综合评估功能调整
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package com.njcn.advance.service.responsibility.impl;
|
package com.njcn.advance.service.responsibility.impl;
|
||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import cn.hutool.core.date.DatePattern;
|
import cn.hutool.core.date.DatePattern;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
@@ -33,12 +34,18 @@ import com.njcn.advance.service.responsibility.IRespDataService;
|
|||||||
import com.njcn.advance.service.responsibility.IRespUserDataService;
|
import com.njcn.advance.service.responsibility.IRespUserDataService;
|
||||||
import com.njcn.advance.utils.ResponsibilityAlgorithm;
|
import com.njcn.advance.utils.ResponsibilityAlgorithm;
|
||||||
import com.njcn.advance.utils.ResponsibilityCallDllOrSo;
|
import com.njcn.advance.utils.ResponsibilityCallDllOrSo;
|
||||||
|
import com.njcn.common.pojo.constant.ServerInfo;
|
||||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||||
import com.njcn.common.pojo.exception.BusinessException;
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
import com.njcn.common.utils.FileUtil;
|
import com.njcn.common.utils.FileUtil;
|
||||||
import com.njcn.common.utils.PubUtils;
|
import com.njcn.common.utils.PubUtils;
|
||||||
import com.njcn.db.constant.DbConstant;
|
import com.njcn.db.constant.DbConstant;
|
||||||
|
import com.njcn.device.biz.commApi.CommTerminalGeneralClient;
|
||||||
|
import com.njcn.device.biz.pojo.dto.DeptGetChildrenMoreDTO;
|
||||||
|
import com.njcn.device.biz.pojo.dto.LineDevGetDTO;
|
||||||
|
import com.njcn.device.biz.pojo.param.DeptGetLineParam;
|
||||||
import com.njcn.device.biz.pojo.po.Overlimit;
|
import com.njcn.device.biz.pojo.po.Overlimit;
|
||||||
|
import com.njcn.device.pms.pojo.po.StatationStat;
|
||||||
import com.njcn.device.pq.api.LineFeignClient;
|
import com.njcn.device.pq.api.LineFeignClient;
|
||||||
import com.njcn.device.pq.pojo.vo.LineDetailDataVO;
|
import com.njcn.device.pq.pojo.vo.LineDetailDataVO;
|
||||||
import com.njcn.device.pq.pojo.vo.LineDetailVO;
|
import com.njcn.device.pq.pojo.vo.LineDetailVO;
|
||||||
@@ -50,6 +57,7 @@ import com.njcn.oss.constant.OssPath;
|
|||||||
import com.njcn.oss.utils.FileStorageUtil;
|
import com.njcn.oss.utils.FileStorageUtil;
|
||||||
import com.njcn.web.factory.PageFactory;
|
import com.njcn.web.factory.PageFactory;
|
||||||
import com.njcn.web.pojo.param.BaseParam;
|
import com.njcn.web.pojo.param.BaseParam;
|
||||||
|
import com.njcn.web.utils.RequestUtil;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
@@ -58,6 +66,7 @@ import java.io.*;
|
|||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
@@ -85,9 +94,21 @@ public class RespDataServiceImpl extends ServiceImpl<RespDataMapper, RespData> i
|
|||||||
|
|
||||||
private final IRespUserDataService respUserDataService;
|
private final IRespUserDataService respUserDataService;
|
||||||
|
|
||||||
|
private final CommTerminalGeneralClient commTerminalGeneralClient;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<RespDataDTO> responsibilityList(BaseParam queryParam) {
|
public Page<RespDataDTO> responsibilityList(BaseParam queryParam) {
|
||||||
QueryWrapper<RespDataDTO> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<RespDataDTO> queryWrapper = new QueryWrapper<>();
|
||||||
|
//获取当前用户部门,根据部门获取监测点
|
||||||
|
DeptGetLineParam deptGetLineParam = new DeptGetLineParam();
|
||||||
|
deptGetLineParam.setDeptId(RequestUtil.getDeptIndex());
|
||||||
|
deptGetLineParam.setServerName(ServerInfo.ADVANCE_BOOT);
|
||||||
|
List<DeptGetChildrenMoreDTO> list = commTerminalGeneralClient.deptGetLine(deptGetLineParam).getData();
|
||||||
|
DeptGetChildrenMoreDTO dto = list.stream().collect(Collectors.toMap(DeptGetChildrenMoreDTO::getUnitId, Function.identity())).get(RequestUtil.getDeptIndex());
|
||||||
|
if (CollUtil.isNotEmpty(dto.getLineBaseList())) {
|
||||||
|
List<String> line = dto.getLineBaseList().stream().map(LineDevGetDTO::getPointId).collect(Collectors.toList());
|
||||||
|
queryWrapper.in("pqs_resp_data.line_id", line);
|
||||||
|
}
|
||||||
if (ObjectUtil.isNotNull(queryParam)) {
|
if (ObjectUtil.isNotNull(queryParam)) {
|
||||||
//查询参数不为空,进行条件填充
|
//查询参数不为空,进行条件填充
|
||||||
if (StrUtil.isNotBlank(queryParam.getSearchValue())) {
|
if (StrUtil.isNotBlank(queryParam.getSearchValue())) {
|
||||||
|
|||||||
@@ -44,4 +44,7 @@ public class AssessParam {
|
|||||||
@ApiModelProperty("电压等级")
|
@ApiModelProperty("电压等级")
|
||||||
private String voltageLevel;
|
private String voltageLevel;
|
||||||
|
|
||||||
|
@ApiModelProperty(name="type",value="类型(1年 2季度 3月份 4周 5日)")
|
||||||
|
private Integer type;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public interface IGridService {
|
|||||||
List<AssessDetailVo> getData(AssessParam param);
|
List<AssessDetailVo> getData(AssessParam param);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 综合评估趋势数据(当前时间统计前三个月时间)
|
* 综合评估趋势数据(当前时间统计前五个月时间、或者前五年)
|
||||||
*/
|
*/
|
||||||
List<AssessVo.AssessTrendVo> getAssessTrend(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.pojo.vo.hebeinorth.EvaluationVo;
|
||||||
import com.njcn.harmonic.service.hebeinorth.IGridService;
|
import com.njcn.harmonic.service.hebeinorth.IGridService;
|
||||||
import com.njcn.harmonic.util.ComAssesUtil;
|
import com.njcn.harmonic.util.ComAssesUtil;
|
||||||
|
import com.njcn.harmonic.util.TimeUtil;
|
||||||
import com.njcn.system.enums.DicDataEnum;
|
import com.njcn.system.enums.DicDataEnum;
|
||||||
import com.njcn.user.api.DeptFeignClient;
|
import com.njcn.user.api.DeptFeignClient;
|
||||||
import com.njcn.user.pojo.dto.DeptDTO;
|
import com.njcn.user.pojo.dto.DeptDTO;
|
||||||
@@ -33,6 +34,7 @@ import lombok.RequiredArgsConstructor;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
import java.time.Year;
|
||||||
import java.time.YearMonth;
|
import java.time.YearMonth;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -176,14 +178,24 @@ public class GridServiceImpl implements IGridService {
|
|||||||
Map<String,List<LineDetail>> lineDetailMap = lineDetailList.stream().collect(Collectors.groupingBy(LineDetail::getActualArea));
|
Map<String,List<LineDetail>> lineDetailMap = lineDetailList.stream().collect(Collectors.groupingBy(LineDetail::getActualArea));
|
||||||
//获取部门
|
//获取部门
|
||||||
List<DeptDTO> deptList = deptFeignClient.getDepSonDetailByDeptId(param.getDeptIndex()).getData();
|
List<DeptDTO> deptList = deptFeignClient.getDepSonDetailByDeptId(param.getDeptIndex()).getData();
|
||||||
//根据传入的参数,获取返回的月份
|
//按月、年来展示数据
|
||||||
List<YearMonth> monthList = this.getLastThreeMonth(3);
|
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->{
|
monthList.forEach(month->{
|
||||||
String firstDayOfMonth = month.atDay(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
String firstDayOfMonth = month.atDay(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||||
String lastDayOfMonth = month.atEndOfMonth().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
String lastDayOfMonth = month.atEndOfMonth().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||||
List<PQSComAssesPO> comAssesList = rStatComassesDMapper.getAvgCount(lineList,firstDayOfMonth,lastDayOfMonth);
|
List<PQSComAssesPO> comAssesList = rStatComassesDMapper.getAvgCount(lineList,firstDayOfMonth,lastDayOfMonth);
|
||||||
map.put(month.toString(),comAssesList);
|
map.put(month.toString(),comAssesList);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
//数据处理
|
//数据处理
|
||||||
deptList.forEach(item->{
|
deptList.forEach(item->{
|
||||||
if (lineDetailMap.containsKey(item.getArea())) {
|
if (lineDetailMap.containsKey(item.getArea())) {
|
||||||
@@ -365,7 +377,7 @@ public class GridServiceImpl implements IGridService {
|
|||||||
// 获取当前年份
|
// 获取当前年份
|
||||||
int currentYear = currentDate.getYear();
|
int currentYear = currentDate.getYear();
|
||||||
LocalDate beginDay = LocalDate.of(currentYear, 1, 1);
|
LocalDate beginDay = LocalDate.of(currentYear, 1, 1);
|
||||||
List<YearMonth> monthList = getMonthsBetween(beginDay,currentDate);
|
List<YearMonth> monthList = TimeUtil.getMonthsBetween(beginDay,currentDate);
|
||||||
for (YearMonth month : monthList) {
|
for (YearMonth month : monthList) {
|
||||||
String firstDayOfMonth = month.atDay(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
String firstDayOfMonth = month.atDay(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||||
String lastDayOfMonth = month.atEndOfMonth().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){
|
}else if(f4<value&&value<=f5){
|
||||||
level="良好";
|
level="良好";
|
||||||
}else if(f5<value&&value<=f6){
|
}else if(f5<value&&value<=f6){
|
||||||
level="轻度污染";
|
// level="轻度污染";
|
||||||
|
level="合格";
|
||||||
}else if(f6<value&&value<=f7){
|
}else if(f6<value&&value<=f7){
|
||||||
level="中度污染";
|
// level="中度污染";
|
||||||
|
level="较差";
|
||||||
}else if(f7<value&&value<=f8){
|
}else if(f7<value&&value<=f8){
|
||||||
level="重度污染";
|
// level="重度污染";
|
||||||
|
level="差";
|
||||||
}else{
|
}else{
|
||||||
level="极度污染";
|
// level="极度污染";
|
||||||
|
level="极差";
|
||||||
}
|
}
|
||||||
return 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
|
* @param list
|
||||||
@@ -827,21 +832,4 @@ public class GridServiceImpl implements IGridService {
|
|||||||
return map;
|
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