From 0df6e7bb33c9f6a18f026a500776b00cbf2ae62c Mon Sep 17 00:00:00 2001 From: Junjie <fallin.jie@qq.com> Date: 星期二, 24 十二月 2024 09:48:06 +0800 Subject: [PATCH] # --- src/main/java/com/zy/core/thread/NyShuttleThread.java | 97 +++++++++++++++++++++++++----------------------- 1 files changed, 50 insertions(+), 47 deletions(-) diff --git a/src/main/java/com/zy/core/thread/NyShuttleThread.java b/src/main/java/com/zy/core/thread/NyShuttleThread.java index 5fcce03..f7dc6fe 100644 --- a/src/main/java/com/zy/core/thread/NyShuttleThread.java +++ b/src/main/java/com/zy/core/thread/NyShuttleThread.java @@ -172,6 +172,8 @@ shuttleProtocol.setStatusSum(jsonObject.getObject("statusSum", NyShuttleProtocol.StatusSumClass.class)); //闈炶嚜鍔ㄧ姸鎬佹椂闂磋鏃� shuttleProtocol.setErrTime(jsonObject.getInteger("errTime")); + //鏈�杩戜竴娆″湪绾挎椂闂� + shuttleProtocol.setLastOnlineTime(System.currentTimeMillis()); //灏忚溅澶勪簬杩愯涓紝灏嗘爣璁扮疆涓篺alse if (shuttleProtocol.getFree() == 0) { @@ -187,56 +189,13 @@ basShuttle.setShuttleNo(slave.getId()); shuttleService.insert(basShuttle); } - //宸ヤ綔妯″紡 - basShuttle.setWorkingMode(shuttleProtocol.getWorkingMode()); - //杩愯鐘舵�� - basShuttle.setFree(shuttleProtocol.getFree()); - //褰撳墠閫熷害 - basShuttle.setSpeed(shuttleProtocol.getSpeed()); - //璐熻浇鐘舵�� - basShuttle.setLoadState(shuttleProtocol.getLoadState()); - //绠″埗鐘舵�� - basShuttle.setSuspendState(shuttleProtocol.getSuspendState()); - //椤跺崌浣嶇疆 - basShuttle.setLiftPosition(shuttleProtocol.getLiftPosition()); - //杩愯鏂瑰悜 - basShuttle.setRunDir(shuttleProtocol.getRunDir()); - //杩愯鏂瑰悜 - basShuttle.setRunDir2(shuttleProtocol.getRunDir2()); - //鍏呯數鐘舵�� - basShuttle.setChargState(shuttleProtocol.getChargState()); - //鐢垫睜鐢甸噺 - basShuttle.setPowerPercent(shuttleProtocol.getPowerPercent()); - //鏈�楂樼數鑺數鍘� - basShuttle.setMaxCellVoltage(shuttleProtocol.getMaxCellVoltage()); - //鐢垫睜鐢靛帇 - basShuttle.setVoltage(shuttleProtocol.getVoltage()); - //鍏呮斁鐢靛惊鐜鏁� - basShuttle.setChargeCycleTimes(shuttleProtocol.getChargeCycleTimes()); - //鍓╀綑鐢甸噺 - basShuttle.setSurplusQuantity(shuttleProtocol.getSurplusQuantity()); - //鎬荤數閲� - basShuttle.setCountQuantity(shuttleProtocol.getCountQuantity()); - //瀹為檯搴撲綅 - basShuttle.setPoint(JSONObject.toJSONString(shuttleProtocol.getPoint())); - //瀹為檯鍧愭爣 - basShuttle.setCoord(JSONObject.toJSONString(shuttleProtocol.getCoord())); - //浠诲姟鐩殑搴撲綅 - basShuttle.setTask(JSONObject.toJSONString(shuttleProtocol.getTask())); - //浠诲姟鐘舵�� - basShuttle.setTaskState(shuttleProtocol.getTaskState()); - //鏁呴殰鐘舵�� - basShuttle.setErrState(shuttleProtocol.getErrState()); - //鎬婚噷绋嬫暟 - basShuttle.setStatusSum(JSONObject.toJSONString(shuttleProtocol.getStatusSum())); - //闈炶嚜鍔ㄧ姸鎬佹椂闂磋鏃� - basShuttle.setErrTime(shuttleProtocol.getErrTime()); //浠诲姟鍙� basShuttle.setWrkNo(shuttleProtocol.getTaskNo().intValue()); //淇敼鏃堕棿 basShuttle.setUpdateTime(new Date()); //浣滀笟鏍囪 basShuttle.setPakMk(shuttleProtocol.getPakMk()); + basShuttle.setDeviceStatus(JSON.toJSONString(basShuttle)); if (shuttleService.updateById(basShuttle)) { OutputQueue.SHUTTLE.offer(MessageFormat.format("銆恵0}銆慬id:{1}] <<<<< 瀹炴椂鏁版嵁鏇存柊鎴愬姛",DateUtils.convert(new Date()), slave.getId())); // log.info(MessageFormat.format("銆恵0}銆慬id:{1}] <<<<< 瀹炴椂鏁版嵁鏇存柊鎴愬姛",DateUtils.convert(new Date()), slave.getId())); @@ -435,7 +394,7 @@ if (!(targetNode.getX() == node.getX() && targetNode.getY() == node.getY())) { nodes.remove(nodes.size() - 1);//鍓旈櫎灏捐妭鐐� } - boolean result = navigateMapUtils.writeNavigateNodeToRedisMap(Utils.getLev(shuttleProtocol.getCurrentLocNo()), nodes, false);//瑙i攣璺緞 + boolean result = navigateMapUtils.writeNavigateNodeToRedisMap(Utils.getLev(shuttleProtocol.getCurrentLocNo()), shuttleProtocol.getShuttleNo().intValue(), nodes, false);//瑙i攣璺緞 if (!result) { return false;//瑙i攣澶辫触 } @@ -800,7 +759,7 @@ } } } - }else {//璺戝簱浣� + } else if (shuttleProtocol.getMoveType() == 1) {//璺戝簱浣� Integer xCurrent = shuttleProtocol.getXCurrent(); if (xCurrent > shuttleProtocol.getXTarget()) {//褰揦鍊煎ぇ浜嶺鐩爣鍊硷紝杩涜褰掗浂涓擸鏂瑰悜+1 shuttleProtocol.setXCurrent(shuttleProtocol.getXStart()); @@ -824,12 +783,56 @@ //璋冨害鍘荤洰鏍囦綅缃� if (shuttleProtocol.getCurrentLocNo().equals(target.getLocNo())) { shuttleProtocol.setXCurrent(shuttleProtocol.getXCurrent() + 1);//灏忚溅鍜岀洰鏍囦綅缃竴鑷达紝璺宠繃 - }else { + } else { boolean result = shuttleDispatchUtils.dispatchShuttle(commonService.getWorkNo(3), target.getLocNo()); if (result) {//璋冨害鎴愬姛 shuttleProtocol.setXCurrent(shuttleProtocol.getXCurrent() + 1); } } + } else if (shuttleProtocol.getMoveType() == 2) {//姣嶈建閬撳惊鐜窇 + Integer xCurrent = shuttleProtocol.getXCurrent(); + Integer yCurrent = shuttleProtocol.getYCurrent(); + + String locNo = Utils.getLocNo(xCurrent, yCurrent, lev); + //璋冨害鍘荤洰鏍囦綅缃� + if (shuttleProtocol.getCurrentLocNo().equals(locNo)) { + if (yCurrent.equals(shuttleProtocol.getYStart())) { + shuttleProtocol.setYCurrent(shuttleProtocol.getYTarget());//灏忚溅鍜岀洰鏍囦綅缃竴鑷达紝鍒囨崲搴撲綅 + }else { + shuttleProtocol.setYCurrent(shuttleProtocol.getYStart());//灏忚溅鍜岀洰鏍囦綅缃竴鑷达紝鍒囨崲搴撲綅 + } + } else { + boolean result = shuttleDispatchUtils.dispatchShuttle(commonService.getWorkNo(3), locNo); + if (result) {//璋冨害鎴愬姛 + if (yCurrent.equals(shuttleProtocol.getYStart())) { + shuttleProtocol.setYCurrent(shuttleProtocol.getYTarget());//鍒囨崲搴撲綅 + }else { + shuttleProtocol.setYCurrent(shuttleProtocol.getYStart());//鍒囨崲搴撲綅 + } + } + } + } else if (shuttleProtocol.getMoveType() == 3) {//瀛愯建閬撳惊鐜窇 + Integer xCurrent = shuttleProtocol.getXCurrent(); + Integer yCurrent = shuttleProtocol.getYCurrent(); + + String locNo = Utils.getLocNo(xCurrent, yCurrent, lev); + //璋冨害鍘荤洰鏍囦綅缃� + if (shuttleProtocol.getCurrentLocNo().equals(locNo)) { + if (xCurrent.equals(shuttleProtocol.getXStart())) { + shuttleProtocol.setXCurrent(shuttleProtocol.getXTarget());//灏忚溅鍜岀洰鏍囦綅缃竴鑷达紝鍒囨崲搴撲綅 + }else { + shuttleProtocol.setXCurrent(shuttleProtocol.getXStart());//灏忚溅鍜岀洰鏍囦綅缃竴鑷达紝鍒囨崲搴撲綅 + } + } else { + boolean result = shuttleDispatchUtils.dispatchShuttle(commonService.getWorkNo(3), locNo); + if (result) {//璋冨害鎴愬姛 + if (xCurrent.equals(shuttleProtocol.getXStart())) { + shuttleProtocol.setXCurrent(shuttleProtocol.getXTarget());//鍒囨崲搴撲綅 + }else { + shuttleProtocol.setXCurrent(shuttleProtocol.getXStart());//鍒囨崲搴撲綅 + } + } + } } } -- Gitblit v1.9.1