cjl
2023-08-02 0a15ced309df3fb76f1af4ee656d79a46e66bc92
feat:空气质量报告
1 files modified
177 ■■■■ changed files
screen-api/src/main/java/com/moral/api/controller/SysTestController.java 177 ●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/controller/SysTestController.java
@@ -184,100 +184,97 @@
        int sizeLowResult = 0;
        String highName = "沙岗村";
        String lowName = "沙岗村";
        StringBuffer highCode = new StringBuffer();
        StringBuffer lowCode = new StringBuffer();
        //1 两高 2两低
        if(type == 1){
            SysTest ResultAqi = listAll.stream().min(Comparator.comparing(SysTest::getAqi)).get();
            if(ResultAqi.getName().contains("沙岗村")){
                lowName = "沙岗村";
                highName = "友爱村、中间村";
            }else if(ResultAqi.getName().contains("友爱村")){
                lowName = "友爱村";
                highName = "沙岗村、中间村";
            } else if(ResultAqi.getName().contains("中间村")){
                lowName = "中间村";
                highName = "沙岗村、友爱村";
            }
            //1 两高 2两低
            if(type == 1){
                SysTest ResultAqi = listAll.stream().min(Comparator.comparing(SysTest::getAqi)).get();
                if(ResultAqi.getName().contains("沙岗村")){
                    lowName = "沙岗村";
                    highName = "友爱村、中间村";
                }else if(ResultAqi.getName().contains("友爱村")){
                    lowName = "友爱村";
                    highName = "沙岗村、中间村";
                } else if(ResultAqi.getName().contains("中间村")){
                    lowName = "中间村";
                    highName = "沙岗村、友爱村";
                }
        }else if(type == 2){
            SysTest ResultAqi = listAll.stream().max(Comparator.comparing(SysTest::getAqi)).get();
            if(ResultAqi.getName().contains("沙岗村")){
                highName = "沙岗村";
                lowName = "友爱村、中间村";
            }else if(ResultAqi.getName().contains("友爱村")){
                highName = "沙岗村";
                lowName = "友爱村、中间村";
            } else if(ResultAqi.getName().contains("中间村")){
                highName = "沙岗村";
                lowName = "友爱村、中间村";
            }
        }else if(type == 3){
            if(aqiHigh == aqiHighResult){
                sizeHighResult = 0;
            }
            if(aqiMiddle == aqiHighResult){
                sizeHighResult = 1;
            }
            if(aqiLow == aqiHighResult){
                sizeHighResult = 2;
            }
            if(aqiHigh == aqiLowResult){
                sizeLowResult = 0;
            }
            if(aqiMiddle == aqiLowResult){
                sizeLowResult = 1;
            }
            if(aqiLow == aqiLowResult){
                sizeLowResult = 2;
            }
            SysTest HighResult = listAll.get(sizeHighResult);
            SysTest LowResult = listAll.get(sizeLowResult);
            }else if(type == 2){
                SysTest ResultAqi = listAll.stream().max(Comparator.comparing(SysTest::getAqi)).get();
                if(ResultAqi.getName().contains("沙岗村")){
                    highName = "沙岗村";
                    lowName = "友爱村、中间村";
                }else if(ResultAqi.getName().contains("友爱村")){
                    highName = "沙岗村";
                    lowName = "友爱村、中间村";
                } else if(ResultAqi.getName().contains("中间村")){
                    highName = "沙岗村";
                    lowName = "友爱村、中间村";
                }
            }else if(type == 3){
                if(aqiHigh == aqiHighResult){
                    sizeHighResult = 0;
                }
                if(aqiMiddle == aqiHighResult){
                    sizeHighResult = 1;
                }
                if(aqiLow == aqiHighResult){
                    sizeHighResult = 2;
                }
                if(aqiHigh == aqiLowResult){
                    sizeLowResult = 0;
                }
                if(aqiMiddle == aqiLowResult){
                    sizeLowResult = 1;
                }
                if(aqiLow == aqiLowResult){
                    sizeLowResult = 2;
                }
                SysTest HighResult = listAll.get(sizeHighResult);
                SysTest LowResult = listAll.get(sizeLowResult);
                if(HighResult.getName().contains("友爱村")){
                    highName = "友爱村";
                }else if(HighResult.getName().contains("中尖村")){
                    highName = "中尖村";
                }
                if(LowResult.getName().contains("友爱村")){
                    lowName = "友爱村";
                }else if(LowResult.getName().contains("中尖村")){
                    lowName = "中尖村";
                }
            if(HighResult.getName().contains("友爱村")){
                highName = "友爱村";
            }else if(HighResult.getName().contains("中尖村")){
                highName = "中尖村";
            }
            SysTest result0 = listAll.get(0);
            SysTest result1 = listAll.get(1);
            SysTest result2 = listAll.get(2);
            Map<String,String> pm10 = nameCode(result0.getName(),result1.getName(),result2.getName(),result0.getPm10(),result1.getPm10(),result2.getPm10());
            Map<String,String> pm25 = nameCode(result0.getName(),result1.getName(),result2.getName(),result0.getPm25(),result1.getPm25(),result2.getPm25());
            Map<String,String> so = nameCode(result0.getName(),result1.getName(),result2.getName(),result0.getSo2(),result1.getSo2(),result2.getSo2());
            Map<String,String> no = nameCode(result0.getName(),result1.getName(),result2.getName(),result0.getNo2(),result1.getNo2(),result2.getNo2());
            Map<String,String> co = nameCode(result0.getName(),result1.getName(),result2.getName(),result0.getCo(),result1.getCo(),result2.getCo());
            Map<String,String> o3 = nameCode(result0.getName(),result1.getName(),result2.getName(),result0.getO3(),result1.getO3(),result2.getO3());
            stringBuffer.append(highName+"整体空气质量(AQI)较高,"+lowName+"整体空气质量(AQI)较低。");
            if(pm10.isEmpty()&& pm25.isEmpty()&&so.isEmpty()&& no.isEmpty()&& co.isEmpty()&& o3.isEmpty()){
                return stringBuffer.toString();
            if(LowResult.getName().contains("友爱村")){
                lowName = "友爱村";
            }else if(LowResult.getName().contains("中尖村")){
                lowName = "中尖村";
            }
            stringBuffer.append("其中:");
            if(!pm10.isEmpty()){
                stringBuffer.append("PM10较高的是:"+pm10.get("high")+";较低的是:"+pm10.get("low")+"。");
            }
            if(!pm25.isEmpty()){
                stringBuffer.append("PM2.5较高的是:"+pm25.get("high")+";较低的是:"+pm25.get("low")+"。");
            }
            if(!so.isEmpty()){
                stringBuffer.append("SO2较高的是:"+so.get("high")+";较低的是:"+so.get("low")+"。");
            }
            if(!no.isEmpty()){
                stringBuffer.append("NO2较高的是:"+no.get("high")+";较低的是:"+no.get("low")+"。");
            }
            if(!co.isEmpty()){
                stringBuffer.append("CO较高的是:"+co.get("high")+";较低的是:"+co.get("low")+"。");
            }
            if(!o3.isEmpty()){
                stringBuffer.append("O3较高的是:"+o3.get("high")+";较低的是:"+o3.get("low")+"。");
            }
        }
        SysTest result0 = listAll.get(0);
        SysTest result1 = listAll.get(1);
        SysTest result2 = listAll.get(2);
        Map<String,String> pm10 = nameCode(result0.getName(),result1.getName(),result2.getName(),result0.getPm10(),result1.getPm10(),result2.getPm10());
        Map<String,String> pm25 = nameCode(result0.getName(),result1.getName(),result2.getName(),result0.getPm25(),result1.getPm25(),result2.getPm25());
        Map<String,String> so = nameCode(result0.getName(),result1.getName(),result2.getName(),result0.getSo2(),result1.getSo2(),result2.getSo2());
        Map<String,String> no = nameCode(result0.getName(),result1.getName(),result2.getName(),result0.getNo2(),result1.getNo2(),result2.getNo2());
        Map<String,String> co = nameCode(result0.getName(),result1.getName(),result2.getName(),result0.getCo(),result1.getCo(),result2.getCo());
        Map<String,String> o3 = nameCode(result0.getName(),result1.getName(),result2.getName(),result0.getO3(),result1.getO3(),result2.getO3());
        stringBuffer.append(highName+"整体空气质量(AQI)较高,"+lowName+"整体空气质量(AQI)较低。");
        if(pm10.isEmpty()&& pm25.isEmpty()&&so.isEmpty()&& no.isEmpty()&& co.isEmpty()&& o3.isEmpty()){
            return stringBuffer.toString();
        }
        stringBuffer.append("其中:");
        if(!pm10.isEmpty()){
            stringBuffer.append("PM10较高的是:"+pm10.get("high")+";较低的是:"+pm10.get("low")+"。");
        }
        if(!pm25.isEmpty()){
            stringBuffer.append("PM2.5较高的是:"+pm25.get("high")+";较低的是:"+pm25.get("low")+"。");
        }
        if(!so.isEmpty()){
            stringBuffer.append("SO2较高的是:"+so.get("high")+";较低的是:"+so.get("low")+"。");
        }
        if(!no.isEmpty()){
            stringBuffer.append("NO2较高的是:"+no.get("high")+";较低的是:"+no.get("low")+"。");
        }
        if(!co.isEmpty()){
            stringBuffer.append("CO较高的是:"+co.get("high")+";较低的是:"+co.get("low")+"。");
        }
        if(!o3.isEmpty()){
            stringBuffer.append("O3较高的是:"+o3.get("high")+";较低的是:"+o3.get("low")+"。");
        }
        return stringBuffer.toString();
    }