调整 格式+推送时间
This commit is contained in:
@@ -9,7 +9,6 @@ from typing import Any
|
||||
|
||||
from inventory_analytics.logging_utils import exception_fields
|
||||
from inventory_analytics.logging_utils import log_event as emit_log_event
|
||||
from inventory_analytics.logging_utils import sanitize_value
|
||||
|
||||
from .feishu import FeishuClient
|
||||
from .postgres import query_postgres
|
||||
@@ -62,14 +61,14 @@ def safe_result_summary(result: dict[str, object]) -> dict[str, object]:
|
||||
summary["sync_brand"] = {
|
||||
"target_count": sync_result.get("target_count"),
|
||||
"source_row_count": sync_result.get("source_row_count"),
|
||||
"filtered_row_count": sync_result.get("filtered_row_count"),
|
||||
"deleted_record_count": sync_result.get("deleted_record_count"),
|
||||
"created_record_count": sync_result.get("created_record_count"),
|
||||
"shop_count": sync_result.get("shop_count"),
|
||||
}
|
||||
return summary
|
||||
|
||||
|
||||
def public_result(result: dict[str, object]) -> dict[str, object]:
|
||||
return sanitize_value(result)
|
||||
|
||||
|
||||
def main() -> int:
|
||||
started_at = time.monotonic()
|
||||
try:
|
||||
@@ -115,10 +114,7 @@ def main() -> int:
|
||||
source_row_count=result["sync_brand"].get("source_row_count") if isinstance(result["sync_brand"], dict) else None,
|
||||
)
|
||||
|
||||
if safe_logs:
|
||||
print(json.dumps(safe_result_summary(result), ensure_ascii=False, indent=2))
|
||||
else:
|
||||
print(json.dumps(public_result(result), ensure_ascii=False, indent=2))
|
||||
print(json.dumps(safe_result_summary(result), ensure_ascii=False, indent=2))
|
||||
log_event(
|
||||
logging.INFO,
|
||||
"渠道库存同步任务完成",
|
||||
|
||||
@@ -189,15 +189,12 @@ def sync_brand_target(
|
||||
)
|
||||
|
||||
return {
|
||||
"brand_name": target.brand_name,
|
||||
"warehouse_keys": target.warehouse_keys,
|
||||
"target_table_name": target.table_name,
|
||||
"target_table_id": table_id,
|
||||
"available_fields": available_fields,
|
||||
"source_row_count": len(source_rows),
|
||||
"filtered_row_count": len(target_rows),
|
||||
"deleted_record_count": deleted_count,
|
||||
"created_record_count": created_count,
|
||||
"available_field_count": len(available_fields),
|
||||
"shop_count": len(shop_names),
|
||||
}
|
||||
|
||||
|
||||
@@ -232,5 +229,8 @@ def run_sync_brand(config: AppConfig, client: FeishuClient, postgres_result: dic
|
||||
return {
|
||||
"target_count": len(BRAND_SYNC_TARGETS),
|
||||
"source_row_count": source_row_count,
|
||||
"targets": results,
|
||||
"filtered_row_count": sum(int(result.get("filtered_row_count") or 0) for result in results),
|
||||
"deleted_record_count": sum(int(result.get("deleted_record_count") or 0) for result in results),
|
||||
"created_record_count": sum(int(result.get("created_record_count") or 0) for result in results),
|
||||
"shop_count": sum(int(result.get("shop_count") or 0) for result in results),
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ class FieldSpec:
|
||||
|
||||
|
||||
BRAND_SYNC_TARGETS = [
|
||||
BrandSyncTarget(brand_name="羽心堂", table_name="羽心堂", warehouse_keys=(2, 3, 7, 13)),
|
||||
BrandSyncTarget(brand_name="羽心堂", table_name="羽心堂渠道库存-9:00和19:00", warehouse_keys=(2, 3, 7, 13)),
|
||||
]
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ FIELD_SPECS = [
|
||||
FieldSpec("分类", "一级分类", 1),
|
||||
FieldSpec("条形码", "条形码", 1),
|
||||
FieldSpec("零售价", "零售价", 2, "0.00", 2),
|
||||
FieldSpec("可用总库存", "可用总库存", 2, "0", 0),
|
||||
FieldSpec("渠道锁库库存", "可用总库存", 2, "0", 0),
|
||||
FieldSpec("全渠道总库存", "总库存", 2, "0", 0),
|
||||
FieldSpec("品牌", "品牌名称", 1),
|
||||
FieldSpec("产品类别", "货品简称", 1),
|
||||
@@ -55,6 +55,7 @@ LEGACY_NAME_MAP = {
|
||||
"商品名称": "货品名称",
|
||||
"店铺名称": "店铺名称",
|
||||
"店铺挂单量": "店铺可用库存",
|
||||
"可用总库存": "渠道锁库库存",
|
||||
"本月销售数量": month_sales_field_name(0),
|
||||
"上月销售数量": month_sales_field_name(1),
|
||||
"上上月销售数量": month_sales_field_name(2),
|
||||
|
||||
Reference in New Issue
Block a user