@@ -38,7 +38,7 @@ public class SocketClient { | |||||
} | } | ||||
public byte[] sendCmd(String astCmd, String ackAckCheckRef) { | |||||
public byte[] sendCmd(String astCmd) { | |||||
try { | try { | ||||
OutputStream os=socket.getOutputStream(); | OutputStream os=socket.getOutputStream(); | ||||
PrintWriter pw=new PrintWriter(os); | PrintWriter pw=new PrintWriter(os); | ||||
@@ -56,23 +56,12 @@ public class SocketClient { | |||||
ByteArrayOutputStream swapStream = new ByteArrayOutputStream(); | ByteArrayOutputStream swapStream = new ByteArrayOutputStream(); | ||||
byte[] buff = new byte[100]; | byte[] buff = new byte[100]; | ||||
//StringBuffer ackResultBuf= new StringBuffer(); | |||||
//String ackHexOut = HexConvert.convertStringToHex(ackAckCheckRef); | |||||
// reply=br.readLine(); | |||||
// while(reply!=null){ | |||||
// //log.debug("接收服务器的信息:"+reply); | |||||
// //if (ackHexOut.equals(reply)) { | |||||
// ackResultBuf.append(reply); | |||||
// reply=br.readLine(); | |||||
// // break; | |||||
// //} | |||||
// } | |||||
int rc = 0; | int rc = 0; | ||||
while ((rc = is.read(buff, 0, 100)) > 0) { | while ((rc = is.read(buff, 0, 100)) > 0) { | ||||
swapStream.write(buff, 0, rc); | swapStream.write(buff, 0, rc); | ||||
} | } | ||||
byte[] in2b = swapStream.toByteArray(); | byte[] in2b = swapStream.toByteArray(); | ||||
//String ackResult = HexConvert.convertHexToString(ackResultBuf.toString()); | |||||
//4.关闭资源 | //4.关闭资源 | ||||
swapStream.close(); | swapStream.close(); | ||||
is.close(); | is.close(); | ||||
@@ -48,8 +48,9 @@ public class DipperDataAsyncTaskServiceImpl implements IDipperDataAsyncTaskServi | |||||
private byte[] pullEPHFromDipper() { | private byte[] pullEPHFromDipper() { | ||||
// 创建Socket客户端实例; | // 创建Socket客户端实例; | ||||
SocketClient client = new SocketClient(schedulingExecutorConfig.getAstServer(), | |||||
schedulingExecutorConfig.getAstEphAstHexPort(),schedulingExecutorConfig.getAstTimeout()); | |||||
String serverAddr = schedulingExecutorConfig.getAstServer(); | |||||
int serverPort = schedulingExecutorConfig.getAstEphAstHexPort(); | |||||
SocketClient client = new SocketClient(serverAddr,serverPort,schedulingExecutorConfig.getAstTimeout()); | |||||
// astTimeCmd 组装 | // astTimeCmd 组装 | ||||
String astTimeCmd = DIPPER_ALL_DATA_REQ; | String astTimeCmd = DIPPER_ALL_DATA_REQ; | ||||
@@ -63,8 +64,9 @@ public class DipperDataAsyncTaskServiceImpl implements IDipperDataAsyncTaskServi | |||||
String hexIn = astTimeCmd + checkSum.substring(0,2) + " " + checkSum.substring(2,4); | String hexIn = astTimeCmd + checkSum.substring(0,2) + " " + checkSum.substring(2,4); | ||||
byte[] sendResult = null; | |||||
String ackAckCheckRef = "233E010102000421293C"; | String ackAckCheckRef = "233E010102000421293C"; | ||||
byte[] sendResult = client.sendCmd(hexIn, ackAckCheckRef); | |||||
sendResult = client.sendCmd(hexIn); | |||||
client.closeConnection(); | client.closeConnection(); | ||||
return sendResult; | return sendResult; | ||||
@@ -55,7 +55,12 @@ public class IpProvinceServiceImpl implements IpProvinceService { | |||||
ExampleMatcher matcher = ExampleMatcher.matching().withIgnorePaths("_class"); | ExampleMatcher matcher = ExampleMatcher.matching().withIgnorePaths("_class"); | ||||
Example<IpProvinceEntity> example = Example.of(query, matcher); | Example<IpProvinceEntity> example = Example.of(query, matcher); | ||||
Optional<IpProvinceEntity> data = ipProvinceMapper.findOne(example); | Optional<IpProvinceEntity> data = ipProvinceMapper.findOne(example); | ||||
return data.orElse(null); | |||||
if (data.isPresent() == true) { | |||||
return data.get(); | |||||
} else { | |||||
return null; | |||||
} | |||||
//return data.orElse(null); | |||||
} catch (Exception e) { | } catch (Exception e) { | ||||
log.error("获取IP省份异常:", e); | log.error("获取IP省份异常:", e); | ||||
return null; | return null; | ||||