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.

191 lines
8.0 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
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.productionPicking.dao.ProductionPickingMapper">
  4. <!-- 获取生产出库单列表 -->
  5. <select id="getOutboundList" resultType="java.util.Map">
  6. select
  7. b.site,
  8. b.NotifyNo as outboundNo,
  9. b.bu AS buNo,
  10. '' AS relatedNo,
  11. '' AS relatedLineNo,
  12. 0 as totalLabels,
  13. 0 as availableLabels,
  14. SUM(CAST(a.QtyToIssue AS float)) as totalQty,
  15. 0 as availableQty ,
  16. b.NotifyDate as required_outbound_date,
  17. 0 AS pickedLabels,
  18. 0 AS pickedQty
  19. from SOIssueNotifyHeader B
  20. INNER JOIN SOIssueNotifyOrderMaterialList a ON A.SITE = B.SITE AND A.NotifyNo = B.NotifyNo
  21. INNER JOIN SOIssueNotifyOrderList D ON A.SITE = D.SITE AND A.NotifyNo = D.NotifyNo AND D.ItemNo = A.ItemNo
  22. where a.site = #{site} and b.bu in (select bu_no from AccessBu where username = #{userName})
  23. AND b.Status = '待出库'
  24. AND a.warehouse_id = #{warehouseId}
  25. <if test="searchCode != null and searchCode != ''">
  26. AND (b.NotifyNo LIKE CONCAT('%', #{searchCode}, '%') or D.SOOrderNo LIKE CONCAT('%', #{searchCode}, '%'))
  27. </if>
  28. <!-- <if test="searchCode == null or searchCode == ''">-->
  29. <!-- AND CONVERT(DATE, b.NotifyDate) = CONVERT(DATE, GETDATE())-->
  30. <!-- </if>-->
  31. GROUP BY
  32. b.site, b.NotifyNo, b.bu ,b.NotifyDate
  33. ORDER BY b.NotifyDate DESC
  34. </select>
  35. <!-- 获取出库单详情 -->
  36. <select id="getOutboundDetails" resultType="java.util.Map">
  37. select
  38. b.site,
  39. b.NotifyNo as outboundNo,
  40. b.bu AS buNo,
  41. #{relatedNo} AS relatedNo,
  42. '' AS relatedLineNo,
  43. 0 as totalLabels,
  44. 0 as availableLabels,
  45. SUM(CAST(a.QtyToIssue AS float)) as totalQty,
  46. 0 as availableQty ,
  47. b.NotifyDate as required_outbound_date,
  48. 0 AS pickedLabels,
  49. 0 AS pickedQty
  50. from SOIssueNotifyHeader B
  51. INNER JOIN SOIssueNotifyOrderMaterialList a ON A.SITE = B.SITE AND A.NotifyNo = B.NotifyNo
  52. WHERE b.site = #{site}
  53. AND b.bu = #{buNo}
  54. AND b.NotifyNo = #{outboundNo}
  55. AND a.warehouse_id = #{warehouseId}
  56. GROUP BY b.site, b.NotifyNo, b.bu ,b.NotifyDate
  57. </select>
  58. <!-- 验证标签与出库单是否匹配 -->
  59. <select id="validateLabelWithOutbound" resultType="java.util.Map">
  60. select
  61. inv.roll_no AS labelCode,
  62. inv.part_no AS partNo,
  63. inv.qty_on_hand AS quantity,
  64. inv.batch_no AS batchNo,
  65. inv.status AS status,
  66. inv.warehouse_id AS warehouseId,
  67. inv.location_id AS locationId
  68. from inventory_stock inv
  69. inner join (select t.site, ComponentPartNo,sum(QtyToIssue) as QtyToIssue from SOIssueNotifyOrderMaterialList t
  70. inner join SOIssueNotifyOrderList b on t.site = b.site and t.NotifyNo = b.notifyno and t.ItemNo = b.itemno
  71. WHERE t.site = #{site} and t.NotifyNo = #{outboundNo} and b.soorderno = #{relatedNo} group by t.site, ComponentPartNo)
  72. a on A.site = inv.site and A.ComponentPartNo = inv.part_no
  73. WHERE
  74. inv.site = #{site}
  75. AND inv.parent_roll_no =#{labelCode}
  76. AND inv.warehouse_id = #{warehouseId}
  77. AND inv.status = '在库'
  78. AND inv.qty_on_hand > 0
  79. </select>
  80. <!-- 更新出库单状态 -->
  81. <update id="updateOutboundStatus">
  82. UPDATE inventory_stock
  83. SET STATUS = #{status},
  84. status_tb = 'E',
  85. LATEST_OUT_DATE = getDate()
  86. WHERE ROLL_NO IN
  87. <foreach collection="labelCodes" item="labelCode" open="(" separator="," close=")">
  88. #{labelCode}
  89. </foreach>
  90. AND SITE = #{site}
  91. <if test="buNo != null and buNo != ''">
  92. AND BU_NO = #{buNo}
  93. </if>
  94. </update>
  95. <!-- 获取出库单物料清单 -->
  96. <select id="getMaterialList" resultType="java.util.Map">
  97. select
  98. b.site,
  99. b.NotifyNo as outboundNo,
  100. b.bu AS buNo,
  101. a.ComponentPartNo AS partNo,
  102. P.PartDescription AS partDesc,
  103. SUM(CAST(a.QtyToIssue AS float)) as requiredQty,
  104. sum(ISNULL(a.actual_out_qty,0)) as pickedQty ,
  105. SUM(ISNULL(S.RollQty,0)) as scansQty --本次扫描数量
  106. from SOIssueNotifyHeader B
  107. INNER JOIN SOIssueNotifyOrderList C ON B.SITE = C.SITE AND B.NotifyNo = C.NotifyNo
  108. INNER JOIN SOIssueNotifyOrderMaterialList a ON A.SITE = C.SITE AND A.NotifyNo = C.NotifyNo AND C.ItemNo = A.ItemNo
  109. INNER JOIN PART P ON A.SITE = P.SITE AND A.ComponentPartNo = P.PARTNO
  110. LEFT JOIN ScannedRollTempTable S ON A.Site = S.site AND A.ComponentPartNo = S.part_no AND C.SOOrderNo = S.OrderNo
  111. where a.site = #{site}
  112. <if test="buNo != null and buNo != ''">
  113. AND b.bu = #{buNo}
  114. </if>
  115. AND b.Status = '待出库'
  116. AND a.warehouse_id = #{warehouseId}
  117. AND B.NotifyNo = #{outboundNo}
  118. AND C.SOOrderNo = #{relatedNo}
  119. GROUP BY b.site, b.NotifyNo, b.bu , a.ComponentPartNo, P.PartDescription
  120. </select>
  121. <!-- 获取出库单物料明细列表 -->
  122. <select id="getOutboundMaterialDetails" resultType="java.util.Map">
  123. SELECT
  124. A.Site as site,
  125. A.NotifyNo as outboundNo, -- 出库单号
  126. A.SOOrderNo as orderNo, -- 工单号
  127. A.FGPartNo as partNo, -- 物料编码
  128. B.PartDescription as partDescription, -- 物料名称
  129. A.IssureQty as requiredQty, -- 需求数量
  130. b.UMID AS umId, -- 计量单位
  131. SUM (C.QtyToIssue) as pickedQty, --
  132. SUM (ISNULL(D.roll_qty, 0)) as totalQty
  133. FROM SOIssueNotifyOrderList A
  134. INNER JOIN PART B ON A.SITE = B.SITE AND A.FGPartNo = B.PartNo
  135. INNER JOIN SOIssueNotifyOrderMaterialList C ON A.SITE = B.SITE AND A.NotifyNo = C.NotifyNo AND A.ItemNo = C.ItemNo
  136. LEFT JOIN StockTransactionLog D ON C.SITE = D.SITE AND C.NotifyNo = D.document_no AND A.SOOrderNo = D.order_line_no
  137. WHERE A.site = #{site} AND a.NotifyNo = #{outboundNo}
  138. GROUP BY A.Site, A.NotifyNo, A.FGPartNo, B.PartDescription, A.IssureQty, b.UMID, A.SOOrderNo
  139. </select>
  140. <select id="getByRollNo" resultType="com.gaotao.modules.inventoryStock.entity.InventoryStock">
  141. select
  142. inv.roll_no AS labelCode,
  143. inv.part_no AS partNo,
  144. inv.qty_on_hand AS qty_on_hand,
  145. inv.batch_no AS batchNo,
  146. inv.status AS status,
  147. inv.warehouse_id AS warehouseId,
  148. inv.location_id AS locationId
  149. from inventory_stock inv
  150. inner join (select site,ComponentPartNo,sum(QtyToIssue) as QtyToIssue from SOIssueNotifyOrderMaterialList t
  151. WHERE site = #{site} and NotifyNo = #{outboundNo} group by site,ComponentPartNo) a on A.site = inv.site and A.ComponentPartNo = inv.part_no
  152. WHERE
  153. inv.site = #{site}
  154. AND inv.roll_no =#{rollNo}
  155. AND inv.warehouse_id = #{warehouseId}
  156. AND inv.status = '在库'
  157. AND inv.qty_on_hand > 0
  158. </select>
  159. <update id="updateSoBomPickedQty">
  160. UPDATE SOBOM
  161. SET QtyIssue = isnull(QtyIssue, 0) + #{transQty}
  162. WHERE Site = #{site}
  163. AND OrderNo = #{relatedNo}
  164. AND ComponentPartNo = #{partNo}
  165. </update>
  166. <!-- 获取已扫描标签列表(从缓存表) -->
  167. <select id="getScannedLabelList" resultType="java.util.Map">
  168. SELECT
  169. site,
  170. bu_no as buNo,
  171. part_no as partNo,
  172. RollNo as labelCode,
  173. RollQty as quantity
  174. FROM ScannedRollTempTable
  175. WHERE site = #{site}
  176. AND bu_no = #{buNo}
  177. AND NotifyNo = #{outboundNo}
  178. AND OrderNo = #{relatedNo}
  179. ORDER BY RollNo DESC
  180. </select>
  181. </mapper>