rev ndc链接
This commit is contained in:
@@ -27,6 +27,7 @@ import org.springframework.stereotype.Component;
|
|||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.net.InetSocketAddress;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -82,12 +83,21 @@ public class TwoNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
System.out.println("2楼1区域AGV系统链接开始");
|
System.out.println("2楼1区域AGV系统链接开始");
|
||||||
|
|
||||||
ip = paramService.findByCode(AcsConfig.AGVURL2).getValue();
|
ip = paramService.findByCode(AcsConfig.AGVURL2).getValue();
|
||||||
port = Integer.parseInt(paramService.findByCode(AcsConfig.AGVPORT2).getValue());
|
port = Integer.parseInt(paramService.findByCode(AcsConfig.AGVPORT2).getValue());
|
||||||
|
// byte[] b = new byte[1024];
|
||||||
|
// s = new Socket(ip, port);
|
||||||
|
// System.out.println("2楼1区域Agv链接成功");
|
||||||
|
// dos = new DataOutputStream(s.getOutputStream());
|
||||||
|
// dis = new DataInputStream(s.getInputStream());
|
||||||
|
|
||||||
|
InetSocketAddress socketAddress = new InetSocketAddress(ip, port);
|
||||||
|
|
||||||
byte[] b = new byte[1024];
|
byte[] b = new byte[1024];
|
||||||
s = new Socket(ip, port);
|
s = new Socket();
|
||||||
System.out.println("2楼1区域Agv链接成功");
|
s.connect(socketAddress,2*1000);
|
||||||
|
s.setKeepAlive(true);//长链接
|
||||||
|
// s.setSoTimeout(1000* 60 * 10);//读取超时时间
|
||||||
dos = new DataOutputStream(s.getOutputStream());
|
dos = new DataOutputStream(s.getOutputStream());
|
||||||
dis = new DataInputStream(s.getInputStream());
|
dis = new DataInputStream(s.getInputStream());
|
||||||
|
|
||||||
@@ -317,17 +327,20 @@ public class TwoNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
|||||||
try {
|
try {
|
||||||
log.info("下发agv数据:" + Bytes2HexString(b));
|
log.info("下发agv数据:" + Bytes2HexString(b));
|
||||||
System.out.println("下发agv数据:" + Bytes2HexString(b));
|
System.out.println("下发agv数据:" + Bytes2HexString(b));
|
||||||
if (ObjectUtil.isEmpty(dos)) {
|
|
||||||
throw new BadRequestException("2楼NDC链接异常!");
|
|
||||||
}
|
|
||||||
dos.write(b);
|
dos.write(b);
|
||||||
dos.flush();
|
dos.flush();
|
||||||
} catch (IOException e) {
|
} catch (Exception e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
log.info("下发agv数据异常:" + e.getMessage());
|
try{
|
||||||
e.printStackTrace();
|
Thread.sleep(5000);
|
||||||
|
log.info("再次下发agv数据:" + Bytes2HexString(b));
|
||||||
|
System.out.println("再次下发agv数据:" + Bytes2HexString(b));
|
||||||
|
dos.write(b);
|
||||||
|
dos.flush();
|
||||||
|
} catch (Exception e1){
|
||||||
|
e1.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -396,7 +396,14 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
&& ObjectUtil.isNotEmpty(task.getAgv_system_type())) {
|
&& ObjectUtil.isNotEmpty(task.getAgv_system_type())) {
|
||||||
NDCAgvService ndcAgvService = SpringContextHolder.getBean(NDCAgvService.class);
|
NDCAgvService ndcAgvService = SpringContextHolder.getBean(NDCAgvService.class);
|
||||||
log.warn("下发AGV指令数据,"+ "指令号:" + dto.getInstruction_code() + ",AGV系统类型:"+ task.getAgv_system_type());
|
log.warn("下发AGV指令数据,"+ "指令号:" + dto.getInstruction_code() + ",AGV系统类型:"+ task.getAgv_system_type());
|
||||||
ndcAgvService.sendAgvInstToNDC(task.getAgv_system_type(), dto);
|
try {
|
||||||
|
ndcAgvService.sendAgvInstToNDC(task.getAgv_system_type(), dto);
|
||||||
|
} catch (Exception e){
|
||||||
|
dto.setSend_status("2");
|
||||||
|
dto.setRemark(e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
log.warn("下发AGV指令异常:"+ e);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Boolean result = createLkInst(task.getStorage_task_type(),dto);
|
// Boolean result = createLkInst(task.getStorage_task_type(),dto);
|
||||||
Resp resp = acsToLiKuService.sendInst(task.getStorage_task_type(), dto);
|
Resp resp = acsToLiKuService.sendInst(task.getStorage_task_type(), dto);
|
||||||
@@ -410,8 +417,8 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
dto.setSend_status("2");
|
dto.setSend_status("2");
|
||||||
dto.setRemark(e.getMessage());
|
dto.setRemark(e.getMessage());
|
||||||
e.printStackTrace();
|
|
||||||
log.warn("创建指令异常:"+e.getMessage());
|
log.warn("创建指令异常:"+e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
WQLObject wo = WQLObject.getWQLObject("acs_instruction");
|
WQLObject wo = WQLObject.getWQLObject("acs_instruction");
|
||||||
|
|||||||
Reference in New Issue
Block a user