作者 郑周

Merge branch 'test' into dev-zhengzhou

... ... @@ -17,6 +17,7 @@ import (
func main() {
startNodeTask()
startSummaryEvaluation()
startConfirmEvaluationScore()
go notify.RunTaskSmsNotify()
go consumer.Run()
web.Run()
... ... @@ -63,3 +64,23 @@ func startSummaryEvaluation() {
}
}()
}
// 定时自动确认周期评估考核结果
func startConfirmEvaluationScore() {
go func() {
var duration time.Duration
if constant.Env == "prd" {
duration = time.Minute * 5
} else {
duration = time.Minute * 1
}
timer := time.NewTimer(duration)
for {
<-timer.C
if err := serviceSummary.TaskConfirmScore(); err != nil {
log.Logger.Error(err.Error())
}
timer.Reset(duration) // 重置定时
}
}()
}
... ...
package adapter
type MeInfo struct {
UserId int64 `json:"userId"` //用户名称
CompanyLogo string `json:"companyLogo"` //图标
CompanyId int64 `json:"companyId"` //公司id
CompanyName string `json:"companyName"` //公司名称
Phone string `json:"phone"` // 手机号
Name string `json:"name"` // 员工名称
IsHrbp bool `json:"isHrbp"` //是否 是hrbp
IsParent bool `json:"isParent"` //是否 是上级
UserId int64 `json:"userId"` //用户名称
CompanyLogo string `json:"companyLogo"` //图标
CompanyId int64 `json:"companyId"` //公司id
CompanyName string `json:"companyName"` //公司名称
Phone string `json:"phone"` // 手机号
Name string `json:"name"` // 员工名称
IsHrbp bool `json:"isHrbp"` //是否 是hrbp
IsParent bool `json:"isParent"` //是否 是上级
IsSuperAdmin bool `json:"isSuperAdmin"` //是否 是超级角色
}
... ...
... ... @@ -5,6 +5,7 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/auth/adapter"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/auth/command"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
roleService "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/role"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/constant"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
)
... ... @@ -173,8 +174,6 @@ func (service *AuthService) MeInfo(param *command.GetMeInfo) (map[string]interfa
}()
userRepository := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext})
companyRepository := factory.CreateCompanyRepository(map[string]interface{}{"transactionContext": transactionContext})
roleRepo := factory.CreateRoleRepository(map[string]interface{}{"transactionContext": transactionContext})
roleUserRepo := factory.CreateRoleUserRepository(map[string]interface{}{"transactionContext": transactionContext})
userData, err := userRepository.FindOne(map[string]interface{}{
"id": param.UserId,
})
... ... @@ -194,37 +193,34 @@ func (service *AuthService) MeInfo(param *command.GetMeInfo) (map[string]interfa
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取公司数据"+err.Error())
}
_, roleList, err := roleRepo.Find(map[string]interface{}{"type": domain.RoleTypeSystem, "companyId": param.CompanyId})
hrbpFlag, err := roleService.GetHrBp(transactionContext, int(param.CompanyId), int(param.UserId))
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取角色信息列表"+err.Error())
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取用户的角色信息"+err.Error())
}
_, userRoleList, err := roleUserRepo.Find(map[string]interface{}{"companyId": param.CompanyId, "userId": param.UserId})
superAdminFlag, err := roleService.GetSuperAdmin(transactionContext, int(param.CompanyId), int(param.UserId))
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取用户的角色信息列表"+err.Error())
}
// 拥有HRBP权限
isHrbp := false
loop:
for _, v := range userRoleList {
for _, v2 := range roleList {
if v.RoleId == v2.Id {
isHrbp = true
break loop
}
}
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取用户的角色信息"+err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
info := adapter.MeInfo{
UserId: userData.Id,
CompanyId: companyData.Id,
CompanyName: companyData.Name,
CompanyLogo: companyData.Logo,
Phone: userData.Account,
Name: userData.Name,
IsHrbp: isHrbp,
IsParent: false,
UserId: userData.Id,
CompanyId: companyData.Id,
CompanyName: companyData.Name,
CompanyLogo: companyData.Logo,
Phone: userData.Account,
Name: userData.Name,
IsHrbp: false,
IsParent: false,
IsSuperAdmin: false,
}
if hrbpFlag == domain.RoleTypeSystem {
info.IsHrbp = true
}
if superAdminFlag == domain.RoleTypeSuperAdmin {
info.IsSuperAdmin = true
}
if len(parentUser) > 0 {
info.IsParent = true
... ...
... ... @@ -37,7 +37,12 @@ func (notices *notifySms) regist(ifsend notifySendOrNot) {
}
func (notices *notifySms) addTask(task *domain.LogSms) {
notices.newSms <- task
// notices.newSms <- task
err := notices.addNewSms(task)
if err != nil {
e := fmt.Sprintf("添加短信通知任务:%+v %s", task, err)
log.Logger.Error(e)
}
}
// RunTask 执行短信通知任务
... ...
... ... @@ -6,9 +6,12 @@ import (
)
type UpdatePermissionCommand struct {
CompanyId int64 `cname:"公司Id"`
OptHrScore int `cname:"上级修改人资综评分数" json:"optHrScore" valid:"Required"`
OptEvalScore int `cname:"上级修改360°综评分数" json:"optEvalScore" valid:"Required"`
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"`
CycleDeadLine *domain.CycleDeadline `cname:"周期评估各业务截止时间" json:"cycleDeadline"`
}
func (in *UpdatePermissionCommand) Valid(validation *validation.Validation) {
... ...
... ... @@ -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())
... ... @@ -46,7 +87,7 @@ func (rs *PermissionService) Update(in *command.UpdatePermissionCommand) (interf
return permission, nil
}
func (rs *PermissionService) Get(in *command.GetPermissionCommand) (interface{}, error) {
func (rs *PermissionService) Get(in *command.GetPermissionCommand) (*domain.Permission, error) {
transactionContext, err := factory.ValidateStartTransaction(in)
if err != nil {
return nil, err
... ... @@ -64,10 +105,12 @@ func (rs *PermissionService) Get(in *command.GetPermissionCommand) (interface{},
var permission *domain.Permission
if len(permissions) == 0 { // 不存在时,新增权限配置
value := &domain.Permission{
Id: 0,
CompanyId: in.CompanyId,
OptHrScore: domain.PermissionOff,
OptEvalScore: domain.PermissionOff,
Id: 0,
CompanyId: in.CompanyId,
OptHrScore: domain.PermissionOff,
OptEvalScore: domain.PermissionOff,
OptConfirmPerf: domain.PermissionOff,
CycleDeadline: rs.defaultCycleDeadline(),
}
permission, err = permissionRepository.Insert(value)
if err != nil {
... ... @@ -75,9 +118,59 @@ func (rs *PermissionService) Get(in *command.GetPermissionCommand) (interface{},
}
} else {
permission = permissions[0]
// 纠正数据
var isChange = false
if permission.OptHrScore == 0 {
isChange = true
permission.OptHrScore = domain.PermissionOff
}
if permission.OptEvalScore == 0 {
isChange = true
permission.OptEvalScore = domain.PermissionOff
}
if permission.OptConfirmPerf == 0 {
isChange = true
permission.OptConfirmPerf = domain.PermissionOff
}
if permission.CycleDeadline == nil {
isChange = true
permission.CycleDeadline = rs.defaultCycleDeadline()
}
if isChange {
permission, err = permissionRepository.Insert(permission)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
}
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return permission, nil
}
// 创建默认周期截止时间
func (rs *PermissionService) defaultCycleDeadline() *domain.CycleDeadline {
return &domain.CycleDeadline{
AssessmentSelf: domain.DeadlineTime{
Hour: 3 * 24,
Minute: 0,
},
AssessmentAll: domain.DeadlineTime{
Hour: 5 * 24,
Minute: 0,
},
AssessmentHr: domain.DeadlineTime{
Hour: 5 * 24,
Minute: 0,
},
AssessmentSuperior: domain.DeadlineTime{
Hour: 7 * 24,
Minute: 0,
},
ViewMyPerf: domain.DeadlineTime{
Hour: 9 * 24,
Minute: 0,
},
}
}
... ...
... ... @@ -113,6 +113,9 @@ func (rs *RoleService) Remove(in *command.DeleteRoleCommand) (interface{}, error
if role.Type == domain.RoleTypeSystem {
return nil, application.ThrowError(application.BUSINESS_ERROR, "系统预制角色不可删除")
}
if role.Type == domain.RoleTypeSuperAdmin {
return nil, application.ThrowError(application.BUSINESS_ERROR, "超级管理员角色不可删除")
}
if _, err := roleRepository.Remove(role); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ... @@ -160,7 +163,7 @@ func (rs *RoleService) ListForUser(in *command.QueryRoleUserCommand) (interface{
adapterList := make([]*adapter.RoleUserAdapter, 0)
// 如果不存在系统预支hrbp角色时,插入一条数据
// 如果不存在系统预支hr-bp角色时,新增数据
var havaSystemType = false
for i := range roles {
if roles[i].Type == domain.RoleTypeSystem {
... ... @@ -190,6 +193,10 @@ func (rs *RoleService) ListForUser(in *command.QueryRoleUserCommand) (interface{
for i := range roles {
v := roles[i]
if v.Type == domain.RoleTypeSuperAdmin { // 超级管理员角色不显示到界面上
continue
}
_, tempList, err := ruRepository.FindAllContainUser(1, 10, in.CompanyId, v.Id)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ...
... ... @@ -115,32 +115,68 @@ func (rs *RoleUserService) ListRole(in *command.UserRoleQueryCommand) (interface
return tool_funs.SimpleWrapGridMap(total, tempList), nil
}
// GetHRBP 当前操作人是否拥有HRBP权限
// 返回 1 是 表示具有hrbp 权限
func GetHRBP(transactionContext application.TransactionContext, companyId int, operatorId int) (int, error) {
roleRepo := factory.CreateRoleRepository(map[string]interface{}{"transactionContext": transactionContext})
roleUserRepo := factory.CreateRoleUserRepository(map[string]interface{}{"transactionContext": transactionContext})
_, roleList, err := roleRepo.Find(map[string]interface{}{"type": domain.RoleTypeSystem, "companyId": companyId})
// GetHrBp 当前操作人是否拥有HR-BP权限 (1表示有权限)
func GetHrBp(transactionContext application.TransactionContext, companyId int, operatorId int) (int, error) {
roleRepository := factory.CreateRoleRepository(map[string]interface{}{"transactionContext": transactionContext})
roleUserRepository := factory.CreateRoleUserRepository(map[string]interface{}{"transactionContext": transactionContext})
_, roles, err := roleRepository.Find(map[string]interface{}{"type": domain.RoleTypeSystem, "companyId": companyId})
if err != nil {
return -1, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取角色信息列表"+err.Error())
}
_, userRoleList, err := roleUserRepo.Find(map[string]interface{}{"companyId": companyId, "userId": operatorId})
if len(roles) == 0 {
return -1, nil
}
_, userRoles, err := roleUserRepository.Find(map[string]interface{}{"companyId": companyId, "userId": operatorId})
if err != nil {
return -1, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取用户的角色信息列表"+err.Error())
}
// 拥有HRBP权限
hrbp := -1
for _, v := range userRoleList {
for _, v2 := range roleList {
if v.RoleId == v2.Id {
hrbp = 1
break
if len(userRoles) == 0 {
return -1, nil
}
hrBp := -1
loopFinish:
for _, userRole := range userRoles {
for _, role := range roles {
if userRole.RoleId == role.Id {
hrBp = domain.RoleTypeSystem
break loopFinish
}
}
if hrbp == 1 {
break
}
return hrBp, nil
}
// GetSuperAdmin 当前操作人是否拥有超级管理员权限 (2表示有权限)
func GetSuperAdmin(transactionContext application.TransactionContext, companyId int, operatorId int) (int, error) {
roleRepository := factory.CreateRoleRepository(map[string]interface{}{"transactionContext": transactionContext})
roleUserRepository := factory.CreateRoleUserRepository(map[string]interface{}{"transactionContext": transactionContext})
_, roles, err := roleRepository.Find(map[string]interface{}{"type": domain.RoleTypeSuperAdmin, "companyId": companyId})
if err != nil {
return -1, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取角色信息列表"+err.Error())
}
if len(roles) == 0 {
return -1, nil
}
_, userRoles, err := roleUserRepository.Find(map[string]interface{}{"companyId": companyId, "userId": operatorId})
if err != nil {
return -1, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取用户的角色信息列表"+err.Error())
}
if len(userRoles) == 0 {
return -1, nil
}
superAdmin := -1
loopFinish:
for _, userRole := range userRoles {
for _, role := range roles {
if userRole.RoleId == role.Id {
superAdmin = domain.RoleTypeSuperAdmin
break loopFinish
}
}
}
return hrbp, nil
return superAdmin, nil
}
... ...
... ... @@ -6,6 +6,8 @@ import (
"strconv"
"time"
service "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/role"
"github.com/linmadan/egglib-go/core/application"
"github.com/linmadan/egglib-go/utils/tool_funs"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
... ... @@ -29,28 +31,9 @@ func NewStaffAssessServeice() *StaffAssessServeice {
// 获取HRBP标记值
func (srv StaffAssessServeice) getHRBP(transactionContext application.TransactionContext, companyId int, operatorId int) (int, error) {
roleRepo := factory.CreateRoleRepository(map[string]interface{}{"transactionContext": transactionContext})
roleUserRepo := factory.CreateRoleUserRepository(map[string]interface{}{"transactionContext": transactionContext})
_, roleList, err := roleRepo.Find(map[string]interface{}{"type": domain.RoleTypeSystem, "companyId": companyId})
if err != nil {
return -1, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取角色信息列表"+err.Error())
}
_, userRoleList, err := roleUserRepo.Find(map[string]interface{}{"companyId": companyId, "userId": operatorId})
hrbp, err := service.GetHrBp(transactionContext, companyId, operatorId)
if err != nil {
return -1, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取用户的角色信息列表"+err.Error())
}
// 拥有HRBP权限
hrbp := -1
for _, v := range userRoleList {
for _, v2 := range roleList {
if v.RoleId == v2.Id {
hrbp = 1
break
}
}
if hrbp == 1 {
break
}
return -1, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
return hrbp, nil
}
... ... @@ -391,7 +374,7 @@ func (srv StaffAssessServeice) createStaffAssessSelf(
assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
beginDay := assessTemp.BeginTime.Format("2006-01-02")
beginDay := assessTemp.BeginTime.Local().Format("2006-01-02")
_, assessListOld, err := assessRepo.Find(map[string]interface{}{"cycleId": assessTemp.CycleId, "beginDay": beginDay, "types": domain.AssessSelf})
if err != nil {
return nil, err
... ... @@ -437,7 +420,7 @@ func (srv StaffAssessServeice) createStaffAssessSupper(
assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
beginDay := assessTemp.BeginTime.Format("2006-01-02")
beginDay := assessTemp.BeginTime.Local().Format("2006-01-02")
_, assessListOld, err := assessRepo.Find(map[string]interface{}{"cycleId": assessTemp.CycleId, "beginDay": beginDay, "types": domain.AssessSuper})
if err != nil {
return nil, err
... ...
package command
// 员工确认 周期评估 分数
type ModifyFinishScore struct {
SummaryEvaluationId int `json:"summaryEvaluationId,string"`
Score float64 `json:"score"`
CompanyId int `json:"-"` //登录的公司
UserId int `json:"-"` //操作员id
}
... ...
... ... @@ -26,11 +26,11 @@ func (srv *SummaryEvaluationService) ExportAllEvaluationFinish(param *command.Qu
_ = transactionContext.RollbackTransaction()
}()
//判断是否是hrbp
flagHrbp, err := roleService.GetHRBP(transactionContext, param.CompanyId, param.UserId)
flagHrbp, err := roleService.GetHrBp(transactionContext, param.CompanyId, param.UserId)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if flagHrbp != 1 {
if flagHrbp != domain.RoleTypeSystem {
return nil, application.ThrowError(application.BUSINESS_ERROR, "暂无数据")
}
//判断是否是上级
... ... @@ -41,7 +41,7 @@ func (srv *SummaryEvaluationService) ExportAllEvaluationFinish(param *command.Qu
"parentId": param.UserId,
"limit": 1,
})
if len(parentUser) == 0 && flagHrbp != 1 {
if len(parentUser) == 0 && flagHrbp != domain.RoleTypeSystem {
return nil, application.ThrowError(application.BUSINESS_ERROR, "暂无数据")
}
evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{
... ...
package service
import (
"fmt"
"strconv"
"time"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/notify"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log"
)
// sendSummaryEvaluafionTask 根据评估项目设置,确认是否下发评估任务
// project 需要处理的项目
// userList 全体的员工数据 map[id]=>domain.User
// departmetList 全部的部门数据 map[id]=>domain.Department
func sendSummaryEvaluation(project *domain.EvaluationProject,
userMap map[int64]*domain.User, departmentMap map[int64]*domain.Department) ([]domain.SummaryEvaluation, error) {
//自评的时间范围
beginTimeSelf := project.EndTime
endTimeSelf := dayZeroTime(project.EndTime).Add(4*24*time.Hour - time.Second)
//人资、360评估的时间范围
beginTime360 := endTimeSelf
endTime360 := endTimeSelf.Add(2 * 24 * time.Hour)
//上级评估的是时间范围
beginTimeSuper := endTime360
endTimeSuper := endTime360.Add(2 * 24 * time.Hour)
//
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, err
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, err
}
defer func() {
_ = transactionContext.RollbackTransaction()
}()
cycleRepo := factory.CreateEvaluationCycleRepository(map[string]interface{}{"transactionContext": transactionContext})
evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext})
// func sendSummaryEvaluation(project *domain.EvaluationProject,
// userMap map[int64]*domain.User, departmentMap map[int64]*domain.Department) ([]domain.SummaryEvaluation, error) {
// //自评的时间范围
// beginTimeSelf := project.EndTime
// endTimeSelf := dayZeroTime(project.EndTime).Add(4*24*time.Hour - time.Second)
// //人资、360评估的时间范围
// beginTime360 := endTimeSelf
// endTime360 := endTimeSelf.Add(2 * 24 * time.Hour)
// //上级评估的是时间范围
// beginTimeSuper := endTime360
// endTimeSuper := endTime360.Add(2 * 24 * time.Hour)
// //
// transactionContext, err := factory.CreateTransactionContext(nil)
// if err != nil {
// return nil, err
// }
// if err := transactionContext.StartTransaction(); err != nil {
// return nil, err
// }
// defer func() {
// _ = transactionContext.RollbackTransaction()
// }()
// cycleRepo := factory.CreateEvaluationCycleRepository(map[string]interface{}{"transactionContext": transactionContext})
cycleData, err := cycleRepo.FindOne(map[string]interface{}{"id": project.CycleId})
if err != nil {
return nil, err
}
//确定 被评估的人
targetUserId := []int64{}
for _, v := range project.Recipients {
id, err := strconv.ParseInt(v, 10, 64)
if err == nil {
targetUserId = append(targetUserId, id)
}
}
if len(targetUserId) == 0 {
return nil, nil
}
//被评估的员工
targetUserMap := map[int64]*domain.User{}
// evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext})
for _, v := range targetUserId {
u, ok := userMap[v]
if ok {
targetUserMap[v] = u
}
}
//确定360评估的执行人
_, itemList, err := evaluationItemRepo.Find(map[string]interface{}{"evaluationProjectId": project.Id, "nodeType": int(domain.LinkNodeSelfAssessment)})
if err != nil {
return nil, err
}
nodeId := 0
executor360Map := map[int64]*domain.User{}
hrbpExist := false
for _, v := range itemList {
nodeId = v.NodeId
if v.EvaluatorId < 0 {
hrbpExist = true
}
if v.EvaluatorId <= 0 {
continue
}
if u, ok := userMap[int64(v.EvaluatorId)]; ok {
executor360Map[u.Id] = u
}
}
//创建周期评估任务
var newEvaluationList []domain.SummaryEvaluation
evaluationTemp := domain.SummaryEvaluation{
Id: 0,
CompanyId: int(project.CompanyId),
EvaluationProjectId: int(project.Id),
EvaluationProjectName: project.Name,
CycleId: cycleData.Id,
CycleName: cycleData.Name,
NodeId: nodeId,
TargetUser: domain.StaffDesc{},
TargetDepartment: []domain.StaffDepartment{},
Executor: domain.StaffDesc{},
Types: 0,
Status: domain.EvaluationUncompleted,
CheckResult: domain.EvaluationCheckUncompleted,
BeginTime: time.Time{},
EndTime: time.Time{},
TotalScore: "",
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
DeletedAt: nil,
}
// cycleData, err := cycleRepo.FindOne(map[string]interface{}{"id": project.CycleId})
// if err != nil {
// return nil, err
// }
// //确定 被评估的人
// targetUserId := []int64{}
// for _, v := range project.Recipients {
// id, err := strconv.ParseInt(v, 10, 64)
// if err == nil {
// targetUserId = append(targetUserId, id)
// }
// }
// if len(targetUserId) == 0 {
// return nil, nil
// }
// //被评估的员工
// targetUserMap := map[int64]*domain.User{}
//确定周期评估
// for _, v := range targetUserId {
// u, ok := userMap[v]
// if ok {
// targetUserMap[v] = u
// }
// }
// //确定360评估的执行人
// _, itemList, err := evaluationItemRepo.Find(map[string]interface{}{"evaluationProjectId": project.Id, "nodeType": int(domain.LinkNodeSelfAssessment)})
// if err != nil {
// return nil, err
// }
// nodeId := 0
// executor360Map := map[int64]*domain.User{}
// hrbpExist := false
// for _, v := range itemList {
// nodeId = v.NodeId
// if v.EvaluatorId < 0 {
// hrbpExist = true
// }
// if v.EvaluatorId <= 0 {
// continue
// }
// if u, ok := userMap[int64(v.EvaluatorId)]; ok {
// executor360Map[u.Id] = u
// }
// }
// //创建周期评估任务
// var newEvaluationList []domain.SummaryEvaluation
// evaluationTemp := domain.SummaryEvaluation{
// Id: 0,
// CompanyId: int(project.CompanyId),
// EvaluationProjectId: int(project.Id),
// EvaluationProjectName: project.Name,
// CycleId: cycleData.Id,
// CycleName: cycleData.Name,
// NodeId: nodeId,
// TargetUser: domain.StaffDesc{},
// TargetDepartment: []domain.StaffDepartment{},
// Executor: domain.StaffDesc{},
// Types: 0,
// Status: domain.EvaluationUncompleted,
// CheckResult: domain.EvaluationCheckUncompleted,
// BeginTime: time.Time{},
// EndTime: time.Time{},
// TotalScore: "",
// CreatedAt: time.Now(),
// UpdatedAt: time.Now(),
// DeletedAt: nil,
// }
for _, v := range targetUserMap {
//处理自评
evaluationTemp.TargetUser = domain.StaffDesc{
UserId: int(v.Id),
Account: v.Account,
UserName: v.Name,
}
evaluationTemp.Executor = domain.StaffDesc{
UserId: int(v.Id),
Account: v.Account,
UserName: v.Name,
}
evaluationTemp.BeginTime = beginTimeSelf
evaluationTemp.EndTime = endTimeSelf
evaluationTemp.TargetDepartment = []domain.StaffDepartment{}
evaluationTemp.Types = domain.EvaluationSelf
for _, departId := range v.DepartmentId {
depart, ok := departmentMap[int64(departId)]
if !ok {
continue
}
evaluationTemp.TargetDepartment = append(evaluationTemp.TargetDepartment, domain.StaffDepartment{
DepartmentId: int(depart.Id),
DepartmentName: depart.Name,
})
}
newEvaluationList = append(newEvaluationList, evaluationTemp)
if hrbpExist {
//处理人资评估
evaluationTemp.BeginTime = beginTime360
evaluationTemp.EndTime = endTime360
evaluationTemp.Executor = domain.StaffDesc{}
evaluationTemp.Types = domain.EvaluationHrbp
newEvaluationList = append(newEvaluationList, evaluationTemp)
}
//处理360 评估
for _, v2 := range executor360Map {
evaluationTemp.BeginTime = beginTime360
evaluationTemp.EndTime = endTime360
evaluationTemp.Executor = domain.StaffDesc{
UserId: int(v2.Id),
Account: v2.Account,
UserName: v2.Name,
}
evaluationTemp.Types = domain.Evaluation360
newEvaluationList = append(newEvaluationList, evaluationTemp)
}
// //确定周期评估
//处理上级评估
superUser, ok := userMap[v.ParentId]
if ok {
evaluationTemp.Types = domain.EvaluationSuper
evaluationTemp.Executor = domain.StaffDesc{
UserId: int(superUser.Id),
Account: superUser.Account,
UserName: superUser.Name,
}
evaluationTemp.BeginTime = beginTimeSuper
evaluationTemp.EndTime = endTimeSuper
//确定上级评估
newEvaluationList = append(newEvaluationList, evaluationTemp)
}
// 确定 考核结果 的评估记录
evaluationTemp.Types = domain.EvaluationFinish
evaluationTemp.Executor = domain.StaffDesc{}
evaluationTemp.BeginTime = endTimeSuper
evaluationTemp.EndTime = endTimeSuper.Add(2 * 24 * time.Hour)
newEvaluationList = append(newEvaluationList, evaluationTemp)
}
summaryEvaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext})
for i := range newEvaluationList {
err = summaryEvaluationRepo.Save(&newEvaluationList[i])
if err != nil {
return nil, err
}
}
//回填 项目的状态
projectDao := dao.NewEvaluationProjectDao(map[string]interface{}{"transactionContext": transactionContext})
err = projectDao.UpdateSummaryState(project.Id, domain.ProjectSummaryStateYes)
if err != nil {
return nil, err
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, err
}
return newEvaluationList, nil
}
// for _, v := range targetUserMap {
// //处理自评
// evaluationTemp.TargetUser = domain.StaffDesc{
// UserId: int(v.Id),
// Account: v.Account,
// UserName: v.Name,
// }
// evaluationTemp.Executor = domain.StaffDesc{
// UserId: int(v.Id),
// Account: v.Account,
// UserName: v.Name,
// }
// evaluationTemp.BeginTime = beginTimeSelf
// evaluationTemp.EndTime = endTimeSelf
// evaluationTemp.TargetDepartment = []domain.StaffDepartment{}
// evaluationTemp.Types = domain.EvaluationSelf
// for _, departId := range v.DepartmentId {
// depart, ok := departmentMap[int64(departId)]
// if !ok {
// continue
// }
// evaluationTemp.TargetDepartment = append(evaluationTemp.TargetDepartment, domain.StaffDepartment{
// DepartmentId: int(depart.Id),
// DepartmentName: depart.Name,
// })
// }
// newEvaluationList = append(newEvaluationList, evaluationTemp)
// if hrbpExist {
// //处理人资评估
// evaluationTemp.BeginTime = beginTime360
// evaluationTemp.EndTime = endTime360
// evaluationTemp.Executor = domain.StaffDesc{}
// evaluationTemp.Types = domain.EvaluationHrbp
// newEvaluationList = append(newEvaluationList, evaluationTemp)
// }
// //处理360 评估
// for _, v2 := range executor360Map {
// evaluationTemp.BeginTime = beginTime360
// evaluationTemp.EndTime = endTime360
// evaluationTemp.Executor = domain.StaffDesc{
// UserId: int(v2.Id),
// Account: v2.Account,
// UserName: v2.Name,
// }
// evaluationTemp.Types = domain.Evaluation360
// newEvaluationList = append(newEvaluationList, evaluationTemp)
// }
func dayZeroTime(t time.Time) time.Time {
y, m, d := t.Local().Date()
t2 := time.Date(y, m, d, 0, 0, 0, 0, time.Local)
return t2
}
// //处理上级评估
// superUser, ok := userMap[v.ParentId]
// if ok {
// evaluationTemp.Types = domain.EvaluationSuper
// evaluationTemp.Executor = domain.StaffDesc{
// UserId: int(superUser.Id),
// Account: superUser.Account,
// UserName: superUser.Name,
// }
// evaluationTemp.BeginTime = beginTimeSuper
// evaluationTemp.EndTime = endTimeSuper
// //确定上级评估
// newEvaluationList = append(newEvaluationList, evaluationTemp)
// }
// // 确定 考核结果 的评估记录
// evaluationTemp.Types = domain.EvaluationFinish
// evaluationTemp.Executor = domain.StaffDesc{}
// evaluationTemp.BeginTime = endTimeSuper
// evaluationTemp.EndTime = endTimeSuper.Add(2 * 24 * time.Hour)
// newEvaluationList = append(newEvaluationList, evaluationTemp)
// }
// summaryEvaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext})
// for i := range newEvaluationList {
// err = summaryEvaluationRepo.Save(&newEvaluationList[i])
// if err != nil {
// return nil, err
// }
// }
// //回填 项目的状态
// projectDao := dao.NewEvaluationProjectDao(map[string]interface{}{"transactionContext": transactionContext})
// err = projectDao.UpdateSummaryState(project.Id, domain.ProjectSummaryStateYes)
// if err != nil {
// return nil, err
// }
// if err := transactionContext.CommitTransaction(); err != nil {
// return nil, err
// }
// return newEvaluationList, nil
// }
// 下发周期评估
func TaskSendSummaryEvaluation() error {
nowTime := time.Now()
defer func() {
str := fmt.Sprintf("下发周期评估耗时%.2f s", time.Since(nowTime).Seconds())
log.Logger.Info(str)
}()
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return err
}
if err := transactionContext.StartTransaction(); err != nil {
return err
}
defer func() {
_ = transactionContext.RollbackTransaction()
}()
// func dayZeroTime(t time.Time) time.Time {
// y, m, d := t.Local().Date()
// t2 := time.Date(y, m, d, 0, 0, 0, 0, time.Local)
// return t2
// }
projectRepo := factory.CreateEvaluationProjectRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
// // 下发周期评估
// func TaskSendSummaryEvaluation() error {
// nowTime := time.Now()
// defer func() {
// str := fmt.Sprintf("下发周期评估耗时%.2f s", time.Since(nowTime).Seconds())
// log.Logger.Info(str)
// }()
// transactionContext, err := factory.CreateTransactionContext(nil)
// if err != nil {
// return err
// }
// if err := transactionContext.StartTransaction(); err != nil {
// return err
// }
// defer func() {
// _ = transactionContext.RollbackTransaction()
// }()
userRepo := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext})
// projectRepo := factory.CreateEvaluationProjectRepository(map[string]interface{}{
// "transactionContext": transactionContext,
// })
departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{"transactionContext": transactionContext})
// userRepo := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext})
_, projectList, err := projectRepo.Find(map[string]interface{}{
"endTime": time.Now(),
"summaryState": domain.ProjectSummaryStateNo,
"state": domain.ProjectStateEnable,
}, "template")
if err != nil {
return fmt.Errorf("获取可用的项目数据,%s", err)
}
companyIdMap := map[int64]struct{}{}
for _, v := range projectList {
companyIdMap[v.CompanyId] = struct{}{}
}
// departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{"transactionContext": transactionContext})
var createdEvalationList []domain.SummaryEvaluation
// _, projectList, err := projectRepo.Find(map[string]interface{}{
// "endTime": time.Now(),
// "summaryState": domain.ProjectSummaryStateNo,
// "state": domain.ProjectStateEnable,
// }, "template")
// if err != nil {
// return fmt.Errorf("获取可用的项目数据,%s", err)
// }
// companyIdMap := map[int64]struct{}{}
// for _, v := range projectList {
// companyIdMap[v.CompanyId] = struct{}{}
// }
//获取可执行的项目
for companyId := range companyIdMap {
//获取员工数据,部门数据
_, userList, err := userRepo.Find(map[string]interface{}{"companyId": companyId})
if err != nil {
log.Logger.Error("TaskSendSummaryEvaluation 获取员工数据:" + err.Error())
continue
}
_, departmentList, err := departmentRepo.Find(map[string]interface{}{"companyId": companyId})
if err != nil {
log.Logger.Error("TaskSendSummaryEvaluation 获取部门数据:" + err.Error())
continue
}
//转map
userMap := map[int64]*domain.User{}
for _, v := range userList {
userMap[v.Id] = v
}
departmentMap := map[int64]*domain.Department{}
for _, v := range departmentList {
departmentMap[v.Id] = v
}
for _, v := range projectList {
if v.CompanyId != companyId {
continue
}
evalationList, err := sendSummaryEvaluation(v, userMap, departmentMap)
if err != nil {
log.Logger.Error("TaskSendSummaryEvaluation 下发评估任务:" + err.Error())
continue
}
createdEvalationList = append(createdEvalationList, evalationList...)
}
}
if err := transactionContext.CommitTransaction(); err != nil {
return err
}
//添加待发送的短信通知
err = sendSmsEvalation(createdEvalationList)
return err
}
// var createdEvalationList []domain.SummaryEvaluation
// 添加待发送的短信通知
func sendSmsEvalation(param []domain.SummaryEvaluation) error {
for i := range param {
if param[i].Types == domain.EvaluationSelf {
notify.AddNotifySummaryEvaluation(&param[i])
}
}
return nil
}
// //获取可执行的项目
// for companyId := range companyIdMap {
// //获取员工数据,部门数据
// _, userList, err := userRepo.Find(map[string]interface{}{"companyId": companyId})
// if err != nil {
// log.Logger.Error("TaskSendSummaryEvaluation 获取员工数据:" + err.Error())
// continue
// }
// _, departmentList, err := departmentRepo.Find(map[string]interface{}{"companyId": companyId})
// if err != nil {
// log.Logger.Error("TaskSendSummaryEvaluation 获取部门数据:" + err.Error())
// continue
// }
// //转map
// userMap := map[int64]*domain.User{}
// for _, v := range userList {
// userMap[v.Id] = v
// }
// departmentMap := map[int64]*domain.Department{}
// for _, v := range departmentList {
// departmentMap[v.Id] = v
// }
// for _, v := range projectList {
// if v.CompanyId != companyId {
// continue
// }
// evalationList, err := sendSummaryEvaluation(v, userMap, departmentMap)
// if err != nil {
// log.Logger.Error("TaskSendSummaryEvaluation 下发评估任务:" + err.Error())
// continue
// }
// createdEvalationList = append(createdEvalationList, evalationList...)
// }
// }
// if err := transactionContext.CommitTransaction(); err != nil {
// return err
// }
// //添加待发送的短信通知
// err = sendSmsEvalation(createdEvalationList)
// return err
// }
... ...
package service
import (
"fmt"
"strconv"
"time"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/command"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log"
)
// 定时自动确认周期评估考核结果
func TaskConfirmScore() error {
nowTime := time.Now()
defer func() {
str := fmt.Sprintf("自动确认周期评估考核结果耗时%.2f s", time.Since(nowTime).Seconds())
log.Logger.Info(str)
}()
evaluationList, err := catchEvaluation()
if err != nil {
log.Logger.Error(fmt.Sprintf("获取周期考核结果%s", err.Error()))
}
if len(evaluationList) == 0 {
return nil
}
evluationSrv := NewSummaryEvaluationService()
for _, val := range evaluationList {
permissionData, err := getPermission(val.CompanyId)
if err != nil {
log.Logger.Error(fmt.Sprintf("获取公司的权限配置失败%s", err.Error()))
}
if permissionData.OptConfirmPerf != domain.PermissionOn {
continue
}
targetUserId, err := strconv.Atoi(val.TargetUserId)
if err != nil {
log.Logger.Error(fmt.Sprintf("获取员工id%s", err))
continue
}
err = evluationSrv.ConfirmScoreEvaluation(&command.ConfirmScore{
SummaryEvaluationId: val.SummaryEvaluationId,
UserId: targetUserId,
})
if err != nil {
log.Logger.Error(fmt.Sprintf("确认周期考核结果%s", err.Error()))
}
}
return nil
}
func catchEvaluation() ([]dao.SummaryEvaluationData1, error) {
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, err
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, err
}
defer func() {
_ = transactionContext.RollbackTransaction()
}()
evaluationDao := dao.NewSummaryEvaluationDao(map[string]interface{}{
"transactionContext": transactionContext,
})
evaluationList, err := evaluationDao.ListEvaluationFinishNoResult()
if err != nil {
return nil, fmt.Errorf("获取综合评估数据%s", err)
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, err
}
return evaluationList, nil
}
... ...
... ... @@ -7,6 +7,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/notify"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log"
... ... @@ -35,6 +36,12 @@ func TaskSendSummaryEvaluationV2() error {
return nil
}
func dayEndTime(t time.Time) time.Time {
y, m, d := t.Local().Date()
t2 := time.Date(y, m, d, 23, 59, 59, 0, time.Local)
return t2
}
// 获取周期
func getPrepareEvaluationCycle() ([]*domain.EvaluationCycle, error) {
transactionContext, err := factory.CreateTransactionContext(nil)
... ... @@ -58,37 +65,6 @@ func getPrepareEvaluationCycle() ([]*domain.EvaluationCycle, error) {
return cycleList, nil
}
// 获取可用的项目
// func getPrepareSummaryEvaluation(cycleId int) ([]*domain.EvaluationProject, error) {
// transactionContext, err := factory.CreateTransactionContext(nil)
// if err != nil {
// return nil, err
// }
// if err := transactionContext.StartTransaction(); err != nil {
// return nil, err
// }
// defer func() {
// _ = transactionContext.RollbackTransaction()
// }()
// projectRepo := factory.CreateEvaluationProjectRepository(map[string]interface{}{
// "transactionContext": transactionContext,
// })
// // 获取项目数据总数
// _, projectList, err := projectRepo.Find(map[string]interface{}{
// "cycleId": cycleId,
// "summaryState": domain.ProjectSummaryStateNo,
// "state": domain.ProjectStateEnable,
// "limit": 200,
// }, "template")
// if err != nil {
// return nil, fmt.Errorf("获取可用的项目数据,%s", err)
// }
// if err := transactionContext.CommitTransaction(); err != nil {
// return nil, err
// }
// return projectList, nil
// }
// 按周期下发 综合评估任务
func sendSummaryEvaluationByCycle(cycleParam *domain.EvaluationCycle) error {
transactionContext, err := factory.CreateTransactionContext(nil)
... ... @@ -115,10 +91,14 @@ func sendSummaryEvaluationByCycle(cycleParam *domain.EvaluationCycle) error {
if err != nil {
return fmt.Errorf("获取可用的项目数据,%s", err)
}
permissionData, err := getPermission(cycleParam.CompanyId)
if err != nil {
return fmt.Errorf("获取公司的周期评估设置项,%s", err)
}
var newEvaluationList []domain.SummaryEvaluation
newPublisher := summaryEvaluationPublisher{}
for _, val := range projectList {
evaluationList, err := newPublisher.sendSummaryEvaluationV2(transactionContext, val, cycleParam)
evaluationList, err := newPublisher.sendSummaryEvaluationV2(transactionContext, val, cycleParam, *permissionData)
if err != nil {
return fmt.Errorf("按项目下发综合评估任务数据,%s", err)
}
... ... @@ -140,6 +120,16 @@ func sendSummaryEvaluationByCycle(cycleParam *domain.EvaluationCycle) error {
return nil
}
// // 添加待发送的短信通知
func sendSmsEvalation(param []domain.SummaryEvaluation) error {
for i := range param {
if param[i].Types == domain.EvaluationSelf {
notify.AddNotifySummaryEvaluation(&param[i])
}
}
return nil
}
// 下发周期综合评估
type summaryEvaluationPublisher struct {
userCache map[int64]*domain.User
... ... @@ -148,18 +138,10 @@ type summaryEvaluationPublisher struct {
func (se *summaryEvaluationPublisher) sendSummaryEvaluationV2(
transactionContext application.TransactionContext,
projectParam *domain.EvaluationProject, cycleData *domain.EvaluationCycle,
projectParam *domain.EvaluationProject,
cycleData *domain.EvaluationCycle,
permissioData domain.Permission,
) ([]domain.SummaryEvaluation, error) {
// transactionContext, err := factory.CreateTransactionContext(nil)
// if err != nil {
// return err
// }
// if err := transactionContext.StartTransaction(); err != nil {
// return err
// }
// defer func() {
// _ = transactionContext.RollbackTransaction()
// }()
userRepo := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext})
departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{"transactionContext": transactionContext})
evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext})
... ... @@ -193,16 +175,31 @@ func (se *summaryEvaluationPublisher) sendSummaryEvaluationV2(
if cycleData.TimeEnd == nil {
return nil, fmt.Errorf("周期%d:%s 结束时间错误", cycleData.Id, cycleData.Name)
}
//自评的时间范围
beginTimeSelf := *cycleData.TimeEnd
beginTimeSelf := *cycleData.TimeEnd //
beginDay := dayEndTime(beginTimeSelf)
//修改 周期结束时间那天的第二天开始计算
endTimeSelf := dayZeroTime(beginTimeSelf).Add(4*24*time.Hour - time.Second)
endTimeSelf := beginDay.Add(time.Duration(permissioData.CycleDeadline.AssessmentSelf.Hour) * time.Hour).
Add(time.Duration(permissioData.CycleDeadline.AssessmentSelf.Minute) * time.Minute)
//人资、360评估的时间范围
beginTime360 := endTimeSelf
endTime360 := endTimeSelf.Add(2 * 24 * time.Hour)
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)
//上级评估的是时间范围
beginTimeSuper := endTime360
endTimeSuper := endTime360.Add(2 * 24 * time.Hour)
beginTimeSuper := endTimeHr
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)
// 创建周期评估任务
var newEvaluationList []domain.SummaryEvaluation
evaluationTemp := domain.SummaryEvaluation{
... ... @@ -287,8 +284,8 @@ func (se *summaryEvaluationPublisher) sendSummaryEvaluationV2(
{
if hrbpExist {
//处理人资评估
evaluationTemp.BeginTime = beginTime360
evaluationTemp.EndTime = endTime360
evaluationTemp.BeginTime = beginTimeHr
evaluationTemp.EndTime = endTimeHr
evaluationTemp.Executor = domain.StaffDesc{}
evaluationTemp.Types = domain.EvaluationHrbp
newEvaluationList = append(newEvaluationList, evaluationTemp)
... ... @@ -314,8 +311,8 @@ func (se *summaryEvaluationPublisher) sendSummaryEvaluationV2(
{
evaluationTemp.Types = domain.EvaluationFinish
evaluationTemp.Executor = domain.StaffDesc{}
evaluationTemp.BeginTime = endTimeSuper
evaluationTemp.EndTime = endTimeSuper.Add(2 * 24 * time.Hour)
evaluationTemp.BeginTime = beginTimeFinish
evaluationTemp.EndTime = endTimeFinish
newEvaluationList = append(newEvaluationList, evaluationTemp)
}
}
... ... @@ -332,30 +329,9 @@ func (se *summaryEvaluationPublisher) sendSummaryEvaluationV2(
if err != nil {
return nil, fmt.Errorf("保存项目状态%s", err)
}
// if err := transactionContext.CommitTransaction(); err != nil {
// return err
// }
return newEvaluationList, nil
}
// 获取周期设置数据
// func (se *summaryEvaluationPublisher) getCycleData(cycleRepo domain.EvaluationCycleRepository, cycleId int64) (*domain.EvaluationCycle, error) {
// var cycleData *domain.EvaluationCycle
// if val, ok := se.cycleCache[cycleId]; ok {
// cycleData = val
// } else {
// _, cycleList, err := cycleRepo.Find(map[string]interface{}{"id": cycleId})
// if err != nil {
// return nil, err
// }
// if len(cycleList) == 0 {
// return nil, nil
// }
// cycleData = cycleList[0]
// }
// return cycleData, nil
// }
// 获取用户数据
func (se *summaryEvaluationPublisher) getUserData(userRepo domain.UserRepository, userId int64) (*domain.User, error) {
if userId == 0 {
... ...
... ... @@ -43,7 +43,7 @@ func (srv *SummaryEvaluationService) GetExecutorCycleList(param *command.QueryCy
"transactionContext": transactionContext,
})
flagHrbp, err := roleService.GetHRBP(transactionContext, param.CompanyId, param.UserId)
flagHrbp, err := roleService.GetHrBp(transactionContext, param.CompanyId, param.UserId)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
... ... @@ -194,7 +194,7 @@ func (srv *SummaryEvaluationService) GetMenu(param *command.QueryMenu) (map[stri
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
}
isHrbp, err := roleService.GetHRBP(transactionContext, param.CompanyId, param.UserId)
isHrbp, err := roleService.GetHrBp(transactionContext, param.CompanyId, param.UserId)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
... ... @@ -354,13 +354,6 @@ func (srv *SummaryEvaluationService) buildSummaryItemValue(itemList []*domain.Ev
Remark: "",
EvaluatorId: v.EvaluatorId,
}
//PromptText 页面展示 特殊处理
if len(v.EntryItems) > 0 {
item.PromptTitle = ""
for _, v2 := range v.EntryItems {
item.PromptTitle += v2.Title + "\n"
}
}
value, ok := valueMap[v.Id]
if ok {
item.Score = value.Score
... ... @@ -1014,11 +1007,15 @@ func (srv *SummaryEvaluationService) GetEvaluationSuper(param *command.QueryEval
itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
permissionRepository := factory.CreatePermissionRepository(map[string]interface{}{"transactionContext": transactionContext})
// permissionRepository := factory.CreatePermissionRepository(map[string]interface{}{"transactionContext": transactionContext})
// 获取权限配置
_, permissionList, err := permissionRepository.Find(map[string]interface{}{"companyId": param.CompanyId})
// _, permissionList, err := permissionRepository.Find(map[string]interface{}{"companyId": param.CompanyId})
// if err != nil {
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
// }
permissinData, err := getPermission(int64(param.CompanyId))
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
return nil, err
}
evaluationData, err := evaluationRepo.FindOne(map[string]interface{}{
"id": param.SummaryEvaluationId,
... ... @@ -1077,15 +1074,13 @@ func (srv *SummaryEvaluationService) GetEvaluationSuper(param *command.QueryEval
//组合 评估填写的值和评估项
itemValuesAdapter := srv.buildSummaryItemValue(itemList, itemValues)
for i, v := range itemValuesAdapter {
if len(permissionList) > 0 {
if permissionList[0].OptEvalScore == domain.PermissionOff &&
v.EvaluatorId > 0 {
itemValuesAdapter[i].ForbidEdit = true
}
if permissionList[0].OptHrScore == domain.PermissionOff &&
v.EvaluatorId < 0 {
itemValuesAdapter[i].ForbidEdit = true
}
if permissinData.OptEvalScore == domain.PermissionOff &&
v.EvaluatorId > 0 {
itemValuesAdapter[i].ForbidEdit = true
}
if permissinData.OptHrScore == domain.PermissionOff &&
v.EvaluatorId < 0 {
itemValuesAdapter[i].ForbidEdit = true
}
}
result := adapter.EvaluationInfoSuperAdapter{
... ... @@ -1213,16 +1208,19 @@ func (srv *SummaryEvaluationService) getEvaluationSuperDefaultValue(transactionC
"transactionContext": transactionContext,
})
permissionRepository := factory.CreatePermissionRepository(map[string]interface{}{"transactionContext": transactionContext})
// 获取权限配置
_, permissionList, err := permissionRepository.Find(map[string]interface{}{"companyId": evaluationData.CompanyId})
// permissionRepository := factory.CreatePermissionRepository(map[string]interface{}{"transactionContext": transactionContext})
// // 获取权限配置
// _, permissionList, err := permissionRepository.Find(map[string]interface{}{"companyId": evaluationData.CompanyId})
// if err != nil {
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
// }
// if len(permissionList) == 0 {
// return nil, nil
// }
permissionData, err := getPermission(int64(evaluationData.CompanyId))
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if len(permissionList) == 0 {
return nil, nil
}
permissionData := permissionList[0]
if permissionData.OptEvalScore == domain.PermissionOn && permissionData.OptHrScore == domain.PermissionOn {
return nil, nil
}
... ... @@ -1392,7 +1390,7 @@ func (srv *SummaryEvaluationService) ListExecutorEvaluationSuper(param *command.
TargetUserName: v.TargetUser.UserName,
TargetUserId: v.TargetUser.UserId,
EvaluationStatus: string(v.Status),
EndTime: v.EndTime.Format("2006-01-02 15:04:05"),
EndTime: v.EndTime.Local().Format("2006-01-02 15:04:05"),
TotalScoreSelf: "",
Department: "",
Position: "",
... ... @@ -1422,7 +1420,7 @@ func (srv *SummaryEvaluationService) ListExecutorEvaluationSuper(param *command.
result["endTime"] = ""
result["uncompleted_number"] = 0
if len(evaluationList) > 0 {
result["endTime"] = evaluationList[0].EndTime.Format("2006-01-02 15:04:05")
result["endTime"] = evaluationList[0].EndTime.Local().Format("2006-01-02 15:04:05")
result["uncompleted_number"] = cntUn
}
return result, nil
... ... @@ -1447,6 +1445,7 @@ func (srv *SummaryEvaluationService) ConfirmScoreEvaluation(param *command.Confi
if err != nil {
return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if result.Types != domain.EvaluationFinish {
return application.ThrowError(application.TRANSACTION_ERROR, "操作方式错误")
}
... ... @@ -1771,11 +1770,11 @@ func (srv *SummaryEvaluationService) ListAllEvaluationFinish(param *command.Quer
_ = transactionContext.RollbackTransaction()
}()
//判断是否是hrbp
flagHrbp, err := roleService.GetHRBP(transactionContext, param.CompanyId, param.UserId)
flagHrbp, err := roleService.GetHrBp(transactionContext, param.CompanyId, param.UserId)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if flagHrbp != 1 {
if flagHrbp != domain.RoleTypeSystem {
return tool_funs.SimpleWrapGridMap(0, []string{}), nil
}
//判断是否是上级
... ... @@ -1787,7 +1786,7 @@ func (srv *SummaryEvaluationService) ListAllEvaluationFinish(param *command.Quer
"parentId": param.UserId,
"limit": 1,
})
if len(parentUser) == 0 && flagHrbp != 1 {
if len(parentUser) == 0 && flagHrbp != domain.RoleTypeSystem {
return tool_funs.SimpleWrapGridMap(0, []string{}), nil
}
evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{
... ... @@ -1802,10 +1801,9 @@ func (srv *SummaryEvaluationService) ListAllEvaluationFinish(param *command.Quer
//获取评估列表信息
condition1 := map[string]interface{}{
"cycleId": param.CycleId,
"types": int(domain.EvaluationFinish),
"limit": limit,
"beginTime": time.Now(),
"cycleId": param.CycleId,
"types": int(domain.EvaluationFinish),
"limit": limit,
}
if offset > 0 {
condition1["offset"] = offset
... ...
... ... @@ -9,7 +9,7 @@ import (
"github.com/linmadan/egglib-go/core/application"
"github.com/linmadan/egglib-go/utils/tool_funs"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
service "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/role"
roleService "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/role"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/adapter"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/command"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
... ... @@ -437,11 +437,11 @@ func (srv *SummaryEvaluationService) EvaluationHRBPList(param *command.QueryEval
}()
// 必须是HRBP权限的人才能编辑操作
hrbp, err := service.GetHRBP(transactionContext, param.CompanyId, param.UserId)
hrbp, err := roleService.GetHrBp(transactionContext, param.CompanyId, param.UserId)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if hrbp != 1 {
if hrbp != domain.RoleTypeSystem {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
}
... ... @@ -738,11 +738,11 @@ func (srv *SummaryEvaluationService) EditEvaluationHRBP(param *command.EditEvalu
itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext})
// 必须是HRBP权限的人才能编辑操作
hrbp, err := service.GetHRBP(transactionContext, param.CompanyId, param.ExecutorId)
hrbp, err := roleService.GetHrBp(transactionContext, param.CompanyId, param.ExecutorId)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if hrbp != 1 {
if hrbp != domain.RoleTypeSystem {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
}
... ... @@ -820,3 +820,54 @@ func (srv *SummaryEvaluationService) EditEvaluationHRBP(param *command.EditEvalu
"evaluationItems": itemValueAdapter,
}, nil
}
// 修改周期考核的分数
func (srv *SummaryEvaluationService) ModifyFinishScore(param *command.ModifyFinishScore) error {
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
_ = transactionContext.RollbackTransaction()
}()
// 只有超级管理员可以使用的功能
superAdmin, err := roleService.GetSuperAdmin(transactionContext, param.CompanyId, param.UserId)
if err != nil {
return err
}
if superAdmin != domain.RoleTypeSuperAdmin {
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
}
//获取周期评估任务finish
evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext})
_, evaluationList, err := evaluationRepo.Find(map[string]interface{}{
"id": []int{param.SummaryEvaluationId},
"companyId": param.CompanyId,
})
if err != nil {
return application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
if len(evaluationList) == 0 {
return nil
}
evaluationData := evaluationList[0]
if evaluationData.Types != domain.EvaluationFinish {
return nil
}
scoreStr := fmt.Sprintf("%.2f", param.Score)
evaluationData.TotalScore = scoreStr
evaluationData.Status = domain.EvaluationCompleted
evaluationData.CheckResult = domain.EvaluationCheckCompleted
err = evaluationRepo.Save(evaluationData)
if err != nil {
return application.ThrowError(application.BUSINESS_ERROR, "修改考核结果"+err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
return nil
}
... ...
package service
import (
permissionSrv "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/permission"
permissionCmd "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/permission/command"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
)
func getPermission(companyId int64) (*domain.Permission, error) {
srv := &permissionSrv.PermissionService{}
permissionData, err := srv.Get(&permissionCmd.GetPermissionCommand{
CompanyId: companyId,
})
if err != nil {
return nil, err
}
return permissionData, nil
}
... ...
... ... @@ -135,11 +135,11 @@ func (us *UserService) EditParentUser(in *command.EditParentCommand) error {
transactionContext.RollbackTransaction()
}()
hrbp, err := service.GetHRBP(transactionContext, in.CompanyId, in.OperatorId)
hrbp, err := service.GetHrBp(transactionContext, in.CompanyId, in.OperatorId)
if err != nil {
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if hrbp != 1 {
if hrbp != domain.RoleTypeSystem {
return application.ThrowError(application.BUSINESS_ERROR, "HRBP权限的员工才能操作")
}
... ... @@ -177,11 +177,11 @@ func (us *UserService) ImportParentUser(in *command.ImportParentUserCommand) (in
transactionContext.RollbackTransaction()
}()
hrbp, err := service.GetHRBP(transactionContext, in.CompanyId, in.OperatorId)
hrbp, err := service.GetHrBp(transactionContext, in.CompanyId, in.OperatorId)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if hrbp != 1 {
if hrbp != domain.RoleTypeSystem {
return nil, application.ThrowError(application.BUSINESS_ERROR, "HRBP权限的员工才能操作")
}
userRepo := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext})
... ...
... ... @@ -8,13 +8,29 @@ const (
)
type Permission struct {
Id int64 `json:"id,string"`
CompanyId int64 `json:"companyId" comment:"公司ID" `
OptHrScore int `json:"optHrScore" comment:"上级是否可以修改人资综评分数"`
OptEvalScore int `json:"optEvalScore" comment:"上级是否可以修改360°综评分数"`
CreatedAt time.Time `json:"createdAt" comment:"创建时间"`
UpdatedAt time.Time `json:"updatedAt" comment:"更新时间"`
DeletedAt *time.Time `json:"deletedAt" comment:"删除时间"`
Id int64 `json:"id,string"`
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:"周期评估各业务截止时间"`
CreatedAt time.Time `json:"createdAt" comment:"创建时间"`
UpdatedAt time.Time `json:"updatedAt" comment:"更新时间"`
DeletedAt *time.Time `json:"deletedAt" comment:"删除时间"`
}
// CycleDeadline 周期评估截止时间
type CycleDeadline struct {
AssessmentSelf DeadlineTime `json:"assessmentSelf" comment:"综合自评"`
AssessmentAll DeadlineTime `json:"assessmentAll" comment:"360评估"`
AssessmentHr DeadlineTime `json:"assessmentHr" comment:"人资评估"`
AssessmentSuperior DeadlineTime `json:"assessmentSuperior" comment:"上级评估"`
ViewMyPerf DeadlineTime `json:"viewMyPerf" comment:"查看我的绩效"`
}
type DeadlineTime struct {
Hour int `json:"hour" comment:"时"`
Minute int `json:"minute" comment:"分"`
}
type PermissionRepository interface {
... ...
... ... @@ -3,8 +3,9 @@ package domain
import "time"
const (
RoleTypeCommon int = 0 // 角色类型-后台添加角色
RoleTypeSystem int = 1 // 角色类型-系统预制角色(不可删除、编辑)
RoleTypeCommon int = 0 // 角色类型-普通角色
RoleTypeSystem int = 1 // 角色类型-系统预制角色HR-BP(不可删除、编辑)
RoleTypeSuperAdmin int = 2 // 角色类型-系统预制超级管理员(不可删除、编辑)
)
type Role struct {
... ...
... ... @@ -151,3 +151,30 @@ func (d *SummaryEvaluationDao) UpdateBeginTime(ids []int, beginTime time.Time) e
_, err := tx.Exec(sqlStr, condition...)
return err
}
type SummaryEvaluationData1 struct {
SummaryEvaluationId int `pg:"summary_evaluation_id"`
TargetUserId string `pg:"target_user_id"`
CompanyId int64 `pg:"company_id"`
}
// 查询周期考核结果
// 条件:已过截止时间,并且还没确认周期考核结果
func (d *SummaryEvaluationDao) ListEvaluationFinishNoResult() ([]SummaryEvaluationData1, error) {
sqlStr := `select
summary_evaluation.id as summary_evaluation_id,
summary_evaluation.target_user ->>'userId' as target_user_id,
summary_evaluation.company_id
from summary_evaluation
where 1=1
and summary_evaluation."types" = 5
and summary_evaluation.status ='completed'
and summary_evaluation.check_result ='uncompleted'
and summary_evaluation.end_time <=now()
and summary_evaluation.deleted_at isnull
`
result := []SummaryEvaluationData1{}
tx := d.transactionContext.PgTx
_, err := tx.Query(&result, sqlStr)
return result, err
}
... ...
package models
import "time"
import (
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
"time"
)
type Permission struct {
tableName struct{} `comment:"配置权限" pg:"permission"`
Id int64 `comment:"ID" pg:"pk:id"`
CompanyId int64 `comment:"公司ID"`
OptHrScore int `comment:"上级是否可以修改人资综评分数"`
OptEvalScore int `comment:"上级是否可以修改360°综评分数"`
CreatedAt time.Time `comment:"创建时间"`
UpdatedAt time.Time `comment:"更新时间"`
DeletedAt *time.Time `comment:"删除时间"`
tableName struct{} `comment:"配置权限" pg:"permission"`
Id int64 `comment:"ID" pg:"pk:id"`
CompanyId int64 `comment:"公司ID"`
OptHrScore int `comment:"上级是否可以修改人资综评分数"`
OptEvalScore int `comment:"上级是否可以修改360°综评分数"`
OptConfirmPerf int `comment:"是否需要员工确认绩效"`
CycleDeadline *domain.CycleDeadline `comment:"周期评估各业务截止时间"`
CreatedAt time.Time `comment:"创建时间"`
UpdatedAt time.Time `comment:"更新时间"`
DeletedAt *time.Time `comment:"删除时间"`
}
... ...
... ... @@ -22,25 +22,29 @@ func NewPermissionRepository(transactionContext *pgTransaction.TransactionContex
func (repo *PermissionRepository) TransformToDomain(m *models.Permission) domain.Permission {
return domain.Permission{
Id: m.Id,
CompanyId: m.CompanyId,
OptHrScore: m.OptHrScore,
OptEvalScore: m.OptEvalScore,
CreatedAt: m.CreatedAt.Local(),
UpdatedAt: m.UpdatedAt.Local(),
DeletedAt: m.DeletedAt,
Id: m.Id,
CompanyId: m.CompanyId,
OptHrScore: m.OptHrScore,
OptEvalScore: m.OptEvalScore,
OptConfirmPerf: m.OptConfirmPerf,
CycleDeadline: m.CycleDeadline,
CreatedAt: m.CreatedAt.Local(),
UpdatedAt: m.UpdatedAt.Local(),
DeletedAt: m.DeletedAt,
}
}
func (repo *PermissionRepository) TransformToModel(d *domain.Permission) models.Permission {
return models.Permission{
Id: d.Id,
CompanyId: d.CompanyId,
OptHrScore: d.OptHrScore,
OptEvalScore: d.OptEvalScore,
CreatedAt: d.CreatedAt,
UpdatedAt: d.UpdatedAt,
DeletedAt: d.DeletedAt,
Id: d.Id,
CompanyId: d.CompanyId,
OptHrScore: d.OptHrScore,
OptEvalScore: d.OptEvalScore,
OptConfirmPerf: d.OptConfirmPerf,
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))
}
}
... ...
... ... @@ -384,3 +384,20 @@ func (c *SummaryEvaluationController) SearchAssessRemark() {
data, err := srv.SearchAssessRemark(param)
c.Response(data, err)
}
// 修改周期考核结果的分数
func (c *SummaryEvaluationController) ModifyFinishScore() {
srv := service.NewSummaryEvaluationService()
param := &command.ModifyFinishScore{}
err := c.BindJSON(param)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
userReq := middlewares.GetUser(c.Ctx)
param.UserId = int(userReq.UserId)
param.CompanyId = int(userReq.CompanyId)
err = srv.ModifyFinishScore(param)
c.Response(nil, err)
}
... ...
... ... @@ -32,6 +32,7 @@ func init() {
//web.NSCtrlPost("/target_user/evaluation-super", (*controllers.SummaryEvaluationController).GetTargetEvaluationResult),
// web.NSCtrlPost("/evaluation-super/all", (*controllers.SummaryEvaluationController).ListAllEvaluationSuper),
web.NSCtrlPost("/evaluation-finish/all", (*controllers.SummaryEvaluationController).ListAllEvaluationFinish),
web.NSCtrlPost("/evaluation-finish/modify-score", (*controllers.SummaryEvaluationController).ModifyFinishScore),
// web.NSCtrlPost("/evaluation-super/all/export", (*controllers.SummaryEvaluationController).ExportAllEvaluationSuper),
web.NSCtrlPost("/evaluation-finish/all/export", (*controllers.SummaryEvaluationController).ExportAllEvaluationFinish),
web.NSCtrlGet("/evaluation-self/now", (*controllers.SummaryEvaluationController).ListExecutorEvaluationSelf),
... ...
-- 权限表建新列
ALTER TABLE public."permission"
ADD opt_confirm_perf int8 NULL DEFAULT 1;
COMMENT
ON COLUMN public."permission".opt_confirm_perf IS '是否需要员工确认绩效';
ALTER TABLE public."permission"
ADD cycle_deadline jsonb NULL;
COMMENT
ON COLUMN public."permission".cycle_deadline IS '周期评估各业务截止时间';
-- 公司添加超级管理员(不存在时插入新数据)(注.公司ID->416)
insert
into
public."role"
( "name",
"type",
description,
company_id,
created_at,
updated_at,
deleted_at)
select
'超级管理员',
2,
'隐藏角色,拥有部分权限',
416,
now(),
now(),
null
where
not exists (
select
1
from
public."role"
where
"role".company_id = 416
and "role"."type" = 2);
-- 超级管理员添加关联用户(不存在时插入新数据)(注.公司ID->416 用户ID->3337322891762688)
with temp_role as (
select
id
from
public."role"
where
"role".company_id = 416
and "role"."type" = 2)
insert
into
public."role_user"
( role_id,
user_id,
company_id,
created_at,
updated_at,
deleted_at)
select
temp_role."id",
3337322891762688,
416,
now(),
now(),
null
from
temp_role
where
not exists(
select
1
from
public."role_user"
where
"role_user".company_id = 416
and "role_user".user_id = 3337322891762688
and "role_user".role_id = temp_role."id");
--
\ No newline at end of file
... ...