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.

188 lines
7.7 KiB

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