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

+ 3 - 0
src/main/java/com/fdkankan/sale/entity/PriceList.java

@@ -95,4 +95,7 @@ public class PriceList implements Serializable {
     @TableField("price_discount")
     @JsonFormat(shape = JsonFormat.Shape.STRING)
     private BigDecimal priceDiscount;
+
+    @TableField(exist = false)
+    private String partUnit;
 }

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

@@ -227,6 +227,18 @@ public class RepairSaleService {
             throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
         }
         List<PriceList> priceLists = priceListService.getByRepairId(repairId);
+        Set<Integer> collect = priceLists.stream().map(PriceList::getPartId).collect(Collectors.toSet());
+        HashMap<Integer,Part> partHashMap = new HashMap<>();
+        if(collect.size() >0){
+            List<Part> parts = partService.listByIds(collect);
+            parts.forEach(entity -> partHashMap.put(entity.getPartId(),entity));
+        }
+
+        for (PriceList priceList : priceLists) {
+            if(priceList.getPartId() != null && partHashMap.get(priceList.getPartId()) !=null) {
+                priceList.setPartUnit(partHashMap.get(priceList.getPartId()).getPartUnit());
+            }
+        }
         List<RepairLog> repairLogs = repairLogService.getByRepairIdAndStatus(repairId, RepairStatusEnum.TO_BE_CONFIRMED.status());
         PriceListVo priceListVo = new PriceListVo();
         priceListVo.setPriceLists(priceLists);