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.

1554 lines
75 KiB

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