正在显示
9 个修改的文件
包含
354 行增加
和
300 行删除
@@ -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,26 +193,15 @@ func (service *AuthService) MeInfo(param *command.GetMeInfo) (map[string]interfa | @@ -194,26 +193,15 @@ 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 | - } | 203 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取用户的角色信息"+err.Error()) |
214 | } | 204 | } |
215 | - } | ||
216 | - //TODO 检查用户是否 超级角色 | ||
217 | if err := transactionContext.CommitTransaction(); err != nil { | 205 | if err := transactionContext.CommitTransaction(); err != nil { |
218 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 206 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
219 | } | 207 | } |
@@ -224,8 +212,15 @@ loop: | @@ -224,8 +212,15 @@ loop: | ||
224 | CompanyLogo: companyData.Logo, | 212 | CompanyLogo: companyData.Logo, |
225 | Phone: userData.Account, | 213 | Phone: userData.Account, |
226 | Name: userData.Name, | 214 | Name: userData.Name, |
227 | - IsHrbp: isHrbp, | 215 | + IsHrbp: false, |
228 | 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 | ||
229 | } | 224 | } |
230 | if len(parentUser) > 0 { | 225 | if len(parentUser) > 0 { |
231 | 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 执行短信通知任务 |
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 | +// } |
@@ -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" |
@@ -119,6 +120,16 @@ func sendSummaryEvaluationByCycle(cycleParam *domain.EvaluationCycle) error { | @@ -119,6 +120,16 @@ func sendSummaryEvaluationByCycle(cycleParam *domain.EvaluationCycle) error { | ||
119 | return nil | 120 | return nil |
120 | } | 121 | } |
121 | 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 | + | ||
122 | // 下发周期综合评估 | 133 | // 下发周期综合评估 |
123 | type summaryEvaluationPublisher struct { | 134 | type summaryEvaluationPublisher struct { |
124 | userCache map[int64]*domain.User | 135 | userCache map[int64]*domain.User |
@@ -820,3 +820,43 @@ func (srv *SummaryEvaluationService) EditEvaluationHRBP(param *command.EditEvalu | @@ -820,3 +820,43 @@ 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 | + //TODO 只有超级管理员可以使用的功能 | ||
827 | + | ||
828 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
829 | + if err != nil { | ||
830 | + return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
831 | + } | ||
832 | + if err := transactionContext.StartTransaction(); err != nil { | ||
833 | + return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
834 | + } | ||
835 | + defer func() { | ||
836 | + _ = transactionContext.RollbackTransaction() | ||
837 | + }() | ||
838 | + //获取周期评估任务finish | ||
839 | + evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
840 | + _, evaluationList, err := evaluationRepo.Find(map[string]interface{}{ | ||
841 | + "id": []int{param.SummaryEvaluationId}, | ||
842 | + "companyId": param.CompanyId, | ||
843 | + }) | ||
844 | + if err != nil { | ||
845 | + return application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
846 | + } | ||
847 | + if len(evaluationList) == 0 { | ||
848 | + return nil | ||
849 | + } | ||
850 | + evaluationData := evaluationList[0] | ||
851 | + if evaluationData.Types != domain.EvaluationFinish { | ||
852 | + return nil | ||
853 | + } | ||
854 | + scoreStr := fmt.Sprintf("%.2f", param.Score) | ||
855 | + evaluationData.TotalScore = scoreStr | ||
856 | + evaluationData.Status = domain.EvaluationCompleted | ||
857 | + evaluationData.CheckResult = domain.EvaluationCheckCompleted | ||
858 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
859 | + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
860 | + } | ||
861 | + return nil | ||
862 | +} |
@@ -384,3 +384,17 @@ func (c *SummaryEvaluationController) SearchAssessRemark() { | @@ -384,3 +384,17 @@ 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 | + err = srv.ModifyFinishScore(param) | ||
399 | + c.Response(nil, err) | ||
400 | +} |
@@ -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), |
-
请 注册 或 登录 后发表评论