添加处理备注。

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

View File

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

View File

@ -1,8 +1,10 @@
package app
import (
"github.com/gin-gonic/gin"
"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 != "" {
res.Msg = msg
}
log.Error(res.Msg)
c.JSON(http.StatusOK, res.ReturnError(code))
}
@ -26,7 +29,7 @@ func OK(c *gin.Context, data interface{}, msg string) {
}
// 分页数据处理
func PageOK(c *gin.Context, result interface{},count int,pageIndex int,pageSize int, msg string) {
func PageOK(c *gin.Context, result interface{}, count int, pageIndex int, pageSize int, msg string) {
var res PageResponse
res.Data.List = result
res.Data.Count = count
@ -40,5 +43,5 @@ func PageOK(c *gin.Context, result interface{},count int,pageIndex int,pageSize
// 兼容函数
func Custum(c *gin.Context, data gin.H) {
c.JSON(http.StatusOK,data)
c.JSON(http.StatusOK, data)
}