fix: 清除采购单号多余的汉字和空格
This commit is contained in:
1 parent
89c8da2990
commit
2df9bdda0d
8 files changed
+99
-17
No files matched your search
@@ -5,7 +5,7 @@ backend/app/services/contract_payment/sync_service.py
|
||||
依赖:ContractOaClient、acceptance_oa_service、ContractPayment* 模型、parse_service、file_assets.service。
|
||||
逻辑:合同申请单走 HTTP 待办/已办;验收归档走 OA SQL(formtable_main_324.cgdh × workflow_requestbase.currentnodetype=3);
|
||||
通知按 source_event_id 幂等;合同编号与采购单号以 OA 为准;列表翻页截断时入库但不推进增量断点;
|
||||
付款状态不再读取 OA 请款作业;合同 owner_user_id 由申请人真实姓名匹配系统用户,附件存储所有者仍可回退默认账号。
|
||||
付款状态不再读取 OA 请款作业;采购单号去掉首尾空格和汉字后再与 ERP 匹配。合同 owner_user_id 由申请人真实姓名匹配系统用户,附件存储所有者仍可回退默认账号。
|
||||
OA 合同金额为 0 或空时不当有效总额;正文抽出的正数在解析时回写台账,强制覆盖也不能把正数总额改成 0。
|
||||
OA/DMS 合同原文落库后标为已引用;临时清理删掉对象后,下载和重解析按附件 ID 重新下载。
|
||||
"""
|
||||
@@ -37,6 +37,7 @@ from app.services.contract_payment.acceptance_oa_service import (
|
||||
)
|
||||
from app.services.contract_payment.oa_client import ContractOaClient
|
||||
from app.services.contract_payment.dms_client import ContractDmsClient
|
||||
from app.services.contract_payment.erp_payment_service import normalize_purchase_order_no
|
||||
from app.services.contract_payment.parse_service import parse_contract_bytes, parse_contract_text, positive_amount
|
||||
from app.services.contract_payment.alert_service import bind_contract_owner_from_applicant
|
||||
from app.services.file_assets.service import (
|
||||
@@ -166,7 +167,7 @@ def sync_notifications(*, client: ContractOaClient | None = None, force: bool =
|
||||
if contract is None and contract_no:
|
||||
contract = db.session.query(ContractPaymentContract).filter_by(contract_no=contract_no).first()
|
||||
if contract is None and event_type == "acceptance_archive":
|
||||
purchase_order_no = str(item.get("purchase_order_no") or "").strip()
|
||||
purchase_order_no = normalize_purchase_order_no(item.get("purchase_order_no"))
|
||||
if purchase_order_no:
|
||||
contract = (
|
||||
db.session.query(ContractPaymentContract)
|
||||
@@ -177,7 +178,7 @@ def sync_notifications(*, client: ContractOaClient | None = None, force: bool =
|
||||
if contract is None:
|
||||
contract = ContractPaymentContract(
|
||||
contract_no=contract_no,
|
||||
purchase_order_no=str(item.get("purchase_order_no") or "").strip() or None,
|
||||
purchase_order_no=normalize_purchase_order_no(item.get("purchase_order_no")) or None,
|
||||
company_name=str(item.get("company_name") or "").strip() or None,
|
||||
supplier_name=str(item.get("supplier_name") or "").strip() or None,
|
||||
applicant_name=str(item.get("applicant_name") or "").strip() or None,
|
||||
@@ -198,7 +199,10 @@ def sync_notifications(*, client: ContractOaClient | None = None, force: bool =
|
||||
else:
|
||||
if force:
|
||||
overwritten += _overwrite_oa_fields(contract, item, operator_id=operator_id)
|
||||
contract.purchase_order_no = contract.purchase_order_no or str(item.get("purchase_order_no") or "").strip() or None
|
||||
stored_po = normalize_purchase_order_no(contract.purchase_order_no) or None
|
||||
if stored_po != (str(contract.purchase_order_no or "").strip() or None):
|
||||
contract.purchase_order_no = stored_po
|
||||
contract.purchase_order_no = contract.purchase_order_no or normalize_purchase_order_no(item.get("purchase_order_no")) or None
|
||||
incoming_company = str(item.get("company_name") or "").strip()
|
||||
stored_company = str(contract.company_name or "").strip()
|
||||
# 早期解析把下拉框全部选项拼进了公司。选中项是其中一段时,用选中项替换整段。
|
||||
@@ -406,7 +410,7 @@ def ingest_acceptance_archives(items: list[dict[str, Any]]) -> tuple[int, int]:
|
||||
created = skipped = 0
|
||||
touched_ids: set[int] = set()
|
||||
for item in items:
|
||||
purchase_order_no = str(item.get("purchase_order_no") or "").strip()
|
||||
purchase_order_no = normalize_purchase_order_no(item.get("purchase_order_no"))
|
||||
request_id = str(item.get("request_id") or "").strip()
|
||||
if not purchase_order_no or not request_id:
|
||||
skipped += 1
|
||||
@@ -480,7 +484,7 @@ def _overwrite_oa_fields(contract: ContractPaymentContract, item: dict[str, Any]
|
||||
实际发生覆盖的字段数量。
|
||||
"""
|
||||
field_parsers = {
|
||||
"purchase_order_no": lambda value: str(value).strip() or None,
|
||||
"purchase_order_no": lambda value: normalize_purchase_order_no(value) or None,
|
||||
"company_name": lambda value: str(value).strip() or None,
|
||||
"supplier_name": lambda value: str(value).strip() or None,
|
||||
"applicant_name": lambda value: str(value).strip() or None,
|
||||
@@ -586,7 +590,7 @@ def sync_vendor_prepayment_requests(*, client: ContractOaClient) -> tuple[int, i
|
||||
skipped += 1
|
||||
continue
|
||||
contract_no = str(item.get("contract_no") or "").strip()
|
||||
purchase_order_no = str(item.get("purchase_order_no") or "").strip()
|
||||
purchase_order_no = normalize_purchase_order_no(item.get("purchase_order_no"))
|
||||
if not contract_no and not purchase_order_no:
|
||||
skipped += 1
|
||||
continue
|
||||
|
||||
Reference in new issue
Block a user