修改 ssj tsj srgv cdz的读取调度,监控调度

This commit is contained in:
liuhanqing
2026-01-05 14:10:56 +08:00
parent f209620cd7
commit 5fe90b8bb4
12 changed files with 124 additions and 136 deletions

View File

@@ -2,15 +2,21 @@ package com.ruoyi.schedule;
import com.ruoyi.common.domain.CustomThread; import com.ruoyi.common.domain.CustomThread;
import com.ruoyi.common.domain.PlcConnectInfo; import com.ruoyi.common.domain.PlcConnectInfo;
import com.ruoyi.device.cdz.domain.DeviceCdz;
import com.ruoyi.device.cdz.service.IDeviceCdzService;
import com.ruoyi.device.ddj.domain.MsgDdj; import com.ruoyi.device.ddj.domain.MsgDdj;
import com.ruoyi.device.ddj.service.IMsgDdjService; import com.ruoyi.device.ddj.service.IMsgDdjService;
import com.ruoyi.device.srgv.domain.DeviceSrgv; import com.ruoyi.device.srgv.domain.DeviceSrgv;
import com.ruoyi.device.srgv.service.IDeviceSrgvService; import com.ruoyi.device.srgv.service.IDeviceSrgvService;
import com.ruoyi.device.ssj.domain.DeviceSsj; import com.ruoyi.device.ssj.domain.DeviceSsj;
import com.ruoyi.device.ssj.service.IDeviceSsjService; import com.ruoyi.device.ssj.service.IDeviceSsjService;
import com.ruoyi.device.tsj.domain.DeviceTsj;
import com.ruoyi.device.tsj.service.IDeviceTsjService;
import com.ruoyi.schedule.plcRead.cdz.PlcCdzRead;
import com.ruoyi.schedule.plcRead.ddj.PlcDdjRead; import com.ruoyi.schedule.plcRead.ddj.PlcDdjRead;
import com.ruoyi.schedule.plcRead.srgv.PlcSrgvRead; import com.ruoyi.schedule.plcRead.srgv.PlcSrgvRead;
import com.ruoyi.schedule.plcRead.ssj.PlcSsjRead; import com.ruoyi.schedule.plcRead.ssj.PlcSsjRead;
import com.ruoyi.schedule.plcRead.tsj.PlcTsjRead;
import com.ruoyi.schedule.scheduleTask.cdz.CdzThread; import com.ruoyi.schedule.scheduleTask.cdz.CdzThread;
import com.ruoyi.schedule.scheduleTask.ddj.impl.Ddj1Thread; import com.ruoyi.schedule.scheduleTask.ddj.impl.Ddj1Thread;
import com.ruoyi.schedule.scheduleTask.monit.MonitoringThread; import com.ruoyi.schedule.scheduleTask.monit.MonitoringThread;
@@ -31,25 +37,27 @@ import java.util.concurrent.ConcurrentHashMap;
public class ScheduleThread { public class ScheduleThread {
public CustomThread<PlcSsjRead> plcSsjReadCustomThread; public CustomThread<PlcSsjRead> plcSsjReadCustomThread;
public CustomThread<PlcTsjRead> plcTsjReadCustomThread;
public CustomThread<PlcCdzRead> plcCdzReadCustomThread;
public CustomThread<PlcSrgvRead> plcSrgvReadCustomThread1; public CustomThread<PlcSrgvRead> plcSrgvReadCustomThread1;
public CustomThread<PlcSrgvRead> plcSrgvReadCustomThread2; public CustomThread<PlcSrgvRead> plcSrgvReadCustomThread2;
public CustomThread<PlcSrgvRead> plcSrgvReadCustomThread3; public CustomThread<PlcSrgvRead> plcSrgvReadCustomThread3;
public CustomThread<MonitoringThread> monitoringCustomThread; public CustomThread<MonitoringThread> monitoringCustomThread;
public CustomThread<SsjThread> ssjThreadCustomThread; public CustomThread<SsjThread> ssjThreadCustomThread;
public CustomThread<SRgv1Thread> sRgvThreadCustomThread; public CustomThread<SRgv1Thread> sRgvThreadCustomThread;
public CustomThread<TsjThread> tsjThreadCustomThread; public CustomThread<TsjThread> tsjThreadCustomThread;
public CustomThread<CdzThread> cdzThreadCustomThread; public CustomThread<CdzThread> cdzThreadCustomThread;
// public CustomThread<Ddj1Thread> ddj1CustomThread;
/*public CustomThread<Ddj2Thread> ddj2CustomThread;
public CustomThread<Ddj3Thread> ddj3CustomThread;
public CustomThread<Ddj4Thread> ddj4CustomThread;
public CustomThread<Ddj5Thread> ddj5CustomThread;
public CustomThread<Ddj6Thread> ddj6CustomThread;*/
@Autowired @Autowired
private IDeviceSsjService deviceSsjService; private IDeviceSsjService deviceSsjService;
@Autowired @Autowired
private IDeviceSrgvService deviceSrgvService; private IDeviceSrgvService deviceSrgvService;
@Autowired
private IDeviceTsjService deviceTsjService;
@Autowired
private IDeviceCdzService deviceCdzService;
private boolean isRun = false; private boolean isRun = false;
private boolean isRun2 = false; private boolean isRun2 = false;
@@ -111,6 +119,7 @@ public class ScheduleThread {
Thread plcSsjReadThread = new Thread(plcSsjRead); Thread plcSsjReadThread = new Thread(plcSsjRead);
plcSsjReadCustomThread = new CustomThread<PlcSsjRead>(plcSsjReadThread, plcSsjRead); plcSsjReadCustomThread = new CustomThread<PlcSsjRead>(plcSsjReadThread, plcSsjRead);
//四向车读取线程
ConcurrentHashMap<String, DeviceSrgv> srgvList = new ConcurrentHashMap<>(); ConcurrentHashMap<String, DeviceSrgv> srgvList = new ConcurrentHashMap<>();
List<DeviceSrgv> srgvs=deviceSrgvService.selectDeviceSrgvList(new DeviceSrgv()); List<DeviceSrgv> srgvs=deviceSrgvService.selectDeviceSrgvList(new DeviceSrgv());
for(DeviceSrgv srgv:srgvs){ for(DeviceSrgv srgv:srgvs){
@@ -136,6 +145,25 @@ public class ScheduleThread {
} }
PlcSrgvRead.deviceSrgvMap=srgvList; PlcSrgvRead.deviceSrgvMap=srgvList;
//提升机读取线程
ConcurrentHashMap<String, DeviceTsj> tsjList = new ConcurrentHashMap<>();
List<DeviceTsj> deviceTsjs = deviceTsjService.selectDeviceTsjList(new DeviceTsj());
for (DeviceTsj deviceTsj : deviceTsjs) {
tsjList.put(deviceTsj.getId().toString(), deviceTsj);
}
PlcTsjRead plcTsjRead = new PlcTsjRead(tsjList,new PlcConnectInfo("127.0.0.1", 102));
Thread plcTsjReadThread = new Thread(plcTsjRead);
plcTsjReadCustomThread = new CustomThread<>(plcTsjReadThread, plcTsjRead);
//充电桩读取线程
ConcurrentHashMap<String, DeviceCdz> cdzList = new ConcurrentHashMap<>();
List<DeviceCdz> deviceCdzs = deviceCdzService.selectDeviceCdzList(new DeviceCdz());
for (DeviceCdz deviceCdz : deviceCdzs) {
cdzList.put(deviceCdz.getId().toString(), deviceCdz);
}
PlcCdzRead plcCdzRead = new PlcCdzRead(cdzList,new PlcConnectInfo("127.0.0.1", 102));
Thread plcCdzReadThread = new Thread(plcCdzRead);
plcCdzReadCustomThread = new CustomThread<>(plcCdzReadThread, plcCdzRead);
} }
@@ -145,8 +173,10 @@ public class ScheduleThread {
public void startAllThread() { public void startAllThread() {
plcSsjReadCustomThread.getThread().start(); plcSsjReadCustomThread.getThread().start();
plcSrgvReadCustomThread1.getThread().start(); plcSrgvReadCustomThread1.getThread().start();
//plcSrgvReadCustomThread2.getThread().start(); plcSrgvReadCustomThread2.getThread().start();
//plcSrgvReadCustomThread3.getThread().start(); plcSrgvReadCustomThread3.getThread().start();
plcTsjReadCustomThread.getThread().start();
plcCdzReadCustomThread.getThread().start();
isRun = true; isRun = true;
@@ -157,16 +187,11 @@ public class ScheduleThread {
*/ */
public void startAllThread2() { public void startAllThread2() {
monitoringCustomThread.thread.start(); monitoringCustomThread.thread.start();
ssjThreadCustomThread.thread.start(); //ssjThreadCustomThread.thread.start();
//tsjThreadCustomThread.thread.start(); //tsjThreadCustomThread.thread.start();
sRgvThreadCustomThread.thread.start(); //sRgvThreadCustomThread.thread.start();
//cdzThreadCustomThread.thread.start(); //cdzThreadCustomThread.thread.start();
// ddj1CustomThread.thread.start();
/*ddj2CustomThread.thread.start();
ddj3CustomThread.thread.start();
ddj4CustomThread.thread.start();
ddj5CustomThread.thread.start();
ddj6CustomThread.thread.start();*/
isRun2 = true; isRun2 = true;
} }

View File

@@ -67,7 +67,7 @@ public class PlcCdzRead implements Runnable {
} }
private void plcRead(DeviceCdz deviceCdz) { private void plcRead(DeviceCdz deviceCdz) {
OperateResultExOne<byte[]> read2 = readWriteNet.Read(deviceCdz.getPlcDbReadAddress(), Short.parseShort("20")); OperateResultExOne<byte[]> read2 = readWriteNet.Read(deviceCdz.getPlcDbReadAddress(), Short.parseShort("4"));
String ddsx1 = "0"; String ddsx1 = "0";
if (read2.IsSuccess) { if (read2.IsSuccess) {
ddsx1 = SoftBasic.ByteToHexString(read2.Content); ddsx1 = SoftBasic.ByteToHexString(read2.Content);

View File

@@ -7,27 +7,22 @@ import HslCommunication.Core.Types.OperateResult;
import HslCommunication.Core.Types.OperateResultExOne; import HslCommunication.Core.Types.OperateResultExOne;
import HslCommunication.ModBus.ModbusTcpNet; import HslCommunication.ModBus.ModbusTcpNet;
import cn.hutool.core.convert.Convert; import cn.hutool.core.convert.Convert;
import com.ruoyi.common.domain.HslRead;
import com.ruoyi.common.domain.PlcConnectInfo; import com.ruoyi.common.domain.PlcConnectInfo;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.device.srgv.domain.DeviceSrgv; import com.ruoyi.device.srgv.domain.DeviceSrgv;
import com.ruoyi.device.srgv.service.IDeviceSrgvService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@Slf4j @Slf4j
public class PlcSrgvRead implements Runnable { public class PlcSrgvRead implements Runnable {
public static ConcurrentHashMap<String, DeviceSrgv> deviceSrgvMap; public static ConcurrentHashMap<String, DeviceSrgv> deviceSrgvMap;
private static ModbusTcpNet modbusTcpNet; private ModbusTcpNet modbusTcpNet;
public static IReadWriteNet readWriteNet = null; public IReadWriteNet readWriteNet = null;
public volatile boolean isRun = true; public volatile boolean isRun = true;
private final String ip; private final String ip;
private final int port; private final int port;
private byte station; private byte station;
private Integer layer;
private DeviceSrgv deviceSrgv; private DeviceSrgv deviceSrgv;
private boolean success = false; private boolean success = false;
private IByteTransform byteTransform = null; private IByteTransform byteTransform = null;
@@ -41,15 +36,16 @@ public class PlcSrgvRead implements Runnable {
public static boolean Write(String address, int[] value){ public static boolean Write(String address, int[] value){
OperateResult write = modbusTcpNet.Write(address, value); //OperateResult write = modbusTcpNet.Write(address, value);
return write.IsSuccess; return true;
} }
public static boolean Write(String address, short[] value){ public static boolean Write(String address, short[] value){
OperateResult write = modbusTcpNet.Write(address, value); //OperateResult write = modbusTcpNet.Write(address, value);
return write.IsSuccess; return true;
} }
@@ -58,24 +54,13 @@ public class PlcSrgvRead implements Runnable {
public void run() { public void run() {
while (isRun) { while (isRun) {
try { try {
/*if (IsConnect()) { if (IsConnect()) {
if (deviceSrgv != null) {
*//*if (deviceSrgv != null) { readSrgvPlc(deviceSrgv);
//readSrgvPlc(deviceSrgv); }
}*//*
} else { } else {
reConnect(); reConnect();
}*/
IDeviceSrgvService deviceSrgvService = SpringUtils.getBean(IDeviceSrgvService.class);
List<DeviceSrgv> srgvs=deviceSrgvService.selectDeviceSrgvList(new DeviceSrgv());
ConcurrentHashMap<String, DeviceSrgv> srgvList = new ConcurrentHashMap<>();
for(DeviceSrgv srgv:srgvs){
srgvList.put(srgv.getDeviceId().toString(),srgv);
} }
PlcSrgvRead.deviceSrgvMap=srgvList;
Thread.sleep(1000); Thread.sleep(1000);
} catch (InterruptedException e) { } catch (InterruptedException e) {
// 捕获中断异常,退出循环 // 捕获中断异常,退出循环
@@ -89,20 +74,16 @@ public class PlcSrgvRead implements Runnable {
} }
private void readSrgvPlc(DeviceSrgv deviceSrgv) { private void readSrgvPlc(DeviceSrgv deviceSrgv) {
OperateResultExOne<byte[]> read1 = modbusTcpNet.Read("2400", (short) 15);//2400-2414 OperateResultExOne<byte[]> read1 = modbusTcpNet.Read("4068", (short) 15);//2400-2414
if (read1.IsSuccess) { if (read1.IsSuccess) {
setValueByByte1(read1.Content, deviceSrgv); setValueByByte1(read1.Content, deviceSrgv);
} }
//读取双字 //读取双字
OperateResultExOne<byte[]> read2 = modbusTcpNet.Read("4800", (short) 8);// 4800-4807任务号、原点、目标点、当前 OperateResultExOne<byte[]> read2 = modbusTcpNet.Read("4060", (short) 8);// 4800-4807任务号、原点、目标点、当前
if (read2.IsSuccess) { if (read2.IsSuccess) {
setValueByByte2(read2.Content, deviceSrgv); setValueByByte2(read2.Content, deviceSrgv);
} }
//读取双字,路径
OperateResultExOne<byte[]> read3 = modbusTcpNet.Read("5000", (short) 800);// 5000-5799 路径 400个
setValueByByte3(read3.Content, deviceSrgv);
} }
//单字 //单字
@@ -112,17 +93,15 @@ public class PlcSrgvRead implements Runnable {
agvData.setWorkMode(Convert.toInt(byteTransform.TransInt16(content, 4))); agvData.setWorkMode(Convert.toInt(byteTransform.TransInt16(content, 4)));
agvData.setAlarm(Convert.toInt(byteTransform.TransInt16(content, 6))); agvData.setAlarm(Convert.toInt(byteTransform.TransInt16(content, 6)));
agvData.setStatus(Convert.toInt(byteTransform.TransInt16(content, 8))); agvData.setStatus(Convert.toInt(byteTransform.TransInt16(content, 8)));
agvData.setFinish(Convert.toInt(byteTransform.TransInt16(content, 10))); //接收完成标志
agvData.setChargeFlag(Convert.toInt(byteTransform.TransInt16(content, 12))); // agvData.setFinish(Convert.toInt(byteTransform.TransInt16(content, 10)));
agvData.setWorkPhase(Convert.toInt(byteTransform.TransInt16(content, 14))); agvData.setFinish(Convert.toInt(byteTransform.TransInt16(content, 12)));
agvData.setErrMsg(Convert.toInt(byteTransform.TransInt16(content, 16))); agvData.setChargeFlag(Convert.toInt(byteTransform.TransInt16(content, 14)));
agvData.setSsjRequest(Convert.toInt(byteTransform.TransInt16(content, 18))); agvData.setWorkPhase(Convert.toInt(byteTransform.TransInt16(content, 16)));
agvData.setChangeLayer(Convert.toInt(byteTransform.TransInt16(content, 20))); agvData.setAllowSend(Convert.toInt(byteTransform.TransInt16(content, 18)));
agvData.setCargoFlag(Convert.toInt(byteTransform.TransInt16(content, 22))); agvData.setSsjRequest(Convert.toInt(byteTransform.TransInt16(content, 20)));
agvData.setManualCharge(Convert.toInt(byteTransform.TransInt16(content, 24))); agvData.setSpare2(String.valueOf(Convert.toInt(byteTransform.TransInt16(content, 22))));
agvData.setSpare1(Convert.toStr(byteTransform.TransInt16(content, 0))); agvData.setChangeLayer(Convert.toInt(byteTransform.TransInt16(content, 24)));//换层标志
agvData.setAllowSend(Convert.toInt(byteTransform.TransInt16(content, 16)));
} }
@@ -130,44 +109,21 @@ public class PlcSrgvRead implements Runnable {
byteTransform.setDataFormat(DataFormat.CDAB); byteTransform.setDataFormat(DataFormat.CDAB);
// TODO 注意双字反转 // TODO 注意双字反转
agvData.setTaskNo(byteTransform.TransInt32(content, 0)); agvData.setTaskNo(byteTransform.TransInt32(content, 0));
//log.info("=====小车{}读取到SRGV任务号:{}=======",agvData.getDeviceId(), agvData.getTaskNo());
agvData.setSrcSite(String.format("%06d", byteTransform.TransInt32(content, 4))); agvData.setSrcSite(String.format("%06d", byteTransform.TransInt32(content, 4)));
//log.info("=====小车{}读取到SRGV源站点:{}=======",agvData.getDeviceId(), agvData.getSrcSite());
agvData.setTarSite(String.format("%06d", byteTransform.TransInt32(content, 8))); agvData.setTarSite(String.format("%06d", byteTransform.TransInt32(content, 8)));
//log.info("=====小车{}读取到SRGV目标站点:{}=======",agvData.getDeviceId(), agvData.getTarSite());
agvData.setCurrSite(String.format("%06d", byteTransform.TransInt32(content, 12))); agvData.setCurrSite(String.format("%06d", byteTransform.TransInt32(content, 12)));
//log.info("=====小车{}读取到SRGV当前站点:{}=======",agvData.getDeviceId(), agvData.getCurrSite());
//设置库区
String currSite = agvData.getCurrSite();
String l = currSite.substring(2, 4);
//截取cur的后俩位,获取当前楼层 //截取cur的后俩位,获取当前楼层
int floor = FloorUtils.extractFloor(Integer.parseInt(agvData.getCurrSite())); int floor = FloorUtils.extractFloor(Integer.parseInt(String.format("%06d", byteTransform.TransInt32(content, 12))));
this.layer = floor;
agvData.setCurrFloor(floor); agvData.setCurrFloor(floor);
} }
private void setValueByByte3(byte[] content, DeviceSrgv agvData) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < content.length; i += 4) {
// 检查剩余字节是否足够4个
if (i + 4 > content.length) break;
// TODO 注意双字反转
int value = byteTransform.TransInt32(content, i);
// 如果值为0,终止循环
if (value == 0) {
break;
}
sb.append(String.format("%06d", value)).append(","); // 用逗号分隔每个int值
}
// 移除最后多余的 ","
if (sb.length() > 0) {
sb.setLength(sb.length() - 1);
}
agvData.setPath(sb.toString());
}
public void ConnectServer() { public void ConnectServer() {
ModbusTcpNet modbusTcpNet = new ModbusTcpNet();//创建一个Modbus对象 modbusTcpNet = new ModbusTcpNet();//创建一个Modbus对象
try { try {
modbusTcpNet.setIpAddress(this.ip); modbusTcpNet.setIpAddress(this.ip);
modbusTcpNet.setPort(this.port); modbusTcpNet.setPort(this.port);
@@ -199,7 +155,7 @@ public class PlcSrgvRead implements Runnable {
void reConnect() { void reConnect() {
closeServer(); closeServer();
ConnectServer(); ConnectServer();
log.info("重新连接 SSJ-PLC"); log.info("重新连接 四象车-PLC");
} }
void closeServer() { void closeServer() {

View File

@@ -52,14 +52,12 @@ public class PlcSsjRead implements Runnable {
while (isRun) { while (isRun) {
try { try {
//todo 要读重量 //todo 要读重量
/*if (IsConnect()) { if (IsConnect()) {
int step = 20; for (String ssjCode : deviceSsjMap.keySet()) {
int baseOffset = 0;
*//*for (String ssjCode : deviceSsjMap.keySet()) {
DeviceSsj ssjDevice = deviceSsjMap.get(ssjCode); DeviceSsj ssjDevice = deviceSsjMap.get(ssjCode);
switch (ssjDevice.getType()) { switch (ssjDevice.getType()) {
case "1": case "1":
readPlcLineSsj(ssjDevice); readPlcRoadWaySsj(ssjDevice);
break; break;
case "2": case "2":
readPlcInOutSsj(ssjDevice); readPlcInOutSsj(ssjDevice);
@@ -68,18 +66,11 @@ public class PlcSsjRead implements Runnable {
readPlcOtherSsj(ssjDevice); readPlcOtherSsj(ssjDevice);
break; break;
} }
}*//* }
} else { } else {
reConnect(); reConnect();
}*/
DeviceSsjServiceImpl deviceSsjService = SpringUtils.getBean(DeviceSsjServiceImpl.class);
List<DeviceSsj> deviceSsjs = deviceSsjService.selectDeviceSsjList(new DeviceSsj());
ConcurrentHashMap<String, DeviceSsj> ssjList = new ConcurrentHashMap<>();
for (DeviceSsj deviceSsj : deviceSsjs) {
ssjList.put(deviceSsj.getDeviceCode(), deviceSsj);
} }
PlcSsjRead.deviceSsjMap = ssjList;
Thread.sleep(1000); Thread.sleep(1000);
} catch (InterruptedException e) { } catch (InterruptedException e) {
// 捕获中断异常,退出循环 // 捕获中断异常,退出循环
@@ -140,7 +131,6 @@ public class PlcSsjRead implements Runnable {
ssjDevice.setException(ParseUtil.optInt(4, ddsx1)); ssjDevice.setException(ParseUtil.optInt(4, ddsx1));
ssjDevice.setAllowPut(ParseUtil.optInt(6, ddsx1)); ssjDevice.setAllowPut(ParseUtil.optInt(6, ddsx1));
ssjDevice.setTaskNo(ParseUtil.optDInt(8, ddsx1)); ssjDevice.setTaskNo(ParseUtil.optDInt(8, ddsx1));
} }
} }

View File

@@ -68,7 +68,7 @@ public class PlcTsjRead implements Runnable {
} }
private void plcRead(DeviceTsj tsjDevice) { private void plcRead(DeviceTsj tsjDevice) {
OperateResultExOne<byte[]> read2 = readWriteNet.Read(tsjDevice.getPlcDbReadAddress(), Short.parseShort("220")); OperateResultExOne<byte[]> read2 = readWriteNet.Read(tsjDevice.getPlcDbReadAddress(), Short.parseShort("48"));
String ddsx1 = "0"; String ddsx1 = "0";
if (read2.IsSuccess) { if (read2.IsSuccess) {
ddsx1 = SoftBasic.ByteToHexString(read2.Content); ddsx1 = SoftBasic.ByteToHexString(read2.Content);
@@ -122,7 +122,7 @@ public class PlcTsjRead implements Runnable {
void reConnect() { void reConnect() {
closeServer(); closeServer();
ConnectServer(); ConnectServer();
log.info("重新连接 SSJ-PLC"); log.info("重新连接 TSJ-PLC");
} }
void closeServer() { void closeServer() {

View File

@@ -48,7 +48,7 @@ public class CdzThread implements Runnable {
init(); init();
while (isRun) { while (isRun) {
try { try {
dispatch(); dispatch();
Thread.sleep(1500); Thread.sleep(1500);
}catch (Exception e){ }catch (Exception e){
log.error(e.getMessage(),e); log.error(e.getMessage(),e);

View File

@@ -1,11 +1,20 @@
package com.ruoyi.schedule.scheduleTask.monit; package com.ruoyi.schedule.scheduleTask.monit;
import com.ruoyi.common.utils.spring.SpringUtils; import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.device.cdz.domain.DeviceCdz;
import com.ruoyi.device.cdz.service.IDeviceCdzService;
import com.ruoyi.device.ddj.service.IMsgDdjService; import com.ruoyi.device.ddj.service.IMsgDdjService;
import com.ruoyi.device.srgv.domain.DeviceSrgv;
import com.ruoyi.device.srgv.service.IDeviceSrgvService;
import com.ruoyi.device.ssj.domain.DeviceSsj; import com.ruoyi.device.ssj.domain.DeviceSsj;
import com.ruoyi.device.ssj.service.IDeviceSsjService; import com.ruoyi.device.ssj.service.IDeviceSsjService;
import com.ruoyi.device.tsj.domain.DeviceTsj;
import com.ruoyi.device.tsj.service.IDeviceTsjService;
import com.ruoyi.schedule.plcRead.cdz.PlcCdzRead;
import com.ruoyi.schedule.plcRead.ddj.PlcDdjRead; import com.ruoyi.schedule.plcRead.ddj.PlcDdjRead;
import com.ruoyi.schedule.plcRead.srgv.PlcSrgvRead;
import com.ruoyi.schedule.plcRead.ssj.PlcSsjRead; import com.ruoyi.schedule.plcRead.ssj.PlcSsjRead;
import com.ruoyi.schedule.plcRead.tsj.PlcTsjRead;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
/** /**
@@ -18,24 +27,39 @@ public class MonitoringThread implements Runnable {
private IDeviceSsjService deviceSsjService; private IDeviceSsjService deviceSsjService;
private IMsgDdjService msgDdjService; private IMsgDdjService msgDdjService;
private IDeviceSrgvService deviceSrgvService;
private IDeviceTsjService deviceTsjService;
private IDeviceCdzService deviceCdzService;
public void init() { public void init() {
deviceSsjService = SpringUtils.getBean(IDeviceSsjService.class); deviceSsjService = SpringUtils.getBean(IDeviceSsjService.class);
msgDdjService = SpringUtils.getBean(IMsgDdjService.class); msgDdjService = SpringUtils.getBean(IMsgDdjService.class);
deviceSrgvService = SpringUtils.getBean(IDeviceSrgvService.class);
deviceTsjService = SpringUtils.getBean(IDeviceTsjService.class);
deviceCdzService = SpringUtils.getBean(IDeviceCdzService.class);
} }
@Override @Override
public void run() { public void run() {
init(); init();
while (isRun){ while (isRun){
//输送机监控
for (String ssjCode : PlcSsjRead.deviceSsjMap.keySet()) { for (String ssjCode : PlcSsjRead.deviceSsjMap.keySet()) {
DeviceSsj deviceSsj = PlcSsjRead.deviceSsjMap.get(ssjCode); DeviceSsj deviceSsj = PlcSsjRead.deviceSsjMap.get(ssjCode);
deviceSsj.setTraySize(deviceSsj.getModel());
deviceSsjService.updateDeviceSsj(deviceSsj); deviceSsjService.updateDeviceSsj(deviceSsj);
} }
for (String ddjCode : PlcDdjRead.deviceDdjMap.keySet()) { for (String srgvCode : PlcSrgvRead.deviceSrgvMap.keySet()) {
msgDdjService.updateMsgDdj(PlcDdjRead.deviceDdjMap.get(ddjCode)); DeviceSrgv deviceSrgv = PlcSrgvRead.deviceSrgvMap.get(srgvCode);
deviceSrgvService.updateDeviceSrgv(deviceSrgv);
}
for (String tsjCode : PlcTsjRead.deviceTsjMap.keySet()) {
DeviceTsj deviceTsj = PlcTsjRead.deviceTsjMap.get(tsjCode);
deviceTsjService.updateDeviceTsj(deviceTsj);
}
for (String cdzCode : PlcCdzRead.deviceCdzMap.keySet()) {
DeviceCdz deviceCdz = PlcCdzRead.deviceCdzMap.get(cdzCode);
deviceCdzService.updateDeviceCdz(deviceCdz);
} }
try { try {
Thread.sleep(1500); Thread.sleep(1500);

View File

@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert; import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjUtil; import cn.hutool.core.util.ObjUtil;
import cn.hutool.core.util.StrUtil;
import com.ruoyi.bas.port.service.IWcsPortService; import com.ruoyi.bas.port.service.IWcsPortService;
import com.ruoyi.bas.srgvmap.domain.WcsSrgvMap; import com.ruoyi.bas.srgvmap.domain.WcsSrgvMap;
import com.ruoyi.bas.srgvmap.service.IWcsSrgvMapService; import com.ruoyi.bas.srgvmap.service.IWcsSrgvMapService;
@@ -351,10 +352,11 @@ public class BaseSRgvThread implements Runnable, SRgvThreadInterface {
if (deviceSrgv1.getCurrFloor().toString().equals(mydoJob1.getTheFloor())) { if (deviceSrgv1.getCurrFloor().toString().equals(mydoJob1.getTheFloor())) {
deviceSrgv = deviceSrgv1; deviceSrgv = deviceSrgv1;
break; // 找到了相同楼层的直接选它 break; // 找到了相同楼层的直接选它
} else if (deviceSrgv == null || deviceSrgv1.getCurrFloor() < deviceSrgv.getCurrFloor()) { } else {
WcsSrgvQueue wcsSrgvQueue2 = wcsSagvQueueMapper.selectWcsSrgvQueueByAgvId(deviceSrgv1.getDeviceId().toString()); WcsSrgvQueue wcsSrgvQueue2 = wcsSagvQueueMapper.selectWcsSrgvQueueByAgvId(deviceSrgv1.getDeviceId().toString());
if (deviceSrgv1.getStatus() == 1 && wcsSrgvQueue2 == null) { if (deviceSrgv1.getStatus() == 1 && wcsSrgvQueue2 == null) {
deviceSrgv = deviceSrgv1; // 更新为更小楼层的小车 deviceSrgv = deviceSrgv1; // 更新为更小楼层的小车
break;
} }
} }
} }
@@ -370,6 +372,10 @@ public class BaseSRgvThread implements Runnable, SRgvThreadInterface {
String executionStatus = "1"; String executionStatus = "1";
WcsSrgvMap wcsSrgvMap = new WcsSrgvMap(); WcsSrgvMap wcsSrgvMap = new WcsSrgvMap();
wcsSrgvMap.setRemark(mydoJob1.getEntranceId()); wcsSrgvMap.setRemark(mydoJob1.getEntranceId());
if (StrUtil.isEmpty(wcsSrgvMap.getRemark())) {
log.error("入库任务号:{} 入库入口ID为空" , mydoJob1.getTaskNo());
return;
}
List<WcsSrgvMap> wcsSrgvMaps = wcsSrgvMapService.selectWcsSrgvMapList(wcsSrgvMap); List<WcsSrgvMap> wcsSrgvMaps = wcsSrgvMapService.selectWcsSrgvMapList(wcsSrgvMap);
//取货地址 //取货地址
String cargoPickSite = wcsSrgvMaps.get(0).getSiteId(); String cargoPickSite = wcsSrgvMaps.get(0).getSiteId();
@@ -423,6 +429,7 @@ public class BaseSRgvThread implements Runnable, SRgvThreadInterface {
wcsSrgvQueue3.setDefault02("4"); wcsSrgvQueue3.setDefault02("4");
wcsSrgvQueue3.setDefault07(sameSiteDevices.get(0).getCurrFloor().toString()); wcsSrgvQueue3.setDefault07(sameSiteDevices.get(0).getCurrFloor().toString());
wcsSagvQueueMapper.insertWcsSrgvQueue(wcsSrgvQueue3); wcsSagvQueueMapper.insertWcsSrgvQueue(wcsSrgvQueue3);
return;
} }
} }

View File

@@ -160,6 +160,7 @@ public class TsjThread implements Runnable {
} }
if (StrUtil.isNotEmpty(startSite) && StrUtil.isNotEmpty(endSite)){ if (StrUtil.isNotEmpty(startSite) && StrUtil.isNotEmpty(endSite)){
wcsSrgvQueue.setStartSite(startSite); wcsSrgvQueue.setStartSite(startSite);
wcsSrgvQueue.setEndSite(endSite); wcsSrgvQueue.setEndSite(endSite);
wcsSrgvQueueService.updateWcsSrgvQueue(wcsSrgvQueue); wcsSrgvQueueService.updateWcsSrgvQueue(wcsSrgvQueue);

View File

@@ -100,11 +100,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="updateDeviceCdz" parameterType="DeviceCdz"> <update id="updateDeviceCdz" parameterType="DeviceCdz">
update device_cdz update device_cdz
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
<if test="name != null">name = #{name},</if>
<if test="ip != null">ip = #{ip},</if>
<if test="port != null">port = #{port},</if>
<if test="plcDbReadAddress != null">plc_db_read_address = #{plcDbReadAddress},</if>
<if test="plcDbWriteAddress != null">plc_db_write_address = #{plcDbWriteAddress},</if>
<if test="rwh != null">rwh = #{rwh},</if> <if test="rwh != null">rwh = #{rwh},</if>
<if test="status != null">status = #{status},</if> <if test="status != null">status = #{status},</if>
<if test="xtxh != null">xtxh = #{xtxh},</if> <if test="xtxh != null">xtxh = #{xtxh},</if>

View File

@@ -3,7 +3,7 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.device.srgv.mapper.DeviceSrgvMapper"> <mapper namespace="com.ruoyi.device.srgv.mapper.DeviceSrgvMapper">
<resultMap type="DeviceSrgv" id="DeviceSrgvResult"> <resultMap type="DeviceSrgv" id="DeviceSrgvResult">
<result property="guid" column="guid" /> <result property="guid" column="guid" />
<result property="deviceId" column="device_id" /> <result property="deviceId" column="device_id" />
@@ -50,7 +50,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectDeviceSrgvList" parameterType="DeviceSrgv" resultMap="DeviceSrgvResult"> <select id="selectDeviceSrgvList" parameterType="DeviceSrgv" resultMap="DeviceSrgvResult">
<include refid="selectDeviceSrgvVo"/> <include refid="selectDeviceSrgvVo"/>
<where> <where>
<if test="deviceId != null "> and device_id = #{deviceId}</if> <if test="deviceId != null "> and device_id = #{deviceId}</if>
<if test="deviceName != null and deviceName != ''"> and device_name like concat('%', #{deviceName}, '%')</if> <if test="deviceName != null and deviceName != ''"> and device_name like concat('%', #{deviceName}, '%')</if>
<if test="ip != null and ip != ''"> and ip = #{ip}</if> <if test="ip != null and ip != ''"> and ip = #{ip}</if>
@@ -89,7 +89,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="spare5 != null and spare5 != ''"> and spare5 = #{spare5}</if> <if test="spare5 != null and spare5 != ''"> and spare5 = #{spare5}</if>
</where> </where>
</select> </select>
<select id="selectDeviceSrgvByGuid" parameterType="String" resultMap="DeviceSrgvResult"> <select id="selectDeviceSrgvByGuid" parameterType="String" resultMap="DeviceSrgvResult">
<include refid="selectDeviceSrgvVo"/> <include refid="selectDeviceSrgvVo"/>
where guid = #{guid} where guid = #{guid}
@@ -180,11 +180,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="updateDeviceSrgv" parameterType="DeviceSrgv"> <update id="updateDeviceSrgv" parameterType="DeviceSrgv">
update device_srgv update device_srgv
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
<if test="deviceId != null">device_id = #{deviceId},</if>
<if test="deviceName != null">device_name = #{deviceName},</if>
<if test="ip != null">ip = #{ip},</if>
<if test="port != null">port = #{port},</if>
<if test="type != null">type = #{type},</if>
<if test="setFloor != null">set_floor = #{setFloor},</if> <if test="setFloor != null">set_floor = #{setFloor},</if>
<if test="powerTime != null">power_time = #{powerTime},</if> <if test="powerTime != null">power_time = #{powerTime},</if>
<if test="lastTime != null">last_time = #{lastTime},</if> <if test="lastTime != null">last_time = #{lastTime},</if>
@@ -225,9 +220,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete> </delete>
<delete id="deleteDeviceSrgvByGuids" parameterType="String"> <delete id="deleteDeviceSrgvByGuids" parameterType="String">
delete from device_srgv where guid in delete from device_srgv where guid in
<foreach item="guid" collection="array" open="(" separator="," close=")"> <foreach item="guid" collection="array" open="(" separator="," close=")">
#{guid} #{guid}
</foreach> </foreach>
</delete> </delete>
</mapper> </mapper>

View File

@@ -3,7 +3,7 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.device.tsj.mapper.DeviceTsjMapper"> <mapper namespace="com.ruoyi.device.tsj.mapper.DeviceTsjMapper">
<resultMap type="DeviceTsj" id="DeviceTsjResult"> <resultMap type="DeviceTsj" id="DeviceTsjResult">
<result property="id" column="id" /> <result property="id" column="id" />
<result property="name" column="name" /> <result property="name" column="name" />
@@ -36,7 +36,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectDeviceTsjList" parameterType="DeviceTsj" resultMap="DeviceTsjResult"> <select id="selectDeviceTsjList" parameterType="DeviceTsj" resultMap="DeviceTsjResult">
<include refid="selectDeviceTsjVo"/> <include refid="selectDeviceTsjVo"/>
<where> <where>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if> <if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="ip != null and ip != ''"> and ip = #{ip}</if> <if test="ip != null and ip != ''"> and ip = #{ip}</if>
<if test="port != null and port != ''"> and port = #{port}</if> <if test="port != null and port != ''"> and port = #{port}</if>
@@ -61,7 +61,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="spare3 != null "> and spare3 = #{spare3}</if> <if test="spare3 != null "> and spare3 = #{spare3}</if>
</where> </where>
</select> </select>
<select id="selectDeviceTsjById" parameterType="Long" resultMap="DeviceTsjResult"> <select id="selectDeviceTsjById" parameterType="Long" resultMap="DeviceTsjResult">
<include refid="selectDeviceTsjVo"/> <include refid="selectDeviceTsjVo"/>
where id = #{id} where id = #{id}
@@ -124,11 +124,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="updateDeviceTsj" parameterType="DeviceTsj"> <update id="updateDeviceTsj" parameterType="DeviceTsj">
update device_tsj update device_tsj
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
<if test="name != null">name = #{name},</if>
<if test="ip != null">ip = #{ip},</if>
<if test="port != null">port = #{port},</if>
<if test="plcDbReadAddress != null">plc_db_read_address = #{plcDbReadAddress},</if>
<if test="plcDbWriteAddress != null">plc_db_write_address = #{plcDbWriteAddress},</if>
<if test="rwh != null">rwh = #{rwh},</if> <if test="rwh != null">rwh = #{rwh},</if>
<if test="jdbz != null">jdbz = #{jdbz},</if> <if test="jdbz != null">jdbz = #{jdbz},</if>
<if test="sbzt != null">sbzt = #{sbzt},</if> <if test="sbzt != null">sbzt = #{sbzt},</if>
@@ -155,9 +150,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete> </delete>
<delete id="deleteDeviceTsjByIds" parameterType="String"> <delete id="deleteDeviceTsjByIds" parameterType="String">
delete from device_tsj where id in delete from device_tsj where id in
<foreach item="id" collection="array" open="(" separator="," close=")"> <foreach item="id" collection="array" open="(" separator="," close=")">
#{id} #{id}
</foreach> </foreach>
</delete> </delete>
</mapper> </mapper>