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