作者 tangxvhui

调整 公司的权限配置项

@@ -17,7 +17,7 @@ import ( @@ -17,7 +17,7 @@ import (
17 func main() { 17 func main() {
18 startNodeTask() 18 startNodeTask()
19 startSummaryEvaluation() 19 startSummaryEvaluation()
20 - // startConfirmEvaluationScore() 20 + startConfirmEvaluationScore()
21 go notify.RunTaskSmsNotify() 21 go notify.RunTaskSmsNotify()
22 go consumer.Run() 22 go consumer.Run()
23 web.Run() 23 web.Run()
@@ -7,6 +7,7 @@ import ( @@ -7,6 +7,7 @@ import (
7 7
8 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" 8 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
9 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/command" 9 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/command"
  10 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
10 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao" 11 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao"
11 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log" 12 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log"
12 ) 13 )
@@ -18,30 +19,38 @@ func TaskConfirmScore() error { @@ -18,30 +19,38 @@ func TaskConfirmScore() error {
18 str := fmt.Sprintf("自动确认周期评估考核结果耗时%.2f s", time.Since(nowTime).Seconds()) 19 str := fmt.Sprintf("自动确认周期评估考核结果耗时%.2f s", time.Since(nowTime).Seconds())
19 log.Logger.Info(str) 20 log.Logger.Info(str)
20 }() 21 }()
21 - for {  
22 - evaluationList, err := catchEvaluation() 22 +
  23 + evaluationList, err := catchEvaluation()
  24 + if err != nil {
  25 + log.Logger.Error(fmt.Sprintf("获取周期考核结果%s", err.Error()))
  26 + }
  27 + if len(evaluationList) == 0 {
  28 + return nil
  29 + }
  30 + evluationSrv := NewSummaryEvaluationService()
  31 + for _, val := range evaluationList {
  32 + permissionData, err := getPermission(val.CompanyId)
23 if err != nil { 33 if err != nil {
24 - log.Logger.Error(fmt.Sprintf("获取周期考核结果%s", err.Error())) 34 + log.Logger.Error(fmt.Sprintf("获取公司的权限配置失败%s", err.Error()))
25 } 35 }
26 - if len(evaluationList) == 0 {  
27 - return nil 36 + if permissionData.OptConfirmPerf != domain.PermissionOn {
  37 + continue
28 } 38 }
29 - evluationSrv := NewSummaryEvaluationService()  
30 - for _, val := range evaluationList {  
31 - targetUserId, err := strconv.Atoi(val.TargetUserId)  
32 - if err != nil {  
33 - log.Logger.Error(fmt.Sprintf("获取员工id%s", err))  
34 - continue  
35 - }  
36 - err = evluationSrv.ConfirmScoreEvaluation(&command.ConfirmScore{  
37 - SummaryEvaluationId: val.SummaryEvaluationId,  
38 - UserId: targetUserId,  
39 - })  
40 - if err != nil {  
41 - log.Logger.Error(fmt.Sprintf("确认周期考核结果%s", err.Error()))  
42 - } 39 +
  40 + targetUserId, err := strconv.Atoi(val.TargetUserId)
  41 + if err != nil {
  42 + log.Logger.Error(fmt.Sprintf("获取员工id%s", err))
  43 + continue
  44 + }
  45 + err = evluationSrv.ConfirmScoreEvaluation(&command.ConfirmScore{
  46 + SummaryEvaluationId: val.SummaryEvaluationId,
  47 + UserId: targetUserId,
  48 + })
  49 + if err != nil {
  50 + log.Logger.Error(fmt.Sprintf("确认周期考核结果%s", err.Error()))
43 } 51 }
44 } 52 }
  53 + return nil
45 } 54 }
46 55
47 func catchEvaluation() ([]dao.SummaryEvaluationData1, error) { 56 func catchEvaluation() ([]dao.SummaryEvaluationData1, error) {
@@ -1015,11 +1015,15 @@ func (srv *SummaryEvaluationService) GetEvaluationSuper(param *command.QueryEval @@ -1015,11 +1015,15 @@ func (srv *SummaryEvaluationService) GetEvaluationSuper(param *command.QueryEval
1015 itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{ 1015 itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{
1016 "transactionContext": transactionContext, 1016 "transactionContext": transactionContext,
1017 }) 1017 })
1018 - permissionRepository := factory.CreatePermissionRepository(map[string]interface{}{"transactionContext": transactionContext}) 1018 + // permissionRepository := factory.CreatePermissionRepository(map[string]interface{}{"transactionContext": transactionContext})
1019 // 获取权限配置 1019 // 获取权限配置
1020 - _, permissionList, err := permissionRepository.Find(map[string]interface{}{"companyId": param.CompanyId}) 1020 + // _, permissionList, err := permissionRepository.Find(map[string]interface{}{"companyId": param.CompanyId})
  1021 + // if err != nil {
  1022 + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  1023 + // }
  1024 + permissinData, err := getPermission(int64(param.CompanyId))
1021 if err != nil { 1025 if err != nil {
1022 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1026 + return nil, err
1023 } 1027 }
1024 evaluationData, err := evaluationRepo.FindOne(map[string]interface{}{ 1028 evaluationData, err := evaluationRepo.FindOne(map[string]interface{}{
1025 "id": param.SummaryEvaluationId, 1029 "id": param.SummaryEvaluationId,
@@ -1078,15 +1082,13 @@ func (srv *SummaryEvaluationService) GetEvaluationSuper(param *command.QueryEval @@ -1078,15 +1082,13 @@ func (srv *SummaryEvaluationService) GetEvaluationSuper(param *command.QueryEval
1078 //组合 评估填写的值和评估项 1082 //组合 评估填写的值和评估项
1079 itemValuesAdapter := srv.buildSummaryItemValue(itemList, itemValues) 1083 itemValuesAdapter := srv.buildSummaryItemValue(itemList, itemValues)
1080 for i, v := range itemValuesAdapter { 1084 for i, v := range itemValuesAdapter {
1081 - if len(permissionList) > 0 {  
1082 - if permissionList[0].OptEvalScore == domain.PermissionOff &&  
1083 - v.EvaluatorId > 0 {  
1084 - itemValuesAdapter[i].ForbidEdit = true  
1085 - }  
1086 - if permissionList[0].OptHrScore == domain.PermissionOff &&  
1087 - v.EvaluatorId < 0 {  
1088 - itemValuesAdapter[i].ForbidEdit = true  
1089 - } 1085 + if permissinData.OptEvalScore == domain.PermissionOff &&
  1086 + v.EvaluatorId > 0 {
  1087 + itemValuesAdapter[i].ForbidEdit = true
  1088 + }
  1089 + if permissinData.OptHrScore == domain.PermissionOff &&
  1090 + v.EvaluatorId < 0 {
  1091 + itemValuesAdapter[i].ForbidEdit = true
1090 } 1092 }
1091 } 1093 }
1092 result := adapter.EvaluationInfoSuperAdapter{ 1094 result := adapter.EvaluationInfoSuperAdapter{
@@ -1214,16 +1216,19 @@ func (srv *SummaryEvaluationService) getEvaluationSuperDefaultValue(transactionC @@ -1214,16 +1216,19 @@ func (srv *SummaryEvaluationService) getEvaluationSuperDefaultValue(transactionC
1214 "transactionContext": transactionContext, 1216 "transactionContext": transactionContext,
1215 }) 1217 })
1216 1218
1217 - permissionRepository := factory.CreatePermissionRepository(map[string]interface{}{"transactionContext": transactionContext})  
1218 - // 获取权限配置  
1219 - _, permissionList, err := permissionRepository.Find(map[string]interface{}{"companyId": evaluationData.CompanyId}) 1219 + // permissionRepository := factory.CreatePermissionRepository(map[string]interface{}{"transactionContext": transactionContext})
  1220 + // // 获取权限配置
  1221 + // _, permissionList, err := permissionRepository.Find(map[string]interface{}{"companyId": evaluationData.CompanyId})
  1222 + // if err != nil {
  1223 + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  1224 + // }
  1225 + // if len(permissionList) == 0 {
  1226 + // return nil, nil
  1227 + // }
  1228 + permissionData, err := getPermission(int64(evaluationData.CompanyId))
1220 if err != nil { 1229 if err != nil {
1221 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1230 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
1222 } 1231 }
1223 - if len(permissionList) == 0 {  
1224 - return nil, nil  
1225 - }  
1226 - permissionData := permissionList[0]  
1227 if permissionData.OptEvalScore == domain.PermissionOn && permissionData.OptHrScore == domain.PermissionOn { 1232 if permissionData.OptEvalScore == domain.PermissionOn && permissionData.OptHrScore == domain.PermissionOn {
1228 return nil, nil 1233 return nil, nil
1229 } 1234 }
  1 +package service
  2 +
  3 +import (
  4 + permissionSrv "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/permission"
  5 + permissionCmd "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/permission/command"
  6 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
  7 +)
  8 +
  9 +func getPermission(companyId int64) (*domain.Permission, error) {
  10 + srv := &permissionSrv.PermissionService{}
  11 + permissionData, err := srv.Get(&permissionCmd.GetPermissionCommand{
  12 + CompanyId: companyId,
  13 + })
  14 + if err != nil {
  15 + return nil, err
  16 + }
  17 + return permissionData, nil
  18 +}
@@ -155,6 +155,7 @@ func (d *SummaryEvaluationDao) UpdateBeginTime(ids []int, beginTime time.Time) e @@ -155,6 +155,7 @@ func (d *SummaryEvaluationDao) UpdateBeginTime(ids []int, beginTime time.Time) e
155 type SummaryEvaluationData1 struct { 155 type SummaryEvaluationData1 struct {
156 SummaryEvaluationId int `pg:"summary_evaluation_id"` 156 SummaryEvaluationId int `pg:"summary_evaluation_id"`
157 TargetUserId string `pg:"target_user_id"` 157 TargetUserId string `pg:"target_user_id"`
  158 + CompanyId int64 `pg:"company_id"`
158 } 159 }
159 160
160 // 查询周期考核结果 161 // 查询周期考核结果
@@ -162,14 +163,15 @@ type SummaryEvaluationData1 struct { @@ -162,14 +163,15 @@ type SummaryEvaluationData1 struct {
162 func (d *SummaryEvaluationDao) ListEvaluationFinishNoResult() ([]SummaryEvaluationData1, error) { 163 func (d *SummaryEvaluationDao) ListEvaluationFinishNoResult() ([]SummaryEvaluationData1, error) {
163 sqlStr := `select 164 sqlStr := `select
164 summary_evaluation.id as summary_evaluation_id, 165 summary_evaluation.id as summary_evaluation_id,
165 - summary_evaluation.target_user ->>'userName' as target_user_name 166 + summary_evaluation.target_user ->>'userName' as target_user_name,
  167 + summary_evaluation.company_id
166 from summary_evaluation 168 from summary_evaluation
167 where 1=1 169 where 1=1
168 and summary_evaluation."types" = 5 170 and summary_evaluation."types" = 5
169 and summary_evaluation.status ='completed' 171 and summary_evaluation.status ='completed'
170 and summary_evaluation.check_result ='uncompleted' 172 and summary_evaluation.check_result ='uncompleted'
171 and summary_evaluation.end_time <=now() 173 and summary_evaluation.end_time <=now()
172 - limit 10` 174 + `
173 result := []SummaryEvaluationData1{} 175 result := []SummaryEvaluationData1{}
174 tx := d.transactionContext.PgTx 176 tx := d.transactionContext.PgTx
175 _, err := tx.Query(&result, sqlStr) 177 _, err := tx.Query(&result, sqlStr)