作者 tangxvhui

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

... ... @@ -44,7 +44,7 @@ func TestCreatTaskAnamaly(t *testing.T) {
"transactionContext": transactionContext,
})
_, taskRacordList, err := taskRecordRepo.Find(map[string]interface{}{
"ids": []int{1669011861988708352},
"ids": []int{1676259651777204224},
})
if err != nil {
t.Error(err)
... ...
... ... @@ -81,7 +81,7 @@ func checkTaskRecordV3(param *domain.TaskRecord) error {
anomaly3 := &domain.TaskAnomaly{}
ok = anomaly2.IsAssistFlag(taskData, param)
if ok {
anomalyIsAssistFlag(transactionContext, anomaly3, taskData)
err = anomalyIsAssistFlag(transactionContext, anomaly3, taskData)
if err != nil {
return err
}
... ... @@ -105,9 +105,7 @@ func anomalyIsNotWarnFlag(transactionContext application.TransactionContext, tas
_, oldAnomaly, err := taskAnomalyRepo.Find(map[string]interface{}{
"isLast": 1,
"category": domain.AnomalyCategoryType1,
"limit": 1,
"taskId": taskData.Id,
// "taskStageCheck": fmt.Sprintf(`{"id":"%d"}`, taskRecord.TaskStageCheck.Id),
})
if err != nil {
return fmt.Errorf("查询里程碑异常的数据:%s", err)
... ... @@ -115,11 +113,14 @@ func anomalyIsNotWarnFlag(transactionContext application.TransactionContext, tas
if len(oldAnomaly) == 0 {
return nil
}
oldAnomaly[0].IsLast = 2
err = taskAnomalyRepo.Save(oldAnomaly[0])
for i := range oldAnomaly {
oldAnomaly[i].IsLast = 2
err = taskAnomalyRepo.Save(oldAnomaly[i])
if err != nil {
return fmt.Errorf("取消里程碑异常:%s", err)
}
}
return nil
}
... ... @@ -131,9 +132,7 @@ func anomalyIsWarnFlag(transactionContext application.TransactionContext, taskAn
_, oldAnomaly, err := taskAnomalyRepo.Find(map[string]interface{}{
"isLast": 1,
"category": domain.AnomalyCategoryType1,
"limit": 1,
"taskId": taskAnomalyData.TaskId,
"taskStageCheck": fmt.Sprintf(`{"id":"%d"}`, taskAnomalyData.TaskStageCheck.Id),
})
if err != nil {
return fmt.Errorf("查询里程碑异常的数据:%s", err)
... ... @@ -145,12 +144,14 @@ func anomalyIsWarnFlag(transactionContext application.TransactionContext, taskAn
if len(oldAnomaly) > 0 {
taskAnomalyData.WarnFlag = oldAnomaly[0].WarnFlag + 1
taskAnomalyData.RecordBegin = oldAnomaly[0].RecordBegin
oldAnomaly[0].IsLast = 2
err = taskAnomalyRepo.Save(oldAnomaly[0])
for i := range oldAnomaly {
oldAnomaly[i].IsLast = 2
err = taskAnomalyRepo.Save(oldAnomaly[i])
if err != nil {
return fmt.Errorf("更新里程碑异常记录:%s", err)
}
}
}
_ = taskAnomalyData.AnomalyDesc()
// 异常就通知自己和上级
//获取任务Leader的数据
... ... @@ -188,7 +189,6 @@ func anomalyIsNotAssessFlag(transactionContext application.TransactionContext, t
_, oldAnomaly, err := taskAnomalyRepo.Find(map[string]interface{}{
"isLast": 1,
"category": domain.AnomalyCategoryType2,
"limit": 1,
"taskId": taskData.Id,
})
if err != nil {
... ... @@ -197,11 +197,14 @@ func anomalyIsNotAssessFlag(transactionContext application.TransactionContext, t
if len(oldAnomaly) == 0 {
return nil
}
oldAnomaly[0].IsLast = 2
err = taskAnomalyRepo.Save(oldAnomaly[0])
for i := range oldAnomaly {
oldAnomaly[i].IsLast = 2
err = taskAnomalyRepo.Save(oldAnomaly[i])
if err != nil {
return fmt.Errorf("取消辅导异常:%s", err)
}
}
return nil
}
... ... @@ -216,7 +219,6 @@ func anomalyisAssessFlag(transactionContext application.TransactionContext, task
_, oldAnomaly, err := taskAnomalyRepo.Find(map[string]interface{}{
"isLast": 1,
"category": domain.AnomalyCategoryType2,
"limit": 1,
"taskId": taskAnomalyData.TaskId,
})
if err != nil {
... ... @@ -225,12 +227,15 @@ func anomalyisAssessFlag(transactionContext application.TransactionContext, task
//
if len(oldAnomaly) > 0 {
taskAnomalyData.RecordBegin = oldAnomaly[0].RecordBegin
oldAnomaly[0].IsLast = 2
err = taskAnomalyRepo.Save(oldAnomaly[0])
for i := range oldAnomaly {
oldAnomaly[i].IsLast = 2
err = taskAnomalyRepo.Save(oldAnomaly[i])
if err != nil {
return fmt.Errorf("更新反馈异常记录:%s", err)
}
}
}
_ = taskAnomalyData.AnomalyDesc()
// 2天未反馈通知被评估人自己;3天通知上级
// 获取任务Leader的数据
... ... @@ -271,7 +276,6 @@ func anomalyIsNotAssistFlag(transactionContext application.TransactionContext, t
_, oldAnomaly, err := taskAnomalyRepo.Find(map[string]interface{}{
"isLast": 1,
"category": domain.AnomalyCategoryType3,
"limit": 1,
"taskId": taskData.Id,
})
if err != nil {
... ... @@ -280,11 +284,14 @@ func anomalyIsNotAssistFlag(transactionContext application.TransactionContext, t
if len(oldAnomaly) == 0 {
return nil
}
oldAnomaly[0].IsLast = 2
err = taskAnomalyRepo.Save(oldAnomaly[0])
for i := range oldAnomaly {
oldAnomaly[i].IsLast = 2
err = taskAnomalyRepo.Save(oldAnomaly[i])
if err != nil {
return fmt.Errorf("取消辅导异常:%s", err)
}
}
return nil
}
... ... @@ -301,8 +308,8 @@ func anomalyIsAssistFlag(transactionContext application.TransactionContext, task
_, oldAnomaly, err := taskAnomalyRepo.Find(map[string]interface{}{
"isLast": 1,
"category": domain.AnomalyCategoryType3,
"limit": 1,
"taskId": taskAnomalyData.TaskId,
"limit": 1,
})
if err != nil {
return fmt.Errorf("查询辅导异常的数据:%s", err)
... ...
... ... @@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"strconv"
"time"
"github.com/go-pg/pg/v10"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
... ... @@ -50,7 +51,7 @@ func (repo *TaskAnomalyRepository) Save(param *domain.TaskAnomaly) error {
m := models.TaskAnomaly{
Id: param.Id,
CreatedAt: param.CreatedAt,
UpdatedAt: param.UpdatedAt,
UpdatedAt: time.Now(),
CompanyId: param.CompanyId,
TaskId: param.TaskId,
TaskRecordId: param.TaskRecordId,
... ...