wcs调度系统基本框架
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
package com.ruoyi.schedule;
|
||||
|
||||
import com.ruoyi.schedule.plc.PlcRead;
|
||||
import com.ruoyi.schedule.plc.domain.CustomThread;
|
||||
import com.ruoyi.schedule.plc.domain.SsjDevice;
|
||||
import com.ruoyi.schedule.plcRead.ssj.domain.PlcConnectInfo;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcRead;
|
||||
import com.ruoyi.schedule.plcRead.ssj.domain.CustomThread;
|
||||
import com.ruoyi.schedule.plcRead.ssj.domain.SsjDevice;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@Component
|
||||
@@ -18,8 +20,15 @@ public class ScheduleThread {
|
||||
*/
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
ConcurrentHashMap<String, SsjDevice> list = new ConcurrentHashMap<>();
|
||||
PlcRead plcRead = new PlcRead(list);
|
||||
String ip = "192.168.0.1";
|
||||
int port = 80;
|
||||
PlcConnectInfo ssjPlcConnectInfo = new PlcConnectInfo(ip, port);
|
||||
ConcurrentHashMap<String, SsjDevice>list = new ConcurrentHashMap<>();
|
||||
//获取要去取的输送机
|
||||
|
||||
|
||||
|
||||
PlcRead plcRead = new PlcRead(list,ssjPlcConnectInfo);
|
||||
Thread plcReadThread = new Thread(plcRead);
|
||||
customThread = new CustomThread(plcReadThread, plcRead);
|
||||
}
|
||||
|
||||
@@ -1,146 +0,0 @@
|
||||
package com.ruoyi.schedule.data;
|
||||
|
||||
|
||||
import com.ruoyi.schedule.plc.domain.ConvPTLInRead;
|
||||
import com.ruoyi.schedule.plc.domain.ConvPTLOutRead;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.plc4x.java.PlcDriverManager;
|
||||
import org.apache.plc4x.java.api.PlcConnection;
|
||||
import org.apache.plc4x.java.api.messages.PlcReadRequest;
|
||||
import org.apache.plc4x.java.api.messages.PlcReadResponse;
|
||||
import org.apache.plc4x.java.api.types.PlcResponseCode;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 获取输送机plc连接
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class ConvConnection {
|
||||
|
||||
Integer convPortCount = 10;
|
||||
|
||||
String ipConv = "127.0.0.1";
|
||||
|
||||
PlcConnection convConnection;
|
||||
|
||||
/**
|
||||
* 初始化输送机plc连接
|
||||
*/
|
||||
@PostConstruct
|
||||
public void initializeConvConnection() {
|
||||
try {
|
||||
convConnection = new PlcDriverManager().getConnection("s7://" + ipConv);
|
||||
log.info("【输送机连接初始化】输送机连接成功!");
|
||||
}catch (Exception e){
|
||||
log.warn("【输送机连接初始化】输送机连接失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取所有PTL入口输送机状态参数
|
||||
* @return
|
||||
*/
|
||||
public List<ConvPTLInRead> getConvPTLIn() {
|
||||
|
||||
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++) {
|
||||
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) {
|
||||
convPTLOut.get(i).setInPostion(response.getInteger("conv-inPostion"));
|
||||
convPTLOut.get(i).setHeight(response.getInteger("conv-height"));
|
||||
convPTLOut.get(i).setIsException(response.getInteger("conv-isException"));
|
||||
convPTLOut.get(i).setFree(response.getInteger("conv-free"));
|
||||
convPTLOut.get(i).setTaskId(response.getString("conv-taskId"));
|
||||
convPTLOut.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 convPTLOut;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,460 +0,0 @@
|
||||
package com.ruoyi.schedule.job.mydojob.domain;
|
||||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
/**
|
||||
* 任务表对象 mydo_job
|
||||
*/
|
||||
public class MydoJob extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 任务ID */
|
||||
@Excel(name = "任务ID")
|
||||
private String jobId;
|
||||
|
||||
/** 任务状态 */
|
||||
@Excel(name = "任务状态",dictType = "mydo_job_status")
|
||||
private String status;
|
||||
|
||||
/** 上线类型 */
|
||||
@Excel(name = "上线类型",dictType = "on_line_type")
|
||||
private String onLineType;
|
||||
|
||||
/** 任务号 */
|
||||
@Excel(name = "任务号")
|
||||
private String taskNo;
|
||||
|
||||
/** 供应商ID */
|
||||
@Excel(name = "供应商ID")
|
||||
private String supplierId;
|
||||
@Excel(name = "供应商名称")
|
||||
private String supplierName;
|
||||
|
||||
/** 客户ID */
|
||||
@Excel(name = "客户ID")
|
||||
private String customerId;
|
||||
@Excel(name = "客户名称")
|
||||
private String customerName;
|
||||
|
||||
/** 部门ID */
|
||||
@Excel(name = "部门ID")
|
||||
private String departmentId;
|
||||
@Excel(name = "部门")
|
||||
private String departmentName;
|
||||
|
||||
/** 托盘码 */
|
||||
@Excel(name = "托盘码")
|
||||
private String trayCode;
|
||||
|
||||
/** 巷道ID */
|
||||
@Excel(name = "巷道ID")
|
||||
private String roadwayId;
|
||||
|
||||
/** 货位ID */
|
||||
@Excel(name = "货位ID")
|
||||
private String cargoSpaceId;
|
||||
@Excel(name = "货位名称")
|
||||
private String cargoSpaceName;
|
||||
|
||||
/** 目标巷道ID */
|
||||
@Excel(name = "目标巷道ID")
|
||||
private String targetRoadwayId;
|
||||
|
||||
/** 目标货位ID */
|
||||
@Excel(name = "目标货位ID")
|
||||
private String targetCargoSpaceId;
|
||||
@Excel(name = "目标货位名称")
|
||||
private String targetCargoSpaceName;
|
||||
|
||||
/** 产线ID */
|
||||
@Excel(name = "产线ID")
|
||||
private String lineId;
|
||||
|
||||
/** 车间ID */
|
||||
@Excel(name = "车间ID")
|
||||
private String workshopId;
|
||||
|
||||
/** 优先级 */
|
||||
@Excel(name = "优先级")
|
||||
private Long priority;
|
||||
|
||||
/** 执行阶段 */
|
||||
@Excel(name = "执行阶段",dictType = "execution_phase_type")
|
||||
private String executionPhase;
|
||||
|
||||
/** 任务类型 */
|
||||
@Excel(name = "任务类型",dictType = "in_or_out_type")
|
||||
private String inOrOut;
|
||||
|
||||
|
||||
|
||||
/** 开始时间 */
|
||||
@Excel(name = "开始时间")
|
||||
private String startTime;
|
||||
|
||||
/** 结束时间 */
|
||||
@Excel(name = "结束时间")
|
||||
private String finishTime;
|
||||
|
||||
/** 入口ID */
|
||||
@Excel(name = "入口ID")
|
||||
private String entranceId;
|
||||
|
||||
/** 出口ID */
|
||||
@Excel(name = "出口ID")
|
||||
private String exitId;
|
||||
|
||||
/** 班组ID */
|
||||
@Excel(name = "班组ID")
|
||||
private String classId;
|
||||
|
||||
/** 仓库ID */
|
||||
@Excel(name = "仓库ID")
|
||||
private String warehouseId;
|
||||
@Excel(name = "仓库名称")
|
||||
private String warehouseName;
|
||||
|
||||
/** 重分标记 */
|
||||
@Excel(name = "重分标记")
|
||||
private String faultFlag;
|
||||
|
||||
private String inOut;
|
||||
|
||||
|
||||
public String getDepartmentName() {
|
||||
return departmentName;
|
||||
}
|
||||
|
||||
public void setDepartmentName(String departmentName) {
|
||||
this.departmentName = departmentName;
|
||||
}
|
||||
|
||||
public String getWarehouseName() {
|
||||
return warehouseName;
|
||||
}
|
||||
|
||||
public void setWarehouseName(String warehouseName) {
|
||||
this.warehouseName = warehouseName;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public String getInOut() {
|
||||
return inOut;
|
||||
}
|
||||
|
||||
public void setInOut(String inOut) {
|
||||
this.inOut = inOut;
|
||||
}
|
||||
|
||||
public void setJobId(String jobId)
|
||||
{
|
||||
this.jobId = jobId;
|
||||
}
|
||||
|
||||
public String getJobId()
|
||||
{
|
||||
return jobId;
|
||||
}
|
||||
|
||||
public void setStatus(String status)
|
||||
{
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getStatus()
|
||||
{
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setOnLineType(String onLineType)
|
||||
{
|
||||
this.onLineType = onLineType;
|
||||
}
|
||||
|
||||
public String getOnLineType()
|
||||
{
|
||||
return onLineType;
|
||||
}
|
||||
|
||||
public void setTaskNo(String taskNo)
|
||||
{
|
||||
this.taskNo = taskNo;
|
||||
}
|
||||
|
||||
public String getTaskNo()
|
||||
{
|
||||
return taskNo;
|
||||
}
|
||||
|
||||
public void setSupplierId(String supplierId)
|
||||
{
|
||||
this.supplierId = supplierId;
|
||||
}
|
||||
|
||||
public String getSupplierId()
|
||||
{
|
||||
return supplierId;
|
||||
}
|
||||
|
||||
public void setCustomerId(String customerId)
|
||||
{
|
||||
this.customerId = customerId;
|
||||
}
|
||||
|
||||
public String getCustomerId()
|
||||
{
|
||||
return customerId;
|
||||
}
|
||||
|
||||
public void setDepartmentId(String departmentId)
|
||||
{
|
||||
this.departmentId = departmentId;
|
||||
}
|
||||
|
||||
public String getDepartmentId()
|
||||
{
|
||||
return departmentId;
|
||||
}
|
||||
|
||||
public void setTrayCode(String trayCode)
|
||||
{
|
||||
this.trayCode = trayCode;
|
||||
}
|
||||
|
||||
public String getTrayCode()
|
||||
{
|
||||
return trayCode;
|
||||
}
|
||||
|
||||
public void setRoadwayId(String roadwayId)
|
||||
{
|
||||
this.roadwayId = roadwayId;
|
||||
}
|
||||
|
||||
public String getRoadwayId()
|
||||
{
|
||||
return roadwayId;
|
||||
}
|
||||
|
||||
public void setCargoSpaceId(String cargoSpaceId)
|
||||
{
|
||||
this.cargoSpaceId = cargoSpaceId;
|
||||
}
|
||||
|
||||
public String getCargoSpaceId()
|
||||
{
|
||||
return cargoSpaceId;
|
||||
}
|
||||
|
||||
public void setTargetRoadwayId(String targetRoadwayId)
|
||||
{
|
||||
this.targetRoadwayId = targetRoadwayId;
|
||||
}
|
||||
|
||||
public String getTargetRoadwayId()
|
||||
{
|
||||
return targetRoadwayId;
|
||||
}
|
||||
|
||||
public void setTargetCargoSpaceId(String targetCargoSpaceId)
|
||||
{
|
||||
this.targetCargoSpaceId = targetCargoSpaceId;
|
||||
}
|
||||
|
||||
public String getTargetCargoSpaceId()
|
||||
{
|
||||
return targetCargoSpaceId;
|
||||
}
|
||||
|
||||
public void setLineId(String lineId)
|
||||
{
|
||||
this.lineId = lineId;
|
||||
}
|
||||
|
||||
public String getLineId()
|
||||
{
|
||||
return lineId;
|
||||
}
|
||||
|
||||
public void setWorkshopId(String workshopId)
|
||||
{
|
||||
this.workshopId = workshopId;
|
||||
}
|
||||
|
||||
public String getWorkshopId()
|
||||
{
|
||||
return workshopId;
|
||||
}
|
||||
|
||||
public void setPriority(Long priority)
|
||||
{
|
||||
this.priority = priority;
|
||||
}
|
||||
|
||||
public Long getPriority()
|
||||
{
|
||||
return priority;
|
||||
}
|
||||
|
||||
public void setExecutionPhase(String executionPhase)
|
||||
{
|
||||
this.executionPhase = executionPhase;
|
||||
}
|
||||
|
||||
public String getExecutionPhase()
|
||||
{
|
||||
return executionPhase;
|
||||
}
|
||||
|
||||
public void setInOrOut(String inOrOut)
|
||||
{
|
||||
this.inOrOut = inOrOut;
|
||||
}
|
||||
|
||||
public String getInOrOut()
|
||||
{
|
||||
return inOrOut;
|
||||
}
|
||||
|
||||
public void setStartTime(String startTime)
|
||||
{
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
public String getStartTime()
|
||||
{
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public void setFinishTime(String finishTime)
|
||||
{
|
||||
this.finishTime = finishTime;
|
||||
}
|
||||
|
||||
public String getFinishTime()
|
||||
{
|
||||
return finishTime;
|
||||
}
|
||||
|
||||
public void setEntranceId(String entranceId)
|
||||
{
|
||||
this.entranceId = entranceId;
|
||||
}
|
||||
|
||||
public String getEntranceId()
|
||||
{
|
||||
return entranceId;
|
||||
}
|
||||
|
||||
public void setExitId(String exitId)
|
||||
{
|
||||
this.exitId = exitId;
|
||||
}
|
||||
|
||||
public String getExitId()
|
||||
{
|
||||
return exitId;
|
||||
}
|
||||
|
||||
public void setClassId(String classId)
|
||||
{
|
||||
this.classId = classId;
|
||||
}
|
||||
|
||||
public String getClassId()
|
||||
{
|
||||
return classId;
|
||||
}
|
||||
|
||||
public void setWarehouseId(String warehouseId)
|
||||
{
|
||||
this.warehouseId = warehouseId;
|
||||
}
|
||||
|
||||
public String getWarehouseId()
|
||||
{
|
||||
return warehouseId;
|
||||
}
|
||||
|
||||
public void setFaultFlag(String faultFlag)
|
||||
{
|
||||
this.faultFlag = faultFlag;
|
||||
}
|
||||
|
||||
public String getFaultFlag()
|
||||
{
|
||||
return faultFlag;
|
||||
}
|
||||
|
||||
public String getSupplierName() {
|
||||
return supplierName;
|
||||
}
|
||||
|
||||
public void setSupplierName(String supplierName) {
|
||||
this.supplierName = supplierName;
|
||||
}
|
||||
|
||||
public String getCustomerName() {
|
||||
return customerName;
|
||||
}
|
||||
|
||||
public void setCustomerName(String customerName) {
|
||||
this.customerName = customerName;
|
||||
}
|
||||
|
||||
public String getCargoSpaceName() {
|
||||
return cargoSpaceName;
|
||||
}
|
||||
|
||||
public void setCargoSpaceName(String cargoSpaceName) {
|
||||
this.cargoSpaceName = cargoSpaceName;
|
||||
}
|
||||
|
||||
public String getTargetCargoSpaceName() {
|
||||
return targetCargoSpaceName;
|
||||
}
|
||||
|
||||
public void setTargetCargoSpaceName(String targetCargoSpaceName) {
|
||||
this.targetCargoSpaceName = targetCargoSpaceName;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("jobId", getJobId())
|
||||
.append("status", getStatus())
|
||||
.append("onLineType", getOnLineType())
|
||||
.append("taskNo", getTaskNo())
|
||||
.append("supplierId", getSupplierId())
|
||||
.append("customerId", getCustomerId())
|
||||
.append("departmentId", getDepartmentId())
|
||||
.append("trayCode", getTrayCode())
|
||||
.append("roadwayId", getRoadwayId())
|
||||
.append("cargoSpaceId", getCargoSpaceId())
|
||||
.append("targetRoadwayId", getTargetRoadwayId())
|
||||
.append("targetCargoSpaceId", getTargetCargoSpaceId())
|
||||
.append("lineId", getLineId())
|
||||
.append("workshopId", getWorkshopId())
|
||||
.append("priority", getPriority())
|
||||
.append("executionPhase", getExecutionPhase())
|
||||
.append("inOrOut", getInOrOut())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("startTime", getStartTime())
|
||||
.append("finishTime", getFinishTime())
|
||||
.append("entranceId", getEntranceId())
|
||||
.append("exitId", getExitId())
|
||||
.append("classId", getClassId())
|
||||
.append("warehouseId", getWarehouseId())
|
||||
.append("faultFlag", getFaultFlag())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package com.ruoyi.schedule.plc;
|
||||
|
||||
import com.ruoyi.schedule.plc.domain.SsjDevice;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class PlcRead implements Runnable{
|
||||
|
||||
private final Map<String, SsjDevice> deviceMap;
|
||||
private volatile boolean running = true;
|
||||
|
||||
public PlcRead(ConcurrentHashMap<String, SsjDevice> deviceMap) {
|
||||
this.deviceMap = deviceMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
while (running && !Thread.currentThread().isInterrupted()) {
|
||||
try {
|
||||
// 模拟PLC读取操作
|
||||
Thread.sleep(1000); // 模拟睡眠
|
||||
// TODO: 实际读取PLC设备数据逻辑
|
||||
} catch (InterruptedException e) {
|
||||
// 捕获中断异常,退出循环
|
||||
Thread.currentThread().interrupt(); // 重新设置中断标志
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void stopReading() {
|
||||
running = false;
|
||||
Thread.currentThread().interrupt(); // 主动中断线程
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
package com.ruoyi.schedule.plc.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ConvBaseRead {
|
||||
|
||||
/**
|
||||
* 输送机编号
|
||||
*/
|
||||
private String convName;
|
||||
|
||||
/**
|
||||
* 任务号
|
||||
*/
|
||||
private String taskId;
|
||||
|
||||
/**
|
||||
* 是否空闲
|
||||
* 1-空闲 0-占用
|
||||
*/
|
||||
private Integer free;
|
||||
|
||||
/**
|
||||
* 输送到位
|
||||
* 0-未到位 1-到位
|
||||
*/
|
||||
private Integer inPostion;
|
||||
|
||||
/**
|
||||
* 入库到位
|
||||
* 0-未到位 1-到位
|
||||
*/
|
||||
private Integer inPostionForStockIn;
|
||||
|
||||
/**
|
||||
* 出库到位
|
||||
* 0-未到位 1-到位
|
||||
*/
|
||||
private Integer inPostionForStockOut;
|
||||
|
||||
/**
|
||||
* 是否异常
|
||||
* 0-正常 1-异常
|
||||
*/
|
||||
private Integer isException;
|
||||
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package com.ruoyi.schedule.plc.domain;
|
||||
|
||||
public class ConvBaseWrite {
|
||||
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
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;
|
||||
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package com.ruoyi.schedule.plc.domain;
|
||||
|
||||
public class ConvPTLInWrite extends ConvBaseWrite {
|
||||
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
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;
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package com.ruoyi.schedule.plc.domain;
|
||||
|
||||
|
||||
public class ConvPTLOutWrite extends ConvBaseWrite{
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
package com.ruoyi.schedule.plc.domain;
|
||||
|
||||
public class SsjDevice {
|
||||
}
|
||||
@@ -0,0 +1,568 @@
|
||||
package com.ruoyi.schedule.plcRead.ssj;
|
||||
|
||||
import HslCommunication.BasicFramework.SoftBasic;
|
||||
import HslCommunication.Core.Net.IReadWriteNet;
|
||||
import HslCommunication.Core.Types.OperateResult;
|
||||
import HslCommunication.Core.Types.OperateResultExOne;
|
||||
import HslCommunication.Profinet.Siemens.SiemensPLCS;
|
||||
import HslCommunication.Profinet.Siemens.SiemensS7Net;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.ruoyi.schedule.plcRead.ssj.domain.PlcConnectInfo;
|
||||
import com.ruoyi.schedule.plcRead.ssj.domain.SsjDevice;
|
||||
import com.ruoyi.schedule.plcRead.util.ParseUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@Slf4j
|
||||
public class PlcRead implements Runnable {
|
||||
|
||||
public static ConcurrentHashMap<String, SsjDevice> deviceMap;
|
||||
private volatile boolean running = true;
|
||||
|
||||
public SiemensS7Net siemensS7Net = null;
|
||||
public static IReadWriteNet readWriteNet = null;
|
||||
private String ip;
|
||||
private int port;
|
||||
private boolean success = false;
|
||||
|
||||
public PlcRead(ConcurrentHashMap<String, SsjDevice> deviceMap, PlcConnectInfo plcConnectInfo) {
|
||||
this.deviceMap = deviceMap;
|
||||
this.ip = plcConnectInfo.getIp();
|
||||
this.port = plcConnectInfo.getPort();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
while (running && !Thread.currentThread().isInterrupted()) {
|
||||
try {
|
||||
if (IsConnect()) {
|
||||
|
||||
for (String ssjCode : deviceMap.keySet()) {
|
||||
SsjDevice ssjDevice = deviceMap.get(ssjCode);
|
||||
String readAddress = "";
|
||||
String writeAddress = "";
|
||||
|
||||
switch (ssjDevice.getDeviceCode()){
|
||||
case "G5011":
|
||||
// 处理 G5011
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G5012":
|
||||
// 处理 G5012
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G5016":
|
||||
// 处理 G5016
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G5017":
|
||||
// 处理 G5017
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G5002":
|
||||
// 处理 G5002
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G5003":
|
||||
// 处理 G5003
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G5007":
|
||||
// 处理 G5007
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G5008":
|
||||
// 处理 G5008
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G3011":
|
||||
// 处理 G3011
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G3012":
|
||||
// 处理 G3012
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G4007":
|
||||
// 处理 G4007
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G4008":
|
||||
// 处理 G4008
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G4016":
|
||||
// 处理 G4016
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G4017":
|
||||
// 处理 G4017
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G4011":
|
||||
// 处理 G4011
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G4012":
|
||||
// 处理 G4012
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G4002":
|
||||
// 处理 G4002
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G4003":
|
||||
// 处理 G4003
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G3002":
|
||||
// 处理 G3002
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G3003":
|
||||
// 处理 G3003
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G2002":
|
||||
// 处理 G2002
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G2003":
|
||||
// 处理 G2003
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G1011":
|
||||
// 处理 G1011
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G3016":
|
||||
// 处理 G3016
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G3017":
|
||||
// 处理 G3017
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G3007":
|
||||
// 处理 G3007
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G3008":
|
||||
// 处理 G3008
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G1007":
|
||||
// 处理 G1007
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G1008":
|
||||
// 处理 G1008
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G1005":
|
||||
// 处理 G1005
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G1001":
|
||||
// 处理 G1001
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G1002":
|
||||
// 处理 G1002
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G2010":
|
||||
// 处理 G2010
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G2011":
|
||||
// 处理 G2011
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G1003":
|
||||
// 处理 G1003
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G1009":
|
||||
// 处理 G1009
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G2012":
|
||||
// 处理 G2012
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G3009":
|
||||
// 处理 G3009
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G3018":
|
||||
// 处理 G3018
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G4009":
|
||||
// 处理 G4009
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G4018":
|
||||
// 处理 G4018
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G5009":
|
||||
// 处理 G5009
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G5018":
|
||||
// 处理 G5018
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G5013":
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G5014":
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G5015":
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G5004":
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G5005":
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G5006":
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G4013":
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G4014":
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G4015":
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G4004":
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G4005":
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G4006":
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G1012":
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G3004":
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G3005":
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G3006":
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G3013":
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G3014":
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G3015":
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G1006":
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G2004":
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G2005":
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G2006":
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G2007":
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G2008":
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G2009":
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G1004":
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G1010":
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G2001":
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G3001":
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G3010":
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G4001":
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G4010":
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G5001":
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
case "G5010":
|
||||
readAddress = "";
|
||||
writeAddress = "";
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (ssjDevice.getType()) {
|
||||
case "1":
|
||||
readPlcOutSsj(ssjDevice);
|
||||
break;
|
||||
case "2":
|
||||
readPlcPickSsj(ssjDevice);
|
||||
break;
|
||||
case "3":
|
||||
readPlcInSsj(ssjDevice);
|
||||
break;
|
||||
case "4":
|
||||
readPlcOtherSsj(ssjDevice);
|
||||
break;
|
||||
}
|
||||
}
|
||||
Thread.sleep(1000);
|
||||
} else {
|
||||
reConnect();
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
// 捕获中断异常,退出循环
|
||||
Thread.currentThread().interrupt(); // 重新设置中断标志
|
||||
break;
|
||||
} catch (Exception e) {
|
||||
log.info("********IP:" + this.ip + " port:" + this.port + "读取数据异常 " + e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 其他输送机
|
||||
*
|
||||
* @param ssjDevice
|
||||
*/
|
||||
private void readPlcOtherSsj(SsjDevice ssjDevice) {
|
||||
ssjDevice.setPlcReadAddress(ssjDevice.getPlcReadAddress());
|
||||
ssjDevice.setPlcWriteAddress(ssjDevice.getPlcWriteAddress());
|
||||
OperateResultExOne<byte[]> read2 = readWriteNet.Read(ssjDevice.getPlcReadAddress(), Short.parseShort("18"));
|
||||
String ddsx1 = "0";
|
||||
if (read2.IsSuccess) {
|
||||
ddsx1 = SoftBasic.ByteToHexString(read2.Content);
|
||||
ssjDevice.setEmpty(ParseUtil.optInt(0,ddsx1));
|
||||
ssjDevice.setInPlace(ParseUtil.optInt(1,ddsx1));
|
||||
ssjDevice.setEntryRequest(ParseUtil.optInt(2,ddsx1));
|
||||
ssjDevice.setTrayCode(ParseUtil.optString(3,ddsx1));
|
||||
ssjDevice.setTaskNo(ParseUtil.optDInt(4,ddsx1));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 入库输送机
|
||||
*
|
||||
* @param ssjDevice
|
||||
*/
|
||||
private void readPlcInSsj(SsjDevice ssjDevice) {
|
||||
ssjDevice.setPlcReadAddress(ssjDevice.getPlcReadAddress());
|
||||
ssjDevice.setPlcWriteAddress(ssjDevice.getPlcWriteAddress());
|
||||
OperateResultExOne<byte[]> read2 = readWriteNet.Read(ssjDevice.getPlcReadAddress(), Short.parseShort("18"));
|
||||
String ddsx1 = "0";
|
||||
if (read2.IsSuccess) {
|
||||
ddsx1 = SoftBasic.ByteToHexString(read2.Content);
|
||||
ssjDevice.setEmpty(ParseUtil.optInt(0,ddsx1));
|
||||
ssjDevice.setInPlace(ParseUtil.optInt(1,ddsx1));
|
||||
ssjDevice.setEntryRequest(ParseUtil.optInt(2,ddsx1));
|
||||
ssjDevice.setTrayCode(ParseUtil.optString(3,ddsx1));
|
||||
ssjDevice.setTaskNo(ParseUtil.optDInt(4,ddsx1));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 拣选口输送机
|
||||
*
|
||||
* @param ssjDevice
|
||||
*/
|
||||
private void readPlcPickSsj(SsjDevice ssjDevice) {
|
||||
ssjDevice.setPlcReadAddress(ssjDevice.getPlcReadAddress());
|
||||
ssjDevice.setPlcWriteAddress(ssjDevice.getPlcWriteAddress());
|
||||
OperateResultExOne<byte[]> read2 = readWriteNet.Read(ssjDevice.getPlcReadAddress(), Short.parseShort("18"));
|
||||
String ddsx1 = "0";
|
||||
if (read2.IsSuccess) {
|
||||
ddsx1 = SoftBasic.ByteToHexString(read2.Content);
|
||||
ssjDevice.setEmpty(ParseUtil.optInt(0,ddsx1));
|
||||
ssjDevice.setInPlace(ParseUtil.optInt(1,ddsx1));
|
||||
ssjDevice.setEntryRequest(ParseUtil.optInt(2,ddsx1));
|
||||
ssjDevice.setTrayCode(ParseUtil.optString(3,ddsx1));
|
||||
ssjDevice.setTaskNo(ParseUtil.optDInt(4,ddsx1));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 出库输送机
|
||||
* @param ssjDevice
|
||||
*/
|
||||
private void readPlcOutSsj(SsjDevice ssjDevice) {
|
||||
ssjDevice.setPlcReadAddress(ssjDevice.getPlcReadAddress());
|
||||
ssjDevice.setPlcWriteAddress(ssjDevice.getPlcWriteAddress());
|
||||
OperateResultExOne<byte[]> read2 = readWriteNet.Read(ssjDevice.getPlcReadAddress(), Short.parseShort("18"));
|
||||
String ddsx1 = "0";
|
||||
if (read2.IsSuccess) {
|
||||
ddsx1 = SoftBasic.ByteToHexString(read2.Content);
|
||||
ssjDevice.setEmpty(ParseUtil.optInt(0,ddsx1));
|
||||
ssjDevice.setInPlace(ParseUtil.optInt(1,ddsx1));
|
||||
ssjDevice.setEntryRequest(ParseUtil.optInt(2,ddsx1));
|
||||
ssjDevice.setTrayCode(ParseUtil.optString(3,ddsx1));
|
||||
ssjDevice.setTaskNo(ParseUtil.optDInt(4,ddsx1));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void stopReading() {
|
||||
running = false;
|
||||
Thread.currentThread().interrupt(); // 主动中断线程
|
||||
}
|
||||
|
||||
|
||||
void ConnectServer() {
|
||||
siemensS7Net = new SiemensS7Net(SiemensPLCS.S1500);
|
||||
try {
|
||||
siemensS7Net.setIpAddress(this.ip);
|
||||
siemensS7Net.setPort(this.port);
|
||||
siemensS7Net.setRack((byte) 0);
|
||||
siemensS7Net.setSlot((byte) 1);
|
||||
|
||||
OperateResult connect = siemensS7Net.ConnectServer();
|
||||
if (connect.IsSuccess) {
|
||||
setIsConnect(true);
|
||||
readWriteNet = siemensS7Net;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
log.info("********IP:" + this.ip + " port:" + this.port + "连接失败 " + ex.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setIsConnect(boolean bflag) {
|
||||
if (!success) {
|
||||
success = bflag;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean IsConnect() {
|
||||
if (success) {
|
||||
return success;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void reConnect() {
|
||||
closeServer();
|
||||
ConnectServer();
|
||||
log.info("重新连接 SSJ-PLC");
|
||||
}
|
||||
|
||||
void closeServer() {
|
||||
if (readWriteNet != null) {
|
||||
siemensS7Net.ConnectClose();
|
||||
}
|
||||
setIsConnect(false);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.ruoyi.schedule.plc.domain;
|
||||
package com.ruoyi.schedule.plcRead.ssj.domain;
|
||||
|
||||
import com.ruoyi.schedule.plc.PlcRead;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.ruoyi.schedule.plcRead.ssj.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class PlcConnectInfo {
|
||||
|
||||
private String ip;
|
||||
private Integer port;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.ruoyi.schedule.plcRead.ssj.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class SsjDevice {
|
||||
private String deviceCode;
|
||||
|
||||
private String plcReadAddress;
|
||||
|
||||
private String plcWriteAddress;
|
||||
//输送机类型:1-出库 2-拣选 3-入库 4-其他
|
||||
private String type;
|
||||
|
||||
//空闲 0-否 1-是
|
||||
private Integer empty;
|
||||
//到位 0-否 1-是
|
||||
private Integer inPlace;
|
||||
//入库请求 0-否 1-是
|
||||
private Integer entryRequest;
|
||||
//条码
|
||||
private String trayCode;
|
||||
//任务号
|
||||
private Integer taskNo;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.ruoyi.schedule.plcRead.util;
|
||||
|
||||
|
||||
import HslCommunication.BasicFramework.SoftBasic;
|
||||
|
||||
/**
|
||||
* @author zn kai
|
||||
* @create 2021-06-28 14:04
|
||||
*/
|
||||
public class ParseUtil {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* short 16λתint
|
||||
* @param start
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
public static int optInt(int start, String data) {
|
||||
return Integer.parseInt(data.substring(start * 2, (start + 2) * 2), 16);
|
||||
}
|
||||
/**
|
||||
* int 16λתint
|
||||
* @param start
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
public static int optDInt(int start, String data) {
|
||||
return Integer.parseInt(data.substring(start * 2, (start + 4) * 2), 16);
|
||||
}
|
||||
/**
|
||||
* long 16λתlong
|
||||
* @param start
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
public static Long optLong(int start, String data) {
|
||||
return Long.parseLong(data.substring(start * 2, (start + 8) * 2), 16);
|
||||
}
|
||||
/**
|
||||
* string 16λתstring
|
||||
* @param start
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
|
||||
public static String optString(int start, String data) {
|
||||
byte[] bytes = SoftBasic.HexStringToBytes(data.substring(start * 2, (start + 12) * 2));
|
||||
return Tools.bytetostringtool(bytes);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,378 @@
|
||||
package com.ruoyi.schedule.plcRead.util;
|
||||
|
||||
import HslCommunication.BasicFramework.SoftBasic;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <20><><EFBFBD><EFBFBD>:cyc16У<36><D0A3><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @author zhu
|
||||
*/
|
||||
public class Tools implements Serializable {
|
||||
public static int Debug = 0x20;
|
||||
public final static int DEBUG_CONVERSIONS = 0x1000;
|
||||
public static final int DINT = 4;
|
||||
|
||||
public static final int INT = 2;
|
||||
|
||||
public static void main(String[] arg) {
|
||||
int jym = getJYM(1, 2, 3);
|
||||
System.out.println(jym);
|
||||
}
|
||||
|
||||
/*4<><34>CRC-16У<36><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㷽<EFBFBD><E3B7BD><EFBFBD><EFBFBD>
|
||||
<20><><EFBFBD>ò<EFBFBD><C3B2><EFBFBD>ͼ<EFBFBD><CDBC>㷨<EFBFBD><E3B7A8><EFBFBD><EFBFBD><EFBFBD>㷽<EFBFBD><E3B7BD>һ<EFBFBD>㶼<EFBFBD>ǣ<EFBFBD>
|
||||
<20><>1<EFBFBD><31><EFBFBD><EFBFBD>Ԥ<EFBFBD><D4A4>1<EFBFBD><31>16λ<36>ļĴ<C4BC><C4B4><EFBFBD>Ϊʮ<CEAA><CAAE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>FFFF<46><46><EFBFBD><EFBFBD>ȫΪ1<CEAA><31><EFBFBD><EFBFBD><EFBFBD>ƴ˼Ĵ<CBBC><C4B4><EFBFBD>ΪCRC<52>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD>
|
||||
<20><>2<EFBFBD><32><EFBFBD><EFBFBD><EFBFBD>ѵ<EFBFBD>һ<EFBFBD><D2BB>8λ<38><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD><DDA3><EFBFBD>ͨѶ<CDA8><D1B6>Ϣ֡<CFA2>ĵ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ֽڣ<D6BD><DAA3><EFBFBD>16λ<36><CEBB>CRC<52>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD>ĵ<EFBFBD>
|
||||
8λ<38><CEBB><EFBFBD><EFBFBD>ѽ<F2A3ACB0><D1BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>CRC<52>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߰<EFBFBD>λ<EFBFBD><CEBB><EFBFBD>ݲ<EFBFBD><DDB2>䣻
|
||||
<20><>3<EFBFBD><33><EFBFBD><EFBFBD><EFBFBD><EFBFBD>CRC<52>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һλ<D2BB><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>0<EFBFBD><EFBFBD><EEB2B9><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƺ<EFBFBD><C6BA><EFBFBD>Ƴ<EFBFBD>λ<EFBFBD><CEBB>
|
||||
<20><>4<EFBFBD><34><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƴ<EFBFBD>λΪ0<CEAA><30><EFBFBD>ظ<EFBFBD><D8B8><EFBFBD>3<EFBFBD><33><EFBFBD><EFBFBD><EFBFBD>ٴ<EFBFBD><D9B4><EFBFBD><EFBFBD><EFBFBD>һλ<D2BB><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƴ<EFBFBD>λΪ1<CEAA><31>CRC<52>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<20><>ʽA001<30><31>1010 0000 0000 0001<30><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<20><>5<EFBFBD><35><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD>3<EFBFBD><33>4<EFBFBD><34>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>8<EFBFBD>Σ<EFBFBD><CEA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>8λ<38><CEBB><EFBFBD><EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˴<EFBFBD><CBB4><EFBFBD>
|
||||
<20><>6<EFBFBD><36><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD>2<EFBFBD><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD>5<EFBFBD><35><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨѶ<CDA8><D1B6>Ϣ֡<CFA2><D6A1>һ<EFBFBD><D2BB><EFBFBD>ֽڵĴ<DAB5><C4B4><EFBFBD>
|
||||
<20><>7<EFBFBD><37><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨѶ<CDA8><D1B6>Ϣ֡<CFA2><D6A1><EFBFBD><EFBFBD><EFBFBD>ֽڰ<D6BD><DAB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɺõ<F3A3ACB5><C3B5><EFBFBD>16λCRC<52>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD>ĸߡ<C4B8><DFA1><EFBFBD>
|
||||
<20>ֽڽ<D6BD><DABD>н<EFBFBD><D0BD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<20><>8<EFBFBD><38><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><C3B5><EFBFBD>CRC<52>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݼ<EFBFBD>Ϊ<EFBFBD><CEAA>CRC<52>롣
|
||||
<20><><EFBFBD>ϼ<EFBFBD><CFBC>㲽<EFBFBD><E3B2BD><EFBFBD>еĶ<D0B5><C4B6><EFBFBD>ʽA001<30><31>8005<30><35>λ<EFBFBD>ߵ<EFBFBD><DFB5><EFBFBD>Ľ<EFBFBD><C4BD><EFBFBD><EFBFBD>
|
||||
<20><><EFBFBD><EFBFBD>ǽ<EFBFBD><C7BD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǽ<EFBFBD>0~256<35><36><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ16λ<36>ļĴ<C4BC><C4B4><EFBFBD><EFBFBD>еĵͰ<C4B5>λ<EFBFBD><CEBB><EFBFBD>߰<EFBFBD>λ<EFBFBD><CEBB><EFBFBD>0<EFBFBD><30>Ȼ<EFBFBD>üĴ<C3BC><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ0XA001<30><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>3<EFBFBD><33>4<EFBFBD><34><EFBFBD>裬ֱ<E8A3AC><D6B1><EFBFBD><EFBFBD>λȫ<CEBB><C8AB><EFBFBD>Ƴ<EFBFBD><C6B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD>е<EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD>DZ<EFBFBD><C7B1><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD>ݣ<EFBFBD><DDA3>߰<EFBFBD>λ<EFBFBD><CEBB><EFBFBD>Ͱ<EFBFBD>λ<EFBFBD>ֱ<D6B1>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>*/
|
||||
|
||||
|
||||
/**
|
||||
* ȫ<><C8AB>У<EFBFBD><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ
|
||||
*
|
||||
* @param ints <20><><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><D0A3><EFBFBD><EFBFBD>
|
||||
* @return <20><><EFBFBD>ص<EFBFBD>int
|
||||
*/
|
||||
public static int getJYM(int... ints) {
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>תΪ32λ<32><CEBB><EFBFBD>ܺ<EFBFBD>תΪ<D7AA>ĸ<EFBFBD><C4B8>ֽڣ<D6BD><DAA3><EFBFBD><EFBFBD>תΪ<D7AA><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>4
|
||||
int[] ints1 = new int[ints.length * 4];
|
||||
for (int i = 0; i < ints.length; i++) {
|
||||
int[] son;
|
||||
son = binaryTints(printBits(ints[i]));
|
||||
for (int j = 0; j < 4; j++) {
|
||||
int s = j + i * 4;
|
||||
ints1[s] = son[j];
|
||||
System.out.println(Arrays.toString(ints1));
|
||||
}
|
||||
}
|
||||
int a = 0;
|
||||
for (int j : ints1) {
|
||||
a = a + j;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param hex <20>ַ<EFBFBD><D6B7><EFBFBD>
|
||||
* @return a <20><><EFBFBD><EFBFBD>
|
||||
*/
|
||||
public static int[] binaryTints(String hex) {
|
||||
int[] a = new int[4];
|
||||
String hexString = change32(hex);
|
||||
a[0] = Integer.parseInt(hexString.substring(0, 8), 2);//<2F><>
|
||||
a[1] = Integer.parseInt(hexString.substring(8, 16), 2);
|
||||
a[2] = Integer.parseInt(hexString.substring(16, 24), 2);
|
||||
a[3] = Integer.parseInt(hexString.substring(24, 32), 2);
|
||||
return a;
|
||||
}
|
||||
|
||||
public static int[] binaryTints16(String hex) {
|
||||
int[] a = new int[2];
|
||||
String hexString = change16(hex);
|
||||
a[0] = Integer.parseInt(hexString.substring(0, 8), 2);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>תΪ<D7AA><CEAA><EFBFBD><EFBFBD>
|
||||
a[1] = Integer.parseInt(hexString.substring(8, 16), 2);
|
||||
return a;
|
||||
}
|
||||
|
||||
public static int binaryTints8(String hex) {
|
||||
int a;
|
||||
String hexString = change8(hex);
|
||||
a = Integer.parseInt(hexString.substring(0, 8), 2);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>תΪ<D7AA><CEAA><EFBFBD><EFBFBD>
|
||||
return a;
|
||||
}
|
||||
|
||||
public static int BytesToInt(int[] ss) {
|
||||
if (ss != null) {
|
||||
StringBuilder lString = new StringBuilder();
|
||||
for (int s : ss) {
|
||||
lString.append(change8(printBits(s)));
|
||||
}
|
||||
return Integer.parseInt(lString.toString(), 2);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <20><><EFBFBD>ַ<EFBFBD>תΪ<D7AA><CEAA><EFBFBD><EFBFBD>
|
||||
**/
|
||||
public static int showAscii(char x) {
|
||||
return x;
|
||||
}
|
||||
|
||||
/**
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>תΪ<D7AA>ַ<EFBFBD>
|
||||
**/
|
||||
public static char showChar(int x) {
|
||||
return (char) x;
|
||||
}
|
||||
|
||||
/**
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
**/
|
||||
public static String byteToStringTool(byte[] aaa) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (byte b : aaa) {
|
||||
String x = Character.toString(showChar(b));
|
||||
builder.append(x);
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>תΪ<D7AA><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
|
||||
*/
|
||||
public static String printBits(int n) {
|
||||
return Integer.toBinaryString(n);
|
||||
}
|
||||
|
||||
/**
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>תΪ<D7AA><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
public static Float printFloat(int n) {
|
||||
return Float.intBitsToFloat(n);
|
||||
}
|
||||
|
||||
/**
|
||||
* <20><><EFBFBD><EFBFBD>8λ<38>Ӹ<EFBFBD>λ<EFBFBD><CEBB>0
|
||||
**/
|
||||
public static String change8(String value) {
|
||||
if (value != null && !value.equals("")) {
|
||||
StringBuilder ss = new StringBuilder(value);
|
||||
for (int i = 0; i < 8 - value.length(); i++) {
|
||||
ss.insert(0, "0");
|
||||
}
|
||||
return ss.toString();
|
||||
} else {
|
||||
return "00000000";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <20><><EFBFBD><EFBFBD>32λ<32>Ӹ<EFBFBD>λ<EFBFBD><CEBB>0 4<><34><EFBFBD>ֽ<EFBFBD>
|
||||
**/
|
||||
public static String change32(String value) {
|
||||
if (value != null && !value.equals("")) {
|
||||
StringBuilder ss = new StringBuilder(value);
|
||||
for (int i = 0; i < 32 - value.length(); i++) {
|
||||
ss.insert(0, "0");
|
||||
}
|
||||
return ss.toString();
|
||||
} else {
|
||||
return "00000000000000000000000000000000";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <20><><EFBFBD><EFBFBD>16λ<36>Ӹ<EFBFBD>λ<EFBFBD><CEBB>0 4<><34><EFBFBD>ֽ<EFBFBD>
|
||||
**/
|
||||
public static String change16(String value) {
|
||||
if (value != null && !value.equals("")) {
|
||||
StringBuilder ss = new StringBuilder(value);
|
||||
for (int i = 0; i < 16 - value.length(); i++) {
|
||||
ss.insert(0, "0");
|
||||
}
|
||||
return ss.toString();
|
||||
} else {
|
||||
return "0000000000000000";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///<2F>ֽ<EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD>
|
||||
public static int get(byte a1, byte a2, byte a3, byte a4, byte a5, byte a6, byte a7, byte a8,
|
||||
byte a9, byte a10, byte a11, byte a12, byte a13, byte a14, byte a15, byte a16,
|
||||
byte a17, byte a18, byte a19, byte a20, byte a21, byte a22, byte a23, byte a24, byte a25) {
|
||||
int[] ints = new int[25];
|
||||
ints[0] = binaryTints8(printBits(a1));
|
||||
ints[1] = binaryTints8(printBits(a2));
|
||||
ints[2] = binaryTints8(printBits(a3));
|
||||
ints[3] = binaryTints8(printBits(a4));
|
||||
ints[4] = binaryTints8(printBits(a5));
|
||||
ints[5] = binaryTints8(printBits(a6));
|
||||
ints[6] = binaryTints8(printBits(a7));
|
||||
ints[7] = binaryTints8(printBits(a8));
|
||||
ints[8] = binaryTints8(printBits(a9));
|
||||
ints[9] = binaryTints8(printBits(a10));
|
||||
ints[10] = binaryTints8(printBits(a11));
|
||||
ints[11] = binaryTints8(printBits(a12));
|
||||
ints[12] = binaryTints8(printBits(a13));
|
||||
ints[13] = binaryTints8(printBits(a14));
|
||||
ints[14] = binaryTints8(printBits(a15));
|
||||
ints[15] = binaryTints8(printBits(a16));
|
||||
ints[16] = binaryTints8(printBits(a17));
|
||||
ints[17] = binaryTints8(printBits(a18));
|
||||
ints[18] = binaryTints8(printBits(a19));
|
||||
ints[19] = binaryTints8(printBits(a20));
|
||||
ints[20] = binaryTints8(printBits(a21));
|
||||
ints[21] = binaryTints8(printBits(a22));
|
||||
ints[22] = binaryTints8(printBits(a23));
|
||||
ints[23] = binaryTints8(printBits(a24));
|
||||
ints[24] = binaryTints8(printBits(a25));
|
||||
for (int anInt : ints) System.out.print(anInt + " ");
|
||||
System.out.println();
|
||||
return BytesToInt(ints);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
public static byte[] int2byte(int res) {///Java<76><61>10<31><30><EFBFBD><EFBFBD>תbyte[]
|
||||
byte[] targets = new byte[4];
|
||||
|
||||
targets[3] = (byte) (res & 0xff);// <20><><EFBFBD>λ
|
||||
targets[2] = (byte) ((res >> 8) & 0xff);// <20>ε<EFBFBD>λ
|
||||
targets[1] = (byte) ((res >> 16) & 0xff);// <20>θ<EFBFBD>λ
|
||||
targets[0] = (byte) (res >>> 24);// <20><><EFBFBD>λ,<2C><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ơ<EFBFBD>
|
||||
return targets;
|
||||
}
|
||||
|
||||
/**
|
||||
* <20><><EFBFBD>byte <20>ϲ<EFBFBD><CFB2><EFBFBD>һ<EFBFBD><D2BB>byte
|
||||
*/
|
||||
public static byte[] byteMerge(byte[]... values) {
|
||||
int length_byte = 0;
|
||||
for (byte[] value : values) {
|
||||
length_byte += value.length;
|
||||
}
|
||||
byte[] all_byte = new byte[length_byte];
|
||||
int countLength = 0;
|
||||
for (byte[] b : values) {
|
||||
System.arraycopy(b, 0, all_byte, countLength, b.length);
|
||||
countLength += b.length;
|
||||
}
|
||||
return all_byte;
|
||||
}
|
||||
|
||||
/** ???????????**/
|
||||
public static String bytetostringtool(byte[] aaa) {
|
||||
String tptm = "";
|
||||
for(int i=0;i<aaa.length;i++){
|
||||
//System.out.println("??????:for:"+aaa[i]);
|
||||
String x = Character.toString(showChar(aaa[i]));
|
||||
char ddd=showChar(aaa[i]);
|
||||
tptm=tptm+x;
|
||||
//System.out.println(tptm);
|
||||
}
|
||||
if(tptm.length() == 0 || tptm.equals("")){
|
||||
return "00000000";
|
||||
}else {
|
||||
return tptm;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* int תbyte
|
||||
*/
|
||||
public static byte[] intToBytes(int value, int len) {
|
||||
byte[] b = new byte[len];
|
||||
for (int i = 0; i < len; i++) {
|
||||
b[len - i - 1] = (byte) ((value >> 8 * i) & 0xff);
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//<2F>·<EFBFBD><C2B7>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD>
|
||||
public static byte[] sendDataToDevice(long taskNo,String trayCode, int...ints){
|
||||
int length = 0;
|
||||
byte[] xfData = null;
|
||||
if (trayCode == null){
|
||||
length = 4 + (ints.length * 2);
|
||||
xfData = new byte[length];
|
||||
byte[] RWH = new byte[4];
|
||||
RWH = Tools.int2byte((int) taskNo);
|
||||
for (int i = 0; i < length; i++){
|
||||
if (i < 4){
|
||||
xfData[i] = RWH[i];
|
||||
} else {
|
||||
if (i % 2 == 0){
|
||||
byte[] param = new byte[2];
|
||||
param = intbyte(ints[(i - 4) / 2]);
|
||||
xfData[i] = param[0];
|
||||
xfData[i + 1] = param[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
length = 12 + (ints.length * 2);
|
||||
xfData = new byte[length];
|
||||
byte[] RWH = new byte[4];
|
||||
RWH = Tools.int2byte((int) taskNo);
|
||||
byte[] tCode = new byte[8];
|
||||
if ("".equals(trayCode)){
|
||||
for (int i = 0;i < tCode.length;i++){
|
||||
tCode[i] = 0;
|
||||
}
|
||||
}else {
|
||||
byte[] code = trayCode.getBytes();
|
||||
for (int i = 0; i < tCode.length; i++) {
|
||||
tCode[i] = code[i];
|
||||
}
|
||||
}
|
||||
for (int i = 0; i< length; i++){
|
||||
if (i < 4){
|
||||
xfData[i] = RWH[i];
|
||||
} else if (i > 3 && i< 12) {
|
||||
xfData[i] = tCode[i - 4];
|
||||
} else {
|
||||
if (i % 2 == 0){
|
||||
byte[] param = new byte[2];
|
||||
param = intbyte(ints[(i - 12) / 2]);
|
||||
xfData[i] = param[0];
|
||||
xfData[i + 1] = param[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return xfData;
|
||||
}
|
||||
|
||||
/**
|
||||
* <20>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
|
||||
*/
|
||||
public static String byteToString(String substring) {
|
||||
return new String(SoftBasic.HexStringToBytes(substring), StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static String getDate() {
|
||||
Date t = new Date();
|
||||
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
return df.format(t);
|
||||
}
|
||||
|
||||
//int ת2<D7AA>ֽ<EFBFBD>
|
||||
public static byte[] intbyte(int res) {///Java<76><61>10<31><30><EFBFBD><EFBFBD>תbyte[]
|
||||
byte[] targets = new byte[2];
|
||||
targets[1] = (byte) ((res >> 0) & 0xff);// <20>θ<EFBFBD>λ
|
||||
targets[0] = (byte) (res >>> 8);// <20><><EFBFBD>λ,<2C><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ơ<EFBFBD>
|
||||
return targets;
|
||||
}
|
||||
|
||||
public static int[] binarysToints(String hex){
|
||||
int[] a = new int[4];
|
||||
String hexString = change32(hex);
|
||||
a[0] = Integer.parseInt(hexString.substring(0,8),2);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>תΪ<D7AA><CEAA><EFBFBD><EFBFBD>
|
||||
a[1] = Integer.parseInt(hexString.substring(8,16),2);
|
||||
a[2] = Integer.parseInt(hexString.substring(16,24),2);
|
||||
a[3] = Integer.parseInt(hexString.substring(24,32),2);
|
||||
return a;
|
||||
}
|
||||
}
|
||||
@@ -1,219 +0,0 @@
|
||||
package com.ruoyi.schedule.scheduleTask;
|
||||
|
||||
import cn.hutool.Hutool;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.http.HttpResponse;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.ruoyi.common.Constant;
|
||||
import com.ruoyi.common.TaskStatusCode;
|
||||
import com.ruoyi.common.TaskType;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.uuid.UUID;
|
||||
import com.ruoyi.device.agv.domain.ResponseBase;
|
||||
import com.ruoyi.device.agv.domain.genAgvSchedulingTask.GenAgvSchedulingTaskRequest;
|
||||
import com.ruoyi.device.agv.domain.genAgvSchedulingTask.GenAgvSchedulingTaskResponse;
|
||||
import com.ruoyi.device.agv.domain.genAgvSchedulingTask.PositionCodeData;
|
||||
import com.ruoyi.device.agv.domain.queryTaskStatus.TaskStatusData;
|
||||
import com.ruoyi.schedule.job.mydojob.domain.MydoJob;
|
||||
import com.ruoyi.schedule.task.domain.WcsTask;
|
||||
import com.ruoyi.schedule.task.mapper.WcsTaskMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 向AGV/CTU下发指令
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class Execution {
|
||||
|
||||
@Autowired
|
||||
WcsTaskMapper wcsTaskMapper;
|
||||
|
||||
/**
|
||||
* 查询是否有wcs任务
|
||||
*/
|
||||
// @PostConstruct
|
||||
public List<MydoJob> getmydoJob(){
|
||||
|
||||
String url = Constant.BASEURL + "/job/inmydoJob/listAll";
|
||||
|
||||
HttpResponse response = HttpRequest.get(url).execute();
|
||||
|
||||
List<MydoJob> mydoJobs = JSON.parseArray(response.body(), MydoJob.class);
|
||||
|
||||
return mydoJobs;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有wcs任务并请求下发
|
||||
*/
|
||||
public void executeTask(){
|
||||
|
||||
//查询实时任务表获取所有【待执行】任务
|
||||
LambdaQueryWrapper<WcsTask> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(WcsTask::getTaskStatus, TaskStatusCode.TASK_READY);
|
||||
List<WcsTask> tasks = wcsTaskMapper.selectList(queryWrapper);
|
||||
|
||||
//无【待执行】任务
|
||||
if (tasks.size() == 0) return;
|
||||
|
||||
//请求agv/ctu下发指令
|
||||
GenAgvSchedulingTaskRequest request = new GenAgvSchedulingTaskRequest();
|
||||
|
||||
for (int i = 0; i < tasks.size(); i++) {
|
||||
|
||||
//判断任务类型
|
||||
switch (tasks.get(i).getTaskType()) {
|
||||
case TaskType.CONV_STOCKIN:
|
||||
//todo 是否要处理输送线取货工位有多个料箱的情况
|
||||
//todo 是否要处理输送线取货工位有多个料箱的情况
|
||||
|
||||
|
||||
request.setReqCode(UUID.randomUUID().toString().replace("-", ""));
|
||||
|
||||
//设备执行任务内置任务类型初始化
|
||||
switch (tasks.get(i).getTaskType()) {
|
||||
case "1":
|
||||
request.setTaskTyp("F12");
|
||||
break;
|
||||
case "2":
|
||||
request.setTaskTyp("F11");
|
||||
break;
|
||||
default:
|
||||
log.warn("【向设备下发任务请求】TaskTyp:{},生成任务的请求参数错误,异常的任务类型!", request.getTaskTyp());
|
||||
return;
|
||||
}
|
||||
|
||||
//todo 了解CTU货架与工作台输送过程中是否需要另外下发取放料箱的任务
|
||||
//todo 了解CTU货架与工作台输送过程中是否需要另外下发取放料箱的任务
|
||||
|
||||
//添加路径(未测试)
|
||||
//todo 了解AGV/CTU路径的格式/规则
|
||||
//todo 了解AGV/CTU路径的格式/规则
|
||||
List<PositionCodeData> path = new ArrayList<>();
|
||||
path.add(new PositionCodeData(tasks.get(i).getSourceLocation(),"05"));
|
||||
path.add(new PositionCodeData(tasks.get(i).getTargetLocation(),"05"));
|
||||
request.setPositionCodePath(path);
|
||||
|
||||
//wcs任务号---设备任务编号
|
||||
request.setTaskCode(tasks.get(i).getTaskId());
|
||||
|
||||
|
||||
//todo 上层平台是否有【校验料箱是否可入库】接口可用
|
||||
//todo 上层平台是否有【校验料箱是否可入库】接口可用
|
||||
|
||||
|
||||
//todo 是否需要单独请求取放料箱接口
|
||||
//todo 是否需要单独请求取放料箱接口
|
||||
|
||||
break;
|
||||
case TaskType.CONV_STOCKOUT_SINGLE_GROUP:
|
||||
|
||||
break;
|
||||
case TaskType.CONV_STOCKOUT_SEQUENCE:
|
||||
|
||||
break;
|
||||
case TaskType.AGV_MOVE:
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
//下发成功---更新【任务状态】为下发成功
|
||||
if (sendCommand(request)){
|
||||
tasks.get(i).setTaskStatus(TaskStatusCode.TASK_SEND_SUCCESS);
|
||||
wcsTaskMapper.updateWcsTask(tasks.get(i));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 向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 ) {
|
||||
if (genAgvSchedulingTaskResponse.getMessage() == ""){
|
||||
log.error("【下发设备任务】下发任务失败,发生了未知错误");
|
||||
}else{
|
||||
log.error("【下发设备任务】下发任务失败,{}", genAgvSchedulingTaskResponse.getMessage());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 下发指令校验
|
||||
* @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;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,119 +0,0 @@
|
||||
package com.ruoyi.schedule.scheduleTask;
|
||||
|
||||
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.PositionCodeData;
|
||||
import com.ruoyi.schedule.data.ConvConnection;
|
||||
import com.ruoyi.schedule.plc.domain.ConvPTLInRead;
|
||||
import com.ruoyi.schedule.plc.domain.ConvPTLOutRead;
|
||||
import com.ruoyi.schedule.task.domain.WcsTask;
|
||||
import com.ruoyi.schedule.task.service.IWcsTaskService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 获取任务生成AGV指令
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class Generation {
|
||||
|
||||
@Autowired
|
||||
ConvConnection conv;
|
||||
|
||||
@Autowired
|
||||
Execution execution;
|
||||
|
||||
@Autowired
|
||||
IWcsTaskService iWcsTaskService;
|
||||
|
||||
public void generateTask() {
|
||||
|
||||
//=========================CTU入库(PTL拣选出口到位)=========================
|
||||
List<ConvPTLOutRead> convPTLOutReads=conv.getConvPTLOut();
|
||||
|
||||
//轮询输送机状态
|
||||
for (int i = 0; i < convPTLOutReads.size(); i++) {
|
||||
|
||||
//PTL出口输送机到位
|
||||
//条码不为空 && 存在任务号 && 设备占用(非空闲)
|
||||
if (StringUtils.isBlank(convPTLOutReads.get(i).getPalletId()) &&
|
||||
StringUtils.isBlank(convPTLOutReads.get(i).getTaskId()) &&
|
||||
convPTLOutReads.get(i).getFree() == 0) {
|
||||
|
||||
|
||||
//todo 请求wms获取调度任务 或 wms推送调度任务(请求wcs接口)
|
||||
//todo 有无其他任务字段校验
|
||||
|
||||
// HttpResponse response = HttpRequest.get(Constant.BASEURL + "/job/inmydoJob/getTaskCount").execute();
|
||||
// Integer count = JSON.parseObject(response.body(), Integer.class);
|
||||
//
|
||||
// WcsTask task = new WcsTask();
|
||||
//
|
||||
// iWcsTaskService.insertWcsTask(task);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//=========================CTU出库(PTL拣选入口空)=========================
|
||||
List<ConvPTLInRead> convPTLInReads=conv.getConvPTLIn();
|
||||
|
||||
for (int i = 0; i < convPTLInReads.size(); i++) {
|
||||
|
||||
//PTL入口输送机空位
|
||||
//设备空闲 && 输送机任务号空
|
||||
if (convPTLInReads.get(i).getFree() == 1 && StringUtils.isBlank(convPTLInReads.get(i).getTaskId())){
|
||||
//todo 请求wms获取调度任务 或 wms推送调度任务(请求wcs接口)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//=========================获取PTL拣选工位出口状态---【CTU入库】=========================
|
||||
public List<ConvPTLOutRead> getConvPTLOutRead() {
|
||||
|
||||
List<ConvPTLOutRead> convPTLOutReads = conv.getConvPTLOut();
|
||||
|
||||
//轮询输送机状态
|
||||
for (int i = 0; i < convPTLOutReads.size(); i++) {
|
||||
|
||||
//条码不为空 && 存在任务号 && 设备占用(非空闲)
|
||||
if (StringUtils.isBlank(convPTLOutReads.get(i).getPalletId()) && StringUtils.isBlank(convPTLOutReads.get(i).getTaskId()) && convPTLOutReads.get(i).getFree() == 0) {
|
||||
|
||||
//查找mydoJob是否存在该条码的任务
|
||||
//todo 有无其他任务字段校验
|
||||
HttpResponse response = HttpRequest.get(Constant.BASEURL + "/job/inmydoJob/getTaskCount").execute();
|
||||
Integer count = JSON.parseObject(response.body(), Integer.class);
|
||||
|
||||
WcsTask task = new WcsTask();
|
||||
|
||||
iWcsTaskService.insertWcsTask(task);
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return convPTLOutReads;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,104 +0,0 @@
|
||||
package com.ruoyi.schedule.scheduleTask;
|
||||
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.http.HttpResponse;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.ruoyi.common.Constant;
|
||||
import com.ruoyi.common.TaskStatusCode;
|
||||
import com.ruoyi.device.agv.domain.queryTaskStatus.QueryTaskStatusRequest;
|
||||
import com.ruoyi.device.agv.domain.queryTaskStatus.QueryTaskStatusResponse;
|
||||
import com.ruoyi.device.agv.domain.queryTaskStatus.TaskStatusData;
|
||||
import com.ruoyi.schedule.task.domain.WcsTask;
|
||||
import com.ruoyi.schedule.task.mapper.WcsTaskMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 通过【查询任务状态】接口获取当前任务的任务状态(待执行/执行中/结束...)
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class StatusUpdate {
|
||||
|
||||
@Autowired
|
||||
WcsTaskMapper wcsTaskMapper;
|
||||
|
||||
|
||||
public void statusUpdate() {
|
||||
|
||||
//查询实时任务表获取所有【下发成功】任务
|
||||
LambdaQueryWrapper<WcsTask> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.ne(WcsTask::getTaskStatus, TaskStatusCode.TASK_READY);
|
||||
List<WcsTask> tasks = wcsTaskMapper.selectList(queryWrapper);
|
||||
|
||||
if (tasks.size() == 0 || tasks == null) return;
|
||||
|
||||
//wcs本地任务轮询
|
||||
for (int i = 0; i < tasks.size(); i++) {
|
||||
//查询【设备任务状态】接口是否已有该任务号
|
||||
HttpResponse response = HttpRequest.post(Constant.BASEURL + "/queryTaskStatus")
|
||||
.body(JSON.toJSONString(new QueryTaskStatusRequest()))
|
||||
.execute();
|
||||
QueryTaskStatusResponse queryTaskStatusResponse = JSON.parseObject(response.body(), QueryTaskStatusResponse.class);
|
||||
List<TaskStatusData> deviceTasks = queryTaskStatusResponse.getData();
|
||||
|
||||
if (deviceTasks.size() == 0 || deviceTasks == null) return;
|
||||
|
||||
//接口查询的AGV/CTU设备任务轮询
|
||||
for (int j = 0; j < deviceTasks.size(); j++) {
|
||||
|
||||
//wcs任务记录的任务号与接口查询的任务号匹配
|
||||
if (tasks.get(i).getTaskId() != deviceTasks.get(j).getTaskCode()) continue;
|
||||
|
||||
switch (deviceTasks.get(j).getTaskStatus()) {
|
||||
case "1":
|
||||
//【任务状态】更新为已创建
|
||||
if (tasks.get(j).getTaskStatus() == TaskStatusCode.TASK_SEND_SUCCESS && tasks.get(j).getTaskStatus() != TaskStatusCode.TASK_CREATED) {
|
||||
tasks.get(j).setTaskStatus(TaskStatusCode.TASK_CREATED);
|
||||
wcsTaskMapper.updateWcsTask(tasks.get(i));
|
||||
}
|
||||
break;
|
||||
case "2"://【任务状态】更新为执行中
|
||||
if (tasks.get(j).getTaskStatus() == TaskStatusCode.TASK_CREATED && tasks.get(j).getTaskStatus() != TaskStatusCode.TASK_RUNNING) {
|
||||
tasks.get(j).setTaskStatus(TaskStatusCode.TASK_RUNNING);
|
||||
//更新【调度时间】
|
||||
tasks.get(j).setScheduleTime(LocalDateTime.now());
|
||||
wcsTaskMapper.updateWcsTask(tasks.get(i));
|
||||
}
|
||||
break;
|
||||
case "5"://【任务状态】更新为已取消
|
||||
if ((tasks.get(j).getTaskStatus() == TaskStatusCode.TASK_CREATED ||
|
||||
tasks.get(j).getTaskStatus() == TaskStatusCode.TASK_RUNNING) &&
|
||||
tasks.get(j).getTaskStatus() != TaskStatusCode.TASK_CANCEL) {
|
||||
tasks.get(j).setTaskStatus(TaskStatusCode.TASK_CANCEL);
|
||||
wcsTaskMapper.updateWcsTask(tasks.get(i));
|
||||
}
|
||||
break;
|
||||
case "9"://【任务状态】更新为已结束
|
||||
if (tasks.get(j).getTaskStatus() != TaskStatusCode.TASK_FINISH) {
|
||||
tasks.get(j).setTaskStatus(TaskStatusCode.TASK_FINISH);
|
||||
wcsTaskMapper.updateWcsTask(tasks.get(j));
|
||||
}
|
||||
break;
|
||||
case "10"://【任务状态】更新为被中断
|
||||
if (tasks.get(j).getTaskStatus() != TaskStatusCode.TASK_INTERUPTED) {
|
||||
tasks.get(j).setTaskStatus(TaskStatusCode.TASK_INTERUPTED);
|
||||
wcsTaskMapper.updateWcsTask(tasks.get(j));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
package com.ruoyi.schedule.scheduleTask;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.ruoyi.common.TaskStatusCode;
|
||||
import com.ruoyi.schedule.task.domain.WcsTask;
|
||||
import com.ruoyi.schedule.task.mapper.WcsTaskMapper;
|
||||
import com.ruoyi.schedule.taskHistory.domain.WcsTaskHistory;
|
||||
import com.ruoyi.schedule.taskHistory.mapper.WcsTaskHistoryMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class TaskFinish {
|
||||
|
||||
@Autowired
|
||||
WcsTaskMapper wcsTaskMapper;
|
||||
|
||||
@Autowired
|
||||
WcsTaskHistoryMapper wcsTaskHistoryMapper;
|
||||
|
||||
public void taskFinish() {
|
||||
|
||||
//查询实时任务表获取所有【已结束】,【已取消】和手动处理的任务任务
|
||||
LambdaQueryWrapper<WcsTask> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(WcsTask::getTaskStatus, TaskStatusCode.TASK_FINISH)
|
||||
.or()
|
||||
.eq(WcsTask::getTaskStatus, TaskStatusCode.TASK_CANCEL)
|
||||
.or()
|
||||
.eq(WcsTask::getTaskStatus, TaskStatusCode.TASK_FINISH_MANUAL)
|
||||
.or()
|
||||
.eq(WcsTask::getTaskStatus, TaskStatusCode.TASK_CANCEL_MANUAL);;
|
||||
List<WcsTask> tasks = wcsTaskMapper.selectList(queryWrapper);
|
||||
|
||||
for (int i = 0; i < tasks.size(); i++) {
|
||||
|
||||
//todo 任务完成/取消请求wms
|
||||
//todo 任务完成/取消请求wms
|
||||
//todo 任务完成/取消请求wms
|
||||
|
||||
|
||||
|
||||
WcsTaskHistory wcsTaskHistory = new WcsTaskHistory();
|
||||
BeanUtils.copyProperties(tasks.get(i), wcsTaskHistory);
|
||||
wcsTaskHistory.setFinishTime(LocalDateTime.now());
|
||||
|
||||
//向历史记录添加任务数据
|
||||
wcsTaskHistoryMapper.insertWcsTaskHistory(wcsTaskHistory);
|
||||
log.info("【添加到历任务记录】{}", JSON.toJSONString(wcsTaskHistory));
|
||||
|
||||
//移除实时任务表数据
|
||||
wcsTaskMapper.deleteWcsTaskByTaskId(tasks.get(i).getTaskId());
|
||||
log.info("【实时任务已完成】{}", JSON.toJSONString(tasks.get(i)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.ruoyi.schedule.scheduleTask;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
/**
|
||||
* 用于处理没有正常执行或完成/取消的任务
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class TaskHandler {
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
package com.ruoyi.schedule.scheduleTask;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class Timer {
|
||||
|
||||
@Autowired
|
||||
Generation generation;
|
||||
|
||||
@Autowired
|
||||
Execution execution;
|
||||
|
||||
@Autowired
|
||||
StatusUpdate statusUpdate;
|
||||
|
||||
@Autowired
|
||||
TaskFinish taskFinish;
|
||||
|
||||
@Autowired
|
||||
TaskHandler taskHandler;
|
||||
|
||||
@Async
|
||||
@Scheduled(cron = "*/2 * * * * *")
|
||||
public void timerTask() {
|
||||
|
||||
try {
|
||||
execution.executeTask();
|
||||
Thread.sleep(200);
|
||||
|
||||
//statusUpdate.statusUpdate();
|
||||
//Thread.sleep(200);
|
||||
|
||||
taskFinish.taskFinish();
|
||||
Thread.sleep(200);
|
||||
|
||||
// generation.
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("【调度任务异常】" + e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
package com.ruoyi.schedule.scheduleTask.agv;
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class AgvDispatch {
|
||||
|
||||
// 基础URL
|
||||
private final String baseUrl;
|
||||
|
||||
// 客户端编号
|
||||
private String clientCode;
|
||||
|
||||
// 令牌号
|
||||
private String tokenCode;
|
||||
|
||||
public AgvDispatch(String ip, int port) {
|
||||
this.baseUrl = String.format("http://%s:%d/rcms/services/rest", ip, port);
|
||||
}
|
||||
|
||||
public AgvDispatch(String baseUrl) {
|
||||
this.baseUrl = baseUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成唯一请求编号
|
||||
*/
|
||||
private String generateReqCode() {
|
||||
return IdUtil.fastSimpleUUID();
|
||||
}
|
||||
|
||||
// ------------------------------ 常用接口 ------------------------------
|
||||
|
||||
/**
|
||||
* 2.1.1 生成任务单
|
||||
* @param taskTyp 任务类型
|
||||
* @param wbCode 工作位
|
||||
* @param positionCodePath 位置路径
|
||||
* @param podCode 货架编号
|
||||
* @return 接口返回结果
|
||||
*/
|
||||
public String genAgvSchedulingTask(String taskTyp, String wbCode,
|
||||
Object[] positionCodePath, String podCode) throws IOException {
|
||||
String url = baseUrl + "/hikRpcService/genAgvSchedulingTask";
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("taskTyp", taskTyp);
|
||||
params.put("wbCode", wbCode);
|
||||
params.put("positionCodePath", positionCodePath);
|
||||
params.put("podCode", podCode);
|
||||
return HttpUtil.post(url, params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 2.1.2 继续执行任务
|
||||
* @param taskCode 任务单号
|
||||
* @return 接口返回结果
|
||||
*/
|
||||
public String continueTask(String taskCode) throws IOException {
|
||||
String url = baseUrl + "/hikRpcService/continueTask";
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("taskCode", taskCode);
|
||||
return HttpUtil.post(url, params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 2.1.3 取消任务
|
||||
* @param taskCode 任务单号
|
||||
* @param forceCancel 取消类型(0-直接放地上,1-软取消)
|
||||
* @return 接口返回结果
|
||||
*/
|
||||
public String cancelTask(String taskCode, String forceCancel) throws IOException {
|
||||
String url = baseUrl + "/hikRpcService/cancelTask";
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("taskCode", taskCode);
|
||||
params.put("forceCancel", forceCancel);
|
||||
return HttpUtil.post(url, params);
|
||||
}
|
||||
|
||||
// ------------------------------ 可选接口 ------------------------------
|
||||
|
||||
/**
|
||||
* 3.1.1 任务优先级设置
|
||||
* @param priorities 优先级列表
|
||||
* @return 接口返回结果
|
||||
*/
|
||||
public String setTaskPriority(Object[] priorities) throws IOException {
|
||||
String url = baseUrl + "/hikRpcService/setTaskPriority";
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("priorities", priorities);
|
||||
return HttpUtil.post(url, params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 3.1.2 货架与位置绑定、解绑
|
||||
* @param podCode 货架编号
|
||||
* @param positionCode 位置编号
|
||||
* @param indBind 1-绑定,0-解绑
|
||||
* @return 接口返回结果
|
||||
*/
|
||||
public String bindPodAndBerth(String podCode, String positionCode, String indBind) throws IOException {
|
||||
String url = baseUrl + "/hikRpcService/bindPodAndBerth";
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("podCode", podCode);
|
||||
params.put("positionCode", positionCode);
|
||||
params.put("indBind", indBind);
|
||||
return HttpUtil.post(url, params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 3.1.9 查询任务状态
|
||||
* @param taskCodes 任务单编号数组
|
||||
* @return 接口返回结果
|
||||
*/
|
||||
public String queryTaskStatus(String[] taskCodes) throws IOException {
|
||||
String url = baseUrl + "/hikRpcService/queryTaskStatus";
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("taskCodes", taskCodes);
|
||||
return HttpUtil.post(url, params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 3.1.10 查询AGV状态
|
||||
* @param mapCode 地图编号
|
||||
* @return 接口返回结果
|
||||
*/
|
||||
public String queryAgvStatus(String mapCode) throws IOException {
|
||||
String url = "http://" + baseUrl.split("//")[1].split("/")[0] + "/rcms-dps/rest/queryAgvStatus";
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("mapCode", mapCode);
|
||||
return HttpUtil.post(url, params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 3.1.16 料箱出库TPS(CTU+分拨墙)
|
||||
* @param taskTyp 任务类型(传1)
|
||||
* @param data 任务数据列表
|
||||
* @return 接口返回结果
|
||||
*/
|
||||
public String getOutPod(String taskTyp, Object[] data) throws IOException {
|
||||
String url = baseUrl + "/hikTpsService/getOutPod";
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("taskTyp", taskTyp);
|
||||
params.put("data", data);
|
||||
return HttpUtil.post(url, params);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
package com.ruoyi.schedule.scheduleTask.ssj;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.ruoyi.device.agv.domain.AgvQueue;
|
||||
import com.ruoyi.device.agv.service.IAgvQueueService;
|
||||
import com.ruoyi.api.domain.agv.genAgvSchedulingTask.GenAgvSchedulingTaskRequest;
|
||||
import com.ruoyi.api.domain.agv.genAgvSchedulingTask.GenAgvSchedulingTaskResponse;
|
||||
import com.ruoyi.api.domain.wcs2wms.MydoJob;
|
||||
import com.ruoyi.api.service.IApiService;
|
||||
import com.ruoyi.schedule.plcRead.ssj.domain.SsjDevice;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class InSsjThread {
|
||||
|
||||
public ConcurrentHashMap<String, SsjDevice> deviceMap;
|
||||
|
||||
@Resource
|
||||
private IApiService apiService;
|
||||
@Resource
|
||||
private IAgvQueueService agvQueueService;
|
||||
|
||||
|
||||
public void inDispatch(SsjDevice inSsjDevice) {
|
||||
//如果入库请求1 并且 托盘码不为空
|
||||
if (inSsjDevice.getEntryRequest() == 1 && StrUtil.isNotEmpty(inSsjDevice.getTrayCode())) {
|
||||
//根据入口,查询对应的入库作业
|
||||
MydoJob mydoJobParam = new MydoJob();
|
||||
//mydoJobParam.setEntranceId(inSsjDevice.getDeviceCode());
|
||||
mydoJobParam.setStatus("1");
|
||||
mydoJobParam.setTrayCode(inSsjDevice.getTrayCode());
|
||||
List<MydoJob> mydoJobs = apiService.getMydoJobList(mydoJobParam);
|
||||
if (CollUtil.isNotEmpty(mydoJobs)) {
|
||||
MydoJob mydoJob = mydoJobs.get(0);
|
||||
//修改mydojob入口
|
||||
mydoJob.setEntranceId(inSsjDevice.getDeviceCode());
|
||||
apiService.updateMydoJob(mydoJob);
|
||||
|
||||
//判断是否生成队列
|
||||
AgvQueue agvQueueParam = new AgvQueue();
|
||||
agvQueueParam.setWmsTaskNo(mydoJob.getTaskNo());
|
||||
agvQueueParam.setPositionCode1(inSsjDevice.getDeviceCode());
|
||||
agvQueueParam.setStatus("0");
|
||||
List<AgvQueue> agvQueues = agvQueueService.selectAgvQueueList(agvQueueParam);
|
||||
if (CollUtil.isEmpty(agvQueues)) {
|
||||
//生成agv队列
|
||||
AgvQueue agvQueue = createAgvQueue(inSsjDevice, mydoJob);
|
||||
//请求任务生成
|
||||
GenAgvSchedulingTaskResponse genAgvSchedulingTaskResponse = requestAgvQueue(mydoJob, agvQueue);
|
||||
//修改wms任务状态
|
||||
if (genAgvSchedulingTaskResponse.getCode() == 0) {
|
||||
//修改ctu执行状态
|
||||
agvQueue.setStatus("1");
|
||||
agvQueueService.updateAgvQueue(agvQueue);
|
||||
log.info("向CTU下入库库作业");
|
||||
//修改mydoJob执行阶段
|
||||
mydoJob.setExecutionPhase("6");
|
||||
apiService.updateMydoJob(mydoJob);
|
||||
}
|
||||
} else {
|
||||
AgvQueue agvQueue = agvQueues.get(0);
|
||||
//请求任务生成
|
||||
GenAgvSchedulingTaskResponse genAgvSchedulingTaskResponse = requestAgvQueue(mydoJob, agvQueue);
|
||||
//修改wms任务状态
|
||||
if (genAgvSchedulingTaskResponse.getCode() == 0) {
|
||||
//修改ctu执行状态
|
||||
agvQueue.setStatus("1");
|
||||
agvQueueService.updateAgvQueue(agvQueue);
|
||||
log.info("向CTU下入库库作业");
|
||||
//修改mydoJob执行阶段
|
||||
mydoJob.setExecutionPhase("6");
|
||||
apiService.updateMydoJob(mydoJob);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
mydoJobParam.setEntranceId(inSsjDevice.getDeviceCode());
|
||||
mydoJobParam.setStatus("3");
|
||||
mydoJobParam.setTrayCode(inSsjDevice.getTrayCode());
|
||||
mydoJobs = apiService.getMydoJobList(mydoJobParam);
|
||||
if (CollUtil.isNotEmpty(mydoJobs)) {
|
||||
log.info("trayCode:{} 入库作业正在执行中", inSsjDevice.getTrayCode());
|
||||
} else {
|
||||
log.info("trayCode:{} 无入库作业", inSsjDevice.getTrayCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成入库AGV队列
|
||||
*
|
||||
* @param ssjDevice
|
||||
* @param mydoJob
|
||||
* @return
|
||||
*/
|
||||
private AgvQueue createAgvQueue(SsjDevice ssjDevice, MydoJob mydoJob) {
|
||||
//生成ctu执行队列
|
||||
AgvQueue agvQueue = new AgvQueue();
|
||||
String reqCode = IdUtil.fastSimpleUUID();
|
||||
agvQueue.setReqCode(reqCode);
|
||||
agvQueue.setReqTime(DateUtil.formatDateTime(DateUtil.date()));
|
||||
agvQueue.setAgvType("CTU");
|
||||
agvQueue.setPositionCode1(mydoJob.getCargoSpaceId());
|
||||
agvQueue.setPositionCode2(ssjDevice.getDeviceCode());
|
||||
agvQueue.setTaskType("F01");
|
||||
agvQueue.setCtnrType("0");
|
||||
agvQueue.setCtnrCode("0");
|
||||
agvQueue.setCtnrNum("0");
|
||||
agvQueue.setTaskMode("0");
|
||||
agvQueue.setPriority("10");
|
||||
agvQueue.setRequest("0");
|
||||
agvQueue.setWmsTraycode(mydoJob.getTrayCode());
|
||||
agvQueue.setWmsTaskNo(mydoJob.getTaskNo());
|
||||
agvQueue.setStatus("0");
|
||||
agvQueueService.insertAgvQueue(agvQueue);
|
||||
return agvQueue;
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求海康生成agv任务,并修改wms任务状态
|
||||
*
|
||||
* @param mydoJob
|
||||
* @param agvQueue
|
||||
*/
|
||||
private GenAgvSchedulingTaskResponse requestAgvQueue(MydoJob mydoJob, AgvQueue agvQueue) {
|
||||
//请求ctu
|
||||
GenAgvSchedulingTaskRequest genAgvSchedulingTaskRequest = new GenAgvSchedulingTaskRequest();
|
||||
genAgvSchedulingTaskRequest.setReqCode(agvQueue.getReqCode());
|
||||
genAgvSchedulingTaskRequest.setTaskMode("0");
|
||||
genAgvSchedulingTaskRequest.setPriority("10");
|
||||
genAgvSchedulingTaskRequest.setTaskTyp("F01");
|
||||
genAgvSchedulingTaskRequest.setCtnrCode("0");
|
||||
genAgvSchedulingTaskRequest.setCtnrNum("0");
|
||||
genAgvSchedulingTaskRequest.setTaskMode("0");
|
||||
genAgvSchedulingTaskRequest.setTaskCode(mydoJob.getTaskNo());
|
||||
genAgvSchedulingTaskRequest.setGroupId(mydoJob.getTaskNo());
|
||||
genAgvSchedulingTaskRequest.setAgvTyp("CTU");
|
||||
genAgvSchedulingTaskRequest.setPositionSelStrategy("0");
|
||||
return apiService.genAgvSchedulingTask(genAgvSchedulingTaskRequest);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.ruoyi.schedule.scheduleTask.ssj;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.ruoyi.device.agv.domain.AgvQueue;
|
||||
import com.ruoyi.device.agv.service.IAgvQueueService;
|
||||
import com.ruoyi.api.domain.agv.genAgvSchedulingTask.GenAgvSchedulingTaskRequest;
|
||||
import com.ruoyi.api.domain.agv.genAgvSchedulingTask.GenAgvSchedulingTaskResponse;
|
||||
import com.ruoyi.api.domain.wcs2wms.MydoJob;
|
||||
import com.ruoyi.api.service.IApiService;
|
||||
import com.ruoyi.schedule.plcRead.ssj.domain.SsjDevice;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class OutSsjThread {
|
||||
|
||||
public ConcurrentHashMap<String, List<SsjDevice>> deviceMap;
|
||||
|
||||
@Resource
|
||||
private IApiService apiService;
|
||||
@Resource
|
||||
private IAgvQueueService agvQueueService;
|
||||
|
||||
|
||||
public void outDispatch(SsjDevice outSsjDevice) {
|
||||
//输送线出库
|
||||
if (outSsjDevice.getEmpty()==1){
|
||||
//查询对应的作业
|
||||
AgvQueue agvQueue = new AgvQueue();
|
||||
agvQueue.setPositionCode2(outSsjDevice.getDeviceCode());
|
||||
agvQueue.setStatus("0");
|
||||
List<AgvQueue> agvQueueList = agvQueueService.selectAgvQueueList(agvQueue);
|
||||
if (CollUtil.isNotEmpty(agvQueueList)){
|
||||
for (AgvQueue queue : agvQueueList) {
|
||||
MydoJob mydoJobParam = new MydoJob();
|
||||
mydoJobParam.setTaskNo(queue.getWmsTaskNo());
|
||||
mydoJobParam.setTrayCode(queue.getWmsTraycode());
|
||||
mydoJobParam.setCargoSpaceId(queue.getPositionCode1());
|
||||
List<MydoJob> mydoJobList = apiService.getMydoJobList(mydoJobParam);
|
||||
if (CollUtil.isNotEmpty(mydoJobList)){
|
||||
MydoJob mydoJob = mydoJobList.get(0);
|
||||
requestAgvQueue(mydoJob, queue);
|
||||
}else {
|
||||
log.info("队列 agvCode {},无对应出库作业", agvQueue.getReqCode());
|
||||
}
|
||||
}
|
||||
}else {
|
||||
log.info("ssjCode:{},没有待下发的出库任务", outSsjDevice.getDeviceCode());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求海康生成agv任务,并修改wms任务状态
|
||||
* @param mydoJob
|
||||
* @param agvQueue
|
||||
*/
|
||||
private void requestAgvQueue(MydoJob mydoJob, AgvQueue agvQueue) {
|
||||
//请求ctu
|
||||
GenAgvSchedulingTaskRequest genAgvSchedulingTaskRequest = new GenAgvSchedulingTaskRequest();
|
||||
genAgvSchedulingTaskRequest.setReqCode(agvQueue.getReqCode());
|
||||
genAgvSchedulingTaskRequest.setTaskMode("0");
|
||||
genAgvSchedulingTaskRequest.setPriority("10");
|
||||
genAgvSchedulingTaskRequest.setTaskTyp("F01");
|
||||
genAgvSchedulingTaskRequest.setCtnrCode("0");
|
||||
genAgvSchedulingTaskRequest.setCtnrNum("0");
|
||||
genAgvSchedulingTaskRequest.setTaskMode("0");
|
||||
genAgvSchedulingTaskRequest.setTaskCode(mydoJob.getTaskNo());
|
||||
genAgvSchedulingTaskRequest.setGroupId(mydoJob.getTaskNo());
|
||||
genAgvSchedulingTaskRequest.setAgvTyp("CTU");
|
||||
genAgvSchedulingTaskRequest.setPositionSelStrategy("0");
|
||||
GenAgvSchedulingTaskResponse genAgvSchedulingTaskResponse = apiService.genAgvSchedulingTask(genAgvSchedulingTaskRequest);
|
||||
if (genAgvSchedulingTaskResponse.getCode() == 0){
|
||||
//修改ctu执行状态
|
||||
agvQueue.setStatus("1");
|
||||
agvQueueService.updateAgvQueue(agvQueue);
|
||||
log.info("向CTU下入库库作业");
|
||||
//修改mydoJob执行阶段
|
||||
mydoJob.setExecutionPhase("6");
|
||||
apiService.updateMydoJob(mydoJob);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.ruoyi.schedule.scheduleTask.ssj;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.ruoyi.device.agv.service.IAgvQueueService;
|
||||
import com.ruoyi.common.core.text.Convert;
|
||||
import com.ruoyi.api.domain.wcs2wms.MydoJob;
|
||||
import com.ruoyi.api.service.IApiService;
|
||||
import com.ruoyi.schedule.plcRead.ssj.domain.SsjDevice;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class PickSsjTread {
|
||||
|
||||
public ConcurrentHashMap<String, List<SsjDevice>> deviceMap;
|
||||
|
||||
@Resource
|
||||
private IApiService apiService;
|
||||
@Resource
|
||||
private IAgvQueueService agvQueueService;
|
||||
|
||||
|
||||
public void pickDispatch(SsjDevice pickSsjDevice) {
|
||||
if (pickSsjDevice.getInPlace() == 1 && pickSsjDevice.getTaskNo() > 0){
|
||||
Integer taskNo = pickSsjDevice.getTaskNo();
|
||||
MydoJob mydoJobParam = new MydoJob();
|
||||
mydoJobParam.setStatus("3");
|
||||
mydoJobParam.setTaskNo(Convert.toStr(taskNo));
|
||||
mydoJobParam.setExitId(pickSsjDevice.getDeviceCode());
|
||||
List<MydoJob> mydoJobList = apiService.getMydoJobList(mydoJobParam);
|
||||
if (CollUtil.isNotEmpty(mydoJobList)){
|
||||
MydoJob mydoJob = mydoJobList.get(0);
|
||||
if ("4".equals(mydoJob.getExecutionPhase())){
|
||||
mydoJob.setExecutionPhase("5");
|
||||
apiService.updateMydoJob(mydoJob);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,190 +0,0 @@
|
||||
package com.ruoyi.schedule.task.controller;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.ruoyi.common.TaskStatusCode;
|
||||
import com.ruoyi.device.agv.domain.ResponseBase;
|
||||
import com.ruoyi.schedule.task.mapper.WcsTaskMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.schedule.task.domain.WcsTask;
|
||||
import com.ruoyi.schedule.task.service.IWcsTaskService;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 实时任务Controller
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-06-27
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/schedule/task")
|
||||
@Slf4j
|
||||
public class WcsTaskController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private IWcsTaskService wcsTaskService;
|
||||
|
||||
@Autowired
|
||||
WcsTaskMapper wcsTaskMapper;
|
||||
|
||||
/**
|
||||
* 查询实时任务列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('schedule:task:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(WcsTask wcsTask)
|
||||
{
|
||||
startPage();
|
||||
List<WcsTask> list = wcsTaskService.selectWcsTaskList(wcsTask);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出实时任务列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('schedule:task:export')")
|
||||
@Log(title = "实时任务", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, WcsTask wcsTask)
|
||||
{
|
||||
List<WcsTask> list = wcsTaskService.selectWcsTaskList(wcsTask);
|
||||
ExcelUtil<WcsTask> util = new ExcelUtil<WcsTask>(WcsTask.class);
|
||||
util.exportExcel(response, list, "实时任务数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取实时任务详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('schedule:task:query')")
|
||||
@GetMapping(value = "/{taskId}")
|
||||
public AjaxResult getInfo(@PathVariable("taskId") String taskId)
|
||||
{
|
||||
return success(wcsTaskService.selectWcsTaskByTaskId(taskId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增实时任务
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('schedule:task:add')")
|
||||
@Log(title = "实时任务", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody WcsTask wcsTask)
|
||||
{
|
||||
return toAjax(wcsTaskService.insertWcsTask(wcsTask));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改实时任务
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('schedule:task:edit')")
|
||||
@Log(title = "实时任务", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody WcsTask wcsTask)
|
||||
{
|
||||
return toAjax(wcsTaskService.updateWcsTask(wcsTask));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除实时任务
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('schedule:task:remove')")
|
||||
@Log(title = "实时任务", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{taskIds}")
|
||||
public AjaxResult remove(@PathVariable String[] taskIds)
|
||||
{
|
||||
return toAjax(wcsTaskService.deleteWcsTaskByTaskIds(taskIds));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* PTL拣选入口空---wms推送请求出库---生成wcs本地任务
|
||||
* @param task
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/stockOut")
|
||||
public ResponseBase stockOut(@RequestBody WcsTask task) {
|
||||
|
||||
log.info("【获取出库请求】" + JSON.toJSONString(task));
|
||||
|
||||
ResponseBase response = new ResponseBase();
|
||||
response.setCode(0);
|
||||
response.setMessage("success");
|
||||
response.setData(JSON.toJSONString(task));
|
||||
|
||||
//todo 有无信息校验
|
||||
//查询是否已经有该作业号的任务
|
||||
LambdaQueryWrapper<WcsTask> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(WcsTask::getJobId, task.getJobId());
|
||||
Long count= wcsTaskMapper.selectCount(wrapper);
|
||||
//任务已存在---返回失败
|
||||
if (count > 0) {
|
||||
response.setCode(1);
|
||||
response.setMessage("failed");
|
||||
return response;
|
||||
}
|
||||
|
||||
//初始化任务状态---待执行
|
||||
task.setTaskStatus(TaskStatusCode.TASK_READY);
|
||||
|
||||
wcsTaskService.insertWcsTask(task);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* PTL拣选出口扫描到到位料箱---wms推送请求入库---生成wcs本地任务
|
||||
* @param task
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/stockIn")
|
||||
public ResponseBase stockIn(@RequestBody WcsTask task) {
|
||||
|
||||
log.info("【获取入库请求】" + JSON.toJSONString(task));
|
||||
|
||||
ResponseBase response = new ResponseBase();
|
||||
response.setCode(0);
|
||||
response.setMessage("success");
|
||||
response.setData(JSON.toJSONString(task));
|
||||
|
||||
//todo 有无信息校验
|
||||
//查询是否已经有该作业号的任务
|
||||
LambdaQueryWrapper<WcsTask> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(WcsTask::getJobId, task.getJobId());
|
||||
Long count= wcsTaskMapper.selectCount(wrapper);
|
||||
//任务已存在---返回失败
|
||||
if (count > 0) {
|
||||
response.setCode(1);
|
||||
response.setMessage("failed");
|
||||
return response;
|
||||
}
|
||||
|
||||
//初始化任务状态---待执行
|
||||
task.setTaskStatus(TaskStatusCode.TASK_READY);
|
||||
|
||||
wcsTaskService.insertWcsTask(task);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
package com.ruoyi.schedule.task.domain;
|
||||
|
||||
import lombok.Data;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 实时任务对象 wcs_task
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-06-27
|
||||
*/
|
||||
@Data
|
||||
public class WcsTask
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 作业号 */
|
||||
@Excel(name = "作业号")
|
||||
private String jobId;
|
||||
|
||||
/** wcs任务号 */
|
||||
@Excel(name = "任务号")
|
||||
private String taskId;
|
||||
|
||||
/** 任务类型 */
|
||||
@Excel(name = "任务类型")
|
||||
private String taskType;
|
||||
|
||||
/** 源站点 */
|
||||
@Excel(name = "源站点")
|
||||
private String sourceLocation;
|
||||
|
||||
/** 目标站点 */
|
||||
@Excel(name = "目标站点")
|
||||
private String targetLocation;
|
||||
|
||||
/** 任务状态 */
|
||||
@Excel(name = "任务状态")
|
||||
private String taskStatus;
|
||||
|
||||
/** 生成时间 */
|
||||
@Excel(name = "生成时间")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime createTime = LocalDateTime.now();
|
||||
|
||||
/**
|
||||
* 调度时间
|
||||
* 设备开始运行的时间
|
||||
*/
|
||||
@Excel(name = "调度时间")
|
||||
private LocalDateTime scheduleTime;
|
||||
|
||||
/** 设备编号 */
|
||||
@Excel(name = "设备编号")
|
||||
private String deviceId;
|
||||
|
||||
/** 库区代码 */
|
||||
@Excel(name = "库区代码")
|
||||
private String areaId;
|
||||
|
||||
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
package com.ruoyi.schedule.task.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ruoyi.schedule.task.domain.WcsTask;
|
||||
|
||||
/**
|
||||
* 实时任务Mapper接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-06-27
|
||||
*/
|
||||
public interface WcsTaskMapper extends BaseMapper<WcsTask>
|
||||
{
|
||||
/**
|
||||
* 查询实时任务
|
||||
*
|
||||
* @param taskId 实时任务主键
|
||||
* @return 实时任务
|
||||
*/
|
||||
public WcsTask selectWcsTaskByTaskId(String taskId);
|
||||
|
||||
/**
|
||||
* 查询实时任务
|
||||
*
|
||||
* @param jobId wms作业号
|
||||
* @return 实时任务
|
||||
*/
|
||||
public WcsTask selectWcsTaskByJobId(String jobId);
|
||||
|
||||
/**
|
||||
* 查询实时任务列表
|
||||
*
|
||||
* @param wcsTask 实时任务
|
||||
* @return 实时任务集合
|
||||
*/
|
||||
public List<WcsTask> selectWcsTaskList(WcsTask wcsTask);
|
||||
|
||||
/**
|
||||
* 新增实时任务
|
||||
*
|
||||
* @param wcsTask 实时任务
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertWcsTask(WcsTask wcsTask);
|
||||
|
||||
/**
|
||||
* 修改实时任务
|
||||
*
|
||||
* @param wcsTask 实时任务
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateWcsTask(WcsTask wcsTask);
|
||||
|
||||
/**
|
||||
* 删除实时任务
|
||||
*
|
||||
* @param taskId 实时任务主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteWcsTaskByTaskId(String taskId);
|
||||
|
||||
/**
|
||||
* 批量删除实时任务
|
||||
*
|
||||
* @param taskIds 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteWcsTaskByTaskIds(String[] taskIds);
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
package com.ruoyi.schedule.task.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.schedule.task.domain.WcsTask;
|
||||
|
||||
/**
|
||||
* 实时任务Service接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-06-27
|
||||
*/
|
||||
public interface IWcsTaskService
|
||||
{
|
||||
/**
|
||||
* 查询实时任务
|
||||
*
|
||||
* @param taskId 实时任务主键
|
||||
* @return 实时任务
|
||||
*/
|
||||
public WcsTask selectWcsTaskByTaskId(String taskId);
|
||||
|
||||
|
||||
/**
|
||||
* 查询实时任务
|
||||
*
|
||||
* @param jobId wms作业号
|
||||
* @return 实时任务
|
||||
*/
|
||||
public WcsTask selectWcsTaskByJobId(String jobId);
|
||||
|
||||
/**
|
||||
* 查询实时任务列表
|
||||
*
|
||||
* @param wcsTask 实时任务
|
||||
* @return 实时任务集合
|
||||
*/
|
||||
public List<WcsTask> selectWcsTaskList(WcsTask wcsTask);
|
||||
|
||||
/**
|
||||
* 新增实时任务
|
||||
*
|
||||
* @param wcsTask 实时任务
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertWcsTask(WcsTask wcsTask);
|
||||
|
||||
/**
|
||||
* 修改实时任务
|
||||
*
|
||||
* @param wcsTask 实时任务
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateWcsTask(WcsTask wcsTask);
|
||||
|
||||
/**
|
||||
* 批量删除实时任务
|
||||
*
|
||||
* @param taskIds 需要删除的实时任务主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteWcsTaskByTaskIds(String[] taskIds);
|
||||
|
||||
/**
|
||||
* 删除实时任务信息
|
||||
*
|
||||
* @param taskId 实时任务主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteWcsTaskByTaskId(String taskId);
|
||||
}
|
||||
@@ -1,108 +0,0 @@
|
||||
package com.ruoyi.schedule.task.service.impl;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.schedule.task.mapper.WcsTaskMapper;
|
||||
import com.ruoyi.schedule.task.domain.WcsTask;
|
||||
import com.ruoyi.schedule.task.service.IWcsTaskService;
|
||||
|
||||
/**
|
||||
* 实时任务Service业务层处理
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-06-27
|
||||
*/
|
||||
@Service
|
||||
public class WcsTaskServiceImpl implements IWcsTaskService
|
||||
{
|
||||
@Autowired
|
||||
private WcsTaskMapper wcsTaskMapper;
|
||||
|
||||
/**
|
||||
* 查询实时任务
|
||||
*
|
||||
* @param taskId 实时任务主键
|
||||
* @return 实时任务
|
||||
*/
|
||||
@Override
|
||||
public WcsTask selectWcsTaskByTaskId(String taskId)
|
||||
{
|
||||
return wcsTaskMapper.selectWcsTaskByTaskId(taskId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询实时任务
|
||||
*
|
||||
* @param jobId 实时任务主键
|
||||
* @return 实时任务
|
||||
*/
|
||||
@Override
|
||||
public WcsTask selectWcsTaskByJobId(String jobId)
|
||||
{
|
||||
return wcsTaskMapper.selectWcsTaskByJobId(jobId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询实时任务列表
|
||||
*
|
||||
* @param wcsTask 实时任务
|
||||
* @return 实时任务
|
||||
*/
|
||||
@Override
|
||||
public List<WcsTask> selectWcsTaskList(WcsTask wcsTask)
|
||||
{
|
||||
return wcsTaskMapper.selectWcsTaskList(wcsTask);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增实时任务
|
||||
*
|
||||
* @param wcsTask 实时任务
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertWcsTask(WcsTask wcsTask)
|
||||
{
|
||||
wcsTask.setCreateTime(LocalDateTime.now());
|
||||
return wcsTaskMapper.insertWcsTask(wcsTask);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改实时任务
|
||||
*
|
||||
* @param wcsTask 实时任务
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateWcsTask(WcsTask wcsTask)
|
||||
{
|
||||
return wcsTaskMapper.updateWcsTask(wcsTask);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除实时任务
|
||||
*
|
||||
* @param taskIds 需要删除的实时任务主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteWcsTaskByTaskIds(String[] taskIds)
|
||||
{
|
||||
return wcsTaskMapper.deleteWcsTaskByTaskIds(taskIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除实时任务信息
|
||||
*
|
||||
* @param taskId 实时任务主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteWcsTaskByTaskId(String taskId)
|
||||
{
|
||||
return wcsTaskMapper.deleteWcsTaskByTaskId(taskId);
|
||||
}
|
||||
}
|
||||
@@ -1,104 +0,0 @@
|
||||
package com.ruoyi.schedule.taskHistory.controller;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.schedule.taskHistory.domain.WcsTaskHistory;
|
||||
import com.ruoyi.schedule.taskHistory.service.IWcsTaskHistoryService;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 任务历史记录Controller
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-06-27
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/schedule/history")
|
||||
public class WcsTaskHistoryController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private IWcsTaskHistoryService wcsTaskHistoryService;
|
||||
|
||||
/**
|
||||
* 查询任务历史记录列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('schedule:history:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(WcsTaskHistory wcsTaskHistory)
|
||||
{
|
||||
startPage();
|
||||
List<WcsTaskHistory> list = wcsTaskHistoryService.selectWcsTaskHistoryList(wcsTaskHistory);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出任务历史记录列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('schedule:history:export')")
|
||||
@Log(title = "任务历史记录", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, WcsTaskHistory wcsTaskHistory)
|
||||
{
|
||||
List<WcsTaskHistory> list = wcsTaskHistoryService.selectWcsTaskHistoryList(wcsTaskHistory);
|
||||
ExcelUtil<WcsTaskHistory> util = new ExcelUtil<WcsTaskHistory>(WcsTaskHistory.class);
|
||||
util.exportExcel(response, list, "任务历史记录数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取任务历史记录详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('schedule:history:query')")
|
||||
@GetMapping(value = "/{taskId}")
|
||||
public AjaxResult getInfo(@PathVariable("taskId") String taskId)
|
||||
{
|
||||
return success(wcsTaskHistoryService.selectWcsTaskHistoryByTaskId(taskId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增任务历史记录
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('schedule:history:add')")
|
||||
@Log(title = "任务历史记录", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody WcsTaskHistory wcsTaskHistory)
|
||||
{
|
||||
return toAjax(wcsTaskHistoryService.insertWcsTaskHistory(wcsTaskHistory));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改任务历史记录
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('schedule:history:edit')")
|
||||
@Log(title = "任务历史记录", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody WcsTaskHistory wcsTaskHistory)
|
||||
{
|
||||
return toAjax(wcsTaskHistoryService.updateWcsTaskHistory(wcsTaskHistory));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除任务历史记录
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('schedule:history:remove')")
|
||||
@Log(title = "任务历史记录", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{taskIds}")
|
||||
public AjaxResult remove(@PathVariable String[] taskIds)
|
||||
{
|
||||
return toAjax(wcsTaskHistoryService.deleteWcsTaskHistoryByTaskIds(taskIds));
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
package com.ruoyi.schedule.taskHistory.domain;
|
||||
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 任务历史记录对象 wcs_task_history
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-06-27
|
||||
*/
|
||||
@Data
|
||||
public class WcsTaskHistory extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 作业号 */
|
||||
@Excel(name = "作业号")
|
||||
private String jobId;
|
||||
|
||||
/** wcs任务号 */
|
||||
@Excel(name = "wcs任务号")
|
||||
private String taskId;
|
||||
|
||||
/** 任务类型 */
|
||||
@Excel(name = "任务类型")
|
||||
private String taskType;
|
||||
|
||||
/** 源站点 */
|
||||
@Excel(name = "源站点")
|
||||
private String sourceLocation;
|
||||
|
||||
/** 目标站点 */
|
||||
@Excel(name = "目标站点")
|
||||
private String targetLocation;
|
||||
|
||||
/** 任务状态 */
|
||||
@Excel(name = "任务状态")
|
||||
private String taskStatus;
|
||||
|
||||
/** 调度时间 */
|
||||
@Excel(name = "调度时间")
|
||||
private LocalDateTime scheduleTime;
|
||||
|
||||
/** 结束时间 */
|
||||
@Excel(name = "结束时间")
|
||||
private LocalDateTime finishTime;
|
||||
|
||||
/** 设备编号 */
|
||||
@Excel(name = "设备编号")
|
||||
private String deviceId;
|
||||
|
||||
/** 库区代码 */
|
||||
@Excel(name = "库区代码")
|
||||
private String areaId;
|
||||
|
||||
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
package com.ruoyi.schedule.taskHistory.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.schedule.taskHistory.domain.WcsTaskHistory;
|
||||
|
||||
/**
|
||||
* 任务历史记录Mapper接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-06-27
|
||||
*/
|
||||
public interface WcsTaskHistoryMapper
|
||||
{
|
||||
/**
|
||||
* 查询任务历史记录
|
||||
*
|
||||
* @param taskId 任务历史记录主键
|
||||
* @return 任务历史记录
|
||||
*/
|
||||
public WcsTaskHistory selectWcsTaskHistoryByTaskId(String taskId);
|
||||
|
||||
/**
|
||||
* 查询任务历史记录列表
|
||||
*
|
||||
* @param wcsTaskHistory 任务历史记录
|
||||
* @return 任务历史记录集合
|
||||
*/
|
||||
public List<WcsTaskHistory> selectWcsTaskHistoryList(WcsTaskHistory wcsTaskHistory);
|
||||
|
||||
/**
|
||||
* 新增任务历史记录
|
||||
*
|
||||
* @param wcsTaskHistory 任务历史记录
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertWcsTaskHistory(WcsTaskHistory wcsTaskHistory);
|
||||
|
||||
/**
|
||||
* 修改任务历史记录
|
||||
*
|
||||
* @param wcsTaskHistory 任务历史记录
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateWcsTaskHistory(WcsTaskHistory wcsTaskHistory);
|
||||
|
||||
/**
|
||||
* 删除任务历史记录
|
||||
*
|
||||
* @param taskId 任务历史记录主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteWcsTaskHistoryByTaskId(String taskId);
|
||||
|
||||
/**
|
||||
* 批量删除任务历史记录
|
||||
*
|
||||
* @param taskIds 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteWcsTaskHistoryByTaskIds(String[] taskIds);
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
package com.ruoyi.schedule.taskHistory.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.schedule.taskHistory.domain.WcsTaskHistory;
|
||||
|
||||
/**
|
||||
* 任务历史记录Service接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-06-27
|
||||
*/
|
||||
public interface IWcsTaskHistoryService
|
||||
{
|
||||
/**
|
||||
* 查询任务历史记录
|
||||
*
|
||||
* @param taskId 任务历史记录主键
|
||||
* @return 任务历史记录
|
||||
*/
|
||||
public WcsTaskHistory selectWcsTaskHistoryByTaskId(String taskId);
|
||||
|
||||
/**
|
||||
* 查询任务历史记录列表
|
||||
*
|
||||
* @param wcsTaskHistory 任务历史记录
|
||||
* @return 任务历史记录集合
|
||||
*/
|
||||
public List<WcsTaskHistory> selectWcsTaskHistoryList(WcsTaskHistory wcsTaskHistory);
|
||||
|
||||
/**
|
||||
* 新增任务历史记录
|
||||
*
|
||||
* @param wcsTaskHistory 任务历史记录
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertWcsTaskHistory(WcsTaskHistory wcsTaskHistory);
|
||||
|
||||
/**
|
||||
* 修改任务历史记录
|
||||
*
|
||||
* @param wcsTaskHistory 任务历史记录
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateWcsTaskHistory(WcsTaskHistory wcsTaskHistory);
|
||||
|
||||
/**
|
||||
* 批量删除任务历史记录
|
||||
*
|
||||
* @param taskIds 需要删除的任务历史记录主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteWcsTaskHistoryByTaskIds(String[] taskIds);
|
||||
|
||||
/**
|
||||
* 删除任务历史记录信息
|
||||
*
|
||||
* @param taskId 任务历史记录主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteWcsTaskHistoryByTaskId(String taskId);
|
||||
}
|
||||
@@ -1,95 +0,0 @@
|
||||
package com.ruoyi.schedule.taskHistory.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.schedule.taskHistory.mapper.WcsTaskHistoryMapper;
|
||||
import com.ruoyi.schedule.taskHistory.domain.WcsTaskHistory;
|
||||
import com.ruoyi.schedule.taskHistory.service.IWcsTaskHistoryService;
|
||||
|
||||
/**
|
||||
* 任务历史记录Service业务层处理
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-06-27
|
||||
*/
|
||||
@Service
|
||||
public class WcsTaskHistoryServiceImpl implements IWcsTaskHistoryService
|
||||
{
|
||||
@Autowired
|
||||
private WcsTaskHistoryMapper wcsTaskHistoryMapper;
|
||||
|
||||
/**
|
||||
* 查询任务历史记录
|
||||
*
|
||||
* @param taskId 任务历史记录主键
|
||||
* @return 任务历史记录
|
||||
*/
|
||||
@Override
|
||||
public WcsTaskHistory selectWcsTaskHistoryByTaskId(String taskId)
|
||||
{
|
||||
return wcsTaskHistoryMapper.selectWcsTaskHistoryByTaskId(taskId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询任务历史记录列表
|
||||
*
|
||||
* @param wcsTaskHistory 任务历史记录
|
||||
* @return 任务历史记录
|
||||
*/
|
||||
@Override
|
||||
public List<WcsTaskHistory> selectWcsTaskHistoryList(WcsTaskHistory wcsTaskHistory)
|
||||
{
|
||||
return wcsTaskHistoryMapper.selectWcsTaskHistoryList(wcsTaskHistory);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增任务历史记录
|
||||
*
|
||||
* @param wcsTaskHistory 任务历史记录
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertWcsTaskHistory(WcsTaskHistory wcsTaskHistory)
|
||||
{
|
||||
wcsTaskHistory.setCreateTime(DateUtils.getNowDate());
|
||||
return wcsTaskHistoryMapper.insertWcsTaskHistory(wcsTaskHistory);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改任务历史记录
|
||||
*
|
||||
* @param wcsTaskHistory 任务历史记录
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateWcsTaskHistory(WcsTaskHistory wcsTaskHistory)
|
||||
{
|
||||
return wcsTaskHistoryMapper.updateWcsTaskHistory(wcsTaskHistory);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除任务历史记录
|
||||
*
|
||||
* @param taskIds 需要删除的任务历史记录主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteWcsTaskHistoryByTaskIds(String[] taskIds)
|
||||
{
|
||||
return wcsTaskHistoryMapper.deleteWcsTaskHistoryByTaskIds(taskIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除任务历史记录信息
|
||||
*
|
||||
* @param taskId 任务历史记录主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteWcsTaskHistoryByTaskId(String taskId)
|
||||
{
|
||||
return wcsTaskHistoryMapper.deleteWcsTaskHistoryByTaskId(taskId);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user