提交 c0830237 作者: 薛凌堃

微信公众号

上级 540a101a
...@@ -149,7 +149,7 @@ def beinWork(tyc_code, social_code,start_time): ...@@ -149,7 +149,7 @@ def beinWork(tyc_code, social_code,start_time):
return retData return retData
try: try:
time_struct = time.localtime(int(info_page['rtm'] / 1000)) # 首先把时间戳转换为结构化时间 time_struct = time.localtime(int(info_page['rtm'] / 1000)) # 首先把时间戳转换为结构化时间
time_format = time.strftime("%Y-%m-%d %H-%M-%S", time_struct) # 把结构化时间转换为格式化时间 time_format = time.strftime("%Y-%m-%d %H:%M:%S", time_struct) # 把结构化时间转换为格式化时间
except: except:
time_format = baseCore.getNowTime(1) time_format = baseCore.getNowTime(1)
try: try:
...@@ -270,20 +270,24 @@ def beinWork(tyc_code, social_code,start_time): ...@@ -270,20 +270,24 @@ def beinWork(tyc_code, social_code,start_time):
return retData return retData
# 日志信息保存至现已创建好数据库中,因此并没有再对此前保存日志信息数据库进行保存 # 日志信息保存至现已创建好数据库中,因此并没有再对此前保存日志信息数据库进行保存
def doJob(): def doJob():
while True: while True:
# 根据从Redis中拿到的社会信用代码,在数据库中获取对应基本信息 # 根据从Redis中拿到的社会信用代码,在数据库中获取对应基本信息
social_code = baseCore.redicPullData('NewsEnterprise:gnqy_socialCode') social_code = baseCore.redicPullData('NewsEnterprise:gnqy_socialCode')
# 判断 如果Redis中已经没有数据,则等待 # 判断 如果Redis中已经没有数据,则等待
if social_code == 'None': if social_code == None:
time.sleep(20) time.sleep(20)
continue continue
start = time.time() start = time.time()
try: try:
data = baseCore.getInfomation(social_code) data = baseCore.getInfomation(social_code)
if len(data) != 0:
pass
else:
#数据重新塞入redis
baseCore.rePutIntoR('NewsEnterprise:gnqy_socialCode',social_code)
continue
id = data[0] id = data[0]
xydm = data[2] xydm = data[2]
tycid = data[11] tycid = data[11]
...@@ -299,7 +303,7 @@ def doJob(): ...@@ -299,7 +303,7 @@ def doJob():
state = 0 state = 0
takeTime = baseCore.getTimeCost(start, time.time()) takeTime = baseCore.getTimeCost(start, time.time())
baseCore.recordLog(social_code, taskType, state, takeTime, '', '获取天眼查id失败') baseCore.recordLog(social_code, taskType, state, takeTime, '', '获取天眼查id失败')
baseCore.rePutIntoR(social_code) baseCore.rePutIntoR('NewsEnterprise:gnqy_socialCode',social_code)
continue continue
count = data[17] count = data[17]
log.info(f"{id}---{xydm}----{tycid}----开始处理") log.info(f"{id}---{xydm}----{tycid}----开始处理")
...@@ -321,20 +325,20 @@ def doJob(): ...@@ -321,20 +325,20 @@ def doJob():
up_repetCount = retData['up_repetCount'] up_repetCount = retData['up_repetCount']
log.info( log.info(
f"{id}---{xydm}----{tycid}----结束处理,耗时{baseCore.getTimeCost(start_time, time.time())}---总数:{total}---成功数:{up_okCount}----失败数:{up_errorCount}--重复数:{up_repetCount}") f"{id}---{xydm}----{tycid}----结束处理,耗时{baseCore.getTimeCost(start_time, time.time())}---总数:{total}---成功数:{up_okCount}----失败数:{up_errorCount}--重复数:{up_repetCount}")
except: except Exception as e:
log.info(f'==={social_code}=====获取企业信息失败====') log.info(f'==={social_code}=====获取企业信息失败====')
#重新塞入redis
baseCore.rePutIntoR('NewsEnterprise:gnqy_socialCode',social_code)
state = 0 state = 0
takeTime = baseCore.getTimeCost(start, time.time()) takeTime = baseCore.getTimeCost(start, time.time())
baseCore.recordLog(social_code, taskType, state, takeTime, '', '获取企业信息失败') baseCore.recordLog(social_code, taskType, state, takeTime, '', f'获取企业信息失败--{e}')
time.sleep(5)
cursor.close() cursor.close()
cnx.close() cnx.close()
# 释放资源 # 释放资源
baseCore.close() baseCore.close()
# Press the green button in the gutter to run the script.
if __name__ == '__main__': if __name__ == '__main__':
doJob() doJob()
......
from base import BaseCore
# 根据从Redis中拿到的社会信用代码,在数据库中获取对应基本信息
import time
baseCore = BaseCore.BaseCore()
# log = baseCore.getLogger()
r = baseCore.r
# social_code = baseCore.redicPullData('NewsEnterprise:gwqy_socialCode')
#
# # 判断 如果Redis中已经没有数据,则等待
# if not social_code:
#
# print('1:')
# if social_code == 'None':
#
# print('2')
#
# if social_code == None:
# print('3:')
#9131000010000595XD 91100000100003962T
# item = '91110000101690725E'
item = '91100000100003962T'
list = ['86',
'122',
'142',
'168',
'270',
'282',
'364',
'407',
'416',
'563',
'566',
'588',
'595',
'597',
'737',
'750',
'810',
'838',
'860',
'875',
'885',
'886',
'1003',
'1250',
'1272',
'1362',
'1379',
'1381',
'1382',
'1392',
'1476',
'1583',
'1639',
'1748',
'1764',
'1775',
'1801',
'1839',
'2018',
'2260',
'2356',
'2471',
'2563',
'2703',
'2800',
'2815',
'2934',
'3162',
'3376',
'3474',
'3737',
'3782',
'3939',
'4118',
'4509',
'4675',
'4801',
'4818',
'4943',
'5149',
'5195',
'5429',
'7023',
'7025',
'7026',
'7039',
'7053',
'7058',
'7059',
'7060',
'7062',
'7066',
'7067',
'7069',
'7073',
'7077',
'7083',
'7091',
'7095',
'7103',
'7105',
'7107',
'7109',
'7110',
'7113',
'7131',
'7135',
'7136',
'7138',
'7140',
'7141',
'7142',
'7143',
'7144',
'7145',
'7147',
'7150',
'7151',
'7152',
'7156',
'7157',
'7160',
'7162',
'7165',
'7169',
'7174',
'7180',
'7187',
'7193',
'7197',
'7198',
'7199',
'7201',
'7202',
'7203',
'7204',
'7205',
'7206',
'7208',
'7209',
'7211',
'7212',
'7213',
'7214']
for item in list:
r.rpush('NewsEnterpriseFbs:gnqy_socialCode', item)
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论