法规意见收集流程定时器:当前日期大于数据截止日期,自动提交未提交的任务以及更新状态。

This commit is contained in:
wangzhijiang
2022-06-30 15:02:46 +08:00
parent f43ddc3617
commit 13cf7620d9
3 changed files with 68 additions and 2 deletions
@@ -8,8 +8,8 @@ import org.apache.commons.lang3.StringUtils;
*/
public enum GatherResultEnum {
UNDERWAY("进行中","underway","underway"),
COMPLETED("已完成","completed","completed"),
UNDERWAY("进行中","Underway","Underway"),
COMPLETED("已完成","Completed","Completed"),
;
@@ -0,0 +1,64 @@
package com.jero.modules.lawsOpinionGather.job;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jero.common.api.vo.Result;
import com.jero.modules.lawsOpinionGather.entity.LawsOpinionGatherEO;
import com.jero.modules.lawsOpinionGather.enums.GatherResultEnum;
import com.jero.modules.lawsOpinionGather.service.ILawsOpinionGatherEOService;
import com.jero.modules.wkflow.feginClient.WorkFlowFeignClient;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.jeecg.modules.jmreport.common.constant.CommonConstant;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
* 法规意见收集表 - 定时器
* 作用:当前日期大于等于截止日志的时候,把该数据的收集结果,更新为已完成,同时把当前这条数据的所有待办任务提交
*/
@Slf4j
public class LawsOpinionGatherJob implements Job {
@Autowired
private ILawsOpinionGatherEOService lawsOpinionGatherEOService;
@Autowired
private WorkFlowFeignClient workFlowFeignClient;
@Override
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
log.info("法规意见收集流程,定时任务开启 =====================================================");
QueryWrapper<LawsOpinionGatherEO> lawsOpinionGatherEOQueryWrapper = new QueryWrapper<>();
lawsOpinionGatherEOQueryWrapper.lambda().eq(LawsOpinionGatherEO::getGatherResult, GatherResultEnum.UNDERWAY.getValue());
List<LawsOpinionGatherEO> lawsOpinionGatherEOList = this.lawsOpinionGatherEOService.list(lawsOpinionGatherEOQueryWrapper);
if (CollectionUtils.isNotEmpty(lawsOpinionGatherEOList)) {
Date currentDate = new Date();
List<LawsOpinionGatherEO> updateLawsOpinionGatherEOList = lawsOpinionGatherEOList.stream().filter(e -> {
boolean flag = false;
if(currentDate.after(e.getEndTime())){
flag = true;
}
return flag;
}).collect(Collectors.toList());
if(CollectionUtils.isNotEmpty(updateLawsOpinionGatherEOList)){
List<String> actiProcInstIdList = updateLawsOpinionGatherEOList.stream().map(LawsOpinionGatherEO::getActiProcInstId).distinct().collect(Collectors.toList());
String actiProcInstIds = StringUtils.join(actiProcInstIdList,",");
//将这些流程实例下的待办任务提交
Result<String> result = this.workFlowFeignClient.completeTaskByPids(actiProcInstIds);
if(result.getCode().equals(CommonConstant.SC_OK_200)){
updateLawsOpinionGatherEOList.forEach(lawsOpinionGatherEO -> {
lawsOpinionGatherEO.setGatherResult(GatherResultEnum.COMPLETED.getValue());
});
this.lawsOpinionGatherEOService.updateBatchById(updateLawsOpinionGatherEOList);
}
}
}
log.info("法规意见收集流程,定时任务开启 =====================================================");
}
}
@@ -135,4 +135,6 @@ public interface WorkFlowFeignClient {
@RequestMapping(value = "/bat-wkflow/task/queryProcessHistoryByPrcId",method = RequestMethod.GET)
List<Map<String, Object>> queryProcessHistoryByPrcId(@RequestParam("prcId") String prcId, @RequestParam("cut") String cut,@RequestParam("prcType") String prcType,@RequestParam(value="sortWord",required = false)String sortWord, @RequestParam(value="shunxu",required = false) String shunxu);
@RequestMapping(value = "/bat-wkflow/task/completeTaskByPids",method = RequestMethod.GET)
Result<String> completeTaskByPids(@RequestParam("actiProcInstIds") String actiProcInstIds);
}