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.
588 lines
20 KiB
588 lines
20 KiB
package quantification
|
|
|
|
import (
|
|
"fmt"
|
|
"strconv"
|
|
|
|
"gin_server_admin/commonus"
|
|
"gin_server_admin/global"
|
|
"gin_server_admin/model/assessmentmodel"
|
|
"gin_server_admin/model/common/response"
|
|
"gin_server_admin/model/hrsystem"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
// 量化考核图标
|
|
func (a *ApiGroup) GetQuantEChartOrgAndYear(c *gin.Context) {
|
|
isTrue, _ := commonus.ClientIdentity()
|
|
if isTrue != true {
|
|
response.Result(1001, isTrue, "您的身份令牌已经失效!请重新登录获取身份令牌!", c)
|
|
return
|
|
}
|
|
var requestData getTargetId[string]
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil {
|
|
response.Result(102, err, "数据获取失败!", c)
|
|
return
|
|
}
|
|
if len(requestData.TargetId) < 1 {
|
|
response.Result(102, err, "未获取到指标", c)
|
|
return
|
|
}
|
|
// var accDepart []string
|
|
var yearTime []string
|
|
var orgMap []orgModelsAry
|
|
var orgMapGuodu []orgModelsAry
|
|
for _, v := range requestData.TargetId {
|
|
|
|
var targetInfoAry assessmentmodel.EvaluationTarget
|
|
targetInfoErr := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.EvaluationTarget{}).Select("et_type,et_dimension").Where("et_id = ?", v).First(&targetInfoAry).Error
|
|
if targetInfoErr == nil {
|
|
|
|
// var taskIdAry []int64
|
|
// global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.QualitativeEvaluation{}).Select("qe_id").Where("qe_state = 1 AND qe_dimension = ? AND qe_target = ? ", targetInfoAry.Dimension, v).Find(&taskIdAry)
|
|
// fmt.Printf("%v----------1----@--->%v----%v\n", len(taskIdAry), targetInfoAry.Type, taskIdAry)
|
|
// panic(taskIdAry)
|
|
// if len(taskIdAry) > 0 {
|
|
|
|
var timeOrDemper dataLockStatistics
|
|
// for _, rikv := range taskIdAry {
|
|
targetId, _ := strconv.ParseInt(v, 10, 64)
|
|
if targetInfoAry.Type == 1 {
|
|
//定性考核
|
|
// fmt.Printf("%v----------1--1--------%v\n", len(taskIdAry), rikv)
|
|
synergeticProcess.Add(1)
|
|
go timeOrDemper.StatisticalQueryCriteriaXin(targetId)
|
|
} else {
|
|
//定量考核
|
|
// fmt.Printf("%v----------1--2--------%v\n", len(taskIdAry), rikv)
|
|
synergeticProcess.Add(1)
|
|
go timeOrDemper.StatisticalQueryCriteria(targetId)
|
|
}
|
|
// }
|
|
synergeticProcess.Wait()
|
|
orgMapGo, yearTimeGo := timeOrDemper.readDataLock()
|
|
for _, gtv := range yearTimeGo {
|
|
if commonus.IsInTrue[string](gtv, yearTime) == false {
|
|
yearTime = append(yearTime, gtv)
|
|
}
|
|
}
|
|
orgMapGuodu = append(orgMapGuodu, orgMapGo...)
|
|
// }
|
|
|
|
}
|
|
|
|
}
|
|
for _, gv := range orgMapGuodu {
|
|
if len(orgMap) > 0 {
|
|
for gvi, gvm := range orgMap {
|
|
if gv.Id == gvm.Id {
|
|
orgMap[gvi].Child = bianLiOrg(gv.Child, gvm.Child)
|
|
} else {
|
|
orgMap = append(orgMap, gv)
|
|
}
|
|
}
|
|
} else {
|
|
orgMap = append(orgMap, gv)
|
|
}
|
|
|
|
}
|
|
outMap := commonus.MapOut()
|
|
outMap["grouplist"] = orgMap
|
|
outMap["timelist"] = yearTime
|
|
response.Result(0, outMap, "数据获取失败!", c)
|
|
}
|
|
|
|
func bianLiOrg(guoDuOrm, outOrm []orgModels) (ormAry []orgModels) {
|
|
for _, v := range guoDuOrm {
|
|
for _, ov := range outOrm {
|
|
if v.Id != ov.Id {
|
|
outOrm = append(outOrm, v)
|
|
}
|
|
}
|
|
}
|
|
ormAry = outOrm
|
|
return
|
|
}
|
|
|
|
// 量化考核图标
|
|
func (a *ApiGroup) QuantEChart(c *gin.Context) {
|
|
isTrue, _ := commonus.ClientIdentity()
|
|
if isTrue != true {
|
|
response.Result(1001, isTrue, "您的身份令牌已经失效!请重新登录获取身份令牌!", c)
|
|
return
|
|
}
|
|
var requestData natureParameter
|
|
c.ShouldBindJSON(&requestData)
|
|
// err := c.ShouldBindJSON(&requestData)
|
|
// if err != nil {
|
|
// response.Result(102, err, "数据获取失败!", c)
|
|
// return
|
|
// }
|
|
if len(requestData.TargetId) < 1 {
|
|
response.Result(103, requestData, "未获取到指标", c)
|
|
return
|
|
}
|
|
if requestData.AnalysisAngle == 0 {
|
|
requestData.AnalysisAngle = 1
|
|
}
|
|
outMap := commonus.MapOut()
|
|
var graphicStatistics GraphicStatistics
|
|
for _, v := range requestData.TargetId {
|
|
|
|
if requestData.AnalysisAngle == 1 {
|
|
// getStatistics, gstErr := OrgDimensionStatistics(v, requestData)
|
|
getStatistics, gstErr := OrgDimensionStatisticsNew(v, requestData)
|
|
outMap["TimeDimension_"+v] = getStatistics
|
|
if gstErr == true {
|
|
for _, gsv := range getStatistics.XLine {
|
|
if commonus.IsItTrueString(gsv, graphicStatistics.XLine) == false {
|
|
graphicStatistics.XLine = append(graphicStatistics.XLine, gsv)
|
|
}
|
|
}
|
|
for _, cilv := range getStatistics.Cylindrical {
|
|
if commonus.IsItTrueString(cilv, graphicStatistics.Cylindrical) == false {
|
|
graphicStatistics.Cylindrical = append(graphicStatistics.Cylindrical, cilv)
|
|
for _, cdv := range getStatistics.CylindricalData {
|
|
// fmt.Printf("%v\n", cdv)
|
|
if cdv.Name == cilv {
|
|
graphicStatistics.CylindricalData = append(graphicStatistics.CylindricalData, cdv)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
//时间维度
|
|
// getStatistics, gstErr := TimeDimensionStatistics(v, requestData)
|
|
getStatistics, gstErr := TimeDimensionStatisticsNew(v, requestData)
|
|
outMap["TimeDimension_"+v] = getStatistics
|
|
if gstErr == true {
|
|
for _, gsv := range getStatistics.XLine {
|
|
if commonus.IsItTrueString(gsv, graphicStatistics.XLine) == false {
|
|
graphicStatistics.XLine = append(graphicStatistics.XLine, gsv)
|
|
}
|
|
}
|
|
for _, cilv := range getStatistics.Cylindrical {
|
|
if commonus.IsItTrueString(cilv, graphicStatistics.Cylindrical) == false {
|
|
graphicStatistics.Cylindrical = append(graphicStatistics.Cylindrical, cilv)
|
|
for _, cdv := range getStatistics.CylindricalData {
|
|
if cdv.Name == cilv {
|
|
graphicStatistics.CylindricalData = append(graphicStatistics.CylindricalData, cdv)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// getStatistics, gstErr := TimeDimensionStatistics(v, requestData)
|
|
// fmt.Println(gstErr)
|
|
|
|
}
|
|
outMap["graphicStatistics"] = graphicStatistics
|
|
response.Result(0, graphicStatistics, "图形数据", c)
|
|
}
|
|
|
|
func getGroupOrgList(orgAry []string) (orgMap []orgModelsAry, orgWherList []orgModels) {
|
|
var govMap []OutGovCont
|
|
var orgErr error
|
|
if len(orgAry) > 0 {
|
|
orgErr = global.GVA_DB_HrDataBase.Model(&hrsystem.AdministrativeOrganization{}).Select("administrative_organization.*,aot.name as classname,aot.level").Joins("left join administrative_organization_type as aot on aot.id = administrative_organization.organization_type").Where("administrative_organization.`state` = 1 AND administrative_organization.id IN ?", orgAry).Find(&govMap).Error
|
|
} else {
|
|
var orgId []int64
|
|
global.GVA_DB_HrDataBase.Model(&hrsystem.AdministrativeOrganization{}).Select("id").Where("`state` = 1 AND `superior` = 0").Find(&orgId)
|
|
orgErr = global.GVA_DB_HrDataBase.Model(&hrsystem.AdministrativeOrganization{}).Select("administrative_organization.*,aot.name as classname,aot.level").Joins("left join administrative_organization_type as aot on aot.id = administrative_organization.organization_type").Where("administrative_organization.`state` = 1 AND administrative_organization.superior IN ?", orgId).Find(&govMap).Error
|
|
}
|
|
|
|
if orgErr != nil {
|
|
return
|
|
}
|
|
for _, v := range govMap {
|
|
if len(orgMap) > 0 {
|
|
for _, gv := range orgMap {
|
|
if gv.Id != strconv.FormatInt(v.Id, 10) {
|
|
var groupInfo orgModelsAry
|
|
groupInfo.Id = strconv.FormatInt(v.Id, 10)
|
|
groupInfo.Name = v.Name
|
|
if v.Abbreviation != "" {
|
|
groupInfo.Name = v.Abbreviation
|
|
}
|
|
groupInfo.Pid = strconv.FormatInt(v.Superior, 10)
|
|
groupInfo.Level = v.Level
|
|
orgMap = append(orgMap, groupInfo)
|
|
}
|
|
}
|
|
} else {
|
|
var groupInfo orgModelsAry
|
|
groupInfo.Id = strconv.FormatInt(v.Id, 10)
|
|
groupInfo.Name = v.Name
|
|
if v.Abbreviation != "" {
|
|
groupInfo.Name = v.Abbreviation
|
|
}
|
|
groupInfo.Pid = strconv.FormatInt(v.Superior, 10)
|
|
groupInfo.Level = v.Level
|
|
orgMap = append(orgMap, groupInfo)
|
|
}
|
|
}
|
|
if len(orgMap) > 0 {
|
|
for _, ov := range orgMap {
|
|
isInGroup := true //界定是否写入
|
|
for _, olv := range orgWherList {
|
|
if ov.Id == olv.Id {
|
|
isInGroup = false
|
|
}
|
|
}
|
|
if isInGroup == true {
|
|
var orgList orgModels
|
|
orgList.Id = ov.Id
|
|
orgList.Name = ov.Name
|
|
orgList.Pid = ov.Pid
|
|
orgList.Level = ov.Level
|
|
orgidInt, _ := strconv.ParseInt(ov.Id, 10, 64)
|
|
orgList.SunOrg = commonus.DiGuiOrgSun(orgidInt, orgList.SunOrg)
|
|
orgList.SunOrg = append(orgList.SunOrg, orgidInt)
|
|
orgWherList = append(orgWherList, orgList)
|
|
}
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
// 获取行政组织
|
|
func getGroupOrg(orgAry []string) (orgMap []orgModelsAry, orgWherList []orgModels) {
|
|
|
|
var govMap []OutGovCont
|
|
orgErr := global.GVA_DB_HrDataBase.Model(&hrsystem.AdministrativeOrganization{}).Select("administrative_organization.*,aot.name as classname,aot.level").Joins("left join administrative_organization_type as aot on aot.id = administrative_organization.organization_type").Where("administrative_organization.`state` = 1 AND administrative_organization.id IN ?", orgAry).Find(&govMap).Error
|
|
if orgErr != nil {
|
|
return
|
|
}
|
|
// fmt.Printf("%v\n", govMap)
|
|
|
|
for _, v := range govMap {
|
|
|
|
if len(orgMap) > 0 {
|
|
if v.Level > 2 {
|
|
groupId, groupIsTrue := commonus.GetNewHrOrg(v.Id)
|
|
if groupIsTrue == true {
|
|
newAdd := true
|
|
for gii, gvv := range orgMap {
|
|
if gvv.Id == strconv.FormatInt(groupId, 10) {
|
|
newAdd = false
|
|
for _, sgv := range orgMap[gii].Child {
|
|
if sgv.Id != strconv.FormatInt(v.Id, 10) {
|
|
var orgSun orgModels
|
|
orgSun.Id = strconv.FormatInt(v.Id, 10)
|
|
orgSun.Pid = strconv.FormatInt(v.Superior, 10)
|
|
orgSun.Name = v.Name
|
|
orgSun.Level = v.Level
|
|
if v.Abbreviation != "" {
|
|
orgSun.Name = v.Abbreviation
|
|
}
|
|
orgMap[gii].Child = append(orgMap[gii].Child, orgSun)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if newAdd == true {
|
|
where := commonus.MapOut()
|
|
where["id"] = groupId
|
|
orgGroupCont, orgGroupErr := commonus.GetNewOrgCont(where, "name", "organization_type")
|
|
|
|
if orgGroupErr == nil {
|
|
var groupInfo orgModelsAry
|
|
groupInfo.Id = strconv.FormatInt(groupId, 10)
|
|
groupInfo.Name = orgGroupCont.Name
|
|
groupInfo.Pid = strconv.FormatInt(v.Superior, 10)
|
|
if orgGroupCont.Abbreviation != "" {
|
|
groupInfo.Name = orgGroupCont.Abbreviation
|
|
}
|
|
var aotModel hrsystem.AdministrativeOrganizationType
|
|
where := commonus.MapOut()
|
|
where["id"] = orgGroupCont.OrganizationType
|
|
aotModel.GetCont(where, "level")
|
|
groupInfo.Level = aotModel.Level
|
|
var orgSun orgModels
|
|
orgSun.Id = strconv.FormatInt(v.Id, 10)
|
|
orgSun.Name = v.Name
|
|
if v.Abbreviation != "" {
|
|
orgSun.Name = v.Abbreviation
|
|
}
|
|
orgSun.Level = v.Level
|
|
orgSun.Pid = strconv.FormatInt(v.Superior, 10)
|
|
groupInfo.Child = append(groupInfo.Child, orgSun)
|
|
orgMap = append(orgMap, groupInfo)
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
for _, gv := range orgMap {
|
|
if gv.Id != strconv.FormatInt(v.Id, 10) {
|
|
var groupInfo orgModelsAry
|
|
groupInfo.Id = strconv.FormatInt(v.Id, 10)
|
|
groupInfo.Name = v.Name
|
|
if v.Abbreviation != "" {
|
|
groupInfo.Name = v.Abbreviation
|
|
}
|
|
groupInfo.Pid = strconv.FormatInt(v.Superior, 10)
|
|
groupInfo.Level = v.Level
|
|
orgMap = append(orgMap, groupInfo)
|
|
}
|
|
}
|
|
}
|
|
|
|
} else {
|
|
if v.Level > 2 {
|
|
groupId, groupIsTrue := commonus.GetNewHrOrg(v.Id)
|
|
if groupIsTrue == true {
|
|
where := commonus.MapOut()
|
|
where["id"] = groupId
|
|
orgGroupCont, orgGroupErr := commonus.GetNewOrgCont(where, "name", "abbreviation", "organization_type")
|
|
if orgGroupErr == nil {
|
|
var groupInfo orgModelsAry
|
|
groupInfo.Id = strconv.FormatInt(groupId, 10)
|
|
groupInfo.Name = orgGroupCont.Name
|
|
if orgGroupCont.Abbreviation != "" {
|
|
groupInfo.Name = orgGroupCont.Abbreviation
|
|
}
|
|
groupInfo.Pid = strconv.FormatInt(v.Superior, 10)
|
|
var aotModel hrsystem.AdministrativeOrganizationType
|
|
where := commonus.MapOut()
|
|
where["id"] = orgGroupCont.OrganizationType
|
|
aotModel.GetCont(where, "level")
|
|
groupInfo.Level = aotModel.Level
|
|
|
|
var orgSun orgModels
|
|
orgSun.Id = strconv.FormatInt(v.Id, 10)
|
|
orgSun.Name = v.Name
|
|
if v.Abbreviation != "" {
|
|
orgSun.Name = v.Abbreviation
|
|
}
|
|
orgSun.Level = v.Level
|
|
groupInfo.Child = append(groupInfo.Child, orgSun)
|
|
orgMap = append(orgMap, groupInfo)
|
|
}
|
|
}
|
|
} else {
|
|
var groupInfo orgModelsAry
|
|
groupInfo.Id = strconv.FormatInt(v.Id, 10)
|
|
groupInfo.Name = v.Name
|
|
if v.Abbreviation != "" {
|
|
groupInfo.Name = v.Abbreviation
|
|
}
|
|
groupInfo.Pid = strconv.FormatInt(v.Superior, 10)
|
|
groupInfo.Level = v.Level
|
|
orgMap = append(orgMap, groupInfo)
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
if len(orgMap) > 0 {
|
|
for _, ov := range orgMap {
|
|
|
|
if len(orgWherList) > 0 {
|
|
isInGroup := true //界定是否写入
|
|
for _, olv := range orgWherList {
|
|
if ov.Id == olv.Id {
|
|
isInGroup = false
|
|
}
|
|
}
|
|
if isInGroup == true {
|
|
var orgList orgModels
|
|
orgList.Id = ov.Id
|
|
orgList.Name = ov.Name
|
|
orgList.Pid = ov.Pid
|
|
orgList.Level = ov.Level
|
|
orgWherList = append(orgWherList, orgList)
|
|
}
|
|
} else {
|
|
var orgList orgModels
|
|
orgList.Id = ov.Id
|
|
orgList.Name = ov.Name
|
|
orgList.Pid = ov.Pid
|
|
orgList.Level = ov.Level
|
|
orgWherList = append(orgWherList, orgList)
|
|
}
|
|
//判断是否有下级菜单
|
|
if len(ov.Child) > 0 {
|
|
for _, ocv := range ov.Child {
|
|
if len(orgWherList) > 0 {
|
|
isIn := true //界定是否写入
|
|
for _, olv := range orgWherList {
|
|
if ocv.Id == olv.Id {
|
|
isIn = false
|
|
}
|
|
}
|
|
if isIn == true {
|
|
var orgList orgModels
|
|
orgList.Id = ocv.Id
|
|
orgList.Pid = ov.Pid
|
|
orgList.Name = fmt.Sprintf("%v%v", ov.Name, ocv.Name)
|
|
orgList.Level = ocv.Level
|
|
orgWherList = append(orgWherList, orgList)
|
|
}
|
|
} else {
|
|
var orgList orgModels
|
|
orgList.Id = ocv.Id
|
|
orgList.Pid = ov.Pid
|
|
orgList.Name = fmt.Sprintf("%v%v", ov.Name, ocv.Name)
|
|
orgList.Level = ocv.Level
|
|
orgWherList = append(orgWherList, orgList)
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
//获取定量考核目标
|
|
/*
|
|
@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, 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("达成率--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 {
|
|
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
|
|
|
|
// chuShu := resultval - zeroPrize
|
|
// beiChuShu := allPrize - zeroPrize
|
|
// // chuShu := resultval - float64(qualConfig.Zeroprize)
|
|
// // beiChuShu := float64(qualConfig.Allprize) - float64(qualConfig.Zeroprize)
|
|
// if beiChuShu > 0 {
|
|
// achievement = commonus.Decimal(chuShu / beiChuShu)
|
|
// // scoreVal = achievement * (resultval / 100)
|
|
// scoreVal = achievement * float64(targetScore)
|
|
// if achievement >= CappingVal {
|
|
// scoreVal = CappingVal * float64(targetScore)
|
|
// }
|
|
// } else {
|
|
// scoreVal = float64(targetScore)
|
|
// }
|
|
// // commonus.Decimal()
|
|
// scoreVal = commonus.Decimal(scoreVal)
|
|
// allPrize = commonus.Decimal(allPrize)
|
|
// zeroPrize = commonus.Decimal(zeroPrize)
|
|
// CappingVal = commonus.Decimal(CappingVal)
|
|
// achievement = commonus.Decimal(achievement) * 100
|
|
|
|
// if resultval <= 0 {
|
|
// achievement = 0
|
|
// scoreVal = 0
|
|
// }
|
|
// if qualConfig.CappingVal != 0 && resultval >= qualConfig.CappingVal {
|
|
// scoreVal = float64(targetScore)
|
|
// achievement = 100
|
|
// // fmt.Printf("达成率--1-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v\n", group, depart, dimen, target, year, allPrize, zeroPrize, CappingVal, achievement)
|
|
// } else {
|
|
// chuShu := resultval - float64(qualConfig.Zeroprize)
|
|
// beiChuShu := float64(qualConfig.Allprize) - float64(qualConfig.Zeroprize)
|
|
// if beiChuShu > 0 {
|
|
// achievement = commonus.Decimal(chuShu / beiChuShu)
|
|
// scoreVal = achievement * (resultval / 100)
|
|
// fmt.Printf("达成率--2-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v\n", group, depart, dimen, target, year, allPrize, zeroPrize, CappingVal, achievement, resultval)
|
|
// } else {
|
|
// scoreVal = float64(targetScore)
|
|
// // fmt.Printf("达成率--3-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v\n", group, depart, dimen, target, year, allPrize, zeroPrize, CappingVal, achievement)
|
|
// }
|
|
// }targetScore int64, resultval float64, group, depart, dimen, target, deaTarget string, year int64, timecopy int scoreVal, allPrize, zeroPrize, CappingVal, achievement float64
|
|
// fmt.Printf("\n\n达成率--4-->targetScore---------->%v------------>resultval---------->%v------------>group---------->%v------------>depart---------->%v------------>dimen---------->%v------------>target---------->%v------------>deaTarget---------->%v------------>year---------->%v------------>timecopy---------->%v------------>scoreVal---------->%v------------>allPrize---------->%v------------>zeroPrize---------->%v------------>CappingVal---------->%v------------>achievement---------->%v\n\n", targetScore, resultval, group, depart, dimen, target, deaTarget, year, timecopy, scoreVal, allPrize, zeroPrize, CappingVal, achievement)
|
|
return
|
|
}
|
|
|
|
//获取指标计算配置参数
|
|
/*
|
|
@targetScore 指标分值
|
|
@resultval 结算值
|
|
@group 集团
|
|
@depart 部门
|
|
@dimen 维度
|
|
@target 指标
|
|
@deaTarget 细则
|
|
@year 年份
|
|
@timecopy 辅助计数
|
|
@typeClass 1:定性;2:定量
|
|
|
|
返回说明
|
|
@scoreVal 计算得分
|
|
@allPrize 全奖值
|
|
@zeroPrize 零奖值
|
|
@CappingVal 封顶值
|
|
@achievement 达成率
|
|
*/
|
|
func GetQuantitativeConfigEs(targetScore int64, resultval float64, group, depart, dimen, target, deaTarget string, year int64, timecopy int, typeClass int) (scoreVal, allPrize, zeroPrize, CappingVal, achievement float64) {
|
|
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)
|
|
}
|
|
err := gormDb.First(&qualConfig).Error
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
scoreVal, allPrize, zeroPrize, CappingVal, achievement = commonus.CalculateScore(targetScore, resultval, qualConfig.Allprize, qualConfig.Zeroprize, qualConfig.CappingVal, typeClass)
|
|
|
|
return
|
|
|
|
chuShu := resultval - float64(qualConfig.Zeroprize)
|
|
beiChuShu := float64(qualConfig.Allprize) - float64(qualConfig.Zeroprize)
|
|
if beiChuShu > 0 {
|
|
achievement = commonus.Decimal(chuShu / beiChuShu)
|
|
}
|
|
|
|
allPrize = qualConfig.Allprize / 100
|
|
zeroPrize = qualConfig.Zeroprize / 100
|
|
CappingVal = qualConfig.CappingVal / 100
|
|
return
|
|
}
|
|
|