@@ -78,9 +78,9 @@ delete from base_inventory_summary
<insertid="SetCabinetInventory">
INSERT INTO base_inventory_summary (id,org_id_int,org_name,type_id, type_name,size_id,size_name,location_id,location_name,number,price, stock_number, outbound_number,location_type,create_time,update_time)
select MAX(t.id) as id,t.orgId,t.orgName,t.type_id,t.typeName,t.size_id,t.sizeName,t.locationId,t.locationName,
sum(t.number) as number,sum(t.price)as price,sum(t.stockNumber)as stockNumber,sum(t.outboundNumber)as outboundNumber,t.location_type,NOW(),NOW()
INSERT INTO base_inventory_summary (id,org_id_int,org_name,type_id, type_name,size_id,size_name,location_id,location_name,number,price, stock_number, outbound_number,destruction_number,location_type,create_time,update_time)
select
MAX(t.id) as id,t.orgId,t.orgName,t.type_id,t.typeName,t.size_id,t.sizeName,t.locationId,t.locationName,sum(t.number) as number,sum(t.price)as price,sum(t.stockNumber)as stockNumber,sum(t.outboundNumber)as outboundNumber,sum(t.destructionNumber)as destructionNumber,t.location_type,NOW(),NOW()
FROM
(SELECT
UUID() as id,
...
...
@@ -96,7 +96,8 @@ delete from base_inventory_summary
count(*) as number,
sum(bi.price) as price,
SUM(CASE WHEN location_state = 'in' THEN 1 ELSE 0 END) AS stockNumber,
count(*) - SUM(CASE WHEN location_state = 'in' THEN 1 ELSE 0 END) AS outboundNumber,
count(*) - SUM(CASE WHEN location_state = 'in' THEN 1 ELSE 0 END) - sum(case when bi.state = 'destory' then 1 else 0 end) AS outboundNumber,
sum(case when bi.state = 'destory' then 1 else 0 end) as destructionNumber,
bi.location_type
FROM base_inventory bi
join base_cabinet_box bcb on bi.location_id = bcb.id
...
...
@@ -110,8 +111,9 @@ delete from base_inventory_summary
</insert>
<insertid="SetWarehouseInventory">
INSERT INTO base_inventory_summary (id,org_id_int,org_name,type_id, type_name,size_id,size_name,location_id,location_name,number,price, stock_number, outbound_number,location_type,create_time,update_time)
INSERT INTO base_inventory_summary (id,org_id_int,org_name,type_id, type_name,size_id,size_name,location_id,location_name,number,price, stock_number, outbound_number,destruction_number,location_type,create_time,update_time)
select
MAX(t.id) as id,t.orgId,t.orgName,t.type_id,t.typeName,t.size_id,t.sizeName,t.locationId,MAX(t.locationName),sum(t.number) as number,sum(t.price)as price,sum(t.stockNumber)as stockNumber,sum(t.outboundNumber)as outboundNumber,sum(t.destructionNumber)as destructionNumber,t.location_type,NOW(),NOW()
FROM
(SELECT
UUID() as id,
...
...
@@ -126,8 +128,9 @@ delete from base_inventory_summary
count(*) as number,
sum(bi.price) as price,
SUM(CASE WHEN location_state = 'in' THEN 1 ELSE 0 END) AS stockNumber,
count(*) - SUM(CASE WHEN location_state = 'in' THEN 1 ELSE 0 END) AS outboundNumber,
bi.location_type as locationType
count(*) - SUM(CASE WHEN location_state = 'in' THEN 1 ELSE 0 END)- sum(case when bi.state = 'destory' then 1 else 0 end) AS outboundNumber,
sum(case when bi.state = 'destory' then 1 else 0 end) as destructionNumber,
bi.location_type
FROM base_inventory bi
join base_warehouse bw on bi.location_id = bw.id
join base_equipment_type t on t.id = bi.type_id
...
...
@@ -135,6 +138,7 @@ delete from base_inventory_summary
join pub_org po on bi.org_id_int = po.org_id
WHERE location_type = 0
GROUP BY type_id,size_id,bi.org_id_int,location_id) as t
SUM(CASE WHEN bi.location_state='in' and bi.location_type='0'THEN 1 ELSE 0 END) AS inSum,
SUM(CASE WHEN bi.location_state='out' AND bi.location_type='0' THEN 1 ELSE 0 END)- SUM(CASE WHEN bi.state='destory' AND bi.location_type='0' THEN 1 ELSE 0 END)AS outSum,
SUM(CASE WHEN bi.location_state='in' AND bi.location_type='1' THEN 1 ELSE 0 END) AS cabinetInSum,
SUM(CASE WHEN bi.location_state='out' AND bi.location_type='1' THEN 1 ELSE 0 END)- SUM(CASE WHEN bi.state='destory' AND bi.location_type='1' THEN 1 ELSE 0 END) AS CabinetOutSum,
SUM(CASE WHEN bi.state='destory'THEN 1 ELSE 0 END) AS brokenSum
FROM base_inventory bi
JOIN pub_org pub ON pub.org_id = bi.org_id_int
join base_equipment_size bes on bes.id=bi.size_id
<where>
<iftest="orgId != null and orgId != ''">
and bi.org_id_int=#{orgId}
</if>
<iftest="sizeId != null and sizeId != '' and sizeName != null and sizeName != ''">