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.

1875 lines
89 KiB

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