正在显示
6 个修改的文件
包含
66 行增加
和
24 行删除
@@ -18,9 +18,10 @@ type TaskAnomalyItem struct { | @@ -18,9 +18,10 @@ type TaskAnomalyItem struct { | ||
18 | TaskEndTime int64 `json:"taskEndTime"` // 任务截止的时间戳,单位:秒;等于0时表示未设置时间 | 18 | TaskEndTime int64 `json:"taskEndTime"` // 任务截止的时间戳,单位:秒;等于0时表示未设置时间 |
19 | TaskSortBy int `json:"taskSortBy"` // 优先级排序;值越小优先级越高 | 19 | TaskSortBy int `json:"taskSortBy"` // 优先级排序;值越小优先级越高 |
20 | RecordBegin int64 `json:"recordBegin"` // | 20 | RecordBegin int64 `json:"recordBegin"` // |
21 | - MarkA string `json:"markA"` // 去更新 | ||
22 | - MarkB string `json:"markB"` // 去反馈 | ||
23 | - MarkC string `json:"markC"` // 去求助 | ||
24 | - MarkD string `json:"markD"` // 去辅导 | ||
25 | - AnomalyDesc string `json:"anomalyDesc"` // 异常状况描述 | 21 | + CreatedAt string `json:"createdAt"` |
22 | + MarkA string `json:"markA"` // 去更新 | ||
23 | + MarkB string `json:"markB"` // 去反馈 | ||
24 | + MarkC string `json:"markC"` // 去求助 | ||
25 | + MarkD string `json:"markD"` // 去辅导 | ||
26 | + AnomalyDesc string `json:"anomalyDesc"` // 异常状况描述 | ||
26 | } | 27 | } |
@@ -3,5 +3,6 @@ package command | @@ -3,5 +3,6 @@ package command | ||
3 | type MarkTaskAnomalyCommand struct { | 3 | type MarkTaskAnomalyCommand struct { |
4 | Id int `json:"id,string"` //异常记录id | 4 | Id int `json:"id,string"` //异常记录id |
5 | CompanyId int `json:"-"` | 5 | CompanyId int `json:"-"` |
6 | + UserId int `json:"-"` | ||
6 | MarkType string `json:"markType"` //a:去更新,b:去反馈,c:去求助,d:去辅导 | 7 | MarkType string `json:"markType"` //a:去更新,b:去反馈,c:去求助,d:去辅导 |
7 | } | 8 | } |
@@ -73,6 +73,7 @@ func (srv TaskService) ListTaskAnomaly1(param *command.ListTaskAnomalyCommand) ( | @@ -73,6 +73,7 @@ func (srv TaskService) ListTaskAnomaly1(param *command.ListTaskAnomalyCommand) ( | ||
73 | TaskAlias: val.TaskAlias, | 73 | TaskAlias: val.TaskAlias, |
74 | TaskEndTime: int64(val.TaskEndTime), | 74 | TaskEndTime: int64(val.TaskEndTime), |
75 | TaskSortBy: val.TaskSortBy, | 75 | TaskSortBy: val.TaskSortBy, |
76 | + CreatedAt: val.CreatedAt.Local().Format("2006-01-02"), | ||
76 | RecordBegin: val.RecordBegin, | 77 | RecordBegin: val.RecordBegin, |
77 | MarkA: "", | 78 | MarkA: "", |
78 | MarkB: "", | 79 | MarkB: "", |
@@ -202,6 +203,7 @@ func (srv TaskService) ListTaskAnomaly2(param *command.ListTaskAnomalyCommand) ( | @@ -202,6 +203,7 @@ func (srv TaskService) ListTaskAnomaly2(param *command.ListTaskAnomalyCommand) ( | ||
202 | TaskEndTime: int64(val.TaskEndTime), | 203 | TaskEndTime: int64(val.TaskEndTime), |
203 | TaskSortBy: val.TaskSortBy, | 204 | TaskSortBy: val.TaskSortBy, |
204 | RecordBegin: val.RecordBegin, | 205 | RecordBegin: val.RecordBegin, |
206 | + CreatedAt: val.CreatedAt.Local().Format("2006-01-02"), | ||
205 | MarkA: "", | 207 | MarkA: "", |
206 | MarkB: "", | 208 | MarkB: "", |
207 | MarkC: "", | 209 | MarkC: "", |
@@ -327,6 +329,7 @@ func (srv TaskService) ListTaskAnomaly3(param *command.ListTaskAnomalyCommand) ( | @@ -327,6 +329,7 @@ func (srv TaskService) ListTaskAnomaly3(param *command.ListTaskAnomalyCommand) ( | ||
327 | TaskEndTime: int64(val.TaskEndTime), | 329 | TaskEndTime: int64(val.TaskEndTime), |
328 | TaskSortBy: val.TaskSortBy, | 330 | TaskSortBy: val.TaskSortBy, |
329 | RecordBegin: val.RecordBegin, | 331 | RecordBegin: val.RecordBegin, |
332 | + CreatedAt: val.CreatedAt.Local().Format("2006-01-02"), | ||
330 | MarkA: "", | 333 | MarkA: "", |
331 | MarkB: "", | 334 | MarkB: "", |
332 | MarkC: "", | 335 | MarkC: "", |
@@ -392,6 +395,12 @@ func (srv TaskService) ListTaskAnomaly3(param *command.ListTaskAnomalyCommand) ( | @@ -392,6 +395,12 @@ func (srv TaskService) ListTaskAnomaly3(param *command.ListTaskAnomalyCommand) ( | ||
392 | return result, nil | 395 | return result, nil |
393 | } | 396 | } |
394 | 397 | ||
398 | +// 异常详情 | ||
399 | +// func (srv TaskService) TaskAnomalyInfo() error { | ||
400 | + | ||
401 | +// return nil | ||
402 | +// } | ||
403 | + | ||
395 | func (srv TaskService) UserSelect(param *command.UserSelectCommand) []adapter.UserItem { | 404 | func (srv TaskService) UserSelect(param *command.UserSelectCommand) []adapter.UserItem { |
396 | transactionContext, err := factory.CreateTransactionContext(nil) | 405 | transactionContext, err := factory.CreateTransactionContext(nil) |
397 | if err != nil { | 406 | if err != nil { |
@@ -449,10 +458,10 @@ func (srv TaskService) UserSelect(param *command.UserSelectCommand) []adapter.Us | @@ -449,10 +458,10 @@ func (srv TaskService) UserSelect(param *command.UserSelectCommand) []adapter.Us | ||
449 | func (srv TaskService) MarkTaskAnomaly(param *command.MarkTaskAnomalyCommand) (map[string]string, error) { | 458 | func (srv TaskService) MarkTaskAnomaly(param *command.MarkTaskAnomalyCommand) (map[string]string, error) { |
450 | transactionContext, err := factory.CreateTransactionContext(nil) | 459 | transactionContext, err := factory.CreateTransactionContext(nil) |
451 | if err != nil { | 460 | if err != nil { |
452 | - return map[string]string{}, nil | 461 | + return map[string]string{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
453 | } | 462 | } |
454 | if err := transactionContext.StartTransaction(); err != nil { | 463 | if err := transactionContext.StartTransaction(); err != nil { |
455 | - return map[string]string{}, nil | 464 | + return map[string]string{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
456 | } | 465 | } |
457 | defer func() { | 466 | defer func() { |
458 | _ = transactionContext.RollbackTransaction() | 467 | _ = transactionContext.RollbackTransaction() |
@@ -460,21 +469,42 @@ func (srv TaskService) MarkTaskAnomaly(param *command.MarkTaskAnomalyCommand) (m | @@ -460,21 +469,42 @@ func (srv TaskService) MarkTaskAnomaly(param *command.MarkTaskAnomalyCommand) (m | ||
460 | taskAnomalyRepo := factory.CreateTaskAnomalyRepository(map[string]interface{}{ | 469 | taskAnomalyRepo := factory.CreateTaskAnomalyRepository(map[string]interface{}{ |
461 | "transactionContext": transactionContext, | 470 | "transactionContext": transactionContext, |
462 | }) | 471 | }) |
463 | - _, anomalyList, err := taskAnomalyRepo.Find(map[string]interface{}{"id": param.Id, "limit": 1}) | 472 | + taskRepo := factory.CreateTaskRepository(map[string]interface{}{ |
473 | + "transactionContext": transactionContext, | ||
474 | + }) | ||
475 | + _, anomalyList, err := taskAnomalyRepo.Find(map[string]interface{}{"id": param.Id, "companyId": param.CompanyId, "limit": 1}) | ||
464 | if err != nil { | 476 | if err != nil { |
465 | - | 477 | + return map[string]string{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
478 | + } | ||
479 | + if len(anomalyList) == 0 { | ||
480 | + return map[string]string{}, nil | ||
466 | } | 481 | } |
467 | - _ = anomalyList | ||
468 | - //MarkType= "a" 去更新,对应里程碑异常 | ||
469 | - //检查最新的异常记录,进行标记 | ||
470 | - //检查是否有任务相关连的每日评估 | ||
471 | - if param.MarkType == "a" { | ||
472 | 482 | ||
483 | + anomalyData := anomalyList[0] | ||
484 | + | ||
485 | + switch param.MarkType { | ||
486 | + case "a": | ||
487 | + anomalyData.MarkA() | ||
488 | + case "b": | ||
489 | + anomalyData.MarkB() | ||
490 | + case "c": | ||
491 | + anomalyData.MarkC() | ||
492 | + case "d": | ||
493 | + anomalyData.MarkD() | ||
494 | + } | ||
495 | + err = taskAnomalyRepo.Save(anomalyData) | ||
496 | + if err != nil { | ||
497 | + return map[string]string{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
473 | } | 498 | } |
474 | - // 或者 MarkType= "b" 去反馈,对应反馈异常 | ||
475 | - //MarkTYpe="c" // | ||
476 | - //MarkType = "d" | ||
477 | - //检查最新的异常记录,进行标记 | 499 | + if !(param.MarkType == "a" || param.MarkType == "b") { |
500 | + return map[string]string{}, nil | ||
501 | + } | ||
502 | + | ||
503 | + taskId := anomalyData.TaskId | ||
504 | + taskRepo.Find(map[string]interface{}{ | ||
505 | + "id": taskId, | ||
506 | + }) | ||
507 | + //检查是否有任务相关连的最新每日评估 | ||
478 | 508 | ||
479 | if err := transactionContext.CommitTransaction(); err != nil { | 509 | if err := transactionContext.CommitTransaction(); err != nil { |
480 | return map[string]string{}, nil | 510 | return map[string]string{}, nil |
@@ -112,12 +112,12 @@ func (t *TaskAnomaly) AnomalyDesc() (str string) { | @@ -112,12 +112,12 @@ func (t *TaskAnomaly) AnomalyDesc() (str string) { | ||
112 | return str | 112 | return str |
113 | } | 113 | } |
114 | 114 | ||
115 | -// 发送异常后的天数 | ||
116 | -func (t *TaskAnomaly) CountAnomalyDay() int { | ||
117 | - t1 := t.CreatedAt | ||
118 | - t2 := time.Unix(t.RecordBegin, 0) | ||
119 | - return xtime.SubDayAbs(t1, t2) | ||
120 | -} | 115 | +// 发生异常后的天数 |
116 | +// func (t *TaskAnomaly) CountAnomalyDay() int { | ||
117 | +// t1 := t.CreatedAt | ||
118 | +// t2 := time.Unix(t.RecordBegin, 0) | ||
119 | +// return xtime.SubDayAbs(t1, t2) | ||
120 | +// } | ||
121 | 121 | ||
122 | // 存储 | 122 | // 存储 |
123 | type TaskAnomalyRepository interface { | 123 | type TaskAnomalyRepository interface { |
@@ -118,6 +118,9 @@ func (repo *TaskAnomalyRepository) Find(queryOptions map[string]interface{}) (in | @@ -118,6 +118,9 @@ func (repo *TaskAnomalyRepository) Find(queryOptions map[string]interface{}) (in | ||
118 | if val, ok := queryOptions["id"]; ok { | 118 | if val, ok := queryOptions["id"]; ok { |
119 | query.Where(" id=? ", val) | 119 | query.Where(" id=? ", val) |
120 | } | 120 | } |
121 | + if val, ok := queryOptions["companyId"]; ok { | ||
122 | + query.Where(" company_id=? ", val) | ||
123 | + } | ||
121 | if val, ok := queryOptions["taskId"]; ok { | 124 | if val, ok := queryOptions["taskId"]; ok { |
122 | query.Where(" task_id=? ", val) | 125 | query.Where(" task_id=? ", val) |
123 | } | 126 | } |
-
请 注册 或 登录 后发表评论