feat(icd): 实现标准ICD新增时自动设置自身为参照源功能
- 在添加标准ICD路径时自动填充referenceIcdId字段为自身ID - 添加fillSelfReferenceForStandardIcd方法处理标准类型ICD的自参照逻辑 - 增加isStandardType方法判断ICD类型是否为标准类型 - 添加单元测试验证手动录入标准ICD和上游解析标准ICD的自参照功能 - 修改应用配置文件中的文件存储路径 - 新增ai-report模块及其子模块的Maven配置 - 移除数据校验服务中已废弃的单个监测点ID字段,统一使用监测点ID列表 - 更新相关实体类、参数类和返回类的数据结构定义 - 修正测试代码中的字段引用和字符编码问题
This commit is contained in:
@@ -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。
|
||||
*/
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user