测试 +修改
This commit is contained in:
@@ -39,7 +39,8 @@ public class TestServiceImpl implements ITestService {
|
||||
SendData xtxh = new SendData(Tools.INT, msgDdj.getXtxh());
|
||||
SendData trayCode = new SendData(Tools.INT, Convert.toInt(msgDdj.getSpare2()));
|
||||
byte[] bytes = Tools.sendData(czfs, sbzt, rwh, hczt, jdbz, yph, ylh, ych, mbph, mblh, mbch, yxxf, xtxh, trayCode);
|
||||
int i = PlcSsjRead.WriteToSSJ("DB41.0", bytes);
|
||||
// int i = PlcSsjRead.WriteToSSJ("DB41.0", bytes);
|
||||
int i = 1;
|
||||
if (i == 1) {
|
||||
System.out.println("写入成功");
|
||||
return true;
|
||||
@@ -59,7 +60,8 @@ public class TestServiceImpl implements ITestService {
|
||||
|
||||
byte[] bytes = Tools.sendData(kx, dw, rkqq, taskNo);
|
||||
|
||||
int i = PlcSsjRead.WriteToSSJ(deviceSsj.getPlcDbReadAddress(), bytes);
|
||||
// int i = PlcSsjRead.WriteToSSJ(deviceSsj.getPlcDbReadAddress(), bytes);
|
||||
int i = 1;
|
||||
if (i == 1) {
|
||||
System.out.println("写入成功");
|
||||
return true;
|
||||
|
||||
@@ -61,7 +61,7 @@ public class RoadCacheServiceImpl implements RoadCacheService {
|
||||
//3.锁定离线小车当前位置
|
||||
lockedOfflineCarCurrSite(maps, deviceSrgv);
|
||||
|
||||
int[][] mapsInt = new int[29][11];
|
||||
int[][] mapsInt = new int[29][15];
|
||||
for (String site : maps.keySet()) {
|
||||
WcsSrgvMap wcsSrgvMap = maps.get(site);
|
||||
mapsInt[wcsSrgvMap.getX()][wcsSrgvMap.getY()] = wcsSrgvMap.getValue();
|
||||
|
||||
@@ -11,6 +11,15 @@ public class SendData2 {
|
||||
|
||||
private int type;//1单字 2双字 3字符串
|
||||
|
||||
public SendData2(String address, String data, int type) {
|
||||
this.address = address;
|
||||
this.data = data;
|
||||
this.type = type;
|
||||
}
|
||||
public SendData2(){
|
||||
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
@@ -84,6 +84,11 @@ public class DeviceSsj extends BaseEntity
|
||||
@Excel(name="输送线模式 1-入库 2-出库")
|
||||
private int model;
|
||||
|
||||
@Excel(name = "操作模式")
|
||||
private int czms;
|
||||
|
||||
@Excel(name = "入库到位")
|
||||
private int rkdw;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ public class JobCallBackController extends BaseController
|
||||
return toAjax(jobCallBackService.deleteJobCallBackByIds(ids));
|
||||
}
|
||||
|
||||
//@Scheduled(fixedDelay=1500)
|
||||
@Scheduled(fixedDelay=1500)
|
||||
public void jobCallBack() {
|
||||
jobCallBackService.jobCallBack();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.ruoyi.schedule;
|
||||
|
||||
import HslCommunication.Core.Types.OperateResultExOne;
|
||||
import com.ruoyi.common.domain.CustomThread;
|
||||
import com.ruoyi.common.domain.PlcConnectInfo;
|
||||
import com.ruoyi.device.ddj.domain.MsgDdj;
|
||||
@@ -8,9 +9,12 @@ 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.impl.DeviceTsjServiceImpl;
|
||||
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,6 +35,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
public class ScheduleThread {
|
||||
|
||||
public CustomThread<PlcSsjRead> plcSsjReadCustomThread;
|
||||
public CustomThread<PlcTsjRead> plcTsjReadCustomThread;
|
||||
public CustomThread<PlcSrgvRead> plcSrgvReadCustomThread1;
|
||||
public CustomThread<PlcSrgvRead> plcSrgvReadCustomThread2;
|
||||
public CustomThread<PlcSrgvRead> plcSrgvReadCustomThread3;
|
||||
@@ -53,6 +58,8 @@ public class ScheduleThread {
|
||||
|
||||
private boolean isRun = false;
|
||||
private boolean isRun2 = false;
|
||||
@Autowired
|
||||
private DeviceTsjServiceImpl deviceTsjServiceImpl;
|
||||
|
||||
/**
|
||||
* 项目初始化启动
|
||||
@@ -66,51 +73,50 @@ public class ScheduleThread {
|
||||
scheduleInit();
|
||||
log.info("调度服务执行成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 调度初始化
|
||||
*/
|
||||
private void scheduleInit() {
|
||||
MonitoringThread monitoringThread = new MonitoringThread();
|
||||
monitoringCustomThread = new CustomThread<MonitoringThread>(new Thread(monitoringThread), monitoringThread);
|
||||
//输送机线程
|
||||
SsjThread ssjThread=new SsjThread();
|
||||
ssjThreadCustomThread=new CustomThread<SsjThread>(new Thread(ssjThread),ssjThread);
|
||||
// //四向车线程
|
||||
SRgv1Thread srgvThread=new SRgv1Thread();
|
||||
sRgvThreadCustomThread=new CustomThread<>(new Thread(srgvThread),srgvThread);
|
||||
//提升机线程
|
||||
TsjThread tsjThread=new TsjThread();
|
||||
tsjThreadCustomThread=new CustomThread<>(new Thread(tsjThread),tsjThread);
|
||||
CdzThread cdzThread = new CdzThread();
|
||||
cdzThreadCustomThread=new CustomThread<>(new Thread(cdzThread),cdzThread);
|
||||
// Ddj1Thread ddj1Thread = new Ddj1Thread();
|
||||
// ddj1CustomThread = new CustomThread<>(new Thread(ddj1Thread), ddj1Thread);
|
||||
/*Ddj2Thread ddj2Thread = new Ddj2Thread();
|
||||
ddj2CustomThread = new CustomThread<>(new Thread(ddj2Thread), ddj2Thread);
|
||||
Ddj3Thread ddj3Thread = new Ddj3Thread();
|
||||
ddj3CustomThread = new CustomThread<>(new Thread(ddj3Thread), ddj3Thread);
|
||||
Ddj4Thread ddj4Thread = new Ddj4Thread();
|
||||
ddj4CustomThread = new CustomThread<>(new Thread(ddj4Thread), ddj4Thread);
|
||||
Ddj5Thread ddj5Thread = new Ddj5Thread();
|
||||
ddj5CustomThread = new CustomThread<>(new Thread(ddj5Thread), ddj5Thread);
|
||||
Ddj6Thread ddj6Thread = new Ddj6Thread();
|
||||
ddj6CustomThread = new CustomThread<>(new Thread(ddj6Thread), ddj6Thread);*/
|
||||
// //充电线程
|
||||
// CdzThread cdzThread = new CdzThread();
|
||||
// cdzThreadCustomThread=new CustomThread<>(new Thread(cdzThread),cdzThread);
|
||||
}
|
||||
|
||||
/**
|
||||
* plc读取初始化
|
||||
*/
|
||||
private void plcReadInit() {
|
||||
|
||||
ConcurrentHashMap<String, DeviceSsj> ssjList = new ConcurrentHashMap<>();
|
||||
//获取要去取的输送机
|
||||
//获取要取的输送机
|
||||
List<DeviceSsj> deviceSsjs = deviceSsjService.selectDeviceSsjList(new DeviceSsj());
|
||||
for (DeviceSsj deviceSsj : deviceSsjs) {
|
||||
ssjList.put(deviceSsj.getDeviceCode(), deviceSsj);
|
||||
}
|
||||
|
||||
//plc输送机读取线程
|
||||
PlcSsjRead plcSsjRead = new PlcSsjRead(ssjList, new PlcConnectInfo("127.0.0.1", 102));
|
||||
PlcSsjRead plcSsjRead = new PlcSsjRead(ssjList, new PlcConnectInfo("127.0.0.1", 1502));
|
||||
Thread plcSsjReadThread = new Thread(plcSsjRead);
|
||||
plcSsjReadCustomThread = new CustomThread<PlcSsjRead>(plcSsjReadThread, plcSsjRead);
|
||||
|
||||
ConcurrentHashMap<String, DeviceTsj> tsjList = new ConcurrentHashMap<>();
|
||||
//获取要取的提升机
|
||||
List<DeviceTsj> tsjLists = deviceTsjServiceImpl.selectDeviceTsjList(new DeviceTsj());
|
||||
for (DeviceTsj t : tsjLists) {
|
||||
tsjList.put(t.getName(), t);
|
||||
}
|
||||
//plc提升机读取线程
|
||||
PlcTsjRead plcTsjRead = new PlcTsjRead(tsjList, new PlcConnectInfo("127.0.0.1", 1502));
|
||||
Thread plcTsjReadThread = new Thread(plcTsjRead);
|
||||
plcTsjReadCustomThread = new CustomThread<PlcTsjRead>(plcTsjReadThread, plcTsjRead);
|
||||
|
||||
ConcurrentHashMap<String, DeviceSrgv> srgvList = new ConcurrentHashMap<>();
|
||||
List<DeviceSrgv> srgvs=deviceSrgvService.selectDeviceSrgvList(new DeviceSrgv());
|
||||
for(DeviceSrgv srgv:srgvs){
|
||||
@@ -126,17 +132,12 @@ public class ScheduleThread {
|
||||
Thread plcSrgvReadThread2 = new Thread((plcSrgvRead2));
|
||||
plcSrgvReadCustomThread2=new CustomThread<PlcSrgvRead>(plcSrgvReadThread2,plcSrgvRead2);
|
||||
break;
|
||||
/*case 3:
|
||||
PlcSrgvRead plcSrgvRead3=new PlcSrgvRead(srgv,new PlcConnectInfo(srgv.getIp(),srgv.getPort()));
|
||||
Thread plcSrgvReadThread3 = new Thread((plcSrgvRead3));
|
||||
plcSrgvReadCustomThread3=new CustomThread<PlcSrgvRead>(plcSrgvReadThread3,plcSrgvRead3);
|
||||
break;*/
|
||||
}
|
||||
|
||||
}
|
||||
PlcSrgvRead.deviceSrgvMap=srgvList;
|
||||
|
||||
|
||||
//监控线程
|
||||
MonitoringThread monitoringThread = new MonitoringThread();
|
||||
monitoringCustomThread = new CustomThread<MonitoringThread>(new Thread(monitoringThread), monitoringThread);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -145,10 +146,9 @@ public class ScheduleThread {
|
||||
public void startAllThread() {
|
||||
plcSsjReadCustomThread.getThread().start();
|
||||
plcSrgvReadCustomThread1.getThread().start();
|
||||
//plcSrgvReadCustomThread2.getThread().start();
|
||||
//plcSrgvReadCustomThread3.getThread().start();
|
||||
|
||||
|
||||
// plcSrgvReadCustomThread2.getThread().start();
|
||||
plcTsjReadCustomThread.getThread().start();
|
||||
monitoringCustomThread.getThread().start();
|
||||
isRun = true;
|
||||
}
|
||||
|
||||
@@ -156,17 +156,10 @@ public class ScheduleThread {
|
||||
* 开启线程2
|
||||
*/
|
||||
public void startAllThread2() {
|
||||
monitoringCustomThread.thread.start();
|
||||
ssjThreadCustomThread.thread.start();
|
||||
//tsjThreadCustomThread.thread.start();
|
||||
tsjThreadCustomThread.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;
|
||||
}
|
||||
|
||||
@@ -175,7 +168,7 @@ public class ScheduleThread {
|
||||
*/
|
||||
public void stopAllThread() {
|
||||
plcSsjReadCustomThread.runnable.isRun = false;
|
||||
// plcDdj1ReadCustomThread.runnable.isRun = false;
|
||||
// plcDdj1ReadCustomThread.runnable.isRun = false;
|
||||
/* plcDdj2ReadCustomThread.runnable.isRun = false;
|
||||
plcDdj3ReadCustomThread.runnable.isRun = false;
|
||||
plcDdj4ReadCustomThread.runnable.isRun = false;
|
||||
@@ -209,4 +202,5 @@ public class ScheduleThread {
|
||||
map.put("isRun2",isRun2);
|
||||
return map;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -39,14 +39,14 @@ public class PlcSrgvRead implements Runnable {
|
||||
this.station = (byte) 1;
|
||||
}
|
||||
|
||||
public static boolean Write(String address, int[] value){
|
||||
public static boolean Write(String address, int[] value) {
|
||||
|
||||
OperateResult write = modbusTcpNet.Write(address, value);
|
||||
return write.IsSuccess;
|
||||
|
||||
}
|
||||
|
||||
public static boolean Write(String address, short[] value){
|
||||
public static boolean Write(String address, short[] value) {
|
||||
|
||||
OperateResult write = modbusTcpNet.Write(address, value);
|
||||
return write.IsSuccess;
|
||||
@@ -58,26 +58,14 @@ 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();
|
||||
}*/
|
||||
//todo 测试使用
|
||||
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(1500);
|
||||
} catch (InterruptedException e) {
|
||||
// 捕获中断异常,退出循环
|
||||
Thread.currentThread().interrupt(); // 重新设置中断标志
|
||||
@@ -90,20 +78,20 @@ 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);
|
||||
// //读取双字,路径
|
||||
// OperateResultExOne<byte[]> read3 = modbusTcpNet.Read("5000", (short) 800);// 5000-5799 路径 400个
|
||||
// setValueByByte3(read3.Content, deviceSrgv);
|
||||
}
|
||||
|
||||
//单字
|
||||
@@ -113,33 +101,34 @@ 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)));//换层标志
|
||||
}
|
||||
|
||||
private void setValueByByte2(byte[] content, DeviceSrgv agvData) {
|
||||
byteTransform.setDataFormat(DataFormat.CDAB);
|
||||
// TODO 注意双字反转
|
||||
agvData.setTaskNo(byteTransform.TransInt32(content, 0));
|
||||
log.info("=====读取到SRGV任务号:{}=======", agvData.getTaskNo());
|
||||
agvData.setSrcSite(String.format("%06d", byteTransform.TransInt32(content, 4)));
|
||||
log.info("=====读取到SRGV源站点:{}=======", agvData.getSrcSite());
|
||||
agvData.setTarSite(String.format("%06d", byteTransform.TransInt32(content, 8)));
|
||||
log.info("=====读取到SRGV目标站点:{}=======", agvData.getTarSite());
|
||||
agvData.setCurrSite(String.format("%06d", byteTransform.TransInt32(content, 12)));
|
||||
log.info("=====读取到SRGV当前站点:{}=======", agvData.getCurrSite());
|
||||
|
||||
//设置库区
|
||||
String currSite = agvData.getCurrSite();
|
||||
String currSite = String.format("%06d", byteTransform.TransInt32(content, 12));
|
||||
String l = currSite.substring(2, 4);
|
||||
//截取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);
|
||||
}
|
||||
@@ -200,7 +189,7 @@ public class PlcSrgvRead implements Runnable {
|
||||
void reConnect() {
|
||||
closeServer();
|
||||
ConnectServer();
|
||||
log.info("重新连接 SSJ-PLC");
|
||||
log.info("重新连接 四象车-PLC");
|
||||
}
|
||||
|
||||
void closeServer() {
|
||||
@@ -210,5 +199,13 @@ public class PlcSrgvRead implements Runnable {
|
||||
setIsConnect(false);
|
||||
}
|
||||
|
||||
public String getSite(String siteId){
|
||||
if (siteId.equals("030502")||siteId.equals("030501")||siteId.equals("030503")){
|
||||
return "tsj";
|
||||
}else {
|
||||
return siteId;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -2,24 +2,34 @@ package com.ruoyi.schedule.plcRead.ssj;
|
||||
|
||||
import HslCommunication.BasicFramework.SoftBasic;
|
||||
import HslCommunication.Core.Net.IReadWriteNet;
|
||||
import HslCommunication.Core.Transfer.DataFormat;
|
||||
import HslCommunication.Core.Transfer.IByteTransform;
|
||||
import HslCommunication.Core.Types.OperateResult;
|
||||
import HslCommunication.Core.Types.OperateResultExOne;
|
||||
import HslCommunication.ModBus.ModbusTcpNet;
|
||||
import HslCommunication.Profinet.Siemens.SiemensPLCS;
|
||||
import HslCommunication.Profinet.Siemens.SiemensS7Net;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import com.ruoyi.common.domain.SendData;
|
||||
import com.ruoyi.common.domain.SendData2;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import com.ruoyi.device.ddj.domain.MsgDdj;
|
||||
import com.ruoyi.device.srgv.domain.DeviceSrgv;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
import com.ruoyi.common.domain.HslRead;
|
||||
import com.ruoyi.common.domain.PlcConnectInfo;
|
||||
import com.ruoyi.device.ssj.service.impl.DeviceSsjServiceImpl;
|
||||
import com.ruoyi.schedule.plcRead.srgv.PlcSrgvRead;
|
||||
import com.ruoyi.schedule.plcRead.util.ParseUtil;
|
||||
import com.ruoyi.schedule.plcRead.util.Tools;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.beanutils.LazyDynaClass;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
public class PlcSsjRead implements Runnable {
|
||||
@@ -27,59 +37,47 @@ public class PlcSsjRead implements Runnable {
|
||||
public static ConcurrentHashMap<String, DeviceSsj> deviceSsjMap;
|
||||
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 DeviceSsj ssjDevice;
|
||||
private static ModbusTcpNet modbusTcpNet;
|
||||
private IByteTransform byteTransform = null;
|
||||
|
||||
public PlcSsjRead(ConcurrentHashMap<String, DeviceSsj> deviceSsjMap, PlcConnectInfo plcConnectInfo) {
|
||||
PlcSsjRead.deviceSsjMap = deviceSsjMap;
|
||||
ssjDevice = deviceSsjMap.get("L1001");
|
||||
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;
|
||||
public static boolean Write(String address, int[] value) {
|
||||
|
||||
OperateResult write = modbusTcpNet.Write(address, value);
|
||||
return write.IsSuccess;
|
||||
|
||||
}
|
||||
|
||||
public static boolean Write(String address, short[] value) {
|
||||
|
||||
OperateResult write = modbusTcpNet.Write(address, value);
|
||||
return write.IsSuccess;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
while (isRun) {
|
||||
try {
|
||||
/*if (IsConnect()) {
|
||||
int step = 20;
|
||||
int baseOffset = 0;
|
||||
*//*for (String ssjCode : deviceSsjMap.keySet()) {
|
||||
DeviceSsj ssjDevice = deviceSsjMap.get(ssjCode);
|
||||
switch (ssjDevice.getType()) {
|
||||
case "1":
|
||||
readPlcLineSsj(ssjDevice);
|
||||
break;
|
||||
case "2":
|
||||
readPlcInOutSsj(ssjDevice);
|
||||
break;
|
||||
case "3":
|
||||
readPlcOtherSsj(ssjDevice);
|
||||
break;
|
||||
}
|
||||
}*//*
|
||||
|
||||
if (IsConnect()) {
|
||||
if (ssjDevice != null) {
|
||||
readPlcLineSsj(ssjDevice);
|
||||
}
|
||||
} 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);
|
||||
Thread.sleep(1500);
|
||||
} catch (InterruptedException e) {
|
||||
// 捕获中断异常,退出循环
|
||||
Thread.currentThread().interrupt(); // 重新设置中断标志
|
||||
@@ -92,111 +90,73 @@ public class PlcSsjRead implements Runnable {
|
||||
}
|
||||
|
||||
/**
|
||||
* 其他输送机
|
||||
*
|
||||
* @param ssjDevice
|
||||
*/
|
||||
private void readPlcOtherSsj(DeviceSsj ssjDevice) {
|
||||
OperateResultExOne<byte[]> read2 = readWriteNet.Read(ssjDevice.getPlcDbReadAddress(), Short.parseShort("20"));
|
||||
String ddsx1 = "0";
|
||||
if (read2.IsSuccess) {
|
||||
ddsx1 = SoftBasic.ByteToHexString(read2.Content);
|
||||
ssjDevice.setKx(ParseUtil.optInt(0, ddsx1));
|
||||
ssjDevice.setDw(ParseUtil.optInt(2, ddsx1));
|
||||
ssjDevice.setTaskNo(ParseUtil.optDInt(6, ddsx1));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 巷道输送机
|
||||
*
|
||||
* @param ssjDevice
|
||||
*/
|
||||
private void readPlcRoadWaySsj(DeviceSsj ssjDevice) {
|
||||
OperateResultExOne<byte[]> read2 = readWriteNet.Read(ssjDevice.getPlcDbReadAddress(), Short.parseShort("20"));
|
||||
String ddsx1 = "0";
|
||||
if (read2.IsSuccess) {
|
||||
ddsx1 = SoftBasic.ByteToHexString(read2.Content);
|
||||
ssjDevice.setKx(ParseUtil.optInt(0, ddsx1));
|
||||
ssjDevice.setDw(ParseUtil.optInt(2, ddsx1));
|
||||
ssjDevice.setRkqq(ParseUtil.optInt(4, ddsx1));
|
||||
ssjDevice.setTaskNo(ParseUtil.optDInt(6, ddsx1));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 入出库输送机
|
||||
*
|
||||
* @param ssjDevice
|
||||
*/
|
||||
private void readPlcInOutSsj(DeviceSsj ssjDevice) {
|
||||
OperateResultExOne<byte[]> read2 = readWriteNet.Read(ssjDevice.getPlcDbReadAddress(), Short.parseShort("20"));
|
||||
String ddsx1 = "0";
|
||||
if (read2.IsSuccess) {
|
||||
ddsx1 = SoftBasic.ByteToHexString(read2.Content);
|
||||
ssjDevice.setKx(ParseUtil.optInt(0, ddsx1));
|
||||
ssjDevice.setDw(ParseUtil.optInt(2, ddsx1));
|
||||
ssjDevice.setException(ParseUtil.optInt(4, ddsx1));
|
||||
ssjDevice.setAllowPut(ParseUtil.optInt(6, ddsx1));
|
||||
ssjDevice.setTaskNo(ParseUtil.optDInt(8, ddsx1));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 产线输送机
|
||||
* L1001输送机 操作模式 任务号 空闲 设备状态 条码 称重 请求入库 出库到位
|
||||
*
|
||||
* @param ssjDevice
|
||||
*/
|
||||
private void readPlcLineSsj(DeviceSsj ssjDevice) {
|
||||
OperateResultExOne<byte[]> read2 = readWriteNet.Read(ssjDevice.getPlcDbReadAddress(), Short.parseShort("220"));
|
||||
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));
|
||||
|
||||
String trayCodeReadAddress="";
|
||||
switch (ssjDevice.getDeviceCode()){
|
||||
case "G1005":
|
||||
trayCodeReadAddress = "DB502.0";
|
||||
break;
|
||||
case "L2012":
|
||||
trayCodeReadAddress = "DB503.0";
|
||||
break;
|
||||
case "L2013":
|
||||
trayCodeReadAddress = "DB504.0";
|
||||
break;
|
||||
}
|
||||
OperateResultExOne<byte[]> trayCodeRead = readWriteNet.Read(trayCodeReadAddress, Short.parseShort("220"));
|
||||
if (trayCodeRead.IsSuccess){
|
||||
byte[] content = trayCodeRead.Content;
|
||||
//去除bytes中
|
||||
ssjDevice.setTrayCode(ParseUtil.filterAndConvert(trayCodeRead.Content));
|
||||
}
|
||||
OperateResultExOne<byte[]> read1 = modbusTcpNet.Read("1110", (short) 1);//1110 操作模式
|
||||
if (read1.IsSuccess) {
|
||||
ssjDevice.setCzms(Convert.toInt(byteTransform.TransInt16(read1.Content, 0)));
|
||||
log.info("=====读取到输送机操作模式:{}======", Convert.toInt(byteTransform.TransInt16(read1.Content, 0)));
|
||||
}else {
|
||||
success =false;
|
||||
}
|
||||
OperateResultExOne<byte[]> read2 = modbusTcpNet.Read("1111", (short) 2);//1111 任务号
|
||||
if (read2.IsSuccess) {
|
||||
byteTransform.setDataFormat(DataFormat.CDAB);
|
||||
// TODO 注意双字反转
|
||||
ssjDevice.setTaskNo(byteTransform.TransInt32(read2.Content, 0));
|
||||
log.info("=====读取到输送机任务号:{}=======", byteTransform.TransInt32(read2.Content, 0));
|
||||
}
|
||||
OperateResultExOne<byte[]> read3 = modbusTcpNet.Read("1113", (short) 2);//1113 空闲 1114 设备状态
|
||||
if (read3.IsSuccess) {
|
||||
ssjDevice.setKx(Convert.toInt(byteTransform.TransInt16(read3.Content, 0)));
|
||||
log.info("=====读取到输送机空闲:{}=======", Convert.toInt(byteTransform.TransInt16(read3.Content, 0)));
|
||||
log.info("=====读取到输送机设备状态:{}=======", Convert.toInt(byteTransform.TransInt16(read3.Content, 2)));
|
||||
}
|
||||
OperateResultExOne<byte[]> read4 = modbusTcpNet.Read("1115", (short) 16);//1115 条码
|
||||
if (read4.IsSuccess) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (byte b : read4.Content) {
|
||||
int code = b & 0xFF;
|
||||
if (code >= 32 && code <= 126) sb.append((char) code);
|
||||
}
|
||||
String barcode = sb.toString();
|
||||
ssjDevice.setTrayCode(barcode);
|
||||
log.info("=====读取到输送机条码:{}=======", barcode);
|
||||
}
|
||||
OperateResultExOne<byte[]> read5 = modbusTcpNet.Read("1131", (short) 2);//1115 称重
|
||||
if (read5.IsSuccess) {
|
||||
byteTransform.setDataFormat(DataFormat.CDAB);
|
||||
log.info("=====读取到输送机称重:{}=======", byteTransform.TransInt32(read5.Content, 0));
|
||||
}
|
||||
OperateResultExOne<byte[]> read6 = modbusTcpNet.Read("1133", (short) 3);//1133 请求入库 1134 出库到位
|
||||
if (read6.IsSuccess) {
|
||||
ssjDevice.setRkqq(Convert.toInt(byteTransform.TransInt16(read6.Content, 0)));
|
||||
log.info("=====读取到输送机入库请求:{}=======", Convert.toInt(byteTransform.TransInt16(read6.Content, 0)));
|
||||
ssjDevice.setDw(Convert.toInt(byteTransform.TransInt16(read6.Content, 2)));
|
||||
log.info("=====读取到输送机出库到位:{}=======", Convert.toInt(byteTransform.TransInt16(read6.Content, 2)));
|
||||
ssjDevice.setRkdw(Convert.toInt(byteTransform.TransInt16(read6.Content, 4)));
|
||||
log.info("=====读取到输送机入库到位:{}=======", Convert.toInt(byteTransform.TransInt16(read6.Content, 2)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ConnectServer() {
|
||||
siemensS7Net = new SiemensS7Net(SiemensPLCS.S1500);
|
||||
modbusTcpNet = new ModbusTcpNet();//创建一个Modbus对象
|
||||
try {
|
||||
siemensS7Net.setIpAddress(this.ip);
|
||||
siemensS7Net.setPort(this.port);
|
||||
siemensS7Net.setRack((byte) 0);
|
||||
siemensS7Net.setSlot((byte) 1);
|
||||
|
||||
OperateResult connect = siemensS7Net.ConnectServer();
|
||||
modbusTcpNet.setIpAddress(this.ip);
|
||||
modbusTcpNet.setPort(this.port);
|
||||
modbusTcpNet.setStation((byte) 1);
|
||||
this.byteTransform = modbusTcpNet.getByteTransform();
|
||||
OperateResult connect = modbusTcpNet.ConnectServer();
|
||||
if (connect.IsSuccess) {
|
||||
setIsConnect(true);
|
||||
readWriteNet = siemensS7Net;
|
||||
readWriteNet = modbusTcpNet;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
log.info("********IP:" + this.ip + " port:" + this.port + "连接失败 " + ex.getMessage());
|
||||
log.info("********IP:{} port:{}SSJ连接失败 {}", this.ip, this.port, ex.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -217,7 +177,7 @@ public class PlcSsjRead implements Runnable {
|
||||
void reConnect() {
|
||||
closeServer();
|
||||
ConnectServer();
|
||||
log.info("重新连接 SSJ-PLC");
|
||||
log.info("重新连接输送机-PLC");
|
||||
}
|
||||
|
||||
void closeServer() {
|
||||
@@ -227,18 +187,45 @@ public class PlcSsjRead implements Runnable {
|
||||
setIsConnect(false);
|
||||
}
|
||||
|
||||
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);
|
||||
SendData qxSendData = new SendData(Tools.INT, qx);
|
||||
SendData completedSendData = new SendData(Tools.INT, completed);
|
||||
SendData jymSendData = new SendData(Tools.INT, jym);
|
||||
byte[] bytes = Tools.sendData(taskNoSendData, qxSendData, completedSendData, jymSendData);
|
||||
return PlcSsjRead.WriteToSSJ(address, bytes);
|
||||
public static int writeToSsj(String taskNo, int qx, int completed) {
|
||||
List<SendData2> sendDataList = new ArrayList<>();
|
||||
sendDataList.add(new SendData2("1100", taskNo, 2));
|
||||
sendDataList.add(new SendData2("1102", String.valueOf(qx), 1));
|
||||
sendDataList.add(new SendData2("1103", String.valueOf(completed), 1));
|
||||
int b = 1;
|
||||
for (SendData2 sendData : sendDataList) {
|
||||
String address = sendData.getAddress();
|
||||
String data = sendData.getData();
|
||||
String[] split = data.split(",");
|
||||
int type = sendData.getType();
|
||||
if (type == 2) {
|
||||
int[] intData = Arrays.stream(split)
|
||||
.map(String::trim)
|
||||
.mapToInt(Integer::parseInt)
|
||||
.toArray();
|
||||
boolean write = PlcSsjRead.Write(address, intData);
|
||||
if (!write) {
|
||||
b = 0;
|
||||
break;
|
||||
}
|
||||
} else if (type == 1) {
|
||||
short[] shortData = new short[split.length];
|
||||
for (int i = 0; i < split.length; i++) {
|
||||
try {
|
||||
shortData[i] = Short.parseShort(split[i].trim());
|
||||
} catch (NumberFormatException e) {
|
||||
shortData[i] = 0;
|
||||
}
|
||||
}
|
||||
boolean write = PlcSsjRead.Write(address, shortData);
|
||||
if (!write) {
|
||||
b = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
String collect = sendDataList.stream().map(li -> "{" + li.getAddress() + ":" + li.getData() + "}").collect(Collectors.joining(","));
|
||||
log.info("输送机下发完成,下发值:{},,结果:{}", collect, b);
|
||||
return b;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -2,20 +2,30 @@ package com.ruoyi.schedule.plcRead.tsj;
|
||||
|
||||
import HslCommunication.BasicFramework.SoftBasic;
|
||||
import HslCommunication.Core.Net.IReadWriteNet;
|
||||
import HslCommunication.Core.Transfer.DataFormat;
|
||||
import HslCommunication.Core.Transfer.IByteTransform;
|
||||
import HslCommunication.Core.Types.OperateResult;
|
||||
import HslCommunication.Core.Types.OperateResultExOne;
|
||||
import HslCommunication.ModBus.ModbusTcpNet;
|
||||
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.common.domain.SendData;
|
||||
import com.ruoyi.common.domain.SendData2;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
import com.ruoyi.device.tsj.domain.DeviceTsj;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcSsjRead;
|
||||
import com.ruoyi.schedule.plcRead.util.ParseUtil;
|
||||
import com.ruoyi.schedule.plcRead.util.Tools;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
public class PlcTsjRead implements Runnable {
|
||||
@@ -23,24 +33,33 @@ public class PlcTsjRead implements Runnable {
|
||||
public static ConcurrentHashMap<String, DeviceTsj> deviceTsjMap;
|
||||
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 final DeviceTsj deviceTsj;
|
||||
private static ModbusTcpNet modbusTcpNet;
|
||||
private IByteTransform byteTransform = null;
|
||||
|
||||
public PlcTsjRead(ConcurrentHashMap<String, DeviceTsj> deviceTsjMap, PlcConnectInfo plcConnectInfo) {
|
||||
PlcTsjRead.deviceTsjMap = deviceTsjMap;
|
||||
deviceTsj = deviceTsjMap.get("tsj1");
|
||||
this.ip = plcConnectInfo.getIp();
|
||||
this.port = plcConnectInfo.getPort();
|
||||
}
|
||||
|
||||
public static int WriteToTSJ(String address, byte[] data) {
|
||||
int a = 0;
|
||||
if (readWriteNet != null) {
|
||||
a = HslRead.WriteResultRender(readWriteNet.Write(address, data), address);
|
||||
}
|
||||
return a;
|
||||
public static boolean Write(String address, int[] value) {
|
||||
|
||||
OperateResult write = modbusTcpNet.Write(address, value);
|
||||
return write.IsSuccess;
|
||||
|
||||
}
|
||||
|
||||
public static boolean Write(String address, short[] value) {
|
||||
|
||||
OperateResult write = modbusTcpNet.Write(address, value);
|
||||
return write.IsSuccess;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -48,9 +67,8 @@ public class PlcTsjRead implements Runnable {
|
||||
while (isRun) {
|
||||
try {
|
||||
if (IsConnect()) {
|
||||
for (String tsjCode : deviceTsjMap.keySet()) {
|
||||
DeviceTsj tsjDevice = deviceTsjMap.get(tsjCode);
|
||||
plcRead(tsjDevice);
|
||||
if (deviceTsj != null) {
|
||||
readPlcLineTsj(deviceTsj);
|
||||
}
|
||||
Thread.sleep(1000);
|
||||
} else {
|
||||
@@ -67,41 +85,46 @@ public class PlcTsjRead implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
private void plcRead(DeviceTsj tsjDevice) {
|
||||
OperateResultExOne<byte[]> read2 = readWriteNet.Read(tsjDevice.getPlcDbReadAddress(), Short.parseShort("220"));
|
||||
String ddsx1 = "0";
|
||||
if (read2.IsSuccess) {
|
||||
ddsx1 = SoftBasic.ByteToHexString(read2.Content);
|
||||
tsjDevice.setCzfs(ParseUtil.optInt(2, ddsx1));
|
||||
tsjDevice.setSbzt(ParseUtil.optInt(4, ddsx1));
|
||||
tsjDevice.setRwh(Convert.toLong(ParseUtil.optDInt(6, ddsx1)));
|
||||
tsjDevice.setDqcs(ParseUtil.optInt(10, ddsx1));
|
||||
tsjDevice.setJdbz(ParseUtil.optInt(12, ddsx1));
|
||||
tsjDevice.setYph(ParseUtil.optInt(14, ddsx1));
|
||||
tsjDevice.setYch(ParseUtil.optInt(16, ddsx1));
|
||||
tsjDevice.setMbph(ParseUtil.optInt(18, ddsx1));
|
||||
tsjDevice.setMbch(ParseUtil.optInt(20, ddsx1));
|
||||
tsjDevice.setYxxf(ParseUtil.optInt(22, ddsx1));
|
||||
tsjDevice.setXtxh(ParseUtil.optInt(24, ddsx1));
|
||||
private void readPlcLineTsj(DeviceTsj tsjDevice) {
|
||||
OperateResultExOne<byte[]> read1 = modbusTcpNet.Read("1013", (short) 2);//1013 任务号
|
||||
if (read1.IsSuccess) {
|
||||
byteTransform.setDataFormat(DataFormat.CDAB);
|
||||
// TODO 注意双字反转
|
||||
deviceTsj.setRwh((long) byteTransform.TransInt32(read1.Content, 0));
|
||||
log.info("=====读取到提升机任务号:{}=======", byteTransform.TransInt32(read1.Content, 0));
|
||||
}
|
||||
OperateResultExOne<byte[]> read2 = modbusTcpNet.Read("1015", (short) 6);//1015 操作方式 1016 设备状态 1017 当前层 1018 执行阶段 1019 允许下发 1020 心跳
|
||||
if (read1.IsSuccess) {
|
||||
deviceTsj.setCzfs(Convert.toInt(byteTransform.TransInt16(read2.Content, 0)));
|
||||
log.info("=====读取到提升机操作模式:{}======", Convert.toInt(byteTransform.TransInt16(read2.Content, 0)));
|
||||
deviceTsj.setSbzt(Convert.toInt(byteTransform.TransInt16(read2.Content, 2)));
|
||||
log.info("=====读取到提升机设备状态:{}======", Convert.toInt(byteTransform.TransInt16(read2.Content, 2)));
|
||||
deviceTsj.setDqcs(Convert.toInt(byteTransform.TransInt16(read2.Content, 4)));
|
||||
log.info("=====读取到提升机当前层:{}======", Convert.toInt(byteTransform.TransInt16(read2.Content, 4)));
|
||||
deviceTsj.setJdbz(Convert.toInt(byteTransform.TransInt16(read2.Content, 6)));
|
||||
log.info("=====读取到提升机执行阶段:{}======", Convert.toInt(byteTransform.TransInt16(read2.Content, 6)));
|
||||
deviceTsj.setYxxf(Convert.toInt(byteTransform.TransInt16(read2.Content, 8)));
|
||||
log.info("=====读取到提升机允许下发:{}======", Convert.toInt(byteTransform.TransInt16(read2.Content, 8)));
|
||||
deviceTsj.setXtxh(Convert.toInt(byteTransform.TransInt16(read2.Content, 10)));
|
||||
log.info("=====读取到提升机心跳信号:{}======", Convert.toInt(byteTransform.TransInt16(read2.Content, 10)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ConnectServer() {
|
||||
siemensS7Net = new SiemensS7Net(SiemensPLCS.S1500);
|
||||
modbusTcpNet = new ModbusTcpNet();
|
||||
try {
|
||||
siemensS7Net.setIpAddress(this.ip);
|
||||
siemensS7Net.setPort(this.port);
|
||||
siemensS7Net.setRack((byte) 0);
|
||||
siemensS7Net.setSlot((byte) 1);
|
||||
|
||||
OperateResult connect = siemensS7Net.ConnectServer();
|
||||
modbusTcpNet.setIpAddress(this.ip);
|
||||
modbusTcpNet.setPort(this.port);
|
||||
modbusTcpNet.setStation((byte) 1);
|
||||
this.byteTransform = modbusTcpNet.getByteTransform();
|
||||
OperateResult connect = modbusTcpNet.ConnectServer();
|
||||
if (connect.IsSuccess) {
|
||||
setIsConnect(true);
|
||||
readWriteNet = siemensS7Net;
|
||||
readWriteNet = modbusTcpNet;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
log.info("********IP:" + this.ip + " port:" + this.port + "连接失败 " + ex.getMessage());
|
||||
log.info("********IP:{} port:{}提升机连接失败 {}", this.ip, this.port, ex.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -122,7 +145,7 @@ public class PlcTsjRead implements Runnable {
|
||||
void reConnect() {
|
||||
closeServer();
|
||||
ConnectServer();
|
||||
log.info("重新连接 SSJ-PLC");
|
||||
log.info("重新连接提升机PLC");
|
||||
}
|
||||
|
||||
void closeServer() {
|
||||
@@ -132,5 +155,50 @@ public class PlcTsjRead implements Runnable {
|
||||
setIsConnect(false);
|
||||
}
|
||||
|
||||
public static int writeToTsj(String taskNo, int rwlx, int hwly , int qx ,int completed) {
|
||||
List<SendData2> sendDataList = new ArrayList<>();
|
||||
sendDataList.add(new SendData2("1000", taskNo, 2));
|
||||
sendDataList.add(new SendData2("1002", String.valueOf(rwlx), 1));
|
||||
sendDataList.add(new SendData2("1003", String.valueOf(hwly), 1));
|
||||
sendDataList.add(new SendData2("1004", String.valueOf(qx), 1));
|
||||
sendDataList.add(new SendData2("1005", String.valueOf(completed), 1));
|
||||
int jym = Tools.getJYM(Integer.parseInt(taskNo),rwlx,hwly,qx,completed);
|
||||
sendDataList.add(new SendData2("1006", String.valueOf(jym), 1));
|
||||
int b = 1;
|
||||
for (SendData2 sendData : sendDataList) {
|
||||
String address = sendData.getAddress();
|
||||
String data = sendData.getData();
|
||||
String[] split = data.split(",");
|
||||
int type = sendData.getType();
|
||||
if (type == 2) {
|
||||
int[] intData = Arrays.stream(split)
|
||||
.map(String::trim)
|
||||
.mapToInt(Integer::parseInt)
|
||||
.toArray();
|
||||
boolean write = PlcSsjRead.Write(address, intData);
|
||||
if (!write) {
|
||||
b = 0;
|
||||
break;
|
||||
}
|
||||
} else if (type == 1) {
|
||||
short[] shortData = new short[split.length];
|
||||
for (int i = 0; i < split.length; i++) {
|
||||
try {
|
||||
shortData[i] = Short.parseShort(split[i].trim());
|
||||
} catch (NumberFormatException e) {
|
||||
shortData[i] = 0;
|
||||
}
|
||||
}
|
||||
boolean write = PlcSsjRead.Write(address, shortData);
|
||||
if (!write) {
|
||||
b = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
String collect = sendDataList.stream().map(li -> "{" + li.getAddress() + ":" + li.getData() + "}").collect(Collectors.joining(","));
|
||||
log.info("提升机下发完成,下发值:{},,结果:{}", collect, b);
|
||||
return b;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,34 +5,33 @@ import com.ruoyi.device.ddj.service.IMsgDdjService;
|
||||
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.service.IDeviceTsjService;
|
||||
import com.ruoyi.device.tsj.service.impl.DeviceTsjServiceImpl;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 监控线程
|
||||
*/
|
||||
@Slf4j
|
||||
public class MonitoringThread implements Runnable {
|
||||
|
||||
public boolean isRun = true;
|
||||
|
||||
private IDeviceSsjService deviceSsjService;
|
||||
private IMsgDdjService msgDdjService;
|
||||
private IDeviceSrgvService deviceSrgvService;
|
||||
|
||||
private DeviceTsjServiceImpl deviceTsjService;
|
||||
|
||||
public void init() {
|
||||
deviceSsjService = SpringUtils.getBean(IDeviceSsjService.class);
|
||||
msgDdjService = SpringUtils.getBean(IMsgDdjService.class);
|
||||
deviceSrgvService = SpringUtils.getBean(IDeviceSrgvService.class);
|
||||
deviceTsjService = SpringUtils.getBean(DeviceTsjServiceImpl.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
init();
|
||||
while (isRun){
|
||||
while (isRun) {
|
||||
for (String ssjCode : PlcSsjRead.deviceSsjMap.keySet()) {
|
||||
DeviceSsj deviceSsj = PlcSsjRead.deviceSsjMap.get(ssjCode);
|
||||
deviceSsj.setTraySize(deviceSsj.getModel());
|
||||
@@ -43,14 +42,14 @@ public class MonitoringThread implements Runnable {
|
||||
deviceSrgvService.updateDeviceSrgv(PlcSrgvRead.deviceSrgvMap.get(sRgv));
|
||||
}
|
||||
|
||||
|
||||
for (String tsj : PlcTsjRead.deviceTsjMap.keySet()) {
|
||||
deviceTsjService.updateDeviceTsj(PlcTsjRead.deviceTsjMap.get(tsj));
|
||||
}
|
||||
try {
|
||||
Thread.sleep(1500);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,11 +14,14 @@ import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import com.ruoyi.device.cdz.domain.DeviceCdz;
|
||||
import com.ruoyi.device.srgv.domain.DeviceSrgv;
|
||||
import com.ruoyi.device.srgv.service.IDeviceSrgvService;
|
||||
import com.ruoyi.device.srgv.service.impl.DeviceSrgvServiceImpl;
|
||||
import com.ruoyi.device.tsj.domain.DeviceTsj;
|
||||
import com.ruoyi.job.charg.domain.SrgvChargingJob;
|
||||
import com.ruoyi.job.charg.service.ISrgvChargingJobService;
|
||||
import com.ruoyi.job.domain.JobCallBack;
|
||||
import com.ruoyi.job.domain.MydoJob;
|
||||
import com.ruoyi.job.service.IMydoJobService;
|
||||
import com.ruoyi.job.service.impl.JobCallBackServiceImpl;
|
||||
import com.ruoyi.queue.srgv.domain.WcsSrgvQueue;
|
||||
import com.ruoyi.queue.srgv.service.IWcsSrgvQueueFinishService;
|
||||
import com.ruoyi.queue.srgv.service.IWcsSrgvQueueService;
|
||||
@@ -63,13 +66,14 @@ public class BaseSRgvThread implements Runnable, SRgvThreadInterface {
|
||||
|
||||
public IDeviceSrgvService deviceSrgvService;
|
||||
|
||||
public JobCallBackServiceImpl jobCallBackService;
|
||||
|
||||
|
||||
public void init() {
|
||||
sRgvCodeList = new HashMap<>();
|
||||
ArrayList<String> sRgvCodes = new ArrayList<>();
|
||||
sRgvCodes.add("1");
|
||||
sRgvCodes.add("2");
|
||||
sRgvCodes.add("3");
|
||||
// sRgvCodes.add("2");
|
||||
sRgvCodeList.put("srgv", sRgvCodes);
|
||||
|
||||
wcsSagvQueueMapper = SpringUtils.getBean(IWcsSrgvQueueService.class);
|
||||
@@ -79,6 +83,7 @@ public class BaseSRgvThread implements Runnable, SRgvThreadInterface {
|
||||
mydoJobService = SpringUtils.getBean(IMydoJobService.class);
|
||||
wcsSrgvMapService = SpringUtils.getBean(IWcsSrgvMapService.class);
|
||||
roadCacheService = SpringUtils.getBean(RoadCacheService.class);
|
||||
deviceSrgvService = SpringUtils.getBean(DeviceSrgvServiceImpl.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -139,10 +144,10 @@ public class BaseSRgvThread implements Runnable, SRgvThreadInterface {
|
||||
for (SrgvChargingJob srgvChargingJob : srgvChargingJobs) {
|
||||
String chargingId = srgvChargingJob.getChargingId();
|
||||
DeviceCdz deviceCdz = PlcCdzRead.deviceCdzMap.get(chargingId);
|
||||
if (ObjUtil.isNotNull(deviceCdz)){
|
||||
if (ObjUtil.isNotNull(deviceCdz)) {
|
||||
//下发断电任务
|
||||
int i = PlcCdzRead.WriteToCdz("", null);
|
||||
if (i == 1){
|
||||
if (i == 1) {
|
||||
srgvChargingJobMapper.insertHistory(srgvChargingJob.getGuid());
|
||||
srgvChargingJobMapper.deleteSrgvChargingJobByGuid(srgvChargingJob.getGuid());
|
||||
}
|
||||
@@ -165,15 +170,15 @@ public class BaseSRgvThread implements Runnable, SRgvThreadInterface {
|
||||
List<SrgvChargingJob> srgvChargingJobs = srgvChargingJobMapper.selectSrgvChargingJobList(param);
|
||||
if (CollUtil.isNotEmpty(srgvChargingJobs)) {
|
||||
SrgvChargingJob srgvChargingJob = srgvChargingJobs.get(0);
|
||||
if ("1".equals(srgvChargingJob.getChargingStatus())){
|
||||
//初始状态
|
||||
if ("1".equals(srgvChargingJob.getChargingStatus())) {
|
||||
//初始状态
|
||||
|
||||
//判断小车和充电桩是否在同一层
|
||||
//判断小车和充电桩是否在同一层
|
||||
String agvId = srgvChargingJob.getAgvId();
|
||||
String chargingId = srgvChargingJob.getChargingId();
|
||||
DeviceSrgv srgv = PlcSrgvRead.deviceSrgvMap.get(agvId);
|
||||
DeviceCdz cdz = PlcCdzRead.deviceCdzMap.get(chargingId);
|
||||
if (srgv.getCurrFloor().equals(cdz.getSzcs())){
|
||||
if (srgv.getCurrFloor().equals(cdz.getSzcs())) {
|
||||
//生成四向小车充电队列
|
||||
String chargingSite = srgvChargingJob.getChargingSite();//充电桩站点
|
||||
WcsSrgvQueue wcsSrgvQueueParam = new WcsSrgvQueue();
|
||||
@@ -181,18 +186,18 @@ public class BaseSRgvThread implements Runnable, SRgvThreadInterface {
|
||||
List<WcsSrgvQueue> wcsSrgvQueues = wcsSagvQueueMapper.selectWcsSrgvQueueList(wcsSrgvQueueParam);
|
||||
if (CollUtil.isEmpty(wcsSrgvQueues)) {
|
||||
//生成队列
|
||||
createSrgvChargingQueue(deviceSrgv, chargingSite,"8");
|
||||
createSrgvChargingQueue(deviceSrgv, chargingSite, "3");
|
||||
srgvChargingJob.setJobStatus("3");
|
||||
srgvChargingJobMapper.updateSrgvChargingJob(srgvChargingJob);
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
//生成四向小车换层队列
|
||||
WcsSrgvQueue wcsSrgvQueueParam = new WcsSrgvQueue();
|
||||
wcsSrgvQueueParam.setAgvId(deviceSrgv.getDeviceId().toString());
|
||||
String chargingSite = srgvChargingJob.getChargingSite();//充电桩站点
|
||||
List<WcsSrgvQueue> wcsSrgvQueues = wcsSagvQueueMapper.selectWcsSrgvQueueList(wcsSrgvQueueParam);
|
||||
if (CollUtil.isEmpty(wcsSrgvQueues)) {
|
||||
createSrgvChargingQueue(deviceSrgv, chargingSite,"4");
|
||||
createSrgvChargingQueue(deviceSrgv, chargingSite, "8");
|
||||
srgvChargingJob.setJobStatus("2");
|
||||
srgvChargingJobMapper.updateSrgvChargingJob(srgvChargingJob);
|
||||
}
|
||||
@@ -203,7 +208,7 @@ public class BaseSRgvThread implements Runnable, SRgvThreadInterface {
|
||||
}
|
||||
}
|
||||
|
||||
private void createSrgvChargingQueue(DeviceSrgv deviceSrgv, String chargingSite,String type) {
|
||||
private void createSrgvChargingQueue(DeviceSrgv deviceSrgv, String chargingSite, String type) {
|
||||
WcsSrgvQueue wcsSrgvQueue = new WcsSrgvQueue();
|
||||
wcsSrgvQueue.setGuid(UUID.randomUUID().toString());
|
||||
wcsSrgvQueue.setTaskNo("");
|
||||
@@ -216,9 +221,9 @@ public class BaseSRgvThread implements Runnable, SRgvThreadInterface {
|
||||
wcsSrgvQueue.setCargoPlaceSite("");
|
||||
wcsSrgvQueue.setStartSite(deviceSrgv.getCurrSite());
|
||||
WcsSrgvMap wcsSrgvMap = wcsSrgvMapService.selectWcsSrgvMapBySiteId(chargingSite);
|
||||
if ("4".equals(type)){
|
||||
if ("8".equals(type)) {
|
||||
wcsSrgvQueue.setEndSite("tsj");
|
||||
}else if ("8".equals(type)){
|
||||
} else if ("3".equals(type)) {
|
||||
wcsSrgvQueue.setEndSite(chargingSite);
|
||||
}
|
||||
wcsSrgvQueue.setTheFloor(deviceSrgv.getCurrFloor().toString());
|
||||
@@ -236,7 +241,7 @@ public class BaseSRgvThread implements Runnable, SRgvThreadInterface {
|
||||
//处理队列下发
|
||||
resQueue(deviceSrgv);
|
||||
|
||||
//小车完成队列
|
||||
// 小车完成队列
|
||||
completeCarTask(deviceSrgv);
|
||||
|
||||
//小车发送任务
|
||||
@@ -245,17 +250,14 @@ public class BaseSRgvThread implements Runnable, SRgvThreadInterface {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 生成入库小车队列
|
||||
*/
|
||||
private void createCarQueue(DeviceSrgv deviceSrgv) {
|
||||
|
||||
if(deviceSrgv.getWorkMode()==4 && deviceSrgv.getStatus()==1) {
|
||||
if (deviceSrgv.getWorkMode() == 5 && deviceSrgv.getStatus() == 1) {
|
||||
WcsSrgvQueue wcsSrgvQueue = wcsSagvQueueMapper.selectWcsSrgvQueueByAgvId(deviceSrgv.getDeviceId().toString());
|
||||
|
||||
if (wcsSrgvQueue == null) {
|
||||
|
||||
//找小车当前层作业,生成队列
|
||||
//如果没有当前层作业,就找最近层换层作业,生成队列
|
||||
MydoJob mydoJob1 = new MydoJob();
|
||||
@@ -267,7 +269,7 @@ public class BaseSRgvThread implements Runnable, SRgvThreadInterface {
|
||||
List<MydoJob> mydoJobs = mydoJobService.selectMydoJobList(mydoJob1);
|
||||
if (!mydoJobs.isEmpty()) {
|
||||
//生成了从小车现在位置到提升机接货的队列
|
||||
createCarQueue(mydoJobs.get(0), deviceSrgv, "4","0");
|
||||
createCarQueue(mydoJobs.get(0), deviceSrgv, "4", "0");
|
||||
} else {
|
||||
MydoJob mydoJob = new MydoJob();
|
||||
mydoJob.setInOut("2");
|
||||
@@ -278,7 +280,7 @@ public class BaseSRgvThread implements Runnable, SRgvThreadInterface {
|
||||
if (!mydoJobs1.isEmpty()) {
|
||||
//找最外层作业存储过程
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("v_layer",deviceSrgv.getCurrFloor());
|
||||
map.put("v_layer", deviceSrgv.getCurrFloor());
|
||||
mydoJobService.selectMydoJobOutside(map);
|
||||
String jobId = map.get("v_job_ids").toString();
|
||||
MydoJob mydoJob2 = mydoJobService.selectMydoJobByJobId(jobId);
|
||||
@@ -286,45 +288,40 @@ public class BaseSRgvThread implements Runnable, SRgvThreadInterface {
|
||||
WcsSrgvMap wcsSrgvMap = new WcsSrgvMap();
|
||||
wcsSrgvMap.setCargoSpaceId(mydoJob2.getCargoSpaceId());
|
||||
List<WcsSrgvMap> wcsSrgvMaps = wcsSrgvMapService.selectWcsSrgvMapList(wcsSrgvMap);
|
||||
if(!deviceSrgv.getCurrSite().equals(wcsSrgvMaps.get(0).getSiteId())){
|
||||
createCarQueue(mydoJob2, deviceSrgv, "4","0");
|
||||
}else{
|
||||
createCarQueue(mydoJob2, deviceSrgv, "4","1");
|
||||
if (!deviceSrgv.getCurrSite().equals(wcsSrgvMaps.get(0).getSiteId())) {
|
||||
createCarQueue(mydoJob2, deviceSrgv, "4", "0");
|
||||
} else {
|
||||
createCarQueue(mydoJob2, deviceSrgv, "4", "1");
|
||||
}
|
||||
|
||||
} else {
|
||||
//别的层的出库作业和入库作业
|
||||
|
||||
MydoJob job=null;
|
||||
MydoJob job = null;
|
||||
MydoJob mydoJob3 = new MydoJob();
|
||||
mydoJob3.setStatus("3");
|
||||
mydoJob3.setInOut("1");
|
||||
//todo 输送机阶段
|
||||
mydoJob3.setExecutionPhase("1");
|
||||
List<MydoJob> mydoJobs4 = mydoJobService.selectMydoJobList(mydoJob3);
|
||||
if(!mydoJobs4.isEmpty()){
|
||||
job=mydoJobs4.get(0);
|
||||
}else{
|
||||
if (!mydoJobs4.isEmpty()) {
|
||||
job = mydoJobs4.get(0);
|
||||
} else {
|
||||
MydoJob mydoJob2 = new MydoJob();
|
||||
mydoJob2.setInOut("2");
|
||||
mydoJob2.setStatus("1");
|
||||
List<MydoJob> mydoJobs3 = mydoJobService.selectMydoJobList(mydoJob2);
|
||||
if(!mydoJobs3.isEmpty()){
|
||||
job=mydoJobs3.get(0);
|
||||
if (!mydoJobs3.isEmpty()) {
|
||||
job = mydoJobs3.get(0);
|
||||
}
|
||||
}
|
||||
if(job!=null) {
|
||||
|
||||
if (job != null) {
|
||||
//判断那层没有小车,并且没有要去那层的小车队列,查监控表
|
||||
//生成换层任务
|
||||
|
||||
|
||||
DeviceSrgv deviceSrgv1 = new DeviceSrgv();
|
||||
deviceSrgv1.setCurrFloor(Convert.toInt(job.getTheFloor()));
|
||||
List<DeviceSrgv> srgvs = deviceSrgvService.selectDeviceSrgvList(deviceSrgv1);
|
||||
//这个作业的目标层没有小车
|
||||
if (srgvs.isEmpty()) {
|
||||
|
||||
WcsSrgvQueue wcsSrgvQueue1 = new WcsSrgvQueue();
|
||||
wcsSrgvQueue1.setDefault07(job.getTheFloor());
|
||||
// wcsSrgvQueue1.setTaskType("3");
|
||||
@@ -334,27 +331,29 @@ public class BaseSRgvThread implements Runnable, SRgvThreadInterface {
|
||||
createCarQueue(job, deviceSrgv, "8", "0");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
} else{
|
||||
if ( "1".equals(wcsSrgvQueue.getIssued())) {
|
||||
} else {
|
||||
if ("1".equals(wcsSrgvQueue.getIssued())) {
|
||||
MydoJob mydoJob = mydoJobService.selectMydoJobByTaskNo(Convert.toLong(wcsSrgvQueue.getTaskNo()));
|
||||
if (mydoJob != null){
|
||||
if (mydoJob != null) {
|
||||
if (deviceSrgv.getCurrSite().equals(wcsSrgvQueue.getEndSite()) && "1".equals(wcsSrgvQueue.getTaskType())) {
|
||||
//TODO 调用WMS完成作业接口 定时器回传完成作业
|
||||
JobCallBack jobCallBack = new JobCallBack();
|
||||
jobCallBack.setType("1");
|
||||
jobCallBack.setMydojobId(mydoJob.getJobId());
|
||||
jobCallBack.setStatus("0");
|
||||
jobCallBack.setTaskNo(Convert.toLong(mydoJob.getTaskNo()));
|
||||
jobCallBack.setCreateTime(new Date());
|
||||
jobCallBackService.insertJobCallBack(jobCallBack);
|
||||
// todo 通知wms入库完成 完成队列 完成作业
|
||||
wcsSagvQueueMapper.insertHistory(wcsSrgvQueue.getTaskNo());
|
||||
wcsSagvQueueMapper.deleteWcsSrgvQueueByGuid(wcsSrgvQueue.getGuid());
|
||||
|
||||
mydoJobService.insertHistory(mydoJob.getJobId());
|
||||
mydoJobService.deleteMydoJobByJobId(mydoJob.getJobId());
|
||||
|
||||
} else if (deviceSrgv.getCurrSite().equals(wcsSrgvQueue.getDefault03()) && "2".equals(wcsSrgvQueue.getTaskType())) {
|
||||
//完成队列 更新作业阶段
|
||||
wcsSagvQueueMapper.insertHistory(wcsSrgvQueue.getTaskNo());
|
||||
@@ -362,24 +361,24 @@ public class BaseSRgvThread implements Runnable, SRgvThreadInterface {
|
||||
//提升机修改阶段
|
||||
// mydoJob.setExecutionPhase("");
|
||||
// mydoJobService.updateMydoJob(mydoJob);
|
||||
} else if (deviceSrgv.getCurrSite().equals(wcsSrgvQueue.getEndSite()) && "4".equals(wcsSrgvQueue.getTaskType())) {
|
||||
} else if (deviceSrgv.getCurrSite().equals(wcsSrgvQueue.getDefault03()) && "4".equals(wcsSrgvQueue.getTaskType())) {
|
||||
//根据任务类型 ,生成队列
|
||||
if (Convert.toInt(mydoJob.getInOrOut()) < 20) {
|
||||
wcsSagvQueueMapper.insertHistory(wcsSrgvQueue.getTaskNo());
|
||||
wcsSagvQueueMapper.deleteWcsSrgvQueueByGuid(wcsSrgvQueue.getGuid());
|
||||
|
||||
createCarQueue(mydoJob, deviceSrgv, "1","0");
|
||||
createCarQueue(mydoJob, deviceSrgv, "1", "0");
|
||||
} else {
|
||||
wcsSagvQueueMapper.insertHistory(wcsSrgvQueue.getTaskNo());
|
||||
wcsSagvQueueMapper.deleteWcsSrgvQueueByGuid(wcsSrgvQueue.getGuid());
|
||||
createCarQueue(mydoJob, deviceSrgv, "2","0");
|
||||
createCarQueue(mydoJob, deviceSrgv, "2", "0");
|
||||
}
|
||||
}else if(deviceSrgv.getCurrSite().equals(wcsSrgvQueue.getDefault03()) && "8".equals(wcsSrgvQueue.getTaskType())){
|
||||
} else if (deviceSrgv.getCurrSite().equals(wcsSrgvQueue.getDefault03()) && "8".equals(wcsSrgvQueue.getTaskType())) {
|
||||
wcsSagvQueueMapper.insertHistory(wcsSrgvQueue.getTaskNo());
|
||||
wcsSagvQueueMapper.deleteWcsSrgvQueueByGuid(wcsSrgvQueue.getGuid());
|
||||
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
//查询充电任务
|
||||
SrgvChargingJob srgvChargingJob = new SrgvChargingJob();
|
||||
srgvChargingJob.setAgvId(String.valueOf(wcsSrgvQueue.getAgvId()));
|
||||
@@ -387,9 +386,9 @@ public class BaseSRgvThread implements Runnable, SRgvThreadInterface {
|
||||
srgvChargingJob.setJobStatus("2");
|
||||
srgvChargingJob.setJobType("1");
|
||||
List<SrgvChargingJob> srgvChargingJobs = srgvChargingJobMapper.selectSrgvChargingJobList(srgvChargingJob);
|
||||
if (!srgvChargingJobs.isEmpty()){
|
||||
if (!srgvChargingJobs.isEmpty()) {
|
||||
SrgvChargingJob srgvChargingJob1 = srgvChargingJobs.get(0);
|
||||
if ( deviceSrgv.getCurrSite().equals(wcsSrgvQueue.getDefault03()) && "4".equals(wcsSrgvQueue.getTaskType())) {
|
||||
if (deviceSrgv.getCurrSite().equals(wcsSrgvQueue.getDefault03()) && "4".equals(wcsSrgvQueue.getTaskType())) {
|
||||
//查询换层任务
|
||||
wcsSagvQueueMapper.insertHistory(wcsSrgvQueue.getTaskNo());
|
||||
wcsSagvQueueMapper.deleteWcsSrgvQueueByGuid(wcsSrgvQueue.getGuid());
|
||||
@@ -398,53 +397,49 @@ public class BaseSRgvThread implements Runnable, SRgvThreadInterface {
|
||||
srgvChargingJobMapper.updateSrgvChargingJob(srgvChargingJob1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void createCarQueue(MydoJob mydoJob1, DeviceSrgv deviceSrgv,String taskType,String issued) {
|
||||
private void createCarQueue(MydoJob mydoJob1, DeviceSrgv deviceSrgv, String taskType, String issued) {
|
||||
WcsSrgvQueue wcsSrgvQueue = new WcsSrgvQueue();
|
||||
wcsSrgvQueue.setGuid(UUID.randomUUID().toString());
|
||||
wcsSrgvQueue.setTaskNo(mydoJob1.getTaskNo());
|
||||
wcsSrgvQueue.setTaskType(taskType);
|
||||
wcsSrgvQueue.setPriority(Long.parseLong("2"));
|
||||
// wcsSrgvQueue.setCargo("1");
|
||||
wcsSrgvQueue.setIssued(issued);
|
||||
wcsSrgvQueue.setExecutionStatus("1");
|
||||
// wcsSrgvQueue.setCargoPlaceSite("tsj");
|
||||
WcsSrgvMap wcsSrgvMap1 = new WcsSrgvMap();
|
||||
//TODO 小车取货之后会不会退出来,会退出来是4 不会退出来是3
|
||||
wcsSrgvMap1.setTheRow(4);
|
||||
wcsSrgvMap1.setTheColumn(5);
|
||||
wcsSrgvMap1.setTheLayer(Convert.toInt(mydoJob1.getTheFloor()));
|
||||
List<WcsSrgvMap> wcsSrgvMaps1 = wcsSrgvMapService.selectWcsSrgvMapList(wcsSrgvMap1);
|
||||
|
||||
if(Integer.parseInt(mydoJob1.getInOrOut())<20 && "4".equals(taskType)){
|
||||
//点到点任务
|
||||
if (Integer.parseInt(mydoJob1.getInOrOut()) < 20 && "4".equals(taskType)) {
|
||||
wcsSrgvQueue.setStartSite(deviceSrgv.getCurrSite());
|
||||
wcsSrgvQueue.setEndSite("tsj");
|
||||
//每一层的停靠点
|
||||
//入库的点到点直接进入提升机 不选停靠点
|
||||
wcsSrgvMap1.setTheRow(3);
|
||||
wcsSrgvMap1.setTheColumn(5);
|
||||
wcsSrgvMap1.setTheLayer(Convert.toInt(mydoJob1.getTheFloor()));
|
||||
wcsSrgvMaps1 = wcsSrgvMapService.selectWcsSrgvMapList(wcsSrgvMap1);
|
||||
wcsSrgvQueue.setDefault03(wcsSrgvMaps1.get(0).getSiteId());
|
||||
}
|
||||
else if(Integer.parseInt(mydoJob1.getInOrOut())<20 && "1".equals(taskType)){
|
||||
} else if (Integer.parseInt(mydoJob1.getInOrOut()) < 20 && "1".equals(taskType)) {
|
||||
wcsSrgvQueue.setStartSite("tsj");
|
||||
WcsSrgvMap wcsSrgvMap = new WcsSrgvMap();
|
||||
wcsSrgvMap.setCargoSpaceId(mydoJob1.getCargoSpaceId());
|
||||
List<WcsSrgvMap> wcsSrgvMaps = wcsSrgvMapService.selectWcsSrgvMapList(wcsSrgvMap);
|
||||
wcsSrgvQueue.setEndSite(wcsSrgvMaps.get(0).getSiteId());
|
||||
//每一层的停靠点
|
||||
//入库的点到点从030501 到目标货位
|
||||
wcsSrgvMap1.setTheRow(3);
|
||||
wcsSrgvMap1.setTheColumn(5);
|
||||
wcsSrgvMap1.setTheLayer(Convert.toInt(mydoJob1.getTheFloor()));
|
||||
wcsSrgvMaps1 = wcsSrgvMapService.selectWcsSrgvMapList(wcsSrgvMap1);
|
||||
wcsSrgvQueue.setDefault03(wcsSrgvMaps1.get(0).getSiteId());
|
||||
}
|
||||
else if(Integer.parseInt(mydoJob1.getInOrOut())>=20 && "4".equals(taskType)){
|
||||
} else if (Integer.parseInt(mydoJob1.getInOrOut()) >= 20 && "4".equals(taskType)) {
|
||||
wcsSrgvQueue.setStartSite(deviceSrgv.getCurrSite());
|
||||
WcsSrgvMap wcsSrgvMap = new WcsSrgvMap();
|
||||
wcsSrgvMap.setCargoSpaceId(mydoJob1.getCargoSpaceId());
|
||||
@@ -452,20 +447,16 @@ public class BaseSRgvThread implements Runnable, SRgvThreadInterface {
|
||||
wcsSrgvQueue.setEndSite(wcsSrgvMaps.get(0).getSiteId());
|
||||
//每一层的停靠点
|
||||
wcsSrgvQueue.setDefault03(wcsSrgvMaps1.get(0).getSiteId());
|
||||
}
|
||||
else if(Integer.parseInt(mydoJob1.getInOrOut())>=20 && "2".equals(taskType)){
|
||||
} else if (Integer.parseInt(mydoJob1.getInOrOut()) >= 20 && "2".equals(taskType)) {
|
||||
wcsSrgvQueue.setStartSite(deviceSrgv.getCurrSite());
|
||||
wcsSrgvQueue.setEndSite("tsj");
|
||||
//每一层的停靠点
|
||||
wcsSrgvQueue.setDefault03(wcsSrgvMaps1.get(0).getSiteId());
|
||||
}
|
||||
else if("8".equals(taskType)){
|
||||
} else if ("8".equals(taskType)) {
|
||||
wcsSrgvQueue.setStartSite(deviceSrgv.getCurrSite());
|
||||
wcsSrgvQueue.setEndSite("tsj");
|
||||
wcsSrgvQueue.setDefault03(wcsSrgvMaps1.get(0).getSiteId());
|
||||
}
|
||||
|
||||
|
||||
wcsSrgvQueue.setTheFloor(deviceSrgv.getCurrFloor().toString());
|
||||
wcsSrgvQueue.setCreateDate(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
||||
wcsSrgvQueue.setAgvId(deviceSrgv.getDeviceId().toString());
|
||||
@@ -487,9 +478,16 @@ public class BaseSRgvThread implements Runnable, SRgvThreadInterface {
|
||||
}
|
||||
for (WcsSrgvQueue wcsSrgvQueue : wcsSrgvQueues) {
|
||||
String agvId = wcsSrgvQueue.getAgvId();
|
||||
if (agvId.equals(Convert.toStr(deviceSrgv.getDeviceId())) && deviceSrgv.getWorkMode() == 4 && deviceSrgv.getAllowSend() == 1) {
|
||||
String startSite = wcsSrgvQueue.getStartSite();
|
||||
String endSite = wcsSrgvQueue.getEndSite();
|
||||
if (agvId.equals(Convert.toStr(deviceSrgv.getDeviceId())) //agvID和小车ID一致
|
||||
&& deviceSrgv.getWorkMode() == 5//工作模式联机自动
|
||||
&& deviceSrgv.getStatus() == 1//小车状态为待机
|
||||
&& deviceSrgv.getWorkPhase() == 0 //执行阶段待机
|
||||
&& deviceSrgv.getAllowSend() == 1 //允许下发
|
||||
) {
|
||||
//处理tsj站点 换层去提升机前 入库去提升机里 出库去提升机里
|
||||
|
||||
String startSite = getSite(wcsSrgvQueue.getStartSite(),wcsSrgvQueue.getTheFloor(),wcsSrgvQueue.getTaskType());
|
||||
String endSite = getSite(wcsSrgvQueue.getEndSite(),wcsSrgvQueue.getTheFloor(),wcsSrgvQueue.getTaskType());
|
||||
String currSite = deviceSrgv.getCurrSite();
|
||||
//判断是否可以下发任务
|
||||
if ("0".equals(wcsSrgvQueue.getIssued()) && deviceSrgv.getStatus() == 1) {
|
||||
@@ -524,8 +522,8 @@ public class BaseSRgvThread implements Runnable, SRgvThreadInterface {
|
||||
//判断是否能规划出最短路径
|
||||
if (shortestPath == null || shortestPath.isEmpty()) {
|
||||
//判断是否是1层 空车取货 或者 满车放货
|
||||
if (floor==1){
|
||||
if ("2".equals(wcsSrgvQueue.getDefault02()) && "tsj".equals(wcsSrgvQueue.getStartSite()) && wcsSrgvQueue.getEndSite().equals(wcsSrgvQueue.getCargoPlaceSite())){
|
||||
if (floor == 1) {
|
||||
if ("2".equals(wcsSrgvQueue.getDefault02()) && "tsj".equals(wcsSrgvQueue.getStartSite()) && wcsSrgvQueue.getEndSite().equals(wcsSrgvQueue.getCargoPlaceSite())) {
|
||||
//1层满车放货
|
||||
//修改终点到出库缓存点
|
||||
WcsSrgvMap wcsSrgvMapParam = new WcsSrgvMap();
|
||||
@@ -537,12 +535,12 @@ public class BaseSRgvThread implements Runnable, SRgvThreadInterface {
|
||||
currentSRgvSite.add(PlcSrgvRead.deviceSrgvMap.get(srgvCode).getCurrSite());
|
||||
}
|
||||
cacheSite.removeAll(currentSRgvSite);
|
||||
if (CollUtil.isNotEmpty(cacheSite)){
|
||||
if (CollUtil.isNotEmpty(cacheSite)) {
|
||||
for (String cache : cacheSite) {
|
||||
WcsSrgvQueue wcsSrgvQueueParam = new WcsSrgvQueue();
|
||||
wcsSrgvQueueParam.setEndSite(cache);
|
||||
List<WcsSrgvQueue> wcsSrgvQueues = wcsSagvQueueMapper.selectWcsSrgvQueueList(wcsSrgvQueueParam);
|
||||
if (CollUtil.isEmpty(wcsSrgvQueues)){
|
||||
if (CollUtil.isEmpty(wcsSrgvQueues)) {
|
||||
wcsSrgvQueue.setEndSite(cacheSite.get(0));
|
||||
wcsSagvQueueMapper.updateWcsSrgvQueue(wcsSrgvQueue);
|
||||
break;
|
||||
@@ -551,7 +549,7 @@ public class BaseSRgvThread implements Runnable, SRgvThreadInterface {
|
||||
|
||||
}
|
||||
}
|
||||
if ("4".equals(wcsSrgvQueue.getDefault02()) && "tsj".equals(wcsSrgvQueue.getStartSite()) && wcsSrgvQueue.getEndSite().equals(wcsSrgvQueue.getCargoPickSite())){
|
||||
if ("4".equals(wcsSrgvQueue.getDefault02()) && "tsj".equals(wcsSrgvQueue.getStartSite()) && wcsSrgvQueue.getEndSite().equals(wcsSrgvQueue.getCargoPickSite())) {
|
||||
//1层空车取货
|
||||
//修改终点到避让点
|
||||
WcsSrgvMap wcsSrgvMapParam = new WcsSrgvMap();
|
||||
@@ -563,12 +561,12 @@ public class BaseSRgvThread implements Runnable, SRgvThreadInterface {
|
||||
currentSRgvSite.add(PlcSrgvRead.deviceSrgvMap.get(srgvCode).getCurrSite());
|
||||
}
|
||||
cacheSite.removeAll(currentSRgvSite);
|
||||
if (CollUtil.isNotEmpty(cacheSite)){
|
||||
if (CollUtil.isNotEmpty(cacheSite)) {
|
||||
for (String cache : cacheSite) {
|
||||
WcsSrgvQueue wcsSrgvQueueParam = new WcsSrgvQueue();
|
||||
wcsSrgvQueueParam.setEndSite(cache);
|
||||
List<WcsSrgvQueue> wcsSrgvQueues = wcsSagvQueueMapper.selectWcsSrgvQueueList(wcsSrgvQueueParam);
|
||||
if (CollUtil.isEmpty(wcsSrgvQueues)){
|
||||
if (CollUtil.isEmpty(wcsSrgvQueues)) {
|
||||
wcsSrgvQueue.setEndSite(cacheSite.get(0));
|
||||
wcsSagvQueueMapper.updateWcsSrgvQueue(wcsSrgvQueue);
|
||||
break;
|
||||
@@ -620,17 +618,46 @@ public class BaseSRgvThread implements Runnable, SRgvThreadInterface {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (endSite.equals("tsj")) {
|
||||
switch (wcsSrgvQueue.getTheFloor()) {
|
||||
case "1":
|
||||
endSite = "030501";
|
||||
break;
|
||||
case "2":
|
||||
endSite = "030502";
|
||||
break;
|
||||
case "3":
|
||||
endSite = "030503";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (startSite.equals("tsj")) {
|
||||
switch (wcsSrgvQueue.getTheFloor()) {
|
||||
case "1":
|
||||
startSite = "030501";
|
||||
break;
|
||||
case "2":
|
||||
startSite = "030502";
|
||||
break;
|
||||
case "3":
|
||||
startSite = "030503";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
List<SendData2> sendDataList = new ArrayList<>();
|
||||
if (!trun.isEmpty()) {
|
||||
SendData2 path = new SendData2();
|
||||
path.setAddress("4000");//地址
|
||||
path.setAddress("4004");//地址
|
||||
path.setData(startSite + "," + endSite + "," + turnBuilder);
|
||||
path.setType(2);
|
||||
sendDataList.add(path);
|
||||
} else {
|
||||
SendData2 path = new SendData2();
|
||||
path.setAddress("4000");//地址
|
||||
path.setAddress("4004");//地址
|
||||
path.setData(startSite + "," + endSite);
|
||||
path.setType(2);
|
||||
sendDataList.add(path);
|
||||
@@ -638,29 +665,44 @@ public class BaseSRgvThread implements Runnable, SRgvThreadInterface {
|
||||
|
||||
|
||||
//任务号、原、目标数据转换
|
||||
String siteId = wcsSrgvQueue.getTaskNo() + "1";//+ "," + startSite + "," + endSite;
|
||||
String taskNo = wcsSrgvQueue.getTaskNo();//+ "," + startSite + "," + endSite;
|
||||
SendData2 site = new SendData2();
|
||||
site.setAddress("4400");
|
||||
site.setData(siteId);
|
||||
site.setAddress("4000");
|
||||
site.setData(taskNo);
|
||||
site.setType(2);
|
||||
sendDataList.add(site);
|
||||
|
||||
//任务类型转换
|
||||
SendData2 taskType = new SendData2();
|
||||
taskType.setAddress("2200");
|
||||
taskType.setAddress("4002");
|
||||
taskType.setData(wcsSrgvQueue.getTaskType());
|
||||
taskType.setType(1);
|
||||
sendDataList.add(taskType);
|
||||
|
||||
if (wcsSrgvQueue.getTaskType().equals("8")) {
|
||||
SendData2 chgLayerLogo = new SendData2();
|
||||
chgLayerLogo.setAddress("4020");
|
||||
chgLayerLogo.setData(wcsSrgvQueue.getTaskType());
|
||||
chgLayerLogo.setType(1);
|
||||
sendDataList.add(chgLayerLogo);
|
||||
|
||||
|
||||
SendData2 tarLayer = new SendData2();
|
||||
tarLayer.setAddress("4022");
|
||||
tarLayer.setData(wcsSrgvQueue.getDefault07());
|
||||
tarLayer.setType(1);
|
||||
sendDataList.add(tarLayer);
|
||||
}
|
||||
|
||||
//下发标志转换
|
||||
SendData2 flag = new SendData2();
|
||||
flag.setAddress("2202");
|
||||
flag.setAddress("4021");
|
||||
flag.setData("1");
|
||||
flag.setType(1);
|
||||
sendDataList.add(flag);
|
||||
|
||||
//下发数据
|
||||
boolean b = true;// sendCarTask(sendDataList, deviceSrgv);
|
||||
boolean b = sendCarTask(sendDataList, deviceSrgv);
|
||||
if (b) {
|
||||
wcsSrgvQueue.setPathInfo(pathBuilder.toString());
|
||||
wcsSrgvQueue.setTrunPath(turnBuilder.toString());
|
||||
@@ -679,13 +721,21 @@ public class BaseSRgvThread implements Runnable, SRgvThreadInterface {
|
||||
String taskType = wcsSrgvQueue.getDefault02();
|
||||
boolean sendFlag = false;
|
||||
switch (taskType) {
|
||||
case "4":
|
||||
// 空车任务(充电、换层、手动点到点、除尘等)
|
||||
sendFlag = sendPointToPointTask(deviceSrgv, wcsSrgvQueue, currSite, endSite);
|
||||
break;
|
||||
case "1":
|
||||
case "2":
|
||||
// 载货任务(出库、入库、移库等)
|
||||
// 载货任务(出库、入库等)
|
||||
sendFlag = sendPointToPointTask(deviceSrgv, wcsSrgvQueue, currSite, endSite);
|
||||
break;
|
||||
case "4":
|
||||
// 空车任务(点到点任务)
|
||||
sendFlag = sendPointToPointTask(deviceSrgv, wcsSrgvQueue, currSite, endSite);
|
||||
break;
|
||||
case "7":
|
||||
// 移库任务
|
||||
sendFlag = sendPointToPointTask(deviceSrgv, wcsSrgvQueue, currSite, endSite);
|
||||
break;
|
||||
case "8":
|
||||
//换层作业
|
||||
sendFlag = sendPointToPointTask(deviceSrgv, wcsSrgvQueue, currSite, endSite);
|
||||
break;
|
||||
}
|
||||
@@ -760,7 +810,7 @@ public class BaseSRgvThread implements Runnable, SRgvThreadInterface {
|
||||
*/
|
||||
private void completeCarTask(DeviceSrgv deviceSrgv) {
|
||||
//联机自动
|
||||
if (deviceSrgv.getWorkMode() == 4) {
|
||||
if (deviceSrgv.getWorkMode() == 5) {
|
||||
if (deviceSrgv.getStatus() == 1) {
|
||||
WcsSrgvQueue param = new WcsSrgvQueue();
|
||||
param.setAgvId(Convert.toStr(deviceSrgv.getDeviceId()));
|
||||
@@ -791,8 +841,6 @@ public class BaseSRgvThread implements Runnable, SRgvThreadInterface {
|
||||
* @return
|
||||
*/
|
||||
private void finishTaskByQueue(String currSite, WcsSrgvQueue wcsSrgvQueue) {
|
||||
|
||||
|
||||
//当前在终点
|
||||
if (Objects.equals(currSite, wcsSrgvQueue.getEndSite())) {
|
||||
String taskType = wcsSrgvQueue.getTaskType();
|
||||
@@ -802,16 +850,16 @@ public class BaseSRgvThread implements Runnable, SRgvThreadInterface {
|
||||
wcsSrgvMap.setRemark("outCache");
|
||||
List<WcsSrgvMap> wcsSrgvMaps = wcsSrgvMapService.selectWcsSrgvMapList(wcsSrgvMap);
|
||||
|
||||
if(wcsSrgvMaps.stream().anyMatch(wcsSrgvMap1 -> wcsSrgvMap1.getSiteId().equals(currSite))){
|
||||
if (wcsSrgvMaps.stream().anyMatch(wcsSrgvMap1 -> wcsSrgvMap1.getSiteId().equals(currSite))) {
|
||||
//生成小车从避让点到放货/取货位置,如果是空车就到取货位置,如果是满车就到放货位置
|
||||
wcsSrgvQueue.setExecutionStatus("4");
|
||||
wcsSagvQueueMapper.insertHistory(wcsSrgvQueue.getTaskNo());
|
||||
wcsSrgvQueue.setIssued("0");
|
||||
wcsSrgvQueue.setExecutionStatus("1");
|
||||
wcsSrgvQueue.setStartSite(currSite);
|
||||
if("1".equals(taskType)){
|
||||
if ("1".equals(taskType)) {
|
||||
wcsSrgvQueue.setEndSite(cargoPickSite);
|
||||
}else if("2".equals(taskType)){
|
||||
} else if ("2".equals(taskType)) {
|
||||
wcsSrgvQueue.setEndSite(cargoPlaceSite);
|
||||
}
|
||||
wcsSrgvQueue.setTheFloor("1");
|
||||
@@ -820,8 +868,6 @@ public class BaseSRgvThread implements Runnable, SRgvThreadInterface {
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
|
||||
//空车现在位置是取货位置(移库取货,入库取货,出库取货),满车现在是放货位置
|
||||
if ("1".equals(taskType) && cargoPickSite.equals(currSite)) {
|
||||
//修改队列起终点,下发类型,重新下发。怎么区分重新下发的类型是移库还是入库,还有可能是出库取货--》判断取货位置是否为入库点
|
||||
@@ -884,12 +930,8 @@ public class BaseSRgvThread implements Runnable, SRgvThreadInterface {
|
||||
|
||||
} else {
|
||||
//充电之类的,不知道用不用
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -912,17 +954,51 @@ public class BaseSRgvThread implements Runnable, SRgvThreadInterface {
|
||||
if (CollUtil.isNotEmpty(wcsSrgvQueues)) {
|
||||
WcsSrgvQueue wcsSrgvQueue = wcsSrgvQueues.get(0);
|
||||
|
||||
String startSite = wcsSrgvQueue.getStartSite();
|
||||
String startSite = wcsSrgvQueue.getDefault03();
|
||||
|
||||
if (!startSite.equals(currSite)) {
|
||||
wcsSrgvQueue.setIssued("1");
|
||||
wcsSrgvQueue.setExecutionStatus("3");
|
||||
wcsSrgvQueue.setStartDate(DateUtil.now());
|
||||
wcsSagvQueueMapper.updateWcsSrgvQueue(wcsSrgvQueue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public String getSite(String sitId,String floor,String type){
|
||||
if (type.equals("8")){
|
||||
if (sitId.equals("tsj")){
|
||||
switch (floor){
|
||||
case "1":
|
||||
sitId="040501";
|
||||
break;
|
||||
case "2":
|
||||
sitId="040502";
|
||||
break;
|
||||
case "3":
|
||||
sitId="040503";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}else {
|
||||
if (sitId.equals("tsj")){
|
||||
switch (floor){
|
||||
case "1":
|
||||
sitId="030501";
|
||||
break;
|
||||
case "2":
|
||||
sitId="030502";
|
||||
break;
|
||||
case "3":
|
||||
sitId="030503";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return sitId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,19 +33,6 @@ public class SsjThread implements Runnable {
|
||||
|
||||
|
||||
public void init() {
|
||||
ssjCodeList = new HashMap<>();
|
||||
ArrayList<String> ssjCodes = new ArrayList<>();
|
||||
ssjCodes.add("TD1001");
|
||||
ssjCodes.add("TD1008");
|
||||
ssjCodeList.put("out", ssjCodes);
|
||||
ArrayList<String> ssjCodes1 = new ArrayList<>();
|
||||
ssjCodes1.add("GS1002");
|
||||
ssjCodes1.add("GS1007");
|
||||
ssjCodeList.put("in", ssjCodes1);
|
||||
ArrayList<String> ssjCodes2 = new ArrayList<>();
|
||||
ssjCodes2.add("L1004");
|
||||
ssjCodes2.add("L1005");
|
||||
ssjCodeList.put("road", ssjCodes2);
|
||||
mydoJobService = SpringUtils.getBean(IMydoJobService.class);
|
||||
jobCallBackService = SpringUtils.getBean(IJobCallBackService.class);
|
||||
apiService = SpringUtils.getBean(IApiService.class);
|
||||
@@ -55,49 +42,19 @@ public class SsjThread implements Runnable {
|
||||
public void run() {
|
||||
init();
|
||||
while (isRun) {
|
||||
for (String type : ssjCodeList.keySet()) {
|
||||
switch (type) {
|
||||
case "out":
|
||||
for (String ssjCode : ssjCodeList.get("out")) {
|
||||
try {
|
||||
if (PlcSsjRead.deviceSsjMap.containsKey(ssjCode)) {
|
||||
inDispatch(PlcSsjRead.deviceSsjMap.get(ssjCode));
|
||||
} else {
|
||||
log.error("设备不存在 ssjCode{}", ssjCode);
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
case "in":
|
||||
for (String ssjCode : ssjCodeList.get("in")) {
|
||||
try {
|
||||
if (PlcSsjRead.deviceSsjMap.containsKey(ssjCode)) {
|
||||
inDispatch1(PlcSsjRead.deviceSsjMap.get(ssjCode));
|
||||
} else {
|
||||
log.error("设备不存在 ssjCode{}", ssjCode);
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case "road":
|
||||
for (String ssjCode : ssjCodeList.get("road")) {
|
||||
try {
|
||||
if (PlcSsjRead.deviceSsjMap.containsKey(ssjCode)) {
|
||||
inDispatch2(PlcSsjRead.deviceSsjMap.get(ssjCode));
|
||||
} else {
|
||||
log.error("设备不存在 ssjCode{}", ssjCode);
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
try {
|
||||
DeviceSsj deviceSsj = PlcSsjRead.deviceSsjMap.get("L1001");
|
||||
if (deviceSsj != null) {
|
||||
//入库请求
|
||||
if (deviceSsj.getRkqq() == 1) {
|
||||
inDispatch1(deviceSsj);
|
||||
}
|
||||
if (deviceSsj.getDw() == 1) {
|
||||
inDispatch(deviceSsj);
|
||||
}
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -106,7 +63,6 @@ public class SsjThread implements Runnable {
|
||||
void inDispatch(DeviceSsj deviceSsj) {
|
||||
//出库到位
|
||||
if (deviceSsj.getDw() == 1 && deviceSsj.getTaskNo() > 0) {
|
||||
|
||||
MydoJob mydoJob = mydoJobService.selectMydoJobByTaskNo(Convert.toLong(deviceSsj.getTaskNo()));
|
||||
if (mydoJob != null) {
|
||||
log.info("设备:{} 位置:{} 任务号:{} 出库到位", "输送线", deviceSsj.getDeviceCode(), mydoJob.getTaskNo());
|
||||
@@ -124,18 +80,43 @@ public class SsjThread implements Runnable {
|
||||
}
|
||||
|
||||
void inDispatch1(DeviceSsj deviceSsj) {
|
||||
if (deviceSsj.getDw() == 1 && StrUtil.isNotBlank(deviceSsj.getTrayCode())) {
|
||||
if (deviceSsj.getRkqq() == 1 && StrUtil.isNotBlank(deviceSsj.getTrayCode())) {
|
||||
// 查是否有正执行的出库作业,有退回
|
||||
MydoJob mydoJob1 = new MydoJob();
|
||||
mydoJob1.setStatus("3");
|
||||
mydoJob1.setInOut("2");
|
||||
List<MydoJob> mydoJobs = mydoJobService.selectMydoJobList(mydoJob1);
|
||||
if (mydoJobs.size() > 0) {
|
||||
int i = writeToSsj(deviceSsj.getPlcDbWriteAddress(), "0", 2,1);
|
||||
MydoJob queryJob = new MydoJob();
|
||||
queryJob.setStatus("3");
|
||||
queryJob.setInOrOut("2");
|
||||
List<MydoJob> mydoJobs = mydoJobService.selectMydoJobList(queryJob);
|
||||
if (!mydoJobs.isEmpty()) {
|
||||
int i = PlcSsjRead.writeToSsj("0", 11, 1);
|
||||
if (i == 1) {
|
||||
log.info(deviceSsj.getDeviceCode()+"已有正执行的出库作业,下发退回,去向2");
|
||||
log.info(deviceSsj.getDeviceCode() + "已有正执行的出库作业,下发退回,去向2");
|
||||
return;
|
||||
}
|
||||
}
|
||||
//查询是否有已经生成的入库作业,有则下发
|
||||
queryJob.setStatus("1");
|
||||
queryJob.setInOrOut("1");
|
||||
queryJob.setTrayCode(deviceSsj.getTrayCode());
|
||||
mydoJobs=mydoJobService.selectMydoJobList(queryJob);
|
||||
if (!mydoJobs.isEmpty()) {
|
||||
//下发已经生成作业
|
||||
MydoJob mydoJob=mydoJobs.get(0);
|
||||
int i = PlcSsjRead.writeToSsj(mydoJob.getTaskNo(), Integer.parseInt(mydoJob.getRoadwayId()), 1);
|
||||
if (i == 1) {
|
||||
mydoJob.setStatus("3");
|
||||
mydoJobService.updateMydoJob(mydoJob);
|
||||
log.info("{}输送机下发入库任务号成功:{}", deviceSsj.getDeviceCode(), mydoJob.getTaskNo());
|
||||
return;
|
||||
}
|
||||
}
|
||||
//查询是否有已经下发的入库作业,有则退出逻辑
|
||||
queryJob.setStatus("3");
|
||||
queryJob.setInOrOut("1");
|
||||
queryJob.setTrayCode(deviceSsj.getTrayCode());
|
||||
mydoJobs=mydoJobService.selectMydoJobList(queryJob);
|
||||
if (!mydoJobs.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("trayCode", deviceSsj.getTrayCode());
|
||||
//拉取
|
||||
@@ -146,33 +127,32 @@ public class SsjThread implements Runnable {
|
||||
mydoJob.setStatus("1");
|
||||
mydoJob.setExecutionPhase("1");
|
||||
mydoJob.setCreateTime(new Date());
|
||||
mydoJob.setTheFloor(mydoJob.getRoadwayId());
|
||||
mydoJobService.insertMydoJob(mydoJob);
|
||||
int i = writeToSsj(deviceSsj.getPlcDbWriteAddress(), mydoJob.getTaskNo(), 1, 1);
|
||||
//找到作业的层下发为去向
|
||||
//TODO 到位后生成提升机的执行队列
|
||||
int i = PlcSsjRead.writeToSsj(mydoJob.getTaskNo(), Integer.parseInt(mydoJob.getRoadwayId()), 1);
|
||||
if (i == 1) {
|
||||
mydoJob.setStatus("3");
|
||||
mydoJobService.updateMydoJob(mydoJob);
|
||||
log.info(deviceSsj.getDeviceCode()+"输送机下发任务号成功:{}", mydoJob.getTaskNo());
|
||||
log.info("{}输送机下发任务号成功:{}", deviceSsj.getDeviceCode(), mydoJob.getTaskNo());
|
||||
}
|
||||
} else {
|
||||
int i = writeToSsj(deviceSsj.getPlcDbWriteAddress(), "0", 2,1);
|
||||
int i = writeToSsj("0", 11, 1);
|
||||
if (i == 1) {
|
||||
log.info(deviceSsj.getDeviceCode()+"未查到该托盘码作业,下发退回,去向2");
|
||||
log.info("{}未查到该托盘码作业,下发退回,去向2", deviceSsj.getDeviceCode());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void inDispatch2(DeviceSsj deviceSsj){
|
||||
if(deviceSsj.getDw() == 1 && deviceSsj.getTaskNo()>1000){
|
||||
void inDispatch2(DeviceSsj deviceSsj) {
|
||||
if (deviceSsj.getDw() == 1 && deviceSsj.getTaskNo() > 1000) {
|
||||
|
||||
MydoJob mydoJob = mydoJobService.selectMydoJobByTaskNo((long) deviceSsj.getTaskNo());
|
||||
if(mydoJob!=null){
|
||||
if (mydoJob != null) {
|
||||
mydoJob.setExecutionPhase("2");
|
||||
mydoJobService.updateMydoJob(mydoJob);
|
||||
mydoJobService.updateMydoJob(mydoJob);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,12 +7,11 @@ import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.ruoyi.bas.port.domain.WcsPort;
|
||||
import com.ruoyi.bas.port.service.IWcsPortService;
|
||||
import com.ruoyi.common.domain.SendData;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import com.ruoyi.device.srgv.domain.DeviceSrgv;
|
||||
import com.ruoyi.device.srgv.service.IDeviceSrgvService;
|
||||
import com.ruoyi.device.srgv.service.impl.DeviceSrgvServiceImpl;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
import com.ruoyi.device.tsj.domain.DeviceTsj;
|
||||
import com.ruoyi.job.domain.MydoJob;
|
||||
@@ -26,13 +25,11 @@ import com.ruoyi.queue.tsj.service.ITsjDeviceExecutionQueueService;
|
||||
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.plcRead.util.Tools;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Slf4j
|
||||
public class TsjThread implements Runnable {
|
||||
@@ -52,22 +49,21 @@ public class TsjThread implements Runnable {
|
||||
tsjDeviceExecutionQueueFinishService = SpringUtils.getBean(ITsjDeviceExecutionQueueFinishService.class);
|
||||
wcsPortService = SpringUtils.getBean(IWcsPortService.class);
|
||||
wcsSrgvQueueService = SpringUtils.getBean(IWcsSrgvQueueService.class);
|
||||
mydoJobService =SpringUtils.getBean(IMydoJobService.class);
|
||||
deviceSrgvService=SpringUtils.getBean(DeviceSrgvServiceImpl.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
init();
|
||||
while (isRun) {
|
||||
for (String tsjCode : PlcTsjRead.deviceTsjMap.keySet()) {
|
||||
DeviceTsj tsj = PlcTsjRead.deviceTsjMap.get(tsjCode);
|
||||
|
||||
tsjTask(tsj);
|
||||
}
|
||||
|
||||
try {
|
||||
Thread.sleep(1500);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
for (String tsjCode : PlcTsjRead.deviceTsjMap.keySet()) {
|
||||
DeviceTsj tsj = PlcTsjRead.deviceTsjMap.get(tsjCode);
|
||||
tsjTask(tsj);
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,40 +71,23 @@ public class TsjThread implements Runnable {
|
||||
|
||||
private void tsjTask(DeviceTsj tsj) {
|
||||
int sbzt = tsj.getSbzt();//设备状态
|
||||
int czfs = tsj.getCzfs();//操作方式 //0:未知,1:手动 2:自动
|
||||
int czfs = tsj.getCzfs();//操作方式 //0:未知,1:自动 2:手动
|
||||
int jdbz = tsj.getJdbz();//执行阶段
|
||||
Long rwh = tsj.getRwh();//任务号
|
||||
int yxxf = tsj.getYxxf();//允许下发
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* 1、下发完成 如果设备状态为 2-工作 ,触发方式 2-自动,任务号大于999,则代表任务下发完成
|
||||
*
|
||||
* */
|
||||
if (czfs == 2 && sbzt == 2 && rwh > 999) {
|
||||
finishSend(rwh);
|
||||
}
|
||||
|
||||
/*
|
||||
* 2、任务完成
|
||||
*
|
||||
* */
|
||||
if (czfs == 2 && sbzt == 2 && jdbz == 5 && rwh > 999) {
|
||||
if (czfs == 1 && sbzt == 98 && jdbz == 11 && rwh > 999) {
|
||||
//任务完成
|
||||
finishTask(rwh);
|
||||
finishTask(tsj);
|
||||
}
|
||||
|
||||
/*
|
||||
* 3、下发
|
||||
*
|
||||
* */
|
||||
if (czfs == 2 && yxxf == 1) {
|
||||
if (czfs == 1 && yxxf == 1) {
|
||||
sendTsj();
|
||||
}
|
||||
|
||||
createTsjQueue(tsj);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -118,9 +97,8 @@ public class TsjThread implements Runnable {
|
||||
private void createTsjQueue(DeviceTsj tsj) {
|
||||
for (String sRgv : PlcSrgvRead.deviceSrgvMap.keySet()) {
|
||||
DeviceSrgv deviceSrgv = PlcSrgvRead.deviceSrgvMap.get(sRgv);
|
||||
|
||||
//车进提升机 换层
|
||||
if ("1".equals(deviceSrgv.getSpare2()) && deviceSrgv.getTaskNo()>0){
|
||||
if ("1".equals(deviceSrgv.getSpare2()) && deviceSrgv.getTaskNo() > 0) {
|
||||
//请求进入输送机
|
||||
WcsSrgvQueue sRgvQueueParam = new WcsSrgvQueue();
|
||||
sRgvQueueParam.setAgvId(Convert.toStr(deviceSrgv.getDeviceId()));
|
||||
@@ -129,16 +107,20 @@ public class TsjThread implements Runnable {
|
||||
if (CollUtil.isNotEmpty(wcsSrgvQueues)) {
|
||||
WcsSrgvQueue wcsSrgvQueue = wcsSrgvQueues.get(0);
|
||||
String rwlx = "";
|
||||
if ("2".equals(wcsSrgvQueue.getTaskType())){
|
||||
if ("2".equals(wcsSrgvQueue.getTaskType())) {
|
||||
//出库
|
||||
rwlx = "1";
|
||||
}
|
||||
if ( "3".equals(wcsSrgvQueue.getTaskType()) || "8".equals(wcsSrgvQueue.getTaskType())){
|
||||
//
|
||||
rwlx = "2";
|
||||
}
|
||||
if ("3".equals(wcsSrgvQueue.getTaskType())) {
|
||||
//
|
||||
rwlx = "1";
|
||||
}
|
||||
if ("8".equals(wcsSrgvQueue.getTaskType())){
|
||||
rwlx = "3";
|
||||
}
|
||||
//TODO 换层时提升机的货物来源是小车层 获取去向是换曾终点层 是否要改为提升机当前层到小车层
|
||||
TsjDeviceExecutionQueue tsjDeviceExecutionQueueByRwh = tsjDeviceExecutionQueueService.selectTsjDeviceExecutionQueueByRwh(Convert.toLong(deviceSrgv.getTaskNo()));
|
||||
if (tsjDeviceExecutionQueueByRwh == null && StrUtil.isNotEmpty(rwlx)){
|
||||
if (tsjDeviceExecutionQueueByRwh == null && StrUtil.isNotEmpty(rwlx)) {
|
||||
String strFloor = wcsSrgvQueue.getTheFloor();
|
||||
String tarFloor = wcsSrgvQueue.getDefault07();
|
||||
if (!Convert.toStr(tsj.getDqcs()).equals(strFloor)) {
|
||||
@@ -165,38 +147,53 @@ public class TsjThread implements Runnable {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//输送机配送货物到提升机
|
||||
for (String ssjCode : inSsjList.keySet()) {
|
||||
DeviceSsj ssj = PlcSsjRead.deviceSsjMap.get(ssjCode);
|
||||
if (ObjUtil.isNotNull(ssj)) {
|
||||
if (ssj.getRkqq() == 1 && ssj.getDw() == 1 && ssj.getTaskNo() > 0) {
|
||||
MydoJob mydoJob = mydoJobService.selectMydoJobByTaskNo(Convert.toLong(ssj.getTaskNo()));
|
||||
//输送机入库
|
||||
DeviceSrgv srgvParam = new DeviceSrgv();
|
||||
srgvParam.setCurrFloor(Convert.toInt(mydoJob.getTheFloor()));
|
||||
List<DeviceSrgv> deviceSrgvs = deviceSrgvService.selectDeviceSrgvList(srgvParam);
|
||||
if (CollUtil.isNotEmpty(deviceSrgvs)){
|
||||
|
||||
String theFloor = mydoJob.getTheFloor();
|
||||
//生成提升机队列
|
||||
TsjDeviceExecutionQueue tsjDeviceExecutionQueue = new TsjDeviceExecutionQueue();
|
||||
tsjDeviceExecutionQueue.setGuid(IdUtil.simpleUUID());
|
||||
tsjDeviceExecutionQueue.setDeviceId(tsj.getId());
|
||||
tsjDeviceExecutionQueue.setDeviceName(tsj.getName());
|
||||
tsjDeviceExecutionQueue.setTaskNo(Convert.toLong(ssj.getTaskNo()));
|
||||
tsjDeviceExecutionQueue.setSrcRow("0");
|
||||
tsjDeviceExecutionQueue.setSrcLayer(String.valueOf(tsj.getDqcs()));
|
||||
tsjDeviceExecutionQueue.setTarRow("0");
|
||||
tsjDeviceExecutionQueue.setTarLayer(theFloor);
|
||||
tsjDeviceExecutionQueue.setSendType("1");
|
||||
tsjDeviceExecutionQueue.setCreateDate(DateUtil.formatDateTime(new Date()));
|
||||
tsjDeviceExecutionQueue.setSpare1("ssj");
|
||||
tsjDeviceExecutionQueue.setTaskType("1");
|
||||
tsjDeviceExecutionQueue.setRwlx("3");
|
||||
tsjDeviceExecutionQueueService.insertTsjDeviceExecutionQueue(tsjDeviceExecutionQueue);
|
||||
}
|
||||
DeviceSsj ssj = PlcSsjRead.deviceSsjMap.get("L1001");
|
||||
if (ObjUtil.isNotNull(ssj)) {
|
||||
if (ssj.getRkdw() == 1 && ssj.getTaskNo() > 0) {
|
||||
MydoJob mydoJob = mydoJobService.selectMydoJobByTaskNo(Convert.toLong(ssj.getTaskNo()));
|
||||
if (mydoJob==null){
|
||||
log.info("未查询到对应作业");
|
||||
return;
|
||||
}
|
||||
//输送机入库
|
||||
DeviceSrgv srgvParam = new DeviceSrgv();
|
||||
srgvParam.setCurrFloor(Convert.toInt(mydoJob.getTheFloor()));
|
||||
//查找当前层是否有小车,提升机是否在当前层,有小车生成提升机队列
|
||||
List<DeviceSrgv> deviceSrgvs = deviceSrgvService.selectDeviceSrgvList(srgvParam);
|
||||
TsjDeviceExecutionQueue queryQueue = new TsjDeviceExecutionQueue();
|
||||
queryQueue.setTaskNo(Convert.toLong(ssj.getTaskNo()));
|
||||
final List<TsjDeviceExecutionQueue> tsjDeviceExecutionQueues = tsjDeviceExecutionQueueService.selectTsjDeviceExecutionQueueList(queryQueue);
|
||||
if (!tsjDeviceExecutionQueues.isEmpty()){
|
||||
log.info("已经生成提升机队列");
|
||||
return;
|
||||
}
|
||||
MydoJob queryJob = new MydoJob();
|
||||
queryJob.setTaskNo(String.valueOf(ssj.getTaskNo()));
|
||||
queryJob.setExecutionPhase("3");
|
||||
List<MydoJob> mydoJobs = mydoJobService.selectMydoJobList(queryJob);
|
||||
if (!mydoJobs.isEmpty()){
|
||||
log.info("提升机队列已完成");
|
||||
return;
|
||||
}
|
||||
if (CollUtil.isNotEmpty(deviceSrgvs)) {
|
||||
String theFloor = mydoJob.getTheFloor();
|
||||
//生成提升机队列
|
||||
TsjDeviceExecutionQueue tsjDeviceExecutionQueue = new TsjDeviceExecutionQueue();
|
||||
tsjDeviceExecutionQueue.setGuid(IdUtil.simpleUUID());
|
||||
tsjDeviceExecutionQueue.setDeviceId(tsj.getId());
|
||||
tsjDeviceExecutionQueue.setDeviceName(tsj.getName());
|
||||
tsjDeviceExecutionQueue.setTaskNo(Convert.toLong(ssj.getTaskNo()));
|
||||
tsjDeviceExecutionQueue.setSrcRow("0");
|
||||
tsjDeviceExecutionQueue.setSrcLayer(String.valueOf(tsj.getDqcs()));
|
||||
tsjDeviceExecutionQueue.setTarRow("0");
|
||||
tsjDeviceExecutionQueue.setTarLayer(theFloor);
|
||||
tsjDeviceExecutionQueue.setSendType("1");
|
||||
tsjDeviceExecutionQueue.setCreateDate(DateUtil.formatDateTime(new Date()));
|
||||
tsjDeviceExecutionQueue.setSpare1("ssj");
|
||||
tsjDeviceExecutionQueue.setTaskType("1");
|
||||
tsjDeviceExecutionQueue.setRwlx("1");
|
||||
tsjDeviceExecutionQueueService.insertTsjDeviceExecutionQueue(tsjDeviceExecutionQueue);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -206,32 +203,9 @@ public class TsjThread implements Runnable {
|
||||
List<TsjDeviceExecutionQueue> tsjDeviceExecutionQueues = tsjDeviceExecutionQueueService.selectTsjDeviceExecutionQueueList(new TsjDeviceExecutionQueue());
|
||||
if (CollUtil.isNotEmpty(tsjDeviceExecutionQueues)) {
|
||||
TsjDeviceExecutionQueue tsjDeviceExecutionQueue = tsjDeviceExecutionQueues.get(0);
|
||||
|
||||
//提升机移动到小车楼层 需要判断目标楼层入库点位小车是否到位
|
||||
WcsPort param = new WcsPort();
|
||||
param.setPortType("1");
|
||||
param.setPortRegion(tsjDeviceExecutionQueue.getTarLayer());
|
||||
param.setStatus("1");
|
||||
param.setSpare2("1");
|
||||
List<WcsPort> wcsInPorts = wcsPortService.selectWcsPortList(param);
|
||||
if (CollUtil.isEmpty(wcsInPorts)) {
|
||||
log.info("提升机任务[{}]下发 目标楼层[{}]入库点位空闲 无法下发提升机任务", tsjDeviceExecutionQueue.getTaskNo(), tsjDeviceExecutionQueue.getTarLayer());
|
||||
return;
|
||||
if (tsjDeviceExecutionQueue.getSendFlag()==null) {
|
||||
writeToTsj(tsjDeviceExecutionQueue);
|
||||
}
|
||||
//提升机承载小车到目标楼层 需要判断目标楼层出库点位是否空闲
|
||||
WcsPort param1 = new WcsPort();
|
||||
param1.setPortType("1");
|
||||
param1.setPortRegion(tsjDeviceExecutionQueue.getTarLayer());
|
||||
param1.setStatus("0");
|
||||
param1.setSpare2("1");
|
||||
List<WcsPort> wcsOutPorts = wcsPortService.selectWcsPortList(param1);
|
||||
if (CollUtil.isEmpty(wcsOutPorts)) {
|
||||
log.info("提升机任务[{}]下发 目标楼层[{}]出库点位占用 无法下发提升机任务", tsjDeviceExecutionQueue.getTaskNo(), tsjDeviceExecutionQueue.getTarLayer());
|
||||
return;
|
||||
}
|
||||
|
||||
writeToTsj(tsjDeviceExecutionQueues.get(0));
|
||||
log.info("提升机任务下发 taskNo{} 任务类型:{}", tsjDeviceExecutionQueue.getTaskNo(), tsjDeviceExecutionQueue.getRwlx());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -241,36 +215,49 @@ public class TsjThread implements Runnable {
|
||||
* @param tsjDeviceExecutionQueue
|
||||
*/
|
||||
private void writeToTsj(TsjDeviceExecutionQueue tsjDeviceExecutionQueue) {
|
||||
SendData taskNoSendData = new SendData(Tools.INT, Convert.toInt(tsjDeviceExecutionQueue.getTaskNo()));
|
||||
SendData srcRow = new SendData(Tools.INT, Convert.toInt(tsjDeviceExecutionQueue.getSrcRow()));
|
||||
SendData srcLayer = new SendData(Tools.INT, Convert.toInt(tsjDeviceExecutionQueue.getSrcLayer()));
|
||||
SendData tarRow = new SendData(Tools.INT, Convert.toInt(tsjDeviceExecutionQueue.getTarRow()));
|
||||
SendData tarLayer = new SendData(Tools.INT, Convert.toInt(tsjDeviceExecutionQueue.getTarLayer()));
|
||||
SendData sendType = new SendData(Tools.INT, Convert.toInt(tsjDeviceExecutionQueue.getSendType()));
|
||||
SendData completedSendData = new SendData(Tools.INT, 1);
|
||||
int jym = Tools.getJYM(taskNoSendData.getNum2(), srcRow.getNum2(), srcLayer.getNum2(), tarRow.getNum2(), tarLayer.getNum2(), sendType.getNum2(), completedSendData.getNum2());
|
||||
SendData jymSendData = new SendData(Tools.INT, jym);
|
||||
byte[] bytes = Tools.sendData(taskNoSendData, srcRow, srcLayer, tarRow, tarLayer, sendType, completedSendData, jymSendData);
|
||||
DeviceTsj deviceTsj = PlcTsjRead.deviceTsjMap.get(Convert.toStr(tsjDeviceExecutionQueue.getDeviceId()));
|
||||
if (ObjUtil.isNotNull(deviceTsj)) {
|
||||
PlcTsjRead.WriteToTSJ(deviceTsj.getPlcDbWriteAddress(), bytes);
|
||||
String taskNo= String.valueOf(tsjDeviceExecutionQueue.getTaskNo());
|
||||
int rwlx = Integer.parseInt(tsjDeviceExecutionQueue.getRwlx());
|
||||
int src_of_goods= Integer.parseInt(tsjDeviceExecutionQueue.getSrcLayer());
|
||||
int dest_of_goods= Integer.parseInt(tsjDeviceExecutionQueue.getTarLayer());
|
||||
final int i = PlcTsjRead.writeToTsj(taskNo, rwlx, src_of_goods, dest_of_goods, 1);
|
||||
if (i > 0) {
|
||||
TsjDeviceExecutionQueue queryQueue = new TsjDeviceExecutionQueue();
|
||||
queryQueue.setTaskNo(Convert.toLong(taskNo));
|
||||
final List<TsjDeviceExecutionQueue> tsjDeviceExecutionQueues = tsjDeviceExecutionQueueService.selectTsjDeviceExecutionQueueList(queryQueue);
|
||||
if (!tsjDeviceExecutionQueues.isEmpty()){
|
||||
TsjDeviceExecutionQueue tsjDeviceExecutionQueue1=tsjDeviceExecutionQueues.get(0);
|
||||
tsjDeviceExecutionQueue1.setSendFlag("1");
|
||||
tsjDeviceExecutionQueue1.setStartDate(DateUtil.formatDateTime(DateUtil.date()));
|
||||
tsjDeviceExecutionQueueService.updateTsjDeviceExecutionQueue(tsjDeviceExecutionQueue1);
|
||||
log.info("提升机任务下发成功 taskNo{} 任务类型:{}", tsjDeviceExecutionQueue.getTaskNo(), tsjDeviceExecutionQueue.getRwlx());
|
||||
}else {
|
||||
log.info("未找到执行队列 任务号{}",tsjDeviceExecutionQueue.getTaskNo());
|
||||
}
|
||||
}else {
|
||||
log.info("提升机任务下发失败 taskNo{} 任务类型:{}", tsjDeviceExecutionQueue.getTaskNo(), tsjDeviceExecutionQueue.getRwlx());
|
||||
}
|
||||
}
|
||||
|
||||
private void finishTask(Long taskNo) {
|
||||
|
||||
private void finishTask(DeviceTsj tsj) {
|
||||
//根据任务号查询队列 修改执行状态
|
||||
TsjDeviceExecutionQueue tsjDeviceExecutionQueue = tsjDeviceExecutionQueueService.selectTsjDeviceExecutionQueueByRwh(taskNo);
|
||||
TsjDeviceExecutionQueue tsjDeviceExecutionQueue = tsjDeviceExecutionQueueService.selectTsjDeviceExecutionQueueByRwh(tsj.getRwh());
|
||||
if (ObjUtil.isNotNull(tsjDeviceExecutionQueue)) {
|
||||
//完成提升机任务 插入历史表
|
||||
TsjDeviceExecutionQueueFinish tsjDeviceExecutionQueueFinish = new TsjDeviceExecutionQueueFinish();
|
||||
BeanUtil.copyProperties(tsjDeviceExecutionQueue, tsjDeviceExecutionQueueFinish);
|
||||
tsjDeviceExecutionQueueFinish.setFinishDate(DateUtil.formatDateTime(DateUtil.date()));
|
||||
tsjDeviceExecutionQueueFinishService.insertTsjDeviceExecutionQueueFinish(tsjDeviceExecutionQueueFinish);
|
||||
tsjDeviceExecutionQueueService.deleteTsjDeviceExecutionQueueByGuid(tsjDeviceExecutionQueue.getGuid());
|
||||
log.info("提升机任务下发完成 taskNo{} 任务类型:{}", taskNo, "提升机任务");
|
||||
String senFlag= tsjDeviceExecutionQueue.getSendFlag()==null?"0":"1";
|
||||
if (tsjDeviceExecutionQueue.getTarLayer().equals(String.valueOf(tsj.getDqcs()))&&senFlag.equals("1")){
|
||||
TsjDeviceExecutionQueueFinish tsjDeviceExecutionQueueFinish = new TsjDeviceExecutionQueueFinish();
|
||||
BeanUtil.copyProperties(tsjDeviceExecutionQueue, tsjDeviceExecutionQueueFinish);
|
||||
tsjDeviceExecutionQueueFinish.setFinishDate(DateUtil.formatDateTime(DateUtil.date()));
|
||||
tsjDeviceExecutionQueueFinishService.insertTsjDeviceExecutionQueueFinish(tsjDeviceExecutionQueueFinish);
|
||||
tsjDeviceExecutionQueueService.deleteTsjDeviceExecutionQueueByGuid(tsjDeviceExecutionQueue.getGuid());
|
||||
MydoJob mydoJob = mydoJobService.selectMydoJobByTaskNo(tsj.getRwh());
|
||||
if (mydoJob != null&&!tsjDeviceExecutionQueue.getRwlx().equals("3")) {
|
||||
mydoJob.setExecutionPhase("3");
|
||||
mydoJobService.updateMydoJob(mydoJob);
|
||||
}
|
||||
log.info("提升机任务下发完成 taskNo{} 任务类型:{}", tsj.getRwh(), "提升机任务");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,10 +22,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="exception" column="exception" />
|
||||
<result property="traySize" column="tray_size" />
|
||||
<result property="allowPut" column="allow_put" />
|
||||
<result property="czms" column="czms" />
|
||||
<result property="rkdw" column="rkdw" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectDeviceSsjVo">
|
||||
select id, device_code , name , type, ip_address, plc_db_read_address, is_active, create_time, plc_db_write_address, rkqq, kx, dw, tray_code, task_no,exception,tray_size,allow_put from device_ssj
|
||||
select id, device_code , name , type, ip_address, plc_db_read_address, is_active, create_time, plc_db_write_address, rkqq, kx, dw, tray_code, task_no, exception, tray_size, allow_put, czms, rkdw from device_ssj
|
||||
</sql>
|
||||
|
||||
<select id="selectDeviceSsjList" parameterType="DeviceSsj" resultMap="DeviceSsjResult">
|
||||
@@ -46,6 +48,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="exception != null and exception != ''"> and exception = #{exception}</if>
|
||||
<if test="traySize != null and traySize != ''"> and tray_size = #{traySize}</if>
|
||||
<if test="allowPut != null and allowPut != ''"> and allow_put = #{allowPut}</if>
|
||||
<if test="czms != null and czms != ''"> and czms = #{czms}</if>
|
||||
<if test="rkdw != null and rkdw != ''"> and rkdw = #{rkdw}</if>
|
||||
|
||||
</where>
|
||||
</select>
|
||||
@@ -75,6 +79,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="dw != null">dw,</if>
|
||||
<if test="trayCode != null">tray_code,</if>
|
||||
<if test="taskNo != null">task_no,</if>
|
||||
<if test="czms != null">czms,</if>
|
||||
<if test="rkdw != null">rkdw,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="deviceCode != null">#{deviceCode },</if>
|
||||
@@ -90,6 +96,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="dw != null">#{dw},</if>
|
||||
<if test="trayCode != null">#{trayCode},</if>
|
||||
<if test="taskNo != null">#{taskNo},</if>
|
||||
<if test="czms != null">#{czms},</if>
|
||||
<if test="rkdw != null">#{rkdw},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
@@ -104,6 +112,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="exception != null">exception = #{exception},</if>
|
||||
<if test="traySize != null">tray_size = #{traySize},</if>
|
||||
<if test="allowPut != null">allow_put = #{allowPut},</if>
|
||||
<if test="czms != null">czms = #{czms},</if>
|
||||
<if test="rkdw != null">rkdw = #{rkdw},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
Reference in New Issue
Block a user