|
@@ -105,6 +105,7 @@ async def get_publish_list(
|
|
|
"publish_group": row.publish_group,
|
|
|
"content": row.content,
|
|
|
"publish_time": get_datetime_str(row.publish_time),
|
|
|
+ "add_time": row.add_time.strftime("%Y-%m-%d %H:%M"),
|
|
|
"publish_channel": row.publish_channel,
|
|
|
"nick_name": nick_name,
|
|
|
"dept_name": dept_name,
|
|
@@ -153,12 +154,29 @@ async def get_info_detail(
|
|
|
row = query.first()
|
|
|
if row is not None:
|
|
|
|
|
|
+ # 发布申请人
|
|
|
+ recorded_by = row.recorded_by
|
|
|
+
|
|
|
+ user_row = db.query(SysUser).filter(SysUser.user_id == recorded_by).first()
|
|
|
+ nick_name = ""
|
|
|
+ dept_name = ""
|
|
|
+
|
|
|
+ if user_row is not None:
|
|
|
+ nick_name = user_row.nick_name
|
|
|
+ dept_id = user_row.dept_id
|
|
|
+ dept_row = db.query(SysDept).filter(SysDept.dept_id == dept_id).first()
|
|
|
+ if dept_row is not None:
|
|
|
+ dept_name = dept_row.dept_name
|
|
|
+
|
|
|
response_row = db.query(InfoPublishResponses).filter(and_(InfoPublishResponses.publish_id == id, InfoPublishResponses.user_id == user_id)).first()
|
|
|
|
|
|
data = {
|
|
|
"id": row.id,
|
|
|
"title": row.title,
|
|
|
"info_type": row.info_type,
|
|
|
+ "add_time": row.add_time.strftime("%Y-%m-%d %H:%M"),
|
|
|
+ "nick_name": nick_name,
|
|
|
+ "dept_name": dept_name,
|
|
|
"publish_group": row.publish_group,
|
|
|
"content": row.content,
|
|
|
"publish_time": get_datetime_str(row.publish_time),
|
|
@@ -305,4 +323,121 @@ def get_signature_base64(db: Session, response_id: int):
|
|
|
if row is None:
|
|
|
return ""
|
|
|
|
|
|
- return "data:image/png;base64," + image2base64(row.file_path)
|
|
|
+ return "data:image/png;base64," + image2base64(row.file_path)
|
|
|
+
|
|
|
+# 我的工作审批
|
|
|
+@router.get("/work_approval/list")
|
|
|
+async def work_approval_list(
|
|
|
+ search_keyword: str = Query('', description='信息内容'),
|
|
|
+ status: str = Query('1', description='状态'),
|
|
|
+ info_type: str = Query(None, description='信息类型'),
|
|
|
+ time_type: str = Query(None, description='时间类型'),
|
|
|
+ info_order: str = Query("desc", description='时间排序'),
|
|
|
+ page: int = Query(1, gt=0, description='页码'),
|
|
|
+ page_size: int = Query(10, gt=0, description='pageSize'),
|
|
|
+ db: Session = Depends(get_db),
|
|
|
+ user_id = Depends(valid_access_token)
|
|
|
+):
|
|
|
+ try:
|
|
|
+ # 应用查询条件
|
|
|
+ where = and_(InfoPublishBase.del_flag == '0')
|
|
|
+
|
|
|
+ # 待办
|
|
|
+ if status == "1":
|
|
|
+ where = and_(where, InfoPublishBase.publish_status < 4)
|
|
|
+
|
|
|
+ # 已完成
|
|
|
+ if status == "2":
|
|
|
+ where = and_(where, InfoPublishBase.publish_status == 4)
|
|
|
+
|
|
|
+ if search_keyword != '':
|
|
|
+ where = and_(where, InfoPublishBase.content.like('%{}%'.format(search_keyword)))
|
|
|
+
|
|
|
+ if info_type != None:
|
|
|
+ where = and_(where, InfoPublishBase.info_type == info_type)
|
|
|
+ '''
|
|
|
+ if end_time_s != None:
|
|
|
+ end_time = datetime.strptime(end_time_s, "%Y-%m-%d") + timedelta(days=1)
|
|
|
+ where = and_(where, InfoPublishBase.publish_time < end_time)
|
|
|
+ print(where)
|
|
|
+ '''
|
|
|
+
|
|
|
+ subquery = db.query(InfoPublishResponses.publish_id).filter(InfoPublishResponses.user_id == user_id).subquery()
|
|
|
+
|
|
|
+ # 计算总条目数
|
|
|
+ q = db.query(func.count(InfoPublishBase.id))
|
|
|
+ q = q.filter(where).filter(InfoPublishBase.id == subquery.c.publish_id)
|
|
|
+ total = q.scalar()
|
|
|
+
|
|
|
+ # 执行分页查询
|
|
|
+ q = db.query(InfoPublishBase)
|
|
|
+ q = q.filter(where).filter(InfoPublishBase.id == subquery.c.publish_id)
|
|
|
+
|
|
|
+ if info_order == 'desc':
|
|
|
+ q.order_by(InfoPublishBase.publish_time.desc())
|
|
|
+ if info_order == 'asc':
|
|
|
+ q.order_by(InfoPublishBase.publish_time.asc())
|
|
|
+
|
|
|
+ rows = q.offset((page - 1) * page_size).limit(page_size).all()
|
|
|
+
|
|
|
+ data = []
|
|
|
+ for row in rows:
|
|
|
+
|
|
|
+ # 发布申请人
|
|
|
+ recorded_by = row.recorded_by
|
|
|
+
|
|
|
+ user_row = db.query(SysUser).filter(SysUser.user_id == recorded_by).first()
|
|
|
+ nick_name = ""
|
|
|
+ dept_name = ""
|
|
|
+
|
|
|
+ if user_row is not None:
|
|
|
+ nick_name = user_row.nick_name
|
|
|
+ dept_id = user_row.dept_id
|
|
|
+ dept_row = db.query(SysDept).filter(SysDept.dept_id == dept_id).first()
|
|
|
+ if dept_row is not None:
|
|
|
+ dept_name = dept_row.dept_name
|
|
|
+
|
|
|
+ # 待处理人
|
|
|
+ examine_user = "无"
|
|
|
+ examine_by = row.examine_by
|
|
|
+ user_row = db.query(SysUser).filter(SysUser.user_id == examine_by).first()
|
|
|
+ if user_row is not None:
|
|
|
+ examine_user = user_row.nick_name
|
|
|
+
|
|
|
+ data.append({
|
|
|
+ "id": row.id,
|
|
|
+ "title": row.title,
|
|
|
+ "info_type": row.info_type,
|
|
|
+ "publish_group": row.publish_group,
|
|
|
+ "content": row.content,
|
|
|
+ "publish_time": get_datetime_str(row.publish_time),
|
|
|
+ "add_time": row.add_time.strftime("%Y-%m-%d %H:%M"),
|
|
|
+ "publish_channel": row.publish_channel,
|
|
|
+ "nick_name": nick_name,
|
|
|
+ "dept_name": dept_name,
|
|
|
+
|
|
|
+ "examine_user": examine_user,
|
|
|
+ "publish_status": db_dict.get_dict_label(db, "mm_publish_status", row.publish_status),
|
|
|
+ "examine_status": db_dict.get_dict_label(db, "mm_examine_status", row.examine_status),
|
|
|
+
|
|
|
+ "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,
|
|
|
+
|
|
|
+ "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 # 是否我的审批事项
|
|
|
+ })
|
|
|
+
|
|
|
+ # 返回结果
|
|
|
+ return {
|
|
|
+ "code": 200,
|
|
|
+ "msg": "查询成功",
|
|
|
+ "data": data,
|
|
|
+ "total": total
|
|
|
+ }
|
|
|
+
|
|
|
+ except Exception as e:
|
|
|
+ # 处理异常
|
|
|
+ traceback.print_exc()
|
|
|
+ raise HTTPException(status_code=500, detail=str(e))
|