作者 tangxvhui

修正数据更新方式

... ... @@ -603,17 +603,25 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluationSelf(param *domain.
if err != nil {
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
nowTime := time.Now()
updatedId := []int{}
// 变更360评估/人资评估/上级评估的开始时间
for _, v := range evaluationList {
if v.BeginTime.After(nowTime) {
v.BeginTime = nowTime
updatedId = append(updatedId, v.Id)
}
}
err = evaluationRepo.Save(v)
evaluationDao := dao.NewSummaryEvaluationDao(map[string]interface{}{
"transactionContext": transactionContext,
})
err = evaluationDao.UpdateBeginTime(updatedId, nowTime)
if err != nil {
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
}
if err := transactionContext.CommitTransaction(); err != nil {
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
... ... @@ -666,16 +674,21 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluation360Hrbp(param *doma
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
nowTime := time.Now()
updatedId := []int{}
// 变更上级评估的开始时间
for _, v := range evaluationList {
if v.BeginTime.After(nowTime) {
v.BeginTime = nowTime
updatedId = append(updatedId, v.Id)
}
}
err = evaluationRepo.Save(v)
evaluationDao := dao.NewSummaryEvaluationDao(map[string]interface{}{
"transactionContext": transactionContext,
})
err = evaluationDao.UpdateBeginTime(updatedId, nowTime)
if err != nil {
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
}
if err := transactionContext.CommitTransaction(); err != nil {
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
... ...
... ... @@ -134,3 +134,17 @@ func (d *SummaryEvaluationDao) CountTargetUserCycleList(executorId int, evaluati
_, err := tx.QueryOne(pg.Scan(&cnt), sqlStr, condition...)
return cnt, err
}
func (d *SummaryEvaluationDao) UpdateBeginTime(ids []int, beginTime time.Time) error {
if len(ids) == 0 {
return nil
}
sqlStr := `update summary_evaluation set begin_time =?
where summary_evaluation.id in(?) `
condition := []interface{}{
beginTime, pg.In(ids),
}
tx := d.transactionContext.PgTx
_, err := tx.ExecOne(sqlStr, condition...)
return err
}
... ...