工单消息提醒
三圆系统
一键已读
对应路径:/sys/service/impl/SysInfoService
方法名:orderRemind
提示:以下是本篇文章正文内容,下面案例可供参考
源码
@Override
public void orderRemind(CmsWorkOrderTaskVo cmsWorkOrderTaskVo, Integer type, List<Long> ids, String feedbackText) {
try{
//工单消息 通用变量
Long orderId = cmsWorkOrderTaskVo.getId();//工单ID
String TaskName = cmsWorkOrderTaskVo.getTaskName();//工单名称
Integer workTypeId = cmsWorkOrderTaskVo.getWorkTypeId();//工单类型
String workTypeName = cmsWorkOrderTaskVo.getWorkTypeName();//工单类型名称
String status = cmsWorkOrderTaskVo.getStatus();//工单状态 1进行中 2已完成 3终止
//获取下一步处理人ID
Long dealId = 0L;//下一步处理人ID
String dealName = "";//下一步处理人名字
String taskFlowName = "";//流程节点名称
String taskFlowDescribe = "";//流程节点描述
for(int i = 0; i < cmsWorkOrderTaskVo.getFlowList().size(); i++){
if(cmsWorkOrderTaskVo.getFlowList().get(i).getCurrentFlag() == 1){
dealId = cmsWorkOrderTaskVo.getFlowList().get(i).getDealId();//下一步处理人ID
dealName = cmsWorkOrderTaskVo.getFlowList().get(i).getDealName();//下一步处理人名字
taskFlowName = cmsWorkOrderTaskVo.getFlowList().get(i).getTaskFlowName();//流程节点名称
taskFlowDescribe = cmsWorkOrderTaskVo.getFlowList().get(i).getTaskFlowDescribe();//流程节点描述
}
}
Long createId = cmsWorkOrderTaskVo.getCreateId();//创建人ID
Long companyId = cmsWorkOrderTaskVo.getCompanyId();//创建人所属公司ID
Long chargeId = cmsWorkOrderTaskVo.getChargeId();//负责人ID
String sendIds = cmsWorkOrderTaskVo.getSendId();//抄送人ID集合
String dealIds = cmsWorkOrderTaskVo.getDealIds();//处理人ID集合
// 创建全体接收人id集合
String toIds = createId + "," + chargeId + "," + sendIds + "," + dealIds;
List<String> toIdList = new ArrayList();
String[] str = toIds.split(",");
for(int i = 0; i < str.length; i++){
toIdList.add(str[i]);
}
// id集合去重 利用toIdList中的元素创建HashSet集合,此时set中进行了去重操作
HashSet set = new HashSet(toIdList);
toIdList.clear();
toIdList.addAll(set);
Integer priority = cmsWorkOrderTaskVo.getPriority();//优先级1低 2中 3高 4紧急
String priorityText = "";//转换优先级文本
if(priority != null){
switch (priority){
case 1:
priorityText = "低";
break;
case 2:
priorityText = "中";
break;
case 3:
priorityText = "高";
break;
case 4:
priorityText = "紧急";
break;
}
}
//获取计划时间
DateFormat df=new SimpleDateFormat("yyyy-MM-dd hh-mm-ss");
String planStartTime = "";
String planEndTime = "";
String finishTime = "";
Date pStartTime = cmsWorkOrderTaskVo.getPlanStartTime();//计划开始时间
if(pStartTime != null){
planStartTime = df.format(pStartTime);
}
Date pEndTime = cmsWorkOrderTaskVo.getPlanEndTime();//计划结束时间
if(pEndTime != null){
planEndTime = df.format(pEndTime);
}
Date fTime = cmsWorkOrderTaskVo.getFinishTime();//工单完成时间
if(fTime != null){
finishTime = df.format(fTime);
}
Date toDay = new Date();
String remark = cmsWorkOrderTaskVo.getRemark();//大背景描述
if(remark==null){
remark = "无";
}
String terminationRemark = cmsWorkOrderTaskVo.getTerminationRemark();//流程终止,审批拒绝描述
if(terminationRemark==null){
terminationRemark = "无";
}
//创建消息对象
SysInfo sysInfo = new SysInfo();
sysInfo.setCreateTime(toDay);
sysInfo.setType(5);//设置消息类型为工单类型
sysInfo.setIsRead(0);
sysInfo.setSendId(createId);//设置创建人ID为消息发送人ID
String contentTask = "任务工单名称:" + TaskName + "\n\n类型名称:" + workTypeName;//预设任务工单文本
String contentReview = "审批工单名称:" + TaskName + "\n\n类型名称:" + workTypeName;//预设审批工单文本
sysInfo.setOrderId(orderId);//设置工单ID
String adviceTitle = "";//消息题目
String content = "";//消息内容
//以type值区分消息类型
switch (type){
case 1://任务代办
adviceTitle = "【任务待办】" + TaskName;
sysInfo.setAdviceTitle(adviceTitle);//保存消息题目
content = contentTask + "\n\n优先级:" + priorityText + "\n\n计划开始时间:" + planStartTime
+ "\n\n计划结束时间:" + planEndTime + "\n\n流程节点名称:" + taskFlowName + "\n\n流程节点描述:" + taskFlowDescribe;
sysInfo.setContent(content);//保存消息内容
sysInfo.setCompanyId(companyId);//设置工单所属公司
sysInfo.setToId(dealId);//设置to_id为下一节点处理人
sysInfoMapper.insert(sysInfo);
break;
case 2://工单编辑
for(int i = 0; i < toIdList.size(); i++){//遍历全体成员
adviceTitle = "【工单编辑】" + TaskName;
sysInfo.setAdviceTitle(adviceTitle);//保存消息题目
content = contentTask;
sysInfo.setContent(content);//保存消息内容
sysInfo.setCompanyId(companyId);//设置工单所属公司
sysInfo.setToId(Long.valueOf(toIdList.get(i)));//设置每个成员ID为to_id
sysInfoMapper.insert(sysInfo);
}
break;
case 3://工单反馈
for(int i = 0; i < ids.size(); i++){//遍历勾选人ID集合
adviceTitle = "【工单反馈】" + TaskName;
sysInfo.setAdviceTitle(adviceTitle);//保存消息题目
content = contentTask + "\n\n反馈内容:" + feedbackText;
sysInfo.setContent(content);//保存消息内容
sysInfo.setCompanyId(companyId);//设置工单所属公司
sysInfo.setToId(ids.get(i));//设置每个勾选成员ID为to_id
sysInfoMapper.insert(sysInfo);
}
break;
case 4://审批代办
adviceTitle = "【审批待办】" + TaskName;
sysInfo.setAdviceTitle(adviceTitle);//保存消息题目
content = contentReview + "\n\n优先级:" + priorityText + "\n\n计划开始时间:" + planStartTime
+ "\n\n计划结束时间:" + planEndTime + "\n\n描述:" + remark;
sysInfo.setContent(content);//保存消息内容
sysInfo.setCompanyId(companyId);//设置工单所属公司
sysInfo.setToId(dealId);//设置to_id为下一节点处理人
sysInfoMapper.insert(sysInfo);
break;
case 5://工单编辑
for(int i = 0; i < toIdList.size(); i++){//遍历全体成员
adviceTitle = "【工单编辑】" + TaskName;
sysInfo.setAdviceTitle(adviceTitle);//保存消息题目
content = contentReview;
sysInfo.setContent(content);//保存消息内容
sysInfo.setCompanyId(companyId);//设置工单所属公司
sysInfo.setToId(Long.valueOf(toIdList.get(i)));//设置每个成员ID为to_id
sysInfoMapper.insert(sysInfo);
}
break;
case 6://工单反馈
for(int i = 0; i < ids.size(); i++){//遍历勾选人ID集合
adviceTitle = "【工单反馈】" + TaskName;
sysInfo.setAdviceTitle(adviceTitle);//保存消息题目
content = contentReview + "\n\n反馈内容:" + feedbackText;
sysInfo.setContent(content);//保存消息内容
sysInfo.setCompanyId(companyId);//设置工单所属公司
sysInfo.setToId(ids.get(i));//设置每个勾选成员ID为to_id
sysInfoMapper.insert(sysInfo);
}
break;
case 7://审批拒绝
adviceTitle = "【审批拒绝】" + TaskName;
sysInfo.setAdviceTitle(adviceTitle);//保存消息题目
content = contentReview + "\n\n审批人:" + dealName + "\n\n审批状态:已拒绝\n\n说明:" + terminationRemark;
sysInfo.setContent(content);//保存消息内容
sysInfo.setCompanyId(companyId);//设置工单所属公司
sysInfo.setToId(createId);//审批拒绝,设置to_id为创建人ID
sysInfoMapper.insert(sysInfo);
break;
case 8://审批完成
adviceTitle = "【审批完成】" + TaskName;
sysInfo.setAdviceTitle(adviceTitle);//保存消息题目
content = contentReview + "\n\n完成时间:" + finishTime;
sysInfo.setContent(content);//保存消息内容
sysInfo.setCompanyId(companyId);//设置工单所属公司
sysInfo.setToId(createId);//审批拒绝,设置to_id为创建人ID
sysInfoMapper.insert(sysInfo);
break;
case 9://创建任务工单
for(int i = 0; i < toIdList.size(); i++){//遍历全体成员
if(dealId.equals(Long.parseLong(toIdList.get(i)))){//下一节点人员发送任务代办消息
adviceTitle = "【任务待办】" + TaskName;
sysInfo.setAdviceTitle(adviceTitle);//保存消息题目
content = contentTask + "\n\n优先级:" + priorityText + "\n\n计划开始时间:" + planStartTime
+ "\n\n计划结束时间:" + planEndTime + "\n\n流程节点名称:" + taskFlowName + "\n\n流程节点描述:" + taskFlowDescribe;
sysInfo.setContent(content);//保存消息内容
sysInfo.setCompanyId(companyId);//设置工单所属公司
sysInfo.setToId(dealId);//设置to_id为下一节点处理人
sysInfoMapper.insert(sysInfo);
}else{//其他全员发送创建工单消息
adviceTitle = "【创建工单】" + TaskName;
sysInfo.setAdviceTitle(adviceTitle);//保存消息题目
content = contentTask;
sysInfo.setContent(content);//保存消息内容
sysInfo.setCompanyId(companyId);//设置工单所属公司
sysInfo.setToId(Long.valueOf(toIdList.get(i)));//设置每个成员ID为to_id
sysInfoMapper.insert(sysInfo);
}
}
break;
case 10://创建审批工单
for(int i = 0; i < toIdList.size(); i++){//遍历全体成员
if(dealId.equals(Long.parseLong(toIdList.get(i)))){//下一节点人员发送审批代办消息
adviceTitle = "【审批待办】" + TaskName;
sysInfo.setAdviceTitle(adviceTitle);//保存消息题目
content = contentReview + "\n\n优先级:" + priorityText + "\n\n计划开始时间:" + planStartTime
+ "\n\n计划结束时间:" + planEndTime + "\n\n描述:" + remark;
sysInfo.setContent(content);//保存消息内容
sysInfo.setCompanyId(companyId);//设置工单所属公司
sysInfo.setToId(dealId);//设置to_id为下一节点处理人
sysInfoMapper.insert(sysInfo);
}else{//其他全员发送创建工单消息
adviceTitle = "【创建工单】" + TaskName;
sysInfo.setAdviceTitle(adviceTitle);//保存消息题目
content = contentReview;
sysInfo.setContent(content);//保存消息内容
sysInfo.setCompanyId(companyId);//设置工单所属公司
sysInfo.setToId(Long.valueOf(toIdList.get(i)));//设置每个成员ID为to_id
sysInfoMapper.insert(sysInfo);
}
}
break;
}
}catch (Exception e){
e.printStackTrace();
}
}