Commit 40a0b238 by yinyong

定时自动作废过期财务驳回费用单

parent db6074d4
package com.blt.other.other_cost.config;
import com.blt.other.other_cost.job.CostStatusSyncJob;
import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class CostStatusSyncConfiguration {
// 扫描主体列表时间间隔:(秒)
private static final int TIME = 3;
// JobDetail 定义要执行的 job
@Bean
public JobDetail costCompanySyncJobJobDetail(){
return JobBuilder.newJob(CostStatusSyncJob.class)
.withIdentity("costStatusSyncJob")
.storeDurably().build();
}
// 触发 Bean 的 Trigger
@Bean
public Trigger costCompanySyncJobTrigger(){
SimpleScheduleBuilder simpleScheduleBuilder = SimpleScheduleBuilder.simpleSchedule()
.withIntervalInHours(TIME).repeatForever();
return TriggerBuilder.newTrigger().forJob(costCompanySyncJobJobDetail())
.withIdentity("costStatusSuncTrigger")
.withSchedule(simpleScheduleBuilder).build();
}
}
......@@ -120,4 +120,6 @@ public interface CostDao {
List<CostDomain> selectNoPayCost(@Param("list") List<String> costNoList);
Integer selectCostStatusByNo(@Param("costNo") String costNo);
List<CostDto> getCostByRejectStatus();
}
package com.blt.other.other_cost.job;
import com.blt.other.other_auth.dao.UserDao;
import com.blt.other.other_cost.dao.CostDao;
import com.blt.other.other_cost.dao.CostLogDao;
import com.blt.other.other_cost.dto.CostDto;
import com.blt.other.other_cost.service.CostService;
import com.blt.other.other_database.model.CostDomain;
import com.blt.other.other_database.model.CostLogDomain;
import com.blt.other.other_database.model.UserDomain;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.quartz.QuartzJobBean;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
public class CostStatusSyncJob extends QuartzJobBean {
private static Logger logger = LoggerFactory.getLogger(CostCompanySyncJob.class);
@Autowired
private CostService costService;
@Autowired
private CostLogDao costLogDao;
@Autowired
private CostDao costDao;
@Autowired
private UserDao userDao;
@Override
protected void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException {
List<CostDto> costDtoList = costService.getCostByRejectStatus();
for(CostDto costDto : costDtoList) {
CostDomain costDomain = new CostDomain();
costDomain.setCostNo(costDto.getCostNo());
costDomain.setCostStatus(5);
int result = costDao.update(costDomain);
if(result > 0) {
CostLogDomain costLog = new CostLogDomain();
costLog.setCostNo(costDto.getCostNo());
costLog.setUpdateTime(new Date());
UserDomain user = userDao.selectByuserid(2493);
costLog.setUpdateUsercode(user.getUsercode());
costLog.setUpdateUserid(2493);
costLog.setUpdateUsername(user.getUsername());
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
costLog.setUpdateNote(sdf.format(costLog.getUpdateTime())+" 过期财务驳回单系统自动作废 更新人:"+user.getUsername());
costLogDao.insert(costLog);
}
}
}
}
......@@ -99,4 +99,6 @@ public interface CostService {
List<CostDto> getLinkLendCost(Integer createuserid);
Integer getCostStatusByNo(String costNo);
List<CostDto> getCostByRejectStatus();
}
......@@ -357,6 +357,11 @@ public class CostServiceImpl implements CostService {
}
@Override
public List<CostDto> getCostByRejectStatus() {
return costDao.getCostByRejectStatus();
}
@Override
public CostDomain getCostDomainByNo(String costNo) {
CostDomain costDomain = costDao.selectByCostNo(costNo);
return costDomain;
......
......@@ -555,4 +555,8 @@
<select id="selectCostStatusByNo" resultType="integer">
select cost_status from cost where cost_no=#{costNo}
</select>
<select id="getCostByRejectStatus" resultType="com.blt.other.other_cost.dto.CostDto">
select * from cost where cost_status = 3 and reject_type = 1 and reject_time <![CDATA[<]]> date_sub(now(),INTERVAL 1 DAY)
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment