@@ -15,127 +15,13 @@ retry_delay_secs = 2 | |||||
[database] | [database] | ||||
host = "10.180.4.100" | host = "10.180.4.100" | ||||
port = 5432 | port = 5432 | ||||
name = "Auseft_new_web" | |||||
name = "Auseft_old" | |||||
user = "postgres" | user = "postgres" | ||||
password = "Auseft@2025qwer" | password = "Auseft@2025qwer" | ||||
# 要同步的表配置 | # 要同步的表配置 | ||||
[[tables]] | [[tables]] | ||||
name = "comm_bch_batch" | |||||
query = "SELECT id, tenant_id, supply_id, material_id, batch_record_id, sample_type, related_code, batching_start_time, batching_end_time, batching_start_ticket, batching_end_ticket, batching_quantity, batching_weight::text, batching_code, batching_code_creator, batching_code_creation_time, preparation_code, preparation_code_creator, preparation_code_creation_time, assay_code, assay_code_creator, assay_code_creation_time, creator_id, creation_time, last_modifier_id, last_modification_reason, last_modification_time, deleted, deleter_id, deletion_reason, deletion_time, source_type FROM comm_bch_batch" | |||||
incremental = false | |||||
key_field = "UpdateTime" | |||||
[[tables]] | |||||
name = "comm_bch_delivering_sampling" | |||||
query = "SELECT id, tenant_id, supply_id, material_id, sample_type, operation_type, business_type, delivering_type, delivering_code, delivering_quantity, delivering_unit, delivering_weight::text as delivering_weight, delivering_weights, delivering_remark, deliverer, delivery_time, sampling, sampling_type, sampling_code, sampling_quantity, sampling_unit, sampling_weight::text as sampling_weight, sampling_weights, sampling_remark, sampler, sample_time, creator_id, creation_time, last_modifier_id, last_modification_reason, last_modification_time, deleted, deleter_id, deletion_reason, deletion_time FROM comm_bch_delivering_sampling " | |||||
incremental = false | |||||
key_field = "UpdateTime" | |||||
[[tables]] | |||||
name = "comm_sp_delivering_sampling" | |||||
query = "SELECT id, tenant_id, supply_id, material_id, sample_type, bch_ds_id, operation_type, business_type, delivering_type, delivering_code, delivering_quantity, delivering_unit, delivering_weight::text as delivering_weight, delivering_weights, delivering_remark, deliverer, delivery_time, sampling, sampling_type, sampling_code, sampling_quantity, sampling_unit, sampling_weight::text as sampling_weight, sampling_weights, sampling_remark, sampler, sample_time, creator_id, creation_time, last_modifier_id, last_modification_reason, last_modification_time, deleted, deleter_id, deletion_reason, deletion_time FROM comm_sp_delivering_sampling " | |||||
incremental = false | |||||
key_field = "UpdateTime" | |||||
[[tables]] | |||||
name = "hy_record" | |||||
query = "SELECT id, hy_code, type, hy_check, hy_approve, check_time, approve_time, approve_user, check_user, hy_time, hy_values, accept_time, accept_user, mt::text as mt, mad::text as mad, aad::text as aad, ad::text as ad, vad::text as vad, vd::text as vd, var::text as var, vdaf::text as vdaf, fcad::text as fcad, st_ar::text as st_ar, st_ad::text as st_ad, st_d::text as st_d, had::text as had, hd::text as hd, qb_ad::text as qb_ad, qgr_ad::text as qgr_ad, qgr_d::text as qgr_d, qnet_ar_mj_kg::text as qnet_ar_mj_kg, qnet_ar_j_cal::text as qnet_ar_j_cal, v::text as v, aar::text as aar, qnet_ar::text as qnet_ar, qnet_ar1::text as qnet_ar1, crc::text as crc, st_daf::text as st_daf, cad ::text as cad, cd::text as cd, isauto, hy_type, isnormal FROM hy_record where hy_approve=0 and accept_time >= NOW() - INTERVAL '10 days' " | |||||
incremental = false | |||||
key_field = "UpdateTime" | |||||
[[tables]] | |||||
name = "hy_itemdetail" | |||||
query = "SELECT * FROM hy_itemdetail where record_id in (select id from hy_record where hy_approve=0 and accept_time >= NOW() - INTERVAL '10 days') " | |||||
incremental = false | |||||
key_field = "UpdateTime" | |||||
[[tables]] | |||||
name = "hy_norm" | |||||
query = " select id,norm_id,zbvalues::text as zbvalues,itemdetail_id,hy_user,checktime,\"explain\" from hy_norm where itemdetail_id in (SELECT t1.id FROM hy_itemdetail t1 inner join hy_record t2 on t1.record_id=t2.id where t2.hy_approve=0 and t2.accept_time >= NOW() - INTERVAL '10 days')" | |||||
incremental = false | |||||
key_field = "UpdateTime" | |||||
[[tables]] | |||||
name = "hy_instrument" | |||||
query = "SELECT * FROM \"hy_instrument\"" | |||||
incremental = false | |||||
key_field = "UpdateTime" | |||||
[[tables]] | |||||
name = "hy_information" | |||||
query = "SELECT * FROM \"hy_information\"" | |||||
incremental = false | |||||
key_field = "UpdateTime" | |||||
[[tables]] | |||||
name = "hy_allot" | |||||
query = "SELECT * FROM \"hy_allot\"" | |||||
incremental = false | |||||
key_field = "UpdateTime" | |||||
[[tables]] | |||||
name = "hy_cytask" | |||||
query = "SELECT * FROM \"hy_cytask\"" | |||||
incremental = false | |||||
key_field = "UpdateTime" | |||||
[[tables]] | |||||
name = "hy_fullwatersample" | |||||
query = "select id,qs_code,qs_tonnage::text as qs_tonnage,mt::text as mt,remark,onecode,towcode,fx_code,fx_onecode,fx_twocode from hy_fullwatersample" | |||||
incremental = false | |||||
key_field = "UpdateTime" | |||||
[[tables]] | |||||
name = "hy_informationnorm" | |||||
query = "SELECT * FROM \"hy_informationnorm\"" | |||||
incremental = false | |||||
key_field = "UpdateTime" | |||||
[[tables]] | |||||
name = "hy_laboratoryinstrument" | |||||
query = "SELECT * FROM \"hy_laboratoryinstrument\"" | |||||
incremental = false | |||||
key_field = "UpdateTime" | |||||
[[tables]] | |||||
name = "hy_materialanalysis_type" | |||||
query = "SELECT * FROM \"hy_materialanalysis_type\"" | |||||
incremental = false | |||||
key_field = "UpdateTime" | |||||
[[tables]] | |||||
name = "hy_materialdetail" | |||||
query = "SELECT * FROM \"hy_materialdetail\"" | |||||
incremental = false | |||||
key_field = "UpdateTime" | |||||
[[tables]] | |||||
name = "hy_weight_input" | |||||
query = "SELECT * FROM \"hy_weight_input\"" | |||||
incremental = false | |||||
key_field = "UpdateTime" | |||||
[[tables]] | |||||
name = "hy_warmhumid" | |||||
query = "select id,laboratoryid,temperature::text as temperature,humidity::text humidity,begintime,endtime, username from hy_warmhumid" | |||||
name = "comm_bm_vehicleinfo" | |||||
query = "SELECT id, licenseplate, type, grosswt::text as grosswt, tarewt::text as tarewt, owner, dl, supervision, outage, insurancedate, insurancenum, lock, transcompany, createdby, creationtime, modifiedby, modifiedtime, reviewed, reviewedby, reviewedtime, remarks, phonenumber, electronicnumber, rfidmodifiedtime, rfidstop, rfidstopby, rfidstoptime, rfidgrantby, rfidgranttime, samplingpoints, drawbar, carriagelength::text as carriagelength , carriagewidth::text as carriagewidth, carriageheight::text as carriageheight, underbodyheight::text as underbodyheight, frontsampling, backsampling, rod1::text as rod1, rod2::text as rod2, rod3::text as rod3, rod4::text as rod4, rod5::text as rod5, rod6::text as rod6, supplier_id, supplier_name, material_id, material_name FROM public.comm_bm_vehicleinfo" | |||||
incremental = false | incremental = false | ||||
key_field = "UpdateTime" | key_field = "UpdateTime" |
@@ -464,6 +464,63 @@ struct HyWeightInput { | |||||
information_norm_id: i32 | information_norm_id: i32 | ||||
} | } | ||||
#[derive(Debug, Deserialize)] | |||||
struct CommBmVehicleinfo { | |||||
id: i32, | |||||
licenseplate: Option<String>, | |||||
r#type: Option<String>, | |||||
grosswt: Option<Decimal>, | |||||
tarewt: Option<Decimal>, | |||||
owner: Option<String>, | |||||
dl: Option<String>, | |||||
#[serde(deserialize_with = "deserialize_string_to_bool")] | |||||
supervision: bool, | |||||
#[serde(deserialize_with = "deserialize_string_to_bool")] | |||||
outage: bool, | |||||
insurancedate: Option<NaiveDateTime>, | |||||
insurancenum: Option<String>, | |||||
#[serde(deserialize_with = "deserialize_string_to_bool")] | |||||
lock: bool, | |||||
transcompany: Option<i32>, | |||||
createdby: Option<String>, | |||||
creationtime: Option<NaiveDate>, | |||||
modifiedby: Option<String>, | |||||
modifiedtime: Option<NaiveDate>, | |||||
#[serde(deserialize_with = "deserialize_string_to_bool")] | |||||
reviewed: bool, | |||||
reviewedby: Option<String>, | |||||
reviewedtime: Option<NaiveDateTime>, | |||||
remarks: Option<String>, | |||||
phonenumber: Option<String>, | |||||
electronicnumber: Option<String>, | |||||
rfidmodified_by: Option<String>, | |||||
rfidmodifiedtime: Option<NaiveDateTime>, | |||||
#[serde(deserialize_with = "deserialize_string_to_bool")] | |||||
rfidstop: bool, | |||||
rfidstopby: Option<String>, | |||||
rfidstoptime: Option<NaiveDateTime>, | |||||
rfidgrantby: Option<String>, | |||||
rfidgranttime: Option<NaiveDate>, | |||||
samplingpoints: Option<i32>, | |||||
drawbar: Option<i32>, | |||||
carriagelength: Option<Decimal>, | |||||
carriagewidth: Option<Decimal>, | |||||
carriageheight: Option<Decimal>, | |||||
underbodyheight: Option<Decimal>, | |||||
frontsampling: Option<i32>, | |||||
backsampling: Option<i32>, | |||||
rod1: Option<Decimal>, | |||||
rod2: Option<Decimal>, | |||||
rod3: Option<Decimal>, | |||||
rod4: Option<Decimal>, | |||||
rod5: Option<Decimal>, | |||||
rod6: Option<Decimal>, | |||||
supplier_id: Option<i32>, | |||||
supplier_name: Option<String>, | |||||
material_id: Option<i32>, | |||||
material_name: Option<String>, | |||||
} | |||||
#[derive(Debug, Deserialize)] | #[derive(Debug, Deserialize)] | ||||
struct HySpotcheck { | struct HySpotcheck { | ||||
id: i32, | id: i32, | ||||
@@ -649,6 +706,84 @@ async fn insert_instrument(client: &tokio_postgres::Client, info: &InstrumentInf | |||||
Ok(()) | Ok(()) | ||||
} | } | ||||
async fn insert_vehicle_info(client: &tokio_postgres::Client, info: &CommBmVehicleinfo) -> Result<(), PgError> { | |||||
let exists = client | |||||
.query_one( | |||||
"SELECT EXISTS(SELECT 1 FROM public.comm_bm_vehicleinfo WHERE id = $1)", | |||||
&[&info.id], | |||||
) | |||||
.await? | |||||
.get::<_, bool>(0); | |||||
if exists { | |||||
// 如果记录存在,执行更新操作 | |||||
client.execute( | |||||
"UPDATE public.comm_bm_vehicleinfo | |||||
SET licenseplate = $2, type = $3, grosswt = $4, tarewt = $5, | |||||
owner = $6, dl = $7, supervision = $8, outage = $9, insurancedate = $10, | |||||
insurancenum = $11, lock = $12, transcompany = $13, createdby = $14, | |||||
creationtime = $15, modifiedby = $16, modifiedtime = $17, reviewed = $18, | |||||
reviewedby = $19, reviewedtime = $20, remarks = $21, phonenumber = $22, | |||||
electronicnumber = $23, material_name = $24, rfidmodifiedtime = $25, | |||||
rfidstop = $26, rfidstopby = $27, rfidstoptime = $28, rfidgrantby = $29, | |||||
rfidgranttime = $30, samplingpoints = $31, drawbar = $32, carriagelength = $33, | |||||
carriagewidth = $34, carriageheight = $35, underbodyheight = $36, | |||||
frontsampling = $37, backsampling = $38, rod1 = $39, rod2 = $40, rod3 = $41, | |||||
rod4 = $42, rod5 = $43, rod6 = $44, supplier_id = $45, supplier_name = $46, | |||||
material_id = $47 | |||||
WHERE id = $1", | |||||
&[ | |||||
&info.id, &info.licenseplate, &info.r#type, &info.grosswt, &info.tarewt, | |||||
&info.owner, &info.dl, &info.supervision, &info.outage, &info.insurancedate, | |||||
&info.insurancenum, &info.lock, &info.transcompany, &info.createdby, | |||||
&info.creationtime, &info.modifiedby, &info.modifiedtime, &info.reviewed, | |||||
&info.reviewedby, &info.reviewedtime, &info.remarks, &info.phonenumber, | |||||
&info.electronicnumber, &info.material_name, &info.rfidmodifiedtime, | |||||
&info.rfidstop, &info.rfidstopby, &info.rfidstoptime, &info.rfidgrantby, | |||||
&info.rfidgranttime, &info.samplingpoints, &info.drawbar, &info.carriagelength, | |||||
&info.carriagewidth, &info.carriageheight, &info.underbodyheight, | |||||
&info.frontsampling, &info.backsampling, &info.rod1, &info.rod2, &info.rod3, | |||||
&info.rod4, &info.rod5, &info.rod6, &info.supplier_id, &info.supplier_name, | |||||
&info.material_id | |||||
], | |||||
).await?; | |||||
} else { | |||||
// 如果记录不存在,执行插入操作 | |||||
client.execute( | |||||
"INSERT INTO public.comm_bm_vehicleinfo ( | |||||
id, licenseplate, type, grosswt, tarewt, owner, dl, | |||||
supervision, outage, insurancedate, insurancenum, lock, transcompany, | |||||
createdby, creationtime, modifiedby, modifiedtime, reviewed, reviewedby, | |||||
reviewedtime, remarks, phonenumber, electronicnumber, | |||||
rfidmodifiedtime, rfidstop, rfidstopby, rfidstoptime, rfidgrantby, | |||||
rfidgranttime, samplingpoints, drawbar, carriagelength, carriagewidth, | |||||
carriageheight, underbodyheight, frontsampling, backsampling, rod1, rod2, | |||||
rod3, rod4, rod5, rod6, supplier_id, supplier_name, material_id, material_name | |||||
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, | |||||
$16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, | |||||
$29, $30, $31, $32, $33, $34, $35, $36, $37, $38, $39, $40, $41, | |||||
$42, $43, $44, $45, $46, $47)", | |||||
&[ | |||||
&info.id, &info.licenseplate, &info.r#type, &info.grosswt, &info.tarewt, | |||||
&info.owner, &info.dl, &info.supervision, &info.outage, &info.insurancedate, | |||||
&info.insurancenum, &info.lock, &info.transcompany, &info.createdby, | |||||
&info.creationtime, &info.modifiedby, &info.modifiedtime, &info.reviewed, | |||||
&info.reviewedby, &info.reviewedtime, &info.remarks, &info.phonenumber, | |||||
&info.electronicnumber, &info.rfidmodifiedtime, | |||||
&info.rfidstop, &info.rfidstopby, &info.rfidstoptime, &info.rfidgrantby, | |||||
&info.rfidgranttime, &info.samplingpoints, &info.drawbar, &info.carriagelength, | |||||
&info.carriagewidth, &info.carriageheight, &info.underbodyheight, | |||||
&info.frontsampling, &info.backsampling, &info.rod1, &info.rod2, &info.rod3, | |||||
&info.rod4, &info.rod5, &info.rod6, &info.supplier_id, &info.supplier_name, | |||||
&info.material_id, &info.material_name | |||||
], | |||||
).await?; | |||||
} | |||||
println!("成功{}车辆信息: ID {}", if exists { "更新" } else { "插入" }, info.id); | |||||
Ok(()) | |||||
} | |||||
async fn insert_information(client: &tokio_postgres::Client, info: &InformationInfo) -> Result<(), PgError> { | async fn insert_information(client: &tokio_postgres::Client, info: &InformationInfo) -> Result<(), PgError> { | ||||
let exists = client | let exists = client | ||||
.query_one( | .query_one( | ||||
@@ -1530,6 +1665,21 @@ async fn handle_client(socket: &mut TcpStream, client: &tokio_postgres::Client) | |||||
false | false | ||||
} | } | ||||
}, | }, | ||||
"comm_bm_vehicleinfo" => { | |||||
if let Ok(info) = serde_json::from_str::<CommBmVehicleinfo>(data_str) { | |||||
println!("接收到车辆信息: {:?}", info); | |||||
match insert_vehicle_info(client, &info).await { | |||||
Ok(_) => true, | |||||
Err(e) => { | |||||
eprintln!("插入车辆信息失败: {}", e); | |||||
false | |||||
} | |||||
} | |||||
} else { | |||||
eprintln!("解析车辆信息失败"); | |||||
false | |||||
} | |||||
}, | |||||
"hy_allot" => { | "hy_allot" => { | ||||
if let Ok(info) = serde_json::from_str::<HyAllot>(data_str) { | if let Ok(info) = serde_json::from_str::<HyAllot>(data_str) { | ||||
println!("接收到分配信息: {:?}", info); | println!("接收到分配信息: {:?}", info); | ||||
@@ -1 +1 @@ | |||||
{"rustc_fingerprint":12877487731689626790,"outputs":{"17747080675513052775":{"success":true,"status":"","code":0,"stdout":"rustc 1.85.0 (4d91de4e4 2025-02-17)\nbinary: rustc\ncommit-hash: 4d91de4e48198da2e33413efdcd9cd2cc0c46688\ncommit-date: 2025-02-17\nhost: x86_64-pc-windows-msvc\nrelease: 1.85.0\nLLVM version: 19.1.7\n","stderr":""},"17313545009459141857":{"success":true,"status":"","code":0,"stdout":"___.exe\nlib___.rlib\n___.dll\n___.dll\n___.lib\n___.dll\nC:\\Users\\qq101\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\npacked\n___\ndebug_assertions\npanic=\"unwind\"\nproc_macro\ntarget_abi=\"\"\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"msvc\"\ntarget_family=\"windows\"\ntarget_feature=\"cmpxchg16b\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_feature=\"sse3\"\ntarget_has_atomic=\"128\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_os=\"windows\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"pc\"\nwindows\n","stderr":""},"13331785392996375709":{"success":true,"status":"","code":0,"stdout":"___.exe\nlib___.rlib\n___.dll\n___.dll\n___.lib\n___.dll\nC:\\Users\\qq101\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\npacked\n___\ndebug_assertions\npanic=\"unwind\"\nproc_macro\ntarget_abi=\"\"\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"msvc\"\ntarget_family=\"windows\"\ntarget_feature=\"cmpxchg16b\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_feature=\"sse3\"\ntarget_has_atomic=\"128\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_os=\"windows\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"pc\"\nwindows\n","stderr":""}},"successes":{}} | |||||
{"rustc_fingerprint":3807311574931242264,"outputs":{"17747080675513052775":{"success":true,"status":"","code":0,"stdout":"rustc 1.85.0 (4d91de4e4 2025-02-17)\nbinary: rustc\ncommit-hash: 4d91de4e48198da2e33413efdcd9cd2cc0c46688\ncommit-date: 2025-02-17\nhost: x86_64-pc-windows-msvc\nrelease: 1.85.0\nLLVM version: 19.1.7\n","stderr":""},"13331785392996375709":{"success":true,"status":"","code":0,"stdout":"___.exe\nlib___.rlib\n___.dll\n___.dll\n___.lib\n___.dll\nC:\\Users\\qq101\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\npacked\n___\ndebug_assertions\npanic=\"unwind\"\nproc_macro\ntarget_abi=\"\"\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"msvc\"\ntarget_family=\"windows\"\ntarget_feature=\"cmpxchg16b\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_feature=\"sse3\"\ntarget_has_atomic=\"128\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_os=\"windows\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"pc\"\nwindows\n","stderr":""}},"successes":{}} |