فهرست منبع

添加任务时长字段

buzhanyi 1 سال پیش
والد
کامیت
6e7c7fdc0a

+ 5 - 3
application-webadmin/src/main/java/com/ankaibei/workFlow/webadmin/ankaibei/mapper/TaskInfoMapper.java

@@ -20,9 +20,11 @@ import java.util.Map;
 public interface TaskInfoMapper extends JpaRepository<TaskInfoEntity, Integer>, JpaSpecificationExecutor<TaskInfoEntity> {
 
 
-    @Query(value = "SELECT t.task_id taskId,t.target_task targetTask,t.task_priority taskPriority,t.task_participant taskParticipant,t.start_time startTime,t.end_time endTime,\n" +
-            "t.task_status taskStatus,t.task_creator taskCreator,t.task_index taskIndex,t.task_standard taskStandard,t.task_statements\n" +
-            "taskStatements,t.project_id projectId,t.process_instance_id processInstanceId,t.flow_task_status flowTaskStatus,t.process_definition_id processDefinitionId  from task_info t WHERE if( ?1 !='', t.target_task = ?1 , 1=1) AND if( ?2 !='', t.task_status = ?2 , 1=1) and is_delete='1' order by t.create_date desc ",
+    @Query(value = "SELECT t.task_id taskId,t.target_task targetTask,t.task_priority taskPriority,t.task_participant taskParticipant," +
+            "t.start_time startTime,t.end_time endTime,t.task_status taskStatus,t.task_creator taskCreator,t.task_index taskIndex," +
+            "t.task_standard taskStandard,t.task_statements taskStatements,t.project_id projectId,t.process_instance_id processInstanceId," +
+            "t.flow_task_status flowTaskStatus,t.process_definition_id processDefinitionId  from task_info t WHERE if( ?1 !='', t.target_task = ?1 , 1=1) " +
+            "AND if( ?2 !='', t.task_status = ?2 , 1=1) and is_delete='1' order by t.create_date desc ",
             countQuery = "select count(1)from task_info t WHERE if( ?1 !='', t.target_task = ?1 , 1=1) AND if( ?2 !='', t.task_status = ?2 , 1=1)", nativeQuery = true)
     Page<Map<String, String>> findTaskInfo(String targetTask, String taskStatus, Pageable page);
 

+ 14 - 1
application-webadmin/src/main/java/com/ankaibei/workFlow/webadmin/ankaibei/service/impl/TaskInfoServiceImpl.java

@@ -31,6 +31,9 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
+import java.time.Duration;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -102,7 +105,17 @@ public class TaskInfoServiceImpl implements TaskInfoService {
                             }
                         });
             }
-
+            //求任务耗时,结束时间-开始时间
+            if (ObjectUtils.isNotEmpty(map1.get("start_time")) && ObjectUtils.isNotEmpty(map1.get("end_time"))) {
+                DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+                LocalDateTime startDateTime = LocalDateTime.parse(map1.get("start_time").toString(), formatter);
+                LocalDateTime endDateTime = LocalDateTime.parse(map1.get("end_time").toString(), formatter);
+                //求差值,转换时间单位
+                Duration duration = Duration.between(startDateTime, endDateTime);
+                long daysDiff = duration.toDays();
+                long hoursDiff = duration.toHours() % 24;
+                map1.put("duration_ch", daysDiff + "天" + hoursDiff + "时");
+            }
             map1.put("taskPriority", TaskPriority.getEnumByCode(map.get("taskPriority")));
             return map1;
         }).getContent(), all.getTotalElements()));