作者 tangxvhui

调整周期评估的编辑规则

... ... @@ -26,6 +26,7 @@ type EvaluationBaseAdapter struct {
Types int `json:"types"` //评估类型
DutyTime string `json:"dutyTime"` //入职时间
Status string `json:"status"` //完成状态
CompletedAt int64 `json:"completedAt"` //
CheckResult string `json:"checkResult"` //确认绩效结果
TotalScore string `json:"totalScore"` //评估总分
Version string `json:"version"` //评估填写方式
... ...
... ... @@ -150,15 +150,22 @@ func (srv *SummaryEvaluationService) EditEvaluation360(param *command.EditEvalua
if summaryEvaluation.CompanyId != param.CompanyId {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
}
// 按照 被评估人加锁
lock := xredis.NewLockSummaryEvaluation(summaryEvaluation.TargetUser.UserId)
err = lock.Lock()
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未能完全提交评估内容")
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未能完全提交评估内容"+err.Error())
}
defer func() {
lock.UnLock()
}()
// 检查是否逾期完成
if summaryEvaluation.EndTime.Unix() < summaryEvaluation.CompletedAt {
return nil, application.ThrowError(application.BUSINESS_ERROR, "已经逾期提交一次,不能再次编辑")
}
//检查被评估人是否已经确认考核结果
_, evaluationList, err := evaluationRepo.Find(map[string]interface{}{
"targetUserId": summaryEvaluation.TargetUser.UserId,
"typesList": []int{int(domain.EvaluationFinish)},
... ... @@ -172,9 +179,10 @@ func (srv *SummaryEvaluationService) EditEvaluation360(param *command.EditEvalua
if len(evaluationList) > 0 && evaluationList[0].CheckResult == domain.EvaluationCheckCompleted {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "用户已经确认该周期的考核结果,不能再编辑!")
}
if ok := summaryEvaluation.EndTime.Before(time.Now()); ok {
return nil, application.ThrowError(application.BUSINESS_ERROR, "评估时间已截止")
}
// 取消时间限制
// if ok := summaryEvaluation.EndTime.Before(time.Now()); ok {
// return nil, application.ThrowError(application.BUSINESS_ERROR, "评估时间已截止")
// }
// 自评评估内容(自评模板、筛选项目评估人)
_, itemList, err := itemUsedRepo.Find(map[string]interface{}{
... ... @@ -246,6 +254,7 @@ func (srv *SummaryEvaluationService) EditEvaluation360(param *command.EditEvalua
if !param.IsTemporary {
//变更评估状态为已填写
summaryEvaluation.Status = domain.EvaluationCompleted
summaryEvaluation.CompletedAt = time.Now().Unix()
//删除旧的填写值,使用新的填写内容
err = itemValueRepo.RemoveBySummaryEvaluationId(summaryEvaluation.Id)
if err != nil {
... ...
... ... @@ -274,11 +274,12 @@ func (srv *SummaryEvaluationService) EditEvaluationHRBP(param *command.EditEvalu
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if summaryEvaluation.Types != domain.EvaluationHrbp {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
return nil, application.ThrowError(application.BUSINESS_ERROR, "没有操作权限")
}
if summaryEvaluation.CompanyId != param.CompanyId {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
return nil, application.ThrowError(application.BUSINESS_ERROR, "没有操作权限")
}
// 按照 被评估人加锁
lock := xredis.NewLockSummaryEvaluation(summaryEvaluation.TargetUser.UserId)
err = lock.Lock()
... ... @@ -288,6 +289,10 @@ func (srv *SummaryEvaluationService) EditEvaluationHRBP(param *command.EditEvalu
defer func() {
lock.UnLock()
}()
// 检查是否逾期完成
if summaryEvaluation.EndTime.Unix() < summaryEvaluation.CompletedAt {
return nil, application.ThrowError(application.BUSINESS_ERROR, "已经逾期提交一次,不能再次编辑")
}
_, evaluationList, err := evaluationRepo.Find(map[string]interface{}{
"targetUserId": summaryEvaluation.TargetUser.UserId,
"typesList": []int{int(domain.EvaluationFinish)},
... ... @@ -301,9 +306,9 @@ func (srv *SummaryEvaluationService) EditEvaluationHRBP(param *command.EditEvalu
if len(evaluationList) > 0 && evaluationList[0].CheckResult == domain.EvaluationCheckCompleted {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "用户已经确认该周期的考核结果,不能再编辑!")
}
if ok := summaryEvaluation.EndTime.Before(time.Now()); ok {
return nil, application.ThrowError(application.BUSINESS_ERROR, "评估时间已截止")
}
// if ok := summaryEvaluation.EndTime.Before(time.Now()); ok {
// return nil, application.ThrowError(application.BUSINESS_ERROR, "评估时间已截止")
// }
// 自评评估内容(自评模板、筛选项目评估人)
_, itemList, err := itemUsedRepo.Find(map[string]interface{}{
"evaluationProjectId": summaryEvaluation.EvaluationProjectId,
... ... @@ -372,6 +377,7 @@ func (srv *SummaryEvaluationService) EditEvaluationHRBP(param *command.EditEvalu
if !param.IsTemporary {
//变更评估状态为已填写
summaryEvaluation.Status = domain.EvaluationCompleted
summaryEvaluation.CompletedAt = time.Now().Unix()
//删除旧的填写值,使用新的填写内容
err = itemValueRepo.RemoveBySummaryEvaluationId(summaryEvaluation.Id)
if err != nil {
... ...
... ... @@ -234,14 +234,18 @@ func (srv *SummaryEvaluationService) EditEvaluationSelfV2(param *command.EditEva
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取评估"+err.Error())
}
if evaluationData.Types != domain.EvaluationSelf {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
return nil, application.ThrowError(application.BUSINESS_ERROR, "没有操作权限")
}
if evaluationData.Executor.UserId != param.ExecutorId {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
return nil, application.ThrowError(application.BUSINESS_ERROR, "没有操作权限")
}
if evaluationData.CompanyId != param.CompanyId {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
return nil, application.ThrowError(application.BUSINESS_ERROR, "没有操作权限")
}
// 检查是否逾期完成
if evaluationData.EndTime.Unix() < evaluationData.CompletedAt {
return nil, application.ThrowError(application.BUSINESS_ERROR, "已经逾期提交一次,不能再次编辑")
}
//按照 被评估人加锁
lock := xredis.NewLockSummaryEvaluation(evaluationData.TargetUser.UserId)
... ... @@ -252,6 +256,20 @@ func (srv *SummaryEvaluationService) EditEvaluationSelfV2(param *command.EditEva
defer func() {
lock.UnLock()
}()
_, evaluationList, err := evaluationRepo.Find(map[string]interface{}{
"targetUserId": evaluationData.TargetUser.UserId,
"typesList": []int{int(domain.EvaluationFinish)},
"cycleId": evaluationData.CycleId,
"limit": 1,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
// 如果目标员工已经确认考核结果,就不能在进行评估编辑
if len(evaluationList) > 0 && evaluationList[0].CheckResult == domain.EvaluationCheckCompleted {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "用户已经确认该周期的考核结果,不能再编辑!")
}
_, itemList, err := itemUsedRepo.Find(map[string]interface{}{
"evaluationProjectId": evaluationData.EvaluationProjectId,
"nodeType": domain.LinkNodeSelfAssessment,
... ... @@ -320,6 +338,7 @@ func (srv *SummaryEvaluationService) EditEvaluationSelfV2(param *command.EditEva
if !param.IsTemporary {
evaluationData.Status = domain.EvaluationCompleted
evaluationData.CompletedAt = time.Now().Unix()
//删除旧的填写值,使用新的填写内容
err = itemValueRepo.RemoveBySummaryEvaluationId(evaluationData.Id)
if err != nil {
... ...
... ... @@ -325,9 +325,13 @@ func (srv *SummaryEvaluationService) EditEvaluationSuper(param *command.EditEval
if evaluationData.CompanyId != param.CompanyId {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
}
ok := evaluationData.EndTime.Before(time.Now())
if ok {
return nil, application.ThrowError(application.BUSINESS_ERROR, "评估时间已截止")
// ok := evaluationData.EndTime.Before(time.Now())
// if ok {
// return nil, application.ThrowError(application.BUSINESS_ERROR, "评估时间已截止")
// }
// 检查是否逾期完成
if evaluationData.EndTime.Unix() < evaluationData.CompletedAt {
return nil, application.ThrowError(application.BUSINESS_ERROR, "已经逾期提交一次,不能再次编辑")
}
//按照被评估人id ,加锁
lock := xredis.NewLockSummaryEvaluation(evaluationData.TargetUser.UserId)
... ... @@ -441,6 +445,7 @@ func (srv *SummaryEvaluationService) EditEvaluationSuper(param *command.EditEval
if !param.IsTemporary {
//变更评估状态为已填写
evaluationData.Status = domain.EvaluationCompleted
evaluationData.CompletedAt = time.Now().Unix()
//删除旧的填写值,使用新的填写内容
err = itemValueRepo.RemoveBySummaryEvaluationId(evaluationData.Id)
if err != nil {
... ...
... ... @@ -463,8 +463,19 @@ func (srv *SummaryEvaluationService) getSummaryEvaluation(transactionContext app
Status: string(evaluationData.Status),
CheckResult: string(evaluationData.CheckResult),
TotalScore: evaluationData.TotalScore,
CompletedAt: evaluationData.CompletedAt,
Version: string(evaluationData.Version),
}
if evaluationData.CompletedAt == 0 {
result.Status = string(domain.EvaluationUncompleted) //未完成
} else {
if evaluationData.EndTime.Unix() < evaluationData.CompletedAt {
result.Status = string(domain.EvaluationCompleted) + "_timeout" //超时完成
} else {
result.Status = string(domain.EvaluationCompleted) // 正常完成
}
}
//获取用户信息
companyRepo := factory.CreateCompanyRepository(map[string]interface{}{"transactionContext": transactionContext})
userRepo := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext})
... ... @@ -869,12 +880,13 @@ func (srv *SummaryEvaluationService) ListExecutorEvaluationSuper(param *command.
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
evaluationListAdapter := []*adapter.EvaluationSuperListAdapter{}
nowTime := time.Now()
for _, v := range evaluationList {
item := adapter.EvaluationSuperListAdapter{
SummaryEvaluationId: v.Id,
TargetUserName: v.TargetUser.UserName,
TargetUserId: v.TargetUser.UserId,
EvaluationStatus: string(v.Status),
EvaluationStatus: "",
EndTime: v.EndTime.Local().Format("2006-01-02 15:04:05"),
TotalScoreSelf: "",
Department: "",
... ... @@ -882,6 +894,20 @@ func (srv *SummaryEvaluationService) ListExecutorEvaluationSuper(param *command.
EntryTime: "",
TotalScoreSuper: v.TotalScore,
}
if v.Status == domain.EvaluationCompleted {
if v.CompletedAt > v.EndTime.Unix() {
item.EvaluationStatus = "逾期完成"
} else {
item.EvaluationStatus = "已完成"
}
} else {
if nowTime.After(v.EndTime) {
item.EvaluationStatus = "已逾期"
} else {
item.EvaluationStatus = "待完成"
}
}
for _, dep := range v.TargetDepartment {
item.Department += dep.DepartmentName + " "
}
... ...
... ... @@ -129,7 +129,11 @@ func (srv *SummaryEvaluationService) Evaluation360List(param *command.QueryEvalu
endTime := v.EndTime.Local()
statusVal := ""
if v.Status == domain.EvaluationCompleted {
statusVal = "已完成"
if v.CompletedAt > v.EndTime.Unix() {
statusVal = "逾期完成"
} else {
statusVal = "已完成"
}
} else {
if now.After(endTime) {
statusVal = "已逾期"
... ... @@ -423,7 +427,11 @@ func (srv *SummaryEvaluationService) EvaluationHRBPList(param *command.QueryEval
// 状态
statusVal := ""
if v.Status == domain.EvaluationCompleted {
statusVal = "已完成"
if v.CompletedAt > v.EndTime.Unix() {
statusVal = "逾期完成"
} else {
statusVal = "已完成"
}
} else {
if now.After(endTime) {
statusVal = "已逾期"
... ...
... ... @@ -63,6 +63,7 @@ const (
// EvaluationEditTotalScore EvaluationStatus = "completed_by_edit_score" //通过超级管理员直接修改分数完成的
EvaluationUncompleted EvaluationStatus = "uncompleted" //未提交填写的内容
EvaluationCompleted EvaluationStatus = "completed" //已提交填写的内容
)
// 被执行的人确认评估结果
... ...
... ... @@ -19,13 +19,13 @@ type SummaryEvaluation struct {
TargetUser domain.StaffDesc //被评估的目标用户,被执行的
TargetDepartment []domain.StaffDepartment //被评估的目标用户所在的部门
Executor domain.StaffDesc //填写评估的用户,执行人
Types int //评估类型
Types int `pg:",use_zero"` //评估类型
Status string //评估的填写状态
CheckResult string //被执行的人确认评估结果
HrCheckResult string //存在人资稽查填写完成评估
BeginTime time.Time //开始时间
EndTime time.Time //截止时间
CompletedAt int64 //完成时间
CompletedAt int64 `pg:",use_zero"` //完成时间
TotalScore string //最终上级评估得分.
Version string //填写评估值的规则版本 v1,v2
TotalRating []domain.RatingCodeNumber //汇总评级
... ...
ALTER TABLE public.summary_evaluation
ADD completedat int8 NOT NULL DEFAULT 0;
ADD completed_at int8 NOT NULL DEFAULT 0;
UPDATE
summary_evaluation
SET
completed_at = extract(epoch FROM summary_evaluation.end_time) - 10
WHERE
status = 'completed'
... ...