作者 tangxvhui

添加接口

@@ -239,10 +239,10 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluation360Hrbp( @@ -239,10 +239,10 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluation360Hrbp(
239 } 239 }
240 if noSuper && len(evaluationFinishList) > 0 { 240 if noSuper && len(evaluationFinishList) > 0 {
241 //不存在上级评估 241 //不存在上级评估
242 - err = srv.syncEvaluationFinishValue(transactionContext, evaluationFinishList[0], evaluationValue)  
243 - if err != nil {  
244 - return err  
245 - } 242 + // err = srv.syncEvaluationFinishValue(transactionContext, evaluationFinishList[0], evaluationValue)
  243 + // if err != nil {
  244 + // return err
  245 + // }
246 } else if len(evaluationList) == 0 && len(evaluationFinishList) > 0 { 246 } else if len(evaluationList) == 0 && len(evaluationFinishList) > 0 {
247 err = evaluationRepo.Save(evaluationFinishList[0]) 247 err = evaluationRepo.Save(evaluationFinishList[0])
248 if err != nil { 248 if err != nil {
@@ -203,34 +203,34 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluationSelf( @@ -203,34 +203,34 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluationSelf(
203 if noSuper && evaluationFinish != nil { 203 if noSuper && evaluationFinish != nil {
204 //没有上级评估 同步数据到考核结果 204 //没有上级评估 同步数据到考核结果
205 205
206 - itemUsedRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{  
207 - "transactionContext": transactionContext,  
208 - })  
209 - _, itemList, err := itemUsedRepo.Find(map[string]interface{}{  
210 - "evaluationProjectId": evaluationData.EvaluationProjectId,  
211 - "nodeType": domain.LinkNodeSelfAssessment,  
212 - })  
213 - if err != nil {  
214 - return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
215 - }  
216 - //提取非360,hrbp 的评估项  
217 - updateValue := []*domain.SummaryEvaluationValue{}  
218 - for _, val := range itemList {  
219 - if val.EvaluatorId != 0 {  
220 - continue  
221 - }  
222 - for _, val2 := range evaluationValue {  
223 - if val.Id == val2.EvaluationItemId {  
224 - updateValue = append(updateValue, val2)  
225 - break  
226 - }  
227 - }  
228 - }  
229 - //同步数据  
230 - err = srv.syncEvaluationFinishValue(transactionContext, evaluationFinish, updateValue)  
231 - if err != nil {  
232 - return err  
233 - } 206 + // itemUsedRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{
  207 + // "transactionContext": transactionContext,
  208 + // })
  209 + // _, itemList, err := itemUsedRepo.Find(map[string]interface{}{
  210 + // "evaluationProjectId": evaluationData.EvaluationProjectId,
  211 + // "nodeType": domain.LinkNodeSelfAssessment,
  212 + // })
  213 + // if err != nil {
  214 + // return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  215 + // }
  216 + // //提取非360,hrbp 的评估项
  217 + // updateValue := []*domain.SummaryEvaluationValue{}
  218 + // for _, val := range itemList {
  219 + // if val.EvaluatorId != 0 {
  220 + // continue
  221 + // }
  222 + // for _, val2 := range evaluationValue {
  223 + // if val.Id == val2.EvaluationItemId {
  224 + // updateValue = append(updateValue, val2)
  225 + // break
  226 + // }
  227 + // }
  228 + // }
  229 + // //同步数据
  230 + // err = srv.syncEvaluationFinishValue(transactionContext, evaluationFinish, updateValue)
  231 + // if err != nil {
  232 + // return err
  233 + // }
234 234
235 } else if len(targetEvaluation) == 0 && evaluationFinish != nil { 235 } else if len(targetEvaluation) == 0 && evaluationFinish != nil {
236 err = evaluationRepo.Save(evaluationFinish) 236 err = evaluationRepo.Save(evaluationFinish)
@@ -191,9 +191,30 @@ func (srv *SummaryEvaluationService) CountEvaluationSelfLevelV2(param *command.Q @@ -191,9 +191,30 @@ func (srv *SummaryEvaluationService) CountEvaluationSelfLevelV2(param *command.Q
191 } 191 }
192 192
193 // 获取已结束的周期列表 193 // 获取已结束的周期列表
194 -func (srv *SummaryEvaluationService) CycleList() (map[string]interface{}, error) {  
195 - // select distinct summary_evaluation.cycle_id ,summary_evaluation.cycle_name ,summary_evaluation.company_id  
196 - // from summary_evaluation  
197 - // where "types" =5  
198 - return nil, nil 194 +func (srv *SummaryEvaluationService) ListCycle(companyId int) (map[string]interface{}, error) {
  195 + transactionContext, err := factory.CreateTransactionContext(nil)
  196 + if err != nil {
  197 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  198 + }
  199 + if err := transactionContext.StartTransaction(); err != nil {
  200 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  201 + }
  202 + defer func() {
  203 + _ = transactionContext.RollbackTransaction()
  204 + }()
  205 + summaryEvaluationDao := dao.NewSummaryEvaluationDao(map[string]interface{}{
  206 + "transactionContext": transactionContext,
  207 + })
  208 + cycleList, err := summaryEvaluationDao.ListCycle(companyId)
  209 + if err != nil {
  210 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取周期列表"+err.Error())
  211 + }
  212 + if err := transactionContext.CommitTransaction(); err != nil {
  213 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  214 + }
  215 + result := map[string]interface{}{
  216 + "list": cycleList,
  217 + }
  218 + return result, nil
  219 +
199 } 220 }
1 package dao 1 package dao
2 2
3 import ( 3 import (
4 - "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"  
5 "time" 4 "time"
6 5
  6 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
  7 +
7 "github.com/go-pg/pg/v10" 8 "github.com/go-pg/pg/v10"
8 pgTransaction "github.com/linmadan/egglib-go/transaction/pg" 9 pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
9 ) 10 )
@@ -201,3 +202,25 @@ func (d *SummaryEvaluationDao) ListEvaluationFinishNoResult() ([]SummaryEvaluati @@ -201,3 +202,25 @@ func (d *SummaryEvaluationDao) ListEvaluationFinishNoResult() ([]SummaryEvaluati
201 _, err := tx.Query(&result, sqlStr) 202 _, err := tx.Query(&result, sqlStr)
202 return result, err 203 return result, err
203 } 204 }
  205 +
  206 +type SummaryEvaluationCycle struct {
  207 + CycleId string `pg:"cycle_id" json:"cycleId"` //周期id
  208 + CompanyId string `pg:"company_id" json:"companyId"`
  209 + CycleName string `pg:"cycle_name" json:"cycleName"` //周期名称
  210 +}
  211 +
  212 +// 查询周期列表
  213 +// 条件:确认考核结果已过截止时间
  214 +func (d *SummaryEvaluationDao) ListCycle(companyId int) ([]SummaryEvaluationCycle, error) {
  215 + sqlStr := ` select
  216 + distinct summary_evaluation.cycle_id ,summary_evaluation.cycle_name ,summary_evaluation.company_id
  217 + from summary_evaluation
  218 + where summary_evaluation."types" =5 and summary_evaluation.end_time <now()
  219 + and summary_evaluation.company_id =?
  220 + order by summary_evaluation.cycle_id desc `
  221 + result := []SummaryEvaluationCycle{}
  222 + tx := d.transactionContext.PgTx
  223 + _, err := tx.Query(&result, sqlStr, companyId)
  224 + return result, err
  225 +
  226 +}
@@ -454,3 +454,12 @@ func (c *SummaryEvaluationController) ListCycleAndProject() { @@ -454,3 +454,12 @@ func (c *SummaryEvaluationController) ListCycleAndProject() {
454 data, err := srv.ListCycleAndProject(param) 454 data, err := srv.ListCycleAndProject(param)
455 c.Response(data, err) 455 c.Response(data, err)
456 } 456 }
  457 +
  458 +// 获取已结束的周期
  459 +func (c *SummaryEvaluationController) ListCycle() {
  460 + srv := service.NewSummaryEvaluationService()
  461 + userReq := middlewares.GetUser(c.Ctx)
  462 + companyId := int(userReq.CompanyId)
  463 + data, err := srv.ListCycle(companyId)
  464 + c.Response(data, err)
  465 +}
@@ -10,6 +10,7 @@ import ( @@ -10,6 +10,7 @@ import (
10 func init() { 10 func init() {
11 summaryNS := web.NewNamespace("/v1/summary-evaluation", 11 summaryNS := web.NewNamespace("/v1/summary-evaluation",
12 web.NSBefore(filters.AllowCors(), middlewares.CheckFontToken()), 12 web.NSBefore(filters.AllowCors(), middlewares.CheckFontToken()),
  13 + web.NSCtrlGet("/cycle/list", (*controllers.SummaryEvaluationController).ListCycle),
13 web.NSCtrlPost("/executor/cycle/list", (*controllers.SummaryEvaluationController).GetExecutorCycleList), 14 web.NSCtrlPost("/executor/cycle/list", (*controllers.SummaryEvaluationController).GetExecutorCycleList),
14 web.NSCtrlPost("/executor/cycle/unconfirmed-score", (*controllers.SummaryEvaluationController).GetUnconfirmedScoreCycleList), 15 web.NSCtrlPost("/executor/cycle/unconfirmed-score", (*controllers.SummaryEvaluationController).GetUnconfirmedScoreCycleList),
15 web.NSCtrlPost("/target_user/cycle/list", (*controllers.SummaryEvaluationController).GetTargetUserCycleList), 16 web.NSCtrlPost("/target_user/cycle/list", (*controllers.SummaryEvaluationController).GetTargetUserCycleList),