whycrzg
2021-02-23 351b9a53cb9ecebdf8f79db0117f540d9c42c2a4
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
package com.fgkj.mapper.impl;
 
import java.util.List;
 
import com.fgkj.dto.BattDischarge_plan;
import com.fgkj.dto.BattMap_information;
import com.fgkj.dto.Batt_Maint_Dealarm;
import com.fgkj.dto.User_inf;
import com.fgkj.mapper.BattTestData;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;
 
public interface BattDischarge_planMapper{
 
    //添加
    @Insert("insert into web_site.tb_battdischarge_plan(battgroupid,BattIndexInFbs,discharge_starttime,discharge_stoptime,discharge_state,discharge_reason,discharge_cleartype,preset_time,preset_cap,preset_monvol,preset_groupvol,preset_curr,preset_mon,dcvolhighlimit,chargecurrset,plan_circle,plan_rate,note) " +
            "values(#{battgroupid},#{battIndexInFbs},#{discharge_starttime},#{discharge_stoptime},#{discharge_state},#{discharge_reason},#{discharge_cleartype},#{preset_time},#{preset_cap},#{preset_monvol},#{preset_groupvol},#{preset_curr},#{preset_mon},#{dcvolhighlimit},#{chargecurrset},#{plan_circle},#{plan_rate},#{note})")
    public int add(BattDischarge_plan obj);
    //8.1批量添加电池计划
    @Insert("insert into web_site.tb_battdischarge_plan(battgroupid,battIndexInFbs,discharge_starttime,discharge_state,discharge_reason,discharge_cleartype," +
            "preset_time,preset_cap,preset_monvol,preset_groupvol,preset_curr,preset_mon,dcvolhighlimit,chargecurrset,plan_circle,plan_rate) " +
            "values(#{battgroupid},#{battIndexInFbs},#{discharge_starttime},#{discharge_state},#{discharge_reason}" +
            ",#{discharge_cleartype},#{preset_time},#{preset_cap} ,#{preset_monvol},#{preset_groupvol},#{preset_curr}" +
            ",#{preset_mon},#{dcvolhighlimit},#{chargecurrset} ,#{plan_circle},#{plan_rate})")
    public int addPro(BattDischarge_plan obj);
 
 
//    @Update("update web_site.tb_battdischarge_plan set battgroupid=#{battgroupid},battIndexInFbs=#{battIndexInFbs},discharge_starttime=#{discharge_starttime},discharge_stoptime=#{discharge_stoptime}," +
//            "discharge_state=#{discharge_state},discharge_reason=#{discharge_reason},discharge_cleartype=#{discharge_cleartype},preset_time=#{preset_time},preset_cap=#{preset_cap}," +
//            "preset_monvol=#{preset_monvol},preset_groupvol=#{preset_groupvol},preset_curr=#{preset_curr},preset_mon=#{preset_mon},dcvolhighlimit=#{dcvolhighlimit}," +
//            "chargecurrset=#{chargecurrset},note=#{note} where num=#{num}")
 
    @Update("update web_site.tb_battdischarge_plan set battgroupid=#{battgroupid},BattIndexInFbs=#{battIndexInFbs}, discharge_starttime=#{discharge_starttime},discharge_stoptime=#{discharge_stoptime}," +
            "discharge_state=#{discharge_state},discharge_reason=#{discharge_reason},discharge_cleartype=#{discharge_cleartype},preset_time=#{preset_time},preset_cap=#{preset_cap}," +
            "preset_monvol=#{preset_monvol},preset_groupvol=#{preset_groupvol},preset_curr=#{preset_curr},preset_mon=#{preset_mon},dcvolhighlimit=#{dcvolhighlimit}," +
            "chargecurrset=#{chargecurrset},note=#{note} where num=#{num}")
    public int update(BattDischarge_plan obj);
 
    //8.1批量修改放电计划的开始时间/放电参数的修改/启用计划和取消计划
    @Update("update web_site.tb_battdischarge_plan set discharge_starttime=#{discharge_starttime},discharge_cleartype=#{discharge_cleartype}," +
            "discharge_reason=#{discharge_reason},discharge_state=#{discharge_state},preset_time=#{preset_time},preset_cap=#{preset_cap}," +
            "preset_monvol=#{preset_monvol},preset_groupvol=#{preset_groupvol},preset_curr=#{preset_curr},preset_mon=#{preset_mon}," +
            "dcvolhighlimit=#{dcvolhighlimit},chargecurrset=#{chargecurrset}  ,plan_circle=#{plan_circle},plan_rate=#{plan_rate} " +
            "where battgroupid=#{battgroupid} and num=#{num}")
    public int updatePro(BattDischarge_plan obj);
 
    @Delete("delete from web_site.tb_battdischarge_plan where num=#{num} ")
    public int del(BattDischarge_plan obj);
 
    //8.1批量添加作业计划时先检测计划的可行性
    @Select(" SELECT battgroupid FROM web_site.tb_battdischarge_plan " +
            "WHERE discharge_starttime>=#{discharge_starttime1} and discharge_starttime<=#{discharge_stoptime1} AND discharge_cleartype=1 and discharge_state in(0,1) AND battgroupid " +
            "in (select battgroupid FROM db_battinf.tb_battinf where stationname=#{note})")
    public List<String> judgePlan(BattDischarge_plan obj);
 
    @Select("select  num,battgroupid,discharge_starttime,discharge_stoptime,discharge_state,discharge_reason,discharge_cleartype,preset_time,preset_cap,preset_monvol,preset_groupvol,preset_curr,preset_mon,dcvolhighlimit,chargecurrset,note from web_site.tb_battdischarge_plan ")
    public List<BattDischarge_plan> searchAll() ;
    //8.1放电计划查询
    /*public List serchByCondition(Object obj) {
        Batt_Maint_Dealarm bmd=(Batt_Maint_Dealarm) obj;
        BattInf binf=bmd.getBinf();
        BattDischarge_plan bplan=bmd.getBplan();
        String numberSql=" SELECT FOUND_ROWS() number";
        Connection conn=DBUtil.getConn();
        String sql="";
        String baseSql="select SQL_CALC_FOUND_ROWS distinct(tb_battdischarge_plan.battgroupid),tb_battdischarge_plan.num,tb_battdischarge_plan.battIndexInFbs,tb_battdischarge_plan.discharge_starttime,tb_battdischarge_plan.discharge_stoptime, " +
                "tb_battdischarge_plan.discharge_state,tb_battdischarge_plan.discharge_reason,tb_battdischarge_plan.discharge_cleartype,tb_battdischarge_plan.note," +
                "tb_battdischarge_plan.preset_time,tb_battdischarge_plan.preset_cap,tb_battdischarge_plan.preset_monvol,tb_battdischarge_plan.preset_groupvol,tb_battdischarge_plan.preset_curr,tb_battdischarge_plan.preset_mon," +
                "tb_battdischarge_plan.dcvolhighlimit,tb_battdischarge_plan.chargecurrset, " +
                "db_battinf.tb_battinf.stationname1,db_battinf.tb_battinf.stationname,db_battinf.tb_battinf.battGroupName  "+
                "from web_site.tb_battdischarge_plan  " +
                "left outer join db_battinf.tb_battinf on tb_battdischarge_plan.battgroupid=db_battinf.tb_battinf.battgroupid  "+
                "where db_battinf.tb_battinf.stationname1 like ? and db_battinf.tb_battinf.stationname like ?   " +
                "and tb_battdischarge_plan.discharge_starttime>=?  and tb_battdischarge_plan.discharge_starttime<=? " +
                "and tb_battdischarge_plan.discharge_state=? ";
        //电池组选择条件
        String idSqlF=" and db_battinf.tb_battinf.battgroupid=? ";
        String idSqlT=" and db_battinf.tb_battinf.battgroupid!=? ";
        if(binf.getBattGroupId()!=0){
            baseSql+=idSqlF;
        }else{
            baseSql+=idSqlT;
        }
        String endSql="order by tb_battdischarge_plan.discharge_starttime desc ";
        String limitSql=" limit ?,? ";
        sql=baseSql+endSql+limitSql;
        //System.out.println(sql);
        List<Batt_Maint_Dealarm> list=DateUtil.executeQueryLimit(sql, conn,
                new Object[]{ "%"+binf.getStationName1()+"%",
                             "%"+binf.getStationName()+"%",
                             bplan.getDischarge_starttime(),
                             bplan.getDischarge_starttime1(),
                             bplan.getDischarge_state(),
                             binf.getBattGroupId(),
                             (bmd.getPage().getPageCurr() - 1)* bmd.getPage().getPageSize(),
                             bmd.getPage().getPageSize()
                             }, new CallBack() {
                                public List getResults(ResultSet rs) {
                                    List<Batt_Maint_Dealarm> list=new ArrayList();
                                    try {
                                        while(rs.next()){
                                            Batt_Maint_Dealarm bmd=new Batt_Maint_Dealarm();
                                            BattInf binf=new BattInf();
                                            BattDischarge_plan bplan=new BattDischarge_plan();
                                            binf.setStationName(rs.getString("stationName"));
                                            binf.setStationName1(rs.getString("stationName1"));
                                            binf.setBattGroupName(rs.getString("battGroupName"));
                                            
                                            bplan.setNum(rs.getInt("num"));
                                            bplan.setBattgroupid(rs.getInt("battgroupid"));
                                            bplan.setBattIndexInFbs(rs.getInt("battIndexInFbs"));//第几组电池组
                                            bplan.setDischarge_starttime(rs.getTimestamp("discharge_starttime"));
                                            bplan.setDischarge_stoptime(rs.getTimestamp("discharge_stoptime"));
                                            bplan.setDischarge_state(rs.getInt("discharge_state"));
                                            bplan.setDischarge_reason(rs.getInt("discharge_reason"));
                                            bplan.setDischarge_cleartype(rs.getInt("discharge_cleartype"));//计划的启用还是取消
                                            bplan.setNote(rs.getString("battGroupName"));//电池组名称
                                            bplan.setPreset_time(rs.getInt("preset_time"));
                                            bplan.setPreset_cap(rs.getFloat("preset_cap"));
                                            bplan.setPreset_monvol(rs.getFloat("preset_monvol"));
                                            bplan.setPreset_groupvol(rs.getFloat("preset_groupvol"));
                                            bplan.setPreset_curr(rs.getFloat("preset_curr"));
                                            bplan.setPreset_mon(rs.getInt("preset_mon"));
                                            bplan.setDcvolhighlimit(rs.getFloat("dcvolhighlimit"));
                                            bplan.setChargecurrset(rs.getFloat("chargecurrset"));
 
                                            
                                            Page page=new Page();
                                            bmd.setBinf(binf);
                                            bmd.setBplan(bplan);
                                            bmd.setPage(page);
                                            list.add(bmd);
                                        }
                                    } catch (SQLException e) {
                                        // TODO Auto-generated catch block
                                        e.printStackTrace();
                                    }
                                    return list;
                                }
                            });
        //去掉limit条件后的总数
        int number=LimitNumberFactory.GetLimtitNumber(conn, numberSql);
        //System.out.println("number: "+number);
        if(list!=null&&list.size()>0){
            list.get(list.size()-1).getPage().setPageAll(number);
        }
        return list;
    }*/
 
 
    public List serchByCondition(Batt_Maint_Dealarm obj);
 
    //9.1查询机房放电计划中存在放电延时的总数
    //地图上所有的放电延时机房
    @Select("select count(num) as nums  from web_site.tb_battdischarge_plan " +
            "where battgroupid in (select distinct battgroupid from db_battinf.tb_battinf where stationid=#{stationId} ) " +
            "and discharge_state=${@com.fgkj.mapper.BattTestData@test_plan1} limit 1 ")
    public int serchByStationId(BattMap_information obj);
 
    //9.1查询机房放电计划中存在放电延时的总数
    //地图上所有的放电延时机房
    public int serchBystationName3(Object obj);
 
    //8.1查询未开始放电的放电计划总数
    /*public int searchNums() {
        String sql="select count(num) as nums  " +
                " from web_site.tb_battdischarge_plan " +
                " where discharge_state="+BattTestData.test_plan0+" " +
                " and battgroupid in (select distinct battgroupid from db_battinf.tb_battinf) "+
                " limit 1 ";
        //System.out.println(sql);
        List list=DateUtil.executeQuery(sql, DBUtil.getConn(), null, new CallBack() {
            
            public List getResults(ResultSet rs) {
                List list=new ArrayList();
                try {
                    while(rs.next()){
                        int nums=rs.getInt("nums");
                        list.add(nums);
                    }
                } catch (SQLException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                return list;
            }
        });
        int nums=0;//最后的结果
        if(list!=null&&list.size()>0){
            nums=(Integer) list.get(list.size()-1);
        }
        return nums;
    }*/
 
    @Select("select count(num) as nums from web_site.tb_battdischarge_plan " +
            "where discharge_state='${@com.fgkj.mapper.BattTestData@test_plan0}' and battgroupid " +
            "in (select distinct db_battinf.tb_battinf.battgroupid  " +
            "from db_battinf.tb_battinf,db_user.tb_user_battgroup_baojigroup_battgroup,db_user.tb_user_battgroup_baojigroup_usr,db_user.tb_user_inf " +
            "where db_user.tb_user_battgroup_baojigroup_battgroup.BattGroupId=db_battinf.tb_battinf.BattGroupId and db_user.tb_user_battgroup_baojigroup_usr.baoji_group_id=db_user.tb_user_battgroup_baojigroup_battgroup.baoji_group_id and db_user.tb_user_inf.uid=db_user.tb_user_battgroup_baojigroup_usr.uid and db_user.tb_user_inf.uid=#{uId})")
    public int searchNums(User_inf obj) ;
 
    //8.1放电计划管理中饼状图(放电计划统计查询)
    /*public List searchState(){
            String sql="SELECT COUNT(num) number,discharge_state from web_site.tb_battdischarge_plan  " +
                    " GROUP BY discharge_state ";
            
            List list=DateUtil.executeQuery(sql, DBUtil.getConn(), null, new CallBack() {
                
                public List getResults(ResultSet rs) {
                    List list=new ArrayList();
                    try {
                        while(rs.next()){
                            BattDischarge_plan bplan=new BattDischarge_plan();
                            bplan.setNum(rs.getInt("number"));
                            bplan.setDischarge_state(rs.getInt("discharge_state"));
                            list.add(bplan);
                        }
                    } catch (SQLException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                    return list;
                }
            });
            return list;
        }*/
 
 
    @Select("SELECT COUNT(num) num,discharge_state,battgroupid " +
            "from web_site.tb_battdischarge_plan " +
            "GROUP BY battgroupid,discharge_state " +
            "having web_site.tb_battdischarge_plan.battgroupid " +
            "in(select distinct db_battinf.tb_battinf.battgroupid from db_battinf.tb_battinf,db_user.tb_user_battgroup_baojigroup_battgroup,db_user.tb_user_battgroup_baojigroup_usr,db_user.tb_user_inf where db_user.tb_user_battgroup_baojigroup_battgroup.BattGroupId=db_battinf.tb_battinf.BattGroupId and db_user.tb_user_battgroup_baojigroup_usr.baoji_group_id=db_user.tb_user_battgroup_baojigroup_battgroup.baoji_group_id and db_user.tb_user_inf.uid=db_user.tb_user_battgroup_baojigroup_usr.uid and db_user.tb_user_inf.uid=#{uId})")
    public List<BattDischarge_plan> searchState(User_inf obj);
 
}