| | |
| | | import java.sql.SQLException; |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | import java.util.ArrayList; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import com.example.springboot.service.JdbcConnections; |
| | | import com.example.springboot.service.SpianService; |
| | | |
| | | import com.example.springboot.entity.StorageCage; |
| | | import com.example.springboot.entity.north_glass_buffer1; |
| | | import com.example.springboot.mapper.AlarmMapper; |
| | | import com.example.springboot.mapper.SpianMapper; |
| | | |
| | | public class PlcHold extends Thread { |
| | | |
| | | private AlarmMapper alarmMapper; |
| | | |
| | | @Autowired |
| | | private JdbcConnections jdbcConnections; |
| | |
| | | |
| | | @Override |
| | | public void run() { |
| | | |
| | | while (this != null) { |
| | | try { |
| | | |
| | | Thread.sleep(100); |
| | | } catch (InterruptedException e) { |
| | | // \\ TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | // if (S7control.getinstance().CheckConnected() == false) { |
| | | spianService = WebSocketServer.applicationContext.getBean(SpianService.class); |
| | | spianService = WebSocketServer.applicationContext.getBean(SpianService.class); |
| | | spianMapper = WebSocketServer.applicationContext.getBean(SpianMapper.class); |
| | | |
| | | jdbcConnections = WebSocketServer.applicationContext.getBean(JdbcConnections.class); |
| | | while (this != null) { |
| | | try { |
| | | spianService.result=new ArrayList<>(); |
| | | Thread.sleep(300); |
| | | // if (S7control.getinstance().CheckConnected() == false) { |
| | | |
| | | // 根据玻璃id获取订单号,单独数据源 |
| | | |
| | | // try { |
| | | // spianService.selectAll(jdbcConnections.SelectGlassByGlassIdOrderIdFrameId("X12345610102GV","","")); |
| | | |
| | | // //spianService.selectAll(jdbcConnections.SelectGlassByGlassIdOrderIdFrameId("X12345610102GV","","")); |
| | | // north_glass_buffer1 aa=jdbcConnections.SelectGlassByGlassIdOrderIdFrameId("X12345610102GV","",""); |
| | | // spianMapper.UpdataAddCage2("123", "123", aa, 5, 1, 9, 2,2000.00); |
| | | // } catch (SQLException e) { |
| | | // // TODO Auto-generated catch block |
| | | // e.printStackTrace(); |
| | | // } |
| | | spianService.selectout2("X12345610102GV"); |
| | | |
| | | |
| | | // 出片任务//////////////////////////////// |
| | | //spianService.selectout2("X21942613103GV"); |
| | | |
| | | // spianService.selectout2("X21942610602GV"); |
| | | |
| | | List<Short> outlist = S7control.getinstance().ReadWord("DB106.20", 1); // 出片车状态 |
| | | List<Short> outlist1 = S7control.getinstance().ReadWord("DB105.18", 1); // 出片任务是否启动 |
| | | |
| | |
| | | // 当有待出片的玻璃时 |
| | | if (outglassid != null) { |
| | | // 获取该玻璃是否被禁用 |
| | | int glassdisabled = spianMapper.SelectCageGlassState(outglassid); |
| | | // 未禁用下发任务 |
| | | if (glassdisabled == 0) { |
| | | StorageCage glassdisabled = spianMapper.SelectCageGlassState(outglassid); |
| | | if(glassdisabled!=null){ |
| | | // 未禁用下发任务 |
| | | if (glassdisabled.getDisabled() == 0) { |
| | | spianService.selectout2(outglassid); |
| | | Plchome.isQueueWarning = false; |
| | | } else { // 禁用更改状态弹出提示 |
| | | Plchome.isQueueWarning = true; |
| | | System.out.println("禁用" + outglassid); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | |
| | | if (HB > 0) { |
| | | // 当B01小车汇报完成时更改玻璃状态 为1 |
| | | S7control.getinstance().WriteWord("DB105.48", (short) 1);// 恢复B01小车应答改为1 |
| | | boolean yingda = spianService.listbool("DB105.48");// b01汇报 |
| | | boolean yingda = spianService.listbool("DB105.48");// b01应答 |
| | | if (yingda == true) { |
| | | spianService.overtask(B01glassid.toString());// 完成任务 |
| | | } |
| | | System.out.println("汇报时B01|第" + aaa + "次" + B01glassid + "应答" + yingda); |
| | | aaa += 1; |
| | | System.out.println("汇报时B01|" + B01glassid + "应答" + yingda); |
| | | Plchome.feedglassid=B01glassid; |
| | | }else{ |
| | | S7control.getinstance().WriteWord("DB105.48", (short) 1);// 恢复B01小车应答改为1 |
| | | System.out.println("HB:|" + HB+"glassid|"+B01glassid); |
| | | } |
| | | |
| | | }else{ |
| | |
| | | if (B02backs == true) { |
| | | // 判断是否汇报正确的id |
| | | int HB = spianMapper.SelectHB(B02glassid.toString()); |
| | | System.out.println("汇报时B02|" + B02glassid); |
| | | System.out.println("huibaoshiB02ID|" + 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) { |
| | | if (yingda == true) { |
| | | spianService.overtask(B02glassid.toString());// 完成任务 |
| | | } |
| | | System.out.println("汇报时B02|第" + aaa + "次" + B02glassid + "应答" + yingda); |
| | | System.out.println("汇报时B02|" + B02glassid + "应答" + yingda); |
| | | Plchome.feedglassid=B01glassid; |
| | | }else{ |
| | | S7control.getinstance().WriteWord("DB105.50", (short) 1);// 恢复B02小车应答改为1 |
| | | System.out.println("HB:|" + HB+"glassid|"+B02glassid); |
| | | } |
| | | }else{ |
| | | S7control.getinstance().WriteWord("DB105.50", (short) 0);// 恢复B02小车应答改为0 |
| | |
| | | StringBuilder queueid2 = spianService.queGlassid("DB103.58", 14); |
| | | |
| | | int questate = spianMapper.Selectquecount(queueid1.toString());// 判断扫码位是否有玻璃已确认 |
| | | // queueid1.toString().isEmpty() |
| | | //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; |
| | | |
| | | north_glass_buffer1 glass1 =new north_glass_buffer1(); |
| | | north_glass_buffer1 glass2 =new north_glass_buffer1(); |
| | | |
| | | try { |
| | | glass1 = jdbcConnections.SelectGlassByGlassIdOrderIdFrameId(queueid1.toString(),"","");// D01玻璃信息 |
| | | glass2 = jdbcConnections.SelectGlassByGlassIdOrderIdFrameId(queueid2.toString(),"","");// D02玻璃信息 |
| | | if(Plchome.dbconnected==true){ |
| | | if(queueid1.toString()!=""){ |
| | | glass1 = jdbcConnections.SelectGlassByGlassIdOrderIdFrameIdplchold(queueid1.toString(),"","");// D01玻璃信息 |
| | | } |
| | | if(queueid2.toString()!=""){ |
| | | glass2 = jdbcConnections.SelectGlassByGlassIdOrderIdFrameIdplchold(queueid2.toString(),"","");// D02玻璃信息 |
| | | } |
| | | } |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | |
| | | // 当扫码位玻璃id为空时 宽度为0 |
| | | if (queueid1 != null && questate == 0) { |
| | | // 写入D01的数据到上片队列表 |
| | | if (glass1 == null) { // 当没有值时传空 |
| | | if (glass1 == null ||glass1.getordernumber()==null) { // 当没有值时传空 |
| | | spianMapper.Updatequeue(null, null, null, null, 0, null, null, null, null, 1); |
| | | } else { |
| | | |
| | |
| | | |
| | | if (queueid2 != null) { |
| | | // 写入D02的数据到上片队列表 |
| | | if (glass2 == null) { |
| | | if (glass2 == null ||glass2.getordernumber()==null) { |
| | | spianMapper.Updatequeue(null, null, null, null, 0, null, null, null, null, 2); |
| | | } else { |
| | | spianMapper.Updatequeue(queueid2.toString(), glass2.getordernumber(), glass2.getlistnumber(), |
| | |
| | | } |
| | | |
| | | } |
| | | // System.out.println(spianService.result); |
| | | |
| | | // 查询数据库 |
| | | // 推送到前端 |
| | | |
| | | // } |
| | | } catch (InterruptedException e) { |
| | | // \\ TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | | |