Bladeren bron

设备remark字段调整

晋江
OCEAN 2 maanden geleden
bovenliggende
commit
b5fe254b69
1 gewijzigde bestanden met toevoegingen van 16 en 12 verwijderingen
  1. +16
    -12
      tcp_server/src/main.rs

+ 16
- 12
tcp_server/src/main.rs Bestand weergeven

@@ -15,8 +15,8 @@ struct InstrumentInfo {
name: String, name: String,
instrumentcode: String, instrumentcode: String,
informationid: i32, informationid: i32,
specification: String,
remark: String,
specification: Option<String>,
remark: Option<String>,
} }


#[derive(Debug, Deserialize)] #[derive(Debug, Deserialize)]
@@ -1216,18 +1216,22 @@ async fn handle_client(socket: &mut TcpStream, client: &tokio_postgres::Client)
if let Some(data_str) = json.get("data").and_then(|v| v.as_str()) { if let Some(data_str) = json.get("data").and_then(|v| v.as_str()) {
match table_name { match table_name {
"hy_instrument" => { "hy_instrument" => {
if let Ok(info) = serde_json::from_str::<InstrumentInfo>(data_str) {
println!("接收到仪器信息: {:?}", info);
match insert_instrument(client, &info).await {
Ok(_) => true,
Err(e) => {
eprintln!("插入仪器信息失败: {}", e);
false
println!("解析仪器数据: {}", data_str);
match serde_json::from_str::<InstrumentInfo>(data_str) {
Ok(info) => {
println!("接收到仪器信息: {:?}", info);
match insert_instrument(client, &info).await {
Ok(_) => true,
Err(e) => {
eprintln!("插入仪器信息失败: {}", e);
false
}
} }
},
Err(e) => {
eprintln!("解析仪器信息失败: {}", e);
false
} }
} else {
eprintln!("解析仪器信息失败");
false
} }
}, },
"hy_information" => { "hy_information" => {


Laden…
Annuleren
Opslaan