This commit is contained in:
caozehui
2025-03-24 10:34:07 +08:00
parent 610a3c1d13
commit d0491b4850
4 changed files with 264 additions and 169 deletions

View File

@@ -2,6 +2,7 @@ package com.njcn.gather.report.pojo.po;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.RequiredArgsConstructor;
/**
* @author caozehui
@@ -19,4 +20,8 @@ public class CellEntity {
private int colSpan;
/**
* 字体颜色 格式为rgb 例如FF0000
*/
private String color;
}

View File

@@ -1,7 +1,14 @@
package com.njcn.gather.report.pojo.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import lombok.Data;
import java.time.LocalDateTime;
/**
* @author caozehui
* @data 2025-03-19
@@ -39,6 +46,14 @@ public class PqReportVO {
*/
private String description;
/**
* 创建时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
@JsonSerialize(using = LocalDateTimeSerializer.class)
private LocalDateTime createTime;
/**
* 状态0-删除 1-正常
*/

View File

@@ -74,6 +74,7 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.*;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -94,6 +95,9 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
@Value("${report.reportDir:D:\\report}")
private String reportPath;
private final String RED = "FF0000";
private final String BLACK = "000000";
private final IPqDevService iPqDevService;
private final IDictDataService dictDataService;
@@ -134,8 +138,8 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
pqReportVO.setBaseFileVO(baseFileVo);
PqReportVO.FileVO detailFileVo = new PqReportVO.FileVO();
detailFileVo.setName(pqReport.getBasePath().substring(pqReport.getBasePath().lastIndexOf(File.separator) + 1));
detailFileVo.setUrl(pqReport.getBasePath());
detailFileVo.setName(pqReport.getDetailPath().substring(pqReport.getDetailPath().lastIndexOf(File.separator) + 1));
detailFileVo.setUrl(pqReport.getDetailPath());
pqReportVO.setDetailFileVO(detailFileVo);
return pqReportVO;
@@ -770,7 +774,7 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
}
/**
* 获取map。 key为 检测大项code_大项ID value为检测项下的所有index。
* 获取map。 key为 检测大项code_大项ID value为检测项下的所有index。
*
* @param list
*/
@@ -810,21 +814,23 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
run.setFontFamily("宋体");
run.setBold(true);
run.setFontSize(12);
String s = key.split("_")[0];
String msg = DicDataEnum.getMessageByCode(s);
if (isHarm) {
run.setText(key.split("_")[0] + "测量准确度(最大允许误差:±" + radius.split("_")[1] + "");
run.setText(msg + "测量准确度(最大允许误差:±" + radius.split("_")[1] + "");
} else {
run.setText(key.split("_")[0] + "测量准确度(最大允许误差:±" + radius + "");
run.setText(msg + "测量准确度(最大允许误差:±" + radius + "");
}
XWPFTable table = generateTableHeaderZJ(baseModelDocument, DicDataEnum.getEnumByCode(key.split("_")[0]));
// 填写数据
// for (RawResultDataVO rawResultDataVO : radiusMap.get(radius)) {
//
// }
DicDataEnum enumByCode = DicDataEnum.getEnumByCode(key.split("_")[0]);
XWPFTable table = generateTableHeaderZJ(baseModelDocument, enumByCode);
paragraph = baseModelDocument.createParagraph();
// 生成表体
generateTableBodyZJ(table, radiusMap.get(radius), enumByCode);
}
}
/**
* 获取同一个检测大项下不同的误差范围,及其检测结果
*
@@ -883,207 +889,207 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
switch (checkItem) {
case FREQ: // 用于 频率
row = new ArrayList<>();
row.add(new CellEntity("给定值HZ", "25.0%", 1, 1));
row.add(new CellEntity("测试值HZ", "25.0%", 1, 1));
row.add(new CellEntity("误差HZ", "25.0%", 1, 1));
row.add(new CellEntity("结论", "25.0%", 1, 1));
row.add(new CellEntity("给定值HZ", "25.0%", 1, 1, BLACK));
row.add(new CellEntity("测试值HZ", "25.0%", 1, 1, BLACK));
row.add(new CellEntity("误差HZ", "25.0%", 1, 1, BLACK));
row.add(new CellEntity("结论", "25.0%", 1, 1, BLACK));
rows.add(row);
break;
case V: // 用于 电压
row = new ArrayList<>();
row.add(new CellEntity("给定值V", "15.0%", 2, 1));
row.add(new CellEntity("测试值V", "12.5%", 1, 3));
row.add(new CellEntity("", "12.5%", 1, 1));
row.add(new CellEntity("", "12.5%", 1, 1));
row.add(new CellEntity("误差(%", "12.5%", 1, 3));
row.add(new CellEntity("", "12.5%", 1, 1));
row.add(new CellEntity("", "12.5%", 1, 1));
row.add(new CellEntity("结论", "10.0%", 2, 1));
row.add(new CellEntity("给定值V", "15.0%", 2, 1, BLACK));
row.add(new CellEntity("测试值V", "12.5%", 1, 3, BLACK));
row.add(new CellEntity("", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("误差(%", "12.5%", 1, 3, BLACK));
row.add(new CellEntity("", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("结论", "10.0%", 2, 1, BLACK));
rows.add(row);
row = new ArrayList<>();
row.add(new CellEntity("", "15.0%", 1, 1));
row.add(new CellEntity("L1", "12.5%", 1, 1));
row.add(new CellEntity("L2", "12.5%", 1, 1));
row.add(new CellEntity("L3", "12.5%", 1, 1));
row.add(new CellEntity("L1", "12.5%", 1, 1));
row.add(new CellEntity("L2", "12.5%", 1, 1));
row.add(new CellEntity("L3", "12.5%", 1, 1));
row.add(new CellEntity("", "10.0%", 1, 1));
row.add(new CellEntity("", "15.0%", 1, 1, BLACK));
row.add(new CellEntity("L1", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("L2", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("L3", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("L1", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("L2", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("L3", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("", "10.0%", 1, 1, BLACK));
rows.add(row);
break;
case I: // 用于 电流
row = new ArrayList<>();
row.add(new CellEntity("给定值A", "15.0%", 2, 1));
row.add(new CellEntity("测试值A", "12.5%", 1, 3));
row.add(new CellEntity("", "12.5%", 1, 1));
row.add(new CellEntity("", "12.5%", 1, 1));
row.add(new CellEntity("误差(%", "12.5%", 1, 3));
row.add(new CellEntity("", "12.5%", 1, 1));
row.add(new CellEntity("", "12.5%", 1, 1));
row.add(new CellEntity("结论", "10.0%", 2, 1));
row.add(new CellEntity("给定值A", "15.0%", 2, 1, BLACK));
row.add(new CellEntity("测试值A", "12.5%", 1, 3, BLACK));
row.add(new CellEntity("", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("误差(%", "12.5%", 1, 3, BLACK));
row.add(new CellEntity("", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("结论", "10.0%", 2, 1, BLACK));
rows.add(row);
row = new ArrayList<>();
row.add(new CellEntity("", "15.0%", 1, 1));
row.add(new CellEntity("L1", "12.5%", 1, 1));
row.add(new CellEntity("L2", "12.5%", 1, 1));
row.add(new CellEntity("L3", "12.5%", 1, 1));
row.add(new CellEntity("L1", "12.5%", 1, 1));
row.add(new CellEntity("L2", "12.5%", 1, 1));
row.add(new CellEntity("L3", "12.5%", 1, 1));
row.add(new CellEntity("", "10.0%", 1, 1));
row.add(new CellEntity("", "15.0%", 1, 1, BLACK));
row.add(new CellEntity("L1", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("L2", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("L3", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("L1", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("L2", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("L3", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("", "10.0%", 1, 1, BLACK));
rows.add(row);
break;
case IMBV:// 用于 负序电压不平衡度、负序电流不平衡度
case IMBA:
row = new ArrayList<>();
row.add(new CellEntity("给定值(%", "25.0%", 1, 1));
row.add(new CellEntity("测试值(%", "25.0%", 1, 1));
row.add(new CellEntity("误差(%", "25.0%", 1, 1));
row.add(new CellEntity("结论", "25.0%", 1, 1));
row.add(new CellEntity("给定值(%", "25.0%", 1, 1, BLACK));
row.add(new CellEntity("测试值(%", "25.0%", 1, 1, BLACK));
row.add(new CellEntity("误差(%", "25.0%", 1, 1, BLACK));
row.add(new CellEntity("结论", "25.0%", 1, 1, BLACK));
rows.add(row);
break;
case F: // 用于 短时闪变
row = new ArrayList<>();
row.add(new CellEntity("给定值", "15.0%", 2, 1));
row.add(new CellEntity("测试值", "12.5%", 1, 3));
row.add(new CellEntity("", "12.5%", 1, 1));
row.add(new CellEntity("", "12.5%", 1, 1));
row.add(new CellEntity("误差(%", "12.5%", 1, 3));
row.add(new CellEntity("", "12.5%", 1, 1));
row.add(new CellEntity("", "12.5%", 1, 1));
row.add(new CellEntity("结论", "10.0%", 2, 1));
row.add(new CellEntity("给定值", "15.0%", 2, 1, BLACK));
row.add(new CellEntity("测试值", "12.5%", 1, 3, BLACK));
row.add(new CellEntity("", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("误差(%", "12.5%", 1, 3, BLACK));
row.add(new CellEntity("", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("结论", "10.0%", 2, 1, BLACK));
rows.add(row);
row = new ArrayList<>();
row.add(new CellEntity("", "15.0%", 1, 1));
row.add(new CellEntity("L1", "12.5%", 1, 1));
row.add(new CellEntity("L2", "12.5%", 1, 1));
row.add(new CellEntity("L3", "12.5%", 1, 1));
row.add(new CellEntity("L1", "12.5%", 1, 1));
row.add(new CellEntity("L2", "12.5%", 1, 1));
row.add(new CellEntity("L3", "12.5%", 1, 1));
row.add(new CellEntity("", "10.0%", 1, 1));
row.add(new CellEntity("", "15.0%", 1, 1, BLACK));
row.add(new CellEntity("L1", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("L2", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("L3", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("L1", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("L2", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("L3", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("", "10.0%", 1, 1, BLACK));
rows.add(row);
break;
case HV: // 用于 谐波电压
row = new ArrayList<>();
row.add(new CellEntity("谐波次数", "7.0%", 2, 1));
row.add(new CellEntity("谐波电压给定值(%", "10.0%", 2, 1));
row.add(new CellEntity("测试值(%", "12.5%", 1, 3));
row.add(new CellEntity("", "12.5%", 1, 1));
row.add(new CellEntity("", "12.5%", 1, 1));
row.add(new CellEntity("误差(%", "12.5%", 1, 3));
row.add(new CellEntity("", "12.5%", 1, 1));
row.add(new CellEntity("", "12.5%", 1, 1));
row.add(new CellEntity("结论", "8.0%", 2, 1));
row.add(new CellEntity("谐波次数", "7.0%", 2, 1, BLACK));
row.add(new CellEntity("谐波电压给定值(%", "10.0%", 2, 1, BLACK));
row.add(new CellEntity("测试值(%", "12.5%", 1, 3, BLACK));
row.add(new CellEntity("", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("误差(%", "12.5%", 1, 3, BLACK));
row.add(new CellEntity("", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("结论", "8.0%", 2, 1, BLACK));
rows.add(row);
row = new ArrayList<>();
row.add(new CellEntity("", "7.0%", 1, 1));
row.add(new CellEntity("", "10.0%", 1, 1));
row.add(new CellEntity("L1", "12.5%", 1, 1));
row.add(new CellEntity("L2", "12.5%", 1, 1));
row.add(new CellEntity("L3", "12.5%", 1, 1));
row.add(new CellEntity("L1", "12.5%", 1, 1));
row.add(new CellEntity("L2", "12.5%", 1, 1));
row.add(new CellEntity("L3", "12.5%", 1, 1));
row.add(new CellEntity("", "8.0%", 1, 1));
row.add(new CellEntity("", "7.0%", 1, 1, BLACK));
row.add(new CellEntity("", "10.0%", 1, 1, BLACK));
row.add(new CellEntity("L1", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("L2", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("L3", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("L1", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("L2", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("L3", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("", "8.0%", 1, 1, BLACK));
rows.add(row);
break;
case HI: // 用于 谐波电流
row = new ArrayList<>();
row.add(new CellEntity("谐波次数", "8.0%", 2, 1));
row.add(new CellEntity("谐波电流给定值A", "10.0%", 2, 1));
row.add(new CellEntity("测试值A", "12.5%", 1, 3));
row.add(new CellEntity("", "12.5%", 1, 1));
row.add(new CellEntity("", "12.5%", 1, 1));
row.add(new CellEntity("误差(%", "12.5%", 1, 3));
row.add(new CellEntity("", "12.5%", 1, 1));
row.add(new CellEntity("", "12.5%", 1, 1));
row.add(new CellEntity("结论", "7.0%", 2, 1));
row.add(new CellEntity("谐波次数", "8.0%", 2, 1, BLACK));
row.add(new CellEntity("谐波电流给定值A", "10.0%", 2, 1, BLACK));
row.add(new CellEntity("测试值A", "12.5%", 1, 3, BLACK));
row.add(new CellEntity("", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("误差(%", "12.5%", 1, 3, BLACK));
row.add(new CellEntity("", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("结论", "7.0%", 2, 1, BLACK));
rows.add(row);
row = new ArrayList<>();
row.add(new CellEntity("", "8.0%", 1, 1));
row.add(new CellEntity("", "10.0%", 1, 1));
row.add(new CellEntity("L1", "12.5%", 1, 1));
row.add(new CellEntity("L2", "12.5%", 1, 1));
row.add(new CellEntity("L3", "12.5%", 1, 1));
row.add(new CellEntity("L1", "12.5%", 1, 1));
row.add(new CellEntity("L2", "12.5%", 1, 1));
row.add(new CellEntity("L3", "12.5%", 1, 1));
row.add(new CellEntity("", "7.0%", 1, 1));
row.add(new CellEntity("", "8.0%", 1, 1, BLACK));
row.add(new CellEntity("", "10.0%", 1, 1, BLACK));
row.add(new CellEntity("L1", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("L2", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("L3", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("L1", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("L2", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("L3", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("", "7.0%", 1, 1, BLACK));
rows.add(row);
break;
case HSV: // 用于 间谐波电压
row = new ArrayList<>();
row.add(new CellEntity("间谐波次数", "8.0%", 2, 1));
row.add(new CellEntity("间谐波电压给定值(%", "10.0%", 2, 1));
row.add(new CellEntity("测试值(%", "12.5%", 1, 3));
row.add(new CellEntity("", "12.5%", 1, 1));
row.add(new CellEntity("", "12.5%", 1, 1));
row.add(new CellEntity("误差(%", "12.5%", 1, 3));
row.add(new CellEntity("", "12.5%", 1, 1));
row.add(new CellEntity("", "12.5%", 1, 1));
row.add(new CellEntity("结论", "7.0%", 2, 1));
row.add(new CellEntity("间谐波次数", "8.0%", 2, 1, BLACK));
row.add(new CellEntity("间谐波电压给定值(%", "10.0%", 2, 1, BLACK));
row.add(new CellEntity("测试值(%", "12.5%", 1, 3, BLACK));
row.add(new CellEntity("", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("误差(%", "12.5%", 1, 3, BLACK));
row.add(new CellEntity("", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("结论", "7.0%", 2, 1, BLACK));
rows.add(row);
row = new ArrayList<>();
row.add(new CellEntity("", "8.0%", 1, 1));
row.add(new CellEntity("", "10.0%", 1, 1));
row.add(new CellEntity("L1", "12.5%", 1, 1));
row.add(new CellEntity("L2", "12.5%", 1, 1));
row.add(new CellEntity("L3", "12.5%", 1, 1));
row.add(new CellEntity("L1", "12.5%", 1, 1));
row.add(new CellEntity("L2", "12.5%", 1, 1));
row.add(new CellEntity("L3", "12.5%", 1, 1));
row.add(new CellEntity("", "7.0%", 1, 1));
row.add(new CellEntity("", "8.0%", 1, 1, BLACK));
row.add(new CellEntity("", "10.0%", 1, 1, BLACK));
row.add(new CellEntity("L1", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("L2", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("L3", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("L1", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("L2", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("L3", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("", "7.0%", 1, 1, BLACK));
rows.add(row);
break;
case HSI: // 用于 间谐波电流
row = new ArrayList<>();
row.add(new CellEntity("间谐波次数", "8.0%", 2, 1));
row.add(new CellEntity("间谐波电流给定值A", "10.0%", 2, 1));
row.add(new CellEntity("测试值A", "12.5%", 1, 3));
row.add(new CellEntity("", "12.5%", 1, 1));
row.add(new CellEntity("", "12.5%", 1, 1));
row.add(new CellEntity("误差(%", "12.5%", 1, 3));
row.add(new CellEntity("", "12.5%", 1, 1));
row.add(new CellEntity("", "12.5%", 1, 1));
row.add(new CellEntity("结论", "7.0%", 2, 1));
row.add(new CellEntity("间谐波次数", "8.0%", 2, 1, BLACK));
row.add(new CellEntity("间谐波电流给定值A", "10.0%", 2, 1, BLACK));
row.add(new CellEntity("测试值A", "12.5%", 1, 3, BLACK));
row.add(new CellEntity("", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("误差(%", "12.5%", 1, 3, BLACK));
row.add(new CellEntity("", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("结论", "7.0%", 2, 1, BLACK));
rows.add(row);
row = new ArrayList<>();
row.add(new CellEntity("", "8.0%", 1, 1));
row.add(new CellEntity("", "10.0%", 1, 1));
row.add(new CellEntity("L1", "12.5%", 1, 1));
row.add(new CellEntity("L2", "12.5%", 1, 1));
row.add(new CellEntity("L3", "12.5%", 1, 1));
row.add(new CellEntity("L1", "12.5%", 1, 1));
row.add(new CellEntity("L2", "12.5%", 1, 1));
row.add(new CellEntity("L3", "12.5%", 1, 1));
row.add(new CellEntity("", "7.0%", 1, 1));
row.add(new CellEntity("", "8.0%", 1, 1, BLACK));
row.add(new CellEntity("", "10.0%", 1, 1, BLACK));
row.add(new CellEntity("L1", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("L2", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("L3", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("L1", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("L2", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("L3", "12.5%", 1, 1, BLACK));
row.add(new CellEntity("", "7.0%", 1, 1, BLACK));
rows.add(row);
break;
case VOLTAGE: // 用于 电压暂降、暂升及短时中断
row = new ArrayList<>();
row.add(new CellEntity("给定值", "16.0%", 1, 2));
row.add(new CellEntity("", "16.0%", 1, 1));
row.add(new CellEntity("测试值", "16.0%", 1, 2));
row.add(new CellEntity("", "16.0%", 1, 1));
row.add(new CellEntity("误差", "16.0%", 1, 2));
row.add(new CellEntity("", "16.0%", 1, 1));
row.add(new CellEntity("给定值", "16.0%", 1, 2, BLACK));
row.add(new CellEntity("", "16.0%", 1, 1, BLACK));
row.add(new CellEntity("测试值", "16.0%", 1, 2, BLACK));
row.add(new CellEntity("", "16.0%", 1, 1, BLACK));
row.add(new CellEntity("误差", "16.0%", 1, 2, BLACK));
row.add(new CellEntity("", "16.0%", 1, 1, BLACK));
rows.add(row);
row = new ArrayList<>();
row.add(new CellEntity("特征幅值(%", "16.0%", 1, 1));
row.add(new CellEntity("持续时间ms", "16.0%", 1, 1));
row.add(new CellEntity("特征幅值(%", "16.0%", 1, 1));
row.add(new CellEntity("持续时间ms", "16.0%", 1, 1));
row.add(new CellEntity("特征幅值(%", "16.0%", 1, 1));
row.add(new CellEntity("持续时间ms", "16.0%", 1, 1));
row.add(new CellEntity("特征幅值(%", "16.0%", 1, 1, BLACK));
row.add(new CellEntity("持续时间ms", "16.0%", 1, 1, BLACK));
row.add(new CellEntity("特征幅值(%", "16.0%", 1, 1, BLACK));
row.add(new CellEntity("持续时间ms", "16.0%", 1, 1, BLACK));
row.add(new CellEntity("特征幅值(%", "16.0%", 1, 1, BLACK));
row.add(new CellEntity("持续时间ms", "16.0%", 1, 1, BLACK));
rows.add(row);
break;
default:
@@ -1091,17 +1097,32 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
}
return generateTableHeader(doc, rows);
return generateTable(doc, rows, true);
}
/**
* 动态生成表格头部
* 根据数据生成表体部分
*
* @param table
* @param rawResultDataVOS
* @param enumByCode
* @return
*/
private XWPFTable generateTableBodyZJ(XWPFTable table,List<RawResultDataVO> rawResultDataVOS, DicDataEnum enumByCode) {
// 组装数据
List<List<CellEntity>> rows = getTableBodyDataZJ(rawResultDataVOS, enumByCode);
return table;
}
/**
* 动态生成表格
*
* @param doc
* @param rows 表头数据
* @param rows 表头数据
* @param isHeader 是否是表头
* @return 生成的表格
*/
private XWPFTable generateTableHeader(XWPFDocument doc, List<List<CellEntity>> rows) {
private XWPFTable generateTable(XWPFDocument doc, List<List<CellEntity>> rows, boolean isHeader) {
XWPFTable table = doc.createTable(rows.size(), rows.get(0).size());
table.setTableAlignment(TableRowAlign.CENTER);
table.setWidth("100%");
@@ -1116,9 +1137,12 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
for (int j = 0; j < rows.get(i).size(); j++) {
CellEntity cellEntity = rows.get(i).get(j);
row.getCell(j).setText(cellEntity.getCellValue());
row.getCell(j).setWidth(cellEntity.getWidth());
setHeaderCellStyle(row.getCell(j));
if (isHeader) {
setCommonCellStyle(row.getCell(j), cellEntity, true);
} else {
setCommonCellStyle(row.getCell(j), cellEntity, false);
}
if (cellEntity.getColSpan() > 1) {
mergeCellsHorizontal(table, i, j, j + cellEntity.getColSpan() - 1);
@@ -1131,6 +1155,34 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
return table;
}
/**
* 获取表体数据
*
* @param resultDataVOList
* @param checkItem
* @return
*/
private List<List<CellEntity>> getTableBodyDataZJ(List<RawResultDataVO> resultDataVOList, DicDataEnum checkItem) {
List<List<CellEntity>> rows = new ArrayList<>();
List<CellEntity> row = null;
switch (checkItem) {
case FREQ:
for (RawResultDataVO resultDataVO : resultDataVOList) {
row = new ArrayList<>();
RawResultDataVO.DetectionData dataT = resultDataVO.getDataT();
row.add(new CellEntity(dataT.getResultData() + "", "25.0%", 1, 1, BLACK));
row.add(new CellEntity(dataT.getData() + "", "25.0%", 1, 1, BLACK));
row.add(new CellEntity(dataT.getRadius() + "", "25.0%", 1, 1, BLACK));
row.add(new CellEntity(getResultStr(resultDataVO.getIsData()) + "", "25.0%", 1, 1, resultDataVO.getIsData() == 1 ? BLACK : RED));
rows.add(row);
}
break;
default:
break;
}
return rows;
}
public CTTcPr getTcPr(XWPFTableCell cell) {
return cell.getCTTc().isSetTcPr() ? cell.getCTTc().getTcPr() : cell.getCTTc().addNewTcPr();
}
@@ -1177,23 +1229,28 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
}
}
public void setHeaderCellStyle(XWPFTableCell cell) {
public void setCommonCellStyle(XWPFTableCell cell, CellEntity cellEntity, boolean isBold) {
cell.setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);
XWPFParagraph xwpfParagraph = cell.getParagraphs().get(0);
xwpfParagraph.setAlignment(ParagraphAlignment.CENTER);
// System.out.println("Paragraph text: " + xwpfParagraph.getText());
// List<XWPFRun> runs = xwpfParagraph.getRuns();
// runs.get(0).setBold(true);
// runs.get(0).setFontSize(10);
// String text = runs.get(0).getText(0);
// if (StrUtil.isNotBlank(text) && Pattern.matches("^[A-Za-z0-9]+$", text)) {
// runs.get(0).setFontFamily("Arial");
// } else {
// runs.get(0).setFontFamily("宋体");
// }
List<XWPFRun> runs = xwpfParagraph.getRuns();
XWPFRun run = null;
if (runs.isEmpty()) {
run = xwpfParagraph.createRun();
} else {
run = runs.get(0);
}
run.setText(cellEntity.getCellValue());
run.setBold(isBold);
run.setFontSize(10);
String text = run.getText(0);
if (StrUtil.isNotBlank(text) && Pattern.matches("^[A-Za-z0-9]+$", text)) {
run.setFontFamily("Arial");
} else {
run.setFontFamily("宋体");
}
}
private void specialDealVoltage(Map<String, String> dataModelMap, String symbol) {
String value = dataModelMap.get(symbol);
if (Objects.nonNull(value) && !value.equals("/")) {
@@ -1407,4 +1464,14 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
throw new BusinessException(ReportResponseEnum.REPORT_REPEATED);
}
}
private String getResultStr(Integer isData) {
if (isData == 1) {
return "合格";
}
if (isData == 2) {
return "不合格";
}
return "/";
}
}

View File

@@ -46,4 +46,12 @@ public enum DicDataEnum {
}
return null;
}
public static String getMessageByCode(String code) {
DicDataEnum e = getEnumByCode(code);
if (e!= null) {
return e.getMessage();
}
return "";
}
}