no message
parent
3b2fbf9385
commit
a05914d0f7
|
|
@ -1,243 +0,0 @@
|
|||
package com.youchain.businessdata.inputJson;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.youchain.basicdata.domain.Point;
|
||||
import com.youchain.basicdata.service.PointService;
|
||||
import com.youchain.businessdata.domain.AgvTask;
|
||||
import com.youchain.utils.BizStatus;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class AgvTaskJsonBuilder {
|
||||
// 常量定义
|
||||
private static final String ORG_ID_WMS = "WMS";//组织
|
||||
private static final String ORG_ID_WCS = "WCS";//组织
|
||||
private static final String PRIORITY = "1";//优先级
|
||||
private static final String NODE_POINT = "NODE_POINT";//节点类型
|
||||
private static final String NODE_SLOT = "NODE_SLOT";//节点类型
|
||||
private static final String PASS_STRATEGY_AUTO = "AUTO";//移动策略
|
||||
private static final String PASS_STRATEGY_MANUAL = "MANUAL";//移动策略
|
||||
|
||||
private final PointService pointService;
|
||||
|
||||
/**
|
||||
* 创建基础AGV任务JSON对象
|
||||
*/
|
||||
private JSONObject createBaseAgvTaskJson(AgvTask agvTask, String orgId, String missionType, String robotType) {
|
||||
JSONObject jsonObject = new JSONObject(true);
|
||||
jsonObject.put("orgId", orgId);
|
||||
jsonObject.put("requestId", String.valueOf(System.currentTimeMillis()));
|
||||
jsonObject.put("missionCode", agvTask.getId());
|
||||
jsonObject.put("missionType", missionType);
|
||||
jsonObject.put("viewBoardType", "");
|
||||
jsonObject.put("robotType", robotType);
|
||||
jsonObject.put("priority", PRIORITY);
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建叉车任务JSON
|
||||
*/
|
||||
public String createForkMissionJson(AgvTask agvTask) {
|
||||
//基础对象
|
||||
JSONObject jsonObject = createBaseAgvTaskJson(agvTask, ORG_ID_WMS, agvTask.getJobType(), "FORKLIFT");
|
||||
jsonObject.put("containerCode", agvTask.getStockCode());
|
||||
jsonObject.put("robotId", "");
|
||||
|
||||
//创建json数组
|
||||
JSONArray missionDataArray = new JSONArray();
|
||||
|
||||
//根据任务类型取节点类型
|
||||
boolean isPickTask = BizStatus.PICK.equals(agvTask.getType());
|
||||
String startNodeType = isPickTask ? NODE_SLOT : NODE_POINT;
|
||||
String endNodeType = isPickTask ? NODE_POINT : NODE_SLOT;
|
||||
|
||||
//起点
|
||||
missionDataArray.add(createForkMissionNode(1, agvTask.getStartSlotCode(), startNodeType));
|
||||
|
||||
//终点
|
||||
missionDataArray.add(createForkMissionNode(2, agvTask.getEndSlotCode(), endNodeType));
|
||||
|
||||
//添加任务数据
|
||||
jsonObject.put("missionData", missionDataArray);
|
||||
return jsonObject.toJSONString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建叉车任务数据节点
|
||||
*/
|
||||
private JSONObject createForkMissionNode(int sequence, String position, String nodeType) {
|
||||
JSONObject node = new JSONObject(true);
|
||||
node.put("sequence", sequence);
|
||||
node.put("position", position);
|
||||
node.put("nodeType", nodeType);
|
||||
node.put("stackNumber", 0);
|
||||
node.put("actionConfirm", false);
|
||||
return node;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建货架任务JSON
|
||||
*/
|
||||
public String createRackMissionJson(AgvTask agvTask) {
|
||||
//基础对象
|
||||
JSONObject jsonObject = createBaseAgvTaskJson(agvTask, ORG_ID_WMS, agvTask.getJobType(), "LIFT");
|
||||
|
||||
//创建json数组
|
||||
JSONArray missionDataArray = new JSONArray();
|
||||
|
||||
//创建任务数据
|
||||
missionDataArray.add(createRackMissionNode(agvTask));
|
||||
|
||||
//添加任务数据
|
||||
jsonObject.put("missionData", missionDataArray);
|
||||
return jsonObject.toJSONString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建货架任务数据节点
|
||||
*/
|
||||
private JSONObject createRackMissionNode(AgvTask agvTask) {
|
||||
JSONObject node = new JSONObject(true);
|
||||
node.put("sequence", 1);//序号
|
||||
node.put("containerCode", agvTask.getStockCode());//容器
|
||||
node.put("startPosition", agvTask.getStartSlotCode());//点位
|
||||
node.put("startPositionType", "NODE_POINT");//
|
||||
node.put("endPosition", agvTask.getEndSlotCode());//点位
|
||||
node.put("endPositionType", "NODE_POINT");//
|
||||
return node;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建滚筒任务JSON
|
||||
*/
|
||||
public String createRollerJson(AgvTask agvTask) {
|
||||
//基础对象
|
||||
JSONObject jsonObject = createBaseAgvTaskJson(agvTask, ORG_ID_WMS, agvTask.getJobType(), "ROLLER");
|
||||
jsonObject.put("lockRobotAfterFinish", false);
|
||||
|
||||
//创建json数组
|
||||
JSONArray missionDataArray = new JSONArray();
|
||||
|
||||
//起点
|
||||
missionDataArray.add(createRollerNode(1, agvTask.getStartSlotCode(), "ROLLER_RECEIVE", agvTask.getStartSlotCode(), true, "AUTO"));
|
||||
|
||||
//途径点
|
||||
missionDataArray.add(createRollerNode(2, "FX001", "", "", false, "MANUAL"));
|
||||
|
||||
//终点
|
||||
missionDataArray.add(createRollerNode(3, agvTask.getEndSlotCode(), "ROLLER_SEND", agvTask.getEndSlotCode(), true, "AUTO"));
|
||||
|
||||
//添加任务数据
|
||||
jsonObject.put("missionData", missionDataArray);
|
||||
return jsonObject.toJSONString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建滚筒任务数据节点
|
||||
*/
|
||||
private JSONObject createRollerNode(int sequence, String position, String actionType, String deviceCode, boolean actionConfirm, String passStrategy) {
|
||||
JSONObject node = new JSONObject(true);
|
||||
node.put("sequence", sequence);
|
||||
node.put("position", position);
|
||||
node.put("type", NODE_POINT);
|
||||
node.put("actionType", actionType);
|
||||
node.put("binCode", "");
|
||||
node.put("rollerLevel", 1);
|
||||
node.put("deviceCode", deviceCode);
|
||||
node.put("actionConfirm", actionConfirm);
|
||||
node.put("passStrategy", passStrategy);
|
||||
return node;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建牵引车任务JSON
|
||||
*/
|
||||
public String createTuggerJson(AgvTask agvTask, List<String> tugModels) {
|
||||
JSONObject jsonObject = createBaseAgvTaskJson(agvTask, ORG_ID_WCS, agvTask.getJobType(), "TUGGER");
|
||||
jsonObject.put("templateCode", "");
|
||||
jsonObject.put("lockRobotAfterFinish", false);
|
||||
jsonObject.put("unlockRobotId", "");
|
||||
jsonObject.put("unlockMissionCode", "");
|
||||
|
||||
// 根据区域调整参数
|
||||
Point point = pointService.validatePoint(agvTask.getStartSlotCode());
|
||||
|
||||
//创建json数组
|
||||
JSONArray missionDataArray = new JSONArray();
|
||||
|
||||
// 起点
|
||||
missionDataArray.add(createTuggerStartNode(agvTask.getStartSlotCode(), tugModels));
|
||||
|
||||
//途径点
|
||||
List<String> stations = parseStations(agvTask.getEndSlotCode());
|
||||
for (int i = 0; i < stations.size(); i++) {
|
||||
missionDataArray.add(createTuggerWayNode(i + 2, stations.get(i)));
|
||||
}
|
||||
|
||||
//终点
|
||||
missionDataArray.add(createTuggerEndNode(stations.size() + 2, point.getBeatCode()));
|
||||
|
||||
jsonObject.put("missionData", missionDataArray);
|
||||
return jsonObject.toJSONString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建牵引车任务起点数据节点
|
||||
*/
|
||||
private JSONObject createTuggerStartNode(String position, List<String> tugModels) {
|
||||
JSONObject node = new JSONObject(true);
|
||||
node.put("sequence", 1);
|
||||
node.put("type", NODE_POINT);
|
||||
node.put("position", position);
|
||||
node.put("actionType", "TUGGER_ATTACH");
|
||||
node.put("tugCount", tugModels.size());
|
||||
node.put("passStrategy", PASS_STRATEGY_AUTO);
|
||||
node.put("tugModels", tugModels);
|
||||
return node;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建牵引车任务途径点节点
|
||||
*/
|
||||
private JSONObject createTuggerWayNode(int sequence, String position) {
|
||||
JSONObject node = new JSONObject(true);
|
||||
node.put("sequence", sequence);
|
||||
node.put("type", NODE_POINT);
|
||||
node.put("position", position);
|
||||
node.put("passStrategy", PASS_STRATEGY_MANUAL);
|
||||
return node;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建牵引车任务终点节点
|
||||
*/
|
||||
private JSONObject createTuggerEndNode(int sequence, String position) {
|
||||
JSONObject node = new JSONObject(true);
|
||||
node.put("sequence", sequence);
|
||||
node.put("type", NODE_POINT);
|
||||
node.put("position", position);
|
||||
node.put("actionType", "TUGGER_DETACH");
|
||||
node.put("passStrategy", PASS_STRATEGY_AUTO);
|
||||
node.put("waitingMillis", 0);
|
||||
return node;
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析站点字符串
|
||||
*/
|
||||
private List<String> parseStations(String stationString) {
|
||||
return Arrays.stream(stationString.split(","))
|
||||
.map(String::trim)
|
||||
.filter(s -> !s.isEmpty())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
package com.youchain.businessdata.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.youchain.basicdata.domain.Point;
|
||||
import com.youchain.basicdata.domain.Stock;
|
||||
import com.youchain.basicdata.service.PointService;
|
||||
import com.youchain.basicdata.service.StockService;
|
||||
import com.youchain.businessdata.domain.AgvTask;
|
||||
import com.youchain.businessdata.inputJson.AgvTaskJsonBuilder;
|
||||
import com.youchain.businessdata.inputJson.Dolly;
|
||||
import com.youchain.businessdata.inputJson.UpdateTuggerTrailerInfo;
|
||||
import com.youchain.businessdata.service.*;
|
||||
|
|
@ -28,12 +28,20 @@ import java.util.stream.Collectors;
|
|||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class KMReServiceImpl implements KMReService {
|
||||
// 常量定义
|
||||
private static final String ORG_ID_WMS = "WMS";//组织
|
||||
private static final String ORG_ID_WCS = "WCS";//组织
|
||||
private static final String PRIORITY = "1";//优先级
|
||||
private static final String NODE_POINT = "NODE_POINT";//节点类型
|
||||
private static final String NODE_SLOT = "NODE_SLOT";//节点类型
|
||||
private static final String PASS_STRATEGY_AUTO = "AUTO";//移动策略
|
||||
private static final String PASS_STRATEGY_MANUAL = "MANUAL";//移动策略
|
||||
|
||||
private final DictService dictService;
|
||||
private final StockService stockService;
|
||||
private final PointService pointService;
|
||||
private final AgvTaskService agvTaskService;
|
||||
private final LesService lesService;
|
||||
private final AgvTaskJsonBuilder agvTaskJsonBuilder;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -162,6 +170,20 @@ public class KMReServiceImpl implements KMReService {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建基础AGV任务JSON对象
|
||||
*/
|
||||
private JSONObject createBaseAgvTaskJson(AgvTask agvTask, String orgId, String missionType, String robotType) {
|
||||
JSONObject jsonObject = new JSONObject(true);
|
||||
jsonObject.put("orgId", orgId);
|
||||
jsonObject.put("requestId", String.valueOf(System.currentTimeMillis()));
|
||||
jsonObject.put("missionCode", agvTask.getId());
|
||||
jsonObject.put("missionType", missionType);
|
||||
jsonObject.put("viewBoardType", "");
|
||||
jsonObject.put("robotType", robotType);
|
||||
jsonObject.put("priority", PRIORITY);
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* 叉车任务Json
|
||||
|
|
@ -170,7 +192,42 @@ public class KMReServiceImpl implements KMReService {
|
|||
*/
|
||||
@Override
|
||||
public String createForkMissionJson(AgvTask agvTask) {
|
||||
return agvTaskJsonBuilder.createForkMissionJson(agvTask);
|
||||
//基础对象
|
||||
JSONObject jsonObject = createBaseAgvTaskJson(agvTask, ORG_ID_WMS, agvTask.getJobType(), "FORKLIFT");
|
||||
jsonObject.put("containerCode", agvTask.getStockCode());
|
||||
jsonObject.put("robotId", "");
|
||||
|
||||
//创建json数组
|
||||
JSONArray missionDataArray = new JSONArray();
|
||||
|
||||
//根据任务类型取节点类型
|
||||
boolean isPickTask = BizStatus.PICK.equals(agvTask.getType());
|
||||
String startNodeType = isPickTask ? NODE_SLOT : NODE_POINT;
|
||||
String endNodeType = isPickTask ? NODE_POINT : NODE_SLOT;
|
||||
|
||||
//起点
|
||||
missionDataArray.add(createForkMissionNode(1, agvTask.getStartSlotCode(), startNodeType));
|
||||
|
||||
//终点
|
||||
missionDataArray.add(createForkMissionNode(2, agvTask.getEndSlotCode(), endNodeType));
|
||||
|
||||
//添加任务数据
|
||||
jsonObject.put("missionData", missionDataArray);
|
||||
return jsonObject.toJSONString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 创建叉车任务数据节点
|
||||
*/
|
||||
private JSONObject createForkMissionNode(int sequence, String position, String nodeType) {
|
||||
JSONObject node = new JSONObject(true);
|
||||
node.put("sequence", sequence);
|
||||
node.put("position", position);
|
||||
node.put("nodeType", nodeType);
|
||||
node.put("stackNumber", 0);
|
||||
node.put("actionConfirm", false);
|
||||
return node;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -180,17 +237,150 @@ public class KMReServiceImpl implements KMReService {
|
|||
*/
|
||||
@Override
|
||||
public String createRackMissionJson(AgvTask agvTask) {
|
||||
return agvTaskJsonBuilder.createRackMissionJson(agvTask);
|
||||
//基础对象
|
||||
JSONObject jsonObject = createBaseAgvTaskJson(agvTask, ORG_ID_WMS, agvTask.getJobType(), "LIFT");
|
||||
|
||||
//创建json数组
|
||||
JSONArray missionDataArray = new JSONArray();
|
||||
|
||||
//创建任务数据
|
||||
missionDataArray.add(createRackMissionNode(agvTask));
|
||||
|
||||
//添加任务数据
|
||||
jsonObject.put("missionData", missionDataArray);
|
||||
return jsonObject.toJSONString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建货架任务数据节点
|
||||
*/
|
||||
private JSONObject createRackMissionNode(AgvTask agvTask) {
|
||||
JSONObject node = new JSONObject(true);
|
||||
node.put("sequence", 1);//序号
|
||||
node.put("containerCode", agvTask.getStockCode());//容器
|
||||
node.put("startPosition", agvTask.getStartSlotCode());//点位
|
||||
node.put("startPositionType", "NODE_POINT");//
|
||||
node.put("endPosition", agvTask.getEndSlotCode());//点位
|
||||
node.put("endPositionType", "NODE_POINT");//
|
||||
return node;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createRollerJson(AgvTask agvTask) {
|
||||
return agvTaskJsonBuilder.createRollerJson(agvTask);
|
||||
//基础对象
|
||||
JSONObject jsonObject = createBaseAgvTaskJson(agvTask, ORG_ID_WMS, agvTask.getJobType(), "ROLLER");
|
||||
jsonObject.put("lockRobotAfterFinish", false);
|
||||
|
||||
//创建json数组
|
||||
JSONArray missionDataArray = new JSONArray();
|
||||
|
||||
//起点
|
||||
missionDataArray.add(createRollerNode(1, agvTask.getStartSlotCode(), "ROLLER_RECEIVE", agvTask.getStartSlotCode(), true, "AUTO"));
|
||||
|
||||
//途径点
|
||||
missionDataArray.add(createRollerNode(2, "FX001", "", "", false, "MANUAL"));
|
||||
|
||||
//终点
|
||||
missionDataArray.add(createRollerNode(3, agvTask.getEndSlotCode(), "ROLLER_SEND", agvTask.getEndSlotCode(), true, "AUTO"));
|
||||
|
||||
//添加任务数据
|
||||
jsonObject.put("missionData", missionDataArray);
|
||||
return jsonObject.toJSONString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建滚筒任务数据节点
|
||||
*/
|
||||
private JSONObject createRollerNode(int sequence, String position, String actionType, String deviceCode, boolean actionConfirm, String passStrategy) {
|
||||
JSONObject node = new JSONObject(true);
|
||||
node.put("sequence", sequence);
|
||||
node.put("position", position);
|
||||
node.put("type", NODE_POINT);
|
||||
node.put("actionType", actionType);
|
||||
node.put("binCode", "");
|
||||
node.put("rollerLevel", 1);
|
||||
node.put("deviceCode", deviceCode);
|
||||
node.put("actionConfirm", actionConfirm);
|
||||
node.put("passStrategy", passStrategy);
|
||||
return node;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createTuggerJson(AgvTask agvTask, List<String> tugModels) {
|
||||
return agvTaskJsonBuilder.createTuggerJson(agvTask, tugModels);
|
||||
JSONObject jsonObject = createBaseAgvTaskJson(agvTask, ORG_ID_WCS, agvTask.getJobType(), "TUGGER");
|
||||
jsonObject.put("templateCode", "");
|
||||
jsonObject.put("lockRobotAfterFinish", false);
|
||||
jsonObject.put("unlockRobotId", "");
|
||||
jsonObject.put("unlockMissionCode", "");
|
||||
|
||||
// 根据区域调整参数
|
||||
Point point = pointService.validatePoint(agvTask.getStartSlotCode());
|
||||
|
||||
//创建json数组
|
||||
JSONArray missionDataArray = new JSONArray();
|
||||
|
||||
// 起点
|
||||
missionDataArray.add(createTuggerStartNode(agvTask.getStartSlotCode(), tugModels));
|
||||
|
||||
//途径点
|
||||
List<String> stations = parseStations(agvTask.getEndSlotCode());
|
||||
for (int i = 0; i < stations.size(); i++) {
|
||||
missionDataArray.add(createTuggerWayNode(i + 2, stations.get(i)));
|
||||
}
|
||||
|
||||
//终点
|
||||
missionDataArray.add(createTuggerEndNode(stations.size() + 2, point.getBeatCode()));
|
||||
|
||||
jsonObject.put("missionData", missionDataArray);
|
||||
return jsonObject.toJSONString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建牵引车任务起点数据节点
|
||||
*/
|
||||
private JSONObject createTuggerStartNode(String position, List<String> tugModels) {
|
||||
JSONObject node = new JSONObject(true);
|
||||
node.put("sequence", 1);
|
||||
node.put("type", NODE_POINT);
|
||||
node.put("position", position);
|
||||
node.put("actionType", "TUGGER_ATTACH");
|
||||
node.put("tugCount", tugModels.size());
|
||||
node.put("passStrategy", PASS_STRATEGY_AUTO);
|
||||
node.put("tugModels", tugModels);
|
||||
return node;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建牵引车任务途径点节点
|
||||
*/
|
||||
private JSONObject createTuggerWayNode(int sequence, String position) {
|
||||
JSONObject node = new JSONObject(true);
|
||||
node.put("sequence", sequence);
|
||||
node.put("type", NODE_POINT);
|
||||
node.put("position", position);
|
||||
node.put("passStrategy", PASS_STRATEGY_MANUAL);
|
||||
return node;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建牵引车任务终点节点
|
||||
*/
|
||||
private JSONObject createTuggerEndNode(int sequence, String position) {
|
||||
JSONObject node = new JSONObject(true);
|
||||
node.put("sequence", sequence);
|
||||
node.put("type", NODE_POINT);
|
||||
node.put("position", position);
|
||||
node.put("actionType", "TUGGER_DETACH");
|
||||
node.put("passStrategy", PASS_STRATEGY_AUTO);
|
||||
node.put("waitingMillis", 0);
|
||||
return node;
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析站点字符串
|
||||
*/
|
||||
private List<String> parseStations(String stationString) {
|
||||
return Arrays.stream(stationString.split(",")).map(String::trim).filter(s -> !s.isEmpty()).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -381,17 +571,7 @@ public class KMReServiceImpl implements KMReService {
|
|||
if (bool) {
|
||||
throw new BadRequestException("任务已重新生成,请勿重复操作! ");
|
||||
}
|
||||
AgvTask newAgvTask = AgvTask.builder()
|
||||
.stockCode(agvTask.getStockCode())
|
||||
.type(agvTask.getType())
|
||||
.jobType(agvTask.getJobType())
|
||||
.jobPriority(1)
|
||||
.startSlotCode(agvTask.getStartSlotCode())
|
||||
.endSlotCode(agvTask.getEndSlotCode())
|
||||
.slotCode(agvTask.getSlotCode())
|
||||
.status(BizStatus.OPEN)
|
||||
.lineSlotCode(agvTask.getLineSlotCode())
|
||||
.build();
|
||||
AgvTask newAgvTask = AgvTask.builder().stockCode(agvTask.getStockCode()).type(agvTask.getType()).jobType(agvTask.getJobType()).jobPriority(1).startSlotCode(agvTask.getStartSlotCode()).endSlotCode(agvTask.getEndSlotCode()).slotCode(agvTask.getSlotCode()).status(BizStatus.OPEN).lineSlotCode(agvTask.getLineSlotCode()).build();
|
||||
agvTaskService.create(newAgvTask);
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue