添加处理备注。

This commit is contained in:
Mr. Lan 2020-08-13 22:24:35 +08:00
parent cbbed1a0f8
commit 1888f26d8d
3 changed files with 11 additions and 61 deletions

View File

@ -302,6 +302,7 @@ func ProcessWorkOrder(c *gin.Context) {
WorkOrderId int `json:"work_order_id"` // 工单ID WorkOrderId int `json:"work_order_id"` // 工单ID
Circulation string `json:"circulation"` // 流转ID Circulation string `json:"circulation"` // 流转ID
FlowProperties int `json:"flow_properties"` // 流转类型 0 拒绝1 同意2 其他 FlowProperties int `json:"flow_properties"` // 流转类型 0 拒绝1 同意2 其他
Remarks string `json:"remarks"` // 处理的备注信息
} }
) )
@ -330,6 +331,7 @@ func ProcessWorkOrder(c *gin.Context) {
params.SourceState, // 源节点 params.SourceState, // 源节点
params.Circulation, // 流转标题 params.Circulation, // 流转标题
params.FlowProperties, // 流转属性 params.FlowProperties, // 流转属性
params.Remarks, // 备注信息
) )
if err != nil { if err != nil {
app.Error(c, -1, nil, fmt.Sprintf("处理工单失败,%v", err.Error())) app.Error(c, -1, nil, fmt.Sprintf("处理工单失败,%v", err.Error()))

View File

@ -16,7 +16,6 @@ import (
"github.com/jinzhu/gorm" "github.com/jinzhu/gorm"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
log "github.com/sirupsen/logrus"
) )
/* /*
@ -74,7 +73,6 @@ func (h *Handle) Countersign(c *gin.Context) (err error) {
err = json.Unmarshal(h.workOrderDetails.State, &stateList) err = json.Unmarshal(h.workOrderDetails.State, &stateList)
if err != nil { if err != nil {
log.Error(err)
return return
} }
@ -101,7 +99,6 @@ func (h *Handle) Countersign(c *gin.Context) (err error) {
h.endHistory = true h.endHistory = true
err = h.circulation() err = h.circulation()
if err != nil { if err != nil {
log.Error(err)
return return
} }
} }
@ -120,13 +117,11 @@ func (h *Handle) circulation() (err error) {
} }
err = GetVariableValue(stateList, h.workOrderDetails.Creator) err = GetVariableValue(stateList, h.workOrderDetails.Creator)
if err != nil { if err != nil {
log.Error(err)
return return
} }
stateValue, err = json.Marshal(h.updateValue["state"]) stateValue, err = json.Marshal(h.updateValue["state"])
if err != nil { if err != nil {
log.Error(err)
return return
} }
@ -138,7 +133,6 @@ func (h *Handle) circulation() (err error) {
}).Error }).Error
if err != nil { if err != nil {
h.tx.Rollback() h.tx.Rollback()
log.Error(err)
return return
} }
return return
@ -161,7 +155,6 @@ func (h *Handle) ConditionalJudgment(condExpr map[string]interface{}) (result bo
default: default:
err = errors.New("未知错误") err = errors.New("未知错误")
} }
log.Error(err)
return return
} }
}() }()
@ -170,7 +163,6 @@ func (h *Handle) ConditionalJudgment(condExpr map[string]interface{}) (result bo
var formData map[string]interface{} var formData map[string]interface{}
err = json.Unmarshal(data, &formData) err = json.Unmarshal(data, &formData)
if err != nil { if err != nil {
log.Error(err)
return return
} }
if condExprValue, condExprOk = formData[condExpr["key"].(string)]; condExprOk { if condExprValue, condExprOk = formData[condExpr["key"].(string)]; condExprOk {
@ -180,7 +172,6 @@ func (h *Handle) ConditionalJudgment(condExpr map[string]interface{}) (result bo
if condExprValue == nil { if condExprValue == nil {
err = errors.New("未查询到对应的表单数据。") err = errors.New("未查询到对应的表单数据。")
log.Error(err)
return return
} }
@ -246,7 +237,6 @@ func (h *Handle) ConditionalJudgment(condExpr map[string]interface{}) (result bo
} }
default: default:
err = errors.New("条件判断目前仅支持字符串、整型。") err = errors.New("条件判断目前仅支持字符串、整型。")
log.Error(err)
} }
return return
@ -261,7 +251,6 @@ func (h *Handle) completeAllParallel(c *gin.Context, target string) (statusOk bo
err = json.Unmarshal(h.workOrderDetails.State, &stateList) err = json.Unmarshal(h.workOrderDetails.State, &stateList)
if err != nil { if err != nil {
err = fmt.Errorf("反序列化失败,%v", err.Error()) err = fmt.Errorf("反序列化失败,%v", err.Error())
log.Error(err)
return return
} }
@ -293,7 +282,6 @@ func (h *Handle) commonProcessing(c *gin.Context) (err error) {
err = h.circulation() err = h.circulation()
if err != nil { if err != nil {
err = fmt.Errorf("工单跳转失败,%v", err.Error()) err = fmt.Errorf("工单跳转失败,%v", err.Error())
log.Error(err)
} }
return return
} }
@ -305,27 +293,23 @@ func (h *Handle) commonProcessing(c *gin.Context) (err error) {
h.endHistory = false h.endHistory = false
err = h.Countersign(c) err = h.Countersign(c)
if err != nil { if err != nil {
log.Error(err)
return return
} }
} else { } else {
err = h.circulation() err = h.circulation()
if err != nil { if err != nil {
log.Error(err)
return return
} }
} }
} else { } else {
err = h.circulation() err = h.circulation()
if err != nil { if err != nil {
log.Error(err)
return return
} }
} }
} else { } else {
err = h.circulation() err = h.circulation()
if err != nil { if err != nil {
log.Error(err)
return return
} }
} }
@ -340,6 +324,7 @@ func (h *Handle) HandleWorkOrder(
sourceState string, sourceState string,
circulationValue string, circulationValue string,
flowProperties int, flowProperties int,
remarks string,
) (err error) { ) (err error) {
h.workOrderId = workOrderId h.workOrderId = workOrderId
h.flowProperties = flowProperties h.flowProperties = flowProperties
@ -374,7 +359,6 @@ func (h *Handle) HandleWorkOrder(
default: default:
err = errors.New("未知错误") err = errors.New("未知错误")
} }
log.Error(err)
return return
} }
}() }()
@ -382,33 +366,28 @@ func (h *Handle) HandleWorkOrder(
// 获取工单信息 // 获取工单信息
err = orm.Eloquent.Model(&process.WorkOrderInfo{}).Where("id = ?", workOrderId).Find(&h.workOrderDetails).Error err = orm.Eloquent.Model(&process.WorkOrderInfo{}).Where("id = ?", workOrderId).Find(&h.workOrderDetails).Error
if err != nil { if err != nil {
log.Error(err)
return return
} }
// 获取流程信息 // 获取流程信息
err = orm.Eloquent.Model(&process.Info{}).Where("id = ?", h.workOrderDetails.Process).Find(&processInfo).Error err = orm.Eloquent.Model(&process.Info{}).Where("id = ?", h.workOrderDetails.Process).Find(&processInfo).Error
if err != nil { if err != nil {
log.Error(err)
return return
} }
err = json.Unmarshal(processInfo.Structure, &h.processState.Structure) err = json.Unmarshal(processInfo.Structure, &h.processState.Structure)
if err != nil { if err != nil {
log.Error(err)
return return
} }
// 获取当前节点 // 获取当前节点
h.stateValue, err = h.processState.GetNode(sourceState) h.stateValue, err = h.processState.GetNode(sourceState)
if err != nil { if err != nil {
log.Error(err)
return return
} }
// 目标状态 // 目标状态
h.targetStateValue, err = h.processState.GetNode(targetState) h.targetStateValue, err = h.processState.GetNode(targetState)
if err != nil { if err != nil {
log.Error(err)
return return
} }
@ -417,7 +396,6 @@ func (h *Handle) HandleWorkOrder(
Where("work_order = ?", workOrderId). Where("work_order = ?", workOrderId).
Pluck("form_data", &h.workOrderData).Error Pluck("form_data", &h.workOrderData).Error
if err != nil { if err != nil {
log.Error(err)
return return
} }
@ -427,13 +405,11 @@ func (h *Handle) HandleWorkOrder(
Order("id desc"). Order("id desc").
Find(&h.cirHistoryList).Error Find(&h.cirHistoryList).Error
if err != nil { if err != nil {
log.Error(err)
return return
} }
err = json.Unmarshal(h.workOrderDetails.RelatedPerson, &relatedPersonList) err = json.Unmarshal(h.workOrderDetails.RelatedPerson, &relatedPersonList)
if err != nil { if err != nil {
log.Error(err)
return return
} }
relatedPersonStatus := false relatedPersonStatus := false
@ -449,7 +425,6 @@ func (h *Handle) HandleWorkOrder(
relatedPersonValue, err = json.Marshal(relatedPersonList) relatedPersonValue, err = json.Marshal(relatedPersonList)
if err != nil { if err != nil {
log.Error(err)
return return
} }
@ -470,7 +445,6 @@ func (h *Handle) HandleWorkOrder(
case "exclusiveGateway": case "exclusiveGateway":
sourceEdges, err = h.processState.GetEdge(h.targetStateValue["id"].(string), "source") sourceEdges, err = h.processState.GetEdge(h.targetStateValue["id"].(string), "source")
if err != nil { if err != nil {
log.Error(err)
return return
} }
breakTag: breakTag:
@ -478,28 +452,24 @@ func (h *Handle) HandleWorkOrder(
edgeCondExpr := make([]map[string]interface{}, 0) edgeCondExpr := make([]map[string]interface{}, 0)
err = json.Unmarshal([]byte(edge["conditionExpression"].(string)), &edgeCondExpr) err = json.Unmarshal([]byte(edge["conditionExpression"].(string)), &edgeCondExpr)
if err != nil { if err != nil {
log.Error(err)
return return
} }
for _, condExpr := range edgeCondExpr { for _, condExpr := range edgeCondExpr {
// 条件判断 // 条件判断
condExprStatus, err = h.ConditionalJudgment(condExpr) condExprStatus, err = h.ConditionalJudgment(condExpr)
if err != nil { if err != nil {
log.Error(err)
return return
} }
if condExprStatus { if condExprStatus {
// 进行节点跳转 // 进行节点跳转
h.targetStateValue, err = h.processState.GetNode(edge["target"].(string)) h.targetStateValue, err = h.processState.GetNode(edge["target"].(string))
if err != nil { if err != nil {
log.Error(err)
return return
} }
if h.targetStateValue["clazz"] == "userTask" || h.targetStateValue["clazz"] == "receiveTask" { if h.targetStateValue["clazz"] == "userTask" || h.targetStateValue["clazz"] == "receiveTask" {
if h.targetStateValue["assignValue"] == nil || h.targetStateValue["assignType"] == "" { if h.targetStateValue["assignValue"] == nil || h.targetStateValue["assignType"] == "" {
err = errors.New("处理人不能为空") err = errors.New("处理人不能为空")
log.Error(err)
return return
} }
} }
@ -513,7 +483,6 @@ func (h *Handle) HandleWorkOrder(
err = h.commonProcessing(c) err = h.commonProcessing(c)
if err != nil { if err != nil {
err = fmt.Errorf("流程流程跳转失败,%v", err.Error()) err = fmt.Errorf("流程流程跳转失败,%v", err.Error())
log.Error(err)
return return
} }
@ -523,7 +492,6 @@ func (h *Handle) HandleWorkOrder(
} }
if !condExprStatus { if !condExprStatus {
err = errors.New("所有流转均不符合条件,请确认。") err = errors.New("所有流转均不符合条件,请确认。")
log.Error(err)
return return
} }
// 并行/聚合网关 // 并行/聚合网关
@ -532,26 +500,22 @@ func (h *Handle) HandleWorkOrder(
sourceEdges, err = h.processState.GetEdge(h.targetStateValue["id"].(string), "source") sourceEdges, err = h.processState.GetEdge(h.targetStateValue["id"].(string), "source")
if err != nil { if err != nil {
err = fmt.Errorf("查询流转信息失败,%v", err.Error()) err = fmt.Errorf("查询流转信息失败,%v", err.Error())
log.Error(err)
return return
} }
targetEdges, err = h.processState.GetEdge(h.targetStateValue["id"].(string), "target") targetEdges, err = h.processState.GetEdge(h.targetStateValue["id"].(string), "target")
if err != nil { if err != nil {
err = fmt.Errorf("查询流转信息失败,%v", err.Error()) err = fmt.Errorf("查询流转信息失败,%v", err.Error())
log.Error(err)
return return
} }
if len(sourceEdges) > 0 { if len(sourceEdges) > 0 {
h.targetStateValue, err = h.processState.GetNode(sourceEdges[0]["target"].(string)) h.targetStateValue, err = h.processState.GetNode(sourceEdges[0]["target"].(string))
if err != nil { if err != nil {
log.Error(err)
return return
} }
} else { } else {
err = errors.New("并行网关流程不正确") err = errors.New("并行网关流程不正确")
log.Error(err)
return return
} }
@ -561,7 +525,6 @@ func (h *Handle) HandleWorkOrder(
for _, edge := range sourceEdges { for _, edge := range sourceEdges {
targetStateValue, err := h.processState.GetNode(edge["target"].(string)) targetStateValue, err := h.processState.GetNode(edge["target"].(string))
if err != nil { if err != nil {
log.Error(err)
return err return err
} }
h.updateValue["state"] = append(h.updateValue["state"].([]map[string]interface{}), map[string]interface{}{ h.updateValue["state"] = append(h.updateValue["state"].([]map[string]interface{}), map[string]interface{}{
@ -574,7 +537,6 @@ func (h *Handle) HandleWorkOrder(
err = h.circulation() err = h.circulation()
if err != nil { if err != nil {
err = fmt.Errorf("工单跳转失败,%v", err.Error()) err = fmt.Errorf("工单跳转失败,%v", err.Error())
log.Error(err)
return return
} }
} else if len(sourceEdges) == 1 && len(targetEdges) > 1 { } else if len(sourceEdges) == 1 && len(targetEdges) > 1 {
@ -582,7 +544,6 @@ func (h *Handle) HandleWorkOrder(
parallelStatusOk, err = h.completeAllParallel(c, sourceEdges[0]["target"].(string)) parallelStatusOk, err = h.completeAllParallel(c, sourceEdges[0]["target"].(string))
if err != nil { if err != nil {
err = fmt.Errorf("并行检测失败,%v", err.Error()) err = fmt.Errorf("并行检测失败,%v", err.Error())
log.Error(err)
return return
} }
if parallelStatusOk { if parallelStatusOk {
@ -606,7 +567,6 @@ func (h *Handle) HandleWorkOrder(
err = h.circulation() err = h.circulation()
if err != nil { if err != nil {
err = fmt.Errorf("工单跳转失败,%v", err.Error()) err = fmt.Errorf("工单跳转失败,%v", err.Error())
log.Error(err)
return return
} }
} else { } else {
@ -615,13 +575,10 @@ func (h *Handle) HandleWorkOrder(
} else { } else {
err = errors.New("并行网关流程不正确") err = errors.New("并行网关流程不正确")
log.Error(err)
return return
} }
// 包容网关 // 包容网关
case "inclusiveGateway": case "inclusiveGateway":
fmt.Println("inclusiveGateway")
log.Error(err)
return return
case "start": case "start":
stateValue["processor"] = []int{h.workOrderDetails.Creator} stateValue["processor"] = []int{h.workOrderDetails.Creator}
@ -629,7 +586,6 @@ func (h *Handle) HandleWorkOrder(
h.updateValue["state"] = []map[string]interface{}{stateValue} h.updateValue["state"] = []map[string]interface{}{stateValue}
err = h.circulation() err = h.circulation()
if err != nil { if err != nil {
log.Error(err)
return return
} }
case "userTask": case "userTask":
@ -638,7 +594,6 @@ func (h *Handle) HandleWorkOrder(
h.updateValue["state"] = []map[string]interface{}{stateValue} h.updateValue["state"] = []map[string]interface{}{stateValue}
err = h.commonProcessing(c) err = h.commonProcessing(c)
if err != nil { if err != nil {
log.Error(err)
return return
} }
case "receiveTask": case "receiveTask":
@ -647,7 +602,6 @@ func (h *Handle) HandleWorkOrder(
h.updateValue["state"] = []map[string]interface{}{stateValue} h.updateValue["state"] = []map[string]interface{}{stateValue}
err = h.commonProcessing(c) err = h.commonProcessing(c)
if err != nil { if err != nil {
log.Error(err)
return return
} }
case "scriptTask": case "scriptTask":
@ -661,7 +615,6 @@ func (h *Handle) HandleWorkOrder(
err = h.circulation() err = h.circulation()
if err != nil { if err != nil {
h.tx.Rollback() h.tx.Rollback()
log.Error(err)
return return
} }
err = h.tx.Model(&process.WorkOrderInfo{}). err = h.tx.Model(&process.WorkOrderInfo{}).
@ -669,7 +622,6 @@ func (h *Handle) HandleWorkOrder(
Update("is_end", 1).Error Update("is_end", 1).Error
if err != nil { if err != nil {
h.tx.Rollback() h.tx.Rollback()
log.Error(err)
return return
} }
} }
@ -681,7 +633,6 @@ func (h *Handle) HandleWorkOrder(
Order("create_time desc").Error Order("create_time desc").Error
if err != nil { if err != nil {
h.tx.Rollback() h.tx.Rollback()
log.Error(err)
return return
} }
for _, t := range cirHistoryValue { for _, t := range cirHistoryValue {
@ -696,7 +647,6 @@ func (h *Handle) HandleWorkOrder(
Where("user_id = ?", tools.GetUserId(c)). Where("user_id = ?", tools.GetUserId(c)).
Find(&currentUserInfo).Error Find(&currentUserInfo).Error
if err != nil { if err != nil {
log.Error(err)
return return
} }
@ -711,19 +661,18 @@ func (h *Handle) HandleWorkOrder(
Processor: currentUserInfo.NickName, Processor: currentUserInfo.NickName,
ProcessorId: tools.GetUserId(c), ProcessorId: tools.GetUserId(c),
CostDuration: costDurationValue, CostDuration: costDurationValue,
Remarks: remarks,
} }
err = h.tx.Create(&cirHistoryData).Error err = h.tx.Create(&cirHistoryData).Error
if err != nil { if err != nil {
h.tx.Rollback() h.tx.Rollback()
log.Error(err)
return return
} }
// 获取流程通知类型列表 // 获取流程通知类型列表
err = json.Unmarshal(processInfo.Notice, &noticeList) err = json.Unmarshal(processInfo.Notice, &noticeList)
if err != nil { if err != nil {
log.Error(err)
return return
} }
@ -755,10 +704,10 @@ func (h *Handle) HandleWorkOrder(
Processor: currentUserInfo.NickName, Processor: currentUserInfo.NickName,
ProcessorId: tools.GetUserId(c), ProcessorId: tools.GetUserId(c),
Circulation: "结束", Circulation: "结束",
Remarks: "工单已结束",
}).Error }).Error
if err != nil { if err != nil {
h.tx.Rollback() h.tx.Rollback()
log.Error(err)
return return
} }
if len(noticeList) > 0 { if len(noticeList) > 0 {
@ -767,7 +716,6 @@ func (h *Handle) HandleWorkOrder(
Where("user_id = ?", h.workOrderDetails.Creator). Where("user_id = ?", h.workOrderDetails.Creator).
Find(&sendToUserList).Error Find(&sendToUserList).Error
if err != nil { if err != nil {
log.Error(err)
return return
} }
@ -781,7 +729,6 @@ func (h *Handle) HandleWorkOrder(
go func(bodyData notify.BodyData) { go func(bodyData notify.BodyData) {
err = bodyData.SendNotify() err = bodyData.SendNotify()
if err != nil { if err != nil {
log.Error(err)
return return
} }
}(bodyData) }(bodyData)
@ -798,7 +745,6 @@ func (h *Handle) HandleWorkOrder(
} }
sendToUserList, err = GetPrincipalUserInfo(stateList, h.workOrderDetails.Creator) sendToUserList, err = GetPrincipalUserInfo(stateList, h.workOrderDetails.Creator)
if err != nil { if err != nil {
log.Error(err)
return return
} }
@ -812,7 +758,6 @@ func (h *Handle) HandleWorkOrder(
go func(bodyData notify.BodyData) { go func(bodyData notify.BodyData) {
err = bodyData.SendNotify() err = bodyData.SendNotify()
if err != nil { if err != nil {
log.Error(err)
return return
} }
}(bodyData) }(bodyData)

View File

@ -1,8 +1,10 @@
package app package app
import ( import (
"github.com/gin-gonic/gin"
"net/http" "net/http"
"github.com/gin-gonic/gin"
log "github.com/sirupsen/logrus"
) )
// 失败数据处理 // 失败数据处理
@ -12,6 +14,7 @@ func Error(c *gin.Context, code int, err error, msg string) {
if msg != "" { if msg != "" {
res.Msg = msg res.Msg = msg
} }
log.Error(res.Msg)
c.JSON(http.StatusOK, res.ReturnError(code)) c.JSON(http.StatusOK, res.ReturnError(code))
} }