Browse Source

加入myself

wangliang 1 year ago
parent
commit
6a8b910056

+ 15 - 0
sop-business/src/main/java/com/qmth/sop/business/activiti/service/impl/ActivitiServiceImpl.java

@@ -118,6 +118,9 @@ public class ActivitiServiceImpl implements ActivitiService {
     @Resource
     SysUserRoleService sysUserRoleService;
 
+    @Resource
+    TSJobRemindService tsJobRemindService;
+
     /**
      * 根据deploymentId查找processDefinitionId
      *
@@ -507,7 +510,11 @@ public class ActivitiServiceImpl implements ActivitiService {
         Map<String, Object> map = new HashMap<>();
         IPage<WorkTaskResult> workTaskResultIPage = sysUserService.getFlowTaskList(iPage, userId, type, serviceId, customName, flowTaskTypeEnum, crmNo);
         if (Objects.nonNull(workTaskResultIPage) && !CollectionUtils.isEmpty(workTaskResultIPage.getRecords())) {
+            Set<String> sopNoSet = new HashSet<>(workTaskResultIPage.getRecords().size());
+            Map<String, WorkTaskResult> workTaskMap = new LinkedHashMap<>();
             for (WorkTaskResult w : workTaskResultIPage.getRecords()) {
+                sopNoSet.add(w.getCode());
+                workTaskMap.put(w.getCode(), w);
                 List<Task> taskList = taskService.createTaskQuery().taskId(String.valueOf(w.getTaskId())).list();
                 if (!CollectionUtils.isEmpty(taskList)) {
                     for (Task t : taskList) {
@@ -520,6 +527,14 @@ public class ActivitiServiceImpl implements ActivitiService {
                     }
                 }
             }
+            List<WorkTaskResult> workTaskResultList = tsJobRemindService.getJobRemindProcessHour(sysUser.getId(), sopNoSet);
+            if (!CollectionUtils.isEmpty(workTaskResultList)) {
+                for (WorkTaskResult w : workTaskResultList) {
+                    if (Objects.nonNull(workTaskMap.get(w.getCode())) && Objects.nonNull(w.getProcessHour())) {
+                        workTaskMap.get(w.getCode()).setProcessHour(w.getProcessHour());
+                    }
+                }
+            }
         }
         return workTaskResultIPage;
     }

+ 13 - 0
sop-business/src/main/java/com/qmth/sop/business/mapper/TSJobRemindMapper.java

@@ -2,9 +2,13 @@ package com.qmth.sop.business.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.qmth.sop.business.bean.result.FlowTaskSmsResult;
+import com.qmth.sop.business.bean.result.WorkTaskResult;
 import com.qmth.sop.business.entity.TSJobRemind;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.List;
+import java.util.Set;
+
 /**
  * <p>
  * 任务提醒表 Mapper 接口
@@ -22,4 +26,13 @@ public interface TSJobRemindMapper extends BaseMapper<TSJobRemind> {
      * @return
      */
     FlowTaskSmsResult getFlowTaskRemindSmsInfo(@Param("id") Long id);
+
+    /**
+     * 根据用户id和sop单号集合查找处理时限
+     *
+     * @param userId
+     * @param sopNoSet
+     * @return
+     */
+    List<WorkTaskResult> getJobRemindProcessHour(@Param("userId") Long userId, @Param("sopNoSet") Set<String> sopNoSet);
 }

+ 11 - 0
sop-business/src/main/java/com/qmth/sop/business/service/TSJobRemindService.java

@@ -2,9 +2,11 @@ package com.qmth.sop.business.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.qmth.sop.business.bean.result.FlowTaskSmsResult;
+import com.qmth.sop.business.bean.result.WorkTaskResult;
 import com.qmth.sop.business.entity.TSJobRemind;
 
 import java.util.List;
+import java.util.Set;
 
 /**
  * <p>
@@ -39,4 +41,13 @@ public interface TSJobRemindService extends IService<TSJobRemind> {
      * @return
      */
     FlowTaskSmsResult getFlowTaskRemindSmsInfo(Long id);
+
+    /**
+     * 根据用户id和sop单号集合查找处理时限
+     *
+     * @param userId
+     * @param sopNoSet
+     * @return
+     */
+    List<WorkTaskResult> getJobRemindProcessHour(Long userId, Set<String> sopNoSet);
 }

+ 14 - 0
sop-business/src/main/java/com/qmth/sop/business/service/impl/TSJobRemindServiceImpl.java

@@ -3,6 +3,7 @@ package com.qmth.sop.business.service.impl;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qmth.sop.business.bean.result.FlowTaskSmsResult;
+import com.qmth.sop.business.bean.result.WorkTaskResult;
 import com.qmth.sop.business.entity.TSJobRemind;
 import com.qmth.sop.business.mapper.TSJobRemindMapper;
 import com.qmth.sop.business.service.TSJobRemindService;
@@ -11,6 +12,7 @@ import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.util.List;
+import java.util.Set;
 
 /**
  * <p>
@@ -59,4 +61,16 @@ public class TSJobRemindServiceImpl extends ServiceImpl<TSJobRemindMapper, TSJob
     public FlowTaskSmsResult getFlowTaskRemindSmsInfo(Long id) {
         return this.baseMapper.getFlowTaskRemindSmsInfo(id);
     }
+
+    /**
+     * 根据用户id和sop单号集合查找处理时限
+     *
+     * @param userId
+     * @param sopNoSet
+     * @return
+     */
+    @Override
+    public List<WorkTaskResult> getJobRemindProcessHour(Long userId, Set<String> sopNoSet) {
+        return this.baseMapper.getJobRemindProcessHour(userId, sopNoSet);
+    }
 }

+ 2 - 10
sop-business/src/main/resources/mapper/SysUserMapper.xml

@@ -34,11 +34,7 @@
         tfcf.flow_deployment_id as flowDeploymentId,
         tfcfe.id as customFlowEntityid,
         tffa.update_time as flowTime,
-        datediff(now(),FROM_UNIXTIME(tffa.update_time / 1000,'%Y-%m-%d %H:%i:%s')) as diffTime,
-        (select 24 - TIMESTAMPDIFF(hour,
-        DATE_FORMAT(FROM_UNIXTIME(tsjr.exec_time / 1000), '%Y-%m-%d %H:%i:%s'),
-        NOW())  from t_s_job_remind tsjr where tsjr.code = tfcfe.code and tsjr.remind_type = 'AFTER' and tsjr.receive_user_id = #{userId}
-        order by tsjr.create_time desc limit 1) as processHour
+        datediff(now(),FROM_UNIXTIME(tffa.update_time / 1000,'%Y-%m-%d %H:%i:%s')) as diffTime
         from
         ACT_RU_TASK art
         join t_f_flow_approve tffa on art.PROC_INST_ID_ = tffa.flow_id
@@ -98,11 +94,7 @@
         tfcf.flow_deployment_id as flowDeploymentId,
         tfcfe.id as customFlowEntityid,
         tffa.update_time as flowTime,
-        datediff(now(),FROM_UNIXTIME(tffa.update_time / 1000,'%Y-%m-%d %H:%i:%s')) as diffTime,
-        (select 24 - TIMESTAMPDIFF(hour,
-        DATE_FORMAT(FROM_UNIXTIME(tsjr.exec_time / 1000), '%Y-%m-%d %H:%i:%s'),
-        NOW())  from t_s_job_remind tsjr where tsjr.code = tfcfe.code and tsjr.remind_type = 'AFTER' and tsjr.receive_user_id = #{userId}
-        order by tsjr.create_time desc limit 1) as processHour
+        datediff(now(),FROM_UNIXTIME(tffa.update_time / 1000,'%Y-%m-%d %H:%i:%s')) as diffTime
         from
         ACT_RU_TASK art
         left join act_ru_identitylink ari on ari.TASK_ID_ = art.ID_

+ 27 - 0
sop-business/src/main/resources/mapper/TSJobRemindMapper.xml

@@ -22,4 +22,31 @@
         where
             tsjr.id = #{id}
     </select>
+
+    <select id="getJobRemindProcessHour" resultType="com.qmth.sop.business.bean.result.WorkTaskResult">
+        select
+            tsjr.code,
+            24 - TIMESTAMPDIFF(hour,
+                    DATE_FORMAT(FROM_UNIXTIME(max(tsjr.exec_time) / 1000), '%Y-%m-%d %H:%i:%s'),
+                    NOW()) as ex
+        from
+            t_s_job_remind tsjr
+                left join t_f_custom_flow_entity tfcfe on
+                tsjr.code = tfcfe.code
+        <where> 1 = 1
+            and tsjr.remind_type = 'AFTER'
+            <if test="userId != null and userId != ''">
+                and tsjr.receive_user_id = #{userId}
+            </if>
+            <if test="sopNoSet != null and sopNoSet != '' and sopNoSet.size() > 0">
+                and tsjr.code IN
+                <foreach collection="sopNoSet" item="item" index="index" open="(" separator="," close=")">
+                    #{item}
+                </foreach>
+            </if>
+        </where>
+        group by
+            tsjr.code,
+            tsjr.exec_time
+    </select>
 </mapper>