正在显示
54 个修改的文件
包含
1391 行增加
和
224 行删除
@@ -3,6 +3,7 @@ module gitlab.fjmaimaimai.com/allied-creation/performance | @@ -3,6 +3,7 @@ module gitlab.fjmaimaimai.com/allied-creation/performance | ||
3 | go 1.16 | 3 | go 1.16 |
4 | 4 | ||
5 | require ( | 5 | require ( |
6 | + github.com/Andrew-M-C/go.timeconv v0.4.0 | ||
6 | github.com/Shopify/sarama v1.25.0 | 7 | github.com/Shopify/sarama v1.25.0 |
7 | github.com/beego/beego/v2 v2.0.5 | 8 | github.com/beego/beego/v2 v2.0.5 |
8 | github.com/bwmarrin/snowflake v0.3.0 | 9 | github.com/bwmarrin/snowflake v0.3.0 |
@@ -31,6 +31,8 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl | @@ -31,6 +31,8 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl | ||
31 | cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= | 31 | cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= |
32 | cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= | 32 | cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= |
33 | dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= | 33 | dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= |
34 | +github.com/Andrew-M-C/go.timeconv v0.4.0 h1:jwSSP1Nru7Hh+XDxIy8Bt/a2kdjqW/xIKkLFhBc/bmA= | ||
35 | +github.com/Andrew-M-C/go.timeconv v0.4.0/go.mod h1:qKsoTE6tDyot1aOcAESJA5GBDxl3sns9YesrA8gBLVo= | ||
34 | github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= | 36 | github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= |
35 | github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= | 37 | github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= |
36 | github.com/Knetic/govaluate v3.0.0+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= | 38 | github.com/Knetic/govaluate v3.0.0+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= |
go_build_main_go
已删除
100755 → 0
不能预览此文件类型
@@ -2,11 +2,16 @@ package main | @@ -2,11 +2,16 @@ package main | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "github.com/beego/beego/v2/server/web" | 4 | "github.com/beego/beego/v2/server/web" |
5 | + service "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/node_task" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log" | ||
5 | _ "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego" | 7 | _ "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego" |
6 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/consumer" | 8 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/consumer" |
9 | + "time" | ||
7 | ) | 10 | ) |
8 | 11 | ||
9 | func main() { | 12 | func main() { |
13 | + startNodeTask() | ||
14 | + | ||
10 | // tree := web.PrintTree() | 15 | // tree := web.PrintTree() |
11 | // methods := tree["Data"].(web.M) | 16 | // methods := tree["Data"].(web.M) |
12 | // for k, v := range methods { | 17 | // for k, v := range methods { |
@@ -15,3 +20,17 @@ func main() { | @@ -15,3 +20,17 @@ func main() { | ||
15 | go consumer.Run() | 20 | go consumer.Run() |
16 | web.Run() | 21 | web.Run() |
17 | } | 22 | } |
23 | + | ||
24 | +// 定时任务-间隔发送评估环节 | ||
25 | +func startNodeTask() { | ||
26 | + go func() { | ||
27 | + nodeTaskService := service.NewNodeTaskService() | ||
28 | + for { | ||
29 | + timer := time.NewTimer(time.Second * 60) | ||
30 | + <-timer.C | ||
31 | + if err := nodeTaskService.SendEvaluationNode(); err != nil { | ||
32 | + log.Logger.Error(err.Error()) | ||
33 | + } | ||
34 | + } | ||
35 | + }() | ||
36 | +} |
@@ -2,15 +2,14 @@ package command | @@ -2,15 +2,14 @@ package command | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "github.com/beego/beego/v2/core/validation" | 4 | "github.com/beego/beego/v2/core/validation" |
5 | - "time" | ||
6 | ) | 5 | ) |
7 | 6 | ||
8 | type CreateCycleCommand struct { | 7 | type CreateCycleCommand struct { |
9 | CompanyId int64 `cname:"公司ID" json:"companyId"` | 8 | CompanyId int64 `cname:"公司ID" json:"companyId"` |
10 | CreatorId int64 `cname:"创建人ID" json:"creatorId"` | 9 | CreatorId int64 `cname:"创建人ID" json:"creatorId"` |
11 | Name string `cname:"周期名称" json:"name" valid:"Required"` | 10 | Name string `cname:"周期名称" json:"name" valid:"Required"` |
12 | - TimeStart *time.Time `cname:"起始时间" json:"timeStart"` | ||
13 | - TimeEnd *time.Time `cname:"截至时间" json:"timeEnd"` | 11 | + TimeStart string `cname:"起始时间" json:"timeStart"` |
12 | + TimeEnd string `cname:"截至时间" json:"timeEnd"` | ||
14 | KpiCycle int `cname:"考核周期" json:"kpiCycle" valid:"Required"` | 13 | KpiCycle int `cname:"考核周期" json:"kpiCycle" valid:"Required"` |
15 | TemplateIds []string `cname:"周期使用模板ID" json:"templateIds"` | 14 | TemplateIds []string `cname:"周期使用模板ID" json:"templateIds"` |
16 | } | 15 | } |
@@ -25,19 +24,24 @@ func (in *CreateCycleCommand) Valid(validation *validation.Validation) { | @@ -25,19 +24,24 @@ func (in *CreateCycleCommand) Valid(validation *validation.Validation) { | ||
25 | return | 24 | return |
26 | } | 25 | } |
27 | if len(in.Name) > 40 { | 26 | if len(in.Name) > 40 { |
28 | - validation.SetError("name", "角色名称最大长度40个字符") | 27 | + validation.SetError("name", "名称最大长度40个字符") |
29 | return | 28 | return |
30 | } | 29 | } |
31 | - if in.TimeStart == nil { | 30 | + if in.KpiCycle == 0 { |
31 | + validation.SetError("kpiCycle", "请选择考核周期") | ||
32 | + return | ||
33 | + } | ||
34 | + | ||
35 | + if len(in.TimeStart) == 0 { | ||
32 | validation.SetError("timeStart", "请选择考核周期的开始时间") | 36 | validation.SetError("timeStart", "请选择考核周期的开始时间") |
33 | return | 37 | return |
34 | } | 38 | } |
35 | - if in.TimeEnd == nil { | 39 | + if len(in.TimeEnd) == 0 { |
36 | validation.SetError("timeEnd", "请选择考核周期的结束时间") | 40 | validation.SetError("timeEnd", "请选择考核周期的结束时间") |
37 | return | 41 | return |
38 | } | 42 | } |
39 | if len(in.TemplateIds) == 0 { | 43 | if len(in.TemplateIds) == 0 { |
40 | - validation.SetError("templates", "请选择周期内使用的评估模板") | 44 | + validation.SetError("templates", "请添加评估模板") |
41 | return | 45 | return |
42 | } | 46 | } |
43 | } | 47 | } |
@@ -19,8 +19,7 @@ type CycleTemplateListCommand struct { | @@ -19,8 +19,7 @@ type CycleTemplateListCommand struct { | ||
19 | } | 19 | } |
20 | 20 | ||
21 | type CycleTemplateCommand struct { | 21 | type CycleTemplateCommand struct { |
22 | - CycleId int64 `cname:"周期ID" json:"cycleId,string" valid:"Required"` | ||
23 | - TemplateId int64 `cname:"模板ID" json:"templateId,string" valid:"Required"` | 22 | + Id int64 `cname:"模板ID" json:"id,string" valid:"Required"` |
24 | } | 23 | } |
25 | 24 | ||
26 | func (in *QueryCycleCommand) Valid(validation *validation.Validation) { | 25 | func (in *QueryCycleCommand) Valid(validation *validation.Validation) { |
@@ -2,15 +2,14 @@ package command | @@ -2,15 +2,14 @@ package command | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "github.com/beego/beego/v2/core/validation" | 4 | "github.com/beego/beego/v2/core/validation" |
5 | - "time" | ||
6 | ) | 5 | ) |
7 | 6 | ||
8 | type UpdateCycleCommand struct { | 7 | type UpdateCycleCommand struct { |
9 | CompanyId int64 `cname:"公司ID" json:"companyId"` | 8 | CompanyId int64 `cname:"公司ID" json:"companyId"` |
10 | Id int64 `cname:"周期ID" json:"id,string" valid:"Required"` | 9 | Id int64 `cname:"周期ID" json:"id,string" valid:"Required"` |
11 | Name string `cname:"周期名称" json:"name" valid:"Required"` | 10 | Name string `cname:"周期名称" json:"name" valid:"Required"` |
12 | - TimeStart *time.Time `cname:"起始时间" json:"timeStart"` | ||
13 | - TimeEnd *time.Time `cname:"截至时间" json:"timeEnd"` | 11 | + TimeStart string `cname:"起始时间" json:"timeStart"` |
12 | + TimeEnd string `cname:"截至时间" json:"timeEnd"` | ||
14 | KpiCycle int `cname:"考核周期(0日、1周、2月)" json:"kpiCycle" valid:"Required"` | 13 | KpiCycle int `cname:"考核周期(0日、1周、2月)" json:"kpiCycle" valid:"Required"` |
15 | TemplateIds []string `cname:"周期使用模板ID" json:"templateIds"` | 14 | TemplateIds []string `cname:"周期使用模板ID" json:"templateIds"` |
16 | } | 15 | } |
@@ -20,11 +19,11 @@ func (in *UpdateCycleCommand) Valid(validation *validation.Validation) { | @@ -20,11 +19,11 @@ func (in *UpdateCycleCommand) Valid(validation *validation.Validation) { | ||
20 | validation.SetError("name", "角色名称最大长度40个字符") | 19 | validation.SetError("name", "角色名称最大长度40个字符") |
21 | return | 20 | return |
22 | } | 21 | } |
23 | - if in.TimeStart == nil { | 22 | + if len(in.TimeStart) == 0 { |
24 | validation.SetError("timeStart", "请选择考核周期的开始时间") | 23 | validation.SetError("timeStart", "请选择考核周期的开始时间") |
25 | return | 24 | return |
26 | } | 25 | } |
27 | - if in.TimeEnd == nil { | 26 | + if len(in.TimeEnd) == 0 { |
28 | validation.SetError("timeEnd", "请选择考核周期的结束时间") | 27 | validation.SetError("timeEnd", "请选择考核周期的结束时间") |
29 | return | 28 | return |
30 | } | 29 | } |
@@ -8,6 +8,7 @@ import ( | @@ -8,6 +8,7 @@ import ( | ||
8 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" | 8 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" |
9 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | 9 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" |
10 | "strconv" | 10 | "strconv" |
11 | + "time" | ||
11 | ) | 12 | ) |
12 | 13 | ||
13 | type EvaluationCycleService struct { | 14 | type EvaluationCycleService struct { |
@@ -38,7 +39,7 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf | @@ -38,7 +39,7 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf | ||
38 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 39 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
39 | } | 40 | } |
40 | if count > 0 { | 41 | if count > 0 { |
41 | - return nil, application.ThrowError(application.BUSINESS_ERROR, "名称已存在") | 42 | + return nil, application.ThrowError(application.BUSINESS_ERROR, "已存在相同名称的周期") |
42 | } | 43 | } |
43 | 44 | ||
44 | _, templates, err := templateRepository.Find(map[string]interface{}{"companyId": in.CompanyId, "ids": in.TemplateIds}) | 45 | _, templates, err := templateRepository.Find(map[string]interface{}{"companyId": in.CompanyId, "ids": in.TemplateIds}) |
@@ -49,12 +50,21 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf | @@ -49,12 +50,21 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf | ||
49 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "模板不存在, 请重新选择") | 50 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "模板不存在, 请重新选择") |
50 | } | 51 | } |
51 | 52 | ||
53 | + start, err := time.ParseInLocation("2006-01-02 15:04:05", in.TimeStart, time.Local) | ||
54 | + if err != nil { | ||
55 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
56 | + } | ||
57 | + end, err := time.ParseInLocation("2006-01-02 15:04:05", in.TimeEnd, time.Local) | ||
58 | + if err != nil { | ||
59 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
60 | + } | ||
61 | + | ||
52 | // 生成新周期数据 | 62 | // 生成新周期数据 |
53 | newCycle := &domain.EvaluationCycle{ | 63 | newCycle := &domain.EvaluationCycle{ |
54 | Id: 0, | 64 | Id: 0, |
55 | Name: in.Name, | 65 | Name: in.Name, |
56 | - TimeStart: in.TimeStart, | ||
57 | - TimeEnd: in.TimeEnd, | 66 | + TimeStart: &start, |
67 | + TimeEnd: &end, | ||
58 | CompanyId: in.CompanyId, | 68 | CompanyId: in.CompanyId, |
59 | CreatorId: in.CreatorId, | 69 | CreatorId: in.CreatorId, |
60 | KpiCycle: in.KpiCycle, | 70 | KpiCycle: in.KpiCycle, |
@@ -65,19 +75,27 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf | @@ -65,19 +75,27 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf | ||
65 | } | 75 | } |
66 | 76 | ||
67 | // 获取所有模板中的规则对象数据 | 77 | // 获取所有模板中的规则对象数据 |
68 | - ruleIds := make([]int64, 0) | ||
69 | - ruleMap := map[int64]*domain.EvaluationRule{} | 78 | + ruleIdsMap := map[int64]int64{} |
70 | for i := range templates { | 79 | for i := range templates { |
71 | v := templates[i] | 80 | v := templates[i] |
72 | for j := range v.LinkNodes { | 81 | for j := range v.LinkNodes { |
73 | node := v.LinkNodes[j] | 82 | node := v.LinkNodes[j] |
74 | for k := range node.NodeContents { | 83 | for k := range node.NodeContents { |
75 | nodeContent := node.NodeContents[k] | 84 | nodeContent := node.NodeContents[k] |
76 | - ruleIds = append(ruleIds, nodeContent.RuleId) | 85 | + if nodeContent.RuleId != 0 { |
86 | + ruleIdsMap[nodeContent.RuleId] = nodeContent.RuleId | ||
87 | + } | ||
77 | } | 88 | } |
78 | } | 89 | } |
79 | } | 90 | } |
91 | + ruleIds := make([]int64, 0) | ||
92 | + for k := range ruleIdsMap { | ||
93 | + ruleIds = append(ruleIds, k) | ||
94 | + } | ||
95 | + | ||
80 | _, rules, err := ruleRepository.Find(map[string]interface{}{"ids": ruleIds, "companyId": in.CompanyId}) | 96 | _, rules, err := ruleRepository.Find(map[string]interface{}{"ids": ruleIds, "companyId": in.CompanyId}) |
97 | + | ||
98 | + ruleMap := map[int64]*domain.EvaluationRule{} | ||
81 | for i := range rules { | 99 | for i := range rules { |
82 | ruleMap[rules[i].Id] = rules[i] | 100 | ruleMap[rules[i].Id] = rules[i] |
83 | } | 101 | } |
@@ -202,9 +220,18 @@ func (rs *EvaluationCycleService) Update(in *command.UpdateCycleCommand) (interf | @@ -202,9 +220,18 @@ func (rs *EvaluationCycleService) Update(in *command.UpdateCycleCommand) (interf | ||
202 | } | 220 | } |
203 | } | 221 | } |
204 | 222 | ||
223 | + start, err := time.ParseInLocation("2006-01-02 15:04:05", in.TimeStart, time.Local) | ||
224 | + if err != nil { | ||
225 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
226 | + } | ||
227 | + end, err := time.ParseInLocation("2006-01-02 15:04:05", in.TimeEnd, time.Local) | ||
228 | + if err != nil { | ||
229 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
230 | + } | ||
231 | + | ||
205 | cycle.Name = in.Name | 232 | cycle.Name = in.Name |
206 | - cycle.TimeStart = in.TimeStart | ||
207 | - cycle.TimeEnd = in.TimeEnd | 233 | + cycle.TimeStart = &start |
234 | + cycle.TimeEnd = &end | ||
208 | cycle.KpiCycle = in.KpiCycle | 235 | cycle.KpiCycle = in.KpiCycle |
209 | cycle, err = cycleRepository.Insert(cycle) | 236 | cycle, err = cycleRepository.Insert(cycle) |
210 | if err != nil { | 237 | if err != nil { |
@@ -313,6 +340,10 @@ func (rs *EvaluationCycleService) List(in *command.QueryCycleCommand) (interface | @@ -313,6 +340,10 @@ func (rs *EvaluationCycleService) List(in *command.QueryCycleCommand) (interface | ||
313 | if err != nil { | 340 | if err != nil { |
314 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 341 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
315 | } | 342 | } |
343 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
344 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
345 | + } | ||
346 | + | ||
316 | return tool_funs.SimpleWrapGridMap(total, cycles), nil | 347 | return tool_funs.SimpleWrapGridMap(total, cycles), nil |
317 | } | 348 | } |
318 | 349 | ||
@@ -325,7 +356,7 @@ func (rs *EvaluationCycleService) StatisticCycleUser(in *command.StatisticCycleP | @@ -325,7 +356,7 @@ func (rs *EvaluationCycleService) StatisticCycleUser(in *command.StatisticCycleP | ||
325 | transactionContext.RollbackTransaction() | 356 | transactionContext.RollbackTransaction() |
326 | }() | 357 | }() |
327 | projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext}) | 358 | projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext}) |
328 | - _, projects, err := projectRepository.Find(tool_funs.SimpleStructToMap(in), "linkNodes") | 359 | + _, projects, err := projectRepository.Find(tool_funs.SimpleStructToMap(in), "template") |
329 | if err != nil { | 360 | if err != nil { |
330 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 361 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
331 | } | 362 | } |
@@ -339,8 +370,8 @@ func (rs *EvaluationCycleService) StatisticCycleUser(in *command.StatisticCycleP | @@ -339,8 +370,8 @@ func (rs *EvaluationCycleService) StatisticCycleUser(in *command.StatisticCycleP | ||
339 | userIdMap[userId] = userId | 370 | userIdMap[userId] = userId |
340 | } | 371 | } |
341 | } | 372 | } |
342 | - for _, v := range userIdMap { | ||
343 | - userIds = append(userIds, v) | 373 | + for k := range userIdMap { |
374 | + userIds = append(userIds, k) | ||
344 | } | 375 | } |
345 | 376 | ||
346 | userTotal := 0 | 377 | userTotal := 0 |
@@ -404,7 +435,7 @@ func (rs *EvaluationCycleService) CycleTemplate(in *command.CycleTemplateCommand | @@ -404,7 +435,7 @@ func (rs *EvaluationCycleService) CycleTemplate(in *command.CycleTemplateCommand | ||
404 | }() | 435 | }() |
405 | 436 | ||
406 | cycleTemplateRepository := factory.CreateEvaluationCycleTemplateRepository(map[string]interface{}{"transactionContext": transactionContext}) | 437 | cycleTemplateRepository := factory.CreateEvaluationCycleTemplateRepository(map[string]interface{}{"transactionContext": transactionContext}) |
407 | - cycleTemplate, err := cycleTemplateRepository.FindOne(map[string]interface{}{"id": in.TemplateId}) | 438 | + cycleTemplate, err := cycleTemplateRepository.FindOne(map[string]interface{}{"id": in.Id}) |
408 | if err != nil { | 439 | if err != nil { |
409 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 440 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
410 | } | 441 | } |
@@ -2,7 +2,6 @@ package command | @@ -2,7 +2,6 @@ package command | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "github.com/beego/beego/v2/core/validation" | 4 | "github.com/beego/beego/v2/core/validation" |
5 | - "time" | ||
6 | ) | 5 | ) |
7 | 6 | ||
8 | type UpdateProjectCommand struct { | 7 | type UpdateProjectCommand struct { |
@@ -22,10 +21,10 @@ type UpdateProjectTemplateCommand struct { | @@ -22,10 +21,10 @@ type UpdateProjectTemplateCommand struct { | ||
22 | Id int64 `cname:"项目ID" json:"id,string" valid:"Required"` | 21 | Id int64 `cname:"项目ID" json:"id,string" valid:"Required"` |
23 | TemplateId int64 `cname:"模板ID" json:"templateId,string"` | 22 | TemplateId int64 `cname:"模板ID" json:"templateId,string"` |
24 | Recipients []string `cname:"被评估人ID" json:"recipients"` | 23 | Recipients []string `cname:"被评估人ID" json:"recipients"` |
25 | - TimeStart *time.Time `cname:"自评起始时间" json:"timeStart" valid:"Required"` | ||
26 | - TimeEnd *time.Time `cname:"自评截止时间" json:"timeEnd" valid:"Required"` | 24 | + TimeStart string `cname:"自评起始时间" json:"timeStart" valid:"Required"` |
25 | + TimeEnd string `cname:"自评截止时间" json:"timeEnd" valid:"Required"` | ||
27 | KpiCycle int `cname:"评估周期" json:"kpiCycle" valid:"Required"` | 26 | KpiCycle int `cname:"评估周期" json:"kpiCycle" valid:"Required"` |
28 | - KpiResultStart *time.Time `cname:"绩效结果开始查看时间" json:"kpiResultStart"` | 27 | + KpiResultStart string `cname:"绩效结果开始查看时间" json:"kpiResultStart"` |
29 | Activate int `cname:"启动项目" json:"activate"` | 28 | Activate int `cname:"启动项目" json:"activate"` |
30 | } | 29 | } |
31 | 30 | ||
@@ -48,4 +47,13 @@ func (in *UpdateProjectTemplateCommand) Valid(validation *validation.Validation) | @@ -48,4 +47,13 @@ func (in *UpdateProjectTemplateCommand) Valid(validation *validation.Validation) | ||
48 | validation.SetError("recipients", "请添加被评估人") | 47 | validation.SetError("recipients", "请添加被评估人") |
49 | return | 48 | return |
50 | } | 49 | } |
50 | + if len(in.TimeStart) == 0 { | ||
51 | + validation.SetError("timeEnd", "请选择开始时间") | ||
52 | + return | ||
53 | + } | ||
54 | + if len(in.TimeEnd) == 0 { | ||
55 | + validation.SetError("timeEnd", "请选择结束时间") | ||
56 | + return | ||
57 | + } | ||
58 | + | ||
51 | } | 59 | } |
@@ -8,7 +8,9 @@ import ( | @@ -8,7 +8,9 @@ import ( | ||
8 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/evaluation_project/command" | 8 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/evaluation_project/command" |
9 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" | 9 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" |
10 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | 10 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" |
11 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/utils" | ||
11 | "strconv" | 12 | "strconv" |
13 | + "time" | ||
12 | ) | 14 | ) |
13 | 15 | ||
14 | type EvaluationProjectService struct { | 16 | type EvaluationProjectService struct { |
@@ -130,9 +132,15 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp | @@ -130,9 +132,15 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp | ||
130 | }() | 132 | }() |
131 | 133 | ||
132 | projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext}) | 134 | projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext}) |
135 | + cycleRepository := factory.CreateEvaluationCycleRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
133 | cycleTemplateRepository := factory.CreateEvaluationCycleTemplateRepository(map[string]interface{}{"transactionContext": transactionContext}) | 136 | cycleTemplateRepository := factory.CreateEvaluationCycleTemplateRepository(map[string]interface{}{"transactionContext": transactionContext}) |
134 | 137 | ||
135 | - _, projects, err := projectRepository.Find(map[string]interface{}{"companyId": in.CompanyId, "cycleId": in.CycleId}, "linkNodes") | 138 | + _, projects, err := projectRepository.Find(map[string]interface{}{"companyId": in.CompanyId, "cycleId": in.CycleId}, "template") |
139 | + if err != nil { | ||
140 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
141 | + } | ||
142 | + | ||
143 | + cycle, err := cycleRepository.FindOne(map[string]interface{}{"id": in.CycleId}) | ||
136 | if err != nil { | 144 | if err != nil { |
137 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 145 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
138 | } | 146 | } |
@@ -177,18 +185,42 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp | @@ -177,18 +185,42 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp | ||
177 | project.State = domain.ProjectStateEnable | 185 | project.State = domain.ProjectStateEnable |
178 | } | 186 | } |
179 | 187 | ||
188 | + start, err := time.ParseInLocation("2006-01-02 15:04:05", in.TimeStart, time.Local) | ||
189 | + if err != nil { | ||
190 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
191 | + } | ||
192 | + end, err := time.ParseInLocation("2006-01-02 15:04:05", in.TimeEnd, time.Local) | ||
193 | + if err != nil { | ||
194 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
195 | + } | ||
196 | + kpiStart, err := time.ParseInLocation("2006-01-02 15:04:05", in.KpiResultStart, time.Local) | ||
197 | + if err != nil { | ||
198 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
199 | + } | ||
200 | + | ||
201 | + minTime := time.Date(cycle.TimeStart.Year(), cycle.TimeStart.Month(), cycle.TimeStart.Day(), cycle.TimeStart.Hour(), cycle.TimeStart.Minute(), 0, 0, time.Local) | ||
202 | + maxTime := time.Date(cycle.TimeEnd.Year(), cycle.TimeEnd.Month(), cycle.TimeEnd.Day(), cycle.TimeEnd.Hour(), cycle.TimeEnd.Minute(), 0, 0, time.Local) | ||
203 | + | ||
204 | + if start.Before(minTime) { | ||
205 | + return nil, application.ThrowError(application.BUSINESS_ERROR, "评估起始时间不能超出周期起始时间") | ||
206 | + } | ||
207 | + | ||
208 | + if end.After(maxTime) { | ||
209 | + return nil, application.ThrowError(application.BUSINESS_ERROR, "评估截至时间不能超出周期截至时间") | ||
210 | + } | ||
211 | + | ||
180 | project.Recipients = in.Recipients | 212 | project.Recipients = in.Recipients |
181 | project.Template = cycleTemplate.Template | 213 | project.Template = cycleTemplate.Template |
182 | for i := range project.Template.LinkNodes { | 214 | for i := range project.Template.LinkNodes { |
183 | node := project.Template.LinkNodes[i] | 215 | node := project.Template.LinkNodes[i] |
184 | node.KpiCycle = in.KpiCycle // 设置周期 | 216 | node.KpiCycle = in.KpiCycle // 设置周期 |
185 | if node.Type == domain.LinkNodeViewResult { | 217 | if node.Type == domain.LinkNodeViewResult { |
186 | - if in.KpiResultStart != nil { | ||
187 | - node.TimeStart = in.KpiResultStart | 218 | + if len(in.KpiResultStart) > 0 { |
219 | + node.TimeStart = &kpiStart | ||
188 | } | 220 | } |
189 | } else { | 221 | } else { |
190 | - node.TimeStart = in.TimeStart | ||
191 | - node.TimeEnd = in.TimeEnd | 222 | + node.TimeStart = &start |
223 | + node.TimeEnd = &end | ||
192 | } | 224 | } |
193 | } | 225 | } |
194 | 226 | ||
@@ -271,7 +303,7 @@ func (rs *EvaluationProjectService) List(in *command.QueryProjectCommand) (inter | @@ -271,7 +303,7 @@ func (rs *EvaluationProjectService) List(in *command.QueryProjectCommand) (inter | ||
271 | }() | 303 | }() |
272 | 304 | ||
273 | projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext}) | 305 | projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext}) |
274 | - total, projects, err := projectRepository.Find(tool_funs.SimpleStructToMap(in), "linkNodes") | 306 | + total, projects, err := projectRepository.Find(tool_funs.SimpleStructToMap(in), "template") |
275 | if err != nil { | 307 | if err != nil { |
276 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 308 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
277 | } | 309 | } |
@@ -303,6 +335,8 @@ func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand) | @@ -303,6 +335,8 @@ func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand) | ||
303 | }() | 335 | }() |
304 | 336 | ||
305 | projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext}) | 337 | projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext}) |
338 | + //cycleRepository := factory.CreateEvaluationCycleRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
339 | + | ||
306 | project, err := projectRepository.FindOne(map[string]interface{}{"id": in.Id}) | 340 | project, err := projectRepository.FindOne(map[string]interface{}{"id": in.Id}) |
307 | if err != nil { | 341 | if err != nil { |
308 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 342 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
@@ -316,17 +350,96 @@ func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand) | @@ -316,17 +350,96 @@ func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand) | ||
316 | return nil, application.ThrowError(application.BUSINESS_ERROR, "请添加被评估人") | 350 | return nil, application.ThrowError(application.BUSINESS_ERROR, "请添加被评估人") |
317 | } | 351 | } |
318 | 352 | ||
353 | + //cycle, err := cycleRepository.FindOne(map[string]interface{}{"id": project.CycleId}) | ||
354 | + //if err != nil { | ||
355 | + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
356 | + //} | ||
357 | + //startMin := cycle.TimeStart | ||
358 | + //maxTime := cycle.TimeEnd | ||
359 | + | ||
319 | project.State = domain.TemplateStateEnable | 360 | project.State = domain.TemplateStateEnable |
320 | project, err = projectRepository.Insert(project) | 361 | project, err = projectRepository.Insert(project) |
321 | if err != nil { | 362 | if err != nil { |
322 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 363 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
323 | } | 364 | } |
365 | + | ||
366 | + taskRepository := factory.CreateNodeTaskRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
367 | + | ||
368 | + now := time.Now().Local() | ||
369 | + nowO := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local) // 当前时间0点0分0秒时刻 | ||
370 | + | ||
371 | + for i := range project.Template.LinkNodes { | ||
372 | + node := project.Template.LinkNodes[i] | ||
373 | + task := &domain.NodeTask{ | ||
374 | + Id: 0, | ||
375 | + CompanyId: project.CompanyId, | ||
376 | + CycleId: project.CycleId, | ||
377 | + ProjectId: project.Id, | ||
378 | + NodeId: node.Id, | ||
379 | + KpiCycle: node.KpiCycle, | ||
380 | + BeginAt: node.TimeStart, | ||
381 | + EndAt: node.TimeEnd, | ||
382 | + } | ||
383 | + // 在当前时间之前,则计算下一个周期时间 | ||
384 | + if node.TimeStart.Before(now) { | ||
385 | + nextTime := utils.NextTime(nowO, node.TimeStart, node.KpiCycle) | ||
386 | + task.NextSentAt = &nextTime | ||
387 | + } else { | ||
388 | + task.NextSentAt = node.TimeStart | ||
389 | + } | ||
390 | + // 如果超出截至时间,则周期置空 | ||
391 | + if task.NextSentAt.After(*node.TimeEnd) { | ||
392 | + task.NextSentAt = nil | ||
393 | + } | ||
394 | + | ||
395 | + task, err := taskRepository.Insert(task) | ||
396 | + if err != nil { | ||
397 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
398 | + } | ||
399 | + } | ||
400 | + | ||
324 | if err := transactionContext.CommitTransaction(); err != nil { | 401 | if err := transactionContext.CommitTransaction(); err != nil { |
325 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 402 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
326 | } | 403 | } |
327 | return project, nil | 404 | return project, nil |
328 | } | 405 | } |
329 | 406 | ||
407 | +// | ||
408 | +//// 0点时刻为标准计算 | ||
409 | +//func (rs *EvaluationProjectService) nextTime(now0 time.Time, start *time.Time, kpiCycle int) time.Time { | ||
410 | +// // 起始时间0点时刻 | ||
411 | +// start0 := time.Date(start.Year(), start.Month(), start.Day(), 0, 0, 0, 0, time.Local) | ||
412 | +// | ||
413 | +// var nextTime time.Time | ||
414 | +// switch kpiCycle { | ||
415 | +// case domain.KpiCycleDay: | ||
416 | +// nextTime = timeconv.AddDate(now0, 0, 0, 1) // 当前时间的下一天开始发送 | ||
417 | +// break | ||
418 | +// case domain.KpiCycleWeek: | ||
419 | +// offsetSeconds := int64(now0.Sub(start0).Seconds()) | ||
420 | +// offsetDay := offsetSeconds / (24 * 60 * 60) | ||
421 | +// cycleCount := int(offsetDay)/7 + 1 | ||
422 | +// nextTime = timeconv.AddDate(start0, 0, 0, cycleCount*7) | ||
423 | +// break | ||
424 | +// case domain.KpiCycleOneMonth: | ||
425 | +// nextTime = timeconv.AddDate(start0, 0, 1, 0) | ||
426 | +// break | ||
427 | +// case domain.KpiCycleTwoMonth: | ||
428 | +// nextTime = timeconv.AddDate(start0, 0, 2, 0) | ||
429 | +// break | ||
430 | +// case domain.KpiCycleThreeMonth: | ||
431 | +// nextTime = timeconv.AddDate(start0, 0, 3, 0) | ||
432 | +// break | ||
433 | +// case domain.KpiCycleSixMonth: | ||
434 | +// nextTime = timeconv.AddDate(start0, 0, 6, 0) | ||
435 | +// break | ||
436 | +// case domain.KpiCycleYear: | ||
437 | +// nextTime = timeconv.AddDate(start0, 1, 0, 0) | ||
438 | +// break | ||
439 | +// } | ||
440 | +// return nextTime | ||
441 | +//} | ||
442 | + | ||
330 | func (rs *EvaluationProjectService) Copy(in *command.CopyProjectCommand) (interface{}, error) { | 443 | func (rs *EvaluationProjectService) Copy(in *command.CopyProjectCommand) (interface{}, error) { |
331 | transactionContext, err := factory.ValidateStartTransaction(in) | 444 | transactionContext, err := factory.ValidateStartTransaction(in) |
332 | if err != nil { | 445 | if err != nil { |
@@ -371,7 +484,7 @@ func (rs *EvaluationProjectService) CheckRecipients(in *command.CheckRecipientCo | @@ -371,7 +484,7 @@ func (rs *EvaluationProjectService) CheckRecipients(in *command.CheckRecipientCo | ||
371 | 484 | ||
372 | projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext}) | 485 | projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext}) |
373 | 486 | ||
374 | - _, projects, err := projectRepository.Find(map[string]interface{}{"companyId": in.CompanyId, "cycleId": in.CycleId}, "linkNodes") | 487 | + _, projects, err := projectRepository.Find(map[string]interface{}{"companyId": in.CompanyId, "cycleId": in.CycleId}, "template") |
375 | if err != nil { | 488 | if err != nil { |
376 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 489 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
377 | } | 490 | } |
@@ -404,5 +517,5 @@ func (rs *EvaluationProjectService) CheckRecipients(in *command.CheckRecipientCo | @@ -404,5 +517,5 @@ func (rs *EvaluationProjectService) CheckRecipients(in *command.CheckRecipientCo | ||
404 | if err := transactionContext.CommitTransaction(); err != nil { | 517 | if err := transactionContext.CommitTransaction(); err != nil { |
405 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 518 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
406 | } | 519 | } |
407 | - return repeatNum, nil | 520 | + return map[string]interface{}{"repeatNum": repeatNum}, nil |
408 | } | 521 | } |
@@ -2,14 +2,13 @@ package command | @@ -2,14 +2,13 @@ package command | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "github.com/beego/beego/v2/core/validation" | 4 | "github.com/beego/beego/v2/core/validation" |
5 | - "time" | ||
6 | ) | 5 | ) |
7 | 6 | ||
8 | type QueryTemplateCommand struct { | 7 | type QueryTemplateCommand struct { |
9 | CompanyId int64 `cname:"公司ID" json:"companyId"` | 8 | CompanyId int64 `cname:"公司ID" json:"companyId"` |
10 | Name string `cname:"模板名称" json:"name"` | 9 | Name string `cname:"模板名称" json:"name"` |
11 | State int `cname:"模板状态" json:"state"` | 10 | State int `cname:"模板状态" json:"state"` |
12 | - CreatedAt *time.Time `cname:"创建时间" json:"createdAt"` | 11 | + CreatedAt string `cname:"创建时间" json:"createdAt"` |
13 | PageNumber int64 `cname:"分页页码" json:"pageNumber" valid:"Required"` | 12 | PageNumber int64 `cname:"分页页码" json:"pageNumber" valid:"Required"` |
14 | PageSize int64 `cname:"分页数量" json:"pageSize" valid:"Required"` | 13 | PageSize int64 `cname:"分页数量" json:"pageSize" valid:"Required"` |
15 | } | 14 | } |
@@ -11,6 +11,7 @@ type UpdateTemplateCommand struct { | @@ -11,6 +11,7 @@ type UpdateTemplateCommand struct { | ||
11 | Name string `cname:"模板名称" json:"name" valid:"Required"` | 11 | Name string `cname:"模板名称" json:"name" valid:"Required"` |
12 | Describe string `cname:"模板描述" json:"describe"` | 12 | Describe string `cname:"模板描述" json:"describe"` |
13 | LinkNodes []*domain.LinkNode `cname:"评估流程" json:"linkNodes"` | 13 | LinkNodes []*domain.LinkNode `cname:"评估流程" json:"linkNodes"` |
14 | + FinishConfig int `cname:"配置" json:"finishConfig"` | ||
14 | } | 15 | } |
15 | 16 | ||
16 | func (in *UpdateTemplateCommand) Valid(validation *validation.Validation) { | 17 | func (in *UpdateTemplateCommand) Valid(validation *validation.Validation) { |
@@ -125,6 +125,11 @@ func (rs *EvaluationTemplateService) Update(in *command.UpdateTemplateCommand) ( | @@ -125,6 +125,11 @@ func (rs *EvaluationTemplateService) Update(in *command.UpdateTemplateCommand) ( | ||
125 | template.Describe = in.Describe | 125 | template.Describe = in.Describe |
126 | template.LinkNodes = in.LinkNodes | 126 | template.LinkNodes = in.LinkNodes |
127 | 127 | ||
128 | + // 完成配置保存,更新状态 | ||
129 | + if in.FinishConfig == 1 && template.State == domain.TemplateStateWaitConfig { | ||
130 | + template.State = domain.TemplateStateWaitActive | ||
131 | + } | ||
132 | + | ||
128 | template, err = templateRepository.Insert(template) | 133 | template, err = templateRepository.Insert(template) |
129 | if err != nil { | 134 | if err != nil { |
130 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 135 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
@@ -190,7 +195,7 @@ func (rs *EvaluationTemplateService) List(in *command.QueryTemplateCommand) (int | @@ -190,7 +195,7 @@ func (rs *EvaluationTemplateService) List(in *command.QueryTemplateCommand) (int | ||
190 | }() | 195 | }() |
191 | 196 | ||
192 | queryOptions := tool_funs.SimpleStructToMap(in) | 197 | queryOptions := tool_funs.SimpleStructToMap(in) |
193 | - if in.CreatedAt == nil { | 198 | + if len(in.CreatedAt) == 0 { |
194 | delete(queryOptions, "createdAt") // 删除创建时间 | 199 | delete(queryOptions, "createdAt") // 删除创建时间 |
195 | } | 200 | } |
196 | 201 |
@@ -129,6 +129,14 @@ func CreateEvaluationProjectRepository(options map[string]interface{}) domain.Ev | @@ -129,6 +129,14 @@ func CreateEvaluationProjectRepository(options map[string]interface{}) domain.Ev | ||
129 | return repository.NewEvaluationProjectRepository(transactionContext) | 129 | return repository.NewEvaluationProjectRepository(transactionContext) |
130 | } | 130 | } |
131 | 131 | ||
132 | +func CreateNodeTaskRepository(options map[string]interface{}) domain.NodeTaskRepository { | ||
133 | + var transactionContext *pg.TransactionContext | ||
134 | + if value, ok := options["transactionContext"]; ok { | ||
135 | + transactionContext = value.(*pg.TransactionContext) | ||
136 | + } | ||
137 | + return repository.NewNodeTaskRepository(transactionContext) | ||
138 | +} | ||
139 | + | ||
132 | func CreateStaffAssessRepository(options map[string]interface{}) domain.StaffAssessRepository { | 140 | func CreateStaffAssessRepository(options map[string]interface{}) domain.StaffAssessRepository { |
133 | var transactionContext *pg.TransactionContext | 141 | var transactionContext *pg.TransactionContext |
134 | if value, ok := options["transactionContext"]; ok { | 142 | if value, ok := options["transactionContext"]; ok { |
1 | +package service | ||
2 | + | ||
3 | +import ( | ||
4 | + "github.com/linmadan/egglib-go/core/application" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/utils" | ||
8 | + "time" | ||
9 | +) | ||
10 | + | ||
11 | +type NodeTaskService struct { | ||
12 | +} | ||
13 | + | ||
14 | +func NewNodeTaskService() *NodeTaskService { | ||
15 | + newRoleService := &NodeTaskService{} | ||
16 | + return newRoleService | ||
17 | +} | ||
18 | + | ||
19 | +// SendEvaluationNode 发送评估环节 | ||
20 | +func (rs *NodeTaskService) SendEvaluationNode() error { | ||
21 | + transactionContext, err := factory.StartTransaction() | ||
22 | + if err != nil { | ||
23 | + return err | ||
24 | + } | ||
25 | + defer func() { | ||
26 | + transactionContext.RollbackTransaction() | ||
27 | + }() | ||
28 | + taskRepository := factory.CreateNodeTaskRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
29 | + projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
30 | + //cycleRepository := factory.CreateEvaluationCycleRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
31 | + | ||
32 | + tasks, err := taskRepository.Find(map[string]interface{}{"now": time.Now().Local()}) | ||
33 | + if err != nil { | ||
34 | + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
35 | + } | ||
36 | + | ||
37 | + //ttaffAssessRepository := factory.CreateStaffAssessTaskRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
38 | + // | ||
39 | + | ||
40 | + projectIdsMap := map[int64]*domain.EvaluationProject{} | ||
41 | + cycleIdsMap := map[int64]*domain.EvaluationCycle{} | ||
42 | + for i := range tasks { | ||
43 | + task := tasks[i] | ||
44 | + projectIdsMap[task.ProjectId] = nil | ||
45 | + cycleIdsMap[task.CycleId] = nil | ||
46 | + } | ||
47 | + projectIds := make([]int64, 0) | ||
48 | + cycleIds := make([]int64, 0) | ||
49 | + for k := range projectIdsMap { | ||
50 | + projectIds = append(projectIds, k) | ||
51 | + } | ||
52 | + for k := range cycleIdsMap { | ||
53 | + cycleIds = append(cycleIds, k) | ||
54 | + } | ||
55 | + | ||
56 | + _, projects, err := projectRepository.Find(map[string]interface{}{"ids": projectIds}) | ||
57 | + if err != nil { | ||
58 | + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
59 | + } | ||
60 | + //_, cycles, err := cycleRepository.Find(map[string]interface{}{"ids": cycleIds}) | ||
61 | + //if err != nil { | ||
62 | + // return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
63 | + //} | ||
64 | + | ||
65 | + for i := range projects { | ||
66 | + projectIdsMap[projects[i].Id] = projects[i] | ||
67 | + } | ||
68 | + | ||
69 | + //staffAssessService := service.NewStaffAssessServeice() | ||
70 | + | ||
71 | + for i := range tasks { | ||
72 | + task := tasks[i] | ||
73 | + | ||
74 | + //if project, ok := projectIdsMap[task.ProjectId]; ok { | ||
75 | + | ||
76 | + //csat := &command.CreateStaffAssessTask{ | ||
77 | + // CompanyId: project.CompanyId, | ||
78 | + // EvaluationProjectId: project.Id, | ||
79 | + // EvaluationProjectName: project.Name, | ||
80 | + // CycleId: project.CycleId, | ||
81 | + //} | ||
82 | + // | ||
83 | + //staffAssessService.CreateStaffAssessTask(csat) | ||
84 | + //} | ||
85 | + | ||
86 | + // 下一次发送时间 | ||
87 | + nextTime := utils.NextTimeInc(task.NextSentAt, task.KpiCycle) | ||
88 | + task.NextSentAt = &nextTime | ||
89 | + // 如果超出截至时间,则周期置空 | ||
90 | + if task.NextSentAt.After(*task.EndAt) { | ||
91 | + task.NextSentAt = nil | ||
92 | + } | ||
93 | + task, err := taskRepository.Insert(task) | ||
94 | + if err != nil { | ||
95 | + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
96 | + } | ||
97 | + } | ||
98 | + | ||
99 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
100 | + return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
101 | + } | ||
102 | + | ||
103 | + return nil | ||
104 | + | ||
105 | +} |
@@ -34,7 +34,7 @@ func (rs *RoleUserService) Create(in *command.UserRoleCreateCommand) (interface{ | @@ -34,7 +34,7 @@ func (rs *RoleUserService) Create(in *command.UserRoleCreateCommand) (interface{ | ||
34 | // int64Array = append(int64Array, int64Num) | 34 | // int64Array = append(int64Array, int64Num) |
35 | //} | 35 | //} |
36 | // 检测已存在的关联用户 | 36 | // 检测已存在的关联用户 |
37 | - _, rus, err := roleUserRepository.Find(map[string]interface{}{"roleId": in.RoleId, "companyId": in.CompanyId, "userIds": in.UserIds, "limit": 9999999}) | 37 | + _, rus, err := roleUserRepository.Find(map[string]interface{}{"roleId": in.RoleId, "companyId": in.CompanyId, "userIds": in.UserIds, "limit": int64(9999999)}) |
38 | if err != nil { | 38 | if err != nil { |
39 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 39 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
40 | } | 40 | } |
@@ -9,12 +9,14 @@ type AssessInfoResp struct { | @@ -9,12 +9,14 @@ type AssessInfoResp struct { | ||
9 | CycleName string `json:"cycleName"` //周期名称 | 9 | CycleName string `json:"cycleName"` //周期名称 |
10 | EvaluationProjectId int `json:"evaluationProjectId"` //项目id | 10 | EvaluationProjectId int `json:"evaluationProjectId"` //项目id |
11 | EvaluationProjectName string `json:"evaluationProjectName"` //项目名称 | 11 | EvaluationProjectName string `json:"evaluationProjectName"` //项目名称 |
12 | + LinkNodeId int `json:"linkNodeId"` | ||
13 | + LinkNodeName string `json:"linkNodeName"` | ||
12 | BeginTime string `json:"beginTime"` //开始时间 2006-01-02 15:04:05 | 14 | BeginTime string `json:"beginTime"` //开始时间 2006-01-02 15:04:05 |
13 | EndTime string `json:"endTime"` //结束时间 2006-01-02 15:04:05 | 15 | EndTime string `json:"endTime"` //结束时间 2006-01-02 15:04:05 |
14 | Status string `json:"status"` //完成状态 | 16 | Status string `json:"status"` //完成状态 |
15 | TargetUserId int `json:"targetUser"` //目标用户 | 17 | TargetUserId int `json:"targetUser"` //目标用户 |
16 | TargetUserName string `json:"targetUserName"` //目标用户名称 | 18 | TargetUserName string `json:"targetUserName"` //目标用户名称 |
17 | - CompanyId int `json:"companyId,string"` // | 19 | + CompanyId int `json:"companyId,string,"` // |
18 | CompanyName string `json:"companyName"` //公司名称 | 20 | CompanyName string `json:"companyName"` //公司名称 |
19 | SupperUser string `json:"superUser"` //目标用户的上级 | 21 | SupperUser string `json:"superUser"` //目标用户的上级 |
20 | DutyTime string `json:"dutyTime"` //入职时间 // | 22 | DutyTime string `json:"dutyTime"` //入职时间 // |
1 | package adapter | 1 | package adapter |
2 | 2 | ||
3 | type ListInviteUserAssessResp struct { | 3 | type ListInviteUserAssessResp struct { |
4 | - TableHeader []ListTableHeader | ||
5 | - List []map[string]string | ||
6 | - Total int | 4 | + LinkNodeName string `json:"linkNodeName"` |
5 | + LinkNodeId int `json:"linkNodeId"` | ||
6 | + LintNodeDesc string `json:"lintNodeDesc"` | ||
7 | + TableHeader []ListTableHeader `json:"tableHeader"` | ||
8 | + List []map[string]string `json:"list"` | ||
9 | + Total int `json:"total"` | ||
7 | } | 10 | } |
8 | type ListTableHeader struct { | 11 | type ListTableHeader struct { |
9 | - Key string | ||
10 | - Name string | 12 | + Key string `json:"key"` |
13 | + Name string `json:"name"` | ||
11 | } | 14 | } |
@@ -2,10 +2,12 @@ package adapter | @@ -2,10 +2,12 @@ package adapter | ||
2 | 2 | ||
3 | type ListSupperAssessResp struct { | 3 | type ListSupperAssessResp struct { |
4 | AssessId int `json:"assessId"` // | 4 | AssessId int `json:"assessId"` // |
5 | + UsrId int `json:"userId"` | ||
5 | UserName string `json:"userName"` //用户名称 | 6 | UserName string `json:"userName"` //用户名称 |
6 | EndTime string `json:"endTime"` //截止时间 | 7 | EndTime string `json:"endTime"` //截止时间 |
7 | - InviteTotal int `json:"inviteCompleted"` //邀请总数 | ||
8 | - InviteUncompleted int `json:"inviteUncompleted"` //邀请未完成 | 8 | + InviteTotal int `json:"inviteTota"` //邀请总数 |
9 | + InviteCompleted int `json:"inviteCompleted"` //邀请未完成 | ||
10 | + Status string `json:"status"` | ||
9 | Department string `json:"department"` //部门 | 11 | Department string `json:"department"` //部门 |
10 | Position string `json:"position"` //职位 | 12 | Position string `json:"position"` //职位 |
11 | DutyTime string `json:"dutyTime"` //入职时间 | 13 | DutyTime string `json:"dutyTime"` //入职时间 |
@@ -6,8 +6,8 @@ type CreateStaffAssessTask struct { | @@ -6,8 +6,8 @@ type CreateStaffAssessTask struct { | ||
6 | EvaluationProjectName string `json:"evaluationProjectName"` //项目名称 | 6 | EvaluationProjectName string `json:"evaluationProjectName"` //项目名称 |
7 | CycleId int64 `json:"cycleId"` //对应的周期id | 7 | CycleId int64 `json:"cycleId"` //对应的周期id |
8 | CycleName string `json:"cycleName"` //对应周期的名称 | 8 | CycleName string `json:"cycleName"` //对应周期的名称 |
9 | - BeginTime string `json:"beginTime"` //绩效考核开始时间 | ||
10 | - EndTime string `json:"endTime"` //绩效考核截止时间 | 9 | + BeginTime string `json:"beginTime"` //绩效考核开始时间 2006-01-02 15:04:05 |
10 | + EndTime string `json:"endTime"` //绩效考核截止时间 2006-01-02 15:04:05 | ||
11 | StepList []AssessTaskStep `json:"steps"` //考评的流程 | 11 | StepList []AssessTaskStep `json:"steps"` //考评的流程 |
12 | ExecutorId []int `json:"executorId"` //参与此次考评的人 | 12 | ExecutorId []int `json:"executorId"` //参与此次考评的人 |
13 | } | 13 | } |
1 | +package command | ||
2 | + | ||
3 | +//保存员工填写评估内容 | ||
4 | +type SaveAssessInfoCommand struct { | ||
5 | + AssessId int `json:"assessId"` | ||
6 | + AssessContent []AssesssContent `json:"assessContent"` | ||
7 | +} | ||
8 | + | ||
9 | +type AssesssContent struct { | ||
10 | + Category string `json:"category"` | ||
11 | + Name string `json:"name"` | ||
12 | + Value string `json:"value"` | ||
13 | + Remark []RemarkText `json:"remark"` | ||
14 | +} | ||
15 | + | ||
16 | +type RemarkText struct { | ||
17 | + Title string `json:"title"` | ||
18 | + RemarkText string `json:"remarkText"` | ||
19 | +} |
1 | +package query | ||
2 | + | ||
3 | +type ListSupperAssessQuery struct { | ||
4 | + PageNumber int `json:"pageNumber"` | ||
5 | + PageSize int `json:"pageSize"` | ||
6 | + UserName string `json:"userName"` //查询条件 员工的名称 | ||
7 | + CompanyId int `json:"companyId"` // | ||
8 | + ExecutorId int `json:"executorId"` //评估的执行人 | ||
9 | + AssessTaskId int `json:"assessTaskId"` //评估任务id | ||
10 | +} |
@@ -2,7 +2,7 @@ package query | @@ -2,7 +2,7 @@ package query | ||
2 | 2 | ||
3 | //获取员工自评填写详情 | 3 | //获取员工自评填写详情 |
4 | type AssessSelfInfoQuery struct { | 4 | type AssessSelfInfoQuery struct { |
5 | - AssessTaskId int `json:"assessTaskId"` //StaffAssess 的id | 5 | + AssessTaskId int `json:"assessTaskId"` //assessTaskId 的id |
6 | TargetUserId int `json:"targetUserId"` //被评估的人id | 6 | TargetUserId int `json:"targetUserId"` //被评估的人id |
7 | CompanyId int `json:"companyId"` //公司id | 7 | CompanyId int `json:"companyId"` //公司id |
8 | 8 |
1 | -package query | ||
2 | - | ||
3 | -type ListSupperAssessQuery struct { | ||
4 | - PageNumber int `json:"pageNumber"` | ||
5 | - PageSize int `json:"pageSize"` | ||
6 | - UserName string `json:"userName"` //查询条件 员工的名称 | ||
7 | - CompanyId int `json:"companyId"` // | ||
8 | - ExecutorId int `json:"executorId"` //评估的执行人 | ||
9 | - AssessTaskkId int `json:"assessTaskId"` //评估任务id | ||
10 | -} |
@@ -5,6 +5,6 @@ type ListInviteUserAssessQuery struct { | @@ -5,6 +5,6 @@ type ListInviteUserAssessQuery struct { | ||
5 | PageSize int `json:"pageSize"` | 5 | PageSize int `json:"pageSize"` |
6 | UserName string `json:"userName"` //查询条件 员工的名称 | 6 | UserName string `json:"userName"` //查询条件 员工的名称 |
7 | CompanyId int `json:"companyId"` // | 7 | CompanyId int `json:"companyId"` // |
8 | - ExecutorId int `json:"executorId"` //评估的执行人 | ||
9 | - AssessTaskkId int `json:"assessTaskId"` //评估任务id | 8 | + ExecutorId int `json:"executorId"` //评估的执行人,必填 |
9 | + AssessTaskId int `json:"assessTaskId"` //评估任务id 必填 | ||
10 | } | 10 | } |
@@ -12,6 +12,7 @@ import ( | @@ -12,6 +12,7 @@ import ( | ||
12 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/command" | 12 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/command" |
13 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/query" | 13 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/query" |
14 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | 14 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" |
15 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao" | ||
15 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log" | 16 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log" |
16 | ) | 17 | ) |
17 | 18 | ||
@@ -321,16 +322,15 @@ func (srv StaffAssessServeice) AssessSelfList(param *query.AssessSelfListQuery) | @@ -321,16 +322,15 @@ func (srv StaffAssessServeice) AssessSelfList(param *query.AssessSelfListQuery) | ||
321 | DutyTime: userData.CreatedAt.Local().Format("2006-01-02 15:04:05"), | 322 | DutyTime: userData.CreatedAt.Local().Format("2006-01-02 15:04:05"), |
322 | } | 323 | } |
323 | for _, v := range supperUserList { | 324 | for _, v := range supperUserList { |
324 | - userInfo.SupperUserName = userInfo.SupperUserName + v.Name + ";" | 325 | + userInfo.SupperUserName = userInfo.SupperUserName + v.Name + " " |
325 | } | 326 | } |
326 | result := tool_funs.SimpleWrapGridMap(int64(cnt), listData) | 327 | result := tool_funs.SimpleWrapGridMap(int64(cnt), listData) |
327 | result["userInfo"] = userInfo | 328 | result["userInfo"] = userInfo |
328 | return result, nil | 329 | return result, nil |
329 | } | 330 | } |
330 | 331 | ||
331 | -// 更具项目评估的配置,创建员工的评估任务 | 332 | +// 根据项目评估的配置,创建员工的评估任务 |
332 | func (srv StaffAssessServeice) CreateStaffAssessTask(param *command.CreateStaffAssessTask) (map[string]interface{}, error) { | 333 | func (srv StaffAssessServeice) CreateStaffAssessTask(param *command.CreateStaffAssessTask) (map[string]interface{}, error) { |
333 | - | ||
334 | transactionContext, err := factory.CreateTransactionContext(nil) | 334 | transactionContext, err := factory.CreateTransactionContext(nil) |
335 | if err != nil { | 335 | if err != nil { |
336 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 336 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
@@ -341,7 +341,9 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(param *command.CreateStaffA | @@ -341,7 +341,9 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(param *command.CreateStaffA | ||
341 | defer func() { | 341 | defer func() { |
342 | _ = transactionContext.RollbackTransaction() | 342 | _ = transactionContext.RollbackTransaction() |
343 | }() | 343 | }() |
344 | - | 344 | + assessTaskRepo := factory.CreateStaffAssessTaskRepository(map[string]interface{}{ |
345 | + "transactionContext": transactionContext, | ||
346 | + }) | ||
345 | taskBeginTime, err := time.ParseInLocation("2006-01-02 15:04:05", param.BeginTime, time.Local) | 347 | taskBeginTime, err := time.ParseInLocation("2006-01-02 15:04:05", param.BeginTime, time.Local) |
346 | if err != nil { | 348 | if err != nil { |
347 | return nil, application.ThrowError(application.ARG_ERROR, "任务开始时间填写错误,"+param.BeginTime) | 349 | return nil, application.ThrowError(application.ARG_ERROR, "任务开始时间填写错误,"+param.BeginTime) |
@@ -351,8 +353,22 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(param *command.CreateStaffA | @@ -351,8 +353,22 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(param *command.CreateStaffA | ||
351 | return nil, application.ThrowError(application.ARG_ERROR, "任务结束时间填写错误,"+param.EndTime) | 353 | return nil, application.ThrowError(application.ARG_ERROR, "任务结束时间填写错误,"+param.EndTime) |
352 | } | 354 | } |
353 | nowTime := time.Now() | 355 | nowTime := time.Now() |
356 | + var assessTaskData *domain.StaffAssessTask | ||
357 | + _, assassessTaskList, err := assessTaskRepo.Find(map[string]interface{}{ | ||
358 | + "evaluationProjectId": param.EvaluationProjectId, | ||
359 | + "beginDay": taskBeginTime.Local().Format("2006-01-02"), | ||
360 | + }) | ||
361 | + if err != nil { | ||
362 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询同日期已存在评估任务"+err.Error()) | ||
363 | + } | ||
364 | + // 获取旧数据 | ||
365 | + | ||
366 | + if len(assassessTaskList) > 0 { | ||
367 | + assessTaskData = assassessTaskList[0] | ||
368 | + assessTaskData.UpdatedAt = nowTime | ||
369 | + } else { | ||
354 | //建立评估任务 | 370 | //建立评估任务 |
355 | - assessTask := domain.StaffAssessTask{ | 371 | + assessTaskData = &domain.StaffAssessTask{ |
356 | Id: 0, | 372 | Id: 0, |
357 | CompanyId: param.CompanyId, | 373 | CompanyId: param.CompanyId, |
358 | EvaluationProjectId: param.EvaluationProjectId, | 374 | EvaluationProjectId: param.EvaluationProjectId, |
@@ -367,8 +383,15 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(param *command.CreateStaffA | @@ -367,8 +383,15 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(param *command.CreateStaffA | ||
367 | UpdatedAt: nowTime, | 383 | UpdatedAt: nowTime, |
368 | DeletedAt: nil, | 384 | DeletedAt: nil, |
369 | } | 385 | } |
386 | + } | ||
387 | + | ||
370 | //填充评估环节 | 388 | //填充评估环节 |
371 | for _, v := range param.StepList { | 389 | for _, v := range param.StepList { |
390 | + for _, vv := range assessTaskData.StepList { | ||
391 | + if vv.LinkNodeType == v.LinkNodeType { | ||
392 | + continue | ||
393 | + } | ||
394 | + } | ||
372 | stepBeginTime, err := time.ParseInLocation("2006-01-02 15:04:05", param.BeginTime, time.Local) | 395 | stepBeginTime, err := time.ParseInLocation("2006-01-02 15:04:05", param.BeginTime, time.Local) |
373 | if err != nil { | 396 | if err != nil { |
374 | return nil, application.ThrowError(application.ARG_ERROR, "评估环节开始时间填写错误,"+param.BeginTime) | 397 | return nil, application.ThrowError(application.ARG_ERROR, "评估环节开始时间填写错误,"+param.BeginTime) |
@@ -385,41 +408,56 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(param *command.CreateStaffA | @@ -385,41 +408,56 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(param *command.CreateStaffA | ||
385 | BeginTime: stepBeginTime, | 408 | BeginTime: stepBeginTime, |
386 | EndTime: stepEndTime, | 409 | EndTime: stepEndTime, |
387 | } | 410 | } |
388 | - assessTask.StepList = append(assessTask.StepList, step) | 411 | + assessTaskData.StepList = append(assessTaskData.StepList, step) |
389 | } | 412 | } |
390 | 413 | ||
391 | - assessTaskRepo := factory.CreateStaffAssessTaskRepository(map[string]interface{}{ | ||
392 | - "transactionContext": transactionContext, | ||
393 | - }) | ||
394 | - _, err = assessTaskRepo.Save(&assessTask) | ||
395 | - if err != nil { | ||
396 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存评估任务"+err.Error()) | ||
397 | - } | ||
398 | - | ||
399 | - assessList, err := srv.createStaffAssess(transactionContext, &assessTask) | 414 | + assessList, err := srv.createStaffAssess(transactionContext, assessTaskData) |
400 | if err != nil { | 415 | if err != nil { |
401 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "生成个人评估项"+err.Error()) | 416 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "生成个人评估项"+err.Error()) |
402 | } | 417 | } |
403 | 418 | ||
419 | + //评估的参与人 | ||
420 | + executorIds := []int{} | ||
421 | + executorIdMap := map[int]struct{}{} //过滤重复的用户 | ||
422 | + for _, v := range param.ExecutorId { | ||
423 | + if _, ok := executorIdMap[v]; ok { | ||
424 | + continue | ||
425 | + } | ||
426 | + executorIds = append(executorIds, v) | ||
427 | + } | ||
428 | + //过滤就数据 | ||
429 | + for _, v := range assessTaskData.ExecutorId { | ||
430 | + if _, ok := executorIdMap[v]; ok { | ||
431 | + continue | ||
432 | + } | ||
433 | + executorIds = append(executorIds, v) | ||
434 | + } | ||
404 | assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{ | 435 | assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{ |
405 | "transactionContext": transactionContext, | 436 | "transactionContext": transactionContext, |
406 | }) | 437 | }) |
438 | + assessTaskData.ExecutorId = executorIds | ||
439 | + _, err = assessTaskRepo.Save(assessTaskData) | ||
440 | + if err != nil { | ||
441 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存评估任务"+err.Error()) | ||
442 | + } | ||
407 | 443 | ||
408 | for i := range assessList { | 444 | for i := range assessList { |
445 | + assessList[i].StaffAssessTaskId = assessTaskData.Id | ||
409 | _, err = assessRepo.Save(&assessList[i]) | 446 | _, err = assessRepo.Save(&assessList[i]) |
410 | if err != nil { | 447 | if err != nil { |
411 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存个人评估项"+err.Error()) | 448 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存个人评估项"+err.Error()) |
412 | } | 449 | } |
413 | } | 450 | } |
451 | + | ||
414 | if err := transactionContext.CommitTransaction(); err != nil { | 452 | if err := transactionContext.CommitTransaction(); err != nil { |
415 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 453 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
416 | } | 454 | } |
417 | return map[string]interface{}{ | 455 | return map[string]interface{}{ |
418 | - "assessTaskId": assessTask.Id, | 456 | + "assessTaskId": assessTaskData.Id, |
419 | }, nil | 457 | }, nil |
420 | } | 458 | } |
421 | 459 | ||
422 | -// 添加自评节点任务 | 460 | +// 添加节点任务 |
423 | func (srv StaffAssessServeice) createStaffAssess(transactionContext application.TransactionContext, param *domain.StaffAssessTask) ([]domain.StaffAssess, error) { | 461 | func (srv StaffAssessServeice) createStaffAssess(transactionContext application.TransactionContext, param *domain.StaffAssessTask) ([]domain.StaffAssess, error) { |
424 | //评估的参与人 | 462 | //评估的参与人 |
425 | selfUserId := []int{} | 463 | selfUserId := []int{} |
@@ -540,13 +578,49 @@ func (srv StaffAssessServeice) createStaffAssessSupper( | @@ -540,13 +578,49 @@ func (srv StaffAssessServeice) createStaffAssessSupper( | ||
540 | assessTemp domain.StaffAssess, | 578 | assessTemp domain.StaffAssess, |
541 | userList []*domain.User, userDepartmentMap map[int64][]*domain.Department, | 579 | userList []*domain.User, userDepartmentMap map[int64][]*domain.Department, |
542 | ) ([]domain.StaffAssess, error) { | 580 | ) ([]domain.StaffAssess, error) { |
543 | - | 581 | + var assessList []domain.StaffAssess |
544 | // 获取员工的上级用户 | 582 | // 获取员工的上级用户 |
545 | - | ||
546 | - return nil, nil | 583 | + userRepo := factory.CreateUserRepository(map[string]interface{}{ |
584 | + "transactionContext": transactionContext, | ||
585 | + }) | ||
586 | + for _, v := range userList { | ||
587 | + departmentList, ok := userDepartmentMap[v.Id] | ||
588 | + if !ok { | ||
589 | + continue | ||
590 | + } | ||
591 | + for _, vv2 := range departmentList { | ||
592 | + if len(vv2.ChargeUserIds) == 0 { | ||
593 | + continue | ||
594 | + } | ||
595 | + _, chargeUserList, err := userRepo.Find(map[string]interface{}{ | ||
596 | + "ids": vv2.ChargeUserIds, | ||
597 | + "limit": 40, | ||
598 | + }) | ||
599 | + if err != nil { | ||
600 | + return nil, application.ThrowError(application.ARG_ERROR, "获取部门主管信息"+err.Error()) | ||
601 | + } | ||
602 | + for _, vvv3 := range chargeUserList { | ||
603 | + assessTemp.TargetDepartment = []domain.StaffDepartment{ | ||
604 | + {DepartmentId: int(vv2.Id), DepartmentName: vv2.Name}, | ||
605 | + } | ||
606 | + assessTemp.TargetUser = domain.StaffDesc{ | ||
607 | + UserId: int(v.Id), | ||
608 | + Account: v.Account, | ||
609 | + UserName: v.Name, | ||
610 | + } | ||
611 | + assessTemp.Executor = domain.StaffDesc{ | ||
612 | + UserId: int(vvv3.Id), | ||
613 | + Account: vvv3.Account, | ||
614 | + UserName: vvv3.Name, | ||
615 | + } | ||
616 | + assessList = append(assessList, assessTemp) | ||
617 | + } | ||
618 | + } | ||
619 | + } | ||
620 | + return assessList, nil | ||
547 | } | 621 | } |
548 | 622 | ||
549 | -// 获取某个员工360邀请的人员 | 623 | +// 获取某个员工360评估邀请的人员 |
550 | func (srv StaffAssessServeice) GetAssessInviteUser(param *query.GetAssessInviteUserQuery) (*adapter.AssessInviteUserResp, error) { | 624 | func (srv StaffAssessServeice) GetAssessInviteUser(param *query.GetAssessInviteUserQuery) (*adapter.AssessInviteUserResp, error) { |
551 | transactionContext, err := factory.CreateTransactionContext(nil) | 625 | transactionContext, err := factory.CreateTransactionContext(nil) |
552 | if err != nil { | 626 | if err != nil { |
@@ -877,14 +951,18 @@ func (srv StaffAssessServeice) GetAssessSelfInfo(param *query.AssessSelfInfoQuer | @@ -877,14 +951,18 @@ func (srv StaffAssessServeice) GetAssessSelfInfo(param *query.AssessSelfInfoQuer | ||
877 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error()) | 951 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error()) |
878 | } | 952 | } |
879 | } | 953 | } |
954 | + | ||
955 | + //获取员工描述 | ||
956 | + staffDesc, _ := srv.getStaffDescrip(transactionContext, int64(param.TargetUserId)) | ||
880 | if err := transactionContext.CommitTransaction(); err != nil { | 957 | if err := transactionContext.CommitTransaction(); err != nil { |
881 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 958 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
882 | } | 959 | } |
883 | - | ||
884 | result := adapter.AssessInfoResp{ | 960 | result := adapter.AssessInfoResp{ |
885 | AssessId: assessData.Id, | 961 | AssessId: assessData.Id, |
886 | CycleId: assessData.CycleId, | 962 | CycleId: assessData.CycleId, |
887 | CycleName: assessData.CycleName, | 963 | CycleName: assessData.CycleName, |
964 | + LinkNodeId: assessData.LinkNodeId, | ||
965 | + LinkNodeName: assessData.LinkNodeName, | ||
888 | EvaluationProjectId: assessData.EvaluationProjectId, | 966 | EvaluationProjectId: assessData.EvaluationProjectId, |
889 | EvaluationProjectName: assessData.EvaluationProjectName, | 967 | EvaluationProjectName: assessData.EvaluationProjectName, |
890 | BeginTime: assessData.BeginTime.Local().Format("2006-01-02 15:04:05"), | 968 | BeginTime: assessData.BeginTime.Local().Format("2006-01-02 15:04:05"), |
@@ -892,8 +970,17 @@ func (srv StaffAssessServeice) GetAssessSelfInfo(param *query.AssessSelfInfoQuer | @@ -892,8 +970,17 @@ func (srv StaffAssessServeice) GetAssessSelfInfo(param *query.AssessSelfInfoQuer | ||
892 | Status: string(assessData.Status), | 970 | Status: string(assessData.Status), |
893 | TargetUserId: assessData.TargetUser.UserId, | 971 | TargetUserId: assessData.TargetUser.UserId, |
894 | TargetUserName: assessData.TargetUser.UserName, | 972 | TargetUserName: assessData.TargetUser.UserName, |
973 | + CompanyId: assessData.CompanyId, | ||
974 | + CompanyName: "", | ||
975 | + SupperUser: "", | ||
976 | + DutyTime: "", | ||
895 | AssessContent: assessContentList, | 977 | AssessContent: assessContentList, |
896 | } | 978 | } |
979 | + if staffDesc != nil { | ||
980 | + result.CompanyName = staffDesc.CompanyName | ||
981 | + result.SupperUser = staffDesc.SupperUserName | ||
982 | + result.DutyTime = staffDesc.DutyTime | ||
983 | + } | ||
897 | return &result, nil | 984 | return &result, nil |
898 | } | 985 | } |
899 | 986 | ||
@@ -998,14 +1085,15 @@ func (srv StaffAssessServeice) SelectAssessInviteUser(param *query.SelectAssessI | @@ -998,14 +1085,15 @@ func (srv StaffAssessServeice) SelectAssessInviteUser(param *query.SelectAssessI | ||
998 | departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{ | 1085 | departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{ |
999 | "transactionContext": transactionContext, | 1086 | "transactionContext": transactionContext, |
1000 | }) | 1087 | }) |
1001 | - | ||
1002 | - _, targetUserDepartment, err := departmentRepo.Find(map[string]interface{}{ | 1088 | + var targetUserDepartment []*domain.Department |
1089 | + if len(targetUser.DepartmentId) > 0 { | ||
1090 | + _, targetUserDepartment, err = departmentRepo.Find(map[string]interface{}{ | ||
1003 | "ids": targetUser.DepartmentId, | 1091 | "ids": targetUser.DepartmentId, |
1004 | }) | 1092 | }) |
1005 | - | ||
1006 | if err != nil { | 1093 | if err != nil { |
1007 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取部门信息"+err.Error()) | 1094 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取部门信息"+err.Error()) |
1008 | } | 1095 | } |
1096 | + } | ||
1009 | //获取部门主管的id | 1097 | //获取部门主管的id |
1010 | targetUserCharge := map[int64]struct{}{} | 1098 | targetUserCharge := map[int64]struct{}{} |
1011 | for _, v := range targetUserDepartment { | 1099 | for _, v := range targetUserDepartment { |
@@ -1060,8 +1148,8 @@ func (srv StaffAssessServeice) SelectAssessInviteUser(param *query.SelectAssessI | @@ -1060,8 +1148,8 @@ func (srv StaffAssessServeice) SelectAssessInviteUser(param *query.SelectAssessI | ||
1060 | return tool_funs.SimpleWrapGridMap(int64(cnt), listData), nil | 1148 | return tool_funs.SimpleWrapGridMap(int64(cnt), listData), nil |
1061 | } | 1149 | } |
1062 | 1150 | ||
1063 | -// 获取我的360评估,用户列表和评估填写的值 | ||
1064 | -func (srv StaffAssessServeice) ListInviteUserAssess(param *query.ListInviteUserAssessQuery) ( | 1151 | +// 获取我要执行的的360评估,用户列表和评估填写的值 |
1152 | +func (srv StaffAssessServeice) ListExecutorInviteAssess(param *query.ListInviteUserAssessQuery) ( | ||
1065 | *adapter.ListInviteUserAssessResp, error) { | 1153 | *adapter.ListInviteUserAssessResp, error) { |
1066 | transactionContext, err := factory.CreateTransactionContext(nil) | 1154 | transactionContext, err := factory.CreateTransactionContext(nil) |
1067 | if err != nil { | 1155 | if err != nil { |
@@ -1077,49 +1165,140 @@ func (srv StaffAssessServeice) ListInviteUserAssess(param *query.ListInviteUserA | @@ -1077,49 +1165,140 @@ func (srv StaffAssessServeice) ListInviteUserAssess(param *query.ListInviteUserA | ||
1077 | assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{ | 1165 | assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{ |
1078 | "transactionContext": transactionContext, | 1166 | "transactionContext": transactionContext, |
1079 | }) | 1167 | }) |
1168 | + assessTaskRepo := factory.CreateStaffAssessTaskRepository(map[string]interface{}{ | ||
1169 | + "transactionContext": transactionContext, | ||
1170 | + }) | ||
1171 | + | ||
1080 | //获取 executorId 对应的360评估任务 用户 | 1172 | //获取 executorId 对应的360评估任务 用户 |
1081 | - cnt, assessList, err := assessRepo.Find(map[string]interface{}{ | ||
1082 | - "staffAssessTaskId": param.AssessTaskkId, | 1173 | + condition := map[string]interface{}{ |
1174 | + "staffAssessTaskId": param.AssessTaskId, | ||
1083 | "executorId": param.ExecutorId, | 1175 | "executorId": param.ExecutorId, |
1084 | "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)}, | 1176 | "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)}, |
1085 | - }) | 1177 | + "limit": 20, |
1178 | + } | ||
1179 | + if param.PageSize > 0 { | ||
1180 | + condition["limit"] = param.PageSize | ||
1181 | + } | ||
1182 | + offset := (param.PageNumber - 1) * param.PageSize | ||
1183 | + if offset > 0 { | ||
1184 | + condition["offset"] = offset | ||
1185 | + } | ||
1186 | + | ||
1187 | + cnt, assessList, err := assessRepo.Find(condition) | ||
1086 | if err != nil { | 1188 | if err != nil { |
1087 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 1189 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
1088 | } | 1190 | } |
1191 | + var assessContentList []*domain.StaffAssessContent | ||
1192 | + if len(assessList) > 0 { | ||
1193 | + //获取评估用的所有评估项 | ||
1194 | + assessContentList, err = srv.getAssessSelfInfoUncompleted(transactionContext, assessList[0]) | ||
1195 | + if err != nil { | ||
1196 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取评估任务"+err.Error()) | ||
1197 | + } | ||
1198 | + } | ||
1199 | + //可变的表格列 | ||
1200 | + changeableHeader := []adapter.ListTableHeader{} | ||
1201 | + //列名与字段对应 | ||
1202 | + keyMap := map[string]string{} | ||
1203 | + for i, v := range assessContentList { | ||
1204 | + name := fmt.Sprintf("%s-%s", v.Category, v.Name) | ||
1205 | + key := fmt.Sprintf("k%d", i) | ||
1206 | + keyMap[name] = key | ||
1207 | + changeableHeader = append(changeableHeader, adapter.ListTableHeader{ | ||
1208 | + Key: key, | ||
1209 | + Name: name, | ||
1210 | + }) | ||
1211 | + } | ||
1212 | + assessContentRepo := factory.CreateStaffAssessContentRepository(map[string]interface{}{ | ||
1213 | + "transactionContext": transactionContext, | ||
1214 | + }) | ||
1089 | // 获取已经填报的内容 | 1215 | // 获取已经填报的内容 |
1216 | + changeableRows := map[int]map[string]string{} | ||
1217 | + for _, v := range assessList { | ||
1218 | + _, contentList, err := assessContentRepo.Find(map[string]interface{}{ | ||
1219 | + "staffAssessId": v.Id, | ||
1220 | + }) | ||
1221 | + if err != nil { | ||
1222 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取评估内容"+err.Error()) | ||
1223 | + } | ||
1224 | + row := map[string]string{} | ||
1225 | + for _, vv := range contentList { | ||
1226 | + name := fmt.Sprintf("%s-%s", vv.Category, vv.Name) | ||
1227 | + if kk, ok := keyMap[name]; ok { | ||
1228 | + row[kk] = vv.Value | ||
1229 | + } | ||
1230 | + } | ||
1231 | + changeableRows[v.TargetUser.UserId] = row | ||
1232 | + } | ||
1233 | + | ||
1234 | + //获取360邀请评估完成情况 | ||
1235 | + //我评估别人,被邀请评估 | ||
1236 | + cnnt, _, err := assessRepo.Find(map[string]interface{}{ | ||
1237 | + "staffAssessTaskId": param.AssessTaskId, | ||
1238 | + "executorId": param.ExecutorId, | ||
1239 | + "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)}, | ||
1240 | + "status": domain.StaffAssessUncompleted, | ||
1241 | + }) | ||
1242 | + if err != nil { | ||
1243 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error()) | ||
1244 | + } | ||
1245 | + | ||
1246 | + assessTaskData, err := assessTaskRepo.FindOne(map[string]interface{}{ | ||
1247 | + "id": param.AssessTaskId, | ||
1248 | + }) | ||
1249 | + if err != nil { | ||
1250 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取评估任务"+err.Error()) | ||
1251 | + } | ||
1090 | if err := transactionContext.CommitTransaction(); err != nil { | 1252 | if err := transactionContext.CommitTransaction(); err != nil { |
1091 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 1253 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
1092 | } | 1254 | } |
1093 | 1255 | ||
1094 | - //TODO 评估填写数据行转列 | 1256 | + //评估填写数据行转列 |
1095 | tableHeader := []adapter.ListTableHeader{ | 1257 | tableHeader := []adapter.ListTableHeader{ |
1096 | {Key: "userName", Name: "姓名"}, | 1258 | {Key: "userName", Name: "姓名"}, |
1097 | {Key: "status", Name: "状态"}, | 1259 | {Key: "status", Name: "状态"}, |
1098 | {Key: "types", Name: "360°评估关系"}, | 1260 | {Key: "types", Name: "360°评估关系"}, |
1099 | {Key: "endTime", Name: "360°评估截止日期"}, | 1261 | {Key: "endTime", Name: "360°评估截止日期"}, |
1100 | } | 1262 | } |
1263 | + tableHeader = append(tableHeader, changeableHeader...) | ||
1101 | listData := []map[string]string{} | 1264 | listData := []map[string]string{} |
1102 | for _, v := range assessList { | 1265 | for _, v := range assessList { |
1103 | m := map[string]string{ | 1266 | m := map[string]string{ |
1104 | "userName": v.TargetUser.UserName, | 1267 | "userName": v.TargetUser.UserName, |
1268 | + "userId": strconv.Itoa(v.TargetUser.UserId), | ||
1105 | "status": string(v.Status), | 1269 | "status": string(v.Status), |
1106 | "types": string(v.Types), | 1270 | "types": string(v.Types), |
1107 | "endTime": v.EndTime.Local().Format("2006-01-02 15:04:05"), | 1271 | "endTime": v.EndTime.Local().Format("2006-01-02 15:04:05"), |
1272 | + "assessId": strconv.Itoa(v.Id), | ||
1273 | + } | ||
1274 | + if row, ok := changeableRows[v.TargetUser.UserId]; ok { | ||
1275 | + for k, v := range row { | ||
1276 | + m[k] = v | ||
1277 | + } | ||
1278 | + } else { | ||
1279 | + for _, v := range changeableHeader { | ||
1280 | + m[v.Key] = "" | ||
1281 | + } | ||
1108 | } | 1282 | } |
1109 | listData = append(listData, m) | 1283 | listData = append(listData, m) |
1110 | } | 1284 | } |
1111 | - _ = tableHeader | ||
1112 | - | ||
1113 | result := adapter.ListInviteUserAssessResp{ | 1285 | result := adapter.ListInviteUserAssessResp{ |
1114 | TableHeader: tableHeader, | 1286 | TableHeader: tableHeader, |
1115 | List: listData, | 1287 | List: listData, |
1116 | Total: cnt, | 1288 | Total: cnt, |
1117 | } | 1289 | } |
1290 | + for _, v := range assessTaskData.StepList { | ||
1291 | + if v.LinkNodeType == domain.LinkNodeAllAssessment { | ||
1292 | + result.LinkNodeId = v.LinkNodeId | ||
1293 | + result.LinkNodeName = v.LinkNodeName | ||
1294 | + result.LintNodeDesc = fmt.Sprintf("截止时间 %s 待评估%d人", v.EndTime.Local().Format("2006-01-02 15:04:05"), cnnt) | ||
1295 | + } | ||
1296 | + } | ||
1118 | return &result, nil | 1297 | return &result, nil |
1119 | } | 1298 | } |
1120 | 1299 | ||
1121 | -// 获取上级评估成员列表 | ||
1122 | -func (srv StaffAssessServeice) ListSupperAssess(param *query.ListSupperAssessQuery) (map[string]interface{}, error) { | 1300 | +// 获取我需要执行的上级评估成员列表 |
1301 | +func (srv StaffAssessServeice) ListExecutorSupperAssess(param *query.ListSupperAssessQuery) (map[string]interface{}, error) { | ||
1123 | transactionContext, err := factory.CreateTransactionContext(nil) | 1302 | transactionContext, err := factory.CreateTransactionContext(nil) |
1124 | if err != nil { | 1303 | if err != nil { |
1125 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 1304 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
@@ -1134,15 +1313,70 @@ func (srv StaffAssessServeice) ListSupperAssess(param *query.ListSupperAssessQue | @@ -1134,15 +1313,70 @@ func (srv StaffAssessServeice) ListSupperAssess(param *query.ListSupperAssessQue | ||
1134 | assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{ | 1313 | assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{ |
1135 | "transactionContext": transactionContext, | 1314 | "transactionContext": transactionContext, |
1136 | }) | 1315 | }) |
1137 | - //获取 executorId 对应的上级评估列表 | ||
1138 | - cnt, assessList, err := assessRepo.Find(map[string]interface{}{ | ||
1139 | - "staffAssessTaskId": param.AssessTaskkId, | 1316 | + |
1317 | + limit := 20 | ||
1318 | + if param.PageSize > 0 { | ||
1319 | + limit = param.PageSize | ||
1320 | + } | ||
1321 | + condition := map[string]interface{}{ | ||
1322 | + "staffAssessTaskId": param.AssessTaskId, | ||
1140 | "executorId": param.ExecutorId, | 1323 | "executorId": param.ExecutorId, |
1141 | "typesList": []string{string(domain.AssessSuper)}, | 1324 | "typesList": []string{string(domain.AssessSuper)}, |
1142 | - }) | 1325 | + "limit": limit, |
1326 | + "targetUserName": param.UserName, | ||
1327 | + } | ||
1328 | + offset := (param.PageNumber - 1) * param.PageSize | ||
1329 | + if offset > 0 { | ||
1330 | + condition["offset"] = offset | ||
1331 | + } | ||
1332 | + //获取 executorId 对应的上级评估列表 | ||
1333 | + cnt, assessList, err := assessRepo.Find(condition) | ||
1143 | if err != nil { | 1334 | if err != nil { |
1144 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 1335 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
1145 | } | 1336 | } |
1337 | + | ||
1338 | + userIds := []int{} | ||
1339 | + for _, v := range assessList { | ||
1340 | + userIds = append(userIds, v.TargetUser.UserId) | ||
1341 | + } | ||
1342 | + //获取员工信息 | ||
1343 | + userRepo := factory.CreateUserRepository(map[string]interface{}{ | ||
1344 | + "transactionContext": transactionContext, | ||
1345 | + }) | ||
1346 | + var targetUserList []*domain.User | ||
1347 | + if len(userIds) > 0 { | ||
1348 | + _, targetUserList, _ = userRepo.Find(map[string]interface{}{ | ||
1349 | + "ids": userIds, | ||
1350 | + }) | ||
1351 | + } | ||
1352 | + //获取职位信息 | ||
1353 | + positionRepo := factory.CreatePositionRepository(map[string]interface{}{ | ||
1354 | + "transactionContext": transactionContext, | ||
1355 | + }) | ||
1356 | + //获取员工的职位 | ||
1357 | + userPositionMap := map[int64][]*domain.Position{} | ||
1358 | + for _, v := range targetUserList { | ||
1359 | + if len(v.PositionId) == 0 { | ||
1360 | + continue | ||
1361 | + } | ||
1362 | + _, positionList, _ := positionRepo.Find(map[string]interface{}{ | ||
1363 | + "ids": v.PositionId, | ||
1364 | + }) | ||
1365 | + userPositionMap[v.Id] = positionList | ||
1366 | + } | ||
1367 | + | ||
1368 | + //获取员工邀请的人完成360评估的数量 | ||
1369 | + var inviteCompletedCount []dao.CountData | ||
1370 | + if len(userIds) > 0 { | ||
1371 | + d := dao.NewStaffAssessDao(map[string]interface{}{ | ||
1372 | + "transactionContext": transactionContext, | ||
1373 | + }) | ||
1374 | + inviteCompletedCount, err = d.CountInviteAssessByTargetUser(userIds, param.AssessTaskId) | ||
1375 | + if err != nil { | ||
1376 | + log.Logger.Error("获取员工邀请的人完成情况" + err.Error()) | ||
1377 | + } | ||
1378 | + } | ||
1379 | + | ||
1146 | if err := transactionContext.CommitTransaction(); err != nil { | 1380 | if err := transactionContext.CommitTransaction(); err != nil { |
1147 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 1381 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
1148 | } | 1382 | } |
@@ -1151,18 +1385,40 @@ func (srv StaffAssessServeice) ListSupperAssess(param *query.ListSupperAssessQue | @@ -1151,18 +1385,40 @@ func (srv StaffAssessServeice) ListSupperAssess(param *query.ListSupperAssessQue | ||
1151 | for _, v := range assessList { | 1385 | for _, v := range assessList { |
1152 | item := adapter.ListSupperAssessResp{ | 1386 | item := adapter.ListSupperAssessResp{ |
1153 | AssessId: v.Id, | 1387 | AssessId: v.Id, |
1388 | + UsrId: v.TargetUser.UserId, | ||
1154 | UserName: v.TargetUser.UserName, | 1389 | UserName: v.TargetUser.UserName, |
1155 | EndTime: v.EndTime.Local().Format("2006-01-02 15:04:05"), | 1390 | EndTime: v.EndTime.Local().Format("2006-01-02 15:04:05"), |
1156 | - InviteUncompleted: 0, | 1391 | + InviteCompleted: 0, |
1392 | + Status: string(v.Status), | ||
1157 | InviteTotal: 5, | 1393 | InviteTotal: 5, |
1158 | Department: "", | 1394 | Department: "", |
1159 | Position: "", | 1395 | Position: "", |
1160 | DutyTime: "", | 1396 | DutyTime: "", |
1161 | } | 1397 | } |
1162 | - | 1398 | + //填入部门 |
1163 | for _, vv := range v.TargetDepartment { | 1399 | for _, vv := range v.TargetDepartment { |
1164 | item.Department += vv.DepartmentName + " " | 1400 | item.Department += vv.DepartmentName + " " |
1165 | } | 1401 | } |
1402 | + for _, vv := range targetUserList { | ||
1403 | + if vv.Id != int64(v.TargetUser.UserId) { | ||
1404 | + continue | ||
1405 | + } | ||
1406 | + //填入入职时间 | ||
1407 | + item.DutyTime = vv.CreatedAt.Local().Format("2006-01-02 15:04:05") | ||
1408 | + //填入职位 | ||
1409 | + for _, vvv := range userPositionMap[vv.Id] { | ||
1410 | + item.Position += vvv.Name + " " | ||
1411 | + } | ||
1412 | + break | ||
1413 | + } | ||
1414 | + // | ||
1415 | + for _, vv := range inviteCompletedCount { | ||
1416 | + if v.TargetUser.UserId == vv.TargetUserId { | ||
1417 | + item.InviteCompleted = vv.InviteCompleted | ||
1418 | + item.InviteTotal = vv.InviteTotal | ||
1419 | + break | ||
1420 | + } | ||
1421 | + } | ||
1166 | resultList = append(resultList, item) | 1422 | resultList = append(resultList, item) |
1167 | } | 1423 | } |
1168 | return tool_funs.SimpleWrapGridMap(int64(cnt), resultList), nil | 1424 | return tool_funs.SimpleWrapGridMap(int64(cnt), resultList), nil |
@@ -1214,6 +1470,11 @@ func (srv StaffAssessServeice) GetAssessInfo(param *query.AssessInfoQuery) (*ada | @@ -1214,6 +1470,11 @@ func (srv StaffAssessServeice) GetAssessInfo(param *query.AssessInfoQuery) (*ada | ||
1214 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error()) | 1470 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error()) |
1215 | } | 1471 | } |
1216 | } | 1472 | } |
1473 | + | ||
1474 | + targetUserDesc, err := srv.getStaffDescrip(transactionContext, int64(assessData.TargetUser.UserId)) | ||
1475 | + if err != nil { | ||
1476 | + log.Logger.Error("获取员工描述" + err.Error()) | ||
1477 | + } | ||
1217 | if err := transactionContext.CommitTransaction(); err != nil { | 1478 | if err := transactionContext.CommitTransaction(); err != nil { |
1218 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 1479 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
1219 | } | 1480 | } |
@@ -1222,6 +1483,8 @@ func (srv StaffAssessServeice) GetAssessInfo(param *query.AssessInfoQuery) (*ada | @@ -1222,6 +1483,8 @@ func (srv StaffAssessServeice) GetAssessInfo(param *query.AssessInfoQuery) (*ada | ||
1222 | AssessId: assessData.Id, | 1483 | AssessId: assessData.Id, |
1223 | CycleId: assessData.CycleId, | 1484 | CycleId: assessData.CycleId, |
1224 | CycleName: assessData.CycleName, | 1485 | CycleName: assessData.CycleName, |
1486 | + LinkNodeId: assessData.LinkNodeId, | ||
1487 | + LinkNodeName: assessData.LinkNodeName, | ||
1225 | EvaluationProjectId: assessData.EvaluationProjectId, | 1488 | EvaluationProjectId: assessData.EvaluationProjectId, |
1226 | EvaluationProjectName: assessData.EvaluationProjectName, | 1489 | EvaluationProjectName: assessData.EvaluationProjectName, |
1227 | BeginTime: assessData.BeginTime.Local().Format("2006-01-02 15:04:05"), | 1490 | BeginTime: assessData.BeginTime.Local().Format("2006-01-02 15:04:05"), |
@@ -1229,13 +1492,192 @@ func (srv StaffAssessServeice) GetAssessInfo(param *query.AssessInfoQuery) (*ada | @@ -1229,13 +1492,192 @@ func (srv StaffAssessServeice) GetAssessInfo(param *query.AssessInfoQuery) (*ada | ||
1229 | Status: string(assessData.Status), | 1492 | Status: string(assessData.Status), |
1230 | TargetUserId: assessData.TargetUser.UserId, | 1493 | TargetUserId: assessData.TargetUser.UserId, |
1231 | TargetUserName: assessData.TargetUser.UserName, | 1494 | TargetUserName: assessData.TargetUser.UserName, |
1495 | + CompanyId: assessData.CompanyId, | ||
1496 | + CompanyName: "", | ||
1497 | + SupperUser: "", | ||
1498 | + DutyTime: "", | ||
1232 | AssessContent: assessContentList, | 1499 | AssessContent: assessContentList, |
1233 | } | 1500 | } |
1501 | + if len(assessContentList) == 0 { | ||
1502 | + result.AssessContent = []*domain.StaffAssessContent{} | ||
1503 | + } | ||
1504 | + if targetUserDesc != nil { | ||
1505 | + result.CompanyName = targetUserDesc.CompanyName | ||
1506 | + result.SupperUser = targetUserDesc.SupperUserName | ||
1507 | + result.DutyTime = targetUserDesc.DutyTime | ||
1508 | + } | ||
1234 | return &result, nil | 1509 | return &result, nil |
1235 | } | 1510 | } |
1236 | 1511 | ||
1237 | -// 获取员工的某次评估任务的360评估记录录 | ||
1238 | -// assessTaskId targetUserId | ||
1239 | -func (srv StaffAssessServeice) AssessInviteList() error { | ||
1240 | - return nil | 1512 | +// 获取员工信息描述 |
1513 | +func (srv *StaffAssessServeice) getStaffDescrip(transactionContext application.TransactionContext, userid int64) (*adapter.StaffInfo, error) { | ||
1514 | + //获取用户数据 | ||
1515 | + userRepo := factory.CreateUserRepository(map[string]interface{}{ | ||
1516 | + "transactionContext": transactionContext, | ||
1517 | + }) | ||
1518 | + userData, err := userRepo.FindOne(map[string]interface{}{ | ||
1519 | + "id": userid, | ||
1520 | + }) | ||
1521 | + if err != nil { | ||
1522 | + log.Logger.Error("获取用户信息," + err.Error()) | ||
1523 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取用户信息,"+err.Error()) | ||
1524 | + } | ||
1525 | + | ||
1526 | + //获取公司数据 | ||
1527 | + companyRep := factory.CreateCompanyRepository(map[string]interface{}{ | ||
1528 | + "transactionContext": transactionContext, | ||
1529 | + }) | ||
1530 | + companyData, err := companyRep.FindOne(map[string]interface{}{ | ||
1531 | + "id": userData.CompanyId, | ||
1532 | + }) | ||
1533 | + if err != nil { | ||
1534 | + log.Logger.Error("获取公司信息," + err.Error()) | ||
1535 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取公司信息,"+err.Error()) | ||
1536 | + } | ||
1537 | + departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{ | ||
1538 | + "transactionContext": transactionContext, | ||
1539 | + }) | ||
1540 | + var supperUserList []*domain.User | ||
1541 | + if len(userData.DepartmentId) > 0 { | ||
1542 | + _, departmentList, err := departmentRepo.Find(map[string]interface{}{ | ||
1543 | + "ids": userData.DepartmentId, | ||
1544 | + }) | ||
1545 | + if err != nil { | ||
1546 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取部门信息,"+err.Error()) | ||
1547 | + } | ||
1548 | + var chargeUserIds []int64 | ||
1549 | + for _, v := range departmentList { | ||
1550 | + chargeUserIds = append(chargeUserIds, v.ChargeUserIds...) | ||
1551 | + } | ||
1552 | + if len(chargeUserIds) > 0 { | ||
1553 | + _, supperUserList, err = userRepo.Find(map[string]interface{}{ | ||
1554 | + "ids": chargeUserIds, | ||
1555 | + }) | ||
1556 | + if err != nil { | ||
1557 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取员工上级信息,"+err.Error()) | ||
1558 | + } | ||
1559 | + } | ||
1560 | + } | ||
1561 | + userInfo := adapter.StaffInfo{ | ||
1562 | + UserName: userData.Name, | ||
1563 | + CompanyName: companyData.Name, | ||
1564 | + SupperUserName: "", | ||
1565 | + DutyTime: userData.CreatedAt.Local().Format("2006-01-02 15:04:05"), | ||
1566 | + } | ||
1567 | + for _, v := range supperUserList { | ||
1568 | + userInfo.SupperUserName = userInfo.SupperUserName + v.Name + " " | ||
1569 | + } | ||
1570 | + return &userInfo, nil | ||
1571 | +} | ||
1572 | + | ||
1573 | +// 提交评估数据 | ||
1574 | +func (srv StaffAssessServeice) SaveAssessInfo(param *command.SaveAssessInfoCommand) (map[string]interface{}, error) { | ||
1575 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
1576 | + if err != nil { | ||
1577 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
1578 | + } | ||
1579 | + if err := transactionContext.StartTransaction(); err != nil { | ||
1580 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
1581 | + } | ||
1582 | + defer func() { | ||
1583 | + _ = transactionContext.RollbackTransaction() | ||
1584 | + }() | ||
1585 | + assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{ | ||
1586 | + "transactionContext": transactionContext, | ||
1587 | + }) | ||
1588 | + //获取员工的评估 | ||
1589 | + assessData, err := assessReps.FindOne(map[string]interface{}{ | ||
1590 | + "id": param.AssessId, | ||
1591 | + }) | ||
1592 | + if err != nil { | ||
1593 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的评估"+err.Error()) | ||
1594 | + } | ||
1595 | + assessContentRepo := factory.CreateStaffAssessContentRepository(map[string]interface{}{ | ||
1596 | + "transactionContext": transactionContext, | ||
1597 | + }) | ||
1598 | + //待更新的评估填写信息 | ||
1599 | + assessContentList := []*domain.StaffAssessContent{} | ||
1600 | + if assessData.Status == domain.StaffAssessCompleted { | ||
1601 | + //已完成 | ||
1602 | + | ||
1603 | + _, assessContentList, err = assessContentRepo.Find(map[string]interface{}{ | ||
1604 | + "staffAssessId": assessData.Id, | ||
1605 | + }) | ||
1606 | + if err != nil { | ||
1607 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error()) | ||
1608 | + } | ||
1609 | + } else if assessData.Status == domain.StaffAssessUncompleted { | ||
1610 | + //未完成 | ||
1611 | + assessContentList, err = srv.getAssessSelfInfoUncompleted(transactionContext, assessData) | ||
1612 | + if err != nil { | ||
1613 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error()) | ||
1614 | + } | ||
1615 | + } | ||
1616 | + //处理提交上来的数据 | ||
1617 | + paramContentMap := map[string]command.AssesssContent{} | ||
1618 | + for i, v := range param.AssessContent { | ||
1619 | + key := fmt.Sprintf("%s-%s", v.Category, v.Name) | ||
1620 | + paramContentMap[key] = param.AssessContent[i] | ||
1621 | + } | ||
1622 | + //更新的评估填写信息 | ||
1623 | + for _, v := range assessContentList { | ||
1624 | + key := fmt.Sprintf("%s-%s", v.Category, v.Name) | ||
1625 | + item, ok := paramContentMap[key] | ||
1626 | + if !ok { | ||
1627 | + continue | ||
1628 | + } | ||
1629 | + v.Value = item.Value | ||
1630 | + for ii := range v.Remark { | ||
1631 | + for _, vvv := range item.Remark { | ||
1632 | + if v.Remark[ii].Title == vvv.Title { | ||
1633 | + v.Remark[ii].RemarkText = vvv.RemarkText | ||
1634 | + break | ||
1635 | + } | ||
1636 | + } | ||
1637 | + } | ||
1638 | + } | ||
1639 | + //保存信息 | ||
1640 | + for i := range assessContentList { | ||
1641 | + _, err = assessContentRepo.Save(assessContentList[i]) | ||
1642 | + if err != nil { | ||
1643 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存评估填写内容"+err.Error()) | ||
1644 | + } | ||
1645 | + } | ||
1646 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
1647 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
1648 | + } | ||
1649 | + return map[string]interface{}{ | ||
1650 | + "assessId": assessData.Id, | ||
1651 | + }, nil | ||
1652 | +} | ||
1653 | + | ||
1654 | +// 获取员工被评估的列表 | ||
1655 | +func (srv StaffAssessServeice) ListTargetUserAssess(param *query.ListTargetUserAssessQuery) (map[string]interface{}, error) { | ||
1656 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
1657 | + if err != nil { | ||
1658 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
1659 | + } | ||
1660 | + if err := transactionContext.StartTransaction(); err != nil { | ||
1661 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
1662 | + } | ||
1663 | + defer func() { | ||
1664 | + _ = transactionContext.RollbackTransaction() | ||
1665 | + }() | ||
1666 | + assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{ | ||
1667 | + "transactionContext": transactionContext, | ||
1668 | + }) | ||
1669 | + //获取员工的评估 | ||
1670 | + cnt, assessList, err := assessReps.Find(map[string]interface{}{ | ||
1671 | + "assessTaskId": param.AssessTaskId, | ||
1672 | + "companyId": param.CompanyId, | ||
1673 | + "targetUserId": param.TargetUserId, | ||
1674 | + }) | ||
1675 | + if err != nil { | ||
1676 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的评估"+err.Error()) | ||
1677 | + } | ||
1678 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
1679 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
1680 | + } | ||
1681 | + | ||
1682 | + return tool_funs.SimpleWrapGridMap(int64(cnt), assessList), nil | ||
1241 | } | 1683 | } |
@@ -60,8 +60,6 @@ type LinkNode struct { | @@ -60,8 +60,6 @@ type LinkNode struct { | ||
60 | TimeStart *time.Time `json:"timeStart" comment:"起始时间"` | 60 | TimeStart *time.Time `json:"timeStart" comment:"起始时间"` |
61 | TimeEnd *time.Time `json:"timeEnd" comment:"截至时间"` | 61 | TimeEnd *time.Time `json:"timeEnd" comment:"截至时间"` |
62 | KpiCycle int `json:"kpiCycle" comment:"考核周期(1日、2周、3月)"` | 62 | KpiCycle int `json:"kpiCycle" comment:"考核周期(1日、2周、3月)"` |
63 | - //NodeAllInvite *NodeAllInvite `json:"nodeAllInvite" comment:"360°邀请人员"` | ||
64 | - | ||
65 | } | 63 | } |
66 | 64 | ||
67 | // 评估模板 | 65 | // 评估模板 |
@@ -4,23 +4,24 @@ import ( | @@ -4,23 +4,24 @@ import ( | ||
4 | "time" | 4 | "time" |
5 | ) | 5 | ) |
6 | 6 | ||
7 | -type NodeTimerTask struct { | 7 | +type NodeTask struct { |
8 | Id int64 `json:"id,string" comment:"ID"` | 8 | Id int64 `json:"id,string" comment:"ID"` |
9 | CompanyId int64 `json:"companyId,string" comment:"公司ID"` | 9 | CompanyId int64 `json:"companyId,string" comment:"公司ID"` |
10 | CycleId int64 `json:"cycleId,string" comment:"周期ID"` | 10 | CycleId int64 `json:"cycleId,string" comment:"周期ID"` |
11 | ProjectId int64 `json:"projectId,string" comment:"项目ID"` | 11 | ProjectId int64 `json:"projectId,string" comment:"项目ID"` |
12 | NodeId int64 `json:"nodeId,string" comment:"节点ID"` | 12 | NodeId int64 `json:"nodeId,string" comment:"节点ID"` |
13 | - LastSentAt *time.Time `json:"lastSentAt" comment:"最后一次发送时间"` | 13 | + KpiCycle int `json:"kpiCycle" comment:"周期"` |
14 | + BeginAt *time.Time `json:"beginAt" comment:"起始时间"` | ||
15 | + EndAt *time.Time `json:"endAt" comment:"截至时间"` | ||
14 | NextSentAt *time.Time `json:"nextSentAt" comment:"下一次发送时间"` | 16 | NextSentAt *time.Time `json:"nextSentAt" comment:"下一次发送时间"` |
15 | CreatedAt time.Time `json:"createdAt" comment:"创建时间"` | 17 | CreatedAt time.Time `json:"createdAt" comment:"创建时间"` |
16 | UpdatedAt time.Time `json:"updatedAt" comment:"更新时间"` | 18 | UpdatedAt time.Time `json:"updatedAt" comment:"更新时间"` |
17 | DeletedAt *time.Time `json:"deletedAt" comment:"删除时间"` | 19 | DeletedAt *time.Time `json:"deletedAt" comment:"删除时间"` |
18 | } | 20 | } |
19 | 21 | ||
20 | -type NodeTimerTaskRepository interface { | ||
21 | - Insert(template *NodeTimerTask) (*NodeTimerTask, error) | ||
22 | - Remove(template *NodeTimerTask) (*NodeTimerTask, error) | ||
23 | - FindOne(queryOptions map[string]interface{}) (*NodeTimerTask, error) | ||
24 | - Find(queryOptions map[string]interface{}, excludeColumns ...string) (int64, []*NodeTimerTask, error) | ||
25 | - Count(queryOptions map[string]interface{}) (int64, error) | 22 | +type NodeTaskRepository interface { |
23 | + Insert(task *NodeTask) (*NodeTask, error) | ||
24 | + Remove(task *NodeTask) (*NodeTask, error) | ||
25 | + FindOne(queryOptions map[string]interface{}) (*NodeTask, error) | ||
26 | + Find(queryOptions map[string]interface{}) ([]*NodeTask, error) | ||
26 | } | 27 | } |
@@ -20,4 +20,5 @@ type PositionRepository interface { | @@ -20,4 +20,5 @@ type PositionRepository interface { | ||
20 | Update(position *Position) (*Position, error) | 20 | Update(position *Position) (*Position, error) |
21 | Remove(ids []int64) error | 21 | Remove(ids []int64) error |
22 | FindOne(queryOption map[string]interface{}) (*Position, error) | 22 | FindOne(queryOption map[string]interface{}) (*Position, error) |
23 | + Find(queryOptions map[string]interface{}) (int, []*Position, error) | ||
23 | } | 24 | } |
@@ -7,7 +7,7 @@ type StaffAssessType string | @@ -7,7 +7,7 @@ type StaffAssessType string | ||
7 | 7 | ||
8 | const ( | 8 | const ( |
9 | AssessSelf StaffAssessType = "self" //自评 | 9 | AssessSelf StaffAssessType = "self" //自评 |
10 | - AssessSuper StaffAssessType = "super" //上级评估 | 10 | + AssessSuper StaffAssessType = "supper" //上级评估 |
11 | AssessInviteSameSuper StaffAssessType = "invite_same_super" //360 邀请评估-相同上级的同事 | 11 | AssessInviteSameSuper StaffAssessType = "invite_same_super" //360 邀请评估-相同上级的同事 |
12 | AssessInviteDiffSuper StaffAssessType = "invite_diff_super" //360 邀请评估-不同上级的同事 | 12 | AssessInviteDiffSuper StaffAssessType = "invite_diff_super" //360 邀请评估-不同上级的同事 |
13 | ) | 13 | ) |
@@ -2,19 +2,6 @@ package domain | @@ -2,19 +2,6 @@ package domain | ||
2 | 2 | ||
3 | import "time" | 3 | import "time" |
4 | 4 | ||
5 | -//评估任务重复执行的方式 | ||
6 | -// type AssessTaskRepeatWay string | ||
7 | - | ||
8 | -// const ( | ||
9 | -// AssessTaskRepeatDay AssessTaskRepeatWay = "day" //按天重复 | ||
10 | -// AssessTaskRepeatWeek AssessTaskRepeatWay = "week" //按周重复 | ||
11 | -// AssessTaskRepeatMonth AssessTaskRepeatWay = "month" //按月 | ||
12 | -// AssessTaskRepeatMonthDouble AssessTaskRepeatWay = "month_double" //按双月 | ||
13 | -// AssessTaskRepeatQuarter AssessTaskRepeatWay = "quarter" //按季度 | ||
14 | -// AssessTaskRepeatYearHalf AssessTaskRepeatWay = "year_half" //按半年 | ||
15 | -// AssessTaskRepeatYear AssessTaskRepeatWay = "year" //按年 | ||
16 | -// ) | ||
17 | - | ||
18 | // 执行评估的任务列表 | 5 | // 执行评估的任务列表 |
19 | type StaffAssessTask struct { | 6 | type StaffAssessTask struct { |
20 | Id int `json:"id"` | 7 | Id int `json:"id"` |
@@ -23,6 +10,7 @@ type StaffAssessTask struct { | @@ -23,6 +10,7 @@ type StaffAssessTask struct { | ||
23 | EvaluationProjectName string `json:"evaluationProjectName"` //项目名称 | 10 | EvaluationProjectName string `json:"evaluationProjectName"` //项目名称 |
24 | CycleId int64 `json:"cycleId"` //对应的周期id | 11 | CycleId int64 `json:"cycleId"` //对应的周期id |
25 | CycleName string `json:"cycleName"` //对应周期的名称 | 12 | CycleName string `json:"cycleName"` //对应周期的名称 |
13 | + BeginDay string `json:"beginDay"` //绩效考核日期 | ||
26 | BeginTime time.Time `json:"beginTime"` //绩效考核开始时间 | 14 | BeginTime time.Time `json:"beginTime"` //绩效考核开始时间 |
27 | EndTime time.Time `json:"endTime"` //绩效考核截止时间 | 15 | EndTime time.Time `json:"endTime"` //绩效考核截止时间 |
28 | StepList []AssessTaskStep `json:"stepList"` //考评的流程 | 16 | StepList []AssessTaskStep `json:"stepList"` //考评的流程 |
@@ -12,3 +12,8 @@ type StaffDepartment struct { | @@ -12,3 +12,8 @@ type StaffDepartment struct { | ||
12 | DepartmentId int `json:"departmentId"` //部门id | 12 | DepartmentId int `json:"departmentId"` //部门id |
13 | DepartmentName string `json:"departmentName"` //部门名称 | 13 | DepartmentName string `json:"departmentName"` //部门名称 |
14 | } | 14 | } |
15 | + | ||
16 | +type StaffPosition struct { | ||
17 | + PositionId int `json:"positionId"` | ||
18 | + PositionName string `json:"positionName"` | ||
19 | +} |
pkg/infrastructure/dao/staff_assess_dao.go
0 → 100644
1 | +package dao | ||
2 | + | ||
3 | +import ( | ||
4 | + "strconv" | ||
5 | + | ||
6 | + "github.com/go-pg/pg/v10" | ||
7 | + pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | ||
8 | +) | ||
9 | + | ||
10 | +type StaffAssessDao struct { | ||
11 | + transactionContext *pgTransaction.TransactionContext | ||
12 | +} | ||
13 | + | ||
14 | +func NewStaffAssessDao(options map[string]interface{}) *StaffAssessDao { | ||
15 | + var transactionContext *pgTransaction.TransactionContext | ||
16 | + if value, ok := options["transactionContext"]; ok { | ||
17 | + transactionContext = value.(*pgTransaction.TransactionContext) | ||
18 | + } | ||
19 | + return &StaffAssessDao{ | ||
20 | + transactionContext: transactionContext, | ||
21 | + } | ||
22 | +} | ||
23 | + | ||
24 | +type CountData struct { | ||
25 | + TargetUserId int | ||
26 | + InviteTotal int | ||
27 | + InviteCompleted int | ||
28 | +} | ||
29 | + | ||
30 | +// 获取员工邀请的人完成360评估的数量 | ||
31 | +func (d *StaffAssessDao) CountInviteAssessByTargetUser(userIds []int, assessTaskId int) ([]CountData, error) { | ||
32 | + sqlStr := `SELECT staff_assess.target_user->>'userId' as target_user_id, | ||
33 | + count(staff_assess."id") AS invite_total, | ||
34 | + sum( | ||
35 | + case WHEN staff_assess.status='completed' THEN 1 | ||
36 | + ELSE 0 END | ||
37 | + ) as invite_completed | ||
38 | + FROM staff_assess | ||
39 | + WHERE staff_assess.target_user->>'userId' IN(?) | ||
40 | + AND staff_assess.types IN ('invite_same_super','invite_diff_super') | ||
41 | + AND staff_assess.staff_assess_task_id = ? | ||
42 | + GROUP BY userId` | ||
43 | + | ||
44 | + userIdList := []string{} | ||
45 | + for _, v := range userIds { | ||
46 | + uid := strconv.Itoa(v) | ||
47 | + userIdList = append(userIdList, uid) | ||
48 | + } | ||
49 | + condition := []interface{}{ | ||
50 | + pg.In(userIdList), assessTaskId, | ||
51 | + } | ||
52 | + tx := d.transactionContext.PgTx | ||
53 | + result := []CountData{} | ||
54 | + _, err := tx.Query(&result, sqlStr, condition...) | ||
55 | + return result, err | ||
56 | +} |
@@ -40,6 +40,7 @@ func init() { | @@ -40,6 +40,7 @@ func init() { | ||
40 | &models.EvaluationCycle{}, | 40 | &models.EvaluationCycle{}, |
41 | &models.EvaluationCycleTemplate{}, | 41 | &models.EvaluationCycleTemplate{}, |
42 | &models.EvaluationProject{}, | 42 | &models.EvaluationProject{}, |
43 | + &models.NodeTask{}, | ||
43 | &models.StaffAssess{}, | 44 | &models.StaffAssess{}, |
44 | &models.StaffAssessTask{}, | 45 | &models.StaffAssessTask{}, |
45 | &models.StaffAssessContent{}, | 46 | &models.StaffAssessContent{}, |
pkg/infrastructure/pg/models/node_task.go
0 → 100644
1 | +package models | ||
2 | + | ||
3 | +import ( | ||
4 | + "time" | ||
5 | +) | ||
6 | + | ||
7 | +type NodeTask struct { | ||
8 | + tableName struct{} `comment:"环节任务" pg:"node_task"` | ||
9 | + Id int64 `comment:"ID" pg:"pk:id"` | ||
10 | + CompanyId int64 `comment:"公司ID"` | ||
11 | + CycleId int64 `comment:"周期ID"` | ||
12 | + ProjectId int64 `comment:"项目ID"` | ||
13 | + NodeId int64 `comment:"环节ID"` | ||
14 | + KpiCycle int `comment:"周期"` | ||
15 | + BeginAt *time.Time `comment:"起始时间"` | ||
16 | + EndAt *time.Time `comment:"截止时间"` | ||
17 | + NextSentAt *time.Time `comment:"下一次发送时间"` | ||
18 | + CreatedAt time.Time `comment:"创建时间"` | ||
19 | + UpdatedAt time.Time `comment:"更新时间"` | ||
20 | + DeletedAt *time.Time `comment:"删除时间"` | ||
21 | +} |
@@ -17,6 +17,7 @@ type StaffAssessTask struct { | @@ -17,6 +17,7 @@ type StaffAssessTask struct { | ||
17 | CycleName string //对应周期的名称 | 17 | CycleName string //对应周期的名称 |
18 | ExecutorId []int //参与考评的人 | 18 | ExecutorId []int //参与考评的人 |
19 | StepList []domain.AssessTaskStep `` //考评的流程 | 19 | StepList []domain.AssessTaskStep `` //考评的流程 |
20 | + BeginDay string //日期 天 2006-01-02 | ||
20 | BeginTime time.Time //开始时间 | 21 | BeginTime time.Time //开始时间 |
21 | EndTime time.Time //截止时间 | 22 | EndTime time.Time //截止时间 |
22 | CreatedAt time.Time //数据创建时间 | 23 | CreatedAt time.Time //数据创建时间 |
@@ -119,7 +119,7 @@ func (repo *EvaluationCycleRepository) Find(queryOptions map[string]interface{}) | @@ -119,7 +119,7 @@ func (repo *EvaluationCycleRepository) Find(queryOptions map[string]interface{}) | ||
119 | 119 | ||
120 | query := tx.Model(&m).Where("deleted_at isnull") | 120 | query := tx.Model(&m).Where("deleted_at isnull") |
121 | 121 | ||
122 | - if v, ok := queryOptions["name"]; ok && len(v.(string)) > 0 { | 122 | + if v, ok := queryOptions["name"].(string); ok && len(v) > 0 { |
123 | query.Where("name LIKE ?", v) | 123 | query.Where("name LIKE ?", v) |
124 | } | 124 | } |
125 | 125 | ||
@@ -127,11 +127,11 @@ func (repo *EvaluationCycleRepository) Find(queryOptions map[string]interface{}) | @@ -127,11 +127,11 @@ func (repo *EvaluationCycleRepository) Find(queryOptions map[string]interface{}) | ||
127 | query.Where("company_id = ?", v) | 127 | query.Where("company_id = ?", v) |
128 | } | 128 | } |
129 | 129 | ||
130 | - if v, ok := queryOptions["limit"].(int); ok { | ||
131 | - query.Limit(v) | 130 | + if v, ok := queryOptions["limit"].(int64); ok { |
131 | + query.Limit(int(v)) | ||
132 | } | 132 | } |
133 | - if v, ok := queryOptions["offset"].(int); ok { | ||
134 | - query.Offset(v) | 133 | + if v, ok := queryOptions["offset"].(int64); ok { |
134 | + query.Offset(int(v)) | ||
135 | } | 135 | } |
136 | 136 | ||
137 | if v, ok := queryOptions["timeStart"]; ok { | 137 | if v, ok := queryOptions["timeStart"]; ok { |
@@ -170,7 +170,7 @@ func (repo *EvaluationCycleRepository) Count(queryOptions map[string]interface{} | @@ -170,7 +170,7 @@ func (repo *EvaluationCycleRepository) Count(queryOptions map[string]interface{} | ||
170 | query.Where("id != ?", notId) | 170 | query.Where("id != ?", notId) |
171 | } | 171 | } |
172 | 172 | ||
173 | - if v, ok := queryOptions["name"]; ok { | 173 | + if v, ok := queryOptions["name"].(string); ok && len(v) > 0 { |
174 | query.Where("name = ?", v) | 174 | query.Where("name = ?", v) |
175 | } | 175 | } |
176 | 176 |
@@ -153,11 +153,11 @@ func (repo *EvaluationCycleTemplateRepository) Find(queryOptions map[string]inte | @@ -153,11 +153,11 @@ func (repo *EvaluationCycleTemplateRepository) Find(queryOptions map[string]inte | ||
153 | query.Where("cycle_id = ?", v) | 153 | query.Where("cycle_id = ?", v) |
154 | } | 154 | } |
155 | 155 | ||
156 | - if v, ok := queryOptions["limit"].(int); ok { | ||
157 | - query.Limit(v) | 156 | + if v, ok := queryOptions["limit"].(int64); ok { |
157 | + query.Limit(int(v)) | ||
158 | } | 158 | } |
159 | - if v, ok := queryOptions["offset"].(int); ok { | ||
160 | - query.Offset(v) | 159 | + if v, ok := queryOptions["offset"].(int64); ok { |
160 | + query.Offset(int(v)) | ||
161 | } | 161 | } |
162 | 162 | ||
163 | count, err := query.SelectAndCount() | 163 | count, err := query.SelectAndCount() |
@@ -186,7 +186,7 @@ func (repo *EvaluationCycleTemplateRepository) Count(queryOptions map[string]int | @@ -186,7 +186,7 @@ func (repo *EvaluationCycleTemplateRepository) Count(queryOptions map[string]int | ||
186 | query.Where("id != ?", v) | 186 | query.Where("id != ?", v) |
187 | } | 187 | } |
188 | 188 | ||
189 | - if v, ok := queryOptions["name"]; ok { | 189 | + if v, ok := queryOptions["name"].(string); ok && len(v) > 0 { |
190 | query.Where("name = ?", v) | 190 | query.Where("name = ?", v) |
191 | } | 191 | } |
192 | 192 |
@@ -131,7 +131,7 @@ func (repo *EvaluationProjectRepository) Find(queryOptions map[string]interface{ | @@ -131,7 +131,7 @@ func (repo *EvaluationProjectRepository) Find(queryOptions map[string]interface{ | ||
131 | query.ExcludeColumn(excludeColumns...) | 131 | query.ExcludeColumn(excludeColumns...) |
132 | } | 132 | } |
133 | 133 | ||
134 | - if v, ok := queryOptions["name"]; ok { | 134 | + if v, ok := queryOptions["name"].(string); ok && len(v) > 0 { |
135 | query.Where("name = ?", v) | 135 | query.Where("name = ?", v) |
136 | } | 136 | } |
137 | 137 | ||
@@ -159,11 +159,11 @@ func (repo *EvaluationProjectRepository) Find(queryOptions map[string]interface{ | @@ -159,11 +159,11 @@ func (repo *EvaluationProjectRepository) Find(queryOptions map[string]interface{ | ||
159 | } | 159 | } |
160 | } | 160 | } |
161 | 161 | ||
162 | - if v, ok := queryOptions["limit"].(int); ok { | ||
163 | - query.Limit(v) | 162 | + if v, ok := queryOptions["limit"].(int64); ok { |
163 | + query.Limit(int(v)) | ||
164 | } | 164 | } |
165 | - if v, ok := queryOptions["offset"].(int); ok { | ||
166 | - query.Offset(v) | 165 | + if v, ok := queryOptions["offset"].(int64); ok { |
166 | + query.Offset(int(v)) | ||
167 | } | 167 | } |
168 | 168 | ||
169 | count, err := query.SelectAndCount() | 169 | count, err := query.SelectAndCount() |
@@ -192,7 +192,7 @@ func (repo *EvaluationProjectRepository) Count(queryOptions map[string]interface | @@ -192,7 +192,7 @@ func (repo *EvaluationProjectRepository) Count(queryOptions map[string]interface | ||
192 | query.Where("id != ?", v) | 192 | query.Where("id != ?", v) |
193 | } | 193 | } |
194 | 194 | ||
195 | - if v, ok := queryOptions["name"]; ok { | 195 | + if v, ok := queryOptions["name"].(string); ok && len(v) > 0 { |
196 | query.Where("name = ?", v) | 196 | query.Where("name = ?", v) |
197 | } | 197 | } |
198 | 198 |
@@ -127,7 +127,7 @@ func (repo *EvaluationRuleRepository) Find(queryOptions map[string]interface{}) | @@ -127,7 +127,7 @@ func (repo *EvaluationRuleRepository) Find(queryOptions map[string]interface{}) | ||
127 | query.Where("id in(?)", pg.In(v)) | 127 | query.Where("id in(?)", pg.In(v)) |
128 | } | 128 | } |
129 | 129 | ||
130 | - if v, ok := queryOptions["name"]; ok { | 130 | + if v, ok := queryOptions["name"].(string); ok && len(v) > 0 { |
131 | query.Where("name = ?", v) | 131 | query.Where("name = ?", v) |
132 | } | 132 | } |
133 | 133 | ||
@@ -143,11 +143,11 @@ func (repo *EvaluationRuleRepository) Find(queryOptions map[string]interface{}) | @@ -143,11 +143,11 @@ func (repo *EvaluationRuleRepository) Find(queryOptions map[string]interface{}) | ||
143 | query.Where("type = ?", v) | 143 | query.Where("type = ?", v) |
144 | } | 144 | } |
145 | 145 | ||
146 | - if v, ok := queryOptions["limit"].(int); ok { | ||
147 | - query.Limit(v) | 146 | + if v, ok := queryOptions["limit"].(int64); ok { |
147 | + query.Limit(int(v)) | ||
148 | } | 148 | } |
149 | - if v, ok := queryOptions["offset"].(int); ok { | ||
150 | - query.Offset(v) | 149 | + if v, ok := queryOptions["offset"].(int64); ok { |
150 | + query.Offset(int(v)) | ||
151 | } | 151 | } |
152 | 152 | ||
153 | count, err := query.SelectAndCount() | 153 | count, err := query.SelectAndCount() |
@@ -176,7 +176,7 @@ func (repo *EvaluationRuleRepository) Count(queryOptions map[string]interface{}) | @@ -176,7 +176,7 @@ func (repo *EvaluationRuleRepository) Count(queryOptions map[string]interface{}) | ||
176 | query.Where("id != ?", v) | 176 | query.Where("id != ?", v) |
177 | } | 177 | } |
178 | 178 | ||
179 | - if v, ok := queryOptions["name"]; ok { | 179 | + if v, ok := queryOptions["name"].(string); ok && len(v) > 0 { |
180 | query.Where("name = ?", v) | 180 | query.Where("name = ?", v) |
181 | } | 181 | } |
182 | 182 |
@@ -129,7 +129,7 @@ func (repo *EvaluationTemplateRepository) Find(queryOptions map[string]interface | @@ -129,7 +129,7 @@ func (repo *EvaluationTemplateRepository) Find(queryOptions map[string]interface | ||
129 | query.Where("id != ?", v) | 129 | query.Where("id != ?", v) |
130 | } | 130 | } |
131 | 131 | ||
132 | - if v, ok := queryOptions["name"]; ok && len(v.(string)) > 0 { | 132 | + if v, ok := queryOptions["name"].(string); ok && len(v) > 0 { |
133 | query.Where("name LIKE ?", v) | 133 | query.Where("name LIKE ?", v) |
134 | } | 134 | } |
135 | 135 | ||
@@ -142,19 +142,22 @@ func (repo *EvaluationTemplateRepository) Find(queryOptions map[string]interface | @@ -142,19 +142,22 @@ func (repo *EvaluationTemplateRepository) Find(queryOptions map[string]interface | ||
142 | } | 142 | } |
143 | 143 | ||
144 | if v, ok := queryOptions["createdAt"]; ok { | 144 | if v, ok := queryOptions["createdAt"]; ok { |
145 | - t := v.(*time.Time) | 145 | + ts := v.(string) |
146 | + t, err := time.ParseInLocation("2006-01-02", ts, time.Local) | ||
147 | + if err == nil { | ||
146 | year, month, day := t.Date() | 148 | year, month, day := t.Date() |
147 | begin := time.Date(year, month, day, 0, 0, 0, 0, time.Local) | 149 | begin := time.Date(year, month, day, 0, 0, 0, 0, time.Local) |
148 | end := time.Date(year, month, day, 23, 59, 59, 0, time.Local) | 150 | end := time.Date(year, month, day, 23, 59, 59, 0, time.Local) |
149 | query.Where("created_at >= ?", begin) | 151 | query.Where("created_at >= ?", begin) |
150 | query.Where("created_at <= ?", end) | 152 | query.Where("created_at <= ?", end) |
151 | } | 153 | } |
154 | + } | ||
152 | 155 | ||
153 | - if v, ok := queryOptions["limit"].(int); ok { | ||
154 | - query.Limit(v) | 156 | + if v, ok := queryOptions["limit"].(int64); ok { |
157 | + query.Limit(int(v)) | ||
155 | } | 158 | } |
156 | - if v, ok := queryOptions["offset"].(int); ok { | ||
157 | - query.Offset(v) | 159 | + if v, ok := queryOptions["offset"].(int64); ok { |
160 | + query.Offset(int(v)) | ||
158 | } | 161 | } |
159 | 162 | ||
160 | count, err := query.SelectAndCount() | 163 | count, err := query.SelectAndCount() |
@@ -183,7 +186,7 @@ func (repo *EvaluationTemplateRepository) Count(queryOptions map[string]interfac | @@ -183,7 +186,7 @@ func (repo *EvaluationTemplateRepository) Count(queryOptions map[string]interfac | ||
183 | query.Where("id != ?", v) | 186 | query.Where("id != ?", v) |
184 | } | 187 | } |
185 | 188 | ||
186 | - if v, ok := queryOptions["name"]; ok { | 189 | + if v, ok := queryOptions["name"].(string); ok && len(v) > 0 { |
187 | query.Where("name = ?", v) | 190 | query.Where("name = ?", v) |
188 | } | 191 | } |
189 | 192 |
1 | +package repository | ||
2 | + | ||
3 | +import ( | ||
4 | + "errors" | ||
5 | + "fmt" | ||
6 | + "github.com/go-pg/pg/v10" | ||
7 | + pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/pg/models" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/utils" | ||
11 | + "time" | ||
12 | +) | ||
13 | + | ||
14 | +type NodeTaskRepository struct { | ||
15 | + transactionContext *pgTransaction.TransactionContext | ||
16 | +} | ||
17 | + | ||
18 | +func NewNodeTaskRepository(transactionContext *pgTransaction.TransactionContext) *NodeTaskRepository { | ||
19 | + return &NodeTaskRepository{transactionContext: transactionContext} | ||
20 | +} | ||
21 | + | ||
22 | +func (repo *NodeTaskRepository) TransformToDomain(m *models.NodeTask) domain.NodeTask { | ||
23 | + return domain.NodeTask{ | ||
24 | + Id: m.Id, | ||
25 | + CompanyId: m.CompanyId, | ||
26 | + CycleId: m.CycleId, | ||
27 | + ProjectId: m.ProjectId, | ||
28 | + NodeId: m.NodeId, | ||
29 | + KpiCycle: m.KpiCycle, | ||
30 | + BeginAt: m.BeginAt, | ||
31 | + EndAt: m.EndAt, | ||
32 | + NextSentAt: m.NextSentAt, | ||
33 | + CreatedAt: m.CreatedAt, | ||
34 | + UpdatedAt: m.UpdatedAt, | ||
35 | + DeletedAt: m.DeletedAt, | ||
36 | + } | ||
37 | +} | ||
38 | + | ||
39 | +func (repo *NodeTaskRepository) TransformToModel(d *domain.NodeTask) models.NodeTask { | ||
40 | + return models.NodeTask{ | ||
41 | + Id: d.Id, | ||
42 | + CompanyId: d.CompanyId, | ||
43 | + CycleId: d.CycleId, | ||
44 | + ProjectId: d.ProjectId, | ||
45 | + NodeId: d.NodeId, | ||
46 | + KpiCycle: d.KpiCycle, | ||
47 | + BeginAt: d.BeginAt, | ||
48 | + EndAt: d.EndAt, | ||
49 | + NextSentAt: d.NextSentAt, | ||
50 | + CreatedAt: d.CreatedAt, | ||
51 | + UpdatedAt: d.UpdatedAt, | ||
52 | + DeletedAt: d.DeletedAt, | ||
53 | + } | ||
54 | +} | ||
55 | + | ||
56 | +func (repo *NodeTaskRepository) nextIdentify() (int64, error) { | ||
57 | + return utils.NewSnowflakeId() | ||
58 | +} | ||
59 | + | ||
60 | +func (repo *NodeTaskRepository) Insert(d *domain.NodeTask) (*domain.NodeTask, error) { | ||
61 | + var isCreate = d.Id == 0 | ||
62 | + if isCreate { | ||
63 | + id, err := repo.nextIdentify() | ||
64 | + if err != nil { | ||
65 | + return d, err | ||
66 | + } | ||
67 | + d.Id = id | ||
68 | + d.CreatedAt = time.Now() | ||
69 | + d.UpdatedAt = d.CreatedAt | ||
70 | + } else { | ||
71 | + d.UpdatedAt = time.Now() | ||
72 | + } | ||
73 | + m := repo.TransformToModel(d) | ||
74 | + tx := repo.transactionContext.PgTx | ||
75 | + var err error | ||
76 | + if isCreate { | ||
77 | + _, err = tx.Model(&m).Returning("id").Insert() | ||
78 | + } else { | ||
79 | + _, err = tx.Model(&m).Returning("id").WherePK().Update() // 更新和删除必须增加条件 | ||
80 | + } | ||
81 | + if err != nil { | ||
82 | + return nil, err | ||
83 | + } | ||
84 | + d.Id = m.Id | ||
85 | + return d, nil | ||
86 | +} | ||
87 | + | ||
88 | +func (repo *NodeTaskRepository) Remove(d *domain.NodeTask) (*domain.NodeTask, error) { | ||
89 | + tx := repo.transactionContext.PgTx | ||
90 | + nowTime := time.Now() | ||
91 | + m := repo.TransformToModel(d) | ||
92 | + m.DeletedAt = &nowTime | ||
93 | + if _, err := tx.Model(&m).WherePK().Update(); err != nil { | ||
94 | + return d, err | ||
95 | + } | ||
96 | + return d, nil | ||
97 | +} | ||
98 | + | ||
99 | +func (repo *NodeTaskRepository) FindOne(queryOptions map[string]interface{}) (*domain.NodeTask, error) { | ||
100 | + tx := repo.transactionContext.PgTx | ||
101 | + m := new(models.NodeTask) | ||
102 | + query := tx.Model(m) | ||
103 | + query.Where("deleted_at isnull") | ||
104 | + if id, ok := queryOptions["id"]; ok { | ||
105 | + query.Where("id=?", id) | ||
106 | + } | ||
107 | + if err := query.First(); err != nil { | ||
108 | + if errors.Is(err, pg.ErrNoRows) { | ||
109 | + return nil, fmt.Errorf("没有此资源") | ||
110 | + } else { | ||
111 | + return nil, err | ||
112 | + } | ||
113 | + } | ||
114 | + u := repo.TransformToDomain(m) | ||
115 | + return &u, nil | ||
116 | +} | ||
117 | + | ||
118 | +func (repo *NodeTaskRepository) Find(queryOptions map[string]interface{}) ([]*domain.NodeTask, error) { | ||
119 | + tx := repo.transactionContext.PgTx | ||
120 | + var m []*models.NodeTask | ||
121 | + query := tx.Model(&m).Where("deleted_at isnull") | ||
122 | + | ||
123 | + if v, ok := queryOptions["now"].(time.Time); ok { | ||
124 | + query.Where("next_sent_at <= ?", v) | ||
125 | + } | ||
126 | + | ||
127 | + if v, ok := queryOptions["ids"]; ok { | ||
128 | + query.Where("id in(?)", pg.In(v)) | ||
129 | + } | ||
130 | + | ||
131 | + if v, ok := queryOptions["companyId"]; ok { | ||
132 | + query.Where("company_id = ?", v) | ||
133 | + } | ||
134 | + | ||
135 | + if v, ok := queryOptions["cycleId"]; ok { | ||
136 | + query.Where("cycle_id = ?", v) | ||
137 | + } | ||
138 | + | ||
139 | + if v, ok := queryOptions["projectId"]; ok { | ||
140 | + query.Where("project_id = ?", v) | ||
141 | + } | ||
142 | + | ||
143 | + if v, ok := queryOptions["nodeId"]; ok { | ||
144 | + query.Where("node_id = ?", v) | ||
145 | + } | ||
146 | + | ||
147 | + err := query.Select() | ||
148 | + if err != nil { | ||
149 | + return nil, err | ||
150 | + } | ||
151 | + var arrays []*domain.NodeTask | ||
152 | + for _, v := range m { | ||
153 | + d := repo.TransformToDomain(v) | ||
154 | + arrays = append(arrays, &d) | ||
155 | + } | ||
156 | + return arrays, nil | ||
157 | +} |
1 | package repository | 1 | package repository |
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | + "time" | ||
5 | + | ||
4 | "github.com/go-pg/pg/v10" | 6 | "github.com/go-pg/pg/v10" |
5 | pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | 7 | pgTransaction "github.com/linmadan/egglib-go/transaction/pg" |
6 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | 8 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" |
7 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/pg/models" | 9 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/pg/models" |
8 | - "time" | ||
9 | ) | 10 | ) |
10 | 11 | ||
11 | type PositionRepository struct { | 12 | type PositionRepository struct { |
@@ -66,6 +67,37 @@ func (repository *PositionRepository) FindOne(queryOption map[string]interface{} | @@ -66,6 +67,37 @@ func (repository *PositionRepository) FindOne(queryOption map[string]interface{} | ||
66 | return repository.transferToDomain(position), nil | 67 | return repository.transferToDomain(position), nil |
67 | } | 68 | } |
68 | 69 | ||
70 | +func (repo *PositionRepository) Find(queryOptions map[string]interface{}) (int, []*domain.Position, error) { | ||
71 | + tx := repo.transactionContext.PgTx | ||
72 | + positionModel := []models.Position{} | ||
73 | + query := tx.Model(&positionModel) | ||
74 | + if v, ok := queryOptions["id"]; ok { | ||
75 | + query.Where("id=?", v) | ||
76 | + } | ||
77 | + if v, ok := queryOptions["ids"]; ok { | ||
78 | + query.Where("id in(?)", pg.In(v)) | ||
79 | + } | ||
80 | + if v, ok := queryOptions["companyId"]; ok { | ||
81 | + query.Where("company_id=?", v) | ||
82 | + } | ||
83 | + if v, ok := queryOptions["offset"]; ok { | ||
84 | + query.Offset(v.(int)) | ||
85 | + } | ||
86 | + if v, ok := queryOptions["limit"]; ok { | ||
87 | + query.Limit(v.(int)) | ||
88 | + } | ||
89 | + cnt, err := query.SelectAndCount() | ||
90 | + if err != nil { | ||
91 | + return 0, nil, err | ||
92 | + } | ||
93 | + var resultList []*domain.Position | ||
94 | + for i := range positionModel { | ||
95 | + result := repo.transferToDomain(&positionModel[i]) | ||
96 | + resultList = append(resultList, result) | ||
97 | + } | ||
98 | + return cnt, resultList, nil | ||
99 | +} | ||
100 | + | ||
69 | func (repository *PositionRepository) transferToDomain(model *models.Position) *domain.Position { | 101 | func (repository *PositionRepository) transferToDomain(model *models.Position) *domain.Position { |
70 | return &domain.Position{ | 102 | return &domain.Position{ |
71 | Id: model.Id, | 103 | Id: model.Id, |
@@ -113,19 +113,19 @@ func (repo *RoleRepository) Find(queryOptions map[string]interface{}) (int64, [] | @@ -113,19 +113,19 @@ func (repo *RoleRepository) Find(queryOptions map[string]interface{}) (int64, [] | ||
113 | var m []*models.Role | 113 | var m []*models.Role |
114 | query := tx.Model(&m).Where("deleted_at isnull") | 114 | query := tx.Model(&m).Where("deleted_at isnull") |
115 | 115 | ||
116 | - if name, ok := queryOptions["name"]; ok { | ||
117 | - query.Where("name = ?", name) | 116 | + if v, ok := queryOptions["name"].(string); ok && len(v) > 0 { |
117 | + query.Where("name = ?", v) | ||
118 | } | 118 | } |
119 | 119 | ||
120 | if companyId, ok := queryOptions["companyId"]; ok { | 120 | if companyId, ok := queryOptions["companyId"]; ok { |
121 | query.Where("company_id = ?", companyId) | 121 | query.Where("company_id = ?", companyId) |
122 | } | 122 | } |
123 | 123 | ||
124 | - if v, ok := queryOptions["limit"].(int); ok { | ||
125 | - query.Limit(v) | 124 | + if v, ok := queryOptions["limit"].(int64); ok { |
125 | + query.Limit(int(v)) | ||
126 | } | 126 | } |
127 | - if v, ok := queryOptions["offset"].(int); ok { | ||
128 | - query.Offset(v) | 127 | + if v, ok := queryOptions["offset"].(int64); ok { |
128 | + query.Offset(int(v)) | ||
129 | } | 129 | } |
130 | 130 | ||
131 | count, err := query.SelectAndCount() | 131 | count, err := query.SelectAndCount() |
@@ -154,8 +154,8 @@ func (repo *RoleRepository) Count(queryOptions map[string]interface{}) (int64, e | @@ -154,8 +154,8 @@ func (repo *RoleRepository) Count(queryOptions map[string]interface{}) (int64, e | ||
154 | query.Where("id != ?", notId) | 154 | query.Where("id != ?", notId) |
155 | } | 155 | } |
156 | 156 | ||
157 | - if name, ok := queryOptions["name"]; ok { | ||
158 | - query.Where("name = ?", name) | 157 | + if v, ok := queryOptions["name"].(string); ok && len(v) > 0 { |
158 | + query.Where("name = ?", v) | ||
159 | } | 159 | } |
160 | 160 | ||
161 | if companyId, ok := queryOptions["companyId"]; ok { | 161 | if companyId, ok := queryOptions["companyId"]; ok { |
@@ -128,11 +128,11 @@ func (repo *RoleUserRepository) Find(queryOptions map[string]interface{}) (int64 | @@ -128,11 +128,11 @@ func (repo *RoleUserRepository) Find(queryOptions map[string]interface{}) (int64 | ||
128 | query.Where("user_id in (?)", pg.In(userIds)) | 128 | query.Where("user_id in (?)", pg.In(userIds)) |
129 | } | 129 | } |
130 | 130 | ||
131 | - if v, ok := queryOptions["limit"].(int); ok { | ||
132 | - query.Limit(v) | 131 | + if v, ok := queryOptions["limit"].(int64); ok { |
132 | + query.Limit(int(v)) | ||
133 | } | 133 | } |
134 | - if v, ok := queryOptions["offset"].(int); ok { | ||
135 | - query.Offset(v) | 134 | + if v, ok := queryOptions["offset"].(int64); ok { |
135 | + query.Offset(int(v)) | ||
136 | } | 136 | } |
137 | 137 | ||
138 | count, err := query.SelectAndCount() | 138 | count, err := query.SelectAndCount() |
@@ -161,8 +161,8 @@ func (repo *RoleUserRepository) Count(queryOptions map[string]interface{}) (int6 | @@ -161,8 +161,8 @@ func (repo *RoleUserRepository) Count(queryOptions map[string]interface{}) (int6 | ||
161 | query.Where("id != ?", notId) | 161 | query.Where("id != ?", notId) |
162 | } | 162 | } |
163 | 163 | ||
164 | - if name, ok := queryOptions["name"]; ok { | ||
165 | - query.Where("name = ?", name) | 164 | + if v, ok := queryOptions["name"].(string); ok && len(v) > 0 { |
165 | + query.Where("name = ?", v) | ||
166 | } | 166 | } |
167 | 167 | ||
168 | if companyId, ok := queryOptions["companyId"]; ok { | 168 | if companyId, ok := queryOptions["companyId"]; ok { |
@@ -130,6 +130,10 @@ func (repo *StaffAssessRepository) Find(queryOptions map[string]interface{}) (in | @@ -130,6 +130,10 @@ func (repo *StaffAssessRepository) Find(queryOptions map[string]interface{}) (in | ||
130 | if v, ok := queryOptions["targetUserId"].(int); ok && v > 0 { | 130 | if v, ok := queryOptions["targetUserId"].(int); ok && v > 0 { |
131 | query.Where(`target_user->>'userId'='?'`, v) | 131 | query.Where(`target_user->>'userId'='?'`, v) |
132 | } | 132 | } |
133 | + | ||
134 | + if v, ok := queryOptions["targetUserName"].(int); ok && v > 0 { | ||
135 | + query.Where(`target_user->>'userName' like ?`, fmt.Sprintf("%%%v%%", v)) | ||
136 | + } | ||
133 | if v, ok := queryOptions["executorId"].(int); ok && v > 0 { | 137 | if v, ok := queryOptions["executorId"].(int); ok && v > 0 { |
134 | query.Where(`executor->>'userId'='?'`, v) | 138 | query.Where(`executor->>'userId'='?'`, v) |
135 | } | 139 | } |
@@ -29,6 +29,7 @@ func (repo *StaffAssessTaskRepository) TransformToDomain(d *models.StaffAssessTa | @@ -29,6 +29,7 @@ func (repo *StaffAssessTaskRepository) TransformToDomain(d *models.StaffAssessTa | ||
29 | EvaluationProjectName: d.EvaluationProjectName, | 29 | EvaluationProjectName: d.EvaluationProjectName, |
30 | CycleId: d.CycleId, | 30 | CycleId: d.CycleId, |
31 | CycleName: d.CycleName, | 31 | CycleName: d.CycleName, |
32 | + BeginDay: d.BeginDay, | ||
32 | BeginTime: d.BeginTime, | 33 | BeginTime: d.BeginTime, |
33 | EndTime: d.EndTime, | 34 | EndTime: d.EndTime, |
34 | StepList: d.StepList, | 35 | StepList: d.StepList, |
@@ -47,6 +48,7 @@ func (repo *StaffAssessTaskRepository) Save(d *domain.StaffAssessTask) (*domain. | @@ -47,6 +48,7 @@ func (repo *StaffAssessTaskRepository) Save(d *domain.StaffAssessTask) (*domain. | ||
47 | EvaluationProjectName: d.EvaluationProjectName, | 48 | EvaluationProjectName: d.EvaluationProjectName, |
48 | CycleId: d.CycleId, | 49 | CycleId: d.CycleId, |
49 | CycleName: d.CycleName, | 50 | CycleName: d.CycleName, |
51 | + BeginDay: d.BeginDay, | ||
50 | ExecutorId: d.ExecutorId, | 52 | ExecutorId: d.ExecutorId, |
51 | StepList: d.StepList, | 53 | StepList: d.StepList, |
52 | BeginTime: d.BeginTime, | 54 | BeginTime: d.BeginTime, |
@@ -115,9 +117,15 @@ func (repo *StaffAssessTaskRepository) Find(queryOptions map[string]interface{}) | @@ -115,9 +117,15 @@ func (repo *StaffAssessTaskRepository) Find(queryOptions map[string]interface{}) | ||
115 | if v, ok := queryOptions["offset"].(int); ok { | 117 | if v, ok := queryOptions["offset"].(int); ok { |
116 | query.Offset(v) | 118 | query.Offset(v) |
117 | } | 119 | } |
120 | + if v, ok := queryOptions["beginDay"]; ok { | ||
121 | + query.Where("begin_day=?", v) | ||
122 | + } | ||
118 | if v, ok := queryOptions["executorId"].(int); ok && v > 0 { | 123 | if v, ok := queryOptions["executorId"].(int); ok && v > 0 { |
119 | query.Where(`executor_id @>'[?]'`, v) | 124 | query.Where(`executor_id @>'[?]'`, v) |
120 | } | 125 | } |
126 | + if v, ok := queryOptions["evaluationProjectId"]; ok { | ||
127 | + query.Where("evaluation_project_id=?", v) | ||
128 | + } | ||
121 | count, err := query.SelectAndCount() | 129 | count, err := query.SelectAndCount() |
122 | if err != nil { | 130 | if err != nil { |
123 | return 0, nil, err | 131 | return 0, nil, err |
@@ -116,7 +116,7 @@ func (repo *UserRepository) Find(queryOptions map[string]interface{}) (int, []*d | @@ -116,7 +116,7 @@ func (repo *UserRepository) Find(queryOptions map[string]interface{}) (int, []*d | ||
116 | if v, ok := queryOptions["account"]; ok { | 116 | if v, ok := queryOptions["account"]; ok { |
117 | query.Where("account like ?", v) | 117 | query.Where("account like ?", v) |
118 | } | 118 | } |
119 | - if v, ok := queryOptions["name"]; ok { | 119 | + if v, ok := queryOptions["name"].(string); ok && len(v) > 0 { |
120 | query.Where("name like ?", fmt.Sprintf("%%%v%%", v)) | 120 | query.Where("name like ?", fmt.Sprintf("%%%v%%", v)) |
121 | } | 121 | } |
122 | if v, ok := queryOptions["offset"]; ok { | 122 | if v, ok := queryOptions["offset"]; ok { |
@@ -21,8 +21,6 @@ func (controller *CycleController) CreateCycle() { | @@ -21,8 +21,6 @@ func (controller *CycleController) CreateCycle() { | ||
21 | ua := middlewares.GetUser(controller.Ctx) | 21 | ua := middlewares.GetUser(controller.Ctx) |
22 | in.CompanyId = ua.CompanyId | 22 | in.CompanyId = ua.CompanyId |
23 | in.CreatorId = ua.UserId | 23 | in.CreatorId = ua.UserId |
24 | - //in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
25 | - //in.CreatorId = middlewares.GetUserId(controller.Ctx) | ||
26 | controller.Response(ruService.Create(in)) | 24 | controller.Response(ruService.Create(in)) |
27 | } | 25 | } |
28 | } | 26 | } |
@@ -101,9 +99,10 @@ func (controller *CycleController) CycleTemplateList() { | @@ -101,9 +99,10 @@ func (controller *CycleController) CycleTemplateList() { | ||
101 | func (controller *CycleController) CycleTemplate() { | 99 | func (controller *CycleController) CycleTemplate() { |
102 | ruService := service.NewEvaluationCycleService() | 100 | ruService := service.NewEvaluationCycleService() |
103 | in := &command.CycleTemplateCommand{} | 101 | in := &command.CycleTemplateCommand{} |
104 | - if err := controller.Unmarshal(in); err != nil { | 102 | + if id, err := controller.GetInt64(":Id"); err != nil { |
105 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | 103 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) |
106 | } else { | 104 | } else { |
105 | + in.Id = id | ||
107 | controller.Response(ruService.CycleTemplate(in)) | 106 | controller.Response(ruService.CycleTemplate(in)) |
108 | } | 107 | } |
109 | } | 108 | } |
@@ -6,6 +6,8 @@ import ( | @@ -6,6 +6,8 @@ import ( | ||
6 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/command" | 6 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/command" |
7 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/query" | 7 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/query" |
8 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/service" | 8 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/service" |
9 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/middlewares" | ||
9 | ) | 11 | ) |
10 | 12 | ||
11 | type StaffAssessController struct { | 13 | type StaffAssessController struct { |
@@ -22,9 +24,10 @@ func (c *StaffAssessController) SearchAssessTaskMe() { | @@ -22,9 +24,10 @@ func (c *StaffAssessController) SearchAssessTaskMe() { | ||
22 | c.Response(nil, e) | 24 | c.Response(nil, e) |
23 | return | 25 | return |
24 | } | 26 | } |
25 | - //TODO 获取当前用户信息 | ||
26 | - paramReq.CompanyId = 1 | ||
27 | - paramReq.UserId = 1 | 27 | + userReq := middlewares.GetUser(c.Ctx) |
28 | + paramReq.CompanyId = int(userReq.CompanyId) | ||
29 | + paramReq.UserId = int(userReq.UserId) | ||
30 | + | ||
28 | data, err := srv.SearchAssessTaskMe(paramReq) | 31 | data, err := srv.SearchAssessTaskMe(paramReq) |
29 | c.Response(data, err) | 32 | c.Response(data, err) |
30 | } | 33 | } |
@@ -39,9 +42,9 @@ func (c *StaffAssessController) AssessTaskMeDesc() { | @@ -39,9 +42,9 @@ func (c *StaffAssessController) AssessTaskMeDesc() { | ||
39 | c.Response(nil, e) | 42 | c.Response(nil, e) |
40 | return | 43 | return |
41 | } | 44 | } |
42 | - //TODO 获取当前用户信息 | ||
43 | - paramReq.CompanyId = 1 | ||
44 | - paramReq.UserId = 1 | 45 | + userReq := middlewares.GetUser(c.Ctx) |
46 | + paramReq.CompanyId = int(userReq.CompanyId) | ||
47 | + paramReq.UserId = int(userReq.UserId) | ||
45 | data, err := srv.AssessTaskDesc(paramReq) | 48 | data, err := srv.AssessTaskDesc(paramReq) |
46 | c.Response(data, err) | 49 | c.Response(data, err) |
47 | } | 50 | } |
@@ -56,9 +59,9 @@ func (c *StaffAssessController) AssessSelfMeList() { | @@ -56,9 +59,9 @@ func (c *StaffAssessController) AssessSelfMeList() { | ||
56 | c.Response(nil, e) | 59 | c.Response(nil, e) |
57 | return | 60 | return |
58 | } | 61 | } |
59 | - //TODO 获取当前用户信息 | ||
60 | - paramReq.CompanyId = 1 | ||
61 | - paramReq.UserId = 1 | 62 | + userReq := middlewares.GetUser(c.Ctx) |
63 | + paramReq.CompanyId = int(userReq.CompanyId) | ||
64 | + paramReq.UserId = int(userReq.UserId) | ||
62 | data, err := srv.AssessSelfList(paramReq) | 65 | data, err := srv.AssessSelfList(paramReq) |
63 | c.Response(data, err) | 66 | c.Response(data, err) |
64 | } | 67 | } |
@@ -88,17 +91,15 @@ func (c *StaffAssessController) GetAssessSelfMeInfo() { | @@ -88,17 +91,15 @@ func (c *StaffAssessController) GetAssessSelfMeInfo() { | ||
88 | c.Response(nil, e) | 91 | c.Response(nil, e) |
89 | return | 92 | return |
90 | } | 93 | } |
91 | - //TODO 获取当前用户信息 | ||
92 | - paramReq.CompanyId = 1 | ||
93 | - paramReq.TargetUserId = 1 | 94 | + userReq := middlewares.GetUser(c.Ctx) |
95 | + paramReq.CompanyId = int(userReq.CompanyId) | ||
96 | + paramReq.TargetUserId = int(userReq.UserId) | ||
94 | data, err := srv.GetAssessSelfInfo(paramReq) | 97 | data, err := srv.GetAssessSelfInfo(paramReq) |
95 | c.Response(data, err) | 98 | c.Response(data, err) |
96 | } | 99 | } |
97 | 100 | ||
98 | -//保存员工自评填写内容 | ||
99 | - | ||
100 | -// 获取员工邀请的人 | ||
101 | -func (c *StaffAssessController) GetAssessInviteUser() { | 101 | +// 获取我邀请的人 |
102 | +func (c *StaffAssessController) GetAssessMeInviteUser() { | ||
102 | srv := service.NewStaffAssessServeice() | 103 | srv := service.NewStaffAssessServeice() |
103 | paramReq := &query.GetAssessInviteUserQuery{} | 104 | paramReq := &query.GetAssessInviteUserQuery{} |
104 | err := c.BindJSON(paramReq) | 105 | err := c.BindJSON(paramReq) |
@@ -107,15 +108,15 @@ func (c *StaffAssessController) GetAssessInviteUser() { | @@ -107,15 +108,15 @@ func (c *StaffAssessController) GetAssessInviteUser() { | ||
107 | c.Response(nil, e) | 108 | c.Response(nil, e) |
108 | return | 109 | return |
109 | } | 110 | } |
110 | - //TODO 获取当前用户信息 | ||
111 | - paramReq.CompanyId = 1 | ||
112 | - paramReq.UserId = 1 | 111 | + userReq := middlewares.GetUser(c.Ctx) |
112 | + paramReq.CompanyId = int(userReq.CompanyId) | ||
113 | + paramReq.UserId = int(userReq.UserId) | ||
113 | data, err := srv.GetAssessInviteUser(paramReq) | 114 | data, err := srv.GetAssessInviteUser(paramReq) |
114 | c.Response(data, err) | 115 | c.Response(data, err) |
115 | } | 116 | } |
116 | 117 | ||
117 | -// 保持员工邀请的人 | ||
118 | -func (c *StaffAssessController) SaveAssessInviteUser() { | 118 | +// 保持我邀请的员工 |
119 | +func (c *StaffAssessController) SaveAssessMeInviteUser() { | ||
119 | srv := service.NewStaffAssessServeice() | 120 | srv := service.NewStaffAssessServeice() |
120 | paramReq := &command.SaveAssessInvite{} | 121 | paramReq := &command.SaveAssessInvite{} |
121 | err := c.BindJSON(paramReq) | 122 | err := c.BindJSON(paramReq) |
@@ -141,15 +142,17 @@ func (c *StaffAssessController) SelectAssessInviteUser() { | @@ -141,15 +142,17 @@ func (c *StaffAssessController) SelectAssessInviteUser() { | ||
141 | c.Response(nil, e) | 142 | c.Response(nil, e) |
142 | return | 143 | return |
143 | } | 144 | } |
144 | - //TODO 获取当前用户信息 | ||
145 | - paramReq.CompanyId = 1 | ||
146 | - paramReq.TargetUserId = 1 | 145 | + // paramReq.CompanyId = 1 |
146 | + // paramReq.TargetUserId = 1 | ||
147 | + userReq := middlewares.GetUser(c.Ctx) | ||
148 | + paramReq.CompanyId = int(userReq.CompanyId) | ||
149 | + paramReq.TargetUserId = int(userReq.UserId) | ||
147 | data, err := srv.SelectAssessInviteUser(paramReq) | 150 | data, err := srv.SelectAssessInviteUser(paramReq) |
148 | c.Response(data, err) | 151 | c.Response(data, err) |
149 | } | 152 | } |
150 | 153 | ||
151 | // 获取我要执行360评估,用户列表和评估填写的值 | 154 | // 获取我要执行360评估,用户列表和评估填写的值 |
152 | -func (c *StaffAssessController) ListInviteUserAssess() { | 155 | +func (c *StaffAssessController) ListMeInviteUserAssess() { |
153 | srv := service.NewStaffAssessServeice() | 156 | srv := service.NewStaffAssessServeice() |
154 | paramReq := &query.ListInviteUserAssessQuery{} | 157 | paramReq := &query.ListInviteUserAssessQuery{} |
155 | err := c.BindJSON(paramReq) | 158 | err := c.BindJSON(paramReq) |
@@ -158,15 +161,18 @@ func (c *StaffAssessController) ListInviteUserAssess() { | @@ -158,15 +161,18 @@ func (c *StaffAssessController) ListInviteUserAssess() { | ||
158 | c.Response(nil, e) | 161 | c.Response(nil, e) |
159 | return | 162 | return |
160 | } | 163 | } |
161 | - //TODO 获取当前用户信息 | ||
162 | - paramReq.CompanyId = 1 | ||
163 | - paramReq.ExecutorId = 1 | ||
164 | - data, err := srv.ListInviteUserAssess(paramReq) | 164 | + //获取当前用户信息 |
165 | + // paramReq.CompanyId = 1 | ||
166 | + // paramReq.ExecutorId = 1 | ||
167 | + userReq := middlewares.GetUser(c.Ctx) | ||
168 | + paramReq.CompanyId = int(userReq.CompanyId) | ||
169 | + paramReq.ExecutorId = int(userReq.UserId) | ||
170 | + data, err := srv.ListExecutorInviteAssess(paramReq) | ||
165 | c.Response(data, err) | 171 | c.Response(data, err) |
166 | } | 172 | } |
167 | 173 | ||
168 | -// 获取上级评估成员列表 | ||
169 | -func (c *StaffAssessController) ListSupperAssess() { | 174 | +// 获取我要执行的上级评估成员列表 |
175 | +func (c *StaffAssessController) ListMeSupperAssess() { | ||
170 | srv := service.NewStaffAssessServeice() | 176 | srv := service.NewStaffAssessServeice() |
171 | paramReq := &query.ListSupperAssessQuery{} | 177 | paramReq := &query.ListSupperAssessQuery{} |
172 | err := c.BindJSON(paramReq) | 178 | err := c.BindJSON(paramReq) |
@@ -176,14 +182,17 @@ func (c *StaffAssessController) ListSupperAssess() { | @@ -176,14 +182,17 @@ func (c *StaffAssessController) ListSupperAssess() { | ||
176 | return | 182 | return |
177 | } | 183 | } |
178 | //TODO 获取当前用户信息 | 184 | //TODO 获取当前用户信息 |
179 | - paramReq.CompanyId = 1 | ||
180 | - paramReq.ExecutorId = 1 | ||
181 | - data, err := srv.ListSupperAssess(paramReq) | 185 | + // paramReq.CompanyId = 1 |
186 | + // paramReq.ExecutorId = 1 | ||
187 | + userReq := middlewares.GetUser(c.Ctx) | ||
188 | + paramReq.CompanyId = int(userReq.CompanyId) | ||
189 | + paramReq.ExecutorId = int(userReq.UserId) | ||
190 | + data, err := srv.ListExecutorSupperAssess(paramReq) | ||
182 | c.Response(data, err) | 191 | c.Response(data, err) |
183 | } | 192 | } |
184 | 193 | ||
185 | // 获取员工自评详情 | 194 | // 获取员工自评详情 |
186 | -func (c *StaffAssessController) GetAssessSelfInfo() { | 195 | +func (c *StaffAssessController) GetAssessTargetUserSelfInfo() { |
187 | srv := service.NewStaffAssessServeice() | 196 | srv := service.NewStaffAssessServeice() |
188 | paramReq := &query.AssessSelfInfoQuery{} | 197 | paramReq := &query.AssessSelfInfoQuery{} |
189 | err := c.BindJSON(paramReq) | 198 | err := c.BindJSON(paramReq) |
@@ -192,7 +201,9 @@ func (c *StaffAssessController) GetAssessSelfInfo() { | @@ -192,7 +201,9 @@ func (c *StaffAssessController) GetAssessSelfInfo() { | ||
192 | c.Response(nil, e) | 201 | c.Response(nil, e) |
193 | return | 202 | return |
194 | } | 203 | } |
195 | - paramReq.CompanyId = 1 | 204 | + // paramReq.CompanyId = 1 |
205 | + userReq := middlewares.GetUser(c.Ctx) | ||
206 | + paramReq.CompanyId = int(userReq.CompanyId) | ||
196 | data, err := srv.GetAssessSelfInfo(paramReq) | 207 | data, err := srv.GetAssessSelfInfo(paramReq) |
197 | c.Response(data, err) | 208 | c.Response(data, err) |
198 | } | 209 | } |
@@ -207,7 +218,41 @@ func (c *StaffAssessController) GetAssessInfo() { | @@ -207,7 +218,41 @@ func (c *StaffAssessController) GetAssessInfo() { | ||
207 | c.Response(nil, e) | 218 | c.Response(nil, e) |
208 | return | 219 | return |
209 | } | 220 | } |
210 | - paramReq.CompanyId = 1 | 221 | + // paramReq.CompanyId = 1 |
222 | + userReq := middlewares.GetUser(c.Ctx) | ||
223 | + paramReq.CompanyId = int(userReq.CompanyId) | ||
211 | data, err := srv.GetAssessInfo(paramReq) | 224 | data, err := srv.GetAssessInfo(paramReq) |
212 | c.Response(data, err) | 225 | c.Response(data, err) |
213 | } | 226 | } |
227 | + | ||
228 | +// 保存评估内容详情 | ||
229 | +func (c *StaffAssessController) SaveAssessInfo() { | ||
230 | + srv := service.NewStaffAssessServeice() | ||
231 | + paramReq := &command.SaveAssessInfoCommand{} | ||
232 | + err := c.BindJSON(paramReq) | ||
233 | + if err != nil { | ||
234 | + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error()) | ||
235 | + c.Response(nil, e) | ||
236 | + return | ||
237 | + } | ||
238 | + data, err := srv.SaveAssessInfo(paramReq) | ||
239 | + c.Response(data, err) | ||
240 | +} | ||
241 | + | ||
242 | +// 被评估的员工的评估列表-360评估 | ||
243 | +func (c *StaffAssessController) ListTargetUserInviteAssess() { | ||
244 | + srv := service.NewStaffAssessServeice() | ||
245 | + paramReq := &query.ListTargetUserAssessQuery{} | ||
246 | + err := c.BindJSON(paramReq) | ||
247 | + if err != nil { | ||
248 | + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error()) | ||
249 | + c.Response(nil, e) | ||
250 | + return | ||
251 | + } | ||
252 | + // paramReq.CompanyId = 1 | ||
253 | + userReq := middlewares.GetUser(c.Ctx) | ||
254 | + paramReq.CompanyId = int(userReq.CompanyId) | ||
255 | + paramReq.Types = []string{string(domain.AssessInviteSameSuper), string(domain.AssessInviteDiffSuper)} | ||
256 | + data, err := srv.ListTargetUserAssess(paramReq) | ||
257 | + c.Response(data, err) | ||
258 | +} |
@@ -17,6 +17,7 @@ func init() { | @@ -17,6 +17,7 @@ func init() { | ||
17 | web.NSRouter("/list", &controllers.CycleController{}, "Post:ListCycle"), | 17 | web.NSRouter("/list", &controllers.CycleController{}, "Post:ListCycle"), |
18 | web.NSRouter("/statistic", &controllers.CycleController{}, "Post:StatisticCycleUser"), | 18 | web.NSRouter("/statistic", &controllers.CycleController{}, "Post:StatisticCycleUser"), |
19 | web.NSRouter("/templates", &controllers.CycleController{}, "Post:CycleTemplateList"), | 19 | web.NSRouter("/templates", &controllers.CycleController{}, "Post:CycleTemplateList"), |
20 | + web.NSRouter("/template/:Id", &controllers.CycleController{}, "Get:CycleTemplate"), | ||
20 | ) | 21 | ) |
21 | web.AddNamespace(ns) | 22 | web.AddNamespace(ns) |
22 | } | 23 | } |
@@ -17,11 +17,16 @@ func init() { | @@ -17,11 +17,16 @@ func init() { | ||
17 | // web.NSBefore(filters.AllowCors(), middlewares.CheckToken()), | 17 | // web.NSBefore(filters.AllowCors(), middlewares.CheckToken()), |
18 | web.NSCtrlPost("/self/me/list", (*controllers.StaffAssessController).AssessSelfMeList), //获取我的自评反馈列表 | 18 | web.NSCtrlPost("/self/me/list", (*controllers.StaffAssessController).AssessSelfMeList), //获取我的自评反馈列表 |
19 | web.NSCtrlPost("/self/me/info", (*controllers.StaffAssessController).GetAssessSelfMeInfo), //获取我的自评反馈详情 | 19 | web.NSCtrlPost("/self/me/info", (*controllers.StaffAssessController).GetAssessSelfMeInfo), //获取我的自评反馈详情 |
20 | - web.NSCtrlPost("/me/invite-user", (*controllers.StaffAssessController).GetAssessInviteUser), //获取邀请的员工 | ||
21 | - web.NSCtrlPost("/me/save-invite-user", (*controllers.StaffAssessController).SaveAssessInviteUser), //保存我邀请的员工 | 20 | + web.NSCtrlPost("/me/invite-user", (*controllers.StaffAssessController).GetAssessMeInviteUser), //获取邀请的员工 |
21 | + web.NSCtrlPost("/me/save-invite-user", (*controllers.StaffAssessController).SaveAssessMeInviteUser), //保存我邀请的员工 | ||
22 | web.NSCtrlPost("/me/invite-user/select", (*controllers.StaffAssessController).SelectAssessInviteUser), //选择我邀请的员工 | 22 | web.NSCtrlPost("/me/invite-user/select", (*controllers.StaffAssessController).SelectAssessInviteUser), //选择我邀请的员工 |
23 | - web.NSCtrlPost("/self/info", (*controllers.StaffAssessController).GetAssessSelfInfo), //获取我的自评反馈详情 | ||
24 | - web.NSCtrlPost("/info", (*controllers.StaffAssessController).GetAssessInfo), //获取我的自评反馈详情 | 23 | + web.NSCtrlPost("/me/execute/invite/list", (*controllers.StaffAssessController).ListMeInviteUserAssess), //我要执行的360评估的用户列表 |
24 | + web.NSCtrlPost("/me/execute/supper/list", (*controllers.StaffAssessController).ListMeSupperAssess), //我要执行的360评估的用户列表 | ||
25 | + web.NSCtrlPost("/info", (*controllers.StaffAssessController).GetAssessInfo), //通用获取员工评估的详情 | ||
26 | + web.NSCtrlPut("/info", (*controllers.StaffAssessController).SaveAssessInfo), //通用保存员工评估的详情 | ||
27 | + web.NSCtrlPost("/target-user/invite/list", (*controllers.StaffAssessController).ListTargetUserInviteAssess), //获取被评估员工评估的详情 | ||
28 | + web.NSCtrlPost("/target-user/self/info", (*controllers.StaffAssessController).GetAssessTargetUserSelfInfo), //获取被评估员工的自评反馈详情 | ||
29 | + | ||
25 | ) | 30 | ) |
26 | web.AddNamespace(assessTaskNS) | 31 | web.AddNamespace(assessTaskNS) |
27 | web.AddNamespace(assessNS) | 32 | web.AddNamespace(assessNS) |
@@ -2,9 +2,12 @@ package utils | @@ -2,9 +2,12 @@ package utils | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "fmt" | 4 | "fmt" |
5 | + timeconv "github.com/Andrew-M-C/go.timeconv" | ||
5 | "github.com/beego/beego/v2/core/validation" | 6 | "github.com/beego/beego/v2/core/validation" |
7 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
6 | "reflect" | 8 | "reflect" |
7 | "strings" | 9 | "strings" |
10 | + "time" | ||
8 | ) | 11 | ) |
9 | 12 | ||
10 | // ValidateCommand 验证输入参数 | 13 | // ValidateCommand 验证输入参数 |
@@ -31,3 +34,70 @@ func ValidateCommand(commandType interface{}) error { | @@ -31,3 +34,70 @@ func ValidateCommand(commandType interface{}) error { | ||
31 | } | 34 | } |
32 | return nil | 35 | return nil |
33 | } | 36 | } |
37 | + | ||
38 | +// NextTime 0点时刻为标准计算 | ||
39 | +func NextTime(now0 time.Time, start *time.Time, kpiCycle int) time.Time { | ||
40 | + // 起始时间0点时刻 | ||
41 | + start0 := time.Date(start.Year(), start.Month(), start.Day(), 0, 0, 0, 0, time.Local) | ||
42 | + | ||
43 | + var nextTime time.Time | ||
44 | + switch kpiCycle { | ||
45 | + case domain.KpiCycleDay: | ||
46 | + nextTime = timeconv.AddDate(now0, 0, 0, 1) // 当前时间的下一天开始发送 | ||
47 | + break | ||
48 | + case domain.KpiCycleWeek: | ||
49 | + offsetSeconds := int64(now0.Sub(start0).Seconds()) | ||
50 | + offsetDay := offsetSeconds / (24 * 60 * 60) | ||
51 | + cycleCount := int(offsetDay)/7 + 1 | ||
52 | + nextTime = timeconv.AddDate(start0, 0, 0, cycleCount*7) | ||
53 | + break | ||
54 | + case domain.KpiCycleOneMonth: | ||
55 | + nextTime = timeconv.AddDate(start0, 0, 1, 0) | ||
56 | + break | ||
57 | + case domain.KpiCycleTwoMonth: | ||
58 | + nextTime = timeconv.AddDate(start0, 0, 2, 0) | ||
59 | + break | ||
60 | + case domain.KpiCycleThreeMonth: | ||
61 | + nextTime = timeconv.AddDate(start0, 0, 3, 0) | ||
62 | + break | ||
63 | + case domain.KpiCycleSixMonth: | ||
64 | + nextTime = timeconv.AddDate(start0, 0, 6, 0) | ||
65 | + break | ||
66 | + case domain.KpiCycleYear: | ||
67 | + nextTime = timeconv.AddDate(start0, 1, 0, 0) | ||
68 | + break | ||
69 | + } | ||
70 | + return nextTime | ||
71 | +} | ||
72 | + | ||
73 | +// NextTimeInc 0点时刻为标准计算 | ||
74 | +func NextTimeInc(start *time.Time, kpiCycle int) time.Time { | ||
75 | + // 起始时间0点时刻 | ||
76 | + start0 := time.Date(start.Year(), start.Month(), start.Day(), 0, 0, 0, 0, time.Local) | ||
77 | + | ||
78 | + var nextTime time.Time | ||
79 | + switch kpiCycle { | ||
80 | + case domain.KpiCycleDay: | ||
81 | + nextTime = timeconv.AddDate(start0, 0, 0, 1) // 当前时间的下一天开始发送 | ||
82 | + break | ||
83 | + case domain.KpiCycleWeek: | ||
84 | + nextTime = timeconv.AddDate(start0, 0, 0, 7) | ||
85 | + break | ||
86 | + case domain.KpiCycleOneMonth: | ||
87 | + nextTime = timeconv.AddDate(start0, 0, 1, 0) | ||
88 | + break | ||
89 | + case domain.KpiCycleTwoMonth: | ||
90 | + nextTime = timeconv.AddDate(start0, 0, 2, 0) | ||
91 | + break | ||
92 | + case domain.KpiCycleThreeMonth: | ||
93 | + nextTime = timeconv.AddDate(start0, 0, 3, 0) | ||
94 | + break | ||
95 | + case domain.KpiCycleSixMonth: | ||
96 | + nextTime = timeconv.AddDate(start0, 0, 6, 0) | ||
97 | + break | ||
98 | + case domain.KpiCycleYear: | ||
99 | + nextTime = timeconv.AddDate(start0, 1, 0, 0) | ||
100 | + break | ||
101 | + } | ||
102 | + return nextTime | ||
103 | +} |
-
请 注册 或 登录 后发表评论