Browse Source

PDA入库码盘解绑-解绑入库备货单+测试

k 1 year ago
parent
commit
0adb5cd7c4

+ 13 - 16
warewms-ams/src/main/java/com/ruoyi/ams/asn/service/impl/WmsDocAsnHeaderServiceImpl.java

@@ -700,19 +700,6 @@ public class WmsDocAsnHeaderServiceImpl implements IWmsDocAsnHeaderService {
         if (invLotLocIdList == null || invLotLocIdList.size() == 0) {
             return AjaxResult.error("该托盘不存在库存:" + unlockForm.getPalletNo());
         }
-        // 备货库存暂时不可解绑
-        boolean isCan = invLotLocIdList.stream().allMatch(v -> {
-            String lotnum = v.getLotnum();
-            InvLotAtt invLotAtt = invLotAttService.selectInvLotAttByLotnum(lotnum);
-            if (StringUtils.isEmpty(invLotAtt.getLotatt14())) {
-                return true;
-            }
-            return false;
-        });
-        if (!isCan) {
-            // todo 解绑备货单 删除条码扫描记录
-            return AjaxResult.error("备货库存暂时不可解绑!");
-        }
         for (InvLotLocId inv : invLotLocIdList) {
             String erpNo = "";
             String erpName = "";
@@ -726,7 +713,6 @@ public class WmsDocAsnHeaderServiceImpl implements IWmsDocAsnHeaderService {
             detailsQuery.setAsnNo(asnNo);
             detailsQuery.setSku(qtt.getSku());
             List<WmsDocAsnDetails> details = wmsDocAsnDetailsMapper.selectWmsDocAsnDetailsList(detailsQuery);
-            // todo 物料qty可能大于某条明细数量
             BigDecimal qty = inv.getQty();
             for (WmsDocAsnDetails d : details) {
                 if (d.getReceivedQty().compareTo(qty) >= 0) {
@@ -737,13 +723,24 @@ public class WmsDocAsnHeaderServiceImpl implements IWmsDocAsnHeaderService {
                     break;
                 }
             }
-            //删除库存 todo 物料增加库存的时候如果改成根据相同库存和批次可以累加数量,这边就需要减库存,而不是直接删除
+            WmsDocAsnHeader docAsnHeaderUpdate = new WmsDocAsnHeader();
+            docAsnHeaderUpdate.setAsnNo(asnNo);
+            docAsnHeaderUpdate.setAsnStatus("30");
+            iWmsDocAsnHeaderService.updateWmsDocAsnHeader(docAsnHeaderUpdate);
+            //删除库存
             invLotLocIdMapper.deleteInvLotLocIdBy(inv.getLotnum(), inv.getSku(), inv.getLocationId(), inv.getCustomerId());
             sum = sum + inv.getQty().intValue();
 
             // 删除条码扫描记录
             erpBarcodesService.untieRecordErpBarcodeListAsnSo(erpNo,erpName,qtt.getLotatt02());
-
+            // 解绑出库备货单
+            if (StringUtils.isNotEmpty(qtt.getLotatt14())) {
+                wmsDocOrderHeaderService.modifystockCompletionStatusAsnUntie(qtt.getLotatt14()
+                        ,inv.getSku()
+                        ,BigDecimal.ONE
+                        ,qtt.getLotatt02()
+                ,unlockForm.getPalletNo());
+            }
         }
         return AjaxResult.success("解绑成功!" + unlockForm.getSku() + ",数量:" + sum);
     }

+ 11 - 0
warewms-ams/src/main/java/com/ruoyi/ams/order/service/IWmsDocOrderHeaderService.java

@@ -397,4 +397,15 @@ public interface IWmsDocOrderHeaderService {
     AjaxResult modifystockCompletionStatusAsn(String orderNo, String sku, BigDecimal qty
             ,String sn,String palletNo,String boxNo);
 
+    /**
+     * 入库备货解绑修改备货单备货状态
+     *
+     * @param orderNo
+     * @param sku
+     * @param qty
+     * @return
+     */
+    AjaxResult modifystockCompletionStatusAsnUntie(String orderNo, String sku, BigDecimal qty
+            ,String sn,String palletNo);
+
 }

+ 74 - 0
warewms-ams/src/main/java/com/ruoyi/ams/order/service/impl/WmsDocOrderHeaderServiceImpl.java

@@ -2465,6 +2465,7 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
 
 
     @Transactional
+    @Override
     public AjaxResult modifystockCompletionStatus(String orderNo, String sku, BigDecimal qty
             , String sn, String palletNo, String boxNo) {
         WmsDocOrderHeader docOrderHeader = wmsDocOrderHeaderService.selectWmsDocOrderHeaderByOrderNo(orderNo);
@@ -2536,6 +2537,7 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
     }
 
     @Transactional
+    @Override
     public AjaxResult modifystockCompletionStatusAsn(String orderNo, String sku, BigDecimal qty
             , String sn, String palletNo, String boxNo) {
         WmsDocOrderHeader docOrderHeader = wmsDocOrderHeaderService.selectWmsDocOrderHeaderByOrderNo(orderNo);
@@ -2615,4 +2617,76 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
 
         return AjaxResult.success();
     }
+
+    @Transactional
+    @Override
+    public AjaxResult modifystockCompletionStatusAsnUntie(String orderNo, String sku, BigDecimal qty, String sn, String palletNo) {
+        WmsDocOrderHeader docOrderHeader = wmsDocOrderHeaderService.selectWmsDocOrderHeaderByOrderNo(orderNo);
+        // 明细
+        List<WmsDocOrderDetails> wmsDocOrderDetails = wmsDocOrderDetailsMapper.selectWmsDocOrderDetailsByOrderNo(orderNo);
+        for (WmsDocOrderDetails wmsDocOrderDetail : wmsDocOrderDetails) {
+            if (qty.compareTo(BigDecimal.ZERO) == 0) {
+                break;
+            }
+            if (sku.equals(wmsDocOrderDetail.getSku())) {
+                // 多少已经备货的
+                BigDecimal toQty = wmsDocOrderDetail.getQtySoftAllocated();
+                if (toQty.compareTo(BigDecimal.ZERO) == 0) {
+                    continue;
+                }
+                WmsDocOrderDetails detailsUpdate = new WmsDocOrderDetails();
+                detailsUpdate.setOrderNo(wmsDocOrderDetail.getOrderNo());
+                detailsUpdate.setOrderLineNo(wmsDocOrderDetail.getOrderLineNo());
+                // 数量相等
+                if (qty.compareTo(toQty) == 0) {
+                    detailsUpdate.setQtyAllocated(wmsDocOrderDetail.getQtyAllocated().subtract(qty));
+                    detailsUpdate.setQtySoftAllocated(wmsDocOrderDetail.getQtySoftAllocated().subtract(qty));
+                    // 如果分配数量等于0 订单创建|部分分配
+                    if (detailsUpdate.getQtyAllocated().compareTo(BigDecimal.ZERO) == 0) {
+                        detailsUpdate.setLineStatus(Constant.ORDER_STS.STS00.getValue());
+                    } else {
+                        detailsUpdate.setLineStatus(Constant.ORDER_STS.STS10.getValue());
+                    }
+                    wmsDocOrderDetailsMapper.updateWmsDocOrderDetails(detailsUpdate);
+                    // 解绑扫码数据
+                    erpBarcodesService.untieRecordErpBarcodeListAsnSo(docOrderHeader.getSoReference1()
+                            , wmsDocOrderDetail.getdEdi07() == null ? "" : wmsDocOrderDetail.getdEdi07()
+                            , sn);
+                    break;
+                    // 数量小于备货数量
+                } else if (qty.compareTo(toQty) == -1) {
+                    detailsUpdate.setQtyAllocated(wmsDocOrderDetail.getQtyAllocated().subtract(qty));
+                    detailsUpdate.setQtySoftAllocated(wmsDocOrderDetail.getQtySoftAllocated().subtract(qty));
+                    // 如果分配数量等于0 订单创建|部分分配
+                    if (detailsUpdate.getQtyAllocated().compareTo(BigDecimal.ZERO) == 0) {
+                        detailsUpdate.setLineStatus(Constant.ORDER_STS.STS00.getValue());
+                    } else {
+                        detailsUpdate.setLineStatus(Constant.ORDER_STS.STS10.getValue());
+                    }
+                    wmsDocOrderDetailsMapper.updateWmsDocOrderDetails(detailsUpdate);
+                    // 解绑扫码数据
+                    erpBarcodesService.untieRecordErpBarcodeListAsnSo(docOrderHeader.getSoReference1()
+                            , wmsDocOrderDetail.getdEdi07() == null ? "" : wmsDocOrderDetail.getdEdi07()
+                            , sn);
+                    break;
+                }
+            }
+        }
+        //修改头单状态
+        String soStatus = Constant.ORDER_STS.STS00.getValue();
+        List<WmsDocOrderDetails> wmsDocOrderDetailsList = wmsDocOrderDetailsMapper.selectWmsDocOrderDetailsByOrderNo(orderNo);
+        for (WmsDocOrderDetails d : wmsDocOrderDetailsList) {
+            if (!d.getLineStatus().equals(Constant.ORDER_STS.STS00.getValue())) {
+                soStatus = Constant.ORDER_STS.STS10.getValue();
+                break;
+            }
+        }
+        WmsDocOrderHeader headerUpdate = new WmsDocOrderHeader();
+        headerUpdate.setOrderNo(orderNo);
+        headerUpdate.setOrderStatus(soStatus);
+        headerUpdate.setUpdateTime(new Date());
+        wmsDocOrderHeaderMapper.updateWmsDocOrderHeader(headerUpdate);
+
+        return AjaxResult.success();
+    }
 }