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.

140 lines
6.5 KiB

2 months ago
2 months ago
2 months ago
2 months ago
2 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.warehouse.dao.LabelTransactionLogMapper">
  4. <!-- 查询标签变动记录列表 -->
  5. <select id="queryList" resultType="java.util.Map">
  6. SELECT
  7. a.Site as site,
  8. a.bu_no as buNo,
  9. a.transaction_id as transactionId,
  10. a.document_type AS documentType,
  11. a.document_no AS documentNo,
  12. a.order_no AS orderNo,
  13. a.order_line_no as orderLineNo,
  14. a.roll_no AS rollNo,
  15. a.roll_qty AS rollQty,
  16. a.batch_no AS batchNo,
  17. a.part_no AS partNo,
  18. d.PartDescription as partDesc,
  19. d.Spec AS spec,
  20. a.warehouse_id as warehouseId,
  21. b.WareHouseName as warehouseName,
  22. a.location_id as locationId,
  23. c.LocationName as locationName,
  24. CASE WHEN a.synced_flag = 'Y' THEN '已传输' ELSE '待传输' END as syncedFlag,
  25. CONVERT(VARCHAR(19), a.synced_time, 120) AS syncedTime,
  26. a.synced_error_msg AS syncedErrorMsg,
  27. a.bom_item_no AS bomItemNo,
  28. a.transaction_by as transactionBy,
  29. CONVERT(VARCHAR(19), a.transaction_date, 120) AS transactionDate
  30. FROM StockTransactionLog as a
  31. LEFT JOIN WareHouse as b ON a.site = b.site AND a.bu_no = b.bu_no AND a.warehouse_id = b.WareHouseID
  32. LEFT JOIN Location as c ON a.site = c.site AND a.bu_no = c.bu_no AND a.location_id = c.LocationID
  33. left join part as d on a.site = d.site and a.part_no = d.PartNo
  34. WHERE a.site IN (SELECT site FROM AccessSite WHERE userID = #{query.userName})
  35. AND a.bu_no IN (SELECT bu_no FROM AccessBu WHERE username = #{query.userName})
  36. <if test="query.buNo != null and query.buNo != ''">
  37. AND a.bu_no = #{query.buNo}
  38. </if>
  39. <if test="query.documentType != null and query.documentType != ''">
  40. <choose>
  41. <when test="query.documentType == '移库调拨'">
  42. AND a.document_type IN ('调拨出库', '调拨入库')
  43. </when>
  44. <otherwise>
  45. AND a.document_type = #{query.documentType}
  46. </otherwise>
  47. </choose>
  48. </if>
  49. <if test="query.rollNo != null and query.rollNo != ''">
  50. AND a.roll_no LIKE '%' + #{query.rollNo} + '%'
  51. </if>
  52. <if test="query.partNo != null and query.partNo != ''">
  53. AND a.part_no LIKE '%' + #{query.partNo} + '%'
  54. </if>
  55. <if test="query.partDesc != null and query.partDesc != ''">
  56. AND d.PartDescription LIKE '%' + #{query.partDesc} + '%'
  57. </if>
  58. <if test="query.spec != null and query.spec != ''">
  59. AND d.Spec LIKE '%' + #{query.spec} + '%'
  60. </if>
  61. <if test="query.documentNo != null and query.documentNo != ''">
  62. AND a.document_no LIKE '%' + #{query.documentNo} + '%'
  63. </if>
  64. <if test="query.orderNo != null and query.orderNo != ''">
  65. AND a.order_no LIKE '%' + #{query.orderNo} + '%'
  66. </if>
  67. <if test="query.orderLineNo != null and query.orderLineNo != ''">
  68. AND a.order_line_no LIKE '%' + #{query.orderLineNo} + '%'
  69. </if>
  70. <if test="query.syncedFlag != null and query.syncedFlag != ''">
  71. AND a.synced_flag = #{query.syncedFlag}
  72. </if>
  73. <if test="query.startDate != null and query.startDate != ''">
  74. AND a.transaction_date &gt;= #{query.startDate}
  75. </if>
  76. <if test="query.endDate != null and query.endDate != ''">
  77. AND a.transaction_date &lt; DATEADD(DAY, 1, #{query.endDate})
  78. </if>
  79. ORDER BY a.transaction_date DESC, a.transaction_id DESC
  80. OFFSET #{query.offset} ROWS FETCH NEXT #{query.limit} ROWS ONLY
  81. </select>
  82. <!-- 查询标签变动记录总数 -->
  83. <select id="queryTotal" resultType="int">
  84. SELECT COUNT(1)
  85. FROM StockTransactionLog as a
  86. LEFT JOIN WareHouse as b ON a.site = b.site AND a.bu_no = b.bu_no AND a.warehouse_id = b.WareHouseID
  87. LEFT JOIN Location as c ON a.site = c.site AND a.bu_no = c.bu_no AND a.location_id = c.LocationID
  88. left join part as d on a.site = d.site and a.part_no = d.PartNo
  89. WHERE a.site IN (SELECT site FROM AccessSite WHERE userID = #{query.userName})
  90. AND a.bu_no IN (SELECT bu_no FROM AccessBu WHERE username = #{query.userName})
  91. <if test="query.buNo != null and query.buNo != ''">
  92. AND a.bu_no = #{query.buNo}
  93. </if>
  94. <if test="query.documentType != null and query.documentType != ''">
  95. <choose>
  96. <when test="query.documentType == '移库调拨'">
  97. AND a.document_type IN ('调拨出库', '调拨入库')
  98. </when>
  99. <otherwise>
  100. AND a.document_type = #{query.documentType}
  101. </otherwise>
  102. </choose>
  103. </if>
  104. <if test="query.rollNo != null and query.rollNo != ''">
  105. AND a.roll_no LIKE '%' + #{query.rollNo} + '%'
  106. </if>
  107. <if test="query.partNo != null and query.partNo != ''">
  108. AND a.part_no LIKE '%' + #{query.partNo} + '%'
  109. </if>
  110. <if test="query.partDesc != null and query.partDesc != ''">
  111. AND d.PartDescription LIKE '%' + #{query.partDesc} + '%'
  112. </if>
  113. <if test="query.spec != null and query.spec != ''">
  114. AND d.Spec LIKE '%' + #{query.spec} + '%'
  115. </if>
  116. <if test="query.documentNo != null and query.documentNo != ''">
  117. AND a.document_no LIKE '%' + #{query.documentNo} + '%'
  118. </if>
  119. <if test="query.orderNo != null and query.orderNo != ''">
  120. AND a.order_no LIKE '%' + #{query.orderNo} + '%'
  121. </if>
  122. <if test="query.orderLineNo != null and query.orderLineNo != ''">
  123. AND a.order_line_no LIKE '%' + #{query.orderLineNo} + '%'
  124. </if>
  125. <if test="query.syncedFlag != null and query.syncedFlag != ''">
  126. AND a.synced_flag = #{query.syncedFlag}
  127. </if>
  128. <if test="query.startDate != null and query.startDate != ''">
  129. AND a.transaction_date &gt;= #{query.startDate}
  130. </if>
  131. <if test="query.endDate != null and query.endDate != ''">
  132. AND a.transaction_date &lt; DATEADD(DAY, 1, #{query.endDate})
  133. </if>
  134. </select>
  135. </mapper>