|
@@ -7,6 +7,7 @@ import ( |
|
@@ -7,6 +7,7 @@ import ( |
7
|
"github.com/linmadan/egglib-go/core/application"
|
7
|
"github.com/linmadan/egglib-go/core/application"
|
8
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
|
8
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
|
9
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
|
9
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
|
|
|
10
|
+ "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/utils/xtime"
|
10
|
)
|
11
|
)
|
11
|
|
12
|
|
12
|
// TODO 检查任务里程碑反馈, 记录异常情况
|
13
|
// TODO 检查任务里程碑反馈, 记录异常情况
|
|
@@ -33,39 +34,47 @@ func checkTaskRecordV2(param *domain.TaskRecord) error { |
|
@@ -33,39 +34,47 @@ func checkTaskRecordV2(param *domain.TaskRecord) error { |
33
|
return nil
|
34
|
return nil
|
34
|
}
|
35
|
}
|
35
|
taskData := taskDataList[0]
|
36
|
taskData := taskDataList[0]
|
36
|
-
|
|
|
37
|
- //userDao := dao.NewUserDao(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
38
|
-
|
|
|
39
|
- // 反馈异常,里程碑异常, 辅导异常
|
|
|
40
|
// 检查反馈异常
|
37
|
// 检查反馈异常
|
41
|
if param.IsRemarkAnomaly() {
|
38
|
if param.IsRemarkAnomaly() {
|
42
|
taskData.Anomaly += 1
|
39
|
taskData.Anomaly += 1
|
43
|
- // err = isAssessFlag(transactionContext, taskData)
|
|
|
44
|
- // if err != nil {
|
|
|
45
|
- // return err
|
|
|
46
|
- // }
|
40
|
+ err = isAssessFlag(transactionContext, taskData, param)
|
|
|
41
|
+ if err != nil {
|
|
|
42
|
+ return err
|
|
|
43
|
+ }
|
47
|
} else {
|
44
|
} else {
|
48
|
taskData.Anomaly = 0
|
45
|
taskData.Anomaly = 0
|
|
|
46
|
+ err = isNotAssessFlag(transactionContext, taskData, param)
|
|
|
47
|
+ if err != nil {
|
|
|
48
|
+ return err
|
|
|
49
|
+ }
|
49
|
}
|
50
|
}
|
50
|
// 检查里程碑异常
|
51
|
// 检查里程碑异常
|
51
|
if param.IsTaskStageAnomaly() {
|
52
|
if param.IsTaskStageAnomaly() {
|
52
|
taskData.WarnFlag = domain.TaskWarn
|
53
|
taskData.WarnFlag = domain.TaskWarn
|
53
|
- err := isWarnFlag(transactionContext, taskData)
|
54
|
+ err := isWarnFlag(transactionContext, taskData, param)
|
54
|
if err != nil {
|
55
|
if err != nil {
|
55
|
return err
|
56
|
return err
|
56
|
}
|
57
|
}
|
57
|
- } else {
|
58
|
+ } else if param.TaskStageCheck.Id > 0 {
|
58
|
taskData.WarnFlag = domain.TaskWarnNull
|
59
|
taskData.WarnFlag = domain.TaskWarnNull
|
|
|
60
|
+ err := isNotWarnFlag(transactionContext, taskData, param)
|
|
|
61
|
+ if err != nil {
|
|
|
62
|
+ return err
|
|
|
63
|
+ }
|
59
|
}
|
64
|
}
|
60
|
// 检查辅导异常
|
65
|
// 检查辅导异常
|
61
|
if param.IsAssistAnomaly() {
|
66
|
if param.IsAssistAnomaly() {
|
62
|
taskData.AssistFlag += 1
|
67
|
taskData.AssistFlag += 1
|
63
|
- err = isAssistFlag(transactionContext, taskData)
|
68
|
+ err = isAssistFlag(transactionContext, taskData, param)
|
64
|
if err != nil {
|
69
|
if err != nil {
|
65
|
return err
|
70
|
return err
|
66
|
}
|
71
|
}
|
67
|
} else {
|
72
|
} else {
|
68
|
taskData.AssistFlag = 0
|
73
|
taskData.AssistFlag = 0
|
|
|
74
|
+ err = isNotAssistFlag(transactionContext, taskData, param)
|
|
|
75
|
+ if err != nil {
|
|
|
76
|
+ return err
|
|
|
77
|
+ }
|
69
|
}
|
78
|
}
|
70
|
// 保存任务数据
|
79
|
// 保存任务数据
|
71
|
err = taskRepo.Save(taskData)
|
80
|
err = taskRepo.Save(taskData)
|
|
@@ -79,8 +88,31 @@ func checkTaskRecordV2(param *domain.TaskRecord) error { |
|
@@ -79,8 +88,31 @@ func checkTaskRecordV2(param *domain.TaskRecord) error { |
79
|
return nil
|
88
|
return nil
|
80
|
}
|
89
|
}
|
81
|
|
90
|
|
|
|
91
|
+// 取消里程碑异常
|
|
|
92
|
+func isNotWarnFlag(transactionContext application.TransactionContext, taskData *domain.Task, taskRecord *domain.TaskRecord) error {
|
|
|
93
|
+ taskAnomalyRepo := factory.CreateTaskAnomalyRepository(map[string]interface{}{
|
|
|
94
|
+ "transactionContext": transactionContext,
|
|
|
95
|
+ })
|
|
|
96
|
+ _, oldAnomaly, err := taskAnomalyRepo.Find(map[string]interface{}{
|
|
|
97
|
+ "isLast": 1,
|
|
|
98
|
+ "category": 2,
|
|
|
99
|
+ "limit": 1,
|
|
|
100
|
+ "taskId": taskData.Id,
|
|
|
101
|
+ "taskStageCheck": fmt.Sprintf(`{"id":"%d"}`, taskRecord.TaskStageCheck.Id),
|
|
|
102
|
+ })
|
|
|
103
|
+ if err != nil {
|
|
|
104
|
+ return fmt.Errorf("查询里程碑异常的数据:%s", err)
|
|
|
105
|
+ }
|
|
|
106
|
+ if len(oldAnomaly) == 0 {
|
|
|
107
|
+ return nil
|
|
|
108
|
+ }
|
|
|
109
|
+ oldAnomaly[0].IsLast = 2
|
|
|
110
|
+ err = taskAnomalyRepo.Save(oldAnomaly[0])
|
|
|
111
|
+ return fmt.Errorf("取消里程碑异常:%s", err)
|
|
|
112
|
+}
|
|
|
113
|
+
|
82
|
// 处理里程碑异常的情况
|
114
|
// 处理里程碑异常的情况
|
83
|
-func isWarnFlag(transactionContext application.TransactionContext, taskData *domain.Task) error {
|
115
|
+func isWarnFlag(transactionContext application.TransactionContext, taskData *domain.Task, taskRecord *domain.TaskRecord) error {
|
84
|
taskAnomalyRepo := factory.CreateTaskAnomalyRepository(map[string]interface{}{
|
116
|
taskAnomalyRepo := factory.CreateTaskAnomalyRepository(map[string]interface{}{
|
85
|
"transactionContext": transactionContext,
|
117
|
"transactionContext": transactionContext,
|
86
|
})
|
118
|
})
|
|
@@ -88,39 +120,146 @@ func isWarnFlag(transactionContext application.TransactionContext, taskData *dom |
|
@@ -88,39 +120,146 @@ func isWarnFlag(transactionContext application.TransactionContext, taskData *dom |
88
|
userRepo := factory.CreateUserRepository(map[string]interface{}{
|
120
|
userRepo := factory.CreateUserRepository(map[string]interface{}{
|
89
|
"transactionContext": transactionContext,
|
121
|
"transactionContext": transactionContext,
|
90
|
})
|
122
|
})
|
|
|
123
|
+
|
|
|
124
|
+ _, oldAnomaly, err := taskAnomalyRepo.Find(map[string]interface{}{
|
|
|
125
|
+ "isLast": 1,
|
|
|
126
|
+ "category": 2,
|
|
|
127
|
+ "limit": 1,
|
|
|
128
|
+ "taskId": taskData.Id,
|
|
|
129
|
+ "taskStageCheck": fmt.Sprintf(`{"id":"%d"}`, taskRecord.TaskStageCheck.Id),
|
|
|
130
|
+ })
|
|
|
131
|
+ if err != nil {
|
|
|
132
|
+ return fmt.Errorf("查询里程碑异常的数据:%s", err)
|
|
|
133
|
+ }
|
|
|
134
|
+
|
|
|
135
|
+ anomalyDataTmp := domain.TaskAnomaly{
|
|
|
136
|
+ Id: taskData.Id,
|
|
|
137
|
+ CreatedAt: time.Now(),
|
|
|
138
|
+ UpdatedAt: time.Now(),
|
|
|
139
|
+ CompanyId: taskData.CompanyId,
|
|
|
140
|
+ TaskId: taskData.Id,
|
|
|
141
|
+ TaskRecordId: taskRecord.Id,
|
|
|
142
|
+ Category: 1,
|
|
|
143
|
+ CurrentStage: taskData.CurrentStage,
|
|
|
144
|
+ LastStage: taskData.LastStage,
|
|
|
145
|
+ TaskStageCheck: taskRecord.TaskStageCheck,
|
|
|
146
|
+ AssessFlag: 0,
|
|
|
147
|
+ WarnFlag: int(taskData.WarnFlag),
|
|
|
148
|
+ AssistFlag: 0,
|
|
|
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(),
|
|
|
156
|
+ NoticeWho: []map[string]string{},
|
|
|
157
|
+ Marks: map[string]string{
|
|
|
158
|
+ "a": "", "b": "", "c": "", "d": "",
|
|
|
159
|
+ },
|
|
|
160
|
+ }
|
|
|
161
|
+ if len(oldAnomaly) > 0 {
|
|
|
162
|
+ anomalyDataTmp.WarnFlag = oldAnomaly[0].WarnFlag + 1
|
|
|
163
|
+ anomalyDataTmp.RecordBegin = oldAnomaly[0].RecordBegin
|
|
|
164
|
+ oldAnomaly[0].IsLast = 2
|
|
|
165
|
+ err = taskAnomalyRepo.Save(oldAnomaly[0])
|
|
|
166
|
+ if err != nil {
|
|
|
167
|
+ return fmt.Errorf("更新里程碑异常记录:%s", err)
|
|
|
168
|
+ }
|
|
|
169
|
+ }
|
|
|
170
|
+ // 异常就通知自己和上级
|
91
|
//获取任务Leader的数据
|
171
|
//获取任务Leader的数据
|
92
|
_, useList, err := userRepo.Find(map[string]interface{}{"id": taskData.Leader.Id, "limit": 1})
|
172
|
_, useList, err := userRepo.Find(map[string]interface{}{"id": taskData.Leader.Id, "limit": 1})
|
93
|
if err != nil {
|
173
|
if err != nil {
|
94
|
return fmt.Errorf("获取任务Leader:%s", err)
|
174
|
return fmt.Errorf("获取任务Leader:%s", err)
|
95
|
}
|
175
|
}
|
96
|
- if len(useList) == 0 {
|
176
|
+ var userParentId int64
|
|
|
177
|
+ if len(useList) > 0 {
|
|
|
178
|
+ anomalyDataTmp.SetNoticeWho(useList[0])
|
|
|
179
|
+ userParentId = useList[0].ParentId
|
|
|
180
|
+ }
|
|
|
181
|
+
|
|
|
182
|
+ if userParentId > 0 {
|
|
|
183
|
+ // 获取上级用户的数据
|
|
|
184
|
+ _, useList2, err := userRepo.Find(map[string]interface{}{"id": userParentId, "limit": 1})
|
|
|
185
|
+ if err != nil {
|
|
|
186
|
+ return fmt.Errorf("获取任务Leader的上级:%s", err)
|
|
|
187
|
+ }
|
|
|
188
|
+ if len(useList2) > 0 {
|
|
|
189
|
+ anomalyDataTmp.SetNoticeWho(useList2[0])
|
|
|
190
|
+ }
|
|
|
191
|
+ }
|
|
|
192
|
+ err = taskAnomalyRepo.Save(&anomalyDataTmp)
|
|
|
193
|
+ if err != nil {
|
|
|
194
|
+ return fmt.Errorf("保存里程碑异常记录:%s", err)
|
|
|
195
|
+ }
|
|
|
196
|
+ return nil
|
|
|
197
|
+}
|
|
|
198
|
+
|
|
|
199
|
+// 取消辅导异常的情况
|
|
|
200
|
+func isNotAssistFlag(transactionContext application.TransactionContext, taskData *domain.Task, taskRecord *domain.TaskRecord) error {
|
|
|
201
|
+ taskAnomalyRepo := factory.CreateTaskAnomalyRepository(map[string]interface{}{
|
|
|
202
|
+ "transactionContext": transactionContext,
|
|
|
203
|
+ })
|
|
|
204
|
+
|
|
|
205
|
+ _, oldAnomaly, err := taskAnomalyRepo.Find(map[string]interface{}{
|
|
|
206
|
+ "isLast": 1,
|
|
|
207
|
+ "category": 3,
|
|
|
208
|
+ "limit": 1,
|
|
|
209
|
+ "taskId": taskData.Id,
|
|
|
210
|
+ })
|
|
|
211
|
+ if err != nil {
|
|
|
212
|
+ return fmt.Errorf("查询辅导异常的数据:%s", err)
|
|
|
213
|
+ }
|
|
|
214
|
+ if len(oldAnomaly) == 0 {
|
97
|
return nil
|
215
|
return nil
|
98
|
}
|
216
|
}
|
99
|
- _, oldAnomaly, err := taskAnomalyRepo.Find(map[string]interface{}{"isLast": 1, "category": 2, "limit": 1})
|
217
|
+ oldAnomaly[0].IsLast = 2
|
|
|
218
|
+ err = taskAnomalyRepo.Save(oldAnomaly[0])
|
|
|
219
|
+ return fmt.Errorf("取消辅导异常:%s", err)
|
|
|
220
|
+}
|
|
|
221
|
+
|
|
|
222
|
+// 处理辅导异常的情况
|
|
|
223
|
+func isAssistFlag(transactionContext application.TransactionContext, taskData *domain.Task, taskRecord *domain.TaskRecord) error {
|
|
|
224
|
+ taskAnomalyRepo := factory.CreateTaskAnomalyRepository(map[string]interface{}{
|
|
|
225
|
+ "transactionContext": transactionContext,
|
|
|
226
|
+ })
|
|
|
227
|
+
|
|
|
228
|
+ userRepo := factory.CreateUserRepository(map[string]interface{}{
|
|
|
229
|
+ "transactionContext": transactionContext,
|
|
|
230
|
+ })
|
|
|
231
|
+
|
|
|
232
|
+ _, oldAnomaly, err := taskAnomalyRepo.Find(map[string]interface{}{
|
|
|
233
|
+ "isLast": 1,
|
|
|
234
|
+ "category": 3,
|
|
|
235
|
+ "limit": 1,
|
|
|
236
|
+ "taskId": taskData.Id,
|
|
|
237
|
+ })
|
100
|
if err != nil {
|
238
|
if err != nil {
|
101
|
- return fmt.Errorf("查询反馈异常的数据:%s", err)
|
239
|
+ return fmt.Errorf("查询辅导异常的数据:%s", err)
|
102
|
}
|
240
|
}
|
103
|
- // 异常就通知自己和上级
|
241
|
+ // 辅导异常通知该条任务负责人的上级;辅导异常超过N天,通知任务负责人的上上级
|
104
|
anomalyDataTmp := domain.TaskAnomaly{
|
242
|
anomalyDataTmp := domain.TaskAnomaly{
|
105
|
- Id: taskData.Id,
|
|
|
106
|
- CreatedAt: taskData.CreatedAt,
|
|
|
107
|
- UpdatedAt: taskData.UpdatedAt,
|
|
|
108
|
- CompanyId: taskData.CompanyId,
|
|
|
109
|
- TaskId: taskData.Id,
|
|
|
110
|
- Category: 1,
|
|
|
111
|
- CurrentStage: taskData.CurrentStage,
|
|
|
112
|
- LastStage: taskData.LastStage,
|
|
|
113
|
- AssessFlag: 0,
|
|
|
114
|
- WarnFlag: int(taskData.WarnFlag),
|
|
|
115
|
- AssistFlag: 0,
|
|
|
116
|
- IsLast: 1,
|
|
|
117
|
- TaskLevel: taskData.LevelName,
|
|
|
118
|
- TaskName: taskData.Name,
|
|
|
119
|
- TaskAlias: taskData.Alias,
|
|
|
120
|
- TaskSortBy: taskData.SortBy,
|
|
|
121
|
- TaskEndTime: taskData.EndTime,
|
|
|
122
|
- RecordBegin: time.Now().Unix(),
|
|
|
123
|
- NoticeWho: []int64{taskData.Leader.Id, useList[0].ParentId},
|
243
|
+ Id: taskData.Id,
|
|
|
244
|
+ CreatedAt: time.Now(),
|
|
|
245
|
+ UpdatedAt: time.Now(),
|
|
|
246
|
+ CompanyId: taskData.CompanyId,
|
|
|
247
|
+ TaskId: taskData.Id,
|
|
|
248
|
+ Category: 3,
|
|
|
249
|
+ CurrentStage: taskData.CurrentStage,
|
|
|
250
|
+ LastStage: taskData.LastStage,
|
|
|
251
|
+ TaskStageCheck: taskRecord.TaskStageCheck,
|
|
|
252
|
+ AssessFlag: 0,
|
|
|
253
|
+ WarnFlag: 0,
|
|
|
254
|
+ AssistFlag: taskData.AssistFlag,
|
|
|
255
|
+ 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(),
|
|
|
262
|
+ NoticeWho: []map[string]string{},
|
124
|
Marks: map[string]string{
|
263
|
Marks: map[string]string{
|
125
|
"a": "", "b": "", "c": "", "d": "",
|
264
|
"a": "", "b": "", "c": "", "d": "",
|
126
|
},
|
265
|
},
|
|
@@ -128,76 +267,119 @@ func isWarnFlag(transactionContext application.TransactionContext, taskData *dom |
|
@@ -128,76 +267,119 @@ func isWarnFlag(transactionContext application.TransactionContext, taskData *dom |
128
|
|
267
|
|
129
|
if len(oldAnomaly) > 0 {
|
268
|
if len(oldAnomaly) > 0 {
|
130
|
anomalyDataTmp.RecordBegin = oldAnomaly[0].RecordBegin
|
269
|
anomalyDataTmp.RecordBegin = oldAnomaly[0].RecordBegin
|
131
|
- anomalyDataTmp.WarnFlag = oldAnomaly[0].WarnFlag + 1
|
|
|
132
|
oldAnomaly[0].IsLast = 2
|
270
|
oldAnomaly[0].IsLast = 2
|
133
|
err = taskAnomalyRepo.Save(oldAnomaly[0])
|
271
|
err = taskAnomalyRepo.Save(oldAnomaly[0])
|
134
|
if err != nil {
|
272
|
if err != nil {
|
135
|
return fmt.Errorf("更新里程碑异常记录:%s", err)
|
273
|
return fmt.Errorf("更新里程碑异常记录:%s", err)
|
136
|
}
|
274
|
}
|
137
|
}
|
275
|
}
|
|
|
276
|
+ //获取任务Leader的数据
|
|
|
277
|
+ _, useList, err := userRepo.Find(map[string]interface{}{"id": taskData.Leader.Id, "limit": 1})
|
|
|
278
|
+ if err != nil {
|
|
|
279
|
+ return fmt.Errorf("获取任务Leader:%s", err)
|
|
|
280
|
+ }
|
|
|
281
|
+ var userParentId int64
|
|
|
282
|
+ if len(useList) > 0 {
|
|
|
283
|
+ userParentId = useList[0].ParentId
|
|
|
284
|
+ }
|
|
|
285
|
+ if userParentId > 0 {
|
|
|
286
|
+ //通知任务负责人的上级
|
|
|
287
|
+ _, useList2, err := userRepo.Find(map[string]interface{}{"id": userParentId, "limit": 1})
|
|
|
288
|
+ if err != nil {
|
|
|
289
|
+ return fmt.Errorf("获取任务Leader:%s", err)
|
|
|
290
|
+ }
|
|
|
291
|
+ var userParentId2 int64
|
|
|
292
|
+ if len(useList2) > 0 {
|
|
|
293
|
+ anomalyDataTmp.SetNoticeWho(useList2[0])
|
|
|
294
|
+ userParentId2 = useList2[0].ParentId
|
|
|
295
|
+ }
|
|
|
296
|
+ // 辅导异常超过N天,通知任务负责人的上上级
|
|
|
297
|
+ if taskData.AssistFlag >= taskData.AssistFlagMax && userParentId2 > 0 {
|
|
|
298
|
+ _, useList3, err := userRepo.Find(map[string]interface{}{"id": userParentId, "limit": 1})
|
|
|
299
|
+ if err != nil {
|
|
|
300
|
+ return fmt.Errorf("获取任务Leader:%s", err)
|
|
|
301
|
+ }
|
|
|
302
|
+ if len(useList3) > 0 {
|
|
|
303
|
+ anomalyDataTmp.SetNoticeWho(useList3[0])
|
|
|
304
|
+ }
|
|
|
305
|
+ }
|
|
|
306
|
+ }
|
|
|
307
|
+
|
138
|
err = taskAnomalyRepo.Save(&anomalyDataTmp)
|
308
|
err = taskAnomalyRepo.Save(&anomalyDataTmp)
|
139
|
if err != nil {
|
309
|
if err != nil {
|
140
|
return fmt.Errorf("保存里程碑异常记录:%s", err)
|
310
|
return fmt.Errorf("保存里程碑异常记录:%s", err)
|
141
|
}
|
311
|
}
|
142
|
return nil
|
312
|
return nil
|
|
|
313
|
+
|
143
|
}
|
314
|
}
|
144
|
|
315
|
|
145
|
-// 处理辅导异常的情况
|
|
|
146
|
-func isAssistFlag(transactionContext application.TransactionContext, taskData *domain.Task) error {
|
316
|
+// 取消反馈异常的情况
|
|
|
317
|
+func isNotAssessFlag(transactionContext application.TransactionContext, taskData *domain.Task, taskRecord *domain.TaskRecord) error {
|
147
|
taskAnomalyRepo := factory.CreateTaskAnomalyRepository(map[string]interface{}{
|
318
|
taskAnomalyRepo := factory.CreateTaskAnomalyRepository(map[string]interface{}{
|
148
|
"transactionContext": transactionContext,
|
319
|
"transactionContext": transactionContext,
|
149
|
})
|
320
|
})
|
150
|
|
321
|
|
151
|
- userRepo := factory.CreateUserRepository(map[string]interface{}{
|
|
|
152
|
- "transactionContext": transactionContext,
|
322
|
+ _, oldAnomaly, err := taskAnomalyRepo.Find(map[string]interface{}{
|
|
|
323
|
+ "isLast": 1,
|
|
|
324
|
+ "category": 3,
|
|
|
325
|
+ "limit": 1,
|
|
|
326
|
+ "taskId": taskData.Id,
|
153
|
})
|
327
|
})
|
154
|
- //获取任务Leader的数据
|
|
|
155
|
- _, useList, err := userRepo.Find(map[string]interface{}{"id": taskData.Leader.Id, "limit": 1})
|
|
|
156
|
if err != nil {
|
328
|
if err != nil {
|
157
|
- return fmt.Errorf("获取任务Leader:%s", err)
|
329
|
+ return fmt.Errorf("查询辅导异常的数据:%s", err)
|
158
|
}
|
330
|
}
|
159
|
- if len(useList) == 0 {
|
331
|
+ if len(oldAnomaly) == 0 {
|
160
|
return nil
|
332
|
return nil
|
161
|
}
|
333
|
}
|
162
|
- _, oldAnomaly, err := taskAnomalyRepo.Find(map[string]interface{}{"isLast": 1, "category": 3, "limit": 1})
|
334
|
+ oldAnomaly[0].IsLast = 2
|
|
|
335
|
+ err = taskAnomalyRepo.Save(oldAnomaly[0])
|
|
|
336
|
+ return fmt.Errorf("取消辅导异常:%s", err)
|
|
|
337
|
+
|
|
|
338
|
+}
|
|
|
339
|
+
|
|
|
340
|
+// 处理反馈异常的情况
|
|
|
341
|
+func isAssessFlag(transactionContext application.TransactionContext, taskData *domain.Task, taskRecord *domain.TaskRecord) error {
|
|
|
342
|
+ taskAnomalyRepo := factory.CreateTaskAnomalyRepository(map[string]interface{}{
|
|
|
343
|
+ "transactionContext": transactionContext,
|
|
|
344
|
+ })
|
|
|
345
|
+ userRepo := factory.CreateUserRepository(map[string]interface{}{
|
|
|
346
|
+ "transactionContext": transactionContext,
|
|
|
347
|
+ })
|
|
|
348
|
+ _, oldAnomaly, err := taskAnomalyRepo.Find(map[string]interface{}{
|
|
|
349
|
+ "isLast": 1,
|
|
|
350
|
+ "category": 2,
|
|
|
351
|
+ "limit": 1,
|
|
|
352
|
+ "taskId": taskData.Id,
|
|
|
353
|
+ })
|
163
|
if err != nil {
|
354
|
if err != nil {
|
164
|
return fmt.Errorf("查询反馈异常的数据:%s", err)
|
355
|
return fmt.Errorf("查询反馈异常的数据:%s", err)
|
165
|
}
|
356
|
}
|
166
|
- // 辅导异常通知该条任务负责人的上级;辅导异常超过3天,通知任务负责人的上上级
|
357
|
+ //
|
167
|
anomalyDataTmp := domain.TaskAnomaly{
|
358
|
anomalyDataTmp := domain.TaskAnomaly{
|
168
|
- Id: taskData.Id,
|
|
|
169
|
- CreatedAt: taskData.CreatedAt,
|
|
|
170
|
- UpdatedAt: taskData.UpdatedAt,
|
|
|
171
|
- CompanyId: taskData.CompanyId,
|
|
|
172
|
- TaskId: taskData.Id,
|
|
|
173
|
- Category: 3,
|
|
|
174
|
- CurrentStage: taskData.CurrentStage,
|
|
|
175
|
- LastStage: taskData.LastStage,
|
|
|
176
|
- AssessFlag: 0,
|
|
|
177
|
- WarnFlag: 0,
|
|
|
178
|
- AssistFlag: taskData.AssistFlag,
|
|
|
179
|
- IsLast: 1,
|
|
|
180
|
- TaskLevel: taskData.LevelName,
|
|
|
181
|
- TaskName: taskData.Name,
|
|
|
182
|
- TaskAlias: taskData.Alias,
|
|
|
183
|
- TaskSortBy: taskData.SortBy,
|
|
|
184
|
- TaskEndTime: taskData.EndTime,
|
|
|
185
|
- RecordBegin: time.Now().Unix(),
|
|
|
186
|
- NoticeWho: []int64{useList[0].ParentId},
|
359
|
+ Id: taskData.Id,
|
|
|
360
|
+ CreatedAt: time.Now(),
|
|
|
361
|
+ UpdatedAt: time.Now(),
|
|
|
362
|
+ CompanyId: taskData.CompanyId,
|
|
|
363
|
+ TaskId: taskData.Id,
|
|
|
364
|
+ Category: 3,
|
|
|
365
|
+ CurrentStage: taskData.CurrentStage,
|
|
|
366
|
+ LastStage: taskData.LastStage,
|
|
|
367
|
+ TaskStageCheck: taskRecord.TaskStageCheck,
|
|
|
368
|
+ AssessFlag: taskData.Anomaly,
|
|
|
369
|
+ WarnFlag: 0,
|
|
|
370
|
+ AssistFlag: 0,
|
|
|
371
|
+ 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(),
|
|
|
378
|
+ NoticeWho: []map[string]string{},
|
187
|
Marks: map[string]string{
|
379
|
Marks: map[string]string{
|
188
|
"a": "", "b": "", "c": "", "d": "",
|
380
|
"a": "", "b": "", "c": "", "d": "",
|
189
|
},
|
381
|
},
|
190
|
}
|
382
|
}
|
191
|
- if taskData.AssistFlag >= taskData.AssistFlagMax {
|
|
|
192
|
- //通知任务负责人的上上级
|
|
|
193
|
- _, useList2, err := userRepo.Find(map[string]interface{}{"id": useList[0].ParentId, "limit": 1})
|
|
|
194
|
- if err != nil {
|
|
|
195
|
- return fmt.Errorf("获取任务Leader:%s", err)
|
|
|
196
|
- }
|
|
|
197
|
- if len(useList2) > 0 {
|
|
|
198
|
- anomalyDataTmp.NoticeWho = append(anomalyDataTmp.NoticeWho, useList2[0].Id)
|
|
|
199
|
- }
|
|
|
200
|
- }
|
|
|
201
|
if len(oldAnomaly) > 0 {
|
383
|
if len(oldAnomaly) > 0 {
|
202
|
anomalyDataTmp.RecordBegin = oldAnomaly[0].RecordBegin
|
384
|
anomalyDataTmp.RecordBegin = oldAnomaly[0].RecordBegin
|
203
|
oldAnomaly[0].IsLast = 2
|
385
|
oldAnomaly[0].IsLast = 2
|
|
@@ -206,6 +388,27 @@ func isAssistFlag(transactionContext application.TransactionContext, taskData *d |
|
@@ -206,6 +388,27 @@ func isAssistFlag(transactionContext application.TransactionContext, taskData *d |
206
|
return fmt.Errorf("更新里程碑异常记录:%s", err)
|
388
|
return fmt.Errorf("更新里程碑异常记录:%s", err)
|
207
|
}
|
389
|
}
|
208
|
}
|
390
|
}
|
|
|
391
|
+ // 2天未反馈通知被评估人自己;3天通知上级
|
|
|
392
|
+ // 获取任务Leader的数据
|
|
|
393
|
+ _, useList, err := userRepo.Find(map[string]interface{}{"id": taskData.Leader.Id, "limit": 1})
|
|
|
394
|
+ if err != nil {
|
|
|
395
|
+ return fmt.Errorf("获取任务Leader:%s", err)
|
|
|
396
|
+ }
|
|
|
397
|
+ var userParentId int64
|
|
|
398
|
+ if len(useList) > 0 {
|
|
|
399
|
+ anomalyDataTmp.SetNoticeWho(useList[0])
|
|
|
400
|
+ userParentId = useList[0].ParentId
|
|
|
401
|
+ }
|
|
|
402
|
+ anomalyDay := xtime.SubDayAbs(time.Now(), time.Unix(anomalyDataTmp.RecordBegin, 0))
|
|
|
403
|
+ if anomalyDay > 3 && userParentId > 0 {
|
|
|
404
|
+ _, useList2, err := userRepo.Find(map[string]interface{}{"id": userParentId, "limit": 1})
|
|
|
405
|
+ if err != nil {
|
|
|
406
|
+ return fmt.Errorf("获取任务Leader:%s", err)
|
|
|
407
|
+ }
|
|
|
408
|
+ if len(useList2) > 0 {
|
|
|
409
|
+ anomalyDataTmp.SetNoticeWho(useList2[0])
|
|
|
410
|
+ }
|
|
|
411
|
+ }
|
209
|
err = taskAnomalyRepo.Save(&anomalyDataTmp)
|
412
|
err = taskAnomalyRepo.Save(&anomalyDataTmp)
|
210
|
if err != nil {
|
413
|
if err != nil {
|
211
|
return fmt.Errorf("保存里程碑异常记录:%s", err)
|
414
|
return fmt.Errorf("保存里程碑异常记录:%s", err)
|
|
@@ -213,8 +416,3 @@ func isAssistFlag(transactionContext application.TransactionContext, taskData *d |
|
@@ -213,8 +416,3 @@ func isAssistFlag(transactionContext application.TransactionContext, taskData *d |
213
|
return nil
|
416
|
return nil
|
214
|
|
417
|
|
215
|
} |
418
|
} |
216
|
-
|
|
|
217
|
-// 处理反馈异常的情况
|
|
|
218
|
-func isAssessFlag(transactionContext application.TransactionContext, taskData *domain.Task) error {
|
|
|
219
|
- return nil
|
|
|
220
|
-} |
|
|