...
|
...
|
@@ -91,7 +91,7 @@ public class CommandClient { |
|
|
head[1]=(byte)0x5C;
|
|
|
head[2]=(byte)0x4B;
|
|
|
head[3]=(byte)0x89;
|
|
|
//消息类型
|
|
|
//消息类型,0x21为gatherInfo 0x22为commandInfo
|
|
|
byte[] mType = new byte[1];
|
|
|
mType[0] = (byte)0x22;
|
|
|
//场站号
|
...
|
...
|
@@ -130,6 +130,63 @@ public class CommandClient { |
|
|
log.info("文件发送失败"+e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private static void sendWithSocket_x21(GatherInfo info,String xmlBody){
|
|
|
Socket socket =null;
|
|
|
OutputStream op = null;
|
|
|
try {
|
|
|
//ip+端口
|
|
|
socket = new Socket("118.31.66.166", 17007);
|
|
|
log.info("socket通讯创建连接成功");
|
|
|
op = socket.getOutputStream();
|
|
|
//xml字节流
|
|
|
byte[]xBody =xmlBody.getBytes("GB2312");
|
|
|
//包头
|
|
|
byte[] head = new byte[4];
|
|
|
head[0]=(byte)0xE2;
|
|
|
head[1]=(byte)0x5C;
|
|
|
head[2]=(byte)0x4B;
|
|
|
head[3]=(byte)0x89;
|
|
|
//消息类型,0x21为gatherInfo 0x22为commandInfo
|
|
|
byte[] mType = new byte[1];
|
|
|
mType[0] = (byte)0x21;
|
|
|
//场站号
|
|
|
byte[]station =info.getAreaid().getBytes("ASCII");
|
|
|
//通道号
|
|
|
byte[]aisle =info.getChnlno().getBytes("ASCII");
|
|
|
//进出标识
|
|
|
byte[]eType =info.getIetype().getBytes("ASCII");
|
|
|
//标识符
|
|
|
byte[] bwFlag = new byte[4];
|
|
|
bwFlag[0]=(byte)0x00;
|
|
|
bwFlag[1]=(byte)0x00;
|
|
|
bwFlag[2]=(byte)0x00;
|
|
|
bwFlag[3]=(byte)0x00;
|
|
|
//xml字节流长度
|
|
|
byte[]xmlLength = intToByte4(xBody.length);
|
|
|
//包尾
|
|
|
byte[]end = new byte[2];
|
|
|
end[0]=(byte)0xFF;
|
|
|
end[1]=(byte)0xFF;
|
|
|
System.out.println();
|
|
|
//总长 4为总长的length
|
|
|
byte [] packge = intToByte4((head.length+xBody.length+mType.length+station.length+aisle.length+eType
|
|
|
.length+bwFlag.length+xmlLength.length+end.length+4));
|
|
|
byte[]allByte = byteMergerAll(head,packge,mType,station,aisle,eType,bwFlag,xmlLength,xBody,end);
|
|
|
op.write(allByte);
|
|
|
op.flush();
|
|
|
op.close();
|
|
|
log.info("发送完毕");
|
|
|
socket.close();
|
|
|
} catch (UnknownHostException e) {
|
|
|
e.printStackTrace();
|
|
|
log.info("创建连接失败"+e.getMessage());
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
|
log.info("文件发送失败"+e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @Param info 卡口采集信息
|
|
|
* @Param flag 放行标识
|
...
|
...
|
@@ -185,7 +242,7 @@ public class CommandClient { |
|
|
//给三宝的去掉BARCODE,todo:不去掉做个测试
|
|
|
.replace("${BAR_CODE}",info.getBarcode());
|
|
|
|
|
|
sendWithSocket(info,gatherXML);
|
|
|
sendWithSocket_x21(info,gatherXML);
|
|
|
}
|
|
|
|
|
|
|
...
|
...
|
|