作者 Your Name

日常保存

  1 +package adapter
  2 +
  3 +import "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
  4 +
  5 +type AssessInviteUserResp struct {
  6 + LinkNodeId int `json:"linkNodeId"`
  7 + LinkNodeName string `json:"linkNodeName"`
  8 + BeginTime string `json:"beginTime"`
  9 + EndTime string `json:"endTime"`
  10 + AssessTaskId int `json:"assessTaskId"`
  11 + InviteSameSuper []domain.StaffDesc `json:"inviteSameSuper"`
  12 + InviteDiffSuper []domain.StaffDesc `json:"inviteDiffSuper"`
  13 +}
  1 +package command
  2 +
  3 +type CreateStaffAssessTask struct {
  4 + CompanyId int `json:"companyId"` //公司id
  5 + EvaluationProjectId int `json:"evaluationProjectId"` //项目id
  6 + EvaluationProjectName string `json:"evaluationProjectName"` //项目名称
  7 + CycleId int64 `json:"cycleId"` //对应的周期id
  8 + CycleName string `json:"cycleName"` //对应周期的名称
  9 + BeginTime string `json:"beginTime"` //绩效考核开始时间
  10 + EndTime string `json:"endTime"` //绩效考核截止时间
  11 + StepList []AssessTaskStep `json:"steps"` //考评的流程
  12 + ExecutorId []int `json:"executorId"` //参与此次考评的人
  13 +}
  14 +
  15 +type AssessTaskStep struct {
  16 + SortBy int `json:"sortBy"` //排序
  17 + LinkNodeId int `json:"linkNodeId"` //考评的流程id
  18 + LinkNodeName string `json:"linkNodeName"` //流程名称
  19 + LinkNodeType int `json:"linkNodeType"` //流程类型 同evaluation_template.go->LinkNode.Type
  20 + BeginTime string `json:"beginTime"` //绩效考核开始时间
  21 + EndTime string `json:"endTime"` //绩效考核截止时间
  22 +}
  1 +package command
  2 +
  3 +type SaveAssessInvite struct {
  4 + InviteSameSuper []string `json:"inviteSameSuper"` //相同上级同事
  5 + InviteDiffSuper []string `json:"inviteDiffSuper"` //不同上级同事
  6 + AssessTaskId int `json:"assessTaskId"` //评估任务id
  7 + TargetUserId int `json:"targetUserId"` //被评估的员工id
  8 +}
  1 +package query
  2 +
  3 +type GetAssessInviteUserQuery struct {
  4 + CompanyId int `json:"companyId"` //对公司
  5 + UsrId int `json:"usrId"` //被评估的员工id
  6 + AssessTaskId int `json:"assessTaskId"` //评估任务的id
  7 +}
@@ -2,11 +2,14 @@ package service @@ -2,11 +2,14 @@ package service
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
  5 + "strconv"
  6 + "time"
5 7
6 "github.com/linmadan/egglib-go/core/application" 8 "github.com/linmadan/egglib-go/core/application"
7 "github.com/linmadan/egglib-go/utils/tool_funs" 9 "github.com/linmadan/egglib-go/utils/tool_funs"
8 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" 10 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
9 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/adapter" 11 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/adapter"
  12 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/command"
10 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/query" 13 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/query"
11 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" 14 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
12 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log" 15 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log"
@@ -16,6 +19,11 @@ import ( @@ -16,6 +19,11 @@ import (
16 type StaffAssessServeice struct { 19 type StaffAssessServeice struct {
17 } 20 }
18 21
  22 +func NewStaffAssessServeice() *StaffAssessServeice {
  23 + newService := &StaffAssessServeice{}
  24 + return newService
  25 +}
  26 +
19 // 获取我参与过的评估任务列表 27 // 获取我参与过的评估任务列表
20 func (srv StaffAssessServeice) SearchAssessTaskMe(param *query.SearchAssessMeQuery) (map[string]interface{}, error) { 28 func (srv StaffAssessServeice) SearchAssessTaskMe(param *query.SearchAssessMeQuery) (map[string]interface{}, error) {
21 transactionContext, err := factory.CreateTransactionContext(nil) 29 transactionContext, err := factory.CreateTransactionContext(nil)
@@ -70,7 +78,7 @@ func (srv StaffAssessServeice) SearchAssessTaskMe(param *query.SearchAssessMeQue @@ -70,7 +78,7 @@ func (srv StaffAssessServeice) SearchAssessTaskMe(param *query.SearchAssessMeQue
70 } 78 }
71 79
72 // 获取项目评估进度描述 80 // 获取项目评估进度描述
73 -func (srv StaffAssessServeice) AssessTaskDesc(param query.AssessTaskDescQuery) (*adapter.AssessTaskDescResp, error) { 81 +func (srv StaffAssessServeice) AssessTaskDesc(param *query.AssessTaskDescQuery) (*adapter.AssessTaskDescResp, error) {
74 transactionContext, err := factory.CreateTransactionContext(nil) 82 transactionContext, err := factory.CreateTransactionContext(nil)
75 if err != nil { 83 if err != nil {
76 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 84 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -204,7 +212,7 @@ func (srv StaffAssessServeice) AssessTaskDesc(param query.AssessTaskDescQuery) ( @@ -204,7 +212,7 @@ func (srv StaffAssessServeice) AssessTaskDesc(param query.AssessTaskDescQuery) (
204 } 212 }
205 213
206 // 获取个人的自评反馈历史记录列表 214 // 获取个人的自评反馈历史记录列表
207 -func (srv StaffAssessServeice) AssessSelfList(param query.AssessSelfListQuery) (map[string]interface{}, error) { 215 +func (srv StaffAssessServeice) AssessSelfList(param *query.AssessSelfListQuery) (map[string]interface{}, error) {
208 transactionContext, err := factory.CreateTransactionContext(nil) 216 transactionContext, err := factory.CreateTransactionContext(nil)
209 if err != nil { 217 if err != nil {
210 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 218 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -321,25 +329,419 @@ func (srv StaffAssessServeice) AssessSelfList(param query.AssessSelfListQuery) ( @@ -321,25 +329,419 @@ func (srv StaffAssessServeice) AssessSelfList(param query.AssessSelfListQuery) (
321 } 329 }
322 330
323 // 更具项目评估的配置,创建员工的评估任务 331 // 更具项目评估的配置,创建员工的评估任务
324 -func (srv StaffAssessServeice) CreateStaffAssessTask() error { 332 +func (srv StaffAssessServeice) CreateStaffAssessTask(param *command.CreateStaffAssessTask) (map[string]interface{}, error) {
  333 +
  334 + transactionContext, err := factory.CreateTransactionContext(nil)
  335 + if err != nil {
  336 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  337 + }
  338 + if err := transactionContext.StartTransaction(); err != nil {
  339 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  340 + }
  341 + defer func() {
  342 + _ = transactionContext.RollbackTransaction()
  343 + }()
  344 +
  345 + taskBeginTime, err := time.ParseInLocation("2006-01-02 15:04:05", param.BeginTime, time.Local)
  346 + if err != nil {
  347 + return nil, application.ThrowError(application.ARG_ERROR, "任务开始时间填写错误,"+param.BeginTime)
  348 + }
  349 + taskEndTime, err := time.ParseInLocation("2006-01-02 15:04:05", param.EndTime, time.Local)
  350 + if err != nil {
  351 + return nil, application.ThrowError(application.ARG_ERROR, "任务结束时间填写错误,"+param.EndTime)
  352 + }
  353 + nowTime := time.Now()
  354 + //建立评估任务
  355 + assessTask := domain.StaffAssessTask{
  356 + Id: 0,
  357 + CompanyId: param.CompanyId,
  358 + EvaluationProjectId: param.EvaluationProjectId,
  359 + EvaluationProjectName: param.EvaluationProjectName,
  360 + CycleId: param.CycleId,
  361 + CycleName: param.CycleName,
  362 + BeginTime: taskBeginTime,
  363 + EndTime: taskEndTime,
  364 + StepList: []domain.AssessTaskStep{},
  365 + ExecutorId: nil,
  366 + CreatedAt: nowTime,
  367 + UpdatedAt: nowTime,
  368 + DeletedAt: nil,
  369 + }
  370 + //填充评估环节
  371 + for _, v := range param.StepList {
  372 + stepBeginTime, err := time.ParseInLocation("2006-01-02 15:04:05", param.BeginTime, time.Local)
  373 + if err != nil {
  374 + return nil, application.ThrowError(application.ARG_ERROR, "评估环节开始时间填写错误,"+param.BeginTime)
  375 + }
  376 + stepEndTime, err := time.ParseInLocation("2006-01-02 15:04:05", param.EndTime, time.Local)
  377 + if err != nil {
  378 + return nil, application.ThrowError(application.ARG_ERROR, "评估环节结束时间填写错误,"+param.EndTime)
  379 + }
  380 + step := domain.AssessTaskStep{
  381 + SortBy: v.SortBy,
  382 + LinkNodeId: v.LinkNodeId,
  383 + LinkNodeName: v.LinkNodeName,
  384 + LinkNodeType: v.LinkNodeType,
  385 + BeginTime: stepBeginTime,
  386 + EndTime: stepEndTime,
  387 + }
  388 + assessTask.StepList = append(assessTask.StepList, step)
  389 + }
  390 +
  391 + assessTaskRepo := factory.CreateStaffAssessTaskRepository(map[string]interface{}{
  392 + "transactionContext": transactionContext,
  393 + })
  394 + _, err = assessTaskRepo.Save(&assessTask)
  395 + if err != nil {
  396 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存评估任务"+err.Error())
  397 + }
  398 +
  399 + assessList, err := srv.createStaffAssess(transactionContext, &assessTask)
  400 + if err != nil {
  401 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "生成个人评估项"+err.Error())
  402 + }
  403 +
  404 + assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
  405 + "transactionContext": transactionContext,
  406 + })
  407 +
  408 + for i := range assessList {
  409 + _, err = assessRepo.Save(&assessList[i])
  410 + if err != nil {
  411 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存个人评估项"+err.Error())
  412 + }
  413 + }
  414 + if err := transactionContext.CommitTransaction(); err != nil {
  415 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  416 + }
  417 + return map[string]interface{}{
  418 + "assessTaskId": assessTask.Id,
  419 + }, nil
  420 +}
  421 +
  422 +// 添加自评节点任务
  423 +func (srv StaffAssessServeice) createStaffAssess(transactionContext application.TransactionContext, param *domain.StaffAssessTask) ([]domain.StaffAssess, error) {
  424 + //评估的参与人
  425 + selfUserId := []int{}
  426 + userIdMap := map[int]struct{}{} //过滤重复的用户
  427 + for _, v := range param.ExecutorId {
  428 + if _, ok := userIdMap[v]; ok {
  429 + continue
  430 + }
  431 + selfUserId = append(selfUserId, v)
  432 + }
  433 + // 获取用户的信息
  434 + if len(selfUserId) == 0 {
  435 + return nil, application.ThrowError(application.ARG_ERROR, "未填写评估任务的执行人")
  436 + }
  437 + userRepo := factory.CreateUserRepository(map[string]interface{}{
  438 + "transactionContext": transactionContext,
  439 + })
  440 + //获取员工信息
  441 + _, userList, err := userRepo.Find(map[string]interface{}{
  442 + "ids": selfUserId,
  443 + })
  444 + if err != nil {
  445 + return nil, application.ThrowError(application.ARG_ERROR, "获取员工信息"+err.Error())
  446 + }
  447 + departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{
  448 + "transactionContext": transactionContext,
  449 + })
  450 + //获取用户的部门
  451 + userDepartmentMap := map[int64][]*domain.Department{}
  452 + for _, v := range userList {
  453 + _, departmemtList, err := departmentRepo.Find(map[string]interface{}{
  454 + "ids": v.DepartmentId,
  455 + })
  456 + if err != nil {
  457 + return nil, application.ThrowError(application.ARG_ERROR, "获取员工的部门信息"+err.Error())
  458 + }
  459 + userDepartmentMap[v.Id] = departmemtList
  460 + }
  461 + assessList := []domain.StaffAssess{}
  462 + //数据样板
  463 + stepSelfTemp := domain.StaffAssess{
  464 + Id: 0,
  465 + CompanyId: param.CompanyId,
  466 + EvaluationProjectId: param.EvaluationProjectId,
  467 + EvaluationProjectName: param.EvaluationProjectName,
  468 + CycleId: param.CycleId,
  469 + CycleName: param.CycleName,
  470 + StaffAssessTaskId: param.Id,
  471 + // TargetUser: domain.StaffDesc{},
  472 + // TargetDepartment: nil,
  473 + // Executor: domain.StaffDesc{},
  474 + Types: domain.AssessSelf,
  475 + // LinkNodeId: v.LinkNodeId,
  476 + Status: domain.StaffAssessUncompleted,
  477 + // BeginTime: time.Time{},
  478 + // EndTime: time.Time{},
  479 + CreatedAt: param.CreatedAt,
  480 + UpdatedAt: param.UpdatedAt,
  481 + DeletedAt: nil,
  482 + }
  483 + for _, v := range param.StepList {
  484 + if v.LinkNodeType == domain.LinkNodeSelfAssessment {
  485 + //员工自评
  486 + stepSelfTemp.BeginTime = v.BeginTime
  487 + stepSelfTemp.EndTime = v.EndTime
  488 + stepSelfTemp.LinkNodeId = v.LinkNodeId
  489 + stepSelfTemp.LinkNodeName = v.LinkNodeName
  490 + assessListTemp := srv.createStaffAssessSelf(stepSelfTemp, userList, userDepartmentMap)
  491 + assessList = append(assessList, assessListTemp...)
  492 + }
  493 + if v.LinkNodeType == domain.LinkNodeSuperiorAssessment {
  494 + // TODO
  495 + stepSelfTemp.BeginTime = v.BeginTime
  496 + stepSelfTemp.EndTime = v.EndTime
  497 + stepSelfTemp.LinkNodeId = v.LinkNodeId
  498 + stepSelfTemp.LinkNodeName = v.LinkNodeName
  499 + assessListTemp, err := srv.createStaffAssessSupper(transactionContext, stepSelfTemp, userList, userDepartmentMap)
  500 + if err != nil {
  501 + return nil, err
  502 + }
  503 + assessList = append(assessList, assessListTemp...)
  504 + }
  505 + }
  506 + return assessList, nil
  507 +}
  508 +
  509 +// 构建员工自评
  510 +func (srv StaffAssessServeice) createStaffAssessSelf(assessTemp domain.StaffAssess,
  511 + userList []*domain.User, userDepartmentMap map[int64][]*domain.Department) []domain.StaffAssess {
  512 + result := []domain.StaffAssess{}
  513 + for _, usr := range userList {
  514 + assessTemp.TargetUser = domain.StaffDesc{
  515 + UserId: int(usr.Id),
  516 + Account: usr.Account,
  517 + UserName: usr.Account,
  518 + }
  519 + assessTemp.Executor = domain.StaffDesc{
  520 + UserId: int(usr.Id),
  521 + Account: usr.Account,
  522 + UserName: usr.Account,
  523 + }
  524 + if depList, ok := userDepartmentMap[usr.Id]; ok {
  525 + for _, dep := range depList {
  526 + assessTemp.TargetDepartment = append(assessTemp.TargetDepartment, domain.StaffDepartment{
  527 + DepartmentId: int(dep.Id),
  528 + DepartmentName: dep.Name,
  529 + })
  530 + }
  531 + }
  532 + result = append(result, assessTemp)
  533 + }
  534 + return result
  535 +}
  536 +
  537 +// 构建员工上级评估
  538 +func (srv StaffAssessServeice) createStaffAssessSupper(
  539 + transactionContext application.TransactionContext,
  540 + assessTemp domain.StaffAssess,
  541 + userList []*domain.User, userDepartmentMap map[int64][]*domain.Department,
  542 +) ([]domain.StaffAssess, error) {
  543 +
  544 + // 获取员工的上级用户
  545 +
  546 + return nil, nil
  547 +}
  548 +
  549 +// 获取某个员工360邀请的人员
  550 +func (srv StaffAssessServeice) GetAssessInviteUser(param *query.GetAssessInviteUserQuery) (*adapter.AssessInviteUserResp, error) {
325 transactionContext, err := factory.CreateTransactionContext(nil) 551 transactionContext, err := factory.CreateTransactionContext(nil)
326 if err != nil { 552 if err != nil {
327 - return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 553 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
328 } 554 }
329 if err := transactionContext.StartTransaction(); err != nil { 555 if err := transactionContext.StartTransaction(); err != nil {
330 - return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 556 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
331 } 557 }
332 defer func() { 558 defer func() {
333 _ = transactionContext.RollbackTransaction() 559 _ = transactionContext.RollbackTransaction()
334 }() 560 }()
335 561
  562 + assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{
  563 + "transactionContext": transactionContext,
  564 + })
  565 +
  566 + assessTaskReps := factory.CreateStaffAssessTaskRepository(map[string]interface{}{
  567 + "transactionContext": transactionContext,
  568 + })
  569 + assessTaskData, err := assessTaskReps.FindOne(map[string]interface{}{
  570 + "id": param.AssessTaskId,
  571 + })
  572 + if err != nil {
  573 + return nil, application.ThrowError(application.ARG_ERROR, "获取评估任务"+err.Error())
  574 + }
  575 + _, assessList, err := assessReps.Find(map[string]interface{}{
  576 + "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
  577 + "staffAssessTaskId": param.AssessTaskId,
  578 + "targetUserId": param.UsrId,
  579 + })
  580 + if err != nil {
  581 + return nil, application.ThrowError(application.ARG_ERROR, "获取个人评估任务"+err.Error())
  582 + }
336 if err := transactionContext.CommitTransaction(); err != nil { 583 if err := transactionContext.CommitTransaction(); err != nil {
337 - return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 584 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  585 + }
  586 +
  587 + result := adapter.AssessInviteUserResp{
  588 + AssessTaskId: assessTaskData.Id,
  589 + }
  590 + for _, v := range assessTaskData.StepList {
  591 + if v.LinkNodeType != domain.LinkNodeAllInvite {
  592 + continue
  593 + }
  594 + result.LinkNodeId = v.LinkNodeId
  595 + result.LinkNodeName = v.LinkNodeName
  596 + result.BeginTime = v.BeginTime.Local().Format("2006-01-02 15:04:05")
  597 + result.EndTime = v.EndTime.Local().Format("2006-01-02 15:04:05")
  598 + break
  599 + }
  600 + for _, v := range assessList {
  601 + if v.Types == domain.AssessInviteDiffSuper {
  602 + result.InviteDiffSuper = append(result.InviteDiffSuper, v.Executor)
  603 + }
  604 + if v.Types == domain.AssessInviteSameSuper {
  605 + result.InviteSameSuper = append(result.InviteDiffSuper, v.Executor)
  606 + }
338 } 607 }
339 - return nil 608 + return &result, nil
340 } 609 }
341 610
342 -// 获取员工自评详情  
343 -func (srv StaffAssessServeice) StaffAssessSelfInfo() { 611 +// 获取某个员工360邀请的人员
  612 +func (srv StaffAssessServeice) SaveAssessInviteUser(param *command.SaveAssessInvite) (*adapter.AssessInviteUserResp, error) {
  613 + inviteSameSuperId := []int{}
  614 + InviteDiffSuperId := []int{}
  615 + for _, v := range param.InviteDiffSuper {
  616 + id, err := strconv.Atoi(v)
  617 + if err != nil {
  618 + return nil, application.ThrowError(application.ARG_ERROR, "用户填写错误")
  619 + }
  620 + InviteDiffSuperId = append(InviteDiffSuperId, id)
  621 + }
  622 + for _, v := range param.InviteSameSuper {
  623 + id, err := strconv.Atoi(v)
  624 + if err != nil {
  625 + return nil, application.ThrowError(application.ARG_ERROR, "用户填写错误")
  626 + }
  627 + inviteSameSuperId = append(inviteSameSuperId, id)
  628 + }
  629 + transactionContext, err := factory.CreateTransactionContext(nil)
  630 + if err != nil {
  631 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  632 + }
  633 + if err := transactionContext.StartTransaction(); err != nil {
  634 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  635 + }
  636 + defer func() {
  637 + _ = transactionContext.RollbackTransaction()
  638 + }()
  639 +
  640 + assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{
  641 + "transactionContext": transactionContext,
  642 + })
  643 + userRepo := factory.CreateUserRepository(map[string]interface{}{
  644 + "transactionContext": transactionContext,
  645 + })
  646 + departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{
  647 + "transactionContext": transactionContext,
  648 + })
  649 +
  650 + assessTaskReps := factory.CreateStaffAssessTaskRepository(map[string]interface{}{
  651 + "transactionContext": transactionContext,
  652 + })
  653 + assessTaskData, err := assessTaskReps.FindOne(map[string]interface{}{
  654 + "id": param.AssessTaskId,
  655 + })
  656 + if err != nil {
  657 + return nil, application.ThrowError(application.ARG_ERROR, "获取评估任务"+err.Error())
  658 + }
  659 +
  660 + targetUser, err := userRepo.FindOne(map[string]interface{}{
  661 + "id": param.TargetUserId,
  662 + })
  663 + //被评估人的部门
  664 + var targetUserDepartment []domain.StaffDepartment
  665 + if len(targetUser.DepartmentId) > 0 {
  666 + _, departmentList, err := departmentRepo.Find(map[string]interface{}{
  667 + "ids": targetUser.DepartmentId,
  668 + })
  669 + if err != nil {
  670 + return nil, application.ThrowError(application.ARG_ERROR, "获取部门信息"+err.Error())
  671 + }
  672 + for _, v := range departmentList {
  673 + targetUserDepartment = append(targetUserDepartment, domain.StaffDepartment{
  674 + DepartmentId: int(v.Id),
  675 + DepartmentName: v.Name,
  676 + })
  677 + }
  678 + }
  679 + //相同上级的员工
  680 + var inviteSameSuper []domain.StaffDesc
  681 + if len(inviteSameSuperId) > 0 {
  682 + _, userList, err := userRepo.Find(map[string]interface{}{
  683 + "ids": inviteSameSuperId,
  684 + })
  685 + if err != nil {
  686 + return nil, application.ThrowError(application.ARG_ERROR, "获取用户信息"+err.Error())
  687 + }
  688 + for _, v := range userList {
  689 + inviteSameSuper = append(inviteSameSuper, domain.StaffDesc{
  690 + UserId: int(v.Id),
  691 + UserName: v.Name,
  692 + Account: v.Account,
  693 + })
  694 + }
  695 + }
  696 + var inviteDiffSuper []domain.StaffDesc
  697 + if len(InviteDiffSuperId) > 0 {
  698 + _, userList, err := userRepo.Find(map[string]interface{}{
  699 + "ids": inviteSameSuperId,
  700 + })
  701 + if err != nil {
  702 + return nil, application.ThrowError(application.ARG_ERROR, "获取用户信息"+err.Error())
  703 + }
  704 + for _, v := range userList {
  705 + inviteSameSuper = append(inviteSameSuper, domain.StaffDesc{
  706 + UserId: int(v.Id),
  707 + UserName: v.Name,
  708 + Account: v.Account,
  709 + })
  710 + }
  711 + }
  712 + // _, assessList, err := assessReps.Find(map[string]interface{}{
  713 + // "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
  714 + // "staffAssessTaskId": param.AssessTaskId,
  715 + // "targetUserId": param.TargetUserId,
  716 + // })
  717 + // if err != nil {
  718 + // return nil, application.ThrowError(application.ARG_ERROR, "获取个人评估任务"+err.Error())
  719 + // }
  720 +
  721 + if err := transactionContext.CommitTransaction(); err != nil {
  722 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  723 + }
344 724
  725 + result := adapter.AssessInviteUserResp{
  726 + AssessTaskId: assessTaskData.Id,
  727 + }
  728 + // for _, v := range assessTaskData.StepList {
  729 + // if v.LinkNodeType != domain.LinkNodeAllInvite {
  730 + // continue
  731 + // }
  732 + // result.LinkNodeId = v.LinkNodeId
  733 + // result.LinkNodeName = v.LinkNodeName
  734 + // result.BeginTime = v.BeginTime.Local().Format("2006-01-02 15:04:05")
  735 + // result.EndTime = v.EndTime.Local().Format("2006-01-02 15:04:05")
  736 + // break
  737 + // }
  738 + // for _, v := range assessList {
  739 + // if v.Types == domain.AssessInviteDiffSuper {
  740 + // result.InviteDiffSuper = append(result.InviteDiffSuper, v.Executor)
  741 + // }
  742 + // if v.Types == domain.AssessInviteSameSuper {
  743 + // result.InviteSameSuper = append(result.InviteDiffSuper, v.Executor)
  744 + // }
  745 + // }
  746 + return &result, nil
345 } 747 }
@@ -35,6 +35,7 @@ type StaffAssess struct { @@ -35,6 +35,7 @@ type StaffAssess struct {
35 Executor StaffDesc `json:"executor"` //填写评估的用户 35 Executor StaffDesc `json:"executor"` //填写评估的用户
36 Types StaffAssessType `json:"types"` //填写评估对应的类型 36 Types StaffAssessType `json:"types"` //填写评估对应的类型
37 LinkNodeId int `json:"linkNodeId"` //评估环节对应的id,用于调取评估模板 37 LinkNodeId int `json:"linkNodeId"` //评估环节对应的id,用于调取评估模板
  38 + LinkNodeName string `json:"linkNodeName"` //评估环节对应的id,用于调取评估模板
38 Status StaffAssessStatus `json:"status"` //评估的填写状态 39 Status StaffAssessStatus `json:"status"` //评估的填写状态
39 BeginTime time.Time `json:"beginTime"` //开始时间 40 BeginTime time.Time `json:"beginTime"` //开始时间
40 EndTime time.Time `json:"endTime"` //截止时间 41 EndTime time.Time `json:"endTime"` //截止时间
@@ -29,7 +29,7 @@ type StaffAssessTask struct { @@ -29,7 +29,7 @@ type StaffAssessTask struct {
29 ExecutorId []int `json:"executorId"` //参与此次考评的人 29 ExecutorId []int `json:"executorId"` //参与此次考评的人
30 CreatedAt time.Time `json:"createdAt"` //数据创建时间 30 CreatedAt time.Time `json:"createdAt"` //数据创建时间
31 UpdatedAt time.Time `json:"updatedAt"` //数据更新时间 31 UpdatedAt time.Time `json:"updatedAt"` //数据更新时间
32 - DeletedAt time.Time `json:"deletedAt"` //数据删除时间 32 + DeletedAt *time.Time `json:"deletedAt"` //数据删除时间
33 } 33 }
34 34
35 //考评的流程 35 //考评的流程
@@ -21,5 +21,5 @@ type StaffAssessTask struct { @@ -21,5 +21,5 @@ type StaffAssessTask struct {
21 EndTime time.Time //截止时间 21 EndTime time.Time //截止时间
22 CreatedAt time.Time //数据创建时间 22 CreatedAt time.Time //数据创建时间
23 UpdatedAt time.Time //数据更新时间 23 UpdatedAt time.Time //数据更新时间
24 - DeletedAt time.Time //数据删除时间 24 + DeletedAt *time.Time //数据删除时间
25 } 25 }
@@ -96,8 +96,7 @@ func (repo *DepartmentRepository) FindOne(queryOptions map[string]interface{}) ( @@ -96,8 +96,7 @@ func (repo *DepartmentRepository) FindOne(queryOptions map[string]interface{}) (
96 func (repo *DepartmentRepository) Find(queryOptions map[string]interface{}) (int, []*domain.Department, error) { 96 func (repo *DepartmentRepository) Find(queryOptions map[string]interface{}) (int, []*domain.Department, error) {
97 tx := repo.transactionContext.PgTx 97 tx := repo.transactionContext.PgTx
98 dparmentModel := []models.Department{} 98 dparmentModel := []models.Department{}
99 - query := tx.Model(&dparmentModel).  
100 - Limit(20) 99 + query := tx.Model(&dparmentModel).Where("delete_at isnull")
101 if v, ok := queryOptions["id"]; ok { 100 if v, ok := queryOptions["id"]; ok {
102 query.Where("id=?", v) 101 query.Where("id=?", v)
103 } 102 }
@@ -79,7 +79,7 @@ func (repo *UserRepository) Remove(userId []int64) error { @@ -79,7 +79,7 @@ func (repo *UserRepository) Remove(userId []int64) error {
79 func (repo *UserRepository) FindOne(queryOptions map[string]interface{}) (*domain.User, error) { 79 func (repo *UserRepository) FindOne(queryOptions map[string]interface{}) (*domain.User, error) {
80 tx := repo.transactionContext.PgTx 80 tx := repo.transactionContext.PgTx
81 userModel := models.User{} 81 userModel := models.User{}
82 - query := tx.Model(&userModel) 82 + query := tx.Model(&userModel).Where("delete_at isnull")
83 if v, ok := queryOptions["id"]; ok { 83 if v, ok := queryOptions["id"]; ok {
84 query.Where("id=?", v) 84 query.Where("id=?", v)
85 } 85 }
  1 +package controllers
  2 +
  3 +import (
  4 + "github.com/linmadan/egglib-go/core/application"
  5 + "github.com/linmadan/egglib-go/web/beego"
  6 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/command"
  7 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/query"
  8 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/service"
  9 +)
  10 +
  11 +type StaffAssessController struct {
  12 + beego.BaseController
  13 +}
  14 +
  15 +// 获取我的绩效任务列表
  16 +func (c *StaffAssessController) SearchAssessTaskMe() {
  17 + srv := service.NewStaffAssessServeice()
  18 + paramReq := &query.SearchAssessMeQuery{}
  19 + err := c.BindJSON(paramReq)
  20 + if err != nil {
  21 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  22 + c.Response(nil, e)
  23 + return
  24 + }
  25 + //TODO 获取当前用户信息
  26 + data, err := srv.SearchAssessTaskMe(paramReq)
  27 + c.Response(data, err)
  28 +}
  29 +
  30 +// 获取我的绩效任务各环节完成情况
  31 +func (c *StaffAssessController) AssessTaskMeDesc() {
  32 + srv := service.NewStaffAssessServeice()
  33 + paramReq := &query.AssessTaskDescQuery{}
  34 + err := c.BindJSON(paramReq)
  35 + if err != nil {
  36 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  37 + c.Response(nil, e)
  38 + return
  39 + }
  40 + //TODO 获取当前用户信息
  41 + data, err := srv.AssessTaskDesc(paramReq)
  42 + c.Response(data, err)
  43 +}
  44 +
  45 +// 获取个人的自评反馈历史记录列表
  46 +func (c *StaffAssessController) AssessSelfMeList() {
  47 + srv := service.NewStaffAssessServeice()
  48 + paramReq := &query.AssessSelfListQuery{}
  49 + err := c.BindJSON(paramReq)
  50 + if err != nil {
  51 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  52 + c.Response(nil, e)
  53 + return
  54 + }
  55 + //TODO 获取当前用户信息
  56 + data, err := srv.AssessSelfList(paramReq)
  57 + c.Response(data, err)
  58 +}
  59 +
  60 +// 更具项目评估的配置,创建员工的评估任务,(调试用)
  61 +func (c *StaffAssessController) CreateStaffAssessTask() {
  62 + srv := service.NewStaffAssessServeice()
  63 + paramReq := &command.CreateStaffAssessTask{}
  64 + err := c.BindJSON(paramReq)
  65 + if err != nil {
  66 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  67 + c.Response(nil, e)
  68 + return
  69 + }
  70 + //服务调用,实际由定时任务触发
  71 + data, err := srv.CreateStaffAssessTask(paramReq)
  72 + c.Response(data, err)
  73 +}