浏览代码

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

zhangxin 1 年之前
父节点
当前提交
6620b97506

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

@@ -476,4 +476,6 @@ public interface IWmsDocOrderHeaderService {
      * @return
      */
     List<PalletMatchLogDTO> queryPalletMatchInfoList(String orderNos);
+
+    AjaxResult pdaUnbind(UnbindDTO unbindDTO);
 }

+ 7 - 7
warewms-ams/src/main/java/com/ruoyi/ams/order/service/impl/UpdateOrderStockingProcessImpl.java

@@ -101,13 +101,13 @@ public class UpdateOrderStockingProcessImpl implements UpdateOrderStockingProces
         }
         // 备货单有分配任务不可更新备货
         List<WmsDocOrderDetails> wmsDocOrderDetailsList = iWmsDocOrderDetailsService.selectWmsDocOrderDetailsByOrderNo(orderNo);
-        for (WmsDocOrderDetails wmsDocOrderDetails : wmsDocOrderDetailsList) {
-            if (wmsDocOrderDetails.getQtyAllocated().compareTo(wmsDocOrderDetails.getQtySoftAllocated()) != 0) {
-                log.error("备货单正在备货,暂不可更新备货" + header.getOrderNo());
-                recordRemark(orderNo, "备货单正在备货,暂不可更新备货" + header.getOrderNo());
-                return AjaxResult.error("备货单正在备货,暂不可更新备货" + header.getOrderNo());
-            }
-        }
+//        for (WmsDocOrderDetails wmsDocOrderDetails : wmsDocOrderDetailsList) {
+//            if (wmsDocOrderDetails.getQtyAllocated().compareTo(wmsDocOrderDetails.getQtySoftAllocated()) != 0) {
+//                log.error("备货单正在备货,暂不可更新备货" + header.getOrderNo());
+//                recordRemark(orderNo, "备货单正在备货,暂不可更新备货" + header.getOrderNo());
+//                return AjaxResult.error("备货单正在备货,暂不可更新备货" + header.getOrderNo());
+//            }
+//        }
         // 备货库存并且没有正在执行的出库任务
         InvLocIdSearchFrom invLocIdSearchFrom = new InvLocIdSearchFrom();
         invLocIdSearchFrom.setLotatt14(orderNo);

+ 17 - 13
warewms-ams/src/main/java/com/ruoyi/ams/order/service/impl/WmsDocOrderHeaderServiceImpl.java

@@ -2740,7 +2740,7 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
      */
     @Override
     public synchronized AjaxResult syncPdaUnbind(UnbindDTO unbindDTO){
-        return pdaUnbind(unbindDTO);
+        return wmsDocOrderHeaderService.pdaUnbind(unbindDTO);
     }
 
     /**
@@ -2748,7 +2748,7 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
      */
     @Override
     public synchronized AjaxResult syncPdaGroupDisk(PdaGroupDiskDTO pdaGroupDiskDTO){
-        return pdaGroupDisk(pdaGroupDiskDTO);
+        return wmsDocOrderHeaderService.pdaGroupDisk(pdaGroupDiskDTO);
     }
 
     /**
@@ -2756,14 +2756,14 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
      */
     @Override
     public synchronized AjaxResult syncPdaReversePickGroupDisk(ReversePickGroupDiskDTO reversePickGroupDiskDTO){
-        return pdaReversePickGroupDisk(reversePickGroupDiskDTO);
+        return wmsDocOrderHeaderService.pdaReversePickGroupDisk(reversePickGroupDiskDTO);
     }
     /**
      * PDA库存匹配并发控制
      */
     @Override
     public synchronized Boolean syncInventoryMatch(String orderNos){
-        return inventoryMatch(orderNos);
+        return wmsDocOrderHeaderService.inventoryMatch(orderNos);
     }
 
     /**
@@ -2771,7 +2771,7 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
      */
     @Override
     public synchronized Boolean syncPdaReversePickInventoryMatch(String orderNos){
-        return reversePickInventoryMatch(orderNos);
+        return wmsDocOrderHeaderService.reversePickInventoryMatch(orderNos);
     }
 
     /**
@@ -2845,6 +2845,7 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
         ReversePickConvertDTO reversePickConvertDTO = buildReversePickConvertDTO(reversePickGroupDiskDTO);
         //判断反拣类型为解绑还是扩容
         BigDecimal qty = judgeReversePickType(reversePickConvertDTO.getSku(), reversePickConvertDTO.getOrderNo());
+        if (CompareUtil.compare(qty, BigDecimal.ZERO) == 0) throw new BaseException("出库单该品号不存在反拣情况!");
         //1. 理货备货
         if (CompareUtil.compare(qty, BigDecimal.ZERO) < 0){
             PdaGroupDiskDTO pdaGroupDiskDTO = ConvertUtils.sourceToTarget(reversePickConvertDTO, PdaGroupDiskDTO.class);
@@ -2865,6 +2866,7 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
     /**
      * PDA解绑物料
      */
+    @Override
     @Transactional(propagation = Propagation.REQUIRES_NEW)
     public AjaxResult pdaUnbind(UnbindDTO unbindDTO) {
         InvLotLocId invLotLocId = invLotLocIdService.queryInvLotLocIdByLotnum(unbindDTO.getLotnum());
@@ -2873,7 +2875,7 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
         if (StringUtils.isBlank(unbindDTO.getErpNo())) return AjaxResult.success("托盘:" + unbindDTO.getPalletTo() + "解绑成功!托盘数量: " + invLotAttService.queryPalletTotal(unbindDTO.getPalletTo()));
         // 删除条码扫描记录
         erpBarcodesService.untieRecordErpBarcodeListAsnSo(unbindDTO.getErpNo(), null, unbindDTO.getSn());
-        unbindWmsDocOrder(unbindDTO.getErpNo(), invLotLocId.getQty());
+        unbindWmsDocOrder(unbindDTO.getErpNo(), invLotLocId.getQty(), unbindDTO.getSku());
         return AjaxResult.success("托盘:" + unbindDTO.getPalletTo() + "解绑成功!托盘数量: " + invLotAttService.queryPalletTotal(unbindDTO.getPalletTo()));
     }
 
@@ -2946,6 +2948,7 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
             for (String sku : skuList) {
                 //判断反拣类型为解绑还是扩容 如果大于零则为该解绑得数量
                 BigDecimal qty = judgeReversePickType(sku, wmsDocOrderDetailsGroupByOrderNoEntry.getKey());
+                if (CompareUtil.compare(qty, BigDecimal.ZERO) == 0) continue;
                 if (CompareUtil.compare(qty, BigDecimal.ZERO) < 0) {
                     flag = Boolean.TRUE;
                     continue;
@@ -3005,7 +3008,7 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
     /**
      * PDA解绑物料:解绑托盘
      */
-    private Long unbindWmsBox(String palletTo, String palletFrom){
+    public Long unbindWmsBox(String palletTo, String palletFrom){
         WmsBoxInfo wmsBoxToInfo = wmsBoxInfoService.selectWmsBoxInfoByBoxNo(palletTo);
         if (ObjectUtil.isNull(wmsBoxToInfo)) {
             throw new BaseException("查询不到目标托盘:" + palletTo);
@@ -3046,11 +3049,11 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
     /**
      * PDA解绑物料:解绑出库单
      */
-    private void unbindWmsDocOrder(String erpNo, BigDecimal qty){
+    public void unbindWmsDocOrder(String erpNo, BigDecimal qty, String sku){
         WmsDocOrderHeader wmsDocOrderHeader = selectWmsDocOrderHeaderByErpNo(erpNo);
         if (ObjectUtil.isNull(wmsDocOrderHeader)) throw new BaseException("出库单号错误!");
         String orderNo = wmsDocOrderHeader.getOrderNo();
-        List<WmsDocOrderDetails> wmsDocOrderDetailsList = wmsDocOrderDetailsService.queryWmsDocOrderDetails(orderNo);
+        List<WmsDocOrderDetails> wmsDocOrderDetailsList = wmsDocOrderDetailsService.queryWmsDocOrderDetails(orderNo, sku);
         if (CollectionUtil.isEmpty(wmsDocOrderDetailsList)) throw new BaseException("出库单明细为空!");
         wmsDocOrderDetailsList = ListUtil.reverse(wmsDocOrderDetailsList.stream().filter(item -> ObjectUtil.isNotNull(item.getQtyAllocated())
                 || !NumberUtil.equals(item.getQtyAllocated(), BigDecimal.ZERO)).collect(Collectors.toList()));
@@ -3083,6 +3086,8 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
             wmsDocOrderDetails.setQtyAllocated(flag ? wmsDocOrderDetails.getQtyOrdered() : wmsDocOrderDetails.getQtyAllocated().subtract(qty));
             wmsDocOrderDetails.setQtyAllocatedEach(wmsDocOrderDetails.getQtyAllocated());
             wmsDocOrderDetails.setLineStatus(Constant.ORDER_STS.STS23.getValue());
+            wmsDocOrderDetails.setQtySoftAllocated(flag ? BigDecimal.ZERO : wmsDocOrderDetails.getQtySoftAllocated().add(qty));
+            wmsDocOrderDetails.setQtySoftallocatedEach(wmsDocOrderDetails.getQtySoftAllocated());
             wmsDocOrderDetailsService.updateWmsDocOrderDetails(wmsDocOrderDetails);
             qty = qty.subtract(orderRequireSub);
             if (!flag || NumberUtil.equals(qty, BigDecimal.ZERO)) return;
@@ -3093,13 +3098,12 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
      * 判断反拣类型为解绑还是扩容 返回负数扩容 正数为需解绑数量
      */
     private BigDecimal judgeReversePickType(String sku, String orderNo){
+        List<WmsDocOrderDetails> wmsDocOrderDetailsList = wmsDocOrderDetailsService.queryWmsDocOrderDetails(orderNo, sku);
+        BigDecimal orderRequireQty = wmsDocOrderDetailsList.stream().map(WmsDocOrderDetails::getQtyOrdered).reduce(BigDecimal.ZERO, BigDecimal::add);
         List<InvLotAtt> invLotAttList = invLotAttService.queryOrderSameSkuInvLotAttList(sku, orderNo);
-        if (CollectionUtil.isEmpty(invLotAttList)) throw new BaseException("该出库单未进行理货备货,无法反拣!");
+        if (CollectionUtil.isEmpty(invLotAttList)) return NumberUtil.sub(BigDecimal.ZERO, orderRequireQty);
         List<InvLotLocId> invLotLocIdList = invLotLocIdService.queryInvLotLocIdByLotnum(invLotAttList.stream().map(InvLotAtt::getLotnum).collect(Collectors.toList()));
-        List<WmsDocOrderDetails> wmsDocOrderDetailsList = wmsDocOrderDetailsService.queryWmsDocOrderDetails(orderNo, sku);
         BigDecimal orderAllocatedQty = invLotLocIdList.stream().map(InvLotLocId::getQtyallocated).reduce(BigDecimal.ZERO, BigDecimal::add);
-        BigDecimal orderRequireQty = wmsDocOrderDetailsList.stream().map(WmsDocOrderDetails::getQtyOrdered).reduce(BigDecimal.ZERO, BigDecimal::add);
-        if (CompareUtil.compare(orderAllocatedQty, orderRequireQty) == 0) throw new BaseException("出库单该品号不存在反拣情况!");
         return NumberUtil.sub(orderAllocatedQty, orderRequireQty);
     }