package com.estate.expert.admin.domain.exam.record.warning; import com.estate.expert.admin.domain.common.EntityBaseRepository; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; import java.time.LocalDateTime; import java.util.List; public interface WarningRecordRepository extends EntityBaseRepository { @Query("select w from WarningRecord w where w.checkTask.id = :checkTaskId " + "and (:creatorId is null or w.creator.id = :creatorId) " + "and w.deleted = false " + "order by w.updateTime desc") Page list(@Param("checkTaskId") Integer checkTaskId, @Param("creatorId") Integer creatorId, Pageable pageable); @Query("select w from WarningRecord w where w.checkTask.id = :checkTaskId " + "and w.deleted = false " + "order by w.updateTime desc") List list(Integer checkTaskId); @Query("select w.problem.id, count(w) from WarningRecord w " + "where w.deleted = false " + "and w.device is null " + "and w.problem is not null " + "and w.problem.id in :problemIds " + "and w.checkTask.project.id = :projectId " + "and w.checkTask.state in :taskStates " + "group by w.problem.id") List countSystemWarningsByProjectAndProblemIds(@Param("projectId") Integer projectId, @Param("taskStates") List taskStates, @Param("problemIds") List problemIds); @Query("select w from WarningRecord w where ( :clientId is null or w.checkTask.project.client.id = :clientId) " + "and ( :planId is null or w.checkTask.plan.id = :planId) " + "and ( :taskId is null or w.checkTask.id = :taskId) " + "and ( :startDate is null or w.createTime >= :startDate) " + "and ( :endDate is null or w.createTime < :endDate) " + "and w.deleted = false " + "order by w.updateTime desc") Page list(@Param("clientId") Integer clientId, @Param("planId") Integer planId, @Param("taskId") Integer taskId, @Param("startDate") LocalDateTime startDate, @Param("endDate") LocalDateTime endDate, Pageable pageable); @Query("select w from WarningRecord w where ( :clientId is null or w.checkTask.project.client.id = :clientId) " + "and ( :planId is null or w.checkTask.plan.id = :planId) " + "and ( :taskId is null or w.checkTask.id = :taskId) " + "and ( :startDate is null or w.createTime >= :startDate) " + "and ( :endDate is null or w.createTime < :endDate) " + "and w.deleted = false " + "order by w.updateTime desc") List list(@Param("clientId") Integer clientId, @Param("planId") Integer planId, @Param("taskId") Integer taskId, @Param("startDate") LocalDateTime startDate, @Param("endDate") LocalDateTime endDate); }