|
|
@@ -812,6 +812,22 @@ async fn insert_spotcheck(client: &tokio_postgres::Client, info: &HySpotcheck) - |
|
|
|
} |
|
|
|
|
|
|
|
async fn insert_sample_delivery(client: &tokio_postgres::Client, info: &HySampleDelivery) -> Result<(), PgError> { |
|
|
|
|
|
|
|
// 先检查 ID 是否存在 |
|
|
|
let exists = client |
|
|
|
.query_one( |
|
|
|
"SELECT EXISTS(SELECT 1 FROM public.hy_sample_delivery WHERE id = $1)", |
|
|
|
&[&info.id], |
|
|
|
) |
|
|
|
.await? |
|
|
|
.get::<_, bool>(0); |
|
|
|
|
|
|
|
if exists { |
|
|
|
println!("ID {} 已存在,跳过插入", info.id); |
|
|
|
return Ok(()); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
client.execute( |
|
|
|
"INSERT INTO public.hy_sample_delivery ( |
|
|
|
id, sample_number, coal_sample, sample_weight, sampler_user, state, |
|
|
@@ -838,6 +854,21 @@ async fn insert_sample_delivery(client: &tokio_postgres::Client, info: &HySample |
|
|
|
} |
|
|
|
|
|
|
|
async fn insert_task(client: &tokio_postgres::Client, info: &HyTask) -> Result<(), PgError> { |
|
|
|
// 先检查 ID 是否存在 |
|
|
|
let exists = client |
|
|
|
.query_one( |
|
|
|
"SELECT EXISTS(SELECT 1 FROM public.hy_task WHERE id = $1)", |
|
|
|
&[&info.id], |
|
|
|
) |
|
|
|
.await? |
|
|
|
.get::<_, bool>(0); |
|
|
|
|
|
|
|
if exists { |
|
|
|
println!("ID {} 已存在,跳过插入", info.id); |
|
|
|
return Ok(()); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
client.execute( |
|
|
|
"INSERT INTO public.hy_task ( |
|
|
|
id, task_name, task_type, task_num, is_auto, task_time, state, |
|
|
|