...
|
...
|
@@ -12,6 +12,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"
|
|
|
)
|
|
|
|
...
|
...
|
@@ -321,16 +322,15 @@ func (srv StaffAssessServeice) AssessSelfList(param *query.AssessSelfListQuery) |
|
|
DutyTime: userData.CreatedAt.Local().Format("2006-01-02 15:04:05"),
|
|
|
}
|
|
|
for _, v := range supperUserList {
|
|
|
userInfo.SupperUserName = userInfo.SupperUserName + v.Name + ";"
|
|
|
userInfo.SupperUserName = userInfo.SupperUserName + v.Name + " "
|
|
|
}
|
|
|
result := tool_funs.SimpleWrapGridMap(int64(cnt), listData)
|
|
|
result["userInfo"] = userInfo
|
|
|
return result, nil
|
|
|
}
|
|
|
|
|
|
// 更具项目评估的配置,创建员工的评估任务
|
|
|
// 根据项目评估的配置,创建员工的评估任务
|
|
|
func (srv StaffAssessServeice) CreateStaffAssessTask(param *command.CreateStaffAssessTask) (map[string]interface{}, error) {
|
|
|
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
...
|
...
|
@@ -546,7 +546,7 @@ func (srv StaffAssessServeice) createStaffAssessSupper( |
|
|
return nil, nil
|
|
|
}
|
|
|
|
|
|
// 获取某个员工360邀请的人员
|
|
|
// 获取某个员工360评估邀请的人员
|
|
|
func (srv StaffAssessServeice) GetAssessInviteUser(param *query.GetAssessInviteUserQuery) (*adapter.AssessInviteUserResp, error) {
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
if err != nil {
|
...
|
...
|
@@ -877,10 +877,12 @@ func (srv StaffAssessServeice) GetAssessSelfInfo(param *query.AssessSelfInfoQuer |
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//获取员工描述
|
|
|
staffDesc, _ := srv.getStaffDescrip(transactionContext, int64(param.TargetUserId))
|
|
|
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,
|
...
|
...
|
@@ -892,8 +894,17 @@ func (srv StaffAssessServeice) GetAssessSelfInfo(param *query.AssessSelfInfoQuer |
|
|
Status: string(assessData.Status),
|
|
|
TargetUserId: assessData.TargetUser.UserId,
|
|
|
TargetUserName: assessData.TargetUser.UserName,
|
|
|
CompanyId: assessData.CompanyId,
|
|
|
CompanyName: "",
|
|
|
SupperUser: "",
|
|
|
DutyTime: "",
|
|
|
AssessContent: assessContentList,
|
|
|
}
|
|
|
if staffDesc != nil {
|
|
|
result.CompanyName = staffDesc.CompanyName
|
|
|
result.SupperUser = staffDesc.SupperUserName
|
|
|
result.DutyTime = staffDesc.DutyTime
|
|
|
}
|
|
|
return &result, nil
|
|
|
}
|
|
|
|
...
|
...
|
@@ -998,13 +1009,14 @@ func (srv StaffAssessServeice) SelectAssessInviteUser(param *query.SelectAssessI |
|
|
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())
|
|
|
var targetUserDepartment []*domain.Department
|
|
|
if len(targetUser.DepartmentId) > 0 {
|
|
|
_, 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{}{}
|
...
|
...
|
@@ -1060,8 +1072,8 @@ func (srv StaffAssessServeice) SelectAssessInviteUser(param *query.SelectAssessI |
|
|
return tool_funs.SimpleWrapGridMap(int64(cnt), listData), nil
|
|
|
}
|
|
|
|
|
|
// 获取我的360评估,用户列表和评估填写的值
|
|
|
func (srv StaffAssessServeice) ListInviteUserAssess(param *query.ListInviteUserAssessQuery) (
|
|
|
// 获取我要执行的的360评估,用户列表和评估填写的值
|
|
|
func (srv StaffAssessServeice) ListExecutorInviteAssess(param *query.ListInviteUserAssessQuery) (
|
|
|
*adapter.ListInviteUserAssessResp, error) {
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
if err != nil {
|
...
|
...
|
@@ -1118,8 +1130,8 @@ func (srv StaffAssessServeice) ListInviteUserAssess(param *query.ListInviteUserA |
|
|
return &result, nil
|
|
|
}
|
|
|
|
|
|
// 获取上级评估成员列表
|
|
|
func (srv StaffAssessServeice) ListSupperAssess(param *query.ListSupperAssessQuery) (map[string]interface{}, error) {
|
|
|
// 获取我需要执行的上级评估成员列表
|
|
|
func (srv StaffAssessServeice) ListExecutorSupperAssess(param *query.ListSupperAssessQuery) (map[string]interface{}, error) {
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
...
|
...
|
@@ -1134,15 +1146,70 @@ func (srv StaffAssessServeice) ListSupperAssess(param *query.ListSupperAssessQue |
|
|
assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
//获取 executorId 对应的上级评估列表
|
|
|
cnt, assessList, err := assessRepo.Find(map[string]interface{}{
|
|
|
"staffAssessTaskId": param.AssessTaskkId,
|
|
|
|
|
|
limit := 20
|
|
|
if param.PageSize > 0 {
|
|
|
limit = param.PageSize
|
|
|
}
|
|
|
condition := map[string]interface{}{
|
|
|
"staffAssessTaskId": param.AssessTaskId,
|
|
|
"executorId": param.ExecutorId,
|
|
|
"typesList": []string{string(domain.AssessSuper)},
|
|
|
})
|
|
|
"limit": limit,
|
|
|
"targetUserName": param.UserName,
|
|
|
}
|
|
|
offset := (param.PageNumber - 1) * param.PageSize
|
|
|
if offset > 0 {
|
|
|
condition["offset"] = offset
|
|
|
}
|
|
|
//获取 executorId 对应的上级评估列表
|
|
|
cnt, assessList, err := assessRepo.Find(condition)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
userIds := []int{}
|
|
|
for _, v := range assessList {
|
|
|
userIds = append(userIds, v.TargetUser.UserId)
|
|
|
}
|
|
|
//获取员工信息
|
|
|
userRepo := factory.CreateUserRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
var targetUserList []*domain.User
|
|
|
if len(userIds) > 0 {
|
|
|
_, targetUserList, _ = userRepo.Find(map[string]interface{}{
|
|
|
"ids": userIds,
|
|
|
})
|
|
|
}
|
|
|
//获取职位信息
|
|
|
positionRepo := factory.CreatePositionRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
//获取员工的职位
|
|
|
userPositionMap := map[int64][]*domain.Position{}
|
|
|
for _, v := range targetUserList {
|
|
|
if len(v.PositionId) == 0 {
|
|
|
continue
|
|
|
}
|
|
|
_, positionList, _ := positionRepo.Find(map[string]interface{}{
|
|
|
"ids": v.PositionId,
|
|
|
})
|
|
|
userPositionMap[v.Id] = positionList
|
|
|
}
|
|
|
|
|
|
//获取员工邀请的人完成360评估的数量
|
|
|
var inviteCompletedCount []dao.CountData
|
|
|
if len(userIds) > 0 {
|
|
|
d := dao.NewStaffAssessDao(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
inviteCompletedCount, err = d.CountInviteAssessByTargetUser(userIds, param.AssessTaskId)
|
|
|
if err != nil {
|
|
|
log.Logger.Error("获取员工邀请的人完成情况" + err.Error())
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
...
|
...
|
@@ -1150,19 +1217,39 @@ func (srv StaffAssessServeice) ListSupperAssess(param *query.ListSupperAssessQue |
|
|
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: "",
|
|
|
AssessId: v.Id,
|
|
|
UserName: v.TargetUser.UserName,
|
|
|
EndTime: v.EndTime.Local().Format("2006-01-02 15:04:05"),
|
|
|
InviteCompleted: 0,
|
|
|
InviteTotal: 5,
|
|
|
Department: "",
|
|
|
Position: "",
|
|
|
DutyTime: "",
|
|
|
}
|
|
|
|
|
|
//填入部门
|
|
|
for _, vv := range v.TargetDepartment {
|
|
|
item.Department += vv.DepartmentName + " "
|
|
|
}
|
|
|
for _, vv := range targetUserList {
|
|
|
if vv.Id != int64(v.TargetUser.UserId) {
|
|
|
continue
|
|
|
}
|
|
|
//填入入职时间
|
|
|
item.DutyTime = vv.CreatedAt.Local().Format("2006-01-02 15:04:05")
|
|
|
//填入职位
|
|
|
for _, vvv := range userPositionMap[vv.Id] {
|
|
|
item.Position += vvv.Name + " "
|
|
|
}
|
|
|
break
|
|
|
}
|
|
|
//
|
|
|
for _, vv := range inviteCompletedCount {
|
|
|
if v.TargetUser.UserId == vv.TargetUserId {
|
|
|
item.InviteCompleted = vv.InviteCompleted
|
|
|
item.InviteTotal = vv.InviteTotal
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
resultList = append(resultList, item)
|
|
|
}
|
|
|
return tool_funs.SimpleWrapGridMap(int64(cnt), resultList), nil
|
...
|
...
|
@@ -1214,6 +1301,11 @@ func (srv StaffAssessServeice) GetAssessInfo(param *query.AssessInfoQuery) (*ada |
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
|
|
|
}
|
|
|
}
|
|
|
|
|
|
targetUserDesc, err := srv.getStaffDescrip(transactionContext, int64(assessData.TargetUser.UserId))
|
|
|
if err != nil {
|
|
|
log.Logger.Error("获取员工描述" + err.Error())
|
|
|
}
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
...
|
...
|
@@ -1229,8 +1321,17 @@ func (srv StaffAssessServeice) GetAssessInfo(param *query.AssessInfoQuery) (*ada |
|
|
Status: string(assessData.Status),
|
|
|
TargetUserId: assessData.TargetUser.UserId,
|
|
|
TargetUserName: assessData.TargetUser.UserName,
|
|
|
CompanyId: assessData.CompanyId,
|
|
|
CompanyName: "",
|
|
|
SupperUser: "",
|
|
|
DutyTime: "",
|
|
|
AssessContent: assessContentList,
|
|
|
}
|
|
|
if targetUserDesc != nil {
|
|
|
result.CompanyName = targetUserDesc.CompanyName
|
|
|
result.SupperUser = targetUserDesc.SupperUserName
|
|
|
result.DutyTime = targetUserDesc.DutyTime
|
|
|
}
|
|
|
return &result, nil
|
|
|
}
|
|
|
|
...
|
...
|
@@ -1239,3 +1340,175 @@ func (srv StaffAssessServeice) GetAssessInfo(param *query.AssessInfoQuery) (*ada |
|
|
func (srv StaffAssessServeice) AssessInviteList() error {
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
// 获取员工信息描述
|
|
|
func (srv *StaffAssessServeice) getStaffDescrip(transactionContext application.TransactionContext, userid int64) (*adapter.StaffInfo, error) {
|
|
|
//获取用户数据
|
|
|
userRepo := factory.CreateUserRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
userData, err := userRepo.FindOne(map[string]interface{}{
|
|
|
"id": userid,
|
|
|
})
|
|
|
if err != nil {
|
|
|
log.Logger.Error("获取用户信息," + err.Error())
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取用户信息,"+err.Error())
|
|
|
}
|
|
|
|
|
|
//获取公司数据
|
|
|
companyRep := factory.CreateCompanyRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
companyData, err := companyRep.FindOne(map[string]interface{}{
|
|
|
"id": userData.CompanyId,
|
|
|
})
|
|
|
if err != nil {
|
|
|
log.Logger.Error("获取公司信息," + err.Error())
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取公司信息,"+err.Error())
|
|
|
}
|
|
|
departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
var supperUserList []*domain.User
|
|
|
if len(userData.DepartmentId) > 0 {
|
|
|
_, departmentList, err := departmentRepo.Find(map[string]interface{}{
|
|
|
"ids": userData.DepartmentId,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取部门信息,"+err.Error())
|
|
|
}
|
|
|
var chargeUserIds []int64
|
|
|
for _, v := range departmentList {
|
|
|
chargeUserIds = append(chargeUserIds, v.ChargeUserIds...)
|
|
|
}
|
|
|
if len(chargeUserIds) > 0 {
|
|
|
_, supperUserList, err = userRepo.Find(map[string]interface{}{
|
|
|
"ids": chargeUserIds,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取员工上级信息,"+err.Error())
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
userInfo := adapter.StaffInfo{
|
|
|
UserName: userData.Name,
|
|
|
CompanyName: companyData.Name,
|
|
|
SupperUserName: "",
|
|
|
DutyTime: userData.CreatedAt.Local().Format("2006-01-02 15:04:05"),
|
|
|
}
|
|
|
for _, v := range supperUserList {
|
|
|
userInfo.SupperUserName = userInfo.SupperUserName + v.Name + " "
|
|
|
}
|
|
|
return &userInfo, nil
|
|
|
}
|
|
|
|
|
|
// 提交评估数据
|
|
|
func (srv StaffAssessServeice) SaveAssessInfo(param *command.SaveAssessInfoCommand) (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()
|
|
|
}()
|
|
|
assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
//获取员工的评估
|
|
|
assessData, err := assessReps.FindOne(map[string]interface{}{
|
|
|
"id": param.AssessId,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的评估"+err.Error())
|
|
|
}
|
|
|
assessContentRepo := factory.CreateStaffAssessContentRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
//待更新的评估填写信息
|
|
|
assessContentList := []*domain.StaffAssessContent{}
|
|
|
if assessData.Status == domain.StaffAssessCompleted {
|
|
|
//已完成
|
|
|
|
|
|
_, 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())
|
|
|
}
|
|
|
}
|
|
|
//处理提交上来的数据
|
|
|
paramContentMap := map[string]command.AssesssContent{}
|
|
|
for i, v := range param.AssessContent {
|
|
|
key := fmt.Sprintf("%s-%s", v.Category, v.Name)
|
|
|
paramContentMap[key] = param.AssessContent[i]
|
|
|
}
|
|
|
//更新的评估填写信息
|
|
|
for _, v := range assessContentList {
|
|
|
key := fmt.Sprintf("%s-%s", v.Category, v.Name)
|
|
|
item, ok := paramContentMap[key]
|
|
|
if !ok {
|
|
|
continue
|
|
|
}
|
|
|
v.Value = item.Value
|
|
|
for ii := range v.Remark {
|
|
|
for _, vvv := range item.Remark {
|
|
|
if v.Remark[ii].Title == vvv.Title {
|
|
|
v.Remark[ii].RemarkText = vvv.RemarkText
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//保存信息
|
|
|
for i := range assessContentList {
|
|
|
_, err = assessContentRepo.Save(assessContentList[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())
|
|
|
}
|
|
|
return map[string]interface{}{
|
|
|
"assessId": assessData.Id,
|
|
|
}, nil
|
|
|
}
|
|
|
|
|
|
// 获取员工被评估的列表 ,类型是360邀请的
|
|
|
func (srv StaffAssessServeice) ListTargetUserAssess(param *query.ListTargetUserAssessQuery) (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()
|
|
|
}()
|
|
|
assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
//获取员工的评估
|
|
|
cnt, assessList, err := assessReps.Find(map[string]interface{}{
|
|
|
"assessTaskId": param.AssessTaskId,
|
|
|
"companyId": param.CompanyId,
|
|
|
"targetUserId": param.TargetUserId,
|
|
|
})
|
|
|
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(cnt), assessList), nil
|
|
|
} |
...
|
...
|
|