Browse Source

流程key枚举

lizhenhao 2 years ago
parent
commit
c802e5691b

+ 7 - 6
jeeplus-plugins/jeeplus-flowable/src/main/java/com/jeeplus/centerservice/controller/ccpm/ReimbursementController.java

@@ -24,8 +24,8 @@ public class ReimbursementController {
      * @return
      */
     @GetMapping("getReimbursementById")
-    public ResponseEntity getReimbursementById(String id) {
-        SaveInfoDto saveInfoDto = reimbursementService.getReimbursementById(id);
+    public ResponseEntity getReimbursementById(String id, String processDefKey) {
+        SaveInfoDto saveInfoDto = reimbursementService.getReimbursementById(id, processDefKey);
         return ResponseEntity.ok (saveInfoDto);
     }
 
@@ -34,11 +34,12 @@ public class ReimbursementController {
      * @param id
      * @param flag yes 审核通过 no 审核失败
      * @param comment 审批意见
+     * @param processDefKey 流程类型
      * @return
      */
     @GetMapping("reimAudit")
-    public ResponseEntity reimAudit(String id, String flag, String comment) {
-        Map<String, Object> resultMap = this.reimbursementService.reimAudit(id, flag, "bmzr", comment);
+    public ResponseEntity reimAudit(String id, String flag, String comment, String processDefKey) {
+        Map<String, Object> resultMap = this.reimbursementService.reimAudit(id, flag, comment, processDefKey);
         return ResponseEntity.ok (resultMap);
     }
 
@@ -48,8 +49,8 @@ public class ReimbursementController {
      * @return
      */
     @GetMapping("reimReapply")
-    public ResponseEntity reimReapply(String id) {
-        Map<String, Object> resultMap = this.reimbursementService.reimAudit(id, "yes", "modifyApply", null);
+    public ResponseEntity reimReapply(String id, String processDefKey) {
+        Map<String, Object> resultMap = this.reimbursementService.reimAudit(id, "yes", null, processDefKey);
         return ResponseEntity.ok (resultMap);
     }
 

+ 85 - 0
jeeplus-plugins/jeeplus-flowable/src/main/java/com/jeeplus/centerservice/enums/TaskAliasEnum.java

@@ -0,0 +1,85 @@
+package com.jeeplus.centerservice.enums;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Objects;
+
+/**
+ * 流程枚举
+ */
+public enum TaskAliasEnum {
+
+    REIMBURSEMENT ("13,102", "Process_1665383385070");
+
+    /**
+     *  ccpm
+     */
+    private String ccpmTaskAlias;
+
+    /**
+     *  cpa
+     */
+    private String cpaTaskAlias;
+
+    TaskAliasEnum(String ccpmTaskAlias, String cpaTaskAlias) {
+        this.ccpmTaskAlias = ccpmTaskAlias;
+        this.cpaTaskAlias = cpaTaskAlias;
+    }
+
+    public String getCcpmTaskAlias() {
+        return ccpmTaskAlias;
+    }
+
+    public String getCpaTaskAlias() {
+        return cpaTaskAlias;
+    }
+
+    public static TaskAliasEnum getByCcpm(String value) {
+        TaskAliasEnum result = null;
+        for (TaskAliasEnum s : values()) {
+            if (s.getCcpmTaskAlias() == value) {
+                result = s;
+                break;
+            }
+        }
+        return result;
+    }
+
+    public static TaskAliasEnum getByCcpmContains(String value) {
+        TaskAliasEnum result = null;
+        for (TaskAliasEnum s : values()) {
+            List<String> stringList = Arrays.asList(s.getCcpmTaskAlias().split(","));
+            if (stringList.contains(value)) {
+                result = s;
+            }
+        }
+        return result;
+    }
+
+    public static TaskAliasEnum getByCpa(String value) {
+        TaskAliasEnum result = null;
+        for (TaskAliasEnum s : values()) {
+            if (s.getCpaTaskAlias() == value) {
+                result = s;
+                break;
+            }
+        }
+        return result;
+    }
+
+    public static List<String> getCcpmListByCpa(String value) {
+        List<String> result = new ArrayList<>();
+        TaskAliasEnum byCpa = getByCpa(value);
+        if (Objects.nonNull(byCpa)) {
+            String[] split = byCpa.getCcpmTaskAlias().split(",");
+            result.addAll(Arrays.asList(split));
+        }
+        return result;
+    }
+
+    @Override
+    public String toString() {
+        return "ccpm:" + this.ccpmTaskAlias + ", cpa:" + this.cpaTaskAlias;
+    }
+}

+ 16 - 7
jeeplus-plugins/jeeplus-flowable/src/main/java/com/jeeplus/centerservice/service/ccpm/CcpmRequest.java

@@ -1,12 +1,16 @@
 package com.jeeplus.centerservice.service.ccpm;
 
+import cn.hutool.core.collection.CollectionUtil;
+import com.jeeplus.centerservice.enums.TaskAliasEnum;
 import com.jeeplus.centerservice.utils.RestTemplateService;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 
 @Service
 @Transactional(rollbackFor = Exception.class)
@@ -18,14 +22,18 @@ public class CcpmRequest {
     /**
      * 根据数据id查询详情
      * @param id
+     * @param processDefKey  流程key:例如 13、102...
      * @return
      */
-    public Object getById(String id, String flowType) {
+    public Object getById(String id, String processDefKey) {
         String token = "";
         Object res = null;
-        if ("13".equals(flowType)) { // 报销详情
+        TaskAliasEnum taskAliasEnum = TaskAliasEnum.getByCcpmContains(processDefKey);
+        // 报销
+        if (taskAliasEnum.getCcpmTaskAlias().equals(TaskAliasEnum.REIMBURSEMENT.getCcpmTaskAlias())) {
             Map<String, Object> paramMap = new HashMap<>();
             paramMap.put("id", id);
+            paramMap.put("processDefKey", processDefKey);
             res = restTemplateService.getCCPM("/a/workreimbursement/workReimbursement/getById", token, paramMap);
         }
         return res;
@@ -33,21 +41,22 @@ public class CcpmRequest {
 
     /**
      * 报销审核 通过、驳回、重新发起
-     * @param resp
-     * @param taskDefKey
-     * @param flag
+     * @param resp 流程详情信息
+     * @param flag 通过或驳回标记:yes通过 no驳回
+     * @param comment 审核意见
+     * @param processDefKey 流程key:例如 13、102...
      * @return
      */
-    public Object saveAuditFunc(Map<String, Object> resp, String taskDefKey, String flag, String comment) {
+    public Object saveAuditFunc(Map<String, Object> resp, String flag, String comment, String processDefKey) {
         String token = "";
         Map<String, Object> createBy = new HashMap<>();
         createBy.put("id", resp.get("handleId").toString());
         Map<String, Object> act = new HashMap<>();
-        act.put("taskDefKey", taskDefKey);
         act.put("flag", flag);
         act.put("comment", comment);
         resp.put("act", act);
         resp.put("createBy", createBy);
+        resp.put("processDefKey", processDefKey);
         Object res = restTemplateService.postCCPM("/a/transpond/transpond/auditDistribute", token, null, resp);
         return res;
     }

+ 8 - 7
jeeplus-plugins/jeeplus-flowable/src/main/java/com/jeeplus/centerservice/service/ccpm/reimbursement/ReimbursementService.java

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.jeeplus.centerservice.dto.reimbursement.SaveInfoDto;
+import com.jeeplus.centerservice.enums.TaskAliasEnum;
 import com.jeeplus.centerservice.service.ccpm.CcpmRequest;
 import com.jeeplus.centerservice.service.ccpm.flow.FlowRequest;
 import com.jeeplus.centerservice.utils.ConvertServiceUtil;
@@ -30,11 +31,12 @@ public class ReimbursementService {
     /**
      * 查询报销待办详情
      * @param id
+     * @param processDefKey  流程key:例如 13、102...
      * @return
      */
-    public SaveInfoDto getReimbursementById(String id) {
+    public SaveInfoDto getReimbursementById(String id, String processDefKey) {
         SaveInfoDto saveInfoDto = new SaveInfoDto();
-        Object response = ccpmRequest.getById(id, "13"); // 报销详情
+        Object response = ccpmRequest.getById(id, processDefKey); // 报销详情
         if (Objects.nonNull(response)) {
             saveInfoDto = ConvertServiceUtil.convertReim(response); // 格式转换
             if (Objects.nonNull(saveInfoDto) && StringUtils.isNotBlank(saveInfoDto.getProcInsId())) {
@@ -60,15 +62,14 @@ public class ReimbursementService {
      * 报销审核通过、驳回
      * @param id
      * @param flag
-     * @param taskDefKey
      * @return
      */
-    public Map<String, Object> reimAudit(String id, String flag, String taskDefKey, String comment) {
+    public Map<String, Object> reimAudit(String id, String flag, String comment, String processDefKey) {
         Map<String, Object> resultMap = new HashMap<>();
-        Object response = ccpmRequest.getById(id, "13"); // 报销详情
+        Object response = ccpmRequest.getById(id, processDefKey); // 报销详情
         if (Objects.nonNull(response)) {
             Map<String, Object> resp = JSONObject.parseObject(JSON.toJSONString(response));
-            Object result = ccpmRequest.saveAuditFunc(resp, taskDefKey, flag, comment); // 审核通过、审核驳回
+            Object result = ccpmRequest.saveAuditFunc(resp, flag, comment, processDefKey); // 审核通过、审核驳回
             if (Objects.nonNull(result)) {
                 resultMap = JSONObject.parseObject(JSON.toJSONString(result));
             } else {
@@ -90,7 +91,7 @@ public class ReimbursementService {
      */
     public Map<String, Object> deleteReim(String id) {
         Map<String, Object> resultMap = new HashMap<>();
-        Object result = flowRequest.deleteNotify(id,"13"); // 13代表报销模块
+        Object result = flowRequest.deleteNotify(id, TaskAliasEnum.REIMBURSEMENT.getCcpmTaskAlias()); // 13代表报销模块
         if (Objects.nonNull(result)) {
             resultMap.putAll(JSONObject.parseObject(JSON.toJSONString(result)));
         } else {