...
|
...
|
@@ -353,37 +353,27 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(transactionContext applicat |
|
|
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 {
|
|
|
//建立评估任务
|
|
|
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: nil,
|
|
|
CreatedAt: nowTime,
|
|
|
UpdatedAt: nowTime,
|
|
|
DeletedAt: nil,
|
|
|
}
|
|
|
// 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: nil,
|
|
|
CreatedAt: nowTime,
|
|
|
UpdatedAt: nowTime,
|
|
|
DeletedAt: nil,
|
|
|
}
|
|
|
// }
|
|
|
|
|
|
//填充评估环节
|
|
|
for _, v := range param.StepList {
|
...
|
...
|
@@ -410,12 +400,6 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(transactionContext applicat |
|
|
}
|
|
|
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())
|
|
|
}
|
|
|
|
|
|
//评估的参与人
|
|
|
executorIds := []int{}
|
|
|
executorIdMap := map[int]struct{}{} //过滤重复的用户
|
...
|
...
|
@@ -425,22 +409,41 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(transactionContext applicat |
|
|
}
|
|
|
executorIds = append(executorIds, v)
|
|
|
}
|
|
|
//过滤就数据
|
|
|
for _, v := range assessTaskData.ExecutorId {
|
|
|
if _, ok := executorIdMap[v]; ok {
|
|
|
continue
|
|
|
}
|
|
|
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())
|
|
|
}
|
|
|
assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
// var assessTaskData *domain.StaffAssessTask
|
|
|
_, assassessTaskList, err := assessTaskRepo.Find(map[string]interface{}{
|
|
|
"evaluationProjectId": param.EvaluationProjectId,
|
|
|
"beginDay": taskBeginTime.Local().Format("2006-01-02"),
|
|
|
})
|
|
|
assessTaskData.ExecutorId = executorIds
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询同日期已存在评估任务"+err.Error())
|
|
|
}
|
|
|
|
|
|
if len(assassessTaskList) > 0 {
|
|
|
//过滤就数据
|
|
|
for _, v := range assassessTaskList[0].ExecutorId {
|
|
|
if _, ok := executorIdMap[v]; ok {
|
|
|
continue
|
|
|
}
|
|
|
executorIds = append(executorIds, v)
|
|
|
}
|
|
|
assessTaskData.ExecutorId = executorIds
|
|
|
assessTaskData.Id = assassessTaskList[0].Id
|
|
|
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())
|
|
|
}
|
|
|
|
|
|
assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
for i := range assessList {
|
|
|
assessList[i].StaffAssessTaskId = assessTaskData.Id
|
|
|
_, err = assessRepo.Save(&assessList[i])
|
...
|
...
|
@@ -470,6 +473,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{}{
|
...
|
...
|
|