Browse Source

包容网关 流转参数模式设定

main
pixel 4 years ago
parent
commit
9e6b8ff0ef
  1. 2
      server/resource/template/server/api.go.tpl
  2. 4
      server/resource/template/server/service.go.tpl
  3. 29
      server/service/wk_process.go

2
server/resource/template/server/api.go.tpl

@ -78,7 +78,7 @@ func Delete{{.StructName}}ByIds(c *gin.Context) {
func Update{{.StructName}}(c *gin.Context) { func Update{{.StructName}}(c *gin.Context) {
var {{.Abbreviation}} model.{{.StructName}} var {{.Abbreviation}} model.{{.StructName}}
_ = c.ShouldBindJSON(&{{.Abbreviation}}) _ = c.ShouldBindJSON(&{{.Abbreviation}})
if err := service.Update{{.StructName}}(&{{.Abbreviation}}); err != nil {
if err := service.Update{{.StructName}}({{.Abbreviation}}); err != nil {
global.GVA_LOG.Error("更新失败!", zap.Any("err", err)) global.GVA_LOG.Error("更新失败!", zap.Any("err", err))
response.FailWithMessage("更新失败", c) response.FailWithMessage("更新失败", c)
} else { } else {

4
server/resource/template/server/service.go.tpl

@ -45,8 +45,8 @@ func Delete{{.StructName}}ByIds(ids request.IdsReq) (err error) {
//@param: {{.Abbreviation}} *model.{{.StructName}} //@param: {{.Abbreviation}} *model.{{.StructName}}
//@return: err error //@return: err error
func Update{{.StructName}}({{.Abbreviation}} *model.{{.StructName}}) (err error) {
err = global.GVA_DB.Save({{.Abbreviation}}).Error
func Update{{.StructName}}({{.Abbreviation}} model.{{.StructName}}) (err error) {
err = global.GVA_DB.Save(&{{.Abbreviation}}).Error
return err return err
} }

29
server/service/wk_process.go

@ -311,11 +311,10 @@ func createNewWorkflowMove(tx *gorm.DB,oldWfm *model.WorkflowMove, targetNodeID
WorkflowProcessID: oldWfm.WorkflowProcessID, WorkflowProcessID: oldWfm.WorkflowProcessID,
Param: "", Param: "",
Action: "", Action: "",
IsActive: true,})
IsActive: true})
return nil, newWfm return nil, newWfm
case model.INCLUSIVE_GATEWAY: case model.INCLUSIVE_GATEWAY:
// 当为包容网关时,需要等待其他网关执行结束才进行创建 // 当为包容网关时,需要等待其他网关执行结束才进行创建
txErr := tx.Find(&edges, "workflow_process_id = ? and target = ?", oldWfm.WorkflowProcessID, nodeInfo.ID).Error txErr := tx.Find(&edges, "workflow_process_id = ? and target = ?", oldWfm.WorkflowProcessID, nodeInfo.ID).Error
if txErr != nil { if txErr != nil {
return txErr, []model.WorkflowMove{} return txErr, []model.WorkflowMove{}
@ -332,12 +331,20 @@ func createNewWorkflowMove(tx *gorm.DB,oldWfm *model.WorkflowMove, targetNodeID
return nil, []model.WorkflowMove{} return nil, []model.WorkflowMove{}
} }
if len(wfms) == len(edges) { if len(wfms) == len(edges) {
//var params string
//for _,v := range wfms{
// params += v.Param
//}
//参数携带模式暂时未定
txErr := tx.First(&edge, "workflow_process_id = ? and source = ?", oldWfm.WorkflowProcessID, nodeInfo.ID).Error
params := make(map[string]int)
var param string
var temp int
for _, v := range wfms {
params[v.Param]++
}
for k, v := range params {
if temp < v {
temp = v
param = k
}
}
//参数携带模式暂时未定 暂时为少数服从多数原则 后续会增加原则配置 (少数服从多数,仅一关键字即为关键字,所有关键字才为关键字 三种方案)
txErr := tx.First(&edge, "workflow_process_id = ? and source = ? and condition_expression = ?", oldWfm.WorkflowProcessID, nodeInfo.ID, param).Error
if txErr != nil { if txErr != nil {
return txErr, []model.WorkflowMove{} return txErr, []model.WorkflowMove{}
} }
@ -350,7 +357,7 @@ func createNewWorkflowMove(tx *gorm.DB,oldWfm *model.WorkflowMove, targetNodeID
WorkflowProcessID: oldWfm.WorkflowProcessID, WorkflowProcessID: oldWfm.WorkflowProcessID,
Param: "", Param: "",
Action: "", Action: "",
IsActive: true,})
IsActive: true})
} }
return nil, newWfm return nil, newWfm
@ -370,7 +377,7 @@ func createNewWorkflowMove(tx *gorm.DB,oldWfm *model.WorkflowMove, targetNodeID
WorkflowProcessID: oldWfm.WorkflowProcessID, WorkflowProcessID: oldWfm.WorkflowProcessID,
Param: "", Param: "",
Action: "", Action: "",
IsActive: true,})
IsActive: true})
} }
return nil, newWfm return nil, newWfm
@ -385,7 +392,7 @@ func createNewWorkflowMove(tx *gorm.DB,oldWfm *model.WorkflowMove, targetNodeID
WorkflowProcessID: oldWfm.WorkflowProcessID, WorkflowProcessID: oldWfm.WorkflowProcessID,
Param: "", Param: "",
Action: "", Action: "",
IsActive: true,})
IsActive: true})
return nil, newWfm return nil, newWfm
} }
} }

Loading…
Cancel
Save