AI实验室后端
This commit is contained in:
@@ -149,6 +149,77 @@ def get_sentinel_record_list_db_page(
|
||||
return result, total
|
||||
|
||||
|
||||
def get_sentinel_record_by_id(record_id):
|
||||
if not record_id:
|
||||
return None
|
||||
|
||||
sql = """
|
||||
SELECT
|
||||
r.id,
|
||||
r.license_plate,
|
||||
r.vehicle_type,
|
||||
r.license_plate_image,
|
||||
r.vehicle_image,
|
||||
r.livestock_type,
|
||||
r.livestock_source,
|
||||
r.is_inspected,
|
||||
r.dept_id,
|
||||
sd.name AS dept_name,
|
||||
r.created_at,
|
||||
r.updated_at,
|
||||
r.remark
|
||||
FROM sentinel_records r
|
||||
LEFT JOIN sys_dept sd ON r.dept_id = sd.id
|
||||
WHERE r.id = %s;
|
||||
"""
|
||||
|
||||
with pg_pool.getConn() as conn:
|
||||
with conn.cursor() as cursor:
|
||||
cursor.execute(sql, [record_id])
|
||||
row = cursor.fetchone()
|
||||
|
||||
if not row:
|
||||
return None
|
||||
|
||||
(
|
||||
record_id,
|
||||
license_plate,
|
||||
vehicle_type,
|
||||
license_plate_image,
|
||||
vehicle_image,
|
||||
livestock_type,
|
||||
livestock_source,
|
||||
is_inspected,
|
||||
dept_id,
|
||||
dept_name,
|
||||
created_at,
|
||||
updated_at,
|
||||
remark,
|
||||
) = row
|
||||
|
||||
result = {
|
||||
"id": str(record_id),
|
||||
"license_plate": license_plate,
|
||||
"vehicle_type": vehicle_type,
|
||||
"license_plate_image": get_temp_url_dict(
|
||||
"sentinel", "license_plate", license_plate_image
|
||||
),
|
||||
"vehicle_image": get_temp_url_dict(
|
||||
"sentinel", "vehicle_image", vehicle_image
|
||||
),
|
||||
"livestock_type": livestock_type,
|
||||
"livestock_source": livestock_source,
|
||||
"is_inspected": 1 if is_inspected else 0,
|
||||
"dept_id": str(dept_id),
|
||||
"dept_name": dept_name,
|
||||
"created_at": format_datetime(created_at),
|
||||
"updated_at": format_datetime(updated_at),
|
||||
"remark": remark,
|
||||
}
|
||||
|
||||
return result
|
||||
|
||||
|
||||
def insert_sentinel_record(data: dict, dept_id) -> str:
|
||||
with pg_pool.getConn() as conn:
|
||||
with conn.cursor() as cursor:
|
||||
|
||||
Reference in New Issue
Block a user