作者 郑周

1. 数据库新增 指标类型字段

2. 导入解析增加 指标类型字段
@@ -847,10 +847,9 @@ func (rs *EvaluationProjectService) generateEvaluationItemUsed(transactionContex @@ -847,10 +847,9 @@ func (rs *EvaluationProjectService) generateEvaluationItemUsed(transactionContex
847 Weight: v2.Weight, 847 Weight: v2.Weight,
848 Required: v2.Required, 848 Required: v2.Required,
849 EvaluatorId: int(v2.EvaluatorId), 849 EvaluatorId: int(v2.EvaluatorId),
  850 + IndicatorType: v2.IndicatorType,
850 CreatedAt: nowTime, 851 CreatedAt: nowTime,
851 UpdatedAt: nowTime, 852 UpdatedAt: nowTime,
852 - // RuleType: 0,  
853 - // Rule: *v2.Rule,  
854 } 853 }
855 if v2.Rule != nil { 854 if v2.Rule != nil {
856 item.RuleType = v2.Rule.Type 855 item.RuleType = v2.Rule.Type
@@ -22,6 +22,7 @@ type EvaluationItemUsed struct { @@ -22,6 +22,7 @@ type EvaluationItemUsed struct {
22 Weight float64 //"权重" 22 Weight float64 //"权重"
23 Required int //必填项 同 NodeContent.Required 23 Required int //必填项 同 NodeContent.Required
24 EvaluatorId int //项目评估人ID ( 0=无评估人、-1=HRBP、 >0 员工的id ) 24 EvaluatorId int //项目评估人ID ( 0=无评估人、-1=HRBP、 >0 员工的id )
  25 + IndicatorType int //指标类型
25 CreatedAt time.Time //数据创建时间 26 CreatedAt time.Time //数据创建时间
26 UpdatedAt time.Time //数据更新时间 27 UpdatedAt time.Time //数据更新时间
27 } 28 }
@@ -24,6 +24,11 @@ const ( @@ -24,6 +24,11 @@ const (
24 NodeRequiredNo int = 2 // 必填项-非必填 24 NodeRequiredNo int = 2 // 必填项-非必填
25 ) 25 )
26 26
  27 +const (
  28 + IndicatorTypeDef int = 0 // 指标类型-指标
  29 + IndicatorTypeTask int = 1 // 指标类型-任务
  30 +)
  31 +
27 type EntryItem struct { 32 type EntryItem struct {
28 Title string `json:"title" comment:"填写标题"` 33 Title string `json:"title" comment:"填写标题"`
29 HintText string `json:"hintText" comment:"文本内容提示"` 34 HintText string `json:"hintText" comment:"文本内容提示"`
@@ -32,16 +37,17 @@ type EntryItem struct { @@ -32,16 +37,17 @@ type EntryItem struct {
32 37
33 // NodeContent 评估内容 38 // NodeContent 评估内容
34 type NodeContent struct { 39 type NodeContent struct {
35 - Category string `json:"category" comment:"类别"`  
36 - Name string `json:"name" comment:"名称"`  
37 - RuleId int64 `json:"ruleId,string" comment:"评估规则ID"`  
38 - Rule *EvaluationRule `json:"rule" comment:"评估规则对象"`  
39 - Weight float64 `json:"weight" comment:"权重"`  
40 - PromptTitle string `json:"promptTitle" comment:"提示项标题"`  
41 - PromptText string `json:"promptText" comment:"提示项正文"`  
42 - EntryItems []*EntryItem `json:"entryItems" comment:"填写项"`  
43 - Required int `json:"required" comment:"必填项"`  
44 - EvaluatorId int64 `json:"evaluatorId,string" comment:"项目评估人ID ( 0=无评估人、-1=HRBP )"` 40 + Category string `json:"category" comment:"类别"`
  41 + Name string `json:"name" comment:"名称"`
  42 + RuleId int64 `json:"ruleId,string" comment:"评估规则ID"`
  43 + Rule *EvaluationRule `json:"rule" comment:"评估规则对象"`
  44 + Weight float64 `json:"weight" comment:"权重"`
  45 + PromptTitle string `json:"promptTitle" comment:"提示项标题"`
  46 + PromptText string `json:"promptText" comment:"提示项正文"`
  47 + EntryItems []*EntryItem `json:"entryItems" comment:"填写项"`
  48 + Required int `json:"required" comment:"必填项"`
  49 + EvaluatorId int64 `json:"evaluatorId,string" comment:"项目评估人ID ( 0=无评估人、-1=HRBP、评估人ID)"`
  50 + IndicatorType int `json:"IndicatorType" comment:"指标类型(0指标、1任务)"`
45 } 51 }
46 52
47 // LinkNode 评估流程、环节 53 // LinkNode 评估流程、环节
@@ -14,6 +14,7 @@ type PerformanceApplicationForm struct { @@ -14,6 +14,7 @@ type PerformanceApplicationForm struct {
14 Definition string // 定义 14 Definition string // 定义
15 Required string // 是否必填 是 否 15 Required string // 是否必填 是 否
16 Evaluator string // 项目评估人 16 Evaluator string // 项目评估人
  17 + IndicatorType string // 指标类型(任务 )
17 } 18 }
18 19
19 type PerformanceDimension struct { 20 type PerformanceDimension struct {
@@ -22,12 +23,13 @@ type PerformanceDimension struct { @@ -22,12 +23,13 @@ type PerformanceDimension struct {
22 } 23 }
23 24
24 type PerformanceModule struct { 25 type PerformanceModule struct {
25 - ModuleName string `json:"moduleName"` // 模块名称  
26 - Weight string `json:"weight"` // 权重  
27 - Standard string `json:"standard"` // 标准(结构化的成果描述)  
28 - Target []*PerformanceTarget `json:"performanceTarget"` // 任务\指标  
29 - Required int `json:"required"` // 是否必填  
30 - Evaluator string `json:"evaluator"` // 项目评估人 26 + ModuleName string `json:"moduleName"` // 模块名称
  27 + Weight string `json:"weight"` // 权重
  28 + Standard string `json:"standard"` // 标准(结构化的成果描述)
  29 + Target []*PerformanceTarget `json:"performanceTarget"` // 任务\指标
  30 + Required int `json:"required"` // 是否必填
  31 + Evaluator string `json:"evaluator"` // 项目评估人
  32 + IndicatorType int `json:"indicatorType"` // 指标类型(任务 )
31 } 33 }
32 34
33 type PerformanceTarget struct { 35 type PerformanceTarget struct {
@@ -169,13 +171,19 @@ func loadPerformanceModule(forms []*PerformanceApplicationForm) ([]*PerformanceM @@ -169,13 +171,19 @@ func loadPerformanceModule(forms []*PerformanceApplicationForm) ([]*PerformanceM
169 if err != nil { 171 if err != nil {
170 return modules, err 172 return modules, err
171 } 173 }
  174 + indicatorType, err := getIndicatorType(item)
  175 + if err != nil {
  176 + return modules, err
  177 + }
  178 +
172 module := &PerformanceModule{ 179 module := &PerformanceModule{
173 - ModuleName: moduleName,  
174 - Weight: weightName,  
175 - Standard: standardName,  
176 - Target: tasks,  
177 - Required: required,  
178 - Evaluator: evaluator, 180 + ModuleName: moduleName,
  181 + Weight: weightName,
  182 + Standard: standardName,
  183 + Target: tasks,
  184 + Required: required,
  185 + Evaluator: evaluator,
  186 + IndicatorType: indicatorType,
179 } 187 }
180 modules = append(modules, module) 188 modules = append(modules, module)
181 } 189 }
@@ -260,7 +268,7 @@ func getEvaluator(items []*PerformanceApplicationForm) (string, error) { @@ -260,7 +268,7 @@ func getEvaluator(items []*PerformanceApplicationForm) (string, error) {
260 prevName = item.Evaluator 268 prevName = item.Evaluator
261 } 269 }
262 if prevName != item.Evaluator { 270 if prevName != item.Evaluator {
263 - return "", errors.New(item.ModuleName + " 对应的项目评估人填不一致") 271 + return "", errors.New(item.ModuleName + " 对应的项目评估人填不一致")
264 } 272 }
265 } 273 }
266 if prevName == "/" { 274 if prevName == "/" {
@@ -269,6 +277,27 @@ func getEvaluator(items []*PerformanceApplicationForm) (string, error) { @@ -269,6 +277,27 @@ func getEvaluator(items []*PerformanceApplicationForm) (string, error) {
269 return prevName, nil 277 return prevName, nil
270 } 278 }
271 279
  280 +// 获取指标类型
  281 +func getIndicatorType(items []*PerformanceApplicationForm) (int, error) {
  282 + if len(items) <= 0 {
  283 + return IndicatorTypeDef, nil
  284 + }
  285 + var prevName string
  286 + for _, item := range items {
  287 + if prevName == "" {
  288 + prevName = item.IndicatorType
  289 + }
  290 + if prevName != item.IndicatorType {
  291 + return IndicatorTypeDef, errors.New(item.ModuleName + " 对应的指标类型填写不一致")
  292 + }
  293 + }
  294 + if prevName == "任务" {
  295 + return IndicatorTypeTask, nil
  296 + } else {
  297 + return IndicatorTypeDef, nil
  298 + }
  299 +}
  300 +
272 // 获取任务 301 // 获取任务
273 func getTasks(items []*PerformanceApplicationForm) ([]*PerformanceTarget, error) { 302 func getTasks(items []*PerformanceApplicationForm) ([]*PerformanceTarget, error) {
274 tasks := make([]*PerformanceTarget, 0) 303 tasks := make([]*PerformanceTarget, 0)
@@ -23,6 +23,7 @@ type EvaluationItemUsed struct { @@ -23,6 +23,7 @@ type EvaluationItemUsed struct {
23 RuleType int `pg:",use_zero"` //评估方式(0评级、1评分) 23 RuleType int `pg:",use_zero"` //评估方式(0评级、1评分)
24 Rule domain.EvaluationRule //评估的选项规则 24 Rule domain.EvaluationRule //评估的选项规则
25 EvaluatorId int // 项目评估人ID ( 0=无评估人、-1=HRBP ) 25 EvaluatorId int // 项目评估人ID ( 0=无评估人、-1=HRBP )
  26 + IndicatorType int `pg:",use_zero"` // 指标规则
26 Weight float64 `pg:",use_zero"` //"权重" 27 Weight float64 `pg:",use_zero"` //"权重"
27 Required int // 必填项 28 Required int // 必填项
28 CreatedAt time.Time //数据创建时间 29 CreatedAt time.Time //数据创建时间
@@ -37,6 +37,7 @@ func (repo *EvaluationItemUsedRepository) TransformToDomain(d *models.Evaluation @@ -37,6 +37,7 @@ func (repo *EvaluationItemUsedRepository) TransformToDomain(d *models.Evaluation
37 CreatedAt: d.CreatedAt, 37 CreatedAt: d.CreatedAt,
38 UpdatedAt: d.UpdatedAt, 38 UpdatedAt: d.UpdatedAt,
39 EvaluatorId: d.EvaluatorId, 39 EvaluatorId: d.EvaluatorId,
  40 + IndicatorType: d.IndicatorType,
40 } 41 }
41 } 42 }
42 43
@@ -58,6 +59,7 @@ func (repo *EvaluationItemUsedRepository) BatchInsert(items []*domain.Evaluation @@ -58,6 +59,7 @@ func (repo *EvaluationItemUsedRepository) BatchInsert(items []*domain.Evaluation
58 RuleType: v.RuleType, 59 RuleType: v.RuleType,
59 Rule: v.Rule, 60 Rule: v.Rule,
60 EvaluatorId: v.EvaluatorId, 61 EvaluatorId: v.EvaluatorId,
  62 + IndicatorType: v.IndicatorType,
61 Weight: v.Weight, 63 Weight: v.Weight,
62 Required: v.Required, 64 Required: v.Required,
63 CreatedAt: v.CreatedAt, 65 CreatedAt: v.CreatedAt,
@@ -162,6 +162,8 @@ func (controller *ImportController) parseTemplateNodeContent(data []*domain.Perf @@ -162,6 +162,8 @@ func (controller *ImportController) parseTemplateNodeContent(data []*domain.Perf
162 evaluatorMap[nc.Category+nc.Name] = module.Evaluator // k,v = (类别+名称, 项目评估人名称) 162 evaluatorMap[nc.Category+nc.Name] = module.Evaluator // k,v = (类别+名称, 项目评估人名称)
163 } 163 }
164 } 164 }
  165 + // 指标类型(0指标、1任务)
  166 + nc.IndicatorType = module.IndicatorType
165 167
166 nodeContents = append(nodeContents, nc) 168 nodeContents = append(nodeContents, nc)
167 } 169 }
@@ -5,3 +5,5 @@ WHERE id IN (1720, 1721, 1708, 1723, 1724, 1711, 1712, 1727, 1728, 1715, 1730, 1 @@ -5,3 +5,5 @@ WHERE id IN (1720, 1721, 1708, 1723, 1724, 1711, 1712, 1727, 1728, 1715, 1730, 1
5 DELETE FROM summary_evaluation_value 5 DELETE FROM summary_evaluation_value
6 WHERE id IN (2299, 2302, 2303, 2304, 2309, 2308, 2313, 2312, 2314, 2316, 2318, 2322, 2324, 2325); 6 WHERE id IN (2299, 2302, 2303, 2304, 2309, 2308, 2313, 2312, 2314, 2316, 2318, 2322, 2324, 2325);
7 7
  8 +-- 增加指标分类字段, 默认0
  9 +ALTER TABLE public.evaluation_item_used ADD indicator_type int4 NOT NULL DEFAULT 0;