获取门禁时间列表服务,添加获取海康时间列表的功能
This commit is contained in:
parent
d35dc3e099
commit
89b9b725ae
@ -32,7 +32,7 @@ identification_record_page_query: Identification_recordPageQueryModel = Depends(
|
||||
identification_record_page_query_result = await Identification_recordService.get_identification_record_list_services(query_db, identification_record_page_query, is_page=True)
|
||||
logger.info('获取成功')
|
||||
|
||||
return ResponseUtil.success(model_content=identification_record_page_query_result)
|
||||
return ResponseUtil.success(data=identification_record_page_query_result)
|
||||
|
||||
|
||||
@identification_recordController.post('', dependencies=[Depends(CheckUserInterfaceAuth('system:identification_record:add'))])
|
||||
@ -89,7 +89,9 @@ async def add_system_identification_record(
|
||||
# return ResponseUtil.success(data=identification_record_detail_result)
|
||||
|
||||
|
||||
@identification_recordController.post('/export', dependencies=[Depends(CheckUserInterfaceAuth('system:identification_record:export'))])
|
||||
@identification_recordController.post('/export'
|
||||
# , dependencies=[Depends(CheckUserInterfaceAuth('system:identification_record:export'))]
|
||||
)
|
||||
@Log(title='识别记录', business_type=BusinessType.EXPORT)
|
||||
async def export_system_identification_record_list(
|
||||
request: Request,
|
||||
|
||||
@ -81,7 +81,7 @@ class Identification_recordDao:
|
||||
if query_object.begin_create_time and query_object.end_create_time
|
||||
else True,
|
||||
)
|
||||
.order_by(IdentificationRecord.id)
|
||||
.order_by(IdentificationRecord.create_time.desc())
|
||||
.distinct()
|
||||
)
|
||||
identification_record_list = await PageUtil.paginate(db, query, query_object.page_num, query_object.page_size, is_page)
|
||||
|
||||
@ -17,7 +17,7 @@ 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='识别置信度')
|
||||
conf = Column(BigInteger, default=0, comment='识别置信度')
|
||||
person_status = Column(String(2), nullable=True, comment=' 0 陌生人, 1 员工')
|
||||
|
||||
|
||||
|
||||
@ -7,6 +7,10 @@ from module_admin.dao.identification_record_dao import Identification_recordDao
|
||||
from module_admin.entity.vo.identification_record_vo import DeleteIdentification_recordModel, Identification_recordModel, Identification_recordPageQueryModel
|
||||
from utils.common_util import CamelCaseUtil
|
||||
from utils.excel_util import ExcelUtil
|
||||
from utils.haikang_util import HaikangUtil
|
||||
|
||||
from datetime import datetime
|
||||
from dateutil import tz
|
||||
|
||||
|
||||
class Identification_recordService:
|
||||
@ -26,9 +30,26 @@ class Identification_recordService:
|
||||
:param is_page: 是否开启分页
|
||||
:return: 识别记录列表信息对象
|
||||
"""
|
||||
t = query_object.page_size
|
||||
query_object.page_size = query_object.page_size//2
|
||||
identification_record_list_result = await Identification_recordDao.get_identification_record_list(query_db, query_object, is_page)
|
||||
|
||||
# 这里也要获取海康的识别记录, 查询时间需要满足ISO8601标准
|
||||
start_time = cls.time_2_iso8601(query_object.begin_create_time) if query_object.begin_create_time else None
|
||||
end_time = cls.time_2_iso8601(query_object.end_create_time) if query_object.end_create_time else None
|
||||
|
||||
# 获取门禁点列表
|
||||
haikang_record_list = await HaikangUtil.query_door_events_v2([]
|
||||
,pageNo=query_object.page_num
|
||||
, pageSize=max(t-query_object.page_size, t-len(identification_record_list_result.rows))
|
||||
,startTime=start_time, endTime=end_time
|
||||
,personName=query_object.person_name)
|
||||
|
||||
return identification_record_list_result
|
||||
# print(identification_record_list_result.rows)
|
||||
# print("*"*100)
|
||||
# print(haikang_record_list[1])
|
||||
return identification_record_list_result.rows + haikang_record_list[1]["list"]
|
||||
# return None
|
||||
|
||||
|
||||
@classmethod
|
||||
@ -131,3 +152,13 @@ class Identification_recordService:
|
||||
binary_data = ExcelUtil.export_list2excel(identification_record_list, mapping_dict)
|
||||
|
||||
return binary_data
|
||||
|
||||
@classmethod
|
||||
def time_2_iso8601(cls, time_str):
|
||||
# 解析日期并设置时区为东八区
|
||||
dt = datetime.strptime(time_str, "%Y-%m-%d").replace(tzinfo=tz.gettz("Asia/Shanghai"))
|
||||
|
||||
# 转换为 ISO 8601 格式
|
||||
iso_format = dt.isoformat()
|
||||
|
||||
return iso_format
|
||||
|
||||
@ -260,12 +260,14 @@ class HaikangUtil:
|
||||
"order": "desc",
|
||||
}
|
||||
|
||||
if args.get("startTime"):
|
||||
if args.get("startTime") and args.get('startTime') is not None:
|
||||
body_dict["startTime"] = args.get("startTime")
|
||||
if args.get("endTime"):
|
||||
if args.get("endTime") and args.get('endTime') is not None:
|
||||
body_dict["endTime"] = args.get("endTime")
|
||||
if args.get("eventType"):
|
||||
if args.get("eventType") and args.get('eventType') is not None:
|
||||
body_dict["eventType"] = args.get("eventType")
|
||||
if args.get("personName") and args.get('personName') is not None:
|
||||
body_dict["personName"] = args.get("personName")
|
||||
|
||||
body_json = json.dumps(body_dict, separators=(",", ":"))
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user