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.
671 lines
34 KiB
671 lines
34 KiB
package statistics
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"strconv"
|
|
"time"
|
|
|
|
"gin_server_admin/api/statistics/quantification"
|
|
"gin_server_admin/commonus"
|
|
"gin_server_admin/global"
|
|
"gin_server_admin/model/assessmentmodel"
|
|
"gin_server_admin/model/common/response"
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
// 获取有效版本考核
|
|
func (a *ApiGroup) GetPlanVersionValides(c *gin.Context) {
|
|
isTrue, userCont := commonus.ClientIdentity()
|
|
if isTrue != true {
|
|
response.Result(1001, isTrue, "您的身份令牌已经失效!请重新登录获取身份令牌!", c)
|
|
return
|
|
}
|
|
var requestData DutyPlanVersio
|
|
c.ShouldBindJSON(&requestData)
|
|
if requestData.Year == "" {
|
|
requestData.Year = commonus.TimeStampToDate(time.Now().Unix(), 11)
|
|
}
|
|
var planVersioCont []assessmentmodel.PlanVersio
|
|
gormDb := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.PlanVersio{}).Where("`state` = 1")
|
|
switch userCont.IsAdmin {
|
|
case "2":
|
|
if requestData.DeaprtId != "" {
|
|
gormDb = gormDb.Where("`department` = ? ", userCont.Deparment)
|
|
}
|
|
gormDb = gormDb.Where("`group` = ? ", userCont.Company)
|
|
case "3":
|
|
if requestData.Group != "" {
|
|
gormDb = gormDb.Where("`group` = ? ", requestData.Group)
|
|
}
|
|
if requestData.DeaprtId != "" {
|
|
gormDb = gormDb.Where("`department` = ? ", requestData.DeaprtId)
|
|
}
|
|
case "4":
|
|
if requestData.Group != "" {
|
|
gormDb = gormDb.Where("`group` = ? ", requestData.Group)
|
|
}
|
|
if requestData.DeaprtId != "" {
|
|
gormDb = gormDb.Where("`department` = ? ", requestData.DeaprtId)
|
|
}
|
|
default:
|
|
// gormDb = gormDb.Where("`group` = ? AND `department` = ?", userCont.Company, userCont.Deparment)
|
|
}
|
|
err := gormDb.Find(&planVersioCont).Error
|
|
if err != nil {
|
|
response.Result(102, err, "没有查询到数据", c)
|
|
return
|
|
}
|
|
yserInt, _ := strconv.ParseInt(requestData.Year, 10, 64)
|
|
var outData []TargetContOutCont
|
|
for _, v := range planVersioCont { //版本列表
|
|
|
|
if v.Content != "" {
|
|
var planInfo []AddDutyNewCont
|
|
jsonErr := json.Unmarshal([]byte(v.Content), &planInfo)
|
|
if jsonErr == nil {
|
|
for _, pv := range planInfo { //维度列表
|
|
|
|
for _, pcv := range pv.Child { //指标列表
|
|
if pcv.Status != 2 {
|
|
var outCont TargetContOutCont
|
|
outCont.Id = strconv.FormatInt(v.Id, 10)
|
|
//集团信息
|
|
outCont.Group = strconv.FormatInt(v.Group, 10)
|
|
where := commonus.MapOut()
|
|
where["id"] = v.Group
|
|
orgCont, _ := commonus.GetNewOrgCont(where, "id", "name")
|
|
outCont.GroupName = orgCont.Name
|
|
//接受考核部门
|
|
outCont.DepartmentId = strconv.FormatInt(v.Department, 10)
|
|
whereDepart := commonus.MapOut()
|
|
whereDepart["id"] = v.Department
|
|
orgContDer, _ := commonus.GetNewOrgCont(whereDepart, "id", "name")
|
|
outCont.DepartmentName = orgContDer.Name
|
|
//维度信息
|
|
outCont.Dimension = pv.Id
|
|
outCont.DimensionName = pv.Name
|
|
outCont.DimensionWeight = int64(pv.ZhiFraction)
|
|
//指标信息
|
|
outCont.Target = pcv.Id
|
|
outCont.TargetName = pcv.Name
|
|
outCont.TargetCont = pcv.Content
|
|
outCont.TargetWeight = pcv.ReferenceScore
|
|
outCont.Unit = pcv.Unit
|
|
//获取指标内容
|
|
var evalTargerCont assessmentmodel.EvaluationTarget
|
|
evalErr := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.EvaluationTarget{}).Select("et_type,et_scoring_method").Where("`et_id` = ?", pcv.Id).First(&evalTargerCont).Error
|
|
scoringMethod := 1
|
|
if evalErr == nil {
|
|
outCont.Type = evalTargerCont.Type
|
|
scoringMethod = evalTargerCont.ScoringMethod
|
|
}
|
|
/*
|
|
@key 方案版本号
|
|
@dimeId 维度
|
|
@targetId 指标
|
|
@accDepartId 接收考核的部门
|
|
|
|
outPut
|
|
|
|
@qualId //方案ID
|
|
@departId 执行部门ID
|
|
@departName 执行部门名称
|
|
@cycle 1:班;2:天;3:周;4:月;5:季度;6:年
|
|
@cycleattr 辅助计数
|
|
@isDuty 1:定性考核;2:定量考核
|
|
*/
|
|
|
|
taskId, _, departName, cycle, cycleattr, isDuty, isDutyErr := getDepartTarget(v.Key, pv.Id, pcv.Id, strconv.FormatInt(v.Group, 10), strconv.FormatInt(v.Department, 10))
|
|
if isDutyErr == nil {
|
|
outCont.ExecutiveDepartment = departName
|
|
outCont.Cycles = cycle
|
|
outCont.CycleAttres = cycleattr
|
|
if isDuty != 0 {
|
|
outCont.Type = isDuty
|
|
}
|
|
} else {
|
|
isDuty = 2
|
|
}
|
|
|
|
var stccStatistics ScoreListAry
|
|
stccStatistics.Class = isDuty
|
|
// panic(departName)
|
|
if isDuty == 1 {
|
|
//定性考核
|
|
switch cycle {
|
|
case 1:
|
|
case 2: //天
|
|
allYearDays := 365
|
|
if commonus.IsLeapYear(yserInt) == true {
|
|
allYearDays = 366
|
|
}
|
|
for i := 1; i <= allYearDays; i++ {
|
|
if pcv.Status != 3 {
|
|
wherStr := fmt.Sprintf("`sf_evaluation_plan` = %v AND `sf_duty_group` = %v AND `sf_duty_department` = %v AND `sf_year` = %v AND `sf_week` = %v", taskId, v.Group, v.Department, yserInt, i)
|
|
|
|
resultDatayuan, _, departnameAry := SubjectiveAuxiliaryCalculationSumMethod(wherStr)
|
|
resultData := commonus.Decimal(resultDatayuan / 100)
|
|
if resultData > float64(pcv.ReferenceScore) {
|
|
resultData = float64(pcv.ReferenceScore)
|
|
}
|
|
if len(departnameAry) > 0 {
|
|
for _, dav := range departnameAry {
|
|
if commonus.IsItTrueString(dav, outCont.ExecutiveDepartment) == false {
|
|
outCont.ExecutiveDepartment = append(outCont.ExecutiveDepartment, dav)
|
|
}
|
|
}
|
|
// outCont.ExecutiveDepartment = departnameAry
|
|
}
|
|
var jiSuanZhi ScoreList
|
|
jiSuanZhi.Class = 1
|
|
jiSuanZhi.AllPrize = 0
|
|
jiSuanZhi.ZeroPrize = 0
|
|
jiSuanZhi.CappingVal = 0
|
|
jiSuanZhi.ScoreVal = 0
|
|
jiSuanZhi.Achievement = 0
|
|
jiSuanZhi.ActualScore = resultData
|
|
outCont.Score = append(outCont.Score, jiSuanZhi)
|
|
stccStatistics.ScoreVal = append(stccStatistics.ScoreVal, 0)
|
|
stccStatistics.AllPrize = append(stccStatistics.AllPrize, 0)
|
|
stccStatistics.ZeroPrize = append(stccStatistics.ZeroPrize, 0)
|
|
stccStatistics.CappingVal = append(stccStatistics.CappingVal, 0)
|
|
stccStatistics.ActualScore = append(stccStatistics.ActualScore, resultData)
|
|
stccStatistics.Achievement = append(stccStatistics.Achievement, 0)
|
|
} else {
|
|
var jiSuanZhi ScoreList
|
|
jiSuanZhi.Class = 1
|
|
jiSuanZhi.AllPrize = 0
|
|
jiSuanZhi.ZeroPrize = 0
|
|
jiSuanZhi.CappingVal = 0
|
|
jiSuanZhi.ScoreVal = 0
|
|
jiSuanZhi.Achievement = 0
|
|
jiSuanZhi.ActualScore = float64(pcv.ReferenceScore)
|
|
outCont.Score = append(outCont.Score, jiSuanZhi)
|
|
stccStatistics.ScoreVal = append(stccStatistics.ScoreVal, 0)
|
|
stccStatistics.AllPrize = append(stccStatistics.AllPrize, 0)
|
|
stccStatistics.ZeroPrize = append(stccStatistics.ZeroPrize, 0)
|
|
stccStatistics.CappingVal = append(stccStatistics.CappingVal, 0)
|
|
stccStatistics.ActualScore = append(stccStatistics.ActualScore, float64(pcv.ReferenceScore))
|
|
stccStatistics.Achievement = append(stccStatistics.Achievement, 0)
|
|
}
|
|
}
|
|
case 3:
|
|
case 5: //季度
|
|
for i := 1; i <= 4; i++ {
|
|
if pcv.Status != 3 {
|
|
wherStr := fmt.Sprintf("`sf_evaluation_plan` = %v AND `sf_duty_group` = %v AND `sf_duty_department` = %v AND `sf_year` = %v AND `sf_quarter` = %v", taskId, v.Group, v.Department, yserInt, i)
|
|
resultDatayuan, _, departnameAry := SubjectiveAuxiliaryCalculationSumMethod(wherStr)
|
|
if len(departnameAry) > 0 {
|
|
for _, dav := range departnameAry {
|
|
if commonus.IsItTrueString(dav, outCont.ExecutiveDepartment) == false {
|
|
outCont.ExecutiveDepartment = append(outCont.ExecutiveDepartment, dav)
|
|
}
|
|
}
|
|
}
|
|
resultData := commonus.Decimal(resultDatayuan / 100)
|
|
if resultData > float64(pcv.ReferenceScore) {
|
|
resultData = float64(pcv.ReferenceScore)
|
|
}
|
|
var jiSuanZhi ScoreList
|
|
jiSuanZhi.Class = 1
|
|
jiSuanZhi.AllPrize = 0
|
|
jiSuanZhi.ZeroPrize = 0
|
|
jiSuanZhi.CappingVal = 0
|
|
jiSuanZhi.ScoreVal = 0
|
|
jiSuanZhi.Achievement = 0
|
|
jiSuanZhi.ActualScore = resultData
|
|
outCont.Score = append(outCont.Score, jiSuanZhi)
|
|
stccStatistics.ScoreVal = append(stccStatistics.ScoreVal, 0)
|
|
stccStatistics.AllPrize = append(stccStatistics.AllPrize, 0)
|
|
stccStatistics.ZeroPrize = append(stccStatistics.ZeroPrize, 0)
|
|
stccStatistics.CappingVal = append(stccStatistics.CappingVal, 0)
|
|
stccStatistics.ActualScore = append(stccStatistics.ActualScore, resultData)
|
|
stccStatistics.Achievement = append(stccStatistics.Achievement, 0)
|
|
} else {
|
|
var jiSuanZhi ScoreList
|
|
jiSuanZhi.Class = 1
|
|
jiSuanZhi.AllPrize = 0
|
|
jiSuanZhi.ZeroPrize = 0
|
|
jiSuanZhi.CappingVal = 0
|
|
jiSuanZhi.ScoreVal = 0
|
|
jiSuanZhi.Achievement = 0
|
|
jiSuanZhi.ActualScore = float64(pcv.ReferenceScore)
|
|
outCont.Score = append(outCont.Score, jiSuanZhi)
|
|
stccStatistics.ScoreVal = append(stccStatistics.ScoreVal, 0)
|
|
stccStatistics.AllPrize = append(stccStatistics.AllPrize, 0)
|
|
stccStatistics.ZeroPrize = append(stccStatistics.ZeroPrize, 0)
|
|
stccStatistics.CappingVal = append(stccStatistics.CappingVal, 0)
|
|
stccStatistics.ActualScore = append(stccStatistics.ActualScore, float64(pcv.ReferenceScore))
|
|
stccStatistics.Achievement = append(stccStatistics.Achievement, 0)
|
|
}
|
|
}
|
|
case 6: //年
|
|
if pcv.Status != 3 {
|
|
wherStr := fmt.Sprintf("`sf_evaluation_plan` = %v AND `sf_duty_group` = %v AND `sf_duty_department` = %v AND `sf_year` = %v", taskId, v.Group, v.Department, yserInt)
|
|
resultDatayuan, _, departnameAry := SubjectiveAuxiliaryCalculationSumMethod(wherStr)
|
|
if len(departnameAry) > 0 {
|
|
for _, dav := range departnameAry {
|
|
if commonus.IsItTrueString(dav, outCont.ExecutiveDepartment) == false {
|
|
outCont.ExecutiveDepartment = append(outCont.ExecutiveDepartment, dav)
|
|
}
|
|
}
|
|
}
|
|
resultData := commonus.Decimal(resultDatayuan / 100)
|
|
if resultData > float64(pcv.ReferenceScore) {
|
|
resultData = float64(pcv.ReferenceScore)
|
|
}
|
|
var jiSuanZhi ScoreList
|
|
jiSuanZhi.Class = 1
|
|
jiSuanZhi.AllPrize = 0
|
|
jiSuanZhi.ZeroPrize = 0
|
|
jiSuanZhi.CappingVal = 0
|
|
jiSuanZhi.ScoreVal = 0
|
|
jiSuanZhi.ActualScore = resultData
|
|
jiSuanZhi.Achievement = 0
|
|
outCont.Score = append(outCont.Score, jiSuanZhi)
|
|
|
|
stccStatistics.ScoreVal = append(stccStatistics.ScoreVal, 0)
|
|
stccStatistics.AllPrize = append(stccStatistics.AllPrize, 0)
|
|
stccStatistics.ZeroPrize = append(stccStatistics.ZeroPrize, 0)
|
|
stccStatistics.CappingVal = append(stccStatistics.CappingVal, 0)
|
|
stccStatistics.ActualScore = append(stccStatistics.ActualScore, resultData)
|
|
stccStatistics.Achievement = append(stccStatistics.Achievement, 0)
|
|
} else {
|
|
var jiSuanZhi ScoreList
|
|
jiSuanZhi.Class = 1
|
|
jiSuanZhi.AllPrize = 0
|
|
jiSuanZhi.ZeroPrize = 0
|
|
jiSuanZhi.CappingVal = 0
|
|
jiSuanZhi.ScoreVal = 0
|
|
jiSuanZhi.Achievement = 0
|
|
jiSuanZhi.ActualScore = float64(pcv.ReferenceScore)
|
|
outCont.Score = append(outCont.Score, jiSuanZhi)
|
|
|
|
stccStatistics.ScoreVal = append(stccStatistics.ScoreVal, 0)
|
|
stccStatistics.AllPrize = append(stccStatistics.AllPrize, 0)
|
|
stccStatistics.ZeroPrize = append(stccStatistics.ZeroPrize, 0)
|
|
stccStatistics.CappingVal = append(stccStatistics.CappingVal, 0)
|
|
stccStatistics.ActualScore = append(stccStatistics.ActualScore, float64(pcv.ReferenceScore))
|
|
stccStatistics.Achievement = append(stccStatistics.Achievement, 0)
|
|
}
|
|
default: //月
|
|
monthValue := commonus.TimeStampToDate(time.Now().Unix(), 12)
|
|
if commonus.TimeStampToDate(time.Now().Unix(), 11) != requestData.Year {
|
|
monthValue = "12"
|
|
}
|
|
monthValueInt, _ := strconv.Atoi(monthValue)
|
|
for i := 1; i <= monthValueInt; i++ {
|
|
if pcv.Status != 3 {
|
|
wherStr := fmt.Sprintf("`sf_evaluation_plan` = %v AND `sf_duty_group` = %v AND `sf_duty_department` = %v AND `sf_year` = %v AND `sf_month` = %v", taskId, v.Group, v.Department, yserInt, i)
|
|
resultDatayuan, _, departnameAry := SubjectiveAuxiliaryCalculationSumMethod(wherStr)
|
|
if len(departnameAry) > 0 {
|
|
for _, dav := range departnameAry {
|
|
if commonus.IsItTrueString(dav, outCont.ExecutiveDepartment) == false {
|
|
outCont.ExecutiveDepartment = append(outCont.ExecutiveDepartment, dav)
|
|
}
|
|
}
|
|
}
|
|
resultData := commonus.Decimal(resultDatayuan / 100)
|
|
if resultData > float64(pcv.ReferenceScore) {
|
|
resultData = float64(pcv.ReferenceScore)
|
|
}
|
|
var jiSuanZhi ScoreList
|
|
jiSuanZhi.Class = 1
|
|
jiSuanZhi.AllPrize = 0
|
|
jiSuanZhi.ZeroPrize = 0
|
|
jiSuanZhi.CappingVal = 0
|
|
jiSuanZhi.ScoreVal = 0
|
|
jiSuanZhi.ActualScore = resultData
|
|
jiSuanZhi.Achievement = 0
|
|
outCont.Score = append(outCont.Score, jiSuanZhi)
|
|
|
|
stccStatistics.ScoreVal = append(stccStatistics.ScoreVal, 0)
|
|
stccStatistics.AllPrize = append(stccStatistics.AllPrize, 0)
|
|
stccStatistics.ZeroPrize = append(stccStatistics.ZeroPrize, 0)
|
|
stccStatistics.CappingVal = append(stccStatistics.CappingVal, 0)
|
|
stccStatistics.ActualScore = append(stccStatistics.ActualScore, resultData)
|
|
stccStatistics.Achievement = append(stccStatistics.Achievement, 0)
|
|
} else {
|
|
var jiSuanZhi ScoreList
|
|
jiSuanZhi.Class = 1
|
|
jiSuanZhi.AllPrize = 0
|
|
jiSuanZhi.ZeroPrize = 0
|
|
jiSuanZhi.CappingVal = 0
|
|
jiSuanZhi.ScoreVal = 0
|
|
jiSuanZhi.Achievement = 0
|
|
jiSuanZhi.ActualScore = float64(pcv.ReferenceScore)
|
|
outCont.Score = append(outCont.Score, jiSuanZhi)
|
|
stccStatistics.ScoreVal = append(stccStatistics.ScoreVal, 0)
|
|
stccStatistics.AllPrize = append(stccStatistics.AllPrize, 0)
|
|
stccStatistics.ZeroPrize = append(stccStatistics.ZeroPrize, 0)
|
|
stccStatistics.CappingVal = append(stccStatistics.CappingVal, 0)
|
|
stccStatistics.ActualScore = append(stccStatistics.ActualScore, float64(pcv.ReferenceScore))
|
|
stccStatistics.Achievement = append(stccStatistics.Achievement, 0)
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
//定量考核
|
|
switch cycle {
|
|
case 1:
|
|
case 2: //天
|
|
allYearDays := 365
|
|
if commonus.IsLeapYear(yserInt) == true {
|
|
allYearDays = 366
|
|
}
|
|
for i := 1; i <= allYearDays; i++ {
|
|
|
|
wherStr := fmt.Sprintf("fld_evaluation_id = %v AND `fl_year` = %v AND `fl_duty_group` = %v AND `fl_duty_department` = %v AND `fl_day` = %v", taskId, yserInt, v.Group, v.Department, i)
|
|
resultDatayuan, _, departnameAry := AuxiliaryCalculationSumMethod(wherStr, scoringMethod)
|
|
if len(departnameAry) > 0 {
|
|
for _, dav := range departnameAry {
|
|
if commonus.IsItTrueString(dav, outCont.ExecutiveDepartment) == false {
|
|
outCont.ExecutiveDepartment = append(outCont.ExecutiveDepartment, dav)
|
|
}
|
|
}
|
|
}
|
|
|
|
// resultData := commonus.Decimal(AuxiliaryCalculationSumMethod(wherStr, scoringMethod) / 100)
|
|
resultData := commonus.Decimal(resultDatayuan / 100)
|
|
if pcv.Status != 3 {
|
|
var jiSuanZhi ScoreList
|
|
jiSuanZhi.Class = 2
|
|
jiSuanZhi.ScoreVal = resultData
|
|
jiSuanZhi.ActualScore, jiSuanZhi.AllPrize, jiSuanZhi.ZeroPrize, jiSuanZhi.CappingVal, jiSuanZhi.Achievement = quantification.GetQuantitativeConfig(pcv.ReferenceScore, resultData, strconv.FormatInt(v.Group, 10), strconv.FormatInt(v.Department, 10), pv.Id, pcv.Id, "0", yserInt, i, 2)
|
|
outCont.Score = append(outCont.Score, jiSuanZhi)
|
|
|
|
stccStatistics.ScoreVal = append(stccStatistics.ScoreVal, resultData)
|
|
stccStatistics.AllPrize = append(stccStatistics.AllPrize, jiSuanZhi.AllPrize)
|
|
stccStatistics.ZeroPrize = append(stccStatistics.ZeroPrize, jiSuanZhi.ZeroPrize)
|
|
stccStatistics.CappingVal = append(stccStatistics.CappingVal, jiSuanZhi.CappingVal)
|
|
stccStatistics.ActualScore = append(stccStatistics.ActualScore, jiSuanZhi.ActualScore)
|
|
stccStatistics.Achievement = append(stccStatistics.Achievement, jiSuanZhi.Achievement)
|
|
// if scoringMethod != 2 {
|
|
// var jiSuanZhi ScoreList
|
|
// jiSuanZhi.ScoreVal = resultData
|
|
// jiSuanZhi.ActualScore, jiSuanZhi.AllPrize, jiSuanZhi.ZeroPrize, jiSuanZhi.CappingVal = quantification.GetQuantitativeConfig(pcv.ReferenceScore, resultData, strconv.FormatInt(v.Group, 10), strconv.FormatInt(v.Department, 10), pv.Id, pcv.Id, "0", yserInt, i)
|
|
// outCont.Score = append(outCont.Score, jiSuanZhi)
|
|
// } else {
|
|
// var jiSuanZhi ScoreList
|
|
// jiSuanZhi.ScoreVal = resultData
|
|
// jiSuanZhi.ActualScore = float64(pcv.ReferenceScore)
|
|
// jiSuanZhi.AllPrize, jiSuanZhi.ZeroPrize, jiSuanZhi.CappingVal = quantification.GetQuantitativeConfigEs(strconv.FormatInt(v.Group, 10), strconv.FormatInt(v.Department, 10), pv.Id, pcv.Id, "0", yserInt, i)
|
|
// outCont.Score = append(outCont.Score, jiSuanZhi)
|
|
// }
|
|
} else {
|
|
var jiSuanZhi ScoreList
|
|
jiSuanZhi.Class = 2
|
|
jiSuanZhi.ScoreVal = resultData
|
|
jiSuanZhi.ActualScore = float64(pcv.ReferenceScore)
|
|
jiSuanZhi.ScoreVal, jiSuanZhi.AllPrize, jiSuanZhi.ZeroPrize, jiSuanZhi.CappingVal, jiSuanZhi.Achievement = quantification.GetQuantitativeConfigEs(pcv.ReferenceScore, resultData, strconv.FormatInt(v.Group, 10), strconv.FormatInt(v.Department, 10), pv.Id, pcv.Id, "0", yserInt, i, 2)
|
|
outCont.Score = append(outCont.Score, jiSuanZhi)
|
|
|
|
stccStatistics.ScoreVal = append(stccStatistics.ScoreVal, resultData)
|
|
stccStatistics.AllPrize = append(stccStatistics.AllPrize, jiSuanZhi.AllPrize)
|
|
stccStatistics.ZeroPrize = append(stccStatistics.ZeroPrize, jiSuanZhi.ZeroPrize)
|
|
stccStatistics.CappingVal = append(stccStatistics.CappingVal, jiSuanZhi.CappingVal)
|
|
stccStatistics.ActualScore = append(stccStatistics.ActualScore, jiSuanZhi.ActualScore)
|
|
stccStatistics.Achievement = append(stccStatistics.Achievement, jiSuanZhi.Achievement)
|
|
}
|
|
}
|
|
case 3:
|
|
case 5: //季度
|
|
for i := 1; i <= 4; i++ {
|
|
wherStr := fmt.Sprintf("fld_evaluation_id = %v AND `fl_year` = %v AND `fl_duty_group` = %v AND `fl_duty_department` = %v AND `fl_quarter` = %v", taskId, yserInt, v.Group, v.Department, i)
|
|
|
|
resultDatayuan, _, departnameAry := AuxiliaryCalculationSumMethod(wherStr, scoringMethod)
|
|
if len(departnameAry) > 0 {
|
|
for _, dav := range departnameAry {
|
|
if commonus.IsItTrueString(dav, outCont.ExecutiveDepartment) == false {
|
|
outCont.ExecutiveDepartment = append(outCont.ExecutiveDepartment, dav)
|
|
}
|
|
}
|
|
}
|
|
resultData := commonus.Decimal(resultDatayuan / 100)
|
|
if pcv.Status != 3 {
|
|
var jiSuanZhi ScoreList
|
|
jiSuanZhi.Class = 2
|
|
jiSuanZhi.ScoreVal = resultData
|
|
jiSuanZhi.ActualScore, jiSuanZhi.AllPrize, jiSuanZhi.ZeroPrize, jiSuanZhi.CappingVal, jiSuanZhi.Achievement = quantification.GetQuantitativeConfig(pcv.ReferenceScore, resultData, strconv.FormatInt(v.Group, 10), strconv.FormatInt(v.Department, 10), pv.Id, pcv.Id, "0", yserInt, i, 2)
|
|
outCont.Score = append(outCont.Score, jiSuanZhi)
|
|
stccStatistics.ScoreVal = append(stccStatistics.ScoreVal, resultData)
|
|
stccStatistics.AllPrize = append(stccStatistics.AllPrize, jiSuanZhi.AllPrize)
|
|
stccStatistics.ZeroPrize = append(stccStatistics.ZeroPrize, jiSuanZhi.ZeroPrize)
|
|
stccStatistics.CappingVal = append(stccStatistics.CappingVal, jiSuanZhi.CappingVal)
|
|
stccStatistics.ActualScore = append(stccStatistics.ActualScore, jiSuanZhi.ActualScore)
|
|
stccStatistics.Achievement = append(stccStatistics.Achievement, jiSuanZhi.Achievement)
|
|
// if scoringMethod != 2 {
|
|
// var jiSuanZhi ScoreList
|
|
// jiSuanZhi.ScoreVal = resultData
|
|
// jiSuanZhi.ActualScore, jiSuanZhi.AllPrize, jiSuanZhi.ZeroPrize, jiSuanZhi.CappingVal = quantification.GetQuantitativeConfig(pcv.ReferenceScore, resultData, strconv.FormatInt(v.Group, 10), strconv.FormatInt(v.Department, 10), pv.Id, pcv.Id, "0", yserInt, i)
|
|
// outCont.Score = append(outCont.Score, jiSuanZhi)
|
|
// } else {
|
|
// var jiSuanZhi ScoreList
|
|
// jiSuanZhi.ScoreVal = resultData
|
|
// jiSuanZhi.ActualScore = float64(pcv.ReferenceScore)
|
|
// jiSuanZhi.AllPrize, jiSuanZhi.ZeroPrize, jiSuanZhi.CappingVal = quantification.GetQuantitativeConfigEs(strconv.FormatInt(v.Group, 10), strconv.FormatInt(v.Department, 10), pv.Id, pcv.Id, "0", yserInt, i)
|
|
// outCont.Score = append(outCont.Score, jiSuanZhi)
|
|
// }
|
|
} else {
|
|
var jiSuanZhi ScoreList
|
|
jiSuanZhi.Class = 2
|
|
jiSuanZhi.ScoreVal = resultData
|
|
jiSuanZhi.ActualScore = float64(pcv.ReferenceScore)
|
|
jiSuanZhi.ScoreVal, jiSuanZhi.AllPrize, jiSuanZhi.ZeroPrize, jiSuanZhi.CappingVal, jiSuanZhi.Achievement = quantification.GetQuantitativeConfigEs(pcv.ReferenceScore, resultData, strconv.FormatInt(v.Group, 10), strconv.FormatInt(v.Department, 10), pv.Id, pcv.Id, "0", yserInt, i, 2)
|
|
outCont.Score = append(outCont.Score, jiSuanZhi)
|
|
stccStatistics.ScoreVal = append(stccStatistics.ScoreVal, resultData)
|
|
stccStatistics.AllPrize = append(stccStatistics.AllPrize, jiSuanZhi.AllPrize)
|
|
stccStatistics.ZeroPrize = append(stccStatistics.ZeroPrize, jiSuanZhi.ZeroPrize)
|
|
stccStatistics.CappingVal = append(stccStatistics.CappingVal, jiSuanZhi.CappingVal)
|
|
stccStatistics.ActualScore = append(stccStatistics.ActualScore, jiSuanZhi.ActualScore)
|
|
stccStatistics.Achievement = append(stccStatistics.Achievement, jiSuanZhi.Achievement)
|
|
}
|
|
}
|
|
case 6: //年
|
|
|
|
wherStr := fmt.Sprintf("fld_evaluation_id = %v AND `fl_year` = %v AND `fl_duty_group` = %v AND `fl_duty_department` = %v ", taskId, yserInt, v.Group, v.Department)
|
|
resultDatayuan, _, departnameAry := AuxiliaryCalculationSumMethod(wherStr, scoringMethod)
|
|
if len(departnameAry) > 0 {
|
|
for _, dav := range departnameAry {
|
|
if commonus.IsItTrueString(dav, outCont.ExecutiveDepartment) == false {
|
|
outCont.ExecutiveDepartment = append(outCont.ExecutiveDepartment, dav)
|
|
}
|
|
}
|
|
}
|
|
resultData := commonus.Decimal(resultDatayuan / 100)
|
|
if pcv.Status != 3 {
|
|
var jiSuanZhi ScoreList
|
|
jiSuanZhi.Class = 2
|
|
jiSuanZhi.ScoreVal = resultData
|
|
jiSuanZhi.ActualScore, jiSuanZhi.AllPrize, jiSuanZhi.ZeroPrize, jiSuanZhi.CappingVal, jiSuanZhi.Achievement = quantification.GetQuantitativeConfig(pcv.ReferenceScore, resultData, strconv.FormatInt(v.Group, 10), strconv.FormatInt(v.Department, 10), pv.Id, pcv.Id, "0", yserInt, 0, 2)
|
|
outCont.Score = append(outCont.Score, jiSuanZhi)
|
|
|
|
stccStatistics.ScoreVal = append(stccStatistics.ScoreVal, resultData)
|
|
stccStatistics.AllPrize = append(stccStatistics.AllPrize, jiSuanZhi.AllPrize)
|
|
stccStatistics.ZeroPrize = append(stccStatistics.ZeroPrize, jiSuanZhi.ZeroPrize)
|
|
stccStatistics.CappingVal = append(stccStatistics.CappingVal, jiSuanZhi.CappingVal)
|
|
stccStatistics.ActualScore = append(stccStatistics.ActualScore, jiSuanZhi.ActualScore)
|
|
stccStatistics.Achievement = append(stccStatistics.Achievement, jiSuanZhi.Achievement)
|
|
// if scoringMethod != 2 {
|
|
// // outCont.Score = append(outCont.Score, quantification.GetQuantitativeConfig(resultData, strconv.FormatInt(v.Group, 10), strconv.FormatInt(v.Department, 10), pv.Id, pcv.Id, "0", yserInt, 0))
|
|
|
|
// var jiSuanZhi ScoreList
|
|
// jiSuanZhi.ScoreVal = resultData
|
|
// jiSuanZhi.ActualScore, jiSuanZhi.AllPrize, jiSuanZhi.ZeroPrize, jiSuanZhi.CappingVal = quantification.GetQuantitativeConfig(pcv.ReferenceScore, resultData, strconv.FormatInt(v.Group, 10), strconv.FormatInt(v.Department, 10), pv.Id, pcv.Id, "0", yserInt, 0)
|
|
// outCont.Score = append(outCont.Score, jiSuanZhi)
|
|
|
|
// } else {
|
|
// // outCont.Score = append(outCont.Score, resultData)
|
|
// var jiSuanZhi ScoreList
|
|
// jiSuanZhi.ScoreVal = resultData
|
|
// jiSuanZhi.ActualScore = float64(pcv.ReferenceScore)
|
|
// jiSuanZhi.AllPrize, jiSuanZhi.ZeroPrize, jiSuanZhi.CappingVal = quantification.GetQuantitativeConfigEs(strconv.FormatInt(v.Group, 10), strconv.FormatInt(v.Department, 10), pv.Id, pcv.Id, "0", yserInt, 0)
|
|
// outCont.Score = append(outCont.Score, jiSuanZhi)
|
|
// }
|
|
} else {
|
|
var jiSuanZhi ScoreList
|
|
jiSuanZhi.Class = 2
|
|
jiSuanZhi.ScoreVal = resultData
|
|
jiSuanZhi.ActualScore = float64(pcv.ReferenceScore)
|
|
jiSuanZhi.ScoreVal, jiSuanZhi.AllPrize, jiSuanZhi.ZeroPrize, jiSuanZhi.CappingVal, jiSuanZhi.Achievement = quantification.GetQuantitativeConfigEs(pcv.ReferenceScore, resultData, strconv.FormatInt(v.Group, 10), strconv.FormatInt(v.Department, 10), pv.Id, pcv.Id, "0", yserInt, 0, 2)
|
|
outCont.Score = append(outCont.Score, jiSuanZhi)
|
|
|
|
stccStatistics.ScoreVal = append(stccStatistics.ScoreVal, resultData)
|
|
stccStatistics.AllPrize = append(stccStatistics.AllPrize, jiSuanZhi.AllPrize)
|
|
stccStatistics.ZeroPrize = append(stccStatistics.ZeroPrize, jiSuanZhi.ZeroPrize)
|
|
stccStatistics.CappingVal = append(stccStatistics.CappingVal, jiSuanZhi.CappingVal)
|
|
stccStatistics.ActualScore = append(stccStatistics.ActualScore, jiSuanZhi.ActualScore)
|
|
stccStatistics.Achievement = append(stccStatistics.Achievement, jiSuanZhi.Achievement)
|
|
}
|
|
default: //月
|
|
monthValue := commonus.TimeStampToDate(time.Now().Unix(), 12)
|
|
if commonus.TimeStampToDate(time.Now().Unix(), 11) != requestData.Year {
|
|
monthValue = "12"
|
|
}
|
|
monthValueInt, _ := strconv.Atoi(monthValue)
|
|
for i := 1; i <= monthValueInt; i++ {
|
|
|
|
wherStr := fmt.Sprintf("fld_evaluation_id = %v AND `fl_year` = %v AND `fl_duty_group` = %v AND `fl_duty_department` = %v AND `fl_month` = %v", taskId, yserInt, v.Group, v.Department, i)
|
|
resultDatayuan, _, departnameAry := AuxiliaryCalculationSumMethod(wherStr, scoringMethod)
|
|
if len(departnameAry) > 0 {
|
|
for _, dav := range departnameAry {
|
|
if commonus.IsItTrueString(dav, outCont.ExecutiveDepartment) == false {
|
|
outCont.ExecutiveDepartment = append(outCont.ExecutiveDepartment, dav)
|
|
}
|
|
}
|
|
}
|
|
// fmt.Printf("wherStr:%v------------>%v\n", wherStr, departnameAry)
|
|
// panic(departnameAry)
|
|
resultData := commonus.Decimal(resultDatayuan / 100)
|
|
if pcv.Status != 3 {
|
|
var jiSuanZhi ScoreList
|
|
jiSuanZhi.Class = 2
|
|
jiSuanZhi.ScoreVal = resultData
|
|
jiSuanZhi.ActualScore, jiSuanZhi.AllPrize, jiSuanZhi.ZeroPrize, jiSuanZhi.CappingVal, jiSuanZhi.Achievement = quantification.GetQuantitativeConfig(pcv.ReferenceScore, resultData, strconv.FormatInt(v.Group, 10), strconv.FormatInt(v.Department, 10), pv.Id, pcv.Id, "0", yserInt, i, 2)
|
|
outCont.Score = append(outCont.Score, jiSuanZhi)
|
|
|
|
stccStatistics.ScoreVal = append(stccStatistics.ScoreVal, resultData)
|
|
stccStatistics.AllPrize = append(stccStatistics.AllPrize, jiSuanZhi.AllPrize)
|
|
stccStatistics.ZeroPrize = append(stccStatistics.ZeroPrize, jiSuanZhi.ZeroPrize)
|
|
stccStatistics.CappingVal = append(stccStatistics.CappingVal, jiSuanZhi.CappingVal)
|
|
stccStatistics.ActualScore = append(stccStatistics.ActualScore, jiSuanZhi.ActualScore)
|
|
stccStatistics.Achievement = append(stccStatistics.Achievement, jiSuanZhi.Achievement)
|
|
// if scoringMethod != 2 {
|
|
// var jiSuanZhi ScoreList
|
|
// jiSuanZhi.ScoreVal = resultData
|
|
// jiSuanZhi.ActualScore, jiSuanZhi.AllPrize, jiSuanZhi.ZeroPrize, jiSuanZhi.CappingVal = quantification.GetQuantitativeConfig(pcv.ReferenceScore, resultData, strconv.FormatInt(v.Group, 10), strconv.FormatInt(v.Department, 10), pv.Id, pcv.Id, "0", yserInt, i)
|
|
// outCont.Score = append(outCont.Score, jiSuanZhi)
|
|
// } else {
|
|
// var jiSuanZhi ScoreList
|
|
// jiSuanZhi.ScoreVal = resultData
|
|
// jiSuanZhi.ActualScore = float64(pcv.ReferenceScore)
|
|
// jiSuanZhi.AllPrize, jiSuanZhi.ZeroPrize, jiSuanZhi.CappingVal = quantification.GetQuantitativeConfigEs(strconv.FormatInt(v.Group, 10), strconv.FormatInt(v.Department, 10), pv.Id, pcv.Id, "0", yserInt, i)
|
|
// outCont.Score = append(outCont.Score, jiSuanZhi)
|
|
// }
|
|
} else {
|
|
var jiSuanZhi ScoreList
|
|
jiSuanZhi.Class = 2
|
|
jiSuanZhi.ScoreVal = resultData
|
|
jiSuanZhi.ActualScore = float64(pcv.ReferenceScore)
|
|
jiSuanZhi.ScoreVal, jiSuanZhi.AllPrize, jiSuanZhi.ZeroPrize, jiSuanZhi.CappingVal, jiSuanZhi.Achievement = quantification.GetQuantitativeConfigEs(pcv.ReferenceScore, resultData, strconv.FormatInt(v.Group, 10), strconv.FormatInt(v.Department, 10), pv.Id, pcv.Id, "0", yserInt, i, 2)
|
|
outCont.Score = append(outCont.Score, jiSuanZhi)
|
|
|
|
stccStatistics.ScoreVal = append(stccStatistics.ScoreVal, resultData)
|
|
stccStatistics.AllPrize = append(stccStatistics.AllPrize, jiSuanZhi.AllPrize)
|
|
stccStatistics.ZeroPrize = append(stccStatistics.ZeroPrize, jiSuanZhi.ZeroPrize)
|
|
stccStatistics.CappingVal = append(stccStatistics.CappingVal, jiSuanZhi.CappingVal)
|
|
stccStatistics.ActualScore = append(stccStatistics.ActualScore, jiSuanZhi.ActualScore)
|
|
stccStatistics.Achievement = append(stccStatistics.Achievement, jiSuanZhi.Achievement)
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
outCont.ScoreAllList = append(outCont.ScoreAllList, stccStatistics)
|
|
outData = append(outData, outCont)
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
} else {
|
|
|
|
}
|
|
|
|
}
|
|
response.Result(0, outData, "获取成功", c)
|
|
}
|
|
|
|
// 获取总值 定量
|
|
func AuxiliaryCalculationSumMethod(where interface{}, scoringMethod int) (sumScore float64, departmentAry []int64, departNameAry []string) {
|
|
if scoringMethod == 2 {
|
|
gormDb := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.FlowLogData{}).Joins("left join flow_log as fl on fl.fl_key = flow_log_data.fld_flow_log").Where(where)
|
|
gormDb.Pluck("COALESCE(SUM(fld_scoring_score), 0) as rescore", &sumScore)
|
|
} else {
|
|
gormDb := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.FlowLogData{}).Joins("left join flow_log as fl on fl.fl_key = flow_log_data.fld_flow_log").Where(where)
|
|
gormDb.Pluck("COALESCE(SUM(fld_score), 0) as rescore", &sumScore)
|
|
}
|
|
//获取测评部门
|
|
// var departmentAry []int64
|
|
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.FlowLogData{}).Select("fl_evaluation_department").Joins("left join flow_log as fl on fl.fl_key = flow_log_data.fld_flow_log").Where(where).Find(&departmentAry)
|
|
// var departNameAry []string
|
|
if len(departmentAry) > 0 {
|
|
for _, v := range departmentAry {
|
|
whereDepart := commonus.MapOut()
|
|
whereDepart["id"] = v
|
|
orgContDer, _ := commonus.GetNewOrgCont(whereDepart, "name")
|
|
departNameAry = append(departNameAry, orgContDer.Name)
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
// 定性
|
|
func SubjectiveAuxiliaryCalculationSumMethod(where interface{}) (sumScore float64, departmentAry []int64, departNameAry []string) {
|
|
//加分
|
|
var addSumScore float64 = 0
|
|
// global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.ScoreFlow{}).Select("sf_score").Where(where).Where("sf_plus_reduce_score = 1").Pluck("COALESCE(SUM(sf_score), 0) as addrescore", &addSumScore)
|
|
var jiaFenAry []TongjiFenShu
|
|
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.ScoreFlow{}).Select("sf_score,sf_count").Where(where).Where("sf_plus_reduce_score = 1").Find(&jiaFenAry)
|
|
for _, jiav := range jiaFenAry {
|
|
addSumScore = addSumScore + (jiav.Score * jiav.Count)
|
|
}
|
|
//加分
|
|
var scoreReduction float64 = 0
|
|
// global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.ScoreFlow{}).Select("sf_score").Where(where).Where("sf_plus_reduce_score = 2").Pluck("COALESCE(SUM(sf_score), 0) as redurescore", &scoreReduction)
|
|
|
|
var jianFenAry []TongjiFenShu
|
|
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.ScoreFlow{}).Select("sf_score,sf_count").Where(where).Where("sf_plus_reduce_score = 2").Find(&jianFenAry)
|
|
for _, jianv := range jianFenAry {
|
|
scoreReduction = scoreReduction + (jianv.Score * jianv.Count)
|
|
}
|
|
|
|
if addSumScore != 0 && scoreReduction != 0 {
|
|
if addSumScore > scoreReduction {
|
|
sumScore = addSumScore - scoreReduction
|
|
} else {
|
|
sumScore = scoreReduction - addSumScore
|
|
}
|
|
} else if addSumScore != 0 {
|
|
sumScore = addSumScore
|
|
} else {
|
|
sumScore = scoreReduction
|
|
}
|
|
//获取测评部门
|
|
// var departmentAry []int64
|
|
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.ScoreFlow{}).Select("sf_evaluation_department").Where(where).Find(&departmentAry)
|
|
// var departNameAry []string
|
|
if len(departmentAry) > 0 {
|
|
for _, v := range departmentAry {
|
|
whereDepart := commonus.MapOut()
|
|
whereDepart["id"] = v
|
|
orgContDer, _ := commonus.GetNewOrgCont(whereDepart, "name")
|
|
departNameAry = append(departNameAry, orgContDer.Name)
|
|
}
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
//获取指标相应的全奖,零奖;封顶值
|
|
|