From 9172742ed9e94cf9a14d5542800a170638a9208d Mon Sep 17 00:00:00 2001 From: yangwei <867012372@qq.com> Date: Fri, 28 Mar 2025 16:34:08 +0800 Subject: [PATCH] =?UTF-8?q?[feat]=201=E3=80=81=E5=A2=9E=E5=8A=A0=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E8=8E=B7=E5=8F=96=E9=A3=9E=E8=A1=8C=E6=9E=B6=E6=AC=A1?= =?UTF-8?q?=E3=80=81=E9=A3=9E=E8=A1=8C=E6=97=B6=E9=95=BF=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/core/constant/Constants.java | 9 +++ .../BusinessAlertStatisticsServiceImpl.java | 55 ++++++++++++++++--- 2 files changed, 55 insertions(+), 9 deletions(-) diff --git a/dk-common/common-core/src/main/java/org/dromara/common/core/constant/Constants.java b/dk-common/common-core/src/main/java/org/dromara/common/core/constant/Constants.java index cdbda89..1f89f3f 100644 --- a/dk-common/common-core/src/main/java/org/dromara/common/core/constant/Constants.java +++ b/dk-common/common-core/src/main/java/org/dromara/common/core/constant/Constants.java @@ -77,5 +77,14 @@ public interface Constants { */ Long TOP_PARENT_ID = 0L; + /** + * 飞行总架次 + */ + String FLY_COUNT = "fly_count"; + + /** + * 飞行总时长 + */ + String FLY_ACC_TIME = "fly_accTime"; } 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 cea17e9..16b398f 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 @@ -9,7 +9,9 @@ import org.dromara.business.domain.model.StatObj; import org.dromara.business.mapper.BusinessAlertMapper; import org.dromara.business.service.IBusinessAlertStatisticsService; import org.dromara.common.core.exception.ServiceException; +import org.dromara.common.redis.utils.RedisOpsUtils; import org.dromara.common.satoken.utils.LoginHelper; +import org.dromara.common.tenant.helper.TenantHelper; import org.dromara.system.api.RemoteDeptService; import org.dromara.system.api.RemoteLabelPostService; import org.dromara.system.api.RemotePostService; @@ -17,7 +19,7 @@ import org.dromara.system.api.domain.vo.RemoteAiLabelPostVo; import org.dromara.system.api.domain.vo.RemoteDeptVo; import org.dromara.system.api.domain.vo.RemotePostVo; import org.springframework.stereotype.Service; - +import org.dromara.common.redis.utils.RedisUtils; import java.math.BigDecimal; import java.math.RoundingMode; import java.time.LocalDate; @@ -29,6 +31,9 @@ import java.util.regex.Pattern; import java.util.stream.Collectors; import java.util.stream.Stream; +import static org.dromara.common.core.constant.Constants.FLY_ACC_TIME; +import static org.dromara.common.core.constant.Constants.FLY_COUNT; + /** * *预警统计Service业务层处理 @@ -141,7 +146,9 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist new StatObj("total", 0), new StatObj("todoCount", 0), new StatObj("finishCount", 0), - new StatObj("cancelCount", 0) + new StatObj("cancelCount", 0), + new StatObj("flyCount", 0), + new StatObj("flyAccTime", 0) ).toList(); } @@ -150,6 +157,34 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist businessAlertBo.setAiLabelEnList(getAiLabel(businessAlertBo.getPostCode()).stream().map(RemoteAiLabelPostVo::getLabelEn).collect(Collectors.toList())); } + //获取飞行总架次、总时长 + Map countMap = RedisUtils.getCacheMap(FLY_COUNT); + + + int flyCount = countMap.values().stream() + .filter(Objects::nonNull) + .mapToInt(value -> { + if (value instanceof Number) { + return ((Number) value).intValue(); + } + return 0; + }) + .sum(); + + + Map accTimeMap = RedisUtils.getCacheMap(FLY_ACC_TIME); + + double flyAccTime = accTimeMap.values().stream() + .filter(Objects::nonNull) + .mapToDouble(value -> { + if (value instanceof Number) { + return ((Number) value).doubleValue(); + } + return 0.0; + }) + .sum(); + + List> mapList = baseMapper.countPanelAlert(businessAlertBo); return mapList.stream() @@ -157,7 +192,9 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist new StatObj("total", map.get("total")), new StatObj("todoCount", map.get("todoCount")), new StatObj("finishCount", map.get("finishCount")), - new StatObj("cancelCount", map.get("cancelCount")) + new StatObj("cancelCount", map.get("cancelCount")), + new StatObj("flyCount", flyCount), + new StatObj("flyAccTime", flyAccTime) )) .collect(Collectors.toList()); } @@ -435,19 +472,19 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist List> top5Map = this.baseMapper.countStreetAlert(businessAlertBo,startTime,endTime,deptIdList); //街道事件高发区前5个 - result.put("streetCount", top5Map); + result.put("incidentTop5", top5Map); //-------------------------------------------------------街道处理效率Top5-------------------------------------------- List> streetRateTop5Map = this.baseMapper.countStreetRateAlert(businessAlertBo,startTime,endTime,deptIdList); //街道处理效率top5 - result.put("handlerRate", streetRateTop5Map); + result.put("incidentHandlerTop5", streetRateTop5Map); //-------------------------------------------------------识别类型事件处理情况-------------------------------------------- //识别类型事件处理情况 List> labelRateMap = this.baseMapper.countLabelRateAlert(businessAlertBo,startTime,endTime); - result.put("labelRate", labelRateMap); + result.put("labelHandlerRate", labelRateMap); return result; @@ -549,7 +586,7 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist List> labelMapList = this.baseMapper.countAiLabel(businessAlertBo,startTime,endTime); - keyMap.put("handlerStat", labelMapList); + keyMap.put("incidentHandlerStat", labelMapList); //-------------------------------------------------------事件高发区-------------------------------------------- @@ -557,13 +594,13 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist //事件高发区top1 Map topStreet = this.baseMapper.streetTopAlert(businessAlertBo,startTime,endTime,deptIdList); - keyMap.put("topAlert",ObjectUtil.isEmpty(topStreet)?null:topStreet.get("deptName")); + keyMap.put("incidentTop1",ObjectUtil.isEmpty(topStreet)?null:topStreet.get("deptName")); //-------------------------------------------------------处理效率-------------------------------------------- //处理效率top1 Map topStreetRate = this.baseMapper.streetRateTopAlert(businessAlertBo,startTime,endTime,deptIdList); - keyMap.put("handlerRate", ObjectUtil.isEmpty(topStreetRate)?null:topStreetRate.get("deptName")); + keyMap.put("handlerRateTop1", ObjectUtil.isEmpty(topStreetRate)?null:topStreetRate.get("deptName")); //-------------------------------------------------------存储结果--------------------------------------------