|
@@ -42,7 +42,6 @@ func (srv TaskService) ListTaskAnomaly1(param *command.ListTaskAnomalyCommand) ( |
|
@@ -42,7 +42,6 @@ func (srv TaskService) ListTaskAnomaly1(param *command.ListTaskAnomalyCommand) ( |
42
|
}
|
42
|
}
|
43
|
|
43
|
|
44
|
listData := []adapter.TaskAnomalyItem{}
|
44
|
listData := []adapter.TaskAnomalyItem{}
|
45
|
- nowTime := time.Now()
|
|
|
46
|
for _, val := range anomalyList {
|
45
|
for _, val := range anomalyList {
|
47
|
item := adapter.TaskAnomalyItem{
|
46
|
item := adapter.TaskAnomalyItem{
|
48
|
Id: val.Id,
|
47
|
Id: val.Id,
|
|
@@ -99,7 +98,7 @@ func (srv TaskService) ListTaskAnomaly1(param *command.ListTaskAnomalyCommand) ( |
|
@@ -99,7 +98,7 @@ func (srv TaskService) ListTaskAnomaly1(param *command.ListTaskAnomalyCommand) ( |
99
|
if val.TaskStageCheck.RealCompletedAt == 0 && val.TaskStageCheck.Id > 0 {
|
98
|
if val.TaskStageCheck.RealCompletedAt == 0 && val.TaskStageCheck.Id > 0 {
|
100
|
//逾期未完成
|
99
|
//逾期未完成
|
101
|
planCompletedAt := time.Unix(val.TaskStageCheck.PlanCompletedAt, 0)
|
100
|
planCompletedAt := time.Unix(val.TaskStageCheck.PlanCompletedAt, 0)
|
102
|
- subDay := xtime.SubDayAbs(nowTime, planCompletedAt)
|
101
|
+ subDay := xtime.SubDayAbs(val.CreatedAt, planCompletedAt)
|
103
|
item.AnomalyDesc = fmt.Sprintf("里程碑%s已逾期%d天", val.TaskStageCheck.Name, subDay)
|
102
|
item.AnomalyDesc = fmt.Sprintf("里程碑%s已逾期%d天", val.TaskStageCheck.Name, subDay)
|
104
|
} else if val.TaskStageCheck.RealCompletedAt > 0 && val.TaskStageCheck.Id > 0 {
|
103
|
} else if val.TaskStageCheck.RealCompletedAt > 0 && val.TaskStageCheck.Id > 0 {
|
105
|
//逾期完成
|
104
|
//逾期完成
|
|
@@ -113,7 +112,7 @@ func (srv TaskService) ListTaskAnomaly1(param *command.ListTaskAnomalyCommand) ( |
|
@@ -113,7 +112,7 @@ func (srv TaskService) ListTaskAnomaly1(param *command.ListTaskAnomalyCommand) ( |
113
|
//反馈异常
|
112
|
//反馈异常
|
114
|
{
|
113
|
{
|
115
|
recordBegin := time.Unix(val.RecordBegin, 0)
|
114
|
recordBegin := time.Unix(val.RecordBegin, 0)
|
116
|
- subDay := xtime.SubDayAbs(nowTime, recordBegin)
|
115
|
+ subDay := xtime.SubDayAbs(val.CreatedAt, recordBegin)
|
117
|
item.AnomalyDesc = fmt.Sprintf(
|
116
|
item.AnomalyDesc = fmt.Sprintf(
|
118
|
"本任务自%s未正常反馈项目进度,已异常%d天",
|
117
|
"本任务自%s未正常反馈项目进度,已异常%d天",
|
119
|
recordBegin.Local().Format("2006-01-02"),
|
118
|
recordBegin.Local().Format("2006-01-02"),
|
|
@@ -124,7 +123,7 @@ func (srv TaskService) ListTaskAnomaly1(param *command.ListTaskAnomalyCommand) ( |
|
@@ -124,7 +123,7 @@ func (srv TaskService) ListTaskAnomaly1(param *command.ListTaskAnomalyCommand) ( |
124
|
//辅导异常
|
123
|
//辅导异常
|
125
|
{
|
124
|
{
|
126
|
recordBegin := time.Unix(val.RecordBegin, 0)
|
125
|
recordBegin := time.Unix(val.RecordBegin, 0)
|
127
|
- subDay := xtime.SubDayAbs(nowTime, recordBegin)
|
126
|
+ subDay := xtime.SubDayAbs(val.CreatedAt, recordBegin)
|
128
|
item.AnomalyDesc = fmt.Sprintf(
|
127
|
item.AnomalyDesc = fmt.Sprintf(
|
129
|
"本任务计划于%s完成辅导,已逾期%d天",
|
128
|
"本任务计划于%s完成辅导,已逾期%d天",
|
130
|
recordBegin.Local().Format("2006-01-02"),
|
129
|
recordBegin.Local().Format("2006-01-02"),
|
|
@@ -141,13 +140,253 @@ func (srv TaskService) ListTaskAnomaly1(param *command.ListTaskAnomalyCommand) ( |
|
@@ -141,13 +140,253 @@ func (srv TaskService) ListTaskAnomaly1(param *command.ListTaskAnomalyCommand) ( |
141
|
}
|
140
|
}
|
142
|
|
141
|
|
143
|
// 我的下级负责任务,异常列表
|
142
|
// 我的下级负责任务,异常列表
|
144
|
-func (srv TaskService) ListTaskAnomaly2() error {
|
|
|
145
|
- return nil
|
143
|
+func (srv TaskService) ListTaskAnomaly2(param *command.ListTaskAnomalyCommand) (map[string]interface{}, error) {
|
|
|
144
|
+ transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
145
|
+ if err != nil {
|
|
|
146
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
147
|
+ }
|
|
|
148
|
+ if err := transactionContext.StartTransaction(); err != nil {
|
|
|
149
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
150
|
+ }
|
|
|
151
|
+ defer func() {
|
|
|
152
|
+ _ = transactionContext.RollbackTransaction()
|
|
|
153
|
+ }()
|
|
|
154
|
+ taskAnomalyDao := dao.NewTaskAnomalyDao(map[string]interface{}{
|
|
|
155
|
+ "transactionContext": transactionContext,
|
|
|
156
|
+ })
|
|
|
157
|
+ limit := 500
|
|
|
158
|
+ offset := 0
|
|
|
159
|
+ cnt, anomalyList, err := taskAnomalyDao.List2(param.UserId, param.CompanyId, param.TaskName, param.Category, param.DayTime, param.LeaderId, limit, offset)
|
|
|
160
|
+ if err != nil {
|
|
|
161
|
+ return map[string]interface{}{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
162
|
+ }
|
|
|
163
|
+
|
|
|
164
|
+ if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
165
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
166
|
+ }
|
|
|
167
|
+
|
|
|
168
|
+ listData := []adapter.TaskAnomalyItem{}
|
|
|
169
|
+
|
|
|
170
|
+ for _, val := range anomalyList {
|
|
|
171
|
+ item := adapter.TaskAnomalyItem{
|
|
|
172
|
+ Id: val.Id,
|
|
|
173
|
+ TaskId: val.TaskId,
|
|
|
174
|
+ TaskRecordId: val.TaskRecordId,
|
|
|
175
|
+ Category: val.Category,
|
|
|
176
|
+ Leader: val.LeaderName,
|
|
|
177
|
+ CurrentStage: adapter.TaskStage{
|
|
|
178
|
+ Id: val.CurrentStage.Id,
|
|
|
179
|
+ Name: val.CurrentStage.Name,
|
|
|
180
|
+ StatusDescription: val.CurrentStage.StatusDescription(),
|
|
|
181
|
+ SortBy: val.CurrentStage.SortBy,
|
|
|
182
|
+ PlanCompletedAt: time.Unix(val.CurrentStage.PlanCompletedAt, 0).Local().Format("2006-01-02"),
|
|
|
183
|
+ RealCompletedAt: "",
|
|
|
184
|
+ },
|
|
|
185
|
+ LastStage: adapter.TaskStage{
|
|
|
186
|
+ Id: val.LastStage.Id,
|
|
|
187
|
+ Name: val.LastStage.Name,
|
|
|
188
|
+ StatusDescription: val.LastStage.StatusDescription(),
|
|
|
189
|
+ SortBy: val.LastStage.SortBy,
|
|
|
190
|
+ PlanCompletedAt: time.Unix(val.LastStage.PlanCompletedAt, 0).Local().Format("2006-01-02"),
|
|
|
191
|
+ RealCompletedAt: "",
|
|
|
192
|
+ },
|
|
|
193
|
+ AssessFlag: val.AssessFlag,
|
|
|
194
|
+ WarnFlag: val.WarnFlag,
|
|
|
195
|
+ AssistFlag: val.AssistFlag,
|
|
|
196
|
+ TaskLevel: val.LevelName,
|
|
|
197
|
+ TaskName: val.TaskName,
|
|
|
198
|
+ TaskAlias: val.TaskAlias,
|
|
|
199
|
+ TaskEndTime: int64(val.TaskEndTime),
|
|
|
200
|
+ TaskSortBy: val.TaskSortBy,
|
|
|
201
|
+ RecordBegin: val.RecordBegin,
|
|
|
202
|
+ MarkA: "",
|
|
|
203
|
+ MarkB: "",
|
|
|
204
|
+ MarkC: "",
|
|
|
205
|
+ MarkD: "",
|
|
|
206
|
+ }
|
|
|
207
|
+ if len(val.Marks) > 0 {
|
|
|
208
|
+ item.MarkA = val.Marks["a"]
|
|
|
209
|
+ item.MarkB = val.Marks["b"]
|
|
|
210
|
+ item.MarkC = val.Marks["c"]
|
|
|
211
|
+ item.MarkD = val.Marks["d"]
|
|
|
212
|
+ }
|
|
|
213
|
+ if val.CurrentStage.RealCompletedAt > 0 {
|
|
|
214
|
+ item.CurrentStage.RealCompletedAt = time.Unix(val.CurrentStage.RealCompletedAt, 0).Local().Format("2006-01-02")
|
|
|
215
|
+ }
|
|
|
216
|
+ if val.LastStage.RealCompletedAt > 0 {
|
|
|
217
|
+ item.LastStage.RealCompletedAt = time.Unix(val.LastStage.RealCompletedAt, 0).Local().Format("2006-01-02")
|
|
|
218
|
+ }
|
|
|
219
|
+ switch val.Category {
|
|
|
220
|
+ case 1:
|
|
|
221
|
+ {
|
|
|
222
|
+ //里程碑异常
|
|
|
223
|
+ if val.TaskStageCheck.RealCompletedAt == 0 && val.TaskStageCheck.Id > 0 {
|
|
|
224
|
+ //逾期未完成
|
|
|
225
|
+ planCompletedAt := time.Unix(val.TaskStageCheck.PlanCompletedAt, 0)
|
|
|
226
|
+ subDay := xtime.SubDayAbs(val.CreatedAt, planCompletedAt)
|
|
|
227
|
+ item.AnomalyDesc = fmt.Sprintf("里程碑%s已逾期%d天", val.TaskStageCheck.Name, subDay)
|
|
|
228
|
+ } else if val.TaskStageCheck.RealCompletedAt > 0 && val.TaskStageCheck.Id > 0 {
|
|
|
229
|
+ //逾期完成
|
|
|
230
|
+ planCompletedAt := time.Unix(val.TaskStageCheck.PlanCompletedAt, 0)
|
|
|
231
|
+ realCompletedAt := time.Unix(val.TaskStageCheck.RealCompletedAt, 0)
|
|
|
232
|
+ subDay := xtime.SubDayAbs(realCompletedAt, planCompletedAt)
|
|
|
233
|
+ item.AnomalyDesc = fmt.Sprintf("里程碑%s逾期%d天完成", val.TaskStageCheck.Name, subDay)
|
|
|
234
|
+ }
|
|
|
235
|
+ }
|
|
|
236
|
+ case 2:
|
|
|
237
|
+ //反馈异常
|
|
|
238
|
+ {
|
|
|
239
|
+ recordBegin := time.Unix(val.RecordBegin, 0)
|
|
|
240
|
+ subDay := xtime.SubDayAbs(val.CreatedAt, recordBegin)
|
|
|
241
|
+ item.AnomalyDesc = fmt.Sprintf(
|
|
|
242
|
+ "本任务自%s未正常反馈项目进度,已异常%d天",
|
|
|
243
|
+ recordBegin.Local().Format("2006-01-02"),
|
|
|
244
|
+ subDay,
|
|
|
245
|
+ )
|
|
|
246
|
+ }
|
|
|
247
|
+ case 3:
|
|
|
248
|
+ //辅导异常
|
|
|
249
|
+ {
|
|
|
250
|
+ recordBegin := time.Unix(val.RecordBegin, 0)
|
|
|
251
|
+ subDay := xtime.SubDayAbs(val.CreatedAt, recordBegin)
|
|
|
252
|
+ item.AnomalyDesc = fmt.Sprintf(
|
|
|
253
|
+ "本任务计划于%s完成辅导,已逾期%d天",
|
|
|
254
|
+ recordBegin.Local().Format("2006-01-02"),
|
|
|
255
|
+ subDay,
|
|
|
256
|
+ )
|
|
|
257
|
+ }
|
|
|
258
|
+ }
|
|
|
259
|
+
|
|
|
260
|
+ listData = append(listData, item)
|
|
|
261
|
+ }
|
|
|
262
|
+
|
|
|
263
|
+ result := tool_funs.SimpleWrapGridMap(int64(cnt), listData)
|
|
|
264
|
+ return result, nil
|
146
|
}
|
265
|
}
|
147
|
|
266
|
|
148
|
// 与我有关的任务,异常列表
|
267
|
// 与我有关的任务,异常列表
|
149
|
-func (srv TaskService) ListTaskAnomaly3() error {
|
|
|
150
|
- return nil
|
268
|
+func (srv TaskService) ListTaskAnomaly3(param *command.ListTaskAnomalyCommand) (map[string]interface{}, error) {
|
|
|
269
|
+ transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
270
|
+ if err != nil {
|
|
|
271
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
272
|
+ }
|
|
|
273
|
+ if err := transactionContext.StartTransaction(); err != nil {
|
|
|
274
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
275
|
+ }
|
|
|
276
|
+ defer func() {
|
|
|
277
|
+ _ = transactionContext.RollbackTransaction()
|
|
|
278
|
+ }()
|
|
|
279
|
+ taskAnomalyDao := dao.NewTaskAnomalyDao(map[string]interface{}{
|
|
|
280
|
+ "transactionContext": transactionContext,
|
|
|
281
|
+ })
|
|
|
282
|
+ limit := 500
|
|
|
283
|
+ offset := 0
|
|
|
284
|
+ cnt, anomalyList, err := taskAnomalyDao.List3(param.UserId, param.CompanyId, param.TaskName, param.Category, param.DayTime, param.LeaderId, limit, offset)
|
|
|
285
|
+ if err != nil {
|
|
|
286
|
+ return map[string]interface{}{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
287
|
+ }
|
|
|
288
|
+
|
|
|
289
|
+ if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
290
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
291
|
+ }
|
|
|
292
|
+
|
|
|
293
|
+ listData := []adapter.TaskAnomalyItem{}
|
|
|
294
|
+
|
|
|
295
|
+ for _, val := range anomalyList {
|
|
|
296
|
+ item := adapter.TaskAnomalyItem{
|
|
|
297
|
+ Id: val.Id,
|
|
|
298
|
+ TaskId: val.TaskId,
|
|
|
299
|
+ TaskRecordId: val.TaskRecordId,
|
|
|
300
|
+ Category: val.Category,
|
|
|
301
|
+ Leader: val.LeaderName,
|
|
|
302
|
+ CurrentStage: adapter.TaskStage{
|
|
|
303
|
+ Id: val.CurrentStage.Id,
|
|
|
304
|
+ Name: val.CurrentStage.Name,
|
|
|
305
|
+ StatusDescription: val.CurrentStage.StatusDescription(),
|
|
|
306
|
+ SortBy: val.CurrentStage.SortBy,
|
|
|
307
|
+ PlanCompletedAt: time.Unix(val.CurrentStage.PlanCompletedAt, 0).Local().Format("2006-01-02"),
|
|
|
308
|
+ RealCompletedAt: "",
|
|
|
309
|
+ },
|
|
|
310
|
+ LastStage: adapter.TaskStage{
|
|
|
311
|
+ Id: val.LastStage.Id,
|
|
|
312
|
+ Name: val.LastStage.Name,
|
|
|
313
|
+ StatusDescription: val.LastStage.StatusDescription(),
|
|
|
314
|
+ SortBy: val.LastStage.SortBy,
|
|
|
315
|
+ PlanCompletedAt: time.Unix(val.LastStage.PlanCompletedAt, 0).Local().Format("2006-01-02"),
|
|
|
316
|
+ RealCompletedAt: "",
|
|
|
317
|
+ },
|
|
|
318
|
+ AssessFlag: val.AssessFlag,
|
|
|
319
|
+ WarnFlag: val.WarnFlag,
|
|
|
320
|
+ AssistFlag: val.AssistFlag,
|
|
|
321
|
+ TaskLevel: val.LevelName,
|
|
|
322
|
+ TaskName: val.TaskName,
|
|
|
323
|
+ TaskAlias: val.TaskAlias,
|
|
|
324
|
+ TaskEndTime: int64(val.TaskEndTime),
|
|
|
325
|
+ TaskSortBy: val.TaskSortBy,
|
|
|
326
|
+ RecordBegin: val.RecordBegin,
|
|
|
327
|
+ MarkA: "",
|
|
|
328
|
+ MarkB: "",
|
|
|
329
|
+ MarkC: "",
|
|
|
330
|
+ MarkD: "",
|
|
|
331
|
+ }
|
|
|
332
|
+ if len(val.Marks) > 0 {
|
|
|
333
|
+ item.MarkA = val.Marks["a"]
|
|
|
334
|
+ item.MarkB = val.Marks["b"]
|
|
|
335
|
+ item.MarkC = val.Marks["c"]
|
|
|
336
|
+ item.MarkD = val.Marks["d"]
|
|
|
337
|
+ }
|
|
|
338
|
+ if val.CurrentStage.RealCompletedAt > 0 {
|
|
|
339
|
+ item.CurrentStage.RealCompletedAt = time.Unix(val.CurrentStage.RealCompletedAt, 0).Local().Format("2006-01-02")
|
|
|
340
|
+ }
|
|
|
341
|
+ if val.LastStage.RealCompletedAt > 0 {
|
|
|
342
|
+ item.LastStage.RealCompletedAt = time.Unix(val.LastStage.RealCompletedAt, 0).Local().Format("2006-01-02")
|
|
|
343
|
+ }
|
|
|
344
|
+ switch val.Category {
|
|
|
345
|
+ case 1:
|
|
|
346
|
+ {
|
|
|
347
|
+ //里程碑异常
|
|
|
348
|
+ if val.TaskStageCheck.RealCompletedAt == 0 && val.TaskStageCheck.Id > 0 {
|
|
|
349
|
+ //逾期未完成
|
|
|
350
|
+ planCompletedAt := time.Unix(val.TaskStageCheck.PlanCompletedAt, 0)
|
|
|
351
|
+ subDay := xtime.SubDayAbs(val.CreatedAt, planCompletedAt)
|
|
|
352
|
+ item.AnomalyDesc = fmt.Sprintf("里程碑%s已逾期%d天", val.TaskStageCheck.Name, subDay)
|
|
|
353
|
+ } else if val.TaskStageCheck.RealCompletedAt > 0 && val.TaskStageCheck.Id > 0 {
|
|
|
354
|
+ //逾期完成
|
|
|
355
|
+ planCompletedAt := time.Unix(val.TaskStageCheck.PlanCompletedAt, 0)
|
|
|
356
|
+ realCompletedAt := time.Unix(val.TaskStageCheck.RealCompletedAt, 0)
|
|
|
357
|
+ subDay := xtime.SubDayAbs(realCompletedAt, planCompletedAt)
|
|
|
358
|
+ item.AnomalyDesc = fmt.Sprintf("里程碑%s逾期%d天完成", val.TaskStageCheck.Name, subDay)
|
|
|
359
|
+ }
|
|
|
360
|
+ }
|
|
|
361
|
+ case 2:
|
|
|
362
|
+ //反馈异常
|
|
|
363
|
+ {
|
|
|
364
|
+ recordBegin := time.Unix(val.RecordBegin, 0)
|
|
|
365
|
+ subDay := xtime.SubDayAbs(val.CreatedAt, recordBegin)
|
|
|
366
|
+ item.AnomalyDesc = fmt.Sprintf(
|
|
|
367
|
+ "本任务自%s未正常反馈项目进度,已异常%d天",
|
|
|
368
|
+ recordBegin.Local().Format("2006-01-02"),
|
|
|
369
|
+ subDay,
|
|
|
370
|
+ )
|
|
|
371
|
+ }
|
|
|
372
|
+ case 3:
|
|
|
373
|
+ //辅导异常
|
|
|
374
|
+ {
|
|
|
375
|
+ recordBegin := time.Unix(val.RecordBegin, 0)
|
|
|
376
|
+ subDay := xtime.SubDayAbs(val.CreatedAt, recordBegin)
|
|
|
377
|
+ item.AnomalyDesc = fmt.Sprintf(
|
|
|
378
|
+ "本任务计划于%s完成辅导,已逾期%d天",
|
|
|
379
|
+ recordBegin.Local().Format("2006-01-02"),
|
|
|
380
|
+ subDay,
|
|
|
381
|
+ )
|
|
|
382
|
+ }
|
|
|
383
|
+ }
|
|
|
384
|
+
|
|
|
385
|
+ listData = append(listData, item)
|
|
|
386
|
+ }
|
|
|
387
|
+
|
|
|
388
|
+ result := tool_funs.SimpleWrapGridMap(int64(cnt), listData)
|
|
|
389
|
+ return result, nil
|
151
|
}
|
390
|
}
|
152
|
|
391
|
|
153
|
// 对异常记录的操作标记
|
392
|
// 对异常记录的操作标记
|