...
|
...
|
@@ -2,7 +2,6 @@ package service |
|
|
|
|
|
import (
|
|
|
"fmt"
|
|
|
"sort"
|
|
|
"strconv"
|
|
|
"time"
|
|
|
|
...
|
...
|
@@ -12,7 +11,6 @@ import ( |
|
|
"github.com/linmadan/egglib-go/core/application"
|
|
|
"github.com/linmadan/egglib-go/utils/tool_funs"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/notify"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/adapter"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/command"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/query"
|
...
|
...
|
@@ -135,342 +133,342 @@ func (srv StaffAssessServeice) AssessSelfList(param *query.AssessSelfListQuery) |
|
|
}
|
|
|
|
|
|
// 根据项目评估的配置,创建员工的评估任务
|
|
|
func (srv StaffAssessServeice) CreateStaffAssessTask(transactionContext application.TransactionContext, param *command.CreateStaffAssessTask) (map[string]interface{}, error) {
|
|
|
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)
|
|
|
}
|
|
|
taskEndTime, err := time.ParseInLocation("2006-01-02 15:04:05", param.EndTime, time.Local)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.ARG_ERROR, "任务结束时间填写错误,"+param.EndTime)
|
|
|
}
|
|
|
nowTime := time.Now()
|
|
|
|
|
|
assessTaskData := &domain.StaffAssessTask{
|
|
|
Id: 0,
|
|
|
CompanyId: param.CompanyId,
|
|
|
EvaluationProjectId: param.EvaluationProjectId,
|
|
|
EvaluationProjectName: param.EvaluationProjectName,
|
|
|
CycleId: param.CycleId,
|
|
|
CycleName: param.CycleName,
|
|
|
BeginTime: taskBeginTime,
|
|
|
EndTime: taskEndTime,
|
|
|
StepList: []domain.AssessTaskStep{},
|
|
|
ExecutorId: []int{},
|
|
|
CreatedAt: nowTime,
|
|
|
UpdatedAt: nowTime,
|
|
|
DeletedAt: nil,
|
|
|
BeginDay: taskBeginTime.Local().Format("2006-01-02"),
|
|
|
}
|
|
|
executorIds := []int{} //提取评估的参与人id
|
|
|
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
|
|
|
for _, v := range param.StepList {
|
|
|
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)
|
|
|
}
|
|
|
stepEndTime, err := time.ParseInLocation("2006-01-02 15:04:05", param.EndTime, time.Local)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.ARG_ERROR, "评估环节结束时间填写错误,"+param.EndTime)
|
|
|
}
|
|
|
step := domain.AssessTaskStep{
|
|
|
SortBy: v.SortBy,
|
|
|
LinkNodeId: v.LinkNodeId,
|
|
|
LinkNodeName: v.LinkNodeName,
|
|
|
LinkNodeType: v.LinkNodeType,
|
|
|
BeginTime: stepBeginTime,
|
|
|
EndTime: stepEndTime,
|
|
|
}
|
|
|
assessTaskData.StepList = append(assessTaskData.StepList, step)
|
|
|
}
|
|
|
//添加员工的节点任务
|
|
|
assessList, err := srv.createStaffAssess(transactionContext, assessTaskData)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "生成个人评估项"+err.Error())
|
|
|
}
|
|
|
// func (srv StaffAssessServeice) CreateStaffAssessTask(transactionContext application.TransactionContext, param *command.CreateStaffAssessTask) (map[string]interface{}, error) {
|
|
|
// 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)
|
|
|
// }
|
|
|
// taskEndTime, err := time.ParseInLocation("2006-01-02 15:04:05", param.EndTime, time.Local)
|
|
|
// if err != nil {
|
|
|
// return nil, application.ThrowError(application.ARG_ERROR, "任务结束时间填写错误,"+param.EndTime)
|
|
|
// }
|
|
|
// nowTime := time.Now()
|
|
|
|
|
|
// assessTaskData := &domain.StaffAssessTask{
|
|
|
// Id: 0,
|
|
|
// CompanyId: param.CompanyId,
|
|
|
// EvaluationProjectId: param.EvaluationProjectId,
|
|
|
// EvaluationProjectName: param.EvaluationProjectName,
|
|
|
// CycleId: param.CycleId,
|
|
|
// CycleName: param.CycleName,
|
|
|
// BeginTime: taskBeginTime,
|
|
|
// EndTime: taskEndTime,
|
|
|
// StepList: []domain.AssessTaskStep{},
|
|
|
// ExecutorId: []int{},
|
|
|
// CreatedAt: nowTime,
|
|
|
// UpdatedAt: nowTime,
|
|
|
// DeletedAt: nil,
|
|
|
// BeginDay: taskBeginTime.Local().Format("2006-01-02"),
|
|
|
// }
|
|
|
// executorIds := []int{} //提取评估的参与人id
|
|
|
// 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
|
|
|
// for _, v := range param.StepList {
|
|
|
// 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)
|
|
|
// }
|
|
|
// stepEndTime, err := time.ParseInLocation("2006-01-02 15:04:05", param.EndTime, time.Local)
|
|
|
// if err != nil {
|
|
|
// return nil, application.ThrowError(application.ARG_ERROR, "评估环节结束时间填写错误,"+param.EndTime)
|
|
|
// }
|
|
|
// step := domain.AssessTaskStep{
|
|
|
// SortBy: v.SortBy,
|
|
|
// LinkNodeId: v.LinkNodeId,
|
|
|
// LinkNodeName: v.LinkNodeName,
|
|
|
// LinkNodeType: v.LinkNodeType,
|
|
|
// BeginTime: stepBeginTime,
|
|
|
// EndTime: stepEndTime,
|
|
|
// }
|
|
|
// assessTaskData.StepList = append(assessTaskData.StepList, step)
|
|
|
// }
|
|
|
// //添加员工的节点任务
|
|
|
// assessList, err := srv.createStaffAssess(transactionContext, assessTaskData)
|
|
|
// if err != nil {
|
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "生成个人评估项"+err.Error())
|
|
|
// }
|
|
|
|
|
|
//合并项目评估的新旧数据
|
|
|
_, 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())
|
|
|
}
|
|
|
// //合并项目评估的新旧数据
|
|
|
// _, 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 {
|
|
|
//就数据中提取参与人
|
|
|
for _, v := range assessTaskData.ExecutorId {
|
|
|
if _, ok := executorIdMap[v]; ok {
|
|
|
continue
|
|
|
}
|
|
|
executorIdMap[v] = struct{}{}
|
|
|
executorIds = append(executorIds, v)
|
|
|
}
|
|
|
assassessTaskList[0].UpdatedAt = time.Now()
|
|
|
assassessTaskList[0].ExecutorId = executorIds
|
|
|
//更新步骤
|
|
|
assassessTaskList[0].StepList = append(assassessTaskList[0].StepList, assessTaskData.StepList...)
|
|
|
for _, val := range assessTaskData.StepList {
|
|
|
hasFound := false
|
|
|
for _, val2 := range assassessTaskList[0].StepList {
|
|
|
if val.LinkNodeType == val2.LinkNodeType {
|
|
|
hasFound = true
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
if !hasFound {
|
|
|
assassessTaskList[0].StepList = append(assassessTaskList[0].StepList, val)
|
|
|
}
|
|
|
}
|
|
|
assessTaskData = assassessTaskList[0]
|
|
|
//排序流程环节
|
|
|
}
|
|
|
stepList := domain.SortTaskStep(assessTaskData.StepList)
|
|
|
sort.Sort(stepList)
|
|
|
_, err = assessTaskRepo.Save(assessTaskData)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存评估任务"+err.Error())
|
|
|
}
|
|
|
// if len(assassessTaskList) > 0 {
|
|
|
// //就数据中提取参与人
|
|
|
// for _, v := range assessTaskData.ExecutorId {
|
|
|
// if _, ok := executorIdMap[v]; ok {
|
|
|
// continue
|
|
|
// }
|
|
|
// executorIdMap[v] = struct{}{}
|
|
|
// executorIds = append(executorIds, v)
|
|
|
// }
|
|
|
// assassessTaskList[0].UpdatedAt = time.Now()
|
|
|
// assassessTaskList[0].ExecutorId = executorIds
|
|
|
// //更新步骤
|
|
|
// assassessTaskList[0].StepList = append(assassessTaskList[0].StepList, assessTaskData.StepList...)
|
|
|
// for _, val := range assessTaskData.StepList {
|
|
|
// hasFound := false
|
|
|
// for _, val2 := range assassessTaskList[0].StepList {
|
|
|
// if val.LinkNodeType == val2.LinkNodeType {
|
|
|
// hasFound = true
|
|
|
// break
|
|
|
// }
|
|
|
// }
|
|
|
// if !hasFound {
|
|
|
// assassessTaskList[0].StepList = append(assassessTaskList[0].StepList, val)
|
|
|
// }
|
|
|
// }
|
|
|
// assessTaskData = assassessTaskList[0]
|
|
|
// //排序流程环节
|
|
|
// }
|
|
|
// stepList := domain.SortTaskStep(assessTaskData.StepList)
|
|
|
// sort.Sort(stepList)
|
|
|
// _, err = assessTaskRepo.Save(assessTaskData)
|
|
|
// if err != nil {
|
|
|
// 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 assessList[i].Types == domain.AssessSelf {
|
|
|
//添加待发送的短信通知
|
|
|
notify.AddNotifyStaffAssess(&assessList[i])
|
|
|
}
|
|
|
}
|
|
|
return map[string]interface{}{
|
|
|
"assessTaskId": assessTaskData.Id,
|
|
|
}, nil
|
|
|
}
|
|
|
// //保存 员工的评估任务
|
|
|
// 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 assessList[i].Types == domain.AssessSelf {
|
|
|
// //添加待发送的短信通知
|
|
|
// notify.AddNotifyStaffAssess(&assessList[i])
|
|
|
// }
|
|
|
// }
|
|
|
// return map[string]interface{}{
|
|
|
// "assessTaskId": assessTaskData.Id,
|
|
|
// }, nil
|
|
|
// }
|
|
|
|
|
|
// 添加节点任务
|
|
|
func (srv StaffAssessServeice) createStaffAssess(transactionContext application.TransactionContext, param *domain.StaffAssessTask) ([]domain.StaffAssess, error) {
|
|
|
selfUserId := []int{} //评估的参与人
|
|
|
userIdMap := map[int]struct{}{} //过滤重复的用户
|
|
|
for _, v := range param.ExecutorId {
|
|
|
if _, ok := userIdMap[v]; ok {
|
|
|
continue
|
|
|
}
|
|
|
selfUserId = append(selfUserId, v)
|
|
|
}
|
|
|
// 获取用户的信息
|
|
|
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{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
//获取员工信息
|
|
|
_, userList, err := userRepo.Find(map[string]interface{}{
|
|
|
"ids": selfUserId,
|
|
|
"status": 1,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.ARG_ERROR, "获取员工信息"+err.Error())
|
|
|
}
|
|
|
departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
//获取用户的部门
|
|
|
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,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.ARG_ERROR, "获取员工的部门信息"+err.Error())
|
|
|
}
|
|
|
userDepartmentMap[v.Id] = departmemtList
|
|
|
}
|
|
|
assessList := []domain.StaffAssess{}
|
|
|
//数据样板
|
|
|
stepSelfTemp := domain.StaffAssess{
|
|
|
Id: 0,
|
|
|
CompanyId: param.CompanyId,
|
|
|
EvaluationProjectId: param.EvaluationProjectId,
|
|
|
EvaluationProjectName: param.EvaluationProjectName,
|
|
|
CycleId: param.CycleId,
|
|
|
CycleName: param.CycleName,
|
|
|
StaffAssessTaskId: param.Id,
|
|
|
// TargetUser: domain.StaffDesc{},
|
|
|
// TargetDepartment: nil,
|
|
|
// Executor: domain.StaffDesc{},
|
|
|
Types: "",
|
|
|
// LinkNodeId: v.LinkNodeId,
|
|
|
Status: domain.StaffAssessUncompleted,
|
|
|
// BeginTime: time.Time{},
|
|
|
// EndTime: time.Time{},
|
|
|
CreatedAt: param.CreatedAt,
|
|
|
UpdatedAt: param.UpdatedAt,
|
|
|
DeletedAt: nil,
|
|
|
}
|
|
|
for _, v := range param.StepList {
|
|
|
if v.LinkNodeType == domain.LinkNodeSelfAssessment {
|
|
|
//员工自评
|
|
|
stepSelfTemp.BeginTime = v.BeginTime
|
|
|
stepSelfTemp.EndTime = v.EndTime
|
|
|
stepSelfTemp.LinkNodeId = v.LinkNodeId
|
|
|
stepSelfTemp.LinkNodeName = v.LinkNodeName
|
|
|
stepSelfTemp.Types = domain.AssessSelf
|
|
|
assessListTemp, err := srv.createStaffAssessSelf(transactionContext, stepSelfTemp, userList, userDepartmentMap)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
assessList = append(assessList, assessListTemp...)
|
|
|
}
|
|
|
if v.LinkNodeType == domain.LinkNodeSuperiorAssessment {
|
|
|
// 创建上级评估
|
|
|
stepSelfTemp.BeginTime = v.BeginTime
|
|
|
stepSelfTemp.EndTime = v.EndTime
|
|
|
stepSelfTemp.LinkNodeId = v.LinkNodeId
|
|
|
stepSelfTemp.LinkNodeName = v.LinkNodeName
|
|
|
stepSelfTemp.Types = domain.AssessSuper
|
|
|
assessListTemp2, err := srv.createStaffAssessSupper(transactionContext, stepSelfTemp, userList, userDepartmentMap)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
assessList = append(assessList, assessListTemp2...)
|
|
|
}
|
|
|
}
|
|
|
return assessList, nil
|
|
|
}
|
|
|
// func (srv StaffAssessServeice) createStaffAssess(transactionContext application.TransactionContext, param *domain.StaffAssessTask) ([]domain.StaffAssess, error) {
|
|
|
// selfUserId := []int{} //评估的参与人
|
|
|
// userIdMap := map[int]struct{}{} //过滤重复的用户
|
|
|
// for _, v := range param.ExecutorId {
|
|
|
// if _, ok := userIdMap[v]; ok {
|
|
|
// continue
|
|
|
// }
|
|
|
// selfUserId = append(selfUserId, v)
|
|
|
// }
|
|
|
// // 获取用户的信息
|
|
|
// 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{}{
|
|
|
// "transactionContext": transactionContext,
|
|
|
// })
|
|
|
// //获取员工信息
|
|
|
// _, userList, err := userRepo.Find(map[string]interface{}{
|
|
|
// "ids": selfUserId,
|
|
|
// "status": 1,
|
|
|
// })
|
|
|
// if err != nil {
|
|
|
// return nil, application.ThrowError(application.ARG_ERROR, "获取员工信息"+err.Error())
|
|
|
// }
|
|
|
// departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{
|
|
|
// "transactionContext": transactionContext,
|
|
|
// })
|
|
|
// //获取用户的部门
|
|
|
// 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,
|
|
|
// })
|
|
|
// if err != nil {
|
|
|
// return nil, application.ThrowError(application.ARG_ERROR, "获取员工的部门信息"+err.Error())
|
|
|
// }
|
|
|
// userDepartmentMap[v.Id] = departmemtList
|
|
|
// }
|
|
|
// assessList := []domain.StaffAssess{}
|
|
|
// //数据样板
|
|
|
// stepSelfTemp := domain.StaffAssess{
|
|
|
// Id: 0,
|
|
|
// CompanyId: param.CompanyId,
|
|
|
// EvaluationProjectId: param.EvaluationProjectId,
|
|
|
// EvaluationProjectName: param.EvaluationProjectName,
|
|
|
// CycleId: param.CycleId,
|
|
|
// CycleName: param.CycleName,
|
|
|
// StaffAssessTaskId: param.Id,
|
|
|
// // TargetUser: domain.StaffDesc{},
|
|
|
// // TargetDepartment: nil,
|
|
|
// // Executor: domain.StaffDesc{},
|
|
|
// Types: "",
|
|
|
// // LinkNodeId: v.LinkNodeId,
|
|
|
// Status: domain.StaffAssessUncompleted,
|
|
|
// // BeginTime: time.Time{},
|
|
|
// // EndTime: time.Time{},
|
|
|
// CreatedAt: param.CreatedAt,
|
|
|
// UpdatedAt: param.UpdatedAt,
|
|
|
// DeletedAt: nil,
|
|
|
// }
|
|
|
// for _, v := range param.StepList {
|
|
|
// if v.LinkNodeType == domain.LinkNodeSelfAssessment {
|
|
|
// //员工自评
|
|
|
// stepSelfTemp.BeginTime = v.BeginTime
|
|
|
// stepSelfTemp.EndTime = v.EndTime
|
|
|
// stepSelfTemp.LinkNodeId = v.LinkNodeId
|
|
|
// stepSelfTemp.LinkNodeName = v.LinkNodeName
|
|
|
// stepSelfTemp.Types = domain.AssessSelf
|
|
|
// assessListTemp, err := srv.createStaffAssessSelf(transactionContext, stepSelfTemp, userList, userDepartmentMap)
|
|
|
// if err != nil {
|
|
|
// return nil, err
|
|
|
// }
|
|
|
// assessList = append(assessList, assessListTemp...)
|
|
|
// }
|
|
|
// if v.LinkNodeType == domain.LinkNodeSuperiorAssessment {
|
|
|
// // 创建上级评估
|
|
|
// stepSelfTemp.BeginTime = v.BeginTime
|
|
|
// stepSelfTemp.EndTime = v.EndTime
|
|
|
// stepSelfTemp.LinkNodeId = v.LinkNodeId
|
|
|
// stepSelfTemp.LinkNodeName = v.LinkNodeName
|
|
|
// stepSelfTemp.Types = domain.AssessSuper
|
|
|
// assessListTemp2, err := srv.createStaffAssessSupper(transactionContext, stepSelfTemp, userList, userDepartmentMap)
|
|
|
// if err != nil {
|
|
|
// return nil, err
|
|
|
// }
|
|
|
// assessList = append(assessList, assessListTemp2...)
|
|
|
// }
|
|
|
// }
|
|
|
// return assessList, nil
|
|
|
// }
|
|
|
|
|
|
// 构建员工自评
|
|
|
func (srv StaffAssessServeice) createStaffAssessSelf(
|
|
|
transactionContext application.TransactionContext,
|
|
|
assessTemp domain.StaffAssess,
|
|
|
userList []*domain.User,
|
|
|
userDepartmentMap map[int64][]*domain.Department) ([]domain.StaffAssess, error) {
|
|
|
assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
beginDay := assessTemp.BeginTime.Local().Format("2006-01-02")
|
|
|
_, assessListOld, err := assessRepo.Find(map[string]interface{}{"cycleId": assessTemp.CycleId, "beginDay": beginDay, "types": domain.AssessSelf})
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
userMapReal := map[int]*domain.User{}
|
|
|
for _, val := range userList {
|
|
|
userMapReal[int(val.Id)] = val
|
|
|
}
|
|
|
for _, val := range assessListOld {
|
|
|
delete(userMapReal, val.TargetUser.UserId)
|
|
|
}
|
|
|
assessListNew := []domain.StaffAssess{}
|
|
|
for _, usr := range userMapReal {
|
|
|
assessTemp.TargetUser = domain.StaffDesc{
|
|
|
UserId: int(usr.Id),
|
|
|
Account: usr.Account,
|
|
|
UserName: usr.Name,
|
|
|
}
|
|
|
assessTemp.Executor = domain.StaffDesc{
|
|
|
UserId: int(usr.Id),
|
|
|
Account: usr.Account,
|
|
|
UserName: usr.Name,
|
|
|
}
|
|
|
if depList, ok := userDepartmentMap[usr.Id]; ok {
|
|
|
for _, dep := range depList {
|
|
|
assessTemp.TargetDepartment = append(assessTemp.TargetDepartment, domain.StaffDepartment{
|
|
|
DepartmentId: int(dep.Id),
|
|
|
DepartmentName: dep.Name,
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
assessListNew = append(assessListNew, assessTemp)
|
|
|
}
|
|
|
return assessListNew, nil
|
|
|
}
|
|
|
// func (srv StaffAssessServeice) createStaffAssessSelf(
|
|
|
// transactionContext application.TransactionContext,
|
|
|
// assessTemp domain.StaffAssess,
|
|
|
// userList []*domain.User,
|
|
|
// userDepartmentMap map[int64][]*domain.Department) ([]domain.StaffAssess, error) {
|
|
|
// assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
|
|
|
// "transactionContext": transactionContext,
|
|
|
// })
|
|
|
// beginDay := assessTemp.BeginTime.Local().Format("2006-01-02")
|
|
|
// _, assessListOld, err := assessRepo.Find(map[string]interface{}{"cycleId": assessTemp.CycleId, "beginDay": beginDay, "types": domain.AssessSelf})
|
|
|
// if err != nil {
|
|
|
// return nil, err
|
|
|
// }
|
|
|
// userMapReal := map[int]*domain.User{}
|
|
|
// for _, val := range userList {
|
|
|
// userMapReal[int(val.Id)] = val
|
|
|
// }
|
|
|
// for _, val := range assessListOld {
|
|
|
// delete(userMapReal, val.TargetUser.UserId)
|
|
|
// }
|
|
|
// assessListNew := []domain.StaffAssess{}
|
|
|
// for _, usr := range userMapReal {
|
|
|
// assessTemp.TargetUser = domain.StaffDesc{
|
|
|
// UserId: int(usr.Id),
|
|
|
// Account: usr.Account,
|
|
|
// UserName: usr.Name,
|
|
|
// }
|
|
|
// assessTemp.Executor = domain.StaffDesc{
|
|
|
// UserId: int(usr.Id),
|
|
|
// Account: usr.Account,
|
|
|
// UserName: usr.Name,
|
|
|
// }
|
|
|
// if depList, ok := userDepartmentMap[usr.Id]; ok {
|
|
|
// for _, dep := range depList {
|
|
|
// assessTemp.TargetDepartment = append(assessTemp.TargetDepartment, domain.StaffDepartment{
|
|
|
// DepartmentId: int(dep.Id),
|
|
|
// DepartmentName: dep.Name,
|
|
|
// })
|
|
|
// }
|
|
|
// }
|
|
|
// assessListNew = append(assessListNew, assessTemp)
|
|
|
// }
|
|
|
// return assessListNew, nil
|
|
|
// }
|
|
|
|
|
|
// 构建员工的上级评估
|
|
|
func (srv StaffAssessServeice) createStaffAssessSupper(
|
|
|
transactionContext application.TransactionContext,
|
|
|
assessTemp domain.StaffAssess,
|
|
|
userList []*domain.User, userDepartmentMap map[int64][]*domain.Department,
|
|
|
) ([]domain.StaffAssess, error) {
|
|
|
assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
beginDay := assessTemp.BeginTime.Local().Format("2006-01-02")
|
|
|
_, assessListOld, err := assessRepo.Find(map[string]interface{}{"cycleId": assessTemp.CycleId, "beginDay": beginDay, "types": domain.AssessSuper})
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
userMapReal := map[int]*domain.User{}
|
|
|
for _, val := range userList {
|
|
|
userMapReal[int(val.Id)] = val
|
|
|
}
|
|
|
for _, val := range assessListOld {
|
|
|
delete(userMapReal, val.TargetUser.UserId)
|
|
|
}
|
|
|
// func (srv StaffAssessServeice) createStaffAssessSupper(
|
|
|
// transactionContext application.TransactionContext,
|
|
|
// assessTemp domain.StaffAssess,
|
|
|
// userList []*domain.User, userDepartmentMap map[int64][]*domain.Department,
|
|
|
// ) ([]domain.StaffAssess, error) {
|
|
|
// assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
|
|
|
// "transactionContext": transactionContext,
|
|
|
// })
|
|
|
// beginDay := assessTemp.BeginTime.Local().Format("2006-01-02")
|
|
|
// _, assessListOld, err := assessRepo.Find(map[string]interface{}{"cycleId": assessTemp.CycleId, "beginDay": beginDay, "types": domain.AssessSuper})
|
|
|
// if err != nil {
|
|
|
// return nil, err
|
|
|
// }
|
|
|
// userMapReal := map[int]*domain.User{}
|
|
|
// for _, val := range userList {
|
|
|
// userMapReal[int(val.Id)] = val
|
|
|
// }
|
|
|
// for _, val := range assessListOld {
|
|
|
// delete(userMapReal, val.TargetUser.UserId)
|
|
|
// }
|
|
|
|
|
|
var assessListNew []domain.StaffAssess
|
|
|
for _, v := range userMapReal {
|
|
|
//获取上级
|
|
|
chargeUserList, err := srv.getStaffSuper(transactionContext, *v)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
if len(chargeUserList) == 0 {
|
|
|
continue
|
|
|
}
|
|
|
for _, v2 := range chargeUserList {
|
|
|
assessTemp.TargetUser = domain.StaffDesc{
|
|
|
UserId: int(v.Id),
|
|
|
Account: v.Account,
|
|
|
UserName: v.Name,
|
|
|
}
|
|
|
assessTemp.Executor = domain.StaffDesc{
|
|
|
UserId: int(v2.Id),
|
|
|
Account: v2.Account,
|
|
|
UserName: v2.Name,
|
|
|
}
|
|
|
targetDepartment := []domain.StaffDepartment{}
|
|
|
if departmentList, ok := userDepartmentMap[v.Id]; ok {
|
|
|
for _, department := range departmentList {
|
|
|
targetDepartment = append(targetDepartment, domain.StaffDepartment{
|
|
|
DepartmentId: int(department.Id),
|
|
|
DepartmentName: department.Name,
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
assessTemp.TargetDepartment = targetDepartment
|
|
|
assessListNew = append(assessListNew, assessTemp)
|
|
|
}
|
|
|
// var assessListNew []domain.StaffAssess
|
|
|
// for _, v := range userMapReal {
|
|
|
// //获取上级
|
|
|
// chargeUserList, err := srv.getStaffSuper(transactionContext, *v)
|
|
|
// if err != nil {
|
|
|
// return nil, err
|
|
|
// }
|
|
|
// if len(chargeUserList) == 0 {
|
|
|
// continue
|
|
|
// }
|
|
|
// for _, v2 := range chargeUserList {
|
|
|
// assessTemp.TargetUser = domain.StaffDesc{
|
|
|
// UserId: int(v.Id),
|
|
|
// Account: v.Account,
|
|
|
// UserName: v.Name,
|
|
|
// }
|
|
|
// assessTemp.Executor = domain.StaffDesc{
|
|
|
// UserId: int(v2.Id),
|
|
|
// Account: v2.Account,
|
|
|
// UserName: v2.Name,
|
|
|
// }
|
|
|
// targetDepartment := []domain.StaffDepartment{}
|
|
|
// if departmentList, ok := userDepartmentMap[v.Id]; ok {
|
|
|
// for _, department := range departmentList {
|
|
|
// targetDepartment = append(targetDepartment, domain.StaffDepartment{
|
|
|
// DepartmentId: int(department.Id),
|
|
|
// DepartmentName: department.Name,
|
|
|
// })
|
|
|
// }
|
|
|
// }
|
|
|
// assessTemp.TargetDepartment = targetDepartment
|
|
|
// assessListNew = append(assessListNew, assessTemp)
|
|
|
// }
|
|
|
|
|
|
}
|
|
|
return assessListNew, nil
|
|
|
}
|
|
|
// }
|
|
|
// return assessListNew, nil
|
|
|
// }
|
|
|
|
|
|
// 获取某个员工360评估邀请的人员
|
|
|
// func (srv StaffAssessServeice) GetAssessInviteUser(param *query.GetAssessInviteUserQuery) (*adapter.AssessInviteUserResp, error) {
|
...
|
...
|
|