修复ppar表的查询、保存的r取值问题
parent
8714266f67
commit
9042da1063
|
|
@ -19,7 +19,7 @@ import java.math.BigDecimal;
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@Schema(description="预报_降雨径流关系表")
|
@Schema(description="预报_降雨径流关系表")
|
||||||
@Data
|
@Data
|
||||||
@TableName("public.forecast_p_pa_r")
|
@TableName("public.forecast_p_pa_r_copy1")
|
||||||
public class ForecastPPaR extends GenericPageParams implements Serializable {
|
public class ForecastPPaR extends GenericPageParams implements Serializable {
|
||||||
|
|
||||||
public final static String thisTableName = "ForecastPPaR";
|
public final static String thisTableName = "ForecastPPaR";
|
||||||
|
|
|
||||||
|
|
@ -46,14 +46,14 @@ public class ForecastPPaRService extends ServiceImpl<ForecastPPaRMapper, Forecas
|
||||||
if (paramMap != null && paramMap.size() > 0) {
|
if (paramMap != null && paramMap.size() > 0) {
|
||||||
Im = new BigDecimal(paramMap.get("param_value").toString());
|
Im = new BigDecimal(paramMap.get("param_value").toString());
|
||||||
} else {
|
} else {
|
||||||
Im = BigDecimal.ZERO;
|
Im = BigDecimal.valueOf(120.0);
|
||||||
}
|
}
|
||||||
List<ForecastPPaR> forecastPPaRList = this.list();
|
List<ForecastPPaR> forecastPPaRList = this.list();
|
||||||
if (CollectionUtils.isNotEmpty(forecastPPaRList)) {
|
if (CollectionUtils.isNotEmpty(forecastPPaRList)) {
|
||||||
BigDecimal maxPa = forecastPPaRList.stream().map(ForecastPPaR::getPa).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> pList = forecastPPaRList.stream().map(ForecastPPaR::getPsum).distinct().sorted().collect(Collectors.toList());
|
||||||
List<BigDecimal> paList = forecastPPaRList.stream().map(ForecastPPaR::getPa).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()));
|
Map<String, BigDecimal> rSumMap = forecastPPaRList.stream().collect(Collectors.toMap(k -> k.getPsum() + "-" + k.getPa(), value -> value.getRsum()));
|
||||||
// 如果pa最大值超过了Im,截取到Im的
|
// 如果pa最大值超过了Im,截取到Im的
|
||||||
if (maxPa.compareTo(Im) > 0) {
|
if (maxPa.compareTo(Im) > 0) {
|
||||||
paList = paList.stream().filter(bd -> bd.compareTo(Im) <= 0).collect(Collectors.toList());
|
paList = paList.stream().filter(bd -> bd.compareTo(Im) <= 0).collect(Collectors.toList());
|
||||||
|
|
@ -68,11 +68,11 @@ public class ForecastPPaRService extends ServiceImpl<ForecastPPaRMapper, Forecas
|
||||||
BigDecimal p = pList.get(i);
|
BigDecimal p = pList.get(i);
|
||||||
for (int j = 0; j < paList.size(); j++) {
|
for (int j = 0; j < paList.size(); j++) {
|
||||||
BigDecimal pa = paList.get(j);
|
BigDecimal pa = paList.get(j);
|
||||||
// 每次添加r时,先添加p
|
// 每次添加rSum时,先添加p
|
||||||
if (j == 0) {
|
if (j == 0) {
|
||||||
sList.add(String.valueOf(p));
|
sList.add(String.valueOf(p));
|
||||||
}
|
}
|
||||||
sList.add(rMap.get(p + "-" + pa).stripTrailingZeros().toString());
|
sList.add(rSumMap.get(p + "-" + pa).stripTrailingZeros().toString());
|
||||||
}
|
}
|
||||||
PPaRList.add(sList.toArray(new String[0]));
|
PPaRList.add(sList.toArray(new String[0]));
|
||||||
}
|
}
|
||||||
|
|
@ -91,7 +91,7 @@ public class ForecastPPaRService extends ServiceImpl<ForecastPPaRMapper, Forecas
|
||||||
Boolean ret = false;
|
Boolean ret = false;
|
||||||
List<String> paStr = new ArrayList<>();
|
List<String> paStr = new ArrayList<>();
|
||||||
List<String> pStr = new ArrayList<>();
|
List<String> pStr = new ArrayList<>();
|
||||||
Map<String, BigDecimal> rMap = new HashMap<>();
|
Map<String, BigDecimal> rSumMap = new HashMap<>();
|
||||||
// 行
|
// 行
|
||||||
for (int i = 0; i < PPaRList.size(); i++) {
|
for (int i = 0; i < PPaRList.size(); i++) {
|
||||||
String[] paArr = PPaRList.get(i);
|
String[] paArr = PPaRList.get(i);
|
||||||
|
|
@ -109,28 +109,31 @@ public class ForecastPPaRService extends ServiceImpl<ForecastPPaRMapper, Forecas
|
||||||
p = paArr[j];
|
p = paArr[j];
|
||||||
pStr.add(p);
|
pStr.add(p);
|
||||||
}
|
}
|
||||||
// rMap:key=P-Pa
|
// rSumMap:key=P-Pa
|
||||||
if (i > 0 && j > 0) {
|
if (i > 0 && j > 0) {
|
||||||
rMap.put(p + "-" + paStr.get(j - 1), new BigDecimal(paArr[j]));
|
rSumMap.put(p + "-" + paStr.get(j - 1), new BigDecimal(paArr[j]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 组装数据
|
// 组装数据
|
||||||
if (paStr.size() > 0 && pStr.size() > 0 && rMap.size() > 0) {
|
if (paStr.size() > 0 && pStr.size() > 0 && rSumMap.size() > 0) {
|
||||||
List<ForecastPPaR> forecastPPaRList = new ArrayList<>();
|
List<ForecastPPaR> forecastPPaRList = new ArrayList<>();
|
||||||
// 外层pa
|
// 外层pa
|
||||||
for (String pa : paStr) {
|
for (String pa : paStr) {
|
||||||
// 循环一次pa,rSum需要重置
|
// 循环一次pa,r需要重置
|
||||||
BigDecimal rSum = BigDecimal.ZERO;
|
BigDecimal r = BigDecimal.ZERO;
|
||||||
|
BigDecimal lastRSum = BigDecimal.ZERO;
|
||||||
// 内层p
|
// 内层p
|
||||||
for (String p : pStr) {
|
for (String p : pStr) {
|
||||||
ForecastPPaR forecastPPaR = new ForecastPPaR();
|
ForecastPPaR forecastPPaR = new ForecastPPaR();
|
||||||
BigDecimal r = rMap.get(p + "-" + pa);
|
BigDecimal rSum = rSumMap.get(p + "-" + pa);
|
||||||
forecastPPaR.setR(r.stripTrailingZeros());
|
|
||||||
forecastPPaR.setPsum(new BigDecimal(p).stripTrailingZeros());
|
|
||||||
// 循环累加
|
|
||||||
rSum = rSum.add(r);
|
|
||||||
forecastPPaR.setRsum(rSum.stripTrailingZeros());
|
forecastPPaR.setRsum(rSum.stripTrailingZeros());
|
||||||
|
forecastPPaR.setPsum(new BigDecimal(p).stripTrailingZeros());
|
||||||
|
// 循环累减
|
||||||
|
r = rSum.subtract(lastRSum);
|
||||||
|
// 赋值
|
||||||
|
lastRSum = rSum;
|
||||||
|
forecastPPaR.setR(r.stripTrailingZeros());
|
||||||
forecastPPaR.setPa(new BigDecimal(pa).stripTrailingZeros());
|
forecastPPaR.setPa(new BigDecimal(pa).stripTrailingZeros());
|
||||||
forecastPPaRList.add(forecastPPaR);
|
forecastPPaRList.add(forecastPPaR);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue