From df835e2b2da1d8b33be2040595f9a641ca31eecf Mon Sep 17 00:00:00 2001 From: Junjie <540245094@qq.com> Date: 星期日, 24 十二月 2023 11:16:52 +0800 Subject: [PATCH] #提升机 --- src/main/java/com/zy/core/thread/LiftThread.java | 74 +++++++++++++++++++++++++++--------- 1 files changed, 55 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/zy/core/thread/LiftThread.java b/src/main/java/com/zy/core/thread/LiftThread.java index e2845c5..a130001 100644 --- a/src/main/java/com/zy/core/thread/LiftThread.java +++ b/src/main/java/com/zy/core/thread/LiftThread.java @@ -363,12 +363,41 @@ //鎬绘搴� int size = commands.size(); - //鍙栧嚭鍛戒护 - NyLiftCommand command = commands.get(commandStep); - if (!redisCommand.getLiftNo().equals(liftProtocol.getLiftNo())) { return false; } + + if (commandStep != 0) { + //鍒ゆ柇涓婁竴鏉℃寚浠ゆ槸鍚﹀仛瀹� + NyLiftCommand lastCommand = commands.get(commandStep - 1);//涓婁竴鏉℃寚浠� + if (!liftProtocol.getBusy() && liftProtocol.getTaskNo().equals(lastCommand.getTaskNo())) { + //鎻愬崌鏈虹┖闂层�佷笖鎻愬崌鏈哄伐浣滃彿涓庝笂涓�鏉℃寚浠ゅ伐浣滃彿鐩稿悓 + lastCommand.setComplete(true);//鏍囪浠诲姟瀹屾垚 + } + + //浠诲姟鏁版嵁淇濆瓨鍒皉edis + redisUtil.set(RedisKeyType.LIFT.key + redisCommand.getWrkNo(), JSON.toJSONString(redisCommand)); + + if (!lastCommand.getComplete()) { + //涓婁竴鏉′换鍔℃湭瀹屾垚锛岀姝笅鍙戝懡浠� + return false; + } + + //鍒ゆ柇鏄惁涓烘渶鍚庝竴鏉″懡浠や笖鍛戒护鎵ц瀹屾垚锛屾姏鍑虹瓑寰呯‘璁ょ姸鎬� + NyLiftCommand endCommand = commands.get(commands.size() - 1); + if (endCommand.getComplete()) { + //宸叉墽琛屽畬鎴� + //鍒犻櫎redis + redisUtil.del(RedisKeyType.LIFT.key + redisCommand.getWrkNo()); + + //瀵逛富绾跨▼鎶涘嚭绛夊緟纭鐘舵�亀aiting + liftProtocol.setProtocolStatus(LiftProtocolStatusType.WAITING); + News.info("鎻愬崌鏈轰换鍔℃墽琛屼笅鍙戝畬鎴愭墽琛岀粨鏉燂紝鎻愬崌鏈哄彿={}锛屼换鍔℃暟鎹�={}", redisCommand.getLiftNo(), JSON.toJSON(redisCommand)); + } + } + + //鍙栧嚭鍛戒护 + NyLiftCommand command = commands.get(commandStep); //涓嬪彂鍛戒护 if (!write(command)) { @@ -400,23 +429,30 @@ liftOptService.insert(opt); } - //鍒ゆ柇鏁版嵁鏄惁鎵ц瀹屾垚 - if (commandStep < size - 1) { - //鏇存柊redis鏁版嵁 - //姝ュ簭澧炲姞 - commandStep++; - redisCommand.setCommandStep(commandStep); - //浠诲姟鏁版嵁淇濆瓨鍒皉edis - redisUtil.set(RedisKeyType.LIFT.key + redisCommand.getWrkNo(), JSON.toJSONString(redisCommand)); - }else { - //宸叉墽琛屽畬鎴� - //鍒犻櫎redis - redisUtil.del(RedisKeyType.LIFT.key + redisCommand.getWrkNo()); + //鏇存柊redis鏁版嵁 + //姝ュ簭澧炲姞 + commandStep++; + redisCommand.setCommandStep(commandStep); + //浠诲姟鏁版嵁淇濆瓨鍒皉edis + redisUtil.set(RedisKeyType.LIFT.key + redisCommand.getWrkNo(), JSON.toJSONString(redisCommand)); - //瀵逛富绾跨▼鎶涘嚭绛夊緟纭鐘舵�亀aiting - liftProtocol.setProtocolStatus(LiftProtocolStatusType.WAITING); - News.info("鎻愬崌鏈轰换鍔℃墽琛屼笅鍙戝畬鎴愮瓑寰呮墽琛岀粨鏉燂紝鎻愬崌鏈哄彿={}锛屼换鍔℃暟鎹�={}", command.getLiftNo(), JSON.toJSON(command)); - } +// //鍒ゆ柇鏁版嵁鏄惁鎵ц瀹屾垚 +// if (commandStep < size - 1) { +// //鏇存柊redis鏁版嵁 +// //姝ュ簭澧炲姞 +// commandStep++; +// redisCommand.setCommandStep(commandStep); +// //浠诲姟鏁版嵁淇濆瓨鍒皉edis +// redisUtil.set(RedisKeyType.LIFT.key + redisCommand.getWrkNo(), JSON.toJSONString(redisCommand)); +// }else { +// //宸叉墽琛屽畬鎴� +// //鍒犻櫎redis +// redisUtil.del(RedisKeyType.LIFT.key + redisCommand.getWrkNo()); +// +// //瀵逛富绾跨▼鎶涘嚭绛夊緟纭鐘舵�亀aiting +// liftProtocol.setProtocolStatus(LiftProtocolStatusType.WAITING); +// News.info("鎻愬崌鏈轰换鍔℃墽琛屼笅鍙戝畬鎴愮瓑寰呮墽琛岀粨鏉燂紝鎻愬崌鏈哄彿={}锛屼换鍔℃暟鎹�={}", command.getLiftNo(), JSON.toJSON(command)); +// } if (redisCommand.getAssignCommand().getTaskMode() == NyLiftTaskModelType.RESET.id.shortValue()) { //澶嶄綅鍛戒护 -- Gitblit v1.9.1