package taskflow
import (
"appPlatform/models/modelAppPlatform"
"appPlatform/models/modelshr"
"appPlatform/overall"
"appPlatform/overall/publicmethod"
"encoding/json"
"fmt"
"strconv"
"strings"
"time"
"github.com/gin-gonic/gin"
)
/ *
*
@ 作者 : 秦东
@ 时间 : 2023 - 11 - 23 11 : 23 : 50
@ 功能 : 流程任务
@ 参数
#
@ 返回值
#
@ 方法原型
#
* /
func ( a * ApiMethod ) TaskFlowList ( c * gin . Context ) {
var requestData QueryTaskFlow
err := c . ShouldBindJSON ( & requestData )
if err != nil {
publicmethod . Result ( 100 , err , c )
return
}
if requestData . Page == 0 {
requestData . Page = 1
}
if requestData . PageSize == 0 {
requestData . PageSize = 10
}
context , _ := c . Get ( overall . MyContJwt )
var userCont modelshr . ManCont
userCont . GetLoginCont ( context ) //当前操作人
gormDb := overall . CONSTANT_DB_AppPlatform . Model ( & modelAppPlatform . RunTaskFlow { } ) . Select ( "`id`" )
switch requestData . Class {
case 2 : //待办事宜
gormDb = gormDb . Where ( "`status` = 3 AND FIND_IN_SET(?,`next_executor`)" , userCont . Key )
case 3 : //已办事宜
gormDb = gormDb . Where ( "`status` IN (2,3,4) AND FIND_IN_SET(?,`participants`) AND NOT FIND_IN_SET(?,`next_executor`) AND `creater` <> ?" , userCont . Key , userCont . Key , userCont . Key )
case 4 : //草稿箱
gormDb = gormDb . Where ( "`status` = 1 AND `creater` = ?" , userCont . Key )
default : //我的请求
gormDb = gormDb . Where ( "`status` IN (1,2,3,4) AND `creater` = ?" , userCont . Key )
}
if requestData . Title != "" {
gormDb = gormDb . Where ( "`title` LIKE ?" , "%" + requestData . Title + "%" )
}
if requestData . State != 0 {
gormDb = gormDb . Where ( "`status` = ?" , requestData . State )
}
//获取总数
var total int64
totalErr := gormDb . Count ( & total ) . Error
if totalErr != nil {
total = 0
}
var idAry [ ] int64
gormDb = publicmethod . PageTurningSettings ( gormDb , requestData . Page , requestData . PageSize )
// err = gormDb.Order("`status` asc").Order("`start_time` desc").Find(&idAry).Error
err = gormDb . Order ( "`start_time` desc" ) . Find ( & idAry ) . Error
var userList [ ] SendTaskFlowInfo
if err != nil || len ( idAry ) < 1 {
publicmethod . ResultList ( 0 , requestData . Page , requestData . PageSize , total , int64 ( len ( userList ) ) , userList , c )
return
}
overall . CONSTANT_DB_AppPlatform . Model ( & modelAppPlatform . RunTaskFlow { } ) . Where ( "`id` IN ?" , idAry ) . Order ( "`start_time` desc" ) . Find ( & userList )
for i := 0 ; i < len ( userList ) ; i ++ {
userList [ i ] . FormVersionId = strconv . FormatInt ( userList [ i ] . VersionId , 10 )
userList [ i ] . IdStr = strconv . FormatInt ( userList [ i ] . Id , 10 )
userList [ i ] . FlowKeys = strconv . FormatInt ( userList [ i ] . FlowKey , 10 )
userList [ i ] . CreaterInfo = GainSmaillUserInfo [ int64 ] ( userList [ i ] . Creater )
if userList [ i ] . NextExecutor != "" {
nextAry := strings . Split ( userList [ i ] . NextExecutor , "," )
for _ , v := range nextAry {
userList [ i ] . CurrentNodeUser = append ( userList [ i ] . CurrentNodeUser , GainSmaillUserInfo [ string ] ( v ) )
}
}
userList [ i ] . StartDate = publicmethod . UnixTimeToDay ( userList [ i ] . StartTime , 27 )
if userList [ i ] . NextStep != 0 {
nodeCont , idTrue := GainCurreNode ( userList [ i ] . FlowCont , userList [ i ] . CurrentStep , userList [ i ] . NextStep , userList [ i ] . Status )
if idTrue {
userList [ i ] . CurrentNodeName = nodeCont . NodeName
}
}
if userList [ i ] . MastesForm == "" || userList [ i ] . MastesFormJson == "" {
userList [ i ] . MastesForm , userList [ i ] . MastesFormJson = GainTaskFormData ( userList [ i ] . FlowKey )
}
}
publicmethod . ResultList ( 0 , requestData . Page , requestData . PageSize , total , int64 ( len ( userList ) ) , userList , c )
}
/ *
*
@ 作者 : 秦东
@ 时间 : 2023 - 11 - 24 11 : 36 : 32
@ 功能 : 获取表单数据
@ 参数
#
@ 返回值
#
@ 方法原型
#
* /
func GainTaskFormData ( taskId int64 ) ( mastesform , mastesformjson string ) {
if taskId > 0 {
var taskInfo modelAppPlatform . Task
err := taskInfo . GetCont ( map [ string ] interface { } { "`masters_key`" : taskId } , "`version_id`" )
if err != nil {
return
}
var formVerInfo modelAppPlatform . CustomerFormVersion
err = formVerInfo . GetCont ( map [ string ] interface { } { "`id`" : taskInfo . VersionId } , "`mastesform`" , "`mastesformjson`" )
if err != nil {
return
}
mastesform = formVerInfo . MastesForm
mastesformjson = formVerInfo . MastesFormJson
taskInfo . EiteCont ( map [ string ] interface { } { "`masters_key`" : taskId } , map [ string ] interface { } { "`mastesform`" : formVerInfo . MastesForm , "`mastesformjson`" : formVerInfo . MastesFormJson } )
}
return
}
/ *
*
@ 作者 : 秦东
@ 时间 : 2023 - 11 - 23 16 : 34 : 22
@ 功能 : 获取当前节点
@ 参数
#
@ 返回值
#
@ 方法原型
#
* /
func GainCurreNode ( flowStr string , step , nextStep , state int ) ( nodeInfo RunFlow , isOk bool ) {
if flowStr == "" {
return
}
var flowAry [ ] RunFlow
err := json . Unmarshal ( [ ] byte ( flowStr ) , & flowAry )
if err != nil {
return
}
if nextStep == 0 {
step = len ( flowAry )
} else {
switch state {
case 1 :
step = 0
case 2 :
if step != 1 {
step = step + 1
}
case 3 :
step = step + 1
case 4 :
step = len ( flowAry )
default :
step = step + 1
}
}
for _ , v := range flowAry {
if v . Step == step {
nodeInfo = v
isOk = true
return
}
}
return
}
/ *
*
@ 作者 : 秦东
@ 时间 : 2023 - 11 - 23 16 : 17 : 17
@ 功能 : 获取简短人员信息
@ 参数
# userKey 操作人
@ 返回值
#
@ 方法原型
#
* /
func GainSmaillUserInfo [ T publicmethod . GenericityVariable ] ( userKey T ) ( createrInfo UserSmallInfo ) {
var userInfo modelshr . ManCont
err := userInfo . GetCont ( map [ string ] interface { } { "`key`" : userKey } , "`id`" , "`key`" , "`name`" , "`number`" , "`icon`" , "`icon_photo`" , "`wechat`" , "`work_wechat`" )
if err != nil {
return
}
createrInfo . Id = userInfo . Id
createrInfo . Key = strconv . FormatInt ( userInfo . Key , 10 )
createrInfo . Name = userInfo . Name
createrInfo . Number = userInfo . Number
createrInfo . Icon = userInfo . Icon
if userInfo . IconPhpto != "" {
createrInfo . Icon = userInfo . IconPhpto
}
createrInfo . WeChat = userInfo . Wechat
if userInfo . WorkWechat != "" {
createrInfo . WeChat = userInfo . WorkWechat
}
return
}
/ *
*
@ 作者 : 秦东
@ 时间 : 2023 - 11 - 24 13 : 35 : 00
@ 功能 : 获取正在执行得任务流程
@ 参数
#
@ 返回值
#
@ 方法原型
#
* /
func ( a * ApiMethod ) GainRunTaskFlow ( c * gin . Context ) {
var requestData publicmethod . PublicId
err := c . ShouldBindJSON ( & requestData )
if err != nil {
publicmethod . Result ( 100 , err , c )
return
}
if requestData . Id == "" {
publicmethod . Result ( 100 , err , c )
return
}
var runFlowInfo modelAppPlatform . RunFlow
err = runFlowInfo . GetCont ( map [ string ] interface { } { "`flow_key`" : requestData . Id } )
if err != nil || runFlowInfo . FlowCont == "" {
publicmethod . Result ( 107 , err , c )
return
}
context , _ := c . Get ( overall . MyContJwt )
var userCont modelshr . ManCont
userCont . GetLoginCont ( context ) //当前操作人
var flowList [ ] RunFlow
err = json . Unmarshal ( [ ] byte ( runFlowInfo . FlowCont ) , & flowList )
if err != nil {
publicmethod . Result ( 107 , err , c )
return
}
//判断是否需要回写流程记录
flowAry , operational := CheckMakeCopy ( runFlowInfo . FlowKey , runFlowInfo . RunKey , runFlowInfo . Status , runFlowInfo . CurrentStep , flowList , userCont )
sendMap := publicmethod . MapOut [ string ] ( )
sendMap [ "flowList" ] = flowAry
sendMap [ "operational" ] = operational
sendMap [ "current_step" ] = runFlowInfo . CurrentStep
publicmethod . Result ( 0 , sendMap , c )
}
/ *
*
@ 作者 : 秦东
@ 时间 : 2023 - 11 - 24 13 : 52 : 00
@ 功能 : 检查当前人抄送是否查看
@ 参数
# uuid 流程唯一识别符
# endStep 当前步进值
# flowList 流程列表
# userCont 人员信息
@ 返回值
# flowMap 流程列表
@ 方法原型
#
* /
func CheckMakeCopy ( uuid , runKey int64 , state int , currepStep int , flowList [ ] RunFlow , userCont modelshr . ManCont ) ( flowMap [ ] RunFlow , operational bool ) {
if len ( flowList ) < 1 {
return
}
endStep := currepStep + 1
if endStep >= len ( flowList ) {
endStep = len ( flowList )
}
fmt . Printf ( "currepStep:%v---->endStep:%v\n" , currepStep , endStep )
operational = false
isWrite := false
userKey := strconv . FormatInt ( userCont . Key , 10 )
var cureeNode RunFlow
for i := 0 ; i < len ( flowList ) ; i ++ { //梳理抄送节点
if flowList [ i ] . Step == endStep {
cureeNode = flowList [ i ]
switch flowList [ i ] . ExamineMode {
case 1 :
operational = ApprovalInSequence ( flowList [ i ] . Operator , userCont )
case 2 :
operational = NotSignJointly ( runKey , state , flowList [ i ] . Operator , userCont )
case 3 :
operational = NotSignJointly ( runKey , state , flowList [ i ] . Operator , userCont )
default :
for m := 0 ; m < len ( flowList [ i ] . Operator ) ; m ++ {
if flowList [ i ] . Operator [ m ] . Id == userKey {
operational = true
}
}
}
fmt . Printf ( "currepStep:%v---->endStep:%v\n" , flowList [ i ] . ExamineMode , operational )
}
if flowList [ i ] . Types != 0 {
if flowList [ i ] . Step <= endStep {
if flowList [ i ] . Types == 2 {
flowList [ i ] . RunType = 0
flowList [ i ] . RunScope = 0
for j := 0 ; j < len ( flowList [ i ] . Operator ) ; j ++ {
if flowList [ i ] . Operator [ j ] . Id == userKey {
if len ( flowList [ i ] . Operator [ j ] . LogList ) < 1 {
var logCont LogList
logCont . State = 4 //状态 1、未操作;2、通过;3、驳回
logCont . TimeVal = publicmethod . UnixTimeToDay ( time . Now ( ) . Unix ( ) , 1 )
flowList [ i ] . Operator [ j ] . LogList = append ( flowList [ i ] . Operator [ j ] . LogList , logCont ) //操作记录
isWrite = true
FlowRunLog ( uuid , userCont . Key , 6 , flowList [ i ] . NodeKey , "查看抄送内容" , "" )
}
}
}
}
}
}
}
if isWrite {
flowJson , _ := json . Marshal ( flowList )
var runFlowInfo modelAppPlatform . RunFlow
runFlowInfo . EiteCont ( map [ string ] interface { } { "`flow_key`" : uuid } , map [ string ] interface { } { "`flow_cont`" : string ( flowJson ) } )
}
// fmt.Printf("cureeNode.CustomNode =====> %v\n", cureeNode.NodeKey)
timeStep := endStep - 1
if timeStep <= 0 {
timeStep = 1
}
fmt . Printf ( "operational--->%v\n" , operational )
if operational {
for k := 0 ; k < len ( flowList ) ; k ++ {
if flowList [ k ] . Step <= endStep {
flowList [ k ] . RunType = 0
flowList [ k ] . RunScope = 0
}
if flowList [ k ] . Step >= endStep {
if flowList [ k ] . CustomNode == cureeNode . NodeKey {
if flowList [ k ] . RunScope == 0 {
flowList [ k ] . RunScope = 1
}
// fmt.Printf("cureeNode.CustomNode =====> %v =====> %v =====> %v =====> %v\n", flowList[k].Step, endStep, flowList[k].CustomNode == cureeNode.NodeKey, flowList[timeStep].Operator)
for j := 0 ; j < len ( flowList [ timeStep ] . Operator ) ; j ++ {
if flowList [ timeStep ] . Operator [ j ] . Id == userKey {
flowList [ k ] . JudgeList = true
}
}
}
}
}
} else {
for k := 0 ; k < len ( flowList ) ; k ++ {
flowList [ k ] . JudgeList = false
}
}
flowMap = flowList
return
}
/ *
*
@ 作者 : 秦东
@ 时间 : 2023 - 11 - 24 16 : 46 : 33
@ 功能 : 依次审批
@ 参数
#
@ 返回值
#
@ 方法原型
#
* /
func ApprovalInSequence ( Operator [ ] OperatorList , userCont modelshr . ManCont ) bool {
allAry := len ( Operator )
if allAry < 1 {
return false
}
userKey := strconv . FormatInt ( userCont . Key , 10 )
if allAry == 1 {
for _ , v := range Operator {
if v . Id == userKey {
return true
}
}
}
minVal := 0
for _ , v := range Operator {
if minVal <= len ( v . LogList ) {
minVal = len ( v . LogList )
}
}
fmt . Printf ( "依次审批--a-->%v---->%v---->%v\n" , minVal , len ( Operator ) , allAry )
if minVal == 0 {
for i , v := range Operator {
fmt . Printf ( "依次审批---->%v---->%v\n" , i , v . Name )
if v . Id == userKey {
if i == 0 {
return true
}
}
}
return false
}
endTrue := true
if allAry >= 2 {
for i := 0 ; i < allAry - 2 ; i ++ {
if len ( Operator [ i ] . LogList ) <= minVal && len ( Operator [ i ] . LogList ) <= len ( Operator [ i + 1 ] . LogList ) {
if Operator [ i ] . Id == userKey {
endTrue = false
return true
}
}
}
}
if endTrue {
if Operator [ allAry - 1 ] . Id == userKey {
return true
}
}
return false
}
/ *
*
@ 作者 : 秦东
@ 时间 : 2023 - 11 - 24 16 : 31 : 43
@ 功能 : 处理非会签情况
@ 参数
# Operator 节点操作人
# userCont 当前操作人
@ 返回值
# bool //是否可以操作
@ 方法原型
#
* /
func NotSignJointly ( runKey int64 , state int , Operator [ ] OperatorList , userCont modelshr . ManCont ) bool {
if len ( Operator ) < 1 {
return false
}
if state != 3 {
return false
}
userKey := strconv . FormatInt ( userCont . Key , 10 )
runKeyStr := strconv . FormatInt ( runKey , 10 )
for _ , v := range Operator {
if v . Id == userKey {
for _ , lv := range v . LogList {
if lv . UID == runKeyStr {
return false
}
}
return true
}
}
return false
}
/ *
*
@ 作者 : 秦东
@ 时间 : 2023 - 11 - 25 0 8 : 52 : 13
@ 功能 : 提交审批结果
@ 参数
#
@ 返回值
#
@ 方法原型
#
* /
func ( a * ApiMethod ) SubmitApprovalResults ( c * gin . Context ) {
var requestData SubmitAppResults
err := c . ShouldBindJSON ( & requestData )
if err != nil {
publicmethod . Result ( 100 , err , c )
return
}
if requestData . Id == "" {
publicmethod . Result ( 100 , err , c )
return
}
if requestData . AgreeOrRefuse == 0 {
requestData . AgreeOrRefuse = 2
}
where := publicmethod . MapOut [ string ] ( )
where [ "`flow_key`" ] = requestData . Id
var flowInfo modelAppPlatform . RunFlow
err = flowInfo . GetCont ( where )
if err != nil {
publicmethod . Result ( 107 , err , c )
return
}
if flowInfo . NextStep == 0 || flowInfo . Status != 3 {
publicmethod . Result ( 1 , err , c , "此流程再不可审批状态!您的提交无效" )
return
}
if len ( requestData . FlowList ) < 1 {
if flowInfo . FlowCont != "" {
json . Unmarshal ( [ ] byte ( flowInfo . FlowCont ) , & requestData . FlowList )
} else {
publicmethod . Result ( 1 , err , c , "流程异常!您的提交无效" )
return
}
}
context , _ := c . Get ( overall . MyContJwt )
var userCont modelshr . ManCont
userCont . GetLoginCont ( context ) //当前操作人
// var runFlowCont RunWorkFlow
// runFlowCont.Step = flowInfo.CurrentStep
// runFlowCont.NextStep = flowInfo.NextStep
// runFlowCont.TotalSteps = len(requestData.FlowList)
// runFlowCont.Uuid = flowInfo.FlowKey
// runFlowCont.RunUid = flowInfo.RunKey
//runFlowCont.Participant = strings.Split(flowInfo.Participants, ",")
// runFlowCont.FlowList = requestData.FlowList
//执行流程
var runFlow RunWorkFlow
runFlow . Step = flowInfo . CurrentStep + 1 //执行第几部
runFlow . NextStep = flowInfo . NextStep
runFlow . TotalSteps = len ( requestData . FlowList ) //流程总长度
runFlow . Uuid = flowInfo . FlowKey
runFlow . RunUid = flowInfo . RunKey
runFlow . Participant = strings . Split ( flowInfo . Participants , "," )
runFlow . FlowList = requestData . FlowList
runFlow . FlowStepRun ( userCont . Key , requestData . AgreeOrRefuse , requestData . Suggest )
// fmt.Printf("执行流程--2->%v------>%v\n", runFlow.Step, runFlow.NextStep)
if runFlow . IsRun {
publicmethod . Result ( 1 , err , c , runFlow . Msg )
return
}
flowJsonCont , _ := json . Marshal ( runFlow . FlowList ) //将步进流转化成json流
saveFlowInfo := publicmethod . MapOut [ string ] ( )
saveTaskInfo := publicmethod . MapOut [ string ] ( )
saveFlowInfo [ "`flow_cont`" ] = flowJsonCont
saveFlowInfo [ "`current_step`" ] = runFlow . Step
saveFlowInfo [ "`next_step`" ] = runFlow . NextStep
if flowInfo . Participants != "" {
oldUser := strings . Split ( flowInfo . Participants , "," )
runFlow . Participant = append ( runFlow . Participant , oldUser ... )
}
//参与人去重
var parUser [ ] string
for _ , v := range runFlow . Participant {
if ! publicmethod . IsInTrue [ string ] ( v , parUser ) {
parUser = append ( parUser , v )
}
}
saveFlowInfo [ "`participants`" ] = strings . Join ( parUser , "," )
//下一步执行人
nextRunUser := runFlow . NextRunNodeUser ( requestData . AgreeOrRefuse )
saveFlowInfo [ "`next_executor`" ] = strings . Join ( nextRunUser , "," )
saveFlowInfo [ "`update_time`" ] = time . Now ( ) . Unix ( )
if requestData . AgreeOrRefuse == 1 {
if runFlow . NextStep != 0 {
saveFlowInfo [ "`status`" ] = 3
saveTaskInfo [ "`status`" ] = 3
} else {
saveFlowInfo [ "`status`" ] = 4
saveTaskInfo [ "`status`" ] = 4
}
} else {
saveFlowInfo [ "`runKey`" ] = publicmethod . GetUUid ( 6 )
if runFlow . Step != 1 {
saveFlowInfo [ "`status`" ] = 3
} else {
saveFlowInfo [ "`status`" ] = 2
saveTaskInfo [ "`status`" ] = 1
}
}
saveTaskInfo [ "`edit_time`" ] = time . Now ( ) . Unix ( )
gordb := overall . CONSTANT_DB_AppPlatform . Begin ( )
flowErr := gordb . Model ( & modelAppPlatform . RunFlow { } ) . Where ( where ) . Updates ( saveFlowInfo ) . Error
taskErr := gordb . Model ( & modelAppPlatform . Task { } ) . Where ( "`masters_key` = ?" , requestData . Id ) . Updates ( saveTaskInfo ) . Error
if flowErr != nil || taskErr != nil {
gordb . Rollback ( )
publicmethod . Result ( 100 , err , c , "数据提交失败!请重新提交!" )
return
}
gordb . Commit ( )
publicmethod . Result ( 0 , err , c )
}
/ *
*
@ 作者 : 秦东
@ 时间 : 2023 - 11 - 25 11 : 15 : 56
@ 功能 : 流程处理
@ 参数
# userKey 当前处理人
# AgreeToRefuse 1 : 同意 , 2 : 驳回
# Suggest 审批意见
@ 返回值
#
@ 方法原型
#
* /
func ( r * RunWorkFlow ) FlowStepRun ( userKey int64 , AgreeToRefuse int , Suggest string ) {
if len ( r . FlowList ) < 1 {
return
}
userKeyStr := strconv . FormatInt ( userKey , 10 )
for i := 0 ; i < r . TotalSteps ; i ++ {
if r . FlowList [ i ] . Step == r . Step {
fmt . Printf ( "节点审批人--11->%v------>%v------>%v\n" , r . FlowList [ i ] . Step , r . Step , userKeyStr )
//判断操作人是有操作权限或是否已经操作过
r . IsRun , r . Msg = JudgeOperUser ( userKey , r . RunUid , r . FlowList [ i ] . Operator )
fmt . Printf ( "节点审批人--12->%v------>%v------>%v\n" , r . IsRun , r . Msg , userKeyStr )
if r . IsRun {
return
} else {
if AgreeToRefuse != 1 { //驳回操作
r . FlowList [ i ] . Status = 3
operatorAry , nodeUser := FindOperator ( userKeyStr , r . RunUid , 3 , r . FlowList [ i ] . Operator , Suggest )
r . FlowList [ i ] . Operator = operatorAry
r . Participant = append ( r . Participant , nodeUser ... )
r . RejectNode ( r . FlowList [ i ] . GoBackNode )
return
} else { //同意操作
currentStep , nextStep := PaceStep ( r . RunUid , r . Step , r . TotalSteps , r . FlowList [ i ] )
fmt . Printf ( "节点审批人--0->%v------>%v->%v------>%v\n" , r . Step , r . NextStep , currentStep , nextStep )
r . FlowList [ i ] . Status = 2
operatorAry , nodeUser := FindOperator ( userKeyStr , r . RunUid , 2 , r . FlowList [ i ] . Operator , Suggest )
r . FlowList [ i ] . Operator = operatorAry
r . Participant = append ( r . Participant , nodeUser ... )
fmt . Printf ( "节点审批人--2->%v------>%v\n" , r . Step , r . NextStep )
switch r . FlowList [ i ] . Types {
case 0 :
r . Step = currentStep
r . NextStep = nextStep
FlowRunLog ( r . Uuid , userKey , 2 , r . FlowList [ i ] . NodeKey , "发起流程" , "" )
if JudgeRunNode ( currentStep , r . FlowList ) {
r . FlowStepRun ( userKey , AgreeToRefuse , Suggest )
}
fmt . Printf ( "节点审批人--3->%v------>%v\n" , r . Step , r . NextStep )
return
case 1 :
r . Step = currentStep
r . NextStep = nextStep
FlowRunLog ( r . Uuid , userKey , 2 , r . FlowList [ i ] . NodeKey , Suggest , "" )
fmt . Printf ( "节点审批人--4->%v------>%v\n" , r . Step , r . NextStep )
return
case 2 :
r . Step = currentStep
r . NextStep = nextStep
// fmt.Printf("执行曹总--0->%v->%v\n", r.Step, r.NextStep)
for _ , op := range r . FlowList [ i ] . Operator {
userkIntId , _ := strconv . ParseInt ( op . Id , 10 , 64 )
title := fmt . Sprintf ( "向%v发送抄送数据" , op . Name )
FlowRunLog ( r . Uuid , userkIntId , AgreeToRefuse , r . FlowList [ i ] . NodeKey , title , "" )
}
if r . NextStep > 0 {
r . FlowStepRun ( userKey , AgreeToRefuse , Suggest )
}
return
fmt . Printf ( "节点审批人--5->%v------>%v\n" , r . Step , r . NextStep )
case 3 :
r . Step = currentStep
r . NextStep = nextStep
FlowRunLog ( r . Uuid , userKey , 2 , r . FlowList [ i ] . NodeKey , Suggest , "" )
fmt . Printf ( "节点审批人--6->%v------>%v\n" , r . Step , r . NextStep )
return
default :
}
}
}
}
}
// fmt.Printf("节点审批人--end->%v------>%v\n", currentStep, nextStep)
// for i := 0; i < r.TotalSteps; i++ {
// if r.FlowList[i].Step == r.Step {
// // operNum := len(r.Operator) //判断有多少审批人
// switch len(r.FlowList[i].Operator) { //判断有多少审批人
// case 0: //没有审批人时
// if r.FlowList[i].NoHanderAction == 2 { //转交给管理员审批
// caoZuoRen, canYuRen := GainFlowRoleUser(10)
// r.FlowList[i].Operator = caoZuoRen
// r.Participant = append(r.Participant, canYuRen...)
// } else { //自动审批通过
// r.Step = currentStep
// r.NextStep = nextStep
// FlowRunLog(r.Uuid, 0, AgreeToRefuse, r.FlowList[i].NodeKey, "自动审批通过", "")
// if JudgeRunNode(currentStep, r.FlowList) {
// r.GainRunNode(userKey, AgreeToRefuse)
// }
// }
// case 1: //只有一个审批人时
// default: //多人审批时
// }
// switch r.FlowList[i].ExamineMode { //多人审批时采用的审批方式。0:无操作 1依次审批 2会签 3:非会签
// case 1:
// default:
// }
// }
// }
}
/ *
*
@ 作者 : 秦东
@ 时间 : 2023 - 11 - 27 14 : 04 : 01
@ 功能 : 删除工作流
@ 参数
#
@ 返回值
#
@ 方法原型
#
* /
func ( a * ApiMethod ) DelRunFlow ( c * gin . Context ) {
var requestData publicmethod . PublicStates
err := c . ShouldBindJSON ( & requestData )
if err != nil {
publicmethod . Result ( 100 , err , c )
return
}
if requestData . Id == "" {
publicmethod . Result ( 100 , err , c )
return
}
if requestData . Status == 0 {
requestData . Status = 1
}
where := publicmethod . MapOut [ string ] ( )
where [ "`id`" ] = requestData . Id
var runFlowInfo modelAppPlatform . RunFlow
err = runFlowInfo . GetCont ( where , "`flow_key`" , "`status`" )
if err != nil {
publicmethod . Result ( 107 , err , c )
return
}
if runFlowInfo . Status != 1 && runFlowInfo . Status != 2 {
publicmethod . Result ( 1 , err , c , "此流程不能操作!" )
return
}
saveRunFlow := publicmethod . MapOut [ string ] ( )
saveRunFlow [ "`status`" ] = requestData . Status
saveRunFlow [ "`update_time`" ] = time . Now ( ) . Unix ( )
saveTask := publicmethod . MapOut [ string ] ( )
if requestData . Status == 2 {
saveTask [ "`status`" ] = 1
} else {
saveTask [ "`status`" ] = requestData . Status
}
saveTask [ "`edit_time`" ] = time . Now ( ) . Unix ( )
var saveRunFlowInfo modelAppPlatform . RunFlow
err = saveRunFlowInfo . EiteCont ( where , saveRunFlow )
var saveTaskInfo modelAppPlatform . Task
saveTaskInfo . EiteCont ( map [ string ] interface { } { "`masters_key`" : runFlowInfo . FlowKey } , saveTask )
if err != nil {
publicmethod . Result ( 106 , err , c )
return
}
publicmethod . Result ( 0 , err , c )
}
/ *
*
@ 作者 : 秦东
@ 时间 : 2023 - 11 - 27 14 : 33 : 51
@ 功能 : 重新发起流程
@ 参数
#
@ 返回值
#
@ 方法原型
#
* /
func ( a * ApiMethod ) AfreshRunFlow ( c * gin . Context ) {
var requestData publicmethod . PublicId
err := c . ShouldBindJSON ( & requestData )
if err != nil {
publicmethod . Result ( 100 , err , c )
return
}
if requestData . Id == "" {
publicmethod . Result ( 100 , err , c )
return
}
where := publicmethod . MapOut [ string ] ( )
where [ "`flow_key`" ] = requestData . Id
var runFlowInfo modelAppPlatform . RunFlow
err = runFlowInfo . GetCont ( where , "`id`" , "`flow_cont`" , "`current_step`" , ` next_step ` , ` participants ` )
if err != nil {
publicmethod . Result ( 107 , err , c )
return
}
var flowList [ ] RunFlow
err = json . Unmarshal ( [ ] byte ( runFlowInfo . FlowCont ) , & flowList )
if err != nil {
publicmethod . Result ( 107 , err , c )
return
}
context , _ := c . Get ( overall . MyContJwt )
var userCont modelshr . ManCont
userCont . GetLoginCont ( context ) //当前操作人
startUs := strconv . FormatInt ( userCont . Key , 10 ) //当前操作人
runUuId := publicmethod . GetUUid ( 6 )
//执行流程
var runFlow RunWorkFlow
runFlow . Step = 0 //执行第几部
runFlow . FlowList = flowList
runFlow . Participant = append ( runFlow . Participant , startUs )
runFlow . TotalSteps = len ( flowList ) //流程总长度
runFlow . Uuid = runFlowInfo . Id
runFlow . RunUid = runUuId
runFlow . GainRunNode ( startUs , 2 , "重新发起流程" )
flowJsonCont , _ := json . Marshal ( runFlow . FlowList ) //将步进流转化成json流
SaveFlowCont := publicmethod . MapOut [ string ] ( )
SaveFlowCont [ "`flow_cont`" ] = string ( flowJsonCont )
SaveFlowCont [ "`current_step`" ] = runFlow . Step
SaveFlowCont [ "`next_step`" ] = runFlow . NextStep
SaveFlowCont [ "`runKey`" ] = runUuId
//参与人去重
var parUser [ ] string
for _ , v := range runFlow . Participant {
if ! publicmethod . IsInTrue [ string ] ( v , parUser ) {
parUser = append ( parUser , v )
}
}
SaveFlowCont [ "`participants`" ] = strings . Join ( parUser , "," )
nextRunUser := runFlow . NextRunNodeUser ( 1 )
SaveFlowCont [ "`next_executor`" ] = strings . Join ( nextRunUser , "," )
SaveFlowCont [ "`status`" ] = 3
if runFlow . NextStep <= 0 {
SaveFlowCont [ "`status`" ] = 4
}
SaveFlowCont [ "`update_time`" ] = time . Now ( ) . Unix ( )
err = runFlowInfo . EiteCont ( where , SaveFlowCont )
if err != nil {
publicmethod . Result ( 106 , err , c )
return
}
var taskInfo modelAppPlatform . Task
saveTask := publicmethod . MapOut [ string ] ( )
saveTask [ "`status`" ] = 3
saveTask [ "`edit_time`" ] = time . Now ( ) . Unix ( )
taskInfo . EiteCont ( map [ string ] interface { } { "`masters_key`" : requestData . Id } , saveTask )
publicmethod . Result ( 0 , err , c )
}