From 7687eb6cc76ab8ca20b39e7567255939abc4ff66 Mon Sep 17 00:00:00 2001 From: ZengTao <2773468879@qq.com> Date: 星期一, 29 四月 2024 09:16:24 +0800 Subject: [PATCH] 修改进片逻辑判断,添加异常捕获 --- springboot-vue3/src/main/java/com/example/springboot/component/Plchome.java | 126 ++++++++++++++++++++++++------------------ 1 files changed, 72 insertions(+), 54 deletions(-) diff --git a/springboot-vue3/src/main/java/com/example/springboot/component/Plchome.java b/springboot-vue3/src/main/java/com/example/springboot/component/Plchome.java index d178723..f294138 100644 --- a/springboot-vue3/src/main/java/com/example/springboot/component/Plchome.java +++ b/springboot-vue3/src/main/java/com/example/springboot/component/Plchome.java @@ -7,9 +7,13 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashMap; import java.util.List; +import java.util.Map; import com.example.springboot.service.*; + +import org.apache.ibatis.annotations.Result; import org.springframework.beans.factory.annotation.Autowired; import com.example.springboot.entity.Glass; @@ -18,6 +22,7 @@ import com.example.springboot.entity.StorageCage; import com.example.springboot.entity.alarmmg; import com.example.springboot.entity.north_glass_buffer1; +import com.example.springboot.entity.device.PlcParameterObject; import com.example.springboot.mapper.HomeMapper; import com.example.springboot.mapper.SpianMapper; @@ -34,7 +39,7 @@ public static Boolean isAllowQueue = true; public static Boolean isAllowReordering = true; // 鍑虹墖闃熷垪璀﹀憡 - public static Boolean isQueueWarning = false; + public static Boolean isQueueWarning = true; // 閾濇id public static String FrameNo = ""; // 鏄惁闇�瑕佹墜鍔ㄧ‘璁ょ幓鐠� @@ -48,6 +53,8 @@ public static Boolean FeedState = false; + public static StringBuilder feedglassid; + // public Plchome() throws IOException { // config = new Configuration("config.properties"); // } @@ -58,6 +65,7 @@ public void run() { while (this != null) { JSONObject jsonObject = new JSONObject(); + jsonObject.append("feedglassid", feedglassid); try { Thread.sleep(1000); // 娉ㄥ叆mapper @@ -188,7 +196,7 @@ GlassIdList.add(spianService.queGlassid("DB103.114", 14).toString()); jsonObject.append("GlassIdList", GlassIdList); - // 璇诲幓Plc杩涚墖杞︿笌鍑虹墖杞︿綅缃甒 + // 鑾峰彇Plc杩涚墖杞︿笌鍑虹墖杞︿綅缃� List<String> addressList = new ArrayList<String>(); addressList.add("DB106.12"); addressList.add("DB106.0"); @@ -196,24 +204,24 @@ if (paramlist != null) { jsonObject.append("params", paramlist); } - // 鑾峰彇杩涚墖杞︾姸鎬� - List<Short> datas1ListState = S7control.getinstance().ReadWord("DB106.8", - 1);// 鑾峰彇杩涚墖杞︾姸鎬� - if (datas1ListState != null) { - boolean exist1 = datas1ListState.contains((short) 0); - jsonObject.append("zhuangtai", exist1); - } + // // 鑾峰彇杩涚墖杞︾姸鎬� + // List<Short> datas1ListState = S7control.getinstance().ReadWord("DB106.8", + // 1);// 鑾峰彇杩涚墖杞︾姸鎬� + // if (datas1ListState != null) { + // boolean exist1 = datas1ListState.contains((short) 0); + // jsonObject.append("zhuangtai", exist1); + // } - // 鑾峰彇杩涚墖鐜荤拑淇℃伅 - List<Short> inglassInfo = S7control.getinstance().ReadWord("DB106.24", 1); - if (inglassInfo != null) { - if (inglassInfo.size() > 0) { - jsonObject.append("loadglassheight", inglassInfo.get(0) * 70); - } - } + // // 鑾峰彇杩涚墖鐜荤拑淇℃伅 + // List<Short> inglassInfo = S7control.getinstance().ReadWord("DB106.24", 1); + // if (inglassInfo != null) { + // if (inglassInfo.size() > 0) { + // jsonObject.append("loadglassheight", inglassInfo.get(0) * 70); + // } + // } // // 鑾峰彇閾濇idDB106.DBW64锛屾坊鍔犲埌鍑虹墖闃熷垪 // String frameno="X21763329601FB"; - String frameno = spianService.queGlassid("DB103.270", 14).toString(); + String frameno = spianService.queGlassid("DB103.270", 11).toString(); if (!frameno.equals(Plchome.FrameNo)) { Plchome.FrameNo = frameno; try { @@ -247,7 +255,7 @@ jsonObject.append("countdown", countdowns); } // jsonObject.append("countdown", true); - // 澶嶄綅瀹屾垚淇″彿ss + // 澶嶄綅瀹屾垚淇″彿 List<Boolean> resetss = S7control.getinstance().ReadBits("DB103.284", 1); for (Boolean reset : resetss) { jsonObject.append("reset", reset); @@ -268,49 +276,59 @@ boolean D01ResponseState = D01respnse.contains((short) 1); // jsonObject.append("D01RequestState", D01RequestState); // 鑷姩杩涚墖 - if ((form3.getglassheight() < 380 || form3.getglasswidth() < 390 || form3.getglassheight() > 1810 - || form3.getglasswidth() > 2760) - || (form3.getglassheight() < 390 || form3.getglasswidth() < 380 - || form3.getglassheight() > 2760 || form3.getglasswidth() > 1810)) { - - if (isConfirm == true && D01RequestState == true && D01ResponseState == false) { - storageCageService.InsertQueueGlassId((short) 1, form3); + if (isConfirm == true && form3.getglassId() != null && form3.getglassId() != "") { + double width = 0; + double height = 0; + if (form3.getglassheight() < form3.getglasswidth()) { + height = form3.getglassheight(); + width = form3.getglasswidth(); + } else { + height = form3.getglasswidth(); + width = form3.getglassheight(); + } + if (height < 380 || width < 380 || height > 1810 || width > 2760) { + FeedState = true; + jsonObject.append("FeedState", FeedState); + FeedState = false; + } else { + if (D01RequestState == true && D01ResponseState != true) { + storageCageService.InsertQueueGlassId((short) 1, form3); + } } } } + boolean dbconnected = false; + try { + dbserve.getConn(); + dbconnected = true; + } catch (Exception e) { + // TODO: handle exception + dbconnected = false; + } + jsonObject.append("dbconnected", dbconnected); + // jsonObject.append("params", new short[] { 30, 40, }); + ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("Home"); + if (sendwServer != null) { + for (WebSocketServer webserver : sendwServer) { + webserver.sendMessage(jsonObject.toString()); - } catch (InterruptedException e) { + if (webserver != null) { + + List<String> messages = webserver.getMessages(); + + if (!messages.isEmpty()) { + // // 灏嗘渶鍚庝竴涓秷鎭浆鎹负鏁存暟绫诲瀷鐨勫垪琛� + webserver.clearMessages(); + } + + } + + } + } + } catch (InterruptedException | SQLException e) { e.printStackTrace(); } - boolean dbconnected = false; - try { - dbserve.getConn(); - dbconnected = true; - } catch (Exception e) { - // TODO: handle exception - dbconnected = false; - } - jsonObject.append("dbconnected", dbconnected); - // jsonObject.append("params", new short[] { 30, 40, }); - ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("Home"); - if (sendwServer != null) { - for (WebSocketServer webserver : sendwServer) { - webserver.sendMessage(jsonObject.toString()); - - if (webserver != null) { - - List<String> messages = webserver.getMessages(); - - if (!messages.isEmpty()) { - // // 灏嗘渶鍚庝竴涓秷鎭浆鎹负鏁存暟绫诲瀷鐨勫垪琛� - webserver.clearMessages(); - } - - } - - } - } } } } -- Gitblit v1.8.0