Sfoglia il codice sorgente

流程文件删除BUG修复

wangliang 3 anni fa
parent
commit
5c533f4757

+ 17 - 6
distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/TFFlow.java

@@ -45,27 +45,38 @@ public class TFFlow extends BaseEntity implements Serializable {
     @ApiModelProperty(value = "是否发布,0:否,1:是")
     @ApiModelProperty(value = "是否发布,0:否,1:是")
     private Boolean publish;
     private Boolean publish;
 
 
+    @ApiModelProperty(value = "流程id")
+    private String actFlowId;
+
     public TFFlow() {
     public TFFlow() {
 
 
     }
     }
 
 
-    public TFFlow(Long schoolId, Long orgId, String name, Long userId, String flowKey) {
-        setId(SystemConstant.getDbUuid());
+    public TFFlow(Long schoolId, Long orgId, String name, Long userId, String flowKey, String actFlowId) {
         this.schoolId = schoolId;
         this.schoolId = schoolId;
         this.orgId = orgId;
         this.orgId = orgId;
         this.name = name;
         this.name = name;
         this.flowKey = flowKey;
         this.flowKey = flowKey;
-        setCreateId(userId);
+        this.actFlowId = actFlowId;
+        insertInfo(userId);
     }
     }
 
 
-    public TFFlow(Long schoolId, Long orgId, String name, Boolean publish, Long userId, String flowKey) {
-        setId(SystemConstant.getDbUuid());
+    public TFFlow(Long schoolId, Long orgId, String name, Boolean publish, Long userId, String flowKey, String actFlowId) {
         this.schoolId = schoolId;
         this.schoolId = schoolId;
         this.orgId = orgId;
         this.orgId = orgId;
         this.name = name;
         this.name = name;
         this.publish = publish;
         this.publish = publish;
         this.flowKey = flowKey;
         this.flowKey = flowKey;
-        setCreateId(userId);
+        this.actFlowId = actFlowId;
+        insertInfo(userId);
+    }
+
+    public String getActFlowId() {
+        return actFlowId;
+    }
+
+    public void setActFlowId(String actFlowId) {
+        this.actFlowId = actFlowId;
     }
     }
 
 
     public String getFlowKey() {
     public String getFlowKey() {

+ 8 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/TFFlowMapper.java

@@ -40,4 +40,12 @@ public interface TFFlowMapper extends BaseMapper<TFFlow> {
      * @return
      * @return
      */
      */
     IPage<FlowApproveResult> flowApproveList(IPage<Map> iPage, @Param("startName") String startName, @Param("schoolId") Long schoolId, @Param("orgId") Long orgId, @Param("flowId") Long flowId);
     IPage<FlowApproveResult> flowApproveList(IPage<Map> iPage, @Param("startName") String startName, @Param("schoolId") Long schoolId, @Param("orgId") Long orgId, @Param("flowId") Long flowId);
+
+    /**
+     * 根据key查找id
+     *
+     * @param flowKey
+     * @return
+     */
+    public String findActIdByFlowKey(@Param("flowKey") String flowKey);
 }
 }

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

@@ -64,8 +64,11 @@ public interface ActivitiService {
 
 
     /**
     /**
      * 流程删除
      * 流程删除
+     *
+     * @param id
+     * @return
      */
      */
-    public Boolean flowDelete();
+    public Boolean flowDelete(Long id);
 
 
     /**
     /**
      * 获取所有流程节点待审批人
      * 获取所有流程节点待审批人

+ 8 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/TFFlowService.java

@@ -47,4 +47,12 @@ public interface TFFlowService extends IService<TFFlow> {
      * @return
      * @return
      */
      */
     public Integer findByFlowKey(String flowKey);
     public Integer findByFlowKey(String flowKey);
+
+    /**
+     * 根据key查找id
+     *
+     * @param flowKey
+     * @return
+     */
+    public String findActIdByFlowKey(String flowKey);
 }
 }

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

@@ -442,10 +442,14 @@ public class ActivitiServiceImpl implements ActivitiService {
 
 
     /**
     /**
      * 流程删除
      * 流程删除
+     *
+     * @param id
+     * @return
      */
      */
     @Override
     @Override
-    public Boolean flowDelete() {
-        List<ProcessInstance> processInstanceList = runtimeService.createProcessInstanceQuery().processDefinitionKey(SystemConstant.GDYKDX_FLOW_KEY).list();
+    public Boolean flowDelete(Long id) {
+        TFFlow tfFlow = tfFlowService.getById(id);
+        List<ProcessInstance> processInstanceList = runtimeService.createProcessInstanceQuery().processDefinitionId(tfFlow.getActFlowId()).processDefinitionKey(SystemConstant.GDYKDX_FLOW_KEY).list();
         if (Objects.nonNull(processInstanceList) && processInstanceList.size() > 0) {
         if (Objects.nonNull(processInstanceList) && processInstanceList.size() > 0) {
             throw ExceptionResultEnum.ERROR.exception("有在途的流程,无法删除!");
             throw ExceptionResultEnum.ERROR.exception("有在途的流程,无法删除!");
         } else {
         } else {

+ 11 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TFFlowServiceImpl.java

@@ -73,4 +73,15 @@ public class TFFlowServiceImpl extends ServiceImpl<TFFlowMapper, TFFlow> impleme
                 .eq(TFFlow::getPublish, true);
                 .eq(TFFlow::getPublish, true);
         return this.count(tfFlowQueryWrapper);
         return this.count(tfFlowQueryWrapper);
     }
     }
+
+    /**
+     * 根据key查找id
+     *
+     * @param flowKey
+     * @return
+     */
+    @Override
+    public String findActIdByFlowKey(String flowKey) {
+        return tfFlowMapper.findActIdByFlowKey(flowKey);
+    }
 }
 }

+ 4 - 0
distributed-print-business/src/main/resources/mapper/TFFlowMapper.xml

@@ -66,4 +66,8 @@
         order by
         order by
             tffal.create_time desc
             tffal.create_time desc
     </select>
     </select>
+
+    <select id="findActIdByFlowKey" resultType="java.lang.String">
+        select max(arp.ID_) as actFlowId from act_re_procdef arp where arp.KEY_ = #{flowKey} order by arp.VERSION_ desc LIMIT 1
+    </select>
 </mapper>
 </mapper>

+ 4 - 3
distributed-print/src/main/java/com/qmth/distributed/print/api/TFFlowController.java

@@ -95,8 +95,9 @@ public class TFFlowController {
                 throw ExceptionResultEnum.ATTACHMENT_ERROR.exception();
                 throw ExceptionResultEnum.ATTACHMENT_ERROR.exception();
             }
             }
             activitiService.uploadDeployment(file);
             activitiService.uploadDeployment(file);
+            String actFlowId = tfFlowService.findActIdByFlowKey(SystemConstant.GDYKDX_FLOW_KEY);
             SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
             SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
-            TFFlow tfFlow = new TFFlow(SystemConstant.getHeadOrUserSchoolId(), sysUser.getOrgId(), name, sysUser.getId(), fileName);
+            TFFlow tfFlow = new TFFlow(SystemConstant.getHeadOrUserSchoolId(), sysUser.getOrgId(), name, sysUser.getId(), fileName, actFlowId);
             tfFlowService.save(tfFlow);
             tfFlowService.save(tfFlow);
         } catch (Exception e) {
         } catch (Exception e) {
             log.error("请求出错", e);
             log.error("请求出错", e);
@@ -132,8 +133,8 @@ public class TFFlowController {
     @ApiOperation(value = "流程逻辑删除")
     @ApiOperation(value = "流程逻辑删除")
     @ApiResponses({@ApiResponse(code = 200, message = "常规信息", response = ResultUtil.class)})
     @ApiResponses({@ApiResponse(code = 200, message = "常规信息", response = ResultUtil.class)})
     @RequestMapping(value = "/enable", method = RequestMethod.POST)
     @RequestMapping(value = "/enable", method = RequestMethod.POST)
-    public Result enable() {
-        return ResultUtil.ok(activitiService.flowDelete());
+    public Result enable(@ApiParam(value = "流程文件id", required = true) @RequestParam String id) {
+        return ResultUtil.ok(activitiService.flowDelete(SystemConstant.convertIdToLong(id)));
     }
     }
 
 
     @ApiOperation(value = "流程列表")
     @ApiOperation(value = "流程列表")