浏览代码

自定义流程接口修改

wangliang 3 年之前
父节点
当前提交
195db2b9a4

+ 14 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/TExamTaskFlow.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.FieldFill;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import com.qmth.distributed.print.business.enums.ExamTaskFlowTypeEnum;
 import com.qmth.teachcloud.common.contant.SystemConstant;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
@@ -42,6 +43,9 @@ public class TExamTaskFlow implements Serializable {
     @ApiModelProperty(value = "流程等级")
     private Integer level;
 
+    @ApiModelProperty(value = "类型")
+    private ExamTaskFlowTypeEnum type;
+
     @JsonSerialize(using = ToStringSerializer.class)
     @TableField("create_id")
     @ApiModelProperty(value = "创建人")
@@ -55,16 +59,25 @@ public class TExamTaskFlow implements Serializable {
 
     }
 
-    public TExamTaskFlow(Long flowEntityId, Long taskId, Long flowId, Integer level, Long userId) {
+    public TExamTaskFlow(Long flowEntityId, Long taskId, Long flowId, Integer level, ExamTaskFlowTypeEnum type, Long userId) {
         setId(SystemConstant.getDbUuid());
         this.flowEntityId = flowEntityId;
         this.taskId = taskId;
         this.flowId = flowId;
         this.level = level;
+        this.type = type;
         this.createId = userId;
         this.createTime = System.currentTimeMillis();
     }
 
+    public ExamTaskFlowTypeEnum getType() {
+        return type;
+    }
+
+    public void setType(ExamTaskFlowTypeEnum type) {
+        this.type = type;
+    }
+
     public Long getCreateId() {
         return createId;
     }

+ 42 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/enums/ExamTaskFlowTypeEnum.java

@@ -0,0 +1,42 @@
+package com.qmth.distributed.print.business.enums;
+
+import java.util.Objects;
+
+/**
+ * @Description: 流程type
+ * @Param:
+ * @return:
+ * @Author: wangliang
+ * @Date: 2021/12/21
+ */
+public enum ExamTaskFlowTypeEnum {
+
+    NEW("新建"),
+
+    RESTART("重新提交");
+
+    private String title;
+
+    private ExamTaskFlowTypeEnum(String title) {
+        this.title = title;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    /**
+     * 状态转换 toName
+     *
+     * @param title
+     * @return
+     */
+    public static String convertToName(String title) {
+        for (ExamTaskFlowTypeEnum e : ExamTaskFlowTypeEnum.values()) {
+            if (Objects.equals(title, e.getTitle())) {
+                return e.name();
+            }
+        }
+        return null;
+    }
+}

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

@@ -155,7 +155,7 @@ public interface ActivitiService {
      * @param taskId
      * @param approveId
      */
-    public void customFlowStart(Long taskId, Long approveId);
+    public Map<String, Object> customFlowStart(Long taskId, Long approveId);
 
     /**
      * 获取当前流程节点信息

+ 4 - 2
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ActivitiServiceImpl.java

@@ -2174,7 +2174,7 @@ public class ActivitiServiceImpl implements ActivitiService {
      */
     @Override
     @Transactional
-    public void customFlowStart(Long taskId, Long approveId) {
+    public Map<String, Object> customFlowStart(Long taskId, Long approveId) {
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
         TFCustomFlow tfCustomFlow = tfCustomFlowService.findMaxVersion(sysUser.getSchoolId(), sysUser.getOrgId(), TFCustomTypeEnum.ELECTRON_FLOW);
         Optional.ofNullable(tfCustomFlow).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("未找到自定义流程数据"));
@@ -2199,7 +2199,6 @@ public class ActivitiServiceImpl implements ActivitiService {
         tfCustomFlowEntity.setFlowId(SystemConstant.convertIdToLong((String) map.get(SystemConstant.FLOW_ID)));
 
         map.remove(SystemConstant.APPROVE_ID);
-        map.remove(SystemConstant.FLOW_ENTITY_ID);
         map.remove(SystemConstant.PROCESS_DEFINITION_ID);
         map.remove(SystemConstant.FLOW_STATUS);
         map.computeIfAbsent(SystemConstant.ACT_FLOW_ID, v -> tfCustomFlow.getActFlowId());
@@ -2207,6 +2206,7 @@ public class ActivitiServiceImpl implements ActivitiService {
         tfCustomFlow.setUpdateId(sysUser.getId());
         tfCustomFlowEntityService.save(tfCustomFlowEntity);
         tfCustomFlowService.updateById(tfCustomFlow);
+        return map;
     }
 
     /**
@@ -2309,6 +2309,8 @@ public class ActivitiServiceImpl implements ActivitiService {
                 if (flowViewResult.getSetup().intValue() == f.getSetup().intValue()) {//当前审批节点
                     f.setCurrentTask(true);
                     f.setCurrentApproveUsers(sysUser.getRealName() + "(" + sysOrg.getName() + ")");
+                    List<TFFlowLogResult> tfFlowLogResults = tfFlowLogResultMap.get(f.getSetup());
+//                    if()
                     nextFlowSetup = flowViewResult.getSetup().intValue() + 1;
                     nextFlowSetup = nextFlowSetup == setupMap.size() ? 0 : nextFlowSetup;
                 } else {

+ 9 - 5
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamTaskServiceImpl.java

@@ -421,15 +421,18 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
             Long teachingRoomId = basicCourseService.getOrgIdBySchoolIdAndCourseCode(schoolId, examTask.getCourseCode());
             examTask.setOrgId(teachingRoomId);
             examTask.setTeachingRoomId(teachingRoomId);
+            Long flowEntityId = null;
             if (examTask.getUserId() == null) {
                 examTask.setStatus(ExamStatusEnum.DRAFT);
             } else if (examTask.getReview()) {
                 examTask.setStatus(ExamStatusEnum.STAGE);
-                Map<String, Object> map = new HashMap<>();
-                map.computeIfAbsent(SystemConstant.APPROVE_ID, v -> String.valueOf(examTask.getUserId()));
-                map.computeIfAbsent(SystemConstant.TEACHING_ROOM_ID, v -> examTask.getTeachingRoomId());
-                ProcessInstance processInstance = activitiService.flowStart(map);
-                examTask.setFlowId(SystemConstant.convertIdToLong(processInstance.getId()));
+//                Map<String, Object> map = new HashMap<>();
+//                map.computeIfAbsent(SystemConstant.APPROVE_ID, v -> String.valueOf(examTask.getUserId()));
+//                map.computeIfAbsent(SystemConstant.TEACHING_ROOM_ID, v -> examTask.getTeachingRoomId());
+//                ProcessInstance processInstance = activitiService.flowStart(map);
+                Map<String, Object> map = activitiService.customFlowStart(examTask.getId(), examTask.getUserId());
+                examTask.setFlowId(SystemConstant.convertIdToLong((String) map.get(SystemConstant.FLOW_ID)));
+                flowEntityId = SystemConstant.convertIdToLong((String) map.get(SystemConstant.FLOW_ENTITY_ID));
             } else if (!examTask.getReview()) {
                 examTask.setStatus(ExamStatusEnum.STAGE);
             }
@@ -438,6 +441,7 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
             texamTaskFlowMap.computeIfAbsent(SystemConstant.SCHOOL_ID, v -> examTask.getSchoolId());
             texamTaskFlowMap.computeIfAbsent(SystemConstant.EXAM_TASK_ID, v -> examTask.getId());
             texamTaskFlowMap.computeIfAbsent(SystemConstant.FLOW_ID, v -> examTask.getFlowId());
+            texamTaskFlowMap.put(SystemConstant.FLOW_ENTITY_ID, flowEntityId);
             tExamTaskFlowService.saveOrUpdate(texamTaskFlowMap);
         } catch (Exception e) {
             log.error(SystemConstant.LOG_ERROR, e);

+ 7 - 4
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TExamTaskFlowServiceImpl.java

@@ -4,14 +4,17 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qmth.boot.api.exception.ApiException;
 import com.qmth.distributed.print.business.entity.TExamTaskFlow;
+import com.qmth.distributed.print.business.enums.ExamTaskFlowTypeEnum;
 import com.qmth.distributed.print.business.mapper.TExamTaskFlowMapper;
 import com.qmth.distributed.print.business.service.TExamTaskFlowService;
 import com.qmth.teachcloud.common.contant.SystemConstant;
 import com.qmth.teachcloud.common.entity.BasicSchool;
+import com.qmth.teachcloud.common.entity.SysUser;
 import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
 import com.qmth.teachcloud.common.service.CommonCacheService;
 import com.qmth.teachcloud.common.util.RedisUtil;
 import com.qmth.teachcloud.common.util.ResultUtil;
+import com.qmth.teachcloud.common.util.ServletUtil;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -47,9 +50,11 @@ public class TExamTaskFlowServiceImpl extends ServiceImpl<TExamTaskFlowMapper, T
      */
     @Override
     public boolean saveOrUpdate(Map<String, Object> map) {
+        SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
         Long schoolId = (Long) map.get(SystemConstant.SCHOOL_ID);
         Long taskId = (Long) map.get(SystemConstant.EXAM_TASK_ID);
         Long flowId = (Long) map.get(SystemConstant.FLOW_ID);
+        Long flowEntityId = (Long) map.get(SystemConstant.FLOW_ENTITY_ID);
         boolean lock = redisUtil.lock(SystemConstant.REDIS_LOCK_EXAM_TASK_FLOW_PREFIX + flowId, SystemConstant.REDIS_LOCK_EXAM_TASK_FLOW_TIME_OUT);
         if (!lock) {
             throw ExceptionResultEnum.ERROR.exception("该流程正在审批中,请稍候再试!");
@@ -59,8 +64,7 @@ public class TExamTaskFlowServiceImpl extends ServiceImpl<TExamTaskFlowMapper, T
             taskFlowQueryWrapper.lambda().eq(TExamTaskFlow::getTaskId, taskId);
             List<TExamTaskFlow> tExamTaskFlowList = this.list(taskFlowQueryWrapper);
             if (Objects.isNull(tExamTaskFlowList) || tExamTaskFlowList.size() == 0) {
-//                TExamTaskFlow tExamTaskFlow = new TExamTaskFlow(taskId, flowId, 1);
-                TExamTaskFlow tExamTaskFlow = null;
+                TExamTaskFlow tExamTaskFlow = new TExamTaskFlow(flowEntityId, taskId, flowId, 1, ExamTaskFlowTypeEnum.NEW, sysUser.getId());
                 this.save(tExamTaskFlow);
             } else if (Objects.nonNull(tExamTaskFlowList) && tExamTaskFlowList.size() == 1) {
                 Map<String, List<String>> flowSchoolCodeMap = SystemConstant.getFlowSchoolCodeMap();
@@ -68,8 +72,7 @@ public class TExamTaskFlowServiceImpl extends ServiceImpl<TExamTaskFlowMapper, T
                 if (flowSchoolCodeMap.get(SystemConstant.GDYKDX_FLOW_KEY).contains(basicSchool.getCode())) {
                     TExamTaskFlow tExamTaskFlow = tExamTaskFlowList.get(0);
                     Integer level = tExamTaskFlow.getLevel();
-                    TExamTaskFlow tExamTaskFlowSub = null;
-//                    TExamTaskFlow tExamTaskFlowSub = new TExamTaskFlow(taskId, flowId, ++level);
+                    TExamTaskFlow tExamTaskFlowSub = new TExamTaskFlow(flowEntityId, taskId, flowId, ++level, ExamTaskFlowTypeEnum.NEW, sysUser.getId());
                     this.save(tExamTaskFlowSub);
                 }
             }

+ 1 - 2
distributed-print/src/main/java/com/qmth/distributed/print/api/TFCustomFlowController.java

@@ -4,8 +4,6 @@ package com.qmth.distributed.print.api;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.google.gson.Gson;
 import com.google.gson.reflect.TypeToken;
-import com.qmth.boot.api.annotation.Aac;
-import com.qmth.boot.api.annotation.BOOL;
 import com.qmth.boot.api.constant.ApiConstant;
 import com.qmth.boot.api.exception.ApiException;
 import com.qmth.distributed.print.business.bean.flow.CustomFlowDto;
@@ -107,6 +105,7 @@ public class TFCustomFlowController {
                 if (!tfCustomFlow.getEnable()) {
                     throw ExceptionResultEnum.ERROR.exception("自定义流程数据已删除");
                 }
+                tfCustomFlow.setObjectData(JacksonUtil.parseJson(customFlowSaveDto.getCustomFlowLists()));
                 tfCustomFlow.updateInfo(sysUser.getId());
                 tfCustomFlow.setActFlowId(null);
             }