Merge branch 'hugo-shipping-notice' into dev
# Conflicts: # frontend/src/features/chat/components/ChatViewContent.vue
This commit is contained in:
commit
80d78130f8
121 files changed
+9621
-1263
No files matched your search
@@ -199,6 +199,7 @@ def workspace_shipping_my_todos():
|
||||
todo_category=str(request.args.get('todo_category') or '').strip() or None,
|
||||
customer=str(request.args.get('customer') or '').strip() or None,
|
||||
task_no=str(request.args.get('task_no') or '').strip() or None,
|
||||
terminal_kind=str(request.args.get('terminal_kind') or '').strip() or None,
|
||||
))
|
||||
|
||||
|
||||
@@ -212,6 +213,67 @@ def workspace_shipping_my_todos_count():
|
||||
return _ok(count_my_todos(user.id, is_admin=is_admin))
|
||||
|
||||
|
||||
def _done_lines_report_params() -> dict[str, Any]:
|
||||
"""解析明细报表共用筛选参数(客户/料号/发货通知日期范围),供查询与导出复用。"""
|
||||
return {
|
||||
'customer': str(request.args.get('customer') or '').strip() or None,
|
||||
'part_number': str(request.args.get('part_number') or '').strip() or None,
|
||||
'notice_date_from': str(request.args.get('notice_date_from') or '').strip() or None,
|
||||
'notice_date_to': str(request.args.get('notice_date_to') or '').strip() or None,
|
||||
}
|
||||
|
||||
|
||||
@workspace_shipping_notice_bp.route('/shipping-tasks/my-todos/done-lines', methods=['GET'])
|
||||
def workspace_shipping_done_lines():
|
||||
"""
|
||||
分页列出已完成(已核验上传成功)通知的平铺明细行,供「通知完成」子视图报表。
|
||||
|
||||
核心逻辑:明细行跨 Notice 混排、不按 OT 聚合;支持 客户 / 料号 /
|
||||
发货通知日期范围 筛选;行结构为标准 12 字段 + 溯源编号(task_no/business_no)。
|
||||
"""
|
||||
user = _require_user()
|
||||
from app.services.shipping_notice.done_line_report import list_done_notice_lines
|
||||
|
||||
is_admin = str(getattr(user, 'role', '') or '').lower() == 'admin'
|
||||
try:
|
||||
page = int(request.args.get('page') or 1)
|
||||
page_size = int(request.args.get('page_size') or 20)
|
||||
except (TypeError, ValueError) as exc:
|
||||
raise ValidationError('page and page_size must be integers') from exc
|
||||
return _ok(list_done_notice_lines(
|
||||
user.id,
|
||||
is_admin=is_admin,
|
||||
page=page,
|
||||
page_size=page_size,
|
||||
**_done_lines_report_params(),
|
||||
))
|
||||
|
||||
|
||||
@workspace_shipping_notice_bp.route('/shipping-tasks/my-todos/done-lines/export', methods=['GET'])
|
||||
def workspace_shipping_done_lines_export():
|
||||
"""
|
||||
导出当前筛选下的已完成通知明细 Excel。
|
||||
|
||||
核心逻辑:固定 12 列标准格式(客户/客户编号/订单日期/订单项次/料号/数量/
|
||||
约定出货日期/客户PO/已用数量/open qty/订单单号/单价),OT 编号不落列;
|
||||
已用数量 / open qty 无数据源留空。
|
||||
"""
|
||||
user = _require_user()
|
||||
from app.services.shipping_notice.done_line_report import build_done_lines_xlsx
|
||||
|
||||
is_admin = str(getattr(user, 'role', '') or '').lower() == 'admin'
|
||||
stream, filename = build_done_lines_xlsx(
|
||||
user.id,
|
||||
is_admin=is_admin,
|
||||
**_done_lines_report_params(),
|
||||
)
|
||||
response = send_file(
|
||||
stream, as_attachment=True, download_name=filename, mimetype=EXPORT_MIME_TYPE,
|
||||
)
|
||||
response.call_on_close(stream.close)
|
||||
return response
|
||||
|
||||
|
||||
def _batch_task_nos(data: dict) -> list[str]:
|
||||
"""校验批量任务号,统一限制 100 条并去重,避免前端循环绕过服务端门禁。"""
|
||||
raw_task_nos = data.get('task_nos')
|
||||
@@ -481,6 +543,45 @@ def workspace_shipping_task_detail(task_no: str):
|
||||
))
|
||||
|
||||
|
||||
@workspace_shipping_notice_bp.route('/shipping-tasks/<task_no>/odm-options', methods=['GET'])
|
||||
def workspace_shipping_task_odm_options(task_no: str):
|
||||
"""返回整单 ODM ID 候选与当前选择(工作台整单裁决路径,只读)。"""
|
||||
user = _require_user()
|
||||
is_admin = str(getattr(user, 'role', '') or '').lower() == 'admin'
|
||||
from app.services.shipping_notice.notice_odm_choice_service import notice_odm_options
|
||||
from app.services.shipping_notice.query_service import get_task_visible_to_user
|
||||
|
||||
task = get_task_visible_to_user(task_no, user.id, is_admin=is_admin)
|
||||
if not task:
|
||||
raise NotFoundError('Not found')
|
||||
return _ok(notice_odm_options(task))
|
||||
|
||||
|
||||
@workspace_shipping_notice_bp.route('/shipping-tasks/<task_no>/odm-choice', methods=['POST'])
|
||||
def workspace_set_shipping_task_odm_choice(task_no: str):
|
||||
"""保存整单 ODM ID 用户选择;重复提交覆盖旧选择,成功后前端可重试生成 Excel。"""
|
||||
user = _require_user()
|
||||
is_admin = str(getattr(user, 'role', '') or '').lower() == 'admin'
|
||||
from app.services.shipping_notice.notice_odm_choice_service import set_notice_odm_choice
|
||||
from app.services.shipping_notice.query_service import get_task_visible_to_user
|
||||
|
||||
task = get_task_visible_to_user(task_no, user.id, is_admin=is_admin)
|
||||
if not task:
|
||||
raise NotFoundError('Not found')
|
||||
data = request.get_json(silent=True) or {}
|
||||
try:
|
||||
snapshot_line_id = int(data.get('snapshot_line_id') or 0)
|
||||
except (TypeError, ValueError):
|
||||
snapshot_line_id = 0
|
||||
result = set_notice_odm_choice(
|
||||
task,
|
||||
snapshot_line_id=snapshot_line_id,
|
||||
odm_id=str(data.get('odm_id') or ''),
|
||||
)
|
||||
db.session.commit()
|
||||
return _ok(result)
|
||||
|
||||
|
||||
@workspace_shipping_notice_bp.route('/shipping-tasks/<task_no>/audit-timeline', methods=['GET'])
|
||||
def workspace_list_shipping_task_audit_timeline(task_no: str):
|
||||
"""业务用户 Task 审计时间线(统一 ShippingAuditEvent,无敏感快照)。"""
|
||||
|
||||
Reference in new issue
Block a user