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.
110 lines
4.0 KiB
110 lines
4.0 KiB
package evaluation
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"gin_server_admin/commonus"
|
|
"gin_server_admin/global"
|
|
"gin_server_admin/model/assessmentmodel"
|
|
)
|
|
|
|
// 数据评估
|
|
type ApiGroup struct {
|
|
EvaluationApi EvaluationInterface
|
|
}
|
|
|
|
//获取定量考核目标
|
|
/*
|
|
@targetScore 指标分值
|
|
@resultval 结算值
|
|
@group 集团
|
|
@depart 部门
|
|
@dimen 维度
|
|
@target 指标
|
|
@deaTarget 细则
|
|
@year 年份
|
|
@timecopy 辅助计数
|
|
@typeClass 1:定性;2:定量
|
|
|
|
返回说明
|
|
@scoreVal 计算得分
|
|
@allPrize 全奖值
|
|
@zeroPrize 零奖值
|
|
@CappingVal 封顶值
|
|
@achievement 达成率
|
|
*/
|
|
func GetQuantitativeConfig(targetScore int64, resultval float64, group, depart, dimen, target, deaTarget string, year int64, timecopy int64, typeClass int) (scoreVal, allPrize, zeroPrize, CappingVal, achievement float64) {
|
|
scoreVal = 0
|
|
allPrize = 0
|
|
zeroPrize = 0
|
|
CappingVal = 0
|
|
achievement = 0
|
|
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)
|
|
}
|
|
// if timecopy != 0 {
|
|
// gormDb = gormDb.Where("timecopy = ?", timecopy)
|
|
// }
|
|
gormDb = gormDb.Where("timecopy = ?", timecopy)
|
|
err := gormDb.First(&qualConfig).Error
|
|
// fmt.Printf("达成率--3-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v\n", group, depart, dimen, target, year, allPrize, zeroPrize, CappingVal, achievement)
|
|
// fmt.Printf("达成率--0-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v\n", group, depart, dimen, target, year, allPrize, zeroPrize, CappingVal, achievement, err)
|
|
|
|
if err != nil {
|
|
achievement = 100
|
|
scoreVal = float64(targetScore)
|
|
return
|
|
}
|
|
|
|
scoreVal, allPrize, zeroPrize, CappingVal, achievement = commonus.CalculateScore(targetScore, resultval, qualConfig.Allprize, qualConfig.Zeroprize, qualConfig.CappingVal, typeClass)
|
|
return
|
|
|
|
allPrize = qualConfig.Allprize / 100
|
|
zeroPrize = qualConfig.Zeroprize / 100
|
|
CappingVal = qualConfig.CappingVal / 100
|
|
fmt.Printf("达成率--4-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v\n", group, depart, dimen, target, year, allPrize, zeroPrize, CappingVal, achievement)
|
|
if allPrize == 0 && zeroPrize == 0 {
|
|
achievement = 100
|
|
scoreVal = float64(targetScore)
|
|
fmt.Printf("达成率--5-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v\n", group, depart, dimen, target, year, allPrize, zeroPrize, CappingVal, achievement)
|
|
} else {
|
|
if allPrize == 0 && resultval == 0 {
|
|
achievement = 0
|
|
scoreVal = 0
|
|
} else {
|
|
chuShu := resultval - float64(qualConfig.Zeroprize)
|
|
beiChuShu := float64(qualConfig.Allprize) - float64(qualConfig.Zeroprize)
|
|
|
|
if beiChuShu != 0 {
|
|
achievement = commonus.Decimal(chuShu / beiChuShu)
|
|
if achievement <= 0 {
|
|
achievement = 0
|
|
scoreVal = 0
|
|
fmt.Printf("达成率--6-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v\n", group, depart, dimen, target, year, allPrize, zeroPrize, CappingVal, achievement)
|
|
} else {
|
|
// scoreVal = achievement * (resultval / 100)
|
|
scoreVal = achievement * (float64(targetScore))
|
|
achievement = commonus.Decimal(achievement * 100)
|
|
if achievement >= CappingVal {
|
|
scoreVal = CappingVal * float64(targetScore) / 100
|
|
fmt.Printf("达成率--9-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v\n", group, depart, dimen, target, year, allPrize, zeroPrize, CappingVal, achievement)
|
|
}
|
|
fmt.Printf("达成率--7-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v\n", group, depart, dimen, target, year, allPrize, zeroPrize, CappingVal, achievement)
|
|
}
|
|
} else {
|
|
achievement = 0
|
|
scoreVal = 0
|
|
fmt.Printf("达成率--8-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v\n", group, depart, dimen, target, year, allPrize, zeroPrize, CappingVal, achievement)
|
|
}
|
|
}
|
|
|
|
}
|
|
scoreVal = commonus.Decimal(scoreVal)
|
|
allPrize = commonus.Decimal(allPrize)
|
|
zeroPrize = commonus.Decimal(zeroPrize)
|
|
CappingVal = commonus.Decimal(CappingVal)
|
|
achievement = commonus.Decimal(achievement)
|
|
return
|
|
}
|
|
|