Browse Source

推送服务完善

Signed-off-by: Binren Zhnag <zhangbr@elab-plus.com>
Binren Zhnag 5 years ago
parent
commit
9879c9a155
3 changed files with 16 additions and 11 deletions
  1. 3 3
      apscheduler_elab.py
  2. 12 7
      jianye_report.py
  3. 1 1
      sql.py

+ 3 - 3
apscheduler_elab.py

@@ -14,9 +14,9 @@ class Config(object):
         day_work_four: 5
     """
     jianye__house_hour = 6
-    jianye_house_minute = 30
-    jianye_brand_hour = 5
-    jianye_brand_minute = 30
+    jianye_house_minute = 00
+    jianye_brand_hour = 6
+    jianye_brand_minute = 00
 
     JOBS = [
         {

+ 12 - 7
jianye_report.py

@@ -11,8 +11,8 @@ class JianYeReport(object):
     """
         建业报表数据处理
     """
-    # customer_mails = ['liutt@elab-plus.com', 'binrenzhang@qq.com', 'plf@centralchina.com']
-    customer_mails = ['liutt@elab-plus.com', 'binrenzhang@qq.com']
+    customer_mails = ['liutt@elab-plus.com', 'binrenzhang@qq.com', 'plf@centralchina.com']
+    # customer_mails = ['liutt@elab-plus.com', 'binrenzhang@qq.com']
 
     #
     index_type = [
@@ -34,6 +34,7 @@ class JianYeReport(object):
     def __init__(self):
         self.db = MysqlDB('bi_report')
         pass
+
     def get_city_house_id(self):
         return self.db.select(Sql.sql_1)
 
@@ -43,6 +44,7 @@ class JianYeReport(object):
     def get_mail_title(self, type, region_name, name):
         """
             获取邮件名称
+        :param region_name:
         :param type:1:项目,2:集团,3:区域
         :param name: 项目 区域名称
         :return:
@@ -127,10 +129,10 @@ class JianYeReport(object):
                 number_2 = x[1]
         data_2.append(number_2)
         data_3 = []
-
+        sql_data_3 = self.db.select(Sql.sql_10, [time_range[0], time_range[1]])
         for key in self.index_type:
             number = 0
-            for x in self.db.select(Sql.sql_10, [time_range[0], time_range[1]]):
+            for x in sql_data_3:
                 if str(x[0]) == str(key):
                     number = x[1]
             data_3.append(number)
@@ -268,7 +270,9 @@ class JianYeReport(object):
                     if customer_type == 2:
                         # 集团
                         content = self.get_brand_content(content, brand_table_one)
-                        send_data.append([brand_table_two, self.sheet_names_1, title, [self.head_1, self.head_1, self.head_1], file_path, content, name, mail])
+                        send_data.append(
+                            [brand_table_two, self.sheet_names_1, title, [self.head_1, self.head_1, self.head_1],
+                             file_path, content, name, mail])
                         # rfu.create_excel_file(table_2, self.sheet_names_1, title, [self.head_1, self.head_1, self.head_1], file_path)
                     elif customer_type == 1:
                         # 项目
@@ -327,9 +331,10 @@ class JianYeReport(object):
     def get_brand_content(self, content, brand_table_one):
 
         content = content.format(rpfu.get_montho_day(),
-            brand_table_one[0], brand_table_one[1], brand_table_one[2], brand_table_one[3],
+                                 brand_table_one[0], brand_table_one[1], brand_table_one[2], brand_table_one[3],
                                  brand_table_one[4], brand_table_one[5],
-                                 brand_table_one[6], brand_table_one[8], brand_table_one[10], brand_table_one[11], rpfu.get_month(),
+                                 brand_table_one[6], brand_table_one[8], brand_table_one[10], brand_table_one[11],
+                                 rpfu.get_month(),
                                  brand_table_one[12], brand_table_one[13], brand_table_one[14], brand_table_one[15],
                                  brand_table_one[16],
                                  brand_table_one[17],

+ 1 - 1
sql.py

@@ -153,7 +153,7 @@ class Sql:
         SELECT house_id, visit_new_uv_dtd FROM a_brand_customer_share_dtd where brand_id ='13' and report_d >= %s and report_d <= %s  order by report_d
     """
     sql_10 = """
-    select type, COUNT(DISTINCT customer_mobile) from f_dm_jianye_allagent_day where report_d >= %s and report_d <= %s and house_id = '0' group by type
+    select type, COUNT(DISTINCT customer_mobile) from f_dm_jianye_allagent_day where report_d >= %s and report_d <= %s group by type
     """
     sql_11 = """"
     select a.house_or_region, min(b.house_or_brand_id), sum(a.name) from report_push_customer_info a left join report_customer_authority_info b on a.id = b.customer_id group by house_or_region