libushang 5 місяців тому
батько
коміт
5f1db07095

+ 5 - 3
.env

@@ -1,6 +1,6 @@
 # 服务器环境,指明生产服务器,开发服务器,测试服务器来动态触发配置变量的调用
 # 系统中设置的环境变量优先于此处设置的环境变量
-ENVIRONMENT = "production" # production or development or stage
+ENVIRONMENT = "development" # production or development or stage
 
 #########################################################################
 # 开发环境的配置
@@ -19,7 +19,8 @@ DEV_YJHTGL_WEB_ROOT_PATH = "http://127.0.0.1:8086/yjzp/#"
 #小屏地址
 DEV_YJXP_WEB_ROOT_PATH = "http://127.0.0.1:8086/yjxp/#"
 #粤政易APP回调地址
-DEV_YJXP_CALLBACK_WEB_PATH = "http://127.0.0.1:9988/yzy/callback.html"
+# DEV_YJXP_CALLBACK_WEB_PATH = "http://127.0.0.1:9988/yzy/callback.html"
+DEV_YJXP_CALLBACK_WEB_PATH = "http://19.155.220.206:8086/yjxp/#/yzy/callback"
 
 #########################################################################
 # 预发布环境配置
@@ -45,7 +46,8 @@ 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"
-STAGE_YJXP_CALLBACK_WEB_PATH = "http://120.241.74.139:8086/yzy/callback.html"
+# STAGE_YJXP_CALLBACK_WEB_PATH = "http://120.241.74.139:8086/yzy/callback.html"
+STAGE_YJXP_CALLBACK_WEB_PATH = "http://19.155.220.206:8086/yjxp/#/yzy/callback"
 
 #########################################################################
 # 生产环境配置

+ 6 - 15
common/YzyApi.py

@@ -188,7 +188,7 @@ def calcRequestSign(timestamp, token, nonce, uid, uinfo, ext):
         ).hexdigest().upper()
 
 
-def format_redirect_url(redirect_url: str, user_id: str = '') -> str:
+def format_redirect_url(redirect_url: str) -> str:
     yzy_callback_url = quote(settings.YJXP_CALLBACK_WEB_PATH)
     logger.info("yzy_callback_url: {}", yzy_callback_url)
     
@@ -200,22 +200,13 @@ def format_redirect_url(redirect_url: str, user_id: str = '') -> str:
     # print(state_str)
     state = base64.b64encode(state_str.encode('utf-8')).decode('utf-8')
         
-    # 测试环境下直接跳转到回调页面
-    if settings.IS_PROD == False:
-        from utils import ase_utils
-        user_val = ase_utils.aesEncrypt(md5("c9128dee-912c-11ef-bf07-00ff257b5fc6"), user_id)
-        detail_url = settings.YJXP_CALLBACK_WEB_PATH + "?code={}&state={}".format(
-            user_val,
-            state)
-    else:
-        detail_url = "https://open.weixin.qq.com/connect/Oauth2/authorize?appid={}&redirect_uri={}&response_type=code&scope=snsapi_base&agentid={}&state={}#wechat_redirect".format(
-            YZY_CORPID,
-            yzy_callback_url, 
-            YZY_AGENTID,
-            state)
+    detail_url = "https://open.weixin.qq.com/connect/Oauth2/authorize?appid={}&redirect_uri={}&response_type=code&scope=snsapi_base&agentid={}&state={}#wechat_redirect".format(
+        YZY_CORPID,
+        yzy_callback_url, 
+        YZY_AGENTID,
+        state)
     
     logger.info("detail_url: {}", detail_url)
-
     return detail_url
     
 

+ 1 - 1
jobs/yzy_job.py

@@ -20,7 +20,7 @@ def proc():
 
         '''
         redirect_url = "{}/leader/index".format(settings.YJXP_WEB_ROOT_PATH) # 业务页面
-        detail_url = YzyApi.format_redirect_url(redirect_url, "eb4kehgy6wj4qn0jhx1dk6")
+        detail_url = YzyApi.format_redirect_url(redirect_url)
         
         yzy_user_id = "eb4kehgy6wj4qn0jhx1dk6"  # 暂时写死梦梅的账号
         description = "预案名称: 茂名市自然灾害救助应急预案\n响应级别: Ⅰ级响应\n消息内容: 单位您好!《茂名市自然灾害救助应急预案》现已全面启动,特此通知您单位迅速响应,全力做好预案工作要点:负责救灾工作宣传报道协调工作。"

+ 4 - 9
routers/api/eventManagement/checkin.py

@@ -35,10 +35,9 @@ async def get_qrcode(
     url = str(request.url)
     url = url.replace("qrcode", "qrcode2") + "&r="+rnd()
 
-    if settings.IS_STAGE:
-        url = url.replace(request.url.hostname, "120.241.74.139:8086")
-        logger.info('替换到互联网ip: {}', url)
-        
+    # if settings.IS_STAGE:
+    #     url = url.replace(request.url.hostname, "120.241.74.139:8086")
+    #    logger.info('替换到互联网ip: {}', url)   
 
     qr = qrcode.QRCode(
         version=1,
@@ -60,17 +59,13 @@ async def get_qrcode2(
     event_id: str,
     db: Session = Depends(get_db)
 ):    
-    # redirect_url = "{}/signPage?event_id={}".format(settings.YJXP_WEB_ROOT_PATH, event_id) # 业务页面
     redirect_url = "/signPage?event_id={}".format(event_id) # 业务页面
-
     logger.info("redirect_url: {}", redirect_url)
-    
     # qrcode_str = f"http://19.155.220.209/api/event_management/event?event_id={event_id}"
-    detail_url = YzyApi.format_redirect_url(redirect_url, "eb4kehgy6wj4qn0jhx1dk6")
+    detail_url = YzyApi.format_redirect_url(redirect_url)
 
     return RedirectResponse(detail_url)
 
-
 @router.post("/getInfo")
 async def getInfo(
     request: Request, 

+ 4 - 15
routers/api/eventManagement/event.py

@@ -11,7 +11,7 @@ import random
 from sqlalchemy import create_engine, select
 from typing import Optional
 from utils.StripTagsHTMLParser import *
-from common.db import db_event_management, db_user, db_area, db_emergency_plan
+from common.db import db_event_management, db_user, db_area, db_emergency_plan, db_msg_center
 from common.security import valid_access_token
 import traceback
 from utils import *
@@ -936,21 +936,8 @@ async def send_emergency_plan_task_by_yzy(
         db.refresh(event_emergency_notify)
 
         description = "预案名称: " + plan_name + "\n响应级别:" + response_level + "\n消息内容: "+yzy_content
-
-        '''
-        yzy_callback_url = quote("http://19.155.220.206/yjxp/#/yzy-callback")
-        state_json = {
-            "redirect_url": "http://19.155.220.206/yjxp/#/leader/index" # 业务页面
-        }
-        state_str = json.dumps(state_json)
-        state = base64.b64encode(state_str).decode('utf-8')
-        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: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
+        detail_url = YzyApi.format_redirect_url(redirect_url)
 
         send_queue.append({
             "id": event_emergency_notify.id,
@@ -958,6 +945,8 @@ async def send_emergency_plan_task_by_yzy(
             "description": description,
             "detail_url": detail_url
         })
+
+        db_msg_center.add_msg(db, "预案通知", event_emergency_notify.id, user_id)
     
     background_tasks.add_task(async_send_yzy_msg, db, send_queue)
 

+ 3 - 3
routers/api/onlineRollCall/call.py

@@ -13,7 +13,7 @@ import os
 from sqlalchemy import create_engine, select
 from typing import Optional
 from utils.StripTagsHTMLParser import *
-from common.db import db_user, db_yzy, db_dept
+from common.db import db_user, db_yzy, db_dept, db_msg_center
 from common.security import valid_access_token
 import traceback
 from utils import *
@@ -151,6 +151,7 @@ async def create_by_city_to_area(
             db.refresh(new_detail)
 
             send_yzy_msg(db, new_detail, user_id)
+            db_msg_center.add_msg(db, "在线点名", new_detail.id, user_id)
 
         return {
             "code": 200,
@@ -532,8 +533,7 @@ def send_yzy_msg(db: Session, detail_entity: OnlineRollCallDetail, user_id: int)
     yzy_account = user_info.yzy_account
     yzy_userid = db_yzy.get_userid_by_account(db, yzy_account)
     create_time = get_datetime_str(detail_entity.create_time)
-    # detail_url = YzyApi.format_redirect_url(settings.YJXP_WEB_ROOT_PATH, yzy_userid)
-    detail_url = "{}/".format(settings.YJXP_WEB_ROOT_PATH) # 主页
+    detail_url = YzyApi.format_redirect_url("{}/".format(settings.YJXP_WEB_ROOT_PATH)) # 主页
 
     description = f"你有一条在线点名通知,请尽快确认\n点名时间:{create_time}"
     data = {