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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
package com.fgkj.services;
 
import com.fgkj.dto.*;
import com.fgkj.mapper.BattTestData;
import com.fgkj.mapper.impl.Batt_rtdataMapper;
import com.fgkj.mapper.impl.Batt_rtstateMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;
 
import java.util.ArrayList;
import java.util.List;
 
import javax.annotation.Resource;
@Service
public class Batt_rtstateService {
 
 
    @Resource
    private Batt_rtstateMapper mapper;
    
    @Resource
    private Batt_rtdataMapper rtDataMapper;
    
    public ServiceModel serchByCondition(Batt_rtstate obj){
        ServiceModel model = new ServiceModel();
        List list=mapper.serchByCondition(obj);
        if(list!=null && list.size()>0){
            model.setCode(1);
            model.setData(list);
        }
        //System.out.println(list);
        return model;
    }
    
    //9.1根据查询电池组单体的实时数据(电池单体实时信息)
    public ServiceModel serchByMons(BattInf obj){
        ServiceModel model = new ServiceModel();
        List<Batt_State>  list=mapper.serchMons(obj);
        if(list!=null&&list.size()>0){
            for(int i=0;i<list.size();i++){
                BattInf binf=list.get(i).getBinf();                
                List<Batt_rtdata> listD=rtDataMapper.serchByInfo(binf);
                if(listD!=null){
                    binf.setMonVolLowToAvg((listD.get(list.size()-1).getMon_vol()));//最大
                    //binf.setMonVolStd((listD.get(list.size()-1).getMon_tmp()));//最小
                }
            }
        }
        if(list!=null && list.size()>0){
            model.setCode(1);
            model.setData(list);
            model.setMsg("查询成功!");
        }else{
            model.setCode(0);
            model.setMsg("查询失败!");
        }
        return model;
    }
    
    //根据电池组id查询该电池组/单体的实时情况(电池续航能力)
    public ServiceModel serchByInfo(BattInf obj){
        ServiceModel model = new ServiceModel();
        List<Batt_State>  list=mapper.serchByInfo(obj);
        if(list!=null&&list.size()>0){
            model.setCode(1);
            model.setData(list);
            model.setMsg("查询成功!");
        }else{
            model.setCode(0);
            model.setMsg("查询失败!");
        }
        //System.out.println(model);
        return model;
    }
    
    /*//查询电池组的实时状态(电池组状态查询<放电,充电>)
    public ServiceModel serchBattState(Object obj){
        List list=mapper.serchBattState(obj);
        if(list!=null&&list.size()>0){
            model.setCode(1);
            model.setData(list);
            model.setMsg("查询成功!");
        }
        else{
            model.setCode(0);
            model.setMsg("查询失败!");
        }
        return model;
    }*/
    
    //电池组实时情况+实时电池续航能力查询
    public ServiceModel serchBattLife(Batt_Maint_Dealarm bmd){
        ServiceModel model = new ServiceModel();
        //分页
        PageBean pageBean = bmd.getPageBean();
//        PageHelper.startPage(pageBean.getPageNum(),pageBean.getPageSize(),true);    //TODO RZG Duplicate column name 'BattGroupId'
        List<Batt_State>  list=mapper.serchBattLife(bmd);
 
        if(list!=null&&list.size()>0){
            list.get(list.size()-1).getBinf().setMonNum(pageBean.getPageAll());
            PageInfo<Batt_State> pageInfo = new PageInfo<>(list);
            model.setCode(1);
            model.setData(pageInfo);
            model.setMsg("查询成功!");
        }else{
            model.setCode(0);
            model.setMsg("查询失败!");
        }
        //System.out.println(model);
        return model;
    }
 
    
    //首页上饼状图电池状态比例
    public ServiceModel serchBattStateRate(User_inf obj){
        ServiceModel model = new ServiceModel();
        List<Batt_rtstate> list=mapper.serchBattStateRate(obj);
        int test_plan0=0;//状态为无
        int test_plan1=0;//状态为浮充
        int test_plan2=0;//状态为充电
        int test_plan3=0;//状态为放电
        int test_plan4=0;//状态为均充
        if(list!=null&&list.size()>0){
            for (Batt_rtstate batt_rtstate : list) {
                if(batt_rtstate.getBatt_state()==BattTestData.test_plan0){
                    test_plan0+=batt_rtstate.getBatt_count();    // COUNT(tb_batt_rtstate.BattGroupId) batt_count
                }else if(batt_rtstate.getBatt_state()==BattTestData.test_plan1){
                    test_plan1+=batt_rtstate.getBatt_count();
                }else if(batt_rtstate.getBatt_state()==BattTestData.test_plan2){
                    test_plan2+=batt_rtstate.getBatt_count();
                }else if(batt_rtstate.getBatt_state()==BattTestData.test_plan3){
                    test_plan3+=batt_rtstate.getBatt_count();
                }else if(batt_rtstate.getBatt_state()==BattTestData.test_plan4){
                    test_plan4+=batt_rtstate.getBatt_count();
                }
            }
            list= new ArrayList<>();
            {
                Batt_rtstate bstate = new Batt_rtstate();
                bstate.setBatt_state(BattTestData.test_plan0);
                bstate.setNum(test_plan0);
                list.add(bstate);
                Batt_rtstate bstate1 = new Batt_rtstate();
                bstate1.setBatt_state(BattTestData.test_plan1);
                bstate1.setNum(test_plan1);
                list.add(bstate1);
                Batt_rtstate bstate2 = new Batt_rtstate();
                bstate2.setBatt_state(BattTestData.test_plan2);
                bstate2.setNum(test_plan2);
                list.add(bstate2);
                Batt_rtstate bstate3 = new Batt_rtstate();
                bstate3.setBatt_state(BattTestData.test_plan3);
                bstate3.setNum(test_plan3);
                list.add(bstate3);
                Batt_rtstate bstate4 = new Batt_rtstate();
                bstate4.setBatt_state(BattTestData.test_plan4);
                bstate4.setNum(test_plan4);
                list.add(bstate4);
            }
            model.setCode(1);
            model.setData(list);
            model.setMsg("查询成功!");
        }
        else{
            model.setCode(0);
            model.setMsg("查询失败!");
        }
        return model;
    }
    //测试数据——实时查询中左下角的充放电统计(旧)
    public ServiceModel serchDisOrChargr(){
        ServiceModel model = new ServiceModel();
        List<Batt_rtstate> list=mapper.serchDisOrChargr();
        if(list!=null&&list.size()>0){
            int charge=0;
            int dischar=0;
            for (Batt_rtstate brt: list) {
                if(brt.getBatt_test_type()==3){
                    dischar++;
                }else if(brt.getBatt_test_type()==2){
                    charge++;
                }
            }
            list.get(list.size()-1).setNum(charge);
            list.get(list.size()-1).setBatt_count(dischar);
            model.setCode(1);
            model.setData(list);
            model.setMsg("查询成功!");
        }
        else{
            model.setCode(0);
            model.setMsg("查询失败!");
        }
        //System.out.println(model);
        return model;
    }
 
    
    //测试数据——实时查询中左下角的充放电统计(用户管理的机房)
    public ServiceModel serchDisOrChargrNew(User_inf obj){
        ServiceModel model = new ServiceModel();
        List<Batt_rtstate> list=mapper.serchDisOrChargrNew(obj);
        if(list!=null&&list.size()>0){
            int charge=0;
            int dischar=0;
            for (Batt_rtstate brt: list) {
                if(brt.getBatt_test_type()==3){
                    dischar++;
                }else if(brt.getBatt_test_type()==2){
                    charge++;
                }
            }
            list.get(list.size()-1).setNum(charge);
            list.get(list.size()-1).setBatt_count(dischar);
            model.setCode(1);
            model.setData(list);
            model.setMsg("查询成功!");
        }
        else{
            model.setCode(0);
            model.setMsg("查询失败!");
        }
        //System.out.println(model);
        return model;
    }
    //实时监测中的查询实时组端信息<-------跨域----------->
    public ServiceModel serchByCondition_ky(Batt_rtstate obj){
        ServiceModel model = new ServiceModel();
        List list=mapper.serchByCondition_ky(obj);
        if(list!=null && list.size()>0){
            model.setCode(1);
            model.setData(list);
        }
        //System.out.println(list);
        return model;
    }
    public static void main(String[] args) {
        Batt_Maint_Dealarm bmd = new Batt_Maint_Dealarm();
        Batt_rtstate br=new Batt_rtstate();
        //br.setBattGroupId(1000001);
        BattInf binf=new BattInf();
        binf.setBattGroupId(0);
        binf.setStationName("内蒙古");
        binf.setStationName1("内蒙古");
        binf.setNum(100);
        
        PageBean pageBean = new PageBean();
        pageBean.setPageCurr(1);
        pageBean.setPageSize(10);
        
        User_inf uinf=new User_inf();
        uinf.setuId(1002);
        
        bmd.setBinf(binf);
        bmd.setPageBean(pageBean);
        bmd.setUinf(uinf);
        Batt_rtstateService bs=new Batt_rtstateService();
        bs.serchBattLife(bmd);
        //bs.serchDisOrChargr();
        
        
    }
}