package departmentweb import ( "encoding/json" "key_performance_indicators/api/version1/statistics" "key_performance_indicators/models/modelshr" "key_performance_indicators/models/modelskpi" "key_performance_indicators/overall/publicmethod" "strconv" "time" ) /* * @ 作者: 秦东 @ 时间: 2023-07-29 16:50:53 @ 功能: 按时间计算行政组织成绩 @ 参数 # @ 返回值 # @ 方法原型 # */ func (s *SyncOrgTimeAllScore) TallyUpOrgCalculateScore(orgCont modelshr.AdministrativeOrganization, year, month string) { //锁操作 s.mutext.Lock() defer s.mutext.Unlock() yearInt, _ := strconv.ParseInt(year, 10, 64) monthInt, _ := strconv.ParseInt(month, 10, 64) //获取版本信息 planCont, err := publicmethod.GetPlanVresion(orgCont.Id, yearInt, monthInt) var getPoints float64 //行政组织总分 if err == nil { var planVersioInfo []SchemeInfo jsonErr := json.Unmarshal([]byte(planCont.Content), &planVersioInfo) if jsonErr == nil { for _, v := range planVersioInfo { //维度 for _, sv := range v.Child { //指标 if sv.Status == 3 { //为观察指标 getPoints = getPoints + float64(sv.ReferenceScore) } else { var targetInfo modelskpi.EvaluationTarget targetInfo.GetCont(map[string]interface{}{"et_id": sv.Id}, "et_type,et_cycle") if sv.Cycles == 0 { //判断统计方式 sv.Cycles = targetInfo.Cycles } if targetInfo.Type == 1 { //定性考核 dingXingScore, _ := statistics.DingXingScoreCalculation(orgCont.Id, yearInt, sv.ReferenceScore, []int64{monthInt}, sv.Id) getPoints = getPoints + dingXingScore } else { //定量考核 var dingLiangScore float64 switch sv.Cycles { case 5: //季度指标 quarterList := []int64{3, 6, 9, 12} if !publicmethod.IsInTrue[int64](monthInt, quarterList) { dingLiangScore = float64(sv.ReferenceScore) // fmt.Printf("季度指标--->%v--->%v--->%v\n", sv.Name, sv.Id, dingLiangScore) } else { switch monthInt { case 3: dingLiangScore, _ = statistics.DingLiangScoreCalculation(orgCont.Id, yearInt, sv.ReferenceScore, []int64{1, 2, 3}, sv.Id, sv.Cycles) case 6: dingLiangScore, _ = statistics.DingLiangScoreCalculation(orgCont.Id, yearInt, sv.ReferenceScore, []int64{4, 5, 6}, sv.Id, sv.Cycles) case 9: dingLiangScore, _ = statistics.DingLiangScoreCalculation(orgCont.Id, yearInt, sv.ReferenceScore, []int64{7, 8, 9}, sv.Id, sv.Cycles) case 12: dingLiangScore, _ = statistics.DingLiangScoreCalculation(orgCont.Id, yearInt, sv.ReferenceScore, []int64{10, 11, 12}, sv.Id, sv.Cycles) default: } } case 6: //年度指标 if monthInt == 12 { dingLiangScore, _ = statistics.DingLiangScoreCalculation(orgCont.Id, yearInt, sv.ReferenceScore, []int64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}, sv.Id, sv.Cycles) } else { dingLiangScore = float64(sv.ReferenceScore) // fmt.Printf("年度指标--->%v--->%v--->%v\n", sv.Name, sv.Id, dingLiangScore) } case 7: //半年指标 switch monthInt { case 6: dingLiangScore, _ = statistics.DingLiangScoreCalculation(orgCont.Id, yearInt, sv.ReferenceScore, []int64{1, 2, 3, 4, 5, 6}, sv.Id, sv.Cycles) case 12: dingLiangScore, _ = statistics.DingLiangScoreCalculation(orgCont.Id, yearInt, sv.ReferenceScore, []int64{7, 8, 9, 10, 11, 12}, sv.Id, sv.Cycles) default: dingLiangScore = float64(sv.ReferenceScore) // fmt.Printf("半年指标--->%v--->%v--->%v\n", sv.Name, sv.Id, dingLiangScore) } default: //月度指标 dingLiangScore, _ = statistics.DingLiangScoreCalculation(orgCont.Id, yearInt, sv.ReferenceScore, []int64{monthInt}, sv.Id, sv.Cycles) } dingLiangScoreGd, _ := publicmethod.DecimalNew(dingLiangScore, 2) getPoints = getPoints + dingLiangScoreGd } } } } } } tayTime := time.Now().Unix() currentYears := publicmethod.UnixTimeToDay(tayTime, 16) currentMonth := publicmethod.UnixTimeToDay(tayTime, 17) currentYearsInt, _ := strconv.Atoi(currentYears) currentMonthInt, _ := strconv.Atoi(currentMonth) yearsInt, _ := strconv.Atoi(year) monthsInt, _ := strconv.Atoi(month) if currentYearsInt == yearsInt && monthsInt > currentMonthInt { getPoints = 0 } if s.AxisMax < getPoints { s.AxisMax = getPoints } if s.AxisMin == 0 { s.AxisMin = getPoints } else { if s.AxisMin > getPoints { s.AxisMin = getPoints } } var orgScore SyncOTASVal orgScore.OrgId = orgCont.Id orgScore.Score = publicmethod.DecimalEs(getPoints, 2) orgScore.Months, _ = strconv.Atoi(month) s.OrgScore = append(s.OrgScore, orgScore) SyncSeting.Done() } /** @ 作者: 秦东 @ 时间: 2023-07-29 17:03:39 @ 功能: 计算行政组织月份得分 @ 参数 # @ 返回值 # @ 方法原型 # */ // func (){}