fix: 绑定解绑数据时,没有添加操作记录,bug修复。
This commit is contained in:
@@ -13,6 +13,7 @@ import com.intc.fishery.domain.AquUser;
|
||||
import com.intc.fishery.domain.Device;
|
||||
import com.intc.fishery.domain.DeviceBindRecord;
|
||||
import com.intc.fishery.domain.DeviceCorrectRecord;
|
||||
import com.intc.fishery.domain.DeviceErrorCode;
|
||||
import com.intc.fishery.domain.DeviceSwitch;
|
||||
import com.intc.fishery.domain.LinkedCtrl;
|
||||
import com.intc.fishery.domain.Pond;
|
||||
@@ -21,6 +22,7 @@ import com.intc.fishery.domain.bo.DeviceBo;
|
||||
import com.intc.fishery.domain.vo.DeviceVo;
|
||||
import com.intc.fishery.mapper.DeviceBindRecordMapper;
|
||||
import com.intc.fishery.mapper.DeviceCorrectRecordMapper;
|
||||
import com.intc.fishery.mapper.DeviceErrorCodeMapper;
|
||||
import com.intc.fishery.mapper.DeviceMapper;
|
||||
import com.intc.fishery.mapper.DeviceSwitchMapper;
|
||||
import com.intc.fishery.mapper.LinkedCtrlMapper;
|
||||
@@ -49,6 +51,7 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||
private final DeviceMapper baseMapper;
|
||||
private final DeviceBindRecordMapper deviceBindRecordMapper;
|
||||
private final DeviceCorrectRecordMapper deviceCorrectRecordMapper;
|
||||
private final DeviceErrorCodeMapper deviceErrorCodeMapper;
|
||||
private final DeviceSwitchMapper deviceSwitchMapper;
|
||||
private final LinkedCtrlMapper linkedCtrlMapper;
|
||||
private final TimingCtrlMapper timingCtrlMapper;
|
||||
@@ -222,7 +225,7 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||
|
||||
/**
|
||||
* 校验并批量删除设备管理信息
|
||||
* 删除顺序:校准记录 -> 定时控制 -> 开关(先解除联动控制引用)-> 联动控制 -> 设备
|
||||
* 删除顺序:故障码 -> 校准记录 -> 定时控制 -> 开关(先解除联动控制引用) -> 联动控制 -> 设备
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
@@ -232,16 +235,22 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if(isValid){
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
|
||||
// 1. 删除设备关联的校准记录
|
||||
|
||||
// 1. 删除设备关联的故障码记录
|
||||
deviceErrorCodeMapper.delete(
|
||||
new LambdaQueryWrapper<DeviceErrorCode>()
|
||||
.in(DeviceErrorCode::getDeviceId, ids)
|
||||
);
|
||||
|
||||
// 2. 删除设备关联的校准记录
|
||||
deviceCorrectRecordMapper.delete(
|
||||
new LambdaQueryWrapper<DeviceCorrectRecord>()
|
||||
.in(DeviceCorrectRecord::getDeviceId, ids)
|
||||
);
|
||||
|
||||
// 2. 查询设备关联的开关
|
||||
|
||||
// 3. 查询设备关联的开关
|
||||
List<DeviceSwitch> switches = deviceSwitchMapper.selectList(
|
||||
new LambdaQueryWrapper<DeviceSwitch>()
|
||||
.in(DeviceSwitch::getDeviceId, ids)
|
||||
@@ -253,7 +262,7 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||
.map(DeviceSwitch::getId)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 3. 删除开关关联的定时控制
|
||||
// 4. 删除开关关联的定时控制
|
||||
timingCtrlMapper.delete(
|
||||
new LambdaQueryWrapper<TimingCtrl>()
|
||||
.in(TimingCtrl::getSwitchId, switchIds)
|
||||
@@ -266,14 +275,14 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 4. 解除开关与联动控制的绑定
|
||||
// 5. 解除开关与联动控制的绑定
|
||||
deviceSwitchMapper.update(null,
|
||||
new LambdaUpdateWrapper<DeviceSwitch>()
|
||||
.set(DeviceSwitch::getLinkedCtrlId, null)
|
||||
.in(DeviceSwitch::getDeviceId, ids)
|
||||
);
|
||||
|
||||
// 5. 删除联动控制(如果有)
|
||||
// 6. 删除联动控制(如果有)
|
||||
if (!linkedCtrlIds.isEmpty()) {
|
||||
linkedCtrlMapper.delete(
|
||||
new LambdaQueryWrapper<LinkedCtrl>()
|
||||
@@ -281,20 +290,20 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||
);
|
||||
}
|
||||
|
||||
// 6. 删除开关
|
||||
// 7. 删除开关
|
||||
deviceSwitchMapper.delete(
|
||||
new LambdaQueryWrapper<DeviceSwitch>()
|
||||
.in(DeviceSwitch::getDeviceId, ids)
|
||||
);
|
||||
}
|
||||
|
||||
// 7. 删除设备本身关联的联动控制
|
||||
// 8. 删除设备本身关联的联动控制
|
||||
linkedCtrlMapper.delete(
|
||||
new LambdaQueryWrapper<LinkedCtrl>()
|
||||
.in(LinkedCtrl::getDeviceId, ids)
|
||||
);
|
||||
|
||||
// 8. 查询要删除的设备信息,添加解绑记录
|
||||
// 9. 查询要删除的设备信息,添加解绑记录
|
||||
List<Device> devicesToDelete = baseMapper.selectList(
|
||||
new LambdaQueryWrapper<Device>()
|
||||
.in(Device::getId, ids)
|
||||
@@ -320,7 +329,7 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||
}
|
||||
}
|
||||
|
||||
// 9. 最后删除设备
|
||||
// 10. 最后删除设备
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user