...
|
...
|
@@ -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": param.BeginTime,
|
|
|
})
|
|
|
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,13 +408,10 @@ 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,
|
|
|
})
|
|
|
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())
|
|
|
}
|
...
|
...
|
@@ -405,27 +425,35 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(param *command.CreateStaffA |
|
|
}
|
|
|
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())
|
|
|
}
|
|
|
}
|
|
|
assessTask.ExecutorId = executorIds
|
|
|
_, err = assessTaskRepo.Save(&assessTask)
|
|
|
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
|
|
|
}
|
|
|
|
...
|
...
|
|