|
@@ -5,163 +5,188 @@
|
|
|
不要修改此文件。所有改动将在下次重新自动生成时丢失。
|
|
|
-->
|
|
|
<mapper namespace="com.ym.mec.biz.dal.dao.ReplacementInstrumentActivityDao">
|
|
|
-
|
|
|
- <resultMap type="com.ym.mec.biz.dal.entity.ReplacementInstrumentActivity" id="ReplacementInstrumentActivity">
|
|
|
- <result column="id_" property="id" />
|
|
|
- <result column="cooperation_organ_id_" property="cooperationOrganId" />
|
|
|
- <result column="user_id_" property="userId" />
|
|
|
- <result column="user_name_" property="userName" />
|
|
|
- <result column="grade_" property="grade" />
|
|
|
- <result column="classes_" property="classes" />
|
|
|
- <result column="mobile_no_" property="mobileNo" />
|
|
|
- <result column="subject_id_" property="subjectId" />
|
|
|
- <result column="question_result_" property="questionResult" />
|
|
|
- <result column="instruments_id_" property="instrumentsId" />
|
|
|
- <result column="other_suggestion_" property="otherSuggestion" />
|
|
|
- <result column="open_flag_" property="openFlag" />
|
|
|
- <result column="create_time_" property="createTime" />
|
|
|
- <result column="update_time_" property="updateTime" />
|
|
|
- </resultMap>
|
|
|
|
|
|
- <resultMap id="ReplacementInstrumentActivityStatDto" type="com.ym.mec.biz.dal.dto.ReplacementInstrumentActivityStatDto" extends="ReplacementInstrumentActivity">
|
|
|
- <result property="subjectName" column="subject_name_"/>
|
|
|
- <result property="brand" column="brand_"/>
|
|
|
- <result property="specification" column="specification_"/>
|
|
|
- </resultMap>
|
|
|
+ <resultMap type="com.ym.mec.biz.dal.entity.ReplacementInstrumentActivity" id="ReplacementInstrumentActivity">
|
|
|
+ <result column="id_" property="id"/>
|
|
|
+ <result column="cooperation_organ_id_" property="cooperationOrganId"/>
|
|
|
+ <result column="user_id_" property="userId"/>
|
|
|
+ <result column="user_name_" property="userName"/>
|
|
|
+ <result column="grade_" property="grade"/>
|
|
|
+ <result column="classes_" property="classes"/>
|
|
|
+ <result column="mobile_no_" property="mobileNo"/>
|
|
|
+ <result column="subject_id_" property="subjectId"/>
|
|
|
+ <result column="question_result_" property="questionResult"/>
|
|
|
+ <result column="instruments_id_" property="instrumentsId"/>
|
|
|
+ <result column="other_suggestion_" property="otherSuggestion"/>
|
|
|
+ <result column="open_flag_" property="openFlag"/>
|
|
|
+ <result column="pay_status_" property="payStatus"/>
|
|
|
+ <result column="create_time_" property="createTime"/>
|
|
|
+ <result column="update_time_" property="updateTime"/>
|
|
|
+ </resultMap>
|
|
|
|
|
|
- <!-- 根据主键查询一条记录 -->
|
|
|
- <select id="get" resultMap="ReplacementInstrumentActivity" >
|
|
|
- SELECT * FROM replacement_instrument_activity WHERE id_ = #{id}
|
|
|
- </select>
|
|
|
-
|
|
|
- <!-- 全查询 -->
|
|
|
- <select id="findAll" resultMap="ReplacementInstrumentActivity">
|
|
|
- SELECT * FROM replacement_instrument_activity ORDER BY id_
|
|
|
- </select>
|
|
|
-
|
|
|
- <!-- 向数据库增加一条记录 -->
|
|
|
- <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.ReplacementInstrumentActivity" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
|
|
|
- INSERT INTO replacement_instrument_activity (cooperation_organ_id_,user_id_,user_name_,grade_,classes_,mobile_no_,subject_id_,question_result_,instruments_id_,other_suggestion_,create_time_,update_time_)
|
|
|
- VALUES(#{cooperationOrganId},#{userId},#{userName},#{grade},#{classes},#{mobileNo},#{subjectId},#{questionResult},#{instrumentsId},#{otherSuggestion},NOW(),NOW())
|
|
|
- </insert>
|
|
|
-
|
|
|
- <!-- 根据主键查询一条记录 -->
|
|
|
- <update id="update" parameterType="com.ym.mec.biz.dal.entity.ReplacementInstrumentActivity">
|
|
|
- UPDATE replacement_instrument_activity <set>
|
|
|
- <if test="subjectId != null">
|
|
|
- subject_id_ = #{subjectId},
|
|
|
- </if>
|
|
|
- <if test="openFlag != null">
|
|
|
- open_flag_ = #{openFlag},
|
|
|
- </if>
|
|
|
- <if test="userId != null">
|
|
|
- user_id_ = #{userId},
|
|
|
- </if>
|
|
|
- <if test="cooperationOrganId != null">
|
|
|
- cooperation_organ_id_ = #{cooperationOrganId},
|
|
|
- </if>
|
|
|
- <if test="userName != null">
|
|
|
- user_name_ = #{userName},
|
|
|
- </if>
|
|
|
- <if test="questionResult != null">
|
|
|
- question_result_ = #{questionResult},
|
|
|
- </if>
|
|
|
- <if test="updateTime != null">
|
|
|
- update_time_ = #{updateTime},
|
|
|
- </if>
|
|
|
- instruments_id_ = #{instrumentsId},
|
|
|
- other_suggestion_ = #{otherSuggestion},
|
|
|
- <if test="mobileNo != null">
|
|
|
- mobile_no_ = #{mobileNo},
|
|
|
- </if>
|
|
|
- <if test="classes != null">
|
|
|
- classes_ = #{classes},
|
|
|
- </if>
|
|
|
- <if test="grade != null">
|
|
|
- grade_ = #{grade},
|
|
|
- </if>
|
|
|
- </set> WHERE id_ = #{id}
|
|
|
- </update>
|
|
|
-
|
|
|
- <!-- 根据主键删除一条记录 -->
|
|
|
- <delete id="delete" >
|
|
|
- DELETE FROM replacement_instrument_activity WHERE id_ = #{id}
|
|
|
- </delete>
|
|
|
-
|
|
|
- <!-- 分页查询 -->
|
|
|
- <select id="queryPage" resultMap="ReplacementInstrumentActivity" parameterType="map">
|
|
|
- SELECT * FROM replacement_instrument_activity ORDER BY id_ <include refid="global.limit"/>
|
|
|
- </select>
|
|
|
-
|
|
|
- <!-- 查询当前表的总记录数 -->
|
|
|
- <select id="queryCount" resultType="int">
|
|
|
- SELECT COUNT(*) FROM replacement_instrument_activity
|
|
|
- </select>
|
|
|
- <select id="findByUserId" resultMap="ReplacementInstrumentActivity">
|
|
|
- SELECT * FROM replacement_instrument_activity WHERE user_id_ = #{userId} LIMIT 1
|
|
|
- </select>
|
|
|
+ <resultMap id="ReplacementInstrumentActivityStatDto"
|
|
|
+ type="com.ym.mec.biz.dal.dto.ReplacementInstrumentActivityStatDto"
|
|
|
+ extends="ReplacementInstrumentActivity">
|
|
|
+ <result property="subjectName" column="subject_name_"/>
|
|
|
+ <result property="brand" column="brand_"/>
|
|
|
+ <result property="specification" column="specification_"/>
|
|
|
+ </resultMap>
|
|
|
|
|
|
- <sql id="queryReplacementsCondition">
|
|
|
- <where>
|
|
|
- <if test="cooperationOrganId!=null">
|
|
|
- AND ria.cooperation_organ_id_ = #{cooperationOrganId}
|
|
|
- </if>
|
|
|
- <if test="subjectId!=null">
|
|
|
- AND ria.subject_id_ = #{subjectId}
|
|
|
- </if>
|
|
|
- <if test="brand!=null and brand!=''">
|
|
|
- AND ri.brand_ = #{brand}
|
|
|
- </if>
|
|
|
- <if test="specification!=null and specification!=''">
|
|
|
- AND ri.specification_ = #{specification}
|
|
|
- </if>
|
|
|
- <if test="search!=null and search!=''">
|
|
|
- AND (ria.mobile_no_ LIKE CONCAT('%', #{search}, '%') OR stu.username_ LIKE CONCAT('%', #{search}, '%'))
|
|
|
- </if>
|
|
|
- </where>
|
|
|
- </sql>
|
|
|
+ <!-- 根据主键查询一条记录 -->
|
|
|
+ <select id="get" resultMap="ReplacementInstrumentActivity">
|
|
|
+ SELECT *
|
|
|
+ FROM replacement_instrument_activity
|
|
|
+ WHERE id_ = #{id}
|
|
|
+ </select>
|
|
|
|
|
|
- <select id="queryReplacements" resultMap="ReplacementInstrumentActivityStatDto">
|
|
|
- SELECT
|
|
|
- ria.subject_id_,
|
|
|
- sub.name_ subject_name_,
|
|
|
- ria.user_name_,
|
|
|
- ria.mobile_no_,
|
|
|
- ri.brand_,
|
|
|
- ri.specification_
|
|
|
- FROM
|
|
|
- replacement_instrument_activity ria
|
|
|
- LEFT JOIN replacement_instrument ri ON ria.instruments_id_ = ri.id_
|
|
|
- LEFT JOIN sys_user stu ON ria.user_id_ = stu.id_
|
|
|
- LEFT JOIN `subject` sub ON ria.subject_id_ = sub.id_
|
|
|
- <include refid="queryReplacementsCondition" />
|
|
|
- ORDER BY ria.update_time_ DESC
|
|
|
- <include refid="global.limit"></include>
|
|
|
- </select>
|
|
|
+ <!-- 全查询 -->
|
|
|
+ <select id="findAll" resultMap="ReplacementInstrumentActivity">
|
|
|
+ SELECT *
|
|
|
+ FROM replacement_instrument_activity
|
|
|
+ ORDER BY id_
|
|
|
+ </select>
|
|
|
|
|
|
- <select id="countReplacements" resultType="int">
|
|
|
- SELECT
|
|
|
- COUNT(ria.id_)
|
|
|
- FROM
|
|
|
- replacement_instrument_activity ria
|
|
|
- LEFT JOIN replacement_instrument ri ON ria.instruments_id_ = ri.id_
|
|
|
- LEFT JOIN sys_user stu ON ria.user_id_ = stu.id_
|
|
|
- LEFT JOIN `subject` sub ON ria.subject_id_ = sub.id_
|
|
|
- <include refid="queryReplacementsCondition" />
|
|
|
- </select>
|
|
|
+ <!-- 向数据库增加一条记录 -->
|
|
|
+ <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.ReplacementInstrumentActivity" useGeneratedKeys="true"
|
|
|
+ keyColumn="id" keyProperty="id">
|
|
|
+ INSERT INTO replacement_instrument_activity (cooperation_organ_id_, user_id_, user_name_, grade_, classes_,
|
|
|
+ mobile_no_, subject_id_, question_result_, instruments_id_,
|
|
|
+ other_suggestion_, create_time_, update_time_)
|
|
|
+ VALUES (#{cooperationOrganId}, #{userId}, #{userName}, #{grade}, #{classes}, #{mobileNo}, #{subjectId},
|
|
|
+ #{questionResult}, #{instrumentsId}, #{otherSuggestion}, NOW(), NOW())
|
|
|
+ </insert>
|
|
|
|
|
|
- <select id="countReplacementsInfo"
|
|
|
- resultType="com.ym.mec.biz.dal.dto.ReplacementInstrumentActivityStatHead">
|
|
|
- SELECT
|
|
|
- COUNT(DISTINCT ria.user_id_) surveyNum,
|
|
|
- COUNT(DISTINCT IF(ria.instruments_id_ IS NOT NULL, ria.user_id_, NULL)) replacementNum,
|
|
|
- TRUNCATE(COUNT(IF(ria.instruments_id_ IS NOT NULL, ria.user_id_, NULL))/COUNT(DISTINCT ria.user_id_)*100, 2) replacementRate
|
|
|
- FROM
|
|
|
- replacement_instrument_activity ria
|
|
|
- WHERE ria.cooperation_organ_id_ = #{cooperationOrganId}
|
|
|
- </select>
|
|
|
+ <!-- 根据主键查询一条记录 -->
|
|
|
+ <update id="update" parameterType="com.ym.mec.biz.dal.entity.ReplacementInstrumentActivity">
|
|
|
+ UPDATE replacement_instrument_activity
|
|
|
+ <set>
|
|
|
+ <if test="subjectId != null">
|
|
|
+ subject_id_ = #{subjectId},
|
|
|
+ </if>
|
|
|
+ <if test="openFlag != null">
|
|
|
+ open_flag_ = #{openFlag},
|
|
|
+ </if>
|
|
|
+ <if test="payStatus != null">
|
|
|
+ pay_status_ = #{payStatus},
|
|
|
+ </if>
|
|
|
+ <if test="userId != null">
|
|
|
+ user_id_ = #{userId},
|
|
|
+ </if>
|
|
|
+ <if test="cooperationOrganId != null">
|
|
|
+ cooperation_organ_id_ = #{cooperationOrganId},
|
|
|
+ </if>
|
|
|
+ <if test="userName != null">
|
|
|
+ user_name_ = #{userName},
|
|
|
+ </if>
|
|
|
+ <if test="questionResult != null">
|
|
|
+ question_result_ = #{questionResult},
|
|
|
+ </if>
|
|
|
+ <if test="updateTime != null">
|
|
|
+ update_time_ = #{updateTime},
|
|
|
+ </if>
|
|
|
+ instruments_id_ = #{instrumentsId},
|
|
|
+ other_suggestion_ = #{otherSuggestion},
|
|
|
+ <if test="mobileNo != null">
|
|
|
+ mobile_no_ = #{mobileNo},
|
|
|
+ </if>
|
|
|
+ <if test="classes != null">
|
|
|
+ classes_ = #{classes},
|
|
|
+ </if>
|
|
|
+ <if test="grade != null">
|
|
|
+ grade_ = #{grade},
|
|
|
+ </if>
|
|
|
+ </set>
|
|
|
+ WHERE id_ = #{id}
|
|
|
+ </update>
|
|
|
|
|
|
- <update id="openPay" parameterType="integer">
|
|
|
- UPDATE replacement_instrument_activity SET open_flag_ = 1 WHERE cooperation_organ_id_ = #{cooperationOrganId} AND open_flag_ = 0
|
|
|
- </update>
|
|
|
+ <!-- 根据主键删除一条记录 -->
|
|
|
+ <delete id="delete">
|
|
|
+ DELETE
|
|
|
+ FROM replacement_instrument_activity
|
|
|
+ WHERE id_ = #{id}
|
|
|
+ </delete>
|
|
|
+
|
|
|
+ <!-- 分页查询 -->
|
|
|
+ <select id="queryPage" resultMap="ReplacementInstrumentActivity" parameterType="map">
|
|
|
+ SELECT * FROM replacement_instrument_activity ORDER BY id_
|
|
|
+ <include refid="global.limit"/>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 查询当前表的总记录数 -->
|
|
|
+ <select id="queryCount" resultType="int">
|
|
|
+ SELECT COUNT(*)
|
|
|
+ FROM replacement_instrument_activity
|
|
|
+ </select>
|
|
|
+ <select id="findByUserId" resultMap="ReplacementInstrumentActivity">
|
|
|
+ SELECT *
|
|
|
+ FROM replacement_instrument_activity
|
|
|
+ WHERE user_id_ = #{userId}
|
|
|
+ LIMIT 1
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <sql id="queryReplacementsCondition">
|
|
|
+ <where>
|
|
|
+ <if test="cooperationOrganId!=null">
|
|
|
+ AND ria.cooperation_organ_id_ = #{cooperationOrganId}
|
|
|
+ </if>
|
|
|
+ <if test="subjectId!=null">
|
|
|
+ AND ria.subject_id_ = #{subjectId}
|
|
|
+ </if>
|
|
|
+ <if test="brand!=null and brand!=''">
|
|
|
+ AND ri.brand_ = #{brand}
|
|
|
+ </if>
|
|
|
+ <if test="specification!=null and specification!=''">
|
|
|
+ AND ri.specification_ = #{specification}
|
|
|
+ </if>
|
|
|
+ <if test="search!=null and search!=''">
|
|
|
+ AND (ria.mobile_no_ LIKE CONCAT('%', #{search}, '%') OR stu.username_ LIKE CONCAT('%', #{search}, '%'))
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ </sql>
|
|
|
+
|
|
|
+ <select id="queryReplacements" resultMap="ReplacementInstrumentActivityStatDto">
|
|
|
+ SELECT
|
|
|
+ ria.subject_id_,
|
|
|
+ sub.name_ subject_name_,
|
|
|
+ ria.user_name_,
|
|
|
+ ria.mobile_no_,
|
|
|
+ ri.brand_,
|
|
|
+ ri.specification_
|
|
|
+ FROM
|
|
|
+ replacement_instrument_activity ria
|
|
|
+ LEFT JOIN replacement_instrument ri ON ria.instruments_id_ = ri.id_
|
|
|
+ LEFT JOIN sys_user stu ON ria.user_id_ = stu.id_
|
|
|
+ LEFT JOIN `subject` sub ON ria.subject_id_ = sub.id_
|
|
|
+ <include refid="queryReplacementsCondition"/>
|
|
|
+ ORDER BY ria.update_time_ DESC
|
|
|
+ <include refid="global.limit"></include>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="countReplacements" resultType="int">
|
|
|
+ SELECT
|
|
|
+ COUNT(ria.id_)
|
|
|
+ FROM
|
|
|
+ replacement_instrument_activity ria
|
|
|
+ LEFT JOIN replacement_instrument ri ON ria.instruments_id_ = ri.id_
|
|
|
+ LEFT JOIN sys_user stu ON ria.user_id_ = stu.id_
|
|
|
+ LEFT JOIN `subject` sub ON ria.subject_id_ = sub.id_
|
|
|
+ <include refid="queryReplacementsCondition"/>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="countReplacementsInfo"
|
|
|
+ resultType="com.ym.mec.biz.dal.dto.ReplacementInstrumentActivityStatHead">
|
|
|
+ SELECT COUNT(DISTINCT ria.user_id_) surveyNum,
|
|
|
+ COUNT(DISTINCT IF(ria.instruments_id_ IS NOT NULL, ria.user_id_, NULL)) replacementNum,
|
|
|
+ TRUNCATE(COUNT(IF(ria.instruments_id_ IS NOT NULL, ria.user_id_, NULL)) / COUNT(DISTINCT ria.user_id_) *
|
|
|
+ 100, 2) replacementRate
|
|
|
+ FROM replacement_instrument_activity ria
|
|
|
+ WHERE ria.cooperation_organ_id_ = #{cooperationOrganId}
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <update id="openPay" parameterType="integer">
|
|
|
+ UPDATE replacement_instrument_activity
|
|
|
+ SET open_flag_ = 1
|
|
|
+ WHERE cooperation_organ_id_ = #{cooperationOrganId}
|
|
|
+ AND open_flag_ = 0
|
|
|
+ </update>
|
|
|
</mapper>
|