|
@@ -150,8 +150,8 @@ async def create_by_city_to_area(
|
|
|
db.commit()
|
|
|
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,
|
|
@@ -250,6 +250,9 @@ async def create_by_city_to_district(
|
|
|
db.add(new_detail)
|
|
|
db.commit()
|
|
|
|
|
|
+ # 发送粤政易消息
|
|
|
+ send_yzy_msg(db, new_detail, user_id)
|
|
|
+
|
|
|
return {
|
|
|
"code": 200,
|
|
|
"msg": "点名创建成功",
|
|
@@ -344,6 +347,9 @@ async def create_by_dept_ids(
|
|
|
db.add(new_detail)
|
|
|
db.commit()
|
|
|
|
|
|
+ # 发送粤政易消息
|
|
|
+ send_yzy_msg(db, new_detail, user_id)
|
|
|
+
|
|
|
# 检查多次,避免人员为空
|
|
|
user_count = db.query(OnlineRollCallDetail).filter(OnlineRollCallDetail.pid == new_call_id).count()
|
|
|
if user_count == 0:
|
|
@@ -455,7 +461,11 @@ async def query_mycall(
|
|
|
db: Session = Depends(get_db),
|
|
|
user_id = Depends(valid_access_token)
|
|
|
):
|
|
|
- rows = db.query(OnlineRollCallDetail).filter(and_(OnlineRollCallDetail.leader_id == user_id, OnlineRollCallDetail.ack_status == 0)).all()
|
|
|
+ is_myid_where = or_(OnlineRollCallDetail.standby_staff_id == user_id,
|
|
|
+ OnlineRollCallDetail.leader_id == user_id,
|
|
|
+ OnlineRollCallDetail.primary_staff_id == user_id,
|
|
|
+ OnlineRollCallDetail.secondary_staff_id == user_id)
|
|
|
+ rows = db.query(OnlineRollCallDetail).filter(and_(is_myid_where, OnlineRollCallDetail.ack_status == 0)).all()
|
|
|
data = []
|
|
|
for row in rows:
|
|
|
call_id = row.pid
|
|
@@ -527,26 +537,35 @@ async def get_event_detail(
|
|
|
traceback.print_exc()
|
|
|
raise HTTPException(status_code=500, detail=str(e))
|
|
|
|
|
|
+# 发送粤政易消息
|
|
|
def send_yzy_msg(db: Session, detail_entity: OnlineRollCallDetail, user_id: int) -> None:
|
|
|
- to_user_id = detail_entity.leader_id
|
|
|
- user_info = db_user.get_user_info(db, to_user_id)
|
|
|
- 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("{}/".format(settings.YJXP_WEB_ROOT_PATH)) # 主页
|
|
|
-
|
|
|
- description = f"你有一条在线点名通知,请尽快确认\n点名时间:{create_time}"
|
|
|
- data = {
|
|
|
- "yzy_userid": yzy_userid,
|
|
|
- "mobile": yzy_account,
|
|
|
- "content": description,
|
|
|
- "recorded_by": user_id,
|
|
|
- "detail_url": detail_url,
|
|
|
- "foreign_key": detail_entity.id,
|
|
|
- "from_scenario": "online_roll_call_detail",
|
|
|
- "title": "在线点名提醒"
|
|
|
- }
|
|
|
- YzyApi.add_to_msg_queue(db, data)
|
|
|
+ to_users = [detail_entity.leader_id, detail_entity.primary_staff_id, detail_entity.secondary_staff_id, detail_entity.standby_staff_id]
|
|
|
+ user_list = []
|
|
|
+ for to_user_id in to_users:
|
|
|
+ user_info = db_user.get_user_info(db, to_user_id)
|
|
|
+ yzy_account = user_info.yzy_account
|
|
|
+
|
|
|
+ if yzy_account not in user_list:
|
|
|
+ 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("{}/".format(settings.YJXP_WEB_ROOT_PATH)) # 主页
|
|
|
+ detail_url = "{}{}".format(settings.YZY_WEB_ROOT, "/yjxp/")
|
|
|
+
|
|
|
+ description = f"你有一条在线点名通知,请尽快确认\n点名时间:{create_time}"
|
|
|
+ data = {
|
|
|
+ "yzy_userid": yzy_userid,
|
|
|
+ "mobile": yzy_account,
|
|
|
+ "content": description,
|
|
|
+ "recorded_by": user_id,
|
|
|
+ "detail_url": detail_url,
|
|
|
+ "foreign_key": detail_entity.id,
|
|
|
+ "from_scenario": "online_roll_call_detail",
|
|
|
+ "title": "在线点名提醒"
|
|
|
+ }
|
|
|
+ YzyApi.add_to_msg_queue(db, data)
|
|
|
+ db_msg_center.add_msg(db, "在线点名", detail_entity.id, user_id)
|
|
|
+
|
|
|
+ user_list.append(yzy_account)
|
|
|
|
|
|
def get_ack_status_text(ack_status: int) -> str:
|
|
|
if ack_status == 0:
|