rev ndc链接

This commit is contained in:
USER-20220102CG\noblelift
2023-10-24 10:10:57 +08:00
parent 9224b0d07c
commit c7fd9d892d
2 changed files with 32 additions and 12 deletions

View File

@@ -27,6 +27,7 @@ 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;
@@ -82,12 +83,21 @@ public class TwoNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
try {
System.out.println("2楼1区域AGV系统链接开始");
ip = paramService.findByCode(AcsConfig.AGVURL2).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];
s = new Socket(ip, port);
System.out.println("2楼1区域Agv链接成功");
s = new Socket();
s.connect(socketAddress,2*1000);
s.setKeepAlive(true);//长链接
// s.setSoTimeout(1000* 60 * 10);//读取超时时间
dos = new DataOutputStream(s.getOutputStream());
dis = new DataInputStream(s.getInputStream());
@@ -317,17 +327,20 @@ public class TwoNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
try {
log.info("下发agv数据:" + Bytes2HexString(b));
System.out.println("下发agv数据:" + Bytes2HexString(b));
if (ObjectUtil.isEmpty(dos)) {
throw new BadRequestException("2楼NDC链接异常");
}
dos.write(b);
dos.flush();
} catch (IOException e) {
} catch (Exception e) {
// TODO Auto-generated catch block
log.info("下发agv数据异常:" + e.getMessage());
e.printStackTrace();
try{
Thread.sleep(5000);
log.info("再次下发agv数据:" + Bytes2HexString(b));
System.out.println("再次下发agv数据:" + Bytes2HexString(b));
dos.write(b);
dos.flush();
} catch (Exception e1){
e1.printStackTrace();
}
}
}
}

View File

@@ -396,7 +396,14 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
&& ObjectUtil.isNotEmpty(task.getAgv_system_type())) {
NDCAgvService ndcAgvService = SpringContextHolder.getBean(NDCAgvService.class);
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 {
// Boolean result = createLkInst(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) {
dto.setSend_status("2");
dto.setRemark(e.getMessage());
e.printStackTrace();
log.warn("创建指令异常:"+e.getMessage());
e.printStackTrace();
}
WQLObject wo = WQLObject.getWQLObject("acs_instruction");