|
@@ -91,22 +91,27 @@ public class RepairSupplyService {
|
|
|
partLogs.forEach(entity -> map.put(entity.getPartId(),entity));
|
|
|
}
|
|
|
|
|
|
- List<RepairRegisterPartVo> parts = new ArrayList<>();
|
|
|
+ HashMap<Integer,Integer> partPriceListMap = new HashMap<>();
|
|
|
for (PriceList priceList : list) {
|
|
|
- Part part = partService.getById(priceList.getPartId());
|
|
|
+ partPriceListMap.merge(priceList.getPartId(), priceList.getCount(), Integer::sum);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<RepairRegisterPartVo> parts = new ArrayList<>();
|
|
|
+
|
|
|
+ for (Integer partId : partPriceListMap.keySet()) {
|
|
|
+ Part part = partService.getById(partId);
|
|
|
if(part == null){
|
|
|
continue;
|
|
|
}
|
|
|
RepairRegisterPartVo vo = new RepairRegisterPartVo();
|
|
|
- vo.setPartName(priceList.getName());
|
|
|
- vo.setPartCount(priceList.getCount() );
|
|
|
- BeanUtils.copyProperties(part,vo);
|
|
|
- BeanUtils.copyProperties(priceList,vo);
|
|
|
+ vo.setPartId(partId);
|
|
|
+ vo.setPartName(part.getPartName());
|
|
|
+ vo.setPartCount(partPriceListMap.get(partId));
|
|
|
if(type != 2){
|
|
|
PartLog partLog = map.get(part.getPartId());
|
|
|
if(partLog != null){
|
|
|
Integer count = partLog.getCount();
|
|
|
- vo.setPartCount(priceList.getCount() - count);
|
|
|
+ vo.setPartCount(vo.getPartCount() - count);
|
|
|
}
|
|
|
if(vo.getPartCount() <=0){
|
|
|
continue;
|