From eff2d8a7af58789682c6fec79e2ab741eb471993 Mon Sep 17 00:00:00 2001 From: JIe Date: Tue, 4 Mar 2025 16:44:45 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=87=E7=AB=99=E6=A3=80=E6=B5=8B=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mes_service.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/mes_service.rs b/src/mes_service.rs index 1634b49..5a1b51f 100644 --- a/src/mes_service.rs +++ b/src/mes_service.rs @@ -36,18 +36,26 @@ impl MesService { download_type: DownloadType, ) -> Result { match download_type { - DownloadType::App => Ok(true), DownloadType::Rail => { let mut conn = self.pool.get_conn()?; let check_result: Vec = conn.query(format!( - "SELECT `Station1` FROM {work_order} WHERE `Barcode` = {label}" + "SELECT `Station2` FROM {work_order} WHERE `Barcode` = {label}" ))?; if check_result.is_empty() { return Ok(false); } Ok(check_result[0] == "1") } - DownloadType::Bootloader => Err(Error::msg("Not implemented yet")), + _ => { + let mut conn = self.pool.get_conn()?; + let check_result: Vec = conn.query(format!( + "SELECT * FROM {work_order} WHERE `Barcode` = {label}" + ))?; + if check_result.is_empty() { + return Ok(true); + } + Ok(false) + } } } @@ -67,7 +75,7 @@ impl MesService { if let Some(work_order_id) = work_order_id.first() { let _: Vec = conn.exec( format!( - "INSERT INTO {work_order} (`ID`, `Barcode`, `IMEI_1`, `Station1`) VALUES ({work_order_id}, {label}, {label}, '1') \ + "INSERT INTO `{work_order}` (`ID`, `Barcode`, `IMEI_1`, `Station1`) VALUES ( {work_order_id}, '{label}', '{label}', '1') \ ON DUPLICATE KEY UPDATE `Barcode` = VALUES(`Barcode`), `IMEI_1` = VALUES(`IMEI_1`), `Station1` = VALUES(`Station1`)" ), () @@ -79,7 +87,7 @@ impl MesService { DownloadType::Rail => { let mut conn = self.pool.get_conn()?; let _: Vec = conn.exec( - format!("UPDATE {work_order} SET `Station2` = 1 WHERE `Barcode` = {label}"), + format!("UPDATE {work_order} SET `Station3` = 1 WHERE `Barcode` = '{label}'"), (), )?; }