作者 tangxvhui

保存

... ... @@ -581,6 +581,7 @@ func (srv *MessagePersonalService) TodayMessageTaskStageModifyV2(param *command.
return resp, nil
}
// 里程碑异常的消息弹窗通知
func (srv *MessagePersonalService) TodayMessageTaskAnomaly(param *command.GetUserMessageCommand) (map[string]interface{}, error) {
transactionContext, err := factory.CreateTransactionContext(nil)
... ...
... ... @@ -34,6 +34,15 @@ func checkTaskRecordV2(param *domain.TaskRecord) error {
return nil
}
taskData := taskDataList[0]
//检查每日评估中任务的异常
// taskData.CheckAndRecordAnomaly(param)
// anomaly1 := &domain.TaskAnomaly{}
// ok := anomaly1.IsWarnFlag(taskData, param)
// if ok {
// }
// 检查反馈异常
if param.IsRemarkAnomaly() {
taskData.Anomaly += 1
... ... @@ -50,13 +59,13 @@ func checkTaskRecordV2(param *domain.TaskRecord) error {
}
// 检查里程碑异常
if param.IsTaskStageAnomaly() {
taskData.WarnFlag = domain.TaskWarn
taskData.WarnFlag += 1
err := isWarnFlag(transactionContext, taskData, param)
if err != nil {
return err
}
} else {
taskData.WarnFlag = domain.TaskWarnNull
taskData.WarnFlag = 0
err := isNotWarnFlag(transactionContext, taskData, param)
if err != nil {
return err
... ...
... ... @@ -861,18 +861,18 @@ func (srv TaskService) ReplyTaskStage(transactionContext application.Transaction
}
//改为定时检查每日任务反馈,并计算反馈异常数
for _, val2 := range stageList {
if val2.Id != val.TaskStageCheck.Id {
continue
}
val2.RealCompletedAt = val.TaskStageCheck.RealCompletedAt
if val2.PlanCompletedAt < val2.RealCompletedAt {
taskData.WarnFlag = domain.TaskWarn
} else {
taskData.WarnFlag = domain.TaskWarnNull
}
break
}
// for _, val2 := range stageList {
// if val2.Id != val.TaskStageCheck.Id {
// continue
// }
// val2.RealCompletedAt = val.TaskStageCheck.RealCompletedAt
// if val2.PlanCompletedAt < val2.RealCompletedAt {
// taskData.WarnFlag = 1
// } else {
// taskData.WarnFlag = 0
// }
// break
// }
err = taskStageRepo.Save(stageList)
if err != nil {
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存任务里程碑数据"+err.Error())
... ...
... ... @@ -3,6 +3,7 @@ package domain
import (
"errors"
"sort"
"strings"
"time"
)
... ... @@ -76,7 +77,7 @@ type Task struct {
RunAt int64 `json:"runAt"` // 启动的时间戳,单位:秒
StopAt int64 `json:"stopAt"` // 停止的时间戳,单位:秒
Anomaly int `json:"anomaly"` // 异常反馈的次数
WarnFlag TaskWarnFlag `json:"warnFlag"` // 里程碑异常标记
WarnFlag int `json:"warnFlag"` // 里程碑异常标记
AssistFlag int `json:"assistFlag"` // 辅导异常标记
AssistFlagMax int `json:"assistFlagMax"` // 辅导异常标记最大值
CurrentStage TaskStage `json:"currentStage"` // 当前执行的里程碑
... ... @@ -160,7 +161,7 @@ func (t *Task) DescriptTaskStatus() string {
if t.Status == TaskStop {
statusNamed = "已停止"
}
if t.WarnFlag == TaskWarn {
if t.WarnFlag > 0 {
statusNamed = "里程碑异常"
}
if t.Anomaly > 0 {
... ... @@ -176,6 +177,51 @@ func (t *Task) Copy() Task {
return t2
}
// 检查每日任务是否异常,并记录异常情况
func (t *Task) CheckAndRecordAnomaly(taskRecordData *TaskRecord) {
nowTime := time.Now().Unix()
// 检查是否是里程碑异常
{
if taskRecordData.TaskStageCheck.Id > 0 {
if taskRecordData.TaskStageCheck.RealCompletedAt == 0 && taskRecordData.TaskStageCheck.PlanCompletedAt < nowTime {
// 超期未完成
t.WarnFlag += 1
} else if taskRecordData.TaskStageCheck.RealCompletedAt > 0 {
// 里程碑完成, 重置计数
t.WarnFlag = 0
}
}
}
// 检查反馈异常
{
t.Anomaly += 1
for _, val := range taskRecordData.RemarkContent {
txt := strings.TrimSpace(val.RemarkText)
if len(txt) == 0 || txt == "无" {
continue
}
//反馈正常,重置计数
t.Anomaly = 0
break
}
}
// 检查辅导异常
{
taskRecordData.AssistContent = strings.TrimSpace(taskRecordData.AssistContent)
if t.Anomaly == 0 && t.WarnFlag == 0 {
//里程碑正常,反馈正常, 设定为已辅导
t.AssistFlag = 0
} else {
//里程碑和反馈 其中一个不正常,记录一次辅导异常
t.AssistFlag += 1
}
if taskRecordData.AssistLevel != AssistLevel1 && !(taskRecordData.AssistContent == "无" || len(taskRecordData.AssistContent) == 0) {
//只要正常填写的辅导都设定为已辅导
t.AssistFlag = 0
}
}
}
type TaskRepository interface {
Save(param *Task) error
Remove(id int) error
... ...
... ... @@ -115,16 +115,95 @@ func (t *TaskAnomaly) AnomalyDesc() (str string) {
// 检查是否是反馈异常
func (t *TaskAnomaly) IsAssessFlag(taskData *Task, taskRecordData *TaskRecord) bool {
if taskData.Anomaly <= 0 {
return false
}
*t = TaskAnomaly{
Id: 0,
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
CompanyId: taskData.CompanyId,
TaskId: taskData.Id,
TaskRecordId: taskRecordData.Id,
Category: AnomalyCategoryType2,
CurrentStage: taskData.CurrentStage,
LastStage: taskData.LastStage,
TaskStageCheck: taskRecordData.TaskStageCheck,
AssessFlag: 1,
WarnFlag: 0,
AssistFlag: 0,
IsLast: 1,
RecordBegin: xtime.DayZeroTime(taskRecordData.CreatedAt).Unix(),
NoticeWho: []map[string]string{},
Marks: map[string]string{
"a": "去更新", "b": "去反馈", "c": "找上级", "d": "去辅导",
},
Remark: "",
}
return true
}
// 检查是否是里程碑异常
func (t *TaskAnomaly) IsWarnFlag(taskData *Task, taskRecordData *TaskRecord) bool {
if taskData.CurrentStage.Id == 0 {
// 没有新的里程碑
return false
}
if taskData.CurrentStage.PlanCompletedAt > time.Now().Unix() {
//新的里程碑未过期, 不计入异常情况
return false
}
*t = TaskAnomaly{
Id: 0,
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
CompanyId: taskData.CompanyId,
TaskId: taskData.Id,
TaskRecordId: taskRecordData.Id,
Category: AnomalyCategoryType1,
CurrentStage: taskData.CurrentStage,
LastStage: taskData.LastStage,
TaskStageCheck: taskRecordData.TaskStageCheck,
AssessFlag: 0,
WarnFlag: 1,
AssistFlag: 0,
IsLast: 1,
RecordBegin: xtime.DayZeroTime(taskRecordData.CreatedAt).Unix(),
NoticeWho: []map[string]string{},
Marks: map[string]string{
"a": "去更新", "b": "去反馈", "c": "找上级", "d": "去辅导",
},
Remark: "",
}
return true
}
// 检查是否是辅导异常
// 检查是否是辅导异常
func (t *TaskAnomaly) IsAssistFlag(taskData *Task, taskRecordData *TaskRecord) bool {
if taskData.AssistFlag < taskData.AssistFlagMax {
return false
}
*t = TaskAnomaly{
Id: 0,
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
CompanyId: taskData.CompanyId,
TaskId: taskData.Id,
TaskRecordId: taskRecordData.Id,
Category: AnomalyCategoryType3,
CurrentStage: taskData.CurrentStage,
LastStage: taskData.LastStage,
TaskStageCheck: taskRecordData.TaskStageCheck,
AssessFlag: taskData.Anomaly,
WarnFlag: taskData.WarnFlag,
AssistFlag: taskData.AssistFlag,
IsLast: 1,
RecordBegin: xtime.DayZeroTime(taskRecordData.CreatedAt).Unix(),
NoticeWho: []map[string]string{},
Marks: map[string]string{
"a": "去更新", "b": "去反馈", "c": "找上级", "d": "去辅导",
},
Remark: "",
}
return true
}
... ...
... ... @@ -44,7 +44,7 @@ func (repo *TaskRepository) TransformToDomain(d *models.Task) *domain.Task {
RunAt: d.RunAt,
StopAt: d.StopAt,
Anomaly: d.Anomaly,
WarnFlag: domain.TaskWarnFlag(d.WarnFlag),
WarnFlag: d.WarnFlag,
AssistFlag: d.AssistFlag,
AssistFlagMax: d.AssistFlagMax,
CurrentStage: d.CurrentStage,
... ...