...
|
...
|
@@ -25,6 +25,27 @@ func dayEndTime(t time.Time) time.Time { |
|
|
return t2
|
|
|
}
|
|
|
|
|
|
func (srv TaskService) CreateTaskTest(param *command.CreateTaskCommand) error {
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
if err != nil {
|
|
|
return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
if err := transactionContext.StartTransaction(); err != nil {
|
|
|
return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
defer func() {
|
|
|
_ = transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
err = srv.CreateTask(transactionContext, param)
|
|
|
if err != nil {
|
|
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "创建任务失败:"+err.Error())
|
|
|
}
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
func (srv TaskService) CreateTask(transactionContext application.TransactionContext, param *command.CreateTaskCommand) error {
|
|
|
taskRepo := factory.CreateTaskRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
...
|
...
|
@@ -44,16 +65,40 @@ func (srv TaskService) CreateTask(transactionContext application.TransactionCont |
|
|
//任务已存在
|
|
|
return nil
|
|
|
}
|
|
|
userRepo := factory.CreateUserRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
|
|
|
_, leaderList, err := userRepo.Find(map[string]interface{}{
|
|
|
"id": param.LeaderId,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询人员失败:"+err.Error())
|
|
|
}
|
|
|
if len(leaderList) == 0 {
|
|
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有查询到人员")
|
|
|
}
|
|
|
leaderData := leaderList[0]
|
|
|
nowTime := time.Now()
|
|
|
newTask := domain.Task{
|
|
|
Id: 0,
|
|
|
Name: param.Name,
|
|
|
Alias: param.Name,
|
|
|
Id: 0,
|
|
|
CreatedAt: time.Time{},
|
|
|
UpdatedAt: time.Time{},
|
|
|
DeletedAt: nil,
|
|
|
CompanyId: int(leaderData.CompanyId),
|
|
|
Name: param.Name,
|
|
|
Alias: param.Name,
|
|
|
Leader: domain.TaskLeader{
|
|
|
Id: leaderData.Id,
|
|
|
Account: leaderData.Account,
|
|
|
Name: leaderData.Name,
|
|
|
},
|
|
|
Status: domain.TaskWait,
|
|
|
Level: 0,
|
|
|
LevelName: "",
|
|
|
RelatedUser: []int{},
|
|
|
RunAt: nowTime.Unix(),
|
|
|
StopAt: 0,
|
|
|
}
|
|
|
newTask.ApplyLevelName("")
|
|
|
err = taskRepo.Save(&newTask)
|
...
|
...
|
@@ -297,7 +342,8 @@ func (srv TaskService) GetTaskInfo(param *command.GetTaskCommand) (*adapter.Task |
|
|
Name: val.Name,
|
|
|
PlanCompletedAt: t1,
|
|
|
RealCompletedAt: t2,
|
|
|
StatusCompleted: val.DescriptStatus(),
|
|
|
StatusDescript: val.StatusDescript(),
|
|
|
Status: int(val.Status),
|
|
|
})
|
|
|
}
|
|
|
return &result, nil
|
...
|
...
|
@@ -441,11 +487,11 @@ func (srv TaskService) ListTask(param *command.ListTaskCommand) (map[string]inte |
|
|
Status: int(val.Status),
|
|
|
Level: val.Level,
|
|
|
LevelName: val.LevelName,
|
|
|
StageA: "",
|
|
|
StageB: "",
|
|
|
StageC: "",
|
|
|
StageD: "",
|
|
|
StageE: "",
|
|
|
// StageA: adapter.TaskStage{},
|
|
|
// StageB: adapter.TaskStage{},
|
|
|
// StageC: adapter.TaskStage{},
|
|
|
// StageD: adapter.TaskStage{},
|
|
|
// StageE: adapter.TaskStage{},
|
|
|
}
|
|
|
taskResult = append(taskResult, &tk)
|
|
|
taskMapResult[val.Id] = &tk
|
...
|
...
|
@@ -455,17 +501,23 @@ func (srv TaskService) ListTask(param *command.ListTaskCommand) (map[string]inte |
|
|
if !ok {
|
|
|
continue
|
|
|
}
|
|
|
stage := adapter.TaskStage{
|
|
|
Id: val.Id,
|
|
|
Name: val.Name,
|
|
|
StatusDescript: val.StatusDescript(),
|
|
|
Status: int(val.Status),
|
|
|
}
|
|
|
switch val.SortBy {
|
|
|
case 1:
|
|
|
taskData.StageA = val.Name
|
|
|
taskData.StageA = stage
|
|
|
case 2:
|
|
|
taskData.StageB = val.Name
|
|
|
taskData.StageB = stage
|
|
|
case 3:
|
|
|
taskData.StageC = val.Name
|
|
|
taskData.StageC = stage
|
|
|
case 4:
|
|
|
taskData.StageD = val.Name
|
|
|
taskData.StageD = stage
|
|
|
case 5:
|
|
|
taskData.StageE = val.Name
|
|
|
taskData.StageE = stage
|
|
|
}
|
|
|
}
|
|
|
result := tool_funs.SimpleWrapGridMap(int64(taskCnt), taskResult)
|
...
|
...
|
@@ -492,8 +544,19 @@ func (t TaskService) CancelAttention(param *command.CancelAttentionCommand) erro |
|
|
defer func() {
|
|
|
_ = transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
//0
|
|
|
//0
|
|
|
taskIgnoreRepo := factory.CreateTaskIgnoreRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
taskIgnore := domain.TaskIgnore{
|
|
|
Id: 0,
|
|
|
TaskId: param.TaskId,
|
|
|
UserId: param.UserId,
|
|
|
CreatedAt: time.Time{},
|
|
|
}
|
|
|
err = taskIgnoreRepo.Save(&taskIgnore)
|
|
|
if err != nil {
|
|
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
...
|
...
|
|