agv常用请求接口实体和和设备参数获取
This commit is contained in:
16
ruoyi-admin/src/main/java/com/ruoyi/common/Constant.java
Normal file
16
ruoyi-admin/src/main/java/com/ruoyi/common/Constant.java
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
package com.ruoyi.common;
|
||||||
|
|
||||||
|
|
||||||
|
public class Constant {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* REST协议接口基础地址
|
||||||
|
*/
|
||||||
|
public static final String BASEURL_REST = "http://IP:PORT/rcms/services/rest/hikRpcService/";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AGV状态协议接口基础地址
|
||||||
|
*/
|
||||||
|
public static final String BASEURL_AGV = "http://IP:PORT/rcms-dps/rest/queryAgvStatus/";
|
||||||
|
|
||||||
|
}
|
||||||
@@ -5,6 +5,9 @@ import lombok.Data;
|
|||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
import javax.validation.constraints.Size;
|
import javax.validation.constraints.Size;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 【取消任务】请求接口
|
||||||
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class CancelTaskRequest {
|
public class CancelTaskRequest {
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,9 @@ package com.ruoyi.device.agv.domain.continueTask;
|
|||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 【继续执行任务】请求接口
|
||||||
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class ContinueTaskRequest {
|
public class ContinueTaskRequest {
|
||||||
|
|
||||||
@@ -63,5 +66,5 @@ public class ContinueTaskRequest {
|
|||||||
* 下一个位置信息
|
* 下一个位置信息
|
||||||
* 在任务类型中配置外部设置时需要传入,否则不需要设置。待现场地图部署、配置完成后可获取。
|
* 在任务类型中配置外部设置时需要传入,否则不需要设置。待现场地图部署、配置完成后可获取。
|
||||||
*/
|
*/
|
||||||
private NextPositionCode nextPositionCode;
|
private NextPositionCodeData nextPositionCode;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.ruoyi.device.agv.domain.continueTask;
|
package com.ruoyi.device.agv.domain.continueTask;
|
||||||
|
|
||||||
public class NextPositionCode {
|
public class NextPositionCodeData {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 位置编号
|
* 位置编号
|
||||||
@@ -5,6 +5,9 @@ import lombok.Data;
|
|||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 【生成AGV任务】请求接口
|
||||||
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class GenAgvSchedulingTaskRequest {
|
public class GenAgvSchedulingTaskRequest {
|
||||||
/**
|
/**
|
||||||
@@ -76,7 +79,7 @@ public class GenAgvSchedulingTaskRequest {
|
|||||||
* 位置路径
|
* 位置路径
|
||||||
* AGV关键路径位置集合,与任务类型中模板配置的位置路径一一对应。待现场地图部署、配置完成后可获取
|
* AGV关键路径位置集合,与任务类型中模板配置的位置路径一一对应。待现场地图部署、配置完成后可获取
|
||||||
*/
|
*/
|
||||||
private List<PositionCode> positionCodePath;
|
private List<PositionCodeData> positionCodePath;
|
||||||
/**
|
/**
|
||||||
* 货架编号
|
* 货架编号
|
||||||
* 不指定货架可以为空
|
* 不指定货架可以为空
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package com.ruoyi.device.agv.domain.genAgvSchedulingTask;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class PositionCode {
|
public class PositionCodeData {
|
||||||
/**
|
/**
|
||||||
* 位置编号 - 单个编号不超过64位
|
* 位置编号 - 单个编号不超过64位
|
||||||
*/
|
*/
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
package com.ruoyi.device.agv.domain.queryAgvStatus;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class AgvStatusData {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 机器人编号
|
||||||
|
*/
|
||||||
|
private String robotCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 机器人方向 (范围 -180~360度)
|
||||||
|
*/
|
||||||
|
private String robotDir;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 机器人IP
|
||||||
|
*/
|
||||||
|
private String robotIp;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 机器人电量, 范围: 0-100
|
||||||
|
*/
|
||||||
|
private String battery;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 机器人 x 坐标,单位:毫米
|
||||||
|
*/
|
||||||
|
private String posX;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 机器人 y 坐标,单位:毫米
|
||||||
|
*/
|
||||||
|
private String posY;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 机器人所在地图
|
||||||
|
*/
|
||||||
|
private String mapCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 机器人当前速度, 单位: mm/s
|
||||||
|
*/
|
||||||
|
private String speed;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 机器人状态
|
||||||
|
* AGV常见状态编号和描述见附件6.1
|
||||||
|
*/
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否已被排除,被排除后不接受新任务(1-排除,0-正常)
|
||||||
|
*/
|
||||||
|
private String exclType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否暂停 0-否 1-是
|
||||||
|
*/
|
||||||
|
private String stop;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 背货架的编号
|
||||||
|
*/
|
||||||
|
private String podCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 背货架的方向
|
||||||
|
*/
|
||||||
|
private String podDir;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 执行路径,单位是毫米, 格式[x,y,dir]
|
||||||
|
* 示例:["[x,y,dir]","[x,y,dir]"]
|
||||||
|
*/
|
||||||
|
private List<String> path;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package com.ruoyi.device.agv.domain.queryAgvStatus;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过请求参数, 查询 AGV 状态信息,包括电池电量。
|
||||||
|
* 调用频次: 100车以下:5秒, 100~200车:10秒, 200 ~300车:15秒
|
||||||
|
* 调用路径: http://IP:8182/rcms-dps/rest/queryAgvStatus
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class QueryAgvStatusRequest {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 请求编号,每个请求都要一个唯一编号,同一个请求重复提交,使用同一编号。
|
||||||
|
*/
|
||||||
|
private String reqCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 请求时间戳,格式: "yyyy-MM-dd HH:mm:ss"
|
||||||
|
*/
|
||||||
|
private String reqTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 客户端编号,如PDA,HCWMS等。
|
||||||
|
*/
|
||||||
|
private String clientCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 令牌号,由调度系统颁发。
|
||||||
|
*/
|
||||||
|
private String tokenCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 地图编号
|
||||||
|
*/
|
||||||
|
private String mapCode;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package com.ruoyi.device.agv.domain.queryAgvStatus;
|
||||||
|
|
||||||
|
import com.ruoyi.device.agv.domain.ResponseBase;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class QueryAgvStatusResponse extends ResponseBase {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据列表
|
||||||
|
*/
|
||||||
|
private List<AgvStatusData> data;
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package com.ruoyi.device.agv.domain.queryTaskStatus;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过任务编号查询任务当前执行状态,支持批量查询。
|
||||||
|
* 参数错误或者任务单未找到返回均为成功。
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class QueryTaskStatusRequest {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 请求编号,每个请求都要一个唯一编号,同一个请求重复提交,使用同一编号。
|
||||||
|
*/
|
||||||
|
private String reqCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 请求时间戳,格式: "yyyy-MM-dd HH:mm:ss"
|
||||||
|
*/
|
||||||
|
private String reqTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 客户端编号,如PDA,HCWMS等。
|
||||||
|
*/
|
||||||
|
private String clientCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 令牌号,由调度系统颁发。
|
||||||
|
*/
|
||||||
|
private String tokenCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AGV编号
|
||||||
|
*/
|
||||||
|
private String agvCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 任务单编号数组,任务单编号与AGV编号只能传其中之一
|
||||||
|
*/
|
||||||
|
private List<String> taskCodes;
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package com.ruoyi.device.agv.domain.queryTaskStatus;
|
||||||
|
|
||||||
|
import com.ruoyi.device.agv.domain.ResponseBase;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class QueryTaskStatusResponse extends ResponseBase {
|
||||||
|
/**
|
||||||
|
* 数据列表
|
||||||
|
*/
|
||||||
|
private List<TaskStatusData> data;
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package com.ruoyi.device.agv.domain.queryTaskStatus;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class TaskStatusData {
|
||||||
|
/**
|
||||||
|
* 任务单编号
|
||||||
|
*/
|
||||||
|
private String taskCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 任务类型
|
||||||
|
*/
|
||||||
|
private String taskTyp;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 任务状态:1-已创建,2-正在执行,5-取消完成,9-已结束, 10-被打断
|
||||||
|
*/
|
||||||
|
private String taskStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AGV编号, 任务分配车后有值
|
||||||
|
*/
|
||||||
|
private String agvCode;
|
||||||
|
}
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
package com.ruoyi.schedule.data;
|
package com.ruoyi.schedule.data;
|
||||||
|
|
||||||
|
|
||||||
import com.ruoyi.schedule.plc.domain.ConvPortRead;
|
import com.ruoyi.schedule.plc.domain.ConvPTLInRead;
|
||||||
|
import com.ruoyi.schedule.plc.domain.ConvPTLOutRead;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.plc4x.java.PlcDriverManager;
|
import org.apache.plc4x.java.PlcDriverManager;
|
||||||
import org.apache.plc4x.java.api.PlcConnection;
|
import org.apache.plc4x.java.api.PlcConnection;
|
||||||
@@ -42,13 +43,63 @@ public class ConvConnection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取所有输送机状态参数
|
* 获取所有PTL入口输送机状态参数
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public List<ConvPortRead> getConvPortStatus() {
|
public List<ConvPTLInRead> getConvPTLIn() {
|
||||||
|
|
||||||
List<ConvPortRead> convPorts = new ArrayList<>();
|
List<ConvPTLInRead> convPTLIn = new ArrayList<>();
|
||||||
|
|
||||||
|
for (int i = 0; i < convPortCount; i++) {
|
||||||
|
try {
|
||||||
|
PlcReadRequest.Builder builder = convConnection.readRequestBuilder();
|
||||||
|
|
||||||
|
builder.addItem("value-test","%M0.0:BOOL");
|
||||||
|
builder.addItem("conv-inPostion","%DB501.DBW" + (0 + i * 30) + ":INT");
|
||||||
|
// builder.addItem("conv-height","%DB501.DBW" + (2 + i * 30) + ":INT");
|
||||||
|
builder.addItem("conv-isException","%DB501.DBD" + (4 + i * 30) + ":DINT");
|
||||||
|
builder.addItem("conv-free","%DB501.DBW" + (6 + i * 30) + ":INT");
|
||||||
|
builder.addItem("conv-taskId","%DB501.DBD" + (8 + i * 30) + ":INT");
|
||||||
|
// builder.addItem("conv-palletId","%DB501.DBD" + (16 + i * 30) + ":STRING");
|
||||||
|
|
||||||
|
PlcReadRequest readRequest = builder.build();
|
||||||
|
|
||||||
|
PlcReadResponse response=readRequest.execute().get(2000, TimeUnit.MILLISECONDS);
|
||||||
|
|
||||||
|
if (response.getResponseCode("value-test") == PlcResponseCode.OK) {
|
||||||
|
convPTLIn.get(i).setInPostion(response.getInteger("conv-inPostion"));
|
||||||
|
// convPTLIn.get(i).setHeight(response.getInteger("conv-height"));
|
||||||
|
convPTLIn.get(i).setIsException(response.getInteger("conv-isException"));
|
||||||
|
convPTLIn.get(i).setFree(response.getInteger("conv-free"));
|
||||||
|
convPTLIn.get(i).setTaskId(response.getString("conv-taskId"));
|
||||||
|
// convPTLIn.get(i).setPalletId(response.getString("conv-palletId"));
|
||||||
|
|
||||||
|
}else{
|
||||||
|
log.warn("【获取PTL拣选入口输送机状态】获取状态参数失败:" + response.getResponseCode("value-test"));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn("【获取PTL拣选入口输送机状态】获取状态参数失败:" + e.getMessage());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return convPTLIn;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有PTL出口输送机状态参数
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public List<ConvPTLOutRead> getConvPTLOut() {
|
||||||
|
|
||||||
|
List<ConvPTLOutRead> convPTLOut = new ArrayList<>();
|
||||||
|
|
||||||
for (int i = 0; i < convPortCount; i++) {
|
for (int i = 0; i < convPortCount; i++) {
|
||||||
try {
|
try {
|
||||||
@@ -67,25 +118,25 @@ public class ConvConnection {
|
|||||||
PlcReadResponse response=readRequest.execute().get(2000, TimeUnit.MILLISECONDS);
|
PlcReadResponse response=readRequest.execute().get(2000, TimeUnit.MILLISECONDS);
|
||||||
|
|
||||||
if (response.getResponseCode("value-test") == PlcResponseCode.OK) {
|
if (response.getResponseCode("value-test") == PlcResponseCode.OK) {
|
||||||
convPorts.get(i).setInPostion(response.getInteger("conv-inPostion"));
|
convPTLOut.get(i).setInPostion(response.getInteger("conv-inPostion"));
|
||||||
convPorts.get(i).setHeight(response.getInteger("conv-height"));
|
convPTLOut.get(i).setHeight(response.getInteger("conv-height"));
|
||||||
convPorts.get(i).setIsException(response.getInteger("conv-isException"));
|
convPTLOut.get(i).setIsException(response.getInteger("conv-isException"));
|
||||||
convPorts.get(i).setFree(response.getInteger("conv-free"));
|
convPTLOut.get(i).setFree(response.getInteger("conv-free"));
|
||||||
convPorts.get(i).setTaskId(response.getString("conv-taskId"));
|
convPTLOut.get(i).setTaskId(response.getString("conv-taskId"));
|
||||||
convPorts.get(i).setPalletId(response.getString("conv-palletId"));
|
convPTLOut.get(i).setPalletId(response.getString("conv-palletId"));
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
log.warn("【获取出入口输送机状态】获取状态参数失败:" + response.getResponseCode("value-test"));
|
log.warn("【获取PTL拣选出口输送机状态】获取状态参数失败:" + response.getResponseCode("value-test"));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.warn("【获取出入口输送机状态】获取状态参数失败:" + e.getMessage());
|
log.warn("【获取PTL拣选出口输送机状态】获取状态参数失败:" + e.getMessage());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return convPorts;
|
return convPTLOut;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,4 +43,10 @@ public class ConvBaseRead {
|
|||||||
*/
|
*/
|
||||||
private Integer inPostionForStockOut;
|
private Integer inPostionForStockOut;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否异常
|
||||||
|
* 0-正常 1-异常
|
||||||
|
*/
|
||||||
|
private Integer isException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package com.ruoyi.schedule.plc.domain;
|
||||||
|
|
||||||
|
public class ConvBaseWrite {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package com.ruoyi.schedule.plc.domain;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PTL拣选输送线入口输送机-读plc状态
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class ConvPTLInRead extends ConvBaseRead {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 外形检测-高度
|
||||||
|
* 1-500mm 2-800mm 3-1000mm
|
||||||
|
*/
|
||||||
|
// private Integer height;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 托盘码
|
||||||
|
*/
|
||||||
|
// private String palletId;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package com.ruoyi.schedule.plc.domain;
|
||||||
|
|
||||||
|
public class ConvPTLInWrite extends ConvBaseWrite {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package com.ruoyi.schedule.plc.domain;
|
||||||
|
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PTL拣选输送线出口输送机
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class ConvPTLOutRead extends ConvBaseRead {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否异常
|
||||||
|
* 0-正常 1-异常
|
||||||
|
*/
|
||||||
|
private Integer isException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 外形检测-高度
|
||||||
|
* 1-500mm 2-800mm 3-1000mm
|
||||||
|
*/
|
||||||
|
private Integer height;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 托盘码
|
||||||
|
*/
|
||||||
|
private String palletId;
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package com.ruoyi.schedule.plc.domain;
|
||||||
|
|
||||||
|
|
||||||
|
public class ConvPTLOutWrite extends ConvBaseWrite{
|
||||||
|
}
|
||||||
119
ruoyi-admin/src/main/java/com/ruoyi/schedule/task/Execution.java
Normal file
119
ruoyi-admin/src/main/java/com/ruoyi/schedule/task/Execution.java
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
package com.ruoyi.schedule.task;
|
||||||
|
|
||||||
|
import cn.hutool.http.HttpRequest;
|
||||||
|
import cn.hutool.http.HttpResponse;
|
||||||
|
import com.alibaba.fastjson2.JSON;
|
||||||
|
import com.ruoyi.common.Constant;
|
||||||
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
import com.ruoyi.device.agv.domain.genAgvSchedulingTask.GenAgvSchedulingTaskRequest;
|
||||||
|
import com.ruoyi.device.agv.domain.genAgvSchedulingTask.GenAgvSchedulingTaskResponse;
|
||||||
|
import com.ruoyi.device.agv.domain.queryAgvStatus.QueryAgvStatusRequest;
|
||||||
|
import com.ruoyi.device.agv.domain.queryAgvStatus.QueryAgvStatusResponse;
|
||||||
|
import com.ruoyi.schedule.job.mydojob.domain.MydoJob;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 向AGV/CTU下发指令
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
public class Execution {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询是否有wcs任务
|
||||||
|
*/
|
||||||
|
@PostConstruct
|
||||||
|
public List<MydoJob> getmydoJob(){
|
||||||
|
|
||||||
|
String url = "http://127.0.0.1:8080/job/inmydoJob/listAll";
|
||||||
|
|
||||||
|
HttpResponse response = HttpRequest.get(url).execute();
|
||||||
|
|
||||||
|
List<MydoJob> mydoJobs = JSON.parseArray(response.body(), MydoJob.class);
|
||||||
|
|
||||||
|
return mydoJobs;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 向AGV/CTU请求下发指令
|
||||||
|
* @param request 请求对象
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean sendCommand(GenAgvSchedulingTaskRequest request) {
|
||||||
|
|
||||||
|
//下发校验
|
||||||
|
if (checkForSendCommand(request)) return false;
|
||||||
|
|
||||||
|
String jsonString = JSON.toJSONString(request);
|
||||||
|
|
||||||
|
//请求源数据输出日志
|
||||||
|
log.info(jsonString);
|
||||||
|
|
||||||
|
//请求接口
|
||||||
|
HttpResponse response = HttpRequest.post(Constant.BASEURL_REST + "genAgvSchedulingTask")
|
||||||
|
.body(jsonString)
|
||||||
|
.header("Content-Type", "application/json")
|
||||||
|
.execute();
|
||||||
|
|
||||||
|
//获取响应对象
|
||||||
|
GenAgvSchedulingTaskResponse genAgvSchedulingTaskResponse = JSON.parseObject(response.body(), GenAgvSchedulingTaskResponse.class);
|
||||||
|
|
||||||
|
//返回请求编号校验
|
||||||
|
if (genAgvSchedulingTaskResponse.getReqCode() != request.getReqCode()) {
|
||||||
|
log.error("【下发设备任务】下发任务失败,请求编号错误不一致!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//返回码
|
||||||
|
if (genAgvSchedulingTaskResponse.getCode() == 0 ) {
|
||||||
|
return true;
|
||||||
|
}else {
|
||||||
|
log.error("【下发设备任务】下发任务失败," + genAgvSchedulingTaskResponse.getMessage() + "!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下发指令校验
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean checkForSendCommand(GenAgvSchedulingTaskRequest request){
|
||||||
|
//todo:请求信息校验
|
||||||
|
//1.reqCode空
|
||||||
|
if (StringUtils.isBlank(request.getReqCode())){
|
||||||
|
log.warn("【生成AGV任务请求接口】---请求异常,reqCode为空!---");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//2.wbCode和positionCodePath至少填写其中一项,以确定任务中的位置信息。若任务中需要指定多个位置信息,如起点和终点信息等,请使用positionCodePath
|
||||||
|
if (StringUtils.isBlank(request.getWbCode()) && request.getPositionCodePath().size() < 1){
|
||||||
|
log.warn("【生成AGV任务请求接口】---请求异常,wbCode和positionCodePath至少填写其中一项!---");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//3.当前区域AGV/CTU是否已存在任务
|
||||||
|
//todo 请求获取设备状态
|
||||||
|
if (true){
|
||||||
|
log.warn("【生成AGV任务请求接口】---当前设备已存在执行中的任务!---");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//4.请求编号一致时避免重复下发
|
||||||
|
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package com.ruoyi.schedule.task;
|
||||||
|
|
||||||
|
import com.ruoyi.schedule.data.ConvConnection;
|
||||||
|
import com.ruoyi.schedule.plc.domain.ConvPTLInRead;
|
||||||
|
import com.ruoyi.schedule.plc.domain.ConvPTLOutRead;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取任务生成AGV指令
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class Generation {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
ConvConnection conv;
|
||||||
|
|
||||||
|
//获取PTL拣选工位入口状态
|
||||||
|
public List<ConvPTLInRead> getConvPTLInRead() {
|
||||||
|
|
||||||
|
List<ConvPTLInRead> convPTLInReads=conv.getConvPTLIn();
|
||||||
|
|
||||||
|
for (int i = 0; i < convPTLInReads.size(); i++) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return convPTLInReads;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//获取PTL拣选工位出口状态
|
||||||
|
public List<ConvPTLOutRead> getConvPTLOutRead() {
|
||||||
|
|
||||||
|
List<ConvPTLOutRead> convPTLOutReads=conv.getConvPTLOut();
|
||||||
|
|
||||||
|
|
||||||
|
return convPTLOutReads;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user