chore(AdminCost): 移除 COS4 数据结构迁移的一次性脚本与参考资料

This commit is contained in:
lianjianwei2024
2026-11-01 15:27:27 +08:00
parent 386e1ad624
commit f0b1033b12
69 changed files with 5936 additions and 42964 deletions

View File

@@ -0,0 +1,122 @@
# -*- coding: utf-8 -*-
"""以 DBJ/T 15-145-2025 第6章为基准,比对两家 cos4 实际导出属性。
输出:每元素 → {特有(无对应), 拼写差异(疑似对应), 标准有但未导出}"""
import json, difflib
STD = {
"ConstructionProject": "Number Name ProjectCategory ProjectType ConstructionType FileKind ValuationModel TaxModel AreaKind ProjectArea ProjectSite BuildUnit BuildAuthorizer StandardName StandardNumber StandardVersion RangeOfCompilation ScaleName Scale Unit ProjectIndex LabourPriceIndex MaterialPriceIndex MachinePriceIndex TechnicalAndEconomicIndex Explains",
"SystemInfo": "ID1 ID2 MakeDate1 MakeDate2",
"Option": "ResPrecision QuantityPrecision CostPrecision RatePrecision",
"ProjectInfo": "Designer Contractor CompileCompany Authorizer Compiler CompilerCertNo CompileDate Examiner ExaminerCertNo ExamineDate Approver ApproverCertNo ApproverDate Total",
"TendereeInfo": "TendereeName TenderAuthorizer TenderCompiler TenderCompilerCertNo TenderCompileDate TenderExaminer TenderExaminerCertNo TenderExamineDate TenderApprover TenderApproverCertNo TenderApproveDate Proxy ProxyAuthorizer ProxyUSCI ProxyCompiler ProxyCompilerCertNo ProxyCompileDate ProxyExaminer ProxyExaminerCertNo ProxyExamineDate ProxyApprover ProxyApproverCertNo ProxyApproveDate Consultant ConsultantUSCI ConsultantAuthorizer ConsultantCompiler ConsultantCompilerCertNo ConsultantCompileDate ConsultantExaminer ConsultantExaminerCertNo ConsultantExamineDate ConsultantApprover ConsultantApproverCertNo ConsultantApproveDate TenderSumLimit",
"BidderInfo": "BidName BidAuthorizer BidTotal BidCompiler BidCompilerCertNo BidCompileDate BidExaminer BidExaminerCertNo BidExamineDate BidApprover BidApproverCertNo BidApproveDate",
"AttrInfoItem": "Name Value Code Remark",
"AddiInfoItem": "Name Value Code Remark",
"SummaryOfCost": "Total Construction Installation DivisionalAndElementalWorks Preliminaries CostForHSE SundryCosts ProvisionalSums SpecialtyProvisionalPrice DayWorkRate MainContractorAttendance ClaimForLossAndExpenses LawsRegulationsAndPolicyChangeProjects ChangeCost Tax Labour Material MainMaterialEquipment MainMaterial Equipment ProvisionalMaterialEquipment Machine Overhead Profit ForeignCurrency ConvertedIntoRMB",
"AddiCost": "Name Total Code",
"ProjectInstallationWorkCost": "Number Name Total ForeignCurrency ConvertedIntoRMB ScaleName Scale Unit TechnicalAndEconomicIndex Ratios Code Remark",
"ProjectInstallationWorkCostSummaryGroup": "Number Name Unit Quantity Total TechnicalAndEconomicIndex Ratios Code Kind Remark",
"ProjectInstallationWorkCostSummaryItem": "Number Name Unit Quantity QtyFormula Rate Total TechnicalAndEconomicIndex Ratios Code Kind Remark",
"SectionalWorks": "Number Name Segment ProjectCategory ProjectType ConstructionType FileKind ValuationModel TaxModel AreaKind Total ProjectArea ProjectSite BuildUnit BuildAuthorizer StandardName StandardNumber StandardVersion RangeOfCompilation ScaleName Scale Unit ProjectIndex LabourPriceIndex MaterialPriceIndex MachinePriceIndex TechnicalAndEconomicIndex Ratios WorkContent QuantityCalculationRules Code Remark Explains",
"UnitWorks": "Number Name Segment ProjectCategory ProjectType ValuationModel TaxModel AreaKind Total Specialty Purposes RangeOfCompilation ScaleName Scale Unit BillDataBase NormDataBase ResInfoPricingFile MaterialPriceDate AppliedRateFile ProjectIndex LabourPriceIndex MaterialPriceIndex MachinePriceIndex TechnicalAndEconomicIndex Ratios WorkContent QuantityCalculationRules Code Remark Explains FileName",
"SummaryOfBasicCost": "Labour Material MainMaterial Equipment MainMaterialEquipment ProvisionalMaterialEquipment Machine Overhead Profit DivisionalAndElementalWorks Preliminaries CostForHSE SundryCosts Tax",
"PreliminaryDivisionalWorks": "Number Name WorkContent Unit Quantity Total TechnicalAndEconomicIndex Code Kind Remark",
"PreliminaryWorkElement": "Number Name WorkContent Unit Quantity QtyFormula Price Rate Total InitialPercent InitialFee MediumPercent MediumFee LastPercent LastFee SupplementaryList CalcType Specialty ListingIdentity LockKind Code Kind Remark",
"SubdivisionFees": "Number Name Unit Quantity QtyFormula Price Rate Total CalcType InitialPercent InitialFee MediumPercent MediumFee LastPercent LastFee Code IsLargeMachinery Kind Remark",
"SundryCosts": "Name Total Code Remark",
"SundryCostsGroup": "Name Total Code Kind Remark",
"SundryCostsItem": "Name Unit Quantity QtyFormula Price Rate Total Code Kind Remark",
"ProvisionalSums": "Name Total Code Remark",
"ProvisionalSumsGroup": "Name Total Kind Remark",
"ProvisionalSumsItem": "Name Unit Quantity QtyFormula Price Rate Total Kind Remark",
"SpecialtyProvisionalPrice": "Name NoTaxTotal Tax Total Code Remark",
"SpecialtyProvisionalPriceGroup": "Name Content NoTaxTotal Tax Total Kind Remark",
"SpecialtyProvisionalPriceItem": "Name Content Unit Quantity QtyFormula Price Rate NoTaxTotal Tax Total Kind Remark",
"DayWorkRate": "Name Total Code Remark",
"DayWorkRateGroup": "Name Total Code Remark",
"DayWorkRateItem": "Number Name Specification Unit Quantity Price Total Remark",
"MainContractorAttendance": "Name Total Code Remark",
"MainContractorAttendanceGroup": "Name Total Kind Remark",
"MainContractorAttendanceItem": "Name Quantity Content QtyFormula Rate Total Kind Remark",
"ClaimsCost": "Name Total Code Remark",
"ClaimsCostGroup": "Name Total Kind Remark",
"ClaimsCostItem": "Name Unit Quantity QtyFormula Price Rate Total Reason Kind Remark",
"LawsRegulationsAndPolicyChangeProjects": "Name Total Code Remark",
"LawsRegulationsAndPolicyChangeProjectsGroup": "Name Total Kind Remark",
"LawsRegulationsAndPolicyChangeProjectsItem": "Name Unit Quantity QtyFormula Price Rate Total Reason Kind Remark",
"ChangeCost": "Number Name Total Code Remark",
"ChangeCostGroup": "Number Name Total Code Remark",
"ChangeCostItem": "Number Name Unit Quantity QtyFormula Price Rate Total Reason Kind Remark",
"Tax": "Name CalBasis QtyFormula Rate Total Code Remark",
"TaxItem": "Name CalBasis QtyFormula Rate Total Code Remark",
"ProvisionalMaterialEquipment": "Name Total Code Remark",
"ProvisionalMaterialEquipmentItem": "Number Name Specification Unit Quantity Price Total Remark",
"LabourMaterialsEquipmentsMachinesSummary": "Number Name Specification Unit LossRate Quantity ProviderRate ProviderBase TaxRate NoTaxOrgPrice NoTaxPriceExpress NoTaxPrice TaxOrgPrice TaxPriceExpress TaxPrice NoTaxOrgTotal NoTaxTotal TaxOrgTotal TaxTotal Weight BasicPrice CurrentPrice Kind Class ExtKind Concrete AddiKind MainMaterial ProvisionalMaterial Provider PriceSource Delivery Location ProducingArea Supplier Character Remark",
"LabourMaterialsEquipmentsMachinesElement": "Number Express Quantity Remark",
"BidEvaluationMainMaterial": "Code Number Name Specification Unit Price LimitedPrice ResClassValue Quantity Total ProviderRate ProviderBase Delivery DeliPlace ProducingArea Supplier Character Remark",
"DivisionalWorks": "Number Name Attr WorkContent QuantityCalculationRules Unit Quantity Total TechnicalAndEconomicIndex ChapterKind Code Kind Remark",
"WorkElement": "Number Name Attr WorkContent QuantityCalculationRules Unit Quantity QtyFormula Price CalcPrice EquipmentPrice PriceHigh Rate Total EquipmentTotal SupplementaryList Major Type CalculationKind CostKind PriceType CalcType Specialty ListingIdentity LockKind Code Kind Remark",
"ExpressElement": "OrderNumber Area BuildingComponents Express Explain Quantity Kind Remark", # Area=部位, 2025 OCR丢名按2018补
"WorkContent": "Name Total Remark",
"Norm": "Number Name Unit Quantity Price EquipmentPrice Total EquipmentTotal IsNorm Type CalculationKind CostKind EfficiencyKind IncFeeKind Specialty NormIdentity Volume Chapter Remark",
"IncFees": "Number Name CalcKind Ratio LabourRatio MachineRatio ManageFeeRate DivisionalAndElementalWorksClassify PreliminaryClassify LabourRate MaterialRate MachineRate DivisionalAndElementalWorksLabour DivisionalAndElementalWorksMaterial DivisionalAndElementalWorksMachine DivisionalAndElementalWorksManageFee PreliminaryLabour PreliminaryMaterial PreliminaryMachine",
"UnitPriceCalculationOfItem": "Name QtyFormula Rate Total Code Remark",
"NormAdjustmentList": "OrderNumber Value",
"UnitWorksPreliminaryWorkElement": "Number Name WorkContent Unit Quantity QtyFormula Price CalcPrice Rate Total InitialPercent InitialFee MediumPercent MediumFee LastPercent LastFee SupplementaryList PriceType CalcType Specialty ListingIdentity LockKind Code Kind Remark",
"UnitWorksSummaryGroup": "Number Name Unit Quantity Total TechnicalAndEconomicIndex Ratios ChapterKind Code Kind Remark",
"UnitWorksSummaryItem": "Number Name Unit Quantity QtyFormula Rate Total TechnicalAndEconomicIndex Ratios ChapterKind Code Kind Remark",
}
STD = {k: set(v.split()) for k, v in STD.items()}
def norm(s):
return s.lower().replace(" ", "").replace("-", "")
def classify(vendor_attrs, std_attrs):
uniq, fuzzy = [], []
vsn = {norm(a): a for a in vendor_attrs}
stdn = {norm(a): a for a in std_attrs}
hit_std = set() # 被精确或拼写命中的标准属性(原始名)
for n, a in sorted(vsn.items()):
if n in stdn:
hit_std.add(stdn[n]); continue
best, br = None, 0.0
for sn in stdn:
if abs(len(sn) - len(n)) > 2 or sn[0] != n[0]:
continue
r = difflib.SequenceMatcher(None, n, sn).ratio()
if r > br:
best, br = sn, r
if best is not None and br >= 0.82:
hit_std.add(stdn[best]); fuzzy.append("%s ≈ 标准 %s" % (a, stdn[best]))
else:
uniq.append(a)
not_exp = sorted(std_attrs - hit_std)
return uniq, fuzzy, not_exp
gld = json.load(open("D:/PricingReview/_analysis/gld_attrs.json", encoding="utf-8"))["elements"]
yd = json.load(open("D:/PricingReview/_analysis/yd_attrs.json", encoding="utf-8"))["elements"]
for tag, data in [("广联达", gld), ("易达", yd)]:
print("=" * 78)
print("## %s" % tag)
for el in sorted(data):
if el not in STD:
print("[%s] !! 标准无此元素,其全部属性均为自有: %s" % (el, ",".join(data[el]["attrs"])))
continue
u, f, ne = classify(data[el]["attrs"], STD[el])
if u or f:
print("[%s]" % el)
if u: print(" 标准没有(特有):", ", ".join(u))
if f: print(" 拼写差异(标准有对应):", "; ".join(f))
print()
print("=" * 78)
print("## 覆盖差异(标准有、该家未导出) — 逐元素")
for tag, data in [("广联达", gld), ("易达", yd)]:
print("-- %s" % tag)
for el in sorted(data):
if el in STD:
_, _, ne = classify(data[el]["attrs"], STD[el])
if ne:
print(" %-42s 缺 %s" % (el, ",".join(ne)))
miss_el = sorted(set(STD) - set(data))
print(" 整元素未出现:", ",".join(miss_el) or "无")