|
@@ -1,17 +1,13 @@
|
|
|
package com.qmth.sop.business.activiti.listener;
|
|
|
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.qmth.sop.business.bean.dto.FlowRejectSequenceDto;
|
|
|
-import com.qmth.sop.business.bean.result.FlowFormWidgetResult;
|
|
|
-import com.qmth.sop.business.bean.result.FlowResult;
|
|
|
-import com.qmth.sop.business.bean.result.FlowTablePropResult;
|
|
|
-import com.qmth.sop.business.bean.result.FlowTaskResult;
|
|
|
+import com.qmth.sop.business.bean.result.*;
|
|
|
import com.qmth.sop.business.entity.*;
|
|
|
-import com.qmth.sop.business.service.SysUserService;
|
|
|
-import com.qmth.sop.business.service.TFCustomFlowService;
|
|
|
-import com.qmth.sop.business.service.TSJobRemindService;
|
|
|
+import com.qmth.sop.business.service.*;
|
|
|
import com.qmth.sop.business.util.SmsSendUtil;
|
|
|
import com.qmth.sop.common.contant.SpringContextHolder;
|
|
|
import com.qmth.sop.common.contant.SystemConstant;
|
|
@@ -64,6 +60,7 @@ public class ProcessEventListener implements ActivitiEventListener, Serializable
|
|
|
TFCustomFlow tfCustomFlow = null;
|
|
|
TFCustomFlowEntity tfCustomFlowEntity = null;
|
|
|
TFFlowApprove tfFlowApprove = null;
|
|
|
+ TFFlowLog tfFlowLog = null;
|
|
|
for (HistoricVariableInstance h : historicVariableInstanceList) {
|
|
|
if (Objects.equals(h.getVariableName(), SystemConstant.FLOW_CUSTOM)) {
|
|
|
tfCustomFlow = (TFCustomFlow) h.getValue();
|
|
@@ -77,8 +74,12 @@ public class ProcessEventListener implements ActivitiEventListener, Serializable
|
|
|
tfFlowApprove = (TFFlowApprove) h.getValue();
|
|
|
Optional.ofNullable(tfFlowApprove).orElseThrow(() -> ExceptionResultEnum.FLOW_APPROVE_NO_DATA.exception());
|
|
|
}
|
|
|
+ if (Objects.equals(h.getVariableName(), SystemConstant.FLOW_APPROVE_LOG)) {
|
|
|
+ tfFlowApprove = (TFFlowApprove) h.getValue();
|
|
|
+ Optional.ofNullable(tfFlowApprove).orElseThrow(() -> ExceptionResultEnum.FLOW_APPROVE_NO_DATA.exception());
|
|
|
+ }
|
|
|
}
|
|
|
- this.sendFlowFinishSms(tfCustomFlow.getType(), tfFlowApprove.getStatus(), tfCustomFlowEntity.getCreateId());
|
|
|
+ this.sendFlowFinishSms(tfCustomFlow.getType(), tfCustomFlowEntity, tfFlowApprove.getStatus(), tfFlowLog);
|
|
|
}
|
|
|
break;
|
|
|
case TASK_CREATED:
|
|
@@ -306,9 +307,6 @@ public class ProcessEventListener implements ActivitiEventListener, Serializable
|
|
|
flowResult.setVersion(tfCustomFlow.getVersion());
|
|
|
tfCustomFlow.setUpdateTime(System.currentTimeMillis());
|
|
|
}
|
|
|
-// if (!CollectionUtils.isEmpty(approveRejectMap)) {
|
|
|
-// flowResult.setApproveRejectMap(approveRejectMap);
|
|
|
-// }
|
|
|
tfCustomFlow.setFlowProcessVar(JacksonUtil.parseJson(flowResult));
|
|
|
tfCustomFlowService.saveOrUpdate(tfCustomFlow);
|
|
|
} catch (DocumentException e) {
|
|
@@ -339,22 +337,61 @@ public class ProcessEventListener implements ActivitiEventListener, Serializable
|
|
|
* 发送流程结束短信
|
|
|
*
|
|
|
* @param type
|
|
|
+ * @param tfCustomFlowEntity
|
|
|
* @param status
|
|
|
- * @param userId
|
|
|
+ * @param tfFlowLog
|
|
|
*/
|
|
|
- protected void sendFlowFinishSms(TFCustomTypeEnum type, FlowStatusEnum status, Long userId) {
|
|
|
- SysUserService sysUserService = SpringContextHolder.getBean(SysUserService.class);
|
|
|
+ protected void sendFlowFinishSms(TFCustomTypeEnum type, TFCustomFlowEntity tfCustomFlowEntity, FlowStatusEnum status, TFFlowLog tfFlowLog) {
|
|
|
SmsSendUtil smsSendUtil = SpringContextHolder.getBean(SmsSendUtil.class);
|
|
|
+ SysMessageService sysMessageService = SpringContextHolder.getBean(SysMessageService.class);
|
|
|
+ TFCustomFlowEntityService tfCustomFlowEntityService = SpringContextHolder.getBean(TFCustomFlowEntityService.class);
|
|
|
|
|
|
if ((type == TFCustomTypeEnum.DING_EXCEPTION_FLOW
|
|
|
|| type == TFCustomTypeEnum.PROJECT_EXCHANGE_FLOW) &&
|
|
|
status == FlowStatusEnum.FINISH) {//流程结束发送短信
|
|
|
- SysUser sysUser = sysUserService.getById(userId);
|
|
|
- Optional.ofNullable(sysUser).orElseThrow(() -> ExceptionResultEnum.USER_NO_EXISTS.exception());
|
|
|
+ FlowTaskMsgResult flowTaskMsgResult = tfCustomFlowEntityService.getFlowTaskRemindMsgInfo(tfCustomFlowEntity.getId(), tfCustomFlowEntity.getCreateId());
|
|
|
+ Optional.ofNullable(flowTaskMsgResult).orElseThrow(() -> ExceptionResultEnum.USER_NO_EXISTS.exception());
|
|
|
|
|
|
+ SysMessage sysMessage = null;
|
|
|
+ String configKey = null, content = null;
|
|
|
Map<String, Object> templateParam = new HashMap<>();
|
|
|
- templateParam.put("code", "test");
|
|
|
- smsSendUtil.sendSms(sysUser.getMobileNumber(), SystemConstant.SMS_TPL_CODE, templateParam);
|
|
|
+ templateParam.put("userName", flowTaskMsgResult.getRealName());
|
|
|
+ if (type == TFCustomTypeEnum.DING_EXCEPTION_FLOW) {//考勤异常
|
|
|
+ content = MessageEnum.NOTICE_OF_DING_EXCEPTION.getTemplate();
|
|
|
+ content = content.replaceAll("\\$\\{userName\\}", flowTaskMsgResult.getRealName());
|
|
|
+ content = content.replaceAll("\\$\\{dingDate\\}", DateUtil.format(new Date(flowTaskMsgResult.getApplyTime()), SystemConstant.DEFAULT_DATE_PATTERN));
|
|
|
+ content = content.replaceAll("\\$\\{approveRemark\\}", tfFlowLog.getApproveRemark());
|
|
|
+
|
|
|
+ configKey = SystemConstant.SMS_TPL_CODE;
|
|
|
+ templateParam.put("dingDate", DateUtil.format(new Date(flowTaskMsgResult.getApplyTime()), SystemConstant.DEFAULT_DATE_PATTERN));
|
|
|
+ templateParam.put("approveRemark", tfFlowLog.getApproveRemark());
|
|
|
+
|
|
|
+ sysMessage = new SysMessage(tfCustomFlowEntity.getCrmNo(), tfCustomFlowEntity.getCode(),
|
|
|
+ MessageTypeEnum.EXCEPTION_APPROVE,
|
|
|
+ type.name(), flowTaskMsgResult.getServiceId(), tfCustomFlowEntity.getCreateId(), content);
|
|
|
+
|
|
|
+ configKey = SystemConstant.SMS_TPL_CODE;
|
|
|
+ } else if (type == TFCustomTypeEnum.PROJECT_EXCHANGE_FLOW) {//项目计划变更
|
|
|
+ content = MessageEnum.NOTICE_OF_PROJECT_EXCHANGE.getTemplate();
|
|
|
+ content = content.replaceAll("\\$\\{userName\\}", flowTaskMsgResult.getRealName());
|
|
|
+ content = content.replaceAll("\\$\\{serviceName\\}", flowTaskMsgResult.getServiceName());
|
|
|
+ content = content.replaceAll("\\$\\{customName\\}", flowTaskMsgResult.getCustomName());
|
|
|
+ content = content.replaceAll("\\$\\{exchangeType\\}", flowTaskMsgResult.getExchangeType().getTitle());
|
|
|
+
|
|
|
+ configKey = SystemConstant.SMS_TPL_CODE;
|
|
|
+ templateParam.put("serviceName", flowTaskMsgResult.getServiceName());
|
|
|
+ templateParam.put("customName", flowTaskMsgResult.getCustomName());
|
|
|
+ templateParam.put("exchangeType", flowTaskMsgResult.getExchangeType().getTitle());
|
|
|
+
|
|
|
+ sysMessage = new SysMessage(tfCustomFlowEntity.getCrmNo(), tfCustomFlowEntity.getCode(),
|
|
|
+ MessageTypeEnum.SYSTEM_PLAN_CHANGE,
|
|
|
+ type.name(), flowTaskMsgResult.getServiceId(), tfCustomFlowEntity.getCreateId(), content);
|
|
|
+ }
|
|
|
+ //发送消息
|
|
|
+ sysMessageService.saveSysMessage(Arrays.asList(sysMessage));
|
|
|
+
|
|
|
+ //发送短信
|
|
|
+ smsSendUtil.sendSms(flowTaskMsgResult.getMobileNumber(), configKey, templateParam);
|
|
|
}
|
|
|
}
|
|
|
}
|