...
|
...
|
@@ -611,7 +611,7 @@ func (srv StaffAssessServeice) GetAssessInviteUser(param *query.GetAssessInviteU |
|
|
}
|
|
|
|
|
|
// 保存某个员工360邀请的人员
|
|
|
func (srv StaffAssessServeice) SaveAssessInviteUser(param *command.SaveAssessInvite) (*adapter.AssessInviteUserResp, error) {
|
|
|
func (srv StaffAssessServeice) SaveAssessInviteUser(param *command.SaveAssessInvite) (map[string]interface{}, error) {
|
|
|
inviteSameSuperId := []int{}
|
|
|
InviteDiffSuperId := []int{}
|
|
|
for _, v := range param.InviteDiffSuper {
|
...
|
...
|
@@ -659,6 +659,19 @@ func (srv StaffAssessServeice) SaveAssessInviteUser(param *command.SaveAssessInv |
|
|
return nil, application.ThrowError(application.ARG_ERROR, "获取评估任务"+err.Error())
|
|
|
}
|
|
|
|
|
|
//获取邀请评估的节点
|
|
|
var inviteNode *domain.AssessTaskStep
|
|
|
for _, v := range assessTaskData.StepList {
|
|
|
if v.LinkNodeType == domain.LinkNodeAllAssessment {
|
|
|
cp := v
|
|
|
inviteNode = &cp
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
if inviteNode == nil {
|
|
|
return nil, application.ThrowError(application.ARG_ERROR, "评估任务没有邀请评估的环节")
|
|
|
}
|
|
|
|
|
|
targetUser, err := userRepo.FindOne(map[string]interface{}{
|
|
|
"id": param.TargetUserId,
|
|
|
})
|
...
|
...
|
@@ -725,39 +738,94 @@ func (srv StaffAssessServeice) SaveAssessInviteUser(param *command.SaveAssessInv |
|
|
return nil, application.ThrowError(application.ARG_ERROR, "获取员工邀请的人"+err.Error())
|
|
|
}
|
|
|
//比对新旧数据
|
|
|
|
|
|
_ = assessList
|
|
|
_ = targetUser
|
|
|
_ = inviteSameSuper
|
|
|
_ = inviteDiffSuper
|
|
|
_ = targetUserDepartment
|
|
|
|
|
|
nowTime := time.Now()
|
|
|
assessMap := map[string]*domain.StaffAssess{}
|
|
|
for _, v := range assessList {
|
|
|
//假设为删除
|
|
|
v.DeletedAt = &nowTime
|
|
|
key := fmt.Sprintf("%s%d", string(v.Types), v.Executor.UserId)
|
|
|
assessMap[key] = v
|
|
|
}
|
|
|
newAssessList := []*domain.StaffAssess{}
|
|
|
//邀请同上级的员工
|
|
|
for _, v := range inviteSameSuper {
|
|
|
key := fmt.Sprintf("%s%d", string(domain.AssessInviteSameSuper), v.UserId)
|
|
|
if _, ok := assessMap[key]; ok {
|
|
|
assessMap[key].DeletedAt = nil
|
|
|
} else {
|
|
|
newAssessList = append(newAssessList, &domain.StaffAssess{
|
|
|
Id: 0,
|
|
|
CompanyId: assessTaskData.CompanyId,
|
|
|
EvaluationProjectId: assessTaskData.EvaluationProjectId,
|
|
|
EvaluationProjectName: assessTaskData.EvaluationProjectName,
|
|
|
CycleId: assessTaskData.CycleId,
|
|
|
CycleName: assessTaskData.CycleName,
|
|
|
StaffAssessTaskId: assessTaskData.Id,
|
|
|
TargetUser: domain.StaffDesc{
|
|
|
UserId: int(targetUser.Id),
|
|
|
Account: targetUser.Account,
|
|
|
UserName: targetUser.Name,
|
|
|
},
|
|
|
TargetDepartment: targetUserDepartment,
|
|
|
Executor: v,
|
|
|
Types: domain.AssessInviteSameSuper,
|
|
|
LinkNodeId: inviteNode.LinkNodeId,
|
|
|
LinkNodeName: inviteNode.LinkNodeName,
|
|
|
Status: domain.StaffAssessUncompleted,
|
|
|
BeginTime: inviteNode.BeginTime,
|
|
|
EndTime: inviteNode.EndTime,
|
|
|
CreatedAt: nowTime,
|
|
|
UpdatedAt: nowTime,
|
|
|
DeletedAt: nil,
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
for _, v := range inviteDiffSuper {
|
|
|
key := fmt.Sprintf("%s%d", string(domain.AssessInviteDiffSuper), v.UserId)
|
|
|
if _, ok := assessMap[key]; ok {
|
|
|
assessMap[key].DeletedAt = nil
|
|
|
} else {
|
|
|
newAssessList = append(newAssessList, &domain.StaffAssess{
|
|
|
Id: 0,
|
|
|
CompanyId: assessTaskData.CompanyId,
|
|
|
EvaluationProjectId: assessTaskData.EvaluationProjectId,
|
|
|
EvaluationProjectName: assessTaskData.EvaluationProjectName,
|
|
|
CycleId: assessTaskData.CycleId,
|
|
|
CycleName: assessTaskData.CycleName,
|
|
|
StaffAssessTaskId: assessTaskData.Id,
|
|
|
TargetUser: domain.StaffDesc{
|
|
|
UserId: int(targetUser.Id),
|
|
|
Account: targetUser.Account,
|
|
|
UserName: targetUser.Name,
|
|
|
},
|
|
|
TargetDepartment: targetUserDepartment,
|
|
|
Executor: v,
|
|
|
Types: domain.AssessInviteDiffSuper,
|
|
|
LinkNodeId: inviteNode.LinkNodeId,
|
|
|
LinkNodeName: inviteNode.LinkNodeName,
|
|
|
Status: domain.StaffAssessUncompleted,
|
|
|
BeginTime: inviteNode.BeginTime,
|
|
|
EndTime: inviteNode.EndTime,
|
|
|
CreatedAt: nowTime,
|
|
|
UpdatedAt: nowTime,
|
|
|
DeletedAt: nil,
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
assessList = append(assessList, newAssessList...)
|
|
|
for i := range assessList {
|
|
|
_, err = assessReps.Save(assessList[i])
|
|
|
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.AssessInviteUserResp{
|
|
|
AssessTaskId: assessTaskData.Id,
|
|
|
result := map[string]interface{}{
|
|
|
"assessTaskId": assessTaskData.Id,
|
|
|
}
|
|
|
// for _, v := range assessTaskData.StepList {
|
|
|
// if v.LinkNodeType != domain.LinkNodeAllInvite {
|
|
|
// continue
|
|
|
// }
|
|
|
// result.LinkNodeId = v.LinkNodeId
|
|
|
// result.LinkNodeName = v.LinkNodeName
|
|
|
// result.BeginTime = v.BeginTime.Local().Format("2006-01-02 15:04:05")
|
|
|
// result.EndTime = v.EndTime.Local().Format("2006-01-02 15:04:05")
|
|
|
// break
|
|
|
// }
|
|
|
// for _, v := range assessList {
|
|
|
// if v.Types == domain.AssessInviteDiffSuper {
|
|
|
// result.InviteDiffSuper = append(result.InviteDiffSuper, v.Executor)
|
|
|
// }
|
|
|
// if v.Types == domain.AssessInviteSameSuper {
|
|
|
// result.InviteSameSuper = append(result.InviteDiffSuper, v.Executor)
|
|
|
// }
|
|
|
// }
|
|
|
return &result, nil
|
|
|
return result, nil
|
|
|
}
|
|
|
|
|
|
// 获取员工自评的评估内容详情
|
...
|
...
|
|