feat:探测器报警信息
This commit is contained in:
parent
e83c1d6199
commit
d5dce1c3fc
|
@ -1,6 +1,7 @@
|
||||||
package org.jeecg.modules.service.impl;
|
package org.jeecg.modules.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.collection.ListUtil;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.util.ArrayUtil;
|
import cn.hutool.core.util.ArrayUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
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.apache.poi.ss.usermodel.Workbook;
|
||||||
import org.jeecg.common.api.QueryRequest;
|
import org.jeecg.common.api.QueryRequest;
|
||||||
import org.jeecg.common.api.vo.Result;
|
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.DateUtils;
|
||||||
import org.jeecg.common.util.ExportUtil;
|
import org.jeecg.common.util.ExportUtil;
|
||||||
import org.jeecg.common.util.RedisUtil;
|
import org.jeecg.common.util.RedisUtil;
|
||||||
|
@ -96,27 +99,42 @@ public class GardsSohDataServiceImpl extends ServiceImpl<GardsSohDataMapper, Gar
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result<?> findAlertSohPage(QueryRequest queryRequest, Integer[] stationIds, String startTime, String endTime) {
|
public Result<?> 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<String, Object> 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<GardsAlertDataWeb> page = new Page<>(pageNo, pageSize);
|
||||||
|
|
||||||
Page<GardsAlertDataWeb> alertDataPage = gardsAlertDataMapper.page(null, null);
|
Page<GardsAlertDataWeb> alertDataPage = gardsAlertDataMapper.page(page, params);
|
||||||
List<GardsAlertDataWeb> records = alertDataPage.getRecords();
|
List<GardsAlertDataWeb> records = alertDataPage.getRecords();
|
||||||
if (CollUtil.isEmpty(records))
|
if (CollUtil.isEmpty(records))
|
||||||
return Result.OK(alertDataPage);
|
return Result.OK(alertDataPage);
|
||||||
// 获取Map(key: code, value: code对应内容)
|
|
||||||
Map<String, String> codeMap = systemClient.codeMap();
|
Map<String, String> codeMap = systemClient.codeMap();
|
||||||
String flag = "Error code: ";
|
String flag1 = "Error code: ";
|
||||||
String regex = flag + "(\\S+)";
|
String flag2 = "Error code : ";
|
||||||
|
String regex1 = flag1 + "(\\S+)";
|
||||||
|
String regex2 = flag2 + "(\\S+)";
|
||||||
for (GardsAlertDataWeb record : records) {
|
for (GardsAlertDataWeb record : records) {
|
||||||
String alertType = record.getAlertType();
|
String alertType = record.getAlertType();
|
||||||
if (!StrUtil.equals(alertType, "ALERT_SYSTEM"))
|
if (!StrUtil.equals(alertType, "ALERT_SYSTEM"))
|
||||||
continue;
|
continue;
|
||||||
String alertText = record.getAlertText();
|
String alertText = record.getAlertText();
|
||||||
if (!StrUtil.contains(alertText, flag))
|
boolean c1 = StrUtil.contains(alertText, flag1);
|
||||||
continue;
|
boolean c2 = StrUtil.contains(alertText, flag2);
|
||||||
// 获取code并通过code获取对应code内容
|
if (!c1 && !c2) continue;
|
||||||
|
String flag = c1 ? flag1 : flag2;
|
||||||
|
String regex = c1 ? regex1 : regex2;
|
||||||
String code = ReUtil.getGroup1(regex, alertText);
|
String code = ReUtil.getGroup1(regex, alertText);
|
||||||
String replace = flag + codeMap.get(code);
|
String replace = flag + codeMap.get(code);
|
||||||
String replaced = ReUtil.getGroup0(regex, alertText);
|
String replaced = ReUtil.getGroup0(regex, alertText);
|
||||||
// 将code替换为对应内容
|
|
||||||
alertText = StrUtil.replace(alertText, replaced, replace);
|
alertText = StrUtil.replace(alertText, replaced, replace);
|
||||||
record.setAlertText(alertText);
|
record.setAlertText(alertText);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user