This commit is contained in:
caozehui
2025-04-18 15:59:05 +08:00
parent 7b951fa4b6
commit be3df5c497
8 changed files with 379 additions and 312 deletions

View File

@@ -3,6 +3,7 @@ package com.njcn.gather.report.pojo;
import lombok.Data; import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.util.List;
/** /**
* @author hongawen * @author hongawen
@@ -34,4 +35,5 @@ public class DevReportParam implements Serializable {
*/ */
private String devId; private String devId;
private List<String> devIdList;
} }

View File

@@ -67,5 +67,5 @@ public interface IPqReportService extends IService<PqReport> {
void downloadReport(DevReportParam devReportParam, HttpServletResponse response); void downloadReport(DevReportParam devReportParam, HttpServletResponse response);
Map<String, Object> getMap(DevReportParam devReportParam); //Map<String, Object> getMap(DevReportParam devReportParam);
} }

View File

@@ -9,7 +9,6 @@ import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
@@ -18,6 +17,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.common.pojo.constant.PatternRegex; import com.njcn.common.pojo.constant.PatternRegex;
import com.njcn.common.pojo.enums.common.DataStateEnum; import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.common.pojo.exception.BusinessException; import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.gather.detection.pojo.enums.DetectionCodeEnum;
import com.njcn.gather.detection.pojo.vo.DetectionData; import com.njcn.gather.detection.pojo.vo.DetectionData;
import com.njcn.gather.device.pojo.enums.DevReportStateEnum; import com.njcn.gather.device.pojo.enums.DevReportStateEnum;
import com.njcn.gather.device.pojo.vo.PqDevVO; import com.njcn.gather.device.pojo.vo.PqDevVO;
@@ -72,8 +72,6 @@ import org.docx4j.jaxb.Context;
import org.docx4j.openpackaging.packages.WordprocessingMLPackage; import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
import org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart; import org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart;
import org.docx4j.wml.*; import org.docx4j.wml.*;
import org.docx4j.wml.CTTblLayoutType;
import org.docx4j.wml.STTblLayoutType;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.*; import org.openxmlformats.schemas.wordprocessingml.x2006.main.*;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
@@ -85,7 +83,6 @@ import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.xml.bind.JAXBElement; import javax.xml.bind.JAXBElement;
import java.io.*; import java.io.*;
import java.lang.reflect.Field;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.BigInteger; import java.math.BigInteger;
import java.math.RoundingMode; import java.math.RoundingMode;
@@ -525,6 +522,8 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
* @param devReportParam 被检设备信息 * @param devReportParam 被检设备信息
*/ */
private void generateReportByDevType(AdPlan plan, DevReportParam devReportParam) { private void generateReportByDevType(AdPlan plan, DevReportParam devReportParam) {
devReportParam.getDevIdList().forEach(devId -> {
devReportParam.setDevId(devId);
// 根据设备类型找到报告模板 // 根据设备类型找到报告模板
PqDevVO pqDevVO = iPqDevService.getPqDevById(devReportParam.getDevId()); PqDevVO pqDevVO = iPqDevService.getPqDevById(devReportParam.getDevId());
if (Objects.isNull(pqDevVO)) { if (Objects.isNull(pqDevVO)) {
@@ -569,6 +568,7 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
log.error(ReportResponseEnum.GENERATE_REPORT_ERROR.getMessage(), e); log.error(ReportResponseEnum.GENERATE_REPORT_ERROR.getMessage(), e);
throw new BusinessException(ReportResponseEnum.GENERATE_REPORT_ERROR); throw new BusinessException(ReportResponseEnum.GENERATE_REPORT_ERROR);
} }
});
} }
/** /**
@@ -579,6 +579,8 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
* @param devReportParam 设备信息 * @param devReportParam 设备信息
*/ */
private void generateReportByPlan(AdPlan plan, DevReportParam devReportParam) { private void generateReportByPlan(AdPlan plan, DevReportParam devReportParam) {
devReportParam.getDevIdList().forEach(devId -> {
devReportParam.setDevId(devId);
// 准备被检设备的基础信息 // 准备被检设备的基础信息
PqDevVO pqDevVO = iPqDevService.getPqDevById(devReportParam.getDevId()); PqDevVO pqDevVO = iPqDevService.getPqDevById(devReportParam.getDevId());
if (Objects.isNull(pqDevVO)) { if (Objects.isNull(pqDevVO)) {
@@ -614,6 +616,7 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
log.error(ReportResponseEnum.GENERATE_REPORT_ERROR.getMessage(), e); log.error(ReportResponseEnum.GENERATE_REPORT_ERROR.getMessage(), e);
throw new BusinessException(ReportResponseEnum.GENERATE_REPORT_ERROR); throw new BusinessException(ReportResponseEnum.GENERATE_REPORT_ERROR);
} }
});
} }
/** /**
@@ -956,7 +959,7 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
TcPr tcPr = element.getValue().getTcPr(); TcPr tcPr = element.getValue().getTcPr();
TblWidth cellWidth = factory.createTblWidth(); TblWidth cellWidth = factory.createTblWidth();
cellWidth.setType("dxa"); cellWidth.setType("dxa");
cellWidth.setW(BigInteger.valueOf(5000/tableKeys.size())); cellWidth.setW(BigInteger.valueOf(5000 / tableKeys.size()));
tcPr.setTcW(cellWidth); tcPr.setTcW(cellWidth);
tbl.getContent().remove(existingRow); tbl.getContent().remove(existingRow);
// 迭代增加行,需要填充的表格keys在tableKeys集合中 // 迭代增加行,需要填充的表格keys在tableKeys集合中
@@ -970,7 +973,6 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
// 插入段落,处理下样式 // 插入段落,处理下样式
paragraphs.add(position++, copiedTableElement); paragraphs.add(position++, copiedTableElement);
} }
} }
@@ -1057,7 +1059,7 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
// 获取设备型号 // 获取设备型号
baseModelMap.put(prefix + BaseReportKeyEnum.DEV_TYPE.getKey() + suffix, devType.getName()); baseModelMap.put(prefix + BaseReportKeyEnum.DEV_TYPE.getKey() + suffix, devType.getName());
// 检测员 // 检测员
baseModelMap.put(prefix + BaseReportKeyEnum.INSPECTOR.getKey() + suffix, pqDevVO.getCheckBy()); baseModelMap.put(prefix + BaseReportKeyEnum.INSPECTOR.getKey() + suffix, pqDevVO.getCheckBy() + "");
// 调试日期 // 调试日期
if (pqDevVO.getCheckTime() != null) { if (pqDevVO.getCheckTime() != null) {
baseModelMap.put(prefix + BaseReportKeyEnum.TEST_DATE.getKey() + suffix, DateUtil.format(pqDevVO.getCheckTime(), DatePattern.CHINESE_DATE_PATTERN)); baseModelMap.put(prefix + BaseReportKeyEnum.TEST_DATE.getKey() + suffix, DateUtil.format(pqDevVO.getCheckTime(), DatePattern.CHINESE_DATE_PATTERN));
@@ -1115,147 +1117,39 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
singleNonHarmParam.setChannelNo(i); singleNonHarmParam.setChannelNo(i);
// 获取数据 // 获取数据
Map<String, String> dataModelMap = new HashMap<>(16); Map<String, String> dataModelMap = new HashMap<>();
dataModelMap.put("${CreateId}", pqDevVO.getCreateId()); dataModelMap.put("${CreateId}", pqDevVO.getCreateId());
dataModelMap.put("${total}", pqDevVO.getDevChns().toString()); dataModelMap.put("${total}", pqDevVO.getDevChns().toString());
dataModelMap.put("${count}", i + ""); dataModelMap.put("${count}", i + "");
// 区分谐波和非谐波数据
// 读取模板文件中的占位符
List<String> allMarkList = getAllKeys(dataModelDocumentTemp);
Map<String, Set<String>> indexKeysMap = allMarkList.stream()
.collect(Collectors.groupingBy(
obj -> obj.split("#")[0].replace("${", ""),
Collectors.mapping(obj -> {
int index1 = obj.indexOf("#") + 1;
return obj.substring(index1, obj.indexOf("#", index1));
}, Collectors.toSet()))); //key为indexvalue为该index下所有测试项对应的code
List<AdNonHarmonicResult> adNonHarmonicResultList = adNonHarmonicService.listAll(devReportParam.getScriptId(), devReportParam.getPlanCode(), devReportParam.getDevId() + "_" + i);
List<AdHarmonicResult> adHarmonicResultList = adHarmonicService.listAll(devReportParam.getScriptId(), devReportParam.getPlanCode(), devReportParam.getDevId() + "_" + i);
// 填充数据
indexKeysMap.forEach((index, keys) -> {
String s1 = keys.stream().findFirst().get();
// 谐波类 // 谐波类
if (DetectionCodeEnum.V2_50.getCode().equals(s1) || DetectionCodeEnum.I2_50.getCode().equals(s1) || DetectionCodeEnum.SV_1_49.getCode().equals(s1) || DetectionCodeEnum.SI_1_49.getCode().equals(s1)) {
fillMapValueHarm(adHarmonicResultList, dataModelMap, keys, index);
} else {
// 非谐波类 // 非谐波类
// 57V电压 电压&相角 index 不用计算了固定为1 if (DetectionCodeEnum.V_UNBAN.getCode().equals(s1) || DetectionCodeEnum.FREQ.getCode().equals(s1)) {
// Integer testItemIndex = getTestItemIndex(scriptId, "e797c4b940389404e64fb92e4507c5f4", "Base", "VOL", 57); fillMapValueT(adNonHarmonicResultList, dataModelMap, keys, index);
// 获取输出脚本ID } else {
Integer testItemIndex = 1; fillMapValueABC(adNonHarmonicResultList, dataModelMap, keys, index);
// String pqScriptCheckDataService = getPqScriptCheckDataByScriptId(scriptId,testItemIndex,1,Arrays.asList("A","B","C")); }
String pqScriptCheckDataService = "8e221487f242c77f1eff05234580d4c5"; }
// 获取数据 });
singleNonHarmParam.setAdType(pqScriptCheckDataService);
singleNonHarmParam.setSort(testItemIndex);
fillMapValue(singleNonHarmParam, dataModelMap, "57Ua", "57Ub", "57Uc");
// 57V相角
testItemIndex = 1;
pqScriptCheckDataService = "e8bbfaad7a3fa343d3c46d345fb45fa3";
// 获取数据
singleNonHarmParam.setAdType(pqScriptCheckDataService);
singleNonHarmParam.setSort(testItemIndex);
fillMapValue(singleNonHarmParam, dataModelMap, "57UaA", "57UbA", "57UcA");
// 10V电压
testItemIndex = 2;
pqScriptCheckDataService = "8e221487f242c77f1eff05234580d4c5";
// 获取数据
singleNonHarmParam.setAdType(pqScriptCheckDataService);
singleNonHarmParam.setSort(testItemIndex);
fillMapValue(singleNonHarmParam, dataModelMap, "10Ua", "10Ub", "10Uc");
// 电压偏差
testItemIndex = 3;
pqScriptCheckDataService = "8e221487f242c77f1eff05234580d4c5";
// 获取数据
singleNonHarmParam.setAdType(pqScriptCheckDataService);
singleNonHarmParam.setSort(testItemIndex);
fillMapValue(singleNonHarmParam, dataModelMap, "DELTA_Ua", "DELTA_Ub", "DELTA_Uc");
// 特殊处理电压偏差
specialDealVoltage(dataModelMap, "${DELTA_Ua}");
specialDealVoltage(dataModelMap, "${DELTA_Ub}");
specialDealVoltage(dataModelMap, "${DELTA_Uc}");
// 5A 电流
testItemIndex = 4;
pqScriptCheckDataService = "7fbadbeb9dd5ccb69d216f4f9ad60b4f";
// 获取数据
singleNonHarmParam.setAdType(pqScriptCheckDataService);
singleNonHarmParam.setSort(testItemIndex);
fillMapValue(singleNonHarmParam, dataModelMap, "5Ia", "5Ib", "5Ic");
// 5A 电流相角
testItemIndex = 4;
pqScriptCheckDataService = "fdffc6b5dfdc8751b9fde9b599b8ea51";
// 获取数据
singleNonHarmParam.setAdType(pqScriptCheckDataService);
singleNonHarmParam.setSort(testItemIndex);
fillMapValue(singleNonHarmParam, dataModelMap, "5IaA", "5IbA", "5IcA");
// 1A 电流
testItemIndex = 5;
pqScriptCheckDataService = "7fbadbeb9dd5ccb69d216f4f9ad60b4f";
// 获取数据
singleNonHarmParam.setAdType(pqScriptCheckDataService);
singleNonHarmParam.setSort(testItemIndex);
fillMapValue(singleNonHarmParam, dataModelMap, "1Ia", "1Ib", "1Ic");
// 三相电压不平衡度
testItemIndex = 6;
pqScriptCheckDataService = "9e9910f3627870c7fcf5846342f29d26";
// 获取数据
singleNonHarmParam.setAdType(pqScriptCheckDataService);
singleNonHarmParam.setSort(testItemIndex);
fillMapValueT(singleNonHarmParam, dataModelMap, "V_UNBAN");
// 频率 45
testItemIndex = 7;
pqScriptCheckDataService = "2da2a32c0cd19fb6368b9f4c249c2b3c";
// 获取数据
singleNonHarmParam.setAdType(pqScriptCheckDataService);
singleNonHarmParam.setSort(testItemIndex);
fillMapValueT(singleNonHarmParam, dataModelMap, "FREQ45");
// 频率 50
testItemIndex = 8;
pqScriptCheckDataService = "2da2a32c0cd19fb6368b9f4c249c2b3c";
// 获取数据
singleNonHarmParam.setAdType(pqScriptCheckDataService);
singleNonHarmParam.setSort(testItemIndex);
fillMapValueT(singleNonHarmParam, dataModelMap, "FREQ50");
// 频率 55
testItemIndex = 9;
pqScriptCheckDataService = "2da2a32c0cd19fb6368b9f4c249c2b3c";
// 获取数据
singleNonHarmParam.setAdType(pqScriptCheckDataService);
singleNonHarmParam.setSort(testItemIndex);
fillMapValueT(singleNonHarmParam, dataModelMap, "FREQ55");
// 谐波电压
testItemIndex = 10;
pqScriptCheckDataService = "cce92410f1902897a61f644d875f2216";
// 获取数据
singleNonHarmParam.setAdType(pqScriptCheckDataService);
singleNonHarmParam.setSort(testItemIndex);
fillMapValueHarm(singleNonHarmParam, dataModelMap, "Uha", "Uhb", "Uhc", 57.74, 100);
// 谐波电电流
testItemIndex = 11;
pqScriptCheckDataService = "3e5e384d38485ca4242152fba336de1d";
// 获取数据
singleNonHarmParam.setAdType(pqScriptCheckDataService);
singleNonHarmParam.setSort(testItemIndex);
fillMapValueHarm(singleNonHarmParam, dataModelMap, "Iha", "Ihb", "Ihc", 1, 1);
// 间谐波电压
testItemIndex = 12;
pqScriptCheckDataService = "d57ea0e085ecf6c4e9f4da09b948befe";
// 获取数据
singleNonHarmParam.setAdType(pqScriptCheckDataService);
singleNonHarmParam.setSort(testItemIndex);
fillMapValueHarm(singleNonHarmParam, dataModelMap, "InUa", "InUb", "InUc", 57.74, 100);
// 间谐波电流
testItemIndex = 13;
pqScriptCheckDataService = "6bc58769dcbb2f83a13ff965a20a3cf3";
// 获取数据
singleNonHarmParam.setAdType(pqScriptCheckDataService);
singleNonHarmParam.setSort(testItemIndex);
fillMapValueHarm(singleNonHarmParam, dataModelMap, "InIa", "InIb", "InIc", 1, 1);
// 替换文档内容 // 替换文档内容
WordUtil.replacePlaceholdersInParagraphs(dataModelDocumentTemp, dataModelMap); WordUtil.replacePlaceholdersInParagraphs(dataModelDocumentTemp, dataModelMap);
@@ -1264,6 +1158,171 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
} }
} }
/**
* 填充数据(ABC相)
*
* @param allNonHarmonicResultList
* @param dataModelMap
* @param keys
* @param index
*/
private void fillMapValueABC(List<AdNonHarmonicResult> allNonHarmonicResultList, Map<String, String> dataModelMap, Set<String> keys, String index) {
keys.forEach(key -> {
List<AdNonHarmonicResult> resultList = allNonHarmonicResultList.stream().filter(obj -> obj.getAdType().equals(key) && obj.getSort().toString().equals(index)).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(resultList)) {
AdNonHarmonicResult adNonHarmonicResult = resultList.get(0);
if (ObjectUtil.isNotNull(adNonHarmonicResult)) {
dataModelMap.put("${" + index + "#" + key + "#A}", devValue(adNonHarmonicResult.getAValue(), 1, 1));
dataModelMap.put("${" + index + "#" + key + "#B}", devValue(adNonHarmonicResult.getBValue(), 1, 1));
dataModelMap.put("${" + index + "#" + key + "#C}", devValue(adNonHarmonicResult.getCValue(), 1, 1));
}
}
});
}
/**
* 填充数据(T相)
*
* @param allNonHarmonicResultList
* @param dataModelMap
* @param keys
* @param index
*/
private void fillMapValueT(List<AdNonHarmonicResult> allNonHarmonicResultList, Map<String, String> dataModelMap, Set<String> keys, String index) {
keys.forEach(key -> {
List<AdNonHarmonicResult> resultList = allNonHarmonicResultList.stream().filter(obj -> obj.getAdType().equals(key) && obj.getSort().toString().equals(index)).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(resultList)) {
AdNonHarmonicResult adNonHarmonicResult = resultList.get(0);
if (ObjectUtil.isNotNull(adNonHarmonicResult)) {
dataModelMap.put("${" + index + "#" + key + "#T}", devValue(adNonHarmonicResult.getTValue(), 1, 1));
}
}
});
}
/**
* 填充数据(谐波类)
*
* @param allHarmonicResultList
* @param dataModelMap
* @param keys
* @param index
*/
private void fillMapValueHarm(List<AdHarmonicResult> allHarmonicResultList, Map<String, String> dataModelMap, Set<String> keys, String index) {
keys.forEach(key -> {
List<AdHarmonicResult> resultList = allHarmonicResultList.stream().filter(obj -> obj.getAdType().equals(key) && obj.getSort().toString().equals(index)).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(resultList)) {
AdHarmonicResult adHarmonicResult = resultList.get(0);
if (Objects.nonNull(adHarmonicResult)) {
if (DetectionCodeEnum.V2_50.getCode().equals(key) || DetectionCodeEnum.SV_1_49.getCode().equals(key)) {
fillHarm(dataModelMap, adHarmonicResult, index, key, 57.74, 100);
}
if (DetectionCodeEnum.I2_50.getCode().equals(key) || DetectionCodeEnum.SI_1_49.getCode().equals(key)) {
fillHarm(dataModelMap, adHarmonicResult, index, key, 1, 1);
}
}
}
});
}
/**
* 对谐波类数据进行处理并填充到map中
*
* @param dataModelMap
* @param adHarmonicResult
* @param index
* @param key
* @param baseValue
* @param percent
*/
private void fillHarm(Map<String, String> dataModelMap, AdHarmonicResult adHarmonicResult, String index, String key, double baseValue, int percent) {
// 要处理 2 5 7 11 23 35 43 50
// 基波
String aBase = devValue(adHarmonicResult.getAValue1(), 1, 1);
String bBase = devValue(adHarmonicResult.getBValue1(), 1, 1);
String cBase = devValue(adHarmonicResult.getCValue1(), 1, 1);
dataModelMap.put("${" + index + "#" + key + "#A#1}", aBase);
dataModelMap.put("${" + index + "#" + key + "#B#1}", bBase);
dataModelMap.put("${" + index + "#" + key + "#C#1}", cBase);
double aBaseValue = baseValue;
double bBaseValue = baseValue;
double cBaseValue = baseValue;
if (!aBase.equals(StrPool.SLASH)) {
aBaseValue = Double.parseDouble(aBase);
}
if (!bBase.equals(StrPool.SLASH)) {
bBaseValue = Double.parseDouble(bBase);
}
if (!cBase.equals(StrPool.SLASH)) {
cBaseValue = Double.parseDouble(cBase);
}
dataModelMap.put("${" + index + "#" + key + "#A#2}", devValue(adHarmonicResult.getAValue2(), aBaseValue, percent));
dataModelMap.put("${" + index + "#" + key + "#B#2}", devValue(adHarmonicResult.getBValue2(), bBaseValue, percent));
dataModelMap.put("${" + index + "#" + key + "#C#2}", devValue(adHarmonicResult.getCValue2(), cBaseValue, percent));
dataModelMap.put("${" + index + "#" + key + "#A#5}", devValue(adHarmonicResult.getAValue5(), aBaseValue, percent));
dataModelMap.put("${" + index + "#" + key + "#B#5}", devValue(adHarmonicResult.getBValue5(), bBaseValue, percent));
dataModelMap.put("${" + index + "#" + key + "#C#5}", devValue(adHarmonicResult.getCValue5(), cBaseValue, percent));
dataModelMap.put("${" + index + "#" + key + "#A#7}", devValue(adHarmonicResult.getAValue7(), aBaseValue, percent));
dataModelMap.put("${" + index + "#" + key + "#B#7}", devValue(adHarmonicResult.getBValue7(), bBaseValue, percent));
dataModelMap.put("${" + index + "#" + key + "#C#7}", devValue(adHarmonicResult.getCValue7(), cBaseValue, percent));
dataModelMap.put("${" + index + "#" + key + "#A#11}", devValue(adHarmonicResult.getAValue11(), aBaseValue, percent));
dataModelMap.put("${" + index + "#" + key + "#B#11}", devValue(adHarmonicResult.getBValue11(), bBaseValue, percent));
dataModelMap.put("${" + index + "#" + key + "#C#11}", devValue(adHarmonicResult.getCValue11(), cBaseValue, percent));
dataModelMap.put("${" + index + "#" + key + "#A#23}", devValue(adHarmonicResult.getAValue23(), aBaseValue, percent));
dataModelMap.put("${" + index + "#" + key + "#B#23}", devValue(adHarmonicResult.getBValue23(), bBaseValue, percent));
dataModelMap.put("${" + index + "#" + key + "#C#23}", devValue(adHarmonicResult.getCValue23(), cBaseValue, percent));
dataModelMap.put("${" + index + "#" + key + "#A#35}", devValue(adHarmonicResult.getAValue35(), aBaseValue, percent));
dataModelMap.put("${" + index + "#" + key + "#B#35}", devValue(adHarmonicResult.getBValue35(), bBaseValue, percent));
dataModelMap.put("${" + index + "#" + key + "#C#35}", devValue(adHarmonicResult.getCValue35(), cBaseValue, percent));
dataModelMap.put("${" + index + "#" + key + "#A#43}", devValue(adHarmonicResult.getAValue43(), aBaseValue, percent));
dataModelMap.put("${" + index + "#" + key + "#B#43}", devValue(adHarmonicResult.getBValue43(), bBaseValue, percent));
dataModelMap.put("${" + index + "#" + key + "#C#43}", devValue(adHarmonicResult.getCValue43(), cBaseValue, percent));
dataModelMap.put("${" + index + "#" + key + "#A#50}", devValue(adHarmonicResult.getAValue50(), aBaseValue, percent));
dataModelMap.put("${" + index + "#" + key + "#B#50}", devValue(adHarmonicResult.getBValue50(), bBaseValue, percent));
dataModelMap.put("${" + index + "#" + key + "#C#50}", devValue(adHarmonicResult.getCValue50(), cBaseValue, percent));
}
/**
* 获取文件所有表格中的占位符
*
* @param dataModelDocumentTemp
* @return
*/
private List<String> getAllKeys(XWPFDocument dataModelDocumentTemp) {
List<String> allMarkList = new ArrayList<>();
List<XWPFTable> tables = dataModelDocumentTemp.getTables();
for (XWPFTable table : tables) {
List<XWPFTableRow> rows = table.getRows();
for (XWPFTableRow row : rows) {
List<XWPFTableCell> cells = row.getTableCells();
for (XWPFTableCell cell : cells) {
List<XWPFParagraph> paragraphs = cell.getParagraphs();
for (XWPFParagraph paragraph : paragraphs) {
List<XWPFRun> runs = paragraph.getRuns();
for (XWPFRun run : runs) {
String text = run.getText(0);
if (StrUtil.isNotBlank(text) && text.startsWith("$")) {
allMarkList.add(text);
}
}
}
}
}
}
return allMarkList.stream().sorted(Comparator.comparing(String::toString)).collect(Collectors.toList());
}
private void dealDataModelZJ(XWPFDocument baseModelDocument, DevReportParam devReportParam, PqDevVO pqDevVO) { private void dealDataModelZJ(XWPFDocument baseModelDocument, DevReportParam devReportParam, PqDevVO pqDevVO) {
List<AdBaseResult> nonHarmonicResultList = adNonHarmonicService.get(devReportParam.getScriptId(), null, devReportParam.getDevId(), "-1", devReportParam.getPlanCode()); List<AdBaseResult> nonHarmonicResultList = adNonHarmonicService.get(devReportParam.getScriptId(), null, devReportParam.getDevId(), "-1", devReportParam.getPlanCode());
List<AdBaseResult> harmonicResultList = adHarmonicService.get(devReportParam.getScriptId(), null, devReportParam.getDevId(), "-1", devReportParam.getPlanCode()); List<AdBaseResult> harmonicResultList = adHarmonicService.get(devReportParam.getScriptId(), null, devReportParam.getDevId(), "-1", devReportParam.getPlanCode());
@@ -2026,93 +2085,93 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
} }
@Override // @Override
public Map<String, Object> getMap(DevReportParam devReportParam) { // public Map<String, Object> getMap(DevReportParam devReportParam) {
HashMap<String, Object> resultMap = new HashMap<>(); // HashMap<String, Object> resultMap = new HashMap<>();
List<AdNonHarmonicResult> adNonHarmonicResultList = adNonHarmonicService.listAll(devReportParam.getScriptId(), "result_" + devReportParam.getPlanCode(), devReportParam.getDevId()); // List<AdNonHarmonicResult> adNonHarmonicResultList = adNonHarmonicService.listAll(devReportParam.getScriptId(), "result_" + devReportParam.getPlanCode(), devReportParam.getDevId());
List<AdHarmonicResult> adHarmonicResultList = adHarmonicService.listAll(devReportParam.getScriptId(), "result_" + devReportParam.getPlanCode(), devReportParam.getDevId()); // List<AdHarmonicResult> adHarmonicResultList = adHarmonicService.listAll(devReportParam.getScriptId(), "result_" + devReportParam.getPlanCode(), devReportParam.getDevId());
//
Map<String, List<AdNonHarmonicResult>> monitorIdMap1 = adNonHarmonicResultList.stream() // Map<String, List<AdNonHarmonicResult>> monitorIdMap1 = adNonHarmonicResultList.stream()
.sorted(Comparator.comparing(AdNonHarmonicResult::getMonitorId)) // .sorted(Comparator.comparing(AdNonHarmonicResult::getMonitorId))
.collect(Collectors.groupingBy(AdNonHarmonicResult::getMonitorId, LinkedHashMap::new, Collectors.toList())); // .collect(Collectors.groupingBy(AdNonHarmonicResult::getMonitorId, LinkedHashMap::new, Collectors.toList()));
Map<String, List<AdHarmonicResult>> monitorIdMap2 = adHarmonicResultList.stream() // Map<String, List<AdHarmonicResult>> monitorIdMap2 = adHarmonicResultList.stream()
.sorted(Comparator.comparing(AdHarmonicResult::getMonitorId)) // .sorted(Comparator.comparing(AdHarmonicResult::getMonitorId))
.collect(Collectors.groupingBy(AdHarmonicResult::getMonitorId, LinkedHashMap::new, Collectors.toList())); // .collect(Collectors.groupingBy(AdHarmonicResult::getMonitorId, LinkedHashMap::new, Collectors.toList()));
//
String[] monitorIds = monitorIdMap1.keySet().stream().map(String::valueOf).toArray(String[]::new); // String[] monitorIds = monitorIdMap1.keySet().stream().map(String::valueOf).toArray(String[]::new);
//
monitorIdMap1.get(monitorIds[0]).stream().forEach(adNonHarmonicResult -> { // monitorIdMap1.get(monitorIds[0]).stream().forEach(adNonHarmonicResult -> {
DictTree dictTree = dictTreeService.getById(adNonHarmonicResult.getAdType()); // DictTree dictTree = dictTreeService.getById(adNonHarmonicResult.getAdType());
//
DetectionData detectionDataA = JSON.parseObject(adNonHarmonicResult.getAValue(), DetectionData.class); // DetectionData detectionDataA = JSON.parseObject(adNonHarmonicResult.getAValue(), DetectionData.class);
DetectionData detectionDataB = JSON.parseObject(adNonHarmonicResult.getBValue(), DetectionData.class); // DetectionData detectionDataB = JSON.parseObject(adNonHarmonicResult.getBValue(), DetectionData.class);
DetectionData detectionDataC = JSON.parseObject(adNonHarmonicResult.getCValue(), DetectionData.class); // DetectionData detectionDataC = JSON.parseObject(adNonHarmonicResult.getCValue(), DetectionData.class);
//
DetectionData detectionDataT = JSON.parseObject(adNonHarmonicResult.getTValue(), DetectionData.class); // DetectionData detectionDataT = JSON.parseObject(adNonHarmonicResult.getTValue(), DetectionData.class);
// 标准值 // // 标准值
Double standardValue = null; // Double standardValue = null;
if (ObjectUtil.isNotNull(detectionDataT)) { // if (ObjectUtil.isNotNull(detectionDataT)) {
standardValue = detectionDataT.getResultData(); // standardValue = detectionDataT.getResultData();
//
resultMap.putIfAbsent(dictTree.getCode() + "_" + standardValue + "_T_Standard", detectionDataT.getResultData()); // resultMap.putIfAbsent(dictTree.getCode() + "_" + standardValue + "_T_Standard", detectionDataT.getResultData());
resultMap.putIfAbsent(dictTree.getCode() + "_" + standardValue + "_T_Test", detectionDataT.getData()); // resultMap.putIfAbsent(dictTree.getCode() + "_" + standardValue + "_T_Test", detectionDataT.getData());
} else { // } else {
standardValue = detectionDataA.getResultData(); // standardValue = detectionDataA.getResultData();
//
resultMap.putIfAbsent(dictTree.getCode() + "_" + standardValue + "_A_Standard", detectionDataA.getResultData()); // resultMap.putIfAbsent(dictTree.getCode() + "_" + standardValue + "_A_Standard", detectionDataA.getResultData());
resultMap.putIfAbsent(dictTree.getCode() + "_" + standardValue + "_A_Test", detectionDataA.getData()); // resultMap.putIfAbsent(dictTree.getCode() + "_" + standardValue + "_A_Test", detectionDataA.getData());
//
resultMap.putIfAbsent(dictTree.getCode() + "_" + standardValue + "_B_Standard", detectionDataB.getResultData()); // resultMap.putIfAbsent(dictTree.getCode() + "_" + standardValue + "_B_Standard", detectionDataB.getResultData());
resultMap.putIfAbsent(dictTree.getCode() + "_" + standardValue + "_B_Test", detectionDataB.getData()); // resultMap.putIfAbsent(dictTree.getCode() + "_" + standardValue + "_B_Test", detectionDataB.getData());
//
resultMap.putIfAbsent(dictTree.getCode() + "_" + standardValue + "_C_Standard", detectionDataC.getResultData()); // resultMap.putIfAbsent(dictTree.getCode() + "_" + standardValue + "_C_Standard", detectionDataC.getResultData());
resultMap.putIfAbsent(dictTree.getCode() + "_" + standardValue + "_C_Test", detectionDataC.getData()); // resultMap.putIfAbsent(dictTree.getCode() + "_" + standardValue + "_C_Test", detectionDataC.getData());
} // }
resultMap.putIfAbsent(dictTree.getCode() + "_" + standardValue + "_Result", getResultStr(adNonHarmonicResult.getResultFlag())); // resultMap.putIfAbsent(dictTree.getCode() + "_" + standardValue + "_Result", getResultStr(adNonHarmonicResult.getResultFlag()));
}); // });
//
monitorIdMap2.get(monitorIds[0]).stream().forEach(adHarmonicResult -> { // monitorIdMap2.get(monitorIds[0]).stream().forEach(adHarmonicResult -> {
DictTree dictTree = dictTreeService.getById(adHarmonicResult.getAdType()); // DictTree dictTree = dictTreeService.getById(adHarmonicResult.getAdType());
//
for (int i = 2; i <= 50; i++) { // for (int i = 2; i <= 50; i++) {
try { // try {
Field fieldA = adHarmonicResult.getClass().getDeclaredField("aValue" + i); // Field fieldA = adHarmonicResult.getClass().getDeclaredField("aValue" + i);
fieldA.setAccessible(true); // fieldA.setAccessible(true);
Object a = fieldA.get(adHarmonicResult); // Object a = fieldA.get(adHarmonicResult);
//
Field fieldB = adHarmonicResult.getClass().getDeclaredField("bValue" + i); // Field fieldB = adHarmonicResult.getClass().getDeclaredField("bValue" + i);
fieldB.setAccessible(true); // fieldB.setAccessible(true);
Object b = fieldB.get(adHarmonicResult); // Object b = fieldB.get(adHarmonicResult);
//
Field fieldC = adHarmonicResult.getClass().getDeclaredField("cValue" + i); // Field fieldC = adHarmonicResult.getClass().getDeclaredField("cValue" + i);
fieldC.setAccessible(true); // fieldC.setAccessible(true);
Object c = fieldC.get(adHarmonicResult); // Object c = fieldC.get(adHarmonicResult);
//
List<Integer> isDataList = new ArrayList<>(); // List<Integer> isDataList = new ArrayList<>();
if (ObjectUtil.isNotNull(a) && ObjectUtil.isNotNull(b) && ObjectUtil.isNotNull(c)) { // if (ObjectUtil.isNotNull(a) && ObjectUtil.isNotNull(b) && ObjectUtil.isNotNull(c)) {
DetectionData detectionData = JSON.parseObject(a.toString(), DetectionData.class); // DetectionData detectionData = JSON.parseObject(a.toString(), DetectionData.class);
resultMap.putIfAbsent(dictTree.getCode() + "_" + detectionData.getResultData() + "_" + i + "_A_Standard", detectionData.getResultData()); // resultMap.putIfAbsent(dictTree.getCode() + "_" + detectionData.getResultData() + "_" + i + "_A_Standard", detectionData.getResultData());
resultMap.putIfAbsent(dictTree.getCode() + "_" + detectionData.getResultData() + "_" + i + "_A_Test", detectionData.getData()); // resultMap.putIfAbsent(dictTree.getCode() + "_" + detectionData.getResultData() + "_" + i + "_A_Test", detectionData.getData());
isDataList.add(detectionData.getIsData()); // isDataList.add(detectionData.getIsData());
//
detectionData = JSON.parseObject(b.toString(), DetectionData.class); // detectionData = JSON.parseObject(b.toString(), DetectionData.class);
resultMap.putIfAbsent(dictTree.getCode() + "_" + detectionData.getResultData() + "_" + i + "_B_Standard", detectionData.getResultData()); // resultMap.putIfAbsent(dictTree.getCode() + "_" + detectionData.getResultData() + "_" + i + "_B_Standard", detectionData.getResultData());
resultMap.putIfAbsent(dictTree.getCode() + "_" + detectionData.getResultData() + "_" + i + "_B_Test", detectionData.getData()); // resultMap.putIfAbsent(dictTree.getCode() + "_" + detectionData.getResultData() + "_" + i + "_B_Test", detectionData.getData());
isDataList.add(detectionData.getIsData()); // isDataList.add(detectionData.getIsData());
//
detectionData = JSON.parseObject(c.toString(), DetectionData.class); // detectionData = JSON.parseObject(c.toString(), DetectionData.class);
resultMap.putIfAbsent(dictTree.getCode() + "_" + detectionData.getResultData() + "_" + i + "_C_Standard", detectionData.getResultData()); // resultMap.putIfAbsent(dictTree.getCode() + "_" + detectionData.getResultData() + "_" + i + "_C_Standard", detectionData.getResultData());
resultMap.putIfAbsent(dictTree.getCode() + "_" + detectionData.getResultData() + "_" + i + "_C_Test", detectionData.getData()); // resultMap.putIfAbsent(dictTree.getCode() + "_" + detectionData.getResultData() + "_" + i + "_C_Test", detectionData.getData());
isDataList.add(detectionData.getIsData()); // isDataList.add(detectionData.getIsData());
} // }
//
resultMap.putIfAbsent(dictTree.getCode() + "_" + i + "_Result", getResultStr(isDataList.stream().allMatch(data -> data == 1) ? 1 : (isDataList.stream().anyMatch(data -> data == 2) ? 2 : 4))); // resultMap.putIfAbsent(dictTree.getCode() + "_" + i + "_Result", getResultStr(isDataList.stream().allMatch(data -> data == 1) ? 1 : (isDataList.stream().anyMatch(data -> data == 2) ? 2 : 4)));
} catch (Exception e) { // } catch (Exception e) {
throw new RuntimeException(e); // throw new RuntimeException(e);
} // }
} // }
}); // });
//
return resultMap; // return resultMap;
} // }
} }

View File

@@ -248,10 +248,13 @@ public class AdHarmonicServiceImpl extends ServiceImpl<AdHarmonicMappper, AdHarm
@Override @Override
public List<AdHarmonicResult> listAll(String scriptId, String code, String devId) { public List<AdHarmonicResult> listAll(String scriptId, String code, String devId) {
String prefix = "ad_harmonic_" + code; String prefix = "ad_harmonic_result_" + code;
DynamicTableNameHandler.setTableName(prefix); DynamicTableNameHandler.setTableName(prefix);
MPJLambdaWrapper<AdHarmonicResult> wrapper = new MPJLambdaWrapper<>(); MPJLambdaWrapper<AdHarmonicResult> wrapper = new MPJLambdaWrapper<>();
wrapper.eq(AdHarmonicResult::getScriptId, scriptId).likeRight(AdHarmonicResult::getMonitorId, devId); wrapper.selectAll(AdHarmonicResult.class)
.selectAs(DictTree::getCode, AdHarmonicResult::getAdType)
.leftJoin(DictTree.class, DictTree::getId, AdHarmonicResult::getAdType).eq(AdHarmonicResult::getScriptId, scriptId)
.likeRight(AdHarmonicResult::getMonitorId, devId);
List<AdHarmonicResult> results = this.getBaseMapper().selectJoinList(AdHarmonicResult.class, wrapper); List<AdHarmonicResult> results = this.getBaseMapper().selectJoinList(AdHarmonicResult.class, wrapper);
DynamicTableNameHandler.remove(); DynamicTableNameHandler.remove();
return results; return results;

View File

@@ -155,10 +155,13 @@ public class AdNonHarmonicServiceImpl extends ServiceImpl<AdNonHarmonicMapper, A
@Override @Override
public List<AdNonHarmonicResult> listAll(String scriptId, String code, String devId) { public List<AdNonHarmonicResult> listAll(String scriptId, String code, String devId) {
String prefix = "ad_non_harmonic_" + code; String prefix = "ad_non_harmonic_result_" + code;
DynamicTableNameHandler.setTableName(prefix); DynamicTableNameHandler.setTableName(prefix);
MPJLambdaWrapper<AdNonHarmonicResult> wrapper = new MPJLambdaWrapper<>(); MPJLambdaWrapper<AdNonHarmonicResult> wrapper = new MPJLambdaWrapper<>();
wrapper.eq(AdNonHarmonicResult::getScriptId, scriptId) wrapper.selectAll(AdNonHarmonicResult.class)
.selectAs(DictTree::getCode, AdNonHarmonicResult::getAdType)
.leftJoin(DictTree.class, DictTree::getId, AdNonHarmonicResult::getAdType)
.eq(AdNonHarmonicResult::getScriptId, scriptId)
.likeRight(AdNonHarmonicResult::getMonitorId, devId); .likeRight(AdNonHarmonicResult::getMonitorId, devId);
List<AdNonHarmonicResult> results = this.getBaseMapper().selectJoinList(AdNonHarmonicResult.class, wrapper); List<AdNonHarmonicResult> results = this.getBaseMapper().selectJoinList(AdNonHarmonicResult.class, wrapper);
DynamicTableNameHandler.remove(); DynamicTableNameHandler.remove();

View File

@@ -138,7 +138,7 @@ public class SysLogAuditServiceImpl extends ServiceImpl<SysLogAuditMapper, SysLo
String level = ReflectCommonUtil.getOperateInfoByMethod(returnType.getMethod()).getOperateLevel(); String level = ReflectCommonUtil.getOperateInfoByMethod(returnType.getMethod()).getOperateLevel();
sysLogAudit.setLevel(levelStringToNumber(level)); sysLogAudit.setLevel(levelStringToNumber(level));
// 中等以上的需要置为未告警,但是告警功能暂未做 // 中等以上的需要置为未告警,但是告警功能暂未做
if (sysLogAudit.getLevel() == 0) { if (sysLogAudit.getLevel() == 1) {
sysLogAudit.setWarn(1); sysLogAudit.setWarn(1);
} else { } else {
sysLogAudit.setWarn(0); sysLogAudit.setWarn(0);