use serde::{Deserialize, Serialize}; use tokio_postgres::Error as PgError; use chrono::NaiveDateTime; #[derive(Debug, Serialize, Deserialize)] pub struct HyAllot { pub id: i32, pub userid: Option, pub username: Option, pub informationid: Option, pub allottime: Option, pub hy_code: Option, pub hy_type: Option, pub hy_method: Option, pub hy_quest: Option, } impl HyAllot { pub async fn insert(&self, client: &tokio_postgres::Client) -> Result<(), PgError> { client .execute( "INSERT INTO public.hy_allot (id, userid, username, informationid, allottime, hy_code, hy_type, hy_method, hy_quest) OVERRIDING SYSTEM VALUE VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)", &[&self.id, &self.userid, &self.username, &self.informationid, &self.allottime, &self.hy_code, &self.hy_type, &self.hy_method, &self.hy_quest], ) .await?; Ok(()) } } #[derive(Debug, Serialize, Deserialize)] pub struct HyFullWaterSample { pub id: i32, pub qs_code: Option, pub qs_tonnage: Option, pub mt: Option, pub remark: Option, pub onecode: Option, pub towcode: Option, pub fx_code: Option, pub fx_onecode: Option, pub fx_twocode: Option, } impl HyFullWaterSample { pub async fn insert(&self, client: &tokio_postgres::Client) -> Result<(), PgError> { client .execute( "INSERT INTO public.hy_fullwatersample (id, qs_code, qs_tonnage, mt, remark, onecode, towcode, fx_code, fx_onecode, fx_twocode) OVERRIDING SYSTEM VALUE VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)", &[&self.id, &self.qs_code, &self.qs_tonnage, &self.mt, &self.remark, &self.onecode, &self.towcode, &self.fx_code, &self.fx_onecode, &self.fx_twocode], ) .await?; Ok(()) } } #[derive(Debug, Serialize, Deserialize)] pub struct HyInformationNorm { pub id: i32, pub information_id: Option, pub hy_id: Option, pub norm_name: Option, pub flag: Option, pub apparatus_id: Option, pub need_compute: Option, pub formula: Option, pub secondformula: Option, pub mapping: Option, pub input_type: Option, pub round: Option, pub sort: Option, } impl HyInformationNorm { pub async fn insert(&self, client: &tokio_postgres::Client) -> Result<(), PgError> { client .execute( "INSERT INTO public.hy_informationnorm (id, information_id, hy_id, norm_name, flag, apparatus_id, need_compute, formula, secondformula, mapping, input_type, round, sort) OVERRIDING SYSTEM VALUE VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13)", &[&self.id, &self.information_id, &self.hy_id, &self.norm_name, &self.flag, &self.apparatus_id, &self.need_compute, &self.formula, &self.secondformula, &self.mapping, &self.input_type, &self.round, &self.sort], ) .await?; Ok(()) } } #[derive(Debug, Serialize, Deserialize)] pub struct HyItemDetail { pub id: i32, pub record_id: Option, pub information_id: Option, pub laboratory_id: Option, pub number: Option, pub cancellation: Option, pub detectionuser: Option, pub detectiontime: Option, pub original_num: Option, pub hy_check: Option, pub checkuser: Option, pub checktime: Option, pub oversize: Option, } impl HyItemDetail { pub async fn insert(&self, client: &tokio_postgres::Client) -> Result<(), PgError> { client .execute( "INSERT INTO public.hy_itemdetail (id, record_id, information_id, laboratory_id, number, cancellation, detectionuser, detectiontime, original_num, hy_check, checkuser, checktime, oversize) OVERRIDING SYSTEM VALUE VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13)", &[&self.id, &self.record_id, &self.information_id, &self.laboratory_id, &self.number, &self.cancellation, &self.detectionuser, &self.detectiontime, &self.original_num, &self.hy_check, &self.checkuser, &self.checktime, &self.oversize], ) .await?; Ok(()) } } #[derive(Debug, Serialize, Deserialize)] pub struct HyLaboratoryInstrument { pub id: i32, pub norm_id: Option, pub instrument_id: Option, } impl HyLaboratoryInstrument { pub async fn insert(&self, client: &tokio_postgres::Client) -> Result<(), PgError> { client .execute( "INSERT INTO public.hy_laboratory_instrument (id, norm_id, instrument_id) OVERRIDING SYSTEM VALUE VALUES ($1, $2, $3)", &[&self.id, &self.norm_id, &self.instrument_id], ) .await?; Ok(()) } } #[derive(Debug, Serialize, Deserialize)] pub struct HyMaterialAnalysisType { pub id: i32, pub name: Option, pub flag: Option, pub sort: Option, pub createtime: Option, pub createuser: Option, } impl HyMaterialAnalysisType { pub async fn insert(&self, client: &tokio_postgres::Client) -> Result<(), PgError> { client .execute( "INSERT INTO public.hy_material_analysis_type (id, name, flag, sort, createtime, createuser) OVERRIDING SYSTEM VALUE VALUES ($1, $2, $3, $4, $5, $6)", &[&self.id, &self.name, &self.flag, &self.sort, &self.createtime, &self.createuser], ) .await?; Ok(()) } } #[derive(Debug, Serialize, Deserialize)] pub struct HyMaterialDetail { pub id: i32, pub name: Option, pub flag: Option, pub sort: Option, pub createtime: Option, pub createuser: Option, pub analysistypeid: Option, pub materialid: Option, } impl HyMaterialDetail { pub async fn insert(&self, client: &tokio_postgres::Client) -> Result<(), PgError> { client .execute( "INSERT INTO public.hy_material_detail (id, name, flag, sort, createtime, createuser, analysistypeid, materialid) OVERRIDING SYSTEM VALUE VALUES ($1, $2, $3, $4, $5, $6, $7, $8)", &[&self.id, &self.name, &self.flag, &self.sort, &self.createtime, &self.createuser, &self.analysistypeid, &self.materialid], ) .await?; Ok(()) } } #[derive(Debug, Serialize, Deserialize)] pub struct HyNorm { pub id: i32, pub norm_id: Option, pub zbvalues: Option, pub itemdetail_id: Option, pub hy_user: Option, pub checktime: Option, pub explain: Option, } impl HyNorm { pub async fn insert(&self, client: &tokio_postgres::Client) -> Result<(), PgError> { client .execute( "INSERT INTO public.hy_norm (id, norm_id, zbvalues, itemdetail_id, hy_user, checktime, explain) OVERRIDING SYSTEM VALUE VALUES ($1, $2, $3, $4, $5, $6, $7)", &[&self.id, &self.norm_id, &self.zbvalues, &self.itemdetail_id, &self.hy_user, &self.checktime, &self.explain], ) .await?; Ok(()) } } #[derive(Debug, Serialize, Deserialize)] pub struct HyWarmHumid { pub id: i32, pub laboratoryid: Option, pub temperature: Option, pub humidity: Option, pub begintime: Option, pub endtime: Option, pub username: Option, } impl HyWarmHumid { pub async fn insert(&self, client: &tokio_postgres::Client) -> Result<(), PgError> { client .execute( "INSERT INTO public.hy_warmhumid (id, laboratoryid, temperature, humidity, begintime, endtime, username) OVERRIDING SYSTEM VALUE VALUES ($1, $2, $3, $4, $5, $6, $7)", &[&self.id, &self.laboratoryid, &self.temperature, &self.humidity, &self.begintime, &self.endtime, &self.username], ) .await?; Ok(()) } } #[derive(Debug, Serialize, Deserialize)] pub struct HyTask { pub id: i32, pub task_name: Option, pub task_type: Option, pub task_num: Option, pub is_auto: Option, pub task_time: Option, pub state: Option, pub create_by: Option, pub create_time: Option, pub update_by: Option, pub update_time: Option, } impl HyTask { pub async fn insert(&self, client: &tokio_postgres::Client) -> Result<(), PgError> { client .execute( "INSERT INTO public.hy_task (id, task_name, task_type, task_num, is_auto, task_time, state, create_by, create_time, update_by, update_time) OVERRIDING SYSTEM VALUE VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)", &[&self.id, &self.task_name, &self.task_type, &self.task_num, &self.is_auto, &self.task_time, &self.state, &self.create_by, &self.create_time, &self.update_by, &self.update_time], ) .await?; Ok(()) } } #[derive(Debug, Serialize, Deserialize)] pub struct HySpotcheck { pub id: i32, pub spotcheck_code: Option, pub spotcheck_user: Option, pub spotcheck_time: Option, pub spotcheck_type: Option, pub coal_sample_code: Option, pub sample_custodian: Option, pub sampling_time: Option, pub quality_incoming: Option, pub granularity: Option, pub spotcheck_compare: Option, pub mt: Option, pub mad: Option, pub aad: f64, // NOT NULL pub ad: Option, pub vad: Option, pub vdaf: Option, pub var_data: Option, pub st_ad: Option, pub st_d: Option, pub qb_ad: Option, pub had: Option, pub qnet_ar: Option, pub qnet_ar1: Option, pub qgr_d: Option, pub qgr_ad: Option, pub vd: Option, pub aar: Option, pub st_ar: Option, pub hd: Option, pub fcad: Option, pub crc: Option, pub st_daf: Option, } impl HySpotcheck { pub async fn insert(&self, client: &tokio_postgres::Client) -> Result<(), PgError> { client .execute( "INSERT INTO public.hy_spotcheck (id, spotcheck_code, spotcheck_user, spotcheck_time, spotcheck_type, coal_sample_code, sample_custodian, sampling_time, quality_incoming, granularity, spotcheck_compare, mt, mad, aad, ad, vad, vdaf, var_data, st_ad, st_d, qb_ad, had, qnet_ar, qnet_ar1, qgr_d, qgr_ad, vd, aar, st_ar, hd, fcad, crc, st_daf) OVERRIDING SYSTEM VALUE VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, $31, $32, $33)", &[&self.id, &self.spotcheck_code, &self.spotcheck_user, &self.spotcheck_time, &self.spotcheck_type, &self.coal_sample_code, &self.sample_custodian, &self.sampling_time, &self.quality_incoming, &self.granularity, &self.spotcheck_compare, &self.mt, &self.mad, &self.aad, &self.ad, &self.vad, &self.vdaf, &self.var_data, &self.st_ad, &self.st_d, &self.qb_ad, &self.had, &self.qnet_ar, &self.qnet_ar1, &self.qgr_d, &self.qgr_ad, &self.vd, &self.aar, &self.st_ar, &self.hd, &self.fcad, &self.crc, &self.st_daf], ) .await?; Ok(()) } } #[derive(Debug, Serialize, Deserialize)] pub struct HyWeightInput { pub id: i32, pub information_id: i32, pub information_norm_id: i32, } impl HyWeightInput { pub async fn insert(&self, client: &tokio_postgres::Client) -> Result<(), PgError> { client .execute( "INSERT INTO public.hy_weight_input (id, information_id, information_norm_id) OVERRIDING SYSTEM VALUE VALUES ($1, $2, $3)", &[&self.id, &self.information_id, &self.information_norm_id], ) .await?; Ok(()) } } #[derive(Debug, Deserialize)] pub struct InstrumentInfo { pub id: i32, pub laboratoryid: Option, pub name: Option, pub instrumentcode: Option, pub informationid: Option, pub specification: Option, pub remark: Option, } impl InstrumentInfo { pub async fn insert(&self, client: &tokio_postgres::Client) -> Result<(), PgError> { client .execute( "INSERT INTO public.hy_instrument (id, laboratoryid, name, instrumentcode, informationid, specification, remark) OVERRIDING SYSTEM VALUE VALUES ($1, $2, $3, $4, $5, $6, $7)", &[&self.id, &self.laboratoryid, &self.name, &self.instrumentcode, &self.informationid, &self.specification, &self.remark], ) .await?; Ok(()) } } #[derive(Debug, Serialize, Deserialize)] pub struct HyInformation { pub id: i32, pub hy_name: Option, pub flag: Option, pub laboratory_id: Option, pub analysistypeid: Option, } impl HyInformation { pub async fn insert(&self, client: &tokio_postgres::Client) -> Result<(), PgError> { client .execute( "INSERT INTO public.hy_information (id, hy_name, flag, laboratory_id, analysistypeid) OVERRIDING SYSTEM VALUE VALUES ($1, $2, $3, $4, $5)", &[&self.id, &self.hy_name, &self.flag, &self.laboratory_id, &self.analysistypeid], ) .await?; Ok(()) } } #[derive(Debug, Serialize, Deserialize)] pub struct HyCyTask { pub id: i32, pub task_id: Option, pub task_name: Option, pub task_status: Option, pub create_time: Option, pub create_user: Option, pub remark: Option, } impl HyCyTask { pub async fn insert(&self, client: &tokio_postgres::Client) -> Result<(), PgError> { client .execute( "INSERT INTO public.hy_cytask (id, task_id, task_name, task_status, create_time, create_user, remark) OVERRIDING SYSTEM VALUE VALUES ($1, $2, $3, $4, $5, $6, $7)", &[&self.id, &self.task_id, &self.task_name, &self.task_status, &self.create_time, &self.create_user, &self.remark], ) .await?; Ok(()) } } #[derive(Debug, Serialize, Deserialize)] pub struct HyRecord { #[serde(skip_deserializing)] pub id: i32, pub hy_code: Option, pub hy_type: Option, pub hy_check: Option, pub hy_approve: Option, pub check_time: Option, pub approve_time: Option, pub approve_user: Option, pub check_user: Option, pub hy_time: Option, pub hy_values: Option, pub accept_time: Option, pub accept_user: Option, pub mt: Option, pub mad: Option, pub aad: Option, pub ad: Option, pub vad: Option, pub vd: Option, pub var_data: Option, pub vdaf: Option, pub fcad: Option, pub st_ar: Option, pub st_ad: Option, pub st_d: Option, pub had: Option, pub hd: Option, pub qb_ad: Option, pub qgr_ad: Option, pub qgr_d: Option, pub qnet_ar_mj_kg: Option, pub qnet_ar_j_cal: Option, pub v: Option, pub aar: Option, pub qnet_ar: Option, pub qnet_ar1: Option, pub crc: Option, pub st_daf: Option, pub cad: Option, pub cd: Option, pub isauto: Option, pub isnormal: Option, } impl HyRecord { pub async fn insert(&self, client: &tokio_postgres::Client) -> Result<(), PgError> { client .execute( "INSERT INTO public.hy_record (hy_code, hy_type, hy_check, hy_approve, check_time, approve_time, approve_user, check_user, hy_time, hy_values, accept_time, accept_user, mt, mad, aad, ad, vad, vd, var, vdaf, fcad, st_ar, st_ad, st_d, had, hd, qb_ad, qgr_ad, qgr_d, qnet_ar_mj_kg, qnet_ar_j_cal, v, aar, qnet_ar, qnet_ar1, crc, st_daf, cad, cd, isauto, isnormal) OVERRIDING SYSTEM VALUE VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, $31, $32, $33, $34, $35, $36, $37, $38, $39, $40, $41)", &[&self.hy_code, &self.hy_type, &self.hy_check, &self.hy_approve, &self.check_time, &self.approve_time, &self.approve_user, &self.check_user, &self.hy_time, &self.hy_values, &self.accept_time, &self.accept_user, &self.mt, &self.mad, &self.aad, &self.ad, &self.vad, &self.vd, &self.var_data, &self.vdaf, &self.fcad, &self.st_ar, &self.st_ad, &self.st_d, &self.had, &self.hd, &self.qb_ad, &self.qgr_ad, &self.qgr_d, &self.qnet_ar_mj_kg, &self.qnet_ar_j_cal, &self.v, &self.aar, &self.qnet_ar, &self.qnet_ar1, &self.crc, &self.st_daf, &self.cad, &self.cd, &self.isauto, &self.isnormal], ) .await?; Ok(()) } } #[derive(Debug, Serialize, Deserialize)] pub struct HySampleCollectionDetail { pub id: i32, pub num: i32, pub unit_num: i32, pub time: Option, pub type_: Option, pub sy_method: Option, pub sy_time: Option, pub one_num: Option, pub two_num: Option, pub three_num: Option, pub sy_starttime: Option, pub sy_endtime: Option, pub cy_startnum: Option, pub cy_endnum: Option, pub sy_user: Option, pub sy_car_count: Option, pub sy_dun_weight: Option, pub byz_bag_count: Option, pub y_liu: Option, pub zy_user: Option, } impl HySampleCollectionDetail { pub async fn insert(&self, client: &tokio_postgres::Client) -> Result<(), PgError> { client .execute( "INSERT INTO public.hy_sample_collection_detail (id, num, unit_num, time, type, sy_method, sy_time, one_num, two_num, three_num, sy_starttime, sy_endtime, cy_startnum, cy_endnum, sy_user, sy_car_count, sy_dun_weight, byz_bag_count, y_liu, zy_user) OVERRIDING SYSTEM VALUE VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20)", &[&self.id, &self.num, &self.unit_num, &self.time, &self.type_, &self.sy_method, &self.sy_time, &self.one_num, &self.two_num, &self.three_num, &self.sy_starttime, &self.sy_endtime, &self.cy_startnum, &self.cy_endnum, &self.sy_user, &self.sy_car_count, &self.sy_dun_weight, &self.byz_bag_count, &self.y_liu, &self.zy_user], ) .await?; Ok(()) } }