|
@@ -44,6 +44,8 @@ public class RepairRegisterServiceImpl extends ServiceImpl<IRepairRegisterMapper
|
|
|
IRepairRegisterPartService repairRegisterPartService;
|
|
|
@Autowired
|
|
|
IPartService partService;
|
|
|
+ @Autowired
|
|
|
+ IPriceListService priceListService;
|
|
|
|
|
|
@Override
|
|
|
public void repairOver(String repairId, String remark,Long userId) {
|
|
@@ -130,7 +132,6 @@ public class RepairRegisterServiceImpl extends ServiceImpl<IRepairRegisterMapper
|
|
|
List<RepairRegisterPart> partList = repairRegisterPartService.getByRepairId(vo.getRepairId());
|
|
|
PriceListVo priceListVo = new PriceListVo();
|
|
|
priceListVo.setCount(1);
|
|
|
- List<PriceList> priceLists = new ArrayList<>();
|
|
|
|
|
|
HashMap<Integer,Part> partHashMap = new HashMap<>();
|
|
|
List<Integer> collect = partList.stream().map(RepairRegisterPart::getPartId).collect(Collectors.toList());
|
|
@@ -138,17 +139,33 @@ public class RepairRegisterServiceImpl extends ServiceImpl<IRepairRegisterMapper
|
|
|
List<Part> parts = partService.listByIds(collect);
|
|
|
parts.forEach(entity -> partHashMap.put(entity.getPartId(),entity));
|
|
|
}
|
|
|
+ List<PriceList> priceListList = priceListService.getByRepairId(repairId);
|
|
|
+ List<PriceList> priceLists = priceListList.stream().filter(e -> e.getStatus() == 2).collect(Collectors.toList());
|
|
|
+ HashMap<Integer,Integer> partCountMap = new HashMap<>();
|
|
|
+ for (PriceList priceList : priceLists) {
|
|
|
+ partCountMap.merge(priceList.getPartId(), priceList.getCount(), Integer::sum);
|
|
|
+ }
|
|
|
for (RepairRegisterPart repairRegisterPart : partList) {
|
|
|
Part part = partHashMap.get(repairRegisterPart.getPartId());
|
|
|
if(part == null){
|
|
|
continue;
|
|
|
}
|
|
|
+ Integer count = partCountMap.get(part.getPartId());
|
|
|
+ Integer partCount = repairRegisterPart.getPartCount();
|
|
|
+ if(count != null){
|
|
|
+ partCount = count - repairRegisterPart.getPartCount() ;
|
|
|
+ }
|
|
|
+ if(partCount == 0){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ partCountMap.put(part.getPartId(),partCount);
|
|
|
+
|
|
|
PriceList priceList = new PriceList();
|
|
|
priceList.setPriceListId(repairRegisterPart.getId());
|
|
|
priceList.setRepairId(repairId);
|
|
|
priceList.setName(part.getPartName());
|
|
|
priceList.setPrice(part.getPartPrice());
|
|
|
- priceList.setCount(repairRegisterPart.getPartCount());
|
|
|
+ priceList.setCount(partCount);
|
|
|
priceList.setPartId(part.getPartId());
|
|
|
priceList.setPriceDiscount(part.getPartPriceDiscount());
|
|
|
priceList.setPartUnit(part.getPartUnit());
|