QrRepertoryMapper.xml 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.abi.qms.platform.dao.mapper.QrRepertoryMapper">
  6. <!-- 码库 -->
  7. <resultMap id="QrRepertoryResult" type="com.abi.qms.platform.dao.entity.QrRepertory">
  8. <result property="id" column="id"/>
  9. <result property="name" column="name"/>
  10. <result property="type" column="type"/>
  11. <result property="status" column="status"/>
  12. <result property="createTime" column="create_time"/>
  13. <result property="createBy" column="create_by"/>
  14. <result property="updateTime" column="update_time"/>
  15. <result property="updateBy" column="update_by"/>
  16. <result property="isDelete" column="is_delete"/>
  17. <result property="isSys" column="is_sys"/>
  18. </resultMap>
  19. <!-- 码库的列 -->
  20. <resultMap id="QrRepertoryColumnResult" type="com.abi.qms.platform.dao.vo.result.QrRepertoryColumnVO">
  21. <result property="id" column="qr_repertory_column_id"/>
  22. <result property="qrRepertoryId" column="qr_repertory_id"/>
  23. <result property="qrFormatId" column="qr_format_id"/>
  24. <result property="qrFormatName" column="qr_format_name"/>
  25. <result property="qrFormatVO.id" column="qr_format_id"/>
  26. <result property="qrFormatVO.codeVariableBuildClass" column="code_variable_build_class"/>
  27. <result property="sortNumber" column="sort_number"/>
  28. <result property="alias" column="alias"/>
  29. <result property="urlType" column="url_type"/>
  30. <result property="remark" column="remark"/>
  31. </resultMap>
  32. <!-- 码包 -->
  33. <resultMap id="QrPackageResult" type="com.abi.qms.platform.dao.vo.result.QrPackageVO">
  34. <!-- <result property="batchNumber" column="batch_number"/>-->
  35. <result property="id" column="qr_package_id"/>
  36. <result property="qrNumber" column="qr_number"/>
  37. <result property="createTime" column="qr_package_create_time"/>
  38. <result property="createByName" column="qr_package_create_by_name"/>
  39. </resultMap>
  40. <!-- 适用于码库详情的resultMap -->
  41. <resultMap id="DetailResult" type="com.abi.qms.platform.dao.vo.result.QrRepertoryVO" extends="QrRepertoryResult">
  42. <result property="updateByName" column="update_by_name"/>
  43. <!-- 码库的列 -->
  44. <collection property="qrRepertoryColumnList" javaType="java.util.List" resultMap="QrRepertoryColumnResult"/>
  45. <!-- 码包 -->
  46. <collection property="qrPackageList" javaType="java.util.List" resultMap="QrPackageResult"/>
  47. </resultMap>
  48. <!-- 适用于分页查询的resultMap,因为IPage遇到collection会分页异常,需要使用select重新查询 -->
  49. <resultMap id="IPageResult" type="com.abi.qms.platform.dao.vo.result.QrRepertoryVO" extends="QrRepertoryResult">
  50. <result property="updateByName" column="update_by_name"/>
  51. <!-- 码库的列 -->
  52. <collection property="qrRepertoryColumnList" column="id" javaType="java.util.List"
  53. ofType="com.abi.qms.platform.dao.vo.result.QrRepertoryColumnVO" select="selectQrRepertoryColumn"/>
  54. </resultMap>
  55. <select id="selectQrRepertoryColumn" resultType="com.abi.qms.platform.dao.vo.result.QrRepertoryColumnVO">
  56. SELECT
  57. id,
  58. qr_repertory_id,
  59. qr_format_id,
  60. sort_number,
  61. alias,
  62. url_type,
  63. remark
  64. FROM qr_repertory_column
  65. WHERE qr_repertory_id = #{id} AND is_delete = 0
  66. </select>
  67. <select id="listQrRepertory" resultMap="IPageResult">
  68. SELECT
  69. qr.id,
  70. qr.name,
  71. qr.type,
  72. qr.status,
  73. qr.update_time,
  74. qr.update_by,
  75. ui.user_name AS update_by_name
  76. FROM qr_repertory qr
  77. LEFT JOIN user_info ui ON qr.update_by = ui.id
  78. <where>
  79. qr.is_delete = 0
  80. AND qr.is_sys = 0
  81. <if test="param.name != null and param.name != ''">
  82. AND qr.name LIKE CONCAT('%',#{param.name},'%')
  83. </if>
  84. <if test="param.type != null">
  85. AND qr.type = #{param.type}
  86. </if>
  87. <if test="param.status != null">
  88. AND qr.status = #{param.status}
  89. </if>
  90. <if test="param.updateByName != null and param.updateByName != ''">
  91. AND ui.user_name LIKE CONCAT('%',#{param.updateByName},'%')
  92. </if>
  93. <if test="param.beginUpdateTime != null and param.beginUpdateTime != ''">
  94. AND qr.update_time &gt;= #{param.beginUpdateTime}
  95. </if>
  96. <if test="param.endUpdateTime != null and param.endUpdateTime != ''">
  97. AND qr.update_time &lt;= #{param.endUpdateTime}
  98. </if>
  99. </where>
  100. order by qr.update_time desc
  101. </select>
  102. <select id="selectQrRepertoryDetailById" resultMap="DetailResult">
  103. SELECT
  104. qr.id,
  105. qr.name,
  106. qr.type,
  107. qr.status,
  108. qr.create_time,
  109. qr.create_by,
  110. qr.update_time,
  111. qr.update_by,
  112. qrc.id AS qr_repertory_column_id,
  113. qrc.qr_repertory_id,
  114. qrc.qr_format_id,
  115. qrc.sort_number,
  116. qrc.alias,
  117. qrc.url_type,
  118. qrc.remark,
  119. qf.code_variable_build_class,
  120. qf.name as qr_format_name,
  121. qp.id as qr_package_id,
  122. qp.qr_number,
  123. qp.create_time AS qr_package_create_time,
  124. ui.user_name AS qr_package_create_by_name
  125. FROM qr_repertory qr
  126. LEFT JOIN qr_repertory_column qrc ON qrc.qr_repertory_id = qr.id
  127. LEFT JOIN qr_format qf ON qf.id = qrc.qr_format_id
  128. LEFT JOIN qr_box_code_format bcf ON bcf.qr_repertory_id = qr.id
  129. LEFT JOIN qr_package qp ON qp.box_code_format_id = bcf.id
  130. LEFT JOIN user_info ui ON ui.id = qp.create_by
  131. WHERE qr.id = #{id} AND qrc.is_delete = 0
  132. </select>
  133. <select id="selectNotDisabledQrRepertory" resultType="java.lang.String">
  134. SELECT
  135. name
  136. FROM
  137. qr_repertory
  138. WHERE
  139. id IN ( SELECT DISTINCT qr_repertory_id FROM qr_repertory_column WHERE qr_format_id = #{qrFormatId} AND is_delete = 0 )
  140. AND is_delete = 0
  141. AND status != 40
  142. </select>
  143. <select id="listQrRepertorySelectDetail"
  144. resultType="com.abi.qms.platform.dao.vo.result.QrRepertorySelectDetailVO">
  145. select
  146. qr.id as repertoryId,
  147. qrc.id as qr_repertory_column_id,
  148. qrc.sort_number,
  149. qrc.alias
  150. from qr_repertory qr
  151. inner join qr_repertory_column qrc on qr.id=qrc.qr_repertory_id
  152. <where>
  153. <if test="id != null and id != ''">
  154. and qr.id = #{id}
  155. </if>
  156. and qr.is_delete = 0
  157. and qr.is_sys = 0
  158. </where>
  159. </select>
  160. </mapper>