|
@@ -9,24 +9,29 @@ 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;
|
|
@@ -68,54 +73,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 sysUserService = SpringContextHolder.getBean(SysUserService.class);
|
|
|
+ SysUserService sysUserService1 = SpringContextHolder.getBean(SysUserService.class);
|
|
|
basicMessageService = SpringContextHolder.getBean(BasicMessageService.class);
|
|
|
- ActivitiService activitiService = SpringContextHolder.getBean(ActivitiService.class);
|
|
|
+ ActivitiService activitiService1 = SpringContextHolder.getBean(ActivitiService.class);
|
|
|
RedisUtil redisUtil = SpringContextHolder.getBean(RedisUtil.class);
|
|
|
|
|
|
Task task = taskService.createTaskQuery().executionId(event.getExecutionId()).singleResult();
|
|
@@ -145,7 +150,7 @@ public class ProcessEventListener implements ActivitiEventListener, Serializable
|
|
|
userIds.add(SystemConstant.convertIdToLong(s.trim()));
|
|
|
}
|
|
|
Gson gson = new Gson();
|
|
|
- List<ApproveUserResult> nextApproverPeopleList = sysUserService.findByIdsForResult(userIds);
|
|
|
+ List<ApproveUserResult> nextApproverPeopleList = sysUserService1.findByIdsForResult(userIds);
|
|
|
if (Objects.nonNull(nextApproverPeopleList) && nextApproverPeopleList.size() > 0 && Objects.nonNull(tfFlowLog.getApproveUserApproveType()) && tfFlowLog.getApproveUserApproveType() == CustomFlowMultipleUserApproveTypeEnum.ORDER) {
|
|
|
nextApproverPeopleList.removeAll(nextApproverPeopleList.subList(1, nextApproverPeopleList.size() - 0));
|
|
|
}
|
|
@@ -157,11 +162,11 @@ public class ProcessEventListener implements ActivitiEventListener, Serializable
|
|
|
int currSetup = currFlowTaskResult.getSetup().intValue();
|
|
|
currSetup = currSetup == setupMap.size() - 1 ? 0 : currSetup + 1;
|
|
|
|
|
|
- nextFlowTaskResult = activitiService.getNextFlowTaskResult(setupMap, gson, currSetup, nextFlowTaskResult);
|
|
|
+ nextFlowTaskResult = activitiService1.getNextFlowTaskResult(setupMap, gson, currSetup, nextFlowTaskResult);
|
|
|
CustomFlowVarDto customFlowVarDto = gson.fromJson(gson.toJson(agginessMap.get(nextFlowTaskResult.getTaskKey())), CustomFlowVarDto.class);
|
|
|
if (Objects.nonNull(customFlowVarDto) && Objects.nonNull(customFlowVarDto.getCopyForUserIds()) && customFlowVarDto.getCopyForUserIds().size() > 0) {
|
|
|
Set<String> copyUserSet = new LinkedHashSet(customFlowVarDto.getCopyForUserIds());
|
|
|
- copyUsersList = sysUserService.findByIdsForResult(copyUserSet.stream().map(s -> SystemConstant.convertIdToLong(s)).collect(Collectors.toList()));
|
|
|
+ copyUsersList = sysUserService1.findByIdsForResult(copyUserSet.stream().map(s -> SystemConstant.convertIdToLong(s)).collect(Collectors.toList()));
|
|
|
}
|
|
|
|
|
|
//如果不是并行会签,则每个节点都发
|