From 61d731589c88a08c88f6355751c1eeaf1e444139 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Mon, 20 Nov 2023 16:57:56 +0800 Subject: [PATCH] =?UTF-8?q?#=E7=AB=99=E7=82=B9=E4=BF=AE=E6=94=B9=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/service/impl/HydropowerServiceImpl.java | 2 +- .../main/service/impl/SideHustleServiceImpl.java | 3 ++- .../station/service/impl/StationServiceImpl.java | 24 ++++++++++------------ 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java index adf3cb8..6e1b95c 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java @@ -1149,7 +1149,7 @@ public class HydropowerServiceImpl implements HydropowerService { long on = reals.stream().filter(real -> entry.getValue().stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(real.getDeptId()) && real.getState()).count(); long sum = reals.stream().filter(real->entry.getValue().stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(real.getDeptId())).count(); if(Math.abs(sum) > 0){ - scale.setDeviceUse(BigDecimal.valueOf(on / sum * 100).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue()); + scale.setDeviceUse(BigDecimal.valueOf(on / (double)sum * 100).setScale(1, RoundingMode.HALF_UP).doubleValue()); } } return scale; diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/SideHustleServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/SideHustleServiceImpl.java index 7cd4825..487c78c 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/SideHustleServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/SideHustleServiceImpl.java @@ -57,6 +57,7 @@ import org.springframework.stereotype.Service; import javax.validation.constraints.NotNull; import java.math.BigDecimal; +import java.math.RoundingMode; import java.sql.Time; import java.text.SimpleDateFormat; import java.time.LocalDate; @@ -1139,7 +1140,7 @@ public class SideHustleServiceImpl implements ISideHustleService { } // 机组开机总数 int onOffCount = map.entrySet().stream().filter(o->deptIds.contains(o.getKey())).mapToInt(vo-> vo.getValue().getStartingUpCount()).sum(); - return BigDecimal.valueOf(onOffCount / (double)unitSumCount * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); + return BigDecimal.valueOf(onOffCount / (double)unitSumCount * 100).setScale(2, RoundingMode.HALF_UP).doubleValue(); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java index cbf54a9..e73d35a 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java @@ -95,11 +95,11 @@ public class StationServiceImpl extends BaseServiceImpl sort = Optional.ofNullable(this.getStationMaxOrder()); req.setSort(sort.isPresent() ? sort.get() + 1 : 1); + this.pushStation(req); boolean updateResult = this.saveOrUpdate(req); Assert.isTrue(updateResult, () -> { throw new ServiceException("创建/修改站点信息失败!"); }); - this.pushStation(req); } /** @@ -130,6 +130,7 @@ public class StationServiceImpl extends BaseServiceImpl