Jelajahi Sumber

分拣组盘、分拣出库、反拣组盘、反拣出库开发

zhangxin 1 tahun lalu
induk
melakukan
356cedba61

+ 2 - 1
warewms-ams/src/main/java/com/ruoyi/ams/order/dto/ReversePickGroupDiskDTO.java

@@ -4,6 +4,7 @@ import lombok.Data;
 
 import javax.validation.constraints.NotBlank;
 import java.io.Serializable;
+import java.math.BigDecimal;
 
 @Data
 public class ReversePickGroupDiskDTO implements Serializable {
@@ -33,6 +34,6 @@ public class ReversePickGroupDiskDTO implements Serializable {
      * 组盘数量
      */
     @NotBlank(message = "组盘数量不能为空")
-    private String qty;
+    private BigDecimal qty;
 
 }

+ 21 - 5
warewms-ams/src/main/java/com/ruoyi/ams/order/service/impl/WmsDocOrderHeaderServiceImpl.java

@@ -2889,9 +2889,6 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
         return result;
     }
 
-
-
-
     private List<InvLotAttPalletTotalDTO> buildInvLotAttPalletTotalList(List<InvLotAttPalletTotalDTO> lotAttPalletTotalDTOList, BigDecimal qty, List<PalletMatchLog> palletMatchLogList){
         //所需出库托盘
         List<InvLotAttPalletTotalDTO> result = new ArrayList<>();
@@ -2971,6 +2968,8 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
         Long locationId = unbindWmsBox(reversePickConvertDTO.getPalletFrom(), reversePickConvertDTO.getPalletTo());
         List<InvLotAtt> invLotAttList = invLotAttService.queryInvLotAtt(reversePickConvertDTO.getPalletFrom(), reversePickConvertDTO.getSn(), reversePickConvertDTO.getOrderNo());
         unbindInvLotLoc(invLotAttList.stream().map(InvLotAtt::getLotnum).collect(Collectors.toList()), locationId, reversePickConvertDTO.getPalletTo(), reversePickConvertDTO.getSku());
+        //出库单明细数量解绑
+        reversePickUnbindWmsDocOrder(reversePickConvertDTO.getOrderNo(), reversePickConvertDTO.getSku(), reversePickConvertDTO.getQty());
         //删除条码扫描记录
         erpBarcodesService.untieRecordErpBarcodeListAsnSo(reversePickConvertDTO.getErpNo(), null, reversePickConvertDTO.getSn());
         return AjaxResult.success("条码:" + reversePickConvertDTO.getSn() + "与出库单:" + reversePickGroupDiskDTO.getErpNo() + "解绑成功!");
@@ -3042,7 +3041,7 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
             boolean flag = CompareUtil.compare(qty, wmsDocOrderDetails.getQtyAllocated()) >= 0;
             wmsDocOrderDetails.setQtyAllocated(flag ? BigDecimal.ZERO : wmsDocOrderDetails.getQtyAllocated().subtract(qty));
             wmsDocOrderDetails.setQtyAllocatedEach(wmsDocOrderDetails.getQtyAllocated());
-            wmsDocOrderDetails.setLineStatus(flag ? Constant.ORDER_STS.STS00.getValue() : Constant.ORDER_STS.STS10.getValue());
+            wmsDocOrderDetails.setLineStatus(flag ? Constant.ORDER_STS.STS00.getValue() : Constant.ORDER_STS.STS22.getValue());
             wmsDocOrderDetailsService.updateWmsDocOrderDetails(wmsDocOrderDetails);
             qty = qty.subtract(wmsDocOrderDetails.getQtyAllocated());
             if (!flag || NumberUtil.equals(qty, BigDecimal.ZERO)) break;
@@ -3052,6 +3051,23 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
                 .set(WmsDocOrderHeader::getOrderStatus, Constant.ORDER_STS.STS22.getValue()).eq(WmsDocOrderHeader::getOrderNo, orderNo));
     }
 
+    private void reversePickUnbindWmsDocOrder(String orderNo, String sku, BigDecimal qty){
+        List<WmsDocOrderDetails> wmsDocOrderDetailsList = wmsDocOrderDetailsService.queryWmsDocOrderDetails(orderNo);
+        if (CollectionUtil.isEmpty(wmsDocOrderDetailsList)) throw new BaseException("出库单明细为空!");
+        List<WmsDocOrderDetails> wmsDocOrderDetailsFilterList = wmsDocOrderDetailsList.stream().filter(item -> CompareUtil.compare(item.getQtyAllocated(), item.getQtyOrdered()) > 0
+                && item.getSku().equals(sku)).sorted(Comparator.comparing(WmsDocOrderDetails::getOrderLineNo).reversed()).collect(Collectors.toList());
+        for (WmsDocOrderDetails wmsDocOrderDetails : wmsDocOrderDetailsFilterList) {
+            BigDecimal orderRequireSub = NumberUtil.sub(wmsDocOrderDetails.getQtyAllocated(), wmsDocOrderDetails.getQtyOrdered());
+            boolean flag = CompareUtil.compare(qty, orderRequireSub) >= 0;
+            wmsDocOrderDetails.setQtyAllocated(flag ? wmsDocOrderDetails.getQtyOrdered() : wmsDocOrderDetails.getQtyAllocated().subtract(qty));
+            wmsDocOrderDetails.setQtyAllocatedEach(wmsDocOrderDetails.getQtyAllocated());
+            wmsDocOrderDetails.setLineStatus(Constant.ORDER_STS.STS23.getValue());
+            wmsDocOrderDetailsService.updateWmsDocOrderDetails(wmsDocOrderDetails);
+            qty = qty.subtract(orderRequireSub);
+            if (!flag || NumberUtil.equals(qty, BigDecimal.ZERO)) return;
+        }
+    }
+
     private ReversePickConvertDTO buildReversePickConvertDTO(ReversePickGroupDiskDTO reversePickGroupDiskDTO) {
         ReversePickConvertDTO reversePickConvertDTO = ConvertUtils.sourceToTarget(reversePickGroupDiskDTO, ReversePickConvertDTO.class);
         // 根据条码获取物料号
@@ -3149,7 +3165,7 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
 
             wmsDocOrderDetails.setQtyAllocated(flag ? wmsDocOrderDetailsQtyAllocated.add(qty) : wmsDocOrderDetails.getQtyOrdered());
             wmsDocOrderDetails.setQtyAllocatedEach(wmsDocOrderDetails.getQtyAllocated());
-            wmsDocOrderDetails.setLineStatus(flag ? Constant.ORDER_STS.STS10.getValue() : Constant.ORDER_STS.STS20.getValue());
+            wmsDocOrderDetails.setLineStatus(flag ? Constant.ORDER_STS.STS22.getValue() : Constant.ORDER_STS.STS23.getValue());
             wmsDocOrderDetailsService.updateWmsDocOrderDetails(wmsDocOrderDetails);
             //生成分配明细
             actAllocationDetailsService.addActAllocationDetails(groupDiskConvertDTO.getLotNum(), groupDiskConvertDTO.getLocationId(), qty, wmsDocOrderDetails