|
|
@ -15,7 +15,6 @@ import com.yvan.logisticsModel.ExecutorItem; |
|
|
import com.yvan.logisticsModel.LogisticsRuntime; |
|
|
import com.yvan.logisticsModel.LogisticsRuntime; |
|
|
import com.yvan.logisticsModel.LogisticsRuntimeService; |
|
|
import com.yvan.logisticsModel.LogisticsRuntimeService; |
|
|
import com.yvan.logisticsModel.StaticItem; |
|
|
import com.yvan.logisticsModel.StaticItem; |
|
|
import com.yvan.workbench.model.entity.Model; |
|
|
|
|
|
import org.clever.core.Conv; |
|
|
import org.clever.core.Conv; |
|
|
import org.clever.core.id.SnowFlake; |
|
|
import org.clever.core.id.SnowFlake; |
|
|
import org.clever.core.model.response.R; |
|
|
import org.clever.core.model.response.R; |
|
|
@ -39,25 +38,39 @@ public class RcsController { |
|
|
|
|
|
|
|
|
RCSService.projectStart(projectUuid, envId); |
|
|
RCSService.projectStart(projectUuid, envId); |
|
|
return R.success("Project started successfully"); |
|
|
return R.success("Project started successfully"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static R<?> projectStop(@RequestBody Map<String, Object> params) { |
|
|
|
|
|
String projectUuid = Conv.asString(params.get("projectUUID")); |
|
|
|
|
|
Long envId = Conv.asLong(params.get("envId")); |
|
|
|
|
|
|
|
|
|
|
|
if (Strings.isNullOrEmpty(projectUuid)) { |
|
|
|
|
|
return R.fail("projectUUID Must not be empty"); |
|
|
|
|
|
} |
|
|
|
|
|
if (envId == null || envId < 0) { |
|
|
|
|
|
return R.fail("envId Must not be empty"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
RCSService.projectStop(projectUuid, envId); |
|
|
|
|
|
return R.success("Project stopped successfully"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static Model<?> agvToCharger(@RequestBody Map<String, Object> params) { |
|
|
public static R<?> agvToCharger(@RequestBody Map<String, Object> params) { |
|
|
Object ret = getCommonParamAndCreateBizTask(params); |
|
|
Object ret = getCommonParamAndCreateBizTask(params); |
|
|
if (ret instanceof Model) { |
|
|
if (ret instanceof R) { |
|
|
// 异常
|
|
|
// 异常
|
|
|
return (Model<Object>) ret; |
|
|
return (R<Object>) ret; |
|
|
} |
|
|
} |
|
|
RcsCommonParam ps = (RcsCommonParam) ret; |
|
|
RcsCommonParam ps = (RcsCommonParam) ret; |
|
|
|
|
|
|
|
|
String chargerId = Conv.asString(params.get("chargerId")); |
|
|
String chargerId = Conv.asString(params.get("chargerId")); |
|
|
if (Strings.isNullOrEmpty(chargerId)) { |
|
|
if (Strings.isNullOrEmpty(chargerId)) { |
|
|
return Model.newFail("chargerId Must not be empty"); |
|
|
return R.fail("chargerId Must not be empty"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
StaticItem toItem = ps.runtime.getStaticItemById(chargerId); |
|
|
StaticItem toItem = ps.runtime.getStaticItemById(chargerId); |
|
|
if (toItem == null) { |
|
|
if (toItem == null) { |
|
|
return Model.newFail("target wayPoint not found!"); |
|
|
return R.fail("target wayPoint not found!"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
ps.bizTask.setTaskTo(chargerId); |
|
|
ps.bizTask.setTaskTo(chargerId); |
|
|
@ -73,20 +86,20 @@ public class RcsController { |
|
|
ps.agv.logicY = ps.fromItem.logicY; |
|
|
ps.agv.logicY = ps.fromItem.logicY; |
|
|
ps.agv.dispatchTask(ps.planSequence); |
|
|
ps.agv.dispatchTask(ps.planSequence); |
|
|
|
|
|
|
|
|
return Model.newSuccess(ps.planSequence.toPrettyMap()); |
|
|
return R.success(ps.planSequence.toPrettyMap()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static Model<Object> agvMove(@RequestBody Map<String, Object> params) { |
|
|
public static R<?> agvMove(@RequestBody Map<String, Object> params) { |
|
|
Object ret = getCommonParamAndCreateBizTask(params); |
|
|
Object ret = getCommonParamAndCreateBizTask(params); |
|
|
if (ret instanceof Model) { |
|
|
if (ret instanceof R) { |
|
|
// 异常
|
|
|
// 异常
|
|
|
return (Model<Object>) ret; |
|
|
return (R<?>) ret; |
|
|
} |
|
|
} |
|
|
RcsCommonParam ps = (RcsCommonParam) ret; |
|
|
RcsCommonParam ps = (RcsCommonParam) ret; |
|
|
|
|
|
|
|
|
String targetWayPointId = Conv.asString(params.get("targetWayPointId")); |
|
|
String targetWayPointId = Conv.asString(params.get("targetWayPointId")); |
|
|
if (Strings.isNullOrEmpty(targetWayPointId)) { |
|
|
if (Strings.isNullOrEmpty(targetWayPointId)) { |
|
|
return Model.newFail("targetWayPointId Must not be empty"); |
|
|
return R.fail("targetWayPointId Must not be empty"); |
|
|
} |
|
|
} |
|
|
String targetDirection = Conv.asString(params.get("targetDirection")); |
|
|
String targetDirection = Conv.asString(params.get("targetDirection")); |
|
|
if (Strings.isNullOrEmpty(targetDirection)) { |
|
|
if (Strings.isNullOrEmpty(targetDirection)) { |
|
|
@ -95,7 +108,7 @@ public class RcsController { |
|
|
|
|
|
|
|
|
StaticItem toItem = ps.runtime.getStaticItemById(targetWayPointId); |
|
|
StaticItem toItem = ps.runtime.getStaticItemById(targetWayPointId); |
|
|
if (toItem == null) { |
|
|
if (toItem == null) { |
|
|
return Model.newFail("target wayPoint not found!"); |
|
|
return R.fail("target wayPoint not found!"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
ps.bizTask.setTaskTo(targetWayPointId); |
|
|
ps.bizTask.setTaskTo(targetWayPointId); |
|
|
@ -111,42 +124,42 @@ public class RcsController { |
|
|
ps.agv.logicY = ps.fromItem.logicY; |
|
|
ps.agv.logicY = ps.fromItem.logicY; |
|
|
ps.agv.dispatchTask(ps.planSequence); |
|
|
ps.agv.dispatchTask(ps.planSequence); |
|
|
|
|
|
|
|
|
return Model.newSuccess(ps.planSequence.toPrettyMap()); |
|
|
return R.success(ps.planSequence.toPrettyMap()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static Model<Object> agvInfo(@RequestBody Map<String, Object> params) { |
|
|
public static R<Object> agvInfo(@RequestBody Map<String, Object> params) { |
|
|
String projectUUID = Conv.asString(params.get("projectUUID")); |
|
|
String projectUUID = Conv.asString(params.get("projectUUID")); |
|
|
Long envId = Conv.asLong(params.get("envId")); |
|
|
Long envId = Conv.asLong(params.get("envId")); |
|
|
String agvId = Conv.asString(params.get("agvId")); |
|
|
String agvId = Conv.asString(params.get("agvId")); |
|
|
|
|
|
|
|
|
if (Strings.isNullOrEmpty(agvId)) { |
|
|
if (Strings.isNullOrEmpty(agvId)) { |
|
|
return Model.newFail("agvId Must not be empty"); |
|
|
return R.fail("agvId Must not be empty"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
LogisticsRuntime logisticsRuntime = LogisticsRuntimeService.INSTANCE.getByProjectEnv(projectUUID, envId); |
|
|
LogisticsRuntime logisticsRuntime = LogisticsRuntimeService.INSTANCE.getByProjectEnv(projectUUID, envId); |
|
|
|
|
|
|
|
|
ExecutorItem executorItem = logisticsRuntime.executorItemMap.get(agvId); |
|
|
ExecutorItem executorItem = logisticsRuntime.executorItemMap.get(agvId); |
|
|
if (executorItem == null) { |
|
|
if (executorItem == null) { |
|
|
return Model.newFail("executor not found: " + agvId); |
|
|
return R.fail("executor not found: " + agvId); |
|
|
} |
|
|
} |
|
|
if (!(executorItem instanceof PtrAgvItem)) { |
|
|
if (!(executorItem instanceof PtrAgvItem)) { |
|
|
return Model.newFail("executor is not a PtrAgvItem id=" + agvId); |
|
|
return R.fail("executor is not a PtrAgvItem id=" + agvId); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return Model.newSuccess(executorItem); |
|
|
return R.success(executorItem); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static Model<Object> agvUnload(@RequestBody Map<String, Object> params) { |
|
|
public static R<Object> agvUnload(@RequestBody Map<String, Object> params) { |
|
|
Object ret = getCommonParamAndCreateBizTask(params); |
|
|
Object ret = getCommonParamAndCreateBizTask(params); |
|
|
if (ret instanceof Model) { |
|
|
if (ret instanceof R) { |
|
|
// 异常
|
|
|
// 异常
|
|
|
return (Model<Object>) ret; |
|
|
return (R<Object>) ret; |
|
|
} |
|
|
} |
|
|
RcsCommonParam ps = (RcsCommonParam) ret; |
|
|
RcsCommonParam ps = (RcsCommonParam) ret; |
|
|
|
|
|
|
|
|
String targetStoreLoc = Conv.asString(params.get("targetStoreLoc")); |
|
|
String targetStoreLoc = Conv.asString(params.get("targetStoreLoc")); |
|
|
if (Strings.isNullOrEmpty(targetStoreLoc)) { |
|
|
if (Strings.isNullOrEmpty(targetStoreLoc)) { |
|
|
return Model.newFail("targetStoreLoc Must not be empty"); |
|
|
return R.fail("targetStoreLoc Must not be empty"); |
|
|
} |
|
|
} |
|
|
StoreLocation targetLocation = StoreLocation.of(targetStoreLoc, "/"); |
|
|
StoreLocation targetLocation = StoreLocation.of(targetStoreLoc, "/"); |
|
|
|
|
|
|
|
|
@ -162,20 +175,20 @@ public class RcsController { |
|
|
ps.agv.logicY = ps.fromItem.logicY; |
|
|
ps.agv.logicY = ps.fromItem.logicY; |
|
|
ps.agv.dispatchTask(ps.planSequence); |
|
|
ps.agv.dispatchTask(ps.planSequence); |
|
|
|
|
|
|
|
|
return Model.newSuccess(ps.planSequence.toPrettyMap()); |
|
|
return R.success(ps.planSequence.toPrettyMap()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static Model<Object> agvLoad(@RequestBody Map<String, Object> params) { |
|
|
public static R<?> agvLoad(@RequestBody Map<String, Object> params) { |
|
|
Object ret = getCommonParamAndCreateBizTask(params); |
|
|
Object ret = getCommonParamAndCreateBizTask(params); |
|
|
if (ret instanceof Model) { |
|
|
if (ret instanceof R) { |
|
|
// 异常
|
|
|
// 异常
|
|
|
return (Model<Object>) ret; |
|
|
return (R<?>) ret; |
|
|
} |
|
|
} |
|
|
RcsCommonParam ps = (RcsCommonParam) ret; |
|
|
RcsCommonParam ps = (RcsCommonParam) ret; |
|
|
|
|
|
|
|
|
String targetStoreLoc = Conv.asString(params.get("targetStoreLoc")); |
|
|
String targetStoreLoc = Conv.asString(params.get("targetStoreLoc")); |
|
|
if (Strings.isNullOrEmpty(targetStoreLoc)) { |
|
|
if (Strings.isNullOrEmpty(targetStoreLoc)) { |
|
|
return Model.newFail("targetStoreLoc Must not be empty"); |
|
|
return R.fail("targetStoreLoc Must not be empty"); |
|
|
} |
|
|
} |
|
|
StoreLocation targetLocation = StoreLocation.of(targetStoreLoc, "/"); |
|
|
StoreLocation targetLocation = StoreLocation.of(targetStoreLoc, "/"); |
|
|
|
|
|
|
|
|
@ -191,26 +204,26 @@ public class RcsController { |
|
|
ps.agv.logicY = ps.fromItem.logicY; |
|
|
ps.agv.logicY = ps.fromItem.logicY; |
|
|
ps.agv.dispatchTask(ps.planSequence); |
|
|
ps.agv.dispatchTask(ps.planSequence); |
|
|
|
|
|
|
|
|
return Model.newSuccess(ps.planSequence.toPrettyMap()); |
|
|
return R.success(ps.planSequence.toPrettyMap()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static Model<Object> cancelTasks(@RequestBody Map<String, Object> params) { |
|
|
public static R<?> cancelTasks(@RequestBody Map<String, Object> params) { |
|
|
Object ret = getCommonParamAndCreateBizTask(params); |
|
|
Object ret = getCommonParamAndCreateBizTask(params); |
|
|
if (ret instanceof Model) { |
|
|
if (ret instanceof R) { |
|
|
// 异常
|
|
|
// 异常
|
|
|
return (Model<Object>) ret; |
|
|
return (R<?>) ret; |
|
|
} |
|
|
} |
|
|
RcsCommonParam ps = (RcsCommonParam) ret; |
|
|
RcsCommonParam ps = (RcsCommonParam) ret; |
|
|
|
|
|
|
|
|
ps.agv.cancelTask(); |
|
|
ps.agv.cancelTask(); |
|
|
return Model.newSuccess("AGV tasks cancelled successfully"); |
|
|
return R.success("AGV tasks cancelled successfully"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static Model<Object> waitTaskFinish(@RequestBody Map<String, Object> params) { |
|
|
public static R<?> waitTaskFinish(@RequestBody Map<String, Object> params) { |
|
|
Object ret = getCommonParamAndCreateBizTask(params); |
|
|
Object ret = getCommonParamAndCreateBizTask(params); |
|
|
if (ret instanceof Model) { |
|
|
if (ret instanceof R) { |
|
|
// 异常
|
|
|
// 异常
|
|
|
return (Model<Object>) ret; |
|
|
return (R<?>) ret; |
|
|
} |
|
|
} |
|
|
RcsCommonParam ps = (RcsCommonParam) ret; |
|
|
RcsCommonParam ps = (RcsCommonParam) ret; |
|
|
|
|
|
|
|
|
@ -222,19 +235,19 @@ public class RcsController { |
|
|
Thread.sleep(100); // 等待100毫秒
|
|
|
Thread.sleep(100); // 等待100毫秒
|
|
|
} catch (InterruptedException e) { |
|
|
} catch (InterruptedException e) { |
|
|
Thread.currentThread().interrupt(); // 恢复中断状态
|
|
|
Thread.currentThread().interrupt(); // 恢复中断状态
|
|
|
return Model.newFail("Interrupted while waiting for task to finish"); |
|
|
return R.fail("Interrupted while waiting for task to finish"); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var cost = System.currentTimeMillis() - now; |
|
|
var cost = System.currentTimeMillis() - now; |
|
|
return Model.newSuccess(cost); |
|
|
return R.success(cost); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static Model<Object> agvCarry(@RequestBody Map<String, Object> params) { |
|
|
public static R<?> agvCarry(@RequestBody Map<String, Object> params) { |
|
|
Object ret = getCommonParamAndCreateBizTask(params); |
|
|
Object ret = getCommonParamAndCreateBizTask(params); |
|
|
if (ret instanceof Model) { |
|
|
if (ret instanceof R) { |
|
|
// 异常
|
|
|
// 异常
|
|
|
return (Model<Object>) ret; |
|
|
return (R<?>) ret; |
|
|
} |
|
|
} |
|
|
RcsCommonParam ps = (RcsCommonParam) ret; |
|
|
RcsCommonParam ps = (RcsCommonParam) ret; |
|
|
|
|
|
|
|
|
@ -242,10 +255,10 @@ public class RcsController { |
|
|
String targetStoreLoc = Conv.asString(params.get("targetStoreLoc")); |
|
|
String targetStoreLoc = Conv.asString(params.get("targetStoreLoc")); |
|
|
|
|
|
|
|
|
if (Strings.isNullOrEmpty(fromStoreLoc)) { |
|
|
if (Strings.isNullOrEmpty(fromStoreLoc)) { |
|
|
return Model.newFail("fromStoreLoc Must not be empty"); |
|
|
return R.fail("fromStoreLoc Must not be empty"); |
|
|
} |
|
|
} |
|
|
if (Strings.isNullOrEmpty(targetStoreLoc)) { |
|
|
if (Strings.isNullOrEmpty(targetStoreLoc)) { |
|
|
return Model.newFail("targetStoreLoc Must not be empty"); |
|
|
return R.fail("targetStoreLoc Must not be empty"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
StoreLocation sourceLocation = StoreLocation.of(fromStoreLoc, "/"); |
|
|
StoreLocation sourceLocation = StoreLocation.of(fromStoreLoc, "/"); |
|
|
@ -253,11 +266,11 @@ public class RcsController { |
|
|
|
|
|
|
|
|
StaticItem sourceItem = ps.runtime.getStaticItemById(sourceLocation.rackId()); |
|
|
StaticItem sourceItem = ps.runtime.getStaticItemById(sourceLocation.rackId()); |
|
|
if (sourceItem == null) { |
|
|
if (sourceItem == null) { |
|
|
return Model.newFail("fromStoreLoc storePoint not found!"); |
|
|
return R.fail("fromStoreLoc storePoint not found!"); |
|
|
} |
|
|
} |
|
|
StaticItem targetItem = ps.runtime.getStaticItemById(targetLocation.rackId()); |
|
|
StaticItem targetItem = ps.runtime.getStaticItemById(targetLocation.rackId()); |
|
|
if (targetItem == null) { |
|
|
if (targetItem == null) { |
|
|
return Model.newFail("targetStoreLoc storePoint not found!"); |
|
|
return R.fail("targetStoreLoc storePoint not found!"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
ps.bizTask.setTaskFrom(fromStoreLoc); |
|
|
ps.bizTask.setTaskFrom(fromStoreLoc); |
|
|
@ -276,7 +289,7 @@ public class RcsController { |
|
|
ps.agv.logicY = ps.fromItem.logicY; |
|
|
ps.agv.logicY = ps.fromItem.logicY; |
|
|
ps.agv.dispatchTask(ps.planSequence); |
|
|
ps.agv.dispatchTask(ps.planSequence); |
|
|
|
|
|
|
|
|
return Model.newSuccess(ps.planSequence.toPrettyMap()); |
|
|
return R.success(ps.planSequence.toPrettyMap()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -287,13 +300,13 @@ public class RcsController { |
|
|
Map<String, Object> option = (Map<String, Object>) params.get("option"); |
|
|
Map<String, Object> option = (Map<String, Object>) params.get("option"); |
|
|
|
|
|
|
|
|
if (Strings.isNullOrEmpty(projectUUID)) { |
|
|
if (Strings.isNullOrEmpty(projectUUID)) { |
|
|
return Model.newFail("projectUUID Must not be empty"); |
|
|
return R.fail("projectUUID Must not be empty"); |
|
|
} |
|
|
} |
|
|
if (envId == null || envId < 0) { |
|
|
if (envId == null || envId < 0) { |
|
|
return Model.newFail("envId Must not be empty"); |
|
|
return R.fail("envId Must not be empty"); |
|
|
} |
|
|
} |
|
|
if (Strings.isNullOrEmpty(agvId)) { |
|
|
if (Strings.isNullOrEmpty(agvId)) { |
|
|
return Model.newFail("agvId Must not be empty"); |
|
|
return R.fail("agvId Must not be empty"); |
|
|
} |
|
|
} |
|
|
if (option == null) { |
|
|
if (option == null) { |
|
|
option = Maps.newHashMap(); |
|
|
option = Maps.newHashMap(); |
|
|
@ -303,10 +316,10 @@ public class RcsController { |
|
|
|
|
|
|
|
|
ExecutorItem executorItem = runtime.executorItemMap.get(agvId); |
|
|
ExecutorItem executorItem = runtime.executorItemMap.get(agvId); |
|
|
if (executorItem == null) { |
|
|
if (executorItem == null) { |
|
|
return Model.newFail("executor not found: " + agvId); |
|
|
return R.fail("executor not found: " + agvId); |
|
|
} |
|
|
} |
|
|
if (!(executorItem instanceof PtrAgvItem agv)) { |
|
|
if (!(executorItem instanceof PtrAgvItem agv)) { |
|
|
return Model.newFail("executor is not a PtrAgvItem id=" + agvId); |
|
|
return R.fail("executor is not a PtrAgvItem id=" + agvId); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 获取机器人当前所在位置, 也可以前端强制指定
|
|
|
// 获取机器人当前所在位置, 也可以前端强制指定
|
|
|
@ -325,10 +338,10 @@ public class RcsController { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (fromItem == null) { |
|
|
if (fromItem == null) { |
|
|
return Model.newFail("PtrAgvItem not found at current location: " + agv.logicX + "_" + agv.logicY + ", id=" + agvId); |
|
|
return R.fail("PtrAgvItem not found at current location: " + agv.logicX + "_" + agv.logicY + ", id=" + agvId); |
|
|
} |
|
|
} |
|
|
if (fromDirection == null) { |
|
|
if (fromDirection == null) { |
|
|
return Model.newFail("PtrAgvItem unkown direction id=" + agvId); |
|
|
return R.fail("PtrAgvItem unkown direction id=" + agvId); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
RcsTaskBiz bizTask = new RcsTaskBiz(); |
|
|
RcsTaskBiz bizTask = new RcsTaskBiz(); |
|
|
|