...
|
...
|
@@ -829,7 +829,7 @@ func (srv StaffAssessServeice) SaveAssessInviteUser(param *command.SaveAssessInv |
|
|
}
|
|
|
|
|
|
// 获取员工自评的评估内容详情
|
|
|
func (srv StaffAssessServeice) GetAssessSelfInfo(param *query.AssessInfoQuery) (*adapter.AssessInfoResp, error) {
|
|
|
func (srv StaffAssessServeice) GetAssessSelfInfo(param *query.AssessSelfInfoQuery) (*adapter.AssessInfoResp, error) {
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
...
|
...
|
@@ -971,3 +971,271 @@ func (srv StaffAssessServeice) getAssessSelfInfoUncompleted(transactionContext a |
|
|
}
|
|
|
return contentList, nil
|
|
|
}
|
|
|
|
|
|
// 选择员工评估可邀请的用户
|
|
|
func (srv StaffAssessServeice) SelectAssessInviteUser(param *query.SelectAssessInviteUser) (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()
|
|
|
}()
|
|
|
//获取被评估的目标用户
|
|
|
userRepo := factory.CreateUserRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
targetUser, err := userRepo.FindOne(map[string]interface{}{
|
|
|
"id": param.TargetUserId,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工信息"+err.Error())
|
|
|
}
|
|
|
//获取被评估的目标用户的部门
|
|
|
departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
|
|
|
_, targetUserDepartment, err := departmentRepo.Find(map[string]interface{}{
|
|
|
"ids": targetUser.DepartmentId,
|
|
|
})
|
|
|
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取部门信息"+err.Error())
|
|
|
}
|
|
|
//获取部门主管的id
|
|
|
targetUserCharge := map[int64]struct{}{}
|
|
|
for _, v := range targetUserDepartment {
|
|
|
for _, vv := range v.ChargeUserIds {
|
|
|
targetUserCharge[vv] = struct{}{}
|
|
|
}
|
|
|
}
|
|
|
//
|
|
|
targetUserDepartmentMap := map[int64]struct{}{}
|
|
|
for _, v := range targetUserDepartment {
|
|
|
targetUserDepartmentMap[v.Id] = struct{}{}
|
|
|
}
|
|
|
//查询员工数据
|
|
|
condition := map[string]interface{}{
|
|
|
"companyId": param.CompanyId,
|
|
|
"name": param.InviteUserName,
|
|
|
"limit": 20,
|
|
|
}
|
|
|
if param.PageSize > 0 {
|
|
|
condition["limit"] = param.PageSize
|
|
|
}
|
|
|
offset := (param.PageNumber - 1) * param.PageSize
|
|
|
if offset > 0 {
|
|
|
condition["offset"] = offset
|
|
|
}
|
|
|
cnt, userList, err := userRepo.Find(condition)
|
|
|
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())
|
|
|
}
|
|
|
listData := []adapter.SelectInviteUser{}
|
|
|
for _, v := range userList {
|
|
|
item := adapter.SelectInviteUser{
|
|
|
UserId: int(v.Id),
|
|
|
UserName: v.Name,
|
|
|
IsSupper: false,
|
|
|
Types: 2, //默认是不同上级
|
|
|
}
|
|
|
if _, ok := targetUserCharge[v.Id]; ok {
|
|
|
item.IsSupper = true
|
|
|
}
|
|
|
for _, vv := range v.DepartmentId {
|
|
|
if _, ok := targetUserDepartmentMap[int64(vv)]; ok {
|
|
|
item.Types = 1 //设为相同上级
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
listData = append(listData, item)
|
|
|
}
|
|
|
return tool_funs.SimpleWrapGridMap(int64(cnt), listData), nil
|
|
|
}
|
|
|
|
|
|
// 获取我的360评估,用户列表和评估填写的值
|
|
|
func (srv StaffAssessServeice) ListInviteUserAssess(param *query.ListInviteUserAssessQuery) (
|
|
|
*adapter.ListInviteUserAssessResp, 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()
|
|
|
}()
|
|
|
//获取对应的评估任务
|
|
|
assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
//获取 executorId 对应的360评估任务 用户
|
|
|
cnt, assessList, err := assessRepo.Find(map[string]interface{}{
|
|
|
"staffAssessTaskId": param.AssessTaskkId,
|
|
|
"executorId": param.ExecutorId,
|
|
|
"typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
|
|
|
})
|
|
|
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())
|
|
|
}
|
|
|
|
|
|
//TODO 评估填写数据行转列
|
|
|
tableHeader := []adapter.ListTableHeader{
|
|
|
{Key: "userName", Name: "姓名"},
|
|
|
{Key: "status", Name: "状态"},
|
|
|
{Key: "types", Name: "360°评估关系"},
|
|
|
{Key: "endTime", Name: "360°评估截止日期"},
|
|
|
}
|
|
|
listData := []map[string]string{}
|
|
|
for _, v := range assessList {
|
|
|
m := map[string]string{
|
|
|
"userName": v.TargetUser.UserName,
|
|
|
"status": string(v.Status),
|
|
|
"types": string(v.Types),
|
|
|
"endTime": v.EndTime.Local().Format("2006-01-02 15:04:05"),
|
|
|
}
|
|
|
listData = append(listData, m)
|
|
|
}
|
|
|
_ = tableHeader
|
|
|
|
|
|
result := adapter.ListInviteUserAssessResp{
|
|
|
TableHeader: tableHeader,
|
|
|
List: listData,
|
|
|
Total: cnt,
|
|
|
}
|
|
|
return &result, nil
|
|
|
}
|
|
|
|
|
|
// 获取上级评估成员列表
|
|
|
func (srv StaffAssessServeice) ListSupperAssess(param *query.ListSupperAssessQuery) (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()
|
|
|
}()
|
|
|
//获取对应的评估任务
|
|
|
assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
//获取 executorId 对应的上级评估列表
|
|
|
cnt, assessList, err := assessRepo.Find(map[string]interface{}{
|
|
|
"staffAssessTaskId": param.AssessTaskkId,
|
|
|
"executorId": param.ExecutorId,
|
|
|
"typesList": []string{string(domain.AssessSuper)},
|
|
|
})
|
|
|
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())
|
|
|
}
|
|
|
|
|
|
resultList := []adapter.ListSupperAssessResp{}
|
|
|
for _, v := range assessList {
|
|
|
item := adapter.ListSupperAssessResp{
|
|
|
AssessId: v.Id,
|
|
|
UserName: v.TargetUser.UserName,
|
|
|
EndTime: v.EndTime.Local().Format("2006-01-02 15:04:05"),
|
|
|
InviteUncompleted: 0,
|
|
|
InviteTotal: 5,
|
|
|
Department: "",
|
|
|
Position: "",
|
|
|
DutyTime: "",
|
|
|
}
|
|
|
|
|
|
for _, vv := range v.TargetDepartment {
|
|
|
item.Department += vv.DepartmentName + " "
|
|
|
}
|
|
|
resultList = append(resultList, item)
|
|
|
}
|
|
|
return tool_funs.SimpleWrapGridMap(int64(cnt), resultList), nil
|
|
|
}
|
|
|
|
|
|
// 根据staffAssessId 获取评估的填写信息
|
|
|
func (srv StaffAssessServeice) GetAssessInfo(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,
|
|
|
"id": param.AssessId,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的评估"+err.Error())
|
|
|
}
|
|
|
if len(assessList) == 0 {
|
|
|
return &adapter.AssessInfoResp{}, nil
|
|
|
}
|
|
|
assessData := assessList[0]
|
|
|
assessContentList := []*domain.StaffAssessContent{}
|
|
|
if assessData.Status == domain.StaffAssessCompleted {
|
|
|
//已完成
|
|
|
assessContentRepo := factory.CreateStaffAssessContentRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
_, assessContentList, err = assessContentRepo.Find(map[string]interface{}{
|
|
|
"staffAssessId": assessData.Id,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
|
|
|
}
|
|
|
} else if assessData.Status == domain.StaffAssessUncompleted {
|
|
|
//未完成
|
|
|
assessContentList, err = srv.getAssessSelfInfoUncompleted(transactionContext, assessData)
|
|
|
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{
|
|
|
AssessId: assessData.Id,
|
|
|
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: assessContentList,
|
|
|
}
|
|
|
return &result, nil
|
|
|
}
|
|
|
|
|
|
// 获取员工的某次评估任务的360评估记录录
|
|
|
// assessTaskId targetUserId
|
|
|
func (srv StaffAssessServeice) AssessInviteList() error {
|
|
|
return nil
|
|
|
} |
...
|
...
|
|