|
@@ -9,16 +9,20 @@ 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.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.util.SmsSendUtil;
|
|
|
import com.qmth.sop.common.contant.SpringContextHolder;
|
|
|
import com.qmth.sop.common.contant.SystemConstant;
|
|
|
import com.qmth.sop.common.enums.*;
|
|
|
import com.qmth.sop.common.util.JacksonUtil;
|
|
|
+import org.activiti.engine.HistoryService;
|
|
|
import org.activiti.engine.TaskService;
|
|
|
import org.activiti.engine.delegate.event.ActivitiEntityEvent;
|
|
|
import org.activiti.engine.delegate.event.ActivitiEvent;
|
|
|
import org.activiti.engine.delegate.event.ActivitiEventListener;
|
|
|
+import org.activiti.engine.history.HistoricVariableInstance;
|
|
|
import org.activiti.engine.impl.persistence.entity.ResourceEntity;
|
|
|
import org.activiti.engine.task.IdentityLink;
|
|
|
import org.activiti.engine.task.Task;
|
|
@@ -53,6 +57,42 @@ public class ProcessEventListener implements ActivitiEventListener, Serializable
|
|
|
case PROCESS_COMPLETED:
|
|
|
// 流程结束
|
|
|
log.info("流程结束_PROCESS_COMPLETED:ProcessInstanceId:{},ExecutionId:{},ProcessDefinitionId:{}", event.getProcessInstanceId(), event.getExecutionId(), event.getProcessDefinitionId());
|
|
|
+ HistoryService historyService = SpringContextHolder.getBean(HistoryService.class);
|
|
|
+ SmsSendUtil smsSendUtil = SpringContextHolder.getBean(SmsSendUtil.class);
|
|
|
+ SysUserService sysUserService = SpringContextHolder.getBean(SysUserService.class);
|
|
|
+
|
|
|
+ List<HistoricVariableInstance> historicVariableInstanceList = historyService.createHistoricVariableInstanceQuery().processInstanceId(event.getProcessInstanceId()).list();
|
|
|
+ if (!CollectionUtils.isEmpty(historicVariableInstanceList)) {
|
|
|
+ TFCustomFlow tfCustomFlow = null;
|
|
|
+ TFCustomFlowEntity tfCustomFlowEntity = null;
|
|
|
+ TFFlowApprove tfFlowApprove = null;
|
|
|
+ for (HistoricVariableInstance h : historicVariableInstanceList) {
|
|
|
+ if (Objects.equals(h.getVariableName(), SystemConstant.FLOW_CUSTOM)) {
|
|
|
+ tfCustomFlow = (TFCustomFlow) h.getValue();
|
|
|
+ Optional.ofNullable(tfCustomFlow).orElseThrow(() -> ExceptionResultEnum.FLOW_CUSTOM_NO_DATA.exception());
|
|
|
+ }
|
|
|
+ if (Objects.equals(h.getVariableName(), SystemConstant.FLOW_ENTITY)) {
|
|
|
+ tfCustomFlowEntity = (TFCustomFlowEntity) h.getValue();
|
|
|
+ Optional.ofNullable(tfCustomFlowEntity).orElseThrow(() -> ExceptionResultEnum.FLOW_ENTITY_NO_DATA.exception());
|
|
|
+ }
|
|
|
+ if (Objects.equals(h.getVariableName(), SystemConstant.FLOW_APPROVE)) {
|
|
|
+ tfFlowApprove = (TFFlowApprove) h.getValue();
|
|
|
+ Optional.ofNullable(tfFlowApprove).orElseThrow(() -> ExceptionResultEnum.FLOW_APPROVE_NO_DATA.exception());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ((tfCustomFlow.getType() == TFCustomTypeEnum.OFFICE_SOP_FLOW
|
|
|
+ || tfCustomFlow.getType() == TFCustomTypeEnum.CLOUD_MARK_SOP_FLOW
|
|
|
+ || tfCustomFlow.getType() == TFCustomTypeEnum.DING_EXCEPTION_FLOW
|
|
|
+ || tfCustomFlow.getType() == TFCustomTypeEnum.PROJECT_EXCHANGE_FLOW) &&
|
|
|
+ tfFlowApprove.getStatus() == FlowStatusEnum.FINISH) {
|
|
|
+ SysUser sysUser = sysUserService.getById(tfCustomFlowEntity.getCreateId());
|
|
|
+ Optional.ofNullable(sysUser).orElseThrow(() -> ExceptionResultEnum.USER_NO_EXISTS.exception());
|
|
|
+
|
|
|
+ Map<String, Object> templateParam = new HashMap<>();
|
|
|
+ templateParam.put("code", "test");
|
|
|
+ smsSendUtil.sendSms(sysUser.getMobileNumber(), SystemConstant.SMS_TPL_CODE, templateParam);
|
|
|
+ }
|
|
|
+ }
|
|
|
break;
|
|
|
case TASK_CREATED:
|
|
|
log.info("流程任务创建_TASK_CREATED:ProcessInstanceId:{},ExecutionId:{},ProcessDefinitionId:{}", event.getProcessInstanceId(), event.getExecutionId(), event.getProcessDefinitionId());
|