lyhzzz 11 bulan lalu
induk
melakukan
b414ee3cc6

+ 1 - 1
src/main/java/com/fdkankan/sale/service/IPriceListService.java

@@ -23,6 +23,7 @@ public interface IPriceListService extends IService<PriceList> {
     BigDecimal getAmountByRepairId(String repairId);
 
     void updateStatusByRepairId(String repairId);
+    void updateStatusByRepairId(String repairId,Integer status);
 
 
     List<PriceList> getByRepairIdAndStatus(String repairId, Integer status);
@@ -39,5 +40,4 @@ public interface IPriceListService extends IService<PriceList> {
 
     List<PriceList> getByRepairIds(List<String> repairIds);
 
-    Boolean checkPartOut(List<PriceList> collect, String repairId);
 }

+ 10 - 15
src/main/java/com/fdkankan/sale/service/impl/PriceListServiceImpl.java

@@ -84,6 +84,15 @@ public class PriceListServiceImpl extends ServiceImpl<IPriceListMapper, PriceLis
     }
 
     @Override
+    public void updateStatusByRepairId(String repairId,Integer status) {
+        LambdaUpdateWrapper<PriceList> wrapper = new LambdaUpdateWrapper<>();
+        wrapper.eq(PriceList::getRepairId,repairId);
+        wrapper.eq(PriceList::getType,0);
+        wrapper.set(PriceList::getStatus,status);
+        this.update(wrapper);
+    }
+
+    @Override
     public List<PriceList> getByRepairIdAndStatus(String repairId, Integer status) {
         LambdaQueryWrapper<PriceList> wrapper = new LambdaQueryWrapper<>();
         wrapper.eq(PriceList::getRepairId,repairId);
@@ -123,6 +132,7 @@ public class PriceListServiceImpl extends ServiceImpl<IPriceListMapper, PriceLis
     public void delNoCm(String repairId) {
         LambdaQueryWrapper<PriceList> wrapper = new LambdaQueryWrapper<>();
         wrapper.eq(PriceList::getRepairId,repairId);
+        wrapper.in(PriceList::getStatus,0,1);
         this.remove(wrapper);
     }
 
@@ -141,21 +151,6 @@ public class PriceListServiceImpl extends ServiceImpl<IPriceListMapper, PriceLis
         return map;
     }
 
-    @Override
-    public Boolean checkPartOut(List<PriceList> collect, String repairId) {
-        Boolean flag = true;
-        HashMap<Integer, PartLog> outMap = partLogService.getByRepairId(repairId, 1);
-        if(!outMap.isEmpty()){
-            for (PriceList priceList : collect) {
-                PartLog partLog = outMap.get(priceList.getPartId());
-                if(partLog == null || !partLog.getCount().equals(priceList.getCount())){
-                    return false;
-                }
-            }
-        }
-        return flag;
-    }
-
     private void setMapAmount(HashMap<String,BigDecimal> map, List<PriceList> priceLists){
         for (PriceList priceList : priceLists) {
             map.putIfAbsent(priceList.getRepairId(), BigDecimal.ZERO);

+ 2 - 2
src/main/java/com/fdkankan/sale/service/impl/RepairCustomerService.java

@@ -99,8 +99,8 @@ public class RepairCustomerService {
             if(collect.size() <=0){
                 repairLogService.saveBySysUser(param.getUserId(),repair.getRepairId(),RepairStatusEnum.TO_BE_REPAIRED.status(),repair.getStatus(),"维修确认");
             }else {
-                Boolean flag = priceListService.checkPartOut( collect ,repair.getRepairId());
-                if(flag){
+                List<RepairRegisterPartVo> partVoList = repairSupplyService.partInfo(repair.getRepairId(), 0);
+                if(partVoList.size() <=0){
                     repairLogService.saveBySysUser(param.getUserId(),repair.getRepairId(),RepairStatusEnum.TO_BE_REPAIRED.status(),repair.getStatus(),"维修确认");
                 }
                 repairLogService.saveBySysUser(param.getUserId(),repair.getRepairId(),RepairStatusEnum.TO_BE_U8SEND.status(),repair.getStatus(),"维修确认");

+ 19 - 2
src/main/java/com/fdkankan/sale/service/impl/RepairRegisterServiceImpl.java

@@ -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());

+ 8 - 3
src/main/java/com/fdkankan/sale/service/impl/RepairSaleService.java

@@ -231,14 +231,18 @@ public class RepairSaleService {
                 }
             }
             priceList.setRepairId(param.getRepairId());
-            if(priceList.getPriceListId() != null){
-                priceList.setPriceListId(null);
-            }
 
             if(param.getConvertWarranty() == 1){
                 priceList.setStatus(1);
             }
 
+            if(priceList.getPriceListId() != null){
+                PriceList dbPriceList = priceListHashMap.get(priceList.getPriceListId());
+                if(dbPriceList!= null && dbPriceList.getStatus() ==2){
+                    continue;
+                }
+                priceList.setPriceListId(null);
+            }
             priceListService.save(priceList);
 
         }
@@ -253,6 +257,7 @@ public class RepairSaleService {
         if(StringUtils.isBlank(repairId)){
             throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
         }
+        //重置报价单
         if(isRest == 1){
             return repairRegisterService.getPriceList(repairId);
         }

+ 1 - 0
src/main/java/com/fdkankan/sale/service/impl/RepairSupplyService.java

@@ -160,6 +160,7 @@ public class RepairSupplyService {
         }
         for (RepairRegisterPartVo partVo : partVoList) {
             partService.outStock(partVo.getPartId(),partVo.getPartCount(),userId,repair.getRepairId());
+            priceListService.updateStatusByRepairId(repair.getRepairId(),2);
         }
 
         repairLogService.saveBySysUser(userId,param.getRepairId(),RepairStatusEnum.TO_BE_REPAIRED.status(),repair.getStatus(),"备件出库");