| | |
| | | if(map.containsKey(k)){ |
| | | Object o = map.get(k).get(sensor); |
| | | timeValueMap.put(c,Objects.nonNull(o)?Double.valueOf(o.toString()):0); |
| | | if(Objects.nonNull(o)){ |
| | | if(Objects.nonNull(o)&& (!Double.valueOf(o.toString()).equals(0d))){ |
| | | doubleArrayList.add(Double.valueOf(o.toString())); |
| | | } |
| | | }else { |
| | |
| | | if(map.containsKey(k)){ |
| | | Object o = map.get(k).get(sensor); |
| | | num = Objects.nonNull(o)?Double.valueOf(o.toString()):0d; |
| | | if(Objects.nonNull(num)){ |
| | | if(Objects.nonNull(num)&& !num.equals(0d)){ |
| | | ArrayList<Double> doubleArrayList = Objects.isNull(listMap.get(numCount+"_"+sensorMap.get(sensor)))?new ArrayList<>():listMap.get(numCount+"_"+sensorMap.get(sensor)); |
| | | doubleArrayList.add(num); |
| | | listMap.put(numCount+"_"+sensorMap.get(sensor),doubleArrayList); |
| | |
| | | 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))),90d); |
| | | }else if(son.contains("一氧化碳")){ |
| | | rsAvg = percentile(listMap.get(numCount+"_"+sensorMap.get(sensorsList.get(z))),95d); |
| | | }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(); |
| | | } |
| | | |
| | | } |
| | | |
| | | |