libushang 6 miesięcy temu
rodzic
commit
a1c8a23f9a
3 zmienionych plików z 38 dodań i 28 usunięć
  1. 2 2
      .env
  2. 5 2
      routers/api/emergencyPlans/contact.py
  3. 31 24
      routers/api/eventManagement/event.py

+ 2 - 2
.env

@@ -40,8 +40,8 @@ STAGE_YJHTGL_WEB_ROOT_PATH = "http://19.155.220.206:8086/yjzp/#"
 # STAGE_YJHTGL_WEB_ROOT_PATH = "http://10.181.7.235:8086/yjzp/#"
 
 # 小屏地址
-STAGE_YJXP_WEB_ROOT_PATH = "http://19.155.220.206:8086/yjxp/#"
-# STAGE_YJXP_WEB_ROOT_PATH = "http://10.181.7.235:8086/yjxp/#"
+# STAGE_YJXP_WEB_ROOT_PATH = "http://19.155.220.206:8086/yjxp/#"
+STAGE_YJXP_WEB_ROOT_PATH = "http://120.241.74.139:8086/yjxp/#"
 
 # 粤政易APP回调地址(域名和端口不能随便改,申请时定下来)
 STAGE_YJXP_CALLBACK_WEB_PATH = "http://19.155.220.206:8086/yzy/callback.html"

+ 5 - 2
routers/api/emergencyPlans/contact.py

@@ -35,7 +35,7 @@ async def get_emergency_contact_list(
     try:
         # 构建查询
         query = db.query(EmergencyContactInfo)
-        query = query.filter(EmergencyContactInfo.del_flag != '2')
+        query = query.filter(EmergencyContactInfo.del_flag == '0')
         # 应用查询条件
         if unitId:
             query = query.filter(EmergencyContactInfo.unit_id == unitId)
@@ -47,7 +47,7 @@ async def get_emergency_contact_list(
 
         # 排序
 
-        query = query.order_by(EmergencyContactInfo.create_time.desc())
+        query = query.order_by(EmergencyContactInfo.id.asc())
         # 执行分页查询
         contact_infos = query.offset((page - 1) * pageSize).limit(pageSize).all()
 
@@ -365,6 +365,9 @@ async def create_contact(
             if unit_id == '':
                 raise AppException(500, "单位名称不正确")
         
+            # 删除之前同一个部门的人员
+            db.query(EmergencyContactInfo).filter(and_(EmergencyContactInfo.del_flag == "0", EmergencyContactInfo.unit_id == unit_id, )).update({"del_flag": "2"})
+
             new_contact = EmergencyContactInfo(
                 unit_id=unit_id,
                 unit_name=contact['单位名称'],

+ 31 - 24
routers/api/eventManagement/event.py

@@ -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")