...
|
...
|
@@ -3,14 +3,18 @@ package service |
|
|
import (
|
|
|
"fmt"
|
|
|
"github.com/linmadan/egglib-go/core/application"
|
|
|
"github.com/linmadan/egglib-go/utils/tool_funs"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
|
|
|
service "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/role"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/adapter"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/command"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao"
|
|
|
"strings"
|
|
|
"time"
|
|
|
)
|
|
|
|
|
|
// Evaluation360List 获取360综评列表
|
|
|
func (srv *SummaryEvaluationService) Evaluation360List(param *command.QueryEvaluation360List) (*adapter.SummaryEvaluationAdapter, error) {
|
|
|
transactionContext, err := factory.ValidateStartTransaction(param)
|
|
|
if err != nil {
|
...
|
...
|
@@ -182,10 +186,24 @@ func (srv *SummaryEvaluationService) GetEvaluation360(param *command.QueryEvalua |
|
|
evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
|
|
|
sEvaluation, err := evaluationRepo.FindOne(map[string]interface{}{"id": param.SummaryEvaluationId})
|
|
|
//sEvaluation, err := evaluationRepo.FindOne(map[string]interface{}{"id": param.SummaryEvaluationId})
|
|
|
//if err != nil {
|
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
//}
|
|
|
_, evaluations, err := evaluationRepo.Find(map[string]interface{}{
|
|
|
"limit": 1,
|
|
|
"companyId": param.CompanyId,
|
|
|
"cycleId": param.CycleId,
|
|
|
"targetUserId": param.TargetUserId,
|
|
|
"types": domain.Evaluation360},
|
|
|
)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if len(evaluations) == 0 {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, "数据不存在")
|
|
|
}
|
|
|
sEvaluation := evaluations[0]
|
|
|
|
|
|
// 自评评估内容(自评模板、筛选项目评估人)
|
|
|
_, itemList, err := evaluationItemRepo.Find(map[string]interface{}{
|
...
|
...
|
@@ -324,6 +342,156 @@ func (srv *SummaryEvaluationService) EditEvaluation360(param *command.EditEvalua |
|
|
}, nil
|
|
|
}
|
|
|
|
|
|
// EvaluationHRBPList 获取人资综评列表
|
|
|
func (srv *SummaryEvaluationService) EvaluationHRBPList(param *command.QueryEvaluationHRList) (map[string]interface{}, error) {
|
|
|
transactionContext, err := factory.ValidateStartTransaction(param)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
defer func() {
|
|
|
_ = transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
|
|
|
evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
staffAssessDaoRepo := dao.NewStaffAssessDao(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
userRepo := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
positionRepo := factory.CreatePositionRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
var searchTargetName string
|
|
|
if len(param.SearchName) > 0 {
|
|
|
searchTargetName = "%" + param.SearchName + "%"
|
|
|
} else {
|
|
|
searchTargetName = ""
|
|
|
}
|
|
|
limit := param.PageSize
|
|
|
offset := limit * (param.PageNumber - 1)
|
|
|
if offset < 0 {
|
|
|
offset = 0
|
|
|
}
|
|
|
count, list, err := evaluationRepo.Find(map[string]interface{}{
|
|
|
"companyId": param.CompanyId,
|
|
|
"cycleId": param.CycleId,
|
|
|
"executorId": -1,
|
|
|
"types": domain.EvaluationHrbp,
|
|
|
"searchTargetName": searchTargetName,
|
|
|
"limit": limit,
|
|
|
"offset": offset,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
userIds := make([]int, 0)
|
|
|
positionIds := make([]int, 0)
|
|
|
projectIds := make([]int, 0)
|
|
|
projectCountMap := map[string]int{} // 自评逾期数量
|
|
|
userMap := map[int64]*domain.User{} // 用户
|
|
|
positionMap := map[int64]*domain.Position{} // 职位
|
|
|
|
|
|
for i := range list {
|
|
|
it := list[i]
|
|
|
userIds = append(userIds, it.TargetUser.UserId)
|
|
|
projectIds = append(projectIds, list[i].EvaluationProjectId)
|
|
|
}
|
|
|
_, users, err := userRepo.Find(map[string]interface{}{"ids": userIds, "companyId": param.CompanyId})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
for i := range users {
|
|
|
userMap[users[i].Id] = users[i]
|
|
|
for _, pid := range users[i].PositionId {
|
|
|
positionIds = append(positionIds, pid)
|
|
|
}
|
|
|
}
|
|
|
_, positions, err := positionRepo.Find(map[string]interface{}{"ids": positionIds, "companyId": param.CompanyId})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
for i := range positions {
|
|
|
positionMap[positions[i].Id] = positions[i]
|
|
|
}
|
|
|
|
|
|
if len(projectIds) > 0 {
|
|
|
targetCount, err := staffAssessDaoRepo.CountUncompletedSelfAssess(param.CompanyId, projectIds)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
for i := range targetCount {
|
|
|
key := fmt.Sprintf("%d-%d", targetCount[i].EvaluationProjectId, targetCount[i].TargetUserId)
|
|
|
projectCountMap[key] = targetCount[i].Cnt
|
|
|
}
|
|
|
}
|
|
|
|
|
|
now := time.Now().Local() // 当前时间
|
|
|
resultList := make([]*adapter.SummaryEvaluationHRBPAdapter, 0)
|
|
|
for i := range list {
|
|
|
v := list[i]
|
|
|
endTime := v.EndTime.Local()
|
|
|
// 状态
|
|
|
statusVal := ""
|
|
|
if v.Status == domain.EvaluationCompleted {
|
|
|
statusVal = "已完成"
|
|
|
} else {
|
|
|
if now.After(endTime) {
|
|
|
statusVal = "已逾期"
|
|
|
} else {
|
|
|
statusVal = "待完成"
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 部门拼接
|
|
|
var departmentBuild strings.Builder
|
|
|
departmentBuild.WriteString("")
|
|
|
for i2 := range v.TargetDepartment {
|
|
|
departmentBuild.WriteString(v.TargetDepartment[i2].DepartmentName)
|
|
|
if i2 != len(v.TargetDepartment)-1 {
|
|
|
departmentBuild.WriteString(",")
|
|
|
}
|
|
|
}
|
|
|
// 入职时间
|
|
|
entryTime := ""
|
|
|
// 职位拼接
|
|
|
var positionBuild strings.Builder
|
|
|
positionBuild.WriteString("")
|
|
|
if user, ok := userMap[int64(v.TargetUser.UserId)]; ok {
|
|
|
for i2 := range user.PositionId {
|
|
|
if position, ok := positionMap[int64(user.PositionId[i2])]; ok {
|
|
|
positionBuild.WriteString(position.Name)
|
|
|
if i2 != len(user.PositionId)-1 {
|
|
|
departmentBuild.WriteString(",")
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
entryTime = user.EntryTime
|
|
|
}
|
|
|
|
|
|
// 自评逾期数量
|
|
|
overdueCount := 0
|
|
|
key := fmt.Sprintf("%d-%d", v.EvaluationProjectId, v.TargetUser.UserId)
|
|
|
if cnt, ok := projectCountMap[key]; ok {
|
|
|
overdueCount = cnt
|
|
|
}
|
|
|
|
|
|
result := &adapter.SummaryEvaluationHRBPAdapter{
|
|
|
Id: v.Id,
|
|
|
TargetUserId: v.TargetUser.UserId,
|
|
|
TargetUserName: v.TargetUser.UserName,
|
|
|
Department: departmentBuild.String(),
|
|
|
Position: positionBuild.String(),
|
|
|
DutyTime: entryTime,
|
|
|
Status: statusVal,
|
|
|
EndTime: endTime.Format("2006-01-02 15:04"),
|
|
|
OverdueCount: overdueCount,
|
|
|
}
|
|
|
resultList = append(resultList, result)
|
|
|
}
|
|
|
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
return tool_funs.SimpleWrapGridMap(int64(count), resultList), nil
|
|
|
}
|
|
|
|
|
|
// GetEvaluationHRBP 获取人资综评详情
|
|
|
func (srv *SummaryEvaluationService) GetEvaluationHRBP(param *command.QueryEvaluationHRBP) (*adapter.EvaluationInfoAdapter, error) {
|
|
|
transactionContext, err := factory.ValidateStartTransaction(param)
|
...
|
...
|
@@ -338,10 +506,21 @@ func (srv *SummaryEvaluationService) GetEvaluationHRBP(param *command.QueryEvalu |
|
|
evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
|
|
|
sEvaluation, err := evaluationRepo.FindOne(map[string]interface{}{"id": param.SummaryEvaluationId})
|
|
|
_, evaluations, err := evaluationRepo.Find(map[string]interface{}{
|
|
|
"limit": 1,
|
|
|
"companyId": param.CompanyId,
|
|
|
"cycleId": param.CycleId,
|
|
|
"targetUserId": param.TargetUserId,
|
|
|
"types": domain.EvaluationHrbp},
|
|
|
)
|
|
|
// sEvaluation, err := evaluationRepo.FindOne(map[string]interface{}{"id": param.SummaryEvaluationId})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if len(evaluations) == 0 {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, "数据不存在")
|
|
|
}
|
|
|
sEvaluation := evaluations[0]
|
|
|
|
|
|
// 自评评估内容(自评模板、筛选项目评估人)
|
|
|
_, itemList, err := evaluationItemRepo.Find(map[string]interface{}{
|
...
|
...
|
|