O
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.

1310 lines
65 KiB

1 year ago
11 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
9 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
10 months ago
1 year ago
1 year ago
1 year ago
1 year ago
10 months ago
8 months ago
9 months ago
1 year ago
10 months ago
1 year ago
1 year ago
1 year ago
8 months ago
1 year ago
10 months ago
1 year ago
1 year ago
1 year ago
8 months ago
1 year ago
8 months ago
1 year ago
1 year ago
1 year ago
1 year ago
9 months ago
1 year ago
1 year ago
1 year ago
8 months ago
1 year ago
1 year ago
9 months ago
8 months ago
8 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
9 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
11 months ago
1 year ago
11 months ago
1 year ago
10 months ago
1 year ago
1 year ago
11 months ago
1 year ago
10 months ago
1 year ago
1 year ago
10 months ago
1 year ago
11 months ago
1 year ago
1 year ago
9 months ago
1 year ago
1 year ago
1 year ago
11 months ago
1 year ago
1 year ago
1 year ago
1 year ago
11 months ago
1 year ago
1 year ago
8 months ago
8 months ago
8 months ago
1 year ago
10 months ago
10 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
9 months ago
1 year ago
1 year ago
1 year ago
1 year ago
9 months ago
9 months ago
9 months ago
9 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
9 months ago
9 months ago
10 months ago
10 months ago
1 year ago
1 year ago
1 year ago
1 year ago
10 months ago
8 months ago
10 months ago
10 months ago
10 months ago
10 months ago
9 months ago
10 months ago
1 year ago
1 year ago
9 months ago
1 year ago
11 months ago
10 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
10 months ago
11 months ago
10 months ago
11 months ago
10 months ago
11 months ago
11 months ago
9 months ago
11 months ago
9 months ago
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.xujie.sys.modules.ecss.mapper.CoDelMapper">
  4. <select id="searchEcssCoDelNotifyHeader" resultType="EcssCoDelNotifyHeaderData">
  5. 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,
  6. 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,
  7. a.modifyFlag,a.overseasShipper,a.overseasAddress,a.cnative,a.localShipAddress,a.walMartOrderFlag
  8. from ecss_CoDelNotifyHeader a
  9. left join accessBu D on A.site=D.site and A.bu_no=d.bu_no and D.username=#{query.username}
  10. <where>
  11. and D.site is not null
  12. <if test="query.buNo != null and query.buNo != ''">
  13. AND a.bu_no = #{query.buNo}
  14. </if>
  15. <if test="query.delNo != null and query.delNo != ''">
  16. AND a.delNo like #{query.delNo}
  17. </if>
  18. <if test="query.cmcInvoice != null and query.cmcInvoice != ''">
  19. AND a.cmc_invoice like #{query.cmcInvoice}
  20. </if>
  21. <if test="query.notifyStatus != null and query.notifyStatus != ''">
  22. AND a.notify_status = #{query.notifyStatus}
  23. </if>
  24. <if test = "query.startDate!= null">
  25. AND a.ready_date>= #{query.startDate}
  26. </if>
  27. <if test = "query.endDate!= null">
  28. AND #{query.endDate} >=a.ready_date
  29. </if>
  30. <if test="query.modifyData == 'true'">
  31. and a.modifyFlag=1
  32. </if>
  33. </where>
  34. order by a.createDate desc ,a.delNo desc
  35. </select>
  36. <select id="searchEcssCoDelNotifyHeaderForCK" resultType="EcssCoDelNotifyHeaderData">
  37. 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,
  38. 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,
  39. a.modifyFlag,ISNULL(a.export_flag,'N') as exportFlag
  40. from ecss_CoDelNotifyHeader a
  41. left join accessBu D on A.site=D.site and A.bu_no=d.bu_no and D.username=#{query.username}
  42. <where>
  43. and D.site is not null
  44. <if test="query.buNo != null and query.buNo != ''">
  45. AND a.bu_no = #{query.buNo}
  46. </if>
  47. <if test="query.delNo != null and query.delNo != ''">
  48. AND a.delNo like #{query.delNo}
  49. </if>
  50. <if test="query.cmcInvoice != null and query.cmcInvoice != ''">
  51. AND a.cmc_invoice like #{query.cmcInvoice}
  52. </if>
  53. <if test="query.notifyStatus != null and query.notifyStatus != ''">
  54. AND a.notify_status = #{query.notifyStatus}
  55. </if>
  56. AND a.notify_status != '已计划'
  57. <if test = "query.startDate!= null">
  58. AND a.ready_date>= #{query.startDate}
  59. </if>
  60. <if test = "query.endDate!= null">
  61. AND #{query.endDate} >=a.ready_date
  62. </if>
  63. <if test="query.modifyData == 'true'">
  64. and a.modifyFlag=1
  65. </if>
  66. <if test="query.exportFlag != null and query.exportFlag != ''">
  67. and ISNULL(a.export_flag,'N') = #{query.exportFlag}
  68. </if>
  69. </where>
  70. order by a.createDate desc ,a.delNo desc
  71. </select>
  72. <select id="searchEcssCoDelNotifyHeaderForDanZheng" resultType="EcssCoDelNotifyHeaderData">
  73. 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,
  74. 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
  75. from ecss_CoDelNotifyHeader a
  76. left join accessBu D on A.site=D.site and A.bu_no=d.bu_no and D.username=#{query.username}
  77. <where>
  78. and D.site is not null
  79. <if test="query.buNo != null and query.buNo != ''">
  80. AND a.bu_no = #{query.buNo}
  81. </if>
  82. <if test="query.delNo != null and query.delNo != ''">
  83. AND a.delNo like #{query.delNo}
  84. </if>
  85. <if test="query.cmcInvoice != null and query.cmcInvoice != ''">
  86. AND a.cmc_invoice like #{query.cmcInvoice}
  87. </if>
  88. <if test="query.notifyStatus != null and query.notifyStatus != ''">
  89. AND a.notify_status = #{query.notifyStatus}
  90. </if>
  91. AND a.notify_status = '仓库已确认'
  92. <if test = "query.startDate!= null">
  93. AND a.ready_date>= #{query.startDate}
  94. </if>
  95. <if test = "query.endDate!= null">
  96. AND #{query.endDate} >=a.ready_date
  97. </if>
  98. </where>
  99. order by a.createDate desc ,a.delNo desc
  100. </select>
  101. <select id="checkEcssCoDelNotifyHeaderByDelNo" resultType="EcssCoDelNotifyHeaderData">
  102. 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,
  103. 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
  104. ,a.overseasShipper,a.overseasAddress,a.cnative,a.localShipAddress,a.salesArea
  105. from ecss_CoDelNotifyHeader a
  106. where a.site = #{site}
  107. AND a.delNo = #{delNo}
  108. </select>
  109. <select id="searchEcssCoDelNotifyDetail" resultType="EcssCoDelNotifyDetailData">
  110. 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,
  111. 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,
  112. 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,
  113. c.num_value as boxrolls,d.num_value as rollqty,w.num_value as boxweight,#{cmcInvoice} as cmcInvoice,a.modifyFlag,a.modifyQtyFlag,
  114. b.hsCodeDesc,a.vat,a.roll,a.carton,b.packageNo
  115. from ecss_CoDelNotifydetail a
  116. left join part b on a.site=b.site and a.part_no=b.part_no
  117. 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
  118. and c.record_type='ECSSPART' and c.code_no='BG001' and c.properties_item_no='BOXROLLS'
  119. 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
  120. and d.record_type='ECSSPART' and d.code_no='BG001' and d.properties_item_no='ROLLQTY'
  121. left join part_sub_properties_value w on a.part_no=w.part_no and w.site=a.site and w.bu_no=a.bu_no
  122. and w.record_type='ECSSPART' and w.code_no='BG001' and w.properties_item_no='BOXWEIGHT'
  123. <where>
  124. And a.site = #{site}
  125. AND a.delNo = #{delNo}
  126. </where>
  127. order by a.item_no
  128. </select>
  129. <select id="getEcssCoDelNotifyDetail" resultType="EcssCoDelNotifyDetailData">
  130. 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,
  131. a.part_no,a.part_description,a.qty,a.lt,a.cmc_comment,a.saleType,a.awb_bl,a.shipping_number,a.forwarder_info,
  132. 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,
  133. a.modifyFlag,a.modifyQtyFlag
  134. from ecss_CoDelNotifydetail a
  135. <where>
  136. And a.site = #{site}
  137. AND a.delNo = #{delNo}
  138. AND a.item_no = #{itemNo} and a.qty>0
  139. </where>
  140. </select>
  141. <select id="getSiteByBu" resultType="String">
  142. select top 1 site from BU where bu_no=#{buNo}
  143. </select>
  144. <select id="checkIfHasHeader" resultType="EcssCoDelNotifyHeaderData">
  145. select top 1 * from ecss_CoDelNotifyHeader where cmc_invoice=#{inVoice}
  146. </select>
  147. <update id="updateTransNo" >
  148. EXEC UpdateTransNo #{site}, #{transType}
  149. </update>
  150. <select id="getTransNo" resultType="String">
  151. SELECT
  152. dbo.Get_TransNo(#{site},#{transType}) as transNo
  153. </select>
  154. <insert id="saveEcssCoDelNotifyHeader" >
  155. insert into ecss_CoDelNotifyHeader(site,bu_no,delNo,ready_date,customer_name,Destination,shipping_mode,erp_flag,notify_status,
  156. remark,createDate,createBy,cmc_invoice,overseasShipper,overseasAddress,cnative,localShipAddress,salesArea)
  157. values(#{site},#{buNo},#{delNo},#{readyDate},#{customerName,jdbcType=NVARCHAR},#{destination,jdbcType=NVARCHAR},#{shippingMode},'N',#{notifyStatus},#{remark,jdbcType=NVARCHAR},GetDate(),
  158. #{createBy},#{cmcInvoice},#{overseasShipper,jdbcType=NVARCHAR},#{overseasAddress,jdbcType=NVARCHAR},#{cnative,jdbcType=NVARCHAR},#{localShipAddress,jdbcType=NVARCHAR}, #{salesArea,jdbcType=NVARCHAR})
  159. </insert>
  160. <insert id="batchSaveEcssCoDelNotifyDetail">
  161. insert into ecss_CoDelNotifyDetail (site,bu_no,delNo,item_no,salesOrder,salesOrder_item_no,customerPO,line,version,
  162. status,family,part_no,part_description,qty,lt,cmc_comment,saleType,
  163. awb_bl,shipping_number,forwarder_info,currency,tp,ttl_amount,sum_price,
  164. so,upc,remark,pn,surplus_qty,vat,roll,carton,saleslt,manufacturer_name,modifyFlag,modifyQtyFlag)
  165. values
  166. <foreach collection="list" separator="," item="item">
  167. (#{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},
  168. #{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},
  169. #{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},
  170. #{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})
  171. </foreach>
  172. </insert>
  173. <select id="checkPart" resultType="PartData">
  174. select site,part_no from Part where site=#{site,jdbcType=VARCHAR} and part_no=#{partNo}
  175. </select>
  176. <select id="getPartNo" resultType="PartData">
  177. select top 1 site,part_no from Part where site=#{site,jdbcType=VARCHAR} and sku=#{partNo} and sourceBu=#{buNo} and
  178. site in (select site from eam_access_site where username = #{userName})
  179. and (site + '-' + sourceBu) in (select * from dbo.query_bu(#{userName}))
  180. </select>
  181. <select id="getPartInfo" resultType="PartData">
  182. select * from Part where site=#{site,jdbcType=VARCHAR} and part_no=#{partNo}
  183. </select>
  184. <update id="updateEcssDelHeader" >
  185. update ecss_CoDelNotifyHeader set ready_date=#{readyDate,jdbcType=TIMESTAMP} ,customer_name=#{customerName,jdbcType=NVARCHAR},
  186. Destination=#{destination,jdbcType=NVARCHAR},shipping_mode=#{shippingMode},modifyFlag=#{modifyFlag},export_flag='N',
  187. remark=#{remark,jdbcType=NVARCHAR} ,cmc_invoice=#{cmcInvoice},overseasShipper=#{overseasShipper,jdbcType=NVARCHAR} ,overseasAddress=#{overseasAddress,jdbcType=NVARCHAR}
  188. where site=#{site} and delNo=#{delNo}
  189. </update>
  190. <delete id="deleteEcssDelHeader">
  191. delete from ecss_CoDelNotifyHeader where site=#{site} and delNo=#{delNo}
  192. </delete>
  193. <update id="updateEcssDelHeaderForBaoGuan" >
  194. update ecss_CoDelNotifyHeader set declaration_no=#{declarationNo} ,notify_status=#{status} where site=#{site} and delNo=#{delNo}
  195. </update>
  196. <update id="updateEcssDelHeaderForModify" >
  197. update ecss_CoDelNotifyHeader set modifyFlag=#{modifyFlag} where site=#{site} and delNo=#{delNo}
  198. </update>
  199. <update id="updateEcssDelDetailForModify" >
  200. update ecss_CoDelNotifyDetail set modifyFlag=#{modifyFlag},modifyQtyFlag=#{modifyFlag},surplus_qty=0 where site=#{site} and delNo=#{delNo}
  201. </update>
  202. <update id="changeEcssDelStatus">
  203. update ecss_CoDelNotifyHeader set notify_status=#{notifyStatus},walMartOrderFlag=#{walMartOrderFlag} where site=#{site} and delNo=#{delNo}
  204. </update>
  205. <update id="updateEcssDelDetailStatus">
  206. update ecss_CoDelNotifyDetail
  207. set status=#{notifyStatus}
  208. where site=#{site} and delNo=#{delNo}
  209. </update>
  210. <update id="recoverEcssDelDetailStatus">
  211. update ecss_CoDelNotifyDetail
  212. set status='正常'
  213. where site=#{site} and delNo=#{delNo}
  214. </update>
  215. <select id="getEcssDelDetailItemNo" resultType="int">
  216. select isnull(max(item_no),0)+1 as itemNo from ecss_CoDelNotifyDetail
  217. where site =#{site} and bu_no=#{buNo} and delNo=#{delNo}
  218. </select>
  219. <insert id="insertEcssDelDetail" >
  220. insert into ecss_CoDelNotifyDetail(site,bu_no,delNo,item_no,salesOrder,salesOrder_item_no,customerPO,line,version,
  221. status,family,part_no,part_description,qty,lt,cmc_comment,saleType,
  222. awb_bl,shipping_number,forwarder_info,currency,tp,ttl_amount,sum_price,
  223. so,upc,remark,pn,modifyFlag,modifyQtyFlag,surplus_qty,vat,roll,carton)
  224. values(#{site},#{buNo},#{delNo},#{itemNo,jdbcType=INTEGER},#{salesOrder},#{salesOrderItemNo},#{customerPO},#{line},#{version},
  225. #{status},#{family},#{partNo},#{partDescription},#{qty,jdbcType=DECIMAL},#{lt,jdbcType=DECIMAL},#{cmcComment},#{saleType},
  226. #{awbBl},#{shippingNumber},#{forwarderInfo},#{currency},#{tp,jdbcType=DECIMAL},#{ttlAmount,jdbcType=DECIMAL},#{sumPrice,jdbcType=DECIMAL},
  227. #{so},#{upc},#{remark},#{pn},#{modifyFlag},#{modifyQtyFlag},#{qty},#{vat},#{roll},#{carton})
  228. </insert>
  229. <update id="updateEcssDelDetail">
  230. update ecss_CoDelNotifyDetail
  231. set salesOrder=#{salesOrder},customerPO=#{customerPO},line=#{line},version=#{version},
  232. status=#{status},family=#{family},part_no=#{partNo},part_description=#{partDescription},qty=#{qty,jdbcType=DECIMAL},
  233. lt=#{lt,jdbcType=DECIMAL},cmc_comment=#{cmcComment},saleType=#{saleType},pn=#{pn},
  234. awb_bl=#{awbBl},shipping_number=#{shippingNumber},forwarder_info=#{forwarderInfo},currency=#{currency},
  235. tp=#{tp,jdbcType=DECIMAL},ttl_amount=#{ttlAmount,jdbcType=DECIMAL},sum_price=#{sumPrice,jdbcType=DECIMAL},
  236. so=#{so},upc=#{upc},remark=#{remark},modifyFlag=#{modifyFlag},modifyQtyFlag=#{modifyQtyFlag},surplus_qty=#{qty,jdbcType=DECIMAL},vat=#{vat},roll=#{roll},carton=#{carton}
  237. where
  238. site=#{site} and delNo=#{delNo} and item_no=#{itemNo}
  239. </update>
  240. <delete id="deleteEcssDelDetail">
  241. delete from ecss_CoDelNotifyDetail where site=#{site} and delNo=#{delNo} and item_no=#{itemNo}
  242. </delete>
  243. <delete id="deleteAllEcssDelDetail">
  244. delete from ecss_CoDelNotifyDetail where site=#{site} and delNo=#{delNo}
  245. </delete>
  246. <update id="confirmEcssDel">
  247. update ecss_CoDelNotifyHeader set notify_status=#{notifyStatus} ,notifyDate=#{notifyDate,jdbcType=TIMESTAMP} where site=#{site} and delNo=#{delNo}
  248. </update>
  249. <update id="updateEcssDel">
  250. update ecss_CoDelNotifyHeader set ready_date=#{readyDate,jdbcType=TIMESTAMP},notifyDate=#{notifyDate,jdbcType=TIMESTAMP},
  251. modifyFlag=1,export_flag='N',updateBy=#{updateBy},updateDate=GetDate()
  252. where site=#{site} and delNo=#{delNo}
  253. </update>
  254. <select id="searchHsCodeData" resultType="EcssHsCodeData">
  255. select a.Site,a.BuNo,a.HsCode,a.Remark,a.CreateBy,a.CreateDate,a.UpdateBy,a.UpdateDate,a.codeNo
  256. ,dbo.get_bu_desc(a.site,a.BuNo) as BuDesc,a.hsCodeDesc,a.hsCodeDescEn,a.unit
  257. from ecss_hsCode a
  258. left join accessBu D on A.site=D.site and A.BuNo=d.bu_no and D.username=#{query.username}
  259. <where>
  260. and D.site is not null
  261. <if test="query.buNo != null and query.buNo != ''">
  262. AND a.BuNo = #{query.buNo}
  263. </if>
  264. <if test="query.hsCode != null and query.hsCode != ''">
  265. AND a.HsCode like #{query.hsCode}
  266. </if>
  267. </where>
  268. order by a.CreateDate ,a.HsCode
  269. </select>
  270. <select id="checkHsCodeDescData" resultType="EcssHsCodeData">
  271. select a.Site,a.BuNo,a.HsCode,a.hsCodeDesc
  272. from ecss_hsCode a where a.site=#{site} and a.buNo=#{buNo} and a.HsCodeDesc=#{hsCodeDesc}
  273. </select>
  274. <select id="checkPropertiesModel" resultType="com.xujie.sys.modules.attrbute.entity.PropertyModelHeader">
  275. select site,bu_no,function_type ,code_no from plm_properties_model_header
  276. where site=#{site} and bu_no=#{buNo} and function_type=#{functionType} and code_no=#{codeNo}
  277. </select>
  278. <insert id="insertHsCodeData" >
  279. insert into ecss_hsCode (Site,BuNo,HsCode,Remark,CreateBy,CreateDate,codeNo,hsCodeDesc,hsCodeDescEn,unit)
  280. values(#{site},#{buNo},#{hsCode},#{remark},#{createBy},GetDate(),#{codeNo},#{hsCodeDesc},#{hsCodeDescEn},#{unit})
  281. </insert>
  282. <update id="updateHsCodeData">
  283. update ecss_hsCode set Remark=#{remark} ,codeNo=#{codeNo},HsCode=#{hsCode},unit=#{unit} ,UpdateDate=GetDate(),UpdateBy=#{updateBy},hsCodeDescEn=#{hsCodeDescEn}
  284. where site=#{site} and buNo=#{buNo} and hsCodeDesc=#{hsCodeDesc}
  285. </update>
  286. <select id="deleteHsCode" >
  287. delete from ecss_hsCode where site=#{site} and buNo=#{buNo} and hsCodeDesc=#{hsCodeDesc}
  288. </select>
  289. <select id="searchPropertiesItemList" resultType="com.xujie.sys.modules.attrbute.entity.PropertyItem">
  290. select
  291. id,site,bu_no,item_no,item_type,item_desc,default_value,value_type,value_type_db,value_choose_flag,min_value,max_value,
  292. create_by,create_date,update_by,update_date
  293. from dbo.plm_properties_item
  294. <where>
  295. and site = #{site} and bu_no=#{buNo}
  296. <if test="itemNo != null and itemNo != ''">
  297. and item_no like #{itemNo}
  298. </if>
  299. <if test="itemDesc != null and itemDesc != ''">
  300. and item_desc like #{itemDesc}
  301. </if>
  302. <if test="itemType != null and itemType != ''">
  303. and item_type = #{itemType}
  304. </if>
  305. order by item_type ,item_no
  306. </where>
  307. </select>
  308. <select id="getPropertiesListByPartAndCodeNo" resultType="com.xujie.sys.modules.part.entity.PartSubPropertiesValueData">
  309. SELECT a.part_no
  310. , a.Site
  311. , a.code_no
  312. , a.sub_code_seq_no
  313. , a.sub_code_desc
  314. ,a.bu_no
  315. ,a.item_no
  316. , a.properties_item_no
  317. , a.text_value
  318. , a.num_value
  319. , a.record_type
  320. , b.item_desc ItemDesc
  321. , b.value_type
  322. , b.value_type_db
  323. , b.value_choose_flag
  324. FROM part_sub_properties_value a
  325. left join plm_properties_item b
  326. 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
  327. <where>
  328. AND a.site = #{site}
  329. and a.record_type = #{recordType}
  330. and a.bu_no=#{buNo}
  331. and a.code_no = #{codeNo}
  332. AND a.part_no = #{partNo,jdbcType=VARCHAR}
  333. </where>
  334. order by a.item_no
  335. </select>
  336. <update id="updatePropertiesList">
  337. update part_sub_properties_value
  338. set text_value=#{textValue},
  339. num_value=#{numValue,jdbcType=DOUBLE}
  340. where Site = #{site}
  341. and code_no = #{codeNo}
  342. and part_no = #{partNo}
  343. and sub_code_seq_no = #{subCodeSeqNo}
  344. and item_no = #{itemNo}
  345. and bu_no=#{buNo}
  346. </update>
  347. <insert id="saveSubPropertiesValueForAlone">
  348. insert into part_sub_properties_value ( part_no, site, bu_no, code_no, sub_code_seq_no, sub_code_desc,
  349. item_no, properties_item_no, text_value, num_value, record_type)
  350. select
  351. #{partNo},
  352. #{site},
  353. #{buNo},
  354. #{codeNo},
  355. 1,
  356. d.code_desc,
  357. #{itemNo,jdbcType=DOUBLE},
  358. c.item_no,
  359. case when c.value_type_db = 'T' then c.default_value else null end,
  360. case when c.value_type_db = 'N' and c.default_value != '' then c.default_value else null end,
  361. #{recordType}
  362. from plm_properties_item c
  363. left join plm_properties_model_header d on c.site=d.site and d.code_no=#{codeNo}
  364. where c.Item_No = #{propertiesItemNo}
  365. and c.site = #{site}
  366. and c.bu_no=#{buNo}
  367. and c.item_Type = #{recordType}
  368. </insert>
  369. <delete id="deleteSubPropertiesValueForAlone">
  370. delete
  371. from part_sub_properties_value
  372. where site = #{site}
  373. and record_type = #{recordType}
  374. and bu_no=#{buNo}
  375. and code_no = #{codeNo}
  376. AND part_no = #{partNo,jdbcType=VARCHAR}
  377. and properties_item_no = #{propertiesItemNo}
  378. </delete>
  379. <select id="getNewSeqNoForAlone" resultType="Double">
  380. select isnull(Max(item_No) + 1, 1)
  381. from part_sub_properties_value a
  382. where a.site = #{site}
  383. and a.record_type = #{recordType}
  384. and a.bu_no=#{buNo}
  385. and a.code_no = #{codeNo}
  386. AND a.part_no = #{partNo,jdbcType=VARCHAR}
  387. </select>
  388. <select id="searchPropertiesUnChoose" resultType="com.xujie.sys.modules.ecss.entity.PropertyItemData">
  389. SELECT
  390. 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,
  391. b.min_value,b.max_value,b.create_by,b.create_date,b.update_by,b.update_date
  392. FROM plm_properties_item b
  393. where b.item_type = #{codeType}
  394. and b.site = #{site} and b.bu_no=#{buNo}
  395. <if test="list != null and list.size() != 0">
  396. and b.item_no not in (
  397. <foreach collection="list" item="item" separator=",">
  398. #{item}
  399. </foreach>
  400. )
  401. </if>
  402. </select>
  403. <insert id="saveCodelPalletHeader">
  404. 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,
  405. create_date,pallet)
  406. values(#{site},#{buNo},#{delNo},#{seqNo},#{palletNo},#{palletQty},#{length},#{width},#{height},#{volume},#{grossWeight,jdbcType=DECIMAL},#{netWeight,jdbcType=DECIMAL},#{palletRemark},#{createBy},
  407. GETDATE(),#{pallet})
  408. </insert>
  409. <insert id="saveCodelBoxList">
  410. insert into ecss_CoDelBoxList(site,bu_no,delNo,seq_no,item_no,gross_weight,net_weight,box_qty,create_by,create_date)
  411. values (#{site},#{buNo},#{delNo},#{seqNo},#{itemNo},#{grossWeight,jdbcType=DECIMAL},#{netWeight,jdbcType=DECIMAL},#{boxQty},#{createBy},GETDATE())
  412. </insert>
  413. <insert id="saveCodelPalletDetail">
  414. 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,notify_detail_item_no)
  415. values (#{site},#{buNo},#{delNo},#{seqNo},#{itemNo},#{partNo},#{qty,jdbcType=DECIMAL},#{poNo},#{boxQty},#{createBy},GETDATE(),#{rolls,jdbcType=DECIMAL},#{pn},#{notifyDetailItemNo})
  416. </insert>
  417. <select id="searchEcssCoDelPalletHeaderData" resultType="EcssCoDelPalletHeaderData">
  418. select site,bu_no,delNo,seq_no,pallet_no,pallet_qty,[length],width,height,volume,gross_weight,net_weight,pallet_remark,create_by,
  419. create_date,update_by,update_date,pallet from ecss_CoDelPalletHeader
  420. where site =#{site} and bu_no=#{buNo} and delNo=#{delNo}
  421. </select>
  422. <select id="searchEcssCoDelPalletDetailData" resultType="EcssCoDelPalletDetailData">
  423. 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,notify_detail_item_no as notifyDetailItemNo
  424. from ecss_CoDelPalletDetail
  425. where site =#{site} and bu_no=#{buNo} and delNo=#{delNo}
  426. <if test="seqNo != null and seqNo != ''">
  427. and seq_no=#{seqNo}
  428. </if>
  429. </select>
  430. <select id="getCoDelPalletHeaderSeqNo" resultType="int">
  431. select isnull(max(seq_no),0)+1 as seqNo from ecss_CoDelPalletHeader
  432. where site =#{site} and bu_no=#{buNo} and delNo=#{delNo}
  433. </select>
  434. <select id="getCoDelBoxListItemNo" resultType="int">
  435. select isnull(max(item_no),0)+1 as seqNo from ecss_CoDelBoxList
  436. where site =#{site} and bu_no=#{buNo} and delNo=#{delNo}
  437. </select>
  438. <select id="getCoDelPalletDetailItem" resultType="int">
  439. select isnull(max(item_no),0)+1 as item_no from ecss_CoDelPalletDetail
  440. where site =#{site} and bu_no=#{buNo} and delNo=#{delNo} and seq_no=#{seqNo}
  441. </select>
  442. <update id="updateCodelPalletHeader">
  443. update ecss_CoDelPalletHeader set pallet_qty=#{palletQty,jdbcType=INTEGER},[length]=#{length,jdbcType=DECIMAL},width=#{width,jdbcType=DECIMAL},height=#{height,jdbcType=DECIMAL},
  444. volume=#{volume,jdbcType=DECIMAL},gross_weight=#{grossWeight,jdbcType=DECIMAL},net_weight=#{netWeight,jdbcType=DECIMAL},pallet_remark=#{palletRemark},
  445. update_by=#{updateBy},update_date=GetDate(),pallet=#{pallet}
  446. where site =#{site} and bu_no=#{buNo} and delNo=#{delNo} and seq_no=#{seqNo}
  447. </update>
  448. <update id="updateCodelPalletHeader2">
  449. update ecss_CoDelPalletHeader set gross_weight=#{grossWeight,jdbcType=DECIMAL},net_weight=#{netWeight,jdbcType=DECIMAL},
  450. update_by=#{updateBy},update_date=GetDate()
  451. where site =#{site} and bu_no=#{buNo} and delNo=#{delNo} and seq_no=#{seqNo}
  452. </update>
  453. <update id="updateCodelPalletHeaderPalletQty">
  454. update ecss_CoDelPalletHeader set pallet_qty=#{palletQty,jdbcType=INTEGER},height=#{height,jdbcType=DECIMAL},
  455. update_by=#{updateBy},update_date=GetDate()
  456. where site =#{site} and bu_no=#{buNo} and delNo=#{delNo} and seq_no=#{seqNo}
  457. </update>
  458. <update id="updateCodelPalletDetail">
  459. update ecss_CoDelPalletDetail set part_no=#{partNo},qty=#{qty,jdbcType=DECIMAL},po_no=#{poNo},
  460. box_qty=#{boxQty,jdbcType=DECIMAL},update_by=#{updateBy},update_date=GetDate(),rolls=#{rolls},pn=#{pn}
  461. where site =#{site} and bu_no=#{buNo} and delNo=#{delNo} and seq_no=#{seqNo} and item_no=#{itemNo}
  462. </update>
  463. <delete id="deletePalletHeader">
  464. delete from ecss_CoDelPalletHeader where site =#{site} and bu_no=#{buNo} and delNo=#{delNo}
  465. <if test="seqNo != null and seqNo != ''">
  466. and seq_no=#{seqNo}
  467. </if>
  468. </delete>
  469. <delete id="deleteBoxList">
  470. delete from ecss_CoDelBoxList where site =#{site} and bu_no=#{buNo} and delNo=#{delNo}
  471. <if test="seqNo != null and seqNo != ''">
  472. and seq_no=#{seqNo}
  473. </if>
  474. </delete>
  475. <delete id="deletePalletDetail">
  476. delete from ecss_CoDelPalletDetail where site =#{site} and bu_no=#{buNo} and delNo=#{delNo}
  477. <if test="seqNo != null and seqNo != ''">
  478. and seq_no=#{seqNo}
  479. </if>
  480. <if test="itemNo != null and itemNo != ''">
  481. and item_no=#{itemNo}
  482. </if>
  483. </delete>
  484. <select id="getAllWeight" resultType="com.xujie.sys.modules.ecss.entity.EcssCoDelPalletHeader">
  485. select sum(gross_weight) as gross_weight ,sum(net_weight) as net_weight from ecss_CoDelBoxList
  486. where site =#{site} and delNo=#{delNo} and bu_no=#{buNo}
  487. </select>
  488. <select id="getDefaultEcssDeclarationDetailData" resultType="EcssDeclarationDetailData">
  489. -- 修复净重计算问题:按数量比例分配箱子净重,避免重复计算
  490. -- 一个箱子(BoxList)可能包含多个零件(PalletDetail),这些零件可能有相同的hsCode
  491. -- 需要按每个零件的数量占该箱子总数量的比例来分配净重
  492. WITH BoxDetail AS (
  493. -- 计算每个箱子中每个零件的数量及其占比
  494. SELECT
  495. d.site,
  496. d.bu_no,
  497. d.delNo,
  498. d.seq_no,
  499. p.hsCode,
  500. p.hsCodeDesc,
  501. d.qty,
  502. b.net_weight,
  503. -- 计算该零件数量占该箱子总数量的比例
  504. CASE
  505. WHEN SUM(d.qty) OVER (PARTITION BY d.site, d.bu_no, d.delNo, d.seq_no) > 0
  506. THEN d.qty * 1.0 / SUM(d.qty) OVER (PARTITION BY d.site, d.bu_no, d.delNo, d.seq_no)
  507. ELSE 0
  508. END as qtyRatio
  509. FROM ecss_CoDelPalletDetail d
  510. LEFT JOIN part p ON d.site=p.site AND d.part_no=p.part_no
  511. LEFT JOIN ecss_CoDelBoxList b ON d.site=b.site AND d.bu_no=b.bu_no AND d.delNo=b.delNo AND d.seq_no=b.item_no
  512. WHERE d.site=#{site} AND d.delNo=#{delNo} AND d.bu_no=#{buNo}
  513. )
  514. SELECT
  515. #{site} as site,
  516. hsCode,
  517. hsCodeDesc,
  518. SUM(qty) as qty,
  519. -- 按数量比例分配净重后汇总
  520. CONVERT(DECIMAL(20,2), SUM(ISNULL(net_weight, 0) * qtyRatio)) as NetWeight,
  521. 'CNY' as currency,
  522. '中国' as madeArea,
  523. #{destination} as destination,
  524. '南通其他' as sourceArea,
  525. '照章征免' as levy
  526. FROM BoxDetail
  527. GROUP BY hsCode, hsCodeDesc
  528. </select>
  529. <select id="getDefaultEcssDeclarationDetailData2" resultType="EcssDeclarationDetailData">
  530. select #{site} as site, b.hsCode,b.hsCodeDesc as hsCodeDesc,sum( a.qty) as qty ,sum(a.ttl_amount) as totalPrice,
  531. CONVERT(DECIMAL(20, 6),sum(a.ttl_amount)/sum( a.qty)) as unitPrice,
  532. a.currency as currency,'中国' as madeArea,#{destination} as destination,'南通其他' as sourceArea ,'照章征免' as levy from
  533. ecss_CoDelNotifyDetail a left join part b on a.site=b.site and a.part_no=b.part_no
  534. where a.site =#{site} and a.delNo=#{delNo} and a.qty>0 and a.bu_no=#{buNo}
  535. GROUP BY b.hsCodeDesc,b.hsCode,a.currency
  536. </select>
  537. <insert id="saveEcssDeclarationHeader">
  538. insert into ecss_declaration_header (site,declaration_no,customs_office_code,input_code,local_shipper,local_ship_address,ship_type,ship_date,submit_date,
  539. filing_no,overseas_shipper,shipping_mode,shipping_data,deliver_no,sales_partner,regulatory_method,duty_status,
  540. permit_number,cmc_invoice,sales_area,receive_area,shipping_port,exit_port,documents,remark,package_type,package_qty,
  541. gross_weight,net_weight,payment_type,ship_price,premium,other_price,special_relationship_comfirm,price_influence_confirm,
  542. royalty_payments_confirm,create_by,create_date,delNo,overseas_address,box_qty)
  543. values(#{site},#{declarationNo},#{customsOfficeCode},#{inputCode},#{localShipper,jdbcType=NVARCHAR},#{localShipAddress,jdbcType=NVARCHAR},#{shipType},#{shipDate},#{submitDate},
  544. #{filingNo},#{overseasShipper,jdbcType=NVARCHAR},#{shippingMode,jdbcType=NVARCHAR},#{shippingData},#{deliverNo},#{salesPartner,jdbcType=NVARCHAR},#{regulatoryMethod,jdbcType=NVARCHAR},#{dutyStatus,jdbcType=NVARCHAR},
  545. #{permitNumber},#{cmcInvoice},#{salesArea,jdbcType=NVARCHAR},#{receiveArea,jdbcType=NVARCHAR},#{shippingPort,jdbcType=NVARCHAR},#{exitPort,jdbcType=NVARCHAR},#{documents,jdbcType=NVARCHAR},#{remark,jdbcType=NVARCHAR},#{packageType,jdbcType=NVARCHAR},#{packageQty,jdbcType=INTEGER},
  546. #{grossWeight,jdbcType=DECIMAL},#{netWeight,jdbcType=DECIMAL},#{paymentType,jdbcType=NVARCHAR},#{shipPrice,jdbcType=DECIMAL},#{premium,jdbcType=DECIMAL},#{otherPrice,jdbcType=DECIMAL},#{specialRelationshipComfirm,jdbcType=NVARCHAR},#{priceInfluenceConfirm,jdbcType=NVARCHAR},
  547. #{royaltyPaymentsConfirm,jdbcType=NVARCHAR},#{createBy},GETDATE(),#{delNo},#{overseasAddress,jdbcType=NVARCHAR},#{boxQty})
  548. </insert>
  549. <insert id="saveEcssDeclarationDetail">
  550. 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,
  551. source_area,levy)
  552. values(#{site},#{declarationNo},#{itemNo,jdbcType=INTEGER},#{hsCode},#{hsCodeDesc},#{qty,jdbcType=DECIMAL},#{netWeight,jdbcType=DECIMAL},#{unitPrice,jdbcType=DECIMAL},#{totalPrice,jdbcType=DECIMAL},#{currency},#{madeArea},#{destination},
  553. #{sourceArea},#{levy})
  554. </insert>
  555. <select id="searchDeclarationHeader" resultType="EcssDeclarationHeaderData">
  556. select a.site,a.declaration_no,a.customs_office_code,a.input_code,a.local_shipper,a.local_ship_address,a.ship_type,
  557. a.ship_date,a.submit_date,a.filing_no,a.overseas_shipper,a.shipping_mode,a.shipping_data,a.deliver_no,a.sales_partner,
  558. a.regulatory_method,a.duty_status,a.permit_number,a.cmc_invoice,a.sales_area,a.receive_area,a.shipping_port,
  559. 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,
  560. a.premium,a.other_price,a.special_relationship_comfirm,a.price_influence_confirm,a.royalty_payments_confirm,
  561. a.create_by,a.create_date,a.update_by,a.update_date,a.delNo,noHeader.bu_no,
  562. a.upc,a.so,a.origin,a.pallet_weight,a.material,a.hs_code,a.packaging,a.kgs,a.shipping_mark,
  563. a.hsCodeDesc,a.contractFlag,a.hsCodeDescType,a.goodsLabel,a.boxChange,noHeader.customer_name as customName,
  564. noHeader.destination
  565. from ecss_declaration_header a
  566. left join ecss_CoDelNotifyHeader noHeader on a.site=noHeader.site and a.delNo=noHeader.delNo
  567. <where>
  568. <if test="query.delNo != null and query.delNo != ''">
  569. AND a.delNo like #{query.delNo}
  570. </if>
  571. <if test="query.declarationNo != null and query.declarationNo != ''">
  572. AND a.declaration_no like #{query.declarationNo}
  573. </if>
  574. <if test="query.cmcInvoice != null and query.cmcInvoice != ''">
  575. AND a.cmc_invoice like #{query.cmcInvoice}
  576. </if>
  577. <if test="query.site != null and query.site != ''">
  578. AND a.site like #{query.site}
  579. </if>
  580. <if test = "query.startDate!= null">
  581. AND a.ship_date>= #{query.startDate}
  582. </if>
  583. <if test = "query.endDate!= null">
  584. AND #{query.endDate} >=a.ship_date
  585. </if>
  586. </where>
  587. order by a.create_date desc
  588. </select>
  589. <select id="searchDeclarationDetail" resultType="EcssDeclarationDetailData">
  590. select site,declaration_no,item_no,hs_code,hs_code_desc,qty,net_weight,unit_price,total_price,currency,made_area,destination,
  591. source_area,levy
  592. from ecss_declaration_detail
  593. where site=#{site} and declaration_no=#{declarationNo}
  594. </select>
  595. <delete id="deleteDeclarationHeader">
  596. delete from ecss_declaration_header where site=#{site} and declaration_no=#{declarationNo}
  597. </delete>
  598. <delete id="deleteDeclarationDetail">
  599. delete from ecss_declaration_detail where site=#{site} and declaration_no=#{declarationNo}
  600. </delete>
  601. <select id="searchPalletData" resultType="EcssPalletData">
  602. select a.id,a.Site,a.BuNo,a.pallet_type as palletType,a.Remark,a.CreateBy,a.CreateDate,a.UpdateBy,a.UpdateDate,
  603. a.length, a.width, a.height, a.application_area as applicationArea, a.pallet_weight as palletWeight
  604. ,dbo.get_bu_desc(a.site,a.BuNo) as BuDesc,a.pallet_no as palletNo
  605. from ecss_pallet a
  606. left join accessBu D on A.site=D.site and A.BuNo=d.bu_no and D.username=#{query.username}
  607. <where>
  608. and D.site is not null
  609. <if test="query.buNo != null and query.buNo != ''">
  610. AND a.BuNo = #{query.buNo}
  611. </if>
  612. <if test="query.palletType != null and query.palletType != ''">
  613. AND a.pallet_type = #{query.palletType}
  614. </if>
  615. </where>
  616. order by a.CreateDate
  617. </select>
  618. <insert id="insertPalletData" >
  619. insert into ecss_pallet (Site,BuNo,pallet_type,Remark,CreateBy,CreateDate,length,width,
  620. height,application_area,pallet_weight,pallet_no)
  621. values(#{site},#{buNo},#{palletType},#{remark},#{createBy},GetDate(),#{length},#{width},
  622. #{height},#{applicationArea},#{palletWeight},#{palletNo})
  623. </insert>
  624. <update id="updatePalletData">
  625. update ecss_pallet set Remark=#{remark} ,pallet_type=#{palletType} ,
  626. length=#{length} ,width=#{width} ,
  627. height=#{height} ,application_area=#{applicationArea} ,
  628. pallet_weight=#{palletWeight} ,pallet_no=#{palletNo},
  629. UpdateDate=GetDate(),UpdateBy=#{updateBy}
  630. where site=#{site} and buNo=#{buNo} and id=#{id}
  631. </update>
  632. <select id="deletePallet" >
  633. delete from ecss_pallet where site=#{site} and buNo=#{buNo} and id=#{id}
  634. </select>
  635. <select id="getPallet" resultType="EcssPalletData">
  636. select * from ecss_pallet where site=#{site} and buNo=#{buNo} and pallet_no=#{palletNo}
  637. </select>
  638. <select id="getPackage" resultType="EcssPackageData">
  639. select * from ecss_package where site=#{site} and buNo=#{buNo} and package_no=#{packageNo}
  640. </select>
  641. <insert id="insertPackageData" >
  642. insert into ecss_package (Site,BuNo,package_type,Remark,CreateBy,CreateDate,length,width,
  643. height,volume,weight,package_no)
  644. values(#{site},#{buNo},#{packageType},#{remark},#{createBy},GetDate(),#{length},#{width},
  645. #{height},#{volume},#{weight},#{packageNo})
  646. </insert>
  647. <update id="updatePackageData">
  648. update ecss_package set Remark=#{remark} ,package_type=#{packageType} ,
  649. length=#{length} ,width=#{width} ,volume=#{volume},weight=#{weight},
  650. package_no=#{packageNo},height=#{height} ,
  651. UpdateDate=GetDate(),UpdateBy=#{updateBy}
  652. where site=#{site} and buNo=#{buNo} and id=#{id}
  653. </update>
  654. <select id="deleteEcssPackage" >
  655. delete from ecss_package where site=#{site} and buNo=#{buNo} and id=#{id}
  656. </select>
  657. <select id="searchPackageData" resultType="EcssPackageData">
  658. select a.id,a.Site,a.BuNo,a.package_type as packageType,a.Remark,a.CreateBy,a.CreateDate,a.UpdateBy,a.UpdateDate,
  659. a.length, a.width, a.height, a.volume, a.weight,a.package_no as packageNo
  660. ,dbo.get_bu_desc(a.site,a.BuNo) as BuDesc
  661. from ecss_package a
  662. left join accessBu D on A.site=D.site and A.BuNo=d.bu_no and D.username=#{query.username}
  663. <where>
  664. and D.site is not null
  665. <if test="query.buNo != null and query.buNo != ''">
  666. AND a.BuNo = #{query.buNo}
  667. </if>
  668. <if test="query.packageType != null and query.packageType != ''">
  669. AND a.package_type = #{query.packageType}
  670. </if>
  671. </where>
  672. order by a.CreateDate
  673. </select>
  674. <select id="searchHsCodeList" resultType="java.util.Map">
  675. select a.BuNo,a.HsCode,a.hsCodeDesc,a.unit,a.hsCodeDescEn
  676. from ecss_hsCode a
  677. <where> a.BuNo = #{buNo}
  678. <if test="hsCode != null and hsCode != ''">
  679. AND a.HsCode like '%'+#{hsCode}+'%'
  680. </if>
  681. <if test="hsCodeDesc != null and hsCodeDesc != ''">
  682. AND a.hsCodeDesc like '%'+#{hsCodeDesc}+'%'
  683. </if>
  684. </where>
  685. order by a.CreateDate ,a.HsCode
  686. </select>
  687. <select id="searchPalletList" resultType="java.util.Map">
  688. select a.BuNo,a.id as palletId,a.pallet_type as palletType,a.pallet_no as palletNo,
  689. a.application_area as applicationArea ,a.length, a.width, a.height
  690. from ecss_pallet a
  691. <where> a.BuNo = #{buNo}
  692. <if test="palletType != null and palletType != ''">
  693. AND a.pallet_type like '%'+#{palletType}+'%'
  694. </if>
  695. </where>
  696. order by a.CreateDate
  697. </select>
  698. <select id="searchPackageList" resultType="java.util.Map">
  699. select a.BuNo,a.id as packageId,a.package_type as packageType,a.package_no as packageNo,
  700. a.length, a.width, a.height
  701. from ecss_package a
  702. <where> a.BuNo = #{buNo}
  703. <if test="packageType != null and packageType != ''">
  704. AND a.package_type like '%'+#{packageType}+'%'
  705. </if>
  706. </where>
  707. order by a.CreateDate
  708. </select>
  709. <select id="getDeclarationElements" resultType="java.util.Map">
  710. select part_no as partNo,bu_no as buNo
  711. from ecss_CoDelNotifyDetail
  712. where site=#{site} and delNo=#{delNo} and qty>0
  713. GROUP BY part_no,bu_no
  714. </select>
  715. <select id="getHsCodeByPartNo" resultType="java.util.Map">
  716. select p.hsCode, p.hsCodeDesc,p.part_no ,h.codeNo,h.BuNo,p.sku,h.hsCodeDescEn
  717. from Part p
  718. left join ecss_hsCode h on p.hsCodeDesc=h.hsCodeDesc and p.site=h.site
  719. where p.site=#{site,jdbcType=VARCHAR} and p.part_no in
  720. <foreach item="item" index="index" collection="partNos" open="(" separator="," close=")">
  721. #{item}
  722. </foreach>
  723. </select>
  724. <select id="getDeclarationHeader" resultType="EcssDeclarationHeaderData">
  725. select * from ecss_declaration_header where site=#{site} and declaration_no=#{declarationNo}
  726. </select>
  727. <select id="getDeclarationHeaderByDelNo" resultType="EcssDeclarationHeaderData">
  728. select * from ecss_declaration_header where site=#{site} and delNo=#{delNo}
  729. </select>
  730. <select id="exportDeclarationDetail" resultType="java.util.Map">
  731. select detail.site,detail.declaration_no,detail.item_no,
  732. CONVERT(DECIMAL(20, 0), detail.qty) as qty,isnull(h.unit,'') as qty_unit,'kg' as weight_unit,
  733. CONVERT(DECIMAL(20, 2),detail.net_weight) as net_weight,CONVERT(DECIMAL(20, 6),detail.unit_price) as unit_price,
  734. CONVERT(DECIMAL(20, 2),detail.total_price) as total_price,detail.currency,detail.made_area,detail.destination,
  735. detail.source_area,detail.levy,detail.hs_code,detail.hs_code_desc,h.hsCodeDescEn
  736. from ecss_declaration_detail detail
  737. left join ecss_hsCode h on detail.hs_code=h.HsCode and detail.site=h.Site and detail.hs_code_desc=h.hsCodeDesc
  738. where detail.site=#{site} and declaration_no=#{declarationNo}
  739. </select>
  740. <select id="getEcssCoDelNotifyHeader" resultType="EcssCoDelNotifyHeaderData">
  741. select * from ecss_CoDelNotifyHeader where site=#{site} and delNo=#{delNo}
  742. </select>
  743. <select id="exportEcssCoDelNotifyDetail" resultType="java.util.Map">
  744. select a.customerPO,a.part_no,a.part_description,a.currency,
  745. CONVERT(DECIMAL(20, 0), a.qty) as qty,CONVERT(DECIMAL(20, 6), a.tp) as unitPrice,b.hsCode,
  746. a.upc,a.so,a.ttl_amount,a.pn,h.hsCodeDesc,h.hsCodeDescEn
  747. from ecss_CoDelNotifydetail a
  748. left join part b on a.site=b.site and a.part_no=b.part_no
  749. left join ecss_hsCode h on b.hsCode=h.HsCode and a.site=h.site and b.hsCodeDesc=h.hsCodeDesc
  750. where a.site = #{site} AND a.delNo = #{delNo} and a.qty>0
  751. order by a.item_no
  752. </select>
  753. <select id="exportCoDelPalletDetail" resultType="java.util.Map">
  754. -- 修复净重毛重重复计算问题:按数量比例分配箱子重量
  755. WITH BoxDetail AS (
  756. SELECT
  757. b.part_no,
  758. b.qty,
  759. b.rolls,
  760. a.box_qty,
  761. a.net_weight,
  762. a.gross_weight,
  763. b.site,
  764. b.bu_no,
  765. b.delNo,
  766. b.seq_no,
  767. -- 计算该零件数量占该箱子总数量的比例
  768. CASE
  769. WHEN SUM(b.qty) OVER (PARTITION BY b.site, b.bu_no, b.delNo, b.seq_no) > 0
  770. THEN b.qty * 1.0 / SUM(b.qty) OVER (PARTITION BY b.site, b.bu_no, b.delNo, b.seq_no)
  771. ELSE 0
  772. END as qtyRatio
  773. FROM ecss_CoDelBoxList a
  774. 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
  775. WHERE a.site=#{site} AND a.bu_no=#{buNo} AND a.delNo=#{delNo} AND b.site IS NOT NULL
  776. )
  777. SELECT
  778. part_no,
  779. CONVERT(DECIMAL(20, 0), SUM(qty)) as total_qty,
  780. CONVERT(DECIMAL(20, 0), SUM(DISTINCT box_qty)) as box_qty,
  781. CONVERT(DECIMAL(20, 0), SUM(rolls)) as rolls,
  782. -- 按数量比例分配净重和毛重
  783. CONVERT(DECIMAL(20, 2), SUM(ISNULL(net_weight, 0) * qtyRatio)) as net_weight,
  784. CONVERT(DECIMAL(20, 2), SUM(ISNULL(gross_weight, 0) * qtyRatio)) as gross_weight,
  785. CONVERT(DECIMAL(20, 0), SUM(rolls * qty)) as qty_per_carton
  786. FROM BoxDetail
  787. GROUP BY part_no
  788. </select>
  789. <select id="getCoDelPalletDetailGroupByPn" resultType="java.util.Map">
  790. -- 修复净重毛重重复计算问题:按数量比例分配箱子重量
  791. WITH BoxDetail AS (
  792. SELECT
  793. b.pn,
  794. b.qty,
  795. b.rolls,
  796. a.box_qty,
  797. a.net_weight,
  798. a.gross_weight,
  799. b.site,
  800. b.bu_no,
  801. b.delNo,
  802. b.seq_no,
  803. -- 计算该零件数量占该箱子总数量的比例
  804. CASE
  805. WHEN SUM(b.qty) OVER (PARTITION BY b.site, b.bu_no, b.delNo, b.seq_no) > 0
  806. THEN b.qty * 1.0 / SUM(b.qty) OVER (PARTITION BY b.site, b.bu_no, b.delNo, b.seq_no)
  807. ELSE 0
  808. END as qtyRatio
  809. FROM ecss_CoDelBoxList a
  810. 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
  811. WHERE a.site=#{site} AND a.bu_no=#{buNo} AND a.delNo=#{delNo}
  812. )
  813. SELECT
  814. pn,
  815. CONVERT(DECIMAL(20, 0), SUM(qty)) as total_qty,
  816. CONVERT(DECIMAL(20, 0), SUM(DISTINCT box_qty)) as box_qty,
  817. CONVERT(DECIMAL(20, 0), SUM(rolls)) as rolls,
  818. -- 按数量比例分配净重和毛重
  819. CONVERT(DECIMAL(20, 2), SUM(ISNULL(net_weight, 0) * qtyRatio)) as net_weight,
  820. CONVERT(DECIMAL(20, 2), SUM(ISNULL(gross_weight, 0) * qtyRatio)) as gross_weight,
  821. CONVERT(DECIMAL(20, 0), SUM(rolls * qty)) as qty_per_carton
  822. FROM BoxDetail
  823. WHERE pn IS NOT NULL
  824. GROUP BY pn
  825. </select>
  826. <select id="exportCoDelBoxList" resultType="java.util.Map">
  827. select CONVERT(DECIMAL(20, 0),sum(a.box_qty)) as box_qty
  828. from ecss_CoDelBoxList a
  829. where a.site=#{site} and a.bu_no=#{buNo} and a.delNo=#{delNo} GROUP BY a.item_no
  830. </select>
  831. <update id="updateEcssDeclarationHeader" >
  832. update ecss_declaration_header set
  833. upc=#{upc},so=#{so},origin=#{origin},pallet_weight=#{palletWeight},material=#{material},
  834. hs_code=#{hsCode},packaging=#{packaging},kgs=#{kgs},shipping_mark=#{shippingMark},boxChange=#{boxChange},
  835. hsCodeDesc=#{hsCodeDesc},contractFlag=#{contractFlag},hsCodeDescType=#{hsCodeDescType},goodsLabel=#{goodsLabel}
  836. where site=#{site} and declaration_no=#{declarationNo}
  837. </update>
  838. <update id="updateEcssCoDelNotifyDetail" >
  839. update ecss_CoDelNotifydetail set lossratio=#{lossratio},ehundred=#{ehundred}
  840. where site=#{site} and delNo=#{delNo} and part_no=#{partNo}
  841. </update>
  842. <update id="updateEcssCoDelNotifyDetailSurplus" >
  843. update ecss_CoDelNotifydetail set surplus_qty=#{surplusQty}
  844. where site=#{site} and bu_no=#{buNo} and delNo=#{delNo} and part_no=#{partNo} and item_no=#{itemNo}
  845. </update>
  846. <select id="getNotifyPartDetail" resultType="java.util.Map">
  847. select a.part_no as partNo,b.hsCode,a.site,a.delNo,a.lossratio,a.ehundred,b.part_desc,a.pn
  848. from ecss_CoDelNotifydetail a
  849. left join part b on a.site=b.site and a.part_no=b.part_no
  850. where a.site = #{site} AND a.delNo = #{delNo} and a.qty>0
  851. group by a.part_no,b.hsCode,a.site,a.delNo,a.lossratio,a.ehundred,b.part_desc,a.pn
  852. </select>
  853. <select id="getNotifyPartDetail2" resultType="EcssCoDelNotifyDetailData">
  854. select a.part_no as partNo,b.hsCode,a.site,a.delNo,a.lossratio,a.ehundred,b.part_desc,a.pn
  855. from ecss_CoDelNotifydetail a
  856. left join part b on a.site=b.site and a.part_no=b.part_no
  857. where a.site = #{site} AND a.delNo = #{delNo} and a.qty>0
  858. group by a.part_no,b.hsCode,a.site,a.delNo,a.lossratio,a.ehundred,b.part_desc,a.pn
  859. </select>
  860. <select id="getNotifyDetailGroup" resultType="java.util.Map">
  861. select b.hsCodeDesc,CONVERT(DECIMAL(20, 2),sum(a.qty)) as total_qty,
  862. CONVERT(DECIMAL(20, 2),sum(a.ttl_amount)) as ttl_amount
  863. from ecss_CoDelNotifydetail a
  864. left join part b on a.site=b.site and a.part_no=b.part_no
  865. where a.site = #{site} AND a.delNo = #{delNo} and a.qty>0
  866. group by b.hsCodeDesc
  867. </select>
  868. <!-- 根据notifyDetailItemNo获取发货通知单明细 -->
  869. <select id="getEcssCoDelNotifyDetailByItemNo" resultType="EcssCoDelNotifyDetailData">
  870. 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,
  871. 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,
  872. 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,
  873. a.modifyFlag,a.modifyQtyFlag
  874. from ecss_CoDelNotifydetail a
  875. where a.site = #{site}
  876. and a.bu_no = #{buNo}
  877. and a.delNo = #{delNo}
  878. and a.item_no = #{notifyDetailItemNo}
  879. </select>
  880. <select id="getPropertiesListByTypeAndCodeNo" resultType="com.xujie.sys.modules.part.entity.PartSubPropertiesValueData">
  881. SELECT a.part_no , a.Site, a.code_no, a.sub_code_seq_no, a.sub_code_desc
  882. ,a.bu_no,a.item_no, a.properties_item_no, a.text_value, a.num_value, a.record_type
  883. , b.item_desc ItemDesc, b.value_type, b.value_type_db, b.value_choose_flag
  884. FROM part_sub_properties_value a
  885. left join plm_properties_item b
  886. 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
  887. <where>
  888. AND a.site = #{site}
  889. and a.record_type = #{recordType}
  890. and a.bu_no=#{buNo}
  891. and a.code_no = #{codeNo}
  892. and a.part_no = #{pn}
  893. </where>
  894. order by a.item_no
  895. </select>
  896. <select id="getEcssContacts" resultType="java.util.Map">
  897. select * from ecss_contacts where bu_no=#{buNo}
  898. </select>
  899. <select id="getCustomerList" resultType="java.util.Map">
  900. select * from ecss_custdev_mes_cmc_customer where buse='是'
  901. </select>
  902. <select id="getCustomerInfo" resultType="java.util.Map">
  903. select DISTINCT vcus.ccusname,vcusp.ccontactname,vcusp.cnative
  904. from ecss_custdev_mes_cmc_customer vcus
  905. LEFT JOIN ecss_custdev_mes_cmc_customer_person vcusp on vcus.ccuscode=vcusp.ccuscode
  906. <where>
  907. <if test="ccusname != null and ccusname != ''">
  908. and vcus.ccusname=#{ccusname}
  909. </if>
  910. <if test="ccuscode != null and ccuscode != ''">
  911. and vcus.ccuscode=#{ccuscode}
  912. </if>
  913. </where>
  914. </select>
  915. <select id="getCustomerAdd" resultType="java.util.Map">
  916. select DISTINCT vcus.ccusname,vcusa.cDeliverAdd
  917. from ecss_custdev_mes_cmc_customer vcus
  918. left join ecss_custdev_mes_cmc_customer_addr vcusa on vcus.ccuscode=vcusa.ccuscode
  919. where vcus.ccusname=#{ccusname}
  920. </select>
  921. <select id="getPackageNoByPartNo" resultType="java.util.Map">
  922. select p.part_no as partNo,p.packageNo
  923. from Part p
  924. where p.site=#{site,jdbcType=VARCHAR} and p.part_no in
  925. <foreach item="item" index="index" collection="partNos" open="(" separator="," close=")">
  926. #{item}
  927. </foreach>
  928. </select>
  929. <select id="getPackageNoByPn" resultType="java.util.Map">
  930. select p.sku as pn,p.packageNo
  931. from Part p
  932. where p.site=#{site,jdbcType=VARCHAR} and p.sku in
  933. <foreach item="item" index="index" collection="pns" open="(" separator="," close=")">
  934. #{item}
  935. </foreach>
  936. </select>
  937. <select id="getPackageList" resultType="EcssPackageData">
  938. select * from ecss_package where site=#{site} and buNo=#{buNo}
  939. and package_no in
  940. <foreach item="item" index="index" collection="packageNos" open="(" separator="," close=")">
  941. #{item}
  942. </foreach>
  943. </select>
  944. <select id="searchEcssTemplateData" resultType="EcssTemplate">
  945. select a.*,dbo.get_bu_desc(a.site,a.BuNo) as BuDesc
  946. from ecss_template a
  947. left join accessBu D on A.site=D.site and A.BuNo=d.bu_no and D.username=#{query.username}
  948. <where>
  949. and D.site is not null
  950. <if test="query.buNo != null and query.buNo != ''">
  951. AND a.buNo = #{query.buNo}
  952. </if>
  953. <if test="query.name != null and query.name != ''">
  954. AND a.name like '%'+#{query.name}+'%'
  955. </if>
  956. <if test="query.customName != null and query.customName != ''">
  957. AND a.customName like '%'+#{query.customName}+'%'
  958. </if>
  959. <if test="query.shippingMode != null and query.shippingMode != ''">
  960. AND a.shippingMode like '%'+#{query.shippingMode}+'%'
  961. </if>
  962. <if test="query.type != null and query.type != ''">
  963. AND a.type = #{query.type}
  964. </if>
  965. </where>
  966. order by a.CreateDate
  967. </select>
  968. <insert id="insertEcssTemplateData" >
  969. insert into ecss_template (customName,site,buNo,name,type,upc,so,origin,palletWeight,material,hsCode,packaging,itemNo,
  970. kgs,shippingMark,boxChange,hsCodeDesc,contractFlag,hsCodeDescType,goodsLabel,hsCodeFlag,shippingMode,CreateBy,CreateDate,
  971. salesMethod,currency,madeArea,sendPort,shipper,voyage,deliveryGoodsDate,shippingDate,fscWeight, remark,highPalletFlag,showWeight)
  972. values(#{customName,jdbcType=NVARCHAR},#{site},#{buNo},#{name},#{type},#{upc},#{so},#{origin},#{palletWeight},#{material},#{hsCode},#{packaging},
  973. #{itemNo},#{kgs},#{shippingMark},#{boxChange},
  974. #{hsCodeDesc},#{contractFlag},#{hsCodeDescType},#{goodsLabel},#{hsCodeFlag},#{shippingMode},#{createBy},GetDate(),
  975. #{salesMethod},#{currency},#{madeArea},#{sendPort},#{shipper},#{voyage},#{deliveryGoodsDate},#{shippingDate},#{fscWeight},#{remark},#{highPalletFlag},#{showWeight})
  976. </insert>
  977. <update id="updateEcssTemplateData">
  978. update ecss_template set buNo=#{buNo},name=#{name},type=#{type},upc=#{upc},so=#{so},origin=#{origin},boxChange=#{boxChange},
  979. palletWeight=#{palletWeight},material=#{material},hsCode=#{hsCode},itemNo=#{itemNo},
  980. packaging=#{packaging},kgs=#{kgs},shippingMark=#{shippingMark},hsCodeDesc=#{hsCodeDesc},
  981. contractFlag=#{contractFlag},hsCodeDescType=#{hsCodeDescType},goodsLabel=#{goodsLabel},hsCodeFlag=#{hsCodeFlag},
  982. shippingMode=#{shippingMode},UpdateDate=GetDate(),UpdateBy=#{updateBy},customName=#{customName,jdbcType=NVARCHAR},salesMethod= #{salesMethod},
  983. currency= #{currency},madeArea= #{madeArea},sendPort= #{sendPort},shipper= #{shipper},remark= #{remark},
  984. voyage= #{voyage},deliveryGoodsDate= #{deliveryGoodsDate},shippingDate= #{shippingDate},fscWeight=#{fscWeight},highPalletFlag=#{highPalletFlag},showWeight=#{showWeight}
  985. where buNo=#{buNo} and name=#{nameNative}
  986. </update>
  987. <select id="deleteEcssTemplate" >
  988. delete from ecss_template where buNo=#{buNo} and name=#{name}
  989. </select>
  990. <select id="getEcssTemplateByBuAndName" resultType="EcssTemplate">
  991. select * from ecss_template where name=#{name} and site=#{site}
  992. </select>
  993. <select id="searchWalMartOrderData" resultType="EcssWalMartOrder">
  994. select a.*
  995. from ecss_walMartOrder a
  996. <where>
  997. <if test="query.so != null and query.so != ''">
  998. AND a.so like '%'+#{query.so}+'%'
  999. </if>
  1000. <if test="query.sku != null and query.sku != ''">
  1001. AND a.sku like '%'+#{query.sku}+'%'
  1002. </if>
  1003. </where>
  1004. order by a.CreateDate
  1005. </select>
  1006. <insert id="insertWalMartOrderData" >
  1007. insert into ecss_walMartOrder (site,buNo,sku,so,qty,rolls,grossWeight,verificationSheet,CreateBy,CreateDate)
  1008. values(#{site},#{buNo},#{sku},#{so},#{qty},#{rolls},#{grossWeight},#{verificationSheet},#{createBy},GetDate())
  1009. </insert>
  1010. <insert id="batchSaveWalMartOrder">
  1011. insert into ecss_walMartOrder (site,buNo,sku,so,qty,rolls,grossWeight,verificationSheet,CreateBy,CreateDate)
  1012. values
  1013. <foreach collection="list" separator="," item="item">
  1014. (#{item.site},#{item.buNo},#{item.sku},#{item.so},#{item.qty},
  1015. #{item.rolls},#{item.grossWeight},#{item.verificationSheet},#{item.createBy},GetDate())
  1016. </foreach>
  1017. </insert>
  1018. <update id="updateWalMartOrderData">
  1019. update ecss_walMartOrder set buNo=#{buNo},sku=#{sku},so=#{so},qty=#{qty},rolls=#{rolls},grossWeight=#{grossWeight},
  1020. verificationSheet=#{verificationSheet},UpdateDate=GetDate(),UpdateBy=#{updateBy}
  1021. where buNo=#{buNo} and sku=#{sku} and so=#{so} and qty=#{qty}
  1022. </update>
  1023. <select id="deleteWalMartOrder" >
  1024. delete from ecss_walMartOrder where buNo=#{buNo} and sku=#{sku} and so=#{so} and qty=#{qty}
  1025. </select>
  1026. <!-- 查出所有类型的物料 -->
  1027. <select id="queryPartListAll" parameterType="PartInformationEntity" resultType="PartInformationEntity">
  1028. SELECT site, sourceBu as buNo, part_no, part_desc, sku
  1029. FROM part
  1030. <where> sourceBu=#{query.buNo} and
  1031. site = #{query.site} and active = 'Y'
  1032. <if test = "query.partNo != null and query.partNo != ''">
  1033. AND part_no like '%' + #{query.partNo} + '%'
  1034. </if>
  1035. <if test = "query.sku != null and query.sku != ''">
  1036. AND sku like '%' + #{query.sku} + '%'
  1037. </if>
  1038. <if test = "query.partDesc != null and query.partDesc != ''">
  1039. AND part_desc like '%' + #{query.partDesc} + '%'
  1040. </if>
  1041. </where>
  1042. </select>
  1043. <select id="queryByUserName" resultType="com.xujie.sys.modules.sys.entity.SysUserEntity">
  1044. select * from sys_user where username = #{username}
  1045. </select>
  1046. <select id="queryUsersByRoleName" resultType="com.xujie.sys.modules.sys.entity.SysUserEntity">
  1047. select u.email from sys_user u
  1048. LEFT JOIN sys_user_role ur on ur.user_id = u.user_id
  1049. LEFT JOIN sys_role r on r.role_id = ur.role_id
  1050. where r.role_name = #{roleName} and u.site = #{site}
  1051. </select>
  1052. <select id="searchCoDelPalletDataNew" resultType="EcssCoDelPalletData">
  1053. 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,
  1054. c.gross_weight,c.net_weight,c.box_qty as pallet_qty,b.notify_detail_item_no as notifyDetailItemNo
  1055. from ecss_CoDelPalletDetail b
  1056. 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
  1057. where b.site=#{site} and b.bu_no=#{buNo} and b.delNo=#{delNo}
  1058. <if test="seqNo != null and seqNo != ''">
  1059. and b.seq_no=#{seqNo}
  1060. </if>
  1061. </select>
  1062. <update id="updateExportFlag">
  1063. update ecss_CoDelNotifyHeader
  1064. set export_flag = #{exportFlag},
  1065. updateBy = #{updateBy},
  1066. updateDate = GetDate()
  1067. where site = #{site}
  1068. and bu_no = #{buNo}
  1069. and delNo = #{delNo}
  1070. </update>
  1071. <select id="selectBoxList" resultType="java.util.Map">
  1072. select *,CONVERT(DECIMAL(20, 3),gross_weight) as grossWeight,CONVERT(DECIMAL(20, 3),net_weight) as netWeight from ecss_CoDelBoxList
  1073. where site = #{site} and bu_no = #{buNo} and delNo = #{delNo}
  1074. </select>
  1075. <update id="updateBoxInfo">
  1076. update ecss_CoDelBoxList
  1077. set box_qty = #{box_qty},
  1078. gross_weight = #{grossWeight},
  1079. net_weight = #{netWeight}
  1080. where site = #{site}
  1081. and bu_no = #{buNo}
  1082. and delNo = #{delNo}
  1083. and item_no = #{item_no}
  1084. </update>
  1085. <delete id="deleteBoxInfo">
  1086. delete from ecss_CoDelBoxList
  1087. where site = #{site}
  1088. and bu_no = #{buNo}
  1089. and delNo = #{delNo}
  1090. and item_no = #{item_no}
  1091. </delete>
  1092. <update id="updateDetailInfo">
  1093. update ecss_CoDelPalletDetail
  1094. set qty = #{qty},
  1095. rolls = #{rolls}
  1096. where site = #{site}
  1097. and bu_no = #{buNo}
  1098. and delNo = #{delNo}
  1099. and seq_no = #{seqNo}
  1100. and item_no = #{itemNo}
  1101. </update>
  1102. <delete id="deleteDetailInfo">
  1103. delete from ecss_CoDelPalletDetail
  1104. where site = #{site}
  1105. and bu_no = #{buNo}
  1106. and delNo = #{delNo}
  1107. and seq_no = #{seqNo}
  1108. and item_no = #{itemNo}
  1109. </delete>
  1110. <delete id="deleteEmptyBoxAfterDetailDelete">
  1111. -- 删除明细后,如果该box下没有明细了,则删除对应的box
  1112. delete from ecss_CoDelBoxList
  1113. where site = #{site}
  1114. and bu_no = #{buNo}
  1115. and delNo = #{delNo}
  1116. and item_no = #{seqNo}
  1117. and not exists (
  1118. select 1
  1119. from ecss_CoDelPalletDetail
  1120. where site = #{site}
  1121. and bu_no = #{buNo}
  1122. and delNo = #{delNo}
  1123. and seq_no = #{seqNo}
  1124. );
  1125. </delete>
  1126. <!--<select id="selectPalletDetailList" resultType="java.util.Map">
  1127. select a.*,b.part_description,b.hsCode,b.upc,b.so
  1128. from ecss_CoDelPalletDetail a left join (
  1129. select a.site,a.bu_no,a.delNo,a.part_no,a.part_description,b.hsCode,a.upc,a.so,a.customerPO
  1130. from ecss_CoDelNotifydetail a
  1131. left join part b on a.site=b.site and a.part_no=b.part_no
  1132. where a.site=#{site} and a.bu_no=#{buNo} and a.delNo=#{delNo}
  1133. GROUP BY a.site,a.bu_no,a.delNo,a.part_no,a.part_description,b.hsCode,a.upc,a.so,a.customerPO
  1134. ) 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 and b.customerPO=a.po_no
  1135. where a.site =#{site} and a.bu_no=#{buNo} and a.delNo=#{delNo}
  1136. <if test="seqNo != null and seqNo != ''">
  1137. and a.seq_no=#{seqNo}
  1138. </if>
  1139. order by a.notify_detail_item_no
  1140. </select>-->
  1141. <select id="selectPalletDetailList" resultType="java.util.Map">
  1142. select a.*,b.part_description,c.hsCode,b.upc,b.so
  1143. from ecss_CoDelPalletDetail a
  1144. left join ecss_CoDelNotifydetail b on a.site=b.site and a.bu_no=b.bu_no and a.delNo=b.delNo and a.notify_detail_item_no=b.item_no
  1145. left join part c on a.site=c.site and a.part_no=c.part_no
  1146. where a.site =#{site} and a.bu_no=#{buNo} and a.delNo=#{delNo}
  1147. <if test="seqNo != null and seqNo != ''">
  1148. and a.seq_no=#{seqNo}
  1149. </if>
  1150. order by a.notify_detail_item_no
  1151. </select>
  1152. <!-- 获取客户模板列表 -->
  1153. <select id="getCustomerTemplateList" resultType="java.util.Map">
  1154. SELECT
  1155. template_no,
  1156. template_name,
  1157. ccuscode,
  1158. ccusname,
  1159. caddcode1,
  1160. localShipAddress,
  1161. salesArea,
  1162. caddcode2,
  1163. overseasAddress,
  1164. cnative,
  1165. overseasShipper
  1166. FROM ecss_Customer_template
  1167. <where>
  1168. <if test="templateName != null and templateName != ''">
  1169. AND template_name like '%'+#{templateName}+'%'
  1170. </if>
  1171. <if test="customerName != null and customerName != ''">
  1172. AND customer_name like '%'+#{customerName}+'%'
  1173. </if>
  1174. </where>
  1175. ORDER BY template_name
  1176. </select>
  1177. </mapper>