2022-07-05 10:46:00 +08:00
|
|
|
from Utils.ObjUtil import SpecObject
|
|
|
|
from Utils.ValidateUtil import ValidateAttr, Validate
|
|
|
|
|
|
|
|
|
|
|
|
class ScoreModelObj(SpecObject):
|
|
|
|
"""打分模型"""
|
|
|
|
|
|
|
|
class LevelSetting(SpecObject):
|
|
|
|
"""级别设置"""
|
|
|
|
level = ValidateAttr(field='level', type=str)
|
|
|
|
score = ValidateAttr(field='score', type=[int, float])
|
|
|
|
position = ValidateAttr(field='position', type=[int, float])
|
|
|
|
|
|
|
|
fields_map = {
|
|
|
|
"level": "级别",
|
|
|
|
"score": "得分",
|
|
|
|
"position": "分位"
|
|
|
|
}
|
|
|
|
|
|
|
|
class Dimension(SpecObject):
|
|
|
|
"""维度"""
|
|
|
|
|
|
|
|
class FirstIndex(SpecObject):
|
|
|
|
"""一级指标"""
|
|
|
|
|
|
|
|
class SecondaryIndex(SpecObject):
|
|
|
|
"""二级指标"""
|
|
|
|
|
|
|
|
class ScoreSetting(SpecObject):
|
|
|
|
"""打分设置"""
|
|
|
|
pattern = ValidateAttr(field="pattern", type=str)
|
|
|
|
interval = ValidateAttr(field="interval", type=list)
|
|
|
|
score_position = ValidateAttr(field="score_position", type=list)
|
|
|
|
|
|
|
|
fields_map = {
|
|
|
|
"pattern": "模式",
|
|
|
|
"interval": "区间",
|
|
|
|
"score_position": "打分位"
|
|
|
|
}
|
|
|
|
|
|
|
|
class BindIndex(SpecObject):
|
|
|
|
"""打分指标"""
|
|
|
|
|
|
|
|
class BindSet(SpecObject):
|
|
|
|
"""绑定设置"""
|
|
|
|
|
|
|
|
class Params(SpecObject):
|
|
|
|
"""传入参数"""
|
|
|
|
|
|
|
|
class DataBind(SpecObject):
|
|
|
|
"""数据绑定"""
|
|
|
|
data_base = ValidateAttr(field="data_base", type=str)
|
|
|
|
data_sheet = ValidateAttr(field="data_sheet", type=str)
|
|
|
|
data_field = ValidateAttr(field="data_field", type=str)
|
|
|
|
dispose_none_string = ValidateAttr(field="dispose_none_string",
|
|
|
|
type=[int, float, str, None])
|
|
|
|
dispose_none_value = ValidateAttr(field="dispose_none_value",
|
|
|
|
type=[int, float, str, None])
|
|
|
|
|
|
|
|
fields_map = {
|
|
|
|
"data_base": "数据库",
|
|
|
|
"data_sheet": "数据表",
|
|
|
|
"data_field": "字段",
|
|
|
|
"dispose_none_string": "处理空字符串",
|
|
|
|
"dispose_none_value": "处理空值"
|
|
|
|
}
|
|
|
|
|
|
|
|
param = ValidateAttr(field="param", type=str)
|
|
|
|
describe = ValidateAttr(field="describe", type=str)
|
|
|
|
data_bind = ValidateAttr(field="data_bind", type=DataBind)
|
|
|
|
|
|
|
|
fields_map = {
|
|
|
|
"param": "参数",
|
|
|
|
"describe": "说明",
|
|
|
|
"data_bind": "数据绑定"
|
|
|
|
}
|
|
|
|
|
|
|
|
type = ValidateAttr(field='type', type=str)
|
|
|
|
name = ValidateAttr(field='name', type=str)
|
|
|
|
params = ValidateAttr(field='params', type=Params)
|
|
|
|
|
|
|
|
fields_map = {
|
|
|
|
"type": "类型",
|
|
|
|
"name": "名称",
|
|
|
|
"params": "传入参数"
|
|
|
|
}
|
|
|
|
|
|
|
|
index_name = ValidateAttr(field="index_name", type=str)
|
|
|
|
bind_set = ValidateAttr(field="bind_set", type=BindSet)
|
|
|
|
|
|
|
|
fields_map = {
|
|
|
|
"index_name": "指标名称",
|
|
|
|
"bind_set": "绑定设置"
|
|
|
|
}
|
|
|
|
|
|
|
|
name = ValidateAttr(field="name", type=str)
|
|
|
|
bind_index = ValidateAttr(field="bind_index", type=BindIndex)
|
|
|
|
standard_score = ValidateAttr(field="standard_score", type=str)
|
|
|
|
score_setting = ValidateAttr(field="score_setting", type=ScoreSetting)
|
|
|
|
|
|
|
|
fields_map = {
|
|
|
|
"name": "指标名称",
|
|
|
|
"bind_index": "构建指标",
|
|
|
|
"standard_score": "标准分",
|
|
|
|
"score_setting": "打分设置"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
name = ValidateAttr(field="name", type=str)
|
|
|
|
secondary_index = ValidateAttr(field="secondary_index", instance_list=SecondaryIndex)
|
|
|
|
|
|
|
|
fields_map = {
|
|
|
|
"name": "指标名称",
|
|
|
|
"secondary_index": "二级指标"
|
|
|
|
}
|
|
|
|
|
|
|
|
name = ValidateAttr(field="name", type=str)
|
|
|
|
first_index = ValidateAttr(field="first_index", instance_list=FirstIndex)
|
|
|
|
|
|
|
|
fields_map = {
|
|
|
|
"name": "维度名称",
|
|
|
|
"first_index": "一级指标"
|
|
|
|
}
|
|
|
|
|
|
|
|
model_id = ValidateAttr(field="model_id", type=str)
|
|
|
|
model_name = ValidateAttr(field="model_name", type=str)
|
|
|
|
level_setting = ValidateAttr(field="level_setting", instance_list=LevelSetting)
|
|
|
|
dimension = ValidateAttr(field="dimension", instance_list=Dimension)
|
|
|
|
author = ValidateAttr(field="author", type=str)
|
|
|
|
edit_date = ValidateAttr(field="edit_date", func=Validate.date_format)
|
|
|
|
tags = ValidateAttr(field="tags", type=list)
|
|
|
|
status = ValidateAttr(field="status", type=str, in_list=['design', 'published'])
|
|
|
|
|
|
|
|
fields_map = {
|
|
|
|
"model_id": "模型ID",
|
|
|
|
"model_name": "模型名称",
|
|
|
|
"level_setting": "级别设置",
|
|
|
|
"dimension": "维度",
|
|
|
|
"author": "作者",
|
|
|
|
"date": "日期",
|
|
|
|
"tags": "标签",
|
|
|
|
"status": "状态"
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-07-05 15:41:42 +08:00
|
|
|
class ScoreResultObj(SpecObject):
|
|
|
|
"""打分结果"""
|
|
|
|
|
|
|
|
class DimensionScore(SpecObject):
|
|
|
|
fields_map = {}
|
|
|
|
name = ValidateAttr(field='name', type=str)
|
|
|
|
dimension_score = ValidateAttr(field='dimension_score', type=DimensionScore)
|
|
|
|
total_socre = ValidateAttr(field='total_socre', type=[int, float])
|
|
|
|
level = ValidateAttr(field='', type=str)
|
|
|
|
|
|
|
|
fields_map = {
|
|
|
|
"name": "企业名称",
|
|
|
|
"dimension_score": "维度得分",
|
|
|
|
"total_socre": "合计得分",
|
|
|
|
"level": "级别"
|
|
|
|
}
|
|
|
|
|
2022-07-05 10:46:00 +08:00
|
|
|
test = {
|
|
|
|
"企业名称": "远东资信评估有限公司",
|
|
|
|
"维度得分": [
|
|
|
|
{
|
|
|
|
"维度名称": "经营环境",
|
|
|
|
"一级指标": [
|
|
|
|
{
|
|
|
|
"指标名称": "区域经济环境",
|
|
|
|
"二级指标": [
|
|
|
|
{
|
|
|
|
"指标名称": "营业利润率",
|
|
|
|
"合计": 3
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"指标名称": "营业利润率",
|
|
|
|
"合计": 3
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"合计": 6
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"指标名称": "区域经济环境",
|
|
|
|
"二级指标": [
|
|
|
|
{
|
|
|
|
"指标名称": "营业利润率",
|
|
|
|
"合计": 3
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"指标名称": "营业利润率",
|
|
|
|
"合计": 3
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"合计": 6
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"合计": 10
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"合计": 100,
|
|
|
|
"级别": "AAA"
|
|
|
|
}
|
2022-07-05 15:41:42 +08:00
|
|
|
|
|
|
|
# if score_setting['pattern'] == '档位打分':
|
|
|
|
# score = gear_score()
|
|
|
|
# elif score_setting['pattern'] == '百分比打分':
|
|
|
|
# score = percentage_score()
|
|
|
|
# else:
|
|
|
|
# score = conditional_score()
|