From 9ecbb672f5345dd5190d4648e3c5f3418693bb29 Mon Sep 17 00:00:00 2001 From: tianyongbao Date: Wed, 1 Jul 2026 23:16:47 +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=E6=A0=A1=E5=87=86=EF=BC=8C=E8=B5=B0=E7=BC=93?= =?UTF-8?q?=E5=AD=98=E9=80=BB=E8=BE=91=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../intc/iot/controller/IotController.java | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) 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 af0daad..3aab23b 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 @@ -1960,6 +1960,58 @@ public class IotController extends BaseController { return R.fail("设备已到期"); } + // 太阳能网控设备:缓存校准指令,等设备上线后自动补发 + boolean isSolarDevice = Integer.valueOf(3).equals(device.getDeviceType()); + if (isSolarDevice) { + if (device.getIotId() == null || device.getIotId().isBlank()) { + return R.fail("设备 iotId 为空,无法缓存校准指令"); + } + if (device.getSerialNum() == null || device.getSerialNum().isBlank()) { + return R.fail("设备编号为空,无法缓存校准指令"); + } + Map calibrateProperties = new LinkedHashMap<>(); + calibrateProperties.put("correct", 1); + if (!cachePendingSolarProperties(device, calibrateProperties)) { + return R.fail("校准指令缓存失败,请稍后重试"); + } + + // 更新设备警告码:清除未校准标记 + int warnCode = device.getWarnCode() != null ? device.getWarnCode() : 0; + if ((warnCode & DefineDeviceWarnCode.OxyDetectorNoCorrect) != 0) { + warnCode &= ~DefineDeviceWarnCode.OxyDetectorNoCorrect; + } + deviceMapper.update(null, + new com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper() + .eq(Device::getId, request.getId()) + .set(Device::getWarnCode, warnCode) + ); + + // 创建校准记录 + if (deviceCorrectRecordMapper != null) { + DeviceCorrectRecord correctRecord = new DeviceCorrectRecord(); + correctRecord.setDeviceId(device.getId()); + correctRecord.setUserId(userId); + correctRecord.setSerialNum(device.getSerialNum()); + correctRecord.setDeviceType(device.getDeviceType()); + correctRecord.setValueDissolvedOxygen(device.getValueDissolvedOxygen()); + correctRecord.setValueTemperature(device.getValueTemperature()); + correctRecord.setValueSaturability(device.getValueSaturability()); + deviceCorrectRecordMapper.insert(correctRecord); + } + + MessageOpRecordUtil.addMessageOpRecordUser( + device.getUserId(), + userId, + "设备操作", + String.format("%s(%s),设备校准。", device.getDeviceName(), device.getSerialNum()) + ); + + log.info("太阳能网控校准指令已缓存: userId={}, deviceId={}, deviceName={}, serialNum={}", + userId, device.getId(), device.getDeviceName(), device.getSerialNum()); + + return R.ok("设置成功"); + } + // 查询设备状态 if (iotDeviceService == null) { return R.fail("飞燕平台配置未启用");