whyclj
2019-10-29 1c0469e45346d464e0c5672ee68f9ecd4fb6be7c
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
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
package com.fgkj.dao.impl.ram;
 
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import com.fgkj.dao.BaseDAO;
import com.fgkj.dao.CallBack;
import com.fgkj.dao.DAOHelper;
import com.fgkj.dao.FBS9100_ComBase;
import com.fgkj.dao.LimitNumberFactory;
import com.fgkj.dao.UinfDaoFactory;
import com.fgkj.db.DBUtil;
import com.fgkj.dto.BattInf;
import com.fgkj.dto.Page;
import com.fgkj.dto.User_inf;
import com.fgkj.dto.User_log;
import com.fgkj.dto.ram.FBS9100;
import com.fgkj.dto.ram.Fbs9100_state;
import com.fgkj.dto.ram.Fbs9600_state;
import com.fgkj.services.User_logService;
import com.sun.corba.se.spi.orbutil.fsm.FSM;
 
public class Fbs9100_stateImpl implements BaseDAO,CallBack{
    public List getResults(ResultSet rs) {
        List list=new ArrayList();
        try {
            while(rs.next()){
                Fbs9100_state fstate=new Fbs9100_state();
                fstate.setNum(rs.getInt("num"));
                fstate.setDev_ip(rs.getString("dev_ip"));
                fstate.setDev_id(rs.getInt("dev_id"));
                fstate.setOp_cmd(rs.getInt("op_cmd"));
                fstate.setDev_datetime(rs.getString("dev_datetime"));
                fstate.setDev_testtype(rs.getInt("dev_testtype"));
                fstate.setDev_testgroupnum(rs.getInt("dev_testgroupnum"));
                fstate.setDev_workstate(rs.getInt("dev_workstate"));
                fstate.setDev_alarmstate(rs.getInt("dev_alarmstate"));
                fstate.setDev_onlinevollow(rs.getInt("dev_onlinevollow"));
                fstate.setDev_eachgroup_battsum(rs.getInt("dev_eachgroup_battsum"));
                fstate.setDev_captest_onlinevol(rs.getFloat("dev_captest_onlinevol"));
                fstate.setDev_captest_groupvol(rs.getFloat("dev_captest_groupvol"));
                fstate.setDev_captest_curr(rs.getFloat("dev_captest_curr"));
                fstate.setDev_captest_cap(rs.getFloat("dev_captest_cap"));
                fstate.setDev_captest_timelong(rs.getInt("dev_captest_timelong"));
                fstate.setDev_restest_moncount(rs.getInt("dev_restest_moncount"));
                fstate.setDev_restest_monindex(rs.getInt("dev_restest_monindex"));
                fstate.setDev_commcount(rs.getInt("dev_commcount"));
                fstate.setDev_errcommcount(rs.getInt("dev_errcommcount"));
                list.add(fstate);
                
            }
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return list;
    }
 
    public boolean add(Object obj) {
        Fbs9100_state fs=(Fbs9100_state) obj;
        String sql="insert into db_ram_db.tb_Fbs9100_state(dev_ip,dev_id,op_cmd,dev_datetime,dev_testtype,dev_testgroupnum," +
                "dev_workstate,dev_alarmstate,dev_onlinevollow,dev_eachgroup_battsum,dev_captest_onlinevol,dev_captest_groupvol," +
                "dev_captest_curr,dev_captest_cap,dev_captest_timelong,dev_restest_moncount,dev_restest_monindex,dev_commcount," +
                "dev_errcommcount) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        Boolean bl=DAOHelper.executeUpdate(DBUtil.getConn(), sql, new Object[]{fs.getDev_ip(),fs.getDev_id(),
            fs.getOp_cmd(),fs.getDev_datetime(),fs.getDev_testtype(),fs.getDev_testgroupnum(),fs.getDev_workstate(),fs.getDev_alarmstate(),
            fs.getDev_onlinevollow(),fs.getDev_eachgroup_battsum(),fs.getDev_captest_onlinevol(),fs.getDev_captest_groupvol(),fs.getDev_captest_curr(),
            fs.getDev_captest_cap(),fs.getDev_captest_timelong(),fs.getDev_restest_moncount(),fs.getDev_restest_monindex(),fs.getDev_commcount(),
            fs.getDev_errcommcount()});
        return bl;
    }
 
    public boolean update(Object obj) {
        Fbs9100_state fs=(Fbs9100_state) obj;
        String sql="update db_ram_db.tb_Fbs9100_state set dev_ip=?,dev_id=?,op_cmd=?,dev_datetime=?,dev_testtype=?,dev_testgroupnum=?," +
                "dev_workstate=?,dev_alarmstate=?,dev_onlinevollow=?,dev_eachgroup_battsum=?,dev_captest_onlinevol=?,dev_captest_groupvol=?," +
                "dev_captest_curr=?,dev_captest_cap=?,dev_captest_timelong=?,dev_restest_moncount=?,dev_restest_monindex=?,dev_commcount=?," +
                "dev_errcommcount=? where num=?";
        Boolean bl=DAOHelper.executeUpdate(DBUtil.getConn(), sql, new Object[]{fs.getDev_ip(),fs.getDev_id(),
            fs.getOp_cmd(),fs.getDev_datetime(),fs.getDev_testtype(),fs.getDev_testgroupnum(),fs.getDev_workstate(),fs.getDev_alarmstate(),
            fs.getDev_onlinevollow(),fs.getDev_eachgroup_battsum(),fs.getDev_captest_onlinevol(),fs.getDev_captest_groupvol(),fs.getDev_captest_curr(),
            fs.getDev_captest_cap(),fs.getDev_captest_timelong(),fs.getDev_restest_moncount(),fs.getDev_restest_monindex(),fs.getDev_commcount(),
            fs.getDev_errcommcount(),fs.getNum()});
        return bl;
    }
    //fbs9600设备内阻测试
    public boolean updatePro(Object obj) {
        List<Fbs9100_state> list=(List<Fbs9100_state>) obj;
        ArrayList sql_str=new ArrayList();
        List<User_log> listU=new ArrayList<User_log>();//存放user_log
        for (Fbs9100_state fstate : list) {
            if(fstate.getOp_cmd()==FBS9100_ComBase.CMD_9600_Start){
                String sql="update db_ram_db.tb_Fbs9100_state set op_cmd="+fstate.getOp_cmd()+"  " +
                        "  where dev_id="+fstate.getDev_id();
                sql_str.add(sql);
            }
            {
                String msg="启动"+fstate.getDev_id()+"的设备内阻测试";
                User_log ulog=UinfDaoFactory.CreateULog(UinfDaoFactory.Increase, msg);
                listU.add(ulog);
             }
            
        }
        boolean bl=DAOHelper.makeManualCommit(DBUtil.getConn(), sql_str);
        (new User_logService()).addPro(listU);//将用户的操作记录下来
        return bl;
    }
    public boolean del(Object obj) {
        Fbs9100_state fs=(Fbs9100_state) obj;
        String sql="delete from db_ram_db.tb_Fbs9100_state where num=?";
        Boolean bl=DAOHelper.executeUpdate(DBUtil.getConn(), sql, new Object[]{fs.getNum()});
        return bl;
    }
 
    public List searchAll() {
        String sql="select * from db_ram_db.tb_Fbs9100_state";
        List list=DAOHelper.executeQuery(sql, DBUtil.getConn(), null, new Fbs9100_stateImpl());
        return list;
    }
    
   //11.1FBS9100设备通信状态查询
    /*
     * fbs9100:op_cmd:0:全部;1:fbs9100,2:fbs9600
     * dev_errcommcount;0:通讯正常,1:通讯中断,100:全部
    public List serchByCondition(Object obj) {
    Fbs9100_state fs=(Fbs9100_state) obj;
    Page page=fs.getPage();
    Connection conn=DBUtil.getConn();
    String numberSql=" SELECT FOUND_ROWS() number";
    String sql="";
    String baseSql="select SQL_CALC_FOUND_ROWS distinct tb_fbs9100_state.num,tb_fbs9100_state.dev_ip,tb_fbs9100_state.dev_version,record_datetime,tb_fbs9100_state.dev_id,op_cmd,dev_datetime,dev_testtype,dev_testgroupnum," +
            "dev_workstate,dev_alarmstate,dev_onlinevollow,dev_eachgroup_battsum,dev_captest_onlinevol,dev_captest_groupvol,dev_captest_curr," +
            "dev_captest_cap,dev_captest_timelong,dev_restest_moncount,dev_restest_monindex,dev_commcount,dev_errcommcount, " +
            "db_battinf.tb_battinf.StationName,db_battinf.tb_battinf.FbsDeviceName," +
            "COUNT(DISTINCT db_battinf.tb_battinf.BattGroupId) as cnt," +
            "group_CONCAT(db_ram_db.tb_batt_rtstate.online_vol ORDER BY db_ram_db.tb_batt_rtstate.BattGroupId separator '/') as online_vols,group_CONCAT(db_ram_db.tb_batt_rtstate.group_vol ORDER BY db_ram_db.tb_batt_rtstate.BattGroupId separator '/') as group_vols,group_CONCAT(db_ram_db.tb_batt_rtstate.group_curr ORDER BY db_ram_db.tb_batt_rtstate.BattGroupId separator '/') as group_currs  " +
            "from db_ram_db.tb_Fbs9100_state " +
            "left outer join db_battinf.tb_battinf ON tb_fbs9100_state.dev_id=db_battinf.tb_battinf.FBSDeviceId  " +
            "LEFT OUTER JOIN db_ram_db.tb_batt_rtstate ON db_battinf.tb_battinf.battgroupid=db_ram_db.tb_batt_rtstate.battgroupid ";
    
    //通讯中断
    String  comSqlT=" where dev_errcommcount=0  "; 
    String  comSqlF=" where dev_errcommcount>0  "; 
    if(fs.getDev_errcommcount()==0){
        baseSql+=comSqlT;
    }else if(fs.getDev_errcommcount()==1){
        baseSql+=comSqlF;
    }
    //分组
    String groupSql=" GROUP BY tb_fbs9100_state.dev_id ";
    //分页
    String limitSql=" limit ?,? ";
    //最后结果
    sql=baseSql+groupSql+limitSql;
    
    //System.out.println(sql);
    List<Fbs9100_state> list=DAOHelper.executeQueryLimit(sql, conn, new Object[]{(page.getPageCurr()-1)*page.getPageSize(),page.getPageSize()}, new CallBack() {
        List list=new ArrayList();
        public List getResults(ResultSet rs) {
            try {
                while(rs.next()){
                    Fbs9100_state fstate=new Fbs9100_state();
                    fstate.setNum(rs.getInt("cnt"));//关联电池组个数
                    fstate.setDev_ip(rs.getString("dev_ip"));
                    fstate.setDev_version(rs.getString("dev_version"));
                    fstate.setDev_id(rs.getInt("dev_id"));
                    fstate.setOp_cmd(rs.getInt("op_cmd"));
                    fstate.setRecord_datetime(rs.getString("record_datetime"));
                    fstate.setDev_datetime(rs.getString("dev_datetime"));
                    fstate.setDev_testtype(rs.getInt("dev_testtype"));
                    fstate.setDev_testgroupnum(rs.getInt("dev_testgroupnum"));
                    fstate.setDev_workstate(rs.getInt("dev_workstate"));
                    fstate.setDev_alarmstate(rs.getInt("dev_alarmstate"));
                    fstate.setDev_onlinevollow(rs.getInt("dev_onlinevollow"));
                    fstate.setDev_eachgroup_battsum(rs.getInt("dev_eachgroup_battsum"));
                    fstate.setDev_captest_onlinevol(rs.getFloat("dev_captest_onlinevol"));
                    fstate.setDev_captest_groupvol(rs.getFloat("dev_captest_groupvol"));
                    fstate.setDev_captest_curr(rs.getFloat("dev_captest_curr"));
                    fstate.setDev_captest_cap(rs.getFloat("dev_captest_cap"));
                    fstate.setDev_captest_timelong(rs.getInt("dev_captest_timelong"));
                    fstate.setDev_restest_moncount(rs.getInt("dev_restest_moncount"));
                    fstate.setDev_restest_monindex(rs.getInt("dev_restest_monindex"));
                    fstate.setDev_commcount(rs.getInt("dev_commcount"));
                    fstate.setDev_errcommcount(rs.getInt("dev_errcommcount"));
                    
                    fstate.setStationName(rs.getString("stationName"));
                    fstate.setDeviceName(rs.getString("FbsDeviceName"));
                    fstate.setOnline_vols(rs.getString("online_vols"));
                    fstate.setGroup_vols(rs.getString("group_vols"));
                    fstate.setGroup_currs(rs.getString("group_currs"));
                    
                    //System.out.println(fstate);
                    list.add(fstate);
                }
            } catch (SQLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            return list;
        }
    });
    //去掉limit条件后的总数
    int number=LimitNumberFactory.GetLimtitNumber(conn, numberSql);
    if(list!=null&&list.size()>0){
        page.setPageAll(number);
        list.get(list.size()-1).setPage(page);
    }
    return list;
     }*/
    //11.1FBS9100设备通信状态查询
    /*
     * fbs9100:op_cmd:0:全部;1:fbs9100,2:fbs9600
     * dev_errcommcount;0:通讯正常,1:通讯中断,100:全部
     * */
    public List serchByCondition(Object obj) {
        Fbs9100_state fs=(Fbs9100_state) obj;
        Page page=fs.getPage();
        Connection conn=DBUtil.getConn();
        String numberSql=" SELECT FOUND_ROWS() number";
        String sql="";
        String baseSql="select SQL_CALC_FOUND_ROWS distinct tb_fbs9100_state.num,tb_fbs9100_state.dev_ip,tb_fbs9100_state.dev_version,record_datetime,tb_fbs9100_state.dev_id,op_cmd,dev_datetime,dev_testtype,dev_testgroupnum," +
                "dev_workstate,dev_alarmstate,dev_res_test_state,dev_onlinevollow,dev_eachgroup_battsum,dev_captest_onlinevol,dev_captest_groupvol,dev_captest_curr," +
                "dev_captest_cap,dev_captest_timelong,dev_restest_moncount,dev_restest_monindex,dev_commcount,dev_errcommcount,db_ram_db.tb_fbs9100_state.dev_61850alarms,dev_last_captest_stop_type, " +
                "db_battinf.tb_battinf.StationName,db_battinf.tb_battinf.FbsDeviceName," +
                "COUNT(DISTINCT db_battinf.tb_battinf.BattGroupId) as cnt," +
                "group_CONCAT(db_ram_db.tb_batt_rtstate.online_vol ORDER BY db_ram_db.tb_batt_rtstate.BattGroupId separator '/') as online_vols,group_CONCAT(db_ram_db.tb_batt_rtstate.group_vol ORDER BY db_ram_db.tb_batt_rtstate.BattGroupId separator '/') as group_vols,group_CONCAT(db_ram_db.tb_batt_rtstate.group_curr ORDER BY db_ram_db.tb_batt_rtstate.BattGroupId separator '/') as group_currs  " +
                "from db_ram_db.tb_Fbs9100_state " +
                "left outer join db_battinf.tb_battinf ON tb_fbs9100_state.dev_id=db_battinf.tb_battinf.FBSDeviceId  " +
                "LEFT OUTER JOIN db_ram_db.tb_batt_rtstate ON db_battinf.tb_battinf.battgroupid=db_ram_db.tb_batt_rtstate.battgroupid ";
        
        //通讯中断
        String  comSqlT=" where dev_errcommcount=0  "; 
        String  comSqlF=" where dev_errcommcount>0  "; 
        String  comSqlA=" where dev_errcommcount>-1  "; 
        if(fs.getDev_errcommcount()==0){
            baseSql+=comSqlT;
        }else if(fs.getDev_errcommcount()==1){
            baseSql+=comSqlF;
        }else{
            baseSql+=comSqlA;
        }
        //判断是否为管理的机房
        String stationSql=" and db_battinf.tb_battinf.StationId in(select distinct db_battinf.tb_battinf.StationId " +
                " 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=? ) ";
        baseSql+=stationSql;
        //分组
        String groupSql=" GROUP BY tb_fbs9100_state.dev_id ";
        //分页
        String limitSql=" limit ?,? ";
        //最后结果
        sql=baseSql+groupSql+limitSql;
        
        //System.out.println(sql);
        List<Fbs9100_state> list=DAOHelper.executeQueryLimit(sql, conn, new Object[]{fs.getNum(),(page.getPageCurr()-1)*page.getPageSize(),page.getPageSize()}, new CallBack() {
            List list=new ArrayList();
            public List getResults(ResultSet rs) {
                try {
                    while(rs.next()){
                        Fbs9100_state fstate=new Fbs9100_state();
                        fstate.setNum(rs.getInt("cnt"));//关联电池组个数
                        fstate.setDev_ip(rs.getString("dev_ip"));
                        fstate.setDev_version(rs.getString("dev_version"));
                        fstate.setDev_id(rs.getInt("dev_id"));
                        fstate.setOp_cmd(rs.getInt("op_cmd"));
                        fstate.setRecord_datetime(rs.getString("record_datetime"));
                        fstate.setDev_datetime(rs.getString("dev_datetime"));
                        fstate.setDev_testtype(rs.getInt("dev_testtype"));
                        fstate.setDev_testgroupnum(rs.getInt("dev_testgroupnum"));
                        fstate.setDev_workstate(rs.getInt("dev_workstate"));
                        fstate.setDev_alarmstate(rs.getInt("dev_alarmstate"));
                        fstate.setDev_res_test_state(rs.getInt("dev_res_test_state"));
                        fstate.setDev_onlinevollow(rs.getInt("dev_onlinevollow"));
                        fstate.setDev_eachgroup_battsum(rs.getInt("dev_eachgroup_battsum"));
                        fstate.setDev_captest_onlinevol(rs.getFloat("dev_captest_onlinevol"));
                        fstate.setDev_captest_groupvol(rs.getFloat("dev_captest_groupvol"));
                        fstate.setDev_captest_curr(rs.getFloat("dev_captest_curr"));
                        fstate.setDev_captest_cap(rs.getFloat("dev_captest_cap"));
                        fstate.setDev_captest_timelong(rs.getInt("dev_captest_timelong"));
                        fstate.setDev_restest_moncount(rs.getInt("dev_restest_moncount"));
                        fstate.setDev_restest_monindex(rs.getInt("dev_restest_monindex"));
                        fstate.setDev_commcount(rs.getInt("dev_commcount"));
                        fstate.setDev_errcommcount(rs.getInt("dev_errcommcount"));
                        
                        fstate.setStationName(rs.getString("stationName"));
                        fstate.setDeviceName(rs.getString("FbsDeviceName"));
                        fstate.setOnline_vols(rs.getString("online_vols"));
                        fstate.setGroup_vols(rs.getString("group_vols"));
                        fstate.setGroup_currs(rs.getString("group_currs"));
                        fstate.setDev_61850alarms(rs.getString("dev_61850alarms"));
                        fstate.setDev_last_captest_stop_type(rs.getInt("dev_last_captest_stop_type"));
                        //System.out.println(fstate);
                        list.add(fstate);
                    }
                } catch (SQLException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                return list;
            }
        });
        //去掉limit条件后的总数
        int number=LimitNumberFactory.GetLimtitNumber(conn, numberSql);
        if(list!=null&&list.size()>0){
            page.setPageAll(number);
            list.get(list.size()-1).setPage(page);
        }
        return list;
    }
    //判断机房实时数据中该机房有没有连接到服务器
    public int judgeSatationInState(int dev_id) {
        String sql=" SELECT count(num) as nums from db_ram_db.tb_fbs9100_state where dev_id=? LIMIT 1 ";
        List list=DAOHelper.executeQuery(sql, DBUtil.getConn(), new Object[]{dev_id}, 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 flag=0;//返回的标识符
        if(list!=null&&list.size()>0){
            int nums=(Integer) list.get(list.size()-1);
            if(nums>0){
                flag=1;
            }else{
                flag=0;
            }
        }
        return flag;
    }
    //实时监测界面根据dev_alarmstate状态判断接触器状态
    public List serchContactorState(Object obj) {
        Fbs9100_state fs=(Fbs9100_state) obj;
        String sql="select dev_id,dev_alarmstate,dev_workstate,record_datetime,dev_temp,dev_res_test_state,dev_testtype,dev_testgroupnum,dev_conresist,dev_concurr,dev_condvoldp,dev_condcurr,dev_61850alarms,dev_last_captest_stop_type  from db_ram_db.tb_fbs9100_state where dev_id=? limit 1";
        List list=DAOHelper.executeQuery(sql, DBUtil.getConn(), new Object[]{fs.getDev_id()},new CallBack() {
            
            public List getResults(ResultSet rs) {
                List list=new ArrayList();
                try {
                    while(rs.next()){
                        Fbs9100_state fstate=new Fbs9100_state();
                        int dev_alarmstate=rs.getInt("dev_alarmstate");
                        String ContactorState="开关闭合";
                        if(dev_alarmstate==1 ||
                           dev_alarmstate==2 ||
                           dev_alarmstate==3 ||
                           dev_alarmstate==4 ||
                           dev_alarmstate==6 ){
                            ContactorState="开关断开";
                        }else{
                            ContactorState="开关闭合";
                        }
                        fstate.setRecord_datetime(rs.getString("record_datetime"));
                        fstate.setDev_testgroupnum(rs.getInt("dev_testgroupnum"));            //被测电池组号
                        fstate.setDev_alarmstate(rs.getInt("dev_alarmstate"));
                        fstate.setDev_res_test_state(rs.getInt("dev_res_test_state"));
                        fstate.setDev_testtype(rs.getInt("dev_testtype"));
                        fstate.setNote(ContactorState);
                        fstate.setDev_workstate(rs.getInt("dev_workstate"));
                        fstate.setDev_id(rs.getInt("dev_id"));
                        fstate.setDev_conresist(rs.getFloat("dev_conresist"));
                        fstate.setDev_concurr(rs.getFloat("dev_concurr"));
                        fstate.setDev_condcurr(rs.getFloat("dev_condcurr"));
                        fstate.setDev_condvoldp(rs.getFloat("dev_condvoldp"));
                        fstate.setDev_61850alarms(rs.getString("dev_61850alarms"));
                        fstate.setDev_last_captest_stop_type(rs.getInt("dev_last_captest_stop_type"));
                        fstate.setDev_temp(rs.getFloat("dev_temp"));
                        fstate.setNote(DAOHelper.sdf.format(new Date()));
                        list.add(fstate);
                    }
                } catch (SQLException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                return list;
            }
        });
        return list;
    }
    //放电测试界面根据设备id查询网络拓扑图    
    public List serchByInfo(Object obj) {
        BattInf binf=(BattInf) obj;
        String sql="select fbs_rt.BattGroupId,fbs_rt.group_curr,fbs_rt.group_vol,fbs_rt.online_vol,fbs_rt.batt_state,fbs_rt.batt_test_type" +
                ",dev_id,dev_workstate,dev_alarmstate,dev_temp,dev_res_test_state,dev_testgroupnum,dev_conresist,dev_concurr,dev_condvoldp,dev_condcurr,dev_61850alarms,dev_last_captest_stop_type  " +
                "from  db_ram_db.tb_fbs9100_state," +
                "(select distinct db_ram_db.tb_batt_rtstate.BattGroupId,group_curr,group_vol,online_vol,batt_state,batt_test_type,db_battinf.tb_battinf.FBSDeviceId from db_ram_db.tb_batt_rtstate,db_battinf.tb_battinf " +
                "where  db_battinf.tb_battinf.BattGroupId=db_ram_db.tb_batt_rtstate.BattGroupId " +
                "and db_ram_db.tb_batt_rtstate.BattGroupId=?" +
                ") as fbs_rt " +
                "where db_ram_db.tb_fbs9100_state.dev_id=fbs_rt.FBSDeviceId ";
        List list=DAOHelper.executeQuery(sql, DBUtil.getConn(),new Object[]{binf.getBattGroupId()}, new CallBack() {
            
            public List getResults(ResultSet rs) {
                List list=new ArrayList();
                try {
                    while(rs.next()){
                        Fbs9100_state fstate=new Fbs9100_state();
                        int dev_alarmstate=rs.getInt("dev_alarmstate");
                        String ContactorState="开关闭合";
                        if(dev_alarmstate==1 ||
                           dev_alarmstate==2 ||
                           dev_alarmstate==3 ||
                           dev_alarmstate==4 ||
                           dev_alarmstate==6 ){
                            ContactorState="开关断开";
                        }else{
                            ContactorState="开关闭合";
                        }
                        fstate.setDev_testgroupnum(rs.getInt("dev_testgroupnum"));            //被测电池组号
                        fstate.setDev_alarmstate(rs.getInt("dev_alarmstate"));
                        fstate.setNote(ContactorState);
                        fstate.setDev_workstate(rs.getInt("dev_workstate"));
                        fstate.setDev_res_test_state(rs.getInt("dev_res_test_state"));
                        fstate.setDev_id(rs.getInt("dev_id"));
                        
                        fstate.setDev_eachgroup_battsum(rs.getInt("batt_state"));//电池组状态
                        fstate.setDev_testtype(rs.getInt("batt_test_type"));
                        fstate.setDev_captest_groupvol(rs.getFloat("group_vol"));
                        fstate.setDev_captest_curr(rs.getFloat("group_curr"));
                        fstate.setDev_captest_onlinevol(rs.getFloat("online_vol"));
                        fstate.setNum(rs.getInt("BattGroupId"));
                        fstate.setDev_conresist(rs.getFloat("dev_conresist"));
                        fstate.setDev_concurr(rs.getFloat("dev_concurr"));
                        fstate.setDev_condcurr(rs.getFloat("dev_condcurr"));
                        fstate.setDev_condvoldp(rs.getFloat("dev_condvoldp"));
                        fstate.setDev_61850alarms(rs.getString("dev_61850alarms"));
                        fstate.setDev_last_captest_stop_type(rs.getInt("dev_last_captest_stop_type"));
                        fstate.setDev_temp(rs.getFloat("dev_temp"));
                        list.add(fstate);
                    }
                } catch (SQLException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                return list;
            }
        });
        return list;
    }
    //实时界面左侧导航实时查询61850设备是否存在4种告警和设备的工作状态
    public List serchBy61850Alarms(){
        String sql="select dev_id,dev_61850alarms,dev_workstate  from db_ram_db.tb_fbs9100_state where dev_id like '%61850%' ";
        List list=DAOHelper.executeQuery(sql, DBUtil.getConn(), null, new CallBack() {
            
            public List getResults(ResultSet rs) {
                List list=new ArrayList();
                try {
                    while(rs.next()){
                        Fbs9100_state fstate=new Fbs9100_state();
                        fstate.setDev_id(rs.getInt("dev_id"));
                        fstate.setDev_workstate(rs.getInt("dev_workstate"));
                        fstate.setDev_61850alarms(rs.getString("dev_61850alarms"));
                        list.add(fstate);
                    }
                } catch (SQLException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                return list;
            }
        });
        return list;
        
    }
    //FBS9600设备内阻测试显示全部9600设备的信息
    public List searchByUid(Object obj) {
        User_inf uinf=(User_inf) obj;
        String sql="";
        String baseSql="select  distinct tb_Fbs9100_state.num,dev_ip,dev_id,op_cmd,dev_workstate,dev_alarmstate,dev_commcount,dev_errcommcount, " +
                " db_battinf.tb_battinf.StationName,db_battinf.tb_battinf.FbsDeviceName " +
                " from db_ram_db.tb_Fbs9100_state  " +
                " left outer join db_battinf.tb_battinf ON tb_Fbs9100_state.dev_id=db_battinf.tb_battinf.FBSDeviceId  " +
                " where  tb_Fbs9100_state.dev_id in(select distinct db_battinf.tb_battinf.FBSDeviceId " +
                " 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=? ) ";
        String F9600sql=" and tb_Fbs9100_state.dev_id like '%96%'";//支持9600设备
        sql=baseSql+F9600sql;    
       // System.out.println(sql);
        List list=DAOHelper.executeQuery(sql, DBUtil.getConn(), new Object[]{uinf.getUId()}, new CallBack() {
            
            public List getResults(ResultSet rs) {
                List list=new ArrayList();
                try {
                    while(rs.next()){
                        Fbs9100_state fstate=new Fbs9100_state();
                        fstate.setNum(rs.getInt("num"));
                        fstate.setDev_ip(rs.getString("dev_ip"));
                        fstate.setDev_id(rs.getInt("dev_id"));
                        fstate.setOp_cmd(rs.getInt("op_cmd"));
                        fstate.setDev_workstate(rs.getInt("dev_workstate"));
                        fstate.setDev_alarmstate(rs.getInt("dev_alarmstate"));
                        fstate.setDev_commcount(rs.getInt("dev_commcount"));
                        fstate.setDev_errcommcount(rs.getInt("dev_errcommcount"));
                        
                        fstate.setStationName(rs.getString("stationName"));
                        fstate.setDeviceName("FBS9600");
                        list.add(fstate);
                    }
                } catch (SQLException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                return list;
            }
        });
        return list;
    }
    //查询61850设备的6种工作状态
    public List searchDevWorkstate(Object obj){
        Fbs9100_state fs=(Fbs9100_state) obj;
        String sql="select dev_id,dev_alarmstate,dev_workstate,dev_temp,dev_res_test_state,dev_testtype,dev_testgroupnum" +
                   ",dev_captest_onlinevol,dev_captest_groupvol,dev_captest_curr,dev_captest_cap,dev_captest_timelong" +
                   ",dev_conresist,dev_concurr,dev_condvoldp,dev_condcurr,dev_61850alarms,dev_last_captest_stop_type  " +
                   ",db_battinf.tb_battinf.StationName,db_battinf.tb_battinf.FbsDeviceName " +  
                   " ,db_ram_db.tb_batt_rtstate.batt_test_tlong   " +
                   " from db_ram_db.tb_fbs9100_state,db_battinf.tb_battinf,db_ram_db.tb_batt_rtstate " +
                   " where  dev_id like '%6185%'" +
                   " and db_battinf.tb_battinf.fbsdeviceId=db_ram_db.tb_fbs9100_state.dev_id "+
                   " and db_battinf.tb_battinf.battgroupid=db_ram_db.tb_batt_rtstate.battgroupid " ;
        //设备条件的筛选
        String devSqlT=" and dev_id!=? ";
        String devSqlF=" and dev_id=?  ";
        if(fs.getDev_id()==0){
            sql+=devSqlT;
        }else{
            sql+=devSqlF;
        }
        //判断是否为管理的机房
        String stationSql=" and db_battinf.tb_battinf.fbsdeviceId in(select distinct db_battinf.tb_battinf.fbsdeviceId " +
                " 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=? ) ";
        sql+=stationSql;
        
        //6种设备状态查询
        String workSqlT=" and dev_workstate!=? ";
        String workSqlF=" and dev_workstate=? ";
        if(fs.getDev_workstate()==100){
            sql+=workSqlT;
        }else{
            sql+=workSqlF;
        }
        //System.out.println(sql);
        List list=DAOHelper.executeQuery(sql, DBUtil.getConn(), new Object[]{fs.getDev_id(),fs.getNum(),fs.getDev_workstate()}, new CallBack() {
            
            public List getResults(ResultSet rs) {
                List list=new ArrayList();
                try {
                    while(rs.next()){
                        Fbs9100_state fstate=new Fbs9100_state();
                        int dev_alarmstate=rs.getInt("dev_alarmstate");
                        String ContactorState="开关闭合";
                        if(dev_alarmstate==1 ||
                           dev_alarmstate==2 ||
                           dev_alarmstate==3 ||
                           dev_alarmstate==4 ||
                           dev_alarmstate==6 ){
                            ContactorState="开关断开";
                        }else{
                            ContactorState="开关闭合";
                        }
                        fstate.setDev_testgroupnum(rs.getInt("dev_testgroupnum"));            //被测电池组号
                        fstate.setDev_alarmstate(rs.getInt("dev_alarmstate"));
                        fstate.setDev_res_test_state(rs.getInt("dev_res_test_state"));
                        fstate.setDev_testtype(rs.getInt("dev_testtype"));
                        fstate.setNote(ContactorState);
                        fstate.setDev_workstate(rs.getInt("dev_workstate"));
                        fstate.setDev_id(rs.getInt("dev_id"));
                        
                        fstate.setDev_captest_onlinevol(rs.getFloat("dev_captest_onlinevol"));
                        fstate.setDev_captest_groupvol(rs.getFloat("dev_captest_groupvol"));
                        fstate.setDev_captest_curr(rs.getFloat("dev_captest_curr"));
                        fstate.setDev_captest_cap(rs.getFloat("dev_captest_cap"));
                        fstate.setDev_captest_timelong(rs.getInt("dev_captest_timelong"));
                        
                        fstate.setDev_conresist(rs.getFloat("dev_conresist"));
                        fstate.setDev_concurr(rs.getFloat("dev_concurr"));
                        fstate.setDev_condcurr(rs.getFloat("dev_condcurr"));
                        fstate.setDev_condvoldp(rs.getFloat("dev_condvoldp"));
                        fstate.setDev_61850alarms(rs.getString("dev_61850alarms"));
                        fstate.setDev_last_captest_stop_type(rs.getInt("dev_last_captest_stop_type"));
                        fstate.setDev_temp(rs.getFloat("dev_temp"));
                        fstate.setStationName(rs.getString("stationName"));
                        fstate.setDeviceName(rs.getString("FbsDeviceName"));
                        /*fstate.setOnline_vols(((Float)rs.getFloat("online_vol")).toString());
                        fstate.setGroup_vols(((Float)rs.getFloat("group_vol")).toString());
                        fstate.setGroup_currs(((Float)rs.getFloat("group_curr")).toString());*/
                        fstate.setNum(rs.getInt("batt_test_tlong"));
                        list.add(fstate);
                    }
                } catch (SQLException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                return list;
            }
        });
        return list;
    }
    
    //实时查询61850设备的设备状态
    public String seachDevNow(Object obj){
        BattInf binf=(BattInf) obj;
        String sql="select dev_id,dev_workstate,dev_61850alarms  " +
                   " from db_ram_db.tb_fbs9100_state " +
                   " where  dev_id like '%6185%' " +
                   " and dev_id=? limit 1";
        List list=DAOHelper.executeQuery(sql, DBUtil.getConn(), new Object[]{binf.getFBSDeviceId()}, new CallBack() {
            
            public List getResults(ResultSet rs) {
                List list=new ArrayList();
                try {
                    while(rs.next()){
                        Fbs9100_state fbs=new Fbs9100_state();
                        fbs.setDev_id(rs.getInt("dev_id"));
                        fbs.setDev_workstate(rs.getInt("dev_workstate"));
                        fbs.setDev_61850alarms(rs.getString("dev_61850alarms"));
                        list.add(fbs);
                    }
                } catch (SQLException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                return list;
            }
        });
        String state="item-online_charge";
        if(list!=null &&list.size()>0){
            Fbs9100_state fbs=(Fbs9100_state) list.get(list.size()-1);
            if(fbs.getDev_61850alarms().contains("true")){
                state="item-dev_alarm";
            }else{
                switch (fbs.getDev_workstate()) {
                case 0:
                    state="item-online_charge";
                    break;
                case 1:
                    state="item-pre_charge";
                    break;
                case 2:
                    state="item-nuclear_cap";
                    break;
                case 3:
                    state="item-nuclear_cap";
                    break;
                default:
                    break;
                }
            }
            
        }
        return state;
    }
    //导航上实时查询61850设备的处于核容测试的数据
    public List seach6185Nuclear_cap(Object obj){
        User_inf uinf=(User_inf) obj;
        String sql="select dev_id,dev_alarmstate,dev_workstate,dev_temp,dev_res_test_state,dev_testtype,dev_testgroupnum " +
                   " ,dev_captest_onlinevol,dev_captest_groupvol,dev_captest_curr,dev_captest_cap,dev_captest_timelong" +
                   " ,dev_conresist,dev_concurr,dev_condvoldp,dev_condcurr,dev_61850alarms,dev_last_captest_stop_type  " +
                   " ,db_battinf.tb_battinf.StationName,db_battinf.tb_battinf.FbsDeviceName   " +
                   " ,db_ram_db.tb_batt_rtstate.batt_test_tlong   " +
                   " from db_ram_db.tb_fbs9100_state,db_battinf.tb_battinf,db_ram_db.tb_batt_rtstate  " +
                   " where  dev_id like '%6185%' and  dev_workstate="+FBS9100_ComBase.DEV_NUCLEAR_CAP+"  "+
                   " and db_battinf.tb_battinf.fbsdeviceId=db_ram_db.tb_fbs9100_state.dev_id  " +
                   " and db_battinf.tb_battinf.battgroupid=db_ram_db.tb_batt_rtstate.battgroupid " +
                   " and db_battinf.tb_battinf.fbsdeviceId in(select distinct db_battinf.tb_battinf.fbsdeviceId  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=? )  " +
                   " " ;
        List list=DAOHelper.executeQuery(sql, DBUtil.getConn(), new Object[]{uinf.getUId()}, new CallBack() {
            
            public List getResults(ResultSet rs) {
                List list=new ArrayList();
                try {
                    while(rs.next()){
                        Fbs9100_state fstate=new Fbs9100_state();
                        int dev_alarmstate=rs.getInt("dev_alarmstate");
                        String ContactorState="开关闭合";
                        if(dev_alarmstate==1 ||
                           dev_alarmstate==2 ||
                           dev_alarmstate==3 ||
                           dev_alarmstate==4 ||
                           dev_alarmstate==6 ){
                            ContactorState="开关断开";
                        }else{
                            ContactorState="开关闭合";
                        }
                        fstate.setDev_testgroupnum(rs.getInt("dev_testgroupnum"));            //被测电池组号
                        fstate.setDev_alarmstate(rs.getInt("dev_alarmstate"));
                        fstate.setDev_res_test_state(rs.getInt("dev_res_test_state"));
                        fstate.setDev_testtype(rs.getInt("dev_testtype"));
                        fstate.setNote(ContactorState);
                        fstate.setDev_workstate(rs.getInt("dev_workstate"));
                        fstate.setDev_id(rs.getInt("dev_id"));
                        
                        fstate.setDev_captest_onlinevol(rs.getFloat("dev_captest_onlinevol"));
                        fstate.setDev_captest_groupvol(rs.getFloat("dev_captest_groupvol"));
                        fstate.setDev_captest_curr(rs.getFloat("dev_captest_curr"));
                        fstate.setDev_captest_cap(rs.getFloat("dev_captest_cap"));
                        fstate.setDev_captest_timelong(rs.getInt("dev_captest_timelong"));
                        
                        fstate.setDev_conresist(rs.getFloat("dev_conresist"));
                        fstate.setDev_concurr(rs.getFloat("dev_concurr"));
                        fstate.setDev_condcurr(rs.getFloat("dev_condcurr"));
                        fstate.setDev_condvoldp(rs.getFloat("dev_condvoldp"));
                        fstate.setDev_61850alarms(rs.getString("dev_61850alarms"));
                        fstate.setDev_last_captest_stop_type(rs.getInt("dev_last_captest_stop_type"));
                        fstate.setDev_temp(rs.getFloat("dev_temp"));
                        fstate.setStationName(rs.getString("stationName"));
                        fstate.setDeviceName(rs.getString("FbsDeviceName"));
                        /*fstate.setOnline_vols(((Float)rs.getFloat("online_vol")).toString());
                        fstate.setGroup_vols(((Float)rs.getFloat("group_vol")).toString());
                        fstate.setGroup_currs(((Float)rs.getFloat("group_curr")).toString());*/
                        fstate.setNum(rs.getInt("batt_test_tlong"));
                        list.add(fstate);
                    }
                } catch (SQLException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                return list;
            }
        });
        
        return list;
    }
    //11.1FBS9100设备通信状态查询<-------跨域----------->
    public List serchByCondition_ky() {
        String sql="";
        String baseSql="select  distinct tb_fbs9100_state.num,tb_fbs9100_state.dev_ip,tb_fbs9100_state.dev_version,record_datetime,tb_fbs9100_state.dev_id,op_cmd,dev_datetime,dev_testtype,dev_testgroupnum," +
                "dev_workstate,dev_alarmstate,dev_res_test_state,dev_onlinevollow,dev_eachgroup_battsum,dev_captest_onlinevol,dev_captest_groupvol,dev_captest_curr," +
                "dev_captest_cap,dev_captest_timelong,dev_restest_moncount,dev_restest_monindex,dev_commcount,dev_errcommcount,db_ram_db.tb_fbs9100_state.dev_61850alarms,dev_last_captest_stop_type, " +
                "db_battinf.tb_battinf.StationName,db_battinf.tb_battinf.FbsDeviceName," +
                "COUNT(DISTINCT db_battinf.tb_battinf.BattGroupId) as cnt," +
                "group_CONCAT(db_ram_db.tb_batt_rtstate.online_vol ORDER BY db_ram_db.tb_batt_rtstate.BattGroupId separator '/') as online_vols,group_CONCAT(db_ram_db.tb_batt_rtstate.group_vol ORDER BY db_ram_db.tb_batt_rtstate.BattGroupId separator '/') as group_vols,group_CONCAT(db_ram_db.tb_batt_rtstate.group_curr ORDER BY db_ram_db.tb_batt_rtstate.BattGroupId separator '/') as group_currs  " +
                "from db_ram_db.tb_Fbs9100_state " +
                "left outer join db_battinf.tb_battinf ON tb_fbs9100_state.dev_id=db_battinf.tb_battinf.FBSDeviceId  " +
                "LEFT OUTER JOIN db_ram_db.tb_batt_rtstate ON db_battinf.tb_battinf.battgroupid=db_ram_db.tb_batt_rtstate.battgroupid ";
        //分组
        String groupSql=" GROUP BY tb_fbs9100_state.dev_id ";
        //最后结果
        sql=baseSql+groupSql;
        //System.out.println(sql);
        List<Fbs9100_state> list=DAOHelper.executeQueryLimit(sql, DBUtil.getConn(), null, new CallBack() {
            List list=new ArrayList();
            public List getResults(ResultSet rs) {
                try {
                    while(rs.next()){
                        Fbs9100_state fstate=new Fbs9100_state();
                        fstate.setNum(rs.getInt("cnt"));//关联电池组个数
                        fstate.setDev_ip(rs.getString("dev_ip"));
                        fstate.setDev_version(rs.getString("dev_version"));
                        fstate.setDev_id(rs.getInt("dev_id"));
                        fstate.setOp_cmd(rs.getInt("op_cmd"));
                        fstate.setRecord_datetime(rs.getString("record_datetime"));
                        fstate.setDev_datetime(rs.getString("dev_datetime"));
                        fstate.setDev_testtype(rs.getInt("dev_testtype"));
                        fstate.setDev_testgroupnum(rs.getInt("dev_testgroupnum"));
                        fstate.setDev_workstate(rs.getInt("dev_workstate"));
                        fstate.setDev_alarmstate(rs.getInt("dev_alarmstate"));
                        fstate.setDev_res_test_state(rs.getInt("dev_res_test_state"));
                        fstate.setDev_onlinevollow(rs.getInt("dev_onlinevollow"));
                        fstate.setDev_eachgroup_battsum(rs.getInt("dev_eachgroup_battsum"));
                        fstate.setDev_captest_onlinevol(rs.getFloat("dev_captest_onlinevol"));
                        fstate.setDev_captest_groupvol(rs.getFloat("dev_captest_groupvol"));
                        fstate.setDev_captest_curr(rs.getFloat("dev_captest_curr"));
                        fstate.setDev_captest_cap(rs.getFloat("dev_captest_cap"));
                        fstate.setDev_captest_timelong(rs.getInt("dev_captest_timelong"));
                        fstate.setDev_restest_moncount(rs.getInt("dev_restest_moncount"));
                        fstate.setDev_restest_monindex(rs.getInt("dev_restest_monindex"));
                        fstate.setDev_commcount(rs.getInt("dev_commcount"));
                        fstate.setDev_errcommcount(rs.getInt("dev_errcommcount"));
                        
                        fstate.setStationName(rs.getString("stationName"));
                        fstate.setDeviceName(rs.getString("FbsDeviceName"));
                        fstate.setOnline_vols(rs.getString("online_vols"));
                        fstate.setGroup_vols(rs.getString("group_vols"));
                        fstate.setGroup_currs(rs.getString("group_currs"));
                        fstate.setDev_61850alarms(rs.getString("dev_61850alarms"));
                        fstate.setDev_last_captest_stop_type(rs.getInt("dev_last_captest_stop_type"));
                        //System.out.println(fstate);
                        list.add(fstate);
                    }
                } catch (SQLException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                return list;
            }
        });
        return list;
    }
 
    public static void main(String[] args) {
        Fbs9100_stateImpl fi=new Fbs9100_stateImpl();
        /*List<Fbs9100_state> list=fi.searchAll();
        System.out.println(list.size());
        for(Fbs9100_state f:list){
            System.out.println(f);
        }*/
        Fbs9100_state fs=new Fbs9100_state();
        fs.setNum(1002);
        fs.setDev_id(0);
        fs.setDev_workstate(100);
        fs.setDev_errcommcount(2);
        Page p=new Page();
        p.setPageSize(20);
        p.setPageCurr(1);
        fs.setPage(p);
        /*List<Fbs9100_state> list=fi.serchByCondition(fs);
        System.out.println(list.size());
        for(Fbs9100_state f:list){
            System.out.println(f);
        }*/
        /*BattInf binf=new BattInf();
        binf.setBattGroupId(1005069);
        List list=fi.serchByInfo(binf);
        System.out.println(list);*/
        User_inf uinf=new User_inf();
        uinf.setUId(1002);
       //List<Fbs9100_state> list=fi.searchByUid(uinf);
        List<Fbs9100_state> list=fi.searchDevWorkstate(fs);
       // List<Fbs9100_state> list=fi.seach6185Nuclear_cap(uinf);
        System.out.println(list.size());
        for(Fbs9100_state f:list){
            System.out.println(f);
        }
    }
 
}