JxglAppraisalMapper.xml 22.5 KB
Newer Older
1 2 3 4 5 6 7
<?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.JxglAppraisalMapper">

    <resultMap id="BaseResultMap" type="cn.timer.api.bean.jxgl.JxglAppraisal" >
                <id column="id" property="id" />
8
                <result column="performance_appraisal_id" property="performanceAppraisalId" />
9 10 11 12 13 14
                <result column="emp_num" property="empNum" />
                <result column="name" property="name" />
                <result column="appraisal_explain" property="appraisalExplain" />
                <result column="create_time" property="createTime" />
                <result column="update_time" property="updateTime" />
                <result column="sts" property="sts" />
tangzhaoqian committed
15 16 17 18 19 20 21 22 23 24 25 26 27
                <result column="is_edit" property="isEdit" />
    </resultMap>
    
    <resultMap id="BaseResultMap_My" type="cn.timer.api.bean.jxgl.JxglAppraisal" >
                <id column="id" property="id" />
                <result column="performance_appraisal_id" property="performanceAppraisalId" />
                <result column="emp_num" property="empNum" />
                <result column="name" property="name" />
                <result column="appraisal_explain" property="appraisalExplain" />
                <result column="create_time" property="createTime" />
                <result column="update_time" property="updateTime" />
                <result column="sts" property="sts" />
                <result column="is_edit" property="isEdit" />
28
                <result column="user_name" property="userName" />
29 30
                <result column="phone" property="phone" />
                <result column="bm_name" property="bmName" />
31 32 33
                <result column="executor_name" property="executorName" />
                <result column="executor_id" property="executorId" />
                <result column="note_sts" property="noteSts" />
34
    </resultMap>
35 36 37 38 39 40 41 42 43 44 45 46 47 48
    
    <resultMap id="BaseResultMap_All" type="cn.timer.api.bean.jxgl.JxglAppraisal" >
                <id column="id" property="id" />
                <result column="performance_appraisal_id" property="performanceAppraisalId" />
                <result column="emp_num" property="empNum" />
                <result column="name" property="name" />
                <result column="appraisal_explain" property="appraisalExplain" />
                <result column="create_time" property="createTime" />
                <result column="update_time" property="updateTime" />
                <result column="sts" property="sts" />
                <result column="user_name" property="userName" />
                <result column="phone" property="phone" />
                <result column="bm_name" property="bmName" />
                <result column="executor_name" property="executorName" />
49
                <result column="total" property="total" />
50
                <result column="level" property="level" />
51 52 53 54 55 56 57 58 59 60 61
                <result column="confirmor" property="confirmor" />
    </resultMap>
    
    <resultMap id="BaseResultMap_Emp" type="cn.timer.api.bean.jxgl.JxglAppraisal" >
                <id column="id" property="id" />
                <result column="performance_appraisal_id" property="performanceAppraisalId" />
                <result column="emp_num" property="empNum" />
                <result column="name" property="name" />
                <result column="appraisal_explain" property="appraisalExplain" />
                <result column="create_time" property="createTime" />
                <result column="update_time" property="updateTime" />
tangzhaoqian committed
62
                <result column="is_edit" property="isEdit" />
63 64 65 66 67 68 69 70 71 72 73
                <result column="sts" property="sts" />
                <result column="user_name" property="userName" />
                <result column="phone" property="phone" />
                <result column="bm_name" property="bmName" />
                
                <result column="rz_time" property="rzTime" />
                <result column="archivedPNum" property="archivedPNum" />
                <result column="underwayPNum" property="underwayPNum" />
                <result column="recentlyProject" property="recentlyProject" />
                <result column="recentlyScore" property="recentlyScore" />
                <result column="recentlyLevel" property="recentlyLevel" />
74 75 76 77 78 79
    </resultMap>
    
    <resultMap id="BaseResultMap_e" type="cn.timer.api.bean.jxgl.JxglAppraisalIndicators" >
                <id column="id" property="id" />
                <result column="appraisal_id" property="appraisalId" />
                <result column="title" property="title" />
80
                <result column="content" property="content" />
81 82 83 84
                <result column="weight" property="weight" />
                <result column="create_time" property="createTime" />
                <result column="update_time" property="updateTime" />
                <result column="type" property="type" />
85
                <result column="is_edit_weight" property="isEditWeight" />
86 87 88 89 90 91 92 93 94 95 96 97 98 99
                <collection column="JxglAppraisalIndicatorsAssessment_id" property="appraisalIndicatorsAssessments" ofType="cn.timer.api.bean.jxgl.JxglAppraisalIndicatorsAssessment" 
	                resultMap="cn.timer.api.dao.jxgl.JxglAppraisalIndicatorsAssessmentMapper.BaseResultMap" columnPrefix="JxglAppraisalIndicatorsAssessment_">
			    </collection>
                <collection column="JxglAppraisalItem_id" property="appraisalItems" ofType="cn.timer.api.bean.jxgl.JxglAppraisalItem" 
	                resultMap="cn.timer.api.dao.jxgl.JxglAppraisalItemMapper.BaseResultMap" columnPrefix="JxglAppraisalItem_">
			    </collection>
    </resultMap>
    
	<resultMap id="BaseResultMap_Detail" type="cn.timer.api.dto.jxgl.AppraisalDetail" >
                <id column="id" property="id" />
                <result column="performance_appraisal_id" property="performanceAppraisalId" />
                <result column="emp_num" property="empNum" />
                <result column="name" property="name" />
                <result column="appraisal_explain" property="appraisalExplain" />
100 101
                <result column="total" property="total" />
                <result column="level" property="level" />
102 103 104
                <result column="create_time" property="createTime" />
                <result column="update_time" property="updateTime" />
                <result column="sts" property="sts" />
105
                <result column="is_edit" property="isEdit" />
tangzhaoqian committed
106
                <result column="appraisal_name" property="appraisalName" />
107
                <result column="head_url" property="headUrl" />
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
                <collection column="JxglProcessNode_id" property="processNodes" ofType="cn.timer.api.bean.jxgl.JxglProcessNode" 
	                resultMap="cn.timer.api.dao.jxgl.JxglProcessNodeMapper.BaseResultMap" columnPrefix="JxglProcessNode_">
			    </collection>
                <collection column="JxglAppraisalAssessment_id" property="appraisalAssessments" ofType="cn.timer.api.bean.jxgl.JxglAppraisalAssessment" 
	                resultMap="cn.timer.api.dao.jxgl.JxglAppraisalAssessmentMapper.BaseResultMap" columnPrefix="JxglAppraisalAssessment_">
			    </collection>
                <collection column="JxglAppraisalLog_id" property="appraisalLogs" ofType="cn.timer.api.bean.jxgl.JxglAppraisalLog" 
	                resultMap="cn.timer.api.dao.jxgl.JxglAppraisalLogMapper.BaseResultMap" columnPrefix="JxglAppraisalLog_">
			    </collection>
                <collection column="e_id" property="appraisalIndicators" ofType="cn.timer.api.bean.jxgl.JxglAppraisalIndicators" 
	                resultMap="cn.timer.api.dao.jxgl.JxglAppraisalMapper.BaseResultMap_e" columnPrefix="e_">
			    </collection>
    </resultMap>
    
    
123 124 125

    <sql id="Base_Column_List">
                id,
126
                performance_appraisal_id,
127 128 129 130 131
                emp_num,
                name,
                appraisal_explain,
                create_time,
                update_time,
tangzhaoqian committed
132 133
                sts,
                is_edit
134 135
    </sql>
    
136 137 138 139 140 141
    <sql id="Base_Column_List_a">
                a.id,
                a.performance_appraisal_id,
                a.emp_num,
                a.name,
                a.appraisal_explain,
142 143
                a.total,
                a.level,
144 145
                a.create_time,
                a.update_time,
tangzhaoqian committed
146 147
                a.sts,
                a.is_edit
148 149 150 151 152 153
    </sql>
    
    <sql id="Base_Column_List_Alias_b">
                b.id JxglProcessNode_id,
                b.appraisal_id JxglProcessNode_appraisal_id,
                b.executor_id JxglProcessNode_executor_id,
154
                <!-- b.executor_name JxglProcessNode_executor_name, -->
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190
                b.execute_type JxglProcessNode_execute_type,
                b.process_type JxglProcessNode_process_type,
                b.name JxglProcessNode_name,
                b.leader_tier JxglProcessNode_leader_tier,
                b.weight JxglProcessNode_weight,
                b.sts JxglProcessNode_sts,
                b.update_time JxglProcessNode_update_time
    </sql>
    
    <sql id="Base_Column_List_Alias_c">
                c.id JxglAppraisalAssessment_id,
                c.appraisal_id JxglAppraisalAssessment_appraisal_id,
                c.assessor_id JxglAppraisalAssessment_assessor_id,
                c.assessor_name JxglAppraisalAssessment_assessor_name,
                c.comprehensive_score JxglAppraisalAssessment_comprehensive_score,
                c.remarks JxglAppraisalAssessment_remarks,
                c.type JxglAppraisalAssessment_type,
                c.create_time JxglAppraisalAssessment_create_time,
                c.level JxglAppraisalAssessment_level
    </sql>
    
    <sql id="Base_Column_List_Alias_d">
                d.id JxglAppraisalLog_id,
                d.appraisal_id JxglAppraisalLog_appraisal_id,
                d.executor_id JxglAppraisalLog_executor_id,
                d.executor_name JxglAppraisalLog_executor_name,
                d.title JxglAppraisalLog_title,
                d.remarks JxglAppraisalLog_remarks,
                d.create_time JxglAppraisalLog_create_time,
                d.type JxglAppraisalLog_type
    </sql>
    
    <sql id="Base_Column_List_Alias_e">
                e.id e_id,
                e.appraisal_id e_id,
                e.title e_title,
191
                e.content e_content,
192 193 194
                e.weight e_weight,
                e.create_time e_create_time,
                e.update_time e_update_time,
195 196
                e.type e_type,
                e.is_edit_weight e_is_edit_weight
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217
    </sql>
    
     <sql id="Base_Column_List_Alias_f">
                f.id e_JxglAppraisalIndicatorsAssessment_id,
                f.appraisal_indicators_id e_JxglAppraisalIndicatorsAssessment_appraisal_indicators_id,
                f.assessor_id e_JxglAppraisalIndicatorsAssessment_assessor_id,
                f.assessor_name e_JxglAppraisalIndicatorsAssessment_assessor_name,
                f.score e_JxglAppraisalIndicatorsAssessment_score,
                f.remarks e_JxglAppraisalIndicatorsAssessment_remarks,
                f.type e_JxglAppraisalIndicatorsAssessment_type,
                f.create_time e_JxglAppraisalIndicatorsAssessment_create_time
    </sql>
    
    <sql id="Base_Column_List_Alias_g">
                g.id e_JxglAppraisalItem_id,
                g.appraisal_indicators_id e_JxglAppraisalItem_appraisal_indicators_id,
                g.title e_JxglAppraisalItem_title,
                g.content e_JxglAppraisalItem_content,
                g.ranks e_JxglAppraisalItem_ranks
    </sql>
    
218 219
    <sql id="Base_Column_List_Alias">
                id JxglAppraisal_id,
220
                performance_appraisal_id JxglAppraisal_performance_appraisal_id,
221 222 223
                emp_num JxglAppraisal_emp_num,
                name JxglAppraisal_name,
                appraisal_explain JxglAppraisal_appraisal_explain,
224 225
                total JxglAppraisal_total,
                level JxglAppraisal_level,
226 227
                create_time JxglAppraisal_create_time,
                update_time JxglAppraisal_update_time,
tangzhaoqian committed
228 229
                sts JxglAppraisal_sts,
                is_edit JxglAppraisal_is_edit
230
    </sql>
231 232 233 234 235 236
    
    <select id="selectListByQuery" resultMap="BaseResultMap_All" >
        SELECT 
        	<include refid="Base_Column_List_a" />,
        	b.name user_name, b.phone,
        	(SELECT name FROM zzgl_bmgw_m WHERE id = (SELECT up_id FROM zzgl_bmgw_m WHERE id = b.bmgw_id limit 1) limit 1) as bm_name,
237
        	(SELECT name FROM yggl_main_emp WHERE emp_num = c.executor_id AND org_code = #{param.orgCode}) as executor_name
238 239
        FROM jxgl_appraisal a
        LEFT JOIN yggl_main_emp b ON a.emp_num = b.emp_num AND b.org_code = #{param.orgCode}
tangzhaoqian committed
240
        LEFT JOIN jxgl_process_node c ON a.id = c.appraisal_id AND c.process_type = a.sts
241
        
242
        WHERE a.performance_appraisal_id = #{param.id} 
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257
        	<if test="param.empNums != null and param.empNums.size() > 0">
        		<choose>
					<when test="param.empNums.size() > 1">
						AND b.emp_num IN
						(
						<foreach item="it" index="index" collection="param.empNums" separator="," close="" >
				        	#{it}
						</foreach>
						) 
					</when>
					<otherwise>
						AND b.emp_num = #{param.empNums[0]}
					</otherwise>
				</choose>
        	</if>
258
        	<if test="param.query != null and param.query != ''">
259
        		AND (
260 261
        			b.name like CONCAT('%',#{param.query},'%') or
        			b.phone like CONCAT('%',#{param.query},'%')
262 263 264
        		)
        	</if>
        	<if test="param.sts != null">
265
        		AND a.sts = #{param.sts}
266 267 268 269
			</if>
        ORDER BY a.id DESC
        	
    </select>
270
    
lal committed
271 272 273 274 275 276 277 278
    <select id="CurrentdepartmentID" resultType="java.lang.String">
        select 
			(SELECT id FROM zzgl_bmgw_m WHERE id = ( SELECT up_id FROM zzgl_bmgw_m WHERE id = b.bmgw_id LIMIT 1 ) LIMIT 1 ) AS bm_id
		from yggl_main_emp b 
		where b.org_code = #{orgcode}
		and b.emp_num = #{empnum}
    </select>
    
tangzhaoqian committed
279 280 281 282 283
    <select id="selectMyEmpByQuery" resultMap="BaseResultMap_All" >
        SELECT 
        	<include refid="Base_Column_List_a" />,
        	b.name user_name, b.phone,
        	(SELECT name FROM zzgl_bmgw_m WHERE id = (SELECT up_id FROM zzgl_bmgw_m WHERE id = b.bmgw_id limit 1) limit 1) as bm_name,
284
        	(SELECT name FROM yggl_main_emp WHERE emp_num = c.executor_id AND org_code = #{param.orgCode}) as executor_name
tangzhaoqian committed
285
        FROM jxgl_appraisal a
286
        LEFT JOIN yggl_main_emp b ON a.emp_num = b.emp_num 
tangzhaoqian committed
287
        LEFT JOIN jxgl_process_node c ON a.id = c.appraisal_id AND c.sts = 1
288 289
        
        <where>
290
        	AND b.org_code = #{param.orgCode}
tangzhaoqian committed
291 292 293 294 295 296 297 298 299 300 301
        	<if test="param.empNums != null and param.empNums.size() > 0">
        		<choose>
					<when test="param.empNums.size() > 1">
						AND b.emp_num IN
						(
						<foreach item="it" index="index" collection="param.empNums" separator="," close="" >
				        	#{it}
						</foreach>
						) 
					</when>
					<otherwise>
302
						AND b.emp_num = #{param.empNums[0]}
tangzhaoqian committed
303 304 305 306 307 308 309 310 311 312
					</otherwise>
				</choose>
        	</if>
        
        	<if test="param.query != null and param.query != ''">
        		AND (
        			b.name like CONCAT('%',#{param.query},'%') or
        			b.phone like CONCAT('%',#{param.query},'%')
        		)
        	</if>
lal committed
313
        	and ( SELECT id FROM zzgl_bmgw_m WHERE id = ( SELECT up_id FROM zzgl_bmgw_m WHERE id = b.bmgw_id LIMIT 1 ) LIMIT 1 ) = #{param.deptid}
314
        </where>
tangzhaoqian committed
315 316 317 318
        ORDER BY a.id DESC
        	
    </select>
    
319 320 321 322 323 324 325 326 327 328 329 330 331 332 333
    <select id="selectListEmpByQuery" resultMap="BaseResultMap_Emp" >
    	SELECT
    		a.emp_num,
	        b.name user_name, b.phone,b.rz_time,
	        	(SELECT name FROM zzgl_bmgw_m WHERE id = (SELECT up_id FROM zzgl_bmgw_m WHERE id = b.bmgw_id limit 1) limit 1) as bm_name,
	        	SUM((CASE WHEN c.sts = 3 THEN 1 ELSE 0 END)) AS archivedPNum,
	        	SUM((CASE WHEN c.sts in (0,1,2) THEN 1 ELSE 0 END)) AS underwayPNum,
	        	(SELECT name FROM jxgl_performance_appraisal WHERE id = a.performance_appraisal_id ORDER BY create_time DESC LIMIT 1 ) recentlyProject,
				(SELECT comprehensive_score FROM jxgl_appraisal_assessment WHERE type = 1 AND appraisal_id in (SELECT id FROM jxgl_appraisal WHERE emp_num = a.emp_num) ORDER BY create_time DESC LIMIT 1 ) recentlyScore,
				(SELECT level FROM jxgl_appraisal_assessment WHERE type = 1 AND appraisal_id in (SELECT id FROM jxgl_appraisal WHERE emp_num = a.emp_num) ORDER BY create_time DESC LIMIT 1 ) recentlyLevel
	        FROM jxgl_appraisal a 
	        LEFT JOIN yggl_main_emp b ON a.emp_num = b.emp_num AND b.org_code = #{param.orgCode}
			LEFT JOIN jxgl_performance_appraisal c ON a.performance_appraisal_id = c.id
        
        <where>
tangzhaoqian committed
334
        	 c.org_code = #{param.orgCode} 
335 336 337 338 339 340
        	<if test="param.query != null and param.query != ''">
        		and (
        			b.name like CONCAT('%',#{param.query},'%') or
        			b.phone like CONCAT('%',#{param.query},'%')
        		)
        	</if>
341 342 343 344 345 346 347 348 349 350 351 352 353 354 355
        	<if test="param.empNums != null and param.empNums.size() > 0">
        		<choose>
					<when test="param.empNums.size() > 1">
						AND b.emp_num IN
						(
						<foreach item="it" index="index" collection="param.empNums" separator="," close="" >
				        	#{it}
						</foreach>
						) 
					</when>
					<otherwise>
						AND asso_id = #{param.empNums[0]}
					</otherwise>
				</choose>
        	</if>
356 357 358 359
		</where>
		GROUP BY a.emp_num
        ORDER BY a.id DESC
    </select>
360 361 362 363

	<select id="selectDetailById" resultMap="BaseResultMap_Detail">
        SELECT 
        	<include refid="Base_Column_List_a" />,
364
        	j.head_url head_url,
365
        	<include refid="Base_Column_List_Alias_b" />,
366
        	i.name JxglProcessNode_executor_name,
367 368 369 370
        	<include refid="Base_Column_List_Alias_c" />,
        	<include refid="Base_Column_List_Alias_d" />,
        	<include refid="Base_Column_List_Alias_e" />,
        	<include refid="Base_Column_List_Alias_f" />,
tangzhaoqian committed
371 372
        	<include refid="Base_Column_List_Alias_g" />,
        	h.name appraisal_name
373 374 375 376 377 378 379 380
        FROM 
        	jxgl_appraisal a
        LEFT JOIN jxgl_process_node b ON a.id = b.appraisal_id
        LEFT JOIN jxgl_appraisal_assessment c ON a.id = c.appraisal_id
        LEFT JOIN jxgl_appraisal_log d ON a.id = d.appraisal_id
        LEFT JOIN jxgl_appraisal_indicators e ON a.id = e.appraisal_id
        LEFT JOIN jxgl_appraisal_indicators_assessment f ON e.id = f.appraisal_indicators_id
        LEFT JOIN jxgl_appraisal_item g ON e.id = g.appraisal_indicators_id
tangzhaoqian committed
381
        LEFT JOIN jxgl_performance_appraisal h ON a.performance_appraisal_id = h.id
382
        LEFT JOIN yggl_main_emp i ON b.executor_id = i.emp_num AND i.org_code = #{orgCode}
383
        LEFT JOIN yggl_main_emp j ON a.emp_num = j.emp_num AND j.org_code = #{orgCode}
384
        WHERE a.id = #{id}
385
        ORDER BY c.id , d.id , b.process_type
386
    </select>
387 388 389 390 391 392

	<!-- 

    <insert id="insert" useGeneratedKeys="true" keyColumn="id" parameterType="cn.timer.api.bean.jxgl.JxglAppraisal">
        INSERT INTO jxgl_appraisal
        <trim prefix="(" suffix=")" suffixOverrides=",">
393 394 395
                        <if test ='null != performanceAppraisalId'>
                        performance_appraisal_id,
                        </if>
396 397 398 399 400 401 402 403 404
                        <if test ='null != empNum'>
                        emp_num,
                        </if>
                        <if test ='null != name'>
                        name,
                        </if>
                        <if test ='null != appraisalExplain'>
                        appraisal_explain,
                        </if>
405 406 407 408 409 410
                        <if test ='null != total'>
                        total,
                        </if>
                        <if test ='null != level'>
                        level,
                        </if>
411 412 413 414 415 416 417 418 419 420 421
                        <if test ='null != createTime'>
                        create_time,
                        </if>
                        <if test ='null != updateTime'>
                        update_time,
                        </if>
                        <if test ='null != sts'>
                        sts
                        </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
422 423 424
                        <if test ='null != performanceAppraisalId'>
                        #{performanceAppraisalId},
                        </if>
425 426 427 428 429 430 431 432 433
                        <if test ='null != empNum'>
                        #{empNum},
                        </if>
                        <if test ='null != name'>
                        #{name},
                        </if>
                        <if test ='null != appraisalExplain'>
                        #{appraisalExplain},
                        </if>
434 435 436 437 438 439
                        <if test ='null != total'>
                        #{total},
                        </if>
                        <if test ='null != level'>
                        #{level},
                        </if>
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459
                        <if test ='null != createTime'>
                        #{createTime},
                        </if>
                        <if test ='null != updateTime'>
                        #{updateTime},
                        </if>
                        <if test ='null != sts'>
                        #{sts}
                        </if>
        </trim>
    </insert>

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

    <update id="update" parameterType="cn.timer.api.bean.jxgl.JxglAppraisal">
        UPDATE jxgl_appraisal
        <set>
460
                    <if test ='null != performanceAppraisalId'>performance_appraisal_id = #{performanceAppraisalId},</if>
461 462 463
                    <if test ='null != empNum'>emp_num = #{empNum},</if>
                    <if test ='null != name'>name = #{name},</if>
                    <if test ='null != appraisalExplain'>appraisal_explain = #{appraisalExplain},</if>
464 465
                    <if test ='null != total'>total = #{total},</if>
                    <if test ='null != level'>level = #{level},</if>
466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493
                    <if test ='null != createTime'>create_time = #{createTime},</if>
                    <if test ='null != updateTime'>update_time = #{updateTime},</if>
                    <if test ='null != sts'>sts = #{sts}</if>
        </set>
        WHERE id = #{id}
    </update>


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

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

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

	 -->

</mapper>