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 3aab23b..5461c41 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) {