Prechádzať zdrojové kódy

解决永湖线上bug-解绑以及出入库重新绑定不会重置托盘

ChenYang 1 rok pred
rodič
commit
d88a14f8c3

+ 2 - 2
ruoyi-admin/src/main/resources/application-dev.yml

@@ -81,8 +81,8 @@ spring:
 # 日志配置
 logging:
     level:
-        com.ruoyi: info
-        org.springframework: info
+        com.ruoyi: debug
+        org.springframework: debug
 
 
 # 是否开启服务

+ 24 - 3
ruoyi-admin/src/test/java/com/ruoyi/admin/test/base/WarehouseTest.java

@@ -8,6 +8,7 @@ import com.ruoyi.ams.agv.ndc.service.IAmsHexdefineDetailService;
 import com.ruoyi.ams.agv.ndc.service.IAmsTaskService;
 import com.ruoyi.ams.asn.domain.WmsDocAsnDetails;
 import com.ruoyi.ams.asn.domain.WmsDocAsnHeader;
+import com.ruoyi.ams.asn.form.StockForm;
 import com.ruoyi.ams.asn.service.IWmsDocAsnHeaderService;
 import com.ruoyi.ams.business.domain.FilterLockInvLocationDTO;
 import com.ruoyi.ams.config.domain.AsnSoStrategy;
@@ -20,7 +21,9 @@ import com.ruoyi.ams.config.mapper.AsnSoStrategyMapper;
 import com.ruoyi.ams.config.service.IFlowConfigHeaderService;
 import com.ruoyi.ams.config.service.LocationAllocationStrategy;
 import com.ruoyi.ams.erp.domain.ErpBarCodeList;
+import com.ruoyi.ams.erp.domain.ErpBarcodes;
 import com.ruoyi.ams.erp.domain.ErpOrderList;
+import com.ruoyi.ams.erp.mapper.ErpBarcodesMapper;
 import com.ruoyi.ams.erp.service.ISyncService;
 import com.ruoyi.ams.erp.service.impl.SyncServiceImpl;
 import com.ruoyi.ams.inv.domain.InvLotLocId;
@@ -43,9 +46,8 @@ import com.ruoyi.base.mapper.BaseSkuMapper;
 import com.ruoyi.base.service.IBaseIdsequenceService;
 import com.ruoyi.base.service.IBaseLocationInfoService;
 import com.ruoyi.base.service.IBaseWarehouseService;
-import com.ruoyi.base.utils.IdSequenceUtils;
-import com.ruoyi.common.core.redis.RedisCache;
-import com.ruoyi.framework.web.domain.server.Sys;
+import com.ruoyi.base.utils.IdSequenceUtils;;
+import org.assertj.core.util.Lists;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -108,6 +110,10 @@ public class WarehouseTest {
     @Autowired
     private RedisTemplate redisTemplate;
 
+    @Autowired
+    private ErpBarcodesMapper erpBarcodesMapper;
+
+
     @Test
     public void test() {
         List<BaseWarehouse> warehouseList = baseWarehouseService.selectBaseWarehouseList(null);
@@ -400,4 +406,19 @@ public class WarehouseTest {
         redisTemplate.opsForValue().set("erpOrderList", JSON.toJSONString(erpOrderListList));
     }
 
+
+
+
+    @Test
+    public void doStockTest() {
+
+        StockForm stockForm = new StockForm();
+        stockForm.setAsnNo(Lists.newArrayList("ASN202307210003", "ASN202307210004"));
+        stockForm.setPalletNo("T001");
+        stockForm.setFullTag("N");
+        stockForm.setSkuSn("CAGEL0HT0L0330030");
+        stockForm.setQty("100");
+        wmsDocAsnHeaderService.doStock(stockForm);
+    }
+
 }

+ 5 - 11
ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysPermissionService.java

@@ -28,16 +28,12 @@ public class SysPermissionService
      * @param user 用户信息
      * @return 角色权限信息
      */
-    public Set<String> getRolePermission(SysUser user)
-    {
+    public Set<String> getRolePermission(SysUser user) {
         Set<String> roles = new HashSet<String>();
         // 管理员拥有所有权限
-        if (user.isAdmin())
-        {
+        if (user.isAdmin()) {
             roles.add("admin");
-        }
-        else
-        {
+        } else {
             roles.addAll(roleService.selectRolePermissionByUserId(user.getUserId()));
         }
         return roles;
@@ -49,12 +45,10 @@ public class SysPermissionService
      * @param user 用户信息
      * @return 菜单权限信息
      */
-    public Set<String> getMenuPermission(SysUser user)
-    {
+    public Set<String> getMenuPermission(SysUser user) {
         Set<String> perms = new HashSet<String>();
         // 管理员拥有所有权限
-        if (user.isAdmin())
-        {
+        if (user.isAdmin()) {
             perms.add("*:*:*");
         }
         else

+ 150 - 113
warewms-ams/src/main/java/com/ruoyi/ams/asn/service/impl/WmsDocAsnHeaderServiceImpl.java

@@ -3,6 +3,8 @@ package com.ruoyi.ams.asn.service.impl;
 import java.math.BigDecimal;
 import java.util.*;
 
+import cn.hutool.core.comparator.CompareUtil;
+import cn.hutool.core.util.ObjectUtil;
 import com.ruoyi.ams.asn.form.PaForm;
 import com.ruoyi.ams.asn.form.StockForm;
 import com.ruoyi.ams.asn.form.UnlockForm;
@@ -20,7 +22,6 @@ import com.ruoyi.ams.erp.service.IErpBarcodesService;
 import com.ruoyi.ams.inv.domain.InvLotAtt;
 import com.ruoyi.ams.inv.domain.InvLotLocId;
 import com.ruoyi.ams.inv.domain.form.InvLocIdSearchFrom;
-import com.ruoyi.ams.inv.domain.form.InvLotLocIdForm;
 import com.ruoyi.ams.inv.domain.vo.InvLotLocIdLotattVO;
 import com.ruoyi.ams.inv.mapper.InvLotLocIdMapper;
 import com.ruoyi.ams.inv.service.IActTransactionLogService;
@@ -30,13 +31,10 @@ import com.ruoyi.ams.lineCall.domain.form.LineCallForm;
 import com.ruoyi.ams.lineCall.domain.form.LineCallListFrom;
 import com.ruoyi.ams.order.domain.WmsDocOrderDetails;
 import com.ruoyi.ams.order.domain.WmsDocOrderHeader;
-import com.ruoyi.ams.order.dto.WmsDocOrderDTO;
-import com.ruoyi.ams.order.form.ActAllocationDetailsFrom;
 import com.ruoyi.ams.order.mapper.WmsDocOrderDetailsMapper;
 import com.ruoyi.ams.order.mapper.WmsDocOrderHeaderMapper;
 import com.ruoyi.ams.order.service.IActAllocationDetailsService;
 import com.ruoyi.ams.order.service.IWmsDocOrderHeaderService;
-import com.ruoyi.ams.task.domain.WcsTask;
 import com.ruoyi.base.constant.Constant;
 import com.ruoyi.base.domain.BaseLocationInfo;
 import com.ruoyi.base.domain.BaseSku;
@@ -46,11 +44,14 @@ import com.ruoyi.base.service.IBaseLocationInfoService;
 import com.ruoyi.base.service.IBaseSkuService;
 import com.ruoyi.base.service.ICodeSkuRelationshipService;
 import com.ruoyi.base.utils.IdSequenceUtils;
+import com.ruoyi.common.constant.Constants;
 import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.core.domain.model.LoginUser;
 import com.ruoyi.common.exception.ServiceException;
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.SecurityUtils;
+import io.jsonwebtoken.lang.Assert;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -285,42 +286,21 @@ public class WmsDocAsnHeaderServiceImpl implements IWmsDocAsnHeaderService {
     @Transactional
     @Override
     public synchronized AjaxResult doStock(StockForm stockForm) {
-        LoginUser loginUser = SecurityUtils.getLoginUser();
+        //LoginUser loginUser = SecurityUtils.getLoginUser();
+        LoginUser loginUser = new LoginUser();
+        loginUser.setUser(new SysUser());
         Long STAGE01 = Constant.LOC_STAGE_CACHE;
         WmsDocOrderHeader wmsDocOrderHeader;
-        List<WmsDocOrderDetails> orderDetails = new ArrayList<>();
 
-        //查询托盘是否存在,生成托盘绑定信息
-        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.setIsEmpty("N");
-            wmsBoxInfo.setLocationId(STAGE01);
-            wmsBoxInfo.setCreateBy(loginUser.getUsername());
-            wmsBoxInfo.setCreateTime(new Date());
-            wmsBoxInfo.setUpdateBy(loginUser.getUsername());
-            wmsBoxInfo.setUpdateTime(new Date());
-            boxInfoService.insertWmsBoxInfo(wmsBoxInfo);
-        } else {
-            //判断已满拖的话不接收
-            if (wmsBoxInfo.getIsFull() != null && wmsBoxInfo.getIsFull().equals("Y")) {
-//                throw new ServiceException("该托盘已放满");
-            }
-            wmsBoxInfo.setBoxState(1);//启用状态
-            wmsBoxInfo.setIsFull(stockForm.getFullTag());
-            wmsBoxInfo.setIsEmpty("N");
-            wmsBoxInfo.setLocationId(STAGE01);
-            wmsBoxInfo.setUpdateBy(loginUser.getUsername());
-            wmsBoxInfo.setUpdateTime(new Date());
-            boxInfoService.updateWmsBoxInfo(wmsBoxInfo);
-        }
+        //第一种策略:如果当前符合条件的托盘号在基础信息中未查询到,则抛错提示;查询到则更新
+        WmsBoxInfo wmsBoxInfo = getWmsBoxInfo(stockForm.getPalletNo());
+        Assert.isTrue(ObjectUtil.isNotNull(wmsBoxInfo) && StringUtils.isNotBlank(wmsBoxInfo.getBoxNo()), "未找到当前可用的托盘");
+        updateIfExist(wmsBoxInfo, stockForm.getFullTag(), loginUser.getUsername());
+
+        //第二种策略:如果当前符合条件的托盘号在基础信息中未查询到,则新增;否则就更新
+        /*wmsBoxInfo = ObjectUtil.isNull(wmsBoxInfo) || StringUtils.isBlank(wmsBoxInfo.getBoxNo())
+                ? insertIfNotExist(wmsBoxInfo, stockForm.getPalletNo(), loginUser.getUsername())
+                : updateIfExist(wmsBoxInfo, stockForm.getFullTag(), loginUser.getUsername());*/
 
         //判断成品条码
         CodeSkuRelationshipVO codeSkuRelationshipVO = codeSkuRelationshipService.checkIsProduct(stockForm.getSkuSn());
@@ -350,7 +330,7 @@ public class WmsDocAsnHeaderServiceImpl implements IWmsDocAsnHeaderService {
         }
 
         // 匹配出库单 计算备货数量是否已经超出出库单可分配数量
-        if (stockForm.getStockTag().equals("Y")) {
+        if (StringUtils.equals("Y", stockForm.getStockTag())) {
             //查询出库单
             wmsDocOrderHeader = wmsDocOrderHeaderService.selectWmsDocOrderHeaderByOrderNo(stockForm.getOrderNo());
             if (wmsDocOrderHeader.getOrderStatus().equals(Constant.ORDER_STS.STS99.getValue())
@@ -359,21 +339,20 @@ public class WmsDocAsnHeaderServiceImpl implements IWmsDocAsnHeaderService {
                 return AjaxResult.error("出库单已完成,不可备货!");
             }
 
-            orderDetails = wmsDocOrderHeader.getWmsDocOrderDetailsList();
-
+            List<WmsDocOrderDetails> orderDetails = wmsDocOrderHeader.getWmsDocOrderDetailsList();
             //匹配出库单,根据sku统计可分配的数量
             BigDecimal orderQty = BigDecimal.ZERO;
             for (WmsDocOrderDetails de : orderDetails) {
                 if (!de.getSku().equals(codeSkuRelationshipVO.getSku())) {
                     continue;
                 }
-                if (de.getQtyOrdered().compareTo(de.getQtyAllocated()) == 1) {
+                if (de.getQtyOrdered().compareTo(de.getQtyAllocated()) > 0) {
                     BigDecimal current = de.getQtyOrdered().subtract(de.getQtyAllocated());
                     orderQty = orderQty.add(current);
                 }
             }
             //可分配数量小于传入数量
-            if (orderQty.compareTo(new BigDecimal(stockForm.getQty())) == -1) {
+            if (orderQty.compareTo(new BigDecimal(stockForm.getQty())) < 0) {
                 return AjaxResult.error("接收数超出出货单需求数量");
             }
         }
@@ -416,77 +395,74 @@ public class WmsDocAsnHeaderServiceImpl implements IWmsDocAsnHeaderService {
                         }
                     }
 
-                    //如果入库单预计数量大于接收数
-                    if (details.getExpectedQty().compareTo(details.getReceivedQty()) == 1) {
+                    //如果入库单预计数量大于接收数
+                    if (details.getExpectedQty().compareTo(details.getReceivedQty()) > 0) {
                         //当前入库单可以接收的数量
                         BigDecimal current = details.getExpectedQty().subtract(details.getReceivedQty());
-                        if (current.compareTo(BigDecimal.ZERO) != 1) {
-                            //如果没有可以接收的数量那么直接跳过
-                            continue;
-                        }
-                        if (totalQty.compareTo(current) != 1) { //如果入库数量<=订单数量
+
+                        if (totalQty.compareTo(current) <= 0) { //如果入库数量<=订单数量
                             current = totalQty;
                         }
                         //判断提交的总数是否已经分配完了
-                        if (totalQty.compareTo(BigDecimal.ZERO) == 1) {
-                            String asnStatus;
-                            if (details.getExpectedQty().compareTo(details.getReceivedQty().add(current)) == 1) {
-                                //部分接收
+
+                        if(CompareUtil.compare(totalQty, BigDecimal.ZERO) <= 0) break;
+
+
+                        String asnStatus;
+                        if (details.getExpectedQty().compareTo(details.getReceivedQty().add(current)) > 0) {
+                            //部分接收
+                            asnStatus = Constant.ASN_STS.STS30.getValue();
+                        } else {
+                            //接收完成
+                            asnStatus = Constant.ASN_STS.STS40.getValue();
+                        }
+                        //更新入库单接收数量及状态
+                        int result = wmsDocAsnDetailsMapper.updateWmsReceivedQty(details.getAsnNo(), details.getAsnLineNo().intValue(), current, asnStatus);
+                        if (result > 0) {
+                            totalQty = totalQty.subtract(current);
+                        } else {
+                            throw new ServiceException("更新接收数失败");
+                        }
+                        // 记录扫码数据
+                        erpBarcodesService.recordErpBarcodeListAsn(details,stockForm.getSkuSn()
+                                ,"STAGE01", stockForm.getPalletNo(), BigDecimal.ONE, stockForm.getBoxNo());
+                        //修改头单状态
+                        WmsDocAsnDetails detailsQuery = new WmsDocAsnDetails();
+                        detailsQuery.setAsnNo(details.getAsnNo());
+                        List<WmsDocAsnDetails> detailsCheckList = wmsDocAsnDetailsMapper.selectWmsDocAsnDetailsList(detailsQuery);
+                        for (WmsDocAsnDetails d : detailsCheckList) {
+                            if (!d.getLineStatus().equals(Constant.ASN_STS.STS40.getValue())) {
                                 asnStatus = Constant.ASN_STS.STS30.getValue();
-                            } else {
-                                //接收完成
-                                asnStatus = Constant.ASN_STS.STS40.getValue();
-                            }
-                            //更新入库单接收数量及状态
-                            int result = wmsDocAsnDetailsMapper.updateWmsReceivedQty(details.getAsnNo(), details.getAsnLineNo().intValue(), current, asnStatus);
-                            if (result > 0) {
-                                totalQty = totalQty.subtract(current);
-                            } else {
-                                throw new ServiceException("更新接收数失败");
-                            }
-                            // 记录扫码数据
-                            erpBarcodesService.recordErpBarcodeListAsn(details,stockForm.getSkuSn()
-                                    ,"STAGE01",stockForm.getPalletNo(),BigDecimal.ONE,stockForm.getBoxNo());
-                            //修改头单状态
-                            WmsDocAsnDetails detailsQuery = new WmsDocAsnDetails();
-                            detailsQuery.setAsnNo(details.getAsnNo());
-                            List<WmsDocAsnDetails> detailsCheckList = wmsDocAsnDetailsMapper.selectWmsDocAsnDetailsList(detailsQuery);
-                            for (WmsDocAsnDetails d : detailsCheckList) {
-                                if (!d.getLineStatus().equals(Constant.ASN_STS.STS40.getValue())) {
-                                    asnStatus = Constant.ASN_STS.STS30.getValue();
-                                    break;
-                                }
-                            }
-                            WmsDocAsnHeader headerUpdate = new WmsDocAsnHeader();
-                            headerUpdate.setAsnNo(details.getAsnNo());
-                            headerUpdate.setAsnStatus(asnStatus);
-                            headerUpdate.setUpdateBy(loginUser.getUsername());
-                            headerUpdate.setUpdateTime(new Date());
-                            wmsDocAsnHeaderMapper.updateWmsDocAsnHeader(headerUpdate);
-
-                            if (stockForm.getStockTag().equals("Y")) {
-                                // 匹配对应出库单 修改出库单备货数量
-                                wmsDocOrderHeaderService.modifystockCompletionStatusAsn(stockForm.getOrderNo(), codeSkuRelationshipVO.getSku(), current
-                                ,stockForm.getSkuSn(),stockForm.getPalletNo(),stockForm.getBoxNo());
+                                break;
                             }
+                        }
+                        WmsDocAsnHeader headerUpdate = new WmsDocAsnHeader();
+                        headerUpdate.setAsnNo(details.getAsnNo());
+                        headerUpdate.setAsnStatus(asnStatus);
+                        headerUpdate.setUpdateBy(loginUser.getUsername());
+                        headerUpdate.setUpdateTime(new Date());
+                        wmsDocAsnHeaderMapper.updateWmsDocAsnHeader(headerUpdate);
+
+                        if (StringUtils.equals(Constants.YES, stockForm.getStockTag())) {
+                            // 匹配对应出库单 修改出库单备货数量
+                            wmsDocOrderHeaderService.modifystockCompletionStatusAsn(stockForm.getOrderNo(), codeSkuRelationshipVO.getSku(), current
+                                    ,stockForm.getSkuSn(),stockForm.getPalletNo(),stockForm.getBoxNo());
+                        }
 
-                            //生成库存
-                            LotattDTO lotattDTO = new LotattDTO();
-                            lotattDTO.setLotatt02(stockForm.getSkuSn());
-                            lotattDTO.setLotatt05("90");
-                            lotattDTO.setLotatt07(stockForm.getPalletNo());
-                            lotattDTO.setLotatt08(details.getAsnNo());
-                            lotattDTO.setLotatt12("Y");
-                            lotattDTO.setLotatt13(DateUtils.dateTimeNow(DateUtils.YYYY_MM_DD));
-                            if (stockForm.getStockTag().equals("Y")) {
-                                lotattDTO.setLotatt14(stockForm.getOrderNo());
-                                // 生成完全分配的库存
-                                invLotLocIdService.initInv(STAGE01.toString(), codeSkuRelationshipVO.getSku(), Constant.CUSTOMER_ID, current.doubleValue(), lotattDTO, current);
-                            } else {
-                                invLotLocIdService.initInv(STAGE01.toString(), codeSkuRelationshipVO.getSku(), Constant.CUSTOMER_ID, current.doubleValue(), lotattDTO, BigDecimal.ZERO);
-                            }
+                        //生成库存
+                        LotattDTO lotattDTO = new LotattDTO();
+                        lotattDTO.setLotatt02(stockForm.getSkuSn());
+                        lotattDTO.setLotatt05("90");
+                        lotattDTO.setLotatt07(stockForm.getPalletNo());
+                        lotattDTO.setLotatt08(details.getAsnNo());
+                        lotattDTO.setLotatt12("Y");
+                        lotattDTO.setLotatt13(DateUtils.dateTimeNow(DateUtils.YYYY_MM_DD));
+                        if (StringUtils.equals(Constants.YES, stockForm.getStockTag())) {
+                            lotattDTO.setLotatt14(stockForm.getOrderNo());
+                            // 生成完全分配的库存
+                            invLotLocIdService.initInv(STAGE01.toString(), codeSkuRelationshipVO.getSku(), Constant.CUSTOMER_ID, current.doubleValue(), lotattDTO, current);
                         } else {
-                            break;
+                            invLotLocIdService.initInv(STAGE01.toString(), codeSkuRelationshipVO.getSku(), Constant.CUSTOMER_ID, current.doubleValue(), lotattDTO, BigDecimal.ZERO);
                         }
                     }
                 }
@@ -515,6 +491,9 @@ public class WmsDocAsnHeaderServiceImpl implements IWmsDocAsnHeaderService {
         return AjaxResult.success("操作成功!" + endMsg.toString());
     }
 
+
+
+
     /**
      * 条码检测
      * 根据入库单和条码查询出未码盘的信息
@@ -565,12 +544,11 @@ public class WmsDocAsnHeaderServiceImpl implements IWmsDocAsnHeaderService {
         LoginUser loginUser = SecurityUtils.getLoginUser();
         //绑定托盘
         String palletNo = paForm.getPalletNo();
-        WmsBoxInfo wmsBoxInfo = new WmsBoxInfo();
-        wmsBoxInfo.setBoxNo(palletNo);
-        wmsBoxInfo = wmsBoxInfoService.selectWmsBoxInfoByModel(wmsBoxInfo);
-        if (wmsBoxInfo == null) {
-            throw new ServiceException("托盘不存在");
-        }
+
+        WmsBoxInfo wmsBoxInfo = getWmsBoxInfo(palletNo);
+        Assert.isTrue(ObjectUtil.isNotNull(wmsBoxInfo) && StringUtils.isNotBlank(wmsBoxInfo.getBoxNo()), "未找到当前可用的托盘");
+        Assert.isTrue(StringUtils.equals(Constants.NO, wmsBoxInfo.getIsFull()), "当前托盘已满托");
+
         BaseLocationInfo locationTo = baseLocationInfoService.selectBaseLocationInfoByIdOrNo(paForm.getLocationTo(), Constant.WAREHOUSE_ID);
         // 校验上架库位必须为入库缓存位或者线边库位
         if (!locationTo.getZoneId().equals(Constant.ZONE_TYPE.ZONE_IN.getValue())
@@ -675,6 +653,10 @@ public class WmsDocAsnHeaderServiceImpl implements IWmsDocAsnHeaderService {
                 .put("orderRules", orderRules);
     }
 
+
+
+
+
     /**
      * 解绑物料
      *
@@ -737,14 +719,13 @@ public class WmsDocAsnHeaderServiceImpl implements IWmsDocAsnHeaderService {
             sum = sum + inv.getQty().intValue();
 
             // 删除条码扫描记录
-            erpBarcodesService.untieRecordErpBarcodeListAsnSo(erpNo,erpName,qtt.getLotatt02());
+            erpBarcodesService.untieRecordErpBarcodeListAsnSo(erpNo, erpName, qtt.getLotatt02());
             // 解绑出库备货单
             if (StringUtils.isNotEmpty(qtt.getLotatt14())) {
                 wmsDocOrderHeaderService.modifystockCompletionStatusAsnUntie(qtt.getLotatt14()
                         ,inv.getSku()
                         ,BigDecimal.ONE
-                        ,qtt.getLotatt02()
-                ,unlockForm.getPalletNo());
+                        ,qtt.getLotatt02());
             }
         }
         return AjaxResult.success("解绑成功!" + unlockForm.getSku() + ",数量:" + sum);
@@ -1000,4 +981,60 @@ public class WmsDocAsnHeaderServiceImpl implements IWmsDocAsnHeaderService {
         }
         return AjaxResult.success();
     }
+
+    /**
+     * 如果存在才更新
+     * @param wmsBoxInfo
+     * @param currentFullTag
+     * @param username
+     * @return
+     */
+    private WmsBoxInfo updateIfExist(WmsBoxInfo wmsBoxInfo, String currentFullTag, String username) {
+        if(ObjectUtil.isNull(wmsBoxInfo) || StringUtils.isBlank(wmsBoxInfo.getBoxNo())) return wmsBoxInfo;
+
+        Assert.isTrue(StringUtils.equals(Constants.NO, wmsBoxInfo.getIsFull()), "当前托盘已满托");
+        wmsBoxInfo.setBoxState(1);//启用状态
+        wmsBoxInfo.setIsFull(currentFullTag);
+        wmsBoxInfo.setIsEmpty("N");
+        wmsBoxInfo.setLocationId(Constant.LOC_STAGE_CACHE);
+        wmsBoxInfo.setUpdateBy(username);
+        wmsBoxInfo.setUpdateTime(new Date());
+        boxInfoService.updateWmsBoxInfo(wmsBoxInfo);
+        return wmsBoxInfo;
+    }
+
+    /**
+     * 如果不存在才新增
+     * @param wmsBoxInfo
+     * @param palletNo
+     * @param username
+     * @return
+     */
+    private WmsBoxInfo insertIfNotExist(WmsBoxInfo wmsBoxInfo, String palletNo, String username) {
+        if(ObjectUtil.isNotNull(wmsBoxInfo) && StringUtils.isNotBlank(wmsBoxInfo.getBoxNo())) return wmsBoxInfo;
+
+        //不存在则创建托盘信息
+        wmsBoxInfo.setBoxNo(palletNo);
+        wmsBoxInfo.setBoxState(1);
+        wmsBoxInfo.setBoxType("pallet");
+        //wmsBoxInfo.setIsFull(stockForm.getFullTag());
+        wmsBoxInfo.setIsEmpty("N");
+        wmsBoxInfo.setLocationId(Constant.LOC_STAGE_CACHE);
+        wmsBoxInfo.setCreateBy(username);
+        wmsBoxInfo.setCreateTime(new Date());
+        wmsBoxInfo.setUpdateBy(username);
+        wmsBoxInfo.setUpdateTime(new Date());
+        boxInfoService.insertWmsBoxInfo(wmsBoxInfo);
+        return wmsBoxInfo;
+    }
+
+    private WmsBoxInfo getWmsBoxInfo(String palletNo) {
+        if(StringUtils.isBlank(palletNo)) return new WmsBoxInfo();
+        WmsBoxInfo wmsBoxInfo = new WmsBoxInfo();
+        wmsBoxInfo.setBoxNo(palletNo);
+        wmsBoxInfo.setBoxState(1);
+        return wmsBoxInfoService.selectWmsBoxInfoByModel(wmsBoxInfo);
+    }
+
+
 }

+ 9 - 15
warewms-ams/src/main/java/com/ruoyi/ams/box/service/impl/WmsBoxInfoServiceImpl.java

@@ -1,25 +1,23 @@
 package com.ruoyi.ams.box.service.impl;
 
-import java.util.Date;
-import java.util.List;
-
+import com.ruoyi.ams.box.domain.WmsBoxInfo;
 import com.ruoyi.ams.box.form.AddBoxForm;
+import com.ruoyi.ams.box.mapper.WmsBoxInfoMapper;
+import com.ruoyi.ams.box.service.IWmsBoxInfoService;
 import com.ruoyi.ams.inv.domain.InvLotAtt;
 import com.ruoyi.ams.inv.domain.InvLotLocId;
 import com.ruoyi.ams.inv.mapper.InvLotLocIdMapper;
-import com.ruoyi.base.constant.Constant;
-import com.ruoyi.base.domain.BaseLocationInfo;
 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;
-import org.springframework.beans.BeanUtils;
+import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-import com.ruoyi.ams.box.mapper.WmsBoxInfoMapper;
-import com.ruoyi.ams.box.domain.WmsBoxInfo;
-import com.ruoyi.ams.box.service.IWmsBoxInfoService;
+
+import java.util.Date;
+import java.util.List;
 
 /**
  * 容器管理Service业务层处理
@@ -76,12 +74,8 @@ public class WmsBoxInfoServiceImpl implements IWmsBoxInfoService {
      */
     @Override
     public WmsBoxInfo selectWmsBoxInfoByModel(WmsBoxInfo wmsBoxInfo) {
-        List<WmsBoxInfo> list = wmsBoxInfoMapper.selectWmsBoxInfoList(wmsBoxInfo);
-        if (list != null && list.size() > 0) {
-            return list.get(0);
-        } else {
-            return null;
-        }
+        List<WmsBoxInfo> wmsBoxInfoList = wmsBoxInfoMapper.selectWmsBoxInfoList(wmsBoxInfo);
+        return CollectionUtils.isNotEmpty(wmsBoxInfoList)? wmsBoxInfoList.get(0) : new WmsBoxInfo();
     }
 
     /**

+ 12 - 9
warewms-ams/src/main/java/com/ruoyi/ams/erp/service/impl/ErpBarcodesServiceImpl.java

@@ -15,6 +15,7 @@ import com.ruoyi.base.constant.Constant;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.StringUtils;
+import io.jsonwebtoken.lang.Assert;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -146,7 +147,7 @@ public class ErpBarcodesServiceImpl implements IErpBarcodesService {
         erpBarcodesS.setBarcode(sn);
         ErpBarcodes erpBarcodesG = this.selectErpBarcodesByModel(erpBarcodesS);
         if (erpBarcodesG != null) {
-            this.untieRecordErpBarcodeList(erpNo, erpName, sn);
+            this.untieRecordErpBarcodeList(erpNo, palletNo, erpName, sn);
             return AjaxResult.success("");
         }
         // 插入新的
@@ -177,17 +178,15 @@ public class ErpBarcodesServiceImpl implements IErpBarcodesService {
         WmsDocOrderHeader wmsDocOrderHeader = wmsDocOrderHeaderService.selectDocOrderHeaderByOrderNo(orderNo);
         String erpNo = wmsDocOrderHeader.getSoReference1();
         //先查一下有没有
-        String erpName = details.getdEdi07() == null ? "" : details.getdEdi07();
-        if (StringUtils.isEmpty(erpName)) {
-            return AjaxResult.success();
-        }
+        if(StringUtils.isBlank(details.getdEdi07())) return AjaxResult.success();
+
         ErpBarcodes erpBarcodesS = new ErpBarcodes();
         erpBarcodesS.setErpNo(erpNo);
-        erpBarcodesS.setErpName(erpName);
+        erpBarcodesS.setErpName(details.getdEdi07());
         erpBarcodesS.setBarcode(sn);
         ErpBarcodes erpBarcodesG = this.selectErpBarcodesByModel(erpBarcodesS);
         if (erpBarcodesG != null) {
-            this.untieRecordErpBarcodeList(erpNo, erpName, sn);
+            this.untieRecordErpBarcodeList(erpNo, palletNo, details.getdEdi07(), sn);
             return AjaxResult.success("");
         }
         ErpBarcodes erpBarcodes = new ErpBarcodes();
@@ -199,7 +198,7 @@ public class ErpBarcodesServiceImpl implements IErpBarcodesService {
         erpBarcodes.setQty(qty); // 数量
         erpBarcodes.setType(details.getdEdi09() == null ? "" : details.getdEdi09()); // 出入库类型
         erpBarcodes.setErpNo(erpNo); // ERP单号
-        erpBarcodes.setErpName(details.getdEdi07() == null ? "" : details.getdEdi07());
+        erpBarcodes.setErpName(details.getdEdi07());//Erp的名称
         erpBarcodes.setUserdefine7(details.getdEdi08() == null ? "" : details.getdEdi08()); // ERP单据类型
         erpBarcodes.setUserdefine5(palletNo); // 托盘号
         erpBarcodes.setUserdefine3(details.getdEdi11() == null ? "" : details.getdEdi11()); // 人员
@@ -211,7 +210,7 @@ public class ErpBarcodesServiceImpl implements IErpBarcodesService {
     }
 
 
-    private AjaxResult untieRecordErpBarcodeList(String erpNo, String erpName, String sn) {
+    private AjaxResult untieRecordErpBarcodeList(String erpNo, String palletNo, String erpName, String sn) {
         if (StringUtils.isEmpty(erpName)) {
             return AjaxResult.success();
         }
@@ -220,11 +219,13 @@ public class ErpBarcodesServiceImpl implements IErpBarcodesService {
         erpBarcodes.setErpName(erpName);
         erpBarcodes.setBarcode(sn);
         erpBarcodes.setUserdefine1("Y");
+        erpBarcodes.setUserdefine5(palletNo);
         erpBarcodes.setUserdefine8("N");
         this.updateErpBarcodesBySn(erpBarcodes);
         return AjaxResult.success();
     }
 
+
     @Override
     public AjaxResult untieRecordErpBarcodeListAsnSo(String erpNo, String erpName, String sn) {
         if (StringUtils.isEmpty(erpName)) {
@@ -234,6 +235,7 @@ public class ErpBarcodesServiceImpl implements IErpBarcodesService {
             ErpBarcodes erpBarcodes1 = this.selectErpBarcodesByModel(erpBarcodes);
             if (erpBarcodes1 != null) {
                 erpBarcodes1.setUserdefine1("N");
+                erpBarcodes1.setUserdefine5(null);
                 erpBarcodes1.setUserdefine8("N");
                 this.updateErpBarcodes(erpBarcodes1);
             }
@@ -244,6 +246,7 @@ public class ErpBarcodesServiceImpl implements IErpBarcodesService {
         erpBarcodes.setErpName(erpName);
         erpBarcodes.setBarcode(sn);
         erpBarcodes.setUserdefine1("N");
+        erpBarcodes.setUserdefine5(null);
         erpBarcodes.setUserdefine8("N");
         this.updateErpBarcodesBySn(erpBarcodes);
         return AjaxResult.success();

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

@@ -411,6 +411,6 @@ public interface IWmsDocOrderHeaderService {
      * @return
      */
     AjaxResult modifystockCompletionStatusAsnUntie(String orderNo, String sku, BigDecimal qty
-            ,String sn,String palletNo);
+            ,String sn);
 
 }

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

@@ -2658,7 +2658,7 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
 
     @Transactional
     @Override
-    public AjaxResult modifystockCompletionStatusAsnUntie(String orderNo, String sku, BigDecimal qty, String sn, String palletNo) {
+    public AjaxResult modifystockCompletionStatusAsnUntie(String orderNo, String sku, BigDecimal qty, String sn) {
         WmsDocOrderHeader docOrderHeader = wmsDocOrderHeaderService.selectWmsDocOrderHeaderByOrderNo(orderNo);
         // 明细
         List<WmsDocOrderDetails> wmsDocOrderDetails = wmsDocOrderDetailsMapper.selectWmsDocOrderDetailsByOrderNo(orderNo);

+ 5 - 1
warewms-ams/src/main/resources/mapper/erp/ErpBarcodesMapper.xml

@@ -146,7 +146,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <update id="updateErpBarcodesBySn" parameterType="ErpBarcodes">
         update erp_barcodes
-        set userdefine1 = #{userdefine1},userdefine8 = #{userdefine8}
+        <set>
+            userdefine1 = #{userdefine1}, userdefine8 = #{userdefine8},
+            <if test="userdefine5 != null">userdefine5 = #{userdefine5},</if>
+            <if test="userdefine5 == null">userdefine5 = null,</if>
+        </set>
         where barcode = #{barcode} and erp_no = #{erpNo} and erp_name = #{erpName}
     </update>