作者 tangxvhui

更新

... ... @@ -28,4 +28,5 @@ type TaskStage struct {
SortBy int `json:"sortBy"`
PlanCompletedAt string `json:"planCompletedAt,omitempty"` //计划完成时间, 例:2006-01-02
RealCompletedAt string `json:"realCompletedAt,omitempty"` //实际完成时间, 例:2006-01-02
IsRef bool `json:"isRef"` //是否已经被下发
}
... ...
package command
type DeleteTaskCommand struct {
TaskId int `json:"taskId,string"`
CompanyId int `json:"-"`
}
... ...
... ... @@ -327,6 +327,18 @@ func (srv TaskService) GetTaskInfo(param *command.GetTaskCommand) (*adapter.Task
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取相关人员"+err.Error())
}
}
//查询是否已经有每日评估
taskRecordRepo := factory.CreateTaskRecordRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
cnt, _, err := taskRecordRepo.Find(map[string]interface{}{
"taskId": param.TaskId,
"limit": 1,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "相关联的任务反馈信息"+err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
... ... @@ -368,14 +380,18 @@ func (srv TaskService) GetTaskInfo(param *command.GetTaskCommand) (*adapter.Task
if val.RealCompletedAt > 0 {
t2 = time.Unix(val.RealCompletedAt, 0).Local().Format("2006-01-02")
}
result.StageList = append(result.StageList, adapter.TaskStage{
stage := adapter.TaskStage{
Id: val.Id,
Name: val.Name,
PlanCompletedAt: t1,
RealCompletedAt: t2,
SortBy: val.SortBy,
StatusDescription: val.StatusDescription(),
})
}
if cnt > 0 {
stage.IsRef = true
}
result.StageList = append(result.StageList, stage)
}
return &result, nil
}
... ... @@ -907,3 +923,39 @@ func (srv TaskService) ListTaskRecord(param *command.ListTaskRecordCommand) (map
result := tool_funs.SimpleWrapGridMap(int64(cnt), resultList)
return result, nil
}
// 获取任务详情
func (srv TaskService) DeleteTaskInfo(param *command.GetTaskCommand) (*adapter.TaskInfoAdapter, 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()
}()
taskRepo := factory.CreateTaskRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
taskData, err := taskRepo.FindOne(map[string]interface{}{
"id": param.TaskId,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "xx"+err.Error())
}
if taskData.CompanyId != param.CompanyId {
return nil, nil
}
nowTime := time.Now()
taskData.DeletedAt = &nowTime
err = taskRepo.Save(taskData)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "xx"+err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
return nil, nil
}
... ...
... ... @@ -139,3 +139,35 @@ func (c *TaskController) ListTask2() {
result, err := srv.ListTask2(paramReq)
c.Response(result, err)
}
// ListTaskRecord 员工绩效-获取任务反馈列表
func (c *TaskController) ListTaskRecord() {
srv := service.NewTaskService()
paramReq := &command.ListTaskRecordCommand{}
err := c.BindJSON(paramReq)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
userReq := middlewares.GetUser(c.Ctx)
paramReq.CompanyId = int(userReq.CompanyId)
result, err := srv.ListTaskRecord(paramReq)
c.Response(result, err)
}
// DeleteTask 删除任务
func (c *TaskController) DeleteTask() {
srv := service.NewTaskService()
paramReq := &command.GetTaskCommand{}
err := c.BindJSON(paramReq)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
userReq := middlewares.GetUser(c.Ctx)
paramReq.CompanyId = int(userReq.CompanyId)
data, err := srv.DeleteTaskInfo(paramReq)
c.Response(data, err)
}
... ...
... ... @@ -13,6 +13,7 @@ func init() {
web.NSBefore(filters.AllowCors(), middlewares.CheckAdminToken()),
web.NSCtrlPost("/info", (*controllers.TaskController).GetTaskInfo),
web.NSCtrlPut("/", (*controllers.TaskController).UpdateTask),
web.NSCtrlPost("/delete", (*controllers.TaskController).DeleteTask),
web.NSCtrlPost("/run", (*controllers.TaskController).RunTask),
web.NSCtrlPost("/stop", (*controllers.TaskController).StopTask),
web.NSCtrlPost("/list", (*controllers.TaskController).ListTask),
... ... @@ -23,9 +24,10 @@ func init() {
web.NSBefore(filters.AllowCors(), middlewares.CheckFontToken()),
web.NSCtrlPost("/attention/cancel", (*controllers.TaskController).CancelAttention),
web.NSCtrlPost("/list", (*controllers.TaskController).ListTask2),
web.NSCtrlPost("/task_record/list", (*controllers.TaskController).ListTaskRecord),
web.NSCtrlPost("/info", (*controllers.TaskController).GetTaskInfo),
)
web.AddNamespace(taskFontNS)
t := web.NewNamespace("/test/task",
web.NSCtrlPost("/", (*controllers.TaskController).CreateTask),
)
... ...