Browse Source

流程审批记录管理

xiaof 3 năm trước cách đây
mục cha
commit
e7875e0c6a

+ 34 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/result/FlowApproveResult.java

@@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonInclude;
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import com.qmth.distributed.print.business.entity.TFFlowApproveLog;
+import com.qmth.teachcloud.common.enums.FlowApproveSetupEnum;
 import com.qmth.teachcloud.common.enums.FlowStatusEnum;
 import io.swagger.annotations.ApiModelProperty;
 
@@ -41,6 +42,15 @@ public class FlowApproveResult extends TFFlowApproveLog implements Serializable
     @ApiModelProperty(value = "流程状态")
     private String statusStr;
 
+    @ApiModelProperty(value = "当前节点")
+    private int setup;
+
+    @ApiModelProperty(value = "当前节点")
+    private String setupStr;
+
+    @ApiModelProperty(value = "当前处理人")
+    private String currentApproveUserName;
+
     public String getThreeApproveName() {
         return threeApproveName;
     }
@@ -100,4 +110,28 @@ public class FlowApproveResult extends TFFlowApproveLog implements Serializable
     public void setStatusStr(String statusStr) {
         this.statusStr = statusStr;
     }
+
+    public int getSetup() {
+        return setup;
+    }
+
+    public void setSetup(int setup) {
+        this.setup = setup;
+    }
+
+    public String getSetupStr() {
+        return setupStr;
+    }
+
+    public void setSetupStr(String setupStr) {
+        this.setupStr = setupStr;
+    }
+
+    public String getCurrentApproveUserName() {
+        return currentApproveUserName;
+    }
+
+    public void setCurrentApproveUserName(String currentApproveUserName) {
+        this.currentApproveUserName = currentApproveUserName;
+    }
 }

+ 2 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/TExamTaskFlowMapper.java

@@ -37,4 +37,6 @@ public interface TExamTaskFlowMapper extends BaseMapper<TExamTaskFlow> {
      * @return
      */
     Integer findByRootLevelByExamTaskId(@Param("examTaskId") Long examTaskId);
+
+    Long selectMaxFlowIdByExamTaskId(Long taskId);
 }

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

@@ -39,7 +39,7 @@ public interface TFFlowMapper extends BaseMapper<TFFlow> {
      * @param flowId
      * @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("status") String status, @Param("startName") String startName, @Param("createStartTime") Long createStartTime, @Param("createEndTime") Long createEndTime, @Param("schoolId") Long schoolId, @Param("orgId") Long orgId, @Param("flowId") Long flowId);
 
     /**
      * 根据key查找id

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

@@ -38,7 +38,7 @@ public interface TFFlowService extends IService<TFFlow> {
      * @param flowId
      * @return
      */
-    public IPage<FlowApproveResult> flowApproveList(IPage<Map> iPage, String startName, Long schoolId, Long orgId, Long flowId);
+    public IPage<FlowApproveResult> flowApproveList(IPage<Map> iPage, String status, String startName, Long createStartTime, Long createEndTime, Long schoolId, Long orgId, Long flowId);
 
     /**
      * 根据key查找流程

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

@@ -487,7 +487,7 @@ public class ActivitiServiceImpl implements ActivitiService {
 
             ExamTask examTask = examTaskService.findByFlowId(flowTaskApprovePeopleAllResult.getFlowId());
 
-            IPage<FlowApproveResult> flowApproveResultIPage = tfFlowService.flowApproveList(new Page<>(SystemConstant.PAGE_NUMBER, SystemConstant.PAGE_SIZE), null, SystemConstant.getHeadOrUserSchoolId(), null, flowTaskApprovePeopleAllResult.getFlowId());
+            IPage<FlowApproveResult> flowApproveResultIPage = tfFlowService.flowApproveList(new Page<>(SystemConstant.PAGE_NUMBER, SystemConstant.PAGE_SIZE), null, null, null, null, SystemConstant.getHeadOrUserSchoolId(), null, flowTaskApprovePeopleAllResult.getFlowId());
             FlowApproveResult flowApproveResult = null;
             if (Objects.nonNull(flowApproveResultIPage) && flowApproveResultIPage.getRecords().size() > 0) {
                 flowApproveResult = flowApproveResultIPage.getRecords().get(0);

+ 46 - 3
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TFFlowServiceImpl.java

@@ -5,14 +5,20 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qmth.distributed.print.business.bean.result.FlowApproveResult;
 import com.qmth.distributed.print.business.entity.TFFlow;
+import com.qmth.distributed.print.business.entity.TFFlowLog;
+import com.qmth.distributed.print.business.mapper.TExamTaskFlowMapper;
+import com.qmth.distributed.print.business.mapper.TFFlowLogMapper;
 import com.qmth.distributed.print.business.mapper.TFFlowMapper;
 import com.qmth.distributed.print.business.service.TFFlowService;
 import com.qmth.teachcloud.common.entity.SysUser;
+import com.qmth.teachcloud.common.enums.FlowApproveSetupEnum;
+import com.qmth.teachcloud.common.service.SysUserService;
 import com.qmth.teachcloud.common.util.ServletUtil;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
-import java.util.Map;
+import java.util.*;
 
 /**
  * <p>
@@ -28,6 +34,15 @@ public class TFFlowServiceImpl extends ServiceImpl<TFFlowMapper, TFFlow> impleme
     @Resource
     TFFlowMapper tfFlowMapper;
 
+    @Resource
+    TExamTaskFlowMapper tExamTaskFlowMapper;
+
+    @Resource
+    TFFlowLogMapper tfFlowLogMapper;
+
+    @Autowired
+    SysUserService sysUserService;
+
     /**
      * 流程列表
      *
@@ -53,8 +68,36 @@ public class TFFlowServiceImpl extends ServiceImpl<TFFlowMapper, TFFlow> impleme
      * @return
      */
     @Override
-    public IPage<FlowApproveResult> flowApproveList(IPage<Map> iPage, String startName, Long schoolId, Long orgId, Long flowId) {
-        return tfFlowMapper.flowApproveList(iPage, startName, schoolId, orgId, flowId);
+    public IPage<FlowApproveResult> flowApproveList(IPage<Map> iPage, String status, String startName, Long createStartTime, Long createEndTime, Long schoolId, Long orgId, Long flowId) {
+        IPage<FlowApproveResult> flowApproveResultIPage = tfFlowMapper.flowApproveList(iPage, status, startName, createStartTime, createEndTime, schoolId, orgId, flowId);
+        for (FlowApproveResult record : flowApproveResultIPage.getRecords()) {
+            record.setStatusStr(record.getStatus().getTitle());
+            // FlowApproveSetupEnum
+            if (!(FlowApproveSetupEnum.END.getSetup() == record.getSetup())) {
+                record.setSetupStr("结束节点");
+            } else if (FlowApproveSetupEnum.SUBMIT.getSetup() == record.getSetup()) {
+                record.setSetupStr("开始节点");
+            } else {
+                record.setSetupStr("审批节点");
+            }
+
+            Long maxFlowId = tExamTaskFlowMapper.selectMaxFlowIdByExamTaskId(record.getTaskId());
+            if (Objects.nonNull(maxFlowId)) {
+                List<TFFlowLog> flowLogs = tfFlowLogMapper.findByFlowId(maxFlowId);
+                TFFlowLog tfFlowLog = flowLogs.stream().sorted(Comparator.comparingLong(TFFlowLog::getCreateTime).reversed()).findFirst().orElse(null);
+                if (Objects.nonNull(tfFlowLog)) {
+                    String pendApproveId = tfFlowLog.getPendApproveId();
+                    StringJoiner sj = new StringJoiner(",");
+                    for (String id : pendApproveId.split(",")) {
+                        SysUser sysUser = sysUserService.getById(id);
+                        sj.add(sysUser.getRealName());
+                    }
+                    record.setCurrentApproveUserName(sj.toString());
+                }
+            }
+
+        }
+        return flowApproveResultIPage;
     }
 
     /**

+ 3 - 0
distributed-print-business/src/main/resources/mapper/TExamTaskFlowMapper.xml

@@ -13,4 +13,7 @@
     <select id="findByRootLevelByExamTaskId" resultType="java.lang.Integer">
         SELECT min(t.level) FROM t_exam_task_flow t WHERE t.exam_task_id = #{examTaskId}
     </select>
+    <select id="selectMaxFlowIdByExamTaskId" resultType="java.lang.Long">
+        select max(flow_id) from t_exam_task_flow t where t.exam_task_id = #{taskId}
+    </select>
 </mapper>

+ 10 - 36
distributed-print-business/src/main/resources/mapper/TFFlowMapper.xml

@@ -25,51 +25,25 @@
             tffal.start_id as startId,
             su.real_name as startName,
             tffal.create_time as createTime,
-            tffal.primary_approve_id as primaryApproveId,
-            (
-            select
-                t.real_name
-            from
-                sys_user t
-            where
-                t.id = tffal.primary_approve_id) as primaryApproveName,
-            tffal.primary_approve_remark as primaryApproveRemark,
-            tffal.second_approve_id as secondApproveId,
-            (
-            select
-                t.real_name
-            from
-                sys_user t
-            where
-                t.id = tffal.second_approve_id) as secondApproveName,
-            tffal.second_approve_remark as secondApproveRemark,
-            tffal.three_approve_id as threeApproveId,
-            tffal.three_approve_remark as threeApproveRemark,
-            (
-            select
-            t.real_name
-            from
-            sys_user t
-            where
-            t.id = tffal.three_approve_id) as threeApproveName,
-            tffal.four_approve_id as fourApproveId,
-            tffal.four_approve_remark as fourApproveRemark,
-            (
-            select
-            t.real_name
-            from
-            sys_user t
-            where
-            t.id = tffal.four_approve_id) as fourApproveName,
+            tffa.setup,
             tffa.status
         from
             t_f_flow_approve_log tffal
         left join t_f_flow_approve tffa on tffa.flow_id = tffal.flow_id
         left join sys_user su on su.id = tffal.start_id
         <where>
+            <if test="status != null and status != ''">
+                and tffa.status = #{status}
+            </if>
             <if test="startName != null and startName != ''">
                 and su.real_name like concat('%',#{startName},'%')
             </if>
+            <if test="createStartTime != null and createStartTime != ''">
+                and tffal.create_time &gt;= #{createStartTime}
+            </if>
+            <if test="createEndTime != null and createEndTime != ''">
+                and tffal.create_time &lt;= #{createEndTime}
+            </if>
             <if test="schoolId != null and schoolId != ''">
                 and tffal.school_id = #{schoolId}
             </if>

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

@@ -4,8 +4,6 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.google.common.reflect.TypeToken;
 import com.google.gson.Gson;
-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.params.FlowApproveParam;
@@ -220,11 +218,14 @@ public class TFFlowController {
     @ApiOperation(value = "流程审批记录列表")
     @ApiResponses({@ApiResponse(code = 200, message = "流程审批记录信息", response = FlowApproveResult.class)})
     @RequestMapping(value = "/approve/list", method = RequestMethod.POST)
-    public Result taskApproveList(@ApiParam(value = "发起人名称", required = false) @RequestParam(required = false) String startName,
+    public Result taskApproveList(@ApiParam(value = "状态", required = false) @RequestParam(required = false) String status,
+                                  @ApiParam(value = "发起人名称", required = false) @RequestParam(required = false) String startName,
+                                  @ApiParam(value = "提交开始时间", required = false) @RequestParam(required = false) Long createStartTime,
+                                  @ApiParam(value = "提交结束时间", required = false) @RequestParam(required = false) Long createEndTime,
                                   @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) {
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
-        return ResultUtil.ok(tfFlowService.flowApproveList(new Page<>(pageNumber, pageSize), startName, SystemConstant.getHeadOrUserSchoolId(), sysUser.getOrgId(), null));
+        return ResultUtil.ok(tfFlowService.flowApproveList(new Page<>(pageNumber, pageSize), status, startName, createStartTime, createEndTime, SystemConstant.getHeadOrUserSchoolId(), sysUser.getOrgId(), null));
     }
 
     @ApiOperation(value = "流程审批记录逻辑删除")