QrBoxMappingMapper.xml 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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.abi.qms.platform.dao.mapper.QrBoxMappingMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.abi.qms.platform.dao.entity.QrBoxMapping">
  6. <id column="ID" property="id"/>
  7. <result column="BOX_CODE" property="boxCode"/>
  8. <result column="INDEX_BEGIN" property="indexBegin"/>
  9. <result column="INDEX_END" property="indexEnd"/>
  10. <result column="BEGIN_QR_CODE" property="beginQrCode"/>
  11. <result column="END_QR_CODE" property="endQrCode"/>
  12. <result column="QR_CODE_COUNT" property="qrCodeCount"/>
  13. <result column="ACTIVE_STATUS" property="activeStatus"/>
  14. <result column="ACTIVE_TIME" property="activeTime"/>
  15. <result column="ACTIVE_USER_ID" property="activeUserId"/>
  16. <result column="ACTIVE_USER_NAME" property="activeUserName"/>
  17. <result column="PACKAGE_ID" property="packageId"/>
  18. <result column="PROJECT_NO" property="projectNo"/>
  19. <result column="BOARD_NO" property="boardNo"/>
  20. <result column="REMARK" property="remark"/>
  21. <result column="CREATE_USER_NAME" property="createUserName"/>
  22. <result column="CREATE_TIME" property="createTime"/>
  23. <result column="CREATE_BY" property="createBy"/>
  24. <result column="UPDATE_TIME" property="updateTime"/>
  25. <result column="UPDATE_BY" property="updateBy"/>
  26. <result column="IS_DELETE" property="isDelete"/>
  27. <result column="invalid" property="invalid"/>
  28. <result column="production_line_name" property="productionLineName"/>
  29. <result column="production_time" property="productionTime"/>
  30. </resultMap>
  31. <!-- 通用查询结果列 -->
  32. <sql id="Base_Column_List">
  33. id, box_code, index_begin, index_end, begin_qr_code, end_qr_code, qr_code_count, active_status, active_time,
  34. active_user_id, active_user_name, package_id, project_no, board_no, remark, create_user_name, create_time,
  35. create_by, update_time, update_by, is_delete, invalid,production_line_name,production_time
  36. </sql>
  37. <select id="listQrBoxCodeMapping" resultType="com.abi.qms.platform.dao.vo.result.QrBoxMappingVO">
  38. select
  39. qbm.id,qbm.box_code,qbm.index_begin,qbm.index_end,qbm.qr_code_count,qbm.project_no,qbm.board_no,qbm.remark,
  40. qbm.create_user_name,qbm.create_time,qbm.active_time,qbm.active_user_name,qbm.active_status,qbm.package_id,
  41. qbm.invalid,bf.factory_name,qbm.begin_qr_code,qbm.end_qr_code
  42. from qr_box_mapping qbm
  43. inner join qr_package qp on qp.id=qbm.package_id
  44. left join base_factory bf on bf.id=qp.factory_beer_id
  45. <where>
  46. qbm.is_delete = 0
  47. <if test="req.activeStatus != null and req.activeStatus != 9 ">
  48. AND qbm.active_status = #{req.activeStatus}
  49. AND qbm.invalid = 0
  50. </if>
  51. <if test="req.packageId != null ">
  52. AND qbm.package_id = #{req.packageId}
  53. </if>
  54. <if test=" req.activeStatus != null and req.activeStatus == 9 ">
  55. AND qbm.invalid = 1
  56. </if>
  57. </where>
  58. order by qbm.create_time
  59. </select>
  60. <select id="listQrBoxCodeMappingForExcel" resultType="com.abi.qms.platform.dao.vo.result.QrBoxMappingVO">
  61. select
  62. qbm.id,qbm.box_code,qbm.index_begin,qbm.index_end,qbm.qr_code_count,qbm.project_no,qbm.board_no,qbm.remark,
  63. qbm.create_user_name,qbm.create_time,qbm.active_time,qbm.active_user_name,qbm.active_status,qbm.package_id,
  64. qbm.invalid,bf.factory_name,qbm.begin_qr_code,qbm.end_qr_code
  65. from qr_box_mapping qbm
  66. inner join qr_package qp on qp.id=qbm.package_id
  67. left join base_factory bf on bf.id=qp.factory_beer_id
  68. <where>
  69. <if test="activeStatus != null ">
  70. AND qbm.active_status = #{activeStatus}
  71. </if>
  72. <if test="packageId !=null">
  73. AND qbm.package_id = #{packageId}
  74. </if>
  75. and qbm.is_delete = 0
  76. </where>
  77. order by qbm.create_time
  78. </select>
  79. <select id="getPrintingDetail" resultType="com.abi.qms.platform.dao.vo.result.PrintingDetailVO">
  80. select
  81. qbm.begin_qr_code,qbm.end_qr_code,qbm.create_time,qbm.box_code,qbm.qr_code_count,
  82. qp.factory_cover_level_two_id,qp.factory_beer_id,
  83. ifnull(book.material_name,bm.material_name) as material_name
  84. from qr_box_mapping qbm
  85. inner join qr_package qp on qp.id=qbm.package_id
  86. left join base_material bm on bm.id=qp.material_id
  87. left join qr_package_booking_order book on book.booking_order=qp.booking_order
  88. <where>
  89. <if test="boxCode != null and boxCode!='' ">
  90. qbm.box_code = #{boxCode}
  91. </if>
  92. </where>
  93. </select>
  94. <select id="getIndexQrBoxCodeMappingOne" resultType="com.abi.qms.platform.dao.entity.QrBoxMapping">
  95. SELECT
  96. <include refid="Base_Column_List"/>
  97. FROM
  98. qr_box_mapping
  99. <where>
  100. <if test="req.packageId != null and req.packageId !='' ">
  101. AND package_id = #{req.packageId}
  102. </if>
  103. <if test="req.qrIndex != null and req.qrIndex != '' ">
  104. AND index_end >= #{req.qrIndex}
  105. AND index_begin &lt;= #{req.qrIndex}
  106. </if>
  107. </where>
  108. AND is_delete = 0
  109. LIMIT 1
  110. </select>
  111. <select id="queryWxQrBoxMappingDetails"
  112. resultType="com.abi.qms.platform.dao.vo.result.QueryWxQrBoxMappingDetailsVO">
  113. SELECT
  114. mapping.box_code ,
  115. material.material_name,
  116. active.active_name,
  117. case when qpckage.qr_type = 2 then qpckage.qr_number else 0 end AS qrCodeCount
  118. FROM
  119. qr_box_mapping AS mapping
  120. LEFT JOIN qr_package AS qpckage ON qpckage.id = mapping.package_id
  121. LEFT JOIN base_material AS material ON material.id = qpckage.material_id
  122. LEFT JOIN base_active AS active ON active.id = material.active_id
  123. WHERE mapping.box_code = #{req.boxCode} AND mapping.is_delete = 0
  124. </select>
  125. <select id="getActivationRecord" resultType="com.abi.qms.platform.dao.vo.result.ActivationRecordVO">
  126. select qbm.box_code,ba.active_name,bm.material_name,
  127. qbm.active_time,ui.user_name
  128. from qr_box_mapping qbm
  129. left join qr_package qp on qbm.package_id=qp.id
  130. left join base_material bm on bm.id = qp.material_id
  131. left join base_active ba on ba.id =bm.active_id
  132. left join user_info ui on ui.id=qbm.create_by
  133. <where>
  134. qbm.active_status=1
  135. <if test="req.month != null and req.month !=''">
  136. AND DATE_FORMAT(qbm.active_time,'%Y-%m') = #{req.month}
  137. </if>
  138. <if test="id != null">
  139. AND ui.id =#{id}
  140. </if>
  141. </where>
  142. ORDER BY qbm.active_time DESC
  143. </select>
  144. <select id="getActivateDetail" resultType="com.abi.qms.platform.dao.vo.result.ActivateDetailVo">
  145. select qbm.box_code,ba.active_name,bm.material_name,qbm.active_status,
  146. case when qp.qr_type = 2 then qp.qr_number else 0 end as capNum
  147. from qr_box_mapping qbm
  148. left join qr_package qp on qbm.package_id=qp.id
  149. left join base_material bm on bm.id = qp.material_id
  150. left join base_active ba on ba.id =bm.active_id
  151. <where>
  152. <if test="boxCode != null and boxCode !=''">
  153. qbm.box_code = #{boxCode}
  154. </if>
  155. </where>
  156. </select>
  157. </mapper>