Merge branch 'master' of https://gitea.suz-ppk.ru/UltraGoose/BreweryControlSystem
commit
ad6cc00f84
|
|
@ -6,3 +6,4 @@ target
|
|||
*.pdb
|
||||
|
||||
**/mutants.out*/
|
||||
.env
|
||||
|
|
|
|||
|
|
@ -723,6 +723,11 @@ name = "code"
|
|||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
"diesel",
|
||||
"dotenv",
|
||||
>>>>>>> 5139defcb4ef73ab9355785c6dd0043e987b9247
|
||||
"eframe",
|
||||
"egui",
|
||||
"egui_dock",
|
||||
|
|
@ -965,10 +970,17 @@ dependencies = [
|
|||
]
|
||||
|
||||
[[package]]
|
||||
<<<<<<< HEAD
|
||||
name = "dotenvy"
|
||||
version = "0.15.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b"
|
||||
=======
|
||||
name = "dotenv"
|
||||
version = "0.15.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f"
|
||||
>>>>>>> 5139defcb4ef73ab9355785c6dd0043e987b9247
|
||||
|
||||
[[package]]
|
||||
name = "downcast-rs"
|
||||
|
|
@ -3266,11 +3278,22 @@ dependencies = [
|
|||
"num-traits",
|
||||
"rand",
|
||||
"rkyv",
|
||||
"rust_decimal_macros",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rust_decimal_macros"
|
||||
version = "1.40.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "74a5a6f027e892c7a035c6fddb50435a1fbf5a734ffc0c2a9fed4d0221440519"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"syn 2.0.117",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc-hash"
|
||||
version = "1.1.0"
|
||||
|
|
|
|||
|
|
@ -4,14 +4,17 @@ version = "0.1.0"
|
|||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
chrono = { version = "0.4.44", features = ["serde"] }
|
||||
dotenv = "0.15.0"
|
||||
eframe = "0.34.2"
|
||||
chrono = { version = "0.4.44", features = ["serde"] }
|
||||
egui = "0.34.2"
|
||||
egui_dock = "0.19.1"
|
||||
egui_extras = "0.34.2"
|
||||
rust_decimal = "1.42.0"
|
||||
rust_decimal = {version = "1.42.0", features = ["macros"]}
|
||||
sqlx = "0.8.6"
|
||||
|
||||
[target.'cfg(target_os="windows")'.dependencies]
|
||||
eframe = {version ="0.34.2",default-features=false, features=["glow"]}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ struct Tab{
|
|||
tab_type: TabTypes,
|
||||
title: String,
|
||||
}
|
||||
|
||||
pub struct App{
|
||||
tree: egui_dock::DockState<Tab>,
|
||||
}
|
||||
|
|
@ -53,33 +52,54 @@ impl eframe::App for App{
|
|||
fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame){
|
||||
DockArea::new(&mut self.tree)
|
||||
.style(Style::from_egui(ui.style().as_ref()))
|
||||
.show_inside(ui, &mut MainTabViewer {});
|
||||
.show_inside(ui, &mut MainTabViewer {
|
||||
equipment: vec![
|
||||
crate::models::Equipment::default(),
|
||||
crate::models::Equipment::default(),
|
||||
crate::models::Equipment::default(),
|
||||
crate::models::Equipment::default(),
|
||||
]
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
struct MainTabViewer {}
|
||||
struct MainTabViewer {
|
||||
equipment: std::vec::Vec<crate::models::Equipment>,
|
||||
}
|
||||
impl MainTabViewer{
|
||||
fn show_equipment(&mut self, ui: &mut egui::Ui){
|
||||
use egui_extras::{Column,TableBuilder};
|
||||
let text_height =egui::TextStyle::Body.resolve(ui.style()).size;
|
||||
let available_heigh = ui.available_height();
|
||||
let mut table = TableBuilder::new(ui)
|
||||
.striped(true)
|
||||
.resizable(false)
|
||||
.cell_layout(egui::Layout::left_to_right(egui::Align::Center))
|
||||
.column(Column::auto())
|
||||
.column(Column::remainder()
|
||||
.at_least(40.0)
|
||||
.clip(true)
|
||||
.resizable(true),
|
||||
)
|
||||
.column(Column::auto())
|
||||
.column(Column::remainder())
|
||||
.column(Column::remainder())
|
||||
.min_scrolled_height(0.0)
|
||||
.max_scroll_height(available_heigh);
|
||||
table = table.sense(egui::Sense::click());
|
||||
|
||||
// use egui_extras::{Column,TableBuilder};
|
||||
// let text_height =egui::TextStyle::Body.resolve(ui.style()).size;
|
||||
// let available_heigh = ui.available_height();
|
||||
// let mut table = TableBuilder::new(ui)
|
||||
// .striped(true)
|
||||
// .resizable(false)
|
||||
// .cell_layout(egui::Layout::left_to_right(egui::Align::Center))
|
||||
// .column(Column::auto())
|
||||
// .column(Column::remainder()
|
||||
// .at_least(40.0)
|
||||
// .clip(true)
|
||||
// .resizable(true),
|
||||
// )
|
||||
// .column(Column::auto())
|
||||
// .column(Column::remainder())
|
||||
// .column(Column::remainder())
|
||||
// .min_scrolled_height(0.0)
|
||||
// .max_scroll_height(available_heigh);
|
||||
// table = table.sense(egui::Sense::click());
|
||||
//Это таблицы, с ними надо разобраться!
|
||||
|
||||
for eq in self.equipment.clone() {
|
||||
ui.push_id("shit".to_owned(), |ui|{
|
||||
egui::CollapsingHeader::new(&eq.name)
|
||||
.default_open(false)
|
||||
.show(ui, |ui|{
|
||||
ui.label(eq.inv_number);
|
||||
ui.label(eq.worker.full_name);
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
use diesel::prelude::*;
|
||||
use dotenv::dotenv;
|
||||
use crate::schema::equipment::dsl::*;
|
||||
use crate::schema::worker::dsl::*;
|
||||
|
||||
pub fn estabilish_connection() -> MysqlConnection{
|
||||
dotenv().ok();
|
||||
let db_url = dotenv::var("DATABASE_URL").expect("DATABASE_URL установи!");
|
||||
MysqlConnection::establish(&db_url)
|
||||
.unwrap_or_else(|_| panic!("Не коннектится!"))
|
||||
}
|
||||
|
||||
pub fn get_positions() -> std::vec::Vec<crate::models::Position>{
|
||||
let ret: std::vec::Vec<crate::models::Position>;
|
||||
ret
|
||||
}
|
||||
|
|
@ -1,8 +1,10 @@
|
|||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||
mod app;
|
||||
mod models;
|
||||
mod database;
|
||||
mod schema;
|
||||
fn main() -> eframe::Result{
|
||||
|
||||
database::estabilish_connection();
|
||||
let native_opts = eframe::NativeOptions {
|
||||
viewport: egui::ViewportBuilder::default()
|
||||
.with_inner_size([400.0,300.0])
|
||||
|
|
|
|||
|
|
@ -1,63 +1,100 @@
|
|||
struct Position{
|
||||
use diesel::{Selectable, deserialize::Queryable};
|
||||
|
||||
use crate::schema::{self, *};
|
||||
|
||||
|
||||
#[derive(Default, Clone, Hash,Queryable,Selectable)]
|
||||
#[diesel(table_name=schema::position)]
|
||||
pub struct Position{
|
||||
id: i32,
|
||||
name: String,
|
||||
wage: rust_decimal::Decimal,
|
||||
}
|
||||
struct Worker{
|
||||
id: i32,
|
||||
full_name: String,
|
||||
hire_date: chrono::NaiveDateTime,
|
||||
position: Position,
|
||||
is_fired: bool,
|
||||
#[derive(Queryable,Selectable)]
|
||||
#[diesel(table_name=schema::worker)]
|
||||
pub struct WorkerRow{
|
||||
pub id:i32,
|
||||
pub full_name: String,
|
||||
pub hire_date: chrono::DateTime<chrono::Local>,
|
||||
pub position_id: i32,
|
||||
pub is_fired:bool
|
||||
}
|
||||
struct Salary{
|
||||
|
||||
#[derive(Default, Clone, Hash)]
|
||||
pub struct Worker{
|
||||
pub id: i32,
|
||||
pub full_name: String,
|
||||
pub hire_date: chrono::DateTime<chrono::Local>,
|
||||
pub position: Position,
|
||||
pub is_fired: bool,
|
||||
}
|
||||
#[derive(Queryable,Selectable)]
|
||||
#[diesel(table_name=schema::salary)]
|
||||
pub struct SalaryRow{
|
||||
pub id: i32,
|
||||
pub worker_id: i32,
|
||||
pub salary_size: rust_decimal::Decimal,
|
||||
pub salary_date: chrono::DateTime<chrono::Local>,
|
||||
}
|
||||
pub struct Salary{
|
||||
id: i32,
|
||||
worker: Worker,
|
||||
salary_size: rust_decimal::Decimal,
|
||||
salary_date: chrono::NaiveDateTime,
|
||||
salary_date: chrono::DateTime<chrono::Local>,
|
||||
}
|
||||
struct Equipment{
|
||||
id: i32,
|
||||
inv_number: String,
|
||||
maintenance_date: chrono::NaiveDateTime,
|
||||
worker: Worker,
|
||||
#[derive(Queryable, Selectable)]
|
||||
#[diesel(table_name= schema::equipment)]
|
||||
pub struct EquipmentRow{
|
||||
pub id: i32,
|
||||
pub name: String,
|
||||
pub inv_number: String,
|
||||
pub maintenance_date: chrono::DateTime<chrono::Local>,
|
||||
pub worker_id: i32,
|
||||
}
|
||||
struct Material{
|
||||
#[derive(Default, Clone, Hash)]
|
||||
pub struct Equipment{
|
||||
pub id: i32,
|
||||
pub name: String,
|
||||
pub inv_number: String,
|
||||
pub maintenance_date: chrono::DateTime<chrono::Local>,
|
||||
pub worker: Worker,
|
||||
}
|
||||
pub struct Material{
|
||||
id: i32,
|
||||
name: String,
|
||||
quantity: i32,
|
||||
category: String
|
||||
}
|
||||
struct RecipeElement{
|
||||
pub struct RecipeElement{
|
||||
id:i32,
|
||||
material: Material,
|
||||
equipment: Equipment,
|
||||
quantity: i32
|
||||
}
|
||||
struct Recipe{
|
||||
pub struct Recipe{
|
||||
id: i32,
|
||||
name: String,
|
||||
elements: std::vec::Vec<RecipeElement>,
|
||||
}
|
||||
struct Client{
|
||||
pub struct Client{
|
||||
id: i32,
|
||||
name: String,
|
||||
address: String
|
||||
}
|
||||
struct Order<'a>{
|
||||
pub struct Order<'a>{
|
||||
id: i32,
|
||||
client: Client,
|
||||
order_date: chrono::NaiveDateTime,
|
||||
order_date: chrono::DateTime<chrono::Local>,
|
||||
total_amount: rust_decimal::Decimal,
|
||||
elements: std::vec::Vec<OrderElement<'a>>
|
||||
}
|
||||
struct OrderElement<'a>{
|
||||
pub struct OrderElement<'a>{
|
||||
id: i32,
|
||||
product: Product<'a>,
|
||||
quantity: i32,
|
||||
total_amount: rust_decimal::Decimal
|
||||
}
|
||||
struct Product<'a>{
|
||||
pub struct Product<'a>{
|
||||
id: i32,
|
||||
recipe: &'a Recipe,
|
||||
volume: f64,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,46 @@
|
|||
use diesel::*;
|
||||
table!{
|
||||
equipment(id){
|
||||
id -> Integer,
|
||||
inv_number -> VarChar,
|
||||
maintenance_date -> Datetime,
|
||||
worker_id -> Integer,
|
||||
name -> VarChar,
|
||||
|
||||
}
|
||||
}
|
||||
table! {
|
||||
salary(id){
|
||||
id -> Integer,
|
||||
worker_id -> Integer,
|
||||
salary_size -> Decimal,
|
||||
salary_date -> Datetime
|
||||
}
|
||||
}
|
||||
table! {
|
||||
position(id){
|
||||
id -> Integer,
|
||||
name -> VarChar,
|
||||
wage -> Decimal
|
||||
}
|
||||
}
|
||||
table! {
|
||||
worker(id){
|
||||
id -> Integer,
|
||||
position_id -> Integer,
|
||||
hire_date -> Datetime,
|
||||
is_fired -> Bool,
|
||||
full_name -> VarChar
|
||||
}
|
||||
}
|
||||
|
||||
joinable!(equipment -> worker(worker_id));
|
||||
joinable!(worker -> position(position_id));
|
||||
joinable!(salary -> worker(worker_id));
|
||||
|
||||
allow_tables_to_appear_in_same_query!(
|
||||
equipment,
|
||||
salary,
|
||||
position,
|
||||
worker,
|
||||
);
|
||||
Loading…
Reference in New Issue