tfse-model-api-v0.2/Esg/scripts/social.py

395 lines
9.8 KiB
Python
Raw Normal View History

2022-02-17 16:44:58 +08:00
import operator
2022-02-11 16:53:01 +08:00
def social_rating(param):
"""
社会部分打分
Parameters:
param dict 填报问卷
Returns:
score float 社会部分得分
"""
2022-02-17 16:44:58 +08:00
result = dict()
result['离职人数占比'] = calculation_01(param)
result['人均薪酬涨幅'] = calculation_02(param)
result['劳动合同中的工作时长(周)'] = calculation_03(param)
result['劳动纠纷'] = calculation_04(param)
result['安全事故'] = calculation_05(param)
result['提供培训'] = calculation_06(param)
result['社保缴纳是否符合当地标准'] = calculation_07(param)
result['公积金缴纳是否符合当地标准'] = calculation_08(param)
result['是否提供员工体检'] = calculation_09(param)
result['是否提供带薪假期'] = calculation_10(param)
result['公司从前三大供货商拿货占比'] = calculation_11(param)
result['公司前3大客户销量占比'] = calculation_12(param)
result['公司返修、退回、投诉产品比例(%'] = calculation_13(param)
result['扶贫+捐赠规模(万元)'] = calculation_14(param)
result['司法风险'] = calculation_15(param)
2022-02-11 16:53:01 +08:00
fraction = list()
2022-02-17 16:44:58 +08:00
if result['司法风险'] == 'S=0':
2022-02-11 16:53:01 +08:00
score = 0
else:
2022-02-17 16:44:58 +08:00
for key, value in result.items():
if key == '司法风险':
continue
else:
fraction.append(value)
2022-02-11 16:53:01 +08:00
score = sum(fraction)
2022-02-17 16:44:58 +08:00
result['合计'] = score
return result
2022-02-11 16:53:01 +08:00
def calculation_01(param):
"""
离职人数占比
Parameters:
param dict 填报问卷
Returns:
score int 得分
"""
2022-02-17 16:44:58 +08:00
# Parameter
three_year_data = sorted(param['社会问卷']['近三年公司数据'], key=operator.itemgetter('年份'), reverse=False)
2022-02-11 16:53:01 +08:00
2022-03-08 13:42:18 +08:00
try:
year_begin = round(three_year_data[0]['当年离职人数'] / three_year_data[0]['员工总数(年底)'], 2)
year_middle = round(three_year_data[1]['当年离职人数'] / three_year_data[1]['员工总数(年底)'], 2)
year_end = round(three_year_data[2]['当年离职人数'] / three_year_data[2]['员工总数(年底)'], 2)
factor_01 = (year_begin + year_middle + year_end) / 3 * 100 <= 20
factor_02 = 20 < (year_begin + year_middle + year_end) / 3 * 100 <= 30
if factor_01:
score = 5
elif factor_02:
score = 2
else:
score = 0
except ZeroDivisionError:
2022-02-11 16:53:01 +08:00
score = 0
return score
def calculation_02(param):
"""
人均薪酬涨幅
Parameters:
param dict 填报问卷
Returns:
score int 得分
"""
2022-02-17 16:44:58 +08:00
# Parameter
three_year_data = sorted(param['社会问卷']['近三年公司数据'], key=operator.itemgetter('年份'), reverse=False)
2022-03-08 13:42:18 +08:00
try:
year_begin = three_year_data[0]['人均薪酬水平(元/月)']
year_end = three_year_data[2]['人均薪酬水平(元/月)']
2022-02-11 16:53:01 +08:00
2022-03-08 13:42:18 +08:00
factor = (year_end / year_begin) ** (1 / 2) - 1 >= 0.03
2022-02-11 16:53:01 +08:00
2022-03-08 13:42:18 +08:00
if factor:
score = 2
else:
score = 0
except ZeroDivisionError:
2022-02-11 16:53:01 +08:00
score = 0
return score
def calculation_03(param):
"""
劳动合同中的工作时长
Parameters:
param dict 填报问卷
Returns:
score int 得分
"""
2022-02-17 16:44:58 +08:00
# Parameter
three_year_data = sorted(param['社会问卷']['近三年公司数据'], key=operator.itemgetter('年份'), reverse=False)
2022-02-11 16:53:01 +08:00
2022-02-17 16:44:58 +08:00
year_begin = three_year_data[0]['劳动合同要求工作时长(每周小时数)']
year_middle = three_year_data[1]['劳动合同要求工作时长(每周小时数)']
year_end = three_year_data[2]['劳动合同要求工作时长(每周小时数)']
factor = (year_end + year_middle + year_begin) / 3 <= 45
2022-02-11 16:53:01 +08:00
if factor:
score = 4
else:
score = 0
return score
def calculation_04(param):
"""
劳动纠纷
Parameters:
param dict 填报问卷
Returns:
score int 得分
"""
2022-02-17 16:44:58 +08:00
# Parameter
three_year_data = sorted(param['社会问卷']['近三年公司数据'], key=operator.itemgetter('年份'), reverse=False)
year_begin = three_year_data[0]['劳资纠纷次数']
year_middle = three_year_data[1]['劳资纠纷次数']
year_end = three_year_data[2]['劳资纠纷次数']
2022-02-11 16:53:01 +08:00
2022-02-17 16:44:58 +08:00
factor = (year_end + year_middle + year_begin) <= 0
2022-02-11 16:53:01 +08:00
if factor:
score = 3
else:
score = 0
return score
def calculation_05(param):
"""
安全事故
Parameters:
param dict 填报问卷
Returns:
score int 得分
"""
2022-02-17 16:44:58 +08:00
# Parameter
three_year_data = sorted(param['社会问卷']['近三年公司数据'], key=operator.itemgetter('年份'), reverse=False)
2022-02-11 16:53:01 +08:00
2022-02-17 16:44:58 +08:00
year_begin = three_year_data[0]['安全事故发生次数']
year_middle = three_year_data[1]['安全事故发生次数']
year_end = three_year_data[2]['安全事故发生次数']
factor = (year_end + year_middle + year_begin) <= 0
2022-02-11 16:53:01 +08:00
if factor:
score = 3
else:
score = 0
return score
def calculation_06(param):
"""
提供培训
Parameters:
param dict 填报问卷
Returns:
score int 得分
"""
2022-02-17 16:44:58 +08:00
# Parameter
three_year_data = sorted(param['社会问卷']['近三年公司数据'], key=operator.itemgetter('年份'), reverse=False)
year_begin = three_year_data[0]['组织培训次数']
year_middle = three_year_data[1]['组织培训次数']
year_end = three_year_data[2]['组织培训次数']
2022-02-11 16:53:01 +08:00
2022-02-17 16:44:58 +08:00
factor_01 = (year_end + year_middle + year_begin) >= 4
factor_02 = (year_end + year_middle + year_begin) >= 1
2022-02-11 16:53:01 +08:00
if factor_01:
score = 5
elif factor_02:
score = 2
else:
score = 0
return score
def calculation_07(param):
"""
社保缴纳是否符合当地标准
Parameters:
param dict 填报问卷
Returns:
score int 得分
"""
anwser = param['社会问卷']['其他类型问卷'][0]
if anwser == 'A':
2022-02-11 16:53:01 +08:00
score = 1
else:
score = 0
return score
def calculation_08(param):
"""
公积金缴纳是否符合当地标准
Parameters:
param dict 填报问卷
Returns:
score int 得分
"""
anwser = param['社会问卷']['其他类型问卷'][1]
if anwser == 'A':
2022-02-11 16:53:01 +08:00
score = 1
else:
score = 0
return score
def calculation_09(param):
"""
是否提供员工体检
Parameters:
param dict 填报问卷
Returns:
score int 得分
"""
anwser = param['社会问卷']['其他类型问卷'][2]
if anwser == 'A':
2022-02-11 16:53:01 +08:00
score = 1
else:
score = 0
return score
def calculation_10(param):
"""
是否提供带薪假期
Parameters:
param dict 填报问卷
Returns:
score int 得分
"""
anwser = param['社会问卷']['其他类型问卷'][3]
if anwser == 'A':
2022-02-11 16:53:01 +08:00
score = 1
else:
score = 0
return score
def calculation_11(param):
"""
公司从前三大供货商拿货占比
Parameters:
param dict 填报问卷
Returns:
score int 得分
"""
2022-02-17 16:44:58 +08:00
# Parameter
three_year_data = sorted(param['社会问卷']['近三年公司数据'], key=operator.itemgetter('年份'), reverse=False)
2022-02-11 16:53:01 +08:00
2022-02-17 16:44:58 +08:00
year_begin = three_year_data[0]['公司从前3大供应商拿货占全部供应商比例%']
year_end = three_year_data[2]['公司从前3大供应商拿货占全部供应商比例%']
factor = year_begin >= year_end
2022-02-11 16:53:01 +08:00
if factor:
score = 1
else:
score = 0
return score
def calculation_12(param):
"""
公司前3大客户销量占比
Parameters:
param dict 填报问卷
Returns:
score int 得分
"""
2022-02-17 16:44:58 +08:00
# Parameter
three_year_data = sorted(param['社会问卷']['近三年公司数据'], key=operator.itemgetter('年份'), reverse=False)
year_begin = three_year_data[0]['公司前3大客户销售额占全部销售比例%']
year_end = three_year_data[2]['公司前3大客户销售额占全部销售比例%']
2022-02-11 16:53:01 +08:00
2022-02-17 16:44:58 +08:00
factor = year_begin >= year_end
2022-02-11 16:53:01 +08:00
if factor:
score = 1
else:
score = 0
return score
def calculation_13(param):
"""
公司返修退回投诉产品比例%
Parameters:
param dict 填报问卷
Returns:
score int 得分
"""
2022-02-17 16:44:58 +08:00
# Parameter
three_year_data = sorted(param['社会问卷']['近三年公司数据'], key=operator.itemgetter('年份'), reverse=False)
2022-02-11 16:53:01 +08:00
2022-02-17 16:44:58 +08:00
year_end = three_year_data[0]['返修、退回、投诉产品对应销售额占全部销售比例(%']
year_begin = three_year_data[2]['返修、退回、投诉产品对应销售额占全部销售比例(%']
factor = year_begin >= year_end
2022-02-11 16:53:01 +08:00
if factor:
score = 1
else:
score = 0
return score
def calculation_14(param):
"""
扶贫+捐赠规模万元
Parameters:
param dict 填报问卷
Returns:
score int 得分
"""
2022-02-17 16:44:58 +08:00
# Parameter
three_year_data = sorted(param['社会问卷']['近三年公司数据'], key=operator.itemgetter('年份'), reverse=False)
year_begin = three_year_data[0]['扶贫+捐赠规模(万元)']
year_middle = three_year_data[1]['扶贫+捐赠规模(万元)']
year_end = three_year_data[2]['扶贫+捐赠规模(万元)']
2022-02-11 16:53:01 +08:00
2022-02-17 16:44:58 +08:00
factor_01 = (year_end + year_middle + year_begin) > 0
2022-02-11 16:53:01 +08:00
if factor_01:
score = 5
else:
score = 0
return score
def calculation_15(param):
"""
司法风险
Parameters:
param dict 填报问卷
Returns:
score int 得分
"""
risk = param['风险数据']
score = None
for value in risk.values():
if value > 0:
score = 'S=0'
break
else:
score = 0
return score