JxglPerformanceAppraisalMapper.xml 18.9 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
<?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="cn.timer.api.dao.jxgl.JxglPerformanceAppraisalMapper">

    <resultMap id="BaseResultMap" type="cn.timer.api.bean.jxgl.JxglPerformanceAppraisal" >
                <id column="id" property="id" />
                <result column="org_code" property="orgCode" />
                <result column="name" property="name" />
                <result column="period" property="period" />
                <result column="appraisal_start_time" property="appraisalStartTime" />
                <result column="appraisal_end_time" property="appraisalEndTime" />
                <result column="is_visible" property="isVisible" />
                <result column="sts" property="sts" />
                <result column="scope" property="scope" />
                <result column="appraisal_t_name" property="appraisalTName" />
                <result column="appraisal_person_num" property="appraisalPersonNum" />
                <result column="process_node" property="processNode" />
19
                <result column="being_appraisal_person" property="beingAppraisalPerson" />
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
                <result column="create_time" property="createTime" />
                <result column="update_time" property="updateTime" />
    </resultMap>

    <resultMap id="BaseResultMap_ALl" type="cn.timer.api.bean.jxgl.JxglPerformanceAppraisal" >
                <id column="id" property="id" />
                <result column="org_code" property="orgCode" />
                <result column="name" property="name" />
                <result column="period" property="period" />
                <result column="appraisal_start_time" property="appraisalStartTime" />
                <result column="appraisal_end_time" property="appraisalEndTime" />
                <result column="is_visible" property="isVisible" />
                <result column="sts" property="sts" />
                <result column="scope" property="scope" />
                <result column="appraisal_t_name" property="appraisalTName" />
                <result column="appraisal_person_num" property="appraisalPersonNum" />
                <result column="process_node" property="processNode" />
                <result column="being_appraisal_person" property="beingAppraisalPerson" />
                <result column="create_time" property="createTime" />
                <result column="update_time" property="updateTime" />
                
                <result column="target_seting" property="targetSeting" />
                <result column="performance_score" property="performanceScore" />
                <result column="result_verification" property="resultVerification" />
                <result column="performance_archive" property="performanceArchive" />
45 46 47 48
                <result column="assessment_complete" property="assessmentComplete" />
                <result column="termination_assessment" property="terminationAssessment" />
                
                <result column="note_sts" property="noteSts" />
49
                <association property="appraisal" column="b_id" javaType="cn.timer.api.bean.jxgl.JxglAppraisal" columnPrefix="b_"
tangzhaoqian committed
50 51
                resultMap="cn.timer.api.dao.jxgl.JxglAppraisalMapper.BaseResultMap_My">
                </association>
52 53 54
                <association property="appraisalAssessment" column="c_id" javaType="cn.timer.api.bean.jxgl.JxglAppraisalAssessment" columnPrefix="c_"
                resultMap="cn.timer.api.dao.jxgl.JxglAppraisalAssessmentMapper.BaseResultMap" />
                
55 56 57 58 59 60 61 62 63 64 65 66 67 68
    </resultMap>

    <sql id="Base_Column_List">
                id,
                org_code,
                name,
                period,
                appraisal_start_time,
                appraisal_end_time,
                is_visible,
                sts,
                scope,
                appraisal_t_name,
                appraisal_person_num,
69
                process_node,
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
                being_appraisal_person,
                create_time,
                update_time
    </sql>
    
    <sql id="Base_Column_List_a">
                a.id,
                a.org_code,
                a.name,
                a.period,
                a.appraisal_start_time,
                a.appraisal_end_time,
                a.is_visible,
                a.sts,
                a.scope,
                a.appraisal_t_name,
                a.appraisal_person_num,
               <!--  a.process_node,
                a.being_appraisal_person, -->
                a.create_time,
                a.update_time
91 92
    </sql>
    
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
    <sql id="Base_Column_List_b">
                b.id                      b_id,
                b.performance_appraisal_id b_performance_appraisal_id,
                b.emp_num                 b_emp_num,
                b.name                    b_name,
                b.appraisal_explain       b_appraisal_explain,
                b.create_time             b_create_time,
                b.update_time             b_update_time,
                b.sts                      b_sts
    </sql>
    
     <sql id="Base_Column_List_c">
                c.id                 c_id,
                c.appraisal_id       c_appraisal_id,
                c.assessor_id        c_assessor_id,
                c.assessor_name      c_assessor_name,
                c.comprehensive_score c_comprehensive_score,
                c.remarks            c_remarks,
                c.type               c_type,
                c.create_time        c_create_time,
tangzhaoqian committed
113
                c.level              c_level
114 115
    </sql>
    
116 117 118 119 120 121 122 123 124 125 126 127
    <sql id="Base_Column_List_Alias">
                id JxglPerformanceAppraisal_id,
                org_code JxglPerformanceAppraisal_org_code,
                name JxglPerformanceAppraisal_name,
                period JxglPerformanceAppraisal_period,
                appraisal_start_time JxglPerformanceAppraisal_appraisal_start_time,
                appraisal_end_time JxglPerformanceAppraisal_appraisal_end_time,
                is_visible JxglPerformanceAppraisal_is_visible,
                sts JxglPerformanceAppraisal_sts,
                scope JxglPerformanceAppraisal_scope,
                appraisal_t_name JxglPerformanceAppraisal_appraisal_t_name,
                appraisal_person_num JxglPerformanceAppraisal_appraisal_person_num,
128
                process_node JxglPerformanceAppraisal_process_node,
129 130 131
                being_appraisal_person JxglPerformanceAppraisal_being_appraisal_person,
                create_time JxglPerformanceAppraisal_create_time,
                update_time JxglPerformanceAppraisal_update_time
132 133
    </sql>

134 135 136 137 138 139
	<select id="selectListByQuery" resultMap="BaseResultMap_ALl" >
        SELECT 
        	<include refid="Base_Column_List_a" />,
        	SUM((CASE WHEN b.sts in (0,1) THEN 1 ELSE 0 END)) AS target_seting,
			SUM((CASE WHEN b.sts in (2,3) THEN 1 ELSE 0 END)) AS performance_score,
			SUM((CASE WHEN b.sts in (4,5) THEN 1 ELSE 0 END)) AS result_verification,
140
			SUM((CASE WHEN b.sts = 6 THEN 1 ELSE 0 END)) AS termination_assessment,
141 142 143
			SUM((CASE WHEN b.sts = 7 THEN 1 ELSE 0 END)) AS performance_archive
        FROM jxgl_performance_appraisal a
        LEFT JOIN jxgl_appraisal b ON a.id = b.performance_appraisal_id
144
        WHERE a.org_code = #{param.orgCode} AND a.sts != 3
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
        	<if test="param.query != null and param.query != ''">
        		and (
        			a.name like CONCAT('%',#{param.query},'%') 
        		)
        	</if>
        	<if test="param.sts != null">
        		and a.sts = #{param.sts}
			</if>
        	<if test="param.startTime != null and param.startTime != ''">
        		and a.create_time <![CDATA[ >= ]]> #{param.startTime}
        	</if>
        	<if test="param.endTime != null and param.endTime != ''">
        		and a.create_time <![CDATA[ <= ]]> #{param.endTime}
        	</if> 
        GROUP BY a.id 
        ORDER BY a.id DESC
        	
    </select>
163 164 165 166 167 168 169
    
	<select id="selectArchiveListByQuery" resultMap="BaseResultMap_ALl" >
        SELECT 
        	<include refid="Base_Column_List_a" />,
        	SUM((CASE WHEN b.sts in (0,1) THEN 1 ELSE 0 END)) AS target_seting,
			SUM((CASE WHEN b.sts in (2,3) THEN 1 ELSE 0 END)) AS performance_score,
			SUM((CASE WHEN b.sts in (4,5) THEN 1 ELSE 0 END)) AS result_verification,
170 171 172
			SUM((CASE WHEN b.sts = 7 THEN 1 ELSE 0 END)) AS performance_archive,
			SUM((CASE WHEN b.sts = 5 THEN 1 ELSE 0 END)) AS assessment_complete,
			SUM((CASE WHEN b.sts = 6 THEN 1 ELSE 0 END)) AS termination_assessment
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
        FROM jxgl_performance_appraisal a
        LEFT JOIN jxgl_appraisal b ON a.id = b.performance_appraisal_id
        WHERE a.org_code = #{param.orgCode} AND a.sts = 3
        	<if test="param.query != null and param.query != ''">
        		and (
        			a.name like CONCAT('%',#{param.query},'%') 
        		)
        	</if>
        	<if test="param.startTime != null and param.startTime != ''">
        		and a.create_time <![CDATA[ >= ]]> #{param.startTime}
        	</if>
        	<if test="param.endTime != null and param.endTime != ''">
        		and a.create_time <![CDATA[ <= ]]> #{param.endTime}
        	</if> 
        GROUP BY a.id 
        ORDER BY a.id DESC
        	
    </select>

	<select id="selectListEmpByQuery" resultMap="BaseResultMap_ALl" >
        SELECT 
        	a.name,a.appraisal_start_time,a.appraisal_end_time,
195 196
        	e.name b_user_name, e.phone b_phone,
        	(SELECT name FROM zzgl_bmgw_m WHERE id = (SELECT up_id FROM zzgl_bmgw_m WHERE id = e.bmgw_id limit 1) limit 1) as b_bm_name,
197
        	b.id b_id, b.sts b_sts,
tangzhaoqian committed
198
        	(SELECT name FROM yggl_main_emp WHERE emp_num = d.executor_id AND org_code = a.org_code) as b_executor_name,
199 200
            d.executor_id b_executor_id,
            d.sts b_note_sts,
201 202 203 204
        	c.comprehensive_score c_comprehensive_score,
        	c.level c_level
		FROM jxgl_performance_appraisal a
		LEFT JOIN jxgl_appraisal b ON b.performance_appraisal_id = a.id
205
		LEFT JOIN jxgl_appraisal_assessment c ON b.id = c.appraisal_id AND c.type = 1
206 207
		LEFT JOIN jxgl_process_node d ON b.id = d.appraisal_id AND b.sts = d.process_type
		LEFT JOIN yggl_main_emp e ON b.emp_num = e.emp_num AND a.org_code = e.org_code
208
		WHERE a.org_code = #{param.orgCode} AND b.emp_num = #{param.id}
209
		ORDER BY a.id DESC
210
    </select>
tangzhaoqian committed
211 212
    
    <select id="selectMyByQuery" resultMap="BaseResultMap_ALl" >
lal committed
213
	    <!-- c.comprehensive_score c_comprehensive_score, -->
tangzhaoqian committed
214 215
        SELECT 
        	a.name,a.appraisal_start_time,a.appraisal_end_time,
216
        	b.id b_id,b.sts b_sts,
lal committed
217
        	b.total c_comprehensive_score,
218
        	c.level c_level,
219 220
        	d.sts note_sts,
        	e.name b_user_name, e.phone b_phone,
221
        	(SELECT name FROM zzgl_bmgw_m WHERE id = (SELECT up_id FROM zzgl_bmgw_m WHERE id = e.bmgw_id limit 1) limit 1) as b_bm_name
tangzhaoqian committed
222 223 224
		FROM jxgl_performance_appraisal a
		LEFT JOIN jxgl_appraisal b ON b.performance_appraisal_id = a.id
		LEFT JOIN jxgl_appraisal_assessment c ON b.id = c.appraisal_id AND c.type = 1 
225
		LEFT JOIN jxgl_process_node d ON b.id = d.appraisal_id AND d.process_type = b.sts
226
		LEFT JOIN yggl_main_emp e ON b.emp_num = e.emp_num AND a.org_code = e.org_code
tangzhaoqian committed
227 228
		<where>
			AND a.org_code = #{param.orgCode} 
229
			AND d.executor_id = #{param.id} 
230
			AND d.sts != 0 
tangzhaoqian committed
231 232 233 234 235 236 237 238 239 240 241 242
			<if test="param.sts != null and param.sts == 0">
				AND b.sts = 0
			</if>
			<if test="param.sts != null and param.sts == 1">
				AND b.sts = 1
			</if>
			<if test="param.sts != null and param.sts == 2">
				AND b.sts in (2,3)
			</if>
			<if test="param.sts != null and param.sts == 3">
				AND b.sts = 4
			</if>
243 244 245
			<if test="param.noteSts != null">
				AND d.sts = #{param.noteSts}
			</if>
tangzhaoqian committed
246
		</where>
247
		ORDER BY a.id DESC
tangzhaoqian committed
248 249 250
		
    </select>
    
251
    <select id="selectMyProcessedByQuery" resultMap="BaseResultMap_ALl" >
lal committed
252
       <!--  SELECT 
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269
        	a.name,a.appraisal_start_time,a.appraisal_end_time,
        	b.id b_id,b.sts b_sts,
        	c.comprehensive_score c_comprehensive_score,
        	c.level c_level,
        	d.sts note_sts,
        	e.name b_user_name, e.phone b_phone,
        	(SELECT name FROM zzgl_bmgw_m WHERE id = (SELECT up_id FROM zzgl_bmgw_m WHERE id = e.bmgw_id limit 1) limit 1) as b_bm_name
		FROM jxgl_performance_appraisal a
		LEFT JOIN jxgl_appraisal b ON b.performance_appraisal_id = a.id
		LEFT JOIN jxgl_appraisal_assessment c ON b.id = c.appraisal_id AND c.type = 1 
		LEFT JOIN jxgl_process_node d ON b.id = d.appraisal_id AND d.process_type = b.sts
		LEFT JOIN yggl_main_emp e ON b.emp_num = e.emp_num AND a.org_code = e.org_code
		<where>
			AND a.org_code = #{param.orgCode} 
			AND d.executor_id = #{param.id} 
			AND d.sts = 2
		</where>
lal committed
270
		ORDER BY a.id DESC -->
271
		
lal committed
272 273 274 275 276 277 278 279 280 281 282 283 284 285
		select em.`name` b_user_name,
			em.phone b_phone,
			(SELECT name FROM zzgl_bmgw_m WHERE id = (SELECT up_id FROM zzgl_bmgw_m WHERE id = em.bmgw_id limit 1) limit 1) as b_bm_name,
			pe.`name`,
			nod.process_type as b_sts,
			jx.total c_comprehensive_score,
			jx.`level` c_level
		from jxgl_process_node nod
		LEFT JOIN jxgl_appraisal as jx on jx.id = nod.appraisal_id
		LEFT JOIN jxgl_performance_appraisal as pe on pe.id = jx.performance_appraisal_id
		LEFT JOIN yggl_main_emp as em on em.emp_num = nod.executor_id
		where nod.executor_id = #{param.id}
		and pe.org_code = #{param.orgCode} 
		and nod.sts = 2
ilal committed
286
		and em.org_code = #{param.orgCode} 
lal committed
287
		ORDER BY pe.id DESC
288 289
    </select>
    
tangzhaoqian committed
290
    
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326
	<!-- 

    <insert id="insert" useGeneratedKeys="true" keyColumn="id" parameterType="cn.timer.api.bean.jxgl.JxglPerformanceAppraisal">
        INSERT INTO jxgl_performance_appraisal
        <trim prefix="(" suffix=")" suffixOverrides=",">
                        <if test ='null != orgCode'>
                        org_code,
                        </if>
                        <if test ='null != name'>
                        name,
                        </if>
                        <if test ='null != period'>
                        period,
                        </if>
                        <if test ='null != appraisalStartTime'>
                        appraisal_start_time,
                        </if>
                        <if test ='null != appraisalEndTime'>
                        appraisal_end_time,
                        </if>
                        <if test ='null != isVisible'>
                        is_visible,
                        </if>
                        <if test ='null != sts'>
                        sts,
                        </if>
                        <if test ='null != scope'>
                        scope,
                        </if>
                        <if test ='null != appraisalTName'>
                        appraisal_t_name,
                        </if>
                        <if test ='null != appraisalPersonNum'>
                        appraisal_person_num,
                        </if>
                        <if test ='null != processNode'>
327 328 329
                        process_node,
                        </if>
                        <if test ='null != beingAppraisalPerson'>
330 331 332 333 334 335 336
                        being_appraisal_person,
                        </if>
                        <if test ='null != createTime'>
                        create_time,
                        </if>
                        <if test ='null != updateTime'>
                        update_time
337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370
                        </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
                        <if test ='null != orgCode'>
                        #{orgCode},
                        </if>
                        <if test ='null != name'>
                        #{name},
                        </if>
                        <if test ='null != period'>
                        #{period},
                        </if>
                        <if test ='null != appraisalStartTime'>
                        #{appraisalStartTime},
                        </if>
                        <if test ='null != appraisalEndTime'>
                        #{appraisalEndTime},
                        </if>
                        <if test ='null != isVisible'>
                        #{isVisible},
                        </if>
                        <if test ='null != sts'>
                        #{sts},
                        </if>
                        <if test ='null != scope'>
                        #{scope},
                        </if>
                        <if test ='null != appraisalTName'>
                        #{appraisalTName},
                        </if>
                        <if test ='null != appraisalPersonNum'>
                        #{appraisalPersonNum},
                        </if>
                        <if test ='null != processNode'>
371 372 373
                        #{processNode},
                        </if>
                        <if test ='null != beingAppraisalPerson'>
374 375 376 377 378 379 380
                        #{beingAppraisalPerson},
                        </if>
                        <if test ='null != createTime'>
                        #{createTime},
                        </if>
                        <if test ='null != updateTime'>
                        #{updateTime}
381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402
                        </if>
        </trim>
    </insert>

    <delete id="delete" >
        DELETE FROM jxgl_performance_appraisal
        WHERE id = #{id}
    </delete>

    <update id="update" parameterType="cn.timer.api.bean.jxgl.JxglPerformanceAppraisal">
        UPDATE jxgl_performance_appraisal
        <set>
                    <if test ='null != orgCode'>org_code = #{orgCode},</if>
                    <if test ='null != name'>name = #{name},</if>
                    <if test ='null != period'>period = #{period},</if>
                    <if test ='null != appraisalStartTime'>appraisal_start_time = #{appraisalStartTime},</if>
                    <if test ='null != appraisalEndTime'>appraisal_end_time = #{appraisalEndTime},</if>
                    <if test ='null != isVisible'>is_visible = #{isVisible},</if>
                    <if test ='null != sts'>sts = #{sts},</if>
                    <if test ='null != scope'>scope = #{scope},</if>
                    <if test ='null != appraisalTName'>appraisal_t_name = #{appraisalTName},</if>
                    <if test ='null != appraisalPersonNum'>appraisal_person_num = #{appraisalPersonNum},</if>
403
                    <if test ='null != processNode'>process_node = #{processNode},</if>
404 405 406
                    <if test ='null != beingAppraisalPerson'>being_appraisal_person = #{beingAppraisalPerson},</if>
                    <if test ='null != createTime'>create_time = #{createTime},</if>
                    <if test ='null != updateTime'>update_time = #{updateTime}</if>
407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431
        </set>
        WHERE id = #{id}
    </update>


    <select id="load" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List" />
        FROM jxgl_performance_appraisal
        WHERE id = #{id}
    </select>

    <select id="pageList" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List" />
        FROM jxgl_performance_appraisal
        LIMIT #{offset}, #{pageSize}
    </select>

    <select id="pageListCount" resultType="java.lang.Integer">
        SELECT count(1)
        FROM jxgl_performance_appraisal
    </select>

	 -->

</mapper>