Merge remote-tracking branch 'origin/test' into test
# Conflicts: # pkg/application/summary_evaluation/service/service2.go
正在显示
7 个修改的文件
包含
396 行增加
和
144 行删除
| @@ -116,6 +116,12 @@ spec: | @@ -116,6 +116,12 @@ spec: | ||
| 116 | value: "https://suplus-business-admin-prd.fjmaimaimai.com" | 116 | value: "https://suplus-business-admin-prd.fjmaimaimai.com" |
| 117 | - name: MMM_OPEN_API_SERVICE_HOST | 117 | - name: MMM_OPEN_API_SERVICE_HOST |
| 118 | value: "https://public-interface.fjmaimaimai.com/openapi" | 118 | value: "https://public-interface.fjmaimaimai.com/openapi" |
| 119 | + - name: PUSH_DATA_HOST | ||
| 120 | + value: "https://character-library-metadata-bastion.sumifcc.com" | ||
| 121 | + - name: PUSH_DATA_APPKEY | ||
| 122 | + value: "7q9Kd8ktoB" | ||
| 123 | + - name: PUSH_DATA_APPSECRET | ||
| 124 | + value: "pQSoBj44Wk" | ||
| 119 | volumes: | 125 | volumes: |
| 120 | - name: accesslogs | 126 | - name: accesslogs |
| 121 | emptyDir: {} | 127 | emptyDir: {} |
| 1 | +package service | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "fmt" | ||
| 5 | + "time" | ||
| 6 | + | ||
| 7 | + "github.com/linmadan/egglib-go/core/application" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" | ||
| 9 | + roleService "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/role" | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/command" | ||
| 11 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
| 12 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/xredis" | ||
| 13 | +) | ||
| 14 | + | ||
| 15 | +// 超管直接修改考核结果分数 | ||
| 16 | +// 修改周期考核的分数 | ||
| 17 | +func (srv *SummaryEvaluationService) ModifyFinishScore(param *command.ModifyFinishScore) error { | ||
| 18 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
| 19 | + if err != nil { | ||
| 20 | + return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 21 | + } | ||
| 22 | + if err := transactionContext.StartTransaction(); err != nil { | ||
| 23 | + return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 24 | + } | ||
| 25 | + defer func() { | ||
| 26 | + _ = transactionContext.RollbackTransaction() | ||
| 27 | + }() | ||
| 28 | + // 只有超级管理员可以使用的功能 | ||
| 29 | + superAdmin, err := roleService.GetSuperAdmin(transactionContext, param.CompanyId, param.UserId) | ||
| 30 | + if err != nil { | ||
| 31 | + return err | ||
| 32 | + } | ||
| 33 | + if superAdmin != domain.RoleTypeSuperAdmin { | ||
| 34 | + return application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限") | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + //获取周期评估任务finish | ||
| 38 | + evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 39 | + evaluationValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 40 | + _, evaluationList, err := evaluationRepo.Find(map[string]interface{}{ | ||
| 41 | + "id": []int{param.SummaryEvaluationId}, | ||
| 42 | + "companyId": param.CompanyId, | ||
| 43 | + }) | ||
| 44 | + if err != nil { | ||
| 45 | + return application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
| 46 | + } | ||
| 47 | + if len(evaluationList) == 0 { | ||
| 48 | + return nil | ||
| 49 | + } | ||
| 50 | + evaluationFinishData := evaluationList[0] | ||
| 51 | + | ||
| 52 | + //按照被评估人id ,加锁 | ||
| 53 | + lock := xredis.NewLockSummaryEvaluation(evaluationFinishData.TargetUser.UserId) | ||
| 54 | + err = lock.Lock() | ||
| 55 | + if err != nil { | ||
| 56 | + return application.ThrowError(application.INTERNAL_SERVER_ERROR, "未能完全提交评估内容") | ||
| 57 | + } | ||
| 58 | + defer func() { | ||
| 59 | + lock.UnLock() | ||
| 60 | + }() | ||
| 61 | + | ||
| 62 | + if evaluationFinishData.Types != domain.EvaluationFinish { | ||
| 63 | + return nil | ||
| 64 | + } | ||
| 65 | + // 获取考核评估项 | ||
| 66 | + var evaluationFinishValue []*domain.SummaryEvaluationValue | ||
| 67 | + var saveNewValue bool //是否需要保存新的考核评估项评估 | ||
| 68 | + //尝试 获取考核结果的评估项 | ||
| 69 | + _, evaluationFinishValue, err = evaluationValueRepo.Find(map[string]interface{}{"summaryEvaluationId": evaluationFinishData.Id}) | ||
| 70 | + if err != nil { | ||
| 71 | + return application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + if len(evaluationFinishValue) == 0 { | ||
| 75 | + saveNewValue = true | ||
| 76 | + evaluationFinishValue, err = srv.buildSummaryFinishValue(transactionContext, evaluationFinishData) | ||
| 77 | + if err != nil { | ||
| 78 | + return application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
| 79 | + } | ||
| 80 | + } | ||
| 81 | + if saveNewValue { | ||
| 82 | + // 重置评级汇总 | ||
| 83 | + for _, val := range evaluationFinishValue { | ||
| 84 | + err = evaluationValueRepo.Save(val) | ||
| 85 | + if err != nil { | ||
| 86 | + return application.ThrowError(application.BUSINESS_ERROR, "修改考核结果"+err.Error()) | ||
| 87 | + } | ||
| 88 | + } | ||
| 89 | + } | ||
| 90 | + scoreStr := fmt.Sprintf("%.2f", param.Score) | ||
| 91 | + evaluationFinishData.TotalScore = scoreStr | ||
| 92 | + evaluationFinishData.Status = domain.EvaluationCompleted | ||
| 93 | + err = evaluationRepo.Save(evaluationFinishData) | ||
| 94 | + if err != nil { | ||
| 95 | + return application.ThrowError(application.BUSINESS_ERROR, "修改考核结果"+err.Error()) | ||
| 96 | + } | ||
| 97 | + | ||
| 98 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
| 99 | + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 100 | + } | ||
| 101 | + return nil | ||
| 102 | +} | ||
| 103 | + | ||
| 104 | +// buildSummaryFinishValue | ||
| 105 | +// 当未能按照id直接查询到考核结果的评估项时, | ||
| 106 | +// 从目标人员的上级评估 或者360评估、人资评估、自评 构建考核结果 | ||
| 107 | +func (srv *SummaryEvaluationService) buildSummaryFinishValue(transactionContext application.TransactionContext, evaluationFinisih *domain.SummaryEvaluation) ( | ||
| 108 | + []*domain.SummaryEvaluationValue, error) { | ||
| 109 | + evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 110 | + evaluationValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 111 | + evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 112 | + //尝试获取目标人员的所有评估 | ||
| 113 | + _, evaluationList, err := evaluationRepo.Find(map[string]interface{}{ | ||
| 114 | + "targetUserId": evaluationFinisih.TargetUser.UserId, | ||
| 115 | + "cycleId": evaluationFinisih.CycleId, | ||
| 116 | + }) | ||
| 117 | + if err != nil { | ||
| 118 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
| 119 | + } | ||
| 120 | + | ||
| 121 | + _, itemUsed, err := evaluationItemRepo.Find(map[string]interface{}{"evaluationProjectId": evaluationFinisih.EvaluationProjectId, "nodeType": domain.LinkNodeSelfAssessment}) | ||
| 122 | + if err != nil { | ||
| 123 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
| 124 | + } | ||
| 125 | + var evaluationFinishValue []*domain.SummaryEvaluationValue | ||
| 126 | + var evaluationData *domain.SummaryEvaluation | ||
| 127 | + //尝试获取目标人员的上级评估 | ||
| 128 | + for _, val := range evaluationList { | ||
| 129 | + if val.Types == domain.EvaluationSuper { | ||
| 130 | + evaluationData = val | ||
| 131 | + break | ||
| 132 | + } | ||
| 133 | + } | ||
| 134 | + | ||
| 135 | + if evaluationData != nil { | ||
| 136 | + //使用上级评估的评估内容 | ||
| 137 | + _, itemValue, err := evaluationValueRepo.Find(map[string]interface{}{"summaryEvaluationId": evaluationData.Id}) | ||
| 138 | + if err != nil { | ||
| 139 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
| 140 | + } | ||
| 141 | + for _, val := range itemUsed { | ||
| 142 | + var newItemValue *domain.SummaryEvaluationValue | ||
| 143 | + for _, val2 := range itemValue { | ||
| 144 | + if val2.EvaluationItemId == val.Id { | ||
| 145 | + newItemValue = val2 | ||
| 146 | + newItemValue.Id = 0 | ||
| 147 | + newItemValue.SummaryEvaluationId = 0 | ||
| 148 | + break | ||
| 149 | + } | ||
| 150 | + } | ||
| 151 | + if newItemValue == nil { | ||
| 152 | + newItemValue = &domain.SummaryEvaluationValue{} | ||
| 153 | + newItemValue.SetBlankValue(evaluationFinisih, val) | ||
| 154 | + } | ||
| 155 | + evaluationFinishValue = append(evaluationFinishValue, newItemValue) | ||
| 156 | + } | ||
| 157 | + } else { | ||
| 158 | + //使用360评估、人资评估、自评 构建考核结果的评估项内容 | ||
| 159 | + var itemValueBack []*domain.SummaryEvaluationValue | ||
| 160 | + var summaryEvaluationId []int | ||
| 161 | + for _, val := range evaluationList { | ||
| 162 | + if val.Types == domain.Evaluation360 || val.Types == domain.EvaluationHrbp || val.Types == domain.EvaluationSelf { | ||
| 163 | + summaryEvaluationId = append(summaryEvaluationId, val.Id) | ||
| 164 | + } | ||
| 165 | + } | ||
| 166 | + if len(summaryEvaluationId) > 0 { | ||
| 167 | + _, itemValueBack, err = evaluationValueRepo.Find(map[string]interface{}{"summaryEvaluationIdList": summaryEvaluationId}) | ||
| 168 | + if err != nil { | ||
| 169 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
| 170 | + } | ||
| 171 | + } | ||
| 172 | + tempSelf := map[int]*domain.SummaryEvaluationValue{} | ||
| 173 | + temp360 := map[int]*domain.SummaryEvaluationValue{} | ||
| 174 | + tempHRBP := map[int]*domain.SummaryEvaluationValue{} | ||
| 175 | + for i := range itemValueBack { | ||
| 176 | + it := itemValueBack[i] | ||
| 177 | + switch it.Types { | ||
| 178 | + case domain.EvaluationSelf: | ||
| 179 | + tempSelf[it.EvaluationItemId] = it | ||
| 180 | + case domain.Evaluation360: | ||
| 181 | + temp360[it.EvaluationItemId] = it | ||
| 182 | + case domain.EvaluationHrbp: | ||
| 183 | + tempHRBP[it.EvaluationItemId] = it | ||
| 184 | + } | ||
| 185 | + } | ||
| 186 | + nowTime := time.Now() | ||
| 187 | + for _, val := range itemUsed { | ||
| 188 | + var newItemValue *domain.SummaryEvaluationValue | ||
| 189 | + if val.EvaluatorId == 0 { | ||
| 190 | + newItemValue = tempSelf[val.Id] | ||
| 191 | + } else if val.EvaluatorId == -1 { | ||
| 192 | + newItemValue = tempHRBP[val.Id] | ||
| 193 | + } else { | ||
| 194 | + newItemValue = temp360[val.Id] | ||
| 195 | + } | ||
| 196 | + if newItemValue == nil { | ||
| 197 | + newItemValue = &domain.SummaryEvaluationValue{} | ||
| 198 | + newItemValue.SetBlankValue(evaluationFinisih, val) | ||
| 199 | + } | ||
| 200 | + newItemValue.SummaryEvaluationId = 0 | ||
| 201 | + newItemValue.Id = 0 | ||
| 202 | + newItemValue.CreatedAt = nowTime | ||
| 203 | + newItemValue.UpdatedAt = nowTime | ||
| 204 | + evaluationFinishValue = append(evaluationFinishValue, newItemValue) | ||
| 205 | + } | ||
| 206 | + } | ||
| 207 | + // 重置评级汇总 | ||
| 208 | + evaluationFinisih.TotalRating = nil | ||
| 209 | + for i := range itemUsed { | ||
| 210 | + evaluationFinisih.ResetTotalRating(itemUsed[i]) | ||
| 211 | + } | ||
| 212 | + // 计算分数 | ||
| 213 | + if err := evaluationFinisih.EvaluationTotalScore(evaluationFinishValue); err != nil { | ||
| 214 | + return evaluationFinishValue, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 215 | + } | ||
| 216 | + return evaluationFinishValue, nil | ||
| 217 | +} |
| @@ -726,152 +726,143 @@ func (srv *SummaryEvaluationService) GetEvaluationHRBPComplete(param *command.Qu | @@ -726,152 +726,143 @@ func (srv *SummaryEvaluationService) GetEvaluationHRBPComplete(param *command.Qu | ||
| 726 | } | 726 | } |
| 727 | 727 | ||
| 728 | // ModifyFinishScore 修改周期考核的分数 | 728 | // ModifyFinishScore 修改周期考核的分数 |
| 729 | -func (srv *SummaryEvaluationService) ModifyFinishScore(param *command.ModifyFinishScore) error { | ||
| 730 | - transactionContext, err := factory.CreateTransactionContext(nil) | ||
| 731 | - if err != nil { | ||
| 732 | - return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 733 | - } | ||
| 734 | - if err := transactionContext.StartTransaction(); err != nil { | ||
| 735 | - return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 736 | - } | ||
| 737 | - defer func() { | ||
| 738 | - _ = transactionContext.RollbackTransaction() | ||
| 739 | - }() | ||
| 740 | - // 只有超级管理员可以使用的功能 | ||
| 741 | - superAdmin, err := roleService.GetSuperAdmin(transactionContext, param.CompanyId, param.UserId) | ||
| 742 | - if err != nil { | ||
| 743 | - return err | ||
| 744 | - } | ||
| 745 | - if superAdmin != domain.RoleTypeSuperAdmin { | ||
| 746 | - return application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限") | ||
| 747 | - } | 729 | +// func (srv *SummaryEvaluationService) ModifyFinishScore(param *command.ModifyFinishScore) error { |
| 730 | +// transactionContext, err := factory.CreateTransactionContext(nil) | ||
| 731 | +// if err != nil { | ||
| 732 | +// return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 733 | +// } | ||
| 734 | +// if err := transactionContext.StartTransaction(); err != nil { | ||
| 735 | +// return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 736 | +// } | ||
| 737 | +// defer func() { | ||
| 738 | +// _ = transactionContext.RollbackTransaction() | ||
| 739 | +// }() | ||
| 740 | +// // 只有超级管理员可以使用的功能 | ||
| 741 | +// superAdmin, err := roleService.GetSuperAdmin(transactionContext, param.CompanyId, param.UserId) | ||
| 742 | +// if err != nil { | ||
| 743 | +// return err | ||
| 744 | +// } | ||
| 745 | +// if superAdmin != domain.RoleTypeSuperAdmin { | ||
| 746 | +// return application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限") | ||
| 747 | +// } | ||
| 748 | 748 | ||
| 749 | - // 获取周期评估任务finish | ||
| 750 | - evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 751 | - itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext}) | 749 | +// // 获取周期评估任务finish |
| 750 | +// evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 751 | +// itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 752 | 752 | ||
| 753 | - _, evaluationList, err := evaluationRepo.Find(map[string]interface{}{"id": []int{param.SummaryEvaluationId}, "companyId": param.CompanyId}) | ||
| 754 | - if err != nil { | ||
| 755 | - return application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
| 756 | - } | ||
| 757 | - if len(evaluationList) == 0 { | ||
| 758 | - return nil | ||
| 759 | - } | ||
| 760 | - result := evaluationList[0] | ||
| 761 | - if result.Types != domain.EvaluationFinish { | ||
| 762 | - return nil | ||
| 763 | - } | ||
| 764 | - // 按照被评估人id ,加锁 | ||
| 765 | - lock := xredis.NewLockSummaryEvaluation(result.TargetUser.UserId) | ||
| 766 | - err = lock.Lock() | ||
| 767 | - if err != nil { | ||
| 768 | - return application.ThrowError(application.INTERNAL_SERVER_ERROR, "未能完全提交评估内容") | ||
| 769 | - } | ||
| 770 | - defer func() { | ||
| 771 | - lock.UnLock() | ||
| 772 | - }() | 753 | +// _, evaluationList, err := evaluationRepo.Find(map[string]interface{}{"id": []int{param.SummaryEvaluationId}, "companyId": param.CompanyId}) |
| 754 | +// if err != nil { | ||
| 755 | +// return application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
| 756 | +// } | ||
| 757 | +// if len(evaluationList) == 0 { | ||
| 758 | +// return nil | ||
| 759 | +// } | ||
| 760 | +// result := evaluationList[0] | ||
| 761 | +// if result.Types != domain.EvaluationFinish { | ||
| 762 | +// return nil | ||
| 763 | +// } | ||
| 773 | 764 | ||
| 774 | - // 获取考核结果评分 | ||
| 775 | - _, itemValues, err := itemValueRepo.Find(map[string]interface{}{"summaryEvaluationId": result.Id}) | ||
| 776 | - if err != nil { | ||
| 777 | - return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 778 | - } | ||
| 779 | - // 如果已经存在考核结果分数,只更新分数(反之先默认生成考核结果,再更新分数) | ||
| 780 | - if len(itemValues) > 0 { | ||
| 781 | - // do nothing... | ||
| 782 | - } else { | ||
| 783 | - evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext}) | 765 | +// // 获取考核结果评分 |
| 766 | +// _, itemValues, err := itemValueRepo.Find(map[string]interface{}{"summaryEvaluationId": result.Id}) | ||
| 767 | +// if err != nil { | ||
| 768 | +// return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 769 | +// } | ||
| 770 | +// // 如果已经存在考核结果分数,只更新分数(反之先默认生成考核结果,再更新分数) | ||
| 771 | +// if len(itemValues) > 0 { | ||
| 772 | +// // do nothing... | ||
| 773 | +// } else { | ||
| 774 | +// evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 784 | 775 | ||
| 785 | - // 周期内所有评估类型 | ||
| 786 | - _, evaluationList, err := evaluationRepo.Find(map[string]interface{}{ | ||
| 787 | - "companyId": result.CompanyId, | ||
| 788 | - "cycleId": result.CycleId, | ||
| 789 | - "targetUserId": result.TargetUser.UserId, | ||
| 790 | - }) | ||
| 791 | - if err != nil { | ||
| 792 | - return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 793 | - } | 776 | +// // 周期内所有评估类型 |
| 777 | +// _, evaluationList, err := evaluationRepo.Find(map[string]interface{}{ | ||
| 778 | +// "companyId": result.CompanyId, | ||
| 779 | +// "cycleId": result.CycleId, | ||
| 780 | +// "targetUserId": result.TargetUser.UserId, | ||
| 781 | +// }) | ||
| 782 | +// if err != nil { | ||
| 783 | +// return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 784 | +// } | ||
| 794 | 785 | ||
| 795 | - var super *domain.SummaryEvaluation // 上级评估 | ||
| 796 | - for i := range evaluationList { | ||
| 797 | - it := evaluationList[i] | ||
| 798 | - if it.Types == domain.EvaluationSuper { | ||
| 799 | - super = it | ||
| 800 | - break | ||
| 801 | - } | ||
| 802 | - } | 786 | +// var super *domain.SummaryEvaluation // 上级评估 |
| 787 | +// for i := range evaluationList { | ||
| 788 | +// it := evaluationList[i] | ||
| 789 | +// if it.Types == domain.EvaluationSuper { | ||
| 790 | +// super = it | ||
| 791 | +// break | ||
| 792 | +// } | ||
| 793 | +// } | ||
| 803 | 794 | ||
| 804 | - // 获取自评模板 | ||
| 805 | - _, itemList, err := evaluationItemRepo.Find(map[string]interface{}{"evaluationProjectId": result.EvaluationProjectId, "nodeType": domain.LinkNodeSelfAssessment}) | ||
| 806 | - if err != nil { | ||
| 807 | - return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 808 | - } | 795 | +// // 获取自评模板 |
| 796 | +// _, itemList, err := evaluationItemRepo.Find(map[string]interface{}{"evaluationProjectId": result.EvaluationProjectId, "nodeType": domain.LinkNodeSelfAssessment}) | ||
| 797 | +// if err != nil { | ||
| 798 | +// return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 799 | +// } | ||
| 809 | 800 | ||
| 810 | - if super != nil { | ||
| 811 | - _, superValues, err := itemValueRepo.Find(map[string]interface{}{"summaryEvaluationId": super.Id}) // 获取已填写的评估内容 | ||
| 812 | - if err != nil { | ||
| 813 | - return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 814 | - } | ||
| 815 | - // 更新填写值 | ||
| 816 | - itemValues, err = srv.updateItemValuePriority(result, itemList, superValues, true) | ||
| 817 | - if err != nil { | ||
| 818 | - return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 819 | - } | ||
| 820 | - } else { | ||
| 821 | - // 评估项ID(除考核结果和上级) | ||
| 822 | - var evaluationIds = make([]int, 0) | ||
| 823 | - for i := range evaluationList { | ||
| 824 | - it := evaluationList[i] | ||
| 825 | - if it.Types == domain.EvaluationSelf || it.Types == domain.Evaluation360 || it.Types == domain.EvaluationHrbp { | ||
| 826 | - evaluationIds = append(evaluationIds, it.Id) | ||
| 827 | - } | ||
| 828 | - } | ||
| 829 | - if len(evaluationIds) > 0 { | ||
| 830 | - // 已填写的评估内容 | ||
| 831 | - _, otherValues, err := itemValueRepo.Find(map[string]interface{}{"summaryEvaluationIdList": evaluationIds}) | ||
| 832 | - if err != nil { | ||
| 833 | - return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 834 | - } | 801 | +// if super != nil { |
| 802 | +// _, superValues, err := itemValueRepo.Find(map[string]interface{}{"summaryEvaluationId": super.Id}) // 获取已填写的评估内容 | ||
| 803 | +// if err != nil { | ||
| 804 | +// return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 805 | +// } | ||
| 806 | +// // 更新填写值 | ||
| 807 | +// itemValues, err = srv.updateItemValuePriority(result, itemList, superValues, true) | ||
| 808 | +// if err != nil { | ||
| 809 | +// return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 810 | +// } | ||
| 811 | +// } else { | ||
| 812 | +// // 评估项ID(除考核结果和上级) | ||
| 813 | +// var evaluationIds = make([]int, 0) | ||
| 814 | +// for i := range evaluationList { | ||
| 815 | +// it := evaluationList[i] | ||
| 816 | +// if it.Types == domain.EvaluationSelf || it.Types == domain.Evaluation360 || it.Types == domain.EvaluationHrbp { | ||
| 817 | +// evaluationIds = append(evaluationIds, it.Id) | ||
| 818 | +// } | ||
| 819 | +// } | ||
| 820 | +// if len(evaluationIds) > 0 { | ||
| 821 | +// // 已填写的评估内容 | ||
| 822 | +// _, otherValues, err := itemValueRepo.Find(map[string]interface{}{"summaryEvaluationIdList": evaluationIds}) | ||
| 823 | +// if err != nil { | ||
| 824 | +// return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 825 | +// } | ||
| 835 | 826 | ||
| 836 | - // 更新填写值 | ||
| 837 | - itemValues, err = srv.updateItemValuePriority(result, itemList, otherValues, false) | ||
| 838 | - if err != nil { | ||
| 839 | - return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 840 | - } | ||
| 841 | - } | ||
| 842 | - } | ||
| 843 | - err = itemValueRepo.RemoveBySummaryEvaluationId(result.Id) | ||
| 844 | - if err != nil { | ||
| 845 | - return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 846 | - } | ||
| 847 | - for i := range itemValues { | ||
| 848 | - if err := itemValueRepo.Save(itemValues[i]); err != nil { | ||
| 849 | - return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 850 | - } | ||
| 851 | - } | ||
| 852 | - // 重置评级汇总 | ||
| 853 | - result.TotalRating = nil | ||
| 854 | - for i := range itemList { | ||
| 855 | - result.ResetTotalRating(itemList[i]) | ||
| 856 | - } | ||
| 857 | - //// 计算分数 | ||
| 858 | - //if err := result.EvaluationTotalScore(itemValues); err != nil { | ||
| 859 | - // return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 860 | - //} | ||
| 861 | - } | 827 | +// // 更新填写值 |
| 828 | +// itemValues, err = srv.updateItemValuePriority(result, itemList, otherValues, false) | ||
| 829 | +// if err != nil { | ||
| 830 | +// return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 831 | +// } | ||
| 832 | +// } | ||
| 833 | +// } | ||
| 834 | +// err = itemValueRepo.RemoveBySummaryEvaluationId(result.Id) | ||
| 835 | +// if err != nil { | ||
| 836 | +// return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 837 | +// } | ||
| 838 | +// for i := range itemValues { | ||
| 839 | +// if err := itemValueRepo.Save(itemValues[i]); err != nil { | ||
| 840 | +// return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 841 | +// } | ||
| 842 | +// } | ||
| 843 | +// // 重置评级汇总 | ||
| 844 | +// result.TotalRating = nil | ||
| 845 | +// for i := range itemList { | ||
| 846 | +// result.ResetTotalRating(itemList[i]) | ||
| 847 | +// } | ||
| 848 | +// //// 计算分数 | ||
| 849 | +// //if err := result.EvaluationTotalScore(itemValues); err != nil { | ||
| 850 | +// // return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 851 | +// //} | ||
| 852 | +// } | ||
| 862 | 853 | ||
| 863 | - scoreStr := fmt.Sprintf("%.2f", param.Score) | ||
| 864 | - result.TotalScore = scoreStr | ||
| 865 | - result.Status = domain.EvaluationCompleted | ||
| 866 | - err = evaluationRepo.Save(result) | ||
| 867 | - if err != nil { | ||
| 868 | - return application.ThrowError(application.BUSINESS_ERROR, "修改考核结果"+err.Error()) | ||
| 869 | - } | ||
| 870 | - if err := transactionContext.CommitTransaction(); err != nil { | ||
| 871 | - return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 872 | - } | ||
| 873 | - return nil | ||
| 874 | -} | 854 | +// scoreStr := fmt.Sprintf("%.2f", param.Score) |
| 855 | +// result.TotalScore = scoreStr | ||
| 856 | +// result.Status = domain.EvaluationCompleted | ||
| 857 | +// err = evaluationRepo.Save(result) | ||
| 858 | +// if err != nil { | ||
| 859 | +// return application.ThrowError(application.BUSINESS_ERROR, "修改考核结果"+err.Error()) | ||
| 860 | +// } | ||
| 861 | +// if err := transactionContext.CommitTransaction(); err != nil { | ||
| 862 | +// return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 863 | +// } | ||
| 864 | +// return nil | ||
| 865 | +// } | ||
| 875 | 866 | ||
| 876 | // GetUnconfirmedCycleList 获取未确认绩效成绩的周期列表 | 867 | // GetUnconfirmedCycleList 获取未确认绩效成绩的周期列表 |
| 877 | func (srv *SummaryEvaluationService) GetUnconfirmedCycleList(companyId int, userId int) (map[string]interface{}, error) { | 868 | func (srv *SummaryEvaluationService) GetUnconfirmedCycleList(companyId int, userId int) (map[string]interface{}, error) { |
pkg/constant/push_data.go
0 → 100644
| 1 | +package constant | ||
| 2 | + | ||
| 3 | +import "os" | ||
| 4 | + | ||
| 5 | +//推送数据到字库 | ||
| 6 | + | ||
| 7 | +var PUSH_DATA_HOST string = "http://character-library-metadata-bastion-test.fjmaimaimai.com" | ||
| 8 | + | ||
| 9 | +var PUSH_DATA_APPKEY string = "GnAmG4jybB" | ||
| 10 | + | ||
| 11 | +var PUSH_DATA_APPSECRET string = "3Oo4dG64X0" | ||
| 12 | + | ||
| 13 | +func init() { | ||
| 14 | + if os.Getenv("PUSH_DATA_HOST") != "" { | ||
| 15 | + PUSH_DATA_HOST = os.Getenv("PUSH_DATA_HOST") | ||
| 16 | + } | ||
| 17 | + if os.Getenv("PUSH_DATA_APPKEY") != "" { | ||
| 18 | + PUSH_DATA_APPKEY = os.Getenv("PUSH_DATA_APPKEY") | ||
| 19 | + } | ||
| 20 | + if os.Getenv("PUSH_DATA_APPSECRET") != "" { | ||
| 21 | + PUSH_DATA_APPSECRET = os.Getenv("PUSH_DATA_APPSECRET") | ||
| 22 | + } | ||
| 23 | +} |
| @@ -8,6 +8,7 @@ import ( | @@ -8,6 +8,7 @@ import ( | ||
| 8 | "time" | 8 | "time" |
| 9 | 9 | ||
| 10 | "github.com/dgrijalva/jwt-go" | 10 | "github.com/dgrijalva/jwt-go" |
| 11 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/constant" | ||
| 11 | ) | 12 | ) |
| 12 | 13 | ||
| 13 | type FieldName struct { | 14 | type FieldName struct { |
| @@ -31,9 +32,9 @@ type Client struct { | @@ -31,9 +32,9 @@ type Client struct { | ||
| 31 | 32 | ||
| 32 | func NewClient() *Client { | 33 | func NewClient() *Client { |
| 33 | return &Client{ | 34 | return &Client{ |
| 34 | - Host: "http://character-library-metadata-bastion-test.fjmaimaimai.com", | ||
| 35 | - AppSecret: "3Oo4dG64X0", | ||
| 36 | - AppKey: "GnAmG4jybB", | 35 | + Host: constant.PUSH_DATA_HOST, |
| 36 | + AppSecret: constant.PUSH_DATA_APPSECRET, | ||
| 37 | + AppKey: constant.PUSH_DATA_APPKEY, | ||
| 37 | } | 38 | } |
| 38 | } | 39 | } |
| 39 | 40 | ||
| @@ -94,6 +95,7 @@ type ReqSearchTable struct { | @@ -94,6 +95,7 @@ type ReqSearchTable struct { | ||
| 94 | // SearchTable 查询应用数据表 | 95 | // SearchTable 查询应用数据表 |
| 95 | func (c *Client) SearchTable(name string) { | 96 | func (c *Client) SearchTable(name string) { |
| 96 | apiUrl := `/api/app-table-file/list` | 97 | apiUrl := `/api/app-table-file/list` |
| 98 | + //TODO | ||
| 97 | _ = apiUrl | 99 | _ = apiUrl |
| 98 | } | 100 | } |
| 99 | 101 | ||
| @@ -106,5 +108,6 @@ type ReqCreateTable struct { | @@ -106,5 +108,6 @@ type ReqCreateTable struct { | ||
| 106 | // CreateTable 创建应用表 | 108 | // CreateTable 创建应用表 |
| 107 | func (c *Client) CreateTable() { | 109 | func (c *Client) CreateTable() { |
| 108 | apiUrl := `/api/app-table-file/create` | 110 | apiUrl := `/api/app-table-file/create` |
| 111 | + //TODO | ||
| 109 | _ = apiUrl | 112 | _ = apiUrl |
| 110 | } | 113 | } |
| @@ -8,6 +8,8 @@ import ( | @@ -8,6 +8,8 @@ import ( | ||
| 8 | 8 | ||
| 9 | func TestToken(t *testing.T) { | 9 | func TestToken(t *testing.T) { |
| 10 | c := NewClient() | 10 | c := NewClient() |
| 11 | + c.AppKey = "7q9Kd8ktoB" | ||
| 12 | + c.AppSecret = "pQSoBj44Wk" | ||
| 11 | h := c.useHeader() | 13 | h := c.useHeader() |
| 12 | t.Logf("%v", h) | 14 | t.Logf("%v", h) |
| 13 | } | 15 | } |
| @@ -21,8 +23,17 @@ func TestField(t *testing.T) { | @@ -21,8 +23,17 @@ func TestField(t *testing.T) { | ||
| 21 | 23 | ||
| 22 | func TestPushData(t *testing.T) { | 24 | func TestPushData(t *testing.T) { |
| 23 | nowTime := time.Unix(1688572800, 0) | 25 | nowTime := time.Unix(1688572800, 0) |
| 24 | - err := SendDataStaffAssess(nowTime) | 26 | + c := NewClient() |
| 27 | + c.Host = "" | ||
| 28 | + c.AppKey = "" | ||
| 29 | + c.AppSecret = "" | ||
| 30 | + entry := StaffAssessItem{} | ||
| 31 | + data, err := entry.DataForAppend(nowTime) | ||
| 32 | + if err != nil { | ||
| 33 | + t.Logf("获取每日评估的数据 %s", err) | ||
| 34 | + } | ||
| 35 | + err = c.AppendData(data) | ||
| 25 | if err != nil { | 36 | if err != nil { |
| 26 | - t.Error(err) | 37 | + t.Logf("获取每日评估的数据 %s", err) |
| 27 | } | 38 | } |
| 28 | } | 39 | } |
| @@ -7,9 +7,10 @@ import ( | @@ -7,9 +7,10 @@ import ( | ||
| 7 | ) | 7 | ) |
| 8 | 8 | ||
| 9 | func PushData() { | 9 | func PushData() { |
| 10 | + //每天15:30点运行 | ||
| 10 | nowTime := time.Now() | 11 | nowTime := time.Now() |
| 11 | y, m, d := nowTime.Date() | 12 | y, m, d := nowTime.Date() |
| 12 | - t1 := time.Date(y, m, d, 10, 0, 0, 0, time.Local) //今天的10点 | 13 | + t1 := time.Date(y, m, d, 16, 50, 0, 0, time.Local) //今天的15:30 |
| 13 | interval := t1.Sub(nowTime) | 14 | interval := t1.Sub(nowTime) |
| 14 | if interval < 0 { | 15 | if interval < 0 { |
| 15 | interval = (24 * time.Hour) + interval | 16 | interval = (24 * time.Hour) + interval |
| @@ -20,7 +21,7 @@ func PushData() { | @@ -20,7 +21,7 @@ func PushData() { | ||
| 20 | nowTime = time.Now() | 21 | nowTime = time.Now() |
| 21 | err := SendDataStaffAssess(nowTime) | 22 | err := SendDataStaffAssess(nowTime) |
| 22 | if err != nil { | 23 | if err != nil { |
| 23 | - log.Logger.Error("发送每日评估任务") | 24 | + log.Logger.Error("发送每日评估任务" + err.Error()) |
| 24 | } | 25 | } |
| 25 | 26 | ||
| 26 | timer.Reset(24 * time.Hour) | 27 | timer.Reset(24 * time.Hour) |
-
请 注册 或 登录 后发表评论