xyc
2026-11-11 841847dbbab3c6fd532dcb747ca290ba6a9e12d0
tools/build_ledger_inspection_report.py
@@ -5,6 +5,7 @@
from __future__ import annotations
import argparse
import json
from collections import Counter
from pathlib import Path
from typing import Any, Dict, Iterable, List, Optional, Sequence, Tuple
@@ -263,6 +264,24 @@
        element.set(qn("w:color"), BORDER_COLOR)
def set_table_borders_gray(table: Any) -> None:
    tbl_pr = table._tbl.tblPr
    tbl_borders = tbl_pr.first_child_found_in("w:tblBorders")
    if tbl_borders is None:
        tbl_borders = OxmlElement("w:tblBorders")
        tbl_pr.append(tbl_borders)
    for edge in ("top", "left", "bottom", "right", "insideH", "insideV"):
        tag = "w:" + edge
        element = tbl_borders.find(qn(tag))
        if element is None:
            element = OxmlElement(tag)
            tbl_borders.append(element)
        element.set(qn("w:val"), "single")
        element.set(qn("w:sz"), "4")
        element.set(qn("w:space"), "0")
        element.set(qn("w:color"), BORDER_COLOR)
def set_cell_margins(cell: Any, top: int = 90, start: int = 100, bottom: int = 90, end: int = 100) -> None:
    tc = cell._tc
    tcpr = tc.get_or_add_tcPr()
@@ -294,16 +313,31 @@
def set_table_widths(table: Any, widths_cm: Sequence[float]) -> None:
    table.autofit = False
    for row in table.rows:
        for index, width in enumerate(widths_cm):
            row.cells[index].width = Cm(width)
    dxa_widths = [int(width * 567) for width in widths_cm]
    tbl_pr = table._tbl.tblPr
    tbl_layout = tbl_pr.first_child_found_in("w:tblLayout")
    if tbl_layout is None:
        tbl_layout = OxmlElement("w:tblLayout")
        tbl_pr.append(tbl_layout)
    tbl_layout.set(qn("w:type"), "fixed")
    tbl_w = tbl_pr.first_child_found_in("w:tblW")
    if tbl_w is None:
        tbl_w = OxmlElement("w:tblW")
        tbl_pr.append(tbl_w)
    tbl_w.set(qn("w:type"), "dxa")
    tbl_w.set(qn("w:w"), str(int(sum(widths_cm) * 567)))
    tbl_w.set(qn("w:w"), str(sum(dxa_widths)))
    grid_cols = table._tbl.tblGrid.findall(qn("w:gridCol"))
    if len(grid_cols) != len(widths_cm):
        raise ValueError("table grid column count mismatch")
    for grid_col, width in zip(grid_cols, dxa_widths):
        grid_col.set(qn("w:w"), str(width))
    for row in table.rows:
        for index, width in enumerate(widths_cm):
            row.cells[index].width = Cm(width)
def set_cell_text(cell: Any, text: str, font_size: float, bold: bool, alignment: str) -> None:
@@ -339,6 +373,7 @@
    table.alignment = WD_TABLE_ALIGNMENT.CENTER
    table.style = "Table Grid"
    table.autofit = False
    set_table_borders_gray(table)
    set_table_widths(table, widths_cm)
    header = table.rows[0]
    set_repeat_table_header(header)
@@ -371,6 +406,61 @@
                paragraph.paragraph_format.line_spacing = Pt(12)
CITY_ORDER = {
    "\u6b66\u6c49\u5e02": 0,
    "\u9ec4\u77f3\u5e02": 1,
    "\u5341\u5830\u5e02": 2,
    "\u5b9c\u660c\u5e02": 3,
    "\u8944\u9633\u5e02": 4,
    "\u9102\u5dde\u5e02": 5,
    "\u8346\u95e8\u5e02": 6,
    "\u5b5d\u611f\u5e02": 7,
    "\u8346\u5dde\u5e02": 8,
    "\u9ec4\u5188\u5e02": 9,
    "\u54b8\u5b81\u5e02": 10,
    "\u968f\u5dde\u5e02": 11,
    "\u6069\u65bd\u5dde": 12,
    "\u4ed9\u6843\u5e02": 13,
    "\u6f5c\u6c5f\u5e02": 14,
    "\u5929\u95e8\u5e02": 15,
    "\u6797\u533a": 16,
}
CITY_FULL_NAMES = {
    "\u6b66\u6c49": "\u6b66\u6c49\u5e02",
    "\u9ec4\u77f3": "\u9ec4\u77f3\u5e02",
    "\u5341\u5830": "\u5341\u5830\u5e02",
    "\u5b9c\u660c": "\u5b9c\u660c\u5e02",
    "\u8944\u9633": "\u8944\u9633\u5e02",
    "\u9102\u5dde": "\u9102\u5dde\u5e02",
    "\u8346\u95e8": "\u8346\u95e8\u5e02",
    "\u5b5d\u611f": "\u5b5d\u611f\u5e02",
    "\u8346\u5dde": "\u8346\u5dde\u5e02",
    "\u9ec4\u5188": "\u9ec4\u5188\u5e02",
    "\u54b8\u5b81": "\u54b8\u5b81\u5e02",
    "\u968f\u5dde": "\u968f\u5dde\u5e02",
    "\u6069\u65bd\u5dde": "\u6069\u65bd\u5dde",
    "\u4ed9\u6843": "\u4ed9\u6843\u5e02",
    "\u6f5c\u6c5f": "\u6f5c\u6c5f\u5e02",
    "\u5929\u95e8": "\u5929\u95e8\u5e02",
    "\u6797\u533a": "\u6797\u533a",
}
def full_city_name(value: Any) -> str:
    text = str(value or "").strip()
    return CITY_FULL_NAMES.get(text, text)
def short_city_name(value: Any) -> str:
    text = full_city_name(value)
    return text[:-1] if text.endswith("\u5e02") else text
def city_sort_key(value: Any) -> Tuple[int, str]:
    city = full_city_name(value)
    return CITY_ORDER.get(city, 99), city
def fmt_int(value: Any) -> str:
    return f"{int(round(float(value or 0))):,}"
@@ -388,100 +478,200 @@
    return (f"{rate:+.2f}%" if signed else f"{rate:.2f}%")
def fmt_days(value: Any) -> str:
    days = int(value or 0)
    return str(days) if days != 0 else "-"
def read_workbook(path: Path) -> Tuple[List[Dict[str, Any]], List[Dict[str, Any]], Counter, Counter]:
def read_enterprises(path: Path) -> List[Dict[str, Any]]:
    wb = load_workbook(path, data_only=True)
    overall = wb["总体情况"]
    enterprises: List[Dict[str, Any]] = []
    for row in range(4, overall.max_row + 1):
        if not overall.cell(row, 2).value:
            continue
        enterprises.append({
            "city": overall.cell(row, 1).value or "",
            "enterprise": overall.cell(row, 2).value or "",
            "ledger_vehicles": overall.cell(row, 7).value or 0,
            "month_turnover": overall.cell(row, 6).value or 0,
            "ledger_turnover": overall.cell(row, 9).value or 0,
            "report_vs_ledger": overall.cell(row, 11).value or 0,
            "ledger_mileage": overall.cell(row, 13).value or 0,
            "platform_mileage": overall.cell(row, 14).value or 0,
            "mileage_diff": overall.cell(row, 15).value or 0,
            "no_track": overall.cell(row, 16).value or 0,
        })
    samples_sheet = wb["抽查车辆轨迹情况"]
    samples: List[Dict[str, Any]] = []
    for row in range(4, samples_sheet.max_row + 1):
        if not samples_sheet.cell(row, 3).value:
            continue
        conclusion = str(samples_sheet.cell(row, 19).value or "")
        if "与申报路线不符" in conclusion:
            judgment = "路线不符"
        elif "远低于申报趟次" in conclusion:
            judgment = "端点频次不足"
        elif "不矛盾" in conclusion and "无法" in conclusion:
            judgment = "局部端点无法定位"
        elif "申报端点为设施或道路名称" in conclusion:
            judgment = "端点名称无法核验"
        else:
            judgment = "需进一步核查"
        samples.append({
            "city": samples_sheet.cell(row, 1).value or "",
            "enterprise": samples_sheet.cell(row, 2).value or "",
            "plate": samples_sheet.cell(row, 3).value or "",
            "ledger_mileage": samples_sheet.cell(row, 7).value or 0,
            "platform_mileage": samples_sheet.cell(row, 8).value or 0,
            "mileage_diff": samples_sheet.cell(row, 9).value or 0,
            "points": samples_sheet.cell(row, 10).value or 0,
            "days": samples_sheet.cell(row, 11).value or 0,
            "support_ratio": samples_sheet.cell(row, 16).value or 0,
            "judgment": judgment,
            "risk": samples_sheet.cell(row, 20).value or "",
        })
    issue_sheet = wb["问题明细"]
    issue_types: Counter = Counter()
    issue_severity: Counter = Counter()
    issue_header_row = next(
        (
            row for row in range(1, issue_sheet.max_row + 1)
            if issue_sheet.cell(row, 4).value == "问题类型"
        ),
        3,
    )
    for row in range(issue_header_row + 1, issue_sheet.max_row + 1):
        issue_type = issue_sheet.cell(row, 4).value
        severity = issue_sheet.cell(row, 5).value
        if issue_type:
            issue_types[str(issue_type)] += 1
        if severity:
            issue_severity[str(severity)] += 1
    if "\u603b\u4f53\u60c5\u51b5" in wb.sheetnames:
        sheet = wb["\u603b\u4f53\u60c5\u51b5"]
        for row in range(4, sheet.max_row + 1):
            if not sheet.cell(row, 2).value:
                continue
            enterprises.append({
                "city": sheet.cell(row, 1).value or "",
                "enterprise": sheet.cell(row, 2).value or "",
                "ledger_vehicles": sheet.cell(row, 7).value or 0,
                "month_turnover": sheet.cell(row, 6).value or 0,
                "ledger_turnover": sheet.cell(row, 9).value or 0,
                "report_vs_ledger": sheet.cell(row, 11).value or 0,
                "ledger_mileage": sheet.cell(row, 13).value or 0,
                "platform_mileage": sheet.cell(row, 14).value or 0,
                "mileage_diff": sheet.cell(row, 15).value or 0,
                "no_track": sheet.cell(row, 16).value or 0,
            })
    elif "\u4f01\u4e1a\u6838\u67e5\u7ed3\u679c" in wb.sheetnames:
        sheet = wb["\u4f01\u4e1a\u6838\u67e5\u7ed3\u679c"]
        for row in range(5, sheet.max_row + 1):
            enterprise = sheet.cell(row, 2).value
            if not enterprise:
                continue
            turnover_pair = str(sheet.cell(row, 4).value or "").split("/")
            mileage_pair = str(sheet.cell(row, 6).value or "").split("/")
            if len(turnover_pair) != 2 or len(mileage_pair) != 2:
                continue
            enterprises.append({
                "city": sheet.cell(row, 1).value or "",
                "enterprise": enterprise,
                "ledger_vehicles": sheet.cell(row, 3).value or 0,
                "month_turnover": float(turnover_pair[0].replace(",", "").strip()) * 10000,
                "ledger_turnover": float(turnover_pair[1].replace(",", "").strip()) * 10000,
                "report_vs_ledger": sheet.cell(row, 5).value or 0,
                "ledger_mileage": float(mileage_pair[0].replace(",", "").strip()),
                "platform_mileage": float(mileage_pair[1].replace(",", "").strip()),
                "mileage_diff": sheet.cell(row, 7).value or 0,
                "no_track": sheet.cell(row, 8).value or 0,
            })
    no_track_by_enterprise: Dict[str, List[str]] = {}
    if "\u8f66\u8f86\u91cc\u7a0b\u5dee\u5f02\u60c5\u51b5" in wb.sheetnames:
        vehicle_sheet = wb["\u8f66\u8f86\u91cc\u7a0b\u5dee\u5f02\u60c5\u51b5"]
        for values in vehicle_sheet.iter_rows(min_row=4, max_col=12, values_only=True):
            enterprise = values[1]
            plate = values[2]
            status = values[11]
            if enterprise and plate and status == "\u5e73\u53f0\u660e\u7ec6\u65e0\u5339\u914d":
                no_track_by_enterprise.setdefault(str(enterprise), []).append(str(plate))
    for item in enterprises:
        item["no_track_plates"] = no_track_by_enterprise.get(str(item["enterprise"]), [])
    wb.close()
    return enterprises, samples, issue_types, issue_severity
    return enterprises
def enterprise_judgment(item: Dict[str, Any]) -> str:
    parts: List[str] = []
    if abs(float(item["report_vs_ledger"])) > 0.01:
        if "凯祥达" in str(item["enterprise"]):
            parts.append("周转量汇总公式错误")
        else:
            parts.append("月报台账差异大")
    if abs(float(item["mileage_diff"])) > 0.30:
        parts.append("里程差异超范围")
def turnover_judgment(item: Dict[str, Any]) -> str:
    difference = float(item["report_vs_ledger"])
    if abs(difference) <= 0.01:
        return "\u6570\u503c\u57fa\u672c\u4e00\u81f4"
    if "\u51ef\u7965\u8fbe" in str(item["enterprise"]):
        return "\u5468\u8f6c\u91cf\u6c47\u603b\u516c\u5f0f\u9519\u8bef"
    return "\u6708\u62a5\u53f0\u8d26\u5dee\u5f02\u8f83\u5927"
def mileage_judgment(item: Dict[str, Any]) -> str:
    difference = float(item["mileage_diff"])
    if difference > 0.30:
        parts = ["\u53f0\u8d26\u91cc\u7a0b\u660e\u663e\u9ad8\u4e8e\u5e73\u53f0"]
    elif difference < -0.30:
        parts = ["\u53f0\u8d26\u91cc\u7a0b\u660e\u663e\u4f4e\u4e8e\u5e73\u53f0"]
    else:
        parts.append("里程差异正常")
        parts = ["\u53f0\u8d26\u91cc\u7a0b\u5728\u6b63\u5e38\u533a\u95f4"]
    if int(item["no_track"] or 0) > 0:
        parts.append("存在无轨迹车辆")
    return ";".join(parts)
        parts.append("\u5b58\u5728\u65e0\u5e73\u53f0\u6708\u91cc\u7a0b\u8f66\u8f86")
    return "\uff1b".join(parts)
def build_report(workbook_path: Path, output_path: Path, attachment_name: str) -> None:
    enterprises, samples, issue_types, issue_severity = read_workbook(workbook_path)
    if len(enterprises) != 12 or len(samples) != 12:
def add_two_level_table(
    doc: Document,
    groups: Sequence[Tuple[str, Sequence[str]]],
    rows: Sequence[Sequence[str]],
    widths_cm: Sequence[float],
    body_alignments: Sequence[str],
    header_size: float = 9.0,
    body_size: float = 8.5,
) -> Any:
    column_count = sum(max(1, len(children)) for _, children in groups)
    if len(widths_cm) != column_count or len(body_alignments) != column_count:
        raise ValueError("two-level table width or alignment count mismatch")
    table = doc.add_table(rows=2, cols=column_count)
    table.alignment = WD_TABLE_ALIGNMENT.CENTER
    table.style = "Table Grid"
    table.autofit = False
    set_table_borders_gray(table)
    set_table_widths(table, widths_cm)
    top_row = table.rows[0]
    second_row = table.rows[1]
    set_repeat_table_header(top_row)
    set_repeat_table_header(second_row)
    prevent_row_split(top_row)
    prevent_row_split(second_row)
    column = 0
    for label, children in groups:
        span = max(1, len(children))
        if children:
            top_cell = top_row.cells[column]
            if span > 1:
                top_cell = top_cell.merge(top_row.cells[column + span - 1])
            set_cell_text(top_cell, label, header_size, True, ALIGN_CENTER)
            for offset, child in enumerate(children):
                set_cell_text(second_row.cells[column + offset], child, header_size, True, ALIGN_CENTER)
        else:
            merged = top_row.cells[column].merge(second_row.cells[column])
            set_cell_text(merged, label, header_size, True, ALIGN_CENTER)
        column += span
    for values in rows:
        row = table.add_row()
        prevent_row_split(row)
        for index, value in enumerate(values):
            set_cell_text(row.cells[index], value, body_size, False, body_alignments[index])
    set_table_widths(table, widths_cm)
    for row_index in (0, 1):
        for cell in table.rows[row_index].cells:
            set_cell_margins(cell, top=35, start=45, bottom=35, end=45)
            for paragraph in cell.paragraphs:
                paragraph.paragraph_format.line_spacing = Pt(12)
    for row in table.rows[2:]:
        for cell in row.cells:
            set_cell_margins(cell, top=35, start=55, bottom=35, end=55)
            for paragraph in cell.paragraphs:
                paragraph.paragraph_format.line_spacing = Pt(12)
    spacer = doc.add_paragraph()
    spacer.paragraph_format.first_line_indent = Pt(0)
    spacer.paragraph_format.space_before = Pt(0)
    spacer.paragraph_format.space_after = Pt(0)
    spacer.paragraph_format.line_spacing = Pt(6)
    return table
def strict_missing_endpoints(vehicle: Dict[str, Any]) -> List[str]:
    return [
        endpoint["label"] for endpoint in vehicle["points"].get("endpoints", [])
        if endpoint.get("strict", True) and endpoint["day_count"] == 0
    ]
def main_region(vehicle: Dict[str, Any]) -> str:
    regions: List[str] = []
    for name, points, days in vehicle["points"].get("top_counties", [])[:2]:
        parts = [part for part in str(name).split("|") if part]
        label = (parts[-2] + parts[-1]) if len(parts) >= 3 else (parts[-1] if parts else str(name))
        regions.append(label)
    return "\u3001".join(regions) if regions else "\u65e0\u6709\u6548\u6d3b\u52a8\u533a\u57df"
def sample_judgment(vehicle: Dict[str, Any]) -> str:
    if strict_missing_endpoints(vehicle):
        return "\u7533\u62a5\u7ebf\u8def\u672a\u83b7\u8f68\u8ff9\u652f\u6301"
    return "\u7ebf\u8def\u65b9\u5411\u6709\u652f\u6301\u4f46\u8d9f\u6b21\u4e0d\u8db3"
def sample_support(vehicle: Dict[str, Any]) -> float:
    return float(vehicle["comparison"].get("trip_support_rate") or 0)
def ledger_route_text(vehicle: Dict[str, Any]) -> str:
    groups = list(vehicle["ledger"].get("route_groups", []))
    groups.sort(key=lambda group: float(group.get("trips") or 0), reverse=True)
    parts: List[str] = []
    for group in groups:
        route = str(group.get("route") or "").strip()
        if len(route) > 28:
            route = route[:27] + "\u2026"
        trips = float(group.get("trips") or 0)
        parts.append(f"{route}\uff08{trips:g}\u8d9f\uff09")
    return "\u3001".join(parts) if parts else "\u672a\u8bc6\u522b"
def build_report(workbook_path: Path, diagnostics_path: Path, output_path: Path) -> None:
    enterprises = read_enterprises(workbook_path)
    enterprises.sort(key=lambda item: (city_sort_key(item["city"]), str(item["enterprise"])))
    diagnostics_data = json.loads(diagnostics_path.read_text(encoding="utf-8"))
    vehicles = diagnostics_data["vehicles"]
    if len(enterprises) != 12 or len(vehicles) != 12:
        raise RuntimeError("Expected 12 enterprise rows and 12 sample vehicles")
    vehicles_by_enterprise = {str(item["enterprise"]): item for item in vehicles}
    if any(str(item["enterprise"]) not in vehicles_by_enterprise for item in enterprises):
        raise RuntimeError("Enterprise and sample vehicle data do not match")
    total_ledger_mileage = sum(float(item["ledger_mileage"]) for item in enterprises)
    total_platform_mileage = sum(float(item["platform_mileage"]) for item in enterprises)
    total_vehicles = sum(int(item["ledger_vehicles"]) for item in enterprises)
@@ -490,100 +680,118 @@
    layer2_normal = sum(abs(float(item["mileage_diff"])) <= 0.30 for item in enterprises)
    total_mileage_diff = total_ledger_mileage / total_platform_mileage - 1 if total_platform_mileage else 0
    no_track_ratio = total_no_track / total_vehicles if total_vehicles else 0
    total_points = sum(int(item["points"]) for item in samples)
    below_half = sum(float(item["support_ratio"]) < 0.5 for item in samples)
    support_min = min(float(item["support_ratio"]) for item in samples)
    support_max = max(float(item["support_ratio"]) for item in samples)
    route_mismatch = sum(item["judgment"] == "路线不符" for item in samples)
    frequency_short = sum(item["judgment"] == "端点频次不足" for item in samples)
    endpoint_uncheckable = len(samples) - route_mismatch - frequency_short
    issue_total = sum(issue_types.values())
    high_issues = int(issue_severity.get("高", 0))
    medium_issues = int(issue_severity.get("中", 0))
    kxd_formula_issue_extra = 0 if issue_types.get("周转量汇总公式错误", 0) else 1
    issue_total += kxd_formula_issue_extra
    high_issues += kxd_formula_issue_extra
    kxd = next((item for item in enterprises if "凯祥达" in item["enterprise"]), None)
    datong = next((item for item in enterprises if "大通" in item["enterprise"]), None)
    raw_points = sum(int(item["points"]["valid_point_count"] or 0) for item in vehicles)
    point_files = sum(int(item["points"]["file_count"] or 0) for item in vehicles)
    point_days_30 = sum(int(item["points"]["day_count"] or 0) == 30 for item in vehicles)
    point_days_29 = len(vehicles) - point_days_30
    positive_days_30 = sum(int(item["platform"].get("positive_mileage_days") or 0) == 30 for item in vehicles)
    positive_days_29 = sum(int(item["platform"].get("positive_mileage_days") or 0) == 29 for item in vehicles)
    positive_days_short = len(vehicles) - positive_days_30 - positive_days_29
    route_mismatch = sum(bool(strict_missing_endpoints(item)) for item in vehicles)
    supported_vehicles = [item for item in vehicles if not strict_missing_endpoints(item)]
    support_below_half_supported = sum(sample_support(item) < 0.5 for item in supported_vehicles)
    supported_support_min = min(sample_support(item) for item in supported_vehicles)
    supported_support_max = max(sample_support(item) for item in supported_vehicles)
    kxd = next((item for item in enterprises if "\u51ef\u7965\u8fbe" in str(item["enterprise"])), None)
    datong = next((item for item in enterprises if "\u5927\u901a" in str(item["enterprise"])), None)
    doc = Document()
    configure_document(doc)
    doc.core_properties.title = "2026年9月企业台账抽查核查报告"
    doc.core_properties.subject = "企业台账、重载平台里程和重点车辆轨迹点核查"
    add_title(doc, "2026年9月企业台账抽查核查报告")
    doc.core_properties.title = "2026\u5e749\u6708\u4f01\u4e1a\u53f0\u8d26\u62bd\u67e5\u6838\u67e5\u62a5\u544a"
    doc.core_properties.subject = "\u4f01\u4e1a\u53f0\u8d26\u3001\u91cd\u8f7d\u5e73\u53f0\u91cc\u7a0b\u548c\u91cd\u70b9\u8f66\u8f86\u8f68\u8ff9\u70b9\u6838\u67e5"
    add_title(doc, "2026\u5e749\u6708\u4f01\u4e1a\u53f0\u8d26\u62bd\u67e5\u6838\u67e5\u62a5\u544a")
    add_body(
        doc,
        "按照工作安排,对咸宁、黄冈、宜昌3个市州12家企业2026年9月台账及其车辆轨迹数据开展抽查核查,累计投入约1周。现将核查情况报告如下。",
        "\u6309\u7167\u5de5\u4f5c\u5b89\u6392\uff0c\u5bf9\u5b9c\u660c\u5e02\u3001\u9ec4\u5188\u5e02\u3001\u54b8\u5b81\u5e023\u4e2a\u5e02\u5dde12\u5bb6\u4f01\u4e1a2026\u5e749\u6708\u53f0\u8d26\u53ca\u5176\u8f66\u8f86\u8f68\u8ff9\u6570\u636e\u5f00\u5c55\u62bd\u67e5\u6838\u67e5\u3002\u73b0\u5c06\u6838\u67e5\u60c5\u51b5\u62a5\u544a\u5982\u4e0b\u3002",
    )
    add_heading(doc, "一、核查范围与工作量")
    add_heading(doc, "\u4e00\u3001\u6838\u67e5\u8303\u56f4\u4e0e\u6570\u636e\u60c5\u51b5")
    add_body(
        doc,
        "本次核查以企业上报月报、企业运输台账、重载平台车辆月度里程和车辆轨迹点为基础,逐户核对月报与台账数据,逐车比对台账里程与平台监测里程,并按照每户企业1辆重点车辆的方式开展整月轨迹点精查。核查覆盖范围和工作量如下。",
        "\u672c\u6b21\u6838\u67e5\u4ee5\u4f01\u4e1a\u4e0a\u62a5\u6708\u62a5\u3001\u4f01\u4e1a\u8fd0\u8f93\u53f0\u8d26\u3001\u91cd\u8f7d\u5e73\u53f0\u8f66\u8f86\u6708\u5ea6\u91cc\u7a0b\u548c\u8f66\u8f86\u8f68\u8ff9\u70b9\u4e3a\u57fa\u7840\uff0c\u4f9d\u6b21\u6838\u5bf9\u6708\u62a5\u4e0e\u53f0\u8d26\u3001\u53f0\u8d26\u91cc\u7a0b\u4e0e\u5e73\u53f0\u76d1\u6d4b\u91cc\u7a0b\uff0c\u5e76\u5bf9\u6bcf\u6237\u4f01\u4e1a1\u8f86\u91cd\u70b9\u8f66\u8f86\u5f00\u5c55\u6574\u6708\u8f68\u8ff9\u70b9\u7cbe\u67e5\u3002\u6838\u67e5\u6570\u636e\u60c5\u51b5\u5982\u4e0b\u3002",
    )
    add_caption(doc, "表1  核查范围与工作量")
    add_caption(doc, "\u88681  \u6838\u67e5\u8303\u56f4\u4e0e\u6570\u636e\u60c5\u51b5")
    workload_rows = [
        ("核查范围", "3个市州、12家企业"),
        ("企业台账", "12份,解析车辆—路线—趟次记录3,003条"),
        ("台账车辆", "579辆"),
        ("平台月度里程", "12份,车辆日里程记录12,921条"),
        ("轨迹点资料", "119个轨迹点文件,原始轨迹点286,438条,去重后286,436条"),
        ("重点车辆精查", "12辆,每户企业1辆"),
        ("比对结果", "企业级结果12组,车辆级结果579组,轨迹线路结果12组"),
        ("问题识别", f"问题{issue_total}项,其中高风险{high_issues}项、中风险{medium_issues}项"),
        ("核查投入", "约1周"),
        ("\u6838\u67e5\u8303\u56f4", "3\u4e2a\u5e02\u5dde\u300112\u5bb6\u4f01\u4e1a"),
        ("\u4f01\u4e1a\u53f0\u8d26", "12\u4efd\uff0c\u8f66\u8f86\u2014\u8def\u7ebf\u2014\u8d9f\u6b21\u2014\u8d27\u8fd0\u91cf\u2014\u5468\u8f6c\u91cf\u8bb0\u5f553,003\u6761"),
        ("\u53f0\u8d26\u8f66\u8f86", f"{fmt_int(total_vehicles)}\u8f86"),
        ("\u5e73\u53f0\u6708\u5ea6\u91cc\u7a0b", "12\u4efd\uff0c\u4ece\u91cd\u8f7d\u5e73\u53f0\u4e0b\u8f7d\uff0c\u8f66\u8f86\u65e5\u91cc\u7a0b\u8bb0\u5f5512,921\u6761"),
        ("\u91cd\u70b9\u8f66\u8f86\u7cbe\u67e5", f"\u4ece\u8f66\u8f86\u65e5\u91cc\u7a0b\u8bb0\u5f55\u7b5b\u9009\u8f68\u8ff9\u5c3d\u91cf\u8986\u76d6\u5168\u6708\u7684\u8f66\u8f86\uff0c\u517112\u8f86\uff0c\u6bcf\u6237\u4f01\u4e1a1\u8f86\uff1b{point_days_30}\u8f8630\u5929\u6709\u8f68\u8ff9\u70b9\uff0c{point_days_29}\u8f8629\u5929\u6709\u8f68\u8ff9\u70b9"),
        ("\u8f68\u8ff9\u70b9\u8d44\u6599", f"{point_files}\u4e2a\u6587\u4ef6\uff0c\u4ece\u91cd\u8f7d\u5e73\u53f0\u4e0b\u8f7d\uff0c\u8f68\u8ff9\u70b9{fmt_int(raw_points)}\u4e2a"),
        ("\u95ee\u9898\u6c47\u603b", "\u53e6\u9644\u95ee\u9898\u6c47\u603b\u8868Excel\uff0c\u517140\u6761\u95ee\u9898\u8bb0\u5f55"),
    ]
    add_table(
        doc,
        ["核查维度", "数量及内容"],
        ["\u6838\u67e5\u7ef4\u5ea6", "\u6570\u91cf\u53ca\u5185\u5bb9"],
        workload_rows,
        [3.7, 10.9],
        [3.5, 11.1],
        [ALIGN_CENTER, ALIGN_LEFT],
        header_size=12,
        body_size=12,
    )
    add_heading(doc, "二、核查内容与方法")
    add_heading(doc, "(一)月报与台账一致性核查", 2)
    add_heading(doc, "\u4e8c\u3001\u6838\u67e5\u5185\u5bb9\u4e0e\u65b9\u6cd5")
    add_heading(doc, "\uff08\u4e00\uff09\u5206\u5c42\u6838\u67e5", 2)
    add_body(
        doc,
        "将企业上报的月报货运量、周转量与台账逐笔汇总结果进行比对,并同步检查台账汇总单元格的计算公式。差异率绝对值不超过1%的,判定为数值基本一致;超过1%的,列为差异事项。对台账汇总公式不采用逐笔周转量求和的,进一步复算1—9月各月月报值与正确明细合计,防止月报和台账沿用同一错误公式而形成表面一致。",
        "\u7b2c\u4e00\u5c42\u6838\u5bf9\u6708\u62a5\u4e0e\u53f0\u8d26\u5468\u8f6c\u91cf\uff0c\u5dee\u5f02\u7387\u7edd\u5bf9\u503c\u4e0d\u8d85\u8fc71%\u7684\u5224\u5b9a\u4e3a\u6570\u503c\u57fa\u672c\u4e00\u81f4\uff0c\u8d85\u8fc71%\u7684\u5217\u4e3a\u5dee\u5f02\u4e8b\u9879\uff1b\u7b2c\u4e8c\u5c42\u9010\u8f66\u6bd4\u5bf9\u53f0\u8d26\u91cc\u7a0b\u4e0e\u5e73\u53f0\u6708\u5ea6\u76d1\u6d4b\u91cc\u7a0b\uff0c\u5dee\u5f02\u7387\u5728\u6b63\u8d1f30%\u4ee5\u5185\u7684\u5224\u5b9a\u4e3a\u6b63\u5e38\uff1b\u7b2c\u4e09\u5c42\u5bf9\u91cd\u70b9\u8f66\u8f86\u6574\u6708\u8f68\u8ff9\u70b9\u6838\u67e5\u6d3b\u52a8\u533a\u57df\u3001\u7ebf\u8def\u7aef\u70b9\u3001\u91cc\u7a0b\u89c4\u6a21\u548c\u53ef\u652f\u6301\u8d9f\u6b21\u3002",
    )
    add_heading(doc, "(二)台账里程与平台监测里程核查", 2)
    add_heading(doc, "\uff08\u4e8c\uff09\u91cd\u70b9\u8f66\u8f86\u9009\u53d6", 2)
    add_body(
        doc,
        "以重载平台车辆日里程汇总形成企业月度监测里程,再与企业台账车辆总里程逐车、逐企业比对。台账与平台里程差异率在正负30%以内的,判定为正常;超出该范围的,列为重点差异。对无平台监测记录的车辆单独统计,不按零公里处理。",
        "\u91cd\u70b9\u8f66\u8f86\u4f18\u5148\u9009\u53d6\u5e73\u53f0\u65e5\u91cc\u7a0b30\u5929\u5747\u6709\u8bb0\u5f55\u4e14\u6bcf\u65e5\u603b\u91cc\u7a0b\u5927\u4e8e0\u3001\u53f0\u8d26\u4e0e\u5e73\u53f0\u91cc\u7a0b\u5dee\u5f02\u8d85\u8fc730%\u3001\u7ebf\u8def\u53ef\u4e0e\u53f0\u8d26\u5bf9\u5e94\u3001\u8f68\u8ff9\u70b9\u8fde\u7eed\u6027\u8f83\u597d\u7684\u8f66\u8f86\u3002\u4e2a\u522b\u4f01\u4e1a\u4e0d\u5b58\u5728\u540c\u65f6\u6ee1\u8db3\u4e0a\u8ff0\u6761\u4ef6\u7684\u8f66\u8f86\u65f6\uff0c\u9009\u53d6\u5f53\u6708\u8986\u76d629\u5929\u4ee5\u4e0a\u3001\u5df2\u8986\u76d6\u65e5\u671f\u603b\u91cc\u7a0b\u5747\u5927\u4e8e0\u4e14\u5dee\u5f02\u7387\u8f83\u5927\u7684\u8f66\u8f86\uff0c\u5e76\u5c06\u8986\u76d6\u4e0d\u8db3\u4f5c\u4e3a\u4f01\u4e1a\u52a8\u6001\u76d1\u63a7\u7ef4\u62a4\u95ee\u9898\u5355\u72ec\u6838\u67e5\u3002",
    )
    add_heading(doc, "(三)重点车辆轨迹点精查", 2)
    add_heading(doc, "\uff08\u4e09\uff09\u8bc1\u636e\u4f7f\u7528\u8fb9\u754c", 2)
    add_body(
        doc,
        "重点车辆选取以重载平台车辆月度里程数据为基础,优先选择轨迹覆盖天数较多、台账与平台月度里程差异较大,且能够对应台账主要运输线路的车辆;每户企业选取1辆。",
    )
    add_body(
        doc,
        "对选中车辆2026年9月整月轨迹点开展核验,重点核查车辆活动区域、线路端点、轨迹覆盖天数、轨迹点路径里程以及按台账平均单趟里程折算的可支持趟次。轨迹点能够证明车辆活动区域和里程规模,但不能单独证明每趟货物的实际重量及装卸货事实。",
        "\u8f68\u8ff9\u6570\u636e\u7528\u4e8e\u5224\u65ad\u8f66\u8f86\u6d3b\u52a8\u533a\u57df\u3001\u7ebf\u8def\u65b9\u5411\u3001\u91cc\u7a0b\u89c4\u6a21\u548c\u8d9f\u6b21\u6570\u91cf\u7ea7\u3002\u8f68\u8ff9\u8986\u76d6\u5929\u6570\u7528\u4e8e\u5224\u65ad\u4f01\u4e1a\u52a8\u6001\u76d1\u63a7\u7ef4\u62a4\u60c5\u51b5\uff0c\u4e0d\u636e\u6b64\u5355\u72ec\u8ba4\u5b9a\u53f0\u8d26\u865a\u5047\uff1b\u8f68\u8ff9\u4e5f\u4e0d\u80fd\u76f4\u63a5\u8bc1\u660e\u6bcf\u8d9f\u8d27\u7269\u5b9e\u9645\u91cd\u91cf\u548c\u88c5\u5378\u8d27\u4e8b\u5b9e\uff0c\u76f8\u5173\u4e8b\u9879\u4ecd\u9700\u7ed3\u5408\u8fd0\u5355\u3001\u8fc7\u78c5\u5355\u3001\u88c5\u5378\u8d27\u8bb0\u5f55\u7b49\u539f\u59cb\u51ed\u636e\u6838\u5b9e\u3002",
    )
    add_heading(doc, "三、核查结果")
    add_heading(doc, "(一)1家企业已查明月报周转量因台账汇总公式错误多报", 2)
    add_section(doc, landscape=False)
    add_heading(doc, "\u4e09\u3001\u6838\u67e5\u7ed3\u679c")
    add_heading(doc, "\uff08\u4e00\uff09\u6708\u62a5\u4e0e\u53f0\u8d26\u5468\u8f6c\u91cf", 2)
    add_body(
        doc,
        f"12\u5bb6\u4f01\u4e1a\u4e2d\uff0c{layer1_consistent}\u5bb6\u6708\u62a5\u4e0e\u53f0\u8d26\u5468\u8f6c\u91cf\u5dee\u5f02\u7387\u7edd\u5bf9\u503c\u4e0d\u8d85\u8fc71%\uff0c1\u5bb6\u8d85\u8fc750%\u3002\u5404\u4f01\u4e1a\u6bd4\u8f83\u60c5\u51b5\u89c1\u88682\u3002",
    )
    add_caption(doc, "\u88682  \u4f01\u4e1a\u6708\u62a5\u4e0e\u53f0\u8d26\u5468\u8f6c\u91cf\u6838\u67e5\u7ed3\u679c")
    turnover_groups = [
        ("\u5e8f\u53f7", ()),
        ("\u5e02\u5dde", ()),
        ("\u4f01\u4e1a", ()),
        ("\u5468\u8f6c\u91cf\uff08\u4e07\u5428\u516c\u91cc\uff09", ("\u6708\u62a5", "\u53f0\u8d26", "\u5dee\u5f02\u7387")),
        ("\u6838\u67e5\u5224\u65ad", ()),
    ]
    turnover_rows: List[Sequence[str]] = []
    for index, item in enumerate(enterprises, start=1):
        turnover_rows.append((
            str(index), short_city_name(item["city"]), str(item["enterprise"]),
            fmt_wan_ton_km(item["month_turnover"]), fmt_wan_ton_km(item["ledger_turnover"]),
            fmt_pct(item["report_vs_ledger"]), turnover_judgment(item),
        ))
    add_two_level_table(
        doc,
        turnover_groups,
        turnover_rows,
        [0.8, 1.1, 4.0, 2.1, 2.1, 1.5, 3.0],
        [ALIGN_CENTER, ALIGN_CENTER, ALIGN_LEFT, ALIGN_RIGHT, ALIGN_RIGHT, ALIGN_RIGHT, ALIGN_LEFT],
        header_size=12,
        body_size=10.5,
    )
    if kxd:
        add_body(
            doc,
            f"12家企业中,{layer1_consistent}家月报与台账周转量差异率绝对值不超过1%,1家超过50%。差异较大的为宜昌凯祥达物流有限公司,9月月报周转量{fmt_wan_ton_km(kxd['month_turnover'])}万吨公里、台账逐行正确合计{fmt_wan_ton_km(kxd['ledger_turnover'])}万吨公里,月报多报{fmt_pct(kxd['report_vs_ledger'])}。经逐月核对,该企业1—9月台账均使用“货运量合计×平均里程”计算周转量,未按明细逐笔汇总,已查明为台账汇总公式错误。",
            f"\u5b9c\u660c\u51ef\u7965\u8fbe\u7269\u6d41\u6709\u9650\u516c\u53f89\u6708\u6708\u62a5\u5468\u8f6c\u91cf{fmt_wan_ton_km(kxd['month_turnover'])}\u4e07\u5428\u516c\u91cc\uff0c\u53f0\u8d26\u9010\u884c\u6b63\u786e\u5408\u8ba1{fmt_wan_ton_km(kxd['ledger_turnover'])}\u4e07\u5428\u516c\u91cc\uff0c\u6708\u62a5\u591a\u62a5{fmt_pct(kxd['report_vs_ledger'])}\u3002\u8be5\u4f01\u4e1a1\u20149\u6708\u5747\u4f7f\u7528\u201c\u8d27\u8fd0\u91cf\u5408\u8ba1\u00d7\u5e73\u5747\u91cc\u7a0b\u201d\u8ba1\u7b97\u5468\u8f6c\u91cf\uff0c\u5df2\u67e5\u660e\u4e3a\u516c\u5f0f\u9519\u8bef\u30021\u20149\u6708\u6708\u62a5\u5468\u8f6c\u91cf\u5408\u8ba1{fmt_wan_ton_km(KAIXIANGDA_TOTAL_REPORT)}\u4e07\u5428\u516c\u91cc\uff0c\u53f0\u8d26\u9010\u884c\u6b63\u786e\u5408\u8ba1{fmt_wan_ton_km(KAIXIANGDA_TOTAL_CORRECT)}\u4e07\u5428\u516c\u91cc\uff0c\u7d2f\u8ba1\u591a\u62a5{fmt_wan_ton_km(KAIXIANGDA_TOTAL_OVER)}\u4e07\u5428\u516c\u91cc\uff0c\u591a\u62a5\u7387{fmt_pct(KAIXIANGDA_TOTAL_RATE, False)}\u3002",
        )
    else:
        add_body(doc, f"12家企业中,{layer1_consistent}家月报与台账周转量差异率绝对值不超过1%,其余企业存在较大差异。")
    add_body(
        doc,
        f"1—9月月报周转量合计{fmt_wan_ton_km(KAIXIANGDA_TOTAL_REPORT)}万吨公里,台账逐行正确合计{fmt_wan_ton_km(KAIXIANGDA_TOTAL_CORRECT)}万吨公里,累计多报{fmt_wan_ton_km(KAIXIANGDA_TOTAL_OVER)}万吨公里,多报率{fmt_pct(KAIXIANGDA_TOTAL_RATE, False)}。",
    )
    add_caption(doc, "表2  宜昌凯祥达1—9月周转量汇总核查结果")
    add_caption(doc, "\u88683  \u5b9c\u660c\u51ef\u7965\u8fbe1\u20149\u6708\u5468\u8f6c\u91cf\u6c47\u603b\u6838\u67e5\u7ed3\u679c")
    kxd_rows = [
        (month, fmt_wan_ton_km(report), fmt_wan_ton_km(correct), fmt_wan_ton_km(over), fmt_pct(rate, False))
        for month, report, correct, over, rate in KAIXIANGDA_MONTHLY
    ]
    kxd_rows.append((
        "合计",
        "\u5408\u8ba1",
        fmt_wan_ton_km(KAIXIANGDA_TOTAL_REPORT),
        fmt_wan_ton_km(KAIXIANGDA_TOTAL_CORRECT),
        fmt_wan_ton_km(KAIXIANGDA_TOTAL_OVER),
@@ -591,173 +799,140 @@
    ))
    kxd_table = add_table(
        doc,
        ["月份", "月报周转量(万吨公里)", "台账逐行正确合计(万吨公里)", "月报多报(万吨公里)", "多报率"],
        ["\u6708\u4efd", "\u6708\u62a5\u5468\u8f6c\u91cf\uff08\u4e07\u5428\u516c\u91cc\uff09", "\u53f0\u8d26\u6b63\u786e\u5408\u8ba1\uff08\u4e07\u5428\u516c\u91cc\uff09", "\u7d2f\u8ba1\u591a\u62a5\uff08\u4e07\u5428\u516c\u91cc\uff09", "\u591a\u62a5\u7387"],
        kxd_rows,
        [1.4, 3.5, 4.0, 3.3, 2.4],
        [1.3, 3.2, 3.6, 3.3, 2.2],
        [ALIGN_CENTER, ALIGN_RIGHT, ALIGN_RIGHT, ALIGN_RIGHT, ALIGN_RIGHT],
        header_size=10,
        body_size=9,
        header_size=12,
        body_size=12,
    )
    compact_table(kxd_table)
    add_body(
        doc,
        "数学上,“货运量合计×平均里程”只有在各趟里程或各趟货运量完全一致时才等于逐行合计,一般情况下既可能多报,也可能少报,方向取决于货运量与运距的相关性。凯祥达1—9月因短途载重较大、长途载重较小,错误公式结果各月均偏大。",
        "\u8be5\u9519\u8bef\u516c\u5f0f\u53ea\u6709\u5728\u5404\u8d9f\u91cc\u7a0b\u6216\u5404\u8d9f\u8d27\u8fd0\u91cf\u5b8c\u5168\u4e00\u81f4\u65f6\u624d\u7b49\u4e8e\u9010\u884c\u5408\u8ba1\uff0c\u4e00\u822c\u60c5\u51b5\u4e0b\u53ef\u80fd\u591a\u62a5\u6216\u5c11\u62a5\u3002\u51ef\u7965\u8fbe1\u20149\u6708\u5404\u6708\u5747\u8868\u73b0\u4e3a\u591a\u62a5\uff0c\u9700\u6309\u660e\u7ec6\u9010\u884c\u91cd\u7b97\u5e76\u8c03\u51cf\u3002",
    )
    add_heading(doc, "(二)台账里程与平台监测里程差异普遍较大", 2)
    add_heading(doc, "\uff08\u4e8c\uff09\u4f01\u4e1a\u53f0\u8d26\u91cc\u7a0b\u4e0e\u5e73\u53f0\u76d1\u6d4b\u91cc\u7a0b", 2)
    add_body(
        doc,
        f"12家企业台账车辆共{fmt_int(total_vehicles)}辆,其中无平台轨迹车辆{fmt_int(total_no_track)}辆,占{fmt_pct(no_track_ratio, False)}。台账里程合计{fmt_num(total_ledger_mileage, 2)}公里,平台监测里程合计{fmt_num(total_platform_mileage, 2)}公里,台账较平台高{fmt_pct(total_mileage_diff)}。按差异率正负30%的正常区间判断,仅{layer2_normal}家企业处于正常范围,{len(enterprises) - layer2_normal}家企业超出正常范围。",
        f"12\u5bb6\u4f01\u4e1a\u53f0\u8d26\u8f66\u8f86\u5171{fmt_int(total_vehicles)}\u8f86\uff0c\u5176\u4e2d\u65e0\u5e73\u53f0\u6708\u91cc\u7a0b\u8bb0\u5f55\u8f66\u8f86{fmt_int(total_no_track)}\u8f86\uff0c\u5360{fmt_pct(no_track_ratio, False)}\u3002\u53f0\u8d26\u91cc\u7a0b\u5408\u8ba1{fmt_num(total_ledger_mileage, 0)}\u516c\u91cc\uff0c\u5e73\u53f0\u76d1\u6d4b\u91cc\u7a0b\u5408\u8ba1{fmt_num(total_platform_mileage, 0)}\u516c\u91cc\uff0c\u53f0\u8d26\u8f83\u5e73\u53f0\u9ad8{fmt_pct(total_mileage_diff)}\u3002\u6309\u6b63\u8d1f30%\u7684\u6b63\u5e38\u533a\u95f4\u5224\u65ad\uff0c{layer2_normal}\u5bb6\u4f01\u4e1a\u5904\u4e8e\u6b63\u5e38\u8303\u56f4\uff0c{len(enterprises) - layer2_normal}\u5bb6\u4f01\u4e1a\u8d85\u51fa\u6b63\u5e38\u8303\u56f4\u3002",
    )
    if datong:
        add_body(
            doc,
            f"\u6e56\u5317\u5927\u901a\u4e34\u7a7a\u7269\u6d41\u6709\u9650\u516c\u53f8\u4f01\u4e1a\u53f0\u8d26\u4e0e\u5e73\u53f0\u91cc\u7a0b\u5dee\u5f02\u7387\u4e3a{fmt_pct(datong['mileage_diff'])}\uff0c\u5904\u4e8e\u6b63\u5e38\u8303\u56f4\uff1b\u5176\u4f5911\u5bb6\u4f01\u4e1a\u5747\u8d85\u51fa\u6b63\u5e38\u8303\u56f4\u3002",
        )
    add_section(doc, landscape=True)
    add_caption(doc, "表3  企业月报、台账与平台监测核查结果")
    enterprise_rows: List[Sequence[str]] = []
    add_caption(doc, "\u88684  \u4f01\u4e1a\u53f0\u8d26\u91cc\u7a0b\u4e0e\u5e73\u53f0\u76d1\u6d4b\u91cc\u7a0b\u6838\u67e5\u7ed3\u679c")
    mileage_groups = [
        ("\u5e8f\u53f7", ()),
        ("\u5e02\u5dde", ()),
        ("\u4f01\u4e1a", ()),
        ("\u53f0\u8d26\u8f66\u8f86\u6570", ()),
        ("\u91cc\u7a0b\uff08\u516c\u91cc\uff09", ("\u53f0\u8d26", "\u5e73\u53f0", "\u5dee\u5f02\u7387")),
        ("\u65e0\u8f68\u8ff9\u8f66\u8f86", ("\u6570\u91cf", "\u5360\u6bd4")),
        ("\u6838\u67e5\u5224\u65ad", ()),
    ]
    mileage_rows: List[Sequence[str]] = []
    for index, item in enumerate(enterprises, start=1):
        ledger_vehicles = int(item["ledger_vehicles"] or 0)
        no_track_vehicles = int(item["no_track"] or 0)
        no_track_ratio_item = no_track_vehicles / ledger_vehicles if ledger_vehicles else 0
        enterprise_rows.append((
            str(index),
            str(item["city"]),
            str(item["enterprise"]),
            fmt_int(ledger_vehicles),
            f"{fmt_wan_ton_km(item['month_turnover'])} / {fmt_wan_ton_km(item['ledger_turnover'])}",
            fmt_pct(item["report_vs_ledger"]),
            f"{fmt_num(item['ledger_mileage'], 0)} / {fmt_num(item['platform_mileage'], 0)}",
            fmt_pct(item["mileage_diff"]),
            fmt_int(no_track_vehicles),
            fmt_pct(no_track_ratio_item, False),
            enterprise_judgment(item),
        mileage_rows.append((
            str(index), short_city_name(item["city"]), str(item["enterprise"]), fmt_int(ledger_vehicles),
            fmt_num(item["ledger_mileage"], 0), fmt_num(item["platform_mileage"], 0), fmt_pct(item["mileage_diff"]),
            fmt_int(no_track_vehicles), fmt_pct(no_track_ratio_item, False), mileage_judgment(item),
        ))
    table2 = add_table(
    add_two_level_table(
        doc,
        ["序号", "市州", "企业", "台账车辆数", "月报/台账周转量(万吨公里)", "月报/台账周转量差异率", "台账/平台里程(公里)", "台账/平台里程差异率", "无轨迹车辆数", "无轨迹车辆占比", "核查判断"],
        enterprise_rows,
        [0.9, 1.2, 4.5, 1.4, 3.3, 1.6, 4.0, 1.6, 1.4, 1.7, 4.0],
        [ALIGN_CENTER, ALIGN_CENTER, ALIGN_LEFT, ALIGN_RIGHT, ALIGN_RIGHT, ALIGN_RIGHT, ALIGN_RIGHT, ALIGN_RIGHT, ALIGN_RIGHT, ALIGN_RIGHT, ALIGN_LEFT],
        header_size=8.5,
        body_size=8.5,
        mileage_groups,
        mileage_rows,
        [0.8, 1.1, 4.8, 1.4, 2.0, 2.0, 1.6, 1.4, 1.6, 9.0],
        [ALIGN_CENTER, ALIGN_CENTER, ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT, ALIGN_RIGHT,
         ALIGN_RIGHT, ALIGN_RIGHT, ALIGN_RIGHT, ALIGN_LEFT],
        header_size=12,
        body_size=10.5,
    )
    compact_table(table2)
    add_section(doc, landscape=False)
    if datong:
        add_body(
            doc,
            f"在12家企业中,湖北大通临空物流有限公司台账与平台里程差异率为{fmt_pct(datong['mileage_diff'])},处于正常区间;其余企业均超过正负30%。台账里程高于平台监测里程的特征较为集中。",
        )
    enterprise_formula_note = doc.add_paragraph()
    enterprise_formula_note.alignment = WD_ALIGN_PARAGRAPH.LEFT
    enterprise_formula_note.paragraph_format.first_line_indent = Pt(0)
    enterprise_formula_note.paragraph_format.space_before = Pt(2)
    enterprise_formula_note.paragraph_format.space_after = Pt(2)
    enterprise_formula_note.paragraph_format.line_spacing = Pt(16)
    enterprise_formula_run = enterprise_formula_note.add_run(
        "注:凯祥达9月差异已查明为台账周转量汇总公式错误,1—9月累计多报39.00%;详见前表及问题明细。"
    )
    set_run_font(enterprise_formula_run, BODY_FONT, 10.5, False)
    add_heading(doc, "(三)重点车辆轨迹精查均发现高风险问题", 2)
    add_heading(doc, "\uff08\u4e09\uff09\u91cd\u70b9\u8f66\u8f86\u8f68\u8ff9\u70b9\u7cbe\u67e5", 2)
    add_body(
        doc,
        f"12辆重点车辆共核验轨迹点{fmt_int(total_points)}个。轨迹核查显示,{route_mismatch}辆存在明确路线不符,{frequency_short}辆存在线路端点出现频次明显不足,{endpoint_uncheckable}辆因端点名称、设施名称或道路名称无法直接定位而不能完成完整线路核验。10辆车轨迹可支持趟次比例低于50%,12辆车均未达到台账申报趟次;可支持趟次比例最低为{fmt_pct(support_min, False)},最高为{fmt_pct(support_max, False)}。",
        f"12\u8f86\u91cd\u70b9\u8f66\u8f86\u5171\u6838\u9a8c\u8f68\u8ff9\u70b9{fmt_int(raw_points)}\u4e2a\u3002{route_mismatch}\u8f86\u7533\u62a5\u7ebf\u8def\u672a\u83b7\u8f68\u8ff9\u652f\u6301\uff1b\u5176\u4f59{len(vehicles) - route_mismatch}\u8f86\u7ebf\u8def\u65b9\u5411\u867d\u6709\u8f68\u8ff9\u652f\u6301\uff0c\u4f46\u53ef\u652f\u6301\u8d9f\u6b21\u6bd4\u4f8b\u5747\u672a\u8fbe\u5230100%\uff0c\u8303\u56f4{fmt_pct(supported_support_min, False)}\u2014{fmt_pct(supported_support_max, False)}\uff0c\u5176\u4e2d{support_below_half_supported}\u8f86\u4f4e\u4e8e50%\u3002{positive_days_30}\u8f86\u5e73\u53f0\u65e5\u91cc\u7a0b30\u5929\u603b\u91cc\u7a0b\u5747\u5927\u4e8e0\uff0c{positive_days_29}\u8f86\u4e3a29\u5929\uff0c\u53e6\u6709{positive_days_short}\u8f86\u4ec523\u5929\u603b\u91cc\u7a0b\u5927\u4e8e0\uff0c\u52a8\u6001\u76d1\u6d4b\u7ef4\u62a4\u5b58\u5728\u7f3a\u53e3\u3002\u8f68\u8ff9\u53ef\u652f\u6301\u8d9f\u6b21\u6bd4\u4f8b\u4ec5\u5bf9\u7ebf\u8def\u65b9\u5411\u83b7\u5f97\u8f68\u8ff9\u652f\u6301\u7684{len(vehicles) - route_mismatch}\u8f86\u8f66\u8ba1\u7b97\u3002",
    )
    add_section(doc, landscape=True)
    add_caption(doc, "表4  重点车辆轨迹核查结果")
    add_caption(doc, "\u88685  \u91cd\u70b9\u8f66\u8f86\u8f68\u8ff9\u6838\u67e5\u7ed3\u679c")
    sample_groups = [
        ("\u5e8f\u53f7", ()),
        ("\u5e02\u5dde", ()),
        ("\u4f01\u4e1a", ()),
        ("\u8f66\u724c\u53f7", ()),
        ("\u53f0\u8d26", ("\u8d9f\u6b21", "\u91cc\u7a0b\uff08\u516c\u91cc\uff09")),
        ("\u5e73\u53f0\u76d1\u6d4b", ("\u91cc\u7a0b\uff08\u516c\u91cc\uff09", "\u8f68\u8ff9\u70b9\u6570", "\u91cc\u7a0b\u5927\u4e8e0\u5929\u6570")),
        ("\u53f0\u8d26\u8f83\u5e73\u53f0\u91cc\u7a0b\u5dee\u5f02\u7387", ()),
        ("\u8f68\u8ff9\u53ef\u652f\u6301\u8d9f\u6b21\u6bd4\u4f8b", ()),
        ("\u6838\u67e5\u5224\u65ad", ()),
    ]
    sample_rows: List[Sequence[str]] = []
    for index, item in enumerate(samples, start=1):
    for index, item in enumerate(enterprises, start=1):
        vehicle = vehicles_by_enterprise[str(item["enterprise"])]
        sample_rows.append((
            str(index),
            str(item["city"]),
            str(item["enterprise"]),
            str(item["plate"]),
            f"{fmt_num(item['ledger_mileage'], 2)} / {fmt_num(item['platform_mileage'], 2)}",
            fmt_pct(item["mileage_diff"]),
            fmt_int(item["points"]),
            fmt_pct(item["support_ratio"], False),
            item["judgment"],
            str(index), short_city_name(item["city"]), str(item["enterprise"]), str(vehicle["plate"]),
            fmt_num(vehicle["ledger"]["trips"], 0), fmt_num(vehicle["ledger"]["mileage"], 2),
            fmt_num(vehicle["platform"]["total_mileage"], 2), fmt_int(vehicle["points"]["valid_point_count"]),
            str(int(vehicle["platform"].get("positive_mileage_days") or 0)),
            fmt_pct(vehicle["comparison"].get("ledger_vs_platform_rate")), ("\u2014" if strict_missing_endpoints(vehicle) else fmt_pct(sample_support(vehicle), False)),
            sample_judgment(vehicle),
        ))
    table3 = add_table(
    add_two_level_table(
        doc,
        ["序号", "市州", "企业", "车牌号", "台账/平台里程(公里)", "里程差异率", "轨迹点数", "可支持趟次比例", "核查判断"],
        sample_groups,
        sample_rows,
        [1.2, 1.3, 5.4, 2.2, 4.0, 2.6, 2.2, 2.8, 3.8],
        [ALIGN_CENTER, ALIGN_CENTER, ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT, ALIGN_RIGHT, ALIGN_RIGHT, ALIGN_RIGHT, ALIGN_CENTER],
        [0.8, 1.1, 4.2, 1.8, 1.2, 1.7, 1.7, 1.8, 1.5, 2.0, 2.2, 5.7],
        [ALIGN_CENTER, ALIGN_CENTER, ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT, ALIGN_RIGHT,
         ALIGN_RIGHT, ALIGN_RIGHT, ALIGN_CENTER, ALIGN_CENTER, ALIGN_CENTER, ALIGN_LEFT],
        header_size=12,
        body_size=10.5,
    )
    compact_table(table3)
    add_section(doc, landscape=False)
    add_heading(doc, "四、主要问题")
    add_heading(doc, "\u56db\u3001\u4f01\u4e1a\u95ee\u9898\u6c47\u603b")
    add_body(
        doc,
        "企业周转量月度汇总公式错误,造成1—9月累计多报。宜昌凯祥达物流有限公司1—9月台账均以“货运量合计×平均里程”代替逐行“货运量×该趟里程”的合计,月报周转量合计16,765.20万吨公里,台账逐行正确合计12,061.67万吨公里,累计多报4,703.53万吨公里,多报39.00%。本次仅抽查12家企业,而全省2026年规上货运企业共636家,其他企业存在同类公式错误的可能,需组织开展全面筛查。",
        "(一)",
    )
    add_body(
        doc,
        "台账里程申报普遍高于平台监测里程。除湖北大通临空物流有限公司外,其余11家企业台账与平台里程差异率均超出正负30%,台账合计里程较平台高134.89%,说明差异不是个别车辆造成,而是企业台账层面存在普遍性。",
        "(二)",
    )
    add_body(
        doc,
        "部分企业申报线路与车辆实际活动区域明显不符。以抽查车辆为例,湖北安欣物流有限责任公司鄂L1N523未监测到天津、崇阳;湖北大通临空物流有限公司鄂J20052D未监测到浠水,主要活动区域为安徽池州、铜陵;宜昌凯祥达物流有限公司鄂E68056未监测到北海、浙江,主要活动区域集中在宜昌市。相关轨迹不能支持台账申报的运输线路。",
        "(三)",
    )
    add_body(
        doc,
        "台账申报趟次与轨迹可支持趟次存在明显差距。12辆重点车辆按台账平均单趟里程折算,平台轨迹可支持趟次比例均低于100%,其中10辆低于50%。部分车辆台账申报趟次较高,但车辆整月活动范围有限,需进一步核对运输任务源、运单、货运单和装卸货记录。",
        "(四)",
    )
    add_body(
        doc,
        "无平台轨迹车辆占比较高。579辆台账车辆中有64辆没有平台监测轨迹,占11.05%。对上述车辆,应区分未接入平台、车牌信息不一致、停运和漏报等不同情形,不能直接认定为未运输,也不能在缺少依据的情况下继续计入台账里程。",
        "(五)",
        "\u4f01\u4e1a\u9010\u9879\u6838\u67e5\u95ee\u9898\u3001\u6d89\u53ca\u8f66\u8f86\u3001\u53f0\u8d26\u60c5\u51b5\u3001\u6708\u62a5\u53ca\u5e73\u53f0\u76d1\u6d4b\u60c5\u51b5\u3001\u6838\u67e5\u7ed3\u8bba\u548c\u6838\u67e5\u4f9d\u636e\uff0c\u8be6\u89c1\u9644\u4ef6\u300a2026\u5e749\u6708\u4f01\u4e1a\u53f0\u8d26\u62bd\u67e5\u6838\u67e5\u95ee\u9898\u6c47\u603b\u8868.xlsx\u300b\u3002",
    )
    add_heading(doc, "五、核查结论")
    add_heading(doc, "\u4e94\u3001\u5904\u7406\u5efa\u8bae")
    add_body(
        doc,
        "宜昌凯祥达物流有限公司1—9月周转量汇总公式错误已经查实:月报合计16,765.20万吨公里,台账逐行正确合计12,061.67万吨公里,累计多报4,703.53万吨公里,多报39.00%。该问题说明,月报与台账数值一致不能替代对计算过程和原始明细的核查。本次仅抽查12家企业,而2026年全省规上货运企业共636家,同类模板或同类公式错误可能在其他企业存在,需将周转量汇总公式纳入全省规上企业专项筛查。",
        "\u8981\u6c42\u5b9c\u660c\u51ef\u7965\u8fbe\u7269\u6d41\u6709\u9650\u516c\u53f8\u7acb\u5373\u5c06\u5468\u8f6c\u91cf\u6c47\u603b\u516c\u5f0f\u6539\u4e3a\u9010\u884c\u201c\u8d27\u8fd0\u91cf\u00d7\u8be5\u8d9f\u91cc\u7a0b\u201d\u6c42\u548c\uff0c\u5e76\u5bf91\u20149\u6708\u591a\u62a5\u7684\u6570\u636e\u62ff\u51fa\u8c03\u51cf\u65b9\u6848\u3002",
        "\uff08\u4e00\uff09",
    )
    add_body(
        doc,
        "除上述公式问题外,台账里程申报与平台监测差异仍然突出。台账里程合计较平台监测里程高134.89%,11家企业超出正负30%的正常范围;12辆重点车辆轨迹均存在高风险问题,其中7辆明确表现为申报线路与车辆实际活动区域不符。",
        "\u5bf92026\u5e74636\u5bb6\u89c4\u4e0a\u8d27\u8fd0\u4f01\u4e1a\u7ec4\u7ec7\u5f00\u5c55\u5468\u8f6c\u91cf\u6c47\u603b\u516c\u5f0f\u4e13\u9879\u7b5b\u67e5\uff0c\u9010\u6237\u4ee5\u660e\u7ec6\u884c\u91cd\u7b971\u20149\u6708\u53ca\u7d2f\u8ba1\u5468\u8f6c\u91cf\uff0c\u65e2\u8bc6\u522b\u591a\u62a5\uff0c\u4e5f\u8bc6\u522b\u5c11\u62a5\u3002",
        "\uff08\u4e8c\uff09",
    )
    add_body(
        doc,
        "本次结论针对抽查的3个市州、12家企业、12辆重点车辆和凯祥达1—9月周转量公式复核结果,不直接认定其他企业存在同类问题。现有轨迹证据能够支持对车辆活动区域、里程规模和线路方向的判断,但货车实际载重、每趟装卸货事实和运输合同履行情况,仍需结合企业原始凭据进一步核实。",
    )
    add_heading(doc, "六、处理建议")
    add_body(
        doc,
        "要求宜昌凯祥达物流有限公司立即将周转量汇总公式改为逐行“货运量×该趟里程”求和,并对1—9月多报的数据拿出调减方案。",
        "(一)",
        "\u5bf9\u53f0\u8d26\u91cc\u7a0b\u4e0e\u5e73\u53f0\u91cc\u7a0b\u5dee\u5f02\u8d85\u8fc730%\u768411\u5bb6\u4f01\u4e1a\uff0c\u8981\u6c42\u9010\u8f66\u8bf4\u660e\u539f\u56e0\uff0c\u5e76\u63d0\u4f9b\u8fd0\u8f93\u4efb\u52a1\u6e90\u3001\u8fd0\u5355\u3001\u8fc7\u78c5\u5355\u3001\u88c5\u5378\u8d27\u8bb0\u5f55\u548c\u8fd0\u8f93\u5408\u540c\u7b49\u539f\u59cb\u8d44\u6599\u3002",
        "\uff08\u4e09\uff09",
    )
    add_body(
        doc,
        "对2026年636家规上货运企业组织开展周转量汇总公式专项筛查,重点检查台账是否使用“货运量合计×平均里程”等错误算法。逐户以明细行“货运量×该趟里程”重算1—9月及累计周转量,既识别多报,也识别少报,不预设方向。",
        "(二)",
        "\u5bf964\u8f86\u65e0\u5e73\u53f0\u6708\u91cc\u7a0b\u8bb0\u5f55\u8f66\u8f86\u5f00\u5c55\u4e13\u9879\u6e05\u7406\uff0c\u9010\u8f66\u6838\u5b9e\u63a5\u5165\u72b6\u6001\u3001\u8f66\u724c\u4fe1\u606f\u3001\u8fd0\u8425\u72b6\u6001\u548c\u53f0\u8d26\u586b\u62a5\u60c5\u51b5\uff1b\u5bf9\u5e73\u53f0\u603b\u91cc\u7a0b\u5927\u4e8e0\u5929\u6570\u4e0d\u8db330\u5929\u7684\u91cd\u70b9\u8f66\u8f86\uff0c\u6838\u5b9e\u8f66\u8f7d\u7ec8\u7aef\u5728\u7ebf\u548c\u8fd0\u884c\u72b6\u6001\u3002",
        "\uff08\u56db\uff09",
    )
    add_body(
        doc,
        "在专项筛查基础上,举一反三检查其他月度汇总指标及年度累计公式,重点核对月度合计是否等于明细行求和、年度累计是否等于各月校正值之和,并对使用平均数和比例派生指标的情形逐项验证统计口径。",
        "(三)",
        "\u5bf9\u7533\u62a5\u7ebf\u8def\u672a\u83b7\u8f68\u8ff9\u652f\u6301\u3001\u7ebf\u8def\u7aef\u70b9\u51fa\u73b0\u9891\u6b21\u4e0d\u8db3\u7684\u8f66\u8f86\uff0c\u7ed3\u5408\u8c03\u5ea6\u8bb0\u5f55\u3001\u88c5\u5378\u8d27\u5730\u70b9\u3001\u9ad8\u901f\u516c\u8def\u901a\u884c\u8bb0\u5f55\u7b49\u5f00\u5c55\u590d\u6838\u3002",
        "\uff08\u4e94\uff09",
    )
    add_body(
        doc,
        "对11家台账与平台里程差异超过30%的企业,要求逐车说明原因,并提供运输任务源、运单、货运单、过磅单、装卸货记录和运输合同等原始资料。对台账里程明显偏高且无法提供有效运输凭据的,按程序进一步核实。",
        "(四)",
    )
    add_body(
        doc,
        "对64辆无平台轨迹车辆开展专项清理,逐车核实接入状态、车牌信息、运营状态和台账填报情况;对轨迹显示线路不符、端点频次不足或无法定位的车辆,结合调度记录、装卸货地点和高速公路通行记录开展复核。",
        "(五)",
    )
    add_body(
        doc,
        "督促企业规范建立月度运输台账,做到车辆、日期、线路、趟次、里程、货运量和周转量相互对应,并保留可核验的原始运输凭据。",
        "(六)",
        "\u7763\u4fc3\u4f01\u4e1a\u89c4\u8303\u5efa\u7acb\u6708\u5ea6\u8fd0\u8f93\u53f0\u8d26\uff0c\u505a\u5230\u8f66\u8f86\u3001\u65e5\u671f\u3001\u7ebf\u8def\u3001\u8d9f\u6b21\u3001\u91cc\u7a0b\u3001\u8d27\u8fd0\u91cf\u548c\u5468\u8f6c\u91cf\u76f8\u4e92\u5bf9\u5e94\uff1b\u540c\u6b65\u843d\u5b9e\u8f66\u8f86\u52a8\u6001\u76d1\u63a7\u8bbe\u5907\u7ef4\u62a4\u548c\u5f02\u5e38\u6570\u636e\u5904\u7f6e\u8d23\u4efb\u3002",
        "\uff08\u516d\uff09",
    )
    signature = doc.add_paragraph()
@@ -766,17 +941,8 @@
    signature.paragraph_format.space_before = Pt(18)
    signature.paragraph_format.space_after = Pt(0)
    signature.paragraph_format.line_spacing = Pt(30)
    signature_run = signature.add_run("2026年10月28日")
    signature_run = signature.add_run("2026\u5e7410\u670829\u65e5")
    set_run_font(signature_run, BODY_FONT, 16, False)
    attachment = doc.add_paragraph()
    attachment.alignment = WD_ALIGN_PARAGRAPH.LEFT
    attachment.paragraph_format.first_line_indent = Pt(0)
    attachment.paragraph_format.space_before = Pt(14)
    attachment.paragraph_format.space_after = Pt(0)
    attachment.paragraph_format.line_spacing = Pt(24)
    attachment_run = attachment.add_run("附件:" + attachment_name)
    set_run_font(attachment_run, BODY_FONT, 14, False)
    output_path.parent.mkdir(parents=True, exist_ok=True)
    doc.save(output_path)
@@ -785,15 +951,17 @@
def main() -> int:
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument("--workbook", required=True)
    parser.add_argument("--diagnostics", required=True)
    parser.add_argument("--output", required=True)
    parser.add_argument("--attachment", default="")
    args = parser.parse_args()
    workbook = Path(args.workbook)
    diagnostics = Path(args.diagnostics)
    output = Path(args.output)
    if not workbook.is_file():
        raise SystemExit("workbook not found: %s" % workbook)
    attachment_name = args.attachment or workbook.name
    build_report(workbook, output, attachment_name)
    if not diagnostics.is_file():
        raise SystemExit("diagnostics not found: %s" % diagnostics)
    build_report(workbook, diagnostics, output)
    print(str(output))
    return 0