法规意见收集模块消息改造完毕

This commit is contained in:
CD
2022-10-27 15:18:42 +08:00
parent 835c005f6c
commit 9a14490f84
4 changed files with 169 additions and 27 deletions
@@ -2,6 +2,7 @@ package com.jero.modules.lawsOpinionGather.job;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jero.common.exception.JeroBootException;
import com.jero.modules.lawsOpinionGather.entity.LawsOpinionGatherEO;
import com.jero.modules.lawsOpinionGather.enums.GatherResultEnum;
import com.jero.modules.lawsOpinionGather.service.ILawsOpinionGatherEOService;
@@ -41,18 +42,45 @@ public class LawsOpinionGatherRemindJob implements Job {
if(CollectionUtils.isNotEmpty(lawsOpinionGatherEOList)){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date currentDate = new Date();
//Date currentDate = new Date();
String now = sdf.format(new Date());
//获取后一天的时间
Calendar calendar=new GregorianCalendar();
calendar.setTime(new Date());
calendar.add(Calendar.DATE,1);
Date nextDay = calendar.getTime();
//Calendar calendar=new GregorianCalendar();
//calendar.setTime(new Date());
//calendar.add(Calendar.DATE,1);
//Date nextDay = calendar.getTime();
String nextDayStr = sdf.format(nextDay);
//String nextDayStr = sdf.format(nextDay);
lawsOpinionGatherEOList.forEach(lawsOpinionGatherEO -> {
if(StringUtils.equals(nextDayStr,sdf.format(lawsOpinionGatherEO.getEndTime()))){
String endTime = sdf.format(lawsOpinionGatherEO.getEndTime());
int days = 0;
try {
days = (int) (sdf.parse(endTime).getTime() - sdf.parse(now).getTime()) / (24 * 60 * 60 * 1000);
} catch (Exception e) {
e.printStackTrace();
throw new JeroBootException("日期转换错误");
}
if (days == 3) {
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_THREE_DAYS_BEFORE_MSG.getValue());
sendJsonObject.put("lawsOpinionGatherId",lawsOpinionGatherEO.getId());
sendJsonObject.put("userIdList",userIdList);
this.lawsOpinionGatherEOService.workFlowSendMsg(sendJsonObject);
}
} else if (endTime.equals(now)) {
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_TODAY_MSG.getValue());
sendJsonObject.put("lawsOpinionGatherId",lawsOpinionGatherEO.getId());
sendJsonObject.put("userIdList",userIdList);
this.lawsOpinionGatherEOService.workFlowSendMsg(sendJsonObject);
}
}
/*if(StringUtils.equals(nextDayStr,sdf.format(lawsOpinionGatherEO.getEndTime()))){
List<String> userIdList = this.workFlowFeignClient.getLawsOpinionGatherFlowAssigneeList(lawsOpinionGatherEO.getId());
if(CollectionUtils.isNotEmpty(userIdList)){
JSONObject sendJsonObject = new JSONObject();
@@ -62,7 +90,7 @@ public class LawsOpinionGatherRemindJob implements Job {
sendJsonObject.put("userIdList",userIdList);
this.lawsOpinionGatherEOService.workFlowSendMsg(sendJsonObject);
}
}
}*/
});
}
@@ -5,9 +5,13 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.jero.common.api.vo.Result;
import com.jero.common.constant.enums.CutEnum;
import com.jero.common.constant.enums.MessageType2Enum;
import com.jero.common.constant.enums.MessageTypeEnum;
import com.jero.common.constant.enums.MsgColorEnum;
import com.jero.common.exception.JeroBootException;
import com.jero.common.system.vo.LoginUser;
import com.jero.modules.feishu.service.IFeishuService;
import com.jero.modules.feishu.vo.FeishuMsg2Vo;
import com.jero.modules.feishu.vo.FeishuMsgVo;
import com.jero.modules.lawsOpinionGather.entity.LawsOpinionGatherEO;
import com.jero.modules.lawsOpinionGather.enums.GatherResultEnum;
@@ -36,6 +40,7 @@ import com.jero.modules.todoCenter.service.IProcessInfoEOService;
import com.jero.modules.wkflow.enums.FlowTypeEnum;
import com.jero.modules.wkflow.feginClient.WorkFlowFeignClient;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.jeecg.modules.jmreport.common.constant.CommonConstant;
@@ -43,6 +48,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
@@ -77,6 +83,8 @@ public class LawsOpinionGatherEOServiceImpl extends ServiceImpl<LawsOpinionGathe
private WorkFlowFeignClient workFlowFeignClient;
@Autowired
private IProcessInfoEOService processInfoEOService;
@Autowired
private IFeishuService feishuService;
/**
* 保存
@@ -196,6 +204,13 @@ public class LawsOpinionGatherEOServiceImpl extends ServiceImpl<LawsOpinionGathe
lawsOpinionGatherEO.setId(jsonObject.getString("id"));
lawsOpinionGatherEO.setGatherResult(jsonObject.getString("gatherResult"));
this.baseMapper.updateById(lawsOpinionGatherEO);
//飞书
JSONObject sendMsgJson = new JSONObject();
sendMsgJson.put("lawsOpinionGatherId",jsonObject.getString("id"));
sendMsgJson.put("initiatorUserId",jsonObject.getString("initiatorUserId"));
sendMsgJson.put("msgType", MsgTypeEnum.LAWS_OPOMOPM_GATHER_COMPLETE_MSG.getValue());
workFlowSendMsg(sendMsgJson);
}
// 发送消息
@@ -273,51 +288,143 @@ public class LawsOpinionGatherEOServiceImpl extends ServiceImpl<LawsOpinionGathe
}
String lawsOpinionGatherId = jsonObject.getString("lawsOpinionGatherId");
String serialNumber = jsonObject.getString("serialNumber"); //文档库编号
//String serialNumber = jsonObject.getString("serialNumber"); //文档库编号
List<String> userIdList = new ArrayList<>();
String msgContentEN = "";
String msgTitle = "";
//String msgContentEN = "";
//String msgTitle = "";
LawsOpinionGatherEO lawsOpinionGatherEO = queryById(lawsOpinionGatherId);
Map<String, String> lawsOpinionGatherPrcInfo = this.workFlowFeignClient.getLawsOpinionGatherPrcInfo(lawsOpinionGatherId);
String initiator = "";
String title = MessageType2Enum.REGULATION_OPINION_COLLECTION.getCn() + "/" + MessageType2Enum.REGULATION_OPINION_COLLECTION.getEn();
String endTime = new SimpleDateFormat("yyyy-MM-dd").format(lawsOpinionGatherEO.getEndTime());//截止日期
String prcNum = lawsOpinionGatherPrcInfo.get("prcNum");
String prcName = lawsOpinionGatherPrcInfo.get("prcName");
String cnContentUpper = "";
String cnContentLower = "";
String enContentUpper = "";
String enContentLower = "";
if(StringUtils.equals(msgType,MsgTypeEnum.LAWS_OPOMOPM_GATHER_START_MSG.getValue())){
userIdList.addAll(Arrays.asList(jsonObject.getString("evaluatorIds").split(",")));
String endTime = jsonObject.getString("endTime"); //截止日期
msgContentEN = "You recieved the Collection of Legislative Comments of "+serialNumber+" . The due date is "+endTime+". Please check and address it in a timely manner.";
msgTitle = "You have a Collection of Legislative Comments task to complete";
//msgContentEN = "You recieved the Collection of Legislative Comments of "+serialNumber+" . The due date is "+endTime+". Please check and address it in a timely manner.";
//msgTitle = "You have a Collection of Legislative Comments task to complete";
String currentUserId = jsonObject.getString("currentUserId"); //当前操作用户id
SysUser currentUser = sysUserService.getBaseMapper().selectOne(new QueryWrapper<SysUser>().lambda().eq(SysUser::getId, currentUserId));
initiator = currentUser.getUsername();
cnContentUpper = "您好,请及时查看处理此项任务,谢谢!";
cnContentLower = "编号: " + prcNum +
"\n标题: " + prcName +
"\n发起人: " + initiator +
"\n截止时间: " + endTime;
enContentUpper = "Hello! Please check and address the task in a timely manner. Thank you!";
enContentLower = "Regulation No: " + prcNum +
"\nTitle: " + prcName +
"\nInitiator: " + initiator +
"\nDue Date: " + endTime;
}else if(StringUtils.equals(msgType,MsgTypeEnum.LAWS_OPOMOPM_GATHER_ENALUATOR_SUBMIT_MSG.getValue())){
String currentUserId = jsonObject.getString("currentUserId"); //当前操作用户id
SysUser currentUser = sysUserService.getBaseMapper().selectOne(new QueryWrapper<SysUser>().lambda().eq(SysUser::getId, currentUserId));
userIdList.add(jsonObject.getString("initiatorUserId"));
msgContentEN = currentUser.getUsername() + " has submitted the collection process of Collection of Legislative Comments of "+serialNumber+", please check it in time.";
msgTitle = "You have a Collection of Legislative Comments task completed";
//msgContentEN = currentUser.getUsername() + " has submitted the collection process of Collection of Legislative Comments of "+serialNumber+", please check it in time.";
//msgTitle = "You have a Collection of Legislative Comments task completed";
initiator = MessageTypeEnum.SYSTEMATIC_NOTIFICATION.getName();
}else if(StringUtils.equals(msgType, MsgTypeEnum.LAWS_OPOMOPM_GATHER_ENALUATOR_EXPIRE_REMIND_MSG.getValue())){
cnContentUpper = "您好,"+ currentUser.getUsername() +"已提交反馈意见,请查看";
cnContentLower = "编号: " + prcNum +
"\n标题: " + prcName +
"\n发起人: " + initiator +
"\n截止时间: " + endTime;
enContentUpper = "Hello! "+ currentUser.getUsername() +" has submitted the comments. Please check it";
enContentLower = "Regulation No: " + lawsOpinionGatherPrcInfo.get("prcNum") +
"\nTitle: " + lawsOpinionGatherPrcInfo.get("prcName") +
"\nInitiator: " + initiator +
"\nDue Date: " + endTime;
} else if (StringUtils.equals(msgType, MsgTypeEnum.LAWS_OPOMOPM_GATHER_ENALUATOR_EXPIRE_REMIND_THREE_DAYS_BEFORE_MSG.getValue())) {
userIdList = (List<String>) jsonObject.get("userIdList");
msgContentEN = "The the Collection of Legislative Comments of "+serialNumber+" will expire tomorrow . Please check and address it in time.";
msgTitle = "You have a Collection of Legislative Comments task to complete";
initiator = MessageTypeEnum.SYSTEMATIC_NOTIFICATION.getName();
cnContentUpper = "您好,该任务将于3天后到期,请及时查看处理,谢谢!";
cnContentLower = "编号: " + prcNum +
"\n标题: " + prcName +
"\n发起人: " + initiator +
"\n截止时间: " + endTime;
enContentUpper = "Hello! This task will expire in 3 days. Please check and address the task in a timely manner. Thank you!";
enContentLower = "Regulation No: " + lawsOpinionGatherPrcInfo.get("prcNum") +
"\nTitle: " + lawsOpinionGatherPrcInfo.get("prcName") +
"\nInitiator: " + initiator +
"\nDue Date: " + endTime;
} else if (StringUtils.equals(msgType, MsgTypeEnum.LAWS_OPOMOPM_GATHER_ENALUATOR_EXPIRE_REMIND_TODAY_MSG.getValue())){
userIdList = (List<String>) jsonObject.get("userIdList");
initiator = MessageTypeEnum.SYSTEMATIC_NOTIFICATION.getName();
cnContentUpper = "您好,该任务将于今天到期,请尽快查看处理,谢谢!";
cnContentLower = "编号: " + prcNum +
"\n标题: " + prcName +
"\n发起人: " + initiator;
enContentUpper = "Hello! This task will expire today. Please check and address the task ASAP. Thank you!";
enContentLower = "Regulation No: " + lawsOpinionGatherPrcInfo.get("prcNum") +
"\nTitle: " + lawsOpinionGatherPrcInfo.get("prcName") +
"\nInitiator: " + initiator;
} else if (StringUtils.equals(msgType, MsgTypeEnum.LAWS_OPOMOPM_GATHER_COMPLETE_MSG.getValue())) {
userIdList.add((String) jsonObject.get("initiatorUserId"));
initiator = MessageTypeEnum.SYSTEMATIC_NOTIFICATION.getName();
cnContentUpper = "您好,该任务已完成,请查看";
cnContentLower = "编号: " + prcNum +
"\n标题: " + prcName +
"\n发起人: " + initiator;
enContentUpper = "Hello! The task is completed. Please check it.";
enContentLower = "Regulation No: " + lawsOpinionGatherPrcInfo.get("prcNum") +
"\nTitle: " + lawsOpinionGatherPrcInfo.get("prcName") +
"\nInitiator: " + initiator;
}
/*else if(StringUtils.equals(msgType, MsgTypeEnum.LAWS_OPOMOPM_GATHER_ENALUATOR_EXPIRE_REMIND_MSG.getValue())){
userIdList = (List<String>) jsonObject.get("userIdList");
//msgContentEN = "The the Collection of Legislative Comments of "+serialNumber+" will expire tomorrow . Please check and address it in time.";
//msgTitle = "You have a Collection of Legislative Comments task to complete";
initiator = MessageTypeEnum.SYSTEMATIC_NOTIFICATION.getName();
}
}*/
List<String> thirdIdList = new ArrayList<>();
List<SysUser> sysUsers = sysUserService.listByIds(userIdList);
if (ObjectUtils.isNotEmpty(sysUsers)) {
thirdIdList = sysUsers.stream().map(SysUser::getThirdId).collect(Collectors.toList());
}
//飞书跳转链接
String hrefFeishu = backUrl + JumpLinkEnum.TASK_AFFIRM_LINK.getLink();
try {
FeishuMsg2Vo feishuMsgVo = new FeishuMsg2Vo();
feishuMsgVo.setTitle(title);
feishuMsgVo.setCnContentUpper(cnContentUpper);
feishuMsgVo.setCnContentLower(cnContentLower);
feishuMsgVo.setEnContentUpper(enContentUpper);
feishuMsgVo.setEnContentLower(enContentLower);
feishuMsgVo.setUrl(hrefFeishu);
feishuMsgVo.setColor(MsgColorEnum.GREEN.getValue()); // 颜色
feishuService.sendCard(thirdIdList.toArray(new String[thirdIdList.size()]), feishuMsgVo);
} catch (IOException e) {
log.error("飞书消息推送失败");
}
//系统内部跳转链接
String href = "<a href='" + JumpLinkEnum.TASK_AFFIRM_LINK.getLink() + "'>" + " View details" + "</a>";
String contentInfo = msgContentEN + " " + href;
//String href = "<a href='" + JumpLinkEnum.TASK_AFFIRM_LINK.getLink() + "'>" + " View details" + "</a>";
//String contentInfo = msgContentEN + " " + href;
Map<String,Object> sendMessageMap = new HashMap<>();
sendMessageMap.put("hrefFeishu",hrefFeishu);
sendMessageMap.put("contentInfo",contentInfo);
//Map<String,Object> sendMessageMap = new HashMap<>();
//sendMessageMap.put("hrefFeishu",hrefFeishu);
//sendMessageMap.put("contentInfo",contentInfo);
SendMessageUtils.sendMessage(msgTitle,msgContentEN,userIdList,lawsOpinionGatherId,sendMessageMap,null,MessageTypeEnum.COLLECTION_OF_LEGISLATIVE_COMMENTS,initiator);
//SendMessageUtils.sendMessage(msgTitle,msgContentEN,userIdList,lawsOpinionGatherId,sendMessageMap,null,MessageTypeEnum.COLLECTION_OF_LEGISLATIVE_COMMENTS,initiator);
}
@Override
@@ -34,6 +34,10 @@ public enum MsgTypeEnum {
LAWS_OPOMOPM_GATHER_START_MSG("法规意见收集发起消息","lawsOpomopmGatherStartMsg"),
LAWS_OPOMOPM_GATHER_ENALUATOR_SUBMIT_MSG("法规意见收集评估人提交任务消息","lawsOpomopmGatherEnaluatorSubmitMsg"),
LAWS_OPOMOPM_GATHER_ENALUATOR_EXPIRE_REMIND_MSG("法规意见收集到期前一天消息","lawsOpomopmGatherExpireRemindMsg"),
LAWS_OPOMOPM_GATHER_ENALUATOR_EXPIRE_REMIND_THREE_DAYS_BEFORE_MSG("法规意见收集到期前三天消息","lawsOpomopmGatherExpireRemindThreeDaysBeforeMsg"),
LAWS_OPOMOPM_GATHER_ENALUATOR_EXPIRE_REMIND_TODAY_MSG("法规意见收集到期当天消息","lawsOpomopmGatherExpireRemindTodayMsg"),
LAWS_OPOMOPM_GATHER_COMPLETE_MSG("法规意见收集任务完成通知消息","lawsOpomopmGatherCompleteMsg"),
LAWS_TECHNOLOGY_EVALUATION_START_MSG("法规技术评估发起消息","lawsTechnologyEvaluationStartMsg"),
LAWS_TECHNOLOGY_EVALUATION_ENALUATOR_SUBMIT_MSG("法规技术评估,评估人提交任务消息","lawsTechnologyEvaluationEnaluatorSubmitMsg"),
@@ -181,4 +181,7 @@ public interface WorkFlowFeignClient {
@RequestMapping(value = "/bat-wkflow/deleteProcessInstanceByPrcIds",method = RequestMethod.GET)
Result<String> deleteProcessInstanceByPrcIds(@RequestParam("prcIds") String prcIds);
@RequestMapping(value = "/bat-wkflow/task/getLawsOpinionGatherPrcInfo",method = RequestMethod.GET)
Map<String,String> getLawsOpinionGatherPrcInfo(@RequestParam("lawsOpinionGatherId") String lawsOpinionGatherId);
}