调整首页统计结构
This commit is contained in:
parent
8b03698185
commit
849d1bf564
|
|
@ -12,11 +12,14 @@ import org.apache.commons.lang3.StringUtils;
|
|||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.IotConstants;
|
||||
import org.jeecg.common.constant.PollutionConstants;
|
||||
import org.jeecg.common.constant.enums.ScreenIndexSummaryEnum;
|
||||
import org.jeecg.common.entity.*;
|
||||
import org.jeecg.common.constant.enums.PollutionEnum;
|
||||
import org.jeecg.common.util.R;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.common.vo.*;
|
||||
import org.jeecg.common.vo.statistic.ScreenIndexSummaryDetailVo;
|
||||
import org.jeecg.common.vo.statistic.ScreenSummaryVo;
|
||||
import org.jeecg.modules.appmana.service.*;
|
||||
import org.jeecg.modules.appmana.utils.Iotutils;
|
||||
import org.jeecg.modules.appmana.utils.YSUtils;
|
||||
|
|
@ -527,24 +530,24 @@ public class BigScreenController {
|
|||
|
||||
@PostMapping("/getIndexSummry")
|
||||
@ApiOperation("大屏首页统计")
|
||||
public Result getIndexSummry (@RequestParam(value = "stationCode",required = false)String stationCode){
|
||||
|
||||
List<SurvStationInfo> stationList = survStationInfoService.getAllStationAndDevice(stationCode,"","token");
|
||||
public Result<List<ScreenIndexSummaryDetailVo>> getIndexSummry (@RequestBody ScreenSummaryVo screenSummaryVo){
|
||||
List<ScreenIndexSummaryDetailVo> results = new ArrayList<>();
|
||||
List<SurvStationInfo> stationList = survStationInfoService.getAllStationAndDevice(screenSummaryVo.getStationCode(),"","token");
|
||||
//补充最新数据进入
|
||||
JSONArray returnArrs= new JSONArray();
|
||||
// JSONArray returnArrs= new JSONArray();
|
||||
Integer intYear = LocalDateTime.now().getYear();
|
||||
String curYear = String.valueOf(intYear);
|
||||
String lastYear = String.valueOf(intYear-1);
|
||||
//计算历史时间段
|
||||
Integer curMonth = LocalDateTime.now().getMonth().getValue();
|
||||
//共需回溯六个月的统计,所以计算是否需要往年数据
|
||||
curMonth=curMonth-1;//不返回本月的统计,从上个月开始
|
||||
// curMonth=curMonth-1;//不返回本月的统计,从上个月开始
|
||||
//计算完整的时间串
|
||||
List<String> wholeTime = new ArrayList<>();
|
||||
for (Integer i = 1; i <= curMonth; i++) {
|
||||
wholeTime.add(curYear+"-"+String.format("%02d", i));
|
||||
}
|
||||
Integer lastYearMonth = 6 -curMonth;
|
||||
Integer lastYearMonth = 12 -curMonth;
|
||||
Boolean isNeedLastYear = Boolean.FALSE;
|
||||
if(lastYearMonth>0){
|
||||
isNeedLastYear = Boolean.TRUE;
|
||||
|
|
@ -560,6 +563,7 @@ public class BigScreenController {
|
|||
if(stationList!=null&&stationList.size()>0){
|
||||
// Map<String,List<String>> deviceMap = new HashMap<>();
|
||||
for (SurvStationInfo survStationInfo : stationList) {
|
||||
ScreenIndexSummaryDetailVo screenIndexSummaryDetailVo = new ScreenIndexSummaryDetailVo();
|
||||
if(survStationInfo.getDeviceList()!=null&&survStationInfo.getDeviceList().size()>0){
|
||||
List<SurvDeviceDeploy> stationDeviceList = new ArrayList<>();
|
||||
List<String> airList = new ArrayList<>();
|
||||
|
|
@ -640,18 +644,20 @@ public class BigScreenController {
|
|||
avgNH = lastavgNH;
|
||||
avgCOD = lastavgCOD;
|
||||
}
|
||||
StationSummry stationSummry =new StationSummry();
|
||||
stationSummry.setTNSummry(avgTN);
|
||||
stationSummry.setTPSummry(avgTP);
|
||||
stationSummry.setNOSummry(avgNO);
|
||||
// StationSummry stationSummry =new StationSummry();
|
||||
LinkedHashMap<String, List<Double>> maps = new LinkedHashMap<>();
|
||||
maps.put(ScreenIndexSummaryEnum.TNSummry.getDesc(),avgTN);
|
||||
maps.put(ScreenIndexSummaryEnum.TPSummry.getDesc(),avgTP);
|
||||
maps.put(ScreenIndexSummaryEnum.NOSummry.getDesc(),avgNO);
|
||||
maps.put(ScreenIndexSummaryEnum.CODSummry.getDesc(),avgCOD);
|
||||
maps.put(ScreenIndexSummaryEnum.NHSummry.getDesc(),avgNH);
|
||||
|
||||
stationSummry.setCODSummry(avgNH);
|
||||
stationSummry.setNHSummry(avgCOD);
|
||||
stationSummry.setDateStr(wholeTime);
|
||||
stationSummry.setGroupId(survStationInfo.getGroupId());
|
||||
stationSummry.setGroupName(survStationInfo.getGroupName());
|
||||
stationSummry.setStationName(survStationInfo.getStationName());
|
||||
returnArrs.add(JSONObject.parseObject(JSONObject.toJSONString(stationSummry, SerializerFeature.WriteNullStringAsEmpty)));
|
||||
screenIndexSummaryDetailVo.setDatas(maps);
|
||||
screenIndexSummaryDetailVo.setDateStr(wholeTime);
|
||||
screenIndexSummaryDetailVo.setGroupId(survStationInfo.getGroupId());
|
||||
screenIndexSummaryDetailVo.setGroupName(survStationInfo.getGroupName());
|
||||
screenIndexSummaryDetailVo.setStationName(survStationInfo.getStationName());
|
||||
results.add(screenIndexSummaryDetailVo);
|
||||
}
|
||||
if(liveList.size()>0){
|
||||
|
||||
|
|
@ -703,28 +709,28 @@ public class BigScreenController {
|
|||
avgCOD = lastavgCOD;
|
||||
avgNO = lastavgNO;
|
||||
}
|
||||
LinkedHashMap<String, List<Double>> maps = new LinkedHashMap<>();
|
||||
|
||||
StationSummry stationSummry =new StationSummry();
|
||||
stationSummry.setTNSummry(avgTN);
|
||||
stationSummry.setTPSummry(avgTP);
|
||||
stationSummry.setNHSummry(avgNH);
|
||||
stationSummry.setCODSummry(avgCOD);
|
||||
maps.put(ScreenIndexSummaryEnum.TNSummry.getDesc(),avgTN);
|
||||
maps.put(ScreenIndexSummaryEnum.TPSummry.getDesc(),avgTP);
|
||||
maps.put(ScreenIndexSummaryEnum.NOSummry.getDesc(),avgNO);
|
||||
maps.put(ScreenIndexSummaryEnum.CODSummry.getDesc(),avgCOD);
|
||||
maps.put(ScreenIndexSummaryEnum.NHSummry.getDesc(),avgNH);
|
||||
|
||||
stationSummry.setNOSummry(avgNO);
|
||||
stationSummry.setDateStr(wholeTime);
|
||||
|
||||
stationSummry.setGroupId(survStationInfo.getGroupId());
|
||||
stationSummry.setGroupName(survStationInfo.getGroupName());
|
||||
stationSummry.setStationName(survStationInfo.getStationName());
|
||||
returnArrs.add(JSONObject.parseObject(JSONObject.toJSONString(stationSummry, SerializerFeature.WriteNullStringAsEmpty)));
|
||||
screenIndexSummaryDetailVo.setDatas(maps);
|
||||
screenIndexSummaryDetailVo.setDateStr(wholeTime);
|
||||
screenIndexSummaryDetailVo.setGroupId(survStationInfo.getGroupId());
|
||||
screenIndexSummaryDetailVo.setGroupName(survStationInfo.getGroupName());
|
||||
screenIndexSummaryDetailVo.setStationName(survStationInfo.getStationName());
|
||||
results.add(screenIndexSummaryDetailVo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
JSONObject datajob = new JSONObject();
|
||||
datajob.put("dataStr",wholeTime);
|
||||
returnArrs.add(datajob);
|
||||
return Result.ok(returnArrs);
|
||||
// JSONObject datajob = new JSONObject();
|
||||
// datajob.put("dataStr",wholeTime);
|
||||
// returnArrs.add(datajob);
|
||||
return Result.ok(results);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,53 @@
|
|||
package org.jeecg.common.constant.enums;
|
||||
|
||||
|
||||
/**
|
||||
* 大屏首页统计枚举
|
||||
*/
|
||||
public enum ScreenIndexSummaryEnum {
|
||||
TPSummry("TPSummry","总磷"),
|
||||
TNSummry("TNSummry","总氮"),
|
||||
NHSummry("NHSummry","氨氮"),
|
||||
NOSummry("NOSummry","硝态氮"),
|
||||
CODSummry("CODSummry","化学需氧量"),
|
||||
OTHER("other","其他")
|
||||
;
|
||||
|
||||
ScreenIndexSummaryEnum(String code, String desc) {
|
||||
this.code = code;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
private String code;
|
||||
private String desc;
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
public void setDesc(String desc) {
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据type获取枚举
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static ScreenIndexSummaryEnum valueOfCode(String code) {
|
||||
for (ScreenIndexSummaryEnum e : ScreenIndexSummaryEnum.values()) {
|
||||
if (e.getCode().equals(code)) {
|
||||
return e;
|
||||
}
|
||||
}
|
||||
return OTHER;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
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 ScreenIndexSummaryDetailVo {
|
||||
@JSONField(name = "datas")
|
||||
private LinkedHashMap<String, List<Double>> datas;
|
||||
@JSONField(name = "dateStr")
|
||||
private List<String> dateStr;
|
||||
@JSONField(name = "groupId")
|
||||
private String groupId;
|
||||
@JSONField(name = "groupName")
|
||||
private String groupName;
|
||||
@JSONField(name = "stationName")
|
||||
private String stationName;
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
package org.jeecg.common.vo.statistic;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class ScreenIndexSummaryVo {
|
||||
private List<ScreenIndexSummaryDetailVo> details;
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package org.jeecg.common.vo.statistic;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ScreenSummaryVo {
|
||||
@ApiModelProperty("站点编号")
|
||||
private String stationCode;
|
||||
@ApiModelProperty("开始时间")
|
||||
private String startTime;
|
||||
@ApiModelProperty("结束时间")
|
||||
private String endTime;
|
||||
@ApiModelProperty("统计模式,dayhours=日小时统计,monthDays=月每日统计,yearMonth=年每月统计")
|
||||
private String summrayMode;
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue