parent
0a8e44f15b
commit
0c83299627
|
|
@ -233,7 +233,15 @@ public class AttResBaseVo {
|
||||||
@Schema(description = "灌溉流量 (m³/s)")
|
@Schema(description = "灌溉流量 (m³/s)")
|
||||||
private BigDecimal irrigationFlowSum;
|
private BigDecimal irrigationFlowSum;
|
||||||
|
|
||||||
|
@Schema(description = "灌溉时间")
|
||||||
|
@JsonFormat(pattern = DateFormatString.YYYY_MM_DD_HH_MM_SS, timezone = "GMT+8")
|
||||||
|
private Date irrigationFlowTm;
|
||||||
|
|
||||||
@Schema(description = "生态供水流量 (m³/s)")
|
@Schema(description = "生态供水流量 (m³/s)")
|
||||||
private BigDecimal ecologyFlow;
|
private BigDecimal ecologyFlow;
|
||||||
|
|
||||||
|
@Schema(description = "生态供水时间")
|
||||||
|
@JsonFormat(pattern = DateFormatString.YYYY_MM_DD_HH_MM_SS, timezone = "GMT+8")
|
||||||
|
private Date ecologyFlowTm;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -76,13 +76,17 @@ public class ReservoirWaterService {
|
||||||
|
|
||||||
for (AttResBaseVo vo : attResBaseVos) {
|
for (AttResBaseVo vo : attResBaseVos) {
|
||||||
BigDecimal rz = vo.getRz();
|
BigDecimal rz = vo.getRz();
|
||||||
List<StZvarlB> zvarlList = stZvarlBMapper.selectList(null);
|
LambdaQueryWrapper<StZvarlB> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
for (StZvarlB zvarl : zvarlList) {
|
queryWrapper.orderByAsc(StZvarlB::getRz);
|
||||||
if (zvarl.getRz().equals(rz)) {
|
List<StZvarlB> zvarlList = stZvarlBMapper.selectList(queryWrapper);
|
||||||
vo.setNowCap(zvarl.getW());
|
BigDecimal w = stZvarlBService.getWByZvarl(zvarlList, rz);
|
||||||
break;
|
vo.setNowCap(w);
|
||||||
}
|
// for (StZvarlB zvarl : zvarlList) {
|
||||||
}
|
// if (zvarl.getRz().equals(rz)) {
|
||||||
|
// vo.setNowCap(zvarl.getW());
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
//查询所有测站的库容曲线
|
//查询所有测站的库容曲线
|
||||||
// List<StZvarlB> zvarlList = queryZval(attResBaseVos.stream().map(AttResBaseVo::getStcd).collect(Collectors.toList()));
|
// List<StZvarlB> zvarlList = queryZval(attResBaseVos.stream().map(AttResBaseVo::getStcd).collect(Collectors.toList()));
|
||||||
|
|
@ -156,7 +160,14 @@ public class ReservoirWaterService {
|
||||||
totalSum = totalSum.add(stWaterRReal2.getQ());
|
totalSum = totalSum.add(stWaterRReal2.getQ());
|
||||||
}
|
}
|
||||||
for (AttResBaseVo attResBaseVo : voList) {
|
for (AttResBaseVo attResBaseVo : voList) {
|
||||||
|
//设置灌溉流量
|
||||||
attResBaseVo.setIrrigationFlowSum(totalSum);
|
attResBaseVo.setIrrigationFlowSum(totalSum);
|
||||||
|
//设置灌溉流量时间
|
||||||
|
if(stWaterRReal1 != null){
|
||||||
|
attResBaseVo.setIrrigationFlowTm(stWaterRReal1.getTm());
|
||||||
|
}else if(stWaterRReal2 != null){
|
||||||
|
attResBaseVo.setIrrigationFlowTm(stWaterRReal2.getTm());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//获取新建生态供水流量站最新得流量
|
//获取新建生态供水流量站最新得流量
|
||||||
String ecologyStcd = "1114";
|
String ecologyStcd = "1114";
|
||||||
|
|
@ -164,7 +175,10 @@ public class ReservoirWaterService {
|
||||||
ecologyQw.eq("stcd", ecologyStcd).orderBy(true, false, "tm");
|
ecologyQw.eq("stcd", ecologyStcd).orderBy(true, false, "tm");
|
||||||
StWaterRReal ecologyWaterRReal = stWaterRRealService.getOne(ecologyQw);
|
StWaterRReal ecologyWaterRReal = stWaterRRealService.getOne(ecologyQw);
|
||||||
if(ecologyWaterRReal != null){
|
if(ecologyWaterRReal != null){
|
||||||
voList.stream().forEach(o -> o.setEcologyFlow(ecologyWaterRReal.getQ()));
|
voList.stream().forEach(o -> {
|
||||||
|
o.setEcologyFlow(ecologyWaterRReal.getQ());
|
||||||
|
o.setEcologyFlowTm(ecologyWaterRReal.getTm());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return voList;
|
return voList;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -243,64 +243,89 @@ public class StStbprpBService extends ServiceImpl<StStbprpBMapper, StStbprpB> {
|
||||||
BigDecimal maxYearSv = BigDecimal.ZERO;
|
BigDecimal maxYearSv = BigDecimal.ZERO;
|
||||||
Date maxQStartTime = null;
|
Date maxQStartTime = null;
|
||||||
Date maxQEndTime = null;
|
Date maxQEndTime = null;
|
||||||
boolean inMaxQPeriod = false;
|
|
||||||
int idx = 0;
|
// 用于跟踪当前连续的最大值段
|
||||||
for (int i =0;i<rsvrList.size();i++) {
|
Date currentSegmentStart = null;
|
||||||
|
BigDecimal currentSegmentValue = BigDecimal.ZERO;
|
||||||
|
boolean segmentActive = false;
|
||||||
|
|
||||||
|
for (int i = 0; i < rsvrList.size(); i++) {
|
||||||
StRsvrR rsvr = rsvrList.get(i);
|
StRsvrR rsvr = rsvrList.get(i);
|
||||||
RsvrComplexVo complex = new RsvrComplexVo();
|
RsvrComplexVo complex = new RsvrComplexVo();
|
||||||
BigDecimal rz = new BigDecimal(rsvr.getRz());
|
BigDecimal rz = new BigDecimal(rsvr.getRz());
|
||||||
complex.setRz(rz);
|
complex.setRz(rz);
|
||||||
complex.setTm(rsvr.getTm());
|
complex.setTm(rsvr.getTm());
|
||||||
|
|
||||||
//TODO 这里需要重新计算水位-流量(溢洪量)对应数据
|
|
||||||
//BigDecimal q = stZqrlBService.getQFromZqrl(rz, zqrlList);
|
|
||||||
BigDecimal q = stZqrlBService.getQByZqrl(zqrlList, rz);
|
BigDecimal q = stZqrlBService.getQByZqrl(zqrlList, rz);
|
||||||
complex.setQ(q);
|
complex.setQ(q);
|
||||||
// complex.setSv(complex.getQ());
|
|
||||||
complex.setSv(complex.getQ().multiply(BigDecimal.valueOf(60 * 60)));
|
complex.setSv(complex.getQ().multiply(BigDecimal.valueOf(60 * 60)));
|
||||||
if(i == 0){
|
|
||||||
|
if (i == 0) {
|
||||||
complex.setTotalSv(BigDecimal.ZERO);
|
complex.setTotalSv(BigDecimal.ZERO);
|
||||||
}else{
|
} else {
|
||||||
RsvrComplexVo pre = complexList.get(i - 1);
|
RsvrComplexVo pre = complexList.get(i - 1);
|
||||||
complex.setTotalSv(pre.getTotalSv().add(complex.getQ().multiply(BigDecimal.valueOf(60 * 60))));
|
complex.setTotalSv(pre.getTotalSv().add(complex.getQ().multiply(BigDecimal.valueOf(60 * 60))));
|
||||||
}
|
}
|
||||||
if(complex.getSv().compareTo(BigDecimal.ZERO) > 0){
|
|
||||||
int compare = complex.getSv().compareTo(maxYearSv);
|
BigDecimal currentSv = complex.getSv();
|
||||||
if(compare > 0){
|
complexList.add(complex);
|
||||||
//发现更大的溢洪流量
|
|
||||||
maxYearSv = complex.getSv();
|
/**
|
||||||
maxQStartTime = rsvr.getTm();
|
* 嗯,这段代码,,,希望未来的你能看得懂
|
||||||
maxQEndTime = null;
|
*/
|
||||||
inMaxQPeriod = true;
|
// 处理溢洪量逻辑
|
||||||
}else if(compare == 0 && inMaxQPeriod){
|
if (currentSv.compareTo(BigDecimal.ZERO) > 0) {
|
||||||
// 连续的最大Q值,更新结束时间
|
// 1. 发现更大的溢洪量
|
||||||
// 如果是最后一条数据,使用当前时间作为结束时间
|
if (currentSv.compareTo(maxYearSv) > 0) {
|
||||||
if (i == rsvrList.size() - 1) {
|
maxYearSv = currentSv;
|
||||||
maxQEndTime = now;
|
// 开始新的最大值段
|
||||||
} else {
|
currentSegmentStart = rsvr.getTm();
|
||||||
maxQEndTime = rsvrList.get(i + 1).getTm();
|
currentSegmentValue = currentSv;
|
||||||
}
|
segmentActive = true;
|
||||||
}else{
|
maxQStartTime = currentSegmentStart;
|
||||||
// Q值变小,结束当前最大Q值期间
|
maxQEndTime = null; // 重置结束时间
|
||||||
inMaxQPeriod = false;
|
}
|
||||||
|
// 2. 等于当前最大值且在活跃段中
|
||||||
|
else if (currentSv.compareTo(maxYearSv) == 0 && segmentActive) {
|
||||||
|
// 继续当前段,不更新结束时间(等待第一个小于的值)
|
||||||
|
// 这里什么都不做,保持当前状态
|
||||||
|
}
|
||||||
|
// 3. 小于当前最大值且在活跃段中
|
||||||
|
else if (currentSv.compareTo(maxYearSv) < 0 && segmentActive) {
|
||||||
|
// 找到第一个小于最大值的点,作为结束时间
|
||||||
|
maxQEndTime = rsvr.getTm();
|
||||||
|
segmentActive = false; // 结束当前段
|
||||||
|
}
|
||||||
|
// 4. 等于当前最大值但不在活跃段中(新的连续段开始)
|
||||||
|
else if (currentSv.compareTo(maxYearSv) == 0 && !segmentActive) {
|
||||||
|
// 开始新的连续段
|
||||||
|
currentSegmentStart = rsvr.getTm();
|
||||||
|
currentSegmentValue = currentSv;
|
||||||
|
segmentActive = true;
|
||||||
|
// 更新全局开始时间(取最新的开始时间)
|
||||||
|
maxQStartTime = currentSegmentStart;
|
||||||
|
maxQEndTime = null; // 重置结束时间
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 遇到0值且在活跃段中
|
||||||
|
if (segmentActive && currentSegmentValue.compareTo(maxYearSv) == 0) {
|
||||||
|
// 找到第一个小于最大值的点(0值),作为结束时间
|
||||||
|
maxQEndTime = rsvr.getTm();
|
||||||
|
segmentActive = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
complexList.add(complex);
|
|
||||||
idx++;
|
|
||||||
}
|
}
|
||||||
// 设置最大Q值及其时间范围
|
|
||||||
|
// 处理最后一条数据仍是最大值的情况
|
||||||
|
if (segmentActive && maxQStartTime != null && maxQEndTime == null) {
|
||||||
|
maxQEndTime = new Date(); // 结束时间为当前时间
|
||||||
|
}
|
||||||
|
// 设置结果
|
||||||
vo.setCurrYearMaxVal(maxYearSv);
|
vo.setCurrYearMaxVal(maxYearSv);
|
||||||
if (maxQStartTime != null) {
|
if (maxQStartTime != null && maxQEndTime != null) {
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
if (maxQEndTime != null) {
|
String period = sdf.format(maxQStartTime) + " ~ " + sdf.format(maxQEndTime);
|
||||||
String period = sdf.format(maxQStartTime) + " ~ " + sdf.format(maxQEndTime);
|
vo.setMaxOverflowPeriod(period);
|
||||||
vo.setMaxOverflowPeriod(period);
|
|
||||||
} else {
|
|
||||||
// 如果最大Q值只出现在一个时间点,时间范围就是这个时间点
|
|
||||||
String period = sdf.format(maxQStartTime);
|
|
||||||
vo.setMaxOverflowPeriod(period);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
vo.setMaxOverflowPeriod("无溢洪记录");
|
vo.setMaxOverflowPeriod("无溢洪记录");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -94,11 +94,11 @@ public class StZvarlBService extends ServiceImpl<StZvarlBMapper, StZvarlB> {
|
||||||
BigDecimal minRz = zvarlBS.get(0).getRz();
|
BigDecimal minRz = zvarlBS.get(0).getRz();
|
||||||
BigDecimal maxRz = zvarlBS.get(zvarlBS.size() - 1).getRz();
|
BigDecimal maxRz = zvarlBS.get(zvarlBS.size() - 1).getRz();
|
||||||
if (rz.compareTo(minRz) < 0) {
|
if (rz.compareTo(minRz) < 0) {
|
||||||
// 低于最低水位,可以选择抛出异常或进行外推(这里选择抛出异常)
|
// 低于最低水位,返回值0
|
||||||
return BigDecimal.ZERO;
|
return BigDecimal.ZERO;
|
||||||
}
|
}
|
||||||
if (rz.compareTo(maxRz) > 0) {
|
if (rz.compareTo(maxRz) > 0) {
|
||||||
// 高于最高水位,可以选择抛出异常或进行外推(这里选择抛出异常)
|
// 高于最高水位,返回值0
|
||||||
return BigDecimal.ZERO;
|
return BigDecimal.ZERO;
|
||||||
}
|
}
|
||||||
int l = 0;
|
int l = 0;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue