|
|
@ -1,6 +1,6 @@ |
|
|
package com.yvan.workbench.controller; |
|
|
package com.yvan.workbench.controller; |
|
|
|
|
|
|
|
|
import com.galaxis.rcs.RCSService; |
|
|
import com.galaxis.rcs.common.entity.LccBasLocation; |
|
|
import com.galaxis.rcs.common.entity.RcsTaskBiz; |
|
|
import com.galaxis.rcs.common.entity.RcsTaskBiz; |
|
|
import com.galaxis.rcs.common.entity.StoreLocation; |
|
|
import com.galaxis.rcs.common.entity.StoreLocation; |
|
|
import com.galaxis.rcs.common.enums.BizTaskStatus; |
|
|
import com.galaxis.rcs.common.enums.BizTaskStatus; |
|
|
@ -11,6 +11,7 @@ import com.galaxis.rcs.plan.task.*; |
|
|
import com.galaxis.rcs.ptr.PtrAgvItem; |
|
|
import com.galaxis.rcs.ptr.PtrAgvItem; |
|
|
import com.google.common.base.Strings; |
|
|
import com.google.common.base.Strings; |
|
|
import com.google.common.collect.Maps; |
|
|
import com.google.common.collect.Maps; |
|
|
|
|
|
import com.yvan.entity.BasLocationVo; |
|
|
import com.yvan.logisticsModel.ExecutorItem; |
|
|
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; |
|
|
@ -22,6 +23,9 @@ import org.clever.web.mvc.annotation.RequestBody; |
|
|
|
|
|
|
|
|
import java.util.Map; |
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
|
|
import static com.galaxis.rcs.common.query.QLccBasLocation.lccBasLocation; |
|
|
|
|
|
import static com.galaxis.rcs.common.query.QLccInvLpn.lccInvLpn; |
|
|
|
|
|
|
|
|
public class RcsController { |
|
|
public class RcsController { |
|
|
static final SnowFlake snowFlake = new SnowFlake(); |
|
|
static final SnowFlake snowFlake = new SnowFlake(); |
|
|
|
|
|
|
|
|
@ -130,6 +134,101 @@ public class RcsController { |
|
|
return R.success(executorItem); |
|
|
return R.success(executorItem); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static R<?> agvCarry(@RequestBody Map<String, Object> params) { |
|
|
|
|
|
Object ret = getCommonParamAndCreateBizTask(params); |
|
|
|
|
|
if (ret instanceof R) { |
|
|
|
|
|
// 异常
|
|
|
|
|
|
return (R<?>) ret; |
|
|
|
|
|
} |
|
|
|
|
|
RcsCommonParam ps = (RcsCommonParam) ret; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ==================== 查找来源货位 ====================
|
|
|
|
|
|
String fromStoreLoc = Conv.asString(params.get("fromStoreLoc")); |
|
|
|
|
|
if (Strings.isNullOrEmpty(fromStoreLoc)) { |
|
|
|
|
|
return R.fail("fromStoreLoc Must not be empty"); |
|
|
|
|
|
} |
|
|
|
|
|
StoreLocation sourceLocation = StoreLocation.of(fromStoreLoc, "/"); |
|
|
|
|
|
StaticItem sourceItem = ps.runtime.getStaticItemById(sourceLocation.rackId()); |
|
|
|
|
|
if (sourceItem == null) { |
|
|
|
|
|
return R.fail("fromStoreLoc storePoint not found!"); |
|
|
|
|
|
} |
|
|
|
|
|
// 查找货位基础资料
|
|
|
|
|
|
LccBasLocation loadBasLocation = ps.runtime.queryDSL.selectFrom( |
|
|
|
|
|
lccBasLocation |
|
|
|
|
|
) |
|
|
|
|
|
.where(lccBasLocation.envId.eq(ps.envId)) |
|
|
|
|
|
.where(lccBasLocation.rack.eq(sourceLocation.rackId())) |
|
|
|
|
|
.where(lccBasLocation.bay.eq(sourceLocation.bay())) |
|
|
|
|
|
.where(lccBasLocation.level.eq(sourceLocation.level())) |
|
|
|
|
|
.where(lccBasLocation.cell.eq(sourceLocation.cell())) |
|
|
|
|
|
.fetchFirst(); |
|
|
|
|
|
if (loadBasLocation == null) { |
|
|
|
|
|
return R.fail("fromStoreLoc location not found!"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ==================== 查找卸货货位 ====================
|
|
|
|
|
|
String targetStoreLoc = Conv.asString(params.get("targetStoreLoc")); |
|
|
|
|
|
if (Strings.isNullOrEmpty(targetStoreLoc)) { |
|
|
|
|
|
return R.fail("targetStoreLoc Must not be empty"); |
|
|
|
|
|
} |
|
|
|
|
|
StoreLocation targetLocation = StoreLocation.of(targetStoreLoc, "/"); |
|
|
|
|
|
StaticItem targetItem = ps.runtime.getStaticItemById(targetLocation.rackId()); |
|
|
|
|
|
if (targetItem == null) { |
|
|
|
|
|
return R.fail("targetStoreLoc storePoint not found!"); |
|
|
|
|
|
} |
|
|
|
|
|
// 查找货位基础资料
|
|
|
|
|
|
LccBasLocation unloadBasLocation = ps.runtime.queryDSL.selectFrom( |
|
|
|
|
|
lccBasLocation |
|
|
|
|
|
) |
|
|
|
|
|
.where(lccBasLocation.envId.eq(ps.envId)) |
|
|
|
|
|
.where(lccBasLocation.rack.eq(targetLocation.rackId())) |
|
|
|
|
|
.where(lccBasLocation.bay.eq(targetLocation.bay())) |
|
|
|
|
|
.where(lccBasLocation.level.eq(targetLocation.level())) |
|
|
|
|
|
.where(lccBasLocation.cell.eq(targetLocation.cell())) |
|
|
|
|
|
.fetchFirst(); |
|
|
|
|
|
if (unloadBasLocation == null) { |
|
|
|
|
|
return R.fail("targetStoreLoc location not found!"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// ==================== 找到托盘号 ====================
|
|
|
|
|
|
String lpn = ps.runtime.queryDSL |
|
|
|
|
|
.select(lccInvLpn.lpn) |
|
|
|
|
|
.from(lccInvLpn) |
|
|
|
|
|
.where(lccInvLpn.envId.eq(ps.envId)) |
|
|
|
|
|
.where(lccInvLpn.locCode.eq(loadBasLocation.getLocCode())) |
|
|
|
|
|
.fetchFirst(); |
|
|
|
|
|
if (Strings.isNullOrEmpty(lpn)) { |
|
|
|
|
|
return R.fail("LPN not found at fromStoreLoc: " + fromStoreLoc); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// ==================== 布置任务 ====================
|
|
|
|
|
|
ps.bizTask.setLpn(lpn); |
|
|
|
|
|
ps.bizTask.setTaskFrom(loadBasLocation.getCatalogCode()); |
|
|
|
|
|
ps.bizTask.setTaskTo(unloadBasLocation.getLocCode()); |
|
|
|
|
|
|
|
|
|
|
|
CarryTask carryTask = new CarryTask( |
|
|
|
|
|
ps.agvId, ps.bizTask.getPriority(), |
|
|
|
|
|
sourceLocation, |
|
|
|
|
|
targetLocation |
|
|
|
|
|
); |
|
|
|
|
|
ps.planSequence.executorVo = new BasLocationVo(ps.agv); |
|
|
|
|
|
ps.planSequence.loadBasLocationVo = new BasLocationVo(loadBasLocation); |
|
|
|
|
|
ps.planSequence.unloadBasLocationVo = new BasLocationVo(unloadBasLocation); |
|
|
|
|
|
ps.planSequence.carryLpn = lpn; |
|
|
|
|
|
ps.planSequence.carryQty = 1; |
|
|
|
|
|
|
|
|
|
|
|
ps.runtime.pathPlannerMap.get(ps.agv.getT()) |
|
|
|
|
|
.planCarryTask(ps.planSequence, ps.fromItem.getId(), ps.fromDirection, carryTask); |
|
|
|
|
|
|
|
|
|
|
|
ps.agv.logicX = ps.fromItem.logicX; |
|
|
|
|
|
ps.agv.logicY = ps.fromItem.logicY; |
|
|
|
|
|
ps.agv.dispatchTask(ps.planSequence); |
|
|
|
|
|
|
|
|
|
|
|
return R.success(ps.planSequence.toPrettyMap()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public static R<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 R) { |
|
|
if (ret instanceof R) { |
|
|
@ -138,16 +237,52 @@ public class RcsController { |
|
|
} |
|
|
} |
|
|
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 R.fail("targetStoreLoc Must not be empty"); |
|
|
return R.fail("targetStoreLoc Must not be empty"); |
|
|
} |
|
|
} |
|
|
StoreLocation targetLocation = StoreLocation.of(targetStoreLoc, "/"); |
|
|
StoreLocation targetLocation = StoreLocation.of(targetStoreLoc, "/"); |
|
|
|
|
|
// 查找货位基础资料
|
|
|
|
|
|
LccBasLocation unloadBasLocation = ps.runtime.queryDSL.selectFrom( |
|
|
|
|
|
lccBasLocation |
|
|
|
|
|
) |
|
|
|
|
|
.where(lccBasLocation.envId.eq(ps.envId)) |
|
|
|
|
|
.where(lccBasLocation.rack.eq(targetLocation.rackId())) |
|
|
|
|
|
.where(lccBasLocation.bay.eq(targetLocation.bay())) |
|
|
|
|
|
.where(lccBasLocation.level.eq(targetLocation.level())) |
|
|
|
|
|
.where(lccBasLocation.cell.eq(targetLocation.cell())) |
|
|
|
|
|
.fetchFirst(); |
|
|
|
|
|
if (unloadBasLocation == null) { |
|
|
|
|
|
return R.fail("targetStoreLoc location not found!"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// ==================== 找到托盘号 ====================
|
|
|
|
|
|
BasLocationVo executorVo = new BasLocationVo(ps.agv); |
|
|
|
|
|
String lpn = ps.runtime.queryDSL |
|
|
|
|
|
.select(lccInvLpn.lpn) |
|
|
|
|
|
.from(lccInvLpn) |
|
|
|
|
|
.where(lccInvLpn.envId.eq(ps.envId)) |
|
|
|
|
|
.where(lccInvLpn.locCode.eq(executorVo.getLocCode())) |
|
|
|
|
|
.fetchFirst(); |
|
|
|
|
|
if (Strings.isNullOrEmpty(lpn)) { |
|
|
|
|
|
return R.fail("LPN not found at StoreLoc: " + executorVo.getLocCode()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// ==================== 布置任务 ====================
|
|
|
|
|
|
ps.bizTask.setLpn(lpn); |
|
|
|
|
|
ps.bizTask.setTaskFrom(ps.fromItem.getId()); |
|
|
|
|
|
ps.bizTask.setTaskTo(unloadBasLocation.getLocCode()); |
|
|
|
|
|
|
|
|
UnloadTask unloadTask = new UnloadTask( |
|
|
UnloadTask unloadTask = new UnloadTask( |
|
|
ps.agvId, ps.bizTask.getPriority(), |
|
|
ps.agvId, ps.bizTask.getPriority(), |
|
|
targetLocation |
|
|
targetLocation |
|
|
); |
|
|
); |
|
|
|
|
|
ps.planSequence.executorVo = executorVo; |
|
|
|
|
|
ps.planSequence.loadBasLocationVo = null; |
|
|
|
|
|
ps.planSequence.unloadBasLocationVo = new BasLocationVo(unloadBasLocation); |
|
|
|
|
|
ps.planSequence.carryLpn = lpn; |
|
|
|
|
|
ps.planSequence.carryQty = 1; |
|
|
|
|
|
|
|
|
ps.runtime.pathPlannerMap.get(ps.agv.getT()) |
|
|
ps.runtime.pathPlannerMap.get(ps.agv.getT()) |
|
|
.planUnloadTask(ps.planSequence, ps.fromItem.getId(), ps.fromDirection, unloadTask); |
|
|
.planUnloadTask(ps.planSequence, ps.fromItem.getId(), ps.fromDirection, unloadTask); |
|
|
@ -167,16 +302,51 @@ public class RcsController { |
|
|
} |
|
|
} |
|
|
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 R.fail("targetStoreLoc Must not be empty"); |
|
|
return R.fail("targetStoreLoc Must not be empty"); |
|
|
} |
|
|
} |
|
|
StoreLocation targetLocation = StoreLocation.of(targetStoreLoc, "/"); |
|
|
StoreLocation targetLocation = StoreLocation.of(targetStoreLoc, "/"); |
|
|
|
|
|
// 查找货位基础资料
|
|
|
|
|
|
LccBasLocation loadBasLocation = ps.runtime.queryDSL.selectFrom( |
|
|
|
|
|
lccBasLocation |
|
|
|
|
|
) |
|
|
|
|
|
.where(lccBasLocation.envId.eq(ps.envId)) |
|
|
|
|
|
.where(lccBasLocation.rack.eq(targetLocation.rackId())) |
|
|
|
|
|
.where(lccBasLocation.bay.eq(targetLocation.bay())) |
|
|
|
|
|
.where(lccBasLocation.level.eq(targetLocation.level())) |
|
|
|
|
|
.where(lccBasLocation.cell.eq(targetLocation.cell())) |
|
|
|
|
|
.fetchFirst(); |
|
|
|
|
|
if (loadBasLocation == null) { |
|
|
|
|
|
return R.fail("targetStoreLoc location not found!"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// ==================== 找到托盘号 ====================
|
|
|
|
|
|
String lpn = ps.runtime.queryDSL |
|
|
|
|
|
.select(lccInvLpn.lpn) |
|
|
|
|
|
.from(lccInvLpn) |
|
|
|
|
|
.where(lccInvLpn.envId.eq(ps.envId)) |
|
|
|
|
|
.where(lccInvLpn.locCode.eq(loadBasLocation.getLocCode())) |
|
|
|
|
|
.fetchFirst(); |
|
|
|
|
|
if (Strings.isNullOrEmpty(lpn)) { |
|
|
|
|
|
return R.fail("LPN not found at targetStoreLoc: " + loadBasLocation.getLocCode()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// ==================== 布置任务 ====================
|
|
|
|
|
|
ps.bizTask.setLpn(lpn); |
|
|
|
|
|
ps.bizTask.setTaskFrom(ps.fromItem.getId()); |
|
|
|
|
|
ps.bizTask.setTaskTo(loadBasLocation.getLocCode()); |
|
|
|
|
|
|
|
|
LoadTask loadTask = new LoadTask( |
|
|
LoadTask loadTask = new LoadTask( |
|
|
ps.agvId, ps.bizTask.getPriority(), |
|
|
ps.agvId, ps.bizTask.getPriority(), |
|
|
targetLocation |
|
|
targetLocation |
|
|
); |
|
|
); |
|
|
|
|
|
ps.planSequence.executorVo = new BasLocationVo(ps.agv); |
|
|
|
|
|
ps.planSequence.loadBasLocationVo = new BasLocationVo(loadBasLocation); |
|
|
|
|
|
ps.planSequence.unloadBasLocationVo = null; |
|
|
|
|
|
ps.planSequence.carryLpn = lpn; |
|
|
|
|
|
ps.planSequence.carryQty = 1; |
|
|
|
|
|
|
|
|
ps.runtime.pathPlannerMap.get(ps.agv.getT()) |
|
|
ps.runtime.pathPlannerMap.get(ps.agv.getT()) |
|
|
.planLoadTask(ps.planSequence, ps.fromItem.getId(), ps.fromDirection, loadTask); |
|
|
.planLoadTask(ps.planSequence, ps.fromItem.getId(), ps.fromDirection, loadTask); |
|
|
@ -224,56 +394,6 @@ public class RcsController { |
|
|
return R.success(cost); |
|
|
return R.success(cost); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static R<?> agvCarry(@RequestBody Map<String, Object> params) { |
|
|
|
|
|
Object ret = getCommonParamAndCreateBizTask(params); |
|
|
|
|
|
if (ret instanceof R) { |
|
|
|
|
|
// 异常
|
|
|
|
|
|
return (R<?>) ret; |
|
|
|
|
|
} |
|
|
|
|
|
RcsCommonParam ps = (RcsCommonParam) ret; |
|
|
|
|
|
|
|
|
|
|
|
String fromStoreLoc = Conv.asString(params.get("fromStoreLoc")); |
|
|
|
|
|
String targetStoreLoc = Conv.asString(params.get("targetStoreLoc")); |
|
|
|
|
|
|
|
|
|
|
|
if (Strings.isNullOrEmpty(fromStoreLoc)) { |
|
|
|
|
|
return R.fail("fromStoreLoc Must not be empty"); |
|
|
|
|
|
} |
|
|
|
|
|
if (Strings.isNullOrEmpty(targetStoreLoc)) { |
|
|
|
|
|
return R.fail("targetStoreLoc Must not be empty"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
StoreLocation sourceLocation = StoreLocation.of(fromStoreLoc, "/"); |
|
|
|
|
|
StoreLocation targetLocation = StoreLocation.of(targetStoreLoc, "/"); |
|
|
|
|
|
|
|
|
|
|
|
StaticItem sourceItem = ps.runtime.getStaticItemById(sourceLocation.rackId()); |
|
|
|
|
|
if (sourceItem == null) { |
|
|
|
|
|
return R.fail("fromStoreLoc storePoint not found!"); |
|
|
|
|
|
} |
|
|
|
|
|
StaticItem targetItem = ps.runtime.getStaticItemById(targetLocation.rackId()); |
|
|
|
|
|
if (targetItem == null) { |
|
|
|
|
|
return R.fail("targetStoreLoc storePoint not found!"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ps.bizTask.setTaskFrom(fromStoreLoc); |
|
|
|
|
|
ps.bizTask.setTaskTo(targetStoreLoc); |
|
|
|
|
|
|
|
|
|
|
|
CarryTask carryTask = new CarryTask( |
|
|
|
|
|
ps.agvId, "N/A", ps.bizTask.getPriority(), |
|
|
|
|
|
sourceLocation, |
|
|
|
|
|
targetLocation |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
ps.runtime.pathPlannerMap.get(ps.agv.getT()) |
|
|
|
|
|
.planCarryTask(ps.planSequence, ps.fromItem.getId(), ps.fromDirection, carryTask); |
|
|
|
|
|
|
|
|
|
|
|
ps.agv.logicX = ps.fromItem.logicX; |
|
|
|
|
|
ps.agv.logicY = ps.fromItem.logicY; |
|
|
|
|
|
ps.agv.dispatchTask(ps.planSequence); |
|
|
|
|
|
|
|
|
|
|
|
return R.success(ps.planSequence.toPrettyMap()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static Object getCommonParamAndCreateBizTask(@RequestBody Map<String, Object> params) { |
|
|
public static Object getCommonParamAndCreateBizTask(@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")); |
|
|
|