Crunchy
2024-07-30 d57d7dd3b307c53b8553414db708161c67b85628
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
<?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.yuanchu.mom.mapper.PerformanceShiftMapper">
 
    <resultMap id="performanceShiftPageMap" type="com.yuanchu.mom.dto.PerformanceShiftMapDto">
        <result column="name" property="name"/>
        <result column="shift_time" property="shiftTime"/>
        <result column="user_id" property="userId" />
        <result column="department" property="department" />
    </resultMap>
 
    <select id="performanceShiftPage" resultMap="performanceShiftPageMap">
        SELECT
        if(u2.department is not null and u2.department != '', CONCAT(u2.name, '(', u2.department, ')'), u2.name) name,
        GROUP_CONCAT(s.work_time, ':', s.shift, ':', s.id order by s.work_time SEPARATOR ';') AS shift_time, u2.id user_id
        FROM performance_shift s
        LEFT JOIN (SELECT distinct u.* from
        user u
        left join department_lims dl on FIND_IN_SET(dl.id,u.depart_lims_id)
        where state=1
        <if test="laboratory != null and laboratory != ''">
          and   dl.name=#{laboratory}
        </if>
         ) u2    on u2.id = s.user_id
        <where>
            name is not null
            <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 u2.name like concat('%', #{userName}, '%')
            </if>
        </where>
        GROUP BY u2.id
        order by s.create_time
    </select>
 
    <select id="performanceShiftYearPage" resultType="map">
        SELECT
        s.user_id, s.shift
        FROM performance_shift s
        LEFT JOIN (SELECT u.* from
        user u
        left join department_lims dl on FIND_IN_SET(dl.id,u.depart_lims_id)
        where state=1
        <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="time != null and time != ''">
            and DATE_FORMAT(s.work_time, '%Y') = DATE_FORMAT(#{time}, '%Y' )
        </if>
        <if test="userName != null and userName != ''">
            and u2.name like concat('%', #{userName}, '%')
        </if>
        order by s.create_time
    </select>
 
    <select id="performanceShiftYear" resultType="java.util.Map">
        SELECT if(u2.department is not null and u2.department != '', CONCAT(u2.name, '(', u2.department, ')'), u2.name) name,
        s.user_id, u2.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 (SELECT u.* from
        user u
        left join department_lims dl on FIND_IN_SET(dl.id,u.depart_lims_id)
        where state=1
        <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="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>
        GROUP BY u2.id
        order by s.create_time
    </select>
 
    <select id="performanceShiftYearList" resultType="map">
        SELECT if(u.department is not null and u.department != '', CONCAT(u.name, '(', u.department, ')'), 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="performanceShiftPageMap">
        SELECT
        if(u.department is not null and u.department != '', CONCAT(u.name, '(', u.department, ')'), 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, u.department
        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>
</mapper>