Jelajahi Sumber

PDA出库拣货

k 2 tahun lalu
induk
melakukan
b2106d74ff

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

@@ -367,7 +367,13 @@ public class PdaController {
      * @return
      */
     @PostMapping("/docOrder/toPick")
-    public AjaxResult toPick(@RequestBody PickForm pickForm) {
+    public AjaxResult toPick(@Validated @RequestBody PickForm pickForm) {
+        // ERP号转换为wms系统出库单号orderNo
+        String orderNo = wmsDocOrderHeaderService.changeErpNoToOrderNo(pickForm.getOrderNo());
+        pickForm.setOrderNo(orderNo);
+        if (StringUtils.isEmpty(orderNo)) {
+            return AjaxResult.error("请扫描正确的出库单号!");
+        }
         return wmsDocOrderHeaderService.toPick(pickForm);
     }
 

+ 11 - 0
warewms-ams/src/main/java/com/ruoyi/ams/inv/mapper/InvLotLocIdMapper.java

@@ -141,6 +141,17 @@ public interface InvLotLocIdMapper {
      */
     int deleteInvLotLocIdByLocationId(Long locationId);
 
+    /**
+     * 删除库位库存信息
+     *
+     * @param locationId
+     * @param customerId
+     * @param sku
+     * @param lotnum
+     * @return
+     */
+    int deleteInvLotLocIdByPrimaryKey(String locationId, String customerId, String sku, String lotnum);
+
     /**
      * 更新起始库位库存至目标库位
      *

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

@@ -120,6 +120,14 @@ public interface IInvLotLocIdService {
      */
     AjaxResult clear(String locationId, Long warehouseId, String updateBy);
 
+    /**
+     * 清除0库存
+     *
+     * @param locationId
+     * @return
+     */
+    AjaxResult clearZeroInventory(String locationId, String customerId, String sku, String lotnum);
+
     /**
      * 库位任务状态调整
      *
@@ -174,6 +182,14 @@ public interface IInvLotLocIdService {
      */
     int deleteInvLotLocIdById(long locId);
 
+    /**
+     * 删除库位库存信息信息
+     *
+     * @param
+     * @return
+     */
+    int deleteInvLotLocIdById(String locationId, String customerId, String sku, String lotnum);
+
     /**
      * 初始化库存
      *

+ 16 - 0
warewms-ams/src/main/java/com/ruoyi/ams/inv/service/impl/InvLotLocIdServiceImpl.java

@@ -352,6 +352,18 @@ public class InvLotLocIdServiceImpl implements IInvLotLocIdService {
         return AjaxResult.success("操作成功!");
     }
 
+    @Override
+    public AjaxResult clearZeroInventory(String locationId, String customerId, String sku, String lotnum) {
+        InvLotLocId invLotLocId = invLotLocIdService.selectInvLotLocIdById(locationId, customerId, sku, lotnum);
+        if (invLotLocId == null) {
+            return AjaxResult.error();
+        }
+        if (invLotLocId.getQty().compareTo(BigDecimal.ZERO) == 0) {
+            invLotLocIdService.deleteInvLotLocIdByLotnum(null);
+        }
+        return AjaxResult.success();
+    }
+
     @Override
     public AjaxResult adjLocationStockStatus(String locationId, Long warehouseId, String updateBy) {
         Long id; // 库位ID
@@ -466,7 +478,11 @@ public class InvLotLocIdServiceImpl implements IInvLotLocIdService {
     @Override
     public int deleteInvLotLocIdById(long locId) {
         return invLotLocIdMapper.deleteInvLotLocIdByLocationId(locId);
+    }
 
+    @Override
+    public int deleteInvLotLocIdById(String locationId, String customerId, String sku, String lotnum) {
+        return invLotLocIdMapper.deleteInvLotLocIdByPrimaryKey(locationId, customerId, sku, lotnum);
     }
 
     @Transactional

+ 4 - 1
warewms-ams/src/main/java/com/ruoyi/ams/order/form/PickForm.java

@@ -2,12 +2,15 @@ package com.ruoyi.ams.order.form;
 
 import lombok.Data;
 
-import java.util.List;
+import javax.validation.constraints.NotEmpty;
 
 @Data
 public class PickForm {
+    @NotEmpty(message = "出库单号不能为空")
     private String orderNo;
     private String sku;
+    @NotEmpty(message = "条码不能为空")
     private String sn;
+    @NotEmpty(message = "数量不能为空")
     private Double qty;
 }

+ 79 - 38
warewms-ams/src/main/java/com/ruoyi/ams/order/service/impl/WmsDocOrderHeaderServiceImpl.java

@@ -54,6 +54,7 @@ import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
 import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * 出库单头Service业务层处理
@@ -303,7 +304,7 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
         }
         for (InvLotLocId inv : invList) {
             if (orderQty.doubleValue() == 0) {
-                return AjaxResult.success("分配完成",originalOrderQty);
+                return AjaxResult.success("分配完成", originalOrderQty);
             }
             //可以叫料且合格的库存
             InvLotAtt lotAtt = invLotAttMapper.selectInvLotAttByLotnum(inv.getLotnum());
@@ -352,7 +353,7 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
 //                            wmsDocOrderHeaderService.updateWmsDocOrderHeader(header);
                             //生成分配明细
                             actAllocationDetailsService.addActAllocationDetails(inv.getLotnum(), inv.getLocationId(), allocatedQty, details, "20");
-                            return AjaxResult.success("分配完成",originalOrderQty);
+                            return AjaxResult.success("分配完成", originalOrderQty);
                         } else {
                             throw new ServiceException("占用库存分配数失败");
                         }
@@ -370,7 +371,7 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
 //                            wmsDocOrderHeaderService.updateWmsDocOrderHeader(header);
                             //生成分配明细
                             actAllocationDetailsService.addActAllocationDetails(inv.getLotnum(), inv.getLocationId(), currentQty, details, "10");
-                            return AjaxResult.success("分配完成",originalOrderQty);
+                            return AjaxResult.success("分配完成", originalOrderQty);
 
                         } else {
                             throw new ServiceException("占用库存分配数失败");
@@ -379,7 +380,7 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
                 }
             }
         }
-        return AjaxResult.success("库存数不足,部分分配",originalOrderQty.subtract(orderQty));
+        return AjaxResult.success("库存数不足,部分分配", originalOrderQty.subtract(orderQty));
     }
 
     @Override
@@ -400,37 +401,77 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
     @Transactional
     @Override
     public AjaxResult toPick(PickForm pickForm) {
-        List<PickInfoForm> pickInfoFormList = null;
-        Map<String, String> exitsMap = new HashMap<>();
-        for (PickInfoForm p : pickInfoFormList) {
-            String locationTo = p.getLocationTo();
-            //TODO 任务完成后更新 查询对应的分配明细表
-            //TODO 改成按托盘号进行呼叫
-            ActAllocationDetails actAllocationDetails = actAllocationDetailsService.selectActAllocationDetailsByAllocationId(p.getAllocationId());
-            String location = actAllocationDetails.getLocationId().toString();
-            //qty = actAllocationDetails.getPickQty();
-            //actAllocationDetails.setPickQty(actAllocationDetails.getPickQty().add(new BigDecimal(p.getQty())));
-            //actAllocationDetails.setPickToLocation(locationTo);
-            actAllocationDetails.setLocationId(Long.parseLong(locationTo));
-            actAllocationDetailsService.updateActAllocationDetails(actAllocationDetails);
-
-            //更新出库单拣货数量
-            WmsDocOrderDetails wmsDocOrderDetails = wmsDocOrderDetailsMapper.selectWmsDocOrderDetailsByNoLineNo(actAllocationDetails.getOrderNo(), actAllocationDetails.getLineNo());
-            wmsDocOrderDetails.setQtyPicked(wmsDocOrderDetails.getQtyPicked().add(actAllocationDetails.getPickQty()));
-            wmsDocOrderDetails.setQtyPickedEach(wmsDocOrderDetails.getQtyPicked());
-            if (actAllocationDetails.getQty().compareTo(actAllocationDetails.getPickQty()) == 1) {
-                wmsDocOrderDetails.setLineStatus("30");
-            } else {
-                wmsDocOrderDetails.setLineStatus("40");
+        String orderNo = pickForm.getOrderNo();
+        String sn = pickForm.getSn();
+        BigDecimal qty = new BigDecimal(pickForm.getQty()); // 拣货数量
+        // 验证sn
+        CodeSkuRelationshipVO codeSkuRelationshipVO = codeSkuRelationshipService.snCheck(sn);
+        WmsDocOrderHeader docOrderHeader = wmsDocOrderHeaderService.selectWmsDocOrderHeaderByOrderNo(orderNo);
+        // 查询出分配明细
+        ActAllocationDetailsFrom actAllocationQuery = new ActAllocationDetailsFrom();
+        actAllocationQuery.setOrderNo(orderNo);
+        actAllocationQuery.setLotatt02(sn);
+        actAllocationQuery.setStatus(Constant.ORDER_STS.STS20.getValue());
+        List<ActAllocationDetailsFrom> actAllocationDetailsFromList = actAllocationDetailsService.selectActAllocationDetailsInvLotAttList(actAllocationQuery);
+        // 最终确定要拣货的明细
+        ActAllocationDetailsFrom endActAllocation = null;
+        // 相等拣货数量的明细
+        List<ActAllocationDetailsFrom> EqualAllocationList = actAllocationDetailsFromList
+                .stream()
+                .filter(v -> {
+                    BigDecimal canPickNum = v.getQty().subtract(v.getPickQty());
+                    return canPickNum.compareTo(qty) == 1;
+                }).collect(Collectors.toList());
+        // 大于拣货数量的明细
+        List<ActAllocationDetailsFrom> greaterAllocationList = new ArrayList<>();
+        if (EqualAllocationList.size() == 0) {
+            greaterAllocationList = actAllocationDetailsFromList
+                    .stream()
+                    .filter(v -> {
+                        BigDecimal canPickNum = v.getQty().subtract(v.getPickQty());
+                        return canPickNum.compareTo(qty) == 0;
+                    }).collect(Collectors.toList());
+            if (greaterAllocationList.size() > 0) {
+                endActAllocation = greaterAllocationList.get(0);
             }
-            wmsDocOrderDetailsMapper.updateWmsDocOrderDetails(wmsDocOrderDetails);
-
-            //库存进行移动
-            invLotLocIdService.stockTransfer(actAllocationDetails.getLocationId(), "", Long.parseLong(locationTo));
-            //托盘进行绑定修改
-            wmsBoxInfoMapper.updateLocationBind(Long.parseLong(location), Long.parseLong(locationTo), null);
-        }
-        return AjaxResult.success("操作成功");
+        } else {
+            endActAllocation = EqualAllocationList.get(0);
+        }
+        if (endActAllocation == null) {
+            return AjaxResult.error("没有可以拣货的分配明细!");
+        }
+        // 更新分配明细
+        ActAllocationDetails allocationUpdate = new ActAllocationDetails();
+        allocationUpdate.setAllocationId(endActAllocation.getAllocationId());
+        allocationUpdate.setPickQty(endActAllocation.getPickQty().add(qty));
+        allocationUpdate.setStatus(Constant.ORDER_STS.STS30.getValue());
+        if (endActAllocation.getQty().compareTo(allocationUpdate.getPickQty()) == 0) {
+            allocationUpdate.setStatus(Constant.ORDER_STS.STS40.getValue());
+        }
+        actAllocationDetailsService.updateActAllocationDetails(allocationUpdate);
+        // 更新库存数量
+        String lotnum = endActAllocation.getLotnum();
+        Long locationId = endActAllocation.getLocationId();
+        String sku = endActAllocation.getMaterial();
+        String customerId = Constant.CUSTOMER_ID;
+        InvLotLocId invLotLocId = invLotLocIdService.selectInvLotLocIdById(locationId.toString(), customerId, sku, lotnum);
+        invLotLocId.setQty(invLotLocId.getQty().subtract(qty));
+        invLotLocId.setQtyEach(invLotLocId.getQty());
+        invLotLocId.setQtyallocated(invLotLocId.getQtyallocated().subtract(qty));
+        invLotLocId.setQtyallocatedEach(invLotLocId.getQtyallocated());
+        invLotLocIdService.updateInvLotLocId(invLotLocId);
+        // 删除0库存
+        invLotLocIdService.clearZeroInventory(locationId.toString(),customerId,sku,lotnum);
+        // 更新出库单拣货数量
+        WmsDocOrderDetails wmsDocOrderDetails = wmsDocOrderDetailsMapper.selectWmsDocOrderDetailsByNoLineNo(endActAllocation.getOrderNo(), endActAllocation.getLineNo());
+        wmsDocOrderDetails.setQtyPicked(wmsDocOrderDetails.getQtyPicked().add(qty));
+        wmsDocOrderDetails.setQtyPickedEach(wmsDocOrderDetails.getQtyPicked());
+        wmsDocOrderDetails.setLineStatus(Constant.ORDER_STS.STS30.getValue());
+        if (wmsDocOrderDetails.getQtyOrdered().compareTo(wmsDocOrderDetails.getQtyPicked()) == 0) {
+            wmsDocOrderDetails.setLineStatus(Constant.ORDER_STS.STS40.getValue());
+        }
+        wmsDocOrderDetailsMapper.updateWmsDocOrderDetails(wmsDocOrderDetails);
+        return AjaxResult.success("拣货成功");
     }
 
     @Override
@@ -572,7 +613,7 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
             } else {
                 List<InvLotLocIdLotattVO> locIdLotattVOList = lotnumAndInvLocIdMap.get(v.getLotnum());
                 locIdLotattVOList.add(v);
-                lotnumAndInvLocIdMap.put(v.getLotnum(),locIdLotattVOList);
+                lotnumAndInvLocIdMap.put(v.getLotnum(), locIdLotattVOList);
             }
         });
         if (palletNoFrom.equals(palletNoTo) && orderNo.equals("")) {
@@ -581,7 +622,7 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
 
         } else {
             // 根据老Lotnum创建新的Lotnum
-            for (Map.Entry<String, List<InvLotLocIdLotattVO>> lotnumToInvLocId: lotnumAndInvLocIdMap.entrySet()) {
+            for (Map.Entry<String, List<InvLotLocIdLotattVO>> lotnumToInvLocId : lotnumAndInvLocIdMap.entrySet()) {
                 String lotnum = lotnumToInvLocId.getKey();
                 List<InvLotLocIdLotattVO> invLocIdList = lotnumToInvLocId.getValue();
                 InvLotAtt invLotAtt = invLotAttMapper.selectInvLotAttByLotnum(lotnum);
@@ -640,7 +681,7 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
             actAllocationDetails.setPickQty(actAllocationDetails.getPickQty().add(new BigDecimal(arrangeStockForm.getQty())));
             if (actAllocationDetails.getQty().compareTo(actAllocationDetails.getPickQty()) == 1) {
                 actAllocationDetails.setStatus("30");
-            }else {
+            } else {
                 actAllocationDetails.setStatus("40");
             }
             actAllocationDetailsService.updateActAllocationDetails(actAllocationDetails);
@@ -885,7 +926,7 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
             details.setdEdi04(erpOrder.getVaild());         //单据状态
             details.setdEdi05(erpOrder.getStockId());       //仓库编号
             details.setdEdi06(erpOrder.getOrderState());    //是否扫描完成
-            details.setdEdi07(erpOrder.getOrderNo()+"");    //项次
+            details.setdEdi07(erpOrder.getOrderNo() + "");    //项次
             details.setdEdi08(erpOrder.getOrderType());     //erp单据类型
             details.setdEdi09(erpOrder.getInout());         //erp出入库类型
             details.setLineStatus("00");

+ 8 - 0
warewms-ams/src/main/resources/mapper/ams/InvLotLocIdMapper.xml

@@ -377,6 +377,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         delete from inv_lot_loc_id where location_id = #{locationId}
     </delete>
 
+    <delete id="deleteInvLotLocIdByPrimaryKey" parameterType="Long">
+        delete from inv_lot_loc_id
+        where lotnum = #{lotnum}
+          and location_id = #{locationId}
+          and customer_id = #{customerId}
+          and sku = #{sku}
+    </delete>
+
     <update id="updateInvLotLocIdLocationId">
         update inv_lot_loc_id set location_id = #{locationTo}
         where location_id = #{locationFrom}

+ 56 - 0
warewms-base/src/main/java/com/ruoyi/base/constant/Constant.java

@@ -50,6 +50,62 @@ public class Constant {
         }
     }
 
+    /**
+     * 入库单据类型
+     */
+    public enum ASN_TYP {
+        /**
+         * 正常入库
+         */
+        ZC("ZC"),
+        /**
+         * 采购入库
+         */
+        PR("PR"),
+        /**
+         * 其他入库
+         */
+        OT("OT");
+
+        private String value;
+
+        ASN_TYP(String value) {
+            this.value = value;
+        }
+
+        public String getValue() {
+            return value;
+        }
+    }
+
+    /**
+     * 出库单据类型
+     */
+    public enum ORDER_TYP {
+        /**
+         * 正常出库
+         */
+        ZC("ZC"),
+        /**
+         * 备货
+         */
+        BH("BH"),
+        /**
+         * 库内理货
+         */
+        LH("LH");
+
+        private String value;
+
+        ORDER_TYP(String value) {
+            this.value = value;
+        }
+
+        public String getValue() {
+            return value;
+        }
+    }
+
     /**
      * 入库单状态
      */