|
@@ -75,8 +75,14 @@ public class DeviceQualityServiceImpl extends ServiceImpl<DeviceQualityMapper, D
|
|
|
public R save(@RequestBody List<DeviceQualityDto.Vo> vos) {
|
|
|
List<DeviceQualityDto.Vo> updates = new ArrayList<>();
|
|
|
List<DeviceQuality> saves = new ArrayList<>();
|
|
|
- List<DeviceInfo> deviceInfos = deviceInfoMapper.selectList(new LambdaQueryWrapper<DeviceInfo>().in(DeviceInfo::getDeviceId, new JArrayList<>(vos).getProperty(DeviceQualityDto.Vo::getDeviceId)));
|
|
|
+ JList<Long> deviceIds = new JArrayList<>(vos).getProperty(DeviceQualityDto.Vo::getDeviceId);
|
|
|
+ //获取设备信息
|
|
|
+ List<DeviceInfo> deviceInfos = deviceInfoMapper.selectList(new LambdaQueryWrapper<DeviceInfo>().in(DeviceInfo::getDeviceId, deviceIds));
|
|
|
JMap<Long, DeviceInfo> deviceInfoJMap = new JArrayList<>(deviceInfos).toMap(DeviceInfo::getDeviceId).cover();
|
|
|
+ //获取已有质检信息
|
|
|
+ List<DeviceQuality> deviceQualities = list(new LambdaQueryWrapper<DeviceQuality>().eq(DeviceQuality::getDeviceId, deviceIds));
|
|
|
+ JMap<Long, List<DeviceQuality>> deviceQualitieJMap = new JArrayList<>(deviceQualities).toMap(DeviceQuality::getDeviceId).group();
|
|
|
+ //封装修改和添加对象
|
|
|
for (DeviceQualityDto.Vo save : vos) {
|
|
|
DeviceQuality deviceQuality = new DeviceQuality().setDeviceId(save.getDeviceId());
|
|
|
DeviceInfo deviceInfo = deviceInfoJMap.get(deviceQuality.getDeviceId());
|
|
@@ -85,7 +91,7 @@ public class DeviceQualityServiceImpl extends ServiceImpl<DeviceQualityMapper, D
|
|
|
}
|
|
|
deviceQuality.setDeviceType(deviceInfo.getDeviceType())
|
|
|
.setCreateTime(LocalDateTime.now());
|
|
|
- List<DeviceQuality> list = list(new LambdaQueryWrapper<DeviceQuality>().eq(DeviceQuality::getDeviceId, deviceQuality.getDeviceId()));
|
|
|
+ List<DeviceQuality> list = deviceQualitieJMap.get(deviceQuality.getDeviceId());
|
|
|
if (Emptys.check(list)) {
|
|
|
JList<Integer> qualityIds = new JArrayList<>(list).getProperty(DeviceQuality::getQualityId);
|
|
|
List<DeviceQualityDto.Vo> vos2 = new ArrayList<>(qualityIds.size());
|
|
@@ -94,9 +100,11 @@ public class DeviceQualityServiceImpl extends ServiceImpl<DeviceQualityMapper, D
|
|
|
}
|
|
|
saves.add(deviceQuality);
|
|
|
}
|
|
|
+ //修改
|
|
|
if (Emptys.check(updates)) {
|
|
|
update(updates);
|
|
|
}
|
|
|
+ //添加
|
|
|
saveBatch(saves);
|
|
|
return R.ok();
|
|
|
}
|