whycrzg
2021-02-23 351b9a53cb9ecebdf8f79db0117f540d9c42c2a4
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
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
package com.fgkj.services;
 
import ch.qos.logback.core.db.dialect.DBUtil;
import com.fgkj.db.DBUtil1;
import com.fgkj.dto.*;
import com.fgkj.mapper.*;
import com.fgkj.mapper.impl.BattInfMapper;
import com.fgkj.mapper.impl.Database_backupMapper;
import com.fgkj.mapper.impl.Process_surveyMapper;
import com.fgkj.mapper.impl.ram.Fbs9100_setparamMapper;
import com.fgkj.services.ram.Fbs9100_setparamService;
import com.fgkj.util.ActionUtil;
import com.fgkj.util.DateUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.stereotype.Service;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
import org.springframework.web.bind.annotation.RequestParam;
 
import javax.annotation.Priority;
import javax.annotation.Resource;
import java.lang.annotation.Target;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
@Service
public class BattInfServices {
 
    ServiceModel model = new ServiceModel();
 
    @Resource
    private Fbs9100_setparamService fbs9100_setparamService;
    @Resource
    private BattInfMapper mapper;
 
    @Resource
    private Fbs9100_setparamMapper fbs9100SetParamMapper;
    @Resource
    private Process_surveyMapper surveyMapper;
    @Resource
    private User_logService uservice;
    @Autowired
    DataSourceTransactionManager dataSourceTransactionManager;
    @Autowired
    TransactionDefinition transactionDefinition;
 
 
    //添加新的电池组
    public ServiceModel add(List<BattInf> list) {
        //更新数据库备份标志表的标志
        boolean flag1 = backupmapper.updateBackupEn("tb_battinf") > 0;
        TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition);
        ServiceModel model = new ServiceModel();
        boolean flag=true;
        if (list != null && list.size() > 0) {
            int battgroupid = BattinfGroupFactory.searchMaxBattgroupId();
            int stationid = BattinfGroupFactory.searchStationId();
            // int dev_id=BattinfGroupFactory.searchmaxdev_id();
//        int dev_id=BattinfGroupFactory.searchmaxdev_id(list.get(0).getFbsDeviceId());    //TODO 方法名不一致
            for (int i = 0; i < list.size(); i++) {
                BattInf binf = list.get(i);
                if(!mapper.add(binf)){
                    flag=false;
                }
                mapper.add(binf);
                {
                    String msg = "添加" + binf.getStationName() + "机房" + binf.getBattGroupId() + "电池组的信息";
                    User_log ulog = UinfDaoFactory.CreateULog(UinfDaoFactory.Increase, msg);
                    uservice.add(ulog);//将用户的操作记录下来
                }
 
            }
 
        }else{
            flag=false;
        }
        if (flag) {
            dataSourceTransactionManager.commit(transactionStatus);
            /*//将主程序的服务设为重启
            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 {
            dataSourceTransactionManager.rollback(transactionStatus);
            model.setCode(0);
            model.setMsg("添加失败!");
        }
        return model;
 
    }
 
    //修改电池组信息
    public ServiceModel update( List<BattInf> list) {
        //更新数据库备份标志表的标志
        boolean flag1 = backupmapper.updateBackupEn("tb_battinf") > 0;
        TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition);
        ServiceModel model = new ServiceModel();
        boolean flag = true;
        if (list != null && list.size() > 0) {
            for (int i = 0; i < list.size(); i++) {
                BattInf binf = list.get(i);
//                System.out.println("binf = " + binf);
                try {
                    flag = mapper.update(binf)>0;
                } catch (Exception e) {
                    e.printStackTrace();
                    dataSourceTransactionManager.rollback(transactionStatus);
                    model.setCode(0);
                    model.setMsg("修改失败!");
                    return model;
                }
                {
                    String msg = "修改" + binf.getStationName() + "机房" + binf.getBattGroupId() + "电池组的信息";
                    User_log ulog = UinfDaoFactory.CreateULog(UinfDaoFactory.Alter, msg);
                    uservice.add(ulog);//将用户的操作记录下来
                }
            }
        }else{
            flag = false;
        }
        if (flag) {
            dataSourceTransactionManager.commit(transactionStatus);
            BattTestData.run_cmd();//缺少文件
            model.setCode(1);
            model.setMsg("修改成功!");
        } else {
            dataSourceTransactionManager.rollback(transactionStatus);
            model.setCode(0);
            model.setMsg("修改失败!");
        }
        return model;
    }
 
 
    @Resource
    private Database_backupMapper backupmapper;
    //修改电池信息配置(ip地址,掩码和网关)
    public ServiceModel updateIp(BattInf binf) {
        ServiceModel model = new ServiceModel();
        //更新数据库备份标志表的标志
        boolean flag = backupmapper.updateBackupEn("tb_battinf") > 0;
        boolean b= false;
        try {
            b = mapper.updateIp(binf)>0;
        } catch (Exception e) {
            e.printStackTrace();
            model.setCode(0);
            model.setMsg("修改失败!");
            return model;
        }
        if(b){
            boolean bl = fbs9100_setparamService.sendCmdToFBS9100Dev(binf.getNum(), 0, binf.getFbsDeviceId());
            if(bl){
                //将6185的服务设为重启
                Process_survey process=new Process_survey();
                process.setProcessName(ProcessServerDao.BMS_FBS61850_BATT);
                Boolean bt=surveyMapper.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());
                mapper.updateIp(binf);
                model.setCode(0);
                model.setMsg("修改61850设备IP信息失败,请检查网络!");
            }
        }else{
            model.setCode(0);
            model.setMsg("修改失败!");
        }
        //System.out.println(model);
        return model;
    }
 
    //删除电池组
    public ServiceModel delete(List<BattInf> list) {
        //更新数据库备份标志表的标志
        boolean flag1 = backupmapper.updateBackupEn("tb_battinf") > 0;
        TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition);
        ServiceModel model = new ServiceModel();
        boolean flag = true;
        if(list!=null&&list.size()>0){
            for (int i = 0; i < list.size(); i++) {
                BattInf binf=list.get(i);
                try {
                    flag =mapper.del(binf)>0;
                } catch (Exception e) {
                    e.printStackTrace();
                    dataSourceTransactionManager.rollback(transactionStatus);
                    model.setCode(0);
                    model.setMsg("删除失败!");
                    return model;
                }
                {
                    String msg="删除"+binf.getStationName()+"机房"+binf.getBattGroupId()+"电池组的信息";
                    User_log ulog = UinfDaoFactory.CreateULog(UinfDaoFactory.Alter, msg);
                    uservice.add(ulog);//将用户的操作记录下来
                }
            }
        }
 
        if(flag){
            dataSourceTransactionManager.commit(transactionStatus);
            /*//将主程序的服务设为重启
            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{
            dataSourceTransactionManager.rollback(transactionStatus);
            model.setCode(0);
            model.setMsg("删除失败!");
        }
        return model;
    }
     //根据维护区和机房名称查询电池组信息
    public ServiceModel searchInform(Batt_Maint_Dealarm obj) {
        //更新数据库备份标志表的标志
        boolean flag1 = backupmapper.updateBackupEn("tb_battinf") > 0;
        ServiceModel model = new ServiceModel();
        PageBean pageBean = obj.getPageBean();
        PageHelper.startPage(pageBean.getPageNum(),pageBean.getPageSize(),true);
        List<BattInf> list=mapper.searchInform(obj);
        if (list != null && list.size() > 0) {
            PageInfo<BattInf> pageInfo = new PageInfo<>(list);
            model.setCode(1);
            model.setData(pageInfo);
            model.setMsg("查询成功!");
        }
        else{
            model.setCode(0);
            model.setMsg("查询失败!");
        }
        return model;
    }
 
    public ServiceModel searchAll() {
        //更新数据库备份标志表的标志
        boolean flag1 = backupmapper.updateBackupEn("tb_battinf") > 0;
        ServiceModel model = new ServiceModel();
        List<Integer> list = mapper.searchAll();
        /*for (int i = 0; i < 100; i++) {
            System.out.println(list.get(i));
        }
        System.out.println("查询结束。。。");*/
        if (list != null && list.size() > 0) {
            ArrayList<Integer> last = new ArrayList<>();
            for (int i = 0; i < list.size(); i++) {
                Integer num = list.get(i);
                if (num.equals(0)) {
                    continue;
                } else {
                    last.add(list.get(i));
                }
            }
            model.setCode(1);
            model.setData(last);
        }
        return model;
    }
    public ServiceModelOnce serchByCondition(BattInf bif) {
        ServiceModelOnce model = new ServiceModelOnce();
        List<BattInf> list = mapper.serchByCondition(bif);
        if (list != null && list.size() > 0) {
            model.setCode(1);
            model.setData(list);
            model.setSum(list.size());
        }
        return model;
    }
    //查询出当前存在内存中最大的设备的id(很重要**********)
    public ServiceModel searchMaxdevId_binf(){
        ServiceModel model = new ServiceModel();
        int id=mapper.searchMaxdevId_binf();
        if(id!=0){
            model.setCode(1);
            model.setData(id);
        }else{
            model.setCode(0);
            model.setData(910000001);
        }
        return model;
    }
 
    //查询电池组左侧导航菜单(实时监测,历史数据查询)
    public ServiceModel findMenu() {
        List<List> list = mapper.findMenu();
        model.setCode(1);
        model.setData(list);
        return model;
    }
    public ServiceModel findByBattGroupId(BattInf obj) {
        ServiceModel model = new ServiceModel();
        List list=mapper.serchByBattgroupId(obj);
        if (list != null && list.size() > 0) {
            model.setCode(1);
            model.setData(list);
        }
        return model;
    }
    //----------根据StationName1(维护区) 查不重复BattGroupName(蓄电池组)
    public ServiceModelOnce serchByStationName1(BattInf bif) {
        ServiceModelOnce model = new ServiceModelOnce();
        List list = null;
        System.out.println("bif = " + bif);
        if (bif.getStationName1() == null&&!bif.getStationName1().equals("null")) {
            list = mapper.serchByStationName1(bif);
        }else{
            list = mapper.serchByStationName1plus(bif);
        }
        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 ServiceModelOnce serchByStationName(BattInf obj) {
        ServiceModelOnce model = new ServiceModelOnce();
        List list=mapper.serchByStationName(obj);
        if (list != null && list.size() > 0) {
            model.setCode(1);
            model.setData(list);
             model.setSum(list.size());
        }
        return model;
    }
 
    // ----------根据StationName1(维护区) 查不重复的StationName(站点)不包含91000000一期设备
    public ServiceModelOnce serchByStationNameNot91(BattInf obj) {
        ServiceModelOnce model = new ServiceModelOnce();
        List list=mapper.serchByStationNameNot91(obj);
        if (list != null && list.size() > 0) {
            model.setCode(1);
            model.setData(list);
             model.setSum(list.size());
        }
        return model;
    }
    //-----------查询所有的省份
    public ServiceModel serchAllStationName1(User_inf obj) {
        ServiceModel model = new ServiceModel();
        List list=mapper.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(BattInf obj) {
        ServiceModel model = new ServiceModel();
        List list=mapper.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(BattInf obj) {
        ServiceModel model = new ServiceModel();
        List list=mapper.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(BattInf obj) {
        ServiceModel model = new ServiceModel();
        List list=mapper.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(BattInf obj) {
        ServiceModel model = new ServiceModel();
        List list=mapper.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 judgeBatt(BattInf obj){
        ServiceModel model = new ServiceModel();
        List list=mapper.judgeBattStationName(obj);
        if (list != null && list.size() > 0) {
            model.setCode(1);
            model.setMsg("该机房存在!");
        }else{
            model.setCode(0);
            model.setMsg("该机房不存在!");
        }
        return model;
    }
 
 
    //查电池品牌
    public ServiceModelOnce serchByBattProducer() {
        ServiceModelOnce model = new ServiceModelOnce();
        List list=mapper.serchByBattProducer();
        if (list != null && list.size() > 0) {
            model.setCode(1);
            model.setData(list);
             model.setSum(list.size());
        }
        return model;
    }
    //查单体电压
    public ServiceModelOnce serchByMonVolStd() {
        ServiceModelOnce model = new ServiceModelOnce();
        List list = mapper.serchByMonVolStd();
        if (list != null && list.size() > 0) {
            model.setCode(1);
            model.setData(list);
            model.setSum(list.size());
        }
        return model;
    }
    //查电池容量
    public ServiceModelOnce serchByMonCapStd() {
        ServiceModelOnce model = new ServiceModelOnce();
        List list=mapper.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(BattInf obj) {
        ServiceModel model = new ServiceModel();
        Boolean bl = false;
        List<BattInf> list = mapper.serchBatt(obj);
        if (list != null && list.size() > 0) {
            model.setCode(1);
            model.setData(list);
        } else {
            model.setCode(0);
            model.setMsg("查询失败!");
        }
        return model;
    }
 
    // ----------查不重复的StationName1(维护区)
    public ServiceModelOnce serchByStation() {
        ServiceModelOnce model = new ServiceModelOnce();
        List list=mapper.serchByStation();
        if (list != null && list.size() > 0) {
            model.setCode(1);
            model.setData(list);
             model.setSum(list.size());
        }
        return model;
    }
    // ----------查不重复的StationName1(维护区)不包含91000000一期设备
    public ServiceModelOnce serchByStationNot91() {
        ServiceModelOnce model = new ServiceModelOnce();
        List list=mapper.serchByStationNot91();
        if (list != null && list.size() > 0) {
            model.setCode(1);
            model.setData(list);
             model.setSum(list.size());
        }
        return model;
    }
    //查单体编号
    public ServiceModelOnce serchByMonNum(BattInf obj) {
        ServiceModelOnce model = new ServiceModelOnce();
        List<BattInf> list = mapper.serchByMonNum(obj);
        if (list != null && list.size() > 0) {
            for (int i = 0; i <list.size(); i++) {
                String s = list.get(i).getSignalName().split("#")[0];
                list.get(i).setMonNum(Integer.parseInt(s));
            }
            model.setCode(1);
            model.setData(list);
            model.setSum(list.size());
        } else {
            model.setCode(0);
            model.setSum(0);
        }
        return model;
    }
    //根据电池id查询电池的基本信息
    public ServiceModel searchBattBybattgroupid(BattInf obj){
        ServiceModel model=new ServiceModel();
        List list=mapper.searchBattBybattgroupid(obj);
        //System.out.println(list);
        if(list!=null && list.size()>0){
            model.setCode(1);
            model.setData(list);
        }
        return model;
    }
    public ServiceModelOnce serchByBattGroupName(BattInf obj) {
        ServiceModelOnce model=new ServiceModelOnce();
        List list=mapper.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(BattInf binf) {
        ServiceModel model = new ServiceModel();
        System.out.println(1111111111);
        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(DateUtil.sdf.parse(dateFirst));
            //System.out.println(dateFirst.substring(0,10));
            dateLast = ActionUtil.getLastDayOfMonth(year, lastMonth);//结束时间
            binf.setBattInUseDate1(DateUtil.sdf.parse(dateLast));
        } catch (Exception e) {
            e.printStackTrace();
        }
 
        int level = Integer.parseInt(binf.getStationId());
        List<BattInf> listFalse = mapper.serchBylevel(level);
 
        //求总数
        List<BattInf> list = mapper.serchByMonVolStdGroup(binf);
        if (null != list && list.size() > 0) {
            String stationName1 = list.get(list.size() - 1).getStationName1();
            String stationName2 = list.get(list.size() - 1).getStationName2();
            String stationName3 = list.get(list.size() - 1).getStationName3();
            String stationName4 = list.get(list.size() - 1).getStationName4();
            int id = 0;//标志符号
            int battGroupNum = id;    //自增变量
            for (int i = 0; i < list.size(); i++) {
                BattInf srcb = list.get(i);
                if (binf.getStationId().equals("1")) {
                    if (srcb.getStationName1().equals(stationName1)) {
                        list.get(i).setBattGroupNum(battGroupNum++);
                    } else {
                        list.get(i).setBattGroupNum(id);
                        id += 1;
                    }
                } else if (binf.getStationId().equals("2")) {
                    if (srcb.getStationName1().equals(stationName1) && srcb.getStationName2().equals(stationName2)) {
                        list.get(i).setBattGroupNum(battGroupNum++);
                    } else {
                        list.get(i).setBattGroupNum(id);
                        id += 1;
                    }
                } else if (binf.getStationId().equals("3")) {
                    if (srcb.getStationName1().equals(stationName1) && srcb.getStationName2().equals(stationName2) && srcb.getStationName3().equals(stationName3)) {
                        list.get(i).setBattGroupNum(battGroupNum++);
                    } else {
                        list.get(i).setBattGroupNum(id);
                        id += 1;
                    }
                } else if (binf.getStationId().equals("4")) {
                    if (srcb.getStationName1().equals(stationName1) && srcb.getStationName2().equals(stationName2) && srcb.getStationName3().equals(stationName3) && srcb.getStationName4().equals(stationName4)) {
                        list.get(i).setBattGroupNum(battGroupNum++);
                    } else {
                        list.get(i).setBattGroupNum(id);
                        id += 1;
                    }
                }
            }
        }
        System.out.println("list = " + list);
        List<BattInf> listB = null;
        try {
            if (list != null && list.size() > 0) {
                listB = BattinfGroupFactory.finishMonvol(list);
            }
            List<BattInf> listL = null;
 
            if (listB != null && listB.size() > 0) {
                System.out.println("listB = " + listB);
                listL = BattinfGroupFactory.delMonvol(listB);
            }
            //求超期服役的数量
            try {
                year = (new Date()).getYear() + 1900 - 3;//当前时间减去年限
                //System.out.println(year);
                dateFirst = ActionUtil.getFirstDayOfMonth(year, firstMonth);//起始时间
                binf.setBattInUseDate(DateUtil.sdf.parse(dateFirst));
                //System.out.println(binf.getBattInUseDate());
            } catch (ParseException e) {
                e.printStackTrace();
            }
            List<BattInf> listY = mapper.serchBeyondTime(binf);//超期服役的电池组数
 
            List<BattInf> listBY = null;
            if (listY != null && listY.size() > 0) {
                System.out.println("超期服役的电池组数 listY.get(0) = " + listY.get(0));
                listBY = BattinfGroupFactory.finishMonvol(listY);
            } else {
                model.setCode(0);
                model.setData(listFalse);
                model.setMsg("查询失败!");
                return model;
            }
            List<BattInf> listLY = null;
 
            if (listBY != null && listBY.size() > 0) {
                listLY = BattinfGroupFactory.delMonvol(listBY);
            } else {
                model.setCode(0);
                model.setMsg("查询失败!");
                return model;
            }
        /*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=mapper.serchBylevel(level);
 
      /* for (BattInf b : listL) {
            System.out.println("1 "+b.getBattGroupNum()+" "+
              "2v: "+b.getBattGroupId()+" "+
              "6v: "+b.getMonCount()+" "+
              "12v: "+b.getMonNum());
        }*/
            if (listL != null && listL.size() > 0) {
                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());
                }
                model.setCode(1);
                model.setData(listEnd);
                model.setMsg("查询成功!");
            } else {
                model.setCode(0);
                model.setData(listFalse);
                model.setMsg("查询失败!");
            }
        } catch (Exception e) {
            e.printStackTrace();
            model.setCode(0);
            model.setMsg("查询失败!");
            return model;
        }
        return model;
    }
    //6.4.8按地域和标称电压分组统计蓄电池组的数量(蓄电池组数量统计)
        /*
         * 区域层次放在stationid中
         * battgroupnum 中存放统计方式:年度统计为0 季度统计为1
         * moncount中存放统计季度:一季度为1 以此类推
         * monnum 中存放年份*/
    public ServiceModel serchByMonVolStdGroup(BattInf binf) {
        ServiceModel model = new ServiceModel();
        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(DateUtil.sdf.parse(dateFirst));
            //System.out.println(dateFirst.substring(0,10));
            dateLast = ActionUtil.getLastDayOfMonth(year, lastMonth);//结束时间
            binf.setBattInUseDate1(DateUtil.sdf.parse(dateLast));
        } catch (Exception e) {
            e.printStackTrace();
            model.setCode(0);
            model.setMsg("查询失败!");
            return model;
        }
 
        List<BattInf> list = mapper.serchByMonVolStdGroup(binf);
        List<BattInf> listB = null;
        List<BattInf> listL = null;
        if (null != list && list.size() > 0) {
            String stationName1 = list.get(list.size() - 1).getStationName1();
            String stationName2 = list.get(list.size() - 1).getStationName2();
            String stationName3 = list.get(list.size() - 1).getStationName3();
            String stationName4 = list.get(list.size() - 1).getStationName4();
            int id = 0;//标志符号
            int battGroupNum = id;    //自增变量
            for (int i = 0; i < list.size(); i++) {
                BattInf srcb = list.get(i);
                if (binf.getStationId().equals("1")) {
                    if (srcb.getStationName1().equals(stationName1)) {
                        list.get(i).setBattGroupNum(battGroupNum++);
                    } else {
                        list.get(i).setBattGroupNum(id);
                        id += 1;
                    }
                } else if (binf.getStationId().equals("2")) {
                    if (srcb.getStationName1().equals(stationName1) && srcb.getStationName2().equals(stationName2)) {
                        list.get(i).setBattGroupNum(battGroupNum++);
                    } else {
                        list.get(i).setBattGroupNum(id);
                        id += 1;
                    }
                } else if (binf.getStationId().equals("3")) {
                    if (srcb.getStationName1().equals(stationName1) && srcb.getStationName2().equals(stationName2) && srcb.getStationName3().equals(stationName3)) {
                        list.get(i).setBattGroupNum(battGroupNum++);
                    } else {
                        list.get(i).setBattGroupNum(id);
                        id += 1;
                    }
                } else if (binf.getStationId().equals("4")) {
                    if (srcb.getStationName1().equals(stationName1) && srcb.getStationName2().equals(stationName2) && srcb.getStationName3().equals(stationName3) && srcb.getStationName4().equals(stationName4)) {
                        list.get(i).setBattGroupNum(battGroupNum++);
                    } else {
                        list.get(i).setBattGroupNum(id);
                        id += 1;
                    }
                }
            }
        }
 
//        battGroupNum 从list传过去
//        System.out.println("list = " + list);
        listB = BattinfGroupFactory.finishMonvol(list);//将同一stationame中的2v,6v,12v数据整合    battGroupNum 从这传过去
        if (null != listB && listB.size() > 0) {
//            System.out.println("listB.get(0) = " + listB.get(0));
            listL = BattinfGroupFactory.delMonvol(listB);//去除重复项 需要参数 battGroupNum
        }
        //没有数据时传分组情况
        int level = Integer.parseInt(binf.getStationId());
        List<BattInf> listFalse = mapper.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(BattInf binf){
        ServiceModel model = new ServiceModel();
        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(DateUtil.sdf.parse(dateFirst));
            //System.out.println(dateFirst.substring(0,10));
            dateLast=ActionUtil.getLastDayOfMonth(year,lastMonth);//结束时间
            binf.setBattInUseDate1(DateUtil.sdf.parse(dateLast));
        } catch (Exception e) {
            e.printStackTrace();
            model.setCode(0);
            model.setMsg("查询失败!");
            return model;
        }
 
 
        List<BattInf> list=mapper.serchByBattProducerGroup(binf);
        //没有数据时传分组情况
        int level = Integer.parseInt(binf.getStationId());
        List<BattInf> listFalse=mapper.serchBylevel(level);
 
        if (null != list && list.size() > 0) {
            String stationName1 = list.get(list.size() - 1).getStationName1();
            String stationName2 = list.get(list.size() - 1).getStationName2();
            String stationName3 = list.get(list.size() - 1).getStationName3();
            String stationName4 = list.get(list.size() - 1).getStationName4();
            int id = 0;//标志符号
            int battGroupNum = id;    //自增变量
            for (int i = 0; i < list.size(); i++) {
                BattInf srcb = list.get(i);
                if (binf.getStationId().equals("1")) {
                    if (srcb.getStationName1().equals(stationName1)) {
                        list.get(i).setBattGroupNum(battGroupNum++);
                    } else {
                        list.get(i).setBattGroupNum(id);
                        id += 1;
                    }
                } else if (binf.getStationId().equals("2")) {
                    if (srcb.getStationName1().equals(stationName1) && srcb.getStationName2().equals(stationName2)) {
                        list.get(i).setBattGroupNum(battGroupNum++);
                    } else {
                        list.get(i).setBattGroupNum(id);
                        id += 1;
                    }
                } else if (binf.getStationId().equals("3")) {
                    if (srcb.getStationName1().equals(stationName1) && srcb.getStationName2().equals(stationName2) && srcb.getStationName3().equals(stationName3)) {
                        list.get(i).setBattGroupNum(battGroupNum++);
                    } else {
                        list.get(i).setBattGroupNum(id);
                        id += 1;
                    }
                } else if (binf.getStationId().equals("4")) {
                    if (srcb.getStationName1().equals(stationName1) && srcb.getStationName2().equals(stationName2) && srcb.getStationName3().equals(stationName3) && srcb.getStationName4().equals(stationName4)) {
                        list.get(i).setBattGroupNum(battGroupNum++);
                    } else {
                        list.get(i).setBattGroupNum(id);
                        id += 1;
                    }
                }
            }
        }
//            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(BattInf binf){
        ServiceModel model = new ServiceModel();
            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(DateUtil.sdf.parse(dateFirst));
                //System.out.println(dateFirst.substring(0,10));
                dateLast=ActionUtil.getLastDayOfMonth(year,lastMonth);//结束时间
                binf.setBattInUseDate1(DateUtil.sdf.parse(dateLast));
            } catch (Exception e) {
                e.printStackTrace();
                model.setCode(0);
                model.setMsg("查询失败!");
                return model;
            }
            
            
            List<BattInf> list=mapper.serchByBattInUseDateGroup(binf);
            //System.out.println(list.size());
            //没有数据时传分组情况
            int level = Integer.parseInt(binf.getStationId());
            List<BattInf> listFalse=mapper.serchBylevel(level);
 
        if (null != list && list.size() > 0) {
            String stationName1 = list.get(list.size() - 1).getStationName1();
            String stationName2 = list.get(list.size() - 1).getStationName2();
            String stationName3 = list.get(list.size() - 1).getStationName3();
            String stationName4 = list.get(list.size() - 1).getStationName4();
            int id = 0;//标志符号
            int battGroupNum = id;    //自增变量
            for (int i = 0; i < list.size(); i++) {
                BattInf srcb = list.get(i);
                if (binf.getStationId().equals("1")) {
                    if (srcb.getStationName1().equals(stationName1)) {
                        list.get(i).setBattGroupNum(battGroupNum++);
                    } else {
                        list.get(i).setBattGroupNum(id);
                        id += 1;
                    }
                } else if (binf.getStationId().equals("2")) {
                    if (srcb.getStationName1().equals(stationName1) && srcb.getStationName2().equals(stationName2)) {
                        list.get(i).setBattGroupNum(battGroupNum++);
                    } else {
                        list.get(i).setBattGroupNum(id);
                        id += 1;
                    }
                } else if (binf.getStationId().equals("3")) {
                    if (srcb.getStationName1().equals(stationName1) && srcb.getStationName2().equals(stationName2) && srcb.getStationName3().equals(stationName3)) {
                        list.get(i).setBattGroupNum(battGroupNum++);
                    } else {
                        list.get(i).setBattGroupNum(id);
                        id += 1;
                    }
                } else if (binf.getStationId().equals("4")) {
                    if (srcb.getStationName1().equals(stationName1) && srcb.getStationName2().equals(stationName2) && srcb.getStationName3().equals(stationName3) && srcb.getStationName4().equals(stationName4)) {
                        list.get(i).setBattGroupNum(battGroupNum++);
                    } else {
                        list.get(i).setBattGroupNum(id);
                        id += 1;
                    }
                }
            }
        }
//            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(BattInf obj) {
        ServiceModel model = new ServiceModel();
        List list = mapper.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 = mapper.searchBattByStationId(obj);
        if(list != null && list.size()>0){
            model.setCode(1);
            model.setData(list);
            
        }else{
            model.setCode(0);
        }
        return model;
    }
    //查询所有的机房
    public ServiceModel serchAllStation(User_inf obj){
        ServiceModel model = new ServiceModel();
        List<BattInf> list=mapper.serchAllStation(obj);
        if (list != null && list.size() > 0) {
            String conStr = "-";//连接机房名称的符号
            for (int i = 0; i < list.size(); i++) {
                BattInf battInf = list.get(i);
 
                String stationName = "";
                if (!battInf.getStationName1().trim().equals("")) {
                    stationName += battInf.getStationName1();
                }
                if (!battInf.getStationName2().trim().equals("")) {
                    stationName += conStr;
                    stationName += battInf.getStationName2();
                }
                if (!battInf.getStationName3().trim().equals("")) {
                    stationName += conStr;
                    stationName += battInf.getStationName3();
                }
                if (!battInf.getStationName4().trim().equals("")) {
                    stationName += conStr;
                    stationName += battInf.getStationName4();
                }
                if (!battInf.getStationName5().trim().equals("")) {
                    stationName += conStr;
                    stationName += battInf.getStationName5();
                }
                if (!battInf.getStationName6().trim().equals("")) {
                    stationName += conStr;
                    stationName += battInf.getStationName6();
                }
                if (!battInf.getStationName7().trim().equals("")) {
                    stationName += conStr;
                    stationName += battInf.getStationName7();
                }
                if (!battInf.getStationName8().trim().equals("")) {
                    stationName += conStr;
                    stationName += battInf.getStationName8();
                }
                if (!battInf.getStationName9().trim().equals("")) {
                    stationName += conStr;
                    stationName += battInf.getStationName9();
                }
                list.get(i).setStationName(stationName);
                list.get(i).setStationId(battInf.getStationId());
                list.get(i).setFbsDeviceId(battInf.getFbsDeviceId());
            }
            model.setCode(1);
            model.setData(list);
            model.setMsg("查询成功!");
        }else{
            model.setCode(0);
            model.setMsg("查询失败!");
        }
        //System.out.println(model);
        return model;
    }
    //搜索机房或电池组
    public ServiceModel serchStationOrBattgroup(BattInf obj){
        ServiceModel model = new ServiceModel();
        List list=mapper.serchStationOrBattgroup(obj);
        if (list != null && list.size() > 0) {
            model.setCode(1);
            model.setData(list);
            model.setMsg("查询成功!");
        }else{
            model.setCode(0);
            model.setMsg("查询失败!");
        }
        //System.out.println(list.size());
        return model;
    }
    //根据机房id查询机房下的电池组信息
    public ServiceModel serchBattByStation(BattInf obj){
        ServiceModel model = new ServiceModel();
        List list=mapper.serchBattByStation(obj);
        if (list != null && list.size() > 0) {
            model.setCode(1);
            model.setData(list);
            model.setMsg("查询成功!");
        }else{
            model.setCode(0);
            model.setMsg("查询失败!");
        }
        //System.out.println(model);
        return model;
    }
    //查询所有的电池组数
    public ServiceModelOnce serchAllBatt(User_inf obj) {
        ServiceModelOnce model = new ServiceModelOnce();
        int nums = mapper.serchAllBatt(obj);
        model.setCode(1);
        model.setSum(nums);
        model.setMsg("查询成功!");
        //System.out.println(model);
        return model;
    }
    @Resource
    private BattInfMapper battInfMapper;
    //添加站点时返回最大的机房id,设备id,电池组id
    public ServiceModel searchmaxId() {
        ServiceModel model = new ServiceModel();
        List list=new ArrayList();
 
//        int battgroupid=BattinfGroupFactory.searchMaxBattgroupId();
        int battgroupid=0;
        int BattgroupId_inf=battInfMapper.searchMaxBattgroupId_zj();//当前内存中最大的电池组id
        if (BattgroupId_inf==0){
            BattgroupId_inf=1010000;
        }
        battgroupid=BattgroupId_inf+1;
        list.add(battgroupid);
 
//        int stationid=BattinfGroupFactory.searchStationId();
        int stationid=0;
        int stationid_inf=battInfMapper.searchMaxId_zj();//当前最大的stationid
        if (stationid_inf==0){
            stationid_inf=42010000;
        }
        stationid=stationid_inf+1;
        list.add(stationid);
 
//        int dev_id=BattinfGroupFactory.searchmaxdev_id();
        int dev_id=0;
        int devid_inf=battInfMapper.searchMaxdevId_binf();
        dev_id=devid_inf+1;
        if(dev_id == 1){
            dev_id = 618500001;
        }
        list.add(dev_id);
        model.setData(list);
        model.setCode(1);
        model.setMsg("查询成功");
        return model;
    }
    //根据维护区和机房名称查询电池组信息(电池组信息配置)<-------跨域----------->
    public ServiceModel searchInform_ky() {
        ServiceModel model = new ServiceModel();
        List<BattInf> list=mapper.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 ServiceModel searchDevByStationName3(BattInf obj) {
        ServiceModel model = new ServiceModel();
        List list=mapper.searchDevByStationName3(obj);
        if (list != null && list.size() > 0) {
            model.setCode(1);
            model.setData(list);
            model.setMsg("查询成功!");
        }
        else{
            model.setCode(0);
            model.setMsg("查询失败!");
        }
        return model;
    }
    
    //首页上根据stationid查询电池组的机历卡
    public ServiceModel serchBattAllInfoByStationId(BattInf obj){
        ServiceModel model = new ServiceModel();
        List<BattInf> list=mapper.serchBattAllInfoByStationId(obj);
        if (list != null && list.size() > 0) {
            for (int i = 0; i < list.size(); i++) {
                BattInf battInf = list.get(i);
                int BattGuarantDayCount = battInf.getBattGuarantDayCount() - ActionUtil.daysBetween(battInf.getBattInUseDate(), new Date());//剩余保修天数
                list.get(i).setBattGuarantDayCount(BattGuarantDayCount);
            }
            model.setCode(1);
            model.setData(list);
            model.setMsg("查询成功!");
        }else{
            model.setCode(0);
            model.setMsg("查询失败!");
        }
        return model;
    }
 
    //--------查询电池组信息<大屏显示>
    public ServiceModel serchBatt_DP(BattInf obj) {
        ServiceModel model = new ServiceModel();
        List list=mapper.serchBatt_DP(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 searchStationList() {
        ServiceModel model = new ServiceModel();
        List list=mapper.searchStationList();
        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);
        
        PageBean pageBean =new PageBean();
        pageBean.setPageCurr(1);
        pageBean.setPageSize(10);
        Batt_Maint_Dealarm bmd=new Batt_Maint_Dealarm();
        bmd.setBinf(b);
        bmd.setPageBean(pageBean);
        //bs.searchInform(bmd);
        //bs.serchByBattGroupName(b);
        bs.updateIp(b);
    }
 
    /**查询所有省市区站点机房*/
    public ServiceModel searchAllStation(Integer uId) {
        Map map =mapper.searchAllStation(uId);
        if(map!=null && !map.isEmpty()){
            model.setCode(1);
            model.setData(map);
        }
        return model;
    }
}