严智鑫
2025-11-13 945bc394f40d8af1072a53da9a94f24207124e6d
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
package com.northglass.repository;
 
import java.io.Serializable;
import java.util.Date;
import java.util.List;
 
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
 
import com.northglass.constants.StateConstants.TaskState;
import com.northglass.entity.ReportTask;
 
 
public interface ReportTaskDao extends JpaSpecificationExecutor<ReportTask> , JpaRepository<ReportTask, Serializable>{
    //根据产线查找所有的统计任务
    @Query("select t from ReportTask t where t.loadMachine.id=?1")
    public List<ReportTask> findByLoadMachineId(long loadMachineId);
    
    //根据产线查找所有的统计任务
        @Query("select t from ReportTask t ")
        public List<ReportTask> findByLoadMachine();
    
    //根据opt任务查找所有的统计任务
    @Query("select t from ReportTask t where t.optPattern.id=?1")
    public List<ReportTask> findByoptPatternId(long optPatternId);
    
    //根据optname查找所有的统计任务
    @Query("select t from ReportTask t where t.opt_name=?1")
    public List<ReportTask> findByOptName(String optName);
    
    //根据optname查找是否存在
    @Query("select t from ReportTask t where t.opt_name like ?1%")
    public List<ReportTask> findByOptNameLike(String optName);
    
    //根据optname查找所有未完成状态的的任务
    @Query("select t from ReportTask t where t.opt_name=?1 and t.state = '"+TaskState.NOT_COMPLETE+"'")
    public List<ReportTask> findNotCompleteByOptName(String optName);
    
    //根据optname清空任务记录
    @Modifying
    @Query("delete from ReportTask t where t.opt_name = ?1")
    public void deleteByOptName(String optName);
    
    //根据产线拿到optname
    @Query("select t.opt_name from ReportTask t where t.opt_name like %?1%")
    public List<String> findOptName(String name);
    
    
    
    
    //---------------------------从此开始多条件查询语句------------------------------------------
    //没有选中任何条件(查询当前产线下的所有任务)
    @Query("select t from ReportTask t where t.loadMachine.id = ?1")
    public List<ReportTask> findReportTasks(long loadmachineId);
 
    //有一个条件时(当前产线)
    @Query("select t from ReportTask t where t.loadMachine.id = ?1 and t.opt_name like ?2%")
    public List<ReportTask> findReportTasksByOptName(long loadmachineId,String opt_name);
 
    
    //有一个条件时(当前产线)
    @Query("select t from ReportTask t where t.loadMachine.id = ?1 and t.state = ?2")
    public List<ReportTask> findReportTasksByState(long loadmachineId,String state);
 
    
    //有一个条件时(当前产线)
    @Query("select t from ReportTask t where t.loadMachine.id = ?1 and t.reson = ?2")
    public List<ReportTask> findReportTasksByReson(long loadmachineId,String reson);
 
    //有一个条件时(当前产线)
    @Query("select t from ReportTask t where t.loadMachine.id = ?1 and t.start_time >= ?2")
    public List<ReportTask> findReportTasksBystartTime(long loadmachineId,Date start_time);
 
    //有一个条件时(当前产线)
    @Query("select t from ReportTask t where t.loadMachine.id = ?1 and t.complete_time >= ?2")
    public List<ReportTask> findReportTasksByCompleteTime(long loadmachineId,Date complete_time);
 
    //有两个条件时
    @Query("select t from ReportTask t where t.loadMachine.id = ?1 and t.opt_name like ?2% and t.state = ?3")
    public List<ReportTask> findReportTasksByOptNameAndState(long loadmachineId,String opt_name,String state);
    
    //有两个条件时
    @Query("select t from ReportTask t where t.loadMachine.id = ?1 and t.opt_name like ?2% and t.reson = ?3")
    public List<ReportTask> findReportTasksByOptNameAndReson(long loadmachineId,String opt_name,String reson);
 
    //有两个条件时
    @Query("select t from ReportTask t where t.loadMachine.id = ?1 and t.opt_name like ?2% and t.start_time >= ?3")
    public List<ReportTask> findReportTasksByOptNameAndStartTime(long loadmachineId,String opt_name,Date start_time);
 
    //有两个条件时
    @Query("select t from ReportTask t where t.loadMachine.id = ?1 and t.opt_name like ?2% and t.complete_time >= ?3")
    public List<ReportTask> findReportTasksByOptNameAndCompleteTime(long loadmachineId,String opt_name,Date complete_time);
 
    //有两个条件时
    @Query("select t from ReportTask t where t.loadMachine.id = ?1 and t.state = ?2 and t.reson = ?3")
    public List<ReportTask> findReportTasksByStateAndReason(long loadmachineId,String state,String reson);
 
    //有两个条件时
    @Query("select t from ReportTask t where t.loadMachine.id = ?1 and t.state = ?2 and t.start_time >= ?3")
    public List<ReportTask> findReportTasksByStateAndStartTime(long loadmachineId,String state,Date start_time);
 
    //有两个条件时
    @Query("select t from ReportTask t where t.loadMachine.id = ?1 and t.state = ?2 and t.complete_time >= ?3")
    public List<ReportTask> findReportTasksByStateAndCompleteTime(long loadmachineId,String state,Date complete_time);
 
    @Query("select t from ReportTask t where t.loadMachine.id = ?1 and t.reson = ?2 and t.start_time >= ?3")
    public List<ReportTask> findReportTasksByResonAndStartTime(long loadmachineId,String reson,Date start_time);
 
    @Query("select t from ReportTask t where t.loadMachine.id = ?1 and t.reson = ?2 and t.complete_time >= ?3")
    public List<ReportTask> findReportTasksByResonAndCompleteTime(long loadmachineId,String reson,Date complete_time);
 
    @Query("select t from ReportTask t where t.loadMachine.id = ?1 and t.start_time >= ?2 and t.complete_time >= ?3")
    public List<ReportTask> findReportTasksByStartTimeAndCompleteTime(long loadmachineId,Date start_time,Date complete_time);
 
    @Query("select t from ReportTask t where t.loadMachine.id = ?1 and t.opt_name like ?2% and t.state = ?3 and t.reson = ?4")
    public List<ReportTask> findReportTasksByOptNameAndStateAndReason(long loadmachineId,String opt_name,String state,String reson);
 
    @Query("select t from ReportTask t where t.loadMachine.id = ?1 and t.opt_name like ?2% and t.state = ?3 and t.start_time >= ?4")
    public List<ReportTask> findReportTasksByOptNameAndStateAndStartTime(long loadmachineId,String opt_name,String state,Date start_time);
 
    @Query("select t from ReportTask t where t.loadMachine.id = ?1 and t.opt_name like ?2% and t.state = ?3 and t.complete_time >= ?4")
    public List<ReportTask> findReportTasksByOptNameAndStateAndCompleteTime(long loadmachineId,String opt_name,String state,Date complete_time);
 
    @Query("select t from ReportTask t where t.loadMachine.id = ?1 and t.opt_name like ?2% and t.reson = ?3 and t.start_time >= ?4")
    public List<ReportTask> findReportTasksByOptNameAndReasonAndStartTime(long loadmachineId,String opt_name,String reson,Date start_time);
 
    @Query("select t from ReportTask t where t.loadMachine.id = ?1 and t.opt_name like ?2% and t.reson = ?3 and t.complete_time >= ?4")
    public List<ReportTask> findReportTasksByOptNameAndReasonAndCompleteTime(long loadmachineId,String opt_name,String reson,Date complete_time);
 
    @Query("select t from ReportTask t where t.loadMachine.id = ?1 and t.opt_name like ?2% and t.start_time >= ?3 and t.complete_time >= ?4")
    public List<ReportTask> findReportTasksByOptNameAndStartTimeAndCompleteTime(long loadmachineId,String opt_name,Date start_time,Date complete_time);
 
    @Query("select t from ReportTask t where t.loadMachine.id = ?1 and t.state = ?2 and t.reson = ?3 and t.start_time >= ?4")
    public List<ReportTask> findReportTasksByStateAndReasonAndStartTime(long loadmachineId,String state,String reson,Date start_time);
 
    @Query("select t from ReportTask t where t.loadMachine.id = ?1 and t.state = ?2 and t.reson = ?3 and t.complete_time >= ?4")
    public List<ReportTask> findReportTasksByStateAndReasonAndCompleteTime(long loadmachineId,String state,String reson,Date complete_time);
 
    @Query("select t from ReportTask t where t.loadMachine.id = ?1 and t.state = ?2 and t.start_time >= ?3 and t.complete_time >= ?4")
    public List<ReportTask> findReportTasksByStateAndStartTimeAndCompleteTime(long loadmachineId,String state,Date start_time,Date complete_time);
 
    @Query("select t from ReportTask t where t.loadMachine.id = ?1 and t.reson = ?2 and t.start_time >= ?3 and t.complete_time >= ?4")
    public List<ReportTask> findReportTasksByResonAndStartTimeAndCompleteTime(long loadmachineId,String reson,Date start_time,Date complete_time);
 
    //四个值
    @Query("select t from ReportTask t where t.loadMachine.id = ?1 and t.opt_name like ?2% and t.state = ?3 and t.reson = ?4 and t.start_time >= ?5")
    public List<ReportTask> findReportTasksByOptNameAndStateAndResonAndStartTime(long loadmachineId,String opt_name,String state,String reson,Date start_time);
 
    @Query("select t from ReportTask t where t.loadMachine.id = ?1 and t.opt_name like ?2% and t.state = ?3 and t.reson = ?4 and t.complete_time >= ?5")
    public List<ReportTask> findReportTasksByOptNameAndStateAndResonAndCompleteTime(long loadmachineId,String opt_name,String state,String reson,Date complete_time);
 
    @Query("select t from ReportTask t where t.loadMachine.id = ?1 and t.opt_name like ?2% and t.state = ?3 and t.start_time >= ?4 and t.complete_time >= ?5")
    public List<ReportTask> findReportTasksByOptNameAndStateAndStartTimeAndCompleteTime(long loadmachineId,String opt_name,String state,Date start_time,Date complete_time);
    
    @Query("select t from ReportTask t where t.loadMachine.id = ?1 and t.opt_name like ?2% and t.reson = ?3 and t.start_time >= ?4 and t.complete_time >= ?5")
    public List<ReportTask> findReportTasksByOptNameAndReasonAndStartTimeAndCompleteTime(long loadmachineId,String opt_name,String reson,Date start_time,Date complete_time);
 
    @Query("select t from ReportTask t where t.loadMachine.id = ?1 and t.state = ?2 and t.reson = ?3 and t.start_time >= ?4 and t.complete_time >= ?5")
    public List<ReportTask> findReportTasksByStateAndReasonAndStartTimeAndCompleteTime(long loadmachineId,String state,String reson,Date start_time,Date complete_time);
 
    //五个值
    @Query("select t from ReportTask t where t.loadMachine.id = ?1 and t.opt_name like ?2% and t.state = ?3 and t.reson = ?4 and t.start_time >= ?5 and t.complete_time >= ?6")
    public List<ReportTask> findReportTasksByOptNameAndStateAndReasonAndStartTimeAndCompleteTime(long loadmachineId,String state,String reson,Date start_time,Date complete_time);
 
}