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.
1402 lines
66 KiB
1402 lines
66 KiB
package statistics
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"sort"
|
|
"strconv"
|
|
"time"
|
|
|
|
"github.com/flipped-aurora/gin-vue-admin/server/api/statistics/quantification"
|
|
"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"
|
|
"github.com/flipped-aurora/gin-vue-admin/server/model/common/response"
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
// 获取有效版本考核
|
|
func (a *ApiGroup) GetPlanVersionValid(c *gin.Context) {
|
|
isTrue, userCont := commonus.ClientIdentity()
|
|
if isTrue != true {
|
|
response.Result(1001, isTrue, "您的身份令牌已经失效!请重新登录获取身份令牌!", c)
|
|
return
|
|
}
|
|
var requestData PlanVersioMingXi
|
|
c.ShouldBindJSON(&requestData)
|
|
if requestData.Year == "" {
|
|
requestData.Year = commonus.TimeStampToDate(time.Now().Unix(), 11)
|
|
}
|
|
|
|
// fmt.Printf("年---->%v\n", requestData.Year)
|
|
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)
|
|
}
|
|
// if requestData.Group != "" {
|
|
// gormDb = gormDb.Where("`group` = ? ", requestData.Group)
|
|
// }
|
|
// if requestData.DeaprtId != "" {
|
|
// gormDb = gormDb.Where("`department` = ? ", requestData.DeaprtId)
|
|
// }
|
|
err := gormDb.Find(&planVersioCont).Error
|
|
if err != nil {
|
|
response.Result(102, err, "没有查询到数据", c)
|
|
return
|
|
}
|
|
|
|
// yserInt, _ := strconv.ParseInt(requestData.Year, 10, 64)
|
|
// var outData []TargetContOutCont
|
|
var xieCheng dataLockStatistics
|
|
for _, v := range planVersioCont { //版本列表
|
|
syncProcess.Add(1)
|
|
// go xieCheng.planVersiconProcess(v, requestData)
|
|
go xieCheng.planVersiconProcessV1(v, requestData)
|
|
// return
|
|
}
|
|
syncProcess.Wait()
|
|
readDingXingDataMap := xieCheng.readMyDayData()
|
|
// var outList []TargetContOutCont
|
|
// mapstructure.Decode(readDingXingDataMap, &outList)
|
|
response.Result(0, readDingXingDataMap, "获取成功", c)
|
|
}
|
|
|
|
func (d *dataLockStatistics) planVersiconProcess(pvInfo assessmentmodel.PlanVersio, giveData PlanVersioMingXi) {
|
|
d.mutext.Lock()
|
|
defer d.mutext.Unlock()
|
|
yserInt, _ := strconv.ParseInt(giveData.Year, 10, 64)
|
|
// fmt.Printf("年--2-->%v--->%v\n", giveData.Year, yserInt)
|
|
if pvInfo.Content != "" {
|
|
//当版本内容不为空时
|
|
var planInfo []AddDutyNewCont
|
|
jsonErr := json.Unmarshal([]byte(pvInfo.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(pvInfo.Id, 10)
|
|
//集团信息
|
|
outCont.Group = strconv.FormatInt(pvInfo.Group, 10)
|
|
where := commonus.MapOut()
|
|
where["id"] = pvInfo.Group
|
|
orgCont, _ := commonus.GetNewOrgCont(where, "id", "name")
|
|
outCont.GroupName = orgCont.Name
|
|
//接受考核部门
|
|
outCont.DepartmentId = strconv.FormatInt(pvInfo.Department, 10)
|
|
whereDepart := commonus.MapOut()
|
|
whereDepart["id"] = pvInfo.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
|
|
targetGormDb := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.EvaluationTarget{}).Select("et_type,et_scoring_method,et_title").Where("`et_id` = ?", pcv.Id)
|
|
if giveData.Title != "" {
|
|
targetGormDb = targetGormDb.Where("et_title LIKE ?", "%"+giveData.Title+"%")
|
|
}
|
|
if giveData.Class != 0 {
|
|
targetGormDb = targetGormDb.Where("et_type = ?", giveData.Class)
|
|
}
|
|
isAdd := 1
|
|
evalErr := targetGormDb.First(&evalTargerCont).Error
|
|
scoringMethod := 1
|
|
if evalErr == nil {
|
|
outCont.Type = evalTargerCont.Type
|
|
scoringMethod = evalTargerCont.ScoringMethod
|
|
isAdd = 1
|
|
} else {
|
|
isAdd = 2
|
|
}
|
|
outCont.ManualGear = scoringMethod
|
|
//获取执行部门及指标性质
|
|
_, _, departName, cycle, cycleattr, isDuty, isDutyErr := getDepartTarget(pvInfo.Key, pv.Id, pcv.Id, strconv.FormatInt(pvInfo.Group, 10), strconv.FormatInt(pvInfo.Department, 10))
|
|
if isDutyErr == nil {
|
|
outCont.ExecutiveDepartment = departName
|
|
outCont.Cycles = cycle
|
|
outCont.CycleAttres = cycleattr
|
|
if isDuty != 0 {
|
|
outCont.Type = isDuty
|
|
}
|
|
} else {
|
|
var evalTargerCont assessmentmodel.EvaluationTarget
|
|
evalErr := global.GVA_DB_Performanceappraisal.Where("`et_id` = ?", pcv.Id).First(&evalTargerCont).Error
|
|
if evalErr == nil {
|
|
outCont.Cycles = evalTargerCont.Cycles
|
|
outCont.CycleAttres = evalTargerCont.CycleAttres
|
|
}
|
|
isDuty = 2
|
|
}
|
|
// fmt.Printf("taskId--->%v--->yyyy--->%v--->departName--->%v--->cycle--->%v--->cycleattr--->%v--->isDuty--->%v--->isDutyErr--->%v\n", taskId, yyyy, departName, cycle, cycleattr, isDuty, isDutyErr)
|
|
// panic(isDutyErr)
|
|
var stccStatistics ScoreListAry
|
|
stccStatistics.Class = isDuty
|
|
if isDuty == 1 {
|
|
//定性考核
|
|
switch cycle {
|
|
case 1:
|
|
case 2: //天
|
|
case 3:
|
|
case 5: //季度
|
|
// monthValue := commonus.TimeStampToDate(time.Now().Unix(), 12)
|
|
// if commonus.TimeStampToDate(time.Now().Unix(), 11) != giveData.Year {
|
|
// monthValue = "12"
|
|
// }
|
|
// monthValueInt, _ := strconv.Atoi(monthValue)
|
|
var tpsProcess tablePlanVersionStic
|
|
for i := 1; i <= 4; i++ {
|
|
// 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, pvInfo.Group, pvInfo.Department, yserInt, i)
|
|
|
|
wherStr := fmt.Sprintf("`sf_target_id` = %v AND `sf_duty_group` = %v AND `sf_duty_department` = %v AND `sf_year` = %v AND `sf_quarter` = %v", pcv.Id, pvInfo.Group, pvInfo.Department, yserInt, i)
|
|
// 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, pvInfo.Group, pvInfo.Department, yserInt, i)
|
|
syncProcessDepartTarget.Add(1)
|
|
go tpsProcess.SubjectiveAuxiliaryCalculationSumMethod(wherStr, i, pcv.Status, 1, pcv.ReferenceScore)
|
|
}
|
|
syncProcessDepartTarget.Wait()
|
|
readStatisticsData := tpsProcess.readMyDayData()
|
|
//按照最大值排序
|
|
sort.Slice(readStatisticsData, func(i int, j int) bool {
|
|
return readStatisticsData[i].Counter < readStatisticsData[j].Counter
|
|
})
|
|
for _, rsdv := range readStatisticsData {
|
|
|
|
// for ik := 0; ik <= 1; ik++ {
|
|
// var jiSuanZhiBuLing ScoreList
|
|
// outCont.Score = append(outCont.Score, jiSuanZhiBuLing)
|
|
// 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, 0)
|
|
// stccStatistics.Achievement = append(stccStatistics.Achievement, 0)
|
|
// }
|
|
|
|
var jiSuanZhi ScoreList
|
|
jiSuanZhi.Class = rsdv.Class
|
|
jiSuanZhi.ScoreVal = rsdv.ScoreVal
|
|
jiSuanZhi.ActualScore = rsdv.ActualScore
|
|
jiSuanZhi.AllPrize = rsdv.AllPrize
|
|
jiSuanZhi.ZeroPrize = rsdv.ZeroPrize
|
|
jiSuanZhi.CappingVal = rsdv.CappingVal
|
|
jiSuanZhi.Achievement = rsdv.Achievement
|
|
|
|
outCont.Score = append(outCont.Score, jiSuanZhi)
|
|
if len(rsdv.ExecutiveDepartment) > 0 { //写入执行考核的部门
|
|
for _, edv := range rsdv.ExecutiveDepartment {
|
|
if commonus.IsItTrueString(edv, outCont.ExecutiveDepartment) == false {
|
|
outCont.ExecutiveDepartment = append(outCont.ExecutiveDepartment, edv)
|
|
}
|
|
}
|
|
}
|
|
|
|
stccStatistics.ScoreVal = append(stccStatistics.ScoreVal, rsdv.ScoreVal)
|
|
stccStatistics.AllPrize = append(stccStatistics.AllPrize, rsdv.AllPrize)
|
|
stccStatistics.ZeroPrize = append(stccStatistics.ZeroPrize, rsdv.ZeroPrize)
|
|
stccStatistics.CappingVal = append(stccStatistics.CappingVal, rsdv.CappingVal)
|
|
stccStatistics.ActualScore = append(stccStatistics.ActualScore, rsdv.ActualScore)
|
|
stccStatistics.Achievement = append(stccStatistics.Achievement, rsdv.Achievement)
|
|
}
|
|
case 6: //年
|
|
// monthValue := commonus.TimeStampToDate(time.Now().Unix(), 12)
|
|
// if commonus.TimeStampToDate(time.Now().Unix(), 11) != giveData.Year {
|
|
// monthValue = "12"
|
|
// }
|
|
// monthValueInt, _ := strconv.Atoi(monthValue)
|
|
var tpsProcess tablePlanVersionStic
|
|
// for i := 1; i <= monthValueInt; i++ {
|
|
// 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, pvInfo.Group, pvInfo.Department, yserInt, i)
|
|
// syncProcessDepartTarget.Add(1)
|
|
// go tpsProcess.SubjectiveAuxiliaryCalculationSumMethod(wherStr, i, pcv.Status, 1, pcv.ReferenceScore)
|
|
// }
|
|
wherStr := fmt.Sprintf("`sf_target_id` = %v AND `sf_duty_group` = %v AND `sf_duty_department` = %v AND `sf_year` = %v", pcv.Id, pvInfo.Group, pvInfo.Department, yserInt)
|
|
syncProcessDepartTarget.Add(1)
|
|
go tpsProcess.SubjectiveAuxiliaryCalculationSumMethod(wherStr, 1, pcv.Status, 1, pcv.ReferenceScore)
|
|
syncProcessDepartTarget.Wait()
|
|
readStatisticsData := tpsProcess.readMyDayData()
|
|
//按照最大值排序
|
|
sort.Slice(readStatisticsData, func(i int, j int) bool {
|
|
return readStatisticsData[i].Counter < readStatisticsData[j].Counter
|
|
})
|
|
for _, rsdv := range readStatisticsData {
|
|
var jiSuanZhi ScoreList
|
|
jiSuanZhi.Class = rsdv.Class
|
|
jiSuanZhi.ScoreVal = rsdv.ScoreVal
|
|
jiSuanZhi.ActualScore = rsdv.ActualScore
|
|
jiSuanZhi.AllPrize = rsdv.AllPrize
|
|
jiSuanZhi.ZeroPrize = rsdv.ZeroPrize
|
|
jiSuanZhi.CappingVal = rsdv.CappingVal
|
|
jiSuanZhi.Achievement = rsdv.Achievement
|
|
|
|
outCont.Score = append(outCont.Score, jiSuanZhi)
|
|
if len(rsdv.ExecutiveDepartment) > 0 { //写入执行考核的部门
|
|
for _, edv := range rsdv.ExecutiveDepartment {
|
|
if commonus.IsItTrueString(edv, outCont.ExecutiveDepartment) == false {
|
|
outCont.ExecutiveDepartment = append(outCont.ExecutiveDepartment, edv)
|
|
}
|
|
}
|
|
}
|
|
|
|
stccStatistics.ScoreVal = append(stccStatistics.ScoreVal, rsdv.ScoreVal)
|
|
stccStatistics.AllPrize = append(stccStatistics.AllPrize, rsdv.AllPrize)
|
|
stccStatistics.ZeroPrize = append(stccStatistics.ZeroPrize, rsdv.ZeroPrize)
|
|
stccStatistics.CappingVal = append(stccStatistics.CappingVal, rsdv.CappingVal)
|
|
stccStatistics.ActualScore = append(stccStatistics.ActualScore, rsdv.ActualScore)
|
|
stccStatistics.Achievement = append(stccStatistics.Achievement, rsdv.Achievement)
|
|
}
|
|
case 7: //半年
|
|
var tpsProcess tablePlanVersionStic
|
|
//上半年
|
|
firstHalfwherStr := fmt.Sprintf("`sf_target_id` = %v AND `sf_duty_group` = %v AND `sf_duty_department` = %v AND `sf_year` = %v AND `sf_month` IN %v", pcv.Id, pvInfo.Group, pvInfo.Department, yserInt, []int{1, 2, 3, 4, 5, 6})
|
|
syncProcessDepartTarget.Add(1)
|
|
go tpsProcess.SubjectiveAuxiliaryCalculationSumMethod(firstHalfwherStr, 1, pcv.Status, 1, pcv.ReferenceScore)
|
|
//下半年
|
|
secondHalfwherStr := fmt.Sprintf("`sf_target_id` = %v AND `sf_duty_group` = %v AND `sf_duty_department` = %v AND `sf_year` = %v AND `sf_month` IN %v", pcv.Id, pvInfo.Group, pvInfo.Department, yserInt, []int{7, 8, 9, 10, 11, 12})
|
|
syncProcessDepartTarget.Add(1)
|
|
go tpsProcess.SubjectiveAuxiliaryCalculationSumMethod(secondHalfwherStr, 2, pcv.Status, 1, pcv.ReferenceScore)
|
|
|
|
syncProcessDepartTarget.Wait()
|
|
readStatisticsData := tpsProcess.readMyDayData()
|
|
|
|
//按照最大值排序
|
|
sort.Slice(readStatisticsData, func(i int, j int) bool {
|
|
return readStatisticsData[i].Counter < readStatisticsData[j].Counter
|
|
})
|
|
for _, rsdv := range readStatisticsData {
|
|
var jiSuanZhi ScoreList
|
|
jiSuanZhi.Class = rsdv.Class
|
|
jiSuanZhi.ScoreVal = rsdv.ScoreVal
|
|
jiSuanZhi.ActualScore = rsdv.ActualScore
|
|
jiSuanZhi.AllPrize = rsdv.AllPrize
|
|
jiSuanZhi.ZeroPrize = rsdv.ZeroPrize
|
|
jiSuanZhi.CappingVal = rsdv.CappingVal
|
|
jiSuanZhi.Achievement = rsdv.Achievement
|
|
|
|
outCont.Score = append(outCont.Score, jiSuanZhi)
|
|
if len(rsdv.ExecutiveDepartment) > 0 { //写入执行考核的部门
|
|
for _, edv := range rsdv.ExecutiveDepartment {
|
|
if commonus.IsItTrueString(edv, outCont.ExecutiveDepartment) == false {
|
|
outCont.ExecutiveDepartment = append(outCont.ExecutiveDepartment, edv)
|
|
}
|
|
}
|
|
}
|
|
|
|
stccStatistics.ScoreVal = append(stccStatistics.ScoreVal, rsdv.ScoreVal)
|
|
stccStatistics.AllPrize = append(stccStatistics.AllPrize, rsdv.AllPrize)
|
|
stccStatistics.ZeroPrize = append(stccStatistics.ZeroPrize, rsdv.ZeroPrize)
|
|
stccStatistics.CappingVal = append(stccStatistics.CappingVal, rsdv.CappingVal)
|
|
stccStatistics.ActualScore = append(stccStatistics.ActualScore, rsdv.ActualScore)
|
|
stccStatistics.Achievement = append(stccStatistics.Achievement, rsdv.Achievement)
|
|
}
|
|
|
|
default: //月
|
|
monthValue := commonus.TimeStampToDate(time.Now().Unix(), 12)
|
|
if commonus.TimeStampToDate(time.Now().Unix(), 11) != giveData.Year {
|
|
monthValue = "12"
|
|
}
|
|
monthValueInt, _ := strconv.Atoi(monthValue)
|
|
var tpsProcess tablePlanVersionStic
|
|
for i := 1; i <= monthValueInt; i++ {
|
|
wherStr := fmt.Sprintf("`sf_target_id` = %v AND `sf_duty_group` = %v AND `sf_duty_department` = %v AND `sf_year` = %v AND `sf_month` = %v", pcv.Id, pvInfo.Group, pvInfo.Department, yserInt, i)
|
|
syncProcessDepartTarget.Add(1)
|
|
go tpsProcess.SubjectiveAuxiliaryCalculationSumMethod(wherStr, i, pcv.Status, 1, pcv.ReferenceScore)
|
|
}
|
|
syncProcessDepartTarget.Wait()
|
|
readStatisticsData := tpsProcess.readMyDayData()
|
|
//按照最大值排序
|
|
sort.Slice(readStatisticsData, func(i int, j int) bool {
|
|
return readStatisticsData[i].Counter < readStatisticsData[j].Counter
|
|
})
|
|
for _, rsdv := range readStatisticsData {
|
|
var jiSuanZhi ScoreList
|
|
jiSuanZhi.Class = rsdv.Class
|
|
jiSuanZhi.ScoreVal = rsdv.ScoreVal
|
|
jiSuanZhi.ActualScore = rsdv.ActualScore
|
|
jiSuanZhi.AllPrize = rsdv.AllPrize
|
|
jiSuanZhi.ZeroPrize = rsdv.ZeroPrize
|
|
jiSuanZhi.CappingVal = rsdv.CappingVal
|
|
jiSuanZhi.Achievement = rsdv.Achievement
|
|
|
|
outCont.Score = append(outCont.Score, jiSuanZhi)
|
|
if len(rsdv.ExecutiveDepartment) > 0 { //写入执行考核的部门
|
|
for _, edv := range rsdv.ExecutiveDepartment {
|
|
if commonus.IsItTrueString(edv, outCont.ExecutiveDepartment) == false {
|
|
outCont.ExecutiveDepartment = append(outCont.ExecutiveDepartment, edv)
|
|
}
|
|
}
|
|
}
|
|
|
|
stccStatistics.ScoreVal = append(stccStatistics.ScoreVal, rsdv.ScoreVal)
|
|
stccStatistics.AllPrize = append(stccStatistics.AllPrize, rsdv.AllPrize)
|
|
stccStatistics.ZeroPrize = append(stccStatistics.ZeroPrize, rsdv.ZeroPrize)
|
|
stccStatistics.CappingVal = append(stccStatistics.CappingVal, rsdv.CappingVal)
|
|
stccStatistics.ActualScore = append(stccStatistics.ActualScore, rsdv.ActualScore)
|
|
stccStatistics.Achievement = append(stccStatistics.Achievement, rsdv.Achievement)
|
|
}
|
|
}
|
|
} else {
|
|
//定量考核
|
|
switch cycle {
|
|
case 1:
|
|
case 2: //天
|
|
case 3:
|
|
case 5: //季度
|
|
// monthValue := commonus.TimeStampToDate(time.Now().Unix(), 12)
|
|
// if commonus.TimeStampToDate(time.Now().Unix(), 11) != giveData.Year {
|
|
// monthValue = "12"
|
|
// }
|
|
// monthValueInt, _ := strconv.Atoi(monthValue)
|
|
var tpsProcess tablePlanVersionStic
|
|
for i := 1; i <= 4; i++ {
|
|
|
|
// fmt.Printf("年--4-->%v--->%v-->%v\n", i, giveData.Year, yserInt)
|
|
wherStr := fmt.Sprintf("fld_target_id = %v AND `fl_year` = %v AND `fl_duty_group` = %v AND `fl_duty_department` = %v AND `fl_quarter` = %v", pcv.Id, yserInt, pvInfo.Group, pvInfo.Department, 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, pvInfo.Group, pvInfo.Department, i)
|
|
// fmt.Printf("wherStr----->%v\n", wherStr)
|
|
// return
|
|
syncProcessDepartTarget.Add(1)
|
|
go tpsProcess.conditionStatistics(wherStr, strconv.FormatInt(pvInfo.Group, 10), strconv.FormatInt(pvInfo.Department, 10), pv.Id, pcv.Id, i, pcv.Status, scoringMethod, 2, yserInt, pcv.ReferenceScore)
|
|
}
|
|
|
|
/*
|
|
统计分数
|
|
@wherStr 统计条件
|
|
@group 集团
|
|
@department 部门
|
|
@dimensionId 维度
|
|
@targetId 指标
|
|
@i 步进器
|
|
@status 是否为观察数据
|
|
@scoringMethod 手动计分还是自动计分
|
|
@class 指标类型 1、定性;2:定量
|
|
@referenceScore 指标权重
|
|
@yserInt 年度
|
|
*/
|
|
syncProcessDepartTarget.Wait()
|
|
readStatisticsData := tpsProcess.readMyDayData()
|
|
//按照最大值排序
|
|
sort.Slice(readStatisticsData, func(i int, j int) bool {
|
|
return readStatisticsData[i].Counter < readStatisticsData[j].Counter
|
|
})
|
|
// jsonVal, jsonErr := json.Marshal(readStatisticsData)
|
|
// fmt.Printf("排序------%v--------》%v--------》%v\n", pvInfo.Id, string(jsonVal), jsonErr)
|
|
// panic(readStatisticsData)
|
|
for _, rsdv := range readStatisticsData {
|
|
// for ik := 0; ik <= 1; ik++ {
|
|
// var jiSuanZhiBuLing ScoreList
|
|
// outCont.Score = append(outCont.Score, jiSuanZhiBuLing)
|
|
// 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, 0)
|
|
// stccStatistics.Achievement = append(stccStatistics.Achievement, 0)
|
|
// }
|
|
var jiSuanZhi ScoreList
|
|
jiSuanZhi.Class = rsdv.Class
|
|
jiSuanZhi.ScoreVal = rsdv.ScoreVal
|
|
jiSuanZhi.AllPrize = rsdv.AllPrize
|
|
jiSuanZhi.ZeroPrize = rsdv.ZeroPrize
|
|
jiSuanZhi.CappingVal = rsdv.CappingVal
|
|
jiSuanZhi.ActualScore = rsdv.ActualScore
|
|
jiSuanZhi.Achievement = rsdv.Achievement
|
|
|
|
// type ScoreList struct {
|
|
// Class int `json:"class"` //统计类型
|
|
// ScoreVal float64 `json:"scoreval"` //原始值
|
|
// AllPrize float64 `json:"allprize"` //全奖值
|
|
// ZeroPrize float64 `json:"zeroprize"` //零奖值
|
|
// CappingVal float64 `json:"cappingval"` //封顶值
|
|
// ActualScore float64 `json:"actualscore"` //实际得分
|
|
// Achievement float64 `json:"achievement"` //达成率
|
|
// }
|
|
|
|
outCont.Score = append(outCont.Score, jiSuanZhi)
|
|
if len(rsdv.ExecutiveDepartment) > 0 { //写入执行考核的部门
|
|
for _, edv := range rsdv.ExecutiveDepartment {
|
|
if commonus.IsItTrueString(edv, outCont.ExecutiveDepartment) == false {
|
|
outCont.ExecutiveDepartment = append(outCont.ExecutiveDepartment, edv)
|
|
}
|
|
}
|
|
}
|
|
|
|
stccStatistics.ScoreVal = append(stccStatistics.ScoreVal, rsdv.ScoreVal)
|
|
stccStatistics.AllPrize = append(stccStatistics.AllPrize, rsdv.AllPrize)
|
|
stccStatistics.ZeroPrize = append(stccStatistics.ZeroPrize, rsdv.ZeroPrize)
|
|
stccStatistics.CappingVal = append(stccStatistics.CappingVal, rsdv.CappingVal)
|
|
stccStatistics.ActualScore = append(stccStatistics.ActualScore, rsdv.ActualScore)
|
|
stccStatistics.Achievement = append(stccStatistics.Achievement, rsdv.Achievement)
|
|
}
|
|
case 6: //年
|
|
// monthValue := commonus.TimeStampToDate(time.Now().Unix(), 12)
|
|
// if commonus.TimeStampToDate(time.Now().Unix(), 11) != giveData.Year {
|
|
// monthValue = "12"
|
|
// }
|
|
// monthValueInt, _ := strconv.Atoi(monthValue)
|
|
var tpsProcess tablePlanVersionStic
|
|
// for i := 1; i <= monthValueInt; i++ {
|
|
// // fmt.Printf("年--5-->%v--->%v-->%v\n", i, giveData.Year, yserInt)
|
|
// 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, pvInfo.Group, pvInfo.Department, i)
|
|
// syncProcessDepartTarget.Add(1)
|
|
// go tpsProcess.conditionStatistics(wherStr, strconv.FormatInt(pvInfo.Group, 10), strconv.FormatInt(pvInfo.Department, 10), pv.Id, pcv.Id, i, pcv.Status, scoringMethod, 2, yserInt, pcv.ReferenceScore)
|
|
// }
|
|
wherStr := fmt.Sprintf("fld_target_id = %v AND `fl_year` = %v AND `fl_duty_group` = %v AND `fl_duty_department` = %v ", pcv.Id, yserInt, pvInfo.Group, pvInfo.Department)
|
|
syncProcessDepartTarget.Add(1)
|
|
go tpsProcess.conditionStatistics(wherStr, strconv.FormatInt(pvInfo.Group, 10), strconv.FormatInt(pvInfo.Department, 10), pv.Id, pcv.Id, 1, pcv.Status, scoringMethod, 2, yserInt, pcv.ReferenceScore)
|
|
syncProcessDepartTarget.Wait()
|
|
readStatisticsData := tpsProcess.readMyDayData()
|
|
//按照最大值排序
|
|
sort.Slice(readStatisticsData, func(i int, j int) bool {
|
|
return readStatisticsData[i].Counter < readStatisticsData[j].Counter
|
|
})
|
|
// jsonVal, jsonErr := json.Marshal(readStatisticsData)
|
|
// fmt.Printf("排序------%v--------》%v--------》%v\n", pvInfo.Id, string(jsonVal), jsonErr)
|
|
|
|
for _, rsdv := range readStatisticsData {
|
|
var jiSuanZhi ScoreList
|
|
jiSuanZhi.Class = rsdv.Class
|
|
jiSuanZhi.ScoreVal = rsdv.ScoreVal
|
|
jiSuanZhi.ActualScore = rsdv.ActualScore
|
|
jiSuanZhi.AllPrize = rsdv.AllPrize
|
|
jiSuanZhi.ZeroPrize = rsdv.ZeroPrize
|
|
jiSuanZhi.CappingVal = rsdv.CappingVal
|
|
jiSuanZhi.Achievement = rsdv.Achievement
|
|
|
|
outCont.Score = append(outCont.Score, jiSuanZhi)
|
|
if len(rsdv.ExecutiveDepartment) > 0 { //写入执行考核的部门
|
|
for _, edv := range rsdv.ExecutiveDepartment {
|
|
if commonus.IsItTrueString(edv, outCont.ExecutiveDepartment) == false {
|
|
outCont.ExecutiveDepartment = append(outCont.ExecutiveDepartment, edv)
|
|
}
|
|
}
|
|
}
|
|
|
|
stccStatistics.ScoreVal = append(stccStatistics.ScoreVal, rsdv.ScoreVal)
|
|
stccStatistics.AllPrize = append(stccStatistics.AllPrize, rsdv.AllPrize)
|
|
stccStatistics.ZeroPrize = append(stccStatistics.ZeroPrize, rsdv.ZeroPrize)
|
|
stccStatistics.CappingVal = append(stccStatistics.CappingVal, rsdv.CappingVal)
|
|
stccStatistics.ActualScore = append(stccStatistics.ActualScore, rsdv.ActualScore)
|
|
stccStatistics.Achievement = append(stccStatistics.Achievement, rsdv.Achievement)
|
|
}
|
|
case 7:
|
|
var tpsProcess tablePlanVersionStic
|
|
//上半年
|
|
wherStr := fmt.Sprintf("fld_target_id = %v AND `fl_year` = %v AND `fl_duty_group` = %v AND `fl_duty_department` = %v AND `fl_month` IN %v", pcv.Id, yserInt, pvInfo.Group, pvInfo.Department, []int{1, 2, 3, 4, 5, 6})
|
|
syncProcessDepartTarget.Add(1)
|
|
go tpsProcess.conditionStatistics(wherStr, strconv.FormatInt(pvInfo.Group, 10), strconv.FormatInt(pvInfo.Department, 10), pv.Id, pcv.Id, 1, pcv.Status, scoringMethod, 2, yserInt, pcv.ReferenceScore)
|
|
|
|
//下半年
|
|
secondwherStr := fmt.Sprintf("fld_target_id = %v AND `fl_year` = %v AND `fl_duty_group` = %v AND `fl_duty_department` = %v AND `fl_month` IN %v", pcv.Id, yserInt, pvInfo.Group, pvInfo.Department, []int{7, 8, 9, 10, 11, 12})
|
|
syncProcessDepartTarget.Add(1)
|
|
go tpsProcess.conditionStatistics(secondwherStr, strconv.FormatInt(pvInfo.Group, 10), strconv.FormatInt(pvInfo.Department, 10), pv.Id, pcv.Id, 2, pcv.Status, scoringMethod, 2, yserInt, pcv.ReferenceScore)
|
|
|
|
syncProcessDepartTarget.Wait()
|
|
readStatisticsData := tpsProcess.readMyDayData()
|
|
//按照最大值排序
|
|
sort.Slice(readStatisticsData, func(i int, j int) bool {
|
|
return readStatisticsData[i].Counter < readStatisticsData[j].Counter
|
|
})
|
|
// jsonVal, jsonErr := json.Marshal(readStatisticsData)
|
|
// fmt.Printf("排序------%v--------》%v--------》%v\n", pvInfo.Id, string(jsonVal), jsonErr)
|
|
|
|
for _, rsdv := range readStatisticsData {
|
|
var jiSuanZhi ScoreList
|
|
jiSuanZhi.Class = rsdv.Class
|
|
jiSuanZhi.ScoreVal = rsdv.ScoreVal
|
|
jiSuanZhi.ActualScore = rsdv.ActualScore
|
|
jiSuanZhi.AllPrize = rsdv.AllPrize
|
|
jiSuanZhi.ZeroPrize = rsdv.ZeroPrize
|
|
jiSuanZhi.CappingVal = rsdv.CappingVal
|
|
jiSuanZhi.Achievement = rsdv.Achievement
|
|
|
|
outCont.Score = append(outCont.Score, jiSuanZhi)
|
|
if len(rsdv.ExecutiveDepartment) > 0 { //写入执行考核的部门
|
|
for _, edv := range rsdv.ExecutiveDepartment {
|
|
if commonus.IsItTrueString(edv, outCont.ExecutiveDepartment) == false {
|
|
outCont.ExecutiveDepartment = append(outCont.ExecutiveDepartment, edv)
|
|
}
|
|
}
|
|
}
|
|
|
|
stccStatistics.ScoreVal = append(stccStatistics.ScoreVal, rsdv.ScoreVal)
|
|
stccStatistics.AllPrize = append(stccStatistics.AllPrize, rsdv.AllPrize)
|
|
stccStatistics.ZeroPrize = append(stccStatistics.ZeroPrize, rsdv.ZeroPrize)
|
|
stccStatistics.CappingVal = append(stccStatistics.CappingVal, rsdv.CappingVal)
|
|
stccStatistics.ActualScore = append(stccStatistics.ActualScore, rsdv.ActualScore)
|
|
stccStatistics.Achievement = append(stccStatistics.Achievement, rsdv.Achievement)
|
|
}
|
|
|
|
default: //月
|
|
monthValue := commonus.TimeStampToDate(time.Now().Unix(), 12)
|
|
if commonus.TimeStampToDate(time.Now().Unix(), 11) != giveData.Year {
|
|
monthValue = "12"
|
|
}
|
|
monthValueInt, _ := strconv.Atoi(monthValue)
|
|
var tpsProcess tablePlanVersionStic
|
|
for i := 1; i <= monthValueInt; i++ {
|
|
// fmt.Printf("年--6-->%v--->%v-->%v\n", i, giveData.Year, yserInt)
|
|
wherStr := fmt.Sprintf("fld_target_id = %v AND `fl_year` = %v AND `fl_duty_group` = %v AND `fl_duty_department` = %v AND `fl_month` = %v", pcv.Id, yserInt, pvInfo.Group, pvInfo.Department, i)
|
|
syncProcessDepartTarget.Add(1)
|
|
go tpsProcess.conditionStatistics(wherStr, strconv.FormatInt(pvInfo.Group, 10), strconv.FormatInt(pvInfo.Department, 10), pv.Id, pcv.Id, i, pcv.Status, scoringMethod, 2, yserInt, pcv.ReferenceScore)
|
|
}
|
|
syncProcessDepartTarget.Wait()
|
|
readStatisticsData := tpsProcess.readMyDayData()
|
|
//按照最大值排序
|
|
sort.Slice(readStatisticsData, func(i int, j int) bool {
|
|
return readStatisticsData[i].Counter < readStatisticsData[j].Counter
|
|
})
|
|
// jsonVal, jsonErr := json.Marshal(readStatisticsData)
|
|
// fmt.Printf("排序------%v--------》%v--------》%v\n", pvInfo.Id, string(jsonVal), jsonErr)
|
|
|
|
for _, rsdv := range readStatisticsData {
|
|
var jiSuanZhi ScoreList
|
|
jiSuanZhi.Class = rsdv.Class
|
|
jiSuanZhi.ScoreVal = rsdv.ScoreVal
|
|
jiSuanZhi.ActualScore = rsdv.ActualScore
|
|
jiSuanZhi.AllPrize = rsdv.AllPrize
|
|
jiSuanZhi.ZeroPrize = rsdv.ZeroPrize
|
|
jiSuanZhi.CappingVal = rsdv.CappingVal
|
|
jiSuanZhi.Achievement = rsdv.Achievement
|
|
|
|
outCont.Score = append(outCont.Score, jiSuanZhi)
|
|
if len(rsdv.ExecutiveDepartment) > 0 { //写入执行考核的部门
|
|
for _, edv := range rsdv.ExecutiveDepartment {
|
|
if commonus.IsItTrueString(edv, outCont.ExecutiveDepartment) == false {
|
|
outCont.ExecutiveDepartment = append(outCont.ExecutiveDepartment, edv)
|
|
}
|
|
}
|
|
}
|
|
|
|
stccStatistics.ScoreVal = append(stccStatistics.ScoreVal, rsdv.ScoreVal)
|
|
stccStatistics.AllPrize = append(stccStatistics.AllPrize, rsdv.AllPrize)
|
|
stccStatistics.ZeroPrize = append(stccStatistics.ZeroPrize, rsdv.ZeroPrize)
|
|
stccStatistics.CappingVal = append(stccStatistics.CappingVal, rsdv.CappingVal)
|
|
stccStatistics.ActualScore = append(stccStatistics.ActualScore, rsdv.ActualScore)
|
|
stccStatistics.Achievement = append(stccStatistics.Achievement, rsdv.Achievement)
|
|
}
|
|
}
|
|
}
|
|
outCont.ScoreAllList = append(outCont.ScoreAllList, stccStatistics)
|
|
outCont.StatisticsName = []string{"全奖值", "零奖值", "实际值", "达成率", "得分"}
|
|
if isAdd == 1 {
|
|
d.outData = append(d.outData, outCont)
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
//当版本内容为空时
|
|
}
|
|
syncProcess.Done()
|
|
}
|
|
|
|
/*
|
|
统计分数
|
|
@wherStr 统计条件
|
|
@group 集团
|
|
@department 部门
|
|
@dimensionId 维度
|
|
@targetId 指标
|
|
@i 步进器
|
|
@status 是否为观察数据
|
|
@scoringMethod 手动计分还是自动计分
|
|
@class 指标类型 1、定性;2:定量
|
|
@referenceScore 指标权重
|
|
@yserInt 年度
|
|
*/
|
|
func (t *tablePlanVersionStic) conditionStatistics(wherStr, group, department, dimensionId, targetId string, i, status, scoringMethod, class int, yserInt, referenceScore int64) {
|
|
t.mutext.Lock()
|
|
defer t.mutext.Unlock()
|
|
// fmt.Printf("年--3-4->%v--->%v--->%v--->%v--->%v--->%v--->%v--->%v--->%v--->%v--->%v\n", wherStr, group, department, dimensionId, targetId, i, status, scoringMethod, class, yserInt, referenceScore)
|
|
var tableScoreCont TableScoreList
|
|
tableScoreCont.Counter = i
|
|
var sumScore float64
|
|
var departmentAry []int64 //部门ID
|
|
// 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(wherStr)
|
|
// 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(wherStr)
|
|
// gormDb.Pluck("COALESCE(SUM(fld_score), 0) as rescore", &sumScore)
|
|
// }
|
|
|
|
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(wherStr)
|
|
gormDb.Pluck("COALESCE(SUM(fld_score), 0) as rescore", &sumScore)
|
|
|
|
// fmt.Printf("计算得分--3-->%v--->%v-->%v--->%v\n", scoringMethod, wherStr, i, sumScore)
|
|
|
|
//获取测评部门
|
|
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(wherStr).Find(&departmentAry)
|
|
if len(departmentAry) > 0 {
|
|
for _, v := range departmentAry {
|
|
whereDepart := commonus.MapOut()
|
|
whereDepart["id"] = v
|
|
orgContDer, _ := commonus.GetNewOrgCont(whereDepart, "name")
|
|
tableScoreCont.ExecutiveDepartment = append(tableScoreCont.ExecutiveDepartment, orgContDer.Name)
|
|
}
|
|
}
|
|
|
|
// fmt.Printf("年--3-->%v--->%v\n", wherStr, yserInt)
|
|
//组装数据
|
|
// resultData := commonus.Decimal(sumScore / 100)
|
|
resultData := sumScore
|
|
tableScoreCont.Class = class
|
|
tableScoreCont.ScoreVal = commonus.Decimal(sumScore / 100)
|
|
if status != 3 {
|
|
tableScoreCont.ActualScore, tableScoreCont.AllPrize, tableScoreCont.ZeroPrize, tableScoreCont.CappingVal, tableScoreCont.Achievement = quantification.GetQuantitativeConfig(referenceScore, resultData, group, department, dimensionId, targetId, "0", yserInt, i, 2)
|
|
|
|
// t.TableScore = append(t.TableScore, tableScoreCont)
|
|
} else {
|
|
tableScoreCont.ActualScore = float64(referenceScore)
|
|
tableScoreCont.ActualScore, tableScoreCont.AllPrize, tableScoreCont.ZeroPrize, tableScoreCont.CappingVal, tableScoreCont.Achievement = quantification.GetQuantitativeConfigEs(referenceScore, resultData, group, department, dimensionId, targetId, "0", yserInt, i, 3)
|
|
// t.TableScore = append(t.TableScore, tableScoreCont)
|
|
}
|
|
|
|
if scoringMethod == 2 {
|
|
var sumManualScore float64
|
|
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(wherStr)
|
|
gormDb.Pluck("COALESCE(SUM(fld_scoring_score), 0) as rescore", &sumManualScore)
|
|
tableScoreCont.ActualScore = sumManualScore / 100
|
|
fmt.Printf("sumManualScore =====> %v\n", sumManualScore)
|
|
}
|
|
// if sumScore == 0 {
|
|
// tableScoreCont.ActualScore = float64(referenceScore)
|
|
// }
|
|
t.TableScore = append(t.TableScore, tableScoreCont)
|
|
// tableScoreCont.ActualScore = commonus.Decimal(tableScoreCont.ActualScore / 100)
|
|
syncProcessDepartTarget.Done()
|
|
|
|
// type ScoreList struct {
|
|
// Class int `json:"class"` //统计类型
|
|
// ScoreVal float64 `json:"scoreval"` //原始值
|
|
// AllPrize float64 `json:"allprize"` //全奖值
|
|
// ZeroPrize float64 `json:"zeroprize"` //零奖值
|
|
// CappingVal float64 `json:"cappingval"` //封顶值
|
|
// ActualScore float64 `json:"actualscore"` //实际得分
|
|
// Achievement float64 `json:"achievement"` //达成率
|
|
// }
|
|
}
|
|
func (t *tablePlanVersionStic) conditionStatisticsold(wherStr, group, department, dimensionId, targetId string, i, status, scoringMethod, class int, yserInt, referenceScore int64) {
|
|
t.mutext.Lock()
|
|
defer t.mutext.Unlock()
|
|
fmt.Printf("年--3-4->%v--->%v--->%v--->%v--->%v--->%v--->%v--->%v--->%v--->%v--->%v\n", wherStr, group, department, dimensionId, targetId, i, status, scoringMethod, class, yserInt, referenceScore)
|
|
var tableScoreCont TableScoreList
|
|
tableScoreCont.Counter = i
|
|
var sumScore float64
|
|
var departmentAry []int64 //部门ID
|
|
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(wherStr)
|
|
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(wherStr)
|
|
gormDb.Pluck("COALESCE(SUM(fld_score), 0) as rescore", &sumScore)
|
|
}
|
|
|
|
// fmt.Printf("计算得分--3-->%v--->%v-->%v--->%v\n", scoringMethod, wherStr, i, sumScore)
|
|
|
|
//获取测评部门
|
|
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(wherStr).Find(&departmentAry)
|
|
if len(departmentAry) > 0 {
|
|
for _, v := range departmentAry {
|
|
whereDepart := commonus.MapOut()
|
|
whereDepart["id"] = v
|
|
orgContDer, _ := commonus.GetNewOrgCont(whereDepart, "name")
|
|
tableScoreCont.ExecutiveDepartment = append(tableScoreCont.ExecutiveDepartment, orgContDer.Name)
|
|
}
|
|
}
|
|
|
|
// fmt.Printf("年--3-->%v--->%v\n", wherStr, yserInt)
|
|
//组装数据
|
|
// resultData := commonus.Decimal(sumScore / 100)
|
|
resultData := sumScore
|
|
tableScoreCont.Class = class
|
|
tableScoreCont.ScoreVal = commonus.Decimal(sumScore / 100)
|
|
if status != 3 {
|
|
tableScoreCont.ActualScore, tableScoreCont.AllPrize, tableScoreCont.ZeroPrize, tableScoreCont.CappingVal, tableScoreCont.Achievement = quantification.GetQuantitativeConfig(referenceScore, resultData, group, department, dimensionId, targetId, "0", yserInt, i, 2)
|
|
|
|
t.TableScore = append(t.TableScore, tableScoreCont)
|
|
} else {
|
|
tableScoreCont.ActualScore = float64(referenceScore)
|
|
tableScoreCont.ActualScore, tableScoreCont.AllPrize, tableScoreCont.ZeroPrize, tableScoreCont.CappingVal, tableScoreCont.Achievement = quantification.GetQuantitativeConfigEs(referenceScore, resultData, group, department, dimensionId, targetId, "0", yserInt, i, 2)
|
|
t.TableScore = append(t.TableScore, tableScoreCont)
|
|
}
|
|
|
|
// tableScoreCont.ActualScore = commonus.Decimal(tableScoreCont.ActualScore / 100)
|
|
syncProcessDepartTarget.Done()
|
|
|
|
// type ScoreList struct {
|
|
// Class int `json:"class"` //统计类型
|
|
// ScoreVal float64 `json:"scoreval"` //原始值
|
|
// AllPrize float64 `json:"allprize"` //全奖值
|
|
// ZeroPrize float64 `json:"zeroprize"` //零奖值
|
|
// CappingVal float64 `json:"cappingval"` //封顶值
|
|
// ActualScore float64 `json:"actualscore"` //实际得分
|
|
// Achievement float64 `json:"achievement"` //达成率
|
|
// }
|
|
}
|
|
|
|
//定性
|
|
/*SubjectiveAuxiliaryCalculationSumMethod(wherStr string, i, status, class int, referenceScore int64)
|
|
统计分数
|
|
@wherStr 统计条件
|
|
@i 步进器
|
|
@status 是否为观察数据
|
|
@class 指标类型 1、定性;2:定量
|
|
@referenceScore 指标权重
|
|
*/
|
|
|
|
func (t *tablePlanVersionStic) SubjectiveAuxiliaryCalculationSumMethod(wherStr string, i, status, class int, referenceScore int64) {
|
|
t.mutext.Lock()
|
|
defer t.mutext.Unlock()
|
|
var tableScoreCont TableScoreList
|
|
tableScoreCont.Counter = i
|
|
var sumScore float64
|
|
var departmentAry []int64 //部门ID
|
|
//加分
|
|
var addSumScore float64 = 0
|
|
|
|
// global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.ScoreFlow{}).Select("sf_score").Where(wherStr).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(wherStr).Where("sf_plus_reduce_score = 1").Where("sf_reply >= 2 AND sf_reply <> 4").Find(&jiaFenAry)
|
|
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.ScoreFlow{}).Select("sf_score,sf_count").Where(wherStr).Where("sf_plus_reduce_score = 1").Where("sf_reply IN (2,3)").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(wherStr).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(wherStr).Where("sf_plus_reduce_score = 2").Where("sf_reply >= 2 AND sf_reply <> 4").Find(&jianFenAry)
|
|
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.ScoreFlow{}).Select("sf_score,sf_count").Where(wherStr).Where("sf_plus_reduce_score = 2").Where("sf_reply IN (2,3)").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
|
|
}
|
|
//获取测评部门
|
|
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.ScoreFlow{}).Select("sf_evaluation_department").Where(wherStr).Find(&departmentAry)
|
|
if len(departmentAry) > 0 {
|
|
for _, v := range departmentAry {
|
|
whereDepart := commonus.MapOut()
|
|
whereDepart["id"] = v
|
|
orgContDer, _ := commonus.GetNewOrgCont(whereDepart, "name")
|
|
tableScoreCont.ExecutiveDepartment = append(tableScoreCont.ExecutiveDepartment, orgContDer.Name)
|
|
}
|
|
}
|
|
|
|
resultData := commonus.Decimal(sumScore / 100)
|
|
if resultData > float64(referenceScore) {
|
|
resultData = float64(referenceScore)
|
|
}
|
|
|
|
//组装数据
|
|
// var jiSuanZhi ScoreList
|
|
tableScoreCont.Class = class
|
|
tableScoreCont.AllPrize = 0
|
|
tableScoreCont.ZeroPrize = 0
|
|
tableScoreCont.CappingVal = 0
|
|
tableScoreCont.ScoreVal = 0
|
|
tableScoreCont.Achievement = 0
|
|
tableScoreCont.ScoreVal = resultData
|
|
if status != 3 {
|
|
// fmt.Printf("referenceScore--1--->%v\n", referenceScore)
|
|
// tableScoreCont.ActualScore = resultData
|
|
if addSumScore == 0 && scoreReduction == 0 {
|
|
// fmt.Printf("referenceScore--2--->%v\n", referenceScore)
|
|
tableScoreCont.ActualScore = float64(referenceScore)
|
|
} else {
|
|
// fmt.Printf("referenceScore--3--->%v\n", referenceScore)
|
|
deFen := float64(referenceScore) - resultData
|
|
if deFen > 0 {
|
|
tableScoreCont.ActualScore = deFen
|
|
} else {
|
|
tableScoreCont.ActualScore = 0
|
|
}
|
|
|
|
}
|
|
} else {
|
|
tableScoreCont.ActualScore = float64(referenceScore)
|
|
// if addSumScore == 0 && scoreReduction == 0 {
|
|
// fmt.Printf("referenceScore--2--->%v\n", referenceScore)
|
|
// tableScoreCont.ActualScore = float64(referenceScore)
|
|
// } else {
|
|
// fmt.Printf("referenceScore--3--->%v\n", referenceScore)
|
|
// tableScoreCont.ActualScore = resultData
|
|
// }
|
|
|
|
}
|
|
fmt.Printf("referenceScore--4--->%v\n", referenceScore)
|
|
t.TableScore = append(t.TableScore, tableScoreCont)
|
|
syncProcessDepartTarget.Done()
|
|
}
|
|
|
|
func (d *dataLockStatistics) planVersiconProcessV1(pvInfo assessmentmodel.PlanVersio, giveData PlanVersioMingXi) {
|
|
d.mutext.Lock()
|
|
defer d.mutext.Unlock()
|
|
yserInt, _ := strconv.ParseInt(giveData.Year, 10, 64)
|
|
// fmt.Printf("年--2-->%v--->%v\n", giveData.Year, yserInt)
|
|
if pvInfo.Content != "" {
|
|
//当版本内容不为空时
|
|
var planInfo []AddDutyNewCont
|
|
jsonErr := json.Unmarshal([]byte(pvInfo.Content), &planInfo)
|
|
if jsonErr == nil {
|
|
//进行维度操作
|
|
for _, pv := range planInfo {
|
|
for _, pcv := range pv.Child { //指标列表
|
|
// if pcv.Id == "4" {
|
|
fmt.Printf("pcv.Id------------------->%v\n", pcv.Id)
|
|
if pcv.Status != 2 { //忽略掉禁用的指标
|
|
var outCont TargetContOutCont
|
|
outCont.Id = strconv.FormatInt(pvInfo.Id, 10)
|
|
//集团信息
|
|
outCont.Group = strconv.FormatInt(pvInfo.Group, 10)
|
|
where := commonus.MapOut()
|
|
where["id"] = pvInfo.Group
|
|
orgCont, _ := commonus.GetNewOrgCont(where, "id", "name")
|
|
outCont.GroupName = orgCont.Name
|
|
//接受考核部门
|
|
outCont.DepartmentId = strconv.FormatInt(pvInfo.Department, 10)
|
|
whereDepart := commonus.MapOut()
|
|
whereDepart["id"] = pvInfo.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
|
|
targetGormDb := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.EvaluationTarget{}).Select("et_type,et_scoring_method,et_title").Where("`et_id` = ?", pcv.Id)
|
|
if giveData.Title != "" {
|
|
targetGormDb = targetGormDb.Where("et_title LIKE ?", "%"+giveData.Title+"%")
|
|
}
|
|
if giveData.Class != 0 {
|
|
targetGormDb = targetGormDb.Where("et_type = ?", giveData.Class)
|
|
}
|
|
isAdd := 1
|
|
evalErr := targetGormDb.First(&evalTargerCont).Error
|
|
scoringMethod := 1
|
|
if evalErr == nil {
|
|
outCont.Type = evalTargerCont.Type
|
|
scoringMethod = evalTargerCont.ScoringMethod
|
|
isAdd = 1
|
|
} else {
|
|
isAdd = 2
|
|
}
|
|
outCont.ManualGear = scoringMethod
|
|
//获取执行部门及指标性质
|
|
_, _, departName, cycle, cycleattr, isDuty, isDutyErr := getDepartTarget(pvInfo.Key, pv.Id, pcv.Id, strconv.FormatInt(pvInfo.Group, 10), strconv.FormatInt(pvInfo.Department, 10))
|
|
|
|
// fmt.Printf("qualEvalId----------->%v----------->departName----------->%v----------->cycle----------->%v----------->cycleattr----------->%v----------->isDuty----------->%v----------->isDutyErr----------->%v\n", qualEvalId, departName, cycle, cycleattr, isDuty, isDutyErr)
|
|
|
|
if isDutyErr == nil {
|
|
outCont.ExecutiveDepartment = departName
|
|
if pcv.Cycles == 0 {
|
|
outCont.Cycles = cycle
|
|
} else {
|
|
outCont.Cycles = pcv.Cycles
|
|
cycle = pcv.Cycles
|
|
}
|
|
if pcv.CycleAttres == 0 {
|
|
outCont.Cycles = cycleattr
|
|
} else {
|
|
outCont.CycleAttres = pcv.CycleAttres
|
|
cycleattr = pcv.CycleAttres
|
|
}
|
|
// outCont.CycleAttres = cycleattr
|
|
if isDuty != 0 {
|
|
outCont.Type = isDuty
|
|
}
|
|
} else {
|
|
var evalTargerCont assessmentmodel.EvaluationTarget
|
|
evalErr := global.GVA_DB_Performanceappraisal.Where("`et_id` = ?", pcv.Id).First(&evalTargerCont).Error
|
|
if evalErr == nil {
|
|
if pcv.Cycles == 0 {
|
|
outCont.Cycles = evalTargerCont.Cycles
|
|
} else {
|
|
outCont.Cycles = pcv.Cycles
|
|
cycle = pcv.Cycles
|
|
}
|
|
if pcv.CycleAttres == 0 {
|
|
outCont.CycleAttres = evalTargerCont.CycleAttres
|
|
} else {
|
|
outCont.CycleAttres = pcv.CycleAttres
|
|
cycleattr = pcv.CycleAttres
|
|
}
|
|
// isDuty = evalTargerCont.Type
|
|
// outCont.CycleAttres = evalTargerCont.CycleAttres
|
|
}
|
|
if isDuty != 0 {
|
|
outCont.Type = isDuty
|
|
}
|
|
// isDuty = 2
|
|
}
|
|
// fmt.Printf("departName--->%v--->cycle--->%v--->cycleattr--->%v--->isDuty--->%v--->isDutyErr--->%v\n", departName, cycle, cycleattr, isDuty, isDutyErr)
|
|
// panic(isDutyErr)
|
|
var stccStatistics ScoreListAry
|
|
stccStatistics.Class = isDuty
|
|
if isDuty == 1 {
|
|
//定性考核
|
|
switch cycle {
|
|
case 1:
|
|
case 2: //天
|
|
case 3:
|
|
case 5: //季度
|
|
|
|
var tpsProcess tablePlanVersionStic
|
|
for i := 1; i <= 4; i++ {
|
|
// 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, pvInfo.Group, pvInfo.Department, yserInt, i)
|
|
|
|
wherStr := fmt.Sprintf("`sf_target_id` = %v AND `sf_duty_group` = %v AND `sf_duty_department` = %v AND `sf_year` = %v AND `sf_quarter` = %v", pcv.Id, pvInfo.Group, pvInfo.Department, yserInt, i)
|
|
// 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, pvInfo.Group, pvInfo.Department, yserInt, i)
|
|
syncProcessDepartTarget.Add(1)
|
|
go tpsProcess.SubjectiveAuxiliaryCalculationSumMethod(wherStr, i, pcv.Status, 1, pcv.ReferenceScore)
|
|
}
|
|
syncProcessDepartTarget.Wait()
|
|
readStatisticsData := tpsProcess.readMyDayData()
|
|
//按照最大值排序
|
|
sort.Slice(readStatisticsData, func(i int, j int) bool {
|
|
return readStatisticsData[i].Counter < readStatisticsData[j].Counter
|
|
})
|
|
for _, rsdv := range readStatisticsData {
|
|
|
|
// for ik := 0; ik <= 1; ik++ {
|
|
// var jiSuanZhiBuLing ScoreList
|
|
// outCont.Score = append(outCont.Score, jiSuanZhiBuLing)
|
|
// 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, 0)
|
|
// stccStatistics.Achievement = append(stccStatistics.Achievement, 0)
|
|
// }
|
|
|
|
var jiSuanZhi ScoreList
|
|
jiSuanZhi.Class = rsdv.Class
|
|
jiSuanZhi.ScoreVal = rsdv.ScoreVal
|
|
jiSuanZhi.ActualScore = commonus.DecimalEs(rsdv.ActualScore, 2)
|
|
jiSuanZhi.AllPrize = rsdv.AllPrize
|
|
jiSuanZhi.ZeroPrize = rsdv.ZeroPrize
|
|
jiSuanZhi.CappingVal = rsdv.CappingVal
|
|
jiSuanZhi.Achievement = rsdv.Achievement
|
|
|
|
outCont.Score = append(outCont.Score, jiSuanZhi)
|
|
if len(rsdv.ExecutiveDepartment) > 0 { //写入执行考核的部门
|
|
for _, edv := range rsdv.ExecutiveDepartment {
|
|
if commonus.IsItTrueString(edv, outCont.ExecutiveDepartment) == false {
|
|
outCont.ExecutiveDepartment = append(outCont.ExecutiveDepartment, edv)
|
|
}
|
|
}
|
|
}
|
|
|
|
stccStatistics.ScoreVal = append(stccStatistics.ScoreVal, rsdv.ScoreVal)
|
|
stccStatistics.AllPrize = append(stccStatistics.AllPrize, rsdv.AllPrize)
|
|
stccStatistics.ZeroPrize = append(stccStatistics.ZeroPrize, rsdv.ZeroPrize)
|
|
stccStatistics.CappingVal = append(stccStatistics.CappingVal, rsdv.CappingVal)
|
|
stccStatistics.ActualScore = append(stccStatistics.ActualScore, rsdv.ActualScore)
|
|
stccStatistics.Achievement = append(stccStatistics.Achievement, rsdv.Achievement)
|
|
}
|
|
case 6: //年
|
|
// monthValue := commonus.TimeStampToDate(time.Now().Unix(), 12)
|
|
// if commonus.TimeStampToDate(time.Now().Unix(), 11) != giveData.Year {
|
|
// monthValue = "12"
|
|
// }
|
|
// monthValueInt, _ := strconv.Atoi(monthValue)
|
|
var tpsProcess tablePlanVersionStic
|
|
// for i := 1; i <= monthValueInt; i++ {
|
|
// 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, pvInfo.Group, pvInfo.Department, yserInt, i)
|
|
// syncProcessDepartTarget.Add(1)
|
|
// go tpsProcess.SubjectiveAuxiliaryCalculationSumMethod(wherStr, i, pcv.Status, 1, pcv.ReferenceScore)
|
|
// }
|
|
wherStr := fmt.Sprintf("`sf_target_id` = %v AND `sf_duty_group` = %v AND `sf_duty_department` = %v AND `sf_year` = %v", pcv.Id, pvInfo.Group, pvInfo.Department, yserInt)
|
|
syncProcessDepartTarget.Add(1)
|
|
go tpsProcess.SubjectiveAuxiliaryCalculationSumMethod(wherStr, 1, pcv.Status, 1, pcv.ReferenceScore)
|
|
syncProcessDepartTarget.Wait()
|
|
readStatisticsData := tpsProcess.readMyDayData()
|
|
//按照最大值排序
|
|
sort.Slice(readStatisticsData, func(i int, j int) bool {
|
|
return readStatisticsData[i].Counter < readStatisticsData[j].Counter
|
|
})
|
|
for _, rsdv := range readStatisticsData {
|
|
var jiSuanZhi ScoreList
|
|
jiSuanZhi.Class = rsdv.Class
|
|
jiSuanZhi.ScoreVal = rsdv.ScoreVal
|
|
jiSuanZhi.ActualScore = rsdv.ActualScore
|
|
jiSuanZhi.AllPrize = rsdv.AllPrize
|
|
jiSuanZhi.ZeroPrize = rsdv.ZeroPrize
|
|
jiSuanZhi.CappingVal = rsdv.CappingVal
|
|
jiSuanZhi.Achievement = rsdv.Achievement
|
|
|
|
outCont.Score = append(outCont.Score, jiSuanZhi)
|
|
if len(rsdv.ExecutiveDepartment) > 0 { //写入执行考核的部门
|
|
for _, edv := range rsdv.ExecutiveDepartment {
|
|
if commonus.IsItTrueString(edv, outCont.ExecutiveDepartment) == false {
|
|
outCont.ExecutiveDepartment = append(outCont.ExecutiveDepartment, edv)
|
|
}
|
|
}
|
|
}
|
|
|
|
stccStatistics.ScoreVal = append(stccStatistics.ScoreVal, rsdv.ScoreVal)
|
|
stccStatistics.AllPrize = append(stccStatistics.AllPrize, rsdv.AllPrize)
|
|
stccStatistics.ZeroPrize = append(stccStatistics.ZeroPrize, rsdv.ZeroPrize)
|
|
stccStatistics.CappingVal = append(stccStatistics.CappingVal, rsdv.CappingVal)
|
|
stccStatistics.ActualScore = append(stccStatistics.ActualScore, rsdv.ActualScore)
|
|
stccStatistics.Achievement = append(stccStatistics.Achievement, rsdv.Achievement)
|
|
}
|
|
case 7: //半年
|
|
var tpsProcess tablePlanVersionStic
|
|
//上半年
|
|
firstHalfwherStr := fmt.Sprintf("`sf_target_id` = %v AND `sf_duty_group` = %v AND `sf_duty_department` = %v AND `sf_year` = %v AND `sf_month` IN %v", pcv.Id, pvInfo.Group, pvInfo.Department, yserInt, []int{1, 2, 3, 4, 5, 6})
|
|
syncProcessDepartTarget.Add(1)
|
|
go tpsProcess.SubjectiveAuxiliaryCalculationSumMethod(firstHalfwherStr, 1, pcv.Status, 1, pcv.ReferenceScore)
|
|
//下半年
|
|
secondHalfwherStr := fmt.Sprintf("`sf_target_id` = %v AND `sf_duty_group` = %v AND `sf_duty_department` = %v AND `sf_year` = %v AND `sf_month` IN %v", pcv.Id, pvInfo.Group, pvInfo.Department, yserInt, []int{7, 8, 9, 10, 11, 12})
|
|
syncProcessDepartTarget.Add(1)
|
|
go tpsProcess.SubjectiveAuxiliaryCalculationSumMethod(secondHalfwherStr, 2, pcv.Status, 1, pcv.ReferenceScore)
|
|
|
|
syncProcessDepartTarget.Wait()
|
|
readStatisticsData := tpsProcess.readMyDayData()
|
|
|
|
//按照最大值排序
|
|
sort.Slice(readStatisticsData, func(i int, j int) bool {
|
|
return readStatisticsData[i].Counter < readStatisticsData[j].Counter
|
|
})
|
|
for _, rsdv := range readStatisticsData {
|
|
var jiSuanZhi ScoreList
|
|
jiSuanZhi.Class = rsdv.Class
|
|
jiSuanZhi.ScoreVal = rsdv.ScoreVal
|
|
jiSuanZhi.ActualScore = rsdv.ActualScore
|
|
jiSuanZhi.AllPrize = rsdv.AllPrize
|
|
jiSuanZhi.ZeroPrize = rsdv.ZeroPrize
|
|
jiSuanZhi.CappingVal = rsdv.CappingVal
|
|
jiSuanZhi.Achievement = rsdv.Achievement
|
|
|
|
outCont.Score = append(outCont.Score, jiSuanZhi)
|
|
if len(rsdv.ExecutiveDepartment) > 0 { //写入执行考核的部门
|
|
for _, edv := range rsdv.ExecutiveDepartment {
|
|
if commonus.IsItTrueString(edv, outCont.ExecutiveDepartment) == false {
|
|
outCont.ExecutiveDepartment = append(outCont.ExecutiveDepartment, edv)
|
|
}
|
|
}
|
|
}
|
|
|
|
stccStatistics.ScoreVal = append(stccStatistics.ScoreVal, rsdv.ScoreVal)
|
|
stccStatistics.AllPrize = append(stccStatistics.AllPrize, rsdv.AllPrize)
|
|
stccStatistics.ZeroPrize = append(stccStatistics.ZeroPrize, rsdv.ZeroPrize)
|
|
stccStatistics.CappingVal = append(stccStatistics.CappingVal, rsdv.CappingVal)
|
|
stccStatistics.ActualScore = append(stccStatistics.ActualScore, rsdv.ActualScore)
|
|
stccStatistics.Achievement = append(stccStatistics.Achievement, rsdv.Achievement)
|
|
}
|
|
|
|
default: //月
|
|
monthValue := commonus.TimeStampToDate(time.Now().Unix(), 12)
|
|
if commonus.TimeStampToDate(time.Now().Unix(), 11) != giveData.Year {
|
|
monthValue = "12"
|
|
}
|
|
monthValueInt, _ := strconv.Atoi(monthValue)
|
|
var tpsProcess tablePlanVersionStic
|
|
for i := 1; i <= monthValueInt; i++ {
|
|
wherStr := fmt.Sprintf("`sf_target_id` = %v AND `sf_duty_group` = %v AND `sf_duty_department` = %v AND `sf_year` = %v AND `sf_month` = %v", pcv.Id, pvInfo.Group, pvInfo.Department, yserInt, i)
|
|
syncProcessDepartTarget.Add(1)
|
|
go tpsProcess.SubjectiveAuxiliaryCalculationSumMethod(wherStr, i, pcv.Status, 1, pcv.ReferenceScore)
|
|
}
|
|
syncProcessDepartTarget.Wait()
|
|
readStatisticsData := tpsProcess.readMyDayData()
|
|
//按照最大值排序
|
|
sort.Slice(readStatisticsData, func(i int, j int) bool {
|
|
return readStatisticsData[i].Counter < readStatisticsData[j].Counter
|
|
})
|
|
for _, rsdv := range readStatisticsData {
|
|
var jiSuanZhi ScoreList
|
|
jiSuanZhi.Class = rsdv.Class
|
|
jiSuanZhi.ScoreVal = rsdv.ScoreVal
|
|
jiSuanZhi.ActualScore = rsdv.ActualScore
|
|
jiSuanZhi.AllPrize = rsdv.AllPrize
|
|
jiSuanZhi.ZeroPrize = rsdv.ZeroPrize
|
|
jiSuanZhi.CappingVal = rsdv.CappingVal
|
|
jiSuanZhi.Achievement = rsdv.Achievement
|
|
|
|
outCont.Score = append(outCont.Score, jiSuanZhi)
|
|
if len(rsdv.ExecutiveDepartment) > 0 { //写入执行考核的部门
|
|
for _, edv := range rsdv.ExecutiveDepartment {
|
|
if commonus.IsItTrueString(edv, outCont.ExecutiveDepartment) == false {
|
|
outCont.ExecutiveDepartment = append(outCont.ExecutiveDepartment, edv)
|
|
}
|
|
}
|
|
}
|
|
|
|
stccStatistics.ScoreVal = append(stccStatistics.ScoreVal, rsdv.ScoreVal)
|
|
stccStatistics.AllPrize = append(stccStatistics.AllPrize, rsdv.AllPrize)
|
|
stccStatistics.ZeroPrize = append(stccStatistics.ZeroPrize, rsdv.ZeroPrize)
|
|
stccStatistics.CappingVal = append(stccStatistics.CappingVal, rsdv.CappingVal)
|
|
stccStatistics.ActualScore = append(stccStatistics.ActualScore, rsdv.ActualScore)
|
|
stccStatistics.Achievement = append(stccStatistics.Achievement, rsdv.Achievement)
|
|
}
|
|
}
|
|
} else {
|
|
//定量考核
|
|
switch cycle {
|
|
case 1:
|
|
case 2: //天
|
|
case 3:
|
|
case 5: //季度
|
|
|
|
var tpsProcess tablePlanVersionStic
|
|
for i := 1; i <= 4; i++ {
|
|
|
|
syncProcessDepartTarget.Add(1)
|
|
go tpsProcess.conditionStatisticsNew(strconv.FormatInt(pvInfo.Group, 10), strconv.FormatInt(pvInfo.Department, 10), pv.Id, pcv.Id, i, pcv.Status, scoringMethod, 2, yserInt, pcv.ReferenceScore, 5, 2)
|
|
}
|
|
|
|
syncProcessDepartTarget.Wait()
|
|
readStatisticsData := tpsProcess.readMyDayData()
|
|
//按照最大值排序
|
|
sort.Slice(readStatisticsData, func(i int, j int) bool {
|
|
return readStatisticsData[i].Counter < readStatisticsData[j].Counter
|
|
})
|
|
|
|
for _, rsdv := range readStatisticsData {
|
|
|
|
var jiSuanZhi ScoreList
|
|
jiSuanZhi.Class = rsdv.Class
|
|
jiSuanZhi.ScoreVal = rsdv.ScoreVal
|
|
jiSuanZhi.AllPrize = rsdv.AllPrize
|
|
jiSuanZhi.ZeroPrize = rsdv.ZeroPrize
|
|
jiSuanZhi.CappingVal = rsdv.CappingVal
|
|
jiSuanZhi.ActualScore = rsdv.ActualScore
|
|
jiSuanZhi.Achievement = rsdv.Achievement
|
|
|
|
outCont.Score = append(outCont.Score, jiSuanZhi)
|
|
if len(rsdv.ExecutiveDepartment) > 0 { //写入执行考核的部门
|
|
for _, edv := range rsdv.ExecutiveDepartment {
|
|
if commonus.IsItTrueString(edv, outCont.ExecutiveDepartment) == false {
|
|
outCont.ExecutiveDepartment = append(outCont.ExecutiveDepartment, edv)
|
|
}
|
|
}
|
|
}
|
|
|
|
stccStatistics.ScoreVal = append(stccStatistics.ScoreVal, rsdv.ScoreVal)
|
|
stccStatistics.AllPrize = append(stccStatistics.AllPrize, rsdv.AllPrize)
|
|
stccStatistics.ZeroPrize = append(stccStatistics.ZeroPrize, rsdv.ZeroPrize)
|
|
stccStatistics.CappingVal = append(stccStatistics.CappingVal, rsdv.CappingVal)
|
|
stccStatistics.ActualScore = append(stccStatistics.ActualScore, rsdv.ActualScore)
|
|
stccStatistics.Achievement = append(stccStatistics.Achievement, rsdv.Achievement)
|
|
}
|
|
case 6: //年
|
|
|
|
var tpsProcess tablePlanVersionStic
|
|
|
|
syncProcessDepartTarget.Add(1)
|
|
|
|
go tpsProcess.conditionStatisticsNew(strconv.FormatInt(pvInfo.Group, 10), strconv.FormatInt(pvInfo.Department, 10), pv.Id, pcv.Id, 1, pcv.Status, scoringMethod, 2, yserInt, pcv.ReferenceScore, 6, 2)
|
|
|
|
syncProcessDepartTarget.Wait()
|
|
readStatisticsData := tpsProcess.readMyDayData()
|
|
//按照最大值排序
|
|
sort.Slice(readStatisticsData, func(i int, j int) bool {
|
|
return readStatisticsData[i].Counter < readStatisticsData[j].Counter
|
|
})
|
|
|
|
for _, rsdv := range readStatisticsData {
|
|
var jiSuanZhi ScoreList
|
|
jiSuanZhi.Class = rsdv.Class
|
|
jiSuanZhi.ScoreVal = rsdv.ScoreVal
|
|
jiSuanZhi.ActualScore = rsdv.ActualScore
|
|
jiSuanZhi.AllPrize = rsdv.AllPrize
|
|
jiSuanZhi.ZeroPrize = rsdv.ZeroPrize
|
|
jiSuanZhi.CappingVal = rsdv.CappingVal
|
|
jiSuanZhi.Achievement = rsdv.Achievement
|
|
|
|
outCont.Score = append(outCont.Score, jiSuanZhi)
|
|
if len(rsdv.ExecutiveDepartment) > 0 { //写入执行考核的部门
|
|
for _, edv := range rsdv.ExecutiveDepartment {
|
|
if commonus.IsItTrueString(edv, outCont.ExecutiveDepartment) == false {
|
|
outCont.ExecutiveDepartment = append(outCont.ExecutiveDepartment, edv)
|
|
}
|
|
}
|
|
}
|
|
|
|
stccStatistics.ScoreVal = append(stccStatistics.ScoreVal, rsdv.ScoreVal)
|
|
stccStatistics.AllPrize = append(stccStatistics.AllPrize, rsdv.AllPrize)
|
|
stccStatistics.ZeroPrize = append(stccStatistics.ZeroPrize, rsdv.ZeroPrize)
|
|
stccStatistics.CappingVal = append(stccStatistics.CappingVal, rsdv.CappingVal)
|
|
stccStatistics.ActualScore = append(stccStatistics.ActualScore, rsdv.ActualScore)
|
|
stccStatistics.Achievement = append(stccStatistics.Achievement, rsdv.Achievement)
|
|
}
|
|
case 7:
|
|
var tpsProcess tablePlanVersionStic
|
|
//上半年
|
|
syncProcessDepartTarget.Add(1)
|
|
go tpsProcess.conditionStatisticsNew(strconv.FormatInt(pvInfo.Group, 10), strconv.FormatInt(pvInfo.Department, 10), pv.Id, pcv.Id, 1, pcv.Status, scoringMethod, 2, yserInt, pcv.ReferenceScore, 7, 2)
|
|
|
|
//下半年
|
|
syncProcessDepartTarget.Add(1)
|
|
go tpsProcess.conditionStatisticsNew(strconv.FormatInt(pvInfo.Group, 10), strconv.FormatInt(pvInfo.Department, 10), pv.Id, pcv.Id, 3, pcv.Status, scoringMethod, 2, yserInt, pcv.ReferenceScore, 6, 2)
|
|
|
|
syncProcessDepartTarget.Wait()
|
|
readStatisticsData := tpsProcess.readMyDayData()
|
|
//按照最大值排序
|
|
sort.Slice(readStatisticsData, func(i int, j int) bool {
|
|
return readStatisticsData[i].Counter < readStatisticsData[j].Counter
|
|
})
|
|
// jsonVal, jsonErr := json.Marshal(readStatisticsData)
|
|
// fmt.Printf("排序------%v--------》%v--------》%v\n", pvInfo.Id, string(jsonVal), jsonErr)
|
|
|
|
for _, rsdv := range readStatisticsData {
|
|
var jiSuanZhi ScoreList
|
|
jiSuanZhi.Class = rsdv.Class
|
|
jiSuanZhi.ScoreVal = rsdv.ScoreVal
|
|
jiSuanZhi.ActualScore = rsdv.ActualScore
|
|
jiSuanZhi.AllPrize = rsdv.AllPrize
|
|
jiSuanZhi.ZeroPrize = rsdv.ZeroPrize
|
|
jiSuanZhi.CappingVal = rsdv.CappingVal
|
|
jiSuanZhi.Achievement = rsdv.Achievement
|
|
|
|
outCont.Score = append(outCont.Score, jiSuanZhi)
|
|
if len(rsdv.ExecutiveDepartment) > 0 { //写入执行考核的部门
|
|
for _, edv := range rsdv.ExecutiveDepartment {
|
|
if commonus.IsItTrueString(edv, outCont.ExecutiveDepartment) == false {
|
|
outCont.ExecutiveDepartment = append(outCont.ExecutiveDepartment, edv)
|
|
}
|
|
}
|
|
}
|
|
|
|
stccStatistics.ScoreVal = append(stccStatistics.ScoreVal, rsdv.ScoreVal)
|
|
stccStatistics.AllPrize = append(stccStatistics.AllPrize, rsdv.AllPrize)
|
|
stccStatistics.ZeroPrize = append(stccStatistics.ZeroPrize, rsdv.ZeroPrize)
|
|
stccStatistics.CappingVal = append(stccStatistics.CappingVal, rsdv.CappingVal)
|
|
stccStatistics.ActualScore = append(stccStatistics.ActualScore, rsdv.ActualScore)
|
|
stccStatistics.Achievement = append(stccStatistics.Achievement, rsdv.Achievement)
|
|
}
|
|
|
|
default: //月
|
|
|
|
monthValue := commonus.TimeStampToDate(time.Now().Unix(), 12)
|
|
if commonus.TimeStampToDate(time.Now().Unix(), 11) != giveData.Year {
|
|
monthValue = "12"
|
|
}
|
|
monthValueInt, _ := strconv.Atoi(monthValue)
|
|
var tpsProcess tablePlanVersionStic
|
|
if giveData.Month != 0 {
|
|
monthIsDay := giveData.Month
|
|
if monthIsDay > 12 {
|
|
monthIsDay = 12
|
|
}
|
|
if monthIsDay < 1 {
|
|
monthIsDay = 1
|
|
}
|
|
syncProcessDepartTarget.Add(1)
|
|
go tpsProcess.conditionStatisticsNew(strconv.FormatInt(pvInfo.Group, 10), strconv.FormatInt(pvInfo.Department, 10), pv.Id, pcv.Id, monthIsDay, pcv.Status, scoringMethod, 2, yserInt, pcv.ReferenceScore, 4, 2)
|
|
} else {
|
|
for i := 1; i <= monthValueInt; i++ {
|
|
syncProcessDepartTarget.Add(1)
|
|
go tpsProcess.conditionStatisticsNew(strconv.FormatInt(pvInfo.Group, 10), strconv.FormatInt(pvInfo.Department, 10), pv.Id, pcv.Id, i, pcv.Status, scoringMethod, 2, yserInt, pcv.ReferenceScore, 4, 2)
|
|
}
|
|
}
|
|
|
|
syncProcessDepartTarget.Wait()
|
|
readStatisticsData := tpsProcess.readMyDayData()
|
|
//按照最大值排序
|
|
sort.Slice(readStatisticsData, func(i int, j int) bool {
|
|
return readStatisticsData[i].Counter < readStatisticsData[j].Counter
|
|
})
|
|
jsonVal, jsonErr := json.Marshal(readStatisticsData)
|
|
fmt.Printf("排序------%v--------》%v--------》%v\n", pvInfo.Id, string(jsonVal), jsonErr)
|
|
|
|
for _, rsdv := range readStatisticsData {
|
|
var jiSuanZhi ScoreList
|
|
jiSuanZhi.Class = rsdv.Class
|
|
jiSuanZhi.ScoreVal = rsdv.ScoreVal
|
|
jiSuanZhi.ActualScore = rsdv.ActualScore
|
|
jiSuanZhi.AllPrize = rsdv.AllPrize
|
|
jiSuanZhi.ZeroPrize = rsdv.ZeroPrize
|
|
jiSuanZhi.CappingVal = rsdv.CappingVal
|
|
jiSuanZhi.Achievement = rsdv.Achievement
|
|
|
|
outCont.Score = append(outCont.Score, jiSuanZhi)
|
|
if len(rsdv.ExecutiveDepartment) > 0 { //写入执行考核的部门
|
|
for _, edv := range rsdv.ExecutiveDepartment {
|
|
if commonus.IsItTrueString(edv, outCont.ExecutiveDepartment) == false {
|
|
outCont.ExecutiveDepartment = append(outCont.ExecutiveDepartment, edv)
|
|
}
|
|
}
|
|
}
|
|
|
|
stccStatistics.ScoreVal = append(stccStatistics.ScoreVal, rsdv.ScoreVal)
|
|
stccStatistics.AllPrize = append(stccStatistics.AllPrize, rsdv.AllPrize)
|
|
stccStatistics.ZeroPrize = append(stccStatistics.ZeroPrize, rsdv.ZeroPrize)
|
|
stccStatistics.CappingVal = append(stccStatistics.CappingVal, rsdv.CappingVal)
|
|
stccStatistics.ActualScore = append(stccStatistics.ActualScore, rsdv.ActualScore)
|
|
stccStatistics.Achievement = append(stccStatistics.Achievement, rsdv.Achievement)
|
|
}
|
|
}
|
|
}
|
|
outCont.ScoreAllList = append(outCont.ScoreAllList, stccStatistics)
|
|
outCont.StatisticsName = []string{"全奖值", "零奖值", "封顶值", "实际值", "达成率", "得分"}
|
|
if isAdd == 1 {
|
|
d.outData = append(d.outData, outCont)
|
|
}
|
|
|
|
}
|
|
|
|
// }
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
//当版本内容为空时
|
|
}
|
|
syncProcess.Done()
|
|
}
|
|
|