|
@@ -116,69 +116,4 @@ public class RepairRegisterServiceImpl extends ServiceImpl<IRepairRegisterMapper
|
|
|
vo.setPartNamesStr(partNamesList.toString());
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public void delByRepairId(String repairId) {
|
|
|
- LambdaQueryWrapper<RepairRegister> wrapper = new LambdaQueryWrapper<>();
|
|
|
- wrapper.eq(RepairRegister::getRepairId,repairId);
|
|
|
- this.remove(wrapper);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public PriceListVo getPriceList(String repairId) {
|
|
|
- RepairRegisterVo vo = this.getBaseMapper().getVoByRepairId(repairId);
|
|
|
- if(vo == null){
|
|
|
- return null;
|
|
|
- }
|
|
|
- List<RepairRegisterPart> partList = repairRegisterPartService.getByRepairId(vo.getRepairId());
|
|
|
- PriceListVo priceListVo = new PriceListVo();
|
|
|
- priceListVo.setCount(1);
|
|
|
-
|
|
|
- HashMap<Integer,Part> partHashMap = new HashMap<>();
|
|
|
- List<Integer> collect = partList.stream().map(RepairRegisterPart::getPartId).collect(Collectors.toList());
|
|
|
- if(collect.size() >0){
|
|
|
- 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);
|
|
|
- Part part = partHashMap.get(priceList.getPartId());
|
|
|
- if(part == null){
|
|
|
- continue;
|
|
|
- }
|
|
|
- priceList.setPartUnit(part.getPartUnit());
|
|
|
- }
|
|
|
- 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(partCount);
|
|
|
- priceList.setPartId(part.getPartId());
|
|
|
- priceList.setPriceDiscount(part.getPartPriceDiscount());
|
|
|
- priceList.setPartUnit(part.getPartUnit());
|
|
|
- priceList.setType(0);
|
|
|
- priceList.setStatus(0);
|
|
|
- priceLists.add(priceList);
|
|
|
- }
|
|
|
- priceListVo.setPriceLists(priceLists);
|
|
|
- return priceListVo;
|
|
|
- }
|
|
|
}
|