新接口,设备综合统计实际日期版本
This commit is contained in:
parent
313c06003b
commit
f2565d7430
|
|
@ -681,7 +681,6 @@ public class BigScreenController {
|
||||||
}
|
}
|
||||||
|
|
||||||
//查询五常数据
|
//查询五常数据
|
||||||
log.warn("ccc======"+waterIdList.size());
|
|
||||||
ScreenIndexSummaryDetailVo waterQuality = commonP2Service.processWaterQuality(screenSummaryVo,waterIdList,startTime,endTime);
|
ScreenIndexSummaryDetailVo waterQuality = commonP2Service.processWaterQuality(screenSummaryVo,waterIdList,startTime,endTime);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,16 +10,24 @@ import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.jeecg.common.api.vo.Result;
|
import org.jeecg.common.api.vo.Result;
|
||||||
|
import org.jeecg.common.constant.IotConstants;
|
||||||
import org.jeecg.common.constant.enums.PollutionEnum;
|
import org.jeecg.common.constant.enums.PollutionEnum;
|
||||||
import org.jeecg.common.entity.SurvDeviceDeploy;
|
import org.jeecg.common.entity.SurvDeviceDeploy;
|
||||||
import org.jeecg.common.entity.SurvMaintainRecord;
|
import org.jeecg.common.entity.SurvMaintainRecord;
|
||||||
|
import org.jeecg.common.iot.common.VOIntegrateStatistic;
|
||||||
|
import org.jeecg.common.iot.common.VOSurvIntegrateResult;
|
||||||
import org.jeecg.common.vo.params.StationMaintainPage;
|
import org.jeecg.common.vo.params.StationMaintainPage;
|
||||||
|
import org.jeecg.common.vo.statistic.DeploySummaryVo;
|
||||||
|
import org.jeecg.common.vo.statistic.ScreenIndexSummaryDetailVo;
|
||||||
|
import org.jeecg.common.vo.statistic.ScreenSummaryDetailVo;
|
||||||
|
import org.jeecg.common.vo.statistic.ScreenSummaryVo;
|
||||||
import org.jeecg.modules.appmana.service.ISurvDeviceDeployService;
|
import org.jeecg.modules.appmana.service.ISurvDeviceDeployService;
|
||||||
import org.jeecg.modules.appmana.service.ISurvMaintainRecordService;
|
import org.jeecg.modules.appmana.service.ISurvMaintainRecordService;
|
||||||
import org.jeecg.modules.appmana.service.impl.CommonServiceImpl;
|
import org.jeecg.modules.appmana.service.impl.CommonServiceImpl;
|
||||||
import org.jeecg.common.vo.VOBigScreenSurvQ;
|
import org.jeecg.common.vo.VOBigScreenSurvQ;
|
||||||
import org.jeecg.common.vo.VOHisFormResult;
|
import org.jeecg.common.vo.VOHisFormResult;
|
||||||
import org.jeecg.common.vo.VOHisResult;
|
import org.jeecg.common.vo.VOHisResult;
|
||||||
|
import org.jeecg.modules.appmana.service.impl.IotCommonP2ServiceImpl;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
|
@ -27,6 +35,7 @@ import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.LocalTime;
|
import java.time.LocalTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.time.temporal.TemporalAdjusters;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
@ -41,6 +50,8 @@ public class BigScreenControllerP2 {
|
||||||
@Autowired
|
@Autowired
|
||||||
private CommonServiceImpl commonService;
|
private CommonServiceImpl commonService;
|
||||||
@Autowired
|
@Autowired
|
||||||
|
private IotCommonP2ServiceImpl iotCommonP2Service;
|
||||||
|
@Autowired
|
||||||
private ISurvMaintainRecordService maintainRecordService;
|
private ISurvMaintainRecordService maintainRecordService;
|
||||||
|
|
||||||
@ApiOperationSupport(order = 1)
|
@ApiOperationSupport(order = 1)
|
||||||
|
|
@ -97,4 +108,12 @@ public class BigScreenControllerP2 {
|
||||||
return Result.OK(records);
|
return Result.OK(records);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperationSupport(order = 3)
|
||||||
|
@ApiOperation(value = "03. 实际日综合曲线数据", notes = "")
|
||||||
|
@PostMapping(value = "/timesIntegrate")
|
||||||
|
public Result<VOIntegrateStatistic> timesIntegrate(@RequestBody DeploySummaryVo deploySummaryVo) {
|
||||||
|
VOIntegrateStatistic voIntegrateStatistic = iotCommonP2Service.CalAirSoilTimesIntegrate(deploySummaryVo);
|
||||||
|
return Result.OK(voIntegrateStatistic);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -153,4 +153,6 @@ public class CommonServiceImpl {
|
||||||
return configService.getCacheConfig(tenantId, configType);
|
return configService.getCacheConfig(tenantId, configType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,19 @@
|
||||||
package org.jeecg.modules.appmana.service.impl;
|
package org.jeecg.modules.appmana.service.impl;
|
||||||
|
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import io.swagger.models.auth.In;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.jeecg.common.constant.IotConstants;
|
import org.jeecg.common.constant.IotConstants;
|
||||||
import org.jeecg.common.constant.enums.PollutionEnum;
|
import org.jeecg.common.constant.enums.PollutionEnum;
|
||||||
import org.jeecg.common.constant.enums.ScreenIndexSummaryEnum;
|
import org.jeecg.common.constant.enums.ScreenIndexSummaryEnum;
|
||||||
|
import org.jeecg.common.iot.common.VOIntegrateStatistic;
|
||||||
import org.jeecg.common.iot.common.VOSurvIntegrateParam;
|
import org.jeecg.common.iot.common.VOSurvIntegrateParam;
|
||||||
import org.jeecg.common.iot.common.VOSurvIntegrateResult;
|
import org.jeecg.common.iot.common.VOSurvIntegrateResult;
|
||||||
import org.jeecg.common.iot.common.VOWaterSurvIntegrateParam;
|
import org.jeecg.common.iot.common.VOWaterSurvIntegrateParam;
|
||||||
import org.jeecg.common.vo.VOHisFormResult;
|
import org.jeecg.common.vo.VOHisFormResult;
|
||||||
import org.jeecg.common.vo.VOHisResult;
|
import org.jeecg.common.vo.VOHisResult;
|
||||||
|
import org.jeecg.common.vo.statistic.DeploySummaryVo;
|
||||||
import org.jeecg.common.vo.statistic.ScreenIndexSummaryDetailVo;
|
import org.jeecg.common.vo.statistic.ScreenIndexSummaryDetailVo;
|
||||||
import org.jeecg.common.vo.statistic.ScreenSummaryVo;
|
import org.jeecg.common.vo.statistic.ScreenSummaryVo;
|
||||||
import org.jeecg.modules.appmana.mapper.IOTStatisticMapper;
|
import org.jeecg.modules.appmana.mapper.IOTStatisticMapper;
|
||||||
|
|
@ -70,6 +74,15 @@ public class IotCommonP2ServiceImpl {
|
||||||
return voHisResult;
|
return voHisResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按实际时间返回综合统计
|
||||||
|
* @param screenSummaryVo
|
||||||
|
* @param deviceList
|
||||||
|
* @param startTime
|
||||||
|
* @param endTime
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public ScreenIndexSummaryDetailVo processWaterQuality(ScreenSummaryVo screenSummaryVo,List<String> deviceList,String startTime,String endTime) {
|
public ScreenIndexSummaryDetailVo processWaterQuality(ScreenSummaryVo screenSummaryVo,List<String> deviceList,String startTime,String endTime) {
|
||||||
if(deviceList.isEmpty()){
|
if(deviceList.isEmpty()){
|
||||||
return null;
|
return null;
|
||||||
|
|
@ -281,4 +294,163 @@ public class IotCommonP2ServiceImpl {
|
||||||
|
|
||||||
return screenIndexSummaryDetailVo;
|
return screenIndexSummaryDetailVo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public VOIntegrateStatistic CalAirSoilTimesIntegrate(DeploySummaryVo deploySummaryVo) {
|
||||||
|
if(deploySummaryVo.getDeployIds()==null || deploySummaryVo.getDeployIds().isEmpty()){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
VOSurvIntegrateResult voSurvIntegrateResult = new VOSurvIntegrateResult();
|
||||||
|
//默认日数据
|
||||||
|
if(StringUtils.isBlank(deploySummaryVo.getSummrayMode())){
|
||||||
|
deploySummaryVo.setSummrayMode(IotConstants.day_hours);
|
||||||
|
}
|
||||||
|
LocalDateTime nowDay = LocalDateTime.now();
|
||||||
|
String startTime = deploySummaryVo.getStartTime();
|
||||||
|
String endTime = deploySummaryVo.getEndTime();
|
||||||
|
LocalDateTime startDay = null;
|
||||||
|
DateTimeFormatter daydtf = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||||
|
DateTimeFormatter monthdtf = DateTimeFormatter.ofPattern("yyyy-MM");
|
||||||
|
DateTimeFormatter yeardtf = DateTimeFormatter.ofPattern("yyyy");
|
||||||
|
|
||||||
|
if(StringUtils.isBlank(deploySummaryVo.getStartTime())){
|
||||||
|
if(IotConstants.day_hours.equals(deploySummaryVo.getSummrayMode())){//默认日
|
||||||
|
startDay = LocalDateTime.of(nowDay.toLocalDate(),LocalTime.MIN);
|
||||||
|
startTime = startDay.format(daydtf);
|
||||||
|
endTime = LocalDateTime.of(nowDay.toLocalDate(),LocalTime.MAX).withNano(999999000).format(daydtf);
|
||||||
|
}else if(IotConstants.month_days.equals(deploySummaryVo.getSummrayMode())){
|
||||||
|
startDay = nowDay.with(TemporalAdjusters.firstDayOfMonth()).with(LocalTime.MIN);
|
||||||
|
startTime = startDay.format(monthdtf);
|
||||||
|
endTime = nowDay.with(TemporalAdjusters.lastDayOfMonth()).with(LocalTime.MAX).withNano(999999000).format(monthdtf);
|
||||||
|
}else if(IotConstants.year_months.equals(deploySummaryVo.getSummrayMode())){
|
||||||
|
startDay = nowDay.with(TemporalAdjusters.firstDayOfYear()).with(LocalTime.MIN);
|
||||||
|
startTime = startDay.format(yeardtf);
|
||||||
|
endTime = nowDay.with(TemporalAdjusters.lastDayOfYear()).with(LocalTime.MAX).withNano(999999000).format(yeardtf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ScreenSummaryVo screenSummaryVo = new ScreenSummaryVo();
|
||||||
|
screenSummaryVo.setStartTime(deploySummaryVo.getStartTime());
|
||||||
|
screenSummaryVo.setEndTime(deploySummaryVo.getEndTime());
|
||||||
|
screenSummaryVo.setSummrayMode(deploySummaryVo.getSummrayMode());
|
||||||
|
|
||||||
|
|
||||||
|
VOSurvIntegrateParam voSurvIntegrateParam = new VOSurvIntegrateParam();
|
||||||
|
voSurvIntegrateParam.setDeployIds(deploySummaryVo.getDeployIds());
|
||||||
|
voSurvIntegrateParam.setSummrayMode(screenSummaryVo.getSummrayMode());
|
||||||
|
voSurvIntegrateParam.setStartTime(startTime);
|
||||||
|
voSurvIntegrateParam.setEndTime(endTime);
|
||||||
|
VOSurvIntegrateResult nowItegrate =commonService.survDataIntegrateStatistic(voSurvIntegrateParam);
|
||||||
|
if(IotConstants.day_hours.equals(screenSummaryVo.getSummrayMode())) {
|
||||||
|
//处理时间格式
|
||||||
|
nowItegrate.setIndexs(commonService.processTime(nowItegrate.getIndexs(),"yyyy-MM-dd HH","H时"));
|
||||||
|
}
|
||||||
|
|
||||||
|
//数据
|
||||||
|
List<String> timeList = new ArrayList<>();
|
||||||
|
LinkedHashMap<String,List<String>> dataMap =new LinkedHashMap<>();
|
||||||
|
//使用数据的数量,默认
|
||||||
|
int todayDataCounts = 0;
|
||||||
|
//需要拼接的数量
|
||||||
|
int yesterDataCounts = 0;
|
||||||
|
if(IotConstants.day_hours.equals(screenSummaryVo.getSummrayMode())) {//日需要24数据
|
||||||
|
todayDataCounts =24;
|
||||||
|
}else if(IotConstants.month_days.equals(screenSummaryVo.getSummrayMode())){//月需要数据量
|
||||||
|
LocalDate curDateMark = LocalDate.parse(startTime+"-01",daydtf);
|
||||||
|
todayDataCounts = curDateMark.with(TemporalAdjusters.lastDayOfMonth()).getDayOfMonth();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(IotConstants.day_hours.equals(screenSummaryVo.getSummrayMode())){//检查是否是今天
|
||||||
|
if(nowDay.format(daydtf).equals(startTime)){//如果查询是今天,再查询一次昨天,拼接为24小时
|
||||||
|
LocalDateTime yesterday = nowDay.minusDays(1);
|
||||||
|
|
||||||
|
todayDataCounts = nowDay.getHour()+1;//0点开始,故+1
|
||||||
|
yesterDataCounts = todayDataCounts;
|
||||||
|
String newTimes = yesterday.format(daydtf);
|
||||||
|
voSurvIntegrateParam.setStartTime(newTimes);
|
||||||
|
voSurvIntegrateParam.setEndTime(newTimes);
|
||||||
|
VOSurvIntegrateResult yesterData = commonService.survDataIntegrateStatistic(voSurvIntegrateParam);
|
||||||
|
LinkedHashMap<String,List<String>> yesterResult = yesterData.getSurvResult();
|
||||||
|
//处理时间格式
|
||||||
|
yesterData.setIndexs(commonService.processTime(yesterData.getIndexs(),"yyyy-MM-dd HH","H时"));
|
||||||
|
//数据截取
|
||||||
|
dataMap = processDataSub(yesterResult,nowItegrate.getSurvResult(),todayDataCounts,yesterDataCounts);
|
||||||
|
timeList.addAll(yesterData.getIndexs().subList(yesterDataCounts,yesterData.getIndexs().size()));
|
||||||
|
}
|
||||||
|
} else if (IotConstants.month_days.equals(screenSummaryVo.getSummrayMode())){//检查是否是本月
|
||||||
|
if(nowDay.format(monthdtf).equals(startTime)){//如果查询是本月,再查询一次上个月,拼接为30天
|
||||||
|
LocalDateTime yesterMonth = nowDay.minusMonths(1);
|
||||||
|
|
||||||
|
todayDataCounts = nowDay.getDayOfMonth();
|
||||||
|
yesterDataCounts = todayDataCounts;
|
||||||
|
String newTimes = yesterMonth.format(monthdtf);
|
||||||
|
voSurvIntegrateParam.setStartTime(newTimes);
|
||||||
|
voSurvIntegrateParam.setEndTime(newTimes);
|
||||||
|
VOSurvIntegrateResult yesterData = commonService.survDataIntegrateStatistic(voSurvIntegrateParam);
|
||||||
|
LinkedHashMap<String,List<String>> yesterResult = yesterData.getSurvResult();
|
||||||
|
dataMap = processDataSub(yesterResult,nowItegrate.getSurvResult(),todayDataCounts,yesterDataCounts);
|
||||||
|
timeList.addAll(yesterData.getIndexs().subList(yesterDataCounts,yesterData.getIndexs().size()));
|
||||||
|
}
|
||||||
|
} else if (IotConstants.year_months.equals(screenSummaryVo.getSummrayMode())){//检查是否是本年
|
||||||
|
if(nowDay.format(yeardtf).equals(startTime)){//如果查询是本年,再查询一次去年,拼接为12个月
|
||||||
|
LocalDateTime yesterYear = nowDay.minusYears(1);
|
||||||
|
|
||||||
|
todayDataCounts = nowDay.getMonthValue();
|
||||||
|
yesterDataCounts = todayDataCounts;
|
||||||
|
String newTimes = yesterYear.format(yeardtf);
|
||||||
|
voSurvIntegrateParam.setStartTime(newTimes);
|
||||||
|
voSurvIntegrateParam.setEndTime(newTimes);
|
||||||
|
VOSurvIntegrateResult yesterData = commonService.survDataIntegrateStatistic(voSurvIntegrateParam);
|
||||||
|
LinkedHashMap<String,List<String>> yesterResult = yesterData.getSurvResult();
|
||||||
|
dataMap = processDataSub(yesterResult,nowItegrate.getSurvResult(),todayDataCounts,yesterDataCounts);
|
||||||
|
timeList.addAll(yesterData.getIndexs().subList(yesterDataCounts,yesterData.getIndexs().size()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
timeList.addAll(nowItegrate.getIndexs().subList(0,todayDataCounts));
|
||||||
|
|
||||||
|
voSurvIntegrateResult.setHeaders(nowItegrate.getHeaders());
|
||||||
|
voSurvIntegrateResult.setSurvResult(dataMap);
|
||||||
|
voSurvIntegrateResult.setIndexs(timeList);
|
||||||
|
|
||||||
|
|
||||||
|
//组装数据
|
||||||
|
VOIntegrateStatistic voIntegrateStatistic = new VOIntegrateStatistic();
|
||||||
|
List<LinkedHashMap<String,String>> voSurvIntegrateTotals = commonService.transToMapList(voSurvIntegrateResult);
|
||||||
|
voIntegrateStatistic.setObjResults(voSurvIntegrateResult.getSurvResult());
|
||||||
|
voIntegrateStatistic.setTableHead(voSurvIntegrateResult.getHeaders());
|
||||||
|
voIntegrateStatistic.setTableIndex(voSurvIntegrateResult.getIndexs());
|
||||||
|
voIntegrateStatistic.setTableData(voSurvIntegrateTotals);
|
||||||
|
voIntegrateStatistic.setTableData2(commonService.transToArr(voSurvIntegrateResult.getHeaders(),voSurvIntegrateTotals));
|
||||||
|
voIntegrateStatistic.setRealTimeData(voSurvIntegrateResult.getLiveData());
|
||||||
|
|
||||||
|
return voIntegrateStatistic;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理数据截取
|
||||||
|
*/
|
||||||
|
private LinkedHashMap<String,List<String>> processDataSub(LinkedHashMap<String,List<String>> datas, LinkedHashMap<String,List<String>> nowDatas, Integer todayDataCounts, Integer yesterDataCounts){
|
||||||
|
LinkedHashMap<String,List<String>> curDatas = new LinkedHashMap<>();
|
||||||
|
LinkedHashMap<String,List<String>> newData = new LinkedHashMap<>();
|
||||||
|
if(nowDatas!=null && !nowDatas.isEmpty()){
|
||||||
|
for (String items : nowDatas.keySet()) {
|
||||||
|
List<String> nowData = nowDatas.get(items);
|
||||||
|
curDatas.put(items,nowData.subList(0,todayDataCounts));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(datas!=null && !datas.isEmpty()){
|
||||||
|
for (String s : datas.keySet()) {
|
||||||
|
List<String> survData = datas.get(s);
|
||||||
|
if(survData!=null && !survData.isEmpty()){
|
||||||
|
List<String> yesterData = survData.subList(yesterDataCounts,survData.size());
|
||||||
|
//拼接新旧数据
|
||||||
|
if(curDatas!=null) {
|
||||||
|
List<String> itemCurData = curDatas.get(s);
|
||||||
|
yesterData.addAll(itemCurData);
|
||||||
|
}
|
||||||
|
newData.put(s,yesterData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return newData;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
package org.jeecg.common.vo.statistic;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class DeploySummaryVo {
|
||||||
|
@ApiModelProperty("站点编号")
|
||||||
|
private List<String> deployIds;
|
||||||
|
@ApiModelProperty("开始时间")
|
||||||
|
private String startTime;
|
||||||
|
@ApiModelProperty("结束时间")
|
||||||
|
private String endTime;
|
||||||
|
@ApiModelProperty("统计模式,dayhours=日小时统计,monthDays=月每日统计,yearMonth=年每月统计")
|
||||||
|
private String summrayMode;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
package org.jeecg.common.vo.statistic;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ScreenSummaryDetailVo {
|
||||||
|
@JSONField(name = "datas")
|
||||||
|
private LinkedHashMap<String, List<Double>> datas;
|
||||||
|
@JSONField(name = "dateStr")
|
||||||
|
private List<String> dateStr;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue