Browse Source

手办

qin_1
超级管理员 4 years ago
parent
commit
a653994247
  1. 69
      gin_server_admin/api/index/evaluation/enter.go
  2. 20
      gin_server_admin/api/index/evaluation/evaluation.go
  3. 323
      gin_server_admin/api/index/evaluation/flowsendnew.go
  4. 8
      gin_server_admin/api/index/statistics/dataform.go
  5. 55
      gin_server_admin/api/index/statistics/programme.go
  6. 55
      gin_server_admin/api/index/statistics/tablestatistics.go
  7. 327
      gin_server_admin/api/reply/quan/ration.go
  8. 59
      gin_server_admin/api/statistics/quantification/auxiliarycalculation.go
  9. 506
      gin_server_admin/api/statistics/quantification/departmentstatisc.go
  10. 32
      gin_server_admin/api/statistics/quantification/enter.go
  11. 305
      gin_server_admin/api/statistics/quantification/jisuanshuzhi.go
  12. 283
      gin_server_admin/api/statistics/quantification/quant.go
  13. 537
      gin_server_admin/api/statistics/quantification/shiyan.go
  14. 996
      gin_server_admin/api/statistics/quantification/timestatistics.go
  15. 146
      gin_server_admin/commonus/publichaneld.go

69
gin_server_admin/api/index/evaluation/enter.go

@ -1,6 +1,8 @@
package evaluation package evaluation
import ( import (
"fmt"
"github.com/flipped-aurora/gin-vue-admin/server/commonus" "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/global"
"github.com/flipped-aurora/gin-vue-admin/server/model/assessmentmodel" "github.com/flipped-aurora/gin-vue-admin/server/model/assessmentmodel"
@ -46,49 +48,62 @@ func GetQuantitativeConfig(targetScore int64, resultval float64, group, depart,
// } // }
gormDb = gormDb.Where("timecopy = ?", timecopy) gormDb = gormDb.Where("timecopy = ?", timecopy)
err := gormDb.First(&qualConfig).Error err := gormDb.First(&qualConfig).Error
// fmt.Printf("达成率--3-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v\n", group, depart, dimen, target, year, allPrize, zeroPrize, CappingVal, achievement)
// fmt.Printf("达成率--0-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v\n", group, depart, dimen, target, year, allPrize, zeroPrize, CappingVal, achievement, err) // fmt.Printf("达成率--0-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v\n", group, depart, dimen, target, year, allPrize, zeroPrize, CappingVal, achievement, err)
if err != nil { if err != nil {
achievement = 100
scoreVal = float64(targetScore)
return return
} }
scoreVal, allPrize, zeroPrize, CappingVal, achievement = commonus.CalculateScore(targetScore, resultval, qualConfig.Allprize, qualConfig.Zeroprize, qualConfig.CappingVal)
return
allPrize = qualConfig.Allprize / 100 allPrize = qualConfig.Allprize / 100
zeroPrize = qualConfig.Zeroprize / 100 zeroPrize = qualConfig.Zeroprize / 100
CappingVal = qualConfig.CappingVal / 100 CappingVal = qualConfig.CappingVal / 100
fmt.Printf("达成率--4-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v\n", group, depart, dimen, target, year, allPrize, zeroPrize, CappingVal, achievement)
if allPrize == 0 && zeroPrize == 0 {
achievement = 100
scoreVal = float64(targetScore)
fmt.Printf("达成率--5-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v\n", group, depart, dimen, target, year, allPrize, zeroPrize, CappingVal, achievement)
} else {
if allPrize == 0 && resultval == 0 {
achievement = 0
scoreVal = 0
} else {
chuShu := resultval - float64(qualConfig.Zeroprize) chuShu := resultval - float64(qualConfig.Zeroprize)
beiChuShu := float64(qualConfig.Allprize) - float64(qualConfig.Zeroprize) beiChuShu := float64(qualConfig.Allprize) - float64(qualConfig.Zeroprize)
if beiChuShu > 0 {
if beiChuShu != 0 {
achievement = commonus.Decimal(chuShu / beiChuShu) achievement = commonus.Decimal(chuShu / beiChuShu)
scoreVal = achievement * (resultval / 100) if achievement <= 0 {
achievement = 0
scoreVal = 0
fmt.Printf("达成率--6-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v\n", group, depart, dimen, target, year, allPrize, zeroPrize, CappingVal, achievement)
} else {
// scoreVal = achievement * (resultval / 100)
scoreVal = achievement * (float64(targetScore))
achievement = commonus.Decimal(achievement * 100) achievement = commonus.Decimal(achievement * 100)
if achievement >= CappingVal { if achievement >= CappingVal {
scoreVal = CappingVal * float64(targetScore) / 100 scoreVal = CappingVal * float64(targetScore) / 100
fmt.Printf("达成率--9-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v\n", group, depart, dimen, target, year, allPrize, zeroPrize, CappingVal, achievement)
}
fmt.Printf("达成率--7-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v\n", group, depart, dimen, target, year, allPrize, zeroPrize, CappingVal, achievement)
} }
} else { } else {
scoreVal = float64(targetScore) achievement = 0
scoreVal = 0
fmt.Printf("达成率--8-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v\n", group, depart, dimen, target, year, allPrize, zeroPrize, CappingVal, achievement)
}
} }
// if qualConfig.CappingVal != 0 && resultval >= qualConfig.CappingVal { }
// scoreVal = float64(targetScore) scoreVal = commonus.Decimal(scoreVal)
// achievement = 100 allPrize = commonus.Decimal(allPrize)
// // fmt.Printf("达成率--1-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v\n", group, depart, dimen, target, year, allPrize, zeroPrize, CappingVal, achievement) zeroPrize = commonus.Decimal(zeroPrize)
// } else { CappingVal = commonus.Decimal(CappingVal)
// chuShu := resultval - float64(qualConfig.Zeroprize) achievement = commonus.Decimal(achievement)
// beiChuShu := float64(qualConfig.Allprize) - float64(qualConfig.Zeroprize)
// if beiChuShu > 0 {
// achievement = commonus.Decimal(chuShu / beiChuShu)
// scoreVal = achievement * (resultval / 100)
// if scoreVal >= CappingVal {
// scoreVal = CappingVal * float64(targetScore)
// }
// fmt.Printf("达成率--2-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v\n", group, depart, dimen, target, year, allPrize, zeroPrize, CappingVal, achievement, resultval)
// } else {
// scoreVal = float64(targetScore)
// // fmt.Printf("达成率--3-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v\n", group, depart, dimen, target, year, allPrize, zeroPrize, CappingVal, achievement)
// }
// }
// fmt.Printf("达成率--4-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v\n", group, depart, dimen, target, year, allPrize, zeroPrize, CappingVal, achievement)
return return
} }

20
gin_server_admin/api/index/evaluation/evaluation.go

@ -740,12 +740,12 @@ func (e *EvaluationInterface) QualitativeEvalRation(c *gin.Context) {
} }
//获取当月的起止时间 //获取当月的起止时间
startMonth, endMonth := commonus.GetAppointMonthStarAndEndTimeInt(time.Now().Unix()) // startMonth, endMonth := commonus.GetAppointMonthStarAndEndTimeInt(time.Now().Unix())
//获取当月内所有的审批流程的部门及指标ID //获取当月内所有的审批流程的部门及指标ID
// var qualEvalFlowLogList QualEvalFlowLog // var qualEvalFlowLogList QualEvalFlowLog
var evalId []int64 // var evalId []int64
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.FlowLog{}).Select("fl_evaluation_id").Where("fl_time BETWEEN ? AND ?", startMonth, endMonth).Find(&evalId) // global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.FlowLog{}).Select("fl_evaluation_id").Where("fl_time BETWEEN ? AND ?", startMonth, endMonth).Find(&evalId)
// var qualEvaList []assessmentmodel.QualitativeEvaluation // var qualEvaList []assessmentmodel.QualitativeEvaluation
// var detailsId []int64 // var detailsId []int64
@ -758,9 +758,10 @@ func (e *EvaluationInterface) QualitativeEvalRation(c *gin.Context) {
var qualEvaList []assessmentmodel.QualitativeEvaluation var qualEvaList []assessmentmodel.QualitativeEvaluation
gormDbIng := global.GVA_DB_Performanceappraisal gormDbIng := global.GVA_DB_Performanceappraisal
gormDbIng = gormDbIng.Where("`qe_type` = 2 AND `qe_state` = 1 AND FIND_IN_SET(?,`qe_operator`)", userCont.Key) gormDbIng = gormDbIng.Where("`qe_type` = 2 AND `qe_state` = 1 AND FIND_IN_SET(?,`qe_operator`)", userCont.Key)
if len(evalId) > 0 { //判断是否已经提交上个月的数据
gormDbIng = gormDbIng.Not(map[string]interface{}{"qe_id": evalId}) // if len(evalId) > 0 {
} // gormDbIng = gormDbIng.Not(map[string]interface{}{"qe_id": evalId})
// }
if requestData.GroupId != "" { if requestData.GroupId != "" {
gormDbIng = gormDbIng.Where("qe_group = ?", requestData.GroupId) gormDbIng = gormDbIng.Where("qe_group = ?", requestData.GroupId)
} }
@ -1717,7 +1718,7 @@ func (d *EvaluationInterface) LookRationkScoreFlow(c *gin.Context) {
if jsonFlowErr == nil { if jsonFlowErr == nil {
} }
} }
fmt.Printf("evalProInfo.NextExecutor-------------->%v\n", evalProInfo.NextExecutor) // fmt.Printf("evalProInfo.NextExecutor-------------->%v\n", evalProInfo.NextExecutor)
if evalProInfo.NextExecutor != "" { if evalProInfo.NextExecutor != "" {
zhiXingRenAry := strings.Split(evalProInfo.NextExecutor, ",") zhiXingRenAry := strings.Split(evalProInfo.NextExecutor, ",")
if commonus.IsItTrueString(userCont.Key, zhiXingRenAry) == true { if commonus.IsItTrueString(userCont.Key, zhiXingRenAry) == true {
@ -1736,7 +1737,7 @@ func (d *EvaluationInterface) LookRationkScoreFlow(c *gin.Context) {
if getErrs == nil { if getErrs == nil {
titlekUserInfo, _ := commonus.GetNewHrPeopleInfo(map[string]interface{}{"`key`": flowLogInfo.EvaluationUser}, "`name`") titlekUserInfo, _ := commonus.GetNewHrPeopleInfo(map[string]interface{}{"`key`": flowLogInfo.EvaluationUser}, "`name`")
// titlekUserInfo, _ := commonus.GetWorkUser(strconv.FormatInt(flowLogInfo.EvaluationUser, 10)) // titlekUserInfo, _ := commonus.GetWorkUser(strconv.FormatInt(flowLogInfo.EvaluationUser, 10))
titleStr := fmt.Sprintf("%v提交的%v年%v月定量考核数据", titlekUserInfo.Name, flowLogInfo.Year, flowLogInfo.Month) titleStr := fmt.Sprintf("%v提交的", titlekUserInfo.Name)
// gErr, groupInfo := commonus.GetGroupCont(flowLogInfo.DutyGroup) // gErr, groupInfo := commonus.GetGroupCont(flowLogInfo.DutyGroup)
groupInfo, gErr := commonus.GetNewOrgCont(flowLogInfo.DutyGroup) groupInfo, gErr := commonus.GetNewOrgCont(flowLogInfo.DutyGroup)
if gErr == nil { if gErr == nil {
@ -1749,10 +1750,11 @@ func (d *EvaluationInterface) LookRationkScoreFlow(c *gin.Context) {
BranchInfo, dErr := commonus.GetNewOrgCont(flowLogInfo.DutyDepartment) BranchInfo, dErr := commonus.GetNewOrgCont(flowLogInfo.DutyDepartment)
if dErr == nil { if dErr == nil {
outListMap["departmentname"] = BranchInfo.Name outListMap["departmentname"] = BranchInfo.Name
titleStr = fmt.Sprintf("%v%v", BranchInfo.Name, titleStr) titleStr = fmt.Sprintf("%v%v", titleStr, BranchInfo.Name)
} else { } else {
outListMap["departmentname"] = "" outListMap["departmentname"] = ""
} }
titleStr = fmt.Sprintf("%v%v年%v月定量考核数据", titleStr, flowLogInfo.Year, flowLogInfo.Month)
outListMap["title"] = titleStr outListMap["title"] = titleStr
} }

323
gin_server_admin/api/index/evaluation/flowsendnew.go

@ -16,7 +16,7 @@ import (
) )
//加减分 //加减分
func (e *EvaluationInterface) PlusOrMinusPointsNew(c *gin.Context) { func (e *EvaluationInterface) PlusOrMinusPointsNewYuan(c *gin.Context) {
isTrue, userCont := commonus.ClientIdentity() isTrue, userCont := commonus.ClientIdentity()
if isTrue != true { if isTrue != true {
response.Result(1001, isTrue, "您的身份令牌已经失效!请重新登录获取身份令牌!", c) response.Result(1001, isTrue, "您的身份令牌已经失效!请重新登录获取身份令牌!", c)
@ -322,3 +322,324 @@ func (e *EvaluationInterface) PlusOrMinusPointsNew(c *gin.Context) {
response.Result(0, outMap, "数据写入成功", c) response.Result(0, outMap, "数据写入成功", c)
} }
//加减分
func (e *EvaluationInterface) PlusOrMinusPointsNew(c *gin.Context) {
isTrue, userCont := commonus.ClientIdentity()
if isTrue != true {
response.Result(1001, isTrue, "您的身份令牌已经失效!请重新登录获取身份令牌!", c)
return
}
var requestData addPlusOrMinusPoints
err := c.ShouldBindJSON(&requestData)
if err != nil {
response.Result(102, err, "数据获取失败!", c)
return
}
if requestData.PlanId == "" {
response.Result(103, requestData, "未知考核项目!请检查你的提交是否正确!", c)
return
}
planIdInt, planIdIntErr := strconv.ParseInt(requestData.PlanId, 10, 64)
if planIdIntErr != nil {
response.Result(104, requestData, "未知考核项目!请检查你的提交是否正确!", c)
return
}
//获取考核项目内容
var programme assessmentmodel.QualitativeEvaluation
judgeProgramme := global.GVA_DB_Performanceappraisal.Where("`qe_id` = ?", planIdInt).First(&programme).Error
if judgeProgramme != nil {
response.Result(105, programme, "未知考核项目!请检查你的提交是否正确!", c)
return
}
if requestData.Type == 0 {
response.Result(106, requestData, "请问您是要进行加分还是减分?请指定,谢谢!", c)
return
}
countFrequency := 1
if requestData.Count != 0 {
countFrequency = requestData.Count
}
switch requestData.State {
case 2, 3:
if requestData.Score == "" {
response.Result(107, requestData, "请您输入要操作的分数,谢谢!", c)
return
}
tijaoFenshu := commonus.GetDuyCycle(requestData.Score, 100)
if tijaoFenshu > programme.MaxScore {
response.Result(107, requestData, fmt.Sprintf("您提交的分数操作允许提交的最大值(最大值:%v)!", float64(programme.MaxScore)/100), c)
return
}
if tijaoFenshu < programme.MinScore {
response.Result(107, requestData, fmt.Sprintf("您提交的分数操作允许提交的最大值(最小值:%v)!", float64(programme.MinScore)/100), c)
return
}
case 1:
//获取分数
requestData.Score = strconv.FormatInt(programme.MaxScore, 10)
default:
if requestData.Score == "" {
response.Result(107, requestData, "请您输入要操作的分数,谢谢!", c)
return
}
}
if requestData.Reason == "" {
response.Result(108, requestData, "请输入您的原因,谢谢!", c)
return
}
if requestData.Addtime == "" {
response.Result(108, requestData, "请输入您的检查时间,谢谢!", c)
return
}
if requestData.Rectification == 0 {
requestData.Rectification = 2
}
var correctionTime int64 = 0
if requestData.Rectification == 1 {
if requestData.CorrectionTime == "" {
response.Result(108, requestData, "请输入整改期限,谢谢!", c)
return
}
var corrTimeErr bool = false
correctionTime, corrTimeErr = commonus.DateToTimeStampEs(requestData.CorrectionTime)
if corrTimeErr == false {
response.Result(108, requestData, "请输入整改期限时间格式不对,谢谢!", c)
return
}
}
operationTime := time.Now().Unix()
keyNumber := commonus.GetFileNumberEs()
var addScore assessmentmodel.ScoreFlow
addScore.EvaluationPlan = planIdInt //考核方案项目ID
addScore.PlusReduceScore = requestData.Type //1:加分;2:减分
addScore.PlanVersion = requestData.PlanVersionNumber
//分值转化
scoreStringToInt64 := commonus.GetDuyCycle(requestData.Score, 100)
addScore.Score = scoreStringToInt64 //分值(乘100录入)
addScore.Key = keyNumber //识别标志
addScore.Reason = requestData.Reason //操作原因
addScore.Time = operationTime
addScore.EiteTime = operationTime
addScore.Count = countFrequency //发生次数
timeOccurrence := commonus.DateToTimeStamp(requestData.Addtime) //发生时间
addScore.HappenTime = timeOccurrence
// addScore.HappenTime = commonus.DateToTimeStamp(requestData.Addtime) //发生时间
departmentId, departmentIdErr := strconv.ParseInt(userCont.Deparment, 10, 64)
if departmentIdErr == nil {
addScore.EvaluationDepartment = departmentId //测评部门
}
userKey, userKeyErr := strconv.ParseInt(userCont.Key, 10, 64)
if userKeyErr == nil {
addScore.EvaluationUser = userKey //测评人
}
userGroup, userGroupErr := strconv.ParseInt(userCont.Company, 10, 64)
if userGroupErr == nil {
addScore.EvaluationGroup = userGroup //测评集团
}
//获取拆分时间节
addScore.Year = commonus.ComputingTime(timeOccurrence, 1)
addScore.Quarter = commonus.ComputingTime(timeOccurrence, 2)
addScore.Month = commonus.ComputingTime(timeOccurrence, 3)
addScore.Week = commonus.ComputingTime(timeOccurrence, 4)
// addScore.Year = commonus.ComputingTime(operationTime, 1)
// addScore.Quarter = commonus.ComputingTime(operationTime, 2)
// addScore.Month = commonus.ComputingTime(operationTime, 3)
// addScore.Week = commonus.ComputingTime(operationTime, 4)
if len(requestData.Enclosure) > 0 {
enclosure, enclosureErr := json.Marshal(requestData.Enclosure)
if enclosureErr == nil {
addScore.Enclosure = string(enclosure) //附件
}
}
addScore.DutyGroup = programme.Group //职责集团
addScore.DutyDepartment = programme.AcceptEvaluation //职责部门
addScore.Rectification = requestData.Rectification //1、需要整改;2:无需整改
addScore.Reply = 1
addScore.CorrectionTime = correctionTime
addErr := global.GVA_DB_Performanceappraisal.Create(&addScore).Error
//步进内容
if addErr != nil {
response.Result(109, addErr, "数据写入失败", c)
return
}
myIsTrue := 1
//流程审批相关
//生成唯一编号
registerNumber := commonus.GetFileNumberEs()
//将步骤写入
var registerCont assessmentmodel.Register
registerCont.Number = registerNumber
registerCont.State = 1
registerCont.Time = time.Now().Unix()
registerCont.AddCont()
//审批卡片跳转链接
// cardJumpUrl := fmt.Sprintf("http://new.hxgk.group/#/approvalList?id=%v&num=%v", keyNumber, strconv.FormatInt(registerNumber, 10))
// jumpUrl := fmt.Sprintf("http://new.hxgk.group/#/responsible?id=%v&num=%v", keyNumber, strconv.FormatInt(registerNumber, 10))
// jumpUrlTitle := "请前往处理"
// sourceDesc := commonus.GetSetpName(2)
//获取通知人信息
//1、获取发起人部门负责人
// var officWorkUserList string
founderDepartId, _ := strconv.ParseInt(userCont.Deparment, 10, 64)
// sendUserIsTrue, sendUserList := commonus.GetSendMsgUserAry(16182159043990656, founderDepartId) //获取对应部门负责人
// if sendUserIsTrue != true {
// response.Result(0, sendUserList, "未指定相关部门处理人!请确定部门负责人后,重新发起请求!", c)
// return
// }
// for _, v := range sendUserList {
// if v == userCont.Wechat {
// myIsTrue = 2
// }
// }
// fmt.Printf("userCont.Wechat====>%v------------>myIsTrue:%v------------>sendUserList:%v\n", userCont.Wechat, myIsTrue, sendUserList)
// officWorkUserList = strings.Join(sendUserList, "|")
// //确定标题
// var title string = ""
// //一级标题副本内容
// var desc string = ""
// detailedTargetCont, detailedTargetErr := commonus.GetDetailedTargetInfo(programme.DetailedTarget) //获取指标细则
// if detailedTargetErr == true {
// tarInf, tarErr := commonus.GetTargetInfo(detailedTargetCont.ParentId) //获取指标信息
// if tarErr == true {
// title = tarInf.Title //一级标题,建议不超过36个字
// desc = detailedTargetCont.Title //一级标题辅助信息,建议不超过44个字
// } else {
// title = detailedTargetCont.Title //一级标题,建议不超过36个字
// }
// } else {
// tarInf, tarErr := commonus.GetTargetInfo(programme.Target) //获取指标信息
// if tarErr == true {
// title = tarInf.Title //一级标题,建议不超过36个字
// } else {
// title = strconv.FormatInt(programme.DetailedTarget, 10) //一级标题,建议不超过36个字
// }
// }
// //执行原因
// reason := fmt.Sprintf("原因:%v\n", requestData.Reason)
// twoLevelKeyName := ""
// execDerpat, execDerpatErr := commonus.GetNewOrgCont(departmentId)
// if execDerpatErr == nil {
// twoLevelKeyName = execDerpat.Name
// }
// var twoLevelKeyValue string = ""
// var twoLevelUserId string = ""
// //获取操作人
// if userCont.Wechat != "" {
// userWechatErr, userWechat := commonus.GetUesrContForWechatID(userCont.Wechat)
// if userWechatErr == true {
// twoLevelKeyValue = userWechat.Name
// twoLevelUserId = userCont.Wechat
// }
// }
// twoLevelTitle := "考核上报部门:"
//分数
// sendScore := scoreStringToInt64 * int64(countFrequency)
// sendScVal := float64(sendScore) / 100
// scoreFloat64ToStringsss := strconv.FormatFloat(sendScVal, 'f', -1, 64)
outMap := commonus.MapOut()
// var quoteAreaTitle string //引用文献标题
if requestData.Type != 1 {
//减分
// quoteAreaTitle = fmt.Sprintf("考核减分:%v\n", scoreFloat64ToStringsss)
if myIsTrue != 1 {
//申请人也是部门负责人
commonus.StepAddDataEs(keyNumber, 0, 2, 1, 1, 1, 1, userCont.Key, requestData.Enclosure)
userKeyInt, _ := strconv.ParseInt(userCont.Key, 10, 64)
commonus.WriteReplyLog(keyNumber, programme.AcceptEvaluation, founderDepartId, userKeyInt, 1, commonus.GetSetpName(1), "")
commonus.StepAddData(keyNumber, 16182159043990656, 3, 2, 1, 2, 2, userCont.Key)
commonus.WriteReplyLog(keyNumber, programme.AcceptEvaluation, founderDepartId, userKeyInt, 1, commonus.GetSetpName(2), "同意")
// sendUserIsTrue, sendUserList := commonus.GetSendMsgUser(16118387069540343, programme.AcceptEvaluation) //获取对应部门内勤
// if sendUserIsTrue != true {
// response.Result(0, sendUserList, "未指定相关部门处理人!未能向相关人员发送考核项目!请手动发起!", c)
// return
// }
// jumpUrl := fmt.Sprintf("http://new.hxgk.group/#/responsible?id=%v&num=%v", keyNumber, strconv.FormatInt(registerNumber, 10))
// jumpUrlTitle := "请前往处理"
// sourceDesc := "责任划分"
// var sendTextMsg sendmessage.TextNoticeTemplateMedium
// callbakcMsg, isTrueCall, callBackCont := sendTextMsg.SendMsgTextShare(sendUserList, strconv.FormatInt(registerNumber, 10), title, desc, quoteAreaTitle, reason, twoLevelTitle, twoLevelKeyName, twoLevelKeyValue, twoLevelUserId, cardJumpUrl, jumpUrl, jumpUrlTitle, sourceDesc)
// outMap["callbakcMsg"] = string(callbakcMsg)
// outMap["isTrueCall"] = isTrueCall
// outMap["callBackCont"] = callBackCont
// outMap["setval"] = 1
//修改定性审批流状态
eiteScoreFlow := commonus.MapOut()
eiteScoreFlow["sf_eite_time"] = time.Now().Unix()
eiteScoreFlow["sf_reply"] = 2
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.ScoreFlow{}).Where("`sf_key` = ?", keyNumber).Updates(&eiteScoreFlow)
evalProcSaveData := commonus.MapOut()
evalProcSaveData["ep_state"] = 2
evalProcSaveData["ep_time"] = time.Now().Unix()
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.EvaluationProcess{}).Where("`ep_order_key` = ?", keyNumber).Updates(&evalProcSaveData)
} else {
//申请人不是是部门负责人 给本部门负责人发送审批
commonus.StepAddDataEs(keyNumber, 16182159043990656, 2, 1, 1, 1, 1, userCont.Key, requestData.Enclosure)
// jumpUrl := fmt.Sprintf("http://new.hxgk.group/#/approvalList?id=%v&num=%v", keyNumber, strconv.FormatInt(registerNumber, 10))
// jumpUrlTitle := "请前往处理"
// sourceDesc := "审核"
// var sendTextMsg sendmessage.TextNoticeTemplateMedium
// callbakcMsg, isTrueCall, callBackCont := sendTextMsg.SendMsgTextShare(officWorkUserList, strconv.FormatInt(registerNumber, 10), title, desc, quoteAreaTitle, reason, twoLevelTitle, twoLevelKeyName, twoLevelKeyValue, twoLevelUserId, cardJumpUrl, jumpUrl, jumpUrlTitle, sourceDesc)
// outMap["callbakcMsg"] = string(callbakcMsg)
// outMap["isTrueCall"] = isTrueCall
// outMap["callBackCont"] = callBackCont
// outMap["setval"] = 2
userKeyInt, _ := strconv.ParseInt(userCont.Key, 10, 64)
commonus.WriteReplyLog(keyNumber, programme.AcceptEvaluation, founderDepartId, userKeyInt, 1, commonus.GetSetpName(1), "")
eiteScoreFlow := commonus.MapOut()
eiteScoreFlow["sf_eite_time"] = time.Now().Unix()
eiteScoreFlow["sf_reply"] = 2
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.ScoreFlow{}).Where("`sf_key` = ?", keyNumber).Updates(&eiteScoreFlow)
evalProcSaveData := commonus.MapOut()
evalProcSaveData["ep_state"] = 2
evalProcSaveData["ep_time"] = time.Now().Unix()
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.EvaluationProcess{}).Where("`ep_order_key` = ?", keyNumber).Updates(&evalProcSaveData)
}
} else {
//加分
// quoteAreaTitle = fmt.Sprintf("考核加分:%v\n", scoreFloat64ToStringsss)
commonus.StepAddDataEs(keyNumber, 16182159043990656, 2, 7, 1, 1, 1, userCont.Key, requestData.Enclosure)
// jumpUrl := fmt.Sprintf("http://new.hxgk.group/#/approvalList?id=%v&num=%v", keyNumber, strconv.FormatInt(registerNumber, 10))
// jumpUrlTitle := "请前往处理"
// sourceDesc := "审核"
// var sendTextMsg sendmessage.TextNoticeTemplateMedium
// callbakcMsg, isTrueCall, callBackCont := sendTextMsg.SendMsgTextShare(officWorkUserList, strconv.FormatInt(registerNumber, 10), title, desc, quoteAreaTitle, reason, twoLevelTitle, twoLevelKeyName, twoLevelKeyValue, twoLevelUserId, cardJumpUrl, jumpUrl, jumpUrlTitle, sourceDesc)
// outMap["callbakcMsg"] = string(callbakcMsg)
// outMap["isTrueCall"] = isTrueCall
// outMap["callBackCont"] = callBackCont
// outMap["setval"] = 3
userKeyInt, _ := strconv.ParseInt(userCont.Key, 10, 64)
commonus.WriteReplyLog(keyNumber, programme.AcceptEvaluation, founderDepartId, userKeyInt, 1, commonus.GetSetpName(1), "")
eiteScoreFlow := commonus.MapOut()
eiteScoreFlow["sf_eite_time"] = time.Now().Unix()
eiteScoreFlow["sf_reply"] = 2
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.ScoreFlow{}).Where("`sf_key` = ?", keyNumber).Updates(&eiteScoreFlow)
evalProcSaveData := commonus.MapOut()
evalProcSaveData["ep_state"] = 2
evalProcSaveData["ep_time"] = time.Now().Unix()
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.EvaluationProcess{}).Where("`ep_order_key` = ?", keyNumber).Updates(&evalProcSaveData)
}
response.Result(0, outMap, "数据写入成功", c)
}

8
gin_server_admin/api/index/statistics/dataform.go

@ -398,7 +398,7 @@ func (a *ApiGroup) GetPlanVersionValides(c *gin.Context) {
jiSuanZhi.Class = 2 jiSuanZhi.Class = 2
jiSuanZhi.ScoreVal = resultData jiSuanZhi.ScoreVal = resultData
jiSuanZhi.ActualScore = float64(pcv.ReferenceScore) jiSuanZhi.ActualScore = float64(pcv.ReferenceScore)
jiSuanZhi.AllPrize, jiSuanZhi.ZeroPrize, jiSuanZhi.CappingVal, jiSuanZhi.Achievement = quantification.GetQuantitativeConfigEs(resultData, strconv.FormatInt(v.Group, 10), strconv.FormatInt(v.Department, 10), pv.Id, pcv.Id, "0", yserInt, i) 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)
outCont.Score = append(outCont.Score, jiSuanZhi) outCont.Score = append(outCont.Score, jiSuanZhi)
stccStatistics.ScoreVal = append(stccStatistics.ScoreVal, resultData) stccStatistics.ScoreVal = append(stccStatistics.ScoreVal, resultData)
@ -452,7 +452,7 @@ func (a *ApiGroup) GetPlanVersionValides(c *gin.Context) {
jiSuanZhi.Class = 2 jiSuanZhi.Class = 2
jiSuanZhi.ScoreVal = resultData jiSuanZhi.ScoreVal = resultData
jiSuanZhi.ActualScore = float64(pcv.ReferenceScore) jiSuanZhi.ActualScore = float64(pcv.ReferenceScore)
jiSuanZhi.AllPrize, jiSuanZhi.ZeroPrize, jiSuanZhi.CappingVal, jiSuanZhi.Achievement = quantification.GetQuantitativeConfigEs(resultData, strconv.FormatInt(v.Group, 10), strconv.FormatInt(v.Department, 10), pv.Id, pcv.Id, "0", yserInt, i) 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)
outCont.Score = append(outCont.Score, jiSuanZhi) outCont.Score = append(outCont.Score, jiSuanZhi)
stccStatistics.ScoreVal = append(stccStatistics.ScoreVal, resultData) stccStatistics.ScoreVal = append(stccStatistics.ScoreVal, resultData)
stccStatistics.AllPrize = append(stccStatistics.AllPrize, jiSuanZhi.AllPrize) stccStatistics.AllPrize = append(stccStatistics.AllPrize, jiSuanZhi.AllPrize)
@ -508,7 +508,7 @@ func (a *ApiGroup) GetPlanVersionValides(c *gin.Context) {
jiSuanZhi.Class = 2 jiSuanZhi.Class = 2
jiSuanZhi.ScoreVal = resultData jiSuanZhi.ScoreVal = resultData
jiSuanZhi.ActualScore = float64(pcv.ReferenceScore) jiSuanZhi.ActualScore = float64(pcv.ReferenceScore)
jiSuanZhi.AllPrize, jiSuanZhi.ZeroPrize, jiSuanZhi.CappingVal, jiSuanZhi.Achievement = quantification.GetQuantitativeConfigEs(resultData, strconv.FormatInt(v.Group, 10), strconv.FormatInt(v.Department, 10), pv.Id, pcv.Id, "0", yserInt, 0) 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)
outCont.Score = append(outCont.Score, jiSuanZhi) outCont.Score = append(outCont.Score, jiSuanZhi)
stccStatistics.ScoreVal = append(stccStatistics.ScoreVal, resultData) stccStatistics.ScoreVal = append(stccStatistics.ScoreVal, resultData)
@ -568,7 +568,7 @@ func (a *ApiGroup) GetPlanVersionValides(c *gin.Context) {
jiSuanZhi.Class = 2 jiSuanZhi.Class = 2
jiSuanZhi.ScoreVal = resultData jiSuanZhi.ScoreVal = resultData
jiSuanZhi.ActualScore = float64(pcv.ReferenceScore) jiSuanZhi.ActualScore = float64(pcv.ReferenceScore)
jiSuanZhi.AllPrize, jiSuanZhi.ZeroPrize, jiSuanZhi.CappingVal, jiSuanZhi.Achievement = quantification.GetQuantitativeConfigEs(resultData, strconv.FormatInt(v.Group, 10), strconv.FormatInt(v.Department, 10), pv.Id, pcv.Id, "0", yserInt, i) 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)
outCont.Score = append(outCont.Score, jiSuanZhi) outCont.Score = append(outCont.Score, jiSuanZhi)
stccStatistics.ScoreVal = append(stccStatistics.ScoreVal, resultData) stccStatistics.ScoreVal = append(stccStatistics.ScoreVal, resultData)

55
gin_server_admin/api/index/statistics/programme.go

@ -12,7 +12,6 @@ import (
"github.com/flipped-aurora/gin-vue-admin/server/global" "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/assessmentmodel"
"github.com/flipped-aurora/gin-vue-admin/server/model/common/response" "github.com/flipped-aurora/gin-vue-admin/server/model/common/response"
"github.com/flipped-aurora/gin-vue-admin/server/model/hrsystem"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )
@ -322,36 +321,36 @@ func getDepartTarget(key, dimeId, targetId, group, accDepartId string) (qualId i
var qualEvalCont assessmentmodel.QualitativeEvaluation var qualEvalCont assessmentmodel.QualitativeEvaluation
err = global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.QualitativeEvaluation{}).Select("qe_id,qe_department_id,qe_type,qe_cycle,qe_cycleattr,qe_operator").Where("qe_qual_eval_id = ? AND qe_dimension = ? AND qe_target = ? AND qe_accept_evaluation = ? AND qe_group = ? AND qe_state = 1", key, dimeId, targetId, accDepartId, group).First(&qualEvalCont).Error err = global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.QualitativeEvaluation{}).Select("qe_id,qe_department_id,qe_type,qe_cycle,qe_cycleattr,qe_operator").Where("qe_qual_eval_id = ? AND qe_dimension = ? AND qe_target = ? AND qe_accept_evaluation = ? AND qe_group = ? AND qe_state = 1", key, dimeId, targetId, accDepartId, group).First(&qualEvalCont).Error
departId = strings.Split(qualEvalCont.DepartmentId, ",") departId = strings.Split(qualEvalCont.DepartmentId, ",")
// if len(departId) > 0 { if len(departId) > 0 {
// for _, v := range departId { for _, v := range departId {
// fmt.Printf("部门Id =====>%v\n", v) // fmt.Printf("部门Id =====>%v\n", v)
// // where := commonus.MapOut() where := commonus.MapOut()
// // where["id"] = v where["id"] = v
// // orgCont, _ := commonus.GetNewOrgCont(where, "id", "name") orgCont, _ := commonus.GetNewOrgCont(where, "id", "name")
// // departName = append(departName, orgCont.Name) departName = append(departName, orgCont.Name)
}
}
// if qualEvalCont.Operator != "" {
// zxrId := strings.Split(qualEvalCont.Operator, ",")
// var zxbm []string
// global.GVA_DB_HrDataBase.Model(&hrsystem.Personnel{}).Select("`deparment`").Where("`key` IN ?", zxrId).Find(&zxbm)
// if len(zxbm) > 0 {
// var buMenIdAry []string
// for _, dv := range zxbm {
// zxmbid := strings.Split(dv, ",")
// if len(zxmbid) > 0 {
// for _, zv := range zxmbid {
// if commonus.IsItTrueString(zv, buMenIdAry) == false {
// buMenIdAry = append(buMenIdAry, zv)
// }
// }
// }
// }
// if len(buMenIdAry) > 0 {
// global.GVA_DB_HrDataBase.Model(&hrsystem.AdministrativeOrganization{}).Select("`name`").Where("`id` IN ?", buMenIdAry).Find(&departName)
// }
// } // }
// } // }
if qualEvalCont.Operator != "" {
zxrId := strings.Split(qualEvalCont.Operator, ",")
var zxbm []string
global.GVA_DB_HrDataBase.Model(&hrsystem.Personnel{}).Select("`deparment`").Where("`key` IN ?", zxrId).Find(&zxbm)
if len(zxbm) > 0 {
var buMenIdAry []string
for _, dv := range zxbm {
zxmbid := strings.Split(dv, ",")
if len(zxmbid) > 0 {
for _, zv := range zxmbid {
if commonus.IsItTrueString(zv, buMenIdAry) == false {
buMenIdAry = append(buMenIdAry, zv)
}
}
}
}
if len(buMenIdAry) > 0 {
global.GVA_DB_HrDataBase.Model(&hrsystem.AdministrativeOrganization{}).Select("`name`").Where("`id` IN ?", buMenIdAry).Find(&departName)
}
}
}
isDuty = qualEvalCont.Type isDuty = qualEvalCont.Type
cycle = qualEvalCont.Cycles cycle = qualEvalCont.Cycles

55
gin_server_admin/api/index/statistics/tablestatistics.go

@ -51,14 +51,14 @@ func (a *ApiGroup) GetPlanVersionValid(c *gin.Context) {
gormDb = gormDb.Where("`department` = ? ", requestData.DeaprtId) gormDb = gormDb.Where("`department` = ? ", requestData.DeaprtId)
} }
default: default:
// gormDb = gormDb.Where("`group` = ? AND `department` = ?", userCont.Company, userCont.Deparment) 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)
} }
// if requestData.Group != "" {
// gormDb = gormDb.Where("`group` = ? ", requestData.Group)
// }
// if requestData.DeaprtId != "" {
// gormDb = gormDb.Where("`department` = ? ", requestData.DeaprtId)
// }
err := gormDb.Find(&planVersioCont).Error err := gormDb.Find(&planVersioCont).Error
if err != nil { if err != nil {
response.Result(102, err, "没有查询到数据", c) response.Result(102, err, "没有查询到数据", c)
@ -136,8 +136,16 @@ func (d *dataLockStatistics) planVersiconProcess(pvInfo assessmentmodel.PlanVers
outCont.Type = isDuty outCont.Type = isDuty
} }
} else { } 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 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 var stccStatistics ScoreListAry
stccStatistics.Class = isDuty stccStatistics.Class = isDuty
if isDuty == 1 { if isDuty == 1 {
@ -384,7 +392,7 @@ func (d *dataLockStatistics) planVersiconProcess(pvInfo assessmentmodel.PlanVers
}) })
// jsonVal, jsonErr := json.Marshal(readStatisticsData) // jsonVal, jsonErr := json.Marshal(readStatisticsData)
// fmt.Printf("排序------%v--------》%v--------》%v\n", pvInfo.Id, string(jsonVal), jsonErr) // fmt.Printf("排序------%v--------》%v--------》%v\n", pvInfo.Id, string(jsonVal), jsonErr)
// panic(readStatisticsData)
for _, rsdv := range readStatisticsData { for _, rsdv := range readStatisticsData {
// for ik := 0; ik <= 1; ik++ { // for ik := 0; ik <= 1; ik++ {
// var jiSuanZhiBuLing ScoreList // var jiSuanZhiBuLing ScoreList
@ -399,12 +407,22 @@ func (d *dataLockStatistics) planVersiconProcess(pvInfo assessmentmodel.PlanVers
var jiSuanZhi ScoreList var jiSuanZhi ScoreList
jiSuanZhi.Class = rsdv.Class jiSuanZhi.Class = rsdv.Class
jiSuanZhi.ScoreVal = rsdv.ScoreVal jiSuanZhi.ScoreVal = rsdv.ScoreVal
jiSuanZhi.ActualScore = rsdv.ActualScore
jiSuanZhi.AllPrize = rsdv.AllPrize jiSuanZhi.AllPrize = rsdv.AllPrize
jiSuanZhi.ZeroPrize = rsdv.ZeroPrize jiSuanZhi.ZeroPrize = rsdv.ZeroPrize
jiSuanZhi.CappingVal = rsdv.CappingVal jiSuanZhi.CappingVal = rsdv.CappingVal
jiSuanZhi.ActualScore = rsdv.ActualScore
jiSuanZhi.Achievement = rsdv.Achievement 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) outCont.Score = append(outCont.Score, jiSuanZhi)
if len(rsdv.ExecutiveDepartment) > 0 { //写入执行考核的部门 if len(rsdv.ExecutiveDepartment) > 0 { //写入执行考核的部门
for _, edv := range rsdv.ExecutiveDepartment { for _, edv := range rsdv.ExecutiveDepartment {
@ -628,19 +646,32 @@ func (t *tablePlanVersionStic) conditionStatistics(wherStr, group, department, d
// fmt.Printf("年--3-->%v--->%v\n", wherStr, yserInt) // fmt.Printf("年--3-->%v--->%v\n", wherStr, yserInt)
//组装数据 //组装数据
resultData := commonus.Decimal(sumScore / 100) // resultData := commonus.Decimal(sumScore / 100)
resultData := sumScore
tableScoreCont.Class = class tableScoreCont.Class = class
tableScoreCont.ScoreVal = resultData tableScoreCont.ScoreVal = commonus.Decimal(sumScore / 100)
if status != 3 { if status != 3 {
tableScoreCont.ActualScore, tableScoreCont.AllPrize, tableScoreCont.ZeroPrize, tableScoreCont.CappingVal, tableScoreCont.Achievement = quantification.GetQuantitativeConfig(referenceScore, resultData, group, department, dimensionId, targetId, "0", yserInt, i) tableScoreCont.ActualScore, tableScoreCont.AllPrize, tableScoreCont.ZeroPrize, tableScoreCont.CappingVal, tableScoreCont.Achievement = quantification.GetQuantitativeConfig(referenceScore, resultData, group, department, dimensionId, targetId, "0", yserInt, i)
t.TableScore = append(t.TableScore, tableScoreCont) t.TableScore = append(t.TableScore, tableScoreCont)
} else { } else {
tableScoreCont.ActualScore = float64(referenceScore) tableScoreCont.ActualScore = float64(referenceScore)
tableScoreCont.AllPrize, tableScoreCont.ZeroPrize, tableScoreCont.CappingVal, tableScoreCont.Achievement = quantification.GetQuantitativeConfigEs(resultData, group, department, dimensionId, targetId, "0", yserInt, i) tableScoreCont.ActualScore, tableScoreCont.AllPrize, tableScoreCont.ZeroPrize, tableScoreCont.CappingVal, tableScoreCont.Achievement = quantification.GetQuantitativeConfigEs(referenceScore, resultData, group, department, dimensionId, targetId, "0", yserInt, i)
t.TableScore = append(t.TableScore, tableScoreCont) t.TableScore = append(t.TableScore, tableScoreCont)
} }
// tableScoreCont.ActualScore = commonus.Decimal(tableScoreCont.ActualScore / 100)
syncProcessDepartTarget.Done() 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"` //达成率
// }
} }
//定性 //定性

327
gin_server_admin/api/reply/quan/ration.go

@ -15,7 +15,7 @@ import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )
func (a *ApiGroup) SendRationFlow(c *gin.Context) { func (a *ApiGroup) SendRationFlowYuan(c *gin.Context) {
isTrue, userCont := commonus.ClientIdentity() isTrue, userCont := commonus.ClientIdentity()
if isTrue != true { if isTrue != true {
response.Result(1001, isTrue, "您的身份令牌已经失效!请重新登录获取身份令牌!", c) response.Result(1001, isTrue, "您的身份令牌已经失效!请重新登录获取身份令牌!", c)
@ -330,3 +330,328 @@ func (a *ApiGroup) SendRationFlow(c *gin.Context) {
} }
} }
} }
func (a *ApiGroup) SendRationFlow(c *gin.Context) {
isTrue, userCont := commonus.ClientIdentity()
if isTrue != true {
response.Result(1001, isTrue, "您的身份令牌已经失效!请重新登录获取身份令牌!", c)
return
}
userKey, userKeyErr := strconv.ParseInt(userCont.Key, 10, 64)
if userKeyErr != nil {
response.Result(102, isTrue, "您的身份令牌已经失效!请重新登录获取身份令牌!", c)
return
}
departmentId, departmentIdErr := strconv.ParseInt(userCont.Deparment, 10, 64)
if departmentIdErr != nil {
response.Result(103, isTrue, "您的身份令牌已经失效!请重新登录获取身份令牌!", c)
return
}
userGroup, userGroupErr := strconv.ParseInt(userCont.Company, 10, 64)
if userGroupErr != nil {
response.Result(104, isTrue, "您的身份令牌已经失效!请重新登录获取身份令牌!", c)
return
}
todaying := commonus.ComputingTime(time.Now().Unix(), 5)
if todaying > 10 {
// response.Result(1051, todaying, "不在可提交数据提时间期限内!不可提交数据。请每月10号前提交数据!。", c)
// return
}
var requestData AddRationFlowLog
err := c.ShouldBindJSON(&requestData)
if err != nil {
response.Result(105, err, "数据获取失败!", c)
return
}
if requestData.GroupId == "" {
response.Result(106, err, "数据异常!", c)
return
}
if requestData.DepartmentID == "" {
response.Result(107, err, "数据异常!", c)
return
}
if len(requestData.List) < 1 {
response.Result(108, err, "没有要考核的项目", c)
return
}
//判断是否已经添加的条件
existenceProess := commonus.MapOut()
existenceProess["fl_planversion"] = requestData.PlanVersionNumber
operationTime := time.Now().Unix()
keyNumber := commonus.GetFileNumberEs()
var flowLog assessmentmodel.FlowLog
flowLog.Key = keyNumber
flowLog.Time = time.Now().Unix()
flowLog.EiteTime = time.Now().Unix()
flowLog.PlanVersion = requestData.PlanVersionNumber
if requestData.Addtime != "" {
timeOccurrence := commonus.DateToTimeStamp(requestData.Addtime) //发生时间
flowLog.Year = commonus.ComputingTime(timeOccurrence, 1)
flowLog.Quarter = commonus.ComputingTime(timeOccurrence, 2)
flowLog.Month = commonus.ComputingTime(timeOccurrence, 3)
flowLog.Week = commonus.ComputingTime(timeOccurrence, 4)
flowLog.ToDay = commonus.ComputingTime(timeOccurrence, 5)
existenceProess["fl_year"] = commonus.ComputingTime(timeOccurrence, 1)
existenceProess["fl_quarter"] = commonus.ComputingTime(timeOccurrence, 2)
existenceProess["fl_month"] = commonus.ComputingTime(timeOccurrence, 3)
existenceProess["fl_week"] = commonus.ComputingTime(timeOccurrence, 4)
existenceProess["fl_day"] = commonus.ComputingTime(timeOccurrence, 5)
} else {
lastMonth, _, _ := commonus.GetLastMonth()
lastMonthInt, lastMonthErr := commonus.DateToTimeStampEs(fmt.Sprintf("%v-10 12:00:00", lastMonth))
if lastMonthErr == true {
operationTime = lastMonthInt
}
flowLog.Year = commonus.ComputingTime(operationTime, 1)
flowLog.Quarter = commonus.ComputingTime(operationTime, 2)
flowLog.Month = commonus.ComputingTime(operationTime, 3)
flowLog.Week = commonus.ComputingTime(operationTime, 4)
flowLog.ToDay = commonus.ComputingTime(operationTime, 5)
existenceProess["fl_year"] = commonus.ComputingTime(operationTime, 1)
existenceProess["fl_quarter"] = commonus.ComputingTime(operationTime, 2)
existenceProess["fl_month"] = commonus.ComputingTime(operationTime, 3)
existenceProess["fl_week"] = commonus.ComputingTime(operationTime, 4)
existenceProess["fl_day"] = commonus.ComputingTime(operationTime, 5)
}
flowLog.EvaluationDepartment = departmentId
flowLog.EvaluationUser = userKey
flowLog.EvaluationGroup = userGroup
// existenceProess["fl_evaluation_department"] = departmentId
// existenceProess["fl_evaluation_user"] = userKey
// existenceProess["fl_evaluation_group"] = userGroup
dutyGroup, dutyGroupErr := strconv.ParseInt(requestData.GroupId, 10, 64)
if dutyGroupErr == nil {
flowLog.DutyGroup = dutyGroup
existenceProess["fl_duty_group"] = dutyGroup
}
departIdInt, departIdIntErr := strconv.ParseInt(requestData.DepartmentID, 10, 64)
if departIdIntErr == nil {
flowLog.DutyDepartment = departIdInt
existenceProess["fl_duty_department"] = departIdInt
}
flowLog.Reply = 2
var evaluationIdStr string
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.FlowLog{}).Select("fl_evaluation_id").Where(existenceProess).First(&evaluationIdStr)
var evaluationIdStrAry []string
// if evaluationIdStr != "" {
// evaluationIdStrAry = strings.Split(evaluationIdStr, ",")
// }
var flowDataLogAry []assessmentmodel.FlowLogData
var reason string
var evaluationPlan []string //方案ID
var yiTianJianMingc []string
// jsonMapStr, _ := json.Marshal(requestData.List)
json.Marshal(requestData.List)
//fmt.Printf("OutJsonMap-----1------>%\n", string(jsonMapStr))
for i, v := range requestData.List {
if len(evaluationIdStrAry) > 0 {
if commonus.IsItTrueString(v.Id, evaluationIdStrAry) == false {
var flowDataLog assessmentmodel.FlowLogData
evaluationPlan = append(evaluationPlan, v.Id)
evaluationPlanid, evaluationPlanidErr := strconv.ParseInt(v.Id, 10, 64)
if evaluationPlanidErr == nil {
flowDataLog.EvaluationPlan = evaluationPlanid
}
flowDataLog.Key = keyNumber
flowDataLog.Score = commonus.GetDuyCycle(v.Actual, 100)
flowDataLog.Content = v.Reason
flowDataLog.Enclosure = strings.Join(v.Enclosure, ",")
if v.ScoringMethod == 2 {
flowDataLog.ScoringMethod = 2
flowDataLog.ScoringScore = v.ScoringScore
} else {
flowDataLog.ScoringMethod = 1
flowDataLog.ScoringScore = 0
}
// flowDataLog.PlanVersion = v.PlanVersionNumber
flowDataLog.Time = time.Now().Unix()
targetInfo, targetInfoErr := commonus.GetQualitativeEvaluation(strconv.FormatInt(evaluationPlanid, 10))
tarInfo, _ := commonus.GetTargetInfo(targetInfo.Target)
if i == 0 {
if targetInfoErr == true {
if v.Reason != "" {
reason = fmt.Sprintf("%v :%v%v\n备注:%v", tarInfo.Title, v.Actual, v.Unit, v.Reason)
} else {
reason = fmt.Sprintf("%v :%v%v", tarInfo.Title, v.Actual, v.Unit)
}
}
} else {
if targetInfoErr == true {
if v.Reason != "" {
reason = fmt.Sprintf("%v\n%v :%v%v\n备注:%v", reason, tarInfo.Title, v.Actual, v.Unit, v.Reason)
} else {
reason = fmt.Sprintf("%v\n%v :%v%v", reason, tarInfo.Title, v.Actual, v.Unit)
}
}
}
flowDataLogAry = append(flowDataLogAry, flowDataLog)
} else {
yiTianJianMingc = append(yiTianJianMingc, v.TargetName)
}
} else {
var flowDataLog assessmentmodel.FlowLogData
evaluationPlan = append(evaluationPlan, v.Id)
evaluationPlanid, evaluationPlanidErr := strconv.ParseInt(v.Id, 10, 64)
if evaluationPlanidErr == nil {
flowDataLog.EvaluationPlan = evaluationPlanid
}
flowDataLog.Key = keyNumber
flowDataLog.Score = commonus.GetDuyCycle(v.Actual, 100)
flowDataLog.Content = v.Reason
flowDataLog.Enclosure = strings.Join(v.Enclosure, ",")
if v.ScoringMethod == 2 {
flowDataLog.ScoringMethod = 2
flowDataLog.ScoringScore = v.ScoringScore
} else {
flowDataLog.ScoringMethod = 1
flowDataLog.ScoringScore = 0
}
flowDataLog.PlanVersion = requestData.PlanVersionNumber
flowDataLog.Time = time.Now().Unix()
targetInfo, targetInfoErr := commonus.GetQualitativeEvaluation(strconv.FormatInt(evaluationPlanid, 10))
tarInfo, _ := commonus.GetTargetInfo(targetInfo.Target)
if i == 0 {
if targetInfoErr == true {
if v.Reason != "" {
reason = fmt.Sprintf("%v :%v%v\n备注:%v", tarInfo.Title, v.Actual, v.Unit, v.Reason)
} else {
reason = fmt.Sprintf("%v :%v%v", tarInfo.Title, v.Actual, v.Unit)
}
}
} else {
if targetInfoErr == true {
if v.Reason != "" {
reason = fmt.Sprintf("%v\n%v :%v%v\n备注:%v", reason, tarInfo.Title, v.Actual, v.Unit, v.Reason)
} else {
reason = fmt.Sprintf("%v\n%v :%v%v", reason, tarInfo.Title, v.Actual, v.Unit)
}
}
}
flowDataLogAry = append(flowDataLogAry, flowDataLog)
}
}
gromDb := global.GVA_DB_Performanceappraisal.Begin()
flowLog.EvaluationPlan = strings.Join(evaluationPlan, ",")
if len(flowDataLogAry) <= 0 {
response.Result(0, yiTianJianMingc, "您的数据已经提交!请不要重复提交!", c)
return
}
addFlowLogErr := gromDb.Create(&flowLog).Error
addFlowLogDataErr := gromDb.Create(&flowDataLogAry).Error
if addFlowLogErr == nil && addFlowLogDataErr == nil {
affairDbErr := gromDb.Commit().Error
if affairDbErr == nil {
commonus.StepAddData(keyNumber, 16182159043990656, 2, 7, 2, 2, 1, userCont.Key)
commonus.WriteReplyLog(keyNumber, departIdInt, departmentId, userKey, 1, commonus.GetSetpName(1), "提交申请")
// sendUserIsTrue, sendUserList := commonus.GetSendMsgUser(16182159043990656, departIdInt) //获取对应部门负责人
// if sendUserIsTrue != true {
// response.Result(0, sendUserList, "未指定相关部门处理人!未能向相关人员发送考核项目!请手动发起!", c)
// return
// }
// title := fmt.Sprintf("%v数据表", commonus.TimeStampToDate(operationTime, 10))
// desc := ""
// mainTitleDesc := "数据详情:"
// //将步骤写入 判断该步骤是否已经操作
// registerNumber := commonus.GetFileNumberEs()
// var registerContIng assessmentmodel.Register
// registerContIng.Number = registerNumber
// registerContIng.State = 1
// registerContIng.Time = time.Now().Unix()
// registerContIng.AddCont()
//审批卡片跳转链接
// cardJumpUrl := fmt.Sprintf("http://new.hxgk.group/#/quantitativeList?id=%v&num=%v", keyNumber, strconv.FormatInt(registerNumber, 10))
// jumpUrl := fmt.Sprintf("http://new.hxgk.group/#/quantitativeList?id=%v&num=%v", keyNumber, strconv.FormatInt(registerNumber, 10))
// jumpUrlTitle := "请前往处理"
// sourceDesc := "审批"
// twoLevelTitle := "审批信息:"
// twoLevelKeyName := ""
// execDerpat, execDerpatErr := commonus.GetNewOrgCont(departmentId)
// if execDerpatErr == nil {
// twoLevelKeyName = execDerpat.Name
// }
// var twoLevelKeyValue string = ""
// var twoLevelUserId string = ""
// //获取操作人
// if userCont.Wechat != "" {
// userWechatErr, userWechat := commonus.GetUesrContForWechatID(userCont.Wechat)
// if userWechatErr == true {
// twoLevelKeyValue = userWechat.Name
// twoLevelUserId = userCont.Wechat
// }
// }
// var sendTextMsg sendmessage.TextNoticeTemplateMedium
// callbakcMsg, isTrueCall, callBackCont := sendTextMsg.SendMsgTextShare(sendUserList, strconv.FormatInt(registerNumber, 10), title, desc, mainTitleDesc, reason, twoLevelTitle, twoLevelKeyName, twoLevelKeyValue, twoLevelUserId, cardJumpUrl, jumpUrl, jumpUrlTitle, sourceDesc)
//发送文本信息通用
/*SendMsgTextShare(sendUserList, taskId, title, desc, quoteAreaTitle, quoteAreaContent, twoLevelTitle, twoLevelKeyName, twoLevelKeyValue, twoLevelUserId, cardJumpUrl, jumpUrl, jumpUrlTitle, sourceDesc string) (callbakcMsg []byte, isTrueCall bool, callBackCont string)
@sendUserList 信息接收人
@taskId 任务id同一个应用任务id不能重复只能由数字字母和_-@组成最长128字节填了action_menu字段的话本字段必填
@Title 一级标题建议不超过36个字
@Desc 标题辅助信息建议不超过44个字
@quoteAreaTitle 引用文献标题
@quoteAreaContent 引用文献内容
@twoLevelTitle 二级文本标题
@twoLevelKeyName 二级标题建议不超过5个字
@twoLevelValue 二级文本如果horizontal_content_list.type是2该字段代表文件名称要包含文件类型建议不超过30个字
@twoLevelUserId 成员详情的useridhorizontal_content_list.type是3时必填
@cardJumpUrl 整体卡片跳转链接
@jumpUrl 底部标题跳转链接
@jumpUrlTitle 跳转链接文案
@sourceDesc 左上角标题
*/
eiteScoreFlow := commonus.MapOut()
eiteScoreFlow["sf_eite_time"] = time.Now().Unix()
eiteScoreFlow["sf_reply"] = 2
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.ScoreFlow{}).Where("`sf_key` = ?", keyNumber).Updates(&eiteScoreFlow)
evalProcSaveData := commonus.MapOut()
evalProcSaveData["ep_state"] = 2
evalProcSaveData["ep_time"] = time.Now().Unix()
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.EvaluationProcess{}).Where("`ep_order_key` = ?", keyNumber).Updates(&evalProcSaveData)
outMap := commonus.MapOut()
// outMap["callbakcMsg"] = string(callbakcMsg)
// outMap["isTrueCall"] = isTrueCall
// outMap["callBackCont"] = callBackCont
outMap["setval"] = 1
response.Result(0, outMap, "数据提交成功!", c)
} else {
gromDb.Rollback()
response.Result(118, yiTianJianMingc, "数据提交失败!", c)
}
} else {
affairDbErr := gromDb.Rollback().Error
if affairDbErr == nil {
response.Result(119, yiTianJianMingc, "数据提交失败!", c)
} else {
response.Result(120, yiTianJianMingc, "数据提交失败!", c)
}
}
}

59
gin_server_admin/api/statistics/quantification/auxiliarycalculation.go

@ -49,43 +49,75 @@ func AverageOfSum(where interface{}, class ...int) (sumScore float64, averageSco
func EstimatedTime(dataAry natureParameter) (timeFrame []TimeFrame) { func EstimatedTime(dataAry natureParameter) (timeFrame []TimeFrame) {
if len(dataAry.Year) > 0 { if len(dataAry.Year) > 0 {
switch dataAry.TimeAttribute.Class { switch dataAry.TimeAttribute.Class {
case 1: case 1: //半年
for _, yearV := range dataAry.Year { // for _, yearV := range dataAry.Year {
// if len(dataAry.TimeAttribute.Time) > 0 {
// for _, banYearVal := range dataAry.TimeAttribute.Time {
// if banYearVal == 1 {
// var timeFrameInfo TimeFrame
// timeFrameInfo.XLine = fmt.Sprintf("%v上半年", yearV)
// timeFrameInfo.Class = 1
// timeFrameInfo.YearName = yearV
// timeFrameInfo.Where = []int{1, 2, 3, 4, 5, 6}
// timeFrame = append(timeFrame, timeFrameInfo)
// }
// if banYearVal == 2 {
// var timeFrameInfo TimeFrame
// timeFrameInfo.XLine = fmt.Sprintf("%v下半年", yearV)
// timeFrameInfo.Class = 1
// timeFrameInfo.YearName = yearV
// timeFrameInfo.Where = []int{7, 8, 9, 10, 11, 12}
// timeFrame = append(timeFrame, timeFrameInfo)
// }
// }
// } else {
// var timeFrameInfo TimeFrame
// timeFrameInfo.XLine = fmt.Sprintf("%v上半年", yearV)
// timeFrameInfo.Class = 1
// timeFrameInfo.YearName = yearV
// timeFrameInfo.Where = []int{1, 2, 3, 4, 5, 6}
// timeFrame = append(timeFrame, timeFrameInfo)
// var timeFrameInfoXia TimeFrame
// timeFrameInfoXia.XLine = fmt.Sprintf("%v下半年", yearV)
// timeFrameInfoXia.Class = 1
// timeFrameInfoXia.YearName = yearV
// timeFrameInfoXia.Where = []int{7, 8, 9, 10, 11, 12}
// timeFrame = append(timeFrame, timeFrameInfoXia)
// }
// }
if len(dataAry.TimeAttribute.Time) > 0 { if len(dataAry.TimeAttribute.Time) > 0 {
for _, banYearVal := range dataAry.TimeAttribute.Time { for _, banYearVal := range dataAry.TimeAttribute.Time {
if banYearVal == 1 { if banYearVal == 1 {
var timeFrameInfo TimeFrame var timeFrameInfo TimeFrame
timeFrameInfo.XLine = fmt.Sprintf("%v上半年", yearV) timeFrameInfo.XLine = fmt.Sprintf("上半年")
timeFrameInfo.Class = 1 timeFrameInfo.Class = 1
timeFrameInfo.YearName = yearV timeFrameInfo.YearName = "1"
timeFrameInfo.Where = []int{1, 2, 3, 4, 5, 6} timeFrameInfo.Where = []int{1, 2, 3, 4, 5, 6}
timeFrame = append(timeFrame, timeFrameInfo) timeFrame = append(timeFrame, timeFrameInfo)
} }
if banYearVal == 2 { if banYearVal == 2 {
var timeFrameInfo TimeFrame var timeFrameInfo TimeFrame
timeFrameInfo.XLine = fmt.Sprintf("%v下半年", yearV) timeFrameInfo.XLine = fmt.Sprintf("下半年")
timeFrameInfo.Class = 1 timeFrameInfo.Class = 1
timeFrameInfo.YearName = yearV timeFrameInfo.YearName = "2"
timeFrameInfo.Where = []int{7, 8, 9, 10, 11, 12} timeFrameInfo.Where = []int{7, 8, 9, 10, 11, 12}
timeFrame = append(timeFrame, timeFrameInfo) timeFrame = append(timeFrame, timeFrameInfo)
} }
} }
} else { } else {
var timeFrameInfo TimeFrame var timeFrameInfo TimeFrame
timeFrameInfo.XLine = fmt.Sprintf("%v上半年", yearV) timeFrameInfo.XLine = fmt.Sprintf("上半年")
timeFrameInfo.Class = 1 timeFrameInfo.Class = 1
timeFrameInfo.YearName = yearV timeFrameInfo.YearName = "1"
timeFrameInfo.Where = []int{1, 2, 3, 4, 5, 6} timeFrameInfo.Where = []int{1, 2, 3, 4, 5, 6}
timeFrame = append(timeFrame, timeFrameInfo) timeFrame = append(timeFrame, timeFrameInfo)
var timeFrameInfoXia TimeFrame var timeFrameInfoXia TimeFrame
timeFrameInfoXia.XLine = fmt.Sprintf("%v下半年", yearV) timeFrameInfoXia.XLine = fmt.Sprintf("下半年")
timeFrameInfoXia.Class = 1 timeFrameInfoXia.Class = 1
timeFrameInfoXia.YearName = yearV timeFrameInfoXia.YearName = "2"
timeFrameInfoXia.Where = []int{7, 8, 9, 10, 11, 12} timeFrameInfoXia.Where = []int{7, 8, 9, 10, 11, 12}
timeFrame = append(timeFrame, timeFrameInfoXia) timeFrame = append(timeFrame, timeFrameInfoXia)
} }
}
case 2: case 2:
if len(dataAry.TimeAttribute.Time) > 0 && len(dataAry.TimeAttribute.Time) < 5 { if len(dataAry.TimeAttribute.Time) > 0 && len(dataAry.TimeAttribute.Time) < 5 {
for _, quarV := range dataAry.TimeAttribute.Time { for _, quarV := range dataAry.TimeAttribute.Time {
@ -143,6 +175,7 @@ func EstimatedTime(dataAry natureParameter) (timeFrame []TimeFrame) {
var timeFrameInfo TimeFrame var timeFrameInfo TimeFrame
timeFrameInfo.XLine = fmt.Sprintf("%v年", dangQianYear) timeFrameInfo.XLine = fmt.Sprintf("%v年", dangQianYear)
timeFrameInfo.Class = 0 timeFrameInfo.Class = 0
timeFrameInfo.YearName = dangQianYear
yearInt, _ := strconv.Atoi(dangQianYear) yearInt, _ := strconv.Atoi(dangQianYear)
timeFrameInfo.Where = append(timeFrameInfo.Where, yearInt) timeFrameInfo.Where = append(timeFrameInfo.Where, yearInt)
timeFrame = append(timeFrame, timeFrameInfo) timeFrame = append(timeFrame, timeFrameInfo)
@ -155,7 +188,7 @@ func EstimatedTime(dataAry natureParameter) (timeFrame []TimeFrame) {
@taskId 执行中的考核方案ID @taskId 执行中的考核方案ID
@dataAry 接收的界定参数 @dataAry 接收的界定参数
*/ */
func TimeDimensionStatistics(taskId string, dataAry natureParameter) (outputData GraphicStatistics, outErr bool) { func TimeStatistics(taskId string, dataAry natureParameter) (outputData GraphicStatistics, outErr bool) {
outErr = true outErr = true
var normName string = "" var normName string = ""
if len(dataAry.TargetId) > 1 { if len(dataAry.TargetId) > 1 {

506
gin_server_admin/api/statistics/quantification/departmentstatisc.go

@ -1,42 +1,57 @@
package quantification package quantification
import ( import (
"encoding/json"
"fmt" "fmt"
"strconv"
"time"
"github.com/flipped-aurora/gin-vue-admin/server/commonus" "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/assessmentmodel"
) )
//行政维度统计计算 //行政维度统计计算
/* /*
@taskId 执行中的考核方案ID @taskId 执行中的考核方案ID弃用 指标ID
@dataAry 接收的界定参数 @dataAry 接收的界定参数
*/ */
func OrgDimensionStatistics(taskId string, dataAry natureParameter) (outputData GraphicStatistics, outErr bool) { func OrgDimensionStatistics(taskId string, dataAry natureParameter) (outputData GraphicStatistics, outErr bool) {
//当同时查询多个指标时启用 获取指标名称 //当同时查询多个指标时启用 获取指标名称
outErr = true outErr = true
var normName string = "" var normName string = ""
if len(dataAry.TargetId) > 1 { norm := 1 //1:定性考核;2:定量考核
// if len(dataAry.TargetId) > 1 {
//当同时查询多个指标时启用 获取指标名称 //当同时查询多个指标时启用 获取指标名称
var qualEvalCont assessmentmodel.QualitativeEvaluation // var qualEvalCont assessmentmodel.QualitativeEvaluation
qualEvaWhe := commonus.MapOut() // qualEvaWhe := commonus.MapOut()
qualEvaWhe["qe_id"] = taskId // qualEvaWhe["qe_id"] = taskId
qualEvalCont.GetCont(qualEvaWhe, "qe_target") // qualEvalCont.GetCont(qualEvaWhe, "qe_target", "qe_type")
taskCont, taskErr := commonus.GetTargetInfo(qualEvalCont.Target) // taskCont, taskErr := commonus.GetTargetIn
taskIdInt, _ := strconv.ParseInt(taskId, 10, 64)
taskCont, taskErr := commonus.GetTargetInfo(taskIdInt)
if taskErr == true { if taskErr == true {
normName = taskCont.Title normName = taskCont.Title
outErr = taskErr outErr = taskErr
norm = taskCont.Type
} else { } else {
// outErr = error.Error("此考核项目没有数据!") // outErr = error.Error("此考核项目没有数据!")
outErr = taskErr outErr = taskErr
return return
} }
} // }
//获取时间参数 //获取时间参数
timeFrame := EstimatedTime(dataAry) timeFrame := EstimatedTime(dataAry)
//获取组织架构参数 //获取组织架构参数
orgAry, orgList := getGroupOrg(dataAry.Org) // orgAry, orgList := getGroupOrgList(dataAry.Org)
//获取组织架构参数
// var orgAry []orgModelsAry
var orgList []orgModels
if len(dataAry.Org) > 0 {
_, orgList = getGroupOrgList(dataAry.Org)
} else {
_, orgList = getGroupOrgList(GetTargerDepartment(taskCont.Dimension, taskIdInt))
}
//统计方式 //统计方式
statisticalMethod := 3 statisticalMethod := 3
if len(dataAry.AccMethod) == 1 { if len(dataAry.AccMethod) == 1 {
@ -48,27 +63,484 @@ func OrgDimensionStatistics(taskId string, dataAry natureParameter) (outputData
} }
for _, v := range orgList { for _, v := range orgList {
//获取此指标跟查询部门相关的考核方案ID
var taskIdAry []int64
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.QualitativeEvaluation{}).Select("qe_id").Where("qe_state = 1 AND qe_dimension = ? AND qe_target = ? AND qe_accept_evaluation IN ?", taskCont.Dimension, taskIdInt, v.SunOrg).Find(&taskIdAry)
orgvSunOrg := "("
for tiai, tiav := range v.SunOrg {
if tiai != 0 {
orgvSunOrg = fmt.Sprintf("%v,%v", orgvSunOrg, tiav)
} else {
orgvSunOrg = fmt.Sprintf("%v%v", orgvSunOrg, tiav)
}
}
orgvSunOrg = fmt.Sprintf("%v)", orgvSunOrg)
//组合考核方案ID
taskIdStrWher := "("
for tiai, tiav := range taskIdAry {
if tiai != 0 {
taskIdStrWher = fmt.Sprintf("%v,%v", taskIdStrWher, tiav)
} else {
taskIdStrWher = fmt.Sprintf("%v%v", taskIdStrWher, tiav)
}
}
taskIdStrWher = fmt.Sprintf("%v)", taskIdStrWher)
if commonus.IsItTrueString(v.Name, outputData.XLine) == false { if commonus.IsItTrueString(v.Name, outputData.XLine) == false {
outputData.XLine = append(outputData.XLine, v.Name) outputData.XLine = append(outputData.XLine, v.Name)
for _, tv := range timeFrame { //在部门维度下进行时间跨度计算 for _, tv := range timeFrame { //在部门维度下进行时间跨度计算
switch tv.Class { switch tv.Class {
case 1: //半年 case 1: //半年
//组合月
monthStr := "("
for twi, twv := range tv.Where {
if twi != 0 {
monthStr = fmt.Sprintf("%v,%v", monthStr, twv)
} else {
monthStr = fmt.Sprintf("%v%v", monthStr, twv)
}
}
monthStr = fmt.Sprintf("%v)", monthStr)
if len(dataAry.Year) > 0 {
for _, dayv := range dataAry.Year {
var sumScore float64
var averageScore float64
if norm == 1 {
//定性考核
wherStr := fmt.Sprintf("sf_evaluation_plan IN %v AND `sf_year` = %v AND `sf_month` IN %v AND sf_duty_department IN %v", taskIdStrWher, dayv, monthStr, orgvSunOrg)
sumScore, averageScore = AverageOfSumNature(wherStr, 1)
} else {
//定量考核
//定量考核
wherStr := fmt.Sprintf("fld_evaluation_id IN %v AND `fl_year` = %v AND `fl_month` IN %v AND fl_duty_department IN %v", taskIdStrWher, dayv, monthStr, orgvSunOrg)
sumScore, averageScore = AverageOfSum(wherStr)
}
//判断计算总值还是平均值
switch statisticalMethod {
case 1:
// sumScore, _ := AverageOfSum(wherStr)
normNameTotal := fmt.Sprintf("%v%v %v总值", dayv, tv.XLine, normName)
if commonus.IsItTrueString(normNameTotal, outputData.Cylindrical) == false {
outputData.Cylindrical = append(outputData.Cylindrical, normNameTotal)
var seriesInfo series
seriesInfo.Name = normNameTotal
seriesInfo.Data = append(seriesInfo.Data, sumScore)
outputData.CylindricalData = append(outputData.CylindricalData, seriesInfo)
} else {
for cdi, cdv := range outputData.CylindricalData {
if cdv.Name == normNameTotal {
outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, sumScore)
}
}
}
case 2:
// _, averageScore := AverageOfSum(wherStr, 1)
normNameAverage := fmt.Sprintf("%v%v %v平均值", dayv, tv.XLine, normName)
if commonus.IsItTrueString(normNameAverage, outputData.Cylindrical) == false {
outputData.Cylindrical = append(outputData.Cylindrical, normNameAverage)
var seriesInfoAverage series
seriesInfoAverage.Name = normNameAverage
seriesInfoAverage.Data = append(seriesInfoAverage.Data, averageScore)
outputData.CylindricalData = append(outputData.CylindricalData, seriesInfoAverage)
} else {
for cdi, cdv := range outputData.CylindricalData {
if cdv.Name == normNameAverage {
outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, averageScore)
}
}
}
default:
//合计与平均
// sumScore, averageScore := AverageOfSum(wherStr, 1)
normNameTotal := fmt.Sprintf("%v%v %v总值", dayv, tv.XLine, normName)
if commonus.IsItTrueString(normNameTotal, outputData.Cylindrical) == false {
outputData.Cylindrical = append(outputData.Cylindrical, normNameTotal)
var seriesInfo series
seriesInfo.Name = normNameTotal
seriesInfo.Data = append(seriesInfo.Data, sumScore)
outputData.CylindricalData = append(outputData.CylindricalData, seriesInfo)
} else {
for cdi, cdv := range outputData.CylindricalData {
if cdv.Name == normNameTotal {
outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, sumScore)
}
}
}
normNameAverage := fmt.Sprintf("%v%v %v平均值", dayv, tv.XLine, normName)
if commonus.IsItTrueString(normNameAverage, outputData.Cylindrical) == false {
outputData.Cylindrical = append(outputData.Cylindrical, normNameAverage)
var seriesInfoAverage series
seriesInfoAverage.Name = normNameAverage
seriesInfoAverage.Data = append(seriesInfoAverage.Data, averageScore)
outputData.CylindricalData = append(outputData.CylindricalData, seriesInfoAverage)
} else {
for cdi, cdv := range outputData.CylindricalData {
if cdv.Name == normNameAverage {
outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, averageScore)
}
}
}
}
}
} else {
var sumScore float64
var averageScore float64
yearVal := commonus.ComputingTime(time.Now().Unix(), 1)
if norm == 1 {
//定性考核
wherStr := fmt.Sprintf("sf_evaluation_plan IN %v AND `sf_year` = %v AND `sf_month` IN %v AND sf_duty_department IN %v", taskIdStrWher, yearVal, monthStr, orgvSunOrg)
sumScore, averageScore = AverageOfSumNature(wherStr, 1)
} else {
//定量考核
wherStr := fmt.Sprintf("fld_evaluation_id IN %v AND `fl_year` = %v AND `fl_month` IN %v AND fl_duty_department IN %v", taskIdStrWher, yearVal, monthStr, orgvSunOrg)
sumScore, averageScore = AverageOfSum(wherStr)
}
//判断计算总值还是平均值
switch statisticalMethod {
case 1:
// sumScore, _ := AverageOfSum(wherStr)
normNameTotal := fmt.Sprintf("%v %v总值", tv.XLine, normName)
if commonus.IsItTrueString(normNameTotal, outputData.Cylindrical) == false {
outputData.Cylindrical = append(outputData.Cylindrical, normNameTotal)
var seriesInfo series
seriesInfo.Name = normNameTotal
seriesInfo.Data = append(seriesInfo.Data, sumScore)
outputData.CylindricalData = append(outputData.CylindricalData, seriesInfo)
} else {
for cdi, cdv := range outputData.CylindricalData {
if cdv.Name == normNameTotal {
outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, sumScore)
}
}
}
case 2:
// _, averageScore := AverageOfSum(wherStr, 1)
normNameAverage := fmt.Sprintf("%v %v平均值", tv.XLine, normName)
if commonus.IsItTrueString(normNameAverage, outputData.Cylindrical) == false {
outputData.Cylindrical = append(outputData.Cylindrical, normNameAverage)
var seriesInfoAverage series
seriesInfoAverage.Name = normNameAverage
seriesInfoAverage.Data = append(seriesInfoAverage.Data, averageScore)
outputData.CylindricalData = append(outputData.CylindricalData, seriesInfoAverage)
} else {
for cdi, cdv := range outputData.CylindricalData {
if cdv.Name == normNameAverage {
outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, averageScore)
}
}
}
default:
//合计与平均
// sumScore, averageScore := AverageOfSum(wherStr, 1)
normNameTotal := fmt.Sprintf("%v %v总值", tv.XLine, normName)
if commonus.IsItTrueString(normNameTotal, outputData.Cylindrical) == false {
outputData.Cylindrical = append(outputData.Cylindrical, normNameTotal)
var seriesInfo series
seriesInfo.Name = normNameTotal
seriesInfo.Data = append(seriesInfo.Data, sumScore)
outputData.CylindricalData = append(outputData.CylindricalData, seriesInfo)
} else {
for cdi, cdv := range outputData.CylindricalData {
if cdv.Name == normNameTotal {
outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, sumScore)
}
}
}
normNameAverage := fmt.Sprintf("%v %v平均值", tv.XLine, normName)
if commonus.IsItTrueString(normNameAverage, outputData.Cylindrical) == false {
outputData.Cylindrical = append(outputData.Cylindrical, normNameAverage)
var seriesInfoAverage series
seriesInfoAverage.Name = normNameAverage
seriesInfoAverage.Data = append(seriesInfoAverage.Data, averageScore)
outputData.CylindricalData = append(outputData.CylindricalData, seriesInfoAverage)
} else {
for cdi, cdv := range outputData.CylindricalData {
if cdv.Name == normNameAverage {
outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, averageScore)
}
}
}
}
}
case 2: //季度 case 2: //季度
for _, dayv := range dataAry.Year {
var sumScore float64
var averageScore float64
if len(taskIdAry) > 0 {
if norm == 1 {
//定性考核
wherStr := fmt.Sprintf("sf_evaluation_plan IN %v AND `sf_year` = %v AND `sf_quarter` = %v AND sf_duty_department IN %v", taskIdStrWher, dayv, tv.YearName, orgvSunOrg)
sumScore, averageScore = AverageOfSumNature(wherStr, 1)
} else {
//定量考核
wherStr := fmt.Sprintf("fld_evaluation_id IN %v AND `fl_year` = %v AND `fl_quarter` = %v AND fl_duty_department IN %v", taskIdStrWher, dayv, tv.YearName, orgvSunOrg)
sumScore, averageScore = AverageOfSum(wherStr)
}
}
//判断计算总值还是平均值
switch statisticalMethod {
case 1:
// sumScore, _ := AverageOfSum(wherStr)
normNameTotal := fmt.Sprintf("%v第%v %v总值", dayv, tv.XLine, normName)
if commonus.IsItTrueString(normNameTotal, outputData.Cylindrical) == false {
outputData.Cylindrical = append(outputData.Cylindrical, normNameTotal)
var seriesInfo series
seriesInfo.Name = normNameTotal
seriesInfo.Data = append(seriesInfo.Data, sumScore)
outputData.CylindricalData = append(outputData.CylindricalData, seriesInfo)
} else {
for cdi, cdv := range outputData.CylindricalData {
if cdv.Name == normNameTotal {
outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, sumScore)
}
}
}
case 2:
// _, averageScore := AverageOfSum(wherStr, 1)
normNameAverage := fmt.Sprintf("%v第%v %v平均值", dayv, tv.XLine, normName)
if commonus.IsItTrueString(normNameAverage, outputData.Cylindrical) == false {
outputData.Cylindrical = append(outputData.Cylindrical, normNameAverage)
var seriesInfoAverage series
seriesInfoAverage.Name = normNameAverage
seriesInfoAverage.Data = append(seriesInfoAverage.Data, averageScore)
outputData.CylindricalData = append(outputData.CylindricalData, seriesInfoAverage)
} else {
for cdi, cdv := range outputData.CylindricalData {
if cdv.Name == normNameAverage {
outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, averageScore)
}
}
}
default:
//合计与平均
// sumScore, averageScore := AverageOfSum(wherStr, 1)
normNameTotal := fmt.Sprintf("%v第%v %v总值", dayv, tv.XLine, normName)
if commonus.IsItTrueString(normNameTotal, outputData.Cylindrical) == false {
outputData.Cylindrical = append(outputData.Cylindrical, normNameTotal)
var seriesInfo series
seriesInfo.Name = normNameTotal
seriesInfo.Data = append(seriesInfo.Data, sumScore)
outputData.CylindricalData = append(outputData.CylindricalData, seriesInfo)
} else {
for cdi, cdv := range outputData.CylindricalData {
if cdv.Name == normNameTotal {
outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, sumScore)
}
}
}
normNameAverage := fmt.Sprintf("%v第%v %v平均值", dayv, tv.XLine, normName)
if commonus.IsItTrueString(normNameAverage, outputData.Cylindrical) == false {
outputData.Cylindrical = append(outputData.Cylindrical, normNameAverage)
var seriesInfoAverage series
seriesInfoAverage.Name = normNameAverage
seriesInfoAverage.Data = append(seriesInfoAverage.Data, averageScore)
outputData.CylindricalData = append(outputData.CylindricalData, seriesInfoAverage)
} else {
for cdi, cdv := range outputData.CylindricalData {
if cdv.Name == normNameAverage {
outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, averageScore)
}
}
}
}
}
case 3: //月 case 3: //月
for _, dayv := range dataAry.Year {
var sumScore float64
var averageScore float64
if len(taskIdAry) > 0 {
if norm == 1 {
//定性考核
wherStr := fmt.Sprintf("sf_evaluation_plan IN %v AND `sf_year` = %v AND `sf_month` = %v AND sf_duty_department IN %v", taskIdStrWher, dayv, tv.YearName, orgvSunOrg)
sumScore, averageScore = AverageOfSumNature(wherStr, 1)
} else {
//定量考核
//定量考核
wherStr := fmt.Sprintf("fld_evaluation_id IN %v AND `fl_year` = %v AND `fl_month` = %v AND fl_duty_department IN %v", taskIdStrWher, dayv, tv.YearName, orgvSunOrg)
sumScore, averageScore = AverageOfSum(wherStr)
}
}
//判断计算总值还是平均值
switch statisticalMethod {
case 1:
// sumScore, _ := AverageOfSum(wherStr)
normNameTotal := fmt.Sprintf("%v年%v %v总值", dayv, tv.XLine, normName)
if commonus.IsItTrueString(normNameTotal, outputData.Cylindrical) == false {
outputData.Cylindrical = append(outputData.Cylindrical, normNameTotal)
var seriesInfo series
seriesInfo.Name = normNameTotal
seriesInfo.Data = append(seriesInfo.Data, sumScore)
outputData.CylindricalData = append(outputData.CylindricalData, seriesInfo)
} else {
for cdi, cdv := range outputData.CylindricalData {
if cdv.Name == normNameTotal {
outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, sumScore)
}
}
}
case 2:
// _, averageScore := AverageOfSum(wherStr, 1)
normNameAverage := fmt.Sprintf("%v年%v %v平均值", dayv, tv.XLine, normName)
if commonus.IsItTrueString(normNameAverage, outputData.Cylindrical) == false {
outputData.Cylindrical = append(outputData.Cylindrical, normNameAverage)
var seriesInfoAverage series
seriesInfoAverage.Name = normNameAverage
seriesInfoAverage.Data = append(seriesInfoAverage.Data, averageScore)
outputData.CylindricalData = append(outputData.CylindricalData, seriesInfoAverage)
} else {
for cdi, cdv := range outputData.CylindricalData {
if cdv.Name == normNameAverage {
outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, averageScore)
}
}
}
default:
//合计与平均
// sumScore, averageScore := AverageOfSum(wherStr, 1)
normNameTotal := fmt.Sprintf("%v年%v %v总值", dayv, tv.XLine, normName)
if commonus.IsItTrueString(normNameTotal, outputData.Cylindrical) == false {
outputData.Cylindrical = append(outputData.Cylindrical, normNameTotal)
var seriesInfo series
seriesInfo.Name = normNameTotal
seriesInfo.Data = append(seriesInfo.Data, sumScore)
outputData.CylindricalData = append(outputData.CylindricalData, seriesInfo)
} else {
for cdi, cdv := range outputData.CylindricalData {
if cdv.Name == normNameTotal {
outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, sumScore)
}
}
}
normNameAverage := fmt.Sprintf("%v年%v %v平均值", dayv, tv.XLine, normName)
if commonus.IsItTrueString(normNameAverage, outputData.Cylindrical) == false {
outputData.Cylindrical = append(outputData.Cylindrical, normNameAverage)
var seriesInfoAverage series
seriesInfoAverage.Name = normNameAverage
seriesInfoAverage.Data = append(seriesInfoAverage.Data, averageScore)
outputData.CylindricalData = append(outputData.CylindricalData, seriesInfoAverage)
} else {
for cdi, cdv := range outputData.CylindricalData {
if cdv.Name == normNameAverage {
outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, averageScore)
}
}
}
}
}
default: //全年 default: //全年
// wherStr := fmt.Sprintf("fld_evaluation_id = %v AND `fl_year` = %v", taskId, tv.YearName) var sumScore float64
var averageScore float64
if len(taskIdAry) > 0 {
if norm == 1 {
//定性考核
wherStr := fmt.Sprintf("sf_evaluation_plan IN %v AND `sf_year` = %v AND sf_duty_department IN %v", taskIdStrWher, tv.YearName, orgvSunOrg)
sumScore, averageScore = AverageOfSumNature(wherStr, 1)
} else {
//定量考核
//定量考核
wherStr := fmt.Sprintf("fld_evaluation_id IN %v AND `fl_year` = %v AND fl_duty_department IN %v", taskIdStrWher, tv.YearName, orgvSunOrg)
sumScore, averageScore = AverageOfSum(wherStr)
}
}
//判断计算总值还是平均值
switch statisticalMethod {
case 1:
// sumScore, _ := AverageOfSum(wherStr)
normNameTotal := fmt.Sprintf("%v %v总值", tv.XLine, normName)
if commonus.IsItTrueString(normNameTotal, outputData.Cylindrical) == false {
outputData.Cylindrical = append(outputData.Cylindrical, normNameTotal)
var seriesInfo series
seriesInfo.Name = normNameTotal
seriesInfo.Data = append(seriesInfo.Data, sumScore)
outputData.CylindricalData = append(outputData.CylindricalData, seriesInfo)
} else {
for cdi, cdv := range outputData.CylindricalData {
if cdv.Name == normNameTotal {
outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, sumScore)
}
}
}
case 2:
// _, averageScore := AverageOfSum(wherStr, 1)
normNameAverage := fmt.Sprintf("%v %v平均值", tv.XLine, normName)
if commonus.IsItTrueString(normNameAverage, outputData.Cylindrical) == false {
outputData.Cylindrical = append(outputData.Cylindrical, normNameAverage)
var seriesInfoAverage series
seriesInfoAverage.Name = normNameAverage
seriesInfoAverage.Data = append(seriesInfoAverage.Data, averageScore)
outputData.CylindricalData = append(outputData.CylindricalData, seriesInfoAverage)
} else {
for cdi, cdv := range outputData.CylindricalData {
if cdv.Name == normNameAverage {
outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, averageScore)
}
}
}
default:
//合计与平均
// sumScore, averageScore := AverageOfSum(wherStr, 1)
normNameTotal := fmt.Sprintf("%v %v总值", tv.XLine, normName)
if commonus.IsItTrueString(normNameTotal, outputData.Cylindrical) == false {
outputData.Cylindrical = append(outputData.Cylindrical, normNameTotal)
var seriesInfo series
seriesInfo.Name = normNameTotal
seriesInfo.Data = append(seriesInfo.Data, sumScore)
outputData.CylindricalData = append(outputData.CylindricalData, seriesInfo)
} else {
for cdi, cdv := range outputData.CylindricalData {
if cdv.Name == normNameTotal {
outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, sumScore)
}
}
}
normNameAverage := fmt.Sprintf("%v %v平均值", tv.XLine, normName)
if commonus.IsItTrueString(normNameAverage, outputData.Cylindrical) == false {
outputData.Cylindrical = append(outputData.Cylindrical, normNameAverage)
var seriesInfoAverage series
seriesInfoAverage.Name = normNameAverage
seriesInfoAverage.Data = append(seriesInfoAverage.Data, averageScore)
outputData.CylindricalData = append(outputData.CylindricalData, seriesInfoAverage)
} else {
for cdi, cdv := range outputData.CylindricalData {
if cdv.Name == normNameAverage {
outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, averageScore)
}
}
}
}
} }
} }
} }
} }
outErr = true outErr = true
fmt.Printf("orgAry====>%v\n", orgAry) // fmt.Printf("orgAry====>%v\n", orgAry)
jn, je := json.Marshal(orgList) // jn, je := json.Marshal(orgList)
fmt.Printf("orgList-====>%v-====>%v\n", string(jn), je) // fmt.Printf("orgList-====>%v-====>%v\n", string(jn), je)
fmt.Printf("timeFrame-====>%v\n", timeFrame) // fmt.Printf("timeFrame-====>%v\n", timeFrame)
fmt.Printf("normName-====>%v\n", normName) // tjn, tje := json.Marshal(timeFrame)
fmt.Printf("statisticalMethod-====>%v\n", statisticalMethod) // fmt.Printf("timeFrameJson-====>%v-====>%v\n", string(tjn), tje)
// fmt.Printf("normName-====>%v\n", normName)
// fmt.Printf("statisticalMethod-====>%v\n", statisticalMethod)
return return
} }

32
gin_server_admin/api/statistics/quantification/enter.go

@ -1,6 +1,8 @@
package quantification package quantification
import ( import (
"sync"
"github.com/flipped-aurora/gin-vue-admin/server/commonus" "github.com/flipped-aurora/gin-vue-admin/server/commonus"
"github.com/flipped-aurora/gin-vue-admin/server/model/common/response" "github.com/flipped-aurora/gin-vue-admin/server/model/common/response"
"github.com/flipped-aurora/gin-vue-admin/server/model/hrsystem" "github.com/flipped-aurora/gin-vue-admin/server/model/hrsystem"
@ -9,6 +11,23 @@ import (
type ApiGroup struct{} type ApiGroup struct{}
//协程设置
var synergeticProcess = sync.WaitGroup{}
//数据锁统计
type dataLockStatistics struct {
YearTime []string
OrgMap []orgModelsAry
mutext sync.RWMutex
}
//读取锁数据
func (d *dataLockStatistics) readDataLock() ([]orgModelsAry, []string) {
d.mutext.RLock()
defer d.mutext.RUnlock()
return d.OrgMap, d.YearTime
}
//入口 //入口
func (a *ApiGroup) Index(c *gin.Context) { func (a *ApiGroup) Index(c *gin.Context) {
outPut := commonus.MapOut() outPut := commonus.MapOut()
@ -38,10 +57,11 @@ type TimeAttributeMap struct {
//组织架构 //组织架构
type orgModels struct { type orgModels struct {
Id string `json:"id"` Id string `json:"id"` //组织ID
Pid string `jsonL:"pid"` Pid string `jsonL:"pid"` //上级
Name string `json:"name"` Name string `json:"name"` //名称
Level int64 `json:level` Level int64 `json:level` //等级
SunOrg []int64 `json:"sunorg"` //子集
} }
type orgModelsAry struct { type orgModelsAry struct {
orgModels orgModels
@ -92,3 +112,7 @@ type series struct {
Name string `json:"name"` //柱形体名称 Name string `json:"name"` //柱形体名称
Data []float64 `json:"data"` //对应X轴点位数值 Data []float64 `json:"data"` //对应X轴点位数值
} }
type TongjiFenShu struct {
Score float64 `json:"score" gorm:"column:sf_score;type:bigint(20) unsigned;default:0;not null;comment:分值(乘100录入)"`
Count float64 `json:"count" gorm:"column:sf_count;type:int(5) unsigned;default:1;not null;comment:发生次数"`
}

305
gin_server_admin/api/statistics/quantification/jisuanshuzhi.go

@ -0,0 +1,305 @@
package quantification
import (
"strconv"
"github.com/flipped-aurora/gin-vue-admin/server/commonus"
"github.com/flipped-aurora/gin-vue-admin/server/global"
"github.com/flipped-aurora/gin-vue-admin/server/model/assessmentmodel"
)
//计算数值用的
/*
计算定性数值
*/
//获取定性总值
func AuxiliaryCalculationSumNature(where interface{}) (sumScore float64) {
var addSumScore float64 = 0
//加分
var jiaFenAry []TongjiFenShu
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.ScoreFlow{}).Select("sf_score,sf_count").Where(where).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
var jianFenAry []TongjiFenShu
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.ScoreFlow{}).Select("sf_score,sf_count").Where(where).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 > scoreReduction {
sumScore = addSumScore - scoreReduction
} else {
sumScore = scoreReduction - addSumScore
}
return
}
//获取定性总数
func AuxiliaryCalculationCountNature(where interface{}) (sumScore float64) {
gormDb := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.ScoreFlow{}).Where(where).Where("sf_reply IN (2,3)")
gormDb.Pluck("COALESCE(COUNT(sf_id), 0) as countid", &sumScore) //获取总数
return
}
//计算总值和平均值
func AverageOfSumNature(where interface{}, class ...int) (sumScore float64, averageScore float64) {
sumScore = AuxiliaryCalculationSumNature(where) / 100
// panic(sumScore)
if len(class) > 0 {
countPage := AuxiliaryCalculationCountNature(where)
if countPage > 0 {
averageScore = sumScore / countPage
}
}
if sumScore != 0 {
sumScore = commonus.Decimal(sumScore)
}
if averageScore != 0 {
averageScore = commonus.Decimal(averageScore)
}
return
}
//统计查询条件
func (d *dataLockStatistics) StatisticalQueryCriteria(qualId int64) {
d.mutext.Lock()
defer d.mutext.Unlock()
var flowLogList []assessmentmodel.FlowLog
floLogErr := global.GVA_DB_Performanceappraisal.Where("FIND_IN_SET(?,`fl_evaluation_id`)", qualId).Find(&flowLogList).Error
if floLogErr == nil {
for _, fv := range flowLogList {
// fvDepartId := strconv.FormatInt(fv.DutyDepartment, 10)
// if commonus.IsItTrueString(fvDepartId, d.accDepart) == false {
// d.accDepart = append(d.accDepart, fvDepartId)
// }
yearStr := strconv.FormatInt(int64(fv.Year), 10)
if commonus.IsItTrueString(yearStr, d.YearTime) == false {
d.YearTime = append(d.YearTime, yearStr)
}
//判断组织架构是否有数据
if len(d.OrgMap) > 0 {
for oi, ov := range d.OrgMap {
//判断公司是否已经存在
if ov.Id == strconv.FormatInt(fv.DutyGroup, 10) {
//判断是否有分厂数据
if len(ov.Child) > 0 {
isYes := true
for _, dv := range ov.Child {
if dv.Id == strconv.FormatInt(fv.DutyDepartment, 10) {
isYes = false //该部门分厂已经存在
}
}
if isYes == true {
//该部门分厂不存在是添加
//写入部门
whereDepart := commonus.MapOut()
whereDepart["id"] = fv.DutyDepartment
orgDepartCont, orgDepartErr := commonus.GetNewOrgCont(whereDepart, "name")
if orgDepartErr == nil {
var orgDepartMapCont orgModels
orgDepartMapCont.Id = strconv.FormatInt(fv.DutyDepartment, 10)
orgDepartMapCont.Name = orgDepartCont.Name
d.OrgMap[oi].Child = append(d.OrgMap[oi].Child, orgDepartMapCont)
}
}
} else {
//没有分厂数据,根据上级数据进行新增
if fv.DutyDepartment != 0 {
//写入部门
whereDepart := commonus.MapOut()
whereDepart["id"] = fv.DutyDepartment
orgDepartCont, orgDepartErr := commonus.GetNewOrgCont(whereDepart, "name")
if orgDepartErr == nil {
var orgDepartMapCont orgModels
orgDepartMapCont.Id = strconv.FormatInt(fv.DutyDepartment, 10)
orgDepartMapCont.Name = orgDepartCont.Name
d.OrgMap[oi].Child = append(d.OrgMap[oi].Child, orgDepartMapCont)
}
}
}
} else {
if fv.DutyGroup != 0 {
//写入集团信息
where := commonus.MapOut()
where["id"] = fv.DutyGroup
orgGroupCont, orgGroupErr := commonus.GetNewOrgCont(where, "name")
if orgGroupErr == nil {
var orgMapCont orgModelsAry
orgMapCont.Id = strconv.FormatInt(fv.DutyGroup, 10)
orgMapCont.Name = orgGroupCont.Name
if fv.DutyDepartment != 0 {
//写入部门
whereDepart := commonus.MapOut()
whereDepart["id"] = fv.DutyDepartment
orgDepartCont, orgDepartErr := commonus.GetNewOrgCont(whereDepart, "name")
if orgDepartErr == nil {
var orgDepartMapCont orgModels
orgDepartMapCont.Id = strconv.FormatInt(fv.DutyDepartment, 10)
orgDepartMapCont.Name = orgDepartCont.Name
orgMapCont.Child = append(orgMapCont.Child, orgDepartMapCont)
}
}
d.OrgMap = append(d.OrgMap, orgMapCont)
}
}
}
}
} else {
//没有数据的时候根据数值进行新增
if fv.DutyGroup != 0 {
//写入集团信息
where := commonus.MapOut()
where["id"] = fv.DutyGroup
orgGroupCont, orgGroupErr := commonus.GetNewOrgCont(where, "name")
if orgGroupErr == nil {
var orgMapCont orgModelsAry
orgMapCont.Id = strconv.FormatInt(fv.DutyGroup, 10)
orgMapCont.Name = orgGroupCont.Name
if fv.DutyDepartment != 0 {
//写入部门
whereDepart := commonus.MapOut()
whereDepart["id"] = fv.DutyDepartment
orgDepartCont, orgDepartErr := commonus.GetNewOrgCont(whereDepart, "name")
if orgDepartErr == nil {
var orgDepartMapCont orgModels
orgDepartMapCont.Id = strconv.FormatInt(fv.DutyDepartment, 10)
orgDepartMapCont.Name = orgDepartCont.Name
orgMapCont.Child = append(orgMapCont.Child, orgDepartMapCont)
}
}
d.OrgMap = append(d.OrgMap, orgMapCont)
}
}
}
}
}
synergeticProcess.Done()
}
func (d *dataLockStatistics) StatisticalQueryCriteriaXin(qualId int64) {
d.mutext.Lock()
defer d.mutext.Unlock()
// fmt.Printf("%v----------1--3--------%v\n", qualId, qualId)
var flowLogList []assessmentmodel.ScoreFlow
floLogErr := global.GVA_DB_Performanceappraisal.Where("sf_evaluation_plan = ?", qualId).Find(&flowLogList).Error
if floLogErr == nil {
for _, fv := range flowLogList {
// fvDepartId := strconv.FormatInt(fv.DutyDepartment, 10)
// if commonus.IsItTrueString(fvDepartId, d.accDepart) == false {
// d.accDepart = append(d.accDepart, fvDepartId)
// }
yearStr := strconv.FormatInt(int64(fv.Year), 10)
if commonus.IsItTrueString(yearStr, d.YearTime) == false {
d.YearTime = append(d.YearTime, yearStr)
}
//判断组织架构是否有数据
if len(d.OrgMap) > 0 {
for oi, ov := range d.OrgMap {
//判断公司是否已经存在
if ov.Id == strconv.FormatInt(fv.DutyGroup, 10) {
//判断是否有分厂数据
if len(ov.Child) > 0 {
isYes := true
for _, dv := range ov.Child {
if dv.Id == strconv.FormatInt(fv.DutyDepartment, 10) {
isYes = false //该部门分厂已经存在
}
}
if isYes == true {
//该部门分厂不存在是添加
//写入部门
whereDepart := commonus.MapOut()
whereDepart["id"] = fv.DutyDepartment
orgDepartCont, orgDepartErr := commonus.GetNewOrgCont(whereDepart, "name")
if orgDepartErr == nil {
var orgDepartMapCont orgModels
orgDepartMapCont.Id = strconv.FormatInt(fv.DutyDepartment, 10)
orgDepartMapCont.Name = orgDepartCont.Name
d.OrgMap[oi].Child = append(d.OrgMap[oi].Child, orgDepartMapCont)
}
}
} else {
//没有分厂数据,根据上级数据进行新增
if fv.DutyDepartment != 0 {
//写入部门
whereDepart := commonus.MapOut()
whereDepart["id"] = fv.DutyDepartment
orgDepartCont, orgDepartErr := commonus.GetNewOrgCont(whereDepart, "name")
if orgDepartErr == nil {
var orgDepartMapCont orgModels
orgDepartMapCont.Id = strconv.FormatInt(fv.DutyDepartment, 10)
orgDepartMapCont.Name = orgDepartCont.Name
d.OrgMap[oi].Child = append(d.OrgMap[oi].Child, orgDepartMapCont)
}
}
}
} else {
if fv.DutyGroup != 0 {
//写入集团信息
where := commonus.MapOut()
where["id"] = fv.DutyGroup
orgGroupCont, orgGroupErr := commonus.GetNewOrgCont(where, "name")
if orgGroupErr == nil {
var orgMapCont orgModelsAry
orgMapCont.Id = strconv.FormatInt(fv.DutyGroup, 10)
orgMapCont.Name = orgGroupCont.Name
if fv.DutyDepartment != 0 {
//写入部门
whereDepart := commonus.MapOut()
whereDepart["id"] = fv.DutyDepartment
orgDepartCont, orgDepartErr := commonus.GetNewOrgCont(whereDepart, "name")
if orgDepartErr == nil {
var orgDepartMapCont orgModels
orgDepartMapCont.Id = strconv.FormatInt(fv.DutyDepartment, 10)
orgDepartMapCont.Name = orgDepartCont.Name
orgMapCont.Child = append(orgMapCont.Child, orgDepartMapCont)
}
}
d.OrgMap = append(d.OrgMap, orgMapCont)
}
}
}
}
} else {
//没有数据的时候根据数值进行新增
if fv.DutyGroup != 0 {
//写入集团信息
where := commonus.MapOut()
where["id"] = fv.DutyGroup
orgGroupCont, orgGroupErr := commonus.GetNewOrgCont(where, "name")
if orgGroupErr == nil {
var orgMapCont orgModelsAry
orgMapCont.Id = strconv.FormatInt(fv.DutyGroup, 10)
orgMapCont.Name = orgGroupCont.Name
if fv.DutyDepartment != 0 {
//写入部门
whereDepart := commonus.MapOut()
whereDepart["id"] = fv.DutyDepartment
orgDepartCont, orgDepartErr := commonus.GetNewOrgCont(whereDepart, "name")
if orgDepartErr == nil {
var orgDepartMapCont orgModels
orgDepartMapCont.Id = strconv.FormatInt(fv.DutyDepartment, 10)
orgDepartMapCont.Name = orgDepartCont.Name
orgMapCont.Child = append(orgMapCont.Child, orgDepartMapCont)
}
}
d.OrgMap = append(d.OrgMap, orgMapCont)
}
}
}
}
}
synergeticProcess.Done()
}

283
gin_server_admin/api/statistics/quantification/quant.go

@ -29,130 +29,79 @@ func (a *ApiGroup) GetQuantEChartOrgAndYear(c *gin.Context) {
response.Result(102, err, "未获取到指标", c) response.Result(102, err, "未获取到指标", c)
return return
} }
var accDepart []string // var accDepart []string
var yearTime []string var yearTime []string
var orgMap []orgModelsAry var orgMap []orgModelsAry
var orgMapGuodu []orgModelsAry
for _, v := range requestData.TargetId { for _, v := range requestData.TargetId {
var flowLogList []assessmentmodel.FlowLog
floLogErr := global.GVA_DB_Performanceappraisal.Where("FIND_IN_SET(?,`fl_evaluation_id`)", v).Find(&flowLogList).Error var targetInfoAry assessmentmodel.EvaluationTarget
if floLogErr == nil { targetInfoErr := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.EvaluationTarget{}).Select("et_type,et_dimension").Where("et_id = ?", v).First(&targetInfoAry).Error
for _, fv := range flowLogList { if targetInfoErr == nil {
fvDepartId := strconv.FormatInt(fv.DutyDepartment, 10)
if commonus.IsItTrueString(fvDepartId, accDepart) == false { var taskIdAry []int64
accDepart = append(accDepart, fvDepartId) global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.QualitativeEvaluation{}).Select("qe_id").Where("qe_state = 1 AND qe_dimension = ? AND qe_target = ? ", targetInfoAry.Dimension, v).Find(&taskIdAry)
} // fmt.Printf("%v----------1-----------%v\n", len(taskIdAry), taskIdAry)
yearStr := strconv.FormatInt(int64(fv.Year), 10) // panic(taskIdAry)
if commonus.IsItTrueString(yearStr, yearTime) == false { if len(taskIdAry) > 0 {
yearTime = append(yearTime, yearStr)
} var timeOrDemper dataLockStatistics
//判断组织架构是否有数据 for _, rikv := range taskIdAry {
if len(orgMap) > 0 {
for oi, ov := range orgMap { if targetInfoAry.Type == 1 {
//判断公司是否已经存在 //定性考核
if ov.Id == strconv.FormatInt(fv.DutyGroup, 10) { // fmt.Printf("%v----------1--1--------%v\n", len(taskIdAry), rikv)
//判断是否有分厂数据 synergeticProcess.Add(1)
if len(ov.Child) > 0 { go timeOrDemper.StatisticalQueryCriteriaXin(rikv)
isYes := true
for _, dv := range ov.Child {
if dv.Id == strconv.FormatInt(fv.DutyDepartment, 10) {
isYes = false //该部门分厂已经存在
}
}
if isYes == true {
//该部门分厂不存在是添加
//写入部门
whereDepart := commonus.MapOut()
whereDepart["id"] = fv.DutyDepartment
orgDepartCont, orgDepartErr := commonus.GetNewOrgCont(whereDepart, "name")
if orgDepartErr == nil {
var orgDepartMapCont orgModels
orgDepartMapCont.Id = strconv.FormatInt(fv.DutyDepartment, 10)
orgDepartMapCont.Name = orgDepartCont.Name
orgMap[oi].Child = append(orgMap[oi].Child, orgDepartMapCont)
}
}
} else { } else {
//没有分厂数据,根据上级数据进行新增 //定量考核
if fv.DutyDepartment != 0 { synergeticProcess.Add(1)
//写入部门 go timeOrDemper.StatisticalQueryCriteria(rikv)
whereDepart := commonus.MapOut()
whereDepart["id"] = fv.DutyDepartment
orgDepartCont, orgDepartErr := commonus.GetNewOrgCont(whereDepart, "name")
if orgDepartErr == nil {
var orgDepartMapCont orgModels
orgDepartMapCont.Id = strconv.FormatInt(fv.DutyDepartment, 10)
orgDepartMapCont.Name = orgDepartCont.Name
orgMap[oi].Child = append(orgMap[oi].Child, orgDepartMapCont)
} }
} }
} synergeticProcess.Wait()
orgMapGo, yearTimeGo := timeOrDemper.readDataLock()
} else { for _, gtv := range yearTimeGo {
if fv.DutyGroup != 0 { if commonus.IsInTrue[string](gtv, yearTime) == false {
//写入集团信息 yearTime = append(yearTime, gtv)
where := commonus.MapOut()
where["id"] = fv.DutyGroup
orgGroupCont, orgGroupErr := commonus.GetNewOrgCont(where, "name")
if orgGroupErr == nil {
var orgMapCont orgModelsAry
orgMapCont.Id = strconv.FormatInt(fv.DutyGroup, 10)
orgMapCont.Name = orgGroupCont.Name
if fv.DutyDepartment != 0 {
//写入部门
whereDepart := commonus.MapOut()
whereDepart["id"] = fv.DutyDepartment
orgDepartCont, orgDepartErr := commonus.GetNewOrgCont(whereDepart, "name")
if orgDepartErr == nil {
var orgDepartMapCont orgModels
orgDepartMapCont.Id = strconv.FormatInt(fv.DutyDepartment, 10)
orgDepartMapCont.Name = orgDepartCont.Name
orgMapCont.Child = append(orgMapCont.Child, orgDepartMapCont)
} }
} }
orgMap = append(orgMap, orgMapCont) orgMapGuodu = append(orgMapGuodu, orgMapGo...)
} }
} }
} }
} for _, gv := range orgMapGuodu {
if len(orgMap) > 0 {
for gvi, gvm := range orgMap {
if gv.Id == gvm.Id {
orgMap[gvi].Child = bianLiOrg(gv.Child, gvm.Child)
} else { } else {
//没有数据的时候根据数值进行新增 orgMap = append(orgMap, gv)
if fv.DutyGroup != 0 {
//写入集团信息
where := commonus.MapOut()
where["id"] = fv.DutyGroup
orgGroupCont, orgGroupErr := commonus.GetNewOrgCont(where, "name")
if orgGroupErr == nil {
var orgMapCont orgModelsAry
orgMapCont.Id = strconv.FormatInt(fv.DutyGroup, 10)
orgMapCont.Name = orgGroupCont.Name
if fv.DutyDepartment != 0 {
//写入部门
whereDepart := commonus.MapOut()
whereDepart["id"] = fv.DutyDepartment
orgDepartCont, orgDepartErr := commonus.GetNewOrgCont(whereDepart, "name")
if orgDepartErr == nil {
var orgDepartMapCont orgModels
orgDepartMapCont.Id = strconv.FormatInt(fv.DutyDepartment, 10)
orgDepartMapCont.Name = orgDepartCont.Name
orgMapCont.Child = append(orgMapCont.Child, orgDepartMapCont)
} }
} }
orgMap = append(orgMap, orgMapCont) } else {
orgMap = append(orgMap, gv)
} }
} }
outMap := commonus.MapOut()
outMap["grouplist"] = orgMap
outMap["timelist"] = yearTime
response.Result(0, outMap, "数据获取失败!", c)
} }
func bianLiOrg(guoDuOrm, outOrm []orgModels) (ormAry []orgModels) {
for _, v := range guoDuOrm {
for _, ov := range outOrm {
if v.Id != ov.Id {
outOrm = append(outOrm, v)
} }
} }
} }
outMap := commonus.MapOut() ormAry = outOrm
outMap["grouplist"] = orgMap return
outMap["timelist"] = yearTime
response.Result(0, outMap, "数据获取失败!", c)
} }
//量化考核图标 //量化考核图标
@ -189,6 +138,17 @@ func (a *ApiGroup) QuantEChart(c *gin.Context) {
graphicStatistics.XLine = append(graphicStatistics.XLine, gsv) graphicStatistics.XLine = append(graphicStatistics.XLine, gsv)
} }
} }
for _, cilv := range getStatistics.Cylindrical {
if commonus.IsItTrueString(cilv, graphicStatistics.Cylindrical) == false {
graphicStatistics.Cylindrical = append(graphicStatistics.Cylindrical, cilv)
for _, cdv := range getStatistics.CylindricalData {
// fmt.Printf("%v\n", cdv)
if cdv.Name == cilv {
graphicStatistics.CylindricalData = append(graphicStatistics.CylindricalData, cdv)
}
}
}
}
} }
} else { } else {
//时间维度 //时间维度
@ -220,6 +180,71 @@ func (a *ApiGroup) QuantEChart(c *gin.Context) {
response.Result(0, graphicStatistics, "图形数据", c) response.Result(0, graphicStatistics, "图形数据", c)
} }
func getGroupOrgList(orgAry []string) (orgMap []orgModelsAry, orgWherList []orgModels) {
var govMap []OutGovCont
var orgErr error
if len(orgAry) > 0 {
orgErr = global.GVA_DB_HrDataBase.Model(&hrsystem.AdministrativeOrganization{}).Select("administrative_organization.*,aot.name as classname,aot.level").Joins("left join administrative_organization_type as aot on aot.id = administrative_organization.organization_type").Where("administrative_organization.`state` = 1 AND administrative_organization.id IN ?", orgAry).Find(&govMap).Error
} else {
var orgId []int64
global.GVA_DB_HrDataBase.Model(&hrsystem.AdministrativeOrganization{}).Select("id").Where("`state` = 1 AND `superior` = 1").Find(&orgId)
orgErr = global.GVA_DB_HrDataBase.Model(&hrsystem.AdministrativeOrganization{}).Select("administrative_organization.*,aot.name as classname,aot.level").Joins("left join administrative_organization_type as aot on aot.id = administrative_organization.organization_type").Where("administrative_organization.`state` = 1 AND administrative_organization.superior IN ?", orgId).Find(&govMap).Error
}
if orgErr != nil {
return
}
for _, v := range govMap {
if len(orgMap) > 0 {
for _, gv := range orgMap {
if gv.Id != strconv.FormatInt(v.Id, 10) {
var groupInfo orgModelsAry
groupInfo.Id = strconv.FormatInt(v.Id, 10)
groupInfo.Name = v.Name
if v.Abbreviation != "" {
groupInfo.Name = v.Abbreviation
}
groupInfo.Pid = strconv.FormatInt(v.Superior, 10)
groupInfo.Level = v.Level
orgMap = append(orgMap, groupInfo)
}
}
} else {
var groupInfo orgModelsAry
groupInfo.Id = strconv.FormatInt(v.Id, 10)
groupInfo.Name = v.Name
if v.Abbreviation != "" {
groupInfo.Name = v.Abbreviation
}
groupInfo.Pid = strconv.FormatInt(v.Superior, 10)
groupInfo.Level = v.Level
orgMap = append(orgMap, groupInfo)
}
}
if len(orgMap) > 0 {
for _, ov := range orgMap {
isInGroup := true //界定是否写入
for _, olv := range orgWherList {
if ov.Id == olv.Id {
isInGroup = false
}
}
if isInGroup == true {
var orgList orgModels
orgList.Id = ov.Id
orgList.Name = ov.Name
orgList.Pid = ov.Pid
orgList.Level = ov.Level
orgidInt, _ := strconv.ParseInt(ov.Id, 10, 64)
orgList.SunOrg = commonus.DiGuiOrgSun(orgidInt, orgList.SunOrg)
orgList.SunOrg = append(orgList.SunOrg, orgidInt)
orgWherList = append(orgWherList, orgList)
}
}
}
return
}
//获取行政组织 //获取行政组织
func getGroupOrg(orgAry []string) (orgMap []orgModelsAry, orgWherList []orgModels) { func getGroupOrg(orgAry []string) (orgMap []orgModelsAry, orgWherList []orgModels) {
@ -449,22 +474,40 @@ func GetQuantitativeConfig(targetScore int64, resultval float64, group, depart,
if err != nil { if err != nil {
return return
} }
allPrize = qualConfig.Allprize / 100
zeroPrize = qualConfig.Zeroprize / 100
CappingVal = qualConfig.CappingVal / 100
chuShu := resultval - float64(qualConfig.Zeroprize) scoreVal, allPrize, zeroPrize, CappingVal, achievement = commonus.CalculateScore(targetScore, resultval, qualConfig.Allprize, qualConfig.Zeroprize, qualConfig.CappingVal)
beiChuShu := float64(qualConfig.Allprize) - float64(qualConfig.Zeroprize)
if beiChuShu > 0 { return
achievement = commonus.Decimal(chuShu / beiChuShu)
scoreVal = achievement * (resultval / 100) // allPrize = qualConfig.Allprize / 100
if achievement >= CappingVal { // zeroPrize = qualConfig.Zeroprize / 100
scoreVal = CappingVal * float64(targetScore) // CappingVal = qualConfig.CappingVal / 100
}
} else {
scoreVal = float64(targetScore)
}
// chuShu := resultval - zeroPrize
// beiChuShu := allPrize - zeroPrize
// // chuShu := resultval - float64(qualConfig.Zeroprize)
// // beiChuShu := float64(qualConfig.Allprize) - float64(qualConfig.Zeroprize)
// if beiChuShu > 0 {
// achievement = commonus.Decimal(chuShu / beiChuShu)
// // scoreVal = achievement * (resultval / 100)
// scoreVal = achievement * float64(targetScore)
// if achievement >= CappingVal {
// scoreVal = CappingVal * float64(targetScore)
// }
// } else {
// scoreVal = float64(targetScore)
// }
// // commonus.Decimal()
// scoreVal = commonus.Decimal(scoreVal)
// allPrize = commonus.Decimal(allPrize)
// zeroPrize = commonus.Decimal(zeroPrize)
// CappingVal = commonus.Decimal(CappingVal)
// achievement = commonus.Decimal(achievement) * 100
// if resultval <= 0 {
// achievement = 0
// scoreVal = 0
// }
// if qualConfig.CappingVal != 0 && resultval >= qualConfig.CappingVal { // if qualConfig.CappingVal != 0 && resultval >= qualConfig.CappingVal {
// scoreVal = float64(targetScore) // scoreVal = float64(targetScore)
// achievement = 100 // achievement = 100
@ -480,8 +523,8 @@ func GetQuantitativeConfig(targetScore int64, resultval float64, group, depart,
// scoreVal = float64(targetScore) // scoreVal = float64(targetScore)
// // fmt.Printf("达成率--3-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v\n", group, depart, dimen, target, year, allPrize, zeroPrize, CappingVal, achievement) // // fmt.Printf("达成率--3-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v\n", group, depart, dimen, target, year, allPrize, zeroPrize, CappingVal, achievement)
// } // }
// } // }targetScore int64, resultval float64, group, depart, dimen, target, deaTarget string, year int64, timecopy int scoreVal, allPrize, zeroPrize, CappingVal, achievement float64
// fmt.Printf("达成率--4-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v\n", group, depart, dimen, target, year, allPrize, zeroPrize, CappingVal, achievement) // fmt.Printf("\n\n达成率--4-->targetScore---------->%v------------>resultval---------->%v------------>group---------->%v------------>depart---------->%v------------>dimen---------->%v------------>target---------->%v------------>deaTarget---------->%v------------>year---------->%v------------>timecopy---------->%v------------>scoreVal---------->%v------------>allPrize---------->%v------------>zeroPrize---------->%v------------>CappingVal---------->%v------------>achievement---------->%v\n\n", targetScore, resultval, group, depart, dimen, target, deaTarget, year, timecopy, scoreVal, allPrize, zeroPrize, CappingVal, achievement)
return return
} }
@ -504,7 +547,7 @@ func GetQuantitativeConfig(targetScore int64, resultval float64, group, depart,
@CappingVal 封顶值 @CappingVal 封顶值
@achievement 达成率 @achievement 达成率
*/ */
func GetQuantitativeConfigEs(resultval float64, group, depart, dimen, target, deaTarget string, year int64, timecopy int) (allPrize, zeroPrize, CappingVal, achievement float64) { func GetQuantitativeConfigEs(targetScore int64, resultval float64, group, depart, dimen, target, deaTarget string, year int64, timecopy int) (scoreVal, allPrize, zeroPrize, CappingVal, achievement float64) {
allPrize = 0 allPrize = 0
zeroPrize = 0 zeroPrize = 0
CappingVal = 0 CappingVal = 0
@ -522,6 +565,10 @@ func GetQuantitativeConfigEs(resultval float64, group, depart, dimen, target, de
return return
} }
scoreVal, allPrize, zeroPrize, CappingVal, achievement = commonus.CalculateScore(targetScore, resultval, qualConfig.Allprize, qualConfig.Zeroprize, qualConfig.CappingVal)
return
chuShu := resultval - float64(qualConfig.Zeroprize) chuShu := resultval - float64(qualConfig.Zeroprize)
beiChuShu := float64(qualConfig.Allprize) - float64(qualConfig.Zeroprize) beiChuShu := float64(qualConfig.Allprize) - float64(qualConfig.Zeroprize)
if beiChuShu > 0 { if beiChuShu > 0 {

537
gin_server_admin/api/statistics/quantification/shiyan.go

@ -82,3 +82,540 @@ func DimensionCalculation(normName, wherStr string, calculationMethod int, oldSt
} }
return return
} }
// func ssd() {
// outErr = true
// var normName string = ""
// if len(dataAry.TargetId) > 1 {
// //当同时查询多个指标时启用 获取指标名称
// var qualEvalCont assessmentmodel.QualitativeEvaluation
// qualEvaWhe := commonus.MapOut()
// qualEvaWhe["qe_id"] = taskId
// qualEvalCont.GetCont(qualEvaWhe, "qe_target")
// taskCont, taskErr := commonus.GetTargetInfo(qualEvalCont.Target)
// if taskErr == true {
// normName = taskCont.Title
// outErr = taskErr
// } else {
// // outErr = error.Error("此考核项目没有数据!")
// outErr = taskErr
// return
// }
// }
// //以时间维度,获取X坐标轴
// timeFrame := EstimatedTime(dataAry)
// //统计方式
// statisticalMethod := 3
// if len(dataAry.AccMethod) == 1 {
// if commonus.IsItTrueInt(1, dataAry.AccMethod) == true {
// statisticalMethod = 1
// } else {
// statisticalMethod = 2
// }
// }
// // fmt.Sprintf("timeFrame--------->%v\n", timeFrame)
// //根据时间维度进行统计
// for _, tfv := range timeFrame {
// switch tfv.Class {
// case 1:
// // fmt.Sprintf("KKKKK--------->%v\n", tfv.XLine)
// if commonus.IsItTrueString(tfv.XLine, outputData.XLine) == false {
// outputData.XLine = append(outputData.XLine, tfv.XLine)
// }
// monthStr := "("
// for twi, twv := range tfv.Where {
// if twi != 0 {
// monthStr = fmt.Sprintf("%v,%v", monthStr, twv)
// } else {
// monthStr = fmt.Sprintf("%v%v", monthStr, twv)
// }
// }
// monthStr = fmt.Sprintf("%v)", monthStr)
// wherStr := fmt.Sprintf("fld_evaluation_id = %v AND `fl_year` = %v AND `fl_month` IN %v", taskId, tfv.YearName, monthStr)
// if len(dataAry.AccMethod) > 0 {
// if commonus.IsItTrueInt(1, dataAry.AccMethod) == true && commonus.IsItTrueInt(2, dataAry.AccMethod) == true {
// //合计与平均
// sumScore, averageScore := AverageOfSum(wherStr, 1)
// normNameTotal := fmt.Sprintf("%v总值", normName)
// if commonus.IsItTrueString(normNameTotal, outputData.Cylindrical) == false {
// outputData.Cylindrical = append(outputData.Cylindrical, normNameTotal)
// var seriesInfo series
// seriesInfo.Name = normNameTotal
// seriesInfo.Data = append(seriesInfo.Data, sumScore)
// outputData.CylindricalData = append(outputData.CylindricalData, seriesInfo)
// } else {
// for cdi, cdv := range outputData.CylindricalData {
// if cdv.Name == normNameTotal {
// outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, sumScore)
// }
// }
// }
// normNameAverage := fmt.Sprintf("%v平均值", normName)
// if commonus.IsItTrueString(normNameAverage, outputData.Cylindrical) == false {
// outputData.Cylindrical = append(outputData.Cylindrical, normNameAverage)
// var seriesInfoAverage series
// seriesInfoAverage.Name = normNameAverage
// seriesInfoAverage.Data = append(seriesInfoAverage.Data, averageScore)
// outputData.CylindricalData = append(outputData.CylindricalData, seriesInfoAverage)
// } else {
// for cdi, cdv := range outputData.CylindricalData {
// if cdv.Name == normNameAverage {
// outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, averageScore)
// }
// }
// }
// } else if commonus.IsItTrueInt(1, dataAry.AccMethod) == true {
// //合计
// sumScore, _ := AverageOfSum(wherStr)
// normNameTotal := fmt.Sprintf("%v总值", normName)
// if commonus.IsItTrueString(normNameTotal, outputData.Cylindrical) == false {
// outputData.Cylindrical = append(outputData.Cylindrical, normNameTotal)
// var seriesInfo series
// seriesInfo.Name = normNameTotal
// seriesInfo.Data = append(seriesInfo.Data, sumScore)
// outputData.CylindricalData = append(outputData.CylindricalData, seriesInfo)
// } else {
// for cdi, cdv := range outputData.CylindricalData {
// if cdv.Name == normNameTotal {
// outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, sumScore)
// }
// }
// }
// } else if commonus.IsItTrueInt(2, dataAry.AccMethod) == true {
// _, averageScore := AverageOfSum(wherStr, 1)
// normNameAverage := fmt.Sprintf("%v平均值", normName)
// if commonus.IsItTrueString(normNameAverage, outputData.Cylindrical) == false {
// outputData.Cylindrical = append(outputData.Cylindrical, normNameAverage)
// var seriesInfoAverage series
// seriesInfoAverage.Name = normNameAverage
// seriesInfoAverage.Data = append(seriesInfoAverage.Data, averageScore)
// outputData.CylindricalData = append(outputData.CylindricalData, seriesInfoAverage)
// } else {
// for cdi, cdv := range outputData.CylindricalData {
// if cdv.Name == normNameAverage {
// outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, averageScore)
// }
// }
// }
// }
// } else {
// //合计与平均
// sumScore, averageScore := AverageOfSum(wherStr, 1)
// normNameTotal := fmt.Sprintf("%v总值", normName)
// if commonus.IsItTrueString(normNameTotal, outputData.Cylindrical) == false {
// outputData.Cylindrical = append(outputData.Cylindrical, normNameTotal)
// var seriesInfo series
// seriesInfo.Name = normNameTotal
// seriesInfo.Data = append(seriesInfo.Data, sumScore)
// outputData.CylindricalData = append(outputData.CylindricalData, seriesInfo)
// } else {
// for cdi, cdv := range outputData.CylindricalData {
// if cdv.Name == normNameTotal {
// outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, sumScore)
// }
// }
// }
// normNameAverage := fmt.Sprintf("%v平均值", normName)
// if commonus.IsItTrueString(normNameAverage, outputData.Cylindrical) == false {
// outputData.Cylindrical = append(outputData.Cylindrical, normNameAverage)
// var seriesInfoAverage series
// seriesInfoAverage.Name = normNameAverage
// seriesInfoAverage.Data = append(seriesInfoAverage.Data, averageScore)
// outputData.CylindricalData = append(outputData.CylindricalData, seriesInfoAverage)
// } else {
// for cdi, cdv := range outputData.CylindricalData {
// if cdv.Name == normNameAverage {
// outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, averageScore)
// }
// }
// }
// }
// case 2:
// //季度
// if commonus.IsItTrueString(tfv.XLine, outputData.XLine) == false {
// outputData.XLine = append(outputData.XLine, tfv.XLine)
// }
// for _, yearVal := range dataAry.Year {
// wherStr := fmt.Sprintf("fld_evaluation_id = %v AND `fl_year` = %v AND `fl_quarter` = %v", taskId, yearVal, tfv.YearName)
// if len(dataAry.AccMethod) > 0 {
// if commonus.IsItTrueInt(1, dataAry.AccMethod) == true && commonus.IsItTrueInt(2, dataAry.AccMethod) == true {
// //合计与平均
// sumScore, averageScore := AverageOfSum(wherStr, 1)
// normNameTotal := fmt.Sprintf("%v总值", normName)
// if commonus.IsItTrueString(normNameTotal, outputData.Cylindrical) == false {
// outputData.Cylindrical = append(outputData.Cylindrical, normNameTotal)
// var seriesInfo series
// seriesInfo.Name = normNameTotal
// seriesInfo.Data = append(seriesInfo.Data, sumScore)
// outputData.CylindricalData = append(outputData.CylindricalData, seriesInfo)
// } else {
// for cdi, cdv := range outputData.CylindricalData {
// if cdv.Name == normNameTotal {
// outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, sumScore)
// }
// }
// }
// normNameAverage := fmt.Sprintf("%v平均值", normName)
// if commonus.IsItTrueString(normNameAverage, outputData.Cylindrical) == false {
// outputData.Cylindrical = append(outputData.Cylindrical, normNameAverage)
// var seriesInfoAverage series
// seriesInfoAverage.Name = normNameAverage
// seriesInfoAverage.Data = append(seriesInfoAverage.Data, averageScore)
// outputData.CylindricalData = append(outputData.CylindricalData, seriesInfoAverage)
// } else {
// for cdi, cdv := range outputData.CylindricalData {
// if cdv.Name == normNameAverage {
// outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, averageScore)
// }
// }
// }
// } else if commonus.IsItTrueInt(1, dataAry.AccMethod) == true {
// //合计
// sumScore, _ := AverageOfSum(wherStr)
// normNameTotal := fmt.Sprintf("%v总值", normName)
// if commonus.IsItTrueString(normNameTotal, outputData.Cylindrical) == false {
// outputData.Cylindrical = append(outputData.Cylindrical, normNameTotal)
// var seriesInfo series
// seriesInfo.Name = normNameTotal
// seriesInfo.Data = append(seriesInfo.Data, sumScore)
// outputData.CylindricalData = append(outputData.CylindricalData, seriesInfo)
// } else {
// for cdi, cdv := range outputData.CylindricalData {
// if cdv.Name == normNameTotal {
// outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, sumScore)
// }
// }
// }
// } else if commonus.IsItTrueInt(2, dataAry.AccMethod) == true {
// _, averageScore := AverageOfSum(wherStr, 1)
// normNameAverage := fmt.Sprintf("%v平均值", normName)
// if commonus.IsItTrueString(normNameAverage, outputData.Cylindrical) == false {
// outputData.Cylindrical = append(outputData.Cylindrical, normNameAverage)
// var seriesInfoAverage series
// seriesInfoAverage.Name = normNameAverage
// seriesInfoAverage.Data = append(seriesInfoAverage.Data, averageScore)
// outputData.CylindricalData = append(outputData.CylindricalData, seriesInfoAverage)
// } else {
// for cdi, cdv := range outputData.CylindricalData {
// if cdv.Name == normNameAverage {
// outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, averageScore)
// }
// }
// }
// }
// } else {
// //合计与平均
// sumScore, averageScore := AverageOfSum(wherStr, 1)
// normNameTotal := fmt.Sprintf("%v总值", normName)
// if commonus.IsItTrueString(normNameTotal, outputData.Cylindrical) == false {
// outputData.Cylindrical = append(outputData.Cylindrical, normNameTotal)
// var seriesInfo series
// seriesInfo.Name = normNameTotal
// seriesInfo.Data = append(seriesInfo.Data, sumScore)
// outputData.CylindricalData = append(outputData.CylindricalData, seriesInfo)
// } else {
// for cdi, cdv := range outputData.CylindricalData {
// if cdv.Name == normNameTotal {
// outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, sumScore)
// }
// }
// }
// normNameAverage := fmt.Sprintf("%v平均值", normName)
// if commonus.IsItTrueString(normNameAverage, outputData.Cylindrical) == false {
// outputData.Cylindrical = append(outputData.Cylindrical, normNameAverage)
// var seriesInfoAverage series
// seriesInfoAverage.Name = normNameAverage
// seriesInfoAverage.Data = append(seriesInfoAverage.Data, averageScore)
// outputData.CylindricalData = append(outputData.CylindricalData, seriesInfoAverage)
// } else {
// for cdi, cdv := range outputData.CylindricalData {
// if cdv.Name == normNameAverage {
// outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, averageScore)
// }
// }
// }
// }
// }
// case 3:
// //月
// if commonus.IsItTrueString(tfv.XLine, outputData.XLine) == false {
// outputData.XLine = append(outputData.XLine, tfv.XLine)
// }
// for _, yearVal := range dataAry.Year {
// wherStr := fmt.Sprintf("fld_evaluation_id = %v AND `fl_year` = %v AND `fl_month` = %v", taskId, yearVal, tfv.YearName)
// if len(dataAry.AccMethod) > 0 {
// if commonus.IsItTrueInt(1, dataAry.AccMethod) == true && commonus.IsItTrueInt(2, dataAry.AccMethod) == true {
// //合计与平均
// sumScore, averageScore := AverageOfSum(wherStr, 1)
// normNameTotal := fmt.Sprintf("%v总值", normName)
// if commonus.IsItTrueString(normNameTotal, outputData.Cylindrical) == false {
// outputData.Cylindrical = append(outputData.Cylindrical, normNameTotal)
// var seriesInfo series
// seriesInfo.Name = normNameTotal
// seriesInfo.Data = append(seriesInfo.Data, sumScore)
// outputData.CylindricalData = append(outputData.CylindricalData, seriesInfo)
// } else {
// for cdi, cdv := range outputData.CylindricalData {
// if cdv.Name == normNameTotal {
// outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, sumScore)
// }
// }
// }
// normNameAverage := fmt.Sprintf("%v平均值", normName)
// if commonus.IsItTrueString(normNameAverage, outputData.Cylindrical) == false {
// outputData.Cylindrical = append(outputData.Cylindrical, normNameAverage)
// var seriesInfoAverage series
// seriesInfoAverage.Name = normNameAverage
// seriesInfoAverage.Data = append(seriesInfoAverage.Data, averageScore)
// outputData.CylindricalData = append(outputData.CylindricalData, seriesInfoAverage)
// } else {
// for cdi, cdv := range outputData.CylindricalData {
// if cdv.Name == normNameAverage {
// outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, averageScore)
// }
// }
// }
// } else if commonus.IsItTrueInt(1, dataAry.AccMethod) == true {
// //合计
// sumScore, _ := AverageOfSum(wherStr)
// normNameTotal := fmt.Sprintf("%v总值", normName)
// if commonus.IsItTrueString(normNameTotal, outputData.Cylindrical) == false {
// outputData.Cylindrical = append(outputData.Cylindrical, normNameTotal)
// var seriesInfo series
// seriesInfo.Name = normNameTotal
// seriesInfo.Data = append(seriesInfo.Data, sumScore)
// outputData.CylindricalData = append(outputData.CylindricalData, seriesInfo)
// } else {
// for cdi, cdv := range outputData.CylindricalData {
// if cdv.Name == normNameTotal {
// outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, sumScore)
// }
// }
// }
// } else if commonus.IsItTrueInt(2, dataAry.AccMethod) == true {
// _, averageScore := AverageOfSum(wherStr, 1)
// normNameAverage := fmt.Sprintf("%v平均值", normName)
// if commonus.IsItTrueString(normNameAverage, outputData.Cylindrical) == false {
// outputData.Cylindrical = append(outputData.Cylindrical, normNameAverage)
// var seriesInfoAverage series
// seriesInfoAverage.Name = normNameAverage
// seriesInfoAverage.Data = append(seriesInfoAverage.Data, averageScore)
// outputData.CylindricalData = append(outputData.CylindricalData, seriesInfoAverage)
// } else {
// for cdi, cdv := range outputData.CylindricalData {
// if cdv.Name == normNameAverage {
// outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, averageScore)
// }
// }
// }
// }
// } else {
// //合计与平均
// sumScore, averageScore := AverageOfSum(wherStr, 1)
// normNameTotal := fmt.Sprintf("%v总值", normName)
// if commonus.IsItTrueString(normNameTotal, outputData.Cylindrical) == false {
// outputData.Cylindrical = append(outputData.Cylindrical, normNameTotal)
// var seriesInfo series
// seriesInfo.Name = normNameTotal
// seriesInfo.Data = append(seriesInfo.Data, sumScore)
// outputData.CylindricalData = append(outputData.CylindricalData, seriesInfo)
// } else {
// for cdi, cdv := range outputData.CylindricalData {
// if cdv.Name == normNameTotal {
// outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, sumScore)
// }
// }
// }
// normNameAverage := fmt.Sprintf("%v平均值", normName)
// if commonus.IsItTrueString(normNameAverage, outputData.Cylindrical) == false {
// outputData.Cylindrical = append(outputData.Cylindrical, normNameAverage)
// var seriesInfoAverage series
// seriesInfoAverage.Name = normNameAverage
// seriesInfoAverage.Data = append(seriesInfoAverage.Data, averageScore)
// outputData.CylindricalData = append(outputData.CylindricalData, seriesInfoAverage)
// } else {
// for cdi, cdv := range outputData.CylindricalData {
// if cdv.Name == normNameAverage {
// outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, averageScore)
// }
// }
// }
// }
// }
// default:
// //全年
// if commonus.IsItTrueString(tfv.XLine, outputData.XLine) == false {
// outputData.XLine = append(outputData.XLine, tfv.XLine)
// }
// for _, tfwv := range tfv.Where {
// wherStr := fmt.Sprintf("fld_evaluation_id = %v AND `fl_year` = %v", taskId, tfwv)
// if len(dataAry.Org) > 0 {
// //存在组织结构
// _, orgList := getGroupOrg(dataAry.Org)
// if len(orgList) > 0 {
// for _, orgv := range orgList {
// if orgv.Level <= 2 {
// wherStr = fmt.Sprintf("%v AND `fl_duty_group` = %v", wherStr, orgv.Id)
// } else {
// wherStr = fmt.Sprintf("%v AND `fl_duty_department` = %v", wherStr, orgv.Id)
// }
// switch statisticalMethod {
// case 1:
// //合计
// sumScore, _ := AverageOfSum(wherStr)
// normNameTotal := fmt.Sprintf("%v %v总值", orgv.Name, normName)
// if commonus.IsItTrueString(normNameTotal, outputData.Cylindrical) == false {
// outputData.Cylindrical = append(outputData.Cylindrical, normNameTotal)
// var seriesInfo series
// seriesInfo.Name = normNameTotal
// seriesInfo.Data = append(seriesInfo.Data, sumScore)
// outputData.CylindricalData = append(outputData.CylindricalData, seriesInfo)
// } else {
// for cdi, cdv := range outputData.CylindricalData {
// if cdv.Name == normNameTotal {
// outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, sumScore)
// }
// }
// }
// case 2:
// _, averageScore := AverageOfSum(wherStr, 1)
// normNameAverage := fmt.Sprintf("%v %v平均值", orgv.Name, normName)
// if commonus.IsItTrueString(normNameAverage, outputData.Cylindrical) == false {
// outputData.Cylindrical = append(outputData.Cylindrical, normNameAverage)
// var seriesInfoAverage series
// seriesInfoAverage.Name = normNameAverage
// seriesInfoAverage.Data = append(seriesInfoAverage.Data, averageScore)
// outputData.CylindricalData = append(outputData.CylindricalData, seriesInfoAverage)
// } else {
// for cdi, cdv := range outputData.CylindricalData {
// if cdv.Name == normNameAverage {
// outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, averageScore)
// }
// }
// }
// default:
// //合计与平均
// sumScore, averageScore := AverageOfSum(wherStr, 1)
// normNameTotal := fmt.Sprintf("%v %v总值", orgv.Name, normName)
// if commonus.IsItTrueString(normNameTotal, outputData.Cylindrical) == false {
// outputData.Cylindrical = append(outputData.Cylindrical, normNameTotal)
// var seriesInfo series
// seriesInfo.Name = normNameTotal
// seriesInfo.Data = append(seriesInfo.Data, sumScore)
// outputData.CylindricalData = append(outputData.CylindricalData, seriesInfo)
// } else {
// for cdi, cdv := range outputData.CylindricalData {
// if cdv.Name == normNameTotal {
// outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, sumScore)
// }
// }
// }
// normNameAverage := fmt.Sprintf("%v %v平均值", orgv.Name, normName)
// if commonus.IsItTrueString(normNameAverage, outputData.Cylindrical) == false {
// outputData.Cylindrical = append(outputData.Cylindrical, normNameAverage)
// var seriesInfoAverage series
// seriesInfoAverage.Name = normNameAverage
// seriesInfoAverage.Data = append(seriesInfoAverage.Data, averageScore)
// outputData.CylindricalData = append(outputData.CylindricalData, seriesInfoAverage)
// } else {
// for cdi, cdv := range outputData.CylindricalData {
// if cdv.Name == normNameAverage {
// outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, averageScore)
// }
// }
// }
// }
// }
// }
// } else {
// //不存在行政组织
// switch statisticalMethod {
// case 1:
// //合计
// sumScore, _ := AverageOfSum(wherStr)
// normNameTotal := fmt.Sprintf("%v总值", normName)
// if commonus.IsItTrueString(normNameTotal, outputData.Cylindrical) == false {
// outputData.Cylindrical = append(outputData.Cylindrical, normNameTotal)
// var seriesInfo series
// seriesInfo.Name = normNameTotal
// seriesInfo.Data = append(seriesInfo.Data, sumScore)
// outputData.CylindricalData = append(outputData.CylindricalData, seriesInfo)
// } else {
// for cdi, cdv := range outputData.CylindricalData {
// if cdv.Name == normNameTotal {
// outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, sumScore)
// }
// }
// }
// case 2:
// _, averageScore := AverageOfSum(wherStr, 1)
// normNameAverage := fmt.Sprintf("%v平均值", normName)
// if commonus.IsItTrueString(normNameAverage, outputData.Cylindrical) == false {
// outputData.Cylindrical = append(outputData.Cylindrical, normNameAverage)
// var seriesInfoAverage series
// seriesInfoAverage.Name = normNameAverage
// seriesInfoAverage.Data = append(seriesInfoAverage.Data, averageScore)
// outputData.CylindricalData = append(outputData.CylindricalData, seriesInfoAverage)
// } else {
// for cdi, cdv := range outputData.CylindricalData {
// if cdv.Name == normNameAverage {
// outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, averageScore)
// }
// }
// }
// default:
// //合计与平均
// sumScore, averageScore := AverageOfSum(wherStr, 1)
// normNameTotal := fmt.Sprintf("%v总值", normName)
// if commonus.IsItTrueString(normNameTotal, outputData.Cylindrical) == false {
// outputData.Cylindrical = append(outputData.Cylindrical, normNameTotal)
// var seriesInfo series
// seriesInfo.Name = normNameTotal
// seriesInfo.Data = append(seriesInfo.Data, sumScore)
// outputData.CylindricalData = append(outputData.CylindricalData, seriesInfo)
// } else {
// for cdi, cdv := range outputData.CylindricalData {
// if cdv.Name == normNameTotal {
// outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, sumScore)
// }
// }
// }
// normNameAverage := fmt.Sprintf("%v平均值", normName)
// if commonus.IsItTrueString(normNameAverage, outputData.Cylindrical) == false {
// outputData.Cylindrical = append(outputData.Cylindrical, normNameAverage)
// var seriesInfoAverage series
// seriesInfoAverage.Name = normNameAverage
// seriesInfoAverage.Data = append(seriesInfoAverage.Data, averageScore)
// outputData.CylindricalData = append(outputData.CylindricalData, seriesInfoAverage)
// } else {
// for cdi, cdv := range outputData.CylindricalData {
// if cdv.Name == normNameAverage {
// outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, averageScore)
// }
// }
// }
// }
// }
// }
// }
// }
// // fmt.Println(normName)
// return
// }

996
gin_server_admin/api/statistics/quantification/timestatistics.go

@ -0,0 +1,996 @@
package quantification
import (
"fmt"
"strconv"
"github.com/flipped-aurora/gin-vue-admin/server/commonus"
"github.com/flipped-aurora/gin-vue-admin/server/global"
"github.com/flipped-aurora/gin-vue-admin/server/model/assessmentmodel"
)
//以时间维度查询统计
/*
@taskId 指标ID
@dataAry 接收的界定参数
*/
func TimeDimensionStatistics(taskId string, dataAry natureParameter) (outputData GraphicStatistics, outErr bool) {
outErr = true
var normName string = ""
norm := 1 //1:定性考核;2:定量考核
//获取指标信息
taskIdInt, _ := strconv.ParseInt(taskId, 10, 64)
taskCont, taskErr := commonus.GetTargetInfo(taskIdInt)
if taskErr == true {
normName = taskCont.Title
outErr = taskErr
norm = taskCont.Type
} else {
// outErr = error.Error("此考核项目没有数据!")
outErr = taskErr
return
}
//获取时间参数
timeFrame := EstimatedTime(dataAry)
//获取组织架构参数
// var orgAry []orgModelsAry
var orgList []orgModels
if len(dataAry.Org) > 0 {
_, orgList = getGroupOrgList(dataAry.Org)
} else {
_, orgList = getGroupOrgList(GetTargerDepartment(taskCont.Dimension, taskIdInt))
}
// fmt.Printf("orgList ---> %v\n", orgList)
//统计方式
statisticalMethod := 3
if len(dataAry.AccMethod) == 1 {
if commonus.IsItTrueInt(1, dataAry.AccMethod) == true {
statisticalMethod = 1
} else {
statisticalMethod = 2
}
}
//根据时间维度进行统计
for _, tfv := range timeFrame {
if commonus.IsItTrueString(tfv.XLine, outputData.XLine) == false {
outputData.XLine = append(outputData.XLine, tfv.XLine)
}
switch tfv.Class {
case 1: //半年
//组合月
monthStr := "("
for twi, twv := range tfv.Where {
if twi != 0 {
monthStr = fmt.Sprintf("%v,%v", monthStr, twv)
} else {
monthStr = fmt.Sprintf("%v%v", monthStr, twv)
}
}
monthStr = fmt.Sprintf("%v)", monthStr)
//定量考核
if len(orgList) > 0 {
//有政组织
for _, orgv := range orgList {
var orgvSunOrg string
//获取此指标跟查询部门相关的考核方案ID
var taskIdAry []int64
// global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.QualitativeEvaluation{}).Select("qe_id").Where("qe_state = 1 AND qe_dimension = ? AND qe_target = ? AND qe_accept_evaluation = ?", taskCont.Dimension, taskIdInt, orgv.Id).Find(&taskIdAry)
if len(orgv.SunOrg) > 0 {
orgvSunOrg = "("
for tiai, tiav := range orgv.SunOrg {
if tiai != 0 {
orgvSunOrg = fmt.Sprintf("%v,%v", orgvSunOrg, tiav)
} else {
orgvSunOrg = fmt.Sprintf("%v%v", orgvSunOrg, tiav)
}
}
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.QualitativeEvaluation{}).Select("qe_id").Where("qe_state = 1 AND qe_dimension = ? AND qe_target = ? AND qe_accept_evaluation IN ?", taskCont.Dimension, taskIdInt, orgv.SunOrg).Find(&taskIdAry)
} else {
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.QualitativeEvaluation{}).Select("qe_id").Where("qe_state = 1 AND qe_dimension = ? AND qe_target = ? AND qe_accept_evaluation = ?", taskCont.Dimension, taskIdInt, orgv.Id).Find(&taskIdAry)
}
//组合考核方案ID
taskIdStrWher := "("
for tiai, tiav := range taskIdAry {
if tiai != 0 {
taskIdStrWher = fmt.Sprintf("%v,%v", taskIdStrWher, tiav)
} else {
taskIdStrWher = fmt.Sprintf("%v%v", taskIdStrWher, tiav)
}
}
taskIdStrWher = fmt.Sprintf("%v)", taskIdStrWher)
for _, yearVal := range dataAry.Year {
var sumScore float64
var averageScore float64
if len(taskIdAry) > 0 {
var wherStr string
if norm == 1 {
//定性考核
if len(orgv.SunOrg) > 0 {
orgvSunOrg = fmt.Sprintf("%v)", orgvSunOrg)
wherStr = fmt.Sprintf("sf_evaluation_plan IN %v AND `sf_year` = %v AND `sf_month` IN %v AND sf_duty_department IN %v", taskIdStrWher, yearVal, monthStr, orgvSunOrg)
} else {
wherStr = fmt.Sprintf("sf_evaluation_plan IN %v AND `sf_year` = %v AND `sf_month` IN %v AND sf_duty_department = %v", taskIdStrWher, yearVal, monthStr, orgv.Id)
}
sumScore, averageScore = AverageOfSumNature(wherStr, 1)
} else {
//定量考核
if len(orgv.SunOrg) > 0 {
wherStr = fmt.Sprintf("fld_evaluation_id IN %v AND `fl_year` = %v AND `fl_month` IN %v AND fl_duty_department IN %v", taskIdStrWher, yearVal, monthStr, orgvSunOrg)
} else {
wherStr = fmt.Sprintf("fld_evaluation_id IN %v AND `fl_year` = %v AND `fl_month` IN %v AND fl_duty_department = %v", taskIdStrWher, yearVal, monthStr, orgv.Id)
}
sumScore, averageScore = AverageOfSum(wherStr, 1)
}
}
switch statisticalMethod {
case 1:
//合计
normNameTotal := fmt.Sprintf("%v%v %v总值", yearVal, orgv.Name, normName)
if commonus.IsItTrueString(normNameTotal, outputData.Cylindrical) == false {
outputData.Cylindrical = append(outputData.Cylindrical, normNameTotal)
var seriesInfo series
seriesInfo.Name = normNameTotal
seriesInfo.Data = append(seriesInfo.Data, sumScore)
outputData.CylindricalData = append(outputData.CylindricalData, seriesInfo)
} else {
for cdi, cdv := range outputData.CylindricalData {
if cdv.Name == normNameTotal {
outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, sumScore)
}
}
}
case 2:
//平均
normNameAverage := fmt.Sprintf("%v%v %v平均值", yearVal, orgv.Name, normName)
if commonus.IsItTrueString(normNameAverage, outputData.Cylindrical) == false {
outputData.Cylindrical = append(outputData.Cylindrical, normNameAverage)
var seriesInfoAverage series
seriesInfoAverage.Name = normNameAverage
seriesInfoAverage.Data = append(seriesInfoAverage.Data, averageScore)
outputData.CylindricalData = append(outputData.CylindricalData, seriesInfoAverage)
} else {
for cdi, cdv := range outputData.CylindricalData {
if cdv.Name == normNameAverage {
outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, averageScore)
}
}
}
default:
//合计与平均
normNameTotal := fmt.Sprintf("%v%v %v总值", yearVal, orgv.Name, normName)
if commonus.IsItTrueString(normNameTotal, outputData.Cylindrical) == false {
outputData.Cylindrical = append(outputData.Cylindrical, normNameTotal)
var seriesInfo series
seriesInfo.Name = normNameTotal
seriesInfo.Data = append(seriesInfo.Data, sumScore)
outputData.CylindricalData = append(outputData.CylindricalData, seriesInfo)
} else {
for cdi, cdv := range outputData.CylindricalData {
if cdv.Name == normNameTotal {
outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, sumScore)
}
}
}
normNameAverage := fmt.Sprintf("%v%v %v平均值", yearVal, orgv.Name, normName)
if commonus.IsItTrueString(normNameAverage, outputData.Cylindrical) == false {
outputData.Cylindrical = append(outputData.Cylindrical, normNameAverage)
var seriesInfoAverage series
seriesInfoAverage.Name = normNameAverage
seriesInfoAverage.Data = append(seriesInfoAverage.Data, averageScore)
outputData.CylindricalData = append(outputData.CylindricalData, seriesInfoAverage)
} else {
for cdi, cdv := range outputData.CylindricalData {
if cdv.Name == normNameAverage {
outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, averageScore)
}
}
}
}
}
}
} else {
//无行政组织
var sumScore float64
var averageScore float64
//获取此指标跟查询部门相关的考核方案ID
var taskIdAry []int64
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.QualitativeEvaluation{}).Select("qe_id").Where("qe_state = 1 AND qe_dimension = ? AND qe_target = ?", taskCont.Dimension, taskIdInt).Find(&taskIdAry)
//组合考核方案ID
taskIdStrWher := "("
for tiai, tiav := range taskIdAry {
if tiai != 0 {
taskIdStrWher = fmt.Sprintf("%v,%v", taskIdStrWher, tiav)
} else {
taskIdStrWher = fmt.Sprintf("%v%v", taskIdStrWher, tiav)
}
}
taskIdStrWher = fmt.Sprintf("%v)", taskIdStrWher)
if len(taskIdAry) > 0 {
if norm == 1 {
//定性考核
wherStr := fmt.Sprintf("sf_evaluation_plan IN %v AND `sf_year` = %v AND `sf_month` IN %v ", taskIdStrWher, tfv.YearName, monthStr)
sumScore, averageScore = AverageOfSumNature(wherStr, 1)
} else {
//定量考核
wherStr := fmt.Sprintf("fld_evaluation_id IN %v AND `fl_year` = %v AND `fl_month` IN %v", taskIdStrWher, tfv.YearName, monthStr)
sumScore, averageScore = AverageOfSum(wherStr, 1)
}
}
//不存在行政组织
switch statisticalMethod {
case 1:
//合计
normNameTotal := fmt.Sprintf("%v总值", normName)
if commonus.IsItTrueString(normNameTotal, outputData.Cylindrical) == false {
outputData.Cylindrical = append(outputData.Cylindrical, normNameTotal)
var seriesInfo series
seriesInfo.Name = normNameTotal
seriesInfo.Data = append(seriesInfo.Data, sumScore)
outputData.CylindricalData = append(outputData.CylindricalData, seriesInfo)
} else {
for cdi, cdv := range outputData.CylindricalData {
if cdv.Name == normNameTotal {
outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, sumScore)
}
}
}
case 2:
//平均
normNameAverage := fmt.Sprintf("%v平均值", normName)
if commonus.IsItTrueString(normNameAverage, outputData.Cylindrical) == false {
outputData.Cylindrical = append(outputData.Cylindrical, normNameAverage)
var seriesInfoAverage series
seriesInfoAverage.Name = normNameAverage
seriesInfoAverage.Data = append(seriesInfoAverage.Data, averageScore)
outputData.CylindricalData = append(outputData.CylindricalData, seriesInfoAverage)
} else {
for cdi, cdv := range outputData.CylindricalData {
if cdv.Name == normNameAverage {
outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, averageScore)
}
}
}
default:
//合计与平均
normNameTotal := fmt.Sprintf("%v总值", normName)
if commonus.IsItTrueString(normNameTotal, outputData.Cylindrical) == false {
outputData.Cylindrical = append(outputData.Cylindrical, normNameTotal)
var seriesInfo series
seriesInfo.Name = normNameTotal
seriesInfo.Data = append(seriesInfo.Data, sumScore)
outputData.CylindricalData = append(outputData.CylindricalData, seriesInfo)
} else {
for cdi, cdv := range outputData.CylindricalData {
if cdv.Name == normNameTotal {
outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, sumScore)
}
}
}
normNameAverage := fmt.Sprintf("%v平均值", normName)
if commonus.IsItTrueString(normNameAverage, outputData.Cylindrical) == false {
outputData.Cylindrical = append(outputData.Cylindrical, normNameAverage)
var seriesInfoAverage series
seriesInfoAverage.Name = normNameAverage
seriesInfoAverage.Data = append(seriesInfoAverage.Data, averageScore)
outputData.CylindricalData = append(outputData.CylindricalData, seriesInfoAverage)
} else {
for cdi, cdv := range outputData.CylindricalData {
if cdv.Name == normNameAverage {
outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, averageScore)
}
}
}
}
}
case 2: //季度
for _, yearVal := range dataAry.Year {
if len(orgList) > 0 {
//有组织
for _, orgv := range orgList {
var sumScore float64
var averageScore float64
//获取此指标跟查询部门相关的考核方案ID
var orgvSunOrg string
var taskIdAry []int64
if len(orgv.SunOrg) > 0 {
orgvSunOrg = "("
for tiai, tiav := range orgv.SunOrg {
if tiai != 0 {
orgvSunOrg = fmt.Sprintf("%v,%v", orgvSunOrg, tiav)
} else {
orgvSunOrg = fmt.Sprintf("%v%v", orgvSunOrg, tiav)
}
}
orgvSunOrg = fmt.Sprintf("%v)", orgvSunOrg)
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.QualitativeEvaluation{}).Select("qe_id").Where("qe_state = 1 AND qe_dimension = ? AND qe_target = ? AND qe_accept_evaluation IN ?", taskCont.Dimension, taskIdInt, orgv.SunOrg).Find(&taskIdAry)
} else {
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.QualitativeEvaluation{}).Select("qe_id").Where("qe_state = 1 AND qe_dimension = ? AND qe_target = ? AND qe_accept_evaluation = ?", taskCont.Dimension, taskIdInt, orgv.Id).Find(&taskIdAry)
}
//组合考核方案ID
taskIdStrWher := "("
for tiai, tiav := range taskIdAry {
if tiai != 0 {
taskIdStrWher = fmt.Sprintf("%v,%v", taskIdStrWher, tiav)
} else {
taskIdStrWher = fmt.Sprintf("%v%v", taskIdStrWher, tiav)
}
}
taskIdStrWher = fmt.Sprintf("%v)", taskIdStrWher)
if len(taskIdAry) > 0 {
var wherStr string
if norm == 1 {
//定性考核
if len(orgv.SunOrg) > 0 {
wherStr = fmt.Sprintf("sf_evaluation_plan IN %v AND `sf_year` = %v AND `sf_quarter` = %v AND sf_duty_department IN %v", taskIdStrWher, yearVal, tfv.YearName, orgvSunOrg)
} else {
wherStr = fmt.Sprintf("sf_evaluation_plan IN %v AND `sf_year` = %v AND `sf_quarter` = %v AND sf_duty_department = %v", taskIdStrWher, yearVal, tfv.YearName, orgv.Id)
}
sumScore, averageScore = AverageOfSumNature(wherStr, 1)
} else {
//定量考核
if len(orgv.SunOrg) > 0 {
wherStr = fmt.Sprintf("fld_evaluation_id IN %v AND `fl_year` = %v AND `fl_quarter` = %v AND fl_duty_department IN %v", taskIdStrWher, yearVal, tfv.YearName, orgvSunOrg)
} else {
wherStr = fmt.Sprintf("fld_evaluation_id IN %v AND `fl_year` = %v AND `fl_quarter` = %v AND fl_duty_department = %v", taskIdStrWher, yearVal, tfv.YearName, orgv.Id)
}
sumScore, averageScore = AverageOfSum(wherStr, 1)
}
}
switch statisticalMethod {
case 1:
//合计
normNameTotal := fmt.Sprintf("%v%v %v总值", yearVal, orgv.Name, normName)
if commonus.IsItTrueString(normNameTotal, outputData.Cylindrical) == false {
outputData.Cylindrical = append(outputData.Cylindrical, normNameTotal)
var seriesInfo series
seriesInfo.Name = normNameTotal
seriesInfo.Data = append(seriesInfo.Data, sumScore)
outputData.CylindricalData = append(outputData.CylindricalData, seriesInfo)
} else {
for cdi, cdv := range outputData.CylindricalData {
if cdv.Name == normNameTotal {
outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, sumScore)
}
}
}
case 2:
//平均
normNameAverage := fmt.Sprintf("%v%v %v平均值", yearVal, orgv.Name, normName)
if commonus.IsItTrueString(normNameAverage, outputData.Cylindrical) == false {
outputData.Cylindrical = append(outputData.Cylindrical, normNameAverage)
var seriesInfoAverage series
seriesInfoAverage.Name = normNameAverage
seriesInfoAverage.Data = append(seriesInfoAverage.Data, averageScore)
outputData.CylindricalData = append(outputData.CylindricalData, seriesInfoAverage)
} else {
for cdi, cdv := range outputData.CylindricalData {
if cdv.Name == normNameAverage {
outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, averageScore)
}
}
}
default:
//合计与平均
normNameTotal := fmt.Sprintf("%v%v %v总值", yearVal, orgv.Name, normName)
if commonus.IsItTrueString(normNameTotal, outputData.Cylindrical) == false {
outputData.Cylindrical = append(outputData.Cylindrical, normNameTotal)
var seriesInfo series
seriesInfo.Name = normNameTotal
seriesInfo.Data = append(seriesInfo.Data, sumScore)
outputData.CylindricalData = append(outputData.CylindricalData, seriesInfo)
} else {
for cdi, cdv := range outputData.CylindricalData {
if cdv.Name == normNameTotal {
outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, sumScore)
}
}
}
normNameAverage := fmt.Sprintf("%v %v平均值", orgv.Name, normName)
if commonus.IsItTrueString(normNameAverage, outputData.Cylindrical) == false {
outputData.Cylindrical = append(outputData.Cylindrical, normNameAverage)
var seriesInfoAverage series
seriesInfoAverage.Name = normNameAverage
seriesInfoAverage.Data = append(seriesInfoAverage.Data, averageScore)
outputData.CylindricalData = append(outputData.CylindricalData, seriesInfoAverage)
} else {
for cdi, cdv := range outputData.CylindricalData {
if cdv.Name == normNameAverage {
outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, averageScore)
}
}
}
}
}
} else {
var sumScore float64
var averageScore float64
//获取此指标跟查询部门相关的考核方案ID
var taskIdAry []int64
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.QualitativeEvaluation{}).Select("qe_id").Where("qe_state = 1 AND qe_dimension = ? AND qe_target = ?", taskCont.Dimension, taskIdInt).Find(&taskIdAry)
//组合考核方案ID
taskIdStrWher := "("
for tiai, tiav := range taskIdAry {
if tiai != 0 {
taskIdStrWher = fmt.Sprintf("%v,%v", taskIdStrWher, tiav)
} else {
taskIdStrWher = fmt.Sprintf("%v%v", taskIdStrWher, tiav)
}
}
taskIdStrWher = fmt.Sprintf("%v)", taskIdStrWher)
//无组织
if len(taskIdAry) > 0 {
if norm == 1 {
//定性考核
} else {
//定量考核
// wherStr := fmt.Sprintf("`fl_year` = %v AND `fl_quarter` = %v", yearVal, tfv.YearName)
wherStr := fmt.Sprintf("fld_evaluation_id IN %v AND `fl_year` = %v AND `fl_quarter` IN %v ", taskIdStrWher, yearVal, tfv.YearName)
sumScore, averageScore = AverageOfSum(wherStr, 1)
}
}
switch statisticalMethod {
case 1:
//合计
normNameTotal := fmt.Sprintf("%v总值", normName)
if commonus.IsItTrueString(normNameTotal, outputData.Cylindrical) == false {
outputData.Cylindrical = append(outputData.Cylindrical, normNameTotal)
var seriesInfo series
seriesInfo.Name = normNameTotal
seriesInfo.Data = append(seriesInfo.Data, sumScore)
outputData.CylindricalData = append(outputData.CylindricalData, seriesInfo)
} else {
for cdi, cdv := range outputData.CylindricalData {
if cdv.Name == normNameTotal {
outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, sumScore)
}
}
}
case 2:
//平均
normNameAverage := fmt.Sprintf("%v平均值", normName)
if commonus.IsItTrueString(normNameAverage, outputData.Cylindrical) == false {
outputData.Cylindrical = append(outputData.Cylindrical, normNameAverage)
var seriesInfoAverage series
seriesInfoAverage.Name = normNameAverage
seriesInfoAverage.Data = append(seriesInfoAverage.Data, averageScore)
outputData.CylindricalData = append(outputData.CylindricalData, seriesInfoAverage)
} else {
for cdi, cdv := range outputData.CylindricalData {
if cdv.Name == normNameAverage {
outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, averageScore)
}
}
}
default:
//合计与平均
normNameTotal := fmt.Sprintf("%v总值", normName)
if commonus.IsItTrueString(normNameTotal, outputData.Cylindrical) == false {
outputData.Cylindrical = append(outputData.Cylindrical, normNameTotal)
var seriesInfo series
seriesInfo.Name = normNameTotal
seriesInfo.Data = append(seriesInfo.Data, sumScore)
outputData.CylindricalData = append(outputData.CylindricalData, seriesInfo)
} else {
for cdi, cdv := range outputData.CylindricalData {
if cdv.Name == normNameTotal {
outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, sumScore)
}
}
}
normNameAverage := fmt.Sprintf("%v平均值", normName)
if commonus.IsItTrueString(normNameAverage, outputData.Cylindrical) == false {
outputData.Cylindrical = append(outputData.Cylindrical, normNameAverage)
var seriesInfoAverage series
seriesInfoAverage.Name = normNameAverage
seriesInfoAverage.Data = append(seriesInfoAverage.Data, averageScore)
outputData.CylindricalData = append(outputData.CylindricalData, seriesInfoAverage)
} else {
for cdi, cdv := range outputData.CylindricalData {
if cdv.Name == normNameAverage {
outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, averageScore)
}
}
}
}
}
}
case 3: //月
for _, yearVal := range dataAry.Year {
if len(orgList) > 0 {
//有组织
for _, orgv := range orgList {
var sumScore float64
var averageScore float64
//获取此指标跟查询部门相关的考核方案ID
var orgvSunOrg string
var taskIdAry []int64
if len(orgv.SunOrg) > 0 {
orgvSunOrg = "("
for tiai, tiav := range orgv.SunOrg {
if tiai != 0 {
orgvSunOrg = fmt.Sprintf("%v,%v", orgvSunOrg, tiav)
} else {
orgvSunOrg = fmt.Sprintf("%v%v", orgvSunOrg, tiav)
}
}
orgvSunOrg = fmt.Sprintf("%v)", orgvSunOrg)
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.QualitativeEvaluation{}).Select("qe_id").Where("qe_state = 1 AND qe_dimension = ? AND qe_target = ? AND qe_accept_evaluation IN ?", taskCont.Dimension, taskIdInt, orgv.SunOrg).Find(&taskIdAry)
} else {
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.QualitativeEvaluation{}).Select("qe_id").Where("qe_state = 1 AND qe_dimension = ? AND qe_target = ? AND qe_accept_evaluation = ?", taskCont.Dimension, taskIdInt, orgv.Id).Find(&taskIdAry)
}
//组合考核方案ID
taskIdStrWher := "("
for tiai, tiav := range taskIdAry {
if tiai != 0 {
taskIdStrWher = fmt.Sprintf("%v,%v", taskIdStrWher, tiav)
} else {
taskIdStrWher = fmt.Sprintf("%v%v", taskIdStrWher, tiav)
}
}
taskIdStrWher = fmt.Sprintf("%v)", taskIdStrWher)
if len(taskIdAry) > 0 {
var wherStr string
if norm == 1 {
//定性考核
if len(orgv.SunOrg) > 0 {
wherStr = fmt.Sprintf("sf_evaluation_plan IN %v AND `sf_year` = %v AND `sf_month` = %v AND sf_duty_department IN %v", taskIdStrWher, yearVal, tfv.YearName, orgvSunOrg)
} else {
wherStr = fmt.Sprintf("sf_evaluation_plan IN %v AND `sf_year` = %v AND `sf_month` = %v AND sf_duty_department = %v", taskIdStrWher, yearVal, tfv.YearName, orgv.Id)
}
sumScore, averageScore = AverageOfSumNature(wherStr, 1)
} else {
//定量考核
if len(orgv.SunOrg) > 0 {
wherStr = fmt.Sprintf("fld_evaluation_id IN %v AND `fl_year` = %v AND `fl_month` = %v AND fl_duty_department IN %v", taskIdStrWher, yearVal, tfv.YearName, orgvSunOrg)
} else {
wherStr = fmt.Sprintf("fld_evaluation_id IN %v AND `fl_year` = %v AND `fl_month` = %v AND fl_duty_department = %v", taskIdStrWher, yearVal, tfv.YearName, orgv.Id)
}
sumScore, averageScore = AverageOfSum(wherStr, 1)
}
}
switch statisticalMethod {
case 1:
//合计
normNameTotal := fmt.Sprintf("%v%v %v总值", yearVal, orgv.Name, normName)
if commonus.IsItTrueString(normNameTotal, outputData.Cylindrical) == false {
outputData.Cylindrical = append(outputData.Cylindrical, normNameTotal)
var seriesInfo series
seriesInfo.Name = normNameTotal
seriesInfo.Data = append(seriesInfo.Data, sumScore)
outputData.CylindricalData = append(outputData.CylindricalData, seriesInfo)
} else {
for cdi, cdv := range outputData.CylindricalData {
if cdv.Name == normNameTotal {
outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, sumScore)
}
}
}
case 2:
//平均
normNameAverage := fmt.Sprintf("%v%v %v平均值", yearVal, orgv.Name, normName)
if commonus.IsItTrueString(normNameAverage, outputData.Cylindrical) == false {
outputData.Cylindrical = append(outputData.Cylindrical, normNameAverage)
var seriesInfoAverage series
seriesInfoAverage.Name = normNameAverage
seriesInfoAverage.Data = append(seriesInfoAverage.Data, averageScore)
outputData.CylindricalData = append(outputData.CylindricalData, seriesInfoAverage)
} else {
for cdi, cdv := range outputData.CylindricalData {
if cdv.Name == normNameAverage {
outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, averageScore)
}
}
}
default:
//合计与平均
normNameTotal := fmt.Sprintf("%v%v %v总值", yearVal, orgv.Name, normName)
if commonus.IsItTrueString(normNameTotal, outputData.Cylindrical) == false {
outputData.Cylindrical = append(outputData.Cylindrical, normNameTotal)
var seriesInfo series
seriesInfo.Name = normNameTotal
seriesInfo.Data = append(seriesInfo.Data, sumScore)
outputData.CylindricalData = append(outputData.CylindricalData, seriesInfo)
} else {
for cdi, cdv := range outputData.CylindricalData {
if cdv.Name == normNameTotal {
outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, sumScore)
}
}
}
normNameAverage := fmt.Sprintf("%v %v平均值", orgv.Name, normName)
if commonus.IsItTrueString(normNameAverage, outputData.Cylindrical) == false {
outputData.Cylindrical = append(outputData.Cylindrical, normNameAverage)
var seriesInfoAverage series
seriesInfoAverage.Name = normNameAverage
seriesInfoAverage.Data = append(seriesInfoAverage.Data, averageScore)
outputData.CylindricalData = append(outputData.CylindricalData, seriesInfoAverage)
} else {
for cdi, cdv := range outputData.CylindricalData {
if cdv.Name == normNameAverage {
outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, averageScore)
}
}
}
}
}
} else {
//无组织
var sumScore float64
var averageScore float64
//获取此指标跟查询部门相关的考核方案ID
var taskIdAry []int64
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.QualitativeEvaluation{}).Select("qe_id").Where("qe_state = 1 AND qe_dimension = ? AND qe_target = ?", taskCont.Dimension, taskIdInt).Find(&taskIdAry)
//组合考核方案ID
taskIdStrWher := "("
for tiai, tiav := range taskIdAry {
if tiai != 0 {
taskIdStrWher = fmt.Sprintf("%v,%v", taskIdStrWher, tiav)
} else {
taskIdStrWher = fmt.Sprintf("%v%v", taskIdStrWher, tiav)
}
}
taskIdStrWher = fmt.Sprintf("%v)", taskIdStrWher)
if len(taskIdAry) > 0 {
if norm == 1 {
//定性考核
} else {
//定量考核
wherStr := fmt.Sprintf("fld_evaluation_id IN %v AND `fl_year` = %v AND `fl_month` = %v ", taskIdStrWher, yearVal, tfv.YearName)
sumScore, averageScore = AverageOfSum(wherStr, 1)
}
}
switch statisticalMethod {
case 1:
//合计
normNameTotal := fmt.Sprintf("%v总值", normName)
if commonus.IsItTrueString(normNameTotal, outputData.Cylindrical) == false {
outputData.Cylindrical = append(outputData.Cylindrical, normNameTotal)
var seriesInfo series
seriesInfo.Name = normNameTotal
seriesInfo.Data = append(seriesInfo.Data, sumScore)
outputData.CylindricalData = append(outputData.CylindricalData, seriesInfo)
} else {
for cdi, cdv := range outputData.CylindricalData {
if cdv.Name == normNameTotal {
outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, sumScore)
}
}
}
case 2:
//平均
normNameAverage := fmt.Sprintf("%v平均值", normName)
if commonus.IsItTrueString(normNameAverage, outputData.Cylindrical) == false {
outputData.Cylindrical = append(outputData.Cylindrical, normNameAverage)
var seriesInfoAverage series
seriesInfoAverage.Name = normNameAverage
seriesInfoAverage.Data = append(seriesInfoAverage.Data, averageScore)
outputData.CylindricalData = append(outputData.CylindricalData, seriesInfoAverage)
} else {
for cdi, cdv := range outputData.CylindricalData {
if cdv.Name == normNameAverage {
outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, averageScore)
}
}
}
default:
//合计与平均
normNameTotal := fmt.Sprintf("%v总值", normName)
if commonus.IsItTrueString(normNameTotal, outputData.Cylindrical) == false {
outputData.Cylindrical = append(outputData.Cylindrical, normNameTotal)
var seriesInfo series
seriesInfo.Name = normNameTotal
seriesInfo.Data = append(seriesInfo.Data, sumScore)
outputData.CylindricalData = append(outputData.CylindricalData, seriesInfo)
} else {
for cdi, cdv := range outputData.CylindricalData {
if cdv.Name == normNameTotal {
outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, sumScore)
}
}
}
normNameAverage := fmt.Sprintf("%v平均值", normName)
if commonus.IsItTrueString(normNameAverage, outputData.Cylindrical) == false {
outputData.Cylindrical = append(outputData.Cylindrical, normNameAverage)
var seriesInfoAverage series
seriesInfoAverage.Name = normNameAverage
seriesInfoAverage.Data = append(seriesInfoAverage.Data, averageScore)
outputData.CylindricalData = append(outputData.CylindricalData, seriesInfoAverage)
} else {
for cdi, cdv := range outputData.CylindricalData {
if cdv.Name == normNameAverage {
outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, averageScore)
}
}
}
}
}
}
default: //全年
// if tfv.YearName == ""{}
fmt.Printf("tfv------------>%v\n", tfv)
if len(orgList) > 0 {
for _, orgv := range orgList {
var sumScore float64
var averageScore float64
//获取此指标跟查询部门相关的考核方案ID
var orgvSunOrg string
var taskIdAry []int64
if len(orgv.SunOrg) > 0 {
orgvSunOrg = "("
for tiai, tiav := range orgv.SunOrg {
if tiai != 0 {
orgvSunOrg = fmt.Sprintf("%v,%v", orgvSunOrg, tiav)
} else {
orgvSunOrg = fmt.Sprintf("%v%v", orgvSunOrg, tiav)
}
}
orgvSunOrg = fmt.Sprintf("%v)", orgvSunOrg)
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.QualitativeEvaluation{}).Select("qe_id").Where("qe_state = 1 AND qe_dimension = ? AND qe_target = ? AND qe_accept_evaluation IN ?", taskCont.Dimension, taskIdInt, orgv.SunOrg).Find(&taskIdAry)
} else {
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.QualitativeEvaluation{}).Select("qe_id").Where("qe_state = 1 AND qe_dimension = ? AND qe_target = ? AND qe_accept_evaluation = ?", taskCont.Dimension, taskIdInt, orgv.Id).Find(&taskIdAry)
}
//组合考核方案ID
taskIdStrWher := "("
for tiai, tiav := range taskIdAry {
if tiai != 0 {
taskIdStrWher = fmt.Sprintf("%v,%v", taskIdStrWher, tiav)
} else {
taskIdStrWher = fmt.Sprintf("%v%v", taskIdStrWher, tiav)
}
}
taskIdStrWher = fmt.Sprintf("%v)", taskIdStrWher)
if len(taskIdAry) > 0 {
var wherStr string
if norm == 1 {
//定性考核
if len(orgv.SunOrg) > 0 {
wherStr = fmt.Sprintf("sf_evaluation_plan IN %v AND `sf_year` = %v AND sf_duty_department IN %v", taskIdStrWher, tfv.YearName, orgvSunOrg)
} else {
wherStr = fmt.Sprintf("sf_evaluation_plan IN %v AND `sf_year` = %v AND sf_duty_department = %v", taskIdStrWher, tfv.YearName, orgv.Id)
}
sumScore, averageScore = AverageOfSumNature(wherStr, 1)
} else {
//定量考核
if len(orgv.SunOrg) > 0 {
wherStr = fmt.Sprintf("fld_evaluation_id IN %v AND `fl_year` = %v AND fl_duty_department IN %v", taskIdStrWher, tfv.YearName, orgvSunOrg)
} else {
wherStr = fmt.Sprintf("fld_evaluation_id IN %v AND `fl_year` = %v AND fl_duty_department = %v", taskIdStrWher, tfv.YearName, orgv.Id)
}
// wherStr := fmt.Sprintf("fld_evaluation_id IN %v AND `fl_year` = %v AND fl_duty_department = %v", taskIdStrWher, tfv.YearName, orgv.Id)
sumScore, averageScore = AverageOfSum(wherStr, 1)
}
}
switch statisticalMethod {
case 1:
//合计
normNameTotal := fmt.Sprintf("%v %v总值", orgv.Name, normName)
if commonus.IsItTrueString(normNameTotal, outputData.Cylindrical) == false {
outputData.Cylindrical = append(outputData.Cylindrical, normNameTotal)
var seriesInfo series
seriesInfo.Name = normNameTotal
seriesInfo.Data = append(seriesInfo.Data, sumScore)
outputData.CylindricalData = append(outputData.CylindricalData, seriesInfo)
} else {
for cdi, cdv := range outputData.CylindricalData {
if cdv.Name == normNameTotal {
outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, sumScore)
}
}
}
case 2:
//平均
normNameAverage := fmt.Sprintf("%v %v平均值", orgv.Name, normName)
if commonus.IsItTrueString(normNameAverage, outputData.Cylindrical) == false {
outputData.Cylindrical = append(outputData.Cylindrical, normNameAverage)
var seriesInfoAverage series
seriesInfoAverage.Name = normNameAverage
seriesInfoAverage.Data = append(seriesInfoAverage.Data, averageScore)
outputData.CylindricalData = append(outputData.CylindricalData, seriesInfoAverage)
} else {
for cdi, cdv := range outputData.CylindricalData {
if cdv.Name == normNameAverage {
outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, averageScore)
}
}
}
default:
//合计与平均
normNameTotal := fmt.Sprintf("%v %v总值", orgv.Name, normName)
if commonus.IsItTrueString(normNameTotal, outputData.Cylindrical) == false {
outputData.Cylindrical = append(outputData.Cylindrical, normNameTotal)
var seriesInfo series
seriesInfo.Name = normNameTotal
seriesInfo.Data = append(seriesInfo.Data, sumScore)
outputData.CylindricalData = append(outputData.CylindricalData, seriesInfo)
} else {
for cdi, cdv := range outputData.CylindricalData {
if cdv.Name == normNameTotal {
outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, sumScore)
}
}
}
normNameAverage := fmt.Sprintf("%v %v平均值", orgv.Name, normName)
if commonus.IsItTrueString(normNameAverage, outputData.Cylindrical) == false {
outputData.Cylindrical = append(outputData.Cylindrical, normNameAverage)
var seriesInfoAverage series
seriesInfoAverage.Name = normNameAverage
seriesInfoAverage.Data = append(seriesInfoAverage.Data, averageScore)
outputData.CylindricalData = append(outputData.CylindricalData, seriesInfoAverage)
} else {
for cdi, cdv := range outputData.CylindricalData {
if cdv.Name == normNameAverage {
outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, averageScore)
}
}
}
}
}
} else {
var sumScore float64
var averageScore float64
//获取此指标跟查询部门相关的考核方案ID
var taskIdAry []int64
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.QualitativeEvaluation{}).Select("qe_id").Where("qe_state = 1 AND qe_dimension = ? AND qe_target = ?", taskCont.Dimension, taskIdInt).Find(&taskIdAry)
//组合考核方案ID
taskIdStrWher := "("
for tiai, tiav := range taskIdAry {
if tiai != 0 {
taskIdStrWher = fmt.Sprintf("%v,%v", taskIdStrWher, tiav)
} else {
taskIdStrWher = fmt.Sprintf("%v%v", taskIdStrWher, tiav)
}
}
taskIdStrWher = fmt.Sprintf("%v)", taskIdStrWher)
if len(taskIdAry) > 0 {
if norm == 1 {
//定性考核
wherStr := fmt.Sprintf("sf_evaluation_plan IN %v AND `sf_year` = %v", taskIdStrWher, tfv.YearName)
sumScore, averageScore = AverageOfSumNature(wherStr, 1)
} else {
//定量考核
wherStr := fmt.Sprintf("fld_evaluation_id IN %v AND `fl_year` = %v ", taskIdStrWher, tfv.YearName)
sumScore, averageScore = AverageOfSum(wherStr, 1)
}
}
//不存在行政组织
switch statisticalMethod {
case 1:
//合计
normNameTotal := fmt.Sprintf("%v总值", normName)
if commonus.IsItTrueString(normNameTotal, outputData.Cylindrical) == false {
outputData.Cylindrical = append(outputData.Cylindrical, normNameTotal)
var seriesInfo series
seriesInfo.Name = normNameTotal
seriesInfo.Data = append(seriesInfo.Data, sumScore)
outputData.CylindricalData = append(outputData.CylindricalData, seriesInfo)
} else {
for cdi, cdv := range outputData.CylindricalData {
if cdv.Name == normNameTotal {
outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, sumScore)
}
}
}
case 2:
//平均
normNameAverage := fmt.Sprintf("%v平均值", normName)
if commonus.IsItTrueString(normNameAverage, outputData.Cylindrical) == false {
outputData.Cylindrical = append(outputData.Cylindrical, normNameAverage)
var seriesInfoAverage series
seriesInfoAverage.Name = normNameAverage
seriesInfoAverage.Data = append(seriesInfoAverage.Data, averageScore)
outputData.CylindricalData = append(outputData.CylindricalData, seriesInfoAverage)
} else {
for cdi, cdv := range outputData.CylindricalData {
if cdv.Name == normNameAverage {
outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, averageScore)
}
}
}
default:
//合计与平均
normNameTotal := fmt.Sprintf("%v总值", normName)
if commonus.IsItTrueString(normNameTotal, outputData.Cylindrical) == false {
outputData.Cylindrical = append(outputData.Cylindrical, normNameTotal)
var seriesInfo series
seriesInfo.Name = normNameTotal
seriesInfo.Data = append(seriesInfo.Data, sumScore)
outputData.CylindricalData = append(outputData.CylindricalData, seriesInfo)
} else {
for cdi, cdv := range outputData.CylindricalData {
if cdv.Name == normNameTotal {
outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, sumScore)
}
}
}
normNameAverage := fmt.Sprintf("%v平均值", normName)
if commonus.IsItTrueString(normNameAverage, outputData.Cylindrical) == false {
outputData.Cylindrical = append(outputData.Cylindrical, normNameAverage)
var seriesInfoAverage series
seriesInfoAverage.Name = normNameAverage
seriesInfoAverage.Data = append(seriesInfoAverage.Data, averageScore)
outputData.CylindricalData = append(outputData.CylindricalData, seriesInfoAverage)
} else {
for cdi, cdv := range outputData.CylindricalData {
if cdv.Name == normNameAverage {
outputData.CylindricalData[cdi].Data = append(outputData.CylindricalData[cdi].Data, averageScore)
}
}
}
}
}
}
}
// fmt.Printf("orgAry====>%v\n", orgAry)
// jn, je := json.Marshal(orgList)
// fmt.Printf("orgList-====>%v-====>%v\n", string(jn), je)
// fmt.Printf("timeFrame-====>%v\n", timeFrame)
// fmt.Printf("normName-====>%v\n", normName)
// fmt.Printf("statisticalMethod-====>%v\n", statisticalMethod)
return
}
//获取指标关联的部门
func GetTargerDepartment(dimension, targerId int64) (departID []string) {
var taskIdAry []int64
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.QualitativeEvaluation{}).Select("qe_accept_evaluation").Where("qe_state = 1 AND qe_dimension = ? AND qe_target = ?", dimension, targerId).Find(&taskIdAry)
if len(taskIdAry) > 0 {
for _, v := range taskIdAry {
departID = append(departID, strconv.FormatInt(v, 10))
}
}
return
}

146
gin_server_admin/commonus/publichaneld.go

@ -1662,6 +1662,7 @@ func StepAddData(flowID, roleGroupId int64, nextStep, stepName, typeclass, state
var evalProCont assessmentmodel.EvaluationProcess var evalProCont assessmentmodel.EvaluationProcess
judgeErr := global.GVA_DB_Performanceappraisal.Where("`ep_order_key` = ?", flowID).First(&evalProCont).Error judgeErr := global.GVA_DB_Performanceappraisal.Where("`ep_order_key` = ?", flowID).First(&evalProCont).Error
var flowStepAryMap []FlowStep var flowStepAryMap []FlowStep
fmt.Printf("evalProCont---------%v----------------->%v\n", judgeErr, evalProCont)
if judgeErr != nil { if judgeErr != nil {
var flowSteping FlowStep var flowSteping FlowStep
flowSteping.Step = 1 flowSteping.Step = 1
@ -2141,19 +2142,19 @@ func WriteFlowMainSet(orderId int64, userKey []int64) {
var evalProCont assessmentmodel.EvaluationProcess var evalProCont assessmentmodel.EvaluationProcess
judgeErr := global.GVA_DB_Performanceappraisal.Where("`ep_order_key` = ?", orderId).First(&evalProCont).Error judgeErr := global.GVA_DB_Performanceappraisal.Where("`ep_order_key` = ?", orderId).First(&evalProCont).Error
if judgeErr != nil { if judgeErr != nil {
fmt.Printf("Zeren--1-1->%v\n", userKey) // fmt.Printf("Zeren--1-1->%v\n", userKey)
return return
} }
flowAllMapOldStr := evalProCont.NextContent flowAllMapOldStr := evalProCont.NextContent
fmt.Printf("Zeren--2-->%v\n", flowAllMapOldStr) // fmt.Printf("Zeren--2-->%v\n", flowAllMapOldStr)
var flowMap []FlowAllMap var flowMap []FlowAllMap
jsonErr := json.Unmarshal([]byte(evalProCont.NextContent), &flowMap) jsonErr := json.Unmarshal([]byte(evalProCont.NextContent), &flowMap)
if jsonErr != nil { if jsonErr != nil {
fmt.Printf("Zeren--2-1->%v\n", jsonErr) // fmt.Printf("Zeren--2-1->%v\n", jsonErr)
return return
} }
fmt.Printf("Zeren--3-->%v\n", flowMap) // fmt.Printf("Zeren--3-->%v\n", flowMap)
var eiteFlowMap []FlowAllMap var eiteFlowMap []FlowAllMap
for _, v := range flowMap { for _, v := range flowMap {
var eiteFlowInfo FlowAllMap var eiteFlowInfo FlowAllMap
@ -2201,7 +2202,7 @@ func WriteFlowMainSet(orderId int64, userKey []int64) {
userClickAry = append(userClickAry, returnUser) userClickAry = append(userClickAry, returnUser)
} }
eiteFlowInfo.UserList = userClickAry eiteFlowInfo.UserList = userClickAry
fmt.Printf("Zeren--4-->%v\n", userClickAry) // fmt.Printf("Zeren--4-->%v\n", userClickAry)
} else { } else {
eiteFlowInfo.UserList = v.UserList eiteFlowInfo.UserList = v.UserList
} }
@ -2215,7 +2216,7 @@ func WriteFlowMainSet(orderId int64, userKey []int64) {
saveEiteData := MapOut() saveEiteData := MapOut()
saveEiteData["ep_time"] = time.Now().Unix() saveEiteData["ep_time"] = time.Now().Unix()
saveEiteData["ep_next_cont"] = flowAllMapOldStr saveEiteData["ep_next_cont"] = flowAllMapOldStr
fmt.Printf("Zeren--5-->%v\n", saveEiteData) // fmt.Printf("Zeren--5-->%v\n", saveEiteData)
EiteDutiesInfoes(evalProCont.Id, saveEiteData) EiteDutiesInfoes(evalProCont.Id, saveEiteData)
} }
@ -2312,8 +2313,16 @@ func IntegrationFlowAll(flowID int64, class int) (flowAllMap string, flowMap []F
twoFlowInfo.NodeName = GetSetpName(7) twoFlowInfo.NodeName = GetSetpName(7)
twoFlowInfo.State = 1 twoFlowInfo.State = 1
twoFlowInfo.Class = 1 twoFlowInfo.Class = 1
twoFlowInfo.UserList = GetFlowNodeMan(flowID, class, 5, 2) twoFlowInfo.UserList = GetFlowNodeMan(flowID, class, 3, 2)
flowMap = append(flowMap, twoFlowInfo) flowMap = append(flowMap, twoFlowInfo)
/*
GetFlowNodeMan(flowID int64, class, style, writeLog int)
@flowID 流程ID
@class 1定性2定量
@style 1测评人2测评人部门内勤3测评人部门负责人4被测评部门内勤5被测评部门负责人
@writeLog 1:写入默认审批记录
*/
} }
flowAllMapByte, eer := json.Marshal(flowMap) flowAllMapByte, eer := json.Marshal(flowMap)
if eer == nil { if eer == nil {
@ -2434,9 +2443,11 @@ func IntegrationFlowAllEs(flowID int64, class int, encFile []EnclosureFormat) (f
//获取节点操作人 //获取节点操作人
/* /*
GetFlowNodeMan(flowID int64, class, style, writeLog int)
@flowID 流程ID @flowID 流程ID
@class 1定性2定量 @class 1定性2定量
@style 1测评人2测评人部门内勤3测评人部门负责人4被测评部门内勤5被测评部门负责人 @style 1测评人2测评人部门内勤3测评人部门负责人4被测评部门内勤5被测评部门负责人
@writeLog 1:写入默认审批记录
*/ */
func GetFlowNodeMan(flowID int64, class, style, writeLog int) (manInfo []UserListFlowAll) { func GetFlowNodeMan(flowID int64, class, style, writeLog int) (manInfo []UserListFlowAll) {
var goDu FlowNodePeopleInfo var goDu FlowNodePeopleInfo
@ -3903,3 +3914,124 @@ func WriteReplyLog(orderId, acceptDepartment, launchDepartment, launchUser, stat
assessLogTwo.DutyList = content assessLogTwo.DutyList = content
global.GVA_DB_Performanceappraisal.Create(&assessLogTwo) global.GVA_DB_Performanceappraisal.Create(&assessLogTwo)
} }
//计算得分
/*
参数
@targetScore 指标分值
@resultval 结算值
@allPrizes 全奖值
@zeroPrizes 零奖值
@CappingVals 封顶值
返回说明
@scoreVal 计算得分
@allPrize 全奖值
@zeroPrize 零奖值
@CappingVal 封顶值
@achievement 达成率
*/
func CalculateScore(targetScore int64, resultval, allPrizes, zeroPrizes, CappingVals float64) (scoreVal, allPrize, zeroPrize, CappingVal, achievement float64) {
allPrize = allPrizes / 100
zeroPrize = zeroPrizes / 100
CappingVal = CappingVals / 100
resultval = resultval / 100
if allPrize == 0 && zeroPrize == 0 { //全奖值与零奖值都为0 那么达成率 100 和实际得分是 指标分
achievement = 100
scoreVal = float64(targetScore)
} else {
if allPrize > zeroPrize { //如果全奖值大于零奖值 执行一下操作
if resultval <= zeroPrize { //实际结算值小于零奖值 那么达成率和实际得分都是0
achievement = 0
scoreVal = 0
// } else if resultval > allPrize { //实际结算值大于全奖值 执行一下操作
} else { //实际结算值在全奖值 与 零奖值之间
chuShu := resultval - float64(zeroPrize)
beiChuShu := float64(allPrize) - float64(zeroPrize)
if beiChuShu != 0 {
achievement = Decimal(chuShu / beiChuShu)
if achievement <= 0 {
//如果在全奖值大于零件值的情况下出现达成率为0或负数,则达成率和实际得分都是0
achievement = 0
scoreVal = 0
} else {
if achievement*100 >= CappingVal {
//如果达成率大于等于封顶值
scoreVal = CappingVal * float64(targetScore) / 100
} else {
scoreVal = achievement * (float64(targetScore))
}
}
achievement = Decimal(achievement * 100)
} else {
//被除数为0时 那么达成率和实际得分都是0
achievement = 0
scoreVal = 0
}
}
} else { //如果全奖值小于零奖值 执行一下操作
if resultval >= zeroPrize { //实际结算值大于零奖值 那么达成率和实际得分都是0
achievement = 0
scoreVal = 0
// fmt.Printf("达成率--1-->%v-->%v-->%v-->%v-->%v-->%v-->%v\n", targetScore, resultval, scoreVal, allPrize, zeroPrize, CappingVal, achievement)
} else {
chuShu := resultval - float64(zeroPrize)
beiChuShu := float64(allPrize) - float64(zeroPrize)
if beiChuShu != 0 {
achievement = Decimal(chuShu / beiChuShu)
if achievement <= 0 {
//如果在全奖值大于零件值的情况下出现达成率为0或负数,则达成率和实际得分都是0
achievement = 0
scoreVal = 0
// fmt.Printf("达成率--2-->%v-->%v-->%v-->%v-->%v-->%v-->%v\n", targetScore, resultval, scoreVal, allPrize, zeroPrize, CappingVal, achievement)
} else {
if achievement*100 >= CappingVal {
//如果达成率大于等于封顶值
scoreVal = CappingVal * float64(targetScore) / 100
// fmt.Printf("达成率--3-->%v-->%v-->%v-->%v-->%v-->%v-->%v\n", targetScore, resultval, scoreVal, allPrize, zeroPrize, CappingVal, achievement)
} else {
scoreVal = achievement * (float64(targetScore))
// fmt.Printf("达成率--4-->%v-->%v-->%v-->%v-->%v-->%v-->%v\n", targetScore, resultval, scoreVal, allPrize, zeroPrize, CappingVal, achievement)
}
}
achievement = Decimal(achievement * 100)
// fmt.Printf("达成率--6-->%v-->%v-->%v-->%v-->%v-->%v-->%v\n", targetScore, resultval, scoreVal, allPrize, zeroPrize, CappingVal, achievement)
} else {
//被除数为0时 那么达成率和实际得分都是0
achievement = 0
scoreVal = 0
// fmt.Printf("达成率--5-->%v-->%v-->%v-->%v-->%v-->%v-->%v\n", targetScore, resultval, scoreVal, allPrize, zeroPrize, CappingVal, achievement)
}
}
}
}
scoreVal = Decimal(scoreVal)
allPrize = Decimal(allPrize)
zeroPrize = Decimal(zeroPrize)
CappingVal = Decimal(CappingVal)
achievement = Decimal(achievement)
return
}
//递归查找指定部门所有子类
func DiGuiOrgSun(superior int64, idary []int64) (groupId []int64) {
fmt.Printf("DiGui----->%v\n", superior)
// return
// groupId = 0
var govMap []OutGovCont
err := global.GVA_DB_HrDataBase.Model(&hrsystem.AdministrativeOrganization{}).Select("administrative_organization.id,aot.name as classname,aot.level").Joins("left join administrative_organization_type as aot on aot.id = administrative_organization.organization_type").Where("administrative_organization.`state` = 1 AND administrative_organization.superior = ?", superior).Find(&govMap).Error
if err != nil {
return
}
for _, v := range govMap {
if IsInTrue[int64](v.Id, groupId) == false {
groupId = append(groupId, v.Id)
DiGuiOrgSun(v.Id, groupId)
} else {
DiGuiOrgSun(v.Id, groupId)
}
}
return
}

Loading…
Cancel
Save