tfse-app-api-v0.2/Rating/Esg/EsgObj.py

271 lines
13 KiB
Python
Raw Normal View History

from Utils.ObjUtil import SpecObject
from Utils.ValidateUtil import ValidateAttr
class RatingRecord(SpecObject):
"""评价记录 """
rid = ValidateAttr(field='rid', type=str, length=8)
cid = ValidateAttr(field='cid', type=str, length=8)
company = ValidateAttr(field='company', type=str)
project = ValidateAttr(field='project', type=str, in_list=["综合信用评价", "ESG评价"])
methods = ValidateAttr(field='methods', type=str, in_list=["企业申报"])
status = ValidateAttr(field='status', type=str, in_list=["进行", "完成"])
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"], default=None)
report_fid = ValidateAttr(field='report_fid', type=str, default=None)
certificate_fid = ValidateAttr(field='certificate_fid', type=str, default=None)
begin_time = ValidateAttr(field='begin_time', type=str)
submit_time = ValidateAttr(field='submit_time', type=str, default=None)
finish_time = ValidateAttr(field='finish_time', type=str, default=None)
finish_date = ValidateAttr(field='finish_date', type=str, default=None)
fields_map = {
"rid": "评价ID",
"cid": "企业ID",
"company": "企业名称",
"project": "评价项目",
"methods": "评价方式",
"status": "进行状态",
"result": "评价结果",
"report_fid": "报告fid",
"certificate_fid": "证书fid",
"begin_time": "开始填报时间",
"submit_time": "提交填报时间",
"finish_time": "评价完成时间",
"finish_date": "评价完成日期"
}
class ThreeYearDataByE(SpecObject):
"""环境问卷近三年数据"""
year = ValidateAttr(field='year', default=None, length=5, type=str)
raw_coal = ValidateAttr(field='raw_coal', default=None, type=float)
coke = ValidateAttr(field='coke', default=None, type=float)
crude = ValidateAttr(field='crude', default=None, type=float)
fuel_oil = ValidateAttr(field='fuel_oil', default=None, type=float)
gasoline = ValidateAttr(field='gasoline', default=None, type=float)
kerosene = ValidateAttr(field='kerosene', default=None, type=float)
diesel_fuel = ValidateAttr(field='diesel_fuel', default=None, type=float)
liquefied_petroleum_gas = ValidateAttr(field='liquefied_petroleum_gas', default=None, type=float)
natural_gas = ValidateAttr(field='natural_gas', default=None, type=float)
gas = ValidateAttr(field='gas', default=None, type=float)
electricity = ValidateAttr(field='electricity', default=None, type=float)
water = ValidateAttr(field='water', default=None, type=float)
green_income = ValidateAttr(field='green_income', default=None, type=float)
fields_map = {
"year": "年份",
"raw_coal": "公司当年消耗的原煤(千克)",
"coke": "公司当年消耗的焦炭(千克)",
"crude": "公司当年消耗的原油(升)",
"fuel_oil": "公司当年消耗的燃料油(升)",
"gasoline": "公司当年消耗的汽油(升)",
"kerosene": "公司当年消耗的煤油(升)",
"diesel_fuel": "公司当年消耗的柴油(升)",
"liquefied_petroleum_gas": "公司当年消耗的液化石油气(千克)",
"natural_gas": "公司当年消耗的天然气(立方米)",
"gas": "公司当年消耗的煤气(立方米)",
"electricity": "公司当年消耗的电(千瓦时)",
"water": "公司当年耗水(吨)",
"green_income": "公司当年绿色业务收入(万元)——包括不限于清洁能源、清洁交通、绿色建筑、清洁技术等"
}
class OtherTypeDataByE(object):
"""环境问卷其他类型问卷"""
question_01 = ValidateAttr(field='question_01', default=None, type=str, in_list=["A", "B"],
error_info='环境其他类型问卷01异常',
error_code=200)
question_02 = ValidateAttr(field='question_02', default=None, type=str, in_list=["A", "B"],
error_info='环境其他类型问卷02异常',
error_code=200)
question_03 = ValidateAttr(field='question_03', default=None, type=str, in_list=["A", "B"],
error_info='环境其他类型问卷03异常',
error_code=200)
question_04 = ValidateAttr(field='question_04', default=None, type=str, in_list=["A", "B"],
error_info='环境其他类型问卷04异常',
error_code=200)
question_05 = ValidateAttr(field='question_05', default=None, type=str, in_list=["A", "B"],
error_info='环境其他类型问卷05异常',
error_code=200)
question_06 = ValidateAttr(field='question_06', default=None, type=str, in_list=["A", "B"],
error_info='环境其他类型问卷06异常',
error_code=200)
question_07 = ValidateAttr(field='question_07', default=None, type=str, in_list=["A", "B"],
error_info='环境其他类型问卷07异常',
error_code=200)
question_08 = ValidateAttr(field='question_08', default=None, type=str, in_list=["A", "B"],
error_info='环境其他类型问卷08异常',
error_code=200)
def list_to_save(self):
"""存储对象"""
_list_ = [
self.question_01,
self.question_02,
self.question_03,
self.question_04,
self.question_05,
self.question_06,
self.question_07,
self.question_08
]
return _list_
class EnvironmentQuestionnaire(SpecObject):
"""环境问卷"""
2022-04-15 15:06:05 +08:00
e_three_year_data = ValidateAttr(field='e_three_year_data', instance_list=ThreeYearDataByE)
e_other_type_data = ValidateAttr(field='e_other_type_data', type=list)
fields_map = {
"e_three_year_data": "近三年公司数据",
"e_other_type_data": "其他类型问卷"
}
class ThreeYearDataByS(SpecObject):
"""社会问卷近三年数据"""
year = ValidateAttr(field='year', default=None, length=5, type=str)
employee_total = ValidateAttr(field='employee_total', default=None, type=int)
leaving_total = ValidateAttr(field='leaving_total', default=None, type=int)
salary_level = ValidateAttr(field='salary_level', default=None, type=float)
work_length = ValidateAttr(field='work_length', default=None, type=float)
labor_dispute = ValidateAttr(field='labor_dispute', default=None, type=int)
security_incident = ValidateAttr(field='security_incident', default=None, type=int)
training_times = ValidateAttr(field='training_times', default=None, type=int)
supplier = ValidateAttr(field='supplier', type=float, default=None)
sales = ValidateAttr(field='sales', type=float, default=None)
return_sales = ValidateAttr(field='return_sales', default=None, type=float)
donate = ValidateAttr(field='donate', default=None, type=float)
fields_map = {
"year": "年份",
"employee_total": "员工总数(年底)",
"leaving_total": "当年离职人数",
"salary_level": "人均薪酬水平(元/月)",
"work_length": "劳动合同要求工作时长(每周小时数)",
"labor_dispute": "劳资纠纷次数",
"security_incident": "安全事故发生次数",
"training_times": "组织培训次数",
"supplier": "公司从前3大供应商拿货占全部供应商比例%",
"sales": "公司前3大客户销售额占全部销售比例%",
"return_sales": "返修、退回、投诉产品对应销售额占全部销售比例(%",
"donate": "扶贫+捐赠规模(万元)"
}
class OtherTypeDataByS(object):
"""社会问卷其他类型数据"""
question_01 = ValidateAttr(field='question_01', default=None, type=str, in_list=["A", "B"], error_info='社会其他类型问卷01异常',
error_code=200)
question_02 = ValidateAttr(field='question_02', default=None, type=str, in_list=["A", "B"], error_info='社会其他类型问卷02异常',
error_code=200)
question_03 = ValidateAttr(field='question_03', default=None, type=str, in_list=["A", "B"], error_info='社会其他类型问卷03异常',
error_code=200)
question_04 = ValidateAttr(field='question_04', default=None, type=str, in_list=["A", "B"], error_info='社会其他类型问卷04异常',
error_code=200)
def list_to_save(self):
"""存储对象"""
_list_ = [
self.question_01,
self.question_02,
self.question_03,
self.question_04
]
return _list_
class SocietyQuestionnaire(SpecObject):
"""社会问卷"""
2022-04-15 15:06:05 +08:00
s_three_year_data = ValidateAttr(field='s_three_year_data', instance_list=ThreeYearDataByS)
s_other_type_data = ValidateAttr(field='s_other_type_data', type=list)
fields_map = {
"s_three_year_data": "近三年公司数据",
"s_other_type_data": "其他类型问卷"
}
class ThreeYearDataByG(SpecObject):
"""治理问卷近三年数据"""
year = ValidateAttr(field='year', default=None, length=5, type=str)
audit_report = ValidateAttr(field='audit_report', default=None, type=str, in_list=['', ''])
net_assets = ValidateAttr(field='net_assets', default=None, type=float)
net_profit = ValidateAttr(field='net_profit', default=None, type=float)
fields_map = {
"year": "年份",
"audit_report": "公司是否有审计报告",
"net_assets": "公司净资产(万元)",
"net_profit": "公司净利润(万元)"
}
class OtherTypeDataByG(object):
question_01 = ValidateAttr(field='question_01', default=None, type=str, in_list=["A", "B"], error_info='环境其他类型问卷01异常',
error_code=200)
question_02 = ValidateAttr(field='question_02', default=None, type=str, in_list=["A", "B"], error_info='环境其他类型问卷02异常',
error_code=200)
question_03 = ValidateAttr(field='question_03', default=None, type=int, error_info='环境其他类型问卷03异常', error_code=200)
question_04 = ValidateAttr(field='question_04', default=None, type=int, error_info='环境其他类型问卷04异常', error_code=200)
question_05 = ValidateAttr(field='question_05', default=None, type=str, in_list=["A", "B"], error_info='环境其他类型问卷05异常',
error_code=200)
question_06 = ValidateAttr(field='question_06', default=None, type=str, in_list=["A", "B"], error_info='环境其他类型问卷06异常',
error_code=200)
question_07 = ValidateAttr(field='question_07', default=None, type=str, in_list=["A", "B"], error_info='环境其他类型问卷07异常',
error_code=200)
question_08 = ValidateAttr(field='question_08', default=None, type=str, in_list=["A", "B"], error_info='环境其他类型问卷08异常',
error_code=200)
def list_to_save(self):
"""存储对象"""
_list_ = [
self.question_01,
self.question_02,
self.question_03,
self.question_04,
self.question_05,
self.question_06,
self.question_07,
self.question_08
]
return _list_
class GovernanceQuestionnaire(SpecObject):
"""治理问卷"""
2022-04-15 15:06:05 +08:00
g_three_year_data = ValidateAttr(field='g_three_year_data', instance_list=ThreeYearDataByG)
g_other_type_data = ValidateAttr(field='g_other_type_data', type=list)
fields_map = {
"g_three_year_data": "近三年公司数据",
"g_other_type_data": "其他类型问卷"
}
class EsgInputData(SpecObject):
"""ESG填报数据"""
rid = ValidateAttr(field='rid', type=str, length=8)
cid = ValidateAttr(field='cid', type=str, length=8)
company = ValidateAttr(field='company', type=str)
year = ValidateAttr(field='year', type=str, length=5)
industry = ValidateAttr(field='industry', type=list)
2022-04-15 15:06:05 +08:00
current_year_income = ValidateAttr(field='current_year_income', type=dict)
environment = ValidateAttr(field='environment', type=EnvironmentQuestionnaire)
society = ValidateAttr(field='society', type=SocietyQuestionnaire)
governance = ValidateAttr(field='governance', type=GovernanceQuestionnaire)
fields_map = {
"rid": "评价ID",
"cid": "企业ID",
"company": "企业名称",
"year": "评价年度",
"industry": "所属行业",
"current_year_income": "公司当年收入(万元)",
"environment": "环境问卷",
"society": "社会问卷",
"governance": "治理问卷"
}