From 73993a142cda17a25b6a262f2b64ad50b69aadf0 Mon Sep 17 00:00:00 2001 From: tianyongbao Date: Wed, 1 Jul 2026 23:45:27 +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=B1=9E=E6=80=A7=E4=B8=8B=E5=8F=91=EF=BC=8C?= =?UTF-8?q?=E4=B8=8D=E5=8C=BA=E5=88=86=E5=9C=A8=E7=BA=BF=E7=A6=BB=E7=BA=BF?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../intc/iot/controller/IotController.java | 66 ++++--------------- 1 file changed, 12 insertions(+), 54 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 7cb592e..94cefae 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 @@ -2255,74 +2255,32 @@ public class IotController extends BaseController { } Map properties = normalizeSolarProperties(request.getProperties()); - boolean cache = Boolean.TRUE.equals(request.getCache()); - Integer statusCode = queryDeviceStatusCode(device.getIotId()); - boolean online = Integer.valueOf(DEVICE_STATUS_ONLINE).equals(statusCode); - Map result = new LinkedHashMap<>(); - result.put("deviceId", device.getId()); - result.put("serialNum", device.getSerialNum()); - result.put("online", online); - result.put("statusCode", statusCode); - result.put("properties", properties); - - if (cache) { - if (online) { - return R.fail("设备当前在线,请使用直接下发"); - } - if (!cachePendingSolarProperties(device, properties)) { - return R.fail("指令缓存失败,请稍后重试"); - } - syncDeviceFieldsAfterSolarCommand(device.getId(), properties); - if (properties.containsKey("salinitySet")) { - setSalinityFreeze(device.getSerialNum(), toDouble(properties.get("salinitySet"))); - } - result.put("mode", "cached"); - result.put("cached", true); - result.put("sent", false); - MessageOpRecordUtil.addMessageOpRecordUser( - device.getUserId(), - userId, - "设备操作", - String.format("%s(%s),太阳能网控属性缓存下发:%s。", - device.getDeviceName(), device.getSerialNum(), properties) - ); - log.info("太阳能网控属性已缓存: userId={}, deviceId={}, serialNum={}, properties={}", - userId, device.getId(), device.getSerialNum(), properties); - return R.ok("缓存成功,设备上线后自动下发", result); + // 太阳能网控统一走缓存下发,设备上线后自动补发,不再区分在线/离线 + if (!cachePendingSolarProperties(device, properties)) { + return R.fail("指令缓存失败,请稍后重试"); } - - if (!online) { - return R.fail("设备离线或未激活,请使用缓存下发"); - } - if (iotCloudService == null) { - return R.fail("飞燕平台配置未启用"); - } - - boolean success = iotCloudService.setProperty(device.getIotId(), properties, true, 2); - if (!success) { - return R.fail("属性下发失败,请重试"); - } - syncDeviceFieldsAfterSolarCommand(device.getId(), properties); - removePendingSolarProperties(device, properties.keySet()); if (properties.containsKey("salinitySet")) { setSalinityFreeze(device.getSerialNum(), toDouble(properties.get("salinitySet"))); } - result.put("mode", "direct"); - result.put("cached", false); - result.put("sent", true); + Map result = new LinkedHashMap<>(); + result.put("deviceId", device.getId()); + result.put("serialNum", device.getSerialNum()); + result.put("properties", properties); + result.put("mode", "cached"); + MessageOpRecordUtil.addMessageOpRecordUser( device.getUserId(), userId, "设备操作", - String.format("%s(%s),太阳能网控属性直接下发:%s。", + String.format("%s(%s),太阳能网控属性缓存下发:%s。", device.getDeviceName(), device.getSerialNum(), properties) ); - log.info("太阳能网控属性下发成功: userId={}, deviceId={}, serialNum={}, properties={}", + log.info("太阳能网控属性已缓存: userId={}, deviceId={}, serialNum={}, properties={}", userId, device.getId(), device.getSerialNum(), properties); - return R.ok("下发成功", result); + return R.ok("缓存成功,设备上线后自动下发", result); } catch (IllegalArgumentException e) { return R.fail(e.getMessage()); } catch (Exception e) {