diff --git a/api/shiyan/maptostruct/shiyan.go b/api/shiyan/maptostruct/shiyan.go index 9ade7c8..878017d 100644 --- a/api/shiyan/maptostruct/shiyan.go +++ b/api/shiyan/maptostruct/shiyan.go @@ -2,7 +2,9 @@ package maptostruct import ( "appPlatform/api/version1/customerform" + "appPlatform/api/version1/taskplatform/taskflow" "appPlatform/models/modelAppPlatform" + "appPlatform/models/modelshr" "appPlatform/models/modelsschool" "appPlatform/overall" "appPlatform/overall/publicmethod" @@ -487,3 +489,57 @@ func (a *ApiMethod) GenJuIdNumber(c *gin.Context) { sendData["myAge"] = myAge publicmethod.Result(0, sendData, c) } + +/* +* +@ 作者: 秦东 +@ 时间: 2023-11-15 15:26:47 +@ 功能: 实验流程图生成 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (a *ApiMethod) CreateFlowChart(c *gin.Context) { + var requestData CreatFlowView + err := c.ShouldBindJSON(&requestData) + if err != nil { + publicmethod.Result(10001, err, c) + return + } + if requestData.Id == "" { + publicmethod.Result(10001, err, c, "未知表单") + return + } + var flowInfo modelAppPlatform.FlowVersion + err = flowInfo.GetCont(map[string]interface{}{"`id`": requestData.Id}) + if err != nil && flowInfo.Content == "" { + publicmethod.Result(106, err, c) + return + } + var flowVersionCont taskflow.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.GenerateFlow(userCont, 349) + workFlowInfo := flowVersionCont.NodeConfig.CircularParsing(1, userCont, 349, requestData.ConditionList) + sendData := publicmethod.MapOut[string]() + // sendData["context"] = context + // sendData["userCont"] = userCont + // sendData["flowInfo"] = flowInfo + // sendData["flowVersionCont"] = flowVersionCont + sendData["workFlowInfo"] = workFlowInfo + publicmethod.Result(0, sendData, c) +} diff --git a/api/shiyan/maptostruct/type.go b/api/shiyan/maptostruct/type.go index 956adc3..a40c935 100644 --- a/api/shiyan/maptostruct/type.go +++ b/api/shiyan/maptostruct/type.go @@ -1,6 +1,7 @@ package maptostruct import ( + "appPlatform/api/version1/taskplatform/taskflow" "appPlatform/models/modelsstorage" "appPlatform/overall/publicmethod" "sync" @@ -112,3 +113,9 @@ type JiaMi struct { UserToken string `json:"usertoken"` Time int64 `json:"time"` } + +// 生成表单参数 +type CreatFlowView struct { + publicmethod.PublicId + ConditionList []taskflow.ConditionListInfo `json:"conditionList"` //判断条件主体 +} diff --git a/api/version1/customerform/form.go b/api/version1/customerform/form.go index 4dcdea1..02b26bf 100644 --- a/api/version1/customerform/form.go +++ b/api/version1/customerform/form.go @@ -238,7 +238,10 @@ func (a *ApiMethod) SaveCustomerForm(c *gin.Context) { if errMain != nil || errVer != nil { createDb.Rollback() - publicmethod.Result(104, customerFormCont, c) + sendErr := publicmethod.MapOut[string]() + sendErr["errMain"] = errMain + sendErr["errVer"] = errVer + publicmethod.Result(104, sendErr, c) return } err = createDb.Commit().Error diff --git a/api/version1/taskplatform/taskflow/flowType.go b/api/version1/taskplatform/taskflow/flowType.go index 03c1b84..2f6c2f3 100644 --- a/api/version1/taskplatform/taskflow/flowType.go +++ b/api/version1/taskplatform/taskflow/flowType.go @@ -166,3 +166,14 @@ type EnclosureFormat struct { FilePath string `json:"filepath"` //附件地址 Type int `json:"type"` //附件类型 } + +//主管层级 +type ContinuousMultiLevelSupervisor struct { + MaxLevel int //最大级别 + Continuity bool //是否连续主管 + UserList []MultiLeveUserList //每级人员列表 +} +type MultiLeveUserList struct { + Level int //第几级 + UserList []OperatorList //操作人 +} diff --git a/api/version1/taskplatform/taskflow/runflow.go b/api/version1/taskplatform/taskflow/runflow.go index 05390a2..fc94e95 100644 --- a/api/version1/taskplatform/taskflow/runflow.go +++ b/api/version1/taskplatform/taskflow/runflow.go @@ -1,10 +1,15 @@ package taskflow import ( + "appPlatform/models/modelAppPlatform" "appPlatform/models/modelshr" "appPlatform/overall" "appPlatform/overall/publicmethod" + "fmt" + "sort" "strconv" + "strings" + "time" ) /* @@ -14,7 +19,8 @@ import ( @ 功能: 生成步进工作流 @ 参数 - # + #creater 发起人信息 + #orgId 执行行政组织 @ 返回值 @@ -24,9 +30,10 @@ import ( # */ -func (f *NodePublicInfo) GenerateFlow(creater publicmethod.AuthenticationPower) { - //寻找发起节点 - +func (f *FlowMainBody) GenerateFlow(creater modelshr.ManCont, orgId int64, condition []ConditionListInfo) (workFlowInfo []RunFlow) { + //生成工作流 + workFlowInfo = f.NodeConfig.CircularParsing(1, creater, orgId, condition) + return } /* @@ -37,6 +44,9 @@ func (f *NodePublicInfo) GenerateFlow(creater publicmethod.AuthenticationPower) @ 参数 #step 步进值 + #creater 当前操作人 + #orgId 执行行政组织 + #condition 判定条件值 @ 返回值 @@ -46,7 +56,8 @@ func (f *NodePublicInfo) GenerateFlow(creater publicmethod.AuthenticationPower) # */ -func (n *NodePublicInfo) CircularParsing(step int) (nodeList []RunFlow) { +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) var nodeInfo RunFlow nodeInfo.Step = step nodeInfo.Types = n.Types @@ -70,34 +81,676 @@ func (n *NodePublicInfo) CircularParsing(step int) (nodeList []RunFlow) { case 1: //指定成员 nodeInfo.Operator = OperatorHandle(n.NodeUserList) case 2: //主管 - + var levelUserList ContinuousMultiLevelSupervisor + levelUserList.MaxLevel = n.DirectorLevel + levelUserList.Continuity = false + if n.Attribute == 1 { + //申请人 + nodeInfo.Operator = levelUserList.ObtainRelevantLevelLeaders(creater.AdminOrg) + } else { + //执行部门 + nodeInfo.Operator = levelUserList.ObtainRelevantLevelLeaders(orgId) + } case 3: //行政岗位 + if n.Attribute == 1 { + nodeInfo.Operator = GainOrgPostUserList(creater.AdminOrg, n.NodeUserList) + } else { + nodeInfo.Operator = GainOrgPostUserList(orgId, n.NodeUserList) + } case 4: //发起人自选 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`") + nodeInfo.Operator = append(nodeInfo.Operator, TransformPublicUs(myCont)) case 6: //连续多级主管 + var levelUserList ContinuousMultiLevelSupervisor + levelUserList.MaxLevel = n.ExamineEndDirectorLevel + levelUserList.Continuity = true + if n.Attribute == 1 { + //申请人 + nodeInfo.Operator = levelUserList.ObtainRelevantLevelLeaders(creater.AdminOrg) + } else { + //执行部门 + nodeInfo.Operator = levelUserList.ObtainRelevantLevelLeaders(orgId) + } case 7: //指定前置审批为本节点设置审批人 case 8: //表单字段 case 9: //权限矩阵 + if n.Attribute == 1 { + nodeInfo.Operator = GainMatrixUserList(creater.AdminOrg, n.Matrix) + } else { + nodeInfo.Operator = GainMatrixUserList(orgId, n.Matrix) + } default: } - nodeList = append(nodeList, nodeInfo) if n.ChildNode != nil { - nodeList = append(nodeList, n.ChildNode.CircularParsing(step+1)...) + nodeList = append(nodeList, n.ChildNode.CircularParsing(step+1, creater, orgId, condition)...) } case 2: nodeInfo.Operator = OperatorHandle(n.NodeUserList) nodeList = append(nodeList, nodeInfo) if n.ChildNode != nil { - nodeList = append(nodeList, n.ChildNode.CircularParsing(step+1)...) + nodeList = append(nodeList, n.ChildNode.CircularParsing(step+1, creater, orgId, condition)...) } case 4: case 5: + if len(n.ConditionNodes) > 0 { + //根据维度序号排序 + sort.Slice(n.ConditionNodes, func(i, j int) bool { + return n.ConditionNodes[i].PriorityLevel < n.ConditionNodes[j].PriorityLevel + }) + lastStrp := step + for _, pv := range n.ConditionNodes { //循环解析相关条件 + routerNodes := pv.ResolveRouting(step, creater, orgId, condition) + if len(routerNodes) > 0 { + lastStrp = lastStrp + len(routerNodes) + nodeList = append(nodeList, routerNodes...) + break + } + } + if n.ChildNode != nil { + nodeList = append(nodeList, n.ChildNode.CircularParsing(lastStrp, creater, orgId, condition)...) + } + } else { + if n.ChildNode != nil { + nodeList = append(nodeList, n.ChildNode.CircularParsing(step+1, creater, orgId, condition)...) + } + } default: + //发起人 + var originator OperatorList + originator.Id = strconv.FormatInt(creater.Key, 10) //操作人ID + originator.Types = 1 //1:人员;2:角色;3:行政组织 + originator.Name = creater.Name //操作人姓名 + originator.Number = creater.Number //操作人工号 + originator.Icon = creater.Icon //操作人头像 + originator.IconBase64 = creater.IconPhpto //操作人头像 + originator.Wechat = creater.Wechat //微信Openid + if creater.WorkWechat != "" { + originator.Wechat = creater.WorkWechat //企业微信Openid + } + + _, companyId, _, _, _ := publicmethod.GetOrgStructurees(creater.AdminOrg) + originator.DepartmentId = companyId //分厂Id + if companyId != 0 { + var orgCont modelshr.AdministrativeOrganization + orgCont.GetCont(map[string]interface{}{"`id`": companyId}, "`name`") + originator.DepartmentName = orgCont.Name //分厂名称 + } + //获取岗位 + if creater.Position != 0 { + var postCont modelshr.Position + postCont.GetCont(map[string]interface{}{"`id`": creater.Position}, "`name`") + originator.PostId = creater.Position //职务Id + originator.PostName = postCont.Name //职务名称 + } + if creater.TeamId != 0 { + var teamCont modelshr.TeamGroup + teamCont.GetCont(map[string]interface{}{"`id`": creater.TeamId}, "`name`") + originator.Tema = creater.TeamId //班组Id + originator.TemaName = teamCont.Name //班组名称 + } + var logCont LogList + logCont.State = 1 //状态 1、未操作;2、通过;3、驳回 + logCont.TimeVal = publicmethod.UnixTimeToDay(time.Now().Unix(), 24) + // 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)...) + } + } + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2023-11-16 09:44:25 +@ 功能: 解析条件 +@ 参数 + + #step 步进值 + #creater 当前操作人 + #orgId 执行行政组织 + #condition 判定条件值 + +@ 返回值 + + #nodeList 操作节点 + +@ 方法原型 + + # +*/ +func (n *NodePublicInfoES) ResolveRouting(step int, creater modelshr.ManCont, orgId int64, condition []ConditionListInfo) (nodeList []RunFlow) { + // fmt.Printf("解析条件---》%v\n", n.NodeName) + if len(n.ConditionList) > 0 { + // fmt.Printf("解析条件--1-》%v\n", n.ConditionList) + termAry := 0 + for _, v := range n.ConditionList { + //条件类型:1:人员、行政组织、角色;2:自定义字段;3:关联表单字段; + switch v.Types { + case 1: + if JudgingTermPeoOrgRoles(v.NodeUserList, creater) { //判断申请人是否在可允许范围之内 + // termAry = append(termAry, 1) + termAry++ + } + case 2: + if JudgingCustomConditions(v.CustomFields, condition) { + termAry++ + } + case 3: + if ProcessMultipleSelectionResults(v, condition) { //判断表单 + // termAry = append(termAry, 3) + termAry++ + } + default: + } + } + // 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)...) + } + } + } else { + if n.ChildNode != nil { + nodeList = append(nodeList, n.ChildNode.CircularParsing(step, creater, orgId, condition)...) + } + } + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2023-11-17 09:20:37 +@ 功能: 处理自定义条件 +@ 参数 + + #CustomFields 条件集合 + #presetVal 提交项目 + +@ 返回值 + + #isTrue true:条件符合,验证通过;false:不通过 + +@ 方法原型 + + # +*/ +func JudgingCustomConditions(customFields []CustomFieldsInfo, presetVal []ConditionListInfo) (isTrue bool) { + isTrue = false + if len(presetVal) < 1 { + return + } + var subCustomFields []CustomFieldsInfo + for _, v := range presetVal { + if v.Types == 2 && len(v.CustomFields) > 0 { + subCustomFields = append(subCustomFields, v.CustomFields...) + } + } + if len(subCustomFields) < 1 { + return + } + isOk := 0 + for _, s := range subCustomFields { //提交的条件结果 + for _, c := range customFields { //预设定条件 + if s.Wordfield == c.Wordfield { + + switch c.OptType { + case "1": //小于 + sLeftVal, sErr := strconv.ParseFloat(s.LeftVal, 64) + if sErr == nil { + cLeftVal, cErr := strconv.ParseFloat(c.LeftVal, 64) + if cErr == nil { + if sLeftVal < cLeftVal { + isOk++ + } + } + } + case "2": //大于 + sLeftVal, sErr := strconv.ParseFloat(s.LeftVal, 64) + if sErr == nil { + cLeftVal, cErr := strconv.ParseFloat(c.LeftVal, 64) + if cErr == nil { + if sLeftVal > cLeftVal { + isOk++ + } + } + } + case "3": //小于等于 + sLeftVal, sErr := strconv.ParseFloat(s.LeftVal, 64) + if sErr == nil { + cLeftVal, cErr := strconv.ParseFloat(c.LeftVal, 64) + if cErr == nil { + if sLeftVal <= cLeftVal { + isOk++ + } + } + } + case "4": //等于 + sLeftVal, sErr := strconv.ParseFloat(s.LeftVal, 64) + if sErr == nil { + cLeftVal, cErr := strconv.ParseFloat(c.LeftVal, 64) + if cErr == nil { + if sLeftVal == cLeftVal { + isOk++ + } + } + } + case "5": //大于等于 + sLeftVal, sErr := strconv.ParseFloat(s.LeftVal, 64) + if sErr == nil { + cLeftVal, cErr := strconv.ParseFloat(c.LeftVal, 64) + if cErr == nil { + if sLeftVal >= cLeftVal { + isOk++ + } + } + } + case "6": //介于两个数之间 + leftIsOk := false + rightIsOk := false + sLeftVal, sLErr := strconv.ParseFloat(s.LeftVal, 64) + sRightVal, sRErr := strconv.ParseFloat(s.RightVal, 64) + if sLErr == nil && sRErr == nil { + cLeftVal, cLErr := strconv.ParseFloat(c.LeftVal, 64) + cRightVal, cRErr := strconv.ParseFloat(c.RightVal, 64) + if cLErr == nil && cRErr == nil { + + if c.LeftOptType == "1" { + if sLeftVal > cLeftVal { + leftIsOk = true + } + } else { + if sLeftVal >= cLeftVal { + leftIsOk = true + } + } + if c.RightOptType == "1" { + if sRightVal < cRightVal { + rightIsOk = true + } + } else { + if sRightVal <= cRightVal { + rightIsOk = true + } + } + } + } + if leftIsOk && rightIsOk { + isOk++ + } + case "7": //包含 + setUpValAry := strings.Split(c.LeftVal, ",") + // fmt.Printf("处理自定义条件-abc->%v-->%v-->%v-->%v\n", s.Wordfield, c.Wordfield, setUpValAry, publicmethod.IsInTrue[string](s.LeftVal, setUpValAry)) + if publicmethod.IsInTrue[string](s.LeftVal, setUpValAry) { + isOk++ + } + case "8": //不包含 + setUpValAry := strings.Split(c.LeftVal, ",") + if !publicmethod.IsInTrue[string](s.LeftVal, setUpValAry) { + isOk++ + } + default: + } + } + } + } + // fmt.Printf("处理自定义条件-->%v-->%v\n", isOk, len(customFields)) + if isOk == len(customFields) { + isTrue = true + } + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2023-11-17 08:48:24 +@ 功能: 处理选择条件 +@ 参数 + + #judging 选择条件 + #presetVal 提交的判断提交 + +@ 返回值 + + #isTrue true:条件符合,验证通过;false:不通过 + +@ 方法原型 + + # +*/ +func ProcessMultipleSelectionResults(judging ConditionListInfo, presetVal []ConditionListInfo) (isTrue bool) { + isTrue = false + if len(presetVal) < 1 { + return + } + for _, v := range presetVal { + + if v.Types == 3 && judging.Factorid == v.Factorid { + if judging.IsCheckbox { + //多选 + if len(v.Answers) <= len(judging.Answers) { //判断答案个数是否小于等于设定条件值个数 + isTrue = true + for i := 0; i < len(v.Answers); i++ { + if !publicmethod.IsInTrue[string](v.Answers[i], judging.Answers) { + isTrue = false + } + } + } + } else { //单选 + if len(v.Answers) == len(judging.Answers) { + isTrue = true + for i := 0; i < len(v.Answers); i++ { + if !publicmethod.IsInTrue[string](v.Answers[i], judging.Answers) { + isTrue = false + } + } + } + } + } + } + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2023-11-17 08:12:29 +@ 功能: 转变人员信息 +@ 参数 + + #condition 判断条件中的人员信息 + +@ 返回值 + + #usAry 转变后的人员列表 + +@ 方法原型 + + # +*/ +func CondToNodeUser(condition []FlowPermissionInfo) (usAry []NodeUserListInfo) { + if len(condition) < 1 { + return + } + for _, v := range condition { + var usCont NodeUserListInfo + usCont.Types = v.Types // 1:人员;2:角色;3:行政组织;4:职务 + usCont.TargetId = v.TargetId // /相关内容识别符 + usCont.Name = v.Name //相关内容名称 + usCont.Icon = v.Icon //头像 + usCont.IconToBase64 = v.IconToBase64 //头像Base64 + usAry = append(usAry, usCont) + } + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2023-11-17 08:04:57 +@ 功能: 判断路由条件(人员、行政组织、角色)是否满足 +@ 参数 + + #term 预设可操作此节点的人 + #creater 流程发起人 + +@ 返回值 + + #isTrue true:条件符合,验证通过;false:不通过 + +@ 方法原型 + + # +*/ +func JudgingTermPeoOrgRoles(term []FlowPermissionInfo, creater modelshr.ManCont) (isTrue bool) { + isTrue = false + usList := CondToNodeUser(term) + operatorList := OperatorHandle(usList) //获取所有可操作的人 + var usKey []string + for i := 0; i < len(operatorList); i++ { //提取可操作人的唯一识别符 + if !publicmethod.IsInTrue[string](operatorList[i].Id, usKey) { + usKey = append(usKey, operatorList[i].Id) + } + } + creKey := strconv.FormatInt(creater.Key, 10) + if publicmethod.IsInTrue[string](creKey, usKey) { //判断当前操作人是否在可执行人当中 + isTrue = true + } + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2023-11-15 14:57:03 +@ 功能: 矩阵拆分 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func GainMatrixUserList(orgId int64, matrix MatrixInfo) (UserList []OperatorList) { + allOrgId := publicmethod.HaveAllOrgRelation(orgId) //获取全部归属行政单位 + 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 { + return + } + var userKeys []int64 + err = overall.CONSTANT_DB_AppPlatform.Model(&modelAppPlatform.MatrixHandler{}).Select("`hand_id`").Where("`types` = 2 AND `mc_id` = ? AND `mh_id` = ? AND `number` = ?", matrix.MatrixId, matrix.OutcomeId, keyVal).Find(&userKeys).Error + 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) + if len(userInfoAry) > 0 { + for _, uv := range userInfoAry { + UserList = append(UserList, TransformPublicUs(uv)) + } + } + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2023-11-15 13:24:29 +@ 功能: 岗位操作人解析 +@ 参数 + + #orgId 行政组织 + #approvers 审批人岗位 + +@ 返回值 + + #UserList 操作人 + +@ 方法原型 + + # +*/ +func GainOrgPostUserList(orgId int64, approvers []NodeUserListInfo) (UserList []OperatorList) { + if len(approvers) > 0 { + allOrgId := publicmethod.HaveAllOrgRelation(orgId) //获取全部归属行政单位 + var userAry MultiLeveUserList + for _, v := range approvers { //逐行分析职务 + if v.Types == 4 { + syncSeting.Add(1) + go userAry.GainOrgPostPeople(allOrgId, v.Options) + } + } + syncSeting.Wait() + UserList = userAry.UserList } return } +/* +* +@ 作者: 秦东 +@ 时间: 2023-11-15 14:30:08 +@ 功能: 获取职务相关人员 +@ 参数 + + #orgId 行政组织 + #options 操作职务 + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (m *MultiLeveUserList) GainOrgPostPeople(orgId []int64, options []OptionsInfo) { + if len(options) > 0 { //判断职务编号 + var postId []int + for i := 0; i < len(options); i++ { + piVal, _ := strconv.Atoi(options[i].Value) + if !publicmethod.IsInTrue[int](piVal, postId) { + postId = append(postId, piVal) + } + } + 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) + if len(userInfoAry) > 0 { + for _, uv := range userInfoAry { + m.UserList = append(m.UserList, TransformPublicUs(uv)) + } + } + } + } + defer syncSeting.Done() +} + +/* +* +@ 作者: 秦东 +@ 时间: 2023-11-15 11:05:55 +@ 功能: 获取单级或多级主管审批人 +@ 参数 + + #orgId 行政组织 + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (c *ContinuousMultiLevelSupervisor) ObtainRelevantLevelLeaders(orgId int64) (UserList []OperatorList) { + if c.MaxLevel == 0 { + c.MaxLevel = 1 + } + c.ObtainRelevantLevelLeadersUser(1, orgId) + if len(c.UserList) > 0 { + if c.Continuity { //连续层级主管 + sort.Slice(c.UserList, func(i, j int) bool { + return c.UserList[i].Level < c.UserList[j].Level + }) + for _, v := range c.UserList { + UserList = append(UserList, v.UserList...) + } + } else { //单一层级 + for i := c.MaxLevel; i > 0; i-- { + UserList = GainOneLevel(i, c.UserList) + if len(UserList) > 0 { + return + } + } + } + } + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2023-11-15 11:50:01 +@ 功能: +@ 参数 + + #level 层级 + #UserList 操作人信息 + +@ 返回值 + + #UserAry 操作人列表 + +@ 方法原型 + + # +*/ +func GainOneLevel(level int, UserList []MultiLeveUserList) (UserAry []OperatorList) { + for _, v := range UserList { + if v.Level == level { + UserAry = v.UserList + return + } + } + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2023-11-15 11:49:24 +@ 功能: 循环获取主管层级负责人 +@ 参数 + + #level 当前主管层级 + #orgId 目标行政组织 + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (c *ContinuousMultiLevelSupervisor) ObtainRelevantLevelLeadersUser(level int, orgId int64) { + 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 + + if err == nil { + var userAry MultiLeveUserList + userAry.Level = level + for _, v := range userList { + userAry.UserList = append(userAry.UserList, TransformPublicUs(v)) + } + c.UserList = append(c.UserList, userAry) + } + nextLevel := level + 1 + if nextLevel <= c.MaxLevel { + c.ObtainRelevantLevelLeadersUser(nextLevel, orgInfo.Superior) + } + } +} + /* * @ 作者: 秦东 @@ -127,7 +780,7 @@ func OperatorHandle(userList []NodeUserListInfo) (userAry []OperatorList) { } case 2: //角色 var usIdList []int64 - overall.CONSTANT_DB_HR.Model(&modelshr.PersonArchives{}).Select("`key`").Where("FIND_IN_SET(?,`role`)", v.TargetId).Find(&usIdList) + overall.CONSTANT_DB_HR.Model(&modelshr.PersonArchives{}).Select("`key`").Where("FIND_IN_SET(?,`role`) AND `emp_type` BETWEEN ? AND ?", v.TargetId, 1, 10).Find(&usIdList) if len(usIdList) > 0 { userIdAry = append(userIdAry, usIdList...) } @@ -138,7 +791,7 @@ func OperatorHandle(userList []NodeUserListInfo) (userAry []OperatorList) { sunOrg.GetOrgSonAllId(myKey) sunOrg.Id = append(sunOrg.Id, myKey) var usIdList []int64 - overall.CONSTANT_DB_HR.Model(&modelshr.PersonArchives{}).Select("`key`").Where("`admin_org` IN ?", sunOrg.Id).Find(&usIdList) + overall.CONSTANT_DB_HR.Model(&modelshr.PersonArchives{}).Select("`key`").Where("`admin_org` IN ? AND `emp_type` BETWEEN ? AND ?", sunOrg.Id, 1, 10).Find(&usIdList) if len(usIdList) > 0 { userIdAry = append(userIdAry, usIdList...) } @@ -148,40 +801,61 @@ func OperatorHandle(userList []NodeUserListInfo) (userAry []OperatorList) { } } var userContMap []modelshr.PersonArchives - overall.CONSTANT_DB_HR.Model(&modelshr.PersonArchives{}).Where("`key` IN ?", userIdAry).Find(&userContMap) + 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) for _, v := range userContMap { - var userCont OperatorList - 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 - if v.WorkWechat != "" { - userCont.Wechat = v.WorkWechat //微信Openid - } - _, companyId, _, _, _ := publicmethod.GetOrgStructurees(v.AdminOrg) - userCont.DepartmentId = companyId //分厂Id - if companyId != 0 { - var orgCont modelshr.AdministrativeOrganization - orgCont.GetCont(map[string]interface{}{"`id`": companyId}, "`name`") - userCont.DepartmentName = orgCont.Name //分厂名称 - } - //获取岗位 - if v.Position != 0 { - var postCont modelshr.Position - postCont.GetCont(map[string]interface{}{"`id`": v.Position}, "`name`") - userCont.PostId = v.Position //职务Id - userCont.PostName = postCont.Name //职务名称 - } - if v.TeamId != 0 { - var teamCont modelshr.TeamGroup - teamCont.GetCont(map[string]interface{}{"`id`": v.TeamId}, "`name`") - userCont.Tema = v.TeamId //班组Id - userCont.TemaName = teamCont.Name //班组名称 - } - userAry = append(userAry, userCont) + userAry = append(userAry, TransformPublicUs(v)) } } return } + +/* +* +@ 作者: 秦东 +@ 时间: 2023-11-15 11:37:00 +@ 功能: 装通用执行人数据 +@ 参数 + + #v 人员信息 + +@ 返回值 + + #userCont 统一操作人信息 + +@ 方法原型 + + # +*/ +func TransformPublicUs(v modelshr.PersonArchives) (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 + if v.WorkWechat != "" { + userCont.Wechat = v.WorkWechat //微信Openid + } + _, companyId, _, _, _ := publicmethod.GetOrgStructurees(v.AdminOrg) + userCont.DepartmentId = companyId //分厂Id + if companyId != 0 { + var orgCont modelshr.AdministrativeOrganization + orgCont.GetCont(map[string]interface{}{"`id`": companyId}, "`name`") + userCont.DepartmentName = orgCont.Name //分厂名称 + } + //获取岗位 + if v.Position != 0 { + var postCont modelshr.Position + postCont.GetCont(map[string]interface{}{"`id`": v.Position}, "`name`") + userCont.PostId = v.Position //职务Id + userCont.PostName = postCont.Name //职务名称 + } + if v.TeamId != 0 { + var teamCont modelshr.TeamGroup + teamCont.GetCont(map[string]interface{}{"`id`": v.TeamId}, "`name`") + userCont.Tema = v.TeamId //班组Id + userCont.TemaName = teamCont.Name //班组名称 + } + return +} diff --git a/apirouter/apishiyan/maptostruct.go b/apirouter/apishiyan/maptostruct.go index c67cc02..72cef24 100644 --- a/apirouter/apishiyan/maptostruct.go +++ b/apirouter/apishiyan/maptostruct.go @@ -33,5 +33,36 @@ func (a *ApiRouter) RouterGroup(router *gin.RouterGroup) { apiRouter.GET("jia_mi", methodBinding.JiaMiShiYan) //加密实验 apiRouter.POST("genJuIdNumber", methodBinding.GenJuIdNumber) //根据身份证号获取生日和年龄 + + apiRouter.POST("createFlowChart", methodBinding.CreateFlowChart) //实验流程图生成 + } +} +func (a *ApiRouter) RouterGroupVerify(router *gin.RouterGroup) { + apiRouter := router.Group("v_shiyan") + + var methodBinding = shiyan.AppApiEntry.MapToStructApi + { + apiRouter.GET("", methodBinding.Index) //入口 + apiRouter.POST("", methodBinding.Index) //入口 + + apiRouter.POST("charparking", methodBinding.CharParking) //获取车场车位信息 + apiRouter.POST("testpage", methodBinding.TestPage) //获取车场车位信息 + + apiRouter.POST("canshu", methodBinding.Canshu) //获取车场车位信息 + + apiRouter.POST("create_table", methodBinding.CreateTable) //模拟创建表单 + + apiRouter.POST("qianyi_version", methodBinding.QianyiVersion) //改革自定义表单列表 + apiRouter.POST("LookTableStruct", methodBinding.LookTableStruct) //查询表结构 + + apiRouter.POST("hzzpy", methodBinding.HanZiZhuanPinYin) //汉字转拼音 + + apiRouter.POST("test_table", methodBinding.TestTable) //测试表格字段类型 + + apiRouter.GET("jia_mi", methodBinding.JiaMiShiYan) //加密实验 + + apiRouter.POST("genJuIdNumber", methodBinding.GenJuIdNumber) //根据身份证号获取生日和年龄 + + apiRouter.POST("createFlowCharts", methodBinding.CreateFlowChart) //实验流程图生成 } } diff --git a/initialization/route/initRoute.go b/initialization/route/initRoute.go index 828c07f..ef87225 100644 --- a/initialization/route/initRoute.go +++ b/initialization/route/initRoute.go @@ -73,6 +73,10 @@ func InitialRouter() *gin.Engine { //注册Redis数据管理接口 redisClassApiRouter := apirouter.RouterGroupEntry.RedisClassApiRouter redisClassApiRouter.RouterGroup(VerifyIdentity) + //带身份实验 + shiyanApiVerify := apirouter.RouterGroupEntry.ShiyanApi + shiyanApiVerify.RouterGroupVerify(VerifyIdentity) + } //验证身份接口 无需鉴权Url(主要web端使用) VerifyIdentityWeb := router.Group("") diff --git a/overall/publicmethod/technique.go b/overall/publicmethod/technique.go index 7abe52f..bdbf8b4 100644 --- a/overall/publicmethod/technique.go +++ b/overall/publicmethod/technique.go @@ -1965,14 +1965,30 @@ func HaveAllOrgRelation(orgId int64) []int64 { // departmentId := RecursionOrgLeve(orgId, 4) // fmt.Printf("获取行政组--->%v--->%v\n", departmentId, orgId) var getAllOrg GetOrgAllParent - // getAllOrg.GetOrgParentAllId(departmentId) - // getAllOrg.GetOrgSonAllId(departmentId) - getAllOrg.Id = append(getAllOrg.Id, orgId) - getAllOrg.GetOrgParent(orgId, 4) + getAllOrg.GetOrgAllFatherId(orgId, 4) + getAllOrg.GetOrgSonAllId(orgId) + // getAllOrg.Id = append(getAllOrg.Id, orgId) + // getAllOrg.GetOrgParent(orgId, 4) // fmt.Printf("获取行政组--2222->%v--->%v\n", getAllOrg.Id, orgId) return getAllOrg.Id } +// 获取指定等级行政组织所有上级 +func (g *GetOrgAllParent) GetOrgAllFatherId(orgId, level int64) { + var orgCont modelshr.OrgContType + err := orgCont.GetCont(map[string]interface{}{"`id`": orgId, "`state`": 1}, "`superior`", "level") + if err == nil { + if !IsInTrue[int64](orgId, g.Id) { + g.Id = append(g.Id, orgId) + } + if orgCont.Level >= level { + g.GetOrgAllFatherId(orgCont.Superior, level) + } + } else { + return + } +} + // 获取上下级 func (g *GetOrgAllParent) GetOrgParent(orgId, level int64) { if orgId != 0 {