Merge branch 'master' of https://gitlab.forthrd.io/Pakin/libtbr
This commit is contained in:
commit
9bf4c508cd
2 changed files with 88 additions and 38 deletions
|
|
@ -50,6 +50,10 @@ impl Table {
|
||||||
.collect::<Vec<String>>();
|
.collect::<Vec<String>>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn set_headers(&mut self, headers: Vec<String>) {
|
||||||
|
self.header = headers;
|
||||||
|
}
|
||||||
|
|
||||||
pub fn get_current_header(self) -> Vec<String> {
|
pub fn get_current_header(self) -> Vec<String> {
|
||||||
self.header
|
self.header
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ use serde_json::{Number, Value};
|
||||||
|
|
||||||
use super::common::*;
|
use super::common::*;
|
||||||
use crate::{
|
use crate::{
|
||||||
models::recipe::{self, PartialRecipe},
|
models::recipe::{self, PartialRecipe, Recipe},
|
||||||
previews::{csvf::*, header::Headers},
|
previews::{csvf::*, header::Headers},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -353,17 +353,18 @@ pub fn generate_recipe_sheet_table(country_name: &str, into_version: usize) {
|
||||||
|
|
||||||
recipe_table.set_config(insert_later_config);
|
recipe_table.set_config(insert_later_config);
|
||||||
|
|
||||||
match country_name {
|
// auto detect
|
||||||
"sgp" => {
|
//
|
||||||
info!("SGP last update [24.02.2025]");
|
let mut mat_header = vec!["Name".to_string(), "ProductCode".to_string()];
|
||||||
recipe_table.set_header(Headers::get_recipe_table_sgp_24022025());
|
mat_header.extend(
|
||||||
}
|
latest_recipe
|
||||||
"dubai" => {
|
.MaterialSetting
|
||||||
info!("UAE last update [16.05.2025]");
|
.iter()
|
||||||
recipe_table.set_header(Headers::get_recipe_table_dubai_16052025());
|
.map(|ms| ms.id.as_u64().unwrap().to_string())
|
||||||
}
|
.collect::<Vec<String>>(),
|
||||||
_ => {}
|
);
|
||||||
}
|
|
||||||
|
recipe_table.set_headers(mat_header);
|
||||||
|
|
||||||
let mut material_names = Vec::new();
|
let mut material_names = Vec::new();
|
||||||
|
|
||||||
|
|
@ -453,16 +454,16 @@ pub fn generate_recipe_sheet_table(country_name: &str, into_version: usize) {
|
||||||
if header_idx > 1 && header.eq(¤t_material.to_string()) {
|
if header_idx > 1 && header.eq(¤t_material.to_string()) {
|
||||||
// search mat settings for further info
|
// search mat settings for further info
|
||||||
|
|
||||||
if rpl.productCode.clone().ends_with("0090") {
|
// if rpl.productCode.clone().ends_with("0090") {
|
||||||
debug!(
|
// debug!(
|
||||||
"MAT [{}]: {} --> {} = pow:{:?},sy:{:?}",
|
// "MAT [{}]: {} --> {} = pow:{:?},sy:{:?}",
|
||||||
rpl.productCode.clone(),
|
// rpl.productCode.clone(),
|
||||||
header_idx,
|
// header_idx,
|
||||||
repl.materialPathId.clone(),
|
// repl.materialPathId.clone(),
|
||||||
repl.powderGram,
|
// repl.powderGram,
|
||||||
repl.syrupGram
|
// repl.syrupGram
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
|
|
||||||
let mat_setting = latest_recipe
|
let mat_setting = latest_recipe
|
||||||
.search_material_settings(current_material.to_string());
|
.search_material_settings(current_material.to_string());
|
||||||
|
|
@ -488,27 +489,27 @@ pub fn generate_recipe_sheet_table(country_name: &str, into_version: usize) {
|
||||||
}
|
}
|
||||||
recipe::MaterialType::Syrup => {
|
recipe::MaterialType::Syrup => {
|
||||||
// debug
|
// debug
|
||||||
if rpl.productCode.clone().ends_with("0090") {
|
// if rpl.productCode.clone().ends_with("0090") {
|
||||||
println!(
|
// println!(
|
||||||
"SYRUP [{}]: {} --> {} = {:?}",
|
// "SYRUP [{}]: {} --> {} = {:?}",
|
||||||
rpl.productCode.clone(),
|
// rpl.productCode.clone(),
|
||||||
header_idx,
|
// header_idx,
|
||||||
repl.materialPathId.clone(),
|
// repl.materialPathId.clone(),
|
||||||
repl.syrupGram
|
// repl.syrupGram
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
|
|
||||||
recipe_brewing_values_only[header_idx] +=
|
recipe_brewing_values_only[header_idx] +=
|
||||||
repl.syrupGram.as_i64().unwrap();
|
repl.syrupGram.as_i64().unwrap();
|
||||||
}
|
}
|
||||||
recipe::MaterialType::Soda => {
|
recipe::MaterialType::Soda => {
|
||||||
println!(
|
// println!(
|
||||||
"SODA [{}]: {} --> {} = {:?}",
|
// "SODA [{}]: {} --> {} = {:?}",
|
||||||
rpl.productCode.clone(),
|
// rpl.productCode.clone(),
|
||||||
header_idx,
|
// header_idx,
|
||||||
repl.materialPathId.clone(),
|
// repl.materialPathId.clone(),
|
||||||
repl.syrupGram
|
// repl.syrupGram
|
||||||
);
|
// );
|
||||||
|
|
||||||
recipe_brewing_values_only[header_idx] +=
|
recipe_brewing_values_only[header_idx] +=
|
||||||
repl.syrupGram.as_i64().unwrap();
|
repl.syrupGram.as_i64().unwrap();
|
||||||
|
|
@ -590,3 +591,48 @@ pub fn generate_recipe_sheet_table(country_name: &str, into_version: usize) {
|
||||||
recipe_table.add_column_desciption(0, material_names);
|
recipe_table.add_column_desciption(0, material_names);
|
||||||
recipe_table.generate_save_file("./test_result/recipe.csv");
|
recipe_table.generate_save_file("./test_result/recipe.csv");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// import only new data from source to target
|
||||||
|
///
|
||||||
|
/// `import_target` must be mutable
|
||||||
|
///
|
||||||
|
/// This only update the following fields
|
||||||
|
///
|
||||||
|
/// - Recipe01
|
||||||
|
/// - MaterialSetting
|
||||||
|
/// - MaterialCode
|
||||||
|
/// - Topping
|
||||||
|
///
|
||||||
|
pub fn full_import_data(source: Recipe, mut import_target: Recipe) {
|
||||||
|
// import menus
|
||||||
|
source.Recipe01.iter().for_each(|r01| {
|
||||||
|
if !import_target.Recipe01.contains(r01) {
|
||||||
|
import_target.Recipe01.push(r01.clone());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// import materials
|
||||||
|
source.MaterialSetting.iter().for_each(|ms| {
|
||||||
|
if !import_target.MaterialSetting.contains(ms) {
|
||||||
|
import_target.MaterialSetting.push(ms.clone());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
source.MaterialCode.iter().for_each(|mc| {
|
||||||
|
if !import_target.MaterialCode.contains(mc) {
|
||||||
|
import_target.MaterialCode.push(mc.clone());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// import new toppings
|
||||||
|
source.Topping.ToppingList.iter().for_each(|tpl| {
|
||||||
|
if !import_target.Topping.ToppingList.contains(tpl) {
|
||||||
|
import_target.Topping.ToppingList.push(tpl.clone());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
source.Topping.ToppingGroup.iter().for_each(|tg| {
|
||||||
|
if !import_target.Topping.ToppingGroup.contains(tg) {
|
||||||
|
import_target.Topping.ToppingGroup.push(tg.clone());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue