andy 2 anni fa
parent
commit
573e4d515d

+ 18 - 5
ruoyi-admin/src/main/java/com/ruoyi/web/controller/warewms/api/PadController.java

@@ -2,15 +2,17 @@ package com.ruoyi.web.controller.warewms.api;
 
 import com.ruoyi.ams.asn.form.StockForm;
 import com.ruoyi.ams.asn.service.IWmsDocAsnHeaderService;
+import com.ruoyi.base.service.ICodeSkuRelationshipService;
 import com.ruoyi.common.annotation.Log;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.enums.BusinessType;
 import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.framework.web.domain.server.Sys;
+import org.aspectj.weaver.loadtime.Aj;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.Map;
 
 /**
  * Created by IntelliJ IDEA.
@@ -19,11 +21,13 @@ import org.springframework.web.bind.annotation.RestController;
  * Description:
  */
 @RestController
-@RequestMapping("/api/docAsn/")
+@RequestMapping("/api/docAsn")
 public class PadController {
 
     @Autowired
     private IWmsDocAsnHeaderService wmsDocAsnHeaderService;
+    @Autowired
+    private ICodeSkuRelationshipService codeSkuRelationshipService;
 
     @PostMapping("/stock")
     @Log(title = "码盘", businessType = BusinessType.INSERT)
@@ -33,4 +37,13 @@ public class PadController {
         }
         return wmsDocAsnHeaderService.doStock(stockForm);
     }
+
+    @PostMapping("/snCheck")
+    public AjaxResult snCheck(@RequestBody Map<String, String> param) {
+        String sn = param.get("sn");
+        if (StringUtils.isEmpty(sn)) {
+            return AjaxResult.error("条码不能为空");
+        }
+        return codeSkuRelationshipService.snCheck(sn);
+    }
 }

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

@@ -311,10 +311,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        delete from inv_lot_loc_id where location_id = #{locationId}
     </update>
 
-    <update id="clearInvByLocationId">
-       delete from inv_lot_loc_id where lotnum = #{lotnum}
-    </update>
-
     <select id="queryInvBySku" resultType="double">
         select
         sum(inv.qty) qty

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

@@ -0,0 +1,18 @@
+package com.ruoyi.base.domain.vo;
+
+import com.ruoyi.base.domain.BaseSku;
+import lombok.Data;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: andy.qu
+ * Date: 2022/11/9
+ * Description:
+ */
+@Data
+public class CodeSkuRelationshipVO {
+    private String sn;
+    private String status;
+    private String sku;
+    private String skuType;
+}

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

@@ -2,6 +2,7 @@ package com.ruoyi.base.mapper;
 
 import java.util.List;
 import com.ruoyi.base.domain.CodeSkuRelationship;
+import com.ruoyi.base.domain.vo.CodeSkuRelationshipVO;
 
 /**
  * 条码品号关系表Mapper接口
@@ -58,4 +59,11 @@ public interface CodeSkuRelationshipMapper
      * @return 结果
      */
      int deleteCodeSkuRelationshipByIds(Long[] ids);
+
+    /**
+     * 根据sn查询产品条码绑定关系
+     * @param sn
+     * @return
+     */
+     CodeSkuRelationshipVO selectCodeSkuRelationshipBySn(String sn);
 }

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

@@ -2,6 +2,7 @@ package com.ruoyi.base.service;
 
 import java.util.List;
 import com.ruoyi.base.domain.CodeSkuRelationship;
+import com.ruoyi.common.core.domain.AjaxResult;
 
 /**
  * 条码品号关系表Service接口
@@ -66,4 +67,11 @@ public interface ICodeSkuRelationshipService
      * @return 结果
      */
      int deleteCodeSkuRelationshipById(Long id);
+
+    /**
+     * 条码检测
+     * @param sn 条码
+     * @return
+     */
+     AjaxResult snCheck(String sn);
 }

+ 34 - 24
warewms-base/src/main/java/com/ruoyi/base/service/impl/CodeSkuRelationshipServiceImpl.java

@@ -1,6 +1,9 @@
 package com.ruoyi.base.service.impl;
 
 import java.util.List;
+
+import com.ruoyi.base.domain.vo.CodeSkuRelationshipVO;
+import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.utils.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -10,37 +13,34 @@ import com.ruoyi.base.service.ICodeSkuRelationshipService;
 
 /**
  * 条码品号关系表Service业务层处理
- * 
+ *
  * @author andy
  * @date 2022-11-07
  */
 @Service
-public class CodeSkuRelationshipServiceImpl implements ICodeSkuRelationshipService 
-{
+public class CodeSkuRelationshipServiceImpl implements ICodeSkuRelationshipService {
     @Autowired
     private CodeSkuRelationshipMapper codeSkuRelationshipMapper;
 
     /**
      * 查询条码品号关系表
-     * 
+     *
      * @param id 条码品号关系表主键
      * @return 条码品号关系表
      */
     @Override
-    public CodeSkuRelationship selectCodeSkuRelationshipById(Long id)
-    {
+    public CodeSkuRelationship selectCodeSkuRelationshipById(Long id) {
         return codeSkuRelationshipMapper.selectCodeSkuRelationshipById(id);
     }
 
     /**
      * 查询条码品号关系表列表
-     * 
+     *
      * @param codeSkuRelationship 条码品号关系表
      * @return 条码品号关系表
      */
     @Override
-    public List<CodeSkuRelationship> selectCodeSkuRelationshipList(CodeSkuRelationship codeSkuRelationship)
-    {
+    public List<CodeSkuRelationship> selectCodeSkuRelationshipList(CodeSkuRelationship codeSkuRelationship) {
         return codeSkuRelationshipMapper.selectCodeSkuRelationshipList(codeSkuRelationship);
     }
 
@@ -51,10 +51,9 @@ public class CodeSkuRelationshipServiceImpl implements ICodeSkuRelationshipServi
      * @return 条码品号关系表
      */
     @Override
-    public CodeSkuRelationship selectCodeSkuRelationshipByModel(CodeSkuRelationship codeSkuRelationship)
-    {
+    public CodeSkuRelationship selectCodeSkuRelationshipByModel(CodeSkuRelationship codeSkuRelationship) {
         List<CodeSkuRelationship> list = codeSkuRelationshipMapper.selectCodeSkuRelationshipList(codeSkuRelationship);
-        if (list!=null && list.size()>0) {
+        if (list != null && list.size() > 0) {
             return list.get(0);
         } else {
             return null;
@@ -63,51 +62,62 @@ public class CodeSkuRelationshipServiceImpl implements ICodeSkuRelationshipServi
 
     /**
      * 新增条码品号关系表
-     * 
+     *
      * @param codeSkuRelationship 条码品号关系表
      * @return 结果
      */
     @Override
-    public int insertCodeSkuRelationship(CodeSkuRelationship codeSkuRelationship)
-    {
+    public int insertCodeSkuRelationship(CodeSkuRelationship codeSkuRelationship) {
         codeSkuRelationship.setCreateTime(DateUtils.getNowDate());
         return codeSkuRelationshipMapper.insertCodeSkuRelationship(codeSkuRelationship);
     }
 
     /**
      * 修改条码品号关系表
-     * 
+     *
      * @param codeSkuRelationship 条码品号关系表
      * @return 结果
      */
     @Override
-    public int updateCodeSkuRelationship(CodeSkuRelationship codeSkuRelationship)
-    {
+    public int updateCodeSkuRelationship(CodeSkuRelationship codeSkuRelationship) {
         codeSkuRelationship.setUpdateTime(DateUtils.getNowDate());
         return codeSkuRelationshipMapper.updateCodeSkuRelationship(codeSkuRelationship);
     }
 
     /**
      * 批量删除条码品号关系表
-     * 
+     *
      * @param ids 需要删除的条码品号关系表主键
      * @return 结果
      */
     @Override
-    public int deleteCodeSkuRelationshipByIds(Long[] ids)
-    {
+    public int deleteCodeSkuRelationshipByIds(Long[] ids) {
         return codeSkuRelationshipMapper.deleteCodeSkuRelationshipByIds(ids);
     }
 
     /**
      * 删除条码品号关系表信息
-     * 
+     *
      * @param id 条码品号关系表主键
      * @return 结果
      */
     @Override
-    public int deleteCodeSkuRelationshipById(Long id)
-    {
+    public int deleteCodeSkuRelationshipById(Long id) {
         return codeSkuRelationshipMapper.deleteCodeSkuRelationshipById(id);
     }
+
+    /**
+     * 条码检测
+     *
+     * @param sn 条码
+     * @return
+     */
+    @Override
+    public AjaxResult snCheck(String sn) {
+        CodeSkuRelationshipVO codeSkuRelationshipVO = codeSkuRelationshipMapper.selectCodeSkuRelationshipBySn(sn);
+        if (codeSkuRelationshipVO.getStatus().equals("N")) {
+            return AjaxResult.error("该产品已禁用");
+        }
+        return AjaxResult.success(codeSkuRelationshipVO);
+    }
 }

+ 20 - 2
warewms-base/src/main/resources/mapper/base/CodeSkuRelationshipMapper.xml

@@ -17,11 +17,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="updateTime"    column="update_time"    />
     </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">
         select id, sn, status, sku, vdate, user_id, create_by, create_time, update_by, update_time from code_sku_relationship
     </sql>
 
-    <select id="selectCodeSkuRelationshipList" parameterType="CodeSkuRelationship" resultMap="CodeSkuRelationshipResult">
+    <select id="selectCodeSkuRelationshipList" parameterType="CodeSkuRelationshipVO" resultMap="CodeSkuRelationshipResult">
         <include refid="selectCodeSkuRelationshipVo"/>
         <where>  
             <if test="sn != null  and sn != ''"> and sn = #{sn}</if>
@@ -37,7 +50,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         where id = #{id}
     </select>
         
-    <insert id="insertCodeSkuRelationship" parameterType="CodeSkuRelationship" useGeneratedKeys="true" keyProperty="id">
+    <insert id="insertCodeSkuRelationship" parameterType="CodeSkuRelationshipVO" useGeneratedKeys="true" keyProperty="id">
         insert into code_sku_relationship
         <trim prefix="(" suffix=")" suffixOverrides=",">
             <if test="sn != null">sn,</if>
@@ -89,4 +102,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             #{id}
         </foreach>
     </delete>
+
+    <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}
+    </select>
 </mapper>