QrBoxMappingMapper.xml 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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
  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. </where>
  51. order by qbm.create_time
  52. </select>
  53. <select id="getPrintingDetail" resultType="com.abi.qms.platform.dao.vo.result.PrintingDetailVO">
  54. select
  55. qbm.begin_qr_code,qbm.end_qr_code,qbm.create_time,qbm.box_code,qbm.qr_code_count,
  56. qp.factory_cover_level_two_id,qp.factory_beer_id,bm.material_name
  57. from qr_box_mapping qbm
  58. inner join qr_package qp on qp.id=qbm.package_id
  59. inner join base_material bm on bm.id=qp.material_id
  60. <where>
  61. <if test="boxCode != null and boxCode!='' ">
  62. qbm.box_code = #{boxCode}
  63. </if>
  64. </where>
  65. </select>
  66. <select id="getIndexQrBoxCodeMappingOne" resultType="com.abi.qms.platform.dao.entity.QrBoxMapping">
  67. SELECT
  68. <include refid="Base_Column_List"/>
  69. FROM
  70. qr_box_mapping
  71. <where>
  72. <if test="req.packageId != null and req.packageId !='' ">
  73. AND package_id = #{req.packageId}
  74. </if>
  75. <if test="req.qrIndex != null and req.qrIndex != '' ">
  76. AND index_begin &lt;= #{req.qrIndex} AND index_end >= #{req.qrIndex}
  77. </if>
  78. </where>
  79. AND is_delete = 0
  80. LIMIT 1
  81. </select>
  82. <select id="queryWxQrBoxMappingDetails"
  83. resultType="com.abi.qms.platform.dao.vo.result.QueryWxQrBoxMappingDetailsVO">
  84. SELECT
  85. mapping.box_code ,
  86. material.material_name,
  87. active.active_name,
  88. case when qpckage.qr_type = 2 then qpckage.qr_number else 0 end AS qrCodeCount
  89. FROM
  90. qr_box_mapping AS mapping
  91. LEFT JOIN qr_package AS qpckage ON qpckage.id = mapping.package_id
  92. LEFT JOIN base_material AS material ON material.id = qpckage.material_id
  93. LEFT JOIN base_active AS active ON active.id = material.active_id
  94. WHERE mapping.box_code = #{req.boxCode} AND mapping.is_delete = 0
  95. </select>
  96. <select id="getActivationRecord" resultType="com.abi.qms.platform.dao.vo.result.ActivationRecordVO">
  97. select qbm.box_code,ba.active_name,bm.material_name,
  98. qbm.active_time,ui.employee_no as activeAccount
  99. from qr_box_mapping qbm
  100. left join qr_package qp on qbm.package_id=qp.id
  101. left join base_material bm on bm.id = qp.material_id
  102. left join base_active ba on ba.id =bm.active_id
  103. left join user_info ui on ui.id=qbm.create_by
  104. <where>
  105. qbm.active_status=1
  106. <if test="req.month != null and req.month !=''">
  107. AND DATE_FORMAT(qbm.active_time,'%Y-%m') = #{req.month}
  108. </if>
  109. </where>
  110. </select>
  111. <select id="getActivateDetail" resultType="com.abi.qms.platform.dao.vo.result.ActivateDetailVo">
  112. select qbm.box_code,ba.active_name,bm.material_name,
  113. case when qp.qr_type = 2 then qp.qr_number else 0 end as capNum
  114. from qr_box_mapping qbm
  115. left join qr_package qp on qbm.package_id=qp.id
  116. left join base_material bm on bm.id = qp.material_id
  117. left join base_active ba on ba.id =bm.active_id
  118. <where>
  119. <if test="boxCode != null and boxCode !=''">
  120. qbm.box_code = #{boxCode}
  121. </if>
  122. </where>
  123. </select>
  124. </mapper>