作者 tangxvhui

日常保存

... ... @@ -55,7 +55,7 @@ func checkTaskRecordV2(param *domain.TaskRecord) error {
if err != nil {
return err
}
} else if param.TaskStageCheck.Id > 0 {
} else {
taskData.WarnFlag = domain.TaskWarnNull
err := isNotWarnFlag(transactionContext, taskData, param)
if err != nil {
... ... @@ -114,8 +114,20 @@ func isNotWarnFlag(transactionContext application.TransactionContext, taskData *
return nil
}
// 处理里程碑异常的情况
// 处理里程碑异常的情况, 日评中 里程碑未正常填写,包含 逾期完成,逾期未完成。
// 记录异常
func isWarnFlag(transactionContext application.TransactionContext, taskData *domain.Task, taskRecord *domain.TaskRecord) error {
nowTime := time.Now()
if taskData.CurrentStage.Id == 0 && taskRecord.TaskStageCheck.RealCompletedAt > 0 {
// 逾期完成,且没有后续的任务
return isNotWarnFlag(transactionContext, taskData, taskRecord)
}
if taskData.CurrentStage.PlanCompletedAt > nowTime.Unix() && taskRecord.TaskStageCheck.RealCompletedAt > 0 {
//逾期完成,且后续任务为过期
return isNotWarnFlag(transactionContext, taskData, taskRecord)
}
taskAnomalyRepo := factory.CreateTaskAnomalyRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
... ...
... ... @@ -36,6 +36,13 @@ type TaskAnomaly struct {
Remark string `json:"remark"`
}
// 存储
type TaskAnomalyRepository interface {
Save(param *TaskAnomaly) error
FindOne(queryOptions map[string]interface{}) (*TaskAnomaly, error)
Find(queryOptions map[string]interface{}) (int, []*TaskAnomaly, error)
}
// 已点击“去更新”
func (t *TaskAnomaly) MarkA() {
t.Marks["a"] = "已更新"
... ... @@ -72,19 +79,10 @@ func (t *TaskAnomaly) AnomalyDesc() (str string) {
case 1:
//里程碑异常
{
if t.TaskStageCheck.RealCompletedAt == 0 {
//逾期未完成
planCompletedAt := time.Unix(t.TaskStageCheck.PlanCompletedAt, 0)
subDay := xtime.SubDayAbs(nowTime, planCompletedAt)
str = fmt.Sprintf("里程碑%s已逾期%d天", t.TaskStageCheck.Name, subDay)
} else {
//逾期完成
planCompletedAt := time.Unix(t.TaskStageCheck.PlanCompletedAt, 0)
realCompletedAt := time.Unix(t.TaskStageCheck.RealCompletedAt, 0)
subDay := xtime.SubDayAbs(realCompletedAt, planCompletedAt)
str = fmt.Sprintf("里程碑%s逾期%d天完成", t.TaskStageCheck.Name, subDay)
}
//逾期未完成
planCompletedAt := time.Unix(t.CurrentStage.PlanCompletedAt, 0)
subDay := xtime.SubDayAbs(nowTime, planCompletedAt)
str = fmt.Sprintf("里程碑%s已逾期%d天", t.TaskStageCheck.Name, subDay)
}
case 2:
//反馈异常
... ... @@ -99,7 +97,7 @@ func (t *TaskAnomaly) AnomalyDesc() (str string) {
}
case 3:
// 辅导异常
// 辅导异常 TODO
{
recordBegin := time.Unix(t.RecordBegin, 0)
subDay := xtime.SubDayAbs(nowTime, recordBegin)
... ... @@ -115,16 +113,18 @@ func (t *TaskAnomaly) AnomalyDesc() (str string) {
return str
}
// 发生异常后的天数
// func (t *TaskAnomaly) CountAnomalyDay() int {
// t1 := t.CreatedAt
// t2 := time.Unix(t.RecordBegin, 0)
// return xtime.SubDayAbs(t1, t2)
// }
// 检查是否是反馈异常
func (t *TaskAnomaly) IsAssessFlag(taskData *Task, taskRecordData *TaskRecord) bool {
// 存储
type TaskAnomalyRepository interface {
Save(param *TaskAnomaly) error
FindOne(queryOptions map[string]interface{}) (*TaskAnomaly, error)
Find(queryOptions map[string]interface{}) (int, []*TaskAnomaly, error)
return false
}
// 检查是否是里程碑异常
func (t *TaskAnomaly) IsWarnFlag(taskData *Task, taskRecordData *TaskRecord) bool {
return false
}
// 检查是否是辅导异常
func (t *TaskAnomaly) IsAssistFlag(taskData *Task, taskRecordData *TaskRecord) bool {
return false
}
... ...
... ... @@ -56,10 +56,13 @@ type TaskRecordRepository interface {
// 是否是辅导异常
func (r *TaskRecord) IsAssistAnomaly() bool {
//TODO 判断是否辅导异常
r.AssistContent = strings.TrimSpace(r.AssistContent)
if r.AssistLevel == AssistLevel1 || r.AssistContent == "无" || len(r.AssistContent) == 0 {
return true
}
return false
}
... ...