소스 검색

分拣组盘bug修复

zhangxin 1 년 전
부모
커밋
a03b13feac

+ 10 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/warewms/pda/PdaController.java

@@ -536,6 +536,16 @@ public class PdaController {
         return AjaxResult.success(wmsDocOrderHeaderService.syncInventoryMatch(orderNos));
     }
 
+    /**
+     * pda分拣出库
+     * @param orderNos
+     * @return
+     */
+    @PostMapping("/docOrder/syncSeparatePick")
+    public AjaxResult separatePick(@RequestParam String orderNos) {
+        return AjaxResult.success(wmsDocOrderHeaderService.syncSeparatePick(orderNos));
+    }
+
     /**
      * 反拣出库
      * @param orderNos

+ 7 - 0
warewms-ams/src/main/java/com/ruoyi/ams/inv/service/IInvLotAttService.java

@@ -127,6 +127,13 @@ public interface IInvLotAttService
      */
     List<InvLotAtt> queryInvLotAtt(String palletNo, String sn, String orderNo);
 
+    /**
+     * 根据出库单号查询已备货/出库批次
+     * @param orderNoList
+     * @return
+     */
+    List<InvLotAtt> queryInvLotAttByOrderNoList(List<String> orderNoList);
+
     /**
      * 根据出库单号及物料码查询出库单与扫描物料相同已分配数量
      * @param sku

+ 0 - 11
warewms-ams/src/main/java/com/ruoyi/ams/inv/service/IInvLotLocIdService.java

@@ -433,17 +433,6 @@ public interface IInvLotLocIdService {
      */
     Boolean updateInvLotLocId(String lotNum, BigDecimal qtyAllocated, String sku);
 
-    /**
-     * 修改库位库存信息
-     * @param lotNum
-     * @param lotNumTo
-     * @param qty
-     * @param sku
-     * @param locationId
-     * @return
-     */
-    Boolean updateInvLotLocId(String lotNum, String lotNumTo, BigDecimal qty, String sku, String locationId);
-
     /**
      * 修改库位库存主键以及库位id
      * @param lotNum

+ 15 - 3
warewms-ams/src/main/java/com/ruoyi/ams/inv/service/impl/InvLotAttServiceImpl.java

@@ -16,6 +16,7 @@ import com.ruoyi.ams.order.dto.ReversePickInventoryMatchDTO;
 import com.ruoyi.common.utils.ConvertUtils;
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.StringUtils;
+import org.apache.commons.compress.utils.Lists;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -143,7 +144,7 @@ public class InvLotAttServiceImpl implements IInvLotAttService {
             return new HashMap<>();
         }
         //根据sku对批次分类
-        Map<String, List<InvLotAtt>> skuInvLotAttMap = invLotAttList.stream().filter(item -> StringUtils.isBlank(item.getLotatt14()) && StringUtils.isBlank(item.getLotatt15())).collect(Collectors.groupingBy(InvLotAtt::getSku));
+        Map<String, List<InvLotAtt>> skuInvLotAttMap = invLotAttList.stream().filter(item -> StringUtils.isBlank(item.getLotatt14())).collect(Collectors.groupingBy(InvLotAtt::getSku));
         //根据sku分类各托盘剩余数量信息
         return buildInvLotAttPalletTotalGroupBySkuMap(lotNumQtyMap, skuInvLotAttMap);
     }
@@ -245,6 +246,17 @@ public class InvLotAttServiceImpl implements IInvLotAttService {
                 .eq(StringUtils.isNotBlank(orderNo), InvLotAtt::getLotatt14, orderNo));
     }
 
+    /**
+     * 根据出库单号查询已备货/出库批次
+     * @param orderNoList
+     * @return
+     */
+    @Override
+    public List<InvLotAtt> queryInvLotAttByOrderNoList(List<String> orderNoList){
+        return queryOrderSameSkuInvLotAttList(Lists.newArrayList(), orderNoList);
+    }
+
+
     /**
      * 根据出库单号及物料码查询出库单与扫描物料相同已分配数量
      * @param sku
@@ -278,8 +290,8 @@ public class InvLotAttServiceImpl implements IInvLotAttService {
     @Override
     public List<InvLotAtt> queryOrderSameSkuInvLotAttList(List<String> skuList, List<String> orderNoList){
         return invLotAttMapper.selectList(Wrappers.<InvLotAtt>lambdaQuery()
-                .in(InvLotAtt::getSku, skuList)
-                .in(InvLotAtt::getLotatt14, orderNoList));
+                .in(CollectionUtil.isNotEmpty(skuList), InvLotAtt::getSku, skuList)
+                .in(CollectionUtil.isNotEmpty(orderNoList), InvLotAtt::getLotatt14, orderNoList));
     }
 
     private List<InvLotAtt> queryInvLotAttByLotNumList(List<String> lotNumList){

+ 1 - 15
warewms-ams/src/main/java/com/ruoyi/ams/inv/service/impl/InvLotLocIdServiceImpl.java

@@ -1172,20 +1172,6 @@ public class InvLotLocIdServiceImpl implements IInvLotLocIdService {
         return updateInvLotLocId(lotNum, null, null, qtyAllocated, sku, null);
     }
 
-    /**
-     * 修改库位库存信息
-     * @param lotNum
-     * @param lotNumTo
-     * @param qty
-     * @param sku
-     * @param locationId
-     * @return
-     */
-    @Override
-    public Boolean updateInvLotLocId(String lotNum, String lotNumTo, BigDecimal qty, String sku, String locationId) {
-        return updateInvLotLocId(lotNum, lotNumTo, qty, null, sku, locationId);
-    }
-
     /**
      * 修改库位库存主键以及库位id
      * @param lotNum
@@ -1221,7 +1207,7 @@ public class InvLotLocIdServiceImpl implements IInvLotLocIdService {
                 .set(StringUtils.isNotBlank(lotNumTo), InvLotLocId::getQty, qty)
                 .set(InvLotLocId::getSku, sku)
                 .set(StringUtils.isNotBlank(locationId), InvLotLocId::getLocationId, locationId)
-                .set(InvLotLocId::getQtyallocated, StringUtils.isNotBlank(lotNumTo) ? qty : qtyAllocated)
+                .set(ObjectUtil.isNotNull(qtyAllocated), InvLotLocId::getQtyallocated, qtyAllocated)
         ) > 0;
     }
 

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

@@ -450,6 +450,11 @@ public interface IWmsDocOrderHeaderService {
      */
     Boolean syncInventoryMatch(String orderNos);
 
+    /**
+     * PDA分拣出库并发控制
+     */
+    Boolean syncSeparatePick(String orderNos);
+
     /**
      * PDA反拣出库并发控制
      */
@@ -474,6 +479,11 @@ public interface IWmsDocOrderHeaderService {
      */
     Boolean inventoryMatch(String orderNos);
 
+    /**
+     * PDA分拣出库
+     */
+    Boolean separatePick(String orderNos);
+
     /**
      * 反拣出库
      */

+ 40 - 2
warewms-ams/src/main/java/com/ruoyi/ams/order/service/impl/WmsDocOrderHeaderServiceImpl.java

@@ -2768,6 +2768,7 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
     public synchronized AjaxResult syncPdaReversePickGroupDisk(ReversePickGroupDiskDTO reversePickGroupDiskDTO){
         return wmsDocOrderHeaderService.pdaReversePickGroupDisk(reversePickGroupDiskDTO);
     }
+
     /**
      * PDA库存匹配并发控制
      */
@@ -2776,6 +2777,14 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
         return wmsDocOrderHeaderService.inventoryMatch(orderNos);
     }
 
+    /**
+     * PDA分拣出库并发控制
+     */
+    @Override
+    public synchronized Boolean syncSeparatePick(String orderNos){
+        return wmsDocOrderHeaderService.separatePick(orderNos);
+    }
+
     /**
      * PDA反拣出库并发控制
      */
@@ -2827,6 +2836,35 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
         return palletMatchLogService.insertBatch(buildPalletMatchLogList(result, orderList));
     }
 
+    /**
+     * 分拣出库
+     */
+    @Override
+    @Transactional(propagation = Propagation.REQUIRES_NEW)
+    public Boolean separatePick(String orderNos) {
+        List<String> orderList = JSONArray.parseArray(orderNos, String.class);
+        List<WmsDocOrderHeader> wmsDocOrderHeaderList = wmsDocOrderHeaderMapper.selectList(Wrappers.<WmsDocOrderHeader>lambdaQuery().in(WmsDocOrderHeader::getSoReference1, orderList).orderByDesc(WmsDocOrderHeader::getCreateTime));
+        if (CollectionUtil.isEmpty(wmsDocOrderHeaderList)) {
+            throw new BaseException("请扫描正确的出库单号");
+        }
+        List<InvLotAtt> invLotAttList = invLotAttService.queryInvLotAttByOrderNoList(wmsDocOrderHeaderList.stream().map(WmsDocOrderHeader::getOrderNo).collect(Collectors.toList()));
+        Assert.isTrue(CollectionUtil.isNotEmpty(invLotAttList), "扫描出库单未进行理货备货!");
+        List<InvLotLocId> invLotLocIdList = invLotLocIdService.queryInvLotLocIdByLotnum(invLotAttList.stream().map(InvLotAtt::getLotnum).collect(Collectors.toList()));
+        Map<String, List<InvLotLocId>> invLotLocIdGroupByLocationMap = invLotLocIdList.stream().collect(Collectors.groupingBy(InvLotLocId::getLocationId));
+        List<InvLotAttPalletTotalDTO> result = invLotLocIdGroupByLocationMap.entrySet().stream().map(item -> {
+            InvLotLocId invLotLocId = item.getValue().stream().findFirst().orElseThrow(() -> new BaseException("Table invLotLocId data is on error"));
+            InvLotAttPalletTotalDTO invLotAttPalletTotalDTO = new InvLotAttPalletTotalDTO();
+            invLotAttPalletTotalDTO.setLocationId(item.getKey());
+            invLotAttPalletTotalDTO.setSku(item.getValue().stream().map(InvLotLocId::getSku).distinct().collect(Collectors.joining(",")));
+            invLotAttPalletTotalDTO.setOrderNo(String.join(",", orderList));
+            invLotAttPalletTotalDTO.setTotalQty(item.getValue().stream().map(InvLotLocId::getQty).reduce(BigDecimal.ZERO, BigDecimal::add).toString());
+            invLotAttPalletTotalDTO.setPalletNo(invLotAttList.stream().filter(invLotAtt ->
+                    StringUtils.equals(invLotLocId.getLotnum(), invLotAtt.getLotnum())).map(InvLotAtt::getLotatt07).findFirst().orElseGet(() -> null));
+            return invLotAttPalletTotalDTO;
+        }).collect(Collectors.toList());
+        return palletMatchLogService.insertBatch(buildPalletMatchLogList(result, orderList));
+    }
+
     /**
      * 反拣出库
      */
@@ -3160,7 +3198,6 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
         InvLotLocId invLotLocId = invLotLocIdList.stream().findFirst().orElseThrow(() -> new BaseException("库位库存信息丢失!"));
         BigDecimal qtyAllocated = ObjectUtil.isNotNull(invLotLocId.getQtyallocated()) ? invLotLocId.getQtyallocated() : BigDecimal.ZERO;
         BigDecimal invLotLocQty = invLotLocId.getQty().subtract(qtyAllocated);
-        Assert.isTrue(NumberUtil.isGreater(invLotLocQty, BigDecimal.ZERO), "该产品已备货!");
         String asnNo = invLotAttList.stream().filter(item -> item.getLotnum().equals(invLotLocId.getLotnum())).map(InvLotAtt::getLotatt08).findFirst().orElseThrow(() -> new BaseException("此批次入库信息丢失!"));
         String sku = groupDiskConvertDTO.getSku();
         invLotAttService.insertInvLotAtt(buildInvLotAtt(groupDiskConvertDTO.getLotNum(), groupDiskConvertDTO.getPalletTo(), orderNo, groupDiskConvertDTO.getSn(), sku, asnNo));
@@ -3168,7 +3205,8 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
         String locationId = verifyInvLotAndGetLocationId(groupDiskConvertDTO.getPalletTo(), groupDiskConvertDTO.getSn(), orderNo);
         locationId = StringUtils.isNotBlank(locationId) ? locationId : invLotLocId.getLocationId();
         if (CompareUtil.compare(groupDiskConvertDTO.getGroupDiskQty(), invLotLocQty) >= 0) {
-            invLotLocIdService.updateInvLotLocId(invLotLocId.getLotnum(), groupDiskConvertDTO.getLotNum(), invLotLocQty, sku, locationId);
+            invLotLocIdService.updateInvLotLocId(invLotLocId.getLotnum(), groupDiskConvertDTO.getLotNum(),
+                    invLotLocId.getQty(), StringUtils.isNotBlank(orderNo) ? invLotLocId.getQty() : invLotLocId.getQtyallocated(), sku, locationId);
         } else {
             // 拆分库存
             // 修改原库存