Răsfoiți Sursa

运行记录1224-插入device_run_log1

yuanchao 5 zile în urmă
părinte
comite
46bddd94be

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

@@ -444,10 +444,11 @@ public class IotOpeationFillController {
                         // 累加:从缓存获取历史最大值
                         String key = fill.getDeviceId() + "_" + fill.getPointName();
                         BigDecimal maxHistory = maxDataMap.getOrDefault(key, BigDecimal.ZERO);
-                        total = maxHistory.add(currentValue);
-                    } else if (fill.getSumId() == 0) {
-                        // 直接赋值
-                        total = currentValue;
+                        if(maxHistory!=null) {
+                            total = maxHistory.add(currentValue);
+                        }else{
+                            total = fill.getTotalRunTime().add(new BigDecimal(fill.getFillContent()));
+                        }
                     }
                 }
                 fill.setTotalRunTime(total);
@@ -603,16 +604,19 @@ public class IotOpeationFillController {
 
         // 3. 批量执行(MyBatis批量操作)
         if (!insertList.isEmpty()) {
+            System.out.println("执行了插入");
             TenantUtils.execute(1L, () -> {
                 iotOpeationFillService.batchInsertLogs(insertList); // 批量插入
             });
         }
         if (!updateList.isEmpty()) {
+            System.out.println("执行了更新");
             TenantUtils.execute(1L, () -> {
                 iotOpeationFillService.batchUpdateLogs(updateList); // 批量更新普通日志
             });
         }
         if (!updateSumList.isEmpty()) {
+            System.out.println("执行了累计更新");
             TenantUtils.execute(1L, () -> {
                 iotOpeationFillService.batchUpdateSumLogs(updateSumList); // 批量更新累计日志
             });