From 3f757a28a9177a54c93b3ab927f64586ab71aa84 Mon Sep 17 00:00:00 2001 From: liuyebo <1515783401@qq.com> Date: Tue, 4 Mar 2025 16:53:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=87=AA=E5=8A=A8=E8=AF=86?= =?UTF-8?q?=E5=88=AB=E8=84=9A=E6=9C=AC=E7=9B=91=E6=8E=A7=EF=BC=8C=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E8=87=AA=E5=8A=A8=E8=AF=86=E5=88=AB=E8=84=9A=E6=9C=AC?= =?UTF-8?q?=E5=8D=A1=E4=BD=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-compose.yml | 2 +- fcbsync_dbphoto_mysql.py | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index cba284b..a202d74 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,6 @@ services: fcb_ai_db_sync: - image: fcb_ai_db_sync:1.1.1 + image: fcb_ai_db_sync:1.1.2 restart: always build: context: . diff --git a/fcbsync_dbphoto_mysql.py b/fcbsync_dbphoto_mysql.py index 68bd457..74f855b 100644 --- a/fcbsync_dbphoto_mysql.py +++ b/fcbsync_dbphoto_mysql.py @@ -34,6 +34,8 @@ from email.mime.text import MIMEText # 构建邮件正文,可以是text,也 from email.mime.application import MIMEApplication # 构建邮件附件,理论上,只要是文件即可,一般是图片,Excel表格,word文件等 from email.header import Header # 专门构建邮件标题的,这样做,可以支持标题中文 +from auto_email.error_email import send_error_email + #import pysnooper #import base64 @@ -83,7 +85,7 @@ def send_data(html_msg, v_head, i): # 邮件发送和接收人yuhong@fucb.cn sender = username - receiver = ["jsxuzl@qq.com","1515783401@qq.com"] + receiver = ["jsxuzl@qq.com", "1515783401@qq.com"] # receiver = ["xuzhengliang@fucb.cn","jsxuzl@qq.com","1804996986@qq.com"] # receiver = ['jsxuzl@qq.com'] @@ -117,8 +119,8 @@ def sync_dbtarget(source_cursor,source_conn,target_cursor,target_db,i_sync_fiel if i_query_sql.count('%s'): source_cursor.execute(i_query_sql,(i_sync_begindate)) else: - source_cursor.execute(i_query_sql) - + source_cursor.execute(i_query_sql) + from_data=source_cursor.fetchall() v_fiels_count=i_sync_fields.count(',')+1 v_fiels_list=i_sync_fields.replace('\n','').replace(' ','').split(',') @@ -160,6 +162,14 @@ def sync_dbtarget(source_cursor,source_conn,target_cursor,target_db,i_sync_fiel if divmod(j, 1000)[1] == 0: logging.info("已经插入"+i_imp_table_name+":" +str(j) + "条") logging.info("插入"+i_imp_table_name+":" + str(j - 1) + "条") + + # 如果工作时间段中识别案子为0,邮件警告 + if i_imp_table_name == "imp_ie_settlement" and j - 1 == 0: + now = datetime.now() + hour = now.hour + if 9 <= hour < 17: + send_error_email('AI赋能数据库同步脚本', '无自动识别结果', '请检查自动识别脚本是否正常运行') + if v_pk_phhd[1:] != '': v_sql =''; v_mess='';