作者 tangxvhui

调整逻辑, 检查每日异常的任务.

... ... @@ -7,6 +7,7 @@ import (
"github.com/linmadan/egglib-go/core/application"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/utils/xtime"
)
... ... @@ -21,6 +22,16 @@ func checkTaskRecordV3(param *domain.TaskRecord) error {
defer func() {
_ = transactionContext.RollbackTransaction()
}()
evaluationProjectDao := dao.NewEvaluationProjectDao(map[string]interface{}{
"transactionContext": transactionContext,
})
exist, err := evaluationProjectDao.ExistRelationProject(param.StaffAssessId)
if err != nil {
return fmt.Errorf("检查项目evaluationProject数据失败:%s", err)
}
if !exist {
return nil
}
taskRepo := factory.CreateTaskRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
... ...
package dao
import (
"github.com/go-pg/pg/v10"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/pg/models"
... ... @@ -28,3 +29,17 @@ func (d *EvaluationProjectDao) UpdateSummaryState(id int64, status domain.Projec
Update()
return err
}
// 检查每日评估是否存在关联的(EvaluationProject)项目数据
func (d *EvaluationProjectDao) ExistRelationProject(staffAssessId int) (bool, error) {
sqlStr := `select count(*) from evaluation_project
where id=any (
select staff_assess.evaluation_project_id
from staff_assess where id=?
)
and evaluation_project.deleted_at isnull `
tx := d.transactionContext.PgTx
result := 0
_, err := tx.QueryOne(pg.Scan(&result), sqlStr, staffAssessId)
return result > 0, err
}
... ...
... ... @@ -45,6 +45,9 @@ func (repo *TaskRecordRepository) TransformToDomain(m *models.TaskRecord) domain
}
func (repo *TaskRecordRepository) TransformToModel(d *domain.TaskRecord) models.TaskRecord {
if len(d.RemarkContent) == 0 {
d.RemarkContent = make([]domain.RemarkText, 0)
}
return models.TaskRecord{
Id: d.Id,
CompanyId: d.CompanyId,
... ...