service2.go
5.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
package service
import (
"fmt"
"time"
"github.com/linmadan/egglib-go/core/application"
"github.com/linmadan/egglib-go/utils/tool_funs"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/task/adapter"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/task/command"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/utils/xtime"
)
// 异常中心查看
// 我负责的任务,异常列表
func (srv TaskService) ListTaskAnomaly1(param command.ListTaskAnomalyCommand) (map[string]interface{}, error) {
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
_ = transactionContext.RollbackTransaction()
}()
taskAnomalyDao := dao.NewTaskAnomalyDao(map[string]interface{}{
"transactionContext": transactionContext,
})
limit := 500
offset := 0
cnt, anomalyList, err := taskAnomalyDao.List1(param.UserId, param.CompanyId, param.TaskName, param.Category, param.DayTime, limit, offset)
if err != nil {
return map[string]interface{}{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
listData := []adapter.TaskAnomalyItem{}
nowTime := time.Now()
for _, val := range anomalyList {
item := adapter.TaskAnomalyItem{
Id: val.Id,
TaskId: val.TaskId,
Category: val.Category,
Leader: val.LeaderName,
CurrentStage: adapter.TaskStage{
Id: val.CurrentStage.Id,
Name: val.CurrentStage.Name,
StatusDescription: val.CurrentStage.StatusDescription(),
SortBy: val.CurrentStage.SortBy,
PlanCompletedAt: time.Unix(val.CurrentStage.PlanCompletedAt, 0).Local().Format("2006-01-02"),
RealCompletedAt: "",
},
LastStage: adapter.TaskStage{
Id: val.LastStage.Id,
Name: val.LastStage.Name,
StatusDescription: val.LastStage.StatusDescription(),
SortBy: val.LastStage.SortBy,
PlanCompletedAt: time.Unix(val.LastStage.PlanCompletedAt, 0).Local().Format("2006-01-02"),
RealCompletedAt: "",
},
AssessFlag: val.AssessFlag,
WarnFlag: val.WarnFlag,
AssistFlag: val.AssistFlag,
TaskLevel: val.LevelName,
TaskName: val.TaskName,
TaskAlias: val.TaskAlias,
TaskEndTime: int64(val.TaskEndTime),
TaskSortBy: val.TaskSortBy,
RecordBegin: val.RecordBegin,
MarkA: "",
MarkB: "",
MarkC: "",
MarkD: "",
}
if len(val.Marks) > 0 {
item.MarkA = val.Marks["a"]
item.MarkB = val.Marks["b"]
item.MarkC = val.Marks["c"]
item.MarkD = val.Marks["d"]
}
if val.TaskStageCheck.RealCompletedAt > 0 {
item.TaskStageCheck.RealCompletedAt = time.Unix(val.TaskStageCheck.RealCompletedAt, 0).Local().Format("2006-01-02")
}
if val.CurrentStage.RealCompletedAt > 0 {
item.CurrentStage.RealCompletedAt = time.Unix(val.CurrentStage.RealCompletedAt, 0).Local().Format("2006-01-02")
}
if val.LastStage.RealCompletedAt > 0 {
item.LastStage.RealCompletedAt = time.Unix(val.LastStage.RealCompletedAt, 0).Local().Format("2006-01-02")
}
switch val.Category {
case 1:
{
//里程碑异常
if val.TaskStageCheck.RealCompletedAt == 0 {
//逾期未完成
planCompletedAt := time.Unix(val.TaskStageCheck.PlanCompletedAt, 0)
subDay := xtime.SubDayAbs(nowTime, planCompletedAt)
item.AnomalyDesc = fmt.Sprintf("里程碑%s已逾期%d天", val.TaskStageCheck.Name, subDay)
} else {
//逾期完成
planCompletedAt := time.Unix(val.TaskStageCheck.PlanCompletedAt, 0)
realCompletedAt := time.Unix(val.TaskStageCheck.RealCompletedAt, 0)
subDay := xtime.SubDayAbs(realCompletedAt, planCompletedAt)
item.AnomalyDesc = fmt.Sprintf("里程碑%s逾期%d天完成", val.TaskStageCheck.Name, subDay)
}
}
case 2:
//反馈异常
{
recordBegin := time.Unix(val.RecordBegin, 0)
subDay := xtime.SubDayAbs(nowTime, recordBegin)
item.AnomalyDesc = fmt.Sprintf(
"本任务自%s未正常反馈项目进度,已异常%d天",
recordBegin.Local().Format("2006-01-02"),
subDay,
)
}
case 3:
//辅导异常
{
recordBegin := time.Unix(val.RecordBegin, 0)
subDay := xtime.SubDayAbs(nowTime, recordBegin)
item.AnomalyDesc = fmt.Sprintf(
"本任务计划于%s完成辅导,已逾期%d天",
recordBegin.Local().Format("2006-01-02"),
subDay,
)
}
}
listData = append(listData, item)
}
result := tool_funs.SimpleWrapGridMap(int64(cnt), listData)
return result, nil
}
// 我的下级负责任务,异常列表
func (srv TaskService) ListTaskAnomaly2() {}
// 与我有关的任务,异常列表
func (srv TaskService) ListTaskAnomaly3() {}
// 对异常记录的操作标记
func (srv TaskService) MarkTaskAnomaly() {}