Эх сурвалжийг харах

自定义流程接口新增

wangliang 3 жил өмнө
parent
commit
46aa3f2da3

+ 17 - 74
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/result/FlowViewTaskResult.java

@@ -1,5 +1,6 @@
 package com.qmth.distributed.print.business.bean.result;
 
+import com.fasterxml.jackson.annotation.JsonInclude;
 import com.qmth.distributed.print.business.enums.CustomFlowMultipleUserApproveTypeEnum;
 import io.swagger.annotations.ApiModelProperty;
 
@@ -13,81 +14,39 @@ import java.util.List;
  * @Author: wangliang
  * @Date: 2021/8/6
  */
+@JsonInclude(JsonInclude.Include.NON_NULL)
 public class FlowViewTaskResult extends FlowTaskResult implements Serializable {
 
-//    @ApiModelProperty(value = "审批操作,SUBMIT:提交,APPROVE:审批,REJECT:驳回,END:终止,EXCHANGE:转他人审批")
-//    private FlowApproveOperationEnum approveOperation;
-
-//    @ApiModelProperty(value = "审批操作,SUBMIT:提交,APPROVE:审批,REJECT:驳回,END:终止,EXCHANGE:转他人审批")
-//    private String approveOperationStr;
-
     @ApiModelProperty(value = "自定义流程审核类型")
     private CustomFlowMultipleUserApproveTypeEnum multipleUserApproveType;
 
-    @ApiModelProperty(value = "流程待审批人")
-    private String pendApproveUsers;
-
-//    @ApiModelProperty(value = "流程已审人")
-//    private String approveUsers;
-
     @ApiModelProperty(value = "当前审批人")
     private String currentApproveUsers;
 
+    @ApiModelProperty(value = "下一级审批人")
+    private String pendApproveUsers;
+
     @ApiModelProperty(value = "是否当前节点")
     private boolean currentTask;
 
-//    @ApiModelProperty(value = "审核意见")
-//    private String approveRemark;
-//
-//    @ApiModelProperty(value = "创建时间")
-//    private Long createTime;
-
     @ApiModelProperty(value = "流程审批信息")
-    List<TFFlowLogResult> tfFlowLogResultList;
+    List<TFFlowViewLogResult> tfFlowViewLogResultList;
+
+    public String getPendApproveUsers() {
+        return pendApproveUsers;
+    }
 
-    public List<TFFlowLogResult> getTfFlowLogResultList() {
-        return tfFlowLogResultList;
+    public void setPendApproveUsers(String pendApproveUsers) {
+        this.pendApproveUsers = pendApproveUsers;
     }
 
-    public void setTfFlowLogResultList(List<TFFlowLogResult> tfFlowLogResultList) {
-        this.tfFlowLogResultList = tfFlowLogResultList;
+    public List<TFFlowViewLogResult> getTfFlowViewLogResultList() {
+        return tfFlowViewLogResultList;
     }
 
-//    public FlowApproveOperationEnum getApproveOperation() {
-//        return approveOperation;
-//    }
-//
-//    public void setApproveOperation(FlowApproveOperationEnum approveOperation) {
-//        this.approveOperation = approveOperation;
-//    }
-//
-//    public String getApproveOperationStr() {
-//        if (Objects.nonNull(approveOperation)) {
-//            return approveOperation.getTitle();
-//        } else {
-//            return approveOperationStr;
-//        }
-//    }
-//
-//    public void setApproveOperationStr(String approveOperationStr) {
-//        this.approveOperationStr = approveOperationStr;
-//    }
-//
-//    public String getApproveRemark() {
-//        return approveRemark;
-//    }
-//
-//    public void setApproveRemark(String approveRemark) {
-//        this.approveRemark = approveRemark;
-//    }
-//
-//    public Long getCreateTime() {
-//        return createTime;
-//    }
-//
-//    public void setCreateTime(Long createTime) {
-//        this.createTime = createTime;
-//    }
+    public void setTfFlowViewLogResultList(List<TFFlowViewLogResult> tfFlowViewLogResultList) {
+        this.tfFlowViewLogResultList = tfFlowViewLogResultList;
+    }
 
     public CustomFlowMultipleUserApproveTypeEnum getMultipleUserApproveType() {
         return multipleUserApproveType;
@@ -97,22 +56,6 @@ public class FlowViewTaskResult extends FlowTaskResult implements Serializable {
         this.multipleUserApproveType = multipleUserApproveType;
     }
 
-    public String getPendApproveUsers() {
-        return pendApproveUsers;
-    }
-
-    public void setPendApproveUsers(String pendApproveUsers) {
-        this.pendApproveUsers = pendApproveUsers;
-    }
-
-//    public String getApproveUsers() {
-//        return approveUsers;
-//    }
-//
-//    public void setApproveUsers(String approveUsers) {
-//        this.approveUsers = approveUsers;
-//    }
-
     public String getCurrentApproveUsers() {
         return currentApproveUsers;
     }

+ 1 - 7
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/result/TFFlowLogResult.java

@@ -3,12 +3,10 @@ package com.qmth.distributed.print.business.bean.result;
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import com.qmth.teachcloud.common.bean.params.ApproveUserResult;
-import com.qmth.teachcloud.common.contant.SystemConstant;
 import com.qmth.teachcloud.common.enums.FlowApproveOperationEnum;
 import io.swagger.annotations.ApiModelProperty;
 
 import java.io.Serializable;
-import java.util.Objects;
 
 /**
  * @Description: TFFlowLogResult
@@ -101,11 +99,7 @@ public class TFFlowLogResult extends ApproveUserResult implements Serializable {
     }
 
     public Integer getApproveSetup() {
-        if (Objects.isNull(approveSetup)) {
-            return SystemConstant.START_SETUP;
-        } else {
-            return approveSetup;
-        }
+        return approveSetup;
     }
 
     public void setApproveSetup(Integer approveSetup) {

+ 172 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/result/TFFlowViewLogResult.java

@@ -0,0 +1,172 @@
+package com.qmth.distributed.print.business.bean.result;
+
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import com.qmth.teachcloud.common.enums.FlowApproveOperationEnum;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.io.Serializable;
+
+/**
+ * @Description: TFFlowLogResult
+ * @Param:
+ * @return:
+ * @Author: wangliang
+ * @Date: 2021/11/22
+ */
+public class TFFlowViewLogResult implements Serializable {
+
+    @ApiModelProperty(value = "流程id")
+    @JsonSerialize(using = ToStringSerializer.class)
+    private Long flowId;
+
+    @ApiModelProperty(value = "任务id")
+    @JsonSerialize(using = ToStringSerializer.class)
+    private Long taskId;
+
+    @ApiModelProperty(value = "审核人id")
+    @JsonSerialize(using = ToStringSerializer.class)
+    private Long approveId;
+
+    @ApiModelProperty(value = "审核步骤")
+    private Integer approveSetup;
+
+    @ApiModelProperty(value = "审核意见")
+    private String approveRemark;
+
+    @ApiModelProperty(value = "审批操作,SUBMIT:提交,APPROVE:审批,REJECT:驳回,END:终止,EXCHANGE:转他人审批")
+    private FlowApproveOperationEnum approveOperation;
+
+    @ApiModelProperty(value = "待审核人id")
+    private String pendApproveId;
+
+    @ApiModelProperty(value = "试卷附件")
+    private String paperAttachmentId;
+
+    @ApiModelProperty(value = "待审核人")
+    private String pendApproveUserName;
+
+    @ApiModelProperty(value = "已审核人")
+    private String approveUserName;
+
+    @ApiModelProperty(value = "试卷urls")
+    private String paperUrls;
+
+    @ApiModelProperty(value = "创建时间")
+    private Long createTime;
+
+    public TFFlowViewLogResult() {
+
+    }
+
+    public TFFlowViewLogResult(TFFlowLogResult tfFlowLogResult) {
+        this.flowId = tfFlowLogResult.getFlowId();
+        this.taskId = tfFlowLogResult.getTaskId();
+        this.approveId = tfFlowLogResult.getApproveId();
+        this.approveSetup = tfFlowLogResult.getApproveSetup();
+        this.approveRemark = tfFlowLogResult.getApproveRemark();
+        this.approveOperation = tfFlowLogResult.getApproveOperation();
+        this.pendApproveId = tfFlowLogResult.getPendApproveId();
+        this.paperAttachmentId = tfFlowLogResult.getPaperAttachmentId();
+        this.pendApproveUserName = tfFlowLogResult.getPendApproveUserName();
+        this.approveUserName = tfFlowLogResult.getApproveUserName();
+        this.paperUrls = tfFlowLogResult.getPaperUrls();
+        this.createTime = tfFlowLogResult.getCreateTime();
+    }
+
+    public String getPaperUrls() {
+        return paperUrls;
+    }
+
+    public void setPaperUrls(String paperUrls) {
+        this.paperUrls = paperUrls;
+    }
+
+    public Long getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Long createTime) {
+        this.createTime = createTime;
+    }
+
+    public String getPendApproveUserName() {
+        return pendApproveUserName;
+    }
+
+    public void setPendApproveUserName(String pendApproveUserName) {
+        this.pendApproveUserName = pendApproveUserName;
+    }
+
+    public String getApproveUserName() {
+        return approveUserName;
+    }
+
+    public void setApproveUserName(String approveUserName) {
+        this.approveUserName = approveUserName;
+    }
+
+    public String getPaperAttachmentId() {
+        return paperAttachmentId;
+    }
+
+    public void setPaperAttachmentId(String paperAttachmentId) {
+        this.paperAttachmentId = paperAttachmentId;
+    }
+
+    public Long getFlowId() {
+        return flowId;
+    }
+
+    public void setFlowId(Long flowId) {
+        this.flowId = flowId;
+    }
+
+    public Long getTaskId() {
+        return taskId;
+    }
+
+    public void setTaskId(Long taskId) {
+        this.taskId = taskId;
+    }
+
+    public Long getApproveId() {
+        return approveId;
+    }
+
+    public void setApproveId(Long approveId) {
+        this.approveId = approveId;
+    }
+
+    public Integer getApproveSetup() {
+        return approveSetup;
+    }
+
+    public void setApproveSetup(Integer approveSetup) {
+        this.approveSetup = approveSetup;
+    }
+
+    public String getApproveRemark() {
+        return approveRemark;
+    }
+
+    public void setApproveRemark(String approveRemark) {
+        this.approveRemark = approveRemark;
+    }
+
+    public FlowApproveOperationEnum getApproveOperation() {
+        return approveOperation;
+    }
+
+    public void setApproveOperation(FlowApproveOperationEnum approveOperation) {
+        this.approveOperation = approveOperation;
+    }
+
+    public String getPendApproveId() {
+        return pendApproveId;
+    }
+
+    public void setPendApproveId(String pendApproveId) {
+        this.pendApproveId = pendApproveId;
+    }
+}

+ 17 - 28
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ActivitiServiceImpl.java

@@ -15,7 +15,6 @@ import com.qmth.distributed.print.business.enums.*;
 import com.qmth.distributed.print.business.service.*;
 import com.qmth.teachcloud.common.bean.params.ApproveUserResult;
 import com.qmth.teachcloud.common.contant.SystemConstant;
-import com.qmth.teachcloud.common.entity.SysOrg;
 import com.qmth.teachcloud.common.entity.SysUser;
 import com.qmth.teachcloud.common.enums.*;
 import com.qmth.teachcloud.common.service.CommonCacheService;
@@ -2256,7 +2255,6 @@ public class ActivitiServiceImpl implements ActivitiService {
     @Override
     public FlowViewResult getFlowView(Long flowId) {
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
-        SysOrg sysOrg = commonCacheService.orgCache(sysUser.getOrgId());
         TFCustomFlowEntity tfCustomFlowEntity = tfCustomFlowEntityService.findByFlowId(flowId);
         Optional.ofNullable(tfCustomFlowEntity).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("自定义流程实体数据为空"));
 
@@ -2292,46 +2290,37 @@ public class ActivitiServiceImpl implements ActivitiService {
             agginessMap = JacksonUtil.readJson(tfFlowApprove.getTransferAssignee(), Map.class);
         }
 
-//        Map<String, Object> varMap = new HashMap<>();
-//        for (Map.Entry<String, CustomFlowVarDto> entry : agginessMap.entrySet()) {
-//            CustomFlowVarDto customFlowVarDto = gson.fromJson(gson.toJson(entry.getValue()), CustomFlowVarDto.class);
-//            varMap.computeIfAbsent(customFlowVarDto.getFlowTaskVar(), s -> customFlowVarDto.getApproveIds().size() == 1 ? customFlowVarDto.getApproveIds().get(0) : customFlowVarDto.getApproveIds());
-//        }
-
         //获取流程审批历史
         List<TFFlowLogResult> tfFlowLogResultList = tfFlowLogService.findByExamTaskId(tExamTaskFlowList.get(0).getTaskId());
         if (Objects.nonNull(tfFlowLogResultList) && tfFlowLogResultList.size() > 0) {
-            LinkedMultiValueMap<Integer, TFFlowLogResult> tfFlowLogResultMap = new LinkedMultiValueMap<>();
+            LinkedMultiValueMap<Integer, TFFlowViewLogResult> tfFlowViewLogResultMap = new LinkedMultiValueMap<>();
             for (TFFlowLogResult t : tfFlowLogResultList) {
-                tfFlowLogResultMap.add(t.getApproveSetup(), t);
+                tfFlowViewLogResultMap.add(t.getApproveSetup(), new TFFlowViewLogResult(t));
             }
 
-            int nextFlowSetup = 0;
             for (FlowViewTaskResult f : flowViewTaskResultList) {
                 CustomFlowVarDto customFlowVarDto = gson.fromJson(gson.toJson(agginessMap.get(f.getTaskKey())), CustomFlowVarDto.class);
-                if (currFlowTaskResult.getSetup().intValue() == f.getSetup().intValue()) {//当前审批节点
-                    f.setCurrentTask(true);
-                    f.setCurrentApproveUsers(sysUser.getRealName() + "(" + sysOrg.getName() + ")");
-                    nextFlowSetup = currFlowTaskResult.getSetup().intValue() + 1;
-                    nextFlowSetup = nextFlowSetup == setupMap.size() ? 0 : nextFlowSetup;
-                } else if (f.getSetup().intValue() < currFlowTaskResult.getSetup().intValue()) {//已审节点
-                    //上一节点审核人
-                    f.setTfFlowLogResultList(tfFlowLogResultMap.get(f.getSetup()));
+                if (f.getSetup().intValue() <= currFlowTaskResult.getSetup().intValue()) {//已审节点
+                    if (currFlowTaskResult.getSetup().intValue() == f.getSetup().intValue()) {//当前审批节点
+                        f.setCurrentTask(true);
+                        List<TFFlowViewLogResult> tfFlowViewLogResultList = tfFlowViewLogResultMap.get(f.getSetup());
+                        f.setTfFlowViewLogResultList(tfFlowViewLogResultList);
+                        TFFlowViewLogResult tfFlowViewLogResult = tfFlowViewLogResultList.get(tfFlowViewLogResultList.size() - 1);
+                        f.setCurrentApproveUsers(tfFlowViewLogResult.getPendApproveUserName());
+                    } else {
+                        //上一节点审核人
+                        f.setTfFlowViewLogResultList(tfFlowViewLogResultMap.get(f.getSetup()));
+                    }
                 } else if (f.getSetup().intValue() > currFlowTaskResult.getSetup().intValue()) {//待审核节点
                     //下一节点审批人
-                    if (nextFlowSetup > 0 && nextFlowSetup == f.getSetup().intValue()) {
-                        List<TFFlowLogResult> tfFlowLogResults = tfFlowLogResultMap.get(f.getSetup() - 1 == 1 ? SystemConstant.START_SETUP : f.getSetup() - 1);
-                        if (Objects.nonNull(tfFlowLogResults) && tfFlowLogResults.size() > 0) {
-                            f.setPendApproveUsers(tfFlowLogResults.get(tfFlowLogResults.size() - 1).getPendApproveUserName());
-                        }
-                    } else {
-                        f.setPendApproveUsers(customFlowVarDto.getApproveIds().toString());
+                    if (Objects.nonNull(customFlowVarDto.getApproveIds())) {
+                        ApproveUserResult approveUserResult = sysUserService.findByIds(customFlowVarDto.getApproveIds().stream().map(x -> SystemConstant.convertIdToLong(x)).collect(Collectors.toList()));
+                        f.setPendApproveUsers(approveUserResult.getPendApproveUsers());
+                        f.setTfFlowViewLogResultList(tfFlowViewLogResultMap.get(f.getSetup()));
                     }
                 }
                 f.setMultipleUserApproveType(customFlowVarDto.getMultipleUserApproveType());
             }
-//            flowViewResult.setFlowTaskResultList(flowViewTaskResultList);
-//            flowViewResult.setTfFlowLogResultList(tfFlowLogResultList);
         }
         return new FlowViewResult(flowViewTaskResultList);
     }

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

@@ -18,7 +18,7 @@
             tffl.pend_approve_id as pendApproveId,
             tffl.create_time as createTime,
             tffl.flow_id as flowId,
-            tffl.task_id as askId,
+            tffl.task_id as taskId,
             tffl.id,
             tffl.paper_attachment_id as paperAttachmentId,
             su.school_id as schoolId,

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

@@ -56,7 +56,7 @@ import java.util.concurrent.atomic.AtomicInteger;
 @Api(tags = "自定义流程Controller")
 @RestController
 @RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + "/${prefix.url.customFlow}")
-@Aac(auth = BOOL.FALSE, strict = BOOL.FALSE)
+//@Aac(auth = BOOL.FALSE, strict = BOOL.FALSE)
 @Validated
 public class TFCustomFlowController {
     private final static Logger log = LoggerFactory.getLogger(TFCustomFlowController.class);
@@ -293,14 +293,6 @@ public class TFCustomFlowController {
         return ResultUtil.ok(activitiService.getTaskAll(flowId));
     }
 
-//    @ApiOperation(value = "获取所有流程节点待审批人")
-//    @ApiResponses({@ApiResponse(code = 200, message = "流程节点待审批人", response = FlowTaskApprovePeopleAllResult.class)})
-//    @RequestMapping(value = "/task/approver/people_all", method = RequestMethod.POST)
-//    public Result taskApproverPeopleAll(@ApiParam(value = "课程编码", required = false) @RequestParam(required = false) String courseCode,
-//                                        @ApiParam(value = "流程节点id", required = false) @RequestParam(required = false) String taskId) {
-//        return ResultUtil.ok(activitiService.taskApproverPeopleAll(courseCode, taskId));
-//    }
-
     @ApiOperation(value = "流程节点转他人审批")
     @ApiResponses({@ApiResponse(code = 200, message = "常规信息", response = ResultUtil.class)})
     @RequestMapping(value = "/task/approver/exchange", method = RequestMethod.POST)

+ 11 - 2
teachcloud-common/src/main/java/com/qmth/teachcloud/common/bean/params/ApproveUserResult.java

@@ -1,13 +1,11 @@
 package com.qmth.teachcloud.common.bean.params;
 
-import com.alibaba.fastjson.JSONArray;
 import com.fasterxml.jackson.annotation.JsonInclude;
 import com.qmth.teachcloud.common.entity.SysUser;
 import com.qmth.teachcloud.common.enums.OrgTypeEnum;
 import io.swagger.annotations.ApiModelProperty;
 
 import java.io.Serializable;
-import java.util.List;
 
 /**
  * @Description: 审批人 result
@@ -28,6 +26,9 @@ public class ApproveUserResult extends SysUser implements Serializable {
     @ApiModelProperty(value = "试卷urls")
     private String paperUrls;
 
+    @ApiModelProperty(value = "流程待审批人")
+    private String pendApproveUsers;
+
     public ApproveUserResult() {
 
     }
@@ -44,6 +45,14 @@ public class ApproveUserResult extends SysUser implements Serializable {
         this.paperUrls = paperUrls;
     }
 
+    public String getPendApproveUsers() {
+        return pendApproveUsers;
+    }
+
+    public void setPendApproveUsers(String pendApproveUsers) {
+        this.pendApproveUsers = pendApproveUsers;
+    }
+
     public String getPaperUrls() {
         return paperUrls;
     }

+ 0 - 1
teachcloud-common/src/main/java/com/qmth/teachcloud/common/contant/SystemConstant.java

@@ -75,7 +75,6 @@ public class SystemConstant {
     public static final int PAGE_SIZE_MIN = 10;
     public static final int PAGE_SIZE_MAX = 500;
     public static final int PAGE_NUMBER_MIN = 1;
-    public static final int START_SETUP = 10000000;
     public static final int IN_SIZE_MAX = 1000;
     public static final int ALL_CARD = -1;
     public static final String MANUAL = "manual";

+ 8 - 0
teachcloud-common/src/main/java/com/qmth/teachcloud/common/mapper/SysUserMapper.java

@@ -50,6 +50,14 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
      */
     public List<ApproveUserResult> findById(@Param("id") Long id);
 
+    /**
+     * 根据id集合获取
+     *
+     * @param ids
+     * @return
+     */
+    public ApproveUserResult findByIds(@Param("ids") List<Long> ids);
+
     /**
      * 根据用户(id和手机号)查询验证码发送几率
      *

+ 8 - 0
teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/SysUserService.java

@@ -180,6 +180,14 @@ public interface SysUserService extends IService<SysUser> {
      */
     public List<ApproveUserResult> findById(Long id);
 
+    /**
+     * 根据id集合获取
+     *
+     * @param ids
+     * @return
+     */
+    public ApproveUserResult findByIds(List<Long> ids);
+
     /**
      * 根据机构id获取
      *

+ 12 - 1
teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/impl/SysUserServiceImpl.java

@@ -998,6 +998,17 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
         return sysUserMapper.findById(id);
     }
 
+    /**
+     * 根据id集合获取
+     *
+     * @param ids
+     * @return
+     */
+    @Override
+    public ApproveUserResult findByIds(List<Long> ids) {
+        return sysUserMapper.findByIds(ids);
+    }
+
     /**
      * 根据机构id获取
      *
@@ -1216,7 +1227,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
     public List<Long> findOrgIdListByUserId(Long userId) {
         List<Long> orgIdList = new ArrayList<>();
         Long orgId = this.getById(userId).getOrgId();
-        if (SystemConstant.longNotNull(orgId)){
+        if (SystemConstant.longNotNull(orgId)) {
             orgIdList.add(orgId);
         }
         return orgIdList.stream().distinct().collect(Collectors.toList());

+ 12 - 0
teachcloud-common/src/main/resources/mapper/SysUserMapper.xml

@@ -184,6 +184,18 @@
         </where>
     </select>
 
+    <select id="findByIds" resultType="com.qmth.teachcloud.common.bean.params.ApproveUserResult">
+        select group_concat(su.real_name,'(',so.name,')') as pendApproveUsers from sys_user su left join sys_org so on so.id = su.org_id
+        <where>
+            <if test="ids != null">
+                AND su.id IN
+                <foreach collection="ids" item="item" index="index" open="(" separator="," close=")">
+                    #{item}
+                </foreach>
+            </if>
+        </where>
+    </select>
+
     <select id="findByOrgIds" resultType="com.qmth.teachcloud.common.bean.params.ApproveUserResult">
         <include refid="approveUserResultHeaderCommon" />
         <where>