正在显示
6 个修改的文件
包含
154 行增加
和
19 行删除
@@ -581,6 +581,7 @@ func (srv *MessagePersonalService) TodayMessageTaskStageModifyV2(param *command. | @@ -581,6 +581,7 @@ func (srv *MessagePersonalService) TodayMessageTaskStageModifyV2(param *command. | ||
581 | return resp, nil | 581 | return resp, nil |
582 | } | 582 | } |
583 | 583 | ||
584 | +// 里程碑异常的消息弹窗通知 | ||
584 | func (srv *MessagePersonalService) TodayMessageTaskAnomaly(param *command.GetUserMessageCommand) (map[string]interface{}, error) { | 585 | func (srv *MessagePersonalService) TodayMessageTaskAnomaly(param *command.GetUserMessageCommand) (map[string]interface{}, error) { |
585 | 586 | ||
586 | transactionContext, err := factory.CreateTransactionContext(nil) | 587 | transactionContext, err := factory.CreateTransactionContext(nil) |
@@ -34,6 +34,15 @@ func checkTaskRecordV2(param *domain.TaskRecord) error { | @@ -34,6 +34,15 @@ func checkTaskRecordV2(param *domain.TaskRecord) error { | ||
34 | return nil | 34 | return nil |
35 | } | 35 | } |
36 | taskData := taskDataList[0] | 36 | taskData := taskDataList[0] |
37 | + | ||
38 | + //检查每日评估中任务的异常 | ||
39 | + // taskData.CheckAndRecordAnomaly(param) | ||
40 | + | ||
41 | + // anomaly1 := &domain.TaskAnomaly{} | ||
42 | + // ok := anomaly1.IsWarnFlag(taskData, param) | ||
43 | + // if ok { | ||
44 | + | ||
45 | + // } | ||
37 | // 检查反馈异常 | 46 | // 检查反馈异常 |
38 | if param.IsRemarkAnomaly() { | 47 | if param.IsRemarkAnomaly() { |
39 | taskData.Anomaly += 1 | 48 | taskData.Anomaly += 1 |
@@ -50,13 +59,13 @@ func checkTaskRecordV2(param *domain.TaskRecord) error { | @@ -50,13 +59,13 @@ func checkTaskRecordV2(param *domain.TaskRecord) error { | ||
50 | } | 59 | } |
51 | // 检查里程碑异常 | 60 | // 检查里程碑异常 |
52 | if param.IsTaskStageAnomaly() { | 61 | if param.IsTaskStageAnomaly() { |
53 | - taskData.WarnFlag = domain.TaskWarn | 62 | + taskData.WarnFlag += 1 |
54 | err := isWarnFlag(transactionContext, taskData, param) | 63 | err := isWarnFlag(transactionContext, taskData, param) |
55 | if err != nil { | 64 | if err != nil { |
56 | return err | 65 | return err |
57 | } | 66 | } |
58 | } else { | 67 | } else { |
59 | - taskData.WarnFlag = domain.TaskWarnNull | 68 | + taskData.WarnFlag = 0 |
60 | err := isNotWarnFlag(transactionContext, taskData, param) | 69 | err := isNotWarnFlag(transactionContext, taskData, param) |
61 | if err != nil { | 70 | if err != nil { |
62 | return err | 71 | return err |
@@ -861,18 +861,18 @@ func (srv TaskService) ReplyTaskStage(transactionContext application.Transaction | @@ -861,18 +861,18 @@ func (srv TaskService) ReplyTaskStage(transactionContext application.Transaction | ||
861 | } | 861 | } |
862 | 862 | ||
863 | //改为定时检查每日任务反馈,并计算反馈异常数 | 863 | //改为定时检查每日任务反馈,并计算反馈异常数 |
864 | - for _, val2 := range stageList { | ||
865 | - if val2.Id != val.TaskStageCheck.Id { | ||
866 | - continue | ||
867 | - } | ||
868 | - val2.RealCompletedAt = val.TaskStageCheck.RealCompletedAt | ||
869 | - if val2.PlanCompletedAt < val2.RealCompletedAt { | ||
870 | - taskData.WarnFlag = domain.TaskWarn | ||
871 | - } else { | ||
872 | - taskData.WarnFlag = domain.TaskWarnNull | ||
873 | - } | ||
874 | - break | ||
875 | - } | 864 | + // for _, val2 := range stageList { |
865 | + // if val2.Id != val.TaskStageCheck.Id { | ||
866 | + // continue | ||
867 | + // } | ||
868 | + // val2.RealCompletedAt = val.TaskStageCheck.RealCompletedAt | ||
869 | + // if val2.PlanCompletedAt < val2.RealCompletedAt { | ||
870 | + // taskData.WarnFlag = 1 | ||
871 | + // } else { | ||
872 | + // taskData.WarnFlag = 0 | ||
873 | + // } | ||
874 | + // break | ||
875 | + // } | ||
876 | err = taskStageRepo.Save(stageList) | 876 | err = taskStageRepo.Save(stageList) |
877 | if err != nil { | 877 | if err != nil { |
878 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存任务里程碑数据"+err.Error()) | 878 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存任务里程碑数据"+err.Error()) |
@@ -3,6 +3,7 @@ package domain | @@ -3,6 +3,7 @@ package domain | ||
3 | import ( | 3 | import ( |
4 | "errors" | 4 | "errors" |
5 | "sort" | 5 | "sort" |
6 | + "strings" | ||
6 | "time" | 7 | "time" |
7 | ) | 8 | ) |
8 | 9 | ||
@@ -76,7 +77,7 @@ type Task struct { | @@ -76,7 +77,7 @@ type Task struct { | ||
76 | RunAt int64 `json:"runAt"` // 启动的时间戳,单位:秒 | 77 | RunAt int64 `json:"runAt"` // 启动的时间戳,单位:秒 |
77 | StopAt int64 `json:"stopAt"` // 停止的时间戳,单位:秒 | 78 | StopAt int64 `json:"stopAt"` // 停止的时间戳,单位:秒 |
78 | Anomaly int `json:"anomaly"` // 异常反馈的次数 | 79 | Anomaly int `json:"anomaly"` // 异常反馈的次数 |
79 | - WarnFlag TaskWarnFlag `json:"warnFlag"` // 里程碑异常标记 | 80 | + WarnFlag int `json:"warnFlag"` // 里程碑异常标记 |
80 | AssistFlag int `json:"assistFlag"` // 辅导异常标记 | 81 | AssistFlag int `json:"assistFlag"` // 辅导异常标记 |
81 | AssistFlagMax int `json:"assistFlagMax"` // 辅导异常标记最大值 | 82 | AssistFlagMax int `json:"assistFlagMax"` // 辅导异常标记最大值 |
82 | CurrentStage TaskStage `json:"currentStage"` // 当前执行的里程碑 | 83 | CurrentStage TaskStage `json:"currentStage"` // 当前执行的里程碑 |
@@ -160,7 +161,7 @@ func (t *Task) DescriptTaskStatus() string { | @@ -160,7 +161,7 @@ func (t *Task) DescriptTaskStatus() string { | ||
160 | if t.Status == TaskStop { | 161 | if t.Status == TaskStop { |
161 | statusNamed = "已停止" | 162 | statusNamed = "已停止" |
162 | } | 163 | } |
163 | - if t.WarnFlag == TaskWarn { | 164 | + if t.WarnFlag > 0 { |
164 | statusNamed = "里程碑异常" | 165 | statusNamed = "里程碑异常" |
165 | } | 166 | } |
166 | if t.Anomaly > 0 { | 167 | if t.Anomaly > 0 { |
@@ -176,6 +177,51 @@ func (t *Task) Copy() Task { | @@ -176,6 +177,51 @@ func (t *Task) Copy() Task { | ||
176 | return t2 | 177 | return t2 |
177 | } | 178 | } |
178 | 179 | ||
180 | +// 检查每日任务是否异常,并记录异常情况 | ||
181 | +func (t *Task) CheckAndRecordAnomaly(taskRecordData *TaskRecord) { | ||
182 | + nowTime := time.Now().Unix() | ||
183 | + // 检查是否是里程碑异常 | ||
184 | + { | ||
185 | + if taskRecordData.TaskStageCheck.Id > 0 { | ||
186 | + if taskRecordData.TaskStageCheck.RealCompletedAt == 0 && taskRecordData.TaskStageCheck.PlanCompletedAt < nowTime { | ||
187 | + // 超期未完成 | ||
188 | + t.WarnFlag += 1 | ||
189 | + } else if taskRecordData.TaskStageCheck.RealCompletedAt > 0 { | ||
190 | + // 里程碑完成, 重置计数 | ||
191 | + t.WarnFlag = 0 | ||
192 | + } | ||
193 | + } | ||
194 | + } | ||
195 | + // 检查反馈异常 | ||
196 | + { | ||
197 | + t.Anomaly += 1 | ||
198 | + for _, val := range taskRecordData.RemarkContent { | ||
199 | + txt := strings.TrimSpace(val.RemarkText) | ||
200 | + if len(txt) == 0 || txt == "无" { | ||
201 | + continue | ||
202 | + } | ||
203 | + //反馈正常,重置计数 | ||
204 | + t.Anomaly = 0 | ||
205 | + break | ||
206 | + } | ||
207 | + } | ||
208 | + // 检查辅导异常 | ||
209 | + { | ||
210 | + taskRecordData.AssistContent = strings.TrimSpace(taskRecordData.AssistContent) | ||
211 | + if t.Anomaly == 0 && t.WarnFlag == 0 { | ||
212 | + //里程碑正常,反馈正常, 设定为已辅导 | ||
213 | + t.AssistFlag = 0 | ||
214 | + } else { | ||
215 | + //里程碑和反馈 其中一个不正常,记录一次辅导异常 | ||
216 | + t.AssistFlag += 1 | ||
217 | + } | ||
218 | + if taskRecordData.AssistLevel != AssistLevel1 && !(taskRecordData.AssistContent == "无" || len(taskRecordData.AssistContent) == 0) { | ||
219 | + //只要正常填写的辅导都设定为已辅导 | ||
220 | + t.AssistFlag = 0 | ||
221 | + } | ||
222 | + } | ||
223 | +} | ||
224 | + | ||
179 | type TaskRepository interface { | 225 | type TaskRepository interface { |
180 | Save(param *Task) error | 226 | Save(param *Task) error |
181 | Remove(id int) error | 227 | Remove(id int) error |
@@ -115,16 +115,95 @@ func (t *TaskAnomaly) AnomalyDesc() (str string) { | @@ -115,16 +115,95 @@ func (t *TaskAnomaly) AnomalyDesc() (str string) { | ||
115 | 115 | ||
116 | // 检查是否是反馈异常 | 116 | // 检查是否是反馈异常 |
117 | func (t *TaskAnomaly) IsAssessFlag(taskData *Task, taskRecordData *TaskRecord) bool { | 117 | func (t *TaskAnomaly) IsAssessFlag(taskData *Task, taskRecordData *TaskRecord) bool { |
118 | - | 118 | + if taskData.Anomaly <= 0 { |
119 | return false | 119 | return false |
120 | + } | ||
121 | + *t = TaskAnomaly{ | ||
122 | + Id: 0, | ||
123 | + CreatedAt: time.Now(), | ||
124 | + UpdatedAt: time.Now(), | ||
125 | + CompanyId: taskData.CompanyId, | ||
126 | + TaskId: taskData.Id, | ||
127 | + TaskRecordId: taskRecordData.Id, | ||
128 | + Category: AnomalyCategoryType2, | ||
129 | + CurrentStage: taskData.CurrentStage, | ||
130 | + LastStage: taskData.LastStage, | ||
131 | + TaskStageCheck: taskRecordData.TaskStageCheck, | ||
132 | + AssessFlag: 1, | ||
133 | + WarnFlag: 0, | ||
134 | + AssistFlag: 0, | ||
135 | + IsLast: 1, | ||
136 | + RecordBegin: xtime.DayZeroTime(taskRecordData.CreatedAt).Unix(), | ||
137 | + NoticeWho: []map[string]string{}, | ||
138 | + Marks: map[string]string{ | ||
139 | + "a": "去更新", "b": "去反馈", "c": "找上级", "d": "去辅导", | ||
140 | + }, | ||
141 | + Remark: "", | ||
142 | + } | ||
143 | + return true | ||
120 | } | 144 | } |
121 | 145 | ||
122 | // 检查是否是里程碑异常 | 146 | // 检查是否是里程碑异常 |
123 | func (t *TaskAnomaly) IsWarnFlag(taskData *Task, taskRecordData *TaskRecord) bool { | 147 | func (t *TaskAnomaly) IsWarnFlag(taskData *Task, taskRecordData *TaskRecord) bool { |
148 | + if taskData.CurrentStage.Id == 0 { | ||
149 | + // 没有新的里程碑 | ||
150 | + return false | ||
151 | + } | ||
152 | + if taskData.CurrentStage.PlanCompletedAt > time.Now().Unix() { | ||
153 | + //新的里程碑未过期, 不计入异常情况 | ||
124 | return false | 154 | return false |
155 | + } | ||
156 | + *t = TaskAnomaly{ | ||
157 | + Id: 0, | ||
158 | + CreatedAt: time.Now(), | ||
159 | + UpdatedAt: time.Now(), | ||
160 | + CompanyId: taskData.CompanyId, | ||
161 | + TaskId: taskData.Id, | ||
162 | + TaskRecordId: taskRecordData.Id, | ||
163 | + Category: AnomalyCategoryType1, | ||
164 | + CurrentStage: taskData.CurrentStage, | ||
165 | + LastStage: taskData.LastStage, | ||
166 | + TaskStageCheck: taskRecordData.TaskStageCheck, | ||
167 | + AssessFlag: 0, | ||
168 | + WarnFlag: 1, | ||
169 | + AssistFlag: 0, | ||
170 | + IsLast: 1, | ||
171 | + RecordBegin: xtime.DayZeroTime(taskRecordData.CreatedAt).Unix(), | ||
172 | + NoticeWho: []map[string]string{}, | ||
173 | + Marks: map[string]string{ | ||
174 | + "a": "去更新", "b": "去反馈", "c": "找上级", "d": "去辅导", | ||
175 | + }, | ||
176 | + Remark: "", | ||
177 | + } | ||
178 | + return true | ||
125 | } | 179 | } |
126 | 180 | ||
127 | -// 检查是否是辅导异常 | 181 | +// 检查是否是辅导异常, |
128 | func (t *TaskAnomaly) IsAssistFlag(taskData *Task, taskRecordData *TaskRecord) bool { | 182 | func (t *TaskAnomaly) IsAssistFlag(taskData *Task, taskRecordData *TaskRecord) bool { |
183 | + if taskData.AssistFlag < taskData.AssistFlagMax { | ||
129 | return false | 184 | return false |
185 | + } | ||
186 | + *t = TaskAnomaly{ | ||
187 | + Id: 0, | ||
188 | + CreatedAt: time.Now(), | ||
189 | + UpdatedAt: time.Now(), | ||
190 | + CompanyId: taskData.CompanyId, | ||
191 | + TaskId: taskData.Id, | ||
192 | + TaskRecordId: taskRecordData.Id, | ||
193 | + Category: AnomalyCategoryType3, | ||
194 | + CurrentStage: taskData.CurrentStage, | ||
195 | + LastStage: taskData.LastStage, | ||
196 | + TaskStageCheck: taskRecordData.TaskStageCheck, | ||
197 | + AssessFlag: taskData.Anomaly, | ||
198 | + WarnFlag: taskData.WarnFlag, | ||
199 | + AssistFlag: taskData.AssistFlag, | ||
200 | + IsLast: 1, | ||
201 | + RecordBegin: xtime.DayZeroTime(taskRecordData.CreatedAt).Unix(), | ||
202 | + NoticeWho: []map[string]string{}, | ||
203 | + Marks: map[string]string{ | ||
204 | + "a": "去更新", "b": "去反馈", "c": "找上级", "d": "去辅导", | ||
205 | + }, | ||
206 | + Remark: "", | ||
207 | + } | ||
208 | + return true | ||
130 | } | 209 | } |
@@ -44,7 +44,7 @@ func (repo *TaskRepository) TransformToDomain(d *models.Task) *domain.Task { | @@ -44,7 +44,7 @@ func (repo *TaskRepository) TransformToDomain(d *models.Task) *domain.Task { | ||
44 | RunAt: d.RunAt, | 44 | RunAt: d.RunAt, |
45 | StopAt: d.StopAt, | 45 | StopAt: d.StopAt, |
46 | Anomaly: d.Anomaly, | 46 | Anomaly: d.Anomaly, |
47 | - WarnFlag: domain.TaskWarnFlag(d.WarnFlag), | 47 | + WarnFlag: d.WarnFlag, |
48 | AssistFlag: d.AssistFlag, | 48 | AssistFlag: d.AssistFlag, |
49 | AssistFlagMax: d.AssistFlagMax, | 49 | AssistFlagMax: d.AssistFlagMax, |
50 | CurrentStage: d.CurrentStage, | 50 | CurrentStage: d.CurrentStage, |
-
请 注册 或 登录 后发表评论