修复预报方案保存接口;参数配置查询接口优化
parent
8a5bb27c93
commit
a8a5e35740
|
|
@ -59,12 +59,13 @@ 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(@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());
|
||||
// }
|
||||
List<String[]> PPaRList = service.handleList(forecastPPaR);
|
||||
return R.ok(PPaRList);
|
||||
}
|
||||
|
||||
@Operation(summary = "分页")
|
||||
|
|
@ -79,8 +80,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);
|
||||
|
|
|
|||
|
|
@ -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,38 @@ import java.util.Map;
|
|||
public class ForecastPPaRService extends ServiceImpl<ForecastPPaRMapper, ForecastPPaR>
|
||||
{
|
||||
|
||||
@Autowired
|
||||
private ForecastUseparamService forecastUseparamService;
|
||||
|
||||
/**
|
||||
* @description: 获取列表
|
||||
* @param forecastPPaR
|
||||
* @return: java.util.List<java.lang.String[]>
|
||||
* @auther: cxw
|
||||
* @date: 2024-08-07, 周三, 11:11:42
|
||||
*/
|
||||
public List<String[]> handleList(ForecastPPaR forecastPPaR) {
|
||||
List<String[]> PPaRList = new ArrayList<>();
|
||||
// 获取Im值,限制pa
|
||||
BigDecimal Im = BigDecimal.ZERO;
|
||||
Map<String, Object> paramMap = forecastUseparamService.getMap(new QueryWrapper<ForecastUseparam>().eq("param_code", "Im"));
|
||||
if(paramMap != null && paramMap.size() > 0){
|
||||
Im = new BigDecimal(paramMap.get("Im").toString());
|
||||
}
|
||||
List<ForecastPPaR> forecastPPaRList = this.list();
|
||||
if(CollectionUtils.isNotEmpty(forecastPPaRList)){
|
||||
BigDecimal maxP = forecastPPaRList.stream().map(ForecastPPaR::getPsum).reduce(BigDecimal.ZERO, BigDecimal::max);
|
||||
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()));
|
||||
|
||||
|
||||
|
||||
}
|
||||
return PPaRList;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 处理批量保存
|
||||
* @param PPaRList
|
||||
|
|
@ -32,30 +68,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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue