You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

1095 lines
55 KiB

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.xujie.sys.modules.ecss.mapper.CoDelMapper">
<!-- <select id="searchEcssCoDelNotify" parameterType="EcssCoDelNotifyData" resultType="EcssCoDelNotifyData">-->
<!-- select a.site,a.bu_no,a.delNo,a.item_no,a.notifyDate,a.salesOrder,a.ready_date,a.customer_name,a.customerPO,a.line,a.version,-->
<!--a.status,a.family,a.part_no,a.part_description,a.qty,a.lt,a.cmc_invoice,a.cmc_comment,a.Destination,a.saleType,-->
<!--a.awb_bl,a.shipping_number,a.shipping_mode,a.forwarder_info,a.currency,a.tp,a.ttl_amount,a.sum_price,a.so,a.upc,-->
<!--a.remark,a.erp_flag,a.notify_status,a.erp_delNo,a.erp_delItemNo,dbo.get_bu_desc(a.site,a.bu_no ) buDesc-->
<!-- from ecss_CoDelNotify a-->
<!-- <where>-->
<!-- <if test="query.username != null and query.username != ''">-->
<!-- AND a.NotifyNo = #{query.username}-->
<!-- </if>-->
<!-- </where>-->
<!-- order by a.ready_date desc-->
<!-- </select>-->
<select id="searchEcssCoDelNotifyHeader" resultType="EcssCoDelNotifyHeaderData">
select a.site,a.bu_no,a.delNo,a.erp_delNo,a.ready_date,a.notifyDate,a.customer_name,a.Destination,a.shipping_mode,a.erp_flag,
a.notify_status,a.remark,a.createDate,a.createBy,a.cmc_invoice,a.updateDate,a.updateBy,dbo.get_bu_desc(a.site,a.bu_no) as buDesc,
a.modifyFlag,a.overseasShipper,a.overseasAddress,a.cnative,a.localShipAddress
from ecss_CoDelNotifyHeader a
left join accessBu D on A.site=D.site and A.bu_no=d.bu_no and D.username=#{query.username}
<where>
and D.site is not null
<if test="query.buNo != null and query.buNo != ''">
AND a.bu_no = #{query.buNo}
</if>
<if test="query.delNo != null and query.delNo != ''">
AND a.delNo like #{query.delNo}
</if>
<if test="query.cmcInvoice != null and query.cmcInvoice != ''">
AND a.cmc_invoice like #{query.cmcInvoice}
</if>
<if test="query.notifyStatus != null and query.notifyStatus != ''">
AND a.notify_status = #{query.notifyStatus}
</if>
<if test = "query.startDate!= null">
AND a.ready_date>= #{query.startDate}
</if>
<if test = "query.endDate!= null">
AND #{query.endDate} >=a.ready_date
</if>
<if test="query.modifyData == 'true'">
and a.modifyFlag=1
</if>
</where>
order by a.createDate desc ,a.delNo desc
</select>
<select id="searchEcssCoDelNotifyHeaderForCK" resultType="EcssCoDelNotifyHeaderData">
select a.site,a.bu_no,a.delNo,a.erp_delNo,a.ready_date,a.notifyDate,a.customer_name,a.Destination,a.shipping_mode,a.erp_flag,
a.notify_status,a.remark,a.createDate,a.createBy,a.cmc_invoice,a.updateDate,a.updateBy,dbo.get_bu_desc(a.site,a.bu_no) as buDesc,a.walMartOrderFlag,
a.modifyFlag,ISNULL(a.export_flag,'N') as exportFlag
from ecss_CoDelNotifyHeader a
left join accessBu D on A.site=D.site and A.bu_no=d.bu_no and D.username=#{query.username}
<where>
and D.site is not null
<if test="query.buNo != null and query.buNo != ''">
AND a.bu_no = #{query.buNo}
</if>
<if test="query.delNo != null and query.delNo != ''">
AND a.delNo like #{query.delNo}
</if>
<if test="query.cmcInvoice != null and query.cmcInvoice != ''">
AND a.cmc_invoice like #{query.cmcInvoice}
</if>
<if test="query.notifyStatus != null and query.notifyStatus != ''">
AND a.notify_status = #{query.notifyStatus}
</if>
AND a.notify_status != '已计划' AND a.notify_status != '订单取消'
<if test = "query.startDate!= null">
AND a.ready_date>= #{query.startDate}
</if>
<if test = "query.endDate!= null">
AND #{query.endDate} >=a.ready_date
</if>
<if test="query.modifyData == 'true'">
and a.modifyFlag=1
</if>
<if test="query.exportFlag != null and query.exportFlag != ''">
and ISNULL(a.export_flag,'N') = #{query.exportFlag}
</if>
</where>
order by a.createDate desc ,a.delNo desc
</select>
<select id="searchEcssCoDelNotifyHeaderForDanZheng" resultType="EcssCoDelNotifyHeaderData">
select a.site,a.bu_no,a.delNo,a.erp_delNo,a.ready_date,a.notifyDate,a.customer_name,a.Destination,a.shipping_mode,a.erp_flag,
a.notify_status,a.remark,a.createDate,a.createBy,a.cmc_invoice,a.updateDate,a.updateBy,dbo.get_bu_desc(a.site,a.bu_no) as buDesc
from ecss_CoDelNotifyHeader a
left join accessBu D on A.site=D.site and A.bu_no=d.bu_no and D.username=#{query.username}
<where>
and D.site is not null
<if test="query.buNo != null and query.buNo != ''">
AND a.bu_no = #{query.buNo}
</if>
<if test="query.delNo != null and query.delNo != ''">
AND a.delNo like #{query.delNo}
</if>
<if test="query.cmcInvoice != null and query.cmcInvoice != ''">
AND a.cmc_invoice like #{query.cmcInvoice}
</if>
<if test="query.notifyStatus != null and query.notifyStatus != ''">
AND a.notify_status = #{query.notifyStatus}
</if>
AND a.notify_status = '仓库已确认'
<if test = "query.startDate!= null">
AND a.ready_date>= #{query.startDate}
</if>
<if test = "query.endDate!= null">
AND #{query.endDate} >=a.ready_date
</if>
</where>
order by a.createDate desc ,a.delNo desc
</select>
<select id="checkEcssCoDelNotifyHeaderByDelNo" resultType="EcssCoDelNotifyHeaderData">
select a.site,a.bu_no,a.delNo,a.erp_delNo,a.ready_date,a.notifyDate,a.customer_name,a.Destination,a.shipping_mode,a.erp_flag,
a.notify_status,a.remark,a.createDate,a.createBy,a.cmc_invoice,a.updateDate,a.updateBy,dbo.get_bu_desc(a.site,a.bu_no) as buDesc
,a.overseasShipper,a.overseasAddress,a.cnative,a.localShipAddress
from ecss_CoDelNotifyHeader a
where a.site = #{site}
AND a.delNo = #{delNo}
</select>
<select id="searchEcssCoDelNotifyDetail" resultType="EcssCoDelNotifyDetailData">
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,
c.num_value as boxrolls,d.num_value as rollqty,#{cmcInvoice} as cmcInvoice,a.modifyFlag
from ecss_CoDelNotifydetail a
left join part_sub_properties_value c on a.part_no=c.part_no and c.site=a.site and c.bu_no=a.bu_no
and c.record_type='ECSSPART' and c.code_no='BG001' and c.properties_item_no='BOXROLLS'
left join part_sub_properties_value d on a.part_no=d.part_no and d.site=a.site and d.bu_no=a.bu_no
and d.record_type='ECSSPART' and d.code_no='BG001' and d.properties_item_no='ROLLQTY'
<where>
And a.site = #{site}
AND a.delNo = #{delNo}
</where>
order by a.item_no
</select>
<select id="getEcssCoDelNotifyDetail" resultType="EcssCoDelNotifyDetailData">
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
from ecss_CoDelNotifydetail a
<where>
And a.site = #{site}
AND a.delNo = #{delNo}
AND a.item_no = #{itemNo} and a.qty>0
</where>
</select>
<select id="getSiteByBu" resultType="String">
select top 1 site from BU where bu_no=#{buNo}
</select>
<select id="checkIfHasHeader" resultType="EcssCoDelNotifyHeaderData">
select top 1 * from ecss_CoDelNotifyHeader where cmc_invoice=#{inVoice}
</select>
<update id="updateTransNo" >
EXEC UpdateTransNo #{site}, #{transType}
</update>
<select id="getTransNo" resultType="String">
SELECT
dbo.Get_TransNo(#{site},#{transType}) as transNo
</select>
<insert id="saveEcssCoDelNotifyHeader" >
insert into ecss_CoDelNotifyHeader(site,bu_no,delNo,ready_date,customer_name,Destination,shipping_mode,erp_flag,notify_status,
remark,createDate,createBy,cmc_invoice,overseasShipper,overseasAddress,cnative,localShipAddress)
values(#{site},#{buNo},#{delNo},#{readyDate},#{customerName},#{destination},#{shippingMode},'N',#{notifyStatus},#{remark},GetDate(),
#{createBy},#{cmcInvoice},#{overseasShipper},#{overseasAddress},#{cnative},#{localShipAddress})
</insert>
<insert id="batchSaveEcssCoDelNotifyDetail">
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)
values
<foreach collection="list" separator="," item="item">
(#{item.site},#{item.buNo},#{item.delNo},#{item.itemNo,jdbcType=INTEGER},#{item.salesOrder},#{item.salesOrderItemNo},#{item.customerPO},#{item.line},#{item.version},
#{item.status},#{item.family},#{item.partNo},#{item.partDescription},#{item.qty,jdbcType=DECIMAL},#{item.lt,jdbcType=DECIMAL},#{item.cmcComment},#{item.saleType},
#{item.awbBl},#{item.shippingNumber},#{item.forwarderInfo},#{item.currency},#{item.tp,jdbcType=DECIMAL},#{item.ttlAmount,jdbcType=DECIMAL},#{item.sumPrice,jdbcType=DECIMAL},
#{item.so},#{item.upc},#{item.remark},#{item.pn})
</foreach>
</insert>
<select id="checkPart" resultType="PartData">
select site,part_no from Part where site=#{site,jdbcType=VARCHAR} and part_no=#{partNo}
</select>
<select id="getPartNo" resultType="PartData">
select top 1 site,part_no from Part where site=#{site,jdbcType=VARCHAR} and sku=#{partNo} and sourceBu=#{buNo} and
site in (select site from eam_access_site where username = #{userName})
and (site + '-' + sourceBu) in (select * from dbo.query_bu(#{userName}))
</select>
<select id="getPartInfo" resultType="PartData">
select * from Part where site=#{site,jdbcType=VARCHAR} and part_no=#{partNo}
</select>
<update id="updateEcssDelHeader" >
update ecss_CoDelNotifyHeader set ready_date=#{readyDate,jdbcType=TIMESTAMP} ,customer_name=#{customerName},
Destination=#{destination},shipping_mode=#{shippingMode},
remark=#{remark} ,cmc_invoice=#{cmcInvoice},overseasShipper=#{overseasShipper} ,overseasAddress=#{overseasAddress}
where site=#{site} and delNo=#{delNo}
</update>
<delete id="deleteEcssDelHeader">
delete from ecss_CoDelNotifyHeader where site=#{site} and delNo=#{delNo}
</delete>
<update id="updateEcssDelHeaderForBaoGuan" >
update ecss_CoDelNotifyHeader set declaration_no=#{declarationNo} ,notify_status=#{status} where site=#{site} and delNo=#{delNo}
</update>
<update id="updateEcssDelHeaderForModify" >
update ecss_CoDelNotifyHeader set modifyFlag=#{modifyFlag} where site=#{site} and delNo=#{delNo}
</update>
<update id="updateEcssDelDetailForModify" >
update ecss_CoDelNotifyDetail set modifyFlag=#{modifyFlag} where site=#{site} and delNo=#{delNo}
</update>
<update id="changeEcssDelStatus">
update ecss_CoDelNotifyHeader set notify_status=#{notifyStatus},walMartOrderFlag=#{walMartOrderFlag} where site=#{site} and delNo=#{delNo}
</update>
<update id="updateEcssDelDetailStatus">
update ecss_CoDelNotifyDetail
set status=#{notifyStatus}
where site=#{site} and delNo=#{delNo}
</update>
<select id="getEcssDelDetailItemNo" resultType="int">
select isnull(max(item_no),0)+1 as itemNo from ecss_CoDelNotifyDetail
where site =#{site} and bu_no=#{buNo} and delNo=#{delNo}
</select>
<insert id="insertEcssDelDetail" >
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)
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})
</insert>
<update id="updateEcssDelDetail">
update ecss_CoDelNotifyDetail
set salesOrder=#{salesOrder},customerPO=#{customerPO},line=#{line},version=#{version},
status=#{status},family=#{family},part_no=#{partNo},part_description=#{partDescription},qty=#{qty,jdbcType=DECIMAL},
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}
where
site=#{site} and delNo=#{delNo} and item_no=#{itemNo}
</update>
<delete id="deleteEcssDelDetail">
delete from ecss_CoDelNotifyDetail where site=#{site} and delNo=#{delNo} and item_no=#{itemNo}
</delete>
<delete id="deleteAllEcssDelDetail">
delete from ecss_CoDelNotifyDetail where site=#{site} and delNo=#{delNo}
</delete>
<update id="confirmEcssDel">
update ecss_CoDelNotifyHeader set notify_status=#{notifyStatus} ,notifyDate=#{notifyDate,jdbcType=TIMESTAMP} where site=#{site} and delNo=#{delNo}
</update>
<update id="updateEcssDel">
update ecss_CoDelNotifyHeader set ready_date=#{readyDate,jdbcType=TIMESTAMP},notifyDate=#{notifyDate,jdbcType=TIMESTAMP}
where site=#{site} and delNo=#{delNo}
</update>
<select id="searchHsCodeData" resultType="EcssHsCodeData">
select a.Site,a.BuNo,a.HsCode,a.Remark,a.CreateBy,a.CreateDate,a.UpdateBy,a.UpdateDate,a.codeNo
,dbo.get_bu_desc(a.site,a.BuNo) as BuDesc,a.hsCodeDesc,a.hsCodeDescEn,a.unit
from ecss_hsCode a
left join accessBu D on A.site=D.site and A.BuNo=d.bu_no and D.username=#{query.username}
<where>
and D.site is not null
<if test="query.buNo != null and query.buNo != ''">
AND a.BuNo = #{query.buNo}
</if>
<if test="query.hsCode != null and query.hsCode != ''">
AND a.HsCode like #{query.hsCode}
</if>
</where>
order by a.CreateDate ,a.HsCode
</select>
<select id="checkHsCodeDescData" resultType="EcssHsCodeData">
select a.Site,a.BuNo,a.HsCode,a.hsCodeDesc
from ecss_hsCode a where a.site=#{site} and a.buNo=#{buNo} and a.HsCodeDesc=#{hsCodeDesc}
</select>
<select id="checkPropertiesModel" resultType="com.xujie.sys.modules.attrbute.entity.PropertyModelHeader">
select site,bu_no,function_type ,code_no from plm_properties_model_header
where site=#{site} and bu_no=#{buNo} and function_type=#{functionType} and code_no=#{codeNo}
</select>
<insert id="insertHsCodeData" >
insert into ecss_hsCode (Site,BuNo,HsCode,Remark,CreateBy,CreateDate,codeNo,hsCodeDesc,hsCodeDescEn,unit)
values(#{site},#{buNo},#{hsCode},#{remark},#{createBy},GetDate(),#{codeNo},#{hsCodeDesc},#{hsCodeDescEn},#{unit})
</insert>
<update id="updateHsCodeData">
update ecss_hsCode set Remark=#{remark} ,codeNo=#{codeNo},HsCode=#{hsCode},unit=#{unit} ,UpdateDate=GetDate(),UpdateBy=#{updateBy},hsCodeDescEn=#{hsCodeDescEn}
where site=#{site} and buNo=#{buNo} and hsCodeDesc=#{hsCodeDesc}
</update>
<select id="deleteHsCode" >
delete from ecss_hsCode where site=#{site} and buNo=#{buNo} and hsCodeDesc=#{hsCodeDesc}
</select>
<select id="searchPropertiesItemList" resultType="com.xujie.sys.modules.attrbute.entity.PropertyItem">
select
id,site,bu_no,item_no,item_type,item_desc,default_value,value_type,value_type_db,value_choose_flag,min_value,max_value,
create_by,create_date,update_by,update_date
from dbo.plm_properties_item
<where>
and site = #{site} and bu_no=#{buNo}
<if test="itemNo != null and itemNo != ''">
and item_no like #{itemNo}
</if>
<if test="itemDesc != null and itemDesc != ''">
and item_desc like #{itemDesc}
</if>
<if test="itemType != null and itemType != ''">
and item_type = #{itemType}
</if>
order by item_type ,item_no
</where>
</select>
<select id="getPropertiesListByPartAndCodeNo" resultType="com.xujie.sys.modules.part.entity.PartSubPropertiesValueData">
SELECT a.part_no
, a.Site
, a.code_no
, a.sub_code_seq_no
, a.sub_code_desc
,a.bu_no
,a.item_no
, a.properties_item_no
, a.text_value
, a.num_value
, a.record_type
, b.item_desc ItemDesc
, b.value_type
, b.value_type_db
, b.value_choose_flag
FROM part_sub_properties_value a
left join plm_properties_item b
on a.properties_item_no = b.Item_No and a.site = b.site and a.record_type = b.Item_Type and a.bu_no=b.bu_no
<where>
AND a.site = #{site}
and a.record_type = #{recordType}
and a.bu_no=#{buNo}
and a.code_no = #{codeNo}
AND a.part_no = #{partNo,jdbcType=VARCHAR}
</where>
order by a.item_no
</select>
<update id="updatePropertiesList">
update part_sub_properties_value
set text_value=#{textValue},
num_value=#{numValue,jdbcType=DOUBLE}
where Site = #{site}
and code_no = #{codeNo}
and part_no = #{partNo}
and sub_code_seq_no = #{subCodeSeqNo}
and item_no = #{itemNo}
and bu_no=#{buNo}
</update>
<insert id="saveSubPropertiesValueForAlone">
insert into part_sub_properties_value ( part_no, site, bu_no, code_no, sub_code_seq_no, sub_code_desc,
item_no, properties_item_no, text_value, num_value, record_type)
select
#{partNo},
#{site},
#{buNo},
#{codeNo},
1,
d.code_desc,
#{itemNo,jdbcType=DOUBLE},
c.item_no,
case when c.value_type_db = 'T' then c.default_value else null end,
case when c.value_type_db = 'N' and c.default_value != '' then c.default_value else null end,
#{recordType}
from plm_properties_item c
left join plm_properties_model_header d on c.site=d.site and d.code_no=#{codeNo}
where c.Item_No = #{propertiesItemNo}
and c.site = #{site}
and c.bu_no=#{buNo}
and c.item_Type = #{recordType}
</insert>
<delete id="deleteSubPropertiesValueForAlone">
delete
from part_sub_properties_value
where site = #{site}
and record_type = #{recordType}
and bu_no=#{buNo}
and code_no = #{codeNo}
AND part_no = #{partNo,jdbcType=VARCHAR}
</delete>
<select id="getNewSeqNoForAlone" resultType="Double">
select isnull(Max(item_No) + 1, 1)
from part_sub_properties_value a
where a.site = #{site}
and a.record_type = #{recordType}
and a.bu_no=#{buNo}
and a.code_no = #{codeNo}
AND a.part_no = #{partNo,jdbcType=VARCHAR}
</select>
<select id="searchPropertiesUnChoose" resultType="com.xujie.sys.modules.ecss.entity.PropertyItemData">
SELECT
b.id,b.site,b.bu_no,b.item_no,b.item_type as functionType,b.item_desc,b.default_value,b.value_type,b.value_type_db,b.value_choose_flag,
b.min_value,b.max_value,b.create_by,b.create_date,b.update_by,b.update_date
FROM plm_properties_item b
where b.item_type = #{codeType}
and b.site = #{site} and b.bu_no=#{buNo}
<if test="list != null and list.size() != 0">
and b.item_no not in (
<foreach collection="list" item="item" separator=",">
#{item}
</foreach>
)
</if>
</select>
<select id="searchCoDelPalletData" resultType="EcssCoDelPalletData">
select a.site,a.bu_no,a.delNo,a.seq_no,a.pallet_no,a.pallet_qty,a.[length],a.width,a.height,a.volume,a.gross_weight,a.net_weight,
a.pallet_remark,a.create_by,a.create_date,a.update_by,a.update_date,b.item_no,b.po_no,b.part_no,b.qty,b.box_qty,b.rolls,b.pn
from ecss_CoDelPalletHeader a
left join ecss_CoDelPalletDetail b on a.site=b.site and a.bu_no=b.bu_no and a.delNo=b.delNo and a.seq_no=b.seq_no
where a.site=#{site} and a.bu_no=#{buNo} and a.delNo=#{delNo} and b.site is not null
</select>
<insert id="saveCodelPalletHeader">
insert into ecss_CoDelPalletHeader (site,bu_no,delNo,seq_no,pallet_no,pallet_qty,[length],width,height,volume,gross_weight,net_weight,pallet_remark,create_by,
create_date,pallet)
values(#{site},#{buNo},#{delNo},#{seqNo},#{palletNo},#{palletQty},#{length},#{width},#{height},#{volume},#{grossWeight,jdbcType=DECIMAL},#{netWeight,jdbcType=DECIMAL},#{palletRemark},#{createBy},
GETDATE(),#{pallet})
</insert>
<insert id="saveCodelBoxList">
insert into ecss_CoDelBoxList(site,bu_no,delNo,seq_no,item_no,gross_weight,net_weight,box_qty,create_by,create_date)
values (#{site},#{buNo},#{delNo},#{seqNo},#{itemNo},#{grossWeight,jdbcType=DECIMAL},#{netWeight,jdbcType=DECIMAL},#{boxQty},#{createBy},GETDATE())
</insert>
<insert id="saveCodelPalletDetail">
insert into ecss_CoDelPalletDetail(site,bu_no,delNo,seq_no,item_no,part_no,qty,po_no,box_qty,create_by,create_date,rolls,pn)
values (#{site},#{buNo},#{delNo},#{seqNo},#{itemNo},#{partNo},#{qty,jdbcType=DECIMAL},#{poNo},#{boxQty},#{createBy},GETDATE(),#{rolls,jdbcType=DECIMAL},#{pn})
</insert>
<select id="searchEcssCoDelPalletHeaderData" resultType="EcssCoDelPalletHeaderData">
select site,bu_no,delNo,seq_no,pallet_no,pallet_qty,[length],width,height,volume,gross_weight,net_weight,pallet_remark,create_by,
create_date,update_by,update_date,pallet from ecss_CoDelPalletHeader
where site =#{site} and bu_no=#{buNo} and delNo=#{delNo}
</select>
<select id="searchEcssCoDelPalletDetailData" resultType="EcssCoDelPalletDetailData">
select site,bu_no,delNo,seq_no,item_no,part_no,qty,po_no,box_qty,create_by,create_date,update_by,update_date,rolls,pn
from ecss_CoDelPalletDetail
where site =#{site} and bu_no=#{buNo} and delNo=#{delNo} and seq_no=#{seqNo}
</select>
<select id="getCoDelPalletHeaderSeqNo" resultType="int">
select isnull(max(seq_no),0)+1 as seqNo from ecss_CoDelPalletHeader
where site =#{site} and bu_no=#{buNo} and delNo=#{delNo}
</select>
<select id="getCoDelPalletDetailItem" resultType="int">
select isnull(max(item_no),0)+1 as item_no from ecss_CoDelPalletDetail
where site =#{site} and bu_no=#{buNo} and delNo=#{delNo} and seq_no=#{seqNo}
</select>
<update id="updateCodelPalletHeader">
update ecss_CoDelPalletHeader set pallet_qty=#{palletQty,jdbcType=INTEGER},[length]=#{length,jdbcType=DECIMAL},width=#{width,jdbcType=DECIMAL},height=#{height,jdbcType=DECIMAL},
volume=#{volume,jdbcType=DECIMAL},gross_weight=#{grossWeight,jdbcType=DECIMAL},net_weight=#{netWeight,jdbcType=DECIMAL},pallet_remark=#{palletRemark},
update_by=#{updateBy},update_date=GetDate(),pallet=#{pallet}
where site =#{site} and bu_no=#{buNo} and delNo=#{delNo} and seq_no=#{seqNo}
</update>
<update id="updateCodelPalletHeader2">
update ecss_CoDelPalletHeader set gross_weight=#{grossWeight,jdbcType=DECIMAL},net_weight=#{netWeight,jdbcType=DECIMAL},
update_by=#{updateBy},update_date=GetDate()
where site =#{site} and bu_no=#{buNo} and delNo=#{delNo} and seq_no=#{seqNo}
</update>
<update id="updateCodelPalletDetail">
update ecss_CoDelPalletDetail set part_no=#{partNo},qty=#{qty,jdbcType=DECIMAL},po_no=#{poNo},
box_qty=#{boxQty,jdbcType=DECIMAL},update_by=#{updateBy},update_date=GetDate(),rolls=#{rolls},pn=#{pn}
where site =#{site} and bu_no=#{buNo} and delNo=#{delNo} and seq_no=#{seqNo} and item_no=#{itemNo}
</update>
<delete id="deletePalletHeader">
delete from ecss_CoDelPalletHeader where site =#{site} and bu_no=#{buNo} and delNo=#{delNo}
<if test="seqNo != null and seqNo != ''">
and seq_no=#{seqNo}
</if>
</delete>
<delete id="deleteBoxList">
delete from ecss_CoDelBoxList where site =#{site} and bu_no=#{buNo} and delNo=#{delNo}
<if test="seqNo != null and seqNo != ''">
and seq_no=#{seqNo}
</if>
</delete>
<delete id="deletePalletDetail">
delete from ecss_CoDelPalletDetail where site =#{site} and bu_no=#{buNo} and delNo=#{delNo}
<if test="seqNo != null and seqNo != ''">
and seq_no=#{seqNo}
</if>
<if test="itemNo != null and itemNo != ''">
and item_no=#{itemNo}
</if>
</delete>
<select id="getAllWeight" resultType="com.xujie.sys.modules.ecss.entity.EcssCoDelPalletHeader">
select sum(gross_weight) as gross_weight ,sum(net_weight) as net_weight from ecss_CoDelBoxList
where site =#{site} and delNo=#{delNo}
</select>
<select id="getDefaultEcssDeclarationDetailData" resultType="EcssDeclarationDetailData">
select #{site} as site, b.hsCode,b.hsCodeDesc as hsCodeDesc,sum(a.qty) as qty,sum(distinct 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}
GROUP BY b.hsCodeDesc,b.hsCode
</select>
<select id="getDefaultEcssDeclarationDetailData2" resultType="EcssDeclarationDetailData">
select #{site} as site, b.hsCode,b.hsCodeDesc as hsCodeDesc,sum( a.qty) as qty ,sum(a.ttl_amount) as totalPrice,
CONVERT(DECIMAL(20, 6),sum(a.ttl_amount)/sum( a.qty)) as unitPrice,
'CNY' 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
GROUP BY b.hsCodeDesc,b.hsCode
</select>
<insert id="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,
filing_no,overseas_shipper,shipping_mode,shipping_data,deliver_no,sales_partner,regulatory_method,duty_status,
permit_number,cmc_invoice,sales_area,receive_area,shipping_port,exit_port,documents,remark,package_type,package_qty,
gross_weight,net_weight,payment_type,ship_price,premium,other_price,special_relationship_comfirm,price_influence_confirm,
royalty_payments_confirm,create_by,create_date,delNo,overseas_address,box_qty)
values(#{site},#{declarationNo},#{customsOfficeCode},#{inputCode},#{localShipper},#{localShipAddress},#{shipType},#{shipDate},#{submitDate},
#{filingNo},#{overseasShipper},#{shippingMode},#{shippingData},#{deliverNo},#{salesPartner},#{regulatoryMethod},#{dutyStatus},
#{permitNumber},#{cmcInvoice},#{salesArea},#{receiveArea},#{shippingPort},#{exitPort},#{documents},#{remark},#{packageType},#{packageQty,jdbcType=INTEGER},
#{grossWeight,jdbcType=DECIMAL},#{netWeight,jdbcType=DECIMAL},#{paymentType},#{shipPrice,jdbcType=DECIMAL},#{premium,jdbcType=DECIMAL},#{otherPrice,jdbcType=DECIMAL},#{specialRelationshipComfirm},#{priceInfluenceConfirm},
#{royaltyPaymentsConfirm},#{createBy},GETDATE(),#{delNo},#{overseasAddress},#{boxQty})
</insert>
<insert id="saveEcssDeclarationDetail">
insert into ecss_declaration_detail(site,declaration_no,item_no,hs_code,hs_code_desc,qty,net_weight,unit_price,total_price,currency,made_area,destination,
source_area,levy)
values(#{site},#{declarationNo},#{itemNo,jdbcType=INTEGER},#{hsCode},#{hsCodeDesc},#{qty,jdbcType=DECIMAL},#{netWeight,jdbcType=DECIMAL},#{unitPrice,jdbcType=DECIMAL},#{totalPrice,jdbcType=DECIMAL},#{currency},#{madeArea},#{destination},
#{sourceArea},#{levy})
</insert>
<select id="searchDeclarationHeader" resultType="EcssDeclarationHeaderData">
select a.site,a.declaration_no,a.customs_office_code,a.input_code,a.local_shipper,a.local_ship_address,a.ship_type,
a.ship_date,a.submit_date,a.filing_no,a.overseas_shipper,a.shipping_mode,a.shipping_data,a.deliver_no,a.sales_partner,
a.regulatory_method,a.duty_status,a.permit_number,a.cmc_invoice,a.sales_area,a.receive_area,a.shipping_port,
a.exit_port,a.documents,a.remark,a.package_type,a.package_qty,a.gross_weight,a.net_weight,a.payment_type,a.ship_price,
a.premium,a.other_price,a.special_relationship_comfirm,a.price_influence_confirm,a.royalty_payments_confirm,
a.create_by,a.create_date,a.update_by,a.update_date,a.delNo,noHeader.bu_no,
a.upc,a.so,a.origin,a.pallet_weight,a.material,a.hs_code,a.packaging,a.kgs,a.shipping_mark,
a.hsCodeDesc,a.contractFlag,a.hsCodeDescType,a.goodsLabel,a.boxChange,noHeader.customer_name as customName
from ecss_declaration_header a
left join ecss_CoDelNotifyHeader noHeader on a.site=noHeader.site and a.delNo=noHeader.delNo
<where>
<if test="query.delNo != null and query.delNo != ''">
AND a.delNo like #{query.delNo}
</if>
<if test="query.declarationNo != null and query.declarationNo != ''">
AND a.declaration_no like #{query.declarationNo}
</if>
<if test="query.cmcInvoice != null and query.cmcInvoice != ''">
AND a.cmc_invoice like #{query.cmcInvoice}
</if>
<if test="query.site != null and query.site != ''">
AND a.site like #{query.site}
</if>
<if test = "query.startDate!= null">
AND a.ship_date>= #{query.startDate}
</if>
<if test = "query.endDate!= null">
AND #{query.endDate} >=a.ship_date
</if>
</where>
order by a.create_date desc
</select>
<select id="searchDeclarationDetail" resultType="EcssDeclarationDetailData">
select site,declaration_no,item_no,hs_code,hs_code_desc,qty,net_weight,unit_price,total_price,currency,made_area,destination,
source_area,levy
from ecss_declaration_detail
where site=#{site} and declaration_no=#{declarationNo}
</select>
<delete id="deleteDeclarationHeader">
delete from ecss_declaration_header where site=#{site} and declaration_no=#{declarationNo}
</delete>
<delete id="deleteDeclarationDetail">
delete from ecss_declaration_detail where site=#{site} and declaration_no=#{declarationNo}
</delete>
<select id="searchPalletData" resultType="EcssPalletData">
select a.id,a.Site,a.BuNo,a.pallet_type as palletType,a.Remark,a.CreateBy,a.CreateDate,a.UpdateBy,a.UpdateDate,
a.length, a.width, a.height, a.application_area as applicationArea
,dbo.get_bu_desc(a.site,a.BuNo) as BuDesc,a.pallet_no as palletNo
from ecss_pallet a
left join accessBu D on A.site=D.site and A.BuNo=d.bu_no and D.username=#{query.username}
<where>
and D.site is not null
<if test="query.buNo != null and query.buNo != ''">
AND a.BuNo = #{query.buNo}
</if>
<if test="query.palletType != null and query.palletType != ''">
AND a.pallet_type = #{query.palletType}
</if>
</where>
order by a.CreateDate
</select>
<insert id="insertPalletData" >
insert into ecss_pallet (Site,BuNo,pallet_type,Remark,CreateBy,CreateDate,length,width,
height,application_area,pallet_no)
values(#{site},#{buNo},#{palletType},#{remark},#{createBy},GetDate(),#{length},#{width},
#{height},#{applicationArea},#{palletNo})
</insert>
<update id="updatePalletData">
update ecss_pallet set Remark=#{remark} ,pallet_type=#{palletType} ,
length=#{length} ,width=#{width} ,
height=#{height} ,application_area=#{applicationArea} ,
pallet_no=#{palletNo},
UpdateDate=GetDate(),UpdateBy=#{updateBy}
where site=#{site} and buNo=#{buNo} and id=#{id}
</update>
<select id="deletePallet" >
delete from ecss_pallet where site=#{site} and buNo=#{buNo} and id=#{id}
</select>
<select id="getPallet" resultType="EcssPalletData">
select * from ecss_pallet where site=#{site} and buNo=#{buNo} and pallet_no=#{palletNo}
</select>
<select id="getPackage" resultType="EcssPackageData">
select * from ecss_package where site=#{site} and buNo=#{buNo} and package_no=#{packageNo}
</select>
<insert id="insertPackageData" >
insert into ecss_package (Site,BuNo,package_type,Remark,CreateBy,CreateDate,length,width,
height,volume,weight,package_no)
values(#{site},#{buNo},#{packageType},#{remark},#{createBy},GetDate(),#{length},#{width},
#{height},#{volume},#{weight},#{packageNo})
</insert>
<update id="updatePackageData">
update ecss_package set Remark=#{remark} ,package_type=#{packageType} ,
length=#{length} ,width=#{width} ,volume=#{volume},weight=#{weight},
package_no=#{packageNo},height=#{height} ,
UpdateDate=GetDate(),UpdateBy=#{updateBy}
where site=#{site} and buNo=#{buNo} and id=#{id}
</update>
<select id="deleteEcssPackage" >
delete from ecss_package where site=#{site} and buNo=#{buNo} and id=#{id}
</select>
<select id="searchPackageData" resultType="EcssPackageData">
select a.id,a.Site,a.BuNo,a.package_type as packageType,a.Remark,a.CreateBy,a.CreateDate,a.UpdateBy,a.UpdateDate,
a.length, a.width, a.height, a.volume, a.weight,a.package_no as packageNo
,dbo.get_bu_desc(a.site,a.BuNo) as BuDesc
from ecss_package a
left join accessBu D on A.site=D.site and A.BuNo=d.bu_no and D.username=#{query.username}
<where>
and D.site is not null
<if test="query.buNo != null and query.buNo != ''">
AND a.BuNo = #{query.buNo}
</if>
<if test="query.packageType != null and query.packageType != ''">
AND a.package_type = #{query.packageType}
</if>
</where>
order by a.CreateDate
</select>
<select id="searchHsCodeList" resultType="java.util.Map">
select a.BuNo,a.HsCode,a.hsCodeDesc,a.unit,a.hsCodeDescEn
from ecss_hsCode a
<where> a.BuNo = #{buNo}
<if test="hsCode != null and hsCode != ''">
AND a.HsCode like '%'+#{hsCode}+'%'
</if>
<if test="hsCodeDesc != null and hsCodeDesc != ''">
AND a.hsCodeDesc like '%'+#{hsCodeDesc}+'%'
</if>
</where>
order by a.CreateDate ,a.HsCode
</select>
<select id="searchPalletList" resultType="java.util.Map">
select a.BuNo,a.id as palletId,a.pallet_type as palletType,a.pallet_no as palletNo,
a.application_area as applicationArea ,a.length, a.width, a.height
from ecss_pallet a
<where> a.BuNo = #{buNo}
<if test="palletType != null and palletType != ''">
AND a.pallet_type like '%'+#{palletType}+'%'
</if>
</where>
order by a.CreateDate
</select>
<select id="searchPackageList" resultType="java.util.Map">
select a.BuNo,a.id as packageId,a.package_type as packageType,a.package_no as packageNo,
a.length, a.width, a.height
from ecss_package a
<where> a.BuNo = #{buNo}
<if test="packageType != null and packageType != ''">
AND a.package_type like '%'+#{packageType}+'%'
</if>
</where>
order by a.CreateDate
</select>
<select id="getDeclarationElements" resultType="java.util.Map">
select part_no as partNo,bu_no as buNo
from ecss_CoDelNotifyDetail
where site=#{site} and delNo=#{delNo} and qty>0
GROUP BY part_no,bu_no
</select>
<select id="getHsCodeByPartNo" resultType="java.util.Map">
select p.hsCode, p.hsCodeDesc,p.part_no ,h.codeNo,h.BuNo,p.sku,h.hsCodeDescEn
from Part p
left join ecss_hsCode h on p.hsCodeDesc=h.hsCodeDesc and p.site=h.site
where p.site=#{site,jdbcType=VARCHAR} and p.part_no in
<foreach item="item" index="index" collection="partNos" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<select id="getDeclarationHeader" resultType="EcssDeclarationHeaderData">
select * from ecss_declaration_header where site=#{site} and declaration_no=#{declarationNo}
</select>
<select id="getDeclarationHeaderByDelNo" resultType="EcssDeclarationHeaderData">
select * from ecss_declaration_header where site=#{site} and delNo=#{delNo}
</select>
<select id="exportDeclarationDetail" resultType="java.util.Map">
select detail.site,detail.declaration_no,detail.item_no,
CONVERT(DECIMAL(20, 0), detail.qty) as qty,isnull(h.unit,'') as qty_unit,'kg' as weight_unit,
CONVERT(DECIMAL(20, 2),detail.net_weight) as net_weight,CONVERT(DECIMAL(20, 6),detail.unit_price) as unit_price,
CONVERT(DECIMAL(20, 2),detail.total_price) as total_price,detail.currency,detail.made_area,detail.destination,
detail.source_area,detail.levy,detail.hs_code,detail.hs_code_desc,h.hsCodeDescEn
from ecss_declaration_detail detail
left join ecss_hsCode h on detail.hs_code=h.HsCode and detail.site=h.Site and detail.hs_code_desc=h.hsCodeDesc
where detail.site=#{site} and declaration_no=#{declarationNo}
</select>
<select id="getEcssCoDelNotifyHeader" resultType="EcssCoDelNotifyHeaderData">
select * from ecss_CoDelNotifyHeader where site=#{site} and delNo=#{delNo}
</select>
<select id="exportEcssCoDelNotifyDetail" resultType="java.util.Map">
select a.customerPO,a.part_no,a.part_description,a.currency,
CONVERT(DECIMAL(20, 0), a.qty) as qty,CONVERT(DECIMAL(20, 6), a.tp) as unitPrice,b.hsCode,
a.upc,a.so,a.ttl_amount,a.pn,h.hsCodeDesc,h.hsCodeDescEn
from ecss_CoDelNotifydetail a
left join part b on a.site=b.site and a.part_no=b.part_no
left join ecss_hsCode h on b.hsCode=h.HsCode and a.site=h.site and b.hsCodeDesc=h.hsCodeDesc
where a.site = #{site} AND a.delNo = #{delNo} and a.qty>0
order by a.item_no
</select>
<select id="exportCoDelPalletDetail" resultType="java.util.Map">
select b.part_no,CONVERT(DECIMAL(20, 0),sum(b.qty)) as total_qty,
CONVERT(DECIMAL(20, 0),sum(DISTINCT b.box_qty)) as box_qty,
CONVERT(DECIMAL(20, 0),sum(b.rolls)) as rolls,
CONVERT(DECIMAL(20, 2),sum(a.net_weight)) as net_weight,
CONVERT(DECIMAL(20, 2),sum(a.gross_weight)) as gross_weight,
CONVERT(DECIMAL(20, 0),sum(b.rolls*b.qty)) as qty_per_carton
from ecss_CoDelBoxList a left join ecss_CoDelPalletDetail b
on a.site=b.site and a.bu_no=b.bu_no and a.delNo=b.delNo and a.item_no=b.seq_no
where a.site=#{site} and a.bu_no=#{buNo} and a.delNo=#{delNo} and b.site is not null GROUP BY b.part_no
</select>
<select id="exportPalletHeaderData" resultType="java.util.Map">
select b.part_no,a.pallet_remark,b.item_no
from ecss_CoDelPalletHeader a
left join ecss_CoDelPalletDetail b on a.site=b.site and a.bu_no=b.bu_no and a.delNo=b.delNo and a.seq_no=b.seq_no
where a.site=#{site} and a.bu_no=#{buNo} and a.delNo=#{delNo} and b.site is not null
</select>
<update id="updateEcssDeclarationHeader" >
update ecss_declaration_header set
upc=#{upc},so=#{so},origin=#{origin},pallet_weight=#{palletWeight},material=#{material},
hs_code=#{hsCode},packaging=#{packaging},kgs=#{kgs},shipping_mark=#{shippingMark},boxChange=#{boxChange},
hsCodeDesc=#{hsCodeDesc},contractFlag=#{contractFlag},hsCodeDescType=#{hsCodeDescType},goodsLabel=#{goodsLabel}
where site=#{site} and declaration_no=#{declarationNo}
</update>
<update id="updateEcssCoDelNotifyDetail" >
update ecss_CoDelNotifydetail set lossratio=#{lossratio},ehundred=#{ehundred}
where site=#{site} and delNo=#{delNo} and part_no=#{partNo}
</update>
<update id="updateEcssCoDelNotifyDetailNocartons" >
update ecss_CoDelNotifydetail set nocartons=#{nocartons}
where site=#{site} and delNo=#{delNo} and part_no=#{partNo}
</update>
<select id="getNotifyPartDetail" resultType="java.util.Map">
select a.part_no as partNo,b.hsCode,a.site,a.delNo,a.lossratio,a.ehundred,b.part_desc,a.pn
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
group by a.part_no,b.hsCode,a.site,a.delNo,a.lossratio,a.ehundred,b.part_desc,a.pn
</select>
<select id="getNotifyPartDetail2" resultType="EcssCoDelNotifyDetailData">
select a.part_no as partNo,b.hsCode,a.site,a.delNo,a.lossratio,a.ehundred,b.part_desc,a.pn
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
group by a.part_no,b.hsCode,a.site,a.delNo,a.lossratio,a.ehundred,b.part_desc,a.pn
</select>
<select id="getNotifyDetailGroup" resultType="java.util.Map">
select b.hsCodeDesc,CONVERT(DECIMAL(20, 2),sum(a.qty)) as total_qty,
CONVERT(DECIMAL(20, 2),sum(a.ttl_amount)) as ttl_amount
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
group by b.hsCodeDesc
</select>
<select id="getPropertiesListByTypeAndCodeNo" resultType="com.xujie.sys.modules.part.entity.PartSubPropertiesValueData">
SELECT a.part_no , a.Site, a.code_no, a.sub_code_seq_no, a.sub_code_desc
,a.bu_no,a.item_no, a.properties_item_no, a.text_value, a.num_value, a.record_type
, b.item_desc ItemDesc, b.value_type, b.value_type_db, b.value_choose_flag
FROM part_sub_properties_value a
left join plm_properties_item b
on a.properties_item_no = b.Item_No and a.site = b.site and a.record_type = b.Item_Type and a.bu_no=b.bu_no
<where>
AND a.site = #{site}
and a.record_type = #{recordType}
and a.bu_no=#{buNo}
and a.code_no = #{codeNo}
and a.part_no = #{pn}
</where>
order by a.item_no
</select>
<select id="getEcssContacts" resultType="java.util.Map">
select * from ecss_contacts where bu_no=#{buNo}
</select>
<select id="getCustomerList" resultType="java.util.Map">
select * from view_custdev_mes_cmc_customer where buse='是'
</select>
<select id="getCustomerInfo" resultType="java.util.Map">
select DISTINCT vcus.ccusname,vcusp.ccontactname,vcusp.cnative
from view_custdev_mes_cmc_customer vcus
LEFT JOIN view_custdev_mes_cmc_customer_person vcusp on vcus.ccuscode=vcusp.ccuscode
<where>
<if test="ccusname != null and ccusname != ''">
and vcus.ccusname=#{ccusname}
</if>
<if test="ccuscode != null and ccuscode != ''">
and vcus.ccuscode=#{ccuscode}
</if>
</where>
</select>
<select id="getCustomerAdd" resultType="java.util.Map">
select DISTINCT vcus.ccusname,vcusa.cDeliverAdd
from view_custdev_mes_cmc_customer vcus
left join view_custdev_mes_cmc_customer_addr vcusa on vcus.ccuscode=vcusa.ccuscode
where vcus.ccusname=#{ccusname}
</select>
<select id="getPackageNoByPartNo" resultType="java.util.Map">
select p.part_no as partNo,p.packageNo
from Part p
where p.site=#{site,jdbcType=VARCHAR} and p.part_no in
<foreach item="item" index="index" collection="partNos" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<select id="getPackageList" resultType="EcssPackageData">
select * from ecss_package where site=#{site} and buNo=#{buNo}
and package_no in
<foreach item="item" index="index" collection="packageNos" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<select id="searchEcssTemplateData" resultType="EcssTemplate">
select a.*,dbo.get_bu_desc(a.site,a.BuNo) as BuDesc
from ecss_template a
left join accessBu D on A.site=D.site and A.BuNo=d.bu_no and D.username=#{query.username}
<where>
and D.site is not null
<if test="query.buNo != null and query.buNo != ''">
AND a.buNo = #{query.buNo}
</if>
<if test="query.name != null and query.name != ''">
AND a.name like '%'+#{query.name}+'%'
</if>
<if test="query.type != null and query.type != ''">
AND a.type = #{query.type}
</if>
</where>
order by a.CreateDate
</select>
<insert id="insertEcssTemplateData" >
insert into ecss_template (customName,site,buNo,name,type,upc,so,origin,palletWeight,material,hsCode,packaging,itemNo,
kgs,shippingMark,boxChange,hsCodeDesc,contractFlag,hsCodeDescType,goodsLabel,hsCodeFlag,shippingMode,CreateBy,CreateDate,
salesMethod,currency,madeArea,sendPort,shipper,voyage,deliveryGoodsDate,shippingDate,fscWeight, remark)
values(#{customName},#{site},#{buNo},#{name},#{type},#{upc},#{so},#{origin},#{palletWeight},#{material},#{hsCode},#{packaging},
#{itemNo},#{kgs},#{shippingMark},#{boxChange},
#{hsCodeDesc},#{contractFlag},#{hsCodeDescType},#{goodsLabel},#{hsCodeFlag},#{shippingMode},#{createBy},GetDate(),
#{salesMethod},#{currency},#{madeArea},#{sendPort},#{shipper},#{voyage},#{deliveryGoodsDate},#{shippingDate},#{fscWeight},#{remark})
</insert>
<update id="updateEcssTemplateData">
update ecss_template set buNo=#{buNo},name=#{name},type=#{type},upc=#{upc},so=#{so},origin=#{origin},boxChange=#{boxChange},
palletWeight=#{palletWeight},material=#{material},hsCode=#{hsCode},itemNo=#{itemNo},
packaging=#{packaging},kgs=#{kgs},shippingMark=#{shippingMark},hsCodeDesc=#{hsCodeDesc},
contractFlag=#{contractFlag},hsCodeDescType=#{hsCodeDescType},goodsLabel=#{goodsLabel},hsCodeFlag=#{hsCodeFlag},
shippingMode=#{shippingMode},UpdateDate=GetDate(),UpdateBy=#{updateBy},customName=#{customName},salesMethod= #{salesMethod},
currency= #{currency},madeArea= #{madeArea},sendPort= #{sendPort},shipper= #{shipper},remark= #{remark},
voyage= #{voyage},deliveryGoodsDate= #{deliveryGoodsDate},shippingDate= #{shippingDate},fscWeight=#{fscWeight}
where buNo=#{buNo} and name=#{nameNative}
</update>
<select id="deleteEcssTemplate" >
delete from ecss_template where buNo=#{buNo} and name=#{name}
</select>
<select id="searchWalMartOrderData" resultType="EcssWalMartOrder">
select a.*
from ecss_walMartOrder a
<where>
<if test="query.so != null and query.so != ''">
AND a.so like '%'+#{query.so}+'%'
</if>
<if test="query.sku != null and query.sku != ''">
AND a.sku like '%'+#{query.sku}+'%'
</if>
</where>
order by a.CreateDate
</select>
<insert id="insertWalMartOrderData" >
insert into ecss_walMartOrder (site,buNo,sku,so,qty,rolls,grossWeight,verificationSheet,CreateBy,CreateDate)
values(#{site},#{buNo},#{sku},#{so},#{qty},#{rolls},#{grossWeight},#{verificationSheet},#{createBy},GetDate())
</insert>
<insert id="batchSaveWalMartOrder">
insert into ecss_walMartOrder (site,buNo,sku,so,qty,rolls,grossWeight,verificationSheet,CreateBy,CreateDate)
values
<foreach collection="list" separator="," item="item">
(#{item.site},#{item.buNo},#{item.sku},#{item.so},#{item.qty},
#{item.rolls},#{item.grossWeight},#{item.verificationSheet},#{item.createBy},GetDate())
</foreach>
</insert>
<update id="updateWalMartOrderData">
update ecss_walMartOrder set buNo=#{buNo},sku=#{sku},so=#{so},qty=#{qty},rolls=#{rolls},grossWeight=#{grossWeight},
verificationSheet=#{verificationSheet},UpdateDate=GetDate(),UpdateBy=#{updateBy}
where buNo=#{buNo} and sku=#{sku} and so=#{so} and qty=#{qty}
</update>
<select id="deleteWalMartOrder" >
delete from ecss_walMartOrder where buNo=#{buNo} and sku=#{sku} and so=#{so} and qty=#{qty}
</select>
<!-- 查出所有类型的物料 -->
<select id="queryPartListAll" parameterType="PartInformationEntity" resultType="PartInformationEntity">
SELECT site, sourceBu as buNo, part_no, part_desc, sku
FROM part
<where> sourceBu=#{query.buNo} and
site = #{query.site} and active = 'Y'
<if test = "query.partNo != null and query.partNo != ''">
AND part_no like '%' + #{query.partNo} + '%'
</if>
<if test = "query.sku != null and query.sku != ''">
AND sku like '%' + #{query.sku} + '%'
</if>
<if test = "query.partDesc != null and query.partDesc != ''">
AND part_desc like '%' + #{query.partDesc} + '%'
</if>
</where>
</select>
<select id="queryByUserName" resultType="com.xujie.sys.modules.sys.entity.SysUserEntity">
select * from sys_user where username = #{username}
</select>
<select id="queryUsersByRoleName" resultType="com.xujie.sys.modules.sys.entity.SysUserEntity">
select u.* from sys_user u
LEFT JOIN sys_user_role ur on ur.user_id = u.user_id
LEFT JOIN sys_role r on r.role_id = ur.role_id
where r.role_name = #{roleName} and u.site = #{site}
</select>
<select id="searchCoDelPalletDataNew" resultType="EcssCoDelPalletData">
select b.site,b.bu_no,b.delNo,b.seq_no,b.item_no,b.po_no,b.part_no,b.qty,b.box_qty,b.rolls,b.pn,
c.gross_weight,c.net_weight,c.box_qty as pallet_qty
from ecss_CoDelPalletDetail b
left join ecss_CoDelBoxList c on b.site=c.site and b.bu_no=c.bu_no and b.delNo=c.delNo and b.seq_no=c.item_no
where b.site=#{site} and b.bu_no=#{buNo} and b.delNo=#{delNo}
<if test="seqNo != null and seqNo != ''">
and b.seq_no=#{seqNo}
</if>
</select>
<update id="updateExportFlag">
update ecss_CoDelNotifyHeader
set export_flag = #{exportFlag},
updateBy = #{updateBy},
updateDate = GetDate()
where site = #{site}
and bu_no = #{buNo}
and delNo = #{delNo}
</update>
<select id="selectBoxList" resultType="java.util.Map">
select *,CONVERT(DECIMAL(20, 3),gross_weight) as grossWeight,CONVERT(DECIMAL(20, 3),net_weight) as netWeight from ecss_CoDelBoxList
where site = #{site} and bu_no = #{buNo} and delNo = #{delNo}
</select>
<select id="selectPalletDetailList" resultType="java.util.Map">
select a.*,b.part_description,b.hsCode,b.upc,b.so
from ecss_CoDelPalletDetail a left join (
select a.site,a.bu_no,a.delNo,a.part_no,a.part_description,b.hsCode,a.upc,a.so
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.bu_no=#{buNo} and a.delNo=#{delNo}
GROUP BY a.site,a.bu_no,a.delNo,a.part_no,a.part_description,b.hsCode,a.upc,a.so
) b on a.site=b.site and a.bu_no=b.bu_no and a.delNo=b.delNo and a.part_no=b.part_no
where a.site =#{site} and a.bu_no=#{buNo} and a.delNo=#{delNo}
<if test="seqNo != null and seqNo != ''">
and a.seq_no=#{seqNo}
</if>
</select>
</mapper>