正在显示
6 个修改的文件
包含
141 行增加
和
129 行删除
此 diff 太大无法显示。
@@ -19,6 +19,11 @@ const ( | @@ -19,6 +19,11 @@ const ( | ||
19 | LinkNodeViewResult int = 5 // 环节-绩效结果查看 | 19 | LinkNodeViewResult int = 5 // 环节-绩效结果查看 |
20 | ) | 20 | ) |
21 | 21 | ||
22 | +const ( | ||
23 | + NodeRequiredNo int = 1 // 是否必填项-非必填 | ||
24 | + NodeRequiredYes int = 2 // 是否必填项-必填 | ||
25 | +) | ||
26 | + | ||
22 | type EntryItem struct { | 27 | type EntryItem struct { |
23 | Title string `json:"title" comment:"填写标题"` | 28 | Title string `json:"title" comment:"填写标题"` |
24 | HintText string `json:"hintText" comment:"文本内容提示"` | 29 | HintText string `json:"hintText" comment:"文本内容提示"` |
@@ -35,6 +40,7 @@ type NodeContent struct { | @@ -35,6 +40,7 @@ type NodeContent struct { | ||
35 | PromptTitle string `json:"promptTitle" comment:"提示项标题"` | 40 | PromptTitle string `json:"promptTitle" comment:"提示项标题"` |
36 | PromptText string `json:"promptText" comment:"提示项正文"` | 41 | PromptText string `json:"promptText" comment:"提示项正文"` |
37 | EntryItems []*EntryItem `json:"entryItems" comment:"填写项"` | 42 | EntryItems []*EntryItem `json:"entryItems" comment:"填写项"` |
43 | + Required int `json:"required" comment:"必填项"` | ||
38 | } | 44 | } |
39 | 45 | ||
40 | // LinkNode 评估流程、环节 | 46 | // LinkNode 评估流程、环节 |
1 | -package domain | ||
2 | - | ||
3 | -import ( | ||
4 | - "errors" | ||
5 | - "fmt" | ||
6 | - "strconv" | ||
7 | - "time" | ||
8 | -) | ||
9 | - | ||
10 | -//填写的评估内容 | ||
11 | -type StaffAssessContent struct { | ||
12 | - Id int `json:"id"` //id | ||
13 | - StaffAssessId int `json:"staffAssessId"` //用户需要的评估项id | ||
14 | - SortBy int `json:"sortBy"` //排序 | ||
15 | - Category string `json:"category"` //类别 | ||
16 | - Name string `json:"name"` //名称 | ||
17 | - PromptTitle string `json:"promptTitle"` //提示项标题 | ||
18 | - PromptText string `json:"promptText"` //提示项正文 | ||
19 | - Remark []AssessContemtRemark `json:"remark"` //填写的反馈 | ||
20 | - Value string `json:"value"` //评估填写的值 | ||
21 | - ScoreValue float64 `json:"scoreValue"` // 填写值按规则Rule转换为相应的量化值 | ||
22 | - LevelValue string `json:"levelValue"` // 填写值按规则Rule转换为相应的等级值 | ||
23 | - ReteResult string `json:"reteResult"` //评估的结果 | ||
24 | - Rule EvaluationRule `json:"rule"` //评估的选项规则 | ||
25 | - Weight float64 `json:"weight" ` //"权重" | ||
26 | - CreatedAt time.Time `json:"createdAt"` //数据创建时间 | ||
27 | - UpdatedAt time.Time `json:"updatedAt"` //数据更新时间 | ||
28 | - DeletedAt *time.Time `json:"deletedAt"` | ||
29 | -} | ||
30 | - | ||
31 | -type AssessContemtRemark struct { | ||
32 | - Title string `json:"title"` //comment:"填写标题" | ||
33 | - HintText string `json:"hintText"` // comment:"文本内容提示" | ||
34 | - Definition string `json:"definition"` //comment:"定义" | ||
35 | - RemarkText string `json:"remarkText"` // comment:"填写文本内容" | ||
36 | -} | ||
37 | - | ||
38 | -//TransformValue | ||
39 | -//根据规则 rule 转换评填写的值 | ||
40 | -func (content *StaffAssessContent) TransformValue() error { | ||
41 | - switch content.Rule.Type { | ||
42 | - case EvaluationTypeRating: | ||
43 | - return content.ratingValue() | ||
44 | - case EvaluationTypeScore: | ||
45 | - return content.scoreValue() | ||
46 | - } | ||
47 | - return nil | ||
48 | -} | ||
49 | - | ||
50 | -// 规则是评级方式 | ||
51 | -func (content *StaffAssessContent) ratingValue() error { | ||
52 | - levels := content.Rule.Rating.Levels | ||
53 | - for _, v := range levels { | ||
54 | - if v.Code != content.Value { | ||
55 | - continue | ||
56 | - } | ||
57 | - content.LevelValue = v.Code | ||
58 | - content.ScoreValue = v.QuantizedValue | ||
59 | - content.ReteResult = v.Name | ||
60 | - return nil | ||
61 | - } | ||
62 | - return errors.New("评级填写的值错误") | ||
63 | -} | ||
64 | - | ||
65 | -// 规则是评分方式 | ||
66 | -func (content *StaffAssessContent) scoreValue() error { | ||
67 | - valueFloat, err := strconv.ParseFloat(content.Value, 64) | ||
68 | - if err != nil { | ||
69 | - return errors.New("评分填写的值错误") | ||
70 | - } | ||
71 | - rule := &content.Rule | ||
72 | - if valueFloat < rule.Score.Min || valueFloat > rule.Score.Max { | ||
73 | - return fmt.Errorf("评分填写的值超出限制,>=%f且<=%f", rule.Score.Min, rule.Score.Max) | ||
74 | - } | ||
75 | - //保留小数处理 | ||
76 | - fStr := fmt.Sprintf("%%.%df", rule.Score.DecimalPlaces) | ||
77 | - valueStr := fmt.Sprintf(fStr, valueFloat) | ||
78 | - content.Value = valueStr | ||
79 | - if rule.Score.IntervalState == 0 { | ||
80 | - // 未开启按分数子区间匹配等级 | ||
81 | - return nil | ||
82 | - } | ||
83 | - for _, v := range rule.Score.Levels { | ||
84 | - if valueFloat < v.Start || valueFloat > v.End { | ||
85 | - continue | ||
86 | - } | ||
87 | - content.LevelValue = v.Code | ||
88 | - content.ScoreValue = valueFloat | ||
89 | - content.ReteResult = v.Name | ||
90 | - return nil | ||
91 | - } | ||
92 | - return errors.New("评分填写的值错误") | ||
93 | -} | ||
94 | - | ||
95 | -type StaffAssessContentRepository interface { | ||
96 | - Save(param *StaffAssessContent) (*StaffAssessContent, error) | ||
97 | - Remove(id int) error | ||
98 | - FindOne(queryOptions map[string]interface{}) (*StaffAssessContent, error) | ||
99 | - Find(queryOptions map[string]interface{}) (int, []*StaffAssessContent, error) | ||
100 | -} | 1 | +package domain |
2 | + | ||
3 | +import ( | ||
4 | + "errors" | ||
5 | + "fmt" | ||
6 | + "strconv" | ||
7 | + "time" | ||
8 | +) | ||
9 | + | ||
10 | +//填写的评估内容 | ||
11 | +type StaffAssessContent struct { | ||
12 | + Id int `json:"id"` //id | ||
13 | + StaffAssessId int `json:"staffAssessId"` //用户需要的评估项id | ||
14 | + SortBy int `json:"sortBy"` //排序 | ||
15 | + Category string `json:"category"` //类别 | ||
16 | + Name string `json:"name"` //名称 | ||
17 | + PromptTitle string `json:"promptTitle"` //提示项标题 | ||
18 | + PromptText string `json:"promptText"` //提示项正文 | ||
19 | + Remark []AssessContemtRemark `json:"remark"` //填写的反馈 | ||
20 | + Value string `json:"value"` //评估填写的值 | ||
21 | + ScoreValue float64 `json:"scoreValue"` // 填写值按规则Rule转换为相应的量化值 | ||
22 | + LevelValue string `json:"levelValue"` // 填写值按规则Rule转换为相应的等级值 | ||
23 | + ReteResult string `json:"reteResult"` //评估的结果 | ||
24 | + Rule EvaluationRule `json:"rule"` //评估的选项规则 | ||
25 | + Weight float64 `json:"weight" ` //"权重" | ||
26 | + Required int `json:"required"` // 必填项 | ||
27 | + CreatedAt time.Time `json:"createdAt"` //数据创建时间 | ||
28 | + UpdatedAt time.Time `json:"updatedAt"` //数据更新时间 | ||
29 | + DeletedAt *time.Time `json:"deletedAt"` | ||
30 | +} | ||
31 | + | ||
32 | +type AssessContemtRemark struct { | ||
33 | + Title string `json:"title"` //comment:"填写标题" | ||
34 | + HintText string `json:"hintText"` // comment:"文本内容提示" | ||
35 | + Definition string `json:"definition"` //comment:"定义" | ||
36 | + RemarkText string `json:"remarkText"` // comment:"填写文本内容" | ||
37 | +} | ||
38 | + | ||
39 | +//TransformValue | ||
40 | +//根据规则 rule 转换评填写的值 | ||
41 | +func (content *StaffAssessContent) TransformValue() error { | ||
42 | + switch content.Rule.Type { | ||
43 | + case EvaluationTypeRating: | ||
44 | + return content.ratingValue() | ||
45 | + case EvaluationTypeScore: | ||
46 | + return content.scoreValue() | ||
47 | + } | ||
48 | + return nil | ||
49 | +} | ||
50 | + | ||
51 | +// 规则是评级方式 | ||
52 | +func (content *StaffAssessContent) ratingValue() error { | ||
53 | + levels := content.Rule.Rating.Levels | ||
54 | + for _, v := range levels { | ||
55 | + if v.Code != content.Value { | ||
56 | + continue | ||
57 | + } | ||
58 | + content.LevelValue = v.Code | ||
59 | + content.ScoreValue = v.QuantizedValue | ||
60 | + content.ReteResult = v.Name | ||
61 | + return nil | ||
62 | + } | ||
63 | + return errors.New("评级填写的值错误") | ||
64 | +} | ||
65 | + | ||
66 | +// 规则是评分方式 | ||
67 | +func (content *StaffAssessContent) scoreValue() error { | ||
68 | + valueFloat, err := strconv.ParseFloat(content.Value, 64) | ||
69 | + if err != nil { | ||
70 | + return errors.New("评分填写的值错误") | ||
71 | + } | ||
72 | + rule := &content.Rule | ||
73 | + if valueFloat < rule.Score.Min || valueFloat > rule.Score.Max { | ||
74 | + return fmt.Errorf("评分填写的值超出限制,>=%f且<=%f", rule.Score.Min, rule.Score.Max) | ||
75 | + } | ||
76 | + //保留小数处理 | ||
77 | + fStr := fmt.Sprintf("%%.%df", rule.Score.DecimalPlaces) | ||
78 | + valueStr := fmt.Sprintf(fStr, valueFloat) | ||
79 | + content.Value = valueStr | ||
80 | + if rule.Score.IntervalState == 0 { | ||
81 | + // 未开启按分数子区间匹配等级 | ||
82 | + return nil | ||
83 | + } | ||
84 | + for _, v := range rule.Score.Levels { | ||
85 | + if valueFloat < v.Start || valueFloat > v.End { | ||
86 | + continue | ||
87 | + } | ||
88 | + content.LevelValue = v.Code | ||
89 | + content.ScoreValue = valueFloat | ||
90 | + content.ReteResult = v.Name | ||
91 | + return nil | ||
92 | + } | ||
93 | + return errors.New("评分填写的值错误") | ||
94 | +} | ||
95 | + | ||
96 | +type StaffAssessContentRepository interface { | ||
97 | + Save(param *StaffAssessContent) (*StaffAssessContent, error) | ||
98 | + Remove(id int) error | ||
99 | + FindOne(queryOptions map[string]interface{}) (*StaffAssessContent, error) | ||
100 | + Find(queryOptions map[string]interface{}) (int, []*StaffAssessContent, error) | ||
101 | +} |
1 | -package models | ||
2 | - | ||
3 | -import ( | ||
4 | - "time" | ||
5 | - | ||
6 | - "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
7 | -) | ||
8 | - | ||
9 | -// 填写的评估内容 | ||
10 | -type StaffAssessContent struct { | ||
11 | - tableName struct{} `pg:"staff_assess_content" comment:"填写的评估项"` | ||
12 | - Id int `pg:",pk"` //id | ||
13 | - StaffAssessId int //用户需要的评估项id | ||
14 | - SortBy int //排序 | ||
15 | - Category string //类别 | ||
16 | - Name string //名称 | ||
17 | - ScoreValue float64 // 填写值按规则Rule转换为相应的量化值 | ||
18 | - LevelValue string // 填写值按规则Rule转换为相应的等级值 | ||
19 | - PromptTitle string //问题标题 | ||
20 | - PromptText string //提示项正文 | ||
21 | - Value string //评估填写的值 | ||
22 | - ReteResult string //评估的结果 | ||
23 | - Rule domain.EvaluationRule | ||
24 | - Remark []domain.AssessContemtRemark | ||
25 | - Weight float64 `pg:",use_zero"` //权重 | ||
26 | - CreatedAt time.Time //数据创建时间 | ||
27 | - UpdatedAt time.Time //数据更新时间 | ||
28 | - DeletedAt *time.Time | ||
29 | -} | 1 | +package models |
2 | + | ||
3 | +import ( | ||
4 | + "time" | ||
5 | + | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
7 | +) | ||
8 | + | ||
9 | +// 填写的评估内容 | ||
10 | +type StaffAssessContent struct { | ||
11 | + tableName struct{} `pg:"staff_assess_content" comment:"填写的评估项"` | ||
12 | + Id int `pg:",pk"` //id | ||
13 | + StaffAssessId int //用户需要的评估项id | ||
14 | + SortBy int //排序 | ||
15 | + Category string //类别 | ||
16 | + Name string //名称 | ||
17 | + ScoreValue float64 // 填写值按规则Rule转换为相应的量化值 | ||
18 | + LevelValue string // 填写值按规则Rule转换为相应的等级值 | ||
19 | + PromptTitle string //问题标题 | ||
20 | + PromptText string //提示项正文 | ||
21 | + Value string //评估填写的值 | ||
22 | + ReteResult string //评估的结果 | ||
23 | + Rule domain.EvaluationRule | ||
24 | + Remark []domain.AssessContemtRemark | ||
25 | + Weight float64 `pg:",use_zero"` //权重 | ||
26 | + Required int //必填项 | ||
27 | + CreatedAt time.Time //数据创建时间 | ||
28 | + UpdatedAt time.Time //数据更新时间 | ||
29 | + DeletedAt *time.Time | ||
30 | +} |
@@ -37,6 +37,7 @@ func (repo *StaffAssessContentRepository) TransformToDomain(d *models.StaffAsses | @@ -37,6 +37,7 @@ func (repo *StaffAssessContentRepository) TransformToDomain(d *models.StaffAsses | ||
37 | ReteResult: d.ReteResult, | 37 | ReteResult: d.ReteResult, |
38 | Rule: d.Rule, | 38 | Rule: d.Rule, |
39 | Weight: d.Weight, | 39 | Weight: d.Weight, |
40 | + Required: d.Required, | ||
40 | CreatedAt: d.CreatedAt, | 41 | CreatedAt: d.CreatedAt, |
41 | UpdatedAt: d.UpdatedAt, | 42 | UpdatedAt: d.UpdatedAt, |
42 | DeletedAt: nil, | 43 | DeletedAt: nil, |
@@ -59,6 +60,7 @@ func (repo *StaffAssessContentRepository) Save(d *domain.StaffAssessContent) (*d | @@ -59,6 +60,7 @@ func (repo *StaffAssessContentRepository) Save(d *domain.StaffAssessContent) (*d | ||
59 | Rule: d.Rule, | 60 | Rule: d.Rule, |
60 | Remark: d.Remark, | 61 | Remark: d.Remark, |
61 | Weight: d.Weight, | 62 | Weight: d.Weight, |
63 | + Required: d.Required, | ||
62 | CreatedAt: d.CreatedAt, | 64 | CreatedAt: d.CreatedAt, |
63 | UpdatedAt: d.UpdatedAt, | 65 | UpdatedAt: d.UpdatedAt, |
64 | DeletedAt: nil, | 66 | DeletedAt: nil, |
@@ -120,6 +120,8 @@ func (controller *ImportController) parseTemplateNodeContent(data []*domain.Perf | @@ -120,6 +120,8 @@ func (controller *ImportController) parseTemplateNodeContent(data []*domain.Perf | ||
120 | }) | 120 | }) |
121 | } | 121 | } |
122 | 122 | ||
123 | + // 必填项 | ||
124 | + nc.Required = domain.NodeRequiredNo | ||
123 | nodeContents = append(nodeContents, nc) | 125 | nodeContents = append(nodeContents, nc) |
124 | } | 126 | } |
125 | } | 127 | } |
-
请 注册 或 登录 后发表评论