оно не работает, но так ему и надо
parent
e22964a1b6
commit
5139defcb4
|
|
@ -6,3 +6,4 @@ target
|
||||||
*.pdb
|
*.pdb
|
||||||
|
|
||||||
**/mutants.out*/
|
**/mutants.out*/
|
||||||
|
.env
|
||||||
|
|
@ -687,6 +687,7 @@ version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"diesel",
|
"diesel",
|
||||||
|
"dotenv",
|
||||||
"eframe",
|
"eframe",
|
||||||
"egui",
|
"egui",
|
||||||
"egui_dock",
|
"egui_dock",
|
||||||
|
|
@ -928,6 +929,12 @@ dependencies = [
|
||||||
"litrs",
|
"litrs",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "dotenv"
|
||||||
|
version = "0.15.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "downcast-rs"
|
name = "downcast-rs"
|
||||||
version = "1.2.1"
|
version = "1.2.1"
|
||||||
|
|
@ -3080,11 +3087,22 @@ dependencies = [
|
||||||
"num-traits",
|
"num-traits",
|
||||||
"rand",
|
"rand",
|
||||||
"rkyv",
|
"rkyv",
|
||||||
|
"rust_decimal_macros",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"wasm-bindgen",
|
"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]]
|
[[package]]
|
||||||
name = "rustc-hash"
|
name = "rustc-hash"
|
||||||
version = "1.1.0"
|
version = "1.1.0"
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,9 @@ edition = "2024"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
chrono = { version = "0.4.44", features = ["serde"] }
|
chrono = { version = "0.4.44", features = ["serde"] }
|
||||||
diesel = { version = "2.3.9", features = ["mysql", "chrono"] }
|
diesel = { version = "2.3.9", features = ["mysql", "chrono"] }
|
||||||
|
dotenv = "0.15.0"
|
||||||
eframe = "0.34.2"
|
eframe = "0.34.2"
|
||||||
egui = "0.34.2"
|
egui = "0.34.2"
|
||||||
egui_dock = "0.19.1"
|
egui_dock = "0.19.1"
|
||||||
egui_extras = "0.34.2"
|
egui_extras = "0.34.2"
|
||||||
rust_decimal = "1.42.0"
|
rust_decimal = {version = "1.42.0", features = ["macros"]}
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@ struct Tab{
|
||||||
tab_type: TabTypes,
|
tab_type: TabTypes,
|
||||||
title: String,
|
title: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct App{
|
pub struct App{
|
||||||
tree: egui_dock::DockState<Tab>,
|
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){
|
fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame){
|
||||||
DockArea::new(&mut self.tree)
|
DockArea::new(&mut self.tree)
|
||||||
.style(Style::from_egui(ui.style().as_ref()))
|
.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{
|
impl MainTabViewer{
|
||||||
fn show_equipment(&mut self, ui: &mut egui::Ui){
|
fn show_equipment(&mut self, ui: &mut egui::Ui){
|
||||||
use egui_extras::{Column,TableBuilder};
|
// use egui_extras::{Column,TableBuilder};
|
||||||
let text_height =egui::TextStyle::Body.resolve(ui.style()).size;
|
// let text_height =egui::TextStyle::Body.resolve(ui.style()).size;
|
||||||
let available_heigh = ui.available_height();
|
// let available_heigh = ui.available_height();
|
||||||
let mut table = TableBuilder::new(ui)
|
// let mut table = TableBuilder::new(ui)
|
||||||
.striped(true)
|
// .striped(true)
|
||||||
.resizable(false)
|
// .resizable(false)
|
||||||
.cell_layout(egui::Layout::left_to_right(egui::Align::Center))
|
// .cell_layout(egui::Layout::left_to_right(egui::Align::Center))
|
||||||
.column(Column::auto())
|
// .column(Column::auto())
|
||||||
.column(Column::remainder()
|
// .column(Column::remainder()
|
||||||
.at_least(40.0)
|
// .at_least(40.0)
|
||||||
.clip(true)
|
// .clip(true)
|
||||||
.resizable(true),
|
// .resizable(true),
|
||||||
)
|
// )
|
||||||
.column(Column::auto())
|
// .column(Column::auto())
|
||||||
.column(Column::remainder())
|
// .column(Column::remainder())
|
||||||
.column(Column::remainder())
|
// .column(Column::remainder())
|
||||||
.min_scrolled_height(0.0)
|
// .min_scrolled_height(0.0)
|
||||||
.max_scroll_height(available_heigh);
|
// .max_scroll_height(available_heigh);
|
||||||
table = table.sense(egui::Sense::click());
|
// 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")]
|
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||||
mod app;
|
mod app;
|
||||||
mod models;
|
mod models;
|
||||||
|
mod database;
|
||||||
|
mod schema;
|
||||||
fn main() -> eframe::Result{
|
fn main() -> eframe::Result{
|
||||||
|
database::estabilish_connection();
|
||||||
let native_opts = eframe::NativeOptions {
|
let native_opts = eframe::NativeOptions {
|
||||||
viewport: egui::ViewportBuilder::default()
|
viewport: egui::ViewportBuilder::default()
|
||||||
.with_inner_size([400.0,300.0])
|
.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,
|
id: i32,
|
||||||
name: String,
|
name: String,
|
||||||
wage: rust_decimal::Decimal,
|
wage: rust_decimal::Decimal,
|
||||||
}
|
}
|
||||||
struct Worker{
|
#[derive(Queryable,Selectable)]
|
||||||
id: i32,
|
#[diesel(table_name=schema::worker)]
|
||||||
full_name: String,
|
pub struct WorkerRow{
|
||||||
hire_date: chrono::NaiveDateTime,
|
pub id:i32,
|
||||||
position: Position,
|
pub full_name: String,
|
||||||
is_fired: bool,
|
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,
|
id: i32,
|
||||||
worker: Worker,
|
worker: Worker,
|
||||||
salary_size: rust_decimal::Decimal,
|
salary_size: rust_decimal::Decimal,
|
||||||
salary_date: chrono::NaiveDateTime,
|
salary_date: chrono::DateTime<chrono::Local>,
|
||||||
}
|
}
|
||||||
struct Equipment{
|
#[derive(Queryable, Selectable)]
|
||||||
id: i32,
|
#[diesel(table_name= schema::equipment)]
|
||||||
inv_number: String,
|
pub struct EquipmentRow{
|
||||||
maintenance_date: chrono::NaiveDateTime,
|
pub id: i32,
|
||||||
worker: Worker,
|
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,
|
id: i32,
|
||||||
name: String,
|
name: String,
|
||||||
quantity: i32,
|
quantity: i32,
|
||||||
category: String
|
category: String
|
||||||
}
|
}
|
||||||
struct RecipeElement{
|
pub struct RecipeElement{
|
||||||
id:i32,
|
id:i32,
|
||||||
material: Material,
|
material: Material,
|
||||||
equipment: Equipment,
|
equipment: Equipment,
|
||||||
quantity: i32
|
quantity: i32
|
||||||
}
|
}
|
||||||
struct Recipe{
|
pub struct Recipe{
|
||||||
id: i32,
|
id: i32,
|
||||||
name: String,
|
name: String,
|
||||||
elements: std::vec::Vec<RecipeElement>,
|
elements: std::vec::Vec<RecipeElement>,
|
||||||
}
|
}
|
||||||
struct Client{
|
pub struct Client{
|
||||||
id: i32,
|
id: i32,
|
||||||
name: String,
|
name: String,
|
||||||
address: String
|
address: String
|
||||||
}
|
}
|
||||||
struct Order<'a>{
|
pub struct Order<'a>{
|
||||||
id: i32,
|
id: i32,
|
||||||
client: Client,
|
client: Client,
|
||||||
order_date: chrono::NaiveDateTime,
|
order_date: chrono::DateTime<chrono::Local>,
|
||||||
total_amount: rust_decimal::Decimal,
|
total_amount: rust_decimal::Decimal,
|
||||||
elements: std::vec::Vec<OrderElement<'a>>
|
elements: std::vec::Vec<OrderElement<'a>>
|
||||||
}
|
}
|
||||||
struct OrderElement<'a>{
|
pub struct OrderElement<'a>{
|
||||||
id: i32,
|
id: i32,
|
||||||
product: Product<'a>,
|
product: Product<'a>,
|
||||||
quantity: i32,
|
quantity: i32,
|
||||||
total_amount: rust_decimal::Decimal
|
total_amount: rust_decimal::Decimal
|
||||||
}
|
}
|
||||||
struct Product<'a>{
|
pub struct Product<'a>{
|
||||||
id: i32,
|
id: i32,
|
||||||
recipe: &'a Recipe,
|
recipe: &'a Recipe,
|
||||||
volume: f64,
|
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