正在显示
1 个修改的文件
包含
51 行增加
和
45 行删除
@@ -353,37 +353,27 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(transactionContext applicat | @@ -353,37 +353,27 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(transactionContext applicat | ||
353 | return nil, application.ThrowError(application.ARG_ERROR, "任务结束时间填写错误,"+param.EndTime) | 353 | return nil, application.ThrowError(application.ARG_ERROR, "任务结束时间填写错误,"+param.EndTime) |
354 | } | 354 | } |
355 | nowTime := time.Now() | 355 | nowTime := time.Now() |
356 | - var assessTaskData *domain.StaffAssessTask | ||
357 | - _, assassessTaskList, err := assessTaskRepo.Find(map[string]interface{}{ | ||
358 | - "evaluationProjectId": param.EvaluationProjectId, | ||
359 | - "beginDay": taskBeginTime.Local().Format("2006-01-02"), | ||
360 | - }) | ||
361 | - if err != nil { | ||
362 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询同日期已存在评估任务"+err.Error()) | ||
363 | - } | ||
364 | - // 获取旧数据 | ||
365 | - | ||
366 | - if len(assassessTaskList) > 0 { | ||
367 | - assessTaskData = assassessTaskList[0] | ||
368 | - assessTaskData.UpdatedAt = nowTime | ||
369 | - } else { | ||
370 | - //建立评估任务 | ||
371 | - assessTaskData = &domain.StaffAssessTask{ | ||
372 | - Id: 0, | ||
373 | - CompanyId: param.CompanyId, | ||
374 | - EvaluationProjectId: param.EvaluationProjectId, | ||
375 | - EvaluationProjectName: param.EvaluationProjectName, | ||
376 | - CycleId: param.CycleId, | ||
377 | - CycleName: param.CycleName, | ||
378 | - BeginTime: taskBeginTime, | ||
379 | - EndTime: taskEndTime, | ||
380 | - StepList: []domain.AssessTaskStep{}, | ||
381 | - ExecutorId: nil, | ||
382 | - CreatedAt: nowTime, | ||
383 | - UpdatedAt: nowTime, | ||
384 | - DeletedAt: nil, | ||
385 | - } | 356 | + // if len(assassessTaskList) > 0 { |
357 | + // assessTaskData = assassessTaskList[0] | ||
358 | + // assessTaskData.UpdatedAt = nowTime | ||
359 | + // } else { | ||
360 | + //建立评估任务 | ||
361 | + assessTaskData := &domain.StaffAssessTask{ | ||
362 | + Id: 0, | ||
363 | + CompanyId: param.CompanyId, | ||
364 | + EvaluationProjectId: param.EvaluationProjectId, | ||
365 | + EvaluationProjectName: param.EvaluationProjectName, | ||
366 | + CycleId: param.CycleId, | ||
367 | + CycleName: param.CycleName, | ||
368 | + BeginTime: taskBeginTime, | ||
369 | + EndTime: taskEndTime, | ||
370 | + StepList: []domain.AssessTaskStep{}, | ||
371 | + ExecutorId: nil, | ||
372 | + CreatedAt: nowTime, | ||
373 | + UpdatedAt: nowTime, | ||
374 | + DeletedAt: nil, | ||
386 | } | 375 | } |
376 | + // } | ||
387 | 377 | ||
388 | //填充评估环节 | 378 | //填充评估环节 |
389 | for _, v := range param.StepList { | 379 | for _, v := range param.StepList { |
@@ -410,12 +400,6 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(transactionContext applicat | @@ -410,12 +400,6 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(transactionContext applicat | ||
410 | } | 400 | } |
411 | assessTaskData.StepList = append(assessTaskData.StepList, step) | 401 | assessTaskData.StepList = append(assessTaskData.StepList, step) |
412 | } | 402 | } |
413 | - | ||
414 | - assessList, err := srv.createStaffAssess(transactionContext, assessTaskData) | ||
415 | - if err != nil { | ||
416 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "生成个人评估项"+err.Error()) | ||
417 | - } | ||
418 | - | ||
419 | //评估的参与人 | 403 | //评估的参与人 |
420 | executorIds := []int{} | 404 | executorIds := []int{} |
421 | executorIdMap := map[int]struct{}{} //过滤重复的用户 | 405 | executorIdMap := map[int]struct{}{} //过滤重复的用户 |
@@ -425,22 +409,41 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(transactionContext applicat | @@ -425,22 +409,41 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(transactionContext applicat | ||
425 | } | 409 | } |
426 | executorIds = append(executorIds, v) | 410 | executorIds = append(executorIds, v) |
427 | } | 411 | } |
428 | - //过滤就数据 | ||
429 | - for _, v := range assessTaskData.ExecutorId { | ||
430 | - if _, ok := executorIdMap[v]; ok { | ||
431 | - continue | ||
432 | - } | ||
433 | - executorIds = append(executorIds, v) | 412 | + assessTaskData.ExecutorId = executorIds |
413 | + assessList, err := srv.createStaffAssess(transactionContext, assessTaskData) | ||
414 | + if err != nil { | ||
415 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "生成个人评估项"+err.Error()) | ||
434 | } | 416 | } |
435 | - assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{ | ||
436 | - "transactionContext": transactionContext, | 417 | + // var assessTaskData *domain.StaffAssessTask |
418 | + _, assassessTaskList, err := assessTaskRepo.Find(map[string]interface{}{ | ||
419 | + "evaluationProjectId": param.EvaluationProjectId, | ||
420 | + "beginDay": taskBeginTime.Local().Format("2006-01-02"), | ||
437 | }) | 421 | }) |
438 | - assessTaskData.ExecutorId = executorIds | 422 | + if err != nil { |
423 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询同日期已存在评估任务"+err.Error()) | ||
424 | + } | ||
425 | + | ||
426 | + if len(assassessTaskList) > 0 { | ||
427 | + //过滤就数据 | ||
428 | + for _, v := range assassessTaskList[0].ExecutorId { | ||
429 | + if _, ok := executorIdMap[v]; ok { | ||
430 | + continue | ||
431 | + } | ||
432 | + executorIds = append(executorIds, v) | ||
433 | + } | ||
434 | + assessTaskData.ExecutorId = executorIds | ||
435 | + assessTaskData.Id = assassessTaskList[0].Id | ||
436 | + assessTaskData.StepList = append(assassessTaskList[0].StepList, assessTaskData.StepList...) | ||
437 | + | ||
438 | + } | ||
439 | _, err = assessTaskRepo.Save(assessTaskData) | 439 | _, err = assessTaskRepo.Save(assessTaskData) |
440 | if err != nil { | 440 | if err != nil { |
441 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存评估任务"+err.Error()) | 441 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存评估任务"+err.Error()) |
442 | } | 442 | } |
443 | 443 | ||
444 | + assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{ | ||
445 | + "transactionContext": transactionContext, | ||
446 | + }) | ||
444 | for i := range assessList { | 447 | for i := range assessList { |
445 | assessList[i].StaffAssessTaskId = assessTaskData.Id | 448 | assessList[i].StaffAssessTaskId = assessTaskData.Id |
446 | _, err = assessRepo.Save(&assessList[i]) | 449 | _, err = assessRepo.Save(&assessList[i]) |
@@ -470,6 +473,9 @@ func (srv StaffAssessServeice) createStaffAssess(transactionContext application. | @@ -470,6 +473,9 @@ func (srv StaffAssessServeice) createStaffAssess(transactionContext application. | ||
470 | } | 473 | } |
471 | // 获取用户的信息 | 474 | // 获取用户的信息 |
472 | if len(selfUserId) == 0 { | 475 | if len(selfUserId) == 0 { |
476 | + log.Logger.Error("createStaffAssess", map[string]interface{}{ | ||
477 | + "param": param, | ||
478 | + }) | ||
473 | return nil, application.ThrowError(application.ARG_ERROR, "未填写评估任务的执行人") | 479 | return nil, application.ThrowError(application.ARG_ERROR, "未填写评估任务的执行人") |
474 | } | 480 | } |
475 | userRepo := factory.CreateUserRepository(map[string]interface{}{ | 481 | userRepo := factory.CreateUserRepository(map[string]interface{}{ |
-
请 注册 或 登录 后发表评论