From 147466c117b56fad2626217bb259133d8d284360 Mon Sep 17 00:00:00 2001
From: “djh” <“3298565835@qq.com”>
Date: Fri, 20 Mar 2026 10:23:44 +0800
Subject: [PATCH] 修改仓库库存显示
---
hazmat-system/src/main/resources/mapper/system/HzHazmatMapper.xml | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/hazmat-system/src/main/resources/mapper/system/HzHazmatMapper.xml b/hazmat-system/src/main/resources/mapper/system/HzHazmatMapper.xml
index eb1576e..03ddf27 100644
--- a/hazmat-system/src/main/resources/mapper/system/HzHazmatMapper.xml
+++ b/hazmat-system/src/main/resources/mapper/system/HzHazmatMapper.xml
@@ -77,8 +77,8 @@
<select id="selectHazmatGroupWareHouse" resultType="com.gkhy.hazmat.system.domain.vo.HzHazmatWarehouseVO">
select a.basic_id,a.warehouse_id,a.cupboard_id,
- (select count(1) from hz_hazmat where state=0 and basic_id=a.basic_id and warehouse_id=a.warehouse_id) as stock,
- (select count(1) from hz_hazmat where state=1 and basic_id=a.basic_id and warehouse_id=a.warehouse_id) as miss_stock
+ SUM(CASE WHEN a.state = 0 THEN 1 ELSE 0 END) AS stock,
+ SUM(CASE WHEN a.state = 1 THEN 1 ELSE 0 END) AS miss_stock
from hz_hazmat a
left join hz_hazmat_basic b on b.id=a.basic_id
<where>
@@ -103,6 +103,7 @@
and a.del_flag=0 and b.del_flag = 0
</where>
group by a.basic_id,a.warehouse_id, a.cupboard_id
+ HAVING stock > 0 OR miss_stock > 0
</select>
@@ -157,12 +158,12 @@
LEFT JOIN hz_hazmat_flow hhf2 on hh2.id = hhf2.hazmat_id
LEFT JOIN sys_user sy on hhf2.create_id = sy.id
LEFT JOIN sys_dept sd on sy.depart_id = sd.id
- where hh2.create_time >= #{startTime} and hh2.create_time <= #{endTime} and hh2.state =3 and hhf2.state = 4
+ where hhf2.create_time >= #{startTime} and hhf2.create_time <= #{endTime} and hh2.state =3 and hhf2.state = 4
<if test="companyId!=null">
and hh2.company_id=#{companyId}
</if>
<if test="userId!=null">
- and hh2f.create_id = #{userId}
+ and hhf2.create_id = #{userId}
</if>
<if test="departId!=null">
and sd.id = #{departId}
--
Gitblit v1.9.2