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
850
851
852
853
854
855
856
857
package com.fgkj.services;
 
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
 
import com.fgkj.actions.ActionUtil;
import com.fgkj.dao.BaseDAO;
import com.fgkj.dao.BaseDAOFactory;
import com.fgkj.dao.BattTestData;
import com.fgkj.dao.BattinfGroupFactory;
import com.fgkj.dao.CallBack;
import com.fgkj.dao.DAOHelper;
import com.fgkj.dao.ProcessServerDao;
import com.fgkj.dao.impl.App_SysImpl;
import com.fgkj.dao.impl.BattInfImpl;
import com.fgkj.dao.impl.Process_surveyImpl;
import com.fgkj.dao.impl.ram.Fbs9100_setparamImpl;
import com.fgkj.db.DBUtil;
import com.fgkj.dto.App_Sys;
import com.fgkj.dto.BattInf;
import com.fgkj.dto.Batt_Maint_Dealarm;
import com.fgkj.dto.Page;
import com.fgkj.dto.Process_survey;
import com.fgkj.dto.ServiceModel;
 
public class BattInfServices {
    private ServiceModel model;
    private BaseDAO dao;
 
    public BattInfServices() {
        this.model = new ServiceModel();
        this.dao = BaseDAOFactory.getBaseDAO(BaseDAO.BATTINF);
    }
    //添加新的电池组
    public ServiceModel add(Object obj) {
        Boolean bl=dao.add(obj);
        if(bl){
            /*//将主程序的服务设为重启
            Process_survey process=new Process_survey();
            process.setProcessName(ProcessServerDao.BMS_FBSDEV);
            Boolean b=(new Process_surveyImpl()).update(process);*/
            /*App_Sys as=new App_Sys();
            as.setAppServer_Reinit_BattGroupData_EN(BattTestData.AppServer_Reinit_BattGroupData_EN);
            Boolean b=(new App_SysImpl()).update(as);*/
            BattTestData.run_cmd();
            model.setCode(1);
            model.setMsg("添加成功!");
        }
        else{
            model.setCode(0);
            model.setMsg("添加失败!");
        }
        return model;
        
    }
    //修改电池组信息
    public ServiceModel update(Object obj) {
        Boolean bl=dao.update(obj);
        if(bl){
            /*//将主程序的服务设为重启
            Process_survey process=new Process_survey();
            process.setProcessName(ProcessServerDao.BMS_FBSDEV);
            Boolean b=(new Process_surveyImpl()).update(process);*/
            /*App_Sys as=new App_Sys();
            as.setAppServer_Reinit_BattGroupData_EN(BattTestData.AppServer_Reinit_BattGroupData_EN);
            Boolean b=(new App_SysImpl()).update(as);*/
            BattTestData.run_cmd();
            model.setCode(1);
            model.setMsg("修改成功!");
        }
        else{
            model.setCode(0);
            model.setMsg("修改失败!");
        }
        return model;    
    }
    //修改电池信息配置(ip地址,掩码和网关)
    public ServiceModel updateIp(Object obj) {
        BattInf binf=(BattInf) obj;
        Connection conn=DBUtil.getConn();
        PreparedStatement ps=null;
        boolean b=((BattInfImpl)dao).updateIp(obj);
        if(b){ 
            boolean bl=(new Fbs9100_setparamImpl()).sendCmdToFBS9100Dev(binf.getNum(),0, binf.getFBSDeviceId());
            if(bl){
                //将6185的服务设为重启
                Process_survey process=new Process_survey();
                process.setProcessName(ProcessServerDao.BMS_FBS61850_BATT);
                Boolean bt=(new Process_surveyImpl()).update(process);
                model.setCode(1);
                model.setMsg("修改成功!");
            }else{
                System.out.println(bl);
                binf.setFbsDeviceIp(binf.getFbsDeviceIp_old());
                binf.setFbsDeviceIp_WG(binf.getFbsDeviceIp_WG_old());
                binf.setFbsDeviceIp_YM(binf.getFbsDeviceIp_YM_old());
                ((BattInfImpl)dao).updateIp(binf);
                model.setCode(0);
                model.setMsg("修改61850设备IP信息失败,请检查网络!");
            }
        }else{
            model.setCode(0);
            model.setMsg("修改失败!");
        }
        //System.out.println(model);
        return model;    
    }
    //删除电池组
    public ServiceModel delete(Object obj) {
        Boolean bl=dao.del(obj);
        if(bl){
            /*//将主程序的服务设为重启
            Process_survey process=new Process_survey();
            process.setProcessName(ProcessServerDao.BMS_FBSDEV);
            Boolean b=(new Process_surveyImpl()).update(process);*/
            /*App_Sys as=new App_Sys();
            as.setAppServer_Reinit_BattGroupData_EN(BattTestData.AppServer_Reinit_BattGroupData_EN);
            Boolean b=(new App_SysImpl()).update(as);*/
            BattTestData.run_cmd();
            model.setCode(1);
            model.setMsg("删除成功!");
        }
        else{
            model.setCode(0);
            model.setMsg("删除失败!");
        }
        return model;    
    }
     //根据维护区和机房名称查询电池组信息
    public ServiceModel searchInform(Object obj) {
        List<BattInf> list=((BattInfImpl)dao).searchInform(obj);
        if (list != null && list.size() > 0) {
            model.setCode(1);
            model.setData(list);
            model.setMsg("查询成功!");
        }
        else{
            model.setCode(0);
            model.setMsg("查询失败!");
        }
        return model;
    }
    
    public ServiceModel searchAll() {
        List list = dao.searchAll();
        /*for (int i = 0; i < 100; i++) {
            System.out.println(list.get(i));
        }
        System.out.println("查询结束。。。");*/
        if (list != null && list.size() > 0) {
            model.setCode(1);
            model.setData(list);
        }
        return model;
    }
    public ServiceModel serchByCondition(Object obj) {
        BattInf bif=(BattInf) obj;
        List<BattInf> list=dao.serchByCondition(bif);
        model=new ServiceModel();
        if (list != null && list.size() > 0) {
            model.setCode(1);
            model.setData(list);
            model.setSum(list.size());
        }
        return model;
    }
    //查询出当前存在内存中最大的设备的id(很重要**********)
    public ServiceModel searchMaxdevId_binf(){
        int id=((BattInfImpl)dao).searchMaxdevId_binf();
        if(id!=0){
            model.setCode(1);
            model.setData(id);
        }else{
            model.setCode(0);
            model.setData(910000001);
        }
        return model;
    }
    
    //查询电池组左侧导航菜单(实时监测,历史数据查询)
    public ServiceModel findMenu() {
        BattInfImpl dtdao=(BattInfImpl)dao;
        List<List> list = dtdao.findMenu();
        model.setCode(1);
        model.setData(list);
        return model;
    }
    public ServiceModel findByBattGroupId(Object obj) {
        List list=((BattInfImpl)dao).serchByBattgroupId(obj);
        if (list != null && list.size() > 0) {
            model.setCode(1);
            model.setData(list);
        }
        return model;
    }
    //----------根据StationName1(维护区) 查不重复BattGroupName(蓄电池组)
    public ServiceModel serchByStationName1(Object obj) {
        List list=((BattInfImpl)dao).serchByStationName1(obj);
        if (list != null && list.size() > 0) {
            model.setCode(1);
            model.setData(list);
            model.setSum(list.size());
        }
        //System.out.println(model);
        return model;
    }
    
    // ----------根据StationName1(维护区) 查不重复的StationName(站点)
    public ServiceModel serchByStationName(Object obj) {
        List list=((BattInfImpl)dao).serchByStationName(obj);
        if (list != null && list.size() > 0) {
            model.setCode(1);
            model.setData(list);
            model.setSum(list.size());
        }
        return model;
    }
    
    // ----------根据StationName1(维护区) 查不重复的StationName(站点)不包含91000000一期设备
    public ServiceModel serchByStationNameNot91(Object obj) {
        List list=((BattInfImpl)dao).serchByStationNameNot91(obj);
        if (list != null && list.size() > 0) {
            model.setCode(1);
            model.setData(list);
            model.setSum(list.size());
        }
        return model;
    }
    //-----------查询所有的省份
    public ServiceModel serchAllStationName1(Object obj) {
        List list=((BattInfImpl)dao).serchAllStationName1(obj);
        if (list != null && list.size() > 0) {
            model.setCode(1);
            model.setData(list);
            model.setMsg("查询成功!");
        }else{
            model.setCode(0);
            model.setMsg("查询失败!");
        }
        return model;
    }
    // ----------查询所有的市
    public ServiceModel serchAllStationName2(Object obj) {
        List list=((BattInfImpl)dao).serchAllStationName2(obj);
        if (list != null && list.size() > 0) {
            model.setCode(1);
            model.setData(list);
            model.setMsg("查询成功!");
        }else{
            model.setCode(0);
            model.setMsg("查询失败!");
        }
        return model;
    }
    // ----------查询所有的区县
    public ServiceModel serchAllStationName5(Object obj) {
        List list=((BattInfImpl)dao).serchAllStationName5(obj);
        if (list != null && list.size() > 0) {
            model.setCode(1);
            model.setData(list);
            model.setMsg("查询成功!");
        }else{
            model.setCode(0);
            model.setMsg("查询失败!");
        }
        return model;
    }
    //-----------查询所有的机房
    public ServiceModel serchAllStationName(Object obj) {
        List list=((BattInfImpl)dao).serchAllStationName(obj);
        if (list != null && list.size() > 0) {
            model.setCode(1);
            model.setData(list);
            model.setMsg("查询成功!");
        }else{
            model.setCode(0);
            model.setMsg("查询失败!");
        }
        return model;
    }
    
    //--------查询电池组信息
    public ServiceModel serchAllBattinf(Object obj) {
        List list=((BattInfImpl)dao).serchAllBattinf(obj);
        if (list != null && list.size() > 0) {
            model.setCode(1);
            model.setData(list);
            model.setMsg("查询成功!");
        }else{
            model.setCode(0);
            model.setMsg("查询失败!");
        }
        return model;
    }
    
    
    
    //查电池品牌
    public ServiceModel serchByBattProducer() {
        List list=((BattInfImpl)dao).serchByBattProducer();
        if (list != null && list.size() > 0) {
            model.setCode(1);
            model.setData(list);
            model.setSum(list.size());
        }
        //System.out.println(model);
        return model;
    }
    //查单体电压
    public ServiceModel serchByMonVolStd() {
        List list=((BattInfImpl)dao).serchByMonVolStd();
        if (list != null && list.size() > 0) {
            model.setCode(1);
            model.setData(list);
            model.setSum(list.size());
        }
        //System.out.println(model);
        return model;
    }
    //查电池容量
    public ServiceModel serchByMonCapStd() {
        List list=((BattInfImpl)dao).serchByMonCapStd();
        if (list != null && list.size() > 0) {
            model.setCode(1);
            model.setData(list);
            model.setSum(list.size());
        }
        //System.out.println(model);
        return model;
    }
    //5.3添加选取电池组或者机房或者维护区(未被应用)
    public ServiceModel serchBatt(Object obj) {
        Boolean bl=false;
        List<BattInf> list=(new BattInfImpl()).serchBatt(obj);
        if(list!=null && list.size()>0){
            model.setCode(1);
            model.setData(list);
        }else{
            model.setCode(0);
            model.setMsg("查询失败!");
        }
        return model;
    }
    
    // ----------查不重复的StationName1(维护区)
    public ServiceModel serchByStation() {
        List list=((BattInfImpl)dao).serchByStation();
        if (list != null && list.size() > 0) {
            model.setCode(1);
            model.setData(list);
            model.setSum(list.size());
        }
        return model;    
    }
    // ----------查不重复的StationName1(维护区)不包含91000000一期设备
    public ServiceModel serchByStationNot91() {
        List list=((BattInfImpl)dao).serchByStationNot91();
        if (list != null && list.size() > 0) {
            model.setCode(1);
            model.setData(list);
            model.setSum(list.size());
        }
        return model;    
    }
    //查单体编号
    public ServiceModel serchByMonNum(Object obj) {
        List list=((BattInfImpl)dao).serchByMonNum(obj);
        if (list != null && list.size() > 0) {
            model.setCode(1);
            model.setData(list);
            model.setSum(list.size());
        }else{
            model.setCode(0);
            model.setSum(0);
        }
        return model;
    }
    //根据电池id查询电池的基本信息
    public ServiceModel searchBattBybattgroupid(Object obj){
        model=new ServiceModel();
        List list=((BattInfImpl)dao).searchBattBybattgroupid(obj);
        //System.out.println(list);
        if(list!=null && list.size()>0){
            model.setCode(1);
            model.setData(list);
        }
        return model;
    }
    public ServiceModel serchByBattGroupName(Object obj) {
        List list=((BattInfImpl)dao).serchByBattGroupName(obj);
        if (list != null && list.size() > 0) {
            model.setCode(1);
            model.setData(list);
            model.setSum(list.size());
            model.setMsg("查询成功!");
        }else{
            model.setCode(0);
            model.setMsg("查询失败!");
        }
        return model;    
    }
    //6.4.7按地域和标称电压分组统计蓄电池组服役超期的数量
        /*
     * 区域层次放在stationid中
     * battgroupnum 中存放统计方式:年度统计为0 季度统计为1
     * moncount中存放统计季度:一季度为1 以此类推
     * monnum 中存放年份*/
    public ServiceModel serchBeyondTime(Object obj){
        System.out.println(1111111111);
        BattInf binf=(BattInf) obj;
        int year=binf.getMonNum();//获取年份
        int firstMonth=0;//获取起始月份
        int lastMonth=0;//获取结束月份
        String dateFirst=""; //起始时间
        String dateLast="";  //结束时间
        //做时间判断
        if(binf.getBattGroupNum()==0){
             firstMonth=0;//获取起始月份
             lastMonth=11;//获取结束月份
        }else if(binf.getBattGroupNum()==1){
             if(binf.getMonCount()==1){
                 firstMonth=0;//获取起始月份
                 lastMonth=2;//获取结束月份
             }else if(binf.getMonCount()==2){
                 firstMonth=3;//获取起始月份
                 lastMonth=5;//获取结束月份
             }else if(binf.getMonCount()==3){
                 firstMonth=6;//获取起始月份
                 lastMonth=8;//获取结束月份
             }else if(binf.getMonCount()==4){
                 firstMonth=9;//获取起始月份
                 lastMonth=11;//获取结束月份
             }
        }
        try {
            dateFirst=ActionUtil.getFirstDayOfMonth(year,firstMonth);//起始时间
            binf.setBattInUseDate(DAOHelper.sdf.parse(dateFirst));
            //System.out.println(dateFirst.substring(0,10));
            dateLast=ActionUtil.getLastDayOfMonth(year,lastMonth);//结束时间
            binf.setBattInUseDate1(DAOHelper.sdf.parse(dateLast));
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        
        //求总数
        List<BattInf> list=(new BattInfImpl()).serchByMonVolStdGroup(binf);
        List<BattInf> listB=BattinfGroupFactory.finishMonvol(list);
        List<BattInf> listL=BattinfGroupFactory.delMonvol(listB);
        //求超期服役的数量
        try {
            year=(new Date()).getYear()+1900-3;//当前时间减去年限
            //System.out.println(year);
            dateFirst=ActionUtil.getFirstDayOfMonth(year,firstMonth);//起始时间
            binf.setBattInUseDate(DAOHelper.sdf.parse(dateFirst));
            //System.out.println(binf.getBattInUseDate());
        } catch (ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        List<BattInf> listY=(new BattInfImpl()).serchBeyondTime(binf);//超期服役的电池组数
        List<BattInf> listBY=BattinfGroupFactory.finishMonvol(listY);
        List<BattInf> listLY=BattinfGroupFactory.delMonvol(listBY);
        /*for (BattInf b : listBY) {
            System.out.println("0 "+b.getBattGroupNum()+" "+
                      "2v: "+b.getBattGroupId()+" "+
                      "6v: "+b.getMonCount()+" "+
                      "12v: "+b.getMonNum());
        }*/
        int level = Integer.parseInt(binf.getStationId());
       List<BattInf> listFalse=(new BattInfImpl()).serchBylevel(level);
      /* for (BattInf b : listL) {
            System.out.println("1 "+b.getBattGroupNum()+" "+
              "2v: "+b.getBattGroupId()+" "+
              "6v: "+b.getMonCount()+" "+
              "12v: "+b.getMonNum());
        }*/
        List<BattInf> listEnd=BattinfGroupFactory.countAll(listL, listLY);
         for (BattInf b : listEnd) {
                System.out.println("2 "+b.getBattGroupNum()+" "+
                  "2v: "+b.getBattGroupId()+" 超过2v: "+b.getMonCapStd()+" "+
                  "6v: "+b.getMonCount()+"          超过6v: "+b.getMonResStd()+" "+
                  "12v: "+b.getMonNum()+"     超过12v: "+b.getMonSerStd());
            }
        if(listL!=null&&listL.size()>0){
            model.setCode(1);
            model.setData(listEnd);
            model.setMsg("查询成功!");
        }else{
            model.setCode(0);
            model.setData(listFalse);
            System.out.println(listFalse.size());
            model.setMsg("查询失败!");
        }
        return model;
    }
    //6.4.8按地域和标称电压分组统计蓄电池组的数量(蓄电池组数量统计)
        /*
         * 区域层次放在stationid中
         * battgroupnum 中存放统计方式:年度统计为0 季度统计为1
         * moncount中存放统计季度:一季度为1 以此类推
         * monnum 中存放年份*/
    public ServiceModel serchByMonVolStdGroup(Object obj){
        BattInf binf=(BattInf) obj;
        int year=binf.getMonNum();//获取年份
        int firstMonth=0;//获取起始月份
        int lastMonth=0;//获取结束月份
        String dateFirst=""; //起始时间
        String dateLast="";  //结束时间
        //做时间判断
        if(binf.getBattGroupNum()==0){
             firstMonth=0;//获取起始月份
             lastMonth=11;//获取结束月份
        }else if(binf.getBattGroupNum()==1){
             if(binf.getMonCount()==1){
                 firstMonth=0;//获取起始月份
                 lastMonth=2;//获取结束月份
             }else if(binf.getMonCount()==2){
                 firstMonth=3;//获取起始月份
                 lastMonth=5;//获取结束月份
             }else if(binf.getMonCount()==3){
                 firstMonth=6;//获取起始月份
                 lastMonth=8;//获取结束月份
             }else if(binf.getMonCount()==4){
                 firstMonth=9;//获取起始月份
                 lastMonth=11;//获取结束月份
             }
        }
        try {
            dateFirst=ActionUtil.getFirstDayOfMonth(year,firstMonth);//起始时间
            binf.setBattInUseDate(DAOHelper.sdf.parse(dateFirst));
            //System.out.println(dateFirst.substring(0,10));
            dateLast=ActionUtil.getLastDayOfMonth(year,lastMonth);//结束时间
            binf.setBattInUseDate1(DAOHelper.sdf.parse(dateLast));
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        
        
        List<BattInf> list=(new BattInfImpl()).serchByMonVolStdGroup(binf);
        List<BattInf> listB=BattinfGroupFactory.finishMonvol(list);
        List<BattInf> listL=BattinfGroupFactory.delMonvol(listB);
        //没有数据时传分组情况
        int level = Integer.parseInt(binf.getStationId());
        List<BattInf> listFalse=(new BattInfImpl()).serchBylevel(level);
//        for (BattInf b : listL) {
//            System.out.println(b.getBattGroupNum()+" "+
//              "2v: "+b.getBattGroupId()+" "+
//              "6v: "+b.getMonCount()+" "+
//              "12v: "+b.getMonNum());
//        }
        if(listL!=null&&listL.size()>0){
            model.setCode(1);
            model.setData(listL);
            model.setMsg("查询成功!");
        }else{
            model.setCode(0);
            model.setData(listFalse);
            model.setMsg("查询失败!");
        }
        return model;
    }
    //6.4.9按地域和标称电压分组统计蓄电池组品牌的数量(蓄电池供应商信息统计)
    /*
     * 区域层次放在stationid中
     * battgroupnum 中存放统计方式:年度统计为0 季度统计为1
     * moncount中存放统计季度:一季度为1 以此类推
     * monnum 中存放年份*/
    public ServiceModel serchByBattProducerGroup(Object obj){
        BattInf binf=(BattInf) obj;
        int year=binf.getMonNum();//获取年份
        int firstMonth=0;//获取起始月份
        int lastMonth=0;//获取结束月份
        String dateFirst=""; //起始时间
        String dateLast="";  //结束时间
        //做时间判断
        if(binf.getBattGroupNum()==0){
             firstMonth=0;//获取起始月份
             lastMonth=11;//获取结束月份
        }else if(binf.getBattGroupNum()==1){
             if(binf.getMonCount()==1){
                 firstMonth=0;//获取起始月份
                 lastMonth=2;//获取结束月份
             }else if(binf.getMonCount()==2){
                 firstMonth=3;//获取起始月份
                 lastMonth=5;//获取结束月份
             }else if(binf.getMonCount()==3){
                 firstMonth=6;//获取起始月份
                 lastMonth=8;//获取结束月份
             }else if(binf.getMonCount()==4){
                 firstMonth=9;//获取起始月份
                 lastMonth=11;//获取结束月份
             }
        }
        try {
            dateFirst=ActionUtil.getFirstDayOfMonth(year,firstMonth);//起始时间
            binf.setBattInUseDate(DAOHelper.sdf.parse(dateFirst));
            //System.out.println(dateFirst.substring(0,10));
            dateLast=ActionUtil.getLastDayOfMonth(year,lastMonth);//结束时间
            binf.setBattInUseDate1(DAOHelper.sdf.parse(dateLast));
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        
        
        List<BattInf> list=(new BattInfImpl()).serchByBattProducerGroup(binf);
        //没有数据时传分组情况
        int level = Integer.parseInt(binf.getStationId());
        List<BattInf> listFalse=(new BattInfImpl()).serchBylevel(level);
        
//            for (BattInf b : list) {
//                System.out.println(b.getNum()+" "+
//                                   b.getStationName1()+" "+
//                                   b.getStationName2()+" "+
//                                   b.getStationName3()+" "+
//                                   b.getStationName4()+" "+
//                                   b.getBattProducer()+" "+
//                                   b.getBattGroupNum());
//            }
        if(list!=null&&list.size()>0){
            model.setCode(1);
            model.setData(list);
            model.setMsg("查询成功!");
        }else{
            model.setCode(0);
            System.out.println(listFalse);
            model.setData(listFalse);
            model.setMsg("查询失败!");
        }
        return model;
    }
    //6.4.10按地域和标称电压分组统计蓄电池组使用时间(蓄电池投产年限统计)
    /*
     * 区域层次放在stationid中
     * battgroupnum 中存放统计方式:年度统计为0 季度统计为1
     * moncount中存放统计季度:一季度为1 以此类推
     * monnum 中存放年份*/
    public ServiceModel serchByBattInUseDateGroup(Object obj){
            BattInf binf=(BattInf) obj;
            int year=binf.getMonNum();//获取年份
            int firstMonth=0;//获取起始月份
            int lastMonth=0;//获取结束月份
            String dateFirst=""; //起始时间
            String dateLast="";  //结束时间
            //做时间判断
            if(binf.getBattGroupNum()==0){
                 firstMonth=0;//获取起始月份
                 lastMonth=11;//获取结束月份
            }else if(binf.getBattGroupNum()==1){
                 if(binf.getMonCount()==1){
                     firstMonth=0;//获取起始月份
                     lastMonth=2;//获取结束月份
                 }else if(binf.getMonCount()==2){
                     firstMonth=3;//获取起始月份
                     lastMonth=5;//获取结束月份
                 }else if(binf.getMonCount()==3){
                     firstMonth=6;//获取起始月份
                     lastMonth=8;//获取结束月份
                 }else if(binf.getMonCount()==4){
                     firstMonth=9;//获取起始月份
                     lastMonth=11;//获取结束月份
                 }
            }
            try {
                dateFirst=ActionUtil.getFirstDayOfMonth(year,firstMonth);//起始时间
                binf.setBattInUseDate(DAOHelper.sdf.parse(dateFirst));
                //System.out.println(dateFirst.substring(0,10));
                dateLast=ActionUtil.getLastDayOfMonth(year,lastMonth);//结束时间
                binf.setBattInUseDate1(DAOHelper.sdf.parse(dateLast));
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            
            
            List<BattInf> list=(new BattInfImpl()).serchByBattInUseDateGroup(binf);
            //System.out.println(list.size());
            //没有数据时传分组情况
            int level = Integer.parseInt(binf.getStationId());
            List<BattInf> listFalse=(new BattInfImpl()).serchBylevel(level);
            
//            for (BattInf b : list) {
//                System.out.println(b.getNum()+" "+
//                                   b.getStationName1()+" "+
//                                   b.getStationName2()+" "+
//                                   b.getStationName3()+" "+
//                                   b.getStationName4()+" "+
//                                   b.getBattInUseDate()+" "+
//                                   b.getBattGroupNum());
//            }
            if(list!=null&&list.size()>0){
                model.setCode(1);
                model.setData(list);
                model.setMsg("查询成功!");
            }else{
                model.setCode(0);
                model.setData(listFalse);
                model.setMsg("查询失败!");
            }
            return model;
        }
 
    //1 根据机房id查询电池组id排序最小值
    public ServiceModel serchByIdLow(Object obj){
        List list=((BattInfImpl)dao).serchByIdLow(obj);
        if (list != null && list.size() > 0) {
            model.setCode(1);
            model.setData(list);
            model.setMsg("查询成功!");
        }else{
            model.setCode(0);
            model.setData(list);
            model.setMsg("查询失败!");
        }
        return model;
    }
    
    /**
     * 根据机房id查询机房中的电池组信息
     * @param obj
     * @return
     */
    public ServiceModel searchBattByStationId(Object obj){
        ServiceModel model = new ServiceModel();
        List list = ((BattInfImpl)dao).searchBattByStationId(obj);
        if(list != null && list.size()>0){
            model.setCode(1);
            model.setData(list);
            
        }else{
            model.setCode(0);
        }
        return model;
    }
    //查询所有的机房
    public ServiceModel serchAllStation(Object obj){
        List list=((BattInfImpl)dao).serchAllStation(obj);
        if (list != null && list.size() > 0) {
            model.setCode(1);
            model.setData(list);
            model.setMsg("查询成功!");
        }else{
            model.setCode(0);
            model.setData(list);
            model.setMsg("查询失败!");
        }
        //System.out.println(model);
        return model;
    }
    //搜索机房或电池组
    public ServiceModel serchStationOrBattgroup(Object obj){
        List list=((BattInfImpl)dao).serchStationOrBattgroup(obj);
        if (list != null && list.size() > 0) {
            model.setCode(1);
            model.setData(list);
            model.setMsg("查询成功!");
        }else{
            model.setCode(0);
            model.setData(list);
            model.setMsg("查询失败!");
        }
        //System.out.println(list.size());
        return model;
    }
    //根据机房id查询机房下的电池组信息
    public ServiceModel serchBattByStation(Object obj){
        List list=((BattInfImpl)dao).serchBattByStation(obj);
        if (list != null && list.size() > 0) {
            model.setCode(1);
            model.setData(list);
            model.setMsg("查询成功!");
        }else{
            model.setCode(0);
            model.setData(list);
            model.setMsg("查询失败!");
        }
        //System.out.println(model);
        return model;
    }
    //查询所有的电池组数
    public ServiceModel serchAllBatt(Object obj){
        int nums=((BattInfImpl)dao).serchAllBatt(obj);
        model.setCode(1);
        model.setSum(nums);
        model.setMsg("查询成功!");
        //System.out.println(model);
        return model;
    }
    
    //根据维护区和机房名称查询电池组信息(电池组信息配置)<-------跨域----------->
    public ServiceModel searchInform_ky() {
        List<BattInf> list=((BattInfImpl)dao).searchInform_ky();
        if (list != null && list.size() > 0) {
            model.setCode(1);
            model.setData(list);
            model.setMsg("查询成功!");
        }
        else{
            model.setCode(0);
            model.setMsg("查询失败!");
        }
        return model;
    }
    
    public static void main(String[] args) {
        //new BattInfServices().findMenu();
        BattInf b=new BattInf();
        //b.setBattGroupId(1000005);
        b.setNum(58);
        b.setFBSDeviceId(91000001);
        b.setFbsDeviceIp("192.168.0.56");
        b.setFbsDeviceIp_YM("255.255.255.0");
        b.setFbsDeviceIp_WG("127.0.0.1");
        b.setFbsDeviceIp_old("192.168.0.56");
        b.setFbsDeviceIp_YM_old("255.255.255.0");
        b.setFbsDeviceIp_WG_old("192.168.0.1");
        b.setStationName("");
        b.setStationName1("");
        b.setStationName9("");
        b.setBattGroupName("");
        b.setStationId("42070463");
        //b.setBattGroupName1("开关电源系统");
        //b.setBattProducer("光宇");
        b.setMonCapStd(100f);
        b.setMonVolStd(12f);
        BattInfServices bs=new BattInfServices();
        //bs.serchByStation();
        //bs.serchByStationName(b);
        //bs.serchByStationName1(b);
        //bs.serchByCondition(b);
        
        //bs.searchBattBybattgroupid(b);
        //bs.serchByBattGroupName(b);
        //bs.findMenu();
        //bs.serchAllStation();
        //bs.serchStationOrBattgroup(b);
        //bs.serchBattByStation(b);
        
        Page page=new Page();
        page.setPageCurr(1);
        page.setPageSize(10);
        Batt_Maint_Dealarm bmd=new Batt_Maint_Dealarm();
        bmd.setBinf(b);
        bmd.setPage(page);
        //bs.searchInform(bmd);
        //bs.serchByBattGroupName(b);
        bs.updateIp(b);
    }
}