opt: 部分优化
This commit is contained in:
@@ -7,7 +7,6 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.AcsConfig;
|
||||
import org.nl.acs.agv.server.NDCAgvService;
|
||||
import org.nl.acs.agv.server.dto.AgvDto;
|
||||
import org.nl.acs.auto.run.OneNDCSocketConnectionAutoRun;
|
||||
import org.nl.acs.auto.run.TwoNDCSocketConnectionAutoRun;
|
||||
import org.nl.acs.common.base.CommonFinalParam;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
@@ -78,6 +77,11 @@ public class NDCAgvServiceImpl implements NDCAgvService {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 组装指令下发到NDC
|
||||
* @param agv_system_type
|
||||
* @param inst
|
||||
*/
|
||||
@Override
|
||||
public void sendAgvInstToNDC(String agv_system_type, Instruction inst) {
|
||||
log.info("sendAgvInstToNDC 指令下发NDC:" + "inst_code:" + inst.getInstruction_code() + ",agv_system_type:" + agv_system_type + ",agv_inst_type:" + inst.getAgv_inst_type() +
|
||||
@@ -88,7 +92,7 @@ public class NDCAgvServiceImpl implements NDCAgvService {
|
||||
int type = Integer.parseInt(inst.getAgv_inst_type());
|
||||
int priority = Integer.parseInt(inst.getPriority()) + 128;
|
||||
// 车号。。。
|
||||
String carno = inst.getCarno();
|
||||
String carno = ObjectUtil.isEmpty(inst.getCarno()) ? "0" : inst.getCarno();
|
||||
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
|
||||
DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class);
|
||||
int startAddress = deviceService.queryAddressBydeviceCode(inst.getStart_point_code());
|
||||
@@ -157,7 +161,8 @@ public class NDCAgvServiceImpl implements NDCAgvService {
|
||||
log.info("下发agv指令数据--{}", Bytes2HexString(b));
|
||||
|
||||
if (StrUtil.equals(agv_system_type, "2")) {
|
||||
OneNDCSocketConnectionAutoRun.write(b);
|
||||
// OneNDCSocketConnectionAutoRun.write(b);
|
||||
TwoNDCSocketConnectionAutoRun.write(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -384,7 +389,8 @@ public class NDCAgvServiceImpl implements NDCAgvService {
|
||||
log.info("下发AGV充电任务--{}", str1);
|
||||
|
||||
try {
|
||||
OneNDCSocketConnectionAutoRun.write(b);
|
||||
// OneNDCSocketConnectionAutoRun.write(b);
|
||||
TwoNDCSocketConnectionAutoRun.write(b);
|
||||
} catch (Exception e) {
|
||||
log.error("下发充电任务失败{}{}", e, e.getMessage());
|
||||
}
|
||||
@@ -518,7 +524,8 @@ public class NDCAgvServiceImpl implements NDCAgvService {
|
||||
log.info("下发AGV充电任务--{}", str1);
|
||||
|
||||
try {
|
||||
OneNDCSocketConnectionAutoRun.write(b);
|
||||
// OneNDCSocketConnectionAutoRun.write(b);
|
||||
TwoNDCSocketConnectionAutoRun.write(b);
|
||||
temp.setValue("1");
|
||||
temp.setPara2(String.valueOf(carno));
|
||||
dictService.updateDetail(temp);
|
||||
|
||||
@@ -1,287 +1,287 @@
|
||||
package org.nl.acs.auto.run;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.AcsConfig;
|
||||
import org.nl.acs.agv.server.NDCAgvService;
|
||||
import org.nl.acs.common.base.CommonFinalParam;
|
||||
import org.nl.acs.device.domain.Device;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.device_driver.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.enums.InstructionStatusEnum;
|
||||
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.config.lucene.service.LuceneExecuteLogService;
|
||||
import org.nl.system.service.dict.ISysDictService;
|
||||
import org.nl.system.service.dict.dao.Dict;
|
||||
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.stereotype.Component;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Socket;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import static org.nl.acs.agv.server.impl.NDCAgvServiceImpl.Bytes2HexString;
|
||||
|
||||
/**
|
||||
* Demo class
|
||||
*
|
||||
* @author zhoujj
|
||||
* @date 2023/12/06
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
||||
|
||||
Socket socket;
|
||||
String ip = "192.168.46.225";
|
||||
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 OneNDCSocketConnectionAutoRun() {
|
||||
this.recordTime = new Date((new Date()).getTime() - (long) this.recordTimeOut);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCode() {
|
||||
return OneNDCSocketConnectionAutoRun.class.getSimpleName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "NDC在线连接";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void autoRun() throws IOException {
|
||||
System.out.println("NDCAgv链接开始");
|
||||
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.AGVURL2).getValue();
|
||||
port = Integer.parseInt(paramService.findByCode(AcsConfig.AGVPORT2).getValue());
|
||||
InetSocketAddress socketAddress = new InetSocketAddress(ip, port);
|
||||
|
||||
try {
|
||||
byte[] b = new byte[1024];
|
||||
socket = new Socket(ip, port);
|
||||
socket.connect(socketAddress, 5 * 1000);
|
||||
socket.setKeepAlive(true);//长链接
|
||||
socket.setSoTimeout(30000);//读取超时时间
|
||||
dos = new DataOutputStream(socket.getOutputStream());
|
||||
dis = new DataInputStream(socket.getInputStream());
|
||||
System.out.println("NDCAgv链接成功");
|
||||
log.info("NDCAgv链接成功");
|
||||
while (bConnected) {
|
||||
int count = dis.read(b);
|
||||
|
||||
if (count == -1) {
|
||||
break;
|
||||
}
|
||||
|
||||
int[] arr = new int[count];
|
||||
StringBuffer bs = new StringBuffer();
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
int temp = b[i];
|
||||
if (temp < 0) {
|
||||
temp += 256;
|
||||
}
|
||||
arr[i] = temp;
|
||||
StringBuffer bs1 = new StringBuffer("0");
|
||||
bs.append(temp < 16 ? bs1.append(Integer.toHexString(temp)) : Integer.toHexString(temp));
|
||||
}
|
||||
|
||||
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上报信息:" + bs);
|
||||
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(InstructionStatusEnum.BUSY.getIndex());
|
||||
inst.setAgv_jobno(String.valueOf(index));
|
||||
inst.setSend_status(CommonFinalParam.ONE);
|
||||
instructionService.update(inst);
|
||||
}
|
||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0);
|
||||
}
|
||||
//任务完毕
|
||||
//(无车id及状态)
|
||||
else if (phase == 0x14) {
|
||||
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任务完成!");
|
||||
}
|
||||
//请求删除任务
|
||||
//(需要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 == 0x67) {
|
||||
device = deviceAppService.findDeviceByCode(Integer.toString(arr[27]));
|
||||
} else {
|
||||
device = deviceAppService.findDeviceByCode(Integer.toString(arr[20]));
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(device)) {
|
||||
if (device.getDeviceDriver() instanceof AgvNdcOneDeviceDriver) {
|
||||
agvNdcOneDeviceDriver = (AgvNdcOneDeviceDriver) device.getDeviceDriver();
|
||||
agvNdcOneDeviceDriver.processSocket(arr);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (!ObjectUtil.isEmpty(data)) {
|
||||
write(data);
|
||||
}
|
||||
|
||||
} else {
|
||||
System.out.println("agv上报不是0073类型动作,不处理");
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
System.out.println("Agv链接异常");
|
||||
log.info("Agv链接异常");
|
||||
log.error("agv连接出现异常:{}", e);
|
||||
if (ObjectUtil.isNotEmpty(socket)) {
|
||||
socket.close();
|
||||
}
|
||||
System.out.println(e.getMessage());
|
||||
e.printStackTrace();
|
||||
|
||||
} finally {
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
super.after();
|
||||
try {
|
||||
socket.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.info("再次下发agv数据:" + Bytes2HexString(b));
|
||||
System.out.println("再次下发agv数据:" + Bytes2HexString(b));
|
||||
dos.write(b);
|
||||
dos.flush();
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//package org.nl.acs.auto.run;
|
||||
//
|
||||
//import cn.hutool.core.util.ObjectUtil;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.nl.acs.AcsConfig;
|
||||
//import org.nl.acs.agv.server.NDCAgvService;
|
||||
//import org.nl.acs.common.base.CommonFinalParam;
|
||||
//import org.nl.acs.device.domain.Device;
|
||||
//import org.nl.acs.device.service.DeviceService;
|
||||
//import org.nl.acs.device_driver.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.enums.InstructionStatusEnum;
|
||||
//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.config.lucene.service.LuceneExecuteLogService;
|
||||
//import org.nl.system.service.dict.ISysDictService;
|
||||
//import org.nl.system.service.dict.dao.Dict;
|
||||
//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.stereotype.Component;
|
||||
//
|
||||
//import java.io.DataInputStream;
|
||||
//import java.io.DataOutputStream;
|
||||
//import java.io.IOException;
|
||||
//import java.net.InetSocketAddress;
|
||||
//import java.net.Socket;
|
||||
//import java.util.Date;
|
||||
//import java.util.List;
|
||||
//
|
||||
//import static org.nl.acs.agv.server.impl.NDCAgvServiceImpl.Bytes2HexString;
|
||||
//
|
||||
///**
|
||||
// * Demo class
|
||||
// *
|
||||
// * @author zhoujj
|
||||
// * @date 2023/12/06
|
||||
// */
|
||||
//@Slf4j
|
||||
//@Component
|
||||
//public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
||||
//
|
||||
// Socket socket;
|
||||
// String ip = "192.168.46.225";
|
||||
// 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 OneNDCSocketConnectionAutoRun() {
|
||||
// this.recordTime = new Date((new Date()).getTime() - (long) this.recordTimeOut);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String getCode() {
|
||||
// return OneNDCSocketConnectionAutoRun.class.getSimpleName();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String getName() {
|
||||
// return "NDC在线连接";
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void autoRun() throws IOException {
|
||||
// System.out.println("NDCAgv链接开始");
|
||||
// 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.AGVURL2).getValue();
|
||||
// port = Integer.parseInt(paramService.findByCode(AcsConfig.AGVPORT2).getValue());
|
||||
// InetSocketAddress socketAddress = new InetSocketAddress(ip, port);
|
||||
//
|
||||
// try {
|
||||
// byte[] b = new byte[1024];
|
||||
// socket = new Socket(ip, port);
|
||||
// socket.connect(socketAddress, 5 * 1000);
|
||||
// socket.setKeepAlive(true);//长链接
|
||||
// socket.setSoTimeout(30000);//读取超时时间
|
||||
// dos = new DataOutputStream(socket.getOutputStream());
|
||||
// dis = new DataInputStream(socket.getInputStream());
|
||||
// System.out.println("NDCAgv链接成功");
|
||||
// log.info("NDCAgv链接成功");
|
||||
// while (bConnected) {
|
||||
// int count = dis.read(b);
|
||||
//
|
||||
// if (count == -1) {
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// int[] arr = new int[count];
|
||||
// StringBuffer bs = new StringBuffer();
|
||||
//
|
||||
// for (int i = 0; i < count; i++) {
|
||||
// int temp = b[i];
|
||||
// if (temp < 0) {
|
||||
// temp += 256;
|
||||
// }
|
||||
// arr[i] = temp;
|
||||
// StringBuffer bs1 = new StringBuffer("0");
|
||||
// bs.append(temp < 16 ? bs1.append(Integer.toHexString(temp)) : Integer.toHexString(temp));
|
||||
// }
|
||||
//
|
||||
// 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上报信息:" + bs);
|
||||
// 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(InstructionStatusEnum.BUSY.getIndex());
|
||||
// inst.setAgv_jobno(String.valueOf(index));
|
||||
// inst.setSend_status(CommonFinalParam.ONE);
|
||||
// instructionService.update(inst);
|
||||
// }
|
||||
// data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0);
|
||||
// }
|
||||
// //任务完毕
|
||||
// //(无车id及状态)
|
||||
// else if (phase == 0x14) {
|
||||
// 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任务完成!");
|
||||
// }
|
||||
// //请求删除任务
|
||||
// //(需要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 == 0x67) {
|
||||
// device = deviceAppService.findDeviceByCode(Integer.toString(arr[27]));
|
||||
// } else {
|
||||
// device = deviceAppService.findDeviceByCode(Integer.toString(arr[20]));
|
||||
// }
|
||||
// if (ObjectUtil.isNotEmpty(device)) {
|
||||
// if (device.getDeviceDriver() instanceof AgvNdcOneDeviceDriver) {
|
||||
// agvNdcOneDeviceDriver = (AgvNdcOneDeviceDriver) device.getDeviceDriver();
|
||||
// agvNdcOneDeviceDriver.processSocket(arr);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// if (!ObjectUtil.isEmpty(data)) {
|
||||
// write(data);
|
||||
// }
|
||||
//
|
||||
// } else {
|
||||
// System.out.println("agv上报不是0073类型动作,不处理");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// } catch (Exception e) {
|
||||
// System.out.println("Agv链接异常");
|
||||
// log.info("Agv链接异常");
|
||||
// log.error("agv连接出现异常:{}", e);
|
||||
// if (ObjectUtil.isNotEmpty(socket)) {
|
||||
// socket.close();
|
||||
// }
|
||||
// System.out.println(e.getMessage());
|
||||
// e.printStackTrace();
|
||||
//
|
||||
// } finally {
|
||||
//
|
||||
//
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Override
|
||||
// public void stop() {
|
||||
// super.after();
|
||||
// try {
|
||||
// socket.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.info("再次下发agv数据:" + Bytes2HexString(b));
|
||||
// System.out.println("再次下发agv数据:" + Bytes2HexString(b));
|
||||
// dos.write(b);
|
||||
// dos.flush();
|
||||
// } catch (Exception e1) {
|
||||
// e1.printStackTrace();
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//
|
||||
|
||||
@@ -7,7 +7,7 @@ import lombok.Data;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.agv.server.NDCAgvService;
|
||||
import org.nl.acs.auto.run.OneNDCSocketConnectionAutoRun;
|
||||
import org.nl.acs.auto.run.TwoNDCSocketConnectionAutoRun;
|
||||
import org.nl.acs.common.base.CommonFinalParam;
|
||||
import org.nl.acs.device.domain.Device;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
@@ -32,7 +32,6 @@ import org.nl.acs.opc.DeviceAppService;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
import org.nl.config.lucene.service.LuceneExecuteLogService;
|
||||
import org.nl.config.lucene.service.dto.LuceneLogDto;
|
||||
import org.nl.config.thread.ThreadPoolExecutorUtil;
|
||||
import org.nl.system.service.param.ISysParamService;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -1419,7 +1418,8 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
|
||||
if (!ObjectUtil.isEmpty(data)) {
|
||||
phase = 0;
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + Bytes2HexString(data));
|
||||
OneNDCSocketConnectionAutoRun.write(data);
|
||||
// OneNDCSocketConnectionAutoRun.write(data);
|
||||
TwoNDCSocketConnectionAutoRun.write(data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -129,6 +129,10 @@ public class CreateTaskRequest extends BaseRequest {
|
||||
* 6、行架
|
||||
* 7、立库
|
||||
* 任务类型
|
||||
* 1、普通任务
|
||||
* 2、取放校验桶号
|
||||
* 3、取放取放校验桶号
|
||||
* 4、4点任务
|
||||
*/
|
||||
String task_type;
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
||||
// response.setErrArr(datas);
|
||||
// return response;
|
||||
// }
|
||||
// 将LMS任务转成ACS任务并保存
|
||||
// 将LMS任务转成ACS任务并保存, 因为到这里的都是一整组,失败一条就全失败
|
||||
for (int i = 0; i < datas.size(); i++) {
|
||||
String data = datas.get(i).toString();
|
||||
CreateTaskRequest request = JsonUtl.format(data, CreateTaskRequest.class);
|
||||
@@ -126,7 +126,6 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
||||
if (StrUtil.isNotEmpty(request.getOven_time())) {
|
||||
oven_time = Double.parseDouble(request.getOven_time());
|
||||
}
|
||||
String temperature = request.getTemperature();
|
||||
String start_height = request.getStart_height();
|
||||
String next_height = request.getNext_height();
|
||||
String params2 = request.getParams2();
|
||||
@@ -162,11 +161,6 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (StrUtil.equals(task_type, "8")) {
|
||||
next_device_code = request.getPut_device_code();
|
||||
put_device_code = request.getNext_device_code();
|
||||
}
|
||||
|
||||
StorageCell start_storageCell = new LambdaQueryChainWrapper<>(storageCellMapper)
|
||||
.eq(StorageCell::getStorage_code, start_device_code)
|
||||
.one();
|
||||
@@ -242,17 +236,6 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
||||
route_plan_code = "normal";
|
||||
}
|
||||
|
||||
if (StrUtil.equals(task_type, "5")) {
|
||||
if (taskserver.querySameDeviceReadyTask(start_device_code, next_device_code, "0") > 1) {
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("task_code", task_code);
|
||||
json.put("ext_task_id", ext_task_id);
|
||||
json.put("message", "已存在相同的起点:" + start_device_code + "终点:" + next_device_code + "未执行的输送任务");
|
||||
errArr.add(json);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
TaskDto taskDto = taskserver.findByCodeFromCache(task_code);
|
||||
if (taskDto != null) {
|
||||
JSONObject json = new JSONObject();
|
||||
@@ -274,15 +257,6 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
||||
}
|
||||
}
|
||||
|
||||
// if (StrUtil.isEmpty(vehicle_code2)) {
|
||||
// JSONObject json = new JSONObject();
|
||||
// json.put("task_code", task_code);
|
||||
// json.put("ext_task_id", ext_task_id);
|
||||
// json.put("message", " 木箱号不能为空!");
|
||||
// errArr.add(json);
|
||||
// continue;
|
||||
// }
|
||||
|
||||
if (StrUtil.isEmpty(start_point_code)) {
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("task_code", task_code);
|
||||
@@ -336,11 +310,8 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
||||
jo.put("paper_array", JSONUtil.toJsonStr(paper_array));
|
||||
jo.put("truss_type", JSONUtil.toJsonStr(truss_type));
|
||||
jo.put("empty_site", JSONUtil.toJsonStr(empty_site));
|
||||
jo.put("is_bushing", JSONUtil.toJsonStr(is_bushing));
|
||||
jo.put("is_pulling", JSONUtil.toJsonStr(is_pulling));
|
||||
jo.put("size", JSONUtil.toJsonStr(size));
|
||||
jo.put("version", JSONUtil.toJsonStr(version));
|
||||
jo.put("bushing_num", JSONUtil.toJsonStr(bushing_num));
|
||||
if (!StrUtil.isEmpty(ext_task_id)) {
|
||||
jo.put("ext_task_id", ext_task_id);
|
||||
}
|
||||
@@ -357,30 +328,16 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("task_code", task_code);
|
||||
json.put("ext_task_id", ext_task_id);
|
||||
json.put("message", e.getMessage());
|
||||
json.put("message", ObjectUtil.isEmpty(e.getMessage()) ? "空指针" : e.getMessage());
|
||||
errArr.add(json);
|
||||
continue;
|
||||
}
|
||||
if ("RK1002".equals(task_dto.getStart_device_code())){
|
||||
Device device = deviceAppService.findDeviceByCode("RK1003");
|
||||
BeltConveyorDeviceDriver beltConveyorDeviceDriver1;
|
||||
if (device.getDeviceDriver() instanceof BeltConveyorDeviceDriver) {
|
||||
beltConveyorDeviceDriver1 = (BeltConveyorDeviceDriver) device.getDeviceDriver();
|
||||
List list1 = new ArrayList();
|
||||
Map map = new HashMap();
|
||||
map.put("code", "to_command");
|
||||
map.put("value", "55");
|
||||
list1.add(map);
|
||||
beltConveyorDeviceDriver1.writing(list1);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isEmpty(errArr)) {
|
||||
response.setStatus(200);
|
||||
response.setMessage("success");
|
||||
} else {
|
||||
response.setStatus(400);
|
||||
response.setStatus(200);
|
||||
if (ObjectUtil.isNotEmpty(errArr)) {
|
||||
response.setMessage(errArr.getJSONObject(0).getString("message"));
|
||||
} else {
|
||||
@@ -550,7 +507,6 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getTubeMes(String jsonObject) throws Exception {
|
||||
log.info("下发管芯信息--------------:输入参数" + jsonObject);
|
||||
@@ -591,8 +547,6 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
||||
JSONArray datas = JSONArray.parseArray(jsonObject);
|
||||
|
||||
|
||||
|
||||
|
||||
//标准版输送线
|
||||
BeltConveyorDeviceDriver beltConveyorDeviceDriver;
|
||||
UnpackingMachineDeviceDriver unpackingMachineDeviceDriver;
|
||||
|
||||
@@ -9,12 +9,12 @@ 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:47.111.78.178}:${DB_PORT:3306}/${DB_NAME:lzhl_two_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
|
||||
url: jdbc:log4jdbc:mysql://${DB_HOST:192.168.81.251}:${DB_PORT:3306}/${DB_NAME:zzzw_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true
|
||||
url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:zzzw_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
|
||||
# url: jdbc:log4jdbc:mysql://${DB_HOST:192.168.81.251}:${DB_PORT:3306}/${DB_NAME:zzzw_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true
|
||||
|
||||
username: ${DB_USER:root}
|
||||
password: ${DB_PWD:P@ssw0rd.}
|
||||
# password: ${DB_PWD:123456}
|
||||
# password: ${DB_PWD:P@ssw0rd.}
|
||||
password: ${DB_PWD:12356}
|
||||
# 初始连接数
|
||||
initial-size: 5
|
||||
# 最小连接数
|
||||
|
||||
Reference in New Issue
Block a user