维修管理优化 逻辑处理优化

This commit is contained in:
syruan 2024-11-21 16:43:55 +08:00
parent 8925b54d9c
commit 7b782583d4
1 changed files with 8 additions and 6 deletions

View File

@ -103,7 +103,9 @@ public class RepairServiceImpl implements RepairService {
resultMap.computeIfAbsent(item.getTypeNameId(), origin -> item).getRepairDeviceList().add(repairDeviceVO); resultMap.computeIfAbsent(item.getTypeNameId(), origin -> item).getRepairDeviceList().add(repairDeviceVO);
resultMap.computeIfPresent(item.getTypeNameId(), (origin, novel) -> { 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; return novel;
}); });
}); });
@ -158,9 +160,9 @@ public class RepairServiceImpl implements RepairService {
}, ConcurrentHashMap::new) }, ConcurrentHashMap::new)
); );
List<RepairPart> list = new ArrayList<>(map.values()); List<RepairPart> list = new ArrayList<>(map.values());
list.forEach(item -> { list.forEach(item -> item.setPartCost(Optional.ofNullable(item.getPartPrice()).orElse(BigDecimal.ZERO)
item.setPartCost(Optional.ofNullable(item.getPartPrice()).orElse(BigDecimal.ZERO).multiply(new BigDecimal(item.getPartNum()))); .multiply(new BigDecimal(Optional.ofNullable(item.getPartNum()).orElse(0))))
}); );
return list; return list;
} catch (Exception e) { } catch (Exception e) {
throw new ServiceException("Error merging parts" + e.getMessage()); throw new ServiceException("Error merging parts" + e.getMessage());