|
@@ -27,6 +27,88 @@ from config import settings
|
|
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
+@router.post('/create')
|
|
|
+async def create_emergency_plan(
|
|
|
+ db: Session = Depends(get_db),
|
|
|
+ body = Depends(remove_xss_json),
|
|
|
+ user_id = Depends(valid_access_token)
|
|
|
+):
|
|
|
+ try:
|
|
|
+ dept_id = 0
|
|
|
+ dept_name = ''
|
|
|
+
|
|
|
+ user_row = db.query(SysUser).filter(SysUser.user_id == user_id).first()
|
|
|
+ dept_id = user_row.dept_id
|
|
|
+
|
|
|
+ dept_row = db.query(SysDept).filter(SysDept.dept_id == dept_id).first()
|
|
|
+ dept_name = dept_row.dept_name
|
|
|
+
|
|
|
+ new_publish = InfoPublishBase(
|
|
|
+ title = body['title'],
|
|
|
+ publish_group = body['publish_group'],
|
|
|
+ template_id = body['template_id'],
|
|
|
+ content = body['content'],
|
|
|
+ recorded_by = user_id,
|
|
|
+ del_flag = '0',
|
|
|
+ dept_id = dept_id,
|
|
|
+ dept_name = dept_name,
|
|
|
+ add_time = datetime.now(),
|
|
|
+ response_type = body['response_type'],
|
|
|
+ publish_time = body['publish_time'],
|
|
|
+ examine_by = body['examine_by'],
|
|
|
+ publish_status = 0,
|
|
|
+ examine_status = 0,
|
|
|
+ publish_channel = body['publish_channel'],
|
|
|
+ user_count = body['user_count'],
|
|
|
+ user_ok_count = 0,
|
|
|
+ user_err_count = 0,
|
|
|
+ user_sending_count = 0
|
|
|
+ )
|
|
|
+ db.add(new_publish)
|
|
|
+ db.commit()
|
|
|
+ db.refresh(new_publish)
|
|
|
+ new_publish_id = new_publish.id
|
|
|
+
|
|
|
+ # 发送人员
|
|
|
+ for u in body['users']:
|
|
|
+ user_id = u['user_id']
|
|
|
+
|
|
|
+ user_row = db.query(SysUser).filter(SysUser.user_id == user_id).first()
|
|
|
+ dept_id = user_row.dept_id
|
|
|
+
|
|
|
+ dept_row = db.query(SysDept).filter(SysDept.dept_id == dept_id).first()
|
|
|
+ dept_name = dept_row.dept_name
|
|
|
+
|
|
|
+ new_resp = InfoPublishResponses(
|
|
|
+ publish_id = new_publish_id,
|
|
|
+ user_id = user_id,
|
|
|
+ user_name = user_row.user_name,
|
|
|
+ nick_name = user_row.nick_name,
|
|
|
+ dept_name = dept_row.dept_name,
|
|
|
+ sent_time = 0,
|
|
|
+ response_type = body['response_type']
|
|
|
+ )
|
|
|
+ db.add(new_resp)
|
|
|
+ db.commit()
|
|
|
+
|
|
|
+ # 附件
|
|
|
+ if 'attachs' in body:
|
|
|
+ for n in body['attachs']:
|
|
|
+ pass
|
|
|
+
|
|
|
+ # 审批附件
|
|
|
+ if 'examine_attachs' in body:
|
|
|
+ for n in body['examine_attachs']:
|
|
|
+ pass
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ except Exception as e:
|
|
|
+ traceback.print_exc()
|
|
|
+ # 处理异常
|
|
|
+ raise HTTPException(status_code=500, detail=str(e))
|
|
|
+
|
|
|
+
|
|
|
@router.get('/list')
|
|
|
async def get_publish_list(
|
|
|
publish_group: str = Query('', description='发布单位'),
|