|
@@ -52,10 +52,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')
|
|
|
|
|
|
print ('發送執行項目通知(無預定完成日期) start...')
|
|
|
|
|
@@ -122,7 +122,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 idx < 1:
|
|
|
html += "<tr><td rowspan='" + q3_result_count + "'>" + str(count) + "</td><td rowspan='" + q3_result_count + "'><a href='" + url + "' target='_blank'>" + r3['num'] + "</a></td><td rowspan='" + q3_result_count + "'>" + r3['company'] + "</td><td rowspan='" + q3_result_count + "'>" + str(r3['contract_time']) + "</td><td rowspan='" + q3_result_count + "'>" + r3['sales_man'] + "</td><td>" + r3['lv1'] + "_" + r3['lv2'] + "</td><tr>"
|
|
@@ -134,9 +134,9 @@ if q2_result_count > 0: # 有執行項目(無預定完成日期)
|
|
|
count += 1
|
|
|
|
|
|
html += "</table>";
|
|
|
-else: # 沒有未預定完成日期的執行表單資料
|
|
|
- print ("所有執行項目皆有【預定完成日期】,不須處理")
|
|
|
- html += "所有執行項目皆有【預定完成日期】,不須處理"
|
|
|
+# else: # 沒有未預定完成日期的執行表單資料
|
|
|
+# print ("所有執行項目皆有【預定完成日期】,不須處理")
|
|
|
+# html += "所有執行項目皆有【預定完成日期】,不須處理"
|
|
|
|
|
|
html += """
|
|
|
</body>
|
|
@@ -154,8 +154,8 @@ for email in crm_list:
|
|
|
|
|
|
print ('發送執行項目通知(無預定完成日期) end...')
|
|
|
|
|
|
-'''
|
|
|
-print ('\n發送逾期執行項目通知 (執行單位) start...')
|
|
|
+
|
|
|
+print ('\n發送執行項目通知(無預定完成日期) (執行單位) start...')
|
|
|
|
|
|
# 執行單位Email
|
|
|
# hhh_edit@hhh.com.tw: 編輯採訪部
|
|
@@ -169,28 +169,6 @@ print ('\n發送逾期執行項目通知 (執行單位) start...')
|
|
|
execute_man_list = ['hhh_edit@hhh.com.tw','hhh_mk@hhh.com.tw','hhh_web@hhh.com.tw','hhh_video@hhh.com.tw','agent@hhh.com.tw','hhh_admin@hhh.com.tw','hhh_sales@hhh.com.tw']
|
|
|
|
|
|
for execute_man in execute_man_list:
|
|
|
- # 所有逾期合約 (執行單位)
|
|
|
- q1 = "SELECT DISTINCT(ef.exf_id) \
|
|
|
- FROM execute_detail ed \
|
|
|
- left JOIN execute_form ef ON ed.exf_id=ef.exf_id \
|
|
|
- WHERE TIMESTAMPDIFF(DAY, set_date, NOW()) > 15 \
|
|
|
- AND ef.is_close='N' AND ef.is_delete='N' \
|
|
|
- AND ed.is_delete = 'N' AND ed.is_complete='N' \
|
|
|
- AND ed.set_date > '" + overdue_date + "' \
|
|
|
- AND ed.execute_man = '" + execute_man + "' \
|
|
|
- ORDER BY ef.contract_time, ed.set_date"
|
|
|
-
|
|
|
- # 所有逾期執行項 (執行單位)
|
|
|
- q2 = "SELECT * \
|
|
|
- FROM execute_detail ed \
|
|
|
- left JOIN execute_form ef ON ed.exf_id=ef.exf_id \
|
|
|
- WHERE TIMESTAMPDIFF(DAY, set_date, NOW()) > 15 \
|
|
|
- AND ef.is_close='N' AND ef.is_delete='N' \
|
|
|
- AND ed.is_delete = 'N' AND ed.is_complete='N' \
|
|
|
- AND ed.set_date > '" + overdue_date + "' \
|
|
|
- AND ed.execute_man = '" + execute_man + "' \
|
|
|
- ORDER BY ef.contract_time, ed.set_date"
|
|
|
-
|
|
|
html = """
|
|
|
<!DOCTYPE html>
|
|
|
<head>
|
|
@@ -202,12 +180,9 @@ for execute_man in execute_man_list:
|
|
|
# q1_result_count = len(list(db.query(q1)))
|
|
|
q2_result_count = len(list(db.query(q2)))
|
|
|
|
|
|
- # if q1_result_count > 0: # 有逾期合約
|
|
|
- # html += "<div style='color:blue;'><b>逾期合約: 共" + str(q1_result_count) + "筆</b></div>"
|
|
|
-
|
|
|
if q2_result_count > 0: # 有逾期執行項目
|
|
|
# html += "<div style='color:blue;'><b>逾期執行項目: 共" + str(q2_result_count) + "筆</b><br><br></div>"
|
|
|
- html += "<div style='color:blue;'><b>" + execute_man + " 逾期執行項目: 共" + str(q2_result_count) + "筆 (由" + overdue_date + "起算)</b><br><br></div>"
|
|
|
+ html += "<div style='color:blue;'><b>" + execute_man + " 無預定完成日期: 共" + str(q2_result_count) + "筆</b><br><br></div>"
|
|
|
|
|
|
html += "<table style='width:100%;border-collapse: collapse;' border='1'> \
|
|
|
<tr style='text-align:left;'> \
|
|
@@ -217,47 +192,41 @@ for execute_man in execute_man_list:
|
|
|
<th style='width:15%;'>合約到期日</th> \
|
|
|
<th style='width:5%;'>負責業務</th> \
|
|
|
<th style='width:20%;'>執行項</th> \
|
|
|
- <th style='width:15%;'>預定到期日</th> \
|
|
|
</tr>";
|
|
|
|
|
|
count = 1
|
|
|
|
|
|
for r1 in db.query(q1):
|
|
|
- # 特定合約的所有逾期執行項
|
|
|
+ # 特定合約的所有執行項(無預定完成日期)
|
|
|
q3 = "SELECT * \
|
|
|
FROM execute_detail ed \
|
|
|
left JOIN execute_form ef ON ed.exf_id=ef.exf_id \
|
|
|
- WHERE TIMESTAMPDIFF(DAY, set_date, NOW()) > 15 \
|
|
|
- AND ef.is_close='N' AND ef.is_delete='N' \
|
|
|
+ WHERE ef.is_close='N' AND ef.is_delete='N' \
|
|
|
AND ed.is_delete = 'N' AND ed.is_complete='N' \
|
|
|
- AND ed.set_date > '" + overdue_date + "' \
|
|
|
- AND ed.execute_man = '" + execute_man + "' \
|
|
|
+ AND ed.set_date = '0000-00-00' \
|
|
|
AND ef.exf_id = '" + str(r1['exf_id']) + "' \
|
|
|
- ORDER BY ef.contract_time, ed.set_date"
|
|
|
+ ORDER BY ed.execute_man"
|
|
|
|
|
|
q3_result_count = str(len(list(db.query(q3)))+1)
|
|
|
|
|
|
idx = 0
|
|
|
|
|
|
for r3 in db.query(q3):
|
|
|
- url = 'https://backstage.hhh.com.tw/admin/home/execute?exf_id=' + str(r3['exf_id'])
|
|
|
-
|
|
|
- if r3['set_date'] is None:
|
|
|
- r3['set_date'] = '無'
|
|
|
+ url = 'https://stage-backstage.hhh.com.tw/admin/home/execute?exf_id=' + str(r3['exf_id'])
|
|
|
|
|
|
if idx < 1:
|
|
|
- html += "<tr><td rowspan='" + q3_result_count + "'>" + str(count) + "</td><td rowspan='" + q3_result_count + "'><a href='" + url + "' target='_blank'>" + r3['num'] + "</a></td><td rowspan='" + q3_result_count + "'>" + r3['company'] + "</td><td rowspan='" + q3_result_count + "'>" + str(r3['contract_time']) + "</td><td rowspan='" + q3_result_count + "'>" + r3['sales_man'] + "</td><td>" + r3['lv1'] + "_" + r3['lv2'] + "</td><td>" + str(r3['set_date']) + "</td><tr>"
|
|
|
+ html += "<tr><td rowspan='" + q3_result_count + "'>" + str(count) + "</td><td rowspan='" + q3_result_count + "'><a href='" + url + "' target='_blank'>" + r3['num'] + "</a></td><td rowspan='" + q3_result_count + "'>" + r3['company'] + "</td><td rowspan='" + q3_result_count + "'>" + str(r3['contract_time']) + "</td><td rowspan='" + q3_result_count + "'>" + r3['sales_man'] + "</td><td>" + r3['lv1'] + "_" + r3['lv2'] + "</td><tr>"
|
|
|
|
|
|
idx += 1
|
|
|
else:
|
|
|
- html += "<tr><td>" + r3['lv1'] + "_" + r3['lv2'] + "</td><td>" + str(r3['set_date']) + "</td></tr>"
|
|
|
+ html += "<tr><td>" + r3['lv1'] + "_" + r3['lv2'] + "</td></tr>"
|
|
|
|
|
|
count += 1
|
|
|
|
|
|
html += "</table>";
|
|
|
- else: # 無逾期執行表單資料
|
|
|
- print (execute_man + " 無逾期執行項目記錄,不須處理 (由" + overdue_date + "起算)")
|
|
|
- html += "<div>" + execute_man + " 無逾期執行項目記錄,不須處理 (由" + overdue_date + "起算)</div>"
|
|
|
+ else:
|
|
|
+ print (execute_man + " 皆有預定完成日期,不須處理")
|
|
|
+ html += "<div>" + execute_man + " 皆有預定完成日期,不須處理)</div>"
|
|
|
|
|
|
html += """
|
|
|
</body>
|
|
@@ -269,5 +238,4 @@ for execute_man in execute_man_list:
|
|
|
print ("發送Email: " + email)
|
|
|
hhh_send_mail(email, html)
|
|
|
|
|
|
-print ('發送逾期執行項目通知 (執行單位) end...')
|
|
|
-'''
|
|
|
+print ('發送執行項目通知(無預定完成日期) (執行單位) end...')
|