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.

1860 lines
88 KiB

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