Compare commits
2 Commits
727249692b
...
c5d17ba613
Author | SHA1 | Date | |
---|---|---|---|
c5d17ba613 | |||
eff2d8a7af |
@ -49,8 +49,8 @@ impl Default for DownloadWrapper {
|
||||
.join("commander/Simplicity Commander/commander.exe"),
|
||||
bin_path: PathBuf::from(std::env::current_dir().unwrap()).join("bin/"),
|
||||
bootloader_name: String::from("RAWM00-2-0-0_silicon-wisun_bootloader_D20241008.s37"),
|
||||
app_name: String::from("RAWM00-2-0-0_silicon-wisun_APP-V1_D20240927.s37"),
|
||||
rail_name: String::from("rail_soc_railtest_sisdk.s37"),
|
||||
app_name: String::from("RAWM00-2-0-0_silicon-combine-V1-D20241230-BZ.hex"),
|
||||
rail_name: String::from("rail_soc_railtest_sisdk(silabs).hex"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ use std::any::Any;
|
||||
use std::fs;
|
||||
use std::io::Write;
|
||||
use std::sync::{Arc, LazyLock, Mutex};
|
||||
use std::thread::sleep;
|
||||
|
||||
pub fn main() -> iced::Result {
|
||||
iced::application("WisunDownload V0.1", MainWindow::update, MainWindow::view)
|
||||
@ -208,6 +209,7 @@ impl MainWindow {
|
||||
}else{
|
||||
self.result_background = Color::from_rgb8(255, 0,0);
|
||||
}
|
||||
self.label = "".to_string();
|
||||
Task::none()
|
||||
}
|
||||
Message::WindowEvent(event) => {
|
||||
@ -297,7 +299,13 @@ impl MainWindow {
|
||||
add_log("请输入Label".to_string());
|
||||
return;
|
||||
}
|
||||
if label.contains(":"){
|
||||
add_log("Label不合法".to_string());
|
||||
self.label = "".to_string();
|
||||
return;
|
||||
}
|
||||
std::thread::spawn(move || {
|
||||
sleep(std::time::Duration::from_secs(5));
|
||||
let mut download_wrapper = download_wrapper::DownloadWrapper::new();
|
||||
let mut mes_service: MesService;
|
||||
sender.send(Message::ClearLog).unwrap();
|
||||
|
@ -36,18 +36,28 @@ impl MesService {
|
||||
download_type: DownloadType,
|
||||
) -> Result<bool, Error> {
|
||||
match download_type {
|
||||
DownloadType::App => Ok(true),
|
||||
DownloadType::Rail => {
|
||||
let mut conn = self.pool.get_conn()?;
|
||||
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() {
|
||||
return Ok(false);
|
||||
}
|
||||
Ok(check_result[0] == "1")
|
||||
}
|
||||
DownloadType::Bootloader => Err(Error::msg("Not implemented yet")),
|
||||
DownloadType::App => {
|
||||
let mut conn = self.pool.get_conn()?;
|
||||
let check_result: Vec<String> = conn.query(format!(
|
||||
"SELECT `IMEI_1` FROM `{work_order}` WHERE `Barcode` = '{label}';"
|
||||
))?;
|
||||
if check_result.is_empty() {
|
||||
Ok(true)
|
||||
} else {
|
||||
Ok(false)
|
||||
}
|
||||
}
|
||||
DownloadType::Bootloader => Ok(true),
|
||||
}
|
||||
}
|
||||
|
||||
@ -57,6 +67,7 @@ impl MesService {
|
||||
label: String,
|
||||
download_type: DownloadType,
|
||||
) -> Result<(), Error> {
|
||||
let time_now = chrono::Local::now().format("%Y-%m-%d %H:%M:%S").to_string();
|
||||
match download_type {
|
||||
DownloadType::Bootloader => {}
|
||||
DownloadType::App => {
|
||||
@ -67,8 +78,11 @@ impl MesService {
|
||||
if let Some(work_order_id) = work_order_id.first() {
|
||||
let _: Vec<String> = conn.exec(
|
||||
format!(
|
||||
"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`)"
|
||||
"INSERT INTO `{work_order}` (`ID`, `Barcode`, `IMEI_1`, `Station1`, `Station1Time`) VALUES ( {work_order_id}, '{label}', '{label}', '1', '{time_now}') \
|
||||
ON DUPLICATE KEY UPDATE `Barcode` = VALUES(`Barcode`), `IMEI_1` = VALUES(`IMEI_1`), `Station1` = VALUES(`Station1`), `Station1Time`= VALUES(`Station1Time`)",
|
||||
work_order_id = work_order_id,
|
||||
label = label,
|
||||
time_now = time_now
|
||||
),
|
||||
()
|
||||
)?;
|
||||
@ -79,7 +93,7 @@ impl MesService {
|
||||
DownloadType::Rail => {
|
||||
let mut conn = self.pool.get_conn()?;
|
||||
let _: Vec<String> = conn.exec(
|
||||
format!("UPDATE {work_order} SET `Station2` = 1 WHERE `Barcode` = {label}"),
|
||||
format!("UPDATE `{work_order}` SET Station3 = 1, Station3Time='{time_now}' WHERE Barcode = '{label}'"),
|
||||
(),
|
||||
)?;
|
||||
}
|
||||
@ -102,6 +116,7 @@ impl MesService {
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use crate::mes_service::MesService;
|
||||
use mysql::prelude::*;
|
||||
|
||||
#[test]
|
||||
fn test_mes_service() {
|
||||
@ -127,4 +142,24 @@ mod test {
|
||||
assert_ne!(work_orders.len(), 0);
|
||||
println!("{:?}", work_orders);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_check_station() {
|
||||
let mes = MesService::new(
|
||||
"192.168.1.17".to_string(),
|
||||
"3306".to_string(),
|
||||
"root".to_string(),
|
||||
"".to_string(),
|
||||
"MOBILETEK_WISUN".to_string(),
|
||||
);
|
||||
let mut conn = mes.unwrap().pool.get_conn().unwrap();
|
||||
let work_order = "3333";
|
||||
let label = "202400154Y000016";
|
||||
let check_result: Vec<String> = conn
|
||||
.query(format!(
|
||||
"SELECT `COUNT` FROM `{work_order}` WHERE `Barcode` = '{label}';"
|
||||
))
|
||||
.unwrap();
|
||||
println!("{:?}", check_result);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user