审查视图

pkg/domain/task_record.go 3.8 KB
tangxvhui authored
1 2
package domain
tangxvhui authored
3
import (
4
	"strings"
tangxvhui authored
5 6
	"time"
)
tangxvhui authored
7
8 9 10 11 12 13 14
const (
	AssistLevel1 int = 1 // 未辅导
	AssistLevel2 int = 2 // 已辅导-辅导对里程碑无作用
	AssistLevel3 int = 3 // 已辅导-辅导对里程碑作用一般
	AssistLevel4 int = 4 // 已辅导-辅导对里程碑作用很好
)
15
const (
16 17 18 19 20 21 22 23 24
	AnomalyStateInit int = -1 // 反馈初始值
	AnomalyState0    int = 0  // 反馈异常
	AnomalyState1    int = 1  // 反馈正常
)

const (
	AssistStateInit int = -1 // 辅导初始值
	AssistState0    int = 0  // 辅导异常
	AssistState1    int = 1  // 辅导正常
25 26
)
27
// TaskRecord 任务反馈情况记录
tangxvhui authored
28
type TaskRecord struct {
tangxvhui authored
29 30 31 32 33 34 35 36 37 38 39
	Id             int          `json:"id,string" comment:"记录ID"`
	CompanyId      int          `json:"companyId,string" comment:"公司ID"`
	StaffAssessId  int          `json:"staffAssessId,string" comment:"每日评估的ID"`
	TaskId         int          `json:"taskId,string" comment:"任务ID"`
	TaskCategory   string       `json:"taskCategory" comment:"任务类别"`
	TaskName       string       `json:"taskName" comment:"任务名称"`
	TaskAlias      string       `json:"taskAlias" comment:"任务别名"`
	TaskLeader     TaskLeader   `json:"taskLeader" comment:"任务负责人"`
	RemarkContent  []RemarkText `json:"remarkContent" comment:"反馈填写"`
	AssistLevel    int          `json:"assistLevel" comment:"上级辅导情况"`
	AssistContent  string       `json:"assistContent" comment:"上级辅导内容"`
40 41
	AnomalyState   int          `json:"anomalyState" comment:"反馈异常状态(-1初始状态、0异常、1正常)"`
	AssistState    int          `json:"assistState" comment:"辅导异常状态(-1初始状态、0异常、1正常)"`
tangxvhui authored
42 43 44 45 46
	TaskStages     []TaskStage  `json:"taskStages" comment:"里程碑列表"`
	TaskStageCheck TaskStage    `json:"taskStageCheck" comment:"提交的里程碑"`
	CreatedAt      time.Time    `json:"createdAt" comment:"创建时间"`
	UpdatedAt      time.Time    `json:"updatedAt" comment:"更新时间"`
	DeletedAt      *time.Time   `json:"deletedAt" comment:"删除时间"`
47
	TaskCreatedBy  int          `json:"taskCreatedBy" comment:"任务的创建方式"` // 任务的创建方式 0: 模板导入创建,1:主动创建
48 49 50 51 52 53 54
}

type TaskRecordRepository interface {
	Insert(t *TaskRecord) (*TaskRecord, error)
	Remove(t *TaskRecord) (*TaskRecord, error)
	FindOne(queryOptions map[string]interface{}) (*TaskRecord, error)
	Find(queryOptions map[string]interface{}) (int, []*TaskRecord, error)
tangxvhui authored
55
}
tangxvhui authored
56
tangxvhui authored
57
// 是否是辅导异常
58 59 60 61 62 63
func (r *TaskRecord) IsAssistAnomaly() bool {
	// 判断是否辅导异常
	taskStageAnomaly := true
	if r.TaskStageCheck.RealCompletedAt > 0 {
		taskStageAnomaly = false
	}
tangxvhui authored
64
65 66 67 68 69 70 71 72 73
	remarkAnomaly := true
	for _, val := range r.RemarkContent {
		txt := strings.TrimSpace(val.RemarkText)
		if len(txt) == 0 || txt == "无" {
			continue
		}
		remarkAnomaly = false
		break
	}
tangxvhui authored
74
75 76 77 78 79 80 81 82 83 84 85 86
	assistAnomaly := false
	if taskStageAnomaly || remarkAnomaly {
		assistAnomaly = true
	}
	r.AssistContent = strings.TrimSpace(r.AssistContent)
	if r.AssistLevel == AssistLevel1 || r.AssistContent == "无" || len(r.AssistContent) == 0 {

	} else {
		assistAnomaly = false
	}
	return assistAnomaly
}
tangxvhui authored
87 88

// 是否是里程碑异常
89 90 91 92 93 94 95 96 97 98 99 100 101
// func (r *TaskRecord) IsTaskStageAnomaly() bool {
// 	if r.TaskStageCheck.Id == 0 {
// 		return false
// 	}
// 	realCompletedAt := r.TaskStageCheck.RealCompletedAt
// 	if realCompletedAt == 0 {
// 		//假设现在完成
// 		realCompletedAt = time.Now().Unix()
// 	}
// 	if r.TaskStageCheck.PlanCompletedAt < realCompletedAt {
// 		//逾期完成,或者预期未完成
// 		return true
// 	}
tangxvhui authored
102
103 104
// 	return false
// }
tangxvhui authored
105 106

// 是否是反馈异常
107 108 109 110 111 112 113 114 115 116 117 118 119
func (r *TaskRecord) IsRemarkAnomaly() bool {
	isAnomaly := true
	for _, val := range r.RemarkContent {
		txt := strings.TrimSpace(val.RemarkText)
		if len(txt) == 0 || txt == "无" {
			continue
		}
		isAnomaly = false
		break
	}

	return isAnomaly
}