xieb
2024-02-21 a2e5aea180e13b868edd3eac3318042f87c10141
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<?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="org.springblade.modules.assessment.mapper.AssessmentScoreMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="assessmentScoreResultMap" type="org.springblade.modules.assessment.entity.AssessmentScoreEntity">
        <result column="id" property="id"/>
        <result column="tenant_id" property="tenantId"/>
        <result column="assessment_task_id" property="assessmentTaskId"/>
        <result column="be_id" property="beId"/>
        <result column="score_user_id" property="scoreUserId"/>
        <result column="score_val" property="scoreVal"/>
        <result column="remark" property="remark"/>
        <result column="type" property="type"/>
        <result column="range_val" property="rangeVal"/>
        <result column="weight" property="weight"/>
        <result column="create_user" property="createUser"/>
        <result column="create_dept" property="createDept"/>
        <result column="create_time" property="createTime"/>
        <result column="update_user" property="updateUser"/>
        <result column="update_time" property="updateTime"/>
        <result column="status" property="status"/>
        <result column="is_deleted" property="isDeleted"/>
    </resultMap>
 
    <resultMap id="assessmentScoreResultInfoMap" type="org.springblade.modules.assessment.vo.AssessmentScoreVO">
        <result column="id" property="id"/>
        <result column="tenant_id" property="tenantId"/>
        <result column="assessment_task_id" property="assessmentTaskId"/>
        <result column="be_id" property="beId"/>
        <result column="score_user_id" property="scoreUserId"/>
        <result column="score_val" property="scoreVal"/>
        <result column="remark" property="remark"/>
        <result column="type" property="type"/>
        <result column="range_val" property="rangeVal"/>
        <result column="weight" property="weight"/>
        <result column="create_user" property="createUser"/>
        <result column="create_dept" property="createDept"/>
        <result column="create_time" property="createTime"/>
        <result column="update_user" property="updateUser"/>
        <result column="update_time" property="updateTime"/>
        <result column="status" property="status"/>
        <result column="is_deleted" property="isDeleted"/>
    </resultMap>
 
 
    <select id="selectAssessmentScorePage" resultMap="assessmentScoreResultMap">
        select * from yw_assessment_score where is_deleted = 0
    </select>
 
    <select id="selectAssessmentScoreInfoPage" resultMap="assessmentScoreResultInfoMap">
        select a.*,b.name as scoreUserName,c.dept_name AS scoreDeptName , d.post_name AS scorePostName ,
        <if test="assessmentScore.type != null and assessmentScore.type == 0">
            bb.`name` as userName,cc.dept_name as deptName,dd.post_name as postName
        </if>
        <if test="assessmentScore.type != null and assessmentScore.type == 1">
            ccc.dept_name as deptName
        </if>
        from yw_assessment_score a
        LEFT JOIN blade_user b ON (a.create_user = b.id)
        LEFT JOIN blade_dept c ON (b.dept_id = c.id)
        LEFT JOIN blade_post d ON (b.post_id = d.id)
 
        LEFT JOIN blade_user bb ON (a.be_id = bb.id)
        LEFT JOIN blade_dept cc ON (bb.dept_id = cc.id)
        LEFT JOIN blade_post dd ON (bb.post_id = dd.id)
 
        LEFT JOIN blade_dept ccc ON (a.be_id = ccc.id)
 
        <where>
            and a.is_deleted = 0
            <if test="assessmentScore.assessmentTaskId != null and assessmentScore.assessmentTaskId != ''">
                and a.assessment_task_id = #{assessmentScore.assessmentTaskId}
            </if>
            <if test="assessmentScore.type != null">
                and a.type = #{assessmentScore.type}
            </if>
            <if test="assessmentScore.userName != null and assessmentScore.userName != ''">
                and bb.name like concat('%', #{assessmentScore.userName}, '%')
            </if>
            <if test="assessmentScore.scoreUserName != null and assessmentScore.scoreUserName != ''">
                and b.name like concat('%', #{assessmentScore.scoreUserName}, '%')
            </if>
            <if test="assessmentScore.deptName != null and assessmentScore.deptName != '' and assessmentScore.type != null and assessmentScore.type == 1">
                and ccc.dept_name like concat('%', #{assessmentScore.deptName}, '%')
            </if>
            <if test="assessmentScore.deptName != null and assessmentScore.deptName != '' and assessmentScore.type != null and assessmentScore.type == 0">
                and cc.dept_name like concat('%', #{assessmentScore.deptName}, '%')
            </if>
        </where>
    </select>
 
    <select id="selectAssessmentScoreInfoV2Page" resultMap="assessmentScoreResultInfoMap">
        select a.user_name as scoreUserName,a.dept_name as scoreDeptName,a.post_name as scorePostName,
               b.user_name,b.dept_name ,b.post_name,
 
        <if test="assessmentScore.type != null and assessmentScore.type == 0">
            c.score_val,c.remark,c.type,a.weight
        </if>
        <if test="assessmentScore.type != null and assessmentScore.type == 1">
            d.score_val,d.remark,d.type,a.weight
        </if>
        from yw_assessment_set_assessor a
        LEFT JOIN yw_assessment_set b ON (a.assessment_set_id = b.id)
        <if test="assessmentScore.type != null and assessmentScore.type == 0">
            LEFT JOIN yw_assessment_score c ON (a.user_id = c.score_user_id and (b.user_id = c.be_id) and c.is_deleted = 0)
        </if>
        <if test="assessmentScore.type != null and assessmentScore.type == 1">
            LEFT JOIN yw_assessment_score d ON (a.user_id = d.score_user_id and (b.dept_id = d.be_id) and d.is_deleted = 0)
        </if>
 
        <where>
            and a.is_deleted = 0
            <if test="assessmentScore.assessmentTaskId != null and assessmentScore.assessmentTaskId != ''">
                and b.assessment_task_id = #{assessmentScore.assessmentTaskId}
            </if>
            <if test="assessmentScore.type != null and assessmentScore.type == 0">
                and b.user_id is not null
            </if>
            <if test="assessmentScore.type != null and assessmentScore.type == 1">
                and b.user_id is null
            </if>
            <if test="assessmentScore.userName != null and assessmentScore.userName != ''">
                and b.user_name like concat('%', #{assessmentScore.userName}, '%')
            </if>
            <if test="assessmentScore.scoreUserName != null and assessmentScore.scoreUserName != ''">
                and a.user_name like concat('%', #{assessmentScore.scoreUserName}, '%')
            </if>
            <if test="assessmentScore.deptName != null and assessmentScore.deptName != ''">
                and b.dept_name like concat('%', #{assessmentScore.deptName}, '%')
            </if>
        </where>
    </select>
 
    <select id="selectAssessmentScoreGroupByBeidPage" resultMap="assessmentScoreResultMap">
        select a.id,a.assessment_task_id,a.be_id,a.score_user_id,SUM(a.weight*a.score_val*0.01) as score_val,a.type from yw_assessment_score a
        <if test="assessmentScore.type != null and assessmentScore.type == 0">
            LEFT JOIN blade_user b on (a.be_id = b.id)
            left join blade_dept c on b.dept_id = c.id
        </if>
        <if test="assessmentScore.type != null and assessmentScore.type == 1">
            left join blade_dept c on a.be_id = c.id
        </if>
 
        <where>
            and a.is_deleted = 0
            <if test="assessmentScore.type != null and assessmentScore.type != ''">
                and a.type = #{assessmentScore.type}
            </if>
            <if test="assessmentScore.assessmentTaskId != null and assessmentScore.assessmentTaskId != ''">
                and a.assessment_task_id = #{assessmentScore.assessmentTaskId}
            </if>
            <if test="assessmentScore.userName != null and assessmentScore.userName != ''">
                and b.name like concat('%', #{assessmentScore.userName},'%')
            </if>
            <if test="assessmentScore.deptId != null and assessmentScore.deptId != ''">
                and c.id = #{assessmentScore.deptId}
            </if>
            <if test="assessmentScore.deptName != null and assessmentScore.deptName != ''">
                and c.dept_name like concat('%', #{assessmentScore.deptName},'%')
            </if>
        </where>
        group by a.be_id
    </select>
 
 
    <select id="exportAssessmentScore" resultType="org.springblade.modules.assessment.excel.AssessmentScoreExcel">
        SELECT * FROM yw_assessment_score ${ew.customSqlSegment}
    </select>
 
</mapper>