From 834f17659be2ff833e350217990b3e55d7135791 Mon Sep 17 00:00:00 2001 From: yangzhe123 <2824096059@qq.com> Date: Tue, 4 Nov 2025 15:22:31 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=A0=B7=E7=94=B1=E4=BA=8E=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E5=B7=AE-=E5=8E=BB=E6=8E=89=E5=88=86=E7=A7=92?= =?UTF-8?q?=E7=9A=84=E9=99=90=E5=88=B6(=E5=8F=8D=E6=AD=A3=E4=B8=80?= =?UTF-8?q?=E5=B0=8F=E6=97=B6=E5=8F=AA=E6=9C=89=E4=B8=80=E6=9D=A1=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gunshi/project/hsz/service/StStbprpBService.java | 6 ++++-- .../com/gunshi/project/hsz/service/StZvarlBService.java | 4 ++-- src/main/resources/mapper/StPptnRHMapper.xml | 3 +-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/gunshi/project/hsz/service/StStbprpBService.java b/src/main/java/com/gunshi/project/hsz/service/StStbprpBService.java index dc63594..2dd29ef 100644 --- a/src/main/java/com/gunshi/project/hsz/service/StStbprpBService.java +++ b/src/main/java/com/gunshi/project/hsz/service/StStbprpBService.java @@ -181,7 +181,7 @@ public class StStbprpBService extends ServiceImpl { //累计溢洪量 = 上一条数据累计溢洪量 + 本条溢洪流量 * 2条数据之间的间隔 Instant curInstant = vo.getTm().toInstant(); Instant preInstant = voPrev.getTm().toInstant(); - long timeDiffSeconds = Duration.between(curInstant, preInstant).getSeconds(); + long timeDiffSeconds = Duration.between(preInstant, curInstant).getSeconds(); //TODO 或者改成60 * 60 .multiply(BigDecimal.valueOf(60 * 60)) BigDecimal qTotal = voPrev.getQtotal().add(vo.getFlowNum().multiply(BigDecimal.valueOf(timeDiffSeconds))); vo.setQtotal(qTotal); @@ -231,7 +231,9 @@ public class StStbprpBService extends ServiceImpl { .between(StRsvrR::getTm, yearStart, now) .orderByAsc(true, StRsvrR::getTm) .list(); - + if(rsvrList.isEmpty()){ + return vo; + } //获取水位流量关系 List zqrlList = stZqrlBService.list(); zqrlList.sort(Comparator.comparing(StZqrlB::getZ)); diff --git a/src/main/java/com/gunshi/project/hsz/service/StZvarlBService.java b/src/main/java/com/gunshi/project/hsz/service/StZvarlBService.java index 2943804..e9c79d9 100644 --- a/src/main/java/com/gunshi/project/hsz/service/StZvarlBService.java +++ b/src/main/java/com/gunshi/project/hsz/service/StZvarlBService.java @@ -155,8 +155,8 @@ public class StZvarlBService extends ServiceImpl { BigDecimal xDiff = x.subtract(x1); BigDecimal product = slope.multiply(xDiff); - // 计算最终结果: y1 + product - return y1.add(product); + // 计算最终结果: y1 + product,并设置小数位数和舍入模式 + return y1.add(product).setScale(3, RoundingMode.HALF_UP); } } diff --git a/src/main/resources/mapper/StPptnRHMapper.xml b/src/main/resources/mapper/StPptnRHMapper.xml index 90ee009..ac6fee2 100644 --- a/src/main/resources/mapper/StPptnRHMapper.xml +++ b/src/main/resources/mapper/StPptnRHMapper.xml @@ -10,7 +10,6 @@ @@ -43,7 +42,7 @@