综合评估功能调整
This commit is contained in:
@@ -41,7 +41,7 @@ public interface IGridService {
|
||||
List<AssessDetailVo> getData(AssessParam param);
|
||||
|
||||
/**
|
||||
* 综合评估趋势数据(当前时间统计前三个月时间)
|
||||
* 综合评估趋势数据(当前时间统计前五个月时间、或者前五年)
|
||||
*/
|
||||
List<AssessVo.AssessTrendVo> getAssessTrend(AssessParam param);
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.njcn.harmonic.pojo.vo.hebeinorth.EvaluationLevelVo;
|
||||
import com.njcn.harmonic.pojo.vo.hebeinorth.EvaluationVo;
|
||||
import com.njcn.harmonic.service.hebeinorth.IGridService;
|
||||
import com.njcn.harmonic.util.ComAssesUtil;
|
||||
import com.njcn.harmonic.util.TimeUtil;
|
||||
import com.njcn.system.enums.DicDataEnum;
|
||||
import com.njcn.user.api.DeptFeignClient;
|
||||
import com.njcn.user.pojo.dto.DeptDTO;
|
||||
@@ -33,6 +34,7 @@ import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.Year;
|
||||
import java.time.YearMonth;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
@@ -176,14 +178,24 @@ public class GridServiceImpl implements IGridService {
|
||||
Map<String,List<LineDetail>> lineDetailMap = lineDetailList.stream().collect(Collectors.groupingBy(LineDetail::getActualArea));
|
||||
//获取部门
|
||||
List<DeptDTO> deptList = deptFeignClient.getDepSonDetailByDeptId(param.getDeptIndex()).getData();
|
||||
//根据传入的参数,获取返回的月份
|
||||
List<YearMonth> monthList = this.getLastThreeMonth(3);
|
||||
monthList.forEach(month->{
|
||||
String firstDayOfMonth = month.atDay(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||
String lastDayOfMonth = month.atEndOfMonth().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||
List<PQSComAssesPO> comAssesList = rStatComassesDMapper.getAvgCount(lineList,firstDayOfMonth,lastDayOfMonth);
|
||||
map.put(month.toString(),comAssesList);
|
||||
});
|
||||
//按月、年来展示数据
|
||||
if (Objects.equals(param.getType(),1)) {
|
||||
List<Integer> yearList = TimeUtil.getLastFiveYear(2);
|
||||
yearList.forEach(year->{
|
||||
String firstDayOfYear = TimeUtil.getYearFirst(year);
|
||||
String lastDayOfYear = TimeUtil.getYearLast(year);
|
||||
List<PQSComAssesPO> comAssesList = rStatComassesDMapper.getAvgCount(lineList,firstDayOfYear,lastDayOfYear);
|
||||
map.put(year.toString(),comAssesList);
|
||||
});
|
||||
} else if (Objects.equals(param.getType(),3)){
|
||||
List<YearMonth> monthList = TimeUtil.getLastThreeMonth(5);
|
||||
monthList.forEach(month->{
|
||||
String firstDayOfMonth = month.atDay(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||
String lastDayOfMonth = month.atEndOfMonth().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||
List<PQSComAssesPO> comAssesList = rStatComassesDMapper.getAvgCount(lineList,firstDayOfMonth,lastDayOfMonth);
|
||||
map.put(month.toString(),comAssesList);
|
||||
});
|
||||
}
|
||||
//数据处理
|
||||
deptList.forEach(item->{
|
||||
if (lineDetailMap.containsKey(item.getArea())) {
|
||||
@@ -365,7 +377,7 @@ public class GridServiceImpl implements IGridService {
|
||||
// 获取当前年份
|
||||
int currentYear = currentDate.getYear();
|
||||
LocalDate beginDay = LocalDate.of(currentYear, 1, 1);
|
||||
List<YearMonth> monthList = getMonthsBetween(beginDay,currentDate);
|
||||
List<YearMonth> monthList = TimeUtil.getMonthsBetween(beginDay,currentDate);
|
||||
for (YearMonth month : monthList) {
|
||||
String firstDayOfMonth = month.atDay(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||
String lastDayOfMonth = month.atEndOfMonth().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||
@@ -775,28 +787,21 @@ public class GridServiceImpl implements IGridService {
|
||||
}else if(f4<value&&value<=f5){
|
||||
level="良好";
|
||||
}else if(f5<value&&value<=f6){
|
||||
level="轻度污染";
|
||||
// level="轻度污染";
|
||||
level="合格";
|
||||
}else if(f6<value&&value<=f7){
|
||||
level="中度污染";
|
||||
// level="中度污染";
|
||||
level="较差";
|
||||
}else if(f7<value&&value<=f8){
|
||||
level="重度污染";
|
||||
// level="重度污染";
|
||||
level="差";
|
||||
}else{
|
||||
level="极度污染";
|
||||
// level="极度污染";
|
||||
level="极差";
|
||||
}
|
||||
return level;
|
||||
}
|
||||
|
||||
private static List<YearMonth> getMonthsBetween(LocalDate startDate, LocalDate endDate) {
|
||||
List<YearMonth> months = new ArrayList<>();
|
||||
YearMonth currentMonth = YearMonth.from(startDate);
|
||||
YearMonth endMonth = YearMonth.from(endDate);
|
||||
while (!currentMonth.isAfter(endMonth)) {
|
||||
months.add(currentMonth);
|
||||
currentMonth = currentMonth.plusMonths(1);
|
||||
}
|
||||
return months;
|
||||
}
|
||||
|
||||
/**
|
||||
* 过滤监测点
|
||||
* @param list
|
||||
@@ -827,21 +832,4 @@ public class GridServiceImpl implements IGridService {
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据传入的月份数获取时间集合
|
||||
* @param month
|
||||
* @return
|
||||
*/
|
||||
public List<YearMonth> getLastThreeMonth(int month) {
|
||||
//按月获取时间集合
|
||||
LocalDate currentDate = LocalDate.now();
|
||||
int currentYear = currentDate.getYear();
|
||||
LocalDate beginDay = LocalDate.of(currentYear, 1, 1);
|
||||
List<YearMonth> monthList = getMonthsBetween(beginDay,currentDate);
|
||||
if (monthList.size() > month) {
|
||||
monthList = monthList.subList(monthList.size() - month,monthList.size());
|
||||
}
|
||||
return monthList;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.njcn.harmonic.util;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.Year;
|
||||
import java.time.YearMonth;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class TimeUtil {
|
||||
|
||||
/**
|
||||
* 根据传入的月份数获取时间集合
|
||||
* @param month
|
||||
* @return
|
||||
*/
|
||||
public static List<YearMonth> getLastThreeMonth(int month) {
|
||||
//按月获取时间集合
|
||||
LocalDate currentDate = LocalDate.now();
|
||||
int currentYear = currentDate.getYear();
|
||||
LocalDate beginDay = LocalDate.of(currentYear, 1, 1);
|
||||
List<YearMonth> monthList = getMonthsBetween(beginDay,currentDate);
|
||||
if (monthList.size() > month) {
|
||||
monthList = monthList.subList(monthList.size() - month,monthList.size());
|
||||
}
|
||||
return monthList;
|
||||
}
|
||||
|
||||
public static List<YearMonth> getMonthsBetween(LocalDate startDate, LocalDate endDate) {
|
||||
List<YearMonth> months = new ArrayList<>();
|
||||
YearMonth currentMonth = YearMonth.from(startDate);
|
||||
YearMonth endMonth = YearMonth.from(endDate);
|
||||
while (!currentMonth.isAfter(endMonth)) {
|
||||
months.add(currentMonth);
|
||||
currentMonth = currentMonth.plusMonths(1);
|
||||
}
|
||||
return months;
|
||||
}
|
||||
|
||||
public static List<Integer> getLastFiveYear(int year) {
|
||||
List<Integer> yearList = new ArrayList<>();
|
||||
LocalDate currentDate = LocalDate.now();
|
||||
int currentYear = currentDate.getYear();
|
||||
for (int i = year; i >= 0; i--) {
|
||||
yearList.add(currentYear - i);
|
||||
}
|
||||
return yearList;
|
||||
}
|
||||
|
||||
public static String getYearFirst(int year){
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.clear();
|
||||
calendar.set(Calendar.YEAR, year);
|
||||
Date currYearFirst = calendar.getTime();
|
||||
return new SimpleDateFormat("yyyy-MM-dd").format(currYearFirst);
|
||||
}
|
||||
|
||||
public static String getYearLast(int year){
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.clear();
|
||||
calendar.set(Calendar.YEAR, year);
|
||||
calendar.roll(Calendar.DAY_OF_YEAR, -1);
|
||||
return new SimpleDateFormat("yyyy-MM-dd").format(calendar.getTime());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user