29 changed files with 848 additions and 13 deletions
@ -0,0 +1,53 @@ |
|||
package com.galaxis.rcs; |
|||
|
|||
import com.galaxis.rcs.common.entity.AddTaskRequest; |
|||
import com.galaxis.rcs.common.entity.AddTaskResult; |
|||
import com.galaxis.rcs.task.TaskService; |
|||
import com.yvan.logisticsModel.LogisticsRuntime; |
|||
import com.yvan.logisticsModel.LogisticsRuntimeService; |
|||
|
|||
/** |
|||
* RCS 对外API调用类 |
|||
*/ |
|||
public class RCS { |
|||
|
|||
static final LogisticsRuntimeService logisticsRuntimeService = new LogisticsRuntimeService(); |
|||
|
|||
/** |
|||
* 添加任务, 示例 |
|||
* <pre> |
|||
* { |
|||
* type: 'carry', // 任务类型
|
|||
* agv: 'cl2', // 指定车辆
|
|||
* lpn: 'pallet1124', // 托盘ID, 用于校验
|
|||
* from: '27', // 起始点位
|
|||
* priority: 1, // 优先级
|
|||
* from: { |
|||
* item: '27', bay: 0, level: 1, cell: 0 // 起始点位的详细信息
|
|||
* }, |
|||
* to:{ |
|||
* item: '20' |
|||
* } |
|||
* } |
|||
* </pre> |
|||
*/ |
|||
public static AddTaskResult addTask(String envCode, AddTaskRequest request) { |
|||
AddTaskResult result = new AddTaskResult(); |
|||
|
|||
LogisticsRuntime logisticsRuntime = logisticsRuntimeService.findByEnvCode(envCode); |
|||
|
|||
String bizTaskId = logisticsRuntime.taskService.addBizTask(request); |
|||
|
|||
logisticsRuntime.taskDispatchFactory.checkAll(); |
|||
|
|||
result.bizTaskId = bizTaskId; |
|||
|
|||
return result; |
|||
} |
|||
|
|||
/** |
|||
* 地图信息2 |
|||
* 1<->2, 2<->3, 3<->4, 4<->5, 5<->6, 6<->7, 7<->8, 8<->9,9<->10 |
|||
* 1 <-> 38, 1 <-> 36 |
|||
*/ |
|||
} |
|||
@ -0,0 +1,54 @@ |
|||
package com.galaxis.rcs.common.entity; |
|||
|
|||
import com.galaxis.rcs.common.enums.BizTaskType; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* <pre> |
|||
* { |
|||
* type: 'carry', // 任务类型
|
|||
* taskExecutorId: 'cl2', // 指定车辆
|
|||
* lpn: 'pallet1124', // 托盘ID, 用于校验
|
|||
* priority: 1, // 优先级
|
|||
* from: { |
|||
* item: '27', bay: 0, level: 1, cell: 0 // 起始点位的详细信息
|
|||
* }, |
|||
* to: { |
|||
* item: '20' |
|||
* } |
|||
* } |
|||
* </pre> |
|||
*/ |
|||
@Data |
|||
public class AddTaskRequest { |
|||
/** |
|||
* 任务类型 |
|||
* 可选值: 'carry', 'putaway', 'pick', 'move' |
|||
*/ |
|||
public BizTaskType type; |
|||
|
|||
/** |
|||
* 指定任务的执行器ID |
|||
*/ |
|||
public String taskExecutorId; |
|||
|
|||
/** |
|||
* 托盘ID, 用于校验 |
|||
*/ |
|||
public String lpn; |
|||
|
|||
/** |
|||
* 任务优先级,越大优先级越高 |
|||
*/ |
|||
public int priority; |
|||
|
|||
/** |
|||
* 起始位置 |
|||
*/ |
|||
public StoreLocation from; |
|||
|
|||
/** |
|||
* 目标位置 |
|||
*/ |
|||
public StoreLocation to; |
|||
} |
|||
@ -0,0 +1,19 @@ |
|||
package com.galaxis.rcs.common.entity; |
|||
|
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* 添加任务结果 |
|||
* <pre> |
|||
* { |
|||
* taskId: 'task123' |
|||
* } |
|||
* </pre> |
|||
*/ |
|||
@Data |
|||
public class AddTaskResult { |
|||
/** |
|||
* 业务任务ID |
|||
*/ |
|||
public String bizTaskId; |
|||
} |
|||
@ -0,0 +1,109 @@ |
|||
package com.galaxis.rcs.common.entity; |
|||
|
|||
import com.yvan.logisticsMonitor.task.BizTask; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* RcsTaskBiz 类用于定义业务任务的实体 |
|||
*/ |
|||
|
|||
/** |
|||
* TODO: 插入 rcs_task_biz 表, 结构为 |
|||
* biz_task_id bigint not null, |
|||
* force_assign_executor_id varchar(50) not null, |
|||
* force_assign_executor_type varchar(50) not null, |
|||
* task_type varchar(10) |
|||
* lpn varchar(50) |
|||
* priority integer |
|||
* task_from varchar(100) |
|||
* task_to varchar(100) |
|||
* allocated_executor_id varchar(50) default 'N/A' |
|||
* biz_task_status varchar(10) default 'pending' |
|||
* create_at timestamp |
|||
* create_by varchar(50) |
|||
* update_at timestamp |
|||
* update_by varchar(50) |
|||
* <p> |
|||
* create table rcs_task_biz ( |
|||
* biz_task_id bigint not null auto_increment, |
|||
* force_assign_executor_id varchar(50) not null comment '用户强制指派了车号' default 'N/A', |
|||
* force_assign_executor_type varchar(50) not null comment '用户强制指派了车型' default 'N/A', |
|||
* task_type varchar(10) not null comment '任务类型' default 'carry', |
|||
* lpn varchar(50) not null comment '托盘ID', |
|||
* priority integer not null comment '任务优先级', |
|||
* task_from varchar(50) not null comment '任务起始点', |
|||
* task_to varchar(50) not null comment '任务目标点', |
|||
* allocated_executor_id varchar(50) default 'N/A' comment '系统分配的执行器ID', |
|||
* biz_task_status varchar(10) default 'pending' comment '任务状态', |
|||
* create_at datetime not null comment '创建时间', |
|||
* create_by varchar(50) not null comment '创建人', |
|||
* update_at datetime not null comment '更新时间', |
|||
* update_by varchar(50) not null comment '更新人', |
|||
* <p> |
|||
* primary key (biz_task_id) |
|||
* } |
|||
*/ |
|||
@Data |
|||
public class RcsTaskBiz implements BizTask { |
|||
/** |
|||
* 业务任务ID |
|||
*/ |
|||
public long bizTaskId; |
|||
|
|||
/** |
|||
* 强制分配的执行器ID |
|||
*/ |
|||
public String forceAssignExecutorId = "N/A"; // 默认值为 'N/A'
|
|||
/** |
|||
* 强制分配的执行器类型 |
|||
*/ |
|||
public String forceAssignExecutorType = "N/A"; // 默认值为 'N/A'
|
|||
/** |
|||
* 任务类型 |
|||
*/ |
|||
public String taskType; |
|||
/** |
|||
* 托盘ID |
|||
*/ |
|||
public String lpn; |
|||
/** |
|||
* 任务优先级 |
|||
*/ |
|||
public int priority; |
|||
/** |
|||
* 任务起始点 |
|||
*/ |
|||
public String taskFrom; |
|||
/** |
|||
* 任务目标点 |
|||
*/ |
|||
public String taskTo; |
|||
/** |
|||
* 分配的执行器ID |
|||
*/ |
|||
public String allocatedExecutorId = "N/A"; // 默认值为 'N/A'
|
|||
/** |
|||
* 业务任务状态 |
|||
*/ |
|||
public String bizTaskStatus = "pending"; // 默认状态为 'pending'
|
|||
/** |
|||
* 创建时间 |
|||
*/ |
|||
public String createAt; |
|||
/** |
|||
* 创建人 |
|||
*/ |
|||
public String createBy; |
|||
/** |
|||
* 更新时间 |
|||
*/ |
|||
public String updateAt; |
|||
/** |
|||
* 更新人 |
|||
*/ |
|||
public String updateBy; |
|||
/** |
|||
* 业务任务描述 |
|||
*/ |
|||
public String description; // 可选字段,用于描述任务的详细信息
|
|||
} |
|||
@ -0,0 +1,24 @@ |
|||
package com.galaxis.rcs.common.entity; |
|||
|
|||
/** |
|||
* 任务规划 |
|||
*/ |
|||
public class RcsTaskPlan { |
|||
/** |
|||
* 表名: rcs_task_plan |
|||
* 表结构为 |
|||
* plan_task_id bigint not null auto_increment primary key, |
|||
* biz_task_id bigint not null, |
|||
* type varchar(50) not null, |
|||
* executor_id varchar(50) not null, |
|||
* seq integer not null, |
|||
* payload varchar(3000) not null, |
|||
* plan_task_status varchar(10) default 'waiting', |
|||
* error_message varchar(500) default '', |
|||
* description varchar(500) default '', |
|||
* create_at timestamp |
|||
* create_by varchar(50) |
|||
* update_at timestamp |
|||
* update_by varchar(50) |
|||
*/ |
|||
} |
|||
@ -0,0 +1,29 @@ |
|||
package com.galaxis.rcs.common.entity; |
|||
|
|||
/** |
|||
* 存储存储位信息 |
|||
* <pre> |
|||
* { |
|||
* item: '27', // 货架ID
|
|||
* bay: 0, // 列
|
|||
* level: 1, // 层
|
|||
* cell: 0 // 格
|
|||
* } |
|||
* </pre> |
|||
*/ |
|||
public record StoreLocation( |
|||
String item, // 货架ID
|
|||
int bay, // 列
|
|||
int level, // 层
|
|||
int cell // 格
|
|||
) { |
|||
@Override |
|||
public String toString() { |
|||
return "StoreLocation{" + |
|||
"item='" + item + '\'' + |
|||
", bay=" + bay + |
|||
", level=" + level + |
|||
", cell=" + cell + |
|||
'}'; |
|||
} |
|||
} |
|||
@ -0,0 +1,5 @@ |
|||
package com.galaxis.rcs.common.enums; |
|||
|
|||
public enum BizTaskType { |
|||
CARRY, // 搬运任务
|
|||
} |
|||
@ -0,0 +1,21 @@ |
|||
package com.galaxis.rcs.common.enums; |
|||
|
|||
/** |
|||
* 环境状态 |
|||
*/ |
|||
public enum EnvStatus { |
|||
/** |
|||
* 环境已启动 |
|||
*/ |
|||
RUNNING, |
|||
|
|||
/** |
|||
* 环境已停止 |
|||
*/ |
|||
STOPPED, |
|||
|
|||
/** |
|||
* 环境已删除 |
|||
*/ |
|||
DELETED, |
|||
} |
|||
@ -1,4 +0,0 @@ |
|||
package com.galaxis.rcs.plan; |
|||
|
|||
public class PlanManager { |
|||
} |
|||
@ -0,0 +1,19 @@ |
|||
package com.galaxis.rcs.plan; |
|||
|
|||
import com.galaxis.rcs.common.entity.RcsTaskBiz; |
|||
import com.yvan.logisticsModel.LogisticsRuntime; |
|||
|
|||
/** |
|||
* 任务执行器的计划接口 |
|||
* 用于定义如何执行任务计划 |
|||
*/ |
|||
public interface Planner { |
|||
/** |
|||
* 执行任务计划 |
|||
* |
|||
* @param runtime 物流运行时环境 |
|||
* @param tasks 任务对象,包含任务的详细信息 |
|||
* @param executorId 执行器ID |
|||
*/ |
|||
void executePlan(LogisticsRuntime runtime, RcsTaskBiz tasks, String executorId); |
|||
} |
|||
@ -0,0 +1,20 @@ |
|||
package com.galaxis.rcs.plan; |
|||
|
|||
import com.galaxis.rcs.plan.planner.PTRTaskPlanner; |
|||
|
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 根据任务执行器类型(车型),找到对应车型的任务分配器 |
|||
*/ |
|||
public class TaskPlannerFactory { |
|||
|
|||
private static final Map<String, Planner> planners = Map.of( |
|||
"cl2", new PTRTaskPlanner(), |
|||
"clx", new PTRTaskPlanner() |
|||
); |
|||
|
|||
public static Planner getPlanner(String executorType) { |
|||
return planners.get(executorType); |
|||
} |
|||
} |
|||
@ -0,0 +1,66 @@ |
|||
package com.galaxis.rcs.plan.planner; |
|||
|
|||
import com.galaxis.rcs.common.entity.RcsTaskBiz; |
|||
import com.galaxis.rcs.common.entity.RcsTaskPlan; |
|||
import com.galaxis.rcs.plan.Planner; |
|||
import com.yvan.logisticsModel.LogisticsRuntime; |
|||
|
|||
/** |
|||
* PTR 任务规划器。 |
|||
* 用于处理 CL2 / CLX 等车型的任务规划 |
|||
*/ |
|||
public class PTRTaskPlanner implements Planner { |
|||
/** |
|||
* 执行任务规划 |
|||
* |
|||
* @param runtime 物流运行时环境 |
|||
* @param task 任务对象,包含任务的详细信息 |
|||
* @param executorId 执行器ID |
|||
*/ |
|||
@Override |
|||
public void executePlan(LogisticsRuntime runtime, RcsTaskBiz task, String executorId) { |
|||
/** |
|||
* 示例数据 |
|||
* { |
|||
* type: 'carry', // 任务类型
|
|||
* agv: 'cl2', // 指定车辆
|
|||
* lpn: 'pallet1124', // 托盘ID, 用于校验
|
|||
* priority: 1, // 优先级
|
|||
* // 起始点位的详细信息
|
|||
* from: { |
|||
* item: '27', // 货架编号
|
|||
* bay: 0, // 货架列
|
|||
* level: 1, // 货架层
|
|||
* cell: 0 // 货架格
|
|||
* }, |
|||
* // 目标点位的详细信息
|
|||
* to: { |
|||
* item: '20' // 地堆货位号
|
|||
* } |
|||
* } |
|||
*/ |
|||
|
|||
/** |
|||
* 地图路由示例1 |
|||
* 17<->20, 20<->21, 21<->22, 22<->23, 23<->24, 24<->25, 25<->26, 26<->27, 27<->charger2, |
|||
* |
|||
* 地图货位信息 |
|||
* 21 左侧 rack1 / 3 |
|||
* 22 右侧 56 |
|||
* 23 左侧 rack1 / 2 |
|||
* 24 旋转位 |
|||
* 25 左侧 rack1 / 1 |
|||
* 26 右侧 58 |
|||
* 27 左侧 rack1 / 0 |
|||
*/ |
|||
|
|||
// 绑定任务执行器
|
|||
task.setAllocatedExecutorId(executorId); |
|||
|
|||
// TODO: 写入 rcs_task_biz 表, 写入 rcs_task_plan 表, 并安排规划方案的顺序执行, 并将全部规划通知给 MQTT
|
|||
RcsTaskPlan[] planList = new RcsTaskPlan[0]; |
|||
|
|||
runtime.executorItemMap.get(executorId).executeTaskPlanList(runtime, task, planList); |
|||
} |
|||
|
|||
} |
|||
@ -1,4 +0,0 @@ |
|||
package com.galaxis.rcs.task; |
|||
|
|||
public class TaskDispatch { |
|||
} |
|||
@ -0,0 +1,36 @@ |
|||
package com.galaxis.rcs.task; |
|||
|
|||
import com.galaxis.rcs.common.entity.RcsTaskBiz; |
|||
import com.galaxis.rcs.task.dispatcher.TaiWanDispatcher; |
|||
import com.yvan.logisticsModel.LogisticsRuntime; |
|||
|
|||
public class TaskDispatchFactory { |
|||
public final LogisticsRuntime logisticsRuntime; |
|||
private TaiWanDispatcher dispatcher = new TaiWanDispatcher(); |
|||
|
|||
public TaskDispatchFactory(LogisticsRuntime logisticsRuntime) { |
|||
this.logisticsRuntime = logisticsRuntime; |
|||
} |
|||
|
|||
/** |
|||
* 开启轮询线程,定时检查有没有空执行器,可以用于执行选定任务 |
|||
*/ |
|||
public void startPolling() { |
|||
// TODO: 启动一个线程,定时检查是否有空闲的执行器
|
|||
RcsTaskBiz taskBiz = new RcsTaskBiz(); |
|||
dispatcher.dispatchTask(this, taskBiz); |
|||
} |
|||
|
|||
/** |
|||
* 停止轮询线程 |
|||
*/ |
|||
public void stopPolling() { |
|||
// TODO: 停止轮询线程
|
|||
} |
|||
|
|||
/** |
|||
* 向巡视线程发送一个信号,让他启动检查 |
|||
*/ |
|||
public void checkAll() { |
|||
} |
|||
} |
|||
@ -1,4 +0,0 @@ |
|||
package com.galaxis.rcs.task; |
|||
|
|||
public class TaskManager { |
|||
} |
|||
@ -0,0 +1,68 @@ |
|||
package com.galaxis.rcs.task; |
|||
|
|||
import com.galaxis.rcs.common.entity.AddTaskRequest; |
|||
import com.google.common.base.Strings; |
|||
import com.yvan.logisticsModel.LogisticsRuntime; |
|||
import org.clever.data.jdbc.DaoFactory; |
|||
|
|||
/** |
|||
* 任务服务 |
|||
* 用于处理业务任务的添加 / 取消 / 修改优先级 / 还入 / 暂停 等操作 |
|||
*/ |
|||
public class TaskService { |
|||
|
|||
public final LogisticsRuntime logisticsRuntime; |
|||
|
|||
public TaskService(LogisticsRuntime logisticsRuntime) { |
|||
this.logisticsRuntime = logisticsRuntime; |
|||
} |
|||
|
|||
/** |
|||
* 添加业务任务 |
|||
* |
|||
* @param request 任务请求 |
|||
* @return 业务任务ID |
|||
*/ |
|||
public String addBizTask(AddTaskRequest request) { |
|||
if (Strings.isNullOrEmpty(request.taskExecutorId)) { |
|||
throw new RuntimeException("TaskExecutorId cannot be null or empty"); |
|||
} |
|||
|
|||
Long taskId = DaoFactory.getJdbc().nextId("rcs_task_biz"); |
|||
|
|||
/** |
|||
* TODO: 插入 rcs_task_biz 表, 结构为 |
|||
* biz_task_id bigint not null, |
|||
* task_executor_id varchar(50) not null, |
|||
* task_type varchar(10) |
|||
* lpn varchar(50) |
|||
* priority integer |
|||
* task_from varchar(100) |
|||
* task_to varchar(100) |
|||
* biz_task_status varchar(10) default 'pending' |
|||
* create_at timestamp |
|||
* create_by varchar(50) |
|||
* update_at timestamp |
|||
* update_by varchar(50) |
|||
* |
|||
* create table rcs_task_biz ( |
|||
* biz_task_id bigint not null auto_increment, |
|||
* task_executor_id varchar(50) not null comment '任务执行器ID' default 'N/A', |
|||
* task_type varchar(10) not null comment '任务类型' default 'carry', |
|||
* lpn varchar(50) not null comment '托盘ID', |
|||
* priority integer not null comment '任务优先级', |
|||
* task_from varchar(50) not null comment '任务起始点', |
|||
* task_to varchar(50) not null comment '任务目标点', |
|||
* biz_task_status varchar(10) default 'pending' comment '任务状态', |
|||
* create_at datetime not null comment '创建时间', |
|||
* create_by varchar(50) not null comment '创建人', |
|||
* update_at datetime not null comment '更新时间', |
|||
* update_by varchar(50) not null comment '更新人', |
|||
* |
|||
* primary key (biz_task_id) |
|||
* } |
|||
*/ |
|||
|
|||
return taskId.toString(); |
|||
} |
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
package com.galaxis.rcs.task.dispatcher; |
|||
|
|||
import com.galaxis.rcs.common.entity.RcsTaskBiz; |
|||
import com.galaxis.rcs.plan.Planner; |
|||
import com.galaxis.rcs.plan.TaskPlannerFactory; |
|||
import com.galaxis.rcs.task.TaskDispatchFactory; |
|||
|
|||
public class TaiWanDispatcher { |
|||
|
|||
public void dispatchTask(TaskDispatchFactory factory, RcsTaskBiz tasks) { |
|||
// TODO: 台湾展会的任务分配逻辑
|
|||
} |
|||
|
|||
/** |
|||
* TODO: 分配任务给指定的执行器 |
|||
* |
|||
* @param tasks 任务对象,包含任务的详细信息 |
|||
* @param executorId 执行器ID |
|||
*/ |
|||
public void allocateExecutorBizTask(TaskDispatchFactory factory, RcsTaskBiz tasks, String executorId) { |
|||
// 选定了一个执行器,分配任务给它
|
|||
String executorType = executorId.substring(0, 3); // 假设执行器ID的前3位是车型标识
|
|||
|
|||
Planner planner = TaskPlannerFactory.getPlanner(executorType); |
|||
planner.executePlan(factory.logisticsRuntime, tasks, executorId); |
|||
} |
|||
} |
|||
@ -0,0 +1,23 @@ |
|||
package com.yvan.logisticsEnv; |
|||
|
|||
import lombok.Getter; |
|||
import lombok.Setter; |
|||
|
|||
/** |
|||
* 环境启动参数 |
|||
*/ |
|||
@Getter |
|||
@Setter |
|||
public class EnvStartParam { |
|||
|
|||
/** |
|||
* 是否虚拟仿真环境 |
|||
*/ |
|||
private boolean isVirtual; |
|||
|
|||
/** |
|||
* 时间倍速(仿真环境专用) |
|||
*/ |
|||
private Integer timespeed; |
|||
|
|||
} |
|||
@ -0,0 +1,42 @@ |
|||
package com.yvan.logisticsEnv; |
|||
|
|||
import com.galaxis.rcs.common.enums.EnvStatus; |
|||
import lombok.Getter; |
|||
import lombok.Setter; |
|||
|
|||
/** |
|||
* 物流仓储环境上下文 |
|||
*/ |
|||
@Getter |
|||
@Setter |
|||
public class LogisticsEnv { |
|||
|
|||
private EnvStartParam startParam; |
|||
|
|||
// 环境ID
|
|||
private String envId; |
|||
|
|||
// 环境状态
|
|||
private EnvStatus state; |
|||
|
|||
/** |
|||
* 获取AGV车列表 |
|||
*/ |
|||
void getTasks() { |
|||
|
|||
} |
|||
|
|||
/** |
|||
* 载入地图 |
|||
*/ |
|||
void loadMap() { |
|||
|
|||
} |
|||
|
|||
/** |
|||
* 获取库存分布状态 |
|||
*/ |
|||
void loadInv() { |
|||
|
|||
} |
|||
} |
|||
@ -1,4 +1,30 @@ |
|||
package com.yvan.logisticsEnv; |
|||
|
|||
import java.util.HashMap; |
|||
import java.util.Map; |
|||
|
|||
public class LogisticsEnvManager { |
|||
|
|||
Map<String, LogisticsEnv> envs = new HashMap<>(); |
|||
|
|||
/** |
|||
* 启动参数 |
|||
*/ |
|||
public void startEnv(EnvStartParam param) { |
|||
|
|||
} |
|||
|
|||
/** |
|||
* 复制环境, 返回新环境ID |
|||
*/ |
|||
public String cloneEnv(String envId) { |
|||
throw new RuntimeException(); |
|||
} |
|||
|
|||
/** |
|||
* 重置环境 |
|||
*/ |
|||
public String resetEnv(String envId) { |
|||
throw new RuntimeException(); |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,25 @@ |
|||
package com.yvan.logisticsModel; |
|||
|
|||
import lombok.Data; |
|||
import lombok.Getter; |
|||
|
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 物流单元基类 |
|||
*/ |
|||
@Data |
|||
public class BaseItem { |
|||
String id; |
|||
String t; |
|||
|
|||
/** |
|||
* 变换矩阵, 3x3矩阵, 采用Y轴向上为正, X轴向右, Z轴向前的右手坐标系 |
|||
*/ |
|||
float[][] tf; |
|||
|
|||
/** |
|||
* 物品的自定义数据 |
|||
*/ |
|||
Map<String, Object> dt; |
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
package com.yvan.logisticsModel; |
|||
|
|||
import com.galaxis.rcs.common.entity.RcsTaskBiz; |
|||
import com.galaxis.rcs.common.entity.RcsTaskPlan; |
|||
import com.google.common.collect.Lists; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 物流任务执行单元(如拣货台、小车、AGV、堆垛机、人等) |
|||
*/ |
|||
public class ExecutorItem extends BaseItem { |
|||
|
|||
private final List<RcsTaskPlan> currentPlanList = Lists.newArrayList(); |
|||
|
|||
/** |
|||
* 执行规划任务 |
|||
*/ |
|||
public void executeTaskPlanList(LogisticsRuntime runtime, RcsTaskBiz task, RcsTaskPlan[] planList) { |
|||
if (this.currentPlanList.size() > 0) { |
|||
throw new RuntimeException("has plans, please wait for the current plans to finish"); |
|||
} |
|||
|
|||
// TODO: 开启轮询线程,等待下一个待执行任务
|
|||
// 找到对应类型的 connector,进行报文的发送
|
|||
} |
|||
} |
|||
@ -0,0 +1,17 @@ |
|||
package com.yvan.logisticsModel; |
|||
|
|||
import com.google.common.collect.Maps; |
|||
|
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 物流模型楼层 |
|||
*/ |
|||
public class Floor { |
|||
|
|||
/** |
|||
* 物流固定单元(非箱子容器/非执行器的单元),比如输送线、货架、地标、路线等 |
|||
*/ |
|||
public final Map<String, StaticItem> itemMap = Maps.newConcurrentMap(); |
|||
|
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
package com.yvan.logisticsModel; |
|||
|
|||
/** |
|||
* 物流流动单元(周转箱、托盘等) |
|||
*/ |
|||
public class FlowItem extends BaseItem { |
|||
} |
|||
@ -0,0 +1,13 @@ |
|||
package com.yvan.logisticsModel; |
|||
|
|||
/** |
|||
* 物流模型类 |
|||
*/ |
|||
public class LogisticsModel { |
|||
|
|||
/** |
|||
* 楼层目录 |
|||
*/ |
|||
LogisticsRuntime catalog; |
|||
|
|||
} |
|||
@ -0,0 +1,48 @@ |
|||
package com.yvan.logisticsModel; |
|||
|
|||
import com.galaxis.rcs.task.TaskDispatchFactory; |
|||
import com.galaxis.rcs.task.TaskService; |
|||
import com.google.common.collect.Maps; |
|||
import com.yvan.logisticsEnv.LogisticsEnv; |
|||
|
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 物流 |
|||
*/ |
|||
public class LogisticsRuntime { |
|||
|
|||
/** |
|||
* 物流执行环境 |
|||
*/ |
|||
public final LogisticsEnv logisticsEnv; |
|||
|
|||
/** |
|||
* 任务服务 |
|||
*/ |
|||
public TaskService taskService = new TaskService(this); |
|||
|
|||
/** |
|||
* 任务分配服务 |
|||
*/ |
|||
public TaskDispatchFactory taskDispatchFactory = new TaskDispatchFactory(this); |
|||
|
|||
/** |
|||
* 物流流动单元(周转箱、托盘、纸箱等) |
|||
*/ |
|||
public final Map<String, FlowItem> flowItemMap = Maps.newConcurrentMap(); |
|||
|
|||
/** |
|||
* 物流任务执行单元(如拣货台、小车、AGV、堆垛机、人等) |
|||
*/ |
|||
public final Map<String, ExecutorItem> executorItemMap = Maps.newConcurrentMap(); |
|||
|
|||
/** |
|||
* 楼层目录 catalogCode -> Floor |
|||
*/ |
|||
public final Map<String, Floor> floorMap = Maps.newHashMap(); |
|||
|
|||
public LogisticsRuntime(LogisticsEnv logisticsEnv) { |
|||
this.logisticsEnv = logisticsEnv; |
|||
} |
|||
} |
|||
@ -0,0 +1,24 @@ |
|||
package com.yvan.logisticsModel; |
|||
|
|||
import com.google.common.collect.Maps; |
|||
|
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 物流运行时服务类 |
|||
*/ |
|||
public class LogisticsRuntimeService { |
|||
|
|||
private final Map<String, LogisticsRuntime> runtimeMap = Maps.newConcurrentMap(); |
|||
|
|||
/** |
|||
* 根据 EnvCode 查找物流运行时实例 |
|||
*/ |
|||
public LogisticsRuntime findByEnvCode(String envCode) { |
|||
LogisticsRuntime runtime = runtimeMap.get(envCode); |
|||
if (runtime != null) { |
|||
return runtime; |
|||
} |
|||
throw new RuntimeException("LogisticsRuntime not found for envCode: " + envCode); |
|||
} |
|||
} |
|||
@ -0,0 +1,10 @@ |
|||
package com.yvan.logisticsModel; |
|||
|
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 物流固定单元(非箱子容器/非执行器的单元),比如输送线、货架、地标、路线等 |
|||
*/ |
|||
public class StaticItem extends BaseItem { |
|||
|
|||
} |
|||
@ -1,4 +1,39 @@ |
|||
package com.yvan.logisticsMonitor.task; |
|||
|
|||
public class BizTask { |
|||
/** |
|||
* bizTaskId |
|||
* taskType |
|||
* lpn |
|||
* priority |
|||
* taskFrom |
|||
* taskTo |
|||
* bizTaskStatus |
|||
* createAt |
|||
* createBy |
|||
* description |
|||
*/ |
|||
public interface BizTask { |
|||
// String getBizTaskId();
|
|||
//
|
|||
// String getTaskType();
|
|||
//
|
|||
// String getLpn();
|
|||
//
|
|||
// int getPriority();
|
|||
//
|
|||
// String getTaskFrom();
|
|||
//
|
|||
// String getTaskTo();
|
|||
//
|
|||
// String getBizTaskStatus();
|
|||
//
|
|||
// String getCreateAt();
|
|||
//
|
|||
// String getCreateBy();
|
|||
//
|
|||
// String getUpdateAt();
|
|||
//
|
|||
// String getUpdateBy();
|
|||
//
|
|||
// String getDescription();
|
|||
} |
|||
|
|||
Loading…
Reference in new issue