作者 tangxvhui

Merge branch 'dev-tangxvhui' of http://gitlab.fjmaimaimai.com/allied-creation/pe…

…rformance into dev-tangxvhui
@@ -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:"文本内容提示"`
@@ -41,7 +46,8 @@ type NodeContent struct { @@ -41,7 +46,8 @@ type NodeContent struct {
41 PromptText string `json:"promptText" comment:"提示项正文"` 46 PromptText string `json:"promptText" comment:"提示项正文"`
42 EntryItems []*EntryItem `json:"entryItems" comment:"填写项"` 47 EntryItems []*EntryItem `json:"entryItems" comment:"填写项"`
43 Required int `json:"required" comment:"必填项"` 48 Required int `json:"required" comment:"必填项"`
44 - EvaluatorId int64 `json:"evaluatorId,string" comment:"项目评估人ID ( 0=无评估人、-1=HRBP )"` 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 {
@@ -28,6 +29,7 @@ type PerformanceModule struct { @@ -28,6 +29,7 @@ type PerformanceModule struct {
28 Target []*PerformanceTarget `json:"performanceTarget"` // 任务\指标 29 Target []*PerformanceTarget `json:"performanceTarget"` // 任务\指标
29 Required int `json:"required"` // 是否必填 30 Required int `json:"required"` // 是否必填
30 Evaluator string `json:"evaluator"` // 项目评估人 31 Evaluator string `json:"evaluator"` // 项目评估人
  32 + IndicatorType int `json:"indicatorType"` // 指标类型(任务 )
31 } 33 }
32 34
33 type PerformanceTarget struct { 35 type PerformanceTarget struct {
@@ -169,6 +171,11 @@ func loadPerformanceModule(forms []*PerformanceApplicationForm) ([]*PerformanceM @@ -169,6 +171,11 @@ 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, 180 ModuleName: moduleName,
174 Weight: weightName, 181 Weight: weightName,
@@ -176,6 +183,7 @@ func loadPerformanceModule(forms []*PerformanceApplicationForm) ([]*PerformanceM @@ -176,6 +183,7 @@ func loadPerformanceModule(forms []*PerformanceApplicationForm) ([]*PerformanceM
176 Target: tasks, 183 Target: tasks,
177 Required: required, 184 Required: required,
178 Evaluator: evaluator, 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 }
@@ -4,4 +4,3 @@ WHERE id IN (1720, 1721, 1708, 1723, 1724, 1711, 1712, 1727, 1728, 1715, 1730, 1 @@ -4,4 +4,3 @@ WHERE id IN (1720, 1721, 1708, 1723, 1724, 1711, 1712, 1727, 1728, 1715, 1730, 1
4 4
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 -  
  1 +
  2 +-- 增加指标分类字段, 默认0
  3 +ALTER TABLE public.evaluation_item_used ADD indicator_type int4 NOT NULL DEFAULT 0;