|
@@ -5,8 +5,8 @@ import time
|
|
|
import pymysql
|
|
|
import pytz,os
|
|
|
|
|
|
-SELECT_SQL = "SELECT sms.space_id, sms.meeting_id, m2. NAME FROM space_meet_set sms " \
|
|
|
- "LEFT JOIN meeting m2 ON sms.meeting_id = m2.id WHERE meeting_id IN" \
|
|
|
+SELECT_SQL = "SELECT sms.space_id, m2.id, m2. NAME FROM meeting m2 " \
|
|
|
+ "LEFT JOIN space_meet_set sms ON sms.meeting_id = m2.id WHERE m2.id IN" \
|
|
|
" ( SELECT id FROM meeting m WHERE classification = %s AND m.building_id = '%s' AND m. STATUS = 1 );"
|
|
|
|
|
|
def datetime_now():
|
|
@@ -56,28 +56,32 @@ while True:
|
|
|
|
|
|
for classification in classifications:
|
|
|
name = classifications[classification]
|
|
|
+ print("%s,四川大厦,开始检查%s数据"%(datetime_now(),name))
|
|
|
# 获取值
|
|
|
mysql_cur.execute(SELECT_SQL%(classification,building_id))
|
|
|
datas = mysql_cur.fetchall()
|
|
|
if datas:
|
|
|
null_sum = [i for i in datas if i[0] == None]
|
|
|
- print("%s,四川大厦, %s: 总共%s个, 有%s个未绑定空间"%(datetime_now(),name,len(datas),len(null_sum)))
|
|
|
- message = (" - **类型:** %s \n" + "- **总数量:** %s \n"+ " - **未绑定空间数量:** <font color=#FF0000>%s</font> \n") % (name,len(datas),len(null_sum))
|
|
|
- messages.append(message)
|
|
|
- messages.append("___")
|
|
|
+ if len(null_sum) != 0:
|
|
|
+ print("%s,四川大厦, %s: 总共%s个, 有%s个未绑定空间"%(datetime_now(),name,len(datas),len(null_sum)))
|
|
|
+ message = (" - **类型:** %s \n" + "- **总数量:** %s \n"+ " - **未绑定空间数量:** <font color=#FF0000>%s</font> \n") % (name,len(datas),len(null_sum))
|
|
|
+ messages.append(message)
|
|
|
+ messages.append("___")
|
|
|
+ else:
|
|
|
+ print("%s,四川大厦, 没有异常数据" % (datetime_now()))
|
|
|
else:
|
|
|
- print("%s,四川大厦, 没有查询到%s数据"%(datetime_now(),classification))
|
|
|
+ print("%s,四川大厦, 没有查询到%s数据"%(datetime_now(),name))
|
|
|
|
|
|
# 关闭数据库
|
|
|
mysql_cur.close()
|
|
|
conn.close()
|
|
|
#
|
|
|
- if messages:
|
|
|
- print("%s 发送钉钉报警" % datetime_now())
|
|
|
- messages.append("<font color=#0080FF>详情查看MySQL数据库sagacloud_setup里的space_meet_set表</font>")
|
|
|
- messages_info = "\n".join(messages)
|
|
|
- # 如果有报警,发送钉钉
|
|
|
- title = "## **【四川大厦】会议室未绑定空间报警** "
|
|
|
- messages_info = title + "\n" + "___" + "\n" + messages_info
|
|
|
- send_message_markdown(title, messages_info, dingding)
|
|
|
+ # if messages:
|
|
|
+ # print("%s 发送钉钉报警" % datetime_now())
|
|
|
+ # messages.append("<font color=#0080FF>详情查看MySQL数据库sagacloud_setup里的space_meet_set表</font>")
|
|
|
+ # messages_info = "\n".join(messages)
|
|
|
+ # # 如果有报警,发送钉钉
|
|
|
+ # title = "## **【四川大厦】会议室未绑定空间报警** "
|
|
|
+ # messages_info = title + "\n" + "___" + "\n" + messages_info
|
|
|
+ # send_message_markdown(title, messages_info, dingding)
|
|
|
time.sleep(2)
|