From 66d8dc2fe77af083df386d3b0d7105ffbc5e4e0c Mon Sep 17 00:00:00 2001 From: tianyongbao Date: Sat, 4 Jul 2026 22:13:04 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=BC=80=E5=85=B3=E6=94=B9=E5=8F=98?= =?UTF-8?q?=E5=A1=98=E5=8F=A3=E6=97=B6=EF=BC=8C=E4=B8=8D=E5=AF=B9=E5=AE=9A?= =?UTF-8?q?=E6=97=B6=E4=BB=BB=E5=8A=A1=E6=B8=85=E9=99=A4=EF=BC=8C=E4=BF=9D?= =?UTF-8?q?=E7=95=99=E5=8E=9F=E6=9D=A5=E7=8A=B6=E6=80=81=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../intc/iot/controller/IotController.java | 54 +------------------ 1 file changed, 2 insertions(+), 52 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 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) {