|
|
@@ -214,6 +214,7 @@ public class ReportCollectService {
|
|
|
|
|
|
ParsedReportPayload.Payload payload;
|
|
|
String method;
|
|
|
+ Map<String, Object> parseSelfCheck = null;
|
|
|
if (!"unknown".equals(typeId) && fp.get("parserPath") != null) {
|
|
|
// 指纹成功:脚本已迁移到 LangGraph(/report/parse,算法 + LLM 兜底)
|
|
|
// 已知类型解析失败不再回退 opencode,改为登记退避重试(parse_error 记录失败原因),
|
|
|
@@ -229,6 +230,8 @@ public class ReportCollectService {
|
|
|
healthReportDraftService.recordRetry(draftId, reason);
|
|
|
return;
|
|
|
}
|
|
|
+ // guhe_v2 解析响应的 _解析自检 透传(P0-3 ③),供 collect_validation 落库
|
|
|
+ parseSelfCheck = outcome.getSelfCheck();
|
|
|
} else {
|
|
|
// 无指纹:先用 LangGraph 识别(detect-type → parse-typed / script),识别不了再 opencode
|
|
|
method = METHOD_LANGGRAPH_DETECT;
|
|
|
@@ -259,7 +262,7 @@ public class ReportCollectService {
|
|
|
// 加固①:校验不通过(pass=false)阻止自动入库,标记失败由管理端人工处理
|
|
|
boolean validationPass;
|
|
|
try {
|
|
|
- validationPass = runCollectValidation(draftId, validationTypeId, payload);
|
|
|
+ validationPass = runCollectValidation(draftId, validationTypeId, payload, parseSelfCheck);
|
|
|
} catch (Exception e) {
|
|
|
log.warn("采集指标校验失败 draftId={}, typeId={}", draftId, validationTypeId, e);
|
|
|
validationPass = true;
|
|
|
@@ -1154,6 +1157,21 @@ public class ReportCollectService {
|
|
|
|
|
|
// ======================== 采集指标完整性校验(report_type_registry.expected_indicators 定义驱动) ========================
|
|
|
|
|
|
+ /** _解析自检 子键-1:自检结果(通过 / 告警)—— guhe_v2 解析响应透传并入 collect_validation(P0-3 ③) */
|
|
|
+ public static final String SELF_CHECK_PASS = "通过";
|
|
|
+
|
|
|
+ /** _解析自检 子键-2:P0 告警数(P0-3 ③) */
|
|
|
+ public static final String SELF_CHECK_P0_ALARMS = "P0告警数";
|
|
|
+
|
|
|
+ /** _解析自检 子键-3:P1 提示数(P0-3 ③) */
|
|
|
+ public static final String SELF_CHECK_P1_TIPS = "P1提示数";
|
|
|
+
|
|
|
+ /** _解析自检 子键-4:告警明细(P0-3 ③) */
|
|
|
+ public static final String SELF_CHECK_ALARMS = "告警";
|
|
|
+
|
|
|
+ /** _解析自检 透传并入 collect_validation 时的 JSON 键(P0-3 ③) */
|
|
|
+ public static final String SELF_CHECK_JSON_KEY = "_解析自检";
|
|
|
+
|
|
|
/**
|
|
|
* 健康(GUT/混检)管道校验入口:汇总 payload 中全部可采集指标名称后按定义比对
|
|
|
*/
|
|
|
@@ -1161,6 +1179,14 @@ public class ReportCollectService {
|
|
|
return runCollectValidation(draftId, typeId, collectHealthNames(payload));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 健康管道校验入口(带 _解析自检 透传):解析响应携带自检信息时并入 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);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* DAN 管道校验入口:汇总解析 items 的 name/code 后按定义比对
|
|
|
*/
|
|
|
@@ -1181,6 +1207,18 @@ public class ReportCollectService {
|
|
|
* 结果 JSON(typeId/expected/matched/pass/missing)写入草稿 collect_validation,缺失项记入 WARN 日志。
|
|
|
*/
|
|
|
private boolean runCollectValidation(Long draftId, String typeId, Set<String> collectedNames) {
|
|
|
+ return runCollectValidation(draftId, typeId, collectedNames, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 采集完整性校验:按 report_type_registry.expected_indicators 定义,校验本次采集结果是否覆盖应采集指标项。
|
|
|
+ * 该类型无指标项定义(expected_indicators 为空 / 类型未注册)时跳过,不影响采集主流程。
|
|
|
+ * 结果 JSON(typeId/expected/matched/pass/missing + _解析自检)写入草稿 collect_validation,缺失项记入 WARN 日志。
|
|
|
+ * <p><b>P0-3 ③</b>:guhe_v2 解析响应携带 _解析自检(通过/P0告警数/P1提示数/告警)时透传并入 collect_validation
|
|
|
+ * JSON;未携带(普通报告 / Python 主路径未落地)则保持原仅 typeId/expected/matched/pass/missing 结构。</p>
|
|
|
+ */
|
|
|
+ private boolean runCollectValidation(Long draftId, String typeId, Set<String> collectedNames,
|
|
|
+ Map<String, Object> parseSelfCheck) {
|
|
|
if (draftId == null || typeId == null || collectedNames == null || collectedNames.isEmpty()) {
|
|
|
return true;
|
|
|
}
|
|
|
@@ -1208,6 +1246,7 @@ public class ReportCollectService {
|
|
|
result.put("matched", matched);
|
|
|
result.put("pass", missing.isEmpty());
|
|
|
result.put("missing", missing.size() > 20 ? missing.subList(0, 20) : missing);
|
|
|
+ mergeParseSelfCheck(result, parseSelfCheck);
|
|
|
try {
|
|
|
healthReportDraftService.updateCollectValidation(draftId, objectMapper.writeValueAsString(result));
|
|
|
if (missing.isEmpty()) {
|
|
|
@@ -1222,6 +1261,26 @@ public class ReportCollectService {
|
|
|
return missing.isEmpty();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * _解析自检 透传并入 collect_validation JSON(P0-3 ③):guhe_v2 解析响应携带
|
|
|
+ * {通过, P0告警数, P1提示数, 告警} 时,以 {@link #SELF_CHECK_JSON_KEY} 并入结果 JSON;
|
|
|
+ * 未携带(普通报告)则原样返回,不影响既有校验结构。
|
|
|
+ */
|
|
|
+ private void mergeParseSelfCheck(Map<String, Object> result, Map<String, Object> parseSelfCheck) {
|
|
|
+ if (parseSelfCheck == null || parseSelfCheck.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Map<String, Object> selfCheck = new LinkedHashMap<>();
|
|
|
+ for (String key : new String[]{SELF_CHECK_PASS, SELF_CHECK_P0_ALARMS, SELF_CHECK_P1_TIPS, SELF_CHECK_ALARMS}) {
|
|
|
+ if (parseSelfCheck.containsKey(key)) {
|
|
|
+ selfCheck.put(key, parseSelfCheck.get(key));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!selfCheck.isEmpty()) {
|
|
|
+ result.put(SELF_CHECK_JSON_KEY, selfCheck);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/** 肠道菌群家族校验可选指标(report_type_registry.expected_indicators 中缺失不阻断入库) */
|
|
|
private static final Set<String> GUT_FLORA_OPTIONAL_INDICATORS =
|
|
|
new HashSet<>(Arrays.asList("肠道预测年龄", "肠型"));
|