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.

175 lines
8.9 KiB

  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.report.dao.InboundNotificationReportMapper">
  4. <!-- 查询收货入库任务报表数据(分页) -->
  5. <select id="searchInboundNotificationReport" resultType="com.gaotao.modules.report.entity.InboundNotificationReportData">
  6. SELECT
  7. h.site,
  8. h.bu_no AS buNo,
  9. h.order_no AS orderNo,
  10. h.order_type AS orderType,
  11. h.order_status AS orderStatus,
  12. CASE
  13. WHEN ISNULL(d.required_qty, 0) = 0 THEN '0%'
  14. ELSE CONCAT(CAST(ROUND(ISNULL(d.actual_in_qty, 0) * 100.0 / d.required_qty, 1) AS VARCHAR), '%')
  15. END AS completionRate,
  16. h.supplier_id AS supplierId,
  17. s.SupplierName AS supplierName,
  18. h.related_order_no AS relatedOrderNo,
  19. h.related_order_line_no AS relatedOrderLineNo,
  20. h.required_inbound_date AS requiredInboundDate,
  21. h.remarks,
  22. h.erp_order_no AS erpOrderNo,
  23. h.erp_order_line_no AS erpOrderLineNo,
  24. h.erp_order_date AS erpOrderDate,
  25. h.created_by AS createdBy,
  26. h.created_date AS createdDate,
  27. h.updated_by AS updatedBy,
  28. h.updated_date AS updatedDate,
  29. h.assigned_by AS assignedBy,
  30. h.assigned_date AS assignedDate,
  31. h.closed_by AS closedBy,
  32. h.closed_date AS closedDate,
  33. h.close_flag AS closeFlag,
  34. h.in_warehouse AS inWarehouse,
  35. wh.WareHouseName AS inWarehouseName,
  36. d.part_no AS detailPartNo,
  37. d.part_desc AS detailPartDesc,
  38. d.unit,
  39. um.umName,
  40. d.required_qty AS requiredQty,
  41. d.order_qty AS orderQty,
  42. d.actual_in_qty AS actualInQty,
  43. d.in_warehouse AS detailInWarehouse,
  44. dwh.WareHouseName AS detailInWarehouseName,
  45. d.in_batch_no AS inBatchNo,
  46. d.related_order_no AS detailRelatedOrderNo,
  47. d.related_order_line_no AS detailRelatedOrderLineNo,
  48. d.roll_no AS rollNo,
  49. h.department_no AS departmentNo,
  50. dep.department_desc AS departmentName
  51. FROM inbound_notification_head h WITH(NOLOCK)
  52. LEFT JOIN Supplier s WITH(NOLOCK) ON h.site = s.site AND h.supplier_id = s.SupplierID
  53. LEFT JOIN WareHouse wh WITH(NOLOCK) ON h.site = wh.site AND h.bu_no = wh.bu_no AND h.in_warehouse = wh.WareHouseID
  54. LEFT JOIN inbound_notification_detail d WITH(NOLOCK) ON h.site = d.site AND h.bu_no = d.bu_no AND h.order_no = d.order_no
  55. LEFT JOIN WareHouse dwh WITH(NOLOCK) ON d.site = dwh.site AND d.bu_no = dwh.bu_no AND d.in_warehouse = dwh.WareHouseID
  56. LEFT JOIN um WITH(NOLOCK) ON d.site = um.site AND d.unit = um.UMID
  57. LEFT JOIN erp_department dep WITH(NOLOCK) ON h.department_no = dep.department_no
  58. <where>
  59. h.site IN (SELECT site FROM AccessSite WHERE UPPER(userID) = UPPER(#{userName}))
  60. AND h.bu_no IN (SELECT bu_no FROM AccessBu WHERE UPPER(username) = UPPER(#{userName}))
  61. <if test="query.site != null and query.site != ''">
  62. AND h.site = #{query.site}
  63. </if>
  64. <if test="query.orderNo != null and query.orderNo != ''">
  65. AND h.order_no LIKE '%' + #{query.orderNo} + '%'
  66. </if>
  67. <if test="query.orderType != null and query.orderType != ''">
  68. AND h.order_type = #{query.orderType}
  69. </if>
  70. <if test="query.orderStatus != null and query.orderStatus != ''">
  71. AND h.order_status = #{query.orderStatus}
  72. </if>
  73. <if test="query.orderStatus == null or query.orderStatus == ''">
  74. AND h.order_status IN ('草稿', '编辑中', '待入库', '已入库', '已关闭')
  75. </if>
  76. <if test="query.supplierId != null and query.supplierId != ''">
  77. AND h.supplier_id LIKE '%' + #{query.supplierId} + '%'
  78. </if>
  79. <if test="query.supplierName != null and query.supplierName != ''">
  80. AND s.SupplierName LIKE '%' + #{query.supplierName} + '%'
  81. </if>
  82. <if test="query.partNo != null and query.partNo != ''">
  83. AND d.part_no LIKE '%' + #{query.partNo} + '%'
  84. </if>
  85. <if test="query.partDesc != null and query.partDesc != ''">
  86. AND d.part_desc LIKE '%' + #{query.partDesc} + '%'
  87. </if>
  88. <if test="query.startDate != null">
  89. AND h.required_inbound_date &gt;= #{query.startDate}
  90. </if>
  91. <if test="query.endDate != null">
  92. AND h.required_inbound_date &lt;= #{query.endDate}
  93. </if>
  94. <if test="query.queryRelatedOrderNo != null and query.queryRelatedOrderNo != ''">
  95. AND d.related_order_no LIKE '%' + #{query.queryRelatedOrderNo} + '%'
  96. </if>
  97. <if test="query.queryRelatedOrderLineNo != null and query.queryRelatedOrderLineNo != ''">
  98. AND d.related_order_line_no LIKE '%' + #{query.queryRelatedOrderLineNo} + '%'
  99. </if>
  100. <if test="query.rollNo != null and query.rollNo != ''">
  101. AND d.roll_no LIKE '%' + #{query.rollNo} + '%'
  102. </if>
  103. <if test="query.departmentNo != null and query.departmentNo != ''">
  104. AND h.department_no = #{query.departmentNo}
  105. </if>
  106. </where>
  107. ORDER BY h.created_date DESC, h.order_no, d.part_no
  108. OFFSET #{offset} ROWS FETCH NEXT #{limit} ROWS ONLY
  109. </select>
  110. <!-- 查询收货入库任务报表数据总数 -->
  111. <select id="countInboundNotificationReport" resultType="int">
  112. SELECT COUNT(1)
  113. FROM inbound_notification_head h WITH(NOLOCK)
  114. LEFT JOIN Supplier s WITH(NOLOCK) ON h.site = s.site AND h.supplier_id = s.SupplierID
  115. LEFT JOIN inbound_notification_detail d WITH(NOLOCK) ON h.site = d.site AND h.bu_no = d.bu_no AND h.order_no = d.order_no
  116. <where>
  117. h.site IN (SELECT site FROM AccessSite WHERE UPPER(userID) = UPPER(#{userName}))
  118. AND h.bu_no IN (SELECT bu_no FROM AccessBu WHERE UPPER(username) = UPPER(#{userName}))
  119. <if test="query.site != null and query.site != ''">
  120. AND h.site = #{query.site}
  121. </if>
  122. <if test="query.orderNo != null and query.orderNo != ''">
  123. AND h.order_no LIKE '%' + #{query.orderNo} + '%'
  124. </if>
  125. <if test="query.orderType != null and query.orderType != ''">
  126. AND h.order_type = #{query.orderType}
  127. </if>
  128. <if test="query.orderStatus != null and query.orderStatus != ''">
  129. AND h.order_status = #{query.orderStatus}
  130. </if>
  131. <if test="query.orderStatus == null or query.orderStatus == ''">
  132. AND h.order_status IN ('草稿', '编辑中', '待入库', '已入库', '已关闭')
  133. </if>
  134. <if test="query.supplierId != null and query.supplierId != ''">
  135. AND h.supplier_id LIKE '%' + #{query.supplierId} + '%'
  136. </if>
  137. <if test="query.supplierName != null and query.supplierName != ''">
  138. AND s.SupplierName LIKE '%' + #{query.supplierName} + '%'
  139. </if>
  140. <if test="query.partNo != null and query.partNo != ''">
  141. AND d.part_no LIKE '%' + #{query.partNo} + '%'
  142. </if>
  143. <if test="query.partDesc != null and query.partDesc != ''">
  144. AND d.part_desc LIKE '%' + #{query.partDesc} + '%'
  145. </if>
  146. <if test="query.startDate != null">
  147. AND h.required_inbound_date &gt;= #{query.startDate}
  148. </if>
  149. <if test="query.endDate != null">
  150. AND h.required_inbound_date &lt;= #{query.endDate}
  151. </if>
  152. <if test="query.queryRelatedOrderNo != null and query.queryRelatedOrderNo != ''">
  153. AND d.related_order_no LIKE '%' + #{query.queryRelatedOrderNo} + '%'
  154. </if>
  155. <if test="query.queryRelatedOrderLineNo != null and query.queryRelatedOrderLineNo != ''">
  156. AND d.related_order_line_no LIKE '%' + #{query.queryRelatedOrderLineNo} + '%'
  157. </if>
  158. <if test="query.rollNo != null and query.rollNo != ''">
  159. AND d.roll_no LIKE '%' + #{query.rollNo} + '%'
  160. </if>
  161. <if test="query.departmentNo != null and query.departmentNo != ''">
  162. AND h.department_no = #{query.departmentNo}
  163. </if>
  164. </where>
  165. </select>
  166. <!-- 获取用户可访问的site列表 -->
  167. <select id="getAccessSiteList" resultType="java.lang.String">
  168. SELECT site FROM AccessSite WHERE UPPER(userID) = UPPER(#{userName}) ORDER BY site
  169. </select>
  170. </mapper>