|
@@ -173,7 +173,7 @@ async def create_emergency_plan(
|
|
|
db.add(infopublish_examine)
|
|
|
db.commit()
|
|
|
|
|
|
- # 改提交、待审批状态
|
|
|
+ # 改草稿、待审批状态
|
|
|
db.query(InfoPublishBase).filter(InfoPublishBase.id == new_publish_id).update({"publish_status": 1, "examine_status": 1})
|
|
|
db.commit()
|
|
|
|
|
@@ -194,21 +194,25 @@ async def get_publish_list(
|
|
|
publish_group: str = Query('', description='发布单位'),
|
|
|
publish_status: str = Query('', description='发布状态的字典键值'),
|
|
|
examine_status: str = Query('', description='审批状态的字典键值'),
|
|
|
+ dispose_status: str = Query('', description='处理状态的字典键值'),
|
|
|
sort_by: str = Query('', description='排序字段'),
|
|
|
sort_order: str = Query("asc", description='排序方式'),
|
|
|
page: int = Query(1, gt=0, description='页码'),
|
|
|
page_size: int = Query(10, gt=0, description='pageSize'),
|
|
|
- db: Session = Depends(get_db)
|
|
|
+ db: Session = Depends(get_db),
|
|
|
+ user_id = Depends(valid_access_token)
|
|
|
):
|
|
|
try:
|
|
|
# 应用查询条件
|
|
|
where = and_(InfoPublishBase.del_flag == '0')
|
|
|
- if publish_status != '':
|
|
|
+ if publish_status not in ['', '0'] :
|
|
|
where = and_(where, InfoPublishBase.publish_status == publish_status)
|
|
|
- if examine_status != '':
|
|
|
+ if examine_status not in ['', '0'] :
|
|
|
where = and_(where, InfoPublishBase.examine_status == examine_status)
|
|
|
if publish_group != '':
|
|
|
where = and_(where, InfoPublishBase.publish_group.like('%{}%'.format(publish_group)))
|
|
|
+ if dispose_status not in ['', '0'] :
|
|
|
+ where = and_(where, InfoPublishBase.examine_status == 1, InfoPublishBase.examine_by == user_id)
|
|
|
print(where)
|
|
|
|
|
|
# 计算总条目数
|
|
@@ -262,7 +266,10 @@ async def get_publish_list(
|
|
|
"user_count": row.user_count,
|
|
|
"user_ok_count": row.user_ok_count,
|
|
|
"user_err_count": row.user_err_count,
|
|
|
- "user_sending_count": row.user_sending_count
|
|
|
+ "user_sending_count": row.user_sending_count,
|
|
|
+
|
|
|
+ "is_my_edit": (row.examine_status == 0 or row.examine_status == 9) and row.recorded_by == user_id, # 是否我的编辑事项
|
|
|
+ "is_my_examine": row.examine_status == 1 and int(row.examine_by) == user_id # 是否我的审批事项
|
|
|
})
|
|
|
|
|
|
# 返回结果
|
|
@@ -395,6 +402,7 @@ async def post_examine_info(
|
|
|
@router.get("/sent_list")
|
|
|
async def get_sent_list(
|
|
|
info_id: str = Query('', description='信息ID'),
|
|
|
+ channel: str = Query('', description='渠道'),
|
|
|
keywords: str = Query('', description='关键字'),
|
|
|
sort_by: str = Query('', description='排序字段'),
|
|
|
sort_order: str = Query("asc", description='排序方式'),
|
|
@@ -405,6 +413,8 @@ async def get_sent_list(
|
|
|
try:
|
|
|
# 应用查询条件
|
|
|
where = and_(InfoPublishResponses.publish_id == info_id)
|
|
|
+ if channel != '':
|
|
|
+ where = and_(where, InfoPublishResponses.publish_channel.like('%{}%'.format(channel)))
|
|
|
|
|
|
# 计算总条目数
|
|
|
q = db.query(func.count(InfoPublishResponses.id))
|
|
@@ -430,7 +440,7 @@ async def get_sent_list(
|
|
|
}
|
|
|
for row in rows
|
|
|
]
|
|
|
-
|
|
|
+
|
|
|
# 返回结果
|
|
|
return {
|
|
|
"code": 200,
|
|
@@ -466,6 +476,68 @@ def template_list(db: Session = Depends(get_db)):
|
|
|
"total": len(data)
|
|
|
}
|
|
|
|
|
|
+ except Exception as e:
|
|
|
+ # 处理异常
|
|
|
+ traceback.print_exc()
|
|
|
+ raise HTTPException(status_code=500, detail=str(e))
|
|
|
+
|
|
|
+
|
|
|
+# 提交审批
|
|
|
+@router.post("/submit_examine")
|
|
|
+async def submit_examine(
|
|
|
+ db: Session = Depends(get_db),
|
|
|
+ body = Depends(remove_xss_json),
|
|
|
+ user_id = Depends(valid_access_token)
|
|
|
+):
|
|
|
+ try:
|
|
|
+ user_row = db.query(SysUser).filter(SysUser.user_id == user_id).first()
|
|
|
+
|
|
|
+ info_id = body['info_id']
|
|
|
+ examine_type = body['examine_type']
|
|
|
+ content = body['content']
|
|
|
+
|
|
|
+ # 审批通过
|
|
|
+ if examine_type == 'approved':
|
|
|
+ new_examine = InfoPublishExamine(
|
|
|
+ publish_id = info_id,
|
|
|
+ examine_type = 20,
|
|
|
+ examine_sub_type = 21,
|
|
|
+ content = content,
|
|
|
+ examine_time = datetime.now(),
|
|
|
+ user_id = user_id,
|
|
|
+ user_name = user_row.user_name,
|
|
|
+ nick_name = user_row.nick_name
|
|
|
+ )
|
|
|
+ db.add(new_examine)
|
|
|
+ db.commit()
|
|
|
+
|
|
|
+ db.query(InfoPublishBase).filter(InfoPublishBase.id == info_id).update({"publish_status": 3, "examine_status": 2})
|
|
|
+ db.commit()
|
|
|
+
|
|
|
+ # 审批不通过
|
|
|
+ elif examine_type == 'rejected':
|
|
|
+
|
|
|
+ new_examine = InfoPublishExamine(
|
|
|
+ publish_id = info_id,
|
|
|
+ examine_type = 20,
|
|
|
+ examine_sub_type = 22,
|
|
|
+ content = content,
|
|
|
+ examine_time = datetime.now(),
|
|
|
+ user_id = user_id,
|
|
|
+ user_name = user_row.user_name,
|
|
|
+ nick_name = user_row.nick_name
|
|
|
+ )
|
|
|
+ db.add(new_examine)
|
|
|
+ db.commit()
|
|
|
+
|
|
|
+ db.query(InfoPublishBase).filter(InfoPublishBase.id == info_id).update({"publish_status": 0, "examine_status": 0})
|
|
|
+ db.commit()
|
|
|
+
|
|
|
+ return {
|
|
|
+ "code": 200,
|
|
|
+ "msg": "审批成功"
|
|
|
+ }
|
|
|
+
|
|
|
except Exception as e:
|
|
|
# 处理异常
|
|
|
traceback.print_exc()
|