Commit c6e7d735 by 黄静

hj

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