作者 tangxvhui

调整 每日检查评估任务是否异常

@@ -44,7 +44,7 @@ func TestCreatTaskAnamaly(t *testing.T) { @@ -44,7 +44,7 @@ func TestCreatTaskAnamaly(t *testing.T) {
44 "transactionContext": transactionContext, 44 "transactionContext": transactionContext,
45 }) 45 })
46 _, taskRacordList, err := taskRecordRepo.Find(map[string]interface{}{ 46 _, taskRacordList, err := taskRecordRepo.Find(map[string]interface{}{
47 - "ids": []int{1669011861988708352}, 47 + "ids": []int{1676259651777204224},
48 }) 48 })
49 if err != nil { 49 if err != nil {
50 t.Error(err) 50 t.Error(err)
@@ -81,7 +81,7 @@ func checkTaskRecordV3(param *domain.TaskRecord) error { @@ -81,7 +81,7 @@ func checkTaskRecordV3(param *domain.TaskRecord) error {
81 anomaly3 := &domain.TaskAnomaly{} 81 anomaly3 := &domain.TaskAnomaly{}
82 ok = anomaly2.IsAssistFlag(taskData, param) 82 ok = anomaly2.IsAssistFlag(taskData, param)
83 if ok { 83 if ok {
84 - anomalyIsAssistFlag(transactionContext, anomaly3, taskData) 84 + err = anomalyIsAssistFlag(transactionContext, anomaly3, taskData)
85 if err != nil { 85 if err != nil {
86 return err 86 return err
87 } 87 }
@@ -105,9 +105,7 @@ func anomalyIsNotWarnFlag(transactionContext application.TransactionContext, tas @@ -105,9 +105,7 @@ func anomalyIsNotWarnFlag(transactionContext application.TransactionContext, tas
105 _, oldAnomaly, err := taskAnomalyRepo.Find(map[string]interface{}{ 105 _, oldAnomaly, err := taskAnomalyRepo.Find(map[string]interface{}{
106 "isLast": 1, 106 "isLast": 1,
107 "category": domain.AnomalyCategoryType1, 107 "category": domain.AnomalyCategoryType1,
108 - "limit": 1,  
109 "taskId": taskData.Id, 108 "taskId": taskData.Id,
110 - // "taskStageCheck": fmt.Sprintf(`{"id":"%d"}`, taskRecord.TaskStageCheck.Id),  
111 }) 109 })
112 if err != nil { 110 if err != nil {
113 return fmt.Errorf("查询里程碑异常的数据:%s", err) 111 return fmt.Errorf("查询里程碑异常的数据:%s", err)
@@ -115,11 +113,14 @@ func anomalyIsNotWarnFlag(transactionContext application.TransactionContext, tas @@ -115,11 +113,14 @@ func anomalyIsNotWarnFlag(transactionContext application.TransactionContext, tas
115 if len(oldAnomaly) == 0 { 113 if len(oldAnomaly) == 0 {
116 return nil 114 return nil
117 } 115 }
118 - oldAnomaly[0].IsLast = 2  
119 - err = taskAnomalyRepo.Save(oldAnomaly[0])  
120 - if err != nil {  
121 - return fmt.Errorf("取消里程碑异常:%s", err) 116 + for i := range oldAnomaly {
  117 + oldAnomaly[i].IsLast = 2
  118 + err = taskAnomalyRepo.Save(oldAnomaly[i])
  119 + if err != nil {
  120 + return fmt.Errorf("取消里程碑异常:%s", err)
  121 + }
122 } 122 }
  123 +
123 return nil 124 return nil
124 } 125 }
125 126
@@ -129,11 +130,9 @@ func anomalyIsWarnFlag(transactionContext application.TransactionContext, taskAn @@ -129,11 +130,9 @@ func anomalyIsWarnFlag(transactionContext application.TransactionContext, taskAn
129 "transactionContext": transactionContext, 130 "transactionContext": transactionContext,
130 }) 131 })
131 _, oldAnomaly, err := taskAnomalyRepo.Find(map[string]interface{}{ 132 _, oldAnomaly, err := taskAnomalyRepo.Find(map[string]interface{}{
132 - "isLast": 1,  
133 - "category": domain.AnomalyCategoryType1,  
134 - "limit": 1,  
135 - "taskId": taskAnomalyData.TaskId,  
136 - "taskStageCheck": fmt.Sprintf(`{"id":"%d"}`, taskAnomalyData.TaskStageCheck.Id), 133 + "isLast": 1,
  134 + "category": domain.AnomalyCategoryType1,
  135 + "taskId": taskAnomalyData.TaskId,
137 }) 136 })
138 if err != nil { 137 if err != nil {
139 return fmt.Errorf("查询里程碑异常的数据:%s", err) 138 return fmt.Errorf("查询里程碑异常的数据:%s", err)
@@ -145,10 +144,12 @@ func anomalyIsWarnFlag(transactionContext application.TransactionContext, taskAn @@ -145,10 +144,12 @@ func anomalyIsWarnFlag(transactionContext application.TransactionContext, taskAn
145 if len(oldAnomaly) > 0 { 144 if len(oldAnomaly) > 0 {
146 taskAnomalyData.WarnFlag = oldAnomaly[0].WarnFlag + 1 145 taskAnomalyData.WarnFlag = oldAnomaly[0].WarnFlag + 1
147 taskAnomalyData.RecordBegin = oldAnomaly[0].RecordBegin 146 taskAnomalyData.RecordBegin = oldAnomaly[0].RecordBegin
148 - oldAnomaly[0].IsLast = 2  
149 - err = taskAnomalyRepo.Save(oldAnomaly[0])  
150 - if err != nil {  
151 - return fmt.Errorf("更新里程碑异常记录:%s", err) 147 + for i := range oldAnomaly {
  148 + oldAnomaly[i].IsLast = 2
  149 + err = taskAnomalyRepo.Save(oldAnomaly[i])
  150 + if err != nil {
  151 + return fmt.Errorf("更新里程碑异常记录:%s", err)
  152 + }
152 } 153 }
153 } 154 }
154 _ = taskAnomalyData.AnomalyDesc() 155 _ = taskAnomalyData.AnomalyDesc()
@@ -188,7 +189,6 @@ func anomalyIsNotAssessFlag(transactionContext application.TransactionContext, t @@ -188,7 +189,6 @@ func anomalyIsNotAssessFlag(transactionContext application.TransactionContext, t
188 _, oldAnomaly, err := taskAnomalyRepo.Find(map[string]interface{}{ 189 _, oldAnomaly, err := taskAnomalyRepo.Find(map[string]interface{}{
189 "isLast": 1, 190 "isLast": 1,
190 "category": domain.AnomalyCategoryType2, 191 "category": domain.AnomalyCategoryType2,
191 - "limit": 1,  
192 "taskId": taskData.Id, 192 "taskId": taskData.Id,
193 }) 193 })
194 if err != nil { 194 if err != nil {
@@ -197,11 +197,14 @@ func anomalyIsNotAssessFlag(transactionContext application.TransactionContext, t @@ -197,11 +197,14 @@ func anomalyIsNotAssessFlag(transactionContext application.TransactionContext, t
197 if len(oldAnomaly) == 0 { 197 if len(oldAnomaly) == 0 {
198 return nil 198 return nil
199 } 199 }
200 - oldAnomaly[0].IsLast = 2  
201 - err = taskAnomalyRepo.Save(oldAnomaly[0])  
202 - if err != nil {  
203 - return fmt.Errorf("取消辅导异常:%s", err) 200 + for i := range oldAnomaly {
  201 + oldAnomaly[i].IsLast = 2
  202 + err = taskAnomalyRepo.Save(oldAnomaly[i])
  203 + if err != nil {
  204 + return fmt.Errorf("取消辅导异常:%s", err)
  205 + }
204 } 206 }
  207 +
205 return nil 208 return nil
206 } 209 }
207 210
@@ -216,7 +219,6 @@ func anomalyisAssessFlag(transactionContext application.TransactionContext, task @@ -216,7 +219,6 @@ func anomalyisAssessFlag(transactionContext application.TransactionContext, task
216 _, oldAnomaly, err := taskAnomalyRepo.Find(map[string]interface{}{ 219 _, oldAnomaly, err := taskAnomalyRepo.Find(map[string]interface{}{
217 "isLast": 1, 220 "isLast": 1,
218 "category": domain.AnomalyCategoryType2, 221 "category": domain.AnomalyCategoryType2,
219 - "limit": 1,  
220 "taskId": taskAnomalyData.TaskId, 222 "taskId": taskAnomalyData.TaskId,
221 }) 223 })
222 if err != nil { 224 if err != nil {
@@ -225,11 +227,14 @@ func anomalyisAssessFlag(transactionContext application.TransactionContext, task @@ -225,11 +227,14 @@ func anomalyisAssessFlag(transactionContext application.TransactionContext, task
225 // 227 //
226 if len(oldAnomaly) > 0 { 228 if len(oldAnomaly) > 0 {
227 taskAnomalyData.RecordBegin = oldAnomaly[0].RecordBegin 229 taskAnomalyData.RecordBegin = oldAnomaly[0].RecordBegin
228 - oldAnomaly[0].IsLast = 2  
229 - err = taskAnomalyRepo.Save(oldAnomaly[0])  
230 - if err != nil {  
231 - return fmt.Errorf("更新反馈异常记录:%s", err) 230 + for i := range oldAnomaly {
  231 + oldAnomaly[i].IsLast = 2
  232 + err = taskAnomalyRepo.Save(oldAnomaly[i])
  233 + if err != nil {
  234 + return fmt.Errorf("更新反馈异常记录:%s", err)
  235 + }
232 } 236 }
  237 +
233 } 238 }
234 _ = taskAnomalyData.AnomalyDesc() 239 _ = taskAnomalyData.AnomalyDesc()
235 // 2天未反馈通知被评估人自己;3天通知上级 240 // 2天未反馈通知被评估人自己;3天通知上级
@@ -271,7 +276,6 @@ func anomalyIsNotAssistFlag(transactionContext application.TransactionContext, t @@ -271,7 +276,6 @@ func anomalyIsNotAssistFlag(transactionContext application.TransactionContext, t
271 _, oldAnomaly, err := taskAnomalyRepo.Find(map[string]interface{}{ 276 _, oldAnomaly, err := taskAnomalyRepo.Find(map[string]interface{}{
272 "isLast": 1, 277 "isLast": 1,
273 "category": domain.AnomalyCategoryType3, 278 "category": domain.AnomalyCategoryType3,
274 - "limit": 1,  
275 "taskId": taskData.Id, 279 "taskId": taskData.Id,
276 }) 280 })
277 if err != nil { 281 if err != nil {
@@ -280,11 +284,14 @@ func anomalyIsNotAssistFlag(transactionContext application.TransactionContext, t @@ -280,11 +284,14 @@ func anomalyIsNotAssistFlag(transactionContext application.TransactionContext, t
280 if len(oldAnomaly) == 0 { 284 if len(oldAnomaly) == 0 {
281 return nil 285 return nil
282 } 286 }
283 - oldAnomaly[0].IsLast = 2  
284 - err = taskAnomalyRepo.Save(oldAnomaly[0])  
285 - if err != nil {  
286 - return fmt.Errorf("取消辅导异常:%s", err) 287 + for i := range oldAnomaly {
  288 + oldAnomaly[i].IsLast = 2
  289 + err = taskAnomalyRepo.Save(oldAnomaly[i])
  290 + if err != nil {
  291 + return fmt.Errorf("取消辅导异常:%s", err)
  292 + }
287 } 293 }
  294 +
288 return nil 295 return nil
289 } 296 }
290 297
@@ -301,8 +308,8 @@ func anomalyIsAssistFlag(transactionContext application.TransactionContext, task @@ -301,8 +308,8 @@ func anomalyIsAssistFlag(transactionContext application.TransactionContext, task
301 _, oldAnomaly, err := taskAnomalyRepo.Find(map[string]interface{}{ 308 _, oldAnomaly, err := taskAnomalyRepo.Find(map[string]interface{}{
302 "isLast": 1, 309 "isLast": 1,
303 "category": domain.AnomalyCategoryType3, 310 "category": domain.AnomalyCategoryType3,
304 - "limit": 1,  
305 "taskId": taskAnomalyData.TaskId, 311 "taskId": taskAnomalyData.TaskId,
  312 + "limit": 1,
306 }) 313 })
307 if err != nil { 314 if err != nil {
308 return fmt.Errorf("查询辅导异常的数据:%s", err) 315 return fmt.Errorf("查询辅导异常的数据:%s", err)
@@ -4,6 +4,7 @@ import ( @@ -4,6 +4,7 @@ import (
4 "errors" 4 "errors"
5 "fmt" 5 "fmt"
6 "strconv" 6 "strconv"
  7 + "time"
7 8
8 "github.com/go-pg/pg/v10" 9 "github.com/go-pg/pg/v10"
9 pgTransaction "github.com/linmadan/egglib-go/transaction/pg" 10 pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
@@ -50,7 +51,7 @@ func (repo *TaskAnomalyRepository) Save(param *domain.TaskAnomaly) error { @@ -50,7 +51,7 @@ func (repo *TaskAnomalyRepository) Save(param *domain.TaskAnomaly) error {
50 m := models.TaskAnomaly{ 51 m := models.TaskAnomaly{
51 Id: param.Id, 52 Id: param.Id,
52 CreatedAt: param.CreatedAt, 53 CreatedAt: param.CreatedAt,
53 - UpdatedAt: param.UpdatedAt, 54 + UpdatedAt: time.Now(),
54 CompanyId: param.CompanyId, 55 CompanyId: param.CompanyId,
55 TaskId: param.TaskId, 56 TaskId: param.TaskId,
56 TaskRecordId: param.TaskRecordId, 57 TaskRecordId: param.TaskRecordId,