wcs调度修改
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
package com.ruoyi.schedule;
|
||||
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
import com.ruoyi.device.ssj.service.IDeviceSsjService;
|
||||
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 com.ruoyi.schedule.plcRead.ssj.domain.Ssj;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
@@ -14,6 +17,8 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
public class ScheduleThread {
|
||||
|
||||
public CustomThread customThread;
|
||||
@Autowired
|
||||
private IDeviceSsjService deviceSsjService;
|
||||
|
||||
/**
|
||||
* 项目初始化启动
|
||||
@@ -23,10 +28,12 @@ public class ScheduleThread {
|
||||
String ip = "192.168.0.1";
|
||||
int port = 80;
|
||||
PlcConnectInfo ssjPlcConnectInfo = new PlcConnectInfo(ip, port);
|
||||
ConcurrentHashMap<String, SsjDevice>list = new ConcurrentHashMap<>();
|
||||
ConcurrentHashMap<String, DeviceSsj>list = new ConcurrentHashMap<>();
|
||||
//获取要去取的输送机
|
||||
|
||||
|
||||
List<DeviceSsj> deviceSsjs = deviceSsjService.selectDeviceSsjList(new DeviceSsj());
|
||||
for (DeviceSsj deviceSsj : deviceSsjs) {
|
||||
list.put(deviceSsj.getDeviceCode(),deviceSsj);
|
||||
}
|
||||
|
||||
PlcRead plcRead = new PlcRead(list,ssjPlcConnectInfo);
|
||||
Thread plcReadThread = new Thread(plcRead);
|
||||
|
||||
@@ -6,9 +6,9 @@ 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.device.ssj.domain.DeviceSsj;
|
||||
import com.ruoyi.schedule.plcRead.ssj.domain.PlcConnectInfo;
|
||||
import com.ruoyi.schedule.plcRead.ssj.domain.SsjDevice;
|
||||
import com.ruoyi.schedule.plcRead.ssj.domain.Ssj;
|
||||
import com.ruoyi.schedule.plcRead.util.ParseUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@@ -18,7 +18,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
@Slf4j
|
||||
public class PlcRead implements Runnable {
|
||||
|
||||
public static ConcurrentHashMap<String, SsjDevice> deviceMap;
|
||||
public static ConcurrentHashMap<String, DeviceSsj> deviceMap;
|
||||
private volatile boolean running = true;
|
||||
|
||||
public SiemensS7Net siemensS7Net = null;
|
||||
@@ -27,7 +27,7 @@ public class PlcRead implements Runnable {
|
||||
private int port;
|
||||
private boolean success = false;
|
||||
|
||||
public PlcRead(ConcurrentHashMap<String, SsjDevice> deviceMap, PlcConnectInfo plcConnectInfo) {
|
||||
public PlcRead(ConcurrentHashMap<String, DeviceSsj> deviceMap, PlcConnectInfo plcConnectInfo) {
|
||||
this.deviceMap = deviceMap;
|
||||
this.ip = plcConnectInfo.getIp();
|
||||
this.port = plcConnectInfo.getPort();
|
||||
@@ -40,11 +40,11 @@ public class PlcRead implements Runnable {
|
||||
if (IsConnect()) {
|
||||
|
||||
for (String ssjCode : deviceMap.keySet()) {
|
||||
SsjDevice ssjDevice = deviceMap.get(ssjCode);
|
||||
DeviceSsj ssjDevice = deviceMap.get(ssjCode);
|
||||
String readAddress = "";
|
||||
String writeAddress = "";
|
||||
|
||||
switch (ssjDevice.getDeviceCode()){
|
||||
switch (ssjDevice.getDeviceCode()) {
|
||||
case "G5011":
|
||||
// 处理 G5011
|
||||
readAddress = "";
|
||||
@@ -404,6 +404,9 @@ public class PlcRead implements Runnable {
|
||||
continue;
|
||||
}
|
||||
|
||||
ssjDevice.setPlcDbReadAddress(readAddress);
|
||||
ssjDevice.setPlcDbWriteAddress(writeAddress);
|
||||
|
||||
switch (ssjDevice.getType()) {
|
||||
case "1":
|
||||
readPlcOutSsj(ssjDevice);
|
||||
@@ -439,18 +442,16 @@ public class PlcRead implements Runnable {
|
||||
*
|
||||
* @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"));
|
||||
private void readPlcOtherSsj(DeviceSsj ssjDevice) {
|
||||
OperateResultExOne<byte[]> read2 = readWriteNet.Read(ssjDevice.getPlcDbReadAddress(), 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));
|
||||
ssjDevice.setKx(ParseUtil.optInt(0, ddsx1));
|
||||
ssjDevice.setDw(ParseUtil.optInt(1, ddsx1));
|
||||
ssjDevice.setRkqq(ParseUtil.optInt(2, ddsx1));
|
||||
ssjDevice.setTrayCode(ParseUtil.optString(3, ddsx1));
|
||||
ssjDevice.setTaskNo(ParseUtil.optDInt(4, ddsx1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -459,18 +460,16 @@ public class PlcRead implements Runnable {
|
||||
*
|
||||
* @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"));
|
||||
private void readPlcInSsj(DeviceSsj ssjDevice) {
|
||||
OperateResultExOne<byte[]> read2 = readWriteNet.Read(ssjDevice.getPlcDbReadAddress(), 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));
|
||||
ssjDevice.setKx(ParseUtil.optInt(0, ddsx1));
|
||||
ssjDevice.setDw(ParseUtil.optInt(1, ddsx1));
|
||||
ssjDevice.setRkqq(ParseUtil.optInt(2, ddsx1));
|
||||
ssjDevice.setTrayCode(ParseUtil.optString(3, ddsx1));
|
||||
ssjDevice.setTaskNo(ParseUtil.optDInt(4, ddsx1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -479,37 +478,34 @@ public class PlcRead implements Runnable {
|
||||
*
|
||||
* @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"));
|
||||
private void readPlcPickSsj(DeviceSsj ssjDevice) {
|
||||
OperateResultExOne<byte[]> read2 = readWriteNet.Read(ssjDevice.getPlcDbReadAddress(), 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));
|
||||
ssjDevice.setKx(ParseUtil.optInt(0, ddsx1));
|
||||
ssjDevice.setDw(ParseUtil.optInt(1, ddsx1));
|
||||
ssjDevice.setRkqq(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"));
|
||||
private void readPlcOutSsj(DeviceSsj ssjDevice) {
|
||||
OperateResultExOne<byte[]> read2 = readWriteNet.Read(ssjDevice.getPlcDbReadAddress(), 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));
|
||||
ssjDevice.setKx(ParseUtil.optInt(0, ddsx1));
|
||||
ssjDevice.setDw(ParseUtil.optInt(1, ddsx1));
|
||||
ssjDevice.setRkqq(ParseUtil.optInt(2, ddsx1));
|
||||
ssjDevice.setTrayCode(ParseUtil.optString(3, ddsx1));
|
||||
ssjDevice.setTaskNo(ParseUtil.optDInt(4, ddsx1));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import lombok.NoArgsConstructor;
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class SsjDevice {
|
||||
public class Ssj {
|
||||
private String deviceCode;
|
||||
|
||||
private String plcReadAddress;
|
||||
@@ -10,7 +10,9 @@ 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 com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcRead;
|
||||
import com.ruoyi.schedule.plcRead.ssj.domain.Ssj;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -23,7 +25,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
@Component
|
||||
public class InSsjThread {
|
||||
|
||||
public ConcurrentHashMap<String, SsjDevice> deviceMap;
|
||||
public ConcurrentHashMap<String, DeviceSsj> deviceMap;
|
||||
|
||||
@Resource
|
||||
private IApiService apiService;
|
||||
@@ -31,9 +33,20 @@ public class InSsjThread {
|
||||
private IAgvQueueService agvQueueService;
|
||||
|
||||
|
||||
public void inDispatch(SsjDevice inSsjDevice) {
|
||||
public void run(){
|
||||
for (String ssjCode : PlcRead.deviceMap.keySet()) {
|
||||
DeviceSsj deviceSsj = PlcRead.deviceMap.get(ssjCode);
|
||||
if ("3".equals(deviceSsj.getType())){
|
||||
inDispatch(deviceSsj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void inDispatch(DeviceSsj inSsjDevice) {
|
||||
//如果入库请求1 并且 托盘码不为空
|
||||
if (inSsjDevice.getEntryRequest() == 1 && StrUtil.isNotEmpty(inSsjDevice.getTrayCode())) {
|
||||
if (inSsjDevice.getRkqq() == 1 && StrUtil.isNotEmpty(inSsjDevice.getTrayCode())) {
|
||||
//根据入口,查询对应的入库作业
|
||||
MydoJob mydoJobParam = new MydoJob();
|
||||
//mydoJobParam.setEntranceId(inSsjDevice.getDeviceCode());
|
||||
@@ -103,7 +116,7 @@ public class InSsjThread {
|
||||
* @param mydoJob
|
||||
* @return
|
||||
*/
|
||||
private AgvQueue createAgvQueue(SsjDevice ssjDevice, MydoJob mydoJob) {
|
||||
private AgvQueue createAgvQueue(DeviceSsj ssjDevice, MydoJob mydoJob) {
|
||||
//生成ctu执行队列
|
||||
AgvQueue agvQueue = new AgvQueue();
|
||||
String reqCode = IdUtil.fastSimpleUUID();
|
||||
|
||||
@@ -7,7 +7,9 @@ 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 com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcRead;
|
||||
import com.ruoyi.schedule.plcRead.ssj.domain.Ssj;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -20,17 +22,25 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
@Component
|
||||
public class OutSsjThread {
|
||||
|
||||
public ConcurrentHashMap<String, List<SsjDevice>> deviceMap;
|
||||
public ConcurrentHashMap<String, DeviceSsj> deviceMap;
|
||||
|
||||
@Resource
|
||||
private IApiService apiService;
|
||||
@Resource
|
||||
private IAgvQueueService agvQueueService;
|
||||
|
||||
public void run() {
|
||||
for (String ssjCode : PlcRead.deviceMap.keySet()) {
|
||||
DeviceSsj deviceSsj = PlcRead.deviceMap.get(ssjCode);
|
||||
if ("1".equals(deviceSsj.getType())){
|
||||
outDispatch(deviceSsj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void outDispatch(SsjDevice outSsjDevice) {
|
||||
public void outDispatch(DeviceSsj outSsjDevice) {
|
||||
//输送线出库
|
||||
if (outSsjDevice.getEmpty()==1){
|
||||
if (outSsjDevice.getKx()==1){
|
||||
//查询对应的作业
|
||||
AgvQueue agvQueue = new AgvQueue();
|
||||
agvQueue.setPositionCode2(outSsjDevice.getDeviceCode());
|
||||
|
||||
@@ -5,7 +5,9 @@ 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 com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcRead;
|
||||
import com.ruoyi.schedule.plcRead.ssj.domain.Ssj;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -18,16 +20,24 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
@Component
|
||||
public class PickSsjTread {
|
||||
|
||||
public ConcurrentHashMap<String, List<SsjDevice>> deviceMap;
|
||||
public ConcurrentHashMap<String, DeviceSsj> deviceMap;
|
||||
|
||||
@Resource
|
||||
private IApiService apiService;
|
||||
@Resource
|
||||
private IAgvQueueService agvQueueService;
|
||||
|
||||
public void run(){
|
||||
for (String ssjCode : PlcRead.deviceMap.keySet()) {
|
||||
DeviceSsj deviceSsj = PlcRead.deviceMap.get(ssjCode);
|
||||
if ("2".equals(deviceSsj.getType())){
|
||||
pickDispatch(deviceSsj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void pickDispatch(SsjDevice pickSsjDevice) {
|
||||
if (pickSsjDevice.getInPlace() == 1 && pickSsjDevice.getTaskNo() > 0){
|
||||
public void pickDispatch(DeviceSsj pickSsjDevice) {
|
||||
if (pickSsjDevice.getDw() == 1 && pickSsjDevice.getTaskNo() > 0){
|
||||
Integer taskNo = pickSsjDevice.getTaskNo();
|
||||
MydoJob mydoJobParam = new MydoJob();
|
||||
mydoJobParam.setStatus("3");
|
||||
|
||||
Reference in New Issue
Block a user