Ver código fonte

增加erp_matl_material

晋江
OCEAN 1 mês atrás
pai
commit
835fe5c9d4
6 arquivos alterados com 128 adições e 14 exclusões
  1. +4
    -5
      tcp_client/config.toml
  2. +13
    -8
      tcp_client/config_send.toml
  3. +1
    -1
      tcp_server/config.toml
  4. +110
    -0
      tcp_server/src/main.rs
  5. BIN
      tcp_server/target/debug/tcp_server.exe
  6. BIN
      tcp_server/target/debug/tcp_server.pdb

+ 4
- 5
tcp_client/config.toml Ver arquivo

@@ -15,15 +15,14 @@ retry_delay_secs = 2
[database]
host = "10.180.4.100"
port = 5432
name = "Auseft_old"
name = "Auseft_RL_Web"
user = "postgres"
password = "Auseft@2025qwer"

# 要同步的表配置


[[tables]]
name = "erp_co_supply"
query = "SELECT id, tenant_id, category_id, company_id, code, name, abbreviate, transport_type, departure_name, departure_address, departure_longitude::text as departure_longitude, departure_latitude::text as departure_latitude, destination_name, destination_address, destination_longitude::text as destination_longitude, destination_latitude::text as destination_latitude, sort, extra_properties, description, status, enabled, enabler_id, enablement_time, creator_id, creation_time, last_modifier_id, last_modification_time, deleted, deleter_id, deletion_time FROM public.erp_co_supply"
name = "erp_shipping_plan"
query = "SELECT id, cust_id, material_id, plan_type, plan_start_date, plan_end_date, plan_days, plan_quantity::text as plan_quantity, through_put::text as through_put, calorific_value::text as calorific_value, sulfur_content::text as sulfur_content, transport_vehicles, sample_code, batch_code, update_by, update_time, review, review_by, review_date, cancel, cancel_by, cancel_time, remarks, plan_number, order_number, warehouse_id, order_type, cust_name, material_name, plan_name, warehouse_name FROM public.erp_shipping_plan"
incremental = false
key_field = "UpdateTime"
key_field = "UpdateTime"

+ 13
- 8
tcp_client/config_send.toml Ver arquivo

@@ -20,9 +20,11 @@ user = "postgres"
password = "Auseft@2025qwer"

# 要同步的表配置


[[tables]]
name = "comm_bm_vehicleinfo"
query = "SELECT id, licenseplate, type, grosswt::text as grosswt, tarewt::text as tarewt, owner, dl, supervision, outage, insurancedate, insurancenum, lock, transcompany, createdby, creationtime, modifiedby, modifiedtime, reviewed, reviewedby, reviewedtime, remarks, phonenumber, electronicnumber, rfidmodifiedtime, rfidstop, rfidstopby, rfidstoptime, rfidgrantby, rfidgranttime, samplingpoints, drawbar, carriagelength::text as carriagelength , carriagewidth::text as carriagewidth, carriageheight::text as carriageheight, underbodyheight::text as underbodyheight, frontsampling, backsampling, rod1::text as rod1, rod2::text as rod2, rod3::text as rod3, rod4::text as rod4, rod5::text as rod5, rod6::text as rod6, supplier_id, supplier_name, material_id, material_name FROM public.comm_bm_vehicleinfo"
name = "erp_matl_material"
query = "SELECT id, tenant_id, category_id, code, name, manufacturer, model, specification, color, unit, warehouse_id, expiration_date, expiration_date_unit, sort, extra_properties, description, status, enabled, enabler_id, enablement_time, creator_id, creation_time, last_modifier_id, last_modification_time, deleted, deleter_id, deletion_time FROM public.erp_matl_material"
incremental = false
key_field = "UpdateTime"

@@ -34,23 +36,26 @@ incremental = false
key_field = "UpdateTime"

[[tables]]
name = "erp_matl_material"
query = "SELECT id, tenant_id, category_id, code, name, manufacturer, model, specification, color, unit, warehouse_id, expiration_date, expiration_date_unit, sort, extra_properties, description, status, enabled, enabler_id, enablement_time, creator_id, creation_time, last_modifier_id, last_modification_time, deleted, deleter_id, deletion_time FROM public.erp_matl_material"
name = "comm_bm_vehicleinfo"
query = "SELECT id, licenseplate, type, grosswt::text as grosswt, tarewt::text as tarewt, owner, dl, supervision, outage, insurancedate, insurancenum, lock, transcompany, createdby, creationtime, modifiedby, modifiedtime, reviewed, reviewedby, reviewedtime, remarks, phonenumber, electronicnumber, rfidmodifiedtime, rfidstop, rfidstopby, rfidstoptime, rfidgrantby, rfidgranttime, samplingpoints, drawbar, carriagelength::text as carriagelength , carriagewidth::text as carriagewidth, carriageheight::text as carriageheight, underbodyheight::text as underbodyheight, frontsampling, backsampling, rod1::text as rod1, rod2::text as rod2, rod3::text as rod3, rod4::text as rod4, rod5::text as rod5, rod6::text as rod6, supplier_id, supplier_name, material_id, material_name FROM public.comm_bm_vehicleinfo"
incremental = false
key_field = "UpdateTime"


[[tables]]
name = "erp_shipping_details"
query = "SELECT id, plan_id, vehicle_id, vehicle_number, gross_weight::text as gross_weight, tare_weight::text as tare_weight, net_weight::text as net_weight, card_number, appointment_number, appointment_time, appointment_weight::text as appointment_weight, is_cancel, is_end, driver_phone, remarks, create_time, create_by, update_time, update_by FROM public.erp_shipping_details"
name = "erp_shipping_plan"
query = "SELECT id, cust_id, material_id, plan_type, plan_start_date, plan_end_date, plan_days, plan_quantity::text as plan_quantity, through_put::text as through_put, calorific_value::text as calorific_value, sulfur_content::text as sulfur_content, transport_vehicles, sample_code, batch_code, update_by, update_time, review, review_by, review_date, cancel, cancel_by, cancel_time, remarks, plan_number, order_number, warehouse_id, order_type, cust_name, material_name, plan_name, warehouse_name FROM public.erp_shipping_plan"
incremental = false
key_field = "UpdateTime"

[[tables]]
name = "erp_shipping_plan"
query = "SELECT id, cust_id, material_id, plan_type, plan_start_date, plan_end_date, plan_days, plan_quantity::text as plan_quantity, through_put::text as through_put, calorific_value::text as calorific_value, sulfur_content::text as sulfur_content, transport_vehicles, sample_code, batch_code, update_by, update_time, review, review_by, review_date, cancel, cancel_by, cancel_time, remarks, plan_number, order_number, warehouse_id, order_type, cust_name, material_name, plan_name, warehouse_name FROM public.erp_shipping_plan"
name = "erp_shipping_details"
query = "SELECT id, plan_id, vehicle_id, vehicle_number, gross_weight::text as gross_weight, tare_weight::text as tare_weight, net_weight::text as net_weight, card_number, appointment_number, appointment_time, appointment_weight::text as appointment_weight, is_cancel, is_end, driver_phone, remarks, create_time, create_by, update_time, update_by FROM public.erp_shipping_details"
incremental = false
key_field = "UpdateTime"



[[tables]]
name = "erp_total_shipping_plan"
query = "SELECT id, order_number, start_time, end_time, finish, ship_name, voyage, total_quantity::text as total_quantity, deviation_quantity::text as deviation_quantity, supplier_code, supplier_name, material_code, material_name, shipping_station_code, shipping_station_name, departure_port, departure_time, port_destination, berthing_time, supplier_id, material_id FROM public.erp_total_shipping_plan"


+ 1
- 1
tcp_server/config.toml Ver arquivo

@@ -5,6 +5,6 @@ port = 9090
[database]
host = "10.180.4.100"
port = 5432
name = "Auseft_new_web_20250514"
name = "Auseft_old"
user = "postgres"
password = "Auseft@2025qwer"

+ 110
- 0
tcp_server/src/main.rs Ver arquivo

@@ -500,6 +500,39 @@ struct ErpCoSupply {
deletion_time: Option<NaiveDateTime>
}

#[derive(Debug, Deserialize)]
struct ErpMatlMaterial {
id: i64,
tenant_id: Option<i64>,
category_id: i64,
code: String,
name: String,
manufacturer: Option<String>,
model: Option<String>,
specification: Option<String>,
color: Option<String>,
unit: Option<String>,
warehouse_id: Option<i64>,
expiration_date: Option<i32>,
expiration_date_unit: Option<String>,
sort: Option<i64>,
extra_properties: Option<String>,
description: Option<String>,
status: Option<i32>,
#[serde(deserialize_with = "deserialize_string_to_bool")]
enabled: bool,
enabler_id: Option<i64>,
enablement_time: Option<NaiveDateTime>,
creator_id: Option<i64>,
creation_time: NaiveDateTime,
last_modifier_id: Option<i64>,
last_modification_time: Option<NaiveDateTime>,
#[serde(deserialize_with = "deserialize_string_to_bool")]
deleted: bool,
deleter_id: Option<i64>,
deletion_time: Option<NaiveDateTime>
}

#[derive(Debug, Deserialize)]
struct CommBmVehicleinfo {
id: i32,
@@ -808,6 +841,68 @@ async fn insert_erp_co_supply(client: &tokio_postgres::Client, info: &ErpCoSuppl
Ok(())
}

async fn insert_erp_matl_material(client: &tokio_postgres::Client, info: &ErpMatlMaterial) -> Result<(), PgError> {
// Check if record exists
let exists = client
.query_one(
"SELECT COUNT(*) FROM public.erp_matl_material WHERE id = $1",
&[&info.id]
)
.await?
.get::<_, i64>(0) > 0;

if exists {
// Update existing record
client.execute(
"UPDATE public.erp_matl_material SET
tenant_id = $2, category_id = $3, code = $4, name = $5,
manufacturer = $6, model = $7, specification = $8, color = $9,
unit = $10, warehouse_id = $11, expiration_date = $12,
expiration_date_unit = $13, sort = $14, extra_properties = $15,
description = $16, status = $17, enabled = $18, enabler_id = $19,
enablement_time = $20, creator_id = $21, creation_time = $22,
last_modifier_id = $23, last_modification_time = $24, deleted = $25,
deleter_id = $26, deletion_time = $27
WHERE id = $1",
&[
&info.id, &info.tenant_id, &info.category_id, &info.code,
&info.name, &info.manufacturer, &info.model, &info.specification,
&info.color, &info.unit, &info.warehouse_id, &info.expiration_date,
&info.expiration_date_unit, &info.sort, &info.extra_properties,
&info.description, &info.status, &info.enabled, &info.enabler_id,
&info.enablement_time, &info.creator_id, &info.creation_time,
&info.last_modifier_id, &info.last_modification_time, &info.deleted,
&info.deleter_id, &info.deletion_time
],
).await?;
} else {
// Insert new record
client.execute(
"INSERT INTO public.erp_matl_material (
id, tenant_id, category_id, code, name, manufacturer, model,
specification, color, unit, warehouse_id, expiration_date,
expiration_date_unit, sort, extra_properties, description,
status, enabled, enabler_id, enablement_time, creator_id,
creation_time, last_modifier_id, last_modification_time,
deleted, deleter_id, deletion_time
) 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)",
&[
&info.id, &info.tenant_id, &info.category_id, &info.code,
&info.name, &info.manufacturer, &info.model, &info.specification,
&info.color, &info.unit, &info.warehouse_id, &info.expiration_date,
&info.expiration_date_unit, &info.sort, &info.extra_properties,
&info.description, &info.status, &info.enabled, &info.enabler_id,
&info.enablement_time, &info.creator_id, &info.creation_time,
&info.last_modifier_id, &info.last_modification_time, &info.deleted,
&info.deleter_id, &info.deletion_time
],
).await?;
}
Ok(())
}

async fn insert_vehicle_info(client: &tokio_postgres::Client, info: &CommBmVehicleinfo) -> Result<(), PgError> {
let exists = client
.query_one(
@@ -2037,6 +2132,21 @@ async fn handle_client(socket: &mut TcpStream, client: &tokio_postgres::Client)
false
}
},
"erp_matl_material" => {
if let Ok(info) = serde_json::from_str::<ErpMatlMaterial>(data_str) {
println!("接收到物料信息: {:?}", info);
match insert_erp_matl_material(client, &info).await {
Ok(_) => true,
Err(e) => {
eprintln!("插入物料信息失败: {}", e);
false
}
}
} else {
eprintln!("解析物料信息失败");
false
}
},
_ => {
eprintln!("未知的表名: {}", table_name);
false


BIN
tcp_server/target/debug/tcp_server.exe Ver arquivo


BIN
tcp_server/target/debug/tcp_server.pdb Ver arquivo


Carregando…
Cancelar
Salvar