过站检测逻辑修改
This commit is contained in:
parent
727249692b
commit
eff2d8a7af
@ -36,18 +36,26 @@ impl MesService {
|
|||||||
download_type: DownloadType,
|
download_type: DownloadType,
|
||||||
) -> Result<bool, Error> {
|
) -> Result<bool, Error> {
|
||||||
match download_type {
|
match download_type {
|
||||||
DownloadType::App => Ok(true),
|
|
||||||
DownloadType::Rail => {
|
DownloadType::Rail => {
|
||||||
let mut conn = self.pool.get_conn()?;
|
let mut conn = self.pool.get_conn()?;
|
||||||
let check_result: Vec<String> = conn.query(format!(
|
let check_result: Vec<String> = conn.query(format!(
|
||||||
"SELECT `Station1` FROM {work_order} WHERE `Barcode` = {label}"
|
"SELECT `Station2` FROM {work_order} WHERE `Barcode` = {label}"
|
||||||
))?;
|
))?;
|
||||||
if check_result.is_empty() {
|
if check_result.is_empty() {
|
||||||
return Ok(false);
|
return Ok(false);
|
||||||
}
|
}
|
||||||
Ok(check_result[0] == "1")
|
Ok(check_result[0] == "1")
|
||||||
}
|
}
|
||||||
DownloadType::Bootloader => Err(Error::msg("Not implemented yet")),
|
_ => {
|
||||||
|
let mut conn = self.pool.get_conn()?;
|
||||||
|
let check_result: Vec<String> = 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() {
|
if let Some(work_order_id) = work_order_id.first() {
|
||||||
let _: Vec<String> = conn.exec(
|
let _: Vec<String> = conn.exec(
|
||||||
format!(
|
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`)"
|
ON DUPLICATE KEY UPDATE `Barcode` = VALUES(`Barcode`), `IMEI_1` = VALUES(`IMEI_1`), `Station1` = VALUES(`Station1`)"
|
||||||
),
|
),
|
||||||
()
|
()
|
||||||
@ -79,7 +87,7 @@ impl MesService {
|
|||||||
DownloadType::Rail => {
|
DownloadType::Rail => {
|
||||||
let mut conn = self.pool.get_conn()?;
|
let mut conn = self.pool.get_conn()?;
|
||||||
let _: Vec<String> = conn.exec(
|
let _: Vec<String> = conn.exec(
|
||||||
format!("UPDATE {work_order} SET `Station2` = 1 WHERE `Barcode` = {label}"),
|
format!("UPDATE {work_order} SET `Station3` = 1 WHERE `Barcode` = '{label}'"),
|
||||||
(),
|
(),
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user