Explorar o código

运行记录1224-打印运行记录保存

yuanchao hai 5 días
pai
achega
db6c2f96c0

+ 22 - 1
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotopeationfill/IotOpeationFillController.java

@@ -362,7 +362,9 @@ public class IotOpeationFillController {
             Integer userId = allFillData.get(0).getUserId();
 
 
-
+            for (IotDeviceRunLogDO a:logDOList) {
+                System.out.println("设备数据-------------"+a);
+            }
             // 6. 批量保存日志(有则更新,无则插入)
             batchSaveLogs(logDOList);
 
@@ -443,14 +445,19 @@ public class IotOpeationFillController {
                     if (fill.getSumId() == 1) {
                         // 累加:从缓存获取历史最大值
                         String key = fill.getDeviceId() + "_" + fill.getPointName();
+                        System.out.println("设备信息:-------"+key);
                         BigDecimal maxHistory = maxDataMap.getOrDefault(key, BigDecimal.ZERO);
+                        System.out.println("maxHistory:-------"+maxHistory.toString());
                         if(maxHistory!=null) {
                             total = maxHistory.add(currentValue);
+                            System.out.println("total:-------"+total.toString());
                         }else{
                             total = fill.getTotalRunTime().add(new BigDecimal(fill.getFillContent()));
+                            System.out.println("total1:-------"+total.toString());
                         }
                     }
                 }
+                System.out.println("finalTotal:-------"+total.toString());
                 fill.setTotalRunTime(total);
             } catch (NumberFormatException e) {
                 //log.warn("DefaultValue转换失败: {}", fill.getDefaultValue());
@@ -493,12 +500,14 @@ public class IotOpeationFillController {
                 .map(fill -> {
                     IotDeviceRunLogDO deviceRunLogDO = new IotDeviceRunLogDO();
                     deviceRunLogDO.setDeviceId(fill.getDeviceId());
+                    System.out.println("deviceId----"+fill.getDeviceId());
                     deviceRunLogDO.setDeviceCode(fill.getDeviceCode());
                     deviceRunLogDO.setFillContent(fill.getFillContent());
                     deviceRunLogDO.setPointCode(fill.getModelAttr());
                     deviceRunLogDO.setDeptId(fill.getDeptId());
                     deviceRunLogDO.setCreateTime(LocalDateTime.of(fill.getCreateTime(), localTime));
                     deviceRunLogDO.setPointName(fill.getPointName());
+                    System.out.println("totalRunTime----"+fill.getTotalRunTime());
                     deviceRunLogDO.setTotalRunTime(fill.getTotalRunTime());
                     deviceRunLogDO.setIsSum(fill.getIsSum() != null ? fill.getIsSum() : 0);
                     return deviceRunLogDO;
@@ -581,6 +590,18 @@ public class IotOpeationFillController {
                         log -> log,
                         (v1, v2) -> v1 // 避免重复key(理论上不会有)
                 ));
+        System.out.println("=== existingLogMap 详细内容 ===");
+        existingLogMap.forEach((key, log) -> {
+            System.out.println("Key: " + key);
+            // 打印IotDeviceRunLogDO的属性(根据实际字段调整)
+            System.out.println("Value: " +
+                    "deviceId=" + log.getDeviceId() +
+                    ", pointName=" + log.getPointName() +
+                    ", createTime=" + log.getCreateTime() +
+                    ", value=" + log.getValue() // 补充你实际的字段
+            );
+            System.out.println("------------------------"); // 分隔符,方便阅读
+        });
 
         // 2. 拆分:待插入列表 + 待更新列表
         List<IotDeviceRunLogDO> insertList = new ArrayList<>();