|
|
|
@ -118,7 +118,7 @@ |
|
|
|
select a.site,a.bu_no,a.delNo,a.item_no,a.salesOrder,a.salesOrder_item_no,a.customerPO,a.line,a.version,a.status,a.family, |
|
|
|
a.part_no,a.part_description,a.qty,a.lt,a.cmc_comment,a.saleType,a.awb_bl,a.shipping_number,a.forwarder_info,isnull(a.surplus_qty,0) surplusQty, |
|
|
|
a.currency,a.tp,a.ttl_amount,a.sum_price,a.so,a.upc,a.remark,a.erp_delItemNo,a.pn,CONVERT(DECIMAL(20, 0),a.nocartons) as nocartons, |
|
|
|
c.num_value as boxrolls,d.num_value as rollqty,w.num_value as boxweight,#{cmcInvoice} as cmcInvoice,a.modifyFlag, |
|
|
|
c.num_value as boxrolls,d.num_value as rollqty,w.num_value as boxweight,#{cmcInvoice} as cmcInvoice,a.modifyFlag,a.modifyQtyFlag, |
|
|
|
b.hsCodeDesc,a.vat,a.roll,a.carton,b.packageNo |
|
|
|
from ecss_CoDelNotifydetail a |
|
|
|
left join part b on a.site=b.site and a.part_no=b.part_no |
|
|
|
@ -139,7 +139,7 @@ |
|
|
|
select a.site,a.bu_no,a.delNo,a.item_no,a.salesOrder,a.salesOrder_item_no,a.customerPO,a.line,a.version,a.status,a.family, |
|
|
|
a.part_no,a.part_description,a.qty,a.lt,a.cmc_comment,a.saleType,a.awb_bl,a.shipping_number,a.forwarder_info, |
|
|
|
a.currency,a.tp,a.ttl_amount,a.sum_price,a.so,a.upc,a.remark,a.erp_delItemNo,a.pn,CONVERT(DECIMAL(20, 0),a.nocartons) as nocartons, |
|
|
|
a.modifyFlag |
|
|
|
a.modifyFlag,a.modifyQtyFlag |
|
|
|
from ecss_CoDelNotifydetail a |
|
|
|
<where> |
|
|
|
And a.site = #{site} |
|
|
|
@ -176,13 +176,13 @@ |
|
|
|
insert into ecss_CoDelNotifyDetail (site,bu_no,delNo,item_no,salesOrder,salesOrder_item_no,customerPO,line,version, |
|
|
|
status,family,part_no,part_description,qty,lt,cmc_comment,saleType, |
|
|
|
awb_bl,shipping_number,forwarder_info,currency,tp,ttl_amount,sum_price, |
|
|
|
so,upc,remark,pn,surplus_qty,vat,roll,carton,saleslt,manufacturer_name,modifyFlag) |
|
|
|
so,upc,remark,pn,surplus_qty,vat,roll,carton,saleslt,manufacturer_name,modifyFlag,modifyQtyFlag) |
|
|
|
values |
|
|
|
<foreach collection="list" separator="," item="item"> |
|
|
|
(#{item.site},#{item.buNo},#{item.delNo},#{item.itemNo,jdbcType=INTEGER},#{item.salesOrder,jdbcType=NVARCHAR},#{item.salesOrderItemNo},#{item.customerPO,jdbcType=NVARCHAR},#{item.line,jdbcType=NVARCHAR},#{item.version,jdbcType=NVARCHAR}, |
|
|
|
#{item.status,jdbcType=NVARCHAR},#{item.family,jdbcType=NVARCHAR},#{item.partNo},#{item.partDescription,jdbcType=NVARCHAR},#{item.qty,jdbcType=DECIMAL},#{item.lt,jdbcType=DECIMAL},#{item.cmcComment,jdbcType=NVARCHAR},#{item.saleType,jdbcType=NVARCHAR}, |
|
|
|
#{item.awbBl,jdbcType=NVARCHAR},#{item.shippingNumber,jdbcType=NVARCHAR},#{item.forwarderInfo,jdbcType=NVARCHAR},#{item.currency,jdbcType=NVARCHAR},#{item.tp,jdbcType=DECIMAL},#{item.ttlAmount,jdbcType=DECIMAL},#{item.sumPrice,jdbcType=DECIMAL}, |
|
|
|
#{item.so,jdbcType=NVARCHAR},#{item.upc,jdbcType=NVARCHAR},#{item.remark,jdbcType=NVARCHAR},#{item.pn,jdbcType=NVARCHAR},#{item.qty},#{item.vat},#{item.roll},#{item.carton},#{item.saleslt,jdbcType=NVARCHAR},#{item.manufacturerName,jdbcType=NVARCHAR},#{item.modifyFlag}) |
|
|
|
#{item.so,jdbcType=NVARCHAR},#{item.upc,jdbcType=NVARCHAR},#{item.remark,jdbcType=NVARCHAR},#{item.pn,jdbcType=NVARCHAR},#{item.qty},#{item.vat},#{item.roll},#{item.carton},#{item.saleslt,jdbcType=NVARCHAR},#{item.manufacturerName,jdbcType=NVARCHAR},#{item.modifyFlag},#{item.modifyQtyFlag}) |
|
|
|
</foreach> |
|
|
|
</insert> |
|
|
|
|
|
|
|
@ -220,7 +220,7 @@ |
|
|
|
</update> |
|
|
|
|
|
|
|
<update id="updateEcssDelDetailForModify" > |
|
|
|
update ecss_CoDelNotifyDetail set modifyFlag=#{modifyFlag},surplus_qty=0 where site=#{site} and delNo=#{delNo} |
|
|
|
update ecss_CoDelNotifyDetail set modifyFlag=#{modifyFlag},modifyQtyFlag=#{modifyFlag},surplus_qty=0 where site=#{site} and delNo=#{delNo} |
|
|
|
</update> |
|
|
|
|
|
|
|
<update id="changeEcssDelStatus"> |
|
|
|
@ -249,11 +249,11 @@ |
|
|
|
insert into ecss_CoDelNotifyDetail(site,bu_no,delNo,item_no,salesOrder,salesOrder_item_no,customerPO,line,version, |
|
|
|
status,family,part_no,part_description,qty,lt,cmc_comment,saleType, |
|
|
|
awb_bl,shipping_number,forwarder_info,currency,tp,ttl_amount,sum_price, |
|
|
|
so,upc,remark,pn,modifyFlag,surplus_qty,vat,roll,carton) |
|
|
|
so,upc,remark,pn,modifyFlag,modifyQtyFlag,surplus_qty,vat,roll,carton) |
|
|
|
values(#{site},#{buNo},#{delNo},#{itemNo,jdbcType=INTEGER},#{salesOrder},#{salesOrderItemNo},#{customerPO},#{line},#{version}, |
|
|
|
#{status},#{family},#{partNo},#{partDescription},#{qty,jdbcType=DECIMAL},#{lt,jdbcType=DECIMAL},#{cmcComment},#{saleType}, |
|
|
|
#{awbBl},#{shippingNumber},#{forwarderInfo},#{currency},#{tp,jdbcType=DECIMAL},#{ttlAmount,jdbcType=DECIMAL},#{sumPrice,jdbcType=DECIMAL}, |
|
|
|
#{so},#{upc},#{remark},#{pn},#{modifyFlag},#{qty},#{vat},#{roll},#{carton}) |
|
|
|
#{so},#{upc},#{remark},#{pn},#{modifyFlag},#{modifyQtyFlag},#{qty},#{vat},#{roll},#{carton}) |
|
|
|
</insert> |
|
|
|
|
|
|
|
<update id="updateEcssDelDetail"> |
|
|
|
@ -263,7 +263,7 @@ |
|
|
|
lt=#{lt,jdbcType=DECIMAL},cmc_comment=#{cmcComment},saleType=#{saleType},pn=#{pn}, |
|
|
|
awb_bl=#{awbBl},shipping_number=#{shippingNumber},forwarder_info=#{forwarderInfo},currency=#{currency}, |
|
|
|
tp=#{tp,jdbcType=DECIMAL},ttl_amount=#{ttlAmount,jdbcType=DECIMAL},sum_price=#{sumPrice,jdbcType=DECIMAL}, |
|
|
|
so=#{so},upc=#{upc},remark=#{remark},modifyFlag=#{modifyFlag},surplus_qty=#{qty},vat=#{vat},roll=#{roll},carton=#{carton} |
|
|
|
so=#{so},upc=#{upc},remark=#{remark},modifyFlag=#{modifyFlag},modifyQtyFlag=#{modifyQtyFlag},surplus_qty=#{qty},vat=#{vat},roll=#{roll},carton=#{carton} |
|
|
|
where |
|
|
|
site=#{site} and delNo=#{delNo} and item_no=#{itemNo} |
|
|
|
</update> |
|
|
|
@ -547,12 +547,45 @@ create_by,create_date,update_by,update_date |
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="getDefaultEcssDeclarationDetailData" resultType="EcssDeclarationDetailData"> |
|
|
|
select #{site} as site, b.hsCode,b.hsCodeDesc as hsCodeDesc,sum(a.qty) as qty,sum( c.Net_Weight) as NetWeight |
|
|
|
,'CNY' as currency,'中国' as madeArea,#{destination} as destination,'南通其他' as sourceArea ,'照章征免' as levy |
|
|
|
from ecss_CoDelPalletDetail a left join part b on a.site=b.site and a.part_no=b.part_no |
|
|
|
left join ecss_CoDelBoxList c on a.site=c.site and a.delNo=c.delNo and a.seq_no=c.item_no |
|
|
|
where a.site =#{site} and a.delNo=#{delNo} and a.bu_no=#{buNo} |
|
|
|
GROUP BY b.hsCodeDesc,b.hsCode |
|
|
|
-- 修复重复计算净重的问题:使用子查询先计算每个hsCode的数量和总净重,然后按比例分配 |
|
|
|
WITH HsCodeQty AS ( |
|
|
|
-- 先计算每个hsCode的总数量 |
|
|
|
SELECT b.hsCode, b.hsCodeDesc, SUM(a.qty) as totalQty |
|
|
|
FROM ecss_CoDelPalletDetail 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.bu_no=#{buNo} |
|
|
|
GROUP BY b.hsCode, b.hsCodeDesc |
|
|
|
), |
|
|
|
TotalWeight AS ( |
|
|
|
-- 计算总净重(不重复) |
|
|
|
SELECT SUM(net_weight) as totalNetWeight |
|
|
|
FROM ecss_CoDelBoxList |
|
|
|
WHERE site=#{site} AND delNo=#{delNo} AND bu_no=#{buNo} |
|
|
|
), |
|
|
|
TotalQty AS ( |
|
|
|
-- 计算总数量 |
|
|
|
SELECT SUM(qty) as allQty |
|
|
|
FROM ecss_CoDelPalletDetail |
|
|
|
WHERE site=#{site} AND delNo=#{delNo} AND bu_no=#{buNo} |
|
|
|
) |
|
|
|
SELECT |
|
|
|
#{site} as site, |
|
|
|
h.hsCode, |
|
|
|
h.hsCodeDesc, |
|
|
|
h.totalQty as qty, |
|
|
|
-- 按数量比例分配净重:(该hsCode的数量 / 总数量) * 总净重 |
|
|
|
CASE |
|
|
|
WHEN tq.allQty > 0 THEN CONVERT(DECIMAL(20,2), (h.totalQty * tw.totalNetWeight) / tq.allQty) |
|
|
|
ELSE 0 |
|
|
|
END as NetWeight, |
|
|
|
'CNY' as currency, |
|
|
|
'中国' as madeArea, |
|
|
|
#{destination} as destination, |
|
|
|
'南通其他' as sourceArea, |
|
|
|
'照章征免' as levy |
|
|
|
FROM HsCodeQty h |
|
|
|
CROSS JOIN TotalWeight tw |
|
|
|
CROSS JOIN TotalQty tq |
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="getDefaultEcssDeclarationDetailData2" resultType="EcssDeclarationDetailData"> |
|
|
|
@ -887,7 +920,7 @@ left join ecss_CoDelNotifyHeader noHeader on a.site=noHeader.site and a.delNo=no |
|
|
|
select a.site,a.bu_no,a.delNo,a.item_no,a.salesOrder,a.salesOrder_item_no,a.customerPO,a.line,a.version,a.status,a.family, |
|
|
|
a.part_no,a.part_description,a.qty,a.lt,a.cmc_comment,a.saleType,a.awb_bl,a.shipping_number,a.forwarder_info,isnull(a.surplus_qty,0) surplusQty, |
|
|
|
a.currency,a.tp,a.ttl_amount,a.sum_price,a.so,a.upc,a.remark,a.erp_delItemNo,a.pn,CONVERT(DECIMAL(20, 0),a.nocartons) as nocartons, |
|
|
|
a.modifyFlag |
|
|
|
a.modifyFlag,a.modifyQtyFlag |
|
|
|
from ecss_CoDelNotifydetail a |
|
|
|
where a.site = #{site} |
|
|
|
and a.bu_no = #{buNo} |
|
|
|
|