fix: 自测问题修复。
This commit is contained in:
@@ -817,12 +817,33 @@ public class DeviceController extends BaseController {
|
||||
|
||||
String pondName = pond != null ? pond.getPondName() : "未知塘口";
|
||||
|
||||
// 删除设备关联的所有联动控制
|
||||
linkedCtrlMapper.delete(
|
||||
// 删除设备关联的所有联动控制前,先解除开关绑定
|
||||
// 1. 查询所有要删除的联动控制ID
|
||||
List<LinkedCtrl> linkedCtrls = linkedCtrlMapper.selectList(
|
||||
new LambdaQueryWrapper<LinkedCtrl>()
|
||||
.eq(LinkedCtrl::getDeviceId, device.getId())
|
||||
.select(LinkedCtrl::getId)
|
||||
);
|
||||
|
||||
if (!linkedCtrls.isEmpty()) {
|
||||
List<Long> linkedCtrlIds = linkedCtrls.stream()
|
||||
.map(LinkedCtrl::getId)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 2. 解除关联的开关绑定
|
||||
deviceSwitchMapper.update(null,
|
||||
new LambdaUpdateWrapper<DeviceSwitch>()
|
||||
.set(DeviceSwitch::getLinkedCtrlId, null)
|
||||
.in(DeviceSwitch::getLinkedCtrlId, linkedCtrlIds)
|
||||
);
|
||||
|
||||
// 3. 删除联动控制记录
|
||||
linkedCtrlMapper.delete(
|
||||
new LambdaQueryWrapper<LinkedCtrl>()
|
||||
.eq(LinkedCtrl::getDeviceId, device.getId())
|
||||
);
|
||||
}
|
||||
|
||||
// 更新设备:移除塘口关联,清除告警状态
|
||||
boolean updated = deviceMapper.update(null,
|
||||
new LambdaUpdateWrapper<Device>()
|
||||
@@ -957,11 +978,32 @@ public class DeviceController extends BaseController {
|
||||
.set(Device::getIsOxygenUsed, 0)
|
||||
);
|
||||
|
||||
// 删除设备的所有联动控制
|
||||
linkedCtrlMapper.delete(
|
||||
// 删除设备的所有联动控制前,先解除开关绑定
|
||||
// 1. 查询所有要删除的联动控制ID
|
||||
List<LinkedCtrl> linkedCtrls = linkedCtrlMapper.selectList(
|
||||
new LambdaQueryWrapper<LinkedCtrl>()
|
||||
.eq(LinkedCtrl::getDeviceId, request.getId())
|
||||
.select(LinkedCtrl::getId)
|
||||
);
|
||||
|
||||
if (!linkedCtrls.isEmpty()) {
|
||||
List<Long> linkedCtrlIds = linkedCtrls.stream()
|
||||
.map(LinkedCtrl::getId)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 2. 解除关联的开关绑定
|
||||
deviceSwitchMapper.update(null,
|
||||
new LambdaUpdateWrapper<DeviceSwitch>()
|
||||
.set(DeviceSwitch::getLinkedCtrlId, null)
|
||||
.in(DeviceSwitch::getLinkedCtrlId, linkedCtrlIds)
|
||||
);
|
||||
|
||||
// 3. 删除联动控制记录
|
||||
linkedCtrlMapper.delete(
|
||||
new LambdaQueryWrapper<LinkedCtrl>()
|
||||
.eq(LinkedCtrl::getDeviceId, request.getId())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// 查询更新后的设备完整信息
|
||||
|
||||
@@ -891,10 +891,32 @@ public class PondController extends BaseController {
|
||||
|
||||
// 如果设备原来有塘口,删除关联的联动控制
|
||||
if (oldPondId != null) {
|
||||
linkedCtrlMapper.delete(
|
||||
// 删除联动控制前,先解除开关绑定
|
||||
// 1. 查询所有要删除的联动控制ID
|
||||
List<LinkedCtrl> linkedCtrls = linkedCtrlMapper.selectList(
|
||||
new LambdaQueryWrapper<LinkedCtrl>()
|
||||
.eq(LinkedCtrl::getDeviceId, request.getId())
|
||||
.select(LinkedCtrl::getId)
|
||||
);
|
||||
|
||||
if (!linkedCtrls.isEmpty()) {
|
||||
List<Long> linkedCtrlIds = linkedCtrls.stream()
|
||||
.map(LinkedCtrl::getId)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 2. 解除关联的开关绑定
|
||||
deviceSwitchMapper.update(null,
|
||||
new LambdaUpdateWrapper<DeviceSwitch>()
|
||||
.set(DeviceSwitch::getLinkedCtrlId, null)
|
||||
.in(DeviceSwitch::getLinkedCtrlId, linkedCtrlIds)
|
||||
);
|
||||
|
||||
// 3. 删除联动控制记录
|
||||
linkedCtrlMapper.delete(
|
||||
new LambdaQueryWrapper<LinkedCtrl>()
|
||||
.eq(LinkedCtrl::getDeviceId, request.getId())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// 情凵1:分配或转移到新塘口
|
||||
|
||||
Reference in New Issue
Block a user