Browse Source

fix:修复工艺结束没有从task map 中remove的问题

master
白凤吉 6 months ago
parent
commit
21545a7bbb
  1. 24
      src/main/java/com/qyft/gd/service/CraftsStepService.java

24
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<TubeSol> 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);

Loading…
Cancel
Save