You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
165 lines
6.1 KiB
165 lines
6.1 KiB
package statistics
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"strconv"
|
|
|
|
"github.com/flipped-aurora/gin-vue-admin/server/commonus"
|
|
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
|
"github.com/flipped-aurora/gin-vue-admin/server/model/assessmentmodel"
|
|
)
|
|
|
|
//计算定量考核
|
|
/*
|
|
统计分数
|
|
@group 集团
|
|
@department 部门
|
|
@dimensionId 维度
|
|
@targetId 指标
|
|
@i 步进器
|
|
@status 是否为观察数据
|
|
@scoringMethod 手动计分还是自动计分
|
|
@class 指标类型 1、定性;2:定量
|
|
@referenceScore 指标权重
|
|
@yserInt 年度
|
|
@timeClass 4:月;5:季度;6:年;7:半年
|
|
@typeClass 1:定性;2:定量;3:观察
|
|
*/
|
|
func (t *tablePlanVersionStic) conditionStatisticsNew(group, department, dimensionId, targetId string, i, status, scoringMethod, class int, yserInt, referenceScore int64, timeClass, typeClass int) {
|
|
t.mutext.Lock()
|
|
defer t.mutext.Unlock()
|
|
var fldList []assessmentmodel.FlowDataLogType
|
|
var tableScoreCont TableScoreList
|
|
tableScoreCont.Counter = i
|
|
gormDb := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.FlowDataLogType{})
|
|
gormDb = gormDb.Where("`targetid` = ? AND `group` = ? AND `department` = ? AND `year` = ?", targetId, group, department, yserInt)
|
|
switch timeClass {
|
|
case 5:
|
|
gormDb = gormDb.Where("`quarte` = ?", i)
|
|
case 6:
|
|
case 7:
|
|
if i == 1 {
|
|
gormDb = gormDb.Where("`month` IN ?", []int{1, 2, 3, 4, 5, 6})
|
|
} else {
|
|
gormDb = gormDb.Where("`month` IN ?", []int{7, 8, 9, 10, 11, 12})
|
|
}
|
|
default:
|
|
gormDb = gormDb.Where("`month` = ?", i)
|
|
}
|
|
gormDb = gormDb.Order("`id` ASC").Find(&fldList)
|
|
|
|
jsCon, _ := json.Marshal(fldList)
|
|
|
|
fmt.Printf("targetid------------->%v------------>%v---->%v\n", targetId, timeClass, string(jsCon))
|
|
|
|
var mtScore float64 = 0
|
|
var atScore float64 = 0
|
|
var lastEvalId int64
|
|
var scoreSum float64 = 0
|
|
if len(fldList) > 0 {
|
|
for _, v := range fldList {
|
|
// fmt.Printf("Key----------------->%v\n", v.Key)
|
|
if v.Key != 0 {
|
|
lastEvalId = v.Key
|
|
}
|
|
if v.ScoringMethod == 1 {
|
|
atScore = atScore + float64(v.Score)
|
|
} else {
|
|
atScore = atScore + float64(v.ScoringScore)
|
|
}
|
|
scoreSum = scoreSum + float64(v.Score)
|
|
mtScore = mtScore + v.ScoringScore
|
|
|
|
whereDepart := commonus.MapOut()
|
|
whereDepart["id"] = v.DutyDepartment
|
|
orgContDer, _ := commonus.GetNewOrgCont(whereDepart, "name")
|
|
tableScoreCont.ExecutiveDepartment = append(tableScoreCont.ExecutiveDepartment, orgContDer.Name)
|
|
}
|
|
}
|
|
tableScoreCont.ScoreVal = commonus.Decimal(scoreSum / 100)
|
|
targetIdInt, _ := strconv.ParseInt(targetId, 10, 64)
|
|
groupId, _ := strconv.ParseInt(group, 10, 64)
|
|
departmentId, _ := strconv.ParseInt(department, 10, 64)
|
|
dimensionIdInt, _ := strconv.ParseInt(dimensionId, 10, 64)
|
|
zeroPrize, allPrize, cappingPrize := GetAllZreoCapp(lastEvalId, groupId, departmentId, dimensionIdInt, targetIdInt, yserInt, int64(i), 0)
|
|
|
|
// fmt.Printf("scoreSum--->%v------->mtScore--->%v---->zeroPrize--->%v---->allPrize--->%v---->cappingPrize--->%v---->typeClass---->%v\n", scoreSum, mtScore, zeroPrize, allPrize, cappingPrize, typeClass)
|
|
|
|
tableScoreCont.ActualScore, tableScoreCont.AllPrize, tableScoreCont.ZeroPrize, tableScoreCont.CappingVal, tableScoreCont.Achievement = commonus.CalculateScore(referenceScore, scoreSum, allPrize, zeroPrize, cappingPrize, typeClass)
|
|
// fmt.Printf("达成率--13-->%v-->%v-->%v-->%v-->%v\n", tableScoreCont.ActualScore, tableScoreCont.AllPrize, tableScoreCont.ZeroPrize, tableScoreCont.CappingVal, tableScoreCont.Achievement)
|
|
if status == 3 {
|
|
tableScoreCont.ActualScore = float64(referenceScore)
|
|
}
|
|
t.TableScore = append(t.TableScore, tableScoreCont)
|
|
syncProcessDepartTarget.Done()
|
|
}
|
|
|
|
//获取定量数据得全奖零奖封顶值得历史数据
|
|
/*
|
|
@flKey 流水KEY
|
|
@group 集团
|
|
@depart 部门
|
|
@dimen 维度
|
|
@target 指标
|
|
@deaTarget 细则
|
|
@year 年份
|
|
@timecopy 辅助计数
|
|
*/
|
|
func GetAllZreoCapp(flKey, group, depart, dimen, targetId, year, timecopy, deaTarget int64) (zeroPrize, allPrize, cappingPrize float64) {
|
|
|
|
var baseLineStr string
|
|
err := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.FlowLog{}).Select("fl_baseline").Where("fl_key = ?", flKey).First(&baseLineStr).Error
|
|
if err != nil {
|
|
zeroPrize, allPrize, cappingPrize = GetPassRate(group, depart, dimen, targetId, year, timecopy, deaTarget)
|
|
return
|
|
}
|
|
var flowLogConfig []FlowLogAllZreo
|
|
jsonErr := json.Unmarshal([]byte(baseLineStr), &flowLogConfig)
|
|
// fmt.Printf("flKey, targetId----------------->%v--------->%v---------->%v--------->%v\n", flKey, targetId, jsonErr, baseLineStr)
|
|
if jsonErr != nil {
|
|
zeroPrize, allPrize, cappingPrize = GetPassRate(group, depart, dimen, targetId, year, timecopy, deaTarget)
|
|
return
|
|
}
|
|
for _, v := range flowLogConfig {
|
|
if v.TargetId == strconv.FormatInt(targetId, 10) {
|
|
zeroPrize = v.Zeroprize
|
|
allPrize = v.Allprize
|
|
cappingPrize = v.Capping
|
|
// fmt.Printf("zeroPrize----------------->%v----allPrize----->%v-----cappingPrize----->%v------TargetId--->%v\n", zeroPrize, allPrize, cappingPrize, v.TargetId)
|
|
return
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
//获取达成率配置
|
|
func GetPassRate(group, depart, dimen, target, year, timecopy, deaTarget int64) (zeroPrize, allPrize, cappingPrize float64) {
|
|
var qualConfig assessmentmodel.QuantitativeConfig
|
|
gormDb := global.GVA_DB_Performanceappraisal.Where("`group` = ? AND `departmentid` = ? AND `dimension` = ? AND `target` = ? AND `year` = ?", group, depart, dimen, target, year)
|
|
if deaTarget != 0 {
|
|
gormDb = gormDb.Where("targetconfig = ?", deaTarget)
|
|
}
|
|
gormDb = gormDb.Where("timecopy = ?", timecopy)
|
|
err := gormDb.First(&qualConfig).Error
|
|
if err != nil {
|
|
return
|
|
}
|
|
allPrize = qualConfig.Allprize
|
|
zeroPrize = qualConfig.Zeroprize
|
|
cappingPrize = qualConfig.CappingVal
|
|
return
|
|
}
|
|
|
|
//定性
|
|
/*SubjectiveAuxiliaryCalculationSumMethod(wherStr string, i, status, class int, referenceScore int64)
|
|
统计分数
|
|
@wherStr 统计条件
|
|
@i 步进器
|
|
@status 是否为观察数据
|
|
@class 指标类型 1、定性;2:定量
|
|
@referenceScore 指标权重
|
|
*/
|
|
|
|
func (t *tablePlanVersionStic) SubjectiveMethodNew(wherStr string, i, status, class int, referenceScore int64) {
|
|
}
|
|
|