修改 ssj tsj srgv cdz的读取调度,监控调度
This commit is contained in:
@@ -2,15 +2,21 @@ package com.ruoyi.schedule;
|
||||
|
||||
import com.ruoyi.common.domain.CustomThread;
|
||||
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.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.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.srgv.PlcSrgvRead;
|
||||
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.ddj.impl.Ddj1Thread;
|
||||
import com.ruoyi.schedule.scheduleTask.monit.MonitoringThread;
|
||||
@@ -31,25 +37,27 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
public class ScheduleThread {
|
||||
|
||||
public CustomThread<PlcSsjRead> plcSsjReadCustomThread;
|
||||
public CustomThread<PlcTsjRead> plcTsjReadCustomThread;
|
||||
public CustomThread<PlcCdzRead> plcCdzReadCustomThread;
|
||||
public CustomThread<PlcSrgvRead> plcSrgvReadCustomThread1;
|
||||
public CustomThread<PlcSrgvRead> plcSrgvReadCustomThread2;
|
||||
public CustomThread<PlcSrgvRead> plcSrgvReadCustomThread3;
|
||||
|
||||
|
||||
public CustomThread<MonitoringThread> monitoringCustomThread;
|
||||
public CustomThread<SsjThread> ssjThreadCustomThread;
|
||||
public CustomThread<SRgv1Thread> sRgvThreadCustomThread;
|
||||
public CustomThread<TsjThread> tsjThreadCustomThread;
|
||||
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
|
||||
private IDeviceSsjService deviceSsjService;
|
||||
@Autowired
|
||||
private IDeviceSrgvService deviceSrgvService;
|
||||
@Autowired
|
||||
private IDeviceTsjService deviceTsjService;
|
||||
@Autowired
|
||||
private IDeviceCdzService deviceCdzService;
|
||||
|
||||
private boolean isRun = false;
|
||||
private boolean isRun2 = false;
|
||||
@@ -111,6 +119,7 @@ public class ScheduleThread {
|
||||
Thread plcSsjReadThread = new Thread(plcSsjRead);
|
||||
plcSsjReadCustomThread = new CustomThread<PlcSsjRead>(plcSsjReadThread, plcSsjRead);
|
||||
|
||||
//四向车读取线程
|
||||
ConcurrentHashMap<String, DeviceSrgv> srgvList = new ConcurrentHashMap<>();
|
||||
List<DeviceSrgv> srgvs=deviceSrgvService.selectDeviceSrgvList(new DeviceSrgv());
|
||||
for(DeviceSrgv srgv:srgvs){
|
||||
@@ -136,6 +145,25 @@ public class ScheduleThread {
|
||||
}
|
||||
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() {
|
||||
plcSsjReadCustomThread.getThread().start();
|
||||
plcSrgvReadCustomThread1.getThread().start();
|
||||
//plcSrgvReadCustomThread2.getThread().start();
|
||||
//plcSrgvReadCustomThread3.getThread().start();
|
||||
plcSrgvReadCustomThread2.getThread().start();
|
||||
plcSrgvReadCustomThread3.getThread().start();
|
||||
plcTsjReadCustomThread.getThread().start();
|
||||
plcCdzReadCustomThread.getThread().start();
|
||||
|
||||
|
||||
isRun = true;
|
||||
@@ -157,16 +187,11 @@ public class ScheduleThread {
|
||||
*/
|
||||
public void startAllThread2() {
|
||||
monitoringCustomThread.thread.start();
|
||||
ssjThreadCustomThread.thread.start();
|
||||
//ssjThreadCustomThread.thread.start();
|
||||
//tsjThreadCustomThread.thread.start();
|
||||
sRgvThreadCustomThread.thread.start();
|
||||
//sRgvThreadCustomThread.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;
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ public class PlcCdzRead implements Runnable {
|
||||
}
|
||||
|
||||
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";
|
||||
if (read2.IsSuccess) {
|
||||
ddsx1 = SoftBasic.ByteToHexString(read2.Content);
|
||||
|
||||
@@ -7,27 +7,22 @@ import HslCommunication.Core.Types.OperateResult;
|
||||
import HslCommunication.Core.Types.OperateResultExOne;
|
||||
import HslCommunication.ModBus.ModbusTcpNet;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import com.ruoyi.common.domain.HslRead;
|
||||
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.service.IDeviceSrgvService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@Slf4j
|
||||
public class PlcSrgvRead implements Runnable {
|
||||
|
||||
public static ConcurrentHashMap<String, DeviceSrgv> deviceSrgvMap;
|
||||
private static ModbusTcpNet modbusTcpNet;
|
||||
public static IReadWriteNet readWriteNet = null;
|
||||
private ModbusTcpNet modbusTcpNet;
|
||||
public IReadWriteNet readWriteNet = null;
|
||||
public volatile boolean isRun = true;
|
||||
private final String ip;
|
||||
private final int port;
|
||||
private byte station;
|
||||
private Integer layer;
|
||||
private DeviceSrgv deviceSrgv;
|
||||
private boolean success = false;
|
||||
private IByteTransform byteTransform = null;
|
||||
@@ -41,15 +36,16 @@ public class PlcSrgvRead implements Runnable {
|
||||
|
||||
public static boolean Write(String address, int[] value){
|
||||
|
||||
OperateResult write = modbusTcpNet.Write(address, value);
|
||||
return write.IsSuccess;
|
||||
//OperateResult write = modbusTcpNet.Write(address, value);
|
||||
return true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static boolean Write(String address, short[] value){
|
||||
|
||||
OperateResult write = modbusTcpNet.Write(address, value);
|
||||
return write.IsSuccess;
|
||||
//OperateResult write = modbusTcpNet.Write(address, value);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
@@ -58,24 +54,13 @@ public class PlcSrgvRead implements Runnable {
|
||||
public void run() {
|
||||
while (isRun) {
|
||||
try {
|
||||
/*if (IsConnect()) {
|
||||
|
||||
*//*if (deviceSrgv != null) {
|
||||
//readSrgvPlc(deviceSrgv);
|
||||
|
||||
}*//*
|
||||
|
||||
if (IsConnect()) {
|
||||
if (deviceSrgv != null) {
|
||||
readSrgvPlc(deviceSrgv);
|
||||
}
|
||||
} else {
|
||||
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);
|
||||
} catch (InterruptedException e) {
|
||||
// 捕获中断异常,退出循环
|
||||
@@ -89,20 +74,16 @@ public class PlcSrgvRead implements Runnable {
|
||||
}
|
||||
|
||||
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) {
|
||||
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) {
|
||||
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.setAlarm(Convert.toInt(byteTransform.TransInt16(content, 6)));
|
||||
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.setWorkPhase(Convert.toInt(byteTransform.TransInt16(content, 14)));
|
||||
agvData.setErrMsg(Convert.toInt(byteTransform.TransInt16(content, 16)));
|
||||
agvData.setSsjRequest(Convert.toInt(byteTransform.TransInt16(content, 18)));
|
||||
agvData.setChangeLayer(Convert.toInt(byteTransform.TransInt16(content, 20)));
|
||||
agvData.setCargoFlag(Convert.toInt(byteTransform.TransInt16(content, 22)));
|
||||
agvData.setManualCharge(Convert.toInt(byteTransform.TransInt16(content, 24)));
|
||||
agvData.setSpare1(Convert.toStr(byteTransform.TransInt16(content, 0)));
|
||||
agvData.setAllowSend(Convert.toInt(byteTransform.TransInt16(content, 16)));
|
||||
|
||||
//接收完成标志
|
||||
// agvData.setFinish(Convert.toInt(byteTransform.TransInt16(content, 10)));
|
||||
agvData.setFinish(Convert.toInt(byteTransform.TransInt16(content, 12)));
|
||||
agvData.setChargeFlag(Convert.toInt(byteTransform.TransInt16(content, 14)));
|
||||
agvData.setWorkPhase(Convert.toInt(byteTransform.TransInt16(content, 16)));
|
||||
agvData.setAllowSend(Convert.toInt(byteTransform.TransInt16(content, 18)));
|
||||
agvData.setSsjRequest(Convert.toInt(byteTransform.TransInt16(content, 20)));
|
||||
agvData.setSpare2(String.valueOf(Convert.toInt(byteTransform.TransInt16(content, 22))));
|
||||
agvData.setChangeLayer(Convert.toInt(byteTransform.TransInt16(content, 24)));//换层标志
|
||||
|
||||
}
|
||||
|
||||
@@ -130,44 +109,21 @@ public class PlcSrgvRead implements Runnable {
|
||||
byteTransform.setDataFormat(DataFormat.CDAB);
|
||||
// TODO 注意双字反转
|
||||
agvData.setTaskNo(byteTransform.TransInt32(content, 0));
|
||||
//log.info("=====小车{}读取到SRGV任务号:{}=======",agvData.getDeviceId(), agvData.getTaskNo());
|
||||
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)));
|
||||
//log.info("=====小车{}读取到SRGV目标站点:{}=======",agvData.getDeviceId(), agvData.getTarSite());
|
||||
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的后俩位,获取当前楼层
|
||||
int floor = FloorUtils.extractFloor(Integer.parseInt(agvData.getCurrSite()));
|
||||
this.layer = floor;
|
||||
int floor = FloorUtils.extractFloor(Integer.parseInt(String.format("%06d", byteTransform.TransInt32(content, 12))));
|
||||
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() {
|
||||
ModbusTcpNet modbusTcpNet = new ModbusTcpNet();//创建一个Modbus对象
|
||||
modbusTcpNet = new ModbusTcpNet();//创建一个Modbus对象
|
||||
try {
|
||||
modbusTcpNet.setIpAddress(this.ip);
|
||||
modbusTcpNet.setPort(this.port);
|
||||
@@ -199,7 +155,7 @@ public class PlcSrgvRead implements Runnable {
|
||||
void reConnect() {
|
||||
closeServer();
|
||||
ConnectServer();
|
||||
log.info("重新连接 SSJ-PLC");
|
||||
log.info("重新连接 四象车-PLC");
|
||||
}
|
||||
|
||||
void closeServer() {
|
||||
|
||||
@@ -52,14 +52,12 @@ public class PlcSsjRead implements Runnable {
|
||||
while (isRun) {
|
||||
try {
|
||||
//todo 要读重量
|
||||
/*if (IsConnect()) {
|
||||
int step = 20;
|
||||
int baseOffset = 0;
|
||||
*//*for (String ssjCode : deviceSsjMap.keySet()) {
|
||||
if (IsConnect()) {
|
||||
for (String ssjCode : deviceSsjMap.keySet()) {
|
||||
DeviceSsj ssjDevice = deviceSsjMap.get(ssjCode);
|
||||
switch (ssjDevice.getType()) {
|
||||
case "1":
|
||||
readPlcLineSsj(ssjDevice);
|
||||
readPlcRoadWaySsj(ssjDevice);
|
||||
break;
|
||||
case "2":
|
||||
readPlcInOutSsj(ssjDevice);
|
||||
@@ -68,18 +66,11 @@ public class PlcSsjRead implements Runnable {
|
||||
readPlcOtherSsj(ssjDevice);
|
||||
break;
|
||||
}
|
||||
}*//*
|
||||
}
|
||||
|
||||
} else {
|
||||
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);
|
||||
} catch (InterruptedException e) {
|
||||
// 捕获中断异常,退出循环
|
||||
@@ -140,7 +131,6 @@ public class PlcSsjRead implements Runnable {
|
||||
ssjDevice.setException(ParseUtil.optInt(4, ddsx1));
|
||||
ssjDevice.setAllowPut(ParseUtil.optInt(6, ddsx1));
|
||||
ssjDevice.setTaskNo(ParseUtil.optDInt(8, ddsx1));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ public class PlcTsjRead implements Runnable {
|
||||
}
|
||||
|
||||
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";
|
||||
if (read2.IsSuccess) {
|
||||
ddsx1 = SoftBasic.ByteToHexString(read2.Content);
|
||||
@@ -122,7 +122,7 @@ public class PlcTsjRead implements Runnable {
|
||||
void reConnect() {
|
||||
closeServer();
|
||||
ConnectServer();
|
||||
log.info("重新连接 SSJ-PLC");
|
||||
log.info("重新连接 TSJ-PLC");
|
||||
}
|
||||
|
||||
void closeServer() {
|
||||
|
||||
@@ -48,7 +48,7 @@ public class CdzThread implements Runnable {
|
||||
init();
|
||||
while (isRun) {
|
||||
try {
|
||||
dispatch();
|
||||
dispatch();
|
||||
Thread.sleep(1500);
|
||||
}catch (Exception e){
|
||||
log.error(e.getMessage(),e);
|
||||
|
||||
@@ -1,11 +1,20 @@
|
||||
package com.ruoyi.schedule.scheduleTask.monit;
|
||||
|
||||
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.srgv.domain.DeviceSrgv;
|
||||
import com.ruoyi.device.srgv.service.IDeviceSrgvService;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
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.srgv.PlcSrgvRead;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcSsjRead;
|
||||
import com.ruoyi.schedule.plcRead.tsj.PlcTsjRead;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
@@ -18,24 +27,39 @@ public class MonitoringThread implements Runnable {
|
||||
|
||||
private IDeviceSsjService deviceSsjService;
|
||||
private IMsgDdjService msgDdjService;
|
||||
private IDeviceSrgvService deviceSrgvService;
|
||||
private IDeviceTsjService deviceTsjService;
|
||||
private IDeviceCdzService deviceCdzService;
|
||||
|
||||
|
||||
public void init() {
|
||||
deviceSsjService = SpringUtils.getBean(IDeviceSsjService.class);
|
||||
msgDdjService = SpringUtils.getBean(IMsgDdjService.class);
|
||||
deviceSrgvService = SpringUtils.getBean(IDeviceSrgvService.class);
|
||||
deviceTsjService = SpringUtils.getBean(IDeviceTsjService.class);
|
||||
deviceCdzService = SpringUtils.getBean(IDeviceCdzService.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
init();
|
||||
while (isRun){
|
||||
//输送机监控
|
||||
for (String ssjCode : PlcSsjRead.deviceSsjMap.keySet()) {
|
||||
DeviceSsj deviceSsj = PlcSsjRead.deviceSsjMap.get(ssjCode);
|
||||
deviceSsj.setTraySize(deviceSsj.getModel());
|
||||
deviceSsjService.updateDeviceSsj(deviceSsj);
|
||||
}
|
||||
for (String ddjCode : PlcDdjRead.deviceDdjMap.keySet()) {
|
||||
msgDdjService.updateMsgDdj(PlcDdjRead.deviceDdjMap.get(ddjCode));
|
||||
for (String srgvCode : PlcSrgvRead.deviceSrgvMap.keySet()) {
|
||||
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 {
|
||||
Thread.sleep(1500);
|
||||
|
||||
@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.ruoyi.bas.port.service.IWcsPortService;
|
||||
import com.ruoyi.bas.srgvmap.domain.WcsSrgvMap;
|
||||
import com.ruoyi.bas.srgvmap.service.IWcsSrgvMapService;
|
||||
@@ -351,10 +352,11 @@ public class BaseSRgvThread implements Runnable, SRgvThreadInterface {
|
||||
if (deviceSrgv1.getCurrFloor().toString().equals(mydoJob1.getTheFloor())) {
|
||||
deviceSrgv = deviceSrgv1;
|
||||
break; // 找到了相同楼层的直接选它
|
||||
} else if (deviceSrgv == null || deviceSrgv1.getCurrFloor() < deviceSrgv.getCurrFloor()) {
|
||||
} else {
|
||||
WcsSrgvQueue wcsSrgvQueue2 = wcsSagvQueueMapper.selectWcsSrgvQueueByAgvId(deviceSrgv1.getDeviceId().toString());
|
||||
if (deviceSrgv1.getStatus() == 1 && wcsSrgvQueue2 == null) {
|
||||
deviceSrgv = deviceSrgv1; // 更新为更小楼层的小车
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -370,6 +372,10 @@ public class BaseSRgvThread implements Runnable, SRgvThreadInterface {
|
||||
String executionStatus = "1";
|
||||
WcsSrgvMap wcsSrgvMap = new WcsSrgvMap();
|
||||
wcsSrgvMap.setRemark(mydoJob1.getEntranceId());
|
||||
if (StrUtil.isEmpty(wcsSrgvMap.getRemark())) {
|
||||
log.error("入库任务号:{} 入库入口ID为空" , mydoJob1.getTaskNo());
|
||||
return;
|
||||
}
|
||||
List<WcsSrgvMap> wcsSrgvMaps = wcsSrgvMapService.selectWcsSrgvMapList(wcsSrgvMap);
|
||||
//取货地址
|
||||
String cargoPickSite = wcsSrgvMaps.get(0).getSiteId();
|
||||
@@ -423,6 +429,7 @@ public class BaseSRgvThread implements Runnable, SRgvThreadInterface {
|
||||
wcsSrgvQueue3.setDefault02("4");
|
||||
wcsSrgvQueue3.setDefault07(sameSiteDevices.get(0).getCurrFloor().toString());
|
||||
wcsSagvQueueMapper.insertWcsSrgvQueue(wcsSrgvQueue3);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -160,6 +160,7 @@ public class TsjThread implements Runnable {
|
||||
}
|
||||
|
||||
if (StrUtil.isNotEmpty(startSite) && StrUtil.isNotEmpty(endSite)){
|
||||
|
||||
wcsSrgvQueue.setStartSite(startSite);
|
||||
wcsSrgvQueue.setEndSite(endSite);
|
||||
wcsSrgvQueueService.updateWcsSrgvQueue(wcsSrgvQueue);
|
||||
|
||||
@@ -100,11 +100,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<update id="updateDeviceCdz" parameterType="DeviceCdz">
|
||||
update device_cdz
|
||||
<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="status != null">status = #{status},</if>
|
||||
<if test="xtxh != null">xtxh = #{xtxh},</if>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.device.srgv.mapper.DeviceSrgvMapper">
|
||||
|
||||
|
||||
<resultMap type="DeviceSrgv" id="DeviceSrgvResult">
|
||||
<result property="guid" column="guid" />
|
||||
<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">
|
||||
<include refid="selectDeviceSrgvVo"/>
|
||||
<where>
|
||||
<where>
|
||||
<if test="deviceId != null "> and device_id = #{deviceId}</if>
|
||||
<if test="deviceName != null and deviceName != ''"> and device_name like concat('%', #{deviceName}, '%')</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>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectDeviceSrgvByGuid" parameterType="String" resultMap="DeviceSrgvResult">
|
||||
<include refid="selectDeviceSrgvVo"/>
|
||||
where guid = #{guid}
|
||||
@@ -180,11 +180,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<update id="updateDeviceSrgv" parameterType="DeviceSrgv">
|
||||
update device_srgv
|
||||
<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="powerTime != null">power_time = #{powerTime},</if>
|
||||
<if test="lastTime != null">last_time = #{lastTime},</if>
|
||||
@@ -225,9 +220,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</delete>
|
||||
|
||||
<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=")">
|
||||
#{guid}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
</mapper>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.device.tsj.mapper.DeviceTsjMapper">
|
||||
|
||||
|
||||
<resultMap type="DeviceTsj" id="DeviceTsjResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="name" column="name" />
|
||||
@@ -36,7 +36,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
|
||||
<select id="selectDeviceTsjList" parameterType="DeviceTsj" resultMap="DeviceTsjResult">
|
||||
<include refid="selectDeviceTsjVo"/>
|
||||
<where>
|
||||
<where>
|
||||
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
|
||||
<if test="ip != null and ip != ''"> and ip = #{ip}</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>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectDeviceTsjById" parameterType="Long" resultMap="DeviceTsjResult">
|
||||
<include refid="selectDeviceTsjVo"/>
|
||||
where id = #{id}
|
||||
@@ -124,11 +124,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<update id="updateDeviceTsj" parameterType="DeviceTsj">
|
||||
update device_tsj
|
||||
<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="jdbz != null">jdbz = #{jdbz},</if>
|
||||
<if test="sbzt != null">sbzt = #{sbzt},</if>
|
||||
@@ -155,9 +150,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</delete>
|
||||
|
||||
<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=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user