Browse Source

PDA入库码盘和解绑逻辑优化

k 2 years ago
parent
commit
bd3354de7a

+ 91 - 49
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/AjaxResult.java

@@ -1,161 +1,203 @@
 package com.ruoyi.common.core.domain;
 
-import java.util.HashMap;
+import com.alibaba.fastjson.JSON;
 import com.ruoyi.common.constant.HttpStatus;
 import com.ruoyi.common.utils.StringUtils;
 
+import java.util.HashMap;
+import java.util.List;
+
 /**
  * 操作消息提醒
- * 
+ *
  * @author ruoyi
  */
-public class AjaxResult extends HashMap<String, Object>
-{
+public class AjaxResult extends HashMap<String, Object> {
     private static final long serialVersionUID = 1L;
 
-    /** 状态码 */
+    /**
+     * 状态码
+     */
     public static final String CODE_TAG = "code";
 
-    /** 返回内容 */
+    /**
+     * 返回内容
+     */
     public static final String MSG_TAG = "msg";
 
-    /** 数据对象 */
+    /**
+     * 数据对象
+     */
     public static final String DATA_TAG = "data";
 
     /**
      * 初始化一个新创建的 AjaxResult 对象,使其表示一个空消息。
      */
-    public AjaxResult()
-    {
+    public AjaxResult() {
     }
 
     /**
      * 初始化一个新创建的 AjaxResult 对象
-     * 
+     *
      * @param code 状态码
-     * @param msg 返回内容
+     * @param msg  返回内容
      */
-    public AjaxResult(int code, String msg)
-    {
+    public AjaxResult(int code, String msg) {
         super.put(CODE_TAG, code);
         super.put(MSG_TAG, msg);
     }
 
     /**
      * 初始化一个新创建的 AjaxResult 对象
-     * 
+     *
      * @param code 状态码
-     * @param msg 返回内容
+     * @param msg  返回内容
      * @param data 数据对象
      */
-    public AjaxResult(int code, String msg, Object data)
-    {
+    public AjaxResult(int code, String msg, Object data) {
         super.put(CODE_TAG, code);
         super.put(MSG_TAG, msg);
-        if (StringUtils.isNotNull(data))
-        {
+        if (StringUtils.isNotNull(data)) {
             super.put(DATA_TAG, data);
         }
     }
 
+    /**
+     * 是否成功
+     *
+     * @return
+     */
+    public boolean isSuccess() {
+        return (int) super.get(CODE_TAG) == 200;
+    }
+
+    /**
+     * 获取反馈
+     *
+     * @return
+     */
+    public String getMsg() {
+        return (String) super.get(MSG_TAG);
+    }
+
+    /**
+     * 获取数据
+     *
+     * @return
+     */
+    public Object getData() {
+        return super.get(DATA_TAG);
+    }
+
+    /**
+     * 获取数据
+     *
+     * @return
+     */
+    public <T> T getDataParseObject(Class<T> clazz) {
+        String json = JSON.toJSONString(getData());
+        return JSON.parseObject(json, clazz);
+    }
+
+    /**
+     * 获取数据
+     *
+     * @return
+     */
+    public <T> List<T> getDataParseArray(Class<T> clazz) {
+        String json = JSON.toJSONString(getData());
+        return JSON.parseArray(json, clazz);
+    }
+
     /**
      * 返回成功消息
-     * 
+     *
      * @return 成功消息
      */
-    public static AjaxResult success()
-    {
+    public static AjaxResult success() {
         return AjaxResult.success("操作成功");
     }
 
     /**
      * 返回成功数据
-     * 
+     *
      * @return 成功消息
      */
-    public static AjaxResult success(Object data)
-    {
+    public static AjaxResult success(Object data) {
         return AjaxResult.success("操作成功", data);
     }
 
     /**
      * 返回成功消息
-     * 
+     *
      * @param msg 返回内容
      * @return 成功消息
      */
-    public static AjaxResult success(String msg)
-    {
+    public static AjaxResult success(String msg) {
         return AjaxResult.success(msg, null);
     }
 
     /**
      * 返回成功消息
-     * 
-     * @param msg 返回内容
+     *
+     * @param msg  返回内容
      * @param data 数据对象
      * @return 成功消息
      */
-    public static AjaxResult success(String msg, Object data)
-    {
+    public static AjaxResult success(String msg, Object data) {
         return new AjaxResult(HttpStatus.SUCCESS, msg, data);
     }
 
     /**
      * 返回错误消息
-     * 
+     *
      * @return
      */
-    public static AjaxResult error()
-    {
+    public static AjaxResult error() {
         return AjaxResult.error("操作失败");
     }
 
     /**
      * 返回错误消息
-     * 
+     *
      * @param msg 返回内容
      * @return 警告消息
      */
-    public static AjaxResult error(String msg)
-    {
+    public static AjaxResult error(String msg) {
         return AjaxResult.error(msg, null);
     }
 
     /**
      * 返回错误消息
-     * 
-     * @param msg 返回内容
+     *
+     * @param msg  返回内容
      * @param data 数据对象
      * @return 警告消息
      */
-    public static AjaxResult error(String msg, Object data)
-    {
+    public static AjaxResult error(String msg, Object data) {
         return new AjaxResult(HttpStatus.ERROR, msg, data);
     }
 
     /**
      * 返回错误消息
-     * 
+     *
      * @param code 状态码
-     * @param msg 返回内容
+     * @param msg  返回内容
      * @return 警告消息
      */
-    public static AjaxResult error(int code, String msg)
-    {
+    public static AjaxResult error(int code, String msg) {
         return new AjaxResult(code, msg, null);
     }
 
     /**
      * 方便链式调用
      *
-     * @param key 键
+     * @param key   
      * @param value 值
      * @return 数据对象
      */
     @Override
-    public AjaxResult put(String key, Object value)
-    {
+    public AjaxResult put(String key, Object value) {
         super.put(key, value);
         return this;
     }

+ 2 - 0
warewms-ams/src/main/java/com/ruoyi/ams/asn/service/IWmsDocAsnHeaderService.java

@@ -160,6 +160,8 @@ public interface IWmsDocAsnHeaderService {
     int closeHeader(String asnNo);
 
     /**
+     * 查询已码盘列表
+     *
      * @param asnNos
      * @return
      */

+ 35 - 17
warewms-ams/src/main/java/com/ruoyi/ams/asn/service/impl/WmsDocAsnHeaderServiceImpl.java

@@ -21,6 +21,7 @@ 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.InvLotLocIdMoveForm;
+import com.ruoyi.ams.inv.domain.vo.InvLotLocIdLotattVO;
 import com.ruoyi.ams.inv.mapper.InvLotLocIdMapper;
 import com.ruoyi.ams.inv.service.IActTransactionLogService;
 import com.ruoyi.ams.inv.service.IInvLotAttService;
@@ -284,8 +285,9 @@ public class WmsDocAsnHeaderServiceImpl implements IWmsDocAsnHeaderService {
             wmsBoxInfo.setBoxNo(stockForm.getPalletNo());
             wmsBoxInfo.setBoxState(1);
             wmsBoxInfo.setBoxType("pallet");
-            wmsBoxInfo.setIsEmpty("N");
             wmsBoxInfo.setIsFull(stockForm.getFullTag());
+            wmsBoxInfo.setIsEmpty("N");
+            wmsBoxInfo.setLocationId(Long.parseLong(STAGE01));
             wmsBoxInfo.setCreateBy(loginUser.getUsername());
             wmsBoxInfo.setCreateTime(new Date());
             wmsBoxInfo.setUpdateBy(loginUser.getUsername());
@@ -297,11 +299,11 @@ public class WmsDocAsnHeaderServiceImpl implements IWmsDocAsnHeaderService {
                 throw new ServiceException("该托盘已放满");
             }
             wmsBoxInfo.setBoxState(1);//启用状态
+            wmsBoxInfo.setIsFull(stockForm.getFullTag());
+            wmsBoxInfo.setIsEmpty("N");
             wmsBoxInfo.setLocationId(Long.parseLong(STAGE01));
             wmsBoxInfo.setUpdateBy(loginUser.getUsername());
             wmsBoxInfo.setUpdateTime(new Date());
-            wmsBoxInfo.setIsFull(stockForm.getFullTag());
-            wmsBoxInfo.setIsEmpty("N");
             boxInfoService.updateWmsBoxInfo(wmsBoxInfo);
         }
 
@@ -387,15 +389,31 @@ public class WmsDocAsnHeaderServiceImpl implements IWmsDocAsnHeaderService {
                 return AjaxResult.error("没有可以接收的入库单");
             } else {
                 for (WmsDocAsnDetails details : list) {
-                    InvLotAtt attQuery = new InvLotAtt();
-                    attQuery.setSku(codeSkuRelationshipVO.getSku());
-                    attQuery.setLotatt07(stockForm.getPalletNo());
-                    attQuery.setLotatt02(codeSkuRelationshipVO.getSn());
-                    attQuery.setLotatt08(details.getAsnNo());
-                    attQuery.setLotatt14(stockForm.getOrderNo());
-                    List<InvLotLocId> samePalletInvList = invLotLocIdMapper.queryInvByInvLotatt(attQuery);
-                    if (samePalletInvList != null && samePalletInvList.size() > 0) {
-                        throw new ServiceException("每个成品条码相同托盘只允许码一次");
+                    // 成品条码,扫码新托盘的时候,自动解绑老托盘数据。
+                    if(codeSkuRelationshipVO.isProduct()) {
+                        InvLotAtt attQuery = new InvLotAtt();
+                        attQuery.setSku(codeSkuRelationshipVO.getSku());
+//                        attQuery.setLotatt07(stockForm.getPalletNo());
+                        attQuery.setLotatt02(codeSkuRelationshipVO.getSn());
+                        attQuery.setLotatt08(details.getAsnNo());
+                        attQuery.setLotatt14(stockForm.getOrderNo());
+                        List<InvLotLocIdLotattVO> samePalletInvList = invLotLocIdMapper.queryInvLotattByInvLotatt(attQuery);
+                        if (samePalletInvList != null && samePalletInvList.size() > 0) {
+                            for (InvLotLocIdLotattVO locIdLotattVO : samePalletInvList) {
+                                if (locIdLotattVO.getLotatt07().equals(stockForm.getPalletNo())) {
+                                    throw new ServiceException("每个成品条码只允许码盘一次");
+                                }
+                                // 解绑老托盘
+                                UnlockForm unlockForm = new UnlockForm();
+                                unlockForm.setPalletNo(locIdLotattVO.getLotatt07());
+                                unlockForm.setSku(locIdLotattVO.getSku());
+                                unlockForm.setLotnum(locIdLotattVO.getLotnum());
+                                AjaxResult ajaxResult = unloadStock(unlockForm);
+                                if (!ajaxResult.isSuccess()) {
+                                    throw new ServiceException("解绑老托盘失败:" + ajaxResult.getMsg());
+                                }
+                            }
+                        }
                     }
 
                     //如果入库单预计数量大于接收数
@@ -427,7 +445,7 @@ public class WmsDocAsnHeaderServiceImpl implements IWmsDocAsnHeaderService {
                                 throw new ServiceException("更新接收数失败");
                             }
                             if (!StringUtils.isEmpty(stockForm.getOrderNo())) {
-                                //绑定对应入库单号
+                                //绑定对应入库单号 todo 这边修改了个寂寞
                                 WmsDocAsnDetails updateDetails = new WmsDocAsnDetails();
                                 updateDetails.setAsnNo(details.getAsnNo());
                                 updateDetails.setAsnLineNo(details.getAsnLineNo());
@@ -566,10 +584,10 @@ public class WmsDocAsnHeaderServiceImpl implements IWmsDocAsnHeaderService {
     public AjaxResult unloadStock(UnlockForm unlockForm) {
         WmsBoxInfo wmsBoxInfo = wmsBoxInfoService.selectWmsBoxInfoByBoxNo(unlockForm.getPalletNo());
         if (wmsBoxInfo == null) {
-            return AjaxResult.error("查询不到托盘");
+            return AjaxResult.error("查询不到托盘" + unlockForm.getPalletNo());
         }
         if (wmsBoxInfo.getLocationId() == null) {
-            return AjaxResult.error("托盘未绑定");
+            return AjaxResult.error("托盘未绑定库位:" + unlockForm.getPalletNo());
         }
 
         //把托盘设置成非满拖
@@ -582,7 +600,7 @@ public class WmsDocAsnHeaderServiceImpl implements IWmsDocAsnHeaderService {
         query.setLocationId(wmsBoxInfo.getLocationId().toString());
         List<InvLotLocId> invLotLocIdList = invLotLocIdMapper.selectInvLotLocIdList(query);
         if (invLotLocIdList == null || invLotLocIdList.size() == 0) {
-            return AjaxResult.error("该托盘不存在库存");
+            return AjaxResult.error("该托盘不存在库存:" + unlockForm.getPalletNo());
         }
         for (InvLotLocId inv : invLotLocIdList) {
             //修改入库单的接收数
@@ -595,7 +613,7 @@ public class WmsDocAsnHeaderServiceImpl implements IWmsDocAsnHeaderService {
             for (WmsDocAsnDetails d : details) {
                 wmsDocAsnDetailsMapper.updateWmsReceivedQty(d.getAsnNo(), d.getAsnLineNo().intValue(), BigDecimal.valueOf(-1 * inv.getQty().doubleValue()), "30");
             }
-            //删除库存
+            //删除库存 todo 物料增加库存的时候如果改成根据相同库存和批次可以累加数量,这边就需要减库存,而不是直接删除
             invLotLocIdMapper.deleteInvLotLocIdBy(inv.getLotnum(), inv.getSku(), inv.getLocationId(), inv.getCustomerId());
         }
         //查询分配单

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

@@ -228,11 +228,18 @@ public interface InvLotLocIdMapper {
      * 根据托盘查询库存
      *
      * @param invLotAtt
-     * @param boxNo
      * @return
      */
     List<InvLotLocId> queryInvByInvLotatt(@Param("lotattDTO") InvLotAtt invLotAtt);
 
+    /**
+     * 根据托盘查询库存(带出批次)
+     *
+     * @param invLotAtt
+     * @return
+     */
+    List<InvLotLocIdLotattVO> queryInvLotattByInvLotatt(@Param("lotattDTO") InvLotAtt invLotAtt);
+
     /**
      * 查询
      *

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

@@ -480,6 +480,7 @@ public class InvLotLocIdServiceImpl implements IInvLotLocIdService {
         invLotAtt.setSku(sku);
         //查询lotatt是否存在
         String lotnum;
+        // todo 注释掉的可能以后会用到,物料码盘的时候同sku批次都是一样的,所以需要在原有库存上进行累加。
 //        List<InvLotAtt> queryList = invLotAttMapper.selectInvLotAttList(invLotAtt);
         List<InvLotAtt> queryList = new ArrayList<>();
 //        if (queryList != null && queryList.size() > 0) {

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

@@ -544,6 +544,35 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </where>
     </select>
 
+    <select id="queryInvLotattByInvLotatt" resultMap="InvLotLocIdLotattResult">
+        select li.*,att.lotatt01,att.lotatt02,att.lotatt03,att.lotatt04,att.lotatt05,att.lotatt06,att.lotatt07,att.lotatt08,att.lotatt09
+             ,att.lotatt10,att.lotatt11,att.lotatt12,att.lotatt13,att.lotatt14,att.lotatt15,att.lotatt16,att.lotatt17,att.lotatt18
+        from inv_lot_loc_id li
+        left join inv_lot_att att on li.lotnum = att.lotnum
+        <where>
+            <if test="lotattDTO != null">
+                <if test="lotattDTO.lotatt01 != null  and lotattDTO.lotatt01 != ''"> and att.lotatt01 = #{lotattDTO.lotatt01}</if>
+                <if test="lotattDTO.lotatt02 != null  and lotattDTO.lotatt02 != ''"> and att.lotatt02 = #{lotattDTO.lotatt02}</if>
+                <if test="lotattDTO.lotatt03 != null  and lotattDTO.lotatt03 != ''"> and att.lotatt03 = #{lotattDTO.lotatt03}</if>
+                <if test="lotattDTO.lotatt04 != null  and lotattDTO.lotatt04 != ''"> and att.lotatt04 = #{lotattDTO.lotatt04}</if>
+                <if test="lotattDTO.lotatt05 != null  and lotattDTO.lotatt05 != ''"> and att.lotatt05 = #{lotattDTO.lotatt05}</if>
+                <if test="lotattDTO.lotatt06 != null  and lotattDTO.lotatt06 != ''"> and att.lotatt06 = #{lotattDTO.lotatt06}</if>
+                <if test="lotattDTO.lotatt07 != null  and lotattDTO.lotatt07 != ''"> and att.lotatt07 = #{lotattDTO.lotatt07}</if>
+                <if test="lotattDTO.lotatt08 != null  and lotattDTO.lotatt08 != ''"> and att.lotatt08 = #{lotattDTO.lotatt08}</if>
+                <if test="lotattDTO.lotatt09 != null  and lotattDTO.lotatt09 != ''"> and att.lotatt09 = #{lotattDTO.lotatt09}</if>
+                <if test="lotattDTO.lotatt10 != null  and lotattDTO.lotatt10 != ''"> and att.lotatt10 = #{lotattDTO.lotatt10}</if>
+                <if test="lotattDTO.lotatt11 != null  and lotattDTO.lotatt11 != ''"> and att.lotatt11 = #{lotattDTO.lotatt11}</if>
+                <if test="lotattDTO.lotatt12 != null  and lotattDTO.lotatt12 != ''"> and att.lotatt12 = #{lotattDTO.lotatt12}</if>
+                <if test="lotattDTO.lotatt13 != null  and lotattDTO.lotatt13 != ''"> and att.lotatt13 = #{lotattDTO.lotatt13}</if>
+                <if test="lotattDTO.lotatt14 != null  and lotattDTO.lotatt14 != ''"> and att.lotatt14 = #{lotattDTO.lotatt14}</if>
+                <if test="lotattDTO.lotatt15 != null  and lotattDTO.lotatt15 != ''"> and att.lotatt15 = #{lotattDTO.lotatt15}</if>
+                <if test="lotattDTO.lotatt16 != null  and lotattDTO.lotatt16 != ''"> and att.lotatt16 = #{lotattDTO.lotatt16}</if>
+                <if test="lotattDTO.lotatt17 != null  and lotattDTO.lotatt17 != ''"> and att.lotatt17 = #{lotattDTO.lotatt17}</if>
+                <if test="lotattDTO.lotatt18 != null  and lotattDTO.lotatt18 != ''"> and att.lotatt18 = #{lotattDTO.lotatt18}</if>
+            </if>
+        </where>
+    </select>
+
     <select id="queryInvByFull" resultMap="InvLotLocIdResult">
         select inv.*
         from inv_lot_loc_id inv