fix: RANK_INVALID 落地 + 空门槛库不判安全(改判边缘+V1)+ 批量坏文件跳过 + 教授补一作/通讯独立门槛
This commit is contained in:
@@ -360,6 +360,7 @@ def cmd_verify_metric(
|
||||
) -> int:
|
||||
"""职称硬指标核验(主命令,同步)。"""
|
||||
log = _get_task_logger()
|
||||
from db.seed_data import KNOWN_RANKS
|
||||
from service.verify_service import run_verify
|
||||
|
||||
with job_context(skill=SKILL_SLUG):
|
||||
@@ -376,12 +377,21 @@ def cmd_verify_metric(
|
||||
metrics = _parse_json_arg(metrics_json, "--metrics-json")
|
||||
if not metrics:
|
||||
raise ValueError("申报指标 JSON 为空")
|
||||
case = metrics[0] if len(metrics) == 1 else dict(metrics[0])
|
||||
if len(metrics) > 1:
|
||||
raise ValueError("verify-metric 仅支持单个申报案例;多个案例请放入 input 目录走 verify-batch-input")
|
||||
case = dict(metrics[0])
|
||||
if teacher_name:
|
||||
case.setdefault("teacherName", teacher_name)
|
||||
if department:
|
||||
case.setdefault("department", department)
|
||||
case.setdefault("applyRank", apply_rank)
|
||||
final_rank = str(case.get("applyRank") or "").strip()
|
||||
if final_rank not in KNOWN_RANKS:
|
||||
message = f"申报级别只接受 {'、'.join(KNOWN_RANKS)}:{final_rank or '(未提供)'}"
|
||||
log.warning("task_failed task_type=verify_metric error_code=RANK_INVALID stage=verify")
|
||||
finish(status="failed", message=message, skill=SKILL_SLUG, error_code="RANK_INVALID", stage="verify")
|
||||
print(f"ERROR:RANK_INVALID {message}")
|
||||
return 1
|
||||
|
||||
result = run_verify([case])
|
||||
brief = result["reports"][0]
|
||||
@@ -419,9 +429,12 @@ def cmd_verify_metric(
|
||||
|
||||
|
||||
def cmd_verify_batch_input() -> int:
|
||||
"""批量核验(async Action 入口):核验 input/ 目录中的申报案例 JSON。"""
|
||||
"""批量核验(async Action 入口):核验 input/ 目录中的申报案例 JSON。
|
||||
|
||||
坏文件(解析失败/非对象数组)跳过并告警,不中断整批;级别非法的案例由内核报错。
|
||||
"""
|
||||
log = _get_task_logger()
|
||||
from service.verify_service import run_verify
|
||||
from service.verify_service import collect_input_cases, run_verify
|
||||
from util.runtime_paths import get_input_dir
|
||||
|
||||
with job_context(skill=SKILL_SLUG):
|
||||
@@ -436,26 +449,17 @@ def cmd_verify_batch_input() -> int:
|
||||
return 1
|
||||
|
||||
input_dir = get_input_dir()
|
||||
files = sorted(
|
||||
os.path.join(input_dir, name)
|
||||
for name in os.listdir(input_dir)
|
||||
if name.lower().endswith(".json")
|
||||
)
|
||||
if not files:
|
||||
message = f"input 目录没有申报案例 JSON:{input_dir}"
|
||||
cases, skipped_files = collect_input_cases(input_dir)
|
||||
for entry in skipped_files:
|
||||
log.warning("batch_input_file_skipped file=%s reason=%s stage=batch", entry["file"], entry["reason"])
|
||||
emit(f"{entry['file']}:{entry['reason']},该文件已跳过", type="warn", skill=SKILL_SLUG, stage="batch")
|
||||
if not cases:
|
||||
message = f"input 目录没有可用的申报案例 JSON({len(skipped_files)} 个文件无法解析):{input_dir}"
|
||||
log.warning("task_failed task_type=verify_batch error_code=METRIC_INVALID stage=batch")
|
||||
finish(status="failed", message=message, skill=SKILL_SLUG, error_code="METRIC_INVALID", stage="batch")
|
||||
print(f"ERROR:METRIC_INVALID {message}")
|
||||
return 1
|
||||
|
||||
cases = []
|
||||
for path in files:
|
||||
with open(path, encoding="utf-8") as f:
|
||||
payload = json.load(f)
|
||||
if isinstance(payload, dict):
|
||||
payload = payload.get("cases") or [payload]
|
||||
cases.extend(payload)
|
||||
|
||||
result = run_verify(cases)
|
||||
for index, brief in enumerate(result["reports"], start=1):
|
||||
emit(
|
||||
@@ -468,6 +472,7 @@ def cmd_verify_batch_input() -> int:
|
||||
"batch_no": result["batch_no"],
|
||||
"count": result["count"],
|
||||
"verdict_counts": result["verdict_counts"],
|
||||
"skipped_files": skipped_files,
|
||||
"brief_file": result["brief_file"],
|
||||
})
|
||||
finish(status="success", message=f"批量核验完成 {result['count']} 个案例", skill=SKILL_SLUG, stage="batch", batch_no=result["batch_no"])
|
||||
|
||||
Reference in New Issue
Block a user