正在显示
11 个修改的文件
包含
301 行增加
和
53 行删除
| 1 | package main | 1 | package main |
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | - "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/constant" | ||
| 5 | "time" | 4 | "time" |
| 6 | 5 | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/constant" | ||
| 7 | + | ||
| 7 | "github.com/beego/beego/v2/server/web" | 8 | "github.com/beego/beego/v2/server/web" |
| 8 | serviceTask "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/node_task" | 9 | serviceTask "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/node_task" |
| 10 | + serviceSummary "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/service" | ||
| 9 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log" | 11 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log" |
| 10 | _ "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego" | 12 | _ "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego" |
| 11 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/consumer" | 13 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/consumer" |
| @@ -13,12 +15,7 @@ import ( | @@ -13,12 +15,7 @@ import ( | ||
| 13 | 15 | ||
| 14 | func main() { | 16 | func main() { |
| 15 | startNodeTask() | 17 | startNodeTask() |
| 16 | - | ||
| 17 | - // tree := web.PrintTree() | ||
| 18 | - // methods := tree["Data"].(web.M) | ||
| 19 | - // for k, v := range methods { | ||
| 20 | - // fmt.Printf("%s => %v \n", k, v) | ||
| 21 | - // } | 18 | + // startSummaryEvaluation() |
| 22 | go consumer.Run() | 19 | go consumer.Run() |
| 23 | web.Run() | 20 | web.Run() |
| 24 | } | 21 | } |
| @@ -44,3 +41,22 @@ func startNodeTask() { | @@ -44,3 +41,22 @@ func startNodeTask() { | ||
| 44 | } | 41 | } |
| 45 | }() | 42 | }() |
| 46 | } | 43 | } |
| 44 | + | ||
| 45 | +func startSummaryEvaluation() { | ||
| 46 | + go func() { | ||
| 47 | + duration := 10 * time.Minute | ||
| 48 | + if constant.Env != "prd" { | ||
| 49 | + duration = 1 * time.Minute | ||
| 50 | + } | ||
| 51 | + timer := time.NewTimer(duration) | ||
| 52 | + for { | ||
| 53 | + <-timer.C | ||
| 54 | + err := serviceSummary.TaskSendSummaryEvaluation() | ||
| 55 | + if err != nil { | ||
| 56 | + log.Logger.Error(err.Error()) | ||
| 57 | + } | ||
| 58 | + timer.Reset(duration) // 重置定时 | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + }() | ||
| 62 | +} |
| @@ -200,3 +200,11 @@ func CreatePermissionRepository(options map[string]interface{}) domain.Permissio | @@ -200,3 +200,11 @@ func CreatePermissionRepository(options map[string]interface{}) domain.Permissio | ||
| 200 | } | 200 | } |
| 201 | return repository.NewPermissionRepository(transactionContext) | 201 | return repository.NewPermissionRepository(transactionContext) |
| 202 | } | 202 | } |
| 203 | + | ||
| 204 | +func CreateLogSmsRepository(options map[string]interface{}) domain.LogSmsRepository { | ||
| 205 | + var transactionContext *pg.TransactionContext | ||
| 206 | + if value, ok := options["transactionContext"]; ok { | ||
| 207 | + transactionContext = value.(*pg.TransactionContext) | ||
| 208 | + } | ||
| 209 | + return repository.NewLogSmsRepository(transactionContext) | ||
| 210 | +} |
| 1 | package adapter | 1 | package adapter |
| 2 | 2 | ||
| 3 | type MenuListAdapter struct { | 3 | type MenuListAdapter struct { |
| 4 | - CycleId int `json:"cycleId,string"` | ||
| 5 | - NodeName string `json:"nodeName"` | ||
| 6 | - StatusName string `json:"statusName"` | ||
| 7 | - Types string `json:"types"` | ||
| 8 | - Child []MenuListAdapter `json:"child"` | 4 | + CycleId int `json:"cycleId,string"` |
| 5 | + NodeName string `json:"nodeName"` | ||
| 6 | + StatusName string `json:"statusName"` | ||
| 7 | + TargetUserId int `json:"targetUserId,string"` | ||
| 8 | + Types string `json:"types"` | ||
| 9 | + Child []MenuListAdapter `json:"child"` | ||
| 9 | } | 10 | } |
| @@ -5,6 +5,10 @@ import ( | @@ -5,6 +5,10 @@ import ( | ||
| 5 | "strconv" | 5 | "strconv" |
| 6 | "time" | 6 | "time" |
| 7 | 7 | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/constant" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/serviceGateway" | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log" | ||
| 11 | + | ||
| 8 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" | 12 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" |
| 9 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | 13 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" |
| 10 | ) | 14 | ) |
| @@ -13,7 +17,7 @@ import ( | @@ -13,7 +17,7 @@ import ( | ||
| 13 | // project 需要处理的项目 | 17 | // project 需要处理的项目 |
| 14 | // userList 全体的员工数据 map[id]=>domain.User | 18 | // userList 全体的员工数据 map[id]=>domain.User |
| 15 | // departmetList 全部的部门数据 map[id]=>domain.Department | 19 | // departmetList 全部的部门数据 map[id]=>domain.Department |
| 16 | -func sendSummaryEvaluation(project *domain.EvaluationProject, cycleData *domain.EvaluationCycle, | 20 | +func sendSummaryEvaluation(project *domain.EvaluationProject, |
| 17 | userMap map[int64]*domain.User, departmentMap map[int64]*domain.Department) ([]domain.SummaryEvaluation, error) { | 21 | userMap map[int64]*domain.User, departmentMap map[int64]*domain.Department) ([]domain.SummaryEvaluation, error) { |
| 18 | //自评的时间范围 | 22 | //自评的时间范围 |
| 19 | beginTimeSelf := project.EndTime | 23 | beginTimeSelf := project.EndTime |
| @@ -35,9 +39,14 @@ func sendSummaryEvaluation(project *domain.EvaluationProject, cycleData *domain. | @@ -35,9 +39,14 @@ func sendSummaryEvaluation(project *domain.EvaluationProject, cycleData *domain. | ||
| 35 | defer func() { | 39 | defer func() { |
| 36 | _ = transactionContext.RollbackTransaction() | 40 | _ = transactionContext.RollbackTransaction() |
| 37 | }() | 41 | }() |
| 42 | + cycleRepo := factory.CreateEvaluationCycleRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 38 | 43 | ||
| 39 | evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext}) | 44 | evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext}) |
| 40 | 45 | ||
| 46 | + cycleData, err := cycleRepo.FindOne(map[string]interface{}{"id": project.CycleId}) | ||
| 47 | + if err != nil { | ||
| 48 | + return nil, err | ||
| 49 | + } | ||
| 41 | //确定 被评估的人 | 50 | //确定 被评估的人 |
| 42 | targetUserId := []int64{} | 51 | targetUserId := []int64{} |
| 43 | for _, v := range project.Recipients { | 52 | for _, v := range project.Recipients { |
| @@ -209,7 +218,7 @@ func TaskSendSummaryEvaluation() error { | @@ -209,7 +218,7 @@ func TaskSendSummaryEvaluation() error { | ||
| 209 | 218 | ||
| 210 | userRepo := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext}) | 219 | userRepo := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext}) |
| 211 | 220 | ||
| 212 | - departmentRepo := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext}) | 221 | + departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{"transactionContext": transactionContext}) |
| 213 | 222 | ||
| 214 | _, projectList, err := projectRepo.Find(map[string]interface{}{ | 223 | _, projectList, err := projectRepo.Find(map[string]interface{}{ |
| 215 | "endTime": time.Now(), | 224 | "endTime": time.Now(), |
| @@ -223,24 +232,96 @@ func TaskSendSummaryEvaluation() error { | @@ -223,24 +232,96 @@ func TaskSendSummaryEvaluation() error { | ||
| 223 | for _, v := range projectList { | 232 | for _, v := range projectList { |
| 224 | companyIdMap[v.CompanyId] = struct{}{} | 233 | companyIdMap[v.CompanyId] = struct{}{} |
| 225 | } | 234 | } |
| 235 | + | ||
| 236 | + var createdEvalationList []domain.SummaryEvaluation | ||
| 237 | + | ||
| 226 | //获取可执行的项目 | 238 | //获取可执行的项目 |
| 227 | for companyId := range companyIdMap { | 239 | for companyId := range companyIdMap { |
| 228 | //获取员工数据,部门数据 | 240 | //获取员工数据,部门数据 |
| 229 | - | 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 | + } | ||
| 230 | for _, v := range projectList { | 260 | for _, v := range projectList { |
| 231 | if v.CompanyId != companyId { | 261 | if v.CompanyId != companyId { |
| 232 | continue | 262 | continue |
| 233 | } | 263 | } |
| 234 | - | 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...) | ||
| 235 | } | 270 | } |
| 236 | } | 271 | } |
| 237 | - //获取员工数据 | 272 | + if err := transactionContext.CommitTransaction(); err != nil { |
| 273 | + return err | ||
| 274 | + } | ||
| 275 | + //发送短信通知 | ||
| 276 | + err = sendSmsEvalation(createdEvalationList) | ||
| 277 | + return err | ||
| 278 | +} | ||
| 238 | 279 | ||
| 239 | - //获取部门数据 | 280 | +// 发送短信通知 |
| 281 | +func sendSmsEvalation(param []domain.SummaryEvaluation) error { | ||
| 282 | + if constant.Env != "prd" { | ||
| 283 | + return nil | ||
| 284 | + } | ||
| 285 | + //处理短信发送 | ||
| 286 | + //过滤去重 处理需要发送改执行人的消息 执行人id=>domain.LogSms | ||
| 287 | + noticeMap := map[string]*domain.LogSms{} | ||
| 288 | + for _, v := range param { | ||
| 289 | + phone := v.Executor.Account | ||
| 290 | + name := v.Executor.UserName | ||
| 291 | + if _, ok := noticeMap[phone]; ok { | ||
| 292 | + continue | ||
| 293 | + } | ||
| 294 | + smsMessage := domain.LogSms{} | ||
| 295 | + smsMessage.SummaryEvaluationMessage(phone, name) | ||
| 296 | + noticeMap[phone] = &smsMessage | ||
| 297 | + } | ||
| 240 | 298 | ||
| 299 | + sms := serviceGateway.SmsService{} | ||
| 300 | + for _, v := range noticeMap { | ||
| 301 | + err := sms.SendNoticeSms(v.Phone, v.TemplateId, v.Value) | ||
| 302 | + if err != nil { | ||
| 303 | + v.Result = err.Error() | ||
| 304 | + } | ||
| 305 | + } | ||
| 306 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
| 307 | + if err != nil { | ||
| 308 | + return err | ||
| 309 | + } | ||
| 310 | + if err := transactionContext.StartTransaction(); err != nil { | ||
| 311 | + return err | ||
| 312 | + } | ||
| 313 | + defer func() { | ||
| 314 | + _ = transactionContext.RollbackTransaction() | ||
| 315 | + }() | ||
| 316 | + logSmsRepo := factory.CreateLogSmsRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 317 | + for _, v := range noticeMap { | ||
| 318 | + err = logSmsRepo.Insert(v) | ||
| 319 | + if err != nil { | ||
| 320 | + log.Logger.Error("TaskSendSummaryEvaluation 发送短信通知:" + err.Error()) | ||
| 321 | + } | ||
| 322 | + } | ||
| 241 | if err := transactionContext.CommitTransaction(); err != nil { | 323 | if err := transactionContext.CommitTransaction(); err != nil { |
| 242 | return err | 324 | return err |
| 243 | } | 325 | } |
| 244 | - | ||
| 245 | return nil | 326 | return nil |
| 246 | } | 327 | } |
| @@ -132,6 +132,7 @@ func (srv *SummaryEvaluationService) GetMenu(param *command.QueryMenu) (map[stri | @@ -132,6 +132,7 @@ func (srv *SummaryEvaluationService) GetMenu(param *command.QueryMenu) (map[stri | ||
| 132 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 132 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 133 | } | 133 | } |
| 134 | 134 | ||
| 135 | + //查找当前周期,我的考核结果,人资评估 | ||
| 135 | if err := transactionContext.CommitTransaction(); err != nil { | 136 | if err := transactionContext.CommitTransaction(); err != nil { |
| 136 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 137 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 137 | } | 138 | } |
| @@ -147,16 +148,18 @@ func (srv *SummaryEvaluationService) GetMenu(param *command.QueryMenu) (map[stri | @@ -147,16 +148,18 @@ func (srv *SummaryEvaluationService) GetMenu(param *command.QueryMenu) (map[stri | ||
| 147 | Child: []adapter.MenuListAdapter{}, | 148 | Child: []adapter.MenuListAdapter{}, |
| 148 | } | 149 | } |
| 149 | menu1_1 := adapter.MenuListAdapter{ | 150 | menu1_1 := adapter.MenuListAdapter{ |
| 150 | - CycleId: param.CycleId, | ||
| 151 | - NodeName: "填写综合自评", | ||
| 152 | - StatusName: "", | ||
| 153 | - Types: "填写综合自评", | 151 | + CycleId: param.CycleId, |
| 152 | + NodeName: "填写综合自评", | ||
| 153 | + StatusName: "", | ||
| 154 | + TargetUserId: param.UserId, | ||
| 155 | + Types: "填写综合自评", | ||
| 154 | } | 156 | } |
| 155 | menu1_2 := adapter.MenuListAdapter{ | 157 | menu1_2 := adapter.MenuListAdapter{ |
| 156 | - CycleId: param.CycleId, | ||
| 157 | - NodeName: "查看综合自评", | ||
| 158 | - StatusName: "", | ||
| 159 | - Types: "查看综合自评", | 158 | + CycleId: param.CycleId, |
| 159 | + NodeName: "查看综合自评", | ||
| 160 | + StatusName: "", | ||
| 161 | + TargetUserId: param.UserId, | ||
| 162 | + Types: "查看综合自评", | ||
| 160 | } | 163 | } |
| 161 | if len(selfEvaluation) > 0 { | 164 | if len(selfEvaluation) > 0 { |
| 162 | if selfEvaluation[0].Status == domain.EvaluationCompleted { | 165 | if selfEvaluation[0].Status == domain.EvaluationCompleted { |
| @@ -277,8 +280,8 @@ func (srv *SummaryEvaluationService) buildSummaryItemValue(itemList []*domain.Ev | @@ -277,8 +280,8 @@ func (srv *SummaryEvaluationService) buildSummaryItemValue(itemList []*domain.Ev | ||
| 277 | return itemValues | 280 | return itemValues |
| 278 | } | 281 | } |
| 279 | 282 | ||
| 280 | -// 获取综合自评详情 | ||
| 281 | -func (srv *SummaryEvaluationService) GetEvaluationSelf(param *command.QueryEvaluation) (*adapter.EvaluationInfoSelfAdapter, error) { | 283 | +// 根据周期id和被评估人获取综合自评详情 |
| 284 | +func (srv *SummaryEvaluationService) GetEvaluationSelfByCycle(param *command.QueryEvaluation) (*adapter.EvaluationInfoSelfAdapter, error) { | ||
| 282 | transactionContext, err := factory.CreateTransactionContext(nil) | 285 | transactionContext, err := factory.CreateTransactionContext(nil) |
| 283 | if err != nil { | 286 | if err != nil { |
| 284 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 287 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
| @@ -753,28 +756,28 @@ func (srv *SummaryEvaluationService) GetEvaluationSuper(param *command.QueryEval | @@ -753,28 +756,28 @@ func (srv *SummaryEvaluationService) GetEvaluationSuper(param *command.QueryEval | ||
| 753 | } | 756 | } |
| 754 | //组合 评估填写的值和评估项 | 757 | //组合 评估填写的值和评估项 |
| 755 | itemValuesAdapter := srv.buildSummaryItemValue(itemList, itemValues) | 758 | itemValuesAdapter := srv.buildSummaryItemValue(itemList, itemValues) |
| 756 | - codeList := []*adapter.LevalCodeCount{} | ||
| 757 | - codeMap := map[string]*adapter.LevalCodeCount{} | ||
| 758 | - for _, v := range itemValuesAdapter { | ||
| 759 | - if v.Weight > 0 { | ||
| 760 | - continue | ||
| 761 | - } | ||
| 762 | - if _, ok := codeMap[v.Value]; !ok { | ||
| 763 | - code := &adapter.LevalCodeCount{ | ||
| 764 | - Code: v.Value, | ||
| 765 | - Number: 0, | ||
| 766 | - ItemList: []string{}, | ||
| 767 | - } | ||
| 768 | - codeMap[v.Value] = code | ||
| 769 | - codeList = append(codeList, code) | ||
| 770 | - } | ||
| 771 | - codeMap[v.Value].ItemList = append(codeMap[v.Value].ItemList, v.Name) | ||
| 772 | - codeMap[v.Value].Number += 1 | ||
| 773 | - } | 759 | + // codeList := []*adapter.LevalCodeCount{} |
| 760 | + // codeMap := map[string]*adapter.LevalCodeCount{} | ||
| 761 | + // for _, v := range itemValuesAdapter { | ||
| 762 | + // if v.Weight > 0 { | ||
| 763 | + // continue | ||
| 764 | + // } | ||
| 765 | + // if _, ok := codeMap[v.Value]; !ok { | ||
| 766 | + // code := &adapter.LevalCodeCount{ | ||
| 767 | + // Code: v.Value, | ||
| 768 | + // Number: 0, | ||
| 769 | + // ItemList: []string{}, | ||
| 770 | + // } | ||
| 771 | + // codeMap[v.Value] = code | ||
| 772 | + // codeList = append(codeList, code) | ||
| 773 | + // } | ||
| 774 | + // codeMap[v.Value].ItemList = append(codeMap[v.Value].ItemList, v.Name) | ||
| 775 | + // codeMap[v.Value].Number += 1 | ||
| 776 | + // } | ||
| 774 | result := adapter.EvaluationInfoSuperAdapter{ | 777 | result := adapter.EvaluationInfoSuperAdapter{ |
| 775 | EvaluationBaseAdapter: evaluationBase, | 778 | EvaluationBaseAdapter: evaluationBase, |
| 776 | - LevelCount: codeList, | ||
| 777 | - EvaluationItems: itemValuesAdapter, | 779 | + // LevelCount: codeList, |
| 780 | + EvaluationItems: itemValuesAdapter, | ||
| 778 | } | 781 | } |
| 779 | return &result, nil | 782 | return &result, nil |
| 780 | } | 783 | } |
| @@ -1184,3 +1187,118 @@ func (srv *SummaryEvaluationService) ConfirmScoreSuperEvaluation(param *command. | @@ -1184,3 +1187,118 @@ func (srv *SummaryEvaluationService) ConfirmScoreSuperEvaluation(param *command. | ||
| 1184 | } | 1187 | } |
| 1185 | return nil | 1188 | return nil |
| 1186 | } | 1189 | } |
| 1190 | + | ||
| 1191 | +// 按照周期和被评估的人 获取上级评估详情 | ||
| 1192 | +func (srv *SummaryEvaluationService) GetTargetUserEvaluationSuper(param *command.QueryEvaluation) (*adapter.EvaluationInfoSuperAdapter, error) { | ||
| 1193 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
| 1194 | + if err != nil { | ||
| 1195 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 1196 | + } | ||
| 1197 | + if err := transactionContext.StartTransaction(); err != nil { | ||
| 1198 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 1199 | + } | ||
| 1200 | + defer func() { | ||
| 1201 | + _ = transactionContext.RollbackTransaction() | ||
| 1202 | + }() | ||
| 1203 | + evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{ | ||
| 1204 | + "transactionContext": transactionContext, | ||
| 1205 | + }) | ||
| 1206 | + evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{ | ||
| 1207 | + "transactionContext": transactionContext, | ||
| 1208 | + }) | ||
| 1209 | + itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{ | ||
| 1210 | + "transactionContext": transactionContext, | ||
| 1211 | + }) | ||
| 1212 | + _, evaluationList, err := evaluationRepo.Find(map[string]interface{}{ | ||
| 1213 | + "limit": 1, | ||
| 1214 | + "cycleId": param.CycleId, | ||
| 1215 | + "executorId": param.UserId, | ||
| 1216 | + "types": domain.EvaluationSuper, | ||
| 1217 | + }) | ||
| 1218 | + if err != nil { | ||
| 1219 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 1220 | + } | ||
| 1221 | + if len(evaluationList) == 0 { | ||
| 1222 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有找到符合条件的数据") | ||
| 1223 | + } | ||
| 1224 | + evaluationData := evaluationList[0] | ||
| 1225 | + if evaluationData.Types == domain.EvaluationSuper { | ||
| 1226 | + return nil, application.ThrowError(application.BUSINESS_ERROR, "没有操作权限") | ||
| 1227 | + } | ||
| 1228 | + if evaluationData.CompanyId == param.CompanyId { | ||
| 1229 | + return nil, application.ThrowError(application.BUSINESS_ERROR, "没有操作权限") | ||
| 1230 | + } | ||
| 1231 | + _, itemList, err := evaluationItemRepo.Find(map[string]interface{}{ | ||
| 1232 | + "evaluationProjectId": evaluationData.EvaluationProjectId, | ||
| 1233 | + "nodeType": int(domain.LinkNodeSelfAssessment), | ||
| 1234 | + }) | ||
| 1235 | + if err != nil { | ||
| 1236 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 1237 | + } | ||
| 1238 | + //获取已填写的评估内容 | ||
| 1239 | + _, itemValues, err := itemValueRepo.Find(map[string]interface{}{ | ||
| 1240 | + "summaryEvaluationId": evaluationData.Id, | ||
| 1241 | + }) | ||
| 1242 | + | ||
| 1243 | + if err != nil { | ||
| 1244 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 1245 | + } | ||
| 1246 | + if len(itemValues) == 0 { | ||
| 1247 | + //上级还未填写评估,获取 360 ,人资评估 | ||
| 1248 | + _, evaluationListOther, err := evaluationRepo.Find(map[string]interface{}{ | ||
| 1249 | + "typesList": []int{int(domain.Evaluation360), int(domain.EvaluationHrbp)}, | ||
| 1250 | + "targetUserId": evaluationData.TargetUser.UserId, | ||
| 1251 | + "cycleId": evaluationData.CycleId, | ||
| 1252 | + }) | ||
| 1253 | + if err != nil { | ||
| 1254 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 1255 | + } | ||
| 1256 | + evaluationIds := []int{} | ||
| 1257 | + for _, v := range evaluationListOther { | ||
| 1258 | + evaluationIds = append(evaluationIds, v.Id) | ||
| 1259 | + } | ||
| 1260 | + if len(evaluationIds) > 0 { | ||
| 1261 | + _, itemValues, err = itemValueRepo.Find(map[string]interface{}{ | ||
| 1262 | + "summaryEvaluationIdList": evaluationIds, | ||
| 1263 | + }) | ||
| 1264 | + if err != nil { | ||
| 1265 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 1266 | + } | ||
| 1267 | + } | ||
| 1268 | + } | ||
| 1269 | + evaluationBase := srv.getSummaryEvaluation(transactionContext, evaluationData) | ||
| 1270 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
| 1271 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 1272 | + } | ||
| 1273 | + //组合 评估填写的值和评估项 | ||
| 1274 | + itemValuesAdapter := srv.buildSummaryItemValue(itemList, itemValues) | ||
| 1275 | + codeList := []*adapter.LevalCodeCount{} | ||
| 1276 | + codeMap := map[string]*adapter.LevalCodeCount{} | ||
| 1277 | + for _, v := range itemValuesAdapter { | ||
| 1278 | + if v.Weight > 0 { | ||
| 1279 | + continue | ||
| 1280 | + } | ||
| 1281 | + if _, ok := codeMap[v.Value]; !ok { | ||
| 1282 | + code := &adapter.LevalCodeCount{ | ||
| 1283 | + Code: v.Value, | ||
| 1284 | + Number: 0, | ||
| 1285 | + ItemList: []string{}, | ||
| 1286 | + } | ||
| 1287 | + codeMap[v.Value] = code | ||
| 1288 | + codeList = append(codeList, code) | ||
| 1289 | + } | ||
| 1290 | + codeMap[v.Value].ItemList = append(codeMap[v.Value].ItemList, v.Name) | ||
| 1291 | + codeMap[v.Value].Number += 1 | ||
| 1292 | + } | ||
| 1293 | + result := adapter.EvaluationInfoSuperAdapter{ | ||
| 1294 | + EvaluationBaseAdapter: evaluationBase, | ||
| 1295 | + LevelCount: codeList, | ||
| 1296 | + EvaluationItems: itemValuesAdapter, | ||
| 1297 | + } | ||
| 1298 | + return &result, nil | ||
| 1299 | +} | ||
| 1300 | + | ||
| 1301 | +// 获取周期综合评估下,周期评估列表 | ||
| 1302 | +func (srv *SummaryEvaluationService) ListEvalationSuper() (map[int]interface{}, error) { | ||
| 1303 | + return nil, nil | ||
| 1304 | +} |
| @@ -7,9 +7,10 @@ import "time" | @@ -7,9 +7,10 @@ import "time" | ||
| 7 | type LogSms struct { | 7 | type LogSms struct { |
| 8 | Id int | 8 | Id int |
| 9 | Phone string | 9 | Phone string |
| 10 | - TemplateId string | 10 | + TemplateId int |
| 11 | Template string | 11 | Template string |
| 12 | Value map[string]string | 12 | Value map[string]string |
| 13 | + Result string | ||
| 13 | CreatedAt time.Time | 14 | CreatedAt time.Time |
| 14 | } | 15 | } |
| 15 | 16 | ||
| @@ -18,7 +19,7 @@ func (sms *LogSms) SummaryEvaluationMessage(phone string, name string) { | @@ -18,7 +19,7 @@ func (sms *LogSms) SummaryEvaluationMessage(phone string, name string) { | ||
| 18 | *sms = LogSms{ | 19 | *sms = LogSms{ |
| 19 | Id: 0, | 20 | Id: 0, |
| 20 | Phone: phone, | 21 | Phone: phone, |
| 21 | - TemplateId: "5475050", | 22 | + TemplateId: 5475050, |
| 22 | Template: "您好,#name#,百忙之中不要忘记填写今天的绩效自评反馈哦", | 23 | Template: "您好,#name#,百忙之中不要忘记填写今天的绩效自评反馈哦", |
| 23 | Value: map[string]string{ | 24 | Value: map[string]string{ |
| 24 | "name": name, | 25 | "name": name, |
| @@ -6,8 +6,9 @@ type LogSms struct { | @@ -6,8 +6,9 @@ type LogSms struct { | ||
| 6 | tableName struct{} `comment:"记录短信消息" pg:"log_sms"` | 6 | tableName struct{} `comment:"记录短信消息" pg:"log_sms"` |
| 7 | Id int `pg:",pk"` | 7 | Id int `pg:",pk"` |
| 8 | Phone string `pg:"phone"` | 8 | Phone string `pg:"phone"` |
| 9 | - TemplateId string `pg:"template_id"` | 9 | + TemplateId int `pg:"template_id"` |
| 10 | Template string `pg:"template"` | 10 | Template string `pg:"template"` |
| 11 | Value map[string]string `pg:"value"` | 11 | Value map[string]string `pg:"value"` |
| 12 | CreatedAt time.Time `pg:"createdAt"` | 12 | CreatedAt time.Time `pg:"createdAt"` |
| 13 | + Result string `pg:"result"` | ||
| 13 | } | 14 | } |
| @@ -105,6 +105,9 @@ func (repo *DepartmentRepository) Find(queryOptions map[string]interface{}) (int | @@ -105,6 +105,9 @@ func (repo *DepartmentRepository) Find(queryOptions map[string]interface{}) (int | ||
| 105 | if v, ok := queryOptions["offset"]; ok { | 105 | if v, ok := queryOptions["offset"]; ok { |
| 106 | query.Offset(v.(int)) | 106 | query.Offset(v.(int)) |
| 107 | } | 107 | } |
| 108 | + if v, ok := queryOptions["companyId"]; ok { | ||
| 109 | + query.Where("company_id = ?", v) | ||
| 110 | + } | ||
| 108 | cnt, err := query.SelectAndCount() | 111 | cnt, err := query.SelectAndCount() |
| 109 | if err != nil { | 112 | if err != nil { |
| 110 | return 0, nil, err | 113 | return 0, nil, err |
| @@ -24,6 +24,7 @@ func (repo *LogSmsRepository) Insert(param *domain.LogSms) error { | @@ -24,6 +24,7 @@ func (repo *LogSmsRepository) Insert(param *domain.LogSms) error { | ||
| 24 | Template: param.Template, | 24 | Template: param.Template, |
| 25 | Value: param.Value, | 25 | Value: param.Value, |
| 26 | CreatedAt: param.CreatedAt, | 26 | CreatedAt: param.CreatedAt, |
| 27 | + Result: param.Result, | ||
| 27 | } | 28 | } |
| 28 | tx := repo.transactionContext.PgTx | 29 | tx := repo.transactionContext.PgTx |
| 29 | _, err := tx.Model(&m).Insert() | 30 | _, err := tx.Model(&m).Insert() |
| @@ -44,6 +44,7 @@ func (c *SummaryEvaluationController) GetMenu() { | @@ -44,6 +44,7 @@ func (c *SummaryEvaluationController) GetMenu() { | ||
| 44 | 44 | ||
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | +// 获取自评详情 | ||
| 47 | func (c *SummaryEvaluationController) GetEvaluationSelf() { | 48 | func (c *SummaryEvaluationController) GetEvaluationSelf() { |
| 48 | srv := service.NewSummaryEvaluationService() | 49 | srv := service.NewSummaryEvaluationService() |
| 49 | paramReq := &command.QueryEvaluation{} | 50 | paramReq := &command.QueryEvaluation{} |
| @@ -56,7 +57,7 @@ func (c *SummaryEvaluationController) GetEvaluationSelf() { | @@ -56,7 +57,7 @@ func (c *SummaryEvaluationController) GetEvaluationSelf() { | ||
| 56 | userReq := middlewares.GetUser(c.Ctx) | 57 | userReq := middlewares.GetUser(c.Ctx) |
| 57 | paramReq.CompanyId = int(userReq.CompanyId) | 58 | paramReq.CompanyId = int(userReq.CompanyId) |
| 58 | paramReq.UserId = int(userReq.UserId) | 59 | paramReq.UserId = int(userReq.UserId) |
| 59 | - data, err := srv.GetEvaluationSelf(paramReq) | 60 | + data, err := srv.GetEvaluationSelfByCycle(paramReq) |
| 60 | c.Response(data, err) | 61 | c.Response(data, err) |
| 61 | 62 | ||
| 62 | } | 63 | } |
| @@ -240,3 +241,19 @@ func (c *SummaryEvaluationController) ConfirmScoreSuperEvaluation() { | @@ -240,3 +241,19 @@ func (c *SummaryEvaluationController) ConfirmScoreSuperEvaluation() { | ||
| 240 | err = srv.ConfirmScoreSuperEvaluation(param) | 241 | err = srv.ConfirmScoreSuperEvaluation(param) |
| 241 | c.Response(nil, err) | 242 | c.Response(nil, err) |
| 242 | } | 243 | } |
| 244 | + | ||
| 245 | +// GetTargetUserEvaluationSuper 根据被评估人和周期获取 上级评估 | ||
| 246 | +func (c *SummaryEvaluationController) GetTargetUserEvaluationSuper() { | ||
| 247 | + srv := service.NewSummaryEvaluationService() | ||
| 248 | + paramReq := &command.QueryEvaluation{} | ||
| 249 | + err := c.BindJSON(paramReq) | ||
| 250 | + if err != nil { | ||
| 251 | + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error()) | ||
| 252 | + c.Response(nil, e) | ||
| 253 | + return | ||
| 254 | + } | ||
| 255 | + userReq := middlewares.GetUser(c.Ctx) | ||
| 256 | + paramReq.UserId = int(userReq.UserId) | ||
| 257 | + data, err := srv.GetTargetUserEvaluationSuper(paramReq) | ||
| 258 | + c.Response(data, err) | ||
| 259 | +} |
| @@ -24,6 +24,7 @@ func init() { | @@ -24,6 +24,7 @@ func init() { | ||
| 24 | web.NSCtrlPost("/evaluation-super/edit", (*controllers.SummaryEvaluationController).EditEvaluationSuper), | 24 | web.NSCtrlPost("/evaluation-super/edit", (*controllers.SummaryEvaluationController).EditEvaluationSuper), |
| 25 | web.NSCtrlPost("/evaluation-super/list", (*controllers.SummaryEvaluationController).ListEvaluationSuper), | 25 | web.NSCtrlPost("/evaluation-super/list", (*controllers.SummaryEvaluationController).ListEvaluationSuper), |
| 26 | web.NSCtrlPost("/evaluation-super/confirm", (*controllers.SummaryEvaluationController).ConfirmScoreSuperEvaluation), | 26 | web.NSCtrlPost("/evaluation-super/confirm", (*controllers.SummaryEvaluationController).ConfirmScoreSuperEvaluation), |
| 27 | + web.NSCtrlPost("/target_user/evaluation-super", (*controllers.SummaryEvaluationController).GetTargetUserEvaluationSuper), | ||
| 27 | // | 28 | // |
| 28 | ) | 29 | ) |
| 29 | web.AddNamespace(summaryNS) | 30 | web.AddNamespace(summaryNS) |
-
请 注册 或 登录 后发表评论