From 7321f972b0b8cbe06b9c002a61477f64866512c8 Mon Sep 17 00:00:00 2001 From: yangwei <867012372@qq.com> Date: Tue, 22 Apr 2025 10:18:04 +0800 Subject: [PATCH] =?UTF-8?q?[feat]=201=E3=80=81=E4=BF=AE=E6=94=B9=E6=A0=B9?= =?UTF-8?q?=E6=8D=AE=E8=AE=BE=E5=A4=87=E6=9D=83=E9=99=90=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E9=A3=9E=E8=A1=8C=E6=97=B6=E9=95=BF=E3=80=81=E9=A3=9E=E8=A1=8C?= =?UTF-8?q?=E6=80=BB=E4=BB=B7=E6=AC=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BusinessAlertStatisticsServiceImpl.java | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertStatisticsServiceImpl.java b/dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertStatisticsServiceImpl.java index 113719e..a973c67 100644 --- a/dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertStatisticsServiceImpl.java +++ b/dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertStatisticsServiceImpl.java @@ -6,6 +6,7 @@ import lombok.RequiredArgsConstructor; import org.apache.dubbo.config.annotation.DubboReference; import org.dromara.business.domain.bo.BusinessAlertBo; import org.dromara.business.domain.model.StatObj; +import org.dromara.business.feign.FeignDeviceGroup; import org.dromara.business.mapper.BusinessAlertMapper; import org.dromara.business.service.IBusinessAlertStatisticsService; import org.dromara.common.core.exception.ServiceException; @@ -20,6 +21,7 @@ import org.dromara.system.api.domain.vo.RemoteDeptVo; import org.dromara.system.api.domain.vo.RemotePostVo; import org.dromara.system.api.model.LoginUser; import org.dromara.system.api.model.RoleDTO; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.math.BigDecimal; @@ -58,6 +60,10 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist @DubboReference(timeout = 30000) RemoteDataScopeService remoteDataScopeService; + @Autowired + FeignDeviceGroup feignDeviceGroup; + + /** * 按照月份分类预警数量 * @param businessAlertBo @@ -176,7 +182,17 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist //----------------------------------------------获取飞行总架次、总时长---------------------------------------------- //获取飞行总架次、总时长 - Map countMap = RedisUtils.getCacheMap(FLY_COUNT); + //获取机场信息根据当前登录人 + List deviceSnList = ObjectUtil.isNotEmpty(feignDeviceGroup.listDevice(LoginHelper.getUserId()))?feignDeviceGroup.listDevice(LoginHelper.getUserId()):ListUtil.empty(); + + + //过滤redis中用户所拥有的设备 + Map countMap = Optional.ofNullable(RedisUtils.getCacheMap(FLY_COUNT)) + .map(map -> map.entrySet().stream() + .filter(entry -> deviceSnList.contains(entry.getKey())) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue))) + .orElse(new HashMap<>()); + int flyCount; if (ObjectUtil.isNotEmpty(countMap)){ @@ -193,7 +209,14 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist flyCount = 0; } - Map accTimeMap = RedisUtils.getCacheMap(FLY_ACC_TIME); + //过滤redis中用户所拥有的设备 + Map accTimeMap = Optional.ofNullable(RedisUtils.getCacheMap(FLY_ACC_TIME)) + .map(map -> map.entrySet().stream() + .filter(entry -> deviceSnList.contains(entry.getKey())) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue))) + .orElse(new HashMap<>()); + + double flyAccTime; if (ObjectUtil.isNotEmpty(accTimeMap)) {