作者 Your Name

修复一些问题

@@ -353,22 +353,12 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(transactionContext applicat @@ -353,22 +353,12 @@ 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 { 356 + // if len(assassessTaskList) > 0 {
  357 + // assessTaskData = assassessTaskList[0]
  358 + // assessTaskData.UpdatedAt = nowTime
  359 + // } else {
370 //建立评估任务 360 //建立评估任务
371 - assessTaskData = &domain.StaffAssessTask{ 361 + assessTaskData := &domain.StaffAssessTask{
372 Id: 0, 362 Id: 0,
373 CompanyId: param.CompanyId, 363 CompanyId: param.CompanyId,
374 EvaluationProjectId: param.EvaluationProjectId, 364 EvaluationProjectId: param.EvaluationProjectId,
@@ -383,7 +373,7 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(transactionContext applicat @@ -383,7 +373,7 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(transactionContext applicat
383 UpdatedAt: nowTime, 373 UpdatedAt: nowTime,
384 DeletedAt: nil, 374 DeletedAt: nil,
385 } 375 }
386 - } 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 }
  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())
  416 + }
  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"),
  421 + })
  422 + if err != nil {
  423 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询同日期已存在评估任务"+err.Error())
  424 + }
  425 +
  426 + if len(assassessTaskList) > 0 {
428 //过滤就数据 427 //过滤就数据
429 - for _, v := range assessTaskData.ExecutorId { 428 + for _, v := range assassessTaskList[0].ExecutorId {
430 if _, ok := executorIdMap[v]; ok { 429 if _, ok := executorIdMap[v]; ok {
431 continue 430 continue
432 } 431 }
433 executorIds = append(executorIds, v) 432 executorIds = append(executorIds, v)
434 } 433 }
435 - assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{  
436 - "transactionContext": transactionContext,  
437 - })  
438 assessTaskData.ExecutorId = executorIds 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{}{