diff --git a/api/version1/postseting/postpc/targetpost.go b/api/version1/postseting/postpc/targetpost.go index 68fbfc1..fca1da8 100644 --- a/api/version1/postseting/postpc/targetpost.go +++ b/api/version1/postseting/postpc/targetpost.go @@ -1,6 +1,7 @@ package postpc import ( + "fmt" "key_performance_indicators/models/modelskpi" "key_performance_indicators/overall" "key_performance_indicators/overall/publicmethod" @@ -415,7 +416,7 @@ func (a *ApiMethod) GetTargetAboutDepartToPostMan(c *gin.Context) { publicmethod.Result(0, outData, c) } -// 添加岗位细则 +// 根据指标添加岗位细则 func (a *ApiMethod) AddPostTargetCont(c *gin.Context) { var receivedValue addPostContTarget c.ShouldBindJSON(&receivedValue) @@ -460,6 +461,11 @@ func (a *ApiMethod) AddPostTargetCont(c *gin.Context) { } targetSunIdInt, _ := strconv.ParseInt(receivedValue.TargetId, 10, 64) deartmentIdInt, _ := strconv.ParseInt(receivedValue.DepartmentId, 10, 64) + //获取指标信息 + var getTargetCont modelskpi.PostTarget + getTargetCont.GetCont(map[string]interface{}{"`id`": receivedValue.TargetId}) + _, postPeople, _ := getTargetAboutPost(deartmentIdInt, getTargetCont.Dimension, getTargetCont.Id, 2) + //指标子栏目 var sunTargetCont modelskpi.PostSonTarget sunErr := sunTargetCont.GetCont(map[string]interface{}{"`title`": receivedValue.TargetSunTitle, "`parent_id`": receivedValue.TargetId, "depart": receivedValue.DepartmentId}, "`id`") @@ -483,7 +489,165 @@ func (a *ApiMethod) AddPostTargetCont(c *gin.Context) { return } //考核细则写入 - // for _, lv := range receivedValue.List { - // } + for _, lv := range receivedValue.List { + if lv.Class == 0 { + lv.Class = 1 + } + if len(lv.Inspect) == 0 { + lv.Inspect = append(lv.Inspect, "1") + } + if lv.Cycle == 0 { + lv.Cycle = getTargetCont.Cycle + } + if lv.CycleAttr == 0 { + lv.CycleAttr = getTargetCont.Cycleattr + } + if lv.Frequency == 0 { + lv.Frequency = 1 + } + + var minScoreInt int64 + var maxScoreInt int64 + scoreAry := strings.Split(lv.ReferenceScore, "-") + scoreLen := len(scoreAry) + // fmt.Printf("ScoreAry:%v----------->%v------------>%v------------>%v\n", ReferenceScore, scoreLen, scoreAry[0], scoreAry) + if scoreLen > 0 { + if scoreLen == 1 { + maxScore, _ := strconv.ParseFloat(scoreAry[0], 64) + // zhhh := maxScore * 100 + // zhuanStr := strconv.FormatFloat(zhhh, 'f', -1, 64) + maxScoreInt, _ = strconv.ParseInt(strconv.FormatFloat(maxScore*100, 'f', -1, 64), 10, 64) + minScoreInt = 0 + } else { + minScore, _ := strconv.ParseFloat(scoreAry[0], 64) + maxScore, _ := strconv.ParseFloat(scoreAry[scoreLen-1], 64) + minScoreInt, _ = strconv.ParseInt(strconv.FormatFloat(minScore*100, 'f', -1, 64), 10, 64) + maxScoreInt, _ = strconv.ParseInt(strconv.FormatFloat(maxScore*100, 'f', -1, 64), 10, 64) + } + } else { + minScoreInt = 0 + maxScoreInt = 0 + } + + var minMoney int64 //罚款或奖励最高金额 + var maxMoney int64 //罚款或奖励最新金额 + moneyAry := strings.Split(lv.CashStandard, "-") + moneyAryLen := len(moneyAry) + if moneyAryLen > 0 { + if moneyAryLen == 1 { + maxMoneyEs, _ := strconv.ParseFloat(moneyAry[0], 64) + maxMoney, _ = strconv.ParseInt(strconv.FormatFloat(maxMoneyEs*100, 'f', -1, 64), 10, 64) + minMoney = 0 + } else { + maxMoneyEs, _ := strconv.ParseFloat(moneyAry[moneyAryLen-1], 64) + maxMoney, _ = strconv.ParseInt(strconv.FormatFloat(maxMoneyEs*100, 'f', -1, 64), 10, 64) + minMoneyEs, _ := strconv.ParseFloat(moneyAry[0], 64) + minMoney, _ = strconv.ParseInt(strconv.FormatFloat(minMoneyEs*100, 'f', -1, 64), 10, 64) + } + } else { + minMoney = 0 + maxMoney = 0 + } + + var saveCont modelskpi.PostTargetDetails + saveCont.Title = lv.Title //指标细则"` + saveCont.Content = lv.Explain //备注说明"` + saveCont.ParentId = targetSunIdInt //归属指标栏目"` + saveCont.ParentIdSun = sunTargetCont.Id //归属指标子栏目"` + saveCont.State = 1 //状态(1:启用;2:禁用;3:删除)"` + saveCont.AddTime = time.Now().Unix() //制定时间"` + saveCont.MinScore = minScoreInt //最小分*100保存"` + saveCont.MaxScore = maxScoreInt //最大分*100保存"` + saveCont.Company = lv.Unit //单位"` + saveCont.AddReduce = lv.Class //1:减少;2:增加;3:无属性,现场确认加或减"` + saveCont.CensorType = strings.Join(lv.Inspect, ",") //检查方式"` + saveCont.CensorCont = lv.Evidence //客观证据"` + saveCont.CensorRate = lv.Frequency //检查频次"` + saveCont.Cycles = lv.Cycle //1:班;2:天;3:周;4:月;5:季度;6:年"` + saveCont.CycleAttres = lv.CycleAttr //辅助计数"` + saveCont.Paretment = deartmentIdInt //接受考核的部门"` + // saveCont.ParetmentPost = strings.Join(requestData.PostId, ",") //接受考核的部门岗位"` + // saveCont.Reportary = strings.Join(lv.ReportAry, ",") //接受考核的部门岗位"` + + saveCont.Punishmode = lv.PunishMode //处罚或奖励方式 1:分数;2:现金;3:分数加现金 + saveCont.Minmoney = minMoney //最高罚款*100保存"` + saveCont.Maxmoney = maxMoney //最低罚款*100保存"` + syncSeting.Add(1) + go addDetaonsCont(saveCont, lv.RelevantPostsMan, postPeople, getTargetCont.Dimension) + } + syncSeting.Wait() + //获取子栏目关联岗位 + var postIdInt64 []int64 + overall.CONSTANT_DB_KPI.Model(&modelskpi.TargetDepartment{}).Distinct("`post_id`").Where("`state` = 1 AND `level` = ? AND `department_id` = ? AND `dimension_id` = ? AND `target_id` = ? AND `target_sun_id` = ?", 2, deartmentIdInt, getTargetCont.Dimension, getTargetCont.Id, sunTargetCont.Id).Find(&postIdInt64) + if len(postIdInt64) > 0 { + var postIdStr []string + for si := 0; si < len(postIdInt64); si++ { + postIdIntToStr := strconv.FormatInt(postIdInt64[si], 10) + postIdStr = append(postIdStr, postIdIntToStr) + } + sunTargetCont.EiteCont(map[string]interface{}{"`id`": sunTargetCont.Id}, map[string]interface{}{"`depart_post`": strings.Join(postIdStr, ","), "`time`": time.Now().Unix()}) + } + publicmethod.Result(0, postIdInt64, c) +} + +/* +添加指标细则 +@saveCont 指标细则数据 +@postMan 指标细则岗位提报人键对 +*/ +func addDetaonsCont(saveCont modelskpi.PostTargetDetails, postMan, targetPostMan []postPeople, dimensionId int64) { + defer syncSeting.Done() + + //获取岗位与提报人 + var departAny []string + var peopletAny []string + for _, v := range postMan { + if publicmethod.IsInTrue[string](v.Id, departAny) == false { + departAny = append(departAny, v.Id) + } + if len(v.Operator) > 0 { + for _, ov := range v.Operator { + if publicmethod.IsInTrue[string](ov, peopletAny) == false { + peopletAny = append(peopletAny, ov) + } + } + } else { + for _, tarv := range targetPostMan { + if tarv.Id == v.Id { + for _, otv := range tarv.Operator { + if publicmethod.IsInTrue[string](otv, peopletAny) == false { + peopletAny = append(peopletAny, otv) + } + } + } + } + } + } + saveCont.ParetmentPost = strings.Join(departAny, ",") //相关岗位"` + saveCont.Reportary = strings.Join(peopletAny, ",") //上报人"` + overall.CONSTANT_DB_KPI.Create(&saveCont) + fmt.Printf("postMan------->%v--------targetPostMan------->%v--------departAny------->%v--------peopletAny------->%v\n", postMan, targetPostMan, departAny, peopletAny) + //关联部门岗位 + if len(departAny) > 0 { + syncSetinges.Add(1) + go EditTargetTableDimenAboutPostOfDepart(dimensionId, saveCont.ParentId, saveCont.ParentIdSun, saveCont.Id, saveCont.Paretment, departAny, 2, 1) + + } + //关联考核岗位和提报人 + for _, dv := range targetPostMan { + operatorList := dv.Operator + if len(operatorList) < 1 { + for _, tarv := range targetPostMan { + if tarv.Id == dv.Id { + operatorList = tarv.Operator + } + } + } + postid, _ := strconv.ParseInt(dv.Id, 10, 64) + syncSetinges.Add(1) + go DepartAboutPostTargetReport(dimensionId, saveCont.ParentId, saveCont.ParentIdSun, saveCont.Id, saveCont.Paretment, postid, operatorList, 2, 1) + + } + syncSetinges.Wait() } diff --git a/api/version1/postseting/postpc/type.go b/api/version1/postseting/postpc/type.go index c7867cb..7bea686 100644 --- a/api/version1/postseting/postpc/type.go +++ b/api/version1/postseting/postpc/type.go @@ -13,6 +13,7 @@ type ApiMethod struct{} // 协程设置 var syncSeting = sync.WaitGroup{} var syncSetinges = sync.WaitGroup{} +var syncSetingRun = sync.WaitGroup{} // 岗位指标协程操作 type postDimeTarSync struct { @@ -190,7 +191,8 @@ type postContList struct { Class int `json:"class"` //1:减少;2:增加;3:无属性,现场确认加或减 Inspect []string `json:"inspect"` //检查方式(1:现场检查;2:资料检查;3:事件触发) Cycle int `json:"cycle"` //1:班;2:天;3:周;4:月;5:季度;6:年 - CycleAttr int `json:"cycleattr"` //频次 + CycleAttr int `json:"cycleattr"` //辅助计数 + Frequency int `json:"frequency"` //频次 Evidence string `json:"evidence"` //客观证据 Explain string `json:"explain"` //备注说明 RelevantPostsMan []postPeople `json:"relevantpostsman"` //相关岗位与提报人 diff --git a/apirouter/v1/postseting/pc.go b/apirouter/v1/postseting/pc.go index 63657d7..32d86b1 100644 --- a/apirouter/v1/postseting/pc.go +++ b/apirouter/v1/postseting/pc.go @@ -23,5 +23,6 @@ func (a *ApiRouter) RouterGroupPc(router *gin.RouterGroup) { apiRouter.POST("add_post_target", methodBinding.AddPostTarget) //添加岗位指标 apiRouter.POST("dit_post_target", methodBinding.EditPostTarget) //编辑岗位指标 apiRouter.POST("get_target_about_depart_to_post_man", methodBinding.GetTargetAboutDepartToPostMan) //获取岗位指标关联部门相关岗位及提报人 + apiRouter.POST("add_post_target_cont", methodBinding.AddPostTargetCont) //根据指标添加岗位细则 } } diff --git a/apirouter/v1/postseting/web.go b/apirouter/v1/postseting/web.go index 626139a..cecbd99 100644 --- a/apirouter/v1/postseting/web.go +++ b/apirouter/v1/postseting/web.go @@ -15,10 +15,11 @@ 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("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) //提交个人岗位定性考核数据 } }