233 lines
14 KiB
Python
233 lines
14 KiB
Python
|
from Utils.ValidateUtil import ValidateAttr
|
||
|
|
||
|
|
||
|
class RatingInfo(object):
|
||
|
"""评价记录 """
|
||
|
rid = ValidateAttr(field='rid', type=str, length=8, error_info='评价ID异常', error_code=200)
|
||
|
cid = ValidateAttr(field='cid', type=str, length=8, error_info='企业ID异常', error_code=200)
|
||
|
company = ValidateAttr(field='company', type=str, error_info='企业名称异常', error_code=200)
|
||
|
project = ValidateAttr(field='project', type=str, in_list=["综合信用评价", "ESG评价"], error_info='评价项目异常', error_code=200)
|
||
|
methods = ValidateAttr(field='methods', type=str, in_list=["企业申报"], error_info='评价方式异常', error_code=200)
|
||
|
status = ValidateAttr(field='status', type=str, in_list=["进行", "完成"], error_info='进行状态异常', error_code=200)
|
||
|
result = ValidateAttr(field='result', type=str,
|
||
|
in_list=["AAA", "AA+", "AA", "AA-", "A+", "A", "A-", "BBB+", "BBB", "BBB-", "BB+", "BB",
|
||
|
"BB-", "B+", "B", "B-", "CCC", "CC"], error_info='评价结果异常', error_code=200)
|
||
|
report_fid = ValidateAttr(field='report_fid', type=str, error_info='报告fid异常', error_code=200)
|
||
|
certificate_fid = ValidateAttr(field='certificate_fid', type=str, error_info='证书fid异常', error_code=200)
|
||
|
begin_time = ValidateAttr(field='begin_time', type=str, error_info='开始填报时间异常', error_code=200)
|
||
|
submit_time = ValidateAttr(field='submit_time', type=str, error_info='提交填报时间异常', error_code=200)
|
||
|
finish_time = ValidateAttr(field='finish_time', type=str, error_info='评价完成时间异常', error_code=200)
|
||
|
finish_date = ValidateAttr(field='finish_date', type=str, error_info='评价完成日期异常', error_code=200)
|
||
|
|
||
|
def rating_info_dict_to_save(self, **kwargs):
|
||
|
"""存储对象"""
|
||
|
_dict_ = {
|
||
|
"评价ID": self.rid,
|
||
|
"企业ID": self.cid,
|
||
|
"企业名称": self.company,
|
||
|
"评价项目": self.project,
|
||
|
"评价方式": self.methods,
|
||
|
"进行状态": self.status,
|
||
|
"评价结果": self.result,
|
||
|
"报告fid": self.report_fid,
|
||
|
"证书fid": self.certificate_fid,
|
||
|
"开始填报时间": self.begin_time,
|
||
|
"提交填报时间": self.submit_time,
|
||
|
"评价完成时间": self.finish_time,
|
||
|
"评价完成日期": self.finish_date
|
||
|
}
|
||
|
if 'columns' in list(kwargs.keys()):
|
||
|
_dict_ = {key: _dict_[key] for key in kwargs['columns']}
|
||
|
|
||
|
return _dict_
|
||
|
|
||
|
|
||
|
class BusinessQuestionnaire(object):
|
||
|
"""经营问卷"""
|
||
|
question_01 = ValidateAttr(field='question_01', type=str, in_list=["A", "B"], error_info='问卷答案01异常', error_code=200)
|
||
|
question_02 = ValidateAttr(field='question_02', type=list, in_list=["A", "B", "C", "D"], error_info='问卷答案02异常', error_code=200)
|
||
|
question_03 = ValidateAttr(field='question_03', type=float, error_info='问卷答案03异常', error_code=200)
|
||
|
question_04 = ValidateAttr(field='question_04', type=float, error_info='问卷答案04异常', error_code=200)
|
||
|
question_05 = ValidateAttr(field='question_05', type=float, error_info='问卷答案05异常', error_code=200)
|
||
|
question_06 = ValidateAttr(field='question_06', type=float, error_info='问卷答案06异常', error_code=200)
|
||
|
question_07 = ValidateAttr(field='question_07', type=str, in_list=["A", "B", "C", "D"], error_info='问卷答案07异常', error_code=200)
|
||
|
question_08 = ValidateAttr(field='question_08', type=str, in_list=["A", "B", "C", "D"], error_info='问卷答案08异常', error_code=200)
|
||
|
question_09 = ValidateAttr(field='question_09', type=str, in_list=["A", "B", "C"], error_info='问卷答案09异常', error_code=200)
|
||
|
question_10 = ValidateAttr(field='question_10', type=str, in_list=["A", "B", "C", "D"], error_info='问卷答案10异常', error_code=200)
|
||
|
question_11 = ValidateAttr(field='question_11', type=str, in_list=["A", "B"], error_info='问卷答案11异常', error_code=200)
|
||
|
question_12 = ValidateAttr(field='question_12', type=str, in_list=["A", "B"], error_info='问卷答案12异常', error_code=200)
|
||
|
question_13 = ValidateAttr(field='question_13', type=str, in_list=["A", "B", "C", "D", "E"], error_info='问卷答案13异常', error_code=200)
|
||
|
question_14 = ValidateAttr(field='question_14', type=float, error_info='问卷答案14异常', error_code=200)
|
||
|
question_15 = ValidateAttr(field='question_15', type=str, in_list=["A", "B", "C"], error_info='问卷答案15异常', error_code=200)
|
||
|
question_16 = ValidateAttr(field='question_16', type=str, in_list=["A", "B", "C"], error_info='问卷答案16异常', error_code=200)
|
||
|
question_17 = ValidateAttr(field='question_17', type=str, in_list=["A", "B", "C"], error_info='问卷答案17异常', error_code=200)
|
||
|
question_18 = ValidateAttr(field='question_18', type=str, in_list=["A", "B", "C", "D", "E"], error_info='问卷答案18异常', error_code=200)
|
||
|
question_19 = ValidateAttr(field='question_19', type=str, in_list=["A", "B"], error_info='问卷答案19异常', error_code=200)
|
||
|
question_20 = ValidateAttr(field='question_20', type=float, error_info='问卷答案20异常', error_code=200)
|
||
|
question_21 = ValidateAttr(field='question_21', type=list, in_list=["A", "B", "C", "D", "E", "F", "G"], error_info='问卷答案21异常', error_code=200)
|
||
|
question_22 = ValidateAttr(field='question_22', type=str, in_list=["A", "B", "C"], error_info='问卷答案22异常', error_code=200)
|
||
|
question_23 = ValidateAttr(field='question_23', type=str, in_list=["A", "B", "C"], error_info='问卷答案23异常', error_code=200)
|
||
|
question_24 = ValidateAttr(field='question_24', type=str, in_list=["A", "B", "C"], error_info='问卷答案24异常', error_code=200)
|
||
|
question_25 = ValidateAttr(field='question_25', type=str, in_list=["A", "B", "C", "D"], error_info='问卷答案25异常', error_code=200)
|
||
|
question_26 = ValidateAttr(field='question_26', type=str, in_list=["A", "B", "C", "D", "E"], error_info='问卷答案26异常', error_code=200)
|
||
|
question_27 = ValidateAttr(field='question_27', type=float, error_info='问卷答案27异常', error_code=200)
|
||
|
question_28 = ValidateAttr(field='question_28', type=str, in_list=["A", "B"], error_info='问卷答案28异常', error_code=200)
|
||
|
question_29 = ValidateAttr(field='question_29', type=str, in_list=["A", "B", "C"], error_info='问卷答案29异常', error_code=200)
|
||
|
question_30 = ValidateAttr(field='question_30', type=str, in_list=["A", "B"], error_info='问卷答案30异常', error_code=200)
|
||
|
|
||
|
def business_questionnaire_dict_to_save(self):
|
||
|
"""存储对象"""
|
||
|
_dict_ = [
|
||
|
self.question_01,
|
||
|
self.question_02,
|
||
|
self.question_03,
|
||
|
self.question_04,
|
||
|
self.question_05,
|
||
|
self.question_06,
|
||
|
self.question_07,
|
||
|
self.question_08,
|
||
|
self.question_09,
|
||
|
self.question_10,
|
||
|
self.question_11,
|
||
|
self.question_12,
|
||
|
self.question_13,
|
||
|
self.question_14,
|
||
|
self.question_15,
|
||
|
self.question_16,
|
||
|
self.question_17,
|
||
|
self.question_18,
|
||
|
self.question_19,
|
||
|
self.question_20,
|
||
|
self.question_21,
|
||
|
self.question_22,
|
||
|
self.question_23,
|
||
|
self.question_24,
|
||
|
self.question_25,
|
||
|
self.question_26,
|
||
|
self.question_27,
|
||
|
self.question_28,
|
||
|
self.question_29,
|
||
|
self.question_30
|
||
|
]
|
||
|
|
||
|
return _dict_
|
||
|
|
||
|
|
||
|
class FinancialReport(object):
|
||
|
class BalanceSheet(object):
|
||
|
"""资产负债表"""
|
||
|
report_date = ValidateAttr(field='report_date', length=10, type=str, error_info='报告期异常', error_code=200)
|
||
|
accounts_receivable = ValidateAttr(field='accounts_receivable', type=float, error_info='应收账款异常', error_code=200)
|
||
|
stock = ValidateAttr(field='stock', type=float, error_info='存货异常', error_code=200)
|
||
|
total_current_assets = ValidateAttr(field='total_current_assets', type=float, error_info='流动资产合计异常',
|
||
|
error_code=200)
|
||
|
total_assets = ValidateAttr(field='total_assets', type=float, error_info='资产总计异常', error_code=200)
|
||
|
short_loan = ValidateAttr(field='short_loan', type=float, error_info='短期借款异常', error_code=200)
|
||
|
one_year_liabilities = ValidateAttr(field='one_year_liabilities', type=float, error_info='一年内到期非流动负债异常',
|
||
|
error_code=200)
|
||
|
total_current_liabilities = ValidateAttr(field='total_current_liabilities', type=float, error_info='流动负债合计异常',
|
||
|
error_code=200)
|
||
|
long_term_loan = ValidateAttr(field='long_term_loan', type=float, error_info='长期借款异常', error_code=200)
|
||
|
total_liabilities = ValidateAttr(field='total_liabilities', type=float, error_info='负债合计异常', error_code=200)
|
||
|
total_owners_equity = ValidateAttr(field='total_owners_equity', type=float, error_info='所有者权益合计异常',
|
||
|
error_code=200)
|
||
|
|
||
|
def dict_to_save(self):
|
||
|
"""存储对象"""
|
||
|
_dict_ = {
|
||
|
"报告期": self.report_date,
|
||
|
"应收账款": self.accounts_receivable,
|
||
|
"存货": self.stock,
|
||
|
"流动资产合计": self.total_current_assets,
|
||
|
"资产总计": self.total_assets,
|
||
|
"短期借款": self.short_loan,
|
||
|
"一年内到期非流动负债": self.one_year_liabilities,
|
||
|
"流动负债合计": self.total_current_liabilities,
|
||
|
"长期借款": self.long_term_loan,
|
||
|
"负债合计": self.total_liabilities,
|
||
|
"所有者权益合计": self.total_owners_equity
|
||
|
}
|
||
|
return _dict_
|
||
|
|
||
|
class IncomeSheet(object):
|
||
|
"""利润表"""
|
||
|
report_date = ValidateAttr(field='report_date', length=10, type=str, error_info='报告期异常', error_code=200)
|
||
|
operating_income = ValidateAttr(field='operating_income', type=float, error_info='营业收入异常', error_code=200)
|
||
|
operating_cost = ValidateAttr(field='operating_cost', type=float, error_info='营业成本异常', error_code=200)
|
||
|
total_profit = ValidateAttr(field='total_profit', type=float, error_info='利润总额异常', error_code=200)
|
||
|
net_profit = ValidateAttr(field='net_profit', type=float, error_info='净利润异常', error_code=200)
|
||
|
|
||
|
def dict_to_save(self):
|
||
|
"""存储对象"""
|
||
|
_dict_ = {
|
||
|
"报告期": self.report_date,
|
||
|
"营业收入": self.operating_income,
|
||
|
"营业成本": self.operating_cost,
|
||
|
"利润总额": self.total_profit,
|
||
|
"净利润": self.net_profit,
|
||
|
|
||
|
}
|
||
|
return _dict_
|
||
|
|
||
|
class AppendixDataSheet(object):
|
||
|
"""补充数据表"""
|
||
|
report_date = ValidateAttr(field='report_date', length=10, type=str, error_info='报告期异常', error_code=200)
|
||
|
rd_expenses = ValidateAttr(field='rd_expenses', type=float, error_info='研发费用异常', error_code=200)
|
||
|
interest_disbursement = ValidateAttr(field='interest_disbursement', type=float, error_info='计入财务费的利息支出异常',
|
||
|
error_code=200)
|
||
|
interest_expense = ValidateAttr(field='interest_expense', type=float, error_info='资本化利息支出异常', error_code=200)
|
||
|
|
||
|
def dict_to_save(self):
|
||
|
"""存储对象"""
|
||
|
_dict_ = {
|
||
|
"报告期": self.report_date,
|
||
|
"研发费用": self.rd_expenses,
|
||
|
"计入财务费的利息支出": self.interest_disbursement,
|
||
|
"资本化利息支出": self.interest_expense
|
||
|
}
|
||
|
return _dict_
|
||
|
|
||
|
balance_sheet_list = ValidateAttr(field='balance_sheet_list', type=list, length=3, error_info='资产负债表异常', error_code=200)
|
||
|
income_sheet_list = ValidateAttr(field='income_sheet_list', type=list, length=3, error_info='利润表异常', error_code=200)
|
||
|
appendix_data_sheet_list = ValidateAttr(field='appendix_data_sheet_list', type=list, length=3, error_info='补充数据表异常', error_code=200)
|
||
|
|
||
|
def financial_dict_to_save(self, **kwargs):
|
||
|
"""存储对象"""
|
||
|
_dict_ = {
|
||
|
"资产负债表": self.balance_sheet_list,
|
||
|
"利润表": self.income_sheet_list,
|
||
|
"补充数据表": self.appendix_data_sheet_list
|
||
|
}
|
||
|
if 'columns' in list(kwargs.keys()):
|
||
|
_dict_ = {key: _dict_[key] for key in kwargs['columns']}
|
||
|
|
||
|
return _dict_
|
||
|
|
||
|
|
||
|
class CreditRatingInput(object):
|
||
|
"""填报数据"""
|
||
|
rid = ValidateAttr(field='rid', type=str, length=8, error_info='评价ID异常', error_code=200)
|
||
|
cid = ValidateAttr(field='cid', type=str, length=8, error_info='企业ID异常', error_code=200)
|
||
|
company = ValidateAttr(field='company', type=str, error_info='企业名称异常', error_code=200)
|
||
|
year = ValidateAttr(field='year', type=str, length=5, error_info='评价年度异常', error_code=200)
|
||
|
industry = ValidateAttr(field='industry', type=list, length=2, error_info='行业选择异常', error_code=200)
|
||
|
business_questionnaire = ValidateAttr(field='business_questionnaire', instance_list=BusinessQuestionnaire,
|
||
|
error_info='经营问卷异常', error_code=200)
|
||
|
financial_report = ValidateAttr(field='financial_report', type=dict, length=3, error_info='财务填报异常', error_code=200)
|
||
|
|
||
|
def credit_rating_dict_to_save(self, **kwargs):
|
||
|
"""存储对象"""
|
||
|
_dict_ = {
|
||
|
"评价ID": self.rid,
|
||
|
"企业ID": self.cid,
|
||
|
"企业名称": self.company,
|
||
|
"评价年度": self.year,
|
||
|
"行业选择": self.industry,
|
||
|
"经营问卷": self.business_questionnaire,
|
||
|
"财务填报": self.financial_report
|
||
|
}
|
||
|
if 'columns' in list(kwargs.keys()):
|
||
|
_dict_ = {key: _dict_[key] for key in kwargs['columns']}
|
||
|
|
||
|
return _dict_
|