Просмотр исходного кода

备件出库,回收回显修改

lyhzzz 2 лет назад
Родитель
Сommit
d4568163cc

+ 2 - 0
src/main/java/com/fdkankan/sale/entity/PartLog.java

@@ -75,5 +75,7 @@ public class PartLog implements Serializable {
     @TableField("update_time")
     private String updateTime;
 
+    @TableField("price_list_id")
+    private Integer priceListId;
 
 }

+ 0 - 10
src/main/java/com/fdkankan/sale/service/impl/RepairSaleService.java

@@ -174,10 +174,6 @@ public class RepairSaleService {
         HashMap<Integer,Part> partMap = partService.getHashMap();
         HashMap<Integer,LaborCost> laborMap = laborCostService.getHashMap();
 
-        List<PriceList> priceLists = priceListService.getByRepairId(repair.getRepairId());
-        List<PriceList> collect = priceLists.stream().filter(entity -> entity.getType() == 0).collect(Collectors.toList());
-        HashMap<Integer,PriceList> partMapDb = new HashMap<>();
-        collect.forEach(entity -> partMapDb.put(entity.getPartId(),entity));
 
         priceListService.delNoCm(repair.getRepairId());
         for (PriceList priceList : param.getPriceLists()) {
@@ -188,11 +184,6 @@ public class RepairSaleService {
                 if(priceList.getPartId() == null ||  partMap.get(priceList.getPartId()) == null || priceList.getDiscount() == null){
                     throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
                 }
-                PriceList priceListDb = partMapDb.get(priceList.getPartId());
-                if(priceListDb != null){
-                    priceList.setPriceListId(priceListDb.getPriceListId());
-                    priceList.setOutStatus(priceListDb.getOutStatus());
-                }
                 Part part = partMap.get(priceList.getPartId());
                 priceList.setPrice(part.getPartPrice());
                 priceList.setPriceDiscount(part.getPartPriceDiscount());
@@ -207,7 +198,6 @@ public class RepairSaleService {
                 priceList.setPrice(laborCost.getPrice());
                 priceList.setName(laborCost.getName());
             }
-            priceList.setPriceListId(null);
             priceList.setRepairId(param.getRepairId());
             priceListService.save(priceList);
 

+ 24 - 8
src/main/java/com/fdkankan/sale/service/impl/RepairSupplyService.java

@@ -25,6 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 
 @Service
@@ -52,6 +53,8 @@ public class RepairSupplyService {
     IPartService partService;
     @Autowired
     IPriceListService priceListService;
+    @Autowired
+    IPartLogService partLogService;
 
     /**
      * 维修备件管理 供应链
@@ -72,20 +75,33 @@ public class RepairSupplyService {
         wrapper.eq(PriceList::getRepairId,repairId);
         wrapper.eq(PriceList::getStatus,1);
         wrapper.eq(PriceList::getType,0);
+        List<PriceList> list = priceListService.list(wrapper);
+        List<PriceList> returnList = new ArrayList<>();
 
-        if(type == 0){
-            wrapper.eq(PriceList::getOutStatus,0);
+        LambdaQueryWrapper<PartLog> wrapper2 = new LambdaQueryWrapper<>();
+        wrapper2.eq(PartLog::getRepairId,repairId);
+        if(type == 0 || type == 2){ //出库
+            wrapper2.eq(PartLog::getStatus,1);
         }
-        if(type == 1){
-            wrapper.eq(PriceList::getRecoveryStatus,0);
+        if(type == 1){ //回收
+            wrapper2.eq(PartLog::getStatus,2);
         }
-        if(type == 2){
-            wrapper.eq(PriceList::getOutStatus,1);
+
+        List<PartLog> partLogs = partLogService.list(wrapper2);
+        HashMap<Integer,PartLog> map = new HashMap<>();
+        partLogs.forEach(entity -> map.put(entity.getPriceListId(),entity));
+
+        for (PriceList priceList : list) {
+            if(type == 1 && map.get(priceList.getPriceListId()) == null){
+                returnList.add(priceList);
+            }
+            if(type == 2 && map.get(priceList.getPriceListId()) != null){
+                returnList.add(priceList);
+            }
         }
-        List<PriceList> list = priceListService.list(wrapper);
 
         List<RepairRegisterPartVo> parts = new ArrayList<>();
-        for (PriceList priceList : list) {
+        for (PriceList priceList : returnList) {
             Part part =  partService.getById(priceList.getPartId());
             if(part == null){
                 continue;