|
@@ -1,12 +1,28 @@
|
|
|
package com.qmth.distributed.print.business.activiti.custom.listener;
|
|
|
|
|
|
+import com.qmth.distributed.print.business.entity.ExamTask;
|
|
|
+import com.qmth.distributed.print.business.entity.TFFlowLog;
|
|
|
+import com.qmth.distributed.print.business.enums.TFCustomTypeEnum;
|
|
|
+import com.qmth.distributed.print.business.service.ExamTaskService;
|
|
|
+import com.qmth.distributed.print.business.service.PrintCommonService;
|
|
|
+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.service.SysUserService;
|
|
|
+import org.activiti.engine.HistoryService;
|
|
|
import org.activiti.engine.delegate.event.ActivitiEvent;
|
|
|
import org.activiti.engine.delegate.event.ActivitiEventListener;
|
|
|
+import org.activiti.engine.history.HistoricVariableInstance;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
import java.io.Serializable;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
+import java.util.Optional;
|
|
|
|
|
|
/**
|
|
|
* @Description: 全局监听
|
|
@@ -29,6 +45,34 @@ 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);
|
|
|
+ ExamTaskService examTaskService = SpringContextHolder.getBean(ExamTaskService.class);
|
|
|
+ PrintCommonService printCommonService = SpringContextHolder.getBean(PrintCommonService.class);
|
|
|
+
|
|
|
+ List<HistoricVariableInstance> historicVariableInstanceList = historyService.createHistoricVariableInstanceQuery().processInstanceId(event.getProcessInstanceId()).list();
|
|
|
+ if (Objects.nonNull(historicVariableInstanceList) && historicVariableInstanceList.size() > 0) {
|
|
|
+ TFFlowLog tfFlowLog = null;
|
|
|
+ for (HistoricVariableInstance h : historicVariableInstanceList) {
|
|
|
+ if (Objects.equals(h.getVariableName(), SystemConstant.APPROVE_TF_FLOW_LOG)) {
|
|
|
+ tfFlowLog = (TFFlowLog) h.getValue();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (Objects.nonNull(tfFlowLog) && Objects.nonNull(tfFlowLog.getObjectTable())) {
|
|
|
+ if (Objects.equals(tfFlowLog.getObjectTable(), TFCustomTypeEnum.ELECTRON_FLOW.getTable())) {//如果是命题任务交卷
|
|
|
+ ExamTask examTask = examTaskService.getById(tfFlowLog.getObjectId());
|
|
|
+ Optional.ofNullable(examTask).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("命题任务为空"));
|
|
|
+ //取命题老师ID
|
|
|
+ SysUser sysUser = sysUserService.getById(examTask.getUserId());
|
|
|
+ try {
|
|
|
+ printCommonService.checkData(examTask.getSchoolId(), examTask.getCourseCode(), examTask.getPaperNumber(), sysUser);
|
|
|
+ } catch (IOException e) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("生成pdf失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
break;
|
|
|
// case ACTIVITY_COMPENSATE:
|
|
|
// // 一个节点将要被补偿。事件包含了将要执行补偿的节点id。
|