ctu agv callback接口返回处理逻辑
This commit is contained in:
@@ -22,9 +22,14 @@ import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.text.Convert;
|
||||
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 com.ruoyi.schedule.plcRead.ssj.domain.SendData;
|
||||
import com.ruoyi.schedule.plcRead.util.Tools;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -70,6 +75,7 @@ public class ApiServiceImpl implements IApiService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AgvCallbackResponse agvCallback(AgvCallbackRequest request) {
|
||||
RequestLog requestLog = requestLogService.getRequestLog(JSONUtil.toJsonStr(request), "AGV任务执行通知");
|
||||
requestLog.setRequestUrl("http://10.214.18.61:8089/external/log/outStockJob");
|
||||
@@ -112,20 +118,25 @@ public class ApiServiceImpl implements IApiService {
|
||||
switch (request.getMethod()) {
|
||||
case "start":
|
||||
//任务开始
|
||||
agvQueue.setStatus("2");
|
||||
agvQueueService.updateAgvQueue(agvQueue);
|
||||
log.info("【AGV任务开始】任务号:{}", taskCode);
|
||||
break;
|
||||
case "outbin":
|
||||
//走出储位
|
||||
if ("2".equals(agvQueue.getStatus())) {
|
||||
agvQueue.setStatus("3");
|
||||
agvQueueService.updateAgvQueue(agvQueue);
|
||||
log.info("【AGV走出储位】任务号:{}", taskCode);
|
||||
}
|
||||
agvQueue.setStatus("3");
|
||||
agvQueueService.updateAgvQueue(agvQueue);
|
||||
log.info("【AGV走出储位】任务号:{}", taskCode);
|
||||
break;
|
||||
case "end":
|
||||
//任务结束
|
||||
agvQueue.setStatus("4");
|
||||
agvQueueService.updateAgvQueue(agvQueue);
|
||||
//通知wms agv搬运阶段完成
|
||||
Map<String, Object> param = new HashMap<>();
|
||||
param.put("task_no", agvQueue.getWmsTaskNo());
|
||||
param.put("tray_code", agvQueue.getWmsTraycode());
|
||||
param.put("wms_type", agvQueue.getWmsTaskType());
|
||||
if ("1".equals(agvQueue.getWmsTaskType()) || "2".equals(agvQueue.getWmsTaskType())){
|
||||
//通知wms 任务结束
|
||||
MydoJob mydoJobParam = new MydoJob();
|
||||
@@ -134,22 +145,53 @@ public class ApiServiceImpl implements IApiService {
|
||||
List<MydoJob> mydoJobList = getMydoJobList(mydoJobParam);
|
||||
if (CollUtil.isNotEmpty(mydoJobList)) {
|
||||
MydoJob mydoJob = mydoJobList.get(0);
|
||||
//通知wms agv搬运阶段完成
|
||||
Map<String, Object> param = new HashMap<>();
|
||||
param.put("task_no", agvQueue.getWmsTaskNo());
|
||||
param.put("tray_code", agvQueue.getWmsTraycode());
|
||||
requestLogService.getRequestLog(AGV_FINISH_URL, "agv任务完成", JSONUtil.toJsonStr(param));
|
||||
log.info("【AGV任务结束】任务号:{}", taskCode);
|
||||
|
||||
if (Convert.toInt(mydoJob.getInOrOut()) < 20) {
|
||||
//入库任务 暂无特殊逻辑
|
||||
RequestLog requestLog = requestLogService.getRequestLog(AGV_FINISH_URL, "agv任务完成", JSONUtil.toJsonStr(param));
|
||||
if ("1".equals(requestLog.getIsSuccessful())){
|
||||
//插入历史
|
||||
agvQueueService.insertHistory(agvQueue.getReqCode());
|
||||
//删除队列
|
||||
agvQueueService.deleteAgvQueueByReqCode(agvQueue.getReqCode());
|
||||
log.info("【AGV任务结束】任务号:{}", taskCode);
|
||||
|
||||
}
|
||||
} else {
|
||||
//todo 写入对应的plc 任务号
|
||||
//写入对应的plc 任务号
|
||||
DeviceSsj deviceSsj = PlcRead.deviceMap.get(mydoJob.getExitId());
|
||||
if (ObjUtil.isNotNull(deviceSsj)){
|
||||
SendData rwh = new SendData(Tools.DINT, mydoJob.getTaskNo());
|
||||
byte[] bytes = Tools.sendData(rwh);
|
||||
//写入信息 取货完成
|
||||
int i = PlcRead.WriteToSSJ(deviceSsj.getPlcDbWriteAddress(), bytes);
|
||||
if (i==1){
|
||||
RequestLog requestLog = requestLogService.getRequestLog(AGV_FINISH_URL, "agv任务完成", JSONUtil.toJsonStr(param));
|
||||
if ("1".equals(requestLog.getIsSuccessful())){
|
||||
//插入历史
|
||||
agvQueueService.insertHistory(agvQueue.getReqCode());
|
||||
//删除队列
|
||||
agvQueueService.deleteAgvQueueByReqCode(agvQueue.getReqCode());
|
||||
log.info("【AGV任务结束】任务号:{}", taskCode);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.info("【AGV任务结束】任务号:{},wms不存在对应的作业", taskCode);
|
||||
}
|
||||
}else if (agvQueue.getWmsTaskType().equals("3")){
|
||||
//todo 绑定点位和料架
|
||||
}else if ("3".equals(agvQueue.getWmsTaskType())){
|
||||
//绑定点位和料架
|
||||
RequestLog requestLog = requestLogService.getRequestLog(AGV_FINISH_URL, "agv任务完成", JSONUtil.toJsonStr(param));
|
||||
if ("1".equals(requestLog.getIsSuccessful())){
|
||||
//插入历史
|
||||
agvQueueService.insertHistory(agvQueue.getReqCode());
|
||||
//删除队列
|
||||
agvQueueService.deleteAgvQueueByReqCode(agvQueue.getReqCode());
|
||||
log.info("【AGV任务结束】任务号:{}", taskCode);
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "cancel":
|
||||
|
||||
@@ -65,4 +65,6 @@ public interface AgvQueueMapper
|
||||
* @return
|
||||
*/
|
||||
AgvQueue selectAgvQueueByTaskCode(String taskCode);
|
||||
|
||||
void insertHistory(String reqCode);
|
||||
}
|
||||
|
||||
@@ -65,4 +65,10 @@ public interface IAgvQueueService
|
||||
* @return
|
||||
*/
|
||||
AgvQueue selectAgvQueueByTaskCode(String taskCode);
|
||||
|
||||
/**
|
||||
* 插入agv完成历史
|
||||
* @param reqCode
|
||||
*/
|
||||
void insertHistory(String reqCode);
|
||||
}
|
||||
|
||||
@@ -95,4 +95,9 @@ public class AgvQueueServiceImpl implements IAgvQueueService
|
||||
public AgvQueue selectAgvQueueByTaskCode(String taskCode) {
|
||||
return agvQueueMapper.selectAgvQueueByTaskCode(taskCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertHistory(String reqCode) {
|
||||
agvQueueMapper.insertHistory(reqCode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,4 +51,16 @@ public class ThreadOperationController {
|
||||
scheduleThread.stopAllThread();
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭线程
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/stopAllThread2")
|
||||
//@PreAuthorize("@ss.hasPermi('device:operation:stop')")
|
||||
public AjaxResult stopAllThread2() {
|
||||
scheduleThread.stopAllThread2();
|
||||
return AjaxResult.success();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,11 @@ 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 org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -23,6 +27,10 @@ public class ScheduleThread {
|
||||
|
||||
public CustomThread bsInSsjThread;
|
||||
public CustomThread jsInSsjThread;
|
||||
public CustomThread bsOutSsjThread;
|
||||
public CustomThread jsOutSsjThread;
|
||||
public CustomThread bsPickSsjThread;
|
||||
public CustomThread jsPickSsjThread;
|
||||
|
||||
/**
|
||||
* 项目初始化启动
|
||||
@@ -39,6 +47,7 @@ public class ScheduleThread {
|
||||
list.put(deviceSsj.getDeviceCode(),deviceSsj);
|
||||
}
|
||||
|
||||
//plc读取线程
|
||||
PlcRead plcRead = new PlcRead(list,ssjPlcConnectInfo);
|
||||
Thread plcReadThread = new Thread(plcRead);
|
||||
customThread = new CustomThread(plcReadThread, plcRead);
|
||||
@@ -48,6 +57,14 @@ public class ScheduleThread {
|
||||
bsInSsjThread = new CustomThread(new Thread(bsInSsjThread1),bsInSsjThread1);
|
||||
JsInSsjThread jsInSsjThread1 = new JsInSsjThread();
|
||||
jsInSsjThread = new CustomThread(new Thread(jsInSsjThread1),bsInSsjThread1);
|
||||
BsOutSsjThread bsOutSsjThread1 = new BsOutSsjThread();
|
||||
bsOutSsjThread = new CustomThread(new Thread(bsOutSsjThread1),bsOutSsjThread1);
|
||||
JsOutSsjThread jsOutSsjThread1 = new JsOutSsjThread();
|
||||
jsOutSsjThread = new CustomThread(new Thread(jsOutSsjThread1),jsOutSsjThread1);
|
||||
BsPickSsjTread bsPickSsjTread1 = new BsPickSsjTread();
|
||||
bsPickSsjThread = new CustomThread(new Thread(bsPickSsjTread1),bsPickSsjTread1);
|
||||
JsPickSsjTread jsPickSsjTread1 = new JsPickSsjTread();
|
||||
jsPickSsjThread = new CustomThread(new Thread(jsPickSsjTread1),jsPickSsjTread1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -58,8 +75,18 @@ public class ScheduleThread {
|
||||
}
|
||||
|
||||
public void startAllThread2() {
|
||||
//臂式入库线程调度
|
||||
bsInSsjThread.getThread().start();
|
||||
//剪式入库线程调度
|
||||
jsInSsjThread.getThread().start();
|
||||
//臂式出库线程调度
|
||||
bsOutSsjThread.getThread().start();
|
||||
//剪式出库线程调度
|
||||
jsOutSsjThread.getThread().start();
|
||||
//臂式出库到位线程调度-wms电子屏交互
|
||||
bsPickSsjThread.getThread().start();
|
||||
//剪上出库到位线程调度-wms电子屏交互
|
||||
jsPickSsjThread.getThread().start();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -69,18 +96,20 @@ public class ScheduleThread {
|
||||
stopThread(customThread);
|
||||
}
|
||||
|
||||
public void stopAllThread2() {
|
||||
stopThread(bsInSsjThread);
|
||||
stopThread(jsInSsjThread);
|
||||
stopThread(bsOutSsjThread);
|
||||
stopThread(jsOutSsjThread);
|
||||
stopThread(bsPickSsjThread);
|
||||
stopThread(jsPickSsjThread);
|
||||
}
|
||||
|
||||
/**
|
||||
* 停止线程
|
||||
*/
|
||||
private void stopThread(CustomThread customThread) {
|
||||
if (customThread.getThread() != null && customThread.getThread().isAlive()) {
|
||||
((PlcRead)customThread.getRunnable()).stopReading();
|
||||
try {
|
||||
customThread.getThread().join(); // 等待线程结束
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import HslCommunication.Core.Types.OperateResultExOne;
|
||||
import HslCommunication.Profinet.Siemens.SiemensPLCS;
|
||||
import HslCommunication.Profinet.Siemens.SiemensS7Net;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
import com.ruoyi.schedule.plcRead.ssj.domain.HslRead;
|
||||
import com.ruoyi.schedule.plcRead.ssj.domain.PlcConnectInfo;
|
||||
import com.ruoyi.schedule.plcRead.util.ParseUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -18,7 +19,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
public class PlcRead implements Runnable {
|
||||
|
||||
public static ConcurrentHashMap<String, DeviceSsj> deviceMap;
|
||||
private volatile boolean running = true;
|
||||
public volatile boolean isRun = true;
|
||||
|
||||
public SiemensS7Net siemensS7Net = null;
|
||||
public static IReadWriteNet readWriteNet = null;
|
||||
@@ -32,9 +33,17 @@ public class PlcRead implements Runnable {
|
||||
this.port = plcConnectInfo.getPort();
|
||||
}
|
||||
|
||||
public static int WriteToSSJ(String address, byte[] data) {
|
||||
int a = 0;
|
||||
if (readWriteNet != null) {
|
||||
a = HslRead.WriteResultRender(readWriteNet.Write(address, data), address);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
while (running && !Thread.currentThread().isInterrupted()) {
|
||||
while (isRun) {
|
||||
try {
|
||||
if (IsConnect()) {
|
||||
int step = 20;
|
||||
@@ -511,11 +520,6 @@ public class PlcRead implements Runnable {
|
||||
}
|
||||
|
||||
|
||||
public void stopReading() {
|
||||
running = false;
|
||||
Thread.currentThread().interrupt(); // 主动中断线程
|
||||
}
|
||||
|
||||
|
||||
void ConnectServer() {
|
||||
siemensS7Net = new SiemensS7Net(SiemensPLCS.S1500);
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
package com.ruoyi.schedule.plcRead.ssj.domain;
|
||||
|
||||
import HslCommunication.BasicFramework.SoftBasic;
|
||||
import HslCommunication.Core.Net.IReadWriteNet;
|
||||
import HslCommunication.Core.Types.OperateResult;
|
||||
import HslCommunication.Core.Types.OperateResultExOne;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
public class HslRead {
|
||||
|
||||
private static SimpleDateFormat dateFormat = new SimpleDateFormat("[HH:mm:ss] ");
|
||||
|
||||
/**
|
||||
* 将结果信息显示出来,在界面里进行显示
|
||||
* @param result 等待显示的结果信息
|
||||
* @param x
|
||||
* @param address 读取的地址数据
|
||||
* @param textBox 显示结果的文本框
|
||||
* @param scrollPane 支持滚动条的控件
|
||||
* @param <T> 类型对象
|
||||
* @return
|
||||
* @return
|
||||
* @return
|
||||
* @return
|
||||
* @return
|
||||
*/
|
||||
public static <T> T ReadResultRender(OperateResultExOne<T> result ) {
|
||||
|
||||
T x = null ;
|
||||
if (result.IsSuccess) {
|
||||
if (result.Content.getClass().isArray()) {
|
||||
|
||||
} else {
|
||||
x= (T) result.Content;
|
||||
}
|
||||
} else {
|
||||
|
||||
JOptionPane.showMessageDialog(
|
||||
null,
|
||||
dateFormat.format(new Date()) + "] Read Failed\r\nReason:" + result.ToMessageShowString(),
|
||||
"Result",
|
||||
JOptionPane.WARNING_MESSAGE);
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
public static int WriteResultRender(OperateResult result, String address ) { //void
|
||||
int x=0;
|
||||
if (result.IsSuccess) {
|
||||
// JOptionPane.showMessageDialog(
|
||||
// null,
|
||||
// dateFormat.format(new Date()) + "[" + address + "] Write Success",
|
||||
// "Result",
|
||||
// JOptionPane.PLAIN_MESSAGE);
|
||||
x=1;
|
||||
} else {
|
||||
// JOptionPane.showMessageDialog(
|
||||
// null,
|
||||
// dateFormat.format(new Date()) + "[" + address + "] Write Failed\r\nReason:" + result.ToMessageShowString(),
|
||||
// "Result",
|
||||
// JOptionPane.WARNING_MESSAGE);
|
||||
x=2;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
public static void BulkReadRenderResult(IReadWriteNet readWrite, JTextField addTextBox, JTextField lengthTextBox, JTextArea resultTextBox ) {
|
||||
try {
|
||||
OperateResultExOne<byte[]> read = readWrite.Read(addTextBox.getText(), Short.parseShort(lengthTextBox.getText()));
|
||||
if (read.IsSuccess) {
|
||||
resultTextBox.setText("Result:" + SoftBasic.ByteToHexString(read.Content));
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(null, "Read Failed:" + read.ToMessageShowString(), "Result", JOptionPane.WARNING_MESSAGE);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
JOptionPane.showMessageDialog(null, "Read Failed:" + ex.getMessage(), "Result", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetPanelEnabled(JPanel panel, boolean enable) {
|
||||
Component[] components = panel.getComponents();
|
||||
|
||||
//System.out.println("Component Length:" + components.length);
|
||||
for (Component component : components) {
|
||||
if (component instanceof JPanel) {
|
||||
SetPanelEnabled((JPanel) component, enable);
|
||||
} else {
|
||||
component.setEnabled(enable);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static String IpAddressInputWrong = "IpAddress input wrong";
|
||||
public static String PortInputWrong = "Port input wrong";
|
||||
public static String SlotInputWrong = "Slot input wrong";
|
||||
public static String BaudRateInputWrong = "Baud rate input wrong";
|
||||
public static String DataBitsInputWrong = "Data bit input wrong";
|
||||
public static String StopBitInputWrong = "Stop bit input wrong";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.ruoyi.schedule.plcRead.ssj.domain;
|
||||
|
||||
/**
|
||||
* 发送数据的实体类
|
||||
* @num 长度
|
||||
* @num2 值
|
||||
*/
|
||||
public class SendData {
|
||||
private static final int DINT = 4;
|
||||
private static final int INT = 2;
|
||||
private int num;
|
||||
private int num2;
|
||||
|
||||
public SendData(int num, int num2) {
|
||||
this.num = num;
|
||||
this.num2 = num2;
|
||||
}
|
||||
|
||||
public SendData(int num, String num2) {
|
||||
this.num = num;
|
||||
this.num2 = Integer.parseInt(num2);
|
||||
}
|
||||
|
||||
public int getNum() {
|
||||
return num;
|
||||
}
|
||||
|
||||
public void setNum(int num) {
|
||||
this.num = num;
|
||||
}
|
||||
|
||||
public int getNum2() {
|
||||
return num2;
|
||||
}
|
||||
|
||||
public void setNum2(int num2) {
|
||||
this.num2 = num2;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
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;
|
||||
@@ -375,4 +376,27 @@ public class Tools implements Serializable {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ public class BsInSsjThread implements Runnable {
|
||||
ArrayList<String> ssjCodes = new ArrayList<>();
|
||||
ssjCodes.add("G1003");
|
||||
ssjCodes.add("G1009");
|
||||
ssjCodeList.put("in", ssjCodes);
|
||||
ssjCodeList.put("ssjIn", ssjCodes);
|
||||
//流利架
|
||||
ArrayList<String> ssjCodes2 = new ArrayList<>();
|
||||
ssjCodes2.add("LLJ1");
|
||||
@@ -51,7 +51,7 @@ public class BsInSsjThread implements Runnable {
|
||||
ssjCodes2.add("LLJ3");
|
||||
ssjCodes2.add("LLJ4");
|
||||
ssjCodes2.add("LLJ5");
|
||||
ssjCodeList.put("in2", ssjCodes2);
|
||||
ssjCodeList.put("fluentIn", ssjCodes2);
|
||||
|
||||
apiService = SpringUtils.getBean(IApiService.class);
|
||||
agvQueueService = SpringUtils.getBean(IAgvQueueService.class);
|
||||
@@ -65,7 +65,7 @@ public class BsInSsjThread implements Runnable {
|
||||
for (String type : ssjCodeList.keySet()) {
|
||||
|
||||
switch ( type){
|
||||
case "in":
|
||||
case "ssjIn":
|
||||
//正常入库
|
||||
for (String ssjCode : ssjCodeList.get(type)) {
|
||||
try {
|
||||
@@ -80,7 +80,7 @@ public class BsInSsjThread implements Runnable {
|
||||
|
||||
}
|
||||
break;
|
||||
case "in2":
|
||||
case "fluentIn":
|
||||
//流利架 空料箱入库
|
||||
for (String lljCode : ssjCodeList.get(type)) {
|
||||
try {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.ruoyi.schedule.scheduleTask.ssj.bs;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
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;
|
||||
@@ -20,45 +21,68 @@ import java.util.List;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class BsOutSsjThread {
|
||||
public class BsOutSsjThread implements Runnable {
|
||||
|
||||
public HashMap<String, List<String>> ssjCodeList;
|
||||
|
||||
@Resource
|
||||
private IApiService apiService;
|
||||
@Resource
|
||||
private IAgvQueueService agvQueueService;
|
||||
|
||||
public boolean isRun = true;
|
||||
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
ssjCodeList = new HashMap<>();
|
||||
ArrayList<String> ssjCodes = new ArrayList<>();
|
||||
ssjCodes.add("G1004");
|
||||
ssjCodes.add("G1010");
|
||||
ssjCodeList.put("ssjOut", ssjCodes);
|
||||
|
||||
apiService = SpringUtils.getBean(IApiService.class);
|
||||
agvQueueService = SpringUtils.getBean(IAgvQueueService.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for (String type : ssjCodeList.keySet()) {
|
||||
switch (type){
|
||||
case "ssjOut":
|
||||
//正常输送线出口
|
||||
for (String ssjCode : ssjCodeList.get(type)) {
|
||||
if (PlcRead.deviceMap.containsKey(ssjCode)) {
|
||||
ssjOutDispatch(PlcRead.deviceMap.get(ssjCode));
|
||||
} else {
|
||||
log.error("设备不存在 ssjCode{}", ssjCode);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "fluentOut":
|
||||
//流利架出口
|
||||
break;
|
||||
}
|
||||
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(3000);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -94,10 +118,10 @@ public class BsOutSsjThread {
|
||||
}
|
||||
|
||||
/**
|
||||
* 流利架出口
|
||||
* todo 流利架出口
|
||||
* @param outSsjDevice
|
||||
*/
|
||||
public void fluentOutDispatch(DeviceSsj outSsjDevice) {
|
||||
public void fluentOutDispatch(String outSsjDevice) {
|
||||
//查询流利架货位是否
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.ruoyi.schedule.scheduleTask.ssj.bs;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import com.ruoyi.device.agv.service.IAgvQueueService;
|
||||
import com.ruoyi.common.core.text.Convert;
|
||||
import com.ruoyi.api.domain.wcs2wms.MydoJob;
|
||||
@@ -19,39 +20,50 @@ import java.util.List;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class BsPickSsjTread {
|
||||
public class BsPickSsjTread implements Runnable{
|
||||
|
||||
public HashMap<String, List<String>> ssjCodeList;
|
||||
|
||||
@Resource
|
||||
private IApiService apiService;
|
||||
@Resource
|
||||
private IAgvQueueService agvQueueService;
|
||||
|
||||
public boolean isRun = true;
|
||||
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
ssjCodeList = new HashMap<>();
|
||||
ArrayList<String> ssjCodes = new ArrayList<>();
|
||||
//流利架
|
||||
ssjCodes.add("G1004");
|
||||
ssjCodes.add("G1010");
|
||||
ssjCodeList.put("pick", ssjCodes);
|
||||
|
||||
|
||||
apiService = SpringUtils.getBean(IApiService.class);
|
||||
agvQueueService = SpringUtils.getBean(IAgvQueueService.class);
|
||||
}
|
||||
|
||||
|
||||
@Scheduled(fixedDelay = 5000)
|
||||
public void run(){
|
||||
for (String type : ssjCodeList.keySet()) {
|
||||
if ("pick".equals(type)) {
|
||||
for (String ssjCode : ssjCodeList.get(type)) {
|
||||
if (PlcRead.deviceMap.containsKey(ssjCode)) {
|
||||
pickDispatch(PlcRead.deviceMap.get(ssjCode));
|
||||
} else {
|
||||
log.error("设备不存在 ssjCode{}", ssjCode);
|
||||
@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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void pickDispatch(DeviceSsj pickSsjDevice) {
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
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;
|
||||
@@ -20,18 +23,16 @@ import java.util.List;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class JsOutSsjThread {
|
||||
public class JsOutSsjThread implements Runnable{
|
||||
|
||||
public HashMap<String, List<String>> ssjCodeList;
|
||||
|
||||
@Resource
|
||||
private IApiService apiService;
|
||||
@Resource
|
||||
private IAgvQueueService agvQueueService;
|
||||
|
||||
public boolean isRun = true;
|
||||
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
ssjCodeList = new HashMap<>();
|
||||
ArrayList<String> ssjCodes = new ArrayList<>();
|
||||
@@ -43,27 +44,46 @@ public class JsOutSsjThread {
|
||||
ssjCodes.add("G5001");
|
||||
ssjCodes.add("G5010");
|
||||
ssjCodeList.put("ssjOut", ssjCodes);
|
||||
|
||||
apiService = SpringUtils.getBean(IApiService.class);
|
||||
agvQueueService = SpringUtils.getBean(IAgvQueueService.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for (String type : ssjCodeList.keySet()) {
|
||||
switch (type){
|
||||
case "ssjOut":
|
||||
//正常输送线出口
|
||||
for (String ssjCode : ssjCodeList.get(type)) {
|
||||
if (PlcRead.deviceMap.containsKey(ssjCode)) {
|
||||
ssjOutDispatch(PlcRead.deviceMap.get(ssjCode));
|
||||
} else {
|
||||
log.error("设备不存在 ssjCode{}", ssjCode);
|
||||
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;
|
||||
break;
|
||||
case "fluentOut":
|
||||
//流利架出口(剪式没有)
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
Thread.sleep(3000);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -71,41 +91,52 @@ public class JsOutSsjThread {
|
||||
* @param outSsjDevice
|
||||
*/
|
||||
public void ssjOutDispatch(DeviceSsj outSsjDevice) {
|
||||
//查询对应的作业 请求ctu生成对应任务单执行
|
||||
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) {
|
||||
MydoJob mydoJobParam = new MydoJob();
|
||||
mydoJobParam.setTaskNo(queue.getWmsTaskNo());
|
||||
mydoJobParam.setTrayCode(queue.getWmsTraycode());
|
||||
mydoJobParam.setCargoSpaceId(queue.getPositionCode1());
|
||||
List<MydoJob> mydoJobList = apiService.getMydoJobList(mydoJobParam);
|
||||
if (CollUtil.isNotEmpty(mydoJobList)){
|
||||
MydoJob mydoJob = mydoJobList.get(0);
|
||||
requestAgvQueue(mydoJob, queue);
|
||||
}else {
|
||||
log.info("队列 agvCode {},无对应出库作业", agvQueue.getReqCode());
|
||||
}
|
||||
}
|
||||
}else {
|
||||
log.info("ssjCode:{},没有待下发的出库任务", outSsjDevice.getDeviceCode());
|
||||
}
|
||||
|
||||
//输送线出库
|
||||
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) {
|
||||
MydoJob mydoJobParam = new MydoJob();
|
||||
mydoJobParam.setTaskNo(queue.getWmsTaskNo());
|
||||
mydoJobParam.setTrayCode(queue.getWmsTraycode());
|
||||
mydoJobParam.setCargoSpaceId(queue.getPositionCode1());
|
||||
List<MydoJob> mydoJobList = apiService.getMydoJobList(mydoJobParam);
|
||||
if (CollUtil.isNotEmpty(mydoJobList)){
|
||||
MydoJob mydoJob = mydoJobList.get(0);
|
||||
requestAgvQueue(mydoJob, queue);
|
||||
}else {
|
||||
log.info("队列 agvCode {},无对应出库作业", agvQueue.getReqCode());
|
||||
AgvQueue agvQueue1 = new AgvQueue();
|
||||
agvQueue1.setPositionCode2(outSsjDevice.getDeviceCode());
|
||||
agvQueue1.setRequest("1");
|
||||
List<AgvQueue> agvQueueList1 = agvQueueService.selectAgvQueueList(agvQueue1);
|
||||
if (CollUtil.isNotEmpty(agvQueueList1)){
|
||||
for (AgvQueue queue : agvQueueList1) {
|
||||
if ("1".equals(queue.getRequest())){
|
||||
//todo 放入继续任务的参数
|
||||
ContinueTaskRequest continueTaskRequest = new ContinueTaskRequest();
|
||||
ContinueTaskResponse continueTaskResponse = apiService.continueTask(continueTaskRequest);
|
||||
if (continueTaskResponse.getCode()==0){
|
||||
//更新任务单状态
|
||||
agvQueue1.setRequest("2");
|
||||
agvQueueService.updateAgvQueue(agvQueue1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}else {
|
||||
log.info("ssjCode:{},没有待下发的出库任务", outSsjDevice.getDeviceCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 流利架出口
|
||||
* @param outSsjDevice
|
||||
*/
|
||||
public void fluentOutDispatch(DeviceSsj outSsjDevice) {
|
||||
//查询流利架货位是否
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求海康生成agv任务,并修改wms任务状态
|
||||
* @param mydoJob
|
||||
|
||||
@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import com.ruoyi.api.domain.wcs2wms.MydoJob;
|
||||
import com.ruoyi.api.service.IApiService;
|
||||
import com.ruoyi.common.core.text.Convert;
|
||||
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;
|
||||
@@ -19,18 +20,16 @@ import java.util.List;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class JsPickSsjTread {
|
||||
public class JsPickSsjTread implements Runnable {
|
||||
|
||||
public HashMap<String, List<String>> ssjCodeList;
|
||||
|
||||
@Resource
|
||||
private IApiService apiService;
|
||||
@Resource
|
||||
private IAgvQueueService agvQueueService;
|
||||
|
||||
public boolean isRun = true;
|
||||
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
ssjCodeList = new HashMap<>();
|
||||
ArrayList<String> ssjCodes = new ArrayList<>();
|
||||
@@ -47,21 +46,34 @@ public class JsPickSsjTread {
|
||||
ssjCodes.add("G4005");
|
||||
ssjCodes.add("G4006");
|
||||
ssjCodeList.put("pick", ssjCodes);
|
||||
|
||||
|
||||
apiService = SpringUtils.getBean(IApiService.class);
|
||||
agvQueueService = SpringUtils.getBean(IAgvQueueService.class);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void run(){
|
||||
for (String type : ssjCodeList.keySet()) {
|
||||
if ("pick".equals(type)) {
|
||||
for (String ssjCode : ssjCodeList.get(type)) {
|
||||
if (PlcRead.deviceMap.containsKey(ssjCode)) {
|
||||
pickDispatch(PlcRead.deviceMap.get(ssjCode));
|
||||
} else {
|
||||
log.error("设备不存在 ssjCode{}", ssjCode);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void pickDispatch(DeviceSsj pickSsjDevice) {
|
||||
|
||||
@@ -102,6 +102,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="taskCode != null">#{taskCode},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<insert id="insertHistory">
|
||||
insert into agv_queue_finish
|
||||
select *
|
||||
from agv_queue
|
||||
where req_code = #{reqCode}
|
||||
</insert>
|
||||
|
||||
<update id="updateAgvQueue" parameterType="AgvQueue">
|
||||
update agv_queue
|
||||
|
||||
Reference in New Issue
Block a user