Pārlūkot izejas kodu

异常审核列表优化

wangliang 1 gadu atpakaļ
vecāks
revīzija
858dde07ec

+ 11 - 0
sop-business/src/main/java/com/qmth/sop/business/bean/result/DingApplyUnDoneResult.java

@@ -53,6 +53,17 @@ public class DingApplyUnDoneResult extends WorkTaskResult implements Serializabl
     @ApiModelProperty(value = "sop单号")
     String sopNo;
 
+    @ApiModelProperty(value = "taskId组合")
+    String taskIdArray;
+
+    public String getTaskIdArray() {
+        return taskIdArray;
+    }
+
+    public void setTaskIdArray(String taskIdArray) {
+        this.taskIdArray = taskIdArray;
+    }
+
     public String getSopNo() {
         return sopNo;
     }

+ 2 - 5
sop-business/src/main/java/com/qmth/sop/business/mapper/TBDingApplyMapper.java

@@ -8,7 +8,6 @@ import com.qmth.sop.business.bean.result.DingApplyUnDoneResult;
 import com.qmth.sop.business.entity.TBDingApply;
 import org.apache.ibatis.annotations.Param;
 
-import java.util.List;
 import java.util.Map;
 
 /**
@@ -25,7 +24,6 @@ public interface TBDingApplyMapper extends BaseMapper<TBDingApply> {
      * 异常待审核接口
      *
      * @param iPage
-     * @param userIdList
      * @param serviceId
      * @param name
      * @param supplierId
@@ -36,13 +34,12 @@ public interface TBDingApplyMapper extends BaseMapper<TBDingApply> {
      * @param applyEndTime
      * @return
      */
-    IPage<DingApplyUnDoneResult> flowTaskUnDoneList(IPage<Map> iPage, @Param("userIdList") List<String> userIdList, @Param("serviceId") Long serviceId, @Param("name") String name, @Param("supplierId") Long supplierId, @Param("customName") String customName, @Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("applyStartTime") Long applyStartTime, @Param("applyEndTime") Long applyEndTime, @Param("dpr") DataPermissionDto dpr);
+    IPage<DingApplyUnDoneResult> flowTaskUnDoneList(IPage<Map> iPage, @Param("serviceId") Long serviceId, @Param("name") String name, @Param("supplierId") Long supplierId, @Param("customName") String customName, @Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("applyStartTime") Long applyStartTime, @Param("applyEndTime") Long applyEndTime, @Param("dpr") DataPermissionDto dpr);
 
     /**
      * 异常已审核接口
      *
      * @param iPage
-     * @param userIdList
      * @param serviceId
      * @param name
      * @param supplierId
@@ -54,5 +51,5 @@ public interface TBDingApplyMapper extends BaseMapper<TBDingApply> {
      * @param applyEndTime
      * @return
      */
-    IPage<DingApplyDoneResult> flowTaskDoneList(IPage<Map> iPage, @Param("userIdList") List<String> userIdList, @Param("serviceId") Long serviceId, @Param("name") String name, @Param("supplierId") Long supplierId, @Param("dingExceptionApprove") String dingExceptionApprove, @Param("customName") String customName, @Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("applyStartTime") Long applyStartTime, @Param("applyEndTime") Long applyEndTime, @Param("dpr") DataPermissionDto dpr);
+    IPage<DingApplyDoneResult> flowTaskDoneList(IPage<Map> iPage, @Param("serviceId") Long serviceId, @Param("name") String name, @Param("supplierId") Long supplierId, @Param("dingExceptionApprove") String dingExceptionApprove, @Param("customName") String customName, @Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("applyStartTime") Long applyStartTime, @Param("applyEndTime") Long applyEndTime, @Param("dpr") DataPermissionDto dpr);
 }

+ 16 - 0
sop-business/src/main/java/com/qmth/sop/business/mapper/TFFlowLogMapper.java

@@ -24,4 +24,20 @@ public interface TFFlowLogMapper extends BaseMapper<TFFlowLog> {
      * @return
      */
     List<TFFlowLogResult> findByObjectId(@Param("objectId") Long objectId);
+
+    /**
+     * 查询最后一条日志审批记录
+     *
+     * @param flowId
+     * @return
+     */
+    TFFlowLog findByLastFlowLog(@Param("flowId") Long flowId);
+
+    /**
+     * 查询最后一条日志审批记录
+     *
+     * @param flowId
+     * @return
+     */
+    String findByLastFlowLogApproveUser(@Param("flowId") Long flowId);
 }

+ 16 - 0
sop-business/src/main/java/com/qmth/sop/business/service/TFFlowLogService.java

@@ -23,4 +23,20 @@ public interface TFFlowLogService extends IService<TFFlowLog> {
      * @return
      */
     List<TFFlowLogResult> findByObjectId(Long objectId);
+
+    /**
+     * 查询最后一条日志审批记录
+     *
+     * @param flowId
+     * @return
+     */
+    TFFlowLog findByLastFlowLog(Long flowId);
+
+    /**
+     * 查询最后一条日志审批记录
+     *
+     * @param flowId
+     * @return
+     */
+    String findByLastFlowLogApproveUser(Long flowId);
 }

+ 48 - 11
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBDingApplyServiceImpl.java

@@ -20,6 +20,7 @@ import com.qmth.sop.common.util.ServletUtil;
 import org.activiti.engine.TaskService;
 import org.activiti.engine.task.IdentityLink;
 import org.activiti.engine.task.Task;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.time.DateFormatUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -124,32 +125,60 @@ public class TBDingApplyServiceImpl extends ServiceImpl<TBDingApplyMapper, TBDin
     public IPage<DingApplyUnDoneResult> flowTaskUnDoneList(IPage<Map> iPage, Long serviceId, String name, Long supplierId, String customName, Long startTime, Long endTime, Long applyStartTime, Long applyEndTime) throws Exception {
         SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
         DataPermissionDto dpr = sysUserService.buildUserDataPermission(requestUser.getId());
-        IPage<DingApplyUnDoneResult> dingApplyUnDoneResultIPage = this.baseMapper.flowTaskUnDoneList(iPage, Arrays.asList(String.valueOf(requestUser.getId())), serviceId, name, supplierId, customName, startTime, endTime, applyStartTime, applyEndTime, dpr);
+        IPage<DingApplyUnDoneResult> dingApplyUnDoneResultIPage = this.baseMapper.flowTaskUnDoneList(iPage, serviceId, name, supplierId, customName, startTime, endTime, applyStartTime, applyEndTime, dpr);
         if (Objects.nonNull(dingApplyUnDoneResultIPage) && !CollectionUtils.isEmpty(dingApplyUnDoneResultIPage.getRecords())) {
             for (DingApplyUnDoneResult d : dingApplyUnDoneResultIPage.getRecords()) {
                 if (Objects.nonNull(d.getAttachmentPaths())) {
-                    String[] strs = d.getAttachmentPaths().split(";");
+                    List<BasicAttachment> basicAttachmentList = basicAttachmentService.listByIds(Arrays.asList(d.getAttachmentPaths().split(",")));
                     StringJoiner stringJoiner = new StringJoiner(";");
-                    for (int i = 0; i < strs.length; i++) {
-                        String path = basicAttachmentService.filePreview(strs[i]);
+                    for (BasicAttachment b : basicAttachmentList) {
+                        String path = basicAttachmentService.filePreview(b.getPath());
                         stringJoiner.add(path);
                     }
                     d.setAttachmentPaths(stringJoiner.toString());
                 }
-                if (Objects.nonNull(d.getTaskId())) {
-                    Task task = taskService.createTaskQuery().taskId(String.valueOf(d.getTaskId())).singleResult();
+                TFFlowLog tfFlowLog = tfFlowLogService.findByLastFlowLog(d.getFlowId());
+                if (Objects.nonNull(tfFlowLog) && Objects.nonNull(tfFlowLog.getPendApproveId())) {
+                    List<SysUser> sysUserList = sysUserService.listByIds(Arrays.asList(tfFlowLog.getPendApproveId().split(",")));
+                    List<String> userName = sysUserList.stream().map(s -> s.getRealName()).collect(Collectors.toList());
+                    d.setApproveUserName(StringUtils.join(userName, ","));
+                } else {
+                    d.setApproveUserName("--");
+                }
+                String taskIds = d.getTaskIdArray();
+                if (Objects.nonNull(taskIds) && taskIds.contains(",")) {
+                    String[] taskStrs = taskIds.split(",");
+                    boolean match = false;
+                    for (int i = 0; i < taskStrs.length; i++) {
+                        Task task = taskService.createTaskQuery().taskId(taskStrs[i]).singleResult();
+                        if (task.getAssignee().equals(requestUser.getId().toString())) {
+                            d.setTaskId(Long.parseLong(task.getId()));
+                            match = true;
+                            d.setMyself(true);
+                            break;
+                        }
+                    }
+                    if (!match) {
+                        d.setTaskId(Long.parseLong(taskStrs[0]));
+                        d.setMyself(false);
+                    }
+                } else if (Objects.nonNull(taskIds)) {
+                    Task task = taskService.createTaskQuery().taskId(taskIds).singleResult();
                     if (Objects.nonNull(task.getAssignee()) && task.getAssignee().equals(requestUser.getId().toString())) {
                         d.setMyself(true);
                     } else {
                         List<IdentityLink> identityLinkList = taskService.getIdentityLinksForTask(task.getId());
                         if (!CollectionUtils.isEmpty(identityLinkList)) {
                             for (IdentityLink i : identityLinkList) {
-                                if (Objects.nonNull(i.getUserId()) && i.getUserId().equals(requestUser.getId().toString())) {
+                                if (i.getUserId().equals(requestUser.getId().toString())) {
                                     d.setMyself(true);
                                 }
                             }
                         }
                     }
+                    d.setTaskId(Long.parseLong(taskIds));
+                } else {
+                    d.setMyself(false);
                 }
             }
         }
@@ -175,18 +204,26 @@ public class TBDingApplyServiceImpl extends ServiceImpl<TBDingApplyMapper, TBDin
     public IPage<DingApplyDoneResult> flowTaskDoneList(IPage<Map> iPage, Long serviceId, String name, Long supplierId, DingExceptionApproveEnum dingExceptionApprove, String customName, Long startTime, Long endTime, Long applyStartTime, Long applyEndTime) throws Exception {
         SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
         DataPermissionDto dpr = sysUserService.buildUserDataPermission(requestUser.getId());
-        IPage<DingApplyDoneResult> dingApplyDoneResultIPage = this.baseMapper.flowTaskDoneList(iPage, Arrays.asList(String.valueOf(requestUser.getId())), serviceId, name, supplierId, Objects.nonNull(dingExceptionApprove) ? dingExceptionApprove.getTitle() : null, customName, startTime, endTime, applyStartTime, applyEndTime, dpr);
+        IPage<DingApplyDoneResult> dingApplyDoneResultIPage = this.baseMapper.flowTaskDoneList(iPage, serviceId, name, supplierId, Objects.nonNull(dingExceptionApprove) ? dingExceptionApprove.getTitle() : null, customName, startTime, endTime, applyStartTime, applyEndTime, dpr);
         if (Objects.nonNull(dingApplyDoneResultIPage) && !CollectionUtils.isEmpty(dingApplyDoneResultIPage.getRecords())) {
             for (DingApplyDoneResult d : dingApplyDoneResultIPage.getRecords()) {
                 if (Objects.nonNull(d.getAttachmentPaths())) {
-                    String[] strs = d.getAttachmentPaths().split(";");
+                    List<BasicAttachment> basicAttachmentList = basicAttachmentService.listByIds(Arrays.asList(d.getAttachmentPaths().split(",")));
                     StringJoiner stringJoiner = new StringJoiner(";");
-                    for (int i = 0; i < strs.length; i++) {
-                        String path = basicAttachmentService.filePreview(strs[i]);
+                    for (BasicAttachment b : basicAttachmentList) {
+                        String path = basicAttachmentService.filePreview(b.getPath());
                         stringJoiner.add(path);
                     }
                     d.setAttachmentPaths(stringJoiner.toString());
                 }
+                String string = tfFlowLogService.findByLastFlowLogApproveUser(d.getFlowId());
+                if (Objects.nonNull(string)) {
+                    List<SysUser> sysUserList = sysUserService.listByIds(Arrays.asList(string.split(",")));
+                    List<String> userName = sysUserList.stream().map(s -> s.getRealName()).collect(Collectors.toList());
+                    d.setApproveUsersName(StringUtils.join(userName, ","));
+                } else {
+                    d.setApproveUsersName("--");
+                }
                 if (Objects.nonNull(d.getApproveInfo())) {
                     String[] strs = d.getApproveInfo().split(";");
                     d.setDingExceptionApprove(strs[0]);

+ 22 - 0
sop-business/src/main/java/com/qmth/sop/business/service/impl/TFFlowLogServiceImpl.java

@@ -30,4 +30,26 @@ public class TFFlowLogServiceImpl extends ServiceImpl<TFFlowLogMapper, TFFlowLog
     public List<TFFlowLogResult> findByObjectId(Long objectId) {
         return this.baseMapper.findByObjectId(objectId);
     }
+
+    /**
+     * 查询最后一条日志审批记录
+     *
+     * @param flowId
+     * @return
+     */
+    @Override
+    public TFFlowLog findByLastFlowLog(Long flowId) {
+        return this.baseMapper.findByLastFlowLog(flowId);
+    }
+
+    /**
+     * 查询最后一条日志审批记录
+     *
+     * @param flowId
+     * @return
+     */
+    @Override
+    public String findByLastFlowLogApproveUser(Long flowId) {
+        return this.baseMapper.findByLastFlowLogApproveUser(flowId);
+    }
 }

+ 72 - 107
sop-business/src/main/resources/mapper/TBDingApplyMapper.xml

@@ -3,35 +3,13 @@
 <mapper namespace="com.qmth.sop.business.mapper.TBDingApplyMapper">
 
     <select id="flowTaskUnDoneList" resultType="com.qmth.sop.business.bean.result.DingApplyUnDoneResult">
-        select t.* from(<include refid="flowTaskUnDoneListHeader"/>
-        where 1 = 1
-        <if test="userIdList != null and userIdList != '' and userIdList.size() > 0">
-            and art.ASSIGNEE_ IN
-            <foreach collection="userIdList" item="item" index="index" open="(" separator="," close=")">
-                #{item}
-            </foreach>
-        </if>
-        <include refid="flowTaskUnDoneListFoot"/>
-        union all
         <include refid="flowTaskUnDoneListHeader"/>
-        left join act_ru_identitylink ari on ari.TASK_ID_ = art.ID_
-        where
-        1 = 1
-        and art.ASSIGNEE_ is null
-        <if test="userIdList != null and userIdList != '' and userIdList.size() > 0">
-            and ari.USER_ID_ IN
-            <foreach collection="userIdList" item="item" index="index" open="(" separator="," close=")">
-                #{item}
-            </foreach>
-        </if>
-        and ari.TYPE_ = 'candidate'
-        <include refid="flowTaskUnDoneListFoot" />) t order by t.code desc
+        <include refid="flowTaskUnDoneListFoot" /> order by tfcfe.code desc
     </select>
 
     <sql id="flowTaskUnDoneListHeader">
         select
-            distinct cast(art.ASSIGNEE_ as Decimal(24)) as userId,
-                     tfcf.type,
+            distinct tfcf.type,
                      tfcfe.code,
                      tffa.status,
                      tffa.setup,
@@ -49,9 +27,6 @@
                      tfcfe.create_id as createId,
                      su.real_name as createRealName,
                      tfcfe.flow_id as flowId,
-                     art.NAME_ as taskName,
-                     art.TASK_DEF_KEY_ as taskDefKey,
-                     art.ID_ as taskId,
                      tfcfe.flow_process_var as flowProcessVar,
                      tfcfe.t_f_custom_flow_id as customFlowId,
                      tfcf.flow_deployment_id as flowDeploymentId,
@@ -60,14 +35,16 @@
                      tbd.sign_date as exceptionTime,
                      tbda.apply_time as applyTime,
                      tbda.reason,
-                     (select group_concat(ba.`path` SEPARATOR ';') from basic_attachment ba where find_in_set(ba.id, tbda.attachment_ids)) as attachmentPaths,
+                     tbda.attachment_ids as attachmentPaths,
                      tbda.create_time as createTime,
-                     su1.real_name as approveUserName,
                      ss.name as supplierName,
                      ss.code as supplierCode,
                      tbs.service_lead_id as serviceUnitLeaderId,
                      tbc.lead_id as regionManagerId,
-                     tbc.region_coordinator_id as coordinatorId
+                     tbc.region_coordinator_id as coordinatorId,
+                     art.NAME_ as taskName,
+                     art.TASK_DEF_KEY_ as taskDefKey,
+                     (select group_concat(cast(art.ID_ as char)) from ACT_RU_TASK art where art.PROC_INST_ID_ = tffa.flow_id) as taskIdArray
         from
             t_b_ding_apply tbda
                 left join t_f_custom_flow_entity tfcfe on
@@ -76,21 +53,29 @@
                 tfcfe.flow_id = tffa.flow_id
                 left join t_f_custom_flow tfcf on
                 tfcf.id = tfcfe.t_f_custom_flow_id
-                left join ACT_RU_TASK art on
-                art.PROC_INST_ID_ = tfcfe.flow_id
-                left join t_b_crm tbc on tbc.crm_no = tfcfe.crm_no
-                left join t_b_service tbs on tbs.id = tbc.service_id
-                left join sys_custom sc on sc.id = tbc.custom_id
-                left join t_b_ding tbd on tbd.id = tbda.ding_id
-                left join sys_user su ON tbda.create_id = su.id
-                left join t_b_user_archives tbua on tbua.mobile_number = su.mobile_number
-                left join t_b_user_archives_supplier tbuas on tbuas.user_archives_id = tbua.id
-                left join sys_supplier ss on ss.id = tbuas.supplier_id
-                left join sys_user su1 ON cast(art.ASSIGNEE_ as Decimal(24)) = su1.id
+                left join t_b_crm tbc on
+                tbc.crm_no = tfcfe.crm_no
+                left join t_b_service tbs on
+                tbs.id = tbc.service_id
+                left join sys_custom sc on
+                sc.id = tbc.custom_id
+                left join t_b_ding tbd on
+                tbd.id = tbda.ding_id
+                left join sys_user su on
+                tbda.create_id = su.id
+                left join t_b_user_archives tbua on
+                tbua.mobile_number = su.mobile_number
+                left join t_b_user_archives_supplier tbuas on
+                tbuas.user_archives_id = tbua.id
+                left join sys_supplier ss on
+                ss.id = tbuas.supplier_id
+                left join ACT_RU_TASK art on art.PROC_INST_ID_ = tffa.flow_id
+                left join act_ru_identitylink ari on ari.TASK_ID_ = art.ID_
     </sql>
 
     <sql id="flowTaskUnDoneListFoot">
-        and tfcf.type = 'DING_EXCEPTION_FLOW'
+        <where>
+            and tfcf.type = 'DING_EXCEPTION_FLOW'
         <if test="serviceId != null and serviceId != ''">
             and tbs.id = #{serviceId}
         </if>
@@ -130,10 +115,12 @@
                 </otherwise>
             </choose>
         </if>
+            and tffa.status in ('START','DRAFT','AUDITING','REJECT','CANCEL')
+        </where>
     </sql>
 
     <select id="flowTaskDoneList" resultType="com.qmth.sop.business.bean.result.DingApplyDoneResult">
-        select t.* from(select
+        select
             distinct tfcf.type,
             tfcfe.code,
             tffa.status,
@@ -162,10 +149,17 @@
             tbda.create_time as createTime,
             tffa.update_time as flowTime,
             tbda.reason,
-            (select group_concat(ba.`path` SEPARATOR ';') from basic_attachment ba where find_in_set(ba.id, tbda.attachment_ids)) as attachmentPaths,
-            (select CONCAT(tffl.approve_remark, ';' ,tffl.create_time) from t_f_flow_log tffl where tffl.flow_id = tfcfe.flow_id order by tffl.create_time desc limit 1) as approveInfo,
-            IFNULL((select group_concat(us1.real_name SEPARATOR ';') from sys_user us1
-		where find_in_set(us1.id, (select group_concat(tffl.approve_id) from t_f_flow_log tffl where tffl.flow_id = tfcfe.flow_id and tffl.approve_setup > 1))),'--') as approveUsersName,
+            tbda.attachment_ids as attachmentPaths,
+            (
+            select
+            CONCAT(tffl.approve_remark, ';' , tffl.create_time)
+            from
+            t_f_flow_log tffl
+            where
+            tffl.flow_id = tfcfe.flow_id
+            order by
+            tffl.create_time desc
+            limit 1) as approveInfo,
             ss.id as supplierId,
             tbd.id as dingId,
             ss.name as supplierName,
@@ -174,63 +168,34 @@
             tbs.service_lead_id as serviceUnitLeaderId,
             tbc.lead_id as regionManagerId,
             tbc.region_coordinator_id as coordinatorId
-        from t_b_ding_apply tbda
-            left join t_f_custom_flow_entity tfcfe on tbda.ding_exception_no = tfcfe.code
-            left join t_f_flow_approve tffa on tfcfe.flow_id = tffa.flow_id
-            left join t_f_custom_flow tfcf on tfcf.id = tfcfe.t_f_custom_flow_id
-            left join t_b_crm tbc on tbc.crm_no = tfcfe.crm_no
-            left join t_b_service tbs on tbs.id = tbc.service_id
-            left join sys_custom sc on sc.id = tbc.custom_id
-            left join t_b_ding tbd on tbd.id = tbda.ding_id
-            left join sys_user su ON tbda.create_id = su.id
-            left join t_b_user_archives tbua on tbua.mobile_number = su.mobile_number
-            left join t_b_user_archives_supplier tbuas on tbuas.user_archives_id = tbua.id
-            left join sys_supplier ss on ss.id = tbuas.supplier_id
-        where 1 = 1 and tfcf.type = 'DING_EXCEPTION_FLOW'
-          and (tffa.status = 'AUDITING' or tffa.status = 'REJECT' or tffa.status = 'FINISH')
-          and EXISTS (
-            select * from(select
-            distinct aht.PROC_INST_ID_
-            from
-            ACT_HI_TASKINST aht
-            where 1 = 1
-            <if test="userIdList != null and userIdList != '' and userIdList.size() > 0">
-                and aht.ASSIGNEE_ IN
-                <foreach collection="userIdList" item="item" index="index" open="(" separator="," close=")">
-                    #{item}
-                </foreach>
-            </if>
-          and aht.END_TIME_ is not null
-            UNION ALL
-            select
-            t.PROC_INST_ID_
-            from
-            (
-            select
-            ahi.*
             from
-            ACT_HI_IDENTITYLINK ahi
-            where
-            ahi.TYPE_ = 'candidate'
-          and exists(
-            select
-            distinct aht.id_
-            from
-            ACT_HI_TASKINST aht
-            where
-            aht.ASSIGNEE_ is null
-          and aht.END_TIME_ is not null
-          and ahi.TASK_ID_ = aht.id_)
-            <if test="userIdList != null and userIdList != '' and userIdList.size() > 0">
-                and ahi.USER_ID_ IN
-                <foreach collection="userIdList" item="item" index="index" open="(" separator="," close=")">
-                    #{item}
-                </foreach>
-            </if>) temp
-            join ACT_HI_TASKINST t on
-            t.ID_ = temp.TASK_ID_) temp where temp.PROC_INST_ID_ = tfcfe.flow_id)) t
-            join t_b_ding tbd on tbd.id = t.dingId
-        <where>
+            t_b_ding_apply tbda
+            left join t_f_custom_flow_entity tfcfe on
+            tbda.ding_exception_no = tfcfe.code
+            left join t_f_flow_approve tffa on
+            tfcfe.flow_id = tffa.flow_id
+            left join t_f_custom_flow tfcf on
+            tfcf.id = tfcfe.t_f_custom_flow_id
+            left join t_b_crm tbc on
+            tbc.crm_no = tfcfe.crm_no
+            left join t_b_service tbs on
+            tbs.id = tbc.service_id
+            left join sys_custom sc on
+            sc.id = tbc.custom_id
+            left join t_b_ding tbd on
+            tbd.id = tbda.ding_id
+            left join sys_user su on
+            tbda.create_id = su.id
+            left join t_b_user_archives tbua on
+            tbua.mobile_number = su.mobile_number
+            left join t_b_user_archives_supplier tbuas on
+            tbuas.user_archives_id = tbua.id
+            left join sys_supplier ss on
+            ss.id = tbuas.supplier_id
+            left join ACT_HI_TASKINST aht on aht.PROC_INST_ID_ = tffa.flow_id
+        <where> 1 = 1 and tfcf.type = 'DING_EXCEPTION_FLOW'
+          and (tffa.status = 'AUDITING' or tffa.status = 'REJECT' or tffa.status = 'FINISH')
+            <!--and aht.ASSIGNEE_ = #{dpr.requestUserId}-->
             <if test="serviceId != null and serviceId != ''">
                 and t.serviceId = #{serviceId}
             </if>
@@ -255,17 +220,17 @@
             <if test="dpr != null and !dpr.hasAdmin and !dpr.hasPmo">
                 <choose>
                     <when test="dpr.hasBusiness">
-                        AND t.serviceUnitLeaderId = #{dpr.requestUserId}
+                        AND tbs.service_lead_id = #{dpr.requestUserId}
                     </when>
                     <otherwise>
                         <choose>
                             <when test="dpr.hasRegionManager">
-                                AND t.regionManagerId = #{dpr.requestUserId}
+                                AND tbc.lead_id = #{dpr.requestUserId}
                             </when>
                             <otherwise>
                                 <choose>
                                     <when test="dpr.hasRegionCoordinator">
-                                        AND t.coordinatorId = #{dpr.requestUserId}
+                                        AND tbc.region_coordinator_id = #{dpr.requestUserId}
                                     </when>
                                 </choose>
                             </otherwise>
@@ -274,6 +239,6 @@
                 </choose>
             </if>
         </where>
-            order by t.code desc
+            order by tfcfe.code desc
     </select>
 </mapper>

+ 8 - 0
sop-business/src/main/resources/mapper/TFFlowLogMapper.xml

@@ -57,4 +57,12 @@
         order by
             tffl.create_time desc
     </select>
+
+    <select id="findByLastFlowLog" resultType="com.qmth.sop.business.entity.TFFlowLog">
+        select * from t_f_flow_log tffl where tffl.flow_id = #{flowId} order by tffl.create_time desc limit 1
+    </select>
+
+    <select id="findByLastFlowLogApproveUser" resultType="java.lang.String">
+        select group_concat(tffl.approve_id) from t_f_flow_log tffl where tffl.flow_id = #{flowId} and tffl.approve_setup > 1
+    </select>
 </mapper>