作者 Your Name

更新

... ... @@ -22,5 +22,4 @@ type AssessContent struct {
PromptTitle string `json:"promptTitle" comment:"提示项标题"`
PromptText string `json:"promptText" comment:"提示项正文"`
EntryItems []domain.EntryItem `json:"entryItems" comment:"填写项"`
RuleId string
}
... ...
package query
type AssessInfoQuery struct {
AssessTaskId int `json:"assessTaskId"` //StaffAssess 的id
TargetUserId int `json:"targetUserId"` //被评估的人id
CompanyId int `json:"companyId"` //公司id
}
... ...
package query
type AssessSelfInfo struct {
AssessId int `json:"assessId"` //StaffAssess 的id
UserId int `json:"userId"`
CompanyId int `json:"companyId"`
}
... ... @@ -660,6 +660,9 @@ func (srv StaffAssessServeice) SaveAssessInviteUser(param *command.SaveAssessInv
targetUser, err := userRepo.FindOne(map[string]interface{}{
"id": param.TargetUserId,
})
if err != nil {
return nil, application.ThrowError(application.ARG_ERROR, "获取被评估员工"+err.Error())
}
//被评估人的部门
var targetUserDepartment []domain.StaffDepartment
if len(targetUser.DepartmentId) > 0 {
... ... @@ -676,7 +679,7 @@ func (srv StaffAssessServeice) SaveAssessInviteUser(param *command.SaveAssessInv
})
}
}
//相同上级的员工
//邀请的相同上级的员工
var inviteSameSuper []domain.StaffDesc
if len(inviteSameSuperId) > 0 {
_, userList, err := userRepo.Find(map[string]interface{}{
... ... @@ -693,22 +696,27 @@ func (srv StaffAssessServeice) SaveAssessInviteUser(param *command.SaveAssessInv
})
}
}
//邀请的不同上级的员工
var inviteDiffSuper []domain.StaffDesc
if len(InviteDiffSuperId) > 0 {
_, userList, err := userRepo.Find(map[string]interface{}{
"ids": inviteSameSuperId,
"ids": InviteDiffSuperId,
})
if err != nil {
return nil, application.ThrowError(application.ARG_ERROR, "获取用户信息"+err.Error())
}
for _, v := range userList {
inviteSameSuper = append(inviteSameSuper, domain.StaffDesc{
inviteDiffSuper = append(inviteDiffSuper, domain.StaffDesc{
UserId: int(v.Id),
UserName: v.Name,
Account: v.Account,
})
}
}
_ = assessReps
_ = inviteSameSuper
_ = inviteDiffSuper
_ = targetUserDepartment
// _, assessList, err := assessReps.Find(map[string]interface{}{
// "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
// "staffAssessTaskId": param.AssessTaskId,
... ... @@ -717,6 +725,7 @@ func (srv StaffAssessServeice) SaveAssessInviteUser(param *command.SaveAssessInv
// if err != nil {
// return nil, application.ThrowError(application.ARG_ERROR, "获取个人评估任务"+err.Error())
// }
// TODO
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ... @@ -745,3 +754,94 @@ func (srv StaffAssessServeice) SaveAssessInviteUser(param *command.SaveAssessInv
// }
return &result, nil
}
// 获取员工自评的评估内容详情
func (srv StaffAssessServeice) GetAssessSelfInfo(param *query.AssessInfoQuery) (*adapter.AssessInfoResp, 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()
}()
assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
//获取员工的评估
_, assessList, err := assessReps.Find(map[string]interface{}{
"companyId": param.CompanyId,
"staffAssessTaskId": param.AssessTaskId,
"targetUserId": param.TargetUserId,
"typesList": []string{string(domain.AssessSelf)},
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的评估"+err.Error())
}
if len(assessList) == 0 {
return &adapter.AssessInfoResp{}, nil
}
assessData := assessList[0]
projectRepo := factory.CreateEvaluationProjectRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
projectData, err := projectRepo.FindOne(map[string]interface{}{
"id": assessData.EvaluationProjectId,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目评估配置"+err.Error())
}
if projectData.Template == nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未获取到项目评估配置模板")
}
var selfLinkNode *domain.LinkNode
for _, v := range projectData.Template.LinkNodes {
if v.Type == domain.LinkNodeSelfAssessment {
selfLinkNode = v
break
}
}
if selfLinkNode == nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未获取到项目评估自评配置")
}
//获取员工评估的填写内容
// assessContentReps := factory.CreateStaffAssessContentRepository(map[string]interface{}{
// "transactionContext": transactionContext,
// })
// _, assessContentList, err := assessContentReps.Find(map[string]interface{}{
// "staffAssessId": assessData.Id,
// })
// 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())
}
result := adapter.AssessInfoResp{
CycleId: assessData.CycleId,
CycleName: assessData.CycleName,
EvaluationProjectId: assessData.EvaluationProjectId,
EvaluationProjectName: assessData.EvaluationProjectName,
BeginTime: assessData.BeginTime.Local().Format("2006-01-02 15:04:05"),
EndTime: assessData.EndTime.Local().Format("2006-01-02 15:04:05"),
Status: string(assessData.Status),
TargetUserId: assessData.TargetUser.UserId,
TargetUserName: assessData.TargetUser.UserName,
AssessContent: nil,
}
assessContent := make([]adapter.AssessContent, 0)
for _, v := range selfLinkNode.NodeContents {
assessContent = append(assessContent, adapter.AssessContent{
Category: v.Category,
Name: v.Name,
PromptTitle: v.PromptTitle,
PromptText: v.PromptText,
})
}
result.AssessContent = assessContent
return &result, nil
}
... ...
... ... @@ -17,6 +17,11 @@ type StaffAssessContent struct {
//TODO
}
type AssessContemtRemark struct {
Title string `json:"title"` //comment:"填写标题"
RemarkText string `json:"hintText"` // comment:"填写文本内容"
}
type StaffAssessContentRepository interface {
Save(param *StaffAssessContent) (*StaffAssessContent, error)
Remove(id int) error
... ...
... ... @@ -89,7 +89,9 @@ func (repo *StaffAssessContentRepository) Find(queryOptions map[string]interface
if v, ok := queryOptions["offset"].(int); ok {
query.Offset(v)
}
if v, ok := queryOptions["staffAssessId"]; ok {
query.Where("staff_assess_id=?", v)
}
count, err := query.SelectAndCount()
if err != nil {
return 0, nil, err
... ...