|
@@ -3,17 +3,22 @@ package com.usky.park.service.impl;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.usky.common.core.bean.CommonPage;
|
|
|
-import com.usky.park.domain.DmpDevice;
|
|
|
-import com.usky.park.domain.DataRealTime;
|
|
|
+import com.usky.common.security.utils.SecurityUtils;
|
|
|
+import com.usky.park.domain.*;
|
|
|
+import com.usky.park.service.DataEvHistoryService;
|
|
|
+import com.usky.park.service.DataGrHistoryService;
|
|
|
+import com.usky.park.service.DataLgHistoryService;
|
|
|
import com.usky.park.mapper.DmpDeviceMapper;
|
|
|
-import com.usky.park.service.DataRealTimeService;
|
|
|
-import com.usky.park.service.DmpDeviceService;
|
|
|
+import com.usky.park.service.*;
|
|
|
import com.usky.common.mybatis.core.AbstractCrudService;
|
|
|
import com.usky.park.service.vo.DmpDeviceVO;
|
|
|
+import com.usky.park.service.vo.HistoryAttributeVO;
|
|
|
+import com.usky.park.service.vo.KeyValueVO;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -39,8 +44,17 @@ public class DmpDeviceServiceImpl extends AbstractCrudService<DmpDeviceMapper, D
|
|
|
@Autowired
|
|
|
private DataRealTimeService dataRealTimeService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private DataGrHistoryService dataGrHistoryService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private DataEvHistoryService dataEvHistoryService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private DataLgHistoryService dataLgHistoryService;
|
|
|
+
|
|
|
@Override
|
|
|
- public CommonPage<DmpDeviceVO> dmpDeviceList(String deviceName,String installAddress,String deviceType,String deviceStatus,String doorStatus,String startDate,String endDate,Integer pageNum,Integer pageSize){
|
|
|
+ public CommonPage<DmpDeviceVO> dmpDeviceList(String deviceName,String installAddress,Integer deviceType,String deviceStatus,String doorStatus,String switchStatus,String startDate,String endDate,Integer pageNum,Integer pageSize){
|
|
|
|
|
|
LambdaQueryWrapper<DmpDevice> queryWrapper = Wrappers.lambdaQuery();
|
|
|
queryWrapper.select(DmpDevice::getDeviceId,DmpDevice::getDeviceName,DmpDevice::getDeviceType,DmpDevice::getInstallAddress,DmpDevice::getCreatedTime)
|
|
@@ -64,8 +78,6 @@ public class DmpDeviceServiceImpl extends AbstractCrudService<DmpDeviceMapper, D
|
|
|
.in(DataRealTime::getDeviceId,deviceIdList);
|
|
|
list1 = dataRealTimeService.list(queryWrapper1);
|
|
|
|
|
|
-
|
|
|
-
|
|
|
List<DataRealTime> list2 = new ArrayList<>();
|
|
|
LambdaQueryWrapper<DataRealTime> queryWrapper2 = Wrappers.lambdaQuery();
|
|
|
queryWrapper2.select(DataRealTime::getDeviceId,DataRealTime::getAttributeName,DataRealTime::getAttributeData)
|
|
@@ -74,6 +86,14 @@ public class DmpDeviceServiceImpl extends AbstractCrudService<DmpDeviceMapper, D
|
|
|
list2 = dataRealTimeService.list(queryWrapper2);
|
|
|
|
|
|
|
|
|
+ List<DataRealTime> switchList = new ArrayList<>();
|
|
|
+ LambdaQueryWrapper<DataRealTime> queryWrapper3 = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper3.select(DataRealTime::getDeviceId,DataRealTime::getAttributeName,DataRealTime::getAttributeData)
|
|
|
+ .eq(DataRealTime::getAttributeName,"switch_status")
|
|
|
+ .in(DataRealTime::getDeviceId,deviceIdList);
|
|
|
+ switchList = dataRealTimeService.list(queryWrapper3);
|
|
|
+
|
|
|
+
|
|
|
List<DmpDeviceVO> list3 = new ArrayList<>();
|
|
|
for(int i=0;i<pagelist.size();i++){
|
|
|
|
|
@@ -99,19 +119,35 @@ public class DmpDeviceServiceImpl extends AbstractCrudService<DmpDeviceMapper, D
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ if(switchList.size()>0){
|
|
|
+ for(int j=0;j<switchList.size();j++){
|
|
|
+ if(pagelist.get(i).getDeviceId().equals(switchList.get(j).getDeviceId())){
|
|
|
+ dmpDeviceVO.setSwitchStatus(switchList.get(j).getAttributeData());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
list3.add(dmpDeviceVO);
|
|
|
}
|
|
|
|
|
|
- if(deviceStatus.length()>0){
|
|
|
+ if(StringUtils.isNotBlank(deviceStatus)){
|
|
|
list = list3.stream().filter(e -> deviceStatus.equals(e.getDeviceStatus())).collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
- if(doorStatus.length()>0){
|
|
|
+ if(StringUtils.isNotBlank(doorStatus)){
|
|
|
list = list3.stream().filter(e -> doorStatus.equals(e.getDoorStatus())).collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
- if((deviceStatus.length()==0 )&&(doorStatus.length()==0)){
|
|
|
- list = list3;
|
|
|
+ if(StringUtils.isNotBlank(switchStatus)){
|
|
|
+ list = list3.stream().filter(e -> switchStatus.equals(e.getSwitchStatus())).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ if((StringUtils.isBlank(deviceStatus))&&(StringUtils.isBlank(doorStatus))&&(StringUtils.isBlank(switchStatus))){
|
|
|
+ if(list3.size()>0){
|
|
|
+ for(int i=0;i<list3.size();i++){
|
|
|
+ list.add(list3.get(i));
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -140,6 +176,11 @@ public class DmpDeviceServiceImpl extends AbstractCrudService<DmpDeviceMapper, D
|
|
|
.like(StringUtils.isNotBlank(installAddress),DmpDevice::getInstallAddress,installAddress)
|
|
|
.eq(DmpDevice::getDeviceType,deviceType);
|
|
|
devList = this.list(queryWrapper);
|
|
|
+
|
|
|
+ if(devList.size() <=0){
|
|
|
+ return new CommonPage<>(list,0,pageNum,pageSize);
|
|
|
+ }
|
|
|
+
|
|
|
if(devList.size()>0){
|
|
|
for(int i=0;i<devList.size();i++){
|
|
|
Map<String,Object> map = new HashMap<>();
|
|
@@ -163,9 +204,7 @@ public class DmpDeviceServiceImpl extends AbstractCrudService<DmpDeviceMapper, D
|
|
|
found = false;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
if(deviceType == 510){
|
|
|
if(found){
|
|
|
list.add(map);
|
|
@@ -196,4 +235,89 @@ public class DmpDeviceServiceImpl extends AbstractCrudService<DmpDeviceMapper, D
|
|
|
return new CommonPage<>(objectList,total,pageNum,pageSize);
|
|
|
}
|
|
|
|
|
|
+ public List<HistoryAttributeVO> deviceHistoryDataList(String deviceId, Integer deviceType, List<String> deviceAttribute, String startDate, String endDate){
|
|
|
+ List<HistoryAttributeVO> list = new ArrayList<>();
|
|
|
+ switch (deviceType){
|
|
|
+ case 504:
|
|
|
+ for(int i=0;i<deviceAttribute.size();i++){
|
|
|
+ HistoryAttributeVO historyAttributeVO = new HistoryAttributeVO();
|
|
|
+
|
|
|
+ historyAttributeVO.setDeviceAttribute(deviceAttribute.get(i));
|
|
|
+ List<KeyValueVO> list2 = new ArrayList<>();
|
|
|
+
|
|
|
+ LambdaQueryWrapper<DataGrHistory> queryWrapper1 = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper1.select(DataGrHistory::getAttributeData,DataGrHistory::getDataTime)
|
|
|
+ .eq(DataGrHistory::getDeviceId,deviceId)
|
|
|
+ .eq(DataGrHistory::getAttributeName,deviceAttribute.get(i))
|
|
|
+ .between(DataGrHistory::getDataTime,startDate,endDate);
|
|
|
+ List<DataGrHistory> grList = dataGrHistoryService.list(queryWrapper1);
|
|
|
+ if(CollectionUtils.isNotEmpty(grList)){
|
|
|
+ for(int j=0;j< grList.size();j++){
|
|
|
+ KeyValueVO keyValueVO = new KeyValueVO();
|
|
|
+ keyValueVO.setValue(grList.get(j).getAttributeData());
|
|
|
+ keyValueVO.setTime(grList.get(j).getDataTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
|
|
+ list2.add(keyValueVO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ historyAttributeVO.setKvList(list2);
|
|
|
+ list.add(historyAttributeVO);
|
|
|
+ }
|
|
|
+
|
|
|
+ break;
|
|
|
+ case 509:
|
|
|
+ for(int i=0;i<deviceAttribute.size();i++){
|
|
|
+ HistoryAttributeVO historyAttributeVO = new HistoryAttributeVO();
|
|
|
+
|
|
|
+ historyAttributeVO.setDeviceAttribute(deviceAttribute.get(i));
|
|
|
+ List<KeyValueVO> list2 = new ArrayList<>();
|
|
|
+
|
|
|
+ LambdaQueryWrapper<DataEvHistory> queryWrapper1 = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper1.select(DataEvHistory::getAttributeData,DataEvHistory::getDataTime)
|
|
|
+ .eq(DataEvHistory::getDeviceId,deviceId)
|
|
|
+ .eq(DataEvHistory::getAttributeName,deviceAttribute.get(i))
|
|
|
+ .between(DataEvHistory::getDataTime,startDate,endDate);
|
|
|
+ List<DataEvHistory> evList = dataEvHistoryService.list(queryWrapper1);
|
|
|
+ if(CollectionUtils.isNotEmpty(evList)){
|
|
|
+ for(int j=0;j< evList.size();j++){
|
|
|
+ KeyValueVO keyValueVO = new KeyValueVO();
|
|
|
+ keyValueVO.setValue(evList.get(j).getAttributeData());
|
|
|
+ keyValueVO.setTime(evList.get(j).getDataTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
|
|
+ list2.add(keyValueVO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ historyAttributeVO.setKvList(list2);
|
|
|
+ list.add(historyAttributeVO);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 510:
|
|
|
+ for(int i=0;i<deviceAttribute.size();i++){
|
|
|
+ HistoryAttributeVO historyAttributeVO = new HistoryAttributeVO();
|
|
|
+
|
|
|
+ historyAttributeVO.setDeviceAttribute(deviceAttribute.get(i));
|
|
|
+ List<KeyValueVO> list2 = new ArrayList<>();
|
|
|
+
|
|
|
+ LambdaQueryWrapper<DataLgHistory> queryWrapper1 = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper1.select(DataLgHistory::getAttributeData,DataLgHistory::getDataTime)
|
|
|
+ .eq(DataLgHistory::getDeviceId,deviceId)
|
|
|
+ .eq(DataLgHistory::getAttributeName,deviceAttribute.get(i))
|
|
|
+ .between(DataLgHistory::getDataTime,startDate,endDate);
|
|
|
+ List<DataLgHistory> lgList = dataLgHistoryService.list(queryWrapper1);
|
|
|
+ if(CollectionUtils.isNotEmpty(lgList)){
|
|
|
+ for(int j=0;j< lgList.size();j++){
|
|
|
+ KeyValueVO keyValueVO = new KeyValueVO();
|
|
|
+ keyValueVO.setValue(lgList.get(j).getAttributeData());
|
|
|
+ keyValueVO.setTime(lgList.get(j).getDataTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
|
|
+ list2.add(keyValueVO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ historyAttributeVO.setKvList(list2);
|
|
|
+ list.add(historyAttributeVO);
|
|
|
+ }
|
|
|
+
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|