Forráskód Böngészése

jinaye_report: 建业报表逻辑修改

Signed-off-by: binren <zhangbr@elab-plus.com>
binren 5 éve
szülő
commit
ddbd8faf47
3 módosított fájl, 27 hozzáadás és 26 törlés
  1. 11 11
      jianye_report.py
  2. 13 12
      report_file_utils.py
  3. 3 3
      sql.py

+ 11 - 11
jianye_report.py

@@ -487,17 +487,17 @@ class JianYeReport(object):
 
     def send_mail(self, mail, send_mail_log):
         result = None
-        for m in self.customer_mails:
-            if len(mail) == 6:
-                result = self.mail_util.send_mail_by_admin(mail[0], mail[1], m, mail[3], mail[4])
-            elif len(mail) == 8:
-                result = self.mail_util.send_mail_by_admin(mail[0], mail[1], m, mail[3], mail[4], mail[6],
-                                                      mail[7])
-            if result:
-                # name, mail, report_name, push_time, send_status, status, error_message
-                send_mail_log.append([mail[5], mail[2], mail[3], 1, 'success'])
-            else:
-                send_mail_log.append([mail[5], mail[2], mail[3], -1, '调用邮件接口失败:{}'.format(str(result))])
+        # for m in self.customer_mails:
+        if len(mail) == 6:
+            result = self.mail_util.send_mail_by_admin(mail[0], mail[1], mail[2], mail[3], mail[4])
+        elif len(mail) == 8:
+            result = self.mail_util.send_mail_by_admin(mail[0], mail[1], mail[2], mail[3], mail[4], mail[6],
+                                                  mail[7])
+        if result:
+            # name, mail, report_name, push_time, send_status, status, error_message
+            send_mail_log.append([mail[5], mail[2], mail[3], 1, 'success'])
+        else:
+            send_mail_log.append([mail[5], mail[2], mail[3], -1, '调用邮件接口失败:{}'.format(str(result))])
         return send_mail_log
 
     def get_house_ids(self, ids_str):

+ 13 - 12
report_file_utils.py

@@ -90,18 +90,19 @@ class ReportFileUtils:
                 format_str=''))  # 合并单元格
 
     def insert_cells(self, ws, data, start_row, start_col, end_col):
-        for index, v in enumerate(data):
-            y = 0
-            for col in range(start_col, end_col):
-                value = v[y]
-                if value is None:
-                    value = 0
-                ws.col(col).width = 150 * 30  # 定义列宽
-                style = self.simple_style if y >= 2 else self.default_style
-                ws.write(start_row, col, value,
-                         style=style)
-                y += 1
-            start_row += 1
+        if len(data) > 0:
+            for index, v in enumerate(data):
+                y = 0
+                for col in range(start_col, end_col):
+                    value = v[y]
+                    if value is None:
+                        value = 0
+                    ws.col(col).width = 150 * 30  # 定义列宽
+                    style = self.simple_style if y >= 3 else self.default_style
+                    ws.write(start_row, col, value,
+                             style=style)
+                    y += 1
+                start_row += 1
 
     def horizontal_space_cells(self, ws, start_row, end_row, start_col, end_col):
         """

+ 3 - 3
sql.py

@@ -268,13 +268,13 @@ class Sql:
     """
 
     sql_16 = """
-          SELECT b.region, b.city, a.house_name, a.advi_name, a.mobile, IFNULL(a.fx_mobile,0), IFNULL(a.zc_mobile, 0), IFNULL(a.bb_mobile, 0) FROM f_dm_jianye_agent_house_day a left join d_jianye_house_city_region_rlat b on a.house_id = b.house_id  where a.report_d = %s and a.house_id in %s
+          SELECT b.region, b.city, a.house_name, a.advi_name, a.mobile, IFNULL(a.fx_mobile,0), IFNULL(a.zc_mobile, 0), IFNULL(a.bb_mobile, 0) FROM f_dm_jianye_agent_house_day a left join d_jianye_house_city_region_rlat b on a.house_id = b.house_id  where a.report_d = %s and a.house_id in %s order by a.fx_mobile desc
     """
     sql_17 = """
-          SELECT b.region, b.city, a.house_name, a.advi_name, a.mobile, IFNULL(a.fx_mobile,0), IFNULL(a.zc_mobile, 0), IFNULL(a.bb_mobile, 0) FROM f_dm_jianye_agent_house_month a left join d_jianye_house_city_region_rlat b on a.house_id = b.house_id  where a.report_d = %s and a.house_id in %s
+          SELECT b.region, b.city, a.house_name, a.advi_name, a.mobile, IFNULL(a.fx_mobile,0), IFNULL(a.zc_mobile, 0), IFNULL(a.bb_mobile, 0) FROM f_dm_jianye_agent_house_month a left join d_jianye_house_city_region_rlat b on a.house_id = b.house_id  where a.report_d = %s and a.house_id in %s order by a.fx_mobile desc
     """
     sql_18 = """
-          SELECT b.region, b.city, a.house_name, a.advi_name, a.mobile, IFNULL(a.fx_mobile,0), IFNULL(a.zc_mobile, 0), IFNULL(a.bb_mobile, 0) FROM f_dm_jianye_agent_house_all a left join d_jianye_house_city_region_rlat b on a.house_id = b.house_id where a.report_d = %s and a.house_id in %s
+          SELECT b.region, b.city, a.house_name, a.advi_name, a.mobile, IFNULL(a.fx_mobile,0), IFNULL(a.zc_mobile, 0), IFNULL(a.bb_mobile, 0) FROM f_dm_jianye_agent_house_all a left join d_jianye_house_city_region_rlat b on a.house_id = b.house_id where a.report_d = %s and a.house_id in %s order by a.fx_mobile desc
     """