jinpengyong
2021-11-03 9485a0cb33bb4535bb553a5bf49debeadbe0c89d
screen-api/src/main/java/com/moral/api/service/impl/CityAqiServiceImpl.java
@@ -22,6 +22,7 @@
import com.moral.util.DateUtils;
import com.moral.util.MathUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
@@ -352,6 +353,10 @@
        sortByField(ranks, "aqi");
        //日排名结果
        Map<String, Object> dayMap = rankByField(ranks, cityCode, "aqi", cityCodes.size());
        if (ObjectUtils.isEmpty(dayMap)) {
            dayMap.put("rank", null);
            dayMap.put("size", null);
        }
        dayMap.put("aqi", dayMap.remove("value"));
        result.put("day", dayMap);
@@ -360,15 +365,22 @@
        sortByField(ranks, "compositeIndexMonth");
        //月排名结果
        Map<String, Object> monthMap = rankByField(ranks, cityCode, "compositeIndexMonth", cityCodes.size());
        if (ObjectUtils.isEmpty(monthMap)) {
            monthMap.put("rank", null);
            monthMap.put("size", null);
        }
        monthMap.put("compositeIndex", monthMap.remove("value"));
        result.put("month", monthMap);
        //年排名,按累计综指排
        sortByField(ranks, "compositeIndexYear");
        //年排名结果
        sortByField(ranks, "compositeIndexYear");
        Map<String, Object> yearMap = rankByField(ranks, cityCode, "compositeIndexYear", cityCodes.size());
        if (ObjectUtils.isEmpty(yearMap)) {
            yearMap.put("rank", null);
            yearMap.put("size", null);
        }
        yearMap.put("compositeIndex", yearMap.remove("value"));
        result.put("year", yearMap);