Browse Source

修改到docker外运行环境

tags/v1.0.0^2
林万龙 3 years ago
parent
commit
1ccd98eb1f
16 changed files with 175 additions and 85 deletions
  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 View File

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


@Autowired private OkHttpClient okHttpClient; @Autowired private OkHttpClient okHttpClient;


private static OkHttpUtil okHttpUtil;
public static OkHttpUtil okHttpUtil;


@PostConstruct @PostConstruct
public void init() { public void init() {


+ 1
- 6
src/main/java/com/telpo/dipperposition/common/RedisUtil.java View File

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


@Resource private RedisTemplate<String, Object> redisTemplate; @Resource private RedisTemplate<String, Object> redisTemplate;


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

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


+ 1
- 1
src/main/java/com/telpo/dipperposition/config/NettyServerConfig.java View File

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


private static NettyServerConfig nettyServerConfig;
public static NettyServerConfig nettyServerConfig;


@PostConstruct @PostConstruct
public void init() { public void init() {


+ 1
- 1
src/main/java/com/telpo/dipperposition/config/PositionConfig.java View File

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




private static PositionConfig positionConfig;
public static PositionConfig positionConfig;


@PostConstruct @PostConstruct
public void init() { public void init() {


+ 30
- 0
src/main/java/com/telpo/dipperposition/controller/DipperAstPosAsyncTaskController.java View File

@@ -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 View File

@@ -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 View File

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


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


@Autowired
IDipperDataAsyncTaskService dipperDataAsyncTaskService;

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

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


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

} }

+ 23
- 19
src/main/java/com/telpo/dipperposition/handler/NettyServerHandler.java View File

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


import com.telpo.dipperposition.config.NettyServerConfig; import com.telpo.dipperposition.config.NettyServerConfig;
import com.telpo.dipperposition.config.PositionConfig; 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.enums.DipperReturnValue;
import com.telpo.dipperposition.service.IDipperAstPosAsyncTaskService; import com.telpo.dipperposition.service.IDipperAstPosAsyncTaskService;
import com.telpo.dipperposition.service.IDipperAstTimeAsyncTaskService; import com.telpo.dipperposition.service.IDipperAstTimeAsyncTaskService;
@@ -38,11 +41,11 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter {
private static String AST_EPH_CMD_BYTE = "455048"; private static String AST_EPH_CMD_BYTE = "455048";


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


@Autowired @Autowired
private NettyServerConfig nettyServerConfig; private NettyServerConfig nettyServerConfig;
@@ -114,10 +117,10 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter {
//if (AST_TIME_CMD.equals(recvmg)) { //if (AST_TIME_CMD.equals(recvmg)) {
if (AST_TIME_CMD.equals(msg)) { 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获取辅助位置信息 // 发送SDBP-AST-POS获取辅助位置信息
@@ -136,24 +139,25 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter {
// positionConfig.getCenterProvince(), // positionConfig.getCenterProvince(),
// positionConfig.getIpPositionRequestPath(), // positionConfig.getIpPositionRequestPath(),
// positionConfig.getIpPositionRequestKey()); // 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星历数 // 从缓存获取SDBP-AST-EPH星历数
//if (Integer.parseInt(starsAsycServerPort) == channel.localAddress().getPort()) { //if (Integer.parseInt(starsAsycServerPort) == channel.localAddress().getPort()) {
//if (AST_POS_CMD.equals(recvmg)) { //if (AST_POS_CMD.equals(recvmg)) {
if (AST_POS_CMD.equals(msg)) { 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); log.info(channelAns);


+ 7
- 7
src/main/java/com/telpo/dipperposition/service/IDipperAstPosAsyncTaskService.java View File

@@ -16,16 +16,16 @@ import java.io.UnsupportedEncodingException;
*/ */
public interface IDipperAstPosAsyncTaskService { 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 View File

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


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


+ 2
- 2
src/main/java/com/telpo/dipperposition/service/IDipperDataAsyncTaskService.java View File

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


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


+ 2
- 2
src/main/java/com/telpo/dipperposition/service/IpProvinceService.java View File

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


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


+ 21
- 14
src/main/java/com/telpo/dipperposition/service/impl/DipperAstPosAsyncTaskServiceImpl.java View File

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


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


private static IDipperAstPosAsyncTaskService dipperAstPosAsyncTaskService;
// private static IDipperAstPosAsyncTaskService dipperAstPosAsyncTaskService;
/** /**
* spring会自动从ioc容器当中根据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 centerProvince;
private String centerProvinceFilePath; private String centerProvinceFilePath;
@@ -149,15 +155,16 @@ public class DipperAstPosAsyncTaskServiceImpl implements IDipperAstPosAsyncTaskS
*/ */
@Override @Override
@Async("asyncServiceExecutor") @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) 获取省会城市信息 // (1) 获取省会城市信息
String centerAddress = getIpPositionProvince(ipAddress); String centerAddress = getIpPositionProvince(ipAddress);
if (ObjectUtils.isEmpty(centerAddress) || centerAddress.equals("0")) { if (ObjectUtils.isEmpty(centerAddress) || centerAddress.equals("0")) {


+ 10
- 10
src/main/java/com/telpo/dipperposition/service/impl/DipperAstTimeAsyncTaskServiceImpl.java View File

@@ -21,16 +21,16 @@ import java.time.LocalDateTime;
@Service @Service
@Slf4j @Slf4j
public class DipperAstTimeAsyncTaskServiceImpl implements IDipperAstTimeAsyncTaskService { 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 @Override
@Async("asyncServiceExecutor") @Async("asyncServiceExecutor")


+ 11
- 10
src/main/java/com/telpo/dipperposition/service/impl/DipperDataAsyncTaskServiceImpl.java View File

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


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


+ 9
- 9
src/main/java/com/telpo/dipperposition/service/impl/IpProvinceServiceImpl.java View File

@@ -23,15 +23,15 @@ public class IpProvinceServiceImpl implements IpProvinceService {
@Autowired @Autowired
private IpProvinceMapper ipProvinceMapper; 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 @Override
public boolean saveIpProvince(IpProvinceEntity entity) { public boolean saveIpProvince(IpProvinceEntity entity) {
ipProvinceMapper.saveIp(entity); ipProvinceMapper.saveIp(entity);


Loading…
Cancel
Save