whyclxw
6 天以前 2753ad7aee272a5a5a8a0124b1feea5a1e4cc83e
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
<?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.whyc.mapper.StationInfMapper">
 
    <select id="getMaxStationId" resultType="java.lang.Integer">
        select ifnull(max(station_id),0) from  db_station.tb_station_inf where station_id>0;
    </select>
    <resultMap id="name1List" type="provice">
        <result property="provice" column="provice" ></result>
        <result property="uid" column="uid" ></result>
        <collection property="cityList" javaType="java.util.ArrayList" ofType="com.whyc.dto.Station.City" column="{provice=provice,uid=uid}" select="selectCity">
        </collection>
    </resultMap>
    <select id="getLeftStation" resultMap="name1List">
          select distinct provice,#{uid} as uid from db_station.tb_station_inf
          <where>
          <if test="uid>100">
            and tb_station_inf.station_id in(
            select distinct station_id from db_user.tb_baojigroup_power,db_user.tb_baojigroup_usr
            where   tb_baojigroup_power.baoji_group_id=tb_baojigroup_usr.baoji_group_id
            and tb_baojigroup_usr.uid=#{uid}
            )
         </if>
          </where>
    </select>
 
    <resultMap id="name2List" type="city">
        <result property="provice" column="provice"></result>
        <result property="city" column="city" ></result>
        <result property="uid" column="uid" ></result>
        <collection property="countryList" javaType="java.util.ArrayList" ofType="com.whyc.dto.Station.Country" column="{provice=provice,city=city,uid=uid}" select="selectCountry">
        </collection>
    </resultMap>
    <select id="selectCity" resultMap="name2List">
        SELECT distinct #{provice} as provice,#{uid} as uid,city from  db_station.tb_station_inf
        <where>
            provice=#{provice}
            <if test="uid>100">
                and tb_station_inf.station_id in(
                select distinct station_id from db_user.tb_baojigroup_power,db_user.tb_baojigroup_usr
                where   tb_baojigroup_power.baoji_group_id=tb_baojigroup_usr.baoji_group_id
                and tb_baojigroup_usr.uid=#{uid}
                )
            </if>
        </where>
    </select>
 
    <resultMap id="name3List" type="country">
        <result property="provice" column="provice"></result>
        <result property="city" column="city" ></result>
        <result property="country" column="country" ></result>
        <result property="uid" column="uid" ></result>
        <collection property="stationList" javaType="java.util.ArrayList" ofType="com.whyc.dto.Station.Station" column="{provice=provice,city=city,country=country,uid=uid}" select="selectStation">
        </collection>
    </resultMap>
    <select id="selectCountry" resultMap="name3List">
        SELECT distinct #{provice} as provice, #{city} as city,#{uid} as uid,country from  db_station.tb_station_inf
        where provice=#{provice} and city=#{city}
        <if test="uid>100">
            and tb_station_inf.station_id in(
            select distinct station_id from db_user.tb_baojigroup_power,db_user.tb_baojigroup_usr
            where   tb_baojigroup_power.baoji_group_id=tb_baojigroup_usr.baoji_group_id
            and tb_baojigroup_usr.uid=#{uid}
            )
        </if>
    </select>
 
    <resultMap id="name4List" type="station">
        <result property="provice" column="provice"></result>
        <result property="city" column="city" ></result>
        <result property="country" column="country" ></result>
        <result property="stationName" column="station_name" ></result>
        <result property="stationId" column="station_id" ></result>
        <result property="uid" column="uid" ></result>
        <collection property="pinflist" javaType="java.util.ArrayList" ofType="com.whyc.dto.Station.Power" column="{stationId=station_id,uid=uid}" select="selectPower">
        </collection>
    </resultMap>
    <select id="selectStation" resultMap="name4List">
        SELECT distinct #{provice} as provice, #{city} as city, #{country} as country,#{uid} as uid,station_name,station_id from  db_station.tb_station_inf
        where provice=#{provice} and city=#{city} and country=#{country}
        <if test="uid>100">
            and tb_station_inf.station_id in(
            select distinct station_id from db_user.tb_baojigroup_power,db_user.tb_baojigroup_usr
            where   tb_baojigroup_power.baoji_group_id=tb_baojigroup_usr.baoji_group_id
            and tb_baojigroup_usr.uid=#{uid}
            )
        </if>
    </select>
    <resultMap id="name5List" type="power">
        <result property="powerId" column="power_id"></result>
        <result property="stationId" column="station_id" ></result>
        <result property="powerName" column="power_name" ></result>
        <collection property="battList" javaType="java.util.ArrayList" ofType="com.whyc.dto.Station.Batt" column="{powerId=power_id}" select="selectBatt">
        </collection>
    </resultMap>
    <select id="selectPower" resultMap="name5List">
        SELECT distinct tb_power_inf.power_id,power_name,station_id from db_station.tb_power_inf
        where tb_power_inf.station_id=#{stationId}
        <if test="uid>100">
            and tb_power_inf.power_id in(
            select distinct power_id from db_user.tb_baojigroup_power,db_user.tb_baojigroup_usr
            where   tb_baojigroup_power.baoji_group_id=tb_baojigroup_usr.baoji_group_id
            and tb_baojigroup_usr.uid=#{uid}
            )
        </if>
    </select>
 
    <select id="selectBatt" resultType="batt">
        SELECT distinct tb_batt_inf.battgroup_id,battgroup_name,power_id,station_id,dev_id,dev_name from db_station.tb_batt_inf
        where tb_batt_inf.power_id=#{powerId}
    </select>
    
    <select id="getProviceByUid" resultType="java.lang.String">
        select distinct provice from db_station.tb_station_inf
        <where>
            <if test="uid>100">
                and tb_station_inf.station_id in(
                select distinct station_id from db_user.tb_baojigroup_power,db_user.tb_baojigroup_usr
                where   tb_baojigroup_power.baoji_group_id=tb_baojigroup_usr.baoji_group_id
                and tb_baojigroup_usr.uid=#{uid}
                )
            </if>
        </where>
    </select>
    <select id="getCityByUid" resultType="java.lang.String">
        select distinct city from db_station.tb_station_inf
        <where>
            <if test="provice!=null">
                and provice=#{provice}
            </if>
            <if test="uid>100">
                and tb_station_inf.station_id in(
                select distinct station_id from db_user.tb_baojigroup_power,db_user.tb_baojigroup_usr
                where   tb_baojigroup_power.baoji_group_id=tb_baojigroup_usr.baoji_group_id
                and tb_baojigroup_usr.uid=#{uid}
                )
            </if>
        </where>
    </select>
    <select id="getCountryByUid" resultType="java.lang.String">
        select distinct country from db_station.tb_station_inf
        <where>
            <if test="provice!=null">
                and provice=#{provice}
            </if>
            <if test="city!=null">
                and city=#{city}
            </if>
            <if test="uid>100">
                and tb_station_inf.station_id in(
                select distinct station_id from db_user.tb_baojigroup_power,db_user.tb_baojigroup_usr
                where   tb_baojigroup_power.baoji_group_id=tb_baojigroup_usr.baoji_group_id
                and tb_baojigroup_usr.uid=#{uid}
                )
            </if>
        </where>
    </select>
    <select id="getStationByUid" resultType="StationInf">
        select distinct * from db_station.tb_station_inf
        <where>
            <if test="provice!=null">
                and provice=#{provice}
            </if>
            <if test="city!=null">
                and city=#{city}
            </if>
            <if test="country!=null">
                and country=#{country}
            </if>
            <if test="uid>100">
                and tb_station_inf.station_id in(
                select distinct station_id from db_user.tb_baojigroup_power,db_user.tb_baojigroup_usr
                where   tb_baojigroup_power.baoji_group_id=tb_baojigroup_usr.baoji_group_id
                and tb_baojigroup_usr.uid=#{uid}
                )
            </if>
        </where>
    </select>
    <select id="getPowerByUid" resultType="PowerInf">
        select distinct * from db_station.tb_power_inf,db_station.tb_station_inf
        <where>
            tb_power_inf.station_id=tb_station_inf.station_id
            <if test="provice!=null">
                and tb_station_inf.provice=#{provice}
            </if>
            <if test="city!=null">
                and tb_station_inf.city=#{city}
            </if>
            <if test="country!=null">
                and tb_station_inf.country=#{country}
            </if>
            <if test="stationName!=null">
                and tb_station_inf.station_name=#{stationName}
            </if>
            <if test="uid>100">
                and tb_power_inf.power_id in(
                select distinct power_id from db_user.tb_baojigroup_power,db_user.tb_baojigroup_usr
                where   tb_baojigroup_power.baoji_group_id=tb_baojigroup_usr.baoji_group_id
                and tb_baojigroup_usr.uid=#{uid}
                )
            </if>
        </where>
    </select>
    <select id="getStationTypeByUid" resultType="java.lang.String">
        select distinct station_type from db_station.tb_station_inf
        <where>
            <if test="uid>100">
                and tb_station_inf.station_id in(
                select distinct station_id from db_user.tb_baojigroup_power,db_user.tb_baojigroup_usr
                where   tb_baojigroup_power.baoji_group_id=tb_baojigroup_usr.baoji_group_id
                and tb_baojigroup_usr.uid=#{uid}
                )
            </if>
        </where>
    </select>
    <select id="getStationStatistic" resultType="com.whyc.pojo.db_station.StationInf">
        select distinct * from db_station.tb_station_inf
        <where>
            <if test="stic.provice!=null">
                and provice=#{stic.provice}
            </if>
            <if test="stic.city!=null">
                and city=#{stic.city}
            </if>
            <if test="stic.country!=null">
                and country=#{stic.country}
            </if>
            <if test="stic.stationName!=null">
                and station_name=#{stic.stationName}
            </if>
            <if test="stic.stationType!=null">
                and station_type=#{stic.stationType}
            </if>
            <if test="stic.uid>100">
                and tb_station_inf.station_id in(
                select distinct station_id from db_user.tb_baojigroup_power,db_user.tb_baojigroup_usr
                where   tb_baojigroup_power.baoji_group_id=tb_baojigroup_usr.baoji_group_id
                and tb_baojigroup_usr.uid=#{stic.uid}
                )
            </if>
            order by station_id asc
        </where>
    </select>
    <select id="getListByUserId" resultType="com.whyc.pojo.db_station.StationInf">
        select distinct * from db_station.tb_station_inf
        where tb_station_inf.station_id in(
            select distinct  station_id from db_user.tb_baojigroup_usr bu,db_user.tb_baojigroup_power bp
            where bu.baoji_group_id = bp.baoji_group_id
            and bu.uid = #{userId}
        )
    </select>
 
</mapper>