TaskStocktakingItemMapper.xml 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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.jsh.erp.datasource.mappers.TaskStocktakingItemMapper">
  4. <select id="pdaList" parameterType="com.jsh.erp.datasource.pda.dto.PDATaskStocktakingItemDTO" resultType="com.jsh.erp.datasource.pda.vo.PDATaskStocktakingItemVO">
  5. SELECT
  6. tsi.id AS id,
  7. tsi.material_item_id AS material_item_id,
  8. me.position AS position,
  9. mc.`name` AS category_name,
  10. m.`name` AS material_name,
  11. m.standard AS standard,
  12. u.username AS create_name,
  13. tsi.oper_time AS oper_time,
  14. me.inventory AS inventory,
  15. me.commodity_unit AS commodity_unit,
  16. tsi.new_inventory AS new_inventory,
  17. tsi.new_position AS new_position,
  18. m.img_name AS img_name,
  19. tsi.status AS status
  20. FROM
  21. task_stocktaking_item tsi
  22. LEFT JOIN jsh_material_extend me ON tsi.material_item_id = me.id
  23. LEFT JOIN jsh_material m ON me.material_id = m.id
  24. LEFT JOIN jsh_material_category mc ON m.category_id = mc.id
  25. LEFT JOIN jsh_user u ON u.id = tsi.creator
  26. <where>
  27. tsi.delete_flag = 0
  28. AND tsi.task_stocktaking_id = #{taskId}
  29. <if test="number != null and number != ''">
  30. AND (m.name LIKE CONCAT('%',#{number},'%')
  31. OR me.batch_number LIKE CONCAT('%',#{number},'%')
  32. OR me.position LIKE CONCAT('%',#{number},'%')
  33. OR m.system_sku LIKE CONCAT('%',#{number},'%'))
  34. </if>
  35. <if test="userIdList != null and userIdList.size > 0">
  36. AND tsi.creator IN
  37. <foreach collection="userIdList" item="item" open="(" separator="," close=")">
  38. #{item}
  39. </foreach>
  40. </if>
  41. <if test="categoryIdList != null and categoryIdList.size > 0">
  42. AND m.category_id IN
  43. <foreach collection="categoryIdList" item="item" open="(" separator="," close=")">
  44. #{item}
  45. </foreach>
  46. </if>
  47. <if test="positionList != null and positionList.size > 0">
  48. AND
  49. <foreach collection="positionList" item="item" open="(" separator="OR" close=")">
  50. me.position LIKE CONCAT('%',#{item},'%')
  51. </foreach>
  52. </if>
  53. <if test="position != null and position != ''">
  54. AND me.position LIKE CONCAT('%',#{position},'%')
  55. </if>
  56. <if test="statusList != null and statusList.size > 0">
  57. AND tsi.status IN
  58. <foreach collection="statusList" item="item" open="(" separator="," close=")">
  59. #{item}
  60. </foreach>
  61. </if>
  62. </where>
  63. ORDER BY
  64. tsi.oper_time DESC,
  65. tsi.id DESC
  66. </select>
  67. <select id="listByTaskStocktakingId" parameterType="com.jsh.erp.datasource.dto.TaskStocktakingItemQueryDTO" resultType="com.jsh.erp.datasource.vo.TaskStocktakingItemVO">
  68. SELECT
  69. tsi.id AS id,
  70. mc.`name` AS category_name,
  71. m.`name` AS material_name,
  72. m.standard AS standard,
  73. m.model AS model,
  74. m.color AS color,
  75. m.brand AS brand,
  76. me.position AS position,
  77. me.batch_number AS batch_number,
  78. m.system_sku AS system_sku,
  79. me.sku AS sku,
  80. me.commodity_unit AS commodity_unit,
  81. me.production_date AS production_date,
  82. s.supplier AS supplier_name,
  83. me.bar_code AS bar_code,
  84. me.inventory AS inventory,
  85. me.expiry_num AS expiry_num,
  86. d.`name` AS depot_name,
  87. tsi.new_position AS new_position,
  88. tsi.new_inventory AS new_inventory,
  89. tsi.difference_count AS difference_count,
  90. tsi.difference_reason AS difference_reason
  91. FROM
  92. task_stocktaking_item tsi
  93. LEFT JOIN jsh_material_extend me ON tsi.material_item_id = me.id
  94. LEFT JOIN jsh_material m ON me.material_id = m.id
  95. LEFT JOIN jsh_material_category mc ON mc.id = m.category_id
  96. LEFT JOIN jsh_supplier s ON me.supplier_id = s.id
  97. LEFT JOIN jsh_depot d ON me.depot_id = d.id
  98. <where>
  99. tsi.delete_flag = 0
  100. AND tsi.task_stocktaking_id = #{taskStocktakingId}
  101. <if test="categoryId != null and categoryId != ''">
  102. AND m.category_id = #{categoryId}
  103. </if>
  104. <if test="materialName != null and materialName != ''">
  105. AND m.`name` LIKE CONCAT('%',#{materialName},'%')
  106. </if>
  107. <if test="batchNumber != null and batchNumber != ''">
  108. AND me.batch_number = #{batchNumber}
  109. </if>
  110. <if test="position != null and position != ''">
  111. AND me.position LIKE CONCAT('%',#{position},'%')
  112. </if>
  113. <if test="isDifference != null and isDifference == '1'">
  114. AND tsi.new_inventory = me.inventory
  115. </if>
  116. <if test="isDifference != null and isDifference == '2'">
  117. AND tsi.new_inventory != 0
  118. AND tsi.new_inventory != me.inventory
  119. </if>
  120. </where>
  121. ORDER BY
  122. tsi.oper_time DESC,
  123. tsi.id DESC
  124. </select>
  125. <select id="creatorSpinnerList" resultType="com.jsh.erp.datasource.vo.SpinnerVO">
  126. SELECT
  127. tsi.creator AS value,
  128. u.username AS label
  129. FROM
  130. task_stocktaking_item tsi
  131. LEFT JOIN jsh_user u ON tsi.creator = u.id
  132. WHERE
  133. tsi.delete_flag = 0
  134. AND tsi.creator IS NOT NULL
  135. AND tsi.task_stocktaking_id = #{taskId}
  136. GROUP BY
  137. tsi.creator
  138. </select>
  139. </mapper>