from Utils.ObjUtil import SpecObject from Utils.ValidateUtil import ValidateAttr, Validate class BasicInfo(SpecObject): """基本工商信息""" status = ValidateAttr(field="status", type=str, default=None) legal_person = ValidateAttr(field="legal_person", type=str, default=None) company_type = ValidateAttr(field="company_type", type=str, default=None) taxpayer_id = ValidateAttr(field="taxpayer_id", type=str, default=None) business_scope = ValidateAttr(field="business_scope", type=str, default=None) registered_capital = ValidateAttr(field="registered_capital", type=str, default=None) paid_capital = ValidateAttr(field="paid_capital", type=str, default=None) registered_address = ValidateAttr(field="registered_address", type=str, default=None) registration_authority = ValidateAttr(field="registration_authority", type=str, default=None) industry = ValidateAttr(field="industry", type=str, default=None) staff_size = ValidateAttr(field="staff_size", type=str, default=None) people_insured_num = ValidateAttr(field="people_insured_num", type=int, default=None) micro_company = ValidateAttr(field="micro_company", type=str, default=None) fields_map = { "status": "企业状态", "legal_person": "法定代表人", "company_type": "企业类型", "taxpayer_id": "纳税人识别号", "business_scope": "经营范围", "registered_capital": "注册资本", "paid_capital": "实缴资本", "registered_address": "注册地址", "registration_authority": "登记机关", "industry": "行业", "staff_size": "人员规模", "people_insured_num": "参保人数", "micro_company": "小微企业" } class ShareHolder(SpecObject): """股东信息""" name = ValidateAttr(field='name', type=str) share_holder_type = ValidateAttr(field='share_holder_type', type=str, default=None) share_holding_ratio = ValidateAttr(field="share_holding_ratio", type=str, default=None) subscription_amount = ValidateAttr(field="subscription_amount", type=str, default=None) subscription_date = ValidateAttr(field="subscription_date", type=str, default=None) paid_amount = ValidateAttr(field="paid_amount", type=list, default=[]) payment_method = ValidateAttr(field="payment_method", type=list, default=[]) payment_time = ValidateAttr(field="payment_time", type=list, default=[]) fields_map = { "name": "股东", "share_holder_type": "股东类型", "share_holding_ratio": "持股比例", "subscription_amount": "认缴金额", "subscription_date": "认缴日期", "paid_amount": "实缴金额", "payment_method": "实缴方式", "payment_time": "实缴时间" } class MainMember(SpecObject): """主要成员""" name = ValidateAttr(field="name", type=str) job_title = ValidateAttr(field="job_title", type=list, default=None) fields_map = { "name": "姓名", "job_title": "职务" } class BalanceSheet(SpecObject): """资产负债表""" accounts_receivable = ValidateAttr(field='accounts_receivable', type=float) stock = ValidateAttr(field='stock', type=float) total_current_assets = ValidateAttr(field='total_current_assets', type=float) total_assets = ValidateAttr(field='total_assets', type=float) short_loan = ValidateAttr(field='short_loan', type=float) one_year_liabilities = ValidateAttr(field='one_year_liabilities', type=float) total_current_liabilities = ValidateAttr(field='total_current_liabilities', type=float) long_term_loan = ValidateAttr(field='long_term_loan', type=float) total_liabilities = ValidateAttr(field='total_liabilities', type=float) total_owners_equity = ValidateAttr(field='total_owners_equity', type=float) fields_map = { 'accounts_receivable': '应收账款', 'stock': '存货', 'total_current_assets': '流动资产合计', 'total_assets': '资产总计', 'short_loan': '短期借款', 'one_year_liabilities': '一年内到期非流动负债', 'total_current_liabilities': '流动负债合计', 'long_term_loan': '长期借款', 'total_liabilities': '负债合计', 'total_owners_equity': '所有者权益合计' } class ProfitSheet(SpecObject): """利润表""" operating_income = ValidateAttr(field='operating_income', type=float) operating_cost = ValidateAttr(field='operating_cost', type=float) total_profit = ValidateAttr(field='total_profit', type=float) net_profit = ValidateAttr(field='net_profit', type=float) fields_map = { 'operating_income': '营业收入', 'operating_cost': '营业成本', 'total_profit': '利润总额', 'net_profit': '净利润' } class AppendixDataSheet(SpecObject): """补充数据表""" rd_expenses = ValidateAttr(field='rd_expenses', type=float) interest_disbursement = ValidateAttr(field='interest_disbursement', type=float) interest_expense = ValidateAttr(field='interest_expense', type=float) fields_map = { 'rd_expenses': '研发费用', 'interest_disbursement': '计入财务费的利息支出', 'interest_expense': '资本化利息支出' } class FinancialIndex(SpecObject): """财务指标""" roe = ValidateAttr(field="roe", type=float) inventory_turnover = ValidateAttr(field="inventory_turnover", type=(float, int)) interest_multiple = ValidateAttr(field="interest_multiple", type=(float, int)) accounts_receivable_turnover = ValidateAttr(field="accounts_receivable_turnover", type=(float, int)) total_asset_turnover = ValidateAttr(field="total_asset_turnover", type=(float, int)) total_asset_growth_rate = ValidateAttr(field="total_asset_growth_rate", type=(float, int)) roa = ValidateAttr(field="roa", type=(float, int)) technology_investment_ratio = ValidateAttr(field="technology_investment_ratio", type=(float, int)) operating_growth_rate = ValidateAttr(field="operating_growth_rate", type=(float, int)) assets_and_liabilities = ValidateAttr(field="assets_and_liabilities", type=(float, int)) quick_ratio = ValidateAttr(field="quick_ratio", type=(float, int)) fields_map = { "roe": "净资产收益率", "inventory_turnover": "存货周转率", "interest_multiple": "已获利息倍数", "accounts_receivable_turnover": "应收账款周转率", "total_asset_turnover": "总资产周转率", "total_asset_growth_rate": "总资产增长率", "roa": "总资产报酬率", "technology_investment_ratio": "技术投入比率", "operating_growth_rate": "营业增长率", "assets_and_liabilities": "资产负债率", "quick_ratio": "速动比率" } class CompanyData(SpecObject): """企业数据""" cid = ValidateAttr(field='cid', type=str, length=8) name = ValidateAttr(field='name', type=str) industry_l1 = ValidateAttr(field='industry_l1', type=str) industry_l2 = ValidateAttr(field='industry_l2', type=str) basic_info = ValidateAttr(field='basic_info', type=BasicInfo) share_holders = ValidateAttr(field='share_holders', instance_list=ShareHolder) main_members = ValidateAttr(field="main_members", instance_list=MainMember) balance_sheet = ValidateAttr(field='balance_sheet', type=BalanceSheet) profit_sheet = ValidateAttr(field='profit_sheet', type=ProfitSheet) appendix_sheet = ValidateAttr(field='appendix_sheet', type=AppendixDataSheet) fin_index = ValidateAttr(field='fin_index', type=FinancialIndex) cc_rating_result = ValidateAttr(field='cc_rating_result', type=dict) esg_rating_result = ValidateAttr(field='esg_rating_result', type=dict) update_time = ValidateAttr(field='update_time', type=dict) fields_map = { "cid": "企业ID", "name": "企业名称", "industry_l1": "一级行业", "industry_l2": "二级行业", "basic_info": "工商信息", "share_holders": "股东信息", "main_members": "主要成员", "balance_sheet": "资产负债表", "profit_sheet": "利润表", "income_sheet": "现金流量表", "appendix_sheet": "财务补充数据", "fin_index": "财务指标", "cc_rating_result": "综信评价结果", "esg_rating_result": "ESG评价结果", "update_time": "更新时间" } def drag_data_from_tyc_api(self): """拉取天眼查接口数据""" def prepare_company_init_data(self): """准备企业初始化数据""" class ComprehensiveCreditAnalysis(SpecObject): """综合信用分析""" class CreditPerformance(SpecObject): class IndicatorRadar(SpecObject): """指标雷达""" class IndexScore(SpecObject): """指标得分""" environment = ValidateAttr(field='environment', type=(int, float)) social_responsibility = ValidateAttr(field='social_responsibility', type=(int, float)) corporate_governance = ValidateAttr(field='corporate_governance', type=(int, float)) profitability = ValidateAttr(field='profitability', type=(int, float)) asset_quality = ValidateAttr(field='asset_quality', type=(int, float)) debt_risk = ValidateAttr(field='debt_risk', type=(int, float)) operational_growth = ValidateAttr(field='operational_growth', type=(int, float)) compliance_risk = ValidateAttr(field='compliance_risk', type=(int, float)) cperational_risk = ValidateAttr(field='cperational_risk', type=(int, float)) associated_risk = ValidateAttr(field='associated_risk', type=(int, float)) fields_map = { "environment": "环境", "social_responsibility": "社会责任", "corporate_governance": "公司治理", "profitability": "盈利能力", "asset_quality": "资产质量", "debt_risk": "债务风险", "operational_growth": "经营增长", "compliance_risk": "合规风险", "cperational_risk": "经营风险", "associated_risk": "关联风险" } class MaxScore(SpecObject): """最大分数""" environment = ValidateAttr(field='environment', type=int) social_responsibility = ValidateAttr(field='social_responsibility', type=int) corporate_governance = ValidateAttr(field='corporate_governance', type=int) profitability = ValidateAttr(field='profitability', type=int) asset_quality = ValidateAttr(field='asset_quality', type=int) debt_risk = ValidateAttr(field='debt_risk', type=int) operational_growth = ValidateAttr(field='operational_growth', type=int) compliance_risk = ValidateAttr(field='compliance_risk', type=int) cperational_risk = ValidateAttr(field='cperational_risk', type=int) associated_risk = ValidateAttr(field='associated_risk', type=int) fields_map = { "environment": "环境", "social_responsibility": "社会责任", "corporate_governance": "公司治理", "profitability": "盈利能力", "asset_quality": "资产质量", "debt_risk": "债务风险", "operational_growth": "经营增长", "compliance_risk": "合规风险", "cperational_risk": "经营风险", "associated_risk": "关联风险" } index_score = ValidateAttr(field='index_score', type=IndexScore) max_score = ValidateAttr(field='max_score', type=MaxScore) fields_map = { "index_score": "指标得分", "max_score": "最大分数" } """综合信用表现""" indicator_radar = ValidateAttr(field='indicator_radar', type=IndicatorRadar) fields_map = { "indicator_radar": "指标雷达" } class CreditAnalysis(SpecObject): """信用分析""" management_analysis = ValidateAttr(field='management_analysis', type=str) finance_analysis = ValidateAttr(field='finance_analysis', type=str) risk_analysis = ValidateAttr(field='risk_analysis', type=str) evaluation_opinion = ValidateAttr(field='evaluation_opinion', type=str) view_report = ValidateAttr(field='view_report', type=str) fields_map = { "management_analysis": "经营分析", "finance_analysis": "财务分析", "risk_analysis": "风险分析", "evaluation_opinion": "评价意见", "view_report": "查看报告" } class IndexTable(SpecObject): """指标表格""" class FinancialIndicators(SpecObject): """财务指标""" profitability = ValidateAttr(field='profitability', in_list=['优', '良', '中', '低', '差']) asset_quality = ValidateAttr(field='asset_quality', in_list=['优', '良', '中', '低', '差']) debt_risk = ValidateAttr(field='debt_risk', in_list=['优', '良', '中', '低', '差']) operating_growth = ValidateAttr(field='operating_growth', in_list=['优', '良', '中', '低', '差']) fields_map = { "profitability": "盈利能力", "asset_quality": "资产质量", "debt_risk": "债务风险", "operating_growth": "经营增长" } class RiskIndicators(SpecObject): """风险指标""" compliance_risk = ValidateAttr(field='compliance_risk', in_list=['优', '良', '中', '低', '差']) operational_risk = ValidateAttr(field='operational_risk', in_list=['优', '良', '中', '低', '差']) associated_risk = ValidateAttr(field='associated_risk', in_list=['优', '良', '中', '低', '差']) fields_map = { "compliance_risk": "合规风险", "operational_risk": "经营风险", "associated_risk": "关联风险" } class OperatingIndicators(SpecObject): """经营指标""" environmental = ValidateAttr(field='environmental', in_list=['优', '良', '中', '低', '差']) social_responsibility = ValidateAttr(field='social_responsibility', in_list=['优', '良', '中', '低', '差']) corporate_governance = ValidateAttr(field='corporate_governance', in_list=['优', '良', '中', '低', '差']) fields_map = { "environmental": "环境", "social_responsibility": "社会责任", "corporate_governance": "公司治理" } financial_indicators = ValidateAttr(field='financial_indicators', type=FinancialIndicators) risk_indicators = ValidateAttr(field='risk_indicators', type=RiskIndicators) operating_indicators = ValidateAttr(field='operating_indicators', type=OperatingIndicators) fields_map = { "financial_indicators": "财务指标", "risk_indicators": "风险指标", "operating_indicators": "经营指标" } class HistoryLevel(SpecObject): """历史级别""" credit_rating = ValidateAttr(field='credit_rating', type=str) credit_score = ValidateAttr(field='credit_score', type=(float, int)) evaluation_time = ValidateAttr(field='evaluation_time', type=str) evaluation_method = ValidateAttr(field='evaluation_method', type=str, in_list=['企业申报']) change_trend = ValidateAttr(field='change_trend', type=str) fields_map = { "credit_rating": "信用等级", "credit_score": "信用评分", "evaluation_time": "评价时间", "evaluation_method": "评价方式", "change_trend": "变化趋势" } cid = ValidateAttr(field='cid', type=str, length=8) rid = ValidateAttr(field='rid', type=str, length=8) name = ValidateAttr(field='name', type=str) update_time = ValidateAttr(field='update_time', func=Validate.time_format) performance = ValidateAttr(field='performance', type=CreditPerformance) credit_analysis = ValidateAttr(field='credit_analysis', type=CreditAnalysis) index_table = ValidateAttr(field='index_table', type=IndexTable) history_level = ValidateAttr(field='history_level', instance_list=HistoryLevel) fields_map = { "cid": "企业ID", "rid": "评价ID", "name": "企业名称", "update_time": "更新时间", "performance": "综合信用表现", "credit_analysis": "信用分析", "index_table": "指标表格", "history_level": "历史级别" } class FinancialIndexs(SpecObject): """财务指标""" profitability = ValidateAttr(field='profitability', type=(int, float, str)) asset_quality = ValidateAttr(field='asset_quality', type=(int, float, str)) debt_risk = ValidateAttr(field='debt_risk', type=(int, float, str)) business_growth = ValidateAttr(field='business_growth', type=(int, float, str)) fields_map = { "profitability": "盈利能力", "asset_quality": "资产质量", "debt_risk": "债务风险", "business_growth": "经营增长" } class FinancialElementsAnalysis(SpecObject): """财务要素分析""" class CompareToYears(SpecObject): """财务得分年度比较""" year = ValidateAttr(field='year', type=str, func=Validate.date_format) index = ValidateAttr(field='index', type=FinancialIndexs) fields_map = { "year": "年度", "index": "指标" } class CompareToIndustry(SpecObject): """财务得分同行比较""" company_score = ValidateAttr(field='company_score', type=FinancialIndexs) average_score = ValidateAttr(field='average_score', type=FinancialIndexs) fields_map = { "company_score": "公司水平", "average_score": "平均水平" } class IndexDetails(SpecObject): """指标详情""" index = ValidateAttr(field='index', type=str) value = ValidateAttr(field='value', type=str) level = ValidateAttr(field='level', type=str, in_list=['优', '良', '中', '低', '差']) fields_map = { "index": "指标", "value": "数值", "level": "水平" } cid = ValidateAttr(field='cid', type=str, length=8, default=None) update_time = ValidateAttr(field='update_time', func=Validate.time_format) rid = ValidateAttr(field='rid', type=str, length=8) report_date = ValidateAttr(field='report_date', type=str, func=Validate.date_format) compare_to_years = ValidateAttr(field='compare_to_years', instance_list=CompareToYears) compare_to_industry = ValidateAttr(field='compare_to_industry', type=CompareToIndustry) delta_to_years = ValidateAttr(field='delta_to_years', type=FinancialIndexs) delta_to_industry = ValidateAttr(field='delta_to_industry', type=FinancialIndexs) index_details = ValidateAttr(field='index_details', instance_list=IndexDetails) fields_map = { "cid": "企业ID", "update_time": "更新时间", "rid": "评价ID", "report_date": "财报期", "compare_to_years": "财务得分年度比较", "compare_to_industry": "财务得分同行比较", "delta_to_years": "财务得分较去年变化", "delta_to_industry": "财务得分较同行差异", "index_details": "指标详情" } class BusinessElementsAnalysis(SpecObject): """经营要素分析""" class ComplianceRisk(SpecObject): """合规风险""" genre = ValidateAttr(field='genre', type=str) quantity = ValidateAttr(field='quantity', type=int) affect = ValidateAttr(field='affect', type=str) fields_map = { "genre": "类型", "quantity": "数量", "affect": "影响" } class OperationalRisk(SpecObject): """经营风险""" genre = ValidateAttr(field='genre', type=str) quantity = ValidateAttr(field='quantity', type=int) affect = ValidateAttr(field='affect', type=str) fields_map = { "genre": "类型", "quantity": "数量", "affect": "影响" } class PeripheralRisk(SpecObject): """周边风险""" genre = ValidateAttr(field='genre', type=str) quantity = ValidateAttr(field='quantity', type=int) detail = ValidateAttr(field='detail', type=list) fields_map = { "genre": "类型", "quantity": "数量", "detail": "详情" } class ChangeLog(SpecObject): """变更记录""" genre = ValidateAttr(field='genre', type=str) quantity = ValidateAttr(field='quantity', type=int) affect = ValidateAttr(field='affect', type=str) fields_map = { "genre": "类型", "quantity": "数量", "affect": "影响" } cid = ValidateAttr(field='cid', type=str, length=8, default=None) rid = ValidateAttr(field='rid', type=str, length=8, default=None) update_time = ValidateAttr(field='update_time', func=Validate.time_format) risk_score = ValidateAttr(field='risk_score', type=(int, float)) risk_level = ValidateAttr(field='risk_level', type=str, in_list=['高', '较高', '中等', '警示', '低']) risk_quantity = ValidateAttr(field='risk_quantity', type=int) untrustworthy_list = ValidateAttr(field='untrustworthy_list', type=str, in_list=['是', '否']) compliance_risk = ValidateAttr(field='compliance_risk', instance_list=ComplianceRisk) operational_risk = ValidateAttr(field='operational_risk', instance_list=OperationalRisk) peripheral_risk = ValidateAttr(field='peripheral_risk', instance_list=PeripheralRisk) change_log = ValidateAttr(field='change_log', instance_list=ChangeLog) fields_map = { "cid": "企业ID", "rid": "评价ID", "update_time": "更新日期", "risk_score": "风险分数", "risk_level": "风险级别", "risk_quantity": "风险数量", "untrustworthy_list": "列入失信名单", "compliance_risk": "合规风险", "operational_risk": "经营风险", "peripheral_risk": "周边风险", "change_log": "变更记录" } class EsgRatingAnalysis(SpecObject): """ESG评价分析""" class EsgRating(SpecObject): """ESG评级""" rating = ValidateAttr(field='rating', type=str) score = ValidateAttr(field='score', type=(float, int)) industry = ValidateAttr(field='industry', type=str) fields_map = { "rating": "ESG评级", "score": "ESG综合得分", "industry": "行业" } class DimensionScore(SpecObject): """维度得分情况""" dimension = ValidateAttr(field='dimension', type=str) weights = ValidateAttr(field='weights', type=str) score = ValidateAttr(field='score', type=(float, int)) score_change = ValidateAttr(field='score_change', type=str) industry_average = ValidateAttr(field='industry_average', type=str) fields_map = { "dimension": "维度", "weights": "权重", "score": "公司得分", "score_change": "得分变化", "industry_average": "行业均分" } cid = ValidateAttr(field='cid', type=str, length=8, default=None) rid = ValidateAttr(field='rid', type=str, length=8, default=None) update_time = ValidateAttr(field='update_time', func=Validate.time_format) esg_rating = ValidateAttr(field='esg_rating', type=EsgRating) dimension_score = ValidateAttr(field='dimension_score', instance_list=DimensionScore) fields_map = { "cid": "企业ID", "rid": "评价ID", "update_time": "更新日期", "esg_rating": "ESG评级", "dimension_score": "维度得分情况" }