From fa326e87de2805d8b66b301daee596b1d959e430 Mon Sep 17 00:00:00 2001
From: guoshilong <123456>
Date: Thu, 15 Sep 2022 11:42:45 +0800
Subject: [PATCH] 出入库记录删除回滚逻辑修改

---
 src/main/java/org/springblade/modules/InventoryLoss/mapper/InventoryMapper.xml |   35 ++++++++++++++++++++++++++++++-----
 1 files changed, 30 insertions(+), 5 deletions(-)

diff --git a/src/main/java/org/springblade/modules/InventoryLoss/mapper/InventoryMapper.xml b/src/main/java/org/springblade/modules/InventoryLoss/mapper/InventoryMapper.xml
index 2efadae..56ac5ee 100644
--- a/src/main/java/org/springblade/modules/InventoryLoss/mapper/InventoryMapper.xml
+++ b/src/main/java/org/springblade/modules/InventoryLoss/mapper/InventoryMapper.xml
@@ -3,16 +3,41 @@
 <mapper namespace="org.springblade.modules.InventoryLoss.mapper.InventoryMapper">
 
     <!-- 通用查询映射结果 -->
-    <resultMap id="inventoryResultMap" type="org.springblade.modules.InventoryLoss.entity.Inventory">
+    <resultMap id="inventoryResultMap" type="org.springblade.modules.InventoryLoss.vo.InventoryVO">
         <result column="id" property="id"/>
-
+        <result column="strain_name" property="strainName"/>
+        <result column="dict_value" property="reasonName"/>
     </resultMap>
 
 
     <select id="selectSalePage" resultMap="inventoryResultMap">
-        select *
-        from sys_inventory
-        where is_deleted = 0
+        select inventory.*,
+               strain.strain_name,bdb.dict_value,
+        CASE WHEN inventory.type = 1 THEN
+        (
+        SELECT m.machining_type FROM sys_process_inv inv
+        LEFT JOIN sys_machining m ON m.id = inv.product_id
+        WHERE inventory.prod_id = inv.id
+        )
+        ELSE
+        (
+        SELECT strain.strain_name FROM sys_farm_product_stock sfps
+        LEFT JOIN sys_strain strain ON strain.id = sfps.strain_id
+        WHERE inventory.prod_id = sfps.id
+        )
+        END AS proName
+        from sys_inventory inventory
+        LEFT JOIN sys_strain strain on inventory.strain_id = strain.id
+        LEFT JOIN blade_dict_biz bdb ON inventory.reason = bdb.dict_key
+        LEFT JOIN sys_land land ON land.id = inventory.land_id
+        where
+        <if test="inventory.strainId !=null and inventory.strainId != '' ">
+            inventory.strain_id = #{inventory.strainId} AND
+        </if>
+        <if test="inventory.farmId != null and inventory.farmId !='' ">
+            land.farm_id = #{inventory.farmId} AND
+        </if>
+              bdb.code = "lossReason" AND inventory.is_deleted = 0 ORDER BY inventory.create_time DESC
     </select>
 
 </mapper>

--
Gitblit v1.9.3