|
@@ -250,7 +250,8 @@ public class DmpDeviceServiceImpl extends AbstractCrudService<DmpDeviceMapper, D
|
|
|
queryWrapper1.select(DataGrHistory::getAttributeData,DataGrHistory::getDataTime)
|
|
|
.eq(DataGrHistory::getDeviceId,deviceId)
|
|
|
.eq(DataGrHistory::getAttributeName,deviceAttribute.get(i))
|
|
|
- .between(DataGrHistory::getDataTime,startDate,endDate);
|
|
|
+ .between(DataGrHistory::getDataTime,startDate,endDate)
|
|
|
+ .orderByDesc(DataGrHistory::getId);
|
|
|
List<DataGrHistory> grList = dataGrHistoryService.list(queryWrapper1);
|
|
|
if(CollectionUtils.isNotEmpty(grList)){
|
|
|
for(int j=0;j< grList.size();j++){
|
|
@@ -276,7 +277,8 @@ public class DmpDeviceServiceImpl extends AbstractCrudService<DmpDeviceMapper, D
|
|
|
queryWrapper1.select(DataEvHistory::getAttributeData,DataEvHistory::getDataTime)
|
|
|
.eq(DataEvHistory::getDeviceId,deviceId)
|
|
|
.eq(DataEvHistory::getAttributeName,deviceAttribute.get(i))
|
|
|
- .between(DataEvHistory::getDataTime,startDate,endDate);
|
|
|
+ .between(DataEvHistory::getDataTime,startDate,endDate)
|
|
|
+ .orderByDesc(DataEvHistory::getId);
|
|
|
List<DataEvHistory> evList = dataEvHistoryService.list(queryWrapper1);
|
|
|
if(CollectionUtils.isNotEmpty(evList)){
|
|
|
for(int j=0;j< evList.size();j++){
|
|
@@ -301,7 +303,8 @@ public class DmpDeviceServiceImpl extends AbstractCrudService<DmpDeviceMapper, D
|
|
|
queryWrapper1.select(DataLgHistory::getAttributeData,DataLgHistory::getDataTime)
|
|
|
.eq(DataLgHistory::getDeviceId,deviceId)
|
|
|
.eq(DataLgHistory::getAttributeName,deviceAttribute.get(i))
|
|
|
- .between(DataLgHistory::getDataTime,startDate,endDate);
|
|
|
+ .between(DataLgHistory::getDataTime,startDate,endDate)
|
|
|
+ .orderByDesc(DataLgHistory::getId);
|
|
|
List<DataLgHistory> lgList = dataLgHistoryService.list(queryWrapper1);
|
|
|
if(CollectionUtils.isNotEmpty(lgList)){
|
|
|
for(int j=0;j< lgList.size();j++){
|
|
@@ -321,4 +324,48 @@ public class DmpDeviceServiceImpl extends AbstractCrudService<DmpDeviceMapper, D
|
|
|
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String,Object> evBuildHealth(){
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
+ float co2 = attributeStatistic(509,"co2");
|
|
|
+ map.put("co2",co2);
|
|
|
+ float jq = attributeStatistic(509,"jq");
|
|
|
+ map.put("jq",jq);
|
|
|
+ float pm2_5 = attributeStatistic(509,"pm2.5");
|
|
|
+ map.put("pm2.5",pm2_5);
|
|
|
+ float pm1_0 = attributeStatistic(509,"pm1.0");
|
|
|
+ map.put("pm1.0",pm1_0);
|
|
|
+ float pm10 = attributeStatistic(509,"pm10");
|
|
|
+ map.put("pm10",pm10);
|
|
|
+ float tvoc = attributeStatistic(509,"tvoc");
|
|
|
+ map.put("tvoc",tvoc);
|
|
|
+ float wd = attributeStatistic(509,"wd");
|
|
|
+ map.put("wd",wd);
|
|
|
+ float sd = attributeStatistic(509,"sd");
|
|
|
+ map.put("sd",sd);
|
|
|
+
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ public float attributeStatistic(Integer deviceType,String attribute_name){
|
|
|
+ float f = 0;
|
|
|
+ int deviceCount = 0;
|
|
|
+ LambdaQueryWrapper<DmpDevice> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.eq(DmpDevice::getDeviceType,deviceType);
|
|
|
+ deviceCount = this.count(queryWrapper);
|
|
|
+ LambdaQueryWrapper<DataRealTime> queryWrapper1 = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper1.select(DataRealTime::getAttributeData)
|
|
|
+ .eq(DataRealTime::getDeviceType,deviceType)
|
|
|
+ .eq(DataRealTime::getAttributeName,attribute_name);
|
|
|
+ List<DataRealTime> list = dataRealTimeService.list(queryWrapper1);
|
|
|
+ if(list.size() > 0){
|
|
|
+ for(int i=0;i<list.size();i++){
|
|
|
+ f += Float.parseFloat(list.get(i).getAttributeData());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ float data = f/deviceCount;
|
|
|
+ return data;
|
|
|
+ }
|
|
|
+
|
|
|
}
|