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.

202 lines
8.4 KiB

2 months ago
2 months ago
2 months ago
2 months ago
2 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.gaotao.modules.outboundNotification.dao.OutboundNotificationDetailMapper">
  4. <!-- 查询拣货出库单明细 -->
  5. <select id="getOutboundDetail" resultType="com.gaotao.modules.outboundNotification.entity.vo.OutboundNotificationDetailVo" parameterType="com.gaotao.modules.outboundNotification.entity.vo.OutboundNotificationDetailVo">
  6. SELECT
  7. a.site,
  8. a.bu_no,
  9. a.order_no,
  10. a.part_no,
  11. a.part_desc,
  12. a.unit,
  13. c.umName,
  14. a.required_qty,
  15. a.out_warehouse,
  16. b.WareHouseName as outWarehouseName,
  17. a.out_batch_no,
  18. a.created_by,
  19. a.created_date,
  20. a.updated_by,
  21. a.updated_date,
  22. a.order_qty,
  23. a.related_order_no,
  24. a.related_order_line_no,
  25. a.actual_out_qty as actualStockOutQty
  26. FROM outbound_notification_detail as a
  27. left join WareHouse as b on a.site = b.site and a.bu_no = b.bu_no and a.out_warehouse = b.WareHouseID
  28. left join um as c on a.site = c.site and a.unit = c.UMID
  29. <where>
  30. a.site = #{site} and a.bu_no = #{buNo} and a.order_no = #{orderNo}
  31. <if test = "partNo != null and partNo != ''">
  32. AND a.part_no = #{partNo}
  33. </if>
  34. </where>
  35. </select>
  36. <select id="getOutboundDetailWithRoll" resultType="com.gaotao.modules.outboundNotification.entity.vo.OutboundNotificationDetailVo" parameterType="com.gaotao.modules.outboundNotification.entity.vo.OutboundNotificationDetailVo">
  37. SELECT
  38. a.site,
  39. a.bu_no,
  40. a.order_no,
  41. a.part_no,
  42. a.part_desc,
  43. a.unit,
  44. a.required_qty,
  45. a.out_warehouse,
  46. a.out_batch_no,
  47. a.created_by,
  48. a.created_date,
  49. a.updated_by,
  50. a.updated_date,
  51. a.order_qty,
  52. a.related_order_no,
  53. a.related_order_line_no,
  54. isnull(sum(c.roll_qty),0) as rollQty,
  55. case when a.required_qty-isnull(sum(c.roll_qty),0)>0 then Round( a.required_qty-isnull(sum(c.roll_qty),0),3)
  56. else 0 end as unScanQty
  57. FROM outbound_notification_detail as a
  58. left join so_receive_boxes b on a.site=b.site and a.bu_no=b.bu_no and a.order_no=b.order_no
  59. left join so_receive_box_rolls c on a.site=c.site and a.bu_no=c.bu_no and b.box_no=c.box_no and a.part_no=c.part_no
  60. <where>
  61. a.site = #{site} and a.bu_no = #{buNo} and a.order_no = #{orderNo}
  62. <if test = "partNo != null and partNo != ''">
  63. AND a.part_no = #{partNo}
  64. </if>
  65. </where>
  66. GROUP BY
  67. a.site,
  68. a.bu_no,
  69. a.order_no,
  70. a.part_no,
  71. a.part_desc,
  72. a.unit,
  73. a.required_qty,
  74. a.out_warehouse,
  75. a.out_batch_no,
  76. a.created_by,
  77. a.created_date,
  78. a.updated_by,
  79. a.updated_date,
  80. a.order_qty,
  81. a.related_order_no, a.related_order_line_no
  82. </select>
  83. <!-- 删除拣货出库单明细 -->
  84. <delete id="deleteOutboundDetail" parameterType="com.gaotao.modules.outboundNotification.entity.vo.OutboundNotificationDetailVo">
  85. DELETE FROM outbound_notification_detail
  86. WHERE site = #{site} and bu_no = #{buNo} and order_no = #{orderNo} and part_no = #{partNo}
  87. </delete>
  88. <insert id="saveOutboundDetails">
  89. INSERT INTO outbound_notification_detail
  90. (site, bu_no, order_no, part_no, part_desc, unit, required_qty, out_warehouse,
  91. out_batch_no, created_by, created_date, order_qty, related_order_no, related_order_line_no)
  92. VALUES
  93. <foreach collection="list" item="detail" separator=",">
  94. (#{detail.site}, #{detail.buNo}, #{detail.orderNo}, #{detail.partNo}, #{detail.partDesc},
  95. #{detail.unit}, #{detail.requiredQty,jdbcType=FLOAT}, #{detail.outWarehouse},
  96. #{detail.outBatchNo}, #{detail.createdBy}, GETDATE(), #{detail.orderQty,jdbcType=FLOAT},
  97. #{detail.relatedOrderNo}, #{detail.relatedOrderLineNo})
  98. </foreach>
  99. </insert>
  100. <select id="getOutboundPartList" resultType="com.gaotao.modules.pms.entity.vo.PartInformationVo">
  101. SELECT
  102. a.site,
  103. a.bu_no,
  104. a.PartNo,
  105. a.PartDescription as partDesc,
  106. a.UMID as unit,
  107. um.umName,
  108. a.outbound_warehouse_id as outboundWarehouseId
  109. FROM part as a
  110. left join outbound_notification_detail as b on a.site = b.site and a.bu_no = b.bu_no and a.partNo = b.part_no and b.order_no = #{query.orderNo}
  111. left join um as um on a.site = um.site and a.UMID = um.UMID
  112. where a.site = #{query.site} and a.bu_no = #{query.buNo} and b.site is null
  113. and a.PartNo not in
  114. <foreach collection="query.arr" close=")" open="(" item="item" separator=",">
  115. #{item}
  116. </foreach>
  117. <if test = "query.partNo != null and query.partNo != ''">
  118. AND a.partNo like '%' + #{query.partNo} + '%'
  119. </if>
  120. <if test = "query.partDesc != null and query.partDesc != ''">
  121. AND a.PartDescription like '%' + #{query.partDesc} + '%'
  122. </if>
  123. </select>
  124. <delete id="deleteOutboundDetailByHead">
  125. DELETE FROM outbound_notification_detail
  126. WHERE site = #{site} AND bu_no = #{buNo} AND order_no = #{orderNo}
  127. </delete>
  128. <update id="updateOutboundDetails" parameterType="java.util.List">
  129. UPDATE outbound_notification_detail
  130. SET
  131. required_qty = CASE
  132. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  133. WHEN part_no = #{item.partNo} THEN #{item.requiredQty,jdbcType=DOUBLE}
  134. </foreach>
  135. ELSE required_qty
  136. END,
  137. out_warehouse = CASE
  138. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  139. WHEN part_no = #{item.partNo} THEN #{item.outWarehouse}
  140. </foreach>
  141. ELSE out_warehouse
  142. END
  143. WHERE part_no IN
  144. <foreach item="item" index="index" collection="list" open="(" separator="," close=")">
  145. #{item.partNo}
  146. </foreach>
  147. AND site = #{list[0].site} and bu_no = #{list[0].buNo} and order_no = #{list[0].orderNo}
  148. </update>
  149. <select id="getOutboundDetail2" resultType="com.gaotao.modules.trans.entity.TransDetailSub" statementType="CALLABLE">
  150. {call GetWarehouseEntryAndExitDetails(
  151. #{site, mode=IN, jdbcType=VARCHAR},
  152. #{buNo, mode=IN, jdbcType=VARCHAR},
  153. #{orderNo, mode=IN, jdbcType=VARCHAR},
  154. #{orderType, mode=IN, jdbcType=VARCHAR},
  155. #{relatedOrderNo, mode=IN, jdbcType=VARCHAR},
  156. #{relatedOrderLineNo, mode=IN, jdbcType=VARCHAR},
  157. #{partNo, mode=IN, jdbcType=VARCHAR}
  158. )}
  159. </select>
  160. <select id="getOutboundShopOrderList" resultType="com.gaotao.modules.outboundNotification.entity.vo.OutboundNotificationDetailVo">
  161. SELECT
  162. a.Site,
  163. a.bu_no,
  164. a.Order_No as related_order_no,
  165. a.item_no as related_order_line_no,
  166. a.Part_No,
  167. a.part_desc as partDesc,
  168. a.order_qty,
  169. b.umid as unit,
  170. um.umName,
  171. SUM(a.roll_qty) AS requiredQty -- 可出库数量
  172. FROM po_order_roll_no a
  173. INNER JOIN part b WITH (NOLOCK) ON a.site = b.site AND a.part_no = b.partno
  174. LEFT JOIN inventory_stock c WITH (NOLOCK) ON a.site = c.site AND a.roll_no = c.roll_no AND (c.status IN ('在库', '冻结') OR A.hardtag_in_flag ='未入库')
  175. left join um as um on a.site = um.site and b.umid = um.umid
  176. where a.site = #{query.site} and a.bu_no = #{query.buNo}
  177. and a.Part_No not in
  178. <foreach collection="query.arr" close=")" open="(" item="item" separator=",">
  179. #{item}
  180. </foreach>
  181. <if test = "query.relatedOrderNo != null and query.relatedOrderNo != ''">
  182. AND a.Order_No like '%' + #{query.relatedOrderNo} + '%'
  183. </if>
  184. <if test = "query.partNo != null and query.partNo != ''">
  185. AND a.Part_No like '%' + #{query.partNo} + '%'
  186. </if>
  187. <if test = "query.partDesc != null and query.partDesc != ''">
  188. AND a.part_desc like '%' + #{query.partDesc} + '%'
  189. </if>
  190. GROUP BY a.Site, a.bu_no, a.Order_No, a.item_no, a.Part_No, a.part_desc, a.order_qty, b.umid, um.umName
  191. </select>
  192. </mapper>