Merge branch 'test' into dev-zhengzhou
正在显示
27 个修改的文件
包含
862 行增加
和
458 行删除
@@ -17,6 +17,7 @@ import ( | @@ -17,6 +17,7 @@ import ( | ||
17 | func main() { | 17 | func main() { |
18 | startNodeTask() | 18 | startNodeTask() |
19 | startSummaryEvaluation() | 19 | startSummaryEvaluation() |
20 | + startConfirmEvaluationScore() | ||
20 | go notify.RunTaskSmsNotify() | 21 | go notify.RunTaskSmsNotify() |
21 | go consumer.Run() | 22 | go consumer.Run() |
22 | web.Run() | 23 | web.Run() |
@@ -63,3 +64,23 @@ func startSummaryEvaluation() { | @@ -63,3 +64,23 @@ func startSummaryEvaluation() { | ||
63 | } | 64 | } |
64 | }() | 65 | }() |
65 | } | 66 | } |
67 | + | ||
68 | +// 定时自动确认周期评估考核结果 | ||
69 | +func startConfirmEvaluationScore() { | ||
70 | + go func() { | ||
71 | + var duration time.Duration | ||
72 | + if constant.Env == "prd" { | ||
73 | + duration = time.Minute * 5 | ||
74 | + } else { | ||
75 | + duration = time.Minute * 1 | ||
76 | + } | ||
77 | + timer := time.NewTimer(duration) | ||
78 | + for { | ||
79 | + <-timer.C | ||
80 | + if err := serviceSummary.TaskConfirmScore(); err != nil { | ||
81 | + log.Logger.Error(err.Error()) | ||
82 | + } | ||
83 | + timer.Reset(duration) // 重置定时 | ||
84 | + } | ||
85 | + }() | ||
86 | +} |
@@ -9,4 +9,5 @@ type MeInfo struct { | @@ -9,4 +9,5 @@ type MeInfo struct { | ||
9 | Name string `json:"name"` // 员工名称 | 9 | Name string `json:"name"` // 员工名称 |
10 | IsHrbp bool `json:"isHrbp"` //是否 是hrbp | 10 | IsHrbp bool `json:"isHrbp"` //是否 是hrbp |
11 | IsParent bool `json:"isParent"` //是否 是上级 | 11 | IsParent bool `json:"isParent"` //是否 是上级 |
12 | + IsSuperAdmin bool `json:"isSuperAdmin"` //是否 是超级角色 | ||
12 | } | 13 | } |
@@ -5,6 +5,7 @@ import ( | @@ -5,6 +5,7 @@ import ( | ||
5 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/auth/adapter" | 5 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/auth/adapter" |
6 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/auth/command" | 6 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/auth/command" |
7 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" | 7 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" |
8 | + roleService "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/role" | ||
8 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/constant" | 9 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/constant" |
9 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | 10 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" |
10 | ) | 11 | ) |
@@ -173,8 +174,6 @@ func (service *AuthService) MeInfo(param *command.GetMeInfo) (map[string]interfa | @@ -173,8 +174,6 @@ func (service *AuthService) MeInfo(param *command.GetMeInfo) (map[string]interfa | ||
173 | }() | 174 | }() |
174 | userRepository := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext}) | 175 | userRepository := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext}) |
175 | companyRepository := factory.CreateCompanyRepository(map[string]interface{}{"transactionContext": transactionContext}) | 176 | companyRepository := factory.CreateCompanyRepository(map[string]interface{}{"transactionContext": transactionContext}) |
176 | - roleRepo := factory.CreateRoleRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
177 | - roleUserRepo := factory.CreateRoleUserRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
178 | userData, err := userRepository.FindOne(map[string]interface{}{ | 177 | userData, err := userRepository.FindOne(map[string]interface{}{ |
179 | "id": param.UserId, | 178 | "id": param.UserId, |
180 | }) | 179 | }) |
@@ -194,24 +193,14 @@ func (service *AuthService) MeInfo(param *command.GetMeInfo) (map[string]interfa | @@ -194,24 +193,14 @@ func (service *AuthService) MeInfo(param *command.GetMeInfo) (map[string]interfa | ||
194 | if err != nil { | 193 | if err != nil { |
195 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取公司数据"+err.Error()) | 194 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取公司数据"+err.Error()) |
196 | } | 195 | } |
197 | - _, roleList, err := roleRepo.Find(map[string]interface{}{"type": domain.RoleTypeSystem, "companyId": param.CompanyId}) | 196 | + |
197 | + hrbpFlag, err := roleService.GetHrBp(transactionContext, int(param.CompanyId), int(param.UserId)) | ||
198 | if err != nil { | 198 | if err != nil { |
199 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取角色信息列表"+err.Error()) | 199 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取用户的角色信息"+err.Error()) |
200 | } | 200 | } |
201 | - _, userRoleList, err := roleUserRepo.Find(map[string]interface{}{"companyId": param.CompanyId, "userId": param.UserId}) | 201 | + superAdminFlag, err := roleService.GetSuperAdmin(transactionContext, int(param.CompanyId), int(param.UserId)) |
202 | if err != nil { | 202 | if err != nil { |
203 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取用户的角色信息列表"+err.Error()) | ||
204 | - } | ||
205 | - // 拥有HRBP权限 | ||
206 | - isHrbp := false | ||
207 | -loop: | ||
208 | - for _, v := range userRoleList { | ||
209 | - for _, v2 := range roleList { | ||
210 | - if v.RoleId == v2.Id { | ||
211 | - isHrbp = true | ||
212 | - break loop | ||
213 | - } | ||
214 | - } | 203 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取用户的角色信息"+err.Error()) |
215 | } | 204 | } |
216 | if err := transactionContext.CommitTransaction(); err != nil { | 205 | if err := transactionContext.CommitTransaction(); err != nil { |
217 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 206 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
@@ -223,8 +212,15 @@ loop: | @@ -223,8 +212,15 @@ loop: | ||
223 | CompanyLogo: companyData.Logo, | 212 | CompanyLogo: companyData.Logo, |
224 | Phone: userData.Account, | 213 | Phone: userData.Account, |
225 | Name: userData.Name, | 214 | Name: userData.Name, |
226 | - IsHrbp: isHrbp, | 215 | + IsHrbp: false, |
227 | IsParent: false, | 216 | IsParent: false, |
217 | + IsSuperAdmin: false, | ||
218 | + } | ||
219 | + if hrbpFlag == domain.RoleTypeSystem { | ||
220 | + info.IsHrbp = true | ||
221 | + } | ||
222 | + if superAdminFlag == domain.RoleTypeSuperAdmin { | ||
223 | + info.IsSuperAdmin = true | ||
228 | } | 224 | } |
229 | if len(parentUser) > 0 { | 225 | if len(parentUser) > 0 { |
230 | info.IsParent = true | 226 | info.IsParent = true |
@@ -37,7 +37,12 @@ func (notices *notifySms) regist(ifsend notifySendOrNot) { | @@ -37,7 +37,12 @@ func (notices *notifySms) regist(ifsend notifySendOrNot) { | ||
37 | } | 37 | } |
38 | 38 | ||
39 | func (notices *notifySms) addTask(task *domain.LogSms) { | 39 | func (notices *notifySms) addTask(task *domain.LogSms) { |
40 | - notices.newSms <- task | 40 | + // notices.newSms <- task |
41 | + err := notices.addNewSms(task) | ||
42 | + if err != nil { | ||
43 | + e := fmt.Sprintf("添加短信通知任务:%+v %s", task, err) | ||
44 | + log.Logger.Error(e) | ||
45 | + } | ||
41 | } | 46 | } |
42 | 47 | ||
43 | // RunTask 执行短信通知任务 | 48 | // RunTask 执行短信通知任务 |
@@ -7,8 +7,11 @@ import ( | @@ -7,8 +7,11 @@ 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"` |
13 | + OptConfirmPerf int `cname:"是否需要员工确认绩效" json:"optConfirmPerf"` | ||
14 | + CycleDeadLine *domain.CycleDeadline `cname:"周期评估各业务截止时间" json:"cycleDeadline"` | ||
12 | } | 15 | } |
13 | 16 | ||
14 | func (in *UpdatePermissionCommand) Valid(validation *validation.Validation) { | 17 | func (in *UpdatePermissionCommand) Valid(validation *validation.Validation) { |
@@ -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()) |
@@ -46,7 +87,7 @@ func (rs *PermissionService) Update(in *command.UpdatePermissionCommand) (interf | @@ -46,7 +87,7 @@ func (rs *PermissionService) Update(in *command.UpdatePermissionCommand) (interf | ||
46 | return permission, nil | 87 | return permission, nil |
47 | } | 88 | } |
48 | 89 | ||
49 | -func (rs *PermissionService) Get(in *command.GetPermissionCommand) (interface{}, error) { | 90 | +func (rs *PermissionService) Get(in *command.GetPermissionCommand) (*domain.Permission, error) { |
50 | transactionContext, err := factory.ValidateStartTransaction(in) | 91 | transactionContext, err := factory.ValidateStartTransaction(in) |
51 | if err != nil { | 92 | if err != nil { |
52 | return nil, err | 93 | return nil, err |
@@ -68,6 +109,8 @@ func (rs *PermissionService) Get(in *command.GetPermissionCommand) (interface{}, | @@ -68,6 +109,8 @@ func (rs *PermissionService) Get(in *command.GetPermissionCommand) (interface{}, | ||
68 | CompanyId: in.CompanyId, | 109 | CompanyId: in.CompanyId, |
69 | OptHrScore: domain.PermissionOff, | 110 | OptHrScore: domain.PermissionOff, |
70 | OptEvalScore: domain.PermissionOff, | 111 | OptEvalScore: domain.PermissionOff, |
112 | + OptConfirmPerf: domain.PermissionOff, | ||
113 | + CycleDeadline: rs.defaultCycleDeadline(), | ||
71 | } | 114 | } |
72 | permission, err = permissionRepository.Insert(value) | 115 | permission, err = permissionRepository.Insert(value) |
73 | if err != nil { | 116 | if err != nil { |
@@ -75,9 +118,59 @@ func (rs *PermissionService) Get(in *command.GetPermissionCommand) (interface{}, | @@ -75,9 +118,59 @@ func (rs *PermissionService) Get(in *command.GetPermissionCommand) (interface{}, | ||
75 | } | 118 | } |
76 | } else { | 119 | } else { |
77 | permission = permissions[0] | 120 | permission = permissions[0] |
121 | + // 纠正数据 | ||
122 | + var isChange = false | ||
123 | + if permission.OptHrScore == 0 { | ||
124 | + isChange = true | ||
125 | + permission.OptHrScore = domain.PermissionOff | ||
126 | + } | ||
127 | + if permission.OptEvalScore == 0 { | ||
128 | + isChange = true | ||
129 | + permission.OptEvalScore = domain.PermissionOff | ||
130 | + } | ||
131 | + if permission.OptConfirmPerf == 0 { | ||
132 | + isChange = true | ||
133 | + permission.OptConfirmPerf = domain.PermissionOff | ||
134 | + } | ||
135 | + if permission.CycleDeadline == nil { | ||
136 | + isChange = true | ||
137 | + permission.CycleDeadline = rs.defaultCycleDeadline() | ||
138 | + } | ||
139 | + if isChange { | ||
140 | + permission, err = permissionRepository.Insert(permission) | ||
141 | + if err != nil { | ||
142 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
143 | + } | ||
144 | + } | ||
78 | } | 145 | } |
79 | if err := transactionContext.CommitTransaction(); err != nil { | 146 | if err := transactionContext.CommitTransaction(); err != nil { |
80 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 147 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
81 | } | 148 | } |
82 | return permission, nil | 149 | return permission, nil |
83 | } | 150 | } |
151 | + | ||
152 | +// 创建默认周期截止时间 | ||
153 | +func (rs *PermissionService) defaultCycleDeadline() *domain.CycleDeadline { | ||
154 | + return &domain.CycleDeadline{ | ||
155 | + AssessmentSelf: domain.DeadlineTime{ | ||
156 | + Hour: 3 * 24, | ||
157 | + Minute: 0, | ||
158 | + }, | ||
159 | + AssessmentAll: domain.DeadlineTime{ | ||
160 | + Hour: 5 * 24, | ||
161 | + Minute: 0, | ||
162 | + }, | ||
163 | + AssessmentHr: domain.DeadlineTime{ | ||
164 | + Hour: 5 * 24, | ||
165 | + Minute: 0, | ||
166 | + }, | ||
167 | + AssessmentSuperior: domain.DeadlineTime{ | ||
168 | + Hour: 7 * 24, | ||
169 | + Minute: 0, | ||
170 | + }, | ||
171 | + ViewMyPerf: domain.DeadlineTime{ | ||
172 | + Hour: 9 * 24, | ||
173 | + Minute: 0, | ||
174 | + }, | ||
175 | + } | ||
176 | +} |
@@ -113,6 +113,9 @@ func (rs *RoleService) Remove(in *command.DeleteRoleCommand) (interface{}, error | @@ -113,6 +113,9 @@ func (rs *RoleService) Remove(in *command.DeleteRoleCommand) (interface{}, error | ||
113 | if role.Type == domain.RoleTypeSystem { | 113 | if role.Type == domain.RoleTypeSystem { |
114 | return nil, application.ThrowError(application.BUSINESS_ERROR, "系统预制角色不可删除") | 114 | return nil, application.ThrowError(application.BUSINESS_ERROR, "系统预制角色不可删除") |
115 | } | 115 | } |
116 | + if role.Type == domain.RoleTypeSuperAdmin { | ||
117 | + return nil, application.ThrowError(application.BUSINESS_ERROR, "超级管理员角色不可删除") | ||
118 | + } | ||
116 | 119 | ||
117 | if _, err := roleRepository.Remove(role); err != nil { | 120 | if _, err := roleRepository.Remove(role); err != nil { |
118 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 121 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
@@ -160,7 +163,7 @@ func (rs *RoleService) ListForUser(in *command.QueryRoleUserCommand) (interface{ | @@ -160,7 +163,7 @@ func (rs *RoleService) ListForUser(in *command.QueryRoleUserCommand) (interface{ | ||
160 | 163 | ||
161 | adapterList := make([]*adapter.RoleUserAdapter, 0) | 164 | adapterList := make([]*adapter.RoleUserAdapter, 0) |
162 | 165 | ||
163 | - // 如果不存在系统预支hrbp角色时,插入一条数据 | 166 | + // 如果不存在系统预支hr-bp角色时,新增数据 |
164 | var havaSystemType = false | 167 | var havaSystemType = false |
165 | for i := range roles { | 168 | for i := range roles { |
166 | if roles[i].Type == domain.RoleTypeSystem { | 169 | if roles[i].Type == domain.RoleTypeSystem { |
@@ -190,6 +193,10 @@ func (rs *RoleService) ListForUser(in *command.QueryRoleUserCommand) (interface{ | @@ -190,6 +193,10 @@ func (rs *RoleService) ListForUser(in *command.QueryRoleUserCommand) (interface{ | ||
190 | 193 | ||
191 | for i := range roles { | 194 | for i := range roles { |
192 | v := roles[i] | 195 | v := roles[i] |
196 | + | ||
197 | + if v.Type == domain.RoleTypeSuperAdmin { // 超级管理员角色不显示到界面上 | ||
198 | + continue | ||
199 | + } | ||
193 | _, tempList, err := ruRepository.FindAllContainUser(1, 10, in.CompanyId, v.Id) | 200 | _, tempList, err := ruRepository.FindAllContainUser(1, 10, in.CompanyId, v.Id) |
194 | if err != nil { | 201 | if err != nil { |
195 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 202 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
@@ -115,32 +115,68 @@ func (rs *RoleUserService) ListRole(in *command.UserRoleQueryCommand) (interface | @@ -115,32 +115,68 @@ func (rs *RoleUserService) ListRole(in *command.UserRoleQueryCommand) (interface | ||
115 | return tool_funs.SimpleWrapGridMap(total, tempList), nil | 115 | return tool_funs.SimpleWrapGridMap(total, tempList), nil |
116 | } | 116 | } |
117 | 117 | ||
118 | -// GetHRBP 当前操作人是否拥有HRBP权限 | ||
119 | -// 返回 1 是 表示具有hrbp 权限 | 118 | +// GetHrBp 当前操作人是否拥有HR-BP权限 (1表示有权限) |
119 | +func GetHrBp(transactionContext application.TransactionContext, companyId int, operatorId int) (int, error) { | ||
120 | + roleRepository := factory.CreateRoleRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
121 | + roleUserRepository := factory.CreateRoleUserRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
122 | + _, roles, err := roleRepository.Find(map[string]interface{}{"type": domain.RoleTypeSystem, "companyId": companyId}) | ||
123 | + if err != nil { | ||
124 | + return -1, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取角色信息列表"+err.Error()) | ||
125 | + } | ||
126 | + if len(roles) == 0 { | ||
127 | + return -1, nil | ||
128 | + } | ||
120 | 129 | ||
121 | -func GetHRBP(transactionContext application.TransactionContext, companyId int, operatorId int) (int, error) { | ||
122 | - roleRepo := factory.CreateRoleRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
123 | - roleUserRepo := factory.CreateRoleUserRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
124 | - _, roleList, err := roleRepo.Find(map[string]interface{}{"type": domain.RoleTypeSystem, "companyId": companyId}) | 130 | + _, userRoles, err := roleUserRepository.Find(map[string]interface{}{"companyId": companyId, "userId": operatorId}) |
131 | + if err != nil { | ||
132 | + return -1, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取用户的角色信息列表"+err.Error()) | ||
133 | + } | ||
134 | + if len(userRoles) == 0 { | ||
135 | + return -1, nil | ||
136 | + } | ||
137 | + | ||
138 | + hrBp := -1 | ||
139 | +loopFinish: | ||
140 | + for _, userRole := range userRoles { | ||
141 | + for _, role := range roles { | ||
142 | + if userRole.RoleId == role.Id { | ||
143 | + hrBp = domain.RoleTypeSystem | ||
144 | + break loopFinish | ||
145 | + } | ||
146 | + } | ||
147 | + } | ||
148 | + return hrBp, nil | ||
149 | +} | ||
150 | + | ||
151 | +// GetSuperAdmin 当前操作人是否拥有超级管理员权限 (2表示有权限) | ||
152 | +func GetSuperAdmin(transactionContext application.TransactionContext, companyId int, operatorId int) (int, error) { | ||
153 | + roleRepository := factory.CreateRoleRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
154 | + roleUserRepository := factory.CreateRoleUserRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
155 | + _, roles, err := roleRepository.Find(map[string]interface{}{"type": domain.RoleTypeSuperAdmin, "companyId": companyId}) | ||
125 | if err != nil { | 156 | if err != nil { |
126 | return -1, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取角色信息列表"+err.Error()) | 157 | return -1, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取角色信息列表"+err.Error()) |
127 | } | 158 | } |
128 | - _, userRoleList, err := roleUserRepo.Find(map[string]interface{}{"companyId": companyId, "userId": operatorId}) | 159 | + if len(roles) == 0 { |
160 | + return -1, nil | ||
161 | + } | ||
162 | + | ||
163 | + _, userRoles, err := roleUserRepository.Find(map[string]interface{}{"companyId": companyId, "userId": operatorId}) | ||
129 | if err != nil { | 164 | if err != nil { |
130 | return -1, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取用户的角色信息列表"+err.Error()) | 165 | return -1, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取用户的角色信息列表"+err.Error()) |
131 | } | 166 | } |
132 | - // 拥有HRBP权限 | ||
133 | - hrbp := -1 | ||
134 | - for _, v := range userRoleList { | ||
135 | - for _, v2 := range roleList { | ||
136 | - if v.RoleId == v2.Id { | ||
137 | - hrbp = 1 | ||
138 | - break | 167 | + if len(userRoles) == 0 { |
168 | + return -1, nil | ||
139 | } | 169 | } |
170 | + | ||
171 | + superAdmin := -1 | ||
172 | +loopFinish: | ||
173 | + for _, userRole := range userRoles { | ||
174 | + for _, role := range roles { | ||
175 | + if userRole.RoleId == role.Id { | ||
176 | + superAdmin = domain.RoleTypeSuperAdmin | ||
177 | + break loopFinish | ||
140 | } | 178 | } |
141 | - if hrbp == 1 { | ||
142 | - break | ||
143 | } | 179 | } |
144 | } | 180 | } |
145 | - return hrbp, nil | 181 | + return superAdmin, nil |
146 | } | 182 | } |
@@ -6,6 +6,8 @@ import ( | @@ -6,6 +6,8 @@ import ( | ||
6 | "strconv" | 6 | "strconv" |
7 | "time" | 7 | "time" |
8 | 8 | ||
9 | + service "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/role" | ||
10 | + | ||
9 | "github.com/linmadan/egglib-go/core/application" | 11 | "github.com/linmadan/egglib-go/core/application" |
10 | "github.com/linmadan/egglib-go/utils/tool_funs" | 12 | "github.com/linmadan/egglib-go/utils/tool_funs" |
11 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" | 13 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" |
@@ -29,28 +31,9 @@ func NewStaffAssessServeice() *StaffAssessServeice { | @@ -29,28 +31,9 @@ func NewStaffAssessServeice() *StaffAssessServeice { | ||
29 | 31 | ||
30 | // 获取HRBP标记值 | 32 | // 获取HRBP标记值 |
31 | func (srv StaffAssessServeice) getHRBP(transactionContext application.TransactionContext, companyId int, operatorId int) (int, error) { | 33 | func (srv StaffAssessServeice) getHRBP(transactionContext application.TransactionContext, companyId int, operatorId int) (int, error) { |
32 | - roleRepo := factory.CreateRoleRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
33 | - roleUserRepo := factory.CreateRoleUserRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
34 | - _, roleList, err := roleRepo.Find(map[string]interface{}{"type": domain.RoleTypeSystem, "companyId": companyId}) | ||
35 | - if err != nil { | ||
36 | - return -1, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取角色信息列表"+err.Error()) | ||
37 | - } | ||
38 | - _, userRoleList, err := roleUserRepo.Find(map[string]interface{}{"companyId": companyId, "userId": operatorId}) | 34 | + hrbp, err := service.GetHrBp(transactionContext, companyId, operatorId) |
39 | if err != nil { | 35 | if err != nil { |
40 | - return -1, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取用户的角色信息列表"+err.Error()) | ||
41 | - } | ||
42 | - // 拥有HRBP权限 | ||
43 | - hrbp := -1 | ||
44 | - for _, v := range userRoleList { | ||
45 | - for _, v2 := range roleList { | ||
46 | - if v.RoleId == v2.Id { | ||
47 | - hrbp = 1 | ||
48 | - break | ||
49 | - } | ||
50 | - } | ||
51 | - if hrbp == 1 { | ||
52 | - break | ||
53 | - } | 36 | + return -1, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
54 | } | 37 | } |
55 | return hrbp, nil | 38 | return hrbp, nil |
56 | } | 39 | } |
@@ -391,7 +374,7 @@ func (srv StaffAssessServeice) createStaffAssessSelf( | @@ -391,7 +374,7 @@ func (srv StaffAssessServeice) createStaffAssessSelf( | ||
391 | assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{ | 374 | assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{ |
392 | "transactionContext": transactionContext, | 375 | "transactionContext": transactionContext, |
393 | }) | 376 | }) |
394 | - beginDay := assessTemp.BeginTime.Format("2006-01-02") | 377 | + beginDay := assessTemp.BeginTime.Local().Format("2006-01-02") |
395 | _, assessListOld, err := assessRepo.Find(map[string]interface{}{"cycleId": assessTemp.CycleId, "beginDay": beginDay, "types": domain.AssessSelf}) | 378 | _, assessListOld, err := assessRepo.Find(map[string]interface{}{"cycleId": assessTemp.CycleId, "beginDay": beginDay, "types": domain.AssessSelf}) |
396 | if err != nil { | 379 | if err != nil { |
397 | return nil, err | 380 | return nil, err |
@@ -437,7 +420,7 @@ func (srv StaffAssessServeice) createStaffAssessSupper( | @@ -437,7 +420,7 @@ func (srv StaffAssessServeice) createStaffAssessSupper( | ||
437 | assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{ | 420 | assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{ |
438 | "transactionContext": transactionContext, | 421 | "transactionContext": transactionContext, |
439 | }) | 422 | }) |
440 | - beginDay := assessTemp.BeginTime.Format("2006-01-02") | 423 | + beginDay := assessTemp.BeginTime.Local().Format("2006-01-02") |
441 | _, assessListOld, err := assessRepo.Find(map[string]interface{}{"cycleId": assessTemp.CycleId, "beginDay": beginDay, "types": domain.AssessSuper}) | 424 | _, assessListOld, err := assessRepo.Find(map[string]interface{}{"cycleId": assessTemp.CycleId, "beginDay": beginDay, "types": domain.AssessSuper}) |
442 | if err != nil { | 425 | if err != nil { |
443 | return nil, err | 426 | return nil, err |
@@ -26,11 +26,11 @@ func (srv *SummaryEvaluationService) ExportAllEvaluationFinish(param *command.Qu | @@ -26,11 +26,11 @@ func (srv *SummaryEvaluationService) ExportAllEvaluationFinish(param *command.Qu | ||
26 | _ = transactionContext.RollbackTransaction() | 26 | _ = transactionContext.RollbackTransaction() |
27 | }() | 27 | }() |
28 | //判断是否是hrbp | 28 | //判断是否是hrbp |
29 | - flagHrbp, err := roleService.GetHRBP(transactionContext, param.CompanyId, param.UserId) | 29 | + flagHrbp, err := roleService.GetHrBp(transactionContext, param.CompanyId, param.UserId) |
30 | if err != nil { | 30 | if err != nil { |
31 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 31 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
32 | } | 32 | } |
33 | - if flagHrbp != 1 { | 33 | + if flagHrbp != domain.RoleTypeSystem { |
34 | return nil, application.ThrowError(application.BUSINESS_ERROR, "暂无数据") | 34 | return nil, application.ThrowError(application.BUSINESS_ERROR, "暂无数据") |
35 | } | 35 | } |
36 | //判断是否是上级 | 36 | //判断是否是上级 |
@@ -41,7 +41,7 @@ func (srv *SummaryEvaluationService) ExportAllEvaluationFinish(param *command.Qu | @@ -41,7 +41,7 @@ func (srv *SummaryEvaluationService) ExportAllEvaluationFinish(param *command.Qu | ||
41 | "parentId": param.UserId, | 41 | "parentId": param.UserId, |
42 | "limit": 1, | 42 | "limit": 1, |
43 | }) | 43 | }) |
44 | - if len(parentUser) == 0 && flagHrbp != 1 { | 44 | + if len(parentUser) == 0 && flagHrbp != domain.RoleTypeSystem { |
45 | return nil, application.ThrowError(application.BUSINESS_ERROR, "暂无数据") | 45 | return nil, application.ThrowError(application.BUSINESS_ERROR, "暂无数据") |
46 | } | 46 | } |
47 | evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{ | 47 | evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{ |
1 | package service | 1 | package service |
2 | 2 | ||
3 | -import ( | ||
4 | - "fmt" | ||
5 | - "strconv" | ||
6 | - "time" | ||
7 | - | ||
8 | - "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" | ||
9 | - "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/notify" | ||
10 | - "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
11 | - "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao" | ||
12 | - "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log" | ||
13 | -) | ||
14 | - | ||
15 | // sendSummaryEvaluafionTask 根据评估项目设置,确认是否下发评估任务 | 3 | // sendSummaryEvaluafionTask 根据评估项目设置,确认是否下发评估任务 |
16 | // project 需要处理的项目 | 4 | // project 需要处理的项目 |
17 | // userList 全体的员工数据 map[id]=>domain.User | 5 | // userList 全体的员工数据 map[id]=>domain.User |
18 | // departmetList 全部的部门数据 map[id]=>domain.Department | 6 | // departmetList 全部的部门数据 map[id]=>domain.Department |
19 | -func sendSummaryEvaluation(project *domain.EvaluationProject, | ||
20 | - userMap map[int64]*domain.User, departmentMap map[int64]*domain.Department) ([]domain.SummaryEvaluation, error) { | ||
21 | - //自评的时间范围 | ||
22 | - beginTimeSelf := project.EndTime | ||
23 | - endTimeSelf := dayZeroTime(project.EndTime).Add(4*24*time.Hour - time.Second) | ||
24 | - //人资、360评估的时间范围 | ||
25 | - beginTime360 := endTimeSelf | ||
26 | - endTime360 := endTimeSelf.Add(2 * 24 * time.Hour) | ||
27 | - //上级评估的是时间范围 | ||
28 | - beginTimeSuper := endTime360 | ||
29 | - endTimeSuper := endTime360.Add(2 * 24 * time.Hour) | ||
30 | - // | ||
31 | - transactionContext, err := factory.CreateTransactionContext(nil) | ||
32 | - if err != nil { | ||
33 | - return nil, err | ||
34 | - } | ||
35 | - if err := transactionContext.StartTransaction(); err != nil { | ||
36 | - return nil, err | ||
37 | - } | ||
38 | - defer func() { | ||
39 | - _ = transactionContext.RollbackTransaction() | ||
40 | - }() | ||
41 | - cycleRepo := factory.CreateEvaluationCycleRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
42 | - | ||
43 | - evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext}) | 7 | +// func sendSummaryEvaluation(project *domain.EvaluationProject, |
8 | +// userMap map[int64]*domain.User, departmentMap map[int64]*domain.Department) ([]domain.SummaryEvaluation, error) { | ||
9 | +// //自评的时间范围 | ||
10 | +// beginTimeSelf := project.EndTime | ||
11 | +// endTimeSelf := dayZeroTime(project.EndTime).Add(4*24*time.Hour - time.Second) | ||
12 | +// //人资、360评估的时间范围 | ||
13 | +// beginTime360 := endTimeSelf | ||
14 | +// endTime360 := endTimeSelf.Add(2 * 24 * time.Hour) | ||
15 | +// //上级评估的是时间范围 | ||
16 | +// beginTimeSuper := endTime360 | ||
17 | +// endTimeSuper := endTime360.Add(2 * 24 * time.Hour) | ||
18 | +// // | ||
19 | +// transactionContext, err := factory.CreateTransactionContext(nil) | ||
20 | +// if err != nil { | ||
21 | +// return nil, err | ||
22 | +// } | ||
23 | +// if err := transactionContext.StartTransaction(); err != nil { | ||
24 | +// return nil, err | ||
25 | +// } | ||
26 | +// defer func() { | ||
27 | +// _ = transactionContext.RollbackTransaction() | ||
28 | +// }() | ||
29 | +// cycleRepo := factory.CreateEvaluationCycleRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
44 | 30 | ||
45 | - cycleData, err := cycleRepo.FindOne(map[string]interface{}{"id": project.CycleId}) | ||
46 | - if err != nil { | ||
47 | - return nil, err | ||
48 | - } | ||
49 | - //确定 被评估的人 | ||
50 | - targetUserId := []int64{} | ||
51 | - for _, v := range project.Recipients { | ||
52 | - id, err := strconv.ParseInt(v, 10, 64) | ||
53 | - if err == nil { | ||
54 | - targetUserId = append(targetUserId, id) | ||
55 | - } | ||
56 | - } | ||
57 | - if len(targetUserId) == 0 { | ||
58 | - return nil, nil | ||
59 | - } | ||
60 | - //被评估的员工 | ||
61 | - targetUserMap := map[int64]*domain.User{} | 31 | +// evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext}) |
62 | 32 | ||
63 | - for _, v := range targetUserId { | ||
64 | - u, ok := userMap[v] | ||
65 | - if ok { | ||
66 | - targetUserMap[v] = u | ||
67 | - } | ||
68 | - } | ||
69 | - //确定360评估的执行人 | ||
70 | - _, itemList, err := evaluationItemRepo.Find(map[string]interface{}{"evaluationProjectId": project.Id, "nodeType": int(domain.LinkNodeSelfAssessment)}) | ||
71 | - if err != nil { | ||
72 | - return nil, err | ||
73 | - } | ||
74 | - nodeId := 0 | ||
75 | - executor360Map := map[int64]*domain.User{} | ||
76 | - hrbpExist := false | ||
77 | - for _, v := range itemList { | ||
78 | - nodeId = v.NodeId | ||
79 | - if v.EvaluatorId < 0 { | ||
80 | - hrbpExist = true | ||
81 | - } | ||
82 | - if v.EvaluatorId <= 0 { | ||
83 | - continue | ||
84 | - } | ||
85 | - if u, ok := userMap[int64(v.EvaluatorId)]; ok { | ||
86 | - executor360Map[u.Id] = u | ||
87 | - } | ||
88 | - } | ||
89 | - //创建周期评估任务 | ||
90 | - var newEvaluationList []domain.SummaryEvaluation | ||
91 | - evaluationTemp := domain.SummaryEvaluation{ | ||
92 | - Id: 0, | ||
93 | - CompanyId: int(project.CompanyId), | ||
94 | - EvaluationProjectId: int(project.Id), | ||
95 | - EvaluationProjectName: project.Name, | ||
96 | - CycleId: cycleData.Id, | ||
97 | - CycleName: cycleData.Name, | ||
98 | - NodeId: nodeId, | ||
99 | - TargetUser: domain.StaffDesc{}, | ||
100 | - TargetDepartment: []domain.StaffDepartment{}, | ||
101 | - Executor: domain.StaffDesc{}, | ||
102 | - Types: 0, | ||
103 | - Status: domain.EvaluationUncompleted, | ||
104 | - CheckResult: domain.EvaluationCheckUncompleted, | ||
105 | - BeginTime: time.Time{}, | ||
106 | - EndTime: time.Time{}, | ||
107 | - TotalScore: "", | ||
108 | - CreatedAt: time.Now(), | ||
109 | - UpdatedAt: time.Now(), | ||
110 | - DeletedAt: nil, | ||
111 | - } | 33 | +// cycleData, err := cycleRepo.FindOne(map[string]interface{}{"id": project.CycleId}) |
34 | +// if err != nil { | ||
35 | +// return nil, err | ||
36 | +// } | ||
37 | +// //确定 被评估的人 | ||
38 | +// targetUserId := []int64{} | ||
39 | +// for _, v := range project.Recipients { | ||
40 | +// id, err := strconv.ParseInt(v, 10, 64) | ||
41 | +// if err == nil { | ||
42 | +// targetUserId = append(targetUserId, id) | ||
43 | +// } | ||
44 | +// } | ||
45 | +// if len(targetUserId) == 0 { | ||
46 | +// return nil, nil | ||
47 | +// } | ||
48 | +// //被评估的员工 | ||
49 | +// targetUserMap := map[int64]*domain.User{} | ||
112 | 50 | ||
113 | - //确定周期评估 | 51 | +// for _, v := range targetUserId { |
52 | +// u, ok := userMap[v] | ||
53 | +// if ok { | ||
54 | +// targetUserMap[v] = u | ||
55 | +// } | ||
56 | +// } | ||
57 | +// //确定360评估的执行人 | ||
58 | +// _, itemList, err := evaluationItemRepo.Find(map[string]interface{}{"evaluationProjectId": project.Id, "nodeType": int(domain.LinkNodeSelfAssessment)}) | ||
59 | +// if err != nil { | ||
60 | +// return nil, err | ||
61 | +// } | ||
62 | +// nodeId := 0 | ||
63 | +// executor360Map := map[int64]*domain.User{} | ||
64 | +// hrbpExist := false | ||
65 | +// for _, v := range itemList { | ||
66 | +// nodeId = v.NodeId | ||
67 | +// if v.EvaluatorId < 0 { | ||
68 | +// hrbpExist = true | ||
69 | +// } | ||
70 | +// if v.EvaluatorId <= 0 { | ||
71 | +// continue | ||
72 | +// } | ||
73 | +// if u, ok := userMap[int64(v.EvaluatorId)]; ok { | ||
74 | +// executor360Map[u.Id] = u | ||
75 | +// } | ||
76 | +// } | ||
77 | +// //创建周期评估任务 | ||
78 | +// var newEvaluationList []domain.SummaryEvaluation | ||
79 | +// evaluationTemp := domain.SummaryEvaluation{ | ||
80 | +// Id: 0, | ||
81 | +// CompanyId: int(project.CompanyId), | ||
82 | +// EvaluationProjectId: int(project.Id), | ||
83 | +// EvaluationProjectName: project.Name, | ||
84 | +// CycleId: cycleData.Id, | ||
85 | +// CycleName: cycleData.Name, | ||
86 | +// NodeId: nodeId, | ||
87 | +// TargetUser: domain.StaffDesc{}, | ||
88 | +// TargetDepartment: []domain.StaffDepartment{}, | ||
89 | +// Executor: domain.StaffDesc{}, | ||
90 | +// Types: 0, | ||
91 | +// Status: domain.EvaluationUncompleted, | ||
92 | +// CheckResult: domain.EvaluationCheckUncompleted, | ||
93 | +// BeginTime: time.Time{}, | ||
94 | +// EndTime: time.Time{}, | ||
95 | +// TotalScore: "", | ||
96 | +// CreatedAt: time.Now(), | ||
97 | +// UpdatedAt: time.Now(), | ||
98 | +// DeletedAt: nil, | ||
99 | +// } | ||
114 | 100 | ||
115 | - for _, v := range targetUserMap { | ||
116 | - //处理自评 | ||
117 | - evaluationTemp.TargetUser = domain.StaffDesc{ | ||
118 | - UserId: int(v.Id), | ||
119 | - Account: v.Account, | ||
120 | - UserName: v.Name, | ||
121 | - } | ||
122 | - evaluationTemp.Executor = domain.StaffDesc{ | ||
123 | - UserId: int(v.Id), | ||
124 | - Account: v.Account, | ||
125 | - UserName: v.Name, | ||
126 | - } | ||
127 | - evaluationTemp.BeginTime = beginTimeSelf | ||
128 | - evaluationTemp.EndTime = endTimeSelf | ||
129 | - evaluationTemp.TargetDepartment = []domain.StaffDepartment{} | ||
130 | - evaluationTemp.Types = domain.EvaluationSelf | ||
131 | - for _, departId := range v.DepartmentId { | ||
132 | - depart, ok := departmentMap[int64(departId)] | ||
133 | - if !ok { | ||
134 | - continue | ||
135 | - } | ||
136 | - evaluationTemp.TargetDepartment = append(evaluationTemp.TargetDepartment, domain.StaffDepartment{ | ||
137 | - DepartmentId: int(depart.Id), | ||
138 | - DepartmentName: depart.Name, | ||
139 | - }) | ||
140 | - } | ||
141 | - newEvaluationList = append(newEvaluationList, evaluationTemp) | ||
142 | - if hrbpExist { | ||
143 | - //处理人资评估 | ||
144 | - evaluationTemp.BeginTime = beginTime360 | ||
145 | - evaluationTemp.EndTime = endTime360 | ||
146 | - evaluationTemp.Executor = domain.StaffDesc{} | ||
147 | - evaluationTemp.Types = domain.EvaluationHrbp | ||
148 | - newEvaluationList = append(newEvaluationList, evaluationTemp) | ||
149 | - } | ||
150 | - //处理360 评估 | ||
151 | - for _, v2 := range executor360Map { | ||
152 | - evaluationTemp.BeginTime = beginTime360 | ||
153 | - evaluationTemp.EndTime = endTime360 | ||
154 | - evaluationTemp.Executor = domain.StaffDesc{ | ||
155 | - UserId: int(v2.Id), | ||
156 | - Account: v2.Account, | ||
157 | - UserName: v2.Name, | ||
158 | - } | ||
159 | - evaluationTemp.Types = domain.Evaluation360 | ||
160 | - newEvaluationList = append(newEvaluationList, evaluationTemp) | ||
161 | - } | 101 | +// //确定周期评估 |
162 | 102 | ||
163 | - //处理上级评估 | ||
164 | - superUser, ok := userMap[v.ParentId] | ||
165 | - if ok { | ||
166 | - evaluationTemp.Types = domain.EvaluationSuper | ||
167 | - evaluationTemp.Executor = domain.StaffDesc{ | ||
168 | - UserId: int(superUser.Id), | ||
169 | - Account: superUser.Account, | ||
170 | - UserName: superUser.Name, | ||
171 | - } | ||
172 | - evaluationTemp.BeginTime = beginTimeSuper | ||
173 | - evaluationTemp.EndTime = endTimeSuper | ||
174 | - //确定上级评估 | ||
175 | - newEvaluationList = append(newEvaluationList, evaluationTemp) | ||
176 | - } | ||
177 | - // 确定 考核结果 的评估记录 | ||
178 | - evaluationTemp.Types = domain.EvaluationFinish | ||
179 | - evaluationTemp.Executor = domain.StaffDesc{} | ||
180 | - evaluationTemp.BeginTime = endTimeSuper | ||
181 | - evaluationTemp.EndTime = endTimeSuper.Add(2 * 24 * time.Hour) | ||
182 | - newEvaluationList = append(newEvaluationList, evaluationTemp) | ||
183 | - } | ||
184 | - summaryEvaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
185 | - for i := range newEvaluationList { | ||
186 | - err = summaryEvaluationRepo.Save(&newEvaluationList[i]) | ||
187 | - if err != nil { | ||
188 | - return nil, err | ||
189 | - } | ||
190 | - } | ||
191 | - //回填 项目的状态 | ||
192 | - projectDao := dao.NewEvaluationProjectDao(map[string]interface{}{"transactionContext": transactionContext}) | ||
193 | - err = projectDao.UpdateSummaryState(project.Id, domain.ProjectSummaryStateYes) | ||
194 | - if err != nil { | ||
195 | - return nil, err | ||
196 | - } | ||
197 | - if err := transactionContext.CommitTransaction(); err != nil { | ||
198 | - return nil, err | ||
199 | - } | ||
200 | - return newEvaluationList, nil | ||
201 | -} | 103 | +// for _, v := range targetUserMap { |
104 | +// //处理自评 | ||
105 | +// evaluationTemp.TargetUser = domain.StaffDesc{ | ||
106 | +// UserId: int(v.Id), | ||
107 | +// Account: v.Account, | ||
108 | +// UserName: v.Name, | ||
109 | +// } | ||
110 | +// evaluationTemp.Executor = domain.StaffDesc{ | ||
111 | +// UserId: int(v.Id), | ||
112 | +// Account: v.Account, | ||
113 | +// UserName: v.Name, | ||
114 | +// } | ||
115 | +// evaluationTemp.BeginTime = beginTimeSelf | ||
116 | +// evaluationTemp.EndTime = endTimeSelf | ||
117 | +// evaluationTemp.TargetDepartment = []domain.StaffDepartment{} | ||
118 | +// evaluationTemp.Types = domain.EvaluationSelf | ||
119 | +// for _, departId := range v.DepartmentId { | ||
120 | +// depart, ok := departmentMap[int64(departId)] | ||
121 | +// if !ok { | ||
122 | +// continue | ||
123 | +// } | ||
124 | +// evaluationTemp.TargetDepartment = append(evaluationTemp.TargetDepartment, domain.StaffDepartment{ | ||
125 | +// DepartmentId: int(depart.Id), | ||
126 | +// DepartmentName: depart.Name, | ||
127 | +// }) | ||
128 | +// } | ||
129 | +// newEvaluationList = append(newEvaluationList, evaluationTemp) | ||
130 | +// if hrbpExist { | ||
131 | +// //处理人资评估 | ||
132 | +// evaluationTemp.BeginTime = beginTime360 | ||
133 | +// evaluationTemp.EndTime = endTime360 | ||
134 | +// evaluationTemp.Executor = domain.StaffDesc{} | ||
135 | +// evaluationTemp.Types = domain.EvaluationHrbp | ||
136 | +// newEvaluationList = append(newEvaluationList, evaluationTemp) | ||
137 | +// } | ||
138 | +// //处理360 评估 | ||
139 | +// for _, v2 := range executor360Map { | ||
140 | +// evaluationTemp.BeginTime = beginTime360 | ||
141 | +// evaluationTemp.EndTime = endTime360 | ||
142 | +// evaluationTemp.Executor = domain.StaffDesc{ | ||
143 | +// UserId: int(v2.Id), | ||
144 | +// Account: v2.Account, | ||
145 | +// UserName: v2.Name, | ||
146 | +// } | ||
147 | +// evaluationTemp.Types = domain.Evaluation360 | ||
148 | +// newEvaluationList = append(newEvaluationList, evaluationTemp) | ||
149 | +// } | ||
202 | 150 | ||
203 | -func dayZeroTime(t time.Time) time.Time { | ||
204 | - y, m, d := t.Local().Date() | ||
205 | - t2 := time.Date(y, m, d, 0, 0, 0, 0, time.Local) | ||
206 | - return t2 | ||
207 | -} | 151 | +// //处理上级评估 |
152 | +// superUser, ok := userMap[v.ParentId] | ||
153 | +// if ok { | ||
154 | +// evaluationTemp.Types = domain.EvaluationSuper | ||
155 | +// evaluationTemp.Executor = domain.StaffDesc{ | ||
156 | +// UserId: int(superUser.Id), | ||
157 | +// Account: superUser.Account, | ||
158 | +// UserName: superUser.Name, | ||
159 | +// } | ||
160 | +// evaluationTemp.BeginTime = beginTimeSuper | ||
161 | +// evaluationTemp.EndTime = endTimeSuper | ||
162 | +// //确定上级评估 | ||
163 | +// newEvaluationList = append(newEvaluationList, evaluationTemp) | ||
164 | +// } | ||
165 | +// // 确定 考核结果 的评估记录 | ||
166 | +// evaluationTemp.Types = domain.EvaluationFinish | ||
167 | +// evaluationTemp.Executor = domain.StaffDesc{} | ||
168 | +// evaluationTemp.BeginTime = endTimeSuper | ||
169 | +// evaluationTemp.EndTime = endTimeSuper.Add(2 * 24 * time.Hour) | ||
170 | +// newEvaluationList = append(newEvaluationList, evaluationTemp) | ||
171 | +// } | ||
172 | +// summaryEvaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
173 | +// for i := range newEvaluationList { | ||
174 | +// err = summaryEvaluationRepo.Save(&newEvaluationList[i]) | ||
175 | +// if err != nil { | ||
176 | +// return nil, err | ||
177 | +// } | ||
178 | +// } | ||
179 | +// //回填 项目的状态 | ||
180 | +// projectDao := dao.NewEvaluationProjectDao(map[string]interface{}{"transactionContext": transactionContext}) | ||
181 | +// err = projectDao.UpdateSummaryState(project.Id, domain.ProjectSummaryStateYes) | ||
182 | +// if err != nil { | ||
183 | +// return nil, err | ||
184 | +// } | ||
185 | +// if err := transactionContext.CommitTransaction(); err != nil { | ||
186 | +// return nil, err | ||
187 | +// } | ||
188 | +// return newEvaluationList, nil | ||
189 | +// } | ||
208 | 190 | ||
209 | -// 下发周期评估 | ||
210 | -func TaskSendSummaryEvaluation() error { | ||
211 | - nowTime := time.Now() | ||
212 | - defer func() { | ||
213 | - str := fmt.Sprintf("下发周期评估耗时%.2f s", time.Since(nowTime).Seconds()) | ||
214 | - log.Logger.Info(str) | ||
215 | - }() | ||
216 | - transactionContext, err := factory.CreateTransactionContext(nil) | ||
217 | - if err != nil { | ||
218 | - return err | ||
219 | - } | ||
220 | - if err := transactionContext.StartTransaction(); err != nil { | ||
221 | - return err | ||
222 | - } | ||
223 | - defer func() { | ||
224 | - _ = transactionContext.RollbackTransaction() | ||
225 | - }() | 191 | +// func dayZeroTime(t time.Time) time.Time { |
192 | +// y, m, d := t.Local().Date() | ||
193 | +// t2 := time.Date(y, m, d, 0, 0, 0, 0, time.Local) | ||
194 | +// return t2 | ||
195 | +// } | ||
226 | 196 | ||
227 | - projectRepo := factory.CreateEvaluationProjectRepository(map[string]interface{}{ | ||
228 | - "transactionContext": transactionContext, | ||
229 | - }) | 197 | +// // 下发周期评估 |
198 | +// func TaskSendSummaryEvaluation() error { | ||
199 | +// nowTime := time.Now() | ||
200 | +// defer func() { | ||
201 | +// str := fmt.Sprintf("下发周期评估耗时%.2f s", time.Since(nowTime).Seconds()) | ||
202 | +// log.Logger.Info(str) | ||
203 | +// }() | ||
204 | +// transactionContext, err := factory.CreateTransactionContext(nil) | ||
205 | +// if err != nil { | ||
206 | +// return err | ||
207 | +// } | ||
208 | +// if err := transactionContext.StartTransaction(); err != nil { | ||
209 | +// return err | ||
210 | +// } | ||
211 | +// defer func() { | ||
212 | +// _ = transactionContext.RollbackTransaction() | ||
213 | +// }() | ||
230 | 214 | ||
231 | - userRepo := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext}) | 215 | +// projectRepo := factory.CreateEvaluationProjectRepository(map[string]interface{}{ |
216 | +// "transactionContext": transactionContext, | ||
217 | +// }) | ||
232 | 218 | ||
233 | - departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{"transactionContext": transactionContext}) | 219 | +// userRepo := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext}) |
234 | 220 | ||
235 | - _, projectList, err := projectRepo.Find(map[string]interface{}{ | ||
236 | - "endTime": time.Now(), | ||
237 | - "summaryState": domain.ProjectSummaryStateNo, | ||
238 | - "state": domain.ProjectStateEnable, | ||
239 | - }, "template") | ||
240 | - if err != nil { | ||
241 | - return fmt.Errorf("获取可用的项目数据,%s", err) | ||
242 | - } | ||
243 | - companyIdMap := map[int64]struct{}{} | ||
244 | - for _, v := range projectList { | ||
245 | - companyIdMap[v.CompanyId] = struct{}{} | ||
246 | - } | 221 | +// departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{"transactionContext": transactionContext}) |
247 | 222 | ||
248 | - var createdEvalationList []domain.SummaryEvaluation | 223 | +// _, projectList, err := projectRepo.Find(map[string]interface{}{ |
224 | +// "endTime": time.Now(), | ||
225 | +// "summaryState": domain.ProjectSummaryStateNo, | ||
226 | +// "state": domain.ProjectStateEnable, | ||
227 | +// }, "template") | ||
228 | +// if err != nil { | ||
229 | +// return fmt.Errorf("获取可用的项目数据,%s", err) | ||
230 | +// } | ||
231 | +// companyIdMap := map[int64]struct{}{} | ||
232 | +// for _, v := range projectList { | ||
233 | +// companyIdMap[v.CompanyId] = struct{}{} | ||
234 | +// } | ||
249 | 235 | ||
250 | - //获取可执行的项目 | ||
251 | - for companyId := range companyIdMap { | ||
252 | - //获取员工数据,部门数据 | ||
253 | - _, userList, err := userRepo.Find(map[string]interface{}{"companyId": companyId}) | ||
254 | - if err != nil { | ||
255 | - log.Logger.Error("TaskSendSummaryEvaluation 获取员工数据:" + err.Error()) | ||
256 | - continue | ||
257 | - } | ||
258 | - _, departmentList, err := departmentRepo.Find(map[string]interface{}{"companyId": companyId}) | ||
259 | - if err != nil { | ||
260 | - log.Logger.Error("TaskSendSummaryEvaluation 获取部门数据:" + err.Error()) | ||
261 | - continue | ||
262 | - } | ||
263 | - //转map | ||
264 | - userMap := map[int64]*domain.User{} | ||
265 | - for _, v := range userList { | ||
266 | - userMap[v.Id] = v | ||
267 | - } | ||
268 | - departmentMap := map[int64]*domain.Department{} | ||
269 | - for _, v := range departmentList { | ||
270 | - departmentMap[v.Id] = v | ||
271 | - } | ||
272 | - for _, v := range projectList { | ||
273 | - if v.CompanyId != companyId { | ||
274 | - continue | ||
275 | - } | ||
276 | - evalationList, err := sendSummaryEvaluation(v, userMap, departmentMap) | ||
277 | - if err != nil { | ||
278 | - log.Logger.Error("TaskSendSummaryEvaluation 下发评估任务:" + err.Error()) | ||
279 | - continue | ||
280 | - } | ||
281 | - createdEvalationList = append(createdEvalationList, evalationList...) | ||
282 | - } | ||
283 | - } | ||
284 | - if err := transactionContext.CommitTransaction(); err != nil { | ||
285 | - return err | ||
286 | - } | ||
287 | - //添加待发送的短信通知 | ||
288 | - err = sendSmsEvalation(createdEvalationList) | ||
289 | - return err | ||
290 | -} | 236 | +// var createdEvalationList []domain.SummaryEvaluation |
291 | 237 | ||
292 | -// 添加待发送的短信通知 | ||
293 | -func sendSmsEvalation(param []domain.SummaryEvaluation) error { | ||
294 | - for i := range param { | ||
295 | - if param[i].Types == domain.EvaluationSelf { | ||
296 | - notify.AddNotifySummaryEvaluation(¶m[i]) | ||
297 | - } | ||
298 | - } | ||
299 | - return nil | ||
300 | -} | 238 | +// //获取可执行的项目 |
239 | +// for companyId := range companyIdMap { | ||
240 | +// //获取员工数据,部门数据 | ||
241 | +// _, userList, err := userRepo.Find(map[string]interface{}{"companyId": companyId}) | ||
242 | +// if err != nil { | ||
243 | +// log.Logger.Error("TaskSendSummaryEvaluation 获取员工数据:" + err.Error()) | ||
244 | +// continue | ||
245 | +// } | ||
246 | +// _, departmentList, err := departmentRepo.Find(map[string]interface{}{"companyId": companyId}) | ||
247 | +// if err != nil { | ||
248 | +// log.Logger.Error("TaskSendSummaryEvaluation 获取部门数据:" + err.Error()) | ||
249 | +// continue | ||
250 | +// } | ||
251 | +// //转map | ||
252 | +// userMap := map[int64]*domain.User{} | ||
253 | +// for _, v := range userList { | ||
254 | +// userMap[v.Id] = v | ||
255 | +// } | ||
256 | +// departmentMap := map[int64]*domain.Department{} | ||
257 | +// for _, v := range departmentList { | ||
258 | +// departmentMap[v.Id] = v | ||
259 | +// } | ||
260 | +// for _, v := range projectList { | ||
261 | +// if v.CompanyId != companyId { | ||
262 | +// continue | ||
263 | +// } | ||
264 | +// evalationList, err := sendSummaryEvaluation(v, userMap, departmentMap) | ||
265 | +// if err != nil { | ||
266 | +// log.Logger.Error("TaskSendSummaryEvaluation 下发评估任务:" + err.Error()) | ||
267 | +// continue | ||
268 | +// } | ||
269 | +// createdEvalationList = append(createdEvalationList, evalationList...) | ||
270 | +// } | ||
271 | +// } | ||
272 | +// if err := transactionContext.CommitTransaction(); err != nil { | ||
273 | +// return err | ||
274 | +// } | ||
275 | +// //添加待发送的短信通知 | ||
276 | +// err = sendSmsEvalation(createdEvalationList) | ||
277 | +// return err | ||
278 | +// } |
1 | +package service | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "strconv" | ||
6 | + "time" | ||
7 | + | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/command" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
11 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao" | ||
12 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log" | ||
13 | +) | ||
14 | + | ||
15 | +// 定时自动确认周期评估考核结果 | ||
16 | +func TaskConfirmScore() error { | ||
17 | + nowTime := time.Now() | ||
18 | + defer func() { | ||
19 | + str := fmt.Sprintf("自动确认周期评估考核结果耗时%.2f s", time.Since(nowTime).Seconds()) | ||
20 | + log.Logger.Info(str) | ||
21 | + }() | ||
22 | + | ||
23 | + evaluationList, err := catchEvaluation() | ||
24 | + if err != nil { | ||
25 | + log.Logger.Error(fmt.Sprintf("获取周期考核结果%s", err.Error())) | ||
26 | + } | ||
27 | + if len(evaluationList) == 0 { | ||
28 | + return nil | ||
29 | + } | ||
30 | + evluationSrv := NewSummaryEvaluationService() | ||
31 | + for _, val := range evaluationList { | ||
32 | + permissionData, err := getPermission(val.CompanyId) | ||
33 | + if err != nil { | ||
34 | + log.Logger.Error(fmt.Sprintf("获取公司的权限配置失败%s", err.Error())) | ||
35 | + } | ||
36 | + if permissionData.OptConfirmPerf != domain.PermissionOn { | ||
37 | + continue | ||
38 | + } | ||
39 | + | ||
40 | + targetUserId, err := strconv.Atoi(val.TargetUserId) | ||
41 | + if err != nil { | ||
42 | + log.Logger.Error(fmt.Sprintf("获取员工id%s", err)) | ||
43 | + continue | ||
44 | + } | ||
45 | + err = evluationSrv.ConfirmScoreEvaluation(&command.ConfirmScore{ | ||
46 | + SummaryEvaluationId: val.SummaryEvaluationId, | ||
47 | + UserId: targetUserId, | ||
48 | + }) | ||
49 | + if err != nil { | ||
50 | + log.Logger.Error(fmt.Sprintf("确认周期考核结果%s", err.Error())) | ||
51 | + } | ||
52 | + } | ||
53 | + return nil | ||
54 | +} | ||
55 | + | ||
56 | +func catchEvaluation() ([]dao.SummaryEvaluationData1, error) { | ||
57 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
58 | + if err != nil { | ||
59 | + return nil, err | ||
60 | + } | ||
61 | + if err := transactionContext.StartTransaction(); err != nil { | ||
62 | + return nil, err | ||
63 | + } | ||
64 | + defer func() { | ||
65 | + _ = transactionContext.RollbackTransaction() | ||
66 | + }() | ||
67 | + evaluationDao := dao.NewSummaryEvaluationDao(map[string]interface{}{ | ||
68 | + "transactionContext": transactionContext, | ||
69 | + }) | ||
70 | + evaluationList, err := evaluationDao.ListEvaluationFinishNoResult() | ||
71 | + if err != nil { | ||
72 | + return nil, fmt.Errorf("获取综合评估数据%s", err) | ||
73 | + } | ||
74 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
75 | + return nil, err | ||
76 | + } | ||
77 | + return evaluationList, nil | ||
78 | +} |
@@ -7,6 +7,7 @@ import ( | @@ -7,6 +7,7 @@ import ( | ||
7 | 7 | ||
8 | "github.com/linmadan/egglib-go/core/application" | 8 | "github.com/linmadan/egglib-go/core/application" |
9 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" | 9 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" |
10 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/notify" | ||
10 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | 11 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" |
11 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao" | 12 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao" |
12 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log" | 13 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log" |
@@ -35,6 +36,12 @@ func TaskSendSummaryEvaluationV2() error { | @@ -35,6 +36,12 @@ func TaskSendSummaryEvaluationV2() error { | ||
35 | return nil | 36 | return nil |
36 | } | 37 | } |
37 | 38 | ||
39 | +func dayEndTime(t time.Time) time.Time { | ||
40 | + y, m, d := t.Local().Date() | ||
41 | + t2 := time.Date(y, m, d, 23, 59, 59, 0, time.Local) | ||
42 | + return t2 | ||
43 | +} | ||
44 | + | ||
38 | // 获取周期 | 45 | // 获取周期 |
39 | func getPrepareEvaluationCycle() ([]*domain.EvaluationCycle, error) { | 46 | func getPrepareEvaluationCycle() ([]*domain.EvaluationCycle, error) { |
40 | transactionContext, err := factory.CreateTransactionContext(nil) | 47 | transactionContext, err := factory.CreateTransactionContext(nil) |
@@ -58,37 +65,6 @@ func getPrepareEvaluationCycle() ([]*domain.EvaluationCycle, error) { | @@ -58,37 +65,6 @@ func getPrepareEvaluationCycle() ([]*domain.EvaluationCycle, error) { | ||
58 | return cycleList, nil | 65 | return cycleList, nil |
59 | } | 66 | } |
60 | 67 | ||
61 | -// 获取可用的项目 | ||
62 | -// func getPrepareSummaryEvaluation(cycleId int) ([]*domain.EvaluationProject, error) { | ||
63 | -// transactionContext, err := factory.CreateTransactionContext(nil) | ||
64 | -// if err != nil { | ||
65 | -// return nil, err | ||
66 | -// } | ||
67 | -// if err := transactionContext.StartTransaction(); err != nil { | ||
68 | -// return nil, err | ||
69 | -// } | ||
70 | -// defer func() { | ||
71 | -// _ = transactionContext.RollbackTransaction() | ||
72 | -// }() | ||
73 | -// projectRepo := factory.CreateEvaluationProjectRepository(map[string]interface{}{ | ||
74 | -// "transactionContext": transactionContext, | ||
75 | -// }) | ||
76 | -// // 获取项目数据总数 | ||
77 | -// _, projectList, err := projectRepo.Find(map[string]interface{}{ | ||
78 | -// "cycleId": cycleId, | ||
79 | -// "summaryState": domain.ProjectSummaryStateNo, | ||
80 | -// "state": domain.ProjectStateEnable, | ||
81 | -// "limit": 200, | ||
82 | -// }, "template") | ||
83 | -// if err != nil { | ||
84 | -// return nil, fmt.Errorf("获取可用的项目数据,%s", err) | ||
85 | -// } | ||
86 | -// if err := transactionContext.CommitTransaction(); err != nil { | ||
87 | -// return nil, err | ||
88 | -// } | ||
89 | -// return projectList, nil | ||
90 | -// } | ||
91 | - | ||
92 | // 按周期下发 综合评估任务 | 68 | // 按周期下发 综合评估任务 |
93 | func sendSummaryEvaluationByCycle(cycleParam *domain.EvaluationCycle) error { | 69 | func sendSummaryEvaluationByCycle(cycleParam *domain.EvaluationCycle) error { |
94 | transactionContext, err := factory.CreateTransactionContext(nil) | 70 | transactionContext, err := factory.CreateTransactionContext(nil) |
@@ -115,10 +91,14 @@ func sendSummaryEvaluationByCycle(cycleParam *domain.EvaluationCycle) error { | @@ -115,10 +91,14 @@ func sendSummaryEvaluationByCycle(cycleParam *domain.EvaluationCycle) error { | ||
115 | if err != nil { | 91 | if err != nil { |
116 | return fmt.Errorf("获取可用的项目数据,%s", err) | 92 | return fmt.Errorf("获取可用的项目数据,%s", err) |
117 | } | 93 | } |
94 | + permissionData, err := getPermission(cycleParam.CompanyId) | ||
95 | + if err != nil { | ||
96 | + return fmt.Errorf("获取公司的周期评估设置项,%s", err) | ||
97 | + } | ||
118 | var newEvaluationList []domain.SummaryEvaluation | 98 | var newEvaluationList []domain.SummaryEvaluation |
119 | newPublisher := summaryEvaluationPublisher{} | 99 | newPublisher := summaryEvaluationPublisher{} |
120 | for _, val := range projectList { | 100 | for _, val := range projectList { |
121 | - evaluationList, err := newPublisher.sendSummaryEvaluationV2(transactionContext, val, cycleParam) | 101 | + evaluationList, err := newPublisher.sendSummaryEvaluationV2(transactionContext, val, cycleParam, *permissionData) |
122 | if err != nil { | 102 | if err != nil { |
123 | return fmt.Errorf("按项目下发综合评估任务数据,%s", err) | 103 | return fmt.Errorf("按项目下发综合评估任务数据,%s", err) |
124 | } | 104 | } |
@@ -140,6 +120,16 @@ func sendSummaryEvaluationByCycle(cycleParam *domain.EvaluationCycle) error { | @@ -140,6 +120,16 @@ func sendSummaryEvaluationByCycle(cycleParam *domain.EvaluationCycle) error { | ||
140 | return nil | 120 | return nil |
141 | } | 121 | } |
142 | 122 | ||
123 | +// // 添加待发送的短信通知 | ||
124 | +func sendSmsEvalation(param []domain.SummaryEvaluation) error { | ||
125 | + for i := range param { | ||
126 | + if param[i].Types == domain.EvaluationSelf { | ||
127 | + notify.AddNotifySummaryEvaluation(¶m[i]) | ||
128 | + } | ||
129 | + } | ||
130 | + return nil | ||
131 | +} | ||
132 | + | ||
143 | // 下发周期综合评估 | 133 | // 下发周期综合评估 |
144 | type summaryEvaluationPublisher struct { | 134 | type summaryEvaluationPublisher struct { |
145 | userCache map[int64]*domain.User | 135 | userCache map[int64]*domain.User |
@@ -148,18 +138,10 @@ type summaryEvaluationPublisher struct { | @@ -148,18 +138,10 @@ type summaryEvaluationPublisher struct { | ||
148 | 138 | ||
149 | func (se *summaryEvaluationPublisher) sendSummaryEvaluationV2( | 139 | func (se *summaryEvaluationPublisher) sendSummaryEvaluationV2( |
150 | transactionContext application.TransactionContext, | 140 | transactionContext application.TransactionContext, |
151 | - projectParam *domain.EvaluationProject, cycleData *domain.EvaluationCycle, | 141 | + projectParam *domain.EvaluationProject, |
142 | + cycleData *domain.EvaluationCycle, | ||
143 | + permissioData domain.Permission, | ||
152 | ) ([]domain.SummaryEvaluation, error) { | 144 | ) ([]domain.SummaryEvaluation, error) { |
153 | - // transactionContext, err := factory.CreateTransactionContext(nil) | ||
154 | - // if err != nil { | ||
155 | - // return err | ||
156 | - // } | ||
157 | - // if err := transactionContext.StartTransaction(); err != nil { | ||
158 | - // return err | ||
159 | - // } | ||
160 | - // defer func() { | ||
161 | - // _ = transactionContext.RollbackTransaction() | ||
162 | - // }() | ||
163 | userRepo := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext}) | 145 | userRepo := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext}) |
164 | departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{"transactionContext": transactionContext}) | 146 | departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{"transactionContext": transactionContext}) |
165 | evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext}) | 147 | evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext}) |
@@ -193,16 +175,31 @@ func (se *summaryEvaluationPublisher) sendSummaryEvaluationV2( | @@ -193,16 +175,31 @@ func (se *summaryEvaluationPublisher) sendSummaryEvaluationV2( | ||
193 | if cycleData.TimeEnd == nil { | 175 | if cycleData.TimeEnd == nil { |
194 | return nil, fmt.Errorf("周期%d:%s 结束时间错误", cycleData.Id, cycleData.Name) | 176 | return nil, fmt.Errorf("周期%d:%s 结束时间错误", cycleData.Id, cycleData.Name) |
195 | } | 177 | } |
178 | + | ||
196 | //自评的时间范围 | 179 | //自评的时间范围 |
197 | - beginTimeSelf := *cycleData.TimeEnd | 180 | + beginTimeSelf := *cycleData.TimeEnd // |
181 | + beginDay := dayEndTime(beginTimeSelf) | ||
198 | //修改 周期结束时间那天的第二天开始计算 | 182 | //修改 周期结束时间那天的第二天开始计算 |
199 | - endTimeSelf := dayZeroTime(beginTimeSelf).Add(4*24*time.Hour - time.Second) | 183 | + endTimeSelf := beginDay.Add(time.Duration(permissioData.CycleDeadline.AssessmentSelf.Hour) * time.Hour). |
184 | + Add(time.Duration(permissioData.CycleDeadline.AssessmentSelf.Minute) * time.Minute) | ||
200 | //人资、360评估的时间范围 | 185 | //人资、360评估的时间范围 |
201 | beginTime360 := endTimeSelf | 186 | beginTime360 := endTimeSelf |
202 | - endTime360 := endTimeSelf.Add(2 * 24 * time.Hour) | 187 | + endTime360 := beginDay.Add(time.Duration(permissioData.CycleDeadline.AssessmentAll.Hour) * time.Hour). |
188 | + Add(time.Duration(permissioData.CycleDeadline.AssessmentAll.Minute) * time.Minute) | ||
189 | + //人资评估的时间范围 | ||
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) | ||
193 | + | ||
203 | //上级评估的是时间范围 | 194 | //上级评估的是时间范围 |
204 | - beginTimeSuper := endTime360 | ||
205 | - endTimeSuper := endTime360.Add(2 * 24 * time.Hour) | 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) | ||
198 | + | ||
199 | + //考核结果的时间范围 | ||
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) | ||
206 | // 创建周期评估任务 | 203 | // 创建周期评估任务 |
207 | var newEvaluationList []domain.SummaryEvaluation | 204 | var newEvaluationList []domain.SummaryEvaluation |
208 | evaluationTemp := domain.SummaryEvaluation{ | 205 | evaluationTemp := domain.SummaryEvaluation{ |
@@ -287,8 +284,8 @@ func (se *summaryEvaluationPublisher) sendSummaryEvaluationV2( | @@ -287,8 +284,8 @@ func (se *summaryEvaluationPublisher) sendSummaryEvaluationV2( | ||
287 | { | 284 | { |
288 | if hrbpExist { | 285 | if hrbpExist { |
289 | //处理人资评估 | 286 | //处理人资评估 |
290 | - evaluationTemp.BeginTime = beginTime360 | ||
291 | - evaluationTemp.EndTime = endTime360 | 287 | + evaluationTemp.BeginTime = beginTimeHr |
288 | + evaluationTemp.EndTime = endTimeHr | ||
292 | evaluationTemp.Executor = domain.StaffDesc{} | 289 | evaluationTemp.Executor = domain.StaffDesc{} |
293 | evaluationTemp.Types = domain.EvaluationHrbp | 290 | evaluationTemp.Types = domain.EvaluationHrbp |
294 | newEvaluationList = append(newEvaluationList, evaluationTemp) | 291 | newEvaluationList = append(newEvaluationList, evaluationTemp) |
@@ -314,8 +311,8 @@ func (se *summaryEvaluationPublisher) sendSummaryEvaluationV2( | @@ -314,8 +311,8 @@ func (se *summaryEvaluationPublisher) sendSummaryEvaluationV2( | ||
314 | { | 311 | { |
315 | evaluationTemp.Types = domain.EvaluationFinish | 312 | evaluationTemp.Types = domain.EvaluationFinish |
316 | evaluationTemp.Executor = domain.StaffDesc{} | 313 | evaluationTemp.Executor = domain.StaffDesc{} |
317 | - evaluationTemp.BeginTime = endTimeSuper | ||
318 | - evaluationTemp.EndTime = endTimeSuper.Add(2 * 24 * time.Hour) | 314 | + evaluationTemp.BeginTime = beginTimeFinish |
315 | + evaluationTemp.EndTime = endTimeFinish | ||
319 | newEvaluationList = append(newEvaluationList, evaluationTemp) | 316 | newEvaluationList = append(newEvaluationList, evaluationTemp) |
320 | } | 317 | } |
321 | } | 318 | } |
@@ -332,30 +329,9 @@ func (se *summaryEvaluationPublisher) sendSummaryEvaluationV2( | @@ -332,30 +329,9 @@ func (se *summaryEvaluationPublisher) sendSummaryEvaluationV2( | ||
332 | if err != nil { | 329 | if err != nil { |
333 | return nil, fmt.Errorf("保存项目状态%s", err) | 330 | return nil, fmt.Errorf("保存项目状态%s", err) |
334 | } | 331 | } |
335 | - // if err := transactionContext.CommitTransaction(); err != nil { | ||
336 | - // return err | ||
337 | - // } | ||
338 | return newEvaluationList, nil | 332 | return newEvaluationList, nil |
339 | } | 333 | } |
340 | 334 | ||
341 | -// 获取周期设置数据 | ||
342 | -// func (se *summaryEvaluationPublisher) getCycleData(cycleRepo domain.EvaluationCycleRepository, cycleId int64) (*domain.EvaluationCycle, error) { | ||
343 | -// var cycleData *domain.EvaluationCycle | ||
344 | -// if val, ok := se.cycleCache[cycleId]; ok { | ||
345 | -// cycleData = val | ||
346 | -// } else { | ||
347 | -// _, cycleList, err := cycleRepo.Find(map[string]interface{}{"id": cycleId}) | ||
348 | -// if err != nil { | ||
349 | -// return nil, err | ||
350 | -// } | ||
351 | -// if len(cycleList) == 0 { | ||
352 | -// return nil, nil | ||
353 | -// } | ||
354 | -// cycleData = cycleList[0] | ||
355 | -// } | ||
356 | -// return cycleData, nil | ||
357 | -// } | ||
358 | - | ||
359 | // 获取用户数据 | 335 | // 获取用户数据 |
360 | func (se *summaryEvaluationPublisher) getUserData(userRepo domain.UserRepository, userId int64) (*domain.User, error) { | 336 | func (se *summaryEvaluationPublisher) getUserData(userRepo domain.UserRepository, userId int64) (*domain.User, error) { |
361 | if userId == 0 { | 337 | if userId == 0 { |
@@ -43,7 +43,7 @@ func (srv *SummaryEvaluationService) GetExecutorCycleList(param *command.QueryCy | @@ -43,7 +43,7 @@ func (srv *SummaryEvaluationService) GetExecutorCycleList(param *command.QueryCy | ||
43 | "transactionContext": transactionContext, | 43 | "transactionContext": transactionContext, |
44 | }) | 44 | }) |
45 | 45 | ||
46 | - flagHrbp, err := roleService.GetHRBP(transactionContext, param.CompanyId, param.UserId) | 46 | + flagHrbp, err := roleService.GetHrBp(transactionContext, param.CompanyId, param.UserId) |
47 | if err != nil { | 47 | if err != nil { |
48 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 48 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
49 | } | 49 | } |
@@ -194,7 +194,7 @@ func (srv *SummaryEvaluationService) GetMenu(param *command.QueryMenu) (map[stri | @@ -194,7 +194,7 @@ func (srv *SummaryEvaluationService) GetMenu(param *command.QueryMenu) (map[stri | ||
194 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 194 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
195 | } | 195 | } |
196 | } | 196 | } |
197 | - isHrbp, err := roleService.GetHRBP(transactionContext, param.CompanyId, param.UserId) | 197 | + isHrbp, err := roleService.GetHrBp(transactionContext, param.CompanyId, param.UserId) |
198 | if err != nil { | 198 | if err != nil { |
199 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 199 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
200 | } | 200 | } |
@@ -354,13 +354,6 @@ func (srv *SummaryEvaluationService) buildSummaryItemValue(itemList []*domain.Ev | @@ -354,13 +354,6 @@ func (srv *SummaryEvaluationService) buildSummaryItemValue(itemList []*domain.Ev | ||
354 | Remark: "", | 354 | Remark: "", |
355 | EvaluatorId: v.EvaluatorId, | 355 | EvaluatorId: v.EvaluatorId, |
356 | } | 356 | } |
357 | - //PromptText 页面展示 特殊处理 | ||
358 | - if len(v.EntryItems) > 0 { | ||
359 | - item.PromptTitle = "" | ||
360 | - for _, v2 := range v.EntryItems { | ||
361 | - item.PromptTitle += v2.Title + "\n" | ||
362 | - } | ||
363 | - } | ||
364 | value, ok := valueMap[v.Id] | 357 | value, ok := valueMap[v.Id] |
365 | if ok { | 358 | if ok { |
366 | item.Score = value.Score | 359 | item.Score = value.Score |
@@ -1014,11 +1007,15 @@ func (srv *SummaryEvaluationService) GetEvaluationSuper(param *command.QueryEval | @@ -1014,11 +1007,15 @@ func (srv *SummaryEvaluationService) GetEvaluationSuper(param *command.QueryEval | ||
1014 | itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{ | 1007 | itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{ |
1015 | "transactionContext": transactionContext, | 1008 | "transactionContext": transactionContext, |
1016 | }) | 1009 | }) |
1017 | - permissionRepository := factory.CreatePermissionRepository(map[string]interface{}{"transactionContext": transactionContext}) | 1010 | + // permissionRepository := factory.CreatePermissionRepository(map[string]interface{}{"transactionContext": transactionContext}) |
1018 | // 获取权限配置 | 1011 | // 获取权限配置 |
1019 | - _, permissionList, err := permissionRepository.Find(map[string]interface{}{"companyId": param.CompanyId}) | 1012 | + // _, permissionList, err := permissionRepository.Find(map[string]interface{}{"companyId": param.CompanyId}) |
1013 | + // if err != nil { | ||
1014 | + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
1015 | + // } | ||
1016 | + permissinData, err := getPermission(int64(param.CompanyId)) | ||
1020 | if err != nil { | 1017 | if err != nil { |
1021 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 1018 | + return nil, err |
1022 | } | 1019 | } |
1023 | evaluationData, err := evaluationRepo.FindOne(map[string]interface{}{ | 1020 | evaluationData, err := evaluationRepo.FindOne(map[string]interface{}{ |
1024 | "id": param.SummaryEvaluationId, | 1021 | "id": param.SummaryEvaluationId, |
@@ -1077,17 +1074,15 @@ func (srv *SummaryEvaluationService) GetEvaluationSuper(param *command.QueryEval | @@ -1077,17 +1074,15 @@ func (srv *SummaryEvaluationService) GetEvaluationSuper(param *command.QueryEval | ||
1077 | //组合 评估填写的值和评估项 | 1074 | //组合 评估填写的值和评估项 |
1078 | itemValuesAdapter := srv.buildSummaryItemValue(itemList, itemValues) | 1075 | itemValuesAdapter := srv.buildSummaryItemValue(itemList, itemValues) |
1079 | for i, v := range itemValuesAdapter { | 1076 | for i, v := range itemValuesAdapter { |
1080 | - if len(permissionList) > 0 { | ||
1081 | - if permissionList[0].OptEvalScore == domain.PermissionOff && | 1077 | + if permissinData.OptEvalScore == domain.PermissionOff && |
1082 | v.EvaluatorId > 0 { | 1078 | v.EvaluatorId > 0 { |
1083 | itemValuesAdapter[i].ForbidEdit = true | 1079 | itemValuesAdapter[i].ForbidEdit = true |
1084 | } | 1080 | } |
1085 | - if permissionList[0].OptHrScore == domain.PermissionOff && | 1081 | + if permissinData.OptHrScore == domain.PermissionOff && |
1086 | v.EvaluatorId < 0 { | 1082 | v.EvaluatorId < 0 { |
1087 | itemValuesAdapter[i].ForbidEdit = true | 1083 | itemValuesAdapter[i].ForbidEdit = true |
1088 | } | 1084 | } |
1089 | } | 1085 | } |
1090 | - } | ||
1091 | result := adapter.EvaluationInfoSuperAdapter{ | 1086 | result := adapter.EvaluationInfoSuperAdapter{ |
1092 | EvaluationBaseAdapter: evaluationBase, | 1087 | EvaluationBaseAdapter: evaluationBase, |
1093 | // LevelCount: codeList, | 1088 | // LevelCount: codeList, |
@@ -1213,16 +1208,19 @@ func (srv *SummaryEvaluationService) getEvaluationSuperDefaultValue(transactionC | @@ -1213,16 +1208,19 @@ func (srv *SummaryEvaluationService) getEvaluationSuperDefaultValue(transactionC | ||
1213 | "transactionContext": transactionContext, | 1208 | "transactionContext": transactionContext, |
1214 | }) | 1209 | }) |
1215 | 1210 | ||
1216 | - permissionRepository := factory.CreatePermissionRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
1217 | - // 获取权限配置 | ||
1218 | - _, permissionList, err := permissionRepository.Find(map[string]interface{}{"companyId": evaluationData.CompanyId}) | 1211 | + // permissionRepository := factory.CreatePermissionRepository(map[string]interface{}{"transactionContext": transactionContext}) |
1212 | + // // 获取权限配置 | ||
1213 | + // _, permissionList, err := permissionRepository.Find(map[string]interface{}{"companyId": evaluationData.CompanyId}) | ||
1214 | + // if err != nil { | ||
1215 | + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
1216 | + // } | ||
1217 | + // if len(permissionList) == 0 { | ||
1218 | + // return nil, nil | ||
1219 | + // } | ||
1220 | + permissionData, err := getPermission(int64(evaluationData.CompanyId)) | ||
1219 | if err != nil { | 1221 | if err != nil { |
1220 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 1222 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
1221 | } | 1223 | } |
1222 | - if len(permissionList) == 0 { | ||
1223 | - return nil, nil | ||
1224 | - } | ||
1225 | - permissionData := permissionList[0] | ||
1226 | if permissionData.OptEvalScore == domain.PermissionOn && permissionData.OptHrScore == domain.PermissionOn { | 1224 | if permissionData.OptEvalScore == domain.PermissionOn && permissionData.OptHrScore == domain.PermissionOn { |
1227 | return nil, nil | 1225 | return nil, nil |
1228 | } | 1226 | } |
@@ -1392,7 +1390,7 @@ func (srv *SummaryEvaluationService) ListExecutorEvaluationSuper(param *command. | @@ -1392,7 +1390,7 @@ func (srv *SummaryEvaluationService) ListExecutorEvaluationSuper(param *command. | ||
1392 | TargetUserName: v.TargetUser.UserName, | 1390 | TargetUserName: v.TargetUser.UserName, |
1393 | TargetUserId: v.TargetUser.UserId, | 1391 | TargetUserId: v.TargetUser.UserId, |
1394 | EvaluationStatus: string(v.Status), | 1392 | EvaluationStatus: string(v.Status), |
1395 | - EndTime: v.EndTime.Format("2006-01-02 15:04:05"), | 1393 | + EndTime: v.EndTime.Local().Format("2006-01-02 15:04:05"), |
1396 | TotalScoreSelf: "", | 1394 | TotalScoreSelf: "", |
1397 | Department: "", | 1395 | Department: "", |
1398 | Position: "", | 1396 | Position: "", |
@@ -1422,7 +1420,7 @@ func (srv *SummaryEvaluationService) ListExecutorEvaluationSuper(param *command. | @@ -1422,7 +1420,7 @@ func (srv *SummaryEvaluationService) ListExecutorEvaluationSuper(param *command. | ||
1422 | result["endTime"] = "" | 1420 | result["endTime"] = "" |
1423 | result["uncompleted_number"] = 0 | 1421 | result["uncompleted_number"] = 0 |
1424 | if len(evaluationList) > 0 { | 1422 | if len(evaluationList) > 0 { |
1425 | - result["endTime"] = evaluationList[0].EndTime.Format("2006-01-02 15:04:05") | 1423 | + result["endTime"] = evaluationList[0].EndTime.Local().Format("2006-01-02 15:04:05") |
1426 | result["uncompleted_number"] = cntUn | 1424 | result["uncompleted_number"] = cntUn |
1427 | } | 1425 | } |
1428 | return result, nil | 1426 | return result, nil |
@@ -1447,6 +1445,7 @@ func (srv *SummaryEvaluationService) ConfirmScoreEvaluation(param *command.Confi | @@ -1447,6 +1445,7 @@ func (srv *SummaryEvaluationService) ConfirmScoreEvaluation(param *command.Confi | ||
1447 | if err != nil { | 1445 | if err != nil { |
1448 | return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 1446 | return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
1449 | } | 1447 | } |
1448 | + | ||
1450 | if result.Types != domain.EvaluationFinish { | 1449 | if result.Types != domain.EvaluationFinish { |
1451 | return application.ThrowError(application.TRANSACTION_ERROR, "操作方式错误") | 1450 | return application.ThrowError(application.TRANSACTION_ERROR, "操作方式错误") |
1452 | } | 1451 | } |
@@ -1771,11 +1770,11 @@ func (srv *SummaryEvaluationService) ListAllEvaluationFinish(param *command.Quer | @@ -1771,11 +1770,11 @@ func (srv *SummaryEvaluationService) ListAllEvaluationFinish(param *command.Quer | ||
1771 | _ = transactionContext.RollbackTransaction() | 1770 | _ = transactionContext.RollbackTransaction() |
1772 | }() | 1771 | }() |
1773 | //判断是否是hrbp | 1772 | //判断是否是hrbp |
1774 | - flagHrbp, err := roleService.GetHRBP(transactionContext, param.CompanyId, param.UserId) | 1773 | + flagHrbp, err := roleService.GetHrBp(transactionContext, param.CompanyId, param.UserId) |
1775 | if err != nil { | 1774 | if err != nil { |
1776 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 1775 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
1777 | } | 1776 | } |
1778 | - if flagHrbp != 1 { | 1777 | + if flagHrbp != domain.RoleTypeSystem { |
1779 | return tool_funs.SimpleWrapGridMap(0, []string{}), nil | 1778 | return tool_funs.SimpleWrapGridMap(0, []string{}), nil |
1780 | } | 1779 | } |
1781 | //判断是否是上级 | 1780 | //判断是否是上级 |
@@ -1787,7 +1786,7 @@ func (srv *SummaryEvaluationService) ListAllEvaluationFinish(param *command.Quer | @@ -1787,7 +1786,7 @@ func (srv *SummaryEvaluationService) ListAllEvaluationFinish(param *command.Quer | ||
1787 | "parentId": param.UserId, | 1786 | "parentId": param.UserId, |
1788 | "limit": 1, | 1787 | "limit": 1, |
1789 | }) | 1788 | }) |
1790 | - if len(parentUser) == 0 && flagHrbp != 1 { | 1789 | + if len(parentUser) == 0 && flagHrbp != domain.RoleTypeSystem { |
1791 | return tool_funs.SimpleWrapGridMap(0, []string{}), nil | 1790 | return tool_funs.SimpleWrapGridMap(0, []string{}), nil |
1792 | } | 1791 | } |
1793 | evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{ | 1792 | evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{ |
@@ -1805,7 +1804,6 @@ func (srv *SummaryEvaluationService) ListAllEvaluationFinish(param *command.Quer | @@ -1805,7 +1804,6 @@ func (srv *SummaryEvaluationService) ListAllEvaluationFinish(param *command.Quer | ||
1805 | "cycleId": param.CycleId, | 1804 | "cycleId": param.CycleId, |
1806 | "types": int(domain.EvaluationFinish), | 1805 | "types": int(domain.EvaluationFinish), |
1807 | "limit": limit, | 1806 | "limit": limit, |
1808 | - "beginTime": time.Now(), | ||
1809 | } | 1807 | } |
1810 | if offset > 0 { | 1808 | if offset > 0 { |
1811 | condition1["offset"] = offset | 1809 | condition1["offset"] = offset |
@@ -9,7 +9,7 @@ import ( | @@ -9,7 +9,7 @@ import ( | ||
9 | "github.com/linmadan/egglib-go/core/application" | 9 | "github.com/linmadan/egglib-go/core/application" |
10 | "github.com/linmadan/egglib-go/utils/tool_funs" | 10 | "github.com/linmadan/egglib-go/utils/tool_funs" |
11 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" | 11 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" |
12 | - service "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/role" | 12 | + roleService "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/role" |
13 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/adapter" | 13 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/adapter" |
14 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/command" | 14 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/command" |
15 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | 15 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" |
@@ -437,11 +437,11 @@ func (srv *SummaryEvaluationService) EvaluationHRBPList(param *command.QueryEval | @@ -437,11 +437,11 @@ func (srv *SummaryEvaluationService) EvaluationHRBPList(param *command.QueryEval | ||
437 | }() | 437 | }() |
438 | 438 | ||
439 | // 必须是HRBP权限的人才能编辑操作 | 439 | // 必须是HRBP权限的人才能编辑操作 |
440 | - hrbp, err := service.GetHRBP(transactionContext, param.CompanyId, param.UserId) | 440 | + hrbp, err := roleService.GetHrBp(transactionContext, param.CompanyId, param.UserId) |
441 | if err != nil { | 441 | if err != nil { |
442 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 442 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
443 | } | 443 | } |
444 | - if hrbp != 1 { | 444 | + if hrbp != domain.RoleTypeSystem { |
445 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限") | 445 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限") |
446 | } | 446 | } |
447 | 447 | ||
@@ -738,11 +738,11 @@ func (srv *SummaryEvaluationService) EditEvaluationHRBP(param *command.EditEvalu | @@ -738,11 +738,11 @@ func (srv *SummaryEvaluationService) EditEvaluationHRBP(param *command.EditEvalu | ||
738 | itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext}) | 738 | itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext}) |
739 | 739 | ||
740 | // 必须是HRBP权限的人才能编辑操作 | 740 | // 必须是HRBP权限的人才能编辑操作 |
741 | - hrbp, err := service.GetHRBP(transactionContext, param.CompanyId, param.ExecutorId) | 741 | + hrbp, err := roleService.GetHrBp(transactionContext, param.CompanyId, param.ExecutorId) |
742 | if err != nil { | 742 | if err != nil { |
743 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 743 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
744 | } | 744 | } |
745 | - if hrbp != 1 { | 745 | + if hrbp != domain.RoleTypeSystem { |
746 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限") | 746 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限") |
747 | } | 747 | } |
748 | 748 | ||
@@ -820,3 +820,54 @@ func (srv *SummaryEvaluationService) EditEvaluationHRBP(param *command.EditEvalu | @@ -820,3 +820,54 @@ func (srv *SummaryEvaluationService) EditEvaluationHRBP(param *command.EditEvalu | ||
820 | "evaluationItems": itemValueAdapter, | 820 | "evaluationItems": itemValueAdapter, |
821 | }, nil | 821 | }, nil |
822 | } | 822 | } |
823 | + | ||
824 | +// 修改周期考核的分数 | ||
825 | +func (srv *SummaryEvaluationService) ModifyFinishScore(param *command.ModifyFinishScore) error { | ||
826 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
827 | + if err != nil { | ||
828 | + return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
829 | + } | ||
830 | + if err := transactionContext.StartTransaction(); err != nil { | ||
831 | + return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
832 | + } | ||
833 | + defer func() { | ||
834 | + _ = transactionContext.RollbackTransaction() | ||
835 | + }() | ||
836 | + // 只有超级管理员可以使用的功能 | ||
837 | + superAdmin, err := roleService.GetSuperAdmin(transactionContext, param.CompanyId, param.UserId) | ||
838 | + if err != nil { | ||
839 | + return err | ||
840 | + } | ||
841 | + if superAdmin != domain.RoleTypeSuperAdmin { | ||
842 | + return application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限") | ||
843 | + } | ||
844 | + | ||
845 | + //获取周期评估任务finish | ||
846 | + evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
847 | + _, evaluationList, err := evaluationRepo.Find(map[string]interface{}{ | ||
848 | + "id": []int{param.SummaryEvaluationId}, | ||
849 | + "companyId": param.CompanyId, | ||
850 | + }) | ||
851 | + if err != nil { | ||
852 | + return application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
853 | + } | ||
854 | + if len(evaluationList) == 0 { | ||
855 | + return nil | ||
856 | + } | ||
857 | + evaluationData := evaluationList[0] | ||
858 | + if evaluationData.Types != domain.EvaluationFinish { | ||
859 | + return nil | ||
860 | + } | ||
861 | + scoreStr := fmt.Sprintf("%.2f", param.Score) | ||
862 | + evaluationData.TotalScore = scoreStr | ||
863 | + evaluationData.Status = domain.EvaluationCompleted | ||
864 | + evaluationData.CheckResult = domain.EvaluationCheckCompleted | ||
865 | + err = evaluationRepo.Save(evaluationData) | ||
866 | + if err != nil { | ||
867 | + return application.ThrowError(application.BUSINESS_ERROR, "修改考核结果"+err.Error()) | ||
868 | + } | ||
869 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
870 | + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
871 | + } | ||
872 | + return nil | ||
873 | +} |
1 | +package service | ||
2 | + | ||
3 | +import ( | ||
4 | + permissionSrv "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/permission" | ||
5 | + permissionCmd "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/permission/command" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
7 | +) | ||
8 | + | ||
9 | +func getPermission(companyId int64) (*domain.Permission, error) { | ||
10 | + srv := &permissionSrv.PermissionService{} | ||
11 | + permissionData, err := srv.Get(&permissionCmd.GetPermissionCommand{ | ||
12 | + CompanyId: companyId, | ||
13 | + }) | ||
14 | + if err != nil { | ||
15 | + return nil, err | ||
16 | + } | ||
17 | + return permissionData, nil | ||
18 | +} |
@@ -135,11 +135,11 @@ func (us *UserService) EditParentUser(in *command.EditParentCommand) error { | @@ -135,11 +135,11 @@ func (us *UserService) EditParentUser(in *command.EditParentCommand) error { | ||
135 | transactionContext.RollbackTransaction() | 135 | transactionContext.RollbackTransaction() |
136 | }() | 136 | }() |
137 | 137 | ||
138 | - hrbp, err := service.GetHRBP(transactionContext, in.CompanyId, in.OperatorId) | 138 | + hrbp, err := service.GetHrBp(transactionContext, in.CompanyId, in.OperatorId) |
139 | if err != nil { | 139 | if err != nil { |
140 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 140 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
141 | } | 141 | } |
142 | - if hrbp != 1 { | 142 | + if hrbp != domain.RoleTypeSystem { |
143 | return application.ThrowError(application.BUSINESS_ERROR, "HRBP权限的员工才能操作") | 143 | return application.ThrowError(application.BUSINESS_ERROR, "HRBP权限的员工才能操作") |
144 | } | 144 | } |
145 | 145 | ||
@@ -177,11 +177,11 @@ func (us *UserService) ImportParentUser(in *command.ImportParentUserCommand) (in | @@ -177,11 +177,11 @@ func (us *UserService) ImportParentUser(in *command.ImportParentUserCommand) (in | ||
177 | transactionContext.RollbackTransaction() | 177 | transactionContext.RollbackTransaction() |
178 | }() | 178 | }() |
179 | 179 | ||
180 | - hrbp, err := service.GetHRBP(transactionContext, in.CompanyId, in.OperatorId) | 180 | + hrbp, err := service.GetHrBp(transactionContext, in.CompanyId, in.OperatorId) |
181 | if err != nil { | 181 | if err != nil { |
182 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 182 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
183 | } | 183 | } |
184 | - if hrbp != 1 { | 184 | + if hrbp != domain.RoleTypeSystem { |
185 | return nil, application.ThrowError(application.BUSINESS_ERROR, "HRBP权限的员工才能操作") | 185 | return nil, application.ThrowError(application.BUSINESS_ERROR, "HRBP权限的员工才能操作") |
186 | } | 186 | } |
187 | userRepo := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext}) | 187 | userRepo := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext}) |
@@ -12,11 +12,27 @@ type Permission struct { | @@ -12,11 +12,27 @@ 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 | CreatedAt time.Time `json:"createdAt" comment:"创建时间"` | 17 | CreatedAt time.Time `json:"createdAt" comment:"创建时间"` |
16 | UpdatedAt time.Time `json:"updatedAt" comment:"更新时间"` | 18 | UpdatedAt time.Time `json:"updatedAt" comment:"更新时间"` |
17 | DeletedAt *time.Time `json:"deletedAt" comment:"删除时间"` | 19 | DeletedAt *time.Time `json:"deletedAt" comment:"删除时间"` |
18 | } | 20 | } |
19 | 21 | ||
22 | +// CycleDeadline 周期评估截止时间 | ||
23 | +type CycleDeadline struct { | ||
24 | + AssessmentSelf DeadlineTime `json:"assessmentSelf" comment:"综合自评"` | ||
25 | + AssessmentAll DeadlineTime `json:"assessmentAll" comment:"360评估"` | ||
26 | + AssessmentHr DeadlineTime `json:"assessmentHr" comment:"人资评估"` | ||
27 | + AssessmentSuperior DeadlineTime `json:"assessmentSuperior" comment:"上级评估"` | ||
28 | + ViewMyPerf DeadlineTime `json:"viewMyPerf" comment:"查看我的绩效"` | ||
29 | +} | ||
30 | + | ||
31 | +type DeadlineTime struct { | ||
32 | + Hour int `json:"hour" comment:"时"` | ||
33 | + Minute int `json:"minute" comment:"分"` | ||
34 | +} | ||
35 | + | ||
20 | type PermissionRepository interface { | 36 | type PermissionRepository interface { |
21 | Insert(permission *Permission) (*Permission, error) | 37 | Insert(permission *Permission) (*Permission, error) |
22 | FindOne(queryOptions map[string]interface{}) (*Permission, error) | 38 | FindOne(queryOptions map[string]interface{}) (*Permission, error) |
@@ -3,8 +3,9 @@ package domain | @@ -3,8 +3,9 @@ package domain | ||
3 | import "time" | 3 | import "time" |
4 | 4 | ||
5 | const ( | 5 | const ( |
6 | - RoleTypeCommon int = 0 // 角色类型-后台添加角色 | ||
7 | - RoleTypeSystem int = 1 // 角色类型-系统预制角色(不可删除、编辑) | 6 | + RoleTypeCommon int = 0 // 角色类型-普通角色 |
7 | + RoleTypeSystem int = 1 // 角色类型-系统预制角色HR-BP(不可删除、编辑) | ||
8 | + RoleTypeSuperAdmin int = 2 // 角色类型-系统预制超级管理员(不可删除、编辑) | ||
8 | ) | 9 | ) |
9 | 10 | ||
10 | type Role struct { | 11 | type Role struct { |
@@ -151,3 +151,30 @@ func (d *SummaryEvaluationDao) UpdateBeginTime(ids []int, beginTime time.Time) e | @@ -151,3 +151,30 @@ func (d *SummaryEvaluationDao) UpdateBeginTime(ids []int, beginTime time.Time) e | ||
151 | _, err := tx.Exec(sqlStr, condition...) | 151 | _, err := tx.Exec(sqlStr, condition...) |
152 | return err | 152 | return err |
153 | } | 153 | } |
154 | + | ||
155 | +type SummaryEvaluationData1 struct { | ||
156 | + SummaryEvaluationId int `pg:"summary_evaluation_id"` | ||
157 | + TargetUserId string `pg:"target_user_id"` | ||
158 | + CompanyId int64 `pg:"company_id"` | ||
159 | +} | ||
160 | + | ||
161 | +// 查询周期考核结果 | ||
162 | +// 条件:已过截止时间,并且还没确认周期考核结果 | ||
163 | +func (d *SummaryEvaluationDao) ListEvaluationFinishNoResult() ([]SummaryEvaluationData1, error) { | ||
164 | + sqlStr := `select | ||
165 | + summary_evaluation.id as summary_evaluation_id, | ||
166 | + summary_evaluation.target_user ->>'userId' as target_user_id, | ||
167 | + summary_evaluation.company_id | ||
168 | + from summary_evaluation | ||
169 | + where 1=1 | ||
170 | + and summary_evaluation."types" = 5 | ||
171 | + and summary_evaluation.status ='completed' | ||
172 | + and summary_evaluation.check_result ='uncompleted' | ||
173 | + and summary_evaluation.end_time <=now() | ||
174 | + and summary_evaluation.deleted_at isnull | ||
175 | + ` | ||
176 | + result := []SummaryEvaluationData1{} | ||
177 | + tx := d.transactionContext.PgTx | ||
178 | + _, err := tx.Query(&result, sqlStr) | ||
179 | + return result, err | ||
180 | +} |
1 | package models | 1 | package models |
2 | 2 | ||
3 | -import "time" | 3 | +import ( |
4 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
5 | + "time" | ||
6 | +) | ||
4 | 7 | ||
5 | type Permission struct { | 8 | type Permission struct { |
6 | tableName struct{} `comment:"配置权限" pg:"permission"` | 9 | tableName struct{} `comment:"配置权限" pg:"permission"` |
@@ -8,6 +11,8 @@ type Permission struct { | @@ -8,6 +11,8 @@ type Permission struct { | ||
8 | CompanyId int64 `comment:"公司ID"` | 11 | CompanyId int64 `comment:"公司ID"` |
9 | OptHrScore int `comment:"上级是否可以修改人资综评分数"` | 12 | OptHrScore int `comment:"上级是否可以修改人资综评分数"` |
10 | OptEvalScore int `comment:"上级是否可以修改360°综评分数"` | 13 | OptEvalScore int `comment:"上级是否可以修改360°综评分数"` |
14 | + OptConfirmPerf int `comment:"是否需要员工确认绩效"` | ||
15 | + CycleDeadline *domain.CycleDeadline `comment:"周期评估各业务截止时间"` | ||
11 | CreatedAt time.Time `comment:"创建时间"` | 16 | CreatedAt time.Time `comment:"创建时间"` |
12 | UpdatedAt time.Time `comment:"更新时间"` | 17 | UpdatedAt time.Time `comment:"更新时间"` |
13 | DeletedAt *time.Time `comment:"删除时间"` | 18 | DeletedAt *time.Time `comment:"删除时间"` |
@@ -26,6 +26,8 @@ func (repo *PermissionRepository) TransformToDomain(m *models.Permission) domain | @@ -26,6 +26,8 @@ func (repo *PermissionRepository) TransformToDomain(m *models.Permission) domain | ||
26 | CompanyId: m.CompanyId, | 26 | CompanyId: m.CompanyId, |
27 | OptHrScore: m.OptHrScore, | 27 | OptHrScore: m.OptHrScore, |
28 | OptEvalScore: m.OptEvalScore, | 28 | OptEvalScore: m.OptEvalScore, |
29 | + OptConfirmPerf: m.OptConfirmPerf, | ||
30 | + CycleDeadline: m.CycleDeadline, | ||
29 | CreatedAt: m.CreatedAt.Local(), | 31 | CreatedAt: m.CreatedAt.Local(), |
30 | UpdatedAt: m.UpdatedAt.Local(), | 32 | UpdatedAt: m.UpdatedAt.Local(), |
31 | DeletedAt: m.DeletedAt, | 33 | DeletedAt: m.DeletedAt, |
@@ -38,6 +40,8 @@ func (repo *PermissionRepository) TransformToModel(d *domain.Permission) models. | @@ -38,6 +40,8 @@ func (repo *PermissionRepository) TransformToModel(d *domain.Permission) models. | ||
38 | CompanyId: d.CompanyId, | 40 | CompanyId: d.CompanyId, |
39 | OptHrScore: d.OptHrScore, | 41 | OptHrScore: d.OptHrScore, |
40 | OptEvalScore: d.OptEvalScore, | 42 | OptEvalScore: d.OptEvalScore, |
43 | + OptConfirmPerf: d.OptConfirmPerf, | ||
44 | + CycleDeadline: d.CycleDeadline, | ||
41 | CreatedAt: d.CreatedAt, | 45 | CreatedAt: d.CreatedAt, |
42 | UpdatedAt: d.UpdatedAt, | 46 | UpdatedAt: d.UpdatedAt, |
43 | 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 | } |
@@ -384,3 +384,20 @@ func (c *SummaryEvaluationController) SearchAssessRemark() { | @@ -384,3 +384,20 @@ func (c *SummaryEvaluationController) SearchAssessRemark() { | ||
384 | data, err := srv.SearchAssessRemark(param) | 384 | data, err := srv.SearchAssessRemark(param) |
385 | c.Response(data, err) | 385 | c.Response(data, err) |
386 | } | 386 | } |
387 | + | ||
388 | +// 修改周期考核结果的分数 | ||
389 | +func (c *SummaryEvaluationController) ModifyFinishScore() { | ||
390 | + srv := service.NewSummaryEvaluationService() | ||
391 | + param := &command.ModifyFinishScore{} | ||
392 | + err := c.BindJSON(param) | ||
393 | + if err != nil { | ||
394 | + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error()) | ||
395 | + c.Response(nil, e) | ||
396 | + return | ||
397 | + } | ||
398 | + userReq := middlewares.GetUser(c.Ctx) | ||
399 | + param.UserId = int(userReq.UserId) | ||
400 | + param.CompanyId = int(userReq.CompanyId) | ||
401 | + err = srv.ModifyFinishScore(param) | ||
402 | + c.Response(nil, err) | ||
403 | +} |
@@ -32,6 +32,7 @@ func init() { | @@ -32,6 +32,7 @@ func init() { | ||
32 | //web.NSCtrlPost("/target_user/evaluation-super", (*controllers.SummaryEvaluationController).GetTargetEvaluationResult), | 32 | //web.NSCtrlPost("/target_user/evaluation-super", (*controllers.SummaryEvaluationController).GetTargetEvaluationResult), |
33 | // web.NSCtrlPost("/evaluation-super/all", (*controllers.SummaryEvaluationController).ListAllEvaluationSuper), | 33 | // web.NSCtrlPost("/evaluation-super/all", (*controllers.SummaryEvaluationController).ListAllEvaluationSuper), |
34 | web.NSCtrlPost("/evaluation-finish/all", (*controllers.SummaryEvaluationController).ListAllEvaluationFinish), | 34 | web.NSCtrlPost("/evaluation-finish/all", (*controllers.SummaryEvaluationController).ListAllEvaluationFinish), |
35 | + web.NSCtrlPost("/evaluation-finish/modify-score", (*controllers.SummaryEvaluationController).ModifyFinishScore), | ||
35 | // web.NSCtrlPost("/evaluation-super/all/export", (*controllers.SummaryEvaluationController).ExportAllEvaluationSuper), | 36 | // web.NSCtrlPost("/evaluation-super/all/export", (*controllers.SummaryEvaluationController).ExportAllEvaluationSuper), |
36 | web.NSCtrlPost("/evaluation-finish/all/export", (*controllers.SummaryEvaluationController).ExportAllEvaluationFinish), | 37 | web.NSCtrlPost("/evaluation-finish/all/export", (*controllers.SummaryEvaluationController).ExportAllEvaluationFinish), |
37 | web.NSCtrlGet("/evaluation-self/now", (*controllers.SummaryEvaluationController).ListExecutorEvaluationSelf), | 38 | web.NSCtrlGet("/evaluation-self/now", (*controllers.SummaryEvaluationController).ListExecutorEvaluationSelf), |
sql/1.2.4.sql
0 → 100644
1 | +-- 权限表建新列 | ||
2 | +ALTER TABLE public."permission" | ||
3 | + ADD opt_confirm_perf int8 NULL DEFAULT 1; | ||
4 | +COMMENT | ||
5 | +ON COLUMN public."permission".opt_confirm_perf IS '是否需要员工确认绩效'; | ||
6 | + | ||
7 | +ALTER TABLE public."permission" | ||
8 | + ADD cycle_deadline jsonb NULL; | ||
9 | +COMMENT | ||
10 | +ON COLUMN public."permission".cycle_deadline IS '周期评估各业务截止时间'; | ||
11 | + | ||
12 | + | ||
13 | +-- 公司添加超级管理员(不存在时插入新数据)(注.公司ID->416) | ||
14 | +insert | ||
15 | +into | ||
16 | + public."role" | ||
17 | +( "name", | ||
18 | + "type", | ||
19 | + description, | ||
20 | + company_id, | ||
21 | + created_at, | ||
22 | + updated_at, | ||
23 | + deleted_at) | ||
24 | +select | ||
25 | + '超级管理员', | ||
26 | + 2, | ||
27 | + '隐藏角色,拥有部分权限', | ||
28 | + 416, | ||
29 | + now(), | ||
30 | + now(), | ||
31 | + null | ||
32 | + where | ||
33 | + not exists ( | ||
34 | + select | ||
35 | + 1 | ||
36 | + from | ||
37 | + public."role" | ||
38 | + where | ||
39 | + "role".company_id = 416 | ||
40 | + and "role"."type" = 2); | ||
41 | + | ||
42 | +-- 超级管理员添加关联用户(不存在时插入新数据)(注.公司ID->416 用户ID->3337322891762688) | ||
43 | +with temp_role as ( | ||
44 | + select | ||
45 | + id | ||
46 | + from | ||
47 | + public."role" | ||
48 | + where | ||
49 | + "role".company_id = 416 | ||
50 | + and "role"."type" = 2) | ||
51 | +insert | ||
52 | +into | ||
53 | + public."role_user" | ||
54 | +( role_id, | ||
55 | + user_id, | ||
56 | + company_id, | ||
57 | + created_at, | ||
58 | + updated_at, | ||
59 | + deleted_at) | ||
60 | +select | ||
61 | + temp_role."id", | ||
62 | + 3337322891762688, | ||
63 | + 416, | ||
64 | + now(), | ||
65 | + now(), | ||
66 | + null | ||
67 | +from | ||
68 | + temp_role | ||
69 | +where | ||
70 | + not exists( | ||
71 | + select | ||
72 | + 1 | ||
73 | + from | ||
74 | + public."role_user" | ||
75 | + where | ||
76 | + "role_user".company_id = 416 | ||
77 | + and "role_user".user_id = 3337322891762688 | ||
78 | + and "role_user".role_id = temp_role."id"); | ||
79 | +-- |
-
请 注册 或 登录 后发表评论