...
|
...
|
@@ -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())
|
...
|
...
|
@@ -341,7 +341,9 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(param *command.CreateStaffA |
|
|
defer func() {
|
|
|
_ = transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
|
|
|
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)
|
...
|
...
|
@@ -351,8 +353,22 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(param *command.CreateStaffA |
|
|
return nil, application.ThrowError(application.ARG_ERROR, "任务结束时间填写错误,"+param.EndTime)
|
|
|
}
|
|
|
nowTime := time.Now()
|
|
|
var assessTaskData *domain.StaffAssessTask
|
|
|
_, assassessTaskList, err := assessTaskRepo.Find(map[string]interface{}{
|
|
|
"evaluationProjectId": param.EvaluationProjectId,
|
|
|
"beginDay": taskBeginTime.Local().Format("2006-01-02"),
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询同日期已存在评估任务"+err.Error())
|
|
|
}
|
|
|
// 获取旧数据
|
|
|
|
|
|
if len(assassessTaskList) > 0 {
|
|
|
assessTaskData = assassessTaskList[0]
|
|
|
assessTaskData.UpdatedAt = nowTime
|
|
|
} else {
|
|
|
//建立评估任务
|
|
|
assessTask := domain.StaffAssessTask{
|
|
|
assessTaskData = &domain.StaffAssessTask{
|
|
|
Id: 0,
|
|
|
CompanyId: param.CompanyId,
|
|
|
EvaluationProjectId: param.EvaluationProjectId,
|
...
|
...
|
@@ -367,8 +383,15 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(param *command.CreateStaffA |
|
|
UpdatedAt: nowTime,
|
|
|
DeletedAt: nil,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//填充评估环节
|
|
|
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 +408,56 @@ 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,
|
|
|
})
|
|
|
_, err = assessTaskRepo.Save(&assessTask)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存评估任务"+err.Error())
|
|
|
}
|
|
|
|
|
|
assessList, err := srv.createStaffAssess(transactionContext, &assessTask)
|
|
|
assessList, err := srv.createStaffAssess(transactionContext, assessTaskData)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "生成个人评估项"+err.Error())
|
|
|
}
|
|
|
|
|
|
//评估的参与人
|
|
|
executorIds := []int{}
|
|
|
executorIdMap := map[int]struct{}{} //过滤重复的用户
|
|
|
for _, v := range param.ExecutorId {
|
|
|
if _, ok := executorIdMap[v]; ok {
|
|
|
continue
|
|
|
}
|
|
|
executorIds = append(executorIds, v)
|
|
|
}
|
|
|
//过滤就数据
|
|
|
for _, v := range assessTaskData.ExecutorId {
|
|
|
if _, ok := executorIdMap[v]; ok {
|
|
|
continue
|
|
|
}
|
|
|
executorIds = append(executorIds, v)
|
|
|
}
|
|
|
assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
assessTaskData.ExecutorId = executorIds
|
|
|
_, err = assessTaskRepo.Save(assessTaskData)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存评估任务"+err.Error())
|
|
|
}
|
|
|
|
|
|
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())
|
|
|
}
|
|
|
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{}
|
...
|
...
|
@@ -540,13 +578,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 {
|
...
|
...
|
@@ -877,14 +951,18 @@ 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,
|
|
|
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"),
|
...
|
...
|
@@ -892,8 +970,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,14 +1085,15 @@ func (srv StaffAssessServeice) SelectAssessInviteUser(param *query.SelectAssessI |
|
|
departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
|
|
|
_, targetUserDepartment, err := departmentRepo.Find(map[string]interface{}{
|
|
|
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 {
|
...
|
...
|
@@ -1060,8 +1148,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 {
|
...
|
...
|
@@ -1077,49 +1165,140 @@ func (srv StaffAssessServeice) ListInviteUserAssess(param *query.ListInviteUserA |
|
|
assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
assessTaskRepo := factory.CreateStaffAssessTaskRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
|
|
|
//获取 executorId 对应的360评估任务 用户
|
|
|
cnt, assessList, err := assessRepo.Find(map[string]interface{}{
|
|
|
"staffAssessTaskId": param.AssessTaskkId,
|
|
|
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())
|
|
|
}
|
|
|
|
|
|
//TODO 评估填写数据行转列
|
|
|
//评估填写数据行转列
|
|
|
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)
|
|
|
}
|
|
|
_ = tableHeader
|
|
|
|
|
|
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) 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 +1313,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())
|
|
|
}
|
...
|
...
|
@@ -1151,18 +1385,40 @@ func (srv StaffAssessServeice) ListSupperAssess(param *query.ListSupperAssessQue |
|
|
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"),
|
|
|
InviteUncompleted: 0,
|
|
|
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
|
...
|
...
|
@@ -1214,6 +1470,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())
|
|
|
}
|
...
|
...
|
@@ -1222,6 +1483,8 @@ func (srv StaffAssessServeice) GetAssessInfo(param *query.AssessInfoQuery) (*ada |
|
|
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"),
|
...
|
...
|
@@ -1229,13 +1492,192 @@ 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 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
|
|
|
}
|
|
|
|
|
|
// 获取员工的某次评估任务的360评估记录录
|
|
|
// assessTaskId targetUserId
|
|
|
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
|
|
|
}
|
|
|
|
|
|
// 获取员工被评估的列表
|
|
|
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
|
|
|
} |
...
|
...
|
|