opt:1.一个设备点变更成两个AGV站点。2.增加手持功能。
This commit is contained in:
@@ -418,11 +418,23 @@
|
||||
<groupId>org.openscada.jinterop</groupId>
|
||||
<artifactId>org.openscada.jinterop.core</artifactId>
|
||||
<version>2.1.8</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcprov-jdk15on</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openscada.jinterop</groupId>
|
||||
<artifactId>org.openscada.jinterop.deps</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcprov-jdk15on</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openscada.utgard</groupId>
|
||||
|
||||
@@ -1,330 +1,330 @@
|
||||
package org.nl.acs.auto.run;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.nl.acs.AcsConfig;
|
||||
import org.nl.acs.agv.server.NDCAgvService;
|
||||
import org.nl.acs.device.domain.Device;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.device_driver.basedriver.agv.ndcone.AgvNdcOneDeviceDriver;
|
||||
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
||||
import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl;
|
||||
import org.nl.acs.instruction.domain.Instruction;
|
||||
import org.nl.acs.instruction.service.InstructionService;
|
||||
import org.nl.acs.instruction.service.impl.InstructionServiceImpl;
|
||||
import org.nl.acs.log.service.DeviceExecuteLogService;
|
||||
import org.nl.acs.opc.DeviceAppService;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
import org.nl.system.service.dict.ISysDictService;
|
||||
import org.nl.system.service.lucene.LuceneExecuteLogService;
|
||||
import org.nl.system.service.param.ISysParamService;
|
||||
import org.nl.system.service.param.impl.SysParamServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.Socket;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import static org.nl.acs.agv.server.impl.NDCAgvServiceImpl.Bytes2HexString;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
@Lazy
|
||||
public class TwoNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
||||
|
||||
Socket s;
|
||||
String ip = "192.168.10.34";
|
||||
int port = 1234;
|
||||
static DataOutputStream dos;
|
||||
static DataInputStream dis;
|
||||
private int recordTimeOut = 10000;
|
||||
private Date recordTime;
|
||||
String[] ERROR = new String[]{
|
||||
"货叉尖部传感器触发", "S300传感器触发", "载货状态改变", "急停按钮触发", "触边开关出发", "需要复位",
|
||||
"停在充电位", "取货失败", "放货失败", "轮子打滑", "没有动作码不能进入站点", "取货时有货", "丢失定位",
|
||||
"抬叉停止"};
|
||||
boolean bConnected = true;
|
||||
|
||||
boolean isReConnect = false;
|
||||
|
||||
@Autowired
|
||||
ISysParamService paramService;
|
||||
@Autowired
|
||||
AutoRunService autoRunService;
|
||||
@Autowired
|
||||
LuceneExecuteLogService luceneExecuteLogService;
|
||||
@Autowired
|
||||
ISysDictService dictService;
|
||||
|
||||
|
||||
public TwoNDCSocketConnectionAutoRun() {
|
||||
this.recordTime = new Date((new Date()).getTime() - (long) this.recordTimeOut);
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return TwoNDCSocketConnectionAutoRun.class.getSimpleName();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "NDC2在线连接";
|
||||
}
|
||||
|
||||
//todo NDC相关逻辑
|
||||
public void autoRun() throws IOException {
|
||||
System.out.println("TwoNDCAgv链接开始");
|
||||
ISysParamService ISysParamService = SpringContextHolder.getBean(SysParamServiceImpl.class);
|
||||
InstructionService instructionService = SpringContextHolder.getBean(InstructionServiceImpl.class);
|
||||
AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class);
|
||||
NDCAgvService NDCAgvService = SpringContextHolder.getBean(NDCAgvService.class);
|
||||
DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppService.class);
|
||||
DeviceService deviceService = SpringContextHolder.getBean(DeviceService.class);
|
||||
DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class);
|
||||
ip = paramService.findByCode(AcsConfig.AGVURL).getValue();
|
||||
port = Integer.parseInt(paramService.findByCode(AcsConfig.AGVPORT2).getValue());
|
||||
|
||||
|
||||
try {
|
||||
byte[] b = new byte[1024];
|
||||
s = new Socket(ip, port);
|
||||
dos = new DataOutputStream(s.getOutputStream());
|
||||
dis = new DataInputStream(s.getInputStream());
|
||||
System.out.println("TwoNDCAgv链接成功");
|
||||
log.info("TwoNDC2Agv链接成功");
|
||||
while (bConnected) {
|
||||
int count = dis.read(b);
|
||||
|
||||
if (count == -1) {
|
||||
break;
|
||||
}
|
||||
|
||||
int[] packetData = new int[count];
|
||||
StringBuffer bs = new StringBuffer();
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
int temp = b[i];
|
||||
if (temp < 0)
|
||||
temp += 256;
|
||||
packetData[i] = temp;
|
||||
StringBuffer bs1 = new StringBuffer("0");
|
||||
bs.append(temp < 16 ? bs1.append(Integer.toHexString(temp)) : Integer.toHexString(temp));
|
||||
}
|
||||
log.info("接收agv上报状态信息:" + bs);
|
||||
// 从字节流的开头开始读取
|
||||
int offset = 0;
|
||||
// 循环处理字节流,逐个拆包 按照S消息解析
|
||||
while (offset < packetData.length) {
|
||||
if (offset + 6 > packetData.length) {
|
||||
System.out.println("错误:没有足够的字节来读取长度字段。");
|
||||
break;
|
||||
}
|
||||
int messageHeader = packetData[offset] * 256 + packetData[offset+1];
|
||||
//检测消息头是否有效
|
||||
if (messageHeader == 0x87CD){
|
||||
//消息头长度
|
||||
int messageHeaderLength = packetData[offset+2] * 256 + packetData[offset+3];
|
||||
//消息数据长度
|
||||
int messageDataLength = packetData[offset+4] * 256 + packetData[offset+5];
|
||||
//消息总长度
|
||||
int messageLength = messageHeaderLength + messageDataLength;
|
||||
// 检查剩余字节是否足够处理完整的数据包
|
||||
if (offset + messageLength > packetData.length) {
|
||||
// System.out.println("错误:检测到不完整的数据包。");
|
||||
log.info("错误:检测到不完整的数据包");
|
||||
// 数据包不完整,停止处理
|
||||
break;
|
||||
}
|
||||
int[] arr = Arrays.copyOfRange(packetData, offset, offset+messageLength);
|
||||
boolean flag = false;
|
||||
if (arr[8] * 256 + arr[9] == 0x73) {
|
||||
byte[] data = null;
|
||||
System.out.println("接收agv上报信息:" + bs);
|
||||
//执行阶段
|
||||
int phase = arr[16] * 256 + arr[17];
|
||||
// agv任务号
|
||||
int index = arr[12] * 256 + arr[13];
|
||||
//任务号
|
||||
int ikey = arr[26] * 256 + arr[27];
|
||||
//站点号
|
||||
int agvaddr = arr[18] * 256 + arr[19];
|
||||
//车号
|
||||
int carno = arr[20];
|
||||
//充电桩站点号
|
||||
int station = arr[25];
|
||||
Instruction link_inst = null;
|
||||
Instruction inst = null;
|
||||
List<Instruction> insts = null;
|
||||
boolean link_flag = false;
|
||||
Device agv_device = null;
|
||||
if (carno != 0) {
|
||||
agv_device = deviceAppService.findDeviceByCode(String.valueOf(carno));
|
||||
}
|
||||
if (ikey != 0) {
|
||||
inst = instructionService.findByCodeFromCache(String.valueOf(ikey));
|
||||
if (ObjectUtil.isEmpty(inst)) {
|
||||
inst = instructionService.findByCode(String.valueOf(ikey));
|
||||
}
|
||||
}
|
||||
if (!ObjectUtil.isEmpty(link_inst)) {
|
||||
link_flag = true;
|
||||
}
|
||||
log.info("接收agv上报信息:" + "phase--" + phase + " index--" + index + " ikey--" + ikey + " agvaddr--" + agvaddr + " Car--" + carno);
|
||||
Device device = null;
|
||||
String device_code = null;
|
||||
|
||||
|
||||
//
|
||||
AgvNdcOneDeviceDriver agvNdcOneDeviceDriver;
|
||||
|
||||
//开始任务/上报订单号
|
||||
if (phase == 0x01) {
|
||||
if (!ObjectUtil.isEmpty(inst)) {
|
||||
inst.setInstruction_status("1");
|
||||
inst.setAgv_jobno(String.valueOf(index));
|
||||
inst.setSend_status("1");
|
||||
instructionService.update(inst);
|
||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
//任务完毕
|
||||
//(无车id及状态)
|
||||
else if (phase == 0x0A) {
|
||||
if (!ObjectUtil.isEmpty(inst)) {
|
||||
instructionService.finish(inst.getInstruction_id());
|
||||
} else {
|
||||
log.warn("指令号:{},未反馈wms任务完成,因为agv上报指令号查询指令为空!");
|
||||
}
|
||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0);
|
||||
log.info("指令号:{},已反馈agv任务完成!");
|
||||
}
|
||||
//todo 检查协议里删除任务流程有很多个步骤,在哪体现的
|
||||
//(需要WCS反馈)
|
||||
else if (phase == 0x30) {
|
||||
data = NDCAgvService.sendAgvOneModeInst(0x8F, index, 0, 0, 0, 0, 0);
|
||||
}
|
||||
//任务删除确认
|
||||
//(需要WCS反馈)
|
||||
else if (phase == 0xFF) {
|
||||
|
||||
if (!ObjectUtil.isEmpty(inst)) {
|
||||
if (!ObjectUtil.isEmpty(inst)) {
|
||||
instructionService.cancelNOSendAgv(inst.getInstruction_id());
|
||||
}
|
||||
}
|
||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0);
|
||||
} else {
|
||||
//上报异常信息
|
||||
//(不需要WCS反馈)
|
||||
if (phase == 0x70 || phase == 0x71 || phase == 0x72 || phase == 0x73 || phase == 0x74 || phase == 0x75 || phase == 0x76 || phase == 0x77) {
|
||||
device = deviceAppService.findDeviceByCode(String.valueOf(agvaddr));
|
||||
} else {
|
||||
//todo NDC根据车辆编号123456进行查找特定车辆
|
||||
device = deviceAppService.findDeviceByCode(Integer.toString(arr[20]));
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(device)) {
|
||||
if (device.getDeviceDriver() instanceof AgvNdcOneDeviceDriver) {
|
||||
agvNdcOneDeviceDriver = (AgvNdcOneDeviceDriver) device.getDeviceDriver();
|
||||
try {
|
||||
// agvNdcOneDeviceDriver.processSocket2(arr);
|
||||
}catch (Exception e){
|
||||
log.error("处理phase:{},发生异常。异常信息:{}",phase,e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (!ObjectUtil.isEmpty(data)) {
|
||||
write(data);
|
||||
}
|
||||
// 更新偏移量,继续处理下一个数据包
|
||||
offset+=messageLength;
|
||||
} else {
|
||||
log.info("agv上报不是0073类型动作,不处理");
|
||||
// 更新偏移量,继续处理下一个数据包
|
||||
offset+=messageHeaderLength;
|
||||
// ArrayUtils.indexOf()
|
||||
int index = IntStream.range(offset, packetData.length-1)
|
||||
.filter(i -> packetData[i] == 135 && packetData[i + 1] == 205)
|
||||
.findFirst()
|
||||
.orElse(-1);
|
||||
// 如果未找到,返回 -1
|
||||
if (index == -1) {
|
||||
break;
|
||||
}else {
|
||||
offset = index;
|
||||
}
|
||||
}
|
||||
}else {
|
||||
log.info("消息头无效,不处理。");
|
||||
int index = IntStream.range(offset, packetData.length-1)
|
||||
.filter(i -> packetData[i] == 135 && packetData[i + 1] == 205)
|
||||
.findFirst()
|
||||
.orElse(-1);
|
||||
if (index == -1) {
|
||||
break;
|
||||
}else {
|
||||
offset = index;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
System.out.println("Agv链接异常");
|
||||
log.info("Agv链接异常");
|
||||
log.error("agv连接出现异常:{}", e);
|
||||
if (ObjectUtil.isNotEmpty(s)) {
|
||||
s.close();
|
||||
}
|
||||
System.out.println(e.getMessage());
|
||||
e.printStackTrace();
|
||||
|
||||
} finally {
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
super.after();
|
||||
try {
|
||||
s.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void write(byte[] b) {
|
||||
try {
|
||||
log.info("下发agv数据:" + Bytes2HexString(b));
|
||||
System.out.println("下发agv数据:" + Bytes2HexString(b));
|
||||
dos.write(b);
|
||||
dos.flush();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
try {
|
||||
Thread.sleep(5000L);
|
||||
log.error("tofix下发agv数据失败,再次下发,再次下发agv数据:" + Bytes2HexString(b) + "失败原因:" + e.getMessage());
|
||||
System.out.println("再次下发agv数据:" + Bytes2HexString(b));
|
||||
dos.write(b);
|
||||
dos.flush();
|
||||
} catch (Exception e1) {
|
||||
log.error("tofix下发agv数据失败,再次下发,下发agv数据:" + Bytes2HexString(b) + "失败原因:" + e1.getMessage());
|
||||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//package org.nl.acs.auto.run;
|
||||
//import cn.hutool.core.util.ObjectUtil;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.apache.commons.lang3.ArrayUtils;
|
||||
//import org.nl.acs.AcsConfig;
|
||||
//import org.nl.acs.agv.server.NDCAgvService;
|
||||
//import org.nl.acs.device.domain.Device;
|
||||
//import org.nl.acs.device.service.DeviceService;
|
||||
//import org.nl.acs.device_driver.basedriver.agv.ndcone.AgvNdcOneDeviceDriver;
|
||||
//import org.nl.acs.ext.wms.service.AcsToWmsService;
|
||||
//import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl;
|
||||
//import org.nl.acs.instruction.domain.Instruction;
|
||||
//import org.nl.acs.instruction.service.InstructionService;
|
||||
//import org.nl.acs.instruction.service.impl.InstructionServiceImpl;
|
||||
//import org.nl.acs.log.service.DeviceExecuteLogService;
|
||||
//import org.nl.acs.opc.DeviceAppService;
|
||||
//import org.nl.config.SpringContextHolder;
|
||||
//import org.nl.system.service.dict.ISysDictService;
|
||||
//import org.nl.system.service.lucene.LuceneExecuteLogService;
|
||||
//import org.nl.system.service.param.ISysParamService;
|
||||
//import org.nl.system.service.param.impl.SysParamServiceImpl;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.context.annotation.Lazy;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
//import java.io.DataInputStream;
|
||||
//import java.io.DataOutputStream;
|
||||
//import java.io.IOException;
|
||||
//import java.net.Socket;
|
||||
//import java.util.Arrays;
|
||||
//import java.util.Date;
|
||||
//import java.util.List;
|
||||
//import java.util.stream.IntStream;
|
||||
//
|
||||
//import static org.nl.acs.agv.server.impl.NDCAgvServiceImpl.Bytes2HexString;
|
||||
//
|
||||
//
|
||||
//@Slf4j
|
||||
//@Component
|
||||
//@Lazy
|
||||
//public class TwoNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
||||
//
|
||||
// Socket s;
|
||||
// String ip = "192.168.10.34";
|
||||
// int port = 1234;
|
||||
// static DataOutputStream dos;
|
||||
// static DataInputStream dis;
|
||||
// private int recordTimeOut = 10000;
|
||||
// private Date recordTime;
|
||||
// String[] ERROR = new String[]{
|
||||
// "货叉尖部传感器触发", "S300传感器触发", "载货状态改变", "急停按钮触发", "触边开关出发", "需要复位",
|
||||
// "停在充电位", "取货失败", "放货失败", "轮子打滑", "没有动作码不能进入站点", "取货时有货", "丢失定位",
|
||||
// "抬叉停止"};
|
||||
// boolean bConnected = true;
|
||||
//
|
||||
// boolean isReConnect = false;
|
||||
//
|
||||
// @Autowired
|
||||
// ISysParamService paramService;
|
||||
// @Autowired
|
||||
// AutoRunService autoRunService;
|
||||
// @Autowired
|
||||
// LuceneExecuteLogService luceneExecuteLogService;
|
||||
// @Autowired
|
||||
// ISysDictService dictService;
|
||||
//
|
||||
//
|
||||
// public TwoNDCSocketConnectionAutoRun() {
|
||||
// this.recordTime = new Date((new Date()).getTime() - (long) this.recordTimeOut);
|
||||
// }
|
||||
//
|
||||
// public String getCode() {
|
||||
// return TwoNDCSocketConnectionAutoRun.class.getSimpleName();
|
||||
// }
|
||||
//
|
||||
// public String getName() {
|
||||
// return "NDC2在线连接";
|
||||
// }
|
||||
//
|
||||
// //todo NDC相关逻辑
|
||||
// public void autoRun() throws IOException {
|
||||
// System.out.println("TwoNDCAgv链接开始");
|
||||
// ISysParamService ISysParamService = SpringContextHolder.getBean(SysParamServiceImpl.class);
|
||||
// InstructionService instructionService = SpringContextHolder.getBean(InstructionServiceImpl.class);
|
||||
// AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class);
|
||||
// NDCAgvService NDCAgvService = SpringContextHolder.getBean(NDCAgvService.class);
|
||||
// DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppService.class);
|
||||
// DeviceService deviceService = SpringContextHolder.getBean(DeviceService.class);
|
||||
// DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class);
|
||||
// ip = paramService.findByCode(AcsConfig.AGVURL).getValue();
|
||||
// port = Integer.parseInt(paramService.findByCode(AcsConfig.AGVPORT2).getValue());
|
||||
//
|
||||
//
|
||||
// try {
|
||||
// byte[] b = new byte[1024];
|
||||
// s = new Socket(ip, port);
|
||||
// dos = new DataOutputStream(s.getOutputStream());
|
||||
// dis = new DataInputStream(s.getInputStream());
|
||||
// System.out.println("TwoNDCAgv链接成功");
|
||||
// log.info("TwoNDC2Agv链接成功");
|
||||
// while (bConnected) {
|
||||
// int count = dis.read(b);
|
||||
//
|
||||
// if (count == -1) {
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// int[] packetData = new int[count];
|
||||
// StringBuffer bs = new StringBuffer();
|
||||
//
|
||||
// for (int i = 0; i < count; i++) {
|
||||
// int temp = b[i];
|
||||
// if (temp < 0)
|
||||
// temp += 256;
|
||||
// packetData[i] = temp;
|
||||
// StringBuffer bs1 = new StringBuffer("0");
|
||||
// bs.append(temp < 16 ? bs1.append(Integer.toHexString(temp)) : Integer.toHexString(temp));
|
||||
// }
|
||||
// log.info("接收agv上报状态信息:" + bs);
|
||||
// // 从字节流的开头开始读取
|
||||
// int offset = 0;
|
||||
// // 循环处理字节流,逐个拆包 按照S消息解析
|
||||
// while (offset < packetData.length) {
|
||||
// if (offset + 6 > packetData.length) {
|
||||
// System.out.println("错误:没有足够的字节来读取长度字段。");
|
||||
// break;
|
||||
// }
|
||||
// int messageHeader = packetData[offset] * 256 + packetData[offset+1];
|
||||
// //检测消息头是否有效
|
||||
// if (messageHeader == 0x87CD){
|
||||
// //消息头长度
|
||||
// int messageHeaderLength = packetData[offset+2] * 256 + packetData[offset+3];
|
||||
// //消息数据长度
|
||||
// int messageDataLength = packetData[offset+4] * 256 + packetData[offset+5];
|
||||
// //消息总长度
|
||||
// int messageLength = messageHeaderLength + messageDataLength;
|
||||
// // 检查剩余字节是否足够处理完整的数据包
|
||||
// if (offset + messageLength > packetData.length) {
|
||||
//// System.out.println("错误:检测到不完整的数据包。");
|
||||
// log.info("错误:检测到不完整的数据包");
|
||||
// // 数据包不完整,停止处理
|
||||
// break;
|
||||
// }
|
||||
// int[] arr = Arrays.copyOfRange(packetData, offset, offset+messageLength);
|
||||
// boolean flag = false;
|
||||
// if (arr[8] * 256 + arr[9] == 0x73) {
|
||||
// byte[] data = null;
|
||||
// System.out.println("接收agv上报信息:" + bs);
|
||||
// //执行阶段
|
||||
// int phase = arr[16] * 256 + arr[17];
|
||||
// // agv任务号
|
||||
// int index = arr[12] * 256 + arr[13];
|
||||
// //任务号
|
||||
// int ikey = arr[26] * 256 + arr[27];
|
||||
// //站点号
|
||||
// int agvaddr = arr[18] * 256 + arr[19];
|
||||
// //车号
|
||||
// int carno = arr[20];
|
||||
// //充电桩站点号
|
||||
// int station = arr[25];
|
||||
// Instruction link_inst = null;
|
||||
// Instruction inst = null;
|
||||
// List<Instruction> insts = null;
|
||||
// boolean link_flag = false;
|
||||
// Device agv_device = null;
|
||||
// if (carno != 0) {
|
||||
// agv_device = deviceAppService.findDeviceByCode(String.valueOf(carno));
|
||||
// }
|
||||
// if (ikey != 0) {
|
||||
// inst = instructionService.findByCodeFromCache(String.valueOf(ikey));
|
||||
// if (ObjectUtil.isEmpty(inst)) {
|
||||
// inst = instructionService.findByCode(String.valueOf(ikey));
|
||||
// }
|
||||
// }
|
||||
// if (!ObjectUtil.isEmpty(link_inst)) {
|
||||
// link_flag = true;
|
||||
// }
|
||||
// log.info("接收agv上报信息:" + "phase--" + phase + " index--" + index + " ikey--" + ikey + " agvaddr--" + agvaddr + " Car--" + carno);
|
||||
// Device device = null;
|
||||
// String device_code = null;
|
||||
//
|
||||
//
|
||||
// //
|
||||
// AgvNdcOneDeviceDriver agvNdcOneDeviceDriver;
|
||||
//
|
||||
// //开始任务/上报订单号
|
||||
// if (phase == 0x01) {
|
||||
// if (!ObjectUtil.isEmpty(inst)) {
|
||||
// inst.setInstruction_status("1");
|
||||
// inst.setAgv_jobno(String.valueOf(index));
|
||||
// inst.setSend_status("1");
|
||||
// instructionService.update(inst);
|
||||
// data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0);
|
||||
// }
|
||||
// }
|
||||
// //任务完毕
|
||||
// //(无车id及状态)
|
||||
// else if (phase == 0x0A) {
|
||||
// if (!ObjectUtil.isEmpty(inst)) {
|
||||
// instructionService.finish(inst.getInstruction_id());
|
||||
// } else {
|
||||
// log.warn("指令号:{},未反馈wms任务完成,因为agv上报指令号查询指令为空!");
|
||||
// }
|
||||
// data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0);
|
||||
// log.info("指令号:{},已反馈agv任务完成!");
|
||||
// }
|
||||
// //todo 检查协议里删除任务流程有很多个步骤,在哪体现的
|
||||
// //(需要WCS反馈)
|
||||
// else if (phase == 0x30) {
|
||||
// data = NDCAgvService.sendAgvOneModeInst(0x8F, index, 0, 0, 0, 0, 0);
|
||||
// }
|
||||
// //任务删除确认
|
||||
// //(需要WCS反馈)
|
||||
// else if (phase == 0xFF) {
|
||||
//
|
||||
// if (!ObjectUtil.isEmpty(inst)) {
|
||||
// if (!ObjectUtil.isEmpty(inst)) {
|
||||
// instructionService.cancelNOSendAgv(inst.getInstruction_id());
|
||||
// }
|
||||
// }
|
||||
// data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0);
|
||||
// } else {
|
||||
// //上报异常信息
|
||||
// //(不需要WCS反馈)
|
||||
// if (phase == 0x70 || phase == 0x71 || phase == 0x72 || phase == 0x73 || phase == 0x74 || phase == 0x75 || phase == 0x76 || phase == 0x77) {
|
||||
// device = deviceAppService.findDeviceByCode(String.valueOf(agvaddr));
|
||||
// } else {
|
||||
// //todo NDC根据车辆编号123456进行查找特定车辆
|
||||
// device = deviceAppService.findDeviceByCode(Integer.toString(arr[20]));
|
||||
// }
|
||||
// if (ObjectUtil.isNotEmpty(device)) {
|
||||
// if (device.getDeviceDriver() instanceof AgvNdcOneDeviceDriver) {
|
||||
// agvNdcOneDeviceDriver = (AgvNdcOneDeviceDriver) device.getDeviceDriver();
|
||||
// try {
|
||||
//// agvNdcOneDeviceDriver.processSocket2(arr);
|
||||
// }catch (Exception e){
|
||||
// log.error("处理phase:{},发生异常。异常信息:{}",phase,e.getMessage());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// if (!ObjectUtil.isEmpty(data)) {
|
||||
// write(data);
|
||||
// }
|
||||
// // 更新偏移量,继续处理下一个数据包
|
||||
// offset+=messageLength;
|
||||
// } else {
|
||||
// log.info("agv上报不是0073类型动作,不处理");
|
||||
// // 更新偏移量,继续处理下一个数据包
|
||||
// offset+=messageHeaderLength;
|
||||
//// ArrayUtils.indexOf()
|
||||
// int index = IntStream.range(offset, packetData.length-1)
|
||||
// .filter(i -> packetData[i] == 135 && packetData[i + 1] == 205)
|
||||
// .findFirst()
|
||||
// .orElse(-1);
|
||||
// // 如果未找到,返回 -1
|
||||
// if (index == -1) {
|
||||
// break;
|
||||
// }else {
|
||||
// offset = index;
|
||||
// }
|
||||
// }
|
||||
// }else {
|
||||
// log.info("消息头无效,不处理。");
|
||||
// int index = IntStream.range(offset, packetData.length-1)
|
||||
// .filter(i -> packetData[i] == 135 && packetData[i + 1] == 205)
|
||||
// .findFirst()
|
||||
// .orElse(-1);
|
||||
// if (index == -1) {
|
||||
// break;
|
||||
// }else {
|
||||
// offset = index;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// } catch (Exception e) {
|
||||
// System.out.println("Agv链接异常");
|
||||
// log.info("Agv链接异常");
|
||||
// log.error("agv连接出现异常:{}", e);
|
||||
// if (ObjectUtil.isNotEmpty(s)) {
|
||||
// s.close();
|
||||
// }
|
||||
// System.out.println(e.getMessage());
|
||||
// e.printStackTrace();
|
||||
//
|
||||
// } finally {
|
||||
//
|
||||
//
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Override
|
||||
// public void stop() {
|
||||
// super.after();
|
||||
// try {
|
||||
// s.close();
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// public static void write(byte[] b) {
|
||||
// try {
|
||||
// log.info("下发agv数据:" + Bytes2HexString(b));
|
||||
// System.out.println("下发agv数据:" + Bytes2HexString(b));
|
||||
// dos.write(b);
|
||||
// dos.flush();
|
||||
// } catch (IOException e) {
|
||||
// // TODO Auto-generated catch block
|
||||
// try {
|
||||
// Thread.sleep(5000L);
|
||||
// log.error("tofix下发agv数据失败,再次下发,再次下发agv数据:" + Bytes2HexString(b) + "失败原因:" + e.getMessage());
|
||||
// System.out.println("再次下发agv数据:" + Bytes2HexString(b));
|
||||
// dos.write(b);
|
||||
// dos.flush();
|
||||
// } catch (Exception e1) {
|
||||
// log.error("tofix下发agv数据失败,再次下发,下发agv数据:" + Bytes2HexString(b) + "失败原因:" + e1.getMessage());
|
||||
// e1.printStackTrace();
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//
|
||||
|
||||
@@ -19,6 +19,7 @@ public enum ResponseWMSTaskStatusEnum {
|
||||
*/
|
||||
BUSY("1", 20, "任务执行中"),
|
||||
CANCEL("3", 30, "取消任务"),
|
||||
WAITING_FOR_EXECUTION("4", 10, "等待执行中"),
|
||||
PICKUP_COMPLETED("5", 50, "取货完成"),
|
||||
FINISHED("2", 100, "完成");
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import org.nl.acs.log.service.DeviceExecuteLogService;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
import org.nl.system.service.param.ISysParamService;
|
||||
import org.nl.system.service.param.impl.SysParamServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
||||
/**
|
||||
* ACS连接外部系统工具类:
|
||||
@@ -17,6 +18,8 @@ import org.nl.system.service.param.impl.SysParamServiceImpl;
|
||||
@Slf4j
|
||||
public class LmsUtil {
|
||||
|
||||
private final static String wmsToken = "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiJXQ1MiLCJpc3MiOiJ3bXMtY29yZSIsImV4cCI6NDA4MzIxMTcyMiwiaWF0IjoxNzE2NTMyNDAxLCJvcGVyYXRvciI6ImFkbWluIiwianRpIjoiMGFiZDI0NDItZjAxOS00MWUyLWIzMGYtNTA1NjQ4OGFkYzE1In0.iKmQM78JArRyPLJmZiHQb-pMWFbCE-fDcbppEDYNCj8TSMSQNNXeYA1SOD8QNUp4SpGME4qrPmJ-jpq_iNbgNLRbTciaymliNyWEAhf2Ozu91EPWUlhVvtEOlWPOAbhm8CH-75Ctz93nNwJ7jyzl796mfbUbz_uFFLAhn677NVs";
|
||||
|
||||
public static <W> String notifyAcs(String api, W requestParam) {
|
||||
DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class);;
|
||||
ISysParamService paramService = SpringContextHolder.getBean(SysParamServiceImpl.class);
|
||||
@@ -35,6 +38,7 @@ public class LmsUtil {
|
||||
//log.info("请求LMS参数:{}", JSON.toJSONString(requestParam));
|
||||
String body = HttpRequest
|
||||
.post(wmsUrl + api).setConnectionTimeout(3000)
|
||||
.header("token", wmsToken)
|
||||
.body(JSON.toJSONString(requestParam))
|
||||
.execute()
|
||||
.body();
|
||||
|
||||
@@ -44,6 +44,11 @@ public class CreateTaskRequest extends BaseRequest {
|
||||
*/
|
||||
String vehicle_type;
|
||||
|
||||
/**
|
||||
* 运输载体 0托盘 1仓储笼
|
||||
*/
|
||||
String carrier;
|
||||
|
||||
|
||||
/**
|
||||
* 任务类型
|
||||
|
||||
@@ -433,6 +433,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
||||
CreateTaskRequest req = reqs.get(i);
|
||||
String task_code = req.getTask_code();
|
||||
String task_id = req.getTask_id();
|
||||
String carrier = req.getCarrier();
|
||||
String start_device_code = req.getStart_device_code();
|
||||
String next_device_code = req.getNext_device_code();
|
||||
String priority = req.getPriority();
|
||||
@@ -473,6 +474,16 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
||||
errArr.add(json);
|
||||
continue;
|
||||
}
|
||||
if (StrUtil.isEmpty(carrier)) {
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("task_code", task_code);
|
||||
json.put("message", "载货类型不能为空");
|
||||
errArr.add(json);
|
||||
continue;
|
||||
}
|
||||
start_device_code = start_device_code + carrier;
|
||||
next_device_code = next_device_code + carrier;
|
||||
|
||||
//JSONObject start_device_json = WQLObject.getWQLObject("acs_storage_cell").query("parent_storage_code ='" + start_device_code + "'").uniqueResult(0);
|
||||
StorageCell storageCell_start = new LambdaQueryChainWrapper<>(storageCellMapper)
|
||||
.eq(StorageCell::getParent_storage_code, start_device_code)
|
||||
|
||||
@@ -429,11 +429,13 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
||||
// }
|
||||
// if (StrUtil.equals(shortPathsList.get(0).getType(), "1")) {
|
||||
NDCAgvService ndcAgvService = SpringContextHolder.getBean(NDCAgvService.class);
|
||||
try {
|
||||
ndcAgvService.sendAgvInstToNDC(task.getAgv_system_type(), dto);
|
||||
} catch (Exception e) {
|
||||
log.error("tofix下发agv数据失败,失败原因:" + e.getMessage());
|
||||
}
|
||||
// try {
|
||||
ndcAgvService.sendAgvInstToNDC(task.getAgv_system_type(), dto);
|
||||
// } catch (Exception e) {
|
||||
// dto.setSend_status("2");
|
||||
// dto.setRemark("失败原因:" + e.getMessage());
|
||||
// log.error("tofix下发agv数据失败,失败原因:" + e.getMessage());
|
||||
// }
|
||||
// } else if (StrUtil.equals(shortPathsList.get(0).getType(), "2")) {
|
||||
// ZheDaAgvService zheDaAgvService = SpringContextHolder.getBean(ZheDaAgvService.class);
|
||||
// HttpResponse result = zheDaAgvService.sendAgvInstToAgv(dto);
|
||||
|
||||
@@ -875,7 +875,8 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
|
||||
FeedBackTaskStatusRequest_WeiBang request_weiBang = new FeedBackTaskStatusRequest_WeiBang();
|
||||
Instruction instruction = instructionService.findByTaskcode(entity.getTask_code());
|
||||
if (ObjectUtil.isNotEmpty(instruction)){
|
||||
request_weiBang.setCarNo(Integer.valueOf(instruction.getCarno()));
|
||||
int carNo = ObjectUtil.isEmpty(instruction.getCarno()) ? 0 : Integer.parseInt(instruction.getCarno());
|
||||
request_weiBang.setCarNo(carNo);
|
||||
}
|
||||
request_weiBang.setTaskNo(entity.getTask_code());
|
||||
request_weiBang.setStatus(ResponseWMSTaskStatusEnum.getCode(dto.getTask_status()));
|
||||
@@ -997,7 +998,8 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
|
||||
FeedBackTaskStatusRequest_WeiBang request_weiBang = new FeedBackTaskStatusRequest_WeiBang();
|
||||
Instruction instruction = instructionService.findByTaskcode(entity.getTask_code());
|
||||
if (ObjectUtil.isNotEmpty(instruction)){
|
||||
request_weiBang.setCarNo(Integer.valueOf(instruction.getCarno()));
|
||||
int carNo = ObjectUtil.isEmpty(instruction.getCarno()) ? 0 : Integer.parseInt(instruction.getCarno());
|
||||
request_weiBang.setCarNo(carNo);
|
||||
}
|
||||
request_weiBang.setTaskNo(entity.getTask_code());
|
||||
request_weiBang.setStatus(ResponseWMSTaskStatusEnum.getCode(entity.getTask_status()));
|
||||
@@ -1031,7 +1033,8 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
|
||||
FeedBackTaskStatusRequest_WeiBang request_weiBang = new FeedBackTaskStatusRequest_WeiBang();
|
||||
Instruction instruction = instructionService.findByTaskcode(entity.getTask_code());
|
||||
if (ObjectUtil.isNotEmpty(instruction)){
|
||||
request_weiBang.setCarNo(Integer.valueOf(instruction.getCarno()));
|
||||
int carNo = ObjectUtil.isEmpty(instruction.getCarno()) ? 0 : Integer.parseInt(instruction.getCarno());
|
||||
request_weiBang.setCarNo(carNo);
|
||||
}
|
||||
request_weiBang.setTaskNo(entity.getTask_code());
|
||||
request_weiBang.setStatus(ResponseWMSTaskStatusEnum.getCode(entity.getTask_status()));
|
||||
@@ -1077,7 +1080,8 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
|
||||
FeedBackTaskStatusRequest_WeiBang request_weiBang = new FeedBackTaskStatusRequest_WeiBang();
|
||||
Instruction instruction = instructionService.findByTaskcode(entity.getTask_code());
|
||||
if (ObjectUtil.isNotEmpty(instruction)){
|
||||
request_weiBang.setCarNo(Integer.valueOf(instruction.getCarno()));
|
||||
int carNo = ObjectUtil.isEmpty(instruction.getCarno()) ? 0 : Integer.parseInt(instruction.getCarno());
|
||||
request_weiBang.setCarNo(carNo);
|
||||
}
|
||||
request_weiBang.setTaskNo(entity.getTask_code());
|
||||
request_weiBang.setStatus(ResponseWMSTaskStatusEnum.getCode(entity.getTask_status()));
|
||||
|
||||
@@ -26,4 +26,9 @@ public class HeadDto implements Serializable {
|
||||
*/
|
||||
private String task_type;
|
||||
|
||||
/**
|
||||
* 任务类型
|
||||
*/
|
||||
private String vehicle_type;
|
||||
|
||||
}
|
||||
|
||||
@@ -97,4 +97,13 @@ public class HandController {
|
||||
return new ResponseEntity<>(handService.taskOperation(dto), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/queryVehicleType")
|
||||
@Log("查询载具类型")
|
||||
@ApiOperation("查询载具类型")
|
||||
@SaIgnore
|
||||
//@PreAuthorize("@el.check('sect:list')")
|
||||
public ResponseEntity<Object> queryVehicleType(@RequestBody HeadDto dto) {
|
||||
return new ResponseEntity<>(handService.queryVehicleType(), HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -34,4 +34,5 @@ public interface HandService {
|
||||
|
||||
Map<String, Object> taskOperation(HeadTaskDto dto);
|
||||
|
||||
Map<String, Object> queryVehicleType();
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -98,6 +99,7 @@ public class HandServiceImpl implements HandService {
|
||||
@Override
|
||||
public Map<String, Object> callTask(HeadDto dto) {
|
||||
JSONArray errArr = new JSONArray();
|
||||
String vehicle_type = dto.getVehicle_type();
|
||||
String start_device_code = dto.getStart_device_code();
|
||||
String next_device_code = dto.getNext_device_code();
|
||||
String task_type = dto.getTask_type();
|
||||
@@ -111,7 +113,11 @@ public class HandServiceImpl implements HandService {
|
||||
if (StrUtil.isEmpty(task_type)) {
|
||||
throw new BadRequestException("任务类型不能为空");
|
||||
}
|
||||
|
||||
if (StrUtil.isEmpty(vehicle_type)) {
|
||||
throw new BadRequestException("托盘类型不能为空");
|
||||
}
|
||||
start_device_code = start_device_code + vehicle_type;
|
||||
next_device_code = next_device_code + vehicle_type;
|
||||
String start_device_code2 = "";
|
||||
String next_device_code2 = "";
|
||||
JSONObject jo = new JSONObject();
|
||||
@@ -460,4 +466,30 @@ public class HandServiceImpl implements HandService {
|
||||
resultJson.put("data", data);
|
||||
return resultJson;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> queryVehicleType() {
|
||||
JSONArray data = new JSONArray();
|
||||
List<Dict> list = dictService.lambdaQuery()
|
||||
.eq(Dict::getCode, "vehicle_type")
|
||||
.list();
|
||||
if (CollectionUtil.isEmpty(list)) {
|
||||
throw new BadRequestException("未查到托盘类型!");
|
||||
}
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
JSONObject jo = new JSONObject();
|
||||
Dict dict = list.get(i);
|
||||
String vehicle_type_id = dict.getDict_id();
|
||||
String vehicle_type_code = dict.getValue();
|
||||
String vehicle_type_name = dict.getLabel();
|
||||
jo.put("vehicle_type_id", vehicle_type_id);
|
||||
jo.put("value", vehicle_type_code);
|
||||
jo.put("text", vehicle_type_name);
|
||||
data.add(jo);
|
||||
}
|
||||
JSONObject resultJson = new JSONObject();
|
||||
resultJson.put("message", "操作成功");
|
||||
resultJson.put("data", data);
|
||||
return resultJson;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,13 +12,13 @@ import org.springframework.stereotype.Component;
|
||||
@Component
|
||||
public class AutoCreateChargingTaskToNDC {
|
||||
|
||||
@Autowired
|
||||
NDCAgvService ndcAgvService;
|
||||
|
||||
public void run(String threadCode) throws Exception {
|
||||
String[] threadCodes = threadCode.split(",");
|
||||
for (String code : threadCodes) {
|
||||
ndcAgvService.createChargingTaskToNDC(code);
|
||||
}
|
||||
}
|
||||
// @Autowired
|
||||
// NDCAgvService ndcAgvService;
|
||||
//
|
||||
// public void run(String threadCode) throws Exception {
|
||||
// String[] threadCodes = threadCode.split(",");
|
||||
// for (String code : threadCodes) {
|
||||
// ndcAgvService.createChargingTaskToNDC(code);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ spring:
|
||||
db-type: com.alibaba.druid.pool.DruidDataSource
|
||||
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
|
||||
# url: jdbc:log4jdbc:mysql://${DB_HOST:192.168.81.252}:${DB_PORT:3306}/${DB_NAME:stand_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
|
||||
url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:qzyf}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
|
||||
url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:weibang_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true
|
||||
username: ${DB_USER:root}
|
||||
# password: ${DB_PWD:Root.123456}
|
||||
password: ${DB_PWD:123456}
|
||||
@@ -73,7 +73,7 @@ spring:
|
||||
#数据库索引
|
||||
database: ${REDIS_DB:5}
|
||||
# host: ${REDIS_HOST:10.44.101.19}
|
||||
host: ${REDIS_HOST:192.168.11.250}
|
||||
host: ${REDIS_HOST:127.0.0.1}
|
||||
port: ${REDIS_PORT:6379}
|
||||
# password: ${REDIS_PWD:}
|
||||
|
||||
@@ -172,7 +172,7 @@ sa-token:
|
||||
# Redis数据库索引(默认为0)
|
||||
database: 5
|
||||
# Redis服务器地址
|
||||
host: 192.168.11.250
|
||||
host: 127.0.0.1
|
||||
# Redis服务器连接端口
|
||||
port: 6379
|
||||
# Redis服务器连接密码(默认为空)
|
||||
|
||||
Reference in New Issue
Block a user