select #{site} as site, b.hsCode,b.hsCodeDesc as hsCodeDesc,b.brand as brand,sum( a.qty) as qty ,sum(a.ttl_amount) as totalPrice,
CONVERT(DECIMAL(20, 6),sum(a.ttl_amount)/sum( a.qty)) as unitPrice,b.ecss_umid as unit,
LEFT(a.currency, 3) AS currency,'中国' as madeArea,#{destination} as destination,'南通其他' as sourceArea ,'照章征免' as levy from
ecss_CoDelNotifyDetail a left join part b on a.site=b.site and a.part_no=b.part_no
where a.site =#{site} and a.delNo=#{delNo} and a.qty>0 and a.bu_no=#{buNo}
GROUP BY b.hsCodeDesc,b.hsCode,b.brand,b.ecss_umid,LEFT(a.currency,3)
</select>
<insertid="saveEcssDeclarationHeader">
insert into ecss_declaration_header (site,declaration_no,customs_office_code,input_code,local_shipper,local_ship_address,ship_type,ship_date,submit_date,