作者 tangxvhui

更新 周期列表菜单

@@ -3,6 +3,7 @@ package adapter @@ -3,6 +3,7 @@ package adapter
3 //综合评估的周期列表 3 //综合评估的周期列表
4 4
5 type CycleList struct { 5 type CycleList struct {
6 - CycleId int `json:"cycleId,string"` //周期id 6 + CycleId string `json:"cycleId"` //周期id
7 CycleName string `json:"cycleName"` // 7 CycleName string `json:"cycleName"` //
  8 + ExecutorId string `json:"executorId "`
8 } 9 }
  1 +package adapter
  2 +
  3 +type MenuList struct {
  4 + CycleId int `json:"cycleId,string"`
  5 + NodeName string `json:"nodeName"`
  6 + StatusName string `json:"statusName"`
  7 + Types string `json:"types"`
  8 + Child []MenuList `json:"child"`
  9 +}
  1 +package command
  2 +
  3 +// 获取周期列表
  4 +type QueryCycleList struct {
  5 + UserId int `json:"userId,string"`
  6 + PageSize int `json:"pageSize"`
  7 + PageNumber int `json:"pageNumber"`
  8 +}
  1 +package command
  2 +
  3 +// QueryMenuCommand
  4 +type QueryMenu struct {
  5 + CycleId int `json:"cycleId,string"`
  6 + UserId int `json:"userId,string"`
  7 +}
1 package service 1 package service
2 2
  3 +import (
  4 + "github.com/linmadan/egglib-go/core/application"
  5 + "github.com/linmadan/egglib-go/utils/tool_funs"
  6 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
  7 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/adapter"
  8 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/command"
  9 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
  10 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao"
  11 +)
  12 +
3 type SummaryEvaluationServeice struct { 13 type SummaryEvaluationServeice struct {
4 } 14 }
5 15
@@ -8,9 +18,218 @@ func NewStaffAssessServeice() *SummaryEvaluationServeice { @@ -8,9 +18,218 @@ func NewStaffAssessServeice() *SummaryEvaluationServeice {
8 return newService 18 return newService
9 } 19 }
10 20
  21 +// GetCycleList
11 // 获取周期列表 22 // 获取周期列表
12 -func (srv SummaryEvaluationServeice) GetCycleList() (map[string]interface{}, error) {  
13 - return nil, nil 23 +func (srv *SummaryEvaluationServeice) GetCycleList(param *command.QueryCycleList) (map[string]interface{}, error) {
  24 + transactionContext, err := factory.CreateTransactionContext(nil)
  25 + if err != nil {
  26 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  27 + }
  28 + if err := transactionContext.StartTransaction(); err != nil {
  29 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  30 + }
  31 + defer func() {
  32 + _ = transactionContext.RollbackTransaction()
  33 + }()
  34 + evaluationDao := dao.NewSummaryEvaluationDao(map[string]interface{}{
  35 + "transactionContext": transactionContext,
  36 + })
  37 + limit := 300
  38 + offset := 0
  39 + if param.PageSize > 0 {
  40 + limit = param.PageSize
  41 + }
  42 + if param.PageNumber > 0 {
  43 + offset = (param.PageNumber - 1) * param.PageSize
  44 + }
  45 +
  46 + cycleData, err := evaluationDao.GetPersonalCycleList(param.UserId, offset, limit)
  47 + if err != nil {
  48 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取周期列表"+err.Error())
  49 + }
  50 +
  51 + cnt, err := evaluationDao.CountPersonalCycleList(param.UserId)
  52 + if err != nil {
  53 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  54 + }
  55 + if err := transactionContext.CommitTransaction(); err != nil {
  56 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  57 + }
  58 + cycleList := []adapter.CycleList{}
  59 + for _, v := range cycleData {
  60 + m := adapter.CycleList{
  61 + CycleId: v.CycleId,
  62 + CycleName: v.CycleName,
  63 + ExecutorId: v.ExecutorId,
  64 + }
  65 + cycleList = append(cycleList, m)
  66 + }
  67 + return tool_funs.SimpleWrapGridMap(int64(cnt), cycleList), nil
14 } 68 }
15 69
16 -// 获取自评信息 70 +// GetMenu
  71 +// 根据周期获取菜单显示
  72 +func (srv *SummaryEvaluationServeice) GetMenu(param *command.QueryMenu) (map[string]interface{}, error) {
  73 + transactionContext, err := factory.CreateTransactionContext(nil)
  74 + if err != nil {
  75 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  76 + }
  77 + if err := transactionContext.StartTransaction(); err != nil {
  78 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  79 + }
  80 + defer func() {
  81 + _ = transactionContext.RollbackTransaction()
  82 + }()
  83 + evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{
  84 + "transactionContext": transactionContext,
  85 + })
  86 +
  87 + //查找我的绩效
  88 + _, selfEvaluation, err := evaluationRepo.Find(map[string]interface{}{
  89 + "types": int(domain.EvaluationSelf),
  90 + "executorId": param.UserId,
  91 + "limit": 1,
  92 + })
  93 + if err != nil {
  94 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  95 + }
  96 + //查找360评估,统计未完成的
  97 + cnt360, _, err := evaluationRepo.Find(map[string]interface{}{
  98 + "types": int(domain.Evaluation360),
  99 + "executorId": param.UserId,
  100 + "limit": 1,
  101 + "status": string(domain.EvaluationUncompleted),
  102 + })
  103 + if err != nil {
  104 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  105 + }
  106 + //查询上级评估,统计未完成
  107 + cntSuper, _, err := evaluationRepo.Find(map[string]interface{}{
  108 + "types": int(domain.EvaluationSelf),
  109 + "executorId": param.UserId,
  110 + "limit": 1,
  111 + "status": string(domain.EvaluationUncompleted),
  112 + })
  113 + if err != nil {
  114 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  115 + }
  116 + //查询人资评估,统计未完成
  117 + cntHrbp, _, err := evaluationRepo.Find(map[string]interface{}{
  118 + "types": int(domain.EvaluationHrbp),
  119 + "executorId": param.UserId,
  120 + "limit": 1,
  121 + "status": string(domain.EvaluationUncompleted),
  122 + })
  123 +
  124 + if err := transactionContext.CommitTransaction(); err != nil {
  125 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  126 + }
  127 +
  128 + menuList := []adapter.MenuList{}
  129 +
  130 + //模块-我的绩效
  131 + menu1 := adapter.MenuList{
  132 + CycleId: 0,
  133 + NodeName: "我的绩效",
  134 + StatusName: "",
  135 + Types: "",
  136 + Child: []adapter.MenuList{},
  137 + }
  138 + menu1_1 := adapter.MenuList{
  139 + CycleId: param.CycleId,
  140 + NodeName: "填写综合自评",
  141 + StatusName: "",
  142 + Types: "填写综合自评",
  143 + }
  144 + menu1_2 := adapter.MenuList{
  145 + CycleId: param.CycleId,
  146 + NodeName: "查看综合自评",
  147 + StatusName: "",
  148 + Types: "查看综合自评",
  149 + }
  150 + if len(selfEvaluation) > 0 {
  151 + if selfEvaluation[0].Status == domain.EvaluationCompleted {
  152 + menu1_1.StatusName = "已完成"
  153 + } else {
  154 + menu1_1.StatusName = "未完成"
  155 + }
  156 + if selfEvaluation[0].CheckResult == domain.EvaluationCheckCompleted {
  157 + menu1_2.StatusName = "已完成"
  158 + } else {
  159 + menu1_2.StatusName = "未完成"
  160 + }
  161 + }
  162 + menu1.Child = append(menu1.Child, menu1_1, menu1_2)
  163 + menuList = append(menuList, menu1)
  164 + menu2 := adapter.MenuList{
  165 + CycleId: 0,
  166 + NodeName: "给他人评估",
  167 + StatusName: "",
  168 + Types: "",
  169 + Child: []adapter.MenuList{},
  170 + }
  171 + menu2_1 := adapter.MenuList{
  172 + CycleId: param.CycleId,
  173 + NodeName: "360综评",
  174 + StatusName: "",
  175 + Types: "360综评",
  176 + }
  177 + if cnt360 > 0 {
  178 + menu2_1.StatusName = "未完成"
  179 + } else {
  180 + menu2_1.StatusName = "已完成"
  181 + }
  182 + menu2.Child = append(menu2.Child, menu2_1)
  183 + menuList = append(menuList, menu2)
  184 + menu3 := adapter.MenuList{
  185 + CycleId: 0,
  186 + NodeName: "人资评估",
  187 + StatusName: "",
  188 + Types: "",
  189 + Child: []adapter.MenuList{},
  190 + }
  191 + menu3_1 := adapter.MenuList{
  192 + CycleId: param.CycleId,
  193 + NodeName: "上级综评",
  194 + StatusName: "",
  195 + Types: "上级综评",
  196 + }
  197 + if cntHrbp > 0 {
  198 + menu3_1.StatusName = "未完成"
  199 + } else {
  200 + menu3_1.StatusName = "已完成"
  201 + }
  202 + menu3.Child = append(menu3.Child, menu3_1)
  203 +
  204 + menuList = append(menuList, menu3)
  205 + menu4 := adapter.MenuList{
  206 + CycleId: 0,
  207 + NodeName: "我的团队绩效",
  208 + StatusName: "",
  209 + Types: "",
  210 + Child: []adapter.MenuList{},
  211 + }
  212 + menu4_1 := adapter.MenuList{
  213 + CycleId: param.CycleId,
  214 + NodeName: "上级综评",
  215 + StatusName: "",
  216 + Types: "上级综评",
  217 + }
  218 + if cntSuper > 0 {
  219 + menu4_1.StatusName = "未完成"
  220 + } else {
  221 + menu4_1.StatusName = "已完成"
  222 + }
  223 + menu4.Child = append(menu4.Child, menu4_1)
  224 + menuList = append(menuList, menu4)
  225 + result := map[string]interface{}{
  226 + "menus": menuList,
  227 + }
  228 + return result, nil
  229 +}
  230 +
  231 +// 获取综合自评详情
  232 +func (srv *SummaryEvaluationServeice) GetEvaluationSelf() {}
  233 +
  234 +// 编辑综合自评详情
  235 +func (srv *SummaryEvaluationServeice) EditEvaluationSelf() {}
@@ -15,7 +15,7 @@ type SummaryEvaluation struct { @@ -15,7 +15,7 @@ type SummaryEvaluation struct {
15 Executor StaffDesc //填写评估的用户,执行人 15 Executor StaffDesc //填写评估的用户,执行人
16 Types EvaluationType //评估类型 16 Types EvaluationType //评估类型
17 Status EvaluationStatus //评估的填写状态 17 Status EvaluationStatus //评估的填写状态
18 - CheckResult int //被执行的人确认评估结果 18 + CheckResult EvaluationCheckResult //被执行的人确认评估结果
19 BeginTime time.Time //开始时间 19 BeginTime time.Time //开始时间
20 EndTime time.Time //截止时间 20 EndTime time.Time //截止时间
21 TotalScore string //最终上级评估得分. 21 TotalScore string //最终上级评估得分.
  1 +package dao
  2 +
  3 +import (
  4 + "github.com/go-pg/pg/v10"
  5 + pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
  6 +)
  7 +
  8 +type SummaryEvaluationDao struct {
  9 + transactionContext *pgTransaction.TransactionContext
  10 +}
  11 +
  12 +func NewSummaryEvaluationDao(options map[string]interface{}) *SummaryEvaluationDao {
  13 + var transactionContext *pgTransaction.TransactionContext
  14 + if value, ok := options["transactionContext"]; ok {
  15 + transactionContext = value.(*pgTransaction.TransactionContext)
  16 + }
  17 + return &SummaryEvaluationDao{
  18 + transactionContext: transactionContext,
  19 + }
  20 +}
  21 +
  22 +type PersonalCycle struct {
  23 + ExecutorId string `pg:"executor_id" ` //
  24 + CycleId string `pg:"cycle_id" ` //
  25 + CycleName string `pg:"cycle_name"` //
  26 +}
  27 +
  28 +// GetPersonalCycleList 获取执行人拥有的周期列表
  29 +func (d *SummaryEvaluationDao) GetPersonalCycleList(executorId int, offset int, limit int) ([]PersonalCycle, error) {
  30 + sqlStr := `select
  31 + distinct
  32 + summary_evaluation.cycle_id ,
  33 + summary_evaluation.cycle_name ,
  34 + summary_evaluation.executor ->>'userId' as executor_id
  35 + from summary_evaluation
  36 + where summary_evaluation.executor ->>'userId'='?'
  37 + offset ? limit ?`
  38 +
  39 + tx := d.transactionContext.PgTx
  40 + condition := []interface{}{
  41 + executorId, offset, limit,
  42 + }
  43 + result := []PersonalCycle{}
  44 + _, err := tx.Query(&result, sqlStr, condition...)
  45 + return result, err
  46 +}
  47 +
  48 +// CountPersonalCycleList 统计执行人拥有的周期列表
  49 +func (d *SummaryEvaluationDao) CountPersonalCycleList(executorId int) (int, error) {
  50 + sqlStr := `select count(
  51 + distinct summary_evaluation.cycle_id
  52 + ) as cnt
  53 + from summary_evaluation
  54 + where summary_evaluation.executor ->>'userId'='?' `
  55 +
  56 + tx := d.transactionContext.PgTx
  57 + condition := []interface{}{
  58 + executorId,
  59 + }
  60 + var cnt int
  61 + _, err := tx.QueryOne(pg.Scan(&cnt), sqlStr, condition...)
  62 + return cnt, err
  63 +}
@@ -46,6 +46,9 @@ func init() { @@ -46,6 +46,9 @@ func init() {
46 &models.StaffAssessTask{}, 46 &models.StaffAssessTask{},
47 &models.StaffAssessContent{}, 47 &models.StaffAssessContent{},
48 &models.StaffAssessCache{}, 48 &models.StaffAssessCache{},
  49 + &models.EvaluationItemUsed{},
  50 + &models.SummaryEvaluation{},
  51 + &models.SummaryEvaluationValue{},
49 } 52 }
50 for _, model := range tables { 53 for _, model := range tables {
51 err := DB.Model(model).CreateTable(&orm.CreateTableOptions{ 54 err := DB.Model(model).CreateTable(&orm.CreateTableOptions{
@@ -20,7 +20,7 @@ type SummaryEvaluation struct { @@ -20,7 +20,7 @@ type SummaryEvaluation struct {
20 Executor domain.StaffDesc //填写评估的用户,执行人 20 Executor domain.StaffDesc //填写评估的用户,执行人
21 Types int //评估类型 21 Types int //评估类型
22 Status string //评估的填写状态 22 Status string //评估的填写状态
23 - CheckResult int //被执行的人确认评估结果 23 + CheckResult string //被执行的人确认评估结果
24 BeginTime time.Time //开始时间 24 BeginTime time.Time //开始时间
25 EndTime time.Time //截止时间 25 EndTime time.Time //截止时间
26 TotalScore string //最终上级评估得分. 26 TotalScore string //最终上级评估得分.
@@ -4,7 +4,7 @@ import "time" @@ -4,7 +4,7 @@ import "time"
4 4
5 // 周期综合评估填写的内容 5 // 周期综合评估填写的内容
6 type SummaryEvaluationValue struct { 6 type SummaryEvaluationValue struct {
7 - tableName struct{} `comment:"周期综合评估填写的内容" pg:"summary_evaluation"` 7 + tableName struct{} `comment:"周期综合评估填写的内容" pg:"summary_evaluation_value"`
8 Id int // 8 Id int //
9 EvaluationItemId int //评估条目的id 9 EvaluationItemId int //评估条目的id
10 SummaryEvaluationId int //综合评估任务(SummaryEvaluation)的id 10 SummaryEvaluationId int //综合评估任务(SummaryEvaluation)的id
@@ -34,7 +34,7 @@ func (repo *SummaryEvaluationRepository) TransformToDomain(d *models.SummaryEval @@ -34,7 +34,7 @@ func (repo *SummaryEvaluationRepository) TransformToDomain(d *models.SummaryEval
34 Executor: d.Executor, 34 Executor: d.Executor,
35 Types: domain.EvaluationType(d.Types), 35 Types: domain.EvaluationType(d.Types),
36 Status: domain.EvaluationStatus(d.Status), 36 Status: domain.EvaluationStatus(d.Status),
37 - CheckResult: d.CheckResult, 37 + CheckResult: domain.EvaluationCheckResult(d.CheckResult),
38 BeginTime: d.BeginTime, 38 BeginTime: d.BeginTime,
39 EndTime: d.EndTime, 39 EndTime: d.EndTime,
40 TotalScore: d.TotalScore, 40 TotalScore: d.TotalScore,
@@ -57,7 +57,7 @@ func (repo *SummaryEvaluationRepository) Save(param *domain.SummaryEvaluation) e @@ -57,7 +57,7 @@ func (repo *SummaryEvaluationRepository) Save(param *domain.SummaryEvaluation) e
57 Executor: param.Executor, 57 Executor: param.Executor,
58 Types: int(param.Types), 58 Types: int(param.Types),
59 Status: string(param.Status), 59 Status: string(param.Status),
60 - CheckResult: param.CheckResult, 60 + CheckResult: string(param.CheckResult),
61 BeginTime: param.BeginTime, 61 BeginTime: param.BeginTime,
62 EndTime: param.EndTime, 62 EndTime: param.EndTime,
63 TotalScore: param.TotalScore, 63 TotalScore: param.TotalScore,
@@ -114,13 +114,33 @@ func (repo *SummaryEvaluationRepository) Find(queryOptions map[string]interface{ @@ -114,13 +114,33 @@ func (repo *SummaryEvaluationRepository) Find(queryOptions map[string]interface{
114 tx := repo.transactionContext.PgTx 114 tx := repo.transactionContext.PgTx
115 var m []*models.SummaryEvaluation 115 var m []*models.SummaryEvaluation
116 query := tx.Model(&m). 116 query := tx.Model(&m).
117 - Where("deleted_at isnull").Limit(20) 117 + Where("deleted_at isnull").
  118 + Limit(20)
  119 +
118 if v, ok := queryOptions["limit"].(int); ok { 120 if v, ok := queryOptions["limit"].(int); ok {
119 query.Limit(v) 121 query.Limit(v)
120 } 122 }
  123 +
121 if v, ok := queryOptions["offset"].(int); ok { 124 if v, ok := queryOptions["offset"].(int); ok {
122 query.Offset(v) 125 query.Offset(v)
123 } 126 }
  127 +
  128 + if v, ok := queryOptions["types"]; ok {
  129 + query.Where("types=?", v)
  130 + }
  131 +
  132 + if v, ok := queryOptions["status"]; ok {
  133 + query.Where("status=?", v)
  134 + }
  135 + if v, ok := queryOptions["targetUserId"]; ok {
  136 + query.Where(`summary_evaluation.target_user->>'userId'='?'`, v)
  137 + }
  138 +
  139 + if v, ok := queryOptions["executorId"]; ok {
  140 + query.Where(`summary_evaluation.executor->>'userId'='?'`, v)
  141 + }
  142 +
  143 + query.Order("id desc")
124 count, err := query.SelectAndCount() 144 count, err := query.SelectAndCount()
125 if err != nil { 145 if err != nil {
126 return 0, nil, err 146 return 0, nil, err