From 0cf839bd0cb73db1fc5aa3146906a67d688d33ca Mon Sep 17 00:00:00 2001 From: herenshan112 Date: Sat, 17 Sep 2022 10:34:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=88=E6=9D=83=E8=8F=9C=E5=8D=95=E8=8E=B7?= =?UTF-8?q?=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/base/loginVerify/login.go | 8 +- api/version1/empower/system_license.go | 3 +- .../jurisdiction/jurisdictionpc/power.go | 67 +++++++++- .../jurisdiction/jurisdictionpc/type.go | 16 ++- api/version1/postseting/postpc/scheme.go | 13 +- api/version1/postseting/postweb/posttarget.go | 75 +++++++++-- api/version1/postseting/postweb/type.go | 11 ++ apirouter/v1/postseting/web.go | 17 +-- apirouter/v1/systempower/pc.go | 3 + models/modelsschool/system_menu.go | 24 ++-- overall/publicmethod/formatOutput.go | 29 +++++ overall/publicmethod/technique.go | 118 +++++++++++++++--- overall/publicmethod/type.go | 15 +++ 13 files changed, 339 insertions(+), 60 deletions(-) diff --git a/api/base/loginVerify/login.go b/api/base/loginVerify/login.go index 943f7f1..0fc6d85 100644 --- a/api/base/loginVerify/login.go +++ b/api/base/loginVerify/login.go @@ -7,6 +7,7 @@ import ( "key_performance_indicators/models/modelsschool" "key_performance_indicators/overall" "key_performance_indicators/overall/publicmethod" + "strconv" "github.com/gin-gonic/gin" ) @@ -65,15 +66,18 @@ func (a *ApiMethod) ScanCodeLogin(c *gin.Context) { return } + uuIdVal := publicmethod.GetUUid(3) + uuIdValStr := strconv.FormatInt(uuIdVal, 10) + var md5JiaMi publicmethod.Md5Encryption md5JiaMi.Md5EncryptionInit(userAgent) md5Token := md5JiaMi.Md5EncryptionAlgorithm() var md5JiaMiNumber publicmethod.Md5Encryption - md5JiaMiNumber.Md5EncryptionInit(userCont.Number) + md5JiaMiNumber.Md5EncryptionInit(userCont.Number + uuIdValStr) userKeyCode := md5JiaMiNumber.Md5EncryptionAlgorithm() - sha1Str := userKeyCode + userCont.Number + userCont.Password + md5Token + sha1Str := userKeyCode + userCont.Number + userCont.Password + md5Token + uuIdValStr sha1Token := publicmethod.Sha1Encryption(sha1Str) //返回值 diff --git a/api/version1/empower/system_license.go b/api/version1/empower/system_license.go index defc4ca..9eee5b8 100644 --- a/api/version1/empower/system_license.go +++ b/api/version1/empower/system_license.go @@ -24,7 +24,8 @@ func (a *ApiMethod) ObtainAuthorization(c *gin.Context) { publicmethod.Result(1, err, c, "未知身份!不可授权!") return } - + // jsonStr, _ := json.Marshal(context) + // fmt.Printf("jsonStr------>%v\n", string(jsonStr)) menuIdAry, menuUrl, err := publicmethod.GetPostPower(context.AdminOrg, context.Position, receivedValue.System) // var systemPermission modelssystempermission.Empower diff --git a/api/version1/jurisdiction/jurisdictionpc/power.go b/api/version1/jurisdiction/jurisdictionpc/power.go index a41d664..7fabdcc 100644 --- a/api/version1/jurisdiction/jurisdictionpc/power.go +++ b/api/version1/jurisdiction/jurisdictionpc/power.go @@ -1,7 +1,10 @@ package jurisdictionpc import ( + "encoding/json" + "fmt" "key_performance_indicators/models/modelsschool" + "key_performance_indicators/models/modelsstorage" "key_performance_indicators/models/modelssystempermission" "key_performance_indicators/overall" "key_performance_indicators/overall/publicmethod" @@ -104,7 +107,7 @@ func (a *ApiMethod) SystemAboutMenu(c *gin.Context) { return } var systemPower modelssystempermission.Appsystem - err = systemPower.GetCont(map[string]interface{}{"`system`": receivedValue.Name}) + err = systemPower.GetCont(map[string]interface{}{"`coder`": receivedValue.Name}) if err != nil { publicmethod.Result(105, err, c) return @@ -117,26 +120,78 @@ func (a *ApiMethod) SystemAboutMenu(c *gin.Context) { publicmethod.Result(1, err, c, "该系统授权已经取消合作!") return } - var menuThree []powerThree + var menuThree []publicmethod.PowerThree + // fmt.Printf("ApiUrl------>%v\n", systemPower) if systemPower.ApiUrl != "" { //api入口不为空的情况下采用get访问方式接收数据 + htmlByte := publicmethod.CurlGet(systemPower.ApiUrl) + fmt.Printf("%v\n", string(htmlByte)) + var jsonAry callBackUrlMenu + jsonErr := json.Unmarshal(htmlByte, &jsonAry) + if jsonErr != nil { + publicmethod.Result(1, jsonErr, c, "数据获取错误!") + return + } + if jsonAry.Code != 0 { + publicmethod.Result(1, jsonErr, c, jsonAry.Msg) + return + } + menuThree = jsonAry.Data } else { //api入口为空,采用系统内置获取授权菜单 switch systemPower.Coder { + case "cangchu": + menuThree = wmsMenuThree() + // fmt.Printf("ApiUrl----2-->%v\n", systemPower.ApiUrl) default: //获取绩效考核菜单树 menuThree = kpiMenuThree() + // fmt.Printf("ApiUrl---1--->%v\n", systemPower.ApiUrl) } } publicmethod.Result(0, menuThree, c) } // kpi菜单树 -func kpiMenuThree() (menuThree []powerThree) { - var menuList []modelsschool.SystemMenu - err := overall.CONSTANT_DB_Master.Where("`m_steat` = 1").Find(&menuList).Error - if err != nil { +func kpiMenuThree() (menuThree []publicmethod.PowerThree) { + + var menuList []modelsschool.SystemMenuSchool + err := overall.CONSTANT_DB_Master.Where("`m_steat` = 1").Order("`m_sort` ASC").Order("`m_id` DESC").Find(&menuList).Error + lenSum := len(menuList) + // fmt.Printf("ApiUrl---3--->%v--->%v\n", err, lenSum) + if err != nil || lenSum < 1 { return } + var menuSmaillList []publicmethod.MenuContList + for i := 0; i < lenSum; i++ { + var menSmaiCont publicmethod.MenuContList + menSmaiCont.Id = strconv.FormatInt(menuList[i].Id, 10) + menSmaiCont.Name = menuList[i].Title + menSmaiCont.ParentId = strconv.FormatInt(menuList[i].ParentId, 10) + menSmaiCont.PathUrl = menuList[i].ApiUrl + menuSmaillList = append(menuSmaillList, menSmaiCont) + } + menuThree = publicmethod.GetMenuThree(1, "0", menuSmaillList) + return +} + +// 仓储菜单树 +func wmsMenuThree() (menuThree []publicmethod.PowerThree) { + var menuList []modelsstorage.AccesstoAddress + err := overall.CONSTANT_DB_Storage.Where("`state` = 1").Find(&menuList).Error + lenSum := len(menuList) + if err != nil || lenSum < 1 { + return + } + var menuSmaillList []publicmethod.MenuContList + for i := 0; i < lenSum; i++ { + var menSmaiCont publicmethod.MenuContList + menSmaiCont.Id = strconv.FormatInt(menuList[i].Id, 10) + menSmaiCont.Name = menuList[i].Name + menSmaiCont.ParentId = strconv.FormatInt(int64(menuList[i].Menuparent), 10) + menSmaiCont.PathUrl = menuList[i].Url + menuSmaillList = append(menuSmaillList, menSmaiCont) + } + menuThree = publicmethod.GetMenuThrees(1, "0", menuSmaillList) return } diff --git a/api/version1/jurisdiction/jurisdictionpc/type.go b/api/version1/jurisdiction/jurisdictionpc/type.go index e0883e2..04b6927 100644 --- a/api/version1/jurisdiction/jurisdictionpc/type.go +++ b/api/version1/jurisdiction/jurisdictionpc/type.go @@ -46,10 +46,22 @@ type editSystemCont struct { addsystemapp } -// 权限菜单树 -type powerThree struct { +// 菜单列表 +type menuContList struct { publicmethod.PublicId publicmethod.PublicName + ParentId string `json:"parentid"` +} +// 权限菜单树 +type powerThree struct { + menuContList Child []powerThree `json:"child"` } + +// 权限菜单树URL返回解析 +type callBackUrlMenu struct { + Code int `json:"code"` + Msg string `json:"msg"` + Data []publicmethod.PowerThree `json:"data"` +} diff --git a/api/version1/postseting/postpc/scheme.go b/api/version1/postseting/postpc/scheme.go index b56c710..971e7a4 100644 --- a/api/version1/postseting/postpc/scheme.go +++ b/api/version1/postseting/postpc/scheme.go @@ -88,7 +88,7 @@ func (a *ApiMethod) GetSchemeList(c *gin.Context) { comCont.GetCont(map[string]interface{}{"`id`": schemeList[i].OrgId}, "`name`") sendDataCont.OrgName = comCont.Name //归属行政组织"` var postContInfo modelshr.Position - postContInfo.GetCont(map[string]interface{}{"`id`": schemeList[i].Group}, "`name`") + postContInfo.GetCont(map[string]interface{}{"`id`": schemeList[i].Position}, "`name`") sendDataCont.PostName = postContInfo.Name //`归属岗位"` sendData = append(sendData, sendDataCont) @@ -164,7 +164,8 @@ func (p *postDimeTarSync) GetPostTargent(position modelshr.Position, dutyClass m targetCont.StandardScore = getPostDimeTarWeight(position.AdministrativeOrganization, position.Id, dutyClass.Id, v.Id, 2, 1) //标准分 targetCont.Unit = v.Unit //单位 targetCont.IsTrue = 2 //是否允许修改 1:不允许;2:允许 - targetCont.State = 1 //状态 1:启用;2:禁用;3:观察 + targetCont.Type = v.Type + targetCont.State = 1 //状态 1:启用;2:禁用;3:观察 planCont.Child = append(planCont.Child, targetCont) } @@ -524,9 +525,11 @@ func postSchemeTargetPost(versionNumber string, source, judgeState int, scheme [ //获取该指标的岗位指标子栏目 var postSonTarget []modelskpi.PostSonTarget overall.CONSTANT_DB_KPI.Model(&modelskpi.PostSonTarget{}).Select("`id`,`parent_id`").Where("`state` = 1 AND `depart` = ? AND `depart_post` = ? AND `parent_id` = ?", orgid, postid, targetIdInt64).Find(&postSonTarget) + fmt.Printf("postSonTarget--------->%v\n", postSonTarget) if len(postSonTarget) > 0 { for _, son_v := range postSonTarget { + fmt.Printf("son_v--------->%v\n", son_v) syncSetinges.Add(1) go xizeXiecheng.eidtPostSchemeInfo(versionNumber, companyId, departmentId, orgid, postid, dimensionIdInt64, son_v.ParentId, son_v.Id, cv.State, scoringMethod, judgeState) } @@ -568,6 +571,7 @@ func (p *postShemeListCont) eidtPostSchemeInfo(versionNumber string, companyId, //获取相关指标细则内容 var postTargetDetailsCont []modelskpi.PostTargetDetails overall.CONSTANT_DB_KPI.Where("`state` = 1 AND `parentid` = ? AND `parentid_sun` = ? AND `paretment` = ? AND `paretment_post` = ?", targetId, sonTargetId, orgid, postid).Find(&postTargetDetailsCont) + fmt.Printf("postTargetDetailsCont--------->%v\n", postTargetDetailsCont) if len(postTargetDetailsCont) > 0 { for _, v := range postTargetDetailsCont { var saveData modelskpi.QualitativeEvaluationScheme //方案内容结构体 @@ -596,6 +600,8 @@ func (p *postShemeListCont) eidtPostSchemeInfo(versionNumber string, companyId, eidtTargetCont["`maxmoney`"] = v.Maxmoney eidtTargetCont["`minmoney`"] = v.Minmoney saveData.EiteCont(map[string]interface{}{"`id`": saveData.Id}, eidtTargetCont) + + fmt.Printf("judgeLianErr--------->%v\n", saveData) } else { //不存在需要新增 var saveData modelskpi.QualitativeEvaluationScheme //方案内容结构体 @@ -605,7 +611,7 @@ func (p *postShemeListCont) eidtPostSchemeInfo(versionNumber string, companyId, saveData.OrgId = orgid //归属行政组织"` saveData.PostId = postid //归属岗位"` saveData.Title = v.Title //考核项名称"` - saveData.DimensionId = departmentId //维度"` + saveData.DimensionId = dimensionId //维度"` saveData.TargetId = targetId //指标"` saveData.SonTargetId = sonTargetId //子栏目"` saveData.DetailsId = v.Id //细则"` @@ -624,6 +630,7 @@ func (p *postShemeListCont) eidtPostSchemeInfo(versionNumber string, companyId, saveData.Maxmoney = v.Maxmoney //最高罚款 saveData.Minmoney = v.Minmoney //最低罚款 p.shememList = append(p.shememList, saveData) + fmt.Printf("judgeLianErr----saveData----->%v\n", saveData) } } } diff --git a/api/version1/postseting/postweb/posttarget.go b/api/version1/postseting/postweb/posttarget.go index da35ece..1219a4c 100644 --- a/api/version1/postseting/postweb/posttarget.go +++ b/api/version1/postseting/postweb/posttarget.go @@ -96,7 +96,7 @@ func (a *ApiMethod) GetPostNature(c *gin.Context) { //获取被考核人本岗位的考核项目 var itemList []modelskpi.ShemePeople - err = overall.CONSTANT_DB_KPI.Where("`state` IN (1,3) AND `type` = 2 AND `attribute` = 1 AND `run_state` <> 2 AND `org_id` = ? AND `post_id` = ? AND `man_key` = ?", userCont.MainDeparment, userCont.Position, context.Key).Find(&itemList).Error + err = overall.CONSTANT_DB_KPI.Where("`state` = 1 AND `tr_type` = 2 AND `attribute` = 1 AND `run_state` <> 2 AND `org_id` = ? AND `post_id` = ? AND `man_key` = ?", userCont.AdminOrg, userCont.Position, context.Key).Find(&itemList).Error if err != nil || len(itemList) < 1 { publicmethod.Result(107, err, c) return @@ -106,9 +106,11 @@ func (a *ApiMethod) GetPostNature(c *gin.Context) { var outDataAry []outPostManTargetList for _, v := range itemList { if publicmethod.IsInTrue[int64](v.TargetId, targetId) == false { + var tarCont modelskpi.PostTarget + tarCont.GetCont(map[string]interface{}{"`id`": v.TargetId}, "`title`") var outCont outPostManTargetList outCont.Id = strconv.FormatInt(v.TargetId, 10) - outCont.Title = v.Title + outCont.Title = tarCont.Title outCont.Class = v.Attribute if v.Source == 1 { //岗位 var postTarDeta modelskpi.PostTargetDetails @@ -122,11 +124,40 @@ func (a *ApiMethod) GetPostNature(c *gin.Context) { outCont.UserKey = receivedValue.Id outCont.DimensionId = strconv.FormatInt(v.DimensionId, 10) outDataAry = append(outDataAry, outCont) + targetId = append(targetId, v.TargetId) } } publicmethod.Result(0, outDataAry, c) } +// 获取定性指标子栏目列表 +func (a *ApiMethod) GetPostNatureSonTarget(c *gin.Context) { + var receivedValue getSonTarList + err := c.ShouldBindJSON(&receivedValue) + if err != nil { + publicmethod.Result(100, err, c) + return + } + if receivedValue.Id == "" { + publicmethod.Result(101, receivedValue, c) + return + } + var sonTargetList []modelskpi.PostSonTarget + gormDb := overall.CONSTANT_DB_KPI.Model(&modelskpi.PostSonTarget{}).Where("`parent_id` = ?", receivedValue.Id) + if receivedValue.OrgId != "" { + gormDb = gormDb.Where("`depart` = ?", receivedValue.OrgId) + } + if receivedValue.PostId != "" { + gormDb = gormDb.Where("`depart_post` = ?", receivedValue.PostId) + } + err = gormDb.Find(&sonTargetList).Error + if err != nil || len(sonTargetList) < 1 { + publicmethod.Result(104, err, c) + return + } + publicmethod.Result(0, sonTargetList, c) +} + // 获取定量指标列表 func (a *ApiMethod) GetPostRation(c *gin.Context) { var receivedValue publicmethod.PublicId @@ -151,7 +182,7 @@ func (a *ApiMethod) GetPostRation(c *gin.Context) { //获取被考核人本岗位的考核项目 var itemList []modelskpi.ShemePeople - err = overall.CONSTANT_DB_KPI.Where("`state` IN (1,3) AND `type` = 2 AND `attribute` = 2 AND `run_state` <> 2 AND `org_id` = ? AND `post_id` = ? AND `man_key` = ?", userCont.MainDeparment, userCont.Position, context.Key).Find(&itemList).Error + err = overall.CONSTANT_DB_KPI.Where("`state` = 1 AND `tr_type` = 2 AND `attribute` = 2 AND `run_state` <> 2 AND `org_id` = ? AND `post_id` = ? AND `man_key` = ?", userCont.AdminOrg, userCont.Position, context.Key).Find(&itemList).Error if err != nil || len(itemList) < 1 { publicmethod.Result(107, err, c) return @@ -205,7 +236,10 @@ func (a *ApiMethod) GetPostDeimensoInfo(c *gin.Context) { //获取被考核人本岗位的考核项目 var itemList []modelskpi.ShemePeople - gormDb := overall.CONSTANT_DB_KPI.Where("`state` IN (1,3) AND `type` = 2 AND `attribute` = 1 AND `run_state` <> 2 AND `dimension_id` = ? AND `target_id` = ? AND `org_id` = ? AND `post_id` = ? AND `man_key` = ?", receivedValue.DimensionId, receivedValue.TargetId, userCont.MainDeparment, userCont.Position, context.Key) + gormDb := overall.CONSTANT_DB_KPI.Where("`state` = 1 AND `tr_type` = 2 AND `attribute` = 1 AND `run_state` <> 2 AND `dimension_id` = ? AND `target_id` = ? AND `org_id` = ? AND `post_id` = ? AND `man_key` = ?", receivedValue.DimensionId, receivedValue.TargetId, userCont.AdminOrg, userCont.Position, context.Key) + if receivedValue.Sontargetid != "" { + gormDb = gormDb.Where("`son_target_id` = ?", receivedValue.Sontargetid) + } gormDb = publicmethod.PageTurningSettings(gormDb, receivedValue.Page, receivedValue.PageSize) errGorm := gormDb.Order("`son_target_id` DESC").Find(&itemList).Error var total int64 @@ -257,16 +291,18 @@ func (a *ApiMethod) GetPostDeimensoInfo(c *gin.Context) { //获取指标信息 if v.Source == 1 { //岗位 var targetCont modelskpi.PostTargetDetails - targetCont.GetCont(map[string]interface{}{"`id`": v.DetailsId}, "content", "add_reduce", "censor_cont") + targetCont.GetCont(map[string]interface{}{"`id`": v.DetailsId}, "`content`", "`add_reduce`", "`censor_cont`", "`company`") outCont.Context = targetCont.Content //指标说明"` outCont.AddReduce = targetCont.AddReduce //1:减少;2:增加;3:无属性,现场确认加或减"` outCont.CensorCont = targetCont.CensorCont //检查依据"` + outCont.Unity = targetCont.Company } else { //部门 var departTarDeta modelskpi.DetailedTarget - departTarDeta.GetCont(map[string]interface{}{"`dt_id`": v.DetailsId}, "`dt_add_reduce`") + departTarDeta.GetCont(map[string]interface{}{"`dt_id`": v.DetailsId}, "`dt_add_reduce`", "`dt_company`") outCont.Context = departTarDeta.Content //指标说明"` outCont.AddReduce = departTarDeta.AddReduce //1:减少;2:增加;3:无属性,现场确认加或减"` outCont.CensorCont = departTarDeta.CensorCont //检查依据"` + outCont.Unity = departTarDeta.Company } } if v.MinScore != 0 { @@ -354,14 +390,37 @@ func (a *ApiMethod) GetNaturePostDimerons(c *gin.Context) { } if shemeCont.MinScore != 0 { outCont.ScoreStr = fmt.Sprintf("%v-%v", shemeCont.MinScore, shemeCont.MaxScore) + outCont.ScoreState = 2 + } else if shemeCont.MinScore > 0 && shemeCont.MaxScore <= 0 { + outCont.ScoreStr = fmt.Sprintf("%v", float64(shemeCont.MinScore)/100) + outCont.ScoreState = 1 + } else if shemeCont.MinScore <= 0 && shemeCont.MaxScore > 0 { + outCont.ScoreStr = fmt.Sprintf("%v", float64(shemeCont.MaxScore)/100) + outCont.ScoreState = 1 } else { - outCont.ScoreStr = fmt.Sprintf("%v", shemeCont.MaxScore) + outCont.ScoreStr = "0" + outCont.ScoreState = 3 } + if shemeCont.Minmoney != 0 { outCont.MoneyStr = fmt.Sprintf("%v-%v", shemeCont.Minmoney, shemeCont.Maxmoney) + outCont.MoneyState = 2 + } else if shemeCont.Minmoney > 0 && shemeCont.Maxmoney <= 0 { + outCont.MoneyStr = fmt.Sprintf("%v", float64(shemeCont.Minmoney)/100) + outCont.MoneyState = 1 + } else if shemeCont.Minmoney <= 0 && shemeCont.Maxmoney > 0 { + outCont.MoneyStr = fmt.Sprintf("%v", float64(shemeCont.Maxmoney)/100) + outCont.MoneyState = 1 } else { - outCont.MoneyStr = fmt.Sprintf("%v", shemeCont.Maxmoney) + outCont.MoneyStr = "0" + outCont.MoneyState = 3 } + + // if shemeCont.Minmoney != 0 { + // outCont.MoneyStr = fmt.Sprintf("%v-%v", shemeCont.Minmoney, shemeCont.Maxmoney) + // } else { + // outCont.MoneyStr = fmt.Sprintf("%v", shemeCont.Maxmoney) + // } outCont.UserKey = receivedValue.UserKey publicmethod.Result(0, outCont, c) } diff --git a/api/version1/postseting/postweb/type.go b/api/version1/postseting/postweb/type.go index 60e9fab..01ba587 100644 --- a/api/version1/postseting/postweb/type.go +++ b/api/version1/postseting/postweb/type.go @@ -45,6 +45,7 @@ type getNatureDimeList struct { UserKey string `json:"userkey"` DimensionId string `json:"dimensionid"` //维度 TargetId string `json:"targetid"` + Sontargetid string `json:"sontargetid"` } // 输出定性考核细则内容 @@ -57,6 +58,7 @@ type outNatureDimeCont struct { ScoreStr string `json:"scorestr"` //基础考核标准 MoneyStr string `json:"moneystr"` //现金 UserKey string `json:"userkey"` + Unity string `json:"unity"` //单位 } // 岗位定性考核细致获取数据 @@ -75,6 +77,8 @@ type outNatureDimePostCont struct { ScoreStr string `json:"scorestr"` //基础考核标准 MoneyStr string `json:"moneystr"` //现金 UserKey string `json:"userkey"` + ScoreState int `json:"scorestate"` //1、定分;2、区间分;3、不定性分值 + MoneyState int `json:"moneystate"` //1、定分;2、区间分;3、不定性分值 } // 个人岗位定性考核提交数据参数 @@ -169,3 +173,10 @@ type baseLineType struct { TargetId string `json:"targetid"` AllZeroCappingWeight } + +// 获取子栏目列表 +type getSonTarList struct { + publicmethod.PublicId + OrgId string `orgid` + PostId string `postid` +} diff --git a/apirouter/v1/postseting/web.go b/apirouter/v1/postseting/web.go index 1cd4b1e..c6c85b1 100644 --- a/apirouter/v1/postseting/web.go +++ b/apirouter/v1/postseting/web.go @@ -15,13 +15,14 @@ func (a *ApiRouter) RouterGroupWeb(router *gin.RouterGroup) { apiRouter.GET("", methodBinding.Index) //入口 apiRouter.POST("", methodBinding.Index) //入口 - apiRouter.POST("getposttarget", methodBinding.GetPostTarget) //获取指定人要考核的项目列表 - apiRouter.POST("getpostnature", methodBinding.GetPostNature) //定性指标列表 - apiRouter.POST("getpostration", methodBinding.GetPostRation) //获取定量指标列表 - apiRouter.POST("get_post_deimenso_info", methodBinding.GetPostDeimensoInfo) //获取岗位定性考核指标细则列表 - apiRouter.POST("get_nature_post_dimerons", methodBinding.GetNaturePostDimerons) //获取被考核人定性指标细则详细内容 - apiRouter.POST("send_us_nature_evaluation", methodBinding.SendUsNatureEvaluation) //提交个人岗位定性考核数据 - apiRouter.POST("get_ration_target_cont", methodBinding.GetRationTargetCont) //获取定量考核详细内容 - apiRouter.POST("submit_ration_post_cont", methodBinding.SubmitRationPostCont) //提交定量考核数据 + apiRouter.POST("getposttarget", methodBinding.GetPostTarget) //获取指定人要考核的项目列表 + apiRouter.POST("getpostnature", methodBinding.GetPostNature) //定性指标列表 + apiRouter.POST("get_post_nature_son_target", methodBinding.GetPostNatureSonTarget) //定性子栏目列表 + apiRouter.POST("getpostration", methodBinding.GetPostRation) //获取定量指标列表 + apiRouter.POST("get_post_deimenso_info", methodBinding.GetPostDeimensoInfo) //获取岗位定性考核指标细则列表 + apiRouter.POST("get_nature_post_dimerons", methodBinding.GetNaturePostDimerons) //获取被考核人定性指标细则详细内容 + apiRouter.POST("send_us_nature_evaluation", methodBinding.SendUsNatureEvaluation) //提交个人岗位定性考核数据 + apiRouter.POST("get_ration_target_cont", methodBinding.GetRationTargetCont) //获取定量考核详细内容 + apiRouter.POST("submit_ration_post_cont", methodBinding.SubmitRationPostCont) //提交定量考核数据 } } diff --git a/apirouter/v1/systempower/pc.go b/apirouter/v1/systempower/pc.go index f61097d..7fdd3aa 100644 --- a/apirouter/v1/systempower/pc.go +++ b/apirouter/v1/systempower/pc.go @@ -20,5 +20,8 @@ func (a *ApiRouter) RouterGroupPc(router *gin.RouterGroup) { apiRouter.POST("system_list", methodBinding.SystemList) //系统列表 apiRouter.POST("edit_system", methodBinding.EditSystem) //编辑应用系统信息 apiRouter.POST("edit_state_of_del", methodBinding.EditStateOfDel) //更改状态或删除 + + //相关系统菜单 + apiRouter.POST("system_about_menu", methodBinding.SystemAboutMenu) //系统菜单 } } diff --git a/models/modelsschool/system_menu.go b/models/modelsschool/system_menu.go index ec6e4fe..5fe54dc 100644 --- a/models/modelsschool/system_menu.go +++ b/models/modelsschool/system_menu.go @@ -6,7 +6,7 @@ import ( ) // 菜单 -type SystemMenu struct { +type SystemMenuSchool struct { Id int64 `json:"id" gorm:"primaryKey;column:m_id;type:bigint(20) unsigned;not null;comment:ID"` Title string `json:"title" gorm:"column:m_title;type:varchar(255);not null;comment:菜单名称"` State int `json:"state" gorm:"column:m_steat;type:tinyint(1) unsigned;default:1;not null;comment:是否启用(1:启用;2:禁用;3:删除)"` @@ -18,24 +18,24 @@ type SystemMenu struct { Sort int `json:"sort" gorm:"column:m_sort;type:tinyint(3) unsigned;default:0;not null;comment:排序"` } -func (SystemMenu *SystemMenu) TableName() string { +func (SystemMenu *SystemMenuSchool) TableName() string { return "system_menu" } -// 菜单管理 -type SystemMenuOperation struct { - SystemMenu - MenuPermit []MenuOperation `json:"menupermit"` -} +// // 菜单管理 +// type SystemMenuOperation struct { +// SystemMenuSchool +// MenuPermit []MenuOperation `json:"menupermit"` +// } // 编辑内容 -func (cont *SystemMenu) EiteCont(whereMap interface{}, saveData interface{}) (err error) { +func (cont *SystemMenuSchool) EiteCont(whereMap interface{}, saveData interface{}) (err error) { err = overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Updates(saveData).Error return } // 获取内容 -func (cont *SystemMenu) GetCont(whereMap interface{}, field ...string) (err error) { +func (cont *SystemMenuSchool) GetCont(whereMap interface{}, field ...string) (err error) { gormDb := overall.CONSTANT_DB_KPI.Model(&cont) if len(field) > 0 { fieldStr := strings.Join(field, ",") @@ -47,13 +47,13 @@ func (cont *SystemMenu) GetCont(whereMap interface{}, field ...string) (err erro } // 根据条件获取总数 -func (cont *SystemMenu) CountCont(whereMap interface{}) (countId int64) { +func (cont *SystemMenuSchool) CountCont(whereMap interface{}) (countId int64) { overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Count(&countId) return } // 读取全部信息 -func (cont *SystemMenu) ContMap(whereMap interface{}, field ...string) (countAry []SystemMenu, err error) { +func (cont *SystemMenuSchool) ContMap(whereMap interface{}, field ...string) (countAry []SystemMenuSchool, err error) { gormDb := overall.CONSTANT_DB_KPI.Model(&cont) if len(field) > 0 { fieldStr := strings.Join(field, ",") @@ -64,7 +64,7 @@ func (cont *SystemMenu) ContMap(whereMap interface{}, field ...string) (countAry } // 删除内容 -func (cont *SystemMenu) DelCont(whereMap interface{}) (err error) { +func (cont *SystemMenuSchool) DelCont(whereMap interface{}) (err error) { err = overall.CONSTANT_DB_KPI.Where(whereMap).Delete(&cont).Error return } diff --git a/overall/publicmethod/formatOutput.go b/overall/publicmethod/formatOutput.go index b1662b1..f8c35b0 100644 --- a/overall/publicmethod/formatOutput.go +++ b/overall/publicmethod/formatOutput.go @@ -1,9 +1,11 @@ package publicmethod import ( + "bytes" "encoding/json" "errors" "fmt" + "io/ioutil" "key_performance_indicators/models/modelshr" "key_performance_indicators/overall" "net/http" @@ -71,3 +73,30 @@ func LoginMyCont(c *gin.Context) (myCont modelshr.ManCont, err error) { } return } + +// Get请求 +func CurlGet(getUrl string) []byte { + client := &http.Client{} + reqest, err := http.NewRequest("GET", getUrl, nil) + if err != nil { + panic(err) + } + response, _ := client.Do(reqest) + defer response.Body.Close() + body, err := ioutil.ReadAll(response.Body) + return body +} + +// Post请求 json +func CurlPostJosn(postUrl string, jsonData []byte) []byte { + req, err := http.NewRequest("POST", postUrl, bytes.NewBuffer(jsonData)) + req.Header.Set("Content-Type", "application/json;charset=utf-8") + client := &http.Client{} + resp, err := client.Do(req) + if err != nil { + panic(err) + } + defer resp.Body.Close() + body, _ := ioutil.ReadAll(resp.Body) + return body +} diff --git a/overall/publicmethod/technique.go b/overall/publicmethod/technique.go index 632b533..7dce54c 100644 --- a/overall/publicmethod/technique.go +++ b/overall/publicmethod/technique.go @@ -697,37 +697,56 @@ func GetPostPower(ordid, postid int64, system string) (menuIdAry, menuUrl []stri redisFileEmpowerKey := fmt.Sprintf("ScanCode:SystemEmpower:Authorize_%v_%v_%v", overall.CONSTANT_CONFIG.RedisPrefixStr.Alias, system, postid) redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS5) empowerRedisToken, isTrue := redisClient.HashGetAll(redisFileEmpowerKey) + // fmt.Printf("empowerRedisToken------------->%v---------->isTrue------------->%v---------->redisFileEmpowerKey------------->%v\n", empowerRedisToken, isTrue, redisFileEmpowerKey) if isTrue == false { - var ponitId string - err = overall.CONSTANT_DB_System_Permission.Model(&modelssystempermission.Empower{}).Select("`point_id`").Where("`state` = 1 AND `post_id` = ? AND `system` = ?", postid, system).Find(&ponitId).Error - if err != nil { - return - } - menuIdAry = strings.Split(ponitId, ",") - if len(menuIdAry) < 1 { - return - } - switch system { - case "cangchu": - menuUrl, err = getStorageSystemEmpower(menuIdAry) - default: - //绩效考核系统 - menuUrl, err = getKpiSystemEmpower(menuIdAry) - } + fmt.Printf("GetPostPower-1-->%v\n", empowerRedisToken["menuid"]) + menuIdAry, menuUrl, err = readMenuList(postid, system) writeRedisData := MapOut[string]() writeRedisData["menuid"] = strings.Join(menuIdAry, ",") writeRedisData["menuurl"] = strings.Join(menuUrl, "|_^_|") redisClient.SetRedisTime(10800) redisClient.HashMsetAdd(redisFileEmpowerKey, writeRedisData) } else { - // fmt.Printf("empowerRedisToken--->%v\n", empowerRedisToken) + // fmt.Printf("GetPostPower-2-->%v\n", empowerRedisToken["menuid"]) menuIdAry = strings.Split(empowerRedisToken["menuid"], ",") menuUrl = strings.Split(empowerRedisToken["menuurl"], "|_^_|") + // fmt.Printf("GetPostPower-3-->%v-->%v\n", len(menuIdAry), menuIdAry) + if len(menuIdAry) <= 1 { + menuIdAry, menuUrl, err = readMenuList(postid, system) + writeRedisData := MapOut[string]() + writeRedisData["menuid"] = strings.Join(menuIdAry, ",") + writeRedisData["menuurl"] = strings.Join(menuUrl, "|_^_|") + redisClient.SetRedisTime(10800) + redisClient.HashMsetAdd(redisFileEmpowerKey, writeRedisData) + } } return } +/* +读取菜单 +*/ +func readMenuList(postid int64, system string) (menuIdAry, menuUrl []string, err error) { + var ponitId string + err = overall.CONSTANT_DB_System_Permission.Model(&modelssystempermission.Empower{}).Select("`point_id`").Where("`state` = 1 AND `post_id` = ? AND `system` = ?", postid, system).Find(&ponitId).Error + if err != nil { + return + } + menuIdAry = strings.Split(ponitId, ",") + if len(menuIdAry) < 1 { + return + } + switch system { + case "cangchu": + menuUrl, err = getStorageSystemEmpower(menuIdAry) + default: + //绩效考核系统 + menuUrl, err = getKpiSystemEmpower(menuIdAry) + } + return +} + /* 获取绩效考核系统授权菜单 @menuIdAry 菜单ID @@ -737,7 +756,7 @@ func getKpiSystemEmpower(menuIdAry []string) (menuUrl []string, err error) { return } var empowerMenuUrl []string - err = overall.CONSTANT_DB_Master.Model(&modelsschool.SystemMenu{}).Distinct("`m_url`").Where("`m_steat` = 1 AND `m_id` IN ?", menuIdAry).Find(&empowerMenuUrl).Error + err = overall.CONSTANT_DB_Master.Model(&modelsschool.SystemMenuSchool{}).Distinct("`m_url`").Where("`m_steat` = 1 AND `m_id` IN ?", menuIdAry).Find(&empowerMenuUrl).Error if err != nil || len(empowerMenuUrl) < 1 { return } @@ -796,3 +815,66 @@ func getSunOrgList(orgId int64) (orgList []modelshr.AdministrativeOrganization, ovErr = overall.CONSTANT_DB_HR.Where("state = 1").Where("ispower = 1 AND superior = ?", orgId).Find(&orgList).Error return } + +// 递归无限极菜单树 +func GetMenuThree(jurisd int, parentId string, threeData []MenuContList) []PowerThree { + treeList := []PowerThree{} + for _, v := range threeData { + if v.ParentId == parentId { + child := GetMenuThree(jurisd, v.Id, threeData) + var node PowerThree + node.Id = v.Id + node.Name = v.Name + node.ParentId = v.ParentId + isTrue, menuOper := MenuOperation(jurisd, v.Id) + if isTrue == true { + node.MenuOperation = menuOper + // fmt.Printf("GetMenuThree-1111--%v--->%v\n", v.Id, menuOper) + } + node.Child = child + treeList = append(treeList, node) + } + } + return treeList +} + +// 获取菜单操作项目 +func MenuOperation(jurisd int, menuId string) (isTrue bool, operation []MenuContList) { + var operList []modelsschool.MenuOperation + isTrue = false + operErr := overall.CONSTANT_DB_Master.Where("`menu_id` = ?", menuId).Order("oper_id desc").Find(&operList).Error + if operErr != nil || len(operList) < 1 { + return + } + + isTrue = true + for i := 0; i < len(operList); i++ { + var menSmaiCont MenuContList + menSmaiCont.Id = strconv.FormatInt(operList[i].OperId, 10) + menSmaiCont.Name = operList[i].OperTitle + menSmaiCont.ParentId = strconv.FormatInt(operList[i].MenuId, 10) + operation = append(operation, menSmaiCont) + } + // fmt.Printf("ApiUrl---%v--->%v--->%v--->%v\n", menuId, isTrue, operErr, operList) + return +} + +/* +递归无限极菜单树 +*/ +func GetMenuThrees(jurisd int, parentId string, threeData []MenuContList) []PowerThree { + treeList := []PowerThree{} + for _, v := range threeData { + if v.ParentId == parentId { + child := GetMenuThrees(jurisd, v.Id, threeData) + var node PowerThree + node.Id = v.Id + node.Name = v.Name + node.ParentId = v.ParentId + node.Child = child + // fmt.Printf("GetMenuThree-22222--%v--->%v\n", v.Id, node) + treeList = append(treeList, node) + } + } + return treeList +} diff --git a/overall/publicmethod/type.go b/overall/publicmethod/type.go index 12b5ca1..9e4691d 100644 --- a/overall/publicmethod/type.go +++ b/overall/publicmethod/type.go @@ -62,3 +62,18 @@ type empowerOut struct { MenuIdAry []string `json:"menuid"` MenuUrl []string `json:"menuurl"` } + +// 菜单列表 +type MenuContList struct { + PublicId + PublicName + ParentId string `json:"parentid"` + PathUrl string `json:"pathurl"` +} + +// 权限菜单树 +type PowerThree struct { + MenuContList + Child []PowerThree `json:"child"` + MenuOperation []MenuContList `json:"menuOperation"` +}