Merge remote-tracking branch 'origin/master'
commit
5b8cebda5d
|
|
@ -59,12 +59,9 @@ public class ForecastPPaRController {
|
|||
|
||||
@Operation(summary = "列表")
|
||||
@PostMapping("/list")
|
||||
public R<List<ForecastPPaR>> list(@RequestBody @Validated ForecastPPaR forecastPPaR) {
|
||||
QueryWrapper<ForecastPPaR> wrapper = new QueryWrapper<ForecastPPaR>();
|
||||
if(StringUtils.isNotBlank(forecastPPaR.getSortField())){
|
||||
wrapper.orderBy(true, ObjectUtils.isEmpty(forecastPPaR.getIsAsc()) ? false : forecastPPaR.getIsAsc(), forecastPPaR.getSortField());
|
||||
}
|
||||
return R.ok(service.list(wrapper));
|
||||
public R<List<String[]>> list() {
|
||||
List<String[]> PPaRList = service.handleList();
|
||||
return R.ok(PPaRList);
|
||||
}
|
||||
|
||||
@Operation(summary = "分页")
|
||||
|
|
@ -79,8 +76,8 @@ public class ForecastPPaRController {
|
|||
|
||||
@Operation(summary = "批量保存")
|
||||
@PostMapping("/saveBatch")
|
||||
public R<Boolean> saveBatch(@RequestBody String[][] PPaRList) {
|
||||
if (PPaRList.length == 0) {
|
||||
public R<Boolean> saveBatch(@RequestBody List<String[]> PPaRList) {
|
||||
if (PPaRList.size() == 0) {
|
||||
throw new IllegalArgumentException("数据格式不正确");
|
||||
}
|
||||
boolean result = service.handleSaveBatch(PPaRList);
|
||||
|
|
|
|||
|
|
@ -128,6 +128,7 @@ public class ForecastProjectController {
|
|||
List<ForecastResults> resultList = forecastResultsService.list(new QueryWrapper<ForecastResults>().eq("project_id", projectId));
|
||||
if(CollectionUtils.isNotEmpty(resultList)) {
|
||||
forecastProject.setVoList(JSON.parseArray(JSON.toJSONString(resultList), ForecastResultVo.class));
|
||||
forecastResultsService.handleVoList(forecastProject);
|
||||
}
|
||||
return R.ok(forecastProject);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.gunshi.project.xyt.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
|
@ -26,6 +27,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 描述: 预报_预测结果表
|
||||
* author: cxw
|
||||
|
|
@ -39,7 +41,6 @@ public class ForecastResultsController {
|
|||
@Autowired
|
||||
private ForecastResultsService service;
|
||||
|
||||
|
||||
@Operation(summary = "新增")
|
||||
@PostMapping("/insert")
|
||||
public R<ForecastResults> insert(@Validated(Insert.class) @RequestBody ForecastResults dto) {
|
||||
|
|
@ -93,6 +94,9 @@ public class ForecastResultsController {
|
|||
forecastProject.setForecastPeriod(forecastTask.getForecastPeriod());
|
||||
forecastProject.setForecastWarm(forecastTask.getForecastWarm());
|
||||
forecastProject.setVoList(voList);
|
||||
if (CollectionUtils.isNotEmpty(voList)) {
|
||||
service.handleVoList(forecastProject);
|
||||
}
|
||||
return R.ok(forecastProject);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
|||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
*@description 预测结果VO
|
||||
|
|
|
|||
|
|
@ -148,4 +148,31 @@ public class ForecastProject extends GenericPageParams implements Serializable {
|
|||
@TableField(exist = false)
|
||||
private List<ForecastResultVo> voList;
|
||||
|
||||
/**
|
||||
* 预报最高调洪水位(m)
|
||||
*/
|
||||
@Schema(description = "预报最高调洪水位(m)")
|
||||
@TableField(exist = false)
|
||||
private BigDecimal ycMaxSwH;
|
||||
|
||||
/**
|
||||
* 预报最大入库流量(m³/s)
|
||||
*/
|
||||
@Schema(description = "预报最大入库流量")
|
||||
@TableField(exist = false)
|
||||
private BigDecimal ycMaxRkQ;
|
||||
|
||||
/**
|
||||
* 预报最大下泄流量(m³/s)
|
||||
*/
|
||||
@Schema(description = "预报最大下泄流量(m³/s)")
|
||||
@TableField(exist = false)
|
||||
private BigDecimal ycMaxCkQ;
|
||||
|
||||
/**
|
||||
* 预报洪水总量(万m³)
|
||||
*/
|
||||
@Schema(description = "预报洪水总量(万m³)")
|
||||
@TableField(exist = false)
|
||||
private BigDecimal ycSumFlood;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.gunshi.project.xyt.model;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
|
|
@ -9,8 +10,6 @@ import com.fasterxml.jackson.annotation.JsonFormat;
|
|||
import com.gunshi.core.dateformat.DateFormatString;
|
||||
import com.gunshi.project.xyt.entity.page.GenericPageParams;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
|
@ -44,6 +43,7 @@ public class ForecastResults extends GenericPageParams implements Serializable {
|
|||
@TableField(value="tm")
|
||||
@Schema(description="时间")
|
||||
@JsonFormat(pattern = DateFormatString.YYYY_MM_DD_HH_MM_SS, timezone = "GMT+8")
|
||||
@JSONField(format = DateFormatString.YYYY_MM_DD_HH_MM_SS)
|
||||
private Date tm;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@ import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
|||
import com.gunshi.core.dateformat.DateFormatString;
|
||||
import com.gunshi.project.xyt.entity.page.GenericPageParams;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
|
||||
|
|
@ -47,8 +45,6 @@ public class ForecastUseparam extends GenericPageParams implements Serializable
|
|||
@TableField(value="param_name")
|
||||
@Schema(description="参数名称")
|
||||
@Size(max = 255,message = "参数名称最大长度要小于 255")
|
||||
@NotBlank(message = "参数名称不能为空")
|
||||
@NotNull(message = "参数名称不能为空")
|
||||
private String paramName;
|
||||
|
||||
/**
|
||||
|
|
@ -57,8 +53,6 @@ public class ForecastUseparam extends GenericPageParams implements Serializable
|
|||
@TableField(value="param_code")
|
||||
@Schema(description="参数名")
|
||||
@Size(max = 255,message = "参数名最大长度要小于 255")
|
||||
@NotBlank(message = "参数名不能为空")
|
||||
@NotNull(message = "参数名不能为空")
|
||||
private String paramCode;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ public class TaskGroupJob implements Job {
|
|||
Map<String, Object> map = forecastUseparamService.getMap(new QueryWrapper<ForecastUseparam>().eq("param_code", "ydgdyjz"));// 获取安全值
|
||||
AttResBase attResBase = attResBaseService.getOne(new QueryWrapper<>());// 获取堰顶高程
|
||||
if (MapUtil.isNotEmpty(map) && ObjectUtils.isNotEmpty(attResBase) && ObjectUtils.isNotEmpty(attResBase.getWcrstel())) {
|
||||
BigDecimal ydgdyjz = new BigDecimal(map.get("ydgdyjz").toString());
|
||||
BigDecimal ydgdyjz = new BigDecimal(map.get("param_value").toString());
|
||||
BigDecimal wcrstel = attResBase.getWcrstel();
|
||||
Boolean isSave = false;
|
||||
for (ForecastResultVo vo : voList) {
|
||||
|
|
@ -117,7 +117,10 @@ public class TaskGroupJob implements Job {
|
|||
forecastProject.setTimeInterval(forecastTask.getTimeInterval());
|
||||
forecastProject.setTaskId(forecastTask.getId());
|
||||
forecastProject.setVoList(voList);
|
||||
forecastProjectService.saveForecastResults(forecastProject);
|
||||
boolean save = forecastProjectService.save(forecastProject);
|
||||
if (save) {
|
||||
forecastProjectService.saveForecastResults(forecastProject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,13 @@
|
|||
package com.gunshi.project.xyt.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gunshi.project.xyt.mapper.ForecastPPaRMapper;
|
||||
import com.gunshi.project.xyt.model.ForecastPPaR;
|
||||
import com.gunshi.project.xyt.model.ForecastUseparam;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
|
|
@ -13,6 +16,7 @@ import java.util.ArrayList;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 描述: 预报_降雨径流关系表
|
||||
|
|
@ -25,6 +29,57 @@ import java.util.Map;
|
|||
public class ForecastPPaRService extends ServiceImpl<ForecastPPaRMapper, ForecastPPaR>
|
||||
{
|
||||
|
||||
@Autowired
|
||||
private ForecastUseparamService forecastUseparamService;
|
||||
|
||||
/**
|
||||
* @description: 获取列表
|
||||
* @return: java.util.List<java.lang.String[]>
|
||||
* @auther: cxw
|
||||
* @date: 2024-08-07, 周三, 11:11:42
|
||||
*/
|
||||
public List<String[]> handleList() {
|
||||
List<String[]> PPaRList = new ArrayList<>();
|
||||
// 获取Im值,限制pa
|
||||
BigDecimal Im;
|
||||
Map<String, Object> paramMap = forecastUseparamService.getMap(new QueryWrapper<ForecastUseparam>().eq("param_code", "Im"));
|
||||
if (paramMap != null && paramMap.size() > 0) {
|
||||
Im = new BigDecimal(paramMap.get("param_value").toString());
|
||||
} else {
|
||||
Im = BigDecimal.ZERO;
|
||||
}
|
||||
List<ForecastPPaR> forecastPPaRList = this.list();
|
||||
if (CollectionUtils.isNotEmpty(forecastPPaRList)) {
|
||||
BigDecimal maxPa = forecastPPaRList.stream().map(ForecastPPaR::getPa).reduce(BigDecimal.ZERO, BigDecimal::max);
|
||||
List<BigDecimal> pList = forecastPPaRList.stream().map(ForecastPPaR::getPsum).distinct().sorted().collect(Collectors.toList());
|
||||
List<BigDecimal> paList = forecastPPaRList.stream().map(ForecastPPaR::getPa).distinct().sorted().collect(Collectors.toList());
|
||||
Map<String, BigDecimal> rMap = forecastPPaRList.stream().collect(Collectors.toMap(k -> k.getPsum() + "-" + k.getPa(), value -> value.getR()));
|
||||
// 如果pa最大值超过了Im,截取到Im的
|
||||
if (maxPa.compareTo(Im) > 0) {
|
||||
paList = paList.stream().filter(bd -> bd.compareTo(Im) <= 0).collect(Collectors.toList());
|
||||
}
|
||||
List<String> sList = new ArrayList<>();
|
||||
// 先添加第一行的Pa
|
||||
sList.add("P/R/Pa");
|
||||
sList.addAll(paList.stream().map(BigDecimal::toString).collect(Collectors.toList()));
|
||||
PPaRList.add(sList.toArray(new String[0]));
|
||||
for (int i = 0; i < pList.size(); i++) {
|
||||
sList = new ArrayList<>();
|
||||
BigDecimal p = pList.get(i);
|
||||
for (int j = 0; j < paList.size(); j++) {
|
||||
BigDecimal pa = paList.get(j);
|
||||
// 每次添加r时,先添加p
|
||||
if (j == 0) {
|
||||
sList.add(String.valueOf(p));
|
||||
}
|
||||
sList.add(rMap.get(p + "-" + pa).stripTrailingZeros().toString());
|
||||
}
|
||||
PPaRList.add(sList.toArray(new String[0]));
|
||||
}
|
||||
}
|
||||
return PPaRList;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 处理批量保存
|
||||
* @param PPaRList
|
||||
|
|
@ -32,30 +87,31 @@ public class ForecastPPaRService extends ServiceImpl<ForecastPPaRMapper, Forecas
|
|||
* @auther: cxw
|
||||
* @date: 2024-08-06, 周二, 15:29:29
|
||||
*/
|
||||
public boolean handleSaveBatch(String[][] PPaRList) {
|
||||
public boolean handleSaveBatch(List<String[]> PPaRList) {
|
||||
Boolean ret = false;
|
||||
List<String> paStr = new ArrayList<>();
|
||||
List<String> pStr = new ArrayList<>();
|
||||
Map<String, BigDecimal> rMap = new HashMap<>();
|
||||
// 行
|
||||
for (int i = 0; i < PPaRList.length; i++) {
|
||||
for (int i = 0; i < PPaRList.size(); i++) {
|
||||
String[] paArr = PPaRList.get(i);
|
||||
String p = "";
|
||||
// 列
|
||||
for (int j = 0; j < PPaRList[i].length; j++) {
|
||||
for (int j = 0; j < paArr.length; j++) {
|
||||
String pa = "";
|
||||
// 第一行:pa
|
||||
if(i == 0 && j > 0){
|
||||
pa = PPaRList[i][j];
|
||||
pa = paArr[j];
|
||||
paStr.add(pa);
|
||||
}
|
||||
// 第一列:p
|
||||
if(i > 0 && j == 0){
|
||||
p = PPaRList[i][j];
|
||||
p = paArr[j];
|
||||
pStr.add(p);
|
||||
}
|
||||
// rMap:key=P-Pa
|
||||
if (i > 0 && j > 0) {
|
||||
rMap.put(p + "-" + paStr.get(j - 1), new BigDecimal(PPaRList[i][j]));
|
||||
rMap.put(p + "-" + paStr.get(j - 1), new BigDecimal(paArr[j]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ public class ForecastProjectService extends ServiceImpl<ForecastProjectMapper, F
|
|||
forecastResults.setProjectId(forecastProject.getId());
|
||||
forecastResults.setFlLowLimLev(vo.getFlLowLimLev());
|
||||
forecastResults.setPa(vo.getPa());
|
||||
retList.add(forecastResults);
|
||||
}
|
||||
return forecastResultsService.saveBatch(retList);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import com.gunshi.project.xyt.grb.RainGrib2Layer;
|
|||
import com.gunshi.project.xyt.mapper.ForecastResultsMapper;
|
||||
import com.gunshi.project.xyt.model.AttResBase;
|
||||
import com.gunshi.project.xyt.model.ForecastPa;
|
||||
import com.gunshi.project.xyt.model.ForecastProject;
|
||||
import com.gunshi.project.xyt.model.ForecastResults;
|
||||
import com.gunshi.project.xyt.model.ForecastTask;
|
||||
import com.gunshi.project.xyt.model.ForecastU;
|
||||
|
|
@ -416,4 +417,43 @@ public class ForecastResultsService extends ServiceImpl<ForecastResultsMapper, F
|
|||
calendar.set(Calendar.MILLISECOND, 0);
|
||||
return date.before(calendar.getTime());
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 处理voList,获取预报最大属性值
|
||||
* @param forecastProject
|
||||
* @return: void
|
||||
* @auther: cxw
|
||||
* @date: 2024-08-07, 周三, 15:52:19
|
||||
*/
|
||||
public void handleVoList(ForecastProject forecastProject) {
|
||||
Map<String, Object> paramMap = forecastUseparamService.getMap(new QueryWrapper<ForecastUseparam>().eq("param_code", "dt"));
|
||||
if(paramMap != null){
|
||||
BigDecimal dt = new BigDecimal(paramMap.get("param_value").toString());// 时间间隔:小时h
|
||||
BigDecimal ycMaxSwH = BigDecimal.ZERO;// 预报最高调洪水位
|
||||
BigDecimal ycMaxRkQ = BigDecimal.ZERO;// 预报最大入库流量
|
||||
BigDecimal ycMaxCkQ = BigDecimal.ZERO;// 预报最大下泄流量
|
||||
BigDecimal ycSumRkQ = BigDecimal.ZERO;// 预报入库流量累计和
|
||||
for (ForecastResultVo vo : forecastProject.getVoList()){
|
||||
BigDecimal ycSwHValue = vo.getYcSwHValue();
|
||||
if (ycSwHValue.compareTo(ycMaxSwH) > 0) {
|
||||
ycMaxSwH = ycSwHValue;
|
||||
}
|
||||
BigDecimal ycRkQValue = vo.getYcRkQValue();
|
||||
if (ycRkQValue.compareTo(ycMaxRkQ) > 0) {
|
||||
ycMaxRkQ = ycRkQValue;
|
||||
}
|
||||
BigDecimal ycCkQValue = vo.getYcCkQValue();
|
||||
if (ycCkQValue.compareTo(ycMaxCkQ) > 0) {
|
||||
ycMaxCkQ = ycCkQValue;
|
||||
}
|
||||
ycSumRkQ = ycSumRkQ.add(ycRkQValue);
|
||||
}
|
||||
// 预报洪水总量(万m³)=预报入库流量累计和 X (dt*60*60) / 10000
|
||||
BigDecimal ycSumFlood = ycSumRkQ.multiply((dt.multiply(new BigDecimal(3600)))).divide(new BigDecimal(10000), 6, BigDecimal.ROUND_HALF_UP).stripTrailingZeros();
|
||||
forecastProject.setYcMaxSwH(ycMaxSwH);
|
||||
forecastProject.setYcMaxRkQ(ycMaxRkQ);
|
||||
forecastProject.setYcMaxCkQ(ycMaxCkQ);
|
||||
forecastProject.setYcSumFlood(ycSumFlood);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue