|
@@ -9,29 +9,24 @@ import com.qmth.distributed.print.business.entity.TFFlowLog;
|
|
|
import com.qmth.distributed.print.business.enums.CustomFlowMultipleUserApproveTypeEnum;
|
|
|
import com.qmth.distributed.print.business.service.ActivitiService;
|
|
|
import com.qmth.distributed.print.business.service.BasicMessageService;
|
|
|
-import com.qmth.distributed.print.business.service.PrintCommonService;
|
|
|
import com.qmth.teachcloud.common.bean.params.ApproveUserResult;
|
|
|
import com.qmth.teachcloud.common.contant.SpringContextHolder;
|
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
|
-import com.qmth.teachcloud.common.entity.SysUser;
|
|
|
import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
|
|
|
import com.qmth.teachcloud.common.enums.FlowApproveOperationEnum;
|
|
|
import com.qmth.teachcloud.common.enums.MessageEnum;
|
|
|
import com.qmth.teachcloud.common.enums.TFCustomTypeEnum;
|
|
|
import com.qmth.teachcloud.common.service.SysUserService;
|
|
|
import com.qmth.teachcloud.common.util.RedisUtil;
|
|
|
-import org.activiti.engine.HistoryService;
|
|
|
import org.activiti.engine.TaskService;
|
|
|
import org.activiti.engine.delegate.event.ActivitiEvent;
|
|
|
import org.activiti.engine.delegate.event.ActivitiEventListener;
|
|
|
import org.activiti.engine.delegate.event.ActivitiProcessStartedEvent;
|
|
|
-import org.activiti.engine.history.HistoricVariableInstance;
|
|
|
import org.activiti.engine.task.Task;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
-import java.io.IOException;
|
|
|
import java.io.Serializable;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -73,54 +68,54 @@ 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);
|
|
|
- SysUserService sysUserService = SpringContextHolder.getBean(SysUserService.class);
|
|
|
- ActivitiService activitiService = SpringContextHolder.getBean(ActivitiService.class);
|
|
|
- PrintCommonService printCommonService = SpringContextHolder.getBean(PrintCommonService.class);
|
|
|
-
|
|
|
- List<HistoricVariableInstance> historicVariableInstanceList = historyService.createHistoricVariableInstanceQuery().processInstanceId(event.getProcessInstanceId()).list();
|
|
|
- if (Objects.nonNull(historicVariableInstanceList) && historicVariableInstanceList.size() > 0) {
|
|
|
- tfFlowLog = null;
|
|
|
- tfFlowApprove = null;
|
|
|
- Object object = null;
|
|
|
- for (HistoricVariableInstance h : historicVariableInstanceList) {
|
|
|
- if (Objects.equals(h.getVariableName(), SystemConstant.APPROVE_TF_FLOW_APPROVE)) {
|
|
|
- tfFlowApprove = (TFFlowApprove) h.getValue();
|
|
|
- Optional.ofNullable(tfFlowApprove).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程流转记录为空"));
|
|
|
- log.info("tfFlowApprove.getStatus():{}", tfFlowApprove.getStatus());
|
|
|
- }
|
|
|
- if (Objects.equals(h.getVariableName(), SystemConstant.APPROVE_TF_FLOW_LOG)) {
|
|
|
- tfFlowLog = (TFFlowLog) h.getValue();
|
|
|
- Optional.ofNullable(tfFlowLog).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程审批日志为空"));
|
|
|
- log.info("tfFlowLog.getApproveOperation():{}", tfFlowLog.getApproveOperation());
|
|
|
- } else if (Objects.equals(h.getVariableName(), SystemConstant.OBJECT_DATA)) {
|
|
|
- object = h.getValue();
|
|
|
- Optional.ofNullable(object).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("实体数据为空"));
|
|
|
- }
|
|
|
- if (Objects.nonNull(object) && Objects.nonNull(tfFlowLog)) {
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- if (Objects.nonNull(tfFlowLog.getObjectTable())) {
|
|
|
- if (Objects.equals(tfFlowLog.getObjectTable(), TFCustomTypeEnum.ELECTRON_FLOW.getTable())) {//如果是命题任务交卷
|
|
|
- //取命题老师ID
|
|
|
- SysUser sysUser = sysUserService.getById(((ExamTask) object).getUserId());
|
|
|
- try {
|
|
|
- printCommonService.checkData(((ExamTask) object).getSchoolId(), ((ExamTask) object).getExamId(), ((ExamTask) object).getCourseCode(), ((ExamTask) object).getPaperNumber(), sysUser);
|
|
|
- } catch (IOException e) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("生成pdf失败");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+// HistoryService historyService = SpringContextHolder.getBean(HistoryService.class);
|
|
|
+// SysUserService sysUserService = SpringContextHolder.getBean(SysUserService.class);
|
|
|
+// ActivitiService activitiService = SpringContextHolder.getBean(ActivitiService.class);
|
|
|
+// PrintCommonService printCommonService = SpringContextHolder.getBean(PrintCommonService.class);
|
|
|
+//
|
|
|
+// List<HistoricVariableInstance> historicVariableInstanceList = historyService.createHistoricVariableInstanceQuery().processInstanceId(event.getProcessInstanceId()).list();
|
|
|
+// if (Objects.nonNull(historicVariableInstanceList) && historicVariableInstanceList.size() > 0) {
|
|
|
+// tfFlowLog = null;
|
|
|
+// tfFlowApprove = null;
|
|
|
+// Object object = null;
|
|
|
+// for (HistoricVariableInstance h : historicVariableInstanceList) {
|
|
|
+// if (Objects.equals(h.getVariableName(), SystemConstant.APPROVE_TF_FLOW_APPROVE)) {
|
|
|
+// tfFlowApprove = (TFFlowApprove) h.getValue();
|
|
|
+// Optional.ofNullable(tfFlowApprove).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程流转记录为空"));
|
|
|
+// log.info("tfFlowApprove.getStatus():{}", tfFlowApprove.getStatus());
|
|
|
+// }
|
|
|
+// if (Objects.equals(h.getVariableName(), SystemConstant.APPROVE_TF_FLOW_LOG)) {
|
|
|
+// tfFlowLog = (TFFlowLog) h.getValue();
|
|
|
+// Optional.ofNullable(tfFlowLog).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程审批日志为空"));
|
|
|
+// log.info("tfFlowLog.getApproveOperation():{}", tfFlowLog.getApproveOperation());
|
|
|
+// } else if (Objects.equals(h.getVariableName(), SystemConstant.OBJECT_DATA)) {
|
|
|
+// object = h.getValue();
|
|
|
+// Optional.ofNullable(object).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("实体数据为空"));
|
|
|
+// }
|
|
|
+// if (Objects.nonNull(object) && Objects.nonNull(tfFlowLog)) {
|
|
|
+// break;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// if (Objects.nonNull(tfFlowLog.getObjectTable())) {
|
|
|
+// if (Objects.equals(tfFlowLog.getObjectTable(), TFCustomTypeEnum.ELECTRON_FLOW.getTable())) {//如果是命题任务交卷
|
|
|
+// //取命题老师ID
|
|
|
+// SysUser sysUser = sysUserService.getById(((ExamTask) object).getUserId());
|
|
|
+// try {
|
|
|
+// printCommonService.checkData(((ExamTask) object).getSchoolId(), ((ExamTask) object).getExamId(), ((ExamTask) object).getCourseCode(), ((ExamTask) object).getPaperNumber(), sysUser);
|
|
|
+// } catch (IOException e) {
|
|
|
+// throw ExceptionResultEnum.ERROR.exception("生成pdf失败");
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
break;
|
|
|
case TASK_COMPLETED:
|
|
|
// 任务被完成了。它会在ENTITY_DELETE事件之前触发。当任务是流程一部分时,事件会在流程继续运行之前, 后续事件将是ACTIVITY_COMPLETE,对应着完成任务的节点。
|
|
|
log.info("流程任务完成_TASK_COMPLETED:ProcessInstanceId:{},ExecutionId:{},ProcessDefinitionId:{}", event.getProcessInstanceId(), event.getExecutionId(), event.getProcessDefinitionId());
|
|
|
TaskService taskService = SpringContextHolder.getBean(TaskService.class);
|
|
|
- sysUserService = SpringContextHolder.getBean(SysUserService.class);
|
|
|
+ SysUserService sysUserService = SpringContextHolder.getBean(SysUserService.class);
|
|
|
basicMessageService = SpringContextHolder.getBean(BasicMessageService.class);
|
|
|
- activitiService = SpringContextHolder.getBean(ActivitiService.class);
|
|
|
+ ActivitiService activitiService = SpringContextHolder.getBean(ActivitiService.class);
|
|
|
RedisUtil redisUtil = SpringContextHolder.getBean(RedisUtil.class);
|
|
|
|
|
|
Task task = taskService.createTaskQuery().executionId(event.getExecutionId()).singleResult();
|