QrBoxMappingMapper.xml 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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 ">
  48. AND qbm.active_status = #{req.activeStatus}
  49. </if>
  50. <if test="req.packageId != null ">
  51. AND qbm.package_id = #{req.packageId}
  52. </if>
  53. </where>
  54. order by qbm.create_time
  55. </select>
  56. <select id="listQrBoxCodeMappingForExcel" resultType="com.abi.qms.platform.dao.vo.result.QrBoxMappingVO">
  57. select
  58. qbm.id,qbm.box_code,qbm.index_begin,qbm.index_end,qbm.qr_code_count,qbm.project_no,qbm.board_no,qbm.remark,
  59. qbm.create_user_name,qbm.create_time,qbm.active_time,qbm.active_user_name,qbm.active_status,qbm.package_id,
  60. qbm.invalid,bf.factory_name,qbm.begin_qr_code,qbm.end_qr_code
  61. from qr_box_mapping qbm
  62. inner join qr_package qp on qp.id=qbm.package_id
  63. left join base_factory bf on bf.id=qp.factory_beer_id
  64. <where>
  65. <if test="activeStatus != null ">
  66. AND qbm.active_status = #{activeStatus}
  67. </if>
  68. <if test="packageId !=null">
  69. AND qbm.package_id = #{packageId}
  70. </if>
  71. and qbm.is_delete = 0
  72. </where>
  73. order by qbm.create_time
  74. </select>
  75. <select id="getPrintingDetail" resultType="com.abi.qms.platform.dao.vo.result.PrintingDetailVO">
  76. select
  77. qbm.begin_qr_code,qbm.end_qr_code,qbm.create_time,qbm.box_code,qbm.qr_code_count,
  78. qp.factory_cover_level_two_id,qp.factory_beer_id,
  79. ifnull(book.material_name,bm.material_name) as material_name
  80. from qr_box_mapping qbm
  81. inner join qr_package qp on qp.id=qbm.package_id
  82. left join base_material bm on bm.id=qp.material_id
  83. left join qr_package_booking_order book on book.booking_order=qp.booking_order
  84. <where>
  85. <if test="boxCode != null and boxCode!='' ">
  86. qbm.box_code = #{boxCode}
  87. </if>
  88. </where>
  89. </select>
  90. <select id="getIndexQrBoxCodeMappingOne" resultType="com.abi.qms.platform.dao.entity.QrBoxMapping">
  91. SELECT
  92. <include refid="Base_Column_List"/>
  93. FROM
  94. qr_box_mapping
  95. <where>
  96. <if test="req.packageId != null and req.packageId !='' ">
  97. AND package_id = #{req.packageId}
  98. </if>
  99. <if test="req.qrIndex != null and req.qrIndex != '' ">
  100. AND index_end >= #{req.qrIndex}
  101. AND index_begin &lt;= #{req.qrIndex}
  102. </if>
  103. </where>
  104. AND is_delete = 0
  105. LIMIT 1
  106. </select>
  107. <select id="queryWxQrBoxMappingDetails"
  108. resultType="com.abi.qms.platform.dao.vo.result.QueryWxQrBoxMappingDetailsVO">
  109. SELECT
  110. mapping.box_code ,
  111. material.material_name,
  112. active.active_name,
  113. case when qpckage.qr_type = 2 then qpckage.qr_number else 0 end AS qrCodeCount
  114. FROM
  115. qr_box_mapping AS mapping
  116. LEFT JOIN qr_package AS qpckage ON qpckage.id = mapping.package_id
  117. LEFT JOIN base_material AS material ON material.id = qpckage.material_id
  118. LEFT JOIN base_active AS active ON active.id = material.active_id
  119. WHERE mapping.box_code = #{req.boxCode} AND mapping.is_delete = 0
  120. </select>
  121. <select id="getActivationRecord" resultType="com.abi.qms.platform.dao.vo.result.ActivationRecordVO">
  122. select qbm.box_code,ba.active_name,bm.material_name,
  123. qbm.active_time,ui.user_name
  124. from qr_box_mapping qbm
  125. left join qr_package qp on qbm.package_id=qp.id
  126. left join base_material bm on bm.id = qp.material_id
  127. left join base_active ba on ba.id =bm.active_id
  128. left join user_info ui on ui.id=qbm.create_by
  129. <where>
  130. qbm.active_status=1
  131. <if test="req.month != null and req.month !=''">
  132. AND DATE_FORMAT(qbm.active_time,'%Y-%m') = #{req.month}
  133. </if>
  134. </where>
  135. ORDER BY qbm.active_time DESC
  136. </select>
  137. <select id="getActivateDetail" resultType="com.abi.qms.platform.dao.vo.result.ActivateDetailVo">
  138. select qbm.box_code,ba.active_name,bm.material_name,qbm.active_status,
  139. case when qp.qr_type = 2 then qp.qr_number else 0 end as capNum
  140. from qr_box_mapping qbm
  141. left join qr_package qp on qbm.package_id=qp.id
  142. left join base_material bm on bm.id = qp.material_id
  143. left join base_active ba on ba.id =bm.active_id
  144. <where>
  145. <if test="boxCode != null and boxCode !=''">
  146. qbm.box_code = #{boxCode}
  147. </if>
  148. </where>
  149. </select>
  150. </mapper>