Commit 6548deb6 by HlQ

feat: 修复设备流转,设备日志 deviceId 为空的问题

1 parent e91a8a68
...@@ -116,10 +116,12 @@ public class IDeviceServiceImpl extends MPJBaseServiceImpl<DeviceMapper, Device> ...@@ -116,10 +116,12 @@ public class IDeviceServiceImpl extends MPJBaseServiceImpl<DeviceMapper, Device>
} }
var userId = dtoList.getFirst().getUserId(); var userId = dtoList.getFirst().getUserId();
var deviceList = converter.convert(dtoList, Device.class); var deviceList = converter.convert(dtoList, Device.class);
var deviceListInDB = this.lambdaQuery().in(Device::getSerialNum, deviceList.stream().map(Device::getSerialNum).toList()).list();
var serialNum2IdMap = deviceListInDB.stream().collect(Collectors.toMap(Device::getSerialNum, Device::getId));
deviceList.forEach(d -> { deviceList.forEach(d -> {
this.lambdaUpdate().eq(Device::getSerialNum, d.getSerialNum()).update(d); this.lambdaUpdate().eq(Device::getSerialNum, d.getSerialNum()).update(d);
var deviceLog = new DeviceLog(); var deviceLog = new DeviceLog();
deviceLog.setDeviceId(d.getId()); deviceLog.setDeviceId(serialNum2IdMap.get(d.getSerialNum()));
deviceLog.setOperator(userId); deviceLog.setOperator(userId);
deviceLog.setContent(getStatusStr(d.getStatus())); deviceLog.setContent(getStatusStr(d.getStatus()));
deviceLogService.save(deviceLog); deviceLogService.save(deviceLog);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!