Merge branch 'dev' into picture-feedback
This commit is contained in:
commit
34ad40778b
180 files changed
+13262
-5333
No files matched your search
@@ -43,7 +43,7 @@ def _ok(data, *, status: int = 200):
|
||||
@admin_bp.route('/freight-rpa/rpa-profiles', methods=['GET'])
|
||||
@require_admin
|
||||
def list_shipping_rpa_profiles():
|
||||
"""列出脱敏后的 RPA Profile 配置。"""
|
||||
"""列出 RPA Profile;响应含用户名明文,不含密码与密文。"""
|
||||
return _ok(freight_rpa_source_admin_service.list_profiles())
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ def create_shipping_rpa_profile():
|
||||
@admin_bp.route('/freight-rpa/rpa-profiles/<int:profile_id>', methods=['PUT'])
|
||||
@require_admin
|
||||
def update_shipping_rpa_profile(profile_id: int):
|
||||
"""更新 RPA Profile;未提交密码字段时保留既有密文。"""
|
||||
"""更新 RPA Profile;用户名与已存明文相同、或密码留空时不重写对应密文。"""
|
||||
return _ok(freight_rpa_source_admin_service.save_profile(request.get_json(silent=True) or {}, actor_id=_actor_id(), profile_id=profile_id))
|
||||
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ backend/app/api/contract_payment/__init__.py
|
||||
依赖:JWT 当前用户、统一响应 envelope、ForbiddenError、Agent 授权、contract_payment 服务和通用 Job 队列。
|
||||
逻辑:页面查询合同、节点、本周待发送摘要、四张汇总卡和周汇总批次;失败批次返回可展示原因。同步和预警操作入队,避免请求线程执行外部系统和企微调用;发送后可按 Job 查询是否真正完成。
|
||||
下载和单合同重解析走 read_contract_attachment_bytes:原文还在则直接读,被临时清理删掉则按附件 ID 从 OA/DMS 重新下载。
|
||||
待确认合同的人工复核走 apply_manual_review:比例合计 100% 后改为已解析并进入台账。未付的预付款、出货款可手动标为已付。
|
||||
待确认合同的人工复核走 apply_manual_review:比例合计 100% 后改为已解析并进入台账。四个付款阶段未付时都可手动标为已付。
|
||||
合同序列化时对 parse_issues 去重,避免 MinerU 重复抽取把同一原因展示多遍;同时返回 OA 公司及对应 ERP 账套。
|
||||
鉴权:查询接口要求平台管理员(is_platform_admin)或持有 `agent_code=contract_payment` 的 Agent 授权;
|
||||
同步/扫描/周汇总发送仅平台管理员。权限组启用后,普通用户通过角色包获得该 Agent,不再按人授权。
|
||||
@@ -641,9 +641,9 @@ def manual_review_contract(contract_id: int):
|
||||
@contract_payment_bp.route("/contracts/<int:contract_id>/nodes/<int:node_id>/mark-paid", methods=["POST"])
|
||||
def mark_contract_node_paid(contract_id: int, node_id: int):
|
||||
"""
|
||||
把未付的预付款或出货款手动标为已付。
|
||||
把未付的付款阶段手动标为已付。
|
||||
|
||||
核心逻辑:与人工复核一样,持有合同付款 Agent 的用户即可提交。只改这一阶段,并关闭尚未发送的预警。
|
||||
核心逻辑:与人工复核一样,持有合同付款 Agent 的用户即可提交。四个阶段都可以标记,只改这一阶段,并关闭尚未发送的预警。
|
||||
|
||||
Args:
|
||||
contract_id: 合同台账主键。
|
||||
|
||||
@@ -110,7 +110,7 @@ def sync_equipment_acceptance():
|
||||
|
||||
@equipment_acceptance_bp.route("/orders", methods=["GET"])
|
||||
def list_equipment_acceptance_orders():
|
||||
"""分页查看已同步的验收单。focus 按原型分组过滤,summary 始终统计全部单据。"""
|
||||
"""分页查看已同步的验收单。focus 按状态分组,keyword 查三种单号,applicant 查申请人。"""
|
||||
_require_equipment_acceptance_access()
|
||||
page = _int_arg("page", 1)
|
||||
page_size = _int_arg("page_size", 20)
|
||||
@@ -119,6 +119,8 @@ def list_equipment_acceptance_orders():
|
||||
focus=request.args.get("focus"),
|
||||
page=page,
|
||||
page_size=page_size,
|
||||
keyword=request.args.get("keyword"),
|
||||
applicant=request.args.get("applicant"),
|
||||
)
|
||||
return ok(payload, request_id=getattr(g, "request_id", None))
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ backend/app/api/freight_rpa.py
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from flask import Blueprint, jsonify, request
|
||||
from flask import Blueprint, current_app, jsonify, request
|
||||
|
||||
from app.core.errors import ValidationError
|
||||
from app.core.tool_auth import require_tool_auth
|
||||
@@ -65,6 +65,12 @@ def heartbeat():
|
||||
except ValueError as exc:
|
||||
raise ValidationError(str(exc))
|
||||
# 心跳存储不可用(ServiceUnavailableError)原样上抛,由全局 AppError handler 出标准错误 envelope。
|
||||
# 到期的 Crane 定时回查跟着心跳落成 trigger;写失败不让心跳本身失败。
|
||||
try:
|
||||
from app.services.freight_rpa.upload.crane_recheck import materialize_due_crane_rechecks
|
||||
materialize_due_crane_rechecks()
|
||||
except Exception:
|
||||
current_app.logger.exception('crane recheck materialize failed')
|
||||
return jsonify({'status': 'ok', 'message': 'heartbeat recorded', 'data': worker})
|
||||
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -1102,6 +1102,47 @@ def workspace_confirm_shipping_notice_uploaded(business_no: str):
|
||||
))
|
||||
|
||||
|
||||
@workspace_shipping_notice_bp.route('/shipping-notices/<business_no>/refresh-crane-upload', methods=['POST'])
|
||||
def workspace_refresh_crane_upload_status(business_no: str):
|
||||
"""手动刷新一张仍在分配中的 Crane 发货单。
|
||||
|
||||
核心逻辑:校验当前用户可见的通知单,读取最近一次上传尝试,写入一条只查状态的 trigger。
|
||||
不改 10 分钟定时回查的到期时间,也不重新上传 Excel。
|
||||
|
||||
Args:
|
||||
business_no: 对外发货通知单号,同时是 Crane 的 Pull Request #。
|
||||
|
||||
Returns:
|
||||
JSON: business_no 与 trigger_queued。
|
||||
|
||||
Raises:
|
||||
ValidationError: 没有可刷新的上传尝试或来源连接。
|
||||
ConflictError: 当前不是分配中,或上一次手动刷新还在排队。
|
||||
"""
|
||||
user = _require_user()
|
||||
task = _load_business_notice_for_user(business_no=business_no, user_id=int(user.id))
|
||||
from app.services.freight_rpa.upload.crane_recheck import request_manual_crane_refresh
|
||||
from app.services.shipping_notice.onhand_source_rules import task_rpa_inventory_source
|
||||
from app.services.shipping_notice.onhand_source_repository import get_rpa_trigger_inventory_source
|
||||
from app.services.shipping_notice.upload_attempt_service import latest_upload_attempt
|
||||
|
||||
attempt = latest_upload_attempt(task)
|
||||
from app.models import ShippingExportArtifact
|
||||
artifact = db.session.get(ShippingExportArtifact, attempt.artifact_id) if attempt is not None else None
|
||||
snapshot = task_rpa_inventory_source(task) or {}
|
||||
upload_source = get_rpa_trigger_inventory_source(str(snapshot.get('source_code') or '')) if snapshot.get('source_code') else None
|
||||
if attempt is None or artifact is None or not isinstance(upload_source, dict):
|
||||
raise ValidationError('Crane upload status cannot be refreshed', code='SHIPPING.UPLOAD_CRANE_ALLOCATING')
|
||||
trigger_path = request_manual_crane_refresh(
|
||||
attempt,
|
||||
upload_source,
|
||||
task_no=str(task.task_no),
|
||||
export_file_path=str(artifact.file_path or ''),
|
||||
)
|
||||
db.session.commit()
|
||||
return _ok({'business_no': str(task.business_no), 'trigger_queued': bool(trigger_path)})
|
||||
|
||||
|
||||
@workspace_shipping_notice_bp.route('/shipping-notices/<business_no>/rpa-upload', methods=['POST'])
|
||||
def workspace_start_shipping_notice_rpa_upload(business_no: str):
|
||||
"""按发货通知单号发起 RPA 上传;RPA 成功事实仍由受信回调裁决。"""
|
||||
|
||||
@@ -4,17 +4,20 @@ backend/app/api/workspace/voucher_check.py
|
||||
用途:立账凭证检核查询、强制重检与通知配置 API(任务列表 / 最近一次检核 / 批次明细 / 企微发送记录 / 按类型接收人)。
|
||||
依赖:auth.jwt、response_utils envelope、Agent 授权、voucher_check.query_service、notify_config_service。
|
||||
逻辑:Chat Agent 与旧工作台查询共用;GET runs/latest 不跟筛选;GET notifications 为企微发送记录;
|
||||
批次明细可按 result 与 invoice_no 筛选。企微记录里的 Excel 走本模块下载,不走排程通知人权限。
|
||||
查询要求 is_platform_admin 或持有 `agent_code=voucher_check` 的 Agent 授权;POST runs 与通知配置仅平台管理员。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from flask import Blueprint, request
|
||||
from io import BytesIO
|
||||
|
||||
from flask import Blueprint, request, send_file
|
||||
|
||||
from app.core.auth.jwt import get_current_user
|
||||
from app.core.errors import ForbiddenError, UnauthorizedError, ValidationError
|
||||
from app.core.errors import ForbiddenError, NotFoundError, UnauthorizedError, ValidationError
|
||||
from app.core.response import ok
|
||||
from app.models import Agent
|
||||
from app.models import Agent, ScheduleRun, VoucherCheckRun
|
||||
from app.services.voucher_check import notify_config_service, query_service
|
||||
|
||||
workspace_voucher_check_bp = Blueprint("workspace_voucher_check", __name__)
|
||||
@@ -149,12 +152,13 @@ def workspace_voucher_latest_run():
|
||||
def workspace_voucher_run_items(run_id: int):
|
||||
"""
|
||||
分页查看批次明细。
|
||||
核心逻辑:委托 query_service.list_run_items,可按 result 过滤,并返回 by_file_type。
|
||||
核心逻辑:委托 query_service.list_run_items,可按 result 与 invoice_no 过滤,并返回 by_file_type。
|
||||
"""
|
||||
_require_voucher_check_access()
|
||||
data = query_service.list_run_items(
|
||||
run_id=run_id,
|
||||
result=request.args.get("result"),
|
||||
invoice_no=request.args.get("invoice_no"),
|
||||
page=request.args.get("page", default=1, type=int) or 1,
|
||||
page_size=request.args.get("page_size", default=50, type=int) or 50,
|
||||
)
|
||||
@@ -177,6 +181,33 @@ def workspace_voucher_notifications():
|
||||
return ok(data)
|
||||
|
||||
|
||||
@workspace_voucher_check_bp.route(
|
||||
"/accounting-voucher-check/schedule-runs/<int:schedule_run_id>/excel",
|
||||
methods=["GET"],
|
||||
)
|
||||
def workspace_voucher_schedule_excel(schedule_run_id: int):
|
||||
"""
|
||||
下载企微发送记录对应的检核结果 Excel。
|
||||
核心逻辑:能看发送记录的人即可下载。只放行已挂到立账凭证批次上的 ScheduleRun,不按排程负责人或通知人拦截。
|
||||
|
||||
Raises:
|
||||
NotFoundError: 该排程记录不是立账凭证批次,或还没有生成 Excel。
|
||||
"""
|
||||
_require_voucher_check_access()
|
||||
engine = VoucherCheckRun.query.filter_by(schedule_run_id=schedule_run_id).first()
|
||||
if engine is None:
|
||||
raise NotFoundError("立账凭证检核批次不存在", code="VOUCHER_CHECK.RUN_NOT_FOUND")
|
||||
run = ScheduleRun.query.get(schedule_run_id)
|
||||
if run is None or not run.excel_file_data:
|
||||
raise NotFoundError("检核结果 Excel 不存在", code="VOUCHER_CHECK.EXCEL_NOT_FOUND")
|
||||
return send_file(
|
||||
BytesIO(run.excel_file_data),
|
||||
as_attachment=True,
|
||||
download_name=run.excel_file_name or "voucher_check.xlsx",
|
||||
mimetype="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||
)
|
||||
|
||||
|
||||
@workspace_voucher_check_bp.route("/accounting-voucher-check/notify-config", methods=["GET"])
|
||||
def workspace_voucher_notify_config_get():
|
||||
"""
|
||||
|
||||
Reference in new issue
Block a user