add full import data
This commit is contained in:
parent
447ec7e78a
commit
2138db21eb
1 changed files with 46 additions and 1 deletions
|
|
@ -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},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -591,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