作者 tangxvhui
... ... @@ -871,3 +871,31 @@ func (srv *SummaryEvaluationService) ModifyFinishScore(param *command.ModifyFini
}
return nil
}
// GetUnconfirmedCycleList 获取未确认绩效成绩的周期列表
func (srv *SummaryEvaluationService) GetUnconfirmedCycleList(companyId int, userId int) (map[string]interface{}, error) {
transactionContext, err := factory.StartTransaction()
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
_ = transactionContext.RollbackTransaction()
}()
evaluationDao := dao.NewSummaryEvaluationDao(map[string]interface{}{"transactionContext": transactionContext})
cycles, err := evaluationDao.TargetUnconfirmedCycleList(companyId, userId)
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())
}
var cycleList []adapter.CycleListAdapter
for _, v := range cycles {
cycleList = append(cycleList, adapter.CycleListAdapter{
CycleId: v.CycleId,
CycleName: v.CycleName,
})
}
return tool_funs.SimpleWrapGridMap(int64(len(cycleList)), cycleList), nil
}
... ...
package dao
import (
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
"time"
"github.com/go-pg/pg/v10"
... ... @@ -138,6 +139,28 @@ func (d *SummaryEvaluationDao) CountTargetUserCycleList(executorId int, evaluati
return cnt, err
}
// TargetUnconfirmedCycleList 用户【未确认绩效成绩】的周期列表
func (d *SummaryEvaluationDao) TargetUnconfirmedCycleList(companyId int, executorId int) ([]TargetUserCycle, error) {
sqlStr := `select
summary_evaluation.cycle_id,
summary_evaluation.begin_time,
summary_evaluation.cycle_name
from summary_evaluation
where summary_evaluation.deleted_at isnull
and summary_evaluation.company_id='?'
and summary_evaluation.target_user ->>'userId'='?'
and summary_evaluation.types='?'
and summary_evaluation.status='?'
and summary_evaluation.check_result='?'
`
tx := d.transactionContext.PgTx
condition := []interface{}{companyId, executorId, domain.EvaluationFinish, domain.EvaluationCompleted, domain.EvaluationCheckUncompleted}
sqlStr += ` order by summary_evaluation.begin_time desc `
result := make([]TargetUserCycle, 0)
_, err := tx.Query(&result, sqlStr, condition...)
return result, err
}
func (d *SummaryEvaluationDao) UpdateBeginTime(ids []int, beginTime time.Time) error {
if len(ids) == 0 {
return nil
... ...
... ... @@ -28,6 +28,13 @@ func (c *SummaryEvaluationController) GetExecutorCycleList() {
c.Response(data, err)
}
func (c *SummaryEvaluationController) GetUnconfirmedScoreCycleList() {
srv := service.NewSummaryEvaluationService()
userReq := middlewares.GetUser(c.Ctx)
data, err := srv.GetUnconfirmedCycleList(int(userReq.CompanyId), int(userReq.UserId))
c.Response(data, err)
}
func (c *SummaryEvaluationController) GetMenu() {
srv := service.NewSummaryEvaluationService()
paramReq := &command.QueryMenu{}
... ...
... ... @@ -11,6 +11,7 @@ func init() {
summaryNS := web.NewNamespace("/v1/summary-evaluation",
web.NSBefore(filters.AllowCors(), middlewares.CheckFontToken()),
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),
web.NSCtrlPost("/cycle/menu", (*controllers.SummaryEvaluationController).GetMenu),
web.NSCtrlPost("/evaluation-self", (*controllers.SummaryEvaluationController).GetEvaluationSelf),
... ...