|
@@ -134,11 +134,31 @@ public class ReportCollectService {
|
|
|
public static final String METHOD_LANGGRAPH_DETECT = "langgraph_detect";
|
|
public static final String METHOD_LANGGRAPH_DETECT = "langgraph_detect";
|
|
|
public static final String METHOD_OPENCODE = "opencode";
|
|
public static final String METHOD_OPENCODE = "opencode";
|
|
|
|
|
|
|
|
- /** 状态常量:与草稿 parse_status 对齐 */
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 状态常量:与草稿 parse_status 对齐
|
|
|
|
|
+ */
|
|
|
public static final String STATUS_COLLECTING = "collecting";
|
|
public static final String STATUS_COLLECTING = "collecting";
|
|
|
public static final String STATUS_COMPLETED = "completed";
|
|
public static final String STATUS_COMPLETED = "completed";
|
|
|
public static final String STATUS_FAILED = "failed";
|
|
public static final String STATUS_FAILED = "failed";
|
|
|
|
|
|
|
|
|
|
+ // ========================================================================
|
|
|
|
|
+ // P0-3 ③ _解析自检 透传合并 —— guhe_v2 新版报告解析结果自检块四子键锚点
|
|
|
|
|
+ // 采集回填层将解析结果中的 _解析自检 信息透传并入 health_report_drafts.collect_validation JSON。
|
|
|
|
|
+ // ========================================================================
|
|
|
|
|
+
|
|
|
|
|
+ /** guhe_v2 解析结果自检块键名(透传并入 collect_validation,见 P0-3 ③) */
|
|
|
|
|
+ public static final String PARSE_SELF_CHECK_KEY = "_解析自检";
|
|
|
|
|
+
|
|
|
|
|
+ /** guhe_v2 解析自检四子键 —— 通过 / P0告警数 / P1提示数 / 告警;用于校验和暴露到 collect/status */
|
|
|
|
|
+ public static final String SELF_CHECK_PASS = "通过";
|
|
|
|
|
+ public static final String SELF_CHECK_P0_ALERTS = "P0告警数";
|
|
|
|
|
+ public static final String SELF_CHECK_P1_HINTS = "P1提示数";
|
|
|
|
|
+ public static final String SELF_CHECK_ALERTS = "告警";
|
|
|
|
|
+
|
|
|
|
|
+ /** _解析自检 四子键常量集合(用于过滤/透传) */
|
|
|
|
|
+ public static final List<String> SELF_CHECK_KEYS = Collections.unmodifiableList(Arrays.asList(
|
|
|
|
|
+ SELF_CHECK_PASS, SELF_CHECK_P0_ALERTS, SELF_CHECK_P1_HINTS, SELF_CHECK_ALERTS));
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 提交异步采集任务。上传完成后调用,立即返回。
|
|
* 提交异步采集任务。上传完成后调用,立即返回。
|
|
|
*/
|
|
*/
|
|
@@ -214,6 +234,8 @@ public class ReportCollectService {
|
|
|
|
|
|
|
|
ParsedReportPayload.Payload payload;
|
|
ParsedReportPayload.Payload payload;
|
|
|
String method;
|
|
String method;
|
|
|
|
|
+ // guhe_v2 解析自检块(P0-3 ③):known-type 分支随 outcome 透出,并入 collect_validation
|
|
|
|
|
+ Map<String, Object> parseSelfCheck = null;
|
|
|
if (!"unknown".equals(typeId) && fp.get("parserPath") != null) {
|
|
if (!"unknown".equals(typeId) && fp.get("parserPath") != null) {
|
|
|
// 指纹成功:脚本已迁移到 LangGraph(/report/parse,算法 + LLM 兜底)
|
|
// 指纹成功:脚本已迁移到 LangGraph(/report/parse,算法 + LLM 兜底)
|
|
|
// 已知类型解析失败不再回退 opencode,改为登记退避重试(parse_error 记录失败原因),
|
|
// 已知类型解析失败不再回退 opencode,改为登记退避重试(parse_error 记录失败原因),
|
|
@@ -222,6 +244,7 @@ public class ReportCollectService {
|
|
|
LangGraphReportParseService.ParseOutcome outcome =
|
|
LangGraphReportParseService.ParseOutcome outcome =
|
|
|
langGraphReportParseService.parseByScriptWithReason(pdfPath, expectedIndicators);
|
|
langGraphReportParseService.parseByScriptWithReason(pdfPath, expectedIndicators);
|
|
|
payload = outcome != null ? outcome.getPayload() : null;
|
|
payload = outcome != null ? outcome.getPayload() : null;
|
|
|
|
|
+ parseSelfCheck = outcome != null ? outcome.getSelfCheck() : null;
|
|
|
if (payload == null) {
|
|
if (payload == null) {
|
|
|
String reason = outcome != null && outcome.getError() != null
|
|
String reason = outcome != null && outcome.getError() != null
|
|
|
? outcome.getError() : "解析结果为空或无效";
|
|
? outcome.getError() : "解析结果为空或无效";
|
|
@@ -259,7 +282,7 @@ public class ReportCollectService {
|
|
|
// 加固①:校验不通过(pass=false)阻止自动入库,标记失败由管理端人工处理
|
|
// 加固①:校验不通过(pass=false)阻止自动入库,标记失败由管理端人工处理
|
|
|
boolean validationPass;
|
|
boolean validationPass;
|
|
|
try {
|
|
try {
|
|
|
- validationPass = runCollectValidation(draftId, validationTypeId, payload);
|
|
|
|
|
|
|
+ validationPass = runCollectValidation(draftId, validationTypeId, payload, parseSelfCheck);
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
log.warn("采集指标校验失败 draftId={}, typeId={}", draftId, validationTypeId, e);
|
|
log.warn("采集指标校验失败 draftId={}, typeId={}", draftId, validationTypeId, e);
|
|
|
validationPass = true;
|
|
validationPass = true;
|
|
@@ -1158,7 +1181,16 @@ public class ReportCollectService {
|
|
|
* 健康(GUT/混检)管道校验入口:汇总 payload 中全部可采集指标名称后按定义比对
|
|
* 健康(GUT/混检)管道校验入口:汇总 payload 中全部可采集指标名称后按定义比对
|
|
|
*/
|
|
*/
|
|
|
private boolean runCollectValidation(Long draftId, String typeId, ParsedReportPayload.Payload payload) {
|
|
private boolean runCollectValidation(Long draftId, String typeId, ParsedReportPayload.Payload payload) {
|
|
|
- return runCollectValidation(draftId, typeId, collectHealthNames(payload));
|
|
|
|
|
|
|
+ return runCollectValidation(draftId, typeId, collectHealthNames(payload), null);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 健康管道校验入口(携带 guhe_v2 解析自检块):_解析自检 四子键随 collects 结果
|
|
|
|
|
+ * 透传并入 collect_validation JSON(P0-3 ③)。
|
|
|
|
|
+ */
|
|
|
|
|
+ private boolean runCollectValidation(Long draftId, String typeId, ParsedReportPayload.Payload payload,
|
|
|
|
|
+ Map<String, Object> parseSelfCheck) {
|
|
|
|
|
+ return runCollectValidation(draftId, typeId, collectHealthNames(payload), parseSelfCheck);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -1172,15 +1204,21 @@ public class ReportCollectService {
|
|
|
addCollectName(names, item.getCode());
|
|
addCollectName(names, item.getCode());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- return runCollectValidation(draftId, typeId, names);
|
|
|
|
|
|
|
+ return runCollectValidation(draftId, typeId, names, null);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 采集完整性校验:按 report_type_registry.expected_indicators 定义,校验本次采集结果是否覆盖应采集指标项。
|
|
* 采集完整性校验:按 report_type_registry.expected_indicators 定义,校验本次采集结果是否覆盖应采集指标项。
|
|
|
* 该类型无指标项定义(expected_indicators 为空 / 类型未注册)时跳过,不影响采集主流程。
|
|
* 该类型无指标项定义(expected_indicators 为空 / 类型未注册)时跳过,不影响采集主流程。
|
|
|
* 结果 JSON(typeId/expected/matched/pass/missing)写入草稿 collect_validation,缺失项记入 WARN 日志。
|
|
* 结果 JSON(typeId/expected/matched/pass/missing)写入草稿 collect_validation,缺失项记入 WARN 日志。
|
|
|
|
|
+ * guhe_v2 解析自检块存在时,额外以 {@code _解析自检} 子对象并入同一 JSON(P0-3 ③)。
|
|
|
*/
|
|
*/
|
|
|
private boolean runCollectValidation(Long draftId, String typeId, Set<String> collectedNames) {
|
|
private boolean runCollectValidation(Long draftId, String typeId, Set<String> collectedNames) {
|
|
|
|
|
+ return runCollectValidation(draftId, typeId, collectedNames, null);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private boolean runCollectValidation(Long draftId, String typeId, Set<String> collectedNames,
|
|
|
|
|
+ Map<String, Object> parseSelfCheck) {
|
|
|
if (draftId == null || typeId == null || collectedNames == null || collectedNames.isEmpty()) {
|
|
if (draftId == null || typeId == null || collectedNames == null || collectedNames.isEmpty()) {
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
@@ -1208,6 +1246,7 @@ public class ReportCollectService {
|
|
|
result.put("matched", matched);
|
|
result.put("matched", matched);
|
|
|
result.put("pass", missing.isEmpty());
|
|
result.put("pass", missing.isEmpty());
|
|
|
result.put("missing", missing.size() > 20 ? missing.subList(0, 20) : missing);
|
|
result.put("missing", missing.size() > 20 ? missing.subList(0, 20) : missing);
|
|
|
|
|
+ attachParseSelfCheck(result, parseSelfCheck);
|
|
|
try {
|
|
try {
|
|
|
healthReportDraftService.updateCollectValidation(draftId, objectMapper.writeValueAsString(result));
|
|
healthReportDraftService.updateCollectValidation(draftId, objectMapper.writeValueAsString(result));
|
|
|
if (missing.isEmpty()) {
|
|
if (missing.isEmpty()) {
|
|
@@ -1222,6 +1261,25 @@ public class ReportCollectService {
|
|
|
return missing.isEmpty();
|
|
return missing.isEmpty();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * P0-3 ③:将 guhe_v2 解析自检({@code _解析自检})四子键(通过/P0告警数/P1提示数/告警)
|
|
|
|
|
+ * 透传并入 collect_validation JSON。仅复制契约声明的四个子键,避免把上游无关字段混入。
|
|
|
|
|
+ */
|
|
|
|
|
+ private void attachParseSelfCheck(Map<String, Object> collectValidation, Map<String, Object> parseSelfCheck) {
|
|
|
|
|
+ if (collectValidation == null || parseSelfCheck == null || parseSelfCheck.isEmpty()) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ Map<String, Object> selfCheck = new LinkedHashMap<>();
|
|
|
|
|
+ for (String key : SELF_CHECK_KEYS) {
|
|
|
|
|
+ if (parseSelfCheck.containsKey(key)) {
|
|
|
|
|
+ selfCheck.put(key, parseSelfCheck.get(key));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!selfCheck.isEmpty()) {
|
|
|
|
|
+ collectValidation.put(PARSE_SELF_CHECK_KEY, selfCheck);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/** 肠道菌群家族校验可选指标(report_type_registry.expected_indicators 中缺失不阻断入库) */
|
|
/** 肠道菌群家族校验可选指标(report_type_registry.expected_indicators 中缺失不阻断入库) */
|
|
|
private static final Set<String> GUT_FLORA_OPTIONAL_INDICATORS =
|
|
private static final Set<String> GUT_FLORA_OPTIONAL_INDICATORS =
|
|
|
new HashSet<>(Arrays.asList("肠道预测年龄", "肠型"));
|
|
new HashSet<>(Arrays.asList("肠道预测年龄", "肠型"));
|