refactor: 下沉资料包列表上下文到 documents 服务层
This commit is contained in:
@@ -1,15 +1,13 @@
|
||||
from django.contrib import messages
|
||||
from django.db.models import Q
|
||||
from django.shortcuts import get_object_or_404, redirect, render
|
||||
from django.views.decorators.http import require_POST
|
||||
|
||||
from apps.scenarios.services import list_scenarios
|
||||
|
||||
from .forms import DocumentUploadForm
|
||||
from .models import SubmissionBatch, UploadedDocument
|
||||
from .models import UploadedDocument
|
||||
from .services import (
|
||||
build_batch_rows,
|
||||
build_exception_items,
|
||||
build_document_list_context,
|
||||
import_submission_batch,
|
||||
index_document,
|
||||
)
|
||||
@@ -17,48 +15,8 @@ from .services import (
|
||||
|
||||
def document_list(request):
|
||||
# 资料包页展示批次、会话绑定和关键异常,同时保留文档级明细便于演示。
|
||||
keyword = (request.GET.get("keyword") or "").strip()
|
||||
batches = SubmissionBatch.objects.all()
|
||||
if keyword:
|
||||
batches = batches.filter(
|
||||
Q(product_name__icontains=keyword) | Q(batch_id__icontains=keyword)
|
||||
)
|
||||
batches = list(batches)
|
||||
documents = list(UploadedDocument.objects.all())
|
||||
status_counts = {
|
||||
"pending": sum(
|
||||
1 for batch in batches if batch.import_status == SubmissionBatch.STATUS_PENDING
|
||||
),
|
||||
"completed": sum(
|
||||
1 for batch in batches if batch.import_status == SubmissionBatch.STATUS_COMPLETED
|
||||
),
|
||||
"review_required": sum(
|
||||
1
|
||||
for batch in batches
|
||||
if batch.import_status == SubmissionBatch.STATUS_REVIEW_REQUIRED
|
||||
),
|
||||
"total": len(batches),
|
||||
}
|
||||
processing_pipeline = [
|
||||
{"title": "原始文件接收", "detail": "校验格式、大小和场景归属后保存原件。"},
|
||||
{"title": "文本与表格抽取", "detail": "按 PDF / DOCX / MD / TXT 使用不同解析策略。"},
|
||||
{"title": "页数统计与可信度评估", "detail": "对 Word 页数采用估算与可信度标记。"},
|
||||
{"title": "章节点归类", "detail": "基于文件名、标题和正文线索识别 CH 节点。"},
|
||||
{"title": "切片与索引入库", "detail": "生成知识切片,供 RAG、规则定位和审计引用使用。"},
|
||||
]
|
||||
return render(
|
||||
request,
|
||||
"documents/document_list.html",
|
||||
{
|
||||
"documents": documents,
|
||||
"batches": batches,
|
||||
"batch_rows": build_batch_rows(batches),
|
||||
"keyword": keyword,
|
||||
"status_counts": status_counts,
|
||||
"processing_pipeline": processing_pipeline,
|
||||
"exception_items": build_exception_items(batches, documents),
|
||||
},
|
||||
)
|
||||
context = build_document_list_context(keyword=(request.GET.get("keyword") or "").strip())
|
||||
return render(request, "documents/document_list.html", context)
|
||||
|
||||
|
||||
def upload(request):
|
||||
|
||||
Reference in New Issue
Block a user