Browse Source

建业报表服务修改

Signed-off-by: Binren Zhnag <zhangbr@elab-plus.com>
Binren Zhnag 4 years ago
parent
commit
ece51e398d
4 changed files with 70 additions and 40 deletions
  1. 36 17
      apscheduler_elab.py
  2. 27 21
      jianye_report.py
  3. 3 2
      report_public_funs_utils.py
  4. 4 0
      sql.py

+ 36 - 17
apscheduler_elab.py

@@ -13,6 +13,11 @@ class Config(object):
         day_work_three: 4
         day_work_four: 5
     """
+    jianye__house_hour = 6
+    jianye_house_minute = 30
+    jianye_brand_hour = 5
+    jianye_brand_minute = 30
+
     JOBS = [
         {
             'id': 'day_push',
@@ -60,13 +65,13 @@ class Config(object):
             'minute': 30
         },
         {
-            'id': 'day_work_four',
-            'func': 'apscheduler_elab:Funcs.day_work_four',
+            'id': 'day_work_5',
+            'func': 'apscheduler_elab:Funcs.day_work_5',
             'args': '',
             'trigger': 'cron',
             'day_of_week': '*',
-            'hour': 6,
-            'minute': 45
+            'hour': jianye__house_hour,
+            'minute': jianye_house_minute
         },
         {
             'id': 'day_work_6',
@@ -74,8 +79,8 @@ class Config(object):
             'args': '',
             'trigger': 'cron',
             'day_of_week': '*',
-            'hour': 6,
-            'minute': 45
+            'hour': jianye__house_hour,
+            'minute': jianye_house_minute
         },
         {
             'id': 'day_work_7',
@@ -83,8 +88,8 @@ class Config(object):
             'args': '',
             'trigger': 'cron',
             'day_of_week': '*',
-            'hour': 6,
-            'minute': 45
+            'hour': jianye__house_hour,
+            'minute': jianye_house_minute
         },
         {
             'id': 'day_work_8',
@@ -92,8 +97,8 @@ class Config(object):
             'args': '',
             'trigger': 'cron',
             'day_of_week': '*',
-            'hour': 6,
-            'minute': 45
+            'hour': jianye__house_hour,
+            'minute': jianye_house_minute
         },
         {
             'id': 'day_work_9',
@@ -101,8 +106,8 @@ class Config(object):
             'args': '',
             'trigger': 'cron',
             'day_of_week': '*',
-            'hour': 6,
-            'minute': 45
+            'hour': jianye__house_hour,
+            'minute': jianye_house_minute
         },
         {
             'id': 'day_work_10',
@@ -110,8 +115,8 @@ class Config(object):
             'args': '',
             'trigger': 'cron',
             'day_of_week': '*',
-            'hour': 6,
-            'minute': 45
+            'hour': jianye__house_hour,
+            'minute': jianye_house_minute
         },
         {
             'id': 'day_work_11',
@@ -119,8 +124,17 @@ class Config(object):
             'args': '',
             'trigger': 'cron',
             'day_of_week': '*',
-            'hour': 6,
-            'minute': 45
+            'hour': jianye__house_hour,
+            'minute': jianye_house_minute
+        },
+        {
+            'id': 'day_work_12',
+            'func': 'apscheduler_elab:Funcs.day_work_12',
+            'args': '',
+            'trigger': 'cron',
+            'day_of_week': '*',
+            'hour': jianye_brand_hour,
+            'minute': jianye_brand_minute
         }
     ]
 
@@ -167,7 +181,7 @@ class Funcs(object):
         rp.report_push_test(4)
 
     @staticmethod
-    def day_work_four():
+    def day_work_5():
         jianye = JianYeReport()
         jianye.send_mail_to_customer(5)
 
@@ -201,6 +215,11 @@ class Funcs(object):
         jianye = JianYeReport()
         jianye.send_mail_to_customer(11)
 
+    @staticmethod
+    def day_work_12():
+        jianye = JianYeReport()
+        jianye.send_mail_to_customer(12)
+
     @staticmethod
     def minute_push_elab():
         # pdu = PandaUtil('linshi')

+ 27 - 21
jianye_report.py

@@ -233,11 +233,28 @@ class JianYeReport(object):
         customers = self.get_report_customers(task_key)
         message[0] = '客户信息获取成功'
         send_mail_log = []
+        brand_table_one = None
+        brand_table_two = None
         try:
             save_path = FileUtil().save_path_create()
             send_data = []
-            error_customer = []
             # 查询数据
+            if task_key == 12:
+                # 集团信息计算一次发送给多个人
+                brand_table_one = self.brand_data()
+                house_ids = self.get_house_id_by_brand_id('13')
+                brand_table_two = self.house_data(house_ids)
+                # 总浏览量:xx ,总浏览人数:xx
+                #
+                # 新增获客: xx, 新增获电:xx
+                #
+                # 推荐用户数:xx,分享获电:xx,裂变获电:xx
+                #
+                # 全民经纪人注册数:xx
+                #
+                # 报备成功数:xx,报备到访数:xx
+
+                pass
             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]
@@ -249,30 +266,19 @@ class JianYeReport(object):
                 content = self.get_mail_content(customer_type)
                 file_path = save_path + '/' + title + '.xls'
                 try:
-
                     if customer_type == 2:
                         # 集团
-                        table_1 = self.brand_data()
-                        house_ids = self.get_house_id_by_brand_id(ids)
-                        table_2 = self.house_data(house_ids)
-                        # 总浏览量:xx ,总浏览人数:xx
-                        #
-                        # 新增获客: xx, 新增获电:xx
-                        #
-                        # 推荐用户数:xx,分享获电:xx,裂变获电:xx
-                        #
-                        # 全民经纪人注册数:xx
-                        #
-                        # 报备成功数:xx,报备到访数:xx
-                        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[8], table_1[10], table_1[11],
-                                                 table_1[12], table_1[13], table_1[14], table_1[15], table_1[16], table_1[17],
-                                                 table_1[18], table_1[20], table_1[22], table_1[23],
-                                                 table_1[24], table_1[25], table_1[26], table_1[27], table_1[28], table_1[29],
-                                                 table_1[30], table_1[32], table_1[34], table_1[35]
+                        content = content.format(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],
+                                                 brand_table_one[12], brand_table_one[13], brand_table_one[14], brand_table_one[15], brand_table_one[16],
+                                                 brand_table_one[17],
+                                                 brand_table_one[18], brand_table_one[20], brand_table_one[22], brand_table_one[23],
+                                                 brand_table_one[24], brand_table_one[25], brand_table_one[26], brand_table_one[27], brand_table_one[28],
+                                                 brand_table_one[29],
+                                                 brand_table_one[30], brand_table_one[32], brand_table_one[34], brand_table_one[35]
                                                  )
                         send_data.append(
-                            [table_2, self.sheet_names_1, title, [self.head_1, self.head_1, self.head_1], file_path,
+                            [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:

+ 3 - 2
report_public_funs_utils.py

@@ -12,7 +12,8 @@ class ReportPublicFunsUtils:
         now_time = datetime.datetime.now()
         year = now_time.year
         month = now_time.month
-        first_day_of_month = str(year) + '-' + str(month)
+        month = str(month) if month > 9 else '0' + str(month)
+        first_day_of_month = str(year) + '-' + month
         if type:
             return [first_day_of_month + '-01 00:00:00', now_time.strftime('%Y-%m-%d %M:%I:%S')]
         else:
@@ -62,4 +63,4 @@ class ReportPublicFunsUtils:
 
 
 if __name__ == '__main__':
-    print(ReportPublicFunsUtils.get_montho_day())
+    print(ReportPublicFunsUtils.get_prd_day())

+ 4 - 0
sql.py

@@ -163,3 +163,7 @@ class Sql:
         insert into report_push_log(name, mail, report_name, push_time, send_status, status, error_message) values(%s, %s, %s, now(), %s, 1, %s)
     """
     pass
+
+
+if __name__ == '__main__':
+    print(len('222'))