From d5dce1c3fc5f64a360e9eb23877353b99b692449 Mon Sep 17 00:00:00 2001 From: nieziyan Date: Tue, 4 Jun 2024 09:52:58 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E6=8E=A2=E6=B5=8B=E5=99=A8?= =?UTF-8?q?=E6=8A=A5=E8=AD=A6=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/GardsSohDataServiceImpl.java | 34 ++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/jeecg-module-web-statistics/src/main/java/org/jeecg/modules/service/impl/GardsSohDataServiceImpl.java b/jeecg-module-web-statistics/src/main/java/org/jeecg/modules/service/impl/GardsSohDataServiceImpl.java index e4e2ee7a..3fcf72b0 100644 --- a/jeecg-module-web-statistics/src/main/java/org/jeecg/modules/service/impl/GardsSohDataServiceImpl.java +++ b/jeecg-module-web-statistics/src/main/java/org/jeecg/modules/service/impl/GardsSohDataServiceImpl.java @@ -1,6 +1,7 @@ package org.jeecg.modules.service.impl; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.collection.ListUtil; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.ArrayUtil; import cn.hutool.core.util.ObjectUtil; @@ -13,6 +14,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.apache.poi.ss.usermodel.Workbook; import org.jeecg.common.api.QueryRequest; import org.jeecg.common.api.vo.Result; +import org.jeecg.common.constant.DateConstant; +import org.jeecg.common.constant.Prompt; import org.jeecg.common.util.DateUtils; import org.jeecg.common.util.ExportUtil; import org.jeecg.common.util.RedisUtil; @@ -96,27 +99,42 @@ public class GardsSohDataServiceImpl extends ServiceImpl findAlertSohPage(QueryRequest queryRequest, Integer[] stationIds, String startTime, String endTime) { + if (StrUtil.isBlank(startTime)) + return Result.error("StartTime" + Prompt.PARAM_REQUIRED); + if (StrUtil.isBlank(endTime)) + return Result.error("EndTime" + Prompt.PARAM_REQUIRED); + startTime += DateConstant.TIME_START; + endTime += DateConstant.TIME_END; + Map params = new HashMap<>(); + params.put("stationIds", ListUtil.toList(stationIds)); + params.put("startTime", startTime); + params.put("endTime", endTime); + Integer pageNo = queryRequest.getPageNo(); + Integer pageSize = queryRequest.getPageSize(); + Page page = new Page<>(pageNo, pageSize); - Page alertDataPage = gardsAlertDataMapper.page(null, null); + Page alertDataPage = gardsAlertDataMapper.page(page, params); List records = alertDataPage.getRecords(); if (CollUtil.isEmpty(records)) return Result.OK(alertDataPage); - // 获取Map(key: code, value: code对应内容) Map codeMap = systemClient.codeMap(); - String flag = "Error code: "; - String regex = flag + "(\\S+)"; + String flag1 = "Error code: "; + String flag2 = "Error code : "; + String regex1 = flag1 + "(\\S+)"; + String regex2 = flag2 + "(\\S+)"; for (GardsAlertDataWeb record : records) { String alertType = record.getAlertType(); if (!StrUtil.equals(alertType, "ALERT_SYSTEM")) continue; String alertText = record.getAlertText(); - if (!StrUtil.contains(alertText, flag)) - continue; - // 获取code并通过code获取对应code内容 + boolean c1 = StrUtil.contains(alertText, flag1); + boolean c2 = StrUtil.contains(alertText, flag2); + if (!c1 && !c2) continue; + String flag = c1 ? flag1 : flag2; + String regex = c1 ? regex1 : regex2; String code = ReUtil.getGroup1(regex, alertText); String replace = flag + codeMap.get(code); String replaced = ReUtil.getGroup0(regex, alertText); - // 将code替换为对应内容 alertText = StrUtil.replace(alertText, replaced, replace); record.setAlertText(alertText); }