zss
2024-05-31 94adc6f8c317f26da2f1f3b65224ac262670bdd8
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
<?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.AuxiliaryOriginalHoursMapper">
    <select id="totalHours" resultType="java.util.Map">
        select E.name, E.month, E.total
        from (select C.name, C.month, C.manHours + D.manHours as total
        from (select A.name,
        A.month,
        sum(A.manHour) as manHours
        from (
        select user.name,
        case
        when reviewer_nonproductive_time is null then nonproductive_time
        else reviewer_nonproductive_time end as manHour,
        date_time                                as month
        from auxiliary_working_hours_day awhd
        left join user on user.id = awhd.name_user
        left join department_lims dl on depart_lims_id = dl.id
        where date_time LIKE CONCAT('%', #{month}, '%')
        and awhd.state='已批准'
        <if test="ids !=null and ids != ''">
            and name_user in
            <foreach collection="ids" index="index" open="(" separator="," close=")" item="val">
                #{val}
            </foreach>
        </if>
        order by month
        ) A
        group by A.name, A.month) C
        LEFT JOIN
        (select B.name,
        B.month,
        B.manHours
        from (
        select user.name,
        date_time             as month,
        sum(output_work_time) as manHours
        from auxiliary_output_working_hours aowh
        left join user on user.id = aowh.`check`
        left join department_lims dl on depart_lims_id = dl.id
        where date_time LIKE CONCAT('%', #{month}, '%')
        <if test="ids !=null and ids != ''">
            and `check` in
            <foreach collection="ids" index="index" open="(" separator="," close=")" item="val">
                #{val}
            </foreach>
        </if>
        group by user.name, month
        order by user.name, month
        ) B
        group by B.name, B.month) D
        on C.month = D.month
        where C.name = D.name
        ) E
        group by E.name, E.month
    </select>
</mapper>