Browse Source

没配置电流默认参数的话不去更新设备状态

lingpeng.li 6 months ago
parent
commit
6c87fb9f75

+ 17 - 20
jeecg-module-gather/src/main/java/org/jeecg/modules/watch/MysqlWatch.java

@@ -173,32 +173,29 @@ public class MysqlWatch {
                 queryWrapper.eq("variable_address", "sys_run_current_limit");
                 queryWrapper.eq("status", 0);
                 SystemVariable systemVariable = systemVariableService.getOne(queryWrapper);
+
+                // 如果 systemVariable 为空,则不执行后续操作
                 if (systemVariable == null) {
                     log.info("{}{}", "fpg_close系统变量未配置正常状态的运行电流限制!", JSON.toJSON(data));
-                    return;
-                }
-
-                DeviceInformation deviceInformation = deviceInformationMapper.selectOne(
-                        new LambdaQueryWrapper<DeviceInformation>()
-                                .eq(DeviceInformation::getId, data.getDeviceInformationId())
-                );
-
-                // 比较大小
-                int result = compareStringWithBigDecimal(systemVariable.getDefaultValue(), data.getRunCurrent());
-
-                if (result > 0) {
-                    deviceInformation.setStatus("1");
-
-                } else if (result < 0) {
-
-                    deviceInformation.setStatus("0");
-
                 } else {
+                    DeviceInformation deviceInformation = deviceInformationMapper.selectOne(
+                            new LambdaQueryWrapper<DeviceInformation>()
+                                    .eq(DeviceInformation::getId, data.getDeviceInformationId())
+                    );
+
+                    // 比较大小
+                    int result = compareStringWithBigDecimal(systemVariable.getDefaultValue(), data.getRunCurrent());
+
+                    if (result > 0) {
+                        deviceInformation.setStatus("1");
+                    } else if (result < 0) {
+                        deviceInformation.setStatus("0");
+                    }
 
+                    // 只有在 systemVariable 不为空时才进行更新操作
+                    deviceInformationMapper.updateById(deviceInformation);
                 }
 
-                deviceInformationMapper.updateById(deviceInformation);
-
                 // 如果不存在则插入
                 if (existingData == null) {
                     fpgGatherDataMapper.insert(data);