ReplacementInstrumentCooperationMapper.xml 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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.ym.mec.biz.dal.dao.ReplacementInstrumentCooperationDao">
  4. <resultMap id="ReplacementInstrumentCooperation" type="com.ym.mec.biz.dal.entity.ReplacementInstrumentCooperation">
  5. <!--@mbg.generated-->
  6. <!--@Table replacement_instrument_cooperation-->
  7. <result column="id_" property="id"/>
  8. <result column="organ_id_" property="organId"/>
  9. <result column="cooperation_organ_id_" property="cooperationOrganId"/>
  10. <result column="topic_id_" property="topicId"/>
  11. <result column="topic_title_" property="topicTitle"/>
  12. <result column="open_pay_" property="openPay" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  13. <result column="show_question_" property="showQuestion" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  14. <result column="organName" property="organName"/>
  15. <result column="cooperationOrganName" property="cooperationOrganName"/>
  16. <result column="create_time_" property="createTime"/>
  17. <result column="update_time_" property="updateTime"/>
  18. </resultMap>
  19. <!-- 根据主键查询一条记录 -->
  20. <select id="get" resultMap="ReplacementInstrumentCooperation">
  21. SELECT *
  22. FROM replacement_instrument_cooperation
  23. WHERE id_ = #{id}
  24. </select>
  25. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.ReplacementInstrumentCooperation"
  26. useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  27. <!--@mbg.generated-->
  28. insert into replacement_instrument_cooperation (organ_id_, cooperation_organ_id_, open_pay_,show_question_,topic_id_, create_time_,
  29. update_time_
  30. )
  31. values (#{organId}, #{cooperationOrganId},
  32. #{openPay,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{showQuestion,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  33. #{topicId}, #{createTime}, #{updateTime}
  34. )
  35. </insert>
  36. <delete id="delete">
  37. <!--@mbg.generated-->
  38. delete from replacement_instrument_cooperation WHERE id_ = #{id}
  39. </delete>
  40. <update id="update" parameterType="com.ym.mec.biz.dal.entity.ReplacementInstrumentCooperation">
  41. <!--@mbg.generated-->
  42. update replacement_instrument_cooperation
  43. <set>
  44. <if test="topicId != null">
  45. topic_id_ = #{topicId},
  46. </if>
  47. <if test="organId != null">
  48. organ_id_ = #{organId},
  49. </if>
  50. <if test="cooperationOrganId != null">
  51. cooperation_organ_id_ = #{cooperationOrganId},
  52. </if>
  53. <if test="openPay != null">
  54. open_pay_ = #{openPay,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  55. </if>
  56. <if test="updateTime != null">
  57. update_time_ = NOW(),
  58. </if>
  59. </set>
  60. WHERE id_ = #{id}
  61. </update>
  62. <!-- 分页查询 -->
  63. <select id="queryPage" resultMap="ReplacementInstrumentCooperation" parameterType="map">
  64. SELECT ric.*,o.name_ organName,co.name_ cooperationOrganName,qt.title_ topic_title_ FROM replacement_instrument_cooperation ric
  65. LEFT JOIN cooperation_organ co ON co.id_ = ric.cooperation_organ_id_
  66. LEFT JOIN organization o ON o.id_ = ric.organ_id_
  67. LEFT JOIN questionnaire_topic qt ON qt.id_ = ric.topic_id_
  68. <include refid="queryPageSql"/>
  69. ORDER BY ric.id_ DESC
  70. <include refid="global.limit"/>
  71. </select>
  72. <sql id="queryPageSql">
  73. <where>
  74. <if test="organId != null">
  75. AND FIND_IN_SET(ric.organ_id_ , #{organId})
  76. </if>
  77. <if test="openPay != null">
  78. AND ric.open_pay_ = #{openPay,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  79. </if>
  80. <if test="showQuestion != null">
  81. AND ric.show_question_ = #{showQuestion,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  82. </if>
  83. <if test="search != null and search != ''">
  84. AND (ric.cooperation_organ_id_ = #{search} OR co.name_ LIKE CONCAT('%',#{search},'%'))
  85. </if>
  86. </where>
  87. </sql>
  88. <!-- 查询当前表的总记录数 -->
  89. <select id="queryCount" resultType="int">
  90. SELECT COUNT(*) FROM replacement_instrument_cooperation ric
  91. LEFT JOIN cooperation_organ co ON co.id_ = ric.cooperation_organ_id_
  92. <include refid="queryPageSql"/>
  93. </select>
  94. <select id="getByCooperationId" resultMap="ReplacementInstrumentCooperation">
  95. SELECT *
  96. FROM replacement_instrument_cooperation
  97. WHERE cooperation_organ_id_ = #{cooperationId}
  98. </select>
  99. <select id="countAllReplacementsInfo" resultType="com.ym.mec.biz.dal.entity.ReplacementInstrumentCooperation">
  100. SELECT cooperation_organ_id_ cooperationOrganId,
  101. COUNT(*) activeNum,
  102. SUM(IF(instruments_id_ > 0, 1, 0)) replaceNum,
  103. SUM(IF(pay_status_ = 2, 1, 0)) payNum
  104. FROM replacement_instrument_activity
  105. GROUP BY cooperation_organ_id_
  106. </select>
  107. </mapper>