作者 tangxvhui

周期评估 查看限制

@@ -15,6 +15,8 @@ type QueryEvaluationList struct { @@ -15,6 +15,8 @@ type QueryEvaluationList struct {
15 PageNumber int `json:"pageNumber"` 15 PageNumber int `json:"pageNumber"`
16 PageSize int `json:"pageSize"` 16 PageSize int `json:"pageSize"`
17 CycleId int `json:"cycleId,string"` 17 CycleId int `json:"cycleId,string"`
18 - CompanyId int `json:"-"`  
19 - TargetUserName string `json:"targetUserName"` 18 + CompanyId int `json:"-"` //当前公司
  19 + UserId int `json:"-"` //当前操作的员工id
  20 + TargetUserName string `json:"targetUserName"` //按照目标员工的名称搜索
  21 + SummaryEvaluationId []string `json:"summaryEvaluationId"` //按照id 获取数据
20 } 22 }
@@ -2,10 +2,12 @@ package service @@ -2,10 +2,12 @@ package service
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
  5 + "strconv"
5 6
6 "github.com/linmadan/egglib-go/core/application" 7 "github.com/linmadan/egglib-go/core/application"
7 "github.com/xuri/excelize/v2" 8 "github.com/xuri/excelize/v2"
8 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" 9 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
  10 + roleService "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/role"
9 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/command" 11 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/command"
10 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" 12 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
11 ) 13 )
@@ -23,6 +25,13 @@ func (srv *SummaryEvaluationService) ExportAllEvaluationSuper(param *command.Que @@ -23,6 +25,13 @@ func (srv *SummaryEvaluationService) ExportAllEvaluationSuper(param *command.Que
23 defer func() { 25 defer func() {
24 _ = transactionContext.RollbackTransaction() 26 _ = transactionContext.RollbackTransaction()
25 }() 27 }()
  28 + flagHrbp, err := roleService.GetHRBP(transactionContext, param.CompanyId, param.UserId)
  29 + if err != nil {
  30 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  31 + }
  32 + if flagHrbp != 1 {
  33 + return nil, application.ThrowError(application.TRANSACTION_ERROR, "没有操作权限")
  34 + }
26 evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{ 35 evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{
27 "transactionContext": transactionContext, 36 "transactionContext": transactionContext,
28 }) 37 })
@@ -47,6 +56,16 @@ func (srv *SummaryEvaluationService) ExportAllEvaluationSuper(param *command.Que @@ -47,6 +56,16 @@ func (srv *SummaryEvaluationService) ExportAllEvaluationSuper(param *command.Que
47 if len(param.TargetUserName) > 0 { 56 if len(param.TargetUserName) > 0 {
48 condition1["targetUserName"] = "%" + param.TargetUserName + "%" 57 condition1["targetUserName"] = "%" + param.TargetUserName + "%"
49 } 58 }
  59 + if len(param.SummaryEvaluationId) > 0 {
  60 + summaryEvaluationIds := []int{}
  61 + for _, v := range param.SummaryEvaluationId {
  62 + id, _ := strconv.Atoi(v)
  63 + summaryEvaluationIds = append(summaryEvaluationIds, id)
  64 + }
  65 + if len(summaryEvaluationIds) > 0 {
  66 + condition1["id"] = summaryEvaluationIds
  67 + }
  68 + }
50 //获取评估列表信息 69 //获取评估列表信息
51 _, evaluationList, err := evaluationRepo.Find(condition1) 70 _, evaluationList, err := evaluationRepo.Find(condition1)
52 if err != nil { 71 if err != nil {
@@ -61,7 +80,6 @@ func (srv *SummaryEvaluationService) ExportAllEvaluationSuper(param *command.Que @@ -61,7 +80,6 @@ func (srv *SummaryEvaluationService) ExportAllEvaluationSuper(param *command.Que
61 } 80 }
62 userMap[int64(v.TargetUser.UserId)] = nil 81 userMap[int64(v.TargetUser.UserId)] = nil
63 targetUserIds = append(targetUserIds, v.TargetUser.UserId) 82 targetUserIds = append(targetUserIds, v.TargetUser.UserId)
64 -  
65 } 83 }
66 if len(targetUserIds) > 0 { 84 if len(targetUserIds) > 0 {
67 _, userList, err := userRepo.Find(map[string]interface{}{ 85 _, userList, err := userRepo.Find(map[string]interface{}{
@@ -1458,6 +1458,7 @@ func (srv *SummaryEvaluationService) GetTargetUserEvaluationSuper(param *command @@ -1458,6 +1458,7 @@ func (srv *SummaryEvaluationService) GetTargetUserEvaluationSuper(param *command
1458 1458
1459 // 获取周期综合评估下,周期评估列表 1459 // 获取周期综合评估下,周期评估列表
1460 func (srv *SummaryEvaluationService) ListAllEvaluationSuper(param *command.QueryEvaluationList) (map[string]interface{}, error) { 1460 func (srv *SummaryEvaluationService) ListAllEvaluationSuper(param *command.QueryEvaluationList) (map[string]interface{}, error) {
  1461 +
1461 transactionContext, err := factory.CreateTransactionContext(nil) 1462 transactionContext, err := factory.CreateTransactionContext(nil)
1462 if err != nil { 1463 if err != nil {
1463 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 1464 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -1468,6 +1469,13 @@ func (srv *SummaryEvaluationService) ListAllEvaluationSuper(param *command.Query @@ -1468,6 +1469,13 @@ func (srv *SummaryEvaluationService) ListAllEvaluationSuper(param *command.Query
1468 defer func() { 1469 defer func() {
1469 _ = transactionContext.RollbackTransaction() 1470 _ = transactionContext.RollbackTransaction()
1470 }() 1471 }()
  1472 + flagHrbp, err := roleService.GetHRBP(transactionContext, param.CompanyId, param.UserId)
  1473 + if err != nil {
  1474 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  1475 + }
  1476 + if flagHrbp != 1 {
  1477 + return map[string]interface{}{}, nil
  1478 + }
1471 evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{ 1479 evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{
1472 "transactionContext": transactionContext, 1480 "transactionContext": transactionContext,
1473 }) 1481 })
@@ -171,6 +171,9 @@ func (repo *SummaryEvaluationRepository) Find(queryOptions map[string]interface{ @@ -171,6 +171,9 @@ func (repo *SummaryEvaluationRepository) Find(queryOptions map[string]interface{
171 t := v.(time.Time) 171 t := v.(time.Time)
172 query.Where(`summary_evaluation.end_time>=?`, t) 172 query.Where(`summary_evaluation.end_time>=?`, t)
173 } 173 }
  174 + if v, ok := queryOptions["id"]; ok {
  175 + query.Where(`summary_evaluation.id in (?)`, pg.In(v))
  176 + }
174 177
175 query.Order("id desc") 178 query.Order("id desc")
176 count, err := query.SelectAndCount() 179 count, err := query.SelectAndCount()
@@ -34,7 +34,6 @@ func (repo *SummaryEvaluationValueRepository) TransformToDomain(d *models.Summar @@ -34,7 +34,6 @@ func (repo *SummaryEvaluationValueRepository) TransformToDomain(d *models.Summar
34 Rating: d.Rating, 34 Rating: d.Rating,
35 CreatedAt: d.CreatedAt, 35 CreatedAt: d.CreatedAt,
36 UpdatedAt: d.UpdatedAt, 36 UpdatedAt: d.UpdatedAt,
37 - // IsTemporary: d.IsTemporary,  
38 } 37 }
39 } 38 }
40 39
@@ -51,7 +50,6 @@ func (repo *SummaryEvaluationValueRepository) Save(param *domain.SummaryEvaluati @@ -51,7 +50,6 @@ func (repo *SummaryEvaluationValueRepository) Save(param *domain.SummaryEvaluati
51 Remark: param.Remark, 50 Remark: param.Remark,
52 CreatedAt: param.CreatedAt, 51 CreatedAt: param.CreatedAt,
53 UpdatedAt: param.UpdatedAt, 52 UpdatedAt: param.UpdatedAt,
54 - // IsTemporary: param.IsTemporary,  
55 } 53 }
56 db := repo.transactionContext.PgTx 54 db := repo.transactionContext.PgTx
57 if m.Id == 0 { 55 if m.Id == 0 {
@@ -64,6 +62,7 @@ func (repo *SummaryEvaluationValueRepository) Save(param *domain.SummaryEvaluati @@ -64,6 +62,7 @@ func (repo *SummaryEvaluationValueRepository) Save(param *domain.SummaryEvaluati
64 } else { 62 } else {
65 m.UpdatedAt = time.Now() 63 m.UpdatedAt = time.Now()
66 _, err := db.Model(&m).WherePK().Update() 64 _, err := db.Model(&m).WherePK().Update()
  65 +
67 if err != nil { 66 if err != nil {
68 return err 67 return err
69 } 68 }
@@ -332,6 +332,7 @@ func (c *SummaryEvaluationController) ListAllEvaluationSuper() { @@ -332,6 +332,7 @@ func (c *SummaryEvaluationController) ListAllEvaluationSuper() {
332 } 332 }
333 userReq := middlewares.GetUser(c.Ctx) 333 userReq := middlewares.GetUser(c.Ctx)
334 param.CompanyId = int(userReq.CompanyId) 334 param.CompanyId = int(userReq.CompanyId)
  335 + param.UserId = int(userReq.UserId)
335 data, err := srv.ListAllEvaluationSuper(param) 336 data, err := srv.ListAllEvaluationSuper(param)
336 c.Response(data, err) 337 c.Response(data, err)
337 } 338 }
@@ -347,6 +348,7 @@ func (c *SummaryEvaluationController) ExportAllEvaluationSuper() { @@ -347,6 +348,7 @@ func (c *SummaryEvaluationController) ExportAllEvaluationSuper() {
347 return 348 return
348 } 349 }
349 userReq := middlewares.GetUser(c.Ctx) 350 userReq := middlewares.GetUser(c.Ctx)
  351 + param.UserId = int(userReq.UserId)
350 param.CompanyId = int(userReq.CompanyId) 352 param.CompanyId = int(userReq.CompanyId)
351 data, err := srv.ExportAllEvaluationSuper(param) 353 data, err := srv.ExportAllEvaluationSuper(param)
352 if err != nil { 354 if err != nil {