feat(icd): 实现标准ICD新增时自动设置自身为参照源功能

- 在添加标准ICD路径时自动填充referenceIcdId字段为自身ID
- 添加fillSelfReferenceForStandardIcd方法处理标准类型ICD的自参照逻辑
- 增加isStandardType方法判断ICD类型是否为标准类型
- 添加单元测试验证手动录入标准ICD和上游解析标准ICD的自参照功能
- 修改应用配置文件中的文件存储路径
- 新增ai-report模块及其子模块的Maven配置
- 移除数据校验服务中已废弃的单个监测点ID字段,统一使用监测点ID列表
- 更新相关实体类、参数类和返回类的数据结构定义
- 修正测试代码中的字段引用和字符编码问题
This commit is contained in:
2026-06-25 07:59:08 +08:00
parent 646b5f3283
commit 0ea686d3cb
44 changed files with 270 additions and 53 deletions

View File

@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.njcn.gather</groupId>
<artifactId>ai-report</artifactId>
<version>1.0.0</version>
</parent>
<artifactId>client-unit</artifactId>
<dependencies>
<dependency>
<groupId>com.njcn</groupId>
<artifactId>njcn-common</artifactId>
<version>0.0.1</version>
</dependency>
<dependency>
<groupId>com.njcn</groupId>
<artifactId>mybatis-plus</artifactId>
<version>0.0.1</version>
</dependency>
<dependency>
<groupId>com.njcn</groupId>
<artifactId>spingboot2.3.12</artifactId>
<version>2.3.12</version>
</dependency>
</dependencies>
</project>

25
ai-report/pom.xml Normal file
View File

@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.njcn.gather</groupId>
<artifactId>CN_Tool</artifactId>
<version>1.0.0</version>
</parent>
<artifactId>ai-report</artifactId>
<packaging>pom</packaging>
<name>ai-report</name>
<description>AI report capability aggregator.</description>
<modules>
<module>report-model</module>
<module>client-unit</module>
<module>test-device</module>
<module>test-report</module>
</modules>
</project>

View File

@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.njcn.gather</groupId>
<artifactId>ai-report</artifactId>
<version>1.0.0</version>
</parent>
<artifactId>report-model</artifactId>
<dependencies>
<dependency>
<groupId>com.njcn</groupId>
<artifactId>njcn-common</artifactId>
<version>0.0.1</version>
</dependency>
<dependency>
<groupId>com.njcn</groupId>
<artifactId>mybatis-plus</artifactId>
<version>0.0.1</version>
</dependency>
<dependency>
<groupId>com.njcn</groupId>
<artifactId>spingboot2.3.12</artifactId>
<version>2.3.12</version>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.njcn.gather</groupId>
<artifactId>ai-report</artifactId>
<version>1.0.0</version>
</parent>
<artifactId>test-device</artifactId>
<dependencies>
<dependency>
<groupId>com.njcn</groupId>
<artifactId>njcn-common</artifactId>
<version>0.0.1</version>
</dependency>
<dependency>
<groupId>com.njcn</groupId>
<artifactId>mybatis-plus</artifactId>
<version>0.0.1</version>
</dependency>
<dependency>
<groupId>com.njcn</groupId>
<artifactId>spingboot2.3.12</artifactId>
<version>2.3.12</version>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.njcn.gather</groupId>
<artifactId>ai-report</artifactId>
<version>1.0.0</version>
</parent>
<artifactId>test-report</artifactId>
<dependencies>
<dependency>
<groupId>com.njcn</groupId>
<artifactId>njcn-common</artifactId>
<version>0.0.1</version>
</dependency>
<dependency>
<groupId>com.njcn</groupId>
<artifactId>mybatis-plus</artifactId>
<version>0.0.1</version>
</dependency>
<dependency>
<groupId>com.njcn</groupId>
<artifactId>spingboot2.3.12</artifactId>
<version>2.3.12</version>
</dependency>
</dependencies>
</project>

View File

@@ -64,7 +64,7 @@ log:
parse-pqdif:
storage:
path: D:\pqdif-files
path: D:\file\pqdif-files
activate:
private-key: "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCcUyYhVqczGxblL+o/xZzF/8nf+LjrfUE/dS1aRHM7uMDD0cgCArhjtfneFePrMxt+Z7W8yNBzSarub8qsfhaVNikV7Es7oaeTygfjQXTi2n4AFkir3fM07J08RpWhl5M8f8uWTCuvFUYAw00gq55typqmnbkmJa2VIUy/iQf+cMCP7abz4/jNhUzUR3qA7TV4oMRgTdIEDUp63YF8dOC+JH8XxYrCVeHXV6fLCwmesdMzl0lB2VTEKMfLbXhOmF5g7P9y/16VCcN8UBuZlbyYfn+GAxJOSbeHi5HshOKfoSuD7Jz+3WQZpNavOWjIFExKIU38/CvnJCOP7XBCqpSTAgMBAAECggEAYeWokWRE3TpvwiOZnUpR/aVMdVi75a3ROL5XIpqPV61B+t/bU3cEpl0GF9C5pUeiRi0IoStZb3mI9D1KPW/REKyUWkhabQO1gFYbTnRlkNOn6MILzKX4cwJjDaZeeo4EBPU7N+qHyOOXrU6hdH5FfxhMdV983ajm5eeuupxER1C2kAcIklTeVpTX6EKOgZb5LBp5ssOVm2P42pOauvcRozRcvZmqnErXmukv0H4l3EVNt4rHpTn9riHUC63e8JfiYzVaF6zuNUxv6nHEft0/SRMw11XSTnNfDzcKqgjz6ksFBS/6eQQYKESk+ONC53HUuYHFAknkwsPupDCT2W8FIQKBgQDLHT/xCU3nxGr4vFKBDNaO2D5oK20ECbBO4oDvLWWmQG7f+6TsMy8PgVdMnoL4RfqGlwFAKEpS6KVFHnBVqnNEhcdy9uCI7x7Xx8UnyUtxj1EDTm76uta9Ki9OrlqB6tImDM9+Ya3vGktW37ht4WOx2OsJRhG1dbf6RLwFlH7DWwKBgQDFBxvi5I1BR6hg6Tj7xd2SqOT2Y+BED3xuSYENhWbmMhLJDResaB7mjztbxlYaY2mOE0holWm2uDmVFFhMh4jYXik4hYH8nmDzq9mDpZCZ9pyjYqnAP8THoAa8EbgrUWB8A6BPH4iL3KbMnBfBKY0pIr2xrvnjQjNBAgta7KDRKQKBgCe6oe4wxrdF2TKsC2tIqpMoQxS3Icy/ZGgZr+SYuaBKTCWtoDW/UT40K3JGMxIDBhzbXphBCUCsVt9tM8Xd4EwP6tJW7dZ7B0pnve2pVwNwaAVAiz6p2yUHIle+jN+Koe5lZRSwYIg7WW81tWpwwsJfzqFyvjYDP6hJV4mz4ROvAoGAaRcdnKvjXApomShMqJ4lTPChD3q+SA8qg3jZSOj6tZXHx00gb2kp8jg7pPvpOTIFPy6x1Ha9aCRjMk0ju84fA6lVuzwa1S907wOehUVuF3Eeo1cgy9Y3k3KbpPyeixxgpkUY4JslLdSHc2NemD0dee951qhJyRmqVOZOQDUuoeECgYEAqBw2cAFk3vM97WY06TSldGA8ajVHx3BYRjj+zl62NTQthy8fw3tqxb3c5e8toOmZWKjZvDhg2TRLhsDDQWEYg3LZG87REqVIjgEPcpjNLidjygGX8n3JF2o0O5I/EMvl0s/+LVQONfduOBvhwDqr8QNisbLsyneiAq7umewMolo="

View File

@@ -19,6 +19,7 @@
<module>tools</module>
<module>event</module>
<module>steady</module>
<module>ai-report</module>
</modules>
<distributionManagement>

View File

@@ -16,9 +16,6 @@ public class SteadyChecksquareQueryParam implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("监测点 ID")
private String lineId;
@ApiModelProperty("监测点 ID 列表")
private List<String> lineIds;

View File

@@ -23,9 +23,6 @@ public class SteadyChecksquareQueryVO implements Serializable {
@ApiModelProperty("任务编号")
private String taskNo;
@ApiModelProperty("监测点 ID")
private String lineId;
@ApiModelProperty("监测点 ID 列表")
private List<String> lineIds = new ArrayList<String>();

View File

@@ -23,9 +23,6 @@ public class SteadyChecksquareTaskVO implements Serializable {
@ApiModelProperty("任务编号")
private String taskNo;
@ApiModelProperty("监测点 ID")
private String lineId;
@ApiModelProperty("监测点 ID 列表")
private List<String> lineIds;

View File

@@ -195,7 +195,6 @@ public class SteadyChecksquareServiceImpl implements SteadyChecksquareService {
SteadyChecksquareQueryVO result = new SteadyChecksquareQueryVO();
result.setTaskId(task.getId());
result.setTaskNo(task.getTaskNo());
result.setLineId(task.getLineId());
result.setLineIds(readTaskLineIds(task));
result.setLineName(task.getLineName());
result.setTimeStart(formatTime(task.getTimeStart()));
@@ -328,7 +327,6 @@ public class SteadyChecksquareServiceImpl implements SteadyChecksquareService {
indicatorCodes = parseTextListSearchValue(task.getIndicatorCodesText());
}
SteadyChecksquareQueryParam param = new SteadyChecksquareQueryParam();
param.setLineId(lineIds.isEmpty() ? task.getLineId() : lineIds.get(0));
param.setLineIds(lineIds);
param.setIndicatorCodes(indicatorCodes);
param.setTimeStart(formatTime(task.getTimeStart()));
@@ -392,7 +390,6 @@ public class SteadyChecksquareServiceImpl implements SteadyChecksquareService {
Map<String, AddLedgerLinePathVO> linePathMap = requireLinePaths(lineIds);
int intervalMinutes = resolveIntervalMinutes(linePathMap.get(lineIds.get(0)));
SteadyChecksquareQueryVO result = new SteadyChecksquareQueryVO();
result.setLineId(lineIds.get(0));
result.setLineIds(new ArrayList<String>(lineIds));
result.setLineName(buildLineNames(lineIds, linePathMap));
result.setTimeStart(param.getTimeStart());
@@ -506,9 +503,9 @@ public class SteadyChecksquareServiceImpl implements SteadyChecksquareService {
if (trimToNull(taskId) == null) {
task.setTaskNo(SteadyChecksquareIdUtil.taskNo());
}
task.setLineId(result.getLineId());
task.setLineName(result.getLineName());
List<String> lineIds = resolveResultLineIds(result);
task.setLineId(lineIds.isEmpty() ? null : lineIds.get(0));
task.setLineName(result.getLineName());
task.setLineIdsJson(writeJson(lineIds));
task.setLineIdsText(buildTextListSearchValue(lineIds));
task.setTimeStart(parseRequiredTime(result.getTimeStart(), "开始时间不能为空"));
@@ -1202,7 +1199,6 @@ public class SteadyChecksquareServiceImpl implements SteadyChecksquareService {
SteadyChecksquareTaskVO vo = new SteadyChecksquareTaskVO();
vo.setTaskId(task.getId());
vo.setTaskNo(task.getTaskNo());
vo.setLineId(task.getLineId());
vo.setLineIds(readTaskLineIds(task));
vo.setLineName(task.getLineName());
vo.setTimeStart(formatTime(task.getTimeStart()));
@@ -1431,11 +1427,7 @@ public class SteadyChecksquareServiceImpl implements SteadyChecksquareService {
}
private List<String> resolveLineIds(SteadyChecksquareQueryParam param) {
List<String> lineIds = normalizeTextList(param == null ? null : param.getLineIds());
if (lineIds.isEmpty() && param != null && trimToNull(param.getLineId()) != null) {
lineIds.add(trimToNull(param.getLineId()));
}
return lineIds;
return normalizeTextList(param == null ? null : param.getLineIds());
}
private List<String> resolveIndicatorCodes(SteadyChecksquareQueryParam param) {
@@ -1451,11 +1443,7 @@ public class SteadyChecksquareServiceImpl implements SteadyChecksquareService {
}
private List<String> resolveResultLineIds(SteadyChecksquareQueryVO result) {
List<String> lineIds = normalizeTextList(result == null ? null : result.getLineIds());
if (lineIds.isEmpty() && result != null && trimToNull(result.getLineId()) != null) {
lineIds.add(trimToNull(result.getLineId()));
}
return lineIds;
return normalizeTextList(result == null ? null : result.getLineIds());
}
private List<String> readTaskLineIds(SteadyChecksquareTaskPO task) {
@@ -1469,7 +1457,6 @@ public class SteadyChecksquareServiceImpl implements SteadyChecksquareService {
private SteadyChecksquareQueryParam copyCreateParam(SteadyChecksquareQueryParam param, List<String> indicatorCodes) {
SteadyChecksquareQueryParam result = new SteadyChecksquareQueryParam();
List<String> lineIds = resolveLineIds(param);
result.setLineId(lineIds.isEmpty() ? null : lineIds.get(0));
result.setLineIds(new ArrayList<String>(lineIds));
result.setIndicatorCodes(new ArrayList<String>(indicatorCodes));
result.setTimeStart(param.getTimeStart());

View File

@@ -56,5 +56,7 @@ class SteadyChecksquareControllerTest {
resultType.getActualTypeArguments()[0]);
Assertions.assertThrows(NoSuchFieldException.class,
() -> com.njcn.gather.steady.checksquare.pojo.vo.SteadyChecksquareTaskVO.class.getDeclaredField("items"));
Assertions.assertThrows(NoSuchFieldException.class,
() -> com.njcn.gather.steady.checksquare.pojo.vo.SteadyChecksquareTaskVO.class.getDeclaredField("lineId"));
}
}

View File

@@ -12,7 +12,8 @@ class SteadyChecksquareQueryParamTest {
@Test
void shouldOnlyExposeChecksquareQueryFields() {
Assertions.assertNotNull(field("lineId"));
Assertions.assertNull(field("lineId"));
Assertions.assertNotNull(field("lineIds"));
Assertions.assertNotNull(field("indicatorCodes"));
Assertions.assertNotNull(field("timeStart"));
Assertions.assertNotNull(field("timeEnd"));

View File

@@ -61,7 +61,7 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
/**
* 鏁版嵁鏍¢獙鏈嶅姟娴嬭瘯? */
* 鏁版嵁鏍¢獙鏈嶅姟娴嬭瘯<EFBFBD>? */
class SteadyChecksquareServiceImplTest {
@BeforeAll
@@ -102,7 +102,7 @@ class SteadyChecksquareServiceImplTest {
when(addLedgerService.listLinePathByLineIds(eq(Collections.singletonList("line-001"))))
.thenReturn(Collections.singletonMap("line-001", linePath));
SteadyChecksquareQueryParam param = new SteadyChecksquareQueryParam();
param.setLineId("line-001");
param.setLineIds(Collections.singletonList("line-001"));
param.setIndicatorCodes(Collections.singletonList("V_RMS"));
param.setTimeStart("2026-05-01 00:00:00");
param.setTimeEnd("2026-05-08 00:01:00");
@@ -147,7 +147,7 @@ class SteadyChecksquareServiceImplTest {
ArgumentCaptor<SteadyChecksquareTaskPO> taskCaptor = ArgumentCaptor.forClass(SteadyChecksquareTaskPO.class);
when(taskService.save(taskCaptor.capture())).thenReturn(true);
SteadyChecksquareQueryParam param = new SteadyChecksquareQueryParam();
param.setLineId("line-001");
param.setLineIds(Collections.singletonList("line-001"));
param.setIndicatorCodes(Arrays.asList("V_RMS", "V_LINE_RMS", "FREQ", "I_RMS", "I_THD"));
param.setTimeStart("2026-05-01 00:00:00");
param.setTimeEnd("2026-05-03 23:59:00");
@@ -190,7 +190,7 @@ class SteadyChecksquareServiceImplTest {
mock(SteadyChecksquareItemService.class), mock(SteadyChecksquareStatSummaryService.class),
mock(SteadyChecksquareDetailService.class), new ObjectMapper());
SteadyChecksquareQueryParam param = new SteadyChecksquareQueryParam();
param.setLineId("line-001");
param.setLineIds(Collections.singletonList("line-001"));
param.setIndicatorCodes(Collections.singletonList("I_RMS"));
param.setTimeStart("2026-05-01 00:00:00");
param.setTimeEnd("2026-05-01 00:01:00");
@@ -238,7 +238,7 @@ class SteadyChecksquareServiceImplTest {
ArgumentCaptor<SteadyChecksquareTaskPO> taskCaptor = ArgumentCaptor.forClass(SteadyChecksquareTaskPO.class);
when(taskService.save(taskCaptor.capture())).thenReturn(true);
SteadyChecksquareQueryParam param = new SteadyChecksquareQueryParam();
param.setLineId("line-001");
param.setLineIds(Collections.singletonList("line-001"));
param.setIndicatorCodes(Collections.singletonList("V_RMS"));
param.setTimeStart("2026-05-01 00:00:00");
param.setTimeEnd("2026-05-01 00:01:00");
@@ -326,7 +326,7 @@ class SteadyChecksquareServiceImplTest {
.thenReturn(emptyHarmonicParityRuleResult());
AddLedgerLinePathVO linePath = new AddLedgerLinePathVO();
linePath.setLineId("line-001");
linePath.setLineName("杩涚嚎涓");
linePath.setLineName("杩涚嚎涓<EFBFBD>?);
linePath.setLineInterval(1);
when(addLedgerService.listLinePathByLineIds(eq(Collections.singletonList("line-001"))))
.thenReturn(Collections.singletonMap("line-001", linePath));
@@ -339,7 +339,7 @@ class SteadyChecksquareServiceImplTest {
LocalDateTime.of(2026, 5, 1, 0, 0))));
SteadyChecksquareQueryParam param = new SteadyChecksquareQueryParam();
param.setLineId("line-001");
param.setLineIds(Collections.singletonList("line-001"));
param.setIndicatorCodes(Arrays.asList("FLUC", "PST", "PLT"));
param.setTimeStart("2026-05-01 00:00:00");
param.setTimeEnd("2026-05-01 02:00:00");
@@ -379,7 +379,7 @@ class SteadyChecksquareServiceImplTest {
.thenReturn(new HashSet<LocalDateTime>());
SteadyChecksquareQueryParam param = new SteadyChecksquareQueryParam();
param.setLineId("line-001");
param.setLineIds(Collections.singletonList("line-001"));
param.setIndicatorCodes(Collections.<String>emptyList());
param.setTimeStart("2026-05-01 00:00:00");
param.setTimeEnd("2026-05-01 00:01:00");
@@ -414,7 +414,7 @@ class SteadyChecksquareServiceImplTest {
.thenReturn(emptyHarmonicParityRuleResult());
AddLedgerLinePathVO linePath = new AddLedgerLinePathVO();
linePath.setLineId("line-001");
linePath.setLineName("杩涚嚎涓");
linePath.setLineName("杩涚嚎涓<EFBFBD>?);
linePath.setLineInterval(1);
when(addLedgerService.listLinePathByLineIds(eq(Collections.singletonList("line-001"))))
.thenReturn(Collections.singletonMap("line-001", linePath));
@@ -423,7 +423,7 @@ class SteadyChecksquareServiceImplTest {
LocalDateTime.of(2026, 5, 1, 0, 0))));
SteadyChecksquareQueryParam param = new SteadyChecksquareQueryParam();
param.setLineId("line-001");
param.setLineIds(Collections.singletonList("line-001"));
param.setIndicatorCodes(Collections.singletonList("V_HARMONIC"));
param.setTimeStart("2026-05-01 00:00:00");
param.setTimeEnd("2026-05-01 00:01:00");
@@ -453,7 +453,7 @@ class SteadyChecksquareServiceImplTest {
.thenReturn(emptyHarmonicParityRuleResult());
AddLedgerLinePathVO linePath = new AddLedgerLinePathVO();
linePath.setLineId("line-001");
linePath.setLineName("杩涚嚎涓");
linePath.setLineName("杩涚嚎涓<EFBFBD>?);
linePath.setLineInterval(1);
when(addLedgerService.listLinePathByLineIds(eq(Collections.singletonList("line-001"))))
.thenReturn(Collections.singletonMap("line-001", linePath));
@@ -477,7 +477,7 @@ class SteadyChecksquareServiceImplTest {
.thenReturn(normalRuleResult);
SteadyChecksquareQueryParam param = new SteadyChecksquareQueryParam();
param.setLineId("line-001");
param.setLineIds(Collections.singletonList("line-001"));
param.setIndicatorCodes(Collections.singletonList("V_HARMONIC"));
param.setTimeStart("2026-05-01 00:00:00");
param.setTimeEnd("2026-05-01 00:01:00");
@@ -507,7 +507,7 @@ class SteadyChecksquareServiceImplTest {
mock(SteadyChecksquareDetailService.class), new ObjectMapper());
AddLedgerLinePathVO linePath = new AddLedgerLinePathVO();
linePath.setLineId("line-001");
linePath.setLineName("杩涚嚎涓");
linePath.setLineName("杩涚嚎涓<EFBFBD>?);
linePath.setLineInterval(1);
when(addLedgerService.listLinePathByLineIds(eq(Collections.singletonList("line-001"))))
.thenReturn(Collections.singletonMap("line-001", linePath));
@@ -525,7 +525,7 @@ class SteadyChecksquareServiceImplTest {
.thenReturn(ruleResult);
SteadyChecksquareQueryParam param = new SteadyChecksquareQueryParam();
param.setLineId("line-001");
param.setLineIds(Collections.singletonList("line-001"));
param.setIndicatorCodes(Collections.singletonList("V_RMS"));
param.setTimeStart("2026-05-01 00:00:00");
param.setTimeEnd("2026-05-01 00:01:00");
@@ -556,7 +556,7 @@ class SteadyChecksquareServiceImplTest {
.thenReturn(emptyHarmonicParityRuleResult());
AddLedgerLinePathVO linePath = new AddLedgerLinePathVO();
linePath.setLineId("line-001");
linePath.setLineName("杩涚嚎涓");
linePath.setLineName("杩涚嚎涓<EFBFBD>?);
linePath.setLineInterval(1);
when(addLedgerService.listLinePathByLineIds(eq(Collections.singletonList("line-001"))))
.thenReturn(Collections.singletonMap("line-001", linePath));
@@ -565,7 +565,7 @@ class SteadyChecksquareServiceImplTest {
LocalDateTime.of(2026, 5, 1, 0, 0))));
SteadyChecksquareQueryParam param = new SteadyChecksquareQueryParam();
param.setLineId("line-001");
param.setLineIds(Collections.singletonList("line-001"));
param.setIndicatorCodes(Arrays.asList("V_RMS", "V_LINE_RMS"));
param.setTimeStart("2026-05-01 00:00:00");
param.setTimeEnd("2026-05-01 00:01:00");
@@ -603,7 +603,7 @@ class SteadyChecksquareServiceImplTest {
.thenReturn(emptyRuleResult());
AddLedgerLinePathVO linePath = new AddLedgerLinePathVO();
linePath.setLineId("line-001");
linePath.setLineName("杩涚嚎涓");
linePath.setLineName("杩涚嚎涓<EFBFBD>?);
linePath.setLineInterval(1);
when(addLedgerService.listLinePathByLineIds(eq(Collections.singletonList("line-001"))))
.thenReturn(Collections.singletonMap("line-001", linePath));
@@ -623,7 +623,7 @@ class SteadyChecksquareServiceImplTest {
.thenReturn(ruleResult);
SteadyChecksquareQueryParam param = new SteadyChecksquareQueryParam();
param.setLineId("line-001");
param.setLineIds(Collections.singletonList("line-001"));
param.setIndicatorCodes(Collections.singletonList("V_HARMONIC"));
param.setTimeStart("2026-05-01 00:00:00");
param.setTimeEnd("2026-05-01 00:01:00");
@@ -665,7 +665,7 @@ class SteadyChecksquareServiceImplTest {
task.setId("task-001");
task.setState(1);
task.setLineId("line-001");
task.setLineName("杩涚嚎涓");
task.setLineName("杩涚嚎涓<EFBFBD>?);
task.setTimeStart(LocalDateTime.of(2026, 5, 1, 0, 0));
task.setTimeEnd(LocalDateTime.of(2026, 5, 1, 0, 1));
task.setIntervalMinutes(1);
@@ -850,8 +850,8 @@ class SteadyChecksquareServiceImplTest {
SteadyChecksquareQueryParam param = new SteadyChecksquareQueryParam();
param.setIndicatorCodes(Collections.singletonList("V_RMS"));
SteadyChecksquareQueryVO result = new SteadyChecksquareQueryVO();
result.setLineId("line-001");
result.setLineName("杩涚嚎涓");
result.setLineIds(Collections.singletonList("line-001"));
result.setLineName("杩涚嚎涓<EFBFBD>?);
result.setTimeStart("2026-05-01 00:00:00");
result.setTimeEnd("2026-05-01 00:01:00");
result.setIntervalMinutes(1);
@@ -860,7 +860,7 @@ class SteadyChecksquareServiceImplTest {
item.setLineId("line-001");
item.setLineName("line-001-name");
item.setIndicatorCode("V_RMS");
item.setIndicatorName("鐩哥數鍘嬫湁鏁堝?");
item.setIndicatorName("鐩哥數鍘嬫湁鏁堝<EFBFBD>?");
item.setIntervalMinutes(1);
item.setHasData(true);
item.setExpectedPointCount(2);
@@ -909,7 +909,7 @@ class SteadyChecksquareServiceImplTest {
SteadyChecksquareQueryParam param = new SteadyChecksquareQueryParam();
param.setIndicatorCodes(Collections.singletonList("V_RMS"));
SteadyChecksquareQueryVO result = new SteadyChecksquareQueryVO();
result.setLineId("line-001");
result.setLineIds(Collections.singletonList("line-001"));
result.setLineName("line-001");
result.setTimeStart("2026-05-01 00:00:00");
result.setTimeEnd("2026-05-01 00:01:00");
@@ -942,8 +942,8 @@ class SteadyChecksquareServiceImplTest {
SteadyChecksquareQueryParam param = new SteadyChecksquareQueryParam();
param.setIndicatorCodes(Collections.singletonList("V_RMS"));
SteadyChecksquareQueryVO result = new SteadyChecksquareQueryVO();
result.setLineId("line-001");
result.setLineName("杩涚嚎涓");
result.setLineIds(Collections.singletonList("line-001"));
result.setLineName("杩涚嚎涓<EFBFBD>?);
result.setTimeStart("2026-05-01 00:00:00");
result.setTimeEnd("2026-05-01 00:01:00");
result.setIntervalMinutes(1);

View File

@@ -86,6 +86,7 @@ public class CsIcdPathServiceImpl implements CsIcdPathService {
LocalDateTime now = LocalDateTime.now();
CsIcdPathPO icdPath = buildIcdPath(checkedParam, true);
icdPath.setId(UUID.randomUUID().toString().replace("-", ""));
fillSelfReferenceForStandardIcd(icdPath);
icdPath.setState(STATE_NORMAL);
icdPath.setCreateBy(currentUserId());
icdPath.setCreateTime(now);
@@ -200,6 +201,21 @@ public class CsIcdPathServiceImpl implements CsIcdPathService {
return type == null ? ICD_TYPE_MANUAL_NON_STANDARD : type;
}
/**
* 标准 ICD 新增时如果未传参照 ICD则默认以自身作为参照来源。
*/
private void fillSelfReferenceForStandardIcd(CsIcdPathPO icdPath) {
if (icdPath == null || !isStandardType(icdPath.getType()) || !isBlank(icdPath.getReferenceIcdId())) {
return;
}
icdPath.setReferenceIcdId(icdPath.getId());
}
private boolean isStandardType(Integer type) {
return Integer.valueOf(ICD_TYPE_MANUAL_STANDARD).equals(type)
|| Integer.valueOf(ICD_TYPE_UPSTREAM_STANDARD).equals(type);
}
/**
* 激活标准 ICD 时保留记录来源:手动录入升为 1上游解析传递升为 3。
*/

View File

@@ -128,6 +128,36 @@ class CsIcdPathServiceImplTest {
Assertions.assertEquals(2, captor.getValue().getType());
}
@Test
void addManualStandardIcdPathShouldDefaultReferenceIcdIdToSelf() {
CsIcdPathParam param = buildParam("标准ICD");
param.setType(1);
param.setReferenceIcdId(null);
when(csIcdPathMapper.insert(any(CsIcdPathPO.class))).thenReturn(1);
boolean result = service.addIcdPath(param);
ArgumentCaptor<CsIcdPathPO> captor = ArgumentCaptor.forClass(CsIcdPathPO.class);
verify(csIcdPathMapper).insert(captor.capture());
Assertions.assertTrue(result);
Assertions.assertEquals(captor.getValue().getId(), captor.getValue().getReferenceIcdId());
}
@Test
void addUpstreamStandardIcdPathShouldDefaultReferenceIcdIdToSelf() {
CsIcdPathParam param = buildParam("上游标准ICD");
param.setType(3);
param.setReferenceIcdId(" ");
when(csIcdPathMapper.insert(any(CsIcdPathPO.class))).thenReturn(1);
boolean result = service.addIcdPath(param);
ArgumentCaptor<CsIcdPathPO> captor = ArgumentCaptor.forClass(CsIcdPathPO.class);
verify(csIcdPathMapper).insert(captor.capture());
Assertions.assertTrue(result);
Assertions.assertEquals(captor.getValue().getId(), captor.getValue().getReferenceIcdId());
}
@Test
void updateIcdPathShouldRejectDeletedRecord() {
CsIcdPathParam.UpdateParam param = new CsIcdPathParam.UpdateParam();