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()
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(CASE WHEN location_state = 'in' THEN 1 ELSE 0 END)+SUM(CASE WHEN location_state = 'out' and bi.state!='destory' THEN 1 ELSE 0 END) as number,
Max(bi.price) as unitPrice,
bi.price as unitPrice,
sum(bi.price) as price,
sum(bi.price) as price,
SUM(CASE WHEN location_state = 'in' THEN 1 ELSE 0 END) AS stockNumber,
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 location_state = 'out' and bi.state!='destory' THEN 1 ELSE 0 END) AS outboundNumber,
sum(case when bi.state = 'destory' then 1 else 0 end) as destructionNumber,
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 else 0 end )as expireNumber,
sum(case when bi.warranty_period=0 then 0 when DATE_ADD(bi.production_date,INTERVAL bi.warranty_period MONTH) > NOW() then 1 else 0 end )as expireNumber,
sum(case when bi.state ='broken' and bi.location_state='in' then 1 else 0 end)as brokenNumber,
sum(case when bi.bussiness_state = 'borrow' and bi.location_state='out' then 1
when bi.bussiness_state = 'take' and bi.location_state='out' then 1 else 0 end)as useNumber,
sum(case when bi.warranty_period=0 then 0 when DATE_ADD(bi.production_date,INTERVAL bi.warranty_period MONTH) < NOW()
and DATEDIFF(DATE_ADD(bi.production_date,INTERVAL bi.warranty_period MONTH),NOW()) < #{brokenNumberDays} then 1 else 0 end)as nearBrokenNumber,
bi.location_type
bi.location_type
FROM base_inventory bi
FROM base_inventory bi
join base_cabinet_box bcb on bi.location_id = bcb.id
join base_cabinet_box bcb on bi.location_id = bcb.id
...
@@ -107,33 +116,43 @@ delete from base_inventory_summary
...
@@ -107,33 +116,43 @@ delete from base_inventory_summary
join base_equipment_size s on s.id = bi.size_id
join base_equipment_size s on s.id = bi.size_id
join pub_org po on bi.org_id_int = po.org_id
join pub_org po on bi.org_id_int = po.org_id
WHERE location_type = 1
WHERE location_type = 1
GROUP BY location_id, type_id,size_id,bi.org_id_int,bi.price ) as t
GROUP BY bi.org_id_int, bcb.cabinet_id, type_id,size_id,bi.price
GROUP BY t.locationId,t.type_id,t.size_id,t.orgId,t.unitPrice
order by po.org_name,bc.name ) as t
GROUP BY t.orgName,t.locationId,t.type_id,t.size_id,t.orgId,t.unitPrice
</insert>
</insert>
<insertid="SetWarehouseInventory">
<insertid="SetWarehouseInventory">
INSERT INTO base_inventory_summary (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)
INSERT INTO base_inventory_summary (id,org_id_int,org_name,location_id,location_name,type_id, type_name,size_id,
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()
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,
SUM(CASE WHEN location_state = 'in' THEN 1 ELSE 0 END)+SUM(CASE WHEN location_state = 'out' and bi.state!='destory' THEN 1 ELSE 0 END) as number,
Max(bi.price) as unitPrice,
bi.price as unitPrice,
sum(bi.price) as price,
sum(bi.price) as price,
SUM(CASE WHEN location_state = 'in' THEN 1 ELSE 0 END) AS stockNumber,
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 location_state = 'out' and bi.state!='destory' THEN 1 ELSE 0 END) AS outboundNumber,
sum(case when bi.state = 'destory' then 1 else 0 end) as destructionNumber,
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
sum(case when bi.warranty_period=0 then 0 when DATE_ADD(bi.production_date,INTERVAL bi.warranty_period MONTH) > NOW() then 1 else 0 end )as expireNumber,
else 0 end )as expireNumber,
sum(case when bi.state ='broken' and bi.location_state='in' then 1 else 0 end)as brokenNumber,
sum(case when bi.bussiness_state = 'borrow' and bi.location_state='out' then 1
when bi.bussiness_state = 'take' and bi.location_state='out' then 1 else 0 end)as useNumber,
sum(case when bi.warranty_period=0 then 0 when DATE_ADD(bi.production_date,INTERVAL bi.warranty_period MONTH) < NOW()
and DATEDIFF(DATE_ADD(bi.production_date,INTERVAL bi.warranty_period MONTH),NOW()) < #{brokenNumberDays} then 1 else 0 end)as nearBrokenNumber,
bi.location_type
bi.location_type
FROM base_inventory bi
FROM base_inventory bi
join base_warehouse bw on bi.location_id = bw.id
join base_warehouse bw on bi.location_id = bw.id
...
@@ -141,13 +160,19 @@ delete from base_inventory_summary
...
@@ -141,13 +160,19 @@ delete from base_inventory_summary
join base_equipment_size s on s.id = bi.size_id
join base_equipment_size s on s.id = bi.size_id
join pub_org po on bi.org_id_int = po.org_id
join pub_org po on bi.org_id_int = po.org_id
WHERE location_type = 0
WHERE location_type = 0
GROUP BY type_id,size_id,bi.org_id_int,location_id,bi.price) as t
GROUP BY type_id,size_id,bi.org_id_int,location_id,bi.price
order by po.org_name,bw.name) as t
GROUP BY t.locationId,t.type_id,t.size_id,t.orgId,t.unitPrice
GROUP BY t.locationId,t.type_id,t.size_id,t.orgId,t.unitPrice
</insert>
</insert>
<insertid="insertInventorySummary">
<insertid="insertInventorySummary">
INSERT INTO base_inventory_summary (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)
INSERT INTO base_inventory_summary (id,org_id_int,org_name,location_id,location_name,type_id, type_name,size_id,
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()
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,sum(t.useNumber)as useNumber,
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()
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(CASE WHEN location_state = 'in' THEN 1 ELSE 0 END)+SUM(CASE WHEN location_state = 'out' and bi.state!='destory' THEN 1 ELSE 0 END) as number,
bi.price as unitPrice,
bi.price as unitPrice,
sum(bi.price) as price,
sum(bi.price) as price,
SUM(CASE WHEN location_state = 'in' THEN 1 ELSE 0 END) AS stockNumber,
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 location_state = 'out' and bi.state!='destory' THEN 1 ELSE 0 END) AS outboundNumber,
sum(case when bi.state = 'destory' then 1 else 0 end) as destructionNumber,
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 else 0 end )as expireNumber,
sum(case when bi.warranty_period=0 then 0 when DATE_ADD(bi.production_date,INTERVAL bi.warranty_period MONTH) > NOW() then 1 else 0 end )as expireNumber,
sum(case when bi.state ='broken' and bi.location_state='in' then 1 else 0 end)as brokenNumber,
sum(case when bi.bussiness_state = 'borrow' and bi.location_state='out' then 1
when bi.bussiness_state = 'take' and bi.location_state='out' then 1 else 0 end)as useNumber,
sum(case when bi.warranty_period=0 then 0 when DATE_ADD(bi.production_date,INTERVAL bi.warranty_period MONTH) < NOW()
and DATEDIFF(DATE_ADD(bi.production_date,INTERVAL bi.warranty_period MONTH),NOW()) < #{brokenNumberDays} then 1 else 0 end)as nearBrokenNumber,
bi.location_type
bi.location_type
FROM base_inventory bi
FROM base_inventory bi
join base_cabinet_box bcb on bi.location_id = bcb.id
join base_cabinet_box bcb on bi.location_id = bcb.id
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()
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,sum(t.brokenNumber) as brokenNumber,
SUM(CASE WHEN location_state = 'in' THEN 1 ELSE 0 END)+SUM(CASE WHEN location_state = 'out' and bi.state!='destory' THEN 1 ELSE 0 END) as number,
Max(bi.price) as unitPrice,
bi.price as unitPrice,
sum(bi.price) as price,
sum(bi.price) as price,
SUM(CASE WHEN location_state = 'in' THEN 1 ELSE 0 END) AS stockNumber,
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 location_state = 'out' and bi.state!='destory' THEN 1 ELSE 0 END) AS outboundNumber,
sum(case when bi.state = 'destory' then 1 else 0 end) as destructionNumber,
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
sum(case when bi.warranty_period=0 then 0 when DATE_ADD(bi.production_date,INTERVAL bi.warranty_period MONTH) > NOW() then 1 else 0 end )as expireNumber,
else 0 end )as expireNumber,
sum(case when bi.state ='broken' and bi.location_state='in' then 1 else 0 end)as brokenNumber,
sum(case when bi.bussiness_state = 'borrow' and bi.location_state='out' then 1
when bi.bussiness_state = 'take' and bi.location_state='out' then 1 else 0 end)as useNumber,
sum(case when bi.warranty_period=0 then 0 when DATE_ADD(bi.production_date,INTERVAL bi.warranty_period MONTH) < NOW()
and DATEDIFF(DATE_ADD(bi.production_date,INTERVAL bi.warranty_period MONTH),NOW()) < #{brokenNumberDays} then 1 else 0 end)as nearBrokenNumber,