作者 tangxvhui
... ... @@ -7,6 +7,7 @@ import (
type UpdatePermissionCommand struct {
CompanyId int64 `cname:"公司Id"`
UserId int64 `cname:"用户ID"`
OptHrScore int `cname:"上级修改人资综评分数" json:"optHrScore" valid:"Required"`
OptEvalScore int `cname:"上级修改360°综评分数" json:"optEvalScore" valid:"Required"`
OptConfirmPerf int `cname:"是否需要员工确认绩效" json:"optConfirmPerf"`
... ...
... ... @@ -4,6 +4,7 @@ import (
"github.com/linmadan/egglib-go/core/application"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/permission/command"
service "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/role"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
)
... ... @@ -23,6 +24,7 @@ func (rs *PermissionService) Update(in *command.UpdatePermissionCommand) (interf
defer func() {
transactionContext.RollbackTransaction()
}()
permissionRepository := factory.CreatePermissionRepository(map[string]interface{}{"transactionContext": transactionContext})
// 获取权限配置
_, permissions, err := permissionRepository.Find(map[string]interface{}{"companyId": in.CompanyId})
... ... @@ -36,6 +38,45 @@ func (rs *PermissionService) Update(in *command.UpdatePermissionCommand) (interf
permission.OptHrScore = in.OptHrScore
permission.OptEvalScore = in.OptEvalScore
// 超级管理员权限传参
if in.OptConfirmPerf > 0 || in.CycleDeadLine != nil {
superAdmin, err := service.GetSuperAdmin(transactionContext, int(in.CompanyId), int(in.UserId))
if err != nil {
return nil, err
}
if superAdmin != domain.RoleTypeSuperAdmin {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
}
switch in.OptConfirmPerf {
case domain.PermissionOff, domain.PermissionOn:
default:
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "是否需要员工确认绩效参数错误")
}
var cycleDeadLine = in.CycleDeadLine
var allMinuteSelf = cycleDeadLine.AssessmentSelf.Hour*60 + cycleDeadLine.AssessmentSelf.Minute
var allMinute360 = cycleDeadLine.AssessmentAll.Hour*60 + cycleDeadLine.AssessmentAll.Minute
//var allMinuteHr = cycleDeadLine.AssessmentHr.Hour*60 + cycleDeadLine.AssessmentHr.Minute
var allMinuteSuperior = cycleDeadLine.AssessmentSuperior.Hour*60 + cycleDeadLine.AssessmentSuperior.Minute
var allMinuteMy = cycleDeadLine.ViewMyPerf.Hour*60 + cycleDeadLine.ViewMyPerf.Minute
// 注. 360和人资评估时间截止是相同的(前端只传递一个360评估参数)
cycleDeadLine.AssessmentHr.Hour = cycleDeadLine.AssessmentAll.Hour
cycleDeadLine.AssessmentHr.Minute = cycleDeadLine.AssessmentAll.Minute
if allMinuteSelf > allMinute360 {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "截止时间:[360评估]不能小于[综合自评]")
}
if allMinute360 > allMinuteSuperior {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "截止时间:[上级评估]不能小于[360评估]")
}
if allMinuteSuperior > allMinuteMy {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "截止时间:[查看我的绩效]不能小于[上级评估]")
}
permission.OptConfirmPerf = in.OptConfirmPerf
permission.CycleDeadline = in.CycleDeadLine
}
permission, err = permissionRepository.Insert(permission)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ... @@ -69,7 +110,7 @@ func (rs *PermissionService) Get(in *command.GetPermissionCommand) (*domain.Perm
OptHrScore: domain.PermissionOff,
OptEvalScore: domain.PermissionOff,
OptConfirmPerf: domain.PermissionOff,
CycleDeadLine: rs.defaultCycleDeadline(),
CycleDeadline: rs.defaultCycleDeadline(),
}
permission, err = permissionRepository.Insert(value)
if err != nil {
... ... @@ -91,9 +132,9 @@ func (rs *PermissionService) Get(in *command.GetPermissionCommand) (*domain.Perm
isChange = true
permission.OptConfirmPerf = domain.PermissionOff
}
if permission.CycleDeadLine == nil {
if permission.CycleDeadline == nil {
isChange = true
permission.CycleDeadLine = rs.defaultCycleDeadline()
permission.CycleDeadline = rs.defaultCycleDeadline()
}
if isChange {
permission, err = permissionRepository.Insert(permission)
... ...
... ... @@ -180,26 +180,26 @@ func (se *summaryEvaluationPublisher) sendSummaryEvaluationV2(
beginTimeSelf := *cycleData.TimeEnd //
beginDay := dayEndTime(beginTimeSelf)
//修改 周期结束时间那天的第二天开始计算
endTimeSelf := beginDay.Add(time.Duration(permissioData.CycleDeadLine.AssessmentSelf.Hour) * time.Hour).
Add(time.Duration(permissioData.CycleDeadLine.AssessmentSelf.Minute) * time.Minute)
endTimeSelf := beginDay.Add(time.Duration(permissioData.CycleDeadline.AssessmentSelf.Hour) * time.Hour).
Add(time.Duration(permissioData.CycleDeadline.AssessmentSelf.Minute) * time.Minute)
//人资、360评估的时间范围
beginTime360 := endTimeSelf
endTime360 := beginDay.Add(time.Duration(permissioData.CycleDeadLine.AssessmentAll.Hour) * time.Hour).
Add(time.Duration(permissioData.CycleDeadLine.AssessmentAll.Minute) * time.Minute)
endTime360 := beginDay.Add(time.Duration(permissioData.CycleDeadline.AssessmentAll.Hour) * time.Hour).
Add(time.Duration(permissioData.CycleDeadline.AssessmentAll.Minute) * time.Minute)
//人资评估的时间范围
beginTimeHr := endTimeSelf
endTimeHr := beginDay.Add(time.Duration(permissioData.CycleDeadLine.AssessmentHr.Hour) * time.Hour).
Add(time.Duration(permissioData.CycleDeadLine.AssessmentHr.Minute) * time.Minute)
endTimeHr := beginDay.Add(time.Duration(permissioData.CycleDeadline.AssessmentHr.Hour) * time.Hour).
Add(time.Duration(permissioData.CycleDeadline.AssessmentHr.Minute) * time.Minute)
//上级评估的是时间范围
beginTimeSuper := endTimeHr
endTimeSuper := beginDay.Add(time.Duration(permissioData.CycleDeadLine.AssessmentSuperior.Hour) * time.Hour).
Add(time.Duration(permissioData.CycleDeadLine.AssessmentSuperior.Minute) * time.Minute)
endTimeSuper := beginDay.Add(time.Duration(permissioData.CycleDeadline.AssessmentSuperior.Hour) * time.Hour).
Add(time.Duration(permissioData.CycleDeadline.AssessmentSuperior.Minute) * time.Minute)
//考核结果的时间范围
beginTimeFinish := endTimeSuper
endTimeFinish := beginDay.Add(time.Duration(permissioData.CycleDeadLine.ViewMyPerf.Hour) * time.Hour).
Add(time.Duration(permissioData.CycleDeadLine.ViewMyPerf.Minute) * time.Minute)
endTimeFinish := beginDay.Add(time.Duration(permissioData.CycleDeadline.ViewMyPerf.Hour) * time.Hour).
Add(time.Duration(permissioData.CycleDeadline.ViewMyPerf.Minute) * time.Minute)
// 创建周期评估任务
var newEvaluationList []domain.SummaryEvaluation
evaluationTemp := domain.SummaryEvaluation{
... ...
... ... @@ -12,8 +12,8 @@ type Permission struct {
CompanyId int64 `json:"companyId" comment:"公司ID" `
OptHrScore int `json:"optHrScore" comment:"上级是否可以修改人资综评分数"`
OptEvalScore int `json:"optEvalScore" comment:"上级是否可以修改360°综评分数"`
OptConfirmPerf int `json:"optConfirmPerf " comment:"是否需要员工确认绩效"`
CycleDeadLine *CycleDeadline `json:"cycleDeadline" comment:"周期评估各业务截止时间"`
OptConfirmPerf int `json:"optConfirmPerf" comment:"是否需要员工确认绩效"`
CycleDeadline *CycleDeadline `json:"cycleDeadline" comment:"周期评估各业务截止时间"`
CreatedAt time.Time `json:"createdAt" comment:"创建时间"`
UpdatedAt time.Time `json:"updatedAt" comment:"更新时间"`
DeletedAt *time.Time `json:"deletedAt" comment:"删除时间"`
... ...
... ... @@ -3,7 +3,7 @@ package domain
import "time"
const (
RoleTypeCommon int = 0 // 角色类型-添加角色
RoleTypeCommon int = 0 // 角色类型-普通角色
RoleTypeSystem int = 1 // 角色类型-系统预制角色HR-BP(不可删除、编辑)
RoleTypeSuperAdmin int = 2 // 角色类型-系统预制超级管理员(不可删除、编辑)
)
... ...
... ... @@ -12,7 +12,7 @@ type Permission struct {
OptHrScore int `comment:"上级是否可以修改人资综评分数"`
OptEvalScore int `comment:"上级是否可以修改360°综评分数"`
OptConfirmPerf int `comment:"是否需要员工确认绩效"`
CycleDeadLine *domain.CycleDeadline `comment:"周期评估各业务截止时间"`
CycleDeadline *domain.CycleDeadline `comment:"周期评估各业务截止时间"`
CreatedAt time.Time `comment:"创建时间"`
UpdatedAt time.Time `comment:"更新时间"`
DeletedAt *time.Time `comment:"删除时间"`
... ...
... ... @@ -27,7 +27,7 @@ func (repo *PermissionRepository) TransformToDomain(m *models.Permission) domain
OptHrScore: m.OptHrScore,
OptEvalScore: m.OptEvalScore,
OptConfirmPerf: m.OptConfirmPerf,
CycleDeadLine: m.CycleDeadLine,
CycleDeadline: m.CycleDeadline,
CreatedAt: m.CreatedAt.Local(),
UpdatedAt: m.UpdatedAt.Local(),
DeletedAt: m.DeletedAt,
... ... @@ -41,7 +41,7 @@ func (repo *PermissionRepository) TransformToModel(d *domain.Permission) models.
OptHrScore: d.OptHrScore,
OptEvalScore: d.OptEvalScore,
OptConfirmPerf: d.OptConfirmPerf,
CycleDeadLine: d.CycleDeadLine,
CycleDeadline: d.CycleDeadline,
CreatedAt: d.CreatedAt,
UpdatedAt: d.UpdatedAt,
DeletedAt: d.DeletedAt,
... ...
... ... @@ -20,6 +20,7 @@ func (controller *PermissionController) UpdatePermission() {
} else {
ua := middlewares.GetUser(controller.Ctx)
in.CompanyId = ua.CompanyId
in.UserId = ua.UserId
controller.Response(ruService.Update(in))
}
}
... ...