wuyouming666
2024-01-24 dd5432591b4018bd1244102b8cf86c22569ec163
springboot-vue3/src/main/java/com/example/springboot/component/Plchome.java
@@ -54,21 +54,19 @@
    @Override
    public void run() {
        while (this != null) {
            JSONObject jsonObject = new JSONObject();
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            JSONObject jsonObject = new JSONObject();
            // 注入mapper
                // 注入mapper
            homeMapper = WebSocketServer.applicationContext.getBean(HomeMapper.class);
            spianMapper = WebSocketServer.applicationContext.getBean(SpianMapper.class);
            spianService = WebSocketServer.applicationContext.getBean(SpianService.class);
            outSliceServive = WebSocketServer.applicationContext.getBean(OutSliceServive.class);
            north_Glass_Buffer1Service = WebSocketServer.applicationContext.getBean(North_Glass_Buffer1Service.class);
            storageCageService = WebSocketServer.applicationContext.getBean(StorageCageService.class);
            dbserve = WebSocketServer.applicationContext.getBean(JdbcConnections.class);
            // 笼子使用情况
            List<StorageCage> tableData = homeMapper.selectAll();
            jsonObject.append("tableData", tableData);
@@ -119,41 +117,46 @@
            Out_slice CurrentFrame = outSliceServive.SelectCurrentFrame();
            jsonObject.append("CurrentFrame", CurrentFrame);
            // List<Short> listd17 = S7control.getinstance().ReadWord("DB17.0",10);
            // String id=spianService.queGlassid("DB17.10", 14).toString();
            //
            // String E01id = new String( S7controlLK.getinstance().ReadByte("DB17.0",16));
            // String J01id = new String( S7controlLK.getinstance().ReadByte("DB17.22",14));
            // 铝框线交互
            try {
                if (CurrentFrame != null) {
                    spianService.outmesid(CurrentFrame.getBarCode(), "DB17.0");
                }
                List<Short> framerequests = S7control.getinstance().ReadWord("铝框id请求字地址", 1);
                for (Short framerequest : framerequests) {
                    if (framerequest == 1) {
                        // 铝框id
                        String franmeno = spianService.queGlassid("DB17.10", 14).toString();
                        String position;
                        try {
                            position = dbserve.SelectPositionByFrameBarcode(franmeno);
                        } catch (SQLException e) {
                            // TODO Auto-generated catch block
                            position = "0";
                            e.printStackTrace();
                        }
                        Short send;
                        if (position == "0") {
                            send = 0;
                        } else {
                            send = 1;
                        }
                        S7control.getinstance().WriteWord("铝框翻转发送地址", (short) send);
                    }
                }
            } catch (Exception e) {
                // TODO: handle exception
            if (CurrentFrame != null) {
                S7controlLK.getinstance().writeStrings(CurrentFrame.getBarCode(),"DB17.0");
            }
            String E01id=S7controlLK.getinstance().readStrings("DB17.0");
            String J01id=S7controlLK.getinstance().readStrings("DB17.22");
            List<Short> liststates=S7controlLK.getinstance().ReadWord("DB17.38", 1);
            List<Short> liststate=S7controlLK.getinstance().ReadWord("DB17.20", 1);
            Short framerequest = liststate.get(0);
                if (framerequest == 1) {
                    // 铝框id
                    String position;
                    try {
                        position = dbserve.SelectPositionByFrameBarcode(J01id);
                    } catch (SQLException e) {
                        // TODO Auto-generated catch block
                        position = "0";
                        e.printStackTrace();
                    }
                    Short send;
                    if (position.equals("0")) {
                        send = 0;
                    } else {
                        send = 1;
                    }
                    S7controlLK.getinstance().WriteWord("DB17.38", (short) send);
                }
            if (S7control.getinstance().CheckConnected() == true) {
                // 获取当前扫码方式
@@ -211,7 +214,6 @@
                    if (inglassInfo.size() > 0) {
                        jsonObject.append("loadglassheight", inglassInfo.get(0) * 70);
                    }
                }
                // // 获取铝框idDB106.DBW64,添加到出片队列
                // String frameno="X21763329601FB";
@@ -268,8 +270,13 @@
                }
            }
            storageCageService = WebSocketServer.applicationContext.getBean(StorageCageService.class);
            dbserve = WebSocketServer.applicationContext.getBean(JdbcConnections.class);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            boolean dbconnected = false;
            try {
                dbserve.getConn();