| | |
| | | |
| | | } |
| | | |
| | | |
| | | //山西晋源特定接口 |
| | | public Response getEnduranceTimeLongJY(int hour){ |
| | | try { |
| | | List<BattEndurance> capList = mapper.getListAndLoadCurrJY(); |
| | | List<BattEndurance> enduranceLowList = new LinkedList<>(); |
| | | for (BattEndurance battEndurance : capList) { |
| | | if (battEndurance.getEnduranceActualTimelong() < hour) { |
| | | enduranceLowList.add(battEndurance); |
| | | } |
| | | } |
| | | Map<Integer, List<BattEndurance>> collect = enduranceLowList.stream().collect(Collectors.groupingBy(BattEndurance::getNum)); |
| | | enduranceLowList.clear(); |
| | | Set<Integer> idSet = collect.keySet(); |
| | | for (Integer id : idSet) { |
| | | List<BattEndurance> battEnduranceList = collect.get(id); |
| | | BattEndurance battEndurance = battEnduranceList.get(0); |
| | | if (battEnduranceList.size() > 1) { |
| | | for (int i = 0; i < battEnduranceList.size(); i++) { |
| | | BattEndurance endurance = battEnduranceList.get(i); |
| | | if (i == 0) { |
| | | battEndurance.setLoadCurr(endurance.getLoadCurr()); |
| | | } else { |
| | | battEndurance.setLoadCurr(battEndurance.getLoadCurr() + "/" + endurance.getLoadCurr()); |
| | | } |
| | | } |
| | | } |
| | | enduranceLowList.add(battEndurance); |
| | | } |
| | | return new Response().setII(1, enduranceLowList.size(), enduranceLowList, null); |
| | | }catch (Exception e){ |
| | | return new Response<>().set(1,false,"发生异常:"+e.getCause()); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 测试时间存在,加入统计 |
| | | * @param userId |
| | |
| | | |
| | | } |
| | | |
| | | //山西晋源特定接口 |
| | | public Response getGroupCapListJY(){ |
| | | try { |
| | | List<BattEndurance> groupCapList = new LinkedList<>(); |
| | | List<BattEndurance> list = mapper.getGroupCapListJY(); |
| | | //获取有效数据 |
| | | for (BattEndurance battEndurance : list) { |
| | | if(battEndurance.getGroupcount()>1){ //多个电池组 |
| | | Class<? extends BattEndurance> clazz = battEndurance.getClass(); |
| | | String[] testTimeSplit = battEndurance.getBattsTeststarttime().split("/"); |
| | | for (int i = 0; i < testTimeSplit.length; i++) { |
| | | String testTime = testTimeSplit[i]; |
| | | if(!testTime.equals("-")){ //有效 |
| | | //通过反射获取字段 |
| | | BattEndurance temp = new BattEndurance(); |
| | | Field groupCapField = clazz.getDeclaredField("realCapGroup" + (i + 1)); |
| | | //groupCapField.setAccessible(true); |
| | | ReflectionUtils.makeAccessible(groupCapField); |
| | | Float groupCap = (Float) groupCapField.get(battEndurance); |
| | | temp.setMoncapstd(Float.parseFloat(battEndurance.getBattsMoncapstd().split("/")[i])); |
| | | temp.setRealCap(groupCap); |
| | | groupCapList.add(temp); |
| | | } |
| | | } |
| | | }else{ //单组 |
| | | BattEndurance temp = new BattEndurance(); |
| | | temp.setRealCap(battEndurance.getRealCapGroup1()); |
| | | temp.setMoncapstd(Float.parseFloat(battEndurance.getBattsMoncapstd())); |
| | | groupCapList.add(temp); |
| | | } |
| | | } |
| | | Map<Integer,Integer> map = new HashMap<>(); |
| | | map.put(1,0); |
| | | map.put(2,0); |
| | | map.put(3,0); |
| | | map.put(4,0); |
| | | map.put(5,0); |
| | | Map<Integer,String> mapPercent = new HashMap<>(); |
| | | |
| | | //获取所有的电池组数 |
| | | int totalNum = battInfService.getBattGroupListJY().size(); |
| | | //非1等级的数量 |
| | | int notLevel1Num=0; |
| | | //获取已经核容的电池组的容量各区间组数 |
| | | float capLevel1 = 0.95f; |
| | | float capLevel2 = 0.85f; |
| | | float capLevel3 = 0.6f; |
| | | float capLevel4 = 0.5f; |
| | | |
| | | for (BattEndurance groupCap : groupCapList) { |
| | | float realCap = groupCap.getRealCap(); |
| | | float capStd = groupCap.getMoncapstd(); |
| | | Float capPercentF = (Float) MathUtil.divide(realCap, capStd, MathUtil.TYPE_FLOAT); |
| | | if(capPercentF>=capLevel1){ |
| | | map.put(1,map.get(1)+1); |
| | | } |
| | | else if(capPercentF>=capLevel2){ |
| | | map.put(2,map.get(2)+1); |
| | | notLevel1Num++; |
| | | } |
| | | else if(capPercentF>=capLevel3){ |
| | | map.put(3,map.get(3)+1); |
| | | notLevel1Num++; |
| | | } |
| | | else if(capPercentF>=capLevel4){ |
| | | map.put(4,map.get(4)+1); |
| | | notLevel1Num++; |
| | | } |
| | | else{ |
| | | map.put(5,map.get(5)+1); |
| | | notLevel1Num++; |
| | | } |
| | | } |
| | | //重置等级1的电池组数,未核容的电池组默认是100%,属于等级1 |
| | | map.put(1,totalNum-notLevel1Num); |
| | | |
| | | Set<Integer> levelSet = map.keySet(); |
| | | for (Integer level : levelSet) { |
| | | Integer num = map.get(level); |
| | | String percent = (String) MathUtil.divide(num, totalNum, MathUtil.TYPE_FLOAT_PERCENT, 1); |
| | | mapPercent.put(level,percent); |
| | | } |
| | | return new Response().setIII(1, true,mapPercent,map,null); |
| | | }catch (Exception e) { |
| | | return new Response().set(1,false,"发生异常:"+e.getCause()); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | } |