识别记录表添加新的属性
This commit is contained in:
parent
2687b73dfe
commit
d35dc3e099
@ -52,41 +52,41 @@ async def add_system_identification_record(
|
||||
return ResponseUtil.success(msg=add_identification_record_result.message)
|
||||
|
||||
|
||||
@identification_recordController.put('', dependencies=[Depends(CheckUserInterfaceAuth('system:identification_record:edit'))])
|
||||
@ValidateFields(validate_model='edit_identification_record')
|
||||
@Log(title='识别记录', business_type=BusinessType.UPDATE)
|
||||
async def edit_system_identification_record(
|
||||
request: Request,
|
||||
edit_identification_record: Identification_recordModel,
|
||||
query_db: AsyncSession = Depends(get_db),
|
||||
current_user: CurrentUserModel = Depends(LoginService.get_current_user),
|
||||
):
|
||||
edit_identification_record.update_by = current_user.user.user_name
|
||||
edit_identification_record.update_time = datetime.now()
|
||||
edit_identification_record_result = await Identification_recordService.edit_identification_record_services(query_db, edit_identification_record)
|
||||
logger.info(edit_identification_record_result.message)
|
||||
# @identification_recordController.put('', dependencies=[Depends(CheckUserInterfaceAuth('system:identification_record:edit'))])
|
||||
# @ValidateFields(validate_model='edit_identification_record')
|
||||
# @Log(title='识别记录', business_type=BusinessType.UPDATE)
|
||||
# async def edit_system_identification_record(
|
||||
# request: Request,
|
||||
# edit_identification_record: Identification_recordModel,
|
||||
# query_db: AsyncSession = Depends(get_db),
|
||||
# current_user: CurrentUserModel = Depends(LoginService.get_current_user),
|
||||
# ):
|
||||
# edit_identification_record.update_by = current_user.user.user_name
|
||||
# edit_identification_record.update_time = datetime.now()
|
||||
# edit_identification_record_result = await Identification_recordService.edit_identification_record_services(query_db, edit_identification_record)
|
||||
# logger.info(edit_identification_record_result.message)
|
||||
|
||||
return ResponseUtil.success(msg=edit_identification_record_result.message)
|
||||
# return ResponseUtil.success(msg=edit_identification_record_result.message)
|
||||
|
||||
|
||||
@identification_recordController.delete('/{ids}', dependencies=[Depends(CheckUserInterfaceAuth('system:identification_record:remove'))])
|
||||
@Log(title='识别记录', business_type=BusinessType.DELETE)
|
||||
async def delete_system_identification_record(request: Request, ids: str, query_db: AsyncSession = Depends(get_db)):
|
||||
delete_identification_record = DeleteIdentification_recordModel(ids=ids)
|
||||
delete_identification_record_result = await Identification_recordService.delete_identification_record_services(query_db, delete_identification_record)
|
||||
logger.info(delete_identification_record_result.message)
|
||||
# @identification_recordController.delete('/{ids}', dependencies=[Depends(CheckUserInterfaceAuth('system:identification_record:remove'))])
|
||||
# @Log(title='识别记录', business_type=BusinessType.DELETE)
|
||||
# async def delete_system_identification_record(request: Request, ids: str, query_db: AsyncSession = Depends(get_db)):
|
||||
# delete_identification_record = DeleteIdentification_recordModel(ids=ids)
|
||||
# delete_identification_record_result = await Identification_recordService.delete_identification_record_services(query_db, delete_identification_record)
|
||||
# logger.info(delete_identification_record_result.message)
|
||||
|
||||
return ResponseUtil.success(msg=delete_identification_record_result.message)
|
||||
# return ResponseUtil.success(msg=delete_identification_record_result.message)
|
||||
|
||||
|
||||
@identification_recordController.get(
|
||||
'/{id}', response_model=Identification_recordModel, dependencies=[Depends(CheckUserInterfaceAuth('system:identification_record:query'))]
|
||||
)
|
||||
async def query_detail_system_identification_record(request: Request, id: int, query_db: AsyncSession = Depends(get_db)):
|
||||
identification_record_detail_result = await Identification_recordService.identification_record_detail_services(query_db, id)
|
||||
logger.info(f'获取id为{id}的信息成功')
|
||||
# @identification_recordController.get(
|
||||
# '/{id}', response_model=Identification_recordModel, dependencies=[Depends(CheckUserInterfaceAuth('system:identification_record:query'))]
|
||||
# )
|
||||
# async def query_detail_system_identification_record(request: Request, id: int, query_db: AsyncSession = Depends(get_db)):
|
||||
# identification_record_detail_result = await Identification_recordService.identification_record_detail_services(query_db, id)
|
||||
# logger.info(f'获取id为{id}的信息成功')
|
||||
|
||||
return ResponseUtil.success(data=identification_record_detail_result)
|
||||
# return ResponseUtil.success(data=identification_record_detail_result)
|
||||
|
||||
|
||||
@identification_recordController.post('/export', dependencies=[Depends(CheckUserInterfaceAuth('system:identification_record:export'))])
|
||||
|
||||
@ -1,112 +0,0 @@
|
||||
"""已启用
|
||||
"""
|
||||
|
||||
|
||||
# from datetime import datetime
|
||||
# from fastapi import APIRouter, Depends, Form, Request
|
||||
# from pydantic_validation_decorator import ValidateFields
|
||||
# from sqlalchemy.ext.asyncio import AsyncSession
|
||||
# from config.enums import BusinessType
|
||||
# from config.get_db import get_db
|
||||
# from module_admin.annotation.log_annotation import Log
|
||||
# from module_admin.aspect.interface_auth import CheckUserInterfaceAuth
|
||||
# from module_admin.entity.vo.user_vo import CurrentUserModel
|
||||
# from module_admin.service.login_service import LoginService
|
||||
# from module_admin.service.identify_record_service import Identify_recordService
|
||||
# from module_admin.entity.vo.identify_record_vo import DeleteIdentify_recordModel, Identify_recordModel, Identify_recordPageQueryModel
|
||||
# from utils.common_util import bytes2file_response
|
||||
# from utils.log_util import logger
|
||||
# from utils.page_util import PageResponseModel
|
||||
# from utils.response_util import ResponseUtil
|
||||
|
||||
|
||||
# identify_recordController = APIRouter(prefix='/system/identify_record', dependencies=[Depends(LoginService.get_current_user)])
|
||||
|
||||
|
||||
# @identify_recordController.get(
|
||||
# '/list', response_model=PageResponseModel
|
||||
# # , dependencies=[Depends(CheckUserInterfaceAuth('system:identify_record:list'))]
|
||||
# )
|
||||
# async def get_system_identify_record_list(
|
||||
# request: Request,
|
||||
# identify_record_page_query: Identify_recordPageQueryModel = Depends(Identify_recordPageQueryModel.as_query) ,
|
||||
# query_db: AsyncSession = Depends(get_db),
|
||||
# ):
|
||||
# # 获取分页数据
|
||||
# identify_record_page_query_result = await Identify_recordService.get_identify_record_list_services(query_db, identify_record_page_query, is_page=True)
|
||||
# logger.info('获取成功')
|
||||
|
||||
# return ResponseUtil.success(model_content=identify_record_page_query_result)
|
||||
|
||||
|
||||
# # @identify_recordController.post('', dependencies=[Depends(CheckUserInterfaceAuth('system:identify_record:add'))])
|
||||
# # @ValidateFields(validate_model='add_identify_record')
|
||||
# # @Log(title='识别记录', business_type=BusinessType.INSERT)
|
||||
# # async def add_system_identify_record(
|
||||
# # request: Request,
|
||||
# # add_identify_record: Identify_recordModel,
|
||||
# # query_db: AsyncSession = Depends(get_db),
|
||||
# # current_user: CurrentUserModel = Depends(LoginService.get_current_user),
|
||||
# # ):
|
||||
# # add_identify_record.create_time = datetime.now()
|
||||
# # add_identify_record_result = await Identify_recordService.add_identify_record_services(query_db, add_identify_record)
|
||||
# # logger.info(add_identify_record_result.message)
|
||||
# #
|
||||
# # return ResponseUtil.success(msg=add_identify_record_result.message)
|
||||
|
||||
|
||||
# # @identify_recordController.put('', dependencies=[Depends(CheckUserInterfaceAuth('system:identify_record:edit'))])
|
||||
# # @ValidateFields(validate_model='edit_identify_record')
|
||||
# # @Log(title='识别记录', business_type=BusinessType.UPDATE)
|
||||
# # async def edit_system_identify_record(
|
||||
# # request: Request,
|
||||
# # edit_identify_record: Identify_recordModel,
|
||||
# # query_db: AsyncSession = Depends(get_db),
|
||||
# # current_user: CurrentUserModel = Depends(LoginService.get_current_user),
|
||||
# # ):
|
||||
# # edit_identify_record.update_by = current_user.user.user_name
|
||||
# # edit_identify_record.update_time = datetime.now()
|
||||
# # edit_identify_record_result = await Identify_recordService.edit_identify_record_services(query_db, edit_identify_record)
|
||||
# # logger.info(edit_identify_record_result.message)
|
||||
# #
|
||||
# # return ResponseUtil.success(msg=edit_identify_record_result.message)
|
||||
|
||||
|
||||
# # @identify_recordController.delete('/{record_ids}', dependencies=[Depends(CheckUserInterfaceAuth('system:identify_record:remove'))])
|
||||
# # @Log(title='识别记录', business_type=BusinessType.DELETE)
|
||||
# # async def delete_system_identify_record(request: Request, record_ids: str, query_db: AsyncSession = Depends(get_db)):
|
||||
# # delete_identify_record = DeleteIdentify_recordModel(recordIds=record_ids)
|
||||
# # delete_identify_record_result = await Identify_recordService.delete_identify_record_services(query_db, delete_identify_record)
|
||||
# # logger.info(delete_identify_record_result.message)
|
||||
# #
|
||||
# # return ResponseUtil.success(msg=delete_identify_record_result.message)
|
||||
# #
|
||||
# #
|
||||
# # @identify_recordController.get(
|
||||
# # '/{record_id}', response_model=Identify_recordModel, dependencies=[Depends(CheckUserInterfaceAuth('system:identify_record:query'))]
|
||||
# # )
|
||||
# # async def query_detail_system_identify_record(request: Request, record_id: int, query_db: AsyncSession = Depends(get_db)):
|
||||
# # identify_record_detail_result = await Identify_recordService.identify_record_detail_services(query_db, record_id)
|
||||
# # logger.info(f'获取record_id为{record_id}的信息成功')
|
||||
# #
|
||||
# # return ResponseUtil.success(data=identify_record_detail_result)
|
||||
# #
|
||||
# #
|
||||
# @identify_recordController.post('/export'
|
||||
# # , dependencies=[Depends(CheckUserInterfaceAuth('system:identify_record:export'))]
|
||||
# )
|
||||
# @Log(title='识别记录', business_type=BusinessType.EXPORT)
|
||||
# async def export_system_identify_record_list(
|
||||
# request: Request,
|
||||
# identify_record_page_query: Identify_recordPageQueryModel = Form(),
|
||||
# query_db: AsyncSession = Depends(get_db),
|
||||
# ):
|
||||
# # 获取全量数据
|
||||
# # identify_record_query_result = await Identify_recordService.get_identify_record_list_services(query_db, identify_record_page_query, is_page=False)
|
||||
|
||||
# identify_record_query_result = await Identify_recordService.test_export_services(query_db)
|
||||
|
||||
# identify_record_export_result = await Identify_recordService.export_identify_record_list_services(identify_record_query_result)
|
||||
# logger.info('导出成功')
|
||||
|
||||
# return ResponseUtil.streaming(data=bytes2file_response(identify_record_export_result))
|
||||
@ -1,149 +0,0 @@
|
||||
from sqlalchemy import delete, select, update, or_, desc
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
from module_admin.entity.do.identify_record_do import IdentifyRecord
|
||||
from module_admin.entity.vo.identify_record_vo import Identify_recordModel, Identify_recordPageQueryModel
|
||||
from utils.page_util import PageUtil
|
||||
from datetime import datetime, time
|
||||
|
||||
|
||||
class Identify_recordDao:
|
||||
"""
|
||||
识别记录模块数据库操作层
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
async def test_export(cls, db: AsyncSession):
|
||||
return (
|
||||
await db.execute(
|
||||
select(IdentifyRecord)
|
||||
)
|
||||
).mappings().all()
|
||||
|
||||
@classmethod
|
||||
async def get_identify_record_detail_by_id(cls, db: AsyncSession, record_id: int):
|
||||
"""
|
||||
根据主键ID获取识别记录详细信息
|
||||
|
||||
:param db: orm对象
|
||||
:param record_id: 主键ID
|
||||
:return: 识别记录信息对象
|
||||
"""
|
||||
identify_record_info = (
|
||||
(
|
||||
await db.execute(
|
||||
select(IdentifyRecord)
|
||||
.where(
|
||||
IdentifyRecord.record_id == record_id
|
||||
)
|
||||
)
|
||||
)
|
||||
.scalars()
|
||||
.first()
|
||||
)
|
||||
|
||||
return identify_record_info
|
||||
|
||||
@classmethod
|
||||
async def get_identify_record_detail_by_info(cls, db: AsyncSession, identify_record: Identify_recordModel):
|
||||
"""
|
||||
根据识别记录参数获取识别记录信息
|
||||
|
||||
:param db: orm对象
|
||||
:param identify_record: 识别记录参数对象
|
||||
:return: 识别记录信息对象
|
||||
"""
|
||||
identify_record_info = (
|
||||
(
|
||||
await db.execute(
|
||||
select(IdentifyRecord).where(
|
||||
)
|
||||
)
|
||||
)
|
||||
.scalars()
|
||||
.first()
|
||||
)
|
||||
|
||||
return identify_record_info
|
||||
|
||||
@classmethod
|
||||
async def get_identify_record_list(cls, db: AsyncSession, query_object: Identify_recordPageQueryModel, is_page: bool = False):
|
||||
"""
|
||||
根据查询参数获取识别记录列表信息
|
||||
|
||||
:param db: orm对象
|
||||
:param query_object: 查询参数对象
|
||||
:param is_page: 是否开启分页
|
||||
:return: 识别记录列表信息对象
|
||||
"""
|
||||
query = (
|
||||
select(IdentifyRecord)
|
||||
.where(
|
||||
IdentifyRecord.create_time.between(
|
||||
datetime.combine(datetime.strptime(query_object.create_time, '%Y-%m-%d'), time(00, 00, 00)),
|
||||
datetime.combine(datetime.strptime(query_object.create_time, '%Y-%m-%d'), time(23, 59, 59)),
|
||||
)
|
||||
if query_object.create_time else True,
|
||||
# IdentifyRecord.name == query_object.name if query_object.name else True,
|
||||
# IdentifyRecord.position == query_object.position if query_object.position else True,
|
||||
# IdentifyRecord.result == query_object.result if query_object.result else True,
|
||||
IdentifyRecord.source == query_object.source if query_object.source else True,
|
||||
# IdentifyRecord.robot_id == query_object.robot_id if query_object.robot_id else True,
|
||||
)
|
||||
.where(
|
||||
or_(
|
||||
IdentifyRecord.name.like(f'%{query_object.keywords}%')
|
||||
if query_object.keywords
|
||||
else True,
|
||||
IdentifyRecord.position.like(f'%{query_object.keywords}%')
|
||||
if query_object.keywords
|
||||
else True,
|
||||
IdentifyRecord.source.like(f'%{query_object.keywords}%')
|
||||
if query_object.keywords
|
||||
else True,
|
||||
IdentifyRecord.result.like(f'%{query_object.keywords}%')
|
||||
)
|
||||
)
|
||||
.order_by(desc(IdentifyRecord.create_time))
|
||||
.distinct()
|
||||
)
|
||||
identify_record_list = await PageUtil.paginate(db, query, query_object.page_num, query_object.page_size, is_page)
|
||||
|
||||
return identify_record_list
|
||||
|
||||
@classmethod
|
||||
async def add_identify_record_dao(cls, db: AsyncSession, identify_record: Identify_recordModel):
|
||||
"""
|
||||
新增识别记录数据库操作
|
||||
|
||||
:param db: orm对象
|
||||
:param identify_record: 识别记录对象
|
||||
:return:
|
||||
"""
|
||||
db_identify_record = IdentifyRecord(**identify_record.model_dump(exclude={}))
|
||||
db.add(db_identify_record)
|
||||
await db.flush()
|
||||
|
||||
return db_identify_record
|
||||
|
||||
@classmethod
|
||||
async def edit_identify_record_dao(cls, db: AsyncSession, identify_record: dict):
|
||||
"""
|
||||
编辑识别记录数据库操作
|
||||
|
||||
:param db: orm对象
|
||||
:param identify_record: 需要更新的识别记录字典
|
||||
:return:
|
||||
"""
|
||||
await db.execute(update(IdentifyRecord), [identify_record])
|
||||
|
||||
@classmethod
|
||||
async def delete_identify_record_dao(cls, db: AsyncSession, identify_record: Identify_recordModel):
|
||||
"""
|
||||
删除识别记录数据库操作
|
||||
|
||||
:param db: orm对象
|
||||
:param identify_record: 识别记录对象
|
||||
:return:
|
||||
"""
|
||||
await db.execute(delete(IdentifyRecord).where(IdentifyRecord.record_id.in_([identify_record.record_id])))
|
||||
|
||||
@ -17,6 +17,8 @@ class IdentificationRecord(Base):
|
||||
pic_uri = Column(String(256), nullable=True, comment='图像url')
|
||||
create_time = Column(DateTime, nullable=True, comment='创建时间')
|
||||
create_by = Column(String(64), nullable=True, comment='创建者')
|
||||
conf = Column(int, default=0, comment='识别置信度')
|
||||
person_status = Column(String(2), nullable=True, comment=' 0 陌生人, 1 员工')
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,22 +0,0 @@
|
||||
from sqlalchemy import BigInteger, String, DateTime, Column
|
||||
from config.database import Base
|
||||
|
||||
|
||||
class IdentifyRecord(Base):
|
||||
"""
|
||||
识别记录表
|
||||
"""
|
||||
|
||||
__tablename__ = 'identify_record'
|
||||
|
||||
record_id = Column(BigInteger, primary_key=True, autoincrement=True, nullable=False, comment='主键ID')
|
||||
create_time = Column(DateTime, nullable=True, comment='识别时间')
|
||||
name = Column(String(32), nullable=True, comment='姓名')
|
||||
position = Column(String(32), nullable=True, comment='门禁点')
|
||||
result = Column(String(2), nullable=True, comment='识别结果(0拒绝,1通过)')
|
||||
source = Column(String(64), nullable=True, comment='识别来源')
|
||||
robot_id = Column(BigInteger, nullable=True, comment='机器人ID(关联robot_info表)')
|
||||
image = Column(String(512), nullable=True, comment='识别图片路径')
|
||||
|
||||
|
||||
|
||||
@ -21,6 +21,8 @@ class Identification_recordModel(BaseModel):
|
||||
pic_uri: Optional[str] = Field(default=None, description='图像url')
|
||||
create_time: Optional[datetime] = Field(default=None, description='创建时间')
|
||||
create_by: Optional[str] = Field(default=None, description='创建者')
|
||||
conf: Optional[int] = Field(default=None, description='识别置信度')
|
||||
person_status: Optional[str] = Field(default=None, description=' 0 陌生人, 1 员工')
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,62 +0,0 @@
|
||||
from datetime import datetime
|
||||
from pydantic import BaseModel, ConfigDict, Field
|
||||
from pydantic.alias_generators import to_camel
|
||||
from typing import Optional
|
||||
from module_admin.annotation.pydantic_annotation import as_query
|
||||
|
||||
|
||||
|
||||
|
||||
class Identify_recordModel(BaseModel):
|
||||
"""
|
||||
识别记录表对应pydantic模型
|
||||
"""
|
||||
model_config = ConfigDict(alias_generator=to_camel, from_attributes=True)
|
||||
|
||||
record_id: Optional[int] = Field(default=None, description='主键ID')
|
||||
create_time: Optional[datetime] = Field(default=None, description='识别时间')
|
||||
name: Optional[str] = Field(default=None, description='姓名')
|
||||
position: Optional[str] = Field(default=None, description='门禁点')
|
||||
result: Optional[str] = Field(default=None, description='识别结果(0拒绝,1通过)')
|
||||
source: Optional[str] = Field(default=None, description='识别来源')
|
||||
robot_id: Optional[int] = Field(default=None, description='机器人ID(关联robot_info表)')
|
||||
image: Optional[str] = Field(default=None, description='识别图片路径')
|
||||
|
||||
|
||||
class IdentifyRecordModelSearchModel(BaseModel):
|
||||
"""
|
||||
识别记录表查询模型
|
||||
"""
|
||||
model_config = ConfigDict(alias_generator=to_camel, from_attributes=True)
|
||||
create_time: Optional[str] = Field(default=None, description='识别时间')
|
||||
source: Optional[str] = Field(default=None, description='识别来源')
|
||||
keywords : Optional[str] = Field(default=None, description='识别关键词')
|
||||
|
||||
|
||||
|
||||
|
||||
class Identify_recordQueryModel(IdentifyRecordModelSearchModel):
|
||||
"""
|
||||
识别记录不分页查询模型
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
@as_query
|
||||
class Identify_recordPageQueryModel(Identify_recordQueryModel):
|
||||
"""
|
||||
识别记录分页查询模型
|
||||
"""
|
||||
|
||||
page_num: int = Field(default=1, description='当前页码')
|
||||
page_size: int = Field(default=10, description='每页记录数')
|
||||
|
||||
|
||||
class DeleteIdentify_recordModel(BaseModel):
|
||||
"""
|
||||
删除识别记录模型
|
||||
"""
|
||||
|
||||
model_config = ConfigDict(alias_generator=to_camel)
|
||||
|
||||
record_ids: str = Field(description='需要删除的主键ID')
|
||||
@ -1,139 +0,0 @@
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
from typing import List
|
||||
from config.constant import CommonConstant
|
||||
from exceptions.exception import ServiceException
|
||||
from module_admin.entity.vo.common_vo import CrudResponseModel
|
||||
from module_admin.dao.identify_record_dao import Identify_recordDao
|
||||
from module_admin.entity.vo.identify_record_vo import DeleteIdentify_recordModel, Identify_recordModel, Identify_recordPageQueryModel
|
||||
from utils.common_util import CamelCaseUtil
|
||||
from utils.excel_util import ExcelUtil
|
||||
|
||||
|
||||
class Identify_recordService:
|
||||
"""
|
||||
识别记录模块服务层
|
||||
"""
|
||||
|
||||
|
||||
# 测试方法
|
||||
@classmethod
|
||||
async def test_export_services(cls, query_db: AsyncSession):
|
||||
result = await Identify_recordDao.test_export(query_db)
|
||||
return result
|
||||
@classmethod
|
||||
async def get_identify_record_list_services(
|
||||
cls, query_db: AsyncSession, query_object: Identify_recordPageQueryModel, is_page: bool = False
|
||||
):
|
||||
"""
|
||||
获取识别记录列表信息service
|
||||
|
||||
:param query_db: orm对象
|
||||
:param query_object: 查询参数对象
|
||||
:param is_page: 是否开启分页
|
||||
:return: 识别记录列表信息对象
|
||||
"""
|
||||
identify_record_list_result = await Identify_recordDao.get_identify_record_list(query_db, query_object, is_page)
|
||||
|
||||
return identify_record_list_result
|
||||
|
||||
|
||||
@classmethod
|
||||
async def add_identify_record_services(cls, query_db: AsyncSession, page_object: Identify_recordModel):
|
||||
"""
|
||||
新增识别记录信息service
|
||||
|
||||
:param query_db: orm对象
|
||||
:param page_object: 新增识别记录对象
|
||||
:return: 新增识别记录校验结果
|
||||
"""
|
||||
try:
|
||||
await Identify_recordDao.add_identify_record_dao(query_db, page_object)
|
||||
await query_db.commit()
|
||||
return CrudResponseModel(is_success=True, message='新增成功')
|
||||
except Exception as e:
|
||||
await query_db.rollback()
|
||||
raise e
|
||||
|
||||
@classmethod
|
||||
async def edit_identify_record_services(cls, query_db: AsyncSession, page_object: Identify_recordModel):
|
||||
"""
|
||||
编辑识别记录信息service
|
||||
|
||||
:param query_db: orm对象
|
||||
:param page_object: 编辑识别记录对象
|
||||
:return: 编辑识别记录校验结果
|
||||
"""
|
||||
edit_identify_record = page_object.model_dump(exclude_unset=True, exclude={'create_time', })
|
||||
identify_record_info = await cls.identify_record_detail_services(query_db, page_object.record_id)
|
||||
if identify_record_info.record_id:
|
||||
try:
|
||||
await Identify_recordDao.edit_identify_record_dao(query_db, edit_identify_record)
|
||||
await query_db.commit()
|
||||
return CrudResponseModel(is_success=True, message='更新成功')
|
||||
except Exception as e:
|
||||
await query_db.rollback()
|
||||
raise e
|
||||
else:
|
||||
raise ServiceException(message='识别记录不存在')
|
||||
|
||||
@classmethod
|
||||
async def delete_identify_record_services(cls, query_db: AsyncSession, page_object: DeleteIdentify_recordModel):
|
||||
"""
|
||||
删除识别记录信息service
|
||||
|
||||
:param query_db: orm对象
|
||||
:param page_object: 删除识别记录对象
|
||||
:return: 删除识别记录校验结果
|
||||
"""
|
||||
if page_object.record_ids:
|
||||
record_id_list = page_object.record_ids.split(',')
|
||||
try:
|
||||
for record_id in record_id_list:
|
||||
await Identify_recordDao.delete_identify_record_dao(query_db, Identify_recordModel(recordId=record_id))
|
||||
await query_db.commit()
|
||||
return CrudResponseModel(is_success=True, message='删除成功')
|
||||
except Exception as e:
|
||||
await query_db.rollback()
|
||||
raise e
|
||||
else:
|
||||
raise ServiceException(message='传入主键ID为空')
|
||||
|
||||
@classmethod
|
||||
async def identify_record_detail_services(cls, query_db: AsyncSession, record_id: int):
|
||||
"""
|
||||
获取识别记录详细信息service
|
||||
|
||||
:param query_db: orm对象
|
||||
:param record_id: 主键ID
|
||||
:return: 主键ID对应的信息
|
||||
"""
|
||||
identify_record = await Identify_recordDao.get_identify_record_detail_by_id(query_db, record_id=record_id)
|
||||
if identify_record:
|
||||
result = Identify_recordModel(**CamelCaseUtil.transform_result(identify_record))
|
||||
else:
|
||||
result = Identify_recordModel(**dict())
|
||||
|
||||
return result
|
||||
|
||||
@staticmethod
|
||||
async def export_identify_record_list_services(identify_record_list: List):
|
||||
"""
|
||||
导出识别记录信息service
|
||||
|
||||
:param identify_record_list: 识别记录信息列表
|
||||
:return: 识别记录信息对应excel的二进制数据
|
||||
"""
|
||||
# 创建一个映射字典,将英文键映射到中文键
|
||||
mapping_dict = {
|
||||
'recordId': '主键ID',
|
||||
'createTime': '识别时间',
|
||||
'name': '姓名',
|
||||
'position': '门禁点',
|
||||
'result': '识别结果(0拒绝,1通过)',
|
||||
'source': '识别来源',
|
||||
'robotId': '机器人ID',
|
||||
'image': '识别图片路径',
|
||||
}
|
||||
binary_data = ExcelUtil.export_list2excel(identify_record_list, mapping_dict)
|
||||
|
||||
return binary_data
|
||||
@ -31,9 +31,10 @@ from module_admin.controller.robot_role_pairing_controller import pairingControl
|
||||
from module_admin.controller.explanation_content_controller import explanationContentController
|
||||
from module_admin.controller.explanation_style_robot_pair_controller import explanation_style_robot_pairController
|
||||
from module_admin.controller.sys_statistics_controller import sys_statisticsController
|
||||
from module_admin.controller.identify_record_controller import identify_recordController
|
||||
# from module_admin.controller.identify_record_controller import identify_recordController
|
||||
from module_admin.controller.ragflow_controller import ragflowController
|
||||
from module_admin.controller.robot_action_controller import robot_actionController
|
||||
from module_admin.controller.identification_record_controller import identification_recordController
|
||||
|
||||
from sub_applications.handle import handle_sub_applications
|
||||
from utils.common_util import worship
|
||||
@ -103,9 +104,10 @@ controller_list = [
|
||||
{'router': explanationContentController, 'tags': ['讲解管理']},
|
||||
{'router': explanation_style_robot_pairController, 'tags': ['讲解风格管理']},
|
||||
{'router': sys_statisticsController, 'tags': ['系统统计数据管理']},
|
||||
{'router': identify_recordController, 'tags': ['识别记录管理']},
|
||||
# {'router': identify_recordController, 'tags': ['识别记录管理']},
|
||||
{'router': ragflowController, 'tags': ['ragflow管理']},
|
||||
{'router': robot_actionController, 'tags': ['机器人动作管理']}
|
||||
{'router': robot_actionController, 'tags': ['机器人动作管理']},
|
||||
{'router': identification_recordController, 'tags': ['识别记录管理']}
|
||||
|
||||
]
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user