Commit ff93d67aa5cb9cdaf9bdf8f693f791554b2efc42

Authored by xp.Huang
1 parent 592d4417

fix: 修复任务中心分页及设备详情任务分页

@@ -30,7 +30,6 @@ import org.thingsboard.server.dao.yunteng.service.*; @@ -30,7 +30,6 @@ import org.thingsboard.server.dao.yunteng.service.*;
30 30
31 import javax.transaction.Transactional; 31 import javax.transaction.Transactional;
32 import java.util.*; 32 import java.util.*;
33 -import java.util.stream.Collectors;  
34 33
35 @Service 34 @Service
36 @RequiredArgsConstructor 35 @RequiredArgsConstructor
@@ -51,29 +50,24 @@ public class TkTaskCenterServiceImpl @@ -51,29 +50,24 @@ public class TkTaskCenterServiceImpl
51 getPage(queryMap, FastIotConstants.DefaultOrder.CREATE_TIME, false); 50 getPage(queryMap, FastIotConstants.DefaultOrder.CREATE_TIME, false);
52 IPage<TkTaskCenterDTO> iPage = baseMapper.getPageData(page, queryMap); 51 IPage<TkTaskCenterDTO> iPage = baseMapper.getPageData(page, queryMap);
53 if (!iPage.getRecords().isEmpty()) { 52 if (!iPage.getRecords().isEmpty()) {
54 - iPage.setRecords(  
55 - iPage.getRecords().stream()  
56 - .map(  
57 - obj -> {  
58 - // 任务执行时间  
59 - String key =  
60 - FastIotConstants.CacheConfigKey.TASK_CENTER_EXECUTE_TIME  
61 - + "_"  
62 - + obj.getId(); 53 + iPage.getRecords().stream()
  54 + .peek(
  55 + obj -> {
  56 + // 任务执行时间
  57 + String key =
  58 + FastIotConstants.CacheConfigKey.TASK_CENTER_EXECUTE_TIME + "_" + obj.getId();
63 59
64 - // 如果通过设备查询分页,以设备执行时间为准  
65 - String tbDeviceId = (String) queryMap.get("tbDeviceId");  
66 - if (null != tbDeviceId) {  
67 - key =  
68 - FastIotConstants.CacheConfigKey.TASK_CENTER_DEVICE_EXECUTE_TIME  
69 - + "_"  
70 - + tbDeviceId;  
71 - }  
72 - Optional<Long> lastExecuteTime = cacheUtils.get(cacheName, key);  
73 - lastExecuteTime.ifPresent(obj::setLastExecuteTime);  
74 - return obj;  
75 - })  
76 - .collect(Collectors.toList())); 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 + });
77 } 71 }
78 return new TkPageData<>(iPage.getRecords(), iPage.getTotal()); 72 return new TkPageData<>(iPage.getRecords(), iPage.getTotal());
79 } 73 }
@@ -31,16 +31,16 @@ @@ -31,16 +31,16 @@
31 tc.id,tc.name,tc.target_type,tc.execute_target,tc.execute_content,tc.execute_time,tc.create_time,tc.creator, 31 tc.id,tc.name,tc.target_type,tc.execute_target,tc.execute_content,tc.execute_time,tc.create_time,tc.creator,
32 tc.updater,tc.update_time,tc.tenant_id,tc.state 32 tc.updater,tc.update_time,tc.tenant_id,tc.state
33 </sql> 33 </sql>
34 -  
35 - <sql id="detailColumns">  
36 - <include refid="basicColumns"/>  
37 - ,tdc.allow_state,tdc.task_center_id,tb_device_id  
38 - </sql>  
39 <select id="getPageData" resultMap="dataMap"> 34 <select id="getPageData" resultMap="dataMap">
40 SELECT 35 SELECT
41 - <include refid="detailColumns"/> 36 + <include refid="basicColumns"/>
  37 + <if test="queryMap.tbDeviceId !=null and queryMap.tbDeviceId !=''">
  38 + ,tdc.allow_state,tdc.task_center_id,tdc.tb_device_id
  39 + </if>
42 FROM tk_task_center tc 40 FROM tk_task_center tc
43 - LEFT JOIN tk_device_task_center tdc ON tc.id = tdc.task_center_id 41 + <if test="queryMap.tbDeviceId !=null and queryMap.tbDeviceId !=''">
  42 + LEFT JOIN tk_device_task_center tdc ON tc.id = tdc.task_center_id
  43 + </if>
44 <where> 44 <where>
45 <if test="queryMap.tenantId !=null and queryMap.tenantId !=''"> 45 <if test="queryMap.tenantId !=null and queryMap.tenantId !=''">
46 AND tc.tenant_id = #{queryMap.tenantId} 46 AND tc.tenant_id = #{queryMap.tenantId}