From 03c8bfb276cb2dab1e6a13c3e59063b5c2ce0dca Mon Sep 17 00:00:00 2001 From: tianyongbao Date: Sat, 25 Apr 2026 06:49:58 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E5=A4=AA=E9=98=B3=E8=83=BD=E7=BD=91?= =?UTF-8?q?=E6=8E=A7=EF=BC=8C=E5=90=8E=E5=8F=B0=E4=BB=A3=E7=A0=81=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E5=AE=8C=E5=96=84=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fishery/controller/DeviceController.java | 4 +++ .../fishery/controller/PondController.java | 7 +++-- .../java/com/intc/fishery/domain/Device.java | 5 ++++ .../com/intc/fishery/domain/vo/DeviceVo.java | 6 ++++ .../domain/vo/PublicDeviceBaseData.java | 15 ++++++++++ .../intc/iot/controller/IotController.java | 9 ++++-- .../intc/iot/handler/DeviceDataHandler.java | 7 +++-- .../service/impl/DeviceSensorDataService.java | 29 ++++++++++--------- 8 files changed, 61 insertions(+), 21 deletions(-) diff --git a/intc-modules/intc-fishery/src/main/java/com/intc/fishery/controller/DeviceController.java b/intc-modules/intc-fishery/src/main/java/com/intc/fishery/controller/DeviceController.java index d6f5d6a..a061aed 100644 --- a/intc-modules/intc-fishery/src/main/java/com/intc/fishery/controller/DeviceController.java +++ b/intc-modules/intc-fishery/src/main/java/com/intc/fishery/controller/DeviceController.java @@ -317,6 +317,10 @@ public class DeviceController extends BaseController { data.setSalinityCompensation(device.getSalinityCompensation()); data.setInputVoltage(device.getInputVoltage()); data.setVoltageWarnOpen(device.getVoltageWarnOpen()); + data.setBatteryWarnCallOpen(device.getBatteryWarnCallOpen()); + data.setBatteryWarnCallNoDis(device.getBatteryWarnCallNoDis()); + data.setBatteryWarnLower(device.getBatteryWarnLower()); + // 设置塘口信息 if (device.getPondId() != null && device.getPondId() > 0) { diff --git a/intc-modules/intc-fishery/src/main/java/com/intc/fishery/controller/PondController.java b/intc-modules/intc-fishery/src/main/java/com/intc/fishery/controller/PondController.java index 8fd9827..5d5ddeb 100644 --- a/intc-modules/intc-fishery/src/main/java/com/intc/fishery/controller/PondController.java +++ b/intc-modules/intc-fishery/src/main/java/com/intc/fishery/controller/PondController.java @@ -186,7 +186,7 @@ public class PondController extends BaseController { /** * 根据塘口ID查询设备列表 * 返回数据按设备类型分类: - * - listDetector: 水质检测仪列表(deviceType=1)+ 开启溶氧检测的测控一体机(deviceType=2 && isOxygenUsed=1) + * - listDetector: 水质检测仪列表(deviceType=1)+ 开启溢氧检测的测控一体机(deviceType=2 && isOxygenUsed=1)+ 太阳能网控(deviceType=3) * - listController: 测控一体机列表(deviceType=2),包含开关列表 * * @param pondId 塘口ID @@ -294,10 +294,11 @@ public class PondController extends BaseController { // 9. 处理探测器列表(严格从 pondDevices 取,与 C# pond.ListDevice 保持一致,不包含仅开关挂塘口的设备) List detectorList = new ArrayList<>(); for (Device device : pondDevices) { - // 水质检测仪 或 开启溶氧检测的测控一体机 + // 水质检测仪 或 开启溢氧检测的测控一体机 或 太阳能网控 if ((device.getDeviceType() != null && device.getDeviceType() == 1) || (device.getDeviceType() != null && device.getDeviceType() == 2 - && device.getIsOxygenUsed() != null && device.getIsOxygenUsed() == 1)) { + && device.getIsOxygenUsed() != null && device.getIsOxygenUsed() == 1) + || (device.getDeviceType() != null && device.getDeviceType() == 3)) { DeviceVo deviceVo = MapstructUtils.convert(device, DeviceVo.class); diff --git a/intc-modules/intc-fishery/src/main/java/com/intc/fishery/domain/Device.java b/intc-modules/intc-fishery/src/main/java/com/intc/fishery/domain/Device.java index e12fc0b..bdf3136 100644 --- a/intc-modules/intc-fishery/src/main/java/com/intc/fishery/domain/Device.java +++ b/intc-modules/intc-fishery/src/main/java/com/intc/fishery/domain/Device.java @@ -238,5 +238,10 @@ public class Device extends TenantEntity { */ private Long batteryWarnLower; + /** + * 电量值(太阳能网控专用,0-100) + */ + private Integer valueBattery; + } diff --git a/intc-modules/intc-fishery/src/main/java/com/intc/fishery/domain/vo/DeviceVo.java b/intc-modules/intc-fishery/src/main/java/com/intc/fishery/domain/vo/DeviceVo.java index 14acfd2..1378e93 100644 --- a/intc-modules/intc-fishery/src/main/java/com/intc/fishery/domain/vo/DeviceVo.java +++ b/intc-modules/intc-fishery/src/main/java/com/intc/fishery/domain/vo/DeviceVo.java @@ -306,6 +306,12 @@ public class DeviceVo implements Serializable { @ExcelProperty(value = "电量电话告警下限") private Long batteryWarnLower; + /** + * 电量值(太阳能网控专用,0-100) + */ + @ExcelProperty(value = "电量值") + private Integer valueBattery; + /** * 手机号 */ diff --git a/intc-modules/intc-fishery/src/main/java/com/intc/fishery/domain/vo/PublicDeviceBaseData.java b/intc-modules/intc-fishery/src/main/java/com/intc/fishery/domain/vo/PublicDeviceBaseData.java index 8d1053d..25d77db 100644 --- a/intc-modules/intc-fishery/src/main/java/com/intc/fishery/domain/vo/PublicDeviceBaseData.java +++ b/intc-modules/intc-fishery/src/main/java/com/intc/fishery/domain/vo/PublicDeviceBaseData.java @@ -109,6 +109,21 @@ public class PublicDeviceBaseData implements Serializable { */ private Integer voltageWarnOpen; + /** + * 低电量电话告警开关(太阳能网控专用) + */ + private Long batteryWarnCallOpen; + + /** + * 低电量告警免打扰(太阳能网控专用) + */ + private Long batteryWarnCallNoDis; + + /** + * 低电量告警下限(太阳能网控专用,0-100) + */ + private Long batteryWarnLower; + /** * 开关列表(仅测控一体机) */ 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 f1da62d..a1465dd 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 @@ -1704,15 +1704,18 @@ public class IotController extends BaseController { // 初始化警告码 int warnCode = 0; + // 判断是否离线 + boolean isOffline = status != null && "OFFLINE".equalsIgnoreCase(status); + // 如果设备离线,添加离线警告 - if (status != null && "OFFLINE".equalsIgnoreCase(status)) { + if (isOffline) { warnCode |= 0x0080; // 设备离线 } device.setWarnCode(warnCode); - // 验证 ICCID 是否存在 - if (device.getIccId() == null || device.getIccId().isEmpty()) { + // 验证 ICCID 是否存在:设备离线时属性无法读取,允许跳过,上线后会通过数据上报补全 + if (!isOffline && (device.getIccId() == null || device.getIccId().isEmpty())) { return R.fail("设备缺少物联网卡号(ICCID)"); } diff --git a/intc-modules/intc-iot/src/main/java/com/intc/iot/handler/DeviceDataHandler.java b/intc-modules/intc-iot/src/main/java/com/intc/iot/handler/DeviceDataHandler.java index 0aa0449..c4339c9 100644 --- a/intc-modules/intc-iot/src/main/java/com/intc/iot/handler/DeviceDataHandler.java +++ b/intc-modules/intc-iot/src/main/java/com/intc/iot/handler/DeviceDataHandler.java @@ -2215,8 +2215,8 @@ public class DeviceDataHandler { : params.getDouble("phasedifference"); sensorData.setPhaseDifference(value); } - if (params.containsKey("battery")) { - sensorData.setBattery(params.getDouble("battery")); + if (params.containsKey("ChargeFlag")) { + sensorData.setBattery(params.getDouble("ChargeFlag")); } // TODO: 如果需要设置 deviceId、userId 等标签字段,需要从设备管理系统查询 @@ -2271,6 +2271,9 @@ public class DeviceDataHandler { if (sensorData.getSalinity() != null) { updateDevice.setValueSalinity(sensorData.getSalinity()); } + if (sensorData.getBattery() != null) { + updateDevice.setValueBattery(sensorData.getBattery().intValue()); + } int updated = deviceMapper.updateById(updateDevice); if (updated > 0) { log.debug("设备实时数据已更新: {}", deviceName); diff --git a/intc-modules/intc-tdengine/src/main/java/com/intc/tdengine/service/impl/DeviceSensorDataService.java b/intc-modules/intc-tdengine/src/main/java/com/intc/tdengine/service/impl/DeviceSensorDataService.java index 8a2b2c3..4845c17 100644 --- a/intc-modules/intc-tdengine/src/main/java/com/intc/tdengine/service/impl/DeviceSensorDataService.java +++ b/intc-modules/intc-tdengine/src/main/java/com/intc/tdengine/service/impl/DeviceSensorDataService.java @@ -139,33 +139,36 @@ public class DeviceSensorDataService implements IDeviceSensorDataService { } try { - // 打印第一条数据的详细信息 - if (!dataList.isEmpty()) { - DeviceSensorData firstData = dataList.get(0); - // 检查子表是否存在(使用缓存优化) - String serialNum = firstData.getSerialNum(); + // 按 serialNum 分组,对每个设备单独检查并确保子表存在 + java.util.Map firstBySerial = new java.util.LinkedHashMap<>(); + for (DeviceSensorData data : dataList) { + String sn = data.getSerialNum(); + if (sn != null && !sn.isEmpty() && !firstBySerial.containsKey(sn)) { + firstBySerial.put(sn, data); + } + } + + for (java.util.Map.Entry entry : firstBySerial.entrySet()) { + String serialNum = entry.getKey(); String tableName = "t_" + serialNum; - - // 先检查缓存,避免重复查询数据库 + if (!CREATED_TABLES.containsKey(serialNum)) { try { Integer exists = deviceSensorDataMapper.checkTableExists(serialNum); if (exists == null || exists == 0) { - deviceSensorDataMapper.createTable(firstData); + deviceSensorDataMapper.createTable(entry.getValue()); log.debug("子表 {} 已创建", tableName); } - // 加入缓存 CREATED_TABLES.put(serialNum, true); } catch (Exception e) { - // 检查表不存在是正常情况,使用 USING 语法会自动创建 String errorMsg = e.getMessage(); if (errorMsg != null && errorMsg.contains("Table does not exist")) { log.debug("子表 {} 不存在,将自动创建", tableName); } else { - log.warn("检查子表失败: {}", errorMsg != null && errorMsg.length() > 100 ? errorMsg.substring(0, 100) : errorMsg); + log.warn("检查子表失败[{}]: {}", tableName, + errorMsg != null && errorMsg.length() > 100 ? errorMsg.substring(0, 100) : errorMsg); } - // 即使失败也加入缓存,避免重复尝试 - CREATED_TABLES.put(serialNum, true); + // 建表异常时不加入缓存,下次重试 } } else { log.debug("子表 {} 已在缓存中", tableName);