...
|
...
|
@@ -154,13 +154,14 @@ func (srv StaffAssessServeice) AssessTaskDesc(param *query.AssessTaskDescQuery) |
|
|
}
|
|
|
if len(assessInviteData) > 0 {
|
|
|
stepItem.Status = string(domain.StaffAssessCompleted)
|
|
|
} else {
|
|
|
stepItem.Status = string(domain.StaffAssessUncompleted)
|
|
|
}
|
|
|
//待邀请人数,为5人减去已邀请的人数。若邀请人数已等于或大于5人,则只显示截止日期即可
|
|
|
if len(assessInviteData) > 5 {
|
|
|
stepItem.Desc = fmt.Sprintf("截止日期:%s", stepItem.EndTime)
|
|
|
} else {
|
|
|
stepItem.Desc = fmt.Sprintf("截止日期:%s 待邀请%d人", stepItem.EndTime, 5-len(assessInviteData))
|
|
|
stepItem.Status = string(domain.StaffAssessUncompleted)
|
|
|
}
|
|
|
case domain.LinkNodeAllAssessment:
|
|
|
//我评估别人,被邀请评估
|
...
|
...
|
@@ -352,36 +353,21 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(transactionContext applicat |
|
|
}
|
|
|
nowTime := time.Now()
|
|
|
|
|
|
_, 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())
|
|
|
}
|
|
|
var assessTaskData *domain.StaffAssessTask
|
|
|
//更新旧数据或者新建数据
|
|
|
if len(assassessTaskList) > 0 {
|
|
|
assessTaskData = assassessTaskList[0]
|
|
|
assessTaskData.UpdatedAt = nowTime
|
|
|
} else {
|
|
|
//建立新的评估任务
|
|
|
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"),
|
|
|
}
|
|
|
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{}{} //过滤重复的用户
|
...
|
...
|
@@ -393,24 +379,8 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(transactionContext applicat |
|
|
executorIdMap[v] = struct{}{}
|
|
|
executorIds = append(executorIds, v)
|
|
|
}
|
|
|
//就数据中提取参与人
|
|
|
for _, v := range assessTaskData.ExecutorId {
|
|
|
if _, ok := executorIdMap[v]; ok {
|
|
|
continue
|
|
|
}
|
|
|
executorIdMap[v] = struct{}{}
|
|
|
executorIds = append(executorIds, v)
|
|
|
}
|
|
|
//填入新的参与人id
|
|
|
assessTaskData.ExecutorId = executorIds
|
|
|
//填充新的评估环节
|
|
|
loop:
|
|
|
for _, v := range param.StepList {
|
|
|
for _, vv := range assessTaskData.StepList {
|
|
|
if vv.LinkNodeId == v.LinkNodeId {
|
|
|
continue loop
|
|
|
}
|
|
|
}
|
|
|
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)
|
...
|
...
|
@@ -429,20 +399,45 @@ loop: |
|
|
}
|
|
|
assessTaskData.StepList = append(assessTaskData.StepList, step)
|
|
|
}
|
|
|
//排序流程环节
|
|
|
stepList := domain.SortTaskStep(assessTaskData.StepList)
|
|
|
sort.Sort(stepList)
|
|
|
assessTaskData.StepList = stepList
|
|
|
//添加员工的节点任务
|
|
|
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())
|
|
|
}
|
|
|
|
|
|
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...)
|
|
|
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,
|
|
|
})
|
...
|
...
|
@@ -453,6 +448,9 @@ loop: |
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存个人评估项"+err.Error())
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//处理生成的项目评估
|
|
|
|
|
|
return map[string]interface{}{
|
|
|
"assessTaskId": assessTaskData.Id,
|
|
|
}, nil
|
...
|
...
|
@@ -460,7 +458,6 @@ loop: |
|
|
|
|
|
// 添加节点任务
|
|
|
func (srv StaffAssessServeice) createStaffAssess(transactionContext application.TransactionContext, param *domain.StaffAssessTask) ([]domain.StaffAssess, error) {
|
|
|
|
|
|
selfUserId := []int{} //评估的参与人
|
|
|
userIdMap := map[int]struct{}{} //过滤重复的用户
|
|
|
for _, v := range param.ExecutorId {
|
...
|
...
|
@@ -588,44 +585,39 @@ func (srv StaffAssessServeice) createStaffAssessSupper( |
|
|
userList []*domain.User, userDepartmentMap map[int64][]*domain.Department,
|
|
|
) ([]domain.StaffAssess, error) {
|
|
|
var assessList []domain.StaffAssess
|
|
|
// 获取员工的上级用户
|
|
|
userRepo := factory.CreateUserRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
for _, v := range userList {
|
|
|
departmentList, ok := userDepartmentMap[v.Id]
|
|
|
if !ok {
|
|
|
//获取上级
|
|
|
chargeUserList, err := srv.getStaffSuper(transactionContext, *v)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
if len(chargeUserList) == 0 {
|
|
|
continue
|
|
|
}
|
|
|
for _, vv2 := range departmentList {
|
|
|
if len(vv2.ChargeUserIds) == 0 {
|
|
|
continue
|
|
|
for _, v2 := range chargeUserList {
|
|
|
assessTemp.TargetUser = domain.StaffDesc{
|
|
|
UserId: int(v.Id),
|
|
|
Account: v.Account,
|
|
|
UserName: v.Name,
|
|
|
}
|
|
|
//获取部门的主管
|
|
|
_, chargeUserList, err := userRepo.Find(map[string]interface{}{
|
|
|
"ids": vv2.ChargeUserIds,
|
|
|
"limit": 40,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.ARG_ERROR, "获取部门主管信息"+err.Error())
|
|
|
assessTemp.Executor = domain.StaffDesc{
|
|
|
UserId: int(v2.Id),
|
|
|
Account: v2.Account,
|
|
|
UserName: v2.Name,
|
|
|
}
|
|
|
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,
|
|
|
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.Executor = domain.StaffDesc{
|
|
|
UserId: int(vvv3.Id),
|
|
|
Account: vvv3.Account,
|
|
|
UserName: vvv3.Name,
|
|
|
}
|
|
|
assessList = append(assessList, assessTemp)
|
|
|
}
|
|
|
assessTemp.TargetDepartment = targetDepartment
|
|
|
assessList = append(assessList, assessTemp)
|
|
|
}
|
|
|
|
|
|
}
|
|
|
return assessList, nil
|
|
|
}
|
...
|
...
|
@@ -1592,36 +1584,37 @@ func (srv *StaffAssessServeice) getStaffDescrip(transactionContext application.T |
|
|
log.Logger.Error("获取公司信息," + err.Error())
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取公司信息,"+err.Error())
|
|
|
}
|
|
|
departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
// departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{
|
|
|
// "transactionContext": transactionContext,
|
|
|
// })
|
|
|
// //查找员工的部门
|
|
|
// var departmentList []*domain.Department
|
|
|
// if len(userData.DepartmentId) > 0 {
|
|
|
|
|
|
// }
|
|
|
|
|
|
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())
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
// 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())
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
supperUserList, _ := srv.getStaffSuper(transactionContext, *userData)
|
|
|
userInfo := adapter.StaffInfo{
|
|
|
UserName: userData.Name,
|
|
|
CompanyName: companyData.Name,
|
...
|
...
|
@@ -1703,12 +1696,14 @@ func (srv StaffAssessServeice) SaveAssessInfo(param *command.SaveAssessInfoComma |
|
|
continue
|
|
|
}
|
|
|
v.Value = item.Value
|
|
|
//填入评估值描述
|
|
|
reteResult, err := v.Rule.ScoreOrRating(&v.Value)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
if len(item.Value) > 0 {
|
|
|
//填入评估值描述
|
|
|
reteResult, err := v.Rule.ScoreOrRating(&v.Value)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
}
|
|
|
v.ReteResult = reteResult
|
|
|
}
|
|
|
v.ReteResult = reteResult
|
|
|
for ii := range v.Remark {
|
|
|
for _, vvv := range item.Remark {
|
|
|
if v.Remark[ii].Title == vvv.Title {
|
...
|
...
|
@@ -1719,7 +1714,6 @@ func (srv StaffAssessServeice) SaveAssessInfo(param *command.SaveAssessInfoComma |
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
//保存信息
|
|
|
for i := range assessContentList {
|
|
|
_, err = assessContentRepo.Save(assessContentList[i])
|
...
|
...
|
@@ -1774,7 +1768,7 @@ func (srv StaffAssessServeice) ListTargetUserAssess(param *query.ListTargetUserA |
|
|
}
|
|
|
|
|
|
//获取员工的上级是谁 ,TODO
|
|
|
func (srv StaffAssessServeice) getStaffSuper(transactionContext application.TransactionContext, targetUser domain.User) ([]domain.User, error) {
|
|
|
func (srv StaffAssessServeice) getStaffSuper(transactionContext application.TransactionContext, targetUser domain.User) ([]*domain.User, error) {
|
|
|
departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
...
|
...
|
@@ -1793,6 +1787,29 @@ func (srv StaffAssessServeice) getStaffSuper(transactionContext application.Tran |
|
|
}
|
|
|
}
|
|
|
if len(departmemtList) == 0 {
|
|
|
//找不到员工的部门
|
|
|
companyRepo := factory.CreateCompanyRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
companyData, err := companyRepo.FindOne(map[string]interface{}{
|
|
|
"id": targetUser.CompanyId,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的公司"+err.Error())
|
|
|
}
|
|
|
//公司作为最顶级
|
|
|
departmemtList = append(departmemtList, &domain.Department{
|
|
|
Id: 0,
|
|
|
CompanyId: companyData.Id,
|
|
|
Level: 0,
|
|
|
Name: companyData.Name,
|
|
|
ParentId: 0,
|
|
|
ChargeUserIds: companyData.ChargeUserIds,
|
|
|
Path: "",
|
|
|
CreatedAt: time.Time{},
|
|
|
UpdatedAt: time.Time{},
|
|
|
DeletedAt: &time.Time{},
|
|
|
})
|
|
|
|
|
|
}
|
|
|
//获取部门管理员
|
...
|
...
|
@@ -1836,14 +1853,5 @@ loop: |
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取主管员工数据"+err.Error())
|
|
|
}
|
|
|
}
|
|
|
if len(chargeUserList) == 0 {
|
|
|
//如果都找不到数据
|
|
|
|
|
|
}
|
|
|
|
|
|
// _, chargeUserList, err := userRepo.Find(map[string]interface{}{
|
|
|
// "ids": chargeUserIds,
|
|
|
// })
|
|
|
|
|
|
return nil, nil
|
|
|
return chargeUserList, nil
|
|
|
} |
...
|
...
|
|