作者 tangxvhui

日常保存

@@ -55,7 +55,7 @@ func checkTaskRecordV2(param *domain.TaskRecord) error { @@ -55,7 +55,7 @@ func checkTaskRecordV2(param *domain.TaskRecord) error {
55 if err != nil { 55 if err != nil {
56 return err 56 return err
57 } 57 }
58 - } else if param.TaskStageCheck.Id > 0 { 58 + } else {
59 taskData.WarnFlag = domain.TaskWarnNull 59 taskData.WarnFlag = domain.TaskWarnNull
60 err := isNotWarnFlag(transactionContext, taskData, param) 60 err := isNotWarnFlag(transactionContext, taskData, param)
61 if err != nil { 61 if err != nil {
@@ -114,8 +114,20 @@ func isNotWarnFlag(transactionContext application.TransactionContext, taskData * @@ -114,8 +114,20 @@ func isNotWarnFlag(transactionContext application.TransactionContext, taskData *
114 return nil 114 return nil
115 } 115 }
116 116
117 -// 处理里程碑异常的情况 117 +// 处理里程碑异常的情况, 日评中 里程碑未正常填写,包含 逾期完成,逾期未完成。
  118 +// 记录异常
118 func isWarnFlag(transactionContext application.TransactionContext, taskData *domain.Task, taskRecord *domain.TaskRecord) error { 119 func isWarnFlag(transactionContext application.TransactionContext, taskData *domain.Task, taskRecord *domain.TaskRecord) error {
  120 +
  121 + nowTime := time.Now()
  122 + if taskData.CurrentStage.Id == 0 && taskRecord.TaskStageCheck.RealCompletedAt > 0 {
  123 + // 逾期完成,且没有后续的任务
  124 + return isNotWarnFlag(transactionContext, taskData, taskRecord)
  125 + }
  126 + if taskData.CurrentStage.PlanCompletedAt > nowTime.Unix() && taskRecord.TaskStageCheck.RealCompletedAt > 0 {
  127 + //逾期完成,且后续任务为过期
  128 + return isNotWarnFlag(transactionContext, taskData, taskRecord)
  129 + }
  130 +
119 taskAnomalyRepo := factory.CreateTaskAnomalyRepository(map[string]interface{}{ 131 taskAnomalyRepo := factory.CreateTaskAnomalyRepository(map[string]interface{}{
120 "transactionContext": transactionContext, 132 "transactionContext": transactionContext,
121 }) 133 })
@@ -36,6 +36,13 @@ type TaskAnomaly struct { @@ -36,6 +36,13 @@ type TaskAnomaly struct {
36 Remark string `json:"remark"` 36 Remark string `json:"remark"`
37 } 37 }
38 38
  39 +// 存储
  40 +type TaskAnomalyRepository interface {
  41 + Save(param *TaskAnomaly) error
  42 + FindOne(queryOptions map[string]interface{}) (*TaskAnomaly, error)
  43 + Find(queryOptions map[string]interface{}) (int, []*TaskAnomaly, error)
  44 +}
  45 +
39 // 已点击“去更新” 46 // 已点击“去更新”
40 func (t *TaskAnomaly) MarkA() { 47 func (t *TaskAnomaly) MarkA() {
41 t.Marks["a"] = "已更新" 48 t.Marks["a"] = "已更新"
@@ -72,19 +79,10 @@ func (t *TaskAnomaly) AnomalyDesc() (str string) { @@ -72,19 +79,10 @@ func (t *TaskAnomaly) AnomalyDesc() (str string) {
72 case 1: 79 case 1:
73 //里程碑异常 80 //里程碑异常
74 { 81 {
75 - if t.TaskStageCheck.RealCompletedAt == 0 {  
76 //逾期未完成 82 //逾期未完成
77 - planCompletedAt := time.Unix(t.TaskStageCheck.PlanCompletedAt, 0) 83 + planCompletedAt := time.Unix(t.CurrentStage.PlanCompletedAt, 0)
78 subDay := xtime.SubDayAbs(nowTime, planCompletedAt) 84 subDay := xtime.SubDayAbs(nowTime, planCompletedAt)
79 str = fmt.Sprintf("里程碑%s已逾期%d天", t.TaskStageCheck.Name, subDay) 85 str = fmt.Sprintf("里程碑%s已逾期%d天", t.TaskStageCheck.Name, subDay)
80 - } else {  
81 - //逾期完成  
82 - planCompletedAt := time.Unix(t.TaskStageCheck.PlanCompletedAt, 0)  
83 - realCompletedAt := time.Unix(t.TaskStageCheck.RealCompletedAt, 0)  
84 - subDay := xtime.SubDayAbs(realCompletedAt, planCompletedAt)  
85 - str = fmt.Sprintf("里程碑%s逾期%d天完成", t.TaskStageCheck.Name, subDay)  
86 -  
87 - }  
88 } 86 }
89 case 2: 87 case 2:
90 //反馈异常 88 //反馈异常
@@ -99,7 +97,7 @@ func (t *TaskAnomaly) AnomalyDesc() (str string) { @@ -99,7 +97,7 @@ func (t *TaskAnomaly) AnomalyDesc() (str string) {
99 97
100 } 98 }
101 case 3: 99 case 3:
102 - // 辅导异常 100 + // 辅导异常 TODO
103 { 101 {
104 recordBegin := time.Unix(t.RecordBegin, 0) 102 recordBegin := time.Unix(t.RecordBegin, 0)
105 subDay := xtime.SubDayAbs(nowTime, recordBegin) 103 subDay := xtime.SubDayAbs(nowTime, recordBegin)
@@ -115,16 +113,18 @@ func (t *TaskAnomaly) AnomalyDesc() (str string) { @@ -115,16 +113,18 @@ func (t *TaskAnomaly) AnomalyDesc() (str string) {
115 return str 113 return str
116 } 114 }
117 115
118 -// 发生异常后的天数  
119 -// func (t *TaskAnomaly) CountAnomalyDay() int {  
120 -// t1 := t.CreatedAt  
121 -// t2 := time.Unix(t.RecordBegin, 0)  
122 -// return xtime.SubDayAbs(t1, t2)  
123 -// } 116 +// 检查是否是反馈异常
  117 +func (t *TaskAnomaly) IsAssessFlag(taskData *Task, taskRecordData *TaskRecord) bool {
124 118
125 -// 存储  
126 -type TaskAnomalyRepository interface {  
127 - Save(param *TaskAnomaly) error  
128 - FindOne(queryOptions map[string]interface{}) (*TaskAnomaly, error)  
129 - Find(queryOptions map[string]interface{}) (int, []*TaskAnomaly, error) 119 + return false
  120 +}
  121 +
  122 +// 检查是否是里程碑异常
  123 +func (t *TaskAnomaly) IsWarnFlag(taskData *Task, taskRecordData *TaskRecord) bool {
  124 + return false
  125 +}
  126 +
  127 +// 检查是否是辅导异常
  128 +func (t *TaskAnomaly) IsAssistFlag(taskData *Task, taskRecordData *TaskRecord) bool {
  129 + return false
130 } 130 }
@@ -56,10 +56,13 @@ type TaskRecordRepository interface { @@ -56,10 +56,13 @@ type TaskRecordRepository interface {
56 56
57 // 是否是辅导异常 57 // 是否是辅导异常
58 func (r *TaskRecord) IsAssistAnomaly() bool { 58 func (r *TaskRecord) IsAssistAnomaly() bool {
  59 + //TODO 判断是否辅导异常
  60 +
59 r.AssistContent = strings.TrimSpace(r.AssistContent) 61 r.AssistContent = strings.TrimSpace(r.AssistContent)
60 if r.AssistLevel == AssistLevel1 || r.AssistContent == "无" || len(r.AssistContent) == 0 { 62 if r.AssistLevel == AssistLevel1 || r.AssistContent == "无" || len(r.AssistContent) == 0 {
61 return true 63 return true
62 } 64 }
  65 +
63 return false 66 return false
64 } 67 }
65 68