...
|
...
|
@@ -309,6 +309,7 @@ func (taskService *TaskService) AcceptanceTask(acceptanceTaskCommand *command.Ac |
|
|
if err := acceptanceTaskCommand.ValidateCommand(); err != nil {
|
|
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
...
|
...
|
@@ -320,6 +321,7 @@ func (taskService *TaskService) AcceptanceTask(acceptanceTaskCommand *command.Ac |
|
|
transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
|
|
|
// 验收服务初始化
|
|
|
var acceptanceTaskService service.AcceptanceTaskService
|
|
|
if value, err := factory.CreateAcceptanceTaskService(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
...
|
...
|
@@ -330,6 +332,31 @@ func (taskService *TaskService) AcceptanceTask(acceptanceTaskCommand *command.Ac |
|
|
acceptanceTaskService.Subscribe(&subscriber.AbilityServiceSubscriber{})
|
|
|
}
|
|
|
|
|
|
// 员工仓储初始化
|
|
|
var employeeRepository domain.EmployeeRepository
|
|
|
if value, err := factory.CreateEmployeeRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
employeeRepository = value
|
|
|
}
|
|
|
|
|
|
// 填充员工信息
|
|
|
for i, taskPercentage := range acceptanceTaskCommand.TaskPercentage {
|
|
|
getEmployee := map[string]interface{}{
|
|
|
"uid": taskPercentage.Contributor.Uid,
|
|
|
}
|
|
|
employeeFound, err := employeeRepository.FindOne(getEmployee)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if employeeFound == nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的员工")
|
|
|
}
|
|
|
acceptanceTaskCommand.TaskPercentage[i].Contributor = employeeFound.EmployeeInfo
|
|
|
}
|
|
|
|
|
|
if task, err := acceptanceTaskService.Acceptance(acceptanceTaskCommand.TaskId, acceptanceTaskCommand.Operator, acceptanceTaskCommand.Participators, acceptanceTaskCommand.SuMoney, acceptanceTaskCommand.TaskPercentage, acceptanceTaskCommand.ReferenceResourceScore, acceptanceTaskCommand.SolveReport, acceptanceTaskCommand.SolvePictureUrls, acceptanceTaskCommand.ActualCompletionTime); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
...
|
...
|
|