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.

700 lines
48 KiB

2 weeks ago
2 weeks ago
2 weeks ago
1 month ago
2 months ago
4 weeks ago
2 weeks ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
2 months ago
1 month ago
1 month ago
4 weeks ago
2 weeks ago
1 month ago
2 months ago
1 month ago
2 months ago
4 weeks ago
2 months ago
2 months ago
2 weeks ago
2 months ago
1 month ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
2 months ago
1 month ago
2 months ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
3 weeks ago
2 weeks ago
1 month ago
1 month ago
1 month ago
3 weeks 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.modules.order.dao.PODetailMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.xujie.modules.order.entity.PODetail">
  6. <id column="order_no" property="orderNo" />
  7. <result column="site" property="site" />
  8. <result column="item_no" property="itemNo" />
  9. <result column="part_no" property="partNo" />
  10. <result column="status" property="status" />
  11. <result column="qty" property="qty" />
  12. <result column="umid" property="umid" />
  13. <result column="convert_factor" property="convertFactor" />
  14. <result column="price" property="price" />
  15. <result column="base_price" property="basePrice" />
  16. <result column="want_receive_date" property="wantReceiveDate" />
  17. <result column="tax_rate" property="taxRate" />
  18. <result column="tax" property="tax" />
  19. <result column="additional_cost" property="additionalCost" />
  20. <result column="freight" property="freight" />
  21. <result column="duty" property="duty" />
  22. <result column="arrive_qty" property="arriveQty" />
  23. <result column="receive_qty" property="receiveQty" />
  24. <result column="qty_returned" property="qtyReturned" />
  25. <result column="qty_replace" property="qtyReplace" />
  26. <result column="qty_scrapt" property="qtyScrapt" />
  27. <result column="invoice_qty" property="invoiceQty" />
  28. <result column="approve_result" property="approveResult" />
  29. <result column="need_inspect_flag" property="needInspectFlag" />
  30. <result column="remark" property="remark" />
  31. <result column="iqc_qty" property="iqcQty" />
  32. <result column="last_update_by" property="lastUpdateBy" />
  33. <result column="pr_convert_note" property="prConvertNote" />
  34. <result column="inspect_type_db" property="inspectTypeDb" />
  35. <result column="inspect_type" property="inspectType" />
  36. <result column="inspect_qty" property="inspectQty" />
  37. <result column="inspect_percent" property="inspectPercent" />
  38. <result column="inspection_level_no" property="inspectionLevelNo" />
  39. <result column="close_tolerance" property="closeTolerance" />
  40. <result column="over_receive_tolerance" property="overReceiveTolerance" />
  41. <result column="item" property="item" />
  42. <result column="c_value" property="value" />
  43. <result column="c_ship_qty" property="shipQty" />
  44. <result column="c_sum_price" property="sumPrice" />
  45. <result column="c_narrival" property="narrival" />
  46. <result column="c_crd" property="crd" />
  47. <result column="c_crd_ori" property="crdOri" />
  48. <result column="c_inspection" property="inspection" />
  49. <result column="c_real_crd" property="realCrd" />
  50. <result column="c_po_place_date" property="poPlaceDate" />
  51. <result column="c_po_promise_ready_date" property="poPromiseReadyDate" />
  52. <result column="c_po_actual_ready_date" property="poActualReadyDate" />
  53. <result column="c_china_office_inspection_date" property="chinaOfficeInspectionDate" />
  54. <result column="c_ship_to_npc_date" property="shipToNpcDate" />
  55. <result column="c_inspection_result" property="inspectionResult" />
  56. <result column="c_eta" property="eta" />
  57. <result column="c_flexid" property="flexid" />
  58. <result column="c_obd" property="obd" />
  59. <result column="c_doc_sent" property="docSent" />
  60. <result column="c_telex_release" property="telexRelease" />
  61. <result column="c_advance_payment" property="advancePayment" />
  62. <result column="c_advance_paid" property="advancePaid" />
  63. <result column="create_time" property="createTime" />
  64. <result column="c_planner" property="planner" />
  65. <result column="c_edit" property="edit" />
  66. <result column="c_end_planner" property="endPlanner" />
  67. <result column="c_remark_delay" property="remarkDelay" />
  68. <result column="c_customer" property="customer" />
  69. <result column="qty_cancelled" property="qtyCancelled" />
  70. <result column="inspect_method_db" property="inspectMethodDb" />
  71. <result column="to_inv_nofity_qty" property="toInvNofityQty" />
  72. <result column="upload_date" property="uploadDate" />
  73. <result column="order_ref1" property="orderRef1" />
  74. <result column="order_ref5" property="orderRef5" />
  75. <result column="batch_no" property="batchNo" />
  76. <result column="order_ref4" property="orderRef4" />
  77. <result column="pre_pay_amount" property="prePayAmount" />
  78. <result column="upload_by" property="uploadBy" />
  79. <result column="pur_lead_time" property="purLeadTime" />
  80. <result column="order_ref_type" property="orderRefType" />
  81. <result column="order_ref3" property="orderRef3" />
  82. <result column="need_receive_flag" property="needReceiveFlag" />
  83. <result column="upload_flag" property="uploadFlag" />
  84. <result column="id" property="id" />
  85. <result column="pre_pay_reverse_amount" property="prePayReverseAmount" />
  86. <result column="out_work_order_flag" property="outWorkOrderFlag" />
  87. <result column="order_ref2" property="orderRef2" />
  88. <result column="qty_rbjs" property="qtyRbjs" />
  89. <result column="pre_pay_pay_amount" property="prePayPayAmount" />
  90. <result column="need_date" property="needDate" />
  91. <result column="inspect_method" property="inspectMethod" />
  92. <result column="inv_notify_qty" property="invNotifyQty" />
  93. <result column="po_header_id" property="poHeaderId" />
  94. <result column="standard_tt" property="standardTt" />
  95. </resultMap>
  96. <!-- 通用查询结果列 -->
  97. <sql id="BaseColumnList">
  98. po_header_id, order_no, site, item_no, part_no, status, qty, umid, convert_factor, price, base_price, want_receive_date, tax_rate, tax, additional_cost, freight, duty, arrive_qty, receive_qty, qty_returned, qty_replace, qty_scrapt, invoice_qty, approve_result, need_inspect_flag, remark, iqc_qty, last_update_by, pr_convert_note, inspect_type_db, inspect_type, inspect_qty, inspect_percent, inspection_level_no, close_tolerance, over_receive_tolerance, item, c_value, c_ship_qty, c_sum_price, c_narrival, c_crd, c_crd_ori, c_inspection, c_real_crd, c_po_place_date, c_po_promise_ready_date, c_po_actual_ready_date, c_china_office_inspection_date, c_ship_to_npc_date, c_inspection_result, c_eta, c_flexid, c_obd, c_doc_sent, c_telex_release, c_advance_payment, c_advance_paid, create_time, c_planner, c_edit, c_end_planner, c_remark_delay, c_customer, qty_cancelled, inspect_method_db, to_inv_nofity_qty, upload_date, order_ref1, order_ref5, batch_no, order_ref4, pre_pay_amount, upload_by, pur_lead_time, order_ref_type, order_ref3, need_receive_flag, upload_flag, id, pre_pay_reverse_amount, out_work_order_flag, order_ref2, qty_rbjs, pre_pay_pay_amount, need_date, inspect_method, inv_notify_qty, standard_tt
  99. </sql>
  100. <select id="getListByModel" resultType="com.xujie.modules.order.vo.PODetailVo">
  101. select <include refid="BaseColumnList"/>
  102. from PODetail
  103. where site = #{site}
  104. <if test="poHeaderId != null and poHeaderId != '' "> and po_header_id = #{poHeaderId}</if>
  105. <if test="orderNo != null and orderNo != '' "> and order_no = #{orderNo}</if>
  106. <if test="itemNo != null "> and item_no = #{itemNo}</if>
  107. <if test="partNo != null and partNo != '' "> and part_no = #{partNo}</if>
  108. <if test="status != null and status != '' "> and status = #{status}</if>
  109. <if test="qty != null and qty != '' "> and qty = #{qty}</if>
  110. <if test="umid != null and umid != '' "> and umid = #{umid}</if>
  111. <if test="convertFactor != null and convertFactor != '' "> and convert_factor = #{convertFactor}</if>
  112. <if test="price != null and price != '' "> and price = #{price}</if>
  113. <if test="basePrice != null and basePrice != '' "> and base_price = #{basePrice}</if>
  114. <if test="wantReceiveDate != null and wantReceiveDate != '' "> and want_receive_date = #{wantReceiveDate}</if>
  115. <if test="taxRate != null and taxRate != '' "> and tax_rate = #{taxRate}</if>
  116. <if test="tax != null and tax != '' "> and tax = #{tax}</if>
  117. <if test="additionalCost != null and additionalCost != '' "> and additional_cost = #{additionalCost}</if>
  118. <if test="freight != null and freight != '' "> and freight = #{freight}</if>
  119. <if test="duty != null and duty != '' "> and duty = #{duty}</if>
  120. <if test="arriveQty != null and arriveQty != '' "> and arrive_qty = #{arriveQty}</if>
  121. <if test="receiveQty != null and receiveQty != '' "> and receive_qty = #{receiveQty}</if>
  122. <if test="qtyReturned != null and qtyReturned != '' "> and qty_returned = #{qtyReturned}</if>
  123. <if test="qtyReplace != null and qtyReplace != '' "> and qty_replace = #{qtyReplace}</if>
  124. <if test="qtyScrapt != null and qtyScrapt != '' "> and qty_scrapt = #{qtyScrapt}</if>
  125. <if test="invoiceQty != null and invoiceQty != '' "> and invoice_qty = #{invoiceQty}</if>
  126. <if test="approveResult != null and approveResult != '' "> and approve_result = #{approveResult}</if>
  127. <if test="needInspectFlag != null and needInspectFlag != '' "> and need_inspect_flag = #{needInspectFlag}</if>
  128. <if test="remark != null and remark != '' "> and remark = #{remark}</if>
  129. <if test="iqcQty != null and iqcQty != '' "> and iqc_qty = #{iqcQty}</if>
  130. <if test="lastUpdateBy != null and lastUpdateBy != '' "> and last_update_by = #{lastUpdateBy}</if>
  131. <if test="prConvertNote != null and prConvertNote != '' "> and pr_convert_note = #{prConvertNote}</if>
  132. <if test="inspectTypeDb != null and inspectTypeDb != '' "> and inspect_type_db = #{inspectTypeDb}</if>
  133. <if test="inspectType != null and inspectType != '' "> and inspect_type = #{inspectType}</if>
  134. <if test="inspectQty != null and inspectQty != '' "> and inspect_qty = #{inspectQty}</if>
  135. <if test="inspectPercent != null and inspectPercent != '' "> and inspect_percent = #{inspectPercent}</if>
  136. <if test="inspectionLevelNo != null and inspectionLevelNo != '' "> and inspection_level_no = #{inspectionLevelNo}</if>
  137. <if test="closeTolerance != null and closeTolerance != '' "> and close_tolerance = #{closeTolerance}</if>
  138. <if test="overReceiveTolerance != null and overReceiveTolerance != '' "> and over_receive_tolerance = #{overReceiveTolerance}</if>
  139. <if test="item != null and item != '' "> and item = #{item}</if>
  140. <if test="value != null and value != '' "> and c_value = #{value}</if>
  141. <if test="shipQty != null "> and c_ship_qty = #{shipQty}</if>
  142. <if test="sumPrice != null and sumPrice != '' "> and c_sum_price = #{sumPrice}</if>
  143. <if test="narrival != null and narrival != '' "> and c_narrival = #{narrival}</if>
  144. <if test="crd != null and crd != '' "> and c_crd = #{crd}</if>
  145. <if test="crdOri != null and crdOri != '' "> and c_crd_ori = #{crdOri}</if>
  146. <if test="inspection != null and inspection != '' "> and c_inspection = #{inspection}</if>
  147. <if test="realCrd != null and realCrd != '' "> and c_real_crd = #{realCrd}</if>
  148. <if test="poPlaceDate != null and poPlaceDate != '' "> and c_po_place_date = #{poPlaceDate}</if>
  149. <if test="poPromiseReadyDate != null and poPromiseReadyDate != '' "> and c_po_promise_ready_date = #{poPromiseReadyDate}</if>
  150. <if test="poActualReadyDate != null and poActualReadyDate != '' "> and c_po_actual_ready_date = #{poActualReadyDate}</if>
  151. <if test="chinaOfficeInspectionDate != null and chinaOfficeInspectionDate != '' "> and c_china_office_inspection_date = #{chinaOfficeInspectionDate}</if>
  152. <if test="shipToNpcDate != null and shipToNpcDate != '' "> and c_ship_to_npc_date = #{shipToNpcDate}</if>
  153. <if test="inspectionResult != null and inspectionResult != '' "> and c_inspection_result = #{inspectionResult}</if>
  154. <if test="eta != null and eta != '' "> and c_eta = #{eta}</if>
  155. <if test="flexid != null and flexid != '' "> and c_flexid = #{flexid}</if>
  156. <if test="obd != null and obd != '' "> and c_obd = #{obd}</if>
  157. <if test="docSent != null and docSent != '' "> and c_doc_sent = #{docSent}</if>
  158. <if test="telexRelease != null and telexRelease != '' "> and c_telex_release = #{telexRelease}</if>
  159. <if test="advancePayment != null and advancePayment != '' "> and c_advance_payment = #{advancePayment}</if>
  160. <if test="advancePaid != null and advancePaid != '' "> and c_advance_paid = #{advancePaid}</if>
  161. <if test="createTime != null and createTime != '' "> and create_time = #{createTime}</if>
  162. <if test="planner != null and planner != '' "> and c_planner = #{planner}</if>
  163. <if test="edit != null and edit != '' "> and c_edit = #{edit}</if>
  164. <if test="endPlanner != null and endPlanner != '' "> and c_end_planner = #{endPlanner}</if>
  165. <if test="remarkDelay != null and remarkDelay != '' "> and c_remark_delay = #{remarkDelay}</if>
  166. <if test="qtyCancelled != null and qtyCancelled != '' "> and qty_cancelled = #{qtyCancelled}</if>
  167. <if test="inspectMethodDb != null and inspectMethodDb != '' "> and inspect_method_db = #{inspectMethodDb}</if>
  168. <if test="toInvNofityQty != null and toInvNofityQty != '' "> and to_inv_nofity_qty = #{toInvNofityQty}</if>
  169. <if test="uploadDate != null and uploadDate != '' "> and upload_date = #{uploadDate}</if>
  170. <if test="orderRef1 != null and orderRef1 != '' "> and order_ref1 = #{orderRef1}</if>
  171. <if test="orderRef5 != null and orderRef5 != '' "> and order_ref5 = #{orderRef5}</if>
  172. <if test="batchNo != null and batchNo != '' "> and batch_no = #{batchNo}</if>
  173. <if test="orderRef4 != null and orderRef4 != '' "> and order_ref4 = #{orderRef4}</if>
  174. <if test="prePayAmount != null and prePayAmount != '' "> and pre_pay_amount = #{prePayAmount}</if>
  175. <if test="uploadBy != null and uploadBy != '' "> and upload_by = #{uploadBy}</if>
  176. <if test="purLeadTime != null and purLeadTime != '' "> and pur_lead_time = #{purLeadTime}</if>
  177. <if test="orderRefType != null and orderRefType != '' "> and order_ref_type = #{orderRefType}</if>
  178. <if test="orderRef3 != null and orderRef3 != '' "> and order_ref3 = #{orderRef3}</if>
  179. <if test="needReceiveFlag != null and needReceiveFlag != '' "> and need_receive_flag = #{needReceiveFlag}</if>
  180. <if test="uploadFlag != null and uploadFlag != '' "> and upload_flag = #{uploadFlag}</if>
  181. <if test="id != null "> and id = #{id}</if>
  182. <if test="prePayReverseAmount != null and prePayReverseAmount != '' "> and pre_pay_reverse_amount = #{prePayReverseAmount}</if>
  183. <if test="outWorkOrderFlag != null and outWorkOrderFlag != '' "> and out_work_order_flag = #{outWorkOrderFlag}</if>
  184. <if test="orderRef2 != null and orderRef2 != '' "> and order_ref2 = #{orderRef2}</if>
  185. <if test="qtyRbjs != null and qtyRbjs != '' "> and qty_rbjs = #{qtyRbjs}</if>
  186. <if test="prePayPayAmount != null and prePayPayAmount != '' "> and pre_pay_pay_amount = #{prePayPayAmount}</if>
  187. <if test="needDate != null and needDate != '' "> and need_date = #{needDate}</if>
  188. <if test="inspectMethod != null and inspectMethod != '' "> and inspect_method = #{inspectMethod}</if>
  189. <if test="invNotifyQty != null and invNotifyQty != '' "> and inv_notify_qty = #{invNotifyQty}</if>
  190. order by id desc
  191. </select>
  192. <select id="myPage" resultType="com.xujie.modules.order.vo.PODetailVo">
  193. select pod.po_header_id as poHeaderId, pod.order_no, pod.site, pod.item_no, pod.part_no, pod.status, pod.qty, pod.umid, pod.convert_factor, pod.price, pod.base_price, pod.want_receive_date, pod.tax_rate, pod.tax, pod.additional_cost, pod.freight, pod.duty, pod.arrive_qty, pod.receive_qty, pod.qty_returned, pod.qty_replace, pod.qty_scrapt, pod.invoice_qty, pod.approve_result, pod.need_inspect_flag, pod.remark, pod.iqc_qty, pod.last_update_by, pod.pr_convert_note, pod.inspect_type_db, pod.inspect_type, pod.inspect_qty, pod.inspect_percent, pod.inspection_level_no, pod.close_tolerance, pod.over_receive_tolerance
  194. ,pod.inspect_method_db, pod.to_inv_nofity_qty, pod.upload_date, pod.order_ref1, pod.order_ref5, pod.batch_no, pod.order_ref4, pod.pre_pay_amount, pod.upload_by, pod.pur_lead_time, pod.order_ref_type, pod.order_ref3, pod.need_receive_flag, pod.upload_flag, pod.id as id, pod.pre_pay_reverse_amount, pod.out_work_order_flag, pod.order_ref2, pod.qty_rbjs, pod.pre_pay_pay_amount, pod.need_date, pod.inspect_method, pod.inv_notify_qty, pod.standard_tt as standardTt
  195. ,COALESCE(p.item, pod.item) as item
  196. ,pod.c_value as value
  197. ,pod.c_ship_qty as shipQty
  198. ,pod.c_sum_price as sumPrice
  199. ,pod.c_narrival as narrival
  200. ,pod.c_crd as crd
  201. ,pod.c_crd_ori as crdOri
  202. ,pod.c_inspection as inspection
  203. ,pod.c_real_crd as realCrd
  204. ,pod.c_po_place_date as poPlaceDate
  205. ,pod.c_po_promise_ready_date as poPromiseReadyDate
  206. ,pod.c_po_actual_ready_date as poActualReadyDate
  207. ,pod.c_china_office_inspection_date as chinaOfficeInspectionDate
  208. ,pod.c_ship_to_npc_date as shipToNpcDate
  209. ,pod.c_inspection_result as inspectionResult
  210. ,pod.c_eta as eta
  211. ,pod.c_flexid as flexid
  212. ,pod.c_obd as obd
  213. ,pod.c_doc_sent as docSent
  214. ,pod.c_telex_release as telexRelease
  215. ,pod.c_advance_payment as advancePayment
  216. ,pod.c_advance_paid as advancePaid
  217. ,pod.create_time as createTime
  218. ,pod.c_planner as planner
  219. ,pod.c_edit as edit
  220. ,pod.c_end_planner as endPlanner
  221. ,pod.c_remark_delay as remarkDelay
  222. ,pod.qty_cancelled as qtyCancelled
  223. ,poh.c_customer as customer
  224. ,poh.buyer as buyer
  225. ,poh.supplier_no as supplierNo
  226. ,poh.po_no as poNo
  227. ,poh.order_type as orderType
  228. ,poh.c_departure as departure
  229. ,poh.c_destination as destination
  230. ,poh.ship_via as shipVia
  231. ,poh.order_date as orderDate
  232. ,poh.c_enquiry as enquiry
  233. ,poh.c_confirmed as confirmed
  234. ,poh.want_receive_date as headerWantReceiveDate
  235. ,ss.supplier_name as supplierName
  236. ,ss.c_short_office as shortOffice
  237. ,ss.c_short_npc as shortNpc
  238. ,p.category
  239. ,pf1.family_name as categoryName
  240. ,p.sku
  241. ,COALESCE(pod.to_inspect_qty, 0) AS toInspectQty
  242. ,COALESCE(pod.inspect_approve_qty, 0) AS inspectApproveQty
  243. ,COALESCE(pod.inspect_approve_qty, 0) AS inspectionCompletedQty
  244. ,(SELECT COALESCE(SUM(ds.qty), 0)
  245. FROM srm_inspection_request_header h
  246. LEFT JOIN srm_inspect_request_detail d ON h.request_no = d.request_no AND h.site = d.site
  247. LEFT JOIN srm_inspect_request_detail_sub ds ON d.request_no = ds.request_no AND d.site = ds.site AND d.item_no = ds.item_no
  248. WHERE h.site = pod.site
  249. AND h.supplier_no = poh.supplier_no
  250. AND ds.po_no = pod.order_no
  251. AND ds.po_item_no = pod.item_no
  252. AND d.status_db = 'Inspecting') AS inspectingQty
  253. from PODetail pod
  254. left join POHeader poh on poh.order_no = pod.order_no
  255. left join srm_supplier ss on ss.supplier_no = poh.supplier_no and ss.site = pod.site
  256. left join part p on p.part_no = pod.part_no and p.site = pod.site
  257. left join part_family pf1 on p.site = pf1.site and p.category = pf1.family_id
  258. where pod.site = '${query.site}'
  259. <if test="query.poHeaderId != null and query.poHeaderId != '' "> and pod.po_header_id like '%${query.poHeaderId}%'</if>
  260. <if test="query.orderNo != null and query.orderNo != '' "> and pod.order_no like '%${query.orderNo}%'</if>
  261. <if test="query.poNo != null and query.poNo != '' "> and poh.po_no like '%${query.poNo}%'</if>
  262. <if test="query.orderType != null and query.orderType != '' "> and poh.order_type = '${query.orderType}'</if>
  263. <if test="query.supplierNo != null and query.supplierNo != '' "> and poh.supplier_no like '%${query.supplierNo}%'</if>
  264. <if test="query.customer != null and query.customer != '' "> and poh.c_customer = #{query.customer}</if>
  265. <if test="query.buyer != null and query.buyer != '' "> and poh.buyer like '%${query.buyer}%'</if>
  266. <if test="query.itemNo != null "> and pod.item_no = '${query.itemNo}'</if>
  267. <if test="query.partNo != null and query.partNo != '' "> and pod.part_no like '%${query.partNo}%'</if>
  268. <if test="query.status != null and query.status != '' "> and pod.status like '%${query.status}%'</if>
  269. <if test="query.qty != null and query.qty != '' "> and pod.qty like '%${query.qty}%'</if>
  270. <if test="query.umid != null and query.umid != '' "> and pod.umid like '%${query.umid}%'</if>
  271. <if test="query.convertFactor != null and query.convertFactor != '' "> and pod.convert_factor like '%${query.convertFactor}%'</if>
  272. <if test="query.price != null and query.price != '' "> and pod.price like '%${query.price}%'</if>
  273. <if test="query.basePrice != null and query.basePrice != '' "> and pod.base_price like '%${query.basePrice}%'</if>
  274. <if test="query.wantReceiveDate != null "> and pod.want_receive_date like '%${query.wantReceiveDate}%'</if>
  275. <if test="query.taxRate != null and query.taxRate != '' "> and pod.tax_rate like '%${query.taxRate}%'</if>
  276. <if test="query.tax != null and query.tax != '' "> and pod.tax like '%${query.tax}%'</if>
  277. <if test="query.additionalCost != null and query.additionalCost != '' "> and pod.additional_cost like '%${query.additionalCost}%'</if>
  278. <if test="query.freight != null and query.freight != '' "> and pod.freight like '%${query.freight}%'</if>
  279. <if test="query.duty != null and query.duty != '' "> and pod.duty like '%${query.duty}%'</if>
  280. <if test="query.arriveQty != null and query.arriveQty != '' "> and pod.arrive_qty like '%${query.arriveQty}%'</if>
  281. <if test="query.receiveQty != null and query.receiveQty != '' "> and pod.receive_qty like '%${query.receiveQty}%'</if>
  282. <if test="query.qtyReturned != null and query.qtyReturned != '' "> and pod.qty_returned like '%${query.qtyReturned}%'</if>
  283. <if test="query.qtyReplace != null and query.qtyReplace != '' "> and pod.qty_replace like '%${query.qtyReplace}%'</if>
  284. <if test="query.qtyScrapt != null and query.qtyScrapt != '' "> and pod.qty_scrapt like '%${query.qtyScrapt}%'</if>
  285. <if test="query.invoiceQty != null and query.invoiceQty != '' "> and pod.invoice_qty like '%${query.invoiceQty}%'</if>
  286. <if test="query.approveResult != null and query.approveResult != '' "> and pod.approve_result like '%${query.approveResult}%'</if>
  287. <if test="query.needInspectFlag != null and query.needInspectFlag != '' "> and pod.need_inspect_flag like '%${query.needInspectFlag}%'</if>
  288. <if test="query.remark != null and query.remark != '' "> and pod.remark like '%${query.remark}%'</if>
  289. <if test="query.iqcQty != null and query.iqcQty != '' "> and pod.iqc_qty like '%${query.iqcQty}%'</if>
  290. <if test="query.lastUpdateBy != null and query.lastUpdateBy != '' "> and pod.last_update_by like '%${query.lastUpdateBy}%'</if>
  291. <if test="query.prConvertNote != null and query.prConvertNote != '' "> and pod.pr_convert_note like '%${query.prConvertNote}%'</if>
  292. <if test="query.inspectTypeDb != null and query.inspectTypeDb != '' "> and pod.inspect_type_db like '%${query.inspectTypeDb}%'</if>
  293. <if test="query.inspectType != null and query.inspectType != '' "> and pod.inspect_type like '%${query.inspectType}%'</if>
  294. <if test="query.inspectQty != null and query.inspectQty != '' "> and pod.inspect_qty like '%${query.inspectQty}%'</if>
  295. <if test="query.inspectPercent != null and query.inspectPercent != '' "> and pod.inspect_percent like '%${query.inspectPercent}%'</if>
  296. <if test="query.inspectionLevelNo != null and query.inspectionLevelNo != '' "> and pod.inspection_level_no like '%${query.inspectionLevelNo}%'</if>
  297. <if test="query.closeTolerance != null and query.closeTolerance != '' "> and pod.close_tolerance like '%${query.closeTolerance}%'</if>
  298. <if test="query.overReceiveTolerance != null and query.overReceiveTolerance != '' "> and pod.over_receive_tolerance like '%${query.overReceiveTolerance}%'</if>
  299. <if test="query.item != null and query.item != '' "> and COALESCE(p.item, pod.item) like '%${query.item}%'</if>
  300. <if test="query.value != null and query.value != '' "> and pod.c_value like '%${query.value}%'</if>
  301. <if test="query.shipQty != null "> and pod.c_ship_qty = '${query.shipQty}'</if>
  302. <if test="query.sumPrice != null and query.sumPrice != '' "> and pod.c_sum_price like '%${query.sumPrice}%'</if>
  303. <if test="query.narrival != null and query.narrival != '' "> and pod.c_narrival like '%${query.narrival}%'</if>
  304. <if test="query.crd != null and query.crd != '' "> and pod.c_crd like '%${query.crd}%'</if>
  305. <if test="query.crdOri != null and query.crdOri != '' "> and pod.c_crd_ori like '%${query.crdOri}%'</if>
  306. <if test="query.inspection != null and query.inspection != '' "> and pod.c_inspection like '%${query.inspection}%'</if>
  307. <if test="query.realCrd != null and query.realCrd != '' "> and pod.c_real_crd like '%${query.realCrd}%'</if>
  308. <if test="query.poPlaceDate != null and query.poPlaceDate != '' "> and pod.c_po_place_date like '%${query.poPlaceDate}%'</if>
  309. <if test="query.poPromiseReadyDate != null and query.poPromiseReadyDate != '' "> and pod.c_po_promise_ready_date like '%${query.poPromiseReadyDate}%'</if>
  310. <if test="query.poActualReadyDate != null and query.poActualReadyDate != '' "> and pod.c_po_actual_ready_date like '%${query.poActualReadyDate}%'</if>
  311. <if test="query.chinaOfficeInspectionDate != null and query.chinaOfficeInspectionDate != '' "> and pod.c_china_office_inspection_date like '%${query.chinaOfficeInspectionDate}%'</if>
  312. <if test="query.shipToNpcDate != null and query.shipToNpcDate != '' "> and pod.c_ship_to_npc_date like '%${query.shipToNpcDate}%'</if>
  313. <if test="query.inspectionResult != null and query.inspectionResult != '' "> and pod.c_inspection_result like '%${query.inspectionResult}%'</if>
  314. <if test="query.eta != null and query.eta != '' "> and pod.c_eta like '%${query.eta}%'</if>
  315. <if test="query.flexid != null and query.flexid != '' "> and pod.c_flexid like '%${query.flexid}%'</if>
  316. <if test="query.obd != null and query.obd != '' "> and pod.c_obd like '%${query.obd}%'</if>
  317. <if test="query.docSent != null and query.docSent != '' "> and pod.c_doc_sent like '%${query.docSent}%'</if>
  318. <if test="query.telexRelease != null and query.telexRelease != '' "> and pod.c_telex_release like '%${query.telexRelease}%'</if>
  319. <if test="query.advancePayment != null and query.advancePayment != '' "> and pod.c_advance_payment like '%${query.advancePayment}%'</if>
  320. <if test="query.advancePaid != null and query.advancePaid != '' "> and pod.c_advance_paid like '%${query.advancePaid}%'</if>
  321. <if test="query.createTime != null and query.createTime != '' "> and pod.create_time like '%${query.createTime}%'</if>
  322. <if test="query.planner != null and query.planner != '' "> and pod.c_planner like '%${query.planner}%'</if>
  323. <if test="query.edit != null and query.edit != '' "> and pod.c_edit like '%${query.edit}%'</if>
  324. <if test="query.endPlanner != null and query.endPlanner != '' "> and pod.c_end_planner like '%${query.endPlanner}%'</if>
  325. <if test="query.remarkDelay != null and query.remarkDelay != '' "> and pod.c_remark_delay like '%${query.remarkDelay}%'</if>
  326. <if test="query.qtyCancelled != null and query.qtyCancelled != '' "> and pod.qty_cancelled like '%${query.qtyCancelled}%'</if>
  327. <if test="query.inspectMethodDb != null and query.inspectMethodDb != '' "> and pod.inspect_method_db like '%${query.inspectMethodDb}%'</if>
  328. <if test="query.toInvNofityQty != null and query.toInvNofityQty != '' "> and pod.to_inv_nofity_qty like '%${query.toInvNofityQty}%'</if>
  329. <if test="query.uploadDate != null and query.uploadDate != '' "> and pod.upload_date like '%${query.uploadDate}%'</if>
  330. <if test="query.orderRef1 != null and query.orderRef1 != '' "> and pod.order_ref1 like '%${query.orderRef1}%'</if>
  331. <if test="query.orderRef5 != null and query.orderRef5 != '' "> and pod.order_ref5 like '%${query.orderRef5}%'</if>
  332. <if test="query.batchNo != null and query.batchNo != '' "> and pod.batch_no like '%${query.batchNo}%'</if>
  333. <if test="query.orderRef4 != null and query.orderRef4 != '' "> and pod.order_ref4 like '%${query.orderRef4}%'</if>
  334. <if test="query.prePayAmount != null and query.prePayAmount != '' "> and pod.pre_pay_amount like '%${query.prePayAmount}%'</if>
  335. <if test="query.uploadBy != null and query.uploadBy != '' "> and pod.upload_by like '%${query.uploadBy}%'</if>
  336. <if test="query.purLeadTime != null and query.purLeadTime != '' "> and pod.pur_lead_time like '%${query.purLeadTime}%'</if>
  337. <if test="query.orderRefType != null and query.orderRefType != '' "> and pod.order_ref_type like '%${query.orderRefType}%'</if>
  338. <if test="query.orderRef3 != null and query.orderRef3 != '' "> and pod.order_ref3 like '%${query.orderRef3}%'</if>
  339. <if test="query.needReceiveFlag != null and query.needReceiveFlag != '' "> and pod.need_receive_flag like '%${query.needReceiveFlag}%'</if>
  340. <if test="query.uploadFlag != null and query.uploadFlag != '' "> and pod.upload_flag like '%${query.uploadFlag}%'</if>
  341. <if test="query.id != null "> and pod.id = '${query.id}'</if>
  342. <if test="query.prePayReverseAmount != null and query.prePayReverseAmount != '' "> and pod.pre_pay_reverse_amount like '%${query.prePayReverseAmount}%'</if>
  343. <if test="query.outWorkOrderFlag != null and query.outWorkOrderFlag != '' "> and pod.out_work_order_flag like '%${query.outWorkOrderFlag}%'</if>
  344. <if test="query.orderRef2 != null and query.orderRef2 != '' "> and pod.order_ref2 like '%${query.orderRef2}%'</if>
  345. <if test="query.qtyRbjs != null and query.qtyRbjs != '' "> and pod.qty_rbjs like '%${query.qtyRbjs}%'</if>
  346. <if test="query.prePayPayAmount != null and query.prePayPayAmount != '' "> and pod.pre_pay_pay_amount like '%${query.prePayPayAmount}%'</if>
  347. <if test="query.needDate != null and query.needDate != '' "> and pod.need_date like '%${query.needDate}%'</if>
  348. <if test="query.inspectMethod != null and query.inspectMethod != '' "> and pod.inspect_method like '%${query.inspectMethod}%'</if>
  349. <if test="query.invNotifyQty != null and query.invNotifyQty != '' "> and pod.inv_notify_qty like '%${query.invNotifyQty}%'</if>
  350. <if test="query.sku != null and query.sku != '' "> and p.sku like '%${query.sku}%'</if>
  351. <if test="query.supplierName != null and query.supplierName != '' "> and ss.supplier_name like '%${query.supplierName}%'</if>
  352. order by pod.create_time desc, pod.order_no desc, pod.item_no desc
  353. </select>
  354. <!-- 高级查询:SELECT/FROM 与 myPage 一致,WHERE = 基础筛选 + validatedConditions 动态 AND -->
  355. <select id="myPageAdvanced" resultType="com.xujie.modules.order.vo.PODetailVo">
  356. select pod.po_header_id as poHeaderId, pod.order_no, pod.site, pod.item_no, pod.part_no, pod.status, pod.qty, pod.umid, pod.convert_factor, pod.price, pod.base_price, pod.want_receive_date, pod.tax_rate, pod.tax, pod.additional_cost, pod.freight, pod.duty, pod.arrive_qty, pod.receive_qty, pod.qty_returned, pod.qty_replace, pod.qty_scrapt, pod.invoice_qty, pod.approve_result, pod.need_inspect_flag, pod.remark, pod.iqc_qty, pod.last_update_by, pod.pr_convert_note, pod.inspect_type_db, pod.inspect_type, pod.inspect_qty, pod.inspect_percent, pod.inspection_level_no, pod.close_tolerance, pod.over_receive_tolerance
  357. ,pod.inspect_method_db, pod.to_inv_nofity_qty, pod.upload_date, pod.order_ref1, pod.order_ref5, pod.batch_no, pod.order_ref4, pod.pre_pay_amount, pod.upload_by, pod.pur_lead_time, pod.order_ref_type, pod.order_ref3, pod.need_receive_flag, pod.upload_flag, pod.id as id, pod.pre_pay_reverse_amount, pod.out_work_order_flag, pod.order_ref2, pod.qty_rbjs, pod.pre_pay_pay_amount, pod.need_date, pod.inspect_method, pod.inv_notify_qty, pod.standard_tt as standardTt
  358. ,COALESCE(p.item, pod.item) as item
  359. ,pod.c_value as value
  360. ,pod.c_ship_qty as shipQty
  361. ,pod.c_sum_price as sumPrice
  362. ,pod.c_narrival as narrival
  363. ,pod.c_crd as crd
  364. ,pod.c_crd_ori as crdOri
  365. ,pod.c_inspection as inspection
  366. ,pod.c_real_crd as realCrd
  367. ,pod.c_po_place_date as poPlaceDate
  368. ,pod.c_po_promise_ready_date as poPromiseReadyDate
  369. ,pod.c_po_actual_ready_date as poActualReadyDate
  370. ,pod.c_china_office_inspection_date as chinaOfficeInspectionDate
  371. ,pod.c_ship_to_npc_date as shipToNpcDate
  372. ,pod.c_inspection_result as inspectionResult
  373. ,pod.c_eta as eta
  374. ,pod.c_flexid as flexid
  375. ,pod.c_obd as obd
  376. ,pod.c_doc_sent as docSent
  377. ,pod.c_telex_release as telexRelease
  378. ,pod.c_advance_payment as advancePayment
  379. ,pod.c_advance_paid as advancePaid
  380. ,pod.create_time as createTime
  381. ,pod.c_planner as planner
  382. ,pod.c_edit as edit
  383. ,pod.c_end_planner as endPlanner
  384. ,pod.c_remark_delay as remarkDelay
  385. ,pod.qty_cancelled as qtyCancelled
  386. ,poh.c_customer as customer
  387. ,poh.buyer as buyer
  388. ,poh.supplier_no as supplierNo
  389. ,poh.po_no as poNo
  390. ,poh.order_type as orderType
  391. ,poh.c_departure as departure
  392. ,poh.c_destination as destination
  393. ,poh.ship_via as shipVia
  394. ,poh.order_date as orderDate
  395. ,poh.c_enquiry as enquiry
  396. ,poh.c_confirmed as confirmed
  397. ,poh.want_receive_date as headerWantReceiveDate
  398. ,ss.supplier_name as supplierName
  399. ,ss.c_short_office as shortOffice
  400. ,ss.c_short_npc as shortNpc
  401. ,p.category
  402. ,pf1.family_name as categoryName
  403. ,p.sku
  404. ,COALESCE(pod.to_inspect_qty, 0) AS toInspectQty
  405. ,COALESCE(pod.inspect_approve_qty, 0) AS inspectApproveQty
  406. ,COALESCE(pod.inspect_approve_qty, 0) AS inspectionCompletedQty
  407. ,(SELECT COALESCE(SUM(ds.qty), 0)
  408. FROM srm_inspection_request_header h
  409. LEFT JOIN srm_inspect_request_detail d ON h.request_no = d.request_no AND h.site = d.site
  410. LEFT JOIN srm_inspect_request_detail_sub ds ON d.request_no = ds.request_no AND d.site = ds.site AND d.item_no = ds.item_no
  411. WHERE h.site = pod.site
  412. AND h.supplier_no = poh.supplier_no
  413. AND ds.po_no = pod.order_no
  414. AND ds.po_item_no = pod.item_no
  415. AND d.status_db = 'Inspecting') AS inspectingQty
  416. from PODetail pod
  417. left join POHeader poh on poh.order_no = pod.order_no
  418. left join po_order_ext_value exv
  419. on exv.site = pod.site
  420. and exv.order_no = pod.order_no
  421. and exv.item_no = pod.item_no
  422. left join srm_supplier ss on ss.supplier_no = poh.supplier_no and ss.site = pod.site
  423. left join part p on p.part_no = pod.part_no and p.site = pod.site
  424. left join part_family pf1 on p.site = pf1.site and p.category = pf1.family_id
  425. where pod.site = #{query.site}
  426. <if test="query.customer != null and query.customer != ''"> and poh.c_customer = #{query.customer}</if>
  427. <if test="query.buyer != null and query.buyer != ''"> and poh.buyer like CONCAT('%', #{query.buyer}, '%')</if>
  428. <if test="query.poNo != null and query.poNo != ''"> and poh.po_no like CONCAT('%', #{query.poNo}, '%')</if>
  429. <if test="query.orderType != null and query.orderType != ''"> and poh.order_type = #{query.orderType}</if>
  430. <if test="query.supplierNo != null and query.supplierNo != ''"> and poh.supplier_no like CONCAT('%', #{query.supplierNo}, '%')</if>
  431. <if test="query.partNo != null and query.partNo != ''"> and pod.part_no like CONCAT('%', #{query.partNo}, '%')</if>
  432. <if test="query.status != null and query.status != ''"> and pod.status like CONCAT('%', #{query.status}, '%')</if>
  433. <if test="query.sku != null and query.sku != ''"> and p.sku like CONCAT('%', #{query.sku}, '%')</if>
  434. <if test="query.supplierName != null and query.supplierName != ''"> and ss.supplier_name like CONCAT('%', #{query.supplierName}, '%')</if>
  435. <if test="validatedConditions != null and validatedConditions.size() > 0">
  436. <foreach collection="validatedConditions" item="c">
  437. <choose>
  438. <when test="c.operator == 'contains'">
  439. AND CAST(${c.sqlExpression} AS NVARCHAR(500)) LIKE CONCAT('%', #{c.value}, '%')
  440. </when>
  441. <when test="c.operator == 'eq' and c.dataType == 'date'">
  442. AND CAST(${c.sqlExpression} AS DATE) = CAST(#{c.value} AS DATE)
  443. </when>
  444. <when test="c.operator == 'eq'">
  445. AND ${c.sqlExpression} = #{c.value}
  446. </when>
  447. <when test="c.operator == 'gt' and c.dataType == 'date'">
  448. AND CAST(${c.sqlExpression} AS DATE) &gt; CAST(#{c.value} AS DATE)
  449. </when>
  450. <when test="c.operator == 'gt'">
  451. AND ${c.sqlExpression} &gt; #{c.value}
  452. </when>
  453. <when test="c.operator == 'lt' and c.dataType == 'date'">
  454. AND CAST(${c.sqlExpression} AS DATE) &lt; CAST(#{c.value} AS DATE)
  455. </when>
  456. <when test="c.operator == 'lt'">
  457. AND ${c.sqlExpression} &lt; #{c.value}
  458. </when>
  459. <when test="c.operator == 'gte' and c.dataType == 'date'">
  460. AND CAST(${c.sqlExpression} AS DATE) &gt;= CAST(#{c.value} AS DATE)
  461. </when>
  462. <when test="c.operator == 'gte'">
  463. AND ${c.sqlExpression} &gt;= #{c.value}
  464. </when>
  465. <when test="c.operator == 'lte' and c.dataType == 'date'">
  466. AND CAST(${c.sqlExpression} AS DATE) &lt;= CAST(#{c.value} AS DATE)
  467. </when>
  468. <when test="c.operator == 'lte'">
  469. AND ${c.sqlExpression} &lt;= #{c.value}
  470. </when>
  471. </choose>
  472. </foreach>
  473. </if>
  474. order by pod.create_time desc, pod.order_no desc, pod.item_no desc
  475. </select>
  476. <update id="updatePoDetailForEdit">
  477. UPDATE PODetail
  478. <set>
  479. <if test="partNo != null">part_no = #{partNo},</if>
  480. <if test="status != null">status = #{status},</if>
  481. <if test="qty != null">qty = #{qty},</if>
  482. <if test="umid != null">umid = #{umid},</if>
  483. <if test="convertFactor != null">convert_factor = #{convertFactor},</if>
  484. <if test="price != null">price = #{price},</if>
  485. <if test="basePrice != null">base_price = #{basePrice},</if>
  486. <if test="wantReceiveDate != null">want_receive_date = #{wantReceiveDate},</if>
  487. <if test="taxRate != null">tax_rate = #{taxRate},</if>
  488. <if test="tax != null">tax = #{tax},</if>
  489. <if test="additionalCost != null">additional_cost = #{additionalCost},</if>
  490. <if test="freight != null">freight = #{freight},</if>
  491. <if test="duty != null">duty = #{duty},</if>
  492. <if test="arriveQty != null">arrive_qty = #{arriveQty},</if>
  493. <if test="receiveQty != null">receive_qty = #{receiveQty},</if>
  494. <if test="qtyReturned != null">qty_returned = #{qtyReturned},</if>
  495. <if test="qtyReplace != null">qty_replace = #{qtyReplace},</if>
  496. <if test="qtyScrapt != null">qty_scrapt = #{qtyScrapt},</if>
  497. <if test="invoiceQty != null">invoice_qty = #{invoiceQty},</if>
  498. <if test="approveResult != null">approve_result = #{approveResult},</if>
  499. <if test="needInspectFlag != null">need_inspect_flag = #{needInspectFlag},</if>
  500. <if test="remark != null">remark = #{remark},</if>
  501. <if test="iqcQty != null">iqc_qty = #{iqcQty},</if>
  502. <if test="lastUpdateBy != null">last_update_by = #{lastUpdateBy},</if>
  503. <if test="prConvertNote != null">pr_convert_note = #{prConvertNote},</if>
  504. <if test="inspectTypeDb != null">inspect_type_db = #{inspectTypeDb},</if>
  505. <if test="inspectType != null">inspect_type = #{inspectType},</if>
  506. <if test="inspectQty != null">inspect_qty = #{inspectQty},</if>
  507. <if test="inspectPercent != null">inspect_percent = #{inspectPercent},</if>
  508. <if test="inspectionLevelNo != null">inspection_level_no = #{inspectionLevelNo},</if>
  509. <if test="closeTolerance != null">close_tolerance = #{closeTolerance},</if>
  510. <if test="overReceiveTolerance != null">over_receive_tolerance = #{overReceiveTolerance},</if>
  511. <if test="item != null">item = #{item},</if>
  512. <if test="value != null">c_value = #{value},</if>
  513. <if test="shipQty != null">c_ship_qty = #{shipQty},</if>
  514. <if test="sumPrice != null">c_sum_price = #{sumPrice},</if>
  515. <if test="narrival != null">c_narrival = #{narrival},</if>
  516. <if test="crd != null">c_crd = #{crd},</if>
  517. <if test="crdOri != null">c_crd_ori = #{crdOri},</if>
  518. <if test="inspection != null">c_inspection = #{inspection},</if>
  519. <if test="realCrd != null">c_real_crd = #{realCrd},</if>
  520. <if test="poPlaceDate != null">c_po_place_date = #{poPlaceDate},</if>
  521. <if test="poPromiseReadyDate != null">c_po_promise_ready_date = #{poPromiseReadyDate},</if>
  522. <if test="poActualReadyDate != null">c_po_actual_ready_date = #{poActualReadyDate},</if>
  523. <if test="chinaOfficeInspectionDate != null">c_china_office_inspection_date = #{chinaOfficeInspectionDate},</if>
  524. <if test="shipToNpcDate != null">c_ship_to_npc_date = #{shipToNpcDate},</if>
  525. <if test="inspectionResult != null">c_inspection_result = #{inspectionResult},</if>
  526. <if test="eta != null">c_eta = #{eta},</if>
  527. <if test="flexid != null">c_flexid = #{flexid},</if>
  528. <if test="obd != null">c_obd = #{obd},</if>
  529. <if test="docSent != null">c_doc_sent = #{docSent},</if>
  530. <if test="telexRelease != null">c_telex_release = #{telexRelease},</if>
  531. <if test="advancePayment != null">c_advance_payment = #{advancePayment},</if>
  532. <if test="advancePaid != null">c_advance_paid = #{advancePaid},</if>
  533. <if test="planner != null">c_planner = #{planner},</if>
  534. <if test="edit != null">c_edit = #{edit},</if>
  535. <if test="endPlanner != null">c_end_planner = #{endPlanner},</if>
  536. <if test="remarkDelay != null">c_remark_delay = #{remarkDelay},</if>
  537. <if test="standardTt != null">standard_tt = #{standardTt},</if>
  538. <if test="orderRef1 != null">order_ref1 = #{orderRef1},</if>
  539. <if test="orderRef2 != null">order_ref2 = #{orderRef2},</if>
  540. </set>
  541. WHERE site = #{site}
  542. AND order_no = #{orderNo}
  543. AND item_no = #{itemNo}
  544. </update>
  545. <select id="selectByPK" resultMap="BaseResultMap">
  546. SELECT TOP 1 *
  547. FROM PODetail
  548. WHERE order_no = #{orderNo}
  549. AND site = #{site}
  550. AND item_no = #{itemNo}
  551. </select>
  552. <select id="getMaxItemNo" resultType="int">
  553. SELECT MAX(item_no)
  554. FROM PODetail
  555. WHERE order_no = #{poNo}
  556. AND site = #{site}
  557. </select>
  558. <select id="getMaxOrderRef2" resultType="java.lang.Integer">
  559. SELECT MAX(CAST(order_ref2 AS INT))
  560. FROM PODetail
  561. WHERE site = #{site}
  562. AND order_ref1 = #{orderRef1}
  563. AND order_ref2 IS NOT NULL
  564. AND order_ref2 &lt;&gt; ''
  565. AND ISNUMERIC(order_ref2) = 1
  566. </select>
  567. <select id="countByOrderRef" resultType="int">
  568. SELECT COUNT(1)
  569. FROM PODetail
  570. WHERE site = #{site}
  571. AND order_ref1 = #{orderRef1}
  572. AND order_ref2 = #{orderRef2}
  573. <if test="excludeOrderNo != null and excludeOrderNo != '' and excludeItemNo != null">
  574. AND NOT (order_no = #{excludeOrderNo} AND item_no = #{excludeItemNo})
  575. </if>
  576. </select>
  577. <select id="listConflictCustomersByOrderRef1" resultType="string">
  578. SELECT DISTINCT ISNULL(NULLIF(LTRIM(RTRIM(poh.c_customer)), ''), N'空值')
  579. FROM PODetail pod
  580. INNER JOIN POHeader poh
  581. ON poh.site = pod.site
  582. AND poh.order_no = pod.order_no
  583. WHERE pod.site = #{site}
  584. AND pod.order_ref1 = #{orderRef1}
  585. AND ISNULL(LTRIM(RTRIM(poh.c_customer)), '') &lt;&gt; ISNULL(LTRIM(RTRIM(#{customer})), '')
  586. ORDER BY ISNULL(NULLIF(LTRIM(RTRIM(poh.c_customer)), ''), N'空值')
  587. </select>
  588. <!-- 根据 PODetail 的 order_no + item_no 查询关联的验货申请明细(分页) -->
  589. <select id="getInspectionByPODetail" resultType="com.xujie.modules.order.vo.PODetailInspectionVO">
  590. SELECT
  591. sub.request_no AS requestNo,
  592. sub.item_no AS inspectItemNo,
  593. sub.qty AS inspectQty,
  594. sub.approve_qty AS approveQty,
  595. sub.order_ref1 AS orderRef1,
  596. sub.order_ref2 AS orderRef2,
  597. sub.ship_mothod AS shipMothod,
  598. sub.crd AS crd,
  599. d.part_no AS partNo,
  600. p.part_desc AS partDesc,
  601. d.status AS status,
  602. d.status_db AS statusDb,
  603. d.inspect_no AS inspectNo,
  604. d.inspect_result AS inspectResult
  605. FROM srm_inspect_request_detail_sub sub
  606. INNER JOIN srm_inspect_request_detail d
  607. ON sub.site = d.site
  608. AND sub.request_no = d.request_no
  609. AND sub.item_no = d.item_no
  610. LEFT JOIN part p
  611. ON sub.part_no = p.part_no
  612. AND sub.site = p.site
  613. <where>
  614. <if test="query.site != null and query.site != ''">
  615. AND sub.site = #{query.site}
  616. </if>
  617. <if test="query.orderNo != null and query.orderNo != ''">
  618. AND sub.po_no = #{query.orderNo}
  619. </if>
  620. <if test="query.itemNo != null">
  621. AND sub.po_item_no = #{query.itemNo}
  622. </if>
  623. </where>
  624. ORDER BY sub.request_no DESC, sub.item_no ASC
  625. </select>
  626. <!-- 原子扣减 inspect_approve_qty 字段 -->
  627. <update id="deductInspectApproveQty">
  628. UPDATE PODetail
  629. SET inspect_approve_qty = CASE
  630. WHEN COALESCE(inspect_approve_qty, 0) - #{deductQty} &lt; 0 THEN 0
  631. ELSE COALESCE(inspect_approve_qty, 0) - #{deductQty}
  632. END
  633. WHERE order_no = #{orderNo}
  634. AND site = #{site}
  635. AND item_no = #{itemNo}
  636. </update>
  637. <select id="getCustomerOptionList" resultType="com.xujie.modules.order.vo.PoCodeOptionVo">
  638. SELECT
  639. site,
  640. customer_code AS code,
  641. customer_name AS name,
  642. active,
  643. remark
  644. FROM po_customer
  645. WHERE site = #{site}
  646. AND active = 'Y'
  647. ORDER BY customer_code
  648. </select>
  649. <select id="getBuyerOptionList" resultType="com.xujie.modules.order.vo.PoCodeOptionVo">
  650. SELECT
  651. site,
  652. buyer_code AS code,
  653. buyer_name AS name,
  654. active,
  655. remark
  656. FROM po_buyer
  657. WHERE site = #{site}
  658. AND customer_code = #{customer}
  659. AND active = 'Y'
  660. ORDER BY buyer_code
  661. </select>
  662. <select id="getVisibleOrderDataByOrderNo" resultType="java.util.HashMap" statementType="CALLABLE">
  663. {CALL dbo.usp_po_order_visible_by_order_no(
  664. #{site,mode=IN,jdbcType=NVARCHAR},
  665. #{orderNo,mode=IN,jdbcType=NVARCHAR}
  666. )}
  667. </select>
  668. <select id="getVisibleOrderDataByOrderRef1" resultType="java.util.HashMap" statementType="CALLABLE">
  669. {CALL dbo.usp_po_order_visible_by_order_ref1(
  670. #{site,mode=IN,jdbcType=NVARCHAR},
  671. #{orderRef1,mode=IN,jdbcType=NVARCHAR}
  672. )}
  673. </select>
  674. </mapper>