|
@@ -234,22 +234,24 @@ class JianYeReport(object):
|
|
|
rfu = ReportFileUtils()
|
|
|
customers = self.get_report_customers(task_key)
|
|
|
message[0] = '客户信息获取成功'
|
|
|
+ send_mail_log = []
|
|
|
try:
|
|
|
save_path = FileUtil().save_path_create()
|
|
|
send_data = []
|
|
|
error_customer = []
|
|
|
# 查询数据
|
|
|
for customer in customers:
|
|
|
+ # a.task_key, b.customer_type, b.name, b.mail, b.house_or_region, a.customer_id, GROUP_CONCAT(c.house_or_brand_id) as ids
|
|
|
+ name = customer[2]
|
|
|
+ customer_type = customer[1]
|
|
|
+ mail = customer[3]
|
|
|
+ ids = customer[6]
|
|
|
+ region_name = customer[4]
|
|
|
+ title = self.get_mail_title(customer_type, region_name, name)
|
|
|
+ content = self.get_mail_content(customer_type)
|
|
|
+ file_path = save_path + '/' + title + '.xlsx'
|
|
|
try:
|
|
|
- # a.task_key, b.customer_type, b.name, b.mail, b.house_or_region, a.customer_id, GROUP_CONCAT(c.house_or_brand_id) as ids
|
|
|
- name = customer[2]
|
|
|
- customer_type = customer[1]
|
|
|
- mail = customer[3]
|
|
|
- ids = customer[6]
|
|
|
- region_name = customer[4]
|
|
|
- title = self.get_mail_title(customer_type, region_name, name)
|
|
|
- content = self.get_mail_content(customer_type)
|
|
|
- file_path = save_path + '/' + title + '.xlsx'
|
|
|
+
|
|
|
if customer_type == 2:
|
|
|
# 集团
|
|
|
table_1 = self.brand_data()
|
|
@@ -293,8 +295,8 @@ class JianYeReport(object):
|
|
|
pass
|
|
|
except Exception as e:
|
|
|
print(str(e))
|
|
|
- error_customer.append(str(e))
|
|
|
- message['errors'] = e
|
|
|
+ # # name, mail, report_name, push_time, send_status, status, error_message
|
|
|
+ send_mail_log.append([name, mail, title, -1, '数据查询失败'])
|
|
|
message['query_data'] = 'success'
|
|
|
# 生成文件
|
|
|
for data in send_data:
|
|
@@ -304,9 +306,9 @@ class JianYeReport(object):
|
|
|
send_mail_info.append([data[2], data[5], data[7], data[4], data[2] + '.xlsx', data[6]])
|
|
|
except Exception as e:
|
|
|
print(e)
|
|
|
+ send_mail_log.append([data[6], data[7], data[2], -1, '文件创建失败'])
|
|
|
message['file'] = 'success'
|
|
|
# 发送邮件
|
|
|
- send_mail_log = []
|
|
|
for mail in send_mail_info:
|
|
|
try:
|
|
|
for m in self.customer_mails:
|
|
@@ -322,7 +324,7 @@ class JianYeReport(object):
|
|
|
send_mail_log.append([mail[5], mail[2], mail[3], -1, str(e)])
|
|
|
message['mail'] = 'success'
|
|
|
# 写入日志
|
|
|
- self.db.add_some(send_mail_log, Sql.sql_12)
|
|
|
+ self.db.add_some(Sql.sql_12, send_mail_log)
|
|
|
message['log'] = 'success'
|
|
|
except Exception as e:
|
|
|
message['error'] = str(e)
|