|
@@ -27,6 +27,7 @@ from exceptions import AppException
|
|
|
from typing import List, Dict,Set
|
|
|
import openpyxl
|
|
|
from io import BytesIO
|
|
|
+from PIL import Image
|
|
|
|
|
|
router = APIRouter()
|
|
|
|
|
@@ -420,7 +421,17 @@ async def ack_all(
|
|
|
body = Depends(remove_xss_json),
|
|
|
user_id = Depends(valid_access_token)
|
|
|
):
|
|
|
- call_id = body['call_id']
|
|
|
+ call_id = get_req_param(body, 'call_id')
|
|
|
+ base64_data = get_req_param(body, "photo_data")
|
|
|
+
|
|
|
+ file_name = new_guid() + ".png"
|
|
|
+ file_path = f'/data/upload/mergefile/uploads/{file_name}'
|
|
|
+
|
|
|
+ base64_data = base64_data.replace("data:image/png;base64,", "")
|
|
|
+ binary_data = base64.b64decode(base64_data)
|
|
|
+ bytes_io = BytesIO(binary_data)
|
|
|
+ image = Image.open(bytes_io)
|
|
|
+ image.save(file_path)
|
|
|
|
|
|
base_row = db.query(OnlineRollCallBase).filter(OnlineRollCallBase.id == call_id).first()
|
|
|
if base_row is None:
|
|
@@ -429,13 +440,30 @@ async def ack_all(
|
|
|
"msg": "点名记录不存在"
|
|
|
}
|
|
|
|
|
|
- detail_row = db.query(OnlineRollCallDetail).filter(and_(OnlineRollCallDetail.pid == call_id, OnlineRollCallDetail.leader_id == user_id)).first()
|
|
|
+ user_or_where = or_(OnlineRollCallDetail.leader_id == user_id, OnlineRollCallDetail.primary_staff_id == user_id, OnlineRollCallDetail.secondary_staff_id == user_id, OnlineRollCallDetail.standby_staff_id == user_id)
|
|
|
+ detail_row = db.query(OnlineRollCallDetail).filter(and_(OnlineRollCallDetail.pid == call_id, user_or_where)).first()
|
|
|
if detail_row is None:
|
|
|
return {
|
|
|
"code": 500,
|
|
|
"msg": "点名记录不存在!"
|
|
|
}
|
|
|
|
|
|
+ new_file = OnlineRollCallFile(
|
|
|
+ file_name=f"点名头像{user_id}.png",
|
|
|
+ storage_file_name=file_name,
|
|
|
+ file_path=f'/data/upload/mergefile/uploads/{file_name}',
|
|
|
+ file_size=os.path.getsize(f'/data/upload/mergefile/uploads/{file_name}'),
|
|
|
+ foreign_key=str(detail_row.id),
|
|
|
+ from_scenario="online_call_photo_file",
|
|
|
+ update_time=datetime.now(),
|
|
|
+ create_time=datetime.now(),
|
|
|
+ create_by=user_id,
|
|
|
+ create_dept=0,
|
|
|
+ del_flag='0',
|
|
|
+ status=0,
|
|
|
+ )
|
|
|
+ db.add(new_file)
|
|
|
+
|
|
|
detail_row.ack_status = 1 # 已应答
|
|
|
detail_row.ack_time = datetime.now()
|
|
|
db.commit()
|