From 75a48cf624bb06044207a2bc9b1310c326469a29 Mon Sep 17 00:00:00 2001
From: guoshilong <123456>
Date: Thu, 15 Sep 2022 14:59:52 +0800
Subject: [PATCH] 返回数量不为0的已出库库存数据

---
 src/main/java/org/springblade/modules/processInv/mapper/ProcessInvMapper.xml |   44 ++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 40 insertions(+), 4 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 6bb1899..1dfdc97 100644
--- a/src/main/java/org/springblade/modules/processInv/mapper/ProcessInvMapper.xml
+++ b/src/main/java/org/springblade/modules/processInv/mapper/ProcessInvMapper.xml
@@ -26,7 +26,7 @@
         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
+        where inv.is_deleted = 0 AND inv.product_inventory_num != 0
         <if test="processInv.fpsId != null and processInv.fpsId != ''">
             AND inv.fps_id = #{processInv.fpsId}
         </if>
@@ -35,9 +35,16 @@
         </if>
     </select>
 
-    <select id="selectBy2Id" resultType="org.springblade.modules.processInv.entity.ProcessInv">
+    <select id="selectBySPId" 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
-        FROM sys_process_inv WHERE strain_id = #{strainId} AND product_id = #{productId}
+        FROM sys_process_inv
+        WHERE is_deleted = 0 AND strain_id = #{strainId} AND product_id = #{productId} AND fps_id = #{fpsId}
+    </select>
+
+    <select id="selectBySFId" 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
+        FROM sys_process_inv
+        WHERE is_deleted = 0 AND strain_id = #{strainId} AND fps_id = #{fpsId}
     </select>
 
     <insert id="add">
@@ -49,7 +56,7 @@
         SELECT
             CASE
                 WHEN
-                    product_inventory_num > #{saleNum} THEN
+                    product_inventory_num >= #{saleNum} THEN
                     TRUE ELSE FALSE
                 END result
         FROM
@@ -67,4 +74,33 @@
     <delete id="del">
         DELETE FROM sys_process_inv WHERE id = #{id}
     </delete>
+
+    <select id="getLand" resultType="org.springblade.modules.processInv.vo.ProcessInvVO">
+        SELECT inv.id,inv.fps_id,fps.land_id
+        FROM sys_process_inv inv
+        LEFT JOIN sys_farm_product_stock fps ON inv.fps_id = fps.id
+        WHERE inv.is_deleted = 0
+        <if test="processInv.id != null and processInv.id != ''">
+            AND inv.id = #{processInv.id}
+        </if>
+    </select>
+    <select id="findById" 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
+        FROM sys_process_inv
+        WHERE is_deleted = 0 AND id = #{prodId}
+    </select>
+    <select id="statisticsStock" resultType="java.lang.Double">
+        SELECT SUM(inv.product_inventory_num) as sum
+        FROM sys_process_inv inv
+        LEFT JOIN sys_farm_product_stock sfps ON sfps.id = inv.fps_id
+        LEFT JOIN sys_land land ON land.id = sfps.land_id
+        WHERE 1=1 AND inv.is_deleted = 0
+        <if test="year!=null and year!=''">
+            and YEAR ( inv.create_time ) = #{year}
+        </if>
+        <if test="farmId!=null and farmId!=''">
+            and land.farm_id = #{farmId}
+        </if>
+    </select>
+
 </mapper>

--
Gitblit v1.9.3