|
@@ -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,37 +88,61 @@ func checkTaskRecordV2(param *domain.TaskRecord) error { |
|
@@ -79,37 +88,61 @@ func checkTaskRecordV2(param *domain.TaskRecord) error { |
79
|
return nil
|
88
|
return nil
|
80
|
}
|
89
|
}
|
81
|
|
90
|
|
82
|
-// 处理里程碑异常的情况
|
|
|
83
|
-func isWarnFlag(transactionContext application.TransactionContext, taskData *domain.Task) error {
|
91
|
+// 取消里程碑异常
|
|
|
92
|
+func isNotWarnFlag(transactionContext application.TransactionContext, taskData *domain.Task, taskRecord *domain.TaskRecord) error {
|
84
|
taskAnomalyRepo := factory.CreateTaskAnomalyRepository(map[string]interface{}{
|
93
|
taskAnomalyRepo := factory.CreateTaskAnomalyRepository(map[string]interface{}{
|
85
|
"transactionContext": transactionContext,
|
94
|
"transactionContext": transactionContext,
|
86
|
})
|
95
|
})
|
87
|
-
|
|
|
88
|
- userRepo := factory.CreateUserRepository(map[string]interface{}{
|
|
|
89
|
- "transactionContext": transactionContext,
|
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),
|
90
|
})
|
102
|
})
|
91
|
- //获取任务Leader的数据
|
|
|
92
|
- _, useList, err := userRepo.Find(map[string]interface{}{"id": taskData.Leader.Id, "limit": 1})
|
|
|
93
|
if err != nil {
|
103
|
if err != nil {
|
94
|
- return fmt.Errorf("获取任务Leader:%s", err)
|
104
|
+ return fmt.Errorf("查询里程碑异常的数据:%s", err)
|
95
|
}
|
105
|
}
|
96
|
- if len(useList) == 0 {
|
106
|
+ if len(oldAnomaly) == 0 {
|
97
|
return nil
|
107
|
return nil
|
98
|
}
|
108
|
}
|
99
|
- _, oldAnomaly, err := taskAnomalyRepo.Find(map[string]interface{}{"isLast": 1, "category": 2, "limit": 1})
|
109
|
+ oldAnomaly[0].IsLast = 2
|
|
|
110
|
+ err = taskAnomalyRepo.Save(oldAnomaly[0])
|
|
|
111
|
+ return fmt.Errorf("取消里程碑异常:%s", err)
|
|
|
112
|
+}
|
|
|
113
|
+
|
|
|
114
|
+// 处理里程碑异常的情况
|
|
|
115
|
+func isWarnFlag(transactionContext application.TransactionContext, taskData *domain.Task, taskRecord *domain.TaskRecord) error {
|
|
|
116
|
+ taskAnomalyRepo := factory.CreateTaskAnomalyRepository(map[string]interface{}{
|
|
|
117
|
+ "transactionContext": transactionContext,
|
|
|
118
|
+ })
|
|
|
119
|
+
|
|
|
120
|
+ userRepo := factory.CreateUserRepository(map[string]interface{}{
|
|
|
121
|
+ "transactionContext": transactionContext,
|
|
|
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
|
+ })
|
100
|
if err != nil {
|
131
|
if err != nil {
|
101
|
- return fmt.Errorf("查询反馈异常的数据:%s", err)
|
132
|
+ return fmt.Errorf("查询里程碑异常的数据:%s", err)
|
102
|
}
|
133
|
}
|
103
|
- // 异常就通知自己和上级
|
134
|
+
|
104
|
anomalyDataTmp := domain.TaskAnomaly{
|
135
|
anomalyDataTmp := domain.TaskAnomaly{
|
105
|
Id: taskData.Id,
|
136
|
Id: taskData.Id,
|
106
|
- CreatedAt: taskData.CreatedAt,
|
|
|
107
|
- UpdatedAt: taskData.UpdatedAt,
|
137
|
+ CreatedAt: time.Now(),
|
|
|
138
|
+ UpdatedAt: time.Now(),
|
108
|
CompanyId: taskData.CompanyId,
|
139
|
CompanyId: taskData.CompanyId,
|
109
|
TaskId: taskData.Id,
|
140
|
TaskId: taskData.Id,
|
|
|
141
|
+ TaskRecordId: taskRecord.Id,
|
110
|
Category: 1,
|
142
|
Category: 1,
|
111
|
CurrentStage: taskData.CurrentStage,
|
143
|
CurrentStage: taskData.CurrentStage,
|
112
|
LastStage: taskData.LastStage,
|
144
|
LastStage: taskData.LastStage,
|
|
|
145
|
+ TaskStageCheck: taskRecord.TaskStageCheck,
|
113
|
AssessFlag: 0,
|
146
|
AssessFlag: 0,
|
114
|
WarnFlag: int(taskData.WarnFlag),
|
147
|
WarnFlag: int(taskData.WarnFlag),
|
115
|
AssistFlag: 0,
|
148
|
AssistFlag: 0,
|
|
@@ -119,22 +152,43 @@ func isWarnFlag(transactionContext application.TransactionContext, taskData *dom |
|
@@ -119,22 +152,43 @@ func isWarnFlag(transactionContext application.TransactionContext, taskData *dom |
119
|
TaskAlias: taskData.Alias,
|
152
|
TaskAlias: taskData.Alias,
|
120
|
TaskSortBy: taskData.SortBy,
|
153
|
TaskSortBy: taskData.SortBy,
|
121
|
TaskEndTime: taskData.EndTime,
|
154
|
TaskEndTime: taskData.EndTime,
|
122
|
- RecordBegin: time.Now().Unix(),
|
|
|
123
|
- NoticeWho: []int64{taskData.Leader.Id, useList[0].ParentId},
|
155
|
+ RecordBegin: taskRecord.CreatedAt.Unix(),
|
|
|
156
|
+ NoticeWho: []map[string]string{},
|
124
|
Marks: map[string]string{
|
157
|
Marks: map[string]string{
|
125
|
"a": "", "b": "", "c": "", "d": "",
|
158
|
"a": "", "b": "", "c": "", "d": "",
|
126
|
},
|
159
|
},
|
127
|
}
|
160
|
}
|
128
|
-
|
|
|
129
|
if len(oldAnomaly) > 0 {
|
161
|
if len(oldAnomaly) > 0 {
|
130
|
- anomalyDataTmp.RecordBegin = oldAnomaly[0].RecordBegin
|
|
|
131
|
anomalyDataTmp.WarnFlag = oldAnomaly[0].WarnFlag + 1
|
162
|
anomalyDataTmp.WarnFlag = oldAnomaly[0].WarnFlag + 1
|
|
|
163
|
+ anomalyDataTmp.RecordBegin = oldAnomaly[0].RecordBegin
|
132
|
oldAnomaly[0].IsLast = 2
|
164
|
oldAnomaly[0].IsLast = 2
|
133
|
err = taskAnomalyRepo.Save(oldAnomaly[0])
|
165
|
err = taskAnomalyRepo.Save(oldAnomaly[0])
|
134
|
if err != nil {
|
166
|
if err != nil {
|
135
|
return fmt.Errorf("更新里程碑异常记录:%s", err)
|
167
|
return fmt.Errorf("更新里程碑异常记录:%s", err)
|
136
|
}
|
168
|
}
|
137
|
}
|
169
|
}
|
|
|
170
|
+ // 异常就通知自己和上级
|
|
|
171
|
+ //获取任务Leader的数据
|
|
|
172
|
+ _, useList, err := userRepo.Find(map[string]interface{}{"id": taskData.Leader.Id, "limit": 1})
|
|
|
173
|
+ if err != nil {
|
|
|
174
|
+ return fmt.Errorf("获取任务Leader:%s", err)
|
|
|
175
|
+ }
|
|
|
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
|
+ }
|
138
|
err = taskAnomalyRepo.Save(&anomalyDataTmp)
|
192
|
err = taskAnomalyRepo.Save(&anomalyDataTmp)
|
139
|
if err != nil {
|
193
|
if err != nil {
|
140
|
return fmt.Errorf("保存里程碑异常记录:%s", err)
|
194
|
return fmt.Errorf("保存里程碑异常记录:%s", err)
|
|
@@ -142,37 +196,59 @@ func isWarnFlag(transactionContext application.TransactionContext, taskData *dom |
|
@@ -142,37 +196,59 @@ func isWarnFlag(transactionContext application.TransactionContext, taskData *dom |
142
|
return nil
|
196
|
return nil
|
143
|
}
|
197
|
}
|
144
|
|
198
|
|
145
|
-// 处理辅导异常的情况
|
|
|
146
|
-func isAssistFlag(transactionContext application.TransactionContext, taskData *domain.Task) error {
|
199
|
+// 取消辅导异常的情况
|
|
|
200
|
+func isNotAssistFlag(transactionContext application.TransactionContext, taskData *domain.Task, taskRecord *domain.TaskRecord) error {
|
147
|
taskAnomalyRepo := factory.CreateTaskAnomalyRepository(map[string]interface{}{
|
201
|
taskAnomalyRepo := factory.CreateTaskAnomalyRepository(map[string]interface{}{
|
148
|
"transactionContext": transactionContext,
|
202
|
"transactionContext": transactionContext,
|
149
|
})
|
203
|
})
|
150
|
|
204
|
|
151
|
- userRepo := factory.CreateUserRepository(map[string]interface{}{
|
|
|
152
|
- "transactionContext": transactionContext,
|
205
|
+ _, oldAnomaly, err := taskAnomalyRepo.Find(map[string]interface{}{
|
|
|
206
|
+ "isLast": 1,
|
|
|
207
|
+ "category": 3,
|
|
|
208
|
+ "limit": 1,
|
|
|
209
|
+ "taskId": taskData.Id,
|
153
|
})
|
210
|
})
|
154
|
- //获取任务Leader的数据
|
|
|
155
|
- _, useList, err := userRepo.Find(map[string]interface{}{"id": taskData.Leader.Id, "limit": 1})
|
|
|
156
|
if err != nil {
|
211
|
if err != nil {
|
157
|
- return fmt.Errorf("获取任务Leader:%s", err)
|
212
|
+ return fmt.Errorf("查询辅导异常的数据:%s", err)
|
158
|
}
|
213
|
}
|
159
|
- if len(useList) == 0 {
|
214
|
+ if len(oldAnomaly) == 0 {
|
160
|
return nil
|
215
|
return nil
|
161
|
}
|
216
|
}
|
162
|
- _, oldAnomaly, err := taskAnomalyRepo.Find(map[string]interface{}{"isLast": 1, "category": 3, "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
|
+ })
|
163
|
if err != nil {
|
238
|
if err != nil {
|
164
|
- return fmt.Errorf("查询反馈异常的数据:%s", err)
|
239
|
+ return fmt.Errorf("查询辅导异常的数据:%s", err)
|
165
|
}
|
240
|
}
|
166
|
- // 辅导异常通知该条任务负责人的上级;辅导异常超过3天,通知任务负责人的上上级
|
241
|
+ // 辅导异常通知该条任务负责人的上级;辅导异常超过N天,通知任务负责人的上上级
|
167
|
anomalyDataTmp := domain.TaskAnomaly{
|
242
|
anomalyDataTmp := domain.TaskAnomaly{
|
168
|
Id: taskData.Id,
|
243
|
Id: taskData.Id,
|
169
|
- CreatedAt: taskData.CreatedAt,
|
|
|
170
|
- UpdatedAt: taskData.UpdatedAt,
|
244
|
+ CreatedAt: time.Now(),
|
|
|
245
|
+ UpdatedAt: time.Now(),
|
171
|
CompanyId: taskData.CompanyId,
|
246
|
CompanyId: taskData.CompanyId,
|
172
|
TaskId: taskData.Id,
|
247
|
TaskId: taskData.Id,
|
173
|
Category: 3,
|
248
|
Category: 3,
|
174
|
CurrentStage: taskData.CurrentStage,
|
249
|
CurrentStage: taskData.CurrentStage,
|
175
|
LastStage: taskData.LastStage,
|
250
|
LastStage: taskData.LastStage,
|
|
|
251
|
+ TaskStageCheck: taskRecord.TaskStageCheck,
|
176
|
AssessFlag: 0,
|
252
|
AssessFlag: 0,
|
177
|
WarnFlag: 0,
|
253
|
WarnFlag: 0,
|
178
|
AssistFlag: taskData.AssistFlag,
|
254
|
AssistFlag: taskData.AssistFlag,
|
|
@@ -182,21 +258,127 @@ func isAssistFlag(transactionContext application.TransactionContext, taskData *d |
|
@@ -182,21 +258,127 @@ func isAssistFlag(transactionContext application.TransactionContext, taskData *d |
182
|
TaskAlias: taskData.Alias,
|
258
|
TaskAlias: taskData.Alias,
|
183
|
TaskSortBy: taskData.SortBy,
|
259
|
TaskSortBy: taskData.SortBy,
|
184
|
TaskEndTime: taskData.EndTime,
|
260
|
TaskEndTime: taskData.EndTime,
|
185
|
- RecordBegin: time.Now().Unix(),
|
|
|
186
|
- NoticeWho: []int64{useList[0].ParentId},
|
261
|
+ RecordBegin: taskRecord.CreatedAt.Unix(),
|
|
|
262
|
+ NoticeWho: []map[string]string{},
|
187
|
Marks: map[string]string{
|
263
|
Marks: map[string]string{
|
188
|
"a": "", "b": "", "c": "", "d": "",
|
264
|
"a": "", "b": "", "c": "", "d": "",
|
189
|
},
|
265
|
},
|
190
|
}
|
266
|
}
|
191
|
- if taskData.AssistFlag >= taskData.AssistFlagMax {
|
|
|
192
|
- //通知任务负责人的上上级
|
|
|
193
|
- _, useList2, err := userRepo.Find(map[string]interface{}{"id": useList[0].ParentId, "limit": 1})
|
267
|
+
|
|
|
268
|
+ if len(oldAnomaly) > 0 {
|
|
|
269
|
+ anomalyDataTmp.RecordBegin = oldAnomaly[0].RecordBegin
|
|
|
270
|
+ oldAnomaly[0].IsLast = 2
|
|
|
271
|
+ err = taskAnomalyRepo.Save(oldAnomaly[0])
|
|
|
272
|
+ if err != nil {
|
|
|
273
|
+ return fmt.Errorf("更新里程碑异常记录:%s", err)
|
|
|
274
|
+ }
|
|
|
275
|
+ }
|
|
|
276
|
+ //获取任务Leader的数据
|
|
|
277
|
+ _, useList, err := userRepo.Find(map[string]interface{}{"id": taskData.Leader.Id, "limit": 1})
|
194
|
if err != nil {
|
278
|
if err != nil {
|
195
|
return fmt.Errorf("获取任务Leader:%s", err)
|
279
|
return fmt.Errorf("获取任务Leader:%s", err)
|
196
|
}
|
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
|
197
|
if len(useList2) > 0 {
|
292
|
if len(useList2) > 0 {
|
198
|
- anomalyDataTmp.NoticeWho = append(anomalyDataTmp.NoticeWho, useList2[0].Id)
|
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
|
+
|
|
|
308
|
+ err = taskAnomalyRepo.Save(&anomalyDataTmp)
|
|
|
309
|
+ if err != nil {
|
|
|
310
|
+ return fmt.Errorf("保存里程碑异常记录:%s", err)
|
|
|
311
|
+ }
|
|
|
312
|
+ return nil
|
|
|
313
|
+
|
|
|
314
|
+}
|
|
|
315
|
+
|
|
|
316
|
+// 取消反馈异常的情况
|
|
|
317
|
+func isNotAssessFlag(transactionContext application.TransactionContext, taskData *domain.Task, taskRecord *domain.TaskRecord) error {
|
|
|
318
|
+ taskAnomalyRepo := factory.CreateTaskAnomalyRepository(map[string]interface{}{
|
|
|
319
|
+ "transactionContext": transactionContext,
|
|
|
320
|
+ })
|
|
|
321
|
+
|
|
|
322
|
+ _, oldAnomaly, err := taskAnomalyRepo.Find(map[string]interface{}{
|
|
|
323
|
+ "isLast": 1,
|
|
|
324
|
+ "category": 3,
|
|
|
325
|
+ "limit": 1,
|
|
|
326
|
+ "taskId": taskData.Id,
|
|
|
327
|
+ })
|
|
|
328
|
+ if err != nil {
|
|
|
329
|
+ return fmt.Errorf("查询辅导异常的数据:%s", err)
|
|
|
330
|
+ }
|
|
|
331
|
+ if len(oldAnomaly) == 0 {
|
|
|
332
|
+ return nil
|
|
|
333
|
+ }
|
|
|
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
|
+ })
|
|
|
354
|
+ if err != nil {
|
|
|
355
|
+ return fmt.Errorf("查询反馈异常的数据:%s", err)
|
199
|
}
|
356
|
}
|
|
|
357
|
+ //
|
|
|
358
|
+ anomalyDataTmp := domain.TaskAnomaly{
|
|
|
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{},
|
|
|
379
|
+ Marks: map[string]string{
|
|
|
380
|
+ "a": "", "b": "", "c": "", "d": "",
|
|
|
381
|
+ },
|
200
|
}
|
382
|
}
|
201
|
if len(oldAnomaly) > 0 {
|
383
|
if len(oldAnomaly) > 0 {
|
202
|
anomalyDataTmp.RecordBegin = oldAnomaly[0].RecordBegin
|
384
|
anomalyDataTmp.RecordBegin = oldAnomaly[0].RecordBegin
|
|
@@ -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
|
-} |
|
|