zouyu
2026-04-20 1fb4735cf75f6b98b8d81611a95ccea395cba323
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
<?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.ruoyi.performance.mapper.PerformanceShiftMapper">
 
    <resultMap id="performanceShiftMap" type="com.ruoyi.performance.dto.PerformanceShiftMapDto">
        <id column="id" property="id"/>
        <result column="shift" property="shift"/>
        <result column="work_time" property="workTime"/>
        <result column="annotation_text" property="annotationText"/>
        <result column="user_name" property="userName"/>
        <result column="shift_time" property="shiftTime"/>
        <result column="user_id" property="userId" />
        <result column="department" property="department" />
    </resultMap>
 
    <select id="performanceShift" resultMap="performanceShiftMap">
        SELECT
        s.id,
        s.shift,
        s.work_time,
        s.annotation_text,
        sd.dict_label AS shift_name,
        u2.name AS user_name,
        u2.id user_id
        FROM performance_shift s
        left join sys_dict_data sd on s.shift = sd.dict_value and sd.dict_type='sys_class_type'
        LEFT JOIN (SELECT distinct u.* from
        user u
        left join department_lims dl on FIND_IN_SET(dl.id,u.depart_lims_id)
        where status = '0'
        and del_flag = '0'
        <if test="laboratory != null and laboratory != ''">
          and   dl.name=#{laboratory}
        </if>
         ) u2    on u2.id = s.user_id
        <where>
            u2.name is not null
            <if test="firstDayOfMonth != null and lastDayOfMonth != null">
                AND s.work_time BETWEEN #{firstDayOfMonth} AND #{lastDayOfMonth}
            </if>
            <if test="userName != null and userName != ''">
                and u2.name like concat('%', #{userName}, '%')
            </if>
        </where>
        order by s.work_time
    </select>
 
    <select id="performanceShiftYear" resultMap="performanceShiftMap">
        SELECT distinct
        u2.name AS user_name,
        s.user_id,
        u2.account,
        sd.dict_label AS shift_name,
        s.work_time,
        s.shift,
        s.id
        FROM performance_shift s
        left join sys_dict_data sd on s.shift = sd.dict_value and sd.dict_type='sys_class_type'
        LEFT JOIN (SELECT u.* from
        user u
        left join department_lims dl on FIND_IN_SET(dl.id,u.depart_lims_id)
        where status = '0'
        and del_flag = '0'
        <if test="laboratory != null and laboratory != ''">
            and   dl.name=#{laboratory}
        </if>
        ) u2   on u2.id = s.user_id
        where s.shift is not NULL
        and s.shift != ''
        and name is not null
        <if test="startDateTime != null and endDateTime != null">
            and s.work_time between #{startDateTime} and #{endDateTime}
        </if>
        <if test="userName != null and userName != ''">
            and u2.name like concat('%', #{userName}, '%')
        </if>
        order by s.work_time
    </select>
 
    <select id="performanceShiftYearList" resultType="map">
        SELECT
        u.name name,
        s.user_id, u.account,
        DATE_FORMAT(s.work_time, '%c') work_time,
        GROUP_CONCAT(DATE_FORMAT(s.work_time, '%c'), ':', s.shift order by s.work_time SEPARATOR ';') month_str
        FROM performance_shift s
        LEFT JOIN user u on u.id = s.user_id
        where s.shift is not NULL
        and s.shift != ''
        <if test="time != null and time != ''">
            and DATE_FORMAT(s.work_time, '%Y') = DATE_FORMAT(#{time}, '%Y' )
        </if>
        <if test="userName != null and userName != ''">
            and u.name like concat('%', #{userName}, '%')
        </if>
        <if test="laboratory != null and laboratory != ''">
        </if>
        GROUP BY u.id
        order by s.create_time
    </select>
 
    <select id="performanceShiftList" resultMap="performanceShiftMap">
        SELECT
        u.name name,
        GROUP_CONCAT(s.work_time, ':', s.shift, ':', s.id order by s.work_time SEPARATOR ';') AS shift_time, u.id user_id
        FROM performance_shift s
        LEFT JOIN user u on u.id = s.user_id
        <where>
            <if test="time != null and time != ''">
                and DATE_FORMAT(s.work_time, '%Y-%m') = DATE_FORMAT(#{time}, '%Y-%m' )
            </if>
            <if test="userName != null and userName != ''">
                and u.name like concat('%', #{userName}, '%')
            </if>
            <if test="laboratory != null and laboratory != ''">
            </if>
        </where>
        GROUP BY u.id
        order by s.create_time
    </select>
 
    <select id="seldepLimsId" resultType="java.lang.String">
        select name
        from department_lims
        where id = #{depLimsId}
    </select>
    <select id="selectListByWorkTime" resultType="com.ruoyi.performance.dto.PerformanceShiftMapDto">
        SELECT
            ps.id,
            ps.shift,
            ps.work_time,
            ps.user_id,
            u.name AS user_name,
            u.account AS person_code,
            st.start_time,
            st.end_time,
            sd.dict_label AS shift_name,
            ps.annotation_text
        FROM performance_shift ps
        inner JOIN user u ON ps.user_id = u.id
        LEFT JOIN shift_time st ON ps.shift = st.shift
        left join sys_dict_data sd on ps.shift = sd.dict_value AND sd.dict_type='sys_class_type'
        <where>
            <if test="startTime!=null and endTime!=null">
                AND ps.work_time BETWEEN #{startTime} AND #{endTime}
            </if>
            <if test="keyword!='' and keyword!=null">
                AND (u.account like concat('%',#{keyword},'%') OR u.name like concat('%',#{keyword},'%'))
            </if>
        </where>
        ORDER BY ps.work_time,u.sort
    </select>
</mapper>