| | |
| | | double rsAvg = 0L; |
| | | String son = numCount+"_"+sensorMap.get(sensorsList.get(z)); |
| | | if(listMap.containsKey(numCount+"_"+sensorMap.get(sensorsList.get(z)))){ |
| | | Double ListAvg = listMap.get(numCount+"_"+sensorMap.get(sensorsList.get(z))).stream().collect(Collectors.averagingDouble(Double::doubleValue)); |
| | | rsAvg = new BigDecimal(ListAvg).setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue(); |
| | | if(son.contains("臭氧")){ |
| | | rsAvg = percentile(listMap.get(numCount+"_"+sensorMap.get(sensorsList.get(z))),95d); |
| | | |
| | | }else if(son.contains("一氧化碳")){ |
| | | rsAvg = percentile(listMap.get(numCount+"_"+sensorMap.get(sensorsList.get(z))),90d); |
| | | }else { |
| | | Double ListAvg = listMap.get(numCount+"_"+sensorMap.get(sensorsList.get(z))).stream().collect(Collectors.averagingDouble(Double::doubleValue)); |
| | | rsAvg = new BigDecimal(ListAvg).setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue(); |
| | | } |
| | | |
| | | } |
| | | timeValueMap.put(sensorMap.get(sensorsList.get(z)),rsAvg); |
| | | } |
| | |
| | | monitorPointMapper.selectList(monitorPointQueryWrapper).forEach(it->map.put(it.getId(),it.getName())); |
| | | return map; |
| | | } |
| | | private Double percentile(List<Double> date,double num){ |
| | | Collections.sort(date); |
| | | double position = (num / 100) * (date.size() - 1); |
| | | int index = (int) position; |
| | | // 获取小数部分的位置索引 |
| | | double fraction = position - index; |
| | | |
| | | // 获取百分位值 |
| | | double percentileValue = date.get(index) + fraction * (date.get(index + 1) - date.get(index)); |
| | | return new BigDecimal(percentileValue).setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue(); |
| | | } |
| | | |
| | | } |
| | | |
| | | |