Explorar o código

条码扫描记录

zhangxin hai 1 ano
pai
achega
ecc79f2ba0

+ 11 - 200
warewms-ams/src/main/java/com/ruoyi/ams/erp/domain/ErpBarcodes.java

@@ -1,10 +1,11 @@
 package com.ruoyi.ams.erp.domain;
 
-import java.math.BigDecimal;
-import org.apache.commons.lang3.builder.ToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.ruoyi.common.annotation.Excel;
 import com.ruoyi.common.core.domain.BaseEntity;
+import lombok.Data;
+
+import java.math.BigDecimal;
 
 /**
  * 条码扫描记录表对象 erp_barcodes
@@ -12,6 +13,7 @@ import com.ruoyi.common.core.domain.BaseEntity;
  * @author ruoyi
  * @date 2023-03-10
  */
+@Data
 public class ErpBarcodes extends BaseEntity
 {
     private static final long serialVersionUID = 1L;
@@ -79,204 +81,13 @@ public class ErpBarcodes extends BaseEntity
     /** 预留字段5 */
     private String userdefine8;
 
-    public void setId(Long id)
-    {
-        this.id = id;
-    }
-
-    public Long getId()
-    {
-        return id;
-    }
-    public void setBarcode(String barcode)
-    {
-        this.barcode = barcode;
-    }
-
-    public String getBarcode()
-    {
-        return barcode;
-    }
-    public void setStockId(String stockId)
-    {
-        this.stockId = stockId;
-    }
-
-    public String getStockId()
-    {
-        return stockId;
-    }
-    public void setLocationNo(String locationNo)
-    {
-        this.locationNo = locationNo;
-    }
-
-    public String getLocationNo()
-    {
-        return locationNo;
-    }
-    public void setBoxNo(String boxNo)
-    {
-        this.boxNo = boxNo;
-    }
-
-    public String getBoxNo()
-    {
-        return boxNo;
-    }
-    public void setLotnum(String lotnum)
-    {
-        this.lotnum = lotnum;
-    }
-
-    public String getLotnum()
-    {
-        return lotnum;
-    }
-    public void setQty(BigDecimal qty)
-    {
-        this.qty = qty;
-    }
-
-    public BigDecimal getQty()
-    {
-        return qty;
-    }
-    public void setType(String type)
-    {
-        this.type = type;
-    }
-
-    public String getType()
-    {
-        return type;
-    }
-    public void setErpNo(String erpNo)
-    {
-        this.erpNo = erpNo;
-    }
-
-    public String getErpNo()
-    {
-        return erpNo;
-    }
-    public void setErpName(String erpName)
-    {
-        this.erpName = erpName;
-    }
-
-    public String getErpName()
-    {
-        return erpName;
-    }
-    public void setErpType(String erpType)
-    {
-        this.erpType = erpType;
-    }
-
-    public String getErpType()
-    {
-        return erpType;
-    }
-    public void setUserdefine1(String userdefine1)
-    {
-        this.userdefine1 = userdefine1;
-    }
-
-    public String getUserdefine1()
-    {
-        return userdefine1;
-    }
-    public void setUserdefine2(String userdefine2)
-    {
-        this.userdefine2 = userdefine2;
-    }
-
-    public String getUserdefine2()
-    {
-        return userdefine2;
-    }
-    public void setUserdefine3(String userdefine3)
-    {
-        this.userdefine3 = userdefine3;
-    }
-
-    public String getUserdefine3()
-    {
-        return userdefine3;
-    }
-    public void setUserdefine4(String userdefine4)
-    {
-        this.userdefine4 = userdefine4;
-    }
-
-    public String getUserdefine4()
-    {
-        return userdefine4;
-    }
-    public void setUserdefine5(String userdefine5)
-    {
-        this.userdefine5 = userdefine5;
-    }
-
-    public String getUserdefine5()
-    {
-        return userdefine5;
-    }
-    public void setUserdefine6(String userdefine6)
-    {
-        this.userdefine6 = userdefine6;
-    }
-
-    public String getUserdefine6()
-    {
-        return userdefine6;
-    }
-    public void setUserdefine7(String userdefine7)
-    {
-        this.userdefine7 = userdefine7;
-    }
+    @TableField(exist = false)
+    private String sku;
 
-    public String getUserdefine7()
-    {
-        return userdefine7;
-    }
-    public void setUserdefine8(String userdefine8)
-    {
-        this.userdefine8 = userdefine8;
-    }
+    @TableField(exist = false)
+    private String model;
 
-    public String getUserdefine8()
-    {
-        return userdefine8;
-    }
+    @TableField(exist = false)
+    private String desc1;
 
-    @Override
-    public String toString() {
-        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
-            .append("id", getId())
-            .append("barcode", getBarcode())
-            .append("stockId", getStockId())
-            .append("locationNo", getLocationNo())
-            .append("boxNo", getBoxNo())
-            .append("lotnum", getLotnum())
-            .append("qty", getQty())
-            .append("type", getType())
-            .append("erpNo", getErpNo())
-            .append("erpName", getErpName())
-            .append("erpType", getErpType())
-            .append("createTime", getCreateTime())
-            .append("createBy", getCreateBy())
-            .append("updateTime", getUpdateTime())
-            .append("updateBy", getUpdateBy())
-            .append("userdefine1", getUserdefine1())
-            .append("userdefine2", getUserdefine2())
-            .append("userdefine3", getUserdefine3())
-            .append("userdefine4", getUserdefine4())
-            .append("userdefine5", getUserdefine5())
-            .append("userdefine6", getUserdefine6())
-            .append("userdefine7", getUserdefine7())
-            .append("userdefine8", getUserdefine8())
-            .toString();
-    }
 }

+ 37 - 8
warewms-ams/src/main/java/com/ruoyi/ams/erp/service/impl/ErpBarcodesServiceImpl.java

@@ -6,21 +6,26 @@ import com.ruoyi.ams.asn.service.IWmsDocAsnHeaderService;
 import com.ruoyi.ams.erp.domain.ErpBarcodes;
 import com.ruoyi.ams.erp.mapper.ErpBarcodesMapper;
 import com.ruoyi.ams.erp.service.IErpBarcodesService;
-import com.ruoyi.ams.inv.domain.InvLotAtt;
 import com.ruoyi.ams.order.domain.WmsDocOrderDetails;
 import com.ruoyi.ams.order.domain.WmsDocOrderHeader;
-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.IBaseSkuTypeService;
+import com.ruoyi.base.service.ICodeSkuRelationshipService;
 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.apache.commons.collections4.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.math.BigDecimal;
 import java.util.List;
+import java.util.Map;
+import java.util.function.Function;
+import java.util.stream.Collectors;
 
 /**
  * 条码扫描记录表Service业务层处理
@@ -37,6 +42,15 @@ public class ErpBarcodesServiceImpl implements IErpBarcodesService {
     @Autowired
     private IWmsDocOrderHeaderService wmsDocOrderHeaderService;
 
+    @Autowired
+    private IBaseSkuService baseSkuService;
+
+    @Autowired
+    private IBaseSkuTypeService baseSkuTypeService;
+
+    @Autowired
+    private ICodeSkuRelationshipService codeSkuRelationshipService;
+
     /**
      * 查询条码扫描记录表
      *
@@ -56,7 +70,21 @@ public class ErpBarcodesServiceImpl implements IErpBarcodesService {
      */
     @Override
     public List<ErpBarcodes> selectErpBarcodesList(ErpBarcodes erpBarcodes) {
-        return erpBarcodesMapper.selectErpBarcodesList(erpBarcodes);
+        List<ErpBarcodes> erpBarcodesList = erpBarcodesMapper.selectErpBarcodesList(erpBarcodes);
+        if (CollectionUtils.isEmpty(erpBarcodesList)) return erpBarcodesList;
+        List<CodeSkuRelationshipVO> codeSkuRelationshipList = codeSkuRelationshipService.selectCodeSkuRelationshipVOList(erpBarcodesList.stream().map(ErpBarcodes::getBarcode).collect(Collectors.toList()));
+        if (CollectionUtils.isEmpty(codeSkuRelationshipList)) return erpBarcodesList;
+        Map<String, String> codeSkuMap = codeSkuRelationshipList.stream().collect(Collectors.toMap(CodeSkuRelationshipVO::getSn, CodeSkuRelationshipVO::getSku));
+        List<BaseSku> baseSkuList = baseSkuService.queryActiveSkuList(codeSkuRelationshipList.stream().map(CodeSkuRelationshipVO::getSku).collect(Collectors.toList()));
+        Map<String, BaseSku> baseSkuMap = baseSkuList.stream().collect(Collectors.toMap(BaseSku::getSku, Function.identity()));
+        erpBarcodesList.forEach(item -> {
+            String sku = codeSkuMap.get(item.getBarcode());
+            BaseSku baseSku = baseSkuMap.get(sku);
+            item.setSku(sku);
+            item.setModel(baseSku.getModel());
+            item.setDesc1(baseSku.getDesc1());
+        });
+        return erpBarcodesList;
     }
 
     /**
@@ -147,7 +175,7 @@ public class ErpBarcodesServiceImpl implements IErpBarcodesService {
         erpBarcodesS.setBarcode(sn);
         ErpBarcodes erpBarcodesG = this.selectErpBarcodesByModel(erpBarcodesS);
         if (erpBarcodesG != null) {
-            this.untieRecordErpBarcodeList(erpNo, palletNo, erpName, sn);
+            this.untieRecordErpBarcodeList(erpNo, palletNo, erpName, sn, boxNo);
             return AjaxResult.success("");
         }
         // 插入新的
@@ -186,7 +214,7 @@ public class ErpBarcodesServiceImpl implements IErpBarcodesService {
         erpBarcodesS.setBarcode(sn);
         ErpBarcodes erpBarcodesG = this.selectErpBarcodesByModel(erpBarcodesS);
         if (erpBarcodesG != null) {
-            this.untieRecordErpBarcodeList(erpNo, palletNo, details.getdEdi07(), sn);
+            this.untieRecordErpBarcodeList(erpNo, palletNo, details.getdEdi07(), sn, boxNo);
             return AjaxResult.success("");
         }
         ErpBarcodes erpBarcodes = new ErpBarcodes();
@@ -210,7 +238,7 @@ public class ErpBarcodesServiceImpl implements IErpBarcodesService {
     }
 
 
-    private AjaxResult untieRecordErpBarcodeList(String erpNo, String palletNo, String erpName, String sn) {
+    private AjaxResult untieRecordErpBarcodeList(String erpNo, String palletNo, String erpName, String sn, String boxNo) {
         if (StringUtils.isEmpty(erpName)) {
             return AjaxResult.success();
         }
@@ -219,6 +247,7 @@ public class ErpBarcodesServiceImpl implements IErpBarcodesService {
         erpBarcodes.setErpName(erpName);
         erpBarcodes.setBarcode(sn);
         erpBarcodes.setUserdefine1("Y");
+        erpBarcodes.setBoxNo(boxNo);
         erpBarcodes.setUserdefine5(palletNo);
         erpBarcodes.setUserdefine8("N");
         this.updateErpBarcodesBySn(erpBarcodes);

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

@@ -67,4 +67,11 @@ public interface CodeSkuRelationshipMapper
      * @return
      */
      List<CodeSkuRelationshipVO> selectCodeSkuRelationshipBySn(String sn);
+
+    /**
+     * 根据物料类型查询物料
+     * @param list
+     * @return
+     */
+    List<CodeSkuRelationshipVO> selectCodeSkuRelationshipVOList(List<String> list);
 }

+ 2 - 0
warewms-base/src/main/java/com/ruoyi/base/service/ICodeSkuRelationshipService.java

@@ -85,4 +85,6 @@ public interface ICodeSkuRelationshipService {
     CodeSkuRelationshipVO checkIsProduct(String sn);
 
     int saveOrUpdate(CodeSkuRelationship codeSkuRelationship);
+
+    List<CodeSkuRelationshipVO> selectCodeSkuRelationshipVOList(List<String> snList);
 }

+ 10 - 6
warewms-base/src/main/java/com/ruoyi/base/service/impl/CodeSkuRelationshipServiceImpl.java

@@ -1,19 +1,18 @@
 package com.ruoyi.base.service.impl;
 
-import java.util.List;
-
 import com.ruoyi.base.constant.Constant;
 import com.ruoyi.base.domain.BaseSku;
+import com.ruoyi.base.domain.CodeSkuRelationship;
 import com.ruoyi.base.domain.vo.CodeSkuRelationshipVO;
+import com.ruoyi.base.mapper.CodeSkuRelationshipMapper;
 import com.ruoyi.base.service.IBaseSkuService;
-import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.base.service.ICodeSkuRelationshipService;
 import com.ruoyi.common.exception.ServiceException;
 import com.ruoyi.common.utils.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-import com.ruoyi.base.mapper.CodeSkuRelationshipMapper;
-import com.ruoyi.base.domain.CodeSkuRelationship;
-import com.ruoyi.base.service.ICodeSkuRelationshipService;
+
+import java.util.List;
 
 /**
  * 条码品号关系表Service业务层处理
@@ -185,4 +184,9 @@ public class CodeSkuRelationshipServiceImpl implements ICodeSkuRelationshipServi
             return codeSkuRelationshipMapper.updateCodeSkuRelationship(codeSkuRelationship);
         }
     }
+
+    @Override
+    public List<CodeSkuRelationshipVO> selectCodeSkuRelationshipVOList(List<String> snList){
+        return codeSkuRelationshipMapper.selectCodeSkuRelationshipVOList(snList);
+    }
 }

+ 11 - 0
warewms-base/src/main/resources/mapper/base/CodeSkuRelationshipMapper.xml

@@ -105,4 +105,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
       left join base_sku s on c.sku = s.sku
       where c.sn = #{sn} and c.status = 'Y'
     </select>
+
+    <select id="selectCodeSkuRelationshipVOList" resultType="com.ruoyi.base.domain.vo.CodeSkuRelationshipVO">
+        <include refid="selectCodeSkuRelationshipVo"/>
+        where 1=1
+        <if test="list != null">
+            and sn in
+            <foreach collection="list" index="index" item="item" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+    </select>
 </mapper>