whyclxw
6 天以前 5720a0b6cb13fcecc7fb810c7a7f0ad124ce6048
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
<?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.BaojigroupPowerMapper">
 
    <delete id="deleteStationAndLockList">
        <foreach collection="list" item="item" separator=";">
            delete from db_user.tb_baojigroup_power where baoji_group_id = #{item.baojiGroupId} and
            station_id = #{item.stationId} and power_id=#{item.powerId}
        </foreach>
    </delete>
    <select id="getALlLockByBjId" resultType="com.whyc.pojo.db_user.BaojigroupPower">
        select tb_baojigroup_power.*,tb_power_inf.power_name,tb_station_inf.station_name
               from db_user.tb_baojigroup_power,db_station.tb_station_inf,db_station.tb_power_inf
        where
              tb_baojigroup_power.station_id=tb_station_inf.station_id
              and tb_baojigroup_power.power_id=tb_power_inf.power_id
              and baoji_group_id=#{id}
        order by tb_baojigroup_power.baoji_group_id asc ,tb_baojigroup_power.station_id asc,tb_baojigroup_power.power_id asc
    </select>
    <select id="getHomeStationAndLock" resultType="com.whyc.pojo.db_user.BaojigroupPower">
        select distinct tb_baojigroup_power.station_id,tb_baojigroup_power.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
           <if test="uid>100">
               and tb_baojigroup_usr.uid=#{uid}
           </if>
       </where>
    </select>
    <select id="getLocIdByStationidAndBjId" resultType="java.lang.Integer">
        select distinct tb_baojigroup_power.power_id
        from db_user.tb_baojigroup_power
        <where>
            tb_baojigroup_power.baoji_group_id=#{baojiId}
          and tb_baojigroup_power.station_id=#{stationId}
        </where>
    </select>
    <select id="getLockList" resultType="com.whyc.pojo.db_station.PowerInf">
        select distinct l.power_id,l.power_name,l.station_id,s.station_name
        from db_user.tb_baojigroup_power bl ,db_station.tb_power_inf l,db_station.tb_station_inf s
        where bl.power_id = l.power_id and bl.station_id = s.station_id
        and bl.baoji_group_id = #{id}
        order by s.station_name
    </select>
    <select id="getPowerList" resultType="com.whyc.pojo.db_station.PowerInf">
        select distinct l.power_id,l.power_name,l.station_id,s.station_name
        from db_user.tb_baojigroup_power bl ,db_station.tb_power_inf l,db_station.tb_station_inf s
        where bl.power_id = l.power_id and bl.station_id = s.station_id
        and bl.baoji_group_id = #{id}
        order by s.station_name
    </select>
    <select id="getStationIdListWithDischargePlanFlag" resultType="com.whyc.pojo.db_user.BaojigroupPower">
        SELECT gb.baoji_group_id,gb.station_id,g.baoji_group_name,b.provice,b.city,b.country,b.station_name,p.power_name
        FROM db_user.tb_baojigroup g,db_user.tb_baojigroup_power gb,db_station.tb_station_inf b,db_station.tb_power_inf p
        where g.baoji_group_id = gb.baoji_group_id and gb.station_id = b.station_id
          and gb.power_id = p.power_id
          and g.team_flag = 1
    </select>
    <select id="getListByUserId" resultType="com.whyc.pojo.db_user.BaojigroupPower">
        SELECT distinct gb.baoji_group_id,gb.station_id,g.baoji_group_name as baoJiGroupName,b.station_name
        FROM db_user.tb_baojigroup g,db_user.tb_baojigroup_power gb,db_station.tb_station_inf b
        where g.baoji_group_id = gb.baoji_group_id 0
        and gb.station_id = b.station_id
        and g.team_flag = 1
        and gb.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}
        )
        order by g.baoji_group_name
    </select>
    <select id="checkPwrIsInBanzu" resultType="com.whyc.pojo.db_user.BaojigroupPower">
        select tb_baojigroup_power.*,tb_baojigroup.baoji_group_name,tb_baojigroup.team_flag
        from db_user.tb_baojigroup_power,db_user.tb_baojigroup
        where tb_baojigroup_power.baoji_group_id=tb_baojigroup.baoji_group_id
        and tb_baojigroup_power.power_id in
              (SELECT power_id from tb_baojigroup_power where baoji_group_id=#{baoJiGroupId}
              )
         and tb_baojigroup_power.baoji_group_id!=#{baoJiGroupId}
    </select>
    <select id="checkPower" resultType="com.whyc.pojo.db_user.BaojigroupPower">
        select tb_baojigroup_power.*,tb_baojigroup.baoji_group_name,tb_baojigroup.team_flag
        from db_user.tb_baojigroup_power,db_user.tb_baojigroup
        where tb_baojigroup_power.baoji_group_id=tb_baojigroup.baoji_group_id
        and tb_baojigroup_power.power_id=#{powerId}
    </select>
</mapper>