| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183 |
- # -*- coding: utf-8 -*-
- """``interface/getAttributes.py`` — Phase 6 拆分后的兼容层。
- 按 ARCHITECTURE.md Phase 6 拆分建议,原 ``interface/getAttributes.py``
- (5,348 行)中的业务装配函数已按职责迁移到以下目标模块:
- | 目标文件 | 迁出内容 | 类型 |
- |---|---|---|
- | ``common/attr_utils.py`` | ``turnMoneySource``、``get_days_between``、``extract_serviceTime`` | CORE (pure) |
- | ``assembly/package_scope.py`` | ``getPackage``、``getPackagesFromArticle``、``getPackageScopePattern``、``pattern_packageScope``、``dict_role_id``、``role2id_dict`` | ASSEMBLY |
- | ``assembly/role_money.py`` | ``getRoleList``、``getPackageRoleMoney``、``findAttributeAfterEntity``、``get_legal_comba``、``get_dict_entity_prob``、``getSumExpectation``、``dispatch``、``initPackageAttr`` | ASSEMBLY |
- | ``assembly/time_attrs.py`` | ``getTimeAttributes``、``turnBidWay``、``my_timeFormat``、``timeAdd``、``getOtherAttributes``、``my_time_format_pattern``、``time_sub_pattern`` | ASSEMBLY |
- | ``assembly/contacts.py`` | ``getProjectContacts`` | ASSEMBLY |
- | ``assembly/post_process.py`` | ``getPREMs``、``correct_rolemoney``、``limit_maximum_amount``、``update_prem``、``rule_add_role``、``confirm_prem``、``add_package_name``、``fix_single_source``、``demand_to_prem``、``add_manager`` | ASSEMBLY |
- | ``assembly/joint.py`` | ``get_win_joint``、``get_multi_winner_and_money`` | ASSEMBLY |
- 本文件通过 re-export 保持全部旧 import 路径可用:
- ``from BiddingKG.dl.interface.getAttributes import getPREMs`` 仍然有效
- ``import BiddingKG.dl.interface.getAttributes as getAttributes`` 仍然有效
- 循环依赖消除:
- ``turnMoneySource``、``extract_serviceTime``、``get_days_between`` 原被
- ``predictors/`` 反向导入,造成 ``predictors ↔ interface.getAttributes`` 循环。
- 现已下沉到 ``common/attr_utils.py``(CORE 层),``predictors/`` 改为从
- ``common/`` 导入,不再反向依赖 ``interface.getAttributes``。
- 未迁移的函数(保留为本地定义):
- - ``getTheRole`` — 小型辅助函数,不在 Phase 6 迁移范围
- - ``getServiceTime`` — 空占位函数
- - ``getMoneyRange`` — 空占位函数
- - ``limit_maximum_amount_backup`` — 旧版备份函数,保留以备回滚
- """
- from __future__ import absolute_import
- # ============================================================================
- # Re-exports from common/attr_utils.py
- # 纯函数,下沉到 common 层以消除 predictors ↔ interface.getAttributes 循环依赖
- # ============================================================================
- from BiddingKG.dl.common.attr_utils import (
- turnMoneySource,
- get_days_between,
- extract_serviceTime,
- )
- # ============================================================================
- # Re-exports from assembly/package_scope.py
- # 包/标段作用域相关
- # ============================================================================
- from BiddingKG.dl.assembly.package_scope import (
- dict_role_id,
- role2id_dict,
- getPackageScopePattern,
- pattern_packageScope,
- getPackagesFromArticle,
- getPackage,
- )
- # ============================================================================
- # Re-exports from assembly/role_money.py
- # 角色/金额/KM 匹配相关
- # ============================================================================
- from BiddingKG.dl.assembly.role_money import (
- get_legal_comba,
- get_dict_entity_prob,
- getSumExpectation,
- getRoleList,
- dispatch,
- findAttributeAfterEntity,
- initPackageAttr,
- getPackageRoleMoney,
- )
- # ============================================================================
- # Re-exports from assembly/time_attrs.py
- # 时间属性相关
- # ============================================================================
- from BiddingKG.dl.assembly.time_attrs import (
- turnBidWay,
- my_time_format_pattern,
- time_sub_pattern,
- my_timeFormat,
- timeAdd,
- getTimeAttributes,
- getOtherAttributes,
- )
- # ============================================================================
- # Re-exports from assembly/contacts.py
- # 联系人相关
- # ============================================================================
- from BiddingKG.dl.assembly.contacts import (
- getProjectContacts,
- )
- # ============================================================================
- # Re-exports from assembly/post_process.py
- # 结果后处理/修正相关
- # ============================================================================
- from BiddingKG.dl.assembly.post_process import (
- getPREMs,
- correct_rolemoney,
- limit_maximum_amount,
- update_prem,
- rule_add_role,
- confirm_prem,
- add_package_name,
- fix_single_source,
- demand_to_prem,
- add_manager,
- )
- # ============================================================================
- # Re-exports from assembly/joint.py
- # 联合体相关
- # ============================================================================
- from BiddingKG.dl.assembly.joint import (
- get_win_joint,
- get_multi_winner_and_money,
- )
- # ============================================================================
- # 本地定义(Phase 6 未迁移)
- # 以下函数不在用户指定的迁移映射中,保留为本地定义。
- # ============================================================================
- def getTheRole(entity, role_list):
- '''
- @summary:根据实体名称拿到index
- @param:
- entity:实体名称
- role_list:角色list
- @return:该实体所在下标
- '''
- for role_index in range(len(role_list)):
- if entity in role_list[role_index]:
- return role_index
- return None
- def getServiceTime():
- pass
- def getMoneyRange(RoleList):
- pass
- def limit_maximum_amount_backup(prem, industry):
- indu = industry['industry'].get('class_name', '')
- indu_amount = {
- '计算机设备': 200000000,
- '办公设备': 100000000,
- '家具用具': 500000000,
- '办公消耗用品及类似物品': 100000000,
- '日杂用品': 100000000,
- '餐饮业': 1000000000,
- '物业管理': 1000000000,
- '工程技术与设计服务': 1000000000,
- '工程评价服务': 100000000,
- '其他工程服务': 100000000,
- '工程监理服务': 100000000,
- '工程造价服务': 100000000,
- '会计、审计及税务服务': 100000000,
- }
- if indu in indu_amount:
- maximum_amount = indu_amount[indu]
- try:
- for value in prem[0]['prem'].values():
- for l in value['roleList']:
- if l["role_name"] == 'win_tenderer' and float(l["role_money"]['money']) > maximum_amount:
- if indu in ['餐饮业', '物业管理']:
- l["role_money"]['money'] = str(float(l["role_money"]['money'])/10000)
- elif l["role_money"]['money_unit'] == '万元':
- l["role_money"]['money'] = str(float(l["role_money"]['money'])/10000)
- if float(value['tendereeMoney']) > maximum_amount:
- if indu in ['餐饮业', '物业管理']:
- value['tendereeMoney'] = float(value['tendereeMoney'])/10000
- elif value['tendereeMoneyUnit'] == '万元':
- value['tendereeMoney'] = float(value['tendereeMoney']) / 10000
- except Exception as e:
- print('行业分类限制最高金额抛出异常:%s' % e)
|