Mike 4 lat temu
rodzic
commit
11af3a7625
2 zmienionych plików z 47 dodań i 12 usunięć
  1. 9 9
      execute_detail_notice.py
  2. 38 3
      is_close_changed_notice.py

+ 9 - 9
execute_detail_notice.py

@@ -53,10 +53,10 @@ def hhh_send_mail(email, html):
 # db = dataset.connect("mysql://choozmo:pAssw0rd@db.ptt.cx:3306/hhh?charset=utf8mb4")
 
 # 測試機 DB
-# db = dataset.connect('mysql://hhh7796hhh:lYmWsu^ujcA1@hhh-v57-cluster.cluster-cmab1ctkglka.ap-northeast-2.rds.amazonaws.com:3306/stage?charset=utf8mb4')
+db = dataset.connect('mysql://hhh7796hhh:lYmWsu^ujcA1@hhh-v57-cluster.cluster-cmab1ctkglka.ap-northeast-2.rds.amazonaws.com:3306/stage?charset=utf8mb4')
 
 # 正式機 DB
-db = dataset.connect('mysql://hhh7796hhh:lYmWsu^ujcA1@hhh-v57-cluster.cluster-cmab1ctkglka.ap-northeast-2.rds.amazonaws.com:3306/xoops?charset=utf8mb4')
+# db = dataset.connect('mysql://hhh7796hhh:lYmWsu^ujcA1@hhh-v57-cluster.cluster-cmab1ctkglka.ap-northeast-2.rds.amazonaws.com:3306/xoops?charset=utf8mb4')
 
 # 逾期日期起算日
 overdue_date = '2021-07-12'
@@ -130,7 +130,7 @@ if q2_result_count > 0: # 有逾期執行項目
         idx = 0
 
         for r3 in db.query(q3):
-            url = 'https://backstage.hhh.com.tw/admin/home/execute?exf_id=' + str(r3['exf_id'])
+            url = 'https://stage-backstage.hhh.com.tw/admin/home/execute?exf_id=' + str(r3['exf_id'])
 
             if r3['set_date'] is None:
                 r3['set_date'] = '無'
@@ -145,9 +145,9 @@ if q2_result_count > 0: # 有逾期執行項目
         count += 1
 
     html += "</table>";
-else: # 無逾期執行表單資料
-    print ("無逾期執行項目記錄,不須處理 (由" + overdue_date + "起算)")
-    html += "<div>無逾期執行項目記錄,不須處理 (由" + overdue_date + "起算)</div>"    
+# else: # 無逾期執行表單資料
+#     print ("無逾期執行項目記錄,不須處理 (由" + overdue_date + "起算)")
+#     html += "<div>無逾期執行項目記錄,不須處理 (由" + overdue_date + "起算)</div>"    
 
 html += """
 </body>
@@ -265,9 +265,9 @@ for execute_man in execute_man_list:
             count += 1
 
         html += "</table>";
-    else: # 無逾期執行表單資料
-        print (execute_man + " 無逾期執行項目記錄,不須處理 (由" + overdue_date + "起算)")
-        html += "<div>" + execute_man + " 無逾期執行項目記錄,不須處理 (由" + overdue_date + "起算)</div>"
+    # else: # 無逾期執行表單資料
+    #     print (execute_man + " 無逾期執行項目記錄,不須處理 (由" + overdue_date + "起算)")
+    #     html += "<div>" + execute_man + " 無逾期執行項目記錄,不須處理 (由" + overdue_date + "起算)</div>"
 
     html += """
     </body>

+ 38 - 3
is_close_changed_notice.py

@@ -134,6 +134,7 @@ async def is_close_changed_notice(exf_id: str = '', is_close: str = ''):
             print('修改後狀態: 續約(D)')
             html += '<div>本合約狀態已修改為 <span style="color:red;">續約</span></div>'
             
+            '''
             # 發送通知給負責業務、CRM、Kevin、Sam
             email_list = ['sam@hhh.com.tw','kevin.h@hhh.com.tw', 'miko@hhh.com.tw', 'mollie@hhh.com.tw', 'lynn@hhh.com.tw', 'zoe_lo@hhh.com.tw']
 
@@ -153,10 +154,12 @@ async def is_close_changed_notice(exf_id: str = '', is_close: str = ''):
                     if r1['execute_man']:
                         print('執行單位: ' + r1['execute_man'])
                         email_list.append(r1['execute_man'])
+            '''
         elif is_close == 'E':
             print('修改後狀態: 不續約延期(E)')
             html += '<div>本合約狀態已修改為 <span style="color:red;">不續約延期</span></div>'
             
+            '''
             # 發送通知給負責業務、CRM、Kevin、Sam
             # 以變更後的合約日期來發送通知信
             email_list = ['sam@hhh.com.tw','kevin.h@hhh.com.tw', 'miko@hhh.com.tw', 'mollie@hhh.com.tw', 'lynn@hhh.com.tw', 'zoe_lo@hhh.com.tw']
@@ -177,10 +180,12 @@ async def is_close_changed_notice(exf_id: str = '', is_close: str = ''):
                     if r1['execute_man']:
                         print('執行單位: ' + r1['execute_man'])
                         email_list.append(r1['execute_man'])
+            '''
         elif is_close == 'F':
             print('修改後狀態: 不續約需下線(F)')
             html += '<div>本合約狀態已修改為 <span style="color:red;">不續約需下線</span></div>'
             
+            '''
             # 發送通知通知給負責業務、CRM、財務部、Kevin、Sam
             email_list = ['sam@hhh.com.tw','kevin.h@hhh.com.tw', 'miko@hhh.com.tw', 'mollie@hhh.com.tw', 'lynn@hhh.com.tw', 'zoe_lo@hhh.com.tw', 'ariel@hhh.com.tw']
 
@@ -200,6 +205,7 @@ async def is_close_changed_notice(exf_id: str = '', is_close: str = ''):
                     if r1['execute_man']:
                         print('執行單位: ' + r1['execute_man'])
                         email_list.append(r1['execute_man'])
+            '''
         elif is_close == 'G':
             print('修改後狀態: 已到期未續約(G)')
             html += '<div>本合約狀態已修改為 <span style="color:red;">已到期未續約</span></div>'
@@ -210,6 +216,36 @@ async def is_close_changed_notice(exf_id: str = '', is_close: str = ''):
             # 負責業務
             print('負責業務: ' + r['sales_man'])
             email_list.append(r['sales_man'])
+
+            # 列出該合約底下所有執行項目(含已完成、未完成)
+            q1 = "SELECT * \
+                FROM execute_detail \
+                WHERE exf_id=" + exf_id
+            
+            q1_result_count = len(list(db.query(q1)))
+
+            if q1_result_count > 0: # 有執行項目
+                html += "<div style='color:blue;'><b>本合約執行項目: 共" + str(q1_result_count) + "筆,如下表:</b><br><br></div>"
+
+                html += "<table style='width:100%;border-collapse: collapse;' border='1'> \
+                <tr style='text-align:left;'> \
+                    <th style='width:5%;'>#</th> \
+                    <th>大項目</th> \
+                    <th>執行項</th> \
+                    <th>單位</th> \
+                    <th>是否完成</th> \
+                    <th>完成人</th> \
+                    <th>備註</th> \
+                    <th>預計排程日期</th> \
+                    <th>第一次提醒日</th> \
+                </tr>";
+
+                idx = 0
+
+                for r1 in db.query(q1):
+                    html += "<tr><td>" + str(idx) + "</td><td>" + r1['lv1'] + "</td><td>" + r1['lv2'] + "</td><td>" + r1['execute_man'] + "</td><td>" + r1['is_complete'] + "</td><td>" + r1['complete_man'] + "</td><td>" + r1['note'] + "</td><td>" + str(r1['set_date']) + "</td><td>" + str(r1['alert_date_1']) + "</td></tr>"
+
+                    idx += 1
         else:
             print ('修改後狀態: ' + is_close + ',不需通知')
             return
@@ -225,11 +261,10 @@ async def is_close_changed_notice(exf_id: str = '', is_close: str = ''):
     for email in email_list: # test
         print('寄送Email: ' + email)
 
-    '''
+
     # Email清單
     email_list = ['mike@choozmo.com']
 
     # 寄送逾期執行表單Email通知
     for email in email_list:
-        hhh_send_mail(email, subject, html)
-    '''    
+        hhh_send_mail(email, subject, html)