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

cpa流程详情、审核操作分发

lizhenhao пре 2 година
родитељ
комит
63d0c5459e

+ 48 - 0
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/centerservice/controller/TranspondController.java

@@ -0,0 +1,48 @@
+package com.jeeplus.test.centerservice.controller;
+
+import com.jeeplus.centerservice.enums.TaskAliasEnum;
+import com.jeeplus.test.centerservice.dto.TranspondDTO;
+import com.jeeplus.test.centerservice.service.TranspondService;
+import com.jeeplus.test.reimbursement.reimbursementInfo.service.ReimbursementInfoService;
+import com.jeeplus.test.reimbursement.reimbursementInfo.service.dto.SaveInfoDto;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import java.util.Map;
+
+/**
+ * 流程审核转发controller
+ */
+@Controller
+@RequestMapping(value = "/transpond")
+public class TranspondController {
+
+    @Resource
+    private ReimbursementInfoService reimbursementInfoService;
+    @Resource
+    private TranspondService transpondService;
+
+    /**
+     * 流程详情分发
+     * @param id
+     * @param processDefKey
+     * @return
+     */
+    @RequestMapping(value = "detailDistribute", method = RequestMethod.GET)
+    @ResponseBody
+    public Object detailDistribute(@RequestParam String id, @RequestParam String processDefKey) {
+        return transpondService.detailDistribute(id, processDefKey);
+    }
+
+    /**
+     * 审核分发操作
+     * @return
+     */
+    @RequestMapping(value = "auditDistribute", method = RequestMethod.POST)
+    @ResponseBody
+    public Map<String,Object> auditDistribute(@RequestBody TranspondDTO transpondDTO) {
+        Map<String, Object> res = transpondService.auditDistribute(transpondDTO);
+        return res;
+    }
+}

+ 32 - 0
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/centerservice/dto/TranspondDTO.java

@@ -0,0 +1,32 @@
+package com.jeeplus.test.centerservice.dto;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class TranspondDTO {
+
+    /**
+     * 数据id
+     */
+    private String id;
+
+    /**
+     * 审核通过或驳回 yes同意 no驳回
+     */
+    private String flag;
+
+    /**
+     * 审核意见
+     */
+    private String comment;
+
+    /**
+     * 流程key
+     * 例如:ccpm系统的13、102  cpa系统的Process_1665383385070
+     */
+    private String processDefKey;
+}

+ 97 - 0
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/centerservice/service/TranspondService.java

@@ -0,0 +1,97 @@
+package com.jeeplus.test.centerservice.service;
+
+import cn.hutool.core.util.ObjectUtil;
+import com.jeeplus.centerservice.enums.TaskAliasEnum;
+import com.jeeplus.flowable.service.FlowTaskService;
+import com.jeeplus.sys.utils.StringUtils;
+import com.jeeplus.test.centerservice.dto.TranspondDTO;
+import com.jeeplus.test.reimbursement.reimbursementInfo.service.ReimbursementInfoService;
+import com.jeeplus.test.reimbursement.reimbursementInfo.service.dto.RetureListDto;
+import com.jeeplus.test.reimbursement.reimbursementInfo.service.dto.SaveInfoDto;
+import org.flowable.engine.TaskService;
+import org.flowable.task.api.Task;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import javax.annotation.Resource;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+
+@Service
+@Transactional(rollbackFor = Exception.class)
+public class TranspondService {
+
+    @Resource
+    private ReimbursementInfoService reimbursementInfoService; // 评估-报销service
+
+    @Resource
+    private TaskService taskService;
+
+    @Resource
+    private FlowTaskService flowTaskService;
+
+    public Object detailDistribute(String id, String processDefKey) {
+        TaskAliasEnum taskAliasEnum = TaskAliasEnum.getByCcpmContains(processDefKey);
+        // 评估-报销
+        if (TaskAliasEnum.REIMBURSEMENT.getCpaTaskAlias().equals(taskAliasEnum.getCpaTaskAlias())) {
+            SaveInfoDto byId = reimbursementInfoService.findById(id);
+            return byId;
+        }
+        return null;
+    }
+
+    public Map<String,Object> auditDistribute(TranspondDTO transpondDTO) {
+        Map<String,Object> result = new HashMap<>();
+        result.put("success", null);
+        if (Objects.nonNull(transpondDTO) && StringUtils.isNotBlank(transpondDTO.getId()) && StringUtils.isNotBlank(transpondDTO.getFlag()) && StringUtils.isNotBlank(transpondDTO.getProcessDefKey())) {
+            String id = transpondDTO.getId(); // 报销数据id
+            String flag = transpondDTO.getFlag(); // 审核标记  yes通过  no驳回
+            TaskAliasEnum taskAliasEnum = TaskAliasEnum.getByCcpmContains(transpondDTO.getProcessDefKey()); // 获取流程key枚举
+            if (ObjectUtil.isNotEmpty(taskAliasEnum)) {
+                if (TaskAliasEnum.REIMBURSEMENT.getCpaTaskAlias().equals(taskAliasEnum.getCpaTaskAlias())) { // 评估-报销流程
+                    SaveInfoDto reim = reimbursementInfoService.findById(id);
+                    if (Objects.nonNull(reim) && StringUtils.isNotBlank(reim.getType()) && "2".equals(reim.getType())) { // 确保当时数据处于“待审核”状态
+                        if ( StringUtils.isNotBlank(reim.getProcInsId())) {
+                            try {
+                                RetureListDto upStatusParam = new RetureListDto();
+                                upStatusParam.setId(id);
+                                if ("yes".equals(flag)) {
+                                    Task task = taskService.createTaskQuery().processInstanceId(reim.getProcInsId()).active().singleResult();
+                                    // task为null则审核节点为最后一个审核节点
+                                    if (Objects.nonNull(task)) {
+                                        upStatusParam.setType("2");
+                                    } else {
+                                        // 当前审核节点为最后节点
+                                        upStatusParam.setType("5"); // 审核状态设置为审核完成
+                                    }
+                                } else {
+                                    upStatusParam.setType("4"); // 审核状态设置为审核驳回
+                                }
+                                reimbursementInfoService.updateStatusById(upStatusParam); // 修改数据的审核状态
+                                flowTaskService.auditByProcInsIdAndFlag(reim.getProcInsId(), flag, null, transpondDTO.getComment()); // 审核操作
+                                result.put("success", "false");
+                                result.put("message", "操作成功");
+                            }catch (Exception e) {
+                                e.printStackTrace();
+                                result.put("success", "false");
+                                result.put("message", "操作失败");
+                            }
+                        }
+                    } else {
+                        result.put("success", "false");
+                        result.put("message", "操作失败,数据已发生改变或不存在,请刷新数据");
+                    }
+                }
+            }
+        }
+        if (ObjectUtil.isEmpty(result.get("success"))) {
+            result.put("success", "false");
+            result.put("message", "操作失败");
+        }
+        return result;
+    }
+}

+ 17 - 0
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/cw/common/CommonApi.java

@@ -17,6 +17,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.Objects;
+
 @RestController
 @RequestMapping(value = "/commonApi")
 public class CommonApi {
@@ -38,6 +40,21 @@ public class CommonApi {
     }
 
     /**
+     * 判断当前审核节点是否为最后一个节点
+     * @param procInsId
+     * @return
+     */
+    @GetMapping("/isLastTask")
+    public ResponseEntity<Boolean> isLastTask(@RequestParam("procInsId") String procInsId) {
+        Task task = taskService.createTaskQuery().processInstanceId(procInsId).active().singleResult();
+        // task为null则审核节点为最后一个审核节点
+        if (ObjectUtil.isEmpty(task)) {
+            return ResponseEntity.ok(true);
+        }
+        return ResponseEntity.ok(false);
+    }
+
+    /**
      * 根据procInsId获取当前流程节点名称
      * @param procInsId
      * @return

+ 14 - 8
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/reimbursement/reimbursementInfo/service/ReimbursementInfoService.java

@@ -34,7 +34,9 @@ import com.jeeplus.test.reimbursement.reimbursementInfo.service.dto.TreeUserDto;
 import com.jeeplus.test.workContract.service.WorkContractService;
 import com.jeeplus.test.workContract.service.dto.WorkAttachmentDto;
 import com.jeeplus.test.workContract.service.dto.WorkContractInfoDto;
+import org.flowable.engine.TaskService;
 import org.flowable.engine.history.HistoricActivityInstance;
+import org.flowable.task.api.Task;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.ResponseEntity;
@@ -80,6 +82,12 @@ public class ReimbursementInfoService {
     @Resource
     private FlowTaskService flowTaskService;
 
+    @Autowired
+    private CommonApi commonApi;
+
+    @Autowired
+    private TaskService taskService;
+
     /**
      * 列表查询
      */
@@ -707,9 +715,6 @@ public class ReimbursementInfoService {
         return iPage;
     }
 
-    @Autowired
-    private CommonApi commonApi;
-
     /**
      * 报销审核
      * @param saveInfoDto
@@ -729,12 +734,13 @@ public class ReimbursementInfoService {
                         RetureListDto upStatusParam = new RetureListDto();
                         upStatusParam.setId(id);
                         if ("yes".equals(flag)) {
-                            String taskName = commonApi.getTaskName(reim.getProcInsId());
-                            if (StringUtils.isNotBlank(taskName) && "公司领导审批".equals(taskName)) {
-                                // “公司领导审批” 节点审核通过时,才会将审核状态改为 “审核通过”
-                                upStatusParam.setType("5"); // 审核状态设置为审核完成
-                            } else {
+                            Task task = taskService.createTaskQuery().processInstanceId(reim.getProcInsId()).active().singleResult();
+                            // task为null则审核节点为最后一个审核节点
+                            if (Objects.nonNull(task)) {
                                 upStatusParam.setType("2");
+                            } else {
+                                // 当前审核节点为最后节点
+                                upStatusParam.setType("5"); // 审核状态设置为审核完成
                             }
                         } else {
                             upStatusParam.setType("4"); // 审核状态设置为审核驳回