Преглед изворни кода

Merge branch 'dev_v3.0.0' of http://git.qmth.com.cn/wangliang/distributed-print-service into dev_v3.0.0

xiaof пре 3 година
родитељ
комит
1713af5b5e

+ 38 - 15
distributed-print-business/src/main/java/com/qmth/distributed/print/business/activiti/custom/listener/ProcessEventListener.java

@@ -1,11 +1,13 @@
 package com.qmth.distributed.print.business.activiti.custom.listener;
 
 import com.google.gson.Gson;
-import com.google.gson.reflect.TypeToken;
+import com.qmth.distributed.print.business.bean.flow.CustomFlowVarDto;
+import com.qmth.distributed.print.business.bean.result.FlowTaskResult;
 import com.qmth.distributed.print.business.entity.ExamTask;
 import com.qmth.distributed.print.business.entity.TFFlowLog;
 import com.qmth.distributed.print.business.enums.CustomFlowMultipleUserApproveTypeEnum;
 import com.qmth.distributed.print.business.enums.MessageEnum;
+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;
@@ -16,7 +18,6 @@ import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
 import com.qmth.teachcloud.common.enums.FlowApproveOperationEnum;
 import com.qmth.teachcloud.common.enums.TFCustomTypeEnum;
 import com.qmth.teachcloud.common.service.SysUserService;
-import com.qmth.teachcloud.common.util.JacksonUtil;
 import org.activiti.engine.HistoryService;
 import org.activiti.engine.TaskService;
 import org.activiti.engine.delegate.event.ActivitiEvent;
@@ -31,6 +32,7 @@ import org.springframework.stereotype.Component;
 import java.io.IOException;
 import java.io.Serializable;
 import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * @Description: 全局监听
@@ -105,6 +107,7 @@ public class ProcessEventListener implements ActivitiEventListener, Serializable
                 TaskService taskService = SpringContextHolder.getBean(TaskService.class);
                 sysUserService = SpringContextHolder.getBean(SysUserService.class);
                 basicMessageService = SpringContextHolder.getBean(BasicMessageService.class);
+                ActivitiService activitiService = SpringContextHolder.getBean(ActivitiService.class);
 
                 Task task = taskService.createTaskQuery().executionId(event.getExecutionId()).singleResult();
                 if (Objects.nonNull(task)) {
@@ -112,6 +115,11 @@ public class ProcessEventListener implements ActivitiEventListener, Serializable
                     Optional.ofNullable(tfFlowLog).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程审批日志为空"));
                     o = taskService.getVariable(task.getId(), SystemConstant.OBJECT_DATA);
                     Optional.ofNullable(o).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("实体数据为空"));
+                    Map<String, CustomFlowVarDto> agginessMap = (Map<String, CustomFlowVarDto>) taskService.getVariable(task.getId(), SystemConstant.AGGINESS_MAP);
+                    Optional.ofNullable(agginessMap).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程审批数据为空"));
+                    Map<String, FlowTaskResult> setupMap = (Map<String, FlowTaskResult>) taskService.getVariable(task.getId(), SystemConstant.SETUP_MAP);
+                    Optional.ofNullable(setupMap).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程审批步骤数据为空"));
+
                     if (tfFlowLog.getApproveOperation() != FlowApproveOperationEnum.SUBMIT
                             && tfFlowLog.getApproveOperation() != FlowApproveOperationEnum.END
                             && tfFlowLog.getApproveOperation() != FlowApproveOperationEnum.FINISH) {
@@ -121,29 +129,44 @@ public class ProcessEventListener implements ActivitiEventListener, Serializable
                             for (String s : strs) {
                                 userIds.add(SystemConstant.convertIdToLong(s.trim()));
                             }
-                            List<SysUser> sysUsers = sysUserService.listByIds(userIds);
-                            List<ApproveUserResult> sysUserList = new Gson().fromJson(JacksonUtil.parseJson(sysUsers), new TypeToken<List<ApproveUserResult>>() {
-                            }.getType());
-
-                            List<ApproveUserResult> nextApproverPeopleList = new ArrayList<>();
-                            nextApproverPeopleList.addAll(sysUserList);
-                            if (Objects.nonNull(tfFlowLog.getApproveUserApproveType()) && tfFlowLog.getApproveUserApproveType() == CustomFlowMultipleUserApproveTypeEnum.ORDER) {
-                                nextApproverPeopleList.clear();
-                                nextApproverPeopleList.add(sysUserList.get(0));
+                            Gson gson = new Gson();
+                            List<ApproveUserResult> nextApproverPeopleList = sysUserService.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));
                             }
 
-                            if (Objects.nonNull(nextApproverPeopleList) && (tfFlowLog.getApproveOperation() == FlowApproveOperationEnum.APPROVE
-                                    || tfFlowLog.getApproveOperation() == FlowApproveOperationEnum.EXCHANGE)) {
+                            if (Objects.nonNull(nextApproverPeopleList) && tfFlowLog.getApproveOperation() == FlowApproveOperationEnum.APPROVE) {
+                                List<ApproveUserResult> copyUsersList = null;
+                                FlowTaskResult nextFlowTaskResult = null;
+                                FlowTaskResult currFlowTaskResult = gson.fromJson(gson.toJson(setupMap.get(task.getTaskDefinitionKey())), FlowTaskResult.class);
+                                int currSetup = currFlowTaskResult.getSetup().intValue();
+                                currSetup = currSetup == setupMap.size() - 1 ? 0 : currSetup + 1;
+
+                                nextFlowTaskResult = activitiService.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()));
+                                }
+
                                 //如果不是并行会签,则每个节点都发
-                                if (Objects.nonNull(tfFlowLog.getApproveUserApproveType()) && tfFlowLog.getApproveUserApproveType() != CustomFlowMultipleUserApproveTypeEnum.ALL) {
+                                if (Objects.nonNull(tfFlowLog.getApproveUserApproveType()) && tfFlowLog.getApproveUserApproveType() == CustomFlowMultipleUserApproveTypeEnum.ORDER) {
                                     if (Objects.nonNull(o) && o instanceof ExamTask) {
                                         basicMessageService.sendNoticeTaskAuditFlow((ExamTask) o, nextApproverPeopleList, MessageEnum.NOTICE_OF_AUDIT_CREATED);
+                                        //抄送短信
+                                        if (Objects.nonNull(copyUsersList) && copyUsersList.size() > 0) {
+                                            basicMessageService.sendNoticeAuditCopyUser((ExamTask) o, copyUsersList, nextApproverPeopleList.get(0).getRealName(), MessageEnum.NOTICE_OF_AUDIT_COPY_USER);
+                                        }
                                     }
                                 } else {
-                                    if (Objects.isNull(tfFlowLog.getApproveMultiSetup()) || tfFlowLog.getApproveMultiSetup().intValue() == 0) {
+                                    if (Objects.isNull(tfFlowLog.getApproveMultiSetup())) {
                                         if (Objects.nonNull(o) && o instanceof ExamTask) {
                                             basicMessageService.sendNoticeTaskAuditFlow((ExamTask) o, nextApproverPeopleList, MessageEnum.NOTICE_OF_AUDIT_CREATED);
                                         }
+                                        //抄送短信
+                                        if (Objects.nonNull(copyUsersList) && copyUsersList.size() > 0) {
+                                            basicMessageService.sendNoticeAuditCopyUser((ExamTask) o, copyUsersList, nextApproverPeopleList.stream().map(s -> s.getRealName()).collect(Collectors.toList()).toString().replaceAll("\\[", "").replaceAll("\\]", "").trim(), MessageEnum.NOTICE_OF_AUDIT_COPY_USER);
+                                        }
                                     }
                                 }
                             } else if (Objects.nonNull(nextApproverPeopleList) && (tfFlowLog.getApproveOperation() == FlowApproveOperationEnum.REJECT

+ 0 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/flow/CustomFlowVarDto.java

@@ -58,7 +58,6 @@ public class CustomFlowVarDto implements Serializable {
     @ApiModelProperty(value = "自定义流程发起人指定选择用户类型")
     CustomFlowApproveUserSelectRangeEnum approveUserSelectRange;
 
-
     public CustomFlowVarDto() {
 
     }

+ 8 - 4
distributed-print-business/src/main/java/com/qmth/distributed/print/business/enums/MessageEnum.java

@@ -36,15 +36,19 @@ public enum MessageEnum {
      * 审核待办提醒
      */
     // 命题任务被命题老师提交后触发,业务id为命题任务id,短信发送给考务老师 examTask.getCreateId()
-    NOTICE_OF_AUDIT_CREATED("审核待办生成通知","${userName}您好,${courseNameAndPaperNumber}试卷已提交入库,请您尽快审核!"),
-    NOTICE_OF_AUDIT_REVIEW("审核待办修改申请通知","${userName}您好,${courseNameAndPaperNumber}试卷重新提交修改申请,请您尽快审核!"),
+    NOTICE_OF_AUDIT_CREATED("审核待办生成通知","${userName}您好,${courseName}试卷已提交入库,请您尽快审核!"),
+    NOTICE_OF_AUDIT_REVIEW("审核待办修改申请通知","${userName}您好,${courseName}试卷重新提交修改申请,请您尽快审核!"),
     // 定时任务查询触发,业务id为考务老师id,短信发送给考务老师
     NOTICE_OF_AUDIT_WILL_EXPIRE("审核待办到期预警通知","${userName}您好,您还有${count}条审核待办即将逾期,请您尽快处理!"),
     NOTICE_OF_AUDIT_OVERDUE("审核待办逾期通知","${userName}您好,您有${count}条审核待办已逾期!"),
 
-    NOTICE_OF_AUDIT_REJECT("审核驳回生成通知","${userName}您好,${courseNameAndPaperNumber}试卷审核未通过,请您尽快处理!"),
-    NOTICE_OF_UPLOAD_STRUCTURE("试卷结构标答上传通知","${userName}您好,${courseNameAndPaperNumber}试卷印刷任务已经完成,请上传试卷结构及标答生成阅卷任务,请您尽快处理!");
+    NOTICE_OF_AUDIT_REJECT("审核驳回生成通知","${userName}您好,${courseName}试卷审核未通过,请您尽快处理!"),
+    NOTICE_OF_UPLOAD_STRUCTURE("试卷结构标答上传通知","${userName}您好,${courseName}试卷印刷任务已经完成,请上传试卷结构及标答生成阅卷任务,请您尽快处理!"),
 
+    /**
+     * 审核抄送
+     */
+    NOTICE_OF_AUDIT_COPY_USER("审核抄送生成通知","${userName}您好,${courseName}相关命题任务已经提交,由${auditUserNames}负责审核,请您查看!");
 
     MessageEnum(String name, String template) {
         this.name = name;

+ 15 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/ActivitiService.java

@@ -1,5 +1,6 @@
 package com.qmth.distributed.print.business.service;
 
+import com.google.gson.Gson;
 import com.qmth.distributed.print.business.bean.flow.CustomFlowSaveDto;
 import com.qmth.distributed.print.business.bean.result.FlowInfoResult;
 import com.qmth.distributed.print.business.bean.result.FlowTaskResult;
@@ -101,4 +102,18 @@ public interface ActivitiService {
      * @return
      */
     public FlowInfoResult getFlowInfoByType(TFCustomTypeEnum type, Long flowId);
+
+    /**
+     * 获取下级审核节点
+     *
+     * @param setupMap
+     * @param gson
+     * @param currSetup
+     * @param nextFlowTaskResult
+     * @return
+     */
+    public FlowTaskResult getNextFlowTaskResult(Map<String, FlowTaskResult> setupMap,
+                                                Gson gson,
+                                                int currSetup,
+                                                FlowTaskResult nextFlowTaskResult);
 }

+ 17 - 2
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/BasicMessageService.java

@@ -44,6 +44,7 @@ public interface BasicMessageService extends IService<BasicMessage> {
 
     /**
      * 发送到期预警、逾期提醒
+     *
      * @param messageType
      * @param userId
      * @param ids
@@ -63,11 +64,22 @@ public interface BasicMessageService extends IService<BasicMessage> {
      */
     void sendNoticeTaskAuditFlow(ExamTask examTask, List<ApproveUserResult> users, MessageEnum messageType);
 
+    /**
+     * 发送审核抄送短信
+     *
+     * @param examTask
+     * @param users
+     * @param auditUserNames
+     * @param messageType
+     */
+    void sendNoticeAuditCopyUser(ExamTask examTask, List<ApproveUserResult> users, String auditUserNames, MessageEnum messageType);
+
     /**
      * 发送给命题老师-试卷结构标答上传通知
+     *
      * @param paperNumber 试卷编号
-     * @param courseCode 课程代码
-     * @param userId 命题老师ID
+     * @param courseCode  课程代码
+     * @param userId      命题老师ID
      * @param messageType 短信类型
      * @param sysUser
      */
@@ -75,6 +87,7 @@ public interface BasicMessageService extends IService<BasicMessage> {
 
     /**
      * 查询
+     *
      * @param messageType
      * @param sendStatus
      * @param mobileNumber
@@ -86,12 +99,14 @@ public interface BasicMessageService extends IService<BasicMessage> {
 
     /**
      * 查询短信类型
+     *
      * @return
      */
     List<EnumResult> listMessageTypes();
 
     /**
      * 短信失败重发
+     *
      * @param id
      */
     void resendSmsTaskById(Long id);

+ 17 - 6
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ActivitiServiceImpl.java

@@ -525,7 +525,8 @@ public class ActivitiServiceImpl implements ActivitiService {
                     nextFlowTaskResult,
                     gson,
                     agginessMap,
-                    o);
+                    o,
+                    approvePass);
             //当前实例的执行到哪个节点
             taskService.complete(String.valueOf(flowTaskId), map);
         } catch (Exception e) {
@@ -556,6 +557,7 @@ public class ActivitiServiceImpl implements ActivitiService {
      * @param gson
      * @param agginessMap
      * @param o
+     * @param approvePass
      */
     protected void setApproveInfo(TFFlowApprove tfFlowApprove,
                                   TFFlowLog tfFlowLog,
@@ -568,7 +570,8 @@ public class ActivitiServiceImpl implements ActivitiService {
                                   FlowTaskResult nextFlowTaskResult,
                                   Gson gson,
                                   Map<String, CustomFlowVarDto> agginessMap,
-                                  Object o) {
+                                  Object o,
+                                  FlowApprovePassEnum approvePass) {
         tfFlowApprove.updateInfo(sysUser.getId());
         if (tfFlowLog.getApproveOperation() == FlowApproveOperationEnum.APPROVE) {
             tfFlowApprove.setApproveSetup(nrOfCompletedInstances);
@@ -614,9 +617,15 @@ public class ActivitiServiceImpl implements ActivitiService {
                 }
                 tfFlowLog.setPendApproveId(customFlowVarDto.getApproveIds().toString().replaceAll("\\[", "").replaceAll("\\]", ""));
             }
+            CustomFlowVarDto currCustomFlowVarDto = gson.fromJson(gson.toJson(agginessMap.get(currFlowTaskResult.getTaskKey())), CustomFlowVarDto.class);
+            //说明在两个审批节点交界处
+            if (approvePass == FlowApprovePassEnum.PASS && currCustomFlowVarDto.getMultipleUserApproveType() != customFlowVarDto.getMultipleUserApproveType()) {
+                tfFlowLog.setApproveMultiSetup(null);
+            }
             tfFlowLog.setApproveUserApproveType(customFlowVarDto.getMultipleUserApproveType());
         }
         map.put(SystemConstant.APPROVE_TF_FLOW_LOG, tfFlowLog);
+        map.put(SystemConstant.AGGINESS_MAP, agginessMap);
         tfFlowApproveService.saveOrUpdate(tfFlowApprove);
         tfFlowLogService.save(tfFlowLog);
         if (Objects.nonNull(o) && o instanceof ExamTask) {
@@ -693,6 +702,7 @@ public class ActivitiServiceImpl implements ActivitiService {
                 setFlowTaskVar(customFlowVarDto, map);
             }
         }
+        map.put(SystemConstant.SETUP_MAP, setupMap);
     }
 
     /**
@@ -806,10 +816,11 @@ public class ActivitiServiceImpl implements ActivitiService {
      * @param nextFlowTaskResult
      * @return
      */
-    protected FlowTaskResult getNextFlowTaskResult(Map<String, FlowTaskResult> setupMap,
-                                                   Gson gson,
-                                                   int currSetup,
-                                                   FlowTaskResult nextFlowTaskResult) {
+    @Override
+    public FlowTaskResult getNextFlowTaskResult(Map<String, FlowTaskResult> setupMap,
+                                                Gson gson,
+                                                int currSetup,
+                                                FlowTaskResult nextFlowTaskResult) {
         for (Map.Entry<String, FlowTaskResult> entry : setupMap.entrySet()) {
             FlowTaskResult flowTaskResultTemp = gson.fromJson(gson.toJson(entry.getValue()), FlowTaskResult.class);
             if (flowTaskResultTemp.getSetup().intValue() == currSetup) {

+ 33 - 4
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/BasicMessageServiceImpl.java

@@ -282,7 +282,7 @@ public class BasicMessageServiceImpl extends ServiceImpl<BasicMessageMapper, Bas
             Map<String, Object> jsonMap = new HashMap<>();
             jsonMap.put("userName", userName);
             StringJoiner sj = new StringJoiner("、").add(courseName).add(paperNumber);
-            jsonMap.put("courseNameAndPaperNumber", sj.toString());
+            jsonMap.put("courseName", sj.toString());
             String variableParams = JSON.toJSONString(jsonMap);
             String remark = String.format("命题任务ID:%s", examTask.getId().toString());
             this.saveMessageSendLog(schoolId, userId, userName, mobileNumber, paperNumber, courseCode, variableParams, messageType, sysUser.getId(), remark);
@@ -342,7 +342,36 @@ public class BasicMessageServiceImpl extends ServiceImpl<BasicMessageMapper, Bas
             Map<String, Object> jsonMap = new HashMap<>();
             jsonMap.put("userName", userName);
             StringJoiner sj = new StringJoiner("、").add(courseName).add(paperNumber);
-            jsonMap.put("courseNameAndPaperNumber", sj.toString());
+            jsonMap.put("courseName", sj.toString());
+            String variableParams = JSON.toJSONString(jsonMap);
+            String remark = String.format("命题任务ID:%s", examTask.getId().toString());
+            this.saveMessageSendLog(schoolId, user.getId(), userName, mobileNumber, paperNumber, courseCode, variableParams, messageType, sysUser.getId(), remark);
+        }
+    }
+
+    /**
+     * 发送审核抄送短信
+     *
+     * @param examTask
+     * @param users
+     * @param auditUserNames
+     * @param messageType
+     */
+    @Override
+    public void sendNoticeAuditCopyUser(ExamTask examTask, List<ApproveUserResult> users, String auditUserNames, MessageEnum messageType) {
+        Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
+        SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
+        for (ApproveUserResult user : users) {
+            String userName = user.getRealName();
+            String mobileNumber = user.getMobileNumber();
+            String paperNumber = examTask.getPaperNumber();
+            String courseCode = examTask.getCourseCode();
+            String courseName = examTask.getCourseName();
+            Map<String, Object> jsonMap = new HashMap<>();
+            jsonMap.put("userName", userName);
+            StringJoiner sj = new StringJoiner("、").add(courseName).add(paperNumber);
+            jsonMap.put("courseName", sj.toString());
+            jsonMap.put("auditUserNames", auditUserNames);
             String variableParams = JSON.toJSONString(jsonMap);
             String remark = String.format("命题任务ID:%s", examTask.getId().toString());
             this.saveMessageSendLog(schoolId, user.getId(), userName, mobileNumber, paperNumber, courseCode, variableParams, messageType, sysUser.getId(), remark);
@@ -350,7 +379,7 @@ public class BasicMessageServiceImpl extends ServiceImpl<BasicMessageMapper, Bas
     }
 
     @Override
-    public void sendNoticeUploadStructure(String paperNumber, String courseCode,String courseName, Long userId, MessageEnum messageType, SysUser sysUser) {
+    public void sendNoticeUploadStructure(String paperNumber, String courseCode, String courseName, Long userId, MessageEnum messageType, SysUser sysUser) {
         QueryWrapper<BasicMessage> queryWrapper = new QueryWrapper<>();
         queryWrapper.lambda().eq(BasicMessage::getPaperNumber, paperNumber).eq(BasicMessage::getCourseCode, courseCode).eq(BasicMessage::getUserId, userId).eq(BasicMessage::getMessageType, messageType);
         List<BasicMessage> list = this.list(queryWrapper);
@@ -365,7 +394,7 @@ public class BasicMessageServiceImpl extends ServiceImpl<BasicMessageMapper, Bas
             Map<String, Object> jsonMap = new HashMap<>();
             jsonMap.put("userName", userName);
             StringJoiner sj = new StringJoiner("、").add(courseName).add(paperNumber);
-            jsonMap.put("courseNameAndPaperNumber", sj.toString());
+            jsonMap.put("courseName", sj.toString());
             String variableParams = JSON.toJSONString(jsonMap);
             this.saveMessageSendLog(sysUser.getSchoolId(), userId, userName, mobileNumber, paperNumber, courseCode, variableParams, messageType, sysUser.getId(), null);
         }