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.

1984 lines
94 KiB

1 year ago
1 year ago
1 year ago
1 year ago
7 months ago
1 year ago
7 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
7 months ago
1 year ago
10 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
7 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
7 months ago
1 year ago
11 months ago
9 months ago
1 year ago
11 months 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
9 months ago
1 year ago
6 months ago
1 year ago
1 year ago
8 months ago
8 months ago
9 months ago
1 year ago
7 months ago
1 year ago
10 months ago
9 months 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
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 month ago
1 year ago
1 year ago
1 month 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
7 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
1 year ago
1 year ago
1 year ago
11 months ago
1 year ago
11 months ago
1 year ago
11 months ago
1 year ago
1 year ago
7 months ago
1 year ago
11 months ago
1 year ago
1 year ago
11 months ago
1 year ago
11 months ago
1 year ago
1 year ago
10 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
9 months ago
9 months ago
9 months ago
1 year ago
7 months ago
1 year ago
4 weeks ago
1 year ago
1 year ago
1 year ago
1 year ago
4 weeks ago
4 weeks 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
10 months ago
10 months ago
10 months ago
10 months ago
1 year ago
1 year ago
1 month ago
1 year ago
1 month ago
9 months ago
9 months ago
11 months ago
11 months ago
4 weeks ago
1 year ago
1 year ago
1 year ago
1 year ago
11 months ago
9 months ago
11 months ago
1 month ago
10 months ago
10 months ago
10 months ago
9 months ago
11 months ago
1 year ago
1 year ago
9 months ago
1 year ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
3 months ago
1 month ago
11 months ago
11 months ago
7 months ago
11 months ago
7 months ago
11 months ago
4 weeks ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
4 months ago
11 months ago
10 months ago
11 months ago
1 month ago
10 months ago
1 month ago
10 months ago
1 month ago
1 month ago
6 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.actualNotifyDate,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.modify_count as modifyCount,a.overseasShipper,a.overseasAddress,a.cnative,a.salesArea,
  8. a.localShipAddress,a.walMartOrderFlag,a.fscFlag,a.boxSizeFlag,a.templateNo
  9. from ecss_CoDelNotifyHeader a
  10. left join accessBu D on A.site=D.site and A.bu_no=d.bu_no and D.username=#{query.username}
  11. <where>
  12. and D.site is not null
  13. <if test="query.buNo != null and query.buNo != ''">
  14. AND a.bu_no = #{query.buNo}
  15. </if>
  16. <if test="query.delNo != null and query.delNo != ''">
  17. AND a.delNo like #{query.delNo}
  18. </if>
  19. <if test="query.cmcInvoice != null and query.cmcInvoice != ''">
  20. AND a.cmc_invoice like #{query.cmcInvoice}
  21. </if>
  22. <if test="query.notifyStatus != null and query.notifyStatus != ''">
  23. AND a.notify_status = #{query.notifyStatus}
  24. </if>
  25. <if test="query.fscFlag == 'true'">
  26. AND a.fscFlag = 'Y'
  27. </if>
  28. <if test="query.boxSizeFlag == 'true'">
  29. AND a.boxSizeFlag = 'Y'
  30. </if>
  31. <if test="query.walMartOrderFlag == 'true'">
  32. AND a.walMartOrderFlag = 'Y'
  33. </if>
  34. <if test = "query.startDate!= null">
  35. AND a.ready_date>= #{query.startDate}
  36. </if>
  37. <if test = "query.endDate!= null">
  38. AND #{query.endDate} >=a.ready_date
  39. </if>
  40. <if test="query.modifyData == 'true'">
  41. and a.modifyFlag=1
  42. </if>
  43. </where>
  44. order by a.createDate desc ,a.delNo desc
  45. </select>
  46. <select id="searchEcssCoDelNotifyHeaderForCK" resultType="EcssCoDelNotifyHeaderData">
  47. select a.site,a.bu_no,a.delNo,a.erp_delNo,a.ready_date,a.notifyDate,a.actualNotifyDate,a.customer_name,a.Destination,a.shipping_mode,a.erp_flag,
  48. 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,
  49. a.modifyFlag,a.modify_count as modifyCount,ISNULL(a.export_flag,'N') as exportFlag,a.fscFlag,a.boxSizeFlag,a.totalVolume
  50. from ecss_CoDelNotifyHeader a
  51. left join accessBu D on A.site=D.site and A.bu_no=d.bu_no and D.username=#{query.username}
  52. <where>
  53. and D.site is not null
  54. <if test="query.buNo != null and query.buNo != ''">
  55. AND a.bu_no = #{query.buNo}
  56. </if>
  57. <if test="query.delNo != null and query.delNo != ''">
  58. AND a.delNo like #{query.delNo}
  59. </if>
  60. <if test="query.cmcInvoice != null and query.cmcInvoice != ''">
  61. AND a.cmc_invoice like #{query.cmcInvoice}
  62. </if>
  63. <if test="query.notifyStatus != null and query.notifyStatus != ''">
  64. AND a.notify_status = #{query.notifyStatus}
  65. </if>
  66. AND a.notify_status != '已计划'
  67. <if test = "query.startDate!= null">
  68. AND a.ready_date>= #{query.startDate}
  69. </if>
  70. <if test = "query.endDate!= null">
  71. AND #{query.endDate} >=a.ready_date
  72. </if>
  73. <if test="query.modifyData == 'true'">
  74. and a.modifyFlag=1
  75. </if>
  76. <if test="query.fscFlag == 'true'">
  77. AND a.fscFlag = 'Y'
  78. </if>
  79. <if test="query.boxSizeFlag == 'true'">
  80. AND a.boxSizeFlag = 'Y'
  81. </if>
  82. <if test="query.walMartOrderFlag == 'true'">
  83. AND a.walMartOrderFlag = 'Y'
  84. </if>
  85. <if test="query.exportFlag != null and query.exportFlag != ''">
  86. and ISNULL(a.export_flag,'N') = #{query.exportFlag}
  87. </if>
  88. </where>
  89. order by a.createDate desc ,a.delNo desc
  90. </select>
  91. <select id="searchEcssCoDelNotifyHeaderForDanZheng" resultType="EcssCoDelNotifyHeaderData">
  92. select a.site,a.bu_no,a.delNo,a.erp_delNo,a.ready_date,a.notifyDate,a.actualNotifyDate,a.customer_name,a.Destination,a.shipping_mode,a.erp_flag,
  93. 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
  94. from ecss_CoDelNotifyHeader a
  95. left join accessBu D on A.site=D.site and A.bu_no=d.bu_no and D.username=#{query.username}
  96. <where>
  97. and D.site is not null
  98. <if test="query.buNo != null and query.buNo != ''">
  99. AND a.bu_no = #{query.buNo}
  100. </if>
  101. <if test="query.delNo != null and query.delNo != ''">
  102. AND a.delNo like #{query.delNo}
  103. </if>
  104. <if test="query.cmcInvoice != null and query.cmcInvoice != ''">
  105. AND a.cmc_invoice like #{query.cmcInvoice}
  106. </if>
  107. <if test="query.notifyStatus != null and query.notifyStatus != ''">
  108. AND a.notify_status = #{query.notifyStatus}
  109. </if>
  110. AND a.notify_status = '仓库已确认'
  111. <if test = "query.startDate!= null">
  112. AND a.ready_date>= #{query.startDate}
  113. </if>
  114. <if test = "query.endDate!= null">
  115. AND #{query.endDate} >=a.ready_date
  116. </if>
  117. <if test="query.walMartOrderFlag == 'true'">
  118. AND a.walMartOrderFlag = 'Y'
  119. </if>
  120. <if test="query.walMartOrderFlag == null or query.walMartOrderFlag == '' or query.walMartOrderFlag == 'false'">
  121. AND (a.walMartOrderFlag is null or a.walMartOrderFlag != 'Y')
  122. </if>
  123. </where>
  124. order by a.createDate desc ,a.delNo desc
  125. </select>
  126. <select id="checkEcssCoDelNotifyHeaderByDelNo" resultType="EcssCoDelNotifyHeaderData">
  127. select a.site,a.bu_no,a.delNo,a.erp_delNo,a.ready_date,a.notifyDate,a.actualNotifyDate,a.customer_name,a.Destination,a.shipping_mode,a.erp_flag,
  128. 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
  129. ,a.overseasShipper,a.overseasAddress,a.cnative,a.localShipAddress,a.salesArea,a.walMartOrderFlag,a.fscFlag,a.boxSizeFlag,a.templateNo
  130. from ecss_CoDelNotifyHeader a
  131. where a.site = #{site}
  132. AND a.delNo = #{delNo}
  133. </select>
  134. <select id="checkEcssDeclarationHeaderByDelNo" resultType="EcssCoDelNotifyHeaderData">
  135. select a.site,a.delNo
  136. from ecss_declaration_header a
  137. where a.site = #{site}
  138. AND a.delNo = #{delNo}
  139. </select>
  140. <select id="searchEcssCoDelNotifyDetail" resultType="EcssCoDelNotifyDetailData">
  141. 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,
  142. 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,
  143. 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,
  144. c.num_value as boxrolls,d.num_value as rollqty,w.num_value as boxweight,#{cmcInvoice} as cmcInvoice,a.modifyFlag,a.modifyQtyFlag,
  145. b.hsCodeDesc,a.vat,a.roll,a.carton,b.packageNo,b.cinvcname,a.qty_roll as qtyRoll,a.qty_box as qtyBox
  146. from ecss_CoDelNotifydetail a
  147. left join part b on a.site=b.site and a.part_no=b.part_no
  148. 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
  149. and c.record_type='ECSSPART' and c.code_no='BG001' and c.properties_item_no='BOXROLLS'
  150. 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
  151. and d.record_type='ECSSPART' and d.code_no='BG001' and d.properties_item_no='ROLLQTY'
  152. 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
  153. and w.record_type='ECSSPART' and w.code_no='BG001' and w.properties_item_no='BOXWEIGHT'
  154. <where>
  155. And a.site = #{site}
  156. AND a.delNo = #{delNo}
  157. </where>
  158. order by a.item_no
  159. </select>
  160. <select id="getEcssCoDelNotifyDetail" resultType="EcssCoDelNotifyDetailData">
  161. 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,
  162. a.part_no,a.part_description,a.qty,a.lt,a.cmc_comment,a.saleType,a.awb_bl,a.shipping_number,a.forwarder_info,
  163. 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,
  164. a.modifyFlag,a.modifyQtyFlag
  165. from ecss_CoDelNotifydetail a
  166. <where>
  167. And a.site = #{site}
  168. AND a.delNo = #{delNo}
  169. AND a.item_no = #{itemNo} and a.qty>0
  170. </where>
  171. </select>
  172. <select id="getSiteByBu" resultType="String">
  173. select top 1 site from BU where bu_no=#{buNo}
  174. </select>
  175. <select id="checkIfHasHeader" resultType="EcssCoDelNotifyHeaderData">
  176. select top 1 * from ecss_CoDelNotifyHeader where cmc_invoice=#{inVoice}
  177. </select>
  178. <update id="updateTransNo" >
  179. EXEC UpdateTransNo #{site}, #{transType}
  180. </update>
  181. <select id="getTransNo" resultType="String">
  182. SELECT
  183. dbo.Get_TransNo(#{site},#{transType}) as transNo
  184. </select>
  185. <insert id="saveEcssCoDelNotifyHeader" >
  186. insert into ecss_CoDelNotifyHeader(site,bu_no,delNo,ready_date,customer_name,Destination,shipping_mode,erp_flag,notify_status,
  187. remark,createDate,createBy,cmc_invoice,overseasShipper,overseasAddress,cnative,localShipAddress,salesArea,templateNo)
  188. values(#{site},#{buNo},#{delNo},#{readyDate},#{customerName,jdbcType=NVARCHAR},#{destination,jdbcType=NVARCHAR},#{shippingMode},'N',#{notifyStatus},#{remark,jdbcType=NVARCHAR},GetDate(),
  189. #{createBy},#{cmcInvoice},#{overseasShipper,jdbcType=NVARCHAR},#{overseasAddress,jdbcType=NVARCHAR},#{cnative,jdbcType=NVARCHAR},
  190. #{localShipAddress,jdbcType=NVARCHAR}, #{salesArea,jdbcType=NVARCHAR},#{templateNo,jdbcType=NVARCHAR})
  191. </insert>
  192. <insert id="batchSaveEcssCoDelNotifyDetail">
  193. insert into ecss_CoDelNotifyDetail (site,bu_no,delNo,item_no,salesOrder,salesOrder_item_no,customerPO,line,version,
  194. status,family,part_no,part_description,qty,lt,cmc_comment,saleType,
  195. awb_bl,shipping_number,forwarder_info,currency,tp,ttl_amount,sum_price,
  196. so,upc,remark,pn,surplus_qty,vat,roll,carton,saleslt,manufacturer_name,modifyFlag,modifyQtyFlag,category,qty_roll,qty_box)
  197. values
  198. <foreach collection="list" separator="," item="item">
  199. (#{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},
  200. #{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},
  201. #{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},
  202. #{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},
  203. #{item.modifyFlag},#{item.modifyQtyFlag},#{item.category,jdbcType=NVARCHAR},#{item.qtyRoll,jdbcType=NVARCHAR},#{item.qtyBox,jdbcType=NVARCHAR})
  204. </foreach>
  205. </insert>
  206. <select id="checkPart" resultType="PartData">
  207. select site,part_no from Part where site=#{site,jdbcType=VARCHAR} and part_no=#{partNo}
  208. </select>
  209. <select id="getPartNo" resultType="PartData">
  210. select top 1 site,part_no,hsCode,hsCodeDesc,part_desc,umid,brand from Part where site=#{site,jdbcType=VARCHAR} and sku=#{partNo} and sourceBu=#{buNo}
  211. </select>
  212. <select id="getPartInfo" resultType="PartData">
  213. select * from Part where site=#{site,jdbcType=VARCHAR} and part_no=#{partNo}
  214. </select>
  215. <update id="updateEcssDelHeader" >
  216. update ecss_CoDelNotifyHeader set notifyDate=#{notifyDate,jdbcType=TIMESTAMP} ,ready_date=#{readyDate,jdbcType=TIMESTAMP} ,customer_name=#{customerName,jdbcType=NVARCHAR},
  217. Destination=#{destination,jdbcType=NVARCHAR},shipping_mode=#{shippingMode},modifyFlag=#{modifyFlag},export_flag='N',
  218. remark=#{remark,jdbcType=NVARCHAR} ,cmc_invoice=#{cmcInvoice},overseasShipper=#{overseasShipper,jdbcType=NVARCHAR} ,overseasAddress=#{overseasAddress,jdbcType=NVARCHAR}
  219. where site=#{site} and delNo=#{delNo}
  220. </update>
  221. <update id="updateEcssDelHeaderVolume" >
  222. update ecss_CoDelNotifyHeader set totalVolume=#{totalVolume,jdbcType=DECIMAL} where site=#{site} and delNo=#{delNo}
  223. </update>
  224. <!-- 专门更新客户信息的方法 -->
  225. <update id="updateCustomerInfo">
  226. update ecss_CoDelNotifyHeader
  227. set customer_name = #{customerName,jdbcType=NVARCHAR},
  228. localShipAddress = #{localShipAddress,jdbcType=NVARCHAR},
  229. overseasShipper = #{overseasShipper,jdbcType=NVARCHAR},
  230. overseasAddress = #{overseasAddress,jdbcType=NVARCHAR},
  231. salesArea = #{salesArea,jdbcType=NVARCHAR},
  232. cnative = #{cnative,jdbcType=NVARCHAR}
  233. where site = #{site} and delNo = #{delNo}
  234. </update>
  235. <delete id="deleteEcssDelHeader">
  236. delete from ecss_CoDelNotifyHeader where site=#{site} and delNo=#{delNo}
  237. </delete>
  238. <update id="updateEcssDelHeaderForBaoGuan" >
  239. update ecss_CoDelNotifyHeader set declaration_no=#{declarationNo} ,notify_status=#{status} where site=#{site} and delNo=#{delNo}
  240. </update>
  241. <update id="updateEcssDelHeaderForModify" >
  242. update ecss_CoDelNotifyHeader
  243. set modifyFlag=#{modifyFlag},
  244. modify_count = CASE
  245. WHEN #{modifyFlag} = 1 THEN ISNULL(modify_count, 0) + 1
  246. ELSE 0
  247. END
  248. where site=#{site} and delNo=#{delNo}
  249. </update>
  250. <update id="updateEcssDelDetailForModify" >
  251. update ecss_CoDelNotifyDetail set modifyFlag=#{modifyFlag},modifyQtyFlag=#{modifyFlag},surplus_qty=0 where site=#{site} and delNo=#{delNo}
  252. </update>
  253. <update id="updateEcssDelDetailSurplusQty" >
  254. update ecss_CoDelNotifyDetail set surplus_qty=0 where site=#{site} and delNo=#{delNo}
  255. </update>
  256. <update id="restoreEcssDelDetailSurplusQty" >
  257. update ecss_CoDelNotifyDetail set surplus_qty=qty
  258. where site=#{site} and delNo=#{delNo} and status != '取消发货'
  259. </update>
  260. <update id="changeEcssDelStatus">
  261. update ecss_CoDelNotifyHeader set notify_status=#{notifyStatus},walMartOrderFlag=#{walMartOrderFlag},
  262. fscFlag=#{fscFlag},boxSizeFlag=#{boxSizeFlag} where site=#{site} and delNo=#{delNo}
  263. </update>
  264. <update id="updateEcssDelDetailStatus">
  265. update ecss_CoDelNotifyDetail
  266. set status=#{notifyStatus}
  267. where site=#{site} and delNo=#{delNo}
  268. </update>
  269. <update id="recoverEcssDelDetailStatus">
  270. update ecss_CoDelNotifyDetail
  271. set status='正常'
  272. where site=#{site} and delNo=#{delNo}
  273. </update>
  274. <select id="getEcssDelDetailItemNo" resultType="int">
  275. select isnull(max(item_no),0)+1 as itemNo from ecss_CoDelNotifyDetail
  276. where site =#{site} and bu_no=#{buNo} and delNo=#{delNo}
  277. </select>
  278. <insert id="insertEcssDelDetail" >
  279. insert into ecss_CoDelNotifyDetail(site,bu_no,delNo,item_no,salesOrder,salesOrder_item_no,customerPO,line,version,
  280. status,family,part_no,part_description,qty,lt,cmc_comment,saleType,
  281. awb_bl,shipping_number,forwarder_info,currency,tp,ttl_amount,sum_price,
  282. so,upc,remark,pn,modifyFlag,modifyQtyFlag,surplus_qty,vat,roll,carton)
  283. values(#{site},#{buNo},#{delNo},#{itemNo,jdbcType=INTEGER},#{salesOrder},#{salesOrderItemNo},#{customerPO},#{line},#{version},
  284. #{status},#{family},#{partNo},#{partDescription},#{qty,jdbcType=DECIMAL},#{lt,jdbcType=DECIMAL},#{cmcComment},#{saleType},
  285. #{awbBl},#{shippingNumber},#{forwarderInfo},#{currency},#{tp,jdbcType=DECIMAL},#{ttlAmount,jdbcType=DECIMAL},#{sumPrice,jdbcType=DECIMAL},
  286. #{so},#{upc},#{remark},#{pn},#{modifyFlag},#{modifyQtyFlag},#{qty},#{vat},#{roll},#{carton})
  287. </insert>
  288. <update id="updateEcssDelDetail">
  289. update ecss_CoDelNotifyDetail
  290. set salesOrder=#{salesOrder},customerPO=#{customerPO},line=#{line},version=#{version},
  291. status=#{status},family=#{family},part_no=#{partNo},part_description=#{partDescription},qty=#{qty,jdbcType=DECIMAL},
  292. lt=#{lt,jdbcType=DECIMAL},cmc_comment=#{cmcComment},saleType=#{saleType},pn=#{pn},
  293. awb_bl=#{awbBl},shipping_number=#{shippingNumber},forwarder_info=#{forwarderInfo},currency=#{currency},
  294. tp=#{tp,jdbcType=DECIMAL},ttl_amount=#{ttlAmount,jdbcType=DECIMAL},sum_price=#{sumPrice,jdbcType=DECIMAL},
  295. so=#{so},upc=#{upc},remark=#{remark},modifyFlag=#{modifyFlag},modifyQtyFlag=#{modifyQtyFlag},surplus_qty=#{qty,jdbcType=DECIMAL},vat=#{vat},roll=#{roll},carton=#{carton}
  296. where
  297. site=#{site} and delNo=#{delNo} and item_no=#{itemNo}
  298. </update>
  299. <delete id="deleteEcssDelDetail">
  300. delete from ecss_CoDelNotifyDetail where site=#{site} and delNo=#{delNo} and item_no=#{itemNo}
  301. </delete>
  302. <delete id="deleteAllEcssDelDetail">
  303. delete from ecss_CoDelNotifyDetail where site=#{site} and delNo=#{delNo}
  304. </delete>
  305. <update id="fixTtlAmount">
  306. update ecss_CoDelNotifyDetail
  307. set ttl_amount = sum_price
  308. where site=#{site} and delNo=#{delNo} and sum_price is not null
  309. </update>
  310. <update id="confirmEcssDel">
  311. update ecss_CoDelNotifyHeader set notify_status=#{notifyStatus} ,actualNotifyDate=#{actualNotifyDate,jdbcType=TIMESTAMP} where site=#{site} and delNo=#{delNo}
  312. </update>
  313. <update id="updateEcssDel">
  314. update ecss_CoDelNotifyHeader set ready_date=#{readyDate,jdbcType=TIMESTAMP},actualNotifyDate=#{actualNotifyDate,jdbcType=TIMESTAMP},
  315. modifyFlag=1,export_flag='N',updateBy=#{updateBy},updateDate=GetDate()
  316. where site=#{site} and delNo=#{delNo}
  317. </update>
  318. <select id="searchHsCodeData" resultType="EcssHsCodeData">
  319. select a.Site,a.BuNo,a.HsCode,a.Remark,a.CreateBy,a.CreateDate,a.UpdateBy,a.UpdateDate,a.codeNo
  320. ,dbo.get_bu_desc(a.site,a.BuNo) as BuDesc,a.hsCodeDesc,a.hsCodeDescEn,a.unit,a.brand
  321. from ecss_hsCode a
  322. left join accessBu D on A.site=D.site and A.BuNo=d.bu_no and D.username=#{query.username}
  323. <where>
  324. and D.site is not null
  325. <if test="query.buNo != null and query.buNo != ''">
  326. AND a.BuNo = #{query.buNo}
  327. </if>
  328. <if test="query.hsCode != null and query.hsCode != ''">
  329. AND a.HsCode like #{query.hsCode}
  330. </if>
  331. <if test="query.hsCodeDesc != null and query.hsCodeDesc != ''">
  332. AND a.HsCodeDesc like #{query.hsCodeDesc}
  333. </if>
  334. <if test="query.brand != null and query.brand != ''">
  335. AND ISNULL(a.brand,'无') = ISNULL(#{query.brand},'无')
  336. </if>
  337. </where>
  338. order by a.CreateDate ,a.HsCode
  339. </select>
  340. <select id="checkHsCodeDescData" resultType="EcssHsCodeData">
  341. select a.Site,a.BuNo,a.HsCode,a.hsCodeDesc,a.brand
  342. from ecss_hsCode a where a.site=#{site} and a.buNo=#{buNo} and a.HsCodeDesc=#{hsCodeDesc}
  343. <choose>
  344. <when test="oldBrand != null and oldBrand != ''">
  345. AND ISNULL(a.brand,'无') = ISNULL(#{oldBrand},'无')
  346. </when>
  347. <otherwise>
  348. AND ISNULL(a.brand,'无') = ISNULL(#{brand},'无')
  349. </otherwise>
  350. </choose>
  351. </select>
  352. <select id="checkPropertiesModel" resultType="com.xujie.sys.modules.attrbute.entity.PropertyModelHeader">
  353. select site,bu_no,function_type ,code_no from plm_properties_model_header
  354. where site=#{site} and bu_no=#{buNo} and function_type=#{functionType} and code_no=#{codeNo}
  355. </select>
  356. <insert id="insertHsCodeData" >
  357. insert into ecss_hsCode (Site,BuNo,HsCode,Remark,CreateBy,CreateDate,codeNo,hsCodeDesc,hsCodeDescEn,unit,brand)
  358. values(#{site},#{buNo},#{hsCode},#{remark},#{createBy},GetDate(),#{codeNo},#{hsCodeDesc},#{hsCodeDescEn},#{unit},#{brand})
  359. </insert>
  360. <update id="updateHsCodeData">
  361. update ecss_hsCode set Remark=#{remark} ,codeNo=#{codeNo},HsCode=#{hsCode},unit=#{unit} ,brand=#{brand},UpdateDate=GetDate(),UpdateBy=#{updateBy},hsCodeDescEn=#{hsCodeDescEn}
  362. where site=#{site} and buNo=#{buNo} and hsCodeDesc=#{hsCodeDesc}
  363. <choose>
  364. <when test="oldBrand != null and oldBrand != ''">
  365. and ISNULL(brand,'无') = ISNULL(#{oldBrand},'无')
  366. </when>
  367. <otherwise>
  368. and ISNULL(brand,'无') = ISNULL(#{brand},'无')
  369. </otherwise>
  370. </choose>
  371. </update>
  372. <select id="deleteHsCode" >
  373. delete from ecss_hsCode where site=#{site} and buNo=#{buNo} and hsCodeDesc=#{hsCodeDesc} and ISNULL(brand,'无') = ISNULL(#{brand},'无')
  374. </select>
  375. <select id="searchPropertiesItemList" resultType="com.xujie.sys.modules.attrbute.entity.PropertyItem">
  376. select
  377. id,site,bu_no,item_no,item_type,item_desc,default_value,value_type,value_type_db,value_choose_flag,min_value,max_value,
  378. create_by,create_date,update_by,update_date
  379. from dbo.plm_properties_item
  380. <where>
  381. and site = #{site} and bu_no=#{buNo}
  382. <if test="itemNo != null and itemNo != ''">
  383. and item_no like #{itemNo}
  384. </if>
  385. <if test="itemDesc != null and itemDesc != ''">
  386. and item_desc like #{itemDesc}
  387. </if>
  388. <if test="itemType != null and itemType != ''">
  389. and item_type = #{itemType}
  390. </if>
  391. order by item_type ,item_no
  392. </where>
  393. </select>
  394. <select id="getPropertiesListByPartAndCodeNo" resultType="com.xujie.sys.modules.part.entity.PartSubPropertiesValueData">
  395. SELECT a.part_no
  396. , a.Site
  397. , a.code_no
  398. , a.brand
  399. , a.sub_code_seq_no
  400. , a.sub_code_desc
  401. ,a.bu_no
  402. ,a.item_no
  403. , a.properties_item_no
  404. , a.text_value
  405. , a.num_value
  406. , a.record_type
  407. , b.item_desc ItemDesc
  408. , b.value_type
  409. , b.value_type_db
  410. , b.value_choose_flag
  411. FROM part_sub_properties_value a
  412. left join plm_properties_item b
  413. 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
  414. <where>
  415. AND a.site = #{site}
  416. and a.record_type = #{recordType}
  417. and a.bu_no=#{buNo}
  418. and a.code_no = #{codeNo}
  419. AND a.part_no = #{partNo,jdbcType=VARCHAR}
  420. <if test="brand != null and brand != ''">
  421. AND ISNULL(a.brand,'无') = ISNULL(#{brand},'无')
  422. </if>
  423. </where>
  424. order by a.item_no
  425. </select>
  426. <update id="updatePropertiesList">
  427. update part_sub_properties_value
  428. set text_value=#{textValue},
  429. num_value=#{numValue,jdbcType=DOUBLE}
  430. where Site = #{site}
  431. and code_no = #{codeNo}
  432. and part_no = #{partNo}
  433. and sub_code_seq_no = #{subCodeSeqNo}
  434. and item_no = #{itemNo}
  435. and bu_no=#{buNo}
  436. <if test="brand != null and brand != ''">
  437. and ISNULL(brand,'无') = ISNULL(#{brand},'无')
  438. </if>
  439. </update>
  440. <insert id="saveSubPropertiesValueForAlone">
  441. insert into part_sub_properties_value ( part_no, site, bu_no, code_no, brand, sub_code_seq_no, sub_code_desc,
  442. item_no, properties_item_no, text_value, num_value, record_type)
  443. select
  444. #{partNo},
  445. #{site},
  446. #{buNo},
  447. #{codeNo},
  448. #{brand,jdbcType=NVARCHAR},
  449. 1,
  450. d.code_desc,
  451. #{itemNo,jdbcType=DOUBLE},
  452. c.item_no,
  453. case when c.value_type_db = 'T' then c.default_value else null end,
  454. case when c.value_type_db = 'N' and c.default_value != '' then c.default_value else null end,
  455. #{recordType}
  456. from plm_properties_item c
  457. left join plm_properties_model_header d on c.site=d.site and d.code_no=#{codeNo} and d.function_type=c.item_Type
  458. where c.Item_No = #{propertiesItemNo}
  459. and c.site = #{site}
  460. and c.bu_no=#{buNo}
  461. and c.item_Type = #{recordType}
  462. </insert>
  463. <delete id="deleteSubPropertiesValueForAlone">
  464. delete
  465. from part_sub_properties_value
  466. where site = #{site}
  467. and record_type = #{recordType}
  468. and bu_no=#{buNo}
  469. and code_no = #{codeNo}
  470. AND part_no = #{partNo,jdbcType=VARCHAR}
  471. <if test="brand != null and brand != ''">
  472. AND ISNULL(brand,'无') = ISNULL(#{brand},'无')
  473. </if>
  474. and properties_item_no = #{propertiesItemNo}
  475. </delete>
  476. <select id="getNewSeqNoForAlone" resultType="Double">
  477. select isnull(Max(item_No) + 1, 1)
  478. from part_sub_properties_value a
  479. where a.site = #{site}
  480. and a.record_type = #{recordType}
  481. and a.bu_no=#{buNo}
  482. and a.code_no = #{codeNo}
  483. AND a.part_no = #{partNo,jdbcType=VARCHAR}
  484. <if test="brand != null and brand != ''">
  485. AND ISNULL(a.brand,'无') = ISNULL(#{brand},'无')
  486. </if>
  487. </select>
  488. <select id="searchPropertiesUnChoose" resultType="com.xujie.sys.modules.ecss.entity.PropertyItemData">
  489. SELECT
  490. 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,
  491. b.min_value,b.max_value,b.create_by,b.create_date,b.update_by,b.update_date
  492. FROM plm_properties_item b
  493. where b.item_type = #{codeType}
  494. and b.site = #{site} and b.bu_no=#{buNo}
  495. <if test="list != null and list.size() != 0">
  496. and b.item_no not in (
  497. <foreach collection="list" item="item" separator=",">
  498. #{item}
  499. </foreach>
  500. )
  501. </if>
  502. </select>
  503. <insert id="saveCodelPalletHeader">
  504. 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,
  505. create_date,pallet)
  506. values(#{site},#{buNo},#{delNo},#{seqNo},#{palletNo},#{palletQty},#{length},#{width},#{height},#{volume},#{grossWeight,jdbcType=DECIMAL},#{netWeight,jdbcType=DECIMAL},#{palletRemark},#{createBy},
  507. GETDATE(),#{pallet})
  508. </insert>
  509. <insert id="saveCodelBoxList">
  510. insert into ecss_CoDelBoxList(site,bu_no,delNo,seq_no,item_no,gross_weight,net_weight,box_qty,rolls,volume,create_by,create_date)
  511. values (#{site},#{buNo},#{delNo},#{seqNo},#{itemNo},#{grossWeight,jdbcType=DECIMAL},#{netWeight,jdbcType=DECIMAL},#{boxQty},#{rolls,jdbcType=DECIMAL},#{volume,jdbcType=DECIMAL},#{createBy},GETDATE())
  512. </insert>
  513. <insert id="saveCodelPalletDetail">
  514. 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)
  515. values (#{site},#{buNo},#{delNo},#{seqNo},#{itemNo},#{partNo},#{qty,jdbcType=DECIMAL},#{poNo},#{boxQty},#{createBy},GETDATE(),#{rolls,jdbcType=DECIMAL},#{pn},#{notifyDetailItemNo})
  516. </insert>
  517. <select id="searchEcssCoDelPalletHeaderData" resultType="EcssCoDelPalletHeaderData">
  518. 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,
  519. a.create_date,a.update_by,a.update_date,a.pallet,CONVERT(DECIMAL(20, 3),(isnull(p.pallet_weight,0)*a.pallet_qty)) as weight
  520. from ecss_CoDelPalletHeader a
  521. LEFT JOIN ecss_pallet p on a.pallet=p.pallet_no and a.site=p.Site and a.bu_no=p.BuNo
  522. where a.site =#{site} and a.bu_no=#{buNo} and a.delNo=#{delNo}
  523. </select>
  524. <select id="searchEcssCoDelPalletDetailData" resultType="EcssCoDelPalletDetailData">
  525. 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
  526. from ecss_CoDelPalletDetail
  527. where site =#{site} and bu_no=#{buNo} and delNo=#{delNo}
  528. <if test="seqNo != null and seqNo != ''">
  529. and seq_no=#{seqNo}
  530. </if>
  531. </select>
  532. <select id="getCoDelPalletHeaderSeqNo" resultType="int">
  533. select isnull(max(seq_no),0)+1 as seqNo from ecss_CoDelPalletHeader
  534. where site =#{site} and bu_no=#{buNo} and delNo=#{delNo}
  535. </select>
  536. <select id="getCoDelBoxListItemNo" resultType="int">
  537. select isnull(max(item_no),0)+1 as seqNo from ecss_CoDelBoxList
  538. where site =#{site} and bu_no=#{buNo} and delNo=#{delNo}
  539. </select>
  540. <select id="getCoDelPalletDetailItem" resultType="int">
  541. select isnull(max(item_no),0)+1 as item_no from ecss_CoDelPalletDetail
  542. where site =#{site} and bu_no=#{buNo} and delNo=#{delNo} and seq_no=#{seqNo}
  543. </select>
  544. <update id="updateCodelPalletHeader">
  545. update ecss_CoDelPalletHeader set pallet_qty=#{palletQty,jdbcType=INTEGER},[length]=#{length,jdbcType=DECIMAL},width=#{width,jdbcType=DECIMAL},height=#{height,jdbcType=DECIMAL},
  546. volume=#{volume,jdbcType=DECIMAL},gross_weight=#{grossWeight,jdbcType=DECIMAL},net_weight=#{netWeight,jdbcType=DECIMAL},pallet_remark=#{palletRemark},
  547. update_by=#{updateBy},update_date=GetDate(),pallet=#{pallet}
  548. where site =#{site} and bu_no=#{buNo} and delNo=#{delNo} and seq_no=#{seqNo}
  549. </update>
  550. <update id="updateCodelPalletHeader2">
  551. update ecss_CoDelPalletHeader set gross_weight=#{grossWeight,jdbcType=DECIMAL},net_weight=#{netWeight,jdbcType=DECIMAL},
  552. update_by=#{updateBy},update_date=GetDate()
  553. where site =#{site} and bu_no=#{buNo} and delNo=#{delNo} and seq_no=#{seqNo}
  554. </update>
  555. <update id="updateCodelPalletHeaderPalletQty">
  556. update ecss_CoDelPalletHeader set pallet_qty=#{palletQty,jdbcType=INTEGER},height=#{height,jdbcType=DECIMAL},
  557. update_by=#{updateBy},update_date=GetDate()
  558. where site =#{site} and bu_no=#{buNo} and delNo=#{delNo} and seq_no=#{seqNo}
  559. </update>
  560. <update id="updateCodelPalletDetail">
  561. update ecss_CoDelPalletDetail set part_no=#{partNo},qty=#{qty,jdbcType=DECIMAL},po_no=#{poNo},
  562. box_qty=#{boxQty,jdbcType=DECIMAL},update_by=#{updateBy},update_date=GetDate(),rolls=#{rolls},pn=#{pn}
  563. where site =#{site} and bu_no=#{buNo} and delNo=#{delNo} and seq_no=#{seqNo} and item_no=#{itemNo}
  564. </update>
  565. <delete id="deletePalletHeader">
  566. delete from ecss_CoDelPalletHeader where site =#{site} and bu_no=#{buNo} and delNo=#{delNo}
  567. <if test="seqNo != null and seqNo != ''">
  568. and seq_no=#{seqNo}
  569. </if>
  570. </delete>
  571. <delete id="deleteBoxList">
  572. delete from ecss_CoDelBoxList where site =#{site} and bu_no=#{buNo} and delNo=#{delNo}
  573. <if test="seqNo != null and seqNo != ''">
  574. and seq_no=#{seqNo}
  575. </if>
  576. </delete>
  577. <delete id="deletePalletDetail">
  578. delete from ecss_CoDelPalletDetail where site =#{site} and bu_no=#{buNo} and delNo=#{delNo}
  579. <if test="seqNo != null and seqNo != ''">
  580. and seq_no=#{seqNo}
  581. </if>
  582. <if test="itemNo != null and itemNo != ''">
  583. and item_no=#{itemNo}
  584. </if>
  585. </delete>
  586. <select id="getAllWeight" resultType="com.xujie.sys.modules.ecss.entity.EcssCoDelPalletHeader">
  587. select sum(gross_weight) as gross_weight ,sum(net_weight) as net_weight from ecss_CoDelBoxList
  588. where site =#{site} and delNo=#{delNo} and bu_no=#{buNo}
  589. </select>
  590. <select id="getDefaultEcssDeclarationDetailData" resultType="EcssDeclarationDetailData">
  591. -- 修复净重计算问题:按数量比例分配箱子净重,避免重复计算
  592. -- 一个箱子(BoxList)可能包含多个零件(PalletDetail),这些零件可能有相同的hsCode
  593. -- 需要按每个零件的数量占该箱子总数量的比例来分配净重
  594. WITH BoxDetail AS (
  595. -- 计算每个箱子中每个零件的数量及其占比
  596. SELECT
  597. d.site,
  598. d.bu_no,
  599. d.delNo,
  600. d.seq_no,
  601. p.hsCode,
  602. p.hsCodeDesc,
  603. p.brand,
  604. d.qty,
  605. b.net_weight,
  606. -- 计算该零件数量占该箱子总数量的比例
  607. CASE
  608. WHEN SUM(d.qty) OVER (PARTITION BY d.site, d.bu_no, d.delNo, d.seq_no) > 0
  609. THEN d.qty * 1.0 / SUM(d.qty) OVER (PARTITION BY d.site, d.bu_no, d.delNo, d.seq_no)
  610. ELSE 0
  611. END as qtyRatio
  612. FROM ecss_CoDelPalletDetail d
  613. LEFT JOIN part p ON d.site=p.site AND d.part_no=p.part_no
  614. 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
  615. WHERE d.site=#{site} AND d.delNo=#{delNo} AND d.bu_no=#{buNo}
  616. )
  617. SELECT
  618. #{site} as site,
  619. hsCode,
  620. hsCodeDesc,
  621. brand,
  622. SUM(qty) as qty,
  623. -- 按数量比例分配净重后汇总
  624. CONVERT(DECIMAL(20,2), SUM(ISNULL(net_weight, 0) * qtyRatio)) as NetWeight,
  625. 'CNY' as currency,
  626. '中国' as madeArea,
  627. #{destination} as destination,
  628. '南通其他' as sourceArea,
  629. '照章征免' as levy
  630. FROM BoxDetail
  631. GROUP BY hsCode, hsCodeDesc, brand
  632. </select>
  633. <select id="getDefaultEcssDeclarationDetailData2" resultType="EcssDeclarationDetailData">
  634. select #{site} as site, b.hsCode,b.hsCodeDesc as hsCodeDesc,b.brand as brand,sum( a.qty) as qty ,sum(a.ttl_amount) as totalPrice,
  635. CONVERT(DECIMAL(20, 6),sum(a.ttl_amount)/sum( a.qty)) as unitPrice,
  636. LEFT(a.currency, 3) AS currency,'中国' as madeArea,#{destination} as destination,'南通其他' as sourceArea ,'照章征免' as levy from
  637. ecss_CoDelNotifyDetail a left join part b on a.site=b.site and a.part_no=b.part_no
  638. where a.site =#{site} and a.delNo=#{delNo} and a.qty>0 and a.bu_no=#{buNo}
  639. GROUP BY b.hsCodeDesc,b.hsCode,b.brand,LEFT(a.currency,3)
  640. </select>
  641. <select id="getDefaultEcssDeclarationDetailDataTX" resultType="EcssDeclarationDetailData">
  642. -- 修复净重计算问题:按数量比例分配箱子净重,避免重复计算
  643. -- 一个箱子(BoxList)可能包含多个零件(PalletDetail),这些零件可能有相同的hsCode
  644. -- 需要按每个零件的数量占该箱子总数量的比例来分配净重
  645. WITH BoxDetail AS (
  646. -- 计算每个箱子中每个零件的数量及其占比
  647. SELECT
  648. d.site,
  649. d.bu_no,
  650. d.delNo,
  651. d.seq_no,
  652. p.hsCode,
  653. p.hsCodeDesc,
  654. p.brand,
  655. p.ecss_umid as unit,
  656. d.qty,
  657. b.net_weight,
  658. -- 计算该零件数量占该箱子总数量的比例
  659. CASE
  660. WHEN SUM(d.qty) OVER (PARTITION BY d.site, d.bu_no, d.delNo, d.seq_no) > 0
  661. THEN d.qty * 1.0 / SUM(d.qty) OVER (PARTITION BY d.site, d.bu_no, d.delNo, d.seq_no)
  662. ELSE 0
  663. END as qtyRatio
  664. FROM ecss_CoDelPalletDetail d
  665. LEFT JOIN part p ON d.site=p.site AND d.part_no=p.part_no
  666. 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
  667. WHERE d.site=#{site} AND d.delNo=#{delNo} AND d.bu_no=#{buNo}
  668. )
  669. SELECT
  670. #{site} as site,
  671. hsCode,
  672. hsCodeDesc,
  673. brand,
  674. unit,
  675. SUM(qty) as qty,
  676. -- 按数量比例分配净重后汇总
  677. CONVERT(DECIMAL(20,2), SUM(ISNULL(net_weight, 0) * qtyRatio)) as NetWeight,
  678. 'CNY' as currency,
  679. '中国' as madeArea,
  680. #{destination} as destination,
  681. '南通其他' as sourceArea,
  682. '照章征免' as levy
  683. FROM BoxDetail
  684. GROUP BY hsCode, hsCodeDesc, brand,unit
  685. </select>
  686. <select id="getDefaultEcssDeclarationDetailData2TX" resultType="EcssDeclarationDetailData">
  687. select #{site} as site, b.hsCode,b.hsCodeDesc as hsCodeDesc,b.brand as brand,sum( a.qty) as qty ,sum(a.ttl_amount) as totalPrice,
  688. CONVERT(DECIMAL(20, 6),sum(a.ttl_amount)/sum( a.qty)) as unitPrice,b.ecss_umid as unit,
  689. LEFT(a.currency, 3) AS currency,'中国' as madeArea,#{destination} as destination,'南通其他' as sourceArea ,'照章征免' as levy from
  690. ecss_CoDelNotifyDetail a left join part b on a.site=b.site and a.part_no=b.part_no
  691. where a.site =#{site} and a.delNo=#{delNo} and a.qty>0 and a.bu_no=#{buNo}
  692. GROUP BY b.hsCodeDesc,b.hsCode,b.brand,b.ecss_umid,LEFT(a.currency,3)
  693. </select>
  694. <insert id="saveEcssDeclarationHeader">
  695. insert into ecss_declaration_header (site,declaration_no,customs_office_code,input_code,local_shipper,local_ship_address,ship_type,ship_date,submit_date,
  696. filing_no,overseas_shipper,shipping_mode,shipping_data,deliver_no,sales_partner,regulatory_method,duty_status,
  697. permit_number,cmc_invoice,sales_area,receive_area,shipping_port,exit_port,documents,remark,package_type,package_qty,
  698. gross_weight,net_weight,payment_type,ship_price,premium,other_price,special_relationship_comfirm,price_influence_confirm,
  699. royalty_payments_confirm,create_by,create_date,delNo,overseas_address,box_qty)
  700. values(#{site},#{declarationNo},#{customsOfficeCode},#{inputCode},#{localShipper,jdbcType=NVARCHAR},#{localShipAddress,jdbcType=NVARCHAR},#{shipType},#{shipDate},#{submitDate},
  701. #{filingNo},#{overseasShipper,jdbcType=NVARCHAR},#{shippingMode,jdbcType=NVARCHAR},#{shippingData},#{deliverNo},#{salesPartner,jdbcType=NVARCHAR},#{regulatoryMethod,jdbcType=NVARCHAR},#{dutyStatus,jdbcType=NVARCHAR},
  702. #{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},
  703. #{grossWeight,jdbcType=DECIMAL},#{netWeight,jdbcType=DECIMAL},#{paymentType,jdbcType=NVARCHAR},#{shipPrice,jdbcType=DECIMAL},#{premium,jdbcType=DECIMAL},#{otherPrice,jdbcType=DECIMAL},#{specialRelationshipComfirm,jdbcType=NVARCHAR},#{priceInfluenceConfirm,jdbcType=NVARCHAR},
  704. #{royaltyPaymentsConfirm,jdbcType=NVARCHAR},#{createBy},GETDATE(),#{delNo},#{overseasAddress,jdbcType=NVARCHAR},#{boxQty})
  705. </insert>
  706. <insert id="saveEcssDeclarationDetail">
  707. insert into ecss_declaration_detail(site,declaration_no,item_no,hs_code,hs_code_desc,brand,qty,net_weight,unit_price,total_price,currency,made_area,destination,
  708. source_area,levy,unit)
  709. values(#{site},#{declarationNo},#{itemNo,jdbcType=INTEGER},#{hsCode},#{hsCodeDesc},#{brand,jdbcType=NVARCHAR},#{qty,jdbcType=DECIMAL},#{netWeight,jdbcType=DECIMAL},#{unitPrice,jdbcType=DECIMAL},#{totalPrice,jdbcType=DECIMAL},#{currency},#{madeArea},#{destination},
  710. #{sourceArea},#{levy},#{unit})
  711. </insert>
  712. <select id="searchDeclarationHeader" resultType="EcssDeclarationHeaderData">
  713. select a.site,a.declaration_no,a.customs_office_code,a.input_code,a.local_shipper,a.local_ship_address,a.ship_type,
  714. a.ship_date,a.submit_date,a.filing_no,a.overseas_shipper,a.shipping_mode,a.shipping_data,a.deliver_no,a.sales_partner,
  715. a.regulatory_method,a.duty_status,a.permit_number,a.cmc_invoice,a.sales_area,a.receive_area,a.shipping_port,
  716. 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,
  717. a.premium,a.other_price,a.special_relationship_comfirm,a.price_influence_confirm,a.royalty_payments_confirm,
  718. a.create_by,a.create_date,a.update_by,a.update_date,a.delNo,noHeader.bu_no,
  719. a.upc,a.so,a.origin,a.pallet_weight,a.material,a.hs_code,a.packaging,a.kgs,a.shipping_mark,
  720. a.hsCodeDesc,a.contractFlag,a.hsCodeDescType,a.goodsLabel,a.boxChange,noHeader.customer_name as customName,
  721. noHeader.destination
  722. from ecss_declaration_header a
  723. left join ecss_CoDelNotifyHeader noHeader on a.site=noHeader.site and a.delNo=noHeader.delNo
  724. left join accessBu D on noHeader.site=D.site and noHeader.bu_no=d.bu_no and D.username=#{query.username}
  725. <where>
  726. and D.site is not null
  727. <if test="query.delNo != null and query.delNo != ''">
  728. AND a.delNo like #{query.delNo}
  729. </if>
  730. <if test="query.declarationNo != null and query.declarationNo != ''">
  731. AND a.declaration_no like #{query.declarationNo}
  732. </if>
  733. <if test="query.cmcInvoice != null and query.cmcInvoice != ''">
  734. AND a.cmc_invoice like #{query.cmcInvoice}
  735. </if>
  736. <if test="query.site != null and query.site != ''">
  737. AND a.site like #{query.site}
  738. </if>
  739. <if test = "query.startDate!= null">
  740. AND a.ship_date>= #{query.startDate}
  741. </if>
  742. <if test = "query.endDate!= null">
  743. AND #{query.endDate} >=a.ship_date
  744. </if>
  745. </where>
  746. order by a.create_date desc
  747. </select>
  748. <select id="searchDeclarationDetail" resultType="EcssDeclarationDetailData">
  749. select site,declaration_no,item_no,hs_code,hs_code_desc,brand,qty,net_weight,unit_price,total_price,currency,made_area,destination,
  750. source_area,levy,brand
  751. from ecss_declaration_detail
  752. where site=#{site} and declaration_no=#{declarationNo}
  753. </select>
  754. <delete id="deleteDeclarationHeader">
  755. delete from ecss_declaration_header where site=#{site} and declaration_no=#{declarationNo}
  756. </delete>
  757. <delete id="deleteDeclarationDetail">
  758. delete from ecss_declaration_detail where site=#{site} and declaration_no=#{declarationNo}
  759. </delete>
  760. <select id="searchPalletData" resultType="EcssPalletData">
  761. select a.id,a.Site,a.BuNo,a.pallet_type as palletType,a.Remark,a.CreateBy,a.CreateDate,a.UpdateBy,a.UpdateDate,
  762. a.length, a.width, a.height, a.application_area as applicationArea, a.pallet_weight as palletWeight
  763. ,dbo.get_bu_desc(a.site,a.BuNo) as BuDesc,a.pallet_no as palletNo
  764. from ecss_pallet a
  765. left join accessBu D on A.site=D.site and A.BuNo=d.bu_no and D.username=#{query.username}
  766. <where>
  767. and D.site is not null
  768. <if test="query.buNo != null and query.buNo != ''">
  769. AND a.BuNo = #{query.buNo}
  770. </if>
  771. <if test="query.palletType != null and query.palletType != ''">
  772. AND a.pallet_type = #{query.palletType}
  773. </if>
  774. </where>
  775. order by a.CreateDate
  776. </select>
  777. <insert id="insertPalletData" >
  778. insert into ecss_pallet (Site,BuNo,pallet_type,Remark,CreateBy,CreateDate,length,width,
  779. height,application_area,pallet_weight,pallet_no)
  780. values(#{site},#{buNo},#{palletType},#{remark},#{createBy},GetDate(),#{length},#{width},
  781. #{height},#{applicationArea},#{palletWeight},#{palletNo})
  782. </insert>
  783. <update id="updatePalletData">
  784. update ecss_pallet set Remark=#{remark} ,pallet_type=#{palletType} ,
  785. length=#{length} ,width=#{width} ,
  786. height=#{height} ,application_area=#{applicationArea} ,
  787. pallet_weight=#{palletWeight} ,pallet_no=#{palletNo},
  788. UpdateDate=GetDate(),UpdateBy=#{updateBy}
  789. where site=#{site} and buNo=#{buNo} and id=#{id}
  790. </update>
  791. <select id="deletePallet" >
  792. delete from ecss_pallet where site=#{site} and buNo=#{buNo} and id=#{id}
  793. </select>
  794. <select id="getPallet" resultType="EcssPalletData">
  795. select * from ecss_pallet where site=#{site} and buNo=#{buNo} and pallet_no=#{palletNo}
  796. </select>
  797. <select id="getPackage" resultType="EcssPackageData">
  798. select * from ecss_package where site=#{site} and buNo=#{buNo} and package_no=#{packageNo}
  799. </select>
  800. <insert id="insertPackageData" >
  801. insert into ecss_package (Site,BuNo,package_type,Remark,CreateBy,CreateDate,length,width,
  802. height,volume,weight,package_no)
  803. values(#{site},#{buNo},#{packageType},#{remark},#{createBy},GetDate(),#{length},#{width},
  804. #{height},#{volume},#{weight},#{packageNo})
  805. </insert>
  806. <update id="updatePackageData">
  807. update ecss_package set Remark=#{remark} ,package_type=#{packageType} ,
  808. length=#{length} ,width=#{width} ,volume=#{volume},weight=#{weight},
  809. package_no=#{packageNo},height=#{height} ,
  810. UpdateDate=GetDate(),UpdateBy=#{updateBy}
  811. where site=#{site} and buNo=#{buNo} and id=#{id}
  812. </update>
  813. <select id="deleteEcssPackage" >
  814. delete from ecss_package where site=#{site} and buNo=#{buNo} and id=#{id}
  815. </select>
  816. <select id="searchPackageData" resultType="EcssPackageData">
  817. select a.id,a.Site,a.BuNo,a.package_type as packageType,a.Remark,a.CreateBy,a.CreateDate,a.UpdateBy,a.UpdateDate,
  818. a.length, a.width, a.height, a.volume, a.weight,a.package_no as packageNo
  819. ,dbo.get_bu_desc(a.site,a.BuNo) as BuDesc
  820. from ecss_package a
  821. left join accessBu D on A.site=D.site and A.BuNo=d.bu_no and D.username=#{query.username}
  822. <where>
  823. and D.site is not null
  824. <if test="query.buNo != null and query.buNo != ''">
  825. AND a.BuNo = #{query.buNo}
  826. </if>
  827. <if test="query.packageType != null and query.packageType != ''">
  828. AND a.package_type = #{query.packageType}
  829. </if>
  830. </where>
  831. order by a.CreateDate
  832. </select>
  833. <select id="searchHsCodeList" resultType="java.util.Map">
  834. select a.BuNo,a.HsCode,a.hsCodeDesc,a.unit,a.hsCodeDescEn,a.brand
  835. from ecss_hsCode a
  836. <where> a.BuNo = #{buNo}
  837. <if test="hsCode != null and hsCode != ''">
  838. AND a.HsCode like '%'+#{hsCode}+'%'
  839. </if>
  840. <if test="hsCodeDesc != null and hsCodeDesc != ''">
  841. AND a.hsCodeDesc like '%'+#{hsCodeDesc}+'%'
  842. </if>
  843. </where>
  844. order by a.CreateDate ,a.HsCode
  845. </select>
  846. <select id="searchPalletList" resultType="java.util.Map">
  847. select a.BuNo,a.id as palletId,a.pallet_type as palletType,a.pallet_no as palletNo,
  848. a.application_area as applicationArea ,a.length, a.width, a.height
  849. from ecss_pallet a
  850. <where> a.BuNo = #{buNo}
  851. <if test="palletType != null and palletType != ''">
  852. AND a.pallet_type like '%'+#{palletType}+'%'
  853. </if>
  854. </where>
  855. order by a.CreateDate
  856. </select>
  857. <select id="searchPackageList" resultType="java.util.Map">
  858. select a.BuNo,a.id as packageId,a.package_type as packageType,a.package_no as packageNo,
  859. a.length, a.width, a.height
  860. from ecss_package a
  861. <where> a.BuNo = #{buNo}
  862. <if test="packageType != null and packageType != ''">
  863. AND a.package_type like '%'+#{packageType}+'%'
  864. </if>
  865. </where>
  866. order by a.CreateDate
  867. </select>
  868. <select id="getDeclarationElements" resultType="java.util.Map">
  869. select part_no as partNo,bu_no as buNo
  870. from ecss_CoDelNotifyDetail
  871. where site=#{site} and delNo=#{delNo} and qty>0
  872. GROUP BY part_no,bu_no
  873. </select>
  874. <select id="getHsCodeByPartNo" resultType="java.util.Map">
  875. select p.hsCode, p.hsCodeDesc, p.brand, p.part_no ,h.codeNo,h.BuNo,p.sku,h.hsCodeDescEn
  876. from Part p
  877. left join ecss_hsCode h on p.hsCodeDesc=h.hsCodeDesc and p.site=h.site
  878. where p.site=#{site,jdbcType=VARCHAR} and p.part_no in
  879. <foreach item="item" index="index" collection="partNos" open="(" separator="," close=")">
  880. #{item}
  881. </foreach>
  882. </select>
  883. <select id="getDeclarationHeader" resultType="EcssDeclarationHeaderData">
  884. select * from ecss_declaration_header where site=#{site} and declaration_no=#{declarationNo}
  885. </select>
  886. <select id="getDeclarationHeaderByDelNo" resultType="EcssDeclarationHeaderData">
  887. select * from ecss_declaration_header where site=#{site} and delNo=#{delNo}
  888. </select>
  889. <select id="exportDeclarationDetail" resultType="java.util.Map">
  890. select detail.site,detail.declaration_no,detail.item_no,
  891. CONVERT(DECIMAL(20, 6), detail.qty) as qty,isnull(h.unit,'') as qty_unit,'kg' as weight_unit,
  892. CONVERT(DECIMAL(20, 2),detail.net_weight) as net_weight,CONVERT(DECIMAL(20, 6),detail.unit_price) as unit_price,
  893. CONVERT(DECIMAL(20, 2),detail.total_price) as total_price,detail.currency,detail.made_area,detail.destination,
  894. detail.source_area,detail.levy,detail.hs_code,detail.hs_code_desc,h.hsCodeDescEn
  895. from ecss_declaration_detail detail
  896. left join ecss_hsCode h on detail.hs_code=h.HsCode and detail.site=h.Site and detail.hs_code_desc=h.hsCodeDesc
  897. where detail.site=#{site} and declaration_no=#{declarationNo}
  898. </select>
  899. <select id="exportDeclarationDetailTX" resultType="java.util.Map">
  900. select detail.site,detail.declaration_no,detail.item_no,isnull(detail.unit,'') as ecss_umid,
  901. CONVERT(DECIMAL(20, 6), detail.qty) as qty,isnull(h.unit,'') as qty_unit,'kg' as weight_unit,
  902. CONVERT(DECIMAL(20, 2),detail.net_weight) as net_weight,CONVERT(DECIMAL(20, 6),detail.unit_price) as unit_price,
  903. CONVERT(DECIMAL(20, 2),detail.total_price) as total_price,detail.currency,detail.made_area,detail.destination,
  904. detail.source_area,detail.levy,detail.hs_code,detail.hs_code_desc,h.hsCodeDescEn
  905. from ecss_declaration_detail detail
  906. left join ecss_hsCode h on detail.hs_code=h.HsCode and detail.site=h.Site and detail.hs_code_desc=h.hsCodeDesc and detail.brand=h.brand
  907. where detail.site=#{site} and declaration_no=#{declarationNo}
  908. </select>
  909. <select id="getEcssCoDelNotifyHeader" resultType="EcssCoDelNotifyHeaderData">
  910. select * from ecss_CoDelNotifyHeader where site=#{site} and delNo=#{delNo}
  911. </select>
  912. <select id="exportEcssCoDelNotifyDetail" resultType="java.util.Map">
  913. select a.customerPO,a.part_no,a.part_description,LEFT(a.currency, 3) as currency,
  914. CONVERT(DECIMAL(20, 0), a.qty) as qty,CONVERT(DECIMAL(20, 6), a.tp) as unitPrice,b.hsCode,
  915. a.upc,a.so,a.ttl_amount,a.pn,b.hsCodeDesc,h.hsCodeDescEn,a.salesOrder,b.umid as unit,b.brand,h.unit as hsUnit,b.ecss_umid as ecssUmid
  916. from ecss_CoDelNotifydetail a
  917. left join part b on a.site=b.site and a.part_no=b.part_no
  918. left join ecss_hsCode h on b.hsCode=h.HsCode and a.site=h.site and b.hsCodeDesc=h.hsCodeDesc
  919. where a.site = #{site} AND a.delNo = #{delNo} and a.qty>0
  920. order by a.item_no
  921. </select>
  922. <select id="exportCoDelPalletDetail" resultType="java.util.Map">
  923. -- 修复净重毛重重复计算问题:按数量比例分配箱子重量
  924. WITH BoxDetail AS (
  925. SELECT
  926. b.part_no,
  927. b.qty,
  928. b.rolls,
  929. a.box_qty,
  930. a.net_weight,
  931. a.gross_weight,
  932. b.site,
  933. b.bu_no,
  934. b.delNo,
  935. b.seq_no,
  936. -- 计算该零件数量占该箱子总数量的比例
  937. CASE
  938. WHEN SUM(b.qty) OVER (PARTITION BY b.site, b.bu_no, b.delNo, b.seq_no) > 0
  939. THEN b.qty * 1.0 / SUM(b.qty) OVER (PARTITION BY b.site, b.bu_no, b.delNo, b.seq_no)
  940. ELSE 0
  941. END as qtyRatio
  942. FROM ecss_CoDelBoxList a
  943. 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
  944. WHERE a.site=#{site} AND a.bu_no=#{buNo} AND a.delNo=#{delNo} AND b.site IS NOT NULL
  945. )
  946. SELECT
  947. part_no,
  948. CONVERT(DECIMAL(20, 6), SUM(qty)) as total_qty,
  949. CONVERT(DECIMAL(20, 0), SUM(DISTINCT box_qty)) as box_qty,
  950. CONVERT(DECIMAL(20, 0), SUM(rolls)) as rolls,
  951. -- 按数量比例分配净重和毛重
  952. CONVERT(DECIMAL(20, 2), SUM(ISNULL(net_weight, 0) * qtyRatio)) as net_weight,
  953. CONVERT(DECIMAL(20, 2), SUM(ISNULL(gross_weight, 0) * qtyRatio)) as gross_weight,
  954. CONVERT(DECIMAL(20, 0), SUM(rolls * qty)) as qty_per_carton
  955. FROM BoxDetail
  956. GROUP BY part_no
  957. </select>
  958. <select id="getCoDelPalletDetailGroupByPn" resultType="java.util.Map">
  959. -- 修复净重毛重重复计算问题:按数量比例分配箱子重量
  960. WITH BoxDetail AS (
  961. SELECT
  962. b.pn,
  963. b.qty,
  964. b.rolls,
  965. a.box_qty,
  966. a.net_weight,
  967. a.gross_weight,
  968. b.site,
  969. b.bu_no,
  970. b.delNo,
  971. b.seq_no,
  972. -- 计算该零件数量占该箱子总数量的比例
  973. CASE
  974. WHEN SUM(b.qty) OVER (PARTITION BY b.site, b.bu_no, b.delNo, b.seq_no) > 0
  975. THEN b.qty * 1.0 / SUM(b.qty) OVER (PARTITION BY b.site, b.bu_no, b.delNo, b.seq_no)
  976. ELSE 0
  977. END as qtyRatio
  978. FROM ecss_CoDelBoxList a
  979. 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
  980. WHERE a.site=#{site} AND a.bu_no=#{buNo} AND a.delNo=#{delNo}
  981. )
  982. SELECT
  983. pn,
  984. CONVERT(DECIMAL(20, 0), SUM(qty)) as total_qty,
  985. CONVERT(DECIMAL(20, 0), SUM(DISTINCT box_qty)) as box_qty,
  986. CONVERT(DECIMAL(20, 0), SUM(rolls)) as rolls,
  987. -- 按数量比例分配净重和毛重
  988. CONVERT(DECIMAL(20, 2), SUM(ISNULL(net_weight, 0) * qtyRatio)) as net_weight,
  989. CONVERT(DECIMAL(20, 2), SUM(ISNULL(gross_weight, 0) * qtyRatio)) as gross_weight,
  990. CONVERT(DECIMAL(20, 0), SUM(rolls * qty)) as qty_per_carton
  991. FROM BoxDetail
  992. WHERE pn IS NOT NULL
  993. GROUP BY pn
  994. </select>
  995. <!-- 按发货通知单明细item_no分组获取装箱明细重量(用于Invoice) -->
  996. <select id="exportCoDelPalletDetailGroupByItemNo" resultType="java.util.Map">
  997. -- 按发货通知单明细行号分组,汇总该行对应的装箱重量
  998. WITH BoxDetail AS (
  999. SELECT
  1000. b.notify_detail_item_no,
  1001. b.part_no,
  1002. b.qty,
  1003. b.rolls,
  1004. a.box_qty,
  1005. a.net_weight,
  1006. a.gross_weight,
  1007. b.site,
  1008. b.bu_no,
  1009. b.delNo,
  1010. b.seq_no,
  1011. -- 计算该零件数量占该箱子总数量的比例
  1012. CASE
  1013. WHEN SUM(b.qty) OVER (PARTITION BY b.site, b.bu_no, b.delNo, b.seq_no) > 0
  1014. THEN b.qty * 1.0 / SUM(b.qty) OVER (PARTITION BY b.site, b.bu_no, b.delNo, b.seq_no)
  1015. ELSE 0
  1016. END as qtyRatio
  1017. FROM ecss_CoDelBoxList a
  1018. 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
  1019. WHERE a.site=#{site} AND a.bu_no=#{buNo} AND a.delNo=#{delNo} AND b.notify_detail_item_no IS NOT NULL
  1020. )
  1021. SELECT
  1022. notify_detail_item_no as item_no,
  1023. part_no,
  1024. CONVERT(DECIMAL(20, 0), SUM(qty)) as total_qty,
  1025. CONVERT(DECIMAL(20, 0), SUM(DISTINCT box_qty)) as box_qty,
  1026. CONVERT(DECIMAL(20, 0), SUM(rolls)) as rolls,
  1027. -- 按数量比例分配净重和毛重
  1028. CONVERT(DECIMAL(20, 2), SUM(ISNULL(net_weight, 0) * qtyRatio)) as net_weight,
  1029. CONVERT(DECIMAL(20, 2), SUM(ISNULL(gross_weight, 0) * qtyRatio)) as gross_weight,
  1030. CONVERT(DECIMAL(20, 0), SUM(rolls * qty)) as qty_per_carton
  1031. FROM BoxDetail
  1032. GROUP BY notify_detail_item_no, part_no
  1033. </select>
  1034. <select id="exportCoDelBoxList" resultType="java.util.Map">
  1035. select CONVERT(DECIMAL(20, 0),sum(a.box_qty)) as box_qty
  1036. from ecss_CoDelBoxList a
  1037. where a.site=#{site} and a.bu_no=#{buNo} and a.delNo=#{delNo} GROUP BY a.item_no
  1038. </select>
  1039. <update id="updateEcssDeclarationHeader" >
  1040. update ecss_declaration_header set
  1041. upc=#{upc},so=#{so},origin=#{origin},pallet_weight=#{palletWeight},material=#{material},
  1042. hs_code=#{hsCode},packaging=#{packaging},kgs=#{kgs},shipping_mark=#{shippingMark},boxChange=#{boxChange},
  1043. hsCodeDesc=#{hsCodeDesc},contractFlag=#{contractFlag},hsCodeDescType=#{hsCodeDescType},goodsLabel=#{goodsLabel}
  1044. where site=#{site} and declaration_no=#{declarationNo}
  1045. </update>
  1046. <update id="updateEcssCoDelNotifyDetail" >
  1047. update ecss_CoDelNotifydetail set lossratio=#{lossratio},ehundred=#{ehundred}
  1048. where site=#{site} and delNo=#{delNo} and part_no=#{partNo}
  1049. </update>
  1050. <update id="updateEcssCoDelNotifyDetailSurplus" >
  1051. update ecss_CoDelNotifydetail set surplus_qty=#{surplusQty}
  1052. where site=#{site} and bu_no=#{buNo} and delNo=#{delNo} and part_no=#{partNo} and item_no=#{itemNo}
  1053. </update>
  1054. <select id="getNotifyPartDetail" resultType="java.util.Map">
  1055. select a.part_no as partNo,b.hsCode,a.site,a.delNo,a.lossratio,a.ehundred,b.part_desc,a.pn
  1056. from ecss_CoDelNotifydetail a
  1057. left join part b on a.site=b.site and a.part_no=b.part_no
  1058. where a.site = #{site} AND a.delNo = #{delNo} and a.qty>0
  1059. group by a.part_no,b.hsCode,a.site,a.delNo,a.lossratio,a.ehundred,b.part_desc,a.pn
  1060. </select>
  1061. <select id="getDeclarationPalletPartDetail" resultType="java.util.Map">
  1062. select pd.part_no as partNo,
  1063. p.hsCode,
  1064. pd.site,
  1065. pd.delNo,
  1066. nd.lossratio,
  1067. nd.ehundred,
  1068. p.part_desc,
  1069. pd.pn,
  1070. ISNULL(p.fsc_flag, 'N') as fscFlag,
  1071. CONVERT(DECIMAL(20, 6), pd.qty) as qty,
  1072. CONVERT(DECIMAL(20, 6), ISNULL(fsc.num_value, 0)) as fscUnitWeight
  1073. from (
  1074. select site, bu_no, delNo, part_no, pn, sum(qty) as qty
  1075. from ecss_CoDelPalletDetail
  1076. where site = #{site} and bu_no = #{buNo} and delNo = #{delNo} and qty > 0
  1077. group by site, bu_no, delNo, part_no, pn
  1078. ) pd
  1079. left join (
  1080. select site, bu_no, delNo, part_no,
  1081. max(lossratio) as lossratio,
  1082. max(ehundred) as ehundred
  1083. from ecss_CoDelNotifydetail
  1084. where site = #{site} and bu_no = #{buNo} and delNo = #{delNo}
  1085. group by site, bu_no, delNo, part_no
  1086. ) nd on pd.site = nd.site
  1087. and pd.bu_no = nd.bu_no
  1088. and pd.delNo = nd.delNo
  1089. and pd.part_no = nd.part_no
  1090. left join part p on pd.site = p.site and pd.part_no = p.part_no
  1091. left join part_sub_properties_value fsc
  1092. on pd.site = fsc.site
  1093. and pd.bu_no = fsc.bu_no
  1094. and pd.part_no = fsc.part_no
  1095. and fsc.record_type = 'ECSSPART'
  1096. and fsc.code_no = 'BG001'
  1097. and fsc.properties_item_no = 'FSC006'
  1098. order by pd.part_no
  1099. </select>
  1100. <select id="getNotifyPartDetail2" resultType="EcssCoDelNotifyDetailData">
  1101. select a.part_no as partNo,b.hsCode,a.site,a.delNo,a.lossratio,a.ehundred,b.part_desc,a.pn
  1102. from ecss_CoDelNotifydetail a
  1103. left join part b on a.site=b.site and a.part_no=b.part_no
  1104. where a.site = #{site} AND a.delNo = #{delNo} and a.qty>0
  1105. group by a.part_no,b.hsCode,a.site,a.delNo,a.lossratio,a.ehundred,b.part_desc,a.pn
  1106. </select>
  1107. <select id="getNotifyDetailGroup" resultType="java.util.Map">
  1108. select b.hsCodeDesc,CONVERT(DECIMAL(20, 2),sum(a.qty)) as total_qty,
  1109. CONVERT(DECIMAL(20, 2),sum(a.ttl_amount)) as ttl_amount
  1110. from ecss_CoDelNotifydetail a
  1111. left join part b on a.site=b.site and a.part_no=b.part_no
  1112. where a.site = #{site} AND a.delNo = #{delNo} and a.qty>0
  1113. group by b.hsCodeDesc
  1114. </select>
  1115. <select id="getNotifyDetailGroupTX" resultType="java.util.Map">
  1116. select b.hsCodeDesc,CONVERT(DECIMAL(20, 2),sum(a.qty)) as total_qty,
  1117. CONVERT(DECIMAL(20, 2),sum(a.ttl_amount)) as ttl_amount
  1118. from ecss_CoDelNotifydetail a
  1119. left join part b on a.site=b.site and a.part_no=b.part_no
  1120. where a.site = #{site} AND a.delNo = #{delNo} and a.qty>0
  1121. group by b.hsCodeDesc,b.brand
  1122. </select>
  1123. <!-- 根据notifyDetailItemNo获取发货通知单明细 -->
  1124. <select id="getEcssCoDelNotifyDetailByItemNo" resultType="EcssCoDelNotifyDetailData">
  1125. 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,
  1126. 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,
  1127. 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,
  1128. a.modifyFlag,a.modifyQtyFlag
  1129. from ecss_CoDelNotifydetail a
  1130. where a.site = #{site}
  1131. and a.bu_no = #{buNo}
  1132. and a.delNo = #{delNo}
  1133. and a.item_no = #{notifyDetailItemNo}
  1134. </select>
  1135. <select id="getPropertiesListByTypeAndCodeNo" resultType="com.xujie.sys.modules.part.entity.PartSubPropertiesValueData">
  1136. SELECT a.part_no , a.Site, a.code_no, a.sub_code_seq_no, a.sub_code_desc
  1137. ,a.bu_no,a.item_no, a.properties_item_no, a.text_value, a.num_value, a.record_type
  1138. , b.item_desc ItemDesc, b.value_type, b.value_type_db, b.value_choose_flag
  1139. FROM part_sub_properties_value a
  1140. left join plm_properties_item b
  1141. 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
  1142. <where>
  1143. AND a.site = #{site}
  1144. and a.record_type = #{recordType}
  1145. and a.bu_no=#{buNo}
  1146. and a.code_no = #{codeNo}
  1147. and a.part_no = #{pn}
  1148. </where>
  1149. order by a.item_no
  1150. </select>
  1151. <select id="getEcssContacts" resultType="java.util.Map">
  1152. select
  1153. bu_no as buNo,
  1154. [name] as [name],
  1155. phone as phone,
  1156. company as company,
  1157. [address] as [address],
  1158. landline as landline,
  1159. [defaultOption] as defaultOption
  1160. from ecss_contacts
  1161. <where>
  1162. bu_no = #{buNo}
  1163. <if test="company != null and company != ''">
  1164. and company = #{company}
  1165. </if>
  1166. <if test="address != null and address != ''">
  1167. and [address] = #{address}
  1168. </if>
  1169. </where>
  1170. order by
  1171. case when [defaultOption] = 'Y' then 0 else 1 end,
  1172. ISNULL(company, ''),
  1173. ISNULL([address], ''),
  1174. ISNULL([name], '')
  1175. </select>
  1176. <select id="getCustomerList" resultType="java.util.Map">
  1177. select * from ecss_custdev_mes_cmc_customer where buse='是'
  1178. </select>
  1179. <select id="getCustomerInfo" resultType="java.util.Map">
  1180. select DISTINCT vcus.ccusname,vcusp.ccontactname,vcusp.cnative
  1181. from ecss_custdev_mes_cmc_customer vcus
  1182. LEFT JOIN ecss_custdev_mes_cmc_customer_person vcusp on vcus.ccuscode=vcusp.ccuscode
  1183. <where>
  1184. <if test="ccusname != null and ccusname != ''">
  1185. and vcus.ccusname=#{ccusname}
  1186. </if>
  1187. <if test="ccuscode != null and ccuscode != ''">
  1188. and vcus.ccuscode=#{ccuscode}
  1189. </if>
  1190. </where>
  1191. </select>
  1192. <select id="getCustomerAdd" resultType="java.util.Map">
  1193. select DISTINCT vcus.ccusname,vcusa.cDeliverAdd
  1194. from ecss_custdev_mes_cmc_customer vcus
  1195. left join ecss_custdev_mes_cmc_customer_addr vcusa on vcus.ccuscode=vcusa.ccuscode
  1196. where vcus.ccusname=#{ccusname}
  1197. </select>
  1198. <select id="getPackageNoByPartNo" resultType="java.util.Map">
  1199. select p.part_no as partNo,p.packageNo
  1200. from Part p
  1201. where p.site=#{site,jdbcType=VARCHAR} and p.part_no in
  1202. <foreach item="item" index="index" collection="partNos" open="(" separator="," close=")">
  1203. #{item}
  1204. </foreach>
  1205. </select>
  1206. <select id="getPackageNoByPn" resultType="java.util.Map">
  1207. select p.sku as pn,p.packageNo
  1208. from Part p
  1209. where p.site=#{site,jdbcType=VARCHAR} and p.sku in
  1210. <foreach item="item" index="index" collection="pns" open="(" separator="," close=")">
  1211. #{item}
  1212. </foreach>
  1213. </select>
  1214. <select id="getPackageList" resultType="EcssPackageData">
  1215. select * from ecss_package where site=#{site} and buNo=#{buNo}
  1216. and package_no in
  1217. <foreach item="item" index="index" collection="packageNos" open="(" separator="," close=")">
  1218. #{item}
  1219. </foreach>
  1220. </select>
  1221. <select id="searchEcssTemplateData" resultType="EcssTemplate">
  1222. select a.*,dbo.get_bu_desc(a.site,a.BuNo) as BuDesc
  1223. from ecss_template a
  1224. left join accessBu D on A.site=D.site and A.BuNo=d.bu_no and D.username=#{query.username}
  1225. <where>
  1226. and D.site is not null
  1227. <if test="query.buNo != null and query.buNo != ''">
  1228. AND a.buNo = #{query.buNo}
  1229. </if>
  1230. <if test="query.name != null and query.name != ''">
  1231. AND a.name like '%'+#{query.name}+'%'
  1232. </if>
  1233. <if test="query.customName != null and query.customName != ''">
  1234. AND a.customName like '%'+#{query.customName}+'%'
  1235. </if>
  1236. <if test="query.shippingMode != null and query.shippingMode != ''">
  1237. AND a.shippingMode like '%'+#{query.shippingMode}+'%'
  1238. </if>
  1239. <if test="query.type != null and query.type != ''">
  1240. AND a.type = #{query.type}
  1241. </if>
  1242. </where>
  1243. order by a.CreateDate
  1244. </select>
  1245. <insert id="insertEcssTemplateData" >
  1246. insert into ecss_template (customName,site,buNo,name,type,upc,so,origin,palletWeight,material,hsCode,packaging,itemNo,
  1247. kgs,shippingMark,boxChange,hsCodeDesc,contractFlag,hsCodeDescType,goodsLabel,hsCodeFlag,shippingMode,CreateBy,CreateDate,
  1248. salesMethod,currency,madeArea,sendPort,shipper,voyage,deliveryGoodsDate,shippingDate,fscWeight, remark,highPalletFlag,showWeight)
  1249. values(#{customName,jdbcType=NVARCHAR},#{site},#{buNo},#{name},#{type},#{upc},#{so},#{origin},#{palletWeight},#{material},#{hsCode},#{packaging},
  1250. #{itemNo},#{kgs},#{shippingMark},#{boxChange},
  1251. #{hsCodeDesc},#{contractFlag},#{hsCodeDescType},#{goodsLabel},#{hsCodeFlag},#{shippingMode},#{createBy},GetDate(),
  1252. #{salesMethod},#{currency},#{madeArea},#{sendPort},#{shipper},#{voyage},#{deliveryGoodsDate},#{shippingDate},#{fscWeight},#{remark},#{highPalletFlag},#{showWeight})
  1253. </insert>
  1254. <update id="updateEcssTemplateData">
  1255. update ecss_template set buNo=#{buNo},name=#{name},type=#{type},upc=#{upc},so=#{so},origin=#{origin},boxChange=#{boxChange},
  1256. palletWeight=#{palletWeight},material=#{material},hsCode=#{hsCode},itemNo=#{itemNo},
  1257. packaging=#{packaging},kgs=#{kgs},shippingMark=#{shippingMark},hsCodeDesc=#{hsCodeDesc},
  1258. contractFlag=#{contractFlag},hsCodeDescType=#{hsCodeDescType},goodsLabel=#{goodsLabel},hsCodeFlag=#{hsCodeFlag},
  1259. shippingMode=#{shippingMode},UpdateDate=GetDate(),UpdateBy=#{updateBy},customName=#{customName,jdbcType=NVARCHAR},salesMethod= #{salesMethod},
  1260. currency= #{currency},madeArea= #{madeArea},sendPort= #{sendPort},shipper= #{shipper},remark= #{remark},
  1261. voyage= #{voyage},deliveryGoodsDate= #{deliveryGoodsDate},shippingDate= #{shippingDate},fscWeight=#{fscWeight},highPalletFlag=#{highPalletFlag},showWeight=#{showWeight}
  1262. where buNo=#{buNo} and name=#{nameNative}
  1263. </update>
  1264. <select id="deleteEcssTemplate" >
  1265. delete from ecss_template where buNo=#{buNo} and name=#{name}
  1266. </select>
  1267. <select id="getEcssTemplateByBuAndName" resultType="EcssTemplate">
  1268. select * from ecss_template where name=#{name} and site=#{site}
  1269. </select>
  1270. <select id="searchWalMartOrderData" resultType="EcssWalMartOrder">
  1271. select a.*
  1272. from ecss_walMartOrder a
  1273. <where>
  1274. <if test="query.so != null and query.so != ''">
  1275. AND a.so like '%'+#{query.so}+'%'
  1276. </if>
  1277. <if test="query.sku != null and query.sku != ''">
  1278. AND a.sku like '%'+#{query.sku}+'%'
  1279. </if>
  1280. </where>
  1281. order by a.CreateDate
  1282. </select>
  1283. <insert id="insertWalMartOrderData" >
  1284. insert into ecss_walMartOrder (site,buNo,sku,so,qty,rolls,grossWeight,verificationSheet,CreateBy,CreateDate)
  1285. values(#{site},#{buNo},#{sku},#{so},#{qty},#{rolls},#{grossWeight},#{verificationSheet},#{createBy},GetDate())
  1286. </insert>
  1287. <insert id="batchSaveWalMartOrder">
  1288. insert into ecss_walMartOrder (site,buNo,sku,so,qty,rolls,grossWeight,verificationSheet,CreateBy,CreateDate)
  1289. values
  1290. <foreach collection="list" separator="," item="item">
  1291. (#{item.site},#{item.buNo},#{item.sku},#{item.so},#{item.qty},
  1292. #{item.rolls},#{item.grossWeight},#{item.verificationSheet},#{item.createBy},GetDate())
  1293. </foreach>
  1294. </insert>
  1295. <update id="updateWalMartOrderData">
  1296. update ecss_walMartOrder set buNo=#{buNo},sku=#{sku},so=#{so},qty=#{qty},rolls=#{rolls},grossWeight=#{grossWeight},
  1297. verificationSheet=#{verificationSheet},UpdateDate=GetDate(),UpdateBy=#{updateBy}
  1298. where buNo=#{buNo} and sku=#{sku} and so=#{so} and qty=#{qty}
  1299. </update>
  1300. <select id="deleteWalMartOrder" >
  1301. delete from ecss_walMartOrder where buNo=#{buNo} and sku=#{sku} and so=#{so} and qty=#{qty}
  1302. </select>
  1303. <!-- 查出所有类型的物料 -->
  1304. <select id="queryPartListAll" parameterType="PartInformationEntity" resultType="PartInformationEntity">
  1305. SELECT site, sourceBu as buNo, part_no, part_desc, sku
  1306. FROM part
  1307. <where> sourceBu=#{query.buNo} and
  1308. site = #{query.site} and active = 'Y'
  1309. <if test = "query.partNo != null and query.partNo != ''">
  1310. AND part_no like '%' + #{query.partNo} + '%'
  1311. </if>
  1312. <if test = "query.sku != null and query.sku != ''">
  1313. AND sku like '%' + #{query.sku} + '%'
  1314. </if>
  1315. <if test = "query.partDesc != null and query.partDesc != ''">
  1316. AND part_desc like '%' + #{query.partDesc} + '%'
  1317. </if>
  1318. </where>
  1319. </select>
  1320. <select id="queryByUserName" resultType="com.xujie.sys.modules.sys.entity.SysUserEntity">
  1321. select * from sys_user where username = #{username}
  1322. </select>
  1323. <select id="queryUsersByRoleName" resultType="com.xujie.sys.modules.sys.entity.SysUserEntity">
  1324. select u.email from sys_user u
  1325. LEFT JOIN sys_user_role ur on ur.user_id = u.user_id
  1326. LEFT JOIN sys_role r on r.role_id = ur.role_id
  1327. where r.role_name = #{roleName} and u.site = #{site}
  1328. </select>
  1329. <select id="searchCoDelPalletDataNew" resultType="EcssCoDelPalletData">
  1330. 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,
  1331. c.gross_weight,c.net_weight,c.box_qty as pallet_qty,b.notify_detail_item_no as notifyDetailItemNo
  1332. from ecss_CoDelPalletDetail b
  1333. 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
  1334. where b.site=#{site} and b.bu_no=#{buNo} and b.delNo=#{delNo}
  1335. <if test="seqNo != null and seqNo != ''">
  1336. and b.seq_no=#{seqNo}
  1337. </if>
  1338. </select>
  1339. <update id="updateExportFlag">
  1340. update ecss_CoDelNotifyHeader
  1341. set export_flag = #{exportFlag},
  1342. updateBy = #{updateBy},
  1343. updateDate = GetDate()
  1344. where site = #{site}
  1345. and bu_no = #{buNo}
  1346. and delNo = #{delNo}
  1347. </update>
  1348. <select id="selectBoxList" resultType="java.util.Map">
  1349. select a.*,
  1350. CONVERT(DECIMAL(20, 3),a.gross_weight) as grossWeight,
  1351. CONVERT(DECIMAL(20, 3),a.net_weight) as netWeight,
  1352. CONVERT(DECIMAL(20, 3),w.num_value) as boxWeight
  1353. from ecss_CoDelBoxList a
  1354. left join (
  1355. select b.site, b.bu_no, b.delNo, b.seq_no, b.part_no,
  1356. ROW_NUMBER() OVER (PARTITION BY b.site, b.bu_no, b.delNo, b.seq_no ORDER BY b.part_no) as rn
  1357. from ecss_CoDelPalletDetail b
  1358. where b.site = #{site} and b.bu_no = #{buNo} and b.delNo = #{delNo}
  1359. ) d on a.site = d.site and a.bu_no = d.bu_no and a.delNo = d.delNo and a.item_no = d.seq_no and d.rn = 1
  1360. left join part_sub_properties_value w on d.part_no = w.part_no and w.site = d.site and w.bu_no = d.bu_no
  1361. and w.record_type='ECSSPART' and w.code_no='BG001' and w.properties_item_no='BOXWEIGHT'
  1362. where a.site = #{site} and a.bu_no = #{buNo} and a.delNo = #{delNo}
  1363. </select>
  1364. <select id="selectBoxListTX" resultType="java.util.Map">
  1365. select a.*,
  1366. CONVERT(DECIMAL(20, 3),a.gross_weight) as grossWeight,
  1367. CONVERT(DECIMAL(20, 3),a.net_weight) as netWeight,
  1368. CONVERT(DECIMAL(20, 3),w.num_value) as boxWeight
  1369. from ecss_CoDelBoxList a
  1370. left join (
  1371. select b.site, b.bu_no, b.delNo, b.seq_no, b.part_no,
  1372. ROW_NUMBER() OVER (PARTITION BY b.site, b.bu_no, b.delNo, b.seq_no ORDER BY b.part_no) as rn
  1373. from ecss_CoDelPalletDetail b
  1374. where b.site = #{site} and b.bu_no = #{buNo} and b.delNo = #{delNo}
  1375. ) d on a.site = d.site and a.bu_no = d.bu_no and a.delNo = d.delNo and a.item_no = d.seq_no and d.rn = 1
  1376. left join part_sub_properties_value w on d.part_no = w.part_no and w.site = d.site and w.bu_no = d.bu_no
  1377. and w.record_type='ECSSPART' and w.code_no='BG001' and w.properties_item_no='BOXWEIGHT'
  1378. where a.site = #{site} and a.bu_no = #{buNo} and a.delNo = #{delNo}
  1379. order by
  1380. CASE
  1381. WHEN LEFT(a.item_no, CHARINDEX('~', a.item_no + '~') - 1) != ''
  1382. AND LEFT(a.item_no, CHARINDEX('~', a.item_no + '~') - 1) NOT LIKE '%[^0-9]%'
  1383. THEN CONVERT(int, LEFT(a.item_no, CHARINDEX('~', a.item_no + '~') - 1))
  1384. ELSE 2147483647
  1385. END,
  1386. CASE
  1387. WHEN SUBSTRING(a.item_no, CHARINDEX('~', a.item_no + '~') + 1, LEN(a.item_no)) != ''
  1388. AND SUBSTRING(a.item_no, CHARINDEX('~', a.item_no + '~') + 1, LEN(a.item_no)) NOT LIKE '%[^0-9]%'
  1389. THEN CONVERT(int, SUBSTRING(a.item_no, CHARINDEX('~', a.item_no + '~') + 1, LEN(a.item_no)))
  1390. WHEN LEFT(a.item_no, CHARINDEX('~', a.item_no + '~') - 1) != ''
  1391. AND LEFT(a.item_no, CHARINDEX('~', a.item_no + '~') - 1) NOT LIKE '%[^0-9]%'
  1392. THEN CONVERT(int, LEFT(a.item_no, CHARINDEX('~', a.item_no + '~') - 1))
  1393. ELSE 2147483647
  1394. END,
  1395. a.item_no
  1396. </select>
  1397. <update id="updateBoxInfo">
  1398. update ecss_CoDelBoxList
  1399. set box_qty = #{box_qty},
  1400. gross_weight = #{grossWeight},
  1401. net_weight = #{netWeight},
  1402. rolls = #{rolls},
  1403. remark = #{remark}
  1404. where site = #{site}
  1405. and bu_no = #{buNo}
  1406. and delNo = #{delNo}
  1407. and item_no = #{item_no}
  1408. </update>
  1409. <update id="updateTotalVolume">
  1410. update ecss_CoDelNotifyHeader
  1411. set totalVolume = #{totalVolume}
  1412. where site = #{site}
  1413. and bu_no = #{buNo}
  1414. and delNo = #{delNo}
  1415. </update>
  1416. <delete id="deleteBoxInfo">
  1417. delete from ecss_CoDelBoxList
  1418. where site = #{site}
  1419. and bu_no = #{buNo}
  1420. and delNo = #{delNo}
  1421. and item_no = #{item_no}
  1422. </delete>
  1423. <update id="updateDetailInfo">
  1424. update ecss_CoDelPalletDetail
  1425. set qty = #{qty},
  1426. rolls = #{rolls}
  1427. where site = #{site}
  1428. and bu_no = #{buNo}
  1429. and delNo = #{delNo}
  1430. and seq_no = #{seqNo}
  1431. and item_no = #{itemNo}
  1432. </update>
  1433. <update id="updateCodelPalletDetailFscWeight">
  1434. update ecss_CoDelPalletDetail
  1435. set fsc_weight = #{fscWeight,jdbcType=DECIMAL}
  1436. where site = #{site}
  1437. and bu_no = #{buNo}
  1438. and delNo = #{delNo}
  1439. and seq_no = #{seqNo}
  1440. and item_no = #{itemNo}
  1441. </update>
  1442. <delete id="deleteDetailInfo">
  1443. delete from ecss_CoDelPalletDetail
  1444. where site = #{site}
  1445. and bu_no = #{buNo}
  1446. and delNo = #{delNo}
  1447. and seq_no = #{seqNo}
  1448. and item_no = #{itemNo}
  1449. </delete>
  1450. <delete id="deleteEmptyBoxAfterDetailDelete">
  1451. -- 删除明细后,如果该box下没有明细了,则删除对应的box
  1452. delete from ecss_CoDelBoxList
  1453. where site = #{site}
  1454. and bu_no = #{buNo}
  1455. and delNo = #{delNo}
  1456. and item_no = #{seqNo}
  1457. and not exists (
  1458. select 1
  1459. from ecss_CoDelPalletDetail
  1460. where site = #{site}
  1461. and bu_no = #{buNo}
  1462. and delNo = #{delNo}
  1463. and seq_no = #{seqNo}
  1464. );
  1465. </delete>
  1466. <!--<select id="selectPalletDetailList" resultType="java.util.Map">
  1467. select a.*,b.part_description,b.hsCode,b.upc,b.so
  1468. from ecss_CoDelPalletDetail a left join (
  1469. select a.site,a.bu_no,a.delNo,a.part_no,a.part_description,b.hsCode,a.upc,a.so,a.customerPO
  1470. from ecss_CoDelNotifydetail a
  1471. left join part b on a.site=b.site and a.part_no=b.part_no
  1472. where a.site=#{site} and a.bu_no=#{buNo} and a.delNo=#{delNo}
  1473. GROUP BY a.site,a.bu_no,a.delNo,a.part_no,a.part_description,b.hsCode,a.upc,a.so,a.customerPO
  1474. ) 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
  1475. where a.site =#{site} and a.bu_no=#{buNo} and a.delNo=#{delNo}
  1476. <if test="seqNo != null and seqNo != ''">
  1477. and a.seq_no=#{seqNo}
  1478. </if>
  1479. order by a.notify_detail_item_no
  1480. </select>-->
  1481. <select id="selectPalletDetailList" resultType="java.util.Map">
  1482. select a.*,b.part_description,c.hsCode,b.upc,b.salesOrder as so,c.hsCodeDesc
  1483. from ecss_CoDelPalletDetail a
  1484. 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
  1485. left join part c on a.site=c.site and a.part_no=c.part_no
  1486. where a.site =#{site} and a.bu_no=#{buNo} and a.delNo=#{delNo}
  1487. <if test="seqNo != null and seqNo != ''">
  1488. and a.seq_no=#{seqNo}
  1489. </if>
  1490. order by a.notify_detail_item_no
  1491. </select>
  1492. <!-- 获取客户模板列表 -->
  1493. <select id="getCustomerTemplateList" resultType="java.util.Map">
  1494. SELECT
  1495. template_no,
  1496. template_name,
  1497. bu_no AS buNo,
  1498. ccuscode,
  1499. ccusname,
  1500. caddcode1,
  1501. localShipAddress,
  1502. salesArea,
  1503. caddcode2,
  1504. overseasAddress,
  1505. cnative,
  1506. overseasShipper
  1507. FROM ecss_Customer_template
  1508. <where>
  1509. <if test="templateName != null and templateName != ''">
  1510. AND template_name like '%'+#{templateName}+'%'
  1511. </if>
  1512. <if test="customerName != null and customerName != ''">
  1513. AND customer_name like '%'+#{customerName}+'%'
  1514. </if>
  1515. <if test="templateBuNo != null and templateBuNo != ''">
  1516. AND EXISTS (
  1517. SELECT 1
  1518. FROM string_split(REPLACE(#{templateBuNo}, ' ', ''), ',') queryBu
  1519. WHERE queryBu.value != ''
  1520. AND CHARINDEX(',' + queryBu.value + ',', ',' + REPLACE(ISNULL(bu_no, ''), ' ', '') + ',') > 0
  1521. )
  1522. </if>
  1523. </where>
  1524. ORDER BY template_name
  1525. </select>
  1526. <update id="updateCustomerTemplate">
  1527. update ecss_Customer_template
  1528. <set>
  1529. ccusname = #{ccusname},
  1530. localShipAddress = #{localShipAddress},
  1531. overseasShipper = #{overseasShipper},
  1532. overseasAddress = #{overseasAddress},
  1533. cnative = #{cnative},
  1534. salesArea = #{salesArea},
  1535. <if test="templateBuNo != null and templateBuNo != ''">
  1536. bu_no = #{templateBuNo},
  1537. </if>
  1538. </set>
  1539. where template_no = #{templateNo}
  1540. </update>
  1541. <!-- ========== 物料包装属性导入相关SQL ========== -->
  1542. <!-- 根据SKU获取物料信息(一个SKU可能对应多个part) -->
  1543. <select id="getPartListBySku" resultType="PartData">
  1544. SELECT site, sourceBu as buNo, part_no as partNo, part_desc as partDesc, sku
  1545. FROM part
  1546. WHERE site = #{site}
  1547. AND sourceBu = #{buNo}
  1548. AND sku = #{sku}
  1549. </select>
  1550. <!-- 检查物料属性是否存在 -->
  1551. <select id="checkPartPropertyExists" resultType="java.util.Map">
  1552. SELECT part_no, properties_item_no, num_value, text_value, item_no
  1553. FROM part_sub_properties_value
  1554. WHERE site = #{site}
  1555. AND bu_no = #{buNo}
  1556. AND part_no = #{partNo}
  1557. AND code_no = #{codeNo}
  1558. AND record_type = #{recordType}
  1559. AND properties_item_no = #{propertiesItemNo}
  1560. </select>
  1561. <!-- 更新物料属性数值 -->
  1562. <update id="updatePartPropertyNumValue">
  1563. UPDATE part_sub_properties_value
  1564. SET num_value = #{numValue}
  1565. WHERE site = #{site}
  1566. AND bu_no = #{buNo}
  1567. AND part_no = #{partNo}
  1568. AND code_no = #{codeNo}
  1569. AND record_type = #{recordType}
  1570. AND properties_item_no = #{propertiesItemNo}
  1571. </update>
  1572. <!-- 获取物料属性的最大item_no -->
  1573. <select id="getMaxItemNo" resultType="java.lang.Double">
  1574. SELECT MAX(item_no)
  1575. FROM part_sub_properties_value
  1576. WHERE site = #{site}
  1577. AND bu_no = #{buNo}
  1578. AND part_no = #{partNo}
  1579. AND code_no = #{codeNo}
  1580. AND record_type = #{recordType}
  1581. </select>
  1582. <!-- 获取属性定义信息 -->
  1583. <select id="getPropertiesItemInfo" resultType="java.util.Map">
  1584. SELECT item_no, item_desc, value_type, value_type_db,
  1585. (SELECT TOP 1 code_desc FROM plm_properties_model_header
  1586. WHERE site = #{site} AND bu_no = #{buNo} AND function_type = #{itemType}) as codeDesc
  1587. FROM plm_properties_item
  1588. WHERE site = #{site}
  1589. AND bu_no = #{buNo}
  1590. AND item_no = #{itemNo}
  1591. AND item_type = #{itemType}
  1592. </select>
  1593. <!-- 插入物料属性 -->
  1594. <insert id="insertPartProperty">
  1595. INSERT INTO part_sub_properties_value
  1596. (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)
  1597. VALUES
  1598. (#{partNo}, #{site}, #{buNo}, #{codeNo}, #{subCodeSeqNo}, #{subCodeDesc}, #{itemNo}, #{propertiesItemNo}, #{textValue}, #{numValue}, #{recordType})
  1599. </insert>
  1600. <!-- 检查箱类型是否存在(根据packageNo) -->
  1601. <select id="checkPackageExists" resultType="java.util.Map">
  1602. SELECT id, site, BuNo, package_no as packageNo, package_type as packageType, length, width, height
  1603. FROM ecss_package
  1604. WHERE site = #{site}
  1605. AND BuNo = #{buNo}
  1606. AND package_no = #{packageNo}
  1607. </select>
  1608. <!-- 根据packageType检查箱类型是否存在 -->
  1609. <select id="checkPackageExistsByType" resultType="java.util.Map">
  1610. SELECT id, site, BuNo, package_no as packageNo, package_type as packageType, length, width, height
  1611. FROM ecss_package
  1612. WHERE site = #{site}
  1613. AND BuNo = #{buNo}
  1614. AND package_type = #{packageType}
  1615. </select>
  1616. <!-- 获取箱类型的最大packageNo编号 -->
  1617. <select id="getMaxPackageNo" resultType="java.lang.String">
  1618. SELECT MAX(package_no)
  1619. FROM ecss_package
  1620. WHERE site = #{site}
  1621. AND BuNo = #{buNo}
  1622. </select>
  1623. <!-- 插入箱类型 -->
  1624. <insert id="insertPackage">
  1625. INSERT INTO ecss_package
  1626. (Site, BuNo, package_no, package_type, length, width, height, volume, weight, Remark, CreateBy, CreateDate)
  1627. VALUES
  1628. (#{site}, #{buNo}, #{packageNo}, #{packageType}, #{length}, #{width}, #{height}, #{volume}, #{weight}, #{remark}, #{createBy}, GETDATE())
  1629. </insert>
  1630. <!-- 更新箱类型尺寸(根据packageType更新) -->
  1631. <update id="updatePackageDimensions">
  1632. UPDATE ecss_package
  1633. SET length = #{length},
  1634. width = #{width},
  1635. height = #{height},
  1636. volume = #{volume},
  1637. UpdateBy = #{updateBy},
  1638. UpdateDate = GETDATE()
  1639. WHERE site = #{site}
  1640. AND BuNo = #{buNo}
  1641. AND package_type = #{packageType}
  1642. </update>
  1643. <!-- 更新物料的packageNo -->
  1644. <update id="updatePartPackageNo">
  1645. UPDATE part
  1646. SET packageNo = #{packageNo}
  1647. WHERE site = #{site}
  1648. AND part_no = #{partNo}
  1649. </update>
  1650. <!-- ============================================= -->
  1651. <!-- UPC导入相关SQL -->
  1652. <!-- ============================================= -->
  1653. <!-- 批量插入UPC导入数据 -->
  1654. <insert id="batchInsertUpcImportData">
  1655. INSERT INTO ecss_del_upc_import (
  1656. site,
  1657. cmc_invoice,
  1658. carton_no,
  1659. so,
  1660. pn,
  1661. description,
  1662. upc,
  1663. qty,
  1664. import_batch,
  1665. import_date,
  1666. import_by,
  1667. created_by,
  1668. created_date,
  1669. is_deleted
  1670. ) VALUES
  1671. <foreach collection="list" item="item" separator=",">
  1672. (
  1673. #{item.site},
  1674. #{item.cmcInvoice},
  1675. #{item.cartonNo},
  1676. #{item.so},
  1677. #{item.pn},
  1678. #{item.description},
  1679. #{item.upc},
  1680. #{item.qty},
  1681. #{item.importBatch},
  1682. #{item.importDate},
  1683. #{item.importBy},
  1684. #{item.createdBy},
  1685. #{item.createdDate},
  1686. '0'
  1687. )
  1688. </foreach>
  1689. </insert>
  1690. <!-- 根据发票号查询UPC导入数据 -->
  1691. <select id="selectUpcImportByCmcInvoice" resultType="EcssDelUpcImport">
  1692. SELECT
  1693. site,
  1694. cmc_invoice AS cmcInvoice,
  1695. carton_no AS cartonNo,
  1696. so,
  1697. pn,
  1698. description,
  1699. upc,
  1700. qty,
  1701. import_batch AS importBatch,
  1702. import_date AS importDate,
  1703. import_by AS importBy,
  1704. created_by AS createdBy,
  1705. created_date AS createdDate,
  1706. updated_by AS updatedBy,
  1707. updated_date AS updatedDate,
  1708. is_deleted AS isDeleted,
  1709. remark
  1710. FROM ecss_del_upc_import
  1711. WHERE site = #{site}
  1712. AND cmc_invoice = #{cmcInvoice}
  1713. ORDER BY TRY_CAST(carton_no AS INT) ASC
  1714. </select>
  1715. <!-- 根据发票号删除UPC导入数据 -->
  1716. <delete id="deleteUpcImportByCmcInvoice">
  1717. delete ecss_del_upc_import
  1718. WHERE site = #{site}
  1719. AND cmc_invoice = #{cmcInvoice}
  1720. </delete>
  1721. <!-- 进出口总表导出:条件与 searchEcssCoDelNotifyHeader 一致,按开票日期排序 -->
  1722. <select id="listImportExportSummary" resultType="EcssCoDelImportExportSummaryRow">
  1723. SELECT
  1724. a.bu_no AS buNo,
  1725. a.cmc_invoice AS cmcInvoice,
  1726. a.ready_date AS readyDate,
  1727. a.shipping_mode AS shippingMode,
  1728. a.customer_name AS ordererName,
  1729. COALESCE(
  1730. NULLIF(LTRIM(RTRIM(d.overseas_shipper)), ''),
  1731. NULLIF(LTRIM(RTRIM(a.overseasShipper)), '')
  1732. ) AS consignee,
  1733. a.Destination AS destination,
  1734. d.package_qty AS packageQty,
  1735. COALESCE(
  1736. d.box_qty,
  1737. CONVERT(INT, ROUND(ISNULL(box.sum_box_qty, 0), 0))
  1738. ) AS boxQty,
  1739. COALESCE(d.net_weight, box.sum_net_weight) AS netWeight,
  1740. COALESCE(d.gross_weight, box.sum_gross_weight) AS grossWeight,
  1741. CONVERT(DECIMAL(20, 6), ISNULL(palVol.sum_pallet_volume, 0)) AS totalVolume,
  1742. det.total_qty AS totalQty,
  1743. det.currency_code AS currencyCode,
  1744. det.total_amount AS totalAmount,
  1745. '' AS blNo,
  1746. '' AS exportDate,
  1747. '' AS customsDeclarationNo
  1748. FROM ecss_CoDelNotifyHeader a
  1749. INNER JOIN accessBu acc ON a.site = acc.site AND a.bu_no = acc.bu_no AND acc.username = #{query.username}
  1750. LEFT JOIN ecss_declaration_header d ON a.site = d.site AND a.delNo = d.delNo
  1751. LEFT JOIN (
  1752. SELECT
  1753. site,
  1754. bu_no,
  1755. delNo,
  1756. CONVERT(DECIMAL(20, 0), SUM(CASE WHEN qty > 0 THEN qty ELSE 0 END)) AS total_qty,
  1757. CONVERT(DECIMAL(20, 2), SUM(CASE WHEN qty > 0 THEN ISNULL(ttl_amount, 0) ELSE 0 END)) AS total_amount,
  1758. MAX(LEFT(LTRIM(RTRIM(currency)), 3)) AS currency_code,
  1759. MAX(NULLIF(LTRIM(RTRIM(awb_bl)), '')) AS awb_bl_max,
  1760. MAX(NULLIF(LTRIM(RTRIM(shipping_number)), '')) AS shipping_number_max
  1761. FROM ecss_CoDelNotifydetail
  1762. GROUP BY site, bu_no, delNo
  1763. ) det ON det.site = a.site AND det.bu_no = a.bu_no AND det.delNo = a.delNo
  1764. LEFT JOIN (
  1765. SELECT
  1766. site,
  1767. bu_no,
  1768. delNo,
  1769. SUM(ISNULL(box_qty, 0)) AS sum_box_qty,
  1770. SUM(ISNULL(net_weight, 0)) AS sum_net_weight,
  1771. SUM(ISNULL(gross_weight, 0)) AS sum_gross_weight
  1772. FROM ecss_CoDelBoxList
  1773. GROUP BY site, bu_no, delNo
  1774. ) box ON box.site = a.site AND box.bu_no = a.bu_no AND box.delNo = a.delNo
  1775. LEFT JOIN (
  1776. SELECT
  1777. site,
  1778. bu_no,
  1779. delNo,
  1780. SUM(ISNULL(volume, 0)) AS sum_pallet_volume
  1781. FROM ecss_CoDelPalletHeader
  1782. GROUP BY site, bu_no, delNo
  1783. ) palVol ON palVol.site = a.site AND palVol.bu_no = a.bu_no AND palVol.delNo = a.delNo
  1784. <where>
  1785. <if test="query.buNo != null and query.buNo != ''">
  1786. AND a.bu_no = #{query.buNo}
  1787. </if>
  1788. <if test="query.delNo != null and query.delNo != ''">
  1789. AND a.delNo LIKE #{query.delNo}
  1790. </if>
  1791. <if test="query.cmcInvoice != null and query.cmcInvoice != ''">
  1792. AND a.cmc_invoice LIKE #{query.cmcInvoice}
  1793. </if>
  1794. <if test="query.notifyStatus != null and query.notifyStatus != ''">
  1795. AND a.notify_status = #{query.notifyStatus}
  1796. </if>
  1797. <if test="query.fscFlag == 'true'">
  1798. AND a.fscFlag = 'Y'
  1799. </if>
  1800. <if test="query.boxSizeFlag == 'true'">
  1801. AND a.boxSizeFlag = 'Y'
  1802. </if>
  1803. <if test="query.walMartOrderFlag == 'true'">
  1804. AND a.walMartOrderFlag = 'Y'
  1805. </if>
  1806. <if test="query.startDate != null">
  1807. AND a.ready_date &gt;= #{query.startDate}
  1808. </if>
  1809. <if test="query.endDate != null">
  1810. AND #{query.endDate} &gt;= a.ready_date
  1811. </if>
  1812. <if test="query.modifyData == 'true'">
  1813. AND a.modifyFlag = 1
  1814. </if>
  1815. </where>
  1816. ORDER BY
  1817. CASE WHEN a.ready_date IS NULL THEN 1 ELSE 0 END,
  1818. a.ready_date ASC,
  1819. a.cmc_invoice ASC
  1820. </select>
  1821. </mapper>