|
@@ -341,7 +341,9 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(param *command.CreateStaffA |
|
@@ -341,7 +341,9 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(param *command.CreateStaffA |
341
|
defer func() {
|
341
|
defer func() {
|
342
|
_ = transactionContext.RollbackTransaction()
|
342
|
_ = transactionContext.RollbackTransaction()
|
343
|
}()
|
343
|
}()
|
344
|
-
|
344
|
+ assessTaskRepo := factory.CreateStaffAssessTaskRepository(map[string]interface{}{
|
|
|
345
|
+ "transactionContext": transactionContext,
|
|
|
346
|
+ })
|
345
|
taskBeginTime, err := time.ParseInLocation("2006-01-02 15:04:05", param.BeginTime, time.Local)
|
347
|
taskBeginTime, err := time.ParseInLocation("2006-01-02 15:04:05", param.BeginTime, time.Local)
|
346
|
if err != nil {
|
348
|
if err != nil {
|
347
|
return nil, application.ThrowError(application.ARG_ERROR, "任务开始时间填写错误,"+param.BeginTime)
|
349
|
return nil, application.ThrowError(application.ARG_ERROR, "任务开始时间填写错误,"+param.BeginTime)
|
|
@@ -351,24 +353,45 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(param *command.CreateStaffA |
|
@@ -351,24 +353,45 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(param *command.CreateStaffA |
351
|
return nil, application.ThrowError(application.ARG_ERROR, "任务结束时间填写错误,"+param.EndTime)
|
353
|
return nil, application.ThrowError(application.ARG_ERROR, "任务结束时间填写错误,"+param.EndTime)
|
352
|
}
|
354
|
}
|
353
|
nowTime := time.Now()
|
355
|
nowTime := time.Now()
|
354
|
- //建立评估任务
|
|
|
355
|
- assessTask := domain.StaffAssessTask{
|
|
|
356
|
- Id: 0,
|
|
|
357
|
- CompanyId: param.CompanyId,
|
|
|
358
|
- EvaluationProjectId: param.EvaluationProjectId,
|
|
|
359
|
- EvaluationProjectName: param.EvaluationProjectName,
|
|
|
360
|
- CycleId: param.CycleId,
|
|
|
361
|
- CycleName: param.CycleName,
|
|
|
362
|
- BeginTime: taskBeginTime,
|
|
|
363
|
- EndTime: taskEndTime,
|
|
|
364
|
- StepList: []domain.AssessTaskStep{},
|
|
|
365
|
- ExecutorId: nil,
|
|
|
366
|
- CreatedAt: nowTime,
|
|
|
367
|
- UpdatedAt: nowTime,
|
|
|
368
|
- DeletedAt: nil,
|
356
|
+ var assessTaskData *domain.StaffAssessTask
|
|
|
357
|
+ _, assassessTaskList, err := assessTaskRepo.Find(map[string]interface{}{
|
|
|
358
|
+ "evaluationProjectId": param.EvaluationProjectId,
|
|
|
359
|
+ "beginDay": param.BeginTime,
|
|
|
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
|
+ }
|
369
|
}
|
386
|
}
|
|
|
387
|
+
|
370
|
//填充评估环节
|
388
|
//填充评估环节
|
371
|
for _, v := range param.StepList {
|
389
|
for _, v := range param.StepList {
|
|
|
390
|
+ for _, vv := range assessTaskData.StepList {
|
|
|
391
|
+ if vv.LinkNodeType == v.LinkNodeType {
|
|
|
392
|
+ continue
|
|
|
393
|
+ }
|
|
|
394
|
+ }
|
372
|
stepBeginTime, err := time.ParseInLocation("2006-01-02 15:04:05", param.BeginTime, time.Local)
|
395
|
stepBeginTime, err := time.ParseInLocation("2006-01-02 15:04:05", param.BeginTime, time.Local)
|
373
|
if err != nil {
|
396
|
if err != nil {
|
374
|
return nil, application.ThrowError(application.ARG_ERROR, "评估环节开始时间填写错误,"+param.BeginTime)
|
397
|
return nil, application.ThrowError(application.ARG_ERROR, "评估环节开始时间填写错误,"+param.BeginTime)
|
|
@@ -385,13 +408,10 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(param *command.CreateStaffA |
|
@@ -385,13 +408,10 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(param *command.CreateStaffA |
385
|
BeginTime: stepBeginTime,
|
408
|
BeginTime: stepBeginTime,
|
386
|
EndTime: stepEndTime,
|
409
|
EndTime: stepEndTime,
|
387
|
}
|
410
|
}
|
388
|
- assessTask.StepList = append(assessTask.StepList, step)
|
411
|
+ assessTaskData.StepList = append(assessTaskData.StepList, step)
|
389
|
}
|
412
|
}
|
390
|
|
413
|
|
391
|
- assessTaskRepo := factory.CreateStaffAssessTaskRepository(map[string]interface{}{
|
|
|
392
|
- "transactionContext": transactionContext,
|
|
|
393
|
- })
|
|
|
394
|
- assessList, err := srv.createStaffAssess(transactionContext, &assessTask)
|
414
|
+ assessList, err := srv.createStaffAssess(transactionContext, assessTaskData)
|
395
|
if err != nil {
|
415
|
if err != nil {
|
396
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "生成个人评估项"+err.Error())
|
416
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "生成个人评估项"+err.Error())
|
397
|
}
|
417
|
}
|
|
@@ -405,27 +425,35 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(param *command.CreateStaffA |
|
@@ -405,27 +425,35 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(param *command.CreateStaffA |
405
|
}
|
425
|
}
|
406
|
executorIds = append(executorIds, v)
|
426
|
executorIds = append(executorIds, v)
|
407
|
}
|
427
|
}
|
|
|
428
|
+ //过滤就数据
|
|
|
429
|
+ for _, v := range assessTaskData.ExecutorId {
|
|
|
430
|
+ if _, ok := executorIdMap[v]; ok {
|
|
|
431
|
+ continue
|
|
|
432
|
+ }
|
|
|
433
|
+ executorIds = append(executorIds, v)
|
|
|
434
|
+ }
|
408
|
assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
|
435
|
assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
|
409
|
"transactionContext": transactionContext,
|
436
|
"transactionContext": transactionContext,
|
410
|
})
|
437
|
})
|
|
|
438
|
+ assessTaskData.ExecutorId = executorIds
|
|
|
439
|
+ _, err = assessTaskRepo.Save(assessTaskData)
|
|
|
440
|
+ if err != nil {
|
|
|
441
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存评估任务"+err.Error())
|
|
|
442
|
+ }
|
411
|
|
443
|
|
412
|
for i := range assessList {
|
444
|
for i := range assessList {
|
|
|
445
|
+ assessList[i].StaffAssessTaskId = assessTaskData.Id
|
413
|
_, err = assessRepo.Save(&assessList[i])
|
446
|
_, err = assessRepo.Save(&assessList[i])
|
414
|
if err != nil {
|
447
|
if err != nil {
|
415
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存个人评估项"+err.Error())
|
448
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存个人评估项"+err.Error())
|
416
|
}
|
449
|
}
|
417
|
}
|
450
|
}
|
418
|
- assessTask.ExecutorId = executorIds
|
|
|
419
|
- _, err = assessTaskRepo.Save(&assessTask)
|
|
|
420
|
- if err != nil {
|
|
|
421
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存评估任务"+err.Error())
|
|
|
422
|
- }
|
|
|
423
|
|
451
|
|
424
|
if err := transactionContext.CommitTransaction(); err != nil {
|
452
|
if err := transactionContext.CommitTransaction(); err != nil {
|
425
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
453
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
426
|
}
|
454
|
}
|
427
|
return map[string]interface{}{
|
455
|
return map[string]interface{}{
|
428
|
- "assessTaskId": assessTask.Id,
|
456
|
+ "assessTaskId": assessTaskData.Id,
|
429
|
}, nil
|
457
|
}, nil
|
430
|
}
|
458
|
}
|
431
|
|
459
|
|