Skip to content

Commit

Permalink
flow: update external dto (#557)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZzIsGod1019 authored Dec 5, 2023
1 parent 6d19e7a commit 6e4f01d
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 22 deletions.
1 change: 1 addition & 0 deletions middleware/flow/src/dto/flow_external_dto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub struct FlowExternalReq {
pub target_sys_state: Option<FlowSysStateKind>,
pub original_state: Option<String>,
pub original_sys_state: Option<FlowSysStateKind>,
pub transition_name: Option<String>,
pub owner_paths: String,
pub obj_ids: Vec<String>,
pub notify: Option<bool>,
Expand Down
2 changes: 2 additions & 0 deletions middleware/flow/src/dto/flow_transition_dto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ pub enum FlowTransitionActionByVarChangeInfoChangedKind {
ChangeContent,
#[sea_orm(string_value = "auto_get_operate_time")]
AutoGetOperateTime,
#[sea_orm(string_value = "auto_get_operator")]
AutoGetOperator,
#[sea_orm(string_value = "select_field")]
SelectField,
}
Expand Down
4 changes: 4 additions & 0 deletions middleware/flow/src/serv/flow_external_serv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ impl FlowExternalServ {
target_sys_state: Option<FlowSysStateKind>,
original_state: Option<String>,
original_sys_state: Option<FlowSysStateKind>,
transition_name: Option<String>,
is_notify: bool,
params: Vec<FlowExternalParams>,
ctx: &TardisContext,
Expand Down Expand Up @@ -112,6 +113,7 @@ impl FlowExternalServ {
original_state,
original_sys_state,
notify: Some(is_notify),
transition_name,
params,
..Default::default()
};
Expand Down Expand Up @@ -140,6 +142,7 @@ impl FlowExternalServ {
target_sys_state: FlowSysStateKind,
original_state: String,
original_sys_state: FlowSysStateKind,
transition_name: String,
is_notify: bool,
ctx: &TardisContext,
funs: &TardisFunsInst,
Expand All @@ -159,6 +162,7 @@ impl FlowExternalServ {
target_sys_state: Some(target_sys_state),
original_state: Some(original_state),
original_sys_state: Some(original_sys_state),
transition_name: Some(transition_name),
notify: Some(is_notify),
..Default::default()
};
Expand Down
21 changes: 8 additions & 13 deletions middleware/flow/src/serv/flow_inst_serv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,7 @@ impl FlowInstServ {
Some(next_flow_state.sys_state.clone()),
Some(prev_flow_state.name.clone()),
Some(prev_flow_state.sys_state.clone()),
Some(next_flow_transition.next_flow_state_name.clone()),
next_transition_detail.is_notify,
params,
ctx,
Expand Down Expand Up @@ -804,6 +805,7 @@ impl FlowInstServ {
next_flow_state.sys_state,
prev_flow_state.name.clone(),
prev_flow_state.sys_state,
next_transition_detail.name.clone(),
next_transition_detail.is_notify,
ctx,
funs,
Expand All @@ -814,16 +816,7 @@ impl FlowInstServ {
let post_changes =
model_transition.into_iter().find(|model_transition| model_transition.id == next_flow_transition.next_flow_transition_id).unwrap_or_default().action_by_post_changes();
if !post_changes.is_empty() {
Self::do_post_change(
&flow_inst_detail,
&flow_model,
post_changes,
updated_instance_list,
next_transition_detail.is_notify,
ctx,
funs,
)
.await?;
Self::do_post_change(&flow_inst_detail, &flow_model, &next_transition_detail, post_changes, updated_instance_list, ctx, funs).await?;
}
let next_flow_transitions = Self::do_find_next_transitions(&flow_inst_detail, &flow_model, None, &None, skip_filter, funs, ctx).await?.next_flow_transitions;

Expand Down Expand Up @@ -852,9 +845,9 @@ impl FlowInstServ {
async fn do_post_change(
current_inst: &FlowInstDetailResp,
current_model: &FlowModelDetailResp,
transition_detail: &FlowTransitionDetailResp,
post_changes: Vec<FlowTransitionActionChangeInfo>,
updated_instance_list: &mut Vec<String>,
is_notify: bool,
ctx: &TardisContext,
funs: &TardisFunsInst,
) -> TardisResult<()> {
Expand Down Expand Up @@ -889,7 +882,8 @@ impl FlowInstServ {
None,
None,
None,
is_notify,
Some(transition_detail.name.clone()),
transition_detail.is_notify,
vec![FlowExternalParams {
rel_kind: None,
rel_tag: None,
Expand All @@ -914,7 +908,8 @@ impl FlowInstServ {
None,
None,
None,
is_notify,
Some(transition_detail.name.clone()),
transition_detail.is_notify,
vec![FlowExternalParams {
rel_kind: None,
rel_tag: None,
Expand Down
29 changes: 20 additions & 9 deletions middleware/flow/src/serv/flow_state_serv.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::collections::HashSet;
use std::collections::{HashMap, HashSet};

use bios_basic::rbum::{
dto::{
Expand Down Expand Up @@ -307,16 +307,27 @@ impl FlowStateServ {
ctx,
)
.await?;
let mut result = vec![];
let mut result = HashMap::new();
let insts = FlowInstServ::find_detail(req.inst_ids.clone(), funs, ctx).await?;
for (state_id, state_name) in states {
let inst_ids = insts.iter().filter(|inst| inst.current_state_id == state_id).map(|inst| inst.id.clone()).collect_vec();
result.push(FlowStateCountGroupByStateResp {
state_name,
count: inst_ids.len().to_string(),
inst_ids,
});
let mut inst_ids = insts.iter().filter(|inst| inst.current_state_id == state_id).map(|inst| inst.id.clone()).collect_vec();
result
.entry(state_name.clone())
.and_modify(|resp: &mut FlowStateCountGroupByStateResp| {
resp.inst_ids.append(&mut inst_ids);
resp.count = (resp.count.parse::<usize>().unwrap_or_default() + inst_ids.len()).to_string()
})
.or_insert(FlowStateCountGroupByStateResp {
state_name,
count: inst_ids.len().to_string(),
inst_ids,
});
// result.push(FlowStateCountGroupByStateResp {
// state_name,
// count: inst_ids.len().to_string(),
// inst_ids,
// });
}
Ok(result)
Ok(result.into_values().collect_vec())
}
}

0 comments on commit 6e4f01d

Please sign in to comment.