You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
178 lines
6.3 KiB
178 lines
6.3 KiB
|
4 years ago
|
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)
|
||
|
|
}
|