From b092806a662b99310cdb050292de2721ba06acd9 Mon Sep 17 00:00:00 2001 From: wu <731351411@qq.com> Date: 星期二, 19 十一月 2024 14:43:18 +0800 Subject: [PATCH] 增加测量台直通模式,增加手动参数界面的JSON文件 --- springboot-vue3/src/main/java/com/example/springboot/component/PlcHoldNew.java | 261 ++++++++++++++++++++++++++++------------------------ 1 files changed, 141 insertions(+), 120 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 b42984e..4b1844c 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,155 +1,176 @@ package com.example.springboot.component; -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.List; +import java.util.Date; + import org.springframework.beans.factory.annotation.Autowired; -import com.example.springboot.service.JdbcConnections; import com.example.springboot.service.SpianServiceNew; -import com.example.springboot.entity.north_glass_buffer1; +import com.example.springboot.service.StorageCageService; +import com.example.springboot.entity.GlassInfo; import com.example.springboot.entity.device.PlcParameterObject; -import com.example.springboot.mapper.AlarmMapper; import com.example.springboot.mapper.AlbaniaMapper; -import com.example.springboot.mapper.SpianMapper; public class PlcHoldNew extends Thread { - private AlarmMapper alarmMapper; - @Autowired - private JdbcConnections jdbcConnections; 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(100); + Thread.sleep(300); } catch (InterruptedException e) { - // \\ TODO Auto-generated catch block e.printStackTrace(); } - // if (S7control.getinstance().CheckConnected() == false) { + storageCageService = WebSocketServer.applicationContext.getBean(StorageCageService.class); spianService = WebSocketServer.applicationContext.getBean(SpianServiceNew.class); albaniaMapper = WebSocketServer.applicationContext.getBean(AlbaniaMapper.class); + // spianService.selectout(1); + // spianService.mateOut(); + // 璇诲彇DB14鍖烘枃浠� + PlcParameterObject plcmes = PLCAutoMes.PlcMesObject; + if (plcmes.getPlcParameter("PLCToMES").getValue() != null) { - //璇诲彇DB105鍖烘枃浠� - PlcParameterObject plcmes=PLCAutoMes.PlcMesObject; - //璇�106 - PlcParameterObject plcread=PLCAutoMes.PlcReadObject; - //璇�103 - - String OutRequest=plcread.getPlcParameter("OutRequest").getValue();//鍑虹墖璇锋眰涓�绾� - String OutActivate=plcmes.getPlcParameter("OutActivate").getValue();//鍑虹墖璇锋眰浜岀嚎 - String AddRequest=plcmes.getPlcParameter("AddRequest").getValue();//杩涚墖璇锋眰 - String CarRequest=plcmes.getPlcParameter("CatReque").getValue();//杩愰�佽溅璇锋眰 - String Tastoverid=plcmes.getPlcParameter("Tastoverid").getValue();//浠诲姟瀹屾垚 - String glassid=plcmes.getPlcParameter("glassid").getValue();//鐜荤拑id - - //璋冪敤鍑虹墖浠诲姟 - if (OutActivate.equals("1") == false&&CarRequest.equals("0")==true) { - //灏嗚繍杈撹溅鐘舵�佹敼涓哄繖纰� - S7control.getinstance().WriteWord(plcmes.getPlcParameter("B01report").getAddress(plcmes.getPlcParameter("B01report").getAddressIndex()), (short) 1); - spianService.selectout(glassid); - } - //璋冪敤杩涚墖浠诲姟 - if(AddRequest.equals("1")==true&&CarRequest.equals("0")==true){ - //灏嗚繍杈撹溅鐘舵�佹敼涓哄繖纰� - S7control.getinstance().WriteWord(plcmes.getPlcParameter("B01report").getAddress(plcmes.getPlcParameter("B01report").getAddressIndex()), (short) 1); + 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();// 鍙戦�佷换鍔″瓧 - spianService.selectAll(albaniaMapper.SelectGlass()); + 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") == true && MESToPLC.equals("0") == true && MESToPLCStatus1.equals("0") == true&&outtask == 0) { + try { + Thread.sleep(100); // 姣�100姣妫�鏌ヤ竴娆� + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); // 澶勭悊绾跨▼涓柇 + } + // System.out + // .println("杩涚墖鐘舵��:MESToPLC:" + MESToPLC + "PLCToMES:" + PLCToMES + "MESToPLCStatus1:" + MESToPLCStatus1); + 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"); + } + } - - - ///////////// 杩涚墖浠诲姟 - - // String B01backs = plcread.getPlcParameter("B01CompleteTheReport").getValue();// b01姹囨姤 - // String B02backs = plcread.getPlcParameter("B02CompleteTheReport").getValue();// b02姹囨姤 - - // String B01glassid = plcstate.getPlcParameter("B01ID1").getValue();// BO1鐨勭幓鐠僫d - // String B02glassid = plcstate.getPlcParameter("B02ID1").getValue();// B02鐨勭幓鐠僫d - - // // 褰撹繘鐗囧皬杞﹀畬鎴愪换鍔℃椂 - // if (B01backs.equals("1") == true) { - // // 鍒ゆ柇鏄惁姹囨姤姝g‘鐨刬d - // int HB = spianMapper.SelectHB(B01glassid.toString()); - // if (HB > 0) { - // // 鎭㈠B01灏忚溅搴旂瓟鏀逛负1 - // S7control.getinstance().WriteWord(plcmes.getPlcParameter("B01report").getAddress(plcmes.getPlcParameter("B01report").getAddressIndex()), (short) 1); - // String yingda =plcmes.getPlcParameter("B01report").getValue();// b01姹囨姤 - // if (yingda.equals("1")) { - // spianService.overtask(B01glassid.toString());// 瀹屾垚浠诲姟 - // } - // } - - // }else{ - // // 鎭㈠B01灏忚溅搴旂瓟鏀逛负0 - // S7control.getinstance().WriteWord(plcmes.getPlcParameter("B01report").getAddress(plcmes.getPlcParameter("B01report").getAddressIndex()), (short) 0); - // } - - // // 褰撳嚭鐗囧皬杞﹀畬鎴愪换鍔℃椂 - // if (B02backs.equals("1") == true) { - // // 鍒ゆ柇鏄惁姹囨姤姝g‘鐨刬d - // int HB = spianMapper.SelectHB(B02glassid); - // if (HB > 0) { - // // 鎭㈠B02灏忚溅搴旂瓟鏀逛负1 - // S7control.getinstance().WriteWord(plcmes.getPlcParameter("B02report").getAddress(plcmes.getPlcParameter("B02report").getAddressIndex()), (short) 1); - // String yingda =plcmes.getPlcParameter("B01report").getValue();// b02搴旂瓟 - // if (yingda.equals("1") == true) { - // spianService.overtask(B02glassid);// 瀹屾垚浠诲姟 - // } - // } - // }else{ - // S7control.getinstance().WriteWord(plcmes.getPlcParameter("B02report").getAddress(plcmes.getPlcParameter("B02report").getAddressIndex()), (short) 0); - // } - - - // // 鑾峰彇DO1鏁版嵁 - // String Do1ID=plcread.getPlcParameter("FeedID").getValue();// 鑾峰彇璇锋眰鐨刬d璺烡O1鍚屾椂娓� - // // 鑾峰彇DO2鏁版嵁 - // String Do2ID=plcread.getPlcParameter("FeedID").getValue();// 鑾峰彇璇锋眰鐨刬d璺烡O1鍚屾椂娓� - - - // int questate = spianMapper.Selectquecount(Do1ID.toString());// 鍒ゆ柇鎵爜浣嶆槸鍚︽湁鐜荤拑宸茬‘璁� - // // queueid1.toString().isEmpty() - // north_glass_buffer1 glass1 = spianMapper.selectGlass(Do1ID);// D01鐨勭幓鐠冧俊鎭� - // north_glass_buffer1 glass2 = spianMapper.selectGlass(Do2ID);// D02鐜荤拑淇℃伅 - // // 褰撴壂鐮佷綅鐜荤拑id涓虹┖鏃� 瀹藉害涓�0 - // if (Do1ID != null && questate == 0) { - // // 鍐欏叆D01鐨勬暟鎹埌涓婄墖闃熷垪琛� - // if (glass1 == null) { // 褰撴病鏈夊�兼椂浼犵┖ - // spianMapper.Updatequeue(null, null, null, null, 0, null, null, null, null, 1); - // } else { - // spianMapper.Updatequeue(Do1ID.toString(), glass1.getordernumber(), glass1.getlistnumber(), - // glass1.getboxnumber(), 0, glass1.getglasslengthmm().toString(), glass1.getglassheightmm().toString(), - // glass1.getglasslength().toString(), glass1.getglassheight().toString(), 1); - // } - - // } - - // if (Do2ID != null) { - // // 鍐欏叆D02鐨勬暟鎹埌涓婄墖闃熷垪琛� - // if (glass2 == null) { - // spianMapper.Updatequeue(null, null, null, null, 0, null, null, null, null, 2); - // } else { - // spianMapper.Updatequeue(Do2ID.toString(), glass2.getordernumber(), glass2.getlistnumber(), - // glass2.getboxnumber(), 0, glass2.getglasslengthmm().toString(), glass2.getglassheightmm().toString(), - // glass2.getglasslength().toString(), glass2.getglassheight().toString(), 2); - // spianMapper.overqueue2(Do2ID.toString(), 0, 1);// 鏇存敼鎵爜浣嶄换鍔¤〃鐨勭姸鎬佷负0 - // S7control.getinstance().WriteWord("DB105.16", (short) 0);// 鍏抽棴浠诲姟鍚姩 - // } - - // } // 鏌ヨ鏁版嵁搴� // 鎺ㄩ�佸埌鍓嶇 - // } } } -- Gitblit v1.8.0