fg电池监控平台的达梦数据库版本
whycxzp
2024-11-11 0f5f5e435cbc4c60ffad2bb84cfe8cc57ea32ddc
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
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
package com.whyc.service;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageInfo;
import com.whyc.dto.ReportBattDTO;
import com.whyc.dto.Response;
import com.whyc.mapper.*;
import com.whyc.pojo.AlarmParam;
import com.whyc.pojo.BattParamLow;
import com.whyc.pojo.Battinf;
import com.whyc.pojo.BatttestdataInf;
import com.whyc.util.PageInfoUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
@Service
public class BattMaintDealarmService {
    @Resource
    private BattMaintDealarmMapper mapper;
    @Resource
    private BattInfMapper battInfMapper;
    @Resource
    private BattParamLowMapper battParamLowMapper;
    @Resource
    private BattResDataMapper BattResDataMapper;
    @Resource
    AlarmParamMapper alarmParamMapper;
    @Resource
    BattalarmDataMapper alarmDataMapper;
 
 
    @Resource
    private BatttestdataInfService batttestdataInfService;
 
    @Autowired
    private SubTablePageInfoService subService;
 
    public Response searchLow(ReportBattDTO tinf, int userId) {
        Response res = new Response();
        List<Battinf> battinfList = battInfMapper.searchByTestType(tinf, userId);
        List<Map> result = new ArrayList<>();
        if (battinfList != null && battinfList.size() > 0) {
            BatttestdataInf btdinf = new BatttestdataInf();
            btdinf.setRecordTime(tinf.getRecordStartTime());
            btdinf.setRecordTime1(tinf.getRecordEndTime());
            btdinf.setTestType(tinf.getTestType());
            btdinf.setTestStarttype(tinf.getTestStartType());
            for (Battinf binf : battinfList) {
                btdinf.setBattGroupId(binf.getBattGroupId());
                btdinf.setGroupVol(binf.getMonVolStd());
                btdinf.setTestCap(binf.getMonCapStd());
                btdinf.setTestRecordCount(binf.getTestRecordCount());
                Map map = new HashMap();
                map.put("battinf", binf);
                //该电池组的放电结果
                List<BatttestdataInf> batttestdataInfList = batttestdataInfService.searchByTestType(btdinf);
                map.put("battTestDataInf", batttestdataInfList);
                result.add(map);
            }
        }
        return res.set(1,result,"查询成功");
    }
 
    //1.4电池性能评估
    public Response searchGroupAssess(int pageNum,int pageSize,ReportBattDTO tinf, int userId){
        List<Battinf> battinfList = battInfMapper.searchGroupAssess(tinf, userId);
        List<Map> result = new ArrayList<>();
        Integer assess = tinf.getAssess();//性能筛选
        Integer wj = tinf.getWj();//往年还是本年
        Integer statictype= tinf.getStatictype();//统计方式
        if (assess == null) {
            assess = -1;
        }
        if (wj == null) {
            wj = -1;
        }
        if (battinfList != null && battinfList.size() > 0) {
            for (Battinf binf : battinfList) {
                Integer battGroupId = binf.getBattGroupId();
                Map<String, Object> map=new HashMap<>();
                Map<String, Object> batttestdataInfList = batttestdataInfService.searchDischargeTest(battGroupId, binf.getMonCapStd(), binf.getMonVolStd(), tinf.getRecordStartTime(), tinf.getRecordEndTime(),wj);
                if(statictype==0){
                    //对每个电池组状态进行判断(容量+内阻)
                    map = getAssess2(binf, batttestdataInfList,assess);
                }else{
                    //对每个电池组状态进行判断(容量)
                    map = getAssess3(binf, batttestdataInfList,assess);
                }
                if (assess == -1) {
                    result.add(map);
                } else {
                    if (map.get("flag") == assess) {
                        result.add(map);
                    }
                }
            }
        }
        PageInfo pageInfo = PageInfoUtils.list2PageInfo(result, pageNum, pageSize);
        return new Response().set(1, pageInfo, "查询成功");
    }
 
    //查询电池告警(劣化:内阻过高重要,电压过低重要;损坏:内阻过高紧急,电压过低紧急)
    private List getAlm(Integer battGroupId, Integer assess) {
        List list = alarmDataMapper.getAlm(battGroupId, assess);
        return list;
    }
 
    //筛选蓄电池组后评性能
    public Map<String, Object> getAssess(Battinf binf, Map<String, Object> mapList, int assess) {
        Map<String, Object> map = new HashMap();
        map.put("battinf", binf);
        map.put("battTestDataInf", mapList);
        //直接去集合第2个数(放电次数),第6个数(实际预估容量:最近一次核容的实际容量)
        int battGroupId = (int) mapList.get("battGroupid");
        int disNum = (int) mapList.get("sum");
        float realCap = (Float) mapList.get("lastCap");
        float monCapStd = binf.getMonCapStd();
        //0.查询劣化(告警)和损坏(更换)的阈值
        QueryWrapper<AlarmParam> alarmWrapper = new QueryWrapper();
        alarmWrapper.and(wrapper -> {
            return wrapper.eq("alm_name", "Batt_Alarm_Type_CapAlarm").or().eq("alm_name", "Batt_Alarm_Type_CapChange");
        });
        alarmWrapper.orderByAsc("alm_id");
        List<AlarmParam> paramList = alarmParamMapper.selectList(alarmWrapper);
        float capAlarm = 0f;
        float capChange = 0f;
        if (paramList != null && paramList.size() > 0) {
            capAlarm = paramList.get(0).getAlmLowCoe();//劣化参数0.8
            capChange = paramList.get(1).getAlmLowCoe();//损坏参数0.6
        } else {
            capAlarm = 0.8f;
            capChange = 0.6f;
        }
        //查询电池告警(劣化:内阻过高重要,电压过低重要;损坏:内阻过高紧急,电压过低紧急)
        List listALmSH = getAlm(battGroupId, 3);
        List listALmLH = getAlm(battGroupId, 2);
        //先判断是否损坏
        if ((disNum != 0 && realCap < capChange * monCapStd)
                || (listALmSH != null && listALmSH.size() > 0)) {
            map.put("flag", 3);
            if (assess == 0) {
                if (disNum == 0) {
                    map.put("flag", 0);
                }
            } else {
                map.put("alarm", listALmSH);
            }
        }//在判断是否劣化
        else if (
                (disNum != 0 && realCap <= capAlarm * monCapStd && realCap >= capChange * monCapStd
                )
                        || (listALmLH != null && listALmLH.size() > 0)) {
            map.put("flag", 2);
            if (assess == 0) {
                if (disNum == 0) {
                    map.put("flag", 0);
                }
            } else {
                map.put("alarm", listALmLH);
            }
        }//再判断是否放电正常
        else if (disNum != 0 && realCap > capAlarm * monCapStd) {
            map.put("flag", 1);
            if (assess == 0) {
                if (disNum == 0) {
                    map.put("flag", 0);
                }
            }
        }
        //在判断是否未放电
        else if (disNum == 0) {
            map.put("flag", 0);
        } else {
            map.put("flag", 0);
        }
        if ((int) map.get("flag") == 0) {
            if ((listALmSH != null && listALmSH.size() > 0)) {
                map.put("noDisAlmSH", listALmSH);
            }
            if ((listALmLH != null && listALmLH.size() > 0)) {
                map.put("noDisAlmLH", listALmLH);
            }
        }
        return map;
    }
 
    //查询电池告警(2024。4.15修改)
    /*未放电:本年度未放电
    *优秀:本年度已放电,且容量健康,无内阻告警(预告警(重要),告警(紧急))
    *劣化:本年度未放电,内阻告警(预告警(重要),告警(紧急))
    *     容量小于劣化阈值,大于损坏阈值,内阻告警(预告警,告警)
    *     容量小于劣化阈值,内阻正常
    *     容量正常,内阻告警(预告警,告警)
    * 损坏:容量低,内阻告警
    * */
    private List getAlm2(Integer battGroupId) {
        List list = alarmDataMapper.getAlm2(battGroupId);
        return list;
    }
 
    //筛选蓄电池组后评性能(2024。4.15修改)
    public Map<String, Object> getAssess2(Battinf binf, Map<String, Object> mapList,int assess) {
        Map<String, Object> map = new HashMap();
        map.put("battinf", binf);
        map.put("battTestDataInf", mapList);
        map.put("wj",mapList.get("wj"));
        //直接去集合第2个数(放电次数),第6个数(实际预估容量:最近一次核容的实际容量)
        int battGroupId = (int) mapList.get("battGroupid");
        int disNum = (int) mapList.get("sum");
        float realCap = (Float) mapList.get("lastCap");
        float monCapStd = binf.getMonCapStd();
        //0.查询劣化(告警)和损坏(更换)的阈值
        QueryWrapper<AlarmParam> alarmWrapper = new QueryWrapper();
        alarmWrapper.and(wrapper -> {
            return wrapper.eq("alm_name", "Batt_Alarm_Type_CapAlarm").or().eq("alm_name", "Batt_Alarm_Type_CapChange");
        });
        alarmWrapper.orderByAsc("alm_id");
        List<AlarmParam> paramList = alarmParamMapper.selectList(alarmWrapper);
        float capAlarm = 0f;
        float capChange = 0f;
        if (paramList != null && paramList.size() > 0) {
            capAlarm = paramList.get(0).getAlmLowCoe();//劣化参数0.8
            capChange = paramList.get(1).getAlmLowCoe();//损坏参数0.6
        } else {
            capAlarm = 0.8f;
            capChange = 0.6f;
        }
        //查询电池告警(内阻告警)
        List listALmRes = getAlm2(battGroupId);
        map.put("noDisAlmSH",listALmRes);
        //未放电:本年度未放电
        if( (disNum==0) ){
            map.put("flag",0);
        }
        //优秀:本年度已放电,且容量健康,无内阻告警(预告警(重要),告警(紧急))
        if( (disNum>0)&&(realCap > capAlarm * monCapStd)&&(listALmRes.size()<=0)){
            map.put("flag",1);
        }
 
        /*劣化:本年度未放电,内阻告警(预告警(重要),告警(紧急))
         *容量小于劣化阈值,大于损坏阈值,内阻告警(预告警,告警)
         *     容量小于劣化阈值,内阻正常
         *     容量正常,内阻告警(预告警,告警)
         */
        if (((disNum==0)&&(listALmRes.size()>0))
           ||((disNum>0)&&(realCap <= capAlarm * monCapStd && realCap >= capChange * monCapStd)&&(listALmRes.size()>0))
           ||((disNum>0)&&(realCap <= capAlarm * monCapStd)&&(listALmRes.size()<=0))
           ||(disNum>0)&&(realCap > capAlarm * monCapStd)&&(listALmRes.size()>0)){
            if((assess==0)&&(disNum==0)){
                map.put("flag",0);
            }else{
                map.put("flag",2);
            }
        }
        //损坏:容量低,内阻告警
        if((disNum!=0)&&(realCap< capChange * monCapStd)&&(listALmRes.size()>0)){
            map.put("flag",3);
        }
        return map;
    }
    //筛选蓄电池组后评性能(2024。4.15修改)
    public Map<String, Object> getAssess3(Battinf binf, Map<String, Object> mapList,int assess) {
        Map<String, Object> map = new HashMap();
        map.put("battinf", binf);
        map.put("battTestDataInf", mapList);
        map.put("wj", mapList.get("wj"));
        //直接去集合第2个数(放电次数),第6个数(实际预估容量:最近一次核容的实际容量)
        int battGroupId = (int) mapList.get("battGroupid");
        int disNum = (int) mapList.get("sum");
        float realCap = (Float) mapList.get("lastCap");
        float monCapStd = binf.getMonCapStd();
        //0.查询劣化(告警)和损坏(更换)的阈值
        QueryWrapper<AlarmParam> alarmWrapper = new QueryWrapper();
        alarmWrapper.and(wrapper -> {
            return wrapper.eq("alm_name", "Batt_Alarm_Type_CapAlarm").or().eq("alm_name", "Batt_Alarm_Type_CapChange");
        });
        alarmWrapper.orderByAsc("alm_id");
        List<AlarmParam> paramList = alarmParamMapper.selectList(alarmWrapper);
        float capAlarm = 0f;
        float capChange = 0f;
        if (paramList != null && paramList.size() > 0) {
            capAlarm = paramList.get(0).getAlmLowCoe();//劣化参数0.8
            capChange = paramList.get(1).getAlmLowCoe();//损坏参数0.6
        } else {
            capAlarm = 0.8f;
            capChange = 0.6f;
        }
        //未放电:本年度未放电
        if ((disNum == 0)) {
            map.put("flag", 0);
        }
        //优秀:本年度已放电,且容量健康)
        if ((disNum > 0) && (realCap > capAlarm * monCapStd)) {
            map.put("flag", 1);
        }
        /*劣化:
         *容量小于劣化阈值,大于损坏阈值
         */
        if (((disNum > 0) && (realCap <= capAlarm * monCapStd && realCap >= capChange * monCapStd))) {
            map.put("flag", 2);
        }
        //损坏:容量低
        if ((disNum > 0) && (realCap < capChange * monCapStd)) {
            map.put("flag", 3);
        }
        return map;
    }
 
 
    public Response searchMonNum(ReportBattDTO dto) {
        List list = new ArrayList();
        if (dto.getTestType() == 3) {
            //list = mapper.searchByBattGroupId(dto);
            list = subService.searchByBattGroupId(dto);
        }
        if (dto.getTestType() == 5) {
            //list = mapper.searchByBattGroupId5(dto);
            list = subService.searchByBattGroupId5(dto);
        }
        //添加内阻测试设置为标准值的那一笔,如果没有则拿最新的一笔
        List listRes = new ArrayList();
        //listRes = BattResDataMapper.serchisStandard(dto.getBattGroupId().intValue());
        listRes = subService.serchisStandard(dto.getBattGroupId().intValue());
        if (listRes == null || listRes.size() <= 0) {
            //listRes = BattResDataMapper.serchCurrent(dto.getBattGroupId().intValue());
            listRes = subService.serchCurrent(dto.getBattGroupId().intValue());
        }
        BattParamLow lowCA = new BattParamLow();
        lowCA.setLowType(2);
        lowCA.setLowNametype(2);//电容告警
        BattParamLow lowCH = new BattParamLow();
        lowCH.setLowType(2);
        lowCH.setLowNametype(3);//电容更换
        List<BattParamLow> listCA = battParamLowMapper.serchByLow(lowCA);
        List<BattParamLow> listCH = battParamLowMapper.serchByLow(lowCH);
        Float percentCA = listCA.get(0).getLowValue();
        Float percentCH = listCH.get(0).getLowValue();
        //电导基准/维护建议/电导分析值
        BattParamLow lowRA=new BattParamLow();
        lowRA.setLowType(3);
        lowRA.setLowNametype(2);//电导告警
        BattParamLow lowRH=new BattParamLow();
        lowRH.setLowType(3);
        lowRH.setLowNametype(3);//电导更换
 
        //电导
        List<BattParamLow> listRA = battParamLowMapper.serchByLow(lowRA);
        List<BattParamLow> listRH = battParamLowMapper.serchByLow(lowRH);
        Float percentRA = listRA.get(0).getLowValue();
        Float percentRH = listRH.get(0).getLowValue();
        int methodRM = listRA.get(0).getLowMethod();  //分析方式
 
        Map<String, Object> map = new HashMap<>();
        map.put("Data", list);
        map.put("Data2", listRes);
        map.put("LowCA", percentCA);
        map.put("LowCH", percentCH);
        map.put("LowRA", percentRA);
        map.put("LowRH", percentRH);
        map.put("newSum", methodRM);
 
        return new Response().set(1, map, "查询成功");
    }
 
 
}