作者 tangxvhui
@@ -7,6 +7,7 @@ import ( @@ -7,6 +7,7 @@ import (
7 7
8 type UpdatePermissionCommand struct { 8 type UpdatePermissionCommand struct {
9 CompanyId int64 `cname:"公司Id"` 9 CompanyId int64 `cname:"公司Id"`
  10 + UserId int64 `cname:"用户ID"`
10 OptHrScore int `cname:"上级修改人资综评分数" json:"optHrScore" valid:"Required"` 11 OptHrScore int `cname:"上级修改人资综评分数" json:"optHrScore" valid:"Required"`
11 OptEvalScore int `cname:"上级修改360°综评分数" json:"optEvalScore" valid:"Required"` 12 OptEvalScore int `cname:"上级修改360°综评分数" json:"optEvalScore" valid:"Required"`
12 OptConfirmPerf int `cname:"是否需要员工确认绩效" json:"optConfirmPerf"` 13 OptConfirmPerf int `cname:"是否需要员工确认绩效" json:"optConfirmPerf"`
@@ -4,6 +4,7 @@ import ( @@ -4,6 +4,7 @@ import (
4 "github.com/linmadan/egglib-go/core/application" 4 "github.com/linmadan/egglib-go/core/application"
5 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" 5 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
6 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/permission/command" 6 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/permission/command"
  7 + service "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/role"
7 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" 8 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
8 ) 9 )
9 10
@@ -23,6 +24,7 @@ func (rs *PermissionService) Update(in *command.UpdatePermissionCommand) (interf @@ -23,6 +24,7 @@ func (rs *PermissionService) Update(in *command.UpdatePermissionCommand) (interf
23 defer func() { 24 defer func() {
24 transactionContext.RollbackTransaction() 25 transactionContext.RollbackTransaction()
25 }() 26 }()
  27 +
26 permissionRepository := factory.CreatePermissionRepository(map[string]interface{}{"transactionContext": transactionContext}) 28 permissionRepository := factory.CreatePermissionRepository(map[string]interface{}{"transactionContext": transactionContext})
27 // 获取权限配置 29 // 获取权限配置
28 _, permissions, err := permissionRepository.Find(map[string]interface{}{"companyId": in.CompanyId}) 30 _, permissions, err := permissionRepository.Find(map[string]interface{}{"companyId": in.CompanyId})
@@ -36,6 +38,45 @@ func (rs *PermissionService) Update(in *command.UpdatePermissionCommand) (interf @@ -36,6 +38,45 @@ func (rs *PermissionService) Update(in *command.UpdatePermissionCommand) (interf
36 permission.OptHrScore = in.OptHrScore 38 permission.OptHrScore = in.OptHrScore
37 permission.OptEvalScore = in.OptEvalScore 39 permission.OptEvalScore = in.OptEvalScore
38 40
  41 + // 超级管理员权限传参
  42 + if in.OptConfirmPerf > 0 || in.CycleDeadLine != nil {
  43 + superAdmin, err := service.GetSuperAdmin(transactionContext, int(in.CompanyId), int(in.UserId))
  44 + if err != nil {
  45 + return nil, err
  46 + }
  47 + if superAdmin != domain.RoleTypeSuperAdmin {
  48 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
  49 + }
  50 +
  51 + switch in.OptConfirmPerf {
  52 + case domain.PermissionOff, domain.PermissionOn:
  53 + default:
  54 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "是否需要员工确认绩效参数错误")
  55 + }
  56 + var cycleDeadLine = in.CycleDeadLine
  57 + var allMinuteSelf = cycleDeadLine.AssessmentSelf.Hour*60 + cycleDeadLine.AssessmentSelf.Minute
  58 + var allMinute360 = cycleDeadLine.AssessmentAll.Hour*60 + cycleDeadLine.AssessmentAll.Minute
  59 + //var allMinuteHr = cycleDeadLine.AssessmentHr.Hour*60 + cycleDeadLine.AssessmentHr.Minute
  60 + var allMinuteSuperior = cycleDeadLine.AssessmentSuperior.Hour*60 + cycleDeadLine.AssessmentSuperior.Minute
  61 + var allMinuteMy = cycleDeadLine.ViewMyPerf.Hour*60 + cycleDeadLine.ViewMyPerf.Minute
  62 +
  63 + // 注. 360和人资评估时间截止是相同的(前端只传递一个360评估参数)
  64 + cycleDeadLine.AssessmentHr.Hour = cycleDeadLine.AssessmentAll.Hour
  65 + cycleDeadLine.AssessmentHr.Minute = cycleDeadLine.AssessmentAll.Minute
  66 +
  67 + if allMinuteSelf > allMinute360 {
  68 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "截止时间:[360评估]不能小于[综合自评]")
  69 + }
  70 + if allMinute360 > allMinuteSuperior {
  71 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "截止时间:[上级评估]不能小于[360评估]")
  72 + }
  73 + if allMinuteSuperior > allMinuteMy {
  74 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "截止时间:[查看我的绩效]不能小于[上级评估]")
  75 + }
  76 + permission.OptConfirmPerf = in.OptConfirmPerf
  77 + permission.CycleDeadline = in.CycleDeadLine
  78 + }
  79 +
39 permission, err = permissionRepository.Insert(permission) 80 permission, err = permissionRepository.Insert(permission)
40 if err != nil { 81 if err != nil {
41 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 82 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
@@ -69,7 +110,7 @@ func (rs *PermissionService) Get(in *command.GetPermissionCommand) (*domain.Perm @@ -69,7 +110,7 @@ func (rs *PermissionService) Get(in *command.GetPermissionCommand) (*domain.Perm
69 OptHrScore: domain.PermissionOff, 110 OptHrScore: domain.PermissionOff,
70 OptEvalScore: domain.PermissionOff, 111 OptEvalScore: domain.PermissionOff,
71 OptConfirmPerf: domain.PermissionOff, 112 OptConfirmPerf: domain.PermissionOff,
72 - CycleDeadLine: rs.defaultCycleDeadline(), 113 + CycleDeadline: rs.defaultCycleDeadline(),
73 } 114 }
74 permission, err = permissionRepository.Insert(value) 115 permission, err = permissionRepository.Insert(value)
75 if err != nil { 116 if err != nil {
@@ -91,9 +132,9 @@ func (rs *PermissionService) Get(in *command.GetPermissionCommand) (*domain.Perm @@ -91,9 +132,9 @@ func (rs *PermissionService) Get(in *command.GetPermissionCommand) (*domain.Perm
91 isChange = true 132 isChange = true
92 permission.OptConfirmPerf = domain.PermissionOff 133 permission.OptConfirmPerf = domain.PermissionOff
93 } 134 }
94 - if permission.CycleDeadLine == nil { 135 + if permission.CycleDeadline == nil {
95 isChange = true 136 isChange = true
96 - permission.CycleDeadLine = rs.defaultCycleDeadline() 137 + permission.CycleDeadline = rs.defaultCycleDeadline()
97 } 138 }
98 if isChange { 139 if isChange {
99 permission, err = permissionRepository.Insert(permission) 140 permission, err = permissionRepository.Insert(permission)
@@ -180,26 +180,26 @@ func (se *summaryEvaluationPublisher) sendSummaryEvaluationV2( @@ -180,26 +180,26 @@ func (se *summaryEvaluationPublisher) sendSummaryEvaluationV2(
180 beginTimeSelf := *cycleData.TimeEnd // 180 beginTimeSelf := *cycleData.TimeEnd //
181 beginDay := dayEndTime(beginTimeSelf) 181 beginDay := dayEndTime(beginTimeSelf)
182 //修改 周期结束时间那天的第二天开始计算 182 //修改 周期结束时间那天的第二天开始计算
183 - endTimeSelf := beginDay.Add(time.Duration(permissioData.CycleDeadLine.AssessmentSelf.Hour) * time.Hour).  
184 - Add(time.Duration(permissioData.CycleDeadLine.AssessmentSelf.Minute) * time.Minute) 183 + endTimeSelf := beginDay.Add(time.Duration(permissioData.CycleDeadline.AssessmentSelf.Hour) * time.Hour).
  184 + Add(time.Duration(permissioData.CycleDeadline.AssessmentSelf.Minute) * time.Minute)
185 //人资、360评估的时间范围 185 //人资、360评估的时间范围
186 beginTime360 := endTimeSelf 186 beginTime360 := endTimeSelf
187 - endTime360 := beginDay.Add(time.Duration(permissioData.CycleDeadLine.AssessmentAll.Hour) * time.Hour).  
188 - Add(time.Duration(permissioData.CycleDeadLine.AssessmentAll.Minute) * time.Minute) 187 + endTime360 := beginDay.Add(time.Duration(permissioData.CycleDeadline.AssessmentAll.Hour) * time.Hour).
  188 + Add(time.Duration(permissioData.CycleDeadline.AssessmentAll.Minute) * time.Minute)
189 //人资评估的时间范围 189 //人资评估的时间范围
190 beginTimeHr := endTimeSelf 190 beginTimeHr := endTimeSelf
191 - endTimeHr := beginDay.Add(time.Duration(permissioData.CycleDeadLine.AssessmentHr.Hour) * time.Hour).  
192 - Add(time.Duration(permissioData.CycleDeadLine.AssessmentHr.Minute) * time.Minute) 191 + endTimeHr := beginDay.Add(time.Duration(permissioData.CycleDeadline.AssessmentHr.Hour) * time.Hour).
  192 + Add(time.Duration(permissioData.CycleDeadline.AssessmentHr.Minute) * time.Minute)
193 193
194 //上级评估的是时间范围 194 //上级评估的是时间范围
195 beginTimeSuper := endTimeHr 195 beginTimeSuper := endTimeHr
196 - endTimeSuper := beginDay.Add(time.Duration(permissioData.CycleDeadLine.AssessmentSuperior.Hour) * time.Hour).  
197 - Add(time.Duration(permissioData.CycleDeadLine.AssessmentSuperior.Minute) * time.Minute) 196 + endTimeSuper := beginDay.Add(time.Duration(permissioData.CycleDeadline.AssessmentSuperior.Hour) * time.Hour).
  197 + Add(time.Duration(permissioData.CycleDeadline.AssessmentSuperior.Minute) * time.Minute)
198 198
199 //考核结果的时间范围 199 //考核结果的时间范围
200 beginTimeFinish := endTimeSuper 200 beginTimeFinish := endTimeSuper
201 - endTimeFinish := beginDay.Add(time.Duration(permissioData.CycleDeadLine.ViewMyPerf.Hour) * time.Hour).  
202 - Add(time.Duration(permissioData.CycleDeadLine.ViewMyPerf.Minute) * time.Minute) 201 + endTimeFinish := beginDay.Add(time.Duration(permissioData.CycleDeadline.ViewMyPerf.Hour) * time.Hour).
  202 + Add(time.Duration(permissioData.CycleDeadline.ViewMyPerf.Minute) * time.Minute)
203 // 创建周期评估任务 203 // 创建周期评估任务
204 var newEvaluationList []domain.SummaryEvaluation 204 var newEvaluationList []domain.SummaryEvaluation
205 evaluationTemp := domain.SummaryEvaluation{ 205 evaluationTemp := domain.SummaryEvaluation{
@@ -12,8 +12,8 @@ type Permission struct { @@ -12,8 +12,8 @@ type Permission struct {
12 CompanyId int64 `json:"companyId" comment:"公司ID" ` 12 CompanyId int64 `json:"companyId" comment:"公司ID" `
13 OptHrScore int `json:"optHrScore" comment:"上级是否可以修改人资综评分数"` 13 OptHrScore int `json:"optHrScore" comment:"上级是否可以修改人资综评分数"`
14 OptEvalScore int `json:"optEvalScore" comment:"上级是否可以修改360°综评分数"` 14 OptEvalScore int `json:"optEvalScore" comment:"上级是否可以修改360°综评分数"`
15 - OptConfirmPerf int `json:"optConfirmPerf " comment:"是否需要员工确认绩效"`  
16 - CycleDeadLine *CycleDeadline `json:"cycleDeadline" comment:"周期评估各业务截止时间"` 15 + OptConfirmPerf int `json:"optConfirmPerf" comment:"是否需要员工确认绩效"`
  16 + CycleDeadline *CycleDeadline `json:"cycleDeadline" comment:"周期评估各业务截止时间"`
17 CreatedAt time.Time `json:"createdAt" comment:"创建时间"` 17 CreatedAt time.Time `json:"createdAt" comment:"创建时间"`
18 UpdatedAt time.Time `json:"updatedAt" comment:"更新时间"` 18 UpdatedAt time.Time `json:"updatedAt" comment:"更新时间"`
19 DeletedAt *time.Time `json:"deletedAt" comment:"删除时间"` 19 DeletedAt *time.Time `json:"deletedAt" comment:"删除时间"`
@@ -3,7 +3,7 @@ package domain @@ -3,7 +3,7 @@ package domain
3 import "time" 3 import "time"
4 4
5 const ( 5 const (
6 - RoleTypeCommon int = 0 // 角色类型-添加角色 6 + RoleTypeCommon int = 0 // 角色类型-普通角色
7 RoleTypeSystem int = 1 // 角色类型-系统预制角色HR-BP(不可删除、编辑) 7 RoleTypeSystem int = 1 // 角色类型-系统预制角色HR-BP(不可删除、编辑)
8 RoleTypeSuperAdmin int = 2 // 角色类型-系统预制超级管理员(不可删除、编辑) 8 RoleTypeSuperAdmin int = 2 // 角色类型-系统预制超级管理员(不可删除、编辑)
9 ) 9 )
@@ -12,7 +12,7 @@ type Permission struct { @@ -12,7 +12,7 @@ type Permission struct {
12 OptHrScore int `comment:"上级是否可以修改人资综评分数"` 12 OptHrScore int `comment:"上级是否可以修改人资综评分数"`
13 OptEvalScore int `comment:"上级是否可以修改360°综评分数"` 13 OptEvalScore int `comment:"上级是否可以修改360°综评分数"`
14 OptConfirmPerf int `comment:"是否需要员工确认绩效"` 14 OptConfirmPerf int `comment:"是否需要员工确认绩效"`
15 - CycleDeadLine *domain.CycleDeadline `comment:"周期评估各业务截止时间"` 15 + CycleDeadline *domain.CycleDeadline `comment:"周期评估各业务截止时间"`
16 CreatedAt time.Time `comment:"创建时间"` 16 CreatedAt time.Time `comment:"创建时间"`
17 UpdatedAt time.Time `comment:"更新时间"` 17 UpdatedAt time.Time `comment:"更新时间"`
18 DeletedAt *time.Time `comment:"删除时间"` 18 DeletedAt *time.Time `comment:"删除时间"`
@@ -27,7 +27,7 @@ func (repo *PermissionRepository) TransformToDomain(m *models.Permission) domain @@ -27,7 +27,7 @@ func (repo *PermissionRepository) TransformToDomain(m *models.Permission) domain
27 OptHrScore: m.OptHrScore, 27 OptHrScore: m.OptHrScore,
28 OptEvalScore: m.OptEvalScore, 28 OptEvalScore: m.OptEvalScore,
29 OptConfirmPerf: m.OptConfirmPerf, 29 OptConfirmPerf: m.OptConfirmPerf,
30 - CycleDeadLine: m.CycleDeadLine, 30 + CycleDeadline: m.CycleDeadline,
31 CreatedAt: m.CreatedAt.Local(), 31 CreatedAt: m.CreatedAt.Local(),
32 UpdatedAt: m.UpdatedAt.Local(), 32 UpdatedAt: m.UpdatedAt.Local(),
33 DeletedAt: m.DeletedAt, 33 DeletedAt: m.DeletedAt,
@@ -41,7 +41,7 @@ func (repo *PermissionRepository) TransformToModel(d *domain.Permission) models. @@ -41,7 +41,7 @@ func (repo *PermissionRepository) TransformToModel(d *domain.Permission) models.
41 OptHrScore: d.OptHrScore, 41 OptHrScore: d.OptHrScore,
42 OptEvalScore: d.OptEvalScore, 42 OptEvalScore: d.OptEvalScore,
43 OptConfirmPerf: d.OptConfirmPerf, 43 OptConfirmPerf: d.OptConfirmPerf,
44 - CycleDeadLine: d.CycleDeadLine, 44 + CycleDeadline: d.CycleDeadline,
45 CreatedAt: d.CreatedAt, 45 CreatedAt: d.CreatedAt,
46 UpdatedAt: d.UpdatedAt, 46 UpdatedAt: d.UpdatedAt,
47 DeletedAt: d.DeletedAt, 47 DeletedAt: d.DeletedAt,
@@ -20,6 +20,7 @@ func (controller *PermissionController) UpdatePermission() { @@ -20,6 +20,7 @@ func (controller *PermissionController) UpdatePermission() {
20 } else { 20 } else {
21 ua := middlewares.GetUser(controller.Ctx) 21 ua := middlewares.GetUser(controller.Ctx)
22 in.CompanyId = ua.CompanyId 22 in.CompanyId = ua.CompanyId
  23 + in.UserId = ua.UserId
23 controller.Response(ruService.Update(in)) 24 controller.Response(ruService.Update(in))
24 } 25 }
25 } 26 }