<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.newfiber.api.pc.dao.Assessment.AssessmentDao" > <resultMap type="com.newfiber.api.pc.model.Assessment.Assessment" id="BaseResultMap"> <id column="Serial" property="serial" jdbcType="BIGINT"/> <result column="Template_No" property="templateNo" jdbcType="VARCHAR"/> <result column="Assessment_No" property="assessmentNo" jdbcType="VARCHAR"/> <result column="Assessment_User_No" property="assessmentUserNo" jdbcType="VARCHAR"/> <result column="Assessment_Status" property="assessmentStatus" jdbcType="INTEGER"/> <result column="Assessment_Status_ZN" property="assessmentStatusZN" jdbcType="NVARCHAR"/> <result column="Assessment_Result" property="assessmentResult" jdbcType="NVARCHAR"/> <result column="Create_Time" property="createTime" jdbcType="TIMESTAMP"/> <result column="Self_Total" property="selfTotal" jdbcType="NUMERIC"/> <result column="Leader_Total" property="leaderTotal" jdbcType="NUMERIC"/> <result column="Total_Score" property="totalScore" jdbcType="NUMERIC"/> <collection column="Assessment_No" property="itemList" ofType="com.newfiber.api.pc.model.Assessment.AssessmentItem" select="com.newfiber.api.pc.dao.Assessment.AssessmentItemDao.getAssessmentItemList2"></collection> </resultMap> <resultMap type="com.newfiber.api.pc.model.Assessment.Assessment" id="BaseResultMap2"> <id column="Serial" property="serial" jdbcType="BIGINT"/> <result column="Template_No" property="templateNo" jdbcType="VARCHAR"/> <result column="Assessment_No" property="assessmentNo" jdbcType="VARCHAR"/> <result column="Assessment_User_No" property="assessmentUserNo" jdbcType="VARCHAR"/> <result column="Assessment_Status" property="assessmentStatus" jdbcType="INTEGER"/> <result column="Assessment_Status_ZN" property="assessmentStatusZN" jdbcType="NVARCHAR"/> <result column="Assessment_Result" property="assessmentResult" jdbcType="NVARCHAR"/> <result column="Create_Time" property="createTime" jdbcType="TIMESTAMP"/> <result column="Self_Total" property="selfTotal" jdbcType="NUMERIC"/> <result column="Leader_Total" property="leaderTotal" jdbcType="NUMERIC"/> <result column="totalScore" property="totalScore" jdbcType="NUMERIC"/> </resultMap> <sql id="Assessment_sql"> SELECT a.Serial,a.Template_No,a.Assessment_No,a.Assessment_User_No,a.Assessment_Status, a.Assessment_Status_ZN,a.Self_Total,a.Leader_Total,a.Total_Score, a.Assessment_Result,DATE_FORMAT(a.Create_Time,'%Y-%m-%d %T') cTime, t.Assessment_Content assessmentContent,t.Assessment_Division assessmentDivision, t.Assessment_Type assessmentType,t.Assessment_Type_ZN assessmentTypeZN, DATE_FORMAT(t.Start_Time,'%Y-%m-%d %T') sTime,DATE_FORMAT(t.End_Time,'%Y-%m-%d %T') eTime, t.Excellent_Score excellentScore,t.Good_Score goodScore,t.Qualified_Score qualifiedScore, t.Proportion Proportion,u.user_name assessmentUserName FROM assessment a INNER JOIN assessment_template t ON a.Template_No = t.Template_No INNER JOIN huludao_main.sys_user_info u ON u.User_No = a.Assessment_User_No where 1=1 </sql> <sql id="Time_sql"> <if test="startTime != null and endTime == null"> AND t.Start_Time > #{startTime} </if> <if test="startTime == null and endTime != null"> AND t.Start_Time < #{endTime} </if> <if test="startTime != null and endTime != null"> AND t.Start_Time between #{startTime} and #{endTime} </if> </sql> <select id="getAssessmentList" parameterType="com.newfiber.api.pc.model.Assessment.Assessment" resultMap="BaseResultMap"> <include refid="Assessment_sql"></include> AND a.Assessment_User_No=#{assessmentUserNo} <if test="assessmentContent != null"> AND t.Assessment_Content like ('%'+#{fuzzyQuery}+'%') </if> <if test="startTime != null and endTime == null"> AND t.Start_Time > #{startTime} </if> <if test="startTime == null and endTime != null"> AND t.Start_Time < #{endTime} </if> <if test="startTime != null and endTime != null"> AND t.Start_Time between #{startTime} and #{endTime} </if> order by a.Create_Time desc <if test="pageSize != 0"> limit #{pageNo},#{pageSize} </if> </select> <select id="countAssessmentList" parameterType="com.newfiber.api.pc.model.Assessment.Assessment" resultType="int"> select COUNT(a.Serial) FROM assessment a,assessment_template b where a.Template_No = b.Template_No AND a.Assessment_User_No=#{assessmentUserNo} <if test="assessmentContent != null"> AND t.Assessment_Content like ('%'+#{fuzzyQuery}+'%') </if> <if test="startTime != null and endTime == null"> AND b.Start_Time > #{startTime} </if> <if test="startTime == null and endTime != null"> AND b.Start_Time < #{endTime} </if> <if test="startTime != null and endTime != null"> AND b.Start_Time between #{startTime} and #{endTime} </if> </select> <select id="getSubAssessmentList" resultMap="BaseResultMap"> <include refid="Assessment_sql"></include> <if test="list != null and list.size >0"> AND a.Assessment_User_No IN <foreach collection="list" index="index" item="item" open="(" separator="," close=")"> #{item} </foreach> </if> <if test="templateNo != null and templateNo != ''"> AND a.Template_No = #{templateNo} </if> <include refid="Time_sql"></include> order by a.Create_Time desc <if test="pageSize != 0"> limit #{pageNo},#{pageSize} </if> </select> <select id="getAssessment" parameterType="com.newfiber.api.pc.model.Assessment.Assessment" resultMap="BaseResultMap"> <include refid="Assessment_sql"></include> AND a.Serial=#{serial} </select> <select id="countAssessment" parameterType="com.newfiber.api.pc.model.Assessment.Assessment" resultMap="BaseResultMap"> SELECT count(Serial) FROM assessment where Assessment_User_No=#{assessmentUserNo} </select> <select id="getAssessmentNoByTemplateNo" parameterType="java.lang.String" resultType="java.lang.String"> select Assessment_No from assessment where Template_No=#{templateNo} </select> <delete id="deleteAssessmentBySerial" parameterType="com.newfiber.api.pc.model.Assessment.Assessment" > delete from assessment where Serial=#{serial} </delete> <delete id="deleteByTemplateNo" parameterType="com.newfiber.api.pc.model.Assessment.Assessment" > delete from assessment where Template_No=#{tenplateNo} </delete> <insert id="insertAssessment" parameterType="com.newfiber.api.pc.model.Assessment.Assessment" > insert into assessment <trim prefix="(" suffix=")" suffixOverrides="," > <if test="templateNo != null" > Template_No, </if> <if test="assessmentNo != null" > Assessment_No, </if> <if test="assessmentUserNo != null" > Assessment_User_No, </if> <if test=" assessmentStatus != null" > Assessment_Status, </if> <if test=" assessmentStatusZN != null" > Assessment_Status_ZN, </if> <if test="assessmentResult != null" > Assessment_Result, </if> <if test="createTime != null" > Create_Time, </if> <if test="selfTotal != null" > Self_Total, </if> <if test="leaderTotal != null" > Leader_Total, </if> <if test="totalScore != null" > Total_Score, </if> </trim> <trim prefix="values (" suffix=")" suffixOverrides="," > <if test="templateNo != null" > #{templateNo,jdbcType=VARCHAR}, </if> <if test="assessmentNo != null" > #{assessmentNo,jdbcType=VARCHAR}, </if> <if test="assessmentUserNo != null" > #{assessmentUserNo,jdbcType=VARCHAR}, </if> <if test="assessmentStatus != null" > #{assessmentStatus,jdbcType=INTEGER}, </if> <if test="assessmentStatusZN != null" > #{assessmentStatusZN,jdbcType=NVARCHAR}, </if> <if test="assessmentResult != null" > #{assessmentResult,jdbcType=NVARCHAR}, </if> <if test="createTime != null" > #{createTime,jdbcType=TIMESTAMP}, </if> <if test="selfTotal != null" > #{selfTotal,jdbcType=NUMERIC}, </if> <if test="leaderTotal != null" > #{leaderTotal,jdbcType=NUMERIC}, </if> <if test="totalScore != null" > #{totalScore,jdbcType=NUMERIC}, </if> </trim> </insert> <update id="updateAssessment" parameterType="com.newfiber.api.pc.model.Assessment.Assessment" > update assessment <set > <if test="templateNo != null" > Template_No = #{templateNo,jdbcType=VARCHAR}, </if> <if test="assessmentNo != null" > Assessment_No = #{assessmentNo,jdbcType=VARCHAR}, </if> <if test="assessmentUserNo != null" > Assessment_User_No = #{assessmentUserNo,jdbcType=VARCHAR}, </if> <if test="assessmentStatus != null" > Assessment_Status = #{assessmentStatus,jdbcType=INTEGER}, </if> <if test="assessmentStatusZN != null" > Assessment_Status_ZN = #{assessmentStatusZN,jdbcType=NVARCHAR}, </if> <if test="assessmentResult != null" > Assessment_Result = #{assessmentResult,jdbcType=NVARCHAR}, </if> <if test="createTime != null" > Create_Time = #{createTime,jdbcType=TIMESTAMP}, </if> <if test="selfTotal != null" > Self_Total = #{selfTotal,jdbcType=NUMERIC}, </if> <if test="leaderTotal != null" > Leader_Total = #{leaderTotal,jdbcType=NUMERIC}, </if> <if test="totalScore != null" > Total_Score = #{totalScore,jdbcType=NUMERIC}, </if> </set> where Serial = #{serial,jdbcType=BIGINT} </update> <select id="getMySameLevelRiverChief" parameterType="java.lang.String" resultType="java.lang.String"> SELECT o.User_No FROM huludao_main.sys_user_org o INNER JOIN division_org_manage m ON m.Org_No = o.Org_No WHERE m.Division_No IN ( SELECT m1.Division_No FROM division_org_manage m1 INNER JOIN huludao_main.sys_user_org o1 ON o1.Org_No = m1.Org_No WHERE o1.User_No = #{userNo} ) </select> <select id="getMyAllTemplateNo" resultType="java.lang.String"> SELECT a.Template_No from assessment a,assessment_template b where a.Template_No = b.Template_No AND a.Assessment_User_No=#{assessmentUserNo} <if test="startTime != null and endTime == null"> AND b.Start_Time > #{startTime} </if> <if test="startTime == null and endTime != null"> AND b.Start_Time < #{endTime} </if> <if test="startTime != null and endTime != null"> AND b.Start_Time between #{startTime} and #{endTime} </if> </select> <select id="getMySubTemplateNo" parameterType="com.newfiber.api.pc.model.Assessment.Assessment" resultType="com.newfiber.api.pc.model.Assessment.Assessment"> SELECT DISTINCT a.Template_No templateNo, t.Assessment_Content assessmentContent FROM assessment a INNER JOIN assessment_template t ON t.Template_No = a.Template_No WHERE a.Assessment_User_No IN <foreach collection="list" index="index" item="item" open="(" separator="," close=")"> #{item} </foreach> <include refid="Time_sql"></include> </select> <select id="getMyRanking" resultMap="BaseResultMap2"> select mm.*,@curRank := @curRank + 1 as orderSort from ( SELECT a.Serial, a.Template_No, a.Assessment_No, a.Assessment_User_No, a.Assessment_Status, a.Assessment_Status_ZN, a.Self_Total, a.Leader_Total, a.Total_Score, a.Assessment_Result, DATE_FORMAT(a.Create_Time,'%Y-%m-%d %T') cTime, t.Assessment_Content assessmentContent, t.Assessment_Division assessmentDivision, t.Assessment_Type assessmentType, t.Assessment_Type_ZN assessmentTypeZN, DATE_FORMAT(t.Start_Time,'%Y-%m-%d %T') sTime, DATE_FORMAT(t.End_Time,'%Y-%m-%d %T') eTime, t.Excellent_Score excellentScore, t.Good_Score goodScore, t.Qualified_Score qualifiedScore, t.Proportion Proportion, u.user_name assessmentUserName, a.Total_Score as totalScore FROM assessment a INNER JOIN assessment_template t ON a.Template_No = t.Template_No INNER JOIN huludao_main.sys_user_info u ON u.User_No = a.Assessment_User_No WHERE 1=1 AND a.Assessment_User_No = #{userNo} <if test="templateNoList != null and templateNoList.size() > 0">and a.Template_No in <foreach collection="templateNoList" separator="," item="item" open="(" close=")"> #{item} </foreach> </if> ) mm,(select @curRank := 0) q ORDER BY mm.totalScore desc <if test="pageSize != 0"> limit #{pageNo},#{pageSize} </if> </select> <select id="getSubRanking" resultMap="BaseResultMap2"> SELECT mm.*,@curRank := @curRank + 1 as orderSort from ( SELECT a.Serial, a.Template_No, a.Assessment_No, a.Assessment_User_No, a.Assessment_Status, a.Assessment_Status_ZN, a.Self_Total, a.Leader_Total, a.Total_Score, a.Assessment_Result, DATE_FORMAT(a.Create_Time,'%Y-%m-%d %T') cTime, t.Assessment_Content assessmentContent, t.Assessment_Division assessmentDivision, t.Assessment_Type assessmentType, t.Assessment_Type_ZN assessmentTypeZN, DATE_FORMAT(t.Start_Time,'%Y-%m-%d %T') sTime, DATE_FORMAT(t.End_Time,'%Y-%m-%d %T') eTime, t.Excellent_Score excellentScore, t.Good_Score goodScore, t.Qualified_Score qualifiedScore, t.Proportion Proportion, u.user_name assessmentUserName, a.Total_Score as totalScore FROM assessment a INNER JOIN assessment_template t ON a.Template_No = t.Template_No INNER JOIN huludao_main.sys_user_info u ON u.User_No = a.Assessment_User_No WHERE 1=1 AND a.Assessment_User_No in <foreach collection="uList" separator="," item="userNo" open="(" close=")"> #{userNo} </foreach> <if test="templateNoList != null and templateNoList.size() > 0"> and a.Template_No in <foreach collection="templateNoList" separator="," item="item" open="(" close=")"> #{item} </foreach> </if> ) mm,(select @curRank := 0) q ORDER BY mm.totalScore desc <if test="pageSize != null and pageNo != null"> limit #{pageNo},#{pageSize} </if> </select> </mapper>