package com.estate.expert.admin.domain.exam.record; import com.estate.expert.admin.domain.common.EntityBaseRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; import java.util.List; public interface RecordRepository extends EntityBaseRepository { @Query("select r.problem.id, count(r) from Record r " + "where r.deleted = false " + "and r.device is null " + "and r.problem is not null " + "and r.problem.id in :problemIds " + "and r.checkTask.id in :taskIds " + "group by r.problem.id") List countSystemChecksByTaskIdsAndProblemIds(@Param("taskIds") List taskIds, @Param("problemIds") List problemIds); @Query(value = "select r.device_id, r.problem_id, count(*) " + "from record r " + "where r.deleted = false " + "and r.device_id is not null " + "and r.problem_id is not null " + "and r.check_task_id in (:taskIds) " + "group by r.device_id, r.problem_id", nativeQuery = true) List countDeviceChecksByTaskIds(@Param("taskIds") List taskIds); }