法规技术评估、法规意见收集流程,消息定时器。

This commit is contained in:
wangzhijiang
2022-09-02 13:22:28 +08:00
parent 1fd2324c56
commit 7d6358bc87
3 changed files with 160 additions and 0 deletions
@@ -0,0 +1,70 @@
package com.jero.modules.lawsOpinionGather.job;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
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.project.enums.MsgTypeEnum;
import com.jero.modules.wkflow.feginClient.WorkFlowFeignClient;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
/**
* 法规意见收集表 - 定时器
* 作用:数据还有一天过期时,给代办人发消息
*/
@Slf4j
public class LawsOpinionGatherRemindJob implements Job {
@Autowired
private ILawsOpinionGatherEOService lawsOpinionGatherEOService;
@Autowired
private WorkFlowFeignClient workFlowFeignClient;
@Override
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
//查询出收集结果为未完成的数据。
QueryWrapper<LawsOpinionGatherEO> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(LawsOpinionGatherEO::getGatherResult, GatherResultEnum.UNDERWAY.getValue());
List<LawsOpinionGatherEO> lawsOpinionGatherEOList = this.lawsOpinionGatherEOService.list(queryWrapper);
if(CollectionUtils.isNotEmpty(lawsOpinionGatherEOList)){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date currentDate = new Date();
//获取后一天的时间
Calendar calendar=new GregorianCalendar();
calendar.setTime(new Date());
calendar.add(Calendar.DATE,1);
Date nextDay = calendar.getTime();
String nextDayStr = sdf.format(nextDay);
lawsOpinionGatherEOList.forEach(lawsOpinionGatherEO -> {
if(StringUtils.equals(nextDayStr,sdf.format(lawsOpinionGatherEO.getEndTime()))){
List<String> userIdList = this.workFlowFeignClient.getLawsOpinionGatherFlowAssigneeList(lawsOpinionGatherEO.getId());
if(CollectionUtils.isNotEmpty(userIdList)){
JSONObject sendJsonObject = new JSONObject();
sendJsonObject.put("msgType", MsgTypeEnum.LAWS_OPOMOPM_GATHER_ENALUATOR_EXPIRE_REMIND_MSG.getValue());
sendJsonObject.put("lawsOpinionGatherId",lawsOpinionGatherEO.getId());
sendJsonObject.put("serialNumber",lawsOpinionGatherEO.getSerialNumber());
sendJsonObject.put("userIdList",userIdList);
this.lawsOpinionGatherEOService.workFlowSendMsg(sendJsonObject);
}
}
});
}
}
}
@@ -0,0 +1,87 @@
package com.jero.modules.lawsTechnologyEvaluation.job;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jero.modules.lawsOpinionGather.enums.GatherResultEnum;
import com.jero.modules.lawsTechnologyEvaluation.entity.LawsTechnologyEvaluationEO;
import com.jero.modules.lawsTechnologyEvaluation.entity.LawsTechnologyEvaluationFlowDetailEO;
import com.jero.modules.lawsTechnologyEvaluation.service.ILawsTechnologyEvaluationEOService;
import com.jero.modules.lawsTechnologyEvaluation.service.ILawsTechnologyEvaluationFlowDetailEOService;
import com.jero.modules.project.enums.MsgTypeEnum;
import com.jero.modules.wkflow.feginClient.WorkFlowFeignClient;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
import java.util.stream.Collectors;
/**
* 法规技术评估 - 定时器
* 作用:数据还有一天过期时,给代办人发消息
*/
@Slf4j
public class LawsTechnologyEvaluationRemindJob implements Job {
@Autowired
private WorkFlowFeignClient workFlowFeignClient;
@Autowired
private ILawsTechnologyEvaluationEOService lawsTechnologyEvaluationEOService;
@Autowired
private ILawsTechnologyEvaluationFlowDetailEOService lawsTechnologyEvaluationFlowDetail;
@Override
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
QueryWrapper<LawsTechnologyEvaluationEO> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(LawsTechnologyEvaluationEO::getFlowStatus, GatherResultEnum.UNDERWAY.getValue());
List<LawsTechnologyEvaluationEO> LawsTechnologyEvaluationEOList = this.lawsTechnologyEvaluationEOService.list(queryWrapper);
if(CollectionUtils.isNotEmpty(LawsTechnologyEvaluationEOList)){
List<String> LawsTechnologyEvaluationIdList = LawsTechnologyEvaluationEOList.stream().map(LawsTechnologyEvaluationEO::getId).distinct().collect(Collectors.toList());
QueryWrapper<LawsTechnologyEvaluationFlowDetailEO> detailQueryWrapper = new QueryWrapper<>();
detailQueryWrapper.lambda().in(LawsTechnologyEvaluationFlowDetailEO::getLawsTechnologyEvaluationId,LawsTechnologyEvaluationIdList);
List<LawsTechnologyEvaluationFlowDetailEO> flowDetailList = this.lawsTechnologyEvaluationFlowDetail.list(detailQueryWrapper);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
//获取后一天的时间
Calendar calendar=new GregorianCalendar();
calendar.setTime(new Date());
calendar.add(Calendar.DATE,1);
Date nextDay = calendar.getTime();
String nextDayStr = sdf.format(nextDay);
LawsTechnologyEvaluationEOList.forEach(lawsTechnologyEvaluationEO -> {
if(StringUtils.equals(nextDayStr,sdf.format(lawsTechnologyEvaluationEO.getEndTime()))){
String actiProcInstIds = flowDetailList.stream().filter(flowDetail -> {
boolean flag = false;
if (StringUtils.equals(lawsTechnologyEvaluationEO.getId(), flowDetail.getLawsTechnologyEvaluationId())) {
flag = true;
}
return flag;
}).map(LawsTechnologyEvaluationFlowDetailEO::getActiProcInstId).distinct().collect(Collectors.joining(","));
if(StringUtils.isNotEmpty(actiProcInstIds)){
List<String> userIdList = this.workFlowFeignClient.getTaskAssigneeListByPrcIds(actiProcInstIds);
if(CollectionUtils.isNotEmpty(userIdList)){
JSONObject sendJsonObject = new JSONObject();
sendJsonObject.put("msgType", MsgTypeEnum.LAWS_TECHNOLOGY_EVALUATION_EXPIRE_REMIND_MSG.getValue());
sendJsonObject.put("lawsTechnologyEvaluationId",lawsTechnologyEvaluationEO.getId());
sendJsonObject.put("serialNumber",lawsTechnologyEvaluationEO.getSerialNumber());
sendJsonObject.put("userIdList",userIdList);
this.lawsTechnologyEvaluationEOService.workFlowSendMsg(sendJsonObject);
}
}
}
});
}
}
}
@@ -167,4 +167,7 @@ public interface WorkFlowFeignClient {
@RequestMapping(value = "/bat-wkflow/task/getLawsOpinionGatherFlowAssigneeList",method = RequestMethod.GET)
List<String> getLawsOpinionGatherFlowAssigneeList(@RequestParam("lawsOpinionGatherId") String lawsOpinionGatherId);
@RequestMapping(value = "/bat-wkflow/task/getTaskAssigneeListByPrcIds",method = RequestMethod.GET)
List<String> getTaskAssigneeListByPrcIds(@RequestParam("actiProcInstIds") String actiProcInstIds);
}