严智鑫
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
package com.northglass.repository;
 
import java.util.List;
 
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
 
import com.northglass.constants.ShelfTaskFlag;
import com.northglass.constants.ShelfTaskType;
import com.northglass.constants.StateConstants.ShelfTaskState;
import com.northglass.entity.ShelfTask;
 
public interface ShelfTaskDao extends JpaRepository<ShelfTask, Long> {
    
    @Query("select t from ShelfTask t where t.state = '" + ShelfTaskState.IN_WORK + "'")
    public ShelfTask findInWorkTask();
    
    @Query("select t from ShelfTask t where t.state = '" + ShelfTaskState.IN_WORK + "'")
    public List<ShelfTask> findInWorkTasks();
    
    @Query("select t from ShelfTask t where t.state = '" + ShelfTaskState.STOP + "'")
    public ShelfTask findStopTask();
    
    @Query("select t from ShelfTask t where t.state = '" + ShelfTaskState.WAITING + "'"+ " and t.flag = ?1")
    public List<ShelfTask> findWaitingTasksByFlag(String flag);
    
    @Query("select t from ShelfTask t where t.state = '" + ShelfTaskState.COMPLETED + "'"+ " and t.flag = ?1")
    public List<ShelfTask> findCompletedTasksByFlag(String flag);
    
    @Query("select t from ShelfTask t where t.state = '" + ShelfTaskState.IN_WORK + "'"+ " and t.flag = ?1")
    public ShelfTask findInWorkTasksByFlag(String flag);
    
    @Query("select t from ShelfTask t where t.state = '" + ShelfTaskState.WAITING + "'")
    public List<ShelfTask> findWaitingTasks();
    
    @Query("select t from ShelfTask t where t.state = '" + ShelfTaskState.WAITING + "' or t.state = '" + ShelfTaskState.IN_WORK + "'")
    public List<ShelfTask> findWaitingAndWorkingTasks();
    
    @Query("select t from ShelfTask t where t.state = '" + ShelfTaskState.IN_WORKING + "'")
    public ShelfTask findInWorkingTask();
    
    
    @Query("select t from ShelfTask t where t.state = '" + ShelfTaskState.WARNING + "'")
    public List<ShelfTask> findWarningTasks();
    
    @Query("select t from ShelfTask t where t.state = '" + ShelfTaskState.COMPLETED + "'")
    public List<ShelfTask> findCompletedTasks();
    
    @Query("select t from ShelfTask t where t.taskType = '" + ShelfTaskType.FROM_SHELF_RACK_TO_LOAD_MACHINE_RACK + "'" 
            + " and t.shelfRank.id = ?1 and t.loadMachineRack.id = ?2" 
            + " and (t.state = '" + ShelfTaskState.IN_WORK + "' or t.state = '" 
            + ShelfTaskState.WAITING +"' or t.state = '"  +ShelfTaskState.IN_WORKING+ "' or t.state = '" + ShelfTaskState.WARNING + "')")
    public ShelfTask findWorkingShelfTaskFromShelfRackToLoadMachineRack(Long shelfRankId, Long loadMachineRackId);
    
    @Query("select t from ShelfTask t where t.taskType = '" + ShelfTaskType.FROM_RANK_TO_HOIST + "'" 
            + " and t.shelfRank.id = ?1 and t.shelfHoist.id = ?2" 
            + " and (t.state = '" + ShelfTaskState.IN_WORK + "' or t.state = '" 
            + ShelfTaskState.WAITING +"' or t.state = '"  +ShelfTaskState.IN_WORKING+ "' or t.state = '" + ShelfTaskState.WARNING + "')")
    public ShelfTask findWorkingShelfTaskFromShelfRackToHoist(Long shelfRankId, Long shelfHoistId);
    
    @Query("select t from ShelfTask t where t.taskType = '" + ShelfTaskType.FROM_LOAD_MACHINE_RACK_TO_SHELF_RACK + "'"
            + " and t.loadMachineRack.id = ?1 and t.shelfRank.id = ?2 "
            + " and (t.state = '" + ShelfTaskState.IN_WORK +"' or t.state = '" 
            + ShelfTaskState.WAITING +"' or t.state = '"  +ShelfTaskState.IN_WORKING+ "' or t.state = '" + ShelfTaskState.WARNING + "')")
    public ShelfTask findShelfTaskFromLoadMachineRackToShelfRack(Long loadMachineRackId,Long shelfRankId);
    
    
    @Query("select t from ShelfTask t where t.taskType = '" + ShelfTaskType.FROM_LOAD_MACHINE_RACK_TO_HOIST + "'" 
            + " and (t.loadMachineRack.id = ?1 and t.shelfHoist.id = ?2) and (t.state = '" + ShelfTaskState.IN_WORK +"' or t.state = '"
            +ShelfTaskState.IN_WORKING+  "' or t.state = '" 
            + ShelfTaskState.WAITING +"')")
    public ShelfTask findShelfTaskFromLoadMachineRackToHoist(Long loadMachineRackId,Long shelfHoistId);
    
    @Query("select t from ShelfTask t where (t.taskType = '" + ShelfTaskType.FROM_LOAD_MACHINE_RACK_TO_SHELF_RACK + "'" 
            + " or t.taskType = '" + ShelfTaskType.FROM_SHELF_RACK_TO_LOAD_MACHINE_RACK + "')"
            + " and (t.loadMachineRack.id = ?1 or t.loadMachineRack.id = ?2) and (t.state = '" + ShelfTaskState.IN_WORK + "' or t.state = '" 
            + ShelfTaskState.WAITING +"')")
    public List<ShelfTask> findShelfTaskFromShelfRackToLoadMachineRack(Long loadMachineRackId1,Long loadMachineRackId2);
    
    
    @Query("select t from ShelfTask t where t.taskType = '" + ShelfTaskType.FROM_HOIST_TO_RANK + "'" 
            + " and (t.shelfHoist.id = ?1 and t.shelfRank.id = ?2) and (t.state = '" + ShelfTaskState.IN_WORK +"' or t.state = '"  +ShelfTaskState.IN_WORKING+  "' or t.state = '" 
            + ShelfTaskState.WAITING +"')")
    public ShelfTask findShelfTaskFromHoistToshelfRack(Long shelfHoistId,Long shelfRackId);
    
    
    @Query("select t from ShelfTask t where t.taskType = '" + ShelfTaskType.FROM_LOAD_MACHINE_RACK_TO_SHELF_RACK + "'" 
            + " and t.loadMachineRack.id = ?1 and t.shelfRank.id = ?2" 
            + " and (t.state = '" + ShelfTaskState.IN_WORK + "' or t.state = '" 
            + ShelfTaskState.WAITING + "' or t.state = '" + ShelfTaskState.WARNING + "')")
    public ShelfTask findExitShelfTaskFromLoadMachineRackToShelfRack(Long loadMachineRackId, Long shelfRankId);
    
    
    @Query("select t from ShelfTask t where (t.taskType = '" + ShelfTaskType.FROM_HOIST_TO_RANK + "'" 
            + " or t.taskType = '" + ShelfTaskType.FROM_EMPTY_RANK_TO_HOIST + "')"
            + " and t.state = '" + ShelfTaskState.WAITING + "'")
    public List<ShelfTask> findShelfTaskFromShelfRackToHoist();
    
    
    //--------------------以下都是上片任务(flag=1)
    //从上片位到吊装位
    @Query("select t from ShelfTask t where t.taskType = '" + ShelfTaskType.FROM_LOAD_MACHINE_RACK_TO_HOIST + "'" 
            + " and (t.loadMachineRack.id = ?1 and t.shelfHoist.id = ?2) and t.flag = '" + ShelfTaskFlag.LOAD_FLAG + "'"
            + " and (t.state = '" + ShelfTaskState.IN_WORK +"' or t.state = '"  +ShelfTaskState.IN_WORKING+  "' or t.state = '" 
            + ShelfTaskState.WAITING +"')")
    public ShelfTask findExitShelfTaskFromLoadMachineRackToHoist(Long loadMachineRackId,Long shelfHoistId);
    
    //从吊装位仓位
    @Query("select t from ShelfTask t where t.taskType = '" + ShelfTaskType.FROM_HOIST_TO_RANK + "'" 
            + " and (t.shelfHoist.id = ?1 and t.shelfRank.id = ?2) and t.flag = '" + ShelfTaskFlag.LOAD_FLAG + "'"
            + "and (t.state = '" + ShelfTaskState.IN_WORK +"' or t.state = '"  +ShelfTaskState.IN_WORKING+  "' or t.state = '" 
            + ShelfTaskState.WAITING +"')")
    public ShelfTask findExitShelfTaskFromHoistToshelfRack(Long shelfHoistId,Long shelfRackId);
    
    
    //调度页面显示调度任务
    @Query("select t from ShelfTask t where (t.taskType = '" + ShelfTaskType.FROM_LOAD_MACHINE_RACK_TO_SHELF_RACK + "'" 
            + " or t.taskType = '" + ShelfTaskType.FROM_LOAD_MACHINE_RACK_TO_HOIST +"'"
            + " or t.taskType = '" + ShelfTaskType.FROM_HOIST_TO_LOAD_MACHINE_RACK +"'"
            + " or t.taskType = '" + ShelfTaskType.FROM_SHELF_RACK_TO_LOAD_MACHINE_RACK + "')"
            + " and (t.loadMachineRack.id = ?1 or t.loadMachineRack.id = ?2) and (t.state = '" + ShelfTaskState.IN_WORK + "' or t.state = '" 
            + ShelfTaskState.WAITING +"')")
    public List<ShelfTask> findDispatchTasks(Long loadMachineRackId1,Long loadMachineRackId2);
    
    //找到产线中所有的等待中的上片任务
    @Query("select t from ShelfTask t where t.flag = '" + ShelfTaskFlag.LOAD_FLAG + "'" 
            + " and t.state = '" + ShelfTaskState.WAITING + "'")
    public List<ShelfTask> findAllLoadTasks();
    
    //从吊装位仓位
    @Query("select t from ShelfTask t where t.taskType = '" + ShelfTaskType.FROM_HOIST_TO_RANK + "'" 
            + " and t.shelfHoist.id = ?1  and t.flag = '" + ShelfTaskFlag.LOAD_FLAG + "'"
            + "and (t.state = '" + ShelfTaskState.IN_WORK +"' or t.state = '" 
            + ShelfTaskState.WAITING +"')")
    public List<ShelfTask> findtask(Long shelfHoistId);
 
    @Query("select t from ShelfTask t where t.state = '" + ShelfTaskState.WAITING + "'")
    public List<ShelfTask> findloadWaitingTasks();
}