ZengTao
2024-05-17 62718fb62a1fc92ee727ce31e0ca877f3e30f503
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
package com.example.springboot.mapper;
 
import org.apache.ibatis.annotations.*;
 
import com.example.springboot.entity.CarPosition;
import com.example.springboot.entity.StorageCage;
import com.example.springboot.entity.StorageTask;
import com.example.springboot.entity.alarmmg;
import com.example.springboot.entity.north_glass_buffer1;
import com.example.springboot.entity.Out_slice;
import com.example.springboot.entity.Queue;
import com.example.springboot.entity.RolePermission;
 
import java.util.List;
 
@Mapper
public interface HomeMapper {
  //查询每个笼子的使用情况
  @Select("select cage,round(100-(21-sum(if(state>0,1,state)))/21*100) as cell,21-sum(if(state>0,1,state)) as state from (select cage,cell,max(state) as state from storage_cage group by cage,cell) as cages group by cage")
  List<StorageCage> selectAll();
 
  // 查询10-6笼内层格子状态
  @Select("SELECT cage,state,ifnull(glasswidth/2750*2,0) as glasswidth from storage_cage where cage>5 and tier=2 order by cage desc,cell desc")
  List<StorageCage> selectRack1();
 
  // 查询5-1笼内层格子状态
  @Select("SELECT cage,state,ifnull(glasswidth/2750*2,0) as glasswidth from storage_cage where cage<=5 and tier=2 order by cage desc,cell desc")
  List<StorageCage> selectRack2();
 
  // 查询10-6笼外层格子状态
  @Select("SELECT case when tier=1 then cage else 0 end as cage,case when tier=1 then state else 0 end as state,sum(case when tier=1 then glasswidth/2750*2 else 0 end) as glasswidth,sum(case when tier=2 then glasswidth/2750*2 else 0 end) as width  from storage_cage where cage>5  group by cage,cell order by cage desc,cell desc")
  List<StorageCage> selectRack3();
 
  // 查询5-1笼外层格子状态
  @Select("SELECT case when tier=1 then cage else 0 end as cage,case when tier=1 then state else 0 end as state,sum(case when tier=1 then glasswidth/2750*2 else 0 end) as glasswidth,sum(case when tier=2 then glasswidth/2750*2 else 0 end) as width  from storage_cage where cage<=5  group by cage,cell order by cage desc,cell desc")
  List<StorageCage> selectRack4();
 
 
 
  // 根据任务类型查询当前正在出片,进片的玻璃信息
  @Select("select * from storage_cage where state=#{task_type}")
  List<StorageCage> selectinout(@Param("task_type") Integer task_type);
 
  // 查询是否存在此订单
  @Select("select count(*) from storage_cage where order_id=#{orderid} and state=1")
  short SelectOrder(@Param("orderid") String orderid);
 
  // @Insert("insert into order_out(orderid) values('#{orderid}')")
  @Insert("INSERT INTO `canadames`.`order_out`( `order_id`,`state`) VALUES ( #{orderid},0)")
  void InsertOrder(String orderid);
 
  // 停止按当前订单出片
  @Update("update order_out set state=1 where state=0")
  void updateOrder();
 
  // 查询是否存在正在上片的任务
  @Select("select count(*) from storage_task where task_state=0 and task_type=0")
  short SelectInTask();
 
  // 手动完成任务
  @Update("update storage_task set task_state=1 where task_type=#{task_type} and glass_id=#{glassid}")
  void UpdateTask(@Param("task_type") Integer task_type,String glassid);
 
  // 手动完成进片任务修改笼子数据
  @Update("update storage_cage set state=1 where glass_id=#{glassid} and state=2")
  void UpdateCageTask1(@Param("glassid") String glassid);
 
  //获取报警信息
  @Select("select id,content,timeon as timeons,endTime from alarmmg where endTime is null")
  List<alarmmg> SelectAlarmmgInfo();
 
  //获取理片笼内玻璃信息
  @Select("select * from storage_cage where position(#{cage} in ifnull(glass_id,\"\"))")
  List<StorageCage> SelectCageInfo(String cage);
 
  // 手动完成出片任务修改笼子数据
  @Update("update storage_cage set state=0,glass_id=null,order_id=null,glasswidth=null,glassheight=null,glasswidthmm=null,glassheightmm=null,listid=null,boxid=null,FrameBarcode=null where glass_id=#{glassid}")
  void DeleteByGlassID(String glassid);
 
  //查询小车位置
  @Select("select * from car_position")
  List<CarPosition> Loadcarlist();
 
  //查询操作密码
  @Select("select dianqimima from user where id=1")
  String SelectPassword();
 
  //根据玻璃id查询理片笼信息
  @Select("select * from storage_cage where glass_id=#{glassid}")
  StorageCage SelectGlassInfo(String glassid);
 
  //根据玻璃id查询理片笼信息
  @Select("select * from storage_cage where glass_id=#{glassid}")
  List<StorageCage> SelectStorageInfoByGlassId(String glassid);
 
  //查询玻璃信息
//  @Select("select * from glass where glassid=#{glassid}")
  @Select("SELECT ordernumber,listnumber,boxnumber,barcode,glasslength,glassheight,glasslength_mm,glassheight_mm FROM north_glass_buffer1 where barcode=#{barcode}")
  north_glass_buffer1 SelectGlassByGlassID(String barcode);
 
  //启用/禁用理片笼格子
  @Update("update storage_cage set disabled=#{disabled} where cage=#{cage} and cell=#{cell}")
  void Disabled(short cage, short cell, short disabled);
 
  //理片笼新增玻璃
  @Update("update storage_cage set state=1,glass_id=#{glass.glassId},order_id=#{glass.orderId},glasswidth=#{glass.glasswidth},glassheight=#{glass.glassheight},glasswidthmm=#{glass.glasswidthmm},glassheightmm=#{glass.glassheightmm},listid=#{glass.listId},boxid=#{glass.boxId} where cage=#{cage} and cell=#{cell} and tier=#{tier}")
  void Inglassid(Queue glass, short cage, short cell, short tier);
 
  //查询理片笼中是否有此玻璃
  @Select("select count(*) from storage_cage where glass_id=#{glassId}")
  short SelectStorageByGlassId(String glassId);
 
  //根据订单查询玻璃信息
  @Select("select * from north_glass_buffer1 where position(#{orderid} in ordernumber)")
  List<north_glass_buffer1> SelectGlass(String orderid);
 
  //获取上片队列信息
  @Select("select * from queue where id=#{id}")
  Queue GetQueueInfo(int id);
 
  //手动添加扫码位玻璃
  @Update("update queue set glassid=#{queue.glassId},orderid=#{queue.orderId},listId=#{queue.listId},boxId=#{queue.boxId},glasswidth=#{queue.glasswidth},glassheight=#{queue.glassheight},glasswidthmm=#{queue.glasswidthmm},glassheightmm=#{queue.glassheightmm},state=1 where id=#{id}")
  void InsertQueueGlassId(Queue queue,Short id);
 
  //确认扫码位玻璃信息
  @Update("update queue set state=1 where id=1")
  void UpdateQueueState();
 
  //手动添加扫码位玻璃
  @Update("update queue set glassid=null,orderid=null,listid=null,boxid=null,glasswidth=null,glassheight=null,glasswidthmm=null,glassheightmm=null,state=0 where id=#{id}")
  void DeleteQueueGlass(String id);
 
  //查询此订单在理片笼里的玻璃数
  @Select("select count(*) from storage_cage where order_id=#{orderid}")
  Short SelectGlassNo(String orderid);
 
  //根据玻璃id从客户表查询数据
  @Select("select * from north_glass_buffer1 where barcode=#{glassid}")
  north_glass_buffer1 SelectBoxNo(String glassid);
 
  //查询出片队列信息
  @Select("select a.*,b.cell from out_slice a left join storage_cage b on a.glassId=b.glass_id order by sequence")
  List<Out_slice> SelectProductionqueue();
 
  //根据玻璃id查询笼内玻璃信息
  @Select("select * from storage_cage where glass_id=#{glassid}")
  StorageCage SelectStorageGlassById(String glassid);
 
  //根据玻璃id查询笼内玻璃信息
  @Select("select * from storage_cage where glass_id=#{glassid}")
  List<StorageCage> SelectStoragesGlassById(String glassid);
 
 
  // //根据玻璃id删除出片队列玻璃
  // @Update("update out_slice set state=4 where barcode=#{FrameNo} and (state=0 or state=1 or state=2)")
  // void DeleteProductionQueueGlass(String id);
 
  //根据铝框id查询对应玻璃信息
  @Select("select * from north_glass_buffer1 where FrameBarcode=#{FrameBarcode}")
  List<north_glass_buffer1> SelectAluminumFrameInfoById(String FrameBarcode);
 
 
  //根据玻璃id查询出片队列信息
  @Select("select * from out_slice where glassid=#{getbarcode}")
  Out_slice SelectQueueByglassid(String getbarcode);
 
  //添加出片队列
  @Insert("INSERT INTO out_slice( `glassId`, `barcode`, `glasswidth`, `glassheight`, `state`, `flip`, `sequence`, `time` ,`position` ,`orderid` ,`listid` ,`boxid` ,`glasswidthmm` ,`glassheightmm` ,`framewidthmm` ,`frameheightmm` ,`framestate` ) VALUES ( #{glassid}, #{FrameNo}, #{glasslengthMm}, #{glassheightMm}, #{state}, #{flip}, #{sequence}, now(), #{position}, #{orderid}, #{listid}, #{boxid}, #{glasswidth}, #{glassheight}, #{framewidthmm}, #{frameheightmm}, 0);")
  void AddOutSliceS(String glassid, String flip, String FrameNo, String glasslengthMm, String glassheightMm, int sequence, String position, Short state,String orderid, String listid, String boxid, String glasswidth, String glassheight,String framewidthmm,String frameheightmm);
 
  //出片队列调序
  @Update("update out_slice set sequence=#{sequence} where glassid=#{glassId}")
  void UpdateOutSliceSequence(String glassId,int sequence);
 
  //查询出片队列最大顺序
  @Select("select ifnull(max(sequence),0)+1 from out_slice ")
  Short SelectMaxSquence();
  //查询用户权限
  @Select("select rp.* from role_permission rp inner join user r on rp.role_id=r.role_id and r.username=#{username} and (permission_id=32 or permission_id=33 or permission_id=34 or permission_id=35 or permission_id=36 or permission_id=37 or permission_id=38 or permission_id=39 or permission_id=50)")
  List<RolePermission> SelectPermissionByUserName(String username);
 
  // //根据玻璃完成出片任务
  // @Update("update out_slice set state=2 where id=#{id}")
  // void CompleteQueue(String id);
 
  //根据玻璃完成出片任务
  @Update("update out_slice set state=2 where glassid=#{glassid}")
  void CompleteQueueByGlassId(String glassid);
 
  //查询铝框id对应玻璃完成数量
  @Select("select count(*) from out_slice where barcode=#{frameid} and state!=4")
  Short SelectCountByFrameNo(String frameid);
 
  //删除已完成的任务
  @Delete("delete from out_slice where Barcode=#{frameid}")
  void CompleteQueueByFrameNo(String frameid);
 
  //查询笼内格子剩余宽度
  @Select("Select width from storage_cage where cage=#{cage} and cell=#{cell} limit 1")
  Double SelectCageWidth(short cage, short cell);
 
  //修改出片队列玻璃状态为缺失
  @Update("update out_slice set state=3 where glassId=#{glassid} and state<3")
  void UpdateOutSliceGlass(String glassid);
 
  //查询未完成的任务
  @Select("select * from storage_task where task_state=0 and task_type=#{task_type}")
  List<StorageTask> SelectTaskByState(int task_type);
 
  //修改出片队列铝框状态
  @Update("update out_slice set framestate=1 where barcode=#{frameno}")
  void FrameStateUpdate(String frameno);
 
  //查询当前铝框信息
  @Select("select * from out_slice where framestate=0 order by id limit 1")
  Out_slice SelectCurrentFrame();
 
  //根据玻璃id查询任务信息
  @Select("select task_type from storage_task where glass_id=#{glassid} and task_state!=1")
  Short SelectTaskByGlassId(String glassid);
 
  //修改格子宽度
  @Update("update storage_cage set width=width+#{width} where   cage=#{cage} and cell=#{cell};")
  void UpdataCageWidth(double width, int cage, int cell);
 
  //获取铝框有没有正在出片的玻璃
  @Select("select count(*) from out_slice where barcode=#{frameNo} and state=1")
  Short SelectOutingQueueCount(String frameNo);
 
  //获取铝框是否存在玻璃对了
  @Select("select count(*) from out_slice where barcode=#{frameNo}")
  int SelectCountFrame(String getbarcode);
  
 
}