ADD: 添加项目配置文档和开发指南
- 新增 CLAUDE.md 项目架构和开发指导文档 - 添加 Gitea本地协作开发服务器配置指南 - 完善检测模块架构分析文档 - 增加报告生成和Word文档处理工具指南 - 添加动态表格和结果服务测试用例 - 更新应用配置和VS Code开发环境设置 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -6,12 +6,12 @@ spring:
|
||||
datasource:
|
||||
druid:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://192.168.1.24:13306/pqs9100?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true
|
||||
# url: jdbc:mysql://192.168.1.24:13306/pqs9100?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true
|
||||
# username: root
|
||||
# password: njcnpqs
|
||||
url: jdbc:mysql://localhost:13306/pqs9100member?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
|
||||
|
||||
175
entrance/src/test/java/com/njcn/DynamicTableTest.java
Normal file
175
entrance/src/test/java/com/njcn/DynamicTableTest.java
Normal file
@@ -0,0 +1,175 @@
|
||||
package com.njcn;
|
||||
|
||||
import com.njcn.gather.tools.report.util.Docx4jUtil;
|
||||
import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
|
||||
import org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart;
|
||||
import org.docx4j.wml.ObjectFactory;
|
||||
import org.docx4j.wml.P;
|
||||
import org.docx4j.wml.Tbl;
|
||||
|
||||
import javax.xml.bind.JAXBElement;
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 动态表格生成测试
|
||||
*
|
||||
* @author hongawen
|
||||
* @version 1.0
|
||||
* @date 2025/9/21
|
||||
*/
|
||||
public class DynamicTableTest {
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
// 测试场景1:2个回路,7个检测项目(与result.png一致)
|
||||
testScenario1();
|
||||
|
||||
// 测试场景2:1个回路,只检测电压和频率
|
||||
testScenario2();
|
||||
|
||||
// 测试场景3:4个回路,多个检测项目
|
||||
testScenario3();
|
||||
|
||||
System.out.println("所有测试场景执行完成!");
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试场景1:2个回路,7个检测项目(模拟result.png的数据)
|
||||
*/
|
||||
public static void testScenario1() throws Exception {
|
||||
System.out.println("=== 测试场景1:2个回路,7个检测项目 ===");
|
||||
|
||||
// 创建Word文档
|
||||
WordprocessingMLPackage wordPackage = WordprocessingMLPackage.createPackage();
|
||||
MainDocumentPart mainDocumentPart = wordPackage.getMainDocumentPart();
|
||||
ObjectFactory factory = new ObjectFactory();
|
||||
|
||||
// 1. 添加标题
|
||||
P titleP = factory.createP();
|
||||
Docx4jUtil.createTitle(factory, titleP, "检测结果(场景1:2回路7项目)", 32, true);
|
||||
mainDocumentPart.getContent().add(titleP);
|
||||
|
||||
// 2. 检测项目配置
|
||||
List<String> testItems = Arrays.asList(
|
||||
"电压",
|
||||
"电压不平衡度",
|
||||
"电流不平衡度",
|
||||
"谐波电压",
|
||||
"谐波电流",
|
||||
"间谐波电压",
|
||||
"短时间闪变"
|
||||
);
|
||||
|
||||
// 3. 检测结果数据(模拟result.png中的数据)
|
||||
String[][] testResults = {
|
||||
{"不合格", "不合格"}, // 电压
|
||||
{"无法比较", "无法比较"}, // 电压不平衡度
|
||||
{"合格", "合格"}, // 电流不平衡度
|
||||
{"合格", "合格"}, // 谐波电压
|
||||
{"合格", "合格"}, // 谐波电流
|
||||
{"不合格", "不合格"}, // 间谐波电压
|
||||
{"无法比较", "无法比较"} // 短时间闪变
|
||||
};
|
||||
|
||||
// 4. 定义回路名称
|
||||
List<String> circuitNames = Arrays.asList("测量回路 1", "测量回路 2");
|
||||
|
||||
// 5. 生成动态表格(包含说明内容)
|
||||
JAXBElement<Tbl> table = Docx4jUtil.createDynamicTestResultTable(
|
||||
factory, testItems, circuitNames, testResults, "不合格",
|
||||
"部分值", "200", "去除最大最小值");
|
||||
mainDocumentPart.getContent().add(table);
|
||||
|
||||
// 6. 保存文档
|
||||
File outputFile = new File("检测结果_场景1_2回路7项目.docx");
|
||||
wordPackage.save(outputFile);
|
||||
System.out.println("文档已保存:" + outputFile.getAbsolutePath());
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试场景2:1个回路,只检测电压和频率
|
||||
*/
|
||||
public static void testScenario2() throws Exception {
|
||||
System.out.println("=== 测试场景2:1个回路,2个检测项目 ===");
|
||||
|
||||
WordprocessingMLPackage wordPackage = WordprocessingMLPackage.createPackage();
|
||||
MainDocumentPart mainDocumentPart = wordPackage.getMainDocumentPart();
|
||||
ObjectFactory factory = new ObjectFactory();
|
||||
|
||||
// 标题
|
||||
P titleP = factory.createP();
|
||||
Docx4jUtil.createTitle(factory, titleP, "检测结果(场景2:1回路2项目)", 32, true);
|
||||
mainDocumentPart.getContent().add(titleP);
|
||||
|
||||
// 简单的检测项目
|
||||
List<String> testItems = Arrays.asList("电压", "频率");
|
||||
|
||||
// 1个回路的检测结果
|
||||
String[][] testResults = {
|
||||
{"不合格"}, // 电压
|
||||
{"合格"} // 频率
|
||||
};
|
||||
|
||||
// 定义回路名称
|
||||
List<String> circuitNames = Arrays.asList("#1母线");
|
||||
|
||||
// 生成表格(包含说明内容)
|
||||
JAXBElement<Tbl> table = Docx4jUtil.createDynamicTestResultTable(
|
||||
factory, testItems, circuitNames, testResults, "不合格",
|
||||
"任意值", "100", "取第一个满足条件的数据");
|
||||
mainDocumentPart.getContent().add(table);
|
||||
|
||||
File outputFile = new File("检测结果_场景2_1回路2项目.docx");
|
||||
wordPackage.save(outputFile);
|
||||
System.out.println("文档已保存:" + outputFile.getAbsolutePath());
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试场景3:4个回路,多个检测项目
|
||||
*/
|
||||
public static void testScenario3() throws Exception {
|
||||
System.out.println("=== 测试场景3:4个回路,5个检测项目 ===");
|
||||
|
||||
WordprocessingMLPackage wordPackage = WordprocessingMLPackage.createPackage();
|
||||
MainDocumentPart mainDocumentPart = wordPackage.getMainDocumentPart();
|
||||
ObjectFactory factory = new ObjectFactory();
|
||||
|
||||
// 标题
|
||||
P titleP = factory.createP();
|
||||
Docx4jUtil.createTitle(factory, titleP, "检测结果(场景3:4回路5项目)", 32, true);
|
||||
mainDocumentPart.getContent().add(titleP);
|
||||
|
||||
// 检测项目
|
||||
List<String> testItems = Arrays.asList(
|
||||
"电压", "频率", "电压不平衡度", "谐波电压", "间谐波电压"
|
||||
);
|
||||
|
||||
// 4个回路的检测结果
|
||||
String[][] testResults = {
|
||||
{"不合格", "合格", "合格", "不合格"}, // 电压
|
||||
{"合格", "合格", "合格", "合格"}, // 频率
|
||||
{"无法比较", "无法比较", "合格", "合格"}, // 电压不平衡度
|
||||
{"合格", "不合格", "合格", "合格"}, // 谐波电压
|
||||
{"不合格", "不合格", "不合格", "合格"} // 间谐波电压
|
||||
};
|
||||
|
||||
// 定义回路名称(自定义名称示例)
|
||||
List<String> circuitNames = Arrays.asList("主变高压侧", "主变低压侧", "备用线路1", "备用线路2");
|
||||
|
||||
// 生成表格(包含说明内容)
|
||||
JAXBElement<Tbl> table = Docx4jUtil.createDynamicTestResultTable(
|
||||
factory, testItems, circuitNames, testResults, "不合格",
|
||||
"平均值", "300", "取算术平均值");
|
||||
mainDocumentPart.getContent().add(table);
|
||||
|
||||
File outputFile = new File("检测结果_场景3_4回路5项目.docx");
|
||||
wordPackage.save(outputFile);
|
||||
System.out.println("文档已保存:" + outputFile.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
75
entrance/src/test/java/com/njcn/ResultServiceImplTest.java
Normal file
75
entrance/src/test/java/com/njcn/ResultServiceImplTest.java
Normal file
@@ -0,0 +1,75 @@
|
||||
package com.njcn;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.njcn.gather.detection.pojo.vo.DetectionData;
|
||||
import com.njcn.gather.device.pojo.vo.PqDevVO;
|
||||
import com.njcn.gather.device.service.IPqDevService;
|
||||
import com.njcn.gather.device.service.impl.PqDevServiceImpl;
|
||||
import com.njcn.gather.report.pojo.DevReportParam;
|
||||
import com.njcn.gather.report.pojo.result.ContrastTestResult;
|
||||
import com.njcn.gather.report.service.IPqReportService;
|
||||
import com.njcn.gather.result.pojo.vo.MonitorResultVO;
|
||||
import com.njcn.gather.result.service.impl.ResultServiceImpl;
|
||||
import com.njcn.gather.storage.pojo.po.ContrastHarmonicResult;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictTree;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.ArgumentMatchers.*;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* ResultServiceImpl 测试类
|
||||
* 专门测试 getContrastResultHarm 方法
|
||||
*
|
||||
* @author test
|
||||
* @date 2025-01-18
|
||||
*/
|
||||
@Slf4j
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = com.njcn.gather.EntranceApplication.class)
|
||||
public class ResultServiceImplTest extends BaseJunitTest {
|
||||
|
||||
@Autowired
|
||||
private ResultServiceImpl resultService;
|
||||
|
||||
@Autowired
|
||||
private IPqDevService pqDevService;
|
||||
|
||||
@Autowired
|
||||
private IPqReportService pqReportService;
|
||||
|
||||
/**
|
||||
* 测试 getContrastResultHarm 方法 - 正常情况,所有数据合格
|
||||
*/
|
||||
@Test
|
||||
public void testGetContrastResultHarm_AllQualified() throws Exception {
|
||||
log.info("==================== 开始测试:所有数据合格场景 ====================");
|
||||
|
||||
// 准备测试数据
|
||||
DevReportParam devReportParam = new DevReportParam();
|
||||
devReportParam.setPlanId("307a4b57abe84746acec5fd62f58e789");
|
||||
devReportParam.setPlanCode("1");
|
||||
devReportParam.setDevId("11b1a3cadafd4d51986d5c88815c2ece");
|
||||
devReportParam.setDevIdList(Collections.singletonList(devReportParam.getDevId()));
|
||||
// PqDevVO pqDevVO = pqDevService.getPqDevById(devReportParam.getDevId());
|
||||
// Map<Integer, List<ContrastTestResult>> contrastResultHarm = resultService.getContrastResultForReport(devReportParam, pqDevVO);
|
||||
|
||||
|
||||
pqReportService.generateReport(devReportParam);
|
||||
System.out.println(1);
|
||||
System.out.println(1);
|
||||
System.out.println(1);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user