|
@@ -72,16 +72,17 @@
|
|
|
<select id="getStockCountByShelves" resultType="map">
|
|
|
SELECT
|
|
|
s1.parent_id id,
|
|
|
- ifnull(count(DISTINCT s.id),0) allCount,
|
|
|
- ifnull(sum(DISTINCT case when i.id is not null then 1 else 0 end ),0)stockCount,
|
|
|
- ifnull(sum(DISTINCT case when i.id is not null then 0 else 1 end ),0)freeCount,
|
|
|
- ifnull(sum(DISTINCT case when s.lock_status = '1' then 1 else 0 end ),0) lockCount
|
|
|
+ ifnull(count( s.id),0) allCount,
|
|
|
+ ifnull(count( case when LENGTH(i.id) >0 then 1 else 0 end ),0)stockCount,
|
|
|
+ ifnull(count( s.id),0) - ifnull(count( case when LENGTH(i.id) >0 then 1 else 0 end ),0)freeCount,
|
|
|
+ ifnull(sum( case when s.lock_status = '0' then 1 else 0 end ),0) lockCount
|
|
|
FROM
|
|
|
imcs_s_storge s
|
|
|
LEFT JOIN imcs_s_stock_info i ON s.id = i.storge_id
|
|
|
- left join imcs_s_shelves s1 on s.shelves_id = s1.id
|
|
|
- GROUP BY
|
|
|
- s1.parent_id
|
|
|
+
|
|
|
+LEFT JOIN imcs_s_shelves s1 ON s.shelves_id = s1.id
|
|
|
+GROUP BY
|
|
|
+ s1.parent_id
|
|
|
</select>
|
|
|
|
|
|
<!-- 获取库位的库存数量,判断是否为空库存 -->
|