From 5236663d1e40ca9ed0cbc0885cbc67a67c47943f Mon Sep 17 00:00:00 2001
From: kaiyu <404897439@qq.com>
Date: Mon, 14 Mar 2022 16:27:23 +0800
Subject: [PATCH] screen-api            增加获取简报接口

---
 screen-common/src/main/java/com/moral/util/AQIUtils.java                              |   19 +
 screen-api/src/main/java/com/moral/api/service/CityAqiDailyService.java               |    9 
 screen-api/src/main/resources/application-dev.yml                                     |    2 
 screen-api/src/main/java/com/moral/api/config/properties/SpecialCitiesProperties.java |    2 
 screen-api/src/main/java/com/moral/api/service/impl/CityAqiMonthlyServiceImpl.java    |   13 
 screen-api/src/main/java/com/moral/api/config/properties/BulletinProperties.java      |   27 +
 screen-common/src/main/java/com/moral/constant/Constants.java                         |   12 
 screen-api/src/main/java/com/moral/api/controller/BulletinController.java             |   51 +++
 screen-api/src/main/java/com/moral/api/service/impl/CityAqiDailyServiceImpl.java      |  325 ++++++++++++++++++++++-
 screen-api/src/main/resources/application-bulletin.yml                                |    6 
 screen-api/src/main/resources/application-specialCity.yml                             |  340 ++++++++++++++++++++++++
 screen-api/src/main/java/com/moral/api/service/CityAqiMonthlyService.java             |    8 
 12 files changed, 792 insertions(+), 22 deletions(-)

diff --git a/screen-api/src/main/java/com/moral/api/config/properties/BulletinProperties.java b/screen-api/src/main/java/com/moral/api/config/properties/BulletinProperties.java
new file mode 100644
index 0000000..2256ef9
--- /dev/null
+++ b/screen-api/src/main/java/com/moral/api/config/properties/BulletinProperties.java
@@ -0,0 +1,27 @@
+package com.moral.api.config.properties;
+
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+/**
+ * @ClassName
+ * @Description TODO
+ * @Author ���������
+ * @Date 2022/3/11 15:04
+ * @Version TODO
+ **/
+@Data
+@Component
+@ConfigurationProperties(prefix = "bulletin")
+public class BulletinProperties {
+    private String title;
+
+    private String paragraphOne;
+
+    private String paragraphTwo;
+
+    private String paragraphThree;
+
+    private String paragraphFour;
+}
diff --git a/screen-api/src/main/java/com/moral/api/config/properties/SpecialCitiesProperties.java b/screen-api/src/main/java/com/moral/api/config/properties/SpecialCitiesProperties.java
index 2f2c2b1..a636026 100644
--- a/screen-api/src/main/java/com/moral/api/config/properties/SpecialCitiesProperties.java
+++ b/screen-api/src/main/java/com/moral/api/config/properties/SpecialCitiesProperties.java
@@ -24,6 +24,8 @@
 
     private List<SysArea> heBeiEightCities;
 
+    private List<SysArea> oneSixEightCities;
+
     public boolean isTwentyEightCities(Integer cityCode){
         for (SysArea city : twentyEightCities) {
             if(city.getAreaCode().equals(cityCode))
diff --git a/screen-api/src/main/java/com/moral/api/controller/BulletinController.java b/screen-api/src/main/java/com/moral/api/controller/BulletinController.java
new file mode 100644
index 0000000..00e2a2c
--- /dev/null
+++ b/screen-api/src/main/java/com/moral/api/controller/BulletinController.java
@@ -0,0 +1,51 @@
+package com.moral.api.controller;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.moral.api.config.properties.BulletinProperties;
+import com.moral.api.config.properties.SpecialCitiesProperties;
+import com.moral.api.service.CityAqiDailyService;
+import com.moral.constant.ResultMessage;
+import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.format.annotation.DateTimeFormat;
+import org.springframework.web.bind.annotation.CrossOrigin;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @ClassName
+ * @Description ������controller
+ * @Author ���������
+ * @Date 2022/3/11 14:53
+ * @Version TODO
+ **/
+@RestController
+@RequestMapping("/bulletin")
+@CrossOrigin(origins = "*", maxAge = 3600)
+public class BulletinController {
+
+    @Autowired
+    CityAqiDailyService cityAqiDailyService;
+    @Autowired
+    BulletinProperties bulletinProperties;
+    @Autowired
+    SpecialCitiesProperties specialCitiesProperties;
+
+    /**
+    * @Description: ���������������������������������������������
+            * @Param: [regionCode, time]
+            * @return: com.moral.constant.ResultMessage
+            * @Author: ���������
+            * @Date: 2022/3/11
+            */
+    @GetMapping("airQualityBulletin")
+    public ResultMessage airQualityBulletin(String regionCode,
+                                            @DateTimeFormat(pattern = "yyyy-MM-dd") Date time) {
+        List<String> strings = cityAqiDailyService.airQualityBulletin(regionCode, time);
+        return ResultMessage.ok(strings);
+    }
+}
diff --git a/screen-api/src/main/java/com/moral/api/service/CityAqiDailyService.java b/screen-api/src/main/java/com/moral/api/service/CityAqiDailyService.java
index 2df895a..caf7754 100644
--- a/screen-api/src/main/java/com/moral/api/service/CityAqiDailyService.java
+++ b/screen-api/src/main/java/com/moral/api/service/CityAqiDailyService.java
@@ -94,5 +94,14 @@
             */
     CityPollutionLevel calculateDaysByTimeAndSysArea(SysArea area, Date startDate, Date endDate);
 
+    /**
+    * @Description: ������������������������
+            * @Param: [regionCode, time]
+            * @return: java.lang.String
+            * @Author: ���������
+            * @Date: 2022/3/11
+            */
+    List<String> airQualityBulletin(String regionCode,Date time);
+
 
 }
diff --git a/screen-api/src/main/java/com/moral/api/service/CityAqiMonthlyService.java b/screen-api/src/main/java/com/moral/api/service/CityAqiMonthlyService.java
index 83688d4..2626ffc 100644
--- a/screen-api/src/main/java/com/moral/api/service/CityAqiMonthlyService.java
+++ b/screen-api/src/main/java/com/moral/api/service/CityAqiMonthlyService.java
@@ -25,4 +25,12 @@
             */
     List<CityAqiMonthly> getCityAqiMonthByRegionCodeAndTime(Integer regionCode, Date startDate,Date endDate);
 
+    /**
+    * @Description: ������������������������������������������
+            * @Param: [regionCode, time]
+            * @return: com.moral.api.entity.CityAqiMonthly
+            * @Author: ���������
+            * @Date: 2022/3/14
+            */
+    CityAqiMonthly getCityAqiMonthByRegionCodeAndTime(Integer regionCode, Date time);
 }
diff --git a/screen-api/src/main/java/com/moral/api/service/impl/CityAqiDailyServiceImpl.java b/screen-api/src/main/java/com/moral/api/service/impl/CityAqiDailyServiceImpl.java
index 2ef07d2..8ee0561 100644
--- a/screen-api/src/main/java/com/moral/api/service/impl/CityAqiDailyServiceImpl.java
+++ b/screen-api/src/main/java/com/moral/api/service/impl/CityAqiDailyServiceImpl.java
@@ -3,10 +3,14 @@
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.moral.api.config.properties.BulletinProperties;
 import com.moral.api.config.properties.SpecialCitiesProperties;
 import com.moral.api.entity.CityAqiDaily;
+import com.moral.api.entity.CityAqiMonthly;
+import com.moral.api.entity.CityAqiYearly;
 import com.moral.api.entity.SysArea;
 import com.moral.api.mapper.CityAqiDailyMapper;
+import com.moral.api.mapper.CityAqiMonthlyMapper;
 import com.moral.api.pojo.dto.cityAQI.CityPollutionLevel;
 import com.moral.api.pojo.dto.cityAQI.MonthlyPollutionLevel;
 import com.moral.api.pojo.dto.cityAQI.PollutionDaysAndProportion;
@@ -18,14 +22,12 @@
 import com.moral.api.service.CityAqiYearlyService;
 import com.moral.api.service.SysAreaService;
 import com.moral.constant.Constants;
-import com.moral.util.AQIUtils;
-import com.moral.util.ComprehensiveIndexUtils;
-import com.moral.util.DateUtils;
-import com.moral.util.MathUtils;
+import com.moral.util.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.util.ObjectUtils;
 
+import java.text.DecimalFormat;
 import java.text.SimpleDateFormat;
 import java.util.*;
 
@@ -46,12 +48,18 @@
     SysAreaService sysAreaService;
     @Autowired
     SpecialCitiesProperties specialCitiesProperties;
+    @Autowired
+    BulletinProperties bulletinProperties;
+    @Autowired
+    CityAqiMonthlyService cityAqiMonthlyService;
+    @Autowired
+    CityAqiYearlyService cityAqiYearlyService;
 
     @Override
     public List<CityAqiDaily> getCityAqiDailyByRegionCodeAndTime(Integer regionCode, Date startDate, Date endDate) {
         QueryWrapper<CityAqiDaily> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("city_code",regionCode);
-        queryWrapper.between("time",startDate,endDate);
+        queryWrapper.eq("city_code", regionCode);
+        queryWrapper.between("time", startDate, endDate);
         return cityAqiDailyMapper.selectList(queryWrapper);
     }
 
@@ -349,14 +357,6 @@
         return datas;
     }
 
-
-    /**
-     * @Description: ���������������������������������������������������������
-     * @Param: [area, startDate, endDate]
-     * @return: com.moral.api.pojo.dto.cityAQI.CityPollutionLevel
-     * @Author: ���������
-     * @Date: 2021/12/31
-     */
     @Override
     public CityPollutionLevel calculateDaysByTimeAndSysArea(SysArea area, Date startDate, Date endDate) {
         //������������
@@ -365,7 +365,7 @@
         wrapper.between("time", startDate, endDate);
         wrapper.orderByAsc("time");
         List<CityAqiDaily> cityAqiDailies = cityAqiDailyMapper.selectList(wrapper);
-        if(ObjectUtils.isEmpty(cityAqiDailies))
+        if (ObjectUtils.isEmpty(cityAqiDailies))
             return null;
         //���������������������������������������
         Map<String, CityAqiDaily> tmpMap = new LinkedHashMap<>();
@@ -404,8 +404,303 @@
         return cityPollutionLevel;
     }
 
+    @Override
+    public List<String> airQualityBulletin(String regionCode, Date time) {
+        List<String> result = new ArrayList<>();
+        //���������������
+        QueryWrapper<CityAqiDaily> dailyWrapper = new QueryWrapper<>();
+        dailyWrapper.eq("city_code", regionCode);
+        dailyWrapper.eq("time", time);
+        CityAqiDaily cityAqiDaily = cityAqiDailyMapper.selectOne(dailyWrapper);
+        if (cityAqiDaily == null)
+            return null;
+        Map<String, Object> dailyDataMap = JSON.parseObject(cityAqiDaily.getValue(), Map.class);
+        //���������������
+        int year = DateUtils.getYear(time);
+        int month = DateUtils.getMonth(time);
+        int day = DateUtils.getDay(time);
+        //������������title
+        String title = getBulletinTitle(month + "", day + "");
+        if (title == null)
+            return null;
+        //���������������������������
+        String paragraphOne = getParagraphOne(month + "", day + "", dailyDataMap);
+        if (paragraphOne == null)
+            return null;
+        //���������������������
+        List<String> paragraphTwoAndFour = getParagraphTwoAndFour(year + "", month + "", day + "", regionCode, time);
+        if(paragraphTwoAndFour==null)
+            return null;
+        String paragraphTwo =  paragraphTwoAndFour.get(0);
+        //���������������������������
+        String paragraphThree = getParagraphThree(month + "", day + "", regionCode, time);
+        if (paragraphThree == null)
+            return null;
+        //���������������������
+        String paragraphFour =  paragraphTwoAndFour.get(1);
+        result.add(title);
+        result.add(paragraphOne);
+        result.add(paragraphTwo);
+        result.add(paragraphThree);
+        result.add(paragraphFour);
+        return result;
+    }
+
+    //������������title������
+    private String getBulletinTitle(String month, String day) {
+        String title = bulletinProperties.getTitle();
+        title = title.replace("{month}", month);
+        title = title.replace("{day}", day);
+        return title;
+    }
+
+    //���������������������������
+    private String getParagraphOne(String month, String day, Map<String, Object> dailyData) {
+        //������������������
+        String pollutionLevelDescribe = AQIUtils.classOfPollutionByAqi(Integer.parseInt(dailyData.get("AQI").toString()));
+        String pollutionLevel = AQIUtils.classCodeOfPollutionByAqi(Integer.parseInt(dailyData.get("AQI").toString()));
+        //���������������������������
+        int standardCount = AQIUtils.standardCount(dailyData);
+        String paragraphOne = bulletinProperties.getParagraphOne();
+        paragraphOne = paragraphOne.replace("{month}", month);
+        paragraphOne = paragraphOne.replace("{day}", day);
+        paragraphOne = paragraphOne.replace("{pollutionLevel}", pollutionLevel);
+        paragraphOne = paragraphOne.replace("{pollutionLevelDescribe}", pollutionLevelDescribe);
+        paragraphOne = paragraphOne.replace("{standardCount}", standardCount + "");
+        paragraphOne = paragraphOne.replace("{PM2.5}", dailyData.get("PM2_5").toString());
+        paragraphOne = paragraphOne.replace("{SO2}", dailyData.get("SO2").toString());
+        paragraphOne = paragraphOne.replace("{NO2}", dailyData.get("NO2").toString());
+        paragraphOne = paragraphOne.replace("{CO}", dailyData.get("CO").toString());
+        paragraphOne = paragraphOne.replace("{O3}", dailyData.get("O3").toString());
+        paragraphOne = paragraphOne.replace("{PM10}", dailyData.get("PM10").toString());
+        return paragraphOne;
+    }
+
+    //���������������������������������������
+    private List<String> getParagraphTwoAndFour(String year, String month, String day, String regionCode, Date time) {
+        List<String> result = new ArrayList<>();
+        String paragraphTwo = bulletinProperties.getParagraphTwo();
+        String paragraphFour = bulletinProperties.getParagraphFour();
+        Date startTime = DateUtils.getFirstDayOfYear(time);
+        Date endTime = time;
+        Date compareStartTime = DateUtils.addMonths(startTime, -12);
+        Date compareEndTime = DateUtils.addMonths(endTime, -12);
+        SysArea area = new SysArea();
+        area.setAreaCode(Integer.parseInt(regionCode));
+        //������������������������
+        CityPollutionLevel days = calculateDaysByTimeAndSysArea(area, startTime, endTime);
+        //������������������������������
+        CityPollutionLevel compareDays = calculateDaysByTimeAndSysArea(area, compareStartTime, compareEndTime);
+        //������������������
+        List<CityAqiYearly> yearDataList = cityAqiYearlyService.getCityAqiYearlyByRegionCodeAndTime(Integer.parseInt(regionCode), startTime, endTime);
+        List<CityAqiYearly> compareYearDataList = cityAqiYearlyService.getCityAqiYearlyByRegionCodeAndTime(Integer.parseInt(regionCode), compareStartTime, compareEndTime);
+        if (ObjectUtils.isEmpty(yearDataList) || ObjectUtils.isEmpty(compareYearDataList))
+            return null;
+        CityAqiYearly yearData = yearDataList.get(0);
+        CityAqiYearly compareYearData = compareYearDataList.get(0);
+        Map<String, Object> dataMap = JSON.parseObject(yearData.getValue(), Map.class);
+        Map<String, Object> compareDataMap = JSON.parseObject(compareYearData.getValue(), Map.class);
+        //���������������������
+        String yearPM_5 = dataMap.get("PM2_5").toString();
+        String fineDays = days.getExcellentWeatherDays() + days.getGoodWeatherDays() + "";
+        int allDays = DateUtils.getDays(startTime, endTime)+1;
+        paragraphTwo = paragraphTwo.replace("{year}", year);
+        paragraphTwo = paragraphTwo.replace("{yearPM2.5}", yearPM_5);
+        paragraphTwo = paragraphTwo.replace("{fineDays}", fineDays);
+        paragraphTwo = paragraphTwo.replace("{days}", allDays + "");
+        result.add(paragraphTwo);
+
+        //���������������������
+        //������������������������
+        Double compositeIndex = Double.valueOf(dataMap.get("compositeIndex").toString());
+        Double compareCompositeIndex = Double.valueOf(compareDataMap.get("compositeIndex").toString());
+        //������������������������������������
+        String yoyYearCompositeIndexUpDown = getUpOrDown(compositeIndex, compareCompositeIndex);
+        //������������������������������������������
+        String yoyYearCompositeIndex = calculateComparePerPositive(compositeIndex, compareCompositeIndex).toString();
+
+        //������������PM2.5
+        Double PM2_5 = Double.valueOf(dataMap.get("PM2_5").toString());
+        Double comparePM2_5 = Double.valueOf(compareDataMap.get("PM2_5").toString());
+        //������PM2.5������������������
+        String yoyYearPM2_5UpDown = getUpOrDown(PM2_5, comparePM2_5);
+        //������PM2.5������������������������
+        String yoyYearPM2_5 = calculateComparePerPositive(PM2_5, comparePM2_5).toString();
+
+        //������������������������
+        int yearFineDays = days.getExcellentWeatherDays() + days.getGoodWeatherDays();
+        //������������������������������
+        int compareYearFineDays = compareDays.getExcellentWeatherDays() + days.getGoodWeatherDays();
+        //������������������������
+        int yoyYearFineDaysInt = yearFineDays - compareYearFineDays;
+        String yoyYearFineDays = yoyYearFineDaysInt > 0 ? yoyYearFineDaysInt + "" : yoyYearFineDaysInt * (-1) + "";
+        //���������������������������������
+        String yoyYearFineDaysUpDown = getIncreaseOrDecrease(yearFineDays, compareYearFineDays);
+        //������������������������
+        int yearPollutionDays = days.getMildWeatherDays() + days.getMiddleWeatherDays() + days.getSeriousWeatherDays() + days.getServerWeatherDays();
+        //������������������������������
+        String yearFineDaysPer = String.valueOf(MathUtils.division(yearFineDays*100 ,allDays,2));
+
+        //������168������������������������������������������������������
+        List<Integer> oneSixEightRanges = rangeByCities(compositeIndex,
+                calculateCompare(compositeIndex, compareCompositeIndex),
+                startTime, endTime, compareStartTime, compareEndTime,
+                specialCitiesProperties.getOneSixEightCities());
+
+        //������28������������������������������������������������������
+        List<Integer> twentyEightRanges = rangeByCities(compositeIndex,
+                calculateCompare(compositeIndex, compareCompositeIndex),
+                startTime, endTime, compareStartTime, compareEndTime,
+                specialCitiesProperties.getTwentyEightCities());
+
+        String compositeIndex28range = twentyEightRanges.get(0).toString();
+        String compositeIndexPer28range = twentyEightRanges.get(1).toString();
+        String compositeIndex168range = oneSixEightRanges.get(0).toString();
+        String compositeIndexPer168range = oneSixEightRanges.get(1).toString();
+        //������������������
+        paragraphFour = paragraphFour.replace("{month}",month);
+        paragraphFour = paragraphFour.replace("{day}",day);
+        paragraphFour = paragraphFour.replace("{yearCompositeIndex}",compositeIndex+"");
+        paragraphFour = paragraphFour.replace("{yoyYearCompositeIndex}",yoyYearCompositeIndex);
+        paragraphFour = paragraphFour.replace("{yoyYearCompositeIndexUpDown}",yoyYearCompositeIndexUpDown);
+        paragraphFour = paragraphFour.replace("{yearPM2.5}",PM2_5+"");
+        paragraphFour = paragraphFour.replace("{yoyYearPM2.5UpDown}",yoyYearPM2_5UpDown);
+        paragraphFour = paragraphFour.replace("{yoyYearPM2.5}",yoyYearPM2_5);
+        paragraphFour = paragraphFour.replace("{yearFineDays}",yearFineDays+"");
+        paragraphFour = paragraphFour.replace("{yearFineDaysPer}",yearFineDaysPer);
+        paragraphFour = paragraphFour.replace("{yearPollutionDays}",yearPollutionDays+"");
+        paragraphFour = paragraphFour.replace("{yoyYearFineDaysUpDown}",yoyYearFineDaysUpDown);
+        paragraphFour = paragraphFour.replace("{yoyYearFineDays}",yoyYearFineDays);
+        paragraphFour = paragraphFour.replace("{compositeIndex28range}",compositeIndex28range);
+        paragraphFour = paragraphFour.replace("{compositeIndexPer28range}",compositeIndexPer28range);
+        paragraphFour = paragraphFour.replace("{compositeIndex168range}",compositeIndex168range);
+        paragraphFour = paragraphFour.replace("{compositeIndexPer168range}",compositeIndexPer168range);
+        result.add(paragraphFour);
+        return result;
+    }
+
+    //������������������������������������������������������
+    private List<Integer> rangeByCities(
+                         Double compositeIndex,
+                         Double compositeIndexPer,
+                         Date startTime,
+                         Date endTime,
+                         Date compareStartTime,
+                         Date compareEndTime, List<SysArea> areas){
+        List<Double> compositeIndexList = new ArrayList<>();
+        List<Double> compositePerList = new ArrayList<>();
+        for (SysArea sysArea : areas) {
+            //������������
+            List<CityAqiYearly> data = cityAqiYearlyService.getCityAqiYearlyByRegionCodeAndTime(sysArea.getAreaCode(), startTime, endTime);
+            //������������������
+            List<CityAqiYearly> compareData = cityAqiYearlyService.getCityAqiYearlyByRegionCodeAndTime(sysArea.getAreaCode(), compareStartTime, compareEndTime);
+            if(ObjectUtils.isEmpty(data)||ObjectUtils.isEmpty(compareData))
+                continue;
+            Map<String,Object> dataMap = JSON.parseObject(data.get(0).getValue(),Map.class);
+            Map<String,Object> compareDataMap = JSON.parseObject(compareData.get(0).getValue(),Map.class);
+            //������������������
+            compositeIndexList.add(Double.valueOf(dataMap.get("compositeIndex").toString()));
+            //���������������������������
+            Double per = calculateCompare(Double.valueOf(dataMap.get("compositeIndex").toString()),Double.valueOf(compareDataMap.get("compositeIndex").toString()));
+            compositePerList.add(per);
+        }
+        Collections.sort(compositeIndexList);
+        Collections.sort(compositePerList);
+        Integer compositeIndexRange = compositeIndexList.indexOf(compositeIndex);
+        Integer compositePerRange = compositePerList.indexOf(compositeIndexPer);
+        return Arrays.asList((compositeIndexRange+1),(compositePerRange+1));
+    }
+
+    //���������������������������
+    private String getParagraphThree(String month, String day, String regionCode, Date time) {
+        String paragraphThree = bulletinProperties.getParagraphThree();
+        //������������������������
+        CityAqiMonthly monthlyData = cityAqiMonthlyService.getCityAqiMonthByRegionCodeAndTime(Integer.parseInt(regionCode), time);
+        //������������������������
+        Date compareTime = DateUtils.addMonths(time, -12);
+        CityAqiMonthly compareMonthlyData = cityAqiMonthlyService.getCityAqiMonthByRegionCodeAndTime(Integer.parseInt(regionCode), compareTime);
+        if (monthlyData == null || compareMonthlyData == null)
+            return null;
+        Map<String, Object> monthlyDataMap = JSON.parseObject(monthlyData.getValue(), Map.class);
+        Map<String, Object> compareMonthlyDataMap = JSON.parseObject(compareMonthlyData.getValue(), Map.class);
+        //������������������
+        Date endTime = time;
+        Date startTime = DateUtils.getFirstDayOfMonth(time);
+        Date compareStartTime = DateUtils.addMonths(startTime, -12);
+        Date compareEndTime = DateUtils.addMonths(endTime, -12);
+        SysArea area = new SysArea();
+        area.setAreaCode(Integer.parseInt(regionCode));
+        CityPollutionLevel days = calculateDaysByTimeAndSysArea(area, startTime, endTime);
+        CityPollutionLevel compareDays = calculateDaysByTimeAndSysArea(area, compareStartTime, compareEndTime);
+        if (days == null || compareDays == null)
+            return null;
+        //������������������������
+        Double compositeIndex = Double.valueOf(monthlyDataMap.get("compositeIndex").toString());
+        Double compareCompositeIndex = Double.valueOf(compareMonthlyDataMap.get("compositeIndex").toString());
+        //������������������������������������
+        String yoyMonthCompositeIndexUpDown = getUpOrDown(compositeIndex, compareCompositeIndex);
+        //������������������������������������������
+        String yoyMonthCompositeIndex = calculateComparePerPositive(compositeIndex, compareCompositeIndex).toString();
+
+        //������������PM2.5
+        Double PM2_5 = Double.valueOf(monthlyDataMap.get("PM2_5").toString());
+        Double comparePM2_5 = Double.valueOf(compareMonthlyDataMap.get("PM2_5").toString());
+        //������PM2.5������������������
+        String yoyMonthPM2_5UpDown = getUpOrDown(PM2_5, comparePM2_5);
+        //������PM2.5������������������������
+        String yoyMonthPM2_5 = calculateComparePerPositive(PM2_5, comparePM2_5).toString();
+
+        //������������������������
+        int monthFineDays = days.getExcellentWeatherDays() + days.getGoodWeatherDays();
+        //������������������������������
+        int compareMonthFineDays = compareDays.getExcellentWeatherDays() + days.getGoodWeatherDays();
+        //������������������������
+        int yoyMonthFineDaysInt = monthFineDays - compareMonthFineDays;
+        String yoyMonthFineDays = yoyMonthFineDaysInt > 0 ? yoyMonthFineDaysInt + "" : yoyMonthFineDaysInt * (-1) + "";
+        //���������������������������������
+        String yoyMonthFineDaysUpDown = getIncreaseOrDecrease(monthFineDays, compareMonthFineDays);
+
+        paragraphThree = paragraphThree.replace("{month}", month);
+        paragraphThree = paragraphThree.replace("{day}", day);
+        paragraphThree = paragraphThree.replace("{monthCompositeIndex}", compositeIndex.toString());
+        paragraphThree = paragraphThree.replace("{yoyMonthCompositeIndex}", yoyMonthCompositeIndex);
+        paragraphThree = paragraphThree.replace("{yoyMonthCompositeIndexUpDown}", yoyMonthCompositeIndexUpDown);
+        paragraphThree = paragraphThree.replace("{monthPM2.5}", PM2_5.toString());
+        paragraphThree = paragraphThree.replace("{yoyMonthPM2.5UpDown}", yoyMonthPM2_5UpDown);
+        paragraphThree = paragraphThree.replace("{yoyMonthPM2.5}", yoyMonthPM2_5);
+        paragraphThree = paragraphThree.replace("{monthFineDays}", monthFineDays + "");
+        paragraphThree = paragraphThree.replace("{yoyMonthFineDaysUpDown}", yoyMonthFineDaysUpDown);
+        paragraphThree = paragraphThree.replace("{yoyMonthFineDays}", yoyMonthFineDays);
+        return paragraphThree;
+    }
+
+    //������currentData���compareData���������������"������","������".currentData>compareData���������������
+    private String getUpOrDown(Double currentData, Double compareData) {
+        if (MathUtils.sub(currentData, compareData) > 0)
+            return "������";
+        return "������";
+    }
+
+    //������������������������������������������������������������"������","������".currentData>compareData���������������
+    private String getIncreaseOrDecrease(int currentDays, int compareDays) {
+        if (currentDays - compareDays > 0)
+            return "������";
+        return "������";
+    }
 
 
+    //������������������/������������ ���������������������-���������������/������������ ���������������
+    private Double calculateComparePerPositive(Double currentData, Double compareData) {
+        double tmp1 = MathUtils.sub(currentData, compareData);
+        double result = MathUtils.mul(MathUtils.division(tmp1, compareData, 4),100d);
+        return result > 0 ? result : MathUtils.mul(result, -1d);
+    }
+
+    //������������������/������������ ���������������������-���������������/������������ ���������������
+    private Double calculateCompare(Double currentData, Double compareData) {
+        double tmp1 = MathUtils.sub(currentData, compareData);
+        return MathUtils.mul(MathUtils.division(tmp1, compareData, 4),100d);
+    }
 
 
 }
diff --git a/screen-api/src/main/java/com/moral/api/service/impl/CityAqiMonthlyServiceImpl.java b/screen-api/src/main/java/com/moral/api/service/impl/CityAqiMonthlyServiceImpl.java
index e0be3d1..5806e82 100644
--- a/screen-api/src/main/java/com/moral/api/service/impl/CityAqiMonthlyServiceImpl.java
+++ b/screen-api/src/main/java/com/moral/api/service/impl/CityAqiMonthlyServiceImpl.java
@@ -5,9 +5,12 @@
 import com.moral.api.mapper.CityAqiMonthlyMapper;
 import com.moral.api.service.CityAqiMonthlyService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.moral.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.io.*;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 
@@ -32,4 +35,14 @@
         queryWrapper.between("time",startDate,endDate);
         return cityAqiMonthlyMapper.selectList(queryWrapper);
     }
+
+    @Override
+    public CityAqiMonthly getCityAqiMonthByRegionCodeAndTime(Integer regionCode, Date time){
+        time = DateUtils.getFirstDayOfMonth(time);
+        QueryWrapper<CityAqiMonthly> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("city_code",regionCode);
+        queryWrapper.eq("time",time);
+        return cityAqiMonthlyMapper.selectOne(queryWrapper);
+    }
+
 }
diff --git a/screen-api/src/main/resources/application-bulletin.yml b/screen-api/src/main/resources/application-bulletin.yml
new file mode 100644
index 0000000..ce2e9fc
--- /dev/null
+++ b/screen-api/src/main/resources/application-bulletin.yml
@@ -0,0 +1,6 @@
+bulletin:
+  title: "{month}���{day}���������������������������"
+  paragraphOne: "{month}���{day}���������������������������{pollutionLevel}���,{pollutionLevelDescribe}������������6������������{standardCount}������������PM10���{PM10}��g/m��������������150��g/m��������PM2.5���{PM2.5}��g/m��������������75��g/m��������SO2���{SO2}��g/m��������������150��g/m��������NO2���{NO2}��g/m��������������80��g/m��������CO���{CO}mg/m��������������4mg/m��������O3-8H���{O3}��g/m��������������160��g/m��������"
+  paragraphTwo: "������������ PM2.5 ���{yearPM2.5}mg/m��������������{fineDays}������������������{days}������"
+  paragraphThree: "���������������{month}���1���-{day}���������������������������������������{monthCompositeIndex}���������{yoyMonthCompositeIndexUpDown}{yoyMonthCompositeIndex}%���PM2.5���������������{monthPM2.5}��g/m3���������{yoyMonthPM2.5UpDown}{yoyMonthPM2.5}%������������������{monthFineDays}���������������������������{yoyMonthFineDaysUpDown} {yoyMonthFineDays}������"
+  paragraphFour: "���������������1���1���-{month}���{day}������������������������������������������{yearCompositeIndex}���������{yoyYearCompositeIndexUpDown} {yoyYearCompositeIndex}%���PM2.5���������������{yearPM2.5}��g/m�����������{yoyYearPM2.5UpDown}{yoyYearPM2.5}%���������2021���������������������������{yearFineDays}���������������������{yearFineDaysPer}%������������{yearPollutionDays}���������������������������������������{yoyYearFineDaysUpDown}{yoyYearFineDays}������������������������2+26������������������{compositeIndex28range}������������������������������{compositeIndexPer28range}������������168������������������{compositeIndex168range}������������������������������{compositeIndexPer168range}������"
\ No newline at end of file
diff --git a/screen-api/src/main/resources/application-dev.yml b/screen-api/src/main/resources/application-dev.yml
index 49177d8..e9b1136 100644
--- a/screen-api/src/main/resources/application-dev.yml
+++ b/screen-api/src/main/resources/application-dev.yml
@@ -13,7 +13,7 @@
 spring:
   profiles:
     active: dev
-    include: specialCity
+    include: bulletin,specialCity
   application:
     name: screen-api
   redis:
diff --git a/screen-api/src/main/resources/application-specialCity.yml b/screen-api/src/main/resources/application-specialCity.yml
index ac19837..06d2f57 100644
--- a/screen-api/src/main/resources/application-specialCity.yml
+++ b/screen-api/src/main/resources/application-specialCity.yml
@@ -73,6 +73,346 @@
       areaName: ���������
     - areaCode: 130200
       areaName: ���������
+  oneSixEightCities:
+    - areaCode: 110000
+      areaName: ���������
+    - areaCode: 120000
+      areaName: ���������
+    - areaCode: 130100
+      areaName: ������������
+    - areaCode: 130200
+      areaName: ���������
+    - areaCode: 130300
+      areaName: ������������
+    - areaCode: 130400
+      areaName: ���������
+    - areaCode: 130500
+      areaName: ���������
+    - areaCode: 130600
+      areaName: ���������
+    - areaCode: 130700
+      areaName: ������������
+    - areaCode: 130800
+      areaName: ���������
+    - areaCode: 130900
+      areaName: ���������
+    - areaCode: 131000
+      areaName: ���������
+    - areaCode: 131100
+      areaName: ���������
+    - areaCode: 140100
+      areaName: ���������
+    - areaCode: 140200
+      areaName: ���������
+    - areaCode: 140600
+      areaName: ���������
+    - areaCode: 140900
+      areaName: ���������
+    - areaCode: 140300
+      areaName: ���������
+    - areaCode: 140400
+      areaName: ���������
+    - areaCode: 140500
+      areaName: ���������
+    - areaCode: 370100
+      areaName: ���������
+    - areaCode: 370200
+      areaName: ���������
+    - areaCode: 370300
+      areaName: ���������
+    - areaCode: 370400
+      areaName: ���������
+    - areaCode: 370500
+      areaName: ���������
+    - areaCode: 370700
+      areaName: ���������
+    - areaCode: 370800
+      areaName: ���������
+    - areaCode: 370900
+      areaName: ���������
+    - areaCode: 371100
+      areaName: ���������
+    - areaCode: 371300
+      areaName: ���������
+    - areaCode: 371400
+      areaName: ���������
+    - areaCode: 371500
+      areaName: ���������
+    - areaCode: 371600
+      areaName: ���������
+    - areaCode: 371700
+      areaName: ���������
+    - areaCode: 410100
+      areaName: ���������
+    - areaCode: 410200
+      areaName: ���������
+    - areaCode: 410400
+      areaName: ������������
+    - areaCode: 410500
+      areaName: ���������
+    - areaCode: 410600
+      areaName: ���������
+    - areaCode: 410700
+      areaName: ���������
+    - areaCode: 410800
+      areaName: ���������
+    - areaCode: 410900
+      areaName: ���������
+    - areaCode: 411000
+      areaName: ���������
+    - areaCode: 411100
+      areaName: ���������
+    - areaCode: 411300
+      areaName: ���������
+    - areaCode: 411400
+      areaName: ���������
+    - areaCode: 411500
+      areaName: ���������
+    - areaCode: 411600
+      areaName: ���������
+    - areaCode: 411700
+      areaName: ������������
+    - areaCode: 150100
+      areaName: ���������������
+    - areaCode: 150200
+      areaName: ���������
+    - areaCode: 211300
+      areaName: ���������
+    - areaCode: 210700
+      areaName: ���������
+    - areaCode: 211400
+      areaName: ������������
+    - areaCode: 310000
+      areaName: ���������
+    - areaCode: 320100
+      areaName: ���������
+    - areaCode: 320200
+      areaName: ���������
+    - areaCode: 320300
+      areaName: ���������
+    - areaCode: 320400
+      areaName: ���������
+    - areaCode: 320500
+      areaName: ���������
+    - areaCode: 320600
+      areaName: ���������
+    - areaCode: 320700
+      areaName: ������������
+    - areaCode: 320800
+      areaName: ���������
+    - areaCode: 320900
+      areaName: ���������
+    - areaCode: 321000
+      areaName: ���������
+    - areaCode: 321100
+      areaName: ���������
+    - areaCode: 321200
+      areaName: ���������
+    - areaCode: 321300
+      areaName: ���������
+    - areaCode: 330100
+      areaName: ���������
+    - areaCode: 330200
+      areaName: ���������
+    - areaCode: 330300
+      areaName: ���������
+    - areaCode: 330600
+      areaName: ���������
+    - areaCode: 330500
+      areaName: ���������
+    - areaCode: 330400
+      areaName: ���������
+    - areaCode: 330700
+      areaName: ���������
+    - areaCode: 330800
+      areaName: ���������
+    - areaCode: 331000
+      areaName: ���������
+    - areaCode: 331100
+      areaName: ���������
+    - areaCode: 330900
+      areaName: ���������
+    - areaCode: 340100
+      areaName: ���������
+    - areaCode: 340200
+      areaName: ���������
+    - areaCode: 340300
+      areaName: ���������
+    - areaCode: 340400
+      areaName: ���������
+    - areaCode: 340500
+      areaName: ������������
+    - areaCode: 340600
+      areaName: ���������
+    - areaCode: 340700
+      areaName: ���������
+    - areaCode: 340800
+      areaName: ���������
+    - areaCode: 341000
+      areaName: ���������
+    - areaCode: 341200
+      areaName: ���������
+    - areaCode: 341300
+      areaName: ���������
+    - areaCode: 341100
+      areaName: ���������
+    - areaCode: 341500
+      areaName: ���������
+    - areaCode: 341800
+      areaName: ���������
+    - areaCode: 341700
+      areaName: ���������
+    - areaCode: 341600
+      areaName: ���������
+    - areaCode: 141100
+      areaName: ���������
+    - areaCode: 140700
+      areaName: ���������
+    - areaCode: 141000
+      areaName: ���������
+    - areaCode: 140800
+      areaName: ���������
+    - areaCode: 410300
+      areaName: ���������
+    - areaCode: 411200
+      areaName: ������������
+    - areaCode: 220403
+      areaName: ���������
+    - areaCode: 610400
+      areaName: ���������
+    - areaCode: 610300
+      areaName: ���������
+    - areaCode: 610200
+      areaName: ���������
+    - areaCode: 610500
+      areaName: ���������
+    - areaCode: 500000
+      areaName: ���������
+    - areaCode: 510100
+      areaName: ���������
+    - areaCode: 510300
+      areaName: ���������
+    - areaCode: 510500
+      areaName: ���������
+    - areaCode: 510600
+      areaName: ���������
+    - areaCode: 510700
+      areaName: ���������
+    - areaCode: 510900
+      areaName: ���������
+    - areaCode: 511000
+      areaName: ���������
+    - areaCode: 511100
+      areaName: ���������
+    - areaCode: 511181
+      areaName: ������������
+    - areaCode: 511500
+      areaName: ���������
+    - areaCode: 511800
+      areaName: ���������
+    - areaCode: 512000
+      areaName: ���������
+    - areaCode: 511300
+      areaName: ���������
+    - areaCode: 511600
+      areaName: ���������
+    - areaCode: 511700
+      areaName: ���������
+    - areaCode: 421200
+      areaName: ���������
+    - areaCode: 420900
+      areaName: ���������
+    - areaCode: 421100
+      areaName: ���������
+    - areaCode: 420100
+      areaName: ���������
+    - areaCode: 420200
+      areaName: ���������
+    - areaCode: 420700
+      areaName: ���������
+    - areaCode: 420600
+      areaName: ���������
+    - areaCode: 420500
+      areaName: ���������
+    - areaCode: 420800
+      areaName: ���������
+    - areaCode: 421000
+      areaName: ���������
+    - areaCode: 421300
+      areaName: ���������
+    - areaCode: 360100
+      areaName: ���������
+    - areaCode: 360300
+      areaName: ���������
+    - areaCode: 360500
+      areaName: ���������
+    - areaCode: 360900
+      areaName: ���������
+    - areaCode: 360400
+      areaName: ���������
+    - areaCode: 430100
+      areaName: ���������
+    - areaCode: 430200
+      areaName: ���������
+    - areaCode: 430300
+      areaName: ���������
+    - areaCode: 430600
+      areaName: ���������
+    - areaCode: 430700
+      areaName: ���������
+    - areaCode: 430900
+      areaName: ���������
+    - areaCode: 440100
+      areaName: ���������
+    - areaCode: 440300
+      areaName: ���������
+    - areaCode: 440400
+      areaName: ���������
+    - areaCode: 440600
+      areaName: ���������
+    - areaCode: 440700
+      areaName: ���������
+    - areaCode: 441200
+      areaName: ���������
+    - areaCode: 441300
+      areaName: ���������
+    - areaCode: 441900
+      areaName: ���������
+    - areaCode: 442000
+      areaName: ���������
+    - areaCode: 210100
+      areaName: ���������
+    - areaCode: 210200
+      areaName: ���������
+    - areaCode: 220100
+      areaName: ���������
+    - areaCode: 230100
+      areaName: ������������
+    - areaCode: 350100
+      areaName: ���������
+    - areaCode: 350200
+      areaName: ���������
+    - areaCode: 450100
+      areaName: ���������
+    - areaCode: 460100
+      areaName: ���������
+    - areaCode: 520100
+      areaName: ���������
+    - areaCode: 530100
+      areaName: ���������
+    - areaCode: 540100
+      areaName: ���������
+    - areaCode: 620100
+      areaName: ���������
+    - areaCode: 630100
+      areaName: ���������
+    - areaCode: 640100
+      areaName: ���������
+    - areaCode: 650100
+      areaName: ���������������
+
+
+
 
 
 
diff --git a/screen-common/src/main/java/com/moral/constant/Constants.java b/screen-common/src/main/java/com/moral/constant/Constants.java
index 5e7f627..37f82fb 100644
--- a/screen-common/src/main/java/com/moral/constant/Constants.java
+++ b/screen-common/src/main/java/com/moral/constant/Constants.java
@@ -266,17 +266,17 @@
 
     public static final String SERVER_WEATHER = "������������";
 
-    public static final String EXCELLENT_WEATHER_CODE = "0";
+    public static final String EXCELLENT_WEATHER_CODE = "1";
 
-    public static final String GOOD_WEATHER_CODE = "1";
+    public static final String GOOD_WEATHER_CODE = "2";
 
-    public static final String MILD_WEATHER_CODE = "2";
+    public static final String MILD_WEATHER_CODE = "3";
 
-    public static final String MIDDLE_WEATHER_CODE = "3";
+    public static final String MIDDLE_WEATHER_CODE = "4";
 
-    public static final String SERIOUS_WEATHER_CODE = "4";
+    public static final String SERIOUS_WEATHER_CODE = "5";
 
-    public static final String SERVER_WEATHER_CODE = "5";
+    public static final String SERVER_WEATHER_CODE = "6";
 
     /*
      * ������������
diff --git a/screen-common/src/main/java/com/moral/util/AQIUtils.java b/screen-common/src/main/java/com/moral/util/AQIUtils.java
index 982af88..ea45313 100644
--- a/screen-common/src/main/java/com/moral/util/AQIUtils.java
+++ b/screen-common/src/main/java/com/moral/util/AQIUtils.java
@@ -24,6 +24,25 @@
     /*���������������������*/
     private static Double[] IAQI_Array = new Double[]{0d,50d,100d,150d,200d,300d,400d,500d};
 
+
+    //������6���������������������
+    public static int standardCount(Map<String,Object> data){
+        int count = 0;
+        if(data.get("PM2_5")!=null&&PM2_5IsStandard(Double.valueOf(data.get("PM2_5").toString())))
+            count++;
+        if(data.get("PM10")!=null&&PM10IsStandard(Double.valueOf(data.get("PM10").toString())))
+            count++;
+        if(data.get("SO2")!=null&&SO2IsStandard(Double.valueOf(data.get("SO2").toString())))
+            count++;
+        if(data.get("NO2")!=null&&NO2IsStandard(Double.valueOf(data.get("NO2").toString())))
+            count++;
+        if(data.get("CO")!=null&&COIsStandard(Double.valueOf(data.get("CO").toString())))
+            count++;
+        if(data.get("O3")!=null&&O3IsStandard(Double.valueOf(data.get("O3").toString())))
+            count++;
+        return count;
+    }
+
     //������aqi������������
     public static boolean aqiIsStandard(int aqi){
         if(aqi<=100)

--
Gitblit v1.8.0