应用集成平台服务端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1763 lines
48 KiB

package taskmanagement
import (
"appPlatform/models/customerForm"
"appPlatform/models/flowlog"
"appPlatform/models/modelAppPlatform"
"appPlatform/models/modelshr"
"appPlatform/models/reviseform"
"appPlatform/overall"
"appPlatform/overall/publicmethod"
"encoding/json"
"fmt"
"strconv"
"strings"
"time"
"github.com/gin-gonic/gin"
)
/*
*
@ 作者: 秦东
@ 时间: 2024-04-10 08:26:53
@ 功能: 发起流程
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) StartRunWorkFlow(c *gin.Context) {
var requestData StartWorkFlow
err := c.ShouldBindJSON(&requestData)
if err != nil {
publicmethod.Result(10001, err, c, "未知进程!不可执行")
return
}
var taskInfo customerForm.TaskRecord
if requestData.Id == "" {
//获取当前任务内容
// taskInfo.EiteCont(map[string]interface{}{"`masters_key`": requestData.Id}, map[string]interface{}{"`status`": 1})
publicmethod.Result(10001, err, c, "未知进程!不可执行")
return
}
if len(requestData.FlowList) < 1 {
//获取当前任务内容
taskInfo.EiteCont(map[string]interface{}{"`masters_key`": requestData.Id}, map[string]interface{}{"`status`": 1})
publicmethod.Result(10001, err, c, "未知进程!不可执行")
return
}
if requestData.State == 0 {
requestData.State = 3
}
context, _ := c.Get(overall.MyContJwt)
var userCont modelshr.ManCont
userCont.GetLoginCont(context) //当前操作人
creetTime := time.Now().Unix() //当前时间
// //获取当前任务内容
// var taskInfo customerForm.TaskRecord
taskInfo.GetCont(map[string]interface{}{"`masters_key`": requestData.Id}, "`flow_key`", "`flow_run_sing`")
//获取流程详情
var flowVersionInfo modelAppPlatform.WorkFlowVersion
flowVersionInfo.GetCont(map[string]interface{}{"`id`": taskInfo.FlowRunSing}, "`content`")
uuid := publicmethod.GetUUid(1)
runUuId := publicmethod.GetUUid(6)
//执行工作流内容
var workFlowInfo customerForm.RunWorkflow
workFlowInfo.Id = uuid
1 year ago
workFlowInfo.FlowKey = taskInfo.FlowKey //统一识别符(任务标识符)
workFlowInfo.Version = strconv.FormatInt(taskInfo.FlowRunSing, 10) //工作流版本
workFlowInfo.VersionCont = flowVersionInfo.Content //当前工作流内容
workFlowInfo.Creater = userCont.Key //流程发起人
workFlowInfo.Status = requestData.State //状态:1、草稿;2:驳回;3:审批中;4:归档;5:删除
workFlowInfo.StartTime = creetTime //开始时间
workFlowInfo.UpdateTime = creetTime //更新时间
workFlowInfo.RunKey = runUuId //当前执行识别符
startCreaterKey := strconv.FormatInt(userCont.Key, 10) //当前操作人
//执行流程
var executeWorkflow RunWorkFlow
executeWorkflow.Step = 0 //执行第几部
executeWorkflow.FlowList = requestData.FlowList
executeWorkflow.Participant = append(executeWorkflow.Participant, startCreaterKey)
executeWorkflow.TotalSteps = len(requestData.FlowList) //流程总长度
executeWorkflow.Uuid = uuid //流程唯一识别符
executeWorkflow.RunUid = runUuId //执行Uid
if requestData.State == 3 {
executeWorkflow.GainRunNode(startCreaterKey, 2, "发起审批")
} else {
executeWorkflow.GainRunNode(startCreaterKey, 1, "")
}
flowJsonCont, _ := json.Marshal(executeWorkflow.FlowList) //将步进流转化成json流
workFlowInfo.FlowCont = string(flowJsonCont) //流程执行体
if requestData.State == 3 {
workFlowInfo.CurrentStep = executeWorkflow.Step
workFlowInfo.NextStep = executeWorkflow.NextStep
//参与人去重
var parUser []string
for _, v := range executeWorkflow.Participant {
if !publicmethod.IsInTrue[string](v, parUser) {
parUser = append(parUser, v)
}
}
workFlowInfo.Participants = strings.Join(parUser, ",")
nextRunUser := executeWorkflow.NextRunNodeUser(1)
workFlowInfo.NextExecutor = strings.Join(nextRunUser, ",")
if executeWorkflow.NextStep <= 0 {
workFlowInfo.Status = 4
}
}
1 year ago
fmt.Printf("步进值-1--%v---->%v》", executeWorkflow.Step, executeWorkflow.NextStep)
err = workFlowInfo.WriteCont() //写入执行工作流
if err != nil {
var taskInfo customerForm.TaskRecord
taskInfo.EiteCont(map[string]interface{}{"`masters_key`": requestData.Id}, map[string]interface{}{"`status`": 1})
publicmethod.Result(10001, err, c, "流程写入失败!请重新发起")
return
}
if executeWorkflow.NextStep <= 0 {
var taskCont customerForm.TaskRecord
1 year ago
taskCont.EiteCont(map[string]interface{}{"`masters_key`": requestData.Id}, map[string]interface{}{"`status`": 4, "`runFlowId`": uuid})
} else {
var taskCont customerForm.TaskRecord
1 year ago
taskCont.EiteCont(map[string]interface{}{"`masters_key`": requestData.Id}, map[string]interface{}{"`status`": requestData.State, "`runFlowId`": uuid})
}
publicmethod.Result(0, err, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2024-04-10 09:50:37
@ 功能: 获取下一步执行人
@ 参数
#isTrue 1:本节点审批完毕非1本节点还有未操作的人
@ 返回值
#userAry 下一步执行人
@ 方法原型
#
*/
func (r *RunWorkFlow) NextRunNodeUser(isTrue int) (userAry []string) {
if r.NextStep <= 0 {
return
}
if isTrue == 1 {
curStep := r.Step + 1
if curStep > r.TotalSteps {
curStep = r.TotalSteps
}
for _, v := range r.FlowList {
if v.Step == curStep {
for _, op := range v.Operator {
if !publicmethod.IsInTrue[string](op.Id, userAry) {
userAry = append(userAry, op.Id)
}
}
}
}
} else {
if r.Step == 1 {
return
}
for _, v := range r.FlowList {
if v.Step == r.Step {
for _, op := range v.Operator {
if !publicmethod.IsInTrue[string](op.Id, userAry) {
userAry = append(userAry, op.Id)
}
}
}
}
}
return
}
/*
*
@ 作者: 秦东
@ 时间: 2024-04-10 09:03:40
@ 功能: 执行工作流
@ 参数
#userKey //当前执行人
#AgreeToRefuse 同意或者驳回
#runCont //执行意见
@ 返回值
#
@ 方法原型
#
*/
func (r *RunWorkFlow) GainRunNode(userKey string, AgreeToRefuse int, runCont string) {
userkInt, _ := strconv.ParseInt(userKey, 10, 64) //将字符型转换成64位整型
curStep := 1
if r.Step != 0 {
curStep = r.Step
}
for i := 0; i < r.TotalSteps; i++ {
if r.FlowList[i].Step == curStep { //获取正在执行得节点
currentStep, nextStep := PaceStep(r.RunUid, r.Step, r.TotalSteps, r.FlowList[i]) //获取当前步进值和下一步步进值
operatorAry, nodeUser := FindOperator(userKey, r.RunUid, AgreeToRefuse, r.FlowList[i].Operator, runCont)
r.FlowList[i].Operator = operatorAry
r.FlowList[i].Status = AgreeToRefuse
r.Participant = append(r.Participant, nodeUser...)
1 year ago
fmt.Printf("节点类型设置---->%v---->%v---->%v\n", r.FlowList[i].Types, currentStep, nextStep)
switch r.FlowList[i].Types { //0:发起节点;1:审批节点;2:抄送;3:执行节点
case 0:
r.Step = currentStep
r.NextStep = nextStep
FlowRunLog(r.Uuid, userkInt, AgreeToRefuse, r.FlowList[i].NodeKey, runCont, "")
if JudgeRunNode(currentStep, r.FlowList) {
r.GainRunNode(userKey, AgreeToRefuse, runCont)
}
return
case 1:
r.Step = currentStep
r.NextStep = nextStep
return
case 2:
r.Step = currentStep
r.NextStep = 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.GainRunNode(userKey, AgreeToRefuse, runCont)
}
return
case 3:
r.Step = currentStep
r.NextStep = nextStep
return
default:
}
}
}
}
/*
*
@ 作者: 秦东
@ 时间: 2024-04-10 09:41:46
@ 功能: 判断当前节点是否要继续执行
@ 参数
#step 当前步进值
#FlowList 流程内容
@ 返回值
#isRun 是否继续执行
@ 方法原型
#
*/
func JudgeRunNode(step int, FlowList []RunFlow) (isRun bool) {
isRun = false
for _, v := range FlowList {
if v.Step == step {
if v.Types == 2 {
isRun = true
}
}
}
return
}
/*
*
@ 作者: 秦东
@ 时间: 2024-12-13 11:26:32
@ 功能: 判断下一个节点是否继续执行
@ 参数
#userKey 当前执行人
#nextStep 下一个节点
@ 返回值
#
@ 方法原型
#
*/
func (r *RunWorkFlow) ToNextNodeRunOrClose(userKey string, nextStep int) (isRun bool) {
isRun = false
if nextStep == 0 {
return isRun
}
runIdStr := strconv.FormatInt(r.RunUid, 10)
fmt.Printf("判断下一个节点是否继续执行:userKey:%v------->nextStep:%v\n", userKey, nextStep)
for _, v := range r.FlowList {
if nextStep == v.Step {
fmt.Printf("判断下一个节点是否继续执行:v.Step:%v----1--->v.Types:%v\n", v.Step, v.Types)
switch v.Types {
case 1, 3:
isMyTrue := false
optUserCount := len(v.Operator)
allPick := 0
for _, ov := range v.Operator {
if ov.Id == userKey {
isMyTrue = true
}
for _, ol := range ov.LogList {
if runIdStr == ol.UID {
allPick++
}
}
}
if isMyTrue {
if optUserCount > 1 {
switch v.ExamineMode {
case 1, 2:
if allPick == 0 {
isRun = true
} else {
if allPick == optUserCount {
isRun = true
} else {
isRun = false
}
}
default:
isRun = true
}
} else {
if optUserCount == 1 {
isRun = true
} else {
isRun = false
}
}
// isRun = true
}
fmt.Printf("判断下一个节点是否继续执行:isMyTrue:%v----3--->isRun:%v\n----3--->optUserCount:%v\n----3--->v.ExamineMode:%v\n", isMyTrue, isRun, optUserCount, v.ExamineMode)
case 2:
isRun = true
default:
isRun = false
}
}
}
return isRun
}
/*
*
@ 作者: 秦东
@ 时间: 2024-04-10 09:37:01
@ 功能: 流程执行记录
@ 参数
#uuid 流程uuid
#userKey 操作人
#AgreeToRefuse 同意或者驳回
#nodeKey 操作得节点
#idea 意见
#annex 附件
@ 返回值
#
@ 方法原型
#func FlowRunLog(uuid, userKey int64, AgreeToRefuse int, nodeKey, idea, annex string)
*/
func FlowRunLog(uuid, userKey int64, AgreeToRefuse int, nodeKey, idea, annex string) {
creetTime := time.Now().Unix()
var flowRunLog flowlog.WorkFlowLog
flowRunLog.FlowId = uuid //执行的流程"`
flowRunLog.Creater = userKey //操作人"`
flowRunLog.Status = AgreeToRefuse //状态:1、草稿;2:驳回;3:通过;4:归档;5:删除"`
flowRunLog.Content = idea //审批意见"`
flowRunLog.Annex = annex //附件"`
flowRunLog.Time = creetTime //创建时间"`
flowRunLog.EditTime = creetTime //ault编辑时间"`
flowRunLog.NodeKey = nodeKey //操作得节点
flowRunLog.WriteCont()
}
/*
*
@ 作者: 秦东
@ 时间: 2024-04-10 09:28:28
@ 功能: 操作人操作记录处理
@ 参数
#userKey 操作人
#runUid 执行Uid
#AgreeToRefuse 同意或者驳回
#operator 当前节点操作人
#suggest 审批意见
@ 返回值
#OperatorAry 操作人信息
#nodeUser 操作人唯一识别符
@ 方法原型
#
*/
func FindOperator(userKey string, runUid int64, AgreeToRefuse int, operator []OperatorList, suggest string) (OperatorAry []OperatorList, nodeUser []string) {
var logInfo LogList
logInfo.State = AgreeToRefuse //状态 1、未操作;2、通过;3、驳回
logInfo.TimeVal = publicmethod.UnixTimeToDay(time.Now().Unix(), 1)
logInfo.UID = strconv.FormatInt(runUid, 10)
logInfo.Cause = suggest
isNewAdd := true
for _, v := range operator {
nodeUser = append(nodeUser, v.Id)
1 year ago
// fmt.Printf("判断人员是谁?v.Id:%v == userKey:%v\n", v.Id, userKey)
if v.Id == userKey {
v.LogList = append(v.LogList, logInfo)
isNewAdd = false
}
OperatorAry = append(OperatorAry, v)
}
if isNewAdd {
var myInfo modelshr.ManCont
myInfo.GetCont(map[string]interface{}{"`key`": userKey})
nodeMan := TransformPublicUs(myInfo)
nodeMan.LogList = append(nodeMan.LogList, logInfo)
OperatorAry = append(OperatorAry, nodeMan)
}
return
}
/*
*
@ 作者: 秦东
@ 时间: 2024-04-10 09:15:45
@ 功能: 计算工作流执行得步伐
@ 参数
#runId 执行工作流唯一识别符
#step 当前执行得步进值
#totalSteps 总步数
#nodeInfo 节点内容
@ 返回值
#currentStep 当前步进值
#nextStep 下一步步进值
@ 方法原型
#func PaceStep(runId int64, step, totalSteps int, nodeInfo RunFlow) (currentStep, nextStep int)
*/
func PaceStep(runId int64, step, totalSteps int, nodeInfo RunFlow) (currentStep, nextStep int) {
if nodeInfo.ExamineMode == 0 { //多人审批时采用的审批方式。0:无操作 1依次审批 2会签 3:非会签
}
1 year ago
duoren, _ := json.Marshal(nodeInfo)
fmt.Printf("当前操作节点----->%v\n", string(duoren))
switch nodeInfo.ExamineMode {
case 0:
if step >= totalSteps {
currentStep = totalSteps
nextStep = 0
return
}
currentStep = step + 1
if currentStep >= totalSteps {
currentStep = totalSteps
nextStep = 0
return
}
nextStep = currentStep + 1
if nextStep >= totalSteps {
nextStep = totalSteps
}
case 3:
if step >= totalSteps {
currentStep = totalSteps
nextStep = 0
return
}
currentStep = step
if currentStep >= totalSteps {
currentStep = totalSteps
nextStep = 0
return
}
nextStep = currentStep + 1
if nextStep >= totalSteps {
nextStep = totalSteps
}
default:
runIdStr := strconv.FormatInt(runId, 10)
allUser := len(nodeInfo.Operator)
jiBuQi := 1
for _, v := range nodeInfo.Operator {
if len(v.LogList) > 0 {
for _, m := range v.LogList {
if m.UID == runIdStr {
jiBuQi++
}
}
} else {
jiBuQi++
}
}
if allUser <= jiBuQi { //全部审批完毕
if step >= totalSteps {
currentStep = totalSteps
nextStep = 0
return
}
currentStep = step
if currentStep >= totalSteps {
currentStep = totalSteps
nextStep = 0
return
}
nextStep = currentStep + 1
if nextStep >= totalSteps {
nextStep = totalSteps
}
} else {
currentStep = step - 1
if currentStep <= 0 {
currentStep = 1
}
if currentStep >= totalSteps {
currentStep = totalSteps
nextStep = 0
return
}
nextStep = currentStep + 1
if nextStep >= totalSteps {
nextStep = totalSteps
}
}
}
return
}
/*
*
@ 作者: 秦东
@ 时间: 2024-04-10 10:28:37
@ 功能: 从草稿箱发起审批
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) DraftsInitiateApproval(c *gin.Context) {
var requestData StartWorkFlow
err := c.ShouldBindJSON(&requestData)
if err != nil {
publicmethod.Result(100, err, c)
return
}
if requestData.Id == "" {
publicmethod.Result(100, err, c, "未知进程!不可执行")
return
}
if len(requestData.FlowList) < 1 {
publicmethod.Result(100, err, c, "未知进程!不可执行")
return
}
if requestData.State == 0 {
requestData.State = 3
}
context, _ := c.Get(overall.MyContJwt)
var userCont modelshr.ManCont
userCont.GetLoginCont(context) //当前操作人
creetTime := time.Now().Unix() //当前时间
var runInfo customerForm.RunWorkflow
1 year ago
err = runInfo.GetCont(map[string]interface{}{"`id`": requestData.Id}, "`flow_cont`", "`current_step`", "`runKey`", "`participants`")
if err != nil {
publicmethod.Result(107, err, c)
return
}
if len(requestData.FlowList) < 1 && runInfo.FlowCont != "" {
json.Unmarshal([]byte(runInfo.FlowCont), &requestData.FlowList)
}
startUs := strconv.FormatInt(userCont.Key, 10) //当前操作人
//执行流程
var runFlow RunWorkFlow
runFlow.Step = 0 //执行第几部
runFlow.FlowList = requestData.FlowList
runFlow.Participant = append(runFlow.Participant, startUs)
runFlow.TotalSteps = len(requestData.FlowList) //流程总长度
runFlow.Uuid = runInfo.FlowKey
runFlow.RunUid = runInfo.RunKey
if requestData.State == 3 {
runFlow.GainRunNode(startUs, 2, "发起审批")
} else {
runFlow.GainRunNode(startUs, 1, "")
}
flowJsonCont, _ := json.Marshal(runFlow.FlowList) //将步进流转化成json流
saveTask := publicmethod.MapOut[string]()
saveFlow := publicmethod.MapOut[string]()
saveFlow["`flow_cont`"] = flowJsonCont
saveFlow["`current_step`"] = runFlow.Step
saveFlow["`next_step`"] = runFlow.NextStep
//参与人去重
var parUser []string
for _, v := range runFlow.Participant {
if !publicmethod.IsInTrue[string](v, parUser) {
parUser = append(parUser, v)
}
}
saveFlow["`participants`"] = strings.Join(parUser, ",")
nextRunUser := runFlow.NextRunNodeUser(1)
saveFlow["`next_executor`"] = strings.Join(nextRunUser, ",")
saveFlow["`status`"] = requestData.State
saveTask["status"] = requestData.State
if runFlow.NextStep <= 0 {
saveFlow["`status`"] = 4
saveTask["status"] = 4
}
if requestData.State == 2 {
saveTask["status"] = 1
}
saveFlow["`update_time`"] = creetTime
saveTask["edit_time"] = creetTime
var saveRunInfo customerForm.RunWorkflow
1 year ago
err = saveRunInfo.EiteCont(map[string]interface{}{"`id`": requestData.Id}, saveFlow)
if err != nil {
publicmethod.Result(106, err, c)
return
}
var saveTaskInfo customerForm.TaskRecord
1 year ago
saveTaskInfo.EiteCont(map[string]interface{}{"`runFlowId`": requestData.Id}, saveTask)
publicmethod.Result(0, err, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2024-04-10 12:58:51
@ 功能: 获取正在执行得任务流程
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) GainRunTaskWorkflow(c *gin.Context) {
var requestData publicmethod.PublicId
err := c.ShouldBindJSON(&requestData)
if err != nil {
publicmethod.Result(200, err, c)
return
}
if requestData.Id == "" {
publicmethod.Result(200, err, c)
return
}
var runFlowInfo customerForm.RunWorkflow
1 year ago
// err = runFlowInfo.GetCont(map[string]interface{}{"`flow_key`": requestData.Id})
err = runFlowInfo.GetCont(map[string]interface{}{"`id`": requestData.Id})
if err != nil || runFlowInfo.FlowCont == "" {
publicmethod.Result(200, 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(200, err, c)
return
}
//判断是否需要回写流程记录
flowAry, operational := CheckMakeCopy(runFlowInfo.FlowKey, runFlowInfo.RunKey, runFlowInfo.Status, runFlowInfo.CurrentStep, flowList, userCont)
if runFlowInfo.Status != 3 {
operational = false
}
sendMap := publicmethod.MapOut[string]()
sendMap["flowList"] = flowAry
sendMap["operational"] = operational
sendMap["current_step"] = runFlowInfo.CurrentStep
publicmethod.Result(0, sendMap, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2024-04-10 13:01:12
@ 功能: 检查当前人抄送是否查看
@ 参数
#uuid 流程唯一识别符
#endStep 当前步进值
#flowList 流程列表
#userCont 人员信息
@ 返回值
#flowMap 流程
#operational 是否可操作
@ 方法原型
#
*/
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)
}
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
}
/*
*
@ 作者: 秦东
@ 时间: 2024-04-10 13:04:49
@ 功能: 处理非会签情况
@ 参数
#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
}
/*
*
@ 作者: 秦东
@ 时间: 2024-04-10 13:03:20
@ 功能: 依次审批
@ 参数
#Operator 操作人
#userCont 当前执行人
@ 返回值
#bool //是否可以操作
@ 方法原型
#
*/
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
}
/*
*
@ 作者: 秦东
@ 时间: 2024-04-11 11:05:04
@ 功能: 重新发起流程
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) AfreshRunWorkflow(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 customerForm.RunWorkflow
1 year ago
err = runFlowInfo.GetCont(map[string]interface{}{"`id`": requestData.Id}, "`id`", "`next_executor`", "`current_step`", "`next_step`", "`participants`", "`flow_key`", "`flow_cont`", "`runKey`")
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(map[string]interface{}{"`id`": runFlowInfo.Id}, SaveFlowCont)
if err != nil {
publicmethod.Result(106, err, c)
return
}
var taskInfo customerForm.TaskRecord
saveTask := publicmethod.MapOut[string]()
saveTask["`status`"] = 3
saveTask["`edit_time`"] = time.Now().Unix()
1 year ago
taskInfo.EiteCont(map[string]interface{}{"`runFlowId`": requestData.Id}, saveTask)
publicmethod.Result(0, runFlowInfo, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2024-04-11 11:42:29
@ 功能: 申请修改数据
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) ApplyForTableFormData(c *gin.Context) {
data, err := c.GetRawData() //接收表单提交得数据
if err != nil {
publicmethod.Result(100, err, c)
return
}
mapData := publicmethod.MapOut[string]() //初始化MAP
err = json.Unmarshal(data, &mapData) //将json字符串转换成Map
if err != nil {
publicmethod.Result(100, err, c)
return
}
masterKey := ""
if masterVal, ok := mapData["masters_key"]; !ok {
publicmethod.Result(1, err, c, "非法表单!不能提交数据!")
return
} else {
if masterValStr, ok := masterVal.(string); ok {
masterKey = masterValStr
}
}
var taskInfo customerForm.TaskRecord
err = taskInfo.GetCont(map[string]interface{}{"`masters_key`": mapData["masters_key"]})
if err != nil {
publicmethod.Result(1, err, c, "未知任务!不可修改!")
return
}
if taskInfo.Types == 1 {
switch taskInfo.Status {
case 3:
publicmethod.Result(1, err, c, "任务审批中不可执行修改审批")
return
default:
}
}
//获取指定版本表单内容
var tableVersion modelAppPlatform.CustomerFormVersion
err = tableVersion.GetCont(map[string]interface{}{"`id`": taskInfo.VersionId})
if err != nil {
publicmethod.Result(107, err, c)
return
}
// var formJsonCont customerform.CustomerFormMaster
// json.Unmarshal([]byte(taskInfo.MastesFormJson), &formJsonCont)
// var tableUnitList customerform.TableFormUnit
// tableUnitList.AnalysisTableFormUnitAttribute("", formJsonCont.List)
var sunFormName []string
if tableVersion.TableStructure != "" { //拆解获取子表名称
var sunFormStruct map[string]string
err = json.Unmarshal([]byte(tableVersion.TableStructure), &sunFormStruct)
if err == nil {
for _, v := range sunFormStruct {
if !publicmethod.IsInTrue[string](v, sunFormName) {
sunFormName = append(sunFormName, v)
}
}
}
} //子表名称集合
masterField := publicmethod.MapOut[string]() //主表数据
sunFieldAry := publicmethod.MapOut[string]() //子表数据
for k, v := range mapData {
if !publicmethod.IsInTrue[string](k, sunFormName) {
switch valAry := v.(type) {
case []interface{}:
if len(valAry) > 0 {
valStrJson, _ := json.Marshal(valAry)
masterField[k] = string(valStrJson)
} else {
masterField[k] = ""
}
default:
masterField[k] = v
}
} else {
sunFieldAry[k] = v
}
}
//获取当前操作人信息
context, _ := c.Get(overall.MyContJwt)
var userCont modelshr.ManCont
userCont.GetLoginCont(context) //当前操作人
cureeTime := time.Now().Unix()
masterOldData, err := MasterTableHandle(tableVersion.TableKey, userCont.Key, cureeTime, masterField)
if err != nil {
publicmethod.Result(106, err, c)
return
}
//自定义表单修改数据历史记录
var tableEditLog reviseform.EditFormDataLog
masterKeyInt, _ := strconv.ParseInt(masterKey, 10, 64)
tableEditLog.MastersKey = masterKeyInt
tableEditLog.SourceForm = taskInfo.VersionId //来源表单版本
if len(sunFormName) > 0 {
sonList, err := SonTableHandle(masterKey, userCont.Key, cureeTime, sunFieldAry)
// fmt.Printf("sonList--->%v\n", sonList)
if err == nil {
sunTableList, _ := json.Marshal(sonList)
tableEditLog.SunDataCont = string(sunTableList) //子表数值
}
}
runUuId := publicmethod.GetUUid(6)
//启动流程
var flowInfo customerForm.RunWorkflow
flowInfo.GetCont(map[string]interface{}{"`flow_key`": mapData["masters_key"]})
//是否为流程表单
if taskInfo.Types == 1 {
tableEditLog.FlowKey = flowInfo.FlowKey //流程标识符"`
tableEditLog.RunKey = runUuId //当前执行识别符"`
}
masterTableOldJson, _ := json.Marshal(masterOldData)
tableEditLog.DataCont = string(masterTableOldJson) //主表数据值
tableEditLog.AddTime = cureeTime //创建时间"`
tableEditLog.State = 1 //状态(1、新数据;2:已批准的老数据)"`
if expval, isOk := mapData["explicate"].(string); isOk {
tableEditLog.Explicate = expval //string 说明"`
}
tableEditLog.EditTime = cureeTime //创建时间"`
tableEditLog.Executor = userCont.Key //:执行人"`
err = overall.CONSTANT_DB_ReviseFormData.Model(&reviseform.EditFormDataLog{}).Create(&tableEditLog).Error
if err == nil {
startUs := strconv.FormatInt(userCont.Key, 10) //当前操作人
var flowList []RunFlow
json.Unmarshal([]byte(flowInfo.FlowCont), &flowList)
//执行流程
var runFlow RunWorkFlow
runFlow.Step = 0 //执行第几部
runFlow.FlowList = flowList
runFlow.Participant = append(runFlow.Participant, startUs)
runFlow.TotalSteps = len(flowList) //流程总长度
runFlow.Uuid = flowInfo.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()
flowInfo.EiteCont(map[string]interface{}{"`flow_key`": flowInfo.FlowKey}, SaveFlowCont)
taskInfo.EiteCont(map[string]interface{}{"`masters_key`": flowInfo.FlowKey}, map[string]interface{}{"`status`": 3})
}
sendInfo := publicmethod.MapOut[string]()
sendInfo["masterField"] = masterField
sendInfo["sunFieldAry"] = sunFieldAry
sendInfo["cureeTime"] = cureeTime
sendInfo["masterKey"] = masterKey
sendInfo["MasterTableHandle"] = masterOldData
sendInfo["err"] = err
publicmethod.Result(0, sendInfo, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2024-04-11 13:33:39
@ 功能: 审批处理
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) AuthorizeWorkflow(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]()
1 year ago
where["`id`"] = requestData.Id
var flowInfo customerForm.RunWorkflow
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 != "" {
err = json.Unmarshal([]byte(flowInfo.FlowCont), &requestData.FlowList)
if err != nil {
publicmethod.Result(1, err, c, "流程异常!您的提交无效")
return
}
} else {
publicmethod.Result(1, err, c, "流程异常!您的提交无效")
return
}
}
context, _ := c.Get(overall.MyContJwt)
var userCont modelshr.ManCont
userCont.GetLoginCont(context) //当前操作人
//执行流程
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)
1 year ago
// publicmethod.Result(1, runFlow, c, runFlow.Msg)
// return
if runFlow.IsRun {
publicmethod.Result(1, err, c, runFlow.Msg)
return
}
flowJsonContdfg, _ := json.Marshal(runFlow) //将步进流转化成json流
fmt.Printf("\n\n\n最终数据写入------------->%v\n\n\n", string(flowJsonContdfg))
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, ",")
1 year ago
var tsakInfos customerForm.TaskRecord
tsakInfos.GetCont(map[string]interface{}{"`runFlowId`": requestData.Id}, "`participant`")
if len(parUser) > 0 {
oldTaskUser := strings.Split(tsakInfos.Participant, ",")
for _, v := range parUser {
if !publicmethod.IsInTrue[string](v, oldTaskUser) {
oldTaskUser = append(oldTaskUser, v)
}
}
saveTaskInfo["`participant`"] = strings.Join(parUser, ",")
}
//抄送人
if flowInfo.MakeCopy != "" {
oldCopyUser := strings.Split(flowInfo.MakeCopy, ",")
runFlow.MakeCopy = append(runFlow.MakeCopy, oldCopyUser...)
}
var copyMan []string
for _, v := range runFlow.MakeCopy {
if !publicmethod.IsInTrue[string](v, copyMan) {
copyMan = append(copyMan, v)
}
}
saveFlowInfo["`makeCopy`"] = strings.Join(copyMan, ",")
//下一步执行人
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
JudgeEditFlow(flowInfo.FlowKey)
}
} 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_CustomerForm.Begin()
flowErr := gordb.Model(&customerForm.RunWorkflow{}).Where(where).Updates(saveFlowInfo).Error
1 year ago
taskErr := gordb.Model(&customerForm.TaskRecord{}).Where("`runFlowId` = ?", 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)
}
/*
*
@ 作者: 秦东
@ 时间: 2024-04-11 13:48:40
@ 功能: 判断是不是修改流程
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func JudgeEditFlow(flowKey int64) {
var logDataInfo reviseform.EditFormDataLog
err := logDataInfo.GetCont(map[string]interface{}{"`flow_key`": flowKey, "`state`": 1})
if err == nil {
oldCont := publicmethod.MapOut[string]()
//处理主表数据
if logDataInfo.DataCont != "" {
mastInfo := publicmethod.MapOut[string]()
json.Unmarshal([]byte(logDataInfo.DataCont), &mastInfo)
var oldMastInfoKey []string
for i, _ := range mastInfo {
if !publicmethod.IsInTrue[string](i, oldMastInfoKey) {
oldMastInfoKey = append(oldMastInfoKey, i)
}
}
//获取主表
var taskInfo customerForm.TaskRecord
err = taskInfo.GetCont(map[string]interface{}{"`masters_key`": flowKey}, "`version_id`")
if err == nil {
var cusFormVersion modelAppPlatform.CustomerFormView
err = cusFormVersion.GetCont(map[string]interface{}{"`id`": taskInfo.VersionId}, "`tablekey`")
if err == nil {
oldDataMast := publicmethod.MapOut[string]()
//获取原始数据
err = overall.CONSTANT_DB_CustomerForm.Table(cusFormVersion.TableKey).Where("`masters_key` = ?", flowKey).Find(&oldDataMast).Error
if err == nil {
for ol, ov := range oldDataMast {
for _, olv := range oldMastInfoKey {
if ol == olv {
oldCont[ol] = ov
}
}
}
}
overall.CONSTANT_DB_CustomerForm.Table(cusFormVersion.TableKey).Where("`masters_key` = ?", flowKey).Updates(mastInfo)
}
}
}
sunOldData := publicmethod.MapOut[string]()
//处理子表数据
if logDataInfo.SunDataCont != "" {
sunTableInfo := publicmethod.MapOut[string]()
json.Unmarshal([]byte(logDataInfo.SunDataCont), &sunTableInfo)
for i, v := range sunTableInfo {
var newSunDataAyr []map[string]interface{} //子表新数据
if val, isOk := v.([]interface{}); isOk { //判断子表数据是不是数组
for _, sv := range val { //循环输出数组数据
if sval, isTrues := sv.(map[string]interface{}); isTrues { //判断值是不是视图
oldSunKey := publicmethod.MapOut[string]()
for svi, svv := range sval { //解析视图值
oldSunKey[svi] = svv
}
newSunDataAyr = append(newSunDataAyr, oldSunKey)
}
}
}
var oldDataSun []map[string]interface{} //子表老数据
overall.CONSTANT_DB_CustomerForm.Table(i).Where("`masters_key` = ?", flowKey).Find(&oldDataSun)
sunOldData[i] = oldDataSun
var oldSunTableIdMAp []int64
for _, oldv := range oldDataSun {
if sunId, iskk := oldv["id"]; iskk {
if idInt, isKv := sunId.(uint64); isKv {
oldSunTableIdMAp = append(oldSunTableIdMAp, int64(idInt))
}
}
}
//一下是区分修改还新增或删除
var nooPerate []int64
if len(newSunDataAyr) > 0 {
for _, nv := range newSunDataAyr {
if sunId, iskk := nv["id"]; iskk {
if idInt, isKv := sunId.(uint64); isKv {
if !publicmethod.IsInTrue[int64](int64(idInt), oldSunTableIdMAp) {
nooPerate = append(nooPerate, int64(idInt))
}
}
overall.CONSTANT_DB_CustomerForm.Table(i).Where("`id` = ?", sunId).Updates(nv)
} else {
overall.CONSTANT_DB_CustomerForm.Table(i).Create(&nv)
}
}
}
if len(nooPerate) > 0 {
delSql := fmt.Sprintf("DELETE FROM %v WHERE `id` IN %v", i, nooPerate)
overall.CONSTANT_DB_CustomerForm.Exec(delSql)
}
}
}
saveDataLog := publicmethod.MapOut[string]()
mastJsonCont, _ := json.Marshal(oldCont)
saveDataLog["dataCont"] = string(mastJsonCont)
sunJsonCont, _ := json.Marshal(sunOldData)
// fmt.Printf("子表会写更新:%v\n", string(sunJsonCont))
saveDataLog["sunDataCont"] = string(sunJsonCont)
saveDataLog["`state`"] = 2
saveDataLog["`editTime`"] = time.Now().Unix()
var logFlow reviseform.EditFormDataLog
logFlow.EiteCont(map[string]interface{}{"`flow_key`": flowKey, "`state`": 1}, saveDataLog)
}
}
/*
*
@ 作者: 秦东
@ 时间: 2024-04-11 13:38:58
@ 功能: 流程处理
@ 参数
#userKey 当前处理人
#AgreeToRefuse 1同意2驳回
#Suggest 审批意见
@ 返回值
#
@ 方法原型
#
*/
func (r *RunWorkFlow) FlowStepRun(userKey int64, AgreeToRefuse int, Suggest string) {
if len(r.FlowList) < 1 {
return
}
rJson, _ := json.Marshal(r)
fmt.Printf("\n\n流程处理----1------>rJson:%v\n\n----------%v---------->%v----------%v\n\n\n", string(rJson), userKey, AgreeToRefuse, Suggest)
userKeyStr := strconv.FormatInt(userKey, 10)
for i := 0; i < r.TotalSteps; i++ {
if r.FlowList[i].Step == r.Step {
//判断操作人是有操作权限或是否已经操作过
isRun, msgInfo := JudgeOperUser(userKey, r.RunUid, r.FlowList[i].Operator)
r.IsRun = isRun
r.Msg = msgInfo
fmt.Printf("判断操作人是有操作权限或是否已经操作过---------->isRun:%v----------msgInfo:%v---------->r.IsRun:%v----------r.Msg:%v\n\n\n", isRun, msgInfo, r.IsRun, r.Msg)
if 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])
1 year ago
fmt.Printf("同意操作---->%v---->%v---->%v\n", currentStep, nextStep, r.FlowList[i].Types)
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("要执行得动作---->%v---->%v---->%v\n", r.FlowList[i].Types)
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)
}
return
case 1:
r.Step = currentStep
r.NextStep = nextStep
FlowRunLog(r.Uuid, userKey, 2, r.FlowList[i].NodeKey, Suggest, "")
if nextStep != 0 {
r.RunNodeHandle(userKey, AgreeToRefuse, Suggest)
}
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 {
1 year ago
r.MakeCopy = append(r.MakeCopy, op.Id)
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
case 3:
r.Step = currentStep
r.NextStep = nextStep
FlowRunLog(r.Uuid, userKey, 2, r.FlowList[i].NodeKey, Suggest, "")
return
default:
}
}
}
}
}
}
/*
*
@ 作者: 秦东
@ 时间: 2024-04-11 13:43:32
@ 功能: 查询驳回到哪个点
@ 参数
#nodeKey 返回的节点
@ 返回值
#isNew 是否重新发起
@ 方法原型
#
*/
func (r *RunWorkFlow) RejectNode(nodeKey string) (isNew bool) {
if nodeKey == "beginnode" {
r.Step = 1
if r.TotalSteps >= 2 {
r.NextStep = 2
isNew = false
} else {
r.NextStep = 0
isNew = true
}
return
}
for _, v := range r.FlowList {
if nodeKey == v.NodeKey {
r.Step = v.Step
nextStep := v.Step + 1
if nextStep <= r.TotalSteps {
r.NextStep = nextStep
isNew = false
} else {
r.NextStep = 0
isNew = true
}
return
}
}
return
}
/*
*
@ 作者: 秦东
@ 时间: 2024-04-11 13:40:35
@ 功能: 判断操作人是否已经操作过,并写入操作记录
@ 参数
#userKey 当前操作人
#runId 执行码
#Operator 操作人
@ 返回值
#isTrue
@ 方法原型
#func JudgeOperUser(userKey, runId int64, Operator []OperatorList) (bool, string) {}
*/
func JudgeOperUser(userKey, runId int64, Operator []OperatorList) (bool, string) {
if len(Operator) < 1 {
return true, "您不是此节点操作人!请不要提交!450"
}
caoZuoQuanXian := true
for _, v := range Operator {
if v.Id == strconv.FormatInt(userKey, 10) {
js, _ := json.Marshal(v)
fmt.Printf("判断操作人是否已经操作过\n userKey:%v====runId:%v=========v.Id=>%v\n\n\n%v\n\n\n", userKey, runId, v.Id, string(js))
// caoZuoQuanXian = false
if len(v.LogList) > 0 {
for _, m := range v.LogList {
if m.UID == strconv.FormatInt(runId, 10) {
fmt.Printf("判断操作人\n\n\n userKey:%v====runId:%v=========v.Id=>%v\n\n\n%v\n\n\n", userKey, runId, m.UID, m)
caoZuoQuanXian = true
return true, "您已经操作过此节点!请不要重复提交!"
}
}
caoZuoQuanXian = false
} else {
caoZuoQuanXian = false
}
jsLog, _ := json.Marshal(v.LogList)
fmt.Printf("是否已经操作过\n userKey:%v====runId:%v=========caoZuoQuanXian=>%v\n\n\n%v\n\n\n", userKey, runId, caoZuoQuanXian, string(jsLog))
}
}
fmt.Printf("是否已经操作过===========================>%v\n\n\n", caoZuoQuanXian)
if caoZuoQuanXian {
return true, "您不是此节点操作人!请不要提交!123"
}
fmt.Printf("是否已经操作过===========234234325================>%v\n\n\n", caoZuoQuanXian)
return false, ""
}
1 year ago
/*
*
@ 作者: 秦东
@ 时间: 2024-06-04 10:27:12
@ 功能: 获取执行流程
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) GainRunFlowStart(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(107, err, c)
return
}
var flowPage modelAppPlatform.FlowVersion //获取当前启用的流程信息
err = flowPage.GetCont(map[string]interface{}{"`key`": requestData.Id, "`state`": 1})
var flowCont FlowMainBody //整体流程架构
var sendInfo SendFlowInfo //执行流程
if err != nil && flowPage.Content == "" {
publicmethod.Result(0, sendInfo, c)
return
}
err = json.Unmarshal([]byte(flowPage.Content), &flowCont) //解析流程列表
if err != nil {
publicmethod.Result(0, sendInfo, c)
return
}
// publicmethod.Result(0, flowCont, c)
// return
1 year ago
context, _ := c.Get(overall.MyContJwt)
var userCont modelshr.ManCont
userCont.GetLoginCont(context) //获取当前操作人
var judgeWhy []ConditionListInfo //判断条件
var ddd []NodelPeopleInfo
workFlowInfo := flowCont.NodeConfig.CircularParsing(1, userCont, userCont.AdminOrg, judgeWhy, ddd)
sendInfo.Step = 1
sendInfo.NodeKey, sendInfo.NextStep, sendInfo.FlowList = ReformFlow(1, workFlowInfo)
publicmethod.Result(0, sendInfo, c)
}