正在显示
37 个修改的文件
包含
1851 行增加
和
168 行删除
@@ -56,7 +56,7 @@ func startSummaryEvaluation() { | @@ -56,7 +56,7 @@ func startSummaryEvaluation() { | ||
56 | timer := time.NewTimer(duration) | 56 | timer := time.NewTimer(duration) |
57 | for { | 57 | for { |
58 | <-timer.C | 58 | <-timer.C |
59 | - if err := serviceSummary.TaskSendSummaryEvaluation(); err != nil { | 59 | + if err := serviceSummary.TaskSendSummaryEvaluationV2(); err != nil { |
60 | log.Logger.Error(err.Error()) | 60 | log.Logger.Error(err.Error()) |
61 | } | 61 | } |
62 | timer.Reset(duration) // 重置定时 | 62 | timer.Reset(duration) // 重置定时 |
@@ -2,6 +2,7 @@ package adapter | @@ -2,6 +2,7 @@ package adapter | ||
2 | 2 | ||
3 | type MeInfo struct { | 3 | type MeInfo struct { |
4 | UserId int64 `json:"userId"` //用户名称 | 4 | UserId int64 `json:"userId"` //用户名称 |
5 | + CompanyLogo string `json:"companyLogo"` //图标 | ||
5 | CompanyId int64 `json:"companyId"` //公司id | 6 | CompanyId int64 `json:"companyId"` //公司id |
6 | CompanyName string `json:"companyName"` //公司名称 | 7 | CompanyName string `json:"companyName"` //公司名称 |
7 | Phone string `json:"phone"` // 手机号 | 8 | Phone string `json:"phone"` // 手机号 |
@@ -220,6 +220,7 @@ loop: | @@ -220,6 +220,7 @@ loop: | ||
220 | UserId: userData.Id, | 220 | UserId: userData.Id, |
221 | CompanyId: companyData.Id, | 221 | CompanyId: companyData.Id, |
222 | CompanyName: companyData.Name, | 222 | CompanyName: companyData.Name, |
223 | + CompanyLogo: companyData.Logo, | ||
223 | Phone: userData.Account, | 224 | Phone: userData.Account, |
224 | Name: userData.Name, | 225 | Name: userData.Name, |
225 | IsHrbp: isHrbp, | 226 | IsHrbp: isHrbp, |
@@ -3,6 +3,7 @@ package service | @@ -3,6 +3,7 @@ package service | ||
3 | import ( | 3 | import ( |
4 | "fmt" | 4 | "fmt" |
5 | "strconv" | 5 | "strconv" |
6 | + "strings" | ||
6 | "time" | 7 | "time" |
7 | 8 | ||
8 | "github.com/linmadan/egglib-go/core/application" | 9 | "github.com/linmadan/egglib-go/core/application" |
@@ -170,7 +171,7 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp | @@ -170,7 +171,7 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp | ||
170 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 171 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
171 | } | 172 | } |
172 | // 项目调整截止时间,同步更新任务时间 | 173 | // 项目调整截止时间,同步更新任务时间 |
173 | - if err := rs.updateTaskTime(transactionContext, in.Id, end); err != nil { | 174 | + if err := rs.updateTaskTime(transactionContext, in.Id, &end); err != nil { |
174 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 175 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
175 | } | 176 | } |
176 | 177 | ||
@@ -179,31 +180,35 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp | @@ -179,31 +180,35 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp | ||
179 | } | 180 | } |
180 | return project, nil | 181 | return project, nil |
181 | } else { | 182 | } else { |
182 | - _, projects, err := projectRepository.Find(map[string]interface{}{"companyId": in.CompanyId, "cycleId": in.CycleId}, "template") | ||
183 | - if err != nil { | ||
184 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
185 | - } | ||
186 | - // 周期内的所有项目,员工不能重复被评估 | ||
187 | - rids := map[string]bool{} | ||
188 | - for i := range projects { | ||
189 | - // 排除当前项目 | ||
190 | - if in.Id != projects[i].Id { | ||
191 | - ids := projects[i].Recipients | ||
192 | - for j := range ids { | ||
193 | - rids[ids[j]] = true | ||
194 | - } | ||
195 | - } | ||
196 | - } | ||
197 | - repeatNum := 0 | ||
198 | - for i := range in.Recipients { | ||
199 | - id := in.Recipients[i] | ||
200 | - if _, ok := rids[id]; ok { | ||
201 | - repeatNum++ | ||
202 | - } | ||
203 | - } | ||
204 | - if repeatNum > 0 { | ||
205 | - return nil, application.ThrowError(application.BUSINESS_ERROR, fmt.Sprintf("有%d人已经在本周期其他项目内,需要将他们移除", repeatNum)) | ||
206 | - } | 183 | + //_, projects, err := projectRepository.Find(map[string]interface{}{"companyId": in.CompanyId, "cycleId": in.CycleId}, "template") |
184 | + //if err != nil { | ||
185 | + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
186 | + //} | ||
187 | + //// 周期内的所有项目,员工不能重复被评估 | ||
188 | + //rids := map[string]bool{} | ||
189 | + //for i := range projects { | ||
190 | + // it := projects[i] | ||
191 | + // // 排除当前项目 | ||
192 | + // if in.Id == it.Id { | ||
193 | + // continue | ||
194 | + // } | ||
195 | + // // 启用状态 | ||
196 | + // if it.State == domain.ProjectStateEnable { | ||
197 | + // for j := range it.Recipients { | ||
198 | + // rids[it.Recipients[j]] = true | ||
199 | + // } | ||
200 | + // } | ||
201 | + //} | ||
202 | + //repeatNum := 0 | ||
203 | + //for i := range in.Recipients { | ||
204 | + // id := in.Recipients[i] | ||
205 | + // if _, ok := rids[id]; ok { | ||
206 | + // repeatNum++ | ||
207 | + // } | ||
208 | + //} | ||
209 | + //if repeatNum > 0 { | ||
210 | + // return nil, application.ThrowError(application.BUSINESS_ERROR, fmt.Sprintf("有%d人已经在本周期其他项目内,需要将他们移除", repeatNum)) | ||
211 | + //} | ||
207 | 212 | ||
208 | cycleTemplate, err := cycleTemplateRepository.FindOne(map[string]interface{}{"id": in.TemplateId, "includeDeleted": true}) | 213 | cycleTemplate, err := cycleTemplateRepository.FindOne(map[string]interface{}{"id": in.TemplateId, "includeDeleted": true}) |
209 | if err != nil { | 214 | if err != nil { |
@@ -237,6 +242,32 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp | @@ -237,6 +242,32 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp | ||
237 | return nil, application.ThrowError(application.BUSINESS_ERROR, "评估截至时间不能超出周期截至时间") | 242 | return nil, application.ThrowError(application.BUSINESS_ERROR, "评估截至时间不能超出周期截至时间") |
238 | } | 243 | } |
239 | 244 | ||
245 | + // 判断起始时间,是否有被评估人的任务 | ||
246 | + assessTaskRepository := factory.CreateStaffAssessTaskRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
247 | + _, assessTasks, err := assessTaskRepository.Find(map[string]interface{}{ | ||
248 | + "companyId": in.CompanyId, | ||
249 | + "cycleId": in.CycleId, | ||
250 | + "beginDay": start.Format("2006-01-02"), | ||
251 | + }) | ||
252 | + | ||
253 | + rids := map[int]int{} | ||
254 | + for i1 := range assessTasks { | ||
255 | + it := assessTasks[i1] | ||
256 | + for i2 := range it.ExecutorId { | ||
257 | + rids[it.ExecutorId[i2]] = 0 | ||
258 | + } | ||
259 | + } | ||
260 | + for i := range in.Recipients { | ||
261 | + id := in.Recipients[i] | ||
262 | + id2, _ := strconv.Atoi(id) | ||
263 | + if _, ok := rids[id2]; ok { | ||
264 | + year, month, day := start.Date() | ||
265 | + start0 := time.Date(year, month, day, 0, 0, 0, 0, time.Local) // 当前时间0点0分0秒时刻 | ||
266 | + today := start0.Add(24 * time.Hour).Format("2006-01-02 15:04:05") | ||
267 | + return nil, application.ThrowError(application.BUSINESS_ERROR, fmt.Sprintf("当前时间已有正在进行的项目,请将项目开始时间设置至 %s 之后", today)) | ||
268 | + } | ||
269 | + } | ||
270 | + | ||
240 | if project.State == domain.ProjectStateWaitConfig { | 271 | if project.State == domain.ProjectStateWaitConfig { |
241 | project.State = domain.ProjectStateWaitActive | 272 | project.State = domain.ProjectStateWaitActive |
242 | } | 273 | } |
@@ -264,7 +295,7 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp | @@ -264,7 +295,7 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp | ||
264 | } | 295 | } |
265 | 296 | ||
266 | // 更新项目截止时间,同步任务截止时间 | 297 | // 更新项目截止时间,同步任务截止时间 |
267 | -func (rs *EvaluationProjectService) updateTaskTime(context application.TransactionContext, projectId int64, end time.Time) error { | 298 | +func (rs *EvaluationProjectService) updateTaskTime(context application.TransactionContext, projectId int64, end *time.Time) error { |
268 | // 查看任务过程,重新日计算任务截至期 | 299 | // 查看任务过程,重新日计算任务截至期 |
269 | taskRepository := factory.CreateNodeTaskRepository(map[string]interface{}{"transactionContext": context}) | 300 | taskRepository := factory.CreateNodeTaskRepository(map[string]interface{}{"transactionContext": context}) |
270 | tasks, err := taskRepository.Find(map[string]interface{}{"projectId": projectId}) | 301 | tasks, err := taskRepository.Find(map[string]interface{}{"projectId": projectId}) |
@@ -278,7 +309,10 @@ func (rs *EvaluationProjectService) updateTaskTime(context application.Transacti | @@ -278,7 +309,10 @@ func (rs *EvaluationProjectService) updateTaskTime(context application.Transacti | ||
278 | 309 | ||
279 | for i := range tasks { | 310 | for i := range tasks { |
280 | task := tasks[i] | 311 | task := tasks[i] |
281 | - task.TimeEnd = &end // 先赋值 | 312 | + |
313 | + if end != nil { | ||
314 | + task.TimeEnd = end // 先赋值 | ||
315 | + } | ||
282 | 316 | ||
283 | if task.NextSentAt == nil { // 重新计算 | 317 | if task.NextSentAt == nil { // 重新计算 |
284 | // 环节起始和截止本地时间 | 318 | // 环节起始和截止本地时间 |
@@ -469,11 +503,58 @@ func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand) | @@ -469,11 +503,58 @@ func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand) | ||
469 | if len(project.Recipients) == 0 { | 503 | if len(project.Recipients) == 0 { |
470 | return nil, application.ThrowError(application.BUSINESS_ERROR, "请添加被评估人") | 504 | return nil, application.ThrowError(application.BUSINESS_ERROR, "请添加被评估人") |
471 | } | 505 | } |
472 | - if project.State == domain.TemplateStateEnable { | 506 | + if project.State == domain.ProjectStateEnable { |
473 | return nil, application.ThrowError(application.BUSINESS_ERROR, "项目已启动") | 507 | return nil, application.ThrowError(application.BUSINESS_ERROR, "项目已启动") |
474 | } | 508 | } |
475 | 509 | ||
476 | - project.State = domain.TemplateStateEnable | 510 | + // 周期内的所有项目,已启用的员工不能重复被评估 |
511 | + _, projects, err := projectRepository.Find(map[string]interface{}{"companyId": project.CompanyId, "cycleId": project.CycleId}, "template") | ||
512 | + if err != nil { | ||
513 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
514 | + } | ||
515 | + userMap := map[string]*domain.User{} | ||
516 | + for i := range projects { | ||
517 | + it := projects[i] | ||
518 | + // 排除当前项目 | ||
519 | + if in.Id == it.Id { | ||
520 | + continue | ||
521 | + } | ||
522 | + // 启用状态的被评估人 | ||
523 | + if it.State == domain.ProjectStateEnable { | ||
524 | + for j := range it.Recipients { | ||
525 | + userMap[it.Recipients[j]] = nil | ||
526 | + } | ||
527 | + } | ||
528 | + } | ||
529 | + ids := make([]string, 0) | ||
530 | + for k := range userMap { | ||
531 | + ids = append(ids, k) | ||
532 | + } | ||
533 | + if len(ids) > 0 { | ||
534 | + userRepository := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
535 | + _, users, err := userRepository.Find(map[string]interface{}{"ids": ids}) | ||
536 | + if err != nil { | ||
537 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
538 | + } | ||
539 | + for i := range users { | ||
540 | + s64 := strconv.FormatInt(users[i].Id, 10) | ||
541 | + userMap[s64] = users[i] | ||
542 | + } | ||
543 | + var build strings.Builder | ||
544 | + for i := range project.Recipients { | ||
545 | + id := project.Recipients[i] | ||
546 | + if user, ok := userMap[id]; ok { | ||
547 | + build.WriteString("[") | ||
548 | + build.WriteString(user.Name) | ||
549 | + build.WriteString("]") | ||
550 | + } | ||
551 | + } | ||
552 | + if build.Len() > 0 { | ||
553 | + return nil, application.ThrowError(application.BUSINESS_ERROR, fmt.Sprintf("请先停止%s正在进行的项目", build.String())) | ||
554 | + } | ||
555 | + } | ||
556 | + | ||
557 | + project.State = domain.ProjectStateEnable | ||
477 | project, err = projectRepository.Insert(project) | 558 | project, err = projectRepository.Insert(project) |
478 | if err != nil { | 559 | if err != nil { |
479 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 560 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
@@ -535,6 +616,139 @@ func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand) | @@ -535,6 +616,139 @@ func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand) | ||
535 | return project, nil | 616 | return project, nil |
536 | } | 617 | } |
537 | 618 | ||
619 | +func (rs *EvaluationProjectService) Pause(in *command.ActivateProjectCommand) (interface{}, error) { | ||
620 | + transactionContext, err := factory.ValidateStartTransaction(in) | ||
621 | + if err != nil { | ||
622 | + return nil, err | ||
623 | + } | ||
624 | + defer func() { | ||
625 | + transactionContext.RollbackTransaction() | ||
626 | + }() | ||
627 | + | ||
628 | + projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
629 | + taskRepository := factory.CreateNodeTaskRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
630 | + | ||
631 | + project, err := projectRepository.FindOne(map[string]interface{}{"id": in.Id}) | ||
632 | + if err != nil { | ||
633 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
634 | + } | ||
635 | + if project.State != domain.ProjectStateEnable { | ||
636 | + return nil, application.ThrowError(application.BUSINESS_ERROR, "项目未启动") | ||
637 | + } | ||
638 | + | ||
639 | + project.State = domain.ProjectStatePause | ||
640 | + project, err = projectRepository.Insert(project) | ||
641 | + if err != nil { | ||
642 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
643 | + } | ||
644 | + | ||
645 | + tasks, err := taskRepository.Find(map[string]interface{}{"projectId": project.Id}) | ||
646 | + if err != nil { | ||
647 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
648 | + } | ||
649 | + | ||
650 | + for i := range tasks { | ||
651 | + it := tasks[i] | ||
652 | + it.NextSentAt = nil | ||
653 | + _, err = taskRepository.Insert(it) | ||
654 | + if err != nil { | ||
655 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
656 | + } | ||
657 | + } | ||
658 | + | ||
659 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
660 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
661 | + } | ||
662 | + return project, nil | ||
663 | +} | ||
664 | + | ||
665 | +func (rs *EvaluationProjectService) Resume(in *command.ActivateProjectCommand) (interface{}, error) { | ||
666 | + transactionContext, err := factory.ValidateStartTransaction(in) | ||
667 | + if err != nil { | ||
668 | + return nil, err | ||
669 | + } | ||
670 | + defer func() { | ||
671 | + transactionContext.RollbackTransaction() | ||
672 | + }() | ||
673 | + | ||
674 | + projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
675 | + project, err := projectRepository.FindOne(map[string]interface{}{"id": in.Id}) | ||
676 | + if err != nil { | ||
677 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
678 | + } | ||
679 | + if project.Template == nil { | ||
680 | + return nil, application.ThrowError(application.BUSINESS_ERROR, "请添加评估模板") | ||
681 | + } | ||
682 | + if len(project.Recipients) == 0 { | ||
683 | + return nil, application.ThrowError(application.BUSINESS_ERROR, "请添加被评估人") | ||
684 | + } | ||
685 | + if project.State == domain.ProjectStateEnable { | ||
686 | + return nil, application.ThrowError(application.BUSINESS_ERROR, "项目已启动") | ||
687 | + } | ||
688 | + | ||
689 | + // 周期内的所有项目,已启用的员工不能重复被评估 | ||
690 | + _, projects, err := projectRepository.Find(map[string]interface{}{"companyId": project.CompanyId, "cycleId": project.CycleId}, "template") | ||
691 | + if err != nil { | ||
692 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
693 | + } | ||
694 | + userMap := map[string]*domain.User{} | ||
695 | + for i := range projects { | ||
696 | + it := projects[i] | ||
697 | + // 排除当前项目 | ||
698 | + if in.Id == it.Id { | ||
699 | + continue | ||
700 | + } | ||
701 | + // 启用状态的被评估人 | ||
702 | + if it.State == domain.ProjectStateEnable { | ||
703 | + for j := range it.Recipients { | ||
704 | + userMap[it.Recipients[j]] = nil | ||
705 | + } | ||
706 | + } | ||
707 | + } | ||
708 | + ids := make([]string, 0) | ||
709 | + for k := range userMap { | ||
710 | + ids = append(ids, k) | ||
711 | + } | ||
712 | + if len(ids) > 0 { | ||
713 | + userRepository := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
714 | + _, users, err := userRepository.Find(map[string]interface{}{"ids": ids}) | ||
715 | + if err != nil { | ||
716 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
717 | + } | ||
718 | + for i := range users { | ||
719 | + s64 := strconv.FormatInt(users[i].Id, 10) | ||
720 | + userMap[s64] = users[i] | ||
721 | + } | ||
722 | + var build strings.Builder | ||
723 | + for i := range project.Recipients { | ||
724 | + id := project.Recipients[i] | ||
725 | + if user, ok := userMap[id]; ok { | ||
726 | + build.WriteString("[") | ||
727 | + build.WriteString(user.Name) | ||
728 | + build.WriteString("]") | ||
729 | + } | ||
730 | + } | ||
731 | + if build.Len() > 0 { | ||
732 | + return nil, application.ThrowError(application.BUSINESS_ERROR, fmt.Sprintf("请先停止%s正在进行的项目", build.String())) | ||
733 | + } | ||
734 | + } | ||
735 | + | ||
736 | + project.State = domain.ProjectStateEnable | ||
737 | + project, err = projectRepository.Insert(project) | ||
738 | + if err != nil { | ||
739 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
740 | + } | ||
741 | + // 项目恢复,同步更新任务时间 | ||
742 | + if err = rs.updateTaskTime(transactionContext, in.Id, nil); err != nil { | ||
743 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
744 | + } | ||
745 | + | ||
746 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
747 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
748 | + } | ||
749 | + return project, nil | ||
750 | +} | ||
751 | + | ||
538 | func (rs *EvaluationProjectService) Copy(in *command.CopyProjectCommand) (interface{}, error) { | 752 | func (rs *EvaluationProjectService) Copy(in *command.CopyProjectCommand) (interface{}, error) { |
539 | transactionContext, err := factory.ValidateStartTransaction(in) | 753 | transactionContext, err := factory.ValidateStartTransaction(in) |
540 | if err != nil { | 754 | if err != nil { |
@@ -555,7 +769,7 @@ func (rs *EvaluationProjectService) Copy(in *command.CopyProjectCommand) (interf | @@ -555,7 +769,7 @@ func (rs *EvaluationProjectService) Copy(in *command.CopyProjectCommand) (interf | ||
555 | project.Recipients = make([]string, 0) // 重置被评估人 | 769 | project.Recipients = make([]string, 0) // 重置被评估人 |
556 | 770 | ||
557 | // 如果拷贝已经启用的模板,默认先设置为待启用 | 771 | // 如果拷贝已经启用的模板,默认先设置为待启用 |
558 | - if project.State == domain.ProjectStateEnable { | 772 | + if project.State == domain.ProjectStateEnable || project.State == domain.ProjectStatePause { |
559 | project.State = domain.ProjectStateWaitActive | 773 | project.State = domain.ProjectStateWaitActive |
560 | } | 774 | } |
561 | project, err = projectRepository.Insert(project) | 775 | project, err = projectRepository.Insert(project) |
@@ -587,11 +801,14 @@ func (rs *EvaluationProjectService) CheckRecipients(in *command.CheckRecipientCo | @@ -587,11 +801,14 @@ func (rs *EvaluationProjectService) CheckRecipients(in *command.CheckRecipientCo | ||
587 | // 周期内的所有项目,员工不能重复被评估 | 801 | // 周期内的所有项目,员工不能重复被评估 |
588 | rids := map[string]bool{} | 802 | rids := map[string]bool{} |
589 | for i := range projects { | 803 | for i := range projects { |
804 | + it := projects[i] | ||
590 | // 排除当前项目 | 805 | // 排除当前项目 |
591 | - if in.Id != projects[i].Id { | ||
592 | - ids := projects[i].Recipients | ||
593 | - for j := range ids { | ||
594 | - rids[ids[j]] = true | 806 | + if in.Id == it.Id { |
807 | + continue | ||
808 | + } | ||
809 | + if it.State == domain.ProjectStateEnable { | ||
810 | + for j := range it.Recipients { | ||
811 | + rids[it.Recipients[j]] = true | ||
595 | } | 812 | } |
596 | } | 813 | } |
597 | } | 814 | } |
@@ -23,3 +23,40 @@ type AssessInfoResp struct { | @@ -23,3 +23,40 @@ type AssessInfoResp struct { | ||
23 | DutyTime string `json:"dutyTime"` //入职时间 // | 23 | DutyTime string `json:"dutyTime"` //入职时间 // |
24 | AssessContent []*domain.StaffAssessContent `json:"assessContent"` //评估内容 | 24 | AssessContent []*domain.StaffAssessContent `json:"assessContent"` //评估内容 |
25 | } | 25 | } |
26 | + | ||
27 | +// 周期内的每日自评小结 | ||
28 | +type AssessCountLevelResp struct { | ||
29 | + CycleId int64 `json:"cycleId,string"` //周期id | ||
30 | + CycleName string `json:"cycleName"` //周期名称 | ||
31 | + EvaluationProjectId int `json:"evaluationProjectId,string"` //项目id | ||
32 | + EvaluationProjectName string `json:"evaluationProjectName"` //项目名称 | ||
33 | + TargetUserId int `json:"targetUserId,string"` //被评估的目标用户,被执行的 | ||
34 | + TargetUserName string `json:"targetUserName"` // | ||
35 | + CompanyLogo string `json:"companyLogo,"` //公司logo | ||
36 | + CompanyName string `json:"companyName"` //公司名称 | ||
37 | + SupperUser string `json:"superUser"` //目标用户的上级 | ||
38 | + DutyTime string `json:"dutyTime"` //入职时间 | ||
39 | + EvaluationItems []AssessCountLeveltItem `json:"evaluationItems"` | ||
40 | +} | ||
41 | + | ||
42 | +type AssessCountLeveltItem struct { | ||
43 | + EvaluationItemId int `json:"evaluationItemId,string"` //评估条目的id | ||
44 | + SortBy int `json:"sortBy"` //排序 | ||
45 | + Category string `json:"category"` //类别 | ||
46 | + Name string `json:"name"` //名称 | ||
47 | + PromptTitle string `json:"promptTitle"` //提示项标题 | ||
48 | + PromptText string `json:"promptText"` //提示项正文 | ||
49 | + EntryItems []*domain.EntryItem `json:"entryItems"` //填写的反馈 | ||
50 | + RuleType int `json:"ruleType"` //评估方式(0评级、1评分) | ||
51 | + Rule domain.EvaluationRule `json:"rule"` //评估的选项规则 | ||
52 | + Weight float64 `json:"weight"` //"权重" | ||
53 | + Remark string `json:"remark"` //填写的内容反馈 | ||
54 | + EvaluatorId int `json:"evaluatorId"` //评估人id | ||
55 | + LevelCount []LevalCodeCount `json:"levelCount"` //周期内每次评估的等级数量统计 | ||
56 | +} | ||
57 | + | ||
58 | +// 评级数量 | ||
59 | +type LevalCodeCount struct { | ||
60 | + Code string `json:"code"` //评级代码 | ||
61 | + Number int `json:"number"` //数量 | ||
62 | +} |
@@ -14,3 +14,10 @@ type ExportUserAssess2Commad struct { | @@ -14,3 +14,10 @@ type ExportUserAssess2Commad struct { | ||
14 | OperatorId int `cname:"操作人ID" json:"operatorId"` | 14 | OperatorId int `cname:"操作人ID" json:"operatorId"` |
15 | ExportUserId []string `cname:"指定员工数据导出" json:"exportUserId"` | 15 | ExportUserId []string `cname:"指定员工数据导出" json:"exportUserId"` |
16 | } | 16 | } |
17 | + | ||
18 | +type StaffAsessSelfCountLevel struct { | ||
19 | + CompanyId int `cname:"公司ID" json:"-"` | ||
20 | + TargetUserId int `json:"targetUserId,string"` | ||
21 | + ProjectId int `json:"projectId,string"` | ||
22 | + CycleId int `cname:"周期ID" json:"cycleId,string"` | ||
23 | +} |
@@ -13,7 +13,7 @@ type MemberSummaryListCommand struct { | @@ -13,7 +13,7 @@ type MemberSummaryListCommand struct { | ||
13 | // MemberPerformanceIndicatorCommand 成员绩效导出-指标 | 13 | // MemberPerformanceIndicatorCommand 成员绩效导出-指标 |
14 | type MemberPerformanceIndicatorCommand struct { | 14 | type MemberPerformanceIndicatorCommand struct { |
15 | CycleId int `cname:"周期ID" json:"cycleId,string"` | 15 | CycleId int `cname:"周期ID" json:"cycleId,string"` |
16 | - UserName string `cname:"用户名称" json:"userName"` | 16 | + UserName string `cname:"搜索用户名称" json:"userName"` |
17 | UserIds []string `cname:"用户ID" json:"userIds"` | 17 | UserIds []string `cname:"用户ID" json:"userIds"` |
18 | CompanyId int `cname:"公司ID" json:"companyId"` | 18 | CompanyId int `cname:"公司ID" json:"companyId"` |
19 | OperatorId int `cname:"操作人ID" json:"operatorId"` | 19 | OperatorId int `cname:"操作人ID" json:"operatorId"` |
1 | +package service | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "strings" | ||
6 | + | ||
7 | + "github.com/linmadan/egglib-go/core/application" | ||
8 | + "github.com/xuri/excelize/v2" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/query" | ||
11 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao" | ||
12 | +) | ||
13 | + | ||
14 | +// 员工绩效-综合管理-导出绩效-个人 | ||
15 | +func (srv *StaffAssessServeice) ExportUserAssess2V2(param *query.ExportUserAssess2Commad) (*excelize.File, error) { | ||
16 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
17 | + if err != nil { | ||
18 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
19 | + } | ||
20 | + if err := transactionContext.StartTransaction(); err != nil { | ||
21 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
22 | + } | ||
23 | + defer func() { | ||
24 | + _ = transactionContext.RollbackTransaction() | ||
25 | + }() | ||
26 | + hrbp, err := srv.getHRBP(transactionContext, param.CompanyId, param.OperatorId) | ||
27 | + if err != nil { | ||
28 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
29 | + } | ||
30 | + assessDao := dao.NewStaffAssessDao(map[string]interface{}{ | ||
31 | + "transactionContext": transactionContext, | ||
32 | + }) | ||
33 | + // 按照cycleId获取项目的指标项 | ||
34 | + evaluationItemList, err := assessDao.SearchEvaluationItemUsed2(param.CompanyId, | ||
35 | + param.CycleId, param.OperatorId, hrbp, param.ExportUserId) | ||
36 | + if err != nil { | ||
37 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
38 | + } | ||
39 | + // 按照项目获取填写的内容 | ||
40 | + assessContentList, err := assessDao.SearchStaffAssessContent2(param.CompanyId, | ||
41 | + param.CycleId, param.OperatorId, hrbp, param.ExportUserId) | ||
42 | + if err != nil { | ||
43 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
44 | + } | ||
45 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
46 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
47 | + } | ||
48 | + eData := newExportData3() | ||
49 | + eData.FormatTableHead(evaluationItemList) | ||
50 | + eData.FormatListValue(assessContentList) | ||
51 | + xlsxFile := excelize.NewFile() | ||
52 | + //设置默认的第一个sheet | ||
53 | + sheetIndex := xlsxFile.GetActiveSheetIndex() | ||
54 | + firstSheetName := xlsxFile.GetSheetName(sheetIndex) | ||
55 | + cycleName := "" | ||
56 | + if len(evaluationItemList) > 0 { | ||
57 | + cycleName = evaluationItemList[0].CycleName | ||
58 | + } | ||
59 | + for k1, val := range eData.userProjcetMap { | ||
60 | + for k2, val2 := range val { | ||
61 | + // 根据员工名称 添加一个sheet | ||
62 | + uname := eData.userIdName[k1] | ||
63 | + if len(uname) == 0 { | ||
64 | + continue | ||
65 | + } | ||
66 | + tableHeader, ok := eData.tableHeader[eData.tableHeaderKey(k1, val2)] | ||
67 | + if !ok { | ||
68 | + continue | ||
69 | + } | ||
70 | + | ||
71 | + newSheetName := uname + fmt.Sprintf("_%d", k2+1) | ||
72 | + xlsxFile.NewSheet(newSheetName) | ||
73 | + xlsxFile.SetCellStr(newSheetName, "B2", uname) | ||
74 | + xlsxFile.MergeCell(newSheetName, "B2", "B4") | ||
75 | + //填充第一列数据 | ||
76 | + xlsxFile.SetCellStr(newSheetName, "A1", tableHeader.Name) | ||
77 | + xlsxFile.SetCellStr(newSheetName, "A2", cycleName) | ||
78 | + xlsxFile.MergeCell(newSheetName, "A2", "A4") | ||
79 | + xlsxFile.SetCellStr(newSheetName, "A5", "权重") | ||
80 | + xlsxFile.MergeCell(newSheetName, "A5", "B5") | ||
81 | + xlsxFile.SetCellStr(newSheetName, "A6", "评估标准") | ||
82 | + xlsxFile.MergeCell(newSheetName, "A6", "B6") | ||
83 | + // 日期 | ||
84 | + dayList := eData.userDayMap[eData.userDayKey(k1, val2)] | ||
85 | + for ii, vv := range dayList { | ||
86 | + //填写在第几行 | ||
87 | + axisNum := 7 + 3*ii | ||
88 | + axis := fmt.Sprintf("A%d", axisNum) | ||
89 | + xlsxFile.SetCellStr(newSheetName, axis, vv) | ||
90 | + axisEnd := fmt.Sprintf("B%d", axisNum+2) | ||
91 | + xlsxFile.MergeCell(newSheetName, axis, axisEnd) //单元格高度按三个单元格合并 | ||
92 | + } | ||
93 | + allColNum := 0 //计算总共有多少列 | ||
94 | + //第一行 | ||
95 | + for _, v2 := range tableHeader.Child { | ||
96 | + | ||
97 | + //第二行 | ||
98 | + for _, v3 := range v2.Child { | ||
99 | + //第三行 | ||
100 | + for _, v4 := range v3.Child { | ||
101 | + allColNum++ | ||
102 | + //按列填充数据 | ||
103 | + colName, _ := excelize.ColumnNumberToName(allColNum + 2) //第3列开始 | ||
104 | + xlsxFile.SetCellStr(newSheetName, colName+"2", v2.Name) //分类 | ||
105 | + xlsxFile.SetCellStr(newSheetName, colName+"3", v3.Name) //加分项 得分项 | ||
106 | + xlsxFile.SetCellStr(newSheetName, colName+"4", v4.Name) // 评估项名称 | ||
107 | + //权重 填写第5行数据 | ||
108 | + k23 := eData.data23Key(k1, v2.Name, v3.Name, v4.Name) | ||
109 | + xlsxFile.SetCellStr(newSheetName, colName+"5", eData.data3[k23]) | ||
110 | + //评估标准 填写第6行数据 | ||
111 | + xlsxFile.SetCellStr(newSheetName, colName+"6", eData.data2[k23]) | ||
112 | + //按日期填充评估的填写的值 | ||
113 | + for i5, v5 := range dayList { | ||
114 | + k1 := eData.dataKey(k1, val2, v5, v2.Name, v3.Name, v4.Name) | ||
115 | + //填写在第几行 | ||
116 | + axisNum := 7 + 3*i5 | ||
117 | + axis := fmt.Sprintf("%s%d", colName, axisNum) | ||
118 | + if d, ok := eData.data[k1]; ok { | ||
119 | + xlsxFile.SetCellStr(newSheetName, axis, d.String()) | ||
120 | + } | ||
121 | + //单元格高度按三个单元格合并 | ||
122 | + axisEnd := fmt.Sprintf("%s%d", colName, axisNum+2) | ||
123 | + xlsxFile.MergeCell(newSheetName, axis, axisEnd) | ||
124 | + } | ||
125 | + } | ||
126 | + } | ||
127 | + } | ||
128 | + // | ||
129 | + colName, _ := excelize.ColumnNumberToName(allColNum + 2) | ||
130 | + xlsxFile.MergeCell(newSheetName, "A1", fmt.Sprintf("%s1", colName)) | ||
131 | + } | ||
132 | + } | ||
133 | + //删除默认的第一个sheet | ||
134 | + xlsxFile.DeleteSheet(firstSheetName) | ||
135 | + return xlsxFile, nil | ||
136 | +} | ||
137 | + | ||
138 | +// 处理原始数据,方便进行 excel导出 | ||
139 | +type exportData3 struct { | ||
140 | + userIdName map[string]string //员工id对应的名字 id=>员工名称 | ||
141 | + userProjcetMap map[string][]string //员工的项目 员工id=>项目id | ||
142 | + tableHeader map[string]*HeaderLevel //表头数据 key=员工id+项目id | ||
143 | + userDayMap map[string][]string //每个员工对应的日期列表 key=员工id+项目id value= 日期列表 | ||
144 | + data map[string]*strings.Builder //每个员工表头对应的评估填写的数据 key=员工id+项目id+日期+表头 | ||
145 | + data2 map[string]string //每个员工评估项的标准描述 key=员工id+项目id+表头 | ||
146 | + data3 map[string]string //每个员工评估项的标准权重 key=员工id+项目id+表头 | ||
147 | +} | ||
148 | + | ||
149 | +func newExportData3() *exportData3 { | ||
150 | + return &exportData3{ | ||
151 | + userIdName: map[string]string{}, | ||
152 | + userProjcetMap: map[string][]string{}, | ||
153 | + tableHeader: map[string]*HeaderLevel{}, | ||
154 | + userDayMap: map[string][]string{}, | ||
155 | + data: map[string]*strings.Builder{}, | ||
156 | + data2: map[string]string{}, data3: map[string]string{}} | ||
157 | +} | ||
158 | + | ||
159 | +func (e *exportData3) FormatTableHead(param []dao.DataEvaluationItemUsed2) { | ||
160 | + userNameMap := map[string]struct{}{} //员工名字过滤 | ||
161 | + projectIdMap := map[string]struct{}{} //项目id过滤 | ||
162 | + for _, val := range param { | ||
163 | + // | ||
164 | + if _, ok := e.userProjcetMap[val.TargetUserId]; !ok { | ||
165 | + e.userProjcetMap[val.TargetUserId] = []string{} | ||
166 | + } | ||
167 | + //处理一个员工多项目的情况 | ||
168 | + if _, ok := projectIdMap[val.EvaluationProjectId]; !ok { | ||
169 | + e.userProjcetMap[val.TargetUserId] = append(e.userProjcetMap[val.TargetUserId], val.EvaluationProjectId) | ||
170 | + projectIdMap[val.EvaluationProjectId] = struct{}{} | ||
171 | + } | ||
172 | + //处理员工的名称 | ||
173 | + if _, ok := e.userIdName[val.TargetUserId]; !ok { | ||
174 | + if _, ok := userNameMap[val.TargetUserName]; ok { | ||
175 | + //员工重名 | ||
176 | + uname := fmt.Sprintf("%s(%d)", val.TargetUserName, len(userNameMap)) | ||
177 | + e.userIdName[val.TargetUserId] = uname | ||
178 | + userNameMap[uname] = struct{}{} | ||
179 | + } else { | ||
180 | + e.userIdName[val.TargetUserId] = val.TargetUserName | ||
181 | + userNameMap[val.TargetUserName] = struct{}{} | ||
182 | + } | ||
183 | + } | ||
184 | + //每个员工对应的日期列表 | ||
185 | + key1 := e.tableHeaderKey(val.TargetUserId, val.EvaluationProjectId) | ||
186 | + if _, ok := e.tableHeader[key1]; !ok { | ||
187 | + e.tableHeader[key1] = &HeaderLevel{ | ||
188 | + Name: "个人绩效评估等级统计表", | ||
189 | + Filter: map[string]int{}, | ||
190 | + Child: []HeaderLevel{}, | ||
191 | + } | ||
192 | + } | ||
193 | + child := e.tableHeader[key1].addChild(val.Category) //第一级,"分类" | ||
194 | + weight := e.weightDesc(val.Weight) | ||
195 | + child = child.addChild(weight) //第二级 '得分项' '加分项' | ||
196 | + child.addChild(val.ContentName) //第三级 评估项名称 | ||
197 | + } | ||
198 | +} | ||
199 | + | ||
200 | +func (e *exportData3) FormatListValue(param []dao.DataStaffAssessContent2) { | ||
201 | + userDay := map[string]struct{}{} | ||
202 | + for _, val := range param { | ||
203 | + weight := e.weightDesc(val.Weight) | ||
204 | + key := e.dataKey(val.TargetUserId, val.EvaluationProjectId, val.BeginDay, val.Category, weight, val.ContentName) | ||
205 | + e.data[key] = &strings.Builder{} | ||
206 | + e.data[key].WriteString(val.Value + "\n") //填写的等级 | ||
207 | + for _, vv := range val.Remark { | ||
208 | + e.data[key].WriteString(vv.Title + "\n") | ||
209 | + e.data[key].WriteString(vv.RemarkText + "\n") | ||
210 | + } | ||
211 | + dayKey := val.TargetUserId + val.EvaluationProjectId + val.BeginDay | ||
212 | + if _, ok := userDay[dayKey]; !ok { | ||
213 | + userDay[dayKey] = struct{}{} | ||
214 | + k := e.userDayKey(val.TargetUserId, val.EvaluationProjectId) | ||
215 | + e.userDayMap[k] = append(e.userDayMap[k], val.BeginDay) | ||
216 | + } | ||
217 | + key23 := e.data23Key(val.TargetUserId, val.Category, weight, val.ContentName) | ||
218 | + e.data2[key23] = val.PromptText | ||
219 | + if val.Weight == 0 { | ||
220 | + e.data3[key23] = "" | ||
221 | + } else { | ||
222 | + e.data3[key23] = fmt.Sprintf("%.2f%%", val.Weight) | ||
223 | + } | ||
224 | + } | ||
225 | +} | ||
226 | + | ||
227 | +func (e *exportData3) weightDesc(weight float64) string { | ||
228 | + if weight == 0 { | ||
229 | + return "加分项" | ||
230 | + } else { | ||
231 | + return "得分项" | ||
232 | + } | ||
233 | +} | ||
234 | + | ||
235 | +func (e *exportData3) dataKey(userId string, projectId string, beginDay string, category string, weight string, contentName string) string { | ||
236 | + key := fmt.Sprintf("%s-%s-%s-%s-%s-%s", userId, projectId, weight, beginDay, category, contentName) | ||
237 | + return key | ||
238 | +} | ||
239 | + | ||
240 | +func (e *exportData3) data23Key(userId string, category string, weight string, contentName string) string { | ||
241 | + key := fmt.Sprintf("%s-%s-%s-%s", userId, weight, category, contentName) | ||
242 | + return key | ||
243 | +} | ||
244 | + | ||
245 | +func (e *exportData3) userDayKey(userId string, projectId string) string { | ||
246 | + return fmt.Sprintf("%s-%s", userId, projectId) | ||
247 | +} | ||
248 | + | ||
249 | +func (e *exportData3) tableHeaderKey(targetUserId, evaluationProjectId string) string { | ||
250 | + return targetUserId + "-" + evaluationProjectId | ||
251 | +} |
@@ -31,34 +31,9 @@ func (h *HeaderLevel) addChild(name string) (child *HeaderLevel) { | @@ -31,34 +31,9 @@ func (h *HeaderLevel) addChild(name string) (child *HeaderLevel) { | ||
31 | return &h.Child[cIndex] | 31 | return &h.Child[cIndex] |
32 | } | 32 | } |
33 | 33 | ||
34 | -// 获取表头的所有列表名 | ||
35 | -// func (h *HeaderLevel) collectAllColumn(all *[][]string) { | ||
36 | -// for _, v := range h.Child { | ||
37 | -// v.collectColumn(&v, all, nil) | ||
38 | -// } | ||
39 | -// } | ||
40 | - | ||
41 | -// func (h *HeaderLevel) collectColumn(child *HeaderLevel, columns *[][]string, column *[]string) { | ||
42 | -// if column == nil { | ||
43 | -// column = &[]string{} | ||
44 | -// } | ||
45 | -// *column = append(*column, h.Name) | ||
46 | -// for _, v := range child.Child { | ||
47 | -// if len(v.Child) > 0 { | ||
48 | -// v.collectColumn(&v, columns, column) | ||
49 | -// } | ||
50 | -// if len(v.Child) == 0 { | ||
51 | -// item := make([]string, len(*column)) | ||
52 | -// copy(item, *column) | ||
53 | -// item = append(item, v.Name) | ||
54 | -// *columns = append(*columns, item) | ||
55 | -// } | ||
56 | -// } | ||
57 | -// } | ||
58 | - | ||
59 | type exportData struct { | 34 | type exportData struct { |
60 | userName []string //员工的名称列表 ,对应excel文件的多个sheet | 35 | userName []string //员工的名称列表 ,对应excel文件的多个sheet |
61 | - usrIdMap map[string]string | 36 | + usrIdMap map[string]string //员工id对应的名字 |
62 | userDayMap map[string][]string //每个员工对应的日期列表 key=员工名称 value= 日期列表 | 37 | userDayMap map[string][]string //每个员工对应的日期列表 key=员工名称 value= 日期列表 |
63 | tableHeader map[string]*HeaderLevel //每个员工数据表格对应表头 key=员工名称 | 38 | tableHeader map[string]*HeaderLevel //每个员工数据表格对应表头 key=员工名称 |
64 | data map[string]*strings.Builder //每个员工表头对应的评估填写的数据 key=员工名称+日期+表头 | 39 | data map[string]*strings.Builder //每个员工表头对应的评估填写的数据 key=员工名称+日期+表头 |
@@ -156,10 +131,6 @@ func (e *exportData) weightDesc(weight float64) string { | @@ -156,10 +131,6 @@ func (e *exportData) weightDesc(weight float64) string { | ||
156 | } | 131 | } |
157 | } | 132 | } |
158 | 133 | ||
159 | -// func (e *exportData) userDayKey(userName string) string { | ||
160 | -// return userName | ||
161 | -// } | ||
162 | - | ||
163 | type exportData2 struct { | 134 | type exportData2 struct { |
164 | tableHeader HeaderLevel //数据表格对应表头 | 135 | tableHeader HeaderLevel //数据表格对应表头 |
165 | userIdMap map[string]string //员工id 对应的名称 | 136 | userIdMap map[string]string //员工id 对应的名称 |
@@ -14,6 +14,7 @@ import ( | @@ -14,6 +14,7 @@ import ( | ||
14 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/command" | 14 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/command" |
15 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/query" | 15 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/query" |
16 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | 16 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" |
17 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao" | ||
17 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log" | 18 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log" |
18 | ) | 19 | ) |
19 | 20 | ||
@@ -241,11 +242,23 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(transactionContext applicat | @@ -241,11 +242,23 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(transactionContext applicat | ||
241 | assassessTaskList[0].ExecutorId = executorIds | 242 | assassessTaskList[0].ExecutorId = executorIds |
242 | //更新步骤 | 243 | //更新步骤 |
243 | assassessTaskList[0].StepList = append(assassessTaskList[0].StepList, assessTaskData.StepList...) | 244 | assassessTaskList[0].StepList = append(assassessTaskList[0].StepList, assessTaskData.StepList...) |
245 | + for _, val := range assessTaskData.StepList { | ||
246 | + hasFound := false | ||
247 | + for _, val2 := range assassessTaskList[0].StepList { | ||
248 | + if val.LinkNodeType == val2.LinkNodeType { | ||
249 | + hasFound = true | ||
250 | + break | ||
251 | + } | ||
252 | + } | ||
253 | + if !hasFound { | ||
254 | + assassessTaskList[0].StepList = append(assassessTaskList[0].StepList, val) | ||
255 | + } | ||
256 | + } | ||
244 | assessTaskData = assassessTaskList[0] | 257 | assessTaskData = assassessTaskList[0] |
245 | //排序流程环节 | 258 | //排序流程环节 |
259 | + } | ||
246 | stepList := domain.SortTaskStep(assessTaskData.StepList) | 260 | stepList := domain.SortTaskStep(assessTaskData.StepList) |
247 | sort.Sort(stepList) | 261 | sort.Sort(stepList) |
248 | - } | ||
249 | _, err = assessTaskRepo.Save(assessTaskData) | 262 | _, err = assessTaskRepo.Save(assessTaskData) |
250 | if err != nil { | 263 | if err != nil { |
251 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存评估任务"+err.Error()) | 264 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存评估任务"+err.Error()) |
@@ -346,7 +359,10 @@ func (srv StaffAssessServeice) createStaffAssess(transactionContext application. | @@ -346,7 +359,10 @@ func (srv StaffAssessServeice) createStaffAssess(transactionContext application. | ||
346 | stepSelfTemp.LinkNodeId = v.LinkNodeId | 359 | stepSelfTemp.LinkNodeId = v.LinkNodeId |
347 | stepSelfTemp.LinkNodeName = v.LinkNodeName | 360 | stepSelfTemp.LinkNodeName = v.LinkNodeName |
348 | stepSelfTemp.Types = domain.AssessSelf | 361 | stepSelfTemp.Types = domain.AssessSelf |
349 | - assessListTemp := srv.createStaffAssessSelf(stepSelfTemp, userList, userDepartmentMap) | 362 | + assessListTemp, err := srv.createStaffAssessSelf(transactionContext, stepSelfTemp, userList, userDepartmentMap) |
363 | + if err != nil { | ||
364 | + return nil, err | ||
365 | + } | ||
350 | assessList = append(assessList, assessListTemp...) | 366 | assessList = append(assessList, assessListTemp...) |
351 | } | 367 | } |
352 | if v.LinkNodeType == domain.LinkNodeSuperiorAssessment { | 368 | if v.LinkNodeType == domain.LinkNodeSuperiorAssessment { |
@@ -367,10 +383,28 @@ func (srv StaffAssessServeice) createStaffAssess(transactionContext application. | @@ -367,10 +383,28 @@ func (srv StaffAssessServeice) createStaffAssess(transactionContext application. | ||
367 | } | 383 | } |
368 | 384 | ||
369 | // 构建员工自评 | 385 | // 构建员工自评 |
370 | -func (srv StaffAssessServeice) createStaffAssessSelf(assessTemp domain.StaffAssess, | ||
371 | - userList []*domain.User, userDepartmentMap map[int64][]*domain.Department) []domain.StaffAssess { | ||
372 | - result := []domain.StaffAssess{} | ||
373 | - for _, usr := range userList { | 386 | +func (srv StaffAssessServeice) createStaffAssessSelf( |
387 | + transactionContext application.TransactionContext, | ||
388 | + assessTemp domain.StaffAssess, | ||
389 | + userList []*domain.User, | ||
390 | + userDepartmentMap map[int64][]*domain.Department) ([]domain.StaffAssess, error) { | ||
391 | + assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{ | ||
392 | + "transactionContext": transactionContext, | ||
393 | + }) | ||
394 | + beginDay := assessTemp.BeginTime.Format("2006-01-02") | ||
395 | + _, assessListOld, err := assessRepo.Find(map[string]interface{}{"cycleId": assessTemp.CycleId, "beginDay": beginDay, "types": domain.AssessSelf}) | ||
396 | + if err != nil { | ||
397 | + return nil, err | ||
398 | + } | ||
399 | + userMapReal := map[int]*domain.User{} | ||
400 | + for _, val := range userList { | ||
401 | + userMapReal[int(val.Id)] = val | ||
402 | + } | ||
403 | + for _, val := range assessListOld { | ||
404 | + delete(userMapReal, val.TargetUser.UserId) | ||
405 | + } | ||
406 | + assessListNew := []domain.StaffAssess{} | ||
407 | + for _, usr := range userMapReal { | ||
374 | assessTemp.TargetUser = domain.StaffDesc{ | 408 | assessTemp.TargetUser = domain.StaffDesc{ |
375 | UserId: int(usr.Id), | 409 | UserId: int(usr.Id), |
376 | Account: usr.Account, | 410 | Account: usr.Account, |
@@ -389,9 +423,9 @@ func (srv StaffAssessServeice) createStaffAssessSelf(assessTemp domain.StaffAsse | @@ -389,9 +423,9 @@ func (srv StaffAssessServeice) createStaffAssessSelf(assessTemp domain.StaffAsse | ||
389 | }) | 423 | }) |
390 | } | 424 | } |
391 | } | 425 | } |
392 | - result = append(result, assessTemp) | 426 | + assessListNew = append(assessListNew, assessTemp) |
393 | } | 427 | } |
394 | - return result | 428 | + return assessListNew, nil |
395 | } | 429 | } |
396 | 430 | ||
397 | // 构建员工的上级评估 | 431 | // 构建员工的上级评估 |
@@ -400,8 +434,24 @@ func (srv StaffAssessServeice) createStaffAssessSupper( | @@ -400,8 +434,24 @@ func (srv StaffAssessServeice) createStaffAssessSupper( | ||
400 | assessTemp domain.StaffAssess, | 434 | assessTemp domain.StaffAssess, |
401 | userList []*domain.User, userDepartmentMap map[int64][]*domain.Department, | 435 | userList []*domain.User, userDepartmentMap map[int64][]*domain.Department, |
402 | ) ([]domain.StaffAssess, error) { | 436 | ) ([]domain.StaffAssess, error) { |
403 | - var assessList []domain.StaffAssess | ||
404 | - for _, v := range userList { | 437 | + assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{ |
438 | + "transactionContext": transactionContext, | ||
439 | + }) | ||
440 | + beginDay := assessTemp.BeginTime.Format("2006-01-02") | ||
441 | + _, assessListOld, err := assessRepo.Find(map[string]interface{}{"cycleId": assessTemp.CycleId, "beginDay": beginDay, "types": domain.AssessSuper}) | ||
442 | + if err != nil { | ||
443 | + return nil, err | ||
444 | + } | ||
445 | + userMapReal := map[int]*domain.User{} | ||
446 | + for _, val := range userList { | ||
447 | + userMapReal[int(val.Id)] = val | ||
448 | + } | ||
449 | + for _, val := range assessListOld { | ||
450 | + delete(userMapReal, val.TargetUser.UserId) | ||
451 | + } | ||
452 | + | ||
453 | + var assessListNew []domain.StaffAssess | ||
454 | + for _, v := range userMapReal { | ||
405 | //获取上级 | 455 | //获取上级 |
406 | chargeUserList, err := srv.getStaffSuper(transactionContext, *v) | 456 | chargeUserList, err := srv.getStaffSuper(transactionContext, *v) |
407 | if err != nil { | 457 | if err != nil { |
@@ -431,11 +481,11 @@ func (srv StaffAssessServeice) createStaffAssessSupper( | @@ -431,11 +481,11 @@ func (srv StaffAssessServeice) createStaffAssessSupper( | ||
431 | } | 481 | } |
432 | } | 482 | } |
433 | assessTemp.TargetDepartment = targetDepartment | 483 | assessTemp.TargetDepartment = targetDepartment |
434 | - assessList = append(assessList, assessTemp) | 484 | + assessListNew = append(assessListNew, assessTemp) |
435 | } | 485 | } |
436 | 486 | ||
437 | } | 487 | } |
438 | - return assessList, nil | 488 | + return assessListNew, nil |
439 | } | 489 | } |
440 | 490 | ||
441 | // 获取某个员工360评估邀请的人员 | 491 | // 获取某个员工360评估邀请的人员 |
@@ -1124,3 +1174,167 @@ func (srv StaffAssessServeice) recoverAssessCache(context application.Transactio | @@ -1124,3 +1174,167 @@ func (srv StaffAssessServeice) recoverAssessCache(context application.Transactio | ||
1124 | } | 1174 | } |
1125 | } | 1175 | } |
1126 | } | 1176 | } |
1177 | + | ||
1178 | +// 获取目标员工自评周期列表 | ||
1179 | +func (srv StaffAssessServeice) ListTargetUserSelfCycle(param *query.ListTargetUserCycleQuery) (map[string]interface{}, error) { | ||
1180 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
1181 | + if err != nil { | ||
1182 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
1183 | + } | ||
1184 | + if err := transactionContext.StartTransaction(); err != nil { | ||
1185 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
1186 | + } | ||
1187 | + defer func() { | ||
1188 | + _ = transactionContext.RollbackTransaction() | ||
1189 | + }() | ||
1190 | + staffAssessDao := dao.NewStaffAssessDao(map[string]interface{}{ | ||
1191 | + "transactionContext": transactionContext, | ||
1192 | + }) | ||
1193 | + var limit int = 1000 | ||
1194 | + var offset int = 0 | ||
1195 | + if param.PageSize > 0 { | ||
1196 | + limit = param.PageSize | ||
1197 | + } | ||
1198 | + offset = (param.PageNumber - 1) * param.PageSize | ||
1199 | + | ||
1200 | + cycleList, err := staffAssessDao.SearchTargetUserCycleProject(param.CompanyId, param.TargetUserId, limit, offset) | ||
1201 | + if err != nil { | ||
1202 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
1203 | + } | ||
1204 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
1205 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
1206 | + } | ||
1207 | + | ||
1208 | + return tool_funs.SimpleWrapGridMap(int64(len(cycleList)), cycleList), nil | ||
1209 | +} | ||
1210 | + | ||
1211 | +// 按照周期获取员工的每日自评小结 | ||
1212 | +func (srv StaffAssessServeice) GetStaffAsessSelfCountLevel(param *query.StaffAsessSelfCountLevel) (*adapter.AssessCountLevelResp, error) { | ||
1213 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
1214 | + if err != nil { | ||
1215 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
1216 | + } | ||
1217 | + if err := transactionContext.StartTransaction(); err != nil { | ||
1218 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
1219 | + } | ||
1220 | + defer func() { | ||
1221 | + _ = transactionContext.RollbackTransaction() | ||
1222 | + }() | ||
1223 | + // 统计周期内,评估项等级的数量 | ||
1224 | + assessDao := dao.NewStaffAssessDao(map[string]interface{}{ | ||
1225 | + "transactionContext": transactionContext, | ||
1226 | + }) | ||
1227 | + evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{ | ||
1228 | + "transactionContext": transactionContext, | ||
1229 | + }) | ||
1230 | + assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{ | ||
1231 | + "transactionContext": transactionContext, | ||
1232 | + }) | ||
1233 | + | ||
1234 | + levelCodeCountList, err := assessDao.CountAssessContentLevelCode(param.ProjectId, param.TargetUserId, domain.AssessSelf, param.CycleId) | ||
1235 | + if err != nil { | ||
1236 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
1237 | + } | ||
1238 | + _, itemList, err := evaluationItemRepo.Find(map[string]interface{}{ | ||
1239 | + "evaluationProjectId": param.ProjectId, | ||
1240 | + "nodeType": int(domain.LinkNodeSelfAssessment), | ||
1241 | + }) | ||
1242 | + if err != nil { | ||
1243 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
1244 | + } | ||
1245 | + //获取员工的评估 | ||
1246 | + _, assessList, err := assessReps.Find(map[string]interface{}{ | ||
1247 | + "companyId": param.CompanyId, | ||
1248 | + "limit": 1, | ||
1249 | + "cycleId": param.CycleId, | ||
1250 | + "targetUserId": param.TargetUserId, | ||
1251 | + "evaluationProjectId": param.ProjectId, | ||
1252 | + }) | ||
1253 | + if err != nil { | ||
1254 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
1255 | + } | ||
1256 | + | ||
1257 | + if len(assessList) == 0 { | ||
1258 | + return &adapter.AssessCountLevelResp{ | ||
1259 | + EvaluationProjectId: param.ProjectId, | ||
1260 | + CycleId: int64(param.CycleId), | ||
1261 | + TargetUserId: param.TargetUserId, | ||
1262 | + }, nil | ||
1263 | + } | ||
1264 | + assessData := assessList[0] | ||
1265 | + targetUserDesc, err := srv.getStaffDescrip(transactionContext, int64(param.TargetUserId)) | ||
1266 | + if err != nil { | ||
1267 | + log.Logger.Error("获取员工描述" + err.Error()) | ||
1268 | + } | ||
1269 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
1270 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
1271 | + } | ||
1272 | + result := adapter.AssessCountLevelResp{ | ||
1273 | + CycleId: assessData.CycleId, | ||
1274 | + CycleName: assessData.CycleName, | ||
1275 | + EvaluationProjectId: assessData.EvaluationProjectId, | ||
1276 | + EvaluationProjectName: assessData.EvaluationProjectName, | ||
1277 | + TargetUserId: assessData.TargetUser.UserId, | ||
1278 | + TargetUserName: assessData.TargetUser.UserName, | ||
1279 | + CompanyLogo: "", | ||
1280 | + CompanyName: "", | ||
1281 | + SupperUser: "", | ||
1282 | + DutyTime: "", | ||
1283 | + EvaluationItems: []adapter.AssessCountLeveltItem{}, | ||
1284 | + } | ||
1285 | + if targetUserDesc != nil { | ||
1286 | + result.CompanyName = targetUserDesc.CompanyName | ||
1287 | + result.SupperUser = targetUserDesc.SupperUserName | ||
1288 | + result.CompanyLogo = targetUserDesc.CompanyLogo | ||
1289 | + result.DutyTime = targetUserDesc.DutyTime | ||
1290 | + } | ||
1291 | + | ||
1292 | + levelCodeMap := map[int][]adapter.LevalCodeCount{} | ||
1293 | + for _, v := range itemList { | ||
1294 | + codes := v.Rule.GetLevelCodes() | ||
1295 | + levelCode := []adapter.LevalCodeCount{} | ||
1296 | + for _, v2 := range codes { | ||
1297 | + levelCode = append(levelCode, adapter.LevalCodeCount{ | ||
1298 | + Code: v2, | ||
1299 | + Number: 0, | ||
1300 | + }) | ||
1301 | + } | ||
1302 | + levelCodeMap[v.Id] = levelCode | ||
1303 | + } | ||
1304 | + levelCodeCountMap := map[string]int{} | ||
1305 | + for _, v := range levelCodeCountList { | ||
1306 | + key := fmt.Sprintf("%s-%s-%s", v.Category, v.Name, v.LevelValue) | ||
1307 | + levelCodeCountMap[key] = v.Cnt | ||
1308 | + } | ||
1309 | + for _, v := range itemList { | ||
1310 | + itemCount := adapter.AssessCountLeveltItem{ | ||
1311 | + EvaluationItemId: v.Id, | ||
1312 | + SortBy: v.SortBy, | ||
1313 | + Category: v.Category, | ||
1314 | + Name: v.Name, | ||
1315 | + PromptTitle: v.PromptTitle, | ||
1316 | + PromptText: v.PromptText, | ||
1317 | + EntryItems: v.EntryItems, | ||
1318 | + RuleType: v.RuleType, | ||
1319 | + Rule: v.Rule, | ||
1320 | + Weight: v.Weight, | ||
1321 | + EvaluatorId: v.EvaluatorId, | ||
1322 | + LevelCount: []adapter.LevalCodeCount{}, | ||
1323 | + } | ||
1324 | + levelCodes := levelCodeMap[v.Id] | ||
1325 | + for i2 := range levelCodes { | ||
1326 | + key := fmt.Sprintf("%s-%s-%s", | ||
1327 | + itemCount.Category, | ||
1328 | + itemCount.Name, | ||
1329 | + levelCodes[i2].Code, | ||
1330 | + ) | ||
1331 | + if mVal, ok := levelCodeCountMap[key]; ok { | ||
1332 | + levelCodes[i2].Number = mVal | ||
1333 | + } | ||
1334 | + } | ||
1335 | + itemCount.LevelCount = levelCodes | ||
1336 | + result.EvaluationItems = append(result.EvaluationItems, itemCount) | ||
1337 | + } | ||
1338 | + | ||
1339 | + return &result, nil | ||
1340 | +} |
@@ -231,10 +231,164 @@ func (srv StaffAssessServeice) QueryMemberPerformanceIndicator(in *query.MemberP | @@ -231,10 +231,164 @@ func (srv StaffAssessServeice) QueryMemberPerformanceIndicator(in *query.MemberP | ||
231 | transactionContext.RollbackTransaction() | 231 | transactionContext.RollbackTransaction() |
232 | }() | 232 | }() |
233 | 233 | ||
234 | + var projectItemUsed = map[int][]*domain.EvaluationItemUsed{} // 项目ID-> 评估内容项 | ||
235 | + var userProjectMap = map[int][]*dao.IndicatorUserProject{} // 用户ID-> 用户评估的项目(用户在周期内可能有多个项目模板,激活状态只能是1个) | ||
236 | + var projectIds = make([]int, 0) | ||
237 | + var userIds = make([]string, 0) | ||
238 | + if len(in.UserIds) > 0 { | ||
239 | + userIds = in.UserIds // 赋值 | ||
240 | + | ||
241 | + staffAssessRepository := factory.CreateStaffAssessRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
242 | + _, assessList, err := staffAssessRepository.Find(map[string]interface{}{ | ||
243 | + "cycleId": in.CycleId, | ||
244 | + "targetUserIds": in.UserIds, | ||
245 | + "types": domain.AssessSelf, | ||
246 | + }) | ||
247 | + if err != nil { | ||
248 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
249 | + } | ||
250 | + | ||
251 | + projectIdsMap := map[int]int{} | ||
252 | + for i := range assessList { | ||
253 | + it := assessList[i] | ||
254 | + projectIdsMap[it.EvaluationProjectId] = it.EvaluationProjectId | ||
255 | + | ||
256 | + // 用户存在多个项目模板 | ||
257 | + array, ok := userProjectMap[it.TargetUser.UserId] | ||
258 | + if !ok { | ||
259 | + array = make([]*dao.IndicatorUserProject, 0) | ||
260 | + } | ||
261 | + userProjectMap[it.TargetUser.UserId] = append(array, &dao.IndicatorUserProject{ | ||
262 | + AssessId: it.Id, | ||
263 | + EvaluationProjectId: it.EvaluationProjectId, | ||
264 | + TargetUserId: it.TargetUser.UserId, | ||
265 | + TargetUserName: it.TargetUser.UserName, | ||
266 | + }) | ||
267 | + } | ||
268 | + for k, _ := range projectIdsMap { | ||
269 | + projectIds = append(projectIds, k) | ||
270 | + } | ||
271 | + | ||
272 | + } else { | ||
273 | + hrbp, err := srv.getHRBP(transactionContext, in.CompanyId, in.OperatorId) | ||
274 | + if err != nil { | ||
275 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
276 | + } | ||
277 | + assessDao := dao.NewStaffAssessDao(map[string]interface{}{"transactionContext": transactionContext}) | ||
278 | + list, err := assessDao.MemberAllProjectId( | ||
279 | + in.CompanyId, | ||
280 | + in.UserName, | ||
281 | + in.OperatorId, | ||
282 | + in.CycleId, | ||
283 | + hrbp) | ||
284 | + if err != nil { | ||
285 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
286 | + } | ||
287 | + | ||
288 | + projectIdsMap := map[int]int{} | ||
289 | + for i := range list { | ||
290 | + it := list[i] | ||
291 | + projectIdsMap[it.EvaluationProjectId] = it.EvaluationProjectId | ||
292 | + | ||
293 | + // 用户存在多个项目模板 | ||
294 | + array, ok := userProjectMap[it.TargetUserId] | ||
295 | + if !ok { | ||
296 | + array = make([]*dao.IndicatorUserProject, 0) | ||
297 | + } | ||
298 | + userProjectMap[it.TargetUserId] = append(array, &it) | ||
299 | + } | ||
300 | + for k := range userProjectMap { | ||
301 | + userIds = append(userIds, strconv.Itoa(k)) | ||
302 | + } | ||
303 | + for k, _ := range projectIdsMap { | ||
304 | + projectIds = append(projectIds, k) | ||
305 | + } | ||
306 | + } | ||
307 | + | ||
308 | + // 项目ID->查询所有评估项 | ||
309 | + if len(projectIds) > 0 { | ||
310 | + itemUsedRepository := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
311 | + _, itemList, err := itemUsedRepository.Find(map[string]interface{}{"evaluationProjectIds": projectIds, "nodeType": domain.LinkNodeSelfAssessment}) | ||
312 | + if err != nil { | ||
313 | + return nil, err | ||
314 | + } | ||
315 | + for i := range itemList { | ||
316 | + it := itemList[i] | ||
317 | + array, ok := projectItemUsed[it.EvaluationProjectId] | ||
318 | + if !ok { | ||
319 | + array = make([]*domain.EvaluationItemUsed, 0) | ||
320 | + } | ||
321 | + projectItemUsed[it.EvaluationProjectId] = append(array, it) | ||
322 | + } | ||
323 | + } | ||
324 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
325 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
326 | + } | ||
327 | + | ||
328 | + adapterList := make([]*adapter.PerformanceIndicatorAdapter, 0) | ||
329 | + categoryMap := map[string]int{} // 内容分类 | ||
330 | + categoryNameMap := map[string]int{} // 内容名称 | ||
331 | + for i := range userIds { | ||
332 | + userId := userIds[i] | ||
333 | + userIdInt, err := strconv.Atoi(userId) | ||
334 | + if err != nil { | ||
335 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
336 | + } | ||
337 | + | ||
338 | + iupArray, ok := userProjectMap[userIdInt] | ||
339 | + if !ok { | ||
340 | + continue | ||
341 | + } | ||
342 | + var pia = &adapter.PerformanceIndicatorAdapter{ | ||
343 | + TargetUserId: userId, | ||
344 | + TargetUserName: iupArray[0].TargetUserName, | ||
345 | + PIContents: make([]adapter.PIContent, 0), | ||
346 | + } | ||
347 | + adapterList = append(adapterList, pia) | ||
348 | + for _, assess := range iupArray { | ||
349 | + items, ok := projectItemUsed[assess.EvaluationProjectId] | ||
350 | + if !ok { | ||
351 | + continue | ||
352 | + } | ||
353 | + for _, item := range items { | ||
354 | + if len(item.Category) == 0 { | ||
355 | + continue | ||
356 | + } | ||
357 | + onlyKey1 := userId + item.Category | ||
358 | + if _, ok := categoryMap[onlyKey1]; !ok { | ||
359 | + categoryMap[onlyKey1] = 0 | ||
360 | + // 不存在分类时,创建分类内容 | ||
361 | + pia.PIContents = append(pia.PIContents, adapter.PIContent{ | ||
362 | + Category: item.Category, | ||
363 | + Names: make([]string, 0), | ||
364 | + }) | ||
365 | + } | ||
366 | + | ||
367 | + // 内容名称有值合并到数组 | ||
368 | + if len(item.Name) > 0 { | ||
369 | + onlyKey2 := userId + item.Category + item.Name | ||
370 | + if _, ok := categoryNameMap[onlyKey2]; !ok { | ||
371 | + categoryNameMap[onlyKey2] = 0 | ||
372 | + for index := range pia.PIContents { | ||
373 | + piContent := &pia.PIContents[index] | ||
374 | + if piContent.Category == item.Category { | ||
375 | + piContent.Names = append(piContent.Names, item.Name) | ||
376 | + break | ||
377 | + } | ||
378 | + } | ||
379 | + } | ||
380 | + } | ||
381 | + } | ||
382 | + } | ||
383 | + } | ||
384 | + | ||
385 | + /* | ||
386 | + // 旧版(如果未填写自评会出现数据评估项丢失的BUG) | ||
234 | hrbp, err := srv.getHRBP(transactionContext, in.CompanyId, in.OperatorId) | 387 | hrbp, err := srv.getHRBP(transactionContext, in.CompanyId, in.OperatorId) |
235 | if err != nil { | 388 | if err != nil { |
236 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 389 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
237 | } | 390 | } |
391 | + | ||
238 | assessDao := dao.NewStaffAssessDao(map[string]interface{}{"transactionContext": transactionContext}) | 392 | assessDao := dao.NewStaffAssessDao(map[string]interface{}{"transactionContext": transactionContext}) |
239 | list, err := assessDao.MemberPerformanceIndicator( | 393 | list, err := assessDao.MemberPerformanceIndicator( |
240 | in.UserName, | 394 | in.UserName, |
@@ -326,10 +480,10 @@ func (srv StaffAssessServeice) QueryMemberPerformanceIndicator(in *query.MemberP | @@ -326,10 +480,10 @@ func (srv StaffAssessServeice) QueryMemberPerformanceIndicator(in *query.MemberP | ||
326 | } | 480 | } |
327 | 481 | ||
328 | } | 482 | } |
329 | - | ||
330 | - if err := transactionContext.CommitTransaction(); err != nil { | ||
331 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
332 | - } | 483 | + */ |
484 | + //if err := transactionContext.CommitTransaction(); err != nil { | ||
485 | + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
486 | + //} | ||
333 | 487 | ||
334 | return tool_funs.SimpleWrapGridMap(int64(len(adapterList)), adapterList), nil | 488 | return tool_funs.SimpleWrapGridMap(int64(len(adapterList)), adapterList), nil |
335 | } | 489 | } |
@@ -374,8 +528,7 @@ func (srv StaffAssessServeice) ExportPerformanceIndicator(in *query.ExportPerfor | @@ -374,8 +528,7 @@ func (srv StaffAssessServeice) ExportPerformanceIndicator(in *query.ExportPerfor | ||
374 | for i := range list { | 528 | for i := range list { |
375 | it := list[i] | 529 | it := list[i] |
376 | if v, ok := selectedMap[it.TargetUserId]; ok { | 530 | if v, ok := selectedMap[it.TargetUserId]; ok { |
377 | - v.UserName = it.TargetUserName | ||
378 | - | 531 | + //v.UserName = it.TargetUserName |
379 | if v.Category == it.ContentCategory && v.Name == it.ContentName { | 532 | if v.Category == it.ContentCategory && v.Name == it.ContentName { |
380 | conditionList = append(conditionList, it) | 533 | conditionList = append(conditionList, it) |
381 | conditionMap[it.TargetUserId+it.BeginDay] = it | 534 | conditionMap[it.TargetUserId+it.BeginDay] = it |
@@ -435,7 +435,7 @@ func (srv StaffAssessServeice) QueryPerformanceIndicator(param *query.ListAssess | @@ -435,7 +435,7 @@ func (srv StaffAssessServeice) QueryPerformanceIndicator(param *query.ListAssess | ||
435 | Hrbp: hrbp, | 435 | Hrbp: hrbp, |
436 | }) | 436 | }) |
437 | if err != nil { | 437 | if err != nil { |
438 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统计总数"+err.Error()) | 438 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取所有的评估的指标"+err.Error()) |
439 | } | 439 | } |
440 | if err := transactionContext.CommitTransaction(); err != nil { | 440 | if err := transactionContext.CommitTransaction(); err != nil { |
441 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 441 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
@@ -478,14 +478,12 @@ func (srv *StaffAssessServeice) ExportUserAssess(param *query.ExportAssessConten | @@ -478,14 +478,12 @@ func (srv *StaffAssessServeice) ExportUserAssess(param *query.ExportAssessConten | ||
478 | assessDao := dao.NewStaffAssessDao(map[string]interface{}{ | 478 | assessDao := dao.NewStaffAssessDao(map[string]interface{}{ |
479 | "transactionContext": transactionContext, | 479 | "transactionContext": transactionContext, |
480 | }) | 480 | }) |
481 | - contentList, err := assessDao.ExportDataUserAssess(dao.SearchConditin1{ | 481 | + contentList, err := assessDao.ExportDataUserAssessV2(dao.SearchConditin2{ |
482 | CompanyId: param.CompanyId, | 482 | CompanyId: param.CompanyId, |
483 | CycleId: param.CycleId, | 483 | CycleId: param.CycleId, |
484 | - BeginDay: "", | 484 | + BeginDayList: param.BeginDayList, |
485 | TargetUserName: param.TargetUserName, | 485 | TargetUserName: param.TargetUserName, |
486 | TargetUserId: param.TargetUserId, | 486 | TargetUserId: param.TargetUserId, |
487 | - Limit: 5000, | ||
488 | - Offset: 0, | ||
489 | OperaterId: param.OperaterId, | 487 | OperaterId: param.OperaterId, |
490 | Hrbp: hrbp, | 488 | Hrbp: hrbp, |
491 | }) | 489 | }) |
@@ -501,11 +499,7 @@ func (srv *StaffAssessServeice) ExportUserAssess(param *query.ExportAssessConten | @@ -501,11 +499,7 @@ func (srv *StaffAssessServeice) ExportUserAssess(param *query.ExportAssessConten | ||
501 | for _, v := range param.ExportItems { | 499 | for _, v := range param.ExportItems { |
502 | includeCol[v.Category+"+"+v.Name] = struct{}{} | 500 | includeCol[v.Category+"+"+v.Name] = struct{}{} |
503 | } | 501 | } |
504 | - includeBeginDay := map[string]struct{}{} | ||
505 | - for _, v := range param.BeginDayList { | ||
506 | - includeBeginDay[v] = struct{}{} | ||
507 | - } | ||
508 | - | 502 | + //过滤日期 |
509 | eData := newExportData2() | 503 | eData := newExportData2() |
510 | eData.setData(contentList) | 504 | eData.setData(contentList) |
511 | //将数据写入xlsx | 505 | //将数据写入xlsx |
@@ -523,11 +517,6 @@ func (srv *StaffAssessServeice) ExportUserAssess(param *query.ExportAssessConten | @@ -523,11 +517,6 @@ func (srv *StaffAssessServeice) ExportUserAssess(param *query.ExportAssessConten | ||
523 | rowNum := 0 | 517 | rowNum := 0 |
524 | for _, v := range eData.rowSort.Child { | 518 | for _, v := range eData.rowSort.Child { |
525 | //纵向-索引-第一列-日期 | 519 | //纵向-索引-第一列-日期 |
526 | - if len(includeBeginDay) > 0 { | ||
527 | - if _, ok := includeBeginDay[v.Name]; !ok { | ||
528 | - continue | ||
529 | - } | ||
530 | - } | ||
531 | for _, v2 := range v.Child { | 520 | for _, v2 := range v.Child { |
532 | //纵向-索引-第二列-员工id | 521 | //纵向-索引-第二列-员工id |
533 | //填充1,2 列 | 522 | //填充1,2 列 |
@@ -572,11 +561,6 @@ func (srv *StaffAssessServeice) ExportUserAssess(param *query.ExportAssessConten | @@ -572,11 +561,6 @@ func (srv *StaffAssessServeice) ExportUserAssess(param *query.ExportAssessConten | ||
572 | rowNum = 0 | 561 | rowNum = 0 |
573 | for _, v4 := range eData.rowSort.Child { | 562 | for _, v4 := range eData.rowSort.Child { |
574 | //纵向-索引-第一列-日期 | 563 | //纵向-索引-第一列-日期 |
575 | - if len(includeBeginDay) > 0 { | ||
576 | - if _, ok := includeBeginDay[v4.Name]; !ok { | ||
577 | - continue | ||
578 | - } | ||
579 | - } | ||
580 | for _, v5 := range v4.Child { | 564 | for _, v5 := range v4.Child { |
581 | //纵向-索引-第二列-员工id | 565 | //纵向-索引-第二列-员工id |
582 | rowNum++ | 566 | rowNum++ |
@@ -2,6 +2,7 @@ package service | @@ -2,6 +2,7 @@ package service | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "fmt" | 4 | "fmt" |
5 | + "sort" | ||
5 | "strconv" | 6 | "strconv" |
6 | 7 | ||
7 | "github.com/linmadan/egglib-go/core/application" | 8 | "github.com/linmadan/egglib-go/core/application" |
@@ -36,14 +37,6 @@ func (srv StaffAssessServeice) SearchAssessTaskMeV2(param *query.SearchAssessMeQ | @@ -36,14 +37,6 @@ func (srv StaffAssessServeice) SearchAssessTaskMeV2(param *query.SearchAssessMeQ | ||
36 | limit = param.PageSize | 37 | limit = param.PageSize |
37 | } | 38 | } |
38 | offset = (param.PageNumber - 1) * param.PageSize | 39 | offset = (param.PageNumber - 1) * param.PageSize |
39 | - // assessCycleList, err := staffAssessTaskRepo.SearchAssessCycleMe(param.UserId, param.CompanyId, limit, offset) | ||
40 | - // if err != nil { | ||
41 | - // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询评估周期"+err.Error()) | ||
42 | - // } | ||
43 | - // cnt, err := staffAssessTaskRepo.CountAssessTaskMe(param.UserId, param.CompanyId) | ||
44 | - // if err != nil { | ||
45 | - // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询评估周期"+err.Error()) | ||
46 | - // } | ||
47 | 40 | ||
48 | assessCycleList, cnt, err := staffAssessDao.SearchExecutorAssessBeforeNow(param.UserId, param.CompanyId, limit, offset) | 41 | assessCycleList, cnt, err := staffAssessDao.SearchExecutorAssessBeforeNow(param.UserId, param.CompanyId, limit, offset) |
49 | if err != nil { | 42 | if err != nil { |
@@ -231,6 +224,10 @@ func (srv StaffAssessServeice) AssessTaskDescV2(param *query.AssessTaskDescV2Que | @@ -231,6 +224,10 @@ func (srv StaffAssessServeice) AssessTaskDescV2(param *query.AssessTaskDescV2Que | ||
231 | } | 224 | } |
232 | result.StepList = append(result.StepList, stepItem) | 225 | result.StepList = append(result.StepList, stepItem) |
233 | } | 226 | } |
227 | + //排序评估阶段 | ||
228 | + sort.Slice(result.StepList, func(i, j int) bool { | ||
229 | + return result.StepList[i].SortBy < result.StepList[j].SortBy | ||
230 | + }) | ||
234 | if err := transactionContext.CommitTransaction(); err != nil { | 231 | if err := transactionContext.CommitTransaction(); err != nil { |
235 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 232 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
236 | } | 233 | } |
@@ -149,10 +149,10 @@ func (srv *SummaryEvaluationService) ExportAllEvaluationFinish(param *command.Qu | @@ -149,10 +149,10 @@ func (srv *SummaryEvaluationService) ExportAllEvaluationFinish(param *command.Qu | ||
149 | tableHead = append(tableHead, ratingHeader...) | 149 | tableHead = append(tableHead, ratingHeader...) |
150 | if len(evaluationList) > 0 { | 150 | if len(evaluationList) > 0 { |
151 | xlsxFile.SetSheetRow(firstSheetName, "A1", &[]string{evaluationList[0].CycleName + "最终成绩"}) | 151 | xlsxFile.SetSheetRow(firstSheetName, "A1", &[]string{evaluationList[0].CycleName + "最终成绩"}) |
152 | - // if len(tableHead) > 1 { | ||
153 | - // cellCode, _ := excelize.ColumnNumberToName(len(tableHead)) | ||
154 | - // xlsxFile.MergeCell(firstSheetName, "A1", cellCode+"1") | ||
155 | - // } | 152 | + if len(tableHead) > 1 { |
153 | + cellCode, _ := excelize.ColumnNumberToName(len(tableHead)) | ||
154 | + xlsxFile.MergeCell(firstSheetName, "A1", cellCode+"1") | ||
155 | + } | ||
156 | } | 156 | } |
157 | xlsxFile.SetSheetRow(firstSheetName, "A2", &tableHead) | 157 | xlsxFile.SetSheetRow(firstSheetName, "A2", &tableHead) |
158 | firstDataRow := 3 | 158 | firstDataRow := 3 |
@@ -138,7 +138,6 @@ func sendSummaryEvaluation(project *domain.EvaluationProject, | @@ -138,7 +138,6 @@ func sendSummaryEvaluation(project *domain.EvaluationProject, | ||
138 | DepartmentName: depart.Name, | 138 | DepartmentName: depart.Name, |
139 | }) | 139 | }) |
140 | } | 140 | } |
141 | - //确定自评 | ||
142 | newEvaluationList = append(newEvaluationList, evaluationTemp) | 141 | newEvaluationList = append(newEvaluationList, evaluationTemp) |
143 | if hrbpExist { | 142 | if hrbpExist { |
144 | //处理人资评估 | 143 | //处理人资评估 |
@@ -146,7 +145,6 @@ func sendSummaryEvaluation(project *domain.EvaluationProject, | @@ -146,7 +145,6 @@ func sendSummaryEvaluation(project *domain.EvaluationProject, | ||
146 | evaluationTemp.EndTime = endTime360 | 145 | evaluationTemp.EndTime = endTime360 |
147 | evaluationTemp.Executor = domain.StaffDesc{} | 146 | evaluationTemp.Executor = domain.StaffDesc{} |
148 | evaluationTemp.Types = domain.EvaluationHrbp | 147 | evaluationTemp.Types = domain.EvaluationHrbp |
149 | - //确定人资评估 | ||
150 | newEvaluationList = append(newEvaluationList, evaluationTemp) | 148 | newEvaluationList = append(newEvaluationList, evaluationTemp) |
151 | } | 149 | } |
152 | //处理360 评估 | 150 | //处理360 评估 |
@@ -159,7 +157,6 @@ func sendSummaryEvaluation(project *domain.EvaluationProject, | @@ -159,7 +157,6 @@ func sendSummaryEvaluation(project *domain.EvaluationProject, | ||
159 | UserName: v2.Name, | 157 | UserName: v2.Name, |
160 | } | 158 | } |
161 | evaluationTemp.Types = domain.Evaluation360 | 159 | evaluationTemp.Types = domain.Evaluation360 |
162 | - //确定人资评估 | ||
163 | newEvaluationList = append(newEvaluationList, evaluationTemp) | 160 | newEvaluationList = append(newEvaluationList, evaluationTemp) |
164 | } | 161 | } |
165 | 162 |
1 | +package service | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "strconv" | ||
6 | + "time" | ||
7 | + | ||
8 | + "github.com/linmadan/egglib-go/core/application" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
11 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao" | ||
12 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log" | ||
13 | +) | ||
14 | + | ||
15 | +// 定时下发周期评估任务 | ||
16 | +func TaskSendSummaryEvaluationV2() error { | ||
17 | + nowTime := time.Now() | ||
18 | + defer func() { | ||
19 | + str := fmt.Sprintf("下发周期评估耗时%.2f s", time.Since(nowTime).Seconds()) | ||
20 | + log.Logger.Info(str) | ||
21 | + }() | ||
22 | + for { | ||
23 | + cycleList, err := getPrepareEvaluationCycle() | ||
24 | + if err != nil { | ||
25 | + return err | ||
26 | + } | ||
27 | + if len(cycleList) == 0 { | ||
28 | + break | ||
29 | + } | ||
30 | + err = sendSummaryEvaluationByCycle(cycleList[0]) | ||
31 | + if err != nil { | ||
32 | + return err | ||
33 | + } | ||
34 | + } | ||
35 | + return nil | ||
36 | +} | ||
37 | + | ||
38 | +// 获取周期 | ||
39 | +func getPrepareEvaluationCycle() ([]*domain.EvaluationCycle, error) { | ||
40 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
41 | + if err != nil { | ||
42 | + return nil, err | ||
43 | + } | ||
44 | + if err := transactionContext.StartTransaction(); err != nil { | ||
45 | + return nil, err | ||
46 | + } | ||
47 | + defer func() { | ||
48 | + _ = transactionContext.RollbackTransaction() | ||
49 | + }() | ||
50 | + cycleRepo := factory.CreateEvaluationCycleRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
51 | + cycleList, err := cycleRepo.FindCycleEnd(1) | ||
52 | + if err != nil { | ||
53 | + return nil, fmt.Errorf("获取可用的周期数据,%s", err) | ||
54 | + } | ||
55 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
56 | + return nil, err | ||
57 | + } | ||
58 | + return cycleList, nil | ||
59 | +} | ||
60 | + | ||
61 | +// 获取可用的项目 | ||
62 | +// func getPrepareSummaryEvaluation(cycleId int) ([]*domain.EvaluationProject, error) { | ||
63 | +// transactionContext, err := factory.CreateTransactionContext(nil) | ||
64 | +// if err != nil { | ||
65 | +// return nil, err | ||
66 | +// } | ||
67 | +// if err := transactionContext.StartTransaction(); err != nil { | ||
68 | +// return nil, err | ||
69 | +// } | ||
70 | +// defer func() { | ||
71 | +// _ = transactionContext.RollbackTransaction() | ||
72 | +// }() | ||
73 | +// projectRepo := factory.CreateEvaluationProjectRepository(map[string]interface{}{ | ||
74 | +// "transactionContext": transactionContext, | ||
75 | +// }) | ||
76 | +// // 获取项目数据总数 | ||
77 | +// _, projectList, err := projectRepo.Find(map[string]interface{}{ | ||
78 | +// "cycleId": cycleId, | ||
79 | +// "summaryState": domain.ProjectSummaryStateNo, | ||
80 | +// "state": domain.ProjectStateEnable, | ||
81 | +// "limit": 200, | ||
82 | +// }, "template") | ||
83 | +// if err != nil { | ||
84 | +// return nil, fmt.Errorf("获取可用的项目数据,%s", err) | ||
85 | +// } | ||
86 | +// if err := transactionContext.CommitTransaction(); err != nil { | ||
87 | +// return nil, err | ||
88 | +// } | ||
89 | +// return projectList, nil | ||
90 | +// } | ||
91 | + | ||
92 | +// 按周期下发 综合评估任务 | ||
93 | +func sendSummaryEvaluationByCycle(cycleParam *domain.EvaluationCycle) error { | ||
94 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
95 | + if err != nil { | ||
96 | + return err | ||
97 | + } | ||
98 | + if err := transactionContext.StartTransaction(); err != nil { | ||
99 | + return err | ||
100 | + } | ||
101 | + defer func() { | ||
102 | + _ = transactionContext.RollbackTransaction() | ||
103 | + }() | ||
104 | + | ||
105 | + projectRepo := factory.CreateEvaluationProjectRepository(map[string]interface{}{ | ||
106 | + "transactionContext": transactionContext, | ||
107 | + }) | ||
108 | + // 获取项目数据总数 | ||
109 | + _, projectList, err := projectRepo.Find(map[string]interface{}{ | ||
110 | + "cycleId": cycleParam.Id, | ||
111 | + "summaryState": domain.ProjectSummaryStateNo, | ||
112 | + "state": domain.ProjectStateEnable, | ||
113 | + "limit": 500, | ||
114 | + }, "template") | ||
115 | + if err != nil { | ||
116 | + return fmt.Errorf("获取可用的项目数据,%s", err) | ||
117 | + } | ||
118 | + var newEvaluationList []domain.SummaryEvaluation | ||
119 | + newPublisher := summaryEvaluationPublisher{} | ||
120 | + for _, val := range projectList { | ||
121 | + evaluationList, err := newPublisher.sendSummaryEvaluationV2(transactionContext, val, cycleParam) | ||
122 | + if err != nil { | ||
123 | + return fmt.Errorf("按项目下发综合评估任务数据,%s", err) | ||
124 | + } | ||
125 | + newEvaluationList = append(newEvaluationList, evaluationList...) | ||
126 | + } | ||
127 | + // 回填周期的状态 | ||
128 | + cycleDao := dao.NewEvaluationCycleDao(map[string]interface{}{"transactionContext": transactionContext}) | ||
129 | + err = cycleDao.UpdateSummaryState(cycleParam.Id, domain.ProjectSummaryStateYes) | ||
130 | + if err != nil { | ||
131 | + return fmt.Errorf("保存项目周期状态%s", err) | ||
132 | + } | ||
133 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
134 | + return err | ||
135 | + } | ||
136 | + err = sendSmsEvalation(newEvaluationList) | ||
137 | + if err != nil { | ||
138 | + return fmt.Errorf("设置短信消息%s", err) | ||
139 | + } | ||
140 | + return nil | ||
141 | +} | ||
142 | + | ||
143 | +// 下发周期综合评估 | ||
144 | +type summaryEvaluationPublisher struct { | ||
145 | + userCache map[int64]*domain.User | ||
146 | + departCache map[int]*domain.Department | ||
147 | +} | ||
148 | + | ||
149 | +func (se *summaryEvaluationPublisher) sendSummaryEvaluationV2( | ||
150 | + transactionContext application.TransactionContext, | ||
151 | + projectParam *domain.EvaluationProject, cycleData *domain.EvaluationCycle, | ||
152 | +) ([]domain.SummaryEvaluation, error) { | ||
153 | + // transactionContext, err := factory.CreateTransactionContext(nil) | ||
154 | + // if err != nil { | ||
155 | + // return err | ||
156 | + // } | ||
157 | + // if err := transactionContext.StartTransaction(); err != nil { | ||
158 | + // return err | ||
159 | + // } | ||
160 | + // defer func() { | ||
161 | + // _ = transactionContext.RollbackTransaction() | ||
162 | + // }() | ||
163 | + userRepo := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
164 | + departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
165 | + evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
166 | + _, evaluationItemList, err := evaluationItemRepo.Find(map[string]interface{}{ | ||
167 | + "evaluationProjectId": projectParam.Id, | ||
168 | + "nodeType": int(domain.LinkNodeSelfAssessment), | ||
169 | + }) | ||
170 | + if err != nil { | ||
171 | + return nil, err | ||
172 | + } | ||
173 | + if len(evaluationItemList) == 0 { | ||
174 | + return nil, nil | ||
175 | + } | ||
176 | + nodeId := evaluationItemList[0].NodeId | ||
177 | + executor360Map := map[int64]*domain.User{} | ||
178 | + hrbpExist := false | ||
179 | + for _, v := range evaluationItemList { | ||
180 | + nodeId = v.NodeId | ||
181 | + if v.EvaluatorId < 0 { | ||
182 | + hrbpExist = true | ||
183 | + } | ||
184 | + if v.EvaluatorId <= 0 { | ||
185 | + continue | ||
186 | + } | ||
187 | + user360, err := se.getUserData(userRepo, int64(v.EvaluatorId)) | ||
188 | + if err != nil { | ||
189 | + return nil, fmt.Errorf("获取360用户%s", err) | ||
190 | + } | ||
191 | + executor360Map[user360.Id] = user360 | ||
192 | + } | ||
193 | + if cycleData.TimeEnd == nil { | ||
194 | + return nil, fmt.Errorf("周期%d:%s 结束时间错误", cycleData.Id, cycleData.Name) | ||
195 | + } | ||
196 | + //自评的时间范围 | ||
197 | + beginTimeSelf := *cycleData.TimeEnd | ||
198 | + endTimeSelf := dayZeroTime(beginTimeSelf).Add(3*24*time.Hour - time.Second) | ||
199 | + //人资、360评估的时间范围 | ||
200 | + beginTime360 := endTimeSelf | ||
201 | + endTime360 := endTimeSelf.Add(2 * 24 * time.Hour) | ||
202 | + //上级评估的是时间范围 | ||
203 | + beginTimeSuper := endTime360 | ||
204 | + endTimeSuper := endTime360.Add(2 * 24 * time.Hour) | ||
205 | + // 创建周期评估任务 | ||
206 | + var newEvaluationList []domain.SummaryEvaluation | ||
207 | + evaluationTemp := domain.SummaryEvaluation{ | ||
208 | + Id: 0, | ||
209 | + CompanyId: int(projectParam.CompanyId), | ||
210 | + EvaluationProjectId: int(projectParam.Id), | ||
211 | + EvaluationProjectName: projectParam.Name, | ||
212 | + CycleId: cycleData.Id, | ||
213 | + CycleName: cycleData.Name, | ||
214 | + NodeId: nodeId, | ||
215 | + TargetUser: domain.StaffDesc{}, //待填充 | ||
216 | + TargetDepartment: []domain.StaffDepartment{}, //待填充 | ||
217 | + Executor: domain.StaffDesc{}, | ||
218 | + Types: 0, //待填充 | ||
219 | + Status: domain.EvaluationUncompleted, | ||
220 | + CheckResult: domain.EvaluationCheckUncompleted, | ||
221 | + BeginTime: time.Time{}, //待填充 | ||
222 | + EndTime: time.Time{}, //待填充 | ||
223 | + TotalScore: "", | ||
224 | + CreatedAt: time.Now(), | ||
225 | + UpdatedAt: time.Now(), | ||
226 | + DeletedAt: nil, | ||
227 | + } | ||
228 | + | ||
229 | + for _, val := range projectParam.Recipients { | ||
230 | + targetUserId, _ := strconv.ParseInt(val, 10, 64) | ||
231 | + if targetUserId == 0 { | ||
232 | + continue | ||
233 | + } | ||
234 | + targetUser, err := se.getUserData(userRepo, targetUserId) | ||
235 | + if err != nil { | ||
236 | + return nil, fmt.Errorf("获取员工数据%s", err) | ||
237 | + } | ||
238 | + if targetUser == nil { | ||
239 | + continue | ||
240 | + } | ||
241 | + targetUserDepartment, err := se.getDepartmentData(departmentRepo, targetUser.DepartmentId) | ||
242 | + if err != nil { | ||
243 | + return nil, fmt.Errorf("获取员工的部门数据%s", err) | ||
244 | + } | ||
245 | + evaluationTemp.TargetDepartment = []domain.StaffDepartment{} | ||
246 | + | ||
247 | + for _, d := range targetUserDepartment { | ||
248 | + evaluationTemp.TargetDepartment = append(evaluationTemp.TargetDepartment, domain.StaffDepartment{ | ||
249 | + DepartmentId: int(d.Id), | ||
250 | + DepartmentName: d.Name, | ||
251 | + }) | ||
252 | + } | ||
253 | + evaluationTemp.TargetUser = domain.StaffDesc{ | ||
254 | + UserId: int(targetUser.Id), | ||
255 | + Account: targetUser.Account, | ||
256 | + UserName: targetUser.Name, | ||
257 | + } | ||
258 | + //处理自评 | ||
259 | + { | ||
260 | + evaluationTemp.Types = domain.EvaluationSelf | ||
261 | + evaluationTemp.Executor = domain.StaffDesc{ | ||
262 | + UserId: int(targetUser.Id), | ||
263 | + Account: targetUser.Account, | ||
264 | + UserName: targetUser.Name, | ||
265 | + } | ||
266 | + evaluationTemp.BeginTime = beginTimeSelf | ||
267 | + evaluationTemp.EndTime = endTimeSelf | ||
268 | + newEvaluationList = append(newEvaluationList, evaluationTemp) | ||
269 | + } | ||
270 | + //处理360评估 | ||
271 | + { | ||
272 | + for _, val2 := range executor360Map { | ||
273 | + evaluationTemp.BeginTime = beginTime360 | ||
274 | + evaluationTemp.EndTime = endTime360 | ||
275 | + evaluationTemp.Executor = domain.StaffDesc{ | ||
276 | + UserId: int(val2.Id), | ||
277 | + Account: val2.Account, | ||
278 | + UserName: val2.Name, | ||
279 | + } | ||
280 | + evaluationTemp.Types = domain.Evaluation360 | ||
281 | + //确定人资评估 | ||
282 | + newEvaluationList = append(newEvaluationList, evaluationTemp) | ||
283 | + } | ||
284 | + } | ||
285 | + //处理人资评估 | ||
286 | + { | ||
287 | + if hrbpExist { | ||
288 | + //处理人资评估 | ||
289 | + evaluationTemp.BeginTime = beginTime360 | ||
290 | + evaluationTemp.EndTime = endTime360 | ||
291 | + evaluationTemp.Executor = domain.StaffDesc{} | ||
292 | + evaluationTemp.Types = domain.EvaluationHrbp | ||
293 | + newEvaluationList = append(newEvaluationList, evaluationTemp) | ||
294 | + } | ||
295 | + } | ||
296 | + //处理上级评估 | ||
297 | + { | ||
298 | + superUser, _ := se.getUserData(userRepo, targetUser.ParentId) | ||
299 | + if superUser != nil { | ||
300 | + evaluationTemp.Types = domain.EvaluationSuper | ||
301 | + evaluationTemp.Executor = domain.StaffDesc{ | ||
302 | + UserId: int(superUser.Id), | ||
303 | + Account: superUser.Account, | ||
304 | + UserName: superUser.Name, | ||
305 | + } | ||
306 | + evaluationTemp.BeginTime = beginTimeSuper | ||
307 | + evaluationTemp.EndTime = endTimeSuper | ||
308 | + //确定上级评估 | ||
309 | + newEvaluationList = append(newEvaluationList, evaluationTemp) | ||
310 | + } | ||
311 | + } | ||
312 | + //综合考评结果 | ||
313 | + { | ||
314 | + evaluationTemp.Types = domain.EvaluationFinish | ||
315 | + evaluationTemp.Executor = domain.StaffDesc{} | ||
316 | + evaluationTemp.BeginTime = endTimeSuper | ||
317 | + evaluationTemp.EndTime = endTimeSuper.Add(2 * 24 * time.Hour) | ||
318 | + newEvaluationList = append(newEvaluationList, evaluationTemp) | ||
319 | + } | ||
320 | + } | ||
321 | + summaryEvaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
322 | + for i := range newEvaluationList { | ||
323 | + err = summaryEvaluationRepo.Save(&newEvaluationList[i]) | ||
324 | + if err != nil { | ||
325 | + return nil, fmt.Errorf("保存周期综合评估%s", err) | ||
326 | + } | ||
327 | + } | ||
328 | + //回填项目的状态 | ||
329 | + projectDao := dao.NewEvaluationProjectDao(map[string]interface{}{"transactionContext": transactionContext}) | ||
330 | + err = projectDao.UpdateSummaryState(projectParam.Id, domain.ProjectSummaryStateYes) | ||
331 | + if err != nil { | ||
332 | + return nil, fmt.Errorf("保存项目状态%s", err) | ||
333 | + } | ||
334 | + // if err := transactionContext.CommitTransaction(); err != nil { | ||
335 | + // return err | ||
336 | + // } | ||
337 | + return newEvaluationList, nil | ||
338 | +} | ||
339 | + | ||
340 | +// 获取周期设置数据 | ||
341 | +// func (se *summaryEvaluationPublisher) getCycleData(cycleRepo domain.EvaluationCycleRepository, cycleId int64) (*domain.EvaluationCycle, error) { | ||
342 | +// var cycleData *domain.EvaluationCycle | ||
343 | +// if val, ok := se.cycleCache[cycleId]; ok { | ||
344 | +// cycleData = val | ||
345 | +// } else { | ||
346 | +// _, cycleList, err := cycleRepo.Find(map[string]interface{}{"id": cycleId}) | ||
347 | +// if err != nil { | ||
348 | +// return nil, err | ||
349 | +// } | ||
350 | +// if len(cycleList) == 0 { | ||
351 | +// return nil, nil | ||
352 | +// } | ||
353 | +// cycleData = cycleList[0] | ||
354 | +// } | ||
355 | +// return cycleData, nil | ||
356 | +// } | ||
357 | + | ||
358 | +// 获取用户数据 | ||
359 | +func (se *summaryEvaluationPublisher) getUserData(userRepo domain.UserRepository, userId int64) (*domain.User, error) { | ||
360 | + if userId == 0 { | ||
361 | + return nil, nil | ||
362 | + } | ||
363 | + var userData *domain.User | ||
364 | + if val, ok := se.userCache[userId]; ok { | ||
365 | + userData = val | ||
366 | + } else { | ||
367 | + _, userList, err := userRepo.Find(map[string]interface{}{"id": userId}) | ||
368 | + if err != nil { | ||
369 | + return nil, err | ||
370 | + } | ||
371 | + if len(userList) == 0 { | ||
372 | + return nil, nil | ||
373 | + } | ||
374 | + userData = userList[0] | ||
375 | + } | ||
376 | + return userData, nil | ||
377 | +} | ||
378 | + | ||
379 | +// 获取部门数据 | ||
380 | +func (se *summaryEvaluationPublisher) getDepartmentData(departmentRepo domain.DepartmentRepository, departmentIds []int) ([]*domain.Department, error) { | ||
381 | + departmentList := []*domain.Department{} | ||
382 | + for _, departmentId := range departmentIds { | ||
383 | + if val, ok := se.departCache[departmentId]; ok { | ||
384 | + departmentList = append(departmentList, val) | ||
385 | + } else { | ||
386 | + _, departments, err := departmentRepo.Find(map[string]interface{}{"id": departmentId}) | ||
387 | + if err != nil { | ||
388 | + return nil, err | ||
389 | + } | ||
390 | + if len(departmentList) == 0 { | ||
391 | + continue | ||
392 | + } | ||
393 | + departmentList = append(departmentList, departments[0]) | ||
394 | + } | ||
395 | + } | ||
396 | + return departmentList, nil | ||
397 | +} |
@@ -657,10 +657,9 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluationSelf(param *domain. | @@ -657,10 +657,9 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluationSelf(param *domain. | ||
657 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 657 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
658 | } | 658 | } |
659 | if len(evaluationList) > 0 { | 659 | if len(evaluationList) > 0 { |
660 | - // 进入考核结果阶段 | ||
661 | - if evaluationList[0].BeginTime.After(nowTime) { | ||
662 | - evaluationList[0].BeginTime = nowTime | ||
663 | - } | 660 | + //进入考核结果 |
661 | + //自评的结束时间 | ||
662 | + evaluationList[0].BeginTime = param.EndTime | ||
664 | evaluationList[0].Status = domain.EvaluationCompleted | 663 | evaluationList[0].Status = domain.EvaluationCompleted |
665 | err = evaluationRepo.Save(evaluationList[0]) | 664 | err = evaluationRepo.Save(evaluationList[0]) |
666 | if err != nil { | 665 | if err != nil { |
@@ -757,9 +756,8 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluation360Hrbp(param *doma | @@ -757,9 +756,8 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluation360Hrbp(param *doma | ||
757 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 756 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
758 | } | 757 | } |
759 | if len(evaluationList) > 0 { | 758 | if len(evaluationList) > 0 { |
760 | - if evaluationList[0].BeginTime.After(nowTime) { | ||
761 | - evaluationList[0].BeginTime = nowTime | ||
762 | - } | 759 | + //360评估的结束时间 |
760 | + evaluationList[0].BeginTime = param.EndTime | ||
763 | evaluationList[0].Status = domain.EvaluationCompleted | 761 | evaluationList[0].Status = domain.EvaluationCompleted |
764 | err = evaluationRepo.Save(evaluationList[0]) | 762 | err = evaluationRepo.Save(evaluationList[0]) |
765 | if err != nil { | 763 | if err != nil { |
@@ -809,11 +807,10 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluationSuper(param *domain | @@ -809,11 +807,10 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluationSuper(param *domain | ||
809 | if err != nil { | 807 | if err != nil { |
810 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 808 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
811 | } | 809 | } |
812 | - nowTime := time.Now() | 810 | + |
813 | if len(evaluationList) > 0 { | 811 | if len(evaluationList) > 0 { |
814 | - if evaluationList[0].BeginTime.After(nowTime) { | ||
815 | - evaluationList[0].BeginTime = nowTime | ||
816 | - } | 812 | + //上级评估的结束时间 |
813 | + evaluationList[0].BeginTime = param.EndTime | ||
817 | evaluationList[0].Status = domain.EvaluationCompleted | 814 | evaluationList[0].Status = domain.EvaluationCompleted |
818 | err = evaluationRepo.Save(evaluationList[0]) | 815 | err = evaluationRepo.Save(evaluationList[0]) |
819 | if err != nil { | 816 | if err != nil { |
@@ -875,7 +872,7 @@ func (srv *SummaryEvaluationService) GetTargetUserCycleList(param *command.Query | @@ -875,7 +872,7 @@ func (srv *SummaryEvaluationService) GetTargetUserCycleList(param *command.Query | ||
875 | return tool_funs.SimpleWrapGridMap(int64(cnt), cycleList), nil | 872 | return tool_funs.SimpleWrapGridMap(int64(cnt), cycleList), nil |
876 | } | 873 | } |
877 | 874 | ||
878 | -// 自评小结详情 | 875 | +// 周期综合自评小结详情 |
879 | func (srv *SummaryEvaluationService) CountEvaluationSelfLevel(param *command.QueryEvaluation) (*adapter.EvaluationInfoCountCodeAdapter, error) { | 876 | func (srv *SummaryEvaluationService) CountEvaluationSelfLevel(param *command.QueryEvaluation) (*adapter.EvaluationInfoCountCodeAdapter, error) { |
880 | transactionContext, err := factory.CreateTransactionContext(nil) | 877 | transactionContext, err := factory.CreateTransactionContext(nil) |
881 | if err != nil { | 878 | if err != nil { |
@@ -887,16 +884,10 @@ func (srv *SummaryEvaluationService) CountEvaluationSelfLevel(param *command.Que | @@ -887,16 +884,10 @@ func (srv *SummaryEvaluationService) CountEvaluationSelfLevel(param *command.Que | ||
887 | defer func() { | 884 | defer func() { |
888 | _ = transactionContext.RollbackTransaction() | 885 | _ = transactionContext.RollbackTransaction() |
889 | }() | 886 | }() |
890 | - | ||
891 | //统计周期内,评估项等级的数量 | 887 | //统计周期内,评估项等级的数量 |
892 | assessDao := dao.NewStaffAssessDao(map[string]interface{}{ | 888 | assessDao := dao.NewStaffAssessDao(map[string]interface{}{ |
893 | "transactionContext": transactionContext, | 889 | "transactionContext": transactionContext, |
894 | }) | 890 | }) |
895 | - levelCodeCountList, err := assessDao.CountAssessContentLevelCode(param.TargetUserId, domain.AssessSelf, param.CycleId) | ||
896 | - if err != nil { | ||
897 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
898 | - } | ||
899 | - | ||
900 | evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{ | 891 | evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{ |
901 | "transactionContext": transactionContext, | 892 | "transactionContext": transactionContext, |
902 | }) | 893 | }) |
@@ -919,6 +910,10 @@ func (srv *SummaryEvaluationService) CountEvaluationSelfLevel(param *command.Que | @@ -919,6 +910,10 @@ func (srv *SummaryEvaluationService) CountEvaluationSelfLevel(param *command.Que | ||
919 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 910 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
920 | } | 911 | } |
921 | evaluationData := evaluationList[0] | 912 | evaluationData := evaluationList[0] |
913 | + levelCodeCountList, err := assessDao.CountAssessContentLevelCode(evaluationData.EvaluationProjectId, param.TargetUserId, domain.AssessSelf, param.CycleId) | ||
914 | + if err != nil { | ||
915 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
916 | + } | ||
922 | _, itemList, err := evaluationItemRepo.Find(map[string]interface{}{ | 917 | _, itemList, err := evaluationItemRepo.Find(map[string]interface{}{ |
923 | "evaluationProjectId": evaluationData.EvaluationProjectId, | 918 | "evaluationProjectId": evaluationData.EvaluationProjectId, |
924 | "nodeType": int(domain.LinkNodeSelfAssessment), | 919 | "nodeType": int(domain.LinkNodeSelfAssessment), |
@@ -28,6 +28,7 @@ type EvaluationCycle struct { | @@ -28,6 +28,7 @@ type EvaluationCycle struct { | ||
28 | CompanyId int64 `json:"companyId,string" comment:"公司ID"` | 28 | CompanyId int64 `json:"companyId,string" comment:"公司ID"` |
29 | CreatorId int64 `json:"creatorId,string" comment:"创建人ID"` | 29 | CreatorId int64 `json:"creatorId,string" comment:"创建人ID"` |
30 | KpiCycle int `json:"kpiCycle" comment:"考核周期(1日、2周、3月)"` | 30 | KpiCycle int `json:"kpiCycle" comment:"考核周期(1日、2周、3月)"` |
31 | + SummaryState ProjectSummaryState `json:"summaryState" comment:"周期评估是否下发"` | ||
31 | CreatedAt time.Time `json:"createdAt" comment:"创建时间"` | 32 | CreatedAt time.Time `json:"createdAt" comment:"创建时间"` |
32 | UpdatedAt time.Time `json:"updatedAt" comment:"更新时间"` | 33 | UpdatedAt time.Time `json:"updatedAt" comment:"更新时间"` |
33 | DeletedAt *time.Time `json:"deletedAt" comment:"删除时间"` | 34 | DeletedAt *time.Time `json:"deletedAt" comment:"删除时间"` |
@@ -39,4 +40,5 @@ type EvaluationCycleRepository interface { | @@ -39,4 +40,5 @@ type EvaluationCycleRepository interface { | ||
39 | FindOne(queryOptions map[string]interface{}) (*EvaluationCycle, error) | 40 | FindOne(queryOptions map[string]interface{}) (*EvaluationCycle, error) |
40 | Find(queryOptions map[string]interface{}) (int64, []*EvaluationCycle, error) | 41 | Find(queryOptions map[string]interface{}) (int64, []*EvaluationCycle, error) |
41 | Count(queryOptions map[string]interface{}) (int64, error) | 42 | Count(queryOptions map[string]interface{}) (int64, error) |
43 | + FindCycleEnd(limit int) ([]*EvaluationCycle, error) // 获取已结束的周期,且还没下发周期评估 | ||
42 | } | 44 | } |
@@ -7,11 +7,12 @@ import ( | @@ -7,11 +7,12 @@ import ( | ||
7 | const ( | 7 | const ( |
8 | ProjectStateWaitConfig int = 0 // 项目状态-待完成配置 | 8 | ProjectStateWaitConfig int = 0 // 项目状态-待完成配置 |
9 | ProjectStateWaitActive int = 1 // 项目状态-待启用 | 9 | ProjectStateWaitActive int = 1 // 项目状态-待启用 |
10 | - ProjectStateEnable int = 2 // 项目状态-启用 | ||
11 | - ProjectStateDisable int = 3 // 项目状态-停用(假状态) | 10 | + ProjectStateEnable int = 2 // 项目状态-启动 |
11 | + ProjectStateDisable int = 3 // 项目状态-结束(假状态) | ||
12 | + ProjectStatePause int = 4 // 项目状态-暂停(可恢复启动) | ||
12 | ) | 13 | ) |
13 | 14 | ||
14 | -// 项目的评估内容配置 | 15 | +// EvaluationProject 项目的评估内容配置 |
15 | type EvaluationProject struct { | 16 | type EvaluationProject struct { |
16 | Id int64 `json:"id,string" comment:"ID"` | 17 | Id int64 `json:"id,string" comment:"ID"` |
17 | Name string `json:"name" comment:"名称"` | 18 | Name string `json:"name" comment:"名称"` |
@@ -33,6 +34,7 @@ type EvaluationProject struct { | @@ -33,6 +34,7 @@ type EvaluationProject struct { | ||
33 | DeletedAt *time.Time `json:"deletedAt" comment:"删除时间"` | 34 | DeletedAt *time.Time `json:"deletedAt" comment:"删除时间"` |
34 | } | 35 | } |
35 | 36 | ||
37 | +// 周期评估的下发状态 | ||
36 | type ProjectSummaryState int | 38 | type ProjectSummaryState int |
37 | 39 | ||
38 | const ( | 40 | const ( |
@@ -42,5 +42,6 @@ func (sms *LogSms) SummaryEvaluationMessage(phone string, name string) { | @@ -42,5 +42,6 @@ func (sms *LogSms) SummaryEvaluationMessage(phone string, name string) { | ||
42 | 42 | ||
43 | type LogSmsRepository interface { | 43 | type LogSmsRepository interface { |
44 | Save(param *LogSms) error | 44 | Save(param *LogSms) error |
45 | + BatchInsert(params []*LogSms) error | ||
45 | Find(queryOptions map[string]interface{}) (int, []*LogSms, error) | 46 | Find(queryOptions map[string]interface{}) (int, []*LogSms, error) |
46 | } | 47 | } |
@@ -9,8 +9,8 @@ import ( | @@ -9,8 +9,8 @@ import ( | ||
9 | func TestGenerateToken(t *testing.T) { | 9 | func TestGenerateToken(t *testing.T) { |
10 | ut := UserAuth{ | 10 | ut := UserAuth{ |
11 | CompanyId: 8, | 11 | CompanyId: 8, |
12 | - UserId: 3422052542754304, | ||
13 | - Phone: "13678998765", | 12 | + UserId: 3422174102828544, |
13 | + Phone: "17708397664", | ||
14 | PlatformId: 29, | 14 | PlatformId: 29, |
15 | AdminType: 1, | 15 | AdminType: 1, |
16 | } | 16 | } |
pkg/infrastructure/dao/evaluation_cycle.go
0 → 100644
1 | +package dao | ||
2 | + | ||
3 | +import ( | ||
4 | + pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/pg/models" | ||
7 | +) | ||
8 | + | ||
9 | +type EvaluationCycleDao struct { | ||
10 | + transactionContext *pgTransaction.TransactionContext | ||
11 | +} | ||
12 | + | ||
13 | +func NewEvaluationCycleDao(options map[string]interface{}) *EvaluationCycleDao { | ||
14 | + var transactionContext *pgTransaction.TransactionContext | ||
15 | + if value, ok := options["transactionContext"]; ok { | ||
16 | + transactionContext = value.(*pgTransaction.TransactionContext) | ||
17 | + } | ||
18 | + return &EvaluationCycleDao{ | ||
19 | + transactionContext: transactionContext, | ||
20 | + } | ||
21 | +} | ||
22 | + | ||
23 | +func (d *EvaluationCycleDao) UpdateSummaryState(id int64, status domain.ProjectSummaryState) error { | ||
24 | + db := d.transactionContext.PgTx | ||
25 | + _, err := db.Model(&models.EvaluationCycle{}). | ||
26 | + Where("id=?", id). | ||
27 | + Set("summary_state=?", int(status)). | ||
28 | + Update() | ||
29 | + return err | ||
30 | +} |
@@ -383,7 +383,8 @@ func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int, | @@ -383,7 +383,8 @@ func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int, | ||
383 | t_staff_assess_0.target_user_name, | 383 | t_staff_assess_0.target_user_name, |
384 | t_staff_assess_0.begin_day, | 384 | t_staff_assess_0.begin_day, |
385 | t_staff_assess_0.cycle_name, | 385 | t_staff_assess_0.cycle_name, |
386 | - t_staff_assess_0.cycle_id | 386 | + t_staff_assess_0.cycle_id, |
387 | + t_staff_assess_0.evaluation_project_id | ||
387 | from t_staff_assess_0 | 388 | from t_staff_assess_0 |
388 | join t_project_3 on t_staff_assess_0.evaluation_project_id = t_project_3.project_id | 389 | join t_project_3 on t_staff_assess_0.evaluation_project_id = t_project_3.project_id |
389 | ) union (select t_staff_assess_0.assess_id, | 390 | ) union (select t_staff_assess_0.assess_id, |
@@ -391,7 +392,8 @@ func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int, | @@ -391,7 +392,8 @@ func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int, | ||
391 | t_staff_assess_0.target_user_name, | 392 | t_staff_assess_0.target_user_name, |
392 | t_staff_assess_0.begin_day, | 393 | t_staff_assess_0.begin_day, |
393 | t_staff_assess_0.cycle_name, | 394 | t_staff_assess_0.cycle_name, |
394 | - t_staff_assess_0.cycle_id | 395 | + t_staff_assess_0.cycle_id, |
396 | + t_staff_assess_0.evaluation_project_id | ||
395 | from t_staff_assess_0 | 397 | from t_staff_assess_0 |
396 | join t_user_1 on t_staff_assess_0.target_user_id=t_user_1.user_id | 398 | join t_user_1 on t_staff_assess_0.target_user_id=t_user_1.user_id |
397 | ) | 399 | ) |
@@ -804,6 +806,38 @@ func (d *StaffAssessDao) MemberPerformanceIndicator(likeUserName string, company | @@ -804,6 +806,38 @@ func (d *StaffAssessDao) MemberPerformanceIndicator(likeUserName string, company | ||
804 | 806 | ||
805 | } | 807 | } |
806 | 808 | ||
809 | +type IndicatorUserProject struct { | ||
810 | + AssessId int `json:"assessId"` // ID | ||
811 | + TargetUserId int `json:"targetUserId"` // 目标用户ID | ||
812 | + TargetUserName string `json:"targetUserName"` // 目标用户名称 | ||
813 | + EvaluationProjectId int `json:"evaluationProjectId"` // 项目ID | ||
814 | + | ||
815 | +} | ||
816 | + | ||
817 | +func (d *StaffAssessDao) MemberAllProjectId(companyId int, likeUserName string, operatorId int, cycleId int, hrbp int) ([]IndicatorUserProject, error) { | ||
818 | + sqlStr := ` select | ||
819 | + t_staff_assess_1.evaluation_project_id, | ||
820 | + t_staff_assess_1.target_user_id, | ||
821 | + t_staff_assess_1.target_user_name, | ||
822 | + t_staff_assess_1.assess_id | ||
823 | + from t_staff_assess_1 | ||
824 | + where 1=1 | ||
825 | + ` | ||
826 | + var condition []interface{} | ||
827 | + if len(likeUserName) > 0 { | ||
828 | + sqlStr += ` and t_staff_assess_1.target_user_name like ? ` | ||
829 | + condition = append(condition, "%"+likeUserName+"%") | ||
830 | + } | ||
831 | + // 获取前置sql语句 | ||
832 | + sqlStr0 := d.useTStaffAssess(companyId, cycleId, operatorId, "", hrbp, 5000, 0, string(domain.AssessSelf)) | ||
833 | + sqlStr = sqlStr0 + sqlStr | ||
834 | + tx := d.transactionContext.PgTx | ||
835 | + var result []IndicatorUserProject | ||
836 | + _, err := tx.Query(&result, sqlStr, condition...) | ||
837 | + return result, err | ||
838 | + | ||
839 | +} | ||
840 | + | ||
807 | type ExportPerformanceIndicator struct { | 841 | type ExportPerformanceIndicator struct { |
808 | AssessId int `json:"assessId"` // ID | 842 | AssessId int `json:"assessId"` // ID |
809 | TargetUserId string `json:"targetUserId"` // 被评估人的id | 843 | TargetUserId string `json:"targetUserId"` // 被评估人的id |
@@ -1199,7 +1233,7 @@ type AssessContentLevelCode struct { | @@ -1199,7 +1233,7 @@ type AssessContentLevelCode struct { | ||
1199 | Name string `pg:"name"` //名称 | 1233 | Name string `pg:"name"` //名称 |
1200 | } | 1234 | } |
1201 | 1235 | ||
1202 | -func (d *StaffAssessDao) CountAssessContentLevelCode(targetUserId int, assessType domain.StaffAssessType, cycleId int) ([]AssessContentLevelCode, error) { | 1236 | +func (d *StaffAssessDao) CountAssessContentLevelCode(projectId int, targetUserId int, assessType domain.StaffAssessType, cycleId int) ([]AssessContentLevelCode, error) { |
1203 | sqlStr := ` | 1237 | sqlStr := ` |
1204 | select | 1238 | select |
1205 | count(staff_assess_content.level_value) as cnt , | 1239 | count(staff_assess_content.level_value) as cnt , |
@@ -1208,16 +1242,18 @@ staff_assess_content.category , | @@ -1208,16 +1242,18 @@ staff_assess_content.category , | ||
1208 | staff_assess_content."name" | 1242 | staff_assess_content."name" |
1209 | from staff_assess_content | 1243 | from staff_assess_content |
1210 | join staff_assess on staff_assess_content.staff_assess_id = staff_assess.id | 1244 | join staff_assess on staff_assess_content.staff_assess_id = staff_assess.id |
1211 | -where 1=1 and staff_assess.deleted_at isnull | 1245 | +where 1=1 |
1246 | +and staff_assess.deleted_at isnull | ||
1212 | and target_user ->>'userId'='?' | 1247 | and target_user ->>'userId'='?' |
1213 | and staff_assess."types" = ? | 1248 | and staff_assess."types" = ? |
1214 | and staff_assess_content.level_value notnull | 1249 | and staff_assess_content.level_value notnull |
1215 | and staff_assess.cycle_id =? | 1250 | and staff_assess.cycle_id =? |
1251 | +and staff_assess.evaluation_project_id=? | ||
1216 | group by level_value,category,"name" ` | 1252 | group by level_value,category,"name" ` |
1217 | 1253 | ||
1218 | var result []AssessContentLevelCode | 1254 | var result []AssessContentLevelCode |
1219 | condition := []interface{}{ | 1255 | condition := []interface{}{ |
1220 | - targetUserId, string(assessType), cycleId, | 1256 | + targetUserId, string(assessType), cycleId, projectId, |
1221 | } | 1257 | } |
1222 | tx := d.transactionContext.PgTx | 1258 | tx := d.transactionContext.PgTx |
1223 | _, err := tx.Query(&result, sqlStr, condition...) | 1259 | _, err := tx.Query(&result, sqlStr, condition...) |
pkg/infrastructure/dao/staff_assess_dao_2.go
0 → 100644
1 | +package dao | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + | ||
6 | + "github.com/go-pg/pg/v10" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
8 | +) | ||
9 | + | ||
10 | +type DataStaffAssessContent2 struct { | ||
11 | + CycleId string `pg:"cycle_id"` //周期id | ||
12 | + CycleName string `pg:"cycle_name"` //周期名称 | ||
13 | + EvaluationProjectId string `pg:"evaluation_project_id"` // | ||
14 | + TargetUserId string `pg:"target_user_id"` //被评估人的id | ||
15 | + TargetUserName string `pg:"target_user_name"` //被评估人的名称 | ||
16 | + BeginDay string `pg:"begin_day"` //评估的日期 | ||
17 | + Value string `pg:"value"` //评估填写的值 | ||
18 | + Category string `pg:"category"` //评估项分类 | ||
19 | + ContentName string `pg:"content_name"` //评估项名称 | ||
20 | + Weight float64 `pg:"weight"` //权重 | ||
21 | + PromptText string `pg:"prompt_text"` //评估标准 | ||
22 | + Remark []domain.AssessContemtRemark `pg:"remark"` | ||
23 | +} | ||
24 | + | ||
25 | +// SearchStaffAssessContent2 用于员工绩效-综合管理-导出绩效-个人 | ||
26 | +// 获取所有评估的填写内容 | ||
27 | +// companyId 公司id | ||
28 | +// cycleId 周期id | ||
29 | +// operaterId 操作人、查看人的id | ||
30 | +// hrbp 操作人、查看人是否hrbp 1:是;-1:否 | ||
31 | +func (d *StaffAssessDao) SearchStaffAssessContent2(companyId int, cycleId int, operaterId int, hrbp int, exportUserIds []string) ( | ||
32 | + []DataStaffAssessContent2, error) { | ||
33 | + withSql := d.catchProjectIdByPermission(companyId, cycleId, operaterId, hrbp) | ||
34 | + sqlStr := ` select | ||
35 | + staff_assess.target_user ->>'userId' as target_user_id, | ||
36 | + staff_assess.evaluation_project_id, | ||
37 | + staff_assess.target_user ->>'userName' as target_user_name, | ||
38 | + to_char(staff_assess.begin_time,'YYYY-MM-DD') as begin_day, | ||
39 | + staff_assess.cycle_id, | ||
40 | + staff_assess.cycle_name, | ||
41 | + staff_assess_content.value , | ||
42 | + staff_assess_content.category , | ||
43 | + staff_assess_content."name" as content_name , | ||
44 | + staff_assess_content.weight, | ||
45 | + staff_assess_content.prompt_text, | ||
46 | + staff_assess_content.remark | ||
47 | +from staff_assess | ||
48 | +join staff_assess_content on staff_assess.id = staff_assess_content.staff_assess_id | ||
49 | +where 1=1 | ||
50 | +and staff_assess.cycle_id =? and "types" ='self' | ||
51 | +and staff_assess.evaluation_project_id in ( | ||
52 | + select t_project_4.project_id from t_project_4 | ||
53 | +) ` | ||
54 | + | ||
55 | + condition := []interface{}{cycleId} | ||
56 | + if len(exportUserIds) > 0 { | ||
57 | + sqlStr += ` and staff_assess.target_user->>'userId' in(?) ` | ||
58 | + condition = append(condition, pg.In(exportUserIds)) | ||
59 | + } | ||
60 | + | ||
61 | + sqlStr = withSql + sqlStr + ` order by staff_assess.begin_time ` | ||
62 | + result := []DataStaffAssessContent2{} | ||
63 | + tx := d.transactionContext.PgTx | ||
64 | + _, err := tx.Query(&result, sqlStr, condition...) | ||
65 | + return result, err | ||
66 | +} | ||
67 | + | ||
68 | +type DataEvaluationItemUsed2 struct { | ||
69 | + CycleId string `pg:"cycle_id"` //周期id | ||
70 | + CycleName string `pg:"cycle_name"` //周期名称 | ||
71 | + EvaluationProjectId string `pg:"evaluation_project_id"` //评估的项目 | ||
72 | + TargetUserId string `pg:"target_user_id"` //被评估人的id | ||
73 | + TargetUserName string `pg:"target_user_name"` //被评估人的名称 | ||
74 | + BeginDay string `pg:"begin_day"` //评估的日期 | ||
75 | + Category string `pg:"category"` //评估项分类 | ||
76 | + ContentName string `pg:"content_name"` //评估项名称 | ||
77 | + Weight float64 `pg:"weight"` //权重 | ||
78 | + PromptText string `pg:"prompt_text"` //评估标准 | ||
79 | +} | ||
80 | + | ||
81 | +// SearchEvaluationItemUsed2 用于员工绩效-综合管理-导出绩效-个人 | ||
82 | +// 获取所有评估的填写项 | ||
83 | +// companyId 公司id | ||
84 | +// cycleId 周期id | ||
85 | +// operaterId 操作人、查看人的id | ||
86 | +// hrbp 操作人、查看人是否hrbp 1:是;-1:否 | ||
87 | +func (d *StaffAssessDao) SearchEvaluationItemUsed2(companyId int, cycleId int, operaterId int, hrbp int, exportUserIds []string) ( | ||
88 | + []DataEvaluationItemUsed2, error) { | ||
89 | + withSql := d.catchProjectIdByPermission(companyId, cycleId, operaterId, hrbp) | ||
90 | + sqlStr := `select | ||
91 | + staff_assess.target_user ->>'userId' as target_user_id, | ||
92 | + staff_assess.evaluation_project_id , | ||
93 | + staff_assess.target_user ->>'userName' as target_user_name, | ||
94 | + to_char(staff_assess.begin_time,'YYYY-MM-DD') as begin_day, | ||
95 | + staff_assess.cycle_id, | ||
96 | + staff_assess.cycle_name, | ||
97 | + evaluation_item_used.category , | ||
98 | + evaluation_item_used."name" as content_name , | ||
99 | + evaluation_item_used.weight, | ||
100 | + evaluation_item_used.prompt_text | ||
101 | +from staff_assess | ||
102 | +join evaluation_item_used on evaluation_item_used.evaluation_project_id = staff_assess.evaluation_project_id | ||
103 | +where 1=1 | ||
104 | +and staff_assess.cycle_id =? and "types" ='self' | ||
105 | +and staff_assess.evaluation_project_id in ( | ||
106 | + select t_project_4.project_id from t_project_4 | ||
107 | +) ` | ||
108 | + condition := []interface{}{cycleId} | ||
109 | + if len(exportUserIds) > 0 { | ||
110 | + sqlStr += ` and staff_assess.target_user->>'userId' in(?) ` | ||
111 | + condition = append(condition, pg.In(exportUserIds)) | ||
112 | + } | ||
113 | + sqlStr = withSql + sqlStr | ||
114 | + result := []DataEvaluationItemUsed2{} | ||
115 | + tx := d.transactionContext.PgTx | ||
116 | + _, err := tx.Query(&result, sqlStr, condition...) | ||
117 | + return result, err | ||
118 | +} | ||
119 | + | ||
120 | +// sql 语句片段 | ||
121 | +// 按照人员可查看权限的过滤 | ||
122 | +// companyId int 公司id (必填) | ||
123 | +// cycleId int, 评估周期id (必填) | ||
124 | +// userId int, 用户id,谁要查看数据 (必填) | ||
125 | +// hrbp 是否搜索HRBP角色的用户可以查看,1:是;-1:否 (必填) | ||
126 | +func (d *StaffAssessDao) catchProjectIdByPermission(companyId int, cycleId int, operaterId int, hrbp int) string { | ||
127 | + withSql := ` | ||
128 | + with | ||
129 | + t_project_0 as( | ||
130 | + select evaluation_project.id as project_id, | ||
131 | + jsonb_array_elements_text(evaluation_project.recipients) as target_user_id, | ||
132 | + evaluation_project.pmp, | ||
133 | + evaluation_project.pmp_ids, | ||
134 | + evaluation_project.hr_bp | ||
135 | + from evaluation_project | ||
136 | + where evaluation_project.cycle_id =%d | ||
137 | + and evaluation_project.deleted_at isnull | ||
138 | + ), | ||
139 | + -- 查我的下级员工 | ||
140 | + t_user_1 as ( | ||
141 | + select "user".id::text as user_id from "user" | ||
142 | + where "user".parent_id =%d and company_id=%d | ||
143 | + ), | ||
144 | + -- 如果是HRBP | ||
145 | + t_project_1 as( | ||
146 | + select t_project_0.project_id,t_project_0.target_user_id | ||
147 | + from t_project_0 | ||
148 | + where t_project_0.hr_bp =%d | ||
149 | + ), | ||
150 | + -- 如果的项目管理员 | ||
151 | + t_project_2 as( | ||
152 | + select t_project_0.project_id,t_project_0.target_user_id | ||
153 | + from t_project_0 | ||
154 | + where t_project_0.pmp =1 | ||
155 | + and t_project_0.pmp_ids @>'["%d"]' | ||
156 | + ), | ||
157 | + -- 如果是上级员工 | ||
158 | + t_project_3 as ( | ||
159 | + select t_project_0.project_id,t_project_0.target_user_id | ||
160 | + from t_project_0 | ||
161 | + join t_user_1 on t_user_1.user_id = t_project_0.target_user_id | ||
162 | + ), | ||
163 | + -- 合并数据 | ||
164 | + t_project_4 as ( | ||
165 | + select t_project_2.project_id,t_project_2.target_user_id from t_project_2 | ||
166 | + union | ||
167 | + select t_project_1.project_id,t_project_1.target_user_id from t_project_1 | ||
168 | + union | ||
169 | + select t_project_3.project_id,t_project_3.target_user_id from t_project_3 | ||
170 | + )` | ||
171 | + params := []interface{}{cycleId, operaterId, companyId, hrbp, operaterId} | ||
172 | + | ||
173 | + return fmt.Sprintf(withSql, params...) | ||
174 | +} | ||
175 | + | ||
176 | +type TargetUserCycleProject struct { | ||
177 | + CycleId string `pg:"cycle_id" json:"cycleId"` //周期id | ||
178 | + CycleName string `pg:"cycle_name" json:"cycleName"` //周期名称 | ||
179 | + EvaluationProjectId string `pg:"evaluation_project_id" json:"evaluationProjectId"` | ||
180 | + EvaluationProjectName string `pg:"evaluation_project_name" json:"evaluationProjectName"` | ||
181 | + TargetUserId string `pg:"target_user_id" json:"targetUserId"` | ||
182 | +} | ||
183 | + | ||
184 | +// 获取目标员工的自评周期和项目 | ||
185 | +func (d *StaffAssessDao) SearchTargetUserCycleProject(companyId int, targetUserId int, limit int, offset int) ([]TargetUserCycleProject, error) { | ||
186 | + sqlStr := `select distinct | ||
187 | + staff_assess.cycle_name, | ||
188 | + staff_assess.cycle_id , | ||
189 | + staff_assess.evaluation_project_id, | ||
190 | + staff_assess.target_user ->>'userId' as target_user_id, | ||
191 | + staff_assess.evaluation_project_name | ||
192 | + from staff_assess ,staff_assess_task | ||
193 | + where 1=1 | ||
194 | + and staff_assess_task.id =staff_assess.staff_assess_task_id | ||
195 | + and staff_assess."types" ='self' | ||
196 | + and staff_assess_task.deleted_at isnull | ||
197 | + and staff_assess.deleted_at isnull | ||
198 | + and staff_assess.target_user ->>'userId'='?' | ||
199 | + and staff_assess.company_id=? | ||
200 | + ` | ||
201 | + sqlStr += ` order by cycle_id desc limit ? offset ? ` | ||
202 | + condition := []interface{}{targetUserId, companyId, limit, offset} | ||
203 | + result := []TargetUserCycleProject{} | ||
204 | + tx := d.transactionContext.PgTx | ||
205 | + _, err := tx.Query(&result, sqlStr, condition...) | ||
206 | + return result, err | ||
207 | +} | ||
208 | + | ||
209 | +type SearchConditin2 struct { | ||
210 | + CompanyId int //公司id | ||
211 | + CycleId int //周期id | ||
212 | + BeginDayList []string //评估的日期 | ||
213 | + TargetUserName string //被评估人的名称 | ||
214 | + TargetUserId []string //查询指定的人 | ||
215 | + OperaterId int //用户的id是谁在搜索数据 | ||
216 | + Hrbp int // | ||
217 | +} | ||
218 | + | ||
219 | +// 项目管理-成员列表 导出数据 | ||
220 | +func (d *StaffAssessDao) ExportDataUserAssessV2(param SearchConditin2) ([]ExportData1, error) { | ||
221 | + withSql := d.catchProjectIdByPermission(param.CompanyId, param.CycleId, param.OperaterId, param.Hrbp) | ||
222 | + sqlStr := `select | ||
223 | + staff_assess.target_user->>'userId' as target_user_id , | ||
224 | + staff_assess.target_user->>'userName' as target_user_name , | ||
225 | + to_char(staff_assess.begin_time at time zone 'PRC','YYYY-MM-DD') as begin_day, | ||
226 | + staff_assess.id as assess_id, | ||
227 | + staff_assess.cycle_id, | ||
228 | + staff_assess.cycle_name, | ||
229 | + staff_assess_content.id as content_id, | ||
230 | + staff_assess_content.value , | ||
231 | + staff_assess_content.sort_by , | ||
232 | + staff_assess_content.category , | ||
233 | + staff_assess_content."name" as content_name , | ||
234 | + staff_assess_content.weight, | ||
235 | + staff_assess_content.prompt_text , | ||
236 | + staff_assess_content.remark | ||
237 | +from staff_assess | ||
238 | +join t_project_4 on staff_assess.evaluation_project_id =t_project_4.project_id | ||
239 | +left join staff_assess_content on staff_assess.id = staff_assess_content.staff_assess_id | ||
240 | +where 1=1 | ||
241 | +and staff_assess."types" ='self' | ||
242 | +` | ||
243 | + condition := []interface{}{} | ||
244 | + if len(param.TargetUserName) > 0 { | ||
245 | + condition = append(condition, "%"+param.TargetUserName+"%") | ||
246 | + sqlStr += ` and staff_assess.target_user->>'userName' like ? ` | ||
247 | + } | ||
248 | + if len(param.BeginDayList) > 0 { | ||
249 | + condition = append(condition, pg.In(param.BeginDayList)) | ||
250 | + sqlStr += ` and to_char(staff_assess.begin_time at time zone 'PRC','YYYY-MM-DD') in(?) ` | ||
251 | + } | ||
252 | + if len(param.TargetUserId) > 0 { | ||
253 | + condition = append(condition, pg.In(param.TargetUserId)) | ||
254 | + sqlStr += ` and staff_assess.target_user->>'userId' in (?) ` | ||
255 | + } | ||
256 | + | ||
257 | + sqlStr = withSql + sqlStr + ` order by convert_to(staff_assess.target_user->>'userName','GBK'),begin_day,staff_assess_content.sort_by ` | ||
258 | + tx := d.transactionContext.PgTx | ||
259 | + var result []ExportData1 | ||
260 | + _, err := tx.Query(&result, sqlStr, condition...) | ||
261 | + return result, err | ||
262 | +} |
@@ -13,6 +13,7 @@ type EvaluationCycle struct { | @@ -13,6 +13,7 @@ type EvaluationCycle struct { | ||
13 | CompanyId int64 `comment:"公司ID"` | 13 | CompanyId int64 `comment:"公司ID"` |
14 | CreatorId int64 `comment:"创建人ID"` | 14 | CreatorId int64 `comment:"创建人ID"` |
15 | KpiCycle int `comment:"考核周期(1日、2周、3月)"` | 15 | KpiCycle int `comment:"考核周期(1日、2周、3月)"` |
16 | + SummaryState int `comment:"周期评估是否下发" pg:",use_zero"` | ||
16 | CreatedAt time.Time `comment:"创建时间"` | 17 | CreatedAt time.Time `comment:"创建时间"` |
17 | UpdatedAt time.Time `comment:"更新时间"` | 18 | UpdatedAt time.Time `comment:"更新时间"` |
18 | DeletedAt *time.Time `comment:"删除时间"` | 19 | DeletedAt *time.Time `comment:"删除时间"` |
@@ -30,6 +30,7 @@ func (repo *EvaluationCycleRepository) TransformToDomain(m *models.EvaluationCyc | @@ -30,6 +30,7 @@ func (repo *EvaluationCycleRepository) TransformToDomain(m *models.EvaluationCyc | ||
30 | CompanyId: m.CompanyId, | 30 | CompanyId: m.CompanyId, |
31 | CreatorId: m.CreatorId, | 31 | CreatorId: m.CreatorId, |
32 | KpiCycle: m.KpiCycle, | 32 | KpiCycle: m.KpiCycle, |
33 | + SummaryState: domain.ProjectSummaryState(m.SummaryState), | ||
33 | CreatedAt: m.CreatedAt.Local(), | 34 | CreatedAt: m.CreatedAt.Local(), |
34 | UpdatedAt: m.UpdatedAt.Local(), | 35 | UpdatedAt: m.UpdatedAt.Local(), |
35 | DeletedAt: m.DeletedAt, | 36 | DeletedAt: m.DeletedAt, |
@@ -45,6 +46,7 @@ func (repo *EvaluationCycleRepository) TransformToModel(d *domain.EvaluationCycl | @@ -45,6 +46,7 @@ func (repo *EvaluationCycleRepository) TransformToModel(d *domain.EvaluationCycl | ||
45 | CompanyId: d.CompanyId, | 46 | CompanyId: d.CompanyId, |
46 | CreatorId: d.CreatorId, | 47 | CreatorId: d.CreatorId, |
47 | KpiCycle: d.KpiCycle, | 48 | KpiCycle: d.KpiCycle, |
49 | + SummaryState: int(d.SummaryState), | ||
48 | CreatedAt: d.CreatedAt, | 50 | CreatedAt: d.CreatedAt, |
49 | UpdatedAt: d.UpdatedAt, | 51 | UpdatedAt: d.UpdatedAt, |
50 | DeletedAt: d.DeletedAt, | 52 | DeletedAt: d.DeletedAt, |
@@ -127,6 +129,10 @@ func (repo *EvaluationCycleRepository) Find(queryOptions map[string]interface{}) | @@ -127,6 +129,10 @@ func (repo *EvaluationCycleRepository) Find(queryOptions map[string]interface{}) | ||
127 | query.Where("id in (?)", pg.In(v)) | 129 | query.Where("id in (?)", pg.In(v)) |
128 | } | 130 | } |
129 | 131 | ||
132 | + if v, ok := queryOptions["id"]; ok { | ||
133 | + query.Where("id=?", v) | ||
134 | + } | ||
135 | + | ||
130 | if v, ok := queryOptions["companyId"]; ok { | 136 | if v, ok := queryOptions["companyId"]; ok { |
131 | query.Where("company_id = ?", v) | 137 | query.Where("company_id = ?", v) |
132 | } | 138 | } |
@@ -191,3 +197,25 @@ func (repo *EvaluationCycleRepository) Count(queryOptions map[string]interface{} | @@ -191,3 +197,25 @@ func (repo *EvaluationCycleRepository) Count(queryOptions map[string]interface{} | ||
191 | } | 197 | } |
192 | return int64(count), nil | 198 | return int64(count), nil |
193 | } | 199 | } |
200 | + | ||
201 | +// 获取已结束的周期 | ||
202 | +func (repo *EvaluationCycleRepository) FindCycleEnd(limit int) ([]*domain.EvaluationCycle, error) { | ||
203 | + tx := repo.transactionContext.PgTx | ||
204 | + var m []*models.EvaluationCycle | ||
205 | + query := tx.Model(&m). | ||
206 | + Where("deleted_at isnull"). | ||
207 | + Where("time_end<=?", time.Now()). | ||
208 | + Where("summary_state=0"). | ||
209 | + Limit(limit) | ||
210 | + | ||
211 | + err := query.Select() | ||
212 | + if err != nil { | ||
213 | + return nil, err | ||
214 | + } | ||
215 | + var arrays []*domain.EvaluationCycle | ||
216 | + for _, v := range m { | ||
217 | + d := repo.TransformToDomain(v) | ||
218 | + arrays = append(arrays, &d) | ||
219 | + } | ||
220 | + return arrays, nil | ||
221 | +} |
@@ -96,3 +96,33 @@ func (repo *LogSmsRepository) TransformToDomain(d *models.LogSms) *domain.LogSms | @@ -96,3 +96,33 @@ func (repo *LogSmsRepository) TransformToDomain(d *models.LogSms) *domain.LogSms | ||
96 | CreatedAt: d.CreatedAt, | 96 | CreatedAt: d.CreatedAt, |
97 | } | 97 | } |
98 | } | 98 | } |
99 | + | ||
100 | +//批量添加 | ||
101 | + | ||
102 | +func (repo *LogSmsRepository) BatchInsert(params []*domain.LogSms) error { | ||
103 | + smsList := []models.LogSms{} | ||
104 | + for _, param := range params { | ||
105 | + m := models.LogSms{ | ||
106 | + Id: param.Id, | ||
107 | + Phone: param.Phone, | ||
108 | + TemplateId: param.TemplateId, | ||
109 | + Template: param.Template, | ||
110 | + Value: param.Value, | ||
111 | + CreatedAt: param.CreatedAt, | ||
112 | + Result: param.Result, | ||
113 | + Status: string(param.Status), | ||
114 | + From: param.From, | ||
115 | + Index: param.Index, | ||
116 | + ExecuteAt: param.ExecuteAt, | ||
117 | + } | ||
118 | + smsList = append(smsList, m) | ||
119 | + } | ||
120 | + | ||
121 | + tx := repo.transactionContext.PgTx | ||
122 | + | ||
123 | + _, err := tx.Model(&smsList).Insert() | ||
124 | + if err != nil { | ||
125 | + return err | ||
126 | + } | ||
127 | + return nil | ||
128 | +} |
@@ -128,9 +128,15 @@ func (repo *StaffAssessRepository) Find(queryOptions map[string]interface{}) (in | @@ -128,9 +128,15 @@ func (repo *StaffAssessRepository) Find(queryOptions map[string]interface{}) (in | ||
128 | if v, ok := queryOptions["offset"].(int); ok { | 128 | if v, ok := queryOptions["offset"].(int); ok { |
129 | query.Offset(v) | 129 | query.Offset(v) |
130 | } | 130 | } |
131 | + if v, ok := queryOptions["id"]; ok { | ||
132 | + query.Where("staff_assess.id=?", v) | ||
133 | + } | ||
131 | if v, ok := queryOptions["targetUserId"]; ok { | 134 | if v, ok := queryOptions["targetUserId"]; ok { |
132 | query.Where(`staff_assess.target_user->>'userId'='?'`, v) | 135 | query.Where(`staff_assess.target_user->>'userId'='?'`, v) |
133 | } | 136 | } |
137 | + if v, ok := queryOptions["targetUserIds"]; ok { | ||
138 | + query.Where(`staff_assess.target_user->>'userId' in(?)`, pg.In(v)) | ||
139 | + } | ||
134 | 140 | ||
135 | if v, ok := queryOptions["targetUserName"].(string); ok { | 141 | if v, ok := queryOptions["targetUserName"].(string); ok { |
136 | query.Where(`staff_assess.target_user->>'userName' like ?`, fmt.Sprintf("%%%v%%", v)) | 142 | query.Where(`staff_assess.target_user->>'userName' like ?`, fmt.Sprintf("%%%v%%", v)) |
@@ -138,16 +144,14 @@ func (repo *StaffAssessRepository) Find(queryOptions map[string]interface{}) (in | @@ -138,16 +144,14 @@ func (repo *StaffAssessRepository) Find(queryOptions map[string]interface{}) (in | ||
138 | if v, ok := queryOptions["executorId"]; ok { | 144 | if v, ok := queryOptions["executorId"]; ok { |
139 | query.Where(`staff_assess.executor->>'userId'='?'`, v) | 145 | query.Where(`staff_assess.executor->>'userId'='?'`, v) |
140 | } | 146 | } |
141 | - | ||
142 | if v, ok := queryOptions["cycleId"]; ok { | 147 | if v, ok := queryOptions["cycleId"]; ok { |
143 | query.Where(`staff_assess.cycle_id=?`, v) | 148 | query.Where(`staff_assess.cycle_id=?`, v) |
144 | } | 149 | } |
145 | if v, ok := queryOptions["staffAssessTaskId"]; ok { | 150 | if v, ok := queryOptions["staffAssessTaskId"]; ok { |
146 | query.Where(`staff_assess.staff_assess_task_id=?`, v) | 151 | query.Where(`staff_assess.staff_assess_task_id=?`, v) |
147 | } | 152 | } |
148 | - | ||
149 | - if v, ok := queryOptions["id"]; ok { | ||
150 | - query.Where("staff_assess.id=?", v) | 153 | + if v, ok := queryOptions["types"]; ok { |
154 | + query.Where(`staff_assess.types=?`, v) | ||
151 | } | 155 | } |
152 | if v, ok := queryOptions["typesList"].([]string); ok { | 156 | if v, ok := queryOptions["typesList"].([]string); ok { |
153 | query.Where("staff_assess.types in(?)", pg.In(v)) | 157 | query.Where("staff_assess.types in(?)", pg.In(v)) |
@@ -161,6 +165,9 @@ func (repo *StaffAssessRepository) Find(queryOptions map[string]interface{}) (in | @@ -161,6 +165,9 @@ func (repo *StaffAssessRepository) Find(queryOptions map[string]interface{}) (in | ||
161 | if v, ok := queryOptions["beginDay"]; ok { | 165 | if v, ok := queryOptions["beginDay"]; ok { |
162 | query.Where("to_char(staff_assess.begin_time at time zone 'PRC','YYYY-MM-DD')= ? ", v) | 166 | query.Where("to_char(staff_assess.begin_time at time zone 'PRC','YYYY-MM-DD')= ? ", v) |
163 | } | 167 | } |
168 | + if v, ok := queryOptions["evaluationProjectId"]; ok { | ||
169 | + query.Where("staff_assess.evaluation_project_id=?", v) | ||
170 | + } | ||
164 | query.Order("staff_assess.id DESC") | 171 | query.Order("staff_assess.id DESC") |
165 | count, err := query.SelectAndCount() | 172 | count, err := query.SelectAndCount() |
166 | if err != nil { | 173 | if err != nil { |
@@ -96,6 +96,26 @@ func (controller *ProjectController) ActivateProject() { | @@ -96,6 +96,26 @@ func (controller *ProjectController) ActivateProject() { | ||
96 | } | 96 | } |
97 | } | 97 | } |
98 | 98 | ||
99 | +func (controller *ProjectController) PauseProject() { | ||
100 | + ruService := service.NewEvaluationProjectService() | ||
101 | + in := &command.ActivateProjectCommand{} | ||
102 | + if err := controller.Unmarshal(in); err != nil { | ||
103 | + controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | ||
104 | + } else { | ||
105 | + controller.Response(ruService.Pause(in)) | ||
106 | + } | ||
107 | +} | ||
108 | + | ||
109 | +func (controller *ProjectController) ResumeProject() { | ||
110 | + ruService := service.NewEvaluationProjectService() | ||
111 | + in := &command.ActivateProjectCommand{} | ||
112 | + if err := controller.Unmarshal(in); err != nil { | ||
113 | + controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | ||
114 | + } else { | ||
115 | + controller.Response(ruService.Resume(in)) | ||
116 | + } | ||
117 | +} | ||
118 | + | ||
99 | func (controller *ProjectController) CopyProject() { | 119 | func (controller *ProjectController) CopyProject() { |
100 | ruService := service.NewEvaluationProjectService() | 120 | ruService := service.NewEvaluationProjectService() |
101 | in := &command.CopyProjectCommand{} | 121 | in := &command.CopyProjectCommand{} |
@@ -249,7 +249,6 @@ func (c *StaffAssessController) QueryMemberPerformanceIndicator() { | @@ -249,7 +249,6 @@ func (c *StaffAssessController) QueryMemberPerformanceIndicator() { | ||
249 | if user := middlewares.GetUser(c.Ctx); user != nil { | 249 | if user := middlewares.GetUser(c.Ctx); user != nil { |
250 | in.CompanyId = int(user.CompanyId) | 250 | in.CompanyId = int(user.CompanyId) |
251 | in.OperatorId = int(user.UserId) | 251 | in.OperatorId = int(user.UserId) |
252 | - | ||
253 | } | 252 | } |
254 | c.Response(srv.QueryMemberPerformanceIndicator(in)) | 253 | c.Response(srv.QueryMemberPerformanceIndicator(in)) |
255 | } | 254 | } |
@@ -311,7 +310,7 @@ func (c *StaffAssessController) ExportUserAssess2() { | @@ -311,7 +310,7 @@ func (c *StaffAssessController) ExportUserAssess2() { | ||
311 | userReq := middlewares.GetUser(c.Ctx) | 310 | userReq := middlewares.GetUser(c.Ctx) |
312 | paramReq.CompanyId = int(userReq.CompanyId) | 311 | paramReq.CompanyId = int(userReq.CompanyId) |
313 | paramReq.OperatorId = int(userReq.UserId) | 312 | paramReq.OperatorId = int(userReq.UserId) |
314 | - data, err := srv.ExportUserAssess2(paramReq) | 313 | + data, err := srv.ExportUserAssess2V2(paramReq) |
315 | if err != nil { | 314 | if err != nil { |
316 | c.Response(nil, err) | 315 | c.Response(nil, err) |
317 | return | 316 | return |
@@ -324,3 +323,35 @@ func (c *StaffAssessController) ExportUserAssess2() { | @@ -324,3 +323,35 @@ func (c *StaffAssessController) ExportUserAssess2() { | ||
324 | c.Ctx.Output.Header("Expires", "0") | 323 | c.Ctx.Output.Header("Expires", "0") |
325 | data.Write(c.Ctx.ResponseWriter) | 324 | data.Write(c.Ctx.ResponseWriter) |
326 | } | 325 | } |
326 | + | ||
327 | +// ListTargetUserSelfCycle 获取目标员工自评周期列表 | ||
328 | +func (c *StaffAssessController) ListTargetUserSelfCycle() { | ||
329 | + srv := service.NewStaffAssessServeice() | ||
330 | + paramReq := &query.ListTargetUserCycleQuery{} | ||
331 | + err := c.BindJSON(paramReq) | ||
332 | + if err != nil { | ||
333 | + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error()) | ||
334 | + c.Response(nil, e) | ||
335 | + return | ||
336 | + } | ||
337 | + userReq := middlewares.GetUser(c.Ctx) | ||
338 | + paramReq.CompanyId = int(userReq.CompanyId) | ||
339 | + data, err := srv.ListTargetUserSelfCycle(paramReq) | ||
340 | + c.Response(data, err) | ||
341 | +} | ||
342 | + | ||
343 | +// ListTargetUserSelfCycle 按照周期获取员工的每日自评小结 | ||
344 | +func (c *StaffAssessController) GetStaffAsessSelfCountLevel() { | ||
345 | + srv := service.NewStaffAssessServeice() | ||
346 | + paramReq := &query.StaffAsessSelfCountLevel{} | ||
347 | + err := c.BindJSON(paramReq) | ||
348 | + if err != nil { | ||
349 | + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error()) | ||
350 | + c.Response(nil, e) | ||
351 | + return | ||
352 | + } | ||
353 | + userReq := middlewares.GetUser(c.Ctx) | ||
354 | + paramReq.CompanyId = int(userReq.CompanyId) | ||
355 | + data, err := srv.GetStaffAsessSelfCountLevel(paramReq) | ||
356 | + c.Response(data, err) | ||
357 | +} |
@@ -90,8 +90,6 @@ func (c *SummaryEvaluationController) GetTargetUserCycleList() { | @@ -90,8 +90,6 @@ func (c *SummaryEvaluationController) GetTargetUserCycleList() { | ||
90 | c.Response(nil, e) | 90 | c.Response(nil, e) |
91 | return | 91 | return |
92 | } | 92 | } |
93 | - // userReq := middlewares.GetUser(c.Ctx) | ||
94 | - // paramReq.UserId = int(userReq.UserId) | ||
95 | data, err := srv.GetTargetUserCycleList(paramReq) | 93 | data, err := srv.GetTargetUserCycleList(paramReq) |
96 | c.Response(data, err) | 94 | c.Response(data, err) |
97 | } | 95 | } |
@@ -110,7 +108,6 @@ func (c *SummaryEvaluationController) CountEvaluationSelfLevel() { | @@ -110,7 +108,6 @@ func (c *SummaryEvaluationController) CountEvaluationSelfLevel() { | ||
110 | paramReq.CompanyId = int(userReq.CompanyId) | 108 | paramReq.CompanyId = int(userReq.CompanyId) |
111 | data, err := srv.CountEvaluationSelfLevel(paramReq) | 109 | data, err := srv.CountEvaluationSelfLevel(paramReq) |
112 | c.Response(data, err) | 110 | c.Response(data, err) |
113 | - | ||
114 | } | 111 | } |
115 | 112 | ||
116 | func (c *SummaryEvaluationController) Evaluation360List() { | 113 | func (c *SummaryEvaluationController) Evaluation360List() { |
@@ -19,6 +19,8 @@ func init() { | @@ -19,6 +19,8 @@ func init() { | ||
19 | web.NSRouter("/check-recipients", &controllers.ProjectController{}, "Post:CheckRecipients"), | 19 | web.NSRouter("/check-recipients", &controllers.ProjectController{}, "Post:CheckRecipients"), |
20 | web.NSRouter("/copy", &controllers.ProjectController{}, "Post:CopyProject"), | 20 | web.NSRouter("/copy", &controllers.ProjectController{}, "Post:CopyProject"), |
21 | web.NSRouter("/activate", &controllers.ProjectController{}, "Post:ActivateProject"), | 21 | web.NSRouter("/activate", &controllers.ProjectController{}, "Post:ActivateProject"), |
22 | + web.NSRouter("/pause", &controllers.ProjectController{}, "Post:PauseProject"), | ||
23 | + web.NSRouter("/resume", &controllers.ProjectController{}, "Post:ResumeProject"), | ||
22 | ) | 24 | ) |
23 | web.AddNamespace(ns) | 25 | web.AddNamespace(ns) |
24 | } | 26 | } |
@@ -20,7 +20,6 @@ func init() { | @@ -20,7 +20,6 @@ func init() { | ||
20 | web.NSCtrlPost("/cycle/day/content/export", (*controllers.StaffAssessController).ExportAssessContentCycleDay), //根据周期里的考核日期,导出员工填写评估内容列表 | 20 | web.NSCtrlPost("/cycle/day/content/export", (*controllers.StaffAssessController).ExportAssessContentCycleDay), //根据周期里的考核日期,导出员工填写评估内容列表 |
21 | web.NSCtrlPost("/cycle/day/analysis", (*controllers.StaffAssessController).AnalysisData), //员工绩效-项目管理-矩阵分析 | 21 | web.NSCtrlPost("/cycle/day/analysis", (*controllers.StaffAssessController).AnalysisData), //员工绩效-项目管理-矩阵分析 |
22 | web.NSCtrlPost("/cycle/day/content/export2", (*controllers.StaffAssessController).ExportUserAssess2), //员工绩效-综合管理-导出绩效-个人 | 22 | web.NSCtrlPost("/cycle/day/content/export2", (*controllers.StaffAssessController).ExportUserAssess2), //员工绩效-综合管理-导出绩效-个人 |
23 | - | ||
24 | ) | 23 | ) |
25 | 24 | ||
26 | assessNS := web.NewNamespace("/v1/staff-assess", | 25 | assessNS := web.NewNamespace("/v1/staff-assess", |
@@ -35,6 +34,8 @@ func init() { | @@ -35,6 +34,8 @@ func init() { | ||
35 | web.NSCtrlPost("/summary/users", (*controllers.StaffAssessController).QueryMemberSummary), //员工绩效-综合管理-成员列表 | 34 | web.NSCtrlPost("/summary/users", (*controllers.StaffAssessController).QueryMemberSummary), //员工绩效-综合管理-成员列表 |
36 | web.NSCtrlPost("/summary/users-indicator", (*controllers.StaffAssessController).QueryMemberPerformanceIndicator), //员工绩效-综合管理-绩效导出指标 | 35 | web.NSCtrlPost("/summary/users-indicator", (*controllers.StaffAssessController).QueryMemberPerformanceIndicator), //员工绩效-综合管理-绩效导出指标 |
37 | web.NSCtrlPost("/summary/export-indicator", (*controllers.StaffAssessController).ExportPerformanceIndicator), //员工绩效-综合管理-绩效导出指标 | 36 | web.NSCtrlPost("/summary/export-indicator", (*controllers.StaffAssessController).ExportPerformanceIndicator), //员工绩效-综合管理-绩效导出指标 |
37 | + web.NSCtrlPost("/target_user/self/cycle", (*controllers.StaffAssessController).ListTargetUserSelfCycle), //获取员工自评的周期下拉列表 | ||
38 | + web.NSCtrlPost("/target_user/self/summary", (*controllers.StaffAssessController).GetStaffAsessSelfCountLevel), //获取员工每日自评小结 | ||
38 | ) | 39 | ) |
39 | //v2 改版 | 40 | //v2 改版 |
40 | assessTaskV2NS := web.NewNamespace("/v2/staff-assess-task", | 41 | assessTaskV2NS := web.NewNamespace("/v2/staff-assess-task", |
@@ -58,7 +58,6 @@ func NextTime(now0 time.Time, start time.Time, kpiCycle int) time.Time { | @@ -58,7 +58,6 @@ func NextTime(now0 time.Time, start time.Time, kpiCycle int) time.Time { | ||
58 | switch kpiCycle { | 58 | switch kpiCycle { |
59 | case domain.KpiCycleDay: | 59 | case domain.KpiCycleDay: |
60 | nextTime = now0 // 当前时间的0点开始发送 | 60 | nextTime = now0 // 当前时间的0点开始发送 |
61 | - //nextTime = timeconv.AddDate(now0, 0, 0, 0) // 当前时间的0点开始发送 | ||
62 | break | 61 | break |
63 | case domain.KpiCycleWeek: | 62 | case domain.KpiCycleWeek: |
64 | offsetSeconds := int64(now0.Sub(start0).Seconds()) | 63 | offsetSeconds := int64(now0.Sub(start0).Seconds()) |
-
请 注册 或 登录 后发表评论