...
|
...
|
@@ -7,6 +7,7 @@ import ( |
|
|
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/event/subscriber"
|
|
|
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/factory"
|
|
|
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/task/command"
|
|
|
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/task/dto"
|
|
|
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/task/query"
|
|
|
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
|
|
|
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain/service"
|
...
|
...
|
@@ -18,6 +19,74 @@ import ( |
|
|
type TaskService struct {
|
|
|
}
|
|
|
|
|
|
// 对抢单任务进行确认
|
|
|
func (taskService *TaskService) ConfirmRobTask(confirmRobTaskCommand *command.ConfirmRobTaskCommand) (interface{}, error) {
|
|
|
if err := confirmRobTaskCommand.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())
|
|
|
}
|
|
|
if err := transactionContext.StartTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
defer func() {
|
|
|
transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
var confirmRobTaskService service.ConfirmRobTaskService
|
|
|
if value, err := factory.CreateConfirmRobTaskService(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
confirmRobTaskService = value
|
|
|
//confirmRobTaskService.Subscribe(&subscriber.AbilityServiceSubscriber{})
|
|
|
}
|
|
|
if task, err := confirmRobTaskService.Confirm(confirmRobTaskCommand.TaskId, confirmRobTaskCommand.Operator, confirmRobTaskCommand.PlannedCompletionTime); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
return task, nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 驳回任务领取人
|
|
|
func (taskService *TaskService) RejectTaskReceiver(rejectTaskReceiverCommand *command.RejectTaskReceiverCommand) (interface{}, error) {
|
|
|
if err := rejectTaskReceiverCommand.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())
|
|
|
}
|
|
|
if err := transactionContext.StartTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
defer func() {
|
|
|
transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
var rejectTaskReceiverService service.RejectTaskReceiverService
|
|
|
if value, err := factory.CreateRejectTaskReceiverService(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
rejectTaskReceiverService = value
|
|
|
//rejectTaskReceiverService.Subscribe(&subscriber.AbilityServiceSubscriber{})
|
|
|
}
|
|
|
if task, err := rejectTaskReceiverService.Reject(rejectTaskReceiverCommand.TaskId, rejectTaskReceiverCommand.Operator, rejectTaskReceiverCommand.RejectReason); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
return task, nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 对任务进行抢单
|
|
|
func (taskService *TaskService) RobTask(robTaskCommand *command.RobTaskCommand) (interface{}, error) {
|
|
|
if err := robTaskCommand.ValidateCommand(); err != nil {
|
...
|
...
|
@@ -109,7 +178,7 @@ func (taskService *TaskService) ChooseSuccessfulBidder(chooseSuccessfulBidderCom |
|
|
chooseSuccessfulBidderService = value
|
|
|
chooseSuccessfulBidderService.Subscribe(&subscriber.AbilityServiceSubscriber{})
|
|
|
}
|
|
|
if task, err := chooseSuccessfulBidderService.Choose(chooseSuccessfulBidderCommand.TaskId, chooseSuccessfulBidderCommand.SuccessfulBidder, chooseSuccessfulBidderCommand.Operator); err != nil {
|
|
|
if task, err := chooseSuccessfulBidderService.Choose(chooseSuccessfulBidderCommand.TaskId, chooseSuccessfulBidderCommand.SuccessfulBidder, chooseSuccessfulBidderCommand.Operator, chooseSuccessfulBidderCommand.PlannedCompletionTime); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
...
|
...
|
@@ -244,7 +313,7 @@ func (taskService *TaskService) AcceptanceTask(acceptanceTaskCommand *command.Ac |
|
|
acceptanceTaskService = value
|
|
|
acceptanceTaskService.Subscribe(&subscriber.AbilityServiceSubscriber{})
|
|
|
}
|
|
|
if task, err := acceptanceTaskService.Acceptance(acceptanceTaskCommand.TaskId, acceptanceTaskCommand.Operator, acceptanceTaskCommand.Participators, acceptanceTaskCommand.TaskPercentage, acceptanceTaskCommand.ReferenceResourceScore, acceptanceTaskCommand.SolveReport, acceptanceTaskCommand.SolvePictureUrls); err != nil {
|
|
|
if task, err := acceptanceTaskService.Acceptance(acceptanceTaskCommand.TaskId, acceptanceTaskCommand.Operator, acceptanceTaskCommand.Participators, acceptanceTaskCommand.TaskPercentage, acceptanceTaskCommand.ReferenceResourceScore, acceptanceTaskCommand.SolveReport, acceptanceTaskCommand.SolvePictureUrls, acceptanceTaskCommand.ActualCompletionTime); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
...
|
...
|
@@ -277,15 +346,77 @@ func (taskService *TaskService) SearchTask(searchTaskCommand *command.SearchTask |
|
|
} else {
|
|
|
taskRepository = value
|
|
|
}
|
|
|
var projectBelongRepository domain.ProjectBelongRepository
|
|
|
if value, err := factory.CreateProjectBelongRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
projectBelongRepository = value
|
|
|
}
|
|
|
projectBelongMap := make(map[int]*domain.ProjectBelong)
|
|
|
if _, projectBelongs, err := projectBelongRepository.Find(map[string]interface{}{
|
|
|
"companyId": searchTaskCommand.CompanyId,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
for _, projectBelong := range projectBelongs {
|
|
|
projectBelongMap[projectBelong.ProjectBelongId] = projectBelong
|
|
|
}
|
|
|
}
|
|
|
var customerValueRepository domain.CustomerValueRepository
|
|
|
if value, err := factory.CreateCustomerValueRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
customerValueRepository = value
|
|
|
}
|
|
|
customerValueMap := make(map[int]*domain.CustomerValue)
|
|
|
if _, customerValues, err := customerValueRepository.Find(map[string]interface{}{
|
|
|
"companyId": searchTaskCommand.CompanyId,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
for _, customerValue := range customerValues {
|
|
|
customerValueMap[customerValue.CustomerValueId] = customerValue
|
|
|
}
|
|
|
}
|
|
|
var taskNatureRepository domain.TaskNatureRepository
|
|
|
if value, err := factory.CreateTaskNatureRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
taskNatureRepository = value
|
|
|
}
|
|
|
taskNatureMap := make(map[int]*domain.TaskNature)
|
|
|
if _, taskNatures, err := taskNatureRepository.Find(map[string]interface{}{
|
|
|
"companyId": searchTaskCommand.CompanyId,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
for _, taskNature := range taskNatures {
|
|
|
taskNatureMap[taskNature.TaskNatureId] = taskNature
|
|
|
}
|
|
|
}
|
|
|
if count, tasks, err := taskRepository.Find(tool_funs.SimpleStructToMap(searchTaskCommand)); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
var taskDtos []*dto.TaskDto
|
|
|
for _, task := range tasks {
|
|
|
taskDto := &dto.TaskDto{}
|
|
|
if err := taskDto.LoadDto(task, projectBelongMap, customerValueMap, taskNatureMap); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
taskDtos = append(taskDtos, taskDto)
|
|
|
}
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
return map[string]interface{}{
|
|
|
"count": count,
|
|
|
"tasks": tasks,
|
|
|
"tasks": taskDtos,
|
|
|
}, nil
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -305,6 +436,60 @@ func (taskService *TaskService) SearchOffTaskRecord(searchOffTaskRecordCommand * |
|
|
defer func() {
|
|
|
transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
var projectBelongRepository domain.ProjectBelongRepository
|
|
|
if value, err := factory.CreateProjectBelongRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
projectBelongRepository = value
|
|
|
}
|
|
|
projectBelongMap := make(map[int]*domain.ProjectBelong)
|
|
|
if _, projectBelongs, err := projectBelongRepository.Find(map[string]interface{}{
|
|
|
"companyId": searchOffTaskRecordCommand.CompanyId,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
for _, projectBelong := range projectBelongs {
|
|
|
projectBelongMap[projectBelong.ProjectBelongId] = projectBelong
|
|
|
}
|
|
|
}
|
|
|
var customerValueRepository domain.CustomerValueRepository
|
|
|
if value, err := factory.CreateCustomerValueRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
customerValueRepository = value
|
|
|
}
|
|
|
customerValueMap := make(map[int]*domain.CustomerValue)
|
|
|
if _, customerValues, err := customerValueRepository.Find(map[string]interface{}{
|
|
|
"companyId": searchOffTaskRecordCommand.CompanyId,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
for _, customerValue := range customerValues {
|
|
|
customerValueMap[customerValue.CustomerValueId] = customerValue
|
|
|
}
|
|
|
}
|
|
|
var taskNatureRepository domain.TaskNatureRepository
|
|
|
if value, err := factory.CreateTaskNatureRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
taskNatureRepository = value
|
|
|
}
|
|
|
taskNatureMap := make(map[int]*domain.TaskNature)
|
|
|
if _, taskNatures, err := taskNatureRepository.Find(map[string]interface{}{
|
|
|
"companyId": searchOffTaskRecordCommand.CompanyId,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
for _, taskNature := range taskNatures {
|
|
|
taskNatureMap[taskNature.TaskNatureId] = taskNature
|
|
|
}
|
|
|
}
|
|
|
var taskRepository domain.TaskRepository
|
|
|
if value, err := factory.CreateTaskRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
...
|
...
|
@@ -326,8 +511,9 @@ func (taskService *TaskService) SearchOffTaskRecord(searchOffTaskRecordCommand * |
|
|
"taskStatus": domain.TASK_STATUS_CLOSED,
|
|
|
"taskContentMatch": searchOffTaskRecordCommand.TaskContentMatch,
|
|
|
"taskType": searchOffTaskRecordCommand.TaskType,
|
|
|
"customerValue": searchOffTaskRecordCommand.CustomerValue,
|
|
|
"taskNature": searchOffTaskRecordCommand.TaskNature,
|
|
|
"projectBelongs": searchOffTaskRecordCommand.ProjectBelongs,
|
|
|
"customerValues": searchOffTaskRecordCommand.CustomerValues,
|
|
|
"taskNatures": searchOffTaskRecordCommand.TaskNatures,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
...
|
...
|
@@ -345,19 +531,25 @@ func (taskService *TaskService) SearchOffTaskRecord(searchOffTaskRecordCommand * |
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
var offTaskRecordDtos []*dto.OffTaskRecordDto
|
|
|
for _, offTaskRecord := range offTaskRecords {
|
|
|
for _, task := range tasks {
|
|
|
if offTaskRecord.Task.TaskId == task.TaskId {
|
|
|
offTaskRecord.Task = task
|
|
|
}
|
|
|
}
|
|
|
offTaskRecordDto := &dto.OffTaskRecordDto{}
|
|
|
if err := offTaskRecordDto.LoadDto(offTaskRecord, projectBelongMap, customerValueMap, taskNatureMap); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
offTaskRecordDtos = append(offTaskRecordDtos, offTaskRecordDto)
|
|
|
}
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
return map[string]interface{}{
|
|
|
"count": count,
|
|
|
"offTaskRecords": offTaskRecords,
|
|
|
"offTaskRecords": offTaskRecordDtos,
|
|
|
}, nil
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -399,6 +591,176 @@ func (taskService *TaskService) GetOffTaskRecord(getOffTaskRecordQuery *query.Ge |
|
|
}
|
|
|
}
|
|
|
|
|
|
// 搜索驳回任务记录
|
|
|
func (taskService *TaskService) SearchRejectTaskRecord(searchRejectTaskRecordCommand *command.SearchRejectTaskRecordCommand) (interface{}, error) {
|
|
|
if err := searchRejectTaskRecordCommand.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())
|
|
|
}
|
|
|
if err := transactionContext.StartTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
defer func() {
|
|
|
transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
var projectBelongRepository domain.ProjectBelongRepository
|
|
|
if value, err := factory.CreateProjectBelongRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
projectBelongRepository = value
|
|
|
}
|
|
|
projectBelongMap := make(map[int]*domain.ProjectBelong)
|
|
|
if _, projectBelongs, err := projectBelongRepository.Find(map[string]interface{}{
|
|
|
"companyId": searchRejectTaskRecordCommand.CompanyId,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
for _, projectBelong := range projectBelongs {
|
|
|
projectBelongMap[projectBelong.ProjectBelongId] = projectBelong
|
|
|
}
|
|
|
}
|
|
|
var customerValueRepository domain.CustomerValueRepository
|
|
|
if value, err := factory.CreateCustomerValueRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
customerValueRepository = value
|
|
|
}
|
|
|
customerValueMap := make(map[int]*domain.CustomerValue)
|
|
|
if _, customerValues, err := customerValueRepository.Find(map[string]interface{}{
|
|
|
"companyId": searchRejectTaskRecordCommand.CompanyId,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
for _, customerValue := range customerValues {
|
|
|
customerValueMap[customerValue.CustomerValueId] = customerValue
|
|
|
}
|
|
|
}
|
|
|
var taskNatureRepository domain.TaskNatureRepository
|
|
|
if value, err := factory.CreateTaskNatureRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
taskNatureRepository = value
|
|
|
}
|
|
|
taskNatureMap := make(map[int]*domain.TaskNature)
|
|
|
if _, taskNatures, err := taskNatureRepository.Find(map[string]interface{}{
|
|
|
"companyId": searchRejectTaskRecordCommand.CompanyId,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
for _, taskNature := range taskNatures {
|
|
|
taskNatureMap[taskNature.TaskNatureId] = taskNature
|
|
|
}
|
|
|
}
|
|
|
var taskRepository domain.TaskRepository
|
|
|
if value, err := factory.CreateTaskRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
taskRepository = value
|
|
|
}
|
|
|
var rejectTaskRecordRepository domain.RejectTaskRecordRepository
|
|
|
if value, err := factory.CreateRejectTaskRecordRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
rejectTaskRecordRepository = value
|
|
|
}
|
|
|
_, tasks, err := taskRepository.Find(map[string]interface{}{
|
|
|
"companyId": searchRejectTaskRecordCommand.CompanyId,
|
|
|
"taskStatus": domain.TASK_STATUS_CLOSED,
|
|
|
"taskContentMatch": searchRejectTaskRecordCommand.TaskContentMatch,
|
|
|
"taskType": searchRejectTaskRecordCommand.TaskType,
|
|
|
"projectBelongs": searchRejectTaskRecordCommand.ProjectBelongs,
|
|
|
"customerValues": searchRejectTaskRecordCommand.CustomerValues,
|
|
|
"taskNatures": searchRejectTaskRecordCommand.TaskNatures,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
var taskIds []int64
|
|
|
for _, task := range tasks {
|
|
|
taskIds = append(taskIds, task.TaskId)
|
|
|
}
|
|
|
if count, rejectTaskRecords, err := rejectTaskRecordRepository.Find(map[string]interface{}{
|
|
|
"taskIds": taskIds,
|
|
|
"rejectStartTime": searchRejectTaskRecordCommand.RejectStartTime,
|
|
|
"rejectEndTime": searchRejectTaskRecordCommand.RejectEndTime,
|
|
|
"offset": searchRejectTaskRecordCommand.Offset,
|
|
|
"limit": searchRejectTaskRecordCommand.Limit,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
var rejectTaskRecordDtos []*dto.RejectTaskRecordDto
|
|
|
for _, rejectTaskRecord := range rejectTaskRecords {
|
|
|
for _, task := range tasks {
|
|
|
if rejectTaskRecord.Task.TaskId == task.TaskId {
|
|
|
rejectTaskRecord.Task = task
|
|
|
}
|
|
|
}
|
|
|
rejectTaskRecordDto := &dto.RejectTaskRecordDto{}
|
|
|
if err := rejectTaskRecordDto.LoadDto(rejectTaskRecord, projectBelongMap, customerValueMap, taskNatureMap); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
rejectTaskRecordDtos = append(rejectTaskRecordDtos, rejectTaskRecordDto)
|
|
|
}
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
return map[string]interface{}{
|
|
|
"count": count,
|
|
|
"offTaskRecords": rejectTaskRecordDtos,
|
|
|
}, nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 返回驳回任务记录
|
|
|
func (taskService *TaskService) GetRejectTaskRecord(getRejectTaskRecordQuery *query.GetRejectTaskRecordQuery) (interface{}, error) {
|
|
|
if err := getRejectTaskRecordQuery.ValidateQuery(); 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())
|
|
|
}
|
|
|
if err := transactionContext.StartTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
defer func() {
|
|
|
transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
var rejectTaskRecordRepository domain.RejectTaskRecordRepository
|
|
|
if value, err := factory.CreateRejectTaskRecordRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
rejectTaskRecordRepository = value
|
|
|
}
|
|
|
rejectTaskRecord, err := rejectTaskRecordRepository.FindOne(map[string]interface{}{"rejectTaskRecordId": getRejectTaskRecordQuery.RejectTaskRecordId})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if rejectTaskRecord == nil {
|
|
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getRejectTaskRecordQuery.RejectTaskRecordId)))
|
|
|
} else {
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
return rejectTaskRecord, nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 创建新任务
|
|
|
func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTaskCommand) (interface{}, error) {
|
|
|
if err := createTaskCommand.ValidateCommand(); err != nil {
|
...
|
...
|
@@ -439,6 +801,19 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask |
|
|
if sponsor == nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的发布者")
|
|
|
}
|
|
|
var assignedPerson *domain.EmployeeInfo
|
|
|
if createTaskCommand.AssignedPerson != 0 {
|
|
|
employee, err := employeeRepository.FindOne(map[string]interface{}{
|
|
|
"uid": createTaskCommand.AssignedPerson,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if employee == nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的指派人员")
|
|
|
}
|
|
|
assignedPerson = employee.EmployeeInfo
|
|
|
}
|
|
|
newTask := &domain.Task{
|
|
|
TaskStatus: domain.TASK_STATUS_UNRELEASED,
|
|
|
CompanyId: createTaskCommand.CompanyId,
|
...
|
...
|
@@ -449,13 +824,16 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask |
|
|
ReferenceResourceType: createTaskCommand.ReferenceResourceType,
|
|
|
ReferenceResourceItems: createTaskCommand.ReferenceResourceItems,
|
|
|
},
|
|
|
CustomerValue: createTaskCommand.CustomerValue,
|
|
|
ProjectBelong: createTaskCommand.ProjectBelong,
|
|
|
CustomerValues: createTaskCommand.CustomerValues,
|
|
|
TaskNature: createTaskCommand.TaskNature,
|
|
|
SuMoney: createTaskCommand.SuMoney,
|
|
|
AcceptanceStandard: createTaskCommand.AcceptanceStandard,
|
|
|
TaskDescription: createTaskCommand.TaskDescription,
|
|
|
TaskPictureUrls: createTaskCommand.TaskPictureUrls,
|
|
|
IsRewardTake: createTaskCommand.IsRewardTake,
|
|
|
AssignedPerson: assignedPerson,
|
|
|
PlannedCompletionTime: createTaskCommand.PlannedCompletionTime,
|
|
|
CreateTime: time.Now(),
|
|
|
}
|
|
|
var taskRepository domain.TaskRepository
|
...
|
...
|
@@ -487,7 +865,7 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask |
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
if createTaskCommand.TaskType == domain.TASK_TYPE_BID {
|
|
|
if err := taskDao.AddBidInfo(task.TaskId, createTaskCommand.BidStartTime, createTaskCommand.BidEndTime); err != nil {
|
|
|
if err := taskDao.AddBidInfo(task.TaskId, createTaskCommand.BidStartTime, createTaskCommand.BidEndTime, createTaskCommand.IsRemind); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -545,10 +923,68 @@ func (taskService *TaskService) GetTask(getTaskQuery *query.GetTaskQuery) (inter |
|
|
if task == nil {
|
|
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getTaskQuery.TaskId)))
|
|
|
} else {
|
|
|
var projectBelongRepository domain.ProjectBelongRepository
|
|
|
if value, err := factory.CreateProjectBelongRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
projectBelongRepository = value
|
|
|
}
|
|
|
projectBelongMap := make(map[int]*domain.ProjectBelong)
|
|
|
if _, projectBelongs, err := projectBelongRepository.Find(map[string]interface{}{
|
|
|
"companyId": task.CompanyId,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
for _, projectBelong := range projectBelongs {
|
|
|
projectBelongMap[projectBelong.ProjectBelongId] = projectBelong
|
|
|
}
|
|
|
}
|
|
|
var customerValueRepository domain.CustomerValueRepository
|
|
|
if value, err := factory.CreateCustomerValueRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
customerValueRepository = value
|
|
|
}
|
|
|
customerValueMap := make(map[int]*domain.CustomerValue)
|
|
|
if _, customerValues, err := customerValueRepository.Find(map[string]interface{}{
|
|
|
"companyId": task.CompanyId,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
for _, customerValue := range customerValues {
|
|
|
customerValueMap[customerValue.CustomerValueId] = customerValue
|
|
|
}
|
|
|
}
|
|
|
var taskNatureRepository domain.TaskNatureRepository
|
|
|
if value, err := factory.CreateTaskNatureRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
taskNatureRepository = value
|
|
|
}
|
|
|
taskNatureMap := make(map[int]*domain.TaskNature)
|
|
|
if _, taskNatures, err := taskNatureRepository.Find(map[string]interface{}{
|
|
|
"companyId": task.CompanyId,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
for _, taskNature := range taskNatures {
|
|
|
taskNatureMap[taskNature.TaskNatureId] = taskNature
|
|
|
}
|
|
|
}
|
|
|
taskDto := &dto.TaskDto{}
|
|
|
if err := taskDto.LoadDto(task, projectBelongMap, customerValueMap, taskNatureMap); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
return task, nil
|
|
|
return taskDto, nil
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
@@ -619,7 +1055,7 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask |
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
if task.TaskType == domain.TASK_TYPE_BID {
|
|
|
if err := taskDao.UpdateBidInfo(updateTaskCommand.TaskId, updateTaskCommand.BidStartTime, updateTaskCommand.BidEndTime); err != nil {
|
|
|
if err := taskDao.UpdateBidInfo(updateTaskCommand.TaskId, updateTaskCommand.BidStartTime, updateTaskCommand.BidEndTime, updateTaskCommand.IsRemind); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
}
|
...
|
...
|
|