diff --git a/api/version1/taskplatform/taskflow/flowType.go b/api/version1/taskplatform/taskflow/flowType.go index 26333d0..5959e4f 100644 --- a/api/version1/taskplatform/taskflow/flowType.go +++ b/api/version1/taskplatform/taskflow/flowType.go @@ -136,7 +136,7 @@ type RunFlow struct { PendPers []OperatorList `json:"pendpers"` //操作人ssss RunType int `json:"runtype"` //运行时选择 0:禁闭;1:发起人自选,2:发起人自己,3:有选中得节点指定,4:抄送节点 RunScope int `json:"runscope"` //运行时选择范围 0:不可选,1:本公司;2:本部门;当RunType = 4时:1:自选;非1:不可自选 - + // Operational bool `json:"operational"` //是否可提交审批意见 } //操作人 @@ -162,10 +162,11 @@ type OperatorList struct { // 节点操作人操作记录 type LogList struct { - State int `json:"state"` //状态 1、未操作;2、通过;3、驳回 + State int `json:"state"` //状态 1、未操作;2、通过;3、驳回;4、已查看 TimeVal string `json:"time"` Cause string `json:"cause"` //审批意见 Enclosure []EnclosureFormat `json:"enclosure"` //附件 + UID string `json:"uid"` //当前执行识别符 } // 附件格式 diff --git a/api/version1/taskplatform/taskflow/judgmentFlow.go b/api/version1/taskplatform/taskflow/judgmentFlow.go new file mode 100644 index 0000000..5b83dc0 --- /dev/null +++ b/api/version1/taskplatform/taskflow/judgmentFlow.go @@ -0,0 +1,128 @@ +package taskflow + +import ( + "appPlatform/models/modelshr" + "appPlatform/overall" + "appPlatform/overall/publicmethod" + "strconv" +) + +/* +* +@ 作者: 秦东 +@ 时间: 2023-11-25 13:14:11 +@ 功能: 获取流程管理员人员 +@ 参数 + + #role 角色ID + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func GainFlowRoleUser(role int) (Operator []OperatorList, userKey []string) { + var userInfoAry []modelshr.ManCont + overall.CONSTANT_DB_HR.Model(&modelshr.ManCont{}).Select("`key`,`name`,`number`,`icon`,`icon_photo`,`wechat`,`work_wechat`,`admin_org`,`position`,`teamid`,`mobilephone`,`company`").Where("FIND_IN_SET(?,`role`) AND `emp_type` BETWEEN ? AND ?", role, 1, 10).Find(&userInfoAry) + if len(userInfoAry) > 0 { + for _, uv := range userInfoAry { + Operator = append(Operator, TransformPublicUs(uv)) + usKey := strconv.FormatInt(uv.Key, 10) + if !publicmethod.IsInTrue[string](usKey, userKey) { + userKey = append(userKey, usKey) + } + } + } + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2023-11-25 13:29:04 +@ 功能: 判断操作人是否已经操作过,并写入操作记录 +@ 参数 + + #userKey 当前操作人 + #runId 执行码 + #Operator 操作人 + +@ 返回值 + + #isTrue + +@ 方法原型 + + #func JudgeOperUser(userKey, runId int64, Operator []OperatorList) (isTrue bool) +*/ +func JudgeOperUser(userKey, runId int64, Operator []OperatorList) (bool, string) { + if len(Operator) < 1 { + return true, "您不是此节点操作人!请不要提交!" + } + caoZuoQuanXian := true + for _, v := range Operator { + if v.Id == strconv.FormatInt(userKey, 10) { + caoZuoQuanXian = false + if len(v.LogList) > 0 { + for _, m := range v.LogList { + if m.UID == strconv.FormatInt(runId, 10) { + return true, "您已经操作过此节点!请不要重复提交!" + } + } + } + } + } + if caoZuoQuanXian { + return true, "您不是此节点操作人!请不要提交!" + } + return false, "" +} + +/* +* +@ 作者: 秦东 +@ 时间: 2023-11-25 13:50:28 +@ 功能: 查询驳回到哪个点 +@ 参数 + + #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 +} diff --git a/api/version1/taskplatform/taskflow/runflow.go b/api/version1/taskplatform/taskflow/runflow.go index b12e72f..065a9dc 100644 --- a/api/version1/taskplatform/taskflow/runflow.go +++ b/api/version1/taskplatform/taskflow/runflow.go @@ -43,7 +43,7 @@ func (a *ApiMethod) GenerateFlow(c *gin.Context) { requestData.Step = 1 } var flowInfo modelAppPlatform.FlowVersion - err = flowInfo.GetCont(map[string]interface{}{"`key`": requestData.Id}) + err = flowInfo.GetCont(map[string]interface{}{"`key`": requestData.Id, "`state`": 1}) if err != nil && flowInfo.Content == "" { publicmethod.Result(107, err, c) return diff --git a/api/version1/taskplatform/taskflow/taskFlow.go b/api/version1/taskplatform/taskflow/taskFlow.go new file mode 100644 index 0000000..64df126 --- /dev/null +++ b/api/version1/taskplatform/taskflow/taskFlow.go @@ -0,0 +1,654 @@ +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 (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("`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].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) + 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 int) (nodeInfo RunFlow, isOk bool) { + if flowStr == "" { + return + } + var flowAry []RunFlow + err := json.Unmarshal([]byte(flowStr), &flowAry) + if err != nil { + return + } + 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.CurrentStep, flowList, userCont) + sendMap := publicmethod.MapOut[string]() + sendMap["flowList"] = flowAry + sendMap["operational"] = operational + publicmethod.Result(0, sendMap, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2023-11-24 13:52:00 +@ 功能: 检查当前人抄送是否查看 +@ 参数 + + #uuid 流程唯一识别符 + #endStep 当前步进值 + #flowList 流程列表 + #userCont 人员信息 + +@ 返回值 + + #flowMap 流程列表 + +@ 方法原型 + + # +*/ +func CheckMakeCopy(uuid int64, endStep int, flowList []RunFlow, userCont modelshr.ManCont) (flowMap []RunFlow, operational bool) { + if len(flowList) < 1 { + return + } + 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(flowList[i].Operator, userCont) + case 3: + operational = NotSignJointly(flowList[i].Operator, userCont) + default: + for m := 0; m < len(flowList[i].Operator); m++ { + if flowList[i].Operator[m].Id == userKey { + operational = true + } + } + } + } + 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 + } + 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 + } + } + } + } + } + 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) + } + } + endTrue := true + 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(Operator []OperatorList, userCont modelshr.ManCont) bool { + if len(Operator) < 1 { + return false + } + userMap := make(map[string]int) + minVal := 0 + for _, v := range Operator { + userMap[v.Id] = len(v.LogList) + if minVal >= len(v.LogList) { + minVal = len(v.LogList) + } + } + userKey := strconv.FormatInt(userCont.Key, 10) + for i, m := range userMap { + if m == minVal && i == userKey { + return true + } + } + return false +} + +/* +* +@ 作者: 秦东 +@ 时间: 2023-11-25 08: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 = 1 //执行第几部 + runFlow.FlowList = requestData.FlowList + runFlow.TotalSteps = len(requestData.FlowList) //流程总长度 + runFlow.Uuid = flowInfo.FlowKey + runFlow.RunUid = flowInfo.RunKey + runFlow.FlowStepRun(userCont.Key, requestData.AgreeOrRefuse, requestData.Suggest) + + flowJsonCont, _ := json.Marshal(runFlow.FlowList) //将步进流转化成json流 + + saveFlowInfo := publicmethod.MapOut[string]() + saveFlowInfo["`flow_cont`"] = flowJsonCont + + // var runFlowContent modelAppPlatform.RunFlow + // var taskContent modelAppPlatform.Task +} + +/* +* +@ 作者: 秦东 +@ 时间: 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) + currentStep, nextStep := PaceStep(2, r.TotalSteps) + for i := 0; i < r.TotalSteps; i++ { + if r.FlowList[i].Step == r.Step { + //判断操作人是有操作权限或是否已经操作过 + r.IsRun, r.Msg = JudgeOperUser(userKey, r.RunUid, r.FlowList[i].Operator) + if r.IsRun { + return + } else { + + if AgreeToRefuse != 1 { //驳回操作 + r.FlowList[i].Status = 3 + operatorAry, nodeUser := FindOperator(userKeyStr, r.RunUid, 3, r.FlowList[i].Operator) + r.FlowList[i].Operator = operatorAry + r.Participant = append(r.Participant, nodeUser...) + r.RejectNode(r.FlowList[i].GoBackNode) + return + } else { //同意操作 + r.FlowList[i].Status = 2 + operatorAry, nodeUser := FindOperator(userKeyStr, r.RunUid, 2, r.FlowList[i].Operator) + r.FlowList[i].Operator = operatorAry + r.Participant = append(r.Participant, nodeUser...) + + 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) + } + case 1: + r.Step = currentStep + r.NextStep = nextStep + FlowRunLog(r.Uuid, userKey, 2, r.FlowList[i].NodeKey, Suggest, "") + 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) + } + case 3: + r.Step = currentStep + r.NextStep = nextStep + FlowRunLog(r.Uuid, userKey, 2, r.FlowList[i].NodeKey, Suggest, "") + default: + } + } + } + } + } + // 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: + // } + // } + // } +} diff --git a/api/version1/taskplatform/taskflow/types.go b/api/version1/taskplatform/taskflow/types.go index d30c916..43959c0 100644 --- a/api/version1/taskplatform/taskflow/types.go +++ b/api/version1/taskplatform/taskflow/types.go @@ -2,6 +2,7 @@ package taskflow import ( "appPlatform/api/version1/customerform" + "appPlatform/models/modelAppPlatform" "appPlatform/overall/publicmethod" "sync" @@ -199,3 +200,59 @@ type SwitchFlowStatus struct { publicmethod.CommonId[string] publicmethod.PublicStatus } + +// 启动流程 +type StartFlow struct { + publicmethod.PublicId + FlowList []RunFlow `json:"flowList"` //流程主体 +} + +// 流程执行 +type RunWorkFlow struct { + Step int //执行哪一步 + NextStep int //下一步 + TotalSteps int //总步数 + FlowList []RunFlow //流程 + Participant []string //参与人 + NewFlowList []RunFlow //流程 + Uuid int64 // + RunUid int64 //执行Uid + IsRun bool //是否结束执行 + Msg string //执行说明 +} + +// 获取任务列表 +type QueryTaskFlow struct { + publicmethod.PagesTurn + Class int `json:"class"` //类型:1、我的请求;2、待办事宜;3、已办事宜;4:草稿箱 + Title string `json:"title"` //任务标题 + State int `json:"state"` //状态:状态:1、草稿;2:驳回;3:审批中;4:归档;5:删除 +} + +// 输出任务列表 +type SendTaskFlowInfo struct { + modelAppPlatform.RunTaskFlow + FlowKeys string `json:"flowkeys" gorm:"-"` //唯一标识符 + CreaterInfo UserSmallInfo `json:"creatorInfo" gorm:"-"` //创建人信息 + StartDate string `json:"startDate" gorm:"-"` //创建日期 + CurrentNodeName string `json:"currentNodeName" gorm:"-"` //当前节点名称 + CurrentNodeUser []UserSmallInfo `json:"currentNodeUser" gorm:"-"` //节点操作人 +} + +// 人员剪短信息 +type UserSmallInfo struct { + Id int64 `json:"id"` + Key string `json:"key"` + Name string `json:"name"` + Number string `json:"number"` + Icon string `json:"icon"` + WeChat string `json:"weChat"` +} + +// 提交审批结果 +type SubmitAppResults struct { + publicmethod.PublicId + AgreeOrRefuse int `json:"agreeOrRefuse"` //1:同意;2:驳回 + Suggest string `json:"suggest"` //审批意见 + FlowList []RunFlow `json:"flowlist"` //执行流程 +} diff --git a/api/version1/taskplatform/taskflow/workFlowRun.go b/api/version1/taskplatform/taskflow/workFlowRun.go new file mode 100644 index 0000000..f42ce68 --- /dev/null +++ b/api/version1/taskplatform/taskflow/workFlowRun.go @@ -0,0 +1,357 @@ +package taskflow + +import ( + "appPlatform/models/flowlog" + "appPlatform/models/modelAppPlatform" + "appPlatform/models/modelshr" + "appPlatform/overall" + "appPlatform/overall/publicmethod" + "encoding/json" + "fmt" + "strconv" + "strings" + "time" + + "github.com/gin-gonic/gin" +) + +/* +* +@ 作者: 秦东 +@ 时间: 2023-11-22 16:13:21 +@ 功能: 发起工作流 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (a *ApiMethod) StartRunFlow(c *gin.Context) { + var requestData StartFlow + err := c.ShouldBindJSON(&requestData) + if err != nil { + publicmethod.Result(10001, err, c) + return + } + if requestData.Id == "" { + publicmethod.Result(10001, err, c, "未知进程!不可执行") + return + } + if len(requestData.FlowList) < 1 { + publicmethod.Result(10001, err, c, "未知进程!不可执行") + return + } + context, _ := c.Get(overall.MyContJwt) + var userCont modelshr.ManCont + userCont.GetLoginCont(context) //当前操作人 + creetTime := time.Now().Unix() //当前时间 + var taskInfo modelAppPlatform.Task + 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`") + var runFlowInfo modelAppPlatform.RunFlow + uuid := publicmethod.GetUUid(1) + runUuId := publicmethod.GetUUid(6) + runFlowInfo.Id = uuid + runFlowInfo.FlowKey, _ = strconv.ParseInt(requestData.Id, 10, 64) //统一识别符 + // runFlowInfo.FlowKey = taskInfo.FlowKey //工作流主体 + runFlowInfo.Version = strconv.FormatInt(taskInfo.FlowRunSing, 10) //工作流版本 + runFlowInfo.VersionCont = flowVersionInfo.Content //当前工作流内容 + + runFlowInfo.Creater = userCont.Key //流程发起人 + runFlowInfo.Status = 3 //状态:1、草稿;2:驳回;3:审批中;4:归档;5:删除 + runFlowInfo.StartTime = creetTime //开始时间 + runFlowInfo.UpdateTime = creetTime //更新时间 + runFlowInfo.RunKey = runUuId //当前执行识别符 + + startUs := strconv.FormatInt(userCont.Key, 10) //当前操作人 + + //执行流程 + var runFlow RunWorkFlow + runFlow.Step = 1 //执行第几部 + runFlow.FlowList = requestData.FlowList + runFlow.Participant = append(runFlow.Participant, startUs) + runFlow.TotalSteps = len(requestData.FlowList) //流程总长度 + runFlow.Uuid = uuid + runFlow.RunUid = runUuId + runFlow.GainRunNode(startUs, 2) + + // fmt.Printf("执行完毕--10->%v->%v\n", runFlow.Step, runFlow.NextStep) + + flowJsonCont, _ := json.Marshal(runFlow.FlowList) //将步进流转化成json流 + runFlowInfo.FlowCont = string(flowJsonCont) //流程执行体 + runFlowInfo.CurrentStep = runFlow.Step + runFlowInfo.NextStep = runFlow.NextStep + //参与人去重 + var parUser []string + for _, v := range runFlow.Participant { + if !publicmethod.IsInTrue[string](v, parUser) { + parUser = append(parUser, v) + } + } + runFlowInfo.Participants = strings.Join(parUser, ",") + nextRunUser := runFlow.NextRunNodeUser() + runFlowInfo.NextExecutor = strings.Join(nextRunUser, ",") + // xie, _ := json.Marshal(runFlowInfo) + // fmt.Printf("写入数据--10->%v\n", string(xie)) + if runFlow.NextStep <= 0 { + runFlowInfo.Status = 4 + } + + err = runFlowInfo.WriteCont() + if err != nil { + publicmethod.Result(10001, err, c, "流程写入失败!请重新发起") + return + } + if runFlow.NextStep <= 0 { + var taskCont modelAppPlatform.Task + taskCont.EiteCont(map[string]interface{}{"`masters_key`": requestData.Id}, map[string]interface{}{"`status`": 4}) + } + publicmethod.Result(0, err, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2023-11-23 10:05:43 +@ 功能: 流程执行记录 +@ 参数 + + #uuid 流程uuid + #userKey 操作人 + #AgreeToRefuse 同意或者驳回 + #nodeKey 操作得节点 + #idea 意见 + #annex 附件 + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +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() +} + +/* +* +@ 作者: 秦东 +@ 时间: 2023-11-23 08:59:16 +@ 功能: 获取下一步执行人 +@ 参数 + + #userAry 下一步执行人 + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (r *RunWorkFlow) NextRunNodeUser() (userAry []string) { + if r.NextStep <= 0 { + 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 +} + +/* +* +@ 作者: 秦东 +@ 时间: 2023-11-22 16:57:06 +@ 功能: 执行工作流 +@ 参数 + + #userKey //当前执行人 + #AgreeToRefuse 同意或者驳回 + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (r *RunWorkFlow) GainRunNode(userKey string, AgreeToRefuse int) { + userkInt, _ := strconv.ParseInt(userKey, 10, 64) + currentStep, nextStep := PaceStep(2, r.TotalSteps) + for i := 0; i < r.TotalSteps; i++ { + if r.FlowList[i].Step == r.Step { + operatorAry, nodeUser := FindOperator(userKey, r.RunUid, AgreeToRefuse, r.FlowList[i].Operator) + r.FlowList[i].Operator = operatorAry + r.FlowList[i].Status = AgreeToRefuse + r.Participant = append(r.Participant, nodeUser...) + switch r.FlowList[i].Types { + case 0: + r.Step = currentStep + r.NextStep = nextStep + FlowRunLog(r.Uuid, userkInt, AgreeToRefuse, r.FlowList[i].NodeKey, "发起流程", "") + if JudgeRunNode(currentStep, r.FlowList) { + r.GainRunNode(userKey, AgreeToRefuse) + } + return + case 1: + r.Step = currentStep + r.NextStep = 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.GainRunNode(userKey, AgreeToRefuse) + } + return + case 3: + r.Step = currentStep + r.NextStep = nextStep + return + default: + } + } + } + +} + +/* +* +@ 作者: 秦东 +@ 时间: 2023-11-23 08:46:38 +@ 功能: 判断当前节点是否要继续执行 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +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 +} + +/* +* +@ 作者: 秦东 +@ 时间: 2023-11-23 08:35:27 +@ 功能: 计算步伐 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func PaceStep(step, totalSteps int) (currentStep, nextStep int) { + // fmt.Printf("计算步伐--1-->%v-->%v\n", step, totalSteps) + if step >= totalSteps { + currentStep = totalSteps + nextStep = 0 + return + } + // fmt.Printf("计算步伐--2-->%v-->%v\n", currentStep, nextStep) + currentStep = step + if currentStep >= totalSteps { + currentStep = totalSteps + nextStep = 0 + return + } + // fmt.Printf("计算步伐--3-->%v-->%v\n", currentStep, nextStep) + nextStep = currentStep + 1 + if nextStep >= totalSteps { + nextStep = totalSteps + } + // fmt.Printf("计算步伐--4-->%v-->%v\n", currentStep, nextStep) + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2023-11-23 08:21:52 +@ 功能: 比对操作人 +@ 参数 + + #userKey 操作人 + #runUid 执行Uid + #AgreeToRefuse 同意或者驳回 + #operator 当前节点操作人 + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func FindOperator(userKey string, runUid int64, AgreeToRefuse int, operator []OperatorList) (OperatorAry []OperatorList, nodeUser []string) { + // isOk := true + var logCont LogList + logCont.State = AgreeToRefuse //状态 1、未操作;2、通过;3、驳回 + logCont.TimeVal = publicmethod.UnixTimeToDay(time.Now().Unix(), 1) + logCont.UID = strconv.FormatInt(runUid, 10) + for _, v := range operator { + nodeUser = append(nodeUser, v.Id) + if v.Id == userKey { + // isOk = false + v.LogList = append(v.LogList, logCont) + } + OperatorAry = append(OperatorAry, v) + } + + return +} diff --git a/api/version1/taskplatform/taskmanagement/appform.go b/api/version1/taskplatform/taskmanagement/appform.go index 3a10503..d7e2c84 100644 --- a/api/version1/taskplatform/taskmanagement/appform.go +++ b/api/version1/taskplatform/taskmanagement/appform.go @@ -127,6 +127,9 @@ func (a *ApiMethod) GainTaskList(c *gin.Context) { userCont.GetLoginCont(context) var list []modelAppPlatform.CustomerFormView gormDb := overall.CONSTANT_DB_AppPlatform.Model(&modelAppPlatform.CustomerFormView{}).Where("`status` = 1") + if requestData.Types != 0 { + gormDb = gormDb.Where("`classify` = ?", requestData.Types) + } //获取当前登录人得行政组织关系 var sunOrg publicmethod.GetOrgAllParent sunOrg.GetOrgSun(userCont.AdminOrg) @@ -640,6 +643,97 @@ func (a *ApiMethod) LookCustomerFormData(c *gin.Context) { publicmethod.Result(0, masterFormCont, c) } +/* +* +@ 作者: 秦东 +@ 时间: 2023-11-24 11:08:00 +@ 功能: 查看自定义表单记录数据(新版) +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (a *ApiMethod) LookNewCustomerFormData(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(1, err, c, "未知表单参数!请核对1后重新提交!") + return + } + //获取当前流程记录使用得哪个表单及表单组件列表 + var taskInfo modelAppPlatform.Task + err = taskInfo.GetCont(map[string]interface{}{"`masters_key`": requestData.Id}, "`version_id`", "`mastesformjson`") + if err != nil { + publicmethod.Result(107, err, c) + return + } + //展开表单 + var formJsonCont customerform.CustomerFormMaster + json.Unmarshal([]byte(taskInfo.MastesFormJson), &formJsonCont) + //获取流程使用得表单数据表 + var customerFormInfo modelAppPlatform.CustomerFormVersion + err = customerFormInfo.GetCont(map[string]interface{}{"`id`": taskInfo.VersionId}, "`tablekey`", "`table_structure`", "`dict`") + if err != nil { + publicmethod.Result(107, err, c) + return + } + var formUnitCont customerform.FormUnitInfo + formUnitCont.GainMasterAndSunFormUnit(customerFormInfo.TableKey, formJsonCont.List, true) + masterUnitList := make(map[string]customerform.MasterStruct) + for _, v := range formUnitCont.MasterInfo { + masterUnitList[v.Name] = v + } + //获取自定义创建表单数据 + masterFormCont := publicmethod.MapOut[string]() + err = overall.CONSTANT_DB_CustomerForm.Table(customerFormInfo.TableKey).Where("`masters_key` = ?", requestData.Id).Take(&masterFormCont).Error + if err != nil { + publicmethod.Result(107, err, c) + return + } + masterFormCont = CustomerFormCallBackVal(masterFormCont, masterUnitList) + if customerFormInfo.TableStructure != "" { + sunFormTable := publicmethod.MapOut[string]() + err = json.Unmarshal([]byte(customerFormInfo.TableStructure), &sunFormTable) + + sunTypeAry := make(map[string]map[string]customerform.MasterStruct) + for _, v := range formUnitCont.SunFormInfo { + sunTypeAry[v.TableName] = v.UbitInfo + } + if err == nil { + for _, v := range sunFormTable { + var sunContList []map[string]interface{} + if tableName, isOk := v.(string); isOk { + overall.CONSTANT_DB_CustomerForm.Table(tableName).Where("`masters_key` = ?", requestData.Id).Find(&sunContList) + var sunContListZhuanBian []map[string]interface{} + if len(sunContList) > 0 { + for _, sclv := range sunContList { + if sunTableType, sunIsOk := sunTypeAry[tableName]; sunIsOk { + masterFormCont := CustomerFormCallBackVal(sclv, sunTableType) + sunContListZhuanBian = append(sunContListZhuanBian, masterFormCont) + } else { + sunContListZhuanBian = append(sunContListZhuanBian, sclv) + } + } + } + masterFormCont[tableName] = sunContListZhuanBian + } + } + } + } + publicmethod.Result(0, masterFormCont, c) +} + /* * @ 作者: 秦东 diff --git a/api/version1/taskplatform/taskmanagement/formcontrol.go b/api/version1/taskplatform/taskmanagement/formcontrol.go index 869a35c..f40151b 100644 --- a/api/version1/taskplatform/taskmanagement/formcontrol.go +++ b/api/version1/taskplatform/taskmanagement/formcontrol.go @@ -556,12 +556,20 @@ func (a *ApiMethod) AddFormAddNewData(c *gin.Context) { var taskCont modelAppPlatform.Task taskCont.MastersKey = uuid taskCont.Title = fmt.Sprintf("%v-%v(%v)-%v", formCont.Name, userCont.Name, userCont.Number, publicmethod.UnixTimeToDay(cureeTime, 14)) //标题"` - taskCont.Creater = userCont.Key //创建人"` - taskCont.CreaterTime = cureeTime //创建时间"` - taskCont.EditTime = cureeTime //编辑时间"` - taskCont.Types = 1 //类型(1:普通表单;2:流程表单)"` - taskCont.VersionId = formCont.Id //来源于哪个表单"` + + taskCont.Creater = userCont.Key //创建人"` + taskCont.CreaterTime = cureeTime //创建时间"` + taskCont.EditTime = cureeTime //编辑时间"` + taskCont.Types = formCont.Classify //类型(1:普通表单;2:流程表单)"` + taskCont.VersionId = formCont.Id //来源于哪个表单"` taskCont.Status = 2 + if formCont.Classify == 2 { + taskCont.Status = 3 + taskCont.FlowKey = formCont.Flowkey + var flowInfo modelAppPlatform.FlowVersion + flowInfo.GetCont(map[string]interface{}{"`key`": formCont.Flowkey, "`state`": 1}, "`id`") + taskCont.FlowRunSing = flowInfo.Id + } //判断是否 if len(sunFieldAry) > 0 { @@ -580,13 +588,15 @@ func (a *ApiMethod) AddFormAddNewData(c *gin.Context) { publicmethod.Result(104, err, c) return } + taskCont.MastesForm = formCont.MastesForm + taskCont.MastesFormJson = formCont.MastesFormJson err = overall.CONSTANT_DB_AppPlatform.Create(&taskCont).Error // for k, v := range masrWriteMap { // fmt.Printf("%v----> %T\n", k, v) // } sendData := publicmethod.MapOut[string]() - sendData["uuid"] = uuid + sendData["uuid"] = strconv.FormatInt(uuid, 10) sendData["cureeTime"] = cureeTime sendData["formUnitCont"] = formUnitCont sendData["masterField"] = masterField diff --git a/api/version1/taskplatform/taskmanagement/types.go b/api/version1/taskplatform/taskmanagement/types.go index 224e4c1..2b511ba 100644 --- a/api/version1/taskplatform/taskmanagement/types.go +++ b/api/version1/taskplatform/taskmanagement/types.go @@ -55,6 +55,7 @@ type SendAppFormDataLog struct { type GainTaskListStruct struct { publicmethod.PagesTurn publicmethod.PublicStatus + Types int `json:"type"` } // 输出可执行得任务列表内容 diff --git a/apirouter/v1/taskrouter/taskrouter.go b/apirouter/v1/taskrouter/taskrouter.go index bd01812..a60f6a7 100644 --- a/apirouter/v1/taskrouter/taskrouter.go +++ b/apirouter/v1/taskrouter/taskrouter.go @@ -11,15 +11,16 @@ func (a *ApiRouter) RouterGroupPc(router *gin.RouterGroup) { apiRouter := router.Group("task_management") var taskManagementRouter = version1.AppApiEntry.TaskManagementApi { - apiRouter.GET("", taskManagementRouter.Index) //入口 - apiRouter.POST("", taskManagementRouter.Index) //入口 - apiRouter.POST("app_formdata_log", taskManagementRouter.AppFormDataLog) //非流程表单提交数据记录 - apiRouter.POST("gain_task_list", taskManagementRouter.GainTaskList) //获取可执行得任务列表 - apiRouter.POST("gain_task_versioncont", taskManagementRouter.GianTaskVersionCont) //根据版本获取表单内容 - apiRouter.POST("customer_form_adddata", taskManagementRouter.CustomerFormAddData) //自定义表单新增记录数据 - apiRouter.POST("customer_form_editdata", taskManagementRouter.CustomerFormEditData) //自定义表单编辑记录数据 - apiRouter.POST("look_customer_formdata", taskManagementRouter.LookCustomerFormData) //查看自定义表单记录数据列表 - apiRouter.POST("del_customer_formdata", taskManagementRouter.DelCustomerFormDataLog) //删除自定义表单记录数据 + apiRouter.GET("", taskManagementRouter.Index) //入口 + apiRouter.POST("", taskManagementRouter.Index) //入口 + apiRouter.POST("app_formdata_log", taskManagementRouter.AppFormDataLog) //非流程表单提交数据记录 + apiRouter.POST("gain_task_list", taskManagementRouter.GainTaskList) //获取可执行得任务列表 + apiRouter.POST("gain_task_versioncont", taskManagementRouter.GianTaskVersionCont) //根据版本获取表单内容 + apiRouter.POST("customer_form_adddata", taskManagementRouter.CustomerFormAddData) //自定义表单新增记录数据 + apiRouter.POST("customer_form_editdata", taskManagementRouter.CustomerFormEditData) //自定义表单编辑记录数据 + // apiRouter.POST("look_customer_formdata", taskManagementRouter.LookCustomerFormData) //查看自定义表单记录数据列表 + apiRouter.POST("look_customer_formdata", taskManagementRouter.LookNewCustomerFormData) //查看自定义表单记录数据列表 + apiRouter.POST("del_customer_formdata", taskManagementRouter.DelCustomerFormDataLog) //删除自定义表单记录数据 apiRouter.POST("add_form_data", taskManagementRouter.AddFormAddData) //用户端自定义表单新增记录 apiRouter.POST("add_form_newdata", taskManagementRouter.AddFormAddNewData) //用户端自定义表单新增记录(新版) @@ -42,5 +43,10 @@ func (a *ApiRouter) RouterGroupPc(router *gin.RouterGroup) { taskFlowApi.POST("generateFlow", taskFlowRouter.GenerateFlow) //生成步进工作流 taskFlowApi.POST("gainFlowPeople", taskFlowRouter.GainFlowPeople) //获取操作人、 taskFlowApi.POST("searchUserList", taskFlowRouter.SearchUserList) //自定义表单搜索人员 + + taskFlowApi.POST("startRunFlow", taskFlowRouter.StartRunFlow) //发起工作流 + taskFlowApi.POST("taskFlowList", taskFlowRouter.TaskFlowList) //流程任务 + + taskFlowApi.POST("gainRunTaskFlow", taskFlowRouter.GainRunTaskFlow) //获取正在执行得任务流程 } } diff --git a/models/flowlog/work_flow_log.go b/models/flowlog/work_flow_log.go index 176d78d..8b66400 100644 --- a/models/flowlog/work_flow_log.go +++ b/models/flowlog/work_flow_log.go @@ -15,6 +15,7 @@ type WorkFlowLog struct { Annex string `json:"annex" gorm:"column:annex;type:mediumtext;default:'';comment:附件"` Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` EditTime int64 `json:"editTime" gorm:"column:edit_time;type:bigint(20) unsigned;default:0;not null;comment:编辑时间"` + NodeKey string `json:"nodekey" gorm:"column:nodekey;type:varchar(255);comment:操作节点"` } func (WorkFlowLog *WorkFlowLog) TableName() string { diff --git a/models/modelAppPlatform/run_flow.go b/models/modelAppPlatform/run_flow.go index 51c4e72..e053bbf 100644 --- a/models/modelAppPlatform/run_flow.go +++ b/models/modelAppPlatform/run_flow.go @@ -8,18 +8,20 @@ import ( // 工作流执行主体 // 字典类型 type RunFlow struct { - Id int `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` + Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` FlowKey int64 `json:"flowKey" gorm:"column:flow_key;type:bigint(20) unsigned;default:0;not null;comment:工作流主体"` Version string `json:"version" gorm:"column:version;type:varchar(255);default:'';comment:使用得版本"` Status int `json:"status" gorm:"column:status;type:int(1) unsigned;default:1;not null;comment:状态:1、草稿;2:驳回;3:通过;4:归档;5:删除"` - FlowCont string `json:"flowcont" gorm:"column:flow_cont;type:longtext;comment:审批意见"` + FlowCont string `json:"flowcont" gorm:"column:flow_cont;type:longtext;comment:流程执行体"` Creater int64 `json:"creater" gorm:"column:creater;type:bigint(20) unsigned;default:0;not null;comment:流程发起人"` - CurrentStep int `json:"currentStep" gorm:"column:current_step;type:int(1) unsigned;default:1;not null;comment:当前节点"` - NextStep int `json:"nextStep" gorm:"column:next_step;type:int(1) unsigned;default:1;not null;comment:下一个节点。0:代表没有下一个节点。流程结束"` + CurrentStep int `json:"currentStep" gorm:"column:current_step;type:int(4) unsigned;default:1;not null;comment:当前节点"` + NextStep int `json:"nextStep" gorm:"column:next_step;type:int(4) unsigned;default:0;not null;comment:下一个节点。0:代表没有下一个节点。流程结束"` NextExecutor string `json:"nextExecutor" gorm:"column:next_executor;type:mediumtext;default:'';comment:下一步执行人"` Participants string `json:"participants" gorm:"column:participants;type:longtext;comment:参与人"` StartTime int64 `json:"startTime" gorm:"column:start_time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` UpdateTime int64 `json:"update_time" gorm:"column:update_time;type:bigint(20) unsigned;default:0;not null;comment:编辑时间"` + VersionCont string `json:"versionCont" gorm:"column:version_cont;type:longtext;comment:版本流程内容"` + RunKey int64 `json:"runKey" gorm:"column:runKey;type:bigint(20) unsigned;default:0;not null;comment:当前执行识别符"` } func (RunFlow *RunFlow) TableName() string { diff --git a/models/modelAppPlatform/run_task_flow.go b/models/modelAppPlatform/run_task_flow.go new file mode 100644 index 0000000..f670cbb --- /dev/null +++ b/models/modelAppPlatform/run_task_flow.go @@ -0,0 +1,78 @@ +package modelAppPlatform + +import ( + "appPlatform/overall" + "strings" +) + +/* +* +@ 作者: 秦东 +@ 时间: 2023-11-23 11:08:11 +@ 功能: 工作流任务视图 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +type RunTaskFlow struct { + Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` + FlowKey int64 `json:"flowKey" gorm:"column:flow_key;type:bigint(20) unsigned;default:0;not null;comment:工作流主体"` + Version string `json:"version" gorm:"column:version;type:varchar(255);default:'';comment:使用得版本"` + Status int `json:"status" gorm:"column:status;type:int(1) unsigned;default:1;not null;comment:状态:1、草稿;2:驳回;3:通过;4:归档;5:删除"` + FlowCont string `json:"flowcont" gorm:"column:flow_cont;type:longtext;comment:流程执行体"` + Creater int64 `json:"creater" gorm:"column:creater;type:bigint(20) unsigned;default:0;not null;comment:流程发起人"` + CurrentStep int `json:"currentStep" gorm:"column:current_step;type:int(4) unsigned;default:1;not null;comment:当前节点"` + NextStep int `json:"nextStep" gorm:"column:next_step;type:int(4) unsigned;default:0;not null;comment:下一个节点。0:代表没有下一个节点。流程结束"` + NextExecutor string `json:"nextExecutor" gorm:"column:next_executor;type:mediumtext;default:'';comment:下一步执行人"` + Participants string `json:"participants" gorm:"column:participants;type:longtext;comment:参与人"` + StartTime int64 `json:"startTime" gorm:"column:start_time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` + UpdateTime int64 `json:"update_time" gorm:"column:update_time;type:bigint(20) unsigned;default:0;not null;comment:编辑时间"` + VersionCont string `json:"versionCont" gorm:"column:version_cont;type:longtext;comment:版本流程内容"` + Title string `json:"title" gorm:"column:title;type:varchar(255) unsigned;default:'';not null;comment:标题"` + TableKey int64 `json:"table_key" gorm:"column:table_key;type:bigint(20) unsigned;default:0;not null;comment:主表标识"` + FlowRunSing int64 `json:"flowRunSing" gorm:"column:flow_run_sing;type:bigint(20) unsigned;default:0;not null;comment:主表标识"` + MastesForm string `json:"mastesform" gorm:"column:mastesform;type:longtext;default:'';comment:表单结构"` + MastesFormJson string `json:"mastesformjson" gorm:"column:mastesformjson;type:longtext;default:'';comment:表单结构json"` + RunKey int64 `json:"runKey" gorm:"column:runKey;type:bigint(20) unsigned;default:0;not null;comment:当前执行识别符"` +} + +func (RunTaskFlow *RunTaskFlow) TableName() string { + return "run_task_flow" +} + +// 获取内容 +func (cont *RunTaskFlow) GetCont(whereMap interface{}, field ...string) (err error) { + gormDb := overall.CONSTANT_DB_AppPlatform.Model(&cont) + if len(field) > 0 { + fieldStr := strings.Join(field, ",") + gormDb = gormDb.Select(fieldStr) + } + gormDb = gormDb.Where(whereMap) + err = gormDb.First(&cont).Error + return +} + +// 根据条件获取总数 +func (cont *RunTaskFlow) CountCont(whereMap interface{}) (countId int64) { + overall.CONSTANT_DB_AppPlatform.Model(&cont).Where(whereMap).Count(&countId) + return +} + +// 读取全部信息 +func (cont *RunTaskFlow) ContMap(whereMap interface{}, field ...string) (countAry []RunTaskFlow, err error) { + gormDb := overall.CONSTANT_DB_AppPlatform.Model(&cont) + if len(field) > 0 { + fieldStr := strings.Join(field, ",") + gormDb = gormDb.Select(fieldStr) + } + err = gormDb.Where(whereMap).Find(&countAry).Error + return +} diff --git a/models/modelAppPlatform/task.go b/models/modelAppPlatform/task.go index 3b47372..280fed5 100644 --- a/models/modelAppPlatform/task.go +++ b/models/modelAppPlatform/task.go @@ -7,15 +7,19 @@ import ( // 行政组织类型 type Task struct { - Id int `json:"id" gorm:"primaryKey;column:id;type:int(5) unsigned;not null;comment:Id;index"` - Title string `json:"title" gorm:"column:title;type:varchar(255) unsigned;default:'';not null;comment:标题"` - Creater int64 `json:"creater" gorm:"column:creater;type:bigint(20) unsigned;default:0;not null;comment:创建人"` - CreaterTime int64 `json:"creater_time" gorm:"column:creater_time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` - EditTime int64 `json:"editTime" gorm:"column:edit_time;type:bigint(20) unsigned;default:0;not null;comment:编辑时间"` - Types int `json:"types" gorm:"column:types;type:int(1) unsigned;default:1;not null;comment:类型(1:普通表单;2:流程表单)"` - VersionId int64 `json:"version_id" gorm:"column:version_id;type:bigint(20) unsigned;default:0;not null;comment:来源于哪个表单"` - Status int `json:"status" gorm:"column:status;type:int(1) unsigned;default:1;not null;comment:状态(1:草稿,2:发表;3:审批中;4:归档;5:删除)"` - MastersKey int64 `json:"masters_key" gorm:"column:masters_key;type:bigint(20) unsigned;default:0;not null;comment:主表标识"` + Id int `json:"id" gorm:"primaryKey;column:id;type:int(5) unsigned;not null;comment:Id;index"` + Title string `json:"title" gorm:"column:title;type:varchar(255) unsigned;default:'';not null;comment:标题"` + Creater int64 `json:"creater" gorm:"column:creater;type:bigint(20) unsigned;default:0;not null;comment:创建人"` + CreaterTime int64 `json:"creater_time" gorm:"column:creater_time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` + EditTime int64 `json:"editTime" gorm:"column:edit_time;type:bigint(20) unsigned;default:0;not null;comment:编辑时间"` + Types int `json:"types" gorm:"column:types;type:int(1) unsigned;default:1;not null;comment:类型(1:普通表单;2:流程表单)"` + VersionId int64 `json:"version_id" gorm:"column:version_id;type:bigint(20) unsigned;default:0;not null;comment:来源于哪个表单"` + Status int `json:"status" gorm:"column:status;type:int(1) unsigned;default:1;not null;comment:状态(1:草稿,2:发表;3:审批中;4:归档;5:删除)"` + MastersKey int64 `json:"masters_key" gorm:"column:masters_key;type:bigint(20) unsigned;default:0;not null;comment:主表标识"` + FlowKey int64 `json:"flow_key" gorm:"column:flow_key;type:bigint(20) unsigned;default:0;not null;comment:主表标识"` + FlowRunSing int64 `json:"flowRunSing" gorm:"column:flow_run_sing;type:bigint(20) unsigned;default:0;not null;comment:主表标识"` + MastesForm string `json:"mastesform" gorm:"column:mastesform;type:longtext;default:'';comment:表单结构"` + MastesFormJson string `json:"mastesformjson" gorm:"column:mastesformjson;type:longtext;default:'';comment:表单结构json"` } func (Task *Task) TableName() string { diff --git a/overall/publicmethod/technique.go b/overall/publicmethod/technique.go index bdbf8b4..8b65acc 100644 --- a/overall/publicmethod/technique.go +++ b/overall/publicmethod/technique.go @@ -173,6 +173,8 @@ func UnixTimeToDay(timeStamp int64, timeType int) (dateStr string) { timeTemplate = "2006.01" case 26: timeTemplate = "01.02" + case 27: + timeTemplate = "2006.01.02 15:04:05" default: timeTemplate = "2006-01-02 15:04:05" //常规类型 }