作者 tangxvhui

调整每日弹窗的查询

... ... @@ -122,9 +122,11 @@ func (srv *MessagePersonalService) TodayMessageTaskStageAnomaly(param *command.G
messageRepo := factory.CreateMessagePersonalRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
nowDay := time.Now().Format("2006-01-02")
cnt, _, err := messageRepo.Find(map[string]interface{}{
"types": domain.MessageTypesTaskStage,
"targetUserId": param.UserId,
"createdAtDay": nowDay,
"limit": 1,
})
if err != nil {
... ... @@ -331,9 +333,11 @@ func (srv *MessagePersonalService) TodayMessageTaskRecordAnomaly(param *command.
messageRepo := factory.CreateMessagePersonalRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
nowDay := time.Now().Format("2006-01-02")
cnt, _, err := messageRepo.Find(map[string]interface{}{
"types": domain.MessageTypesTaskRecord,
"targetUserId": param.UserId,
"createdAtDay": nowDay,
"limit": 1,
})
if err != nil {
... ...
... ... @@ -408,17 +408,21 @@ type TaskData3 struct {
// 根据负责人获取超期未完成的异常的里程碑任务
func (d *TaskDao) TaskStageAnomalyByLeader(leaderId []string) ([]TaskData3, error) {
sqlStr := `select distinct
task.id as task_id,
task.leader ->>'name' as leader_name,
task.leader ->>'id' as leader_id,
task.alias as task_alias,
task.name as task_name
from task
join task_stage on task.id=task_stage.task_id
where 1=1
and task_stage.real_completed_at=0 and task_stage.plan_completed_at<extract(epoch from now())
and task.leader ->>'id' in(?) `
sqlStr := `select
task.id as task_id,
task."name" as task_name ,
task.alias as task_alias,
task.leader ->>'id' as leader_id,
task.leader ->>'name' as leader_name
from task where 1=1
and task.deleted_at isnull
and (
task.last_stage ->>'planCompletedAt'< task.last_stage ->>'realCompletedAt'
or
cast(COALESCE(task.current_stage ->>'plan_completed_at','0') as int) between 1 and floor(extract(epoch from now()))
)
and task.leader ->>'id' in(?) `
result := []TaskData3{}
tx := d.transactionContext.PgTx
_, err := tx.Query(&result, sqlStr, pg.In(leaderId))
... ... @@ -427,17 +431,20 @@ func (d *TaskDao) TaskStageAnomalyByLeader(leaderId []string) ([]TaskData3, erro
// 根据任务相关人获取超期未完成的异常的里程碑任务
func (d *TaskDao) TaskStageAnomalyByRelatedUser(relatedUserId int) ([]TaskData3, error) {
sqlStr := `select distinct
sqlStr := `select
task.id as task_id,
task.leader ->>'name' as leader_name,
task.leader ->>'id' as leader_id,
task."name" as task_name ,
task.alias as task_alias,
task.name as task_name
from task
join task_stage on task.id=task_stage.task_id
where 1=1
and task_stage.real_completed_at=0 and task_stage.plan_completed_at<extract(epoch from now())
and task.related_user @>? `
task.leader ->>'id' as leader_id,
task.leader ->>'name' as leader_name
from task where 1=1
and task.deleted_at isnull
and (
task.last_stage ->>'planCompletedAt'< task.last_stage ->>'realCompletedAt'
or
cast(COALESCE(task.current_stage ->>'plan_completed_at','0') as int) between 1 and floor(extract(epoch from now()))
)
and task.related_user @>? `
relatedUser := fmt.Sprintf("[%d]", relatedUserId)
result := []TaskData3{}
... ...
... ... @@ -73,6 +73,9 @@ func (repo *MessagePersonalRepository) Find(param map[string]interface{}) (int,
if v, ok := param["payload"]; ok {
query.Where("payload @>?", v)
}
if v, ok := param["createdAtDay"]; ok {
query.Where("to_char(created_at at time zone 'PRC' ,'YYYY-MM-DD')=?", v)
}
query.Order("id desc")
count, err := query.SelectAndCount()
if err != nil {
... ...