Преглед изворни кода

增加OkHttp配置文件读取

tags/v1.0.0^2
林万龙 пре 3 година
родитељ
комит
5fc68fa22a
4 измењених фајлова са 42 додато и 29 уклоњено
  1. +5
    -3
      src/main/java/com/telpo/dipperposition/co/PositionConfigInfo.java
  2. +22
    -22
      src/main/java/com/telpo/dipperposition/config/PositionConfig.java
  3. +12
    -2
      src/main/java/com/telpo/dipperposition/server/DipperPositionServer.java
  4. +3
    -2
      src/main/java/com/telpo/dipperposition/service/impl/DipperDataAsyncTaskServiceImpl.java

+ 5
- 3
src/main/java/com/telpo/dipperposition/co/PositionConfigInfo.java Прегледај датотеку

@@ -6,6 +6,7 @@ import lombok.ToString;
import okhttp3.*;
import okhttp3.internal.ws.RealWebSocket;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

@@ -20,14 +21,15 @@ import javax.net.SocketFactory;
@Getter
@Setter
@Component
@ConfigurationProperties(prefix = "position-server")
public class PositionConfigInfo {

private String serverAddr;

private String timeAsycServerPort;
private String timeAsycPort;

private String posAsycServerPort;
private String posAsycPort;

private String starsAsycServerPort;
private String starsAsycPort;

}

+ 22
- 22
src/main/java/com/telpo/dipperposition/config/PositionConfig.java Прегледај датотеку

@@ -30,32 +30,32 @@ public class PositionConfig {
//@Value(value = "${spring.application.name}")
//private String name;

@Value(value = "${position.server.serverAddr}")
private String serverAddr;
@Value(value = "${position.server.timeAsycPort}")
private String timeAsycServerPort;
@Value(value = "${position.server.posAsycPort}")
private String posAsycServerPort;
@Value(value = "${position.server.starsAsycPort}")
private String starsAsycServerPort;
// @Value(value = "${position.server.serverAddr}")
// private String serverAddr;
//
// @Value(value = "${position.server.timeAsycPort}")
// private String timeAsycServerPort;
//
// @Value(value = "${position.server.posAsycPort}")
// private String posAsycServerPort;
//
// @Value(value = "${position.server.starsAsycPort}")
// private String starsAsycServerPort;

PositionConfig()
{
//hello = configurableApplicationContext.getEnvironment().getProperty("position.hello");
//name = configurableApplicationContext.getEnvironment().getProperty("spring.application.name");
}
@Bean (name = "positionConfigInfo")
public PositionConfigInfo positionConfigInfo(){
PositionConfigInfo configInfo = new PositionConfigInfo();
configInfo.setServerAddr(this.serverAddr);
configInfo.setTimeAsycServerPort(this.timeAsycServerPort);
configInfo.setPosAsycServerPort(this.posAsycServerPort);
configInfo.setStarsAsycServerPort(this.starsAsycServerPort);
System.out.print(configInfo.toString());
return configInfo;
}
//
// @Bean (name = "positionConfigInfo")
// public PositionConfigInfo positionConfigInfo(){
// PositionConfigInfo configInfo = new PositionConfigInfo();
// configInfo.setServerAddr(this.serverAddr);
// configInfo.setTimeAsycServerPort(this.timeAsycServerPort);
// configInfo.setPosAsycServerPort(this.posAsycServerPort);
// configInfo.setStarsAsycServerPort(this.starsAsycServerPort);
// System.out.print(configInfo.toString());
// return configInfo;
// }
}

+ 12
- 2
src/main/java/com/telpo/dipperposition/server/DipperPositionServer.java Прегледај датотеку

@@ -1,5 +1,9 @@
package com.telpo.dipperposition.server;

import com.alibaba.nacos.api.NacosFactory;
import com.alibaba.nacos.api.PropertyKeyConst;
import com.alibaba.nacos.api.config.ConfigService;
import com.alibaba.nacos.api.exception.NacosException;
import com.telpo.dipperposition.co.PositionConfigInfo;
import com.telpo.dipperposition.config.AsyncExecutorConfig;
import com.telpo.dipperposition.config.PositionConfig;
@@ -14,8 +18,11 @@ import io.netty.channel.socket.nio.NioServerSocketChannel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.config.YamlMapFactoryBean;

import java.io.InputStream;
import java.net.InetSocketAddress;
import java.util.Properties;


/**
@@ -27,13 +34,16 @@ import java.net.InetSocketAddress;
@Slf4j
public class DipperPositionServer {

@Autowired PositionConfigInfo positionConfigInfo;
private String serverAddr="172.16.192.26";
private String timeAsycServerPort="9011";
private String posAsycServerPort="9013";
private String starsAsycServerPort="9012";

@Autowired
AsyncExecutorConfig positionConfig;
public DipperPositionServer() throws NacosException {
String serverAddr = positionConfigInfo.getServerAddr();
log.info("Config serverAddr is " + serverAddr);
}
/*
* 时间同步进程线程
*/


+ 3
- 2
src/main/java/com/telpo/dipperposition/service/impl/DipperDataAsyncTaskServiceImpl.java Прегледај датотеку

@@ -22,6 +22,7 @@ public class DipperDataAsyncTaskServiceImpl implements IDipperDataAsyncTaskServi


private static String DIPPER_DATA_KEY = "TaidouDipperData";
private static String DIPPER_ALL_DATA_REQ = "616C6C";

@Autowired
private RedisUtil redisUtil;
@@ -49,8 +50,8 @@ public class DipperDataAsyncTaskServiceImpl implements IDipperDataAsyncTaskServi
SocketClient client = new SocketClient(schedulingExecutorConfig.getAstServer(), schedulingExecutorConfig.getEphAstHexPort(),schedulingExecutorConfig.getAstTimeout());

// astTimeCmd 组装
String astTimeCmd = "all";
String hexIn = HexConvert.convertStringToHex(astTimeCmd) + HexConvert.makeChecksum(astTimeCmd);
String astTimeCmd = DIPPER_ALL_DATA_REQ;
String hexIn = astTimeCmd + HexConvert.makeChecksum(astTimeCmd);

String ackAckCheckRef = "233E010102000421293C";
String sendResult = client.sendCmd(hexIn, ackAckCheckRef);


Loading…
Откажи
Сачувај