提交 369b5d9f 作者: LiuLiYuan

baseCore 02/26

上级 6e37a78a
...@@ -256,10 +256,13 @@ class BaseCore: ...@@ -256,10 +256,13 @@ class BaseCore:
__USER_PHONE_AGENT_LIST = [ __USER_PHONE_AGENT_LIST = [
'Mozilla/5.0 (Linux; Android 7.1.1; OPPO R9sk) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.111 Mobile Safari/537.36'] 'Mozilla/5.0 (Linux; Android 7.1.1; OPPO R9sk) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.111 Mobile Safari/537.36']
def __init__(self): def __init__(self, sqlFlg=True):
# self.__cnx_proxy = pymysql.connect(host='114.115.159.144', user='caiji', password='zzsn9988', db='clb_project', # self.__cnx_proxy = pymysql.connect(host='114.115.159.144', user='caiji', password='zzsn9988', db='clb_project',
# charset='utf8mb4') # charset='utf8mb4')
# self.__cursor_proxy = self.__cnx_proxy.cursor() # self.__cursor_proxy = self.__cnx_proxy.cursor()
# 连接到Redis
self.r = redis.Redis(host="114.115.236.206", port=6379, password='clbzzsn', db=6)
if sqlFlg:
self.cnx = pymysql.connect(host='114.115.159.144', user='caiji', password='zzsn9988', db='caiji', self.cnx = pymysql.connect(host='114.115.159.144', user='caiji', password='zzsn9988', db='caiji',
charset='utf8mb4') charset='utf8mb4')
...@@ -269,9 +272,6 @@ class BaseCore: ...@@ -269,9 +272,6 @@ class BaseCore:
self.cnx_ = pymysql.connect(host='114.116.44.11', user='caiji', password='f7s0&7qqtK', db='clb_project', self.cnx_ = pymysql.connect(host='114.116.44.11', user='caiji', password='f7s0&7qqtK', db='clb_project',
charset='utf8mb4') charset='utf8mb4')
self.cursor_ = self.cnx_.cursor() self.cursor_ = self.cnx_.cursor()
# 连接到Redis
self.r = redis.Redis(host="114.115.236.206", port=6379, password='clbzzsn', db=6)
self.pool_caiji = PooledDB( self.pool_caiji = PooledDB(
creator=pymysql, creator=pymysql,
maxconnections=5, maxconnections=5,
...@@ -300,7 +300,7 @@ class BaseCore: ...@@ -300,7 +300,7 @@ class BaseCore:
charset='utf8mb4' charset='utf8mb4'
) )
def check_mysql_conn(self,conn): def check_mysql_conn(self, conn):
try: try:
conn.ping() conn.ping()
return True return True
...@@ -542,7 +542,6 @@ class BaseCore: ...@@ -542,7 +542,6 @@ class BaseCore:
except: except:
log = self.getLogger() log = self.getLogger()
log.info('=========数据库操作失败========') log.info('=========数据库操作失败========')
return data return data
# 根据企业名称获取企业信息 # 根据企业名称获取企业信息
...@@ -587,6 +586,7 @@ class BaseCore: ...@@ -587,6 +586,7 @@ class BaseCore:
log.info('=========数据库操作失败========') log.info('=========数据库操作失败========')
return data return data
# 更新企业采集次数 # 更新企业采集次数
def updateRun(self, social_code, runType, count): def updateRun(self, social_code, runType, count):
try: try:
...@@ -679,8 +679,8 @@ class BaseCore: ...@@ -679,8 +679,8 @@ class BaseCore:
return 'dan' return 'dan'
return result[0] return result[0]
#创建excel文件 # 创建excel文件
def check_excel_file(self,file_path): def check_excel_file(self, file_path):
if os.path.isfile(file_path): if os.path.isfile(file_path):
self.getLogger().info("Excel文件已存在") self.getLogger().info("Excel文件已存在")
return True return True
...@@ -688,7 +688,6 @@ class BaseCore: ...@@ -688,7 +688,6 @@ class BaseCore:
self.getLogger().info("Excel文件不存在,正在创建...") self.getLogger().info("Excel文件不存在,正在创建...")
return False return False
# 追加接入excel # 追加接入excel
def writerToExcel(self, detailList, filename): def writerToExcel(self, detailList, filename):
# filename='baidu搜索.xlsx' # filename='baidu搜索.xlsx'
...@@ -772,8 +771,7 @@ class BaseCore: ...@@ -772,8 +771,7 @@ class BaseCore:
# #
# return retData # return retData
def deliteATT(self, id):
def deliteATT(self,id):
delitesql = f"delete from clb_sys_attachment where id = '{id}' " delitesql = f"delete from clb_sys_attachment where id = '{id}' "
self.cursor_.execute(delitesql) self.cursor_.execute(delitesql)
self.cnx_.commit() self.cnx_.commit()
...@@ -785,7 +783,7 @@ class BaseCore: ...@@ -785,7 +783,7 @@ class BaseCore:
return selects return selects
# 插入到att表 返回附件id # 插入到att表 返回附件id
def tableUpdate(self, retData, com_name, year, pdf_name, num, pub_time,origin): def tableUpdate(self, retData, com_name, year, pdf_name, num, pub_time, origin):
item_id = retData['item_id'] item_id = retData['item_id']
type_id = retData['type_id'] type_id = retData['type_id']
group_name = retData['group_name'] group_name = retData['group_name']
...@@ -811,7 +809,7 @@ class BaseCore: ...@@ -811,7 +809,7 @@ class BaseCore:
year, pdf_name, type_id, item_id, group_name, path, full_path, category, file_size, order_by, year, pdf_name, type_id, item_id, group_name, path, full_path, category, file_size, order_by,
status, create_by, status, create_by,
create_time, page_size, full_path.split('https://zzsn.obs.cn-north-1.myhuaweicloud.com/')[1], 'zzsn', create_time, page_size, full_path.split('https://zzsn.obs.cn-north-1.myhuaweicloud.com/')[1], 'zzsn',
pub_time,origin) pub_time, origin)
self.cursor_.execute(Upsql, values) # 插入 self.cursor_.execute(Upsql, values) # 插入
self.cnx_.commit() # 提交 self.cnx_.commit() # 提交
...@@ -859,13 +857,13 @@ class BaseCore: ...@@ -859,13 +857,13 @@ class BaseCore:
else: else:
self.getLogger().info(f'=====文件存在obs========{file_path}') self.getLogger().info(f'=====文件存在obs========{file_path}')
#uuid 根据时间戳生成 文件名 上传到obs # uuid 根据时间戳生成 文件名 上传到obs
def getuuid(self): def getuuid(self):
get_timestamp_uuid = uuid.uuid1() # 根据 时间戳生成 uuid , 保证全球唯一 get_timestamp_uuid = uuid.uuid1() # 根据 时间戳生成 uuid , 保证全球唯一
return get_timestamp_uuid return get_timestamp_uuid
def uptoOBS(self, pdf_url, name_pdf, type_id, social_code, pathType, taskType, start_time,create_by): def uptoOBS(self, pdf_url, name_pdf, type_id, social_code, pathType, taskType, start_time, create_by):
headers = {} headers = {}
retData = {'state': False, 'type_id': type_id, 'item_id': social_code, 'group_name': '', 'path': '', retData = {'state': False, 'type_id': type_id, 'item_id': social_code, 'group_name': '', 'path': '',
'full_path': '', 'full_path': '',
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论