| | |
| | | package com.example.springboot.component; |
| | | |
| | | import java.sql.SQLException; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import javax.websocket.Session; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | |
| | | import com.example.springboot.service.JdbcConnections; |
| | | import com.example.springboot.service.SpianService; |
| | | import com.example.springboot.entity.Glass; |
| | | import com.example.springboot.mapper.AlarmMapper; |
| | | |
| | | import cn.hutool.json.JSONArray; |
| | | import cn.hutool.json.JSONObject; |
| | | import com.example.springboot.mapper.SpianMapper; |
| | | |
| | | public class PlcHold extends Thread { |
| | | |
| | | private AlarmMapper alarmMapper; |
| | | |
| | | @Autowired |
| | | private JdbcConnections jdbcConnections; |
| | | private SpianMapper spianMapper; |
| | | private SpianService spianService; |
| | | |
| | | @Override |
| | | public void run() { |
| | | |
| | | while (this != null) { |
| | | try { |
| | | |
| | | Thread.sleep(10000); |
| | | Thread.sleep(500); |
| | | } catch (InterruptedException e) { |
| | | // TODO Auto-generated catch block |
| | | // \\ TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | } |
| | | List<Boolean> bitlist = S7control.getinstance().ReadBits("DB2.0.0", 100); |
| | | spianService = WebSocketServer.applicationContext.getBean(SpianService.class); |
| | | spianMapper = WebSocketServer.applicationContext.getBean(SpianMapper.class); |
| | | jdbcConnections = WebSocketServer.applicationContext.getBean(JdbcConnections.class); |
| | | |
| | | List<Short> paramlist = S7control.getinstance().ReadWord("DB100.6", 1); |
| | | // 根据玻璃id获取订单号,单独数据源 |
| | | // try { |
| | | // Glass glass = jdbcConnections.selectGlass(112); |
| | | |
| | | // // System.out.println(glass.getOrderId()); |
| | | // } catch (SQLException e) { |
| | | // // TODO Auto-generated catch block |
| | | // e.printStackTrace(); |
| | | // } |
| | | // spianService.selectAll((short)257); |
| | | //判断进片请求 |
| | | List<Short> datas1List = S7control.getinstance().ReadWord("DB106.24", 1); |
| | | List<Short> datas1ListState = S7control.getinstance().ReadWord("DB106.8", 1); |
| | | |
| | | |
| | | if (datas1List != null && datas1ListState != null) { |
| | | // 获取prc进片请求数据 |
| | | boolean exist = datas1List.contains((short) 1); |
| | | // 获取进片车状态 |
| | | boolean exist1 = datas1ListState.contains((short) 0); |
| | | String glassid=""; |
| | | StringBuilder strId=new StringBuilder(); |
| | | |
| | | // 进片请求为1时 |
| | | if (exist == true) { |
| | | // 当进片车空闲时 |
| | | if (exist1 == true) { |
| | | // 获取进片id |
| | | byte[] datas1ListID = S7control.getinstance().ReadByte("DB106.26", 4); |
| | | if (datas1ListID != null) { |
| | | // 获取玻璃id |
| | | for (byte list1 : datas1ListID) { |
| | | strId.append(list1); |
| | | |
| | | } |
| | | spianService.selectAll(strId.toString()); |
| | | //spianService.selectAll(Short.parseShort(strId.toString())); |
| | | S7control.getinstance().WriteByte("DB105.16",datas1ListID); |
| | | } |
| | | |
| | | } |
| | | // System.out.println(exist); |
| | | } |
| | | } |
| | | |
| | | //spianService.selectAll((short) 111); |
| | | |
| | | List<Short> outlist = S7control.getinstance().ReadWord("DB106.20", 1); // 出片车状态 |
| | | boolean outstate=false;//出片车空闲判断 |
| | | if (outlist != null) { |
| | | // 判断按订单出片 |
| | | outstate = outlist.contains((short) 0); |
| | | Glass glass=spianMapper.SelectDBOut();//判断是否有调拨后的出片任务未完成 |
| | | |
| | | if(outstate== true ){ |
| | | if(glass.getId()==2){ |
| | | spianService.selectout2(glass.getGlassId().toString()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | if (outstate == true) { // 出片车状态空闲时 |
| | | String orderid = spianMapper.SelectOrderout(); |
| | | if (orderid != null) { |
| | | spianService.selectout(orderid); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | // 查询数据库 |
| | | // 推送到前端 |
| | | |
| | | } |
| | | } |
| | | |
| | | } |