diff --git a/src/main/java/com/qyft/gd/model/vo/CraftsStepResult.java b/src/main/java/com/qyft/gd/model/vo/CraftsStepResult.java index 2e311b6..3330eaf 100644 --- a/src/main/java/com/qyft/gd/model/vo/CraftsStepResult.java +++ b/src/main/java/com/qyft/gd/model/vo/CraftsStepResult.java @@ -16,8 +16,8 @@ public class CraftsStepResult { */ private Integer status; /** - * 当前工艺执行的方法 + * 当前工艺执行的方法数组下标 */ - private String method; + private Integer methodIndex; } diff --git a/src/main/java/com/qyft/gd/service/CraftsStepService.java b/src/main/java/com/qyft/gd/service/CraftsStepService.java index d2cf7b5..1810fb9 100644 --- a/src/main/java/com/qyft/gd/service/CraftsStepService.java +++ b/src/main/java/com/qyft/gd/service/CraftsStepService.java @@ -99,20 +99,21 @@ public class CraftsStepService { this.pushMsg(heatId, status, null); } - private void pushMsg(String heatId, Integer status, String method) { + + private void pushMsg(String heatId, Integer status, Integer methodNum) { CraftsStepResult craftsStepResult = new CraftsStepResult(); craftsStepResult.setHeatId(heatId); craftsStepResult.setStatus(status); - craftsStepResult.setMethod(method); + craftsStepResult.setMethodIndex(methodNum); webSocketService.pushMsg(WebSocketMessageType.CRAFTS, craftsStepResult); } class CraftsTask implements Runnable { - private static String currentMethod = null; + private static int currentMethodNum = 0; private final String heatId; - private final Long craftId; + private final long craftId; - public CraftsTask(Long craftId, String heatId) { + public CraftsTask(long craftId, String heatId) { this.heatId = heatId; this.craftId = craftId; } @@ -144,8 +145,8 @@ public class CraftsStepService { }; if (!result) { taskMap.remove(heatId); - log.info("执行工艺错误,加热区: {}, 当前执行步骤: {}", heatId, currentMethod); - pushMsg(heatId, CraftsStepStatus.ERROR); + log.info("执行工艺错误,加热区: {}, 当前执行步骤: {}", heatId, stepsJsonArray.get(currentMethodNum).toString()); + pushMsg(heatId, CraftsStepStatus.ERROR, currentMethodNum); return; } @@ -168,6 +169,7 @@ public class CraftsStepService { pushMsg(heatId, CraftsStepStatus.STOPPED); return; } + currentMethodNum++; } taskMap.remove(heatId); log.info("执行工艺完毕,加热区: {}", heatId); @@ -179,8 +181,7 @@ public class CraftsStepService { * 抬起托盘 */ private boolean upTray() { - currentMethod = CraftsStepMethod.UP_TRAY; - pushMsg(heatId, CraftsStepStatus.IN_PROGRESS, currentMethod); + pushMsg(heatId, CraftsStepStatus.IN_PROGRESS, currentMethodNum); try { Thread.sleep(2000); } catch (InterruptedException e) { @@ -194,8 +195,7 @@ public class CraftsStepService { * 降下托盘 */ private boolean downTray() { - currentMethod = CraftsStepMethod.DOWN_TRAY; - pushMsg(heatId, CraftsStepStatus.IN_PROGRESS, currentMethod); + pushMsg(heatId, CraftsStepStatus.IN_PROGRESS, currentMethodNum); try { Thread.sleep(2000); } catch (InterruptedException e) { @@ -209,8 +209,7 @@ public class CraftsStepService { * 添加溶液 */ private boolean addLiquid(JSONObject params) { - currentMethod = CraftsStepMethod.ADD_LIQUID; - pushMsg(heatId, CraftsStepStatus.IN_PROGRESS, currentMethod); + pushMsg(heatId, CraftsStepStatus.IN_PROGRESS, currentMethodNum); JSONArray tubeSolJSONArray = params.getJSONArray("tubeSolList"); List tubeSolList = JSONUtil.toList(tubeSolJSONArray.toString(), TubeSol.class); @@ -227,8 +226,7 @@ public class CraftsStepService { * 将指定加热区的托盘移至加液区 */ private boolean moveToSol() { - currentMethod = CraftsStepMethod.MOVE_TO_SOL; - pushMsg(heatId, CraftsStepStatus.IN_PROGRESS, currentMethod); + pushMsg(heatId, CraftsStepStatus.IN_PROGRESS, currentMethodNum); try { Thread.sleep(5000); @@ -243,8 +241,7 @@ public class CraftsStepService { * 移至加热 */ private boolean moveToHeat() { - currentMethod = CraftsStepMethod.MOVE_TO_HEAT; - pushMsg(heatId, CraftsStepStatus.IN_PROGRESS, currentMethod); + pushMsg(heatId, CraftsStepStatus.IN_PROGRESS, currentMethodNum); try { Thread.sleep(5000); @@ -259,8 +256,7 @@ public class CraftsStepService { * 摇匀 */ private boolean shaking(JSONObject params) { - currentMethod = CraftsStepMethod.SHAKING; - pushMsg(heatId, CraftsStepStatus.IN_PROGRESS, currentMethod); + pushMsg(heatId, CraftsStepStatus.IN_PROGRESS, currentMethodNum); Integer second = params.getInt("second"); try { @@ -276,8 +272,7 @@ public class CraftsStepService { * 开始加热 */ private boolean startHeating(JSONObject params) { - currentMethod = CraftsStepMethod.START_HEATING; - pushMsg(heatId, CraftsStepStatus.IN_PROGRESS, currentMethod); + pushMsg(heatId, CraftsStepStatus.IN_PROGRESS, currentMethodNum); Double temperature = params.getDouble("temperature"); try { @@ -293,8 +288,7 @@ public class CraftsStepService { * 停止加热 */ private boolean stopHeating() { - currentMethod = CraftsStepMethod.STOP_HEATING; - pushMsg(heatId, CraftsStepStatus.IN_PROGRESS, currentMethod); + pushMsg(heatId, CraftsStepStatus.IN_PROGRESS, currentMethodNum); try { Thread.sleep(1000); @@ -309,8 +303,7 @@ public class CraftsStepService { * 拍照 */ private boolean takePhoto() { - currentMethod = CraftsStepMethod.TAKE_PHOTO; - pushMsg(heatId, CraftsStepStatus.IN_PROGRESS, currentMethod); + pushMsg(heatId, CraftsStepStatus.IN_PROGRESS, currentMethodNum); try { Thread.sleep(1000); @@ -339,8 +332,7 @@ public class CraftsStepService { * 等待 */ private boolean delay(JSONObject params) { - currentMethod = CraftsStepMethod.DELAY; - pushMsg(heatId, CraftsStepStatus.IN_PROGRESS, currentMethod); + pushMsg(heatId, CraftsStepStatus.IN_PROGRESS, currentMethodNum); Integer second = params.getInt("second"); return deviceStepService.delay(second);