From 28ded8102d83cf74bc232d1cdfc89b7f22c41952 Mon Sep 17 00:00:00 2001 From: wu <731351411@qq.com> Date: 星期二, 03 十二月 2024 09:09:31 +0800 Subject: [PATCH] 增加点击防抖事件 增加笼子使用详情的计算优化。 增加数据推送时的报错处理 测量台交互逻辑增加 参数界面增加翻转加减速度 --- springboot-vue3/src/main/java/com/example/springboot/component/PlcHoldNew.java | 210 ++++++++++++++++++++++++++++++++++------------------ 1 files changed, 137 insertions(+), 73 deletions(-) diff --git a/springboot-vue3/src/main/java/com/example/springboot/component/PlcHoldNew.java b/springboot-vue3/src/main/java/com/example/springboot/component/PlcHoldNew.java index 49863c4..8a11960 100644 --- a/springboot-vue3/src/main/java/com/example/springboot/component/PlcHoldNew.java +++ b/springboot-vue3/src/main/java/com/example/springboot/component/PlcHoldNew.java @@ -1,4 +1,7 @@ package com.example.springboot.component; + +import java.util.Date; + import org.springframework.beans.factory.annotation.Autowired; import com.example.springboot.service.SpianServiceNew; import com.example.springboot.service.StorageCageService; @@ -6,106 +9,167 @@ import com.example.springboot.entity.device.PlcParameterObject; import com.example.springboot.mapper.AlbaniaMapper; - public class PlcHoldNew extends Thread { - - @Autowired private AlbaniaMapper albaniaMapper; private SpianServiceNew spianService; private StorageCageService storageCageService; int aaa; - + String huibao = ""; + String qidong = ""; @Override public void run() { while (this != null) { try { - Thread.sleep(500); + Thread.sleep(300); } catch (InterruptedException e) { e.printStackTrace(); } - - storageCageService = WebSocketServer.applicationContext.getBean(StorageCageService.class); spianService = WebSocketServer.applicationContext.getBean(SpianServiceNew.class); albaniaMapper = WebSocketServer.applicationContext.getBean(AlbaniaMapper.class); - - //璇诲彇DB14鍖烘枃浠� - PlcParameterObject plcmes=PLCAutoMes.PlcMesObject; - if(plcmes.getPlcParameter("PLCToMES").getValue()!=null){ - - //spianService.Mestast("NG0001-1",1,4,1,"MESID1",1); + + // spianService.selectout(1); + // spianService.mateOut(); + // 璇诲彇DB14鍖烘枃浠� + PlcParameterObject plcmes = PLCAutoMes.PlcMesObject; + if (plcmes.getPlcParameter("PLCToMES").getValue() != null) { - - - String ExportTOMES1=plcmes.getPlcParameter("ExportTOMES1").getValue();//鍑虹墖璇锋眰涓�绾� - String ExportToMES2=plcmes.getPlcParameter("ExportToMES2").getValue();//鍑虹墖璇锋眰浜岀嚎 - String PLCToMES=plcmes.getPlcParameter("PLCToMES").getValue();//杩愰�佽溅璇锋眰 - String IDStatus1=plcmes.getPlcParameter("IDStatus1").getValue();//1鍙蜂换鍔″畬鎴� - String MESToPLCStatus1=plcmes.getPlcParameter("MESToPLCStatus1").getValue();//1鍙风‘璁ゅ瓧 - String MESToPLC=plcmes.getPlcParameter("MESToPLC").getValue();//鍙戦�佷换鍔″瓧 - - //涓�鍙风嚎璇锋眰 - if(ExportTOMES1!=null&&MESToPLC!=null){ - if (ExportTOMES1.equals("1") == true&&MESToPLC.equals("0")==true) { - spianService.selectout(1); - } - } - // //浜岀嚎鍙疯姹傛椂 - if(ExportToMES2!=null &&MESToPLC!=null){ - if (ExportToMES2.equals("1") == true&&MESToPLC.equals("0")==true) { - spianService.selectout(2); - } - } - //杩涚墖璇锋眰鏃� - GlassInfo glass=albaniaMapper.SelectGlass(); - if(PLCToMES!=null && glass!=null&&MESToPLC!=null){ - if(PLCToMES.equals("1")==true&&MESToPLC.equals("0")==true){ - spianService.selectAll(glass); - } - } - - - //浠诲姟瀹屾垚鏃� - if(IDStatus1.equals("1")==true && MESToPLCStatus1.equals("0")==true){ - //瀹屾垚纭瀛� - for(int i=1;i<7;i++){ - - String Tastover=plcmes.getPlcParameter("IDStatus"+i).getValue();//PLC鐞嗙墖浠诲姟鐘舵�佹眹鎶� - String Glassid=plcmes.getPlcParameter("MESID"+i).getValueString();//MES鐜荤拑ID - GlassInfo id=albaniaMapper.SelectTaskId(Glassid); - if(id!=null&&Tastover.equals("1")){ - //璋冪敤瀹屾垚浠诲姟 Glassid - storageCageService.FinishTask(id.getId()); - } - S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToPLCStatus"+i).getAddress(), (short) 1);//瀹屾垚纭瀛� - } - S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToPLC").getAddress(), (short) 0);//娓呴櫎浠诲姟鍙戦�佸瓧 - } - + String ExportTOMES1 = plcmes.getPlcParameter("ExportTOMES1").getValue();// 鍑虹墖璇锋眰涓�绾� + String PLCToMES = plcmes.getPlcParameter("PLCToMES").getValue();// 杩愰�佽溅璇锋眰 + String IDStatus1 = plcmes.getPlcParameter("IDStatus1").getValue();// 1鍙蜂换鍔″畬鎴� + String MESToPLCStatus1 = plcmes.getPlcParameter("MESToPLCStatus1").getValue();// 1鍙风‘璁ゅ瓧 + String MESToPLC = plcmes.getPlcParameter("MESToPLC").getValue();// 鍙戦�佷换鍔″瓧 + String GaToMES = plcmes.getPlcParameter("GaToMES").getValue();// 娴嬮噺鎴愬姛淇″彿 - - //姹囨姤鍙栨秷鏃� - if(IDStatus1.equals("0")==true &&MESToPLCStatus1.equals("1")){ - - //鍙栨秷纭瀛� - for(int i=1;i<7;i++){ - String Tastover=plcmes.getPlcParameter("IDStatus"+i).getValue();//渚濇鑾峰彇浠诲姟姹囨姤 - if(Tastover.equals("0")){ - S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToPLCStatus"+i).getAddress(), (short) 0);//娓呴櫎纭瀛� + int taskcont = albaniaMapper.SelectTaskcount(); // 姝e湪杩涜鐨勪换鍔℃暟閲� + int outtask = albaniaMapper.SelectOutTaskCount(); // 绛夊緟琛ュ彂鐨勫嚭鐗囦换鍔℃暟閲� + if (ExportTOMES1 != null && MESToPLC != null && taskcont == 0) { + //褰撳彲浠ュ彂浠诲姟骞朵笖鍑虹墖闃熷垪鏈変换鍔℃椂 + if (ExportTOMES1.equals("1") == true && MESToPLC.equals("0") == true && PLCToMES.equals("1") == true&&outtask>0 && MESToPLCStatus1.equals("0")) { + spianService.mateOut(); } } + + // String scan=plcmes.getPlcParameter("scan").getValue();//鍙戦�佹壂鐮佷俊鎭� + // if(scan.equals("1")==true){ + // spianService.scan(scan); + // } + // 鑾峰彇褰撳墠鏃堕棿 + String currentTime = new Date().toString(); + if (!huibao.equals(IDStatus1)) { + System.out.println("姹囨姤璁板綍:" + IDStatus1 + "鏃堕棿" + currentTime); + } + huibao = IDStatus1; + if (!qidong.equals(MESToPLC)) { + System.out.println("鍚姩璁板綍:" + MESToPLC + "鏃堕棿" + currentTime); + } + qidong = MESToPLC; + + PLCToMES = plcmes.getPlcParameter("PLCToMES").getValue();// 杩愰�佽溅璇锋眰 + IDStatus1 = plcmes.getPlcParameter("IDStatus1").getValue();// 1鍙蜂换鍔″畬鎴� + MESToPLCStatus1 = plcmes.getPlcParameter("MESToPLCStatus1").getValue();// 1鍙风‘璁ゅ瓧 + MESToPLC = plcmes.getPlcParameter("MESToPLC").getValue();// 鍙戦�佷换鍔″瓧 + + // 涓�鍙风嚎璇锋眰 + if (ExportTOMES1 != null && MESToPLC != null && taskcont == 0) { + if (ExportTOMES1.equals("1") == true && MESToPLC.equals("0") == true && PLCToMES.equals("1") == true + && MESToPLCStatus1.equals("0") == true&&outtask == 0) { + // System.out + // .println("鍑虹墖鐘舵��:MESToPLC:" + MESToPLC + "PLCToMES:" + PLCToMES + "MESToPLCStatus1:" + MESToPLCStatus1); + spianService.selectout(1); + try { + Thread.sleep(100); // 姣�100姣妫�鏌ヤ竴娆� + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); // 澶勭悊绾跨▼涓柇 + } + } + } + + PLCToMES = plcmes.getPlcParameter("PLCToMES").getValue();// 杩愰�佽溅璇锋眰 + IDStatus1 = plcmes.getPlcParameter("IDStatus1").getValue();// 1鍙蜂换鍔″畬鎴� + MESToPLCStatus1 = plcmes.getPlcParameter("MESToPLCStatus1").getValue();// 1鍙风‘璁ゅ瓧 + MESToPLC = plcmes.getPlcParameter("MESToPLC").getValue();// 鍙戦�佷换鍔″瓧 + // 杩愰�佽溅璇锋眰鍜屾祴閲忓畬鎴愯姹� + GlassInfo glass = albaniaMapper.SelectGlass(); + if (PLCToMES != null && glass != null && MESToPLC != null) { + if (PLCToMES.equals("1")&& MESToPLC.equals("0")&&("1".equals(GaToMES)||"2".equals(GaToMES))&& taskcont == 0) { + try { + Thread.sleep(100); // 姣�100姣妫�鏌ヤ竴娆� + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); // 澶勭悊绾跨▼涓柇 + } + spianService.selectAll(glass); + } + } + + // 浠诲姟瀹屾垚鏃� + if ((IDStatus1.equals("1") && MESToPLCStatus1.equals("0")) || + (IDStatus1.equals("4") && MESToPLCStatus1.equals("0"))) { + // 瀹屾垚纭瀛� + for (int i = 1; i < 7; i++) { + String Tastover = plcmes.getPlcParameter("IDStatus" + i).getValue();// PLC鐞嗙墖浠诲姟鐘舵�佹眹鎶� + String Glassid = plcmes.getPlcParameter("MESID" + i).getValueString();// MES鐜荤拑ID + GlassInfo id = albaniaMapper.SelectTaskId(Glassid); + if (Tastover.equals("1")) { + // 璋冪敤瀹屾垚浠诲姟 Glassid + storageCageService.FinishTask(); + System.out.println("瀹屾垚浠诲姟ID:" + id); + } else if (Tastover.equals("4")) { + storageCageService.FinishTask(); + System.out.println("瀹屾垚澶辫触浠诲姟ID:" + id); + } + S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToPLCStatus" + i).getAddress(), (short) 1);// 瀹屾垚纭瀛� + } + System.out.println("瀹屾垚纭瀛桵ESToPLCStatus"); + // 娓呴櫎浠诲姟鍦板潃 + for (int i = 1; i < 7; i++) { + S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToPLCStart" + i).getAddress(), (short) 0);// 娓呴櫎浠诲姟鍦板潃 + S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToPLCTarget" + i).getAddress(), (short) 0);// 娓呴櫎浠诲姟鍦板潃 + } + System.out.println("娓呴櫎浠诲姟鍦板潃"); + while (true) { + String currentValue = plcmes.getPlcParameter("MESToPLC").getValue(); + // 妫�鏌� MESToPLC 鐨勫�兼槸鍚︿负 0 + if (currentValue.equals("0")) { + System.out.println("MESToPLC 宸插彉涓� 0,鍋滄寰幆鍐欏叆"); + break; // 閫�鍑哄惊鐜� + } + // 濡傛灉涓嶄负 0锛岀户缁啓鍏� + S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToPLC").getAddress(), + (short) 0);// 娓呴櫎浠诲姟鍙戦�佸瓧 + System.out.println("缁х画鍐欏叆 MESToPLC,褰撳墠鍊�:" + currentValue); + // 鍔犱笂寤舵椂锛岄伩鍏嶅崰鐢ㄨ繃澶� CPU 璧勬簮 + try { + Thread.sleep(100); // 渚嬪姣忕妫�鏌ヤ竴娆� + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + } + + // 姹囨姤鍙栨秷鏃� + if ((IDStatus1.equals("0")) && MESToPLCStatus1.equals("1")) { + // 鍙栨秷纭瀛� + for (int i = 1; i < 7; i++) { + String Tastover = plcmes.getPlcParameter("IDStatus" + i).getValue();// 渚濇鑾峰彇浠诲姟姹囨姤 + if (Tastover.equals("0")) { + S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToPLCStatus" + i).getAddress(), (short) 0);// 娓呴櫎纭瀛� + + } + } + System.out.println("娓呴櫎纭瀛桵ESToPLCStatus"); + } + } - - } - + // 鏌ヨ鏁版嵁搴� // 鎺ㄩ�佸埌鍓嶇 - } } -- Gitblit v1.8.0