|
@@ -23,13 +23,18 @@ import org.thingsboard.server.common.data.yunteng.enums.StatusEnum; |
|
@@ -23,13 +23,18 @@ import org.thingsboard.server.common.data.yunteng.enums.StatusEnum; |
23
|
import org.thingsboard.server.common.data.yunteng.enums.TargetTypeEnum;
|
23
|
import org.thingsboard.server.common.data.yunteng.enums.TargetTypeEnum;
|
24
|
import org.thingsboard.server.common.data.yunteng.utils.JacksonUtil;
|
24
|
import org.thingsboard.server.common.data.yunteng.utils.JacksonUtil;
|
25
|
import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData;
|
25
|
import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData;
|
|
|
26
|
+import org.thingsboard.server.dao.util.yunteng.task.RelativeDateHandler;
|
26
|
import org.thingsboard.server.dao.yunteng.entities.TkDeviceTaskCenterEntity;
|
27
|
import org.thingsboard.server.dao.yunteng.entities.TkDeviceTaskCenterEntity;
|
27
|
import org.thingsboard.server.dao.yunteng.entities.TkTaskCenterEntity;
|
28
|
import org.thingsboard.server.dao.yunteng.entities.TkTaskCenterEntity;
|
28
|
import org.thingsboard.server.dao.yunteng.mapper.TkTaskCenterMapper;
|
29
|
import org.thingsboard.server.dao.yunteng.mapper.TkTaskCenterMapper;
|
29
|
import org.thingsboard.server.dao.yunteng.service.*;
|
30
|
import org.thingsboard.server.dao.yunteng.service.*;
|
30
|
|
31
|
|
31
|
import javax.transaction.Transactional;
|
32
|
import javax.transaction.Transactional;
|
|
|
33
|
+import java.time.Instant;
|
|
|
34
|
+import java.time.LocalDateTime;
|
|
|
35
|
+import java.time.ZoneOffset;
|
32
|
import java.util.*;
|
36
|
import java.util.*;
|
|
|
37
|
+import java.util.stream.Collectors;
|
33
|
|
38
|
|
34
|
@Service
|
39
|
@Service
|
35
|
@RequiredArgsConstructor
|
40
|
@RequiredArgsConstructor
|
|
@@ -50,24 +55,39 @@ public class TkTaskCenterServiceImpl |
|
@@ -50,24 +55,39 @@ public class TkTaskCenterServiceImpl |
50
|
getPage(queryMap, FastIotConstants.DefaultOrder.CREATE_TIME, false);
|
55
|
getPage(queryMap, FastIotConstants.DefaultOrder.CREATE_TIME, false);
|
51
|
IPage<TkTaskCenterDTO> iPage = baseMapper.getPageData(page, queryMap);
|
56
|
IPage<TkTaskCenterDTO> iPage = baseMapper.getPageData(page, queryMap);
|
52
|
if (!iPage.getRecords().isEmpty()) {
|
57
|
if (!iPage.getRecords().isEmpty()) {
|
53
|
- iPage.getRecords().stream()
|
|
|
54
|
- .peek(
|
|
|
55
|
- obj -> {
|
|
|
56
|
- // 任务执行时间
|
|
|
57
|
- String key =
|
|
|
58
|
- FastIotConstants.CacheConfigKey.TASK_CENTER_EXECUTE_TIME + "_" + obj.getId();
|
58
|
+ iPage.setRecords(
|
|
|
59
|
+ iPage.getRecords().stream()
|
|
|
60
|
+ .map(
|
|
|
61
|
+ obj -> {
|
|
|
62
|
+ // 任务执行时间
|
|
|
63
|
+ String key =
|
|
|
64
|
+ FastIotConstants.CacheConfigKey.TASK_CENTER_EXECUTE_TIME
|
|
|
65
|
+ + "_"
|
|
|
66
|
+ + obj.getId();
|
59
|
|
67
|
|
60
|
- // 如果通过设备查询分页,以设备执行时间为准
|
|
|
61
|
- String tbDeviceId = (String) queryMap.get("tbDeviceId");
|
|
|
62
|
- if (null != tbDeviceId) {
|
|
|
63
|
- key =
|
|
|
64
|
- FastIotConstants.CacheConfigKey.TASK_CENTER_DEVICE_EXECUTE_TIME
|
|
|
65
|
- + "_"
|
|
|
66
|
- + tbDeviceId;
|
|
|
67
|
- }
|
|
|
68
|
- Optional<Long> lastExecuteTime = cacheUtils.get(cacheName, key);
|
|
|
69
|
- lastExecuteTime.ifPresent(obj::setLastExecuteTime);
|
|
|
70
|
- });
|
68
|
+ // 如果通过设备查询分页,以设备执行时间为准
|
|
|
69
|
+ String tbDeviceId = (String) queryMap.get("tbDeviceId");
|
|
|
70
|
+ if (null != tbDeviceId) {
|
|
|
71
|
+ key =
|
|
|
72
|
+ FastIotConstants.CacheConfigKey.TASK_CENTER_DEVICE_EXECUTE_TIME
|
|
|
73
|
+ + "_"
|
|
|
74
|
+ + obj.getId()
|
|
|
75
|
+ + "_"
|
|
|
76
|
+ + tbDeviceId;
|
|
|
77
|
+ }
|
|
|
78
|
+ Optional<Long> lastExecuteTime = cacheUtils.get(cacheName, key);
|
|
|
79
|
+ if (lastExecuteTime.isPresent()) {
|
|
|
80
|
+ Long executeTime = lastExecuteTime.get();
|
|
|
81
|
+ obj.setLastExecuteTime(executeTime);
|
|
|
82
|
+ LocalDateTime localDateTime =
|
|
|
83
|
+ Instant.ofEpochMilli(executeTime)
|
|
|
84
|
+ .atZone(ZoneOffset.ofHours(8))
|
|
|
85
|
+ .toLocalDateTime();
|
|
|
86
|
+ obj.setLastExecuteStr(RelativeDateHandler.format(localDateTime));
|
|
|
87
|
+ }
|
|
|
88
|
+ return obj;
|
|
|
89
|
+ })
|
|
|
90
|
+ .collect(Collectors.toList()));
|
71
|
}
|
91
|
}
|
72
|
return new TkPageData<>(iPage.getRecords(), iPage.getTotal());
|
92
|
return new TkPageData<>(iPage.getRecords(), iPage.getTotal());
|
73
|
}
|
93
|
}
|