Skip to content

Commit

Permalink
#2477 update record sub proc in req
Browse files Browse the repository at this point in the history
  • Loading branch information
zgyzgyhero committed Dec 20, 2024
1 parent 0bb9466 commit 76428a7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions platform-core/models/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ type ProcRunNodeSubProc struct {
EntityTypeId string `json:"entityTypeId" xorm:"entity_type_id"` // 绑定数据entity
EntityDataId string `json:"entityDataId" xorm:"entity_data_id"` // 绑定数据id
CreatedTime time.Time `json:"createdTime" xorm:"created_time"` // 创建时间
ProcInsId string `json:"-" xorm:"-"`
}

type ProcSubProcQueryRow struct {
Expand Down
11 changes: 9 additions & 2 deletions platform-core/services/database/process-exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -2132,14 +2132,21 @@ func CheckProcInsUserPermission(ctx context.Context, userRoleList []string, proc
return
}

func UpdateProcRunNodeSubProc(ctx context.Context, procRunNodeId string, subProcWorkflowList []*models.ProcRunNodeSubProc, dataBinding []*models.ProcDataBinding) (err error) {
func UpdateProcRunNodeSubProc(ctx context.Context, procRunNodeId string, subProcWorkflowList []*models.ProcRunNodeSubProc, dataBinding []*models.ProcDataBinding, parentInsNodeId string) (err error) {
var actions []*db.ExecAction
nowTime := time.Now()
reqId := "proc_req_" + guid.CreateGuid()
actions = append(actions, &db.ExecAction{Sql: "delete from proc_run_node_sub_proc where proc_run_node_id=?", Param: []interface{}{procRunNodeId}})
for _, row := range subProcWorkflowList {
actions = append(actions, &db.ExecAction{Sql: "insert into proc_ins_node_req(id,proc_ins_node_id,req_url,req_data_amount,is_completed,created_time,updated_time) values (?,?,?,?,?,?,?)", Param: []interface{}{
reqId, parentInsNodeId, "", len(subProcWorkflowList), 1, nowTime, nowTime,
}})
for i, row := range subProcWorkflowList {
actions = append(actions, &db.ExecAction{Sql: "insert into proc_run_node_sub_proc(proc_run_node_id,workflow_id,entity_type_id,entity_data_id,created_time) values (?,?,?,?,?)", Param: []interface{}{
procRunNodeId, row.WorkflowId, row.EntityTypeId, row.EntityDataId, nowTime,
}})
actions = append(actions, &db.ExecAction{Sql: "insert into proc_ins_node_req_param(req_id,data_index,from_type,name,data_type,data_value,entity_data_id,entity_type_id,is_sensitive,full_data_id,multiple,param_def_id,mapping_type,callback_id,created_time) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", Param: []interface{}{
reqId, i, "subProc", "subProcInsId", "string", row.ProcInsId, row.EntityDataId, row.EntityTypeId, 0, "", 0, "", "", row.EntityDataId, nowTime,
}})
}
for _, dataBind := range dataBinding {
if dataBind.SubProcInsId != "" {
Expand Down
4 changes: 2 additions & 2 deletions platform-core/services/workflow/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -725,9 +725,9 @@ func (n *WorkNode) doSubProcessJob(recoverFlag bool) (output string, err error)
workObj.Links = subWorkLinks
subWorkflowList = append(subWorkflowList, &workObj)
subWorkNodeList = append(subWorkNodeList, subWorkNodes)
subProcWorkflowList = append(subProcWorkflowList, &models.ProcRunNodeSubProc{WorkflowId: subWorkflowRow.Id, EntityTypeId: dataRow.EntityTypeId, EntityDataId: dataRow.EntityDataId})
subProcWorkflowList = append(subProcWorkflowList, &models.ProcRunNodeSubProc{WorkflowId: subWorkflowRow.Id, EntityTypeId: dataRow.EntityTypeId, EntityDataId: dataRow.EntityDataId, ProcInsId: subProcInsId})
}
if err = database.UpdateProcRunNodeSubProc(ctx, n.Id, subProcWorkflowList, dataBindings); err != nil {
if err = database.UpdateProcRunNodeSubProc(ctx, n.Id, subProcWorkflowList, dataBindings, procInsNode.Id); err != nil {
err = fmt.Errorf("UpdateProcRunNodeSubProc fail,%s ", err.Error())
return
}
Expand Down

0 comments on commit 76428a7

Please sign in to comment.