From 21545a7bbb30dae904ba9f914b32f3eabed5b951 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=87=A4=E5=90=89?= Date: Thu, 20 Feb 2025 11:20:35 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E5=B7=A5=E8=89=BA?= =?UTF-8?q?=E7=BB=93=E6=9D=9F=E6=B2=A1=E6=9C=89=E4=BB=8Etask=20map=20?= =?UTF-8?q?=E4=B8=ADremove=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/qyft/gd/service/CraftsStepService.java | 24 ++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/qyft/gd/service/CraftsStepService.java b/src/main/java/com/qyft/gd/service/CraftsStepService.java index 9a69544..05a400c 100644 --- a/src/main/java/com/qyft/gd/service/CraftsStepService.java +++ b/src/main/java/com/qyft/gd/service/CraftsStepService.java @@ -86,12 +86,13 @@ public class CraftsStepService { public void run() { currentStatus = CraftsStepStatus.IN_PROGRESS; Crafts crafts = craftsService.findCraftsById(craftId); - log.info("开始执行工艺,加热区 {},工艺 {}", heatId, crafts.getName()); + log.info("开始执行工艺,加热区: {}, 工艺: {}", heatId, crafts.getName()); String steps = crafts.getSteps(); JSONArray stepsJsonArray = JSONUtil.parseArray(steps); for (Object stepsJsonObject : stepsJsonArray) { if (!Thread.currentThread().isInterrupted()) { JSONObject stepsJson = (JSONObject) stepsJsonObject; + log.info("执行工艺步骤,加热区: {}, 执行步骤: {}", heatId, stepsJson.toString()); String method = stepsJson.get("method").toString(); JSONObject params = (JSONObject) stepsJson.get("params"); boolean result = switch (method) { @@ -108,15 +109,20 @@ public class CraftsStepService { default -> false; }; if (!result) { + taskMap.remove(heatId); + log.info("执行工艺错误,加热区: {}, 当前执行步骤: {}", heatId, currentMethod); pushMsg(heatId, CraftsStepStatus.ERROR); return; } - pushMsg(heatId, currentStatus, currentMethod); } else { + taskMap.remove(heatId); + log.info("停止执行工艺,加热区: {}", heatId); pushMsg(heatId, CraftsStepStatus.STOPPED); return; } } + taskMap.remove(heatId); + log.info("执行工艺完毕,加热区: {}", heatId); pushMsg(heatId, CraftsStepStatus.FINISH); } @@ -126,6 +132,7 @@ public class CraftsStepService { */ private boolean upTray() { currentMethod = CraftsStepMethod.UP_TRAY; + pushMsg(heatId, currentStatus, currentMethod); try { Thread.sleep(2000); } catch (InterruptedException e) { @@ -140,6 +147,7 @@ public class CraftsStepService { */ private boolean downTray() { currentMethod = CraftsStepMethod.DOWN_TRAY; + pushMsg(heatId, currentStatus, currentMethod); try { Thread.sleep(2000); } catch (InterruptedException e) { @@ -154,6 +162,7 @@ public class CraftsStepService { */ private boolean addLiquid(JSONObject params) { currentMethod = CraftsStepMethod.ADD_LIQUID; + pushMsg(heatId, currentStatus, currentMethod); JSONArray tubeSolJSONArray = params.getJSONArray("tubeSolList"); List tubeSolList = JSONUtil.toList(tubeSolJSONArray.toString(), TubeSol.class); @@ -171,6 +180,8 @@ public class CraftsStepService { */ private boolean moveToSol() { currentMethod = CraftsStepMethod.MOVE_TO_SOL; + pushMsg(heatId, currentStatus, currentMethod); + try { Thread.sleep(5000); } catch (InterruptedException e) { @@ -185,6 +196,8 @@ public class CraftsStepService { */ private boolean moveToHeater() { currentMethod = CraftsStepMethod.MOVE_TO_HEATER; + pushMsg(heatId, currentStatus, currentMethod); + try { Thread.sleep(5000); } catch (InterruptedException e) { @@ -199,6 +212,7 @@ public class CraftsStepService { */ private boolean shaking(JSONObject params) { currentMethod = CraftsStepMethod.SHAKING; + pushMsg(heatId, currentStatus, currentMethod); Integer second = params.getInt("second"); try { @@ -215,6 +229,7 @@ public class CraftsStepService { */ private boolean startHeating(JSONObject params) { currentMethod = CraftsStepMethod.START_HEATING; + pushMsg(heatId, currentStatus, currentMethod); Double temperature = params.getDouble("temperature"); try { @@ -231,6 +246,8 @@ public class CraftsStepService { */ private boolean stopHeating() { currentMethod = CraftsStepMethod.STOP_HEATING; + pushMsg(heatId, currentStatus, currentMethod); + try { Thread.sleep(1000); } catch (InterruptedException e) { @@ -245,6 +262,8 @@ public class CraftsStepService { */ private boolean takePhoto() { currentMethod = CraftsStepMethod.TAKE_PHOTO; + pushMsg(heatId, currentStatus, currentMethod); + try { Thread.sleep(1000); } catch (InterruptedException e) { @@ -273,6 +292,7 @@ public class CraftsStepService { */ private boolean delay(JSONObject params) { currentMethod = CraftsStepMethod.DELAY; + pushMsg(heatId, currentStatus, currentMethod); Integer second = params.getInt("second"); return deviceStepService.delay(second);