正在显示
5 个修改的文件
包含
96 行增加
和
3 行删除
@@ -28,4 +28,5 @@ type TaskStage struct { | @@ -28,4 +28,5 @@ type TaskStage struct { | ||
28 | SortBy int `json:"sortBy"` | 28 | SortBy int `json:"sortBy"` |
29 | PlanCompletedAt string `json:"planCompletedAt,omitempty"` //计划完成时间, 例:2006-01-02 | 29 | PlanCompletedAt string `json:"planCompletedAt,omitempty"` //计划完成时间, 例:2006-01-02 |
30 | RealCompletedAt string `json:"realCompletedAt,omitempty"` //实际完成时间, 例:2006-01-02 | 30 | RealCompletedAt string `json:"realCompletedAt,omitempty"` //实际完成时间, 例:2006-01-02 |
31 | + IsRef bool `json:"isRef"` //是否已经被下发 | ||
31 | } | 32 | } |
pkg/application/task/command/delete_task.go
0 → 100644
@@ -327,6 +327,18 @@ func (srv TaskService) GetTaskInfo(param *command.GetTaskCommand) (*adapter.Task | @@ -327,6 +327,18 @@ func (srv TaskService) GetTaskInfo(param *command.GetTaskCommand) (*adapter.Task | ||
327 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取相关人员"+err.Error()) | 327 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取相关人员"+err.Error()) |
328 | } | 328 | } |
329 | } | 329 | } |
330 | + | ||
331 | + //查询是否已经有每日评估 | ||
332 | + taskRecordRepo := factory.CreateTaskRecordRepository(map[string]interface{}{ | ||
333 | + "transactionContext": transactionContext, | ||
334 | + }) | ||
335 | + cnt, _, err := taskRecordRepo.Find(map[string]interface{}{ | ||
336 | + "taskId": param.TaskId, | ||
337 | + "limit": 1, | ||
338 | + }) | ||
339 | + if err != nil { | ||
340 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "相关联的任务反馈信息"+err.Error()) | ||
341 | + } | ||
330 | if err := transactionContext.CommitTransaction(); err != nil { | 342 | if err := transactionContext.CommitTransaction(); err != nil { |
331 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 343 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
332 | } | 344 | } |
@@ -368,14 +380,18 @@ func (srv TaskService) GetTaskInfo(param *command.GetTaskCommand) (*adapter.Task | @@ -368,14 +380,18 @@ func (srv TaskService) GetTaskInfo(param *command.GetTaskCommand) (*adapter.Task | ||
368 | if val.RealCompletedAt > 0 { | 380 | if val.RealCompletedAt > 0 { |
369 | t2 = time.Unix(val.RealCompletedAt, 0).Local().Format("2006-01-02") | 381 | t2 = time.Unix(val.RealCompletedAt, 0).Local().Format("2006-01-02") |
370 | } | 382 | } |
371 | - result.StageList = append(result.StageList, adapter.TaskStage{ | 383 | + stage := adapter.TaskStage{ |
372 | Id: val.Id, | 384 | Id: val.Id, |
373 | Name: val.Name, | 385 | Name: val.Name, |
374 | PlanCompletedAt: t1, | 386 | PlanCompletedAt: t1, |
375 | RealCompletedAt: t2, | 387 | RealCompletedAt: t2, |
376 | SortBy: val.SortBy, | 388 | SortBy: val.SortBy, |
377 | StatusDescription: val.StatusDescription(), | 389 | StatusDescription: val.StatusDescription(), |
378 | - }) | 390 | + } |
391 | + if cnt > 0 { | ||
392 | + stage.IsRef = true | ||
393 | + } | ||
394 | + result.StageList = append(result.StageList, stage) | ||
379 | } | 395 | } |
380 | return &result, nil | 396 | return &result, nil |
381 | } | 397 | } |
@@ -907,3 +923,39 @@ func (srv TaskService) ListTaskRecord(param *command.ListTaskRecordCommand) (map | @@ -907,3 +923,39 @@ func (srv TaskService) ListTaskRecord(param *command.ListTaskRecordCommand) (map | ||
907 | result := tool_funs.SimpleWrapGridMap(int64(cnt), resultList) | 923 | result := tool_funs.SimpleWrapGridMap(int64(cnt), resultList) |
908 | return result, nil | 924 | return result, nil |
909 | } | 925 | } |
926 | + | ||
927 | +// 获取任务详情 | ||
928 | +func (srv TaskService) DeleteTaskInfo(param *command.GetTaskCommand) (*adapter.TaskInfoAdapter, error) { | ||
929 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
930 | + if err != nil { | ||
931 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
932 | + } | ||
933 | + if err := transactionContext.StartTransaction(); err != nil { | ||
934 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
935 | + } | ||
936 | + defer func() { | ||
937 | + _ = transactionContext.RollbackTransaction() | ||
938 | + }() | ||
939 | + taskRepo := factory.CreateTaskRepository(map[string]interface{}{ | ||
940 | + "transactionContext": transactionContext, | ||
941 | + }) | ||
942 | + taskData, err := taskRepo.FindOne(map[string]interface{}{ | ||
943 | + "id": param.TaskId, | ||
944 | + }) | ||
945 | + if err != nil { | ||
946 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "xx"+err.Error()) | ||
947 | + } | ||
948 | + if taskData.CompanyId != param.CompanyId { | ||
949 | + return nil, nil | ||
950 | + } | ||
951 | + nowTime := time.Now() | ||
952 | + taskData.DeletedAt = &nowTime | ||
953 | + err = taskRepo.Save(taskData) | ||
954 | + if err != nil { | ||
955 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "xx"+err.Error()) | ||
956 | + } | ||
957 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
958 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
959 | + } | ||
960 | + return nil, nil | ||
961 | +} |
@@ -139,3 +139,35 @@ func (c *TaskController) ListTask2() { | @@ -139,3 +139,35 @@ func (c *TaskController) ListTask2() { | ||
139 | result, err := srv.ListTask2(paramReq) | 139 | result, err := srv.ListTask2(paramReq) |
140 | c.Response(result, err) | 140 | c.Response(result, err) |
141 | } | 141 | } |
142 | + | ||
143 | +// ListTaskRecord 员工绩效-获取任务反馈列表 | ||
144 | +func (c *TaskController) ListTaskRecord() { | ||
145 | + srv := service.NewTaskService() | ||
146 | + paramReq := &command.ListTaskRecordCommand{} | ||
147 | + err := c.BindJSON(paramReq) | ||
148 | + if err != nil { | ||
149 | + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error()) | ||
150 | + c.Response(nil, e) | ||
151 | + return | ||
152 | + } | ||
153 | + userReq := middlewares.GetUser(c.Ctx) | ||
154 | + paramReq.CompanyId = int(userReq.CompanyId) | ||
155 | + result, err := srv.ListTaskRecord(paramReq) | ||
156 | + c.Response(result, err) | ||
157 | +} | ||
158 | + | ||
159 | +// DeleteTask 删除任务 | ||
160 | +func (c *TaskController) DeleteTask() { | ||
161 | + srv := service.NewTaskService() | ||
162 | + paramReq := &command.GetTaskCommand{} | ||
163 | + err := c.BindJSON(paramReq) | ||
164 | + if err != nil { | ||
165 | + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error()) | ||
166 | + c.Response(nil, e) | ||
167 | + return | ||
168 | + } | ||
169 | + userReq := middlewares.GetUser(c.Ctx) | ||
170 | + paramReq.CompanyId = int(userReq.CompanyId) | ||
171 | + data, err := srv.DeleteTaskInfo(paramReq) | ||
172 | + c.Response(data, err) | ||
173 | +} |
@@ -13,6 +13,7 @@ func init() { | @@ -13,6 +13,7 @@ func init() { | ||
13 | web.NSBefore(filters.AllowCors(), middlewares.CheckAdminToken()), | 13 | web.NSBefore(filters.AllowCors(), middlewares.CheckAdminToken()), |
14 | web.NSCtrlPost("/info", (*controllers.TaskController).GetTaskInfo), | 14 | web.NSCtrlPost("/info", (*controllers.TaskController).GetTaskInfo), |
15 | web.NSCtrlPut("/", (*controllers.TaskController).UpdateTask), | 15 | web.NSCtrlPut("/", (*controllers.TaskController).UpdateTask), |
16 | + web.NSCtrlPost("/delete", (*controllers.TaskController).DeleteTask), | ||
16 | web.NSCtrlPost("/run", (*controllers.TaskController).RunTask), | 17 | web.NSCtrlPost("/run", (*controllers.TaskController).RunTask), |
17 | web.NSCtrlPost("/stop", (*controllers.TaskController).StopTask), | 18 | web.NSCtrlPost("/stop", (*controllers.TaskController).StopTask), |
18 | web.NSCtrlPost("/list", (*controllers.TaskController).ListTask), | 19 | web.NSCtrlPost("/list", (*controllers.TaskController).ListTask), |
@@ -23,9 +24,10 @@ func init() { | @@ -23,9 +24,10 @@ func init() { | ||
23 | web.NSBefore(filters.AllowCors(), middlewares.CheckFontToken()), | 24 | web.NSBefore(filters.AllowCors(), middlewares.CheckFontToken()), |
24 | web.NSCtrlPost("/attention/cancel", (*controllers.TaskController).CancelAttention), | 25 | web.NSCtrlPost("/attention/cancel", (*controllers.TaskController).CancelAttention), |
25 | web.NSCtrlPost("/list", (*controllers.TaskController).ListTask2), | 26 | web.NSCtrlPost("/list", (*controllers.TaskController).ListTask2), |
27 | + web.NSCtrlPost("/task_record/list", (*controllers.TaskController).ListTaskRecord), | ||
28 | + web.NSCtrlPost("/info", (*controllers.TaskController).GetTaskInfo), | ||
26 | ) | 29 | ) |
27 | web.AddNamespace(taskFontNS) | 30 | web.AddNamespace(taskFontNS) |
28 | - | ||
29 | t := web.NewNamespace("/test/task", | 31 | t := web.NewNamespace("/test/task", |
30 | web.NSCtrlPost("/", (*controllers.TaskController).CreateTask), | 32 | web.NSCtrlPost("/", (*controllers.TaskController).CreateTask), |
31 | ) | 33 | ) |
-
请 注册 或 登录 后发表评论