堆垛机调度初始化
This commit is contained in:
@@ -1,17 +1,17 @@
|
||||
package com.ruoyi.schedule;
|
||||
|
||||
import com.ruoyi.device.ddj.domain.MsgDdj;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
import com.ruoyi.device.ssj.service.IDeviceSsjService;
|
||||
import com.ruoyi.schedule.plcRead.ssj.domain.PlcConnectInfo;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcRead;
|
||||
import com.ruoyi.schedule.plcRead.ssj.domain.CustomThread;
|
||||
import com.ruoyi.schedule.scheduleTask.ssj.bs.BsInSsjThread;
|
||||
import com.ruoyi.schedule.scheduleTask.ssj.bs.BsOutSsjThread;
|
||||
import com.ruoyi.schedule.scheduleTask.ssj.bs.BsPickSsjTread;
|
||||
import com.ruoyi.schedule.scheduleTask.ssj.js.JsInSsjThread;
|
||||
import com.ruoyi.schedule.scheduleTask.ssj.js.JsOutSsjThread;
|
||||
import com.ruoyi.schedule.scheduleTask.ssj.js.JsPickSsjTread;
|
||||
import com.ruoyi.schedule.scheduleTask.ssj.monitor.SsjMonitorThread;
|
||||
import com.ruoyi.schedule.scheduleTask.ddj.Ddj1Thread;
|
||||
import com.ruoyi.schedule.scheduleTask.ddj.Ddj2Thread;
|
||||
import com.ruoyi.schedule.scheduleTask.ssj.floor1.Floor1SsjInOutThread;
|
||||
import com.ruoyi.schedule.scheduleTask.ssj.floor1.Floor1SsjRoadWayThread;
|
||||
import com.ruoyi.schedule.scheduleTask.ssj.floor2.Floor2SsjInOutThread;
|
||||
import com.ruoyi.schedule.scheduleTask.ssj.floor2.Floor2SsjRoadWayThread;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -29,13 +29,12 @@ public class ScheduleThread {
|
||||
@Autowired
|
||||
private IDeviceSsjService deviceSsjService;
|
||||
|
||||
public CustomThread<BsInSsjThread> bsInSsjThread;
|
||||
public CustomThread<JsInSsjThread> jsInSsjThread;
|
||||
public CustomThread<BsOutSsjThread> bsOutSsjThread;
|
||||
public CustomThread<JsOutSsjThread> jsOutSsjThread;
|
||||
public CustomThread<BsPickSsjTread> bsPickSsjThread;
|
||||
public CustomThread<JsPickSsjTread> jsPickSsjThread;
|
||||
public CustomThread<SsjMonitorThread> ssjMonitorThread;
|
||||
public CustomThread<Ddj1Thread> ddj1ThreadCustomThread;
|
||||
public CustomThread<Ddj2Thread> ddj2ThreadCustomThread;
|
||||
public CustomThread<Floor1SsjInOutThread> bsOutSsjThread;
|
||||
public CustomThread<Floor1SsjRoadWayThread> jsOutSsjThread;
|
||||
public CustomThread<Floor2SsjInOutThread> bsPickSsjThread;
|
||||
public CustomThread<Floor2SsjRoadWayThread> jsPickSsjThread;
|
||||
|
||||
|
||||
private boolean isRun = false;
|
||||
@@ -58,7 +57,7 @@ public class ScheduleThread {
|
||||
* 调度初始化
|
||||
*/
|
||||
private void scheduleInit() {
|
||||
BsInSsjThread bsInSsjThread1 = new BsInSsjThread();
|
||||
/* BsInSsjThread bsInSsjThread1 = new BsInSsjThread();
|
||||
bsInSsjThread = new CustomThread<BsInSsjThread>(new Thread(bsInSsjThread1), bsInSsjThread1);
|
||||
JsInSsjThread jsInSsjThread1 = new JsInSsjThread();
|
||||
jsInSsjThread = new CustomThread<JsInSsjThread>(new Thread(jsInSsjThread1), jsInSsjThread1);
|
||||
@@ -72,7 +71,7 @@ public class ScheduleThread {
|
||||
jsPickSsjThread = new CustomThread<JsPickSsjTread>(new Thread(jsPickSsjTread1), jsPickSsjTread1);
|
||||
|
||||
SsjMonitorThread ssjMonitorThread1 = new SsjMonitorThread();
|
||||
ssjMonitorThread = new CustomThread<SsjMonitorThread>(new Thread(ssjMonitorThread1), ssjMonitorThread1);
|
||||
ssjMonitorThread = new CustomThread<SsjMonitorThread>(new Thread(ssjMonitorThread1), ssjMonitorThread1);*/
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -89,8 +88,10 @@ public class ScheduleThread {
|
||||
list.put(deviceSsj.getDeviceCode(), deviceSsj);
|
||||
}
|
||||
|
||||
ConcurrentHashMap<String, MsgDdj> list2 = new ConcurrentHashMap<>();
|
||||
|
||||
//plc读取线程
|
||||
PlcRead plcRead = new PlcRead(list, ssjPlcConnectInfo);
|
||||
PlcRead plcRead = new PlcRead(list,list2, ssjPlcConnectInfo);
|
||||
Thread plcReadThread = new Thread(plcRead);
|
||||
customThread = new CustomThread<PlcRead>(plcReadThread, plcRead);
|
||||
}
|
||||
@@ -107,7 +108,7 @@ public class ScheduleThread {
|
||||
* 开启线程2
|
||||
*/
|
||||
public void startAllThread2() {
|
||||
//臂式入库线程调度
|
||||
/* //臂式入库线程调度
|
||||
bsInSsjThread.getThread().start();
|
||||
//臂式出库线程调度
|
||||
bsOutSsjThread.getThread().start();
|
||||
@@ -121,7 +122,7 @@ public class ScheduleThread {
|
||||
//剪上出库到位线程调度-wms电子屏交互
|
||||
//jsPickSsjThread.getThread().start();
|
||||
//监控输送机
|
||||
//ssjMonitorThread.getThread().start();
|
||||
//ssjMonitorThread.getThread().start();*/
|
||||
|
||||
isRun2 = true;
|
||||
}
|
||||
@@ -139,12 +140,12 @@ public class ScheduleThread {
|
||||
* 停止线程2
|
||||
*/
|
||||
public void stopAllThread2() {
|
||||
bsInSsjThread.runnable.isRun = false;
|
||||
/*bsInSsjThread.runnable.isRun = false;
|
||||
jsInSsjThread.runnable.isRun = false;
|
||||
bsOutSsjThread.runnable.isRun = false;
|
||||
jsOutSsjThread.runnable.isRun = false;
|
||||
bsPickSsjThread.runnable.isRun = false;
|
||||
jsPickSsjThread.runnable.isRun = false;
|
||||
jsPickSsjThread.runnable.isRun = false;*/
|
||||
scheduleInit();
|
||||
isRun2 = false;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.ruoyi.schedule;
|
||||
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/device/operation")
|
||||
public class ThreadOperationController {
|
||||
|
||||
@Resource
|
||||
private ScheduleThread scheduleThread;
|
||||
|
||||
/**
|
||||
* 开启plc读取线程
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/startAllThread")
|
||||
//@PreAuthorize("@ss.hasPermi('device:operation:start')")
|
||||
public AjaxResult startAllThread() {
|
||||
scheduleThread.startAllThread();
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 开启调度线程
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/startAllThread2")
|
||||
//@PreAuthorize("@ss.hasPermi('device:operation:start')")
|
||||
public AjaxResult startAllThread2() {
|
||||
scheduleThread.startAllThread2();
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭线程
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/stopAllThread")
|
||||
//@PreAuthorize("@ss.hasPermi('device:operation:stop')")
|
||||
public AjaxResult stopAllThread() {
|
||||
scheduleThread.stopAllThread();
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭线程
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/stopAllThread2")
|
||||
//@PreAuthorize("@ss.hasPermi('device:operation:stop')")
|
||||
public AjaxResult stopAllThread2() {
|
||||
scheduleThread.stopAllThread2();
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取调度状态
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/getScheduleStatus")
|
||||
public AjaxResult getScheduleStatus() {
|
||||
return AjaxResult.success(scheduleThread.getScheduleStatus());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.ruoyi.schedule.plcRead.ddj;
|
||||
|
||||
public class IsoTcpClientDDJ1 extends Thread {
|
||||
|
||||
|
||||
/// <20>Ѷ<EFBFBD><D1B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD>
|
||||
public static int WritetoDDJ(String address, byte[] tsak) {
|
||||
/*int a = 0;
|
||||
if (readWriteNet != null) {
|
||||
a = HslRead.WriteResultRender(readWriteNet.Write(address, tsak), address);
|
||||
}
|
||||
return a;*/
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import HslCommunication.Core.Types.OperateResult;
|
||||
import HslCommunication.Core.Types.OperateResultExOne;
|
||||
import HslCommunication.Profinet.Siemens.SiemensPLCS;
|
||||
import HslCommunication.Profinet.Siemens.SiemensS7Net;
|
||||
import com.ruoyi.device.ddj.domain.MsgDdj;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
import com.ruoyi.schedule.plcRead.ssj.domain.HslRead;
|
||||
import com.ruoyi.schedule.plcRead.ssj.domain.PlcConnectInfo;
|
||||
@@ -18,7 +19,8 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
@Slf4j
|
||||
public class PlcRead implements Runnable {
|
||||
|
||||
public static ConcurrentHashMap<String, DeviceSsj> deviceMap;
|
||||
public static ConcurrentHashMap<String, DeviceSsj> deviceSsjMap;
|
||||
public static ConcurrentHashMap<String, MsgDdj> deviceDdjMap;
|
||||
public volatile boolean isRun = true;
|
||||
|
||||
public SiemensS7Net siemensS7Net = null;
|
||||
@@ -27,8 +29,9 @@ public class PlcRead implements Runnable {
|
||||
private int port;
|
||||
private boolean success = false;
|
||||
|
||||
public PlcRead(ConcurrentHashMap<String, DeviceSsj> deviceMap, PlcConnectInfo plcConnectInfo) {
|
||||
this.deviceMap = deviceMap;
|
||||
public PlcRead(ConcurrentHashMap<String, DeviceSsj> deviceMap1,ConcurrentHashMap<String, MsgDdj> deviceMap2, PlcConnectInfo plcConnectInfo) {
|
||||
this.deviceSsjMap = deviceMap1;
|
||||
this.deviceDdjMap = deviceMap2;
|
||||
this.ip = plcConnectInfo.getIp();
|
||||
this.port = plcConnectInfo.getPort();
|
||||
}
|
||||
@@ -48,8 +51,8 @@ public class PlcRead implements Runnable {
|
||||
if (IsConnect()) {
|
||||
int step = 20;
|
||||
int baseOffset = 0;
|
||||
for (String ssjCode : deviceMap.keySet()) {
|
||||
DeviceSsj ssjDevice = deviceMap.get(ssjCode);
|
||||
for (String ssjCode : deviceSsjMap.keySet()) {
|
||||
DeviceSsj ssjDevice = deviceSsjMap.get(ssjCode);
|
||||
switch (ssjDevice.getType()) {
|
||||
case "1":
|
||||
readPlcOutSsj(ssjDevice);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.ruoyi.schedule.plcRead.util;
|
||||
|
||||
import HslCommunication.BasicFramework.SoftBasic;
|
||||
import com.ruoyi.schedule.plcRead.ssj.domain.SendData;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
@@ -10,7 +9,7 @@ import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>:cyc16У<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* 描述:cyc16校验码
|
||||
*
|
||||
* @author zhu
|
||||
*/
|
||||
@@ -26,31 +25,31 @@ public class Tools implements Serializable {
|
||||
System.out.println(jym);
|
||||
}
|
||||
|
||||
/*4<EFBFBD><EFBFBD>CRC-16У<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㷽<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD>ò<EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><EFBFBD>㷨<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㷽<EFBFBD><EFBFBD>һ<EFBFBD>㶼<EFBFBD>ǣ<EFBFBD>
|
||||
<EFBFBD><EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԥ<EFBFBD><EFBFBD>1<EFBFBD><EFBFBD>16λ<EFBFBD>ļĴ<EFBFBD><EFBFBD><EFBFBD>Ϊʮ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>FFFF<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȫΪ1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƴ˼Ĵ<EFBFBD><EFBFBD><EFBFBD>ΪCRC<EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD>2<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѵ<EFBFBD>һ<EFBFBD><EFBFBD>8λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD><EFBFBD><EFBFBD>ͨѶ<EFBFBD><EFBFBD>Ϣ֡<EFBFBD>ĵ<EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>ֽڣ<EFBFBD><EFBFBD><EFBFBD>16λ<EFBFBD><EFBFBD>CRC<EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD>
|
||||
8λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>CRC<EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߰<EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD>ݲ<EFBFBD><EFBFBD>䣻
|
||||
<EFBFBD><EFBFBD>3<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>CRC<EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һλ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>0<EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƺ<EFBFBD><EFBFBD><EFBFBD>Ƴ<EFBFBD>λ<EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD>4<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƴ<EFBFBD>λΪ0<EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD><EFBFBD><EFBFBD>3<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һλ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƴ<EFBFBD>λΪ1<EFBFBD><EFBFBD>CRC<EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD>ʽA001<EFBFBD><EFBFBD>1010 0000 0000 0001<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD>5<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>3<EFBFBD><EFBFBD>4<EFBFBD><EFBFBD>ֱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>8<EFBFBD>Σ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>8λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˴<EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD>6<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>5<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨѶ<EFBFBD><EFBFBD>Ϣ֡<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>ֽڵĴ<EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD>7<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨѶ<EFBFBD><EFBFBD>Ϣ֡<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֽڰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɺõ<EFBFBD><EFBFBD><EFBFBD>16λCRC<EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĸߡ<EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD>ֽڽ<EFBFBD><EFBFBD>н<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD>8<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><EFBFBD><EFBFBD>CRC<EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݼ<EFBFBD>Ϊ<EFBFBD><EFBFBD>CRC<EFBFBD>롣
|
||||
<EFBFBD><EFBFBD><EFBFBD>ϼ<EFBFBD><EFBFBD>㲽<EFBFBD><EFBFBD><EFBFBD>еĶ<EFBFBD><EFBFBD><EFBFBD>ʽA001<EFBFBD><EFBFBD>8005<EFBFBD><EFBFBD>λ<EFBFBD>ߵ<EFBFBD><EFBFBD><EFBFBD>Ľ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǽ<EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǽ<EFBFBD>0~256<35><36><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ16λ<36>ļĴ<C4BC><C4B4><EFBFBD><EFBFBD>еĵͰ<C4B5>λ<EFBFBD><CEBB><EFBFBD>߰<EFBFBD>λ<EFBFBD><CEBB><EFBFBD>0<EFBFBD><30>Ȼ<EFBFBD>üĴ<C3BC><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ0XA001<30><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>3<EFBFBD><33>4<EFBFBD><34><EFBFBD>裬ֱ<E8A3AC><D6B1><EFBFBD><EFBFBD>λȫ<CEBB><C8AB><EFBFBD>Ƴ<EFBFBD><C6B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD>е<EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD>DZ<EFBFBD><C7B1><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD>ݣ<EFBFBD><DDA3>߰<EFBFBD>λ<EFBFBD><CEBB><EFBFBD>Ͱ<EFBFBD>λ<EFBFBD>ֱ<D6B1>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>*/
|
||||
/*4、CRC-16校验码计算方法:
|
||||
常用查表法和计算法。计算方法一般都是:
|
||||
(1)、预置1个16位的寄存器为十六进制FFFF(即全为1),称此寄存器为CRC寄存器;
|
||||
(2)、把第一个8位二进制数据(既通讯信息帧的第一个字节)与16位的CRC寄存器的低
|
||||
8位相异或,把结果放于CRC寄存器,高八位数据不变;
|
||||
(3)、把CRC寄存器的内容右移一位(朝低位)用0填补最高位,并检查右移后的移出位;
|
||||
(4)、如果移出位为0:重复第3步(再次右移一位);如果移出位为1,CRC寄存器与多
|
||||
项式A001(1010 0000 0000 0001)进行异或;
|
||||
(5)、重复步骤3和4,直到右移8次,这样整个8位数据全部进行了处理;
|
||||
(6)、重复步骤2到步骤5,进行通讯信息帧下一个字节的处理;
|
||||
(7)、将该通讯信息帧所有字节按上述步骤计算完成后,得到的16位CRC寄存器的高、低
|
||||
字节进行交换;
|
||||
(8)、最后得到的CRC寄存器内容即为:CRC码。
|
||||
以上计算步骤中的多项式A001是8005按位颠倒后的结果。
|
||||
查表法是将移位异或的计算结果做成了一个表,就是将0~256放入一个长度为16位的寄存器中的低八位,高八位填充0,然后将该寄存器与多项式0XA001按照上述3、4步骤,直到八位全部移出,最后寄存器中的值就是表格中的数据,高八位、低八位分别单独一个表。*/
|
||||
|
||||
|
||||
/**
|
||||
* ȫ<EFBFBD><EFBFBD>У<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ
|
||||
* 全部校验码可用这个获取
|
||||
*
|
||||
* @param ints <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* @return <EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD>int
|
||||
* @param ints 传入的校验码
|
||||
* @return 返回的int
|
||||
*/
|
||||
public static int getJYM(int... ints) {
|
||||
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>תΪ32λ<EFBFBD><EFBFBD><EFBFBD>ܺ<EFBFBD>תΪ<EFBFBD>ĸ<EFBFBD><EFBFBD>ֽڣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>תΪ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>4
|
||||
//将整形任务号转为32位,能后转为四个字节,最后转为整形组4
|
||||
int[] ints1 = new int[ints.length * 4];
|
||||
for (int i = 0; i < ints.length; i++) {
|
||||
int[] son;
|
||||
@@ -69,13 +68,13 @@ public class Tools implements Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param hex <EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD>
|
||||
* @return a <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* @param hex 字符串
|
||||
* @return a 整型
|
||||
*/
|
||||
public static int[] binaryTints(String hex) {
|
||||
int[] a = new int[4];
|
||||
String hexString = change32(hex);
|
||||
a[0] = Integer.parseInt(hexString.substring(0, 8), 2);//<EFBFBD><EFBFBD>
|
||||
a[0] = Integer.parseInt(hexString.substring(0, 8), 2);//将
|
||||
a[1] = Integer.parseInt(hexString.substring(8, 16), 2);
|
||||
a[2] = Integer.parseInt(hexString.substring(16, 24), 2);
|
||||
a[3] = Integer.parseInt(hexString.substring(24, 32), 2);
|
||||
@@ -85,7 +84,7 @@ public class Tools implements Serializable {
|
||||
public static int[] binaryTints16(String hex) {
|
||||
int[] a = new int[2];
|
||||
String hexString = change16(hex);
|
||||
a[0] = Integer.parseInt(hexString.substring(0, 8), 2);//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD>תΪ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
a[0] = Integer.parseInt(hexString.substring(0, 8), 2);//将二进制字符串转为整形
|
||||
a[1] = Integer.parseInt(hexString.substring(8, 16), 2);
|
||||
return a;
|
||||
}
|
||||
@@ -93,7 +92,7 @@ public class Tools implements Serializable {
|
||||
public static int binaryTints8(String hex) {
|
||||
int a;
|
||||
String hexString = change8(hex);
|
||||
a = Integer.parseInt(hexString.substring(0, 8), 2);//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD>תΪ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
a = Integer.parseInt(hexString.substring(0, 8), 2);//将二进制字符串转为整形
|
||||
return a;
|
||||
}
|
||||
|
||||
@@ -110,21 +109,21 @@ public class Tools implements Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* <EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD>תΪ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* 将字符转为整形
|
||||
**/
|
||||
public static int showAscii(char x) {
|
||||
return x;
|
||||
}
|
||||
|
||||
/**
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>תΪ<EFBFBD>ַ<EFBFBD>
|
||||
* 将整形转为字符
|
||||
**/
|
||||
public static char showChar(int x) {
|
||||
return (char) x;
|
||||
}
|
||||
|
||||
/**
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* 托盘条码解析
|
||||
**/
|
||||
public static String byteToStringTool(byte[] aaa) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
@@ -136,21 +135,21 @@ public class Tools implements Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>תΪ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD>
|
||||
* 将整形转为二进制字符串
|
||||
*/
|
||||
public static String printBits(int n) {
|
||||
return Integer.toBinaryString(n);
|
||||
}
|
||||
|
||||
/**
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>תΪ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* 将整形转为浮点型
|
||||
*/
|
||||
public static Float printFloat(int n) {
|
||||
return Float.intBitsToFloat(n);
|
||||
}
|
||||
|
||||
/**
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>8λ<EFBFBD>Ӹ<EFBFBD>λ<EFBFBD><EFBFBD>0
|
||||
* 不满8位加高位加0
|
||||
**/
|
||||
public static String change8(String value) {
|
||||
if (value != null && !value.equals("")) {
|
||||
@@ -165,7 +164,7 @@ public class Tools implements Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>32λ<EFBFBD>Ӹ<EFBFBD>λ<EFBFBD><EFBFBD>0 4<><34><EFBFBD>ֽ<EFBFBD>
|
||||
* 不满32位加高位加0 4个字节
|
||||
**/
|
||||
public static String change32(String value) {
|
||||
if (value != null && !value.equals("")) {
|
||||
@@ -180,7 +179,7 @@ public class Tools implements Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>16λ<EFBFBD>Ӹ<EFBFBD>λ<EFBFBD><EFBFBD>0 4<><34><EFBFBD>ֽ<EFBFBD>
|
||||
* 不满16位加高位加0 4个字节
|
||||
**/
|
||||
public static String change16(String value) {
|
||||
if (value != null && !value.equals("")) {
|
||||
@@ -195,7 +194,7 @@ public class Tools implements Serializable {
|
||||
}
|
||||
|
||||
|
||||
///<EFBFBD>ֽ<EFBFBD>ת<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
///字节转整型
|
||||
public static int get(byte a1, byte a2, byte a3, byte a4, byte a5, byte a6, byte a7, byte a8,
|
||||
byte a9, byte a10, byte a11, byte a12, byte a13, byte a14, byte a15, byte a16,
|
||||
byte a17, byte a18, byte a19, byte a20, byte a21, byte a22, byte a23, byte a24, byte a25) {
|
||||
@@ -225,7 +224,9 @@ public class Tools implements Serializable {
|
||||
ints[22] = binaryTints8(printBits(a23));
|
||||
ints[23] = binaryTints8(printBits(a24));
|
||||
ints[24] = binaryTints8(printBits(a25));
|
||||
for (int anInt : ints) System.out.print(anInt + " ");
|
||||
for (int anInt : ints) {
|
||||
System.out.print(anInt + " ");
|
||||
}
|
||||
System.out.println();
|
||||
return BytesToInt(ints);
|
||||
}
|
||||
@@ -233,18 +234,18 @@ public class Tools implements Serializable {
|
||||
|
||||
|
||||
//
|
||||
public static byte[] int2byte(int res) {///Java<EFBFBD><EFBFBD>10<EFBFBD><EFBFBD><EFBFBD><EFBFBD>תbyte[]
|
||||
public static byte[] int2byte(int res) {///Java中10进制转byte[]
|
||||
byte[] targets = new byte[4];
|
||||
|
||||
targets[3] = (byte) (res & 0xff);// <EFBFBD><EFBFBD><EFBFBD>λ
|
||||
targets[2] = (byte) ((res >> 8) & 0xff);// <EFBFBD>ε<EFBFBD>λ
|
||||
targets[1] = (byte) ((res >> 16) & 0xff);// <EFBFBD>θ<EFBFBD>λ
|
||||
targets[0] = (byte) (res >>> 24);// <EFBFBD><EFBFBD><EFBFBD>λ,<2C><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ơ<EFBFBD>
|
||||
targets[3] = (byte) (res & 0xff);// 最低位
|
||||
targets[2] = (byte) ((res >> 8) & 0xff);// 次低位
|
||||
targets[1] = (byte) ((res >> 16) & 0xff);// 次高位
|
||||
targets[0] = (byte) (res >>> 24);// 最高位,无符号右移。
|
||||
return targets;
|
||||
}
|
||||
|
||||
/**
|
||||
* <EFBFBD><EFBFBD><EFBFBD>byte <EFBFBD>ϲ<EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>byte
|
||||
* 多个byte 合并成一个byte
|
||||
*/
|
||||
public static byte[] byteMerge(byte[]... values) {
|
||||
int length_byte = 0;
|
||||
@@ -264,18 +265,20 @@ public class Tools implements Serializable {
|
||||
public static String bytetostringtool(byte[] aaa) {
|
||||
String tptm = "";
|
||||
for(int i=0;i<aaa.length;i++){
|
||||
//System.out.println("??????:for:"+aaa[i]);
|
||||
String x = Character.toString(showChar(aaa[i]));
|
||||
char ddd=showChar(aaa[i]);
|
||||
tptm=tptm+x;
|
||||
//System.out.println(tptm);
|
||||
}
|
||||
if(tptm.isEmpty() || "\u0000\u0000\u0000\u0000\u0000\u0000\u0000".equals(tptm)){
|
||||
return "";
|
||||
if(tptm.length() == 0 || tptm.equals("")){
|
||||
return "00000000";
|
||||
}else {
|
||||
return tptm;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* int תbyte
|
||||
* int 转byte
|
||||
*/
|
||||
public static byte[] intToBytes(int value, int len) {
|
||||
byte[] b = new byte[len];
|
||||
@@ -287,7 +290,7 @@ public class Tools implements Serializable {
|
||||
|
||||
|
||||
|
||||
//<EFBFBD>·<EFBFBD><EFBFBD>ֽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//下发字节数组
|
||||
public static byte[] sendDataToDevice(long taskNo,String trayCode, int...ints){
|
||||
int length = 0;
|
||||
byte[] xfData = null;
|
||||
@@ -343,58 +346,34 @@ public class Tools implements Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* <EFBFBD>ֽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD>
|
||||
* 字节数组转字符船
|
||||
*/
|
||||
public static String byteToString(String substring) {
|
||||
return new String(SoftBasic.HexStringToBytes(substring), StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static String getDate() {
|
||||
Date t = new Date();
|
||||
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
return df.format(t);
|
||||
}
|
||||
|
||||
//int ת2<EFBFBD>ֽ<EFBFBD>
|
||||
public static byte[] intbyte(int res) {///Java<EFBFBD><EFBFBD>10<EFBFBD><EFBFBD><EFBFBD><EFBFBD>תbyte[]
|
||||
//int 转2字节
|
||||
public static byte[] intbyte(int res) {///Java中10进制转byte[]
|
||||
byte[] targets = new byte[2];
|
||||
targets[1] = (byte) ((res >> 0) & 0xff);// <EFBFBD>θ<EFBFBD>λ
|
||||
targets[0] = (byte) (res >>> 8);// <EFBFBD><EFBFBD><EFBFBD>λ,<2C><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ơ<EFBFBD>
|
||||
targets[1] = (byte) ((res >> 0) & 0xff);// 次高位
|
||||
targets[0] = (byte) (res >>> 8);// 最高位,无符号右移。
|
||||
return targets;
|
||||
}
|
||||
|
||||
public static int[] binarysToints(String hex){
|
||||
int[] a = new int[4];
|
||||
String hexString = change32(hex);
|
||||
a[0] = Integer.parseInt(hexString.substring(0,8),2);//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD>תΪ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
a[0] = Integer.parseInt(hexString.substring(0,8),2);//将二进制字符串转为整形
|
||||
a[1] = Integer.parseInt(hexString.substring(8,16),2);
|
||||
a[2] = Integer.parseInt(hexString.substring(16,24),2);
|
||||
a[3] = Integer.parseInt(hexString.substring(24,32),2);
|
||||
return a;
|
||||
}
|
||||
|
||||
/**
|
||||
* 下发到PLC的反馈字节
|
||||
*/
|
||||
public static byte[] sendData(SendData... list) {
|
||||
byte[][] values = new byte[list.length][0];
|
||||
for (int i = 0; i < list.length; i++) {
|
||||
byte[] bytes = Tools.intToBytes(list[i].getNum2(), list[i].getNum());
|
||||
//System.out.println(bytes.length);
|
||||
values[i] = bytes;
|
||||
}
|
||||
int length_byte = 0;
|
||||
for (byte[] value : values) {
|
||||
length_byte += value.length;
|
||||
}
|
||||
byte[] all_byte = new byte[length_byte];
|
||||
int countLength = 0;
|
||||
for (byte[] b : values) {
|
||||
System.arraycopy(b, 0, all_byte, countLength, b.length);
|
||||
countLength += b.length;
|
||||
}
|
||||
return all_byte;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,256 @@
|
||||
package com.ruoyi.schedule.scheduleTask.ddj;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import com.ruoyi.api.domain.wcs2wms.JobParam;
|
||||
import com.ruoyi.api.service.IApiService;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import com.ruoyi.device.ddj.domain.MsgDdj;
|
||||
import com.ruoyi.job.domain.MydoJob;
|
||||
import com.ruoyi.job.service.IMydoJobService;
|
||||
import com.ruoyi.queue.ddj.domain.DdjDeviceExecutionQueue;
|
||||
import com.ruoyi.queue.ddj.service.IDdjDeviceExecutionQueueFinishService;
|
||||
import com.ruoyi.queue.ddj.service.IDdjDeviceExecutionQueueService;
|
||||
import com.ruoyi.schedule.plcRead.ddj.IsoTcpClientDDJ1;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcRead;
|
||||
import com.ruoyi.schedule.plcRead.util.Tools;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Slf4j
|
||||
public class Ddj1Thread implements Runnable {
|
||||
|
||||
public HashMap<String, List<String>> ddjCodeList;
|
||||
|
||||
private IApiService apiService;
|
||||
private IDdjDeviceExecutionQueueService ddjDeviceExecutionQueueService;
|
||||
private IDdjDeviceExecutionQueueFinishService ddjDeviceExecutionQueueFinishService;
|
||||
private IMydoJobService mydoJobService;
|
||||
|
||||
public boolean isRun = true;
|
||||
|
||||
|
||||
public void init() {
|
||||
//todo 获取设备编码列表
|
||||
ddjCodeList = new HashMap<>();
|
||||
ArrayList<String> ddjCodes = new ArrayList<>();
|
||||
ddjCodes.add("ddj1");
|
||||
ddjCodes.add("ddj2");
|
||||
ddjCodeList.put("ddj", ddjCodes);
|
||||
|
||||
apiService = SpringUtils.getBean(IApiService.class);
|
||||
ddjDeviceExecutionQueueService = SpringUtils.getBean(IDdjDeviceExecutionQueueService.class);
|
||||
ddjDeviceExecutionQueueFinishService = SpringUtils.getBean(IDdjDeviceExecutionQueueFinishService.class);
|
||||
log.info("初始化服务 {},{},{}", apiService, ddjDeviceExecutionQueueService, ddjDeviceExecutionQueueFinishService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
init();
|
||||
while (isRun) {
|
||||
for (String type : ddjCodeList.keySet()) {
|
||||
|
||||
if ("ddj".equals(type)) {
|
||||
for (String ddjCode : ddjCodeList.get(type)) {
|
||||
try {
|
||||
if (PlcRead.deviceDdjMap.containsKey(ddjCode)) {
|
||||
ddjTask(PlcRead.deviceDdjMap.get(ddjCode));
|
||||
} else {
|
||||
log.error("设备不存在 ssjCode{}", ddjCode);
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
Thread.sleep(1500);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void ddjTask(MsgDdj ddj) {
|
||||
/*
|
||||
第一部分
|
||||
堆垛机线程进来后第一件事先进行堆垛机正执行任务的账务处理
|
||||
以防存在漏处理,没处理的情况发生
|
||||
*/
|
||||
if (ddj.getCzfs() == 5 && ddj.getSbzt() == 0 && ddj.getJdbz() == 5) {
|
||||
Long rwh = ddj.getRwh();
|
||||
//完成作业
|
||||
MydoJob mydoJob = mydoJobService.selectMydoJobByTaskNo(rwh);
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(rwh);
|
||||
if (mydoJob != null && ddjDeviceExecutionQueue != null) {
|
||||
//回传完成信号
|
||||
ddjTaskFinish(rwh, ddj.getId());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
第二部分
|
||||
跟踪队列执行阶段
|
||||
*/
|
||||
if (ddj.getCzfs() == 5 && ddj.getSbzt() == 1 && (ddj.getJdbz() == 2 || ddj.getJdbz() == 3 || ddj.getJdbz() == 4)) {
|
||||
//根据堆垛机上任务号,修改任务执行阶段
|
||||
Long rwh = ddj.getRwh();
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(rwh);
|
||||
if (ddjDeviceExecutionQueue != null) {
|
||||
//修改队列执行阶段
|
||||
ddjDeviceExecutionQueue.setRwzt(ddj.getJdbz());
|
||||
ddjDeviceExecutionQueueService.updateDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
第三部分
|
||||
放货有货,重新分配货位
|
||||
*/
|
||||
if (ddj.getCzfs() == 5 && ddj.getSbzt() == 1052 && ddj.getJdbz() < 5 && ddj.getYxxf() == 1) {
|
||||
//判断堆垛机上任务是否已重分,若未重分,则调用接口,请求重分货位
|
||||
Long rwh = ddj.getRwh();
|
||||
MydoJob mydoJob = mydoJobService.selectMydoJobByTaskNo(rwh);
|
||||
if ("0".equals(mydoJob.getFaultFlag())){
|
||||
mydoJob.setStatus("1");
|
||||
mydoJobService.updateMydoJob(mydoJob);
|
||||
AjaxResult ajaxResult = apiService.reAssignMydoJob(new JobParam(rwh.toString(), null, null));
|
||||
if (ajaxResult.isSuccess()){
|
||||
mydoJob.setStatus("2");
|
||||
mydoJobService.updateMydoJob(mydoJob);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
第四部分
|
||||
取货无货,重新分配单据
|
||||
*/
|
||||
if (ddj.getCzfs() == 5 && ddj.getSbzt() == 1053 && ddj.getJdbz() < 5) {
|
||||
Long rwh = ddj.getRwh();
|
||||
//无货异常处理
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(rwh);
|
||||
//找到对应任务 调用api接口 取货无货,重新分配单据
|
||||
if (ObjUtil.isNotNull(ddjDeviceExecutionQueue)) {
|
||||
AjaxResult ajaxResult = apiService.reAssignMydoJob2(new JobParam(rwh.toString(), null, null));
|
||||
if (ajaxResult.isSuccess()) {
|
||||
//作废作业
|
||||
InvalidMydoJob(rwh, ddj.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
第五部分
|
||||
堆垛机任务下发
|
||||
*/
|
||||
if (ddj.getYxxf() == 1 && ddj.getCzfs() == 5 && ddj.getSbzt() == 1052) {
|
||||
Long rwh = ddj.getRwh();
|
||||
//查询作业
|
||||
MydoJob mydoJob = mydoJobService.selectMydoJobByTaskNo(rwh);
|
||||
if (ObjUtil.isNotNull(mydoJob) && "2".equals(mydoJob.getFaultFlag())) {
|
||||
//判断任务是否重分完成
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(rwh);
|
||||
if (ObjUtil.isNotNull(ddjDeviceExecutionQueue)) {
|
||||
//重新下发堆垛机任务
|
||||
int i = issuedDDJTask(ddj.getId(), ddjDeviceExecutionQueue);
|
||||
if (i == 1) {
|
||||
//更新开始时间,修改ddjxf为已下发1
|
||||
ddjDeviceExecutionQueue.setXfsj(DateUtil.formatDateTime(DateUtil.date()));
|
||||
ddjDeviceExecutionQueue.setDdjxf("1");
|
||||
ddjDeviceExecutionQueueService.updateDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
|
||||
mydoJob.setFaultFlag("0");
|
||||
mydoJobService.updateMydoJob(mydoJob);
|
||||
log.info("托盘堆垛机重新下发任务成功 rwh:{}", rwh);
|
||||
} else {
|
||||
log.error("托盘堆垛机重新下发任务失败!!!!!!!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//正常下发
|
||||
if (ddj.getYxxf() == 1 && ddj.getCzfs() == 5 && ddj.getSbzt() == 0) {
|
||||
Long rwh = ddj.getRwh();
|
||||
//对堆垛机执行队列中无已下发队列
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueueParam = new DdjDeviceExecutionQueue();
|
||||
ddjDeviceExecutionQueueParam.setDdjxf("1");
|
||||
ddjDeviceExecutionQueueParam.setDevId(ddj.getId());
|
||||
List<DdjDeviceExecutionQueue> ddjDeviceExecutionQueues = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueList(ddjDeviceExecutionQueueParam);
|
||||
//取堆垛机队列中,生成时间最早的执行队列下发
|
||||
if (CollUtil.isEmpty(ddjDeviceExecutionQueues)) {
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueues.get(0);
|
||||
if (ddjDeviceExecutionQueue == null) {
|
||||
return;
|
||||
}
|
||||
int i = issuedDDJTask(ddj.getId(), ddjDeviceExecutionQueue);
|
||||
if (i == 1) {
|
||||
//更新开始时间,修改ddjxf为已下发1
|
||||
ddjDeviceExecutionQueue.setXfsj(DateUtil.formatDateTime(DateUtil.date()));
|
||||
ddjDeviceExecutionQueue.setDdjxf("1");
|
||||
ddjDeviceExecutionQueueService.updateDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
|
||||
log.info("托盘堆垛机下发任务成功 rwh:{}", rwh);
|
||||
} else {
|
||||
log.error("托盘堆垛机下发任务失败!!!!!!!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 作废作业
|
||||
*
|
||||
* @param rwh 作业单号
|
||||
* @param id 作业单id
|
||||
*/
|
||||
private void InvalidMydoJob(Long rwh, Long id) {
|
||||
mydoJobService.InvalidMydoJob(rwh, id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 堆垛机任务完成
|
||||
*
|
||||
* @param rwh 作业单号
|
||||
* @param id 作业单id
|
||||
*/
|
||||
private void ddjTaskFinish(Long rwh, Long id) {
|
||||
mydoJobService.ddjTaskFinish(rwh, id);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 给堆垛机下发任务
|
||||
*
|
||||
* @param queue 堆垛机执行的队列
|
||||
*/
|
||||
private int issuedDDJTask(Long devId, DdjDeviceExecutionQueue queue) {
|
||||
int taskNo = Convert.toInt(queue.getRwh());
|
||||
int yph = Convert.toInt(queue.getYph());
|
||||
int ylh = Convert.toInt(queue.getYlh());
|
||||
int ych = Convert.toInt(queue.getYch());
|
||||
int mbph = Convert.toInt(queue.getMbph());
|
||||
int mblh = Convert.toInt(queue.getMblh());
|
||||
int mbch = Convert.toInt(queue.getMbch());
|
||||
int mlfs = 5;
|
||||
int xfwc = 1;
|
||||
int jym = Tools.getJYM(taskNo, yph, ylh, ych, mbph, mblh, mbch, mlfs, xfwc);
|
||||
byte[] sendData = Tools.sendDataToDevice(taskNo, null, yph, ylh, ych, mbph, mblh, mbch, mlfs, xfwc, jym);
|
||||
if (devId==1){
|
||||
return IsoTcpClientDDJ1.WritetoDDJ("DB61.0", sendData);
|
||||
}else {
|
||||
return IsoTcpClientDDJ1.WritetoDDJ("DB61.0", sendData);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,14 +1,14 @@
|
||||
package com.ruoyi.schedule.scheduleTask.ssj.js;
|
||||
package com.ruoyi.schedule.scheduleTask.ddj;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.ruoyi.api.domain.agv.genAgvSchedulingTask.GenAgvSchedulingTaskResponse;
|
||||
import com.ruoyi.api.domain.wcs2wms.MydoJob;
|
||||
import com.ruoyi.api.service.IApiService;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import com.ruoyi.device.agv.domain.AgvQueue;
|
||||
import com.ruoyi.device.agv.service.IAgvQueueService;
|
||||
import com.ruoyi.job.domain.MydoJob;
|
||||
import com.ruoyi.queue.agv.domain.AgvQueue;
|
||||
import com.ruoyi.queue.agv.service.IAgvQueueService;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcRead;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -19,7 +19,7 @@ import java.util.List;
|
||||
|
||||
|
||||
@Slf4j
|
||||
public class JsInSsjThread implements Runnable {
|
||||
public class Ddj2Thread implements Runnable {
|
||||
|
||||
public HashMap<String, List<String>> ssjCodeList;
|
||||
|
||||
@@ -58,8 +58,8 @@ public class JsInSsjThread implements Runnable {
|
||||
//正常入库 尾箱回流 物料入库 空料箱入库
|
||||
for (String ssjCode : ssjCodeList.get(type)) {
|
||||
try {
|
||||
if (PlcRead.deviceMap.containsKey(ssjCode)) {
|
||||
inDispatch(PlcRead.deviceMap.get(ssjCode));
|
||||
if (PlcRead.deviceSsjMap.containsKey(ssjCode)) {
|
||||
inDispatch(PlcRead.deviceSsjMap.get(ssjCode));
|
||||
} else {
|
||||
log.error("设备不存在 ssjCode{}", ssjCode);
|
||||
}
|
||||
@@ -1,148 +0,0 @@
|
||||
package com.ruoyi.schedule.scheduleTask.ssj.bs;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.ruoyi.bas.fluent.domain.BasFluentFrame;
|
||||
import com.ruoyi.bas.fluent.service.IBasFluentFrameService;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import com.ruoyi.device.agv.domain.AgvQueue;
|
||||
import com.ruoyi.device.agv.service.IAgvQueueService;
|
||||
import com.ruoyi.api.domain.agv.genAgvSchedulingTask.GenAgvSchedulingTaskRequest;
|
||||
import com.ruoyi.api.domain.agv.genAgvSchedulingTask.GenAgvSchedulingTaskResponse;
|
||||
import com.ruoyi.api.domain.wcs2wms.MydoJob;
|
||||
import com.ruoyi.api.service.IApiService;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcRead;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Slf4j
|
||||
public class BsOutSsjThread implements Runnable {
|
||||
|
||||
public HashMap<String, List<String>> ssjCodeList;
|
||||
|
||||
private IApiService apiService;
|
||||
private IAgvQueueService agvQueueService;
|
||||
private IBasFluentFrameService basFluentFrameService;
|
||||
|
||||
public boolean isRun = true;
|
||||
|
||||
|
||||
public void init() {
|
||||
ssjCodeList = new HashMap<>();
|
||||
ArrayList<String> ssjCodes = new ArrayList<>();
|
||||
ssjCodes.add("G1004");
|
||||
ssjCodes.add("G1010");
|
||||
ssjCodeList.put("ssjOut", ssjCodes);
|
||||
ArrayList<String> fluentOut = new ArrayList<>();
|
||||
fluentOut.add("fluent1");
|
||||
fluentOut.add("fluent2");
|
||||
ssjCodeList.put("fluentOut", fluentOut);
|
||||
|
||||
apiService = SpringUtils.getBean(IApiService.class);
|
||||
agvQueueService = SpringUtils.getBean(IAgvQueueService.class);
|
||||
basFluentFrameService = SpringUtils.getBean(IBasFluentFrameService.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
init();
|
||||
while (isRun){
|
||||
for (String type : ssjCodeList.keySet()) {
|
||||
switch (type){
|
||||
case "ssjOut":
|
||||
//正常输送线出口
|
||||
for (String ssjCode : ssjCodeList.get(type)) {
|
||||
try {
|
||||
if (PlcRead.deviceMap.containsKey(ssjCode)) {
|
||||
ssjOutDispatch(PlcRead.deviceMap.get(ssjCode));
|
||||
} else {
|
||||
log.error("设备不存在 ssjCode{}", ssjCode);
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
case "fluentOut":
|
||||
//流利架出口
|
||||
for (String ssjCode : ssjCodeList.get(type)) {
|
||||
try {
|
||||
fluentOutDispatch(ssjCode);
|
||||
}catch (Exception e){
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
try {
|
||||
Thread.sleep(1500);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 输送线出口
|
||||
* @param outSsjDevice
|
||||
*/
|
||||
public void ssjOutDispatch(DeviceSsj outSsjDevice) {
|
||||
//输送线出库
|
||||
if (outSsjDevice.getKx()==1){
|
||||
//查询对应的作业
|
||||
AgvQueue agvQueue = new AgvQueue();
|
||||
agvQueue.setPositionCode2(outSsjDevice.getDeviceCode());
|
||||
agvQueue.setStatus("0");
|
||||
List<AgvQueue> agvQueueList = agvQueueService.selectAgvQueueList(agvQueue);
|
||||
if (CollUtil.isNotEmpty(agvQueueList)){
|
||||
for (AgvQueue queue : agvQueueList) {
|
||||
apiService.requestAgvQueue(queue);
|
||||
agvQueue.setStatus("1");
|
||||
agvQueueService.updateAgvQueue(queue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* todo 流利架出口
|
||||
* @param outSsjDevice
|
||||
*/
|
||||
public void fluentOutDispatch(String outSsjDevice) {
|
||||
//查询对应的作业
|
||||
AgvQueue agvQueue = new AgvQueue();
|
||||
agvQueue.setPositionCode2(outSsjDevice);
|
||||
agvQueue.setStatus("0");
|
||||
List<AgvQueue> agvQueueList = agvQueueService.selectAgvQueueList(agvQueue);
|
||||
for (AgvQueue queue : agvQueueList) {
|
||||
//修改实际流利架货位
|
||||
BasFluentFrame basFluentFrame = basFluentFrameService.selectBasFluentFrameOrderByAllotNum(queue.getPositionCode2());
|
||||
if (basFluentFrame != null){
|
||||
queue.setPositionCode2(basFluentFrame.getLocationName());
|
||||
agvQueueService.updateAgvQueue(queue);
|
||||
GenAgvSchedulingTaskResponse genAgvSchedulingTaskResponse = apiService.requestAgvQueue(queue);
|
||||
if (genAgvSchedulingTaskResponse.getCode() == 0) {
|
||||
//修改ctu执行状态
|
||||
queue.setStatus("1");
|
||||
agvQueueService.updateAgvQueue(queue);
|
||||
log.info("向CTU下入库库作业");
|
||||
//更新流利架
|
||||
basFluentFrame.setTrayCode(queue.getWmsTraycode());
|
||||
basFluentFrame.setAllotNum(1L);
|
||||
basFluentFrameService.updateBasFluentFrame(basFluentFrame);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,119 +0,0 @@
|
||||
package com.ruoyi.schedule.scheduleTask.ssj.bs;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.ruoyi.api.domain.RequestLog;
|
||||
import com.ruoyi.api.service.IApiService;
|
||||
import com.ruoyi.bas.port.domain.WcsPort;
|
||||
import com.ruoyi.bas.port.service.IWcsPortService;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import com.ruoyi.device.agv.service.IAgvQueueService;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcRead;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.ruoyi.common.Constant.JOB_FINISH_URL;
|
||||
|
||||
|
||||
@Slf4j
|
||||
public class BsPickSsjTread implements Runnable{
|
||||
|
||||
public HashMap<String, List<String>> ssjCodeList;
|
||||
|
||||
private IApiService apiService;
|
||||
private IAgvQueueService agvQueueService;
|
||||
private IWcsPortService wcsPortService;
|
||||
|
||||
public boolean isRun = true;
|
||||
|
||||
|
||||
public void init() {
|
||||
ssjCodeList = new HashMap<>();
|
||||
ArrayList<String> ssjCodes = new ArrayList<>();
|
||||
ssjCodes.add("G1006");
|
||||
ssjCodes.add("G1012");
|
||||
ssjCodeList.put("pick", ssjCodes);
|
||||
|
||||
|
||||
apiService = SpringUtils.getBean(IApiService.class);
|
||||
agvQueueService = SpringUtils.getBean(IAgvQueueService.class);
|
||||
wcsPortService = SpringUtils.getBean(IWcsPortService.class);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
init();
|
||||
while (isRun) {
|
||||
for (String type : ssjCodeList.keySet()) {
|
||||
if ("pick".equals(type)) {
|
||||
for (String ssjCode : ssjCodeList.get(type)) {
|
||||
try {
|
||||
if (PlcRead.deviceMap.containsKey(ssjCode)) {
|
||||
pickDispatch(PlcRead.deviceMap.get(ssjCode));
|
||||
} else {
|
||||
log.error("设备不存在 ssjCode{}", ssjCode);
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error(e.getMessage(),e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
Thread.sleep(1500);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void pickDispatch(DeviceSsj pickSsjDevice) {
|
||||
if (pickSsjDevice.getDw() == 1 && pickSsjDevice.getTaskNo() > 0) {
|
||||
WcsPort wcsPortParam = new WcsPort();
|
||||
wcsPortParam.setPortCode(pickSsjDevice.getDeviceCode());
|
||||
wcsPortParam.setPortType("1");
|
||||
List<WcsPort> wcsPorts = wcsPortService.selectWcsPortList(wcsPortParam);
|
||||
if (CollUtil.isNotEmpty(wcsPorts)){
|
||||
WcsPort wcsPort = wcsPorts.get(0);
|
||||
if ("1".equals(wcsPort.getStatus())){
|
||||
Map<String, Object> param = new HashMap<>();
|
||||
param.put("taskNo", pickSsjDevice.getTaskNo());
|
||||
param.put("wmsType", "2");
|
||||
param.put("pickSsj", pickSsjDevice.getDeviceCode());
|
||||
RequestLog requestLog = apiService.finishMydoJob(JOB_FINISH_URL, "出库任务到达拣选口", param);
|
||||
if ("1".equals(requestLog.getIsSuccessful())){
|
||||
wcsPort.setStatus("2");
|
||||
wcsPortService.updateWcsPort(wcsPort);
|
||||
}else {
|
||||
log.error("任务失败{}", requestLog.getErrorDetails());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (pickSsjDevice.getKx() == 1 && pickSsjDevice.getTaskNo() == 0){
|
||||
WcsPort wcsPortParam = new WcsPort();
|
||||
wcsPortParam.setPortCode(pickSsjDevice.getDeviceCode());
|
||||
wcsPortParam.setPortType("1");
|
||||
List<WcsPort> wcsPorts = wcsPortService.selectWcsPortList(wcsPortParam);
|
||||
if (CollUtil.isNotEmpty(wcsPorts)){
|
||||
WcsPort wcsPort = wcsPorts.get(0);
|
||||
if ("2".equals(wcsPort.getStatus())){
|
||||
wcsPort.setStatus("1");
|
||||
wcsPortService.updateWcsPort(wcsPort);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,33 +1,25 @@
|
||||
package com.ruoyi.schedule.scheduleTask.ssj.bs;
|
||||
package com.ruoyi.schedule.scheduleTask.ssj.floor1;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.ruoyi.api.domain.agv.genAgvSchedulingTask.GenAgvSchedulingTaskRequest;
|
||||
import com.ruoyi.api.domain.agv.genAgvSchedulingTask.GenAgvSchedulingTaskResponse;
|
||||
import com.ruoyi.api.domain.wcs2wms.MydoJob;
|
||||
import com.ruoyi.api.service.IApiService;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import com.ruoyi.device.agv.domain.AgvQueue;
|
||||
import com.ruoyi.device.agv.service.IAgvQueueService;
|
||||
import com.ruoyi.job.domain.MydoJob;
|
||||
import com.ruoyi.queue.agv.domain.AgvQueue;
|
||||
import com.ruoyi.queue.agv.service.IAgvQueueService;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcRead;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@Slf4j
|
||||
public class BsInSsjThread implements Runnable {
|
||||
public class Floor1SsjInOutThread implements Runnable {
|
||||
|
||||
public HashMap<String, List<String>> ssjCodeList;
|
||||
|
||||
@@ -40,25 +32,15 @@ public class BsInSsjThread implements Runnable {
|
||||
public void init() {
|
||||
//todo 获取设备编码列表
|
||||
ssjCodeList = new HashMap<>();
|
||||
log.info("初始化臂式入库输送机");
|
||||
//入库口
|
||||
ArrayList<String> ssjCodes = new ArrayList<>();
|
||||
ssjCodes.add("G1003");
|
||||
ssjCodes.add("G1009");
|
||||
ssjCodeList.put("ssjIn", ssjCodes);
|
||||
//流利架
|
||||
ArrayList<String> ssjCodes2 = new ArrayList<>();
|
||||
ssjCodes2.add("fluent1-11");
|
||||
ssjCodes2.add("fluent1-12");
|
||||
ssjCodes2.add("fluent1-13");
|
||||
ssjCodes2.add("fluent1-14");
|
||||
ssjCodes2.add("fluent1-15");
|
||||
ssjCodes2.add("fluent2-11");
|
||||
ssjCodes2.add("fluent2-12");
|
||||
ssjCodes2.add("fluent2-13");
|
||||
ssjCodes2.add("fluent2-14");
|
||||
ssjCodes2.add("fluent2-15");
|
||||
ssjCodeList.put("fluentIn", ssjCodes2);
|
||||
ssjCodes.add("G2012");
|
||||
ssjCodes.add("G3009");
|
||||
ssjCodes.add("G3018");
|
||||
ssjCodes.add("G4009");
|
||||
ssjCodes.add("G4018");
|
||||
ssjCodes.add("G5009");
|
||||
ssjCodes.add("G5018");
|
||||
ssjCodeList.put("in", ssjCodes);
|
||||
|
||||
apiService = SpringUtils.getBean(IApiService.class);
|
||||
agvQueueService = SpringUtils.getBean(IAgvQueueService.class);
|
||||
@@ -68,36 +50,24 @@ public class BsInSsjThread implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
init();
|
||||
while (isRun) {
|
||||
while (isRun){
|
||||
for (String type : ssjCodeList.keySet()) {
|
||||
|
||||
switch (type) {
|
||||
case "ssjIn":
|
||||
//正常入库
|
||||
switch ( type){
|
||||
case "in":
|
||||
//正常入库 尾箱回流 物料入库 空料箱入库
|
||||
for (String ssjCode : ssjCodeList.get(type)) {
|
||||
try {
|
||||
if (PlcRead.deviceMap.containsKey(ssjCode)) {
|
||||
inDispatch(PlcRead.deviceMap.get(ssjCode));
|
||||
if (PlcRead.deviceSsjMap.containsKey(ssjCode)) {
|
||||
inDispatch(PlcRead.deviceSsjMap.get(ssjCode));
|
||||
} else {
|
||||
log.error("设备不存在 ssjCode{}", ssjCode);
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
log.error(e.getMessage(),e);
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
case "fluentIn":
|
||||
//流利架 空料箱入库
|
||||
for (String lljCode : ssjCodeList.get(type)) {
|
||||
try {
|
||||
inLljDispatch(lljCode);
|
||||
} catch (RuntimeException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -108,44 +78,9 @@ public class BsInSsjThread implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 流利架空料箱入库
|
||||
*
|
||||
* @param lljCode
|
||||
*/
|
||||
private void inLljDispatch(String lljCode) {
|
||||
|
||||
//判断是否生成队列
|
||||
AgvQueue agvQueueParam = new AgvQueue();
|
||||
agvQueueParam.setPositionCode1(lljCode);
|
||||
agvQueueParam.setStatus("0");
|
||||
List<AgvQueue> agvQueues = agvQueueService.selectAgvQueueList(agvQueueParam);
|
||||
if (CollUtil.isNotEmpty(agvQueues)) {
|
||||
for (AgvQueue agvQueue : agvQueues) {
|
||||
//请求任务生成
|
||||
GenAgvSchedulingTaskResponse genAgvSchedulingTaskResponse = apiService.requestAgvQueue(agvQueue);
|
||||
//修改wms任务状态
|
||||
if (genAgvSchedulingTaskResponse.getCode() == 0) {
|
||||
//修改ctu执行状态
|
||||
agvQueue.setStatus("1");
|
||||
agvQueueService.updateAgvQueue(agvQueue);
|
||||
log.info("向CTU下入库库作业");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 输送线入库
|
||||
*
|
||||
* @param inSsjDevice
|
||||
*/
|
||||
public void inDispatch(DeviceSsj inSsjDevice) {
|
||||
//如果入库请求1 并且 托盘码不为空
|
||||
if (inSsjDevice.getDw()==1 && inSsjDevice.getRkqq() == 1 && StrUtil.isNotEmpty(inSsjDevice.getTrayCode())) {
|
||||
@@ -166,7 +101,7 @@ public class BsInSsjThread implements Runnable {
|
||||
//生成agv队列
|
||||
AgvQueue agvQueue = apiService.createAgvQueue(inSsjDevice.getName(), mydoJob.getCargoSpaceId(),mydoJob.getTrayCode(),mydoJob.getTaskNo(),"1");
|
||||
//请求任务生成
|
||||
GenAgvSchedulingTaskResponse genAgvSchedulingTaskResponse = apiService.requestAgvQueue( agvQueue);
|
||||
GenAgvSchedulingTaskResponse genAgvSchedulingTaskResponse = apiService.requestAgvQueue(agvQueue);
|
||||
//修改wms任务状态
|
||||
if (genAgvSchedulingTaskResponse.getCode() == 0) {
|
||||
//修改ctu执行状态
|
||||
@@ -194,7 +129,4 @@ public class BsInSsjThread implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
package com.ruoyi.schedule.scheduleTask.ssj.floor1;
|
||||
|
||||
import com.ruoyi.api.service.IApiService;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import com.ruoyi.queue.agv.service.IAgvQueueService;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcRead;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Slf4j
|
||||
public class Floor1SsjRoadWayThread implements Runnable {
|
||||
|
||||
public HashMap<String, List<String>> ssjCodeList;
|
||||
|
||||
private IApiService apiService;
|
||||
private IAgvQueueService agvQueueService;
|
||||
|
||||
public boolean isRun = true;
|
||||
|
||||
|
||||
public void init() {
|
||||
//todo 获取设备编码列表
|
||||
ssjCodeList = new HashMap<>();
|
||||
ArrayList<String> in = new ArrayList<>();
|
||||
in.add("L2003");
|
||||
in.add("L2005");
|
||||
ssjCodeList.put("in", in);
|
||||
ArrayList<String> out = new ArrayList<>();
|
||||
in.add("L2003");
|
||||
in.add("L2005");
|
||||
ssjCodeList.put("out", out);
|
||||
|
||||
apiService = SpringUtils.getBean(IApiService.class);
|
||||
agvQueueService = SpringUtils.getBean(IAgvQueueService.class);
|
||||
log.info("初始化服务 {},{}", apiService, agvQueueService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
init();
|
||||
while (isRun) {
|
||||
for (String type : ssjCodeList.keySet()) {
|
||||
|
||||
switch (type) {
|
||||
case "in":
|
||||
//退料入库 其它入库
|
||||
for (String ssjCode : ssjCodeList.get(type)) {
|
||||
try {
|
||||
if (PlcRead.deviceSsjMap.containsKey(ssjCode)) {
|
||||
inDispatch(PlcRead.deviceSsjMap.get(ssjCode));
|
||||
} else {
|
||||
log.error("设备不存在 ssjCode{}", ssjCode);
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
case "out":
|
||||
for (String ssjCode : ssjCodeList.get(type)) {
|
||||
try {
|
||||
if (PlcRead.deviceSsjMap.containsKey(ssjCode)) {
|
||||
outDispatch(PlcRead.deviceSsjMap.get(ssjCode));
|
||||
} else {
|
||||
log.error("设备不存在 ssjCode{}", ssjCode);
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
try {
|
||||
Thread.sleep(1500);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void outDispatch(DeviceSsj outSsjDevice) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void inDispatch(DeviceSsj inSsjDevice) {
|
||||
//如果入库请求1 并且 托盘码不为空
|
||||
if (inSsjDevice.getDw() == 1 && inSsjDevice.getTaskNo() > 0 && inSsjDevice.getRkqq() == 1) {
|
||||
//查询货位 排列层
|
||||
|
||||
//查询入口 排列层
|
||||
|
||||
//生成堆垛机队列
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
package com.ruoyi.schedule.scheduleTask.ssj.floor2;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.ruoyi.api.domain.agv.genAgvSchedulingTask.GenAgvSchedulingTaskResponse;
|
||||
import com.ruoyi.api.service.IApiService;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import com.ruoyi.job.domain.MydoJob;
|
||||
import com.ruoyi.queue.agv.domain.AgvQueue;
|
||||
import com.ruoyi.queue.agv.service.IAgvQueueService;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcRead;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Slf4j
|
||||
public class Floor2SsjInOutThread implements Runnable {
|
||||
|
||||
public HashMap<String, List<String>> ssjCodeList;
|
||||
|
||||
private IApiService apiService;
|
||||
private IAgvQueueService agvQueueService;
|
||||
|
||||
public boolean isRun = true;
|
||||
|
||||
|
||||
public void init() {
|
||||
//todo 获取设备编码列表
|
||||
ssjCodeList = new HashMap<>();
|
||||
ArrayList<String> ssjCodes = new ArrayList<>();
|
||||
ssjCodes.add("G2012");
|
||||
ssjCodes.add("G3009");
|
||||
ssjCodes.add("G3018");
|
||||
ssjCodes.add("G4009");
|
||||
ssjCodes.add("G4018");
|
||||
ssjCodes.add("G5009");
|
||||
ssjCodes.add("G5018");
|
||||
ssjCodeList.put("in", ssjCodes);
|
||||
|
||||
apiService = SpringUtils.getBean(IApiService.class);
|
||||
agvQueueService = SpringUtils.getBean(IAgvQueueService.class);
|
||||
log.info("初始化服务 {},{}", apiService, agvQueueService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
init();
|
||||
while (isRun){
|
||||
for (String type : ssjCodeList.keySet()) {
|
||||
|
||||
switch ( type){
|
||||
case "in":
|
||||
//正常入库 尾箱回流 物料入库 空料箱入库
|
||||
for (String ssjCode : ssjCodeList.get(type)) {
|
||||
try {
|
||||
if (PlcRead.deviceSsjMap.containsKey(ssjCode)) {
|
||||
inDispatch(PlcRead.deviceSsjMap.get(ssjCode));
|
||||
} else {
|
||||
log.error("设备不存在 ssjCode{}", ssjCode);
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
log.error(e.getMessage(),e);
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
try {
|
||||
Thread.sleep(1500);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void inDispatch(DeviceSsj inSsjDevice) {
|
||||
//如果入库请求1 并且 托盘码不为空
|
||||
if (inSsjDevice.getDw()==1 && inSsjDevice.getRkqq() == 1 && StrUtil.isNotEmpty(inSsjDevice.getTrayCode())) {
|
||||
//判断是否生成队列
|
||||
AgvQueue agvQueueParam = new AgvQueue();
|
||||
agvQueueParam.setWmsTraycode(inSsjDevice.getTrayCode());
|
||||
//agvQueueParam.setStatus("0");
|
||||
List<AgvQueue> agvQueues = agvQueueService.selectAgvQueueList(agvQueueParam);
|
||||
if (CollUtil.isEmpty(agvQueues)) {
|
||||
//根据入口,查询对应的入库作业
|
||||
MydoJob mydoJobParam = new MydoJob();
|
||||
mydoJobParam.setStatus("1");
|
||||
mydoJobParam.setTrayCode(inSsjDevice.getTrayCode());
|
||||
mydoJobParam.setEntranceId(inSsjDevice.getDeviceCode());
|
||||
MydoJob mydoJob = apiService.requestEnterByTrayCode(mydoJobParam);
|
||||
if (ObjUtil.isNotNull(mydoJob)) {
|
||||
|
||||
//生成agv队列
|
||||
AgvQueue agvQueue = apiService.createAgvQueue(inSsjDevice.getName(), mydoJob.getCargoSpaceId(),mydoJob.getTrayCode(),mydoJob.getTaskNo(),"1");
|
||||
//请求任务生成
|
||||
GenAgvSchedulingTaskResponse genAgvSchedulingTaskResponse = apiService.requestAgvQueue(agvQueue);
|
||||
//修改wms任务状态
|
||||
if (genAgvSchedulingTaskResponse.getCode() == 0) {
|
||||
//修改ctu执行状态
|
||||
agvQueue.setStatus("1");
|
||||
agvQueueService.updateAgvQueue(agvQueue);
|
||||
log.info("向CTU下入库库作业");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}else {
|
||||
AgvQueue agvQueue = agvQueues.get(0);
|
||||
if ("0".equals(agvQueue.getStatus())){
|
||||
//请求任务生成
|
||||
GenAgvSchedulingTaskResponse genAgvSchedulingTaskResponse = apiService.requestAgvQueue(agvQueue);
|
||||
//修改wms任务状态
|
||||
if (genAgvSchedulingTaskResponse.getCode() == 0) {
|
||||
//修改ctu执行状态
|
||||
agvQueue.setStatus("1");
|
||||
agvQueueService.updateAgvQueue(agvQueue);
|
||||
log.info("向CTU下入库库作业");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package com.ruoyi.schedule.scheduleTask.ssj.floor2;
|
||||
|
||||
import com.ruoyi.api.service.IApiService;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import com.ruoyi.queue.agv.service.IAgvQueueService;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcRead;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Slf4j
|
||||
public class Floor2SsjRoadWayThread implements Runnable {
|
||||
|
||||
public HashMap<String, List<String>> ssjCodeList;
|
||||
|
||||
private IApiService apiService;
|
||||
private IAgvQueueService agvQueueService;
|
||||
|
||||
public boolean isRun = true;
|
||||
|
||||
|
||||
public void init() {
|
||||
ssjCodeList = new HashMap<>();
|
||||
ArrayList<String> ssjCodes = new ArrayList<>();
|
||||
ssjCodes.add("L1002");
|
||||
ssjCodes.add("L1004");
|
||||
ssjCodeList.put("in", ssjCodes);
|
||||
apiService = SpringUtils.getBean(IApiService.class);
|
||||
agvQueueService = SpringUtils.getBean(IAgvQueueService.class);
|
||||
log.info("初始化服务 {},{}", apiService, agvQueueService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
init();
|
||||
while (isRun){
|
||||
for (String type : ssjCodeList.keySet()) {
|
||||
|
||||
switch ( type){
|
||||
case "in":
|
||||
//生产线入库
|
||||
for (String ssjCode : ssjCodeList.get(type)) {
|
||||
try {
|
||||
if (PlcRead.deviceSsjMap.containsKey(ssjCode)) {
|
||||
inDispatch(PlcRead.deviceSsjMap.get(ssjCode));
|
||||
} else {
|
||||
log.error("设备不存在 ssjCode{}", ssjCode);
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
log.error(e.getMessage(),e);
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
try {
|
||||
Thread.sleep(1500);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void inDispatch(DeviceSsj inSsjDevice) {
|
||||
//如果入库请求1 并且 托盘码不为空
|
||||
if (inSsjDevice.getDw() == 1 && inSsjDevice.getTaskNo() > 0 && inSsjDevice.getRkqq() == 1) {
|
||||
//查询货位 排列层
|
||||
|
||||
//查询入口 排列层
|
||||
|
||||
//生成堆垛机队列
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,135 +0,0 @@
|
||||
package com.ruoyi.schedule.scheduleTask.ssj.js;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.ruoyi.api.domain.agv.continueTask.ContinueTaskRequest;
|
||||
import com.ruoyi.api.domain.agv.continueTask.ContinueTaskResponse;
|
||||
import com.ruoyi.api.domain.agv.genAgvSchedulingTask.GenAgvSchedulingTaskRequest;
|
||||
import com.ruoyi.api.domain.agv.genAgvSchedulingTask.GenAgvSchedulingTaskResponse;
|
||||
import com.ruoyi.api.domain.wcs2wms.MydoJob;
|
||||
import com.ruoyi.api.service.IApiService;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import com.ruoyi.device.agv.domain.AgvQueue;
|
||||
import com.ruoyi.device.agv.service.IAgvQueueService;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcRead;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Slf4j
|
||||
public class JsOutSsjThread implements Runnable{
|
||||
|
||||
public HashMap<String, List<String>> ssjCodeList;
|
||||
|
||||
private IApiService apiService;
|
||||
private IAgvQueueService agvQueueService;
|
||||
|
||||
public boolean isRun = true;
|
||||
|
||||
|
||||
public void init() {
|
||||
ssjCodeList = new HashMap<>();
|
||||
ArrayList<String> ssjCodes = new ArrayList<>();
|
||||
ssjCodes.add("G2001");
|
||||
ssjCodes.add("G3001");
|
||||
ssjCodes.add("G3010");
|
||||
ssjCodes.add("G4001");
|
||||
ssjCodes.add("G4010");
|
||||
ssjCodes.add("G5001");
|
||||
ssjCodes.add("G5010");
|
||||
ssjCodeList.put("ssjOut", ssjCodes);
|
||||
|
||||
apiService = SpringUtils.getBean(IApiService.class);
|
||||
agvQueueService = SpringUtils.getBean(IAgvQueueService.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
init();
|
||||
|
||||
while (isRun){
|
||||
for (String type : ssjCodeList.keySet()) {
|
||||
switch (type){
|
||||
case "ssjOut":
|
||||
try {
|
||||
//正常输送线出口
|
||||
for (String ssjCode : ssjCodeList.get(type)) {
|
||||
if (PlcRead.deviceMap.containsKey(ssjCode)) {
|
||||
ssjOutDispatch(PlcRead.deviceMap.get(ssjCode));
|
||||
} else {
|
||||
log.error("设备不存在 ssjCode{}", ssjCode);
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
break;
|
||||
case "fluentOut":
|
||||
//流利架出口(剪式没有)
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
Thread.sleep(1500);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 输送线出口
|
||||
* @param outSsjDevice
|
||||
*/
|
||||
public void ssjOutDispatch(DeviceSsj outSsjDevice) {
|
||||
if (outSsjDevice.getKx()==1){
|
||||
//查询对应的作业
|
||||
AgvQueue agvQueue = new AgvQueue();
|
||||
agvQueue.setPositionCode2(outSsjDevice.getDeviceCode());
|
||||
agvQueue.setStatus("0");
|
||||
List<AgvQueue> agvQueueList = agvQueueService.selectAgvQueueList(agvQueue);
|
||||
if (CollUtil.isNotEmpty(agvQueueList)){
|
||||
for (AgvQueue queue : agvQueueList) {
|
||||
requestAgvQueue( queue);
|
||||
}
|
||||
}else {
|
||||
log.info("ssjCode:{},没有待下发的出库任务", outSsjDevice.getDeviceCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求海康生成agv任务,并修改wms任务状态
|
||||
* @param agvQueue
|
||||
*/
|
||||
private void requestAgvQueue(AgvQueue agvQueue) {
|
||||
//请求ctu
|
||||
GenAgvSchedulingTaskRequest genAgvSchedulingTaskRequest = new GenAgvSchedulingTaskRequest();
|
||||
genAgvSchedulingTaskRequest.setReqCode(agvQueue.getReqCode());
|
||||
genAgvSchedulingTaskRequest.setTaskMode("0");
|
||||
genAgvSchedulingTaskRequest.setPriority("10");
|
||||
genAgvSchedulingTaskRequest.setTaskTyp("F01");
|
||||
genAgvSchedulingTaskRequest.setCtnrCode("0");
|
||||
genAgvSchedulingTaskRequest.setCtnrNum("0");
|
||||
genAgvSchedulingTaskRequest.setTaskMode("0");
|
||||
genAgvSchedulingTaskRequest.setTaskCode(agvQueue.getTaskCode());
|
||||
genAgvSchedulingTaskRequest.setAgvTyp("CTU");
|
||||
genAgvSchedulingTaskRequest.setPositionSelStrategy("0");
|
||||
GenAgvSchedulingTaskResponse genAgvSchedulingTaskResponse = apiService.genAgvSchedulingTask(genAgvSchedulingTaskRequest);
|
||||
if (genAgvSchedulingTaskResponse.getCode() == 0){
|
||||
//修改ctu执行状态
|
||||
agvQueue.setStatus("1");
|
||||
agvQueueService.updateAgvQueue(agvQueue);
|
||||
log.info("向CTU下入库库作业");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,131 +0,0 @@
|
||||
package com.ruoyi.schedule.scheduleTask.ssj.js;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.ruoyi.api.domain.RequestLog;
|
||||
import com.ruoyi.api.service.IApiService;
|
||||
import com.ruoyi.bas.port.domain.WcsPort;
|
||||
import com.ruoyi.bas.port.service.IWcsPortService;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import com.ruoyi.device.agv.service.IAgvQueueService;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcRead;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.ruoyi.common.Constant.JOB_FINISH_URL;
|
||||
|
||||
|
||||
@Slf4j
|
||||
public class JsPickSsjTread implements Runnable {
|
||||
|
||||
public HashMap<String, List<String>> ssjCodeList;
|
||||
|
||||
private IApiService apiService;
|
||||
private IAgvQueueService agvQueueService;
|
||||
private IWcsPortService wcsPortService;
|
||||
|
||||
|
||||
public boolean isRun = true;
|
||||
|
||||
|
||||
public void init() {
|
||||
ssjCodeList = new HashMap<>();
|
||||
ArrayList<String> ssjCodes = new ArrayList<>();
|
||||
ssjCodes.add("G5013");
|
||||
ssjCodes.add("G5014");
|
||||
ssjCodes.add("G5015");
|
||||
ssjCodes.add("G5004");
|
||||
ssjCodes.add("G5005");
|
||||
ssjCodes.add("G5006");
|
||||
ssjCodes.add("G4013");
|
||||
ssjCodes.add("G4014");
|
||||
ssjCodes.add("G4015");
|
||||
ssjCodes.add("G4004");
|
||||
ssjCodes.add("G4005");
|
||||
ssjCodes.add("G4006");
|
||||
ssjCodeList.put("pick", ssjCodes);
|
||||
|
||||
|
||||
apiService = SpringUtils.getBean(IApiService.class);
|
||||
agvQueueService = SpringUtils.getBean(IAgvQueueService.class);
|
||||
wcsPortService = SpringUtils.getBean(IWcsPortService.class);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void run(){
|
||||
init();
|
||||
while (isRun){
|
||||
for (String type : ssjCodeList.keySet()) {
|
||||
if ("pick".equals(type)) {
|
||||
for (String ssjCode : ssjCodeList.get(type)) {
|
||||
try {
|
||||
if (PlcRead.deviceMap.containsKey(ssjCode)) {
|
||||
pickDispatch(PlcRead.deviceMap.get(ssjCode));
|
||||
} else {
|
||||
log.error("设备不存在 ssjCode{}", ssjCode);
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error(e.getMessage(),e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
Thread.sleep(1500);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void pickDispatch(DeviceSsj pickSsjDevice) {
|
||||
if (pickSsjDevice.getDw() == 1 && pickSsjDevice.getTaskNo() > 0) {
|
||||
WcsPort wcsPortParam = new WcsPort();
|
||||
wcsPortParam.setPortCode(pickSsjDevice.getDeviceCode());
|
||||
wcsPortParam.setPortType("1");
|
||||
List<WcsPort> wcsPorts = wcsPortService.selectWcsPortList(wcsPortParam);
|
||||
if (CollUtil.isNotEmpty(wcsPorts)){
|
||||
WcsPort wcsPort = wcsPorts.get(0);
|
||||
if ("1".equals(wcsPort.getStatus())){
|
||||
Map<String, Object> param = new HashMap<>();
|
||||
param.put("taskNo", pickSsjDevice.getTaskNo());
|
||||
param.put("wmsType", "2");
|
||||
param.put("pickSsj", pickSsjDevice.getDeviceCode());
|
||||
RequestLog requestLog = apiService.finishMydoJob(JOB_FINISH_URL, "出库任务到达拣选口", param);
|
||||
if ("1".equals(requestLog.getIsSuccessful())){
|
||||
wcsPort.setStatus("2");
|
||||
wcsPortService.updateWcsPort(wcsPort);
|
||||
}else {
|
||||
log.error("任务失败{}", requestLog.getErrorDetails());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (pickSsjDevice.getKx() == 1 && pickSsjDevice.getTaskNo() == 0){
|
||||
WcsPort wcsPortParam = new WcsPort();
|
||||
wcsPortParam.setPortCode(pickSsjDevice.getDeviceCode());
|
||||
wcsPortParam.setPortType("1");
|
||||
List<WcsPort> wcsPorts = wcsPortService.selectWcsPortList(wcsPortParam);
|
||||
if (CollUtil.isNotEmpty(wcsPorts)){
|
||||
WcsPort wcsPort = wcsPorts.get(0);
|
||||
if ("2".equals(wcsPort.getStatus())){
|
||||
wcsPort.setStatus("1");
|
||||
wcsPortService.updateWcsPort(wcsPort);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,95 +0,0 @@
|
||||
package com.ruoyi.schedule.scheduleTask.ssj.monitor;
|
||||
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
import com.ruoyi.device.ssj.service.IDeviceSsjService;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcRead;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
|
||||
@Slf4j
|
||||
public class CarMonitorThread implements Runnable {
|
||||
|
||||
|
||||
|
||||
private IDeviceSsjService deviceSsjService;
|
||||
public boolean isRun = true;
|
||||
|
||||
|
||||
public void init() {
|
||||
deviceSsjService = SpringUtils.getBean(IDeviceSsjService.class);
|
||||
log.info("初始化服务 {}", deviceSsjService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
init();
|
||||
while (isRun) {
|
||||
for (String ssjCode : PlcRead.deviceMap.keySet()) {
|
||||
try {
|
||||
DeviceSsj deviceSsj = PlcRead.deviceMap.get(ssjCode);
|
||||
if (ObjUtil.isNotNull(deviceSsj)){
|
||||
switch (deviceSsj.getType()) {
|
||||
case "1":
|
||||
monitor1(deviceSsj);
|
||||
break;
|
||||
case "2":
|
||||
monitor2(deviceSsj);
|
||||
break;
|
||||
case "3":
|
||||
monitor3(deviceSsj);
|
||||
break;
|
||||
case "4":
|
||||
monitor4(deviceSsj);
|
||||
break;
|
||||
}
|
||||
}else {
|
||||
log.error("设备不存在 {}", ssjCode);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
try {
|
||||
Thread.sleep(1500);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*其他输送机监控
|
||||
* @param deviceSsj
|
||||
*/
|
||||
private void monitor4(DeviceSsj deviceSsj) {
|
||||
deviceSsjService.updateDeviceSsj(deviceSsj);
|
||||
}
|
||||
|
||||
/**
|
||||
*入库输送机监控
|
||||
* @param deviceSsj
|
||||
*/
|
||||
private void monitor3(DeviceSsj deviceSsj) {
|
||||
deviceSsjService.updateDeviceSsj(deviceSsj);
|
||||
}
|
||||
|
||||
/**
|
||||
*拣选输送机监控
|
||||
* @param deviceSsj
|
||||
*/
|
||||
private void monitor2(DeviceSsj deviceSsj) {
|
||||
deviceSsjService.updateDeviceSsj(deviceSsj);
|
||||
}
|
||||
|
||||
/**
|
||||
*出库输送机监控
|
||||
* @param deviceSsj
|
||||
*/
|
||||
private void monitor1(DeviceSsj deviceSsj) {
|
||||
deviceSsjService.updateDeviceSsj(deviceSsj);
|
||||
}
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
package com.ruoyi.schedule.scheduleTask.ssj.monitor;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.ruoyi.api.domain.agv.genAgvSchedulingTask.GenAgvSchedulingTaskResponse;
|
||||
import com.ruoyi.api.domain.wcs2wms.MydoJob;
|
||||
import com.ruoyi.api.service.IApiService;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import com.ruoyi.device.agv.domain.AgvQueue;
|
||||
import com.ruoyi.device.agv.service.IAgvQueueService;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
import com.ruoyi.device.ssj.service.IDeviceSsjService;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcRead;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Slf4j
|
||||
public class SsjMonitorThread implements Runnable {
|
||||
|
||||
|
||||
|
||||
private IDeviceSsjService deviceSsjService;
|
||||
public boolean isRun = true;
|
||||
|
||||
|
||||
public void init() {
|
||||
deviceSsjService = SpringUtils.getBean(IDeviceSsjService.class);
|
||||
log.info("初始化服务 {}", deviceSsjService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
init();
|
||||
while (isRun) {
|
||||
for (String ssjCode : PlcRead.deviceMap.keySet()) {
|
||||
try {
|
||||
DeviceSsj deviceSsj = PlcRead.deviceMap.get(ssjCode);
|
||||
if (ObjUtil.isNotNull(deviceSsj)){
|
||||
switch (deviceSsj.getType()) {
|
||||
case "1":
|
||||
monitor1(deviceSsj);
|
||||
break;
|
||||
case "2":
|
||||
monitor2(deviceSsj);
|
||||
break;
|
||||
case "3":
|
||||
monitor3(deviceSsj);
|
||||
break;
|
||||
case "4":
|
||||
monitor4(deviceSsj);
|
||||
break;
|
||||
}
|
||||
}else {
|
||||
log.error("设备不存在 {}", ssjCode);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
try {
|
||||
Thread.sleep(15000);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*其他输送机监控
|
||||
* @param deviceSsj
|
||||
*/
|
||||
private void monitor4(DeviceSsj deviceSsj) {
|
||||
deviceSsjService.updateDeviceSsj(deviceSsj);
|
||||
}
|
||||
|
||||
/**
|
||||
*入库输送机监控
|
||||
* @param deviceSsj
|
||||
*/
|
||||
private void monitor3(DeviceSsj deviceSsj) {
|
||||
deviceSsjService.updateDeviceSsj(deviceSsj);
|
||||
}
|
||||
|
||||
/**
|
||||
*拣选输送机监控
|
||||
* @param deviceSsj
|
||||
*/
|
||||
private void monitor2(DeviceSsj deviceSsj) {
|
||||
deviceSsjService.updateDeviceSsj(deviceSsj);
|
||||
}
|
||||
|
||||
/**
|
||||
*出库输送机监控
|
||||
* @param deviceSsj
|
||||
*/
|
||||
private void monitor1(DeviceSsj deviceSsj) {
|
||||
deviceSsjService.updateDeviceSsj(deviceSsj);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user