|
@@ -54,34 +54,38 @@ def proc():
|
|
|
'''
|
|
|
redis_unlock(lock_key)
|
|
|
|
|
|
-def yzy_msg_queue_proc(db = get_local_db()):
|
|
|
+def yzy_msg_queue_proc():
|
|
|
+ print('yzy_msg_queue_proc ')
|
|
|
if settings.IS_PROD == False:
|
|
|
return
|
|
|
|
|
|
- lock_key = "yzy_msg_queue_job"
|
|
|
- if redis_lock(lock_key):
|
|
|
- logger.info(datetime.now())
|
|
|
+ with get_local_db() as db:
|
|
|
+ print('yzy_msg_queue_proc starting...')
|
|
|
+ lock_key = "yzy_msg_queue_job"
|
|
|
+ if redis_lock(lock_key):
|
|
|
+ logger.info(datetime.now())
|
|
|
|
|
|
- rows = db.query(YzyMsgQueue).filter(YzyMsgQueue.sent_status == 0).limit(20).all()
|
|
|
- for row in rows:
|
|
|
- try:
|
|
|
- resp = YzyApi.send_textcard_message(row.yzy_userid, row.title, row.content, row.detail_url)
|
|
|
- logger.info(resp)
|
|
|
- row.sent_time = datetime.now()
|
|
|
- if resp['errcode'] == 0:
|
|
|
- row.sent_status = 1
|
|
|
+ rows = db.query(YzyMsgQueue).filter(YzyMsgQueue.sent_status == 0).limit(20).all()
|
|
|
+ for row in rows:
|
|
|
+ try:
|
|
|
+ resp = YzyApi.send_textcard_message(row.yzy_userid, row.title, row.content, row.detail_url)
|
|
|
+ logger.info(resp)
|
|
|
+ row.sent_time = datetime.now()
|
|
|
+ if resp['errcode'] == 0:
|
|
|
+ row.sent_status = 1
|
|
|
|
|
|
- if 'jobid' not in resp:
|
|
|
- resp['jobid'] = ''
|
|
|
- row.errmsg = resp['jobid']
|
|
|
- else:
|
|
|
- row.sent_status = 9
|
|
|
- row.errmsg = resp['errmsg']
|
|
|
- db.commit()
|
|
|
- except Exception as e:
|
|
|
- traceback.print_exc()
|
|
|
+ if 'jobid' not in resp:
|
|
|
+ resp['jobid'] = ''
|
|
|
+ row.errmsg = resp['jobid']
|
|
|
+ else:
|
|
|
+ row.sent_status = 9
|
|
|
+ row.errmsg = resp['errmsg']
|
|
|
+ db.commit()
|
|
|
+ except Exception as e:
|
|
|
+ traceback.print_exc()
|
|
|
|
|
|
- redis_unlock(lock_key)
|
|
|
+ redis_unlock(lock_key)
|
|
|
+ print('yzy_msg_queue_proc end.')
|
|
|
|
|
|
def yzy_unit_queue_proc():
|
|
|
if settings.IS_PROD == False:
|
|
@@ -98,7 +102,7 @@ def yzy_unit_queue_proc():
|
|
|
# 这个看起来没用
|
|
|
# YzyApi.getauthorizedusersbyupdatetime(starttime, endtime)
|
|
|
|
|
|
- YzyApi.getappusersbyupdatetime(starttime, endtime)
|
|
|
+ result = YzyApi.getappusersbyupdatetime(starttime, endtime)
|
|
|
|
|
|
'''
|
|
|
result = {
|
|
@@ -184,7 +188,7 @@ def yzy_unit_queue_proc():
|
|
|
"unitid": unitid,
|
|
|
"position": position,
|
|
|
"priority": priority,
|
|
|
- "order": order,
|
|
|
+ "order_num": order,
|
|
|
"unitpath": unitpath
|
|
|
}
|
|
|
|