пампарам
parent
97d73cf027
commit
37d9ae5474
|
|
@ -6,12 +6,9 @@
|
|||
- [x] Сырья
|
||||
- [ ] Произведённой продукции
|
||||
- [ ] Доходов от продажи продукции
|
||||
- [ ] Зарплат сотрудникам
|
||||
- [x] Зарплат сотрудникам
|
||||
|
||||
Помимо этого, система позволяет:
|
||||
- [ ] Составлять рецепты, используя доступное сырьё и оборудование
|
||||
- [ ] Использовать рецепты при учёте произведённой продукции, позволяя отслеживать, сколько и какого сырья потребуется на производство определённого объёма продукции.
|
||||
|
||||
//Если оно выдаёт странную ошибку 0xc0000005 на винде:
|
||||
$env:WGPU_BACKEND="dx12" - в повершеле
|
||||
set WGPU_BACKEND=dx12 - в не-повершеле
|
||||
|
|
@ -404,6 +404,40 @@ impl DBOperator {
|
|||
Err(_) => Ok(false),
|
||||
}
|
||||
}
|
||||
pub async fn get_recipes(&self) -> Result<Vec<Recipe>, sqlx::Error> {
|
||||
let pre_ret = sqlx::query_as::<_, RecipeRow>("SELECT * FROM recipe")
|
||||
.fetch_all(&self.pool)
|
||||
.await
|
||||
.unwrap_or(Vec::new());
|
||||
|
||||
let ret: Vec<Recipe> = Vec::new();
|
||||
let elements = self.get_recipe_elements().await.unwrap_or(Vec::new());
|
||||
for pr in pre_ret.iter() {}
|
||||
Ok(ret)
|
||||
}
|
||||
pub async fn get_recipe_elements(&self) -> Result<Vec<RecipeElement>, sqlx::Error> {
|
||||
let pre_ret = sqlx::query_as::<_, RecipeElementRow>("SELECT id, recipe_id, material_id, equipment_id, quantity FROM Brewery.recipe_element;").fetch_all(&self.pool).await;
|
||||
|
||||
let mats = self.get_materials().await.unwrap();
|
||||
let eqs = self.get_equipment().await.unwrap();
|
||||
let ret: Vec<RecipeElement> = Vec::new();
|
||||
for re in pre_ret.unwrap().iter() {
|
||||
let mat = mats.iter().find(|m| m.id == re.material_id);
|
||||
let eq = eqs.iter().find(|e| e.id == re.equipment_id);
|
||||
match (mat, eq) {
|
||||
(Some(m), Some(e)) => {
|
||||
ret.push(RecipeElement {
|
||||
id: re.id,
|
||||
material: m.clone(),
|
||||
equipment: e.clone(),
|
||||
quantity: re.quantity,
|
||||
});
|
||||
}
|
||||
(_, _) => {}
|
||||
}
|
||||
}
|
||||
Ok(ret)
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn estabilish_connection() -> Result<(), sqlx::Error> {
|
||||
|
|
|
|||
|
|
@ -92,15 +92,27 @@ pub struct MaterialCategory {
|
|||
pub name: String,
|
||||
}
|
||||
pub struct RecipeElement {
|
||||
id: i32,
|
||||
material: Material,
|
||||
equipment: Equipment,
|
||||
quantity: i32,
|
||||
pub id: i32,
|
||||
pub material: Material,
|
||||
pub equipment: Equipment,
|
||||
pub quantity: i32,
|
||||
}
|
||||
#[derive(FromRow)]
|
||||
pub struct RecipeElementRow {
|
||||
pub id: i32,
|
||||
pub material_id: i32,
|
||||
pub equipment_id: i32,
|
||||
pub quantity: i32,
|
||||
}
|
||||
pub struct Recipe {
|
||||
id: i32,
|
||||
name: String,
|
||||
elements: std::vec::Vec<RecipeElement>,
|
||||
pub id: i32,
|
||||
pub name: String,
|
||||
pub elements: std::vec::Vec<RecipeElement>,
|
||||
}
|
||||
#[derive(FromRow)]
|
||||
pub struct RecipeRow {
|
||||
pub id: i32,
|
||||
pub name: String,
|
||||
}
|
||||
pub struct Client {
|
||||
id: i32,
|
||||
|
|
|
|||
|
|
@ -50,6 +50,12 @@ impl egui_dock::TabViewer for RecipeTabViewer {
|
|||
|
||||
impl Default for RecipeTabViewer {
|
||||
fn default() -> Self {
|
||||
Self { is_admin: false }
|
||||
let rt = tokio::runtime::Runtime::new().unwrap();
|
||||
let db_oper = rt.block_on(async{DBOperator::new().await});
|
||||
Self { is_admin: false,
|
||||
rt,
|
||||
db_oper,
|
||||
recipes:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue