Commit d7273eafb3aee0b39d5ebf1080e2bc33dce72749

Authored by 杨鸣坤
1 parent eba49cc3

page接口时间筛选演示调整

@@ -18,8 +18,10 @@ import org.thingsboard.server.dao.yunteng.service.TkInspectionPlanService; @@ -18,8 +18,10 @@ import org.thingsboard.server.dao.yunteng.service.TkInspectionPlanService;
18 import org.thingsboard.server.queue.util.TbCoreComponent; 18 import org.thingsboard.server.queue.util.TbCoreComponent;
19 19
20 import java.sql.Timestamp; 20 import java.sql.Timestamp;
  21 +import java.text.ParseException;
  22 +import java.text.SimpleDateFormat;
  23 +import java.util.Date;
21 import java.util.HashMap; 24 import java.util.HashMap;
22 -import java.util.List;  
23 import java.util.Map; 25 import java.util.Map;
24 26
25 import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.PAGE; 27 import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.PAGE;
@@ -42,8 +44,10 @@ public class TkInspectionPlanController extends BaseController { @@ -42,8 +44,10 @@ public class TkInspectionPlanController extends BaseController {
42 @RequestParam(PAGE) int page, 44 @RequestParam(PAGE) int page,
43 @RequestParam(value = "name", required = false) String name, 45 @RequestParam(value = "name", required = false) String name,
44 @RequestParam(value = "type", required = false) TkInspectionPlanStatusEnum status, 46 @RequestParam(value = "type", required = false) TkInspectionPlanStatusEnum status,
45 - @RequestParam(value = "startTime", required = false) List<Long> startTime,  
46 - @RequestParam(value = "endTime", required = false) List<Long> endTime 47 + @RequestParam(value = "startTimeStart", required = false) String startTimeStart,
  48 + @RequestParam(value = "startTimeEnd", required = false) String startTimeEnd,
  49 + @RequestParam(value = "endTimeStart", required = false) String endTimeStart,
  50 + @RequestParam(value = "endTimeEnd", required = false) String endTimeEnd
47 ) throws ThingsboardException { 51 ) throws ThingsboardException {
48 Map<String, Object> queryMap = new HashMap<>(); 52 Map<String, Object> queryMap = new HashMap<>();
49 queryMap.put(PAGE_SIZE, pageSize); 53 queryMap.put(PAGE_SIZE, pageSize);
@@ -56,23 +60,43 @@ public class TkInspectionPlanController extends BaseController { @@ -56,23 +60,43 @@ public class TkInspectionPlanController extends BaseController {
56 queryMap.put("status", status); 60 queryMap.put("status", status);
57 } 61 }
58 62
59 - if (startTime != null && startTime.size() == 2) {  
60 - if (startTime.get(0) != null) {  
61 - queryMap.put("startTimeStart", new Timestamp(startTime.get(0)).toLocalDateTime()); 63 + if (StringUtils.isNotBlank(startTimeStart)) {
  64 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  65 + try {
  66 + Date date = sdf.parse(startTimeStart);
  67 + queryMap.put("startTimeStart", new Timestamp(date.getTime()).toLocalDateTime());
  68 + } catch (ParseException e) {
  69 + throw new RuntimeException(e);
62 } 70 }
  71 + }
63 72
64 - if (startTime.get(1) != null) {  
65 - queryMap.put("startTimeEnd", new Timestamp(startTime.get(1)).toLocalDateTime()); 73 + if (StringUtils.isNotBlank(startTimeEnd)) {
  74 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  75 + try {
  76 + Date date = sdf.parse(startTimeEnd);
  77 + queryMap.put("startTimeEnd", new Timestamp(date.getTime()).toLocalDateTime());
  78 + } catch (ParseException e) {
  79 + throw new RuntimeException(e);
66 } 80 }
67 } 81 }
68 82
69 - if (endTime != null && endTime.size() == 2) {  
70 - if (endTime.get(0) != null) {  
71 - queryMap.put("endTimeStart", new Timestamp(endTime.get(0)).toLocalDateTime()); 83 + if (StringUtils.isNotBlank(endTimeStart)) {
  84 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  85 + try {
  86 + Date date = sdf.parse(endTimeStart);
  87 + queryMap.put("endTimeStart", new Timestamp(date.getTime()).toLocalDateTime());
  88 + } catch (ParseException e) {
  89 + throw new RuntimeException(e);
72 } 90 }
  91 + }
73 92
74 - if (endTime.get(1) != null) {  
75 - queryMap.put("endTimeEnd", new Timestamp(endTime.get(1)).toLocalDateTime()); 93 + if (StringUtils.isNotBlank(endTimeEnd)) {
  94 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  95 + try {
  96 + Date date = sdf.parse(endTimeEnd);
  97 + queryMap.put("endTimeEnd", new Timestamp(date.getTime()).toLocalDateTime());
  98 + } catch (ParseException e) {
  99 + throw new RuntimeException(e);
76 } 100 }
77 } 101 }
78 102
@@ -16,6 +16,10 @@ import org.thingsboard.server.controller.BaseController; @@ -16,6 +16,10 @@ import org.thingsboard.server.controller.BaseController;
16 import org.thingsboard.server.dao.yunteng.service.TkInspectionRecordService; 16 import org.thingsboard.server.dao.yunteng.service.TkInspectionRecordService;
17 import org.thingsboard.server.queue.util.TbCoreComponent; 17 import org.thingsboard.server.queue.util.TbCoreComponent;
18 18
  19 +import java.sql.Timestamp;
  20 +import java.text.ParseException;
  21 +import java.text.SimpleDateFormat;
  22 +import java.util.Date;
19 import java.util.HashMap; 23 import java.util.HashMap;
20 import java.util.Map; 24 import java.util.Map;
21 25
@@ -40,8 +44,8 @@ public class TkInspectionRecordController extends BaseController { @@ -40,8 +44,8 @@ public class TkInspectionRecordController extends BaseController {
40 @RequestParam(value = "inspectionPlanId", required = false) String inspectionPlanId, 44 @RequestParam(value = "inspectionPlanId", required = false) String inspectionPlanId,
41 @RequestParam(value = "inspectionPlanName", required = false) String inspectionPlanName, 45 @RequestParam(value = "inspectionPlanName", required = false) String inspectionPlanName,
42 @RequestParam(value = "inspectorId", required = false) String inspectorId, 46 @RequestParam(value = "inspectorId", required = false) String inspectorId,
43 - @RequestParam(value = "startTime", required = false) Long startTime,  
44 - @RequestParam(value = "endTime", required = false) Long endTime, 47 + @RequestParam(value = "startTime", required = false) String startTime,
  48 + @RequestParam(value = "endTime", required = false) String endTime,
45 @RequestParam(value = "recordResult", required = false) Boolean recordResult, 49 @RequestParam(value = "recordResult", required = false) Boolean recordResult,
46 @RequestParam(value = "deviceId", required = false) String deviceId 50 @RequestParam(value = "deviceId", required = false) String deviceId
47 ) throws ThingsboardException { 51 ) throws ThingsboardException {
@@ -68,7 +72,26 @@ public class TkInspectionRecordController extends BaseController { @@ -68,7 +72,26 @@ public class TkInspectionRecordController extends BaseController {
68 queryMap.put("deviceId", deviceId); 72 queryMap.put("deviceId", deviceId);
69 } 73 }
70 74
71 - checkTimeAndPut(queryMap, startTime, endTime); 75 + if (StringUtils.isNotBlank(startTime)) {
  76 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  77 + try {
  78 + Date startDate = sdf.parse(startTime);
  79 + queryMap.put("startTime", new Timestamp(startDate.getTime()).toLocalDateTime());
  80 + } catch (ParseException e) {
  81 + throw new RuntimeException(e);
  82 + }
  83 + }
  84 +
  85 + if (StringUtils.isNotBlank(endTime)) {
  86 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  87 + try {
  88 + Date endDate = sdf.parse(endTime);
  89 + queryMap.put("endTime", new Timestamp(endDate.getTime()).toLocalDateTime());
  90 + } catch (ParseException e) {
  91 + throw new RuntimeException(e);
  92 + }
  93 + }
  94 +
72 return tkInspectionRecordService.page(queryMap, getCurrentUser().getCurrentTenantId()); 95 return tkInspectionRecordService.page(queryMap, getCurrentUser().getCurrentTenantId());
73 } 96 }
74 97