Commit abbe2e07ab97804e0b499fab90599801530f33da
1 parent
c8c80de7
feat: 自动出库组盘新增规则:批次管理的物料(存货档案,字段:是否批次="是"),自动组盘时,要求先进先出(参考生产日期,若没有生产日期,看入库日期)
Showing
1 changed file
with
40 additions
and
26 deletions
src/main/java/com/huaheng/pc/shipment/shippingCombination/service/ShippingCombinationService.java
@@ -54,16 +54,19 @@ public class ShippingCombinationService { | @@ -54,16 +54,19 @@ public class ShippingCombinationService { | ||
54 | 54 | ||
55 | 55 | ||
56 | //根据分配规则查找库存 | 56 | //根据分配规则查找库存 |
57 | - public List<InventoryDetail> getInventorys(ShipmentDetail shipmentDetail, boolean isAuto, boolean isFlatWarehouse, boolean openExhibitionRestrictions) { | 57 | + public List<InventoryDetail> getInventorys(ShipmentDetail shipmentDetail, boolean isAuto, boolean isFlatWarehouse, |
58 | + boolean openExhibitionRestrictions) { | ||
58 | String materialCode = shipmentDetail.getMaterialCode(); | 59 | String materialCode = shipmentDetail.getMaterialCode(); |
59 | - String noticeNo = shipmentDetail.getNoticeNo(); | ||
60 | - noticeNo = Optional.ofNullable(noticeNo).orElse(""); | 60 | + checkNotEmpty(materialCode, "出库明细没有物料编码"); |
61 | + | ||
62 | + String noticeNo = Optional.ofNullable(shipmentDetail.getNoticeNo()).orElse(""); | ||
61 | String containerCode = shipmentDetail.getContainerCode(); | 63 | String containerCode = shipmentDetail.getContainerCode(); |
62 | String receiptCode = shipmentDetail.getReceiptCode(); | 64 | String receiptCode = shipmentDetail.getReceiptCode(); |
63 | - checkNotEmpty(materialCode, "出库明细没有物料编码"); | 65 | + |
64 | Material material = getMaterialByCode(materialCode); | 66 | Material material = getMaterialByCode(materialCode); |
65 | String policy = Optional.ofNullable(material.getPolicy()).orElse(""); | 67 | String policy = Optional.ofNullable(material.getPolicy()).orElse(""); |
66 | - //String isBatchMaterial = Optional.ofNullable(material.getIsBatch()).orElse(""); | 68 | + String isBatchMaterial = Optional.ofNullable(material.getIsBatch()).orElse(""); |
69 | + | ||
67 | ShipmentHeader shipmentHeader = shipmentHeaderService.getById(shipmentDetail.getShipmentId()); | 70 | ShipmentHeader shipmentHeader = shipmentHeaderService.getById(shipmentDetail.getShipmentId()); |
68 | String warehouse = shipmentHeader.getWarehouse(); | 71 | String warehouse = shipmentHeader.getWarehouse(); |
69 | String color = shipmentHeader.getMaterialColor(); | 72 | String color = shipmentHeader.getMaterialColor(); |
@@ -94,27 +97,38 @@ public class ShippingCombinationService { | @@ -94,27 +97,38 @@ public class ShippingCombinationService { | ||
94 | } | 97 | } |
95 | 98 | ||
96 | 99 | ||
97 | - //排序:主体颜色加喷漆状态、喷漆状态、主体颜色、喷漆状态(底漆)、无颜色、先进先出 | ||
98 | - String finalNoticeNo1 = noticeNo; | ||
99 | - return list.stream() | ||
100 | - .sorted(Comparator.comparing((InventoryDetail detail) -> { | ||
101 | - if (StringUtils.isNotEmpty(finalNoticeNo1) && finalNoticeNo1.equals(detail.getNoticeCode())) { | ||
102 | - return 1; | ||
103 | - } else if (StringUtils.isNotEmpty(color) && StringUtils.isNotEmpty(paintStatus) && color.equals(detail.getMaterialColor()) && paintStatus.equals(detail.getPaintStatus())) { | ||
104 | - return 2; | ||
105 | - } else if (StringUtils.isNotEmpty(paintStatus) && paintStatus.equals(detail.getPaintStatus())) { | ||
106 | - return 3; | ||
107 | - } else if (StringUtils.isNotEmpty(color) && color.equals(detail.getMaterialColor())) { | ||
108 | - return 4; | ||
109 | - } else if ("底漆".equals(detail.getPaintStatus())) { | ||
110 | - return 5; | ||
111 | - } else if (StringUtils.isEmpty(detail.getMaterialColor())) { | ||
112 | - return 6; | ||
113 | - } else { | ||
114 | - return 7; | ||
115 | - } | ||
116 | - })) | ||
117 | - .collect(Collectors.toList()); | 100 | + // 批次管控的物料,优先按生产日期、创建时间、通知单号、颜色、喷漆状态、入库单号排序 |
101 | + if (StringUtils.isNotEmpty(isBatchMaterial) && isBatchMaterial.equals("是")) { | ||
102 | + list.sort(Comparator.comparing(InventoryDetail::getProductionDate) | ||
103 | + .thenComparing(InventoryDetail::getCreated) | ||
104 | + .thenComparing(InventoryDetail::getNoticeCode) | ||
105 | + .thenComparing(InventoryDetail::getMaterialColor) | ||
106 | + .thenComparing(InventoryDetail::getPaintStatus) | ||
107 | + .thenComparing(InventoryDetail::getReceiptCode)); | ||
108 | + } else { | ||
109 | + // 排序:通知单号匹配、主体颜色加喷漆状态、喷漆状态、主体颜色、喷漆状态(底漆)、无颜色、先进先出 | ||
110 | + String finalNoticeNo1 = noticeNo; | ||
111 | + list.sort(Comparator.comparing((InventoryDetail detail) -> { | ||
112 | + if (StringUtils.isNotEmpty(finalNoticeNo1) && finalNoticeNo1.equals(detail.getNoticeCode())) { | ||
113 | + return 1; | ||
114 | + } else if (StringUtils.isNotEmpty(color) && StringUtils.isNotEmpty(paintStatus) && color.equals(detail.getMaterialColor()) && paintStatus.equals(detail.getPaintStatus())) { | ||
115 | + return 2; | ||
116 | + } else if (StringUtils.isNotEmpty(paintStatus) && paintStatus.equals(detail.getPaintStatus())) { | ||
117 | + return 3; | ||
118 | + } else if (StringUtils.isNotEmpty(color) && color.equals(detail.getMaterialColor())) { | ||
119 | + return 4; | ||
120 | + } else if ("底漆".equals(detail.getPaintStatus())) { | ||
121 | + return 5; | ||
122 | + } else if (StringUtils.isEmpty(detail.getMaterialColor())) { | ||
123 | + return 6; | ||
124 | + } else { | ||
125 | + return 7; | ||
126 | + } | ||
127 | + }) | ||
128 | + .thenComparing(InventoryDetail::getCreated) | ||
129 | + .thenComparing(InventoryDetail::getReceiptCode)); | ||
130 | + } | ||
131 | + return list; | ||
118 | 132 | ||
119 | 133 | ||
120 | //批次管控的物料,出库时优先按,生产日期,先进先出 | 134 | //批次管控的物料,出库时优先按,生产日期,先进先出 |