Merge pull request #177 from lanyulei/dev

fix: 修复工单因流程删除而无法显示的bug。
This commit is contained in:
lanyulei 2021-04-19 16:07:06 +08:00 committed by GitHub
commit 4f713d961e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 50 additions and 43 deletions

View File

@ -34,11 +34,12 @@ func ProcessStructure(c *gin.Context, processId int, workOrderId int) (result ma
) )
err = orm.Eloquent.Model(&processValue).Where("id = ?", processId).Find(&processValue).Error err = orm.Eloquent.Model(&processValue).Where("id = ?", processId).Find(&processValue).Error
if err != nil { //if err != nil {
err = fmt.Errorf("查询流程失败,%v", err.Error()) // err = fmt.Errorf("查询流程失败,%v", err.Error())
return // return
} //}
if processValue.Structure != nil && len(processValue.Structure) > 0 {
err = json.Unmarshal([]byte(processValue.Structure), &processStructureDetails) err = json.Unmarshal([]byte(processValue.Structure), &processStructureDetails)
if err != nil { if err != nil {
err = fmt.Errorf("json转map失败%v", err.Error()) err = fmt.Errorf("json转map失败%v", err.Error())
@ -67,6 +68,7 @@ func ProcessStructure(c *gin.Context, processId int, workOrderId int) (result ma
} else { } else {
processNode = processStructureDetails["nodes"].([]map[string]interface{}) processNode = processStructureDetails["nodes"].([]map[string]interface{})
} }
}
processValue.Structure = nil processValue.Structure = nil
result = map[string]interface{}{ result = map[string]interface{}{
@ -141,6 +143,7 @@ func ProcessStructure(c *gin.Context, processId int, workOrderId int) (result ma
if len(stateList) > 0 { if len(stateList) > 0 {
breakStateTag: breakStateTag:
for _, stateValue := range stateList { for _, stateValue := range stateList {
if processStructureDetails["nodes"] != nil {
for _, processNodeValue := range processStructureDetails["nodes"].([]interface{}) { for _, processNodeValue := range processStructureDetails["nodes"].([]interface{}) {
if stateValue["id"].(string) == processNodeValue.(map[string]interface{})["id"] { if stateValue["id"].(string) == processNodeValue.(map[string]interface{})["id"] {
if _, ok := stateValue["processor"]; ok { if _, ok := stateValue["processor"]; ok {
@ -157,6 +160,7 @@ func ProcessStructure(c *gin.Context, processId int, workOrderId int) (result ma
} }
} }
} }
}
if workOrderInfo.CurrentState == "" { if workOrderInfo.CurrentState == "" {
workOrderInfo.CurrentState = stateList[0]["id"].(string) workOrderInfo.CurrentState = stateList[0]["id"].(string)

View File

@ -44,13 +44,16 @@ func JudgeUserAuthority(c *gin.Context, workOrderId int, currentState string) (s
// 获取流程信息 // 获取流程信息
err = orm.Eloquent.Model(&process.Info{}).Where("id = ?", workOrderInfo.Process).Find(&processInfo).Error err = orm.Eloquent.Model(&process.Info{}).Where("id = ?", workOrderInfo.Process).Find(&processInfo).Error
if err != nil { //if err != nil {
return // return
} //}
if processInfo.Structure != nil && len(processInfo.Structure) > 0 {
err = json.Unmarshal(processInfo.Structure, &processState.Structure) err = json.Unmarshal(processInfo.Structure, &processState.Structure)
if err != nil { if err != nil {
return return
} }
}
stateValue, err = processState.GetNode(currentState) stateValue, err = processState.GetNode(currentState)
if err != nil { if err != nil {