This commit is contained in:
zj
2025-12-25 14:46:44 +08:00
parent 885fab377d
commit 88d01609d8
18 changed files with 363 additions and 120 deletions

View File

@@ -3,7 +3,7 @@ package com.ruoyi.common;
public class Constant {
public static final String WMS_BASE_URL = "http://localhost:8080/api2wms/";
public static final String WMS_BASE_URL = "http://localhost:8082/api2wms/";
public static final String RCS_BASE_URL = "http://127.0.0.1:8081/rcms-dps/rest/";

View File

@@ -83,6 +83,6 @@ public class DeviceSsj extends BaseEntity
@Excel(name="允许放货")
private int allowPut;
private int sszt;
}

View File

@@ -6,7 +6,8 @@ import com.ruoyi.device.ddj.service.IMsgDdjService;
import com.ruoyi.device.ssj.domain.DeviceSsj;
import com.ruoyi.device.ssj.service.IDeviceSsjService;
import com.ruoyi.common.domain.PlcConnectInfo;
import com.ruoyi.schedule.plcRead.ddj.PlcDdjRead;
import com.ruoyi.schedule.plcRead.ddj.PlcDdj1Read;
import com.ruoyi.schedule.plcRead.ddj.PlcDdj2Read;
import com.ruoyi.schedule.plcRead.ssj.PlcSsjRead;
import com.ruoyi.common.domain.CustomThread;
import com.ruoyi.schedule.scheduleTask.ddj.Ddj1Thread;
@@ -31,8 +32,8 @@ import java.util.concurrent.ConcurrentHashMap;
public class ScheduleThread {
public CustomThread<PlcSsjRead> plcSsjReadCustomThread;
public CustomThread<PlcDdjRead> plcDdj1ReadCustomThread;
public CustomThread<PlcDdjRead> plcDdj2ReadCustomThread;
public CustomThread<PlcDdj1Read> plcDdj1ReadCustomThread;
public CustomThread<PlcDdj2Read> plcDdj2ReadCustomThread;
public CustomThread<Floor1BothWayInSsjThread> floor1BothWayInSsjCustomThread;
public CustomThread<Floor1BothWayOutSsjThread> floor1BothWayOutSsjCustomThread;
@@ -108,24 +109,28 @@ public class ScheduleThread {
PlcSsjRead.deviceSsjMap = ssjList;
//获取堆垛机
ConcurrentHashMap<String, MsgDdj> ddjList = new ConcurrentHashMap<>();
ConcurrentHashMap<String, MsgDdj> ddj1List = new ConcurrentHashMap<>();
ConcurrentHashMap<String, MsgDdj> ddj2List = new ConcurrentHashMap<>();
List<MsgDdj> msgDdjs = msgDdjService.selectMsgDdjList(new MsgDdj());
for (MsgDdj msgDdj : msgDdjs) {
msgDdj.setPlcDbReadAddress(msgDdj.getPlcDbReadAddress());
PlcDdjRead plcDdjRead = new PlcDdjRead(msgDdj, new PlcConnectInfo(msgDdj.getIp(), Convert.toInt(msgDdj.getPort())));
Thread plcDdjReadThread = new Thread(plcDdjRead);
switch (msgDdj.getId()){
case 1:
plcDdj1ReadCustomThread = new CustomThread<PlcDdjRead>(plcDdjReadThread, plcDdjRead);
PlcDdj1Read plcDdj1Read = new PlcDdj1Read(msgDdj, new PlcConnectInfo(msgDdj.getIp(), Convert.toInt(msgDdj.getPort())));
Thread plcDdj1ReadThread = new Thread(plcDdj1Read);
plcDdj1ReadCustomThread = new CustomThread<PlcDdj1Read>(plcDdj1ReadThread, plcDdj1Read);
ddj1List.put("ddj1", msgDdj);
PlcDdj1Read.deviceDdjMap = ddj1List;
break;
case 2:
plcDdj2ReadCustomThread = new CustomThread<PlcDdjRead>(plcDdjReadThread, plcDdjRead);
PlcDdj2Read plcDdj2Read = new PlcDdj2Read(msgDdj, new PlcConnectInfo(msgDdj.getIp(), Convert.toInt(msgDdj.getPort())));
Thread plcDdj2ReadThread = new Thread(plcDdj2Read);
plcDdj2ReadCustomThread = new CustomThread<PlcDdj2Read>(plcDdj2ReadThread, plcDdj2Read);
ddj2List.put("ddj2", msgDdj);
PlcDdj2Read.deviceDdjMap = ddj2List;
break;
}
ddjList.put("ddj" + msgDdj.getId(), msgDdj);
}
PlcDdjRead.deviceDdjMap = ddjList;
}
/**
@@ -143,9 +148,9 @@ public class ScheduleThread {
*/
public void startAllThread2() {
monitoringCustomThread.thread.start();
floor1BothWayInSsjCustomThread.thread.start();
floor1BothWayOutSsjCustomThread.thread.start();
floor1SingleSsjCustomThread.thread.start();
// floor1BothWayInSsjCustomThread.thread.start();
// floor1BothWayOutSsjCustomThread.thread.start();
// floor1SingleSsjCustomThread.thread.start();
floor2InSsjCustomThread.thread.start();
lineSsjCustomThread.thread.start();
floor2OutSsjCustomThread.thread.start();

View File

@@ -10,14 +10,13 @@ import cn.hutool.core.convert.Convert;
import com.ruoyi.common.domain.HslRead;
import com.ruoyi.common.domain.PlcConnectInfo;
import com.ruoyi.device.ddj.domain.MsgDdj;
import com.ruoyi.device.ssj.domain.DeviceSsj;
import com.ruoyi.schedule.plcRead.util.ParseUtil;
import lombok.extern.slf4j.Slf4j;
import java.util.concurrent.ConcurrentHashMap;
@Slf4j
public class PlcDdjRead extends Thread {
public class PlcDdj1Read extends Thread {
public static ConcurrentHashMap<String, MsgDdj> deviceDdjMap;
public volatile boolean isRun = true;
@@ -28,20 +27,12 @@ public class PlcDdjRead extends Thread {
private boolean success = false;
private MsgDdj msgDdj;
public PlcDdjRead(MsgDdj msgDdj, PlcConnectInfo plcConnectInfo) {
public PlcDdj1Read(MsgDdj msgDdj, PlcConnectInfo plcConnectInfo) {
this.msgDdj = msgDdj;
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) {
@@ -56,7 +47,7 @@ public class PlcDdjRead extends Thread {
Thread.currentThread().interrupt();
return;
} catch (Exception e) {
log.info("********IP:" + this.ip + " port:" + this.port + "<EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>쳣 " + e.getMessage());
log.info("********IP:" + this.ip + " port:" + this.port + "连接失败" + e.getMessage());
}
}
@@ -119,7 +110,7 @@ public class PlcDdjRead extends Thread {
void reConnect() {
closeServer();
ConnectServer();
log.info("重新连接 SSJ-PLC");
log.info("重新连接 DDJ1-PLC");
}
void closeServer() {
@@ -129,6 +120,8 @@ public class PlcDdjRead extends Thread {
setIsConnect(false);
}
public static int WriteToDDJ(String address, byte[] data) {
int a = 0;
if (readWriteNet != null) {

View File

@@ -0,0 +1,132 @@
package com.ruoyi.schedule.plcRead.ddj;
import HslCommunication.BasicFramework.SoftBasic;
import HslCommunication.Core.Net.IReadWriteNet;
import HslCommunication.Core.Types.OperateResult;
import HslCommunication.Core.Types.OperateResultExOne;
import HslCommunication.Profinet.Siemens.SiemensPLCS;
import HslCommunication.Profinet.Siemens.SiemensS7Net;
import cn.hutool.core.convert.Convert;
import com.ruoyi.common.domain.HslRead;
import com.ruoyi.common.domain.PlcConnectInfo;
import com.ruoyi.device.ddj.domain.MsgDdj;
import com.ruoyi.schedule.plcRead.util.ParseUtil;
import lombok.extern.slf4j.Slf4j;
import java.util.concurrent.ConcurrentHashMap;
@Slf4j
public class PlcDdj2Read extends Thread {
public static ConcurrentHashMap<String, MsgDdj> deviceDdjMap;
public volatile boolean isRun = true;
public SiemensS7Net siemensS7Net = null;
public static IReadWriteNet readWriteNet = null;
private final String ip;
private final int port;
private boolean success = false;
private MsgDdj msgDdj;
public PlcDdj2Read(MsgDdj msgDdj, PlcConnectInfo plcConnectInfo) {
this.msgDdj = msgDdj;
this.ip = plcConnectInfo.getIp();
this.port = plcConnectInfo.getPort();
}
@Override
public void run() {
while (isRun) {
try {
if (IsConnect()) {
readPlcDdj(msgDdj);
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());
}
}
}
private void readPlcDdj(MsgDdj msgDdj) {
OperateResultExOne<byte[]> read2 = readWriteNet.Read(msgDdj.getPlcDbReadAddress(), Convert.toShort("38"));
String ddsx = "0";
if (read2.IsSuccess) {
ddsx = SoftBasic.ByteToHexString(read2.Content);
msgDdj.setCzfs(ParseUtil.optInt(0, ddsx));
msgDdj.setSbzt(ParseUtil.optInt(2, ddsx));
msgDdj.setRwh(Convert.toLong(ParseUtil.optDInt(4, ddsx)));
msgDdj.setHczt(ParseUtil.optInt(8, ddsx));
msgDdj.setJdbz(ParseUtil.optInt(10, ddsx));
msgDdj.setYph(ParseUtil.optInt(12, ddsx));
msgDdj.setYlh(ParseUtil.optInt(14, ddsx));
msgDdj.setYch(ParseUtil.optInt(16, ddsx));
msgDdj.setMbph(ParseUtil.optInt(18, ddsx));
msgDdj.setMblh(ParseUtil.optInt(20, ddsx));
msgDdj.setMbch(ParseUtil.optInt(22, ddsx));
msgDdj.setYxxf(ParseUtil.optInt(24, ddsx));
msgDdj.setXtxh(ParseUtil.optInt(26, ddsx));
}
}
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("重新连接 DDJ2-PLC");
}
void closeServer() {
if (readWriteNet != null) {
readWriteNet.ConnectClose();
}
setIsConnect(false);
}
public static int WriteToDDJ(String address, byte[] data) {
int a = 0;
if (readWriteNet != null) {
a = HslRead.WriteResultRender(readWriteNet.Write(address, data), address);
}
return a;
}
}

View File

@@ -87,7 +87,7 @@ public class PlcSsjRead implements Runnable {
* @param ssjDevice
*/
private void readPlcOtherSsj(DeviceSsj ssjDevice) {
OperateResultExOne<byte[]> read2 = readWriteNet.Read(ssjDevice.getPlcDbReadAddress(), Short.parseShort("20"));
OperateResultExOne<byte[]> read2 = readWriteNet.Read(ssjDevice.getPlcDbReadAddress(), Short.parseShort("10"));
String ddsx1 = "0";
if (read2.IsSuccess) {
ddsx1 = SoftBasic.ByteToHexString(read2.Content);
@@ -103,14 +103,14 @@ public class PlcSsjRead implements Runnable {
* @param ssjDevice
*/
private void readPlcRoadWaySsj(DeviceSsj ssjDevice) {
OperateResultExOne<byte[]> read2 = readWriteNet.Read(ssjDevice.getPlcDbReadAddress(), Short.parseShort("20"));
OperateResultExOne<byte[]> read2 = readWriteNet.Read(ssjDevice.getPlcDbReadAddress(), Short.parseShort("10"));
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.setDw(ParseUtil.optInt(0, ddsx1));
ssjDevice.setKx(ParseUtil.optInt(2, ddsx1));
ssjDevice.setTaskNo(ParseUtil.optDInt(4, ddsx1));
ssjDevice.setSszt(ParseUtil.optInt(8, ddsx1));
}
}
@@ -120,16 +120,17 @@ public class PlcSsjRead implements Runnable {
* @param ssjDevice
*/
private void readPlcInOutSsj(DeviceSsj ssjDevice) {
OperateResultExOne<byte[]> read2 = readWriteNet.Read(ssjDevice.getPlcDbReadAddress(), Short.parseShort("20"));
OperateResultExOne<byte[]> read2 = readWriteNet.Read(ssjDevice.getPlcDbReadAddress(), Short.parseShort("30"));
String ddsx1 = "0";
if (read2.IsSuccess) {
ddsx1 = SoftBasic.ByteToHexString(read2.Content);
ssjDevice.setKx(ParseUtil.optInt(0, ddsx1));
ssjDevice.setDw(ParseUtil.optInt(2, ddsx1));
ssjDevice.setException(ParseUtil.optInt(4, ddsx1));
ssjDevice.setAllowPut(ParseUtil.optInt(6, ddsx1));
ssjDevice.setTaskNo(ParseUtil.optDInt(8, ddsx1));
ssjDevice.setDw(ParseUtil.optInt(0, ddsx1));
ssjDevice.setKx(ParseUtil.optInt(2, ddsx1));
ssjDevice.setTaskNo(ParseUtil.optDInt(4, ddsx1));
ssjDevice.setSszt(ParseUtil.optInt(8, ddsx1));
ssjDevice.setRkqq(ParseUtil.optInt(10, ddsx1));
ssjDevice.setTraySize(ParseUtil.optInt(12, ddsx1));
ssjDevice.setException(ParseUtil.optInt(28, ddsx1));
}
}
@@ -139,39 +140,56 @@ public class PlcSsjRead implements Runnable {
* @param ssjDevice
*/
private void readPlcSmSsj(DeviceSsj ssjDevice) {
OperateResultExOne<byte[]> read2 = readWriteNet.Read(ssjDevice.getPlcDbReadAddress(), Short.parseShort("220"));
OperateResultExOne<byte[]> read2 = readWriteNet.Read(ssjDevice.getPlcDbReadAddress(), Short.parseShort("30"));
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.setTraySize(ParseUtil.optInt(6, ddsx1));
ssjDevice.setTaskNo(ParseUtil.optDInt(8, ddsx1));
ssjDevice.setDw(ParseUtil.optInt(0, ddsx1));
ssjDevice.setKx(ParseUtil.optInt(2, ddsx1));
ssjDevice.setTaskNo(ParseUtil.optDInt(4, ddsx1));
ssjDevice.setSszt(ParseUtil.optInt(8, ddsx1));
ssjDevice.setRkqq(ParseUtil.optInt(10, ddsx1));
ssjDevice.setTraySize(ParseUtil.optInt(12, ddsx1));
ssjDevice.setException(ParseUtil.optInt(28, ddsx1));
String trayCodeReadAddress="";
String allot="";
switch (ssjDevice.getDeviceCode()){
case "G1005":
trayCodeReadAddress = "DB502.0";
trayCodeReadAddress = "DB5023.0";
allot = "DB802.0";
break;
case "L2004":
trayCodeReadAddress = "DB503.0";
trayCodeReadAddress = "DB503.200";
break;
case "L2006":
trayCodeReadAddress = "DB504.0";
trayCodeReadAddress = "DB503.400";
break;
case "L1001":
trayCodeReadAddress = "DB506.0";
trayCodeReadAddress = "DB503.600";
allot = "DB802.12";
break;
case "L1003":
trayCodeReadAddress = "DB505.0";
trayCodeReadAddress = "DB503.800";
allot = "DB802.24";
break;
}
OperateResultExOne<byte[]> trayCodeRead = readWriteNet.Read(trayCodeReadAddress, Short.parseShort("220"));
if (trayCodeRead.IsSuccess){
byte[] content = trayCodeRead.Content;
//去除bytes中
ssjDevice.setTrayCode(ParseUtil.filterAndConvert(trayCodeRead.Content));
if(!"".equals(allot)){
OperateResultExOne<byte[]> agvSsj = readWriteNet.Read(trayCodeReadAddress, Short.parseShort("12"));
if (agvSsj.IsSuccess){
//去除bytes中
ddsx1 = SoftBasic.ByteToHexString(agvSsj.Content);
ssjDevice.setAllowPut(ParseUtil.optInt(0, ddsx1));
}
}
if(!"".equals(trayCodeReadAddress)){
OperateResultExOne<byte[]> trayCodeRead = readWriteNet.Read(trayCodeReadAddress, Short.parseShort("220"));
if (trayCodeRead.IsSuccess){
byte[] content = trayCodeRead.Content;
//去除bytes中
ssjDevice.setTrayCode(ParseUtil.filterAndConvert(trayCodeRead.Content));
}
}
}
}
@@ -225,8 +243,8 @@ public class PlcSsjRead implements Runnable {
public static int writeToSsj(String address, String taskNo, int qx , int completed) {
int jym = Tools.getJYM(Integer.parseInt(taskNo), qx, completed);
SendData taskNoSendData = new SendData(Tools.INT, taskNo);
int jym = Tools.getJYM(Integer.parseInt(taskNo), qx);
SendData taskNoSendData = new SendData(Tools.DINT, taskNo);
SendData qxSendData = new SendData(Tools.INT, qx);
SendData completedSendData = new SendData(Tools.INT, completed);
SendData jymSendData = new SendData(Tools.INT, jym);

View File

@@ -16,8 +16,8 @@ import com.ruoyi.job.service.IMydoJobService;
import com.ruoyi.queue.ddj.domain.DdjDeviceExecutionQueue;
import com.ruoyi.queue.ddj.service.IDdjDeviceExecutionQueueFinishService;
import com.ruoyi.queue.ddj.service.IDdjDeviceExecutionQueueService;
import com.ruoyi.schedule.plcRead.ddj.PlcDdjRead;
import com.ruoyi.schedule.plcRead.ssj.PlcSsjRead;
import com.ruoyi.schedule.plcRead.ddj.PlcDdj1Read;
import com.ruoyi.schedule.plcRead.ddj.PlcDdj2Read;
import com.ruoyi.schedule.plcRead.util.Tools;
import lombok.extern.slf4j.Slf4j;
@@ -65,10 +65,12 @@ public class Ddj1Thread implements Runnable {
if ("ddj".equals(type)) {
for (String ddjCode : ddjCodeList.get(type)) {
try {
if (PlcDdjRead.deviceDdjMap.containsKey(ddjCode)) {
ddjTask(PlcDdjRead.deviceDdjMap.get(ddjCode));
} else {
log.error("设备不存在 ssjCode{}", ddjCode);
if ("ddj1".equals(ddjCode)) {
ddjTask(PlcDdj1Read.deviceDdjMap.get(ddjCode));
}
//PlcDdj2Read.deviceDdjMap.containsKey(ddjCode)
if ("ddj2".equals(ddjCode)) {
ddjTask(PlcDdj2Read.deviceDdjMap.get(ddjCode));
}
} catch (RuntimeException e) {
log.error(e.getMessage(), e);
@@ -221,7 +223,7 @@ public class Ddj1Thread implements Runnable {
ddjDeviceExecutionQueue.setXfsj(DateUtil.formatDateTime(DateUtil.date()));
ddjDeviceExecutionQueue.setDdjxf("1");
ddjDeviceExecutionQueueService.updateDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
log.info("托盘堆垛机下发任务成功 rwh:{}", rwh);
log.info("托盘堆垛机下发任务成功 rwh:{}", ddjDeviceExecutionQueue.getRwh());
} else {
log.error("托盘堆垛机下发任务失败!!!!!!!");
}
@@ -266,12 +268,13 @@ public class Ddj1Thread implements Runnable {
int mbch = Convert.toInt(queue.getMbch());
int mlfs = 5;
int xfwc = 1;
int jym = Tools.getJYM(taskNo, yph, ylh, ych, mbph, mblh, mbch, mlfs, xfwc);
byte[] sendData = Tools.sendDataToDevice(taskNo, null, yph, ylh, ych, mbph, mblh, mbch, mlfs, xfwc, jym);
int hwlx = Convert.toInt(queue.getSpare1());
int jym = Tools.getJYM(taskNo, yph, ylh, ych, mbph, mblh, mbch, mlfs, hwlx);
byte[] sendData = Tools.sendDataToDevice(taskNo, null, yph, ylh, ych, mbph, mblh, mbch, mlfs, hwlx, xfwc, jym);
if (devId==1){
return PlcDdjRead.WriteToDDJ("DB61.0", sendData);
return PlcDdj1Read.WriteToDDJ("DB61.0", sendData);
}else {
return PlcDdjRead.WriteToDDJ("DB61.0", sendData);
return PlcDdj2Read.WriteToDDJ("DB61.0", sendData);
}
}

View File

@@ -1,10 +1,8 @@
package com.ruoyi.schedule.scheduleTask.monit;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjUtil;
import com.ruoyi.bas.fault.domain.BasFaultRecord;
import com.ruoyi.bas.fault.service.IBasFaultRecordService;
import com.ruoyi.common.utils.spring.SpringUtils;
@@ -12,9 +10,9 @@ import com.ruoyi.device.ddj.domain.MsgDdj;
import com.ruoyi.device.ddj.service.IMsgDdjService;
import com.ruoyi.device.ssj.domain.DeviceSsj;
import com.ruoyi.device.ssj.service.IDeviceSsjService;
import com.ruoyi.job.domain.MydoJob;
import com.ruoyi.job.service.IMydoJobService;
import com.ruoyi.schedule.plcRead.ddj.PlcDdjRead;
import com.ruoyi.schedule.plcRead.ddj.PlcDdj1Read;
import com.ruoyi.schedule.plcRead.ddj.PlcDdj2Read;
import com.ruoyi.schedule.plcRead.ssj.PlcSsjRead;
import lombok.extern.slf4j.Slf4j;
@@ -49,8 +47,48 @@ public class MonitoringThread implements Runnable {
DeviceSsj deviceSsj = PlcSsjRead.deviceSsjMap.get(ssjCode);
deviceSsjService.updateDeviceSsj(deviceSsj);
}
for (String ddjCode : PlcDdjRead.deviceDdjMap.keySet()) {
MsgDdj msgDdj = PlcDdjRead.deviceDdjMap.get(ddjCode);
for (String ddjCode : PlcDdj1Read.deviceDdjMap.keySet()) {
MsgDdj msgDdj = PlcDdj1Read.deviceDdjMap.get(ddjCode);
msgDdjService.updateMsgDdj(msgDdj);
if (msgDdj.getSbzt() > 1000) {
BasFaultRecord param = new BasFaultRecord();
param.setTaskNo(msgDdj.getRwh() + "");
param.setDeviceId(String.valueOf(msgDdj.getId()));
param.setDeviceType("DDJ");
param.setFault(msgDdj.getSbzt() + "");
param.setJobId("0");
List<BasFaultRecord> basFaultRecords = basFaultRecordService.selectBasFaultRecordList(param);
if (CollUtil.isEmpty(basFaultRecords)) {
BasFaultRecord faultRecord = new BasFaultRecord();
faultRecord.setId(IdUtil.fastSimpleUUID());
faultRecord.setDeviceId(String.valueOf(msgDdj.getId()));
faultRecord.setDeviceName(msgDdj.getName());
faultRecord.setDeviceType("DDJ");
faultRecord.setJobId("0");
faultRecord.setTaskNo(msgDdj.getRwh() + "");
faultRecord.setFault(msgDdj.getSbzt() + "");
faultRecord.setStartTime(DateUtil.formatDateTime(DateUtil.date()));
//faultRecord.setWarehouseId(mydoJob.getWarehouseId());
basFaultRecordService.insertBasFaultRecord(faultRecord);
}
}
if (msgDdj.getSbzt() < 1000 && msgDdj.getCzfs() == 5){
BasFaultRecord param = new BasFaultRecord();
param.setDeviceId(String.valueOf(msgDdj.getId()));
param.setDeviceType("DDJ");
param.setJobId("0");
List<BasFaultRecord> basFaultRecords = basFaultRecordService.selectBasFaultRecordList(param);
if (CollUtil.isNotEmpty(basFaultRecords)) {
BasFaultRecord faultRecord = basFaultRecords.get(0);
faultRecord.setJobId("1");
faultRecord.setFinishTime(DateUtil.formatDateTime(DateUtil.date()));
basFaultRecordService.updateBasFaultRecord(faultRecord);
}
}
}
for (String ddjCode : PlcDdj2Read.deviceDdjMap.keySet()) {
MsgDdj msgDdj = PlcDdj2Read.deviceDdjMap.get(ddjCode);
msgDdjService.updateMsgDdj(msgDdj);
if (msgDdj.getSbzt() > 1000) {

View File

@@ -61,8 +61,8 @@ public class Floor1BothWayInSsjThread implements Runnable {
//初始化巷道口 排 列 层
roadwayMap.put("L2003", Arrays.asList(1, 1, 1));
roadwayMap.put("L2005", Arrays.asList(1, 1, 1));
roadwayMap.put("L2003", Arrays.asList(2, 47, 1));
roadwayMap.put("L2005", Arrays.asList(3, 70, 1));
exitRoadwayMap.put("L2003", "L2004");
exitRoadwayMap.put("L2005", "L2006");
@@ -128,6 +128,7 @@ public class Floor1BothWayInSsjThread implements Runnable {
ddjDeviceExecutionQueue.setMbch(Convert.toInt(basCargoSpace.getTheFloor()));
ddjDeviceExecutionQueue.setDdjxf("0");
ddjDeviceExecutionQueue.setMlfs(5);
ddjDeviceExecutionQueue.setSpare1(mydoJob.getTraySize());
ddjDeviceExecutionQueue.setScsj(DateUtil.formatDateTime(DateUtil.date()));
ddjDeviceExecutionQueue.setRwlx(DDJ_RWLX_3);
ddjDeviceExecutionQueueService.insertDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);

View File

@@ -74,8 +74,8 @@ public class Floor1BothWayOutSsjThread implements Runnable {
//初始化巷道口 排 列 层
roadwayMap.put("L2003",Arrays.asList(1,1,1));
roadwayMap.put("L2005",Arrays.asList(1,1,1));
roadwayMap.put("L2003",Arrays.asList(2,47,1));
roadwayMap.put("L2005",Arrays.asList(3,70,1));
}
@Override
@@ -168,6 +168,7 @@ public class Floor1BothWayOutSsjThread implements Runnable {
ddjDeviceExecutionQueue.setMbch(pclList.get(2));
ddjDeviceExecutionQueue.setDdjxf("0");
ddjDeviceExecutionQueue.setMlfs(5);
ddjDeviceExecutionQueue.setSpare1(pdOutJob.getTraySize());
ddjDeviceExecutionQueue.setScsj(DateUtil.formatDateTime(DateUtil.date()));
ddjDeviceExecutionQueue.setRwlx(DDJ_RWLX_3);
ddjDeviceExecutionQueueService.insertDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);

View File

@@ -65,8 +65,8 @@ public class Floor1SingleSsjThread implements Runnable {
exitRoadwayMap.put("L2007", "L2008");
//初始化巷道口 排 列 层
roadwayMap.put("L2001", Arrays.asList(1, 1, 1));
roadwayMap.put("L2007", Arrays.asList(1, 1, 1));
roadwayMap.put("L2001", Arrays.asList(1, 47, 1));
roadwayMap.put("L2007", Arrays.asList(4, 70, 1));
}
@Override
@@ -177,6 +177,7 @@ public class Floor1SingleSsjThread implements Runnable {
ddjDeviceExecutionQueue.setMbch(pclList.get(2));
ddjDeviceExecutionQueue.setDdjxf("0");
ddjDeviceExecutionQueue.setMlfs(5);
ddjDeviceExecutionQueue.setSpare1(mydoJob.getTraySize());
ddjDeviceExecutionQueue.setScsj(DateUtil.formatDateTime(DateUtil.date()));
ddjDeviceExecutionQueue.setRwlx(DDJ_RWLX_2);
ddjDeviceExecutionQueueService.insertDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);

View File

@@ -101,8 +101,8 @@ public class Floor2InOutSsjThread implements Runnable {
List<AgvQueue> agvQueues = agvQueueService.selectAgvQueueList(agvQueue);
//不允许放货 等着
if (!agvQueues.isEmpty() && inSsjDevice.getAllowPut() == 0 && "L1001".equals(inSsjDevice.getDeviceCode())) {
//下发输送线切换导向
int i = writeToSsjQH(inSsjDevice.getPlcDbWriteAddress(), Integer.parseInt(agvQueues.get(0).getCtnrType()));
//下发输送线切换导向 DB未知
int i = writeToSsjQH("inSsjDevice.getPlcDbWriteAddress()", Integer.parseInt(agvQueues.get(0).getCtnrType()));
if (i == 1) {
log.info("输送机{}下发切换导向{}成功", inSsjDevice.getDeviceCode(), agvQueues.get(0).getCtnrType());
}
@@ -202,17 +202,15 @@ public class Floor2InOutSsjThread implements Runnable {
mydoJobService.updateMydoJob(mydoJob1);
log.info(ssjDevice.getDeviceCode()+"输送机下发任务号成功:{}" , mydoJob1.getTaskNo());
}
}else{
HashMap<String, Object> map = new HashMap<>();
map.put("trayCode",ssjDevice.getTrayCode());
map.put("entranceId",ssjDevice.getDeviceCode());
map.put("size", ssjDevice.getTraySize());
// map.put("size", ssjDevice.getTraySize());
map.put("floor", "2");
AjaxResult ajaxResult = apiService.selectMydoJobByTrayCodeAndEntranceId(map);
if(ajaxResult.isSuccess()){
MydoJob mydoJob2 = BeanUtil.toBean(ajaxResult.get("data"), MydoJob.class) ;
MydoJob mydoJob2 = BeanUtil.toBean(ajaxResult.get("data"), MydoJob.class);
mydoJob2.setStatus("1");
mydoJob2.setExecutionPhase(TASK_EP_CREATE);
mydoJob2.setCreateTime(new Date());
@@ -278,17 +276,8 @@ public class Floor2InOutSsjThread implements Runnable {
if (i == 1) {
log.info("G1005产线输送机下发错误信息成功");
}
}
}
}
}
}

View File

@@ -22,8 +22,8 @@ import lombok.extern.slf4j.Slf4j;
import java.util.*;
import static com.ruoyi.common.TaskStatusCode.*;
import static com.ruoyi.common.TaskType.DDJ_RWLX_1;
import static com.ruoyi.common.TaskType.DDJ_RWLX_3;
import static com.ruoyi.common.TaskType.*;
import static com.ruoyi.common.TaskType.DDJ_RWLX_2;
/**
* 二楼出库线程 检测当前巷道有没有入库作业,没有作业,生成堆垛机出库队列
@@ -53,8 +53,8 @@ public class Floor2RoadWaySsjThread implements Runnable {
basCargoSpaceService = SpringUtils.getBean(IBasCargoSpaceService.class);
ddjDeviceExecutionQueueService = SpringUtils.getBean(IDdjDeviceExecutionQueueService.class);
//初始化巷道口 排 列 层
roadwayMap.put("L1002", Arrays.asList(1, 1, 1));
roadwayMap.put("L1004", Arrays.asList(1, 1, 1));
roadwayMap.put("L1002", Arrays.asList(2, 0, 1));
roadwayMap.put("L1004", Arrays.asList(4, 0, 1));
log.info("初始化服务 {},{}", apiService, agvQueueService);
}
@@ -94,7 +94,7 @@ public class Floor2RoadWaySsjThread implements Runnable {
public void inDispatch(DeviceSsj roadSsjDevice) {
//如果到位,且任务号大于0
if (roadSsjDevice.getDw()==1 && roadSsjDevice.getTaskNo()>0) {
if (roadSsjDevice.getDw()==1 && roadSsjDevice.getTaskNo()>1000) {
MydoJob mydoJob = mydoJobService.selectMydoJobByTaskNo(Convert.toLong(roadSsjDevice.getTaskNo()));
if (ObjUtil.isNotNull(mydoJob) && mydoJob.getExecutionPhase().equals(TASK_EP_SSJ)) {
mydoJob.setExecutionPhase(TASK_EP_ROADWAY_SSJ);
@@ -119,6 +119,7 @@ public class Floor2RoadWaySsjThread implements Runnable {
ddjDeviceExecutionQueue.setMbch(Convert.toInt(basCargoSpace.getTheFloor()));
ddjDeviceExecutionQueue.setDdjxf("0");
ddjDeviceExecutionQueue.setMlfs(5);
ddjDeviceExecutionQueue.setSpare1(mydoJob.getTraySize());
ddjDeviceExecutionQueue.setScsj(DateUtil.formatDateTime(DateUtil.date()));
ddjDeviceExecutionQueue.setRwlx(DDJ_RWLX_1);
ddjDeviceExecutionQueueService.insertDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
@@ -128,6 +129,53 @@ public class Floor2RoadWaySsjThread implements Runnable {
}
}
}
if(roadSsjDevice.getKx()==1 && roadSsjDevice.getTaskNo() == 0){
List<String> exitList = new ArrayList<>();
if("L1002".equals(roadSsjDevice.getDeviceCode())){
exitList.add("l1001");
}
if("L1004".equals(roadSsjDevice.getDeviceCode())){
exitList.add("l1003");
}
MydoJob mydoJob = mydoJobService.selectMydoJobByExitList(exitList);
if (ObjUtil.isNotNull(mydoJob)) {
BasCargoSpace basCargoSpace = basCargoSpaceService.selectBasCargoSpaceByWmsCargoSpaceId(mydoJob.getCargoSpaceId());
if (ObjUtil.isNull(basCargoSpace)) {
log.error("货位不存在 cargoSpaceId{}", mydoJob.getCargoSpaceId());
} else {
//生成队列
List<DdjDeviceExecutionQueue> list = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueListByRwlx(DDJ_RWLX_2, Convert.toInt(mydoJob.getRoadwayId()));
List<Integer> pclList = roadwayMap.get(roadSsjDevice.getDeviceCode());
if (CollUtil.isEmpty(list) && CollUtil.isNotEmpty(pclList)) {
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = new DdjDeviceExecutionQueue();
ddjDeviceExecutionQueue.setUuid(IdUtil.simpleUUID());
ddjDeviceExecutionQueue.setRwh(Convert.toLong(mydoJob.getTaskNo()));
ddjDeviceExecutionQueue.setDevName(mydoJob.getRoadwayId());
ddjDeviceExecutionQueue.setDevId(Convert.toInt(mydoJob.getRoadwayId()));
ddjDeviceExecutionQueue.setRwzt(0);
ddjDeviceExecutionQueue.setYph(Convert.toInt(basCargoSpace.getThePlatoon()));
ddjDeviceExecutionQueue.setYlh(Convert.toInt(basCargoSpace.getTheColumn()));
ddjDeviceExecutionQueue.setYch(Convert.toInt(basCargoSpace.getTheFloor()));
ddjDeviceExecutionQueue.setMbph(pclList.get(0));
ddjDeviceExecutionQueue.setMblh(pclList.get(1));
ddjDeviceExecutionQueue.setMbch(pclList.get(2));
ddjDeviceExecutionQueue.setDdjxf("0");
ddjDeviceExecutionQueue.setMlfs(5);
ddjDeviceExecutionQueue.setSpare1(mydoJob.getTraySize());
ddjDeviceExecutionQueue.setScsj(DateUtil.formatDateTime(DateUtil.date()));
ddjDeviceExecutionQueue.setRwlx(DDJ_RWLX_1);
ddjDeviceExecutionQueueService.insertDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
//修改作业状态
mydoJob.setStatus(TASK_STATUS_RUNNING);
mydoJob.setExecutionPhase(TASK_EP_DDJ);
mydoJob.setStartTime(DateUtil.formatDateTime(DateUtil.date()));
mydoJobService.updateMydoJob(mydoJob);
}
}
}
}
}
}

View File

@@ -140,16 +140,24 @@ public class LineSsjThread implements Runnable {
log.info("G1005产线输送机下发任务号成功:{}" , mydoJob2.getTaskNo());
}
} else {
//超大,给plc下发错误信息,等待人工处理
//托盘大小对不上,给plc下发错误信息,等待人工处理
//码不对,给plc下发错误信息,等待人工处理
int i = writeToSsj(SsjDevice.getPlcDbWriteAddress(), "0", Integer.parseInt(ajaxResult.get("code").toString()), 2);
/**
* 1, "二维码内容错误!"
* 2,"该序列号已有作业或库存!"
* 3, "物料不存在!"
* 4, "入口与托盘尺寸对应错误!"
* 5, "超大托盘!"
* 6, "托盘大小不匹配!"
* 7, "巷道入库锁定!"
* 8, "没有可用货位!"
* 9, "创建工艺入库单失败!"
*/
//超大,给plc下发错误信息,AGV搬到缓存区 其余人工处理
int i = writeToSsj(SsjDevice.getPlcDbWriteAddress(), "0", (Integer) ajaxResult.get("code"), 2);
if (i == 1) {
log.info("G1005产线输送机下发错误信息成功");
}
//7是报工单失败,不处理
if(!"7".equals(Integer.parseInt(ajaxResult.get("code").toString()))){
createMoveToPort(SsjDevice);
if((Integer) ajaxResult.get("code") == 5){
createMoveToPort(SsjDevice);
}
}
}
@@ -204,7 +212,7 @@ public class LineSsjThread implements Runnable {
log.info("G1005产线输送机下发错误信息成功");
}
//7是报工单失败,不处理
if(!"7".equals(Integer.parseInt(ajaxResult.get("code").toString()))){
if(!"9".equals(Integer.parseInt(ajaxResult.get("code").toString()))){
createMoveToPort(SsjDevice);
}
}
@@ -237,7 +245,7 @@ public class LineSsjThread implements Runnable {
//查是否有队列,如果有了请求放货修改为允许放货
AgvQueue agvQueue = agvQueueService.selectAgvQueueByTaskCode(mydoJob.getJobId());
if (agvQueue != null){
if ("3".equals(mydoJob.getStatus()) && "1".equals(agvQueue.getStatus())){
if ("3".equals(mydoJob.getStatus()) && "1".equals(agvQueue.getStatus()) && SsjDevice.getAllowPut() == 1){
AjaxResult ajaxResult = apiService.continueTask(agvQueue);
if (ajaxResult.isSuccess()) {
log.info("给agv下发允许取货继续任务成功"+agvQueue.getWmsTaskNo());

View File

@@ -6,9 +6,13 @@ spring:
druid:
#主数据信息
master:
url: jdbc:sqlserver://172.16.2.170:1433;databaseName=FT517-WCS;
# url: jdbc:sqlserver://172.16.2.170:1433;databaseName=FT517-WCS;
# username: sa
# password: Flrd0914.
url: jdbc:sqlserver://192.168.56.212:1433;databaseName=FT517-wcs;
username: sa
password: Flrd0914.
password: www.123.com
# 从库数据源
slave:
# 从数据源开关/默认关闭

View File

@@ -68,11 +68,11 @@ spring:
# redis 配置
redis:
# 地址
host: 172.16.2.170
host: 192.168.56.212
# 端口,默认为6379
port: 6379
# 数据库索引
database: 1
database: 2
# 密码
password: 123456
# 连接超时时间

View File

@@ -6,8 +6,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<resultMap type="DeviceSsj" id="DeviceSsjResult">
<result property="id" column="id" />
<result property="deviceCode " column="device_code " />
<result property="name " column="name " />
<result property="deviceCode" column="device_code" />
<result property="name" column="name" />
<result property="type" column="type" />
<result property="ipAddress" column="ip_address" />
<result property="plcDbReadAddress" column="plc_db_read_address" />
@@ -24,11 +24,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="allowPut" column="allow_put" />
<result property="ipAddress" column="ip_address" />
<result property="port" column="port" />
<result property="sszt" column="sszt" />
</resultMap>
<sql id="selectDeviceSsjVo">
select id, device_code , name , type, plc_db_read_address, is_active, create_time, plc_db_write_address,
rkqq, kx, dw, tray_code, task_no,exception,tray_size,allow_put,ip_address , port from device_ssj
rkqq, kx, dw, tray_code, task_no,exception,tray_size,allow_put,ip_address , port, sszt
from device_ssj
</sql>
<select id="selectDeviceSsjList" parameterType="DeviceSsj" resultMap="DeviceSsjResult">

View File

@@ -56,7 +56,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="warehouseId != null and warehouseId != ''">and warehouse_id = #{warehouseId}</if>
<if test="faultFlag != null and faultFlag != ''">and fault_flag = #{faultFlag}</if>
<if test="flag != null and flag != ''">and flag = #{flag}</if>
<if test="trayCode != null and trayCode != ''">and trayCode = #{tray_code}</if>
<if test="trayCode != null and trayCode != ''">and tray_code = #{trayCode}</if>
<if test="traySize != null and traySize != ''">and traySize = #{tray_size}</if>
<if test="epList != null and epList.size() > 0">
and entrance_id in