Bladeren bron

电子标签修改

sunhz 3 jaren geleden
bovenliggende
commit
7433a4d679

+ 6 - 2
ruoyi-admin/src/main/java/com/ruoyi/web/controller/warehouse/warehouseBusiness/TWarehouseLabelController.java

@@ -25,11 +25,15 @@ public class TWarehouseLabelController extends BaseController {
         return AjaxResult.success(labelService.selectByfPid(elabel.getfPid()));
     }
 
+    @GetMapping("/in-list")
+    public AjaxResult inList(Long stockId) {
+        return AjaxResult.success(labelService.selectByStockId(stockId));
+    }
+
     @PostMapping("/save")
     @RepeatSubmit
     public AjaxResult save(@RequestBody List<TWarehousebillsitemsElabel> elabelList) {
-        labelService.insert(elabelList);
-        return AjaxResult.success();
+        return labelService.insert(elabelList);
     }
 
     @GetMapping("/remove/{fId}")

+ 11 - 0
ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/mapper/TWarehousebillsitemsElabelMapper.java

@@ -30,6 +30,12 @@ public interface TWarehousebillsitemsElabelMapper {
      * 根据父级 id 删除数据
      */
     int deleteByFPid(Long fPid);
+
+    /**
+     * 查一条
+     */
+    List<TWarehousebillsitemsElabel> selectList(TWarehousebillsitemsElabel elabel);
+
     /**
      * 查一条
      */
@@ -63,4 +69,9 @@ public interface TWarehousebillsitemsElabelMapper {
      */
     List<String> getLabelByPid(Long pid);
 
+    /**
+     * 获取数据
+     */
+    List<TWarehousebillsitemsElabel> selectByStockId(Long stockId);
+
 }

+ 6 - 5
ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/service/ITWarehousebillsitemsElabelService.java

@@ -1,5 +1,6 @@
 package com.ruoyi.warehouseBusiness.service;
 
+import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.warehouseBusiness.domain.TWarehousebillsitemsElabel;
 
 import java.util.List;
@@ -8,11 +9,7 @@ public interface ITWarehousebillsitemsElabelService {
     /**
      * 增一条
      */
-    void insert(List<TWarehousebillsitemsElabel> elabelList);
-    /**
-     * 修改一条
-     */
-    void update(TWarehousebillsitemsElabel elabel);
+    AjaxResult insert(List<TWarehousebillsitemsElabel> elabelList);
     /**
      * 删一条
      */
@@ -21,4 +18,8 @@ public interface ITWarehousebillsitemsElabelService {
      * 根据父级的父级 id 获取数据
      */
     List<TWarehousebillsitemsElabel> selectByfPid(Long fPid);
+    /**
+     * 根据父级的父级 id 获取数据
+     */
+    List<TWarehousebillsitemsElabel> selectByStockId(Long stockId);
 }

+ 19 - 6
ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/service/impl/TWarehousebillsitemsElabelServiceImpl.java

@@ -1,6 +1,7 @@
 package com.ruoyi.warehouseBusiness.service.impl;
 
 import cn.hutool.core.util.ObjectUtil;
+import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.warehouseBusiness.domain.TWarehousebillsitemsElabel;
 import com.ruoyi.warehouseBusiness.mapper.TWarehousebillsitemsElabelMapper;
 import com.ruoyi.warehouseBusiness.service.ITWarehousebillsitemsElabelService;
@@ -9,15 +10,26 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.util.List;
+import java.util.stream.Collectors;
 
 @Service
 public class TWarehousebillsitemsElabelServiceImpl implements ITWarehousebillsitemsElabelService {
+
     @Autowired
     private TWarehousebillsitemsElabelMapper elabelMapper;
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public void insert(List<TWarehousebillsitemsElabel> elabelList) {
+    public AjaxResult insert(List<TWarehousebillsitemsElabel> elabelList) {
+        List<String> tempList = elabelList.stream()
+                .map(TWarehousebillsitemsElabel::getfContent)
+                .distinct()
+                .collect(Collectors.toList());
+
+        if (elabelList.size() != tempList.size()) {
+            return AjaxResult.error("电子标签重复");
+        }
+
         elabelList.forEach(elabel -> {
             if (ObjectUtil.isNull(elabel.getfId())) {
                 elabelMapper.insert(elabel);
@@ -25,11 +37,7 @@ public class TWarehousebillsitemsElabelServiceImpl implements ITWarehousebillsit
                 elabelMapper.updateById(elabel);
             }
         });
-    }
-
-    @Override
-    public void update(TWarehousebillsitemsElabel elabel) {
-        elabelMapper.updateById(elabel);
+        return AjaxResult.success();
     }
 
     @Override
@@ -41,4 +49,9 @@ public class TWarehousebillsitemsElabelServiceImpl implements ITWarehousebillsit
     public List<TWarehousebillsitemsElabel> selectByfPid(Long fPid) {
         return elabelMapper.selectByfPid(fPid);
     }
+
+    @Override
+    public List<TWarehousebillsitemsElabel> selectByStockId(Long stockId) {
+        return elabelMapper.selectByStockId(stockId);
+    }
 }

+ 42 - 62
ruoyi-warehouse/src/main/resources/mapper/warehouseBusiness/TWarehousebillsitemsElabelMapper.xml

@@ -19,6 +19,33 @@
         <result property="updateTime"    column="update_time"    />
     </resultMap>
 
+    <sql id="selectElabel">
+        select f_id,
+               f_g_pid,
+               f_pid,
+               f_content,
+               f_qty,
+               f_weight,
+               f_type,
+               f_status,
+               create_by,
+               create_time,
+               update_by,
+               update_time
+        from t_warehousebillsitems_elabel
+    </sql>
+
+    <select id="selectList" parameterType="TWarehousebillsitemsElabel" resultMap="ElabelResult">
+        <include refid="selectElabel"/>
+        <where>
+            <if test="fGPid != null">and f_g_pid = #{fGPid}</if>
+            <if test="fPid != null">and f_pid = #{fPid}</if>
+            <if test="fContent != null and fContent != ''">and f_content = #{fContent}</if>
+            <if test="fType != null">and f_type = #{fType}</if>
+            <if test="fStatus != null">and f_status = #{fStatus}</if>
+        </where>
+    </select>
+
     <insert id="insert" parameterType="TWarehousebillsitemsElabel" useGeneratedKeys="true" keyProperty="fId">
         insert into t_warehousebillsitems_elabel
         <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -82,78 +109,22 @@
     </delete>
 
     <select id="selectById" parameterType="com.ruoyi.warehouseBusiness.domain.TWarehousebillsitemsElabel" resultMap="ElabelResult">
-        SELECT
-            f_id,
-            f_g_pid,
-            f_pid,
-            f_content,
-            f_qty,
-            f_weight,
-            f_type,
-            f_status,
-            create_by,
-            create_time,
-            update_by,
-            update_time
-        FROM
-            t_warehousebillsitems_elabel
+        <include refid="selectElabel"/>
         WHERE f_id = #{fId}
     </select>
 
     <select id="selectByfContent" parameterType="com.ruoyi.warehouseBusiness.domain.TWarehousebillsitemsElabel" resultMap="ElabelResult">
-        SELECT
-            f_id,
-            f_g_pid,
-            f_pid,
-            f_content,
-            f_qty,
-            f_weight,
-            f_type,
-            f_status,
-            create_by,
-            create_time,
-            update_by,
-            update_time
-        FROM
-            t_warehousebillsitems_elabel
+        <include refid="selectElabel"/>
         WHERE f_content = #{fContent}
     </select>
 
     <select id="selectByfPid" parameterType="com.ruoyi.warehouseBusiness.domain.TWarehousebillsitemsElabel" resultMap="ElabelResult">
-        SELECT
-            f_id,
-            f_g_pid,
-            f_pid,
-            f_content,
-            f_qty,
-            f_weight,
-            f_type,
-            f_status,
-            create_by,
-            create_time,
-            update_by,
-            update_time
-        FROM
-            t_warehousebillsitems_elabel
+        <include refid="selectElabel"/>
         WHERE f_pid = #{fPid}
     </select>
 
     <select id="selectByfGPid" parameterType="com.ruoyi.warehouseBusiness.domain.TWarehousebillsitemsElabel" resultMap="ElabelResult">
-        SELECT
-            f_id,
-            f_g_pid,
-            f_pid,
-            f_content,
-            f_qty,
-            f_weight,
-            f_type,
-            f_status,
-            create_by,
-            create_time,
-            update_by,
-            update_time
-        FROM
-            t_warehousebillsitems_elabel
+        <include refid="selectElabel"/>
         WHERE f_g_pid = #{fGPid}
     </select>
 
@@ -164,17 +135,26 @@
         where t2.f_originalbillno = #{billNo} and t1.f_type = 3 and t1.f_status = 0
     </select>
 
-    <select id="getLabelByTop" parameterType="string" resultType="string">
+    <select id="getLabelByTop" parameterType="long" resultType="string">
         select t1.f_content
         from t_warehousebillsitems_elabel t1
                  left join t_warehousebills t2 on t2.f_id = t1.f_g_pid
         where t1.f_g_pid = #{topId}
     </select>
 
-    <select id="getLabelByPid" parameterType="string" resultType="string">
+    <select id="getLabelByPid" parameterType="long" resultType="string">
         select t1.f_content
         from t_warehousebillsitems_elabel t1
                  left join t_warehousebillsitems t2 on t2.f_id = t1.f_pid
         where t1.f_pid = #{pid}
     </select>
+
+    <select id="selectByStockId" parameterType="long" resultMap="ElabelResult">
+        select
+            t1.*
+        from t_warehousebillsitems_elabel t1
+                 left join t_warehousebillsitems t2 on t2.f_id = t1.f_pid
+                 left join t_whgenleg t3 on t3.f_originalbillno = t2.f_billno
+        where t3.f_id = #{stockId}
+    </select>
 </mapper>