Merge branch 'dev' into picture-feedback

This commit is contained in:
HTEWJ\26070045 committed 2026-10-29 11:04:59 +08:00
commit 34ad40778b
180 files changed
+13262 -5333

No files matched your search

@@ -10,7 +10,8 @@
unconfigured 后再各写最多一个 batch;
证据下载(POST /sources/inbound-files)按同一函数打包各来源最新可用
入站/出站文件;当天清单(GET /sources/<code>/evidence-files)复用可用
条件返回当天全部文件,并分别签发预览地址与带保存名的下载地址;
条件返回当天全部文件;单文件下载(GET .../evidence-files/<file_id>)
由当前站点回传字节,不把 HTTP MinIO 地址交给 HTTPS 页面;
匹配创建(POST /matchings)与进度恢复(GET /matchings/{id});执行为 D8
异步契约(POST /items/execute → 202 queued + run_no,单在提交时组建);
result_unknown 单人工重新触发(POST /runs/{run_no}/documents/{doc_no}/
@@ -369,9 +370,9 @@ def list_source_evidence_files_api(source_code: str):
查询参数 record_kind 缺省 inbound,只接受 inbound 或 outbound。
可用条件与证据压缩包相同,但返回当天全部可用文件,不只最新一份。
每项含 file_id、original_filename、created_at、sha256、file_size、
presigned_url、download_url。不解析 Excel,不含行数。预览与下载各签一次
presigned_get_url(storage_key, expires_seconds=300);下载地址额外带
download_name(库存源_东八区年月日_时分.扩展名),避免浏览器用对象键哈希当保存名。
presigned_url、download_url。不解析 Excel,不含行数。预览仍打开
presigned_url。单文件下载不使用 download_url,改走
GET evidence-files/<file_id>,由当前站点回传。
签发时写 TRANSFER_INBOUND_FILES_DOWNLOADED,aggregate_id 为 source_code。
"""
from app.services.file_assets.storage import file_asset_storage
@@ -401,6 +402,47 @@ def list_source_evidence_files_api(source_code: str):
return _ok(payload)
@in_transit_transfer_bp.route("/sources/<source_code>/evidence-files/<int:file_id>", methods=["GET"])
@require_transfer_permission
def download_source_evidence_file_api(source_code: str, file_id: int):
"""把一份仍可用的证据文件经当前站点返回给浏览器。
查询参数 record_kind 缺省 inbound,只接受 inbound 或 outbound。
只接受该来源、该记录类型下仍在可用窗口内的归档。保存名用
evidence_download_filename。页面是 HTTPS,MinIO 公网地址是 HTTP,
直接打开预签名链接会被浏览器当成不安全下载拦掉。
Args:
source_code: 来源实例编码。
file_id: 归档文件主键。
Returns:
附件响应。找不到或已不可用时 404,错误码 SHIPPING.INBOUND_FILE_NOT_FOUND。
"""
import io
import mimetypes
from app.services.file_assets.storage import file_asset_storage
kind = str(request.args.get("record_kind") or "inbound").strip()
if kind not in {"inbound", "outbound"}:
raise ValidationError("record_kind must be inbound or outbound")
code = str(source_code or "").strip()
report = next((item for item in _usable_archive_files(code, kind) if item.id == file_id), None)
if report is None:
raise NotFoundError("evidence file is not available", code="SHIPPING.INBOUND_FILE_NOT_FOUND")
data = file_asset_storage.get_bytes(report.storage_key)
download_name = evidence_download_filename(code, report.created_at, report.original_filename)
_record_evidence_download_audit(aggregate_id=code)
mime = mimetypes.guess_type(download_name)[0] or "application/octet-stream"
return send_file(
io.BytesIO(data),
mimetype=mime,
as_attachment=True,
download_name=download_name,
)
@in_transit_transfer_bp.route("/runs/<run_no>", methods=["GET"])
@require_transfer_permission
def get_run_api(run_no: str):
@@ -1436,6 +1478,7 @@ def _serialize_backlog_item(item) -> dict[str, Any]:
'item_id': item.item_id,
'source_code': item.source_code,
'invoice_no': item.invoice_no,
'external_doc_no': item.external_doc_no,
'material_no': item.material_no,
'status': item.status,
'reason': item.reason,