select a.id, a.basic_id, a.warehouse_id, a.code,a.remaining, a.state,a.company_id,a.version, a.create_by, a.create_time, a.update_by, a.update_time, a.remark,
b.id as basic_id,b.name as basic_name,b.cas as basic_cas,b.hazmat_type as basic_hazmat_type,b.hazmat_character as basic_hazmat_character,
b.supplier as basic_supplier,b.manufacturer as basic_manufacturer,b.metering as basic_metering,b.unit as basic_unit,
b.product_sn,b.min_package as basic_min_package,c.name as warehouse_name,d.cupboard_name as cupboard_name
from hz_hazmat a
left join hz_hazmat_basic b on b.id=a.basic_id
left join hz_warehouse c on c.id=a.warehouse_id
left join hz_warehouse_cupboard d on d.id=a.cupboard_id
update hz_hazmat set del_flag=1 where id=#{hazmatId}
and a.del_flag=0
and a.warehouse_id=#{warehouseId}
and a.state=#{state}
and a.basic_id=#{basicId}
and a.entry_id=#{entryId}
AND a.company_id= #{companyId}
order by a.id desc
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
from hz_hazmat a
left join hz_hazmat_basic b on b.id=a.basic_id
AND a.company_id= #{companyId}
AND a.basic_id= #{basicId}
AND a.state= #{state}
AND a.warehouse_id= #{warehouseId}
AND b.name like concat(#{params.name},"%")
AND b.product_sn =#{params.productSn}
and a.del_flag=0
group by a.basic_id,a.warehouse_id, a.cupboard_id
select count(a.id) from hz_hazmat a
inner join hz_hazmat_basic b on b.id=basic_id
where a.warehouse_id=#{warehouseId} and b.id=#{basicId} and a.company_id=#{companyId} and b.company_id=#{companyId}
and a.del_flag=0 and (a.state=0 or a.state=1) and a.cupboard_id = #{cupboardId}
select DISTINCT b.peculiarity_number spNum ,b.id from hz_hazmat a
inner join hz_hazmat_basic b on b.id=basic_id
where a.warehouse_id=#{warehouseId} and a.company_id=#{companyId} and b.company_id=#{companyId}
and a.del_flag=0 and (a.state=0 or a.state=1) and a.cupboard_id = #{cupboardId}
where a.del_flag=0 and a.code=#{code} and a.company_id=#{companyId} limit 1
select count(*) as count, month(create_time) as month,day(create_time) as day from hz_hazmat
where create_time >= #{startTime} and create_time <= #{endTime} and state in (2,3)
and company_id=#{companyId}
group by month,day
order by month asc,day asc
select count(*) as count,basic_id from hz_hazmat
where create_time >= #{startTime} and create_time <= #{endTime} and state in (1,2,3)
and company_id=#{companyId}
group by basic_id
order by count desc
limit 10
select count(*) as count,basic_id from hz_hazmat
where create_time >= #{startTime} and create_time <= #{endTime} and state =3
and company_id=#{companyId}
group by basic_id
order by count desc
select * from hz_hazmat_#{slice} a
left join hz_hazmat_basic b on b.id=a.basic_id
left join hz_warning c on c.hazmat_id=a.id and c.state=0
and c.id is null and b.threshold>0 and a.state=2 and DATE_ADD(a.update_time,INTERVAL b.threshold HOUR) <= now()
order by a.id
limit #{startIndex},#{pageSize}