作者 tangxvhui

添加接口

... ... @@ -239,10 +239,10 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluation360Hrbp(
}
if noSuper && len(evaluationFinishList) > 0 {
//不存在上级评估
err = srv.syncEvaluationFinishValue(transactionContext, evaluationFinishList[0], evaluationValue)
if err != nil {
return err
}
// err = srv.syncEvaluationFinishValue(transactionContext, evaluationFinishList[0], evaluationValue)
// if err != nil {
// return err
// }
} else if len(evaluationList) == 0 && len(evaluationFinishList) > 0 {
err = evaluationRepo.Save(evaluationFinishList[0])
if err != nil {
... ...
... ... @@ -203,34 +203,34 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluationSelf(
if noSuper && evaluationFinish != nil {
//没有上级评估 同步数据到考核结果
itemUsedRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
_, itemList, err := itemUsedRepo.Find(map[string]interface{}{
"evaluationProjectId": evaluationData.EvaluationProjectId,
"nodeType": domain.LinkNodeSelfAssessment,
})
if err != nil {
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
//提取非360,hrbp 的评估项
updateValue := []*domain.SummaryEvaluationValue{}
for _, val := range itemList {
if val.EvaluatorId != 0 {
continue
}
for _, val2 := range evaluationValue {
if val.Id == val2.EvaluationItemId {
updateValue = append(updateValue, val2)
break
}
}
}
//同步数据
err = srv.syncEvaluationFinishValue(transactionContext, evaluationFinish, updateValue)
if err != nil {
return err
}
// itemUsedRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{
// "transactionContext": transactionContext,
// })
// _, itemList, err := itemUsedRepo.Find(map[string]interface{}{
// "evaluationProjectId": evaluationData.EvaluationProjectId,
// "nodeType": domain.LinkNodeSelfAssessment,
// })
// if err != nil {
// return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
// }
// //提取非360,hrbp 的评估项
// updateValue := []*domain.SummaryEvaluationValue{}
// for _, val := range itemList {
// if val.EvaluatorId != 0 {
// continue
// }
// for _, val2 := range evaluationValue {
// if val.Id == val2.EvaluationItemId {
// updateValue = append(updateValue, val2)
// break
// }
// }
// }
// //同步数据
// err = srv.syncEvaluationFinishValue(transactionContext, evaluationFinish, updateValue)
// if err != nil {
// return err
// }
} else if len(targetEvaluation) == 0 && evaluationFinish != nil {
err = evaluationRepo.Save(evaluationFinish)
... ...
... ... @@ -191,9 +191,30 @@ func (srv *SummaryEvaluationService) CountEvaluationSelfLevelV2(param *command.Q
}
// 获取已结束的周期列表
func (srv *SummaryEvaluationService) CycleList() (map[string]interface{}, error) {
// select distinct summary_evaluation.cycle_id ,summary_evaluation.cycle_name ,summary_evaluation.company_id
// from summary_evaluation
// where "types" =5
return nil, nil
func (srv *SummaryEvaluationService) ListCycle(companyId int) (map[string]interface{}, error) {
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
_ = transactionContext.RollbackTransaction()
}()
summaryEvaluationDao := dao.NewSummaryEvaluationDao(map[string]interface{}{
"transactionContext": transactionContext,
})
cycleList, err := summaryEvaluationDao.ListCycle(companyId)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取周期列表"+err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
result := map[string]interface{}{
"list": cycleList,
}
return result, nil
}
... ...
package dao
import (
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
"time"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
"github.com/go-pg/pg/v10"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
)
... ... @@ -201,3 +202,25 @@ func (d *SummaryEvaluationDao) ListEvaluationFinishNoResult() ([]SummaryEvaluati
_, err := tx.Query(&result, sqlStr)
return result, err
}
type SummaryEvaluationCycle struct {
CycleId string `pg:"cycle_id" json:"cycleId"` //周期id
CompanyId string `pg:"company_id" json:"companyId"`
CycleName string `pg:"cycle_name" json:"cycleName"` //周期名称
}
// 查询周期列表
// 条件:确认考核结果已过截止时间
func (d *SummaryEvaluationDao) ListCycle(companyId int) ([]SummaryEvaluationCycle, error) {
sqlStr := ` select
distinct summary_evaluation.cycle_id ,summary_evaluation.cycle_name ,summary_evaluation.company_id
from summary_evaluation
where summary_evaluation."types" =5 and summary_evaluation.end_time <now()
and summary_evaluation.company_id =?
order by summary_evaluation.cycle_id desc `
result := []SummaryEvaluationCycle{}
tx := d.transactionContext.PgTx
_, err := tx.Query(&result, sqlStr, companyId)
return result, err
}
... ...
... ... @@ -454,3 +454,12 @@ func (c *SummaryEvaluationController) ListCycleAndProject() {
data, err := srv.ListCycleAndProject(param)
c.Response(data, err)
}
// 获取已结束的周期
func (c *SummaryEvaluationController) ListCycle() {
srv := service.NewSummaryEvaluationService()
userReq := middlewares.GetUser(c.Ctx)
companyId := int(userReq.CompanyId)
data, err := srv.ListCycle(companyId)
c.Response(data, err)
}
... ...
... ... @@ -10,6 +10,7 @@ import (
func init() {
summaryNS := web.NewNamespace("/v1/summary-evaluation",
web.NSBefore(filters.AllowCors(), middlewares.CheckFontToken()),
web.NSCtrlGet("/cycle/list", (*controllers.SummaryEvaluationController).ListCycle),
web.NSCtrlPost("/executor/cycle/list", (*controllers.SummaryEvaluationController).GetExecutorCycleList),
web.NSCtrlPost("/executor/cycle/unconfirmed-score", (*controllers.SummaryEvaluationController).GetUnconfirmedScoreCycleList),
web.NSCtrlPost("/target_user/cycle/list", (*controllers.SummaryEvaluationController).GetTargetUserCycleList),
... ...