...
|
...
|
@@ -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"
|
|
|
)
|
|
|
|
...
|
...
|
@@ -36,27 +37,40 @@ func (srv StaffAssessServeice) SearchAssessTaskMe(param *query.SearchAssessMeQue |
|
|
defer func() {
|
|
|
_ = transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
staffAssessTaskRepo := factory.CreateStaffAssessTaskRepository(map[string]interface{}{
|
|
|
// staffAssessTaskRepo := factory.CreateStaffAssessTaskRepository(map[string]interface{}{
|
|
|
// "transactionContext": transactionContext,
|
|
|
// })
|
|
|
|
|
|
staffAssessTaskRepo := dao.NewStaffAssessDao(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
var limit int = 20
|
|
|
|
|
|
var limit int = 200
|
|
|
var offset int = 0
|
|
|
if param.PageSize > 0 {
|
|
|
limit = param.PageSize
|
|
|
}
|
|
|
offset = (param.PageNumber - 1) * param.PageSize
|
|
|
condition := map[string]interface{}{
|
|
|
"executorId": param.UserId,
|
|
|
"companyId": param.CompanyId,
|
|
|
"limit": limit,
|
|
|
}
|
|
|
if offset > 0 {
|
|
|
condition["offset"] = offset
|
|
|
assessTaskList, err := staffAssessTaskRepo.SearchAssessTaskMe(param.UserId, param.CompanyId, limit, offset)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询评估任务"+err.Error())
|
|
|
}
|
|
|
cnt, assessTaskList, err := staffAssessTaskRepo.Find(condition)
|
|
|
cnt, err := staffAssessTaskRepo.CountAssessTaskMe(param.UserId, param.CompanyId)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询周期"+err.Error())
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询评估任务"+err.Error())
|
|
|
}
|
|
|
// condition := map[string]interface{}{
|
|
|
// "executorId": param.UserId,
|
|
|
// "companyId": param.CompanyId,
|
|
|
// "limit": limit,
|
|
|
// }
|
|
|
// if offset > 0 {
|
|
|
// condition["offset"] = offset
|
|
|
// }
|
|
|
// cnt, assessTaskList, err := staffAssessTaskRepo.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())
|
|
|
}
|
...
|
...
|
@@ -199,6 +213,7 @@ func (srv StaffAssessServeice) AssessTaskDesc(param *query.AssessTaskDescQuery) |
|
|
}
|
|
|
}
|
|
|
if uncompletedNum > 0 {
|
|
|
stepItem.Status = string(domain.StaffAssessUncompleted)
|
|
|
stepItem.Desc = fmt.Sprintf("截止日期:%s 待评估%d人", stepItem.EndTime, uncompletedNum)
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -321,27 +336,31 @@ 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())
|
|
|
}
|
|
|
if err := transactionContext.StartTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
defer func() {
|
|
|
_ = transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
|
|
|
// 根据项目评估的配置,创建员工的评估任务
|
|
|
func (srv StaffAssessServeice) CreateStaffAssessTask(transactionContext application.TransactionContext, param *command.CreateStaffAssessTask) (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()
|
|
|
// }()
|
|
|
log.Logger.Debug("CreateStaffAssessTask 获取参数", map[string]interface{}{
|
|
|
"param": param,
|
|
|
})
|
|
|
assessTaskRepo := factory.CreateStaffAssessTaskRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
taskBeginTime, err := time.ParseInLocation("2006-01-02 15:04:05", param.BeginTime, time.Local)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.ARG_ERROR, "任务开始时间填写错误,"+param.BeginTime)
|
...
|
...
|
@@ -352,7 +371,7 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(param *command.CreateStaffA |
|
|
}
|
|
|
nowTime := time.Now()
|
|
|
//建立评估任务
|
|
|
assessTask := domain.StaffAssessTask{
|
|
|
assessTaskData := &domain.StaffAssessTask{
|
|
|
Id: 0,
|
|
|
CompanyId: param.CompanyId,
|
|
|
EvaluationProjectId: param.EvaluationProjectId,
|
...
|
...
|
@@ -366,9 +385,17 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(param *command.CreateStaffA |
|
|
CreatedAt: nowTime,
|
|
|
UpdatedAt: nowTime,
|
|
|
DeletedAt: nil,
|
|
|
BeginDay: taskBeginTime.Local().Format("2006-01-02"),
|
|
|
}
|
|
|
// }
|
|
|
|
|
|
//填充评估环节
|
|
|
for _, v := range param.StepList {
|
|
|
for _, vv := range assessTaskData.StepList {
|
|
|
if vv.LinkNodeType == v.LinkNodeType {
|
|
|
continue
|
|
|
}
|
|
|
}
|
|
|
stepBeginTime, err := time.ParseInLocation("2006-01-02 15:04:05", param.BeginTime, time.Local)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.ARG_ERROR, "评估环节开始时间填写错误,"+param.BeginTime)
|
...
|
...
|
@@ -385,41 +412,71 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(param *command.CreateStaffA |
|
|
BeginTime: stepBeginTime,
|
|
|
EndTime: stepEndTime,
|
|
|
}
|
|
|
assessTask.StepList = append(assessTask.StepList, step)
|
|
|
assessTaskData.StepList = append(assessTaskData.StepList, step)
|
|
|
}
|
|
|
|
|
|
assessTaskRepo := factory.CreateStaffAssessTaskRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
//评估的参与人
|
|
|
executorIds := []int{}
|
|
|
executorIdMap := map[int]struct{}{} //过滤重复的用户
|
|
|
for _, v := range param.ExecutorId {
|
|
|
if _, ok := executorIdMap[v]; ok {
|
|
|
continue
|
|
|
}
|
|
|
executorIdMap[v] = struct{}{}
|
|
|
executorIds = append(executorIds, v)
|
|
|
}
|
|
|
assessTaskData.ExecutorId = executorIds
|
|
|
assessList, err := srv.createStaffAssess(transactionContext, assessTaskData)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "生成个人评估项"+err.Error())
|
|
|
}
|
|
|
// var assessTaskData *domain.StaffAssessTask
|
|
|
_, assassessTaskList, err := assessTaskRepo.Find(map[string]interface{}{
|
|
|
"evaluationProjectId": param.EvaluationProjectId,
|
|
|
"beginDay": taskBeginTime.Local().Format("2006-01-02"),
|
|
|
})
|
|
|
_, err = assessTaskRepo.Save(&assessTask)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存评估任务"+err.Error())
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询同日期已存在评估任务"+err.Error())
|
|
|
}
|
|
|
|
|
|
assessList, err := srv.createStaffAssess(transactionContext, &assessTask)
|
|
|
if len(assassessTaskList) > 0 {
|
|
|
//过滤就数据
|
|
|
assessTaskData.Id = assassessTaskList[0].Id
|
|
|
for _, v := range assassessTaskList[0].ExecutorId {
|
|
|
if _, ok := executorIdMap[v]; ok {
|
|
|
continue
|
|
|
}
|
|
|
executorIdMap[v] = struct{}{}
|
|
|
executorIds = append(executorIds, v)
|
|
|
}
|
|
|
assessTaskData.ExecutorId = executorIds
|
|
|
assessTaskData.StepList = append(assassessTaskList[0].StepList, assessTaskData.StepList...)
|
|
|
|
|
|
}
|
|
|
_, err = assessTaskRepo.Save(assessTaskData)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "生成个人评估项"+err.Error())
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存评估任务"+err.Error())
|
|
|
}
|
|
|
|
|
|
assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
|
|
|
for i := range assessList {
|
|
|
assessList[i].StaffAssessTaskId = assessTaskData.Id
|
|
|
_, err = assessRepo.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())
|
|
|
}
|
|
|
|
|
|
// if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
// }
|
|
|
return map[string]interface{}{
|
|
|
"assessTaskId": assessTask.Id,
|
|
|
"assessTaskId": assessTaskData.Id,
|
|
|
}, nil
|
|
|
}
|
|
|
|
|
|
// 添加自评节点任务
|
|
|
// 添加节点任务
|
|
|
func (srv StaffAssessServeice) createStaffAssess(transactionContext application.TransactionContext, param *domain.StaffAssessTask) ([]domain.StaffAssess, error) {
|
|
|
//评估的参与人
|
|
|
selfUserId := []int{}
|
...
|
...
|
@@ -432,6 +489,9 @@ func (srv StaffAssessServeice) createStaffAssess(transactionContext application. |
|
|
}
|
|
|
// 获取用户的信息
|
|
|
if len(selfUserId) == 0 {
|
|
|
log.Logger.Error("createStaffAssess", map[string]interface{}{
|
|
|
"param": param,
|
|
|
})
|
|
|
return nil, application.ThrowError(application.ARG_ERROR, "未填写评估任务的执行人")
|
|
|
}
|
|
|
userRepo := factory.CreateUserRepository(map[string]interface{}{
|
...
|
...
|
@@ -450,6 +510,9 @@ func (srv StaffAssessServeice) createStaffAssess(transactionContext application. |
|
|
//获取用户的部门
|
|
|
userDepartmentMap := map[int64][]*domain.Department{}
|
|
|
for _, v := range userList {
|
|
|
if len(v.DepartmentId) == 0 {
|
|
|
continue
|
|
|
}
|
|
|
_, departmemtList, err := departmentRepo.Find(map[string]interface{}{
|
|
|
"ids": v.DepartmentId,
|
|
|
})
|
...
|
...
|
@@ -471,7 +534,7 @@ func (srv StaffAssessServeice) createStaffAssess(transactionContext application. |
|
|
// TargetUser: domain.StaffDesc{},
|
|
|
// TargetDepartment: nil,
|
|
|
// Executor: domain.StaffDesc{},
|
|
|
Types: domain.AssessSelf,
|
|
|
Types: "",
|
|
|
// LinkNodeId: v.LinkNodeId,
|
|
|
Status: domain.StaffAssessUncompleted,
|
|
|
// BeginTime: time.Time{},
|
...
|
...
|
@@ -487,6 +550,7 @@ func (srv StaffAssessServeice) createStaffAssess(transactionContext application. |
|
|
stepSelfTemp.EndTime = v.EndTime
|
|
|
stepSelfTemp.LinkNodeId = v.LinkNodeId
|
|
|
stepSelfTemp.LinkNodeName = v.LinkNodeName
|
|
|
stepSelfTemp.Types = domain.AssessSelf
|
|
|
assessListTemp := srv.createStaffAssessSelf(stepSelfTemp, userList, userDepartmentMap)
|
|
|
assessList = append(assessList, assessListTemp...)
|
|
|
}
|
...
|
...
|
@@ -496,11 +560,12 @@ func (srv StaffAssessServeice) createStaffAssess(transactionContext application. |
|
|
stepSelfTemp.EndTime = v.EndTime
|
|
|
stepSelfTemp.LinkNodeId = v.LinkNodeId
|
|
|
stepSelfTemp.LinkNodeName = v.LinkNodeName
|
|
|
assessListTemp, err := srv.createStaffAssessSupper(transactionContext, stepSelfTemp, userList, userDepartmentMap)
|
|
|
stepSelfTemp.Types = domain.AssessSuper
|
|
|
assessListTemp2, err := srv.createStaffAssessSupper(transactionContext, stepSelfTemp, userList, userDepartmentMap)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
assessList = append(assessList, assessListTemp...)
|
|
|
assessList = append(assessList, assessListTemp2...)
|
|
|
}
|
|
|
}
|
|
|
return assessList, nil
|
...
|
...
|
@@ -511,15 +576,16 @@ func (srv StaffAssessServeice) createStaffAssessSelf(assessTemp domain.StaffAsse |
|
|
userList []*domain.User, userDepartmentMap map[int64][]*domain.Department) []domain.StaffAssess {
|
|
|
result := []domain.StaffAssess{}
|
|
|
for _, usr := range userList {
|
|
|
|
|
|
assessTemp.TargetUser = domain.StaffDesc{
|
|
|
UserId: int(usr.Id),
|
|
|
Account: usr.Account,
|
|
|
UserName: usr.Account,
|
|
|
UserName: usr.Name,
|
|
|
}
|
|
|
assessTemp.Executor = domain.StaffDesc{
|
|
|
UserId: int(usr.Id),
|
|
|
Account: usr.Account,
|
|
|
UserName: usr.Account,
|
|
|
UserName: usr.Name,
|
|
|
}
|
|
|
if depList, ok := userDepartmentMap[usr.Id]; ok {
|
|
|
for _, dep := range depList {
|
...
|
...
|
@@ -540,13 +606,49 @@ func (srv StaffAssessServeice) createStaffAssessSupper( |
|
|
assessTemp domain.StaffAssess,
|
|
|
userList []*domain.User, userDepartmentMap map[int64][]*domain.Department,
|
|
|
) ([]domain.StaffAssess, error) {
|
|
|
|
|
|
var assessList []domain.StaffAssess
|
|
|
// 获取员工的上级用户
|
|
|
|
|
|
return nil, nil
|
|
|
userRepo := factory.CreateUserRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
for _, v := range userList {
|
|
|
departmentList, ok := userDepartmentMap[v.Id]
|
|
|
if !ok {
|
|
|
continue
|
|
|
}
|
|
|
for _, vv2 := range departmentList {
|
|
|
if len(vv2.ChargeUserIds) == 0 {
|
|
|
continue
|
|
|
}
|
|
|
_, chargeUserList, err := userRepo.Find(map[string]interface{}{
|
|
|
"ids": vv2.ChargeUserIds,
|
|
|
"limit": 40,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.ARG_ERROR, "获取部门主管信息"+err.Error())
|
|
|
}
|
|
|
for _, vvv3 := range chargeUserList {
|
|
|
assessTemp.TargetDepartment = []domain.StaffDepartment{
|
|
|
{DepartmentId: int(vv2.Id), DepartmentName: vv2.Name},
|
|
|
}
|
|
|
assessTemp.TargetUser = domain.StaffDesc{
|
|
|
UserId: int(v.Id),
|
|
|
Account: v.Account,
|
|
|
UserName: v.Name,
|
|
|
}
|
|
|
assessTemp.Executor = domain.StaffDesc{
|
|
|
UserId: int(vvv3.Id),
|
|
|
Account: vvv3.Account,
|
|
|
UserName: vvv3.Name,
|
|
|
}
|
|
|
assessList = append(assessList, assessTemp)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return assessList, nil
|
|
|
}
|
|
|
|
|
|
// 获取某个员工360邀请的人员
|
|
|
// 获取某个员工360评估邀请的人员
|
|
|
func (srv StaffAssessServeice) GetAssessInviteUser(param *query.GetAssessInviteUserQuery) (*adapter.AssessInviteUserResp, error) {
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
if err != nil {
|
...
|
...
|
@@ -575,7 +677,7 @@ func (srv StaffAssessServeice) GetAssessInviteUser(param *query.GetAssessInviteU |
|
|
_, assessList, err := assessReps.Find(map[string]interface{}{
|
|
|
"typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
|
|
|
"staffAssessTaskId": param.AssessTaskId,
|
|
|
"targetUserId": param.UsrId,
|
|
|
"targetUserId": param.UserId,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.ARG_ERROR, "获取个人评估任务"+err.Error())
|
...
|
...
|
@@ -585,7 +687,9 @@ func (srv StaffAssessServeice) GetAssessInviteUser(param *query.GetAssessInviteU |
|
|
}
|
|
|
|
|
|
result := adapter.AssessInviteUserResp{
|
|
|
AssessTaskId: assessTaskData.Id,
|
|
|
AssessTaskId: assessTaskData.Id,
|
|
|
InviteDiffSuper: []domain.StaffDesc{},
|
|
|
InviteSameSuper: []domain.StaffDesc{},
|
|
|
}
|
|
|
for _, v := range assessTaskData.StepList {
|
|
|
if v.LinkNodeType != domain.LinkNodeAllInvite {
|
...
|
...
|
@@ -608,8 +712,8 @@ func (srv StaffAssessServeice) GetAssessInviteUser(param *query.GetAssessInviteU |
|
|
return &result, nil
|
|
|
}
|
|
|
|
|
|
// 获取某个员工360邀请的人员
|
|
|
func (srv StaffAssessServeice) SaveAssessInviteUser(param *command.SaveAssessInvite) (*adapter.AssessInviteUserResp, error) {
|
|
|
// 保存某个员工360邀请的人员
|
|
|
func (srv StaffAssessServeice) SaveAssessInviteUser(param *command.SaveAssessInvite) (map[string]interface{}, error) {
|
|
|
inviteSameSuperId := []int{}
|
|
|
InviteDiffSuperId := []int{}
|
|
|
for _, v := range param.InviteDiffSuper {
|
...
|
...
|
@@ -657,6 +761,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,
|
|
|
})
|
...
|
...
|
@@ -713,50 +830,108 @@ func (srv StaffAssessServeice) SaveAssessInviteUser(param *command.SaveAssessInv |
|
|
})
|
|
|
}
|
|
|
}
|
|
|
_ = assessReps
|
|
|
_ = inviteSameSuper
|
|
|
_ = inviteDiffSuper
|
|
|
_ = targetUserDepartment
|
|
|
// _, assessList, err := assessReps.Find(map[string]interface{}{
|
|
|
// "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
|
|
|
// "staffAssessTaskId": param.AssessTaskId,
|
|
|
// "targetUserId": param.TargetUserId,
|
|
|
// })
|
|
|
// if err != nil {
|
|
|
// return nil, application.ThrowError(application.ARG_ERROR, "获取个人评估任务"+err.Error())
|
|
|
// }
|
|
|
// TODO
|
|
|
|
|
|
//获取员工邀请的人
|
|
|
_, assessList, err := assessReps.Find(map[string]interface{}{
|
|
|
"typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
|
|
|
"staffAssessTaskId": param.AssessTaskId,
|
|
|
"targetUserId": param.TargetUserId,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.ARG_ERROR, "获取员工邀请的人"+err.Error())
|
|
|
}
|
|
|
//比对新旧数据
|
|
|
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,
|
|
|
}
|
|
|
// 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
|
|
|
result := map[string]interface{}{
|
|
|
"assessTaskId": assessTaskData.Id,
|
|
|
}
|
|
|
return result, nil
|
|
|
}
|
|
|
|
|
|
// 获取员工自评的评估内容详情
|
|
|
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())
|
...
|
...
|
@@ -770,7 +945,6 @@ func (srv StaffAssessServeice) GetAssessSelfInfo(param *query.AssessInfoQuery) ( |
|
|
assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
|
|
|
//获取员工的评估
|
|
|
_, assessList, err := assessReps.Find(map[string]interface{}{
|
|
|
"companyId": param.CompanyId,
|
...
|
...
|
@@ -785,45 +959,38 @@ func (srv StaffAssessServeice) GetAssessSelfInfo(param *query.AssessInfoQuery) ( |
|
|
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
|
|
|
|
|
|
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 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())
|
|
|
// }
|
|
|
|
|
|
//获取员工描述
|
|
|
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,
|
|
|
CycleName: assessData.CycleName,
|
|
|
LinkNodeId: assessData.LinkNodeId,
|
|
|
LinkNodeName: assessData.LinkNodeName,
|
|
|
EvaluationProjectId: assessData.EvaluationProjectId,
|
|
|
EvaluationProjectName: assessData.EvaluationProjectName,
|
|
|
BeginTime: assessData.BeginTime.Local().Format("2006-01-02 15:04:05"),
|
...
|
...
|
@@ -831,18 +998,715 @@ func (srv StaffAssessServeice) GetAssessSelfInfo(param *query.AssessInfoQuery) ( |
|
|
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,
|
|
|
EntryItems: v.EntryItems,
|
|
|
})
|
|
|
CompanyId: assessData.CompanyId,
|
|
|
CompanyName: "",
|
|
|
SupperUser: "",
|
|
|
DutyTime: "",
|
|
|
AssessContent: assessContentList,
|
|
|
}
|
|
|
if staffDesc != nil {
|
|
|
result.CompanyName = staffDesc.CompanyName
|
|
|
result.SupperUser = staffDesc.SupperUserName
|
|
|
result.DutyTime = staffDesc.DutyTime
|
|
|
}
|
|
|
result.AssessContent = assessContent
|
|
|
return &result, nil
|
|
|
}
|
|
|
|
|
|
// 获取未完成的员工评估内容
|
|
|
func (srv StaffAssessServeice) getAssessSelfInfoUncompleted(transactionContext application.TransactionContext,
|
|
|
assess *domain.StaffAssess) ([]*domain.StaffAssessContent, error) {
|
|
|
projectRepo := factory.CreateEvaluationProjectRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
projectData, err := projectRepo.FindOne(map[string]interface{}{
|
|
|
"id": assess.EvaluationProjectId,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
|
|
|
}
|
|
|
var linkNode *domain.LinkNode
|
|
|
for _, v := range projectData.Template.LinkNodes {
|
|
|
if v.Id == int64(assess.LinkNodeId) {
|
|
|
linkNode = v
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
if linkNode == nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未获得评估环节配置"+err.Error())
|
|
|
}
|
|
|
ruleRepo := factory.CreateEvaluationRuleRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
ruleMap := map[int64]*domain.EvaluationRule{}
|
|
|
for _, v := range linkNode.NodeContents {
|
|
|
if _, ok := ruleMap[v.RuleId]; ok {
|
|
|
continue
|
|
|
}
|
|
|
ruleData, err := ruleRepo.FindOne(map[string]interface{}{
|
|
|
"id": v.RuleId,
|
|
|
})
|
|
|
if err == nil {
|
|
|
ruleMap[v.RuleId] = ruleData
|
|
|
}
|
|
|
}
|
|
|
|
|
|
var contentList []*domain.StaffAssessContent
|
|
|
nowTime := time.Now()
|
|
|
for i, v := range linkNode.NodeContents {
|
|
|
item := &domain.StaffAssessContent{
|
|
|
Id: 0,
|
|
|
StaffAssessId: assess.Id,
|
|
|
SortBy: i + 1,
|
|
|
Category: v.Category,
|
|
|
Name: v.Name,
|
|
|
PromptTitle: v.PromptTitle,
|
|
|
PromptText: v.PromptText,
|
|
|
Remark: nil,
|
|
|
Value: "",
|
|
|
ReteResult: "",
|
|
|
CreatedAt: nowTime,
|
|
|
Weight: v.Weight,
|
|
|
UpdatedAt: nowTime,
|
|
|
DeletedAt: nil,
|
|
|
// Rule: ,
|
|
|
}
|
|
|
if ruleVal, ok := ruleMap[v.RuleId]; ok {
|
|
|
item.Rule = *ruleVal
|
|
|
}
|
|
|
var remarks []domain.AssessContemtRemark
|
|
|
for _, vv := range v.EntryItems {
|
|
|
ritem := domain.AssessContemtRemark{
|
|
|
Title: vv.Title,
|
|
|
HintText: vv.HintText,
|
|
|
RemarkText: "",
|
|
|
}
|
|
|
remarks = append(remarks, ritem)
|
|
|
}
|
|
|
item.Remark = remarks
|
|
|
contentList = append(contentList, item)
|
|
|
}
|
|
|
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,
|
|
|
})
|
|
|
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{}{}
|
|
|
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) ListExecutorInviteAssess(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,
|
|
|
})
|
|
|
assessTaskRepo := factory.CreateStaffAssessTaskRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
|
|
|
//获取 executorId 对应的360评估任务 用户
|
|
|
condition := map[string]interface{}{
|
|
|
"staffAssessTaskId": param.AssessTaskId,
|
|
|
"executorId": param.ExecutorId,
|
|
|
"typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
|
|
|
"limit": 20,
|
|
|
}
|
|
|
if param.PageSize > 0 {
|
|
|
condition["limit"] = param.PageSize
|
|
|
}
|
|
|
offset := (param.PageNumber - 1) * param.PageSize
|
|
|
if offset > 0 {
|
|
|
condition["offset"] = offset
|
|
|
}
|
|
|
|
|
|
cnt, assessList, err := assessRepo.Find(condition)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
var assessContentList []*domain.StaffAssessContent
|
|
|
if len(assessList) > 0 {
|
|
|
//获取评估用的所有评估项
|
|
|
assessContentList, err = srv.getAssessSelfInfoUncompleted(transactionContext, assessList[0])
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取评估任务"+err.Error())
|
|
|
}
|
|
|
}
|
|
|
//可变的表格列
|
|
|
changeableHeader := []adapter.ListTableHeader{}
|
|
|
//列名与字段对应
|
|
|
keyMap := map[string]string{}
|
|
|
for i, v := range assessContentList {
|
|
|
name := fmt.Sprintf("%s-%s", v.Category, v.Name)
|
|
|
key := fmt.Sprintf("k%d", i)
|
|
|
keyMap[name] = key
|
|
|
changeableHeader = append(changeableHeader, adapter.ListTableHeader{
|
|
|
Key: key,
|
|
|
Name: name,
|
|
|
})
|
|
|
}
|
|
|
assessContentRepo := factory.CreateStaffAssessContentRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
// 获取已经填报的内容
|
|
|
changeableRows := map[int]map[string]string{}
|
|
|
for _, v := range assessList {
|
|
|
_, contentList, err := assessContentRepo.Find(map[string]interface{}{
|
|
|
"staffAssessId": v.Id,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取评估内容"+err.Error())
|
|
|
}
|
|
|
row := map[string]string{}
|
|
|
for _, vv := range contentList {
|
|
|
name := fmt.Sprintf("%s-%s", vv.Category, vv.Name)
|
|
|
if kk, ok := keyMap[name]; ok {
|
|
|
row[kk] = vv.Value
|
|
|
}
|
|
|
}
|
|
|
changeableRows[v.TargetUser.UserId] = row
|
|
|
}
|
|
|
|
|
|
//获取360邀请评估完成情况
|
|
|
//我评估别人,被邀请评估
|
|
|
cnnt, _, err := assessRepo.Find(map[string]interface{}{
|
|
|
"staffAssessTaskId": param.AssessTaskId,
|
|
|
"executorId": param.ExecutorId,
|
|
|
"typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
|
|
|
"status": domain.StaffAssessUncompleted,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error())
|
|
|
}
|
|
|
|
|
|
assessTaskData, err := assessTaskRepo.FindOne(map[string]interface{}{
|
|
|
"id": param.AssessTaskId,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取评估任务"+err.Error())
|
|
|
}
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
//评估填写数据行转列
|
|
|
tableHeader := []adapter.ListTableHeader{
|
|
|
{Key: "userName", Name: "姓名"},
|
|
|
{Key: "status", Name: "状态"},
|
|
|
{Key: "types", Name: "360°评估关系"},
|
|
|
{Key: "endTime", Name: "360°评估截止日期"},
|
|
|
}
|
|
|
tableHeader = append(tableHeader, changeableHeader...)
|
|
|
listData := []map[string]string{}
|
|
|
for _, v := range assessList {
|
|
|
m := map[string]string{
|
|
|
"userName": v.TargetUser.UserName,
|
|
|
"userId": strconv.Itoa(v.TargetUser.UserId),
|
|
|
"status": string(v.Status),
|
|
|
"types": string(v.Types),
|
|
|
"endTime": v.EndTime.Local().Format("2006-01-02 15:04:05"),
|
|
|
"assessId": strconv.Itoa(v.Id),
|
|
|
}
|
|
|
if row, ok := changeableRows[v.TargetUser.UserId]; ok {
|
|
|
for k, v := range row {
|
|
|
m[k] = v
|
|
|
}
|
|
|
} else {
|
|
|
for _, v := range changeableHeader {
|
|
|
m[v.Key] = ""
|
|
|
}
|
|
|
}
|
|
|
listData = append(listData, m)
|
|
|
}
|
|
|
result := adapter.ListInviteUserAssessResp{
|
|
|
TableHeader: tableHeader,
|
|
|
List: listData,
|
|
|
Total: cnt,
|
|
|
}
|
|
|
for _, v := range assessTaskData.StepList {
|
|
|
if v.LinkNodeType == domain.LinkNodeAllAssessment {
|
|
|
result.LinkNodeId = v.LinkNodeId
|
|
|
result.LinkNodeName = v.LinkNodeName
|
|
|
result.LintNodeDesc = fmt.Sprintf("截止时间 %s 待评估%d人", v.EndTime.Local().Format("2006-01-02 15:04:05"), cnnt)
|
|
|
}
|
|
|
}
|
|
|
return &result, nil
|
|
|
}
|
|
|
|
|
|
// 获取我需要执行的上级评估成员列表
|
|
|
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())
|
|
|
}
|
|
|
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,
|
|
|
})
|
|
|
|
|
|
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())
|
|
|
}
|
|
|
|
|
|
resultList := []adapter.ListSupperAssessResp{}
|
|
|
for _, v := range assessList {
|
|
|
item := adapter.ListSupperAssessResp{
|
|
|
AssessId: v.Id,
|
|
|
UsrId: v.TargetUser.UserId,
|
|
|
UserName: v.TargetUser.UserName,
|
|
|
EndTime: v.EndTime.Local().Format("2006-01-02 15:04:05"),
|
|
|
InviteCompleted: 0,
|
|
|
Status: string(v.Status),
|
|
|
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
|
|
|
}
|
|
|
|
|
|
// 根据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())
|
|
|
}
|
|
|
}
|
|
|
|
|
|
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())
|
|
|
}
|
|
|
|
|
|
result := adapter.AssessInfoResp{
|
|
|
AssessId: assessData.Id,
|
|
|
CycleId: assessData.CycleId,
|
|
|
CycleName: assessData.CycleName,
|
|
|
LinkNodeId: assessData.LinkNodeId,
|
|
|
LinkNodeName: assessData.LinkNodeName,
|
|
|
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,
|
|
|
CompanyId: assessData.CompanyId,
|
|
|
CompanyName: "",
|
|
|
SupperUser: "",
|
|
|
DutyTime: "",
|
|
|
AssessContent: assessContentList,
|
|
|
}
|
|
|
if len(assessContentList) == 0 {
|
|
|
result.AssessContent = []*domain.StaffAssessContent{}
|
|
|
}
|
|
|
if targetUserDesc != nil {
|
|
|
result.CompanyName = targetUserDesc.CompanyName
|
|
|
result.SupperUser = targetUserDesc.SupperUserName
|
|
|
result.DutyTime = targetUserDesc.DutyTime
|
|
|
}
|
|
|
return &result, 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
|
|
|
}
|
|
|
|
|
|
// 获取员工被评估的列表
|
|
|
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
|
|
|
} |
...
|
...
|
|