diff --git a/apis/process/workOrder.go b/apis/process/workOrder.go index 4125e0c..ee97670 100644 --- a/apis/process/workOrder.go +++ b/apis/process/workOrder.go @@ -81,7 +81,7 @@ func WorkOrderList(c *gin.Context) { classifyInt int ) - classify := c.DefaultQuery("classify", "0") + classify := c.DefaultQuery("classify", "") if classify == "" { app.Error(c, -1, errors.New("参数错误,请确认classify是否传递"), "") return diff --git a/pkg/service/createWorkOrder.go b/pkg/service/createWorkOrder.go index d5df238..45ea353 100644 --- a/pkg/service/createWorkOrder.go +++ b/pkg/service/createWorkOrder.go @@ -31,6 +31,8 @@ func CreateWorkOrder(c *gin.Context) (err error) { processState ProcessState condExprStatus bool tpl []byte + sourceEdges []map[string]interface{} + targetEdges []map[string]interface{} workOrderValue struct { process.WorkOrderInfo Tpls map[string][]interface{} `json:"tpls"` @@ -137,8 +139,48 @@ func CreateWorkOrder(c *gin.Context) (err error) { return } case "parallelGateway": - err = fmt.Errorf("新建工单无法使用并行网关,%v", err) - return + // 入口,判断 + sourceEdges, err = processState.GetEdge(nodeValue["id"].(string), "source") + if err != nil { + err = fmt.Errorf("查询流转信息失败,%v", err.Error()) + return + } + + targetEdges, err = processState.GetEdge(nodeValue["id"].(string), "target") + if err != nil { + err = fmt.Errorf("查询流转信息失败,%v", err.Error()) + return + } + + if len(sourceEdges) > 0 { + nodeValue, err = processState.GetNode(sourceEdges[0]["target"].(string)) + if err != nil { + return + } + } else { + err = errors.New("并行网关流程不正确") + return + } + + if len(sourceEdges) > 1 && len(targetEdges) == 1 { + // 入口 + variableValue = []interface{}{} + for _, edge := range sourceEdges { + targetStateValue, err := processState.GetNode(edge["target"].(string)) + if err != nil { + return err + } + variableValue = append(variableValue, map[string]interface{}{ + "id": edge["target"].(string), + "label": targetStateValue["label"], + "processor": targetStateValue["assignValue"], + "process_method": targetStateValue["assignType"], + }) + } + } else { + err = errors.New("并行网关流程配置不正确") + return + } } // 获取变量数据 diff --git a/pkg/service/handle.go b/pkg/service/handle.go index 84714b6..3da4c44 100644 --- a/pkg/service/handle.go +++ b/pkg/service/handle.go @@ -243,7 +243,7 @@ func (h *Handle) ConditionalJudgment(condExpr map[string]interface{}) (result bo } // 并行网关,确认其他节点是否完成 -func (h *Handle) completeAllParallel(c *gin.Context, target string) (statusOk bool, err error) { +func (h *Handle) completeAllParallel(target string) (statusOk bool, err error) { var ( stateList []map[string]interface{} ) @@ -548,7 +548,7 @@ func (h *Handle) HandleWorkOrder( } } else if len(sourceEdges) == 1 && len(targetEdges) > 1 { // 出口 - parallelStatusOk, err = h.completeAllParallel(c, sourceEdges[0]["target"].(string)) + parallelStatusOk, err = h.completeAllParallel(sourceEdges[0]["target"].(string)) if err != nil { err = fmt.Errorf("并行检测失败,%v", err.Error()) return diff --git a/pkg/service/workOrderList.go b/pkg/service/workOrderList.go index 81a836f..7eef6c0 100644 --- a/pkg/service/workOrderList.go +++ b/pkg/service/workOrderList.go @@ -24,6 +24,7 @@ type WorkOrder struct { type workOrderInfo struct { process.WorkOrderInfo Principals string `json:"principals"` + StateName string `json:"state_name"` DataClassify int `json:"data_classify"` } @@ -107,16 +108,35 @@ func (w *WorkOrder) WorkOrderList() (result interface{}, err error) { return } - for i, w := range *result.(*pagination.Paginator).Data.(*[]workOrderInfo) { - err = json.Unmarshal(w.State, &StateList) + for i, v := range *result.(*pagination.Paginator).Data.(*[]workOrderInfo) { + err = json.Unmarshal(v.State, &StateList) if err != nil { err = fmt.Errorf("json反序列化失败,%v", err.Error()) return } + var ( + stateName string + ) if len(StateList) != 0 { processorList := make([]int, 0) - for _, v := range StateList[0]["processor"].([]interface{}) { - processorList = append(processorList, int(v.(float64))) + if len(StateList) > 1 { + for _, s := range StateList { + for _, p := range s["processor"].([]interface{}) { + if int(p.(float64)) == tools.GetUserId(w.GinObj) { + processorList = append(processorList, int(p.(float64))) + } + } + if len(processorList) > 0 { + stateName = s["label"].(string) + break + } + } + } + if len(processorList) == 0 { + for _, v := range StateList[0]["processor"].([]interface{}) { + processorList = append(processorList, int(v.(float64))) + } + stateName = StateList[0]["label"].(string) } principals, err = GetPrincipal(processorList, StateList[0]["process_method"].(string)) if err != nil { @@ -126,7 +146,8 @@ func (w *WorkOrder) WorkOrderList() (result interface{}, err error) { } workOrderDetails := *result.(*pagination.Paginator).Data.(*[]workOrderInfo) workOrderDetails[i].Principals = principals - workOrderDetails[i].DataClassify = w.Classify + workOrderDetails[i].StateName = stateName + workOrderDetails[i].DataClassify = v.Classify } return result, nil