diff --git a/api/shiyan/maptostruct/shiyan.go b/api/shiyan/maptostruct/shiyan.go index 878017d..67b33c9 100644 --- a/api/shiyan/maptostruct/shiyan.go +++ b/api/shiyan/maptostruct/shiyan.go @@ -534,7 +534,7 @@ func (a *ApiMethod) CreateFlowChart(c *gin.Context) { var userCont modelshr.ManCont userCont.GetLoginCont(context) // workFlowInfo := flowVersionCont.GenerateFlow(userCont, 349) - workFlowInfo := flowVersionCont.NodeConfig.CircularParsing(1, userCont, 349, requestData.ConditionList) + workFlowInfo := flowVersionCont.NodeConfig.CircularParsing(1, userCont, 349, requestData.ConditionList, requestData.NodelPeople) sendData := publicmethod.MapOut[string]() // sendData["context"] = context // sendData["userCont"] = userCont diff --git a/api/shiyan/maptostruct/type.go b/api/shiyan/maptostruct/type.go index a40c935..5874348 100644 --- a/api/shiyan/maptostruct/type.go +++ b/api/shiyan/maptostruct/type.go @@ -118,4 +118,5 @@ type JiaMi struct { type CreatFlowView struct { publicmethod.PublicId ConditionList []taskflow.ConditionListInfo `json:"conditionList"` //判断条件主体 + NodelPeople []taskflow.NodelPeopleInfo `json:"nodelPeople"` //节点操作人 } diff --git a/api/version1/taskplatform/taskflow/flowType.go b/api/version1/taskplatform/taskflow/flowType.go index 7325253..26333d0 100644 --- a/api/version1/taskplatform/taskflow/flowType.go +++ b/api/version1/taskplatform/taskflow/flowType.go @@ -49,7 +49,7 @@ type NodePublicInfo struct { NodePublicInfoES Settype int `json:"settype"` // 审批人设置 1:指定成员; 2:主管;3:行政岗位; 4:发起人自选; 5:发起人自己;6:连续多级主管;7:指定前置审批为本节点设置审批人;8:表单字段;9:权限矩阵 SelectMode int `json:"selectMode"` //审批人数 1选一个人 2选多个人 - SelectRange int `json:"selectRange"` //选择范围 1.全公司 2指定成员 2指定角色 + SelectRange int `json:"selectRange"` //选择范围 1.全公司 2指定成员 3指定角色 DirectorLevel int `json:"directorLevel"` //审批终点 最高层主管数 ExamineMode int `json:"examineMode"` //多人审批时采用的审批方式 1:依次审批; 2:会签;3:非会签 NoHanderAction int `json:"noHanderAction"` //审批人为空时 1自动审批通过/不允许发起 2转交给审核管理员 @@ -133,6 +133,10 @@ type RunFlow struct { CustomNode string `json:"customNode"` //由哪个节点指定本节点审批人 JudgeList bool `json:"judgelist"` //是否可自己选中操作人 Operator []OperatorList `json:"operator"` //操作人 + 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:不可自选 + } //操作人 @@ -151,6 +155,9 @@ type OperatorList struct { Tema int64 `json:"tema"` //班组Id TemaName string `json:"temaname"` //班组名称 LogList []LogList `json:"log"` //操作记录 + NoEdit bool `json:"noedit"` //不可删除 + Tel string `json:"tel"` //电话 + CompanyName string `json:"companyName"` //公司 } // 节点操作人操作记录 @@ -178,3 +185,34 @@ type MultiLeveUserList struct { Level int //第几级 UserList []OperatorList //操作人 } + +type CreatFlowView struct { + publicmethod.PublicId + ConditionList []ConditionListInfo `json:"conditionList"` //判断条件主体 + NodelPeople []NodelPeopleInfo `json:"nodelPeople"` //节点操作人 + Step int `json:"step"` //当前执行第几步 +} +type NodelPeopleInfo struct { + FactorId string `json:"factorid"` + UserList string `json:"userList"` +} + +//输出工作流相关操作 +type SendFlowInfo struct { + Step int `json:"Step"` //当前执行第几步 + NodeKey string `json:"nodeKey"` //当前节点标识 + NextStep int `json:"nextStep"` //下一步执行第几步 + FlowList []RunFlow `json:"flowList"` //流程主体 +} + +//根据工号获取操作人信息 +type GainFlowOperator struct { + Numbers []string `json:"number"` +} + +//搜索人员参数 +type SearchUserCont struct { + publicmethod.PagesTurn + Name string `json:"name"` + Department int64 `json:"department"` +} diff --git a/api/version1/taskplatform/taskflow/flowengine.go b/api/version1/taskplatform/taskflow/flowengine.go index 2783720..5182353 100644 --- a/api/version1/taskplatform/taskflow/flowengine.go +++ b/api/version1/taskplatform/taskflow/flowengine.go @@ -239,11 +239,13 @@ func (a *ApiMethod) EditFlowCont(c *gin.Context) { jsonCont, _ := json.Marshal(requestData.FlowInfo) editInfo["`content`"] = jsonCont editInfo["`time`"] = time.Now().Unix() + saveData := publicmethod.MapOut[string]() + var customerForm modelAppPlatform.CustomerForm + err = customerForm.GetCont(map[string]interface{}{"`id`": flowVersionInfo.FormKey}, "`permitstr`", "`userpermit`") if isFormWrite { - var customerForm modelAppPlatform.CustomerForm - err = customerForm.GetCont(map[string]interface{}{"`id`": flowVersionInfo.FormKey}, "`permitstr`", "`userpermit`") + if err == nil { - saveData := publicmethod.MapOut[string]() + if len(orgList) > 0 { if customerForm.PermitStr != "" { oldOrgList := strings.Split(customerForm.PermitStr, ",") @@ -264,10 +266,7 @@ func (a *ApiMethod) EditFlowCont(c *gin.Context) { } else { editInfo["userpermit"] = customerForm.UserPermit } - if len(saveData) > 0 { - saveData["edit_time"] = time.Now().Unix() - customerForm.EiteCont(map[string]interface{}{"`id`": flowVersionInfo.FormKey}, saveData) - } + } } err = flowVersionInfo.EiteCont(why, editInfo) @@ -275,6 +274,11 @@ func (a *ApiMethod) EditFlowCont(c *gin.Context) { publicmethod.Result(106, err, c) return } + saveData["flowkey"] = flowVersionInfo.Key + saveData["classify"] = 2 + saveData["edit_time"] = time.Now().Unix() + customerForm.EiteCont(map[string]interface{}{"`id`": flowVersionInfo.FormKey}, saveData) + publicmethod.Result(0, err, c) } @@ -343,12 +347,13 @@ func (a *ApiMethod) SaveNewFlow(c *gin.Context) { } } } - + var customerForm modelAppPlatform.CustomerForm + err = customerForm.GetCont(map[string]interface{}{"`id`": flowVersionInfo.FormKey}, "`permitstr`", "`userpermit`") + saveData := publicmethod.MapOut[string]() if isFormWrite { - var customerForm modelAppPlatform.CustomerForm - err = customerForm.GetCont(map[string]interface{}{"`id`": flowVersionInfo.FormKey}, "`permitstr`", "`userpermit`") + if err == nil { - saveData := publicmethod.MapOut[string]() + if len(orgList) > 0 { if customerForm.PermitStr != "" { oldOrgList := strings.Split(customerForm.PermitStr, ",") @@ -370,10 +375,10 @@ func (a *ApiMethod) SaveNewFlow(c *gin.Context) { flowVersion.UserPermit = customerForm.UserPermit } saveData["flowkey"] = uuid - if len(saveData) > 0 { - saveData["edit_time"] = time.Now().Unix() - customerForm.EiteCont(map[string]interface{}{"`id`": flowVersionInfo.FormKey}, saveData) - } + // if len(saveData) > 0 { + // saveData["edit_time"] = time.Now().Unix() + // customerForm.EiteCont(map[string]interface{}{"`id`": flowVersionInfo.FormKey}, saveData) + // } } } err = flowVersion.InSetCont() @@ -381,6 +386,10 @@ func (a *ApiMethod) SaveNewFlow(c *gin.Context) { publicmethod.Result(104, err, c) return } + saveData["flowkey"] = flowVersionInfo.Key + saveData["classify"] = 2 + saveData["edit_time"] = time.Now().Unix() + customerForm.EiteCont(map[string]interface{}{"`id`": flowVersionInfo.FormKey}, saveData) publicmethod.Result(0, err, c) } diff --git a/api/version1/taskplatform/taskflow/runflow.go b/api/version1/taskplatform/taskflow/runflow.go index 3573ee5..b12e72f 100644 --- a/api/version1/taskplatform/taskflow/runflow.go +++ b/api/version1/taskplatform/taskflow/runflow.go @@ -5,11 +5,14 @@ import ( "appPlatform/models/modelshr" "appPlatform/overall" "appPlatform/overall/publicmethod" - "fmt" + "encoding/json" + "regexp" "sort" "strconv" "strings" "time" + + "github.com/gin-gonic/gin" ) /* @@ -19,8 +22,7 @@ import ( @ 功能: 生成步进工作流 @ 参数 - #creater 发起人信息 - #orgId 执行行政组织 + # @ 返回值 @@ -30,9 +32,123 @@ import ( # */ -func (f *FlowMainBody) GenerateFlow(creater modelshr.ManCont, orgId int64, condition []ConditionListInfo) (workFlowInfo []RunFlow) { - //生成工作流 - workFlowInfo = f.NodeConfig.CircularParsing(1, creater, orgId, condition) +func (a *ApiMethod) GenerateFlow(c *gin.Context) { + var requestData CreatFlowView + err := c.ShouldBindJSON(&requestData) + if err != nil { + publicmethod.Result(10001, err, c) + return + } + if requestData.Step == 0 { + requestData.Step = 1 + } + var flowInfo modelAppPlatform.FlowVersion + err = flowInfo.GetCont(map[string]interface{}{"`key`": requestData.Id}) + if err != nil && flowInfo.Content == "" { + publicmethod.Result(107, err, c) + return + } + var flowVersionCont FlowMainBody + err = json.Unmarshal([]byte(flowInfo.Content), &flowVersionCont) + if err != nil { + publicmethod.Result(104, err, c) + return + } + context, _ := c.Get(overall.MyContJwt) + var userCont modelshr.ManCont + userCont.GetLoginCont(context) + workFlowInfo := flowVersionCont.NodeConfig.CircularParsing(1, userCont, 349, requestData.ConditionList, requestData.NodelPeople) + + var sendInfo SendFlowInfo + sendInfo.Step = requestData.Step + sendInfo.NodeKey, sendInfo.NextStep, sendInfo.FlowList = ReformFlow(requestData.Step, workFlowInfo) + publicmethod.Result(0, sendInfo, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2023-11-21 09:26:44 +@ 功能: 重整工作流步进值 +@ 参数 + + #step 当前在执行第几步 + #nodeList 工作流主体 + +@ 返回值 + + #nodeKey 当前执行节点标识 + #nodeMap 工作流主体 + +@ 方法原型 + + # +*/ +func ReformFlow(step int, nodeList []RunFlow) (nodeKey string, nextStep int, nodeMap []RunFlow) { + sort.Slice(nodeList, func(i, j int) bool { + return nodeList[i].Step < nodeList[j].Step + }) + nodeNum := make(map[int]string) + for i, v := range nodeList { + nodeNum[i] = v.NodeKey + } + for i, v := range nodeList { + if v.Step == step { + nodeKey = v.NodeKey + } + lastStep := step + 1 + if lastStep == v.Step { + nextStep = lastStep + } + var nodeInfo RunFlow + nodeInfo.Step = v.Step //步骤 + nodeInfo.Types = v.Types //0:发起节点;1:审批节点;2:抄送;3:执行节点 + nodeInfo.NodeKey = v.NodeKey //节点识别符 + nodeInfo.NodeName = v.NodeName //节点名称 + nodeInfo.Status = v.Status //1:未到达;2:已审批;3:已驳回;4:再次审批 + if i-1 >= 0 { + nodeInfo.FromNode = nodeNum[i-1] + } + if val, isOk := nodeNum[i+1]; isOk { + nodeInfo.ArriveNode = val //到哪个节点 + } else { + nodeInfo.ArriveNode = "endflow" //到哪个节点 + } + nodeInfo.GoBackNode = v.GoBackNode //驳回返回节点 + nodeInfo.ExamineMode = v.ExamineMode //多人审批时采用的审批方式。0:无操作 1依次审批 2会签 3:非会签 + nodeInfo.NoHanderAction = v.NoHanderAction //审批人为空时 1自动审批通过/不允许发起 2转交给审核管理员 + nodeInfo.CustomNode = v.CustomNode //由哪个节点指定本节点审批人 + nodeInfo.JudgeList = v.JudgeList //是否可自己选中操作人 + + var operAry []OperatorList + for _, op := range v.Operator { + var operInfo OperatorList + operInfo.Id = op.Id //操作人ID + operInfo.Types = op.Types //1:人员;2:角色;3:行政组织 + operInfo.Name = op.Name //操作人姓名 + operInfo.Number = op.Number //操作人工号 + operInfo.Icon = op.Icon //操作人头像 + operInfo.IconBase64 = op.IconBase64 //操作人头像 + operInfo.Wechat = op.Wechat //微信Openid + operInfo.DepartmentId = op.DepartmentId //分厂Id + operInfo.DepartmentName = op.DepartmentName //分厂名称 + operInfo.PostId = op.PostId //职务Id + operInfo.PostName = op.PostName //职务名称 + operInfo.Tema = op.Tema //班组Id + operInfo.TemaName = op.TemaName //班组名称 + operInfo.LogList = op.LogList //操作记录 + operInfo.NoEdit = true //不可删除 + operInfo.Tel = op.Tel // + operInfo.CompanyName = op.CompanyName + operAry = append(operAry, operInfo) + } + nodeInfo.Operator = operAry //操作人 + nodeInfo.RunType = v.RunType //运行时选择 0:禁闭;1:发起人自选,2:发起人自己,3:有选中得节点指定,4:抄送节点 + nodeInfo.RunScope = v.RunScope //运行时选择范围 0:不可选,1:本公司;2:本部门;当RunType = 4时:1:自选;非1:不可自选 + nodeInfo.PendPers = v.PendPers // + nodeMap = append(nodeMap, nodeInfo) + } + // nodeMap = nodeList return } @@ -56,9 +172,10 @@ func (f *FlowMainBody) GenerateFlow(creater modelshr.ManCont, orgId int64, condi # */ -func (n *NodePublicInfo) CircularParsing(step int, creater modelshr.ManCont, orgId int64, condition []ConditionListInfo) (nodeList []RunFlow) { - fmt.Printf("step: %v; name:%v; Types:%v\n", step, n.NodeName, n.Types) +func (n *NodePublicInfo) CircularParsing(step int, creater modelshr.ManCont, orgId int64, condition []ConditionListInfo, nodelPeople []NodelPeopleInfo) (nodeList []RunFlow) { + // fmt.Printf("step: %v; name:%v; Types:%v\n", step, n.NodeName, n.Types) var nodeInfo RunFlow + nodeInfo.Step = step nodeInfo.Types = n.Types nodeInfo.NodeKey = n.NodeNumber @@ -72,6 +189,7 @@ func (n *NodePublicInfo) CircularParsing(step int, creater modelshr.ManCont, org } nodeInfo.ExamineMode = n.ExamineMode nodeInfo.NoHanderAction = n.NoHanderAction + //判断节点类型 //0:发起人;1:审批;2:抄送;3:执行人;4:条件;5:路由 switch n.Types { @@ -98,9 +216,16 @@ func (n *NodePublicInfo) CircularParsing(step int, creater modelshr.ManCont, org nodeInfo.Operator = GainOrgPostUserList(orgId, n.NodeUserList) } case 4: //发起人自选 + nodeInfo.RunType = 1 + nodeInfo.RunScope = n.SelectRange + if n.SelectRange != 1 { + // fmt.Printf("发起人自选--->%v\n--->%v\n", n.SelectRange, OperatorHandle(n.NodeUserList)) + nodeInfo.PendPers = OperatorHandle(n.NodeUserList) + + } case 5: //发起人自己 - var myCont modelshr.PersonArchives - myCont.GetCont(map[string]interface{}{"`id`": creater.Id}, "`key`", "`name`", "`number`", "`icon`", "`icon_photo`", "`wechat`", "`work_wechat`", "`admin_org`", "`position`", "`teamid`") + var myCont modelshr.ManCont + myCont.GetCont(map[string]interface{}{"`id`": creater.Id}, "`key`", "`name`", "`number`", "`icon`", "`icon_photo`", "`wechat`", "`work_wechat`", "`admin_org`", "`position`", "`teamid`", "`mobilephone`,`company`") nodeInfo.Operator = append(nodeInfo.Operator, TransformPublicUs(myCont)) case 6: //连续多级主管 var levelUserList ContinuousMultiLevelSupervisor @@ -114,7 +239,29 @@ func (n *NodePublicInfo) CircularParsing(step int, creater modelshr.ManCont, org nodeInfo.Operator = levelUserList.ObtainRelevantLevelLeaders(orgId) } case 7: //指定前置审批为本节点设置审批人 + nodeInfo.RunType = 3 + nodeInfo.CustomNode = n.CustomNode case 8: //表单字段 + reg1 := regexp.MustCompile(`\(([^)]+)\)`) //解析()内的数据 + var userNumber []string //工号切片 + for _, v := range n.NodeUserList { //判断本节点需要什么样的表格字段 + for _, e := range nodelPeople { //循环找出提交得表格字段 + if v.Id == e.FactorId { //判断提交得字段是否为当前节点操作字段 + userAry := reg1.FindAllStringSubmatch(e.UserList, -1) //按照正则规则提取数据 + for _, u := range userAry { + vLen := len(u) + if vLen > 0 { + if !publicmethod.IsInTrue[string](u[vLen-1], userNumber) { + userNumber = append(userNumber, u[vLen-1]) //将工号写入数组 + } + } + } + } + } + } + if len(userNumber) > 0 { + nodeInfo.Operator = GainUserCode(userNumber) + } case 9: //权限矩阵 if n.Attribute == 1 { nodeInfo.Operator = GainMatrixUserList(creater.AdminOrg, n.Matrix) @@ -123,15 +270,19 @@ func (n *NodePublicInfo) CircularParsing(step int, creater modelshr.ManCont, org } default: } + // jsonCont, _ := json.Marshal(nodeInfo) + // fmt.Printf("第%v步------>%v\n", step, string(jsonCont)) nodeList = append(nodeList, nodeInfo) if n.ChildNode != nil { - nodeList = append(nodeList, n.ChildNode.CircularParsing(step+1, creater, orgId, condition)...) + nodeList = append(nodeList, n.ChildNode.CircularParsing(step+1, creater, orgId, condition, nodelPeople)...) } case 2: + nodeInfo.RunType = 4 + nodeInfo.RunScope = n.CcSelfSelectFlag nodeInfo.Operator = OperatorHandle(n.NodeUserList) nodeList = append(nodeList, nodeInfo) if n.ChildNode != nil { - nodeList = append(nodeList, n.ChildNode.CircularParsing(step+1, creater, orgId, condition)...) + nodeList = append(nodeList, n.ChildNode.CircularParsing(step+1, creater, orgId, condition, nodelPeople)...) } case 4: case 5: @@ -142,7 +293,7 @@ func (n *NodePublicInfo) CircularParsing(step int, creater modelshr.ManCont, org }) lastStrp := step for _, pv := range n.ConditionNodes { //循环解析相关条件 - routerNodes := pv.ResolveRouting(step, creater, orgId, condition) + routerNodes := pv.ResolveRouting(step, creater, orgId, condition, nodelPeople) if len(routerNodes) > 0 { lastStrp = lastStrp + len(routerNodes) nodeList = append(nodeList, routerNodes...) @@ -150,14 +301,15 @@ func (n *NodePublicInfo) CircularParsing(step int, creater modelshr.ManCont, org } } if n.ChildNode != nil { - nodeList = append(nodeList, n.ChildNode.CircularParsing(lastStrp, creater, orgId, condition)...) + nodeList = append(nodeList, n.ChildNode.CircularParsing(lastStrp, creater, orgId, condition, nodelPeople)...) } } else { if n.ChildNode != nil { - nodeList = append(nodeList, n.ChildNode.CircularParsing(step+1, creater, orgId, condition)...) + nodeList = append(nodeList, n.ChildNode.CircularParsing(step+1, creater, orgId, condition, nodelPeople)...) } } default: + nodeInfo.RunType = 0 //发起人 var originator OperatorList originator.Id = strconv.FormatInt(creater.Key, 10) //操作人ID @@ -193,12 +345,12 @@ func (n *NodePublicInfo) CircularParsing(step int, creater modelshr.ManCont, org } var logCont LogList logCont.State = 1 //状态 1、未操作;2、通过;3、驳回 - logCont.TimeVal = publicmethod.UnixTimeToDay(time.Now().Unix(), 24) + logCont.TimeVal = publicmethod.UnixTimeToDay(time.Now().Unix(), 1) // originator.LogList = append(originator.LogList, logCont) //操作记录 nodeInfo.Operator = append(nodeInfo.Operator, originator) nodeList = append(nodeList, nodeInfo) if n.ChildNode != nil { - nodeList = append(nodeList, n.ChildNode.CircularParsing(step+1, creater, orgId, condition)...) + nodeList = append(nodeList, n.ChildNode.CircularParsing(step+1, creater, orgId, condition, nodelPeople)...) } } return @@ -224,7 +376,7 @@ func (n *NodePublicInfo) CircularParsing(step int, creater modelshr.ManCont, org # */ -func (n *NodePublicInfoES) ResolveRouting(step int, creater modelshr.ManCont, orgId int64, condition []ConditionListInfo) (nodeList []RunFlow) { +func (n *NodePublicInfoES) ResolveRouting(step int, creater modelshr.ManCont, orgId int64, condition []ConditionListInfo, nodelPeople []NodelPeopleInfo) (nodeList []RunFlow) { // fmt.Printf("解析条件---》%v\n", n.NodeName) if len(n.ConditionList) > 0 { // fmt.Printf("解析条件--1-》%v\n", n.ConditionList) @@ -249,16 +401,16 @@ func (n *NodePublicInfoES) ResolveRouting(step int, creater modelshr.ManCont, or default: } } - fmt.Printf("termAry:%v----->%v\n", len(n.ConditionList), termAry) + // fmt.Printf("termAry:%v----->%v\n", len(n.ConditionList), termAry) // if len(termAry) == len(n.ConditionList) { if termAry == len(n.ConditionList) { if n.ChildNode != nil { - nodeList = append(nodeList, n.ChildNode.CircularParsing(step, creater, orgId, condition)...) + nodeList = append(nodeList, n.ChildNode.CircularParsing(step, creater, orgId, condition, nodelPeople)...) } } } else { if n.ChildNode != nil { - nodeList = append(nodeList, n.ChildNode.CircularParsing(step, creater, orgId, condition)...) + nodeList = append(nodeList, n.ChildNode.CircularParsing(step, creater, orgId, condition, nodelPeople)...) } } return @@ -401,7 +553,7 @@ func JudgingCustomConditions(customFields []CustomFieldsInfo, presetVal []Condit } } } - fmt.Printf("处理自定义条件-->%v-->%v\n", isOk, len(customFields)) + // fmt.Printf("处理自定义条件-->%v-->%v\n", isOk, len(customFields)) if isOk == len(customFields) { isTrue = true } @@ -435,7 +587,7 @@ func ProcessMultipleSelectionResults(judging ConditionListInfo, presetVal []Cond if v.Types == 3 && judging.Factorid == v.Factorid { if judging.IsCheckbox { - fmt.Printf("termAry:%v----->%v----->%v\n", v.Answers, judging.Answers, len(v.Answers) <= len(judging.Answers)) + // fmt.Printf("termAry:%v----->%v----->%v\n", v.Answers, judging.Answers, len(v.Answers) <= len(judging.Answers)) //多选 if len(v.Answers) <= len(judging.Answers) { //判断答案个数是否小于等于设定条件值个数 isTrue = true @@ -446,7 +598,7 @@ func ProcessMultipleSelectionResults(judging ConditionListInfo, presetVal []Cond } } } else { //单选 - fmt.Printf("termAry:%v----->%v----->%v\n", v.Oneanswer, judging.Oneanswer, v.Oneanswer == judging.Oneanswer) + // fmt.Printf("termAry:%v----->%v----->%v\n", v.Oneanswer, judging.Oneanswer, v.Oneanswer == judging.Oneanswer) // if len(v.Answers) == len(judging.Answers) { // isTrue = false // for i := 0; i < len(v.Answers); i++ { @@ -551,7 +703,7 @@ func JudgingTermPeoOrgRoles(term []FlowPermissionInfo, creater modelshr.ManCont) */ func GainMatrixUserList(orgId int64, matrix MatrixInfo) (UserList []OperatorList) { allOrgId := publicmethod.HaveAllOrgRelation(orgId) //获取全部归属行政单位 - fmt.Printf("全部行政组织:%v---->%v\n", orgId, allOrgId) + // fmt.Printf("全部行政组织:%v---->%v\n", orgId, allOrgId) var keyVal int64 err := overall.CONSTANT_DB_AppPlatform.Model(&modelAppPlatform.MatrixHandler{}).Select("`number`").Where("`types` = 1 AND `mc_id` = ? AND `mh_id` = ? AND `hand_id` IN ?", matrix.MatrixId, matrix.FactorId, allOrgId).First(&keyVal).Error if err != nil { @@ -562,8 +714,8 @@ func GainMatrixUserList(orgId int64, matrix MatrixInfo) (UserList []OperatorList if err != nil || len(userKeys) < 1 { return } - var userInfoAry []modelshr.PersonArchives - overall.CONSTANT_DB_HR.Model(&modelshr.PersonArchives{}).Select("`key`,`name`,`number`,`icon`,`icon_photo`,`wechat`,`work_wechat`,`admin_org`,`position`,`teamid`").Where("`key` IN ? AND `emp_type` BETWEEN ? AND ?", userKeys, 1, 10).Find(&userInfoAry) + 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("`key` IN ? AND `emp_type` BETWEEN ? AND ?", userKeys, 1, 10).Find(&userInfoAry) if len(userInfoAry) > 0 { for _, uv := range userInfoAry { UserList = append(UserList, TransformPublicUs(uv)) @@ -592,7 +744,9 @@ func GainMatrixUserList(orgId int64, matrix MatrixInfo) (UserList []OperatorList */ func GainOrgPostUserList(orgId int64, approvers []NodeUserListInfo) (UserList []OperatorList) { if len(approvers) > 0 { - allOrgId := publicmethod.HaveAllOrgRelation(orgId) //获取全部归属行政单位 + _, companyId, _, _, _ := publicmethod.GetOrgStructurees(orgId) + allOrgId := publicmethod.HaveAllOrgRelation(companyId) //获取全部归属行政单位 + var userAry MultiLeveUserList for _, v := range approvers { //逐行分析职务 if v.Types == 4 { @@ -634,8 +788,8 @@ func (m *MultiLeveUserList) GainOrgPostPeople(orgId []int64, options []OptionsIn } } if len(postId) > 0 { - var userInfoAry []modelshr.PersonArchives - overall.CONSTANT_DB_HR.Model(&modelshr.PersonArchives{}).Select("`key`,`name`,`number`,`icon`,`icon_photo`,`wechat`,`work_wechat`,`admin_org`,`position`,`teamid`").Where("`person_in_charge` = 1 AND `admin_org` IN ? AND position = ? AND `emp_type` BETWEEN ? AND ?", orgId, postId, 1, 10).Find(&userInfoAry) + 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("`person_in_charge` = 1 AND `admin_org` IN ? AND position = ? AND `emp_type` BETWEEN ? AND ?", orgId, postId, 1, 10).Find(&userInfoAry) if len(userInfoAry) > 0 { for _, uv := range userInfoAry { m.UserList = append(m.UserList, TransformPublicUs(uv)) @@ -738,8 +892,8 @@ func (c *ContinuousMultiLevelSupervisor) ObtainRelevantLevelLeadersUser(level in var orgInfo modelshr.AdministrativeOrganization err := orgInfo.GetCont(map[string]interface{}{"`id`": orgId}, "`superior`") if err == nil { - var userList []modelshr.PersonArchives - err = overall.CONSTANT_DB_HR.Model(&modelshr.PersonArchives{}).Select("`key`,`name`,`number`,`icon`,`icon_photo`,`wechat`,`work_wechat`,`admin_org`,`position`,`teamid`").Where("`person_in_charge` = 1 AND `admin_org` = ? AND `emp_type` BETWEEN ? AND ?", orgId, 1, 10).Find(&userList).Error + var userList []modelshr.ManCont + err = overall.CONSTANT_DB_HR.Model(&modelshr.ManCont{}).Select("`key`,`name`,`number`,`icon`,`icon_photo`,`wechat`,`work_wechat`,`admin_org`,`position`,`teamid`,`mobilephone`,`company`").Where("`person_in_charge` = 1 AND `admin_org` = ? AND `emp_type` BETWEEN ? AND ?", orgId, 1, 10).Find(&userList).Error if err == nil { var userAry MultiLeveUserList @@ -805,8 +959,8 @@ func OperatorHandle(userList []NodeUserListInfo) (userAry []OperatorList) { default: } } - var userContMap []modelshr.PersonArchives - overall.CONSTANT_DB_HR.Model(&modelshr.PersonArchives{}).Select("`key`,`name`,`number`,`icon`,`icon_photo`,`wechat`,`work_wechat`,`admin_org`,`position`,`teamid`").Where("`key` IN ?", userIdAry).Find(&userContMap) + var userContMap []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("`key` IN ?", userIdAry).Find(&userContMap) for _, v := range userContMap { userAry = append(userAry, TransformPublicUs(v)) } @@ -831,17 +985,23 @@ func OperatorHandle(userList []NodeUserListInfo) (userAry []OperatorList) { # */ -func TransformPublicUs(v modelshr.PersonArchives) (userCont OperatorList) { +func TransformPublicUs(v modelshr.ManCont) (userCont OperatorList) { userCont.Id = strconv.FormatInt(v.Key, 10) userCont.Types = 1 //1:人员;2:角色;3:行政组织 userCont.Name = v.Name //操作人姓名 userCont.Number = v.Number //操作人工号 userCont.Icon = v.Icon //操作人头像 - userCont.IconBase64 = v.IconPhoto //操作人头像 - userCont.Wechat = v.Wechat //微信Openid + userCont.IconBase64 = v.IconPhpto //操作人头像 + userCont.Wechat = v.Wechat //微信Openid、 + userCont.Tel = v.Mobilephone if v.WorkWechat != "" { userCont.Wechat = v.WorkWechat //微信Openid } + if v.Company != 0 { + var orgGroupCont modelshr.AdministrativeOrganization + orgGroupCont.GetCont(map[string]interface{}{"`id`": v.Company}, "`name`") + userCont.CompanyName = orgGroupCont.Name //公司名称 + } _, companyId, _, _, _ := publicmethod.GetOrgStructurees(v.AdminOrg) userCont.DepartmentId = companyId //分厂Id if companyId != 0 { @@ -864,3 +1024,121 @@ func TransformPublicUs(v modelshr.PersonArchives) (userCont OperatorList) { } return } + +/* +* +@ 作者: 秦东 +@ 时间: 2023-11-20 16:06:09 +@ 功能: 根据工号获取人员信息 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func GainUserCode(userNumber []string) (userAry []OperatorList) { + 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("`number` IN ? AND `emp_type` BETWEEN ? AND ?", userNumber, 1, 10).Find(&userInfoAry) + if len(userInfoAry) > 0 { + for _, uv := range userInfoAry { + userAry = append(userAry, TransformPublicUs(uv)) + } + } + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2023-11-22 10:00:34 +@ 功能: 获取操作人、 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (a *ApiMethod) GainFlowPeople(c *gin.Context) { + var requestData GainFlowOperator + err := c.ShouldBindJSON(&requestData) + if err != nil || len(requestData.Numbers) < 1 { + publicmethod.Result(10001, err, c) + return + } + usSry := GainUserCode(requestData.Numbers) + if len(usSry) < 1 { + publicmethod.Result(10001, err, c, "没有数据") + return + } + publicmethod.Result(0, usSry, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2023-11-22 10:19:10 +@ 功能: 自定义表单搜索人员 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (a *ApiMethod) SearchUserList(c *gin.Context) { + var requestData SearchUserCont + c.ShouldBindJSON(&requestData) + if requestData.Page == 0 { + requestData.Page = 1 + } + if requestData.PageSize == 0 { + requestData.PageSize = 10 + } + gormDb := overall.CONSTANT_DB_HR.Model(&modelshr.PersonArchives{}).Select("`number`").Where("`number` NOT LIKE ?", "%W%") + if requestData.Name != "" { + gormDb = gormDb.Where("number LIKE ? OR name LIKE ?", "%"+requestData.Name+"%", "%"+requestData.Name+"%") + } + if requestData.Department != 0 { + var sunOrg publicmethod.GetOrgAllParent + sunOrg.GetOrgSonAllId(requestData.Department) + sunOrg.Id = append(sunOrg.Id, requestData.Department) + gormDb = gormDb.Where("admin_org IN ?", sunOrg.Id) + } + gormDb = gormDb.Where("emp_type BETWEEN ? AND ?", 1, 10) + var total int64 + totalErr := gormDb.Count(&total).Error + if totalErr != nil { + total = 0 + } + var idAry []string + gormDb = publicmethod.PageTurningSettings(gormDb, requestData.Page, requestData.PageSize) + err := gormDb.Find(&idAry).Error + var userList []OperatorList + if err != nil || len(idAry) < 1 { + publicmethod.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(userList)), userList, c) + return + } + usSry := GainUserCode(idAry) + if len(usSry) < 1 { + publicmethod.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(userList)), userList, c) + return + } + publicmethod.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(usSry)), usSry, c) +} diff --git a/api/version1/taskplatform/taskmanagement/appform.go b/api/version1/taskplatform/taskmanagement/appform.go index c0140e0..3a10503 100644 --- a/api/version1/taskplatform/taskmanagement/appform.go +++ b/api/version1/taskplatform/taskmanagement/appform.go @@ -210,7 +210,29 @@ func (a *ApiMethod) GianTaskVersionCont(c *gin.Context) { publicmethod.Result(107, err, c) return } - publicmethod.Result(0, versionCont, c) + var sendInfo CallBackFormStruct + sendInfo.Id = versionCont.Id + sendInfo.TableKey = versionCont.TableKey //表单标识符"` + sendInfo.Version = versionCont.Version //版本号"` + sendInfo.Status = versionCont.Status //显示状态(1:启用;2:禁用,3:删除)"` + sendInfo.MastesForm = versionCont.MastesForm //表单结构"` + sendInfo.MastesFormJson = versionCont.MastesFormJson //表单结构json"` + sendInfo.Creater = versionCont.Creater //创建人"` + sendInfo.CreaterTime = versionCont.CreaterTime //创建时间"` + sendInfo.EditTime = versionCont.EditTime //编辑时间"` + sendInfo.TableStructure = versionCont.TableStructure //字表结构"` + sendInfo.Dict = versionCont.Dict //字表结构"` + sendInfo.CfId = versionCont.CfId // + sendInfo.Name = versionCont.Name //表单名称"` + sendInfo.Classify = versionCont.Classify //分类1:表单;2:流程表单"` + sendInfo.Permit = versionCont.Permit //授权范围"` + sendInfo.PermitStr = versionCont.PermitStr //授权范围"` + sendInfo.Flowkey = versionCont.Flowkey //关联工作流"` + sendInfo.UserPermit = versionCont.UserPermit //可见人员"` + sendInfo.PostPermit = versionCont.PostPermit //可见角色"` + sendInfo.FlowkeyStr = strconv.FormatInt(versionCont.Flowkey, 10) + sendInfo.CreaterStr = strconv.FormatInt(versionCont.Creater, 10) + publicmethod.Result(0, sendInfo, c) } /* diff --git a/api/version1/taskplatform/taskmanagement/types.go b/api/version1/taskplatform/taskmanagement/types.go index c29de0e..224e4c1 100644 --- a/api/version1/taskplatform/taskmanagement/types.go +++ b/api/version1/taskplatform/taskmanagement/types.go @@ -71,3 +71,10 @@ type GainCustomerFormLogInfo struct { publicmethod.CommonId[string] MastersKey string `json:"formId"` } + +// 返回自定义表单数据 +type CallBackFormStruct struct { + modelAppPlatform.CustomerFormView + FlowkeyStr string `json:"flowkeystr"` + CreaterStr string `json:"createrstr"` +} diff --git a/apirouter/v1/taskrouter/taskrouter.go b/apirouter/v1/taskrouter/taskrouter.go index ee017e1..bd01812 100644 --- a/apirouter/v1/taskrouter/taskrouter.go +++ b/apirouter/v1/taskrouter/taskrouter.go @@ -39,5 +39,8 @@ func (a *ApiRouter) RouterGroupPc(router *gin.RouterGroup) { taskFlowApi.POST("edit_flow_cont", taskFlowRouter.EditFlowCont) //编辑工作流 taskFlowApi.POST("save_new_flow", taskFlowRouter.SaveNewFlow) //另存为新版 taskFlowApi.POST("switch_flow_version", taskFlowRouter.SwitchFlowVersion) //启用&禁用 + taskFlowApi.POST("generateFlow", taskFlowRouter.GenerateFlow) //生成步进工作流 + taskFlowApi.POST("gainFlowPeople", taskFlowRouter.GainFlowPeople) //获取操作人、 + taskFlowApi.POST("searchUserList", taskFlowRouter.SearchUserList) //自定义表单搜索人员 } } diff --git a/models/modelAppPlatform/customer_form_view.go b/models/modelAppPlatform/customer_form_view.go index 7a7d814..cf8617f 100644 --- a/models/modelAppPlatform/customer_form_view.go +++ b/models/modelAppPlatform/customer_form_view.go @@ -23,6 +23,9 @@ type CustomerFormView struct { Classify int `json:"classify" gorm:"column:classify;type:int(1) unsigned;default:1;not null;comment:分类1:表单;2:流程表单"` Permit string `json:"permit" gorm:"column:permit;type:mediumtext;default:'';comment:授权范围"` PermitStr string `json:"permitstr" gorm:"column:permitstr;type:mediumtext;default:'';comment:授权范围"` + Flowkey int64 `json:"flowkey" gorm:"column:flowkey;type:bigint(20) unsigned;default:0;not null;comment:关联工作流"` + UserPermit string `json:"userpermit" gorm:"column:userpermit;type:mediumtext;default:'';comment:可见人员"` + PostPermit string `json:"postpermit" gorm:"column:postpermit;type:mediumtext;default:'';comment:可见角色"` } func (CustomerFormView *CustomerFormView) TableName() string {