From 678f43f99d4fe259c6ce3dabbc2563776c2a25f1 Mon Sep 17 00:00:00 2001 From: luxiaotao1123 <t1341870251@163.com> Date: 星期一, 28 十二月 2020 17:40:11 +0800 Subject: [PATCH] # --- src/main/java/com/zy/asrs/controller/ConsoleController.java | 3 + src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 5 +- src/main/java/com/zy/core/thread/MelsecCrnThread.java | 7 +++ src/main/java/com/zy/asrs/controller/CrnController.java | 2 src/main/resources/application.yml | 46 +++++++++++----------- 5 files changed, 35 insertions(+), 28 deletions(-) diff --git a/src/main/java/com/zy/asrs/controller/ConsoleController.java b/src/main/java/com/zy/asrs/controller/ConsoleController.java index 980903d..d9f8138 100644 --- a/src/main/java/com/zy/asrs/controller/ConsoleController.java +++ b/src/main/java/com/zy/asrs/controller/ConsoleController.java @@ -13,6 +13,7 @@ import com.zy.asrs.service.BasDevpService; import com.zy.asrs.service.WrkMastService; import com.zy.common.CodeRes; +import com.zy.core.CrnThread; import com.zy.core.Slave; import com.zy.core.cache.SlaveConnection; import com.zy.core.enums.CrnModeType; @@ -111,7 +112,7 @@ List<CrnLatestDataVo> vos = new ArrayList<>(); for (CrnSlave crn : slaveProperties.getCrn()) { // 鑾峰彇鍫嗗灈鏈轰俊鎭� - SiemensCrnThread crnThread = (SiemensCrnThread) SlaveConnection.get(SlaveType.Crn, crn.getId()); + CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crn.getId()); if (crnThread == null) { continue; } diff --git a/src/main/java/com/zy/asrs/controller/CrnController.java b/src/main/java/com/zy/asrs/controller/CrnController.java index 86d7e68..0c02526 100644 --- a/src/main/java/com/zy/asrs/controller/CrnController.java +++ b/src/main/java/com/zy/asrs/controller/CrnController.java @@ -128,7 +128,7 @@ vo.setForkOffset(crnProtocol.getForkPosType().desc); // 璐у弶浣嶇疆 vo.setXLocation(crnProtocol.getWalkPos() == 1?"鏄�":"鍚�"); // 璧拌瀹氫綅 vo.setYLocation(crnProtocol.getLiftPosType().equals(CrnLiftPosType.NONE)?"鍚�":"鏄�"); // 鍗囬檷瀹氫綅 - vo.setStop(crnProtocol.getCrnError1().controlStop||crnProtocol.getCrnError1().mainStop||crnProtocol.getCrnError1().remoteStop?"鏄�":"鍚�"); // 鎬ュ仠 +// vo.setStop(crnProtocol.getCrnError1().controlStop||crnProtocol.getCrnError1().mainStop||crnProtocol.getCrnError1().remoteStop?"鏄�":"鍚�"); // 鎬ュ仠 vo.setWarnCode(String.valueOf(crnProtocol.getAlarm1())); // 寮傚父鐮� } return R.ok().add(list); diff --git a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java index 1869f0d..3e53f03 100644 --- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java +++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java @@ -775,6 +775,7 @@ // 璁板綍鏂板紓甯� if (latest == null || (latest.getErrCode() != crnProtocol.getAlarm1().intValue())) { BasCrnError crnError = basCrnErrorMapper.selectById(crnProtocol.getAlarm1()); + String errName = crnError==null? String.valueOf(crnProtocol.getAlarm1()):crnError.getErrName(); BasErrLog basErrLog = new BasErrLog( null, // 缂栧彿 null, // 宸ヤ綔鍙� @@ -790,7 +791,7 @@ null, // 婧愬簱浣� null, // 鏉$爜 crnProtocol.getAlarm1().intValue(), // 寮傚父鐮� - crnError.getErrName(), // 寮傚父 + errName, // 寮傚父 1, // 寮傚父鎯呭喌 now, // 娣诲姞鏃堕棿 null, // 娣诲姞浜哄憳 @@ -799,7 +800,7 @@ "鏃犱换鍔″紓甯�" // 澶囨敞 ); if (!basErrLogService.insert(basErrLog)) { - log.error("鍫嗗灈鏈簆lc寮傚父璁板綍澶辫触 ===>> [id:{}] [error:{}]", crn.getId(), crnError.getErrName()); + log.error("鍫嗗灈鏈簆lc寮傚父璁板綍澶辫触 ===>> [id:{}] [error:{}]", crn.getId(), errName); } } // 鏃犲紓甯� diff --git a/src/main/java/com/zy/core/thread/MelsecCrnThread.java b/src/main/java/com/zy/core/thread/MelsecCrnThread.java index ca7d69a..88a03b7 100644 --- a/src/main/java/com/zy/core/thread/MelsecCrnThread.java +++ b/src/main/java/com/zy/core/thread/MelsecCrnThread.java @@ -96,7 +96,7 @@ } Thread.sleep(500); } catch (Exception e) { -// e.printStackTrace(); + e.printStackTrace(); } } @@ -145,6 +145,10 @@ } melsecMcNet.ConnectClose(); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + } return result; } @@ -198,6 +202,7 @@ BasCrnpService basCrnpService = SpringUtils.getBean(BasCrnpService.class); BasCrnp basCrnp = new BasCrnp(); basCrnp.setCrnNo(slave.getId()); + crnProtocol.setAlarm1((short) (crnProtocol.getAlarm1() + 1000)); if (!basCrnpService.updateById(crnProtocol.toSqlModel(basCrnp))){ log.error("鍫嗗灈鏈簆lc鏁版嵁搴撴洿鏂板け璐� ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 66ab06c..ee826a3 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -62,29 +62,29 @@ row: 1 bay: 0 lev: 1 - # 鍫嗗灈鏈�2 - crn[1]: - id: 2 - ip: 192.168.6.20 - port: 6000 - rack: 0 - slot: 0 - # 鍋忕Щ閲忥紝褰撳爢鍨涙満绔欑偣鍒楀彿=1鏃讹紝鍋忕Щ閲�=2 - offset: 2 - # 鍫嗗灈鏈哄叆搴撶珯鐐� - crnInStn[0]: - devpPlcId: ${wcs-slave.devp[1].id} - staNo: 107 - row: 4 - bay: 0 - lev: 1 - # 鍫嗗灈鏈哄嚭搴撶珯鐐� - crnOutStn[0]: - devpPlcId: ${wcs-slave.devp[1].id} - staNo: 101 - row: 3 - bay: 0 - lev: 1 + # 鍫嗗灈鏈�2 + crn[1]: + id: 2 + ip: 192.168.6.20 + port: 6000 + rack: 0 + slot: 0 + # 鍋忕Щ閲忥紝褰撳爢鍨涙満绔欑偣鍒楀彿=1鏃讹紝鍋忕Щ閲�=2 + offset: 2 + # 鍫嗗灈鏈哄叆搴撶珯鐐� + crnInStn[0]: + devpPlcId: ${wcs-slave.devp[1].id} + staNo: 107 + row: 4 + bay: 0 + lev: 1 + # 鍫嗗灈鏈哄嚭搴撶珯鐐� + crnOutStn[0]: + devpPlcId: ${wcs-slave.devp[1].id} + staNo: 101 + row: 3 + bay: 0 + lev: 1 # 杈撻�佺嚎 devp[0]: id: 1 -- Gitblit v1.9.1