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.

223 lines
9.5 KiB

6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.gaotao.modules.inboundNotification.dao.InboundNotificationDetailMapper">
  4. <!-- 验证标签与入库单是否匹配 -->
  5. <select id="validateLabelWithInbound" resultType="java.util.Map">
  6. SELECT top 1
  7. pr.roll_no as labelCode,
  8. pr.part_no as partNo,
  9. pr.roll_qty as quantity,
  10. pr.hardtag_in_flag as hardtagInFlag,
  11. pr.batch_no as batchNo
  12. FROM po_order_roll_no pr
  13. INNER JOIN inbound_notification_detail d ON pr.site = d.site and pr.bu_no = d.bu_no and pr.inspection_no = d.inspection_no AND pr.part_no = d.part_no
  14. WHERE pr.roll_no = #{labelCode}
  15. AND d.order_no = #{orderNo}
  16. AND pr.hardtag_in_flag = '未入库'
  17. AND pr.site = #{site}
  18. </select>
  19. <!-- 获取入库单的标签明细 -->
  20. <select id="getInboundLabelDetails" resultType="java.util.Map">
  21. SELECT
  22. pr.roll_no as labelCode,
  23. pr.part_no as partNo,
  24. pr.roll_qty as quantity,
  25. pr.hardtag_in_flag as hardtagInFlag
  26. FROM po_order_roll_no pr
  27. INNER JOIN inbound_notification_detail d ON pr.inspection_no = d.order_no AND pr.part_no = d.part_no
  28. WHERE pr.inspection_no = #{orderNo}
  29. AND pr.part_no = #{partNo}
  30. AND pr.hardtag_in_flag = '未入库'
  31. AND pr.site = #{site}
  32. ORDER BY pr.roll_no
  33. </select>
  34. <!-- 更新标签状态 -->
  35. <update id="updateLabelStatus">
  36. <if test="labelCodes != null and labelCodes.size() > 0">
  37. UPDATE po_order_roll_no
  38. SET hardtag_in_flag = #{status},
  39. updated_date = GETDATE(),
  40. update_by = 'SYSTEM'
  41. WHERE roll_no IN
  42. <foreach collection="labelCodes" item="labelCode" open="(" separator="," close=")">
  43. #{labelCode}
  44. </foreach>
  45. AND site = #{site}
  46. AND bu_no = #{buNo}
  47. </if>
  48. </update>
  49. <!-- 查询收获入库单明细 -->
  50. <select id="getInboundDetail" resultType="com.gaotao.modules.inboundNotification.entity.vo.InboundNotificationDetailVo" parameterType="com.gaotao.modules.inboundNotification.entity.vo.InboundNotificationDetailVo">
  51. SELECT
  52. a.site,
  53. a.bu_no,
  54. a.order_no,
  55. a.part_no,
  56. a.part_desc,
  57. a.unit,
  58. c.umName,
  59. a.required_qty,
  60. a.in_warehouse,
  61. b.WareHouseName as inWarehouseName,
  62. a.in_batch_no,
  63. a.created_by,
  64. a.created_date,
  65. a.updated_by,
  66. a.updated_date,
  67. a.order_qty,
  68. a.related_order_no,
  69. a.related_order_line_no,
  70. a.actual_in_qty as actualStockInQty,
  71. a.roll_no
  72. FROM inbound_notification_detail as a
  73. left join WareHouse as b on a.site = b.site and a.bu_no = b.bu_no and a.in_warehouse = b.WareHouseID
  74. left join um as c on a.site = c.site and a.unit = c.UMID
  75. <where>
  76. a.site = #{site} and a.bu_no = #{buNo} and a.order_no = #{orderNo}
  77. <if test = "partNo != null and partNo != ''">
  78. AND a.part_no = #{partNo}
  79. </if>
  80. </where>
  81. </select>
  82. <!-- 删除收获入库单明细 -->
  83. <delete id="deleteInboundDetail" parameterType="com.gaotao.modules.inboundNotification.entity.vo.InboundNotificationDetailVo">
  84. DELETE FROM inbound_notification_detail
  85. WHERE site = #{site} and bu_no = #{buNo} and order_no = #{orderNo} and part_no = #{partNo}
  86. <if test="rollNo != null and rollNo != ''">
  87. AND roll_no = #{rollNo}
  88. </if>
  89. </delete>
  90. <insert id="saveInboundDetails">
  91. INSERT INTO inbound_notification_detail
  92. (site, bu_no, order_no, part_no, part_desc, unit, required_qty,
  93. in_warehouse, in_batch_no, created_by, created_date, order_qty,
  94. related_order_no, related_order_line_no, inspection_no, order_item_no, roll_no)
  95. VALUES
  96. <foreach collection="list" item="detail" separator=",">
  97. (#{detail.site}, #{detail.buNo}, #{detail.orderNo}, #{detail.partNo}, #{detail.partDesc}, #{detail.unit}, #{detail.requiredQty,jdbcType=FLOAT},
  98. #{detail.inWarehouse}, #{detail.inBatchNo}, #{detail.createdBy}, GETDATE(), #{detail.orderQty,jdbcType=FLOAT},
  99. #{detail.relatedOrderNo}, #{detail.relatedOrderLineNo}, #{detail.inspectionNo}, #{detail.orderItemNo}, #{detail.rollNo})
  100. </foreach>
  101. </insert>
  102. <select id="getInboundPartList" resultType="com.gaotao.modules.pms.entity.vo.PartInformationVo">
  103. SELECT
  104. a.site,
  105. a.bu_no,
  106. a.PartNo,
  107. a.PartDescription as partDesc,
  108. a.UMID as unit,
  109. a.inbound_warehouse_id as inboundWarehouseId
  110. FROM part as a
  111. left join inbound_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}
  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="deleteInboundDetailByHead">
  125. DELETE FROM inbound_notification_detail
  126. WHERE site = #{site} AND bu_no = #{buNo} AND order_no = #{orderNo}
  127. </delete>
  128. <update id="updateInboundDetails" parameterType="java.util.List">
  129. UPDATE inbound_notification_detail
  130. SET
  131. required_qty = CASE
  132. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  133. WHEN (roll_no = #{item.rollNo} OR (ISNULL(roll_no, '') = '' AND part_no = #{item.partNo})) THEN #{item.requiredQty,jdbcType=DOUBLE}
  134. </foreach>
  135. ELSE required_qty
  136. END,
  137. in_warehouse = CASE
  138. <foreach item="item" index="index" collection="list" open="" close="" separator=" ">
  139. WHEN (roll_no = #{item.rollNo} OR (ISNULL(roll_no, '') = '' AND part_no = #{item.partNo})) THEN #{item.inWarehouse}
  140. </foreach>
  141. ELSE in_warehouse
  142. END
  143. WHERE site = #{list[0].site} AND bu_no = #{list[0].buNo} AND order_no = #{list[0].orderNo}
  144. AND (
  145. roll_no IN
  146. <foreach item="item" index="index" collection="list" open="(" separator="," close=")">
  147. #{item.rollNo}
  148. </foreach>
  149. OR (ISNULL(roll_no, '') = '' AND part_no IN
  150. <foreach item="item" index="index" collection="list" open="(" separator="," close=")">
  151. #{item.partNo}
  152. </foreach>
  153. )
  154. )
  155. </update>
  156. <select id="getInboundDetail2" resultType="com.gaotao.modules.trans.entity.TransDetailSub" statementType="CALLABLE">
  157. {call GetWarehouseEntryAndExitDetails(
  158. #{site, mode=IN, jdbcType=VARCHAR},
  159. #{buNo, mode=IN, jdbcType=VARCHAR},
  160. #{orderNo, mode=IN, jdbcType=VARCHAR},
  161. #{orderType, mode=IN, jdbcType=VARCHAR},
  162. #{relatedOrderNo, mode=IN, jdbcType=VARCHAR},
  163. #{relatedOrderLineNo, mode=IN, jdbcType=VARCHAR},
  164. #{partNo, mode=IN, jdbcType=VARCHAR}
  165. )}
  166. </select>
  167. <select id="getInboundShopOrderList" resultType="com.gaotao.modules.inboundNotification.entity.vo.InboundNotificationDetailVo">
  168. SELECT
  169. a.Site,
  170. a.bu_no,
  171. a.OrderNo as related_order_no,
  172. a.PartNo,
  173. c.PartDescription as partDesc,
  174. c.UMID as unit,
  175. a.status,
  176. a.LotSize as order_qty,
  177. pr.RollNo as rollNo,
  178. pr.RollQty as requiredQty,
  179. pr.remark,
  180. c.inbound_warehouse_id as inboundWarehouseId
  181. FROM ShopOrder a
  182. INNER JOIN SFDC_Rolls pr ON a.site = pr.site AND a.bu_no = pr.bu_no AND a.OrderNo = pr.OrderNo
  183. LEFT JOIN inbound_notification_detail b ON pr.Site = b.site AND pr.bu_no = b.bu_no AND pr.OrderNo = b.related_order_no AND pr.RollNo = b.roll_no
  184. INNER JOIN Part c on a.Site = c.Site and a.bu_no = c.bu_no and a.PartNo = c.PartNo
  185. WHERE a.site = #{query.site} and a.bu_no = #{query.buNo} and pr.status = '待入库' AND b.site IS NULL AND pr.RollType <![CDATA[<>]]> '删除卷'
  186. AND pr.RollNo NOT IN
  187. <foreach collection="query.arr" close=")" open="(" item="item" separator=",">
  188. #{item}
  189. </foreach>
  190. <if test = "query.relatedOrderNo != null and query.relatedOrderNo != ''">
  191. AND a.OrderNo like '%' + #{query.relatedOrderNo} + '%'
  192. </if>
  193. <if test = "query.partNo != null and query.partNo != ''">
  194. AND a.partNo like '%' + #{query.partNo} + '%'
  195. </if>
  196. <if test = "query.partDesc != null and query.partDesc != ''">
  197. AND c.PartDescription like '%' + #{query.partDesc} + '%'
  198. </if>
  199. <if test = "query.status != null and query.status != ''">
  200. AND a.status = #{query.status}
  201. </if>
  202. ORDER BY a.OrderNo, pr.RollNo
  203. </select>
  204. <select id="getMaxLineNo" resultType="java.lang.Integer">
  205. SELECT
  206. MAX(order_item_no)
  207. FROM inbound_notification_detail
  208. WHERE site = #{site} AND bu_no = #{buNo} AND order_no = #{orderNo}
  209. </select>
  210. </mapper>