From 680b380e3d9189f2bfd79fb33a6428d82219e4bc Mon Sep 17 00:00:00 2001
From: guoshilong <123456>
Date: Sat, 17 Sep 2022 10:29:44 +0800
Subject: [PATCH] 新增加工产品出库,修改加工产品数据存储逻辑

---
 src/main/java/org/springblade/modules/processInv/mapper/ProcessInvMapper.xml |   46 +++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 43 insertions(+), 3 deletions(-)

diff --git a/src/main/java/org/springblade/modules/processInv/mapper/ProcessInvMapper.xml b/src/main/java/org/springblade/modules/processInv/mapper/ProcessInvMapper.xml
index 1dfdc97..ea64b8d 100644
--- a/src/main/java/org/springblade/modules/processInv/mapper/ProcessInvMapper.xml
+++ b/src/main/java/org/springblade/modules/processInv/mapper/ProcessInvMapper.xml
@@ -20,10 +20,9 @@
 
     <select id="selectProcessInvPage" resultMap="processInvResultMap">
         select inv.*,m.machining_tp,
-               m.machining_type,strain_name
+               m.machining_type
         from sys_process_inv inv
         LEFT JOIN sys_machining m ON m.id = inv.product_id
-        LEFT JOIN sys_strain strain ON strain.id = inv.strain_id
         LEFT JOIN sys_farm_product_stock fps ON inv.fps_id = fps.id
         LEFT JOIN sys_land land ON land.id = fps.land_id
         where inv.is_deleted = 0 AND inv.product_inventory_num != 0
@@ -31,7 +30,7 @@
             AND inv.fps_id = #{processInv.fpsId}
         </if>
         <if test="processInv.farmId != null and processInv.farmId !=''">
-            AND land.farm_id = #{processInv.farmId}
+            AND inv.fps_id = #{processInv.farmId}
         </if>
     </select>
 
@@ -70,6 +69,11 @@
         WHERE
             id = #{proid}
     </update>
+    <update id="stockAdd">
+        UPDATE sys_process_inv SET product_inventory_num = product_inventory_num + #{saleNum}
+        WHERE
+            id = #{proid}
+    </update>
 
     <delete id="del">
         DELETE FROM sys_process_inv WHERE id = #{id}
@@ -102,5 +106,41 @@
             and land.farm_id = #{farmId}
         </if>
     </select>
+    <select id="selectByFarmIdProductId" resultType="org.springblade.modules.processInv.entity.ProcessInv">
+--         SELECT id,strain_id,product_id,product_inventory_num,create_time,update_user,update_time,status,is_deleted,fps_id
+        SELECT *
+        FROM sys_process_inv
+        WHERE is_deleted = 0
+        <if test="farmId != null and farmId !=''">
+            AND fps_id = #{farmId}
+        </if>
+        <if test="productId != null and productId !=''">
+            AND product_id = #{productId}
+        </if>
+    </select>
+    <select id="selectByProcessIdLandId" resultType="org.springblade.modules.processInv.entity.ProcessInv">
+        SELECT
+            inv.id,
+            inv.strain_id,
+            inv.product_id,
+            inv.product_inventory_num,
+            inv.create_time,
+            inv.update_user,
+            inv.update_time,
+            inv.fps_id,
+            inv.status,
+            inv.is_deleted
+        FROM
+            sys_process_inv inv
+            LEFT JOIN sys_land l ON l.farm_id = inv.fps_id
+        WHERE inv.is_deleted = 0 AND 1=1
+        <if test="processId !=null and processId !='' ">
+           AND inv.product_id = #{processId}
+        </if>
+        <if test="landId !=null and landId !='' ">
+            AND l.id = #{landId}
+        </if>
+
+    </select>
 
 </mapper>

--
Gitblit v1.9.3