1. 评估内容中,新增字段 项目主导人ID字段
2. excel文件解析 项目主导人名称->ID
正在显示
5 个修改的文件
包含
91 行增加
和
14 行删除
@@ -41,7 +41,7 @@ type NodeContent struct { | @@ -41,7 +41,7 @@ type NodeContent struct { | ||
41 | PromptText string `json:"promptText" comment:"提示项正文"` | 41 | PromptText string `json:"promptText" comment:"提示项正文"` |
42 | EntryItems []*EntryItem `json:"entryItems" comment:"填写项"` | 42 | EntryItems []*EntryItem `json:"entryItems" comment:"填写项"` |
43 | Required int `json:"required" comment:"必填项"` | 43 | Required int `json:"required" comment:"必填项"` |
44 | - LeaderId int64 `json:"leaderId,string" comment:"项目主导人"` | 44 | + EvaluatorId int64 `json:"evaluatorId,string" comment:"项目评估人ID ( 0=无评估人、-1=HRBP )"` |
45 | } | 45 | } |
46 | 46 | ||
47 | // LinkNode 评估流程、环节 | 47 | // LinkNode 评估流程、环节 |
@@ -6,26 +6,28 @@ import ( | @@ -6,26 +6,28 @@ import ( | ||
6 | ) | 6 | ) |
7 | 7 | ||
8 | type PerformanceApplicationForm struct { | 8 | type PerformanceApplicationForm struct { |
9 | - DimensionName string //维度名称 | ||
10 | - ModuleName string //模块名称 | ||
11 | - Weight string //权重 | ||
12 | - Standard string //标准 | ||
13 | - Task string //任务、指标 | ||
14 | - Definition string //定义 | 9 | + DimensionName string // 维度名称 |
10 | + ModuleName string // 模块名称 | ||
11 | + Weight string // 权重 | ||
12 | + Standard string // 标准 | ||
13 | + Task string // 任务、指标 | ||
14 | + Definition string // 定义 | ||
15 | Required string // 是否必填 是 否 | 15 | Required string // 是否必填 是 否 |
16 | + Evaluator string // 项目评估人 | ||
16 | } | 17 | } |
17 | 18 | ||
18 | type PerformanceDimension struct { | 19 | type PerformanceDimension struct { |
19 | - Name string `json:"name"` //维度名称 | ||
20 | - PerformanceModule []*PerformanceModule `json:"performanceModule"` //模块 | 20 | + Name string `json:"name"` // 维度名称 |
21 | + PerformanceModule []*PerformanceModule `json:"performanceModule"` // 模块 | ||
21 | } | 22 | } |
22 | 23 | ||
23 | type PerformanceModule struct { | 24 | type PerformanceModule struct { |
24 | - ModuleName string `json:"moduleName"` //模块名称 | ||
25 | - Weight string `json:"weight"` //权重 | ||
26 | - Standard string `json:"standard"` //标准(结构化的成果描述) | ||
27 | - Target []*PerformanceTarget `json:"performanceTarget"` //任务\指标 | 25 | + ModuleName string `json:"moduleName"` // 模块名称 |
26 | + Weight string `json:"weight"` // 权重 | ||
27 | + Standard string `json:"standard"` // 标准(结构化的成果描述) | ||
28 | + Target []*PerformanceTarget `json:"performanceTarget"` // 任务\指标 | ||
28 | Required int `json:"required"` // 是否必填 | 29 | Required int `json:"required"` // 是否必填 |
30 | + Evaluator string `json:"evaluator"` // 项目评估人 | ||
29 | } | 31 | } |
30 | 32 | ||
31 | type PerformanceTarget struct { | 33 | type PerformanceTarget struct { |
@@ -35,7 +37,7 @@ type PerformanceTarget struct { | @@ -35,7 +37,7 @@ type PerformanceTarget struct { | ||
35 | 37 | ||
36 | func LoadPerformanceDimensions(rows [][]string) ([]*PerformanceDimension, error) { | 38 | func LoadPerformanceDimensions(rows [][]string) ([]*PerformanceDimension, error) { |
37 | formRows := make([]*PerformanceApplicationForm, 0) | 39 | formRows := make([]*PerformanceApplicationForm, 0) |
38 | - var dimensionName, moduleName, taskName, weightName, standardName string | 40 | + var dimensionName, moduleName, taskName, weightName, standardName, evaluator string |
39 | required := "是" | 41 | required := "是" |
40 | for key, item := range rows { | 42 | for key, item := range rows { |
41 | if key < 3 { | 43 | if key < 3 { |
@@ -88,6 +90,13 @@ func LoadPerformanceDimensions(rows [][]string) ([]*PerformanceDimension, error) | @@ -88,6 +90,13 @@ func LoadPerformanceDimensions(rows [][]string) ([]*PerformanceDimension, error) | ||
88 | required = strings.TrimSpace(item[9]) | 90 | required = strings.TrimSpace(item[9]) |
89 | } | 91 | } |
90 | form.Required = required | 92 | form.Required = required |
93 | + | ||
94 | + // 项目评估人 | ||
95 | + if len(item) > 10 && item[10] != "" { | ||
96 | + evaluator = strings.TrimSpace(item[10]) | ||
97 | + } | ||
98 | + form.Evaluator = evaluator | ||
99 | + | ||
91 | formRows = append(formRows, form) | 100 | formRows = append(formRows, form) |
92 | } | 101 | } |
93 | dimensions := make([]*PerformanceDimension, 0) | 102 | dimensions := make([]*PerformanceDimension, 0) |
@@ -156,12 +165,17 @@ func loadPerformanceModule(forms []*PerformanceApplicationForm) ([]*PerformanceM | @@ -156,12 +165,17 @@ func loadPerformanceModule(forms []*PerformanceApplicationForm) ([]*PerformanceM | ||
156 | if err != nil { | 165 | if err != nil { |
157 | return modules, err | 166 | return modules, err |
158 | } | 167 | } |
168 | + evaluator, err := getEvaluator(item) | ||
169 | + if err != nil { | ||
170 | + return modules, err | ||
171 | + } | ||
159 | module := &PerformanceModule{ | 172 | module := &PerformanceModule{ |
160 | ModuleName: moduleName, | 173 | ModuleName: moduleName, |
161 | Weight: weightName, | 174 | Weight: weightName, |
162 | Standard: standardName, | 175 | Standard: standardName, |
163 | Target: tasks, | 176 | Target: tasks, |
164 | Required: required, | 177 | Required: required, |
178 | + Evaluator: evaluator, | ||
165 | } | 179 | } |
166 | modules = append(modules, module) | 180 | modules = append(modules, module) |
167 | } | 181 | } |
@@ -235,6 +249,23 @@ func getRequired(items []*PerformanceApplicationForm) (int, error) { | @@ -235,6 +249,23 @@ func getRequired(items []*PerformanceApplicationForm) (int, error) { | ||
235 | } | 249 | } |
236 | } | 250 | } |
237 | 251 | ||
252 | +// 获取项目评估人 | ||
253 | +func getEvaluator(items []*PerformanceApplicationForm) (string, error) { | ||
254 | + if len(items) <= 0 { | ||
255 | + return "", nil | ||
256 | + } | ||
257 | + var prevName string | ||
258 | + for _, item := range items { | ||
259 | + if prevName == "" { | ||
260 | + prevName = item.Evaluator | ||
261 | + } | ||
262 | + if prevName != item.Evaluator { | ||
263 | + return "", errors.New(item.ModuleName + " 对应的项目评估人填不一致") | ||
264 | + } | ||
265 | + } | ||
266 | + return prevName, nil | ||
267 | +} | ||
268 | + | ||
238 | // 获取任务 | 269 | // 获取任务 |
239 | func getTasks(items []*PerformanceApplicationForm) ([]*PerformanceTarget, error) { | 270 | func getTasks(items []*PerformanceApplicationForm) ([]*PerformanceTarget, error) { |
240 | tasks := make([]*PerformanceTarget, 0) | 271 | tasks := make([]*PerformanceTarget, 0) |
@@ -133,6 +133,9 @@ func (repo *UserRepository) Find(queryOptions map[string]interface{}) (int, []*d | @@ -133,6 +133,9 @@ func (repo *UserRepository) Find(queryOptions map[string]interface{}) (int, []*d | ||
133 | if v, ok := queryOptions["name"].(string); ok && len(v) > 0 { | 133 | if v, ok := queryOptions["name"].(string); ok && len(v) > 0 { |
134 | query.Where("name like ?", fmt.Sprintf("%%%v%%", v)) | 134 | query.Where("name like ?", fmt.Sprintf("%%%v%%", v)) |
135 | } | 135 | } |
136 | + if v, ok := queryOptions["names"]; ok { | ||
137 | + query.Where("name in(?)", pg.In(v)) | ||
138 | + } | ||
136 | if v, ok := queryOptions["offset"]; ok { | 139 | if v, ok := queryOptions["offset"]; ok { |
137 | if value, ok := v.(int); ok { | 140 | if value, ok := v.(int); ok { |
138 | query.Offset(value) | 141 | query.Offset(value) |
@@ -65,6 +65,8 @@ func (controller *ImportController) parseTemplateNodeContent(data []*domain.Perf | @@ -65,6 +65,8 @@ func (controller *ImportController) parseTemplateNodeContent(data []*domain.Perf | ||
65 | }() | 65 | }() |
66 | // 获取当前公司下的默认规则 | 66 | // 获取当前公司下的默认规则 |
67 | ua := middlewares.GetUser(controller.Ctx) | 67 | ua := middlewares.GetUser(controller.Ctx) |
68 | + | ||
69 | + // 系统默认规则确认 | ||
68 | ruleRepository := factory.CreateEvaluationRuleRepository(map[string]interface{}{"transactionContext": transactionContext}) | 70 | ruleRepository := factory.CreateEvaluationRuleRepository(map[string]interface{}{"transactionContext": transactionContext}) |
69 | _, rules, err := ruleRepository.Find(map[string]interface{}{"companyId": ua.CompanyId, "sysType": domain.EvaluationSysTypeSystem, "limit": 1}) | 71 | _, rules, err := ruleRepository.Find(map[string]interface{}{"companyId": ua.CompanyId, "sysType": domain.EvaluationSysTypeSystem, "limit": 1}) |
70 | if err != nil { | 72 | if err != nil { |
@@ -85,6 +87,10 @@ func (controller *ImportController) parseTemplateNodeContent(data []*domain.Perf | @@ -85,6 +87,10 @@ func (controller *ImportController) parseTemplateNodeContent(data []*domain.Perf | ||
85 | ruleId = rules[0].Id | 87 | ruleId = rules[0].Id |
86 | } | 88 | } |
87 | 89 | ||
90 | + // 评估内容主导人名称 | ||
91 | + evaluatorNames := make([]string, 0) | ||
92 | + evaluatorMap := map[string]string{} | ||
93 | + | ||
88 | for i := range data { | 94 | for i := range data { |
89 | dimension := data[i] | 95 | dimension := data[i] |
90 | for i2 := range dimension.PerformanceModule { | 96 | for i2 := range dimension.PerformanceModule { |
@@ -122,9 +128,46 @@ func (controller *ImportController) parseTemplateNodeContent(data []*domain.Perf | @@ -122,9 +128,46 @@ func (controller *ImportController) parseTemplateNodeContent(data []*domain.Perf | ||
122 | 128 | ||
123 | // 必填项 | 129 | // 必填项 |
124 | nc.Required = module.Required | 130 | nc.Required = module.Required |
131 | + // 项目评估人 | ||
132 | + if module.Evaluator == "HRBP" { | ||
133 | + nc.EvaluatorId = -1 | ||
134 | + } else { | ||
135 | + | ||
136 | + if len(module.Evaluator) > 0 { | ||
137 | + evaluatorNames = append(evaluatorNames, module.Evaluator) // 项目评估人名称数组 | ||
138 | + evaluatorMap[nc.Category+nc.Name] = module.Evaluator // k,v = (类别+名称, 项目评估人名称) | ||
139 | + } | ||
140 | + } | ||
141 | + | ||
125 | nodeContents = append(nodeContents, nc) | 142 | nodeContents = append(nodeContents, nc) |
126 | } | 143 | } |
127 | } | 144 | } |
128 | 145 | ||
146 | + if len(evaluatorNames) > 0 { | ||
147 | + userRepository := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
148 | + _, users, err := userRepository.Find(map[string]interface{}{"companyId": ua.CompanyId, "names": evaluatorNames}) | ||
149 | + if err != nil { | ||
150 | + return nodeContents | ||
151 | + } | ||
152 | + nameIdMap := map[string]int64{} | ||
153 | + for i := range users { | ||
154 | + nameIdMap[users[i].Name] = users[i].Id | ||
155 | + } | ||
156 | + | ||
157 | + // 名称 -> ID | ||
158 | + var nc *domain.NodeContent | ||
159 | + for i := range nodeContents { | ||
160 | + nc = nodeContents[i] | ||
161 | + if nc.EvaluatorId == -1 { // HRBP | ||
162 | + continue | ||
163 | + } | ||
164 | + if evaluatorName, ok := evaluatorMap[nc.Category+nc.Name]; ok { | ||
165 | + if userId, ok := nameIdMap[evaluatorName]; ok { | ||
166 | + nc.EvaluatorId = userId | ||
167 | + } | ||
168 | + } | ||
169 | + } | ||
170 | + } | ||
171 | + | ||
129 | return nodeContents | 172 | return nodeContents |
130 | } | 173 | } |
不能预览此文件类型
-
请 注册 或 登录 后发表评论