...
|
...
|
@@ -14,6 +14,7 @@ import ( |
|
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/command"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/query"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log"
|
|
|
)
|
|
|
|
...
|
...
|
@@ -1124,3 +1125,167 @@ func (srv StaffAssessServeice) recoverAssessCache(context application.Transactio |
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 获取目标员工自评周期列表
|
|
|
func (srv StaffAssessServeice) ListTargetUserSelfCycle(param *query.ListTargetUserCycleQuery) (map[string]interface{}, error) {
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
if err := transactionContext.StartTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
defer func() {
|
|
|
_ = transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
staffAssessDao := dao.NewStaffAssessDao(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
var limit int = 360
|
|
|
var offset int = 0
|
|
|
if param.PageSize > 0 {
|
|
|
limit = param.PageSize
|
|
|
}
|
|
|
offset = (param.PageNumber - 1) * param.PageSize
|
|
|
|
|
|
cycleList, err := staffAssessDao.SearchTargetUserCycleProject(param.CompanyId, param.TargetUserId, limit, offset)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
return tool_funs.SimpleWrapGridMap(int64(len(cycleList)), cycleList), nil
|
|
|
}
|
|
|
|
|
|
// 按照周期获取员工的每日自评小结
|
|
|
func (srv StaffAssessServeice) GetStaffAsessSelfCountLevel(param *query.StaffAsessSelfCountLevel) (*adapter.AssessCountLevelResp, error) {
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
if err := transactionContext.StartTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
defer func() {
|
|
|
_ = transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
// 统计周期内,评估项等级的数量
|
|
|
assessDao := dao.NewStaffAssessDao(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
|
|
|
levelCodeCountList, err := assessDao.CountAssessContentLevelCode(param.ProjectId, param.TargetUserId, domain.AssessSelf, param.CycleId)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
_, itemList, err := evaluationItemRepo.Find(map[string]interface{}{
|
|
|
"evaluationProjectId": param.ProjectId,
|
|
|
"nodeType": int(domain.LinkNodeSelfAssessment),
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
//获取员工的评估
|
|
|
_, assessList, err := assessReps.Find(map[string]interface{}{
|
|
|
"companyId": param.CompanyId,
|
|
|
"limit": 1,
|
|
|
"cycleId": param.CycleId,
|
|
|
"targetUserId": param.TargetUserId,
|
|
|
"evaluationProjectId": param.ProjectId,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
if len(assessList) == 0 {
|
|
|
return &adapter.AssessCountLevelResp{
|
|
|
EvaluationProjectId: param.ProjectId,
|
|
|
CycleId: int64(param.CycleId),
|
|
|
TargetUserId: param.TargetUserId,
|
|
|
}, nil
|
|
|
}
|
|
|
assessData := assessList[0]
|
|
|
targetUserDesc, err := srv.getStaffDescrip(transactionContext, int64(param.TargetUserId))
|
|
|
if err != nil {
|
|
|
log.Logger.Error("获取员工描述" + err.Error())
|
|
|
}
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
result := adapter.AssessCountLevelResp{
|
|
|
CycleId: assessData.CycleId,
|
|
|
CycleName: assessData.CycleName,
|
|
|
EvaluationProjectId: assessData.EvaluationProjectId,
|
|
|
EvaluationProjectName: assessData.EvaluationProjectName,
|
|
|
TargetUserId: assessData.TargetUser.UserId,
|
|
|
TargetUserName: assessData.TargetUser.UserName,
|
|
|
CompanyLogo: "",
|
|
|
CompanyName: "",
|
|
|
SupperUser: "",
|
|
|
DutyTime: "",
|
|
|
EvaluationItems: []adapter.AssessCountLeveltItem{},
|
|
|
}
|
|
|
if targetUserDesc != nil {
|
|
|
result.CompanyName = targetUserDesc.CompanyName
|
|
|
result.SupperUser = targetUserDesc.SupperUserName
|
|
|
result.CompanyLogo = targetUserDesc.CompanyLogo
|
|
|
result.DutyTime = targetUserDesc.DutyTime
|
|
|
}
|
|
|
|
|
|
levelCodeMap := map[int][]adapter.LevalCodeCount{}
|
|
|
for _, v := range itemList {
|
|
|
codes := v.Rule.GetLevelCodes()
|
|
|
levelCode := []adapter.LevalCodeCount{}
|
|
|
for _, v2 := range codes {
|
|
|
levelCode = append(levelCode, adapter.LevalCodeCount{
|
|
|
Code: v2,
|
|
|
Number: 0,
|
|
|
})
|
|
|
}
|
|
|
levelCodeMap[v.Id] = levelCode
|
|
|
}
|
|
|
levelCodeCountMap := map[string]int{}
|
|
|
for _, v := range levelCodeCountList {
|
|
|
key := fmt.Sprintf("%s-%s-%s", v.Category, v.Name, v.LevelValue)
|
|
|
levelCodeCountMap[key] = v.Cnt
|
|
|
}
|
|
|
for _, v := range itemList {
|
|
|
itemCount := adapter.AssessCountLeveltItem{
|
|
|
EvaluationItemId: v.Id,
|
|
|
SortBy: v.SortBy,
|
|
|
Category: v.Category,
|
|
|
Name: v.Name,
|
|
|
PromptTitle: v.PromptTitle,
|
|
|
PromptText: v.PromptText,
|
|
|
EntryItems: v.EntryItems,
|
|
|
RuleType: v.RuleType,
|
|
|
Rule: v.Rule,
|
|
|
Weight: v.Weight,
|
|
|
EvaluatorId: v.EvaluatorId,
|
|
|
LevelCount: []adapter.LevalCodeCount{},
|
|
|
}
|
|
|
levelCodes := levelCodeMap[v.Id]
|
|
|
for i2 := range levelCodes {
|
|
|
key := fmt.Sprintf("%s-%s-%s",
|
|
|
itemCount.Category,
|
|
|
itemCount.Name,
|
|
|
levelCodes[i2].Code,
|
|
|
)
|
|
|
if mVal, ok := levelCodeCountMap[key]; ok {
|
|
|
levelCodes[i2].Number = mVal
|
|
|
}
|
|
|
}
|
|
|
itemCount.LevelCount = levelCodes
|
|
|
result.EvaluationItems = append(result.EvaluationItems, itemCount)
|
|
|
}
|
|
|
|
|
|
return &result, nil
|
|
|
} |
...
|
...
|
|