Commit 7cf3766f5b86a087b19859fa8a718d20a421b084
1 parent
0addfb59
fix: new customer homepage statistics
Showing
1 changed file
with
12 additions
and
9 deletions
... | ... | @@ -72,10 +72,11 @@ public class TkHomePageServiceImpl implements HomePageService { |
72 | 72 | HomePageLeftTopDTO homePageLeftTopDTO = new HomePageLeftTopDTO(); |
73 | 73 | HomeDeviceInfoDTO homeDeviceInfo; |
74 | 74 | LocalDateTime nowTime = LocalDateTime.now(); |
75 | + int zero = FastIotConstants.MagicNumber.ZERO; | |
75 | 76 | LocalDateTime startTime = LocalDateTime.of(nowTime.toLocalDate(), LocalTime.MIN); |
76 | 77 | LocalDateTime endTime = LocalDateTime.of(nowTime.toLocalDate(), LocalTime.MAX); |
77 | - HomePageTopMessage messageInfo = new HomePageTopMessage(FastIotConstants.MagicNumber.ZERO); | |
78 | - BaseHomePageTop alarm = new BaseHomePageTop(FastIotConstants.MagicNumber.ZERO); | |
78 | + HomePageTopMessage messageInfo = new HomePageTopMessage(zero); | |
79 | + BaseHomePageTop alarm = new BaseHomePageTop(zero); | |
79 | 80 | Map<String, Object> queryMap = new HashMap<>(); |
80 | 81 | List<DeviceDTO> deviceList; |
81 | 82 | if (isPtSysAdmin || isPtAdmin) { |
... | ... | @@ -92,19 +93,21 @@ public class TkHomePageServiceImpl implements HomePageService { |
92 | 93 | queryMap.put("customerId", customerId); |
93 | 94 | long startTs = startTime.toInstant(ZoneOffset.of("+8")).toEpochMilli(); |
94 | 95 | List<BaseHomePageTop> baseHomePageTopList = deviceMapper.findDeviceMessageInfo(startTs, customerId); |
95 | - if (baseHomePageTopList.size() > FastIotConstants.MagicNumber.ZERO) { | |
96 | - messageInfo.setMessageCount(baseHomePageTopList.get(0).getSumCount()); | |
97 | - messageInfo.setTodayMessageAdd(baseHomePageTopList.get(0).getTodayAdd()); | |
96 | + if (baseHomePageTopList.size() > zero) { | |
97 | + BaseHomePageTop homePageTop = baseHomePageTopList.get(zero); | |
98 | + messageInfo.setMessageCount(homePageTop.getSumCount()); | |
99 | + messageInfo.setTodayMessageAdd(homePageTop.getTodayAdd()==null?zero:homePageTop.getTodayAdd()); | |
98 | 100 | } |
99 | 101 | List<BaseHomePageTop> alarmList = deviceMapper.findDeviceAlarmInfoByCustomer(startTs, customerId); |
100 | - if (alarmList.size() > FastIotConstants.MagicNumber.ZERO) { | |
101 | - alarm.setSumCount(alarmList.get(0).getSumCount()); | |
102 | - alarm.setTodayAdd(alarmList.get(0).getTodayAdd()); | |
102 | + if (alarmList.size() > zero) { | |
103 | + BaseHomePageTop homePageTop = alarmList.get(zero); | |
104 | + alarm.setSumCount(homePageTop.getSumCount()); | |
105 | + alarm.setTodayAdd(homePageTop.getTodayAdd()==null?zero:homePageTop.getTodayAdd()); | |
103 | 106 | } |
104 | 107 | } |
105 | 108 | } |
106 | 109 | deviceList = deviceMapper.findDevices(queryMap); |
107 | - homeDeviceInfo = new HomeDeviceInfoDTO(FastIotConstants.MagicNumber.ZERO); | |
110 | + homeDeviceInfo = new HomeDeviceInfoDTO(zero); | |
108 | 111 | if (null != deviceList) { |
109 | 112 | setDeviceInfoData(deviceList, homeDeviceInfo); |
110 | 113 | } | ... | ... |