Van333
2022-12-29 d8f66b834134f6b755fd3fb93bb91b56f9d31f6f
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
<?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="api.dao.HuinengMachineErrorDao">
 
    <select id="findAllBySort" resultType="api.bean.HuinengMachineError">
        select
            ps.streetlight_name ,
            ps.streetlight_id,
            pe.photovoltaic_name,
            pe.photovoltaic_id,
            hme.*
        from
            pole_streetlight ps
                right join
            (
                select
                    *
                from
                    huineng_machine_error
                        join
                    (
                        select
                            max(error_id) as id
                        from
                            huineng_machine_error
                        group by
                            streetlight_mac
                        limit #{page},#{size}
                    ) a
                    on
                        error_id = a.id ) hme
            on
                hme.streetlight_mac = ps.code_number
                join
            photovoltaic_entity pe
            on
                pe.bind_pole_streelight_id = streetlight_id
    </select>
 
    <select id="findByCompanyBySort"
            resultType="api.bean.HuinengMachineError">
        select
            *
        from
            huineng_machine_error hme
                join
            (
                select
                    *
                from
                    (
                        select
                            ps.streetlight_id ,
                            ps.streetlight_name,
                            ps.code_number
                        from
                            pole_streetlight ps
                        where
                                ps.streetlight_id in (
                                select
                                    pus.streetlight_id
                                from
                                    pole_user_streetlight pus
                                where
                                        pus.company_id in(
                                        select
                                            suc.company_id
                                        from
                                            sys_user_company suc
                                        where
                                                suc.user_id =
                                                #{userId}
 
                                    )
                            )
                        limit #{page},#{size}) streetlight
                        join
                    (
                        select
                            max(error_id) as maxid,
                            streetlight_mac
                        from
                            huineng_machine_error hme2
                        group by
                            streetlight_mac
                    ) a
                    on
                        a.streetlight_mac = streetlight.code_number)
                b
            on
                b.maxid = hme.error_id
                join
            photovoltaic_entity pe
            on
                pe.bind_pole_streelight_id = streetlight_id
 
 
    </select>
 
    <select id="findByPhotovoltaicId"
            resultType="api.bean.HuinengMachineError"
            parameterType="java.lang.Integer">
 
        select
            ps.streetlight_name ,
            ps.streetlight_id,
            hme.*,
            pe.photovoltaic_name,
            pe.photovoltaic_id
        from
            pole_streetlight ps
                right join
            (
                select
                    *
                from
                    huineng_machine_error
            ) hme
            on
                hme.streetlight_mac = ps.code_number
                join
            photovoltaic_entity pe
            on
                pe.bind_pole_streelight_id = streetlight_id
        where ps.streetlight_id in (
            select pe.bind_pole_streelight_id  from photovoltaic_entity pe where pe.photovoltaic_id = #{photovoltaicId})
    </select>
</mapper>