Skip to content

Commit 544cc9f

Browse files
authored
flow: rust_decimal install (#749)
1 parent 44aeca8 commit 544cc9f

File tree

4 files changed

+16
-19
lines changed

4 files changed

+16
-19
lines changed

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,15 @@ strip = true
5050
[workspace.dependencies]
5151
# basic
5252
async-recursion = { version = "1.0.4" }
53-
bigdecimal = { version = "0.4.3" }
5453
serde = { version = "1", features = ["derive"] }
5554
serde_json = { version = "1" }
5655
async-trait = { version = "0.1" }
5756
lazy_static = { version = "1" }
5857
itertools = { version = "0" }
5958
fancy-regex = { version = "0" }
6059
run_script = { version = "0.10" }
60+
rust_decimal = { version = "1" }
61+
rust_decimal_macros = { version = "1" }
6162
testcontainers-modules = { version = "0.3", features = ["redis"] }
6263
strum = { version = "0.26", features = ["derive"] }
6364
# tardis

backend/middlewares/flow/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ serde.workspace = true
2020
serde_json.workspace = true
2121
async-trait.workspace = true
2222
async-recursion.workspace = true
23-
bigdecimal.workspace = true
23+
rust_decimal.workspace = true
24+
rust_decimal_macros.workspace = true
2425
lazy_static.workspace = true
2526
itertools.workspace = true
2627
tardis = { workspace = true, features = ["reldb-postgres", "web-client"] }

backend/middlewares/flow/src/serv/flow_event_serv.rs

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
use std::collections::HashMap;
1+
use std::{collections::HashMap, str::FromStr};
22

33
use async_recursion::async_recursion;
4-
use bigdecimal::{BigDecimal, FromPrimitive, ToPrimitive};
54
use bios_basic::rbum::dto::rbum_filer_dto::RbumBasicFilterReq;
5+
use rust_decimal::Decimal;
66
use serde_json::{json, Value};
77
use tardis::{
88
basic::{dto::TardisContext, result::TardisResult},
@@ -243,22 +243,16 @@ impl FlowEventServ {
243243
change_info.changed_kind = Some(FlowTransitionActionByVarChangeInfoChangedKind::ChangeContent);
244244
match changed_op.as_str() {
245245
"add" => {
246-
change_info.changed_val = Some(json!((BigDecimal::from_f64(
247-
original_value.as_str().unwrap_or_default().parse::<f64>().unwrap_or_default()
248-
)
249-
.unwrap()
250-
+ BigDecimal::from_f64(target_value).unwrap())
251-
.to_f64()
252-
.unwrap()))
246+
change_info.changed_val = Some(json!(
247+
(Decimal::from_str(&original_value.as_str().unwrap_or_default().parse::<f64>().unwrap_or_default().to_string()).unwrap()
248+
+ Decimal::from_str(&target_value.to_string()).unwrap())
249+
))
253250
}
254251
"sub" => {
255-
change_info.changed_val = Some(json!((BigDecimal::from_f64(
256-
original_value.as_str().unwrap_or_default().parse::<f64>().unwrap_or_default()
257-
)
258-
.unwrap()
259-
- BigDecimal::from_f64(target_value).unwrap())
260-
.to_f64()
261-
.unwrap()))
252+
change_info.changed_val = Some(json!(
253+
(Decimal::from_str(&original_value.as_str().unwrap_or_default().parse::<f64>().unwrap_or_default().to_string()).unwrap()
254+
- Decimal::from_str(&target_value.to_string()).unwrap())
255+
))
262256
}
263257
_ => {}
264258
}

backend/middlewares/flow/tests/test_flow_scenes_fsm.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use std::collections::HashMap;
2+
use std::str::FromStr;
23

34
use bios_basic::rbum::rbum_enumeration::RbumScopeLevelKind;
45
use bios_basic::test::test_http_client::TestHttpClient;
@@ -20,6 +21,7 @@ use bios_mw_flow::dto::flow_transition_dto::{
2021

2122
use bios_mw_flow::dto::flow_var_dto::{FlowVarInfo, RbumDataTypeKind, RbumWidgetTypeKind};
2223
use bios_sdk_invoke::clients::spi_kv_client::KvItemSummaryResp;
24+
use rust_decimal::Decimal;
2325
use tardis::basic::dto::TardisContext;
2426

2527
use tardis::basic::result::TardisResult;
@@ -32,7 +34,6 @@ use tardis::TardisFuns;
3234

3335
pub async fn test(flow_client: &mut TestHttpClient) -> TardisResult<()> {
3436
info!("【test_flow_scenes_fsm】");
35-
3637
let mut ctx = TardisContext {
3738
own_paths: "".to_string(),
3839
ak: "u001".to_string(),

0 commit comments

Comments
 (0)