3 changed files with 65 additions and 4 deletions
-
8src/main/java/com/iflytop/gd/app/core/CraftsContext.java
-
3src/main/java/com/iflytop/gd/app/service/CraftsService.java
-
58src/main/java/com/iflytop/gd/app/service/CraftsStepService.java
@ -0,0 +1,58 @@ |
|||||
|
package com.iflytop.gd.app.service; |
||||
|
|
||||
|
import cn.hutool.json.JSONObject; |
||||
|
import com.iflytop.gd.app.model.bo.CraftsStep; |
||||
|
import lombok.RequiredArgsConstructor; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
/** |
||||
|
* 工艺步骤 |
||||
|
*/ |
||||
|
@Service |
||||
|
@RequiredArgsConstructor |
||||
|
public class CraftsStepService { |
||||
|
|
||||
|
/** |
||||
|
* 执行单个工艺步骤 |
||||
|
*/ |
||||
|
public boolean executeStep(String heatId, CraftsStep step) throws InterruptedException { |
||||
|
String method = step.getMethod(); |
||||
|
JSONObject params = step.getParams(); |
||||
|
return switch (method) { |
||||
|
case "UP_TRAY" -> upTray(heatId); |
||||
|
case "DOWN_TRAY" -> downTray(heatId); |
||||
|
case "ADD_LIQUID" -> addLiquid(heatId, params); |
||||
|
case "DELAY" -> delay(params); |
||||
|
default -> false; |
||||
|
}; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 将托盘升起 |
||||
|
*/ |
||||
|
private boolean upTray(String heatId) { |
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 将托盘降下 |
||||
|
*/ |
||||
|
private boolean downTray(String heatId) { |
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 加液操作 |
||||
|
*/ |
||||
|
private boolean addLiquid(String heatId, JSONObject params) { |
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 等待指定秒数 |
||||
|
*/ |
||||
|
private boolean delay(JSONObject params) throws InterruptedException { |
||||
|
Thread.sleep(params.getInt("second") * 1000L); |
||||
|
return true; |
||||
|
} |
||||
|
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue