|
@@ -13,6 +13,7 @@ import cn.iocoder.yudao.module.pms.controller.admin.iotmodeltemplateattrs.vo.Iot
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.*;
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.*;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotrhdailyreport.vo.IotRhDailyReportSaveReqVO;
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotrhdailyreport.vo.IotRhDailyReportSaveReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotrydailyreport.vo.IotRyDailyReportSaveReqVO;
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotrydailyreport.vo.IotRyDailyReportSaveReqVO;
|
|
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.vo.DeviceTdVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.vo.DeviceVO;
|
|
import cn.iocoder.yudao.module.pms.controller.admin.vo.DeviceVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.vo.IotDeviceRespVO;
|
|
import cn.iocoder.yudao.module.pms.controller.admin.vo.IotDeviceRespVO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotcountdata.IotCountDataDO;
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotcountdata.IotCountDataDO;
|
|
@@ -1190,12 +1191,13 @@ public class IotOpeationFillController {
|
|
|
LocalDateTime midDay = LocalDateTime.of(createDate, LocalTime.of(12, 0));
|
|
LocalDateTime midDay = LocalDateTime.of(createDate, LocalTime.of(12, 0));
|
|
|
|
|
|
|
|
// 批量收集DeviceVO查询参数
|
|
// 批量收集DeviceVO查询参数
|
|
|
- List<DeviceVO> deviceVOQueries = new ArrayList<>();
|
|
|
|
|
|
|
+ List<DeviceTdVO> deviceVOQueries = new ArrayList<>();
|
|
|
List<IotDeviceRunLogDO> logDOQueries = new ArrayList<>();
|
|
List<IotDeviceRunLogDO> logDOQueries = new ArrayList<>();
|
|
|
for (IotModelTemplateAttrsDO attrsDO : attrsList) {
|
|
for (IotModelTemplateAttrsDO attrsDO : attrsList) {
|
|
|
if (isVirtualDevice) {
|
|
if (isVirtualDevice) {
|
|
|
- DeviceVO dv = new DeviceVO();
|
|
|
|
|
|
|
+ DeviceTdVO dv = new DeviceTdVO();
|
|
|
dv.setDeviceName(deviceCode.toLowerCase());
|
|
dv.setDeviceName(deviceCode.toLowerCase());
|
|
|
|
|
+ dv.setDeviceName1(deviceCode);
|
|
|
dv.setColName(attrsDO.getModelAttr());
|
|
dv.setColName(attrsDO.getModelAttr());
|
|
|
dv.setTs(startTime);
|
|
dv.setTs(startTime);
|
|
|
dv.setTs1(endTime);
|
|
dv.setTs1(endTime);
|
|
@@ -1212,12 +1214,40 @@ public class IotOpeationFillController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 批量查询(替代循环查询)
|
|
// 批量查询(替代循环查询)
|
|
|
- Map<String, DeviceVO> deviceVOMap = new HashMap<>();
|
|
|
|
|
- if (isVirtualDevice && !deviceVOQueries.isEmpty()) {
|
|
|
|
|
- List<DeviceVO> deviceVOList = iDeviceService.batchGetYesInfo(deviceVOQueries);
|
|
|
|
|
|
|
+ Map<String, DeviceTdVO> deviceVOMap = new HashMap<>();
|
|
|
|
|
+ /*if (isVirtualDevice && !deviceVOQueries.isEmpty()) {
|
|
|
|
|
+ List<DeviceTdVO> deviceVOList = iDeviceService.batchGetYesInfo(deviceVOQueries);
|
|
|
deviceVOMap = deviceVOList.stream()
|
|
deviceVOMap = deviceVOList.stream()
|
|
|
.filter(voObj -> !StringUtils.isEmpty(voObj.getEarliestData()) && !"0.0".equals(voObj.getEarliestData()))
|
|
.filter(voObj -> !StringUtils.isEmpty(voObj.getEarliestData()) && !"0.0".equals(voObj.getEarliestData()))
|
|
|
- .collect(Collectors.toMap(DeviceVO::getDeviceName, Function.identity()));
|
|
|
|
|
|
|
+ .collect(Collectors.toMap(DeviceTdVO::getDeviceName, Function.identity()));
|
|
|
|
|
+ }*/
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if (isVirtualDevice && !deviceVOQueries.isEmpty()) {
|
|
|
|
|
+ List<DeviceTdVO> deviceVOList = iDeviceService.batchGetYesInfo(deviceVOQueries);
|
|
|
|
|
+ if(deviceVOList.size()>0){
|
|
|
|
|
+
|
|
|
|
|
+ deviceVOMap = deviceVOList.stream()
|
|
|
|
|
+ // 增强过滤:排除deviceName为null、earliestData为null/空/0.0的记录
|
|
|
|
|
+ .filter(voObj -> {
|
|
|
|
|
+ // 过滤deviceName为null/空的情况
|
|
|
|
|
+ if (StringUtils.isEmpty(voObj.getColName())) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ // 过滤earliestData为null/空/0.0的情况
|
|
|
|
|
+ String earliest = voObj.getEarliestData();
|
|
|
|
|
+ return earliest != null && !earliest.isEmpty() && !"0.0".equals(earliest);
|
|
|
|
|
+ })
|
|
|
|
|
+ // 使用重载方法:key重复时保留后面的记录(或根据业务选择保留前面的)
|
|
|
|
|
+ .collect(Collectors.toMap(
|
|
|
|
|
+ DeviceTdVO::getColName, // key:deviceName
|
|
|
|
|
+ Function.identity(), // value:自身
|
|
|
|
|
+ (v1, v2) -> v2 // 重复key时的合并策略(此处保留后一个)
|
|
|
|
|
+ ));
|
|
|
|
|
+ }else{
|
|
|
|
|
+ isVirtualDevice = false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 批量查询logInfo和maxLog
|
|
// 批量查询logInfo和maxLog
|
|
@@ -1232,32 +1262,45 @@ public class IotOpeationFillController {
|
|
|
|
|
|
|
|
// 处理属性数据
|
|
// 处理属性数据
|
|
|
for (IotModelTemplateAttrsDO attrsDO : attrsList) {
|
|
for (IotModelTemplateAttrsDO attrsDO : attrsList) {
|
|
|
- String attrId = attrsDO.getId().toString();
|
|
|
|
|
|
|
+ String attrId = attrsDO.getModelAttr();
|
|
|
String attrName = attrsDO.getName();
|
|
String attrName = attrsDO.getName();
|
|
|
if (isVirtualDevice) {
|
|
if (isVirtualDevice) {
|
|
|
- DeviceVO deviceVO = deviceVOMap.get(attrId);
|
|
|
|
|
|
|
+ DeviceTdVO deviceVO = deviceVOMap.get(attrId);
|
|
|
if (deviceVO != null) {
|
|
if (deviceVO != null) {
|
|
|
// 数采设备逻辑
|
|
// 数采设备逻辑
|
|
|
double diff = Double.parseDouble(deviceVO.getLatestData()) - Double.parseDouble(deviceVO.getEarliestData());
|
|
double diff = Double.parseDouble(deviceVO.getLatestData()) - Double.parseDouble(deviceVO.getEarliestData());
|
|
|
attrsDO.setFillContent(String.valueOf(diff));
|
|
attrsDO.setFillContent(String.valueOf(diff));
|
|
|
attrsDO.setTotalRunTime(BigDecimal.valueOf(Double.parseDouble(deviceVO.getLatestData())));
|
|
attrsDO.setTotalRunTime(BigDecimal.valueOf(Double.parseDouble(deviceVO.getLatestData())));
|
|
|
attrsDO.setIsCollection(1);
|
|
attrsDO.setIsCollection(1);
|
|
|
- continue;
|
|
|
|
|
|
|
+ }else{
|
|
|
|
|
+ IotDeviceRunLogDO logInfo = logInfoMap.get(attrName);
|
|
|
|
|
+ IotDeviceRunLogDO maxLog = maxLogMap.get(attrName);
|
|
|
|
|
+
|
|
|
|
|
+ if (logInfo != null) {
|
|
|
|
|
+ attrsDO.setFillContent(logInfo.getFillContent());
|
|
|
|
|
+ attrsDO.setTotalRunTime(logInfo.getTotalRunTime() != null ? logInfo.getTotalRunTime() : BigDecimal.ZERO);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ attrsDO.setFillContent("");
|
|
|
|
|
+ attrsDO.setTotalRunTime(maxLog != null ? maxLog.getTotalRunTime() : BigDecimal.ZERO);
|
|
|
|
|
+ }
|
|
|
|
|
+ attrsDO.setIsCollection(0);
|
|
|
|
|
+ }
|
|
|
|
|
+ }else{
|
|
|
|
|
+ // 非数采设备逻辑
|
|
|
|
|
+ IotDeviceRunLogDO logInfo = logInfoMap.get(attrName);
|
|
|
|
|
+ IotDeviceRunLogDO maxLog = maxLogMap.get(attrName);
|
|
|
|
|
+
|
|
|
|
|
+ if (logInfo != null) {
|
|
|
|
|
+ attrsDO.setFillContent(logInfo.getFillContent());
|
|
|
|
|
+ attrsDO.setTotalRunTime(logInfo.getTotalRunTime() != null ? logInfo.getTotalRunTime() : BigDecimal.ZERO);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ attrsDO.setFillContent("");
|
|
|
|
|
+ attrsDO.setTotalRunTime(maxLog != null ? maxLog.getTotalRunTime() : BigDecimal.ZERO);
|
|
|
}
|
|
}
|
|
|
|
|
+ attrsDO.setIsCollection(0);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 非数采设备逻辑
|
|
|
|
|
- IotDeviceRunLogDO logInfo = logInfoMap.get(attrName);
|
|
|
|
|
- IotDeviceRunLogDO maxLog = maxLogMap.get(attrName);
|
|
|
|
|
|
|
|
|
|
- if (logInfo != null) {
|
|
|
|
|
- attrsDO.setFillContent(logInfo.getFillContent());
|
|
|
|
|
- attrsDO.setTotalRunTime(logInfo.getTotalRunTime() != null ? logInfo.getTotalRunTime() : BigDecimal.ZERO);
|
|
|
|
|
- } else {
|
|
|
|
|
- attrsDO.setFillContent("");
|
|
|
|
|
- attrsDO.setTotalRunTime(maxLog != null ? maxLog.getTotalRunTime() : BigDecimal.ZERO);
|
|
|
|
|
- }
|
|
|
|
|
- attrsDO.setIsCollection(0);
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|