Forráskód Böngészése

自定义流程接口新增

wangliang 3 éve
szülő
commit
7dbb92a49e

+ 12 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/flow/CustomFlowSaveDto.java

@@ -20,6 +20,10 @@ import java.util.Objects;
  */
 public class CustomFlowSaveDto implements Serializable {
 
+    @JsonSerialize(using = ToStringSerializer.class)
+    @ApiModelProperty(value = "自定义流程id")
+    private Long customFlowId;
+
     @ApiModelProperty(value = "id")
     @NotBlank(message = "流程名称")
     String name;
@@ -47,6 +51,14 @@ public class CustomFlowSaveDto implements Serializable {
         this.orgId = orgId;
     }
 
+    public Long getCustomFlowId() {
+        return customFlowId;
+    }
+
+    public void setCustomFlowId(Long customFlowId) {
+        this.customFlowId = customFlowId;
+    }
+
     public String getName() {
         return name;
     }

+ 15 - 3
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/params/FlowParam.java → distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/params/customFlowParam.java

@@ -14,13 +14,17 @@ import java.io.Serializable;
  * @Author: wangliang
  * @Date: 2021/8/6
  */
-public class FlowParam implements Serializable {
+public class customFlowParam implements Serializable {
 
-    @ApiModelProperty(value = "流程id")
+    @ApiModelProperty(value = "id")
     @JsonSerialize(using = ToStringSerializer.class)
-    @NotNull(message = "流程id不能为空")
+    @NotNull(message = "id不能为空")
     private Long id;
 
+    @ApiModelProperty(value = "是否启用,0:停用,1:启用")
+    @NotNull(message = "启用/禁用不能为空")
+    private Boolean enable;
+
     public Long getId() {
         return id;
     }
@@ -28,4 +32,12 @@ public class FlowParam implements Serializable {
     public void setId(Long id) {
         this.id = id;
     }
+
+    public Boolean getEnable() {
+        return enable;
+    }
+
+    public void setEnable(Boolean enable) {
+        this.enable = enable;
+    }
 }

+ 11 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/TFFlowApprove.java

@@ -67,6 +67,9 @@ public class TFFlowApprove extends BaseEntity implements Serializable {
     @TableField(value = "reject_link", updateStrategy = FieldStrategy.IGNORED)
     private String rejectLink;
 
+    @ApiModelProperty(value = "是否启用,0:停用,1:启用")
+    private Boolean enable;
+
     public TFFlowApprove() {
 
     }
@@ -81,6 +84,14 @@ public class TFFlowApprove extends BaseEntity implements Serializable {
         this.setup = FlowApproveSetupEnum.SUBMIT.getSetup();
     }
 
+    public Boolean getEnable() {
+        return enable;
+    }
+
+    public void setEnable(Boolean enable) {
+        this.enable = enable;
+    }
+
     public String getRejectLink() {
         return rejectLink;
     }

+ 5 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/TFCustomFlowMapper.java

@@ -1,9 +1,12 @@
 package com.qmth.distributed.print.business.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.qmth.distributed.print.business.entity.TFCustomFlow;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.Map;
+
 /**
  * <p>
  * 自定义流程表 Mapper 接口
@@ -23,4 +26,6 @@ public interface TFCustomFlowMapper extends BaseMapper<TFCustomFlow> {
      * @return
      */
     TFCustomFlow findMaxVersion(@Param("schoolId") Long schoolId, @Param("orgId") Long orgId, @Param("type") String type);
+
+    public IPage<TFCustomFlow> list(IPage<Map> iPage, @Param("name") String name, @Param("schoolId") Long schoolId, @Param("orgId") Long orgId);
 }

+ 14 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/TFCustomFlowService.java

@@ -1,9 +1,12 @@
 package com.qmth.distributed.print.business.service;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.qmth.distributed.print.business.entity.TFCustomFlow;
 import com.qmth.distributed.print.business.enums.TFCustomTypeEnum;
 
+import java.util.Map;
+
 /**
  * <p>
  * 自定义流程表 服务类
@@ -23,4 +26,15 @@ public interface TFCustomFlowService extends IService<TFCustomFlow> {
      * @return
      */
     TFCustomFlow findMaxVersion(Long schoolId, Long orgId, TFCustomTypeEnum type);
+
+    /**
+     * 查询自定义流程数据列表
+     *
+     * @param iPage
+     * @param name
+     * @param schoolId
+     * @param orgId
+     * @return
+     */
+    public IPage<TFCustomFlow> list(IPage<Map> iPage, String name, Long schoolId, Long orgId);
 }

+ 16 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TFCustomFlowServiceImpl.java

@@ -1,5 +1,6 @@
 package com.qmth.distributed.print.business.service.impl;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qmth.distributed.print.business.entity.TFCustomFlow;
 import com.qmth.distributed.print.business.enums.TFCustomTypeEnum;
@@ -8,6 +9,7 @@ import com.qmth.distributed.print.business.service.TFCustomFlowService;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.util.Map;
 import java.util.Objects;
 
 /**
@@ -36,4 +38,18 @@ public class TFCustomFlowServiceImpl extends ServiceImpl<TFCustomFlowMapper, TFC
     public TFCustomFlow findMaxVersion(Long schoolId, Long orgId, TFCustomTypeEnum type) {
         return tfCustomFlowMapper.findMaxVersion(schoolId, orgId, Objects.nonNull(type) ? type.name() : null);
     }
+
+    /**
+     * 查询自定义流程数据列表
+     *
+     * @param iPage
+     * @param name
+     * @param schoolId
+     * @param orgId
+     * @return
+     */
+    @Override
+    public IPage<TFCustomFlow> list(IPage<Map> iPage, String name, Long schoolId, Long orgId) {
+        return tfCustomFlowMapper.list(iPage, name, schoolId, orgId);
+    }
 }

+ 29 - 1
distributed-print-business/src/main/resources/mapper/TFCustomFlowMapper.xml

@@ -17,7 +17,10 @@
                 <if test="type != null and type != ''">
                     and t.type = #{type}
                 </if>
-            </where>)
+                and t.enable = 1
+                and t.publish = 1
+            </where>
+            )
             <if test="schoolId != null and schoolId != ''">
                 and tfcf.school_id = #{schoolId}
             </if>
@@ -27,6 +30,31 @@
             <if test="type != null and type != ''">
                 and tfcf.type = #{type}
             </if>
+            and tfcf.enable = 1
+            and tfcf.publish = 1
         </where>
     </select>
+
+    <select id="list" resultType="com.qmth.distributed.print.business.entity.TFCustomFlow">
+        select
+            tfcf.id,
+            tfcf.school_id as schoolId,
+            tfcf.org_id as orgId,
+            tfcf.name,
+            tfcf.enable,
+            tfcf.publish
+        from <where>
+            <if test="schoolId != null and schoolId != ''">
+                and tff.school_id = #{schoolId}
+            </if>
+            <if test="name != null and name != ''">
+                and tff.name like concat('%',#{name},'%')
+            </if>
+            and tff.enable = 1
+            <if test="orgId != null and orgId != ''">
+                and tff.org_id = #{orgId}
+            </if>
+        </where>
+    </select>
+
 </mapper>

+ 38 - 9
distributed-print/src/main/java/com/qmth/distributed/print/api/TFCustomFlowController.java

@@ -1,19 +1,21 @@
 package com.qmth.distributed.print.api;
 
 
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 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.CustomFlowSaveDto;
-import com.qmth.distributed.print.business.bean.params.FlowApproveParam;
-import com.qmth.distributed.print.business.bean.params.FlowParam;
 import com.qmth.distributed.print.business.bean.params.FlowTaskApproveParam;
+import com.qmth.distributed.print.business.bean.params.customFlowParam;
 import com.qmth.distributed.print.business.bean.result.FlowTaskApprovePeopleAllResult;
 import com.qmth.distributed.print.business.bean.result.FlowTaskResult;
 import com.qmth.distributed.print.business.entity.TFCustomFlow;
+import com.qmth.distributed.print.business.entity.TFFlowApprove;
 import com.qmth.distributed.print.business.service.ActivitiService;
 import com.qmth.distributed.print.business.service.TFCustomFlowService;
+import com.qmth.distributed.print.business.service.TFFlowApproveService;
 import com.qmth.teachcloud.common.contant.SystemConstant;
 import com.qmth.teachcloud.common.entity.BasicSchool;
 import com.qmth.teachcloud.common.entity.SysUser;
@@ -37,6 +39,7 @@ import java.security.NoSuchAlgorithmException;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Objects;
+import java.util.Optional;
 import java.util.concurrent.atomic.AtomicInteger;
 
 /**
@@ -67,6 +70,9 @@ public class TFCustomFlowController {
     @Resource
     CommonCacheService commonCacheService;
 
+    @Resource
+    TFFlowApproveService tfFlowApproveService;
+
     @ApiOperation(value = "保存和发布流程")
     @ApiResponses({@ApiResponse(code = 200, message = "常规信息", response = ResultUtil.class)})
     @RequestMapping(value = "/save", method = RequestMethod.POST)
@@ -86,7 +92,13 @@ public class TFCustomFlowController {
         }
         try {
             TFCustomFlow dbTfCustomFlow = tfCustomFlowService.findMaxVersion(customFlowSaveDto.getSchoolId(), customFlowSaveDto.getOrgId(), customFlowSaveDto.getType());
-            TFCustomFlow tfCustomFlow = new TFCustomFlow(customFlowSaveDto.getSchoolId(), customFlowSaveDto.getOrgId(), customFlowSaveDto.getName(), customFlowSaveDto.getType(), customFlowSaveDto.getPublish(), JacksonUtil.parseJson(customFlowSaveDto.getCustomFlowLists()), sysUser.getId(), flowBpmnId);
+            TFCustomFlow tfCustomFlow = null;
+            if (Objects.isNull(customFlowSaveDto.getCustomFlowId())) {
+                tfCustomFlow = new TFCustomFlow(customFlowSaveDto.getSchoolId(), customFlowSaveDto.getOrgId(), customFlowSaveDto.getName(), customFlowSaveDto.getType(), customFlowSaveDto.getPublish(), JacksonUtil.parseJson(customFlowSaveDto.getCustomFlowLists()), sysUser.getId(), flowBpmnId);
+            } else {
+                tfCustomFlow = tfCustomFlowService.getById(customFlowSaveDto.getCustomFlowId());
+                tfCustomFlow.updateInfo(sysUser.getId());
+            }
             AtomicInteger atomicInteger = null;
             if (Objects.isNull(dbTfCustomFlow)) {//新增
                 atomicInteger = new AtomicInteger(1);
@@ -98,7 +110,7 @@ public class TFCustomFlowController {
             //自定义流程处理开始
             Map<String, Object> map = activitiService.dynamicBuildBpmn(customFlowSaveDto, flowBpmnId, tfCustomFlow.getVersion());
             tfCustomFlow.setFlowProcessVar(JacksonUtil.parseJson(map));
-            tfCustomFlowService.save(tfCustomFlow);
+            tfCustomFlowService.saveOrUpdate(tfCustomFlow);
         } catch (Exception e) {
             log.error(SystemConstant.LOG_ERROR, e);
             if (e instanceof ApiException) {
@@ -192,27 +204,44 @@ public class TFCustomFlowController {
     public Result list(@ApiParam(value = "流程名称", required = false) @RequestParam(required = false) String name,
                        @ApiParam(value = "页码", required = true) @RequestParam @Min(SystemConstant.PAGE_NUMBER_MIN) Integer pageNumber,
                        @ApiParam(value = "数量", required = true) @RequestParam @Min(SystemConstant.PAGE_SIZE_MIN) @Max(SystemConstant.PAGE_SIZE_MAX) Integer pageSize) {
-        return ResultUtil.ok(true);
+        SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
+        return ResultUtil.ok(tfCustomFlowService.list(new Page<>(pageNumber, pageSize), name, SystemConstant.getHeadOrUserSchoolId(), sysUser.getOrgId()));
+    }
+
+    @ApiOperation(value = "流程编辑")
+    @ApiResponses({@ApiResponse(code = 200, message = "流程信息", response = ResultUtil.class)})
+    @RequestMapping(value = "/edit", method = RequestMethod.POST)
+    public Result edit(@ApiParam(value = "自定义流程id", required = true) @RequestParam String id) {
+        TFCustomFlow tfCustomFlow = tfCustomFlowService.getById(SystemConstant.convertIdToLong(id));
+        Optional.ofNullable(tfCustomFlow).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("自定义流程数据为空"));
+        Optional.ofNullable(tfCustomFlow.getObjectData()).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("自定义流程绘图数据为空"));
+        return ResultUtil.ok(tfCustomFlow.getObjectData());
     }
 
     @ApiOperation(value = "流程逻辑删除")
     @ApiResponses({@ApiResponse(code = 200, message = "常规信息", response = ResultUtil.class)})
     @RequestMapping(value = "/enable", method = RequestMethod.POST)
-    public Result enable(@Valid @RequestBody FlowParam flowParam, BindingResult bindingResult) {
+    public Result enable(@Valid @RequestBody customFlowParam customFlowParam, BindingResult bindingResult) {
         if (bindingResult.hasErrors()) {
             return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
         }
-        return ResultUtil.ok(activitiService.flowDelete(flowParam.getId()));
+        TFCustomFlow tfCustomFlow = tfCustomFlowService.getById(customFlowParam.getId());
+        Optional.ofNullable(tfCustomFlow).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("自定义流程数据为空"));
+        tfCustomFlow.setEnable(customFlowParam.getEnable());
+        return ResultUtil.ok(tfCustomFlowService.updateById(tfCustomFlow));
     }
 
     @ApiOperation(value = "流程审批记录逻辑删除")
     @ApiResponses({@ApiResponse(code = 200, message = "常规信息", response = ResultUtil.class)})
     @RequestMapping(value = "/approve/enable", method = RequestMethod.POST)
-    public Result enable(@Valid @RequestBody FlowApproveParam flowApproveParam, BindingResult bindingResult) {
+    public Result approveEnable(@Valid @RequestBody customFlowParam customFlowParam, BindingResult bindingResult) {
         if (bindingResult.hasErrors()) {
             return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
         }
-        return ResultUtil.ok(true);
+        TFFlowApprove tfFlowApprove = tfFlowApproveService.getById(customFlowParam.getId());
+        Optional.ofNullable(tfFlowApprove).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程审批记录数据为空"));
+        tfFlowApprove.setEnable(customFlowParam.getEnable());
+        return ResultUtil.ok(tfFlowApproveService.updateById(tfFlowApprove));
     }
 
     @ApiOperation(value = "流程终止")