whyclxw
2024-03-05 e1f01e8e70bc3ca75ad7ee25cb45c263e4631df3
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
package com.whyc.factory;
 
import com.whyc.mapper.BattInfMapper;
import com.whyc.pojo.Battinf;
import com.whyc.service.BattInfService;
 
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
 
public class BattinfGroupFactory {
    /**电源设备编码*/
    public static final int DEVICE_POWER=110;
    //电源厂家编码 TODO
 
    public static final int DEVICE_INSULATION=111;
    public static final int DEVICE_CHARGER=112;
    public static final int DEVICE_AIR_CONDITIONER=113;
    public static final int DEVICE_VIDEO=114;
    //将同一stationame中的2v,6v,12v数据整合
    public static List finishMonvol(Object obj1){
        List<Battinf> list=(List<Battinf>) obj1;
        if(list!=null&&list.size()>0){
            for (int i = 0; i < list.size(); i++) {
                /*
                 * 2V 数量放在BattGroupid
                 * 6V 数量放在MonCount
                 * 12V数量放在MonNum
                 */
                if(i==0){
                    if(list.get(i).getMonVolStd()==2){
                        list.get(i).setBattGroupId(list.get(i).getNum());
                    }else if(list.get(i).getMonVolStd()==6){
                        list.get(i).setMonCount(list.get(i).getNum());
                    }else if(list.get(i).getMonVolStd()==12){
                        list.get(i).setMonNum(list.get(i).getNum());
                    }
                }else{
                    if(list.get(i).getBattGroupNum().equals(list.get(i-1).getBattGroupNum())){
                        if(list.get(i).getMonVolStd()==2){
                            list.get(i-1).setBattGroupId(list.get(i).getNum());
                        }else if(list.get(i).getMonVolStd()==6){
                            list.get(i-1).setMonCount(list.get(i).getNum());
                        }else if(list.get(i).getMonVolStd()==12){
                            list.get(i-1).setMonNum(list.get(i).getNum());
                        }
                    }else{
                        if(list.get(i).getMonVolStd()==2){
 
                            list.get(i).setBattGroupId(list.get(i).getNum());
                        }else if(list.get(i).getMonVolStd()==6){
                            list.get(i).setMonCount(list.get(i).getNum());
                        }else if(list.get(i).getMonVolStd()==12){
                            list.get(i).setMonNum(list.get(i).getNum());
                        }
                    }
                }
 
            }
        }
 
        return list;
    }
    //去除重复项
    public static List delMonvol(Object obj1){
        List<Battinf> list=(List<Battinf>) obj1;
        List<Battinf> listB=new ArrayList<Battinf>();
        int battGroupNum=1000;//标识
        if(list!=null&&list.size()>0){
            for (int i = 0; i <list.size(); i++) {
                if(list.get(i).getBattGroupNum()!=battGroupNum){
                    listB.add(list.get(i));
                }
                battGroupNum=listB.get(listB.size()-1).getBattGroupNum();
            }
        }
        return listB;
    }
    //整合超期的电池组数和总数
    public static List countAll(Object obj1,Object obj2){
        List<Battinf> list=(List<Battinf>) obj1;
        List<Battinf> listY=(List<Battinf>) obj2;
        if(list.size()>0){
            for(int i=0;i<list.size();i++){
                if(list.get(i).getBattGroupId()==null){
                    list.get(i).setBattGroupId(0);
                }
                if(list.get(i).getMonCount()==null){
                    list.get(i).setMonCount(0);
                }
                if(list.get(i).getMonNum()==null){
                    list.get(i).setMonNum(0);
                }
                if(listY.size()>0){
                    if(listY.get(i).getBattGroupId()!=null){
                        list.get(i).setMonCapStd((float)listY.get(i).getBattGroupId());
                    }else{
                        list.get(i).setMonCapStd(0f);
                    }
                    if(listY.get(i).getMonCount()!=null){
                        list.get(i).setMonResStd((float)listY.get(i).getMonCount());
                    }else{
                        list.get(i).setMonResStd(0f);
                    }
                    if(listY.get(i).getMonNum()!=null){
                        list.get(i).setMonSerStd((float)listY.get(i).getMonNum());
                    }else{
                        list.get(i).setMonSerStd(0f);
                    }
 
                }
            }
        }
        return list;
    }
 
 
    //查询当前最大的电池组id
    public static int searchMaxBattgroupId(){
        int battgroupid=0;
        int BattgroupId_inf=new BattInfService().searchMaxBattgroupId_zj();//当前内存中最大的电池组id
        battgroupid=BattgroupId_inf+1;
        return battgroupid;
    }
    //查询当前最大的stationid
    public static int searchStationId(){
        int stationid=0;
        int stationid_inf=Integer.valueOf((new BattInfService()).searchMaxId_zj());//当前最大的stationid
        stationid=stationid_inf+1;
        return stationid;
    }
    //查询当前最大的dev_id,
//    public static int searchmaxdev_id(){
//        int dev_id=0;
//        int devid_inf=(new BattinfImpl()).searchMaxdevId_binf();
//        dev_id=devid_inf+1;
//        if(dev_id == 1){
//            dev_id = 618500001;
//        }
//        return dev_id;
//    }
//
//    //从数据库读取最大的设备id+1作为新增设备的id,分五种类型:9100 9110 9120 61850 71850;设备id为九位数
    public static int searchmaxdev_id(Integer fbsDeviceId) {
        Integer devId = new BattInfService().searchMaxDevId(fbsDeviceId);
        if(devId==null||devId==0){
            int length = String.valueOf(fbsDeviceId).length();
            switch (length){
                case 3:
                    devId = fbsDeviceId*1000000;break;
                case 4:
                    devId = fbsDeviceId*100000;break;
                case 5:
                    devId = fbsDeviceId*10000;break;
                case 6:
                    devId = fbsDeviceId*1000;break;
                /*case 9100:
                case 9110:
                case 9120:
                case 9605:
                    devId = fbsDeviceId*100000;break;
                case 61850:
                case 71850:
                    devId = fbsDeviceId*10000;break;
                default:
                    devId= fbsDeviceId*100000;break;*/
            }
        }
        devId+=1;
 
        return devId;
 
    }
//
//    //从数据库读取最大的电源设备id+1作为新增设备的id,设备id为8位数
//    public static int getPowerDeviceId(Integer powerDeviceType) {
//        Integer devId = new PowerInfDao().getMaxPowerDeviceId(powerDeviceType);
//        if(devId==null||devId==0){
//            /*switch (powerDeviceType){
//                //电源系统
//                case 110:
//                //绝缘装置
//                case 111:
//                //充电机
//                case 112:
//                //空调系统
//                case 113:
//                //视频系统
//                case 114:
//                    devId = powerDeviceType*1000000;break;
//            }*/
//            devId = powerDeviceType*1000000;
//        }
//        devId+=1;
//
//        return devId;
//
//    }
}