wcs项目初始化

This commit is contained in:
liuhanqing
2025-09-17 14:11:04 +08:00
commit 1b44d350b0
726 changed files with 108835 additions and 0 deletions

View File

@@ -0,0 +1,161 @@
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.scheduleTask.ssj.bs.BsInSsjThread;
import com.ruoyi.schedule.scheduleTask.ssj.bs.BsOutSsjThread;
import com.ruoyi.schedule.scheduleTask.ssj.bs.BsPickSsjTread;
import com.ruoyi.schedule.scheduleTask.ssj.js.JsInSsjThread;
import com.ruoyi.schedule.scheduleTask.ssj.js.JsOutSsjThread;
import com.ruoyi.schedule.scheduleTask.ssj.js.JsPickSsjTread;
import com.ruoyi.schedule.scheduleTask.ssj.monitor.SsjMonitorThread;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
@Component
@Slf4j
public class ScheduleThread {
public CustomThread<PlcRead> customThread;
@Autowired
private IDeviceSsjService deviceSsjService;
public CustomThread<BsInSsjThread> bsInSsjThread;
public CustomThread<JsInSsjThread> jsInSsjThread;
public CustomThread<BsOutSsjThread> bsOutSsjThread;
public CustomThread<JsOutSsjThread> jsOutSsjThread;
public CustomThread<BsPickSsjTread> bsPickSsjThread;
public CustomThread<JsPickSsjTread> jsPickSsjThread;
public CustomThread<SsjMonitorThread> ssjMonitorThread;
private boolean isRun = false;
private boolean isRun2 = false;
/**
* 项目初始化启动
*/
@PostConstruct
public void init() {
log.info("初始化调度服务");
//读取信息初始化
plcReadInit();
//调度初始化
scheduleInit();
log.info("调度服务执行成功");
}
/**
* 调度初始化
*/
private void scheduleInit() {
BsInSsjThread bsInSsjThread1 = new BsInSsjThread();
bsInSsjThread = new CustomThread<BsInSsjThread>(new Thread(bsInSsjThread1), bsInSsjThread1);
JsInSsjThread jsInSsjThread1 = new JsInSsjThread();
jsInSsjThread = new CustomThread<JsInSsjThread>(new Thread(jsInSsjThread1), jsInSsjThread1);
BsOutSsjThread bsOutSsjThread1 = new BsOutSsjThread();
bsOutSsjThread = new CustomThread<BsOutSsjThread>(new Thread(bsOutSsjThread1), bsOutSsjThread1);
JsOutSsjThread jsOutSsjThread1 = new JsOutSsjThread();
jsOutSsjThread = new CustomThread<JsOutSsjThread>(new Thread(jsOutSsjThread1), jsOutSsjThread1);
BsPickSsjTread bsPickSsjTread1 = new BsPickSsjTread();
bsPickSsjThread = new CustomThread<BsPickSsjTread>(new Thread(bsPickSsjTread1), bsPickSsjTread1);
JsPickSsjTread jsPickSsjTread1 = new JsPickSsjTread();
jsPickSsjThread = new CustomThread<JsPickSsjTread>(new Thread(jsPickSsjTread1), jsPickSsjTread1);
SsjMonitorThread ssjMonitorThread1 = new SsjMonitorThread();
ssjMonitorThread = new CustomThread<SsjMonitorThread>(new Thread(ssjMonitorThread1), ssjMonitorThread1);
}
/**
* plc读取初始化
*/
private void plcReadInit() {
String ip = "127.0.0.1";
int port = 102;
PlcConnectInfo ssjPlcConnectInfo = new PlcConnectInfo(ip, port);
ConcurrentHashMap<String, DeviceSsj> list = new ConcurrentHashMap<>();
//获取要去取的输送机
List<DeviceSsj> deviceSsjs = deviceSsjService.selectDeviceSsjList(new DeviceSsj());
for (DeviceSsj deviceSsj : deviceSsjs) {
list.put(deviceSsj.getDeviceCode(), deviceSsj);
}
//plc读取线程
PlcRead plcRead = new PlcRead(list, ssjPlcConnectInfo);
Thread plcReadThread = new Thread(plcRead);
customThread = new CustomThread<PlcRead>(plcReadThread, plcRead);
}
/**
* 开始线程
*/
public void startAllThread() {
customThread.getThread().start();
isRun = true;
}
/**
* 开启线程2
*/
public void startAllThread2() {
//臂式入库线程调度
bsInSsjThread.getThread().start();
//臂式出库线程调度
bsOutSsjThread.getThread().start();
//臂式出库到位线程调度-wms电子屏交互
bsPickSsjThread.getThread().start();
//剪式入库线程调度
jsInSsjThread.getThread().start();
//剪式出库线程调度
//jsOutSsjThread.getThread().start();
//剪上出库到位线程调度-wms电子屏交互
//jsPickSsjThread.getThread().start();
//监控输送机
//ssjMonitorThread.getThread().start();
isRun2 = true;
}
/**
* 停止线程
*/
public void stopAllThread() {
customThread.runnable.isRun = false;
plcReadInit();
isRun = false;
}
/**
* 停止线程2
*/
public void stopAllThread2() {
bsInSsjThread.runnable.isRun = false;
jsInSsjThread.runnable.isRun = false;
bsOutSsjThread.runnable.isRun = false;
jsOutSsjThread.runnable.isRun = false;
bsPickSsjThread.runnable.isRun = false;
jsPickSsjThread.runnable.isRun = false;
scheduleInit();
isRun2 = false;
}
/**
* 获取调度状态
*/
public HashMap<String,Boolean> getScheduleStatus() {
HashMap<String,Boolean> map = new HashMap<>();
map.put("isRun",isRun);
map.put("isRun2",isRun2);
return map;
}
}

View File

@@ -0,0 +1,202 @@
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 com.ruoyi.device.ssj.domain.DeviceSsj;
import com.ruoyi.schedule.plcRead.ssj.domain.HslRead;
import com.ruoyi.schedule.plcRead.ssj.domain.PlcConnectInfo;
import com.ruoyi.schedule.plcRead.util.ParseUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.formula.functions.Offset;
import java.util.concurrent.ConcurrentHashMap;
@Slf4j
public class PlcRead implements Runnable {
public static ConcurrentHashMap<String, DeviceSsj> deviceMap;
public volatile boolean isRun = true;
public SiemensS7Net siemensS7Net = null;
public static IReadWriteNet readWriteNet = null;
private String ip;
private int port;
private boolean success = false;
public PlcRead(ConcurrentHashMap<String, DeviceSsj> deviceMap, PlcConnectInfo plcConnectInfo) {
this.deviceMap = deviceMap;
this.ip = plcConnectInfo.getIp();
this.port = plcConnectInfo.getPort();
}
public static int WriteToSSJ(String address, byte[] data) {
int a = 0;
if (readWriteNet != null) {
a = HslRead.WriteResultRender(readWriteNet.Write(address, data), address);
}
return a;
}
@Override
public void run() {
while (isRun) {
try {
if (IsConnect()) {
int step = 20;
int baseOffset = 0;
for (String ssjCode : deviceMap.keySet()) {
DeviceSsj ssjDevice = deviceMap.get(ssjCode);
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(); // 重新设置中断标志
return;
} catch (Exception e) {
log.info("********IP:" + this.ip + " port:" + this.port + "读取数据异常 " + e.getMessage());
}
}
}
/**
* 其他输送机
*
* @param ssjDevice
*/
private void readPlcOtherSsj(DeviceSsj ssjDevice) {
OperateResultExOne<byte[]> read2 = readWriteNet.Read(ssjDevice.getPlcDbReadAddress(), Short.parseShort("20"));
String ddsx1 = "0";
if (read2.IsSuccess) {
ddsx1 = SoftBasic.ByteToHexString(read2.Content);
ssjDevice.setKx(ParseUtil.optInt(0, ddsx1));
ssjDevice.setDw(ParseUtil.optInt(2, ddsx1));
ssjDevice.setRkqq(ParseUtil.optInt(4, ddsx1));
ssjDevice.setTaskNo(ParseUtil.optDInt(6, ddsx1));
ssjDevice.setTrayCode(ParseUtil.optString(10, ddsx1));
}
}
/**
* 入库输送机
*
* @param ssjDevice
*/
private void readPlcInSsj(DeviceSsj ssjDevice) {
OperateResultExOne<byte[]> read2 = readWriteNet.Read(ssjDevice.getPlcDbReadAddress(), Short.parseShort("20"));
String ddsx1 = "0";
if (read2.IsSuccess) {
ddsx1 = SoftBasic.ByteToHexString(read2.Content);
ssjDevice.setKx(ParseUtil.optInt(0, ddsx1));
ssjDevice.setDw(ParseUtil.optInt(2, ddsx1));
ssjDevice.setRkqq(ParseUtil.optInt(4, ddsx1));
ssjDevice.setTaskNo(ParseUtil.optDInt(6, ddsx1));
ssjDevice.setTrayCode(ParseUtil.optString(12, ddsx1));
}
}
/**
* 拣选口输送机
*
* @param ssjDevice
*/
private void readPlcPickSsj(DeviceSsj ssjDevice) {
OperateResultExOne<byte[]> read2 = readWriteNet.Read(ssjDevice.getPlcDbReadAddress(), Short.parseShort("20"));
String ddsx1 = "0";
if (read2.IsSuccess) {
ddsx1 = SoftBasic.ByteToHexString(read2.Content);
ssjDevice.setKx(ParseUtil.optInt(0, ddsx1));
ssjDevice.setDw(ParseUtil.optInt(2, ddsx1));
ssjDevice.setRkqq(ParseUtil.optInt(4, ddsx1));
ssjDevice.setTaskNo(ParseUtil.optDInt(6, ddsx1));
ssjDevice.setTrayCode(ParseUtil.optString(10, ddsx1));
}
}
/**
* 出库输送机
*
* @param ssjDevice
*/
private void readPlcOutSsj(DeviceSsj ssjDevice) {
OperateResultExOne<byte[]> read2 = readWriteNet.Read(ssjDevice.getPlcDbReadAddress(), Short.parseShort("20"));
String ddsx1 = "0";
if (read2.IsSuccess) {
ddsx1 = SoftBasic.ByteToHexString(read2.Content);
ssjDevice.setKx(ParseUtil.optInt(0, ddsx1));
ssjDevice.setDw(ParseUtil.optInt(2, ddsx1));
ssjDevice.setRkqq(ParseUtil.optInt(4, ddsx1));
ssjDevice.setTaskNo(ParseUtil.optDInt(6, ddsx1));
ssjDevice.setTrayCode(ParseUtil.optString(10, ddsx1));
}
}
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) {
readWriteNet.ConnectClose();
}
setIsConnect(false);
}
}

View File

@@ -0,0 +1,13 @@
package com.ruoyi.schedule.plcRead.ssj.domain;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CustomThread<T> {
public Thread thread;
public T runnable;
}

View File

@@ -0,0 +1,105 @@
package com.ruoyi.schedule.plcRead.ssj.domain;
import HslCommunication.BasicFramework.SoftBasic;
import HslCommunication.Core.Net.IReadWriteNet;
import HslCommunication.Core.Types.OperateResult;
import HslCommunication.Core.Types.OperateResultExOne;
import javax.swing.*;
import java.awt.*;
import java.text.SimpleDateFormat;
import java.util.Date;
public class HslRead {
private static SimpleDateFormat dateFormat = new SimpleDateFormat("[HH:mm:ss] ");
/**
* 将结果信息显示出来,在界面里进行显示
* @param result 等待显示的结果信息
* @param x
* @param address 读取的地址数据
* @param textBox 显示结果的文本框
* @param scrollPane 支持滚动条的控件
* @param <T> 类型对象
* @return
* @return
* @return
* @return
* @return
*/
public static <T> T ReadResultRender(OperateResultExOne<T> result ) {
T x = null ;
if (result.IsSuccess) {
if (result.Content.getClass().isArray()) {
} else {
x= (T) result.Content;
}
} else {
JOptionPane.showMessageDialog(
null,
dateFormat.format(new Date()) + "] Read Failed\r\nReason:" + result.ToMessageShowString(),
"Result",
JOptionPane.WARNING_MESSAGE);
}
return x;
}
public static int WriteResultRender(OperateResult result, String address ) { //void
int x=0;
if (result.IsSuccess) {
// JOptionPane.showMessageDialog(
// null,
// dateFormat.format(new Date()) + "[" + address + "] Write Success",
// "Result",
// JOptionPane.PLAIN_MESSAGE);
x=1;
} else {
// JOptionPane.showMessageDialog(
// null,
// dateFormat.format(new Date()) + "[" + address + "] Write Failed\r\nReason:" + result.ToMessageShowString(),
// "Result",
// JOptionPane.WARNING_MESSAGE);
x=2;
}
return x;
}
public static void BulkReadRenderResult(IReadWriteNet readWrite, JTextField addTextBox, JTextField lengthTextBox, JTextArea resultTextBox ) {
try {
OperateResultExOne<byte[]> read = readWrite.Read(addTextBox.getText(), Short.parseShort(lengthTextBox.getText()));
if (read.IsSuccess) {
resultTextBox.setText("Result:" + SoftBasic.ByteToHexString(read.Content));
} else {
JOptionPane.showMessageDialog(null, "Read Failed:" + read.ToMessageShowString(), "Result", JOptionPane.WARNING_MESSAGE);
}
} catch (Exception ex) {
JOptionPane.showMessageDialog(null, "Read Failed:" + ex.getMessage(), "Result", JOptionPane.ERROR_MESSAGE);
}
}
public static void SetPanelEnabled(JPanel panel, boolean enable) {
Component[] components = panel.getComponents();
//System.out.println("Component Length:" + components.length);
for (Component component : components) {
if (component instanceof JPanel) {
SetPanelEnabled((JPanel) component, enable);
} else {
component.setEnabled(enable);
}
}
}
public static String IpAddressInputWrong = "IpAddress input wrong";
public static String PortInputWrong = "Port input wrong";
public static String SlotInputWrong = "Slot input wrong";
public static String BaudRateInputWrong = "Baud rate input wrong";
public static String DataBitsInputWrong = "Data bit input wrong";
public static String StopBitInputWrong = "Stop bit input wrong";
}

View File

@@ -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;
}

View File

@@ -0,0 +1,39 @@
package com.ruoyi.schedule.plcRead.ssj.domain;
/**
* 发送数据的实体类
* @num 长度
* @num2 值
*/
public class SendData {
private static final int DINT = 4;
private static final int INT = 2;
private int num;
private int num2;
public SendData(int num, int num2) {
this.num = num;
this.num2 = num2;
}
public SendData(int num, String num2) {
this.num = num;
this.num2 = Integer.parseInt(num2);
}
public int getNum() {
return num;
}
public void setNum(int num) {
this.num = num;
}
public int getNum2() {
return num2;
}
public void setNum2(int num2) {
this.num2 = num2;
}
}

View File

@@ -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 + 7) * 2));
return Tools.bytetostringtool(bytes);
}
}

View File

@@ -0,0 +1,400 @@
package com.ruoyi.schedule.plcRead.util;
import HslCommunication.BasicFramework.SoftBasic;
import com.ruoyi.schedule.plcRead.ssj.domain.SendData;
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++){
String x = Character.toString(showChar(aaa[i]));
char ddd=showChar(aaa[i]);
tptm=tptm+x;
}
if(tptm.isEmpty() || "\u0000\u0000\u0000\u0000\u0000\u0000\u0000".equals(tptm)){
return "";
}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;
}
/**
* 下发到PLC的反馈字节
*/
public static byte[] sendData(SendData... list) {
byte[][] values = new byte[list.length][0];
for (int i = 0; i < list.length; i++) {
byte[] bytes = Tools.intToBytes(list[i].getNum2(), list[i].getNum());
//System.out.println(bytes.length);
values[i] = bytes;
}
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;
}
}

View File

@@ -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);
}
}

View File

@@ -0,0 +1,200 @@
package com.ruoyi.schedule.scheduleTask.ssj.bs;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjUtil;
import cn.hutool.core.util.StrUtil;
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.common.utils.spring.SpringUtils;
import com.ruoyi.device.agv.domain.AgvQueue;
import com.ruoyi.device.agv.service.IAgvQueueService;
import com.ruoyi.device.ssj.domain.DeviceSsj;
import com.ruoyi.schedule.plcRead.ssj.PlcRead;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Slf4j
public class BsInSsjThread implements Runnable {
public HashMap<String, List<String>> ssjCodeList;
private IApiService apiService;
private IAgvQueueService agvQueueService;
public boolean isRun = true;
public void init() {
//todo 获取设备编码列表
ssjCodeList = new HashMap<>();
log.info("初始化臂式入库输送机");
//入库口
ArrayList<String> ssjCodes = new ArrayList<>();
ssjCodes.add("G1003");
ssjCodes.add("G1009");
ssjCodeList.put("ssjIn", ssjCodes);
//流利架
ArrayList<String> ssjCodes2 = new ArrayList<>();
ssjCodes2.add("fluent1-11");
ssjCodes2.add("fluent1-12");
ssjCodes2.add("fluent1-13");
ssjCodes2.add("fluent1-14");
ssjCodes2.add("fluent1-15");
ssjCodes2.add("fluent2-11");
ssjCodes2.add("fluent2-12");
ssjCodes2.add("fluent2-13");
ssjCodes2.add("fluent2-14");
ssjCodes2.add("fluent2-15");
ssjCodeList.put("fluentIn", ssjCodes2);
apiService = SpringUtils.getBean(IApiService.class);
agvQueueService = SpringUtils.getBean(IAgvQueueService.class);
log.info("初始化服务 {},{}", apiService, agvQueueService);
}
@Override
public void run() {
init();
while (isRun) {
for (String type : ssjCodeList.keySet()) {
switch (type) {
case "ssjIn":
//正常入库
for (String ssjCode : ssjCodeList.get(type)) {
try {
if (PlcRead.deviceMap.containsKey(ssjCode)) {
inDispatch(PlcRead.deviceMap.get(ssjCode));
} else {
log.error("设备不存在 ssjCode{}", ssjCode);
}
} catch (RuntimeException e) {
log.error(e.getMessage(), e);
}
}
break;
case "fluentIn":
//流利架 空料箱入库
for (String lljCode : ssjCodeList.get(type)) {
try {
inLljDispatch(lljCode);
} catch (RuntimeException e) {
log.error(e.getMessage(), e);
}
}
break;
}
}
try {
Thread.sleep(1500);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
}
/**
* 流利架空料箱入库
*
* @param lljCode
*/
private void inLljDispatch(String lljCode) {
//判断是否生成队列
AgvQueue agvQueueParam = new AgvQueue();
agvQueueParam.setPositionCode1(lljCode);
agvQueueParam.setStatus("0");
List<AgvQueue> agvQueues = agvQueueService.selectAgvQueueList(agvQueueParam);
if (CollUtil.isNotEmpty(agvQueues)) {
for (AgvQueue agvQueue : agvQueues) {
//请求任务生成
GenAgvSchedulingTaskResponse genAgvSchedulingTaskResponse = apiService.requestAgvQueue(agvQueue);
//修改wms任务状态
if (genAgvSchedulingTaskResponse.getCode() == 0) {
//修改ctu执行状态
agvQueue.setStatus("1");
agvQueueService.updateAgvQueue(agvQueue);
log.info("向CTU下入库库作业");
}
}
}
}
/**
* 输送线入库
*
* @param inSsjDevice
*/
public void inDispatch(DeviceSsj inSsjDevice) {
//如果入库请求1 并且 托盘码不为空
if (inSsjDevice.getDw()==1 && inSsjDevice.getRkqq() == 1 && StrUtil.isNotEmpty(inSsjDevice.getTrayCode())) {
//判断是否生成队列
AgvQueue agvQueueParam = new AgvQueue();
agvQueueParam.setWmsTraycode(inSsjDevice.getTrayCode());
//agvQueueParam.setStatus("0");
List<AgvQueue> agvQueues = agvQueueService.selectAgvQueueList(agvQueueParam);
if (CollUtil.isEmpty(agvQueues)) {
//根据入口,查询对应的入库作业
MydoJob mydoJobParam = new MydoJob();
mydoJobParam.setStatus("1");
mydoJobParam.setTrayCode(inSsjDevice.getTrayCode());
mydoJobParam.setEntranceId(inSsjDevice.getDeviceCode());
MydoJob mydoJob = apiService.requestEnterByTrayCode(mydoJobParam);
if (ObjUtil.isNotNull(mydoJob)) {
//生成agv队列
AgvQueue agvQueue = apiService.createAgvQueue(inSsjDevice.getName(), mydoJob.getCargoSpaceId(),mydoJob.getTrayCode(),mydoJob.getTaskNo(),"1");
//请求任务生成
GenAgvSchedulingTaskResponse genAgvSchedulingTaskResponse = apiService.requestAgvQueue( agvQueue);
//修改wms任务状态
if (genAgvSchedulingTaskResponse.getCode() == 0) {
//修改ctu执行状态
agvQueue.setStatus("1");
agvQueueService.updateAgvQueue(agvQueue);
log.info("向CTU下入库库作业");
}
}
}else {
AgvQueue agvQueue = agvQueues.get(0);
if ("0".equals(agvQueue.getStatus())){
//请求任务生成
GenAgvSchedulingTaskResponse genAgvSchedulingTaskResponse = apiService.requestAgvQueue(agvQueue);
//修改wms任务状态
if (genAgvSchedulingTaskResponse.getCode() == 0) {
//修改ctu执行状态
agvQueue.setStatus("1");
agvQueueService.updateAgvQueue(agvQueue);
log.info("向CTU下入库库作业");
}
}
}
}
}
}

View File

@@ -0,0 +1,148 @@
package com.ruoyi.schedule.scheduleTask.ssj.bs;
import cn.hutool.core.collection.CollUtil;
import com.ruoyi.bas.fluent.domain.BasFluentFrame;
import com.ruoyi.bas.fluent.service.IBasFluentFrameService;
import com.ruoyi.common.utils.spring.SpringUtils;
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.device.ssj.domain.DeviceSsj;
import com.ruoyi.schedule.plcRead.ssj.PlcRead;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@Slf4j
public class BsOutSsjThread implements Runnable {
public HashMap<String, List<String>> ssjCodeList;
private IApiService apiService;
private IAgvQueueService agvQueueService;
private IBasFluentFrameService basFluentFrameService;
public boolean isRun = true;
public void init() {
ssjCodeList = new HashMap<>();
ArrayList<String> ssjCodes = new ArrayList<>();
ssjCodes.add("G1004");
ssjCodes.add("G1010");
ssjCodeList.put("ssjOut", ssjCodes);
ArrayList<String> fluentOut = new ArrayList<>();
fluentOut.add("fluent1");
fluentOut.add("fluent2");
ssjCodeList.put("fluentOut", fluentOut);
apiService = SpringUtils.getBean(IApiService.class);
agvQueueService = SpringUtils.getBean(IAgvQueueService.class);
basFluentFrameService = SpringUtils.getBean(IBasFluentFrameService.class);
}
@Override
public void run() {
init();
while (isRun){
for (String type : ssjCodeList.keySet()) {
switch (type){
case "ssjOut":
//正常输送线出口
for (String ssjCode : ssjCodeList.get(type)) {
try {
if (PlcRead.deviceMap.containsKey(ssjCode)) {
ssjOutDispatch(PlcRead.deviceMap.get(ssjCode));
} else {
log.error("设备不存在 ssjCode{}", ssjCode);
}
}catch (Exception e){
log.error(e.getMessage(), e);
}
}
break;
case "fluentOut":
//流利架出口
for (String ssjCode : ssjCodeList.get(type)) {
try {
fluentOutDispatch(ssjCode);
}catch (Exception e){
log.error(e.getMessage(), e);
}
}
break;
}
}
try {
Thread.sleep(1500);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
}
/**
* 输送线出口
* @param outSsjDevice
*/
public void ssjOutDispatch(DeviceSsj outSsjDevice) {
//输送线出库
if (outSsjDevice.getKx()==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) {
apiService.requestAgvQueue(queue);
agvQueue.setStatus("1");
agvQueueService.updateAgvQueue(queue);
}
}
}
}
/**
* todo 流利架出口
* @param outSsjDevice
*/
public void fluentOutDispatch(String outSsjDevice) {
//查询对应的作业
AgvQueue agvQueue = new AgvQueue();
agvQueue.setPositionCode2(outSsjDevice);
agvQueue.setStatus("0");
List<AgvQueue> agvQueueList = agvQueueService.selectAgvQueueList(agvQueue);
for (AgvQueue queue : agvQueueList) {
//修改实际流利架货位
BasFluentFrame basFluentFrame = basFluentFrameService.selectBasFluentFrameOrderByAllotNum(queue.getPositionCode2());
if (basFluentFrame != null){
queue.setPositionCode2(basFluentFrame.getLocationName());
agvQueueService.updateAgvQueue(queue);
GenAgvSchedulingTaskResponse genAgvSchedulingTaskResponse = apiService.requestAgvQueue(queue);
if (genAgvSchedulingTaskResponse.getCode() == 0) {
//修改ctu执行状态
queue.setStatus("1");
agvQueueService.updateAgvQueue(queue);
log.info("向CTU下入库库作业");
//更新流利架
basFluentFrame.setTrayCode(queue.getWmsTraycode());
basFluentFrame.setAllotNum(1L);
basFluentFrameService.updateBasFluentFrame(basFluentFrame);
}
}
}
}
}

View File

@@ -0,0 +1,119 @@
package com.ruoyi.schedule.scheduleTask.ssj.bs;
import cn.hutool.core.collection.CollUtil;
import com.ruoyi.api.domain.RequestLog;
import com.ruoyi.api.service.IApiService;
import com.ruoyi.bas.port.domain.WcsPort;
import com.ruoyi.bas.port.service.IWcsPortService;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.device.agv.service.IAgvQueueService;
import com.ruoyi.device.ssj.domain.DeviceSsj;
import com.ruoyi.schedule.plcRead.ssj.PlcRead;
import lombok.extern.slf4j.Slf4j;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.ruoyi.common.Constant.JOB_FINISH_URL;
@Slf4j
public class BsPickSsjTread implements Runnable{
public HashMap<String, List<String>> ssjCodeList;
private IApiService apiService;
private IAgvQueueService agvQueueService;
private IWcsPortService wcsPortService;
public boolean isRun = true;
public void init() {
ssjCodeList = new HashMap<>();
ArrayList<String> ssjCodes = new ArrayList<>();
ssjCodes.add("G1006");
ssjCodes.add("G1012");
ssjCodeList.put("pick", ssjCodes);
apiService = SpringUtils.getBean(IApiService.class);
agvQueueService = SpringUtils.getBean(IAgvQueueService.class);
wcsPortService = SpringUtils.getBean(IWcsPortService.class);
}
@Override
public void run() {
init();
while (isRun) {
for (String type : ssjCodeList.keySet()) {
if ("pick".equals(type)) {
for (String ssjCode : ssjCodeList.get(type)) {
try {
if (PlcRead.deviceMap.containsKey(ssjCode)) {
pickDispatch(PlcRead.deviceMap.get(ssjCode));
} else {
log.error("设备不存在 ssjCode{}", ssjCode);
}
}catch (Exception e){
log.error(e.getMessage(),e);
}
}
}
}
try {
Thread.sleep(1500);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
}
public void pickDispatch(DeviceSsj pickSsjDevice) {
if (pickSsjDevice.getDw() == 1 && pickSsjDevice.getTaskNo() > 0) {
WcsPort wcsPortParam = new WcsPort();
wcsPortParam.setPortCode(pickSsjDevice.getDeviceCode());
wcsPortParam.setPortType("1");
List<WcsPort> wcsPorts = wcsPortService.selectWcsPortList(wcsPortParam);
if (CollUtil.isNotEmpty(wcsPorts)){
WcsPort wcsPort = wcsPorts.get(0);
if ("1".equals(wcsPort.getStatus())){
Map<String, Object> param = new HashMap<>();
param.put("taskNo", pickSsjDevice.getTaskNo());
param.put("wmsType", "2");
param.put("pickSsj", pickSsjDevice.getDeviceCode());
RequestLog requestLog = apiService.finishMydoJob(JOB_FINISH_URL, "出库任务到达拣选口", param);
if ("1".equals(requestLog.getIsSuccessful())){
wcsPort.setStatus("2");
wcsPortService.updateWcsPort(wcsPort);
}else {
log.error("任务失败{}", requestLog.getErrorDetails());
}
}
}
}
if (pickSsjDevice.getKx() == 1 && pickSsjDevice.getTaskNo() == 0){
WcsPort wcsPortParam = new WcsPort();
wcsPortParam.setPortCode(pickSsjDevice.getDeviceCode());
wcsPortParam.setPortType("1");
List<WcsPort> wcsPorts = wcsPortService.selectWcsPortList(wcsPortParam);
if (CollUtil.isNotEmpty(wcsPorts)){
WcsPort wcsPort = wcsPorts.get(0);
if ("2".equals(wcsPort.getStatus())){
wcsPort.setStatus("1");
wcsPortService.updateWcsPort(wcsPort);
}
}
}
}
}

View File

@@ -0,0 +1,132 @@
package com.ruoyi.schedule.scheduleTask.ssj.js;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjUtil;
import cn.hutool.core.util.StrUtil;
import com.ruoyi.api.domain.agv.genAgvSchedulingTask.GenAgvSchedulingTaskResponse;
import com.ruoyi.api.domain.wcs2wms.MydoJob;
import com.ruoyi.api.service.IApiService;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.device.agv.domain.AgvQueue;
import com.ruoyi.device.agv.service.IAgvQueueService;
import com.ruoyi.device.ssj.domain.DeviceSsj;
import com.ruoyi.schedule.plcRead.ssj.PlcRead;
import lombok.extern.slf4j.Slf4j;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@Slf4j
public class JsInSsjThread implements Runnable {
public HashMap<String, List<String>> ssjCodeList;
private IApiService apiService;
private IAgvQueueService agvQueueService;
public boolean isRun = true;
public void init() {
//todo 获取设备编码列表
ssjCodeList = new HashMap<>();
ArrayList<String> ssjCodes = new ArrayList<>();
ssjCodes.add("G2012");
ssjCodes.add("G3009");
ssjCodes.add("G3018");
ssjCodes.add("G4009");
ssjCodes.add("G4018");
ssjCodes.add("G5009");
ssjCodes.add("G5018");
ssjCodeList.put("in", ssjCodes);
apiService = SpringUtils.getBean(IApiService.class);
agvQueueService = SpringUtils.getBean(IAgvQueueService.class);
log.info("初始化服务 {},{}", apiService, agvQueueService);
}
@Override
public void run() {
init();
while (isRun){
for (String type : ssjCodeList.keySet()) {
switch ( type){
case "in":
//正常入库 尾箱回流 物料入库 空料箱入库
for (String ssjCode : ssjCodeList.get(type)) {
try {
if (PlcRead.deviceMap.containsKey(ssjCode)) {
inDispatch(PlcRead.deviceMap.get(ssjCode));
} else {
log.error("设备不存在 ssjCode{}", ssjCode);
}
} catch (RuntimeException e) {
log.error(e.getMessage(),e);
}
}
break;
}
}
try {
Thread.sleep(1500);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
}
public void inDispatch(DeviceSsj inSsjDevice) {
//如果入库请求1 并且 托盘码不为空
if (inSsjDevice.getDw()==1 && inSsjDevice.getRkqq() == 1 && StrUtil.isNotEmpty(inSsjDevice.getTrayCode())) {
//判断是否生成队列
AgvQueue agvQueueParam = new AgvQueue();
agvQueueParam.setWmsTraycode(inSsjDevice.getTrayCode());
//agvQueueParam.setStatus("0");
List<AgvQueue> agvQueues = agvQueueService.selectAgvQueueList(agvQueueParam);
if (CollUtil.isEmpty(agvQueues)) {
//根据入口,查询对应的入库作业
MydoJob mydoJobParam = new MydoJob();
mydoJobParam.setStatus("1");
mydoJobParam.setTrayCode(inSsjDevice.getTrayCode());
mydoJobParam.setEntranceId(inSsjDevice.getDeviceCode());
MydoJob mydoJob = apiService.requestEnterByTrayCode(mydoJobParam);
if (ObjUtil.isNotNull(mydoJob)) {
//生成agv队列
AgvQueue agvQueue = apiService.createAgvQueue(inSsjDevice.getName(), mydoJob.getCargoSpaceId(),mydoJob.getTrayCode(),mydoJob.getTaskNo(),"1");
//请求任务生成
GenAgvSchedulingTaskResponse genAgvSchedulingTaskResponse = apiService.requestAgvQueue(agvQueue);
//修改wms任务状态
if (genAgvSchedulingTaskResponse.getCode() == 0) {
//修改ctu执行状态
agvQueue.setStatus("1");
agvQueueService.updateAgvQueue(agvQueue);
log.info("向CTU下入库库作业");
}
}
}else {
AgvQueue agvQueue = agvQueues.get(0);
if ("0".equals(agvQueue.getStatus())){
//请求任务生成
GenAgvSchedulingTaskResponse genAgvSchedulingTaskResponse = apiService.requestAgvQueue(agvQueue);
//修改wms任务状态
if (genAgvSchedulingTaskResponse.getCode() == 0) {
//修改ctu执行状态
agvQueue.setStatus("1");
agvQueueService.updateAgvQueue(agvQueue);
log.info("向CTU下入库库作业");
}
}
}
}
}
}

View File

@@ -0,0 +1,135 @@
package com.ruoyi.schedule.scheduleTask.ssj.js;
import cn.hutool.core.collection.CollUtil;
import com.ruoyi.api.domain.agv.continueTask.ContinueTaskRequest;
import com.ruoyi.api.domain.agv.continueTask.ContinueTaskResponse;
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.common.utils.spring.SpringUtils;
import com.ruoyi.device.agv.domain.AgvQueue;
import com.ruoyi.device.agv.service.IAgvQueueService;
import com.ruoyi.device.ssj.domain.DeviceSsj;
import com.ruoyi.schedule.plcRead.ssj.PlcRead;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@Slf4j
public class JsOutSsjThread implements Runnable{
public HashMap<String, List<String>> ssjCodeList;
private IApiService apiService;
private IAgvQueueService agvQueueService;
public boolean isRun = true;
public void init() {
ssjCodeList = new HashMap<>();
ArrayList<String> ssjCodes = new ArrayList<>();
ssjCodes.add("G2001");
ssjCodes.add("G3001");
ssjCodes.add("G3010");
ssjCodes.add("G4001");
ssjCodes.add("G4010");
ssjCodes.add("G5001");
ssjCodes.add("G5010");
ssjCodeList.put("ssjOut", ssjCodes);
apiService = SpringUtils.getBean(IApiService.class);
agvQueueService = SpringUtils.getBean(IAgvQueueService.class);
}
@Override
public void run() {
init();
while (isRun){
for (String type : ssjCodeList.keySet()) {
switch (type){
case "ssjOut":
try {
//正常输送线出口
for (String ssjCode : ssjCodeList.get(type)) {
if (PlcRead.deviceMap.containsKey(ssjCode)) {
ssjOutDispatch(PlcRead.deviceMap.get(ssjCode));
} else {
log.error("设备不存在 ssjCode{}", ssjCode);
}
}
}catch (Exception e){
log.error(e.getMessage(), e);
}
break;
case "fluentOut":
//流利架出口(剪式没有)
break;
}
}
try {
Thread.sleep(1500);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
}
/**
* 输送线出口
* @param outSsjDevice
*/
public void ssjOutDispatch(DeviceSsj outSsjDevice) {
if (outSsjDevice.getKx()==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) {
requestAgvQueue( queue);
}
}else {
log.info("ssjCode:{},没有待下发的出库任务", outSsjDevice.getDeviceCode());
}
}
}
/**
* 请求海康生成agv任务,并修改wms任务状态
* @param agvQueue
*/
private void requestAgvQueue(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(agvQueue.getTaskCode());
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下入库库作业");
}
}
}

View File

@@ -0,0 +1,131 @@
package com.ruoyi.schedule.scheduleTask.ssj.js;
import cn.hutool.core.collection.CollUtil;
import com.ruoyi.api.domain.RequestLog;
import com.ruoyi.api.service.IApiService;
import com.ruoyi.bas.port.domain.WcsPort;
import com.ruoyi.bas.port.service.IWcsPortService;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.device.agv.service.IAgvQueueService;
import com.ruoyi.device.ssj.domain.DeviceSsj;
import com.ruoyi.schedule.plcRead.ssj.PlcRead;
import lombok.extern.slf4j.Slf4j;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.ruoyi.common.Constant.JOB_FINISH_URL;
@Slf4j
public class JsPickSsjTread implements Runnable {
public HashMap<String, List<String>> ssjCodeList;
private IApiService apiService;
private IAgvQueueService agvQueueService;
private IWcsPortService wcsPortService;
public boolean isRun = true;
public void init() {
ssjCodeList = new HashMap<>();
ArrayList<String> ssjCodes = new ArrayList<>();
ssjCodes.add("G5013");
ssjCodes.add("G5014");
ssjCodes.add("G5015");
ssjCodes.add("G5004");
ssjCodes.add("G5005");
ssjCodes.add("G5006");
ssjCodes.add("G4013");
ssjCodes.add("G4014");
ssjCodes.add("G4015");
ssjCodes.add("G4004");
ssjCodes.add("G4005");
ssjCodes.add("G4006");
ssjCodeList.put("pick", ssjCodes);
apiService = SpringUtils.getBean(IApiService.class);
agvQueueService = SpringUtils.getBean(IAgvQueueService.class);
wcsPortService = SpringUtils.getBean(IWcsPortService.class);
}
@Override
public void run(){
init();
while (isRun){
for (String type : ssjCodeList.keySet()) {
if ("pick".equals(type)) {
for (String ssjCode : ssjCodeList.get(type)) {
try {
if (PlcRead.deviceMap.containsKey(ssjCode)) {
pickDispatch(PlcRead.deviceMap.get(ssjCode));
} else {
log.error("设备不存在 ssjCode{}", ssjCode);
}
}catch (Exception e){
log.error(e.getMessage(),e);
}
}
}
}
try {
Thread.sleep(1500);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
}
public void pickDispatch(DeviceSsj pickSsjDevice) {
if (pickSsjDevice.getDw() == 1 && pickSsjDevice.getTaskNo() > 0) {
WcsPort wcsPortParam = new WcsPort();
wcsPortParam.setPortCode(pickSsjDevice.getDeviceCode());
wcsPortParam.setPortType("1");
List<WcsPort> wcsPorts = wcsPortService.selectWcsPortList(wcsPortParam);
if (CollUtil.isNotEmpty(wcsPorts)){
WcsPort wcsPort = wcsPorts.get(0);
if ("1".equals(wcsPort.getStatus())){
Map<String, Object> param = new HashMap<>();
param.put("taskNo", pickSsjDevice.getTaskNo());
param.put("wmsType", "2");
param.put("pickSsj", pickSsjDevice.getDeviceCode());
RequestLog requestLog = apiService.finishMydoJob(JOB_FINISH_URL, "出库任务到达拣选口", param);
if ("1".equals(requestLog.getIsSuccessful())){
wcsPort.setStatus("2");
wcsPortService.updateWcsPort(wcsPort);
}else {
log.error("任务失败{}", requestLog.getErrorDetails());
}
}
}
}
if (pickSsjDevice.getKx() == 1 && pickSsjDevice.getTaskNo() == 0){
WcsPort wcsPortParam = new WcsPort();
wcsPortParam.setPortCode(pickSsjDevice.getDeviceCode());
wcsPortParam.setPortType("1");
List<WcsPort> wcsPorts = wcsPortService.selectWcsPortList(wcsPortParam);
if (CollUtil.isNotEmpty(wcsPorts)){
WcsPort wcsPort = wcsPorts.get(0);
if ("2".equals(wcsPort.getStatus())){
wcsPort.setStatus("1");
wcsPortService.updateWcsPort(wcsPort);
}
}
}
}
}

View File

@@ -0,0 +1,95 @@
package com.ruoyi.schedule.scheduleTask.ssj.monitor;
import cn.hutool.core.util.ObjUtil;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.device.ssj.domain.DeviceSsj;
import com.ruoyi.device.ssj.service.IDeviceSsjService;
import com.ruoyi.schedule.plcRead.ssj.PlcRead;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class CarMonitorThread implements Runnable {
private IDeviceSsjService deviceSsjService;
public boolean isRun = true;
public void init() {
deviceSsjService = SpringUtils.getBean(IDeviceSsjService.class);
log.info("初始化服务 {}", deviceSsjService);
}
@Override
public void run() {
init();
while (isRun) {
for (String ssjCode : PlcRead.deviceMap.keySet()) {
try {
DeviceSsj deviceSsj = PlcRead.deviceMap.get(ssjCode);
if (ObjUtil.isNotNull(deviceSsj)){
switch (deviceSsj.getType()) {
case "1":
monitor1(deviceSsj);
break;
case "2":
monitor2(deviceSsj);
break;
case "3":
monitor3(deviceSsj);
break;
case "4":
monitor4(deviceSsj);
break;
}
}else {
log.error("设备不存在 {}", ssjCode);
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
try {
Thread.sleep(1500);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
}
/**
*其他输送机监控
* @param deviceSsj
*/
private void monitor4(DeviceSsj deviceSsj) {
deviceSsjService.updateDeviceSsj(deviceSsj);
}
/**
*入库输送机监控
* @param deviceSsj
*/
private void monitor3(DeviceSsj deviceSsj) {
deviceSsjService.updateDeviceSsj(deviceSsj);
}
/**
*拣选输送机监控
* @param deviceSsj
*/
private void monitor2(DeviceSsj deviceSsj) {
deviceSsjService.updateDeviceSsj(deviceSsj);
}
/**
*出库输送机监控
* @param deviceSsj
*/
private void monitor1(DeviceSsj deviceSsj) {
deviceSsjService.updateDeviceSsj(deviceSsj);
}
}

View File

@@ -0,0 +1,106 @@
package com.ruoyi.schedule.scheduleTask.ssj.monitor;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjUtil;
import cn.hutool.core.util.StrUtil;
import com.ruoyi.api.domain.agv.genAgvSchedulingTask.GenAgvSchedulingTaskResponse;
import com.ruoyi.api.domain.wcs2wms.MydoJob;
import com.ruoyi.api.service.IApiService;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.device.agv.domain.AgvQueue;
import com.ruoyi.device.agv.service.IAgvQueueService;
import com.ruoyi.device.ssj.domain.DeviceSsj;
import com.ruoyi.device.ssj.service.IDeviceSsjService;
import com.ruoyi.schedule.plcRead.ssj.PlcRead;
import lombok.extern.slf4j.Slf4j;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@Slf4j
public class SsjMonitorThread implements Runnable {
private IDeviceSsjService deviceSsjService;
public boolean isRun = true;
public void init() {
deviceSsjService = SpringUtils.getBean(IDeviceSsjService.class);
log.info("初始化服务 {}", deviceSsjService);
}
@Override
public void run() {
init();
while (isRun) {
for (String ssjCode : PlcRead.deviceMap.keySet()) {
try {
DeviceSsj deviceSsj = PlcRead.deviceMap.get(ssjCode);
if (ObjUtil.isNotNull(deviceSsj)){
switch (deviceSsj.getType()) {
case "1":
monitor1(deviceSsj);
break;
case "2":
monitor2(deviceSsj);
break;
case "3":
monitor3(deviceSsj);
break;
case "4":
monitor4(deviceSsj);
break;
}
}else {
log.error("设备不存在 {}", ssjCode);
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
try {
Thread.sleep(15000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
}
/**
*其他输送机监控
* @param deviceSsj
*/
private void monitor4(DeviceSsj deviceSsj) {
deviceSsjService.updateDeviceSsj(deviceSsj);
}
/**
*入库输送机监控
* @param deviceSsj
*/
private void monitor3(DeviceSsj deviceSsj) {
deviceSsjService.updateDeviceSsj(deviceSsj);
}
/**
*拣选输送机监控
* @param deviceSsj
*/
private void monitor2(DeviceSsj deviceSsj) {
deviceSsjService.updateDeviceSsj(deviceSsj);
}
/**
*出库输送机监控
* @param deviceSsj
*/
private void monitor1(DeviceSsj deviceSsj) {
deviceSsjService.updateDeviceSsj(deviceSsj);
}
}