正在显示
9 个修改的文件
包含
418 行增加
和
80 行删除
pkg/application/task/adapter/task_anomaly.go
0 → 100644
1 | +package adapter | ||
2 | + | ||
3 | +type TaskAnomalyItem struct { | ||
4 | + Id int `json:"id"` | ||
5 | + TaskId int `json:"taskId,string"` // 任务id | ||
6 | + Category int `json:"category"` // 异常分类 | ||
7 | + Leader string `json:"leader"` // 任务负责人 | ||
8 | + CurrentStage TaskStage `json:"currentStage"` // 计划进度的里程碑 | ||
9 | + LastStage TaskStage `json:"lastStage"` // 实际进度完成的里程碑 | ||
10 | + TaskStageCheck TaskStage `json:"taskStageCheck"` | ||
11 | + AssessFlag int `json:"anomaly"` // 异常反馈的次数 | ||
12 | + WarnFlag int `json:"warnFlag"` // 里程碑异常次数 | ||
13 | + AssistFlag int `json:"assistFlag"` // 辅导异常次数 | ||
14 | + TaskLevel string `json:"taskLevel"` // 任务类型 | ||
15 | + TaskName string `json:"taskName"` // 任务名称 | ||
16 | + TaskAlias string `json:"taskAlias"` // 任务别名 | ||
17 | + TaskEndTime int64 `json:"taskEndTime"` // 任务截止的时间戳,单位:秒;等于0时表示未设置时间 | ||
18 | + TaskSortBy int `json:"taskSortBy"` // 优先级排序;值越小优先级越高 | ||
19 | + RecordBegin int64 `json:"recordBegin"` // | ||
20 | + MarkA string `json:"markA"` // 去更新 | ||
21 | + MarkB string `json:"markB"` // 去反馈 | ||
22 | + MarkC string `json:"markC"` // 去求助 | ||
23 | + MarkD string `json:"markD"` // 去辅导 | ||
24 | + AnomalyDesc string `json:"anomalyDesc"` // 异常状况描述 | ||
25 | +} | ||
26 | + | ||
27 | +// func (t *TaskAnomalyItem) GenAnomalyDesc() { | ||
28 | +// nowTime := time.Now() | ||
29 | +// var str string | ||
30 | +// switch t.Category { | ||
31 | +// case 1: | ||
32 | +// //里程碑异常 | ||
33 | +// { | ||
34 | +// if t.TaskStageCheck.RealCompletedAt == 0 { | ||
35 | +// //逾期未完成 | ||
36 | +// planCompletedAt := time.Unix(t.TaskStageCheck.PlanCompletedAt, 0) | ||
37 | +// subDay := xtime.SubDayAbs(nowTime, planCompletedAt) | ||
38 | +// str = fmt.Sprintf("里程碑%s已逾期%d天", t.TaskStageCheck.Name, subDay) | ||
39 | +// } else { | ||
40 | +// //逾期完成 | ||
41 | +// planCompletedAt := time.Unix(t.TaskStageCheck.PlanCompletedAt, 0) | ||
42 | +// realCompletedAt := time.Unix(t.TaskStageCheck.RealCompletedAt, 0) | ||
43 | +// subDay := xtime.SubDayAbs(realCompletedAt, planCompletedAt) | ||
44 | +// str = fmt.Sprintf("里程碑%s逾期%d天完成", t.TaskStageCheck.Name, subDay) | ||
45 | + | ||
46 | +// } | ||
47 | +// } | ||
48 | +// case 2: | ||
49 | +// //反馈异常 | ||
50 | +// { | ||
51 | +// recordBegin := time.Unix(t.RecordBegin, 0) | ||
52 | +// subDay := xtime.SubDayAbs(nowTime, recordBegin) | ||
53 | +// str = fmt.Sprintf( | ||
54 | +// "本任务自%s未正常反馈项目进度,已异常%d天", | ||
55 | +// recordBegin.Local().Format("2006-01-02"), | ||
56 | +// subDay, | ||
57 | +// ) | ||
58 | + | ||
59 | +// } | ||
60 | +// case 3: | ||
61 | +// // 辅导异常 | ||
62 | +// { | ||
63 | +// recordBegin := time.Unix(t.RecordBegin, 0) | ||
64 | +// subDay := xtime.SubDayAbs(nowTime, recordBegin) | ||
65 | +// str = fmt.Sprintf( | ||
66 | +// "本任务计划于%s完成辅导,已逾期%d天", | ||
67 | +// recordBegin.Local().Format("2006-01-02"), | ||
68 | +// subDay, | ||
69 | +// ) | ||
70 | + | ||
71 | +// } | ||
72 | +// } | ||
73 | +// } |
1 | package command | 1 | package command |
2 | 2 | ||
3 | type ListTaskAnomalyCommand struct { | 3 | type ListTaskAnomalyCommand struct { |
4 | - PageNumber int `json:"pageNumber"` | ||
5 | - PageSize int `json:"pageSize"` | ||
6 | - UserId int `json:"-"` | ||
7 | - CompanyId int `json:"-"` | ||
8 | - DayTime string `json:"DayTime"` | ||
9 | - TaskLeader int `json:"taskLeader,string"` | 4 | + PageNumber int `json:"pageNumber"` |
5 | + PageSize int `json:"pageSize"` | ||
6 | + UserId int `json:"-"` | ||
7 | + CompanyId int `json:"-"` | ||
8 | + TaskName string `json:"taskName"` | ||
9 | + DayTime string `json:"dayTime"` //发生异常的日期 | ||
10 | + Category int `json:"category"` //异常分类 | ||
11 | + TaskLeaderId string `json:"taskLeaderId"` //任务负责人id | ||
10 | } | 12 | } |
@@ -147,11 +147,6 @@ func isWarnFlag(transactionContext application.TransactionContext, taskData *dom | @@ -147,11 +147,6 @@ func isWarnFlag(transactionContext application.TransactionContext, taskData *dom | ||
147 | WarnFlag: int(taskData.WarnFlag), | 147 | WarnFlag: int(taskData.WarnFlag), |
148 | AssistFlag: 0, | 148 | AssistFlag: 0, |
149 | IsLast: 1, | 149 | IsLast: 1, |
150 | - TaskLevel: taskData.LevelName, | ||
151 | - TaskName: taskData.Name, | ||
152 | - TaskAlias: taskData.Alias, | ||
153 | - TaskSortBy: taskData.SortBy, | ||
154 | - TaskEndTime: taskData.EndTime, | ||
155 | RecordBegin: taskRecord.CreatedAt.Unix(), | 150 | RecordBegin: taskRecord.CreatedAt.Unix(), |
156 | NoticeWho: []map[string]string{}, | 151 | NoticeWho: []map[string]string{}, |
157 | Marks: map[string]string{ | 152 | Marks: map[string]string{ |
@@ -253,11 +248,6 @@ func isAssistFlag(transactionContext application.TransactionContext, taskData *d | @@ -253,11 +248,6 @@ func isAssistFlag(transactionContext application.TransactionContext, taskData *d | ||
253 | WarnFlag: 0, | 248 | WarnFlag: 0, |
254 | AssistFlag: taskData.AssistFlag, | 249 | AssistFlag: taskData.AssistFlag, |
255 | IsLast: 1, | 250 | IsLast: 1, |
256 | - TaskLevel: taskData.LevelName, | ||
257 | - TaskName: taskData.Name, | ||
258 | - TaskAlias: taskData.Alias, | ||
259 | - TaskSortBy: taskData.SortBy, | ||
260 | - TaskEndTime: taskData.EndTime, | ||
261 | RecordBegin: taskRecord.CreatedAt.Unix(), | 251 | RecordBegin: taskRecord.CreatedAt.Unix(), |
262 | NoticeWho: []map[string]string{}, | 252 | NoticeWho: []map[string]string{}, |
263 | Marks: map[string]string{ | 253 | Marks: map[string]string{ |
@@ -369,11 +359,6 @@ func isAssessFlag(transactionContext application.TransactionContext, taskData *d | @@ -369,11 +359,6 @@ func isAssessFlag(transactionContext application.TransactionContext, taskData *d | ||
369 | WarnFlag: 0, | 359 | WarnFlag: 0, |
370 | AssistFlag: 0, | 360 | AssistFlag: 0, |
371 | IsLast: 1, | 361 | IsLast: 1, |
372 | - TaskLevel: taskData.LevelName, | ||
373 | - TaskName: taskData.Name, | ||
374 | - TaskAlias: taskData.Alias, | ||
375 | - TaskSortBy: taskData.SortBy, | ||
376 | - TaskEndTime: taskData.EndTime, | ||
377 | RecordBegin: taskRecord.CreatedAt.Unix(), | 362 | RecordBegin: taskRecord.CreatedAt.Unix(), |
378 | NoticeWho: []map[string]string{}, | 363 | NoticeWho: []map[string]string{}, |
379 | Marks: map[string]string{ | 364 | Marks: map[string]string{ |
1 | package service | 1 | package service |
2 | 2 | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "time" | ||
6 | + | ||
7 | + "github.com/linmadan/egglib-go/core/application" | ||
8 | + "github.com/linmadan/egglib-go/utils/tool_funs" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/task/adapter" | ||
11 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/task/command" | ||
12 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao" | ||
13 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/utils/xtime" | ||
14 | +) | ||
15 | + | ||
3 | // 异常中心查看 | 16 | // 异常中心查看 |
4 | 17 | ||
5 | // 我负责的任务,异常列表 | 18 | // 我负责的任务,异常列表 |
19 | +func (srv TaskService) ListTaskAnomaly1(param command.ListTaskAnomalyCommand) (map[string]interface{}, error) { | ||
20 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
21 | + if err != nil { | ||
22 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
23 | + } | ||
24 | + if err := transactionContext.StartTransaction(); err != nil { | ||
25 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
26 | + } | ||
27 | + defer func() { | ||
28 | + _ = transactionContext.RollbackTransaction() | ||
29 | + }() | ||
30 | + taskAnomalyDao := dao.NewTaskAnomalyDao(map[string]interface{}{ | ||
31 | + "transactionContext": transactionContext, | ||
32 | + }) | ||
33 | + limit := 500 | ||
34 | + offset := 0 | ||
35 | + cnt, anomalyList, err := taskAnomalyDao.List1(param.UserId, param.CompanyId, param.TaskName, param.Category, param.DayTime, limit, offset) | ||
36 | + if err != nil { | ||
37 | + return map[string]interface{}{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
38 | + } | ||
39 | + | ||
40 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
41 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
42 | + } | ||
43 | + | ||
44 | + listData := []adapter.TaskAnomalyItem{} | ||
45 | + nowTime := time.Now() | ||
46 | + for _, val := range anomalyList { | ||
47 | + item := adapter.TaskAnomalyItem{ | ||
48 | + Id: val.Id, | ||
49 | + TaskId: val.TaskId, | ||
50 | + Category: val.Category, | ||
51 | + Leader: val.LeaderName, | ||
52 | + CurrentStage: adapter.TaskStage{ | ||
53 | + Id: val.CurrentStage.Id, | ||
54 | + Name: val.CurrentStage.Name, | ||
55 | + StatusDescription: val.CurrentStage.StatusDescription(), | ||
56 | + SortBy: val.CurrentStage.SortBy, | ||
57 | + PlanCompletedAt: time.Unix(val.CurrentStage.PlanCompletedAt, 0).Local().Format("2006-01-02"), | ||
58 | + RealCompletedAt: "", | ||
59 | + }, | ||
60 | + LastStage: adapter.TaskStage{ | ||
61 | + Id: val.LastStage.Id, | ||
62 | + Name: val.LastStage.Name, | ||
63 | + StatusDescription: val.LastStage.StatusDescription(), | ||
64 | + SortBy: val.LastStage.SortBy, | ||
65 | + PlanCompletedAt: time.Unix(val.LastStage.PlanCompletedAt, 0).Local().Format("2006-01-02"), | ||
66 | + RealCompletedAt: "", | ||
67 | + }, | ||
68 | + AssessFlag: val.AssessFlag, | ||
69 | + WarnFlag: val.WarnFlag, | ||
70 | + AssistFlag: val.AssistFlag, | ||
71 | + TaskLevel: val.LevelName, | ||
72 | + TaskName: val.TaskName, | ||
73 | + TaskAlias: val.TaskAlias, | ||
74 | + TaskEndTime: int64(val.TaskEndTime), | ||
75 | + TaskSortBy: val.TaskSortBy, | ||
76 | + RecordBegin: val.RecordBegin, | ||
77 | + MarkA: "", | ||
78 | + MarkB: "", | ||
79 | + MarkC: "", | ||
80 | + MarkD: "", | ||
81 | + } | ||
82 | + if len(val.Marks) > 0 { | ||
83 | + item.MarkA = val.Marks["a"] | ||
84 | + item.MarkB = val.Marks["b"] | ||
85 | + item.MarkC = val.Marks["c"] | ||
86 | + item.MarkD = val.Marks["d"] | ||
87 | + } | ||
88 | + if val.TaskStageCheck.RealCompletedAt > 0 { | ||
89 | + item.TaskStageCheck.RealCompletedAt = time.Unix(val.TaskStageCheck.RealCompletedAt, 0).Local().Format("2006-01-02") | ||
90 | + } | ||
91 | + if val.CurrentStage.RealCompletedAt > 0 { | ||
92 | + item.CurrentStage.RealCompletedAt = time.Unix(val.CurrentStage.RealCompletedAt, 0).Local().Format("2006-01-02") | ||
93 | + } | ||
94 | + if val.LastStage.RealCompletedAt > 0 { | ||
95 | + item.LastStage.RealCompletedAt = time.Unix(val.LastStage.RealCompletedAt, 0).Local().Format("2006-01-02") | ||
96 | + } | ||
97 | + switch val.Category { | ||
98 | + case 1: | ||
99 | + { | ||
100 | + //里程碑异常 | ||
101 | + if val.TaskStageCheck.RealCompletedAt == 0 { | ||
102 | + //逾期未完成 | ||
103 | + planCompletedAt := time.Unix(val.TaskStageCheck.PlanCompletedAt, 0) | ||
104 | + subDay := xtime.SubDayAbs(nowTime, planCompletedAt) | ||
105 | + item.AnomalyDesc = fmt.Sprintf("里程碑%s已逾期%d天", val.TaskStageCheck.Name, subDay) | ||
106 | + } else { | ||
107 | + //逾期完成 | ||
108 | + planCompletedAt := time.Unix(val.TaskStageCheck.PlanCompletedAt, 0) | ||
109 | + realCompletedAt := time.Unix(val.TaskStageCheck.RealCompletedAt, 0) | ||
110 | + subDay := xtime.SubDayAbs(realCompletedAt, planCompletedAt) | ||
111 | + item.AnomalyDesc = fmt.Sprintf("里程碑%s逾期%d天完成", val.TaskStageCheck.Name, subDay) | ||
112 | + } | ||
113 | + } | ||
114 | + case 2: | ||
115 | + //反馈异常 | ||
116 | + { | ||
117 | + recordBegin := time.Unix(val.RecordBegin, 0) | ||
118 | + subDay := xtime.SubDayAbs(nowTime, recordBegin) | ||
119 | + item.AnomalyDesc = fmt.Sprintf( | ||
120 | + "本任务自%s未正常反馈项目进度,已异常%d天", | ||
121 | + recordBegin.Local().Format("2006-01-02"), | ||
122 | + subDay, | ||
123 | + ) | ||
124 | + } | ||
125 | + case 3: | ||
126 | + //辅导异常 | ||
127 | + { | ||
128 | + recordBegin := time.Unix(val.RecordBegin, 0) | ||
129 | + subDay := xtime.SubDayAbs(nowTime, recordBegin) | ||
130 | + item.AnomalyDesc = fmt.Sprintf( | ||
131 | + "本任务计划于%s完成辅导,已逾期%d天", | ||
132 | + recordBegin.Local().Format("2006-01-02"), | ||
133 | + subDay, | ||
134 | + ) | ||
135 | + } | ||
136 | + } | ||
137 | + | ||
138 | + listData = append(listData, item) | ||
139 | + } | ||
140 | + | ||
141 | + result := tool_funs.SimpleWrapGridMap(int64(cnt), listData) | ||
142 | + return result, nil | ||
143 | +} | ||
144 | + | ||
145 | +// 我的下级负责任务,异常列表 | ||
146 | +func (srv TaskService) ListTaskAnomaly2() {} | ||
147 | + | ||
148 | +// 与我有关的任务,异常列表 | ||
149 | +func (srv TaskService) ListTaskAnomaly3() {} | ||
150 | + | ||
151 | +// 对异常记录的操作标记 | ||
152 | +func (srv TaskService) MarkTaskAnomaly() {} |
@@ -14,7 +14,7 @@ type TaskAnomaly struct { | @@ -14,7 +14,7 @@ type TaskAnomaly struct { | ||
14 | CreatedAt time.Time `json:"createdAt"` | 14 | CreatedAt time.Time `json:"createdAt"` |
15 | UpdatedAt time.Time `json:"updatedAt"` | 15 | UpdatedAt time.Time `json:"updatedAt"` |
16 | CompanyId int `json:"companyId,string"` | 16 | CompanyId int `json:"companyId,string"` |
17 | - TaskId int `jsom:"taskId,string"` // 任务id | 17 | + TaskId int `json:"taskId,string"` // 任务id |
18 | TaskRecordId int `json:"taskRecordId,string"` // 任务反馈的进度 | 18 | TaskRecordId int `json:"taskRecordId,string"` // 任务反馈的进度 |
19 | Category int `json:"category"` // 异常记录的分类 1 里程碑异常;2反馈异常 ;3 辅导异常 | 19 | Category int `json:"category"` // 异常记录的分类 1 里程碑异常;2反馈异常 ;3 辅导异常 |
20 | CurrentStage TaskStage `json:"currentStage"` // 计划进度的里程碑 | 20 | CurrentStage TaskStage `json:"currentStage"` // 计划进度的里程碑 |
@@ -24,11 +24,6 @@ type TaskAnomaly struct { | @@ -24,11 +24,6 @@ type TaskAnomaly struct { | ||
24 | WarnFlag int `json:"warnFlag"` // 里程碑异常次数 | 24 | WarnFlag int `json:"warnFlag"` // 里程碑异常次数 |
25 | AssistFlag int `json:"assistFlag"` // 辅导异常次数 | 25 | AssistFlag int `json:"assistFlag"` // 辅导异常次数 |
26 | IsLast int `json:"isLast"` // 是否是最新的一条记录 1 是最新的记录 2 不是最新的记录 | 26 | IsLast int `json:"isLast"` // 是否是最新的一条记录 1 是最新的记录 2 不是最新的记录 |
27 | - TaskLevel string `json:"taskLevel"` // 任务类型 | ||
28 | - TaskName string `json:"taskName"` // 任务名称 | ||
29 | - TaskAlias string `json:"taskAlias"` // 任务别名 | ||
30 | - TaskSortBy TaskSortBy `json:"taskSortBy"` // 优先级排序;值越小优先级越高 | ||
31 | - TaskEndTime int64 `json:"taskEndTime"` // 任务截止的时间戳,单位:秒;等于0时表示未设置时间 | ||
32 | RecordBegin int64 `json:"recordBegin"` // 异常记录的开始时间 | 27 | RecordBegin int64 `json:"recordBegin"` // 异常记录的开始时间 |
33 | NoticeWho []map[string]string `json:"noticeWho"` // 异常记录消息通知的人 | 28 | NoticeWho []map[string]string `json:"noticeWho"` // 异常记录消息通知的人 |
34 | Marks map[string]string `json:"marks"` // 已经操作的标记 | 29 | Marks map[string]string `json:"marks"` // 已经操作的标记 |
1 | package dao | 1 | package dao |
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | + "fmt" | ||
5 | + | ||
6 | + "github.com/go-pg/pg/v10" | ||
4 | pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | 7 | pgTransaction "github.com/linmadan/egglib-go/transaction/pg" |
5 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | 8 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" |
6 | ) | 9 | ) |
@@ -20,27 +23,104 @@ func NewTaskAnomalyDao(options map[string]interface{}) *TaskAnomalyDao { | @@ -20,27 +23,104 @@ func NewTaskAnomalyDao(options map[string]interface{}) *TaskAnomalyDao { | ||
20 | } | 23 | } |
21 | } | 24 | } |
22 | 25 | ||
26 | +type ListTaskAnomaly struct { | ||
27 | + Id int `pg:"id"` | ||
28 | + TaskId int `pg:"task_id"` | ||
29 | + Category int `pg:"category"` | ||
30 | + CurrentStage domain.TaskStage `pg:"current_stage"` // 计划执行的里程碑 | ||
31 | + LastStage domain.TaskStage `pg:"last_stage"` // 上一个完成的里程碑 | ||
32 | + TaskStageCheck domain.TaskStage `pg:"task_stage_check"` // | ||
33 | + AssessFlag int `pg:"assess_flag"` | ||
34 | + WarnFlag int `pg:"warn_flag"` | ||
35 | + AssistFlag int `pg:"assist_flag"` | ||
36 | + RecordBegin int64 `pg:"record_begin"` | ||
37 | + Marks map[string]string `pg:"marks"` | ||
38 | + NoticeWho []map[string]string `pg:"notice_who"` | ||
39 | + TaskAlias string `pg:"task_alias"` | ||
40 | + TaskName string `pg:"task_name"` | ||
41 | + TaskEndTime int `pg:"task_end_time"` | ||
42 | + TaskSortBy int `pg:"task_sort_by"` | ||
43 | + LeaderName string `pg:"leader_name"` | ||
44 | + LevelName string `pg:"level_name"` | ||
45 | +} | ||
46 | + | ||
23 | // 异常的任务记录, 获取我负责的任务 | 47 | // 异常的任务记录, 获取我负责的任务 |
24 | // userId 谁要查看数据 | 48 | // userId 谁要查看数据 |
25 | // companyId 公司id | 49 | // companyId 公司id |
26 | // dayTime 搜索条件日期 ,例:"2006-01-02" | 50 | // dayTime 搜索条件日期 ,例:"2006-01-02" |
27 | // pageSize 分页大小 | 51 | // pageSize 分页大小 |
28 | // pageNumber 分页页码 | 52 | // pageNumber 分页页码 |
29 | -func (d *TaskAnomalyDao) List1(userId int, companyId int, dayTime string, pageSize int, pageNumber int) (int, []*domain.Task, error) { | ||
30 | - | ||
31 | - // with t_task_ignore as ( | ||
32 | - // select task_ignore.id ,task_ignore.task_id | ||
33 | - // from task_ignore | ||
34 | - // where user_id = 0 | ||
35 | - // ) | ||
36 | - // select * | ||
37 | - // from task as task_anomaly | ||
38 | - // left join t_task_ignore on task_anomaly.id=t_task_ignore.task_id | ||
39 | - // where t_task_ignore.id isnull and task_anomaly.company_id =? | ||
40 | - // order by task_anomaly.id desc | ||
41 | - // limit 20 | ||
42 | - | ||
43 | - return 0, nil, nil | 53 | +func (d *TaskAnomalyDao) List1(userId int, companyId int, taskName string, category int, dayTime string, limit int, offset int) (int, []ListTaskAnomaly, error) { |
54 | + sqlStr1 := ` with t_task_ignore as ( | ||
55 | + select task_ignore.id ,task_ignore.task_id | ||
56 | + from task_ignore | ||
57 | + where user_id = ? | ||
58 | + )select | ||
59 | + task_anomaly.id, | ||
60 | + task_anomaly.task_id, | ||
61 | + task_anomaly.category, | ||
62 | + task_anomaly.current_stage, | ||
63 | + task_anomaly.last_stage, | ||
64 | + task_anomaly.task_stage_check, | ||
65 | + task_anomaly.assess_flag, | ||
66 | + task_anomaly.warn_flag, | ||
67 | + task_anomaly.assist_flag, | ||
68 | + task_anomaly.record_begin, | ||
69 | + task_anomaly.marks, | ||
70 | + task_anomaly.notice_who, | ||
71 | + task.alias as "task_alias", | ||
72 | + task."name" as "task_name", | ||
73 | + task.end_time as "task_end_time", | ||
74 | + task.sort_by as "task_sort_by", | ||
75 | + task.leader->>'name' as "leader_name", | ||
76 | + task.level_name | ||
77 | + from task_anomaly | ||
78 | + join task on task.id = task_anomaly.task_id | ||
79 | + left join t_task_ignore on task_anomaly.task_id=t_task_ignore.task_id | ||
80 | + where t_task_ignore.id isnull and task.deleted_at isnull | ||
81 | + and task_anomaly.company_id = ? | ||
82 | + and task.leader->>'id'='?' ` | ||
83 | + | ||
84 | + sqlStr2 := ` with t_task_ignore as ( | ||
85 | + select task_ignore.id ,task_ignore.task_id | ||
86 | + from task_ignore | ||
87 | + where user_id = ? | ||
88 | + )select count(*) as cnt | ||
89 | + from task_anomaly | ||
90 | + join task on task.id = task_anomaly.task_id | ||
91 | + left join t_task_ignore on task_anomaly.task_id=t_task_ignore.task_id | ||
92 | + where t_task_ignore.id isnull and task.deleted_at isnull | ||
93 | + and task_anomaly.company_id = ? | ||
94 | + and task.leader->>'id'='?' ` | ||
95 | + | ||
96 | + condition := []interface{}{userId, companyId, userId} | ||
97 | + if len(dayTime) > 0 { | ||
98 | + condition = append(condition, dayTime) | ||
99 | + sqlStr2 += ` and to_char(task_anomaly.created_at,'yyyy-MM-dd') =? ` | ||
100 | + sqlStr1 += ` and to_char(task_anomaly.created_at,'yyyy-MM-dd') =? ` | ||
101 | + } | ||
102 | + if len(taskName) > 0 { | ||
103 | + condition = append(condition, "%"+taskName+"%") | ||
104 | + sqlStr2 += ` and task.alias like ? ` | ||
105 | + sqlStr1 += ` and task.alias like ? ` | ||
106 | + } | ||
107 | + if category > 0 { | ||
108 | + condition = append(condition, category) | ||
109 | + sqlStr1 += ` and task_anomaly.category=? ` | ||
110 | + sqlStr2 += ` and task_anomaly.category=? ` | ||
111 | + | ||
112 | + } | ||
113 | + condition = append(condition, limit, offset) | ||
114 | + sqlStr1 += ` order by task_anomaly.id desc limit ? offset ? ` | ||
115 | + result := []ListTaskAnomaly{} | ||
116 | + tx := d.transactionContext.PgTx | ||
117 | + _, err := tx.Query(&result, sqlStr1, condition...) | ||
118 | + if err != nil { | ||
119 | + return 0, result, err | ||
120 | + } | ||
121 | + var cnt int | ||
122 | + _, err = tx.QueryOne(pg.Scan(&cnt), sqlStr2, condition...) | ||
123 | + return cnt, result, err | ||
44 | } | 124 | } |
45 | 125 | ||
46 | // 异常的任务记录,获取我的下级负责的任务 | 126 | // 异常的任务记录,获取我的下级负责的任务 |
@@ -49,7 +129,7 @@ func (d *TaskAnomalyDao) List1(userId int, companyId int, dayTime string, pageSi | @@ -49,7 +129,7 @@ func (d *TaskAnomalyDao) List1(userId int, companyId int, dayTime string, pageSi | ||
49 | // dayTime 搜索条件日期 ,例:"2006-01-02" | 129 | // dayTime 搜索条件日期 ,例:"2006-01-02" |
50 | // pageSize 分页大小 | 130 | // pageSize 分页大小 |
51 | // pageNumber 分页页码 | 131 | // pageNumber 分页页码 |
52 | -func (d *TaskAnomalyDao) List2(userId int, companyId int, dayTime string, pageSize int, pageNumber int) error { | 132 | +func (d *TaskAnomalyDao) List2(userId int, companyId int, leaderId string, dayTime string, pageSize int, pageNumber int) error { |
53 | 133 | ||
54 | return nil | 134 | return nil |
55 | } | 135 | } |
@@ -60,6 +140,81 @@ func (d *TaskAnomalyDao) List2(userId int, companyId int, dayTime string, pageSi | @@ -60,6 +140,81 @@ func (d *TaskAnomalyDao) List2(userId int, companyId int, dayTime string, pageSi | ||
60 | // dayTime 搜索条件日期 ,例:"2006-01-02" | 140 | // dayTime 搜索条件日期 ,例:"2006-01-02" |
61 | // pageSize 分页大小 | 141 | // pageSize 分页大小 |
62 | // pageNumber 分页页码 | 142 | // pageNumber 分页页码 |
63 | -func (d *TaskAnomalyDao) List3(userId int, companyId int, dayTime string, pageSize int, pageNumber int) error { | ||
64 | - return nil | 143 | +func (d *TaskAnomalyDao) List3(userId int, companyId int, taskName string, category int, dayTime string, leaderId string, limit int, offset int) (int, []ListTaskAnomaly, error) { |
144 | + sqlStr1 := ` with t_task_ignore as ( | ||
145 | + select task_ignore.id ,task_ignore.task_id | ||
146 | + from task_ignore | ||
147 | + where user_id = ? | ||
148 | + )select | ||
149 | + task_anomaly.id, | ||
150 | + task_anomaly.task_id, | ||
151 | + task_anomaly.category, | ||
152 | + task_anomaly.current_stage, | ||
153 | + task_anomaly.last_stage, | ||
154 | + task_anomaly.task_stage_check, | ||
155 | + task_anomaly.assess_flag, | ||
156 | + task_anomaly.warn_flag, | ||
157 | + task_anomaly.assist_flag, | ||
158 | + task_anomaly.record_begin, | ||
159 | + task_anomaly.marks, | ||
160 | + task_anomaly.notice_who, | ||
161 | + task.alias as "task_alias", | ||
162 | + task."name" as "task_name", | ||
163 | + task.end_time as "task_end_time", | ||
164 | + task.sort_by as "task_sort_by", | ||
165 | + task.leader->>'name' as "leader_name", | ||
166 | + task.level_name | ||
167 | + from task_anomaly | ||
168 | + join task on task.id = task_anomaly.task_id | ||
169 | + left join t_task_ignore on task_anomaly.task_id=t_task_ignore.task_id | ||
170 | + where t_task_ignore.id isnull and task.deleted_at isnull | ||
171 | + and task_anomaly.company_id = ? | ||
172 | + and task.related_user@> ? ` | ||
173 | + | ||
174 | + sqlStr2 := ` with t_task_ignore as ( | ||
175 | + select task_ignore.id ,task_ignore.task_id | ||
176 | + from task_ignore | ||
177 | + where user_id = ? | ||
178 | + )select count(*) as cnt | ||
179 | + from task_anomaly | ||
180 | + join task on task.id = task_anomaly.task_id | ||
181 | + left join t_task_ignore on task_anomaly.task_id=t_task_ignore.task_id | ||
182 | + where t_task_ignore.id isnull and task.deleted_at isnull | ||
183 | + and task_anomaly.company_id = ? | ||
184 | + and task.related_user@> ? ` | ||
185 | + | ||
186 | + condition := []interface{}{userId, companyId, fmt.Sprintf("[%d]", userId)} | ||
187 | + if len(dayTime) > 0 { | ||
188 | + condition = append(condition, dayTime) | ||
189 | + sqlStr2 += ` and to_char(task_anomaly.created_at,'yyyy-MM-dd') =? ` | ||
190 | + sqlStr1 += ` and to_char(task_anomaly.created_at,'yyyy-MM-dd') =? ` | ||
191 | + } | ||
192 | + if len(taskName) > 0 { | ||
193 | + condition = append(condition, "%"+taskName+"%") | ||
194 | + sqlStr2 += ` and task.alias like ? ` | ||
195 | + sqlStr1 += ` and task.alias like ? ` | ||
196 | + } | ||
197 | + if category > 0 { | ||
198 | + condition = append(condition, category) | ||
199 | + sqlStr1 += ` and task_anomaly.category=? ` | ||
200 | + sqlStr2 += ` and task_anomaly.category=? ` | ||
201 | + | ||
202 | + } | ||
203 | + if len(leaderId) > 0 { | ||
204 | + condition = append(condition, fmt.Sprintf(`{"id":"%s"}`, leaderId)) | ||
205 | + sqlStr1 += ` and task.leader@>? ` | ||
206 | + sqlStr2 += ` and task.leader@>? ` | ||
207 | + } | ||
208 | + condition = append(condition, limit, offset) | ||
209 | + sqlStr1 += ` order by task_anomaly.id desc limit ? offset ? ` | ||
210 | + result := []ListTaskAnomaly{} | ||
211 | + tx := d.transactionContext.PgTx | ||
212 | + _, err := tx.Query(&result, sqlStr1, condition...) | ||
213 | + if err != nil { | ||
214 | + return 0, result, err | ||
215 | + } | ||
216 | + var cnt int | ||
217 | + _, err = tx.QueryOne(pg.Scan(&cnt), sqlStr2, condition...) | ||
218 | + return cnt, result, err | ||
219 | + | ||
65 | } | 220 | } |
@@ -9,25 +9,20 @@ import ( | @@ -9,25 +9,20 @@ import ( | ||
9 | // 任务的异常记录 | 9 | // 任务的异常记录 |
10 | type TaskAnomaly struct { | 10 | type TaskAnomaly struct { |
11 | tableName struct{} `comment:"任务的异常记录" pg:"task_anomaly"` | 11 | tableName struct{} `comment:"任务的异常记录" pg:"task_anomaly"` |
12 | - Id int `pg:"id"` // | ||
13 | - CreatedAt time.Time `pg:"created_at"` // | ||
14 | - UpdatedAt time.Time `pg:"updated_at"` // | ||
15 | - CompanyId int `pg:"company_id"` // | ||
16 | - TaskId int `pg:"task_id"` // 任务id | ||
17 | - Category int `pg:"category"` // 异常任务的分类 | ||
18 | - CurrentStage domain.TaskStage `pg:"current_stage"` // 计划完成的里程碑 | ||
19 | - LastStage domain.TaskStage `pg:"last_stage"` // 实际完成的里程碑 | ||
20 | - TaskStageCheck domain.TaskStage `pg:"task_stage_check"` // 当天任务反馈操作里程碑记录 | ||
21 | - AssessFlag int `pg:"assess_flag,use_zero"` // 异常反馈的次数 | ||
22 | - WarnFlag int `pg:"warn_flag,use_zero"` // 里程碑异常次数 | ||
23 | - AssistFlag int `pg:"assist_flag,use_zero"` // 辅导异常次数 | ||
24 | - IsLast int `pg:"is_last"` // 是否是最新的一条记录 1 是最新的记录 2 不是最新的记录 | ||
25 | - TaskLevel string `pg:"task_level"` // 任务类型 | ||
26 | - TaskName string `pg:"task_name"` // 任务名称 | ||
27 | - TaskAlias string `pg:"task_alias"` // 任务别名 | ||
28 | - TaskSortBy int `pg:"task_sort_by"` // 优先级排序;值越小优先级越高 | ||
29 | - TaskEndTime int64 `pg:"task_end_time,use_zero"` // 任务截止的时间戳,单位:秒;等于0时表示未设置时间 | ||
30 | - RecordBegin int64 `pg:"record_begin"` // 异常记录的开始时间 | ||
31 | - NoticeWho []map[string]string `pg:"notice_who"` // 异常记录消息通知的人 | ||
32 | - Marks map[string]string `pg:"marks"` // 已经操作的标记 | 12 | + Id int `pg:"id"` // |
13 | + CreatedAt time.Time `pg:"created_at"` // | ||
14 | + UpdatedAt time.Time `pg:"updated_at"` // | ||
15 | + CompanyId int `pg:"company_id"` // | ||
16 | + TaskId int `pg:"task_id"` // 任务id | ||
17 | + Category int `pg:"category"` // 异常任务的分类 | ||
18 | + CurrentStage domain.TaskStage `pg:"current_stage"` // 计划完成的里程碑 | ||
19 | + LastStage domain.TaskStage `pg:"last_stage"` // 实际完成的里程碑 | ||
20 | + TaskStageCheck domain.TaskStage `pg:"task_stage_check"` // 当天任务反馈操作里程碑记录 | ||
21 | + AssessFlag int `pg:"assess_flag,use_zero"` // 异常反馈的次数 | ||
22 | + WarnFlag int `pg:"warn_flag,use_zero"` // 里程碑异常次数 | ||
23 | + AssistFlag int `pg:"assist_flag,use_zero"` // 辅导异常次数 | ||
24 | + IsLast int `pg:"is_last"` // 是否是最新的一条记录 1 是最新的记录 2 不是最新的记录 | ||
25 | + RecordBegin int64 `pg:"record_begin"` // 异常记录的开始时间 | ||
26 | + NoticeWho []map[string]string `pg:"notice_who"` // 异常记录消息通知的人 | ||
27 | + Marks map[string]string `pg:"marks"` // 已经操作的标记 | ||
33 | } | 28 | } |
@@ -38,11 +38,6 @@ func (repo *TaskAnomalyRepository) TransformToDomain(d *models.TaskAnomaly) *dom | @@ -38,11 +38,6 @@ func (repo *TaskAnomalyRepository) TransformToDomain(d *models.TaskAnomaly) *dom | ||
38 | WarnFlag: d.WarnFlag, | 38 | WarnFlag: d.WarnFlag, |
39 | AssistFlag: d.AssistFlag, | 39 | AssistFlag: d.AssistFlag, |
40 | IsLast: d.IsLast, | 40 | IsLast: d.IsLast, |
41 | - TaskLevel: d.TaskLevel, | ||
42 | - TaskName: d.TaskName, | ||
43 | - TaskAlias: d.TaskAlias, | ||
44 | - TaskSortBy: domain.TaskSortBy(d.TaskSortBy), | ||
45 | - TaskEndTime: d.TaskEndTime, | ||
46 | RecordBegin: d.RecordBegin, | 41 | RecordBegin: d.RecordBegin, |
47 | NoticeWho: d.NoticeWho, | 42 | NoticeWho: d.NoticeWho, |
48 | Marks: d.Marks, | 43 | Marks: d.Marks, |
@@ -64,11 +59,6 @@ func (repo *TaskAnomalyRepository) Save(param *domain.TaskAnomaly) error { | @@ -64,11 +59,6 @@ func (repo *TaskAnomalyRepository) Save(param *domain.TaskAnomaly) error { | ||
64 | WarnFlag: param.WarnFlag, | 59 | WarnFlag: param.WarnFlag, |
65 | AssistFlag: param.AssistFlag, | 60 | AssistFlag: param.AssistFlag, |
66 | IsLast: param.IsLast, | 61 | IsLast: param.IsLast, |
67 | - TaskLevel: param.TaskLevel, | ||
68 | - TaskName: param.TaskName, | ||
69 | - TaskAlias: param.TaskAlias, | ||
70 | - TaskSortBy: int(param.TaskSortBy), | ||
71 | - TaskEndTime: param.TaskEndTime, | ||
72 | RecordBegin: param.RecordBegin, | 62 | RecordBegin: param.RecordBegin, |
73 | NoticeWho: param.NoticeWho, | 63 | NoticeWho: param.NoticeWho, |
74 | Marks: param.Marks, | 64 | Marks: param.Marks, |
@@ -34,8 +34,4 @@ func init() { | @@ -34,8 +34,4 @@ func init() { | ||
34 | web.NSCtrlPost("/ignore/cancel", (*controllers.TaskController).CancelIgnore), | 34 | web.NSCtrlPost("/ignore/cancel", (*controllers.TaskController).CancelIgnore), |
35 | ) | 35 | ) |
36 | web.AddNamespace(taskFontNS) | 36 | web.AddNamespace(taskFontNS) |
37 | - t := web.NewNamespace("/test/task", | ||
38 | - web.NSCtrlPost("/", (*controllers.TaskController).CreateTask), | ||
39 | - ) | ||
40 | - web.AddNamespace(t) | ||
41 | } | 37 | } |
-
请 注册 或 登录 后发表评论