|
@@ -779,7 +779,7 @@ async def send_emergency_plan_task_by_yzy(
|
|
|
if len(rows) == 0:
|
|
|
return {
|
|
|
"code": 500,
|
|
|
- "msg": "该预案没有相关通知人员"
|
|
|
+ "msg": "该预案没有相关通知部门"
|
|
|
}
|
|
|
|
|
|
for row in rows:
|
|
@@ -794,11 +794,11 @@ async def send_emergency_plan_task_by_yzy(
|
|
|
# 通过预案人员管理匹配负责人
|
|
|
user_id = 0
|
|
|
user_name = ''
|
|
|
- contact_row = db.query(EmergencyContactInfo).filter(EmergencyContactInfo.unit_id == dept_id).first()
|
|
|
+ contact_row = db.query(EmergencyContactInfo).filter(and_(EmergencyContactInfo.del_flag == "0", EmergencyContactInfo.unit_id == dept_id)).first()
|
|
|
yzy_account = contact_row.yue_gov_ease_phone
|
|
|
nick_name = contact_row.contact_name
|
|
|
|
|
|
- yzy_user_row = db.query(YzyOrgUserEntity).filter(YzyOrgUserEntity.telephonenumber == yzy_account).first()
|
|
|
+ yzy_user_row = db.query(YzyOrgUserEntity).filter(YzyOrgUserEntity.account == yzy_account).first()
|
|
|
if yzy_user_row is None:
|
|
|
logger.info("粤政易人员ID不存在", yzy_account)
|
|
|
yzy_user_id = ""
|
|
@@ -811,7 +811,7 @@ async def send_emergency_plan_task_by_yzy(
|
|
|
# user_id = user_row.user_id
|
|
|
# user_name = user_row.user_name
|
|
|
# nick_name = user_row.nick_name
|
|
|
- yzy_user_id = "eb4kehgy6wj4qn0jhx1dk6" # 暂时写死梦梅的账号
|
|
|
+ # yzy_user_id = "eb4kehgy6wj4qn0jhx1dk6" # 暂时写死梦梅的账号
|
|
|
yzy_content = "{},您好!《{}》现已全面启动,特此通知您单位迅速响应,全力做好预案工作要点:{}".format(row.dept_name, plan_info['plan_name'], row.content)
|
|
|
|
|
|
event_emergency_notify = EventEmergencyNotify(
|
|
@@ -844,15 +844,16 @@ async def send_emergency_plan_task_by_yzy(
|
|
|
detail_url = "https://open.weixin.qq.com/connect/Oauth2/authorize?appid=wld341060039&redirect_uri={}&response_type=code&scope=snsapi_base&agentid=1004302&state={}#wechat_redirect".format(yzy_callback_url, state)
|
|
|
'''
|
|
|
|
|
|
- # redirect_url = "http://19.155.220.206/yjxp/#/leader/index" # 业务页面
|
|
|
- redirect_url = "{}/leader/index".format(settings.YJXP_WEB_ROOT_PATH) # 业务页面
|
|
|
- detail_url = YzyApi.format_redirect_url(redirect_url, "eb4kehgy6wj4qn0jhx1dk6")
|
|
|
+ # redirect_url = "http://19.155.220.206:8086/yjxp/#/leader/index" # 业务页面
|
|
|
+ redirect_url = "{}/".format(settings.YJXP_WEB_ROOT_PATH) # 主页
|
|
|
+ # detail_url = YzyApi.format_redirect_url(redirect_url, "eb4kehgy6wj4qn0jhx1dk6")
|
|
|
+ detail_url = redirect_url
|
|
|
|
|
|
send_queue.append({
|
|
|
- id: event_emergency_notify.id,
|
|
|
- yzy_user_id: yzy_user_id,
|
|
|
- description: description,
|
|
|
- detail_url: detail_url
|
|
|
+ "id": event_emergency_notify.id,
|
|
|
+ "yzy_user_id": yzy_user_id,
|
|
|
+ "description": description,
|
|
|
+ "detail_url": detail_url
|
|
|
})
|
|
|
|
|
|
background_tasks.add_task(async_send_yzy_msg, db, send_queue)
|
|
@@ -863,22 +864,28 @@ async def send_emergency_plan_task_by_yzy(
|
|
|
}
|
|
|
|
|
|
def async_send_yzy_msg(db: Session, queue: dict):
|
|
|
- for i in queue:
|
|
|
- event_emergency_notify = db.query(EventEmergencyNotify).filter(EventEmergencyNotify.id == i['id']).first()
|
|
|
+ for item in queue:
|
|
|
+ event_emergency_notify = db.query(EventEmergencyNotify).filter(EventEmergencyNotify.id == item['id']).first()
|
|
|
if event_emergency_notify is not None and event_emergency_notify.sent_status == 0:
|
|
|
- yzy_user_id = i['yzy_user_id']
|
|
|
- description = i['description']
|
|
|
- detail_url = i['detail_url']
|
|
|
- try:
|
|
|
- resp = YzyApi.send_textcard_message([yzy_user_id], "预案响应消息", description, detail_url)
|
|
|
- if resp['errcode'] == 0:
|
|
|
- event_emergency_notify.sent_status = 1 # 发送成功
|
|
|
- else:
|
|
|
- event_emergency_notify.sent_status = 9 # 发送失败
|
|
|
+ yzy_user_id = item['yzy_user_id']
|
|
|
+
|
|
|
+ if yzy_user_id == "":
|
|
|
+ event_emergency_notify.sent_status = 9 # 发送失败
|
|
|
db.commit()
|
|
|
|
|
|
- except Exception:
|
|
|
- pass
|
|
|
+ else:
|
|
|
+ description = item['description']
|
|
|
+ detail_url = item['detail_url']
|
|
|
+ try:
|
|
|
+ resp = YzyApi.send_textcard_message([yzy_user_id], "预案响应消息", description, detail_url)
|
|
|
+ if resp['errcode'] == 0:
|
|
|
+ event_emergency_notify.sent_status = 1 # 发送成功
|
|
|
+ else:
|
|
|
+ event_emergency_notify.sent_status = 9 # 发送失败
|
|
|
+ db.commit()
|
|
|
+
|
|
|
+ except Exception:
|
|
|
+ pass
|
|
|
|
|
|
# 获取预案通知
|
|
|
@router.post("/emergency_plan_task_list")
|