23 changed files with 1288 additions and 424 deletions
@ -1,6 +1,94 @@ |
|||||
package evaluation |
package evaluation |
||||
|
|
||||
|
import ( |
||||
|
"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" |
||||
|
) |
||||
|
|
||||
//数据评估
|
//数据评估
|
||||
type ApiGroup struct { |
type ApiGroup struct { |
||||
EvaluationApi EvaluationInterface |
EvaluationApi EvaluationInterface |
||||
} |
} |
||||
|
|
||||
|
//获取定量考核目标
|
||||
|
/* |
||||
|
@targetScore 指标分值 |
||||
|
@resultval 结算值 |
||||
|
@group 集团 |
||||
|
@depart 部门 |
||||
|
@dimen 维度 |
||||
|
@target 指标 |
||||
|
@deaTarget 细则 |
||||
|
@year 年份 |
||||
|
@timecopy 辅助计数 |
||||
|
|
||||
|
返回说明 |
||||
|
@scoreVal 计算得分 |
||||
|
@allPrize 全奖值 |
||||
|
@zeroPrize 零奖值 |
||||
|
@CappingVal 封顶值 |
||||
|
@achievement 达成率 |
||||
|
*/ |
||||
|
func GetQuantitativeConfig(targetScore int64, resultval float64, group, depart, dimen, target, deaTarget string, year int64, timecopy int64) (scoreVal, allPrize, zeroPrize, CappingVal, achievement float64) { |
||||
|
scoreVal = 0 |
||||
|
allPrize = 0 |
||||
|
zeroPrize = 0 |
||||
|
CappingVal = 0 |
||||
|
achievement = 0 |
||||
|
var qualConfig assessmentmodel.QuantitativeConfig |
||||
|
gormDb := global.GVA_DB_Performanceappraisal.Where("`group` = ? AND `departmentid` = ? AND `dimension` = ? AND `target` = ? AND `year` = ?", group, depart, dimen, target, year) |
||||
|
if deaTarget != "0" { |
||||
|
gormDb = gormDb.Where("targetconfig = ?", deaTarget) |
||||
|
} |
||||
|
// if timecopy != 0 {
|
||||
|
// gormDb = gormDb.Where("timecopy = ?", timecopy)
|
||||
|
// }
|
||||
|
gormDb = gormDb.Where("timecopy = ?", timecopy) |
||||
|
err := gormDb.First(&qualConfig).Error |
||||
|
|
||||
|
// fmt.Printf("达成率--0-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v\n", group, depart, dimen, target, year, allPrize, zeroPrize, CappingVal, achievement, err)
|
||||
|
if err != nil { |
||||
|
return |
||||
|
} |
||||
|
allPrize = qualConfig.Allprize / 100 |
||||
|
zeroPrize = qualConfig.Zeroprize / 100 |
||||
|
CappingVal = qualConfig.CappingVal / 100 |
||||
|
|
||||
|
chuShu := resultval - float64(qualConfig.Zeroprize) |
||||
|
beiChuShu := float64(qualConfig.Allprize) - float64(qualConfig.Zeroprize) |
||||
|
if beiChuShu > 0 { |
||||
|
achievement = commonus.Decimal(chuShu / beiChuShu) |
||||
|
scoreVal = achievement * (resultval / 100) |
||||
|
achievement = commonus.Decimal(achievement * 100) |
||||
|
|
||||
|
if achievement >= CappingVal { |
||||
|
scoreVal = CappingVal * float64(targetScore) / 100 |
||||
|
} |
||||
|
} else { |
||||
|
scoreVal = float64(targetScore) |
||||
|
} |
||||
|
|
||||
|
// if qualConfig.CappingVal != 0 && resultval >= qualConfig.CappingVal {
|
||||
|
// scoreVal = float64(targetScore)
|
||||
|
// achievement = 100
|
||||
|
// // fmt.Printf("达成率--1-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v-->%v\n", group, depart, dimen, target, year, allPrize, zeroPrize, CappingVal, achievement)
|
||||
|
// } else {
|
||||
|
// chuShu := resultval - float64(qualConfig.Zeroprize)
|
||||
|
// beiChuShu := float64(qualConfig.Allprize) - float64(qualConfig.Zeroprize)
|
||||
|
// if beiChuShu > 0 {
|
||||
|
// achievement = commonus.Decimal(chuShu / beiChuShu)
|
||||
|
// scoreVal = achievement * (resultval / 100)
|
||||
|
|
||||
|
// 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 |
||||
|
} |
||||
|
|||||
@ -0,0 +1,177 @@ |
|||||
|
package evaluation |
||||
|
|
||||
|
import ( |
||||
|
"encoding/json" |
||||
|
"fmt" |
||||
|
"strconv" |
||||
|
"time" |
||||
|
|
||||
|
"github.com/flipped-aurora/gin-vue-admin/server/commonus" |
||||
|
"github.com/flipped-aurora/gin-vue-admin/server/global" |
||||
|
"github.com/flipped-aurora/gin-vue-admin/server/model/assessmentmodel" |
||||
|
"github.com/flipped-aurora/gin-vue-admin/server/model/common/response" |
||||
|
"github.com/gin-gonic/gin" |
||||
|
) |
||||
|
|
||||
|
//加减分
|
||||
|
func (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 |
||||
|
|
||||
|
if requestData.Type != 1 { |
||||
|
//减分
|
||||
|
if myIsTrue != 1 { |
||||
|
//申请人也是部门负责人
|
||||
|
commonus.StepAddDataEs(keyNumber, 0, 3, 1, 1, 1, 1, userCont.Key, requestData.Enclosure) |
||||
|
} else { |
||||
|
//申请人不是是部门负责人 给本部门负责人发送审批
|
||||
|
commonus.StepAddDataEs(keyNumber, 16182159043990656, 2, 1, 1, 1, 1, userCont.Key, requestData.Enclosure) |
||||
|
} |
||||
|
} else { |
||||
|
//加分
|
||||
|
commonus.StepAddDataEs(keyNumber, 16182159043990656, 2, 7, 1, 1, 1, userCont.Key, requestData.Enclosure) |
||||
|
} |
||||
|
|
||||
|
response.Result(0, requestData, "数据写入成功", c) |
||||
|
} |
||||
Loading…
Reference in new issue