liujie
2026-04-01 4b33796be3887c81fa40fba2f55dce4489cff041
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
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<WarningRecord> {
 
    @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<WarningRecord> 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<WarningRecord> 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<Object[]> countSystemWarningsByProjectAndProblemIds(@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 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<WarningRecord> 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<WarningRecord> list(@Param("clientId") Integer clientId,
                             @Param("planId") Integer planId,
                             @Param("taskId") Integer taskId,
                             @Param("startDate") LocalDateTime startDate,
                             @Param("endDate") LocalDateTime endDate);
}