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 94cefae..179fbc4 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 @@ -3099,58 +3099,8 @@ public class IotController extends BaseController { return R.ok(); } - // 如果开关原本有塘口,需要清理定时控制 - if (oldPondId != null) { - // 查询设备的IotId - Device device = deviceMapper.selectById(vo.getDeviceId()); - if (device != null && com.intc.common.core.utils.StringUtils.isNotBlank(device.getIotId())) { - // 检查设备是否在线(通过判断warnCode判断设备状态) - boolean isOnline = device.getWarnCode() != null && device.getWarnCode() != 99; - - if (isOnline && iotCloudService != null) { - try { - // 构造清空定时控制的属性 - Map properties = new java.util.HashMap<>(); - // 清空定时器:localTimer_switch{Index} - properties.put("localTimer_switch" + vo.getIndex(), java.util.Collections.emptyList()); - - // 如果开关是打开状态,需要关闭它 - if (vo.getIsOpen() != null && vo.getIsOpen() == 1) { - // 关闭开关:Switch{Index} = 0 - properties.put(IOTPropertyName.SWITCH_INDEX + vo.getIndex(), 0); - - // 更新数据库中的开关状态 - deviceSwitchMapper.update(null, - new com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper() - .eq(DeviceSwitch::getId, switchId) - .set(DeviceSwitch::getIsOpen, 0) - ); - } - - // 调用物联网服务设置属性 - boolean success = iotCloudService.setProperty(device.getIotId(), properties, false, 0); - - if (success) { - log.info("成功通过物联网服务清空开关定时控制和关闭开关, switchId={}", switchId); - } else { - log.warn("通过物联网服务清空开关定时控制失败, switchId={}", switchId); - } - } catch (Exception e) { - log.error("调用物联网服务失败, switchId={}", switchId, e); - } - } - } - - // 删除该开关的所有定时控制记录 - if (timingCtrlMapper != null) { - timingCtrlMapper.delete( - new com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper() - .eq(TimingCtrl::getSwitchId, switchId) - ); - } - - log.info("已清除开关ID={}的定时控制数据", switchId); - } + // 注意:定时任务绑定在开关维度(TimingCtrl 仅含 switchId),不随塘口变化。 + // 切换塘口只更新归属,不清空设备端 localTimer、不关开关、不删除定时任务记录。 // 处理新塘口分配 if (pondId != null && pondId > 0) {