|
@@ -233,6 +233,7 @@ class JianYeReport(object):
|
|
|
customers = self.get_report_customers(task_key)
|
|
|
message[0] = '客户信息获取成功'
|
|
|
try:
|
|
|
+ save_path = FileUtil().save_path_create()
|
|
|
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]
|
|
@@ -242,18 +243,12 @@ class JianYeReport(object):
|
|
|
region_name = customer[4]
|
|
|
title = self.get_mail_title(customer_type, region_name, name)
|
|
|
content = self.get_mail_content(customer_type)
|
|
|
- save_path = FileUtil().save_path_create()
|
|
|
file_path = save_path + '/' + title
|
|
|
- message[11] = '邮件信息生成成功'
|
|
|
if customer_type == 2:
|
|
|
# 集团
|
|
|
- message['99'] = '集团'
|
|
|
table_1 = self.brand_data()
|
|
|
- message[33] = 'brand_data'
|
|
|
house_ids = self.get_house_id_by_brand_id(ids)
|
|
|
- message[55] = 'get_house_id_by_brand_id'
|
|
|
table_2 = self.house_data(house_ids)
|
|
|
- message[66] = 'house_data'
|
|
|
# data, sheet_names, title, headers, save_path
|
|
|
content = content.format(table_1[0], table_1[1], table_1[2], table_1[3], table_1[4], table_1[5],
|
|
|
table_1[6], table_1[7], table_1[8], table_1[9], table_1[10], table_1[11], table_1[12],table_1[13], table_1[14],
|
|
@@ -266,24 +261,17 @@ class JianYeReport(object):
|
|
|
rfu.create_excel_file(table_2, self.sheet_names_1, title, [self.head_1, self.head_1, self.head_1], save_path)
|
|
|
elif customer_type == 1:
|
|
|
# 项目
|
|
|
- message[111] = '项目'
|
|
|
table_2 = self.house_data(self.get_house_ids(ids))
|
|
|
- message[222] = 'house_data'
|
|
|
- message[99999] = table_2
|
|
|
rfu.create_excel_file(table_2, self.sheet_names_1, title, [self.head_1, self.head_1, self.head_1], save_path)
|
|
|
elif customer_type == 3:
|
|
|
# 区域
|
|
|
- message[333] = '区域'
|
|
|
table_2 = self.house_data(self.get_house_ids(ids))
|
|
|
- message[444] = 'self.house_data'
|
|
|
rfu.create_excel_file(table_2, self.sheet_names_1, title, [self.head_1, self.head_1, self.head_1], save_path)
|
|
|
else:
|
|
|
pass
|
|
|
send_mail_info.append([title, content, mail, file_path, title + '.xlsx', name])
|
|
|
- message[1] = '数据查询和excel生成完毕'
|
|
|
# 发送邮件
|
|
|
send_mail_log = []
|
|
|
- message[0000] = '客户数据数量;{}'.format(len(send_mail_info))
|
|
|
for mail in send_mail_info:
|
|
|
try:
|
|
|
for m in self.customer_mails:
|
|
@@ -297,7 +285,6 @@ class JianYeReport(object):
|
|
|
print(str(e))
|
|
|
send_mail_log.append([mail[5], mail[2], mail[3], -1, str(e)])
|
|
|
self.db.add_some(send_mail_log, Sql.sql_12)
|
|
|
- message[2] = '遇见发送完毕, 共:{}份邮件'.format(len(send_mail_info))
|
|
|
except Exception as e:
|
|
|
message['error'] = str(e)
|
|
|
finally:
|