维修管理优化 逻辑处理优化
This commit is contained in:
parent
8925b54d9c
commit
59d82ace10
|
|
@ -91,19 +91,19 @@ public class RepairServiceImpl implements RepairService {
|
|||
try {
|
||||
BeanUtil.copyProperties(item, repairDeviceVO);
|
||||
} catch (Exception e) {
|
||||
// 记录异常日志,并提供更详细的错误信息
|
||||
System.err.println("复制属性时发生错误: {}" + e.getMessage());
|
||||
throw new RuntimeException("复制属性时发生错误", e);
|
||||
}
|
||||
if (item.getTypeNameId() == null) {
|
||||
// 处理 typeNameId 为空的情况
|
||||
System.err.println("typeNameId 为空,跳过当前项: " + item);
|
||||
return;
|
||||
}
|
||||
resultMap.computeIfAbsent(item.getTypeNameId(), origin -> item).getRepairDeviceList().add(repairDeviceVO);
|
||||
|
||||
resultMap.computeIfPresent(item.getTypeNameId(), (origin, novel) -> {
|
||||
novel.setTotalCost(novel.getTotalCost().add(Optional.ofNullable(item.getTotalCost()).orElse(BigDecimal.ZERO)));
|
||||
novel.setTotalCost(Optional.ofNullable(novel.getTotalCost()).orElse(BigDecimal.ZERO)
|
||||
.add(Optional.ofNullable(item.getTotalCost()).orElse(BigDecimal.ZERO))
|
||||
);
|
||||
return novel;
|
||||
});
|
||||
});
|
||||
|
|
@ -150,17 +150,17 @@ public class RepairServiceImpl implements RepairService {
|
|||
|
||||
public static List<RepairPart> mergePartsNum(@NotNull List<RepairPart> devices) {
|
||||
try {
|
||||
Map<String, RepairPart> map = devices.stream().filter(Objects::nonNull).collect(
|
||||
Map<String, RepairPart> map = devices.stream().filter(Objects::nonNull).collect(
|
||||
Collectors.toConcurrentMap(device -> device.getTypeId() + ":" + device.getPartCost() + ":" + device.getPartName(),
|
||||
device -> device, (existing, recently) -> {
|
||||
existing.setPartNum(existing.getPartNum() + recently.getPartNum());
|
||||
return existing;
|
||||
}, ConcurrentHashMap::new)
|
||||
);
|
||||
);
|
||||
List<RepairPart> list = new ArrayList<>(map.values());
|
||||
list.forEach(item -> {
|
||||
item.setPartCost(Optional.ofNullable(item.getPartPrice()).orElse(BigDecimal.ZERO).multiply(new BigDecimal(item.getPartNum())));
|
||||
});
|
||||
list.forEach(item -> item.setPartCost(Optional.ofNullable(item.getPartPrice()).orElse(BigDecimal.ZERO)
|
||||
.multiply(new BigDecimal(Optional.ofNullable(item.getPartNum()).orElse(0))))
|
||||
);
|
||||
return list;
|
||||
} catch (Exception e) {
|
||||
throw new ServiceException("Error merging parts" + e.getMessage());
|
||||
|
|
|
|||
Loading…
Reference in New Issue