lxw
2023-10-16 c18ffcf7b10717335a2e202372bec6ca2bc650a5
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
package com.whyc.service;
 
import com.whyc.dto.StandardFeatureCurve;
import com.whyc.mapper.CallBack;
import com.whyc.pojo.DevalarmDataHistory;
import com.whyc.pojo.PwrdevAlarmHistory;
import com.whyc.pojo.PwrdevDataHistory;
import com.whyc.pojo.UserLog;
import com.whyc.util.ActionUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import javax.swing.*;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
 
@Service
public class SubTablePageInfoService {
    @Autowired
    private MybatisSqlExecuteService sqlExecuteService;
    //2-SubTablePageInfoUtils.java;201行
    public List<PwrdevAlarmHistory> getList2(PwrdevAlarmHistory data){
        String sql="select  alarm.*,inf.StationName,inf.StationName1,inf.StationName2,inf.StationName3,inf.StationName5 " +
            " from db_pwrdev_alarm."+data.getRecordYear()+" alarm,db_pwrdev_inf.tb_pwrdev_inf inf " +
            " where alarm.PowerDeviceId = inf.PowerDeviceId ";
        if(data.getStationName1()!=null){
            sql+=" and stationName1 like '%"+data.getStationName1()+"%'";
        }
        if(data.getStationName2()!=null){
            sql+=" and stationName2 like '%"+data.getStationName2()+"%'";
        }
        if(data.getStationName5()!=null){
            sql+=" and stationName5 like '%"+data.getStationName5()+"%'";
        }
        if(data.getStationName3()!=null){
            sql+=" and stationName3 like '%"+data.getStationName3()+"%'";
        }
        if(data.getAlmStartTime()!=null){
            sql+=" and alarm.alm_start_time  >="+data.getAlmStartTime()+" ";
        }
        if(data.getAlmStartTime1()!=null){
            sql+=" and alarm.alm_start_time  <="+data.getAlmStartTime1()+" ";
        }
        if(data.getAlmSource()==0){
            sql+=" and alm_source!=100 ";
        }
        if(data.getAlmSource()!=0){
            sql+=" and alm_source="+data.getAlmSource()+" ";
        }
        if(data.getAlmTypes()!=null&&data.getAlmTypes().size()>0){
            sql+=" and alm_type in ( ";
            for (Integer item:data.getAlmTypes()) {
                sql+=item+",";
            }
            sql+=")";
        }
        sql+=" and StationId in ( select distinct inf.StationId from " +
                "                (select StationId from db_battinf.tb_battinf union select StationId from db_pwrdev_inf.tb_pwrdev_inf ) inf," +
                "                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.StationId=inf.StationId" +
                "                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="+data.getUsrId()+" ) order by alarm.alm_start_time desc limit "+data.getLimitStart()+","+data.getLimitEnd()+" ";
        List<PwrdevAlarmHistory> list = sqlExecuteService.executeQuery_call(sql, new CallBack() {
            @Override
            public List getResults(ResultSet rs) throws SQLException {
                List<PwrdevAlarmHistory> list=new ArrayList<>();
                while (rs.next()){
                    PwrdevAlarmHistory ph=new PwrdevAlarmHistory();
                    ph.setNum(rs.getLong("num"));
                    ph.setRecordId(rs.getLong("record_id"));
                    ph.setPowerDeviceId(rs.getLong("PowerDeviceId"));
                    ph.setAlmType(rs.getInt("alm_type"));
                    ph.setAlmLevel(rs.getInt("alm_level"));
                    ph.setAlmSource(rs.getInt("alm_source"));
                    ph.setAlmIndex(rs.getInt("alm_index"));
                    ph.setAlmStartTime(rs.getTimestamp("alm_start_time"));
                    ph.setAlmEndTime(rs.getTimestamp("alm_end_time"));
                    ph.setAlmValue(rs.getFloat("alm_value"));
                    ph.setAlmIsConfirmed(rs.getInt("alm_is_confirmed"));
                    ph.setAlmConfirmedTime(rs.getTimestamp("alm_confirmed_time"));
                    ph.setAlmClearedType(rs.getInt("alm_cleared_type"));
                    ph.setUsrId(rs.getInt("usr_Id"));
                    ph.setAlmTrigger(rs.getInt("alm_trigger"));
                    ph.setAlmSeverity(rs.getInt("alm_severity"));
                    ph.setStationName(rs.getString("StationName"));
                    ph.setStationName1(rs.getString("StationName1"));
                    ph.setStationName2(rs.getString("StationName2"));
                    ph.setStationName3(rs.getString("StationName3"));
                    ph.setStationName5(rs.getString("StationName5"));
                    list.add(ph);
                }
                return list;
            }
        });
        return  list;
    }
 
    //3-SubTablePageInfoUtils.java;72行
    public List<PwrdevAlarmHistory> getListForTX(PwrdevAlarmHistory data){
        String sql="select  alarm.*,inf.StationName,inf.StationName1,inf.StationName2,inf.StationName3,inf.StationName5 " +
        " from db_pwrdev_alarm."+data.getRecordYear()+" alarm,db_pwrdev_inf.tb_pwrdev_inf inf " +
        " where alarm.PowerDeviceId = inf.PowerDeviceId ";
        if(data.getStationName1()!=null){
            sql+=" and stationName1 like '%"+data.getStationName1()+"%'";
        }
        if(data.getStationName2()!=null){
            sql+=" and stationName2 like '%"+data.getStationName2()+"%'";
        }
        if(data.getStationName5()!=null){
            sql+=" and stationName5 like '%"+data.getStationName5()+"%'";
        }
        if(data.getStationName3()!=null){
            sql+=" and stationName3 like '%"+data.getStationName3()+"%'";
        }
        if(data.getAlmStartTime()!=null){
            sql+=" and alarm.alm_start_time  >="+data.getAlmStartTime()+" ";
        }
        if(data.getAlmStartTime1()!=null){
            sql+=" and alarm.alm_start_time  <="+data.getAlmStartTime1()+" ";
        }
        if(data.getAlmSource()==0){
            sql+=" and alm_source!=100 ";
        }
        if(data.getAlmSource()!=0){
            sql+=" and alm_source="+data.getAlmSource()+" ";
        }
        if(data.getAlmTypes()!=null&&data.getAlmTypes().size()>0){
            sql+=" and alm_type in ( ";
            for (Integer item:data.getAlmTypes()) {
                sql+=item+",";
            }
            sql+=")";
        }
        if(data.getAlmLevels()!=null&&data.getAlmLevels().size()>0){
            sql+=" and alm_level in ( ";
            for (Integer item:data.getAlmTypes()) {
                sql+=item+",";
            }
            sql+=")";
        }
        sql+=" and StationId in ( select distinct inf.StationId from " +
                "                (select StationId from db_battinf.tb_battinf union select StationId from db_pwrdev_inf.tb_pwrdev_inf ) inf," +
                "                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.StationId=inf.StationId" +
                "                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="+data.getUsrId()+" ) order by alarm.alm_start_time desc limit "+data.getLimitStart()+","+data.getLimitEnd()+" ";
        List<PwrdevAlarmHistory> list = sqlExecuteService.executeQuery_call(sql, new CallBack() {
            @Override
            public List getResults(ResultSet rs) throws SQLException {
                List<PwrdevAlarmHistory> list=new ArrayList<>();
                while (rs.next()){
                    PwrdevAlarmHistory ph=new PwrdevAlarmHistory();
                    ph.setNum(rs.getLong("num"));
                    ph.setRecordId(rs.getLong("record_id"));
                    ph.setPowerDeviceId(rs.getLong("PowerDeviceId"));
                    ph.setAlmType(rs.getInt("alm_type"));
                    ph.setAlmLevel(rs.getInt("alm_level"));
                    ph.setAlmSource(rs.getInt("alm_source"));
                    ph.setAlmIndex(rs.getInt("alm_index"));
                    ph.setAlmStartTime(rs.getTimestamp("alm_start_time"));
                    ph.setAlmEndTime(rs.getTimestamp("alm_end_time"));
                    ph.setAlmValue(rs.getFloat("alm_value"));
                    ph.setAlmIsConfirmed(rs.getInt("alm_is_confirmed"));
                    ph.setAlmConfirmedTime(rs.getTimestamp("alm_confirmed_time"));
                    ph.setAlmClearedType(rs.getInt("alm_cleared_type"));
                    ph.setUsrId(rs.getInt("usr_Id"));
                    ph.setAlmTrigger(rs.getInt("alm_trigger"));
                    ph.setAlmSeverity(rs.getInt("alm_severity"));
                    ph.setStationName(rs.getString("StationName"));
                    ph.setStationName1(rs.getString("StationName1"));
                    ph.setStationName2(rs.getString("StationName2"));
                    ph.setStationName3(rs.getString("StationName3"));
                    ph.setStationName5(rs.getString("StationName5"));
                    list.add(ph);
                }
                return list;
            }
        });
        return  list;
    }
 
    //4-SubTablePageInfoUtils.java;445行
    public int getCount(UserLog userLog){
        String sql=" select count(*) num from db_user."+userLog.getRecordYear()+" l,db_user.tb_user_inf u" +
                "        where l.uId = u.uId" +
                "        and uOprateDay between "+userLog.getOperationTime()+" and "+userLog.getOperationTime2()+" ";
        if(userLog.getUId()!=null){
            sql+=" and l.uId ="+userLog.getUId()+" ";
        }
        //条件查询-非全部
        if(userLog.getEventType()!=null){
            if(userLog.getEventType()==1){
                if(userLog.getOperationType()==1||userLog.getOperationType()==2
                   ||userLog.getOperationType()==20||userLog.getOperationType()==21){
                    if(userLog.getOperationType()==1){
                        sql+=" and uoprateType in ("+userLog.getOperationType()+",35) ";
                    }else{
                        sql+=" and uoprateType ="+userLog.getOperationType()+" ";
                    }
                }
                if(userLog.getOperationType()==31||userLog.getOperationType()==32
                        ||userLog.getOperationType()==33||userLog.getOperationType()==34){
                    sql+=" and uoprateType ="+userLog.getOperationType()+" ";
                    if(userLog.getOperationType()==31){
                        sql+=" or uOprateMsg  regexp '登录PC系统失败' ";
                    }else if(userLog.getOperationType()==32){
                        sql+=" or uOprateMsg  regexp '配置参数修改|导航配置' ";
                    }else if(userLog.getOperationType()==33){
                        sql+=" r uOprateMsg  regexp '密码' and uOprateMsg not regexp '更新密码复杂度规则' ";
                    }else{
                        sql+=" or uOprateMsg  regexp 'LoginAction!login|imeout' ";
                    }
                }
                if(userLog.getOperationType()==3||userLog.getOperationType()==4||userLog.getOperationType()==5){
                    sql+=" and uoprateType= #{operationType} " +
                            "                            and uOprateMsg  regexp " +
                            "                            '添加新用户|的用户信息|权限组|审计数据记录容量 " +
                            "                            |执行了User模块|执行了PermitGroup' ";
                }
            }
            if(userLog.getEventType()==2){
                sql+=" and uoprateType= #{operationType} " +
                        "                    and uOprateMsg regexp '单体|电池组|组端|设备|Batt|Dev|FBO|Fbs|Ld9|Li9130|Lithium|Station3D' " +
                        "                    and uOprateMsg not regexp '电源|Pwrdev' ";
            }
            if(userLog.getEventType()==3){
                sql+=" and uoprateType= #{operationType}  " +
                        "                    and uOprateMsg regexp 'PowerInf|Pwr' ";
            }
            if(userLog.getEventType()==4){
                sql+=" and uoprateType= #{operationType} " +
                        "                    and uOprateMsg not regexp '添加新用户|的用户信息|权限组|审计数据记录容量|配置参数修改|导航配置|密码|单体|电池组|组端|设备|电源| " +
                        "                    |执行了User模块|执行了PermitGroup| " +
                        "                    |Batt|Dev|FBO|Fbs|Ld9|Li9130|Lithium|Station3D| " +
                        "                    |PowerInf|Pwr' ";
            }
        }
        List list = sqlExecuteService.executeQuery_call(sql, new CallBack() {
            @Override
            public List getResults(ResultSet rs) throws SQLException {
                LinkedList<Object> temp = new LinkedList<>();
                try {
                    while (rs.next())
                        temp.add(rs.getInt("num"));
                } catch (SQLException e) {
                    e.printStackTrace();
                }
                return temp;
            }
        });
        int num =0;
        if(list!=null){
            num= (int) list.get(0);
        }
       return num;
    }
 
    //5-PwrdevDataHistoryService.java;81行
    public List<PwrdevDataHistory> getData(String tableName){
        String sql=" select * from db_pwrdev_data_history."+tableName+" ";
        List<PwrdevDataHistory> list = sqlExecuteService.executeQuery_call(sql, new CallBack() {
            @Override
            public List getResults(ResultSet rs) throws SQLException {
                List<PwrdevDataHistory> list=new ArrayList<>();
                while (rs.next()){
                    PwrdevDataHistory ph=new PwrdevDataHistory();
                    ph.setNum(rs.getInt("num"));
                    ph.setPowerDeviceId(rs.getInt("PowerDeviceId"));
                    ph.setRecordTime(rs.getTimestamp("record_time"));
                    ph.setAcAcIn1VolA(rs.getFloat("AC_acIn1_volA"));
                    ph.setAcAcIn1VolB(rs.getFloat("AC_acIn1_volB"));
                    ph.setAcAcIn1VolC(rs.getFloat("AC_acIn1_volC"));
                    ph.setAcAcIn1CurrA(rs.getFloat("AC_acIn1_currA"));
                    ph.setAcAcIn1CurrB(rs.getFloat("AC_acIn1_currB"));
                    ph.setAcAcIn1CurrC(rs.getFloat("AC_acIn1_currC"));
                    ph.setAcAcIn2VolA(rs.getFloat("AC_acIn2_volA"));
                    ph.setAcAcIn2VolB(rs.getFloat("AC_acIn2_volB"));
                    ph.setAcAcIn2VolC(rs.getFloat("AC_acIn2_volC"));
                    ph.setAcAcIn2CurrA(rs.getFloat("AC_acIn2_currA"));
                    ph.setAcAcIn2CurrB(rs.getFloat("AC_acIn2_currB"));
                    ph.setAcAcIn2CurrC(rs.getFloat("AC_acIn2_currC"));
                    ph.setAcTemprature(rs.getFloat("AC_temprature"));
                    ph.setAcAcVolHLimit(rs.getFloat("AC_acVolH_Limit"));
                    ph.setAcAcVolLLimit(rs.getFloat("AC_acVolL_Limit"));
                    ph.setAcdcAcIn1VolA(rs.getFloat("ACDC_acIn1_volA"));
                    ph.setAcdcAcIn1VolB(rs.getFloat("ACDC_acIn1_volB"));
                    ph.setAcdcAcIn1VolC(rs.getFloat("ACDC_acIn1_volC"));
                    ph.setAcdcAcIn2VolA(rs.getFloat("ACDC_acIn2_volA"));
                    ph.setAcdcAcIn2VolB(rs.getFloat("ACDC_acIn2_volB"));
                    ph.setAcdcAcIn2VolC(rs.getFloat("ACDC_acIn2_volC"));
                    ph.setAcdcAcOutVolA(rs.getFloat("ACDC_acOut_volA"));
                    ph.setAcdcAcOutVolB(rs.getFloat("ACDC_acOut_volB"));
                    ph.setAcdcAcOutVolC(rs.getFloat("ACDC_acOut_volC"));
                    ph.setAcdcAcOutCurrA(rs.getFloat("ACDC_acOut_currA"));
                    ph.setAcdcAcOutCurrB(rs.getFloat("ACDC_acOut_currB"));
                    ph.setAcdcAcOutCurrC(rs.getFloat("ACDC_acOut_currC"));
                    ph.setAcdcDcOutVol(rs.getFloat("ACDC_dcOut_vol"));
                    ph.setAcdcLoaderCurr(rs.getFloat("ACDC_loader_curr"));
                    ph.setAcdcBattgroup1Vol(rs.getFloat("ACDC_battgroup1_vol"));
                    ph.setAcdcBattgroup1Curr(rs.getFloat("ACDC_battgroup1_curr"));
                    ph.setAcdcBattgroup2Vol(rs.getFloat("ACDC_battgroup2_vol"));
                    ph.setAcdcBattgroup2Curr(rs.getFloat("ACDC_battgroup2_curr"));
                    ph.setAcdcAcdcmTemp(rs.getFloat("ACDC_acdcm_temp"));
                    ph.setAcdcM1OutCurr(rs.getFloat("ACDC_m1_outCurr"));
                    ph.setAcdcM2OutCurr(rs.getFloat("ACDC_m2_outCurr"));
                    ph.setAcdcM3OutCurr(rs.getFloat("ACDC_m3_outCurr"));
                    ph.setAcdcM4OutCurr(rs.getFloat("ACDC_m4_outCurr"));
                    ph.setAcdcM5OutCurr(rs.getFloat("ACDC_m5_outCurr"));
                    ph.setAcdcM6OutCurr(rs.getFloat("ACDC_m6_outCurr"));
                    ph.setAcdcM7OutCurr(rs.getFloat("ACDC_m7_outCurr"));
                    ph.setAcdcM8OutCurr(rs.getFloat("ACDC_m8_outCurr"));
                    ph.setAcdcM9OutCurr(rs.getFloat("ACDC_m9_outCurr"));
                    ph.setAcdcM10OutCurr(rs.getFloat("ACDC_m10_outCurr"));
                    ph.setAcdcM11OutCurr(rs.getFloat("ACDC_m11_outCurr"));
                    ph.setAcdcM12OutCurr(rs.getFloat("ACDC_m12_outCurr"));
                    ph.setAcdcM13OutCurr(rs.getFloat("ACDC_m13_outCurr"));
                    ph.setAcdcM14OutCurr(rs.getFloat("ACDC_m14_outCurr"));
                    ph.setAcdcM15OutCurr(rs.getFloat("ACDC_m15_outCurr"));
                    ph.setAcdcM16OutCurr(rs.getFloat("ACDC_m16_outCurr"));
                    ph.setAcdcChargLimitCurr(rs.getFloat("ACDC_chargLimitCurr"));
                    ph.setAcdcJunChargeVol(rs.getFloat("ACDC_junChargeVol"));
                    ph.setAcdcFloatChargeVol(rs.getFloat("ACDC_floatChargeVol"));
                    ph.setAcdcAcVolHLimit(rs.getFloat("ACDC_acVolH_Limit"));
                    ph.setAcdcAcVolLLimit(rs.getFloat("ACDC_acVolL_Limit"));
                    ph.setAcdcDcOutVolHLimit(rs.getFloat("ACDC_dcOutVolH_Limit"));
                    ph.setAcdcDcOutVolLLimit(rs.getFloat("ACDC_dcOutVolL_Limit"));
                    ph.setDcDcIn1Vol(rs.getFloat("DC_dcIn1_vol"));
                    ph.setDcDcIn2Vol(rs.getFloat("DC_dcIn2_vol"));
                    ph.setDcDcOut1Vol(rs.getFloat("DC_dcOut1_vol"));
                    ph.setDcDcOut1Curr(rs.getFloat("DC_dcOut1_curr"));
                    ph.setDcDcOut2Vol(rs.getFloat("DC_dcOut2_vol"));
                    ph.setDcDcOut2Curr(rs.getFloat("DC_dcOut2_curr"));
                    ph.setDcTemprature(rs.getFloat("DC_temprature"));
                    ph.setDcDcVolHLimit(rs.getFloat("DC_dcVolH_Limit"));
                    ph.setDcDcVolLLimit(rs.getFloat("DC_dcVolL_Limit"));
                    list.add(ph);
                }
                return list;
            }
        });
        return list;
    }
 
}