Browse Source

1.PDA备货理货可以随意扫条码业务逻辑优化
2.PDA反拣组盘接口初始化

k 1 year ago
parent
commit
e0b5364f5b

+ 22 - 7
ruoyi-admin/src/main/java/com/ruoyi/web/controller/warewms/pda/PdaController.java

@@ -209,13 +209,13 @@ public class PdaController {
         if (baseLocationInfoFrom == null) {
             return AjaxResult.error("起始库位不存在!");
         }
-            if (!baseLocationInfoFrom.getStockStatus().equals(Constant.STOCK_STATUS.STOCK00.getValue())) {
-                return AjaxResult.error("起始库位不为空闲状态!");
-            }
-            if (!baseLocationInfoFrom.getZoneId().equals(Constant.ZONE_TYPE.ZONE_VIRTUAL.getValue())
-                    && !baseLocationInfoFrom.getIsEmpty().equals(Constant.IS_YES.Y.name())) {
-                return AjaxResult.error("起始库位已经有货!");
-            }
+        if (!baseLocationInfoFrom.getStockStatus().equals(Constant.STOCK_STATUS.STOCK00.getValue())) {
+            return AjaxResult.error("起始库位不为空闲状态!");
+        }
+        if (!baseLocationInfoFrom.getZoneId().equals(Constant.ZONE_TYPE.ZONE_VIRTUAL.getValue())
+                && !baseLocationInfoFrom.getIsEmpty().equals(Constant.IS_YES.Y.name())) {
+            return AjaxResult.error("起始库位已经有货!");
+        }
         if (StringUtils.isNotEmpty(lform.getLocationTo())) {
             BaseLocationInfo baseLocationInfoTo = baseLocationInfoService.selectBaseLocationInfoByIdOrNo(lform.getLocationTo()
                     , Constant.WAREHOUSE_ID);
@@ -560,6 +560,21 @@ public class PdaController {
         }
     }
 
+    /**
+     * 反拣组盘
+     *
+     * @return
+     */
+    @PostMapping("/docOrder/groupDiskFJ")
+    public AjaxResult groupDiskFJ(@RequestBody GroupDiskFrom groupDiskFrom) {
+        String orderNo = wmsDocOrderHeaderService.changeErpNoToOrderNo(groupDiskFrom.getOrderNo());
+        if (StringUtils.isEmpty(orderNo)) {
+            return AjaxResult.error("请扫描正确的出库单号");
+        }
+        groupDiskFrom.setOrderNo(orderNo);
+        return wmsDocOrderHeaderService.groupDisk(groupDiskFrom);
+    }
+
     /**
      * 拣货组盘(理货备货)
      *

+ 91 - 49
warewms-ams/src/main/java/com/ruoyi/ams/order/service/impl/WmsDocOrderHeaderServiceImpl.java

@@ -825,8 +825,8 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
         wmsDocOrderHeader.setOrderStatus(orderSts);
         wmsDocOrderHeaderService.updateWmsDocOrderHeader(wmsDocOrderHeader);
         // 记录扫码数据
-        erpBarcodesService.recordErpBarcodeListSo(wmsDocOrderDetails,sn
-                ,"SORTATION01",palletNo,BigDecimal.ONE,"");
+        erpBarcodesService.recordErpBarcodeListSo(wmsDocOrderDetails, sn
+                , "SORTATION01", palletNo, BigDecimal.ONE, "");
 
         return AjaxResult.success("拣货成功!" + endMsg);
     }
@@ -1302,7 +1302,7 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
         String palletNoTo = groupDiskFrom.getPalletNoTo(); // 目标托盘
         String sn = groupDiskFrom.getSn(); // 条码号
         String orderNo = ""; // 出库单号(备货才会传入)
-        String boxNo = groupDiskFrom.getBoxNo() == null ?"":groupDiskFrom.getBoxNo(); //箱号
+        String boxNo = groupDiskFrom.getBoxNo() == null ? "" : groupDiskFrom.getBoxNo(); //箱号
         String sku = ""; // 物料编码
         Double qty = Double.valueOf(groupDiskFrom.getQty()); // 数量
         boolean isAllUpdate = false; // 库存转移类型,是全部修改,还是拆分
@@ -1339,7 +1339,7 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
         for (WmsDocOrderDetails wmsDocOrderDetail : wmsDocOrderDetails) {
             if (wmsDocOrderDetail.getSku().equals(sku)) {
                 if (wmsDocOrderDetail.getQtyAllocated().compareTo(wmsDocOrderDetail.getQtySoftAllocated()) == 1) {
-                    con =true;
+                    con = true;
                     break;
                 }
             }
@@ -1377,7 +1377,7 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
             }
         }
         if (endLotattVO == null) {
-            return AjaxResult.error("组盘数量大于单条库存数量!");
+            return AjaxResult.error("不存在匹配库存!");
         }
         currentVirtualZone = endLotattVO.getLocationId();
         invLotLocIdLotattVOList.add(endLotattVO);
@@ -1427,6 +1427,7 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
                         invLotLocIdUpdate.setLocationId(v.getLocationId().toString());
                         invLotLocIdUpdate.setCustomerId(v.getCustomerId());
                         invLotLocIdUpdate.setSku(v.getSku());
+                        invLotLocIdUpdate.setQtyallocated(BigDecimal.ONE);
                         invLotLocIdUpdate.setLotnumTo(newLotnum);
                         invLotLocIdService.updateInvLotLocId(invLotLocIdUpdate);
                     } else {
@@ -1456,18 +1457,33 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
                     }
                     // 更新出库单备货数量
                     wmsDocOrderHeaderService.modifystockCompletionStatus(orderNo, sku, new BigDecimal(toQty)
-                    ,sn,palletNoFrom,boxNo);
+                            , sn, palletNoFrom, boxNo);
                 }
 
             }
         }
+        // 统计
+        int residual = 0; // 还剩需要备货的
+        // 还剩需要备货的
+        InvLocIdSearchFrom locIdSearchFromR = new InvLocIdSearchFrom();
+        LotattDTO lotattDTOR = new LotattDTO();
+        lotattDTOR.setLotatt07(palletNoFrom);
+        lotattDTOR.setLotatt15(orderNo);
+        locIdSearchFromR.setLotattDTO(lotattDTOR);
+        List<InvLotLocIdLotattVO> invLotLocIdLotattListR = invLotLocIdService.selectInvLocIdLotattList(locIdSearchFromR);
+        for (InvLotLocIdLotattVO invLotLocIdLotattVO : invLotLocIdLotattListR) {
+            if (StringUtils.isNotEmpty(invLotLocIdLotattVO.getLotatt15())
+                    && StringUtils.isEmpty(invLotLocIdLotattVO.getLotatt14())) {
+                residual++;
+            }
+        }
         // 更新托盘
         WmsBoxInfo wmsBoxInfo = wmsBoxInfoService.selectWmsBoxInfoByBoxNo(palletNoTo);
         WmsBoxInfo boxInfoUpdate = new WmsBoxInfo();
         boxInfoUpdate.setId(wmsBoxInfo.getId());
         boxInfoUpdate.setLocationId(currentVirtualZone);
         wmsBoxInfoService.updateWmsBoxInfo(boxInfoUpdate);
-        return AjaxResult.success("备货成功!");
+        return AjaxResult.success("当前托盘备货成功!还剩余未备数:" + residual);
     }
 
     /**
@@ -1481,7 +1497,7 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
         String palletNoFrom = groupDiskFrom.getPalletNoFrom(); // 起始托盘
         String palletNoTo = groupDiskFrom.getPalletNoTo(); // 目标托盘
         String sn = groupDiskFrom.getSn(); // 条码号
-        String boxNo = groupDiskFrom.getBoxNo() == null ?"":groupDiskFrom.getBoxNo(); //箱号
+        String boxNo = groupDiskFrom.getBoxNo() == null ? "" : groupDiskFrom.getBoxNo(); //箱号
         String orderNo = ""; // 出库单号
         String sku = ""; // 物料编码
         Double qty = Double.valueOf(groupDiskFrom.getQty()); // 数量
@@ -1500,7 +1516,6 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
             qty = 1.0; //产品默认为1
         }
         toQty = qty;
-        // todo 验证当前托盘sku原本分配了几个 现在已经备货了几个 如果相等了就不能备货了
         // 根据起始托盘,物料号查出库存
         InvLocIdSearchFrom locIdSearchFrom = new InvLocIdSearchFrom();
         locIdSearchFrom.setSku(sku);
@@ -1529,7 +1544,7 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
             }
         }
         if (endLotattVO == null) {
-            return AjaxResult.error("组盘数量大于单条库存数量!");
+            return AjaxResult.error("不存在匹配库存!");
         }
         // 判断扫描条码的库存是否被分配
         if (endLotattVO.getQtyallocated().compareTo(BigDecimal.ONE.doubleValue()) == 0) {
@@ -1569,7 +1584,7 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
             invLotAtt.setLotatt14(orderNo); // 备货对应的出库单号
             InvLotLocIdLotattVO invLotLocIdLotattVO = invLocIdList.get(0);
             if (StringUtils.isEmpty(invLotLocIdLotattVO.getLotatt15())) {
-                invLotAtt.setLotatt15(orderNo);
+                invLotAtt.setLotatt15("");
             } else {
                 invLotAtt.setLotatt15(invLotLocIdLotattVO.getLotatt15());
             }
@@ -1577,31 +1592,43 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
             if (invLotAttMapper.insertInvLotAtt(invLotAtt) > 0) {
                 for (InvLotLocIdLotattVO v : invLocIdList) {
                     if (isAllUpdate) {
-                        // 如果扫描的条码未分配
-                        if (!isAllocation) {
-                            // 修改原本出库单对应的任意一个条码分配数为1
-                            InvLocIdSearchFrom locIdSearchFrom01 = new InvLocIdSearchFrom();
-                            LotattDTO lotattDTO01 = new LotattDTO();
-                            lotattDTO01.setLotatt07(palletNoFrom);
-                            lotattDTO01.setLotatt15(orderNo);
-                            locIdSearchFrom01.setLotattDTO(lotattDTO01);
-                            List<InvLotLocIdLotattVO> invLotLocIdLotattList01 = invLotLocIdService.selectInvLocIdLotattList(locIdSearchFrom01);
-                            for (InvLotLocIdLotattVO locIdLotattVO : invLotLocIdLotattList01) {
-                                // 没有备货并且分配数为1
-                                if (StringUtils.isEmpty(locIdLotattVO.getLotatt14())
-                                        && locIdLotattVO.getQtyallocated().compareTo(BigDecimal.ONE.doubleValue()) == 0) {
-                                    InvLotLocIdForm invLotLocIdUpdate = new InvLotLocIdForm();
-                                    invLotLocIdUpdate.setLotnum(locIdLotattVO.getLotnum());
-                                    invLotLocIdUpdate.setLocationId(locIdLotattVO.getLocationId().toString());
-                                    invLotLocIdUpdate.setCustomerId(locIdLotattVO.getCustomerId());
-                                    invLotLocIdUpdate.setSku(locIdLotattVO.getSku());
-                                    invLotLocIdUpdate.setQtyallocated(BigDecimal.ZERO);
-                                    invLotLocIdService.updateInvLotLocId(invLotLocIdUpdate);
-                                    break;
-                                }
+                        boolean con = false;
+                        // 修改原本出库单对应的任意一个条码数据
+                        InvLocIdSearchFrom locIdSearchFrom01 = new InvLocIdSearchFrom();
+                        locIdSearchFrom01.setSku(sku);
+                        LotattDTO lotattDTO01 = new LotattDTO();
+                        lotattDTO01.setLotatt07(palletNoFrom);
+                        lotattDTO01.setLotatt15(orderNo);
+                        locIdSearchFrom01.setLotattDTO(lotattDTO01);
+                        List<InvLotLocIdLotattVO> invLotLocIdLotattList01 = invLotLocIdService.selectInvLocIdLotattList(locIdSearchFrom01);
+                        for (InvLotLocIdLotattVO locIdLotattVO : invLotLocIdLotattList01) {
+                            // 没有备货并且分配数为1
+                            if (StringUtils.isEmpty(locIdLotattVO.getLotatt14())
+                                    && locIdLotattVO.getQtyallocated().compareTo(BigDecimal.ONE.doubleValue()) == 0) {
+                                // 创建新批次
+                                InvLotAtt invLotAttNew = invLotAttMapper.selectInvLotAttByLotnum(locIdLotattVO.getLotnum());
+                                String newLotnum01 = idSequenceUtils.generateId("LOTNUMBER");
+                                invLotAttNew.setLotnum(newLotnum01);
+                                invLotAttNew.setLotatt15(isAllocation ? invLotAtt.getLotatt15() : "");
+                                invLotAttNew.setCreateTime(DateUtils.getNowDate());
+                                invLotAttMapper.insertInvLotAtt(invLotAttNew);
+                                // 更新库存
+                                InvLotLocIdForm invLotLocIdUpdate = new InvLotLocIdForm();
+                                invLotLocIdUpdate.setLotnum(locIdLotattVO.getLotnum());
+                                invLotLocIdUpdate.setLotnumTo(newLotnum01);
+                                invLotLocIdUpdate.setLocationId(locIdLotattVO.getLocationId().toString());
+                                invLotLocIdUpdate.setCustomerId(locIdLotattVO.getCustomerId());
+                                invLotLocIdUpdate.setSku(locIdLotattVO.getSku());
+                                invLotLocIdUpdate.setQtyallocated(isAllocation ? BigDecimal.ONE : BigDecimal.ZERO);
+                                invLotLocIdService.updateInvLotLocId(invLotLocIdUpdate);
+                                con = true;
+                                break;
                             }
-
                         }
+                        if (!con) {
+                            return AjaxResult.error("托盘对应物料已经扫描完成!");
+                        }
+                        // 更新库存
                         InvLotLocIdForm invLotLocIdUpdate = new InvLotLocIdForm();
                         invLotLocIdUpdate.setLotnum(lotnum);
                         invLotLocIdUpdate.setLocationId(v.getLocationId().toString());
@@ -1618,13 +1645,28 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
 
             }
         }
+        // 统计
+        int residual = 0; // 还剩需要备货的
+        // 还剩需要备货的
+        InvLocIdSearchFrom locIdSearchFromR = new InvLocIdSearchFrom();
+        LotattDTO lotattDTOR = new LotattDTO();
+        lotattDTOR.setLotatt07(palletNoFrom);
+        lotattDTOR.setLotatt15(orderNo);
+        locIdSearchFromR.setLotattDTO(lotattDTOR);
+        List<InvLotLocIdLotattVO> invLotLocIdLotattListR = invLotLocIdService.selectInvLocIdLotattList(locIdSearchFromR);
+        for (InvLotLocIdLotattVO invLotLocIdLotattVO : invLotLocIdLotattListR) {
+            if (StringUtils.isNotEmpty(invLotLocIdLotattVO.getLotatt15())
+                    && StringUtils.isEmpty(invLotLocIdLotattVO.getLotatt14())) {
+                residual++;
+            }
+        }
         // 更新托盘
         WmsBoxInfo wmsBoxInfo = wmsBoxInfoService.selectWmsBoxInfoByBoxNo(palletNoTo);
         WmsBoxInfo boxInfoUpdate = new WmsBoxInfo();
         boxInfoUpdate.setId(wmsBoxInfo.getId());
         boxInfoUpdate.setLocationId(currentVirtualZone);
         wmsBoxInfoService.updateWmsBoxInfo(boxInfoUpdate);
-        return AjaxResult.success("备货成功!(未分配条码)");
+        return AjaxResult.success("当前托盘备货成功!(未分配条码),还剩余未备数:" + residual);
     }
 
     @Transactional
@@ -2250,7 +2292,7 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
 
     @Transactional
     public AjaxResult modifystockCompletionStatus(String orderNo, String sku, BigDecimal qty
-            ,String sn,String palletNo,String boxNo) {
+            , String sn, String palletNo, String boxNo) {
         WmsDocOrderHeader docOrderHeader = wmsDocOrderHeaderService.selectWmsDocOrderHeaderByOrderNo(orderNo);
         // 明细
         List<WmsDocOrderDetails> wmsDocOrderDetails = wmsDocOrderDetailsMapper.selectWmsDocOrderDetailsByOrderNo(orderNo);
@@ -2277,8 +2319,8 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
                         }
                         wmsDocOrderDetailsMapper.updateWmsDocOrderDetails(detailsUpdate);
                         // 记录扫码数据
-                        erpBarcodesService.recordErpBarcodeListSo(wmsDocOrderDetail,sn
-                                ,"SORTATION01",palletNo,BigDecimal.ONE,boxNo);
+                        erpBarcodesService.recordErpBarcodeListSo(wmsDocOrderDetail, sn
+                                , "SORTATION01", palletNo, BigDecimal.ONE, boxNo);
                         break;
                     } else if (qty.compareTo(toQty) == 1) {
                         qty = qty.subtract(toQty);
@@ -2288,14 +2330,14 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
                         }
                         wmsDocOrderDetailsMapper.updateWmsDocOrderDetails(detailsUpdate);
                         // 记录扫码数据
-                        erpBarcodesService.recordErpBarcodeListSo(wmsDocOrderDetail,sn
-                                ,"SORTATION01",palletNo,BigDecimal.ONE,boxNo);
+                        erpBarcodesService.recordErpBarcodeListSo(wmsDocOrderDetail, sn
+                                , "SORTATION01", palletNo, BigDecimal.ONE, boxNo);
                     } else {
                         detailsUpdate.setQtySoftAllocated(wmsDocOrderDetail.getQtySoftAllocated().add(qty));
                         wmsDocOrderDetailsMapper.updateWmsDocOrderDetails(detailsUpdate);
                         // 记录扫码数据
-                        erpBarcodesService.recordErpBarcodeListSo(wmsDocOrderDetail,sn
-                                ,"SORTATION01",palletNo,BigDecimal.ONE,boxNo);
+                        erpBarcodesService.recordErpBarcodeListSo(wmsDocOrderDetail, sn
+                                , "SORTATION01", palletNo, BigDecimal.ONE, boxNo);
                         break;
                     }
                 }
@@ -2321,7 +2363,7 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
 
     @Transactional
     public AjaxResult modifystockCompletionStatusAsn(String orderNo, String sku, BigDecimal qty
-    ,String sn,String palletNo,String boxNo) {
+            , String sn, String palletNo, String boxNo) {
         WmsDocOrderHeader docOrderHeader = wmsDocOrderHeaderService.selectWmsDocOrderHeaderByOrderNo(orderNo);
         // 明细
         List<WmsDocOrderDetails> wmsDocOrderDetails = wmsDocOrderDetailsMapper.selectWmsDocOrderDetailsByOrderNo(orderNo);
@@ -2350,8 +2392,8 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
                         }
                         wmsDocOrderDetailsMapper.updateWmsDocOrderDetails(detailsUpdate);
                         // 记录扫码数据
-                        erpBarcodesService.recordErpBarcodeListSo(wmsDocOrderDetail,sn
-                                ,"STAGE01",palletNo,BigDecimal.ONE,boxNo);
+                        erpBarcodesService.recordErpBarcodeListSo(wmsDocOrderDetail, sn
+                                , "STAGE01", palletNo, BigDecimal.ONE, boxNo);
                         break;
                         // 完全分配
                     } else if (qty.compareTo(toQty) == 1) {
@@ -2366,8 +2408,8 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
                         }
                         wmsDocOrderDetailsMapper.updateWmsDocOrderDetails(detailsUpdate);
                         // 记录扫码数据
-                        erpBarcodesService.recordErpBarcodeListSo(wmsDocOrderDetail,sn
-                                ,"SORTATION01",palletNo,BigDecimal.ONE,boxNo);
+                        erpBarcodesService.recordErpBarcodeListSo(wmsDocOrderDetail, sn
+                                , "SORTATION01", palletNo, BigDecimal.ONE, boxNo);
                         // 部分分配
                     } else {
                         detailsUpdate.setQtyAllocated(wmsDocOrderDetail.getQtyAllocated().add(qty));
@@ -2375,8 +2417,8 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
                         detailsUpdate.setLineStatus(Constant.ORDER_STS.STS10.getValue());
                         wmsDocOrderDetailsMapper.updateWmsDocOrderDetails(detailsUpdate);
                         // 记录扫码数据
-                        erpBarcodesService.recordErpBarcodeListSo(wmsDocOrderDetail,sn
-                                ,"SORTATION01",palletNo,BigDecimal.ONE,boxNo);
+                        erpBarcodesService.recordErpBarcodeListSo(wmsDocOrderDetail, sn
+                                , "SORTATION01", palletNo, BigDecimal.ONE, boxNo);
                         break;
                     }
                 }