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
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
package com.battdata_rt;
 
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Random;
 
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
 
import com.base.Com;
import com.config.AppConfig;
import com.config.AppParam;
import com.sql.MysqlConnPool;
import com.sql.Sql_Mysql;
import com.sql.Sql_Sybase;
 
public class BattData_RT_Array {
    
    final public static int DATA_SOURCE_FBSDEV = 0;
    final public static int DATA_SOURCE_SQLSERVER = 1;
    final public static int DATA_SOURCE_C_INTERFACE = 2;
    final public static int DATA_SOURCE_SQLSERVER_AND_C_INTERFACE = 3;
    
    private ArrayList<BattData_RT> Data_Array = new ArrayList<BattData_RT>();
    private MysqlConnPool m_Conn_Pool;
    private int Sybase_query_count = 0;
    private Date m_SybaseServerDate = new Date();
    private AppParam m_Param;
    private AppConfig m_AppCfg;
    private ArrayList<String> al_stationid = new ArrayList<String>();
    private Logger logger = null;
    
    public BattData_RT_Array(AppConfig cfg, AppParam param, MysqlConnPool pool)
    {
        logger = LogManager.getFormatterLogger(this);
        m_AppCfg = cfg;
        m_Param = param;
        m_Conn_Pool = pool;
    }
    
    public Date getSybaseServerDateTime()
    {
        return m_SybaseServerDate;
    }
    
    public int getSybaseQueryCount()
    {
        return Sybase_query_count;
    }
    
    public int getItemCount()
    {
        return Data_Array.size();
    }
    
    public BattData_RT getItem(int index)
    {
        return Data_Array.get(index);
    }
    
    public void addItem(BattData_RT data)
    {
        Data_Array.add(data);
    }
    /********************************* initBattDataRT_Inf *************************************/
    public void initBattDataRT_Inf()
    {
        Data_Array.clear();
        //³õʼ»¯ Data_Array ¼¯ºÏÖеÄÊý¾Ý
        initBattDataRT_Inf_FromSQL();            //ÉèÖÃData_ArrayÖеÄÖµ    
    }
    
    /******************************************************************************************/
    private void initBattDataRT_Inf_FromSQL1()
    {
        Sql_Mysql sql = new Sql_Mysql(m_Conn_Pool.getConn());
        ResultSet res;
        String sql_str;
        try {
            sql.sqlMysqlUseDB(Sql_Mysql.DB_BATT_INF);
            
            sql_str = "    SELECT DISTINCT StationId,StationName,StationIp, "
                    + " FBSDeviceId,FBSDeviceIp,FBSDeviceName,GroupIndexInFBSDevice,"
                    + " BattGroupId,BattGroupNum,MonCount,BattFloatCurrent,FloatVolLevel,MonCapStd,MonVolStd,MonResStd"
                    + " FROM " + Sql_Mysql.BattInf_Table
                    + " ORDER BY BattGroupId ASC";
            
            res = sql.sqlMysqlQuery(sql_str);
            while(res.next())
            {
                BattData_RT rtdata = new BattData_RT(m_AppCfg, m_Param, m_Conn_Pool);
                
                rtdata.StationId = res.getLong("StationId");
                rtdata.StationName = res.getString("StationName");
                
                //System.out.println("StationIp" + res.getString("StationIp"));
                //Com.getIPFromStr(res.getString("StationIp").trim(), rtdata.StationIp);
                
                rtdata.FBSDeviceId = res.getInt("FBSDeviceId");
                rtdata.FBSDeviceIp = res.getString("FBSDeviceIp").trim();
                rtdata.FBSDeviceName = res.getString("FBSDeviceName");
                rtdata.GroupIndexInFBSDevice = res.getInt("GroupIndexInFBSDevice");
                
                rtdata.BattGroupId = res.getInt("BattGroupId");
                rtdata.BattGroupNum = res.getInt("BattGroupNum");
                
                rtdata.MonCount = res.getInt("MonCount");
                if(rtdata.MonCount >= 500)
                    rtdata.MonCount = 500;
                if(rtdata.MonCount < 0)
                    rtdata.MonCount = 0;
                
                rtdata.MonStdCap = res.getFloat("MonCapStd");
                rtdata.MonStdVol = res.getFloat("MonVolStd");
                rtdata.MonStdRes = res.getFloat("MonResStd");
                rtdata.setBattFloatVolCurrLevel(res.getFloat("FloatVolLevel"), res.getFloat("BattFloatCurrent"));
                Data_Array.add(rtdata);
            }
            
            boolean std_SignalName = false;
            sql_str = "SELECT SignalName "
                    + " FROM " + Sql_Mysql.BattInf_Table
                    + " LIMIT 1";
            res = sql.sqlMysqlQuery(sql_str);
            if(res.next()) {
                if(null != res.getString("SignalName") && res.getString("SignalName").contains("#")) {
                    std_SignalName = true;
                }
            }
            
            int auto_cid = 1000;
            for(int n=0; n<Data_Array.size(); n++)
            {
                BattData_RT rtdata = Data_Array.get(n);
                if(true == std_SignalName) {
                    sql_str = "SELECT DISTINCT DeviceId,SignalId,SignalName,CInterFaceId "
                            + " FROM " + Sql_Mysql.BattInf_Table
                            + " WHERE BattGroupId=" + rtdata.BattGroupId 
                            + " ORDER BY SignalName ASC";
                } else {
                    sql_str = "SELECT DISTINCT DeviceId,SignalId,SignalName,CInterFaceId,DeviceName "
                            + " FROM " + Sql_Mysql.BattInf_Table
                            + " WHERE BattGroupId=" + rtdata.BattGroupId 
                            + " ORDER BY "
                            + " CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(DeviceName,'-',-2),'-',1)  AS SIGNED) ASC, "
                            + " CAST(TRIM('µ¥Ìåµçѹ' FROM SignalName) AS SIGNED) ASC";
                }
                
                res = sql.sqlMysqlQuery(sql_str);
                
                boolean mon_data_ready = false;
                while(res.next())
                {
                    if(res.getString("SignalName").contains("µ¥Ìå"))
                    {
                        if(rtdata.al_MonVol.size() < rtdata.MonCount) {
                            MonVolData data = new MonVolData(res.getInt("DeviceId"), res.getInt("SignalId"), res.getInt("CInterFaceId"));
                            rtdata.al_MonVol.add(data);                            
                            rtdata.al_MonVol_RtOld.add(data.clone());
                            rtdata.al_MonVol_History.add(data.clone());
                        }
                        mon_data_ready = true;
                    } else {
                        mon_data_ready = false;
                        break;
                    }
                }
                //-------------------------------------------------------------//
                if(false == mon_data_ready) {
                    for(int mn=0; mn<rtdata.MonCount; mn++) {
                        MonVolData data = new MonVolData(0, 0, auto_cid++);
                        rtdata.al_MonVol.add(data);
                        //System.out.println(data.monVol+"################");
                        rtdata.al_MonVol_RtOld.add(data.clone());
                        rtdata.al_MonVol_History.add(data.clone());
                    }
                }
                
                rtdata.make_al_MonVol_C_Id();
                //-------------------------------------------------------------//
                /*
                sql_str = "SELECT DISTINCT CurrDeviceId,CurrValueId"
                            + " FROM " + Sql_Mysql.BattCurrInf_Table
                            + " WHERE BattGroupId=" + rtdata.BattGroupId;
                res = sql.sqlMysqlQuery(sql_str);
                int c_id_count=0;
                while(res.next())
                {
                    rtdata.BattCurrDeviceId = res.getInt("CurrDeviceId");
                    if(c_id_count < rtdata.BattCurrValueId.length)
                        rtdata.BattCurrValueId[c_id_count++] = res.getInt("CurrValueId");
                    else break;
                }
                */
            }
            res.close();
            
            /**********************************************************************************/
            sql.sqlMysqlUseDB(Sql_Mysql.DB_BATT_INF);
            al_stationid.clear();
            sql_str = "SELECT DISTINCT StationId FROM " + Sql_Mysql.BattInf_Table;
            res = sql.sqlMysqlQuery(sql_str);
            while(res.next())
            {
                al_stationid.add(res.getString("StationId"));
            }
            /**********************************************************************************/
            
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            sql.close_con();
        }
    }
    /******************************************************************************************/
    /******************************************************************************************/
    private void initBattDataRT_Inf_FromSQL()
    {
        logger.warn("run initBattDataRT_Inf_FromSQL()");
        Sql_Mysql sql = new Sql_Mysql(m_Conn_Pool.getConn());
        try {
            sql.sqlMysqlUseDB(Sql_Mysql.DB_BATT_INF);
            
            String sql_str = "SELECT DISTINCT "
                            + " FBSDeviceId,FBSDeviceIp,BattGroupName6,GroupIndexInFBSDevice,"
                            + " BattGroupId,BattGroupNum,MonCount,BattFloatCurrent,FloatVolLevel,MonCapStd,MonVolStd,MonResStd,CInterFaceId,PackCount"
                            + " FROM " + Sql_Mysql.BattInf_Table
                            + " ORDER BY BattGroupId ASC";
            
            ResultSet res = sql.sqlMysqlQuery(sql_str);
            int auto_cid = 100000001;
            while(res.next()) {
                int dev_id = res.getInt("FBSDeviceId");
                int bg_id = res.getInt("BattGroupId");
                int mon_cnt = res.getInt("MonCount");
                /**
                 *     Ð½®ï®µç³Ø°üÓÃÓÚͳ¼Æ×ܵĵ¥ÌåÊýÄ¿
                 */
                int tmp_PackCount = res.getInt("PackCount");                            //ï®µç³Ø°üÊýÁ¿
                if(dev_id/100000 == 9131 && tmp_PackCount > 0) {
                    //н®ï®µç³Ø°üµ¥Ìå×ÜÊý = µ¥ÌåÊýÄ¿ * ï®µç³Ø°üÊýÁ¿
                    mon_cnt = mon_cnt * tmp_PackCount;
                    //System.out.println(dev_id+"ï®µç³Øµ¥ÌåÊýÄ¿£º"+mon_cnt);
                }
                if(mon_cnt >= 500) {
                    mon_cnt = 500;
                }
                if(mon_cnt < 0) {
                    mon_cnt = 0;
                }
                boolean batt_group_exist = false;
                String tmp_devip = res.getString("FBSDeviceIp").trim();
                String reg_code = res.getString("BattGroupName6");
                reg_code = reg_code==null?"":reg_code.trim(); 
                float float_vol_lev = res.getFloat("FloatVolLevel");
                float float_curr_lev = res.getFloat("BattFloatCurrent");
                int GroupIndexInFBSDevice = res.getInt("GroupIndexInFBSDevice");
                int CInterFaceId = res.getInt("CInterFaceId");                            //ÅжÏÊÇ·ñ¼ÓÃÜ
                
                if(GroupIndexInFBSDevice > 3) {
                    GroupIndexInFBSDevice = 3;
                }
                if(GroupIndexInFBSDevice < 0) {
                    GroupIndexInFBSDevice = 0;
                }
                for(int n=0; n<Data_Array.size(); n++) {
                    BattData_RT brt = Data_Array.get(n);
                    if(bg_id == brt.BattGroupId) {
                        //----------------- edit by mxpopstar @2020-11-10 -----------------//
                        if(false == tmp_devip.contentEquals(brt.FBSDeviceIp)) {
                            logger.warn("old dev_ip:" + brt.FBSDeviceIp + ", new dev_ip:" + tmp_devip);
                            brt.FBSDeviceIp = tmp_devip;
                        }
                        
                        boolean param_changed = false;
                        if(mon_cnt != brt.al_MonVol.size()) {
                            brt.updateMonCnt(mon_cnt);
                            param_changed = true;
                        }
                        if(GroupIndexInFBSDevice != brt.GroupIndexInFBSDevice) {
                            brt.GroupIndexInFBSDevice = GroupIndexInFBSDevice;
                            param_changed = true;
                        }
                        
                        if(true == param_changed) {
                            logger.warn(String.format("FBS9100S Dev Inf Changed£ºdevid:%d, bgid:%d, group_index:%d, moncnt:%d,",
                                                        brt.FBSDeviceId, brt.BattGroupId, 
                                                        brt.GroupIndexInFBSDevice, brt.MonCount));
                            
                        }
                        
                        batt_group_exist = true;
                        break;
                    }
                }
                
                if(true == batt_group_exist) {
                    continue;
                } else {
                    BattData_RT rtdata = new BattData_RT(m_AppCfg,m_Param, m_Conn_Pool);
                    
                    rtdata.FBSDeviceId = res.getInt("FBSDeviceId");
                    rtdata.FBSDeviceIp = res.getString("FBSDeviceIp").trim();
                    
                    String tmp_reg_code = res.getString("BattGroupName6");
                    
                    rtdata.GroupIndexInFBSDevice = res.getInt("GroupIndexInFBSDevice");
                    if(rtdata.GroupIndexInFBSDevice > 8) {
                        rtdata.GroupIndexInFBSDevice = 8;
                    }
                    if(rtdata.GroupIndexInFBSDevice < 0) {
                        rtdata.GroupIndexInFBSDevice = 0;
                    }
                    
                    rtdata.BattGroupId = res.getInt("BattGroupId");
                    rtdata.BattGroupNum = res.getInt("BattGroupNum");
                    
                    //rtdata.MonCount = res.getInt("MonCount");
                    rtdata.MonCount = mon_cnt;
                    if(rtdata.MonCount >= 500) {
                        rtdata.MonCount = 500;
                    }
                    if(rtdata.MonCount < 0) {
                        rtdata.MonCount = 0;
                    }
                    
                    rtdata.MonStdCap = res.getFloat("MonCapStd");
                    rtdata.MonStdVol = res.getFloat("MonVolStd");
                    rtdata.MonStdRes = res.getFloat("MonResStd");
                    rtdata.setBattFloatVolCurrLevel(res.getFloat("FloatVolLevel"), res.getFloat("BattFloatCurrent"));
                    
                    for(int mn=0; mn<rtdata.MonCount; mn++) {
                        MonVolData data = new MonVolData(0, 0, auto_cid++);
                        rtdata.al_MonVol.add(data);
                        //System.out.println(data.monVol+"################");
                        rtdata.al_MonVol_RtOld.add(data.clone());
                        rtdata.al_MonVol_History.add(data.clone());
                    }
                    Data_Array.add(rtdata);
                }
            }
            res.close();
            
            /*
            sql.sqlMysqlUseDB(Sql_Mysql.DB_BATT_INF);
            al_stationid.clear();
            sql_str = "SELECT DISTINCT StationId FROM " + Sql_Mysql.BattInf_Table;
            res = sql.sqlMysqlQuery(sql_str);
            while(res.next()) {
                al_stationid.add(res.getString("StationId"));
            }*/
            /**********************************************************************************/
            
        } catch (SQLException e) {
            logger.error(e.toString(), e);
        } finally {
            sql.close_con();
        }
    }
    
    /******************************* getDataFromSybase_Task ***********************************/
    public void getDataFromSybase_Task( AppConfig cfg, int start_index, int count,
                                        GregorianCalendar gc_start, GregorianCalendar gc_end, 
                                        boolean realtime_data, String time_order)
    {
        Sql_Sybase m_sybase_sql = null;
        try 
        {
            String sql_str = null;
            m_sybase_sql = new Sql_Sybase(cfg);
            if(false == m_sybase_sql.get_conn_state())
            {
                Thread.sleep(1000);
                return;
            }
            
            //-----------------------------------------------//
            if(start_index < 0)
                start_index = 0;
            if(count < 0)
                count = 0;
            
            if(start_index >= al_stationid.size()) {
                start_index = al_stationid.size()-1;
            }
            if((start_index+count) > al_stationid.size()) {
                count = al_stationid.size()-start_index;
            }
            //-----------------------------------------------//
            
            /**********************************************************************************/
            ResultSet rs = m_sybase_sql.sqlSybaseQuery("select getdate()");
            if (rs.next()) {
                m_SybaseServerDate.setTime(rs.getTimestamp("").getTime());
            }
            if(Math.abs(m_SybaseServerDate.getTime() - (new Date().getTime())) > 5000) {
                Com.setDateTime(m_SybaseServerDate);
            }
            /**********************************************************************************/
            //================================================================================//
            if(Sql_Sybase.SQL_TYPE_SYBASE == m_sybase_sql.get_SQL_TYPE())
            {
                for(int n=start_index; n<(start_index+count); n++)
                {
                    //System.out.println(al_stationid.get(n));
                    sql_str = m_sybase_sql.getQueryCurrentString(al_stationid.get(n), gc_start, gc_end, time_order);
                    //System.out.println(sql_str);
                    rs = m_sybase_sql.sqlSybaseQuery(sql_str);
                    
                    while(rs.next())
                    {
                        long st_id = rs.getLong("StationId");
                        int dv_id = rs.getInt("EquipmentId");
                        int sg_id = rs.getInt("SignalId");
                        
                        //System.out.println(st_id + ", " + dv_id + ", " + sg_id);
                        if((dv_id < 1) || (sg_id < 1))
                            continue;
                        
                        for(int st_index=0; st_index<Data_Array.size(); st_index++)
                        {
                            if(Data_Array.get(st_index).StationId == st_id)
                            {
                                BattData_RT batt_data = Data_Array.get(st_index);
                                if(batt_data.BattCurrDeviceId == dv_id)
                                {
                                    if(true == realtime_data)
                                    {
                                        for(int id_cnt=0; id_cnt<batt_data.BattCurrValueId.length; id_cnt++)
                                        {
                                            if(sg_id == batt_data.BattCurrValueId[id_cnt])
                                            {
                                                batt_data.TestData.TestCurr_RT_TMP = rs.getFloat("FloatValue");
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    rs.close();
                }
            }
            /**********************************************************************************/
            /**********************************************************************************/
            for(int n=start_index; n<(start_index+count); n++)
            {
                //System.out.println(al_stationid.get(n));
                sql_str = m_sybase_sql.getQueryVolString(al_stationid.get(n), gc_start, gc_end, time_order);
                //System.out.println(sql_str);
                rs = m_sybase_sql.sqlSybaseQuery(sql_str);
                
                while(rs.next())
                {
                    int st_id = rs.getInt("StationId");
                    int dv_id = rs.getInt("EquipmentId");
                    int sg_id = rs.getInt("SignalId");
                    
                    //System.out.println(st_id + ", " + dv_id + ", " + sg_id);
                    
                    if((dv_id < 1) || (sg_id < 1))
                        continue;                    
                    for(int st_index=0; st_index<Data_Array.size(); st_index++)
                    {
                        if(Data_Array.get(st_index).StationId == st_id)
                        {
                            BattData_RT batt_data = Data_Array.get(st_index);
                            if((Sql_Sybase.SQL_TYPE_SYBASE != m_sybase_sql.get_SQL_TYPE())
                                    && (batt_data.BattCurrDeviceId == dv_id))
                            {
                                if(true == realtime_data)
                                {
                                    for(int id_cnt=0; id_cnt<batt_data.BattCurrValueId.length; id_cnt++)
                                    {
                                        if(sg_id == batt_data.BattCurrValueId[id_cnt])
                                        {
                                            batt_data.TestData.TestCurr_RT_TMP = rs.getFloat("FloatValue");
                                        }
                                    }
                                }
                            }
                            else
                            {
                                for(int bt_index=0; bt_index<batt_data.al_MonVol.size(); bt_index++)
                                {
                                    if((batt_data.al_MonVol.get(bt_index).deviceId == dv_id)
                                        && (batt_data.al_MonVol.get(bt_index).monId == sg_id))
                                    {
                                        if((true == realtime_data) || (batt_data.al_MonVol.get(bt_index).monVol_TMP <= 0.01))
                                        {
                                            batt_data.al_MonVol.get(bt_index).monVol_TMP = rs.getFloat("FloatValue");
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                rs.close();
            }
            /**********************************************************************************/
            /**********************************************************************************/
            m_sybase_sql.close_conn();
            /**********************************************************************************/
            for(int n=0; n<Data_Array.size(); n++)
            {
                BattData_RT batt_data = Data_Array.get(n);
                batt_data.TestData.updateCurrFrom_SqlServer();
                batt_data.updateMonVolFromSQL_SERVER();
            }
            /*****************************************************************************************
            String path = "E:/suncity_java.txt";
            FileWriter fw = null;
            try {
                fw = new FileWriter(path);
            } catch (IOException e2) {
                e2.printStackTrace();
            }
            
            int write_count = 0;
            for(int g=0; g<st_data.size(); g++)
            {
                BattData_RT tmpdata = st_data.get(g);
                for(int n=0; n<tmpdata.MonVol.size(); n++)
                {
                    String file_str = tmpdata.StationId + ": "
                                        + tmpdata.MonVol.get(n).monName + ": "
                                        + tmpdata.MonVol.get(n).deviceId + ": " 
                                        + tmpdata.MonVol.get(n).monId + ": " 
                                        + tmpdata.MonVol.get(n).monVol;
                    try {
                        fw.write("count: " + (++write_count) + ": " + file_str + "\r\n");
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }
            try {
                fw.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
            ***************************************************************************************/
            Sybase_query_count++;
            if(Sybase_query_count < 0)
                Sybase_query_count = 0;
            /*
            System.out.println( Thread.currentThread().getName() 
                                + ": From " + Com.getDateTimeFormat(gc_start.getTime(), Com.DTF_YMDhms)
                                + " To " + Com.getDateTimeFormat(gc_end.getTime(), Com.DTF_YMDhms)
                                + ", sybase query_count: " + Sybase_query_count );
            */
        } catch (InterruptedException | SQLException e) {
            //e.printStackTrace();
        } finally {
            try {
                m_sybase_sql.close_conn();
            } catch (SQLException e) {
                //e.printStackTrace();
            }
        }
    }
    /******************************************************************************************/
    /********************************** makeRondomData_Task ***********************************/
    /**
     * ¸ù¾ÝËæ»úÊý¸üÐÂData_ArrayÖеĵçѹ£¬µçÁ÷£¬Î¶ȣ¬ÄÚ×裬µçµ¼µÈÖµ
     * @param start_index
     * @param count
     */
    public void makeRondomData_Task(int start_index, int count)
    {
        if(start_index < 0)
            start_index = 0;
        if(count < 0)
            count = 0;
        
        if(start_index >= al_stationid.size())
        {
            start_index = al_stationid.size()-1;
        }
        if((start_index+count) > al_stationid.size())
        {
            count = al_stationid.size()-start_index;
        }
        //-----------------------------------------------//
        Random rd = new Random();
        for(int n=0; n<Data_Array.size(); n++)
        {
            BattData_RT batt_data = Data_Array.get(n);
            for(int bt_index=0; bt_index<batt_data.al_MonVol.size(); bt_index++)
            {
                batt_data.al_MonVol.get(bt_index).monVol_TMP = batt_data.MonStdVol 
                                                                + (batt_data.MonStdVol/2) * (rd.nextFloat()/10);
            }
        }
        //-----------------------------------------------//
        for(int n=0; n<Data_Array.size(); n++)
        {
            BattData_RT batt_data = Data_Array.get(n);
            
            float sumvol = 0;
            for(int bt_index=0; bt_index<batt_data.al_MonVol.size(); bt_index++)
            {
                batt_data.al_MonVol.get(bt_index).monVol = batt_data.al_MonVol.get(bt_index).monVol_TMP;
                batt_data.al_MonVol.get(bt_index).monTmp = (float) (20.0 + rd.nextFloat()*5);
                batt_data.al_MonVol.get(bt_index).monRes = (float) (1.0 + rd.nextFloat()/2) * (batt_data.MonStdVol/2);
                //System.out.println(batt_data.BattGroupId + "," + (bt_index+1) + "," + batt_data.al_MonVol.get(bt_index).monVol);
                float ser = 0;
                if(batt_data.al_MonVol.get(bt_index).monRes > 0.1) {
                    ser = (float) ((1000.0 / batt_data.al_MonVol.get(bt_index).monRes) * (batt_data.MonStdVol/2));
                }
                batt_data.al_MonVol.get(bt_index).monSer = ser;
                sumvol += batt_data.al_MonVol.get(bt_index).monVol;
            }
            batt_data.TestData.groupVol = sumvol;
        }
        
        Sybase_query_count++;
        if(Sybase_query_count < 0)
            Sybase_query_count = 0;
    }
    /******************************************************************************************/
}