2021-12-27 17:02:03 +08:00
|
|
|
|
from rating.scripts.common import *
|
2021-12-09 17:11:29 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def risk_data_etl(param1, param2, param3):
|
|
|
|
|
"""
|
|
|
|
|
根据企业名称,查询天眼查数据库
|
2021-12-13 17:00:23 +08:00
|
|
|
|
将数据按规定格式存储到股交企业数据库中(评价-风险数据)
|
2021-12-09 17:11:29 +08:00
|
|
|
|
Parameters:
|
|
|
|
|
param1: 企业名称
|
|
|
|
|
param2: 企业ID
|
|
|
|
|
param3: 评价ID
|
|
|
|
|
Returns:
|
|
|
|
|
res: 保存结果
|
|
|
|
|
"""
|
|
|
|
|
# 合规风险
|
|
|
|
|
compliance_risk = dict()
|
|
|
|
|
compliance_risk['失信人'] = dishonest_person(param1)
|
|
|
|
|
compliance_risk['严重违法'] = serious_illegal(param1)
|
|
|
|
|
compliance_risk['经营异常'] = abnormal_operation(param1)
|
|
|
|
|
compliance_risk['欠税公告'] = owing_taxes(param1)
|
|
|
|
|
compliance_risk['税收违法'] = tax_violation(param1)
|
|
|
|
|
compliance_risk['行政处罚'] = administrative_punish(param1)
|
|
|
|
|
compliance_risk['环保处罚'] = environmental_punish(param1)
|
|
|
|
|
|
|
|
|
|
# 经营风险
|
|
|
|
|
business_risk = dict()
|
2021-12-23 18:16:45 +08:00
|
|
|
|
business_risk['立案信息'] = filing_info(param1)
|
2021-12-09 17:11:29 +08:00
|
|
|
|
business_risk['开庭公告'] = opening_announcement(param1)
|
|
|
|
|
business_risk['被执行人'] = executed_person(param1)
|
|
|
|
|
business_risk['法院公告'] = court_announcement(param1)
|
|
|
|
|
business_risk['诉讼'] = lawsuit(param1)
|
|
|
|
|
business_risk['送达公告'] = service_notice(param1)
|
|
|
|
|
business_risk['股权出质'] = equity_pledge(param1)
|
|
|
|
|
|
|
|
|
|
# 关联风险
|
|
|
|
|
relation_risk = dict()
|
|
|
|
|
relation_risk['周边风险'] = dict()
|
|
|
|
|
relation_risk['周边风险']['高风险'] = periphery_risk(param1, '高风险')
|
|
|
|
|
relation_risk['周边风险']['警示'] = periphery_risk(param1, '警示')
|
|
|
|
|
relation_risk['变更记录'] = dict()
|
|
|
|
|
relation_risk['变更记录']['法人变更'] = change_record(param1, '法人变更')
|
|
|
|
|
relation_risk['变更记录']['主要成员变更'] = change_record(param1, '主要成员变更')
|
|
|
|
|
|
|
|
|
|
# 合并数据
|
|
|
|
|
insert_data = dict()
|
|
|
|
|
insert_data['评价ID'] = param3
|
|
|
|
|
insert_data['企业ID'] = param2
|
|
|
|
|
insert_data['合规风险'] = compliance_risk
|
|
|
|
|
insert_data['经营风险'] = business_risk
|
|
|
|
|
insert_data['关联风险'] = relation_risk
|
|
|
|
|
|
|
|
|
|
info = conserve_data(db='评价', col='风险数据', cid=param2, insert_data=insert_data)
|
|
|
|
|
return info
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def dishonest_person(param):
|
|
|
|
|
"""
|
|
|
|
|
失信人
|
|
|
|
|
根据企业名称,查询天眼查数据库,根据条件筛选数据
|
|
|
|
|
Parameters:
|
|
|
|
|
param: 企业名称
|
|
|
|
|
Returns:
|
|
|
|
|
res: 满足条件总数
|
|
|
|
|
"""
|
|
|
|
|
total = 0
|
|
|
|
|
res = find_tyc_db(db='司法风险', col='失信人', query={'企业名称': param})
|
|
|
|
|
if len(res):
|
|
|
|
|
data = res[0]
|
|
|
|
|
try:
|
|
|
|
|
quantity = len(data['失信人'])
|
|
|
|
|
if quantity:
|
|
|
|
|
for num in range(quantity):
|
|
|
|
|
try:
|
|
|
|
|
date = int(data['失信人'][num]['publishdate'][:4])
|
|
|
|
|
current_year = datetime.date.today().year
|
2021-12-13 17:00:23 +08:00
|
|
|
|
if current_year - date <= 3:
|
2021-12-09 17:11:29 +08:00
|
|
|
|
total += 1
|
|
|
|
|
except Exception:
|
|
|
|
|
total += 1
|
|
|
|
|
return total
|
|
|
|
|
except KeyError:
|
|
|
|
|
return total
|
|
|
|
|
else:
|
|
|
|
|
return total
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def serious_illegal(param):
|
|
|
|
|
"""
|
|
|
|
|
严重违法
|
|
|
|
|
根据企业名称,查询天眼查数据库,根据条件筛选数据
|
|
|
|
|
Parameters:
|
|
|
|
|
param: 企业名称
|
|
|
|
|
Returns:
|
|
|
|
|
res: 满足条件总数
|
|
|
|
|
"""
|
|
|
|
|
total = 0
|
|
|
|
|
res = find_tyc_db(db='经营风险', col='严重违法', query={'企业名称': param})
|
|
|
|
|
if len(res):
|
|
|
|
|
data = res[0]
|
|
|
|
|
try:
|
|
|
|
|
quantity = len(data['严重违法']['result'])
|
|
|
|
|
if quantity:
|
|
|
|
|
for num in range(quantity):
|
|
|
|
|
try:
|
|
|
|
|
timestamp = data['严重违法']['result'][num]['putDate'] / 1000
|
|
|
|
|
put_date = time.localtime(timestamp)
|
|
|
|
|
date = int(time.strftime("%Y", put_date))
|
|
|
|
|
current_year = datetime.date.today().year
|
2021-12-13 17:00:23 +08:00
|
|
|
|
if current_year - date <= 3:
|
2021-12-09 17:11:29 +08:00
|
|
|
|
total += 1
|
|
|
|
|
except Exception:
|
|
|
|
|
total += 1
|
|
|
|
|
return total
|
|
|
|
|
except KeyError:
|
|
|
|
|
return total
|
|
|
|
|
else:
|
|
|
|
|
return total
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def abnormal_operation(param):
|
|
|
|
|
"""
|
|
|
|
|
经营异常
|
|
|
|
|
根据企业名称,查询天眼查数据库,根据条件筛选数据
|
|
|
|
|
Parameters:
|
|
|
|
|
param: 企业名称
|
|
|
|
|
Returns:
|
|
|
|
|
res: 满足条件总数
|
|
|
|
|
"""
|
|
|
|
|
total = 0
|
|
|
|
|
res = find_tyc_db(db='经营风险', col='经营异常', query={'企业名称': param})
|
|
|
|
|
if len(res):
|
|
|
|
|
data = res[0]
|
|
|
|
|
try:
|
|
|
|
|
quantity = len(data['经营异常']['result'])
|
|
|
|
|
if quantity:
|
|
|
|
|
for num in range(quantity):
|
|
|
|
|
try:
|
|
|
|
|
date = int(data['经营异常']['result'][num]['putDate'][:4])
|
|
|
|
|
current_year = datetime.date.today().year
|
|
|
|
|
if current_year - date <= 3:
|
|
|
|
|
total += 1
|
|
|
|
|
except Exception:
|
|
|
|
|
total += 1
|
|
|
|
|
return total
|
|
|
|
|
except KeyError:
|
|
|
|
|
return total
|
|
|
|
|
else:
|
|
|
|
|
return total
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def owing_taxes(param):
|
|
|
|
|
"""
|
|
|
|
|
欠税公告
|
|
|
|
|
根据企业名称,查询天眼查数据库,根据条件筛选数据
|
|
|
|
|
Parameters:
|
|
|
|
|
param: 企业名称
|
|
|
|
|
Returns:
|
|
|
|
|
res: 满足条件总数
|
|
|
|
|
"""
|
|
|
|
|
total = 0
|
|
|
|
|
res = find_tyc_db(db='经营风险', col='欠税公告', query={'企业名称': param})
|
|
|
|
|
if len(res):
|
|
|
|
|
data = res[0]
|
|
|
|
|
try:
|
|
|
|
|
quantity = len(data['欠税公告']['result'])
|
|
|
|
|
if quantity:
|
|
|
|
|
for num in range(quantity):
|
|
|
|
|
try:
|
|
|
|
|
date = int(data['经营异常']['result'][num]['publishDate'][:4])
|
|
|
|
|
current_year = datetime.date.today().year
|
|
|
|
|
if current_year - date <= 3:
|
|
|
|
|
total += 1
|
|
|
|
|
except Exception:
|
|
|
|
|
total += 1
|
|
|
|
|
return total
|
|
|
|
|
except KeyError:
|
|
|
|
|
return total
|
|
|
|
|
else:
|
|
|
|
|
return total
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def tax_violation(param):
|
|
|
|
|
"""
|
|
|
|
|
税收违法
|
|
|
|
|
根据企业名称,查询天眼查数据库,根据条件筛选数据
|
|
|
|
|
Parameters:
|
|
|
|
|
param: 企业名称
|
|
|
|
|
Returns:
|
|
|
|
|
res: 满足条件总数
|
|
|
|
|
"""
|
|
|
|
|
total = 0
|
|
|
|
|
res = find_tyc_db(db='经营风险', col='税收违法', query={'企业名称': param})
|
|
|
|
|
if len(res):
|
|
|
|
|
data = res[0]
|
|
|
|
|
try:
|
|
|
|
|
quantity = len(data['税收违法']['result'])
|
|
|
|
|
if quantity:
|
|
|
|
|
for num in range(quantity):
|
|
|
|
|
try:
|
|
|
|
|
date = int(data['税收违法']['result'][num]['publish_time'][:4])
|
|
|
|
|
current_year = datetime.date.today().year
|
|
|
|
|
if current_year - date <= 3:
|
|
|
|
|
total += 1
|
|
|
|
|
except Exception:
|
|
|
|
|
total += 1
|
|
|
|
|
return total
|
|
|
|
|
except KeyError:
|
|
|
|
|
return total
|
|
|
|
|
else:
|
|
|
|
|
return total
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def filing_info(param):
|
|
|
|
|
"""
|
|
|
|
|
立案信息
|
|
|
|
|
根据企业名称,查询天眼查数据库,根据条件筛选数据
|
|
|
|
|
Parameters:
|
|
|
|
|
param: 企业名称
|
|
|
|
|
Returns:
|
|
|
|
|
res: 满足条件总数
|
|
|
|
|
"""
|
|
|
|
|
total = 0
|
|
|
|
|
res = find_tyc_db(db='司法风险', col='立案信息', query={'企业名称': param})
|
|
|
|
|
if len(res):
|
|
|
|
|
data = res[0]
|
|
|
|
|
try:
|
|
|
|
|
quantity = len(data['立案信息'])
|
|
|
|
|
if quantity:
|
|
|
|
|
for num in range(quantity):
|
|
|
|
|
try:
|
|
|
|
|
date = int(data['立案信息'][num]['filingDate'][:4])
|
|
|
|
|
current_year = datetime.date.today().year
|
|
|
|
|
if current_year - date <= 3:
|
|
|
|
|
total += 1
|
|
|
|
|
except Exception:
|
|
|
|
|
total += 1
|
|
|
|
|
return total
|
|
|
|
|
except KeyError:
|
|
|
|
|
return total
|
|
|
|
|
else:
|
|
|
|
|
return total
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def administrative_punish(param):
|
|
|
|
|
"""
|
|
|
|
|
行政处罚
|
|
|
|
|
根据企业名称,查询天眼查数据库,根据条件筛选数据
|
|
|
|
|
Parameters:
|
|
|
|
|
param: 企业名称
|
|
|
|
|
Returns:
|
|
|
|
|
res: 满足条件总数
|
|
|
|
|
"""
|
|
|
|
|
total = 0
|
|
|
|
|
res = find_tyc_db(db='经营风险', col='行政处罚', query={'企业名称': param})
|
|
|
|
|
if len(res):
|
|
|
|
|
data = res[0]
|
|
|
|
|
try:
|
|
|
|
|
quantity = len(data['行政处罚']['result'])
|
|
|
|
|
if quantity:
|
|
|
|
|
for num in range(quantity):
|
|
|
|
|
try:
|
|
|
|
|
date = int(data['行政处罚']['result'][num]['decisionDate'][:4])
|
|
|
|
|
current_year = datetime.date.today().year
|
|
|
|
|
if current_year - date <= 3:
|
|
|
|
|
total += 1
|
|
|
|
|
except Exception:
|
|
|
|
|
total += 1
|
|
|
|
|
return total
|
|
|
|
|
except KeyError:
|
|
|
|
|
return total
|
|
|
|
|
else:
|
|
|
|
|
return total
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def environmental_punish(param):
|
|
|
|
|
"""
|
|
|
|
|
环保处罚
|
|
|
|
|
根据企业名称,查询天眼查数据库,根据条件筛选数据
|
|
|
|
|
Parameters:
|
|
|
|
|
param: 企业名称
|
|
|
|
|
Returns:
|
|
|
|
|
res: 满足条件总数
|
|
|
|
|
"""
|
|
|
|
|
total = 0
|
|
|
|
|
res = find_tyc_db(db='经营风险', col='环保处罚', query={'企业名称': param})
|
|
|
|
|
if len(res):
|
|
|
|
|
data = res[0]
|
|
|
|
|
try:
|
|
|
|
|
quantity = len(data['环保处罚']['result'])
|
|
|
|
|
if quantity:
|
|
|
|
|
for num in range(quantity):
|
|
|
|
|
try:
|
|
|
|
|
date = int(data['环保处罚']['result'][num]['publish_time'][:4])
|
|
|
|
|
current_year = datetime.date.today().year
|
|
|
|
|
if current_year - date <= 3:
|
|
|
|
|
total += 1
|
|
|
|
|
except Exception:
|
|
|
|
|
total += 1
|
|
|
|
|
return total
|
|
|
|
|
except KeyError:
|
|
|
|
|
return total
|
|
|
|
|
else:
|
|
|
|
|
return total
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def opening_announcement(param):
|
|
|
|
|
"""
|
|
|
|
|
开庭公告
|
|
|
|
|
根据企业名称,查询天眼查数据库,根据条件筛选数据
|
|
|
|
|
Parameters:
|
|
|
|
|
param: 企业名称
|
|
|
|
|
Returns:
|
|
|
|
|
res: 满足条件总数
|
|
|
|
|
"""
|
|
|
|
|
total = 0
|
|
|
|
|
res = find_tyc_db(db='司法风险', col='开庭公告', query={'企业名称': param})
|
|
|
|
|
if len(res):
|
|
|
|
|
data = res[0]
|
|
|
|
|
try:
|
|
|
|
|
quantity = len(data['开庭公告'])
|
|
|
|
|
if quantity:
|
|
|
|
|
for num in range(quantity):
|
|
|
|
|
try:
|
|
|
|
|
date = int(data['开庭公告'][num]['startDate'][:4])
|
|
|
|
|
current_year = datetime.date.today().year
|
|
|
|
|
if current_year - date <= 3:
|
|
|
|
|
defendant = data['开庭公告'][num]['defendant']
|
|
|
|
|
if len(defendant) > 0:
|
|
|
|
|
for item in defendant:
|
|
|
|
|
if param == item['name']:
|
|
|
|
|
total += 1
|
|
|
|
|
except Exception:
|
|
|
|
|
total += 1
|
|
|
|
|
return total
|
|
|
|
|
except KeyError:
|
|
|
|
|
return total
|
|
|
|
|
else:
|
|
|
|
|
return total
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def executed_person(param):
|
|
|
|
|
"""
|
|
|
|
|
被执行人
|
|
|
|
|
根据企业名称,查询天眼查数据库,根据条件筛选数据
|
|
|
|
|
Parameters:
|
|
|
|
|
param: 企业名称
|
|
|
|
|
Returns:
|
|
|
|
|
res: 满足条件总数
|
|
|
|
|
"""
|
|
|
|
|
total = 0
|
|
|
|
|
res = find_tyc_db(db='司法风险', col='被执行人', query={'企业名称': param})
|
|
|
|
|
if len(res):
|
|
|
|
|
data = res[0]
|
|
|
|
|
try:
|
|
|
|
|
quantity = len(data['被执行人'])
|
|
|
|
|
if quantity:
|
|
|
|
|
for num in range(quantity):
|
|
|
|
|
try:
|
|
|
|
|
date = int(data['被执行人'][num]['caseCreateTime'][:4])
|
|
|
|
|
current_year = datetime.date.today().year
|
|
|
|
|
if current_year - date <= 3:
|
|
|
|
|
total += 1
|
|
|
|
|
except Exception:
|
|
|
|
|
total += 1
|
|
|
|
|
return total
|
|
|
|
|
except KeyError:
|
|
|
|
|
return total
|
|
|
|
|
else:
|
|
|
|
|
return total
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def court_announcement(param):
|
|
|
|
|
"""
|
|
|
|
|
法院公告
|
|
|
|
|
根据企业名称,查询天眼查数据库,根据条件筛选数据
|
|
|
|
|
Parameters:
|
|
|
|
|
param: 企业名称
|
|
|
|
|
Returns:
|
|
|
|
|
res: 满足条件总数
|
|
|
|
|
"""
|
|
|
|
|
total = 0
|
|
|
|
|
res = find_tyc_db(db='司法风险', col='法院公告', query={'企业名称': param})
|
|
|
|
|
if len(res):
|
|
|
|
|
data = res[0]
|
|
|
|
|
try:
|
|
|
|
|
quantity = len(data['法院公告'])
|
|
|
|
|
if quantity:
|
|
|
|
|
for num in range(quantity):
|
|
|
|
|
try:
|
|
|
|
|
date = int(data['法院公告'][num]['publishdate'][:4])
|
|
|
|
|
current_year = datetime.date.today().year
|
|
|
|
|
party = data['法院公告'][num]['party2']
|
|
|
|
|
if current_year - date <= 3 and param in party:
|
|
|
|
|
total += 1
|
|
|
|
|
except Exception:
|
|
|
|
|
total += 1
|
|
|
|
|
return total
|
|
|
|
|
except KeyError:
|
|
|
|
|
return total
|
|
|
|
|
else:
|
|
|
|
|
return total
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def lawsuit(param):
|
|
|
|
|
"""
|
|
|
|
|
诉讼
|
|
|
|
|
根据企业名称,查询天眼查数据库,根据条件筛选数据
|
|
|
|
|
Parameters:
|
|
|
|
|
param: 企业名称
|
|
|
|
|
Returns:
|
|
|
|
|
res: 满足条件总数
|
|
|
|
|
"""
|
|
|
|
|
total = 0
|
|
|
|
|
res = find_tyc_db(db='司法风险', col='诉讼', query={'企业名称': param})
|
|
|
|
|
if len(res):
|
|
|
|
|
data = res[0]
|
|
|
|
|
try:
|
|
|
|
|
quantity = len(data['诉讼'])
|
|
|
|
|
if quantity:
|
|
|
|
|
for num in range(quantity):
|
|
|
|
|
try:
|
|
|
|
|
date = int(data['诉讼'][num]['submittime'][:4])
|
|
|
|
|
current_year = datetime.date.today().year
|
|
|
|
|
defendants = data['诉讼'][num]['defendants']
|
|
|
|
|
if current_year - date <= 3 and param in defendants:
|
|
|
|
|
total += 1
|
|
|
|
|
except Exception:
|
|
|
|
|
total += 1
|
|
|
|
|
return total
|
|
|
|
|
except KeyError:
|
|
|
|
|
return total
|
|
|
|
|
else:
|
|
|
|
|
return total
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def service_notice(param):
|
|
|
|
|
"""
|
|
|
|
|
送达公告
|
|
|
|
|
根据企业名称,查询天眼查数据库,根据条件筛选数据
|
|
|
|
|
Parameters:
|
|
|
|
|
param: 企业名称
|
|
|
|
|
Returns:
|
|
|
|
|
res: 满足条件总数
|
|
|
|
|
"""
|
|
|
|
|
total = 0
|
|
|
|
|
res = find_tyc_db(db='司法风险', col='送达公告', query={'企业名称': param})
|
|
|
|
|
if len(res):
|
|
|
|
|
data = res[0]
|
|
|
|
|
try:
|
|
|
|
|
quantity = len(data['送达公告'])
|
|
|
|
|
if quantity:
|
|
|
|
|
for num in range(quantity):
|
|
|
|
|
try:
|
|
|
|
|
date = int(data['送达公告'][num]['startDate'][:4])
|
|
|
|
|
current_year = datetime.date.today().year
|
|
|
|
|
if current_year - date <= 3:
|
|
|
|
|
total += 1
|
|
|
|
|
except Exception:
|
|
|
|
|
total += 1
|
|
|
|
|
return total
|
|
|
|
|
except KeyError:
|
|
|
|
|
return total
|
|
|
|
|
else:
|
|
|
|
|
return total
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def equity_pledge(param):
|
|
|
|
|
"""
|
|
|
|
|
股权出质
|
|
|
|
|
根据企业名称,查询天眼查数据库,根据条件筛选数据
|
|
|
|
|
Parameters:
|
|
|
|
|
param: 企业名称
|
|
|
|
|
Returns:
|
|
|
|
|
res: 满足条件总数
|
|
|
|
|
"""
|
|
|
|
|
total = 0
|
|
|
|
|
res = find_tyc_db(db='经营风险', col='股权出质', query={'企业名称': param})
|
|
|
|
|
if len(res):
|
|
|
|
|
data = res[0]
|
|
|
|
|
try:
|
|
|
|
|
quantity = len(data['股权出质']['result'])
|
|
|
|
|
if quantity:
|
|
|
|
|
for num in range(quantity):
|
|
|
|
|
try:
|
|
|
|
|
timestamp = data['股权出质']['result'][num]['putDate'] / 1000
|
|
|
|
|
put_date = time.localtime(timestamp)
|
|
|
|
|
date = int(time.strftime("%Y", put_date))
|
|
|
|
|
current_year = datetime.date.today().year
|
|
|
|
|
if current_year - date <= 3:
|
|
|
|
|
total += 1
|
|
|
|
|
except Exception:
|
|
|
|
|
total += 1
|
|
|
|
|
return total
|
|
|
|
|
except KeyError:
|
|
|
|
|
return total
|
|
|
|
|
else:
|
|
|
|
|
return total
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def periphery_risk(param1, param2):
|
|
|
|
|
"""
|
|
|
|
|
股权出质
|
|
|
|
|
根据企业名称,查询天眼查数据库,根据条件筛选数据
|
|
|
|
|
Parameters:
|
|
|
|
|
param1: 企业名称
|
|
|
|
|
param2: 风险类型
|
|
|
|
|
Returns:
|
|
|
|
|
res: 满足条件总数
|
|
|
|
|
"""
|
|
|
|
|
total = 0
|
|
|
|
|
res = find_tyc_db(db='天眼风险', col='周边风险', query={'企业名称': param1})
|
|
|
|
|
if len(res):
|
|
|
|
|
data = res[0]
|
|
|
|
|
try:
|
|
|
|
|
quantity = len(data['周边风险']['list'])
|
|
|
|
|
if quantity:
|
|
|
|
|
for num in range(quantity):
|
|
|
|
|
try:
|
|
|
|
|
if data['周边风险']['list'][num]['tag'] == param2:
|
|
|
|
|
total += data['周边风险']['list'][num]['total']
|
|
|
|
|
except Exception:
|
|
|
|
|
total += 0
|
|
|
|
|
return total
|
|
|
|
|
except KeyError:
|
|
|
|
|
return total
|
|
|
|
|
else:
|
|
|
|
|
return total
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def change_record(param1, param2):
|
|
|
|
|
"""
|
|
|
|
|
变更记录
|
|
|
|
|
根据企业名称,查询天眼查数据库,根据条件筛选数据
|
|
|
|
|
Parameters:
|
|
|
|
|
param1: 企业名称
|
|
|
|
|
param2: 变更事项
|
|
|
|
|
Returns:
|
|
|
|
|
res: 满足条件总数
|
|
|
|
|
"""
|
|
|
|
|
total = 0
|
|
|
|
|
res = find_tyc_db(db='公司背景', col='变更记录', query={'企业名称': param1})
|
|
|
|
|
if len(res):
|
|
|
|
|
data = res[0]
|
|
|
|
|
try:
|
|
|
|
|
quantity = len(data['变更记录']['result'])
|
|
|
|
|
if quantity:
|
|
|
|
|
for num in range(quantity):
|
|
|
|
|
try:
|
|
|
|
|
date = int(data['变更记录']['result'][num]['createTime'][:4])
|
|
|
|
|
current_year = datetime.date.today().year
|
|
|
|
|
if current_year - date <= 3:
|
|
|
|
|
if param2 == '法人变更' and '法定代表人' in data['变更记录']['result'][num]['changeItem']:
|
|
|
|
|
total += 1
|
|
|
|
|
elif param2 == '主要成员变更' and '董事(理事)、经理、监事' in data['变更记录']['result'][num]['changeItem']:
|
|
|
|
|
total += 1
|
|
|
|
|
except Exception:
|
|
|
|
|
total += 0
|
|
|
|
|
return total
|
|
|
|
|
except KeyError:
|
|
|
|
|
return total
|
|
|
|
|
else:
|
|
|
|
|
return total
|