Browse Source

fix:工艺步骤执行反馈应当反馈工艺执行的数组下标而不是方法名称

master
白凤吉 5 months ago
parent
commit
f94b04aaf3
  1. 4
      src/main/java/com/qyft/gd/model/vo/CraftsStepResult.java
  2. 46
      src/main/java/com/qyft/gd/service/CraftsStepService.java

4
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;
}

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

Loading…
Cancel
Save