select max(bis.org_id_int) as orgId,max(bis.org_name) as orgName,bis.location_id,max(bis.location_name) as location_name
select max(bis.org_id_int) as orgId,max(bis.org_name) as orgName,bis.location_id,max(bis.location_name) as location_name
<iftest="req.locationId !=null and req.locationId != ''">
<iftest="req.locationId !=null and req.locationId != ''">
...
@@ -67,7 +68,92 @@
...
@@ -67,7 +68,92 @@
</if>
</if>
</select>
</select>
<insertid="getSumByCabinet">
INSERT INTO base_inventory_summary (id,org_id_int,org_name,type_id, type_name,size_id,size_name,location_id,location_name,number,unit_price,price,stock_number, outbound_number,destruction_number,expire_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,t.unitPrice,sum(t.price)as price,sum(t.stockNumber)as stockNumber,sum(t.outboundNumber)as outboundNumber,sum(t.destructionNumber)as destructionNumber,sum(t.expireNumber)as expireNumber,t.location_type,NOW(),NOW()
FROM
(SELECT
UUID() as id,
bi.org_id_int as orgId,
po.org_name as orgName,
bcb.cabinet_id as locationId,
bi.location_id as locationBoxId,
bc.name as locationName,
bi.type_id,
t.name as typeName,
bi.size_id,
s.name as sizeName,
count(*) as number,
bi.price as unitPrice,
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,
sum(case when bi.state = 'destory' then 1 else 0 end) as destructionNumber,
sum(case when bi.warranty_period=0 then 0 when DATE_ADD(bi.production_date,INTERVAL bi.warranty_period MONTH)<NOW()then1else0end)asexpireNumber,
delete from base_inventory_summary_type2 where locationId = #{cabinetId}
</delete>
<insertid="getSumByWarehouse">
INSERT INTO base_inventory_summary_type2 (id,org_id_int,org_name,location_id,location_name,type_id, type_name,size_id,size_name,number,unit_price,price, stock_number, outbound_number,destruction_number,expire_number,location_type,create_time,update_time)
select
MAX(t.id) as id,t.orgId,t.orgName,t.locationId,MAX(t.locationName),t.type_id,t.typeName,t.size_id,t.sizeName,sum(t.number) as number,t.unitPrice,sum(t.price)as price,sum(t.stockNumber)as stockNumber,sum(t.outboundNumber)as outboundNumber,sum(t.destructionNumber)as destructionNumber,sum(t.destructionNumber) as expireNumber,t.location_type,NOW(),NOW()
FROM
(SELECT
UUID() as id,
bi.org_id_int as orgId,
po.org_name as orgName,
MAX(bi.location_id) as locationId,
MAX(bw.name) as locationName,
bi.type_id,
t.name as typeName,
bi.size_id,
s.name as sizeName,
count(*) as number,
Max(bi.price) as unitPrice,
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,
sum(case when bi.state = 'destory' then 1 else 0 end) as destructionNumber,
sum(case when bi.warranty_period=0 then 0 when DATE_ADD(bi.production_date,INTERVAL bi.warranty_period MONTH) < NOW() then 1