|
|
package service
|
|
|
|
|
|
import (
|
|
|
"fmt"
|
|
|
"time"
|
|
|
|
|
|
"github.com/linmadan/egglib-go/core/application"
|
...
|
...
|
@@ -266,19 +267,18 @@ func (srv *SummaryEvaluationService) buildSummaryItemValue(itemList []*domain.Ev |
|
|
Remark: "",
|
|
|
}
|
|
|
value, ok := valueMap[v.Id]
|
|
|
if !ok {
|
|
|
continue
|
|
|
}
|
|
|
if ok {
|
|
|
item.Score = value.Score
|
|
|
item.Value = value.Value
|
|
|
item.Remark = value.Remark
|
|
|
}
|
|
|
itemValues = append(itemValues, item)
|
|
|
}
|
|
|
return itemValues
|
|
|
}
|
|
|
|
|
|
// 获取综合自评详情
|
|
|
func (srv *SummaryEvaluationService) GetEvaluationSelf(param *command.QueryEvaluationInfo) (*adapter.EvaluationInfoAdapter, error) {
|
|
|
func (srv *SummaryEvaluationService) GetEvaluationSelf(param *command.QueryEvaluation) (*adapter.EvaluationInfoAdapter, error) {
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
...
|
...
|
@@ -301,7 +301,7 @@ func (srv *SummaryEvaluationService) GetEvaluationSelf(param *command.QueryEvalu |
|
|
_, evaluationList, err := evaluationRepo.Find(map[string]interface{}{
|
|
|
"limit": 1,
|
|
|
"cycleId": param.CompanyId,
|
|
|
"executorId": param.ExecutorId,
|
|
|
"executorId": param.UserId,
|
|
|
"types": domain.EvaluationSelf,
|
|
|
})
|
|
|
if err != nil {
|
...
|
...
|
@@ -326,12 +326,17 @@ func (srv *SummaryEvaluationService) GetEvaluationSelf(param *command.QueryEvalu |
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
result := srv.getSummaryEvaluation(transactionContext, evaluationData)
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
itemValuesAdapter := srv.buildSummaryItemValue(itemList, itemValues)
|
|
|
result.EvaluationItems = itemValuesAdapter
|
|
|
return result, nil
|
|
|
}
|
|
|
|
|
|
func (srv *SummaryEvaluationService) getSummaryEvaluation(transactionContext application.TransactionContext, evaluationData *domain.SummaryEvaluation) *adapter.EvaluationInfoAdapter {
|
|
|
result := adapter.EvaluationInfoAdapter{
|
|
|
SummaryEvaluationId: evaluationData.Id,
|
|
|
CycleId: int(evaluationData.CycleId),
|
...
|
...
|
@@ -343,10 +348,50 @@ func (srv *SummaryEvaluationService) GetEvaluationSelf(param *command.QueryEvalu |
|
|
EndTime: evaluationData.EndTime.Format("2006-01-02 15:04:05"),
|
|
|
TargetUserId: evaluationData.TargetUser.UserId,
|
|
|
TargetUserName: evaluationData.TargetUser.UserName,
|
|
|
CompanyLogo: "",
|
|
|
CompanyName: "",
|
|
|
SupperUser: "",
|
|
|
DutyTime: "",
|
|
|
Status: string(evaluationData.Status),
|
|
|
EvaluationItems: itemValuesAdapter,
|
|
|
EvaluationItems: []adapter.EvaluationItemAdapter{},
|
|
|
}
|
|
|
//获取用户信息
|
|
|
companyRepo := factory.CreateCompanyRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
userRepo := factory.CreateUserRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
|
|
|
companyData, err := companyRepo.FindOne(map[string]interface{}{
|
|
|
"id": evaluationData.CompanyId,
|
|
|
})
|
|
|
|
|
|
if err != nil {
|
|
|
return &result
|
|
|
}
|
|
|
|
|
|
userData, err := userRepo.FindOne(map[string]interface{}{
|
|
|
"id": evaluationData.TargetUser.UserId,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return &result
|
|
|
}
|
|
|
result.DutyTime = userData.EntryTime
|
|
|
result.CompanyLogo = companyData.Logo
|
|
|
result.CompanyName = companyData.Name
|
|
|
|
|
|
if userData.ParentId <= 0 {
|
|
|
return &result
|
|
|
}
|
|
|
pUserData, err := userRepo.FindOne(map[string]interface{}{
|
|
|
"id": userData.ParentId,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return &result
|
|
|
}
|
|
|
return &result, nil
|
|
|
result.SupperUser = pUserData.Name
|
|
|
return &result
|
|
|
}
|
|
|
|
|
|
// 编辑综合自评详情
|
...
|
...
|
@@ -377,6 +422,10 @@ func (srv *SummaryEvaluationService) EditEvaluationSelf(param *command.EditEvalu |
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if evaluationData.Types != domain.EvaluationSelf {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
|
|
|
}
|
|
|
|
|
|
if evaluationData.Executor.UserId != param.ExecutorId {
|
|
|
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
|
...
|
...
|
@@ -388,6 +437,7 @@ func (srv *SummaryEvaluationService) EditEvaluationSelf(param *command.EditEvalu |
|
|
|
|
|
_, itemList, err := itemUsedRepo.Find(map[string]interface{}{
|
|
|
"evaluationProjectId": evaluationData.EvaluationProjectId,
|
|
|
"nodeType": domain.LinkNodeSelfAssessment,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
...
|
...
|
@@ -443,6 +493,7 @@ func (srv *SummaryEvaluationService) EditEvaluationSelf(param *command.EditEvalu |
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
evaluationData.UpdatedAt = nowTime
|
|
|
evaluationData.Status = domain.EvaluationCompleted
|
|
|
//保存填写值
|
|
|
err = evaluationRepo.Save(evaluationData)
|
|
|
if err != nil {
|
...
|
...
|
@@ -506,15 +557,23 @@ func (srv *SummaryEvaluationService) GetTargetUserCycleList(param *command.Query |
|
|
}
|
|
|
|
|
|
// 自评小结详情
|
|
|
func (srv *SummaryEvaluationService) CountEvaluationSelfLevel(param *command.QueryEvaluationInfo) (*adapter.EvaluationInfoAdapter, error) {
|
|
|
|
|
|
func (srv *SummaryEvaluationService) CountEvaluationSelfLevel(param *command.QueryEvaluation) (*adapter.EvaluationInfoAdapter, error) {
|
|
|
evaluationInfo, err := srv.GetEvaluationSelf(param)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
|
|
|
_ = evaluationInfo
|
|
|
//TODO 组装等级数量统计
|
|
|
levelCodeMap := map[int][]adapter.LevalCodeCount{}
|
|
|
for _, v := range evaluationInfo.EvaluationItems {
|
|
|
codes := v.Rule.GetLevelCodes()
|
|
|
levelCode := []adapter.LevalCodeCount{}
|
|
|
for _, v2 := range codes {
|
|
|
levelCode = append(levelCode, adapter.LevalCodeCount{
|
|
|
Code: v2,
|
|
|
Number: 0,
|
|
|
})
|
|
|
}
|
|
|
levelCodeMap[v.EvaluationItemId] = levelCode
|
|
|
}
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
...
|
...
|
@@ -526,8 +585,42 @@ func (srv *SummaryEvaluationService) CountEvaluationSelfLevel(param *command.Que |
|
|
_ = transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
|
|
|
//统计周期内,评估项等级的数量
|
|
|
assessDao := dao.NewStaffAssessDao(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
levelCodeCountList, err := assessDao.CountAssessContentLevelCode(param.UserId, domain.AssessSelf, param.CycleId)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
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 i := range evaluationInfo.EvaluationItems {
|
|
|
itemId := evaluationInfo.EvaluationItems[i].EvaluationItemId
|
|
|
levelCodes, ok := levelCodeMap[itemId]
|
|
|
if !ok {
|
|
|
continue
|
|
|
}
|
|
|
evaluationInfo.EvaluationItems[i].LevelCount = levelCodes
|
|
|
for i2 := range levelCodes {
|
|
|
key := fmt.Sprintf("%s-%s-%s",
|
|
|
evaluationInfo.EvaluationItems[i].Category,
|
|
|
evaluationInfo.EvaluationItems[i].Name,
|
|
|
levelCodes[i2].Code,
|
|
|
)
|
|
|
|
|
|
if mVal, ok := levelCodeCountMap[key]; ok {
|
|
|
levelCodes[i2].Number = mVal
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
return nil, nil
|
|
|
return evaluationInfo, nil
|
|
|
} |
...
|
...
|
|