Selaa lähdekoodia

修改到docker外运行环境

tags/v1.0.0^2
林万龙 3 vuotta sitten
vanhempi
commit
1ccd98eb1f
16 muutettua tiedostoa jossa 175 lisäystä ja 85 poistoa
  1. +1
    -1
      src/main/java/com/telpo/dipperposition/common/OkHttpUtil.java
  2. +1
    -6
      src/main/java/com/telpo/dipperposition/common/RedisUtil.java
  3. +1
    -1
      src/main/java/com/telpo/dipperposition/config/NettyServerConfig.java
  4. +1
    -1
      src/main/java/com/telpo/dipperposition/config/PositionConfig.java
  5. +30
    -0
      src/main/java/com/telpo/dipperposition/controller/DipperAstPosAsyncTaskController.java
  6. +32
    -0
      src/main/java/com/telpo/dipperposition/controller/DipperAstTimeAsyncTaskController.java
  7. +22
    -1
      src/main/java/com/telpo/dipperposition/controller/DipperDataAsyncTaskController.java
  8. +23
    -19
      src/main/java/com/telpo/dipperposition/handler/NettyServerHandler.java
  9. +7
    -7
      src/main/java/com/telpo/dipperposition/service/IDipperAstPosAsyncTaskService.java
  10. +2
    -2
      src/main/java/com/telpo/dipperposition/service/IDipperAstTimeAsyncTaskService.java
  11. +2
    -2
      src/main/java/com/telpo/dipperposition/service/IDipperDataAsyncTaskService.java
  12. +2
    -2
      src/main/java/com/telpo/dipperposition/service/IpProvinceService.java
  13. +21
    -14
      src/main/java/com/telpo/dipperposition/service/impl/DipperAstPosAsyncTaskServiceImpl.java
  14. +10
    -10
      src/main/java/com/telpo/dipperposition/service/impl/DipperAstTimeAsyncTaskServiceImpl.java
  15. +11
    -10
      src/main/java/com/telpo/dipperposition/service/impl/DipperDataAsyncTaskServiceImpl.java
  16. +9
    -9
      src/main/java/com/telpo/dipperposition/service/impl/IpProvinceServiceImpl.java

+ 1
- 1
src/main/java/com/telpo/dipperposition/common/OkHttpUtil.java Näytä tiedosto

@@ -26,7 +26,7 @@ public class OkHttpUtil {

@Autowired private OkHttpClient okHttpClient;

private static OkHttpUtil okHttpUtil;
public static OkHttpUtil okHttpUtil;

@PostConstruct
public void init() {


+ 1
- 6
src/main/java/com/telpo/dipperposition/common/RedisUtil.java Näytä tiedosto

@@ -25,12 +25,7 @@ public class RedisUtil {

@Resource private RedisTemplate<String, Object> redisTemplate;

private static RedisUtil redisUtil;
/**
* spring会自动从ioc容器当中根据RedisUtil类型找到redisUtil,当做参数传进来
*
*/

public static RedisUtil redisUtil;
@PostConstruct
public void init() {
redisUtil = this;


+ 1
- 1
src/main/java/com/telpo/dipperposition/config/NettyServerConfig.java Näytä tiedosto

@@ -34,7 +34,7 @@ public class NettyServerConfig {
@NacosValue(value = "${position-server.starsAsycPort}")
private String starsAsycServerPort;

private static NettyServerConfig nettyServerConfig;
public static NettyServerConfig nettyServerConfig;

@PostConstruct
public void init() {


+ 1
- 1
src/main/java/com/telpo/dipperposition/config/PositionConfig.java Näytä tiedosto

@@ -40,7 +40,7 @@ public class PositionConfig {
int astTimeout;


private static PositionConfig positionConfig;
public static PositionConfig positionConfig;

@PostConstruct
public void init() {


+ 30
- 0
src/main/java/com/telpo/dipperposition/controller/DipperAstPosAsyncTaskController.java Näytä tiedosto

@@ -0,0 +1,30 @@
package com.telpo.dipperposition.controller;

import com.telpo.dipperposition.service.IDipperAstPosAsyncTaskService;
import com.telpo.dipperposition.service.IDipperAstTimeAsyncTaskService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;


/**
* @program: DipperAstPosAsyncTaskController
* @description: 北斗定位
* @author: linwl
* @create: 2020-07-10 14:01
*/
@RestController
@Slf4j
public class DipperAstPosAsyncTaskController {

@Autowired
IDipperAstPosAsyncTaskService dipperAstPosAsyncTaskService;

/*
* 拉取星历数据
*/
public String pushAstPos(String ipAddress) {
return dipperAstPosAsyncTaskService.pushAstPos(ipAddress);
}

}

+ 32
- 0
src/main/java/com/telpo/dipperposition/controller/DipperAstTimeAsyncTaskController.java Näytä tiedosto

@@ -0,0 +1,32 @@
package com.telpo.dipperposition.controller;

import com.telpo.dipperposition.service.IDipperAstTimeAsyncTaskService;
import com.telpo.dipperposition.service.IDipperDataAsyncTaskService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
* @program: DipperPositionController
* @description: 北斗定位
* @author: linwl
* @create: 2020-07-10 14:01
*/
@RestController
@Slf4j
public class DipperAstTimeAsyncTaskController {

@Autowired
IDipperAstTimeAsyncTaskService dipperTimeAsyncTaskService;

/*
* 拉取星历数据
*/
public String pushAstTime() {
return dipperTimeAsyncTaskService.pushAstTime();
}

}

src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java → src/main/java/com/telpo/dipperposition/controller/DipperDataAsyncTaskController.java Näytä tiedosto

@@ -1,6 +1,8 @@
package com.telpo.dipperposition.controller;

import com.telpo.dipperposition.service.IDipperDataAsyncTaskService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@@ -14,13 +16,32 @@ import org.springframework.web.bind.annotation.RestController;
*/
@RestController
@Slf4j
public class DipperPositionController {
public class DipperDataAsyncTaskController {
@Value(value = "${position-server.serverAddr}")
private String hello;
//RzlAccount rzlAccount;

@Autowired
IDipperDataAsyncTaskService dipperDataAsyncTaskService;

/*
* 拉取星历数据
*/
public void pullAstEPH() {
dipperDataAsyncTaskService.pullAstEPH();
}

/*
* 获取星历数据
*/
public String getAstEPH() {
return dipperDataAsyncTaskService.getAstEPH();
}


@RequestMapping("/getPos")
public String getPos() {
return "return serverAddr = " + hello;
}

}

+ 23
- 19
src/main/java/com/telpo/dipperposition/handler/NettyServerHandler.java Näytä tiedosto

@@ -2,6 +2,9 @@ package com.telpo.dipperposition.handler;

import com.telpo.dipperposition.config.NettyServerConfig;
import com.telpo.dipperposition.config.PositionConfig;
import com.telpo.dipperposition.controller.DipperAstPosAsyncTaskController;
import com.telpo.dipperposition.controller.DipperAstTimeAsyncTaskController;
import com.telpo.dipperposition.controller.DipperDataAsyncTaskController;
import com.telpo.dipperposition.enums.DipperReturnValue;
import com.telpo.dipperposition.service.IDipperAstPosAsyncTaskService;
import com.telpo.dipperposition.service.IDipperAstTimeAsyncTaskService;
@@ -38,11 +41,11 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter {
private static String AST_EPH_CMD_BYTE = "455048";

@Autowired
private IDipperAstTimeAsyncTaskService dipperTimeAsyncTaskService;
private DipperAstTimeAsyncTaskController dipperTimeAsyncTaskController;
@Autowired
private IDipperAstPosAsyncTaskService dipperAstPosAsyncTaskService;
private DipperAstPosAsyncTaskController dipperAstPosAsyncTaskController;
@Autowired
private IDipperDataAsyncTaskService dipperDataAsyncTaskService;
private DipperDataAsyncTaskController dipperDataAsyncTaskController;

@Autowired
private NettyServerConfig nettyServerConfig;
@@ -114,10 +117,10 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter {
//if (AST_TIME_CMD.equals(recvmg)) {
if (AST_TIME_CMD.equals(msg)) {
// 初始时间辅助输入;
if (dipperTimeAsyncTaskService == null) {
dipperTimeAsyncTaskService = new DipperAstTimeAsyncTaskServiceImpl();
}
channelAns = dipperTimeAsyncTaskService.pushAstTime();
// if (dipperTimeAsyncTaskService == null) {
// dipperTimeAsyncTaskService = new DipperAstTimeAsyncTaskServiceImpl();
// }
channelAns = dipperTimeAsyncTaskController.pushAstTime();
}

// 发送SDBP-AST-POS获取辅助位置信息
@@ -136,24 +139,25 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter {
// positionConfig.getCenterProvince(),
// positionConfig.getIpPositionRequestPath(),
// positionConfig.getIpPositionRequestKey());
if (dipperAstPosAsyncTaskService == null) {
dipperAstPosAsyncTaskService = new DipperAstPosAsyncTaskServiceImpl();
}
channelAns = dipperAstPosAsyncTaskService.pushAstPos(ipAddress,
"/csv/provinceLonAlt.csv",
"湖北省",
"https://restapi.amap.com/v3/ip",
"65e794b0a1a4b87eeec86f93fea05411");
// if (dipperAstPosAsyncTaskService == null) {
// dipperAstPosAsyncTaskService = new DipperAstPosAsyncTaskServiceImpl();
// }
channelAns = dipperAstPosAsyncTaskController.pushAstPos(ipAddress);
// (ipAddress,
// "/csv/provinceLonAlt.csv",
// "湖北省",
// "https://restapi.amap.com/v3/ip",
// "65e794b0a1a4b87eeec86f93fea05411");
}

// 从缓存获取SDBP-AST-EPH星历数
//if (Integer.parseInt(starsAsycServerPort) == channel.localAddress().getPort()) {
//if (AST_POS_CMD.equals(recvmg)) {
if (AST_POS_CMD.equals(msg)) {
if (dipperDataAsyncTaskService == null) {
dipperDataAsyncTaskService = new DipperDataAsyncTaskServiceImpl();
}
channelAns = dipperDataAsyncTaskService.getAstEPH();
// if (dipperDataAsyncTaskService == null) {
// dipperDataAsyncTaskService = new DipperDataAsyncTaskServiceImpl();
// }
channelAns = dipperDataAsyncTaskController.getAstEPH();
}

log.info(channelAns);


+ 7
- 7
src/main/java/com/telpo/dipperposition/service/IDipperAstPosAsyncTaskService.java Näytä tiedosto

@@ -16,16 +16,16 @@ import java.io.UnsupportedEncodingException;
*/
public interface IDipperAstPosAsyncTaskService {

@Autowired
void setDipperAstPosAsyncTaskService(IDipperAstPosAsyncTaskService dipperAstPosAsyncTaskService);
/**
* 同步任务
*
*/
String pushAstPos(String ipAddress,
String centerProvinceFilePath,
String centerProvince,
String ipPositionRequestPath,
String ipPositionRequestKey) throws UnsupportedEncodingException;
String pushAstPos(String ipAddress);

// String pushAstPos(String ipAddress,
// String centerProvinceFilePath,
// String centerProvince,
// String ipPositionRequestPath,
// String ipPositionRequestKey) throws UnsupportedEncodingException;

}

+ 2
- 2
src/main/java/com/telpo/dipperposition/service/IDipperAstTimeAsyncTaskService.java Näytä tiedosto

@@ -11,8 +11,8 @@ import org.springframework.beans.factory.annotation.Autowired;
*/
public interface IDipperAstTimeAsyncTaskService {

@Autowired
void setDipperAstTimeAsyncTaskService(IDipperAstTimeAsyncTaskService dipperAstTimeAsyncTaskService);
// @Autowired
// void setDipperAstTimeAsyncTaskService(IDipperAstTimeAsyncTaskService dipperAstTimeAsyncTaskService);
/**
* 同步任务
*


+ 2
- 2
src/main/java/com/telpo/dipperposition/service/IDipperDataAsyncTaskService.java Näytä tiedosto

@@ -13,8 +13,8 @@ import org.springframework.beans.factory.annotation.Value;
*/
public interface IDipperDataAsyncTaskService {

@Autowired
void setDipperDataAsyncTaskService(IDipperDataAsyncTaskService IDipperDataAsyncTaskService);
// @Autowired
// void setDipperDataAsyncTaskService(IDipperDataAsyncTaskService IDipperDataAsyncTaskService);
/**
* 同步任务
*


+ 2
- 2
src/main/java/com/telpo/dipperposition/service/IpProvinceService.java Näytä tiedosto

@@ -11,8 +11,8 @@ import org.springframework.beans.factory.annotation.Autowired;
*/
public interface IpProvinceService {

@Autowired
void setIPProvinceService(IpProvinceService ipProvinceService);
// @Autowired
// void setIPProvinceService(IpProvinceService ipProvinceService);
/**
* 保存IP省份
*


+ 21
- 14
src/main/java/com/telpo/dipperposition/service/impl/DipperAstPosAsyncTaskServiceImpl.java Näytä tiedosto

@@ -2,6 +2,8 @@ package com.telpo.dipperposition.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.telpo.dipperposition.common.*;
import com.telpo.dipperposition.config.NettyServerConfig;
import com.telpo.dipperposition.config.PositionConfig;
import com.telpo.dipperposition.entity.mongo.IpProvinceEntity;
import com.telpo.dipperposition.service.IDipperAstPosAsyncTaskService;
import com.telpo.dipperposition.service.IpProvinceService;
@@ -33,17 +35,21 @@ public class DipperAstPosAsyncTaskServiceImpl implements IDipperAstPosAsyncTaskS
@Autowired
private OkHttpUtil okHttpUtil;
@Autowired
private NettyServerConfig nettyServerConfig;
@Autowired
private PositionConfig positionConfig;
@Autowired
private IpProvinceService ipProvinceService;

private static IDipperAstPosAsyncTaskService dipperAstPosAsyncTaskService;
// private static IDipperAstPosAsyncTaskService dipperAstPosAsyncTaskService;
/**
* spring会自动从ioc容器当中根据IDipperAstPosAsyncTaskService类型找到dipperAstPosAsyncTaskService,当做参数传进来
*
*/
@Override
public void setDipperAstPosAsyncTaskService(IDipperAstPosAsyncTaskService dipperAstPosAsyncTaskService) {
this.dipperAstPosAsyncTaskService = dipperAstPosAsyncTaskService;
}
// @Override
// public void setDipperAstPosAsyncTaskService(IDipperAstPosAsyncTaskService dipperAstPosAsyncTaskService) {
// this.dipperAstPosAsyncTaskService = dipperAstPosAsyncTaskService;
// }

private String centerProvince;
private String centerProvinceFilePath;
@@ -149,15 +155,16 @@ public class DipperAstPosAsyncTaskServiceImpl implements IDipperAstPosAsyncTaskS
*/
@Override
@Async("asyncServiceExecutor")
public String pushAstPos(String ipAddress,
String centerProvinceFilePath,
String centerProvince,
String ipPositionRequestPath,
String ipPositionRequestKey) throws UnsupportedEncodingException {
this.ipPositionRequestKey = ipPositionRequestKey;
this.ipPositionRequestPath = ipPositionRequestPath;
this.centerProvince = centerProvince;
this.centerProvinceFilePath = centerProvinceFilePath;
// public String pushAstPos(String ipAddress,
// String centerProvinceFilePath,
// String centerProvince,
// String ipPositionRequestPath,
// String ipPositionRequestKey) throws UnsupportedEncodingException {
public String pushAstPos(String ipAddress) {
this.ipPositionRequestKey = positionConfig.getIpPositionRequestKey();
this.ipPositionRequestPath = positionConfig.getIpPositionRequestPath();
this.centerProvince = positionConfig.getCenterProvince();
this.centerProvinceFilePath = positionConfig.getCenterProvinceFilePath();
// (1) 获取省会城市信息
String centerAddress = getIpPositionProvince(ipAddress);
if (ObjectUtils.isEmpty(centerAddress) || centerAddress.equals("0")) {


+ 10
- 10
src/main/java/com/telpo/dipperposition/service/impl/DipperAstTimeAsyncTaskServiceImpl.java Näytä tiedosto

@@ -21,16 +21,16 @@ import java.time.LocalDateTime;
@Service
@Slf4j
public class DipperAstTimeAsyncTaskServiceImpl implements IDipperAstTimeAsyncTaskService {
private static IDipperAstTimeAsyncTaskService dipperAstTimeAsyncTaskService;
/**
* spring会自动从ioc容器当中根据IDipperAstTimeAsyncTaskService类型找到dipperAstTimeAsyncTaskService,当做参数传进来
*
*/
@Override
public void setDipperAstTimeAsyncTaskService(IDipperAstTimeAsyncTaskService dipperAstTimeAsyncTaskService) {
this.dipperAstTimeAsyncTaskService = dipperAstTimeAsyncTaskService;
}
//
// private static IDipperAstTimeAsyncTaskService dipperAstTimeAsyncTaskService;
// /**
// * spring会自动从ioc容器当中根据IDipperAstTimeAsyncTaskService类型找到dipperAstTimeAsyncTaskService,当做参数传进来
// *
// */
// @Override
// public void setDipperAstTimeAsyncTaskService(IDipperAstTimeAsyncTaskService dipperAstTimeAsyncTaskService) {
// this.dipperAstTimeAsyncTaskService = dipperAstTimeAsyncTaskService;
// }

@Override
@Async("asyncServiceExecutor")


+ 11
- 10
src/main/java/com/telpo/dipperposition/service/impl/DipperDataAsyncTaskServiceImpl.java Näytä tiedosto

@@ -31,15 +31,15 @@ public class DipperDataAsyncTaskServiceImpl implements IDipperDataAsyncTaskServi
private SchedulingExecutorConfig schedulingExecutorConfig;


private static IDipperDataAsyncTaskService dipperDataAsyncTaskService;
/**
* spring会自动从ioc容器当中根据IDipperAstTimeAsyncTaskService类型找到dipperDataAsyncTaskService,当做参数传进来
*
*/
@Override
public void setDipperDataAsyncTaskService(IDipperDataAsyncTaskService dipperDataAsyncTaskService) {
this.dipperDataAsyncTaskService = dipperDataAsyncTaskService;
}
// private static IDipperDataAsyncTaskService dipperDataAsyncTaskService;
// /**
// * spring会自动从ioc容器当中根据IDipperAstTimeAsyncTaskService类型找到dipperDataAsyncTaskService,当做参数传进来
// *
// */
// @Override
// public void setDipperDataAsyncTaskService(IDipperDataAsyncTaskService dipperDataAsyncTaskService) {
// this.dipperDataAsyncTaskService = dipperDataAsyncTaskService;
// }

@Override
public void pullAstEPH() {
@@ -51,6 +51,7 @@ public class DipperDataAsyncTaskServiceImpl implements IDipperDataAsyncTaskServi
log.error("获取星历数据错误,取不到星历数据。");
} else {
// 保存到DB或者缓存
log.info("保存到DB或者缓存");
redisUtil.set(DIPPER_DATA_KEY,dipperData);
}
}
@@ -73,7 +74,7 @@ public class DipperDataAsyncTaskServiceImpl implements IDipperDataAsyncTaskServi
}

@Override
@Async("asyncServiceExecutor")
//@Async("asyncServiceExecutor")
public String getAstEPH(){
return (String)redisUtil.get(DIPPER_DATA_KEY);
}


+ 9
- 9
src/main/java/com/telpo/dipperposition/service/impl/IpProvinceServiceImpl.java Näytä tiedosto

@@ -23,15 +23,15 @@ public class IpProvinceServiceImpl implements IpProvinceService {
@Autowired
private IpProvinceMapper ipProvinceMapper;

private static IpProvinceService ipProvinceService;
/**
* spring会自动从ioc容器当中根据IPProvinceService类型找到ipProvinceService,当做参数传进来
*
*/
@Override
public void setIPProvinceService(IpProvinceService ipProvinceService) {
this.ipProvinceService = ipProvinceService;
}
// private static IpProvinceService ipProvinceService;
// /**
// * spring会自动从ioc容器当中根据IPProvinceService类型找到ipProvinceService,当做参数传进来
// *
// */
// @Override
// public void setIPProvinceService(IpProvinceService ipProvinceService) {
// this.ipProvinceService = ipProvinceService;
// }
@Override
public boolean saveIpProvince(IpProvinceEntity entity) {
ipProvinceMapper.saveIp(entity);


Loading…
Peruuta
Tallenna