Commit 7df5cbaf14469067ffc23732ac4d7c16936d2529

Authored by 易文鹏
1 parent 265489a2

feat: 更新出库组盘逻辑:①通知单号匹配

②主体颜色加喷漆状态、喷漆状态、主体颜色、底漆(状态)、无颜色
              ③先进先出
src/main/java/com/huaheng/pc/receipt/receiptContainerHeader/service/ReceiptContainerHeaderServiceImpl.java
... ... @@ -936,11 +936,7 @@ public class ReceiptContainerHeaderServiceImpl extends ServiceImpl<ReceiptContai
936 936  
937 937 @Override
938 938 public List<ReceiptContainerHeader> getUnCompleteCombineList() {
939   - LambdaQueryWrapper<ReceiptContainerHeader> receiptContainerHeaderLambdaQueryWrapper = Wrappers.lambdaQuery();
940   - receiptContainerHeaderLambdaQueryWrapper
941   - .lt(ReceiptContainerHeader::getStatus, QuantityConstant.RECEIPT_CONTAINER_FINISHED);
942   - List<ReceiptContainerHeader> receiptContainerHeaderList = list(receiptContainerHeaderLambdaQueryWrapper);
943   - return receiptContainerHeaderList;
  939 + return list(new LambdaQueryWrapper<ReceiptContainerHeader>().lt(ReceiptContainerHeader::getStatus, QuantityConstant.RECEIPT_CONTAINER_FINISHED));
944 940 }
945 941  
946 942  
... ...
src/main/java/com/huaheng/pc/shipment/shipmentHeader/domain/ShipmentHeader.java
... ... @@ -509,6 +509,11 @@ public class ShipmentHeader implements Serializable {
509 509 @TableField(value = "materialColor")
510 510 @ApiModelProperty(value = "物料颜色")
511 511 public String materialColor;
  512 + /**
  513 + * 喷漆状态
  514 + */
  515 + @TableField(value = "paintStatus")
  516 + public String paintStatus;
512 517  
513 518 /**
514 519 * 任务完成时间
... ... @@ -536,9 +541,4 @@ public class ShipmentHeader implements Serializable {
536 541 @ApiModelProperty(value = "物料编码")
537 542 private String materialCode;
538 543  
539   - /**
540   - * 喷漆状态
541   - */
542   - @TableField(value = "paintStatus")
543   - public String paintStatus;
544 544 }
... ...
src/main/java/com/huaheng/pc/shipment/shippingCombination/controller/ShippingCombinationController.java
... ... @@ -160,19 +160,23 @@ public class ShippingCombinationController extends BaseController {
160 160 if (list.isEmpty()) {
161 161 // 处理库存为0的明细
162 162 //handleDetail(shipmentHeader, shipmentDetail);
163   - throw new ServiceException("该物料没有库存可能是原仓库不同");
  163 + throw new ServiceException("该物料WMS系统没有库存,无法出库,或者是原仓库不同");
164 164 }
165 165 List<InventoryDetail> removeList = new ArrayList<>();
166 166 for (InventoryDetail item : list) {
167 167 item.setQty(item.getQty().subtract(item.getTaskQty()));
168 168 String containerCode = item.getContainerCode();
169   - Container container = containerService.getContainerByCode(containerCode);
  169 + //Container container = containerService.getContainerByCode(containerCode);
170 170 //平库不统计有任务的托盘
171   - if (container.getFlat() == null || container.getFlat() != 1) {
172   - Integer number = taskHeaderService.UncompleteCount(containerCode);
173   - if (number >= 1) {
174   - removeList.add(item);
175   - }
  171 + //if (container.getFlat() == null || container.getFlat() != 1) {
  172 + // Integer number = taskHeaderService.UncompleteCount(containerCode);
  173 + // if (number >= 1) {
  174 + // removeList.add(item);
  175 + // }
  176 + //}
  177 + Integer number = taskHeaderService.UncompleteCount(containerCode);
  178 + if (number >= 1) {
  179 + removeList.add(item);
176 180 }
177 181 }
178 182 List<ReceiptContainerHeader> unCompleteCombineList = receiptContainerHeaderService.getUnCompleteCombineList();
... ... @@ -190,7 +194,7 @@ public class ShippingCombinationController extends BaseController {
190 194 }
191 195 }
192 196 StringBuilder builder = new StringBuilder();
193   - builder.append("库存不足,剩余库存 ");
  197 + builder.append("库存不足,剩余库存");
194 198 list.removeAll(removeList);
195 199 for (InventoryDetail inventoryDetail : removeList) {
196 200 builder.append(inventoryDetail.getContainerCode() + "-");
... ...
src/main/java/com/huaheng/pc/shipment/shippingCombination/service/ShippingCombinationService.java
... ... @@ -26,8 +26,10 @@ import org.springframework.stereotype.Service;
26 26  
27 27 import javax.annotation.Resource;
28 28 import java.util.ArrayList;
  29 +import java.util.Comparator;
29 30 import java.util.List;
30 31 import java.util.Optional;
  32 +import java.util.stream.Collectors;
31 33  
32 34  
33 35 @Service
... ... @@ -53,84 +55,86 @@ public class ShippingCombinationService {
53 55  
54 56 //根据分配规则查找库存
55 57 public List<InventoryDetail> getInventorys(ShipmentDetail shipmentDetail, boolean isAuto, boolean isFlatWarehouse) {
56   - String warehouseCode = shipmentDetail.getWarehouseCode();
57   - String companyCode = shipmentDetail.getCompanyCode();
58 58 String materialCode = shipmentDetail.getMaterialCode();
59   - String inventorySts = shipmentDetail.getInventorySts();
60 59 String noticeNo = shipmentDetail.getNoticeNo();
61   - String batch = shipmentDetail.getBatch();
  60 + //noticeNo = Optional.ofNullable(noticeNo).orElse("");
62 61 String containerCode = shipmentDetail.getContainerCode();
63 62 String receiptCode = shipmentDetail.getReceiptCode();
64   - checkNotEmpty(warehouseCode, "出库详情没有仓库编码");
65   - checkNotEmpty(companyCode, "出库详情没有货主编码");
66   - checkNotEmpty(materialCode, "出库详情没有物料编码");
67   - checkNotEmpty(inventorySts, "出库详情没有物料品质");
68   - Material material = getMaterialByCode(materialCode);
69   - String policy = Optional.ofNullable(material.getPolicy()).orElse("");
70   - noticeNo = Optional.ofNullable(noticeNo).orElse("");
71   -
72   - String isBatchMaterial = Optional.ofNullable(material.getIsBatch()).orElse("");
  63 + checkNotEmpty(materialCode, "出库明细没有物料编码");
  64 + //Material material = getMaterialByCode(materialCode);
  65 + //String policy = Optional.ofNullable(material.getPolicy()).orElse("");
  66 + //String isBatchMaterial = Optional.ofNullable(material.getIsBatch()).orElse("");
73 67 ShipmentHeader shipmentHeader = shipmentHeaderService.getById(shipmentDetail.getShipmentId());
74 68 String warehouse = shipmentHeader.getWarehouse();
  69 + String color = shipmentHeader.getMaterialColor();
  70 + String paintStatus = shipmentHeader.getPaintStatus();
75 71  
76 72 LambdaQueryWrapper<InventoryDetail> wrapper = Wrappers.lambdaQuery();
77   - wrapper.eq(InventoryDetail::getWarehouseCode, warehouseCode)
78   - .eq(InventoryDetail::getCompanyCode, companyCode)
79   - .eq(InventoryDetail::getMaterialCode, materialCode)
80   - .eq(InventoryDetail::getInventorySts, inventorySts)
81   - .eq(StringUtils.isNotEmpty(receiptCode), InventoryDetail::getReceiptCode, receiptCode)
82   - .eq(StringUtils.isNotEmpty(warehouse), InventoryDetail::getWarehouse, warehouse)
83   - .eq(StringUtils.isNotEmpty(containerCode), InventoryDetail::getContainerCode, containerCode);
84   -
85   - if (isAuto && StringUtils.isNotEmpty(noticeNo)) {
86   - wrapper.eq(InventoryDetail::getNoticeCode, noticeNo);
87   - }
88   - if (isFlatWarehouse) {
89   - wrapper.ne(InventoryDetail::getZoneCode, "L");
  73 + wrapper.eq(InventoryDetail::getMaterialCode, materialCode)
  74 + .eq(StringUtils.isNotEmpty(warehouse), InventoryDetail::getWarehouse, warehouse)//原仓库
  75 + .eq(StringUtils.isNotEmpty(containerCode), InventoryDetail::getContainerCode, containerCode) //托盘号
  76 + .eq(StringUtils.isNotEmpty(receiptCode), InventoryDetail::getReceiptCode, receiptCode)//入库单号
  77 + .eq(StringUtils.isNotEmpty(noticeNo), InventoryDetail::getNoticeCode, noticeNo)//通知单号
  78 + .ne(isFlatWarehouse, InventoryDetail::getZoneCode, "L");//如果用平库组盘功能,只能出平库的库存
  79 + List<InventoryDetail> list = inventoryDetailService.list(wrapper);
  80 + if (list.isEmpty()) {
  81 + return list;
90 82 }
91   -
  83 + //排序:主体颜色加喷漆状态、喷漆状态、主体颜色、喷漆状态(底漆)、无颜色、先进先出
  84 +
  85 + return list.stream()
  86 + .sorted(Comparator.comparing((InventoryDetail detail) -> {
  87 + if (StringUtils.isNotEmpty(color) && StringUtils.isNotEmpty(paintStatus) && color.equals(detail.getMaterialColor()) && paintStatus.equals(detail.getPaintStatus())) {
  88 + return 1;
  89 + } else if (StringUtils.isNotEmpty(paintStatus) && paintStatus.equals(detail.getPaintStatus())) {
  90 + return 2;
  91 + } else if (StringUtils.isNotEmpty(color) && color.equals(detail.getMaterialColor())) {
  92 + return 3;
  93 + } else if ("底漆".equals(detail.getPaintStatus())) {
  94 + return 4;
  95 + } else if (StringUtils.isEmpty(detail.getPaintStatus())) {
  96 + return 5;
  97 + } else {
  98 + return 6;
  99 + }
  100 + }))
  101 + .collect(Collectors.toList());
92 102 //批次管控的物料,出库时优先按,生产日期,先进先出
93   - if (StringUtils.isNotEmpty(isBatchMaterial) && isBatchMaterial.equals("是")) {
94   - //是批次批次管控的物料走这里
95   - wrapper.orderByAsc(InventoryDetail::getProductionDate);
96   - }
97   - wrapper.orderByDesc(InventoryDetail::getQty);
98   - wrapper.orderByAsc(InventoryDetail::getCreated);
99   - List<InventoryDetail> list = inventoryDetailService.list(wrapper);
  103 + //if (StringUtils.isNotEmpty(isBatchMaterial) && isBatchMaterial.equals("是")) {
  104 + // //是批次批次管控的物料走这里
  105 + // wrapper.orderByAsc(InventoryDetail::getProductionDate);
  106 + //}
100 107  
101   - //优先匹配通知单号,没有数据就去掉通知单号再匹配
102   - if (list.isEmpty() && isAuto) {
103   - //如果物料的供需政策为LP的,或者通知单号包含展会字样的,必须匹配通知单号才可以出库,所以下面的代码不能走了,直接返回空集合
104   - if (policy.equals("PL") || noticeNo.contains("展会")) {
105   - return list;
106   - }
107   - return getInventoryWithoutNotice(companyCode, materialCode, inventorySts, receiptCode, containerCode, batch, isFlatWarehouse, isBatchMaterial);
108   - }
109   - return list;
110   - }
111 108  
  109 + ////优先匹配通知单号,没有数据就去掉通知单号再匹配
  110 + //if (list.isEmpty() && isAuto) {
  111 + // //如果物料的供需政策为LP的,或者通知单号包含展会字样的,必须匹配通知单号才可以出库,所以下面的代码不能走了,直接返回空集合
  112 + // if (policy.equals("PL") || noticeNo.contains("展会")) {
  113 + // return list;
  114 + // }
  115 + // return getInventoryWithoutNotice(materialCode, receiptCode, containerCode, isFlatWarehouse, isBatchMaterial);
  116 + //}
112 117  
113   - // 提取方法,用于构建没有通知单号的查询条件
114   - private List<InventoryDetail> getInventoryWithoutNotice(String companyCode, String materialCode, String inventorySts, String receiptCode, String containerCode, String batch, boolean isFlatWarehouse, String isBatchMaterial) {
115   - LambdaQueryWrapper<InventoryDetail> wrapper = Wrappers.lambdaQuery();
116   - wrapper.eq(InventoryDetail::getMaterialCode, materialCode)
117   - .eq(InventoryDetail::getCompanyCode, companyCode)
118   - .eq(InventoryDetail::getInventorySts, inventorySts)
119   - .eq(StringUtils.isNotEmpty(receiptCode), InventoryDetail::getReceiptCode, receiptCode)
120   - .eq(StringUtils.isNotEmpty(containerCode), InventoryDetail::getContainerCode, containerCode)
121   - .eq(StringUtils.isNotEmpty(batch), InventoryDetail::getBatch, batch);
122   -
123   - if (isFlatWarehouse) {
124   - wrapper.ne(InventoryDetail::getZoneCode, "L");
125   - }
126   - if (StringUtils.isEmpty(isBatchMaterial) || !isBatchMaterial.equals("是")) {
127   - wrapper.orderByDesc(InventoryDetail::getQty);
128   - }
129   - wrapper.orderByAsc(InventoryDetail::getCreated);
130   - return inventoryDetailService.list(wrapper);
131 118 }
132 119  
133 120  
  121 + // 没有通知单号
  122 + //private List<InventoryDetail> getInventoryWithoutNotice(String materialCode, String receiptCode, String containerCode, boolean isFlatWarehouse, String isBatchMaterial) {
  123 + // LambdaQueryWrapper<InventoryDetail> wrapper = Wrappers.lambdaQuery();
  124 + // wrapper.eq(InventoryDetail::getMaterialCode, materialCode)
  125 + // .eq(StringUtils.isNotEmpty(receiptCode), InventoryDetail::getReceiptCode, receiptCode)
  126 + // .eq(StringUtils.isNotEmpty(containerCode), InventoryDetail::getContainerCode, containerCode);
  127 + // if (isFlatWarehouse) {
  128 + // wrapper.ne(InventoryDetail::getZoneCode, "L");
  129 + // }
  130 + // if (StringUtils.isEmpty(isBatchMaterial) || !isBatchMaterial.equals("是")) {
  131 + // wrapper.orderByDesc(InventoryDetail::getQty);
  132 + // }
  133 + // wrapper.orderByAsc(InventoryDetail::getCreated);
  134 + // return inventoryDetailService.list(wrapper);
  135 + //}
  136 +
  137 +
134 138 // 封装判断方法,检查字符串是否为空,如果为空则抛出 ServiceException 异常
135 139 private void checkNotEmpty(String value, String errorMessage) {
136 140 if (StringUtils.isEmpty(value)) {
... ...