作者 郑周

Merge branch 'test' into dev-zhengzhou

  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,76 @@ func (service *AuthService) MobileLogin(param *command.MobileLoginCommand) (map[ @@ -156,3 +157,76 @@ 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) (*adapter.MeInfo, 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 &info, nil
  232 +}
  1 +package command
  2 +
  3 +type GetUserMessageCommand struct {
  4 + UserId int `json:"-"`
  5 +}
  1 +package notify
  2 +
  3 +import (
  4 + "github.com/linmadan/egglib-go/core/application"
  5 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
  6 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/notify/command"
  7 +)
  8 +
  9 +// 个人信息提示
  10 +
  11 +type MessagePersonalService struct {
  12 +}
  13 +
  14 +func NewMessagePersonalService() *MessagePersonalService {
  15 + newService := &MessagePersonalService{}
  16 + return newService
  17 +}
  18 +
  19 +// 获取今天的周期综合自评消息提示
  20 +func (srv *MessagePersonalService) TodayMessageSummaryEvaluationSelf(param *command.GetUserMessageCommand) (interface{}, error) {
  21 + transactionContext, err := factory.CreateTransactionContext(nil)
  22 + if err != nil {
  23 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  24 + }
  25 + if err := transactionContext.StartTransaction(); err != nil {
  26 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  27 + }
  28 + defer func() {
  29 + _ = transactionContext.RollbackTransaction()
  30 + }()
  31 + // nowTime := time.Now()
  32 +
  33 + if err := transactionContext.CommitTransaction(); err != nil {
  34 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  35 + }
  36 + return nil, nil
  37 +}
@@ -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 // 每日自评短信通知 ,预创建待发送的短信消息
@@ -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())
@@ -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 {
@@ -177,6 +177,12 @@ func sendSummaryEvaluation(project *domain.EvaluationProject, @@ -177,6 +177,12 @@ func sendSummaryEvaluation(project *domain.EvaluationProject,
177 //确定上级评估 177 //确定上级评估
178 newEvaluationList = append(newEvaluationList, evaluationTemp) 178 newEvaluationList = append(newEvaluationList, evaluationTemp)
179 } 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)
180 } 186 }
181 summaryEvaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext}) 187 summaryEvaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext})
182 for i := range newEvaluationList { 188 for i := range newEvaluationList {
@@ -200,11 +200,12 @@ func (srv *SummaryEvaluationService) GetMenu(param *command.QueryMenu) (map[stri @@ -200,11 +200,12 @@ func (srv *SummaryEvaluationService) GetMenu(param *command.QueryMenu) (map[stri
200 } 200 }
201 201
202 //查找当前周期,我的考核结果 202 //查找当前周期,我的考核结果
203 - _, myEvaluationSuper, _ := evaluationRepo.Find(map[string]interface{}{  
204 - "types": int(domain.EvaluationSuper), 203 + _, myEvaluationFinish, _ := evaluationRepo.Find(map[string]interface{}{
  204 + "types": int(domain.EvaluationFinish),
205 "limit": 1, 205 "limit": 1,
206 "targetUserId": param.UserId, 206 "targetUserId": param.UserId,
207 "cycleId": param.CycleId, 207 "cycleId": param.CycleId,
  208 + "beginTime": time.Now(),
208 }) 209 })
209 210
210 if err := transactionContext.CommitTransaction(); err != nil { 211 if err := transactionContext.CommitTransaction(); err != nil {
@@ -243,16 +244,14 @@ func (srv *SummaryEvaluationService) GetMenu(param *command.QueryMenu) (map[stri @@ -243,16 +244,14 @@ func (srv *SummaryEvaluationService) GetMenu(param *command.QueryMenu) (map[stri
243 } 244 }
244 menu1.Child = append(menu1.Child, menu1_1) 245 menu1.Child = append(menu1.Child, menu1_1)
245 } 246 }
246 - if len(myEvaluationSuper) > 0 {  
247 - if myEvaluationSuper[0].CheckResult == domain.EvaluationCheckCompleted { 247 + if len(myEvaluationFinish) > 0 {
  248 + if myEvaluationFinish[0].CheckResult == domain.EvaluationCheckCompleted {
248 menu1_2.StatusName = "已完成" 249 menu1_2.StatusName = "已完成"
249 } else { 250 } else {
250 menu1_2.StatusName = "未完成" 251 menu1_2.StatusName = "未完成"
251 } 252 }
252 - if myEvaluationSuper[0].Status == domain.EvaluationCompleted {  
253 menu1.Child = append(menu1.Child, menu1_2) 253 menu1.Child = append(menu1.Child, menu1_2)
254 } 254 }
255 - }  
256 255
257 if len(selfEvaluation) > 0 { 256 if len(selfEvaluation) > 0 {
258 menuList = append(menuList, menu1) 257 menuList = append(menuList, menu1)
@@ -491,7 +490,6 @@ func (srv *SummaryEvaluationService) getSummaryEvaluation(transactionContext app @@ -491,7 +490,6 @@ func (srv *SummaryEvaluationService) getSummaryEvaluation(transactionContext app
491 490
492 // 编辑综合自评详情 491 // 编辑综合自评详情
493 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) {
494 - // xredis.NewLockSummaryEvaluation(param.SummaryEvaluationId)  
495 493
496 transactionContext, err := factory.CreateTransactionContext(nil) 494 transactionContext, err := factory.CreateTransactionContext(nil)
497 if err != nil { 495 if err != nil {
@@ -658,16 +656,13 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluationSelf(param *domain. @@ -658,16 +656,13 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluationSelf(param *domain.
658 if err != nil { 656 if err != nil {
659 return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 657 return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
660 } 658 }
661 - if len(evaluationList) == 0 {  
662 - // 获取考核结果阶段  
663 - finishEvaluation := *param  
664 - finishEvaluation.BeginTime = time.Now()  
665 - finishEvaluation.CreatedAt = time.Now()  
666 - finishEvaluation.UpdatedAt = time.Now()  
667 - finishEvaluation.Executor = domain.StaffDesc{}  
668 - finishEvaluation.Id = 0  
669 - finishEvaluation.Types = domain.EvaluationFinish  
670 - err = evaluationRepo.Save(&finishEvaluation) 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])
671 if err != nil { 666 if err != nil {
672 return application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存考核结果,"+err.Error()) 667 return application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存考核结果,"+err.Error())
673 } 668 }
@@ -728,7 +723,7 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluation360Hrbp(param *doma @@ -728,7 +723,7 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluation360Hrbp(param *doma
728 "targetUserId": param.TargetUser.UserId, 723 "targetUserId": param.TargetUser.UserId,
729 "typesList": []int{int(domain.EvaluationSuper)}, 724 "typesList": []int{int(domain.EvaluationSuper)},
730 "cycleId": param.CycleId, 725 "cycleId": param.CycleId,
731 - "limit": 10, 726 + "limit": 1,
732 }) 727 })
733 if err != nil { 728 if err != nil {
734 return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 729 return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
@@ -761,17 +756,12 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluation360Hrbp(param *doma @@ -761,17 +756,12 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluation360Hrbp(param *doma
761 if err != nil { 756 if err != nil {
762 return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 757 return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
763 } 758 }
764 - if len(evaluationList) == 0 {  
765 - finishEvaluation := *param  
766 - finishEvaluation.BeginTime = time.Now()  
767 - finishEvaluation.CreatedAt = time.Now()  
768 - finishEvaluation.UpdatedAt = time.Now()  
769 - finishEvaluation.Executor = domain.StaffDesc{}  
770 - finishEvaluation.Id = 0  
771 - finishEvaluation.Types = domain.EvaluationFinish  
772 - finishEvaluation.TotalScore = ""  
773 - finishEvaluation.TotalRating = []domain.RatingCodeNumber{}  
774 - err = evaluationRepo.Save(&finishEvaluation) 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])
775 if err != nil { 765 if err != nil {
776 return application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存考核结果,"+err.Error()) 766 return application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存考核结果,"+err.Error())
777 } 767 }
@@ -783,7 +773,7 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluation360Hrbp(param *doma @@ -783,7 +773,7 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluation360Hrbp(param *doma
783 return nil 773 return nil
784 } 774 }
785 775
786 -// 员工提交上级评估 776 +// 员工提交上级评估
787 // 生成考核结果 777 // 生成考核结果
788 func (srv *SummaryEvaluationService) AfterCompletedEvaluationSuper(param *domain.SummaryEvaluation) error { 778 func (srv *SummaryEvaluationService) AfterCompletedEvaluationSuper(param *domain.SummaryEvaluation) error {
789 lock := xredis.NewLockSummaryEvaluation(param.TargetUser.UserId) 779 lock := xredis.NewLockSummaryEvaluation(param.TargetUser.UserId)
@@ -819,17 +809,13 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluationSuper(param *domain @@ -819,17 +809,13 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluationSuper(param *domain
819 if err != nil { 809 if err != nil {
820 return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 810 return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
821 } 811 }
822 - if len(evaluationList) == 0 {  
823 - finishEvaluation := *param  
824 - finishEvaluation.BeginTime = time.Now()  
825 - finishEvaluation.CreatedAt = time.Now()  
826 - finishEvaluation.UpdatedAt = time.Now()  
827 - finishEvaluation.Executor = domain.StaffDesc{}  
828 - finishEvaluation.Id = 0  
829 - finishEvaluation.Types = domain.EvaluationFinish  
830 - finishEvaluation.TotalScore = ""  
831 - finishEvaluation.TotalRating = []domain.RatingCodeNumber{}  
832 - err = evaluationRepo.Save(&finishEvaluation) 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])
833 if err != nil { 819 if err != nil {
834 return application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存考核结果,"+err.Error()) 820 return application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存考核结果,"+err.Error())
835 } 821 }
@@ -1827,8 +1813,8 @@ func (srv *SummaryEvaluationService) GetTargetUserEvaluationSuper(param *command @@ -1827,8 +1813,8 @@ func (srv *SummaryEvaluationService) GetTargetUserEvaluationSuper(param *command
1827 return &eiAdapter, nil 1813 return &eiAdapter, nil
1828 } 1814 }
1829 1815
1830 -// 获取周期综合评估下,周期评估列表  
1831 -func (srv *SummaryEvaluationService) ListAllEvaluationSuper(param *command.QueryEvaluationList) (map[string]interface{}, error) { 1816 +// 按周期获取所有员工的评估考核结果
  1817 +func (srv *SummaryEvaluationService) ListAllEvaluationFinish(param *command.QueryEvaluationList) (map[string]interface{}, error) {
1832 transactionContext, err := factory.CreateTransactionContext(nil) 1818 transactionContext, err := factory.CreateTransactionContext(nil)
1833 if err != nil { 1819 if err != nil {
1834 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 1820 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -1872,7 +1858,7 @@ func (srv *SummaryEvaluationService) ListAllEvaluationSuper(param *command.Query @@ -1872,7 +1858,7 @@ func (srv *SummaryEvaluationService) ListAllEvaluationSuper(param *command.Query
1872 //获取评估列表信息 1858 //获取评估列表信息
1873 condition1 := map[string]interface{}{ 1859 condition1 := map[string]interface{}{
1874 "cycleId": param.CycleId, 1860 "cycleId": param.CycleId,
1875 - "types": int(domain.EvaluationSuper), 1861 + "types": int(domain.EvaluationFinish),
1876 "limit": limit, 1862 "limit": limit,
1877 "beginTime": time.Now(), 1863 "beginTime": time.Now(),
1878 } 1864 }
@@ -1973,12 +1959,14 @@ func (srv *SummaryEvaluationService) editEvaluationValue( @@ -1973,12 +1959,14 @@ func (srv *SummaryEvaluationService) editEvaluationValue(
1973 } 1959 }
1974 evaluationItemMap := map[int]*domain.EvaluationItemUsed{} 1960 evaluationItemMap := map[int]*domain.EvaluationItemUsed{}
1975 evaluationValueMap := map[int]*domain.SummaryEvaluationValue{} 1961 evaluationValueMap := map[int]*domain.SummaryEvaluationValue{}
  1962 + evaluationValueSlice := []*domain.SummaryEvaluationValue{}
1976 evaluationData.TotalRating = nil //清空评级数量统计 1963 evaluationData.TotalRating = nil //清空评级数量统计
1977 for _, v := range evaluationItems { 1964 for _, v := range evaluationItems {
1978 newValue := &domain.SummaryEvaluationValue{} 1965 newValue := &domain.SummaryEvaluationValue{}
1979 newValue.SetBlankValue(evaluationData, v) 1966 newValue.SetBlankValue(evaluationData, v)
1980 evaluationValueMap[v.Id] = newValue 1967 evaluationValueMap[v.Id] = newValue
1981 evaluationItemMap[v.Id] = v 1968 evaluationItemMap[v.Id] = v
  1969 + evaluationValueSlice = append(evaluationValueSlice, newValue)
1982 //重置计数 1970 //重置计数
1983 evaluationData.ResetTotalRating(v) 1971 evaluationData.ResetTotalRating(v)
1984 } 1972 }
@@ -2036,10 +2024,14 @@ func (srv *SummaryEvaluationService) editEvaluationValue( @@ -2036,10 +2024,14 @@ func (srv *SummaryEvaluationService) editEvaluationValue(
2036 } 2024 }
2037 } 2025 }
2038 //完全更新itemValueList 2026 //完全更新itemValueList
2039 - *itemValueList = (*itemValueList)[0:0]  
2040 - for _, v := range evaluationValueMap {  
2041 - *itemValueList = append(*itemValueList, v)  
2042 - } 2027 + *itemValueList = evaluationValueSlice
  2028 + // *itemValueList = (*itemValueList)[0:0]
  2029 + // for _, v := range evaluationValueMap {
  2030 + // *itemValueList = append(*itemValueList, v)
  2031 + // }
  2032 + // sort.Slice(*itemValueList, func(i, j int) bool {
  2033 + // return (*itemValueList)[i].EvaluationItemId < (*itemValueList)[j].EvaluationItemId
  2034 + // })
2043 // 计算总得分 2035 // 计算总得分
2044 err := evaluationData.EvaluationTotalScore(*itemValueList) 2036 err := evaluationData.EvaluationTotalScore(*itemValueList)
2045 if err != nil { 2037 if err != nil {
@@ -803,3 +803,45 @@ func (srv *SummaryEvaluationService) EditEvaluationHRBP(param *command.EditEvalu @@ -803,3 +803,45 @@ func (srv *SummaryEvaluationService) EditEvaluationHRBP(param *command.EditEvalu
803 "evaluationItems": itemValueAdapter, 803 "evaluationItems": itemValueAdapter,
804 }, nil 804 }, nil
805 } 805 }
  806 +
  807 +func (srv *SummaryEvaluationService) SummaryEvaluationFinishNotUseSuper(
  808 + evaluation domain.SummaryEvaluation,
  809 + items []*domain.EvaluationItemUsed,
  810 + itemValue []*domain.SummaryEvaluationValue,
  811 +) []*domain.SummaryEvaluationValue {
  812 + typeSelf := map[int]*domain.SummaryEvaluationValue{}
  813 + typeHrbp360 := map[int]*domain.SummaryEvaluationValue{}
  814 + for _, v := range itemValue {
  815 + switch v.Types {
  816 + case domain.EvaluationSelf:
  817 + typeSelf[v.EvaluationItemId] = v
  818 + case domain.Evaluation360, domain.EvaluationHrbp:
  819 + typeHrbp360[v.EvaluationItemId] = v
  820 + }
  821 + }
  822 + newItemValue := []*domain.SummaryEvaluationValue{}
  823 + nowTime := time.Now()
  824 + for _, v := range items {
  825 + var itemValueTemp domain.SummaryEvaluationValue
  826 + if v.EvaluatorId == 0 {
  827 + if v2, ok := typeSelf[v.Id]; ok {
  828 + itemValueTemp = *v2
  829 + }
  830 + } else {
  831 + if v2, ok := typeHrbp360[v.Id]; ok {
  832 + itemValueTemp = *v2
  833 + }
  834 + }
  835 +
  836 + if itemValueTemp.Id == 0 {
  837 + //360 hrbp,或者自评 都没有填写过
  838 + itemValueTemp.SetBlankValue(&evaluation, v)
  839 + }
  840 + //清理id信息
  841 + itemValueTemp.Id = 0
  842 + itemValueTemp.CreatedAt = nowTime
  843 + itemValueTemp.UpdatedAt = nowTime
  844 + newItemValue = append(newItemValue, &itemValueTemp)
  845 + }
  846 + return newItemValue
  847 +}
  1 +package domain
  2 +
  3 +import "time"
  4 +
  5 +// MessagePersonal 个人的消息提示
  6 +type MessagePersonal struct {
  7 + Id int //
  8 + Types string //消息类型
  9 + TargetUserId int //消息指向的用户
  10 + ReadFlag MessageReadFlag //1:已读、2:未读
  11 + Title string //消息的标题
  12 + Content string //消息的内容
  13 + CreatedAt time.Time
  14 + UpdatedAt time.Time
  15 + Payload string //消息的额外承载的数据
  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 +)
@@ -37,7 +37,7 @@ func (itemValue *SummaryEvaluationValue) SetBlankValue(evaluation *SummaryEvalua @@ -37,7 +37,7 @@ func (itemValue *SummaryEvaluationValue) SetBlankValue(evaluation *SummaryEvalua
37 itemValue.EvaluationItemId = item.Id 37 itemValue.EvaluationItemId = item.Id
38 itemValue.SummaryEvaluationId = evaluation.Id 38 itemValue.SummaryEvaluationId = evaluation.Id
39 itemValue.Value = "" 39 itemValue.Value = ""
40 - itemValue.Score = "" 40 + itemValue.Score = "0"
41 itemValue.Remark = "" 41 itemValue.Remark = ""
42 itemValue.Weight = item.Weight 42 itemValue.Weight = item.Weight
43 itemValue.CreatedAt = time.Now() 43 itemValue.CreatedAt = time.Now()
@@ -120,7 +120,7 @@ func (repo *SummaryEvaluationValueRepository) Find(queryOptions map[string]inter @@ -120,7 +120,7 @@ func (repo *SummaryEvaluationValueRepository) Find(queryOptions map[string]inter
120 if v, ok := queryOptions["types"]; ok { 120 if v, ok := queryOptions["types"]; ok {
121 query.Where("types=?", v) 121 query.Where("types=?", v)
122 } 122 }
123 - 123 + query.Order("evaluation_item_id")
124 count, err := query.SelectAndCount() 124 count, err := query.SelectAndCount()
125 if err != nil { 125 if err != nil {
126 return 0, nil, err 126 return 0, nil, err
@@ -20,11 +20,16 @@ func (controller *AuthController) Login() { @@ -20,11 +20,16 @@ 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 手机端登录 35 // Login 手机端登录
@@ -321,7 +321,7 @@ func (c *SummaryEvaluationController) GetTargetUserEvaluationSuper() { @@ -321,7 +321,7 @@ func (c *SummaryEvaluationController) GetTargetUserEvaluationSuper() {
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
@@ -29,8 +29,10 @@ func init() { @@ -29,8 +29,10 @@ func init() {
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).ConfirmScoreEvaluation), 30 web.NSCtrlPost("/evaluation-super/confirm", (*controllers.SummaryEvaluationController).ConfirmScoreEvaluation),
31 web.NSCtrlPost("/target_user/evaluation-super", (*controllers.SummaryEvaluationController).GetTargetUserEvaluationSuper), 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), 32 + // web.NSCtrlPost("/evaluation-super/all", (*controllers.SummaryEvaluationController).ListAllEvaluationSuper),
  33 + web.NSCtrlPost("/evaluation-finish/all", (*controllers.SummaryEvaluationController).ListAllEvaluationFinish),
  34 + // web.NSCtrlPost("/evaluation-super/all/export", (*controllers.SummaryEvaluationController).ExportAllEvaluationSuper),
  35 + web.NSCtrlPost("/evaluation-finish/all/export", (*controllers.SummaryEvaluationController).ExportAllEvaluationFinish),
34 web.NSCtrlGet("/evaluation-self/now", (*controllers.SummaryEvaluationController).ListExecutorEvaluationSelf), 36 web.NSCtrlGet("/evaluation-self/now", (*controllers.SummaryEvaluationController).ListExecutorEvaluationSelf),
35 // 37 //
36 ) 38 )