Commit c6e7d735 by 黄静

hj

parent 8397642f
# coding:utf-8
#计算风控结果
import re
class IndexComputer:
funs=[]#公式集合
......@@ -15,9 +14,10 @@ class IndexComputer:
Y = []
V = {}
S = []
# 1.给indexItem.FactorsValue赋测试值
for factorkey in indexItem.FactorsValue:
tempval = indexItem.FactorsValue[factorkey]
tempval = str(tempval)
tempval=str(tempval)
if indexItem.FactorsValue[factorkey] is None:
print("is None")
return {"status_key":0,"status_value":"normal"}
......@@ -32,16 +32,17 @@ class IndexComputer:
i = i + 1
S = sorted(S, key=lambda i: len(i), reverse=True)
j = 0
gongshi_list = []
for fun in indexItem.Funs:
print(indexItem.id,"===============gsid")
print(indexItem.id, "===============gsid")
funstr = fun
for s in S:
funstr = funstr.replace(s, str(V[s]))
strinfo = re.compile(r'X\[\d*\]=')
funstr = strinfo.sub("", funstr)
gongshi_list.append(funstr)
try:
funstr = funstr.replace("[(", "((").replace(")]", "))")
print(funstr,"======funstr")
funstr=funstr.replace("[(","((").replace(")]","))")
val = eval(funstr)
X.append(val)
j = j + 1
......@@ -51,24 +52,26 @@ class IndexComputer:
except(ValueError):
print('other:', ValueError)
return {"status_key":0,"status_value":"normal"}
except:
return {"status_key": 0, "status_value": "normal"}
print(j - 1,"=====j - 1")
if X[j - 1] == False:
if indexItem.Name in ["销售额变动率", "销售毛利(益)率", "税收负担率", "税收负担变动率"]:
if indexItem.Name in ["销售额变动率","销售毛利(益)率","税收负担率","税收负担变动率"]:
last_gongshi = gongshi_list[-1]
print(last_gongshi, "=========last_gongshi")
# 2.以and进行分割
last_gongshi = last_gongshi.split("and")
print(last_gongshi[0], last_gongshi[1], "=====aaa")
print(eval(last_gongshi[0]), "=====eval1")
last_gongshi=last_gongshi.split("and")
print(last_gongshi[0],last_gongshi[1],"=====aaa")
print(eval(last_gongshi[0]),"=====eval1")
print(eval(last_gongshi[1]), "=====eval2")
if eval(last_gongshi[0]) == True and eval(last_gongshi[1]) == False:
if eval(last_gongshi[0])==True and eval(last_gongshi[1])==False:
return {"status_key": 2, "status_value": "big"}
else:
return {"status_key": 2, "status_value": "small"}
else:
return {"status_key": 2, "status_value": "normal"}
return {"status_key":2,"status_value":"normal"}
else:
return {"status_key": 1, "status_value": "normal"}
return {"status_key":1,"status_value":"normal"}
def finance_Compute(self, indexItem):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment