feat(freight-rpa): 库存/收料改名在手/入站,报表归属RPA,类名统一FreightRpa
把 shipping 侧 inventory/receipt 词根迁到 onhand/inbound,29 张表与 枚举/权限/前端/i18n 同步改名;在手与入站报表配置及文件改由 freight_rpa 持有,发货与调拨仅按 source_code 消费;ORM 类加 FreightRpa 前缀, 上传动作改为 freight_rpa_upload。含类名与上传动作改名规格文档。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
ffc0d4a430
commit
39fe3c05f2
453 files changed
+17945
-8646
No files matched your search
@@ -12,7 +12,7 @@ from app.api.workspace.shipping_notice import workspace_shipping_notice_bp
|
||||
from app.api.workspace.voucher_check import workspace_voucher_check_bp
|
||||
|
||||
import app.api.workspace.shipping_process_gate # noqa: F401
|
||||
import app.api.workspace.shipping_inventory_candidates # noqa: F401
|
||||
import app.api.workspace.shipping_onhand_candidates # noqa: F401
|
||||
|
||||
__all__ = [
|
||||
'workspace_announcements_bp',
|
||||
|
||||
@@ -87,11 +87,11 @@ def _ok(payload: Any, *, status: int = 200):
|
||||
return ok(payload, request_id=getattr(g, 'request_id', None), status=status)
|
||||
|
||||
|
||||
@workspace_shipping_notice_bp.route('/receipt-report-files/<int:file_id>/download', methods=['GET'])
|
||||
@workspace_shipping_notice_bp.route('/inbound-report-files/<int:file_id>/download', methods=['GET'])
|
||||
def workspace_download_receipt_report_file(file_id: int):
|
||||
"""下载当前接收人或管理员有权读取的原样收料报表。"""
|
||||
user = _require_user()
|
||||
from app.services.shipping_notice.receipt_report_access import resolve_receipt_report_download
|
||||
from app.services.shipping_notice.inbound_report_access import resolve_receipt_report_download
|
||||
|
||||
stream, filename, content_type = resolve_receipt_report_download(file_id, user)
|
||||
response = send_file(
|
||||
@@ -102,7 +102,7 @@ def workspace_download_receipt_report_file(file_id: int):
|
||||
return response
|
||||
|
||||
|
||||
@workspace_shipping_notice_bp.route('/receipt-report-files', methods=['GET'])
|
||||
@workspace_shipping_notice_bp.route('/inbound-report-files', methods=['GET'])
|
||||
def workspace_list_receipt_report_files():
|
||||
"""列出当前接收人或管理员可下载的收料归档文件,不返回对象存储定位。"""
|
||||
user = _require_user()
|
||||
@@ -110,7 +110,7 @@ def workspace_list_receipt_report_files():
|
||||
limit = int(request.args.get('limit') or 100)
|
||||
except (TypeError, ValueError) as exc:
|
||||
raise ValidationError('limit must be an integer') from exc
|
||||
from app.services.shipping_notice.receipt_report_access import list_receipt_report_files
|
||||
from app.services.shipping_notice.inbound_report_access import list_receipt_report_files
|
||||
|
||||
return _ok({'items': list_receipt_report_files(user, limit=limit)})
|
||||
|
||||
@@ -1308,11 +1308,11 @@ def workspace_shipping_task_inventory_file(task_no: str):
|
||||
task = get_task_for_user(task_no, user.id)
|
||||
if not task:
|
||||
raise NotFoundError('Not found')
|
||||
from app.services.shipping_notice.inventory_file_store import resolve_task_inventory_download
|
||||
from app.services.shipping_notice.onhand_file_store import resolve_task_inventory_download
|
||||
|
||||
resolved = resolve_task_inventory_download(task)
|
||||
if resolved is None:
|
||||
raise NotFoundError('Inventory file not found', code='SHIPPING.TASK_INVENTORY_FILE_NOT_FOUND')
|
||||
raise NotFoundError('Inventory file not found', code='SHIPPING.TASK_ONHAND_FILE_NOT_FOUND')
|
||||
path, download_name = resolved
|
||||
from app.services.shipping_notice.fulfillment_audit import record_access_audit
|
||||
record_access_audit(
|
||||
@@ -1338,28 +1338,28 @@ def workspace_shipping_task_line_inventory_file(task_no: str, inventory_file_no:
|
||||
raise NotFoundError('Not found')
|
||||
from pathlib import Path
|
||||
|
||||
from app.models import ShippingInventoryFile, ShippingNoticeLineInventoryMatch
|
||||
from app.models import FreightRpaOnhandReportFile, ShippingNoticeLineOnhandMatch
|
||||
|
||||
requested_file_no = str(inventory_file_no or '').strip()
|
||||
inventory_file = (
|
||||
ShippingInventoryFile.query
|
||||
FreightRpaOnhandReportFile.query
|
||||
.join(
|
||||
ShippingNoticeLineInventoryMatch,
|
||||
ShippingNoticeLineInventoryMatch.inventory_snapshot_id == ShippingInventoryFile.id,
|
||||
ShippingNoticeLineOnhandMatch,
|
||||
ShippingNoticeLineOnhandMatch.onhand_snapshot_id == FreightRpaOnhandReportFile.id,
|
||||
)
|
||||
.filter(
|
||||
ShippingNoticeLineInventoryMatch.task_id == int(task.id),
|
||||
ShippingNoticeLineInventoryMatch.is_current.is_(True),
|
||||
ShippingNoticeLineInventoryMatch.matched_file_no == requested_file_no,
|
||||
ShippingInventoryFile.inventory_file_no == requested_file_no,
|
||||
ShippingNoticeLineOnhandMatch.task_id == int(task.id),
|
||||
ShippingNoticeLineOnhandMatch.is_current.is_(True),
|
||||
ShippingNoticeLineOnhandMatch.matched_file_no == requested_file_no,
|
||||
FreightRpaOnhandReportFile.onhand_file_no == requested_file_no,
|
||||
)
|
||||
.first()
|
||||
)
|
||||
storage_path = str(getattr(inventory_file, 'storage_path', '') or '').strip()
|
||||
path = Path(storage_path).resolve() if storage_path else None
|
||||
if inventory_file is None or not storage_path or storage_path.startswith('failed://') or not path.is_file():
|
||||
raise NotFoundError('Inventory file not found', code='SHIPPING.TASK_INVENTORY_FILE_NOT_FOUND')
|
||||
from app.services.shipping_notice.inventory_file_store import build_inventory_download_name
|
||||
raise NotFoundError('Inventory file not found', code='SHIPPING.TASK_ONHAND_FILE_NOT_FOUND')
|
||||
from app.services.shipping_notice.onhand_file_store import build_inventory_download_name
|
||||
download_name = build_inventory_download_name(
|
||||
inventory_file, source_file_name=inventory_file.source_file_name, path=path,
|
||||
)
|
||||
|
||||
+3
-3
@@ -1,8 +1,8 @@
|
||||
"""
|
||||
backend/app/api/workspace/shipping_inventory_candidates.py
|
||||
backend/app/api/workspace/shipping_onhand_candidates.py
|
||||
|
||||
用途:正式 Task 库存候选只读详情 API。
|
||||
依赖:workspace_shipping_notice_bp、query_service.get_task_for_user、inventory_candidate_projection。
|
||||
依赖:workspace_shipping_notice_bp、query_service.get_task_for_user、onhand_candidate_projection。
|
||||
逻辑:路由层仅做鉴权与查询参数校验;当前版本缺失返回 200 + current_set=null + blocking_reason,
|
||||
不把可恢复业务阻断误报成 404。
|
||||
"""
|
||||
@@ -13,7 +13,7 @@ from flask import request
|
||||
|
||||
from app.api.workspace.shipping_notice import _ok, _require_user, workspace_shipping_notice_bp
|
||||
from app.core.errors import ValidationError
|
||||
from app.services.shipping_notice.inventory_candidate_projection import (
|
||||
from app.services.shipping_notice.onhand_candidate_projection import (
|
||||
project_inventory_candidate_detail,
|
||||
)
|
||||
from app.services.shipping_notice.query_service import get_task_for_user
|
||||
Reference in new issue
Block a user