From 80b8e9da512fa7399db08d6e2b2f825383645c09 Mon Sep 17 00:00:00 2001 From: tianyongbao Date: Mon, 23 Mar 2026 22:52:52 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=8E=A7=E5=88=B6=E5=99=A8=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E6=97=B6=E5=80=99=EF=BC=8C=E7=94=B5=E5=8E=8B=E8=AE=BE?= =?UTF-8?q?=E7=BD=AEbug=E4=BF=AE=E5=A4=8D=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../intc/iot/controller/IotController.java | 81 +++++++++++++++---- 1 file changed, 66 insertions(+), 15 deletions(-) diff --git a/intc-modules/intc-iot/src/main/java/com/intc/iot/controller/IotController.java b/intc-modules/intc-iot/src/main/java/com/intc/iot/controller/IotController.java index 6053d93..6d05859 100644 --- a/intc-modules/intc-iot/src/main/java/com/intc/iot/controller/IotController.java +++ b/intc-modules/intc-iot/src/main/java/com/intc/iot/controller/IotController.java @@ -903,16 +903,29 @@ public class IotController extends BaseController { // 设置设备属性 Map properties = new java.util.HashMap<>(); - // 设置额定电压 - rated_voltage 是结构体类型 - // 根据C#代码,需要调用 ControllerHelper.GetInputVoltageProperty - // 该方法返回一个特定结构的对象 - Integer voltValue = getVoltageValue(bo.getInputVoltage()); - if (voltValue == null) { - return R.fail("电压参数错误"); + // 构建 rated_voltage 结构体并写入属性 + Map ratedVoltageStruct = new java.util.HashMap<>(); + switch (bo.getInputVoltage()) { + case 1: + ratedVoltageStruct.put("voltage", 220); + ratedVoltageStruct.put("phase", "A"); + break; + case 2: + ratedVoltageStruct.put("voltage", 220); + ratedVoltageStruct.put("phase", "B"); + break; + case 3: + ratedVoltageStruct.put("voltage", 220); + ratedVoltageStruct.put("phase", "C"); + break; + case 4: + ratedVoltageStruct.put("voltage", 380); + ratedVoltageStruct.put("phase", "ABC"); + break; + default: + return R.fail("电压参数错误"); } - - // 暂时跳过 rated_voltage 设置,先设置其他属性 - // properties.put("rated_voltage", ratedVoltageStruct); + properties.put("rated_voltage", ratedVoltageStruct); // 如果是三相380V四线,设置输出电压 if (bo.getInputVoltage() == 4) { @@ -1012,11 +1025,12 @@ public class IotController extends BaseController { device.setPhaseDifference(0.0); } + device.setOxyWarnCallOpen(1); + device.setOxyWarnCallNoDis(1); + if (bo.getIsOxygenUsed()) { device.setSalinityCompensation(bo.getSalinityCompensation()); device.setOxyWarnLower(bo.getOxyWarnLower()); - device.setOxyWarnCallOpen(1); - device.setOxyWarnCallNoDis(1); // 如果有塘口且开关列表包含0(设备自身),则设置设备的塘口ID if (bo.getPondId() != null && bo.getPondId() > 0 @@ -1186,16 +1200,53 @@ public class IotController extends BaseController { deviceSwitchMapper.insert(deviceSwitch); } + // 计算故障码对应的开关序号 + int switchIndex = 0; // 0表示设备自身 + if (errorCode != 0) { + // 三相输入缺相 (强制4路开关断开) + if (errorCode >= 0x1001 && errorCode <= 0x1003) { + switchIndex = 0; + // 三相过压欠压 + } else if (errorCode >= 0x1004 && errorCode <= 0x1009) { + switchIndex = 0; + // 三相开关缺相 (每路3个相位) + } else if (errorCode >= 0x100A && errorCode <= 0x1019) { + int tempIndex = errorCode - 0x100A; + switchIndex = tempIndex / 3 + 1; + // 三相开关过流 (每路3个相位) + } else if (errorCode >= 0x101A && errorCode <= 0x1029) { + int tempIndex = errorCode - 0x101A; + switchIndex = tempIndex / 3 + 1; + // 三相开关欠流 (每路3个相位) + } else if (errorCode >= 0x102A && errorCode <= 0x1039) { + int tempIndex = errorCode - 0x102A; + switchIndex = tempIndex / 3 + 1; + // 三相开关电流为空 + } else if (errorCode >= 0x103A && errorCode <= 0x103D) { + switchIndex = errorCode - 0x103A + 1; + // 单相开关过流 + } else if (errorCode >= 0x2003 && errorCode <= 0x2006) { + switchIndex = errorCode - 0x2003 + 1; + // 单相开关欠流 + } else if (errorCode >= 0x2007 && errorCode <= 0x200A) { + switchIndex = errorCode - 0x2007 + 1; + // 单相开关电流为空 + } else if (errorCode >= 0x200B && errorCode <= 0x200E) { + switchIndex = errorCode - 0x200B + 1; + // 断电告警 + } else if (errorCode == 0x3001) { + warnCode |= 0x0020; // ErrorPowerOff + } + } + // 保存故障码记录 if (errorCode != 0) { - Date createTime = new Date(); DeviceErrorCode errorCodeData = new DeviceErrorCode(); errorCodeData.setDeviceId(device.getId()); - errorCodeData.setSwitchIndex(0); // 0表示设备本身的故障码 + errorCodeData.setSwitchIndex(switchIndex); errorCodeData.setErrorCode(errorCode); - // 注意:DeviceErrorCode继承自TenantEntity,已包含createTime和updateTime字段 deviceErrorCodeMapper.insert(errorCodeData); - log.info("保存设备故障码: deviceId={}, errorCode={}", device.getId(), errorCode); + log.info("保存设备故障码: deviceId={}, switchIndex={}, errorCode={}", device.getId(), switchIndex, errorCode); } return R.ok();