|
@@ -10,6 +10,8 @@ from common.auth_user import *
|
|
|
from sqlalchemy import text
|
|
|
from pydantic import BaseModel
|
|
|
from common.BigDataCenterAPI import *
|
|
|
+from common.db import db_event_management, db_user, db_yzy
|
|
|
+from config import settings
|
|
|
from database import get_db
|
|
|
from typing import List
|
|
|
from models import *
|
|
@@ -17,8 +19,10 @@ from utils import *
|
|
|
from utils.spatial import *
|
|
|
from utils.ry_system_util import *
|
|
|
from common.websocketManager import *
|
|
|
+from common import YzyApi
|
|
|
import json
|
|
|
import traceback
|
|
|
+from common.enc import mpfun
|
|
|
from . import template
|
|
|
from . import classification
|
|
|
|
|
@@ -138,8 +142,45 @@ async def delete_pattern(
|
|
|
traceback.print_exc()
|
|
|
raise HTTPException(status_code=500, detail=f"Internal server error: {str(e)}")
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+# 预案分享
|
|
|
+@router.post("/share")
|
|
|
+async def share_pattern(
|
|
|
+ user_id=Depends(valid_access_token),
|
|
|
+ body = Depends(remove_xss_json),
|
|
|
+ db: Session = Depends(get_db)
|
|
|
+):
|
|
|
+ try:
|
|
|
+ event_id = body['event_id']
|
|
|
+ pattern_id = body['pattern_id']
|
|
|
+ pattern_name = body['pattern_name']
|
|
|
+ userIdList = body['userIdList']
|
|
|
+
|
|
|
+ nick_name = db_user.get_nick_name_by_id(db, user_id)
|
|
|
+
|
|
|
+ for to_user_id in userIdList:
|
|
|
+ user_info = db_user.get_user_info(db, to_user_id)
|
|
|
+ yzy_account = mpfun.dec_data(user_info.yzy_account)
|
|
|
+ yzy_userid = db_yzy.get_userid_by_account(db, yzy_account)
|
|
|
+
|
|
|
+ detail_url = "{}{}{}".format(settings.YZY_WEB_ROOT, "/yjxp/#/leader/mobile_control?event_id=", event_id)
|
|
|
+
|
|
|
+ description = f"{nick_name}分享预案“{pattern_name}”给您,请查看!"
|
|
|
+ data = {
|
|
|
+ "yzy_userid": yzy_userid,
|
|
|
+ "mobile": yzy_account,
|
|
|
+ "content": description,
|
|
|
+ "recorded_by": user_id,
|
|
|
+ "detail_url": detail_url,
|
|
|
+ "foreign_key": pattern_id,
|
|
|
+ "from_scenario": "pattern_list",
|
|
|
+ "title": "预案分享"
|
|
|
+ }
|
|
|
+ YzyApi.add_to_msg_queue(db, data)
|
|
|
+
|
|
|
+ return {"code": 200, "msg": "预案分享成功", "data": None}
|
|
|
+ except Exception as e:
|
|
|
+ traceback.print_exc()
|
|
|
+ raise HTTPException(status_code=500, detail=f"Internal server error: {str(e)}")
|
|
|
|
|
|
@router.websocket("/{pattern_id}/ws")
|
|
|
async def websocket_endpoint(pattern_id:str ,websocket: WebSocket,db: Session = Depends(get_db)):
|