|
@@ -242,6 +242,7 @@ async def update_task_status(
|
|
|
processing_status = get_req_param(body, 'processing_status')
|
|
|
feedback_content = get_req_param_optional(body, 'feedback_content')
|
|
|
work_station = get_req_param_optional(body, 'work_station')
|
|
|
+ address = get_req_param_optional(body, 'address')
|
|
|
|
|
|
attachList = None
|
|
|
if 'fileList'in body:
|
|
@@ -250,8 +251,12 @@ async def update_task_status(
|
|
|
|
|
|
longitude = latitude = None
|
|
|
if 'lnglat' in body:
|
|
|
- longitude = body['lnglat'][0]
|
|
|
- latitude = body['lnglat'][1]
|
|
|
+ if len(body['lnglat']) > 1:
|
|
|
+ longitude = body['lnglat'][0]
|
|
|
+ latitude = body['lnglat'][1]
|
|
|
+ else:
|
|
|
+ longitude = latitude = 0
|
|
|
+
|
|
|
|
|
|
if not task_id_to_use:
|
|
|
return Response(content="Missing required parameter 'task_id'", status_code=400)
|
|
@@ -278,6 +283,7 @@ async def update_task_status(
|
|
|
recorded_by=user_id,
|
|
|
longitude = longitude,
|
|
|
latitude = latitude,
|
|
|
+ address = address,
|
|
|
work_station = work_station
|
|
|
)
|
|
|
db.add(new_feeback)
|
|
@@ -687,3 +693,87 @@ async def approval(
|
|
|
traceback.print_exc()
|
|
|
raise HTTPException(status_code=500, detail=str(e))
|
|
|
|
|
|
+
|
|
|
+# 手机工作台任务反馈查询
|
|
|
+@router.get('/feeback_by_mobile_station')
|
|
|
+async def feeback_by_mobile_station(
|
|
|
+ request: Request,
|
|
|
+ mobile_id: str,
|
|
|
+ event_code: str = Query(None, description="事件ID"),
|
|
|
+ db: Session = Depends(get_db),
|
|
|
+ user_id: int = Depends(valid_access_token),
|
|
|
+ pageNum: int = Query(1, gt=0, description="页码"),
|
|
|
+ pageSize: int = Query(10, gt=0, le=100, description="每页大小")):
|
|
|
+ try:
|
|
|
+
|
|
|
+ def get_img_list_by_task_id(task_id):
|
|
|
+ return db_task.get_image_file_list(db, task_id)
|
|
|
+
|
|
|
+ def get_file_list_by_task_id(task_id):
|
|
|
+ task_file_list = db_task.get_task_file_list(db, task_id)
|
|
|
+ task_feeback_file_list = db_task.get_task_feeback_file_list(db, task_id)
|
|
|
+ return task_file_list + task_feeback_file_list
|
|
|
+
|
|
|
+ missing_event_code = db.query(EventBase).filter(EventBase.event_code == event_code).first()
|
|
|
+ # print(missing_event_code)
|
|
|
+ if not missing_event_code:
|
|
|
+ return {
|
|
|
+ "code": 500,
|
|
|
+ "msg": "事件不存在"
|
|
|
+ }
|
|
|
+
|
|
|
+ # 匹配所有事件相关任务
|
|
|
+ data_query = db.query(TaskRegistration, TaskFeeback).join(TaskFeeback, TaskRegistration.task_id == TaskFeeback.task_id)
|
|
|
+ data_query = data_query.filter(TaskRegistration.del_flag != '2').filter(TaskRegistration.event_code == event_code).filter(TaskFeeback.feeback_type == '0')
|
|
|
+ data_query = data_query.filter(TaskFeeback.work_station == mobile_id)
|
|
|
+
|
|
|
+ total_count = data_query.count()
|
|
|
+ offset = (pageNum - 1) * pageSize
|
|
|
+ data_query = data_query.offset(offset).limit(pageSize)
|
|
|
+
|
|
|
+ rows = data_query.all()
|
|
|
+ data = []
|
|
|
+ for register, feeback in rows:
|
|
|
+ print('register.task_id', register.task_id)
|
|
|
+ info = {
|
|
|
+ "task_id": register.task_id,
|
|
|
+ "unit_name": register.unit_name,
|
|
|
+ "task_description": register.task_description,
|
|
|
+ "registrar": register.registrar,
|
|
|
+ "executor": register.executor,
|
|
|
+ "content": feeback.content,
|
|
|
+ "update_time": feeback.create_time,
|
|
|
+ "address": feeback.address,
|
|
|
+ "longitude": feeback.longitude,
|
|
|
+ "latitude": feeback.latitude,
|
|
|
+ 'imgList': get_img_list_by_task_id(register.task_id),
|
|
|
+ 'fileList': get_file_list_by_task_id(register.task_id),
|
|
|
+ "img_name": "",
|
|
|
+ "img_url": "",
|
|
|
+ "file_name": "",
|
|
|
+ "file_url": "",
|
|
|
+ }
|
|
|
+
|
|
|
+ if len(info['imgList']) > 0:
|
|
|
+ n = len(info['imgList']) - 1
|
|
|
+ info['img_name'] = info['imgList'][n]['name']
|
|
|
+ info['img_url'] = info['imgList'][n]['url']
|
|
|
+
|
|
|
+ if len(info['fileList']) > 0:
|
|
|
+ n = len(info['fileList']) - 1
|
|
|
+ info['file_name'] = info['fileList'][n]['name']
|
|
|
+ info['file_url'] = info['fileList'][n]['url']
|
|
|
+
|
|
|
+ data.append(info)
|
|
|
+
|
|
|
+ return {
|
|
|
+ "code": 200,
|
|
|
+ "msg": "任务查询成功",
|
|
|
+ "data": data,
|
|
|
+ "total": total_count
|
|
|
+ }
|
|
|
+
|
|
|
+ except Exception as e:
|
|
|
+ db.rollback()
|
|
|
+ traceback.print_exc()
|
|
|
+ raise HTTPException(status_code=500, detail=f"Internal server error: {str(e)}")
|