Sfoglia il codice sorgente

拣货分配修改

andy 2 anni fa
parent
commit
d146382ba6
26 ha cambiato i file con 553 aggiunte e 335 eliminazioni
  1. 29 4
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/warewms/pda/PdaController.java
  2. 9 7
      ruoyi-admin/src/test/java/com/ruoyi/admin/test/base/WarehouseTest.java
  3. 1 1
      ruoyi-ui/src/views/wms/box/index.vue
  4. 1 0
      ruoyi-ui/src/views/wms/docOrder/index.vue
  5. 1 1
      warewms-ams/src/main/java/com/ruoyi/ams/asn/form/StockForm.java
  6. 84 139
      warewms-ams/src/main/java/com/ruoyi/ams/asn/service/impl/WmsDocAsnHeaderServiceImpl.java
  7. 9 0
      warewms-ams/src/main/java/com/ruoyi/ams/box/form/AddBoxForm.java
  8. 14 0
      warewms-ams/src/main/java/com/ruoyi/ams/box/mapper/WmsBoxInfoMapper.java
  9. 26 9
      warewms-ams/src/main/java/com/ruoyi/ams/box/service/IWmsBoxInfoService.java
  10. 46 17
      warewms-ams/src/main/java/com/ruoyi/ams/box/service/impl/WmsBoxInfoServiceImpl.java
  11. 21 1
      warewms-ams/src/main/java/com/ruoyi/ams/inv/mapper/InvLotLocIdMapper.java
  12. 9 0
      warewms-ams/src/main/java/com/ruoyi/ams/inv/service/IInvLotLocIdService.java
  13. 43 9
      warewms-ams/src/main/java/com/ruoyi/ams/inv/service/impl/InvLotLocIdServiceImpl.java
  14. 14 0
      warewms-ams/src/main/java/com/ruoyi/ams/order/form/ArrangeStockForm.java
  15. 5 3
      warewms-ams/src/main/java/com/ruoyi/ams/order/form/PickForm.java
  16. 9 0
      warewms-ams/src/main/java/com/ruoyi/ams/order/form/PickInfoForm.java
  17. 10 2
      warewms-ams/src/main/java/com/ruoyi/ams/order/service/IWmsDocOrderHeaderService.java
  18. 11 2
      warewms-ams/src/main/java/com/ruoyi/ams/order/service/impl/ActAllocationDetailsServiceImpl.java
  19. 131 110
      warewms-ams/src/main/java/com/ruoyi/ams/order/service/impl/WmsDocOrderHeaderServiceImpl.java
  20. 16 1
      warewms-ams/src/main/resources/mapper/ams/InvLotLocIdMapper.xml
  21. 10 0
      warewms-ams/src/main/resources/mapper/box/WmsBoxInfoMapper.xml
  22. 1 0
      warewms-base/src/main/java/com/ruoyi/base/domain/vo/CodeSkuRelationshipVO.java
  23. 1 1
      warewms-base/src/main/java/com/ruoyi/base/mapper/CodeSkuRelationshipMapper.java
  24. 26 16
      warewms-base/src/main/java/com/ruoyi/base/service/ICodeSkuRelationshipService.java
  25. 25 4
      warewms-base/src/main/java/com/ruoyi/base/service/impl/CodeSkuRelationshipServiceImpl.java
  26. 1 8
      warewms-base/src/main/resources/mapper/base/CodeSkuRelationshipMapper.xml

+ 29 - 4
ruoyi-admin/src/main/java/com/ruoyi/web/controller/warewms/pda/PdaController.java

@@ -9,6 +9,8 @@ import com.ruoyi.ams.asn.form.StockingListForm;
 import com.ruoyi.ams.asn.form.UnlockForm;
 import com.ruoyi.ams.asn.service.IWmsDocAsnHeaderService;
 import com.ruoyi.ams.asn.vo.SearchStockVO;
+import com.ruoyi.ams.box.form.AddBoxForm;
+import com.ruoyi.ams.box.service.IWmsBoxInfoService;
 import com.ruoyi.ams.business.IBusinessService;
 import com.ruoyi.ams.common.vo.DictVO;
 import com.ruoyi.ams.config.domain.FlowConfigHeader;
@@ -25,6 +27,7 @@ import com.ruoyi.ams.lineCall.domain.form.LineCallListFrom;
 import com.ruoyi.ams.lineCall.domain.vo.LineCallVO;
 import com.ruoyi.ams.lineCall.service.ILineCallService;
 import com.ruoyi.ams.order.domain.ActAllocationDetails;
+import com.ruoyi.ams.order.form.ArrangeStockForm;
 import com.ruoyi.ams.order.form.CheckOutForm;
 import com.ruoyi.ams.order.form.PickForm;
 import com.ruoyi.ams.order.service.IActAllocationDetailsService;
@@ -76,6 +79,8 @@ public class PdaController {
     private IBusinessService businessService;
     @Autowired
     private IFlowConfigHeaderService flowConfigHeaderService;
+    @Autowired
+    private IWmsBoxInfoService wmsBoxInfoService;
 
     /**
      * 查询批次属性后台配置
@@ -325,14 +330,34 @@ public class PdaController {
     }
 
     /**
-     * 分拣更新分拣
+     * 呼叫拣货
      *
      * @param pickForm
      * @return
      */
-    @PostMapping("/docOrder/pick")
-    public AjaxResult doPick(@RequestBody PickForm pickForm) {
-        return wmsDocOrderHeaderService.doPick(pickForm);
+    @PostMapping("/docOrder/toPick")
+    public AjaxResult toPick(@RequestBody PickForm pickForm) {
+        return wmsDocOrderHeaderService.toPick(pickForm);
     }
 
+
+    /**
+     * 拣货组盘(理货)
+     *
+     * @return
+     */
+    @PostMapping("/docOrder/arrangeStock")
+    public AjaxResult arrangeStock(@RequestBody ArrangeStockForm arrangeStockForm) {
+        return wmsDocOrderHeaderService.arrangeStock(arrangeStockForm);
+    }
+
+    /**
+     * 初始化托盘
+     *
+     * @return
+     */
+    @PostMapping("/boxInfo/placeBox")
+    public AjaxResult placeBox(@RequestBody AddBoxForm addBoxForm) {
+        return wmsBoxInfoService.addBoxInfo(addBoxForm);
+    }
 }

+ 9 - 7
ruoyi-admin/src/test/java/com/ruoyi/admin/test/base/WarehouseTest.java

@@ -206,13 +206,14 @@ public class WarehouseTest {
         header.setCreateBy("warewms");
         header.setCustomerId("default");
         List<WmsDocAsnDetails> detailsList = new ArrayList<>();
-        String[] arr = new String[]{"test201", "test202", "test301", "test302", "test401", "test402"};
-        for (int i = 1; i < 5; i++) {
+        //String[] arr = new String[]{"test201", "test202", "test301", "test302", "test401", "test402"};
+        String[] arr = new String[]{"test201", "test203"};
+        for (int i = 1; i <= arr.length; i++) {
             WmsDocAsnDetails details = new WmsDocAsnDetails();
             details.setAsnNo(asnNo);
             details.setAsnLineNo(Long.valueOf(i));
             details.setSku(arr[i - 1]);
-            details.setExpectedQty(BigDecimal.valueOf(i * 10));
+            details.setExpectedQty(BigDecimal.valueOf(15));
             details.setExpectedQtyEach(details.getExpectedQty());
             details.setReceivedQty(BigDecimal.ZERO);
             details.setReceivedQtyEach(BigDecimal.ZERO);
@@ -241,14 +242,15 @@ public class WarehouseTest {
         header.setCreateBy("warewms");
         header.setCustomerId("default");
         List<WmsDocOrderDetails> detailsList = new ArrayList<>();
-        String[] arr = new String[]{"test201", "test202", "test301", "test302", "test401", "test402"};
-        for (int i = 1; i < 5; i++) {
+        //String[] arr = new String[]{"test201", "test202", "test301", "test302", "test401", "test402"};
+        String[] arr = new String[]{"test201", "test203"};
+        for (int i = 1; i <= arr.length; i++) {
             WmsDocOrderDetails details = new WmsDocOrderDetails();
             details.setOrderNo(soNo);
             details.setCustomerId(Constant.CUSTOMER_ID);
             details.setOrderLineNo(BigDecimal.valueOf(i));
             details.setSku(arr[i - 1]);
-            details.setQtyOrdered(BigDecimal.valueOf(i * 10));
+            details.setQtyOrdered(BigDecimal.valueOf(10));
             details.setQtyOrderedEach(details.getQtyOrdered());
             details.setQtyPicked(BigDecimal.ZERO);
             details.setQtyPickedEach(BigDecimal.ZERO);
@@ -271,7 +273,7 @@ public class WarehouseTest {
 
     @Test
     public void querySameTypeByPalletNo() {
-        List<InvLotLocId> invLotLocIdList = invLotLocIdMapper.querySameTypeByPalletNo("2","B1001");
+        List<InvLotLocId> invLotLocIdList = invLotLocIdMapper.querySameTypeByPalletNo("2", "B1001");
         System.out.println(JSON.toJSONString(invLotLocIdList));
     }
 

+ 1 - 1
ruoyi-ui/src/views/wms/box/index.vue

@@ -156,7 +156,7 @@
         </template>
       </el-table-column>
     </el-table>
-    
+
     <pagination
       v-show="total>0"
       :total="total"

+ 1 - 0
ruoyi-ui/src/views/wms/docOrder/index.vue

@@ -134,6 +134,7 @@
             size="mini"
             type="text"
             icon="el-icon-edit"
+            v-if="scope.row.orderStatus === '00' || scope.row.orderStatus === '10'"
             @click="doAllocation(scope.row)"
             v-hasPermi="['docOrder:docOrder:edit']"
           >分配</el-button>

+ 1 - 1
warewms-ams/src/main/java/com/ruoyi/ams/asn/form/StockForm.java

@@ -21,7 +21,7 @@ public class StockForm {
     //托盘编号
     private String palletNo;
     private String skuSn;
-    private String sku;
+    //private String sku;
     private String desc;
     private String model;
     private String qty;

+ 84 - 139
warewms-ams/src/main/java/com/ruoyi/ams/asn/service/impl/WmsDocAsnHeaderServiceImpl.java

@@ -29,7 +29,9 @@ import com.ruoyi.ams.order.service.IWmsDocOrderDetailsService;
 import com.ruoyi.ams.order.service.IWmsDocOrderHeaderService;
 import com.ruoyi.base.constant.Constant;
 import com.ruoyi.base.domain.BaseSku;
+import com.ruoyi.base.domain.vo.CodeSkuRelationshipVO;
 import com.ruoyi.base.service.IBaseSkuService;
+import com.ruoyi.base.service.ICodeSkuRelationshipService;
 import com.ruoyi.base.utils.IdSequenceUtils;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.core.domain.model.LoginUser;
@@ -81,6 +83,8 @@ public class WmsDocAsnHeaderServiceImpl implements IWmsDocAsnHeaderService {
     private InvLotLocIdMapper invLotLocIdMapper;
     @Autowired
     private IActAllocationDetailsService actAllocationDetailsService;
+    @Autowired
+    private ICodeSkuRelationshipService codeSkuRelationshipService;
 
     /**
      * 查询入库单
@@ -245,13 +249,46 @@ public class WmsDocAsnHeaderServiceImpl implements IWmsDocAsnHeaderService {
         String STAGE01 = "900";
         BigDecimal totalQty = new BigDecimal(stockForm.getQty());
         WmsDocOrderHeader wmsDocOrderHeader;
-        List<WmsDocOrderDetails> orderDetails;
+        List<WmsDocOrderDetails> orderDetails = new ArrayList<>();
         Map<String, List<WmsDocOrderDTO>> orderMap = new HashMap<>();
 
+        //查询托盘是否存在,生成托盘绑定信息
+        WmsBoxInfo wmsBoxInfo = new WmsBoxInfo();
+        wmsBoxInfo.setBoxNo(stockForm.getPalletNo());
+        wmsBoxInfo = boxInfoService.selectWmsBoxInfoByModel(wmsBoxInfo);
+        if (wmsBoxInfo == null) {
+            //不存在则创建托盘信息
+            wmsBoxInfo = new WmsBoxInfo();
+            wmsBoxInfo.setBoxNo(stockForm.getPalletNo());
+            wmsBoxInfo.setBoxState(1);
+            wmsBoxInfo.setBoxType("pallet");
+            wmsBoxInfo.setIsFull(stockForm.getFullTag());
+            wmsBoxInfo.setCreateBy(loginUser.getUsername());
+            wmsBoxInfo.setCreateTime(new Date());
+            wmsBoxInfo.setUpdateBy(loginUser.getUsername());
+            wmsBoxInfo.setUpdateTime(new Date());
+            boxInfoService.insertWmsBoxInfo(wmsBoxInfo);
+        } else {
+            //判断已满拖的话不接收
+            if (wmsBoxInfo.getIsFull().equals("Y")) {
+                throw new ServiceException("该托盘已放满");
+            }
+            wmsBoxInfo.setBoxState(1);
+            wmsBoxInfo.setIsFull(stockForm.getFullTag());
+            wmsBoxInfo.setLocationId(Long.parseLong(STAGE01));
+            wmsBoxInfo.setUpdateBy(loginUser.getUsername());
+            wmsBoxInfo.setUpdateTime(new Date());
+            boxInfoService.updateWmsBoxInfo(wmsBoxInfo);
+        }
+
+        //判断成品条码
+        CodeSkuRelationshipVO codeSkuRelationshipVO = codeSkuRelationshipService.checkIsProduct(stockForm.getSkuSn());
+
         //产品条码属于出入库单
         if (stockForm.getStockTag().equals("Y") && StringUtils.isEmpty(stockForm.getOrderNo())) {
             return AjaxResult.error("备货必须选择出库单号");
-        } else {
+        }
+        if (stockForm.getStockTag().equals("Y")) {
             //查询出库单
             wmsDocOrderHeader = wmsDocOrderHeaderService.selectWmsDocOrderHeaderByOrderNo(stockForm.getOrderNo());
             if (wmsDocOrderHeader == null) {
@@ -261,58 +298,63 @@ public class WmsDocAsnHeaderServiceImpl implements IWmsDocAsnHeaderService {
                 return AjaxResult.error("出库单已完成");
             }
             orderDetails = wmsDocOrderHeader.getWmsDocOrderDetailsList();
-        }
-        //匹配出库单
-        BigDecimal orderQty = BigDecimal.ZERO;
-        for (WmsDocOrderDetails de : orderDetails) {
-            if (!de.getSku().equals(stockForm.getSku())) {
-                continue;
-            }
-            if (de.getQtyOrdered().compareTo(de.getQtyAllocated()) == 1) {
-                BigDecimal current = de.getQtyOrdered().subtract(de.getQtyAllocated());
-                orderQty = orderQty.add(current);
-                List<WmsDocOrderDTO> list = orderMap.get(de.getSku());
-                if (list == null) {
-                    list = new ArrayList<>();
+
+            //匹配出库单
+            BigDecimal orderQty = BigDecimal.ZERO;
+            for (WmsDocOrderDetails de : orderDetails) {
+                if (!de.getSku().equals(codeSkuRelationshipVO.getSku())) {
+                    continue;
                 }
-                WmsDocOrderDTO orderDTO = new WmsDocOrderDTO();
-                orderDTO.setOrderNo(de.getOrderNo());
-                orderDTO.setOrderLineNo(de.getOrderLineNo().longValue());
-                orderDTO.setQty(current);
-                list.add(orderDTO);
-                orderMap.put(de.getSku(), list);
-                if (orderQty.compareTo(totalQty) == 0) {
-                    break;
+                if (de.getQtyOrdered().compareTo(de.getQtyAllocated()) == 1) {
+                    BigDecimal current = de.getQtyOrdered().subtract(de.getQtyAllocated());
+                    orderQty = orderQty.add(current);
+                    List<WmsDocOrderDTO> list = orderMap.get(de.getSku());
+                    if (list == null) {
+                        list = new ArrayList<>();
+                    }
+                    WmsDocOrderDTO orderDTO = new WmsDocOrderDTO();
+                    orderDTO.setOrderNo(de.getOrderNo());
+                    orderDTO.setOrderLineNo(de.getOrderLineNo().longValue());
+                    orderDTO.setQty(current);
+                    list.add(orderDTO);
+                    orderMap.put(de.getSku(), list);
+                    if (orderQty.compareTo(totalQty) == 0) {
+                        break;
+                    }
                 }
             }
-        }
 
-        if (stockForm.getStockTag().equals("Y")) {
             if (orderQty.compareTo(BigDecimal.ZERO) != 1 || orderQty.compareTo(new BigDecimal(stockForm.getQty())) == -1) {
                 return AjaxResult.error("接收数超出出货单需求数量");
             }
         }
 
-        //判断成品条码
-        InvLotAtt queryAtt = new InvLotAtt();
-        queryAtt.setSku(stockForm.getSku());
-        queryAtt.setLotatt02(stockForm.getSkuSn());
-        List<InvLotLocId> invList = invLotLocIdService.queryInvByInvLotatt(queryAtt, stockForm.getPalletNo());
-        if (invList != null && invList.size() > 1) {
-            throw new ServiceException("每个成品条码只允许码一次");
-        }
+        if (codeSkuRelationshipVO.isProduct()) {
+            stockForm.setQty("1");
 
-        if (checkSameTypeByPalletNo(stockForm.getPalletNo(), stockForm.getSku()) == false) {
-            throw new ServiceException("不同的产品分类不允许放一个托盘上");
+            InvLotAtt queryAtt = new InvLotAtt();
+            queryAtt.setSku(codeSkuRelationshipVO.getSku());
+            queryAtt.setLotatt02(stockForm.getSkuSn());
+            List<InvLotLocId> invList = invLotLocIdService.queryInvByInvLotatt(queryAtt, stockForm.getPalletNo());
+            if (invList != null && invList.size() > 1) {
+                throw new ServiceException("每个成品条码只允许码一次");
+            }
+
+            if (checkSameTypeByPalletNo(stockForm.getPalletNo(), codeSkuRelationshipVO.getSku()) == false) {
+                throw new ServiceException("不同的产品分类不允许放一个托盘上");
+            }
         }
 
         //匹配对应的入库单,出库单
         if (stockForm.getAsnNo() != null && stockForm.getAsnNo().size() > 0) {
-            List<WmsDocAsnDetails> list = wmsDocAsnDetailsMapper.selectDetailsListByAsnNos(stockForm.getAsnNo(), stockForm.getSku());
+            List<WmsDocAsnDetails> list = wmsDocAsnDetailsMapper.selectDetailsListByAsnNos(stockForm.getAsnNo(), codeSkuRelationshipVO.getSku());
             if (list == null || list.size() == 0) {
                 return AjaxResult.error("没有可以接收的入库单");
             } else {
                 for (WmsDocAsnDetails details : list) {
+                    if (new BigDecimal(stockForm.getQty()).compareTo(details.getExpectedQty()) == 1) {
+                        throw new ServiceException("入库数量超出入库单数量");
+                    }
                     //如果入库单预计数量大于接收数
                     if (details.getExpectedQty().compareTo(details.getReceivedQty()) == 1) {
                         //当前入库单可以接收的数量
@@ -367,85 +409,10 @@ public class WmsDocAsnHeaderServiceImpl implements IWmsDocAsnHeaderService {
                             lotattDTO.setLotatt05("90");
                             lotattDTO.setLotatt07(stockForm.getPalletNo());
                             lotattDTO.setLotatt08(details.getAsnNo());
-                            lotattDTO.setLotatt12("N");
+                            lotattDTO.setLotatt12("Y");
                             lotattDTO.setLotatt13(DateUtils.dateTimeNow(DateUtils.YYYY_MM_DD));
                             lotattDTO.setLotatt14(stockForm.getOrderNo());
-                            String lotnum = invLotLocIdService.initInv(STAGE01, stockForm.getSku(), Constant.CUSTOMER_ID, current.doubleValue(), lotattDTO, current);
-
-                            //更新出库单备货数量
-                            List<WmsDocOrderDTO> odList = orderMap.get(details.getSku());
-                            BigDecimal orderCurrent = current;//当前需要扣减的数量
-                            for (WmsDocOrderDTO dto : odList) {
-                                BigDecimal subQty;
-                                String soStatus;
-                                //如果当前订单需要的数量大于扣减数,那么就加上所有扣减数
-                                if (dto.getQty().compareTo(orderCurrent) == 1) {
-                                    soStatus = "10";
-                                    subQty = orderCurrent;
-                                    wmsDocOrderHeaderService.updateOrderDetailsStock(dto.getOrderNo(), dto.getOrderLineNo().longValue(), orderCurrent.doubleValue(), soStatus);
-
-                                    //TODO 修改头单状态
-                                    WmsDocOrderHeader odHeaderUpdate = new WmsDocOrderHeader();
-                                    odHeaderUpdate.setOrderNo(dto.getOrderNo());
-                                    odHeaderUpdate.setOrderStatus(soStatus);
-                                    odHeaderUpdate.setUpdateBy(loginUser.getUsername());
-                                    odHeaderUpdate.setUpdateTime(new Date());
-                                    wmsDocOrderHeaderService.updateWmsDocOrderHeader(odHeaderUpdate);
-
-                                    //记录分配明细(由于是初始化的库存所以只绑定到对应的托盘)
-                                    ActAllocationDetails actAllocationDetails = new ActAllocationDetails();
-                                    actAllocationDetails.setAllocationId(SnowflakeIdWorker.generateId().toString());
-                                    actAllocationDetails.setLineNo(dto.getOrderLineNo());
-                                    actAllocationDetails.setOrderNo(dto.getOrderNo());
-                                    actAllocationDetails.setQty(subQty);
-                                    actAllocationDetails.setPickQty(BigDecimal.ZERO);
-                                    actAllocationDetails.setMaterial(details.getSku());
-                                    actAllocationDetails.setStatus("00");
-                                    actAllocationDetails.setLotnum(lotnum);
-                                    actAllocationDetails.setUserdefine1(stockForm.getPalletNo());
-                                    actAllocationDetails.setCreateBy(loginUser.getUsername());
-                                    actAllocationDetails.setCreateTime(new Date());
-                                    actAllocationDetails.setUpdateBy(loginUser.getUsername());
-                                    actAllocationDetails.setUpdateTime(new Date());
-                                    actAllocationDetailsService.addOrUpdateAllocationDetails(actAllocationDetails);
-
-                                    break;
-                                } else {
-                                    //如果当前订单需求数量小于扣减数那么循环对下一个订单继续扣减
-                                    soStatus = "20";
-                                    subQty = dto.getQty();
-                                    orderCurrent = orderCurrent.subtract(dto.getQty());
-                                    wmsDocOrderHeaderService.updateOrderDetailsStock(dto.getOrderNo(), dto.getOrderLineNo().longValue(), dto.getQty().doubleValue(), soStatus);
-
-                                    //TODO 修改头单状态
-                                    WmsDocOrderHeader odHeaderUpdate = new WmsDocOrderHeader();
-                                    odHeaderUpdate.setOrderNo(dto.getOrderNo());
-                                    odHeaderUpdate.setOrderStatus(soStatus);
-                                    odHeaderUpdate.setCreateBy(loginUser.getUsername());
-                                    odHeaderUpdate.setCreateTime(new Date());
-                                    odHeaderUpdate.setUpdateBy(loginUser.getUsername());
-                                    odHeaderUpdate.setUpdateTime(new Date());
-                                    wmsDocOrderHeaderService.updateWmsDocOrderHeader(odHeaderUpdate);
-
-                                    //记录分配明细(由于是初始化的库存所以只绑定到对应的托盘)
-                                    ActAllocationDetails actAllocationDetails = new ActAllocationDetails();
-                                    actAllocationDetails.setAllocationId(SnowflakeIdWorker.generateId().toString());
-                                    actAllocationDetails.setLineNo(dto.getOrderLineNo());
-                                    actAllocationDetails.setOrderNo(dto.getOrderNo());
-                                    actAllocationDetails.setQty(subQty);
-                                    actAllocationDetails.setPickQty(BigDecimal.ZERO);
-                                    actAllocationDetails.setMaterial(details.getSku());
-                                    actAllocationDetails.setStatus("00");
-                                    actAllocationDetails.setLotnum(lotnum);
-                                    actAllocationDetails.setUserdefine1(stockForm.getPalletNo());
-                                    actAllocationDetails.setCreateBy(loginUser.getUsername());
-                                    actAllocationDetails.setCreateTime(new Date());
-                                    actAllocationDetails.setUpdateBy(loginUser.getUsername());
-                                    actAllocationDetails.setUpdateTime(new Date());
-                                    actAllocationDetailsService.addOrUpdateAllocationDetails(actAllocationDetails);
-                                }
-                            }
-                            totalQty = totalQty.subtract(current);
+                            String lotnum = invLotLocIdService.initInv(STAGE01, codeSkuRelationshipVO.getSku(), Constant.CUSTOMER_ID, current.doubleValue(), lotattDTO, BigDecimal.ZERO);
                         } else {
                             break;
                         }
@@ -453,31 +420,6 @@ public class WmsDocAsnHeaderServiceImpl implements IWmsDocAsnHeaderService {
                 }
             }
         }
-
-        //查询托盘是否存在,生成托盘绑定信息
-        WmsBoxInfo wmsBoxInfo = new WmsBoxInfo();
-        wmsBoxInfo.setBoxNo(stockForm.getPalletNo());
-        wmsBoxInfo = boxInfoService.selectWmsBoxInfoByModel(wmsBoxInfo);
-        if (wmsBoxInfo == null) {
-            //不存在则创建托盘信息
-            wmsBoxInfo = new WmsBoxInfo();
-            wmsBoxInfo.setBoxNo(stockForm.getPalletNo());
-            wmsBoxInfo.setBoxState(1);
-            wmsBoxInfo.setBoxType("pallet");
-            wmsBoxInfo.setIsFull(stockForm.getFullTag());
-            wmsBoxInfo.setCreateBy(loginUser.getUsername());
-            wmsBoxInfo.setCreateTime(new Date());
-            wmsBoxInfo.setUpdateBy(loginUser.getUsername());
-            wmsBoxInfo.setUpdateTime(new Date());
-            boxInfoService.insertWmsBoxInfo(wmsBoxInfo);
-        } else {
-            wmsBoxInfo.setBoxState(1);
-            wmsBoxInfo.setIsFull(stockForm.getFullTag());
-            wmsBoxInfo.setLocationId(Long.parseLong(STAGE01));
-            wmsBoxInfo.setUpdateBy(loginUser.getUsername());
-            wmsBoxInfo.setUpdateTime(new Date());
-            boxInfoService.updateWmsBoxInfo(wmsBoxInfo);
-        }
         return AjaxResult.success("操作成功");
     }
 
@@ -502,7 +444,8 @@ public class WmsDocAsnHeaderServiceImpl implements IWmsDocAsnHeaderService {
                 lotatt08 = invLotAtt.getLotatt08();
             }
             //更新托盘库存到起始库位
-            invLotLocIdMapper.updateInvLotLocIdLocationId(Long.parseLong(inv.getLocationId()), Long.parseLong(paForm.getLocationTo()));
+            //invLotLocIdMapper.updateInvLotLocIdLocationId(Long.parseLong(inv.getLocationId()), Long.parseLong(paForm.getLocationTo()));
+            invLotLocIdMapper.updateInvLotLocIdToByLotnum(inv.getLotnum(), Long.parseLong(paForm.getLocationTo()));
         }
 
         wmsBoxInfo.setLocationId(Long.parseLong(paForm.getLocationTo()));
@@ -584,6 +527,8 @@ public class WmsDocAsnHeaderServiceImpl implements IWmsDocAsnHeaderService {
         allQuery.setUserdefine1(unlockForm.getPalletNo());
         List<ActAllocationDetails> allocationDetails = actAllocationDetailsService.selectActAllocationDetailsList(allQuery);
         for (ActAllocationDetails actAllocationDetails : allocationDetails) {
+            //删除分配表
+            actAllocationDetailsService.deleteActAllocationDetailsByAllocationId(actAllocationDetails.getAllocationId());
             wmsDocOrderDetailsMapper.updateOrderDetailsStock(actAllocationDetails.getOrderNo(), actAllocationDetails.getLineNo(), (-1 * actAllocationDetails.getQty().doubleValue()), "00");
         }
         return AjaxResult.success("解绑成功");

+ 9 - 0
warewms-ams/src/main/java/com/ruoyi/ams/box/form/AddBoxForm.java

@@ -0,0 +1,9 @@
+package com.ruoyi.ams.box.form;
+
+import lombok.Data;
+
+@Data
+public class AddBoxForm {
+    private String boxNo;
+    private String locationId;
+}

+ 14 - 0
warewms-ams/src/main/java/com/ruoyi/ams/box/mapper/WmsBoxInfoMapper.java

@@ -75,4 +75,18 @@ public interface WmsBoxInfoMapper
      * @return
      */
      int unbindBox(@Param("locationId")String locationId);
+
+    /**
+     * 根据编号查询托盘
+     * @param boxNo
+     * @return
+     */
+     WmsBoxInfo selectWmsBoxInfoByBoxNo(@Param("boxNo")String boxNo);
+
+    /**
+     * 根据库位id查询托盘信息
+     * @param locationId
+     * @return
+     */
+     WmsBoxInfo selectByLocationId(@Param("locationId")String locationId);
 }

+ 26 - 9
warewms-ams/src/main/java/com/ruoyi/ams/box/service/IWmsBoxInfoService.java

@@ -1,7 +1,10 @@
 package com.ruoyi.ams.box.service;
 
 import java.util.List;
+
 import com.ruoyi.ams.box.domain.WmsBoxInfo;
+import com.ruoyi.ams.box.form.AddBoxForm;
+import com.ruoyi.common.core.domain.AjaxResult;
 
 /**
  * 容器管理Service接口
@@ -9,15 +12,14 @@ import com.ruoyi.ams.box.domain.WmsBoxInfo;
  * @author ruoyi
  * @date 2022-11-01
  */
-public interface IWmsBoxInfoService
-{
+public interface IWmsBoxInfoService {
     /**
      * 查询容器管理
      *
      * @param id 容器管理主键
      * @return 容器管理
      */
-     WmsBoxInfo selectWmsBoxInfoById(Long id);
+    WmsBoxInfo selectWmsBoxInfoById(Long id);
 
     /**
      * 查询容器管理列表
@@ -25,14 +27,15 @@ public interface IWmsBoxInfoService
      * @param wmsBoxInfo 容器管理
      * @return 容器管理集合
      */
-     List<WmsBoxInfo> selectWmsBoxInfoList(WmsBoxInfo wmsBoxInfo);
+    List<WmsBoxInfo> selectWmsBoxInfoList(WmsBoxInfo wmsBoxInfo);
 
     /**
      * 查询容器管理(根据boxNo)
+     *
      * @param boxNo
      * @return
      */
-     WmsBoxInfo selectWmsBoxInfoByBoxNo(String boxNo);
+    WmsBoxInfo selectWmsBoxInfoByBoxNo(String boxNo);
 
     /**
      * 查询容器管理
@@ -48,7 +51,7 @@ public interface IWmsBoxInfoService
      * @param wmsBoxInfo 容器管理
      * @return 结果
      */
-     int insertWmsBoxInfo(WmsBoxInfo wmsBoxInfo);
+    int insertWmsBoxInfo(WmsBoxInfo wmsBoxInfo);
 
     /**
      * 修改容器管理
@@ -56,7 +59,7 @@ public interface IWmsBoxInfoService
      * @param wmsBoxInfo 容器管理
      * @return 结果
      */
-     int updateWmsBoxInfo(WmsBoxInfo wmsBoxInfo);
+    int updateWmsBoxInfo(WmsBoxInfo wmsBoxInfo);
 
     /**
      * 批量删除容器管理
@@ -64,7 +67,7 @@ public interface IWmsBoxInfoService
      * @param ids 需要删除的容器管理主键集合
      * @return 结果
      */
-     int deleteWmsBoxInfoByIds(Long[] ids);
+    int deleteWmsBoxInfoByIds(Long[] ids);
 
     /**
      * 删除容器管理信息
@@ -72,5 +75,19 @@ public interface IWmsBoxInfoService
      * @param id 容器管理主键
      * @return 结果
      */
-     int deleteWmsBoxInfoById(Long id);
+    int deleteWmsBoxInfoById(Long id);
+
+    /**
+     * 初始化一个托盘
+     * @param addBoxForm
+     * @return
+     */
+    AjaxResult addBoxInfo(AddBoxForm addBoxForm);
+
+    /**
+     * 根据库位id查询托盘
+     * @param locationId
+     * @return
+     */
+    WmsBoxInfo selectByLocationId(String locationId);
 }

+ 46 - 17
warewms-ams/src/main/java/com/ruoyi/ams/box/service/impl/WmsBoxInfoServiceImpl.java

@@ -1,7 +1,12 @@
 package com.ruoyi.ams.box.service.impl;
 
 import java.util.List;
+
+import com.ruoyi.ams.box.form.AddBoxForm;
+import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.common.utils.StringUtils;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.ruoyi.ams.box.mapper.WmsBoxInfoMapper;
@@ -15,8 +20,7 @@ import com.ruoyi.ams.box.service.IWmsBoxInfoService;
  * @date 2022-11-01
  */
 @Service
-public class WmsBoxInfoServiceImpl implements IWmsBoxInfoService
-{
+public class WmsBoxInfoServiceImpl implements IWmsBoxInfoService {
     @Autowired
     private WmsBoxInfoMapper wmsBoxInfoMapper;
 
@@ -27,8 +31,7 @@ public class WmsBoxInfoServiceImpl implements IWmsBoxInfoService
      * @return 容器管理
      */
     @Override
-    public WmsBoxInfo selectWmsBoxInfoById(Long id)
-    {
+    public WmsBoxInfo selectWmsBoxInfoById(Long id) {
         return wmsBoxInfoMapper.selectWmsBoxInfoById(id);
     }
 
@@ -39,8 +42,7 @@ public class WmsBoxInfoServiceImpl implements IWmsBoxInfoService
      * @return 容器管理
      */
     @Override
-    public List<WmsBoxInfo> selectWmsBoxInfoList(WmsBoxInfo wmsBoxInfo)
-    {
+    public List<WmsBoxInfo> selectWmsBoxInfoList(WmsBoxInfo wmsBoxInfo) {
         return wmsBoxInfoMapper.selectWmsBoxInfoList(wmsBoxInfo);
     }
 
@@ -62,10 +64,9 @@ public class WmsBoxInfoServiceImpl implements IWmsBoxInfoService
      * @return 容器管理
      */
     @Override
-    public WmsBoxInfo selectWmsBoxInfoByModel(WmsBoxInfo wmsBoxInfo)
-    {
+    public WmsBoxInfo selectWmsBoxInfoByModel(WmsBoxInfo wmsBoxInfo) {
         List<WmsBoxInfo> list = wmsBoxInfoMapper.selectWmsBoxInfoList(wmsBoxInfo);
-        if (list!=null && list.size()>0) {
+        if (list != null && list.size() > 0) {
             return list.get(0);
         } else {
             return null;
@@ -79,8 +80,7 @@ public class WmsBoxInfoServiceImpl implements IWmsBoxInfoService
      * @return 结果
      */
     @Override
-    public int insertWmsBoxInfo(WmsBoxInfo wmsBoxInfo)
-    {
+    public int insertWmsBoxInfo(WmsBoxInfo wmsBoxInfo) {
         wmsBoxInfo.setCreateTime(DateUtils.getNowDate());
         return wmsBoxInfoMapper.insertWmsBoxInfo(wmsBoxInfo);
     }
@@ -92,8 +92,7 @@ public class WmsBoxInfoServiceImpl implements IWmsBoxInfoService
      * @return 结果
      */
     @Override
-    public int updateWmsBoxInfo(WmsBoxInfo wmsBoxInfo)
-    {
+    public int updateWmsBoxInfo(WmsBoxInfo wmsBoxInfo) {
         wmsBoxInfo.setUpdateTime(DateUtils.getNowDate());
         return wmsBoxInfoMapper.updateWmsBoxInfo(wmsBoxInfo);
     }
@@ -105,8 +104,7 @@ public class WmsBoxInfoServiceImpl implements IWmsBoxInfoService
      * @return 结果
      */
     @Override
-    public int deleteWmsBoxInfoByIds(Long[] ids)
-    {
+    public int deleteWmsBoxInfoByIds(Long[] ids) {
         return wmsBoxInfoMapper.deleteWmsBoxInfoByIds(ids);
     }
 
@@ -117,8 +115,39 @@ public class WmsBoxInfoServiceImpl implements IWmsBoxInfoService
      * @return 结果
      */
     @Override
-    public int deleteWmsBoxInfoById(Long id)
-    {
+    public int deleteWmsBoxInfoById(Long id) {
         return wmsBoxInfoMapper.deleteWmsBoxInfoById(id);
     }
+
+    @Override
+    public AjaxResult addBoxInfo(AddBoxForm addBoxForm) {
+        WmsBoxInfo wmsBoxInfo = wmsBoxInfoMapper.selectWmsBoxInfoByBoxNo(addBoxForm.getBoxNo());
+        if (wmsBoxInfo != null) {
+            //TODO 移动库存
+            return AjaxResult.error("该容器已存在");
+        } else {
+            WmsBoxInfo boxInfo = new WmsBoxInfo();
+            boxInfo.setBoxNo(addBoxForm.getBoxNo());
+            if (!StringUtils.isEmpty(addBoxForm.getLocationId())) {
+                boxInfo.setLocationId(Long.parseLong(addBoxForm.getLocationId()));
+            }
+            boxInfo.setBoxState(1);
+            boxInfo.setIsEmpty("Y");
+            boxInfo.setIsFull("N");
+            boxInfo.setBoxType("pallet");
+            int result = wmsBoxInfoMapper.insertWmsBoxInfo(boxInfo);
+            if (result > 0) {
+                return AjaxResult.success("操作成功");
+            } else {
+                return AjaxResult.error("操作失败");
+            }
+        }
+
+    }
+
+    @Override
+    public WmsBoxInfo selectByLocationId(String locationId) {
+        WmsBoxInfo wmsBoxInfo = wmsBoxInfoMapper.selectByLocationId(locationId);
+        return wmsBoxInfo;
+    }
 }

+ 21 - 1
warewms-ams/src/main/java/com/ruoyi/ams/inv/mapper/InvLotLocIdMapper.java

@@ -76,7 +76,7 @@ public interface InvLotLocIdMapper {
      * @param lotnum 库位库存信息主键
      * @return 结果
      */
-    int deleteInvLotLocIdBy(@Param("lotnum") String lotnum,@Param("sku") String sku,@Param("locationId") String locationId,@Param("customerId") String customerId);
+    int deleteInvLotLocIdBy(@Param("lotnum") String lotnum, @Param("sku") String sku, @Param("locationId") String locationId, @Param("customerId") String customerId);
 
     /**
      * 批量删除库位库存信息
@@ -139,6 +139,15 @@ public interface InvLotLocIdMapper {
      */
     int updateInvLotLocIdLocationId(@Param("locationFrom") Long locationFrom, @Param("locationTo") Long locationTo);
 
+    /**
+     * 根据托盘号将库存更新到目标库位
+     *
+     * @param lotnum
+     * @param locationTo
+     * @return
+     */
+    int updateInvLotLocIdToByLotnum(@Param("lotnum") String lotnum, @Param("locationTo") Long locationTo);
+
     /**
      * 清除库位库存信息
      *
@@ -195,6 +204,7 @@ public interface InvLotLocIdMapper {
 
     /**
      * 解绑库存
+     *
      * @param locationId
      * @param sku
      * @param customerId
@@ -227,9 +237,19 @@ public interface InvLotLocIdMapper {
 
     /**
      * 根据托盘号和物料分类查询是否有相同的库存
+     *
      * @param skuType
      * @param palletNo
      * @return
      */
     List<InvLotLocId> querySameTypeByPalletNo(@Param("skuType") String skuType, @Param("palletNo") String palletNo);
+
+    /**
+     * 根据sku和locationid查询库存(根据sku进行排序)
+     *
+     * @param sku
+     * @param locationId
+     * @return
+     */
+    List<InvLotLocId> selectInvLotLocIdBySkuLocationSort(@Param("sku") String sku, @Param("locationId") Long locationId);
 }

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

@@ -238,4 +238,13 @@ public interface IInvLotLocIdService {
      * @return
      */
     AjaxResult unLockInvByPalletNo(String palletNo, String sn);
+
+    /**
+     * 库存转移部分
+     *
+     * @param locationFrom
+     * @param locationTo
+     * @return
+     */
+    AjaxResult stockTransferPick(Long locationFrom, Long locationTo, String lotnum, BigDecimal qty);
 }

+ 43 - 9
warewms-ams/src/main/java/com/ruoyi/ams/inv/service/impl/InvLotLocIdServiceImpl.java

@@ -17,6 +17,7 @@ import com.ruoyi.base.domain.BaseLocationInfo;
 import com.ruoyi.base.service.IBaseLocationInfoService;
 import com.ruoyi.base.utils.IdSequenceUtils;
 import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.exception.ServiceException;
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.StringUtils;
 import lombok.extern.slf4j.Slf4j;
@@ -49,6 +50,8 @@ public class InvLotLocIdServiceImpl implements IInvLotLocIdService {
     private IdSequenceUtils idSequenceUtils;
     @Autowired
     private IWmsBoxInfoService iWmsBoxInfoService;
+    @Autowired
+    private IInvLotLocIdService invLotLocIdService;
 
     /**
      * 查询库位库存信息
@@ -413,18 +416,18 @@ public class InvLotLocIdServiceImpl implements IInvLotLocIdService {
         BeanUtils.copyProperties(lotattDTO, invLotAtt);
         //查询lotatt是否存在
         String lotnum;
-        List<InvLotAtt> queryList = invLotAttMapper.selectInvLotAttList(invLotAtt);
+        /*List<InvLotAtt> queryList = invLotAttMapper.selectInvLotAttList(invLotAtt);
         if (queryList != null && queryList.size() > 0) {
             invLotAtt = queryList.get(0);
             lotnum = invLotAtt.getLotnum();
-        } else {
-            lotnum = idSequenceUtils.generateId("LOTNUMBER");
-            invLotAtt.setLotnum(lotnum);
-            invLotAtt.setSku(sku);
-            invLotAtt.setCustomerId(customerId);
-            invLotAtt.setCreateTime(DateUtils.getNowDate());
-            invLotAttMapper.insertInvLotAtt(invLotAtt);
-        }
+        } else {*/
+        lotnum = idSequenceUtils.generateId("LOTNUMBER");
+        invLotAtt.setLotnum(lotnum);
+        invLotAtt.setSku(sku);
+        invLotAtt.setCustomerId(customerId);
+        invLotAtt.setCreateTime(DateUtils.getNowDate());
+        invLotAttMapper.insertInvLotAtt(invLotAtt);
+        //}
         InvLotLocId invLotLocId = new InvLotLocId();
         invLotLocId.setLotnum(lotnum);
         invLotLocId.setLocationId(locationFrom);
@@ -488,4 +491,35 @@ public class InvLotLocIdServiceImpl implements IInvLotLocIdService {
         }
         return AjaxResult.success("解绑成功");
     }
+
+    @Override
+    public AjaxResult stockTransferPick(Long locationFrom, Long locationTo, String lotnum, BigDecimal qty) {
+        List<InvLotLocId> invLotLocIds = invLotLocIdMapper.selectInvLotLocIdByLotnum(lotnum);
+        if (invLotLocIds != null && invLotLocIds.size() > 0) {
+            for (InvLotLocId inv : invLotLocIds) {
+                BigDecimal current = inv.getQty().subtract(inv.getQtyallocated());
+                if (current.compareTo(qty) == 1) { //大于
+                    BigDecimal temp = current.subtract(qty);
+                    InvLotLocId copy = new InvLotLocId();
+                    BeanUtils.copyProperties(inv, copy);
+                    copy.setLocationId(locationTo.toString());
+                    copy.setQty(temp);
+                    copy.setQtyEach(temp);
+                    invLotLocIdService.insertInvLotLocId(copy);
+
+                    inv.setQty(temp);
+                    inv.setQtyEach(temp);
+                    invLotLocIdService.updateInvLotLocId(inv);
+                    //TODO 进行退回
+                    return AjaxResult.success("操作成功");
+                } else { //小于
+                    invLotLocIdService.stockTransfer(locationFrom, locationTo);
+                    return AjaxResult.success("操作成功");
+                }
+            }
+            throw new ServiceException("查询不到库存信息");
+        } else {
+            throw new ServiceException("查询不到库存信息");
+        }
+    }
 }

+ 14 - 0
warewms-ams/src/main/java/com/ruoyi/ams/order/form/ArrangeStockForm.java

@@ -0,0 +1,14 @@
+package com.ruoyi.ams.order.form;
+
+import lombok.Data;
+
+@Data
+public class ArrangeStockForm {
+    private String allocationId;
+    private String orderNo;
+    private String palletNo;
+    //箱号
+    private String boxNo;
+    private String sn;
+    private String qty;
+}

+ 5 - 3
warewms-ams/src/main/java/com/ruoyi/ams/order/form/PickForm.java

@@ -6,13 +6,15 @@ import java.util.List;
 
 @Data
 public class PickForm {
-    //private List<PickInfoForm> pickInfoFormList;
-    private String allocationId;
+    private List<PickInfoForm> pickInfoFormList;
+    /*private String allocationId;
+    private String qty;
+    private String locationTo;
     private String orderNo;
     private String palletNo;
     private String sn;
     private String sku;
     private String qty;
     private String locationTo;
-    private String fullTag;
+    private String fullTag;*/
 }

+ 9 - 0
warewms-ams/src/main/java/com/ruoyi/ams/order/form/PickInfoForm.java

@@ -0,0 +1,9 @@
+package com.ruoyi.ams.order.form;
+
+import lombok.Data;
+
+@Data
+public class PickInfoForm {
+    private String allocationId;
+    private String locationTo;
+}

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

@@ -4,6 +4,7 @@ import java.util.List;
 
 import com.ruoyi.ams.order.domain.WmsDocOrderDetails;
 import com.ruoyi.ams.order.domain.WmsDocOrderHeader;
+import com.ruoyi.ams.order.form.ArrangeStockForm;
 import com.ruoyi.ams.order.form.CheckOutInfoForm;
 import com.ruoyi.ams.order.form.PickForm;
 import com.ruoyi.ams.order.vo.StockOrderVO;
@@ -85,8 +86,8 @@ public interface IWmsDocOrderHeaderService {
      *
      * @param orderNo     订单号
      * @param orderLoneNo 订单明细
-     * @param sku         物料
      * @param qty         数量
+     * @param status      状态
      * @return
      */
     int updateOrderDetailsStock(String orderNo, Long orderLoneNo, Double qty, String status);
@@ -121,7 +122,7 @@ public interface IWmsDocOrderHeaderService {
      * @param pickForm
      * @return
      */
-    AjaxResult doPick(PickForm pickForm);
+    AjaxResult toPick(PickForm pickForm);
 
     /**
      * 分拣出库
@@ -160,4 +161,11 @@ public interface IWmsDocOrderHeaderService {
      *
      */
     void checkStatusClose(String asnNo, String status);
+
+    /**
+     * 理货
+     * @param arrangeStockForm
+     * @return
+     */
+    AjaxResult arrangeStock(ArrangeStockForm arrangeStockForm);
 }

+ 11 - 2
warewms-ams/src/main/java/com/ruoyi/ams/order/service/impl/ActAllocationDetailsServiceImpl.java

@@ -3,6 +3,8 @@ package com.ruoyi.ams.order.service.impl;
 import java.math.BigDecimal;
 import java.util.List;
 
+import com.ruoyi.ams.box.domain.WmsBoxInfo;
+import com.ruoyi.ams.box.service.IWmsBoxInfoService;
 import com.ruoyi.ams.order.domain.WmsDocOrderDetails;
 import com.ruoyi.base.utils.IdSequenceUtils;
 import com.ruoyi.common.core.domain.AjaxResult;
@@ -25,6 +27,8 @@ public class ActAllocationDetailsServiceImpl implements IActAllocationDetailsSer
     private ActAllocationDetailsMapper actAllocationDetailsMapper;
     @Autowired
     private IdSequenceUtils idSequenceUtils;
+    @Autowired
+    private IWmsBoxInfoService wmsBoxInfoService;
 
     /**
      * 查询分配查询
@@ -110,6 +114,7 @@ public class ActAllocationDetailsServiceImpl implements IActAllocationDetailsSer
 
     @Override
     public AjaxResult addActAllocationDetails(String lotnum, String locationId, BigDecimal qty, WmsDocOrderDetails orderDetails) {
+        WmsBoxInfo wmsBoxInfo = wmsBoxInfoService.selectByLocationId(locationId);
         String allocationId = idSequenceUtils.generateId("ANO");
         ActAllocationDetails actAllocationDetails = new ActAllocationDetails();
         actAllocationDetails.setAllocationId(allocationId);
@@ -119,10 +124,14 @@ public class ActAllocationDetailsServiceImpl implements IActAllocationDetailsSer
         actAllocationDetails.setStatus("00");
         actAllocationDetails.setLotnum(lotnum);
         actAllocationDetails.setQty(qty);
+        actAllocationDetails.setPickQty(BigDecimal.ZERO);
         actAllocationDetails.setLocationId(Long.parseLong(locationId));
+        if (wmsBoxInfo != null) {
+            actAllocationDetails.setUserdefine1(wmsBoxInfo.getBoxNo());
+        }
         int count = actAllocationDetailsMapper.insertActAllocationDetails(actAllocationDetails);
         if (count > 0) {
-            return AjaxResult.success("分配明细生成成功");
+            return AjaxResult.success("分配明细生成成功", qty);
         } else {
             return AjaxResult.error("分配明细生成失败");
         }
@@ -153,6 +162,6 @@ public class ActAllocationDetailsServiceImpl implements IActAllocationDetailsSer
 
     @Override
     public void updateAllocationDetailsLocationIdByPalletNo(String locationId, String palletNo) {
-        actAllocationDetailsMapper.updateAllocationDetailsLocationIdByPalletNo(locationId,palletNo);
+        actAllocationDetailsMapper.updateAllocationDetailsLocationIdByPalletNo(locationId, palletNo);
     }
 }

+ 131 - 110
warewms-ams/src/main/java/com/ruoyi/ams/order/service/impl/WmsDocOrderHeaderServiceImpl.java

@@ -13,15 +13,19 @@ import com.ruoyi.ams.inv.mapper.InvLotLocIdMapper;
 import com.ruoyi.ams.inv.service.IInvLotLocIdService;
 import com.ruoyi.ams.order.domain.ActAllocationDetails;
 import com.ruoyi.ams.order.domain.WmsDocOrderDetails;
+import com.ruoyi.ams.order.form.ArrangeStockForm;
 import com.ruoyi.ams.order.form.CheckOutInfoForm;
 import com.ruoyi.ams.order.form.PickForm;
+import com.ruoyi.ams.order.form.PickInfoForm;
 import com.ruoyi.ams.order.mapper.WmsDocOrderDetailsMapper;
 import com.ruoyi.ams.order.service.IActAllocationDetailsService;
 import com.ruoyi.ams.order.vo.StockOrderVO;
 import com.ruoyi.base.constant.Constant;
+import com.ruoyi.base.service.IBaseLocationInfoService;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.core.domain.model.LoginUser;
 import com.ruoyi.common.utils.SecurityUtils;
+import com.ruoyi.common.utils.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.ruoyi.ams.order.mapper.WmsDocOrderHeaderMapper;
@@ -55,6 +59,8 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
     private InvLotLocIdMapper invLotLocIdMapper;
     @Autowired
     private InvLotAttMapper invLotAttMapper;
+    @Autowired
+    private IBaseLocationInfoService baseLocationInfoService;
 
     /**
      * 查询出库单头
@@ -170,12 +176,19 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
         }
         boolean isbf = false;
         boolean isAllocation = false;
+        BigDecimal total = BigDecimal.ZERO;
         List<WmsDocOrderDetails> orderDetails = orderHeader.getWmsDocOrderDetailsList();
+        for (WmsDocOrderDetails o : orderDetails) {
+            total = total.add(o.getQtyOrdered());
+        }
         for (WmsDocOrderDetails o : orderDetails) {
             AjaxResult result = wmsDocOrderHeaderService.doAllocationDetails(orderHeader, o);
             if ((int) result.get(AjaxResult.CODE_TAG) != 500) {
-                isbf = true;
-                isAllocation = true;
+                BigDecimal current = new BigDecimal(result.get(AjaxResult.DATA_TAG).toString());
+                total = total.subtract(current);
+                if (total.compareTo(BigDecimal.ZERO) == 1) {
+                    isbf = true;
+                }
             }
         }
         if (isbf) {
@@ -200,133 +213,126 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
     @Transactional
     @Override
     public AjaxResult doAllocationDetails(WmsDocOrderHeader header, WmsDocOrderDetails details) {
-        if (header.getOrderType().equals("OD")) {
-            List<InvLotLocId> invList = invLotLocIdService.queryInvByFull(header.getOrderNo(), details.getSku());
-            BigDecimal totalQty = BigDecimal.ZERO;
-            for (InvLotLocId inv : invList) {
-                //可以叫料且合格的库存
-                InvLotAtt lotAtt = invLotAttMapper.selectInvLotAttByLotnum(inv.getLotnum());
-                if (!lotAtt.getLotatt05().equals("90") || !lotAtt.getLotatt12().equals("Y")) {
-                    continue;
-                }
-
-                //可以分配的库存
-                inv.setQtyallocated(inv.getQty());
-                inv.setQtyallocatedEach(inv.getQtyEach());
-
-                if (invLotLocIdService.updateInvLotLocId(inv) > 0) {
-                    totalQty.add(inv.getQty());
-                    //修改出库单状态
-                    details.setQtyAllocated(details.getQtyAllocated().add(inv.getQty()));
-                    wmsDocOrderDetailsMapper.updateWmsDocOrderDetails(details);
-                    //生成分配明细
-                    return actAllocationDetailsService.addActAllocationDetails(inv.getLotnum(), inv.getLocationId(), inv.getQty(), details);
-                }
+        List<InvLotLocId> invList = invLotLocIdService.queryInvOrderBy(details.getLotnum(), details.getSku(), details.getLocation(), details.getCustomerId());
+        //库存可分配数小于订单数
+        BigDecimal orderQty = details.getQtyOrdered();
+        //判断总数是否足够分配
+        double qtySum = invList.stream().mapToDouble(item -> item.getQty().doubleValue() > item.getQtyallocated().doubleValue() ? item.getQty().doubleValue() : 0).sum();
+        if (qtySum < orderQty.doubleValue()) {
+            return AjaxResult.error("库存不足分配失败");
+        }
+        for (InvLotLocId inv : invList) {
+            if (orderQty.doubleValue() == 0) {
+                return AjaxResult.success("分配完成");
             }
-        } else {
-            List<InvLotLocId> invList = invLotLocIdService.queryInvOrderBy(details.getLotnum(), details.getSku(), details.getLocation(), details.getCustomerId());
-            //库存可分配数小于订单数
-            BigDecimal orderQty = details.getQtyOrdered();
-            //判断总数是否足够分配
-            double qtySum = invList.stream().mapToDouble(item -> item.getQty().doubleValue() > item.getQtyallocated().doubleValue() ? item.getQty().doubleValue() : 0).sum();
-            if (qtySum < orderQty.doubleValue()) {
-                return AjaxResult.error("库存不足分配失败");
+            //可以叫料且合格的库存
+            InvLotAtt lotAtt = invLotAttMapper.selectInvLotAttByLotnum(inv.getLotnum());
+            if (!lotAtt.getLotatt05().equals("90") || !lotAtt.getLotatt12().equals("Y")) {
+                continue;
             }
-            for (InvLotLocId inv : invList) {
-                if (orderQty.doubleValue() == 0) {
-                    return AjaxResult.success("分配完成");
-                }
-                //可以叫料且合格的库存
-                InvLotAtt lotAtt = invLotAttMapper.selectInvLotAttByLotnum(inv.getLotnum());
-                if (!lotAtt.getLotatt05().equals("90") || !lotAtt.getLotatt12().equals("Y")) {
-                    continue;
-                }
 
-                BigDecimal canallocatedQty = inv.getQty().subtract(inv.getQtyallocated());
-                if (canallocatedQty.doubleValue() > 0) {
-                    if (inv.getQty().intValue() > 0) {
-                        if (inv.getQty().subtract(inv.getQtyallocated()).compareTo(orderQty) == -1) {
-                            //可以分配的库存
-                            BigDecimal allocatedQty = inv.getQty().subtract(inv.getQtyallocated());
-                            inv.setQtyallocated(inv.getQtyallocated().add(allocatedQty));
-                            inv.setQtyallocatedEach(inv.getQtyallocatedEach().add(allocatedQty));
-                            if (invLotLocIdService.updateInvLotLocId(inv) > 0) {
-                                orderQty = orderQty.subtract(allocatedQty);
-                                //修改出库单状态
-                                details.setQtyAllocated(details.getQtyAllocated().add(allocatedQty));
-                                wmsDocOrderDetailsMapper.updateWmsDocOrderDetails(details);
+            BigDecimal canallocatedQty = inv.getQty().subtract(inv.getQtyallocated());
+            if (canallocatedQty.doubleValue() > 0) {
+                if (inv.getQty().intValue() > 0) {
+                    if (inv.getQty().subtract(inv.getQtyallocated()).compareTo(orderQty) == -1) {
+                        //可以分配的库存
+                        BigDecimal allocatedQty = inv.getQty().subtract(inv.getQtyallocated());
+                        inv.setQtyallocated(inv.getQtyallocated().add(allocatedQty));
+                        inv.setQtyallocatedEach(inv.getQtyallocatedEach().add(allocatedQty));
+                        if (invLotLocIdService.updateInvLotLocId(inv) > 0) {
+                            orderQty = orderQty.subtract(allocatedQty);
+                            //修改出库单状态
+                            details.setQtyAllocated(details.getQtyAllocated().add(allocatedQty));
+                            details.setLineStatus("10");
+                            wmsDocOrderDetailsMapper.updateWmsDocOrderDetails(details);
 
-                                //生成分配明细
-                                return actAllocationDetailsService.addActAllocationDetails(inv.getLotnum(), inv.getLocationId(), allocatedQty, details);
-                            } else {
-                                continue;
-                            }
-                        } else if (inv.getQty().subtract(inv.getQtyallocated()).compareTo(orderQty) == 0) {
-                            //可以分配的库存
-                            BigDecimal allocatedQty = inv.getQty().subtract(inv.getQtyallocated());
-                            inv.setQtyallocated(inv.getQtyallocated().add(allocatedQty));
-                            inv.setQtyallocatedEach(inv.getQtyallocatedEach().add(allocatedQty));
-                            if (invLotLocIdService.updateInvLotLocId(inv) > 0) {
-                                orderQty = orderQty.subtract(allocatedQty);
-                                //修改出库单状态
-                                //修改出库单状态
-                                details.setQtyAllocated(details.getQtyAllocated().add(allocatedQty));
-                                wmsDocOrderDetailsMapper.updateWmsDocOrderDetails(details);
+                            header.setOrderStatus("10");
+                            wmsDocOrderHeaderService.updateWmsDocOrderHeader(header);
+                            //生成分配明细
+                            actAllocationDetailsService.addActAllocationDetails(inv.getLotnum(), inv.getLocationId(), allocatedQty, details);
+                        } else {
+                            continue;
+                        }
+                    } else if (inv.getQty().subtract(inv.getQtyallocated()).compareTo(orderQty) == 0) {
+                        //可以分配的库存
+                        BigDecimal allocatedQty = inv.getQty().subtract(inv.getQtyallocated());
+                        inv.setQtyallocated(inv.getQtyallocated().add(allocatedQty));
+                        inv.setQtyallocatedEach(inv.getQtyallocatedEach().add(allocatedQty));
+                        if (invLotLocIdService.updateInvLotLocId(inv) > 0) {
+                            orderQty = orderQty.subtract(allocatedQty);
+                            //修改出库单状态
+                            //修改出库单状态
+                            details.setLineStatus("20");
+                            details.setQtyAllocated(details.getQtyAllocated().add(allocatedQty));
+                            wmsDocOrderDetailsMapper.updateWmsDocOrderDetails(details);
 
-                                //生成分配明细
-                                return actAllocationDetailsService.addActAllocationDetails(inv.getLotnum(), inv.getLocationId(), allocatedQty, details);
-                            } else {
-                                return AjaxResult.error("占用库存分配数失败");
-                            }
+                            header.setOrderStatus("20");
+                            wmsDocOrderHeaderService.updateWmsDocOrderHeader(header);
+                            //生成分配明细
+                            return actAllocationDetailsService.addActAllocationDetails(inv.getLotnum(), inv.getLocationId(), allocatedQty, details);
+                        } else {
+                            return AjaxResult.error("占用库存分配数失败");
+                        }
+                    } else {
+                        BigDecimal currentQty = orderQty;
+                        inv.setQtyallocated(inv.getQtyallocated().add(currentQty));
+                        inv.setQtyallocatedEach(inv.getQtyallocatedEach().add(currentQty));
+                        if (invLotLocIdService.updateInvLotLocId(inv) > 0) {
+                            //修改出库单状态
+                            details.setLineStatus("10");
+                            details.setQtyAllocated(details.getQtyAllocated().add(currentQty));
+                            wmsDocOrderDetailsMapper.updateWmsDocOrderDetails(details);
+                            header.setOrderStatus("20");
+                            wmsDocOrderHeaderService.updateWmsDocOrderHeader(header);
+                            //生成分配明细
+                            return actAllocationDetailsService.addActAllocationDetails(inv.getLotnum(), inv.getLocationId(), currentQty, details);
                         } else {
-                            BigDecimal currentQty = orderQty;
-                            inv.setQtyallocated(inv.getQtyallocated().add(currentQty));
-                            inv.setQtyallocatedEach(inv.getQtyallocatedEach().add(currentQty));
-                            if (invLotLocIdService.updateInvLotLocId(inv) > 0) {
-                                //修改出库单状态
-                                details.setQtyAllocated(details.getQtyAllocated().add(currentQty));
-                                wmsDocOrderDetailsMapper.updateWmsDocOrderDetails(details);
-                                //生成分配明细
-                                return actAllocationDetailsService.addActAllocationDetails(inv.getLotnum(), inv.getLocationId(), currentQty, details);
-                            } else {
-                                return AjaxResult.error("占用库存分配数失败");
-                            }
+                            return AjaxResult.error("占用库存分配数失败");
                         }
                     }
                 }
             }
+            //}
         }
         return AjaxResult.error("库存数不足,无法分配");
     }
 
     @Transactional
     @Override
-    public AjaxResult doPick(PickForm pickForm) {
-        BigDecimal qty;
-        //查询对应的分配明细表
-        ActAllocationDetails actAllocationDetails = actAllocationDetailsService.selectActAllocationDetailsByAllocationId(pickForm.getAllocationId());
-        qty = actAllocationDetails.getPickQty();
-        actAllocationDetails.setPickQty(actAllocationDetails.getPickQty().add(new BigDecimal(pickForm.getQty())));
-        actAllocationDetails.setPickToLocation(pickForm.getLocationTo());
-        actAllocationDetailsService.updateActAllocationDetails(actAllocationDetails);
+    public AjaxResult toPick(PickForm pickForm) {
+        List<PickInfoForm> pickInfoFormList = pickForm.getPickInfoFormList();
+        for (PickInfoForm p : pickInfoFormList) {
+            String locationTo = p.getLocationTo();
+            if (StringUtils.isEmpty(locationTo)) {
+                //TODO 分配可用库位
+            }
 
-        //更新出库单拣货数量
-        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");
-        }
-        wmsDocOrderDetailsMapper.updateWmsDocOrderDetails(wmsDocOrderDetails);
+            //查询对应的分配明细表
+            ActAllocationDetails actAllocationDetails = actAllocationDetailsService.selectActAllocationDetailsByAllocationId(p.getAllocationId());
+            //qty = actAllocationDetails.getPickQty();
+            //actAllocationDetails.setPickQty(actAllocationDetails.getPickQty().add(new BigDecimal(p.getQty())));
+            //actAllocationDetails.setPickToLocation(locationTo);
+            actAllocationDetails.setLocationId(Long.parseLong(locationTo));
+            actAllocationDetailsService.updateActAllocationDetails(actAllocationDetails);
 
-        //库存进行移动
-        invLotLocIdService.stockTransfer(actAllocationDetails.getLocationId(), Long.parseLong(actAllocationDetails.getPickToLocation()));
-        //托盘进行绑定修改
-        wmsBoxInfoMapper.updateLocationBind(actAllocationDetails.getLocationId(), Long.parseLong(pickForm.getLocationTo()), pickForm.getFullTag());
+            //更新出库单拣货数量
+            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");
+            }
+            wmsDocOrderDetailsMapper.updateWmsDocOrderDetails(wmsDocOrderDetails);
+
+            //库存进行移动
+            invLotLocIdService.stockTransfer(actAllocationDetails.getLocationId(), Long.parseLong(locationTo));
+            //托盘进行绑定修改
+            wmsBoxInfoMapper.updateLocationBind(actAllocationDetails.getLocationId(), Long.parseLong(locationTo), null);
+            //TODO 是否需要生成任务
 
-        //TODO 是否需要生成任务
+        }
         return AjaxResult.success("操作成功");
     }
 
@@ -403,4 +409,19 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
 
         }
     }
+
+    @Transactional
+    @Override
+    public AjaxResult arrangeStock(ArrangeStockForm arrangeStockForm) {
+        //把拣货库位上的库存移动到一个新的托盘上
+        ActAllocationDetails actAllocationDetails = actAllocationDetailsService.selectActAllocationDetailsByAllocationId(arrangeStockForm.getAllocationId());
+        WmsBoxInfo wmsBoxInfo = wmsBoxInfoService.selectWmsBoxInfoByBoxNo(arrangeStockForm.getPalletNo());
+        //修改托盘状态
+        wmsBoxInfo.setIsFull("N");
+        wmsBoxInfoService.updateWmsBoxInfo(wmsBoxInfo);
+        //库存进行移动
+        invLotLocIdService.stockTransferPick(Long.parseLong(actAllocationDetails.getPickToLocation()), wmsBoxInfo.getLocationId(), actAllocationDetails.getLotnum(), new BigDecimal(arrangeStockForm.getQty()));
+        //TODO 生成任务退回
+        return AjaxResult.success("操作成功");
+    }
 }

+ 16 - 1
warewms-ams/src/main/resources/mapper/ams/InvLotLocIdMapper.xml

@@ -325,7 +325,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </delete>
 
     <update id="updateInvLotLocIdLocationId">
-        update inv_lot_loc_id set location_id = #{locationTo} where location_id = #{locationFrom}
+        update inv_lot_loc_id set location_id = #{locationTo}
+        where location_id = #{locationFrom}
+    </update>
+
+    <update id="updateInvLotLocIdToByLotnum">
+        update inv_lot_loc_id set location_id = #{locationTo}
+        where lotnum = #{lotnum}
     </update>
 
     <update id="clearInvByLocationId">
@@ -491,4 +497,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         where sk.sku_type <![CDATA[ <> ]]> #{skuType}
         and b.box_no = #{palletNo}
     </select>
+
+    <select id="selectInvLotLocIdBySkuLocationSort" resultMap="InvLotLocIdResult">
+        select *,(qtyallocated - qty) qty from inv_lot_loc_id
+        <where>
+            <if test="locationId != null  and locationId != ''"> and location_id = #{locationId}</if>
+            <if test="sku != null  and sku != ''"> and sku = #{sku}</if>
+        </where>
+        order by (qtyallocated - qty)
+    </select>
 </mapper>

+ 10 - 0
warewms-ams/src/main/resources/mapper/box/WmsBoxInfoMapper.xml

@@ -116,4 +116,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         update wms_box_info set location_id = '',is_full = 'N'
         where location_id = #{locationId}
     </update>
+
+    <select id="selectWmsBoxInfoByBoxNo" parameterType="string" resultMap="WmsBoxInfoResult">
+        <include refid="selectWmsBoxInfoVo"/>
+        where box_no = #{boxNo}
+    </select>
+
+    <select id="selectByLocationId" parameterType="string" resultMap="WmsBoxInfoResult">
+        <include refid="selectWmsBoxInfoVo"/>
+        where location_id = #{locationId}
+    </select>
 </mapper>

+ 1 - 0
warewms-base/src/main/java/com/ruoyi/base/domain/vo/CodeSkuRelationshipVO.java

@@ -15,4 +15,5 @@ public class CodeSkuRelationshipVO {
     private String status;
     private String sku;
     private String skuType;
+    private boolean isProduct;
 }

+ 1 - 1
warewms-base/src/main/java/com/ruoyi/base/mapper/CodeSkuRelationshipMapper.java

@@ -65,5 +65,5 @@ public interface CodeSkuRelationshipMapper
      * @param sn
      * @return
      */
-     CodeSkuRelationshipVO selectCodeSkuRelationshipBySn(String sn);
+     List<CodeSkuRelationshipVO> selectCodeSkuRelationshipBySn(String sn);
 }

+ 26 - 16
warewms-base/src/main/java/com/ruoyi/base/service/ICodeSkuRelationshipService.java

@@ -1,32 +1,33 @@
 package com.ruoyi.base.service;
 
 import java.util.List;
+
 import com.ruoyi.base.domain.CodeSkuRelationship;
+import com.ruoyi.base.domain.vo.CodeSkuRelationshipVO;
 import com.ruoyi.common.core.domain.AjaxResult;
 
 /**
  * 条码品号关系表Service接口
- * 
+ *
  * @author andy
  * @date 2022-11-07
  */
-public interface ICodeSkuRelationshipService 
-{
+public interface ICodeSkuRelationshipService {
     /**
      * 查询条码品号关系表
-     * 
+     *
      * @param id 条码品号关系表主键
      * @return 条码品号关系表
      */
-     CodeSkuRelationship selectCodeSkuRelationshipById(Long id);
+    CodeSkuRelationship selectCodeSkuRelationshipById(Long id);
 
     /**
      * 查询条码品号关系表列表
-     * 
+     *
      * @param codeSkuRelationship 条码品号关系表
      * @return 条码品号关系表集合
      */
-     List<CodeSkuRelationship> selectCodeSkuRelationshipList(CodeSkuRelationship codeSkuRelationship);
+    List<CodeSkuRelationship> selectCodeSkuRelationshipList(CodeSkuRelationship codeSkuRelationship);
 
     /**
      * 查询条码品号关系表
@@ -38,40 +39,49 @@ public interface ICodeSkuRelationshipService
 
     /**
      * 新增条码品号关系表
-     * 
+     *
      * @param codeSkuRelationship 条码品号关系表
      * @return 结果
      */
-     int insertCodeSkuRelationship(CodeSkuRelationship codeSkuRelationship);
+    int insertCodeSkuRelationship(CodeSkuRelationship codeSkuRelationship);
 
     /**
      * 修改条码品号关系表
-     * 
+     *
      * @param codeSkuRelationship 条码品号关系表
      * @return 结果
      */
-     int updateCodeSkuRelationship(CodeSkuRelationship codeSkuRelationship);
+    int updateCodeSkuRelationship(CodeSkuRelationship codeSkuRelationship);
 
     /**
      * 批量删除条码品号关系表
-     * 
+     *
      * @param ids 需要删除的条码品号关系表主键集合
      * @return 结果
      */
-     int deleteCodeSkuRelationshipByIds(Long[] ids);
+    int deleteCodeSkuRelationshipByIds(Long[] ids);
 
     /**
      * 删除条码品号关系表信息
-     * 
+     *
      * @param id 条码品号关系表主键
      * @return 结果
      */
-     int deleteCodeSkuRelationshipById(Long id);
+    int deleteCodeSkuRelationshipById(Long id);
 
     /**
      * 条码检测
+     *
      * @param sn 条码
      * @return
      */
-     AjaxResult snCheck(String sn);
+    AjaxResult snCheck(String sn);
+
+    /**
+     * 检查是否是成品
+     *
+     * @param sn
+     * @return
+     */
+    CodeSkuRelationshipVO checkIsProduct(String sn);
 }

+ 25 - 4
warewms-base/src/main/java/com/ruoyi/base/service/impl/CodeSkuRelationshipServiceImpl.java

@@ -4,6 +4,7 @@ import java.util.List;
 
 import com.ruoyi.base.domain.vo.CodeSkuRelationshipVO;
 import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.exception.ServiceException;
 import com.ruoyi.common.utils.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -114,10 +115,30 @@ public class CodeSkuRelationshipServiceImpl implements ICodeSkuRelationshipServi
      */
     @Override
     public AjaxResult snCheck(String sn) {
-        CodeSkuRelationshipVO codeSkuRelationshipVO = codeSkuRelationshipMapper.selectCodeSkuRelationshipBySn(sn);
-        if (codeSkuRelationshipVO.getStatus().equals("N")) {
-            return AjaxResult.error("该产品已禁用");
+        CodeSkuRelationshipVO codeSkuRelationshipVO = this.checkIsProduct(sn);
+        return AjaxResult.success("", codeSkuRelationshipVO);
+    }
+
+    /**
+     * 条码检测
+     * @param sn
+     * @return
+     */
+    @Override
+    public CodeSkuRelationshipVO checkIsProduct(String sn) {
+        List<CodeSkuRelationshipVO> codeSkuRelationshipVO = codeSkuRelationshipMapper.selectCodeSkuRelationshipBySn(sn);
+        if (codeSkuRelationshipVO != null && codeSkuRelationshipVO.size() > 1) {
+            //物料条码
+            CodeSkuRelationshipVO tmp = codeSkuRelationshipVO.get(0);
+            tmp.setProduct(false);
+            return tmp;
+        } else if (codeSkuRelationshipVO != null && codeSkuRelationshipVO.size() == 1) {
+            //成品条码
+            CodeSkuRelationshipVO tmp = codeSkuRelationshipVO.get(0);
+            tmp.setProduct(true);
+            return tmp;
+        } else {
+            throw new ServiceException("条码不存在");
         }
-        return AjaxResult.success(codeSkuRelationshipVO);
     }
 }

+ 1 - 8
warewms-base/src/main/resources/mapper/base/CodeSkuRelationshipMapper.xml

@@ -18,16 +18,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
 
     <resultMap type="codeSkuRelationshipVO" id="CodeSkuRelationshipVOResult">
-        <result property="id"    column="id"    />
         <result property="sn"    column="sn"    />
         <result property="status"    column="status"    />
         <result property="sku"    column="sku"    />
-        <result property="vdate"    column="vdate"    />
-        <result property="userId"    column="user_id"    />
-        <result property="createBy"    column="create_by"    />
-        <result property="createTime"    column="create_time"    />
-        <result property="updateBy"    column="update_by"    />
-        <result property="updateTime"    column="update_time"    />
     </resultMap>
 
     <sql id="selectCodeSkuRelationshipVo">
@@ -105,6 +98,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="selectCodeSkuRelationshipBySn" parameterType="string" resultMap="CodeSkuRelationshipVOResult">
       select c.sn,s.* from code_sku_relationship c left join base_sku s on c.sku = s.sku
-      where c.sn = #{sn}
+      where c.sn = #{sn} and status = 'Y'
     </select>
 </mapper>