异常数据功能调整
This commit is contained in:
@@ -16,7 +16,9 @@ public class DetailAbnormalVO {
|
|||||||
|
|
||||||
private String monitorName;
|
private String monitorName;
|
||||||
|
|
||||||
private Long timeSum;
|
private String timeSum;
|
||||||
|
|
||||||
|
private String errCount;
|
||||||
|
|
||||||
private String targetKey;
|
private String targetKey;
|
||||||
|
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ public class DataVerifyServiceImpl extends ServiceImpl<DataVerifyMapper, DataVer
|
|||||||
long count = lineList.stream().map(DataVerify::getTime).distinct().count();
|
long count = lineList.stream().map(DataVerify::getTime).distinct().count();
|
||||||
DetailAbnormalVO detailAbnormalVO = new DetailAbnormalVO();
|
DetailAbnormalVO detailAbnormalVO = new DetailAbnormalVO();
|
||||||
LineDevGetDTO lineDevGetDTO = lineDetailMap.get(lineId);
|
LineDevGetDTO lineDevGetDTO = lineDetailMap.get(lineId);
|
||||||
detailAbnormalVO.setTimeSum(lineDevGetDTO.getTimeInterval() * count);
|
detailAbnormalVO.setTimeSum("");
|
||||||
detailAbnormalVO.setDate(dateStr);
|
detailAbnormalVO.setDate(dateStr);
|
||||||
detailAbnormalVO.setMonitorName(lineDevGetDTO.getPointName());
|
detailAbnormalVO.setMonitorName(lineDevGetDTO.getPointName());
|
||||||
detailAbnormalVO.setMonitorId(lineDevGetDTO.getPointId());
|
detailAbnormalVO.setMonitorId(lineDevGetDTO.getPointId());
|
||||||
@@ -375,7 +375,7 @@ public class DataVerifyServiceImpl extends ServiceImpl<DataVerifyMapper, DataVer
|
|||||||
detailAbnormalVO.setMonitorId(lineId);
|
detailAbnormalVO.setMonitorId(lineId);
|
||||||
detailAbnormalVO.setDate(date.format(DATE_FORMAT));
|
detailAbnormalVO.setDate(date.format(DATE_FORMAT));
|
||||||
detailAbnormalVO.setMonitorName(lineInfoVO.getPointName());
|
detailAbnormalVO.setMonitorName(lineInfoVO.getPointName());
|
||||||
detailAbnormalVO.setTimeSum((long) timeSet.size() * timeInterval);
|
detailAbnormalVO.setTimeSum("");
|
||||||
detailAbnormalVO.setTargetKey(monitorBaseParam.getTargetKey());
|
detailAbnormalVO.setTargetKey(monitorBaseParam.getTargetKey());
|
||||||
result.add(detailAbnormalVO);
|
result.add(detailAbnormalVO);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -177,7 +177,6 @@ public class PqDataVerifyBakServiceImpl extends ServiceImpl<PqDataVerifyBakMappe
|
|||||||
@Override
|
@Override
|
||||||
public List<DetailAbnormalVO> monitorAbnormalTable(MonitorBaseParam monitorBaseParam) {
|
public List<DetailAbnormalVO> monitorAbnormalTable(MonitorBaseParam monitorBaseParam) {
|
||||||
List<DetailAbnormalVO> result = new ArrayList<>();
|
List<DetailAbnormalVO> result = new ArrayList<>();
|
||||||
|
|
||||||
//参数校验
|
//参数校验
|
||||||
Map<String, PqReasonableRangeDto> rangeMap= getStandRange();
|
Map<String, PqReasonableRangeDto> rangeMap= getStandRange();
|
||||||
if(StrUtil.isNotBlank(monitorBaseParam.getTargetKey())) {
|
if(StrUtil.isNotBlank(monitorBaseParam.getTargetKey())) {
|
||||||
@@ -264,30 +263,45 @@ public class PqDataVerifyBakServiceImpl extends ServiceImpl<PqDataVerifyBakMappe
|
|||||||
lambdaQueryWrapper.eq(PqDataVerifyBak::getPf,1);
|
lambdaQueryWrapper.eq(PqDataVerifyBak::getPf,1);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
log.error("未匹配到异常数据指标");
|
log.error("方法{}未匹配到异常数据指标","monitorAbnormalTable");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
List<PqDataVerifyBak> dataVerifyList = this.list(lambdaQueryWrapper);
|
List<PqDataVerifyBak> dataVerifyList = this.list(lambdaQueryWrapper);
|
||||||
|
|
||||||
for (PqDataVerifyBak pqDataVerifyBak : dataVerifyList) {
|
for (PqDataVerifyBak pqDataVerifyBak : dataVerifyList) {
|
||||||
Set<String> set = new HashSet<>();
|
|
||||||
try (InputStream fileStream = fileStorageUtil.getFileStream(pqDataVerifyBak.getPath())) {
|
try (InputStream fileStream = fileStorageUtil.getFileStream(pqDataVerifyBak.getPath())) {
|
||||||
JSONArray jsonArray = new JSONArray(new JSONTokener(fileStream, new JSONConfig()));
|
JSONArray jsonArray = new JSONArray(new JSONTokener(fileStream, new JSONConfig()));
|
||||||
|
String[] errorTimeCount = {"0"};
|
||||||
|
Long [] errAllCount = {0L};
|
||||||
jsonArray.forEach(it -> {
|
jsonArray.forEach(it -> {
|
||||||
JSONObject targetJson = (JSONObject) it;
|
JSONObject targetJson = (JSONObject) it;
|
||||||
if (StrUtil.isNotBlank(monitorBaseParam.getTargetKey())) {
|
if (StrUtil.isNotBlank(monitorBaseParam.getTargetKey())) {
|
||||||
if (targetJson.containsKey(monitorBaseParam.getTargetKey())) {
|
if (targetJson.containsKey(monitorBaseParam.getTargetKey())) {
|
||||||
JSONArray innerJson = targetJson.getJSONArray(monitorBaseParam.getTargetKey());
|
JSONArray innerJson = targetJson.getJSONArray(monitorBaseParam.getTargetKey());
|
||||||
|
PqReasonableRangeDto dto = rangeMap.get(monitorBaseParam.getTargetKey());
|
||||||
|
if(Objects.nonNull(dto.getHarmStart()) && Objects.nonNull(dto.getHarmEnd())){
|
||||||
|
errorTimeCount[0] = targetJson.get("errorTimes").toString();
|
||||||
for(Object oJson : innerJson){
|
for(Object oJson : innerJson){
|
||||||
JSONObject jsonObjectTem = (JSONObject) oJson;
|
JSONObject jsonObjectTem = (JSONObject) oJson;
|
||||||
JSONArray list = jsonObjectTem.getJSONArray("list");
|
JSONArray list = jsonObjectTem.getJSONArray("list");
|
||||||
list.forEach(listItem -> {
|
list.forEach(listItem -> {
|
||||||
JSONObject object = (JSONObject) listItem;
|
JSONObject object = (JSONObject) listItem;
|
||||||
JSONArray timeArr = object.getJSONArray("time");
|
long errCount = Long.parseLong(object.get("errorCounts").toString());
|
||||||
timeArr.forEach(timeJson -> set.add((String) timeJson));
|
errAllCount[0] +=errCount;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}else {
|
||||||
|
for(Object oJson : innerJson){
|
||||||
|
JSONObject jsonObjectTem = (JSONObject) oJson;
|
||||||
|
JSONArray list = jsonObjectTem.getJSONArray("list");
|
||||||
|
list.forEach(listItem -> {
|
||||||
|
JSONObject object = (JSONObject) listItem;
|
||||||
|
long errCount = Long.parseLong(object.get("errorCounts").toString());
|
||||||
|
errAllCount[0] +=errCount;
|
||||||
|
});
|
||||||
|
errorTimeCount[0] = jsonObjectTem.get("errorTimes").toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
rangeMap.forEach((rangeKey, val) -> {
|
rangeMap.forEach((rangeKey, val) -> {
|
||||||
@@ -298,22 +312,35 @@ public class PqDataVerifyBakServiceImpl extends ServiceImpl<PqDataVerifyBakMappe
|
|||||||
JSONArray list = jsonObjectTem.getJSONArray("list");
|
JSONArray list = jsonObjectTem.getJSONArray("list");
|
||||||
list.forEach(listItem -> {
|
list.forEach(listItem -> {
|
||||||
JSONObject object = (JSONObject) listItem;
|
JSONObject object = (JSONObject) listItem;
|
||||||
JSONArray timeArr = object.getJSONArray("time");
|
long errCount = Long.parseLong(object.get("errorCounts").toString());
|
||||||
timeArr.forEach(timeJson -> set.add((String) timeJson));
|
errAllCount[0] +=errCount;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
if (targetJson.containsKey("lineErrorTimes")) {
|
||||||
|
errorTimeCount[0] = targetJson.get("lineErrorTimes").toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
DetailAbnormalVO detailAbnormalVO = new DetailAbnormalVO();
|
DetailAbnormalVO detailAbnormalVO = new DetailAbnormalVO();
|
||||||
LineDevGetDTO lineDevGetDTO = lineDetailMap.get(pqDataVerifyBak.getLineId());
|
LineDevGetDTO lineDevGetDTO = lineDetailMap.get(pqDataVerifyBak.getLineId());
|
||||||
detailAbnormalVO.setTimeSum((long) lineDevGetDTO.getTimeInterval() * set.size());
|
detailAbnormalVO.setTimeSum(errorTimeCount[0]);
|
||||||
detailAbnormalVO.setDate(pqDataVerifyBak.getTimeId().format(DateTimeFormatter.ofPattern(DatePattern.NORM_DATE_PATTERN)));
|
detailAbnormalVO.setDate(pqDataVerifyBak.getTimeId().format(DateTimeFormatter.ofPattern(DatePattern.NORM_DATE_PATTERN)));
|
||||||
detailAbnormalVO.setMonitorName(lineDevGetDTO.getPointName());
|
detailAbnormalVO.setMonitorName(lineDevGetDTO.getPointName());
|
||||||
detailAbnormalVO.setMonitorId(lineDevGetDTO.getPointId());
|
detailAbnormalVO.setMonitorId(lineDevGetDTO.getPointId());
|
||||||
detailAbnormalVO.setTargetKey("");
|
detailAbnormalVO.setTargetKey(monitorBaseParam.getTargetKey());
|
||||||
|
detailAbnormalVO.setErrCount(errAllCount[0].toString());
|
||||||
|
result.add(detailAbnormalVO);
|
||||||
|
} catch (BusinessException b){
|
||||||
|
//文件为空时候的特殊处理
|
||||||
|
DetailAbnormalVO detailAbnormalVO = new DetailAbnormalVO();
|
||||||
|
LineDevGetDTO lineDevGetDTO = lineDetailMap.get(pqDataVerifyBak.getLineId());
|
||||||
|
detailAbnormalVO.setTimeSum("/");
|
||||||
|
detailAbnormalVO.setDate(pqDataVerifyBak.getTimeId().format(DateTimeFormatter.ofPattern(DatePattern.NORM_DATE_PATTERN)));
|
||||||
|
detailAbnormalVO.setMonitorName(lineDevGetDTO.getPointName());
|
||||||
|
detailAbnormalVO.setMonitorId(lineDevGetDTO.getPointId());
|
||||||
|
detailAbnormalVO.setTargetKey(monitorBaseParam.getTargetKey());
|
||||||
result.add(detailAbnormalVO);
|
result.add(detailAbnormalVO);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new BusinessException("数据异常");
|
throw new BusinessException("数据异常");
|
||||||
@@ -322,6 +349,7 @@ public class PqDataVerifyBakServiceImpl extends ServiceImpl<PqDataVerifyBakMappe
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DetailAbnormalVO.DetailAbnormalInnerVO> monitorAbnormalTableDetail(MonitorBaseParam monitorBaseParam) {
|
public List<DetailAbnormalVO.DetailAbnormalInnerVO> monitorAbnormalTableDetail(MonitorBaseParam monitorBaseParam) {
|
||||||
Map<String, PqReasonableRangeDto> dtoMap = getStandRange();
|
Map<String, PqReasonableRangeDto> dtoMap = getStandRange();
|
||||||
@@ -340,6 +368,9 @@ public class PqDataVerifyBakServiceImpl extends ServiceImpl<PqDataVerifyBakMappe
|
|||||||
JSONArray jsonArray = new JSONArray(new JSONTokener(fileStream, new JSONConfig()));
|
JSONArray jsonArray = new JSONArray(new JSONTokener(fileStream, new JSONConfig()));
|
||||||
for (Object it : jsonArray) {
|
for (Object it : jsonArray) {
|
||||||
JSONObject targetJson = (JSONObject) it;
|
JSONObject targetJson = (JSONObject) it;
|
||||||
|
if(targetJson.containsKey("lineErrorTimes")){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (StrUtil.isNotBlank(monitorBaseParam.getTargetKey())) {
|
if (StrUtil.isNotBlank(monitorBaseParam.getTargetKey())) {
|
||||||
if (targetJson.containsKey(monitorBaseParam.getTargetKey())) {
|
if (targetJson.containsKey(monitorBaseParam.getTargetKey())) {
|
||||||
resultDeal(dtoMap, monitorBaseParam.getTargetKey(), targetJson, result);
|
resultDeal(dtoMap, monitorBaseParam.getTargetKey(), targetJson, result);
|
||||||
@@ -389,6 +420,11 @@ public class PqDataVerifyBakServiceImpl extends ServiceImpl<PqDataVerifyBakMappe
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理json对象中list数组
|
||||||
|
*/
|
||||||
|
|
||||||
private void resultDeal(Map<String, PqReasonableRangeDto> dtoMap, String targetKey, JSONObject targetJson, List<DetailAbnormalVO.DetailAbnormalInnerVO> result) {
|
private void resultDeal(Map<String, PqReasonableRangeDto> dtoMap, String targetKey, JSONObject targetJson, List<DetailAbnormalVO.DetailAbnormalInnerVO> result) {
|
||||||
PqReasonableRangeDto pqReasonableRangeDto = dtoMap.get(targetKey);
|
PqReasonableRangeDto pqReasonableRangeDto = dtoMap.get(targetKey);
|
||||||
JSONArray innerJson = targetJson.getJSONArray(targetKey);
|
JSONArray innerJson = targetJson.getJSONArray(targetKey);
|
||||||
@@ -432,7 +468,12 @@ public class PqDataVerifyBakServiceImpl extends ServiceImpl<PqDataVerifyBakMappe
|
|||||||
vo.setTargetName(timeList.get(0).getTargetName());
|
vo.setTargetName(timeList.get(0).getTargetName());
|
||||||
vo.setTargetKey(targetKey);
|
vo.setTargetKey(targetKey);
|
||||||
vo.setPhaseType(phaseKey);
|
vo.setPhaseType(phaseKey);
|
||||||
|
|
||||||
|
if((pqReasonableRangeDto.getInfluxdbTableName()+SEPARATOR+pqReasonableRangeDto.getIndexCode()).equals(targetKey)){
|
||||||
|
vo.setRangeDesc(pqReasonableRangeDto.getMinValue() + unit + " ~ " + pqReasonableRangeDto.getMaxValue()+"*CT1" + unit);
|
||||||
|
}else {
|
||||||
vo.setRangeDesc(pqReasonableRangeDto.getMinValue() + unit + " ~ " + pqReasonableRangeDto.getMaxValue() + unit);
|
vo.setRangeDesc(pqReasonableRangeDto.getMinValue() + unit + " ~ " + pqReasonableRangeDto.getMaxValue() + unit);
|
||||||
|
}
|
||||||
valueList.forEach(ites -> {
|
valueList.forEach(ites -> {
|
||||||
switch (ites.getType()) {
|
switch (ites.getType()) {
|
||||||
case "AVG":
|
case "AVG":
|
||||||
@@ -549,7 +590,6 @@ public class PqDataVerifyBakServiceImpl extends ServiceImpl<PqDataVerifyBakMappe
|
|||||||
ids = dataVerifyList.stream().filter(it -> it.getVlDev() > 0).map(PqDataVerifyBak::getLineId).collect(Collectors.toSet());
|
ids = dataVerifyList.stream().filter(it -> it.getVlDev() > 0).map(PqDataVerifyBak::getLineId).collect(Collectors.toSet());
|
||||||
assembleEntity(ids, dto, result);
|
assembleEntity(ids, dto, result);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Param.rms_i:
|
case Param.rms_i:
|
||||||
ids = dataVerifyList.stream().filter(it -> it.getIRms() > 0).map(PqDataVerifyBak::getLineId).collect(Collectors.toSet());
|
ids = dataVerifyList.stream().filter(it -> it.getIRms() > 0).map(PqDataVerifyBak::getLineId).collect(Collectors.toSet());
|
||||||
assembleEntity(ids, dto, result);
|
assembleEntity(ids, dto, result);
|
||||||
@@ -623,7 +663,8 @@ public class PqDataVerifyBakServiceImpl extends ServiceImpl<PqDataVerifyBakMappe
|
|||||||
*/
|
*/
|
||||||
private void assembleEntity(Set<String> ids, PqReasonableRangeDto dto, List<VerifyTargetVO> result) {
|
private void assembleEntity(Set<String> ids, PqReasonableRangeDto dto, List<VerifyTargetVO> result) {
|
||||||
VerifyTargetVO verifyTargetVO = new VerifyTargetVO();
|
VerifyTargetVO verifyTargetVO = new VerifyTargetVO();
|
||||||
verifyTargetVO.setKey(dto.getInfluxdbTableName() + SEPARATOR + dto.getIndexCode());
|
String temStr = dto.getInfluxdbTableName() + SEPARATOR + dto.getIndexCode();
|
||||||
|
verifyTargetVO.setKey(temStr);
|
||||||
verifyTargetVO.setTargetName(dto.getIndexName().replace("次", ""));
|
verifyTargetVO.setTargetName(dto.getIndexName().replace("次", ""));
|
||||||
verifyTargetVO.setIds(ids);
|
verifyTargetVO.setIds(ids);
|
||||||
verifyTargetVO.setRemark(dto.getRemark());
|
verifyTargetVO.setRemark(dto.getRemark());
|
||||||
@@ -632,7 +673,12 @@ public class PqDataVerifyBakServiceImpl extends ServiceImpl<PqDataVerifyBakMappe
|
|||||||
if (StrUtil.isNotBlank(dto.getUnit())) {
|
if (StrUtil.isNotBlank(dto.getUnit())) {
|
||||||
unit = dto.getUnit();
|
unit = dto.getUnit();
|
||||||
}
|
}
|
||||||
|
if(temStr.equals(Param.rms_i)){
|
||||||
|
verifyTargetVO.setRangeDesc(dto.getMinValue() + unit + " ~ " + dto.getMaxValue()+"*CT1" + unit);
|
||||||
|
}else {
|
||||||
verifyTargetVO.setRangeDesc(dto.getMinValue() + unit + " ~ " + dto.getMaxValue() + unit);
|
verifyTargetVO.setRangeDesc(dto.getMinValue() + unit + " ~ " + dto.getMaxValue() + unit);
|
||||||
|
}
|
||||||
|
|
||||||
result.add(verifyTargetVO);
|
result.add(verifyTargetVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user