15 Commits

Author SHA1 Message Date
caozehui
32fc732f2e Merge remote-tracking branch 'origin/qr_branch' into qr_branch 2026-03-26 14:24:12 +08:00
caozehui
ef59d7b514 微调 2026-03-26 14:24:05 +08:00
caozehui
5e9cc50e6b 微调 2026-03-26 13:35:29 +08:00
caozehui
8aac33c14b 报告改成读取指定目录下的 2026-03-25 14:30:10 +08:00
caozehui
d6f2dbe64c 报告封面微调 2025-12-26 10:14:18 +08:00
caozehui
303c8dd4f0 微调 2025-12-23 15:48:57 +08:00
caozehui
753a303fec 报告设备类型调整 2025-12-23 15:12:11 +08:00
caozehui
3f1ae1886a Merge remote-tracking branch 'origin/qr_branch' into qr_branch 2025-12-19 16:17:40 +08:00
caozehui
af4863af65 2楼报告封面调整:装置编码改成装置编号 2025-12-19 16:17:33 +08:00
2012221b73 河北报告定制化改动 2025-12-02 13:37:35 +08:00
caozehui
f4df52dd1c 暂态只有a项时,当a相无数据时判断为不符合 2025-11-27 18:36:38 +08:00
41c557118c Merge remote-tracking branch 'origin/qr_branch' into qr_branch 2025-11-26 10:22:15 +08:00
6596a572d6 修复数模式的相序校验电流加量问题 2025-11-26 10:17:33 +08:00
caozehui
786bd5d660 报告调整 2025-11-19 13:20:35 +08:00
caozehui
21d2c2b7a7 报告调整 2025-11-19 13:20:17 +08:00
20 changed files with 153 additions and 59 deletions

View File

@@ -12,6 +12,7 @@ import com.njcn.gather.detection.pojo.enums.DetectionCodeEnum;
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
import com.njcn.gather.detection.pojo.po.DevData;
import com.njcn.gather.detection.pojo.vo.DetectionData;
import com.njcn.gather.device.pojo.enums.CheckResultEnum;
import com.njcn.gather.err.pojo.param.PqErrSysParam;
import com.njcn.gather.err.pojo.po.PqErrSysDtls;
import com.njcn.gather.err.pojo.vo.ErrDtlsCheckDataVO;
@@ -774,6 +775,9 @@ public class DetectionServiceImpl {
))
.collect(Collectors.toList());
DetectionData a = setDetectionData(isQualified, dataRule, mag, fData, dur, magErrList, channelTypeAList, TYPE_A);
if (CollUtil.isEmpty(mag.get(TYPE_A))) {
a.setIsData(2);
}
result.setAValue(JSON.toJSONString(a));
result.setTValue(JSON.toJSONString(a));
result.setResultFlag(a.getIsData());

View File

@@ -32,7 +32,10 @@ public enum BaseReportKeyEnum {
YEAR_MONTH_DAY("year-month-day","年-月-日"),
TEMPERATURE("temp","温度"),
HUMIDITY("hum","相对湿度"),
DELEGATE("delegate","委托方");
DELEGATE("delegate","委托方"),
CREATEDATE("createDate","出厂日期"),
HW_VERSION("hardwareVersion","硬件版本"),
SW_VERSION("softwareVersion","软件版本");
private String key;

View File

@@ -65,13 +65,14 @@ import com.njcn.gather.storage.service.AdNonHarmonicService;
import com.njcn.gather.system.cfg.pojo.enums.SceneEnum;
import com.njcn.gather.system.cfg.service.ISysTestConfigService;
import com.njcn.gather.system.dictionary.pojo.po.DictData;
import com.njcn.gather.system.dictionary.pojo.po.DictType;
import com.njcn.gather.system.dictionary.service.IDictDataService;
import com.njcn.gather.system.dictionary.service.IDictTypeService;
import com.njcn.gather.type.pojo.po.DevType;
import com.njcn.gather.type.service.IDevTypeService;
import com.njcn.http.util.RestTemplateUtil;
import com.njcn.web.factory.PageFactory;
import io.netty.channel.Channel;
import javafx.scene.input.DataFormat;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.net.ftp.FTPClient;
@@ -85,6 +86,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.FileSystemResource;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -162,9 +164,13 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
@Value("${report.dateFormat}")
private String dateFormat;
// 设备出厂装置型号字典对应的code
private final String EX_FACTORY_DEV_TYPE = "Ex-factory_Dev_Type";
private final IPqDevService iPqDevService;
private final PqDevMapper pqDevMapper;
private final IDictTypeService dictTypeService;
private final IDictDataService dictDataService;
private final IAdPlanService adPlanService;
@@ -595,7 +601,8 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
throw new BusinessException(ReportResponseEnum.REPORT_TEMPLATE_NOT_EXIST);
}
// 读取模板文件
ClassPathResource resource = new ClassPathResource("/model/" + reportName.getCode() + ReportConstant.DOCX);
// ClassPathResource resource = new ClassPathResource("/model/" + reportName.getCode() + ReportConstant.DOCX);
FileSystemResource resource = new FileSystemResource(templatePath + File.separator + reportName.getCode() + ReportConstant.DOCX);
try (InputStream inputStream = resource.getInputStream()) {
// 加载Word文档
XWPFDocument baseModelDocument = new XWPFDocument(inputStream);
@@ -1233,16 +1240,34 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
Tr existingRow = (Tr) tbl.getContent().get(rows.size() - 1);
// 获取现有样式
TrPr trPr = existingRow.getTrPr();
JAXBElement<Tc> element = (JAXBElement<Tc>) existingRow.getContent().get(0);
TcPr tcPr = element.getValue().getTcPr();
TblWidth cellWidth = factory.createTblWidth();
cellWidth.setType("dxa");
cellWidth.setW(BigInteger.valueOf(5000 / tableKeys.size()));
tcPr.setTcW(cellWidth);
// 获取每个单元格的TcPr保留各单元格独立的边框设置
List<TcPr> tcPrList = new ArrayList<>();
RPr templateRPr = null;
for (Object cellObj : existingRow.getContent()) {
if (cellObj instanceof JAXBElement) {
JAXBElement<Tc> cellElement = (JAXBElement<Tc>) cellObj;
Tc templateCell = cellElement.getValue();
TcPr tcPr = templateCell.getTcPr();
// 设置单元格宽度
if (tcPr == null) {
tcPr = factory.createTcPr();
}
TblWidth cellWidth = factory.createTblWidth();
cellWidth.setType("dxa");
cellWidth.setW(BigInteger.valueOf(5000 / tableKeys.size()));
tcPr.setTcW(cellWidth);
tcPrList.add(tcPr);
// 从第一个单元格获取字体样式
if (templateRPr == null && !templateCell.getContent().isEmpty() && templateCell.getContent().get(0) instanceof P) {
P templateP = (P) templateCell.getContent().get(0);
templateRPr = Docx4jUtil.getTcPrFromParagraph(templateP);
}
}
}
tbl.getContent().remove(existingRow);
// 迭代增加行,需要填充的表格keys在tableKeys集合中
for (Map<String, String> stringStringMap : dataList) {
Tr newRow = Docx4jUtil.createCustomRow(factory, stringStringMap, tableKeys, trPr, tcPr, true);
Tr newRow = Docx4jUtil.createCustomRow(factory, stringStringMap, tableKeys, trPr, tcPrList, templateRPr, true);
tbl.getContent().add(newRow);
}
} else {
@@ -1409,6 +1434,17 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
Map<String, String> baseModelMap = new HashMap<>(32);
// 获取设备型号
baseModelMap.put(prefix + BaseReportKeyEnum.DEV_TYPE.getKey() + suffix, devType.getName());
DictType dictType = dictTypeService.getByCode(EX_FACTORY_DEV_TYPE);
if (ObjectUtil.isNotNull(dictType)) {
List<DictData> dictDataList = dictDataService.getDictDataByTypeId(dictType.getId());
DictData targetDictData = dictDataList.stream().filter(dictData -> dictData.getCode().equals(devType.getName())).findFirst().orElse(null);
if (ObjectUtil.isNotNull(targetDictData)) {
String name = devType.getName();
name = name.substring(0, name.lastIndexOf(StrUtil.DASHED));
baseModelMap.put(prefix + BaseReportKeyEnum.DEV_TYPE.getKey() + suffix, name + "(" + targetDictData.getValue() + ")");
}
}
// 检测员
baseModelMap.put(prefix + BaseReportKeyEnum.INSPECTOR.getKey() + suffix, pqDevVO.getCheckBy() + "");
String datePattern = DatePattern.NORM_DATE_PATTERN;
@@ -1416,6 +1452,14 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
datePattern = DatePattern.CHINESE_DATE_PATTERN;
}
// 出厂日期
baseModelMap.put(prefix + BaseReportKeyEnum.CREATEDATE.getKey() + suffix, pqDevVO.getCreateDate().format(DateTimeFormatter.ofPattern(datePattern)));
// 硬件版本
baseModelMap.put(prefix + BaseReportKeyEnum.HW_VERSION.getKey() + suffix, StrUtil.isNotBlank(pqDevVO.getHardwareVersion()) ? pqDevVO.getHardwareVersion() : StrUtil.EMPTY);
// 软件版本
baseModelMap.put(prefix + BaseReportKeyEnum.SW_VERSION.getKey() + suffix, StrUtil.isNotBlank(pqDevVO.getSoftwareVersion()) ? pqDevVO.getSoftwareVersion() : StrUtil.EMPTY);
// 调试日期
if (pqDevVO.getCheckTime() != null) {
baseModelMap.put(prefix + BaseReportKeyEnum.TEST_DATE.getKey() + suffix, DateUtil.format(pqDevVO.getCheckTime(), datePattern));
@@ -1442,9 +1486,9 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
// 委托方
String delegate = pqDevVO.getDelegate();
if (StrUtil.isNotBlank(delegate)) {
DictData delegateDictData = dictDataService.getDictDataById(pqDevVO.getManufacturer());
DictData delegateDictData = dictDataService.getDictDataById(pqDevVO.getDelegate());
if (ObjectUtil.isNotNull(delegateDictData)) {
baseModelMap.put(prefix + BaseReportKeyEnum.DELEGATE.getKey() + suffix, dictData.getName());
baseModelMap.put(prefix + BaseReportKeyEnum.DELEGATE.getKey() + suffix, delegateDictData.getName());
} else {
baseModelMap.put(prefix + BaseReportKeyEnum.DELEGATE.getKey() + suffix, StrPool.TAB);
}
@@ -1483,12 +1527,13 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
//String scriptId = adPlan.getScriptId();
Integer devChns = pqDevVO.getDevChns();
for (int i = 1; i <= devChns; i++) {
String path = "/model/report_table.docx";
String path = "/report_table.docx";
DevType devType = devTypeService.getById(pqDevVO.getDevType());
if (devType.getName().equals("PQ-COM")) {
path = "/model/report_table - PQ-COM.docx";
path = "/report_table - PQ-COM.docx";
}
ClassPathResource resource = new ClassPathResource(path);
// ClassPathResource resource = new ClassPathResource(path);
FileSystemResource resource = new FileSystemResource(templatePath + path);
XWPFDocument dataModelDocumentTemp = new XWPFDocument(resource.getInputStream());
SingleNonHarmParam singleNonHarmParam = new SingleNonHarmParam();

View File

@@ -93,18 +93,19 @@ public class BookmarkUtil {
idx = idx + 1;
parentContent.add(idx, p);
}
else if (textFromP.startsWith(PowerIndexEnum.IMBV.getDesc())
|| textFromP.startsWith(PowerIndexEnum.HV.getDesc())
|| textFromP.startsWith(PowerIndexEnum.HI.getDesc())
) {
// 另起一页
P pagePara = Docx4jUtil.getPageBreak();
idx = idx + 1;
parentContent.add(idx, pagePara);
idx = idx + 1;
parentContent.add(idx, element);
}else if(textFromP.startsWith("基波电流幅值5.000A基波频率50.0Hz,各次间谐波电流含有率均为3.0%。")){
// else if (textFromP.startsWith(PowerIndexEnum.IMBV.getDesc())
// || textFromP.startsWith(PowerIndexEnum.HV.getDesc())
// || textFromP.startsWith(PowerIndexEnum.HI.getDesc())
//
// ) {
// // 另起一页
// P pagePara = Docx4jUtil.getPageBreak();
// idx = idx + 1;
// parentContent.add(idx, pagePara);
// idx = idx + 1;
// parentContent.add(idx, element);
// }
else if(textFromP.startsWith("基波电流幅值5.000A基波频率50.0Hz,各次间谐波电流含有率均为3.0%。")){
idx = idx + 1;
parentContent.add(idx, element);
P pagePara = Docx4jUtil.getPageBreak();

View File

@@ -322,17 +322,20 @@ public class Docx4jUtil {
}
/**
* 根据已知信息创建新
* 根据已知信息创建新
*
* @param factory 工厂
* @param valueMap 数据
* @param tableKeys keys
* @param trPr 行样式
* @param tcPr 单元格样式
* @param factory 工厂
* @param valueMap 数据
* @param tableKeys keys
* @param trPr 行样式
* @param tcPrList 每个单元格样式列表(用于保留各单元格独立的边框设置)
* @param templateRPr 模板中的字体样式可为null为null时使用默认宋体10号
* @param centerFlag 是否居中
*/
public static Tr createCustomRow(ObjectFactory factory, Map<String, String> valueMap, List<String> tableKeys, TrPr trPr, TcPr tcPr, boolean centerFlag) {
public static Tr createCustomRow(ObjectFactory factory, Map<String, String> valueMap, List<String> tableKeys, TrPr trPr, List<TcPr> tcPrList, RPr templateRPr, boolean centerFlag) {
Tr row = factory.createTr();
for (String tableKey : tableKeys) {
for (int i = 0; i < tableKeys.size(); i++) {
String tableKey = tableKeys.get(i);
Tc cell = factory.createTc();
P paragraph = factory.createP();
R run = factory.createR();
@@ -341,20 +344,41 @@ public class Docx4jUtil {
text.setValue(value);
run.getContent().add(text);
paragraph.getContent().add(run);
// 字体
// 设置字体
// 从模板复制字体样式
RPr rPr = factory.createRPr();
RFonts rFonts = factory.createRFonts();
if (containsChinese(value)) {
if (templateRPr != null) {
// 复制字体
if (templateRPr.getRFonts() != null) {
RFonts rFonts = factory.createRFonts();
rFonts.setEastAsia(templateRPr.getRFonts().getEastAsia());
rFonts.setAscii(templateRPr.getRFonts().getAscii());
rFonts.setHAnsi(templateRPr.getRFonts().getHAnsi());
rPr.setRFonts(rFonts);
}
// 复制字号
if (templateRPr.getSz() != null) {
HpsMeasure sz = factory.createHpsMeasure();
sz.setVal(templateRPr.getSz().getVal());
rPr.setSz(sz);
}
if (templateRPr.getSzCs() != null) {
HpsMeasure szCs = factory.createHpsMeasure();
szCs.setVal(templateRPr.getSzCs().getVal());
rPr.setSzCs(szCs);
}
} else {
// 默认使用宋体10号
RFonts rFonts = factory.createRFonts();
rFonts.setEastAsia("宋体");
rFonts.setAscii("宋体");
rFonts.setHAnsi("宋体");
} else {
rFonts.setEastAsia("Arial");
rFonts.setAscii("Arial");
rFonts.setHAnsi("Arial");
rPr.setRFonts(rFonts);
HpsMeasure sz = factory.createHpsMeasure();
sz.setVal(new BigInteger("20"));
rPr.setSz(sz);
}
rPr.setRFonts(rFonts);
// 设置段落居中
if (centerFlag) {
PPr pPr = factory.createPPr();
@@ -363,20 +387,19 @@ public class Docx4jUtil {
pPr.setJc(jc);
paragraph.setPPr(pPr);
}
if (value.equals("不合格")) {
// 不合格标红
if (value != null && value.equals("不合格")) {
Color color = factory.createColor();
// 红色
color.setVal("FF0000");
rPr.setColor(color);
run.setRPr(rPr);
}
HpsMeasure sz = factory.createHpsMeasure();
// 10号字体 = 20 half-points
sz.setVal(new BigInteger("20"));
rPr.setSz(sz);
run.setRPr(rPr);
cell.getContent().add(paragraph);
cell.setTcPr(tcPr);
// 使用对应位置的单元格样式(保留边框设置)
if (tcPrList != null && i < tcPrList.size()) {
cell.setTcPr(tcPrList.get(i));
}
row.getContent().add(cell);
row.setTrPr(trPr);
}

View File

@@ -14,6 +14,7 @@ import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
import com.njcn.gather.device.pojo.enums.CommonEnum;
import com.njcn.gather.device.pojo.po.PqDev;
import com.njcn.gather.device.pojo.vo.PqDevVO;
import com.njcn.gather.device.service.IPqDevService;
import com.njcn.gather.plan.mapper.AdPlanMapper;
import com.njcn.gather.plan.pojo.po.AdPlan;
@@ -886,6 +887,22 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
queryWrapper.eq(PqScriptDtls::getScriptIndex, -1)
.eq(PqScriptDtls::getEnable, 1);
pqScriptDtls = this.list(queryWrapper);
// 相序校验中电流需加量需要依据企标10650.2中章节5.5.3的描述过载能力2 倍额定电流连续10 倍额定电流持续 1 s。
// 考虑到有可能存在1A的额定电流本处做特殊处理加量分别为额定电流的0.2/0.4/0.6的标幺乘积加量
// 电压暂不做处理原因1、电压的企标描述过载能力为4倍空间较大2、额定电压比如57.74V为浮点数,存在不确定小数位,避免引起算术误差;
// 1. 获取额定电流,前端已做限制,相同额定电流才能一起检测
String deviceId = param.getDevIds().get(0);
PqDevVO pqDev = pqDevService.getPqDevById(deviceId);
String devTypeId = pqDev.getDevType();
DevType devType = devTypeService.getById(devTypeId);
Double devCurr = devType.getDevCurr();
for (int i = 0; i < pqScriptDtls.size(); i++) {
PqScriptDtls scriptDtls = pqScriptDtls.get(i);
// 注意此处scriptDtls.getValue() < 1.0,考虑到有些已经投入运行的地方,可能没有改库,避免不必要的异常
if(scriptDtls.getValueType().equalsIgnoreCase("CUR") && scriptDtls.getValue() < 1.0){
scriptDtls.setValue(devCurr * scriptDtls.getValue());
}
}
} else if (param.getIsPhaseSequence().equals(CommonEnum.COEFFICIENT_TEST.getValue())) {
//系数
queryWrapper.in(PqScriptDtls::getScriptIndex, param.getIndexList())

View File

@@ -6,12 +6,12 @@ spring:
datasource:
druid:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://192.168.1.24:13306/pqs9100_2f?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=Asia/Shanghai
# url: jdbc:mysql://192.168.1.24:13306/pqs91002?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true
# username: root
# password: njcnpqs
url: jdbc:mysql://192.168.1.24:13306/pqs9100_2f?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true
username: root
password: njcnpqs
# url: jdbc:mysql://localhost:3306/pqs91001?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=CTT
# username: root
# password: root
#初始化建立物理连接的个数、最小、最大连接数
initial-size: 5
min-idle: 5
@@ -49,10 +49,10 @@ phaseAngle:
socket:
source:
ip: 192.168.1.138
ip: 127.0.0.1
port: 62000
device:
ip: 192.168.1.138
ip: 127.0.0.1
port: 61000
# source:
# ip: 192.168.1.121
@@ -87,7 +87,7 @@ log:
report:
template: D:\template
reportDir: D:\report
dateFormat: yyyy年MM月dd日
qr:
cloud: http://pqmcc.com:18082/api/file
dev:

1
license.key Normal file
View File

@@ -0,0 +1 @@
AoNUHvLQag9nPPxWDsf5EwwBqifh5wnoFjrU01w+kIA7TPdRl0AQDBSA3IU7AY28Liubt6Rl8CsDtxEDrz8L5m0FqQrmZ1TmIJtZWbBR16NxXRgf8izM5JurYEY6ZbjU021yCu0fitxB0DJZ8LB8zfUDsV1MFGHl+yPjh4ZQrYDffID4rk/mRe/EE6F7bS19upStSOnQxVQVJSXwCVVHgsuFXqiuagM21OmxpYNjqaPnvAKoHRXTTxXn9BrSgZBocxuHB/IE+a0a+Q2eQo4RZa2IQpneEA/QIKEqezqsABxmM33duQ4eKt17hAttISV1J0R1cKpwZ4tYuSoHCuMONA==