Commit 9ee3064c authored by 王瑞环's avatar 王瑞环

update

parent 34a72ffc
......@@ -7,7 +7,7 @@ mysql 里面的数据和es里面的数据是否一致
import pymysql
import datetime
from dingtalkchatbot.chatbot import DingtalkChatbot
import settings_local
import settings_local
from elasticsearch import Elasticsearch
......@@ -23,7 +23,7 @@ def main():
artemis_cursor = artemis_db.cursor()
limit = 100
account_sql = "select doctor_id, (rechange_amount+cashback_amount) as amount from account_account order by modify_time desc limit %s"
try:
artemis_cursor.execute(account_sql, (limit))
accounts = artemis_cursor.fetchall()
......@@ -34,7 +34,7 @@ def main():
"query": {"bool": {
"filter": [
{"terms": {"id": doctor_ids}}]}}}
es_result = es.search(query)
es_result = es.search(query, settings_local.ES_INDEX)
budgetSql = """
select budget, is_open from bdtransfer_prioritybdtransfer
where merchant_id = {}
......@@ -43,7 +43,7 @@ def main():
consumeSql = """
select amount from bdtransfer_bdtransferconsume
where merchant_id = {}
and date = {} """
and date = '{}' """
today = str(datetime.date.today())
num = 0.0
......@@ -65,31 +65,36 @@ def main():
budget_res = artemis_cursor.fetchone()
artemis_cursor.execute(consume_sql)
consume_res = artemis_cursor.fetchone()
if budget_res:
budget = budget_res[0]
mysql_is_merchant_priority_send_order = budget_res[1]
if consume_res:
consume = consume_res[0]
mysql_left_consume = consume - budget
print("""
merchant_left_money: {}, mysql_merchant_left_money: {},
left_consume: {}, mysql_left_consume:{},
is_merchant_priority_send_order: {},
mysql_is_merchant_priority_send_order:{}""".format(
merchant_left_money, mysql_merchant_left_money,
left_consume, mysql_left_consume,
is_merchant_priority_send_order,
mysql_is_merchant_priority_send_order
))
mysql_left_consume = budget - consume
if (
merchant_left_money == mysql_merchant_left_money and
left_consume == mysql_left_consume and
is_merchant_priority_send_order == mysql_is_merchant_priority_send_order):
int(merchant_left_money) == int(mysql_merchant_left_money) and
int(left_consume) == int(mysql_left_consume) and
int(is_merchant_priority_send_order) == int(mysql_is_merchant_priority_send_order)):
pass
else:
num = num + 1
error_doctors.append(doctor_id)
if (is_merchant_priority_send_order == mysql_is_merchant_priority_send_order and is_merchant_priority_send_order==False):
pass
else:
print("""
doctor_id: {},
merchant_left_money: {}, mysql_merchant_left_money: {},
left_consume: {}, mysql_left_consume:{},
is_merchant_priority_send_order: {},
mysql_is_merchant_priority_send_order:{}""".format(
doctor_id,
merchant_left_money, mysql_merchant_left_money,
left_consume, mysql_left_consume,
is_merchant_priority_send_order,
mysql_is_merchant_priority_send_order
))
num = num + 1
error_doctors.append(doctor_id)
print(num)
if num / limit > 0.02:
msg = "数据同步监控,总共{}个医生id,有{}个数据存在差异,具体医生id:{}".format(limit, len(error_doctors), error_doctors)
......@@ -99,7 +104,7 @@ def main():
at_mobiles = ["17794411132"]
# at_mobiles = []
xiaoding.send_text(msg=msg, at_mobiles=at_mobiles)
except Exception as e:
msg = "数据同步监控,数据diff出现问题"
webhook = 'https://oapi.dingtalk.com/robot/send?access_token={}'.format(
......@@ -111,4 +116,4 @@ def main():
if __name__ == '__main__':
main()
main()
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment