| | |
| | | package com.example.springboot.component; |
| | | |
| | | import java.sql.SQLException; |
| | | import java.util.ArrayList; |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | |
| | | 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.entity.north_glass_buffer1; |
| | | import com.example.springboot.mapper.AlarmMapper; |
| | | import com.example.springboot.mapper.SpianMapper; |
| | | |
| | |
| | | private SpianMapper spianMapper; |
| | | private SpianService spianService; |
| | | |
| | | int aaa; |
| | | |
| | | @Override |
| | | public void run() { |
| | | |
| | | |
| | | while (this != null) { |
| | | try { |
| | | |
| | | Thread.sleep(500); |
| | | Thread.sleep(100); |
| | | } catch (InterruptedException e) { |
| | | //\\ TODO Auto-generated catch block |
| | | // \\ TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | // if (S7control.getinstance().CheckConnected() == false) { |
| | | spianService = WebSocketServer.applicationContext.getBean(SpianService.class); |
| | | spianMapper = WebSocketServer.applicationContext.getBean(SpianMapper.class); |
| | | jdbcConnections = WebSocketServer.applicationContext.getBean(JdbcConnections.class); |
| | | |
| | | //根据玻璃id获取订单号 |
| | | try { |
| | | Glass glass=jdbcConnections.selectGlass(112); |
| | | jdbcConnections = WebSocketServer.applicationContext.getBean(JdbcConnections.class); |
| | | // 根据玻璃id获取订单号,单独数据源 |
| | | |
| | | // try { |
| | | // spianService.selectAll(jdbcConnections.SelectGlassByGlassIdOrderIdFrameId("X12345610102GV","","")); |
| | | |
| | | // } catch (SQLException e) { |
| | | // // TODO Auto-generated catch block |
| | | // e.printStackTrace(); |
| | | // } |
| | | spianService.selectout2("X12345610102GV"); |
| | | |
| | | |
| | | //System.out.println(glass.getOrderId()); |
| | | } catch (SQLException e) { |
| | | // TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | } |
| | | // 出片任务//////////////////////////////// |
| | | //spianService.selectout2("X21942613103GV"); |
| | | |
| | | |
| | | //spianService.selectout("11"); |
| | | //判断进片请求 |
| | | List<Short> datas1List=S7control.getinstance().ReadWord("DB106.24", 1); |
| | | List<Short> datas1ListState=S7control.getinstance().ReadWord("DB106.8", 1); |
| | | List<Short> outlist = S7control.getinstance().ReadWord("DB106.20", 1); // 出片车状态 |
| | | List<Short> outlist1 = S7control.getinstance().ReadWord("DB105.18", 1); // 出片任务是否启动 |
| | | |
| | | if(datas1List!=null &&datas1ListState!=null){ |
| | | //获取prc进片请求数据 |
| | | boolean exist = datas1List.contains((short)1); |
| | | //获取进片车状态 |
| | | boolean exist1 = datas1ListState.contains((short)0); |
| | | //进片请求为1时 |
| | | if(exist=true){ |
| | | //当进片车空闲时 |
| | | if(exist1=true){ |
| | | //获取进片id |
| | | List<Short> datas1ListID=S7control.getinstance().ReadWord("DB106.26", 13); |
| | | //获取玻璃id |
| | | for(Short list1:datas1ListID){ |
| | | |
| | | spianService.selectAll((short)list1); |
| | | } |
| | | } |
| | | //System.out.println(exist); |
| | | } |
| | | } |
| | | |
| | | List<Short> outlist=S7control.getinstance().ReadWord("DB106.20", 1); //出片车状态 |
| | | List<Short> outlist2=S7control.getinstance().ReadWord("DB106.20", 1); //出片任务完成 |
| | | |
| | | |
| | | List<Short>ceshi1=new ArrayList<Short>();//出片车状态 |
| | | List<Short>ceshi2=new ArrayList<Short>();//出片任务完成 |
| | | ceshi1.add((short)0); |
| | | ceshi2.add((short)1); |
| | | if(ceshi1!=null && ceshi2!=null){ |
| | | //判断按订单出片 |
| | | boolean outstate = ceshi1.contains((short)0); |
| | | boolean outstate2 = ceshi1.contains((short)1); |
| | | if(outstate=true){ //出片车状态空闲时 |
| | | if(outstate2=true){ //出片车任务完成时 |
| | | String orderid=spianMapper.SelectOrderout(); |
| | | if(orderid!=null){ |
| | | spianService.selectout(orderid); |
| | | } |
| | | |
| | | } |
| | | boolean Plcout = spianService.listbool("DB106.64"); // 出片请求字 |
| | | boolean Plcout2 = spianService.listbool("DB105.18"); // 出片启动 |
| | | if (Plcout == false&&Plcout2==true) { |
| | | S7control.getinstance().WriteWord("DB105.18", (short) 0);// 出片任务启动改为0 |
| | | System.out.println("关闭出片启动" + LocalDateTime.now());// 出片任务发送字改为0 |
| | | } |
| | | boolean Plcadd = spianService.listbool("DB106.24"); // 进片请求字 |
| | | boolean Plcadd2 = spianService.listbool("DB105.16"); // 进片启动 |
| | | if (Plcadd == false&&Plcadd2==true) { |
| | | S7control.getinstance().WriteWord("DB105.16", (short) 0);//进片任务启动改为0 |
| | | System.out.println("关闭进片启动" + LocalDateTime.now());// 进片任务发送字改为0 |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | // StringBuilder writedstrIdOut = new StringBuilder(); |
| | | // 获取已下发的出片id |
| | | byte[] writedglassidbytesOut = S7control.getinstance().ReadByte("DB105.30", 14); |
| | | String writedstrIdOut = new String(writedglassidbytesOut); |
| | | |
| | | |
| | | if (Plcout == true) { |
| | | // 判断当前是否有未执行的任务 |
| | | int outnum = spianMapper.SelectOutSliceshu();//是否有正在出片的任务 |
| | | int cageoutsum = spianMapper.Selectcageout(3);//笼子内是否还有在出片的玻璃 |
| | | // 当没有任务执行并且出片车空闲时 |
| | | if (outnum == 0 && Plchome.isAllowQueue == true && cageoutsum == 0) { |
| | | // 判断铝框出片队列表是否有待出片的玻璃 |
| | | String outglassid = spianMapper.SelectOutSlice(); |
| | | // 当有待出片的玻璃时 |
| | | if (outglassid != null) { |
| | | // 获取该玻璃是否被禁用 |
| | | int glassdisabled = spianMapper.SelectCageGlassState(outglassid); |
| | | // 未禁用下发任务 |
| | | if (glassdisabled == 0) { |
| | | spianService.selectout2(outglassid); |
| | | Plchome.isQueueWarning = false; |
| | | } else { // 禁用更改状态弹出提示 |
| | | Plchome.isQueueWarning = true; |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | ///////////// 进片任务 |
| | | List<Short> datas1List = S7control.getinstance().ReadWord("DB106.24", 1);// 获取prc进片请求数据 |
| | | List<Short> datas1ListState = S7control.getinstance().ReadWord("DB106.8", 1);// 获取进片车状态 |
| | | List<Short> datas1ListState2 = S7control.getinstance().ReadWord("DB105.16", 1);// 获取进片车任务是否启动 |
| | | |
| | | boolean B01backs = spianService.listbool("DB106.60");// b01汇报 |
| | | boolean B02backs = spianService.listbool("DB106.62");// b02汇报 |
| | | StringBuilder B01glassid = spianService.queGlassid("DB103.184", 14);// BO1的玻璃id |
| | | StringBuilder B02glassid = spianService.queGlassid("DB103.212", 14);// B02的玻璃id |
| | | |
| | | // 当进片小车完成任务时 |
| | | if (B01backs == true) { |
| | | // 判断是否汇报正确的id |
| | | int HB = spianMapper.SelectHB(B01glassid.toString()); |
| | | if (HB > 0) { |
| | | // 当B01小车汇报完成时更改玻璃状态 为1 |
| | | S7control.getinstance().WriteWord("DB105.48", (short) 1);// 恢复B01小车应答改为1 |
| | | boolean yingda = spianService.listbool("DB105.48");// b01汇报 |
| | | if (yingda == true) { |
| | | spianService.overtask(B01glassid.toString());// 完成任务 |
| | | } |
| | | System.out.println("汇报时B01|第" + aaa + "次" + B01glassid + "应答" + yingda); |
| | | aaa += 1; |
| | | } |
| | | |
| | | }else{ |
| | | S7control.getinstance().WriteWord("DB105.48", (short) 0);// 恢复B01小车应答改为1 |
| | | } |
| | | |
| | | // 当出片小车完成任务时 |
| | | if (B02backs == true) { |
| | | // 判断是否汇报正确的id |
| | | int HB = spianMapper.SelectHB(B02glassid.toString()); |
| | | System.out.println("汇报时B02|" + B02glassid); |
| | | if (HB > 0) { |
| | | // 当B02小车汇报完成时更改玻璃状态为0 |
| | | |
| | | S7control.getinstance().WriteWord("DB105.50", (short) 1);// 恢复B02小车应答改为1 |
| | | System.out.println("汇报时B02ID|" + B02glassid); |
| | | boolean yingda = spianService.listbool("DB105.50");// b02汇报 |
| | | if (yingda == true) { |
| | | spianService.overtask(B02glassid.toString());// 完成任务 |
| | | } |
| | | System.out.println("汇报时B02|第" + aaa + "次" + B02glassid + "应答" + yingda); |
| | | } |
| | | }else{ |
| | | S7control.getinstance().WriteWord("DB105.50", (short) 0);// 恢复B02小车应答改为0 |
| | | } |
| | | |
| | | |
| | | // 获取DO1数据 |
| | | StringBuilder queueid1 = spianService.queGlassid("DB106.26", 14);// 获取请求的id跟DO1同时清 |
| | | // 获取DO2数据 |
| | | StringBuilder queueid2 = spianService.queGlassid("DB103.58", 14); |
| | | |
| | | int questate = spianMapper.Selectquecount(queueid1.toString());// 判断扫码位是否有玻璃已确认 |
| | | // queueid1.toString().isEmpty() |
| | | // north_glass_buffer1 glass1 = spianMapper.selectGlass(queueid1.toString());// D01的玻璃信息 |
| | | // north_glass_buffer1 glass2 = spianMapper.selectGlass(queueid2.toString());// D02玻璃信息 |
| | | north_glass_buffer1 glass1=null; |
| | | north_glass_buffer1 glass2=null; |
| | | try { |
| | | glass1 = jdbcConnections.SelectGlassByGlassIdOrderIdFrameId(queueid1.toString(),"","");// D01玻璃信息 |
| | | glass2 = jdbcConnections.SelectGlassByGlassIdOrderIdFrameId(queueid2.toString(),"","");// D02玻璃信息 |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | // 当扫码位玻璃id为空时 宽度为0 |
| | | if (queueid1 != null && questate == 0) { |
| | | // 写入D01的数据到上片队列表 |
| | | if (glass1 == null) { // 当没有值时传空 |
| | | spianMapper.Updatequeue(null, null, null, null, 0, null, null, null, null, 1); |
| | | } else { |
| | | |
| | | spianMapper.Updatequeue(queueid1.toString(), glass1.getordernumber(), glass1.getlistnumber(), |
| | | glass1.getboxnumber(), 0, glass1.getglasslengthmm().toString(), glass1.getglassheightmm().toString(), |
| | | glass1.getglasslength().toString(), glass1.getglassheight().toString(), 1); |
| | | } |
| | | |
| | | } |
| | | |
| | | if (queueid2 != null) { |
| | | // 写入D02的数据到上片队列表 |
| | | if (glass2 == null) { |
| | | spianMapper.Updatequeue(null, null, null, null, 0, null, null, null, null, 2); |
| | | } else { |
| | | spianMapper.Updatequeue(queueid2.toString(), glass2.getordernumber(), glass2.getlistnumber(), |
| | | glass2.getboxnumber(), 0, glass2.getglasslengthmm().toString(), glass2.getglassheightmm().toString(), |
| | | glass2.getglasslength().toString(), glass2.getglassheight().toString(), 2); |
| | | spianMapper.overqueue2(queueid2.toString(), 0, 1);// 更改扫码位任务表的状态为0 |
| | | S7control.getinstance().WriteWord("DB105.16", (short) 0);// 关闭任务启动 |
| | | } |
| | | |
| | | } |
| | | |
| | | // 查询数据库 |
| | | // 推送到前端 |
| | | |
| | | // } |
| | | } |
| | | } |
| | | |
| | | |
| | | } |