fourcal-pms/backend/app/service/calc/mapping.py

62 lines
2.2 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

"""老分类码到新列名的映射,集中一处,避免散在各服务的 if/else。"""
from __future__ import annotations
#: 采购分类 -> 资金计划里的支出列(PLAN-001 的六类支出)
PAY_PROJECT_TO_COLUMN = {
1: "device_cost", # 设备
2: "construction_cost", # 施工
3: "service_cost", # 服务
4: "other_cost", # 其他
}
#: 收入分类 -> 汇总键
INCOME_TYPE_TO_KEY = {1: "device", 2: "engineering", 3: "service"}
#: 采购分类 -> 汇总键
PURCHASE_TYPE_TO_KEY = {1: "device", 2: "construction", 3: "service", 4: "other"}
#: 老 project_budget_cost.type 的六个汇总位
COST_TYPE_TO_KEY = {
1: "device", 2: "construction", 3: "service", 4: "other",
5: "project_manage", 6: "other_other",
}
#: 产品归属编码 -> 项目主档上的金额列(BUD-COST-002)
PRODUCT_CATEGORY_TO_FIELD = {
"huizhi": "huizhi_amount",
"huazhi": "huazhi_amount",
"h3c": "h3c_amount",
"ziguang_other": "other_product_amount",
}
#: 老库 procurement_type 字典(id -> 中文名)。
#: project_budget_cost_detail.category 存的是这张表的 id(写成字符串,"8"/"12"/"17"…),
#: 少数老行直接存了中文名,所以迁移时两种都要认。
#: 这里留一份是为了老库不可达时也能解释历史数据;真正导数时脚本会现查老库的表,以库里的为准。
LEGACY_PROCUREMENT_TYPES = {
8: "华智产品",
9: "紫光其他产品",
10: "华智服务",
11: "紫光其他服务",
12: "外购产品",
13: "外购工程",
14: "外购服务",
15: "其他产品",
16: "汇智产品",
17: "华三产品",
}
#: 老数据里可能出现的中文分类名,迁移时折成上面的编码
LEGACY_CATEGORY_ALIASES = {
"汇智产品": "huizhi",
"华智产品": "huazhi",
"华三产品": "h3c",
"紫光其他": "ziguang_other",
"紫光其他产品": "ziguang_other",
# 老字典里"华智服务 / 紫光其他服务"是独立条目,但项目主档只有四个产品归属列
# (huazhi / huizhi / h3c / other_product),按品牌归到同一桶。
"华智服务": "huazhi",
"紫光其他服务": "ziguang_other",
}