|
@@ -3,7 +3,7 @@ from utils import *
|
|
|
from sqlalchemy import and_, or_
|
|
|
from datetime import datetime, timedelta
|
|
|
from dateutil.relativedelta import relativedelta
|
|
|
-from common.db import db_user, db_yzy, db_msg_center
|
|
|
+from common.db import db_user, db_yzy, db_msg_center, db_dict
|
|
|
from common import YzyApi
|
|
|
from config import settings
|
|
|
|
|
@@ -191,12 +191,12 @@ def create_children_task(db,task_info,corn_query):
|
|
|
task_title = get_task_title_by_type(task_info.inspection_business)
|
|
|
description = f"你有一个{task_title}任务需要处理,点击处理"
|
|
|
detail_url = "{}/yjxp/#/worker/inspectionWork".format(settings.YZY_WEB_ROOT)
|
|
|
- foreign_key = "0"
|
|
|
- from_scenario = ""
|
|
|
+ foreign_key = str(task_info.id)
|
|
|
+ from_scenario = "risk_management_inspection_task"
|
|
|
|
|
|
- send_yzy_msg(db, to_user_id, task_info.id, yzy_account, description, detail_url, foreign_key, from_scenario)
|
|
|
+ send_yzy_msg(db, "隐患巡查", to_user_id, task_info.id, yzy_account, description, detail_url, foreign_key, from_scenario)
|
|
|
|
|
|
-def get_task_title_by_type(type: int) -> str:
|
|
|
+def get_task_title_by_type(type: str) -> str:
|
|
|
if type == '0':
|
|
|
return '城市隐患巡查'
|
|
|
elif type == '1':
|
|
@@ -209,7 +209,7 @@ def get_task_title_by_type(type: int) -> str:
|
|
|
return str(type)
|
|
|
|
|
|
# 发送粤政易消息
|
|
|
-def send_yzy_msg(db: Session, to_user_id: int, task_id: int, yzy_account: str, description: str, detail_url: str, foreign_key:str, from_scenario: str) -> None:
|
|
|
+def send_yzy_msg(db: Session, msg_type: str, to_user_id: int, task_id: int, yzy_account: str, description: str, detail_url: str, foreign_key:str, from_scenario: str) -> None:
|
|
|
yzy_userid = db_yzy.get_userid_by_account(db, yzy_account)
|
|
|
|
|
|
data = {
|
|
@@ -218,14 +218,15 @@ def send_yzy_msg(db: Session, to_user_id: int, task_id: int, yzy_account: str, d
|
|
|
"content": description,
|
|
|
"recorded_by": 0,
|
|
|
"detail_url": detail_url,
|
|
|
- "foreign_key": str(task_id),
|
|
|
- "from_scenario": "risk_management_inspection_task",
|
|
|
+ "foreign_key": foreign_key,
|
|
|
+ "from_scenario": from_scenario,
|
|
|
"title": "数据报送提醒"
|
|
|
}
|
|
|
YzyApi.add_to_msg_queue(db, data)
|
|
|
|
|
|
- db_msg_center.add_msg(db, "隐患巡查", str(task_id), to_user_id)
|
|
|
+ db_msg_center.add_msg(db, msg_type, str(task_id), to_user_id)
|
|
|
|
|
|
+# 风险防控
|
|
|
def create_risk_children_task(db,task_info,corn_query):
|
|
|
cycle = task_info.task_cycle
|
|
|
task_range = task_info.task_range
|
|
@@ -243,6 +244,20 @@ def create_risk_children_task(db,task_info,corn_query):
|
|
|
)
|
|
|
db.add(new_children_task)
|
|
|
db.commit()
|
|
|
+
|
|
|
+ # 发送粤政易消息
|
|
|
+ user_list = rang_get_user_list(db, task_range)
|
|
|
+ for user_info in user_list:
|
|
|
+ to_user_id = user_info.user_id
|
|
|
+ yzy_account = user_info.yzy_account
|
|
|
+ task_title = db_dict.get_dict_label(db, 'risk_type', task_info.risk_type)
|
|
|
+ description = f"你有一个{task_title}任务需要处理,点击处理"
|
|
|
+ detail_url = "{}/yjxp/#/worker/riskManagement".format(settings.YZY_WEB_ROOT)
|
|
|
+ foreign_key = str(task_info.id)
|
|
|
+ from_scenario = "risk_management_risk_task"
|
|
|
+
|
|
|
+ send_yzy_msg(db, "风险防控", to_user_id, task_info.id, yzy_account, description, detail_url, foreign_key, from_scenario)
|
|
|
+
|
|
|
def create_rescue_resources_children_task(db,task_info,corn_query):
|
|
|
cycle = task_info.task_cycle
|
|
|
task_range = task_info.task_range
|
|
@@ -260,6 +275,30 @@ def create_rescue_resources_children_task(db,task_info,corn_query):
|
|
|
)
|
|
|
db.add(new_children_task)
|
|
|
db.commit()
|
|
|
+
|
|
|
+ # 发送粤政易消息
|
|
|
+ user_list = rang_get_user_list(db, task_range)
|
|
|
+ for user_info in user_list:
|
|
|
+ to_user_id = user_info.user_id
|
|
|
+ yzy_account = user_info.yzy_account
|
|
|
+ task_title = get_rescue_resources_task_title_by_type(task_info.type)
|
|
|
+ description = f"你有一个{task_title}任务需要处理,点击处理"
|
|
|
+ detail_url = "{}/yjxp/#/worker/rescueManagement".format(settings.YZY_WEB_ROOT)
|
|
|
+ foreign_key = str(task_info.id)
|
|
|
+ from_scenario = "risk_management_rescue_resources_task"
|
|
|
+
|
|
|
+ send_yzy_msg(db, "数据采集", to_user_id, task_info.id, yzy_account, description, detail_url, foreign_key, from_scenario)
|
|
|
+
|
|
|
+def get_rescue_resources_task_title_by_type(type: str) -> str:
|
|
|
+ if type == '0':
|
|
|
+ return '庇护场所'
|
|
|
+ elif type == '1':
|
|
|
+ return '救援队伍'
|
|
|
+ elif type == '2':
|
|
|
+ return '救援设备'
|
|
|
+ else:
|
|
|
+ return str(type)
|
|
|
+
|
|
|
def inspection_task_id_get_inspection_task_info(db,id):
|
|
|
query = db.query(RiskManagementInspectionTask)
|
|
|
query = query.filter(RiskManagementInspectionTask.del_flag != '2')
|