package com.estate.expert.admin.domain.exam.record.error;
|
|
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 ErrorRecordRepository extends EntityBaseRepository<ErrorRecord> {
|
|
@Query("select w from ErrorRecord w where w.checkTask.id = :checkTaskId " +
|
"and (:creatorId is null or w.creator.id = :creatorId) " +
|
"and w.device is null " +
|
"and w.deleted = false " +
|
"order by w.updateTime desc")
|
Page<ErrorRecord> listSystemErrors(@Param("checkTaskId") Integer checkTaskId,
|
@Param("creatorId") Integer creatorId,
|
Pageable pageable);
|
|
@Query("select w from ErrorRecord w where w.checkTask.id = :checkTaskId " +
|
"and (:creatorId is null or w.creator.id = :creatorId) " +
|
"and w.device is not null " +
|
"and (:deviceId is null or w.device.id = :deviceId) " +
|
"and w.deleted = false " +
|
"order by w.device.id asc, w.updateTime desc")
|
Page<ErrorRecord> listDeviceErrors(@Param("checkTaskId") Integer checkTaskId,
|
@Param("deviceId") Integer deviceId,
|
@Param("creatorId") Integer creatorId,
|
Pageable pageable);
|
|
@Query("select w from ErrorRecord 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 w.device is null " +
|
"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<ErrorRecord> listSystemErrors(@Param("clientId") Integer clientId,
|
@Param("planId") Integer planId,
|
@Param("taskId") Integer taskId,
|
@Param("startDate") LocalDateTime startDate,
|
@Param("endDate") LocalDateTime endDate);
|
|
@Query("select w from ErrorRecord 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 w.device is null " +
|
"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<ErrorRecord> listSystemErrors(@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 ErrorRecord 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 w.device is not null " +
|
"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<ErrorRecord> listDeviceErrors(@Param("clientId") Integer clientId,
|
@Param("planId") Integer planId,
|
@Param("taskId") Integer taskId,
|
@Param("startDate") LocalDateTime startDate,
|
@Param("endDate") LocalDateTime endDate);
|
|
@Query("select w from ErrorRecord 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 w.device is not null " +
|
"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<ErrorRecord> listDeviceErrors(@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 ErrorRecord w where w.checkTask.id = :checkTaskId and w.device = null " +
|
"and w.deleted = false")
|
List<ErrorRecord> listSystemErrors(Integer checkTaskId);
|
|
@Query("select w from ErrorRecord w where w.checkTask.id = :checkTaskId and w.device != null " +
|
"and w.deleted = false")
|
List<ErrorRecord> listDeviceErrors(Integer checkTaskId);
|
|
@Query("select w.problem.id, count(w) from ErrorRecord w " +
|
"where w.deleted = false " +
|
"and w.device is null " +
|
"and w.level is not 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<Object[]> countSystemHazardsByProjectAndProblemIds(@Param("projectId") Integer projectId,
|
@Param("taskStates") List<com.estate.expert.admin.domain.exam.task.check.CheckTaskState> taskStates,
|
@Param("problemIds") List<Integer> problemIds);
|
|
@Query("select w.problem.id, count(w) from ErrorRecord 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.id in :taskIds " +
|
"group by w.problem.id")
|
List<Object[]> countSystemHazardsByTaskIdsAndProblemIds(@Param("taskIds") List<Integer> taskIds,
|
@Param("problemIds") List<Integer> 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.record_type = 'error' " +
|
"and r.check_task_id in (:taskIds) " +
|
"group by r.device_id, r.problem_id", nativeQuery = true)
|
List<Object[]> countDeviceHazardsByTaskIds(@Param("taskIds") List<Integer> taskIds);
|
|
//根据人员来获取检查成果
|
@Query("select w from ErrorRecord w where w.deleted = false and w.creator.id = :creatorId"+ " and ( :startDate is null or w.createTime >= :startDate) " +
|
"and ( :endDate is null or w.createTime < :endDate) " )
|
List<ErrorRecord> inspectionResultsBasedOnPersonnel(Integer creatorId, @Param("startDate") LocalDateTime startDate,
|
@Param("endDate") LocalDateTime endDate);
|
|
//根据人员来获取检查成果
|
@Query("select w from ErrorRecord w where w.deleted = false and w.creator.id in :creatorIds"+ " and ( :startDate is null or w.createTime >= :startDate) " +
|
"and ( :endDate is null or w.createTime < :endDate) ")
|
List<ErrorRecord> inspectionResultsBasedOnPersonnel(List<Integer> creatorIds, @Param("startDate") LocalDateTime startDate,
|
@Param("endDate") LocalDateTime endDate);
|
|
@Query("select w from ErrorRecord w join fetch w.problem join fetch w.checkTask c join fetch c.project p where w.deleted = false" )
|
List<ErrorRecord> getErrorRecordAndProblem();
|
|
@Query("select w from ErrorRecord w join fetch w.problem pr join fetch w.checkTask c join fetch c.project p where w.deleted = false and pr.hierarchyId = 1 " )
|
List<ErrorRecord> getErrorRecordByNotDevice();
|
}
|