作者 tangxvhui

Merge branch 'test'

正在显示 39 个修改的文件 包含 1219 行增加296 行删除
@@ -8,7 +8,7 @@ prod 环境 http://performance-back-prd.fjmaimaimai.com/ @@ -8,7 +8,7 @@ prod 环境 http://performance-back-prd.fjmaimaimai.com/
8 前端页面地址 8 前端页面地址
9 test环境 https://enterprise-platform-dev.fjmaimaimai.com/#/login 9 test环境 https://enterprise-platform-dev.fjmaimaimai.com/#/login
10 10
11 -测试账号 17708397664 密码123456 11 +测试账号 17708397664 密码 123456
12 12
13 13
14 短信模板ID:5475050 短信内容: 您好,#name#,百忙之中不要忘记填写今天的绩效自评反馈哦 14 短信模板ID:5475050 短信内容: 您好,#name#,百忙之中不要忘记填写今天的绩效自评反馈哦
  1 +package adapter
  2 +
  3 +type MeInfo struct {
  4 + UserId int64 `json:"userId"` //用户名称
  5 + CompanyId int64 `json:"companyId"` //公司id
  6 + CompanyName string `json:"companyName"` //公司名称
  7 + Phone string `json:"phone"` // 手机号
  8 + Name string `json:"name"` // 员工名称
  9 + IsHrbp bool `json:"isHrbp"` //是否 是hrbp
  10 + IsParent bool `json:"isParent"` //是否 是上级
  11 +}
  1 +package command
  2 +
  3 +type GetMeInfo struct {
  4 + UserId int64 `json:"-"`
  5 + CompanyId int64 `json:"-"`
  6 +}
@@ -2,6 +2,7 @@ package service @@ -2,6 +2,7 @@ package service
2 2
3 import ( 3 import (
4 "github.com/linmadan/egglib-go/core/application" 4 "github.com/linmadan/egglib-go/core/application"
  5 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/auth/adapter"
5 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/auth/command" 6 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/auth/command"
6 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" 7 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
7 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/constant" 8 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/constant"
@@ -156,3 +157,78 @@ func (service *AuthService) MobileLogin(param *command.MobileLoginCommand) (map[ @@ -156,3 +157,78 @@ func (service *AuthService) MobileLogin(param *command.MobileLoginCommand) (map[
156 } 157 }
157 return result, nil 158 return result, nil
158 } 159 }
  160 +
  161 +// 获取我的
  162 +func (service *AuthService) MeInfo(param *command.GetMeInfo) (map[string]interface{}, error) {
  163 +
  164 + transactionContext, err := factory.CreateTransactionContext(nil)
  165 + if err != nil {
  166 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  167 + }
  168 + if errStart := transactionContext.StartTransaction(); errStart != nil {
  169 + return nil, application.ThrowError(application.TRANSACTION_ERROR, errStart.Error())
  170 + }
  171 + defer func() {
  172 + _ = transactionContext.RollbackTransaction()
  173 + }()
  174 + userRepository := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext})
  175 + 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{}{
  179 + "id": param.UserId,
  180 + })
  181 + if err != nil {
  182 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工数据"+err.Error())
  183 + }
  184 + _, parentUser, err := userRepository.Find(map[string]interface{}{
  185 + "parentId": userData.Id,
  186 + "limit": 1,
  187 + })
  188 + if err != nil {
  189 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工数据"+err.Error())
  190 + }
  191 + companyData, err := companyRepository.FindOne(map[string]interface{}{
  192 + "id": param.CompanyId,
  193 + })
  194 + if err != nil {
  195 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取公司数据"+err.Error())
  196 + }
  197 + _, roleList, err := roleRepo.Find(map[string]interface{}{"type": domain.RoleTypeSystem, "companyId": param.CompanyId})
  198 + if err != nil {
  199 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取角色信息列表"+err.Error())
  200 + }
  201 + _, userRoleList, err := roleUserRepo.Find(map[string]interface{}{"companyId": param.CompanyId, "userId": param.UserId})
  202 + if err != nil {
  203 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取用户的角色信息列表"+err.Error())
  204 + }
  205 + // 拥有HRBP权限
  206 + isHrbp := false
  207 +loop:
  208 + for _, v := range userRoleList {
  209 + for _, v2 := range roleList {
  210 + if v.RoleId == v2.Id {
  211 + isHrbp = true
  212 + break loop
  213 + }
  214 + }
  215 + }
  216 + if err := transactionContext.CommitTransaction(); err != nil {
  217 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  218 + }
  219 + info := adapter.MeInfo{
  220 + UserId: userData.Id,
  221 + CompanyId: companyData.Id,
  222 + CompanyName: companyData.Name,
  223 + Phone: userData.Account,
  224 + Name: userData.Name,
  225 + IsHrbp: isHrbp,
  226 + IsParent: false,
  227 + }
  228 + if len(parentUser) > 0 {
  229 + info.IsParent = true
  230 + }
  231 + return map[string]interface{}{
  232 + "user": info,
  233 + }, nil
  234 +}
@@ -208,3 +208,11 @@ func CreateLogSmsRepository(options map[string]interface{}) domain.LogSmsReposit @@ -208,3 +208,11 @@ func CreateLogSmsRepository(options map[string]interface{}) domain.LogSmsReposit
208 } 208 }
209 return repository.NewLogSmsRepository(transactionContext) 209 return repository.NewLogSmsRepository(transactionContext)
210 } 210 }
  211 +
  212 +func CreateMessagePersonalRepository(options map[string]interface{}) domain.MessagePersonalRepository {
  213 + var transactionContext *pg.TransactionContext
  214 + if value, ok := options["transactionContext"]; ok {
  215 + transactionContext = value.(*pg.TransactionContext)
  216 + }
  217 + return repository.NewMessagePersonalRepository(transactionContext)
  218 +}
@@ -33,143 +33,295 @@ func (rs *NodeTaskService) SendEvaluationNode() error { @@ -33,143 +33,295 @@ func (rs *NodeTaskService) SendEvaluationNode() error {
33 transactionContext.RollbackTransaction() 33 transactionContext.RollbackTransaction()
34 34
35 if err := recover(); err != nil { 35 if err := recover(); err != nil {
36 - log.Logger.Error(application.ThrowError(application.BUSINESS_ERROR, fmt.Sprintf("定时发送评估任务异常:%s", err)).Error()) 36 + log.Logger.Error(application.ThrowError(application.BUSINESS_ERROR, fmt.Sprintf("定时发送评估任务[基础查询]异常:%s", err)).Error())
37 } 37 }
38 }() 38 }()
39 taskRepository := factory.CreateNodeTaskRepository(map[string]interface{}{"transactionContext": transactionContext}) 39 taskRepository := factory.CreateNodeTaskRepository(map[string]interface{}{"transactionContext": transactionContext})
40 - tasks, err := taskRepository.Find(map[string]interface{}{"now": time.Now().Local()}) 40 + tasks, err := taskRepository.Find(map[string]interface{}{"lessNextSentAt": time.Now().Local()})
41 if err != nil { 41 if err != nil {
42 return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 42 return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
43 } 43 }
44 if len(tasks) == 0 { 44 if len(tasks) == 0 {
45 return nil 45 return nil
46 } 46 }
47 - projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext})  
48 - cycleRepository := factory.CreateEvaluationCycleRepository(map[string]interface{}{"transactionContext": transactionContext})  
49 47
50 - projectIdsMap := map[int64]*domain.EvaluationProject{}  
51 - cycleIdsMap := map[int64]*domain.EvaluationCycle{} 48 + projectMap := map[int64]*domain.EvaluationProject{}
  49 + cycleMap := map[int64]*domain.EvaluationCycle{}
52 for i := range tasks { 50 for i := range tasks {
53 - task := tasks[i]  
54 - projectIdsMap[task.ProjectId] = nil  
55 - cycleIdsMap[task.CycleId] = nil 51 + projectMap[tasks[i].ProjectId] = nil
  52 + cycleMap[tasks[i].CycleId] = nil
56 } 53 }
57 projectIds := make([]int64, 0) 54 projectIds := make([]int64, 0)
58 cycleIds := make([]int64, 0) 55 cycleIds := make([]int64, 0)
59 - for k := range projectIdsMap { 56 + for k := range projectMap {
60 projectIds = append(projectIds, k) 57 projectIds = append(projectIds, k)
61 } 58 }
62 - for k := range cycleIdsMap { 59 + for k := range cycleMap {
63 cycleIds = append(cycleIds, k) 60 cycleIds = append(cycleIds, k)
64 } 61 }
65 62
66 - _, projects, err := projectRepository.Find(map[string]interface{}{"ids": projectIds}, "template")  
67 - if err != nil {  
68 - return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 63 + if len(projectIds) > 0 {
  64 + projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext})
  65 + _, projects, err := projectRepository.Find(map[string]interface{}{"ids": projectIds}, "template")
  66 + if err != nil {
  67 + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  68 + }
  69 + for i := range projects {
  70 + projectMap[projects[i].Id] = projects[i]
  71 + }
69 } 72 }
70 - _, cycles, err := cycleRepository.Find(map[string]interface{}{"ids": cycleIds})  
71 - if err != nil {  
72 - return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 73 + if len(cycleIds) > 0 {
  74 + cycleRepository := factory.CreateEvaluationCycleRepository(map[string]interface{}{"transactionContext": transactionContext})
  75 + _, cycles, err := cycleRepository.Find(map[string]interface{}{"ids": cycleIds})
  76 + if err != nil {
  77 + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  78 + }
  79 + for i := range cycles {
  80 + cycleMap[cycles[i].Id] = cycles[i]
  81 + }
  82 + }
  83 + if err = transactionContext.CommitTransaction(); err != nil {
  84 + return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
73 } 85 }
74 86
75 - for i := range projects {  
76 - projectIdsMap[projects[i].Id] = projects[i] 87 + // 相同项目节点先聚合
  88 + taskMap := map[int64][]*domain.NodeTask{}
  89 + for i := range tasks {
  90 + task := tasks[i]
  91 + array, ok := taskMap[task.ProjectId]
  92 + if !ok {
  93 + array = make([]*domain.NodeTask, 0)
  94 + }
  95 + taskMap[task.ProjectId] = append(array, task)
77 } 96 }
78 - for i := range cycles {  
79 - cycleIdsMap[cycles[i].Id] = cycles[i] 97 + for k, v := range taskMap {
  98 + project, ok := projectMap[k]
  99 + if ok && project != nil {
  100 + if err = rs.taskSend(project, v, cycleMap); err != nil {
  101 + return err
  102 + }
  103 + } else {
  104 + if err = rs.taskAbort(v); err != nil {
  105 + return err
  106 + }
  107 + }
80 } 108 }
81 109
82 - staffAssessService := service.NewStaffAssessServeice() 110 + //staffAssessService := service.NewStaffAssessServeice()
  111 + //now := time.Now().Local()
  112 + //for i := range tasks {
  113 + // task := tasks[i]
  114 + // project, ok := projectMap[task.ProjectId] // 项目还存在
  115 + // if ok && project != nil {
  116 + // // 环节截止时间
  117 + // maxTime := task.TimeEnd.Local()
  118 + //
  119 + // // 更新任务最后一次的发送时间(取当前时间)
  120 + // task.LastSentAt = &now
  121 + //
  122 + // // 当前周起始时间和截止时间
  123 + // var cycleTimeStart = task.NextSentAt.Local()
  124 + // var cycleTimeEnd time.Time
  125 + //
  126 + // // 下个周期起始时间
  127 + // nextTime := utils.NextTimeInc(cycleTimeStart, task.KpiCycle)
  128 + // // 超过截止时间
  129 + // if nextTime.After(maxTime) {
  130 + // task.NextSentAt = nil
  131 + // } else {
  132 + // task.NextSentAt = &nextTime
  133 + // }
  134 + //
  135 + // // 周期的截至时间=下一个周期的开始时间-1秒(需求方要求提交数据时间延长到第二天8点30分截止)
  136 + // if task.NextSentAt == nil {
  137 + // //cycleTimeEnd = maxTime
  138 + // maxYear, maxMonth, maxDay := maxTime.Date()
  139 + // cycleTimeEnd = time.Date(maxYear, maxMonth, maxDay, 0, 0, 0, 0, time.Local)
  140 + // cycleTimeEnd = cycleTimeEnd.Add(24*time.Hour + 8*time.Hour + 30*time.Minute) // 注.延长8.5小时
  141 + // } else {
  142 + // //cycleTimeEnd = task.NextSentAt.Local().Add(-1 * time.Second) // 周期截至时间=下一个周期起始时间-1秒
  143 + // cycleTimeEnd = task.NextSentAt.Local().Add(8*time.Hour + 30*time.Minute) // 注.延长8.5小时
  144 + // }
  145 + //
  146 + // // 格式化周期的起始和截止时间
  147 + // fmCycleStartTime := cycleTimeStart.Format("2006-01-02 15:04:05")
  148 + // fmCycleTimeEnd := cycleTimeEnd.Format("2006-01-02 15:04:05")
  149 + //
  150 + // csat := &command.CreateStaffAssessTask{
  151 + // CompanyId: int(project.CompanyId),
  152 + // EvaluationProjectId: int(project.Id),
  153 + // EvaluationProjectName: project.Name,
  154 + // CycleId: project.CycleId,
  155 + // StepList: make([]command.AssessTaskStep, 0),
  156 + // }
  157 + //
  158 + // // 周期名称
  159 + // if cycle, ok := cycleMap[project.CycleId]; ok {
  160 + // csat.CycleName = cycle.Name
  161 + // }
  162 + //
  163 + // // 接收人
  164 + // csat.ExecutorId = make([]int, 0)
  165 + // for rIndex := range project.Recipients {
  166 + // vInt, _ := strconv.Atoi(project.Recipients[rIndex])
  167 + // csat.ExecutorId = append(csat.ExecutorId, vInt)
  168 + // }
  169 + //
  170 + // csat.BeginTime = fmCycleStartTime
  171 + // csat.EndTime = fmCycleTimeEnd
  172 + // csat.StepList = append(csat.StepList, command.AssessTaskStep{
  173 + // SortBy: task.NodeSort,
  174 + // LinkNodeId: int(task.NodeId),
  175 + // LinkNodeName: task.NodeName,
  176 + // LinkNodeType: task.NodeType,
  177 + // BeginTime: fmCycleStartTime,
  178 + // EndTime: fmCycleTimeEnd,
  179 + // })
  180 + //
  181 + // // 创建发送任务
  182 + // _, err := staffAssessService.CreateStaffAssessTask(transactionContext, csat)
  183 + // if err != nil {
  184 + // return application.ThrowError(application.INTERNAL_SERVER_ERROR, "创建发送任务"+err.Error())
  185 + // }
  186 + // } else {
  187 + // task.NextSentAt = nil // 项目不存在,取消周期任务发送
  188 + // }
  189 + //
  190 + // task, err := taskRepository.Insert(task)
  191 + // if err != nil {
  192 + // return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  193 + // }
  194 + //}
  195 +
  196 + return nil
  197 +
  198 +}
  199 +
  200 +func (rs *NodeTaskService) taskSend(project *domain.EvaluationProject, tasks []*domain.NodeTask, cycleMap map[int64]*domain.EvaluationCycle) error {
  201 + transactionContext, err := factory.StartTransaction()
  202 + if err != nil {
  203 + return err
  204 + }
  205 + defer func() {
  206 + _ = transactionContext.RollbackTransaction()
  207 + if err := recover(); err != nil {
  208 + log.Logger.Error(application.ThrowError(application.BUSINESS_ERROR, fmt.Sprintf("定时发送评估任务异常:%s", err)).Error())
  209 + }
  210 + }()
  211 + taskRepository := factory.CreateNodeTaskRepository(map[string]interface{}{"transactionContext": transactionContext})
83 212
84 now := time.Now().Local() 213 now := time.Now().Local()
  214 + csat := &command.CreateStaffAssessTask{
  215 + CompanyId: int(project.CompanyId),
  216 + EvaluationProjectId: int(project.Id),
  217 + EvaluationProjectName: project.Name,
  218 + CycleId: project.CycleId,
  219 + StepList: make([]command.AssessTaskStep, 0),
  220 + }
  221 + // 周期名称
  222 + if cycle, ok := cycleMap[project.CycleId]; ok {
  223 + csat.CycleName = cycle.Name
  224 + }
  225 +
  226 + // 接收人
  227 + csat.ExecutorId = make([]int, 0)
  228 + for rIndex := range project.Recipients {
  229 + vInt, _ := strconv.Atoi(project.Recipients[rIndex])
  230 + csat.ExecutorId = append(csat.ExecutorId, vInt)
  231 + }
  232 +
85 for i := range tasks { 233 for i := range tasks {
86 task := tasks[i] 234 task := tasks[i]
87 - project, ok := projectIdsMap[task.ProjectId] // 项目  
88 - if ok && project != nil {  
89 - // 环节截止时间  
90 - maxTime := task.TimeEnd.Local()  
91 -  
92 - // 更新任务最后一次的发送时间(取当前时间)  
93 - task.LastSentAt = &now  
94 -  
95 - // 当前周起始时间和截止时间  
96 - var cycleTimeStart = task.NextSentAt.Local()  
97 - var cycleTimeEnd time.Time  
98 -  
99 - // 下个周期起始时间  
100 - nextTime := utils.NextTimeInc(cycleTimeStart, task.KpiCycle)  
101 - // 超过截止时间  
102 - if nextTime.After(maxTime) {  
103 - task.NextSentAt = nil  
104 - } else {  
105 - task.NextSentAt = &nextTime  
106 - }  
107 235
108 - // 周期的截至时间=下一个周期的开始时间-1秒(需求方要求提交数据时间延长到第二天8点30分截止)  
109 - if task.NextSentAt == nil {  
110 - //cycleTimeEnd = maxTime  
111 - maxYear, maxMonth, maxDay := maxTime.Date()  
112 - cycleTimeEnd = time.Date(maxYear, maxMonth, maxDay, 0, 0, 0, 0, time.Local)  
113 - cycleTimeEnd = cycleTimeEnd.Add(24*time.Hour + 8*time.Hour + 30*time.Minute) // 注.延长8.5小时  
114 - } else {  
115 - //cycleTimeEnd = task.NextSentAt.Local().Add(-1 * time.Second) // 周期截至时间=下一个周期起始时间-1秒  
116 - cycleTimeEnd = task.NextSentAt.Local().Add(8*time.Hour + 30*time.Minute) // 注.延长8.5小时  
117 - } 236 + // 环节截止时间
  237 + maxTime := task.TimeEnd.Local()
118 238
119 - // 格式化周期的起始和截止时间  
120 - fmCycleStartTime := cycleTimeStart.Format("2006-01-02 15:04:05")  
121 - fmCycleTimeEnd := cycleTimeEnd.Format("2006-01-02 15:04:05") 239 + // 更新任务最后一次的发送时间(取当前时间)
  240 + task.LastSentAt = &now
122 241
123 - csat := &command.CreateStaffAssessTask{  
124 - CompanyId: int(project.CompanyId),  
125 - EvaluationProjectId: int(project.Id),  
126 - EvaluationProjectName: project.Name,  
127 - CycleId: project.CycleId,  
128 - StepList: make([]command.AssessTaskStep, 0),  
129 - } 242 + // 当前小周期范围[起始时间-截止时间]
  243 + var cycleTimeStart = task.NextSentAt.Local()
  244 + var cycleTimeEnd time.Time
130 245
131 - // 周期名称  
132 - if cycle, ok := cycleIdsMap[project.CycleId]; ok {  
133 - csat.CycleName = cycle.Name  
134 - } 246 + // 下个周期起始时间
  247 + nextTime := utils.NextTimeInc(cycleTimeStart, task.KpiCycle)
  248 + // 超过截止时间
  249 + if nextTime.After(maxTime) {
  250 + task.NextSentAt = nil
  251 + } else {
  252 + task.NextSentAt = &nextTime
  253 + }
  254 + // 更新下个周期
  255 + _, err = taskRepository.Insert(task)
  256 + if err != nil {
  257 + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  258 + }
135 259
136 - // 接收人  
137 - csat.ExecutorId = make([]int, 0)  
138 - for rIndex := range project.Recipients {  
139 - vInt, _ := strconv.Atoi(project.Recipients[rIndex])  
140 - csat.ExecutorId = append(csat.ExecutorId, vInt)  
141 - } 260 + // 周期的截至时间=下一个周期的开始时间-1秒(需求方要求:提交数据时间延长到第二天8点30分截止)
  261 + if task.NextSentAt == nil {
  262 + //cycleTimeEnd = maxTime
  263 + maxYear, maxMonth, maxDay := maxTime.Date()
  264 + cycleTimeEnd = time.Date(maxYear, maxMonth, maxDay, 0, 0, 0, 0, time.Local)
  265 + cycleTimeEnd = cycleTimeEnd.Add(24*time.Hour + 8*time.Hour + 30*time.Minute) // 注.延长8.5小时
  266 + } else {
  267 + //cycleTimeEnd = task.NextSentAt.Local().Add(-1 * time.Second) // 周期截至时间=下一个周期起始时间-1秒
  268 + cycleTimeEnd = task.NextSentAt.Local().Add(8*time.Hour + 30*time.Minute) // 注.延长8.5小时
  269 + }
  270 +
  271 + // 格式化周期的起始和截止时间
  272 + fmCycleStartTime := cycleTimeStart.Format("2006-01-02 15:04:05")
  273 + fmCycleTimeEnd := cycleTimeEnd.Format("2006-01-02 15:04:05")
142 274
  275 + // 格式化周期的起始和截止时间
  276 + if len(csat.BeginTime) == 0 {
143 csat.BeginTime = fmCycleStartTime 277 csat.BeginTime = fmCycleStartTime
  278 + }
  279 + if len(csat.EndTime) == 0 {
144 csat.EndTime = fmCycleTimeEnd 280 csat.EndTime = fmCycleTimeEnd
145 - csat.StepList = append(csat.StepList, command.AssessTaskStep{  
146 - SortBy: task.NodeSort,  
147 - LinkNodeId: int(task.NodeId),  
148 - LinkNodeName: task.NodeName,  
149 - LinkNodeType: task.NodeType,  
150 - BeginTime: fmCycleStartTime,  
151 - EndTime: fmCycleTimeEnd,  
152 - })  
153 -  
154 - // 创建发送任务  
155 - _, err := staffAssessService.CreateStaffAssessTask(transactionContext, csat)  
156 - if err != nil {  
157 - return application.ThrowError(application.INTERNAL_SERVER_ERROR, "创建发送任务"+err.Error())  
158 - }  
159 - } else {  
160 - task.NextSentAt = nil // 项目不存在,取消周期任务发送  
161 } 281 }
  282 + csat.StepList = append(csat.StepList, command.AssessTaskStep{
  283 + SortBy: task.NodeSort,
  284 + LinkNodeId: int(task.NodeId),
  285 + LinkNodeName: task.NodeName,
  286 + LinkNodeType: task.NodeType,
  287 + BeginTime: fmCycleStartTime,
  288 + EndTime: fmCycleTimeEnd,
  289 + })
  290 + }
162 291
163 - task, err := taskRepository.Insert(task)  
164 - if err != nil {  
165 - return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
166 - } 292 + // 创建发送任务
  293 + _, err = service.NewStaffAssessServeice().CreateStaffAssessTask(transactionContext, csat)
  294 + if err != nil {
  295 + return application.ThrowError(application.INTERNAL_SERVER_ERROR, "创建发送任务"+err.Error())
167 } 296 }
168 297
169 - if err := transactionContext.CommitTransaction(); err != nil { 298 + if err = transactionContext.CommitTransaction(); err != nil {
170 return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 299 return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
171 } 300 }
172 301
173 return nil 302 return nil
  303 +}
174 304
  305 +// 节点任务中止
  306 +func (rs *NodeTaskService) taskAbort(tasks []*domain.NodeTask) error {
  307 + transactionContext, err := factory.StartTransaction()
  308 + if err != nil {
  309 + return err
  310 + }
  311 + defer func() {
  312 + transactionContext.RollbackTransaction()
  313 + }()
  314 + taskRepository := factory.CreateNodeTaskRepository(map[string]interface{}{"transactionContext": transactionContext})
  315 + for i := range tasks {
  316 + task := tasks[i]
  317 + task.NextSentAt = nil // 项目不存在,取消周期任务发送
  318 + _, err = taskRepository.Insert(task)
  319 + if err != nil {
  320 + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  321 + }
  322 + }
  323 + if err = transactionContext.CommitTransaction(); err != nil {
  324 + return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  325 + }
  326 + return nil
175 } 327 }
  1 +package command
  2 +
  3 +type GetUserMessageCommand struct {
  4 + UserId int `json:"-"`
  5 +}
@@ -2,6 +2,7 @@ package notify @@ -2,6 +2,7 @@ package notify
2 2
3 import "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" 3 import "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
4 4
  5 +// 执行定时任务检查是否发送短信通知
5 var taskSmsNotify *notifySms 6 var taskSmsNotify *notifySms
6 7
7 // 检查并发送短信通知 8 // 检查并发送短信通知
@@ -11,7 +12,6 @@ func RunTaskSmsNotify() { @@ -11,7 +12,6 @@ func RunTaskSmsNotify() {
11 taskSmsNotify.regist(notifyStaffAssess{}) 12 taskSmsNotify.regist(notifyStaffAssess{})
12 taskSmsNotify.regist(notifySummaryEvaluation{}) 13 taskSmsNotify.regist(notifySummaryEvaluation{})
13 taskSmsNotify.runTask() 14 taskSmsNotify.runTask()
14 -  
15 } 15 }
16 16
17 // 每日自评短信通知 ,预创建待发送的短信消息 17 // 每日自评短信通知 ,预创建待发送的短信消息
  1 +package service
  2 +
  3 +import (
  4 + "encoding/json"
  5 + "fmt"
  6 + "strconv"
  7 + "time"
  8 +
  9 + "github.com/linmadan/egglib-go/core/application"
  10 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
  11 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/notify/command"
  12 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
  13 +)
  14 +
  15 +// 个人信息提示
  16 +
  17 +type MessagePersonalService struct {
  18 +}
  19 +
  20 +func NewMessagePersonalService() *MessagePersonalService {
  21 + newService := &MessagePersonalService{}
  22 + return newService
  23 +}
  24 +
  25 +// 获取今天的周期综合自评消息提示
  26 +func (srv *MessagePersonalService) TodayMessageSummaryEvaluationSelf(param *command.GetUserMessageCommand) (map[string]interface{}, error) {
  27 + transactionContext, err := factory.CreateTransactionContext(nil)
  28 + if err != nil {
  29 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  30 + }
  31 + if err := transactionContext.StartTransaction(); err != nil {
  32 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  33 + }
  34 + defer func() {
  35 + _ = transactionContext.RollbackTransaction()
  36 + }()
  37 +
  38 + nowTime := time.Now()
  39 + evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{
  40 + "transactionContext": transactionContext,
  41 + })
  42 + _, evaluationList, err := evaluationRepo.Find(map[string]interface{}{
  43 + "targetUserId": param.UserId,
  44 + "types": domain.EvaluationSelf,
  45 + "beginTime": nowTime,
  46 + "endTime": nowTime,
  47 + })
  48 + if err != nil {
  49 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "周期综合自评"+err.Error())
  50 + }
  51 + resp := map[string]interface{}{
  52 + "needNotify": false,
  53 + "content": "",
  54 + }
  55 + if len(evaluationList) == 0 {
  56 + return resp, nil
  57 + }
  58 +
  59 + messageRepo := factory.CreateMessagePersonalRepository(map[string]interface{}{
  60 + "transactionContext": transactionContext,
  61 + })
  62 + newMessageList := []domain.MessagePersonal{}
  63 + for _, val := range evaluationList {
  64 + payload := map[string]string{
  65 + "id": strconv.Itoa(val.Id),
  66 + }
  67 + payloadStr, _ := json.Marshal(payload)
  68 + cnt, _, err := messageRepo.Find(map[string]interface{}{
  69 + "types": domain.MessageTypesOther,
  70 + "targetUserId": param.UserId,
  71 + "payload": string(payloadStr),
  72 + "limit": 1,
  73 + })
  74 + if err != nil {
  75 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "检查自评消息记录"+err.Error())
  76 + }
  77 + if cnt == 0 {
  78 + newMessageList = append(newMessageList, domain.MessagePersonal{
  79 + Id: 0,
  80 + Types: domain.MessageTypesOther,
  81 + TargetUserId: val.TargetUser.UserId,
  82 + ReadFlag: domain.MessageIsRead,
  83 + Title: fmt.Sprintf("%s综合自评已开启,请前往进行评估.", val.CycleName),
  84 + Content: fmt.Sprintf("%s综合自评已开启,请前往进行评估.", val.CycleName),
  85 + CreatedAt: time.Time{},
  86 + UpdatedAt: time.Time{},
  87 + Payload: string(payloadStr),
  88 + })
  89 + resp["needNotify"] = true
  90 + resp["content"] = fmt.Sprintf("%s综合自评已开启,请前往进行评估.", val.CycleName)
  91 + break
  92 + }
  93 + }
  94 + for i := range newMessageList {
  95 + err = messageRepo.Save(&newMessageList[i])
  96 + if err != nil {
  97 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存自评消息记录"+err.Error())
  98 + }
  99 + }
  100 + if err := transactionContext.CommitTransaction(); err != nil {
  101 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  102 + }
  103 + return resp, nil
  104 +}
@@ -43,6 +43,11 @@ func (notices notifyStaffAssess) makeNotify(param *domain.StaffAssess) *domain.L @@ -43,6 +43,11 @@ func (notices notifyStaffAssess) makeNotify(param *domain.StaffAssess) *domain.L
43 43
44 // ifSend 确认是否发送通知 44 // ifSend 确认是否发送通知
45 func (notices notifyStaffAssess) ifSend(index int) (bool, error) { 45 func (notices notifyStaffAssess) ifSend(index int) (bool, error) {
  46 + nowDay := time.Now().Weekday()
  47 + if nowDay == time.Sunday || nowDay == time.Saturday {
  48 + //周末不发
  49 + return false, nil
  50 + }
46 transactionContext, err := factory.CreateTransactionContext(nil) 51 transactionContext, err := factory.CreateTransactionContext(nil)
47 if err != nil { 52 if err != nil {
48 return false, err 53 return false, err
@@ -44,6 +44,11 @@ func (notices notifySummaryEvaluation) makeNotify(param *domain.SummaryEvaluatio @@ -44,6 +44,11 @@ func (notices notifySummaryEvaluation) makeNotify(param *domain.SummaryEvaluatio
44 44
45 // ifSend 确认是否发送通知 45 // ifSend 确认是否发送通知
46 func (notices notifySummaryEvaluation) ifSend(index int) (bool, error) { 46 func (notices notifySummaryEvaluation) ifSend(index int) (bool, error) {
  47 + nowDay := time.Now().Weekday()
  48 + if nowDay == time.Sunday || nowDay == time.Saturday {
  49 + //周末不发
  50 + return false, nil
  51 + }
47 transactionContext, err := factory.CreateTransactionContext(nil) 52 transactionContext, err := factory.CreateTransactionContext(nil)
48 if err != nil { 53 if err != nil {
49 return false, err 54 return false, err
@@ -13,8 +13,8 @@ type ListAssessContentCycleDay struct { @@ -13,8 +13,8 @@ type ListAssessContentCycleDay struct {
13 } 13 }
14 14
15 type ExportAssessContentCycleDay struct { 15 type ExportAssessContentCycleDay struct {
16 - CompanyId int `json:"companyId"`  
17 - OperaterId int `json:"operaterId"` 16 + CompanyId int `json:"-"`
  17 + OperaterId int `json:"-"`
18 CycleId int `json:"cycleId,string"` //周期id 18 CycleId int `json:"cycleId,string"` //周期id
19 BeginDayList []string `json:"beginDayList"` //评估开始的时间 19 BeginDayList []string `json:"beginDayList"` //评估开始的时间
20 TargetUserName string `json:"targetUserName"` 20 TargetUserName string `json:"targetUserName"`
@@ -1090,13 +1090,13 @@ func (srv StaffAssessServeice) getStaffSuper(transactionContext application.Tran @@ -1090,13 +1090,13 @@ func (srv StaffAssessServeice) getStaffSuper(transactionContext application.Tran
1090 "transactionContext": transactionContext, 1090 "transactionContext": transactionContext,
1091 }) 1091 })
1092 1092
1093 - userData, err := userRepo.FindOne(map[string]interface{}{ 1093 + _, userData, err := userRepo.Find(map[string]interface{}{
1094 "id": targetUser.ParentId, 1094 "id": targetUser.ParentId,
1095 }) 1095 })
1096 if err != nil { 1096 if err != nil {
1097 return nil, err 1097 return nil, err
1098 } 1098 }
1099 - return []*domain.User{userData}, nil 1099 + return userData, nil
1100 } 1100 }
1101 1101
1102 func (srv StaffAssessServeice) recoverAssessCache(context application.TransactionContext, assessId int, dataArray []*domain.StaffAssessContent) { 1102 func (srv StaffAssessServeice) recoverAssessCache(context application.TransactionContext, assessId int, dataArray []*domain.StaffAssessContent) {
@@ -14,7 +14,7 @@ import ( @@ -14,7 +14,7 @@ import (
14 14
15 // 导出数据 15 // 导出数据
16 // 综合管理-周期评估 16 // 综合管理-周期评估
17 -func (srv *SummaryEvaluationService) ExportAllEvaluationSuper(param *command.QueryEvaluationList) (*excelize.File, error) { 17 +func (srv *SummaryEvaluationService) ExportAllEvaluationFinish(param *command.QueryEvaluationList) (*excelize.File, error) {
18 transactionContext, err := factory.CreateTransactionContext(nil) 18 transactionContext, err := factory.CreateTransactionContext(nil)
19 if err != nil { 19 if err != nil {
20 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 20 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -41,7 +41,7 @@ func (srv *SummaryEvaluationService) ExportAllEvaluationSuper(param *command.Que @@ -41,7 +41,7 @@ func (srv *SummaryEvaluationService) ExportAllEvaluationSuper(param *command.Que
41 "parentId": param.UserId, 41 "parentId": param.UserId,
42 "limit": 1, 42 "limit": 1,
43 }) 43 })
44 - if len(parentUser) == 0 { 44 + if len(parentUser) == 0 && flagHrbp != 1 {
45 return nil, application.ThrowError(application.BUSINESS_ERROR, "暂无数据") 45 return nil, application.ThrowError(application.BUSINESS_ERROR, "暂无数据")
46 } 46 }
47 evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{ 47 evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{
@@ -56,7 +56,7 @@ func (srv *SummaryEvaluationService) ExportAllEvaluationSuper(param *command.Que @@ -56,7 +56,7 @@ func (srv *SummaryEvaluationService) ExportAllEvaluationSuper(param *command.Que
56 //获取评估列表信息 56 //获取评估列表信息
57 condition1 := map[string]interface{}{ 57 condition1 := map[string]interface{}{
58 "cycleId": param.CycleId, 58 "cycleId": param.CycleId,
59 - "types": int(domain.EvaluationSuper), 59 + "types": int(domain.EvaluationFinish),
60 "limit": limit, 60 "limit": limit,
61 } 61 }
62 if offset > 0 { 62 if offset > 0 {
@@ -147,7 +147,15 @@ func (srv *SummaryEvaluationService) ExportAllEvaluationSuper(param *command.Que @@ -147,7 +147,15 @@ func (srv *SummaryEvaluationService) ExportAllEvaluationSuper(param *command.Que
147 firstSheetName := xlsxFile.GetSheetName(sheetIndex) 147 firstSheetName := xlsxFile.GetSheetName(sheetIndex)
148 tableHead := []string{"姓名", "部门", "职位", "最终绩效得分"} 148 tableHead := []string{"姓名", "部门", "职位", "最终绩效得分"}
149 tableHead = append(tableHead, ratingHeader...) 149 tableHead = append(tableHead, ratingHeader...)
150 - xlsxFile.SetSheetRow(firstSheetName, "A1", &tableHead) 150 + if len(evaluationList) > 0 {
  151 + xlsxFile.SetSheetRow(firstSheetName, "A1", &[]string{evaluationList[0].CycleName + "最终成绩"})
  152 + // if len(tableHead) > 1 {
  153 + // cellCode, _ := excelize.ColumnNumberToName(len(tableHead))
  154 + // xlsxFile.MergeCell(firstSheetName, "A1", cellCode+"1")
  155 + // }
  156 + }
  157 + xlsxFile.SetSheetRow(firstSheetName, "A2", &tableHead)
  158 + firstDataRow := 3
151 for i, v := range evaluationList { 159 for i, v := range evaluationList {
152 departmentName := "" 160 departmentName := ""
153 for _, dep := range v.TargetDepartment { 161 for _, dep := range v.TargetDepartment {
@@ -176,7 +184,7 @@ func (srv *SummaryEvaluationService) ExportAllEvaluationSuper(param *command.Que @@ -176,7 +184,7 @@ func (srv *SummaryEvaluationService) ExportAllEvaluationSuper(param *command.Que
176 dataRaw = append(dataRaw, "0") 184 dataRaw = append(dataRaw, "0")
177 } 185 }
178 } 186 }
179 - xlsxFile.SetSheetRow(firstSheetName, fmt.Sprintf("A%d", i+2), &dataRaw) 187 + xlsxFile.SetSheetRow(firstSheetName, fmt.Sprintf("A%d", i+firstDataRow), &dataRaw)
180 } 188 }
181 return xlsxFile, nil 189 return xlsxFile, nil
182 } 190 }
@@ -73,8 +73,12 @@ func sendSummaryEvaluation(project *domain.EvaluationProject, @@ -73,8 +73,12 @@ func sendSummaryEvaluation(project *domain.EvaluationProject,
73 } 73 }
74 nodeId := 0 74 nodeId := 0
75 executor360Map := map[int64]*domain.User{} 75 executor360Map := map[int64]*domain.User{}
  76 + hrbpExist := false
76 for _, v := range itemList { 77 for _, v := range itemList {
77 nodeId = v.NodeId 78 nodeId = v.NodeId
  79 + if v.EvaluatorId < 0 {
  80 + hrbpExist = true
  81 + }
78 if v.EvaluatorId <= 0 { 82 if v.EvaluatorId <= 0 {
79 continue 83 continue
80 } 84 }
@@ -106,8 +110,8 @@ func sendSummaryEvaluation(project *domain.EvaluationProject, @@ -106,8 +110,8 @@ func sendSummaryEvaluation(project *domain.EvaluationProject,
106 DeletedAt: nil, 110 DeletedAt: nil,
107 } 111 }
108 112
109 - //确定自评  
110 - //确定 被评估人的 上级评估 113 + //确定周期评估
  114 +
111 for _, v := range targetUserMap { 115 for _, v := range targetUserMap {
112 //处理自评 116 //处理自评
113 evaluationTemp.TargetUser = domain.StaffDesc{ 117 evaluationTemp.TargetUser = domain.StaffDesc{
@@ -136,13 +140,15 @@ func sendSummaryEvaluation(project *domain.EvaluationProject, @@ -136,13 +140,15 @@ func sendSummaryEvaluation(project *domain.EvaluationProject,
136 } 140 }
137 //确定自评 141 //确定自评
138 newEvaluationList = append(newEvaluationList, evaluationTemp) 142 newEvaluationList = append(newEvaluationList, evaluationTemp)
139 - //处理人资评估  
140 - evaluationTemp.BeginTime = beginTime360  
141 - evaluationTemp.EndTime = endTime360  
142 - evaluationTemp.Executor = domain.StaffDesc{}  
143 - evaluationTemp.Types = domain.EvaluationHrbp  
144 - //确定人资评估  
145 - newEvaluationList = append(newEvaluationList, evaluationTemp) 143 + if hrbpExist {
  144 + //处理人资评估
  145 + evaluationTemp.BeginTime = beginTime360
  146 + evaluationTemp.EndTime = endTime360
  147 + evaluationTemp.Executor = domain.StaffDesc{}
  148 + evaluationTemp.Types = domain.EvaluationHrbp
  149 + //确定人资评估
  150 + newEvaluationList = append(newEvaluationList, evaluationTemp)
  151 + }
146 //处理360 评估 152 //处理360 评估
147 for _, v2 := range executor360Map { 153 for _, v2 := range executor360Map {
148 evaluationTemp.BeginTime = beginTime360 154 evaluationTemp.BeginTime = beginTime360
@@ -171,6 +177,12 @@ func sendSummaryEvaluation(project *domain.EvaluationProject, @@ -171,6 +177,12 @@ func sendSummaryEvaluation(project *domain.EvaluationProject,
171 //确定上级评估 177 //确定上级评估
172 newEvaluationList = append(newEvaluationList, evaluationTemp) 178 newEvaluationList = append(newEvaluationList, evaluationTemp)
173 } 179 }
  180 + // 确定 考核结果 的评估记录
  181 + evaluationTemp.Types = domain.EvaluationFinish
  182 + evaluationTemp.Executor = domain.StaffDesc{}
  183 + evaluationTemp.BeginTime = endTimeSuper
  184 + evaluationTemp.EndTime = endTimeSuper.Add(2 * 24 * time.Hour)
  185 + newEvaluationList = append(newEvaluationList, evaluationTemp)
174 } 186 }
175 summaryEvaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext}) 187 summaryEvaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext})
176 for i := range newEvaluationList { 188 for i := range newEvaluationList {
@@ -199,6 +211,11 @@ func dayZeroTime(t time.Time) time.Time { @@ -199,6 +211,11 @@ func dayZeroTime(t time.Time) time.Time {
199 211
200 // 下发周期评估 212 // 下发周期评估
201 func TaskSendSummaryEvaluation() error { 213 func TaskSendSummaryEvaluation() error {
  214 + nowTime := time.Now()
  215 + defer func() {
  216 + str := fmt.Sprintf("下发周期评估耗时%.2f s", time.Since(nowTime).Seconds())
  217 + log.Logger.Info(str)
  218 + }()
202 transactionContext, err := factory.CreateTransactionContext(nil) 219 transactionContext, err := factory.CreateTransactionContext(nil)
203 if err != nil { 220 if err != nil {
204 return err 221 return err
@@ -15,6 +15,7 @@ import ( @@ -15,6 +15,7 @@ import (
15 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/command" 15 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/command"
16 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" 16 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
17 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao" 17 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao"
  18 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/xredis"
18 ) 19 )
19 20
20 type SummaryEvaluationService struct { 21 type SummaryEvaluationService struct {
@@ -59,12 +60,12 @@ func (srv *SummaryEvaluationService) GetExecutorCycleList(param *command.QueryCy @@ -59,12 +60,12 @@ func (srv *SummaryEvaluationService) GetExecutorCycleList(param *command.QueryCy
59 offset = (param.PageNumber - 1) * param.PageSize 60 offset = (param.PageNumber - 1) * param.PageSize
60 } 61 }
61 62
62 - cycleData, err := evaluationDao.GetExecutorCycleList(param.UserId, offset, limit, isHrbp) 63 + cycleData, err := evaluationDao.GetExecutorCycleList(param.CompanyId, param.UserId, offset, limit, isHrbp)
63 if err != nil { 64 if err != nil {
64 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取周期列表"+err.Error()) 65 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取周期列表"+err.Error())
65 } 66 }
66 67
67 - cnt, err := evaluationDao.CountExecutorCycleList(param.UserId, domain.EvaluationSelf) 68 + cnt, err := evaluationDao.CountExecutorCycleList(param.CompanyId, param.UserId, isHrbp)
68 if err != nil { 69 if err != nil {
69 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 70 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
70 } 71 }
@@ -199,11 +200,12 @@ func (srv *SummaryEvaluationService) GetMenu(param *command.QueryMenu) (map[stri @@ -199,11 +200,12 @@ func (srv *SummaryEvaluationService) GetMenu(param *command.QueryMenu) (map[stri
199 } 200 }
200 201
201 //查找当前周期,我的考核结果 202 //查找当前周期,我的考核结果
202 - _, myEvaluationSuper, _ := evaluationRepo.Find(map[string]interface{}{  
203 - "types": int(domain.EvaluationSuper), 203 + _, myEvaluationFinish, _ := evaluationRepo.Find(map[string]interface{}{
  204 + "types": int(domain.EvaluationFinish),
204 "limit": 1, 205 "limit": 1,
205 "targetUserId": param.UserId, 206 "targetUserId": param.UserId,
206 "cycleId": param.CycleId, 207 "cycleId": param.CycleId,
  208 + "beginTime": time.Now(),
207 }) 209 })
208 210
209 if err := transactionContext.CommitTransaction(); err != nil { 211 if err := transactionContext.CommitTransaction(); err != nil {
@@ -242,15 +244,13 @@ func (srv *SummaryEvaluationService) GetMenu(param *command.QueryMenu) (map[stri @@ -242,15 +244,13 @@ func (srv *SummaryEvaluationService) GetMenu(param *command.QueryMenu) (map[stri
242 } 244 }
243 menu1.Child = append(menu1.Child, menu1_1) 245 menu1.Child = append(menu1.Child, menu1_1)
244 } 246 }
245 - if len(myEvaluationSuper) > 0 {  
246 - if myEvaluationSuper[0].CheckResult == domain.EvaluationCheckCompleted { 247 + if len(myEvaluationFinish) > 0 {
  248 + if myEvaluationFinish[0].CheckResult == domain.EvaluationCheckCompleted {
247 menu1_2.StatusName = "已完成" 249 menu1_2.StatusName = "已完成"
248 } else { 250 } else {
249 menu1_2.StatusName = "未完成" 251 menu1_2.StatusName = "未完成"
250 } 252 }
251 - if myEvaluationSuper[0].Status == domain.EvaluationCompleted {  
252 - menu1.Child = append(menu1.Child, menu1_2)  
253 - } 253 + menu1.Child = append(menu1.Child, menu1_2)
254 } 254 }
255 255
256 if len(selfEvaluation) > 0 { 256 if len(selfEvaluation) > 0 {
@@ -367,6 +367,7 @@ func (srv *SummaryEvaluationService) buildSummaryItemValue(itemList []*domain.Ev @@ -367,6 +367,7 @@ func (srv *SummaryEvaluationService) buildSummaryItemValue(itemList []*domain.Ev
367 item.Value = value.Value 367 item.Value = value.Value
368 item.Remark = value.Remark 368 item.Remark = value.Remark
369 item.Rating = value.Rating 369 item.Rating = value.Rating
  370 + item.EvaluatorName = value.Executor.UserName
370 } 371 }
371 itemValues = append(itemValues, item) 372 itemValues = append(itemValues, item)
372 } 373 }
@@ -462,24 +463,14 @@ func (srv *SummaryEvaluationService) getSummaryEvaluation(transactionContext app @@ -462,24 +463,14 @@ func (srv *SummaryEvaluationService) getSummaryEvaluation(transactionContext app
462 TotalScore: evaluationData.TotalScore, 463 TotalScore: evaluationData.TotalScore,
463 } 464 }
464 //获取用户信息 465 //获取用户信息
465 - companyRepo := factory.CreateCompanyRepository(map[string]interface{}{  
466 - "transactionContext": transactionContext,  
467 - })  
468 - userRepo := factory.CreateUserRepository(map[string]interface{}{  
469 - "transactionContext": transactionContext,  
470 - })  
471 -  
472 - companyData, err := companyRepo.FindOne(map[string]interface{}{  
473 - "id": evaluationData.CompanyId,  
474 - }) 466 + companyRepo := factory.CreateCompanyRepository(map[string]interface{}{"transactionContext": transactionContext})
  467 + userRepo := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext})
475 468
  469 + companyData, err := companyRepo.FindOne(map[string]interface{}{"id": evaluationData.CompanyId})
476 if err != nil { 470 if err != nil {
477 return result 471 return result
478 } 472 }
479 -  
480 - userData, err := userRepo.FindOne(map[string]interface{}{  
481 - "id": evaluationData.TargetUser.UserId,  
482 - }) 473 + userData, err := userRepo.FindOne(map[string]interface{}{"id": evaluationData.TargetUser.UserId})
483 if err != nil { 474 if err != nil {
484 return result 475 return result
485 } 476 }
@@ -487,22 +478,18 @@ func (srv *SummaryEvaluationService) getSummaryEvaluation(transactionContext app @@ -487,22 +478,18 @@ func (srv *SummaryEvaluationService) getSummaryEvaluation(transactionContext app
487 result.CompanyLogo = companyData.Logo 478 result.CompanyLogo = companyData.Logo
488 result.CompanyName = companyData.Name 479 result.CompanyName = companyData.Name
489 480
490 - if userData.ParentId <= 0 {  
491 - return result  
492 - }  
493 - pUserData, err := userRepo.FindOne(map[string]interface{}{  
494 - "id": userData.ParentId,  
495 - })  
496 - if err != nil {  
497 - return result 481 + if userData.ParentId > 0 {
  482 + pUserData, err := userRepo.FindOne(map[string]interface{}{"id": userData.ParentId})
  483 + if err != nil {
  484 + return result
  485 + }
  486 + result.SupperUser = pUserData.Name
498 } 487 }
499 - result.SupperUser = pUserData.Name  
500 return result 488 return result
501 } 489 }
502 490
503 // 编辑综合自评详情 491 // 编辑综合自评详情
504 func (srv *SummaryEvaluationService) EditEvaluationSelf(param *command.EditEvaluationValue) (map[string][]adapter.EvaluationItemAdapter, error) { 492 func (srv *SummaryEvaluationService) EditEvaluationSelf(param *command.EditEvaluationValue) (map[string][]adapter.EvaluationItemAdapter, error) {
505 - // xredis.NewLockSummaryEvaluation(param.SummaryEvaluationId)  
506 493
507 transactionContext, err := factory.CreateTransactionContext(nil) 494 transactionContext, err := factory.CreateTransactionContext(nil)
508 if err != nil { 495 if err != nil {
@@ -596,7 +583,17 @@ func (srv *SummaryEvaluationService) EditEvaluationSelf(param *command.EditEvalu @@ -596,7 +583,17 @@ func (srv *SummaryEvaluationService) EditEvaluationSelf(param *command.EditEvalu
596 // 员工提交自评内容后, 583 // 员工提交自评内容后,
597 // 员工作为被评估人, 584 // 员工作为被评估人,
598 // 变更360评估/人资评估/的开始时间 585 // 变更360评估/人资评估/的开始时间
  586 +// 或者变更上级评估的开始时间
  587 +// 或者生成考核结果
599 func (srv *SummaryEvaluationService) AfterCompletedEvaluationSelf(param *domain.SummaryEvaluation) error { 588 func (srv *SummaryEvaluationService) AfterCompletedEvaluationSelf(param *domain.SummaryEvaluation) error {
  589 + lock := xredis.NewLockSummaryEvaluation(param.TargetUser.UserId)
  590 + err := lock.Lock()
  591 + if err != nil {
  592 + return application.ThrowError(application.INTERNAL_SERVER_ERROR, "未能完全提交评估内容")
  593 + }
  594 + defer func() {
  595 + lock.UnLock()
  596 + }()
600 transactionContext, err := factory.CreateTransactionContext(nil) 597 transactionContext, err := factory.CreateTransactionContext(nil)
601 if err != nil { 598 if err != nil {
602 return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 599 return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -619,7 +616,18 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluationSelf(param *domain. @@ -619,7 +616,18 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluationSelf(param *domain.
619 if err != nil { 616 if err != nil {
620 return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 617 return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
621 } 618 }
622 - 619 + if len(evaluationList) == 0 {
  620 + //如果没有360评估和hrbp 评估,查找上级评估
  621 + _, evaluationList, err = evaluationRepo.Find(map[string]interface{}{
  622 + "targetUserId": param.TargetUser.UserId,
  623 + "typesList": []int{int(domain.EvaluationSuper)},
  624 + "cycleId": param.CycleId,
  625 + "limit": 10,
  626 + })
  627 + if err != nil {
  628 + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  629 + }
  630 + }
623 nowTime := time.Now() 631 nowTime := time.Now()
624 updatedId := []int{} 632 updatedId := []int{}
625 // 变更360评估/人资评估/上级评估的开始时间 633 // 变更360评估/人资评估/上级评估的开始时间
@@ -632,21 +640,52 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluationSelf(param *domain. @@ -632,21 +640,52 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluationSelf(param *domain.
632 evaluationDao := dao.NewSummaryEvaluationDao(map[string]interface{}{ 640 evaluationDao := dao.NewSummaryEvaluationDao(map[string]interface{}{
633 "transactionContext": transactionContext, 641 "transactionContext": transactionContext,
634 }) 642 })
635 -  
636 err = evaluationDao.UpdateBeginTime(updatedId, nowTime) 643 err = evaluationDao.UpdateBeginTime(updatedId, nowTime)
637 if err != nil { 644 if err != nil {
638 return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 645 return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
639 } 646 }
640 - 647 + if len(evaluationList) == 0 {
  648 + //没有上级评估、360评估、hrbp 评估
  649 + //直接进入考核结果阶段
  650 + _, evaluationList, err = evaluationRepo.Find(map[string]interface{}{
  651 + "targetUserId": param.TargetUser.UserId,
  652 + "typesList": []int{int(domain.EvaluationFinish)},
  653 + "cycleId": param.CycleId,
  654 + "limit": 1,
  655 + })
  656 + if err != nil {
  657 + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  658 + }
  659 + if len(evaluationList) > 0 {
  660 + // 进入考核结果阶段
  661 + if evaluationList[0].BeginTime.After(nowTime) {
  662 + evaluationList[0].BeginTime = nowTime
  663 + }
  664 + evaluationList[0].Status = domain.EvaluationCompleted
  665 + err = evaluationRepo.Save(evaluationList[0])
  666 + if err != nil {
  667 + return application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存考核结果,"+err.Error())
  668 + }
  669 + }
  670 + }
641 if err := transactionContext.CommitTransaction(); err != nil { 671 if err := transactionContext.CommitTransaction(); err != nil {
642 return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 672 return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
643 } 673 }
644 return nil 674 return nil
645 } 675 }
646 676
647 -// 被评估员工的人资评估 或者 360 评估, 677 +// 提交员工的人资评估 或者 360 评估
648 // 变更上级评估的开始时间 678 // 变更上级评估的开始时间
  679 +// 或者生成考核结果
649 func (srv *SummaryEvaluationService) AfterCompletedEvaluation360Hrbp(param *domain.SummaryEvaluation) error { 680 func (srv *SummaryEvaluationService) AfterCompletedEvaluation360Hrbp(param *domain.SummaryEvaluation) error {
  681 + lock := xredis.NewLockSummaryEvaluation(param.TargetUser.UserId)
  682 + err := lock.Lock()
  683 + if err != nil {
  684 + return application.ThrowError(application.INTERNAL_SERVER_ERROR, "未能完全提交评估内容")
  685 + }
  686 + defer func() {
  687 + lock.UnLock()
  688 + }()
650 transactionContext, err := factory.CreateTransactionContext(nil) 689 transactionContext, err := factory.CreateTransactionContext(nil)
651 if err != nil { 690 if err != nil {
652 return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 691 return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -684,7 +723,7 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluation360Hrbp(param *doma @@ -684,7 +723,7 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluation360Hrbp(param *doma
684 "targetUserId": param.TargetUser.UserId, 723 "targetUserId": param.TargetUser.UserId,
685 "typesList": []int{int(domain.EvaluationSuper)}, 724 "typesList": []int{int(domain.EvaluationSuper)},
686 "cycleId": param.CycleId, 725 "cycleId": param.CycleId,
687 - "limit": 1000, 726 + "limit": 1,
688 }) 727 })
689 if err != nil { 728 if err != nil {
690 return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 729 return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
@@ -705,6 +744,82 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluation360Hrbp(param *doma @@ -705,6 +744,82 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluation360Hrbp(param *doma
705 if err != nil { 744 if err != nil {
706 return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 745 return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
707 } 746 }
  747 + if len(evaluationList) == 0 {
  748 + //没有上级评估
  749 + //直接进入考核结果阶段
  750 + _, evaluationList, err = evaluationRepo.Find(map[string]interface{}{
  751 + "targetUserId": param.TargetUser.UserId,
  752 + "typesList": []int{int(domain.EvaluationFinish)},
  753 + "cycleId": param.CycleId,
  754 + "limit": 1,
  755 + })
  756 + if err != nil {
  757 + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  758 + }
  759 + if len(evaluationList) > 0 {
  760 + if evaluationList[0].BeginTime.After(nowTime) {
  761 + evaluationList[0].BeginTime = nowTime
  762 + }
  763 + evaluationList[0].Status = domain.EvaluationCompleted
  764 + err = evaluationRepo.Save(evaluationList[0])
  765 + if err != nil {
  766 + return application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存考核结果,"+err.Error())
  767 + }
  768 + }
  769 + }
  770 + if err := transactionContext.CommitTransaction(); err != nil {
  771 + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  772 + }
  773 + return nil
  774 +}
  775 +
  776 +// 员工提交上级评估后
  777 +// 生成考核结果
  778 +func (srv *SummaryEvaluationService) AfterCompletedEvaluationSuper(param *domain.SummaryEvaluation) error {
  779 + lock := xredis.NewLockSummaryEvaluation(param.TargetUser.UserId)
  780 + err := lock.Lock()
  781 + if err != nil {
  782 + return application.ThrowError(application.INTERNAL_SERVER_ERROR, "未能完全提交评估内容")
  783 + }
  784 + defer func() {
  785 + lock.UnLock()
  786 + }()
  787 + transactionContext, err := factory.CreateTransactionContext(nil)
  788 + if err != nil {
  789 + return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  790 + }
  791 + if err := transactionContext.StartTransaction(); err != nil {
  792 + return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  793 + }
  794 + defer func() {
  795 + _ = transactionContext.RollbackTransaction()
  796 + }()
  797 +
  798 + evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{
  799 + "transactionContext": transactionContext,
  800 + })
  801 + //没有上级评估
  802 + //直接进入考核结果阶段
  803 + _, evaluationList, err := evaluationRepo.Find(map[string]interface{}{
  804 + "targetUserId": param.TargetUser.UserId,
  805 + "typesList": []int{int(domain.EvaluationFinish)},
  806 + "cycleId": param.CycleId,
  807 + "limit": 1,
  808 + })
  809 + if err != nil {
  810 + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  811 + }
  812 + nowTime := time.Now()
  813 + if len(evaluationList) > 0 {
  814 + if evaluationList[0].BeginTime.After(nowTime) {
  815 + evaluationList[0].BeginTime = nowTime
  816 + }
  817 + evaluationList[0].Status = domain.EvaluationCompleted
  818 + err = evaluationRepo.Save(evaluationList[0])
  819 + if err != nil {
  820 + return application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存考核结果,"+err.Error())
  821 + }
  822 + }
708 if err := transactionContext.CommitTransaction(); err != nil { 823 if err := transactionContext.CommitTransaction(); err != nil {
709 return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 824 return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
710 } 825 }
@@ -1062,6 +1177,14 @@ func (srv *SummaryEvaluationService) EditEvaluationSuper(param *command.EditEval @@ -1062,6 +1177,14 @@ func (srv *SummaryEvaluationService) EditEvaluationSuper(param *command.EditEval
1062 if err := transactionContext.CommitTransaction(); err != nil { 1177 if err := transactionContext.CommitTransaction(); err != nil {
1063 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1178 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
1064 } 1179 }
  1180 +
  1181 + if !param.IsTemporary {
  1182 + err = srv.AfterCompletedEvaluationSuper(evaluationData)
  1183 + if err != nil {
  1184 + return nil, err
  1185 + }
  1186 + }
  1187 +
1065 itemValueAdapter := srv.buildSummaryItemValue(itemList, itemValueList) 1188 itemValueAdapter := srv.buildSummaryItemValue(itemList, itemValueList)
1066 return map[string][]adapter.EvaluationItemAdapter{ 1189 return map[string][]adapter.EvaluationItemAdapter{
1067 "EvaluationItems": itemValueAdapter, 1190 "EvaluationItems": itemValueAdapter,
@@ -1295,40 +1418,117 @@ func (srv *SummaryEvaluationService) ListExecutorEvaluationSuper(param *command. @@ -1295,40 +1418,117 @@ func (srv *SummaryEvaluationService) ListExecutorEvaluationSuper(param *command.
1295 return result, nil 1418 return result, nil
1296 } 1419 }
1297 1420
1298 -// 员工确认综评考核结果  
1299 -func (srv *SummaryEvaluationService) ConfirmScoreSuperEvaluation(param *command.ConfirmScore) error {  
1300 - transactionContext, err := factory.CreateTransactionContext(nil) 1421 +// ConfirmScoreEvaluation 员工确认考核结果
  1422 +func (srv *SummaryEvaluationService) ConfirmScoreEvaluation(param *command.ConfirmScore) error {
  1423 + transactionContext, err := factory.ValidateStartTransaction(param)
1301 if err != nil { 1424 if err != nil {
1302 - return application.ThrowError(application.TRANSACTION_ERROR, err.Error())  
1303 - }  
1304 - if err := transactionContext.StartTransaction(); err != nil {  
1305 - return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 1425 + return err
1306 } 1426 }
1307 defer func() { 1427 defer func() {
1308 _ = transactionContext.RollbackTransaction() 1428 _ = transactionContext.RollbackTransaction()
1309 }() 1429 }()
1310 - evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{  
1311 - "transactionContext": transactionContext,  
1312 - })  
1313 1430
1314 - evaluationData, err := evaluationRepo.FindOne(map[string]interface{}{  
1315 - "id": param.SummaryEvaluationId,  
1316 - }) 1431 + evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext})
  1432 + evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext})
  1433 + itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext})
  1434 +
  1435 + // 考核结果
  1436 + result, err := evaluationRepo.FindOne(map[string]interface{}{"id": param.SummaryEvaluationId})
1317 if err != nil { 1437 if err != nil {
1318 return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 1438 return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
1319 } 1439 }
1320 - if evaluationData.Types != domain.EvaluationSuper { 1440 + if result.Types != domain.EvaluationFinish {
1321 return application.ThrowError(application.TRANSACTION_ERROR, "操作方式错误") 1441 return application.ThrowError(application.TRANSACTION_ERROR, "操作方式错误")
1322 } 1442 }
1323 - if evaluationData.TargetUser.UserId != param.UserId { 1443 + if result.TargetUser.UserId != param.UserId {
1324 return application.ThrowError(application.TRANSACTION_ERROR, "没有操作权限") 1444 return application.ThrowError(application.TRANSACTION_ERROR, "没有操作权限")
1325 } 1445 }
1326 - if evaluationData.Status == domain.EvaluationUncompleted {  
1327 - return application.ThrowError(application.TRANSACTION_ERROR, "上级还未正式提交评估内容") 1446 + if result.CheckResult == domain.EvaluationCheckCompleted {
  1447 + return application.ThrowError(application.TRANSACTION_ERROR, "考核结果已确认过了!")
1328 } 1448 }
1329 - evaluationData.CheckResult = domain.EvaluationCheckCompleted  
1330 - err = evaluationRepo.Save(evaluationData) 1449 + if result.Status == domain.EvaluationUncompleted {
  1450 + return application.ThrowError(application.TRANSACTION_ERROR, "前面流程暂未完成提交评估内容")
  1451 + }
  1452 +
  1453 + _, evaluationList, err := evaluationRepo.Find(map[string]interface{}{
  1454 + "companyId": result.CompanyId,
  1455 + "cycleId": result.CycleId,
  1456 + "targetUserId": result.TargetUser.UserId,
  1457 + })
  1458 + if err != nil {
  1459 + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  1460 + }
  1461 +
  1462 + var super *domain.SummaryEvaluation // 上级评估
  1463 + for i := range evaluationList {
  1464 + it := evaluationList[i]
  1465 + if it.Types == domain.EvaluationSuper {
  1466 + super = it
  1467 + break
  1468 + }
  1469 + }
  1470 +
  1471 + // 评估内容和值
  1472 + var itemList []*domain.EvaluationItemUsed
  1473 + var itemValues []*domain.SummaryEvaluationValue
  1474 +
  1475 + // 获取自评模板内容
  1476 + _, itemList, err = evaluationItemRepo.Find(map[string]interface{}{"evaluationProjectId": result.EvaluationProjectId, "nodeType": domain.LinkNodeSelfAssessment})
1331 if err != nil { 1477 if err != nil {
  1478 + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  1479 + }
  1480 +
  1481 + // 按评估项优先级顺序(已确认考核结果 ->上级评估 ->HR或360评估或自评)
  1482 + if super != nil {
  1483 + _, itemValues, err = itemValueRepo.Find(map[string]interface{}{"summaryEvaluationId": super.Id}) // 获取已填写的评估内容
  1484 + if err != nil {
  1485 + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  1486 + }
  1487 + // 更新填写值
  1488 + itemValues, err = srv.updateItemValuePriority(result, itemList, itemValues, true)
  1489 + if err != nil {
  1490 + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  1491 + }
  1492 + } else {
  1493 + // 评估项ID(除考核结果和上级)
  1494 + var evaluationIds = make([]int, 0)
  1495 + for i := range evaluationList {
  1496 + it := evaluationList[i]
  1497 + if it.Types == domain.EvaluationSelf || it.Types == domain.Evaluation360 || it.Types == domain.EvaluationHrbp {
  1498 + evaluationIds = append(evaluationIds, it.Id)
  1499 + }
  1500 + }
  1501 + if len(evaluationIds) > 0 {
  1502 + // 获取已填写的评估内容
  1503 + _, itemValues, err = itemValueRepo.Find(map[string]interface{}{"summaryEvaluationIdList": evaluationIds})
  1504 + if err != nil {
  1505 + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  1506 + }
  1507 +
  1508 + // 更新填写值
  1509 + itemValues, err = srv.updateItemValuePriority(result, itemList, itemValues, false)
  1510 + if err != nil {
  1511 + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  1512 + }
  1513 + }
  1514 + }
  1515 +
  1516 + for i := range itemValues {
  1517 + if err := itemValueRepo.Save(itemValues[i]); err != nil {
  1518 + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  1519 + }
  1520 + }
  1521 + //重置评级汇总
  1522 + result.TotalRating = nil
  1523 + for i := range itemList {
  1524 + result.ResetTotalRating(itemList[i])
  1525 + }
  1526 + if err := result.EvaluationTotalScore(itemValues); err != nil {
  1527 + return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  1528 + }
  1529 +
  1530 + result.CheckResult = domain.EvaluationCheckCompleted
  1531 + if err := evaluationRepo.Save(result); err != nil {
1332 return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 1532 return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
1333 } 1533 }
1334 if err := transactionContext.CommitTransaction(); err != nil { 1534 if err := transactionContext.CommitTransaction(); err != nil {
@@ -1337,107 +1537,184 @@ func (srv *SummaryEvaluationService) ConfirmScoreSuperEvaluation(param *command. @@ -1337,107 +1537,184 @@ func (srv *SummaryEvaluationService) ConfirmScoreSuperEvaluation(param *command.
1337 return nil 1537 return nil
1338 } 1538 }
1339 1539
1340 -// 按照周期和被评估的人 获取上级评估详情  
1341 -func (srv *SummaryEvaluationService) GetTargetUserEvaluationSuper(param *command.QueryEvaluation) (*adapter.EvaluationInfoSuperAdapter, error) {  
1342 - transactionContext, err := factory.CreateTransactionContext(nil)  
1343 - if err != nil {  
1344 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 1540 +// 处理优先级
  1541 +func (srv *SummaryEvaluationService) updateItemValuePriority(
  1542 + result *domain.SummaryEvaluation,
  1543 + itemList []*domain.EvaluationItemUsed,
  1544 + itemValues []*domain.SummaryEvaluationValue,
  1545 + superior bool) ([]*domain.SummaryEvaluationValue, error) {
  1546 +
  1547 + tempSelf := map[int]*domain.SummaryEvaluationValue{}
  1548 + temp360 := map[int]*domain.SummaryEvaluationValue{}
  1549 + tempHRBP := map[int]*domain.SummaryEvaluationValue{}
  1550 + tempSuperior := map[int]*domain.SummaryEvaluationValue{}
  1551 +
  1552 + for i := range itemValues {
  1553 + it := itemValues[i]
  1554 + if it.Types == domain.EvaluationSelf {
  1555 + tempSelf[it.EvaluationItemId] = it
  1556 + } else if it.Types == domain.Evaluation360 {
  1557 + temp360[it.EvaluationItemId] = it
  1558 + } else if it.Types == domain.EvaluationHrbp {
  1559 + tempHRBP[it.EvaluationItemId] = it
  1560 + } else if it.Types == domain.EvaluationSuper {
  1561 + tempSuperior[it.EvaluationItemId] = it
  1562 + }
1345 } 1563 }
1346 - if err := transactionContext.StartTransaction(); err != nil { 1564 + nowTime := time.Now()
  1565 + var newItemValues = make([]*domain.SummaryEvaluationValue, 0)
  1566 + for i := range itemList {
  1567 + it := itemList[i]
  1568 +
  1569 + var tempValue domain.SummaryEvaluationValue
  1570 + tempValue.SetBlankValue(result, it)
  1571 +
  1572 + if superior /* 上级数据 */ {
  1573 + if v, ok := tempSuperior[it.Id]; ok {
  1574 + tempValue = *v
  1575 + }
  1576 + tempValue.Types = domain.EvaluationSuper
  1577 + } else /* 其它数据 */ {
  1578 + if it.EvaluatorId == 0 {
  1579 + if v, ok := tempSelf[it.Id]; ok {
  1580 + tempValue = *v
  1581 + }
  1582 + tempValue.Types = domain.EvaluationSelf
  1583 + } else if it.EvaluatorId == -1 {
  1584 + if v, ok := tempHRBP[it.Id]; ok {
  1585 + tempValue = *v
  1586 + }
  1587 + tempValue.Types = domain.EvaluationHrbp
  1588 + } else if it.EvaluatorId > 0 {
  1589 + if v, ok := temp360[it.Id]; ok {
  1590 + tempValue = *v
  1591 + }
  1592 + tempValue.Types = domain.Evaluation360
  1593 + }
  1594 + }
  1595 +
  1596 + // ID置空
  1597 + tempValue.Id = 0
  1598 + tempValue.CreatedAt = nowTime
  1599 + tempValue.UpdatedAt = nowTime
  1600 + newItemValues = append(newItemValues, &tempValue)
  1601 + }
  1602 + return newItemValues, nil
  1603 +}
  1604 +
  1605 +// GetTargetEvaluationResult 按照周期和被评估的人 获取考核结果
  1606 +func (srv *SummaryEvaluationService) GetTargetEvaluationResult(param *command.QueryEvaluation) (*adapter.EvaluationInfoSuperAdapter, error) {
  1607 + transactionContext, err := factory.ValidateStartTransaction(param)
  1608 + if err != nil {
1347 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 1609 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
1348 } 1610 }
  1611 + // if err := transactionContext.StartTransaction(); err != nil {
  1612 + // return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  1613 + // }
1349 defer func() { 1614 defer func() {
1350 _ = transactionContext.RollbackTransaction() 1615 _ = transactionContext.RollbackTransaction()
1351 }() 1616 }()
1352 - evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{  
1353 - "transactionContext": transactionContext,  
1354 - })  
1355 - evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{  
1356 - "transactionContext": transactionContext,  
1357 - })  
1358 - itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{  
1359 - "transactionContext": transactionContext,  
1360 - })  
1361 - permissionRepository := factory.CreatePermissionRepository(map[string]interface{}{"transactionContext": transactionContext})  
1362 - // 获取权限配置  
1363 - _, permissionList, err := permissionRepository.Find(map[string]interface{}{"companyId": param.CompanyId})  
1364 - if err != nil {  
1365 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
1366 - } 1617 + evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext})
  1618 + evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext})
  1619 + itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext})
  1620 +
1367 _, evaluationList, err := evaluationRepo.Find(map[string]interface{}{ 1621 _, evaluationList, err := evaluationRepo.Find(map[string]interface{}{
1368 - "limit": 1, 1622 + "companyId": param.CompanyId,
1369 "cycleId": param.CycleId, 1623 "cycleId": param.CycleId,
1370 "targetUserId": param.TargetUserId, 1624 "targetUserId": param.TargetUserId,
1371 - "types": domain.EvaluationSuper,  
1372 }) 1625 })
1373 if err != nil { 1626 if err != nil {
1374 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1627 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
1375 } 1628 }
1376 - if len(evaluationList) == 0 {  
1377 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有找到符合条件的数据")  
1378 - }  
1379 - evaluationData := evaluationList[0]  
1380 - if evaluationData.CompanyId != param.CompanyId {  
1381 - return nil, application.ThrowError(application.BUSINESS_ERROR, "没有操作权限") 1629 +
  1630 + var result *domain.SummaryEvaluation // 绩效考核结果项
  1631 + var super *domain.SummaryEvaluation // 上级评估
  1632 + for i := range evaluationList {
  1633 + it := evaluationList[i]
  1634 + if it.Types == domain.EvaluationFinish {
  1635 + result = it
  1636 + continue
  1637 + }
  1638 + if it.Types == domain.EvaluationSuper {
  1639 + super = it
  1640 + continue
  1641 + }
1382 } 1642 }
1383 - _, itemList, err := evaluationItemRepo.Find(map[string]interface{}{  
1384 - "evaluationProjectId": evaluationData.EvaluationProjectId,  
1385 - "nodeType": int(domain.LinkNodeSelfAssessment),  
1386 - })  
1387 - if err != nil {  
1388 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1643 + if result == nil {
  1644 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有找到符合条件的数据")
1389 } 1645 }
1390 - //获取已填写的评估内容  
1391 - _, itemValues, err := itemValueRepo.Find(map[string]interface{}{  
1392 - "summaryEvaluationId": evaluationData.Id,  
1393 - })  
1394 1646
  1647 + // 评估内容和值
  1648 + var itemList []*domain.EvaluationItemUsed
  1649 + var itemValues []*domain.SummaryEvaluationValue
  1650 +
  1651 + // 获取自评模板内容
  1652 + _, itemList, err = evaluationItemRepo.Find(map[string]interface{}{"evaluationProjectId": result.EvaluationProjectId, "nodeType": domain.LinkNodeSelfAssessment})
1395 if err != nil { 1653 if err != nil {
1396 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1654 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
1397 } 1655 }
1398 - if len(itemValues) == 0 {  
1399 - //上级还未填写评估,获取 360 ,人资评估  
1400 - _, evaluationListOther, err := evaluationRepo.Find(map[string]interface{}{  
1401 - "typesList": []int{int(domain.Evaluation360), int(domain.EvaluationHrbp)},  
1402 - "targetUserId": evaluationData.TargetUser.UserId,  
1403 - "cycleId": evaluationData.CycleId,  
1404 - }) 1656 +
  1657 + // 按评估项优先级顺序(已确认考核结果 ->上级评估 ->HR或360评估或自评)
  1658 + if result.CheckResult == domain.EvaluationCheckCompleted { /* 已完成考核*/
  1659 + _, itemValues, err = itemValueRepo.Find(map[string]interface{}{"summaryEvaluationId": result.Id}) // 获取已填写的评估内容
1405 if err != nil { 1660 if err != nil {
1406 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1661 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
1407 } 1662 }
1408 - evaluationIds := []int{}  
1409 - for _, v := range evaluationListOther {  
1410 - evaluationIds = append(evaluationIds, v.Id)  
1411 - }  
1412 - if len(evaluationIds) > 0 {  
1413 - _, itemValues, err = itemValueRepo.Find(map[string]interface{}{  
1414 - "summaryEvaluationIdList": evaluationIds,  
1415 - }) 1663 + } else {
  1664 + if super != nil {
  1665 + _, itemValues, err = itemValueRepo.Find(map[string]interface{}{"summaryEvaluationId": super.Id}) // 获取已填写的评估内容
1416 if err != nil { 1666 if err != nil {
1417 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1667 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
1418 } 1668 }
  1669 + } else {
  1670 + // 评估项ID(除考核结果和上级)
  1671 + var evaluationIds = make([]int, 0)
  1672 + for i := range evaluationList {
  1673 + it := evaluationList[i]
  1674 + if it.Types == domain.EvaluationSelf || it.Types == domain.Evaluation360 || it.Types == domain.EvaluationHrbp {
  1675 + evaluationIds = append(evaluationIds, it.Id)
  1676 + }
  1677 + }
  1678 + if len(evaluationIds) > 0 {
  1679 + // 获取已填写的评估内容
  1680 + _, itemValues, err = itemValueRepo.Find(map[string]interface{}{"summaryEvaluationIdList": evaluationIds})
  1681 + if err != nil {
  1682 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  1683 + }
  1684 +
  1685 + // 更新填写值
  1686 + itemValues, err = srv.updateItemValuePriority(result, itemList, itemValues, false)
  1687 + if err != nil {
  1688 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  1689 + }
  1690 + }
1419 } 1691 }
1420 } 1692 }
1421 - evaluationBase := srv.getSummaryEvaluation(transactionContext, evaluationData) 1693 + // 未完成考核,需要重新计算分数
  1694 + if result.CheckResult == domain.EvaluationCheckUncompleted {
  1695 + result.TotalRating = nil
  1696 + for i := range itemList {
  1697 + result.ResetTotalRating(itemList[i])
  1698 + }
  1699 + if err = result.EvaluationTotalScore(itemValues); err != nil {
  1700 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  1701 + }
  1702 + }
  1703 +
  1704 + // 基础数据
  1705 + evaluationBase := srv.getSummaryEvaluation(transactionContext, result)
  1706 +
1422 if err := transactionContext.CommitTransaction(); err != nil { 1707 if err := transactionContext.CommitTransaction(); err != nil {
1423 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1708 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
1424 } 1709 }
1425 - //组合 评估填写的值和评估项 1710 +
  1711 + // 组合 评估填写的值和评估项
1426 itemValuesAdapter := srv.buildSummaryItemValue(itemList, itemValues) 1712 itemValuesAdapter := srv.buildSummaryItemValue(itemList, itemValues)
1427 - codeList := []*adapter.LevalCodeCount{} 1713 +
1428 codeMap := map[string]*adapter.LevalCodeCount{} 1714 codeMap := map[string]*adapter.LevalCodeCount{}
1429 - for i, v := range itemValuesAdapter {  
1430 - if len(permissionList) > 0 {  
1431 - if permissionList[0].OptEvalScore == domain.PermissionOff &&  
1432 - v.EvaluatorId > 0 {  
1433 - itemValuesAdapter[i].ForbidEdit = true  
1434 - }  
1435 - if permissionList[0].OptHrScore == domain.PermissionOff &&  
1436 - v.EvaluatorId < 0 {  
1437 - itemValuesAdapter[i].ForbidEdit = true  
1438 - }  
1439 - }  
1440 - if v.Weight == 0 { 1715 + for _, v := range itemValuesAdapter {
  1716 + //处理加分项评级汇总
  1717 + if v.Weight == 0 && len(v.Value) > 0 {
1441 if _, ok := codeMap[v.Value]; !ok { 1718 if _, ok := codeMap[v.Value]; !ok {
1442 code := &adapter.LevalCodeCount{ 1719 code := &adapter.LevalCodeCount{
1443 Code: v.Value, 1720 Code: v.Value,
@@ -1445,23 +1722,33 @@ func (srv *SummaryEvaluationService) GetTargetUserEvaluationSuper(param *command @@ -1445,23 +1722,33 @@ func (srv *SummaryEvaluationService) GetTargetUserEvaluationSuper(param *command
1445 ItemList: []string{}, 1722 ItemList: []string{},
1446 } 1723 }
1447 codeMap[v.Value] = code 1724 codeMap[v.Value] = code
1448 - codeList = append(codeList, code)  
1449 } 1725 }
1450 codeMap[v.Value].ItemList = append(codeMap[v.Value].ItemList, v.Name) 1726 codeMap[v.Value].ItemList = append(codeMap[v.Value].ItemList, v.Name)
1451 codeMap[v.Value].Number += 1 1727 codeMap[v.Value].Number += 1
1452 } 1728 }
1453 } 1729 }
1454 -  
1455 - result := adapter.EvaluationInfoSuperAdapter{ 1730 + codeList := make([]*adapter.LevalCodeCount, 0)
  1731 + for _, val := range result.TotalRating {
  1732 + if codeItem, ok := codeMap[val.Code]; ok {
  1733 + codeList = append(codeList, codeItem)
  1734 + } else {
  1735 + codeList = append(codeList, &adapter.LevalCodeCount{
  1736 + Code: val.Code,
  1737 + Number: 0,
  1738 + ItemList: []string{},
  1739 + })
  1740 + }
  1741 + }
  1742 + eiAdapter := adapter.EvaluationInfoSuperAdapter{
1456 EvaluationBaseAdapter: evaluationBase, 1743 EvaluationBaseAdapter: evaluationBase,
1457 LevelCount: codeList, 1744 LevelCount: codeList,
1458 EvaluationItems: itemValuesAdapter, 1745 EvaluationItems: itemValuesAdapter,
1459 } 1746 }
1460 - return &result, nil 1747 + return &eiAdapter, nil
1461 } 1748 }
1462 1749
1463 -// 获取周期综合评估下,周期评估列表  
1464 -func (srv *SummaryEvaluationService) ListAllEvaluationSuper(param *command.QueryEvaluationList) (map[string]interface{}, error) { 1750 +// 按周期获取所有员工的评估考核结果
  1751 +func (srv *SummaryEvaluationService) ListAllEvaluationFinish(param *command.QueryEvaluationList) (map[string]interface{}, error) {
1465 transactionContext, err := factory.CreateTransactionContext(nil) 1752 transactionContext, err := factory.CreateTransactionContext(nil)
1466 if err != nil { 1753 if err != nil {
1467 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 1754 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -1489,7 +1776,7 @@ func (srv *SummaryEvaluationService) ListAllEvaluationSuper(param *command.Query @@ -1489,7 +1776,7 @@ func (srv *SummaryEvaluationService) ListAllEvaluationSuper(param *command.Query
1489 "parentId": param.UserId, 1776 "parentId": param.UserId,
1490 "limit": 1, 1777 "limit": 1,
1491 }) 1778 })
1492 - if len(parentUser) == 0 { 1779 + if len(parentUser) == 0 && flagHrbp != 1 {
1493 return tool_funs.SimpleWrapGridMap(0, []string{}), nil 1780 return tool_funs.SimpleWrapGridMap(0, []string{}), nil
1494 } 1781 }
1495 evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{ 1782 evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{
@@ -1505,7 +1792,7 @@ func (srv *SummaryEvaluationService) ListAllEvaluationSuper(param *command.Query @@ -1505,7 +1792,7 @@ func (srv *SummaryEvaluationService) ListAllEvaluationSuper(param *command.Query
1505 //获取评估列表信息 1792 //获取评估列表信息
1506 condition1 := map[string]interface{}{ 1793 condition1 := map[string]interface{}{
1507 "cycleId": param.CycleId, 1794 "cycleId": param.CycleId,
1508 - "types": int(domain.EvaluationSuper), 1795 + "types": int(domain.EvaluationFinish),
1509 "limit": limit, 1796 "limit": limit,
1510 "beginTime": time.Now(), 1797 "beginTime": time.Now(),
1511 } 1798 }
@@ -1606,12 +1893,14 @@ func (srv *SummaryEvaluationService) editEvaluationValue( @@ -1606,12 +1893,14 @@ func (srv *SummaryEvaluationService) editEvaluationValue(
1606 } 1893 }
1607 evaluationItemMap := map[int]*domain.EvaluationItemUsed{} 1894 evaluationItemMap := map[int]*domain.EvaluationItemUsed{}
1608 evaluationValueMap := map[int]*domain.SummaryEvaluationValue{} 1895 evaluationValueMap := map[int]*domain.SummaryEvaluationValue{}
  1896 + evaluationValueSlice := []*domain.SummaryEvaluationValue{}
1609 evaluationData.TotalRating = nil //清空评级数量统计 1897 evaluationData.TotalRating = nil //清空评级数量统计
1610 for _, v := range evaluationItems { 1898 for _, v := range evaluationItems {
1611 newValue := &domain.SummaryEvaluationValue{} 1899 newValue := &domain.SummaryEvaluationValue{}
1612 newValue.SetBlankValue(evaluationData, v) 1900 newValue.SetBlankValue(evaluationData, v)
1613 evaluationValueMap[v.Id] = newValue 1901 evaluationValueMap[v.Id] = newValue
1614 evaluationItemMap[v.Id] = v 1902 evaluationItemMap[v.Id] = v
  1903 + evaluationValueSlice = append(evaluationValueSlice, newValue)
1615 //重置计数 1904 //重置计数
1616 evaluationData.ResetTotalRating(v) 1905 evaluationData.ResetTotalRating(v)
1617 } 1906 }
@@ -1669,10 +1958,14 @@ func (srv *SummaryEvaluationService) editEvaluationValue( @@ -1669,10 +1958,14 @@ func (srv *SummaryEvaluationService) editEvaluationValue(
1669 } 1958 }
1670 } 1959 }
1671 //完全更新itemValueList 1960 //完全更新itemValueList
1672 - *itemValueList = (*itemValueList)[0:0]  
1673 - for _, v := range evaluationValueMap {  
1674 - *itemValueList = append(*itemValueList, v)  
1675 - } 1961 + *itemValueList = evaluationValueSlice
  1962 + // *itemValueList = (*itemValueList)[0:0]
  1963 + // for _, v := range evaluationValueMap {
  1964 + // *itemValueList = append(*itemValueList, v)
  1965 + // }
  1966 + // sort.Slice(*itemValueList, func(i, j int) bool {
  1967 + // return (*itemValueList)[i].EvaluationItemId < (*itemValueList)[j].EvaluationItemId
  1968 + // })
1676 // 计算总得分 1969 // 计算总得分
1677 err := evaluationData.EvaluationTotalScore(*itemValueList) 1970 err := evaluationData.EvaluationTotalScore(*itemValueList)
1678 if err != nil { 1971 if err != nil {
@@ -1685,7 +1978,7 @@ func (srv *SummaryEvaluationService) editEvaluationValue( @@ -1685,7 +1978,7 @@ func (srv *SummaryEvaluationService) editEvaluationValue(
1685 func (srv *SummaryEvaluationService) ListExecutorNowEvaluationSelf(param *command.QueryExecutorEvaluationList) (map[string]interface{}, error) { 1978 func (srv *SummaryEvaluationService) ListExecutorNowEvaluationSelf(param *command.QueryExecutorEvaluationList) (map[string]interface{}, error) {
1686 transactionContext, err := factory.CreateTransactionContext(nil) 1979 transactionContext, err := factory.CreateTransactionContext(nil)
1687 if err != nil { 1980 if err != nil {
1688 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 1981 + return nil, err
1689 } 1982 }
1690 if err := transactionContext.StartTransaction(); err != nil { 1983 if err := transactionContext.StartTransaction(); err != nil {
1691 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 1984 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -21,7 +21,7 @@ type EvaluationItemUsed struct { @@ -21,7 +21,7 @@ type EvaluationItemUsed struct {
21 Rule EvaluationRule //评估的选项规则 21 Rule EvaluationRule //评估的选项规则
22 Weight float64 //"权重" 22 Weight float64 //"权重"
23 Required int //必填项 同 NodeContent.Required 23 Required int //必填项 同 NodeContent.Required
24 - EvaluatorId int //项目评估人ID ( 0=无评估人、-1=HRBP、 >0 =员工的id ) 24 + EvaluatorId int //项目评估人ID ( 0=无评估人、-1=HRBP、 >0 员工的id )
25 CreatedAt time.Time //数据创建时间 25 CreatedAt time.Time //数据创建时间
26 UpdatedAt time.Time //数据更新时间 26 UpdatedAt time.Time //数据更新时间
27 } 27 }
  1 +package domain
  2 +
  3 +import "time"
  4 +
  5 +// MessagePersonal 个人的消息提示
  6 +type MessagePersonal struct {
  7 + Id int `json:"id"` //
  8 + Types MessageTypes `json:"types"` //消息类型
  9 + TargetUserId int `json:"targetUserId"` //消息指向的用户
  10 + ReadFlag MessageReadFlag `json:"readFlag"` //1:已读、2:未读
  11 + Title string `json:"title"` //消息的标题
  12 + Content string `json:"content"` //消息的内容
  13 + CreatedAt time.Time `json:"createdAt"`
  14 + UpdatedAt time.Time `json:"updatedAt"`
  15 + Payload string `json:"payload"` //消息的额外承载的数据
  16 +}
  17 +
  18 +type MessageTypes string
  19 +
  20 +const (
  21 + MessageTypesOther MessageTypes = "other"
  22 +)
  23 +
  24 +type MessageReadFlag string
  25 +
  26 +const (
  27 + MessageIsRead MessageReadFlag = "read"
  28 + MessageUnread MessageReadFlag = "unread"
  29 +)
  30 +
  31 +type MessagePersonalRepository interface {
  32 + Save(param *MessagePersonal) error
  33 + Find(queryOptions map[string]interface{}) (int, []*MessagePersonal, error)
  34 +}
@@ -263,6 +263,9 @@ func getEvaluator(items []*PerformanceApplicationForm) (string, error) { @@ -263,6 +263,9 @@ func getEvaluator(items []*PerformanceApplicationForm) (string, error) {
263 return "", errors.New(item.ModuleName + " 对应的项目评估人填不一致") 263 return "", errors.New(item.ModuleName + " 对应的项目评估人填不一致")
264 } 264 }
265 } 265 }
  266 + if prevName == "/" {
  267 + prevName = ""
  268 + }
266 return prevName, nil 269 return prevName, nil
267 } 270 }
268 271
@@ -39,11 +39,11 @@ type RatingCodeNumber struct { @@ -39,11 +39,11 @@ type RatingCodeNumber struct {
39 type EvaluationType int //综合评估类型 39 type EvaluationType int //综合评估类型
40 40
41 const ( 41 const (
42 - EvaluationSelf EvaluationType = 1 //自评  
43 - Evaluation360 EvaluationType = 2 //360评估  
44 - EvaluationSuper EvaluationType = 3 //上级评估  
45 - EvaluationHrbp EvaluationType = 4 //人资评估  
46 - 42 + EvaluationSelf EvaluationType = 1 //自评
  43 + Evaluation360 EvaluationType = 2 //360评估
  44 + EvaluationSuper EvaluationType = 3 //上级评估
  45 + EvaluationHrbp EvaluationType = 4 //人资评估
  46 + EvaluationFinish EvaluationType = 5 //考核结果
47 ) 47 )
48 48
49 // 评估的填写状态 49 // 评估的填写状态
@@ -72,6 +72,9 @@ type SummaryEvaluationRepository interface { @@ -72,6 +72,9 @@ type SummaryEvaluationRepository interface {
72 72
73 // 计算总分。TotalScore 保留1位小数 73 // 计算总分。TotalScore 保留1位小数
74 func (evaluation *SummaryEvaluation) EvaluationTotalScore(valueList []*SummaryEvaluationValue) error { 74 func (evaluation *SummaryEvaluation) EvaluationTotalScore(valueList []*SummaryEvaluationValue) error {
  75 + //重置计数
  76 + evaluation.TotalScore = "0"
  77 + //汇总评估填写值
75 var totalScore float64 78 var totalScore float64
76 for _, v := range valueList { 79 for _, v := range valueList {
77 if v.Weight == 0 { 80 if v.Weight == 0 {
@@ -17,6 +17,7 @@ type SummaryEvaluationValue struct { @@ -17,6 +17,7 @@ type SummaryEvaluationValue struct {
17 Score string `json:"score"` //评定得分 17 Score string `json:"score"` //评定得分
18 Types EvaluationType `json:"types"` //评估类型 18 Types EvaluationType `json:"types"` //评估类型
19 Remark string `json:"remark"` //填写的内容反馈 19 Remark string `json:"remark"` //填写的内容反馈
  20 + Executor StaffDesc `json:"executor"` //填写评估的用户,执行人
20 Weight float64 `json:"weight"` //"权重" 21 Weight float64 `json:"weight"` //"权重"
21 Rating RatingLevel `json:"rating"` //评级时的填写值 22 Rating RatingLevel `json:"rating"` //评级时的填写值
22 CreatedAt time.Time `json:"createdAt"` //数据创建时间 23 CreatedAt time.Time `json:"createdAt"` //数据创建时间
@@ -36,11 +37,12 @@ func (itemValue *SummaryEvaluationValue) SetBlankValue(evaluation *SummaryEvalua @@ -36,11 +37,12 @@ func (itemValue *SummaryEvaluationValue) SetBlankValue(evaluation *SummaryEvalua
36 itemValue.EvaluationItemId = item.Id 37 itemValue.EvaluationItemId = item.Id
37 itemValue.SummaryEvaluationId = evaluation.Id 38 itemValue.SummaryEvaluationId = evaluation.Id
38 itemValue.Value = "" 39 itemValue.Value = ""
39 - itemValue.Score = "" 40 + itemValue.Score = "0"
40 itemValue.Remark = "" 41 itemValue.Remark = ""
41 itemValue.Weight = item.Weight 42 itemValue.Weight = item.Weight
42 itemValue.CreatedAt = time.Now() 43 itemValue.CreatedAt = time.Now()
43 itemValue.UpdatedAt = time.Now() 44 itemValue.UpdatedAt = time.Now()
  45 + itemValue.Executor = evaluation.Executor
44 } 46 }
45 47
46 // 填充评估的内容 48 // 填充评估的内容
@@ -50,6 +50,7 @@ func (userAuth *UserAuth) ParseAccessToken(token string) (*UserAuth, error) { @@ -50,6 +50,7 @@ func (userAuth *UserAuth) ParseAccessToken(token string) (*UserAuth, error) {
50 user.PlatformId = claim.PlatformId 50 user.PlatformId = claim.PlatformId
51 user.Name = claim.Name 51 user.Name = claim.Name
52 user.AdminType = claim.AdminType 52 user.AdminType = claim.AdminType
  53 + user.CompanyName = claim.CompanyName
53 return user, nil 54 return user, nil
54 } 55 }
55 return user, errors.New("解析token失败") 56 return user, errors.New("解析token失败")
1 package domain 1 package domain
2 2
3 -import "testing" 3 +import (
  4 + "testing"
  5 +
  6 + "github.com/dgrijalva/jwt-go"
  7 +)
4 8
5 func TestGenerateToken(t *testing.T) { 9 func TestGenerateToken(t *testing.T) {
6 ut := UserAuth{ 10 ut := UserAuth{
7 CompanyId: 8, 11 CompanyId: 8,
8 - UserId: 3422174102828544,  
9 - Phone: "17708397664", 12 + UserId: 3422052605249024,
  13 + Phone: "13677777777",
10 PlatformId: 29, 14 PlatformId: 29,
11 AdminType: 1, 15 AdminType: 1,
12 } 16 }
13 tk, _ := ut.CreateAccessToken() 17 tk, _ := ut.CreateAccessToken()
14 t.Log(tk) 18 t.Log(tk)
15 } 19 }
  20 +
  21 +func TestParsetToken1(t *testing.T) {
  22 + ut := UserAuth{}
  23 + str := `eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOjM0MjE4NDc3MjcyOTYwMDAsImNvbXBhbnlJZCI6MTAsImNvbXBhbnlOYW1lIjoi5aSp6IGU5L-h5oGv56eR5oqA5pyJ6ZmQ5YWs5Y-4IiwicGhvbmUiOiIxNTY1OTM3NTk0MCIsInBsYXRmb3JtSWQiOjI5LCJuYW1lIjoi5bq35Lyf5Y2OIiwiYWRtaW5UeXBlIjoxfQ.v4qNLvYST03XpBdGnhYTK78A9v_k5IOdZ4r-WmDwfYg`
  24 + tk, _ := ut.ParseAccessToken(str)
  25 + t.Logf("%+v", tk)
  26 +}
  27 +func TestParsetToken2(t *testing.T) {
  28 + ut := UserAuth{}
  29 + str := `eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOjM0MjYxMDAxMTcwOTM4ODgsImNvbXBhbnlJZCI6MSwiY29tcGFueU5hbWUiOiLnpo_lt57ntKDlpKnkuIvpo5_lk4HmnInpmZDlhazlj7giLCJwaG9uZSI6IjE1NjU5Mzc1OTQwIiwicGxhdGZvcm1JZCI6MjksIm5hbWUiOiLlurfkvJ_ljY4iLCJhZG1pblR5cGUiOjF9.BwJ2mLdTlFKF322y4GeqPOW6wKroIrPSI8eNyuQEMkQ`
  30 + tk, _ := ut.ParseAccessToken(str)
  31 + t.Logf("===》%+v", tk)
  32 + tk.StandardClaims = jwt.StandardClaims{}
  33 + tk.PlatformId = 29
  34 + tkStr, _ := tk.CreateAccessToken()
  35 + t.Logf(" ===》%v", tkStr)
  36 +}
@@ -5,7 +5,6 @@ import ( @@ -5,7 +5,6 @@ import (
5 5
6 "github.com/go-pg/pg/v10" 6 "github.com/go-pg/pg/v10"
7 pgTransaction "github.com/linmadan/egglib-go/transaction/pg" 7 pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
8 - "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"  
9 ) 8 )
10 9
11 type SummaryEvaluationDao struct { 10 type SummaryEvaluationDao struct {
@@ -31,7 +30,7 @@ type ExecutorCycle struct { @@ -31,7 +30,7 @@ type ExecutorCycle struct {
31 // GetExecutorCycleList 获取执行人拥有的周期列表 30 // GetExecutorCycleList 获取执行人拥有的周期列表
32 // executorId 执行人id 31 // executorId 执行人id
33 // offset,limit 分页 32 // offset,limit 分页
34 -func (d *SummaryEvaluationDao) GetExecutorCycleList(executorId int, offset int, limit int, isHrbp bool) ([]ExecutorCycle, error) { 33 +func (d *SummaryEvaluationDao) GetExecutorCycleList(companyId int, executorId int, offset int, limit int, isHrbp bool) ([]ExecutorCycle, error) {
35 sqlStr := `select 34 sqlStr := `select
36 distinct on( 35 distinct on(
37 summary_evaluation.cycle_id , 36 summary_evaluation.cycle_id ,
@@ -40,14 +39,16 @@ func (d *SummaryEvaluationDao) GetExecutorCycleList(executorId int, offset int, @@ -40,14 +39,16 @@ func (d *SummaryEvaluationDao) GetExecutorCycleList(executorId int, offset int,
40 summary_evaluation.cycle_id , 39 summary_evaluation.cycle_id ,
41 summary_evaluation.cycle_name 40 summary_evaluation.cycle_name
42 from summary_evaluation 41 from summary_evaluation
43 - where summary_evaluation.executor ->>'userId'='?' 42 + where summary_evaluation.company_id=?
44 ` 43 `
45 tx := d.transactionContext.PgTx 44 tx := d.transactionContext.PgTx
46 condition := []interface{}{ 45 condition := []interface{}{
47 - executorId, 46 + companyId, executorId,
48 } 47 }
49 if isHrbp { 48 if isHrbp {
50 - sqlStr += ` or summary_evaluation."types"=4 ` 49 + sqlStr += ` and (summary_evaluation.executor ->>'userId'='?' or summary_evaluation."types"=4 ) `
  50 + } else {
  51 + sqlStr += ` and (summary_evaluation.executor ->>'userId'='?') `
51 } 52 }
52 condition = append(condition, offset, limit) 53 condition = append(condition, offset, limit)
53 54
@@ -58,22 +59,22 @@ func (d *SummaryEvaluationDao) GetExecutorCycleList(executorId int, offset int, @@ -58,22 +59,22 @@ func (d *SummaryEvaluationDao) GetExecutorCycleList(executorId int, offset int,
58 } 59 }
59 60
60 // CountExecutorCycleList 统计执行人拥有的周期列表 61 // CountExecutorCycleList 统计执行人拥有的周期列表
61 -func (d *SummaryEvaluationDao) CountExecutorCycleList(executorId int, evaluationType domain.EvaluationType) (int, error) { 62 +func (d *SummaryEvaluationDao) CountExecutorCycleList(companyId int, executorId int, isHrbp bool) (int, error) {
62 sqlStr := `select count( 63 sqlStr := `select count(
63 distinct summary_evaluation.cycle_id 64 distinct summary_evaluation.cycle_id
64 ) as cnt 65 ) as cnt
65 from summary_evaluation 66 from summary_evaluation
66 - where summary_evaluation.executor ->>'userId'='?' ` 67 + where summary_evaluation.company_id=? `
67 68
68 tx := d.transactionContext.PgTx 69 tx := d.transactionContext.PgTx
69 condition := []interface{}{ 70 condition := []interface{}{
70 - executorId, 71 + companyId, executorId,
71 } 72 }
72 - if evaluationType > 0 {  
73 - sqlStr += ` and summary_evaluation."types"=? `  
74 - condition = append(condition, int(evaluationType)) 73 + if isHrbp {
  74 + sqlStr += ` and (summary_evaluation.executor ->>'userId'='?' or summary_evaluation."types"=4 ) `
  75 + } else {
  76 + sqlStr += ` and (summary_evaluation.executor ->>'userId'='?') `
75 } 77 }
76 -  
77 var cnt int 78 var cnt int
78 _, err := tx.QueryOne(pg.Scan(&cnt), sqlStr, condition...) 79 _, err := tx.QueryOne(pg.Scan(&cnt), sqlStr, condition...)
79 return cnt, err 80 return cnt, err
@@ -51,6 +51,7 @@ func init() { @@ -51,6 +51,7 @@ func init() {
51 &models.SummaryEvaluationValue{}, 51 &models.SummaryEvaluationValue{},
52 &models.Permission{}, 52 &models.Permission{},
53 &models.LogSms{}, 53 &models.LogSms{},
  54 + &models.MessagePersonal{},
54 } 55 }
55 for _, model := range tables { 56 for _, model := range tables {
56 err := DB.Model(model).CreateTable(&orm.CreateTableOptions{ 57 err := DB.Model(model).CreateTable(&orm.CreateTableOptions{
  1 +package models
  2 +
  3 +import "time"
  4 +
  5 +// MessagePersonal 记录个人的提示消息
  6 +type MessagePersonal struct {
  7 + tableName struct{} `comment:"记录个人的提示消息" pg:"message_personal"`
  8 + Id int `pg:"id,pk"` //
  9 + Types string `pg:"types"` //消息类型
  10 + TargetUserId int `pg:"target_user_id"` //消息指向的用户
  11 + ReadFlag string `pg:"read_flag"` //1:已读、2:未读
  12 + Title string `pg:"title"` //消息的标题
  13 + Content string `pg:"content"` //消息的内容
  14 + CreatedAt time.Time `pg:"created_at"`
  15 + UpdatedAt time.Time `pg:"updated_at"`
  16 + Payload string `pg:"payload,type:jsonb"` //消息的额外承载的数据
  17 +}
@@ -15,6 +15,7 @@ type SummaryEvaluationValue struct { @@ -15,6 +15,7 @@ type SummaryEvaluationValue struct {
15 Value string //评估填写的评分 15 Value string //评估填写的评分
16 Score string //评定得分 16 Score string //评定得分
17 Types int //评估类型 17 Types int //评估类型
  18 + Executor domain.StaffDesc //填写评估的用户,执行人
18 Weight float64 //权重 19 Weight float64 //权重
19 Rating domain.RatingLevel //评级填写值 20 Rating domain.RatingLevel //评级填写值
20 Remark string //填写的内容反馈 21 Remark string //填写的内容反馈
@@ -36,6 +36,7 @@ func (repo *LogSmsRepository) Save(param *domain.LogSms) error { @@ -36,6 +36,7 @@ func (repo *LogSmsRepository) Save(param *domain.LogSms) error {
36 if err != nil { 36 if err != nil {
37 return err 37 return err
38 } 38 }
  39 + return nil
39 } 40 }
40 _, err := tx.Model(&m).WherePK().Update() 41 _, err := tx.Model(&m).WherePK().Update()
41 if err != nil { 42 if err != nil {
  1 +package repository
  2 +
  3 +import (
  4 + "time"
  5 +
  6 + pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
  7 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
  8 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/pg/models"
  9 +)
  10 +
  11 +type MessagePersonalRepository struct {
  12 + transactionContext *pgTransaction.TransactionContext
  13 +}
  14 +
  15 +var _ domain.MessagePersonalRepository = (*MessagePersonalRepository)(nil)
  16 +
  17 +func NewMessagePersonalRepository(tx *pgTransaction.TransactionContext) *MessagePersonalRepository {
  18 + return &MessagePersonalRepository{
  19 + transactionContext: tx,
  20 + }
  21 +}
  22 +
  23 +func (repo *MessagePersonalRepository) TransformToDomain(param *models.MessagePersonal) *domain.MessagePersonal {
  24 + return &domain.MessagePersonal{
  25 + Id: param.Id,
  26 + Types: domain.MessageTypes(param.Types),
  27 + TargetUserId: param.TargetUserId,
  28 + ReadFlag: domain.MessageReadFlag(param.ReadFlag),
  29 + Title: param.Title,
  30 + Content: param.Content,
  31 + Payload: param.Payload,
  32 + UpdatedAt: param.UpdatedAt,
  33 + CreatedAt: param.CreatedAt,
  34 + }
  35 +}
  36 +
  37 +func (repo *MessagePersonalRepository) Save(param *domain.MessagePersonal) error {
  38 + message := &models.MessagePersonal{
  39 + Id: param.Id,
  40 + Types: string(param.Types),
  41 + TargetUserId: param.TargetUserId,
  42 + ReadFlag: string(param.ReadFlag),
  43 + Title: param.Title,
  44 + Content: param.Content,
  45 + Payload: param.Payload,
  46 + UpdatedAt: time.Now(),
  47 + CreatedAt: param.CreatedAt,
  48 + }
  49 + tx := repo.transactionContext.PgTx
  50 + if message.Id == 0 {
  51 + message.CreatedAt = time.Now()
  52 + _, err := tx.Model(message).Insert()
  53 +
  54 + return err
  55 + }
  56 + _, err := tx.Model(message).WherePK().Update()
  57 + return err
  58 +}
  59 +
  60 +func (repo *MessagePersonalRepository) Find(param map[string]interface{}) (int, []*domain.MessagePersonal, error) {
  61 + tx := repo.transactionContext.PgTx
  62 + var m []*models.MessagePersonal
  63 + query := tx.Model(&m).Limit(20)
  64 + if v, ok := param["targetUserId"]; ok {
  65 + query.Where("target_user_id=?", v)
  66 + }
  67 + if v, ok := param["types"]; ok {
  68 + query.Where("types=?", v)
  69 + }
  70 + if v, ok := param["payload"]; ok {
  71 + query.Where("payload @>?", v)
  72 + }
  73 + query.Order("id desc")
  74 + count, err := query.SelectAndCount()
  75 + if err != nil {
  76 + return 0, nil, err
  77 + }
  78 + var datas []*domain.MessagePersonal
  79 + for _, v := range m {
  80 + d := repo.TransformToDomain(v)
  81 + datas = append(datas, d)
  82 + }
  83 + return count, datas, nil
  84 +
  85 +}
@@ -131,7 +131,7 @@ func (repo *NodeTaskRepository) Find(queryOptions map[string]interface{}) ([]*do @@ -131,7 +131,7 @@ func (repo *NodeTaskRepository) Find(queryOptions map[string]interface{}) ([]*do
131 var m []*models.NodeTask 131 var m []*models.NodeTask
132 query := tx.Model(&m).Where("deleted_at isnull") 132 query := tx.Model(&m).Where("deleted_at isnull")
133 133
134 - if v, ok := queryOptions["now"].(time.Time); ok { 134 + if v, ok := queryOptions["lessNextSentAt"].(time.Time); ok {
135 query.Where("next_sent_at <= ?", v) 135 query.Where("next_sent_at <= ?", v)
136 } 136 }
137 137
@@ -30,6 +30,7 @@ func (repo *SummaryEvaluationValueRepository) TransformToDomain(d *models.Summar @@ -30,6 +30,7 @@ func (repo *SummaryEvaluationValueRepository) TransformToDomain(d *models.Summar
30 Score: d.Score, 30 Score: d.Score,
31 Types: domain.EvaluationType(d.Types), 31 Types: domain.EvaluationType(d.Types),
32 Remark: d.Remark, 32 Remark: d.Remark,
  33 + Executor: d.Executor,
33 Weight: d.Weight, 34 Weight: d.Weight,
34 Rating: d.Rating, 35 Rating: d.Rating,
35 CreatedAt: d.CreatedAt, 36 CreatedAt: d.CreatedAt,
@@ -45,6 +46,7 @@ func (repo *SummaryEvaluationValueRepository) Save(param *domain.SummaryEvaluati @@ -45,6 +46,7 @@ func (repo *SummaryEvaluationValueRepository) Save(param *domain.SummaryEvaluati
45 Value: param.Value, 46 Value: param.Value,
46 Score: param.Score, 47 Score: param.Score,
47 Types: int(param.Types), 48 Types: int(param.Types),
  49 + Executor: param.Executor,
48 Weight: param.Weight, 50 Weight: param.Weight,
49 Rating: param.Rating, 51 Rating: param.Rating,
50 Remark: param.Remark, 52 Remark: param.Remark,
@@ -118,7 +120,7 @@ func (repo *SummaryEvaluationValueRepository) Find(queryOptions map[string]inter @@ -118,7 +120,7 @@ func (repo *SummaryEvaluationValueRepository) Find(queryOptions map[string]inter
118 if v, ok := queryOptions["types"]; ok { 120 if v, ok := queryOptions["types"]; ok {
119 query.Where("types=?", v) 121 query.Where("types=?", v)
120 } 122 }
121 - 123 + query.Order("evaluation_item_id")
122 count, err := query.SelectAndCount() 124 count, err := query.SelectAndCount()
123 if err != nil { 125 if err != nil {
124 return 0, nil, err 126 return 0, nil, err
@@ -10,8 +10,8 @@ type LockSummaryEvaluation struct { @@ -10,8 +10,8 @@ type LockSummaryEvaluation struct {
10 m *redsync.Mutex 10 m *redsync.Mutex
11 } 11 }
12 12
13 -func NewLockSummaryEvaluation(id int) *LockSummaryEvaluation {  
14 - key := fmt.Sprintf("performance:summary_evaluation:%d", id) 13 +func NewLockSummaryEvaluation(targetUserId int) *LockSummaryEvaluation {
  14 + key := fmt.Sprintf("performance:summary_evaluation:%d", targetUserId)
15 15
16 return &LockSummaryEvaluation{ 16 return &LockSummaryEvaluation{
17 m: rsync.NewMutex(key), 17 m: rsync.NewMutex(key),
@@ -20,14 +20,19 @@ func (controller *AuthController) Login() { @@ -20,14 +20,19 @@ func (controller *AuthController) Login() {
20 controller.Response(resp, err) 20 controller.Response(resp, err)
21 } 21 }
22 22
  23 +// 获取个人信息
23 func (controller *AuthController) User() { 24 func (controller *AuthController) User() {
24 userAuth := controller.Ctx.Input.GetData(domain.UserAuth{}).(*domain.UserAuth) 25 userAuth := controller.Ctx.Input.GetData(domain.UserAuth{}).(*domain.UserAuth)
25 - controller.Response(map[string]interface{}{  
26 - "user": userAuth,  
27 - }, nil) 26 + authService := &service.AuthService{}
  27 + param := &command.GetMeInfo{
  28 + UserId: userAuth.UserId,
  29 + CompanyId: userAuth.CompanyId,
  30 + }
  31 + resp, err := authService.MeInfo(param)
  32 + controller.Response(resp, err)
28 } 33 }
29 34
30 -// Login PC端登录 35 +// Login 手机端登录
31 func (controller *AuthController) MobileLogin() { 36 func (controller *AuthController) MobileLogin() {
32 authService := &service.AuthService{} 37 authService := &service.AuthService{}
33 loginCommand := &command.MobileLoginCommand{} 38 loginCommand := &command.MobileLoginCommand{}
  1 +package controllers
  2 +
  3 +import (
  4 + "github.com/linmadan/egglib-go/web/beego"
  5 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/notify/command"
  6 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/notify/service"
  7 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/middlewares"
  8 +)
  9 +
  10 +// 获取个人的消息提示
  11 +type MessagePersonalController struct {
  12 + beego.BaseController
  13 +}
  14 +
  15 +// 周期综合自评是否开启,是否提示
  16 +func (c *MessagePersonalController) TodayMessageSummaryEvaluation() {
  17 + srv := service.NewMessagePersonalService()
  18 + userReq := middlewares.GetUser(c.Ctx)
  19 + param := command.GetUserMessageCommand{}
  20 + param.UserId = int(userReq.UserId)
  21 + data, err := srv.TodayMessageSummaryEvaluationSelf(&param)
  22 + c.Response(data, err)
  23 +}
@@ -288,8 +288,8 @@ func (c *SummaryEvaluationController) ListExecutorEvaluationSuper() { @@ -288,8 +288,8 @@ func (c *SummaryEvaluationController) ListExecutorEvaluationSuper() {
288 c.Response(data, err) 288 c.Response(data, err)
289 } 289 }
290 290
291 -// 员工确认评估分数  
292 -func (c *SummaryEvaluationController) ConfirmScoreSuperEvaluation() { 291 +// ConfirmScoreEvaluation 员工确认评估分数
  292 +func (c *SummaryEvaluationController) ConfirmScoreEvaluation() {
293 srv := service.NewSummaryEvaluationService() 293 srv := service.NewSummaryEvaluationService()
294 param := &command.ConfirmScore{} 294 param := &command.ConfirmScore{}
295 err := c.BindJSON(param) 295 err := c.BindJSON(param)
@@ -300,12 +300,12 @@ func (c *SummaryEvaluationController) ConfirmScoreSuperEvaluation() { @@ -300,12 +300,12 @@ func (c *SummaryEvaluationController) ConfirmScoreSuperEvaluation() {
300 } 300 }
301 userReq := middlewares.GetUser(c.Ctx) 301 userReq := middlewares.GetUser(c.Ctx)
302 param.UserId = int(userReq.UserId) 302 param.UserId = int(userReq.UserId)
303 - err = srv.ConfirmScoreSuperEvaluation(param) 303 + err = srv.ConfirmScoreEvaluation(param)
304 c.Response(nil, err) 304 c.Response(nil, err)
305 } 305 }
306 306
307 -// GetTargetUserEvaluationSuper 根据被评估人和周期获取 上级评估  
308 -func (c *SummaryEvaluationController) GetTargetUserEvaluationSuper() { 307 +// GetTargetEvaluationResult 按照周期和被评估的人 获取考核结果
  308 +func (c *SummaryEvaluationController) GetTargetEvaluationResult() {
309 srv := service.NewSummaryEvaluationService() 309 srv := service.NewSummaryEvaluationService()
310 paramReq := &command.QueryEvaluation{} 310 paramReq := &command.QueryEvaluation{}
311 err := c.BindJSON(paramReq) 311 err := c.BindJSON(paramReq)
@@ -316,12 +316,12 @@ func (c *SummaryEvaluationController) GetTargetUserEvaluationSuper() { @@ -316,12 +316,12 @@ func (c *SummaryEvaluationController) GetTargetUserEvaluationSuper() {
316 } 316 }
317 userReq := middlewares.GetUser(c.Ctx) 317 userReq := middlewares.GetUser(c.Ctx)
318 paramReq.CompanyId = int(userReq.CompanyId) 318 paramReq.CompanyId = int(userReq.CompanyId)
319 - data, err := srv.GetTargetUserEvaluationSuper(paramReq) 319 + data, err := srv.GetTargetEvaluationResult(paramReq)
320 c.Response(data, err) 320 c.Response(data, err)
321 } 321 }
322 322
323 // 按周期获取上级评估列表 323 // 按周期获取上级评估列表
324 -func (c *SummaryEvaluationController) ListAllEvaluationSuper() { 324 +func (c *SummaryEvaluationController) ListAllEvaluationFinish() {
325 srv := service.NewSummaryEvaluationService() 325 srv := service.NewSummaryEvaluationService()
326 param := &command.QueryEvaluationList{} 326 param := &command.QueryEvaluationList{}
327 err := c.BindJSON(param) 327 err := c.BindJSON(param)
@@ -333,12 +333,12 @@ func (c *SummaryEvaluationController) ListAllEvaluationSuper() { @@ -333,12 +333,12 @@ func (c *SummaryEvaluationController) ListAllEvaluationSuper() {
333 userReq := middlewares.GetUser(c.Ctx) 333 userReq := middlewares.GetUser(c.Ctx)
334 param.CompanyId = int(userReq.CompanyId) 334 param.CompanyId = int(userReq.CompanyId)
335 param.UserId = int(userReq.UserId) 335 param.UserId = int(userReq.UserId)
336 - data, err := srv.ListAllEvaluationSuper(param) 336 + data, err := srv.ListAllEvaluationFinish(param)
337 c.Response(data, err) 337 c.Response(data, err)
338 } 338 }
339 339
340 // 按周期 导出上级评估列表 340 // 按周期 导出上级评估列表
341 -func (c *SummaryEvaluationController) ExportAllEvaluationSuper() { 341 +func (c *SummaryEvaluationController) ExportAllEvaluationFinish() {
342 srv := service.NewSummaryEvaluationService() 342 srv := service.NewSummaryEvaluationService()
343 param := &command.QueryEvaluationList{} 343 param := &command.QueryEvaluationList{}
344 err := c.BindJSON(param) 344 err := c.BindJSON(param)
@@ -350,7 +350,7 @@ func (c *SummaryEvaluationController) ExportAllEvaluationSuper() { @@ -350,7 +350,7 @@ func (c *SummaryEvaluationController) ExportAllEvaluationSuper() {
350 userReq := middlewares.GetUser(c.Ctx) 350 userReq := middlewares.GetUser(c.Ctx)
351 param.UserId = int(userReq.UserId) 351 param.UserId = int(userReq.UserId)
352 param.CompanyId = int(userReq.CompanyId) 352 param.CompanyId = int(userReq.CompanyId)
353 - data, err := srv.ExportAllEvaluationSuper(param) 353 + data, err := srv.ExportAllEvaluationFinish(param)
354 if err != nil { 354 if err != nil {
355 c.Response(nil, err) 355 c.Response(nil, err)
356 return 356 return
  1 +package routers
  2 +
  3 +import (
  4 + "github.com/beego/beego/v2/server/web"
  5 + "github.com/linmadan/egglib-go/web/beego/filters"
  6 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/controllers"
  7 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/middlewares"
  8 +)
  9 +
  10 +func init() {
  11 + ns := web.NewNamespace("/v1/message-personal",
  12 + web.NSBefore(filters.AllowCors(), middlewares.CheckFontToken()),
  13 + web.NSCtrlGet("/summary-evaluation/self/today", (*controllers.MessagePersonalController).TodayMessageSummaryEvaluation),
  14 + )
  15 + web.AddNamespace(ns)
  16 +}
@@ -27,10 +27,13 @@ func init() { @@ -27,10 +27,13 @@ func init() {
27 web.NSCtrlPost("/evaluation-super", (*controllers.SummaryEvaluationController).GetEvaluationSuper), 27 web.NSCtrlPost("/evaluation-super", (*controllers.SummaryEvaluationController).GetEvaluationSuper),
28 web.NSCtrlPost("/evaluation-super/edit", (*controllers.SummaryEvaluationController).EditEvaluationSuper), 28 web.NSCtrlPost("/evaluation-super/edit", (*controllers.SummaryEvaluationController).EditEvaluationSuper),
29 web.NSCtrlPost("/evaluation-super/list", (*controllers.SummaryEvaluationController).ListExecutorEvaluationSuper), 29 web.NSCtrlPost("/evaluation-super/list", (*controllers.SummaryEvaluationController).ListExecutorEvaluationSuper),
30 - web.NSCtrlPost("/evaluation-super/confirm", (*controllers.SummaryEvaluationController).ConfirmScoreSuperEvaluation),  
31 - web.NSCtrlPost("/target_user/evaluation-super", (*controllers.SummaryEvaluationController).GetTargetUserEvaluationSuper),  
32 - web.NSCtrlPost("/evaluation-super/all", (*controllers.SummaryEvaluationController).ListAllEvaluationSuper),  
33 - web.NSCtrlPost("/evaluation-super/all/export", (*controllers.SummaryEvaluationController).ExportAllEvaluationSuper), 30 + web.NSCtrlPost("/evaluation-super/confirm", (*controllers.SummaryEvaluationController).ConfirmScoreEvaluation),
  31 + web.NSCtrlPost("/evaluation-result", (*controllers.SummaryEvaluationController).GetTargetEvaluationResult),
  32 + //web.NSCtrlPost("/target_user/evaluation-super", (*controllers.SummaryEvaluationController).GetTargetEvaluationResult),
  33 + // web.NSCtrlPost("/evaluation-super/all", (*controllers.SummaryEvaluationController).ListAllEvaluationSuper),
  34 + web.NSCtrlPost("/evaluation-finish/all", (*controllers.SummaryEvaluationController).ListAllEvaluationFinish),
  35 + // web.NSCtrlPost("/evaluation-super/all/export", (*controllers.SummaryEvaluationController).ExportAllEvaluationSuper),
  36 + web.NSCtrlPost("/evaluation-finish/all/export", (*controllers.SummaryEvaluationController).ExportAllEvaluationFinish),
34 web.NSCtrlGet("/evaluation-self/now", (*controllers.SummaryEvaluationController).ListExecutorEvaluationSelf), 37 web.NSCtrlGet("/evaluation-self/now", (*controllers.SummaryEvaluationController).ListExecutorEvaluationSelf),
35 // 38 //
36 ) 39 )
  1 +-- summary_evaluation_value表添加字段
  2 +ALTER TABLE public.summary_evaluation_value
  3 + ADD executor jsonb NULL;
  4 +
  5 +-- 初始化旧数据的summary_evaluation_value.executor
  6 +UPDATE
  7 + public.summary_evaluation_value
  8 +SET
  9 + executor = public.summary_evaluation.executor
  10 +FROM
  11 + public.summary_evaluation
  12 +WHERE
  13 + public.summary_evaluation_value.summary_evaluation_id = public.summary_evaluation.id;
  14 +