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 EnvironmentInput(object): class ThreeYearDataByE(object): """近三年公司数据""" year = ValidateAttr(field='year', default=None, length=5, type=str, error_info='年份异常', error_code=200) raw_coal = ValidateAttr(field='raw_coal', default=None, type=float, error_info='原煤异常', error_code=200) coke = ValidateAttr(field='coke', default=None, type=float, error_info='焦炭异常', error_code=200) crude = ValidateAttr(field='crude', default=None, type=float, error_info='原油异常', error_code=200) fuel_oil = ValidateAttr(field='fuel_oil', default=None, type=float, error_info='燃料油异常', error_code=200) gasoline = ValidateAttr(field='gasoline', default=None, type=float, error_info='汽油异常', error_code=200) kerosene = ValidateAttr(field='kerosene', default=None, type=float, error_info='煤油异常', error_code=200) diesel_fuel = ValidateAttr(field='diesel_fuel', default=None, type=float, error_info='柴油异常', error_code=200) liquefied_petroleum_gas = ValidateAttr(field='liquefied_petroleum_gas', default=None, type=float, error_info='液化石油气异常', error_code=200) natural_gas = ValidateAttr(field='natural_gas', default=None, type=float, error_info='天然气异常', error_code=200) gas = ValidateAttr(field='gas', default=None, type=float, error_info='煤气异常', error_code=200) electricity = ValidateAttr(field='electricity', default=None, type=float, error_info='电异常', error_code=200) water = ValidateAttr(field='water', default=None, type=float, error_info='耗水异常', error_code=200) green_income = ValidateAttr(field='green_income', default=None, type=float, error_info='绿色业务收入异常', error_code=200) def dict_to_save(self): """存储对象""" _dict_ = { "年份": self.year, "公司当年消耗的原煤(千克)": self.raw_coal, "公司当年消耗的焦炭(千克)": self.coke, "公司当年消耗的原油(升)": self.crude, "公司当年消耗的燃料油(升)": self.fuel_oil, "公司当年消耗的汽油(升)": self.gasoline, "公司当年消耗的煤油(升)": self.kerosene, "公司当年消耗的柴油(升)": self.diesel_fuel, "公司当年消耗的液化石油气(千克)": self.liquefied_petroleum_gas, "公司当年消耗的天然气(立方米)": self.natural_gas, "公司当年消耗的煤气(立方米)": self.gas, "公司当年消耗的电(千瓦时)": self.electricity, "公司当年耗水(吨)": self.water, "公司当年绿色业务收入(万元)——包括不限于清洁能源、清洁交通、绿色建筑、清洁技术等": self.green_income } return _dict_ 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_ e_three_year_data = ValidateAttr(field='three_year_data', type=list, length=3, error_info='环境问卷近三年数据异常', error_code=200) e_other_type_data = ValidateAttr(field='other_type_data', type=list, length=8, error_info='环境其他类型问卷异常', error_code=200) def environment_dict_to_save(self, **kwargs): """存储对象""" _dict_ = { "近三年公司数据": self.e_three_year_data, "其他类型问卷": self.e_other_type_data } if 'columns' in list(kwargs.keys()): _dict_ = {key: _dict_[key] for key in kwargs['columns']} return _dict_ class SocietyInput(object): class ThreeYearDataByS(object): """近三年公司数据""" year = ValidateAttr(field='year', default=None, length=5, type=str, error_info='年份异常', error_code=200) employee_total = ValidateAttr(field='employee_total', default=None, type=int, error_info='员工总数(年底)异常', error_code=200) leaving_total = ValidateAttr(field='leaving_total', default=None, type=int, error_info='当年离职人数异常', error_code=200) salary_level = ValidateAttr(field='salary_level', default=None, type=float, error_info='人均薪酬水平(元/月)异常', error_code=200) work_length = ValidateAttr(field='work_length', default=None, type=float, error_info='劳动合同要求工作时长(每周小时数)异常', error_code=200) labor_dispute = ValidateAttr(field='labor_dispute', default=None, type=int, error_info='劳资纠纷次数异常', error_code=200) security_incident = ValidateAttr(field='security_incident', default=None, type=int, error_info='安全事故发生次数异常', error_code=200) training_times = ValidateAttr(field='training_times', default=None, type=int, error_info='组织培训次数异常', error_code=200) supplier = ValidateAttr(field='supplier', type=float, default=None, error_info='公司从前3大供应商拿货占全部供应商比例异常', error_code=200) sales = ValidateAttr(field='sales', type=float, default=None, error_info='公司前3大客户销售额占全部销售比例异常', error_code=200) return_sales = ValidateAttr(field='return_sales', default=None, type=float, error_info='返修、退回、投诉产品对应销售额占全部销售比例异常', error_code=200) donate = ValidateAttr(field='donate', default=None, type=float, error_info='扶贫+捐赠规模异常', error_code=200) def dict_to_save(self): """存储对象""" _dict_ = { "年份": self.year, "员工总数(年底)": self.employee_total, "当年离职人数": self.leaving_total, "人均薪酬水平(元/月)": self.salary_level, "劳动合同要求工作时长(每周小时数)": self.work_length, "劳资纠纷次数": self.labor_dispute, "安全事故发生次数": self.security_incident, "组织培训次数": self.training_times, "公司从前3大供应商拿货占全部供应商比例(%)": self.supplier, "公司前3大客户销售额占全部销售比例(%)": self.sales, "返修、退回、投诉产品对应销售额占全部销售比例(%)": self.return_sales, "扶贫+捐赠规模(万元)": self.donate } return _dict_ 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_ s_three_year_data = ValidateAttr(field='three_year_data', type=list, length=3, error_info='社会问卷近三年数据异常', error_code=200) s_other_type_data = ValidateAttr(field='other_type_data', type=list, length=4, error_info='社会其他类型问卷异常', error_code=200) def society_dict_to_save(self, **kwargs): """存储对象""" _dict_ = { "近三年公司数据": self.s_three_year_data, "其他类型问卷": self.s_other_type_data } if 'columns' in list(kwargs.keys()): _dict_ = {key: _dict_[key] for key in kwargs['columns']} return _dict_ class GovernanceInput(object): class ThreeYearDataByG(object): """近三年公司数据""" year = ValidateAttr(field='year', default=None, length=5, type=str, error_info='年份异常', error_code=200) audit_report = ValidateAttr(field='audit_report', default=None, type=str, in_list=['是', '否'], error_info='公司是否有审计报告异常', error_code=200) net_assets = ValidateAttr(field='net_assets', default=None, type=float, error_info='公司净资产异常', error_code=200) net_profit = ValidateAttr(field='net_profit', default=None, type=float, error_info='公司净利润异常', error_code=200) def dict_to_save(self): """存储对象""" _dict_ = { "年份": self.year, "公司是否有审计报告": self.audit_report, "公司净资产(万元)": self.net_assets, "公司净利润(万元)": self.net_profit } return _dict_ 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_ g_three_year_data = ValidateAttr(field='three_year_data', type=list, length=3, error_info='治理问卷近三年数据异常', error_code=200) g_other_type_data = ValidateAttr(field='other_type_data', type=list, length=8, error_info='治理其他类型问卷异常', error_code=200) def governance_dict_to_save(self, **kwargs): """存储对象""" _dict_ = { "近三年公司数据": self.g_three_year_data, "其他类型问卷": self.g_other_type_data } if 'columns' in list(kwargs.keys()): _dict_ = {key: _dict_[key] for key in kwargs['columns']} return _dict_ class EsgRatingInput(object): """ESG填报数据""" 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) current_year_income = ValidateAttr(field='current_year_income', type=dict, length=3, error_info='公司当年收入异常', error_code=200) environment = ValidateAttr(field='environment', type=dict, length=2, error_info='环境问卷异常', error_code=200) society = ValidateAttr(field='society', type=dict, length=2, error_info='社会问卷异常', error_code=200) governance = ValidateAttr(field='governance', type=dict, length=2, error_info='治理问卷异常', error_code=200) def esg_input_dict_to_save(self, **kwargs): """存储对象""" _dict_ = { "评价ID": self.rid, "企业ID": self.cid, "企业名称": self.company, "评价年度": self.year, "所属行业": self.industry, "公司当年收入(万元)": self.current_year_income, "环境问卷": self.environment, "社会问卷": self.society, "治理问卷": self.governance } if 'columns' in list(kwargs.keys()): _dict_ = {key: _dict_[key] for key in kwargs['columns']} return _dict_