|
|
@@ -571,6 +571,139 @@ struct ErpShippingPlan { |
|
|
|
warehouse_name: Option<String> |
|
|
|
} |
|
|
|
|
|
|
|
#[derive(Debug, Deserialize)] |
|
|
|
struct WtWeightInfo { |
|
|
|
id: i32, |
|
|
|
unit_id: Option<i32>, |
|
|
|
materiel_id: Option<i32>, |
|
|
|
weigh_type: i32, |
|
|
|
associated_order_id: Option<i32>, |
|
|
|
warehouse_id: Option<i32>, |
|
|
|
receive_company_id: Option<i32>, |
|
|
|
transit_company_id: Option<i32>, |
|
|
|
vehicle_id: Option<i32>, |
|
|
|
bill_no: String, |
|
|
|
supply_id: Option<i32>, |
|
|
|
card_no: Option<String>, |
|
|
|
rfid_no: Option<String>, |
|
|
|
vehicle_no: String, |
|
|
|
order_no: Option<String>, |
|
|
|
ship_type: Option<i32>, |
|
|
|
issued_device_no: Option<String>, |
|
|
|
issued_by: Option<String>, |
|
|
|
issued_time: Option<NaiveDateTime>, |
|
|
|
sample_device_no: Option<String>, |
|
|
|
sample_by: Option<String>, |
|
|
|
sample_time: Option<NaiveDateTime>, |
|
|
|
#[serde(deserialize_with = "deserialize_option_decimal")] |
|
|
|
gw: Option<Decimal>, |
|
|
|
gw_scale_no: Option<String>, |
|
|
|
gw_time: Option<NaiveDateTime>, |
|
|
|
gw_by: Option<String>, |
|
|
|
accept_by: Option<String>, |
|
|
|
accept_time: Option<NaiveDateTime>, |
|
|
|
#[serde(deserialize_with = "deserialize_option_decimal")] |
|
|
|
t: Option<Decimal>, |
|
|
|
t_scale_no: Option<String>, |
|
|
|
t_time: Option<NaiveDateTime>, |
|
|
|
t_by: Option<String>, |
|
|
|
review_by: Option<String>, |
|
|
|
review_time: Option<NaiveDateTime>, |
|
|
|
#[serde(deserialize_with = "deserialize_option_decimal")] |
|
|
|
deduction: Option<Decimal>, |
|
|
|
#[serde(deserialize_with = "deserialize_option_decimal")] |
|
|
|
nw: Option<Decimal>, |
|
|
|
#[serde(deserialize_with = "deserialize_option_decimal")] |
|
|
|
aw: Option<Decimal>, |
|
|
|
card_return_time: Option<NaiveDateTime>, |
|
|
|
flow_id: Option<i32>, |
|
|
|
#[serde(deserialize_with = "deserialize_string_to_bool")] |
|
|
|
is_invoice: bool, |
|
|
|
#[serde(deserialize_with = "deserialize_string_to_bool")] |
|
|
|
is_end: bool, |
|
|
|
#[serde(deserialize_with = "deserialize_string_to_bool")] |
|
|
|
is_cancel: bool, |
|
|
|
cancel_by: Option<String>, |
|
|
|
cancel_time: Option<NaiveDateTime>, |
|
|
|
#[serde(deserialize_with = "deserialize_string_to_bool")] |
|
|
|
is_manual_data: bool, |
|
|
|
first_identify_vehicle_no: Option<String>, |
|
|
|
second_identify_vehicle_no: Option<String>, |
|
|
|
comment: Option<String>, |
|
|
|
#[serde(deserialize_with = "deserialize_string_to_bool")] |
|
|
|
is_inbound: bool, |
|
|
|
#[serde(deserialize_with = "deserialize_string_to_bool")] |
|
|
|
is_outbound: bool, |
|
|
|
#[serde(deserialize_with = "deserialize_string_to_bool")] |
|
|
|
is_settle_and_review: bool, |
|
|
|
#[serde(deserialize_with = "deserialize_string_to_bool")] |
|
|
|
is_settle: bool, |
|
|
|
settle_id: Option<i32>, |
|
|
|
settle_time: Option<NaiveDateTime>, |
|
|
|
vehicle_and_vessel_no: Option<String>, |
|
|
|
shipping_location: Option<String>, |
|
|
|
destination: Option<String>, |
|
|
|
entry_no: Option<String>, |
|
|
|
batch_no: Option<String>, |
|
|
|
lane_id: Option<i32>, |
|
|
|
queue_id: Option<i32>, |
|
|
|
#[serde(deserialize_with = "deserialize_option_decimal")] |
|
|
|
tax_rate: Option<Decimal>, |
|
|
|
#[serde(deserialize_with = "deserialize_option_decimal")] |
|
|
|
itax_unit_price: Option<Decimal>, |
|
|
|
#[serde(deserialize_with = "deserialize_option_decimal")] |
|
|
|
iunit_price: Option<Decimal>, |
|
|
|
operate_time: Option<NaiveDateTime>, |
|
|
|
#[serde(deserialize_with = "deserialize_string_to_bool")] |
|
|
|
is_special_batch: bool, |
|
|
|
#[serde(deserialize_with = "deserialize_option_decimal")] |
|
|
|
total: Option<Decimal>, |
|
|
|
arrival_time: Option<NaiveDateTime>, |
|
|
|
leave_time: Option<NaiveDateTime>, |
|
|
|
ash_start_time: Option<NaiveDateTime>, |
|
|
|
#[serde(deserialize_with = "deserialize_string_to_bool")] |
|
|
|
is_rejected: bool, |
|
|
|
train_shipping_detail_id: Option<i32>, |
|
|
|
#[serde(deserialize_with = "deserialize_string_to_bool")] |
|
|
|
sample1_collection: bool, |
|
|
|
sample1_collection_id: Option<i32>, |
|
|
|
#[serde(deserialize_with = "deserialize_string_to_bool")] |
|
|
|
sample2_collection: bool, |
|
|
|
samplecard1: Option<String>, |
|
|
|
samplecard2: Option<String>, |
|
|
|
cabno1: Option<i32>, |
|
|
|
cabno2: Option<i32>, |
|
|
|
entry_time2: Option<NaiveDateTime>, |
|
|
|
cab2_card: Option<String>, |
|
|
|
entry_time1: Option<NaiveDateTime>, |
|
|
|
cab1_card: Option<String>, |
|
|
|
sampleout_time1: Option<NaiveDateTime>, |
|
|
|
sampleout_time2: Option<NaiveDateTime>, |
|
|
|
sample2_collection_id: Option<i32>, |
|
|
|
supply_id_name: Option<String>, |
|
|
|
sample_type: Option<i32>, |
|
|
|
sample_code: Option<String>, |
|
|
|
#[serde(deserialize_with = "deserialize_string_to_bool")] |
|
|
|
sample_done: bool, |
|
|
|
load_type: Option<i32>, |
|
|
|
#[serde(deserialize_with = "deserialize_option_decimal")] |
|
|
|
load_weight: Option<Decimal>, |
|
|
|
sample1_incab_by: Option<String>, |
|
|
|
sample2_incab_by: Option<String>, |
|
|
|
cabname1: Option<String>, |
|
|
|
cabname2: Option<String>, |
|
|
|
samplepoint: Option<String>, |
|
|
|
#[serde(deserialize_with = "deserialize_string_to_bool")] |
|
|
|
is_reviewed: bool, |
|
|
|
#[serde(deserialize_with = "deserialize_option_decimal")] |
|
|
|
deduction1: Option<Decimal>, |
|
|
|
#[serde(deserialize_with = "deserialize_option_decimal")] |
|
|
|
deduction2: Option<Decimal>, |
|
|
|
material_name: Option<String>, |
|
|
|
#[serde(deserialize_with = "deserialize_string_to_bool")] |
|
|
|
is_accept_and_receive: bool |
|
|
|
} |
|
|
|
|
|
|
|
#[derive(Debug, Deserialize)] |
|
|
|
struct ErpTotalShippingPlan { |
|
|
|
id: i32, |
|
|
@@ -1091,6 +1224,152 @@ where |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
async fn insert_wt_weight_info(client: &tokio_postgres::Client, info: &WtWeightInfo) -> Result<(), PgError> { |
|
|
|
// Check if record exists using bill_no and vehicle_no |
|
|
|
let exists = client |
|
|
|
.query_one( |
|
|
|
"SELECT COUNT(*) FROM public.wt_weight_info WHERE id=$1", |
|
|
|
&[&info.id] |
|
|
|
) |
|
|
|
.await? |
|
|
|
.get::<_, i64>(0) > 0; |
|
|
|
|
|
|
|
if exists { |
|
|
|
// Update existing record |
|
|
|
client.execute( |
|
|
|
"UPDATE public.wt_weight_info SET |
|
|
|
unit_id = $1, materiel_id = $2, weigh_type = $3, associated_order_id = $4, |
|
|
|
warehouse_id = $5, receive_company_id = $6, transit_company_id = $7, |
|
|
|
vehicle_id = $8, supply_id = $9, card_no = $10, rfid_no = $11, |
|
|
|
order_no = $12, ship_type = $13, issued_device_no = $14, issued_by = $15, |
|
|
|
issued_time = $16, sample_device_no = $17, sample_by = $18, sample_time = $19, |
|
|
|
gw = $20, gw_scale_no = $21, gw_time = $22, gw_by = $23, accept_by = $24, |
|
|
|
accept_time = $25, t = $26, t_scale_no = $27, t_time = $28, t_by = $29, |
|
|
|
review_by = $30, review_time = $31, deduction = $32, nw = $33, aw = $34, |
|
|
|
card_return_time = $35, flow_id = $36, is_invoice = $37, is_end = $38, |
|
|
|
is_cancel = $39, cancel_by = $40, cancel_time = $41, is_manual_data = $42, |
|
|
|
first_identify_vehicle_no = $43, second_identify_vehicle_no = $44, |
|
|
|
comment = $45, is_inbound = $46, is_outbound = $47, is_settle_and_review = $48, |
|
|
|
is_settle = $49, settle_id = $50, settle_time = $51, vehicle_and_vessel_no = $52, |
|
|
|
shipping_location = $53, destination = $54, entry_no = $55, batch_no = $56, |
|
|
|
lane_id = $57, queue_id = $58, tax_rate = $59, itax_unit_price = $60, |
|
|
|
iunit_price = $61, operate_time = $62, is_special_batch = $63, total = $64, |
|
|
|
arrival_time = $65, leave_time = $66, ash_start_time = $67, is_rejected = $68, |
|
|
|
train_shipping_detail_id = $69, sample1_collection = $70, |
|
|
|
sample1_collection_id = $71, sample2_collection = $72, samplecard1 = $73, |
|
|
|
samplecard2 = $74, cabno1 = $75, cabno2 = $76, entry_time2 = $77, |
|
|
|
cab2_card = $78, entry_time1 = $79, cab1_card = $80, sampleout_time1 = $81, |
|
|
|
sampleout_time2 = $82, sample2_collection_id = $83, supply_id_name = $84, |
|
|
|
sample_type = $85, sample_code = $86, sample_done = $87, load_type = $88, |
|
|
|
load_weight = $89, sample1_incab_by = $90, sample2_incab_by = $91, |
|
|
|
cabname1 = $92, cabname2 = $93, samplepoint = $94, is_reviewed = $95, |
|
|
|
deduction1 = $96, deduction2 = $97, material_name = $98, |
|
|
|
is_accept_and_receive = $99, bill_no = $100 ,vehicle_no = $101 |
|
|
|
WHERE id=$102", |
|
|
|
&[ |
|
|
|
&info.unit_id, &info.materiel_id, &info.weigh_type, &info.associated_order_id, |
|
|
|
&info.warehouse_id, &info.receive_company_id, &info.transit_company_id, |
|
|
|
&info.vehicle_id, &info.supply_id, &info.card_no, &info.rfid_no, |
|
|
|
&info.order_no, &info.ship_type, &info.issued_device_no, &info.issued_by, |
|
|
|
&info.issued_time, &info.sample_device_no, &info.sample_by, &info.sample_time, |
|
|
|
&info.gw, &info.gw_scale_no, &info.gw_time, &info.gw_by, &info.accept_by, |
|
|
|
&info.accept_time, &info.t, &info.t_scale_no, &info.t_time, &info.t_by, |
|
|
|
&info.review_by, &info.review_time, &info.deduction, &info.nw, &info.aw, |
|
|
|
&info.card_return_time, &info.flow_id, &info.is_invoice, &info.is_end, |
|
|
|
&info.is_cancel, &info.cancel_by, &info.cancel_time, &info.is_manual_data, |
|
|
|
&info.first_identify_vehicle_no, &info.second_identify_vehicle_no, |
|
|
|
&info.comment, &info.is_inbound, &info.is_outbound, &info.is_settle_and_review, |
|
|
|
&info.is_settle, &info.settle_id, &info.settle_time, &info.vehicle_and_vessel_no, |
|
|
|
&info.shipping_location, &info.destination, &info.entry_no, &info.batch_no, |
|
|
|
&info.lane_id, &info.queue_id, &info.tax_rate, &info.itax_unit_price, |
|
|
|
&info.iunit_price, &info.operate_time, &info.is_special_batch, &info.total, |
|
|
|
&info.arrival_time, &info.leave_time, &info.ash_start_time, &info.is_rejected, |
|
|
|
&info.train_shipping_detail_id, &info.sample1_collection, |
|
|
|
&info.sample1_collection_id, &info.sample2_collection, &info.samplecard1, |
|
|
|
&info.samplecard2, &info.cabno1, &info.cabno2, &info.entry_time2, |
|
|
|
&info.cab2_card, &info.entry_time1, &info.cab1_card, &info.sampleout_time1, |
|
|
|
&info.sampleout_time2, &info.sample2_collection_id, &info.supply_id_name, |
|
|
|
&info.sample_type, &info.sample_code, &info.sample_done, &info.load_type, |
|
|
|
&info.load_weight, &info.sample1_incab_by, &info.sample2_incab_by, |
|
|
|
&info.cabname1, &info.cabname2, &info.samplepoint, &info.is_reviewed, |
|
|
|
&info.deduction1, &info.deduction2, &info.material_name, |
|
|
|
&info.is_accept_and_receive, &info.bill_no, &info.vehicle_no,&info.id |
|
|
|
], |
|
|
|
).await?; |
|
|
|
} else { |
|
|
|
// Insert new record |
|
|
|
client.execute( |
|
|
|
"INSERT INTO public.wt_weight_info (id, |
|
|
|
unit_id, materiel_id, weigh_type, associated_order_id, |
|
|
|
warehouse_id, receive_company_id, transit_company_id, |
|
|
|
vehicle_id, bill_no, supply_id, card_no, rfid_no, |
|
|
|
vehicle_no, order_no, ship_type, issued_device_no, issued_by, |
|
|
|
issued_time, sample_device_no, sample_by, sample_time, |
|
|
|
gw, gw_scale_no, gw_time, gw_by, accept_by, |
|
|
|
accept_time, t, t_scale_no, t_time, t_by, |
|
|
|
review_by, review_time, deduction, nw, aw, |
|
|
|
card_return_time, flow_id, is_invoice, is_end, |
|
|
|
is_cancel, cancel_by, cancel_time, is_manual_data, |
|
|
|
first_identify_vehicle_no, second_identify_vehicle_no, |
|
|
|
comment, is_inbound, is_outbound, is_settle_and_review, |
|
|
|
is_settle, settle_id, settle_time, vehicle_and_vessel_no, |
|
|
|
shipping_location, destination, entry_no, batch_no, |
|
|
|
lane_id, queue_id, tax_rate, itax_unit_price, |
|
|
|
iunit_price, operate_time, is_special_batch, total, |
|
|
|
arrival_time, leave_time, ash_start_time, is_rejected, |
|
|
|
train_shipping_detail_id, sample1_collection, |
|
|
|
sample1_collection_id, sample2_collection, samplecard1, |
|
|
|
samplecard2, cabno1, cabno2, entry_time2, |
|
|
|
cab2_card, entry_time1, cab1_card, sampleout_time1, |
|
|
|
sampleout_time2, sample2_collection_id, supply_id_name, |
|
|
|
sample_type, sample_code, sample_done, load_type, |
|
|
|
load_weight, sample1_incab_by, sample2_incab_by, |
|
|
|
cabname1, cabname2, samplepoint, is_reviewed, |
|
|
|
deduction1, deduction2, material_name, |
|
|
|
is_accept_and_receive |
|
|
|
) 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, $42, $43, $44, $45, $46, |
|
|
|
$47, $48, $49, $50, $51, $52, $53, $54, $55, $56, $57, |
|
|
|
$58, $59, $60, $61, $62, $63, $64, $65, $66, $67, $68, |
|
|
|
$69, $70, $71, $72, $73, $74, $75, $76, $77, $78, $79, |
|
|
|
$80, $81, $82, $83, $84, $85, $86, $87, $88, $89, $90, |
|
|
|
$91, $92, $93, $94, $95, $96, $97, $98, $99,$100,$101,$102)", |
|
|
|
&[ &info.id, |
|
|
|
&info.unit_id, &info.materiel_id, &info.weigh_type, &info.associated_order_id, |
|
|
|
&info.warehouse_id, &info.receive_company_id, &info.transit_company_id, |
|
|
|
&info.vehicle_id, &info.bill_no, &info.supply_id, &info.card_no, &info.rfid_no, |
|
|
|
&info.vehicle_no, &info.order_no, &info.ship_type, &info.issued_device_no, |
|
|
|
&info.issued_by, &info.issued_time, &info.sample_device_no, &info.sample_by, |
|
|
|
&info.sample_time, &info.gw, &info.gw_scale_no, &info.gw_time, &info.gw_by, |
|
|
|
&info.accept_by, &info.accept_time, &info.t, &info.t_scale_no, &info.t_time, |
|
|
|
&info.t_by, &info.review_by, &info.review_time, &info.deduction, &info.nw, |
|
|
|
&info.aw, &info.card_return_time, &info.flow_id, &info.is_invoice, &info.is_end, |
|
|
|
&info.is_cancel, &info.cancel_by, &info.cancel_time, &info.is_manual_data, |
|
|
|
&info.first_identify_vehicle_no, &info.second_identify_vehicle_no, |
|
|
|
&info.comment, &info.is_inbound, &info.is_outbound, &info.is_settle_and_review, |
|
|
|
&info.is_settle, &info.settle_id, &info.settle_time, &info.vehicle_and_vessel_no, |
|
|
|
&info.shipping_location, &info.destination, &info.entry_no, &info.batch_no, |
|
|
|
&info.lane_id, &info.queue_id, &info.tax_rate, &info.itax_unit_price, |
|
|
|
&info.iunit_price, &info.operate_time, &info.is_special_batch, &info.total, |
|
|
|
&info.arrival_time, &info.leave_time, &info.ash_start_time, &info.is_rejected, |
|
|
|
&info.train_shipping_detail_id, &info.sample1_collection, |
|
|
|
&info.sample1_collection_id, &info.sample2_collection, &info.samplecard1, |
|
|
|
&info.samplecard2, &info.cabno1, &info.cabno2, &info.entry_time2, |
|
|
|
&info.cab2_card, &info.entry_time1, &info.cab1_card, &info.sampleout_time1, |
|
|
|
&info.sampleout_time2, &info.sample2_collection_id, &info.supply_id_name, |
|
|
|
&info.sample_type, &info.sample_code, &info.sample_done, &info.load_type, |
|
|
|
&info.load_weight, &info.sample1_incab_by, &info.sample2_incab_by, |
|
|
|
&info.cabname1, &info.cabname2, &info.samplepoint, &info.is_reviewed, |
|
|
|
&info.deduction1, &info.deduction2, &info.material_name, |
|
|
|
&info.is_accept_and_receive |
|
|
|
], |
|
|
|
).await?; |
|
|
|
} |
|
|
|
Ok(()) |
|
|
|
} |
|
|
|
|
|
|
|
async fn insert_erp_total_shipping_plan(client: &tokio_postgres::Client, info: &ErpTotalShippingPlan) -> Result<(), PgError> { |
|
|
|
// Check if record exists using order_number |
|
|
|
let exists = client |
|
|
@@ -2495,6 +2774,21 @@ async fn handle_client(socket: &mut TcpStream, client: &tokio_postgres::Client) |
|
|
|
false |
|
|
|
} |
|
|
|
}, |
|
|
|
"wt_weight_info" => { |
|
|
|
if let Ok(info) = serde_json::from_str::<WtWeightInfo>(data_str) { |
|
|
|
println!("接收到wt_weight_info信息: {:?}", info); |
|
|
|
match insert_wt_weight_info(client, &info).await { |
|
|
|
Ok(_) => true, |
|
|
|
Err(e) => { |
|
|
|
eprintln!("插入wt_weight_info信息失败: {}", e); |
|
|
|
false |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
eprintln!("解析wt_weight_info信息失败"); |
|
|
|
false |
|
|
|
} |
|
|
|
}, |
|
|
|
_ => { |
|
|
|
eprintln!("未知的表名: {}", table_name); |
|
|
|
false |
|
|
|