yangys
2024-10-29 d728f14a2f23cb477ebfecd33df5f7e5cb54a178
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
<?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.qianwen.smartman.modules.perf.mapper.EmployeeOnOffWorkMapper">
 
    <select id="queryWork" resultType="com.qianwen.smartman.modules.perf.entity.EmployeeOnOffWork">
        select *
        from blade_employee_on_off_work beoow1
        where beoow1.id in
        (select max(id)
        from blade_employee_on_off_work beoow2
        where beoow2.workstation_id IN
        <foreach collection="wIds" item="id" open="(" separator="," close=")">
            #{id}
        </foreach>
        and beoow2.is_deleted = 0
        <if test="onType != null">
            and beoow2.online_type = #{onType}
        </if>
        group by beoow2.workstation_id)
    </select>
 
    <select id="willOnWork" resultType="com.qianwen.smartman.modules.cps.vo.GroupTreeVO">
        select bw.id,
               bw.code,
               bw.name,
               bw.avatar,
               bcg.id   parentId,
               0 as isGroup
        from blade_workstation bw
                 inner join blade_common_group_of_item bcgoi on bw.id = bcgoi.item_id
                 inner join blade_common_group bcg on bcgoi.group_id = bcg.id
        where bw.is_deleted = 0
          and bw.status = 1
          and not exists(select max(beoow.id)
                         from blade_employee_on_off_work beoow
                         where beoow.workstation_id = bw.id
                           and beoow.is_deleted = 0
                           and beoow.online_type = #{onType}
                         group by beoow.workstation_id
            )
    </select>
 
    <select id="willOffWork" resultType="com.qianwen.smartman.modules.perf.vo.OffEmployeeTreeVO">
        select beoow.workstation_id   as id,
               beoow.workstation_code as code,
               beoow.workstation_name as name,
               bcg.id                 as parentId,
               0                     isGroup,
               beoow.id               as logId
        from blade_employee_on_off_work beoow
                 inner join blade_common_group_of_item bcgoi on beoow.workstation_id = bcgoi.item_id
                 inner join blade_common_group bcg on bcgoi.group_id = bcg.id
        where beoow.id in (select max(id)
                           from blade_employee_on_off_work beoow2
                           where beoow2.is_deleted = 0
                             and beoow2.online_type = #{onType}
                           group by beoow2.workstation_id)
    </select>
 
    <select id="currWorkLog" resultType="com.qianwen.smartman.modules.perf.vo.CurrWorkDetailVO">
        select id,
               online_time      as onlineTime,
               offline_time     as offlineTime,
               on_employee_id   as employeeId,
               on_employee_code as employeeCode,
               on_employee_name as employeeName,
               workstation_id   as workstationId,
               workstation_code as workstationCode,
               workstation_name as workstationName,
               create_time      as createTime,
               online_type      as onlineType
        from blade_employee_on_off_work
        <if test="_databaseId == 'mysql' ">
            where id in (select MAX(id) as id
            from blade_employee_on_off_work
            where is_deleted = 0
            and workstation_id = #{workstationId}
            group by on_employee_name)
            order by online_time desc
            limit 0,10;
        </if>
        <if test="_databaseId == 'dm' ">
            where id in (select MAX(id) as id
            from blade_employee_on_off_work
            where is_deleted = 0
            and workstation_id = #{workstationId}
            group by on_employee_name)
            order by online_time desc
            limit 0,10;
        </if>
        <if test="_databaseId == 'oracle' ">
            where id in (select MAX(id) as id
            from blade_employee_on_off_work
            where is_deleted = 0
            and workstation_id = #{workstationId}
            group by on_employee_name)
            and ROWNUM &lt;= 10
            order by online_time desc;
        </if>
    </select>
</mapper>