From ddaee239feb428cc426396a742c9d992d5983548 Mon Sep 17 00:00:00 2001
From: kaiyu <404897439@qq.com>
Date: Fri, 18 Feb 2022 10:42:38 +0800
Subject: [PATCH] screen-api                 更改优良天变化率正负号

---
 screen-api/src/main/java/com/moral/api/service/impl/CityAqiYearlyServiceImpl.java |   54 ++++++++++++++++++++++++++++++------------------------
 1 files changed, 30 insertions(+), 24 deletions(-)

diff --git a/screen-api/src/main/java/com/moral/api/service/impl/CityAqiYearlyServiceImpl.java b/screen-api/src/main/java/com/moral/api/service/impl/CityAqiYearlyServiceImpl.java
index a8afe09..1fec4d8 100644
--- a/screen-api/src/main/java/com/moral/api/service/impl/CityAqiYearlyServiceImpl.java
+++ b/screen-api/src/main/java/com/moral/api/service/impl/CityAqiYearlyServiceImpl.java
@@ -86,12 +86,12 @@
         DataPercentRange fineDays = calculateFineDays(cities, twentyEightCities, heBeiEightCities, startDate, endDate, city);
         //������6���������������������������
         Map<String, DataPercentRange> sixParamMap = calculateSixParam(thisYear, startDate, endDate, city, cities, twentyEightCities, heBeiEightCities);
-        Map<String,DataPercentRange> result = new HashMap<>();
-        if(fineDays!=null)
-            result.put("fineDays",fineDays);
-        if(sixParamMap!=null)
+        Map<String, DataPercentRange> result = new HashMap<>();
+        if (fineDays != null)
+            result.put("fineDays", fineDays);
+        if (sixParamMap != null)
             result.putAll(sixParamMap);
-        if(result.size()==0)
+        if (result.size() == 0)
             return null;
         return result;
     }
@@ -108,7 +108,7 @@
 
         //���������������������
         CityPollutionLevel cityPollutionLevel = cityAqiDailyService.calculateDaysByTimeAndSysArea(city, startDate, endDate);
-        if(cityPollutionLevel==null)
+        if (cityPollutionLevel == null)
             return null;
         Integer fineDays = cityPollutionLevel.getExcellentWeatherDays() + cityPollutionLevel.getGoodWeatherDays();
         //������������������
@@ -116,13 +116,19 @@
         Date compareEndDate = DateUtils.addMonths(endDate, -12);
         CityPollutionLevel cityPollutionLevelCompare = cityAqiDailyService.calculateDaysByTimeAndSysArea(city, compareStartDate, compareEndDate);
         String percent = null;
-        if(cityPollutionLevelCompare!=null){
+        if (cityPollutionLevelCompare != null) {
             Integer compareFineDays = cityPollutionLevelCompare.getExcellentWeatherDays() + cityPollutionLevelCompare.getGoodWeatherDays();
-            percent = (fineDays - compareFineDays) + " ���";
+            Integer percentInt = fineDays - compareFineDays;
+            if (percentInt > 0) {
+                percent = "+" + percentInt + " ���";
+            } else {
+                percent = percentInt + " ���";
+            }
+
         }
         //������������������
         Integer provinceRange = null;
-        if(provinceCities!=null)
+        if (provinceCities != null)
             provinceRange = calculateFineDaysRange(provinceCities, city, startDate, endDate);
         //������2+26������������
         Integer twentyEightRange = null;
@@ -161,7 +167,7 @@
         Map<String, Double> compareCentration = getConcentration(thisYear, compareStartDate, compareEndDate, cityCode);
         //������6���������������������������
         Map<String, String> compareResult = null;
-        if(compareCentration!=null)
+        if (compareCentration != null)
             compareResult = calculateSixParamYOY(concentration, compareCentration);
         //������������������
         Map<String, Integer> provinceRangeResult = null;
@@ -185,13 +191,13 @@
         DataPercentRange O3 = packageSixParam(concentration, compareResult, provinceRangeResult, twentyEightRangeResult, provinceChannelRangeResult, "O3", 0, "��g/m��");
         DataPercentRange CO = packageSixParam(concentration, compareResult, provinceRangeResult, twentyEightRangeResult, provinceChannelRangeResult, "CO", 1, "mg/m��");
         DataPercentRange compositeIndex = packageSixParam(concentration, compareResult, provinceRangeResult, twentyEightRangeResult, provinceChannelRangeResult, "compositeIndex", 3, "");
-        result.put("PM2_5",PM2_5);
-        result.put("PM10",PM10);
-        result.put("SO2",SO2);
-        result.put("NO2",NO2);
-        result.put("O3",O3);
-        result.put("CO",CO);
-        result.put("compositeIndex",compositeIndex);
+        result.put("PM2_5", PM2_5);
+        result.put("PM10", PM10);
+        result.put("SO2", SO2);
+        result.put("NO2", NO2);
+        result.put("O3", O3);
+        result.put("CO", CO);
+        result.put("compositeIndex", compositeIndex);
         return result;
     }
 
@@ -286,31 +292,31 @@
 
         Double pm2_5 = calculateSensorYOY(dataMap, compareDataMap, "PM2_5");
         if (pm2_5 != null)
-            result.put("PM2_5", pm2_5.intValue() + " ��g/m��");
+            result.put("PM2_5", pm2_5.intValue() > 0 ? "+" + pm2_5.intValue() + " ��g/m��" : pm2_5.intValue() + " ��g/m��");
 
         Double pm10 = calculateSensorYOY(dataMap, compareDataMap, "PM10");
         if (pm10 != null)
-            result.put("PM10", pm10.intValue() + " ��g/m��");
+            result.put("PM10", pm10.intValue() > 0 ? "+" + pm10.intValue() + " ��g/m��" : pm10.intValue() + " ��g/m��");
 
         Double so2 = calculateSensorYOY(dataMap, compareDataMap, "SO2");
         if (so2 != null)
-            result.put("SO2", so2.intValue() + " ��g/m��");
+            result.put("SO2", so2.intValue() > 0 ? "+" + so2.intValue() + " ��g/m��" : so2.intValue() + " ��g/m��");
 
 
         Double no2 = calculateSensorYOY(dataMap, compareDataMap, "NO2");
         if (no2 != null)
-            result.put("NO2", no2.intValue() + " ��g/m��");
+            result.put("NO2", no2.intValue() > 0 ? "+" + no2.intValue() + " ��g/m��" : no2.intValue() + " ��g/m��");
 
 
         Double o3 = calculateSensorYOY(dataMap, compareDataMap, "O3");
         if (o3 != null)
-            result.put("O3", o3.intValue() + " ��g/m��");
+            result.put("O3", o3.intValue() > 0 ? "+" + o3.intValue() + " ��g/m��" : o3.intValue() + " ��g/m��");
 
 
         Double co = calculateSensorYOY(dataMap, compareDataMap, "CO");
         if (co != null) {
             co = AmendUtils.sciCal(co, 1);
-            result.put("CO", co + " mg/m��");
+            result.put("CO", co.intValue() > 0 ? "+" + co.intValue() + " mg/m��" : co.intValue() + " mg/m��");
         }
 
         //������������������������������
@@ -321,7 +327,7 @@
         if (compositeIndex != null && compareCompositeIndex != null) {
             Double compareResult = MathUtils.division(compositeIndex - compareCompositeIndex, compareCompositeIndex, 3);
             compareResult = MathUtils.mul(compareResult, 100);
-            result.put("compositeIndex", compareResult + "%");
+            result.put("compositeIndex", compareResult > 0 ? "+" + compareResult + " %" : compareResult + " %");
         }
         if (result.size() != 7)
             return null;

--
Gitblit v1.8.0