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.

296 lines
12 KiB

7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
2 months ago
7 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.InboundNotificationHeadMapper">
  4. <!-- 获取检验合格待入库列表 -->
  5. <select id="getQualifiedInboundList" resultType="java.util.Map">
  6. SELECT
  7. h.site,
  8. h.order_no AS inboundNo,
  9. h.bu_no AS buNo,
  10. '' AS batchNo,
  11. h.required_inbound_date AS inspectionDate,
  12. SUM(CASE WHEN pr.hardtag_in_flag = '已入库' THEN 1 ELSE 0 END) AS labelinCount, -- 已入库标签数
  13. COUNT(DISTINCT pr.roll_no) AS totalLabels, -- 需入库标签数
  14. SUM(CASE WHEN pr.hardtag_in_flag = '已入库' THEN ISNULL(pr.roll_qty, 0) ELSE 0 END) AS totalinLabels, -- 已入库物料总数
  15. D.required_qty as labelCount --需入库总数
  16. FROM inbound_notification_head h
  17. INNER JOIN inbound_notification_detail d ON h.site = d.site and h.bu_no = d.bu_no and h.order_no = d.order_no
  18. LEFT JOIN po_order_roll_no pr ON d.site = pr.site and d.bu_no = pr.bu_no and d.inspection_no = pr.inspection_no AND d.part_no = pr.part_no
  19. WHERE h.site = #{site} and h.bu_no in (select bu_no from AccessBu where username = #{userName})
  20. and h.order_type = '采购入库' and h.close_flag = 'N' AND h.order_status = '待入库' and d.in_warehouse = #{warehouseId}
  21. <if test="searchCode != null and searchCode != ''">
  22. AND (
  23. h.order_no LIKE CONCAT('%', #{searchCode}, '%')
  24. OR d.related_order_no LIKE CONCAT('%', #{searchCode}, '%')
  25. )
  26. </if>
  27. <!-- <if test="searchCode == null or searchCode == ''">-->
  28. <!-- AND CONVERT(DATE, h.required_inbound_date) = CONVERT(DATE, GETDATE())-->
  29. <!-- </if>-->
  30. GROUP BY h.site,h.bu_no,h.order_no,h.required_inbound_date ,D.required_qty
  31. ORDER BY h.required_inbound_date DESC
  32. </select>
  33. <!-- 获取入库单详情 -->
  34. <select id="getInboundDetails" resultType="java.util.Map">
  35. SELECT
  36. h.site,
  37. h.order_no as inboundNo,
  38. h.site as site,
  39. h.bu_no as buNo,
  40. '' as batchNo,
  41. h.required_inbound_date as inspectionDate,
  42. SUM(CASE WHEN hardtag_in_flag = '已入库' then 1 else 0 end) labelinCount, --已入库标签数
  43. COUNT(DISTINCT pr.roll_no) as totalLabels , --需入库标签数
  44. SUM(CASE WHEN hardtag_in_flag = '已入库' then CAST(roll_qty AS float) else 0 end) totalinLabels,--已入库物料总数
  45. D.required_qty as labelCount --需入库总数
  46. FROM inbound_notification_head h
  47. INNER JOIN inbound_notification_detail d ON h.site = d.site and h.bu_no = d.bu_no and h.order_no = d.order_no
  48. LEFT JOIN po_order_roll_no pr ON d.site = pr.site and d.bu_no = pr.bu_no and d.inspection_no = pr.inspection_no AND d.part_no = pr.part_no
  49. WHERE
  50. h.site = #{site}
  51. AND h.bu_no = #{buNo}
  52. AND h.order_no = #{orderNo}
  53. GROUP BY h.order_no, h.site, h.bu_no, h.required_inbound_date,D.required_qty
  54. </select>
  55. <!-- 更新入库单状态 -->
  56. <update id="updateInboundStatus">
  57. UPDATE h
  58. SET h.order_status = #{status},
  59. h.updated_date = GETDATE(),
  60. h.updated_by = 'SYSTEM'
  61. FROM inbound_notification_head h
  62. WHERE h.order_no = #{orderNo}
  63. AND h.site = #{site}
  64. AND h.bu_no = #{buNo}
  65. </update>
  66. <!-- 获取物料清单 -->
  67. <select id="getMaterialList" resultType="java.util.Map">
  68. SELECT
  69. d.site,
  70. d.bu_no,
  71. d.part_no as partNo,
  72. d.part_desc,
  73. SUM(CASE WHEN hardtag_in_flag = '已入库' then CAST(roll_qty AS float) else 0 end) totalinLabels,--已入库数
  74. D.required_qty as labelCount --需入库总数
  75. FROM inbound_notification_detail d
  76. LEFT JOIN po_order_roll_no pr ON d.site = pr.site and d.bu_no = pr.bu_no and d.inspection_no = pr.inspection_no AND d.part_no = pr.part_no
  77. WHERE d.SITE = #{site} AND d.bu_no = #{buNo} AND d.order_no = #{inboundNo}
  78. group by d.site, d.bu_no,d.part_no, d.part_desc,D.required_qty
  79. </select>
  80. <!-- 验证库位是否存在且可用 -->
  81. <select id="validateLocation" resultType="java.util.Map">
  82. SELECT
  83. LocationID as locationCode,
  84. WareHouseID as warehouseId,
  85. LocationName as locationName,
  86. Active as status,
  87. site
  88. FROM Location
  89. WHERE LocationID = #{locationCode}
  90. AND site = #{site}
  91. </select>
  92. <!-- 检查入库单的所有标签是否都已入库 -->
  93. <select id="checkAllLabelsInbound" resultType="java.util.Map">
  94. SELECT
  95. COUNT(DISTINCT pr.roll_no) as totalLabels,
  96. SUM(CASE WHEN pr.hardtag_in_flag = '已入库' THEN 1 ELSE 0 END) as inboundLabels
  97. FROM inbound_notification_head h
  98. INNER JOIN inbound_notification_detail d ON h.order_no = d.order_no AND h.site = d.site
  99. LEFT JOIN po_order_roll_no pr ON d.order_no = pr.inspection_no AND d.part_no = pr.part_no
  100. WHERE h.order_no = #{orderNo}
  101. AND h.site = #{site}
  102. AND h.bu_no = #{buNo}
  103. </select>
  104. <!-- 查询收获入库单 -->
  105. <select id="searchInboundNotification" parameterType="com.gaotao.modules.inboundNotification.entity.vo.InboundNotificationHeadVo" resultType="com.gaotao.modules.inboundNotification.entity.vo.InboundNotificationHeadVo">
  106. SELECT
  107. a.site,
  108. a.bu_no,
  109. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  110. a.order_no,
  111. a.order_type,
  112. a.order_status,
  113. a.supplier_id,
  114. b.SupplierName,
  115. a.related_order_no,
  116. a.related_order_line_no,
  117. a.required_inbound_date,
  118. a.remarks,
  119. a.erp_order_no,
  120. a.erp_order_line_no,
  121. a.erp_order_date,
  122. a.created_by,
  123. a.created_date,
  124. a.updated_by,
  125. a.updated_date,
  126. a.assigned_by,
  127. a.assigned_date,
  128. a.closed_by,
  129. a.closed_date,
  130. a.archived_by,
  131. a.archived_date,
  132. a.orderref1,
  133. a.orderref2,
  134. a.orderref3,
  135. a.orderref4,
  136. a.orderref5,
  137. a.order_date,
  138. a.close_flag,
  139. a.in_warehouse,
  140. a.required_qty_count,
  141. a.order_qty,
  142. a.show_in_query_flag,
  143. r.crdname as category,
  144. a.department_no,
  145. d.department_desc as departmentName
  146. FROM inbound_notification_head as a
  147. left join Supplier as b on a.site = b.site and a.supplier_id = b.SupplierID
  148. left join Rdstyle r on a.category = r.crdcode and r.bRdFlag = '入'
  149. left join erp_department d on a.department_no = d.department_no
  150. <where>
  151. a.site in (select site from AccessSite where userID = #{query.userName})
  152. and a.bu_no in (select bu_no from AccessBu where username = #{query.userName})
  153. <if test="query.orderNo != null and query.orderNo != ''">
  154. AND a.order_no like '%' + #{query.orderNo} + '%'
  155. </if>
  156. <if test="query.orderType != null and query.orderType != ''">
  157. AND a.order_type = #{query.orderType}
  158. </if>
  159. <if test="query.orderStatus != null and query.orderStatus != ''">
  160. AND a.order_status in
  161. <foreach collection="query.statusArr" close=")" open="(" item="item" separator=",">
  162. #{item}
  163. </foreach>
  164. </if>
  165. <if test="query.startDate != null ">
  166. AND a.required_inbound_date >= #{query.startDate}
  167. </if>
  168. <if test="query.endDate != null ">
  169. AND #{query.endDate} >= a.required_inbound_date
  170. </if>
  171. </where>
  172. </select>
  173. <insert id="saveInboundNotification" parameterType="com.gaotao.modules.inboundNotification.entity.vo.InboundNotificationHeadVo">
  174. INSERT INTO inbound_notification_head
  175. (site, bu_no, order_no, order_type, order_status, supplier_id, related_order_no, related_order_line_no,
  176. required_inbound_date, remarks, erp_order_no, erp_order_line_no, erp_order_date, created_by, created_date, category, department_no)
  177. VALUES
  178. (#{site}, #{buNo}, #{orderNo}, #{orderType}, #{orderStatus}, #{supplierId}, #{relatedOrderNo}, #{relatedOrderLineNo},
  179. #{requiredInboundDate}, #{remarks}, #{erpOrderNo}, #{erpOrderLineNo}, #{erpOrderDate}, #{createdBy}, GETDATE(), #{category}, #{departmentNo})
  180. </insert>
  181. <delete id="deleteInboundNotification">
  182. DELETE FROM inbound_notification_head
  183. WHERE site = #{site} AND bu_no = #{buNo} AND order_no = #{orderNo}
  184. </delete>
  185. <update id="closeInboundNotification">
  186. UPDATE inbound_notification_head
  187. SET order_status = #{orderStatus},
  188. close_flag = 'Y',
  189. closed_by = #{closedBy},
  190. closed_date = GETDATE()
  191. WHERE site = #{site} AND bu_no = #{buNo} AND order_no = #{orderNo} AND close_flag = 'N'
  192. </update>
  193. <update id="issueInboundNotification">
  194. UPDATE inbound_notification_head
  195. SET assigned_by = #{assignedBy},
  196. assigned_date = GETDATE()
  197. WHERE site = #{site} AND bu_no = #{buNo} AND order_no = #{orderNo}
  198. </update>
  199. <update id="updateInboundNotification">
  200. UPDATE inbound_notification_head
  201. SET supplier_id = #{supplierId},
  202. remarks = #{remarks},
  203. order_status = #{orderStatus},
  204. category = #{category},
  205. department_no = #{departmentNo},
  206. updated_by = #{updatedBy},
  207. updated_date = GETDATE()
  208. WHERE site = #{site} AND bu_no = #{buNo} AND order_no = #{orderNo}
  209. </update>
  210. <!-- 获取已扫描标签列表(从缓存表) -->
  211. <select id="getScannedLabelList" resultType="java.util.Map">
  212. SELECT
  213. site,
  214. bu_no as buNo,
  215. part_no as partNo,
  216. RollNo as labelCode,
  217. RollQty as quantity
  218. FROM ScannedRollTempTable
  219. WHERE site = #{site}
  220. AND bu_no = #{buNo}
  221. AND NotifyNo = #{inboundNo}
  222. ORDER BY RollNo DESC
  223. </select>
  224. <!-- 获取物料可用库存(调用存储过程) -->
  225. <select id="getInventoryStock" resultType="java.util.Map" statementType="CALLABLE">
  226. {call GetInventoryStock(
  227. #{site, mode=IN, jdbcType=VARCHAR},
  228. #{notifyNo, mode=IN, jdbcType=VARCHAR},
  229. #{notifyType, mode=IN, jdbcType=VARCHAR},
  230. #{orderNo, mode=IN, jdbcType=VARCHAR},
  231. #{orderLineNo, mode=IN, jdbcType=VARCHAR},
  232. #{partNo, mode=IN, jdbcType=VARCHAR},
  233. #{warehouseId, mode=IN, jdbcType=VARCHAR}
  234. )}
  235. </select>
  236. <!-- 查询入库类别列表 -->
  237. <select id="getInboundCategoryList" resultType="java.util.Map">
  238. SELECT crdcode, crdname
  239. FROM Rdstyle
  240. WHERE bRdFlag = '入'
  241. </select>
  242. <!-- 查询部门列表 -->
  243. <select id="getDepartmentList" resultType="java.util.Map">
  244. SELECT department_no AS departmentNo, department_desc AS departmentDesc
  245. FROM erp_department
  246. </select>
  247. <!-- 删除标签导入临时表数据 -->
  248. <delete id="deleteLabelImportTemp">
  249. DELETE FROM label_import_temp
  250. WHERE site = #{site}
  251. AND bu_no = #{buNo}
  252. AND order_no = #{orderNo}
  253. </delete>
  254. <!-- 插入标签导入临时表数据 -->
  255. <insert id="insertLabelImportTemp">
  256. INSERT INTO label_import_temp (
  257. site, bu_no, order_no, order_type, related_order_no,
  258. related_order_line_no, part_no, roll_no, batch_no, roll_qty
  259. ) VALUES (
  260. #{site}, #{buNo}, #{orderNo}, #{orderType}, #{relatedOrderNo},
  261. #{relatedOrderLineNo}, #{partNo}, #{rollNo}, #{batchNo}, #{rollQty}
  262. )
  263. </insert>
  264. <!-- 调用存储过程 UspImportRoll -->
  265. <select id="callUspImportRoll" statementType="CALLABLE" parameterType="java.util.Map">
  266. {call UspImportRoll(
  267. #{site, mode=IN, jdbcType=VARCHAR},
  268. #{buNo, mode=IN, jdbcType=VARCHAR},
  269. #{orderNo, mode=IN, jdbcType=VARCHAR},
  270. #{orderType, mode=IN, jdbcType=VARCHAR},
  271. #{resultCode, mode=OUT, jdbcType=VARCHAR},
  272. #{resultMsg, mode=OUT, jdbcType=VARCHAR}
  273. )}
  274. </select>
  275. </mapper>