Browse Source

修改到docker外运行环境

tags/v1.0.0^2
林万龙 4 years ago
parent
commit
196e1aa05a
9 changed files with 114 additions and 4 deletions
  1. +13
    -3
      src/main/java/com/telpo/dipperposition/common/OkHttpUtil.java
  2. +10
    -0
      src/main/java/com/telpo/dipperposition/common/RedisUtil.java
  3. +12
    -0
      src/main/java/com/telpo/dipperposition/config/NettyServerConfig.java
  4. +12
    -0
      src/main/java/com/telpo/dipperposition/config/PositionConfig.java
  5. +13
    -0
      src/main/java/com/telpo/dipperposition/mapper/IPProvinceMapper.java
  6. +19
    -1
      src/main/java/com/telpo/dipperposition/service/impl/DipperAstPosAsyncTaskServiceImpl.java
  7. +13
    -0
      src/main/java/com/telpo/dipperposition/service/impl/DipperAstTimeAsyncTaskServiceImpl.java
  8. +12
    -0
      src/main/java/com/telpo/dipperposition/service/impl/DipperDataAsyncTaskServiceImpl.java
  9. +10
    -0
      src/main/java/com/telpo/dipperposition/service/impl/IPProvinceServiceImpl.java

+ 13
- 3
src/main/java/com/telpo/dipperposition/common/OkHttpUtil.java View File

@@ -25,12 +25,22 @@ public class OkHttpUtil {


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


private static OkHttpUtil okHttpUtil;
/** /**
* 根据map获取get请求参数
* spring会自动从ioc容器当中根据OkHttpUtil类型找到okHttpUtil,当做参数传进来
* *
* @param queries
* @return
*/ */
@Autowired
public void setOkHttpUtil(OkHttpUtil okHttpUtil) {
this.okHttpUtil = okHttpUtil;
}

/**
* 根据map获取get请求参数
*
* @param queries
* @return
*/
public StringBuffer getQueryString(String url, Map<String, String> queries) { public StringBuffer getQueryString(String url, Map<String, String> queries) {
StringBuffer sb = new StringBuffer(url); StringBuffer sb = new StringBuffer(url);
if (queries != null && queries.keySet().size() > 0) { if (queries != null && queries.keySet().size() > 0) {


+ 10
- 0
src/main/java/com/telpo/dipperposition/common/RedisUtil.java View File

@@ -1,6 +1,7 @@
package com.telpo.dipperposition.common; package com.telpo.dipperposition.common;


import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
@@ -23,6 +24,15 @@ public class RedisUtil {


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


private static RedisUtil redisUtil;
/**
* spring会自动从ioc容器当中根据RedisUtil类型找到redisUtil,当做参数传进来
*
*/
@Autowired
public void setRedisUtil(RedisUtil redisUtil) {
this.redisUtil = redisUtil;
}
// =============================common============================ // =============================common============================
/** /**
* 指定缓存失效时间 * 指定缓存失效时间


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

@@ -2,8 +2,10 @@ package com.telpo.dipperposition.config;


import com.alibaba.nacos.api.config.annotation.NacosValue; import com.alibaba.nacos.api.config.annotation.NacosValue;
import com.alibaba.nacos.spring.context.annotation.config.NacosPropertySource; import com.alibaba.nacos.spring.context.annotation.config.NacosPropertySource;
import com.telpo.dipperposition.common.OkHttpUtil;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;


/** /**
@@ -30,4 +32,14 @@ public class NettyServerConfig {
@NacosValue(value = "${position-server.starsAsycPort}") @NacosValue(value = "${position-server.starsAsycPort}")
private String starsAsycServerPort; private String starsAsycServerPort;


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

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

@@ -4,6 +4,7 @@ import com.alibaba.nacos.api.config.annotation.NacosValue;
import com.alibaba.nacos.spring.context.annotation.config.NacosPropertySource; import com.alibaba.nacos.spring.context.annotation.config.NacosPropertySource;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;


/** /**
@@ -35,4 +36,15 @@ public class PositionConfig {
int posAstPort; int posAstPort;
@NacosValue("${pos.astTimeout}") @NacosValue("${pos.astTimeout}")
int astTimeout; int astTimeout;


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

+ 13
- 0
src/main/java/com/telpo/dipperposition/mapper/IPProvinceMapper.java View File

@@ -1,8 +1,10 @@
package com.telpo.dipperposition.mapper; package com.telpo.dipperposition.mapper;


import com.telpo.dipperposition.annotation.MongoSwitch; import com.telpo.dipperposition.annotation.MongoSwitch;
import com.telpo.dipperposition.config.NettyServerConfig;
import com.telpo.dipperposition.entity.mongo.IPProvinceEntity; import com.telpo.dipperposition.entity.mongo.IPProvinceEntity;
import db.BaseMongoDbDao; import db.BaseMongoDbDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;


import java.util.List; import java.util.List;
@@ -16,6 +18,17 @@ import java.util.List;
@Repository @Repository
public class IPProvinceMapper extends BaseMongoDbDao<IPProvinceEntity> { public class IPProvinceMapper extends BaseMongoDbDao<IPProvinceEntity> {


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

@Override @Override
protected Class<IPProvinceEntity> getEntityClass() { protected Class<IPProvinceEntity> getEntityClass() {
return IPProvinceEntity.class; return IPProvinceEntity.class;


+ 19
- 1
src/main/java/com/telpo/dipperposition/service/impl/DipperAstPosAsyncTaskServiceImpl.java View File

@@ -42,6 +42,16 @@ public class DipperAstPosAsyncTaskServiceImpl implements IDipperAstPosAsyncTaskS
@Autowired @Autowired
private IPProvinceService iPProvinceService; private IPProvinceService iPProvinceService;


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

private String centerProvince; private String centerProvince;
private String centerProvinceFilePath; private String centerProvinceFilePath;
private String ipPositionRequestPath; private String ipPositionRequestPath;
@@ -84,6 +94,9 @@ public class DipperAstPosAsyncTaskServiceImpl implements IDipperAstPosAsyncTaskS
} else { } else {
centerProvinceName = centerAddressSetArray[3]; centerProvinceName = centerAddressSetArray[3];
centerProvinceLonAndAlt = centerAddressSetArray[1]+","+centerAddressSetArray[2]; centerProvinceLonAndAlt = centerAddressSetArray[1]+","+centerAddressSetArray[2];
if (redisUtil == null) {
redisUtil = new RedisUtil();
}
redisUtil.set(centerProvinceName, centerProvinceLonAndAlt, 0); redisUtil.set(centerProvinceName, centerProvinceLonAndAlt, 0);
} }
} }
@@ -104,7 +117,9 @@ public class DipperAstPosAsyncTaskServiceImpl implements IDipperAstPosAsyncTaskS
JSONObject userObj = new JSONObject(); JSONObject userObj = new JSONObject();
userObj.put("ip", ipAddress); userObj.put("ip", ipAddress);
userObj.put("key", ipPositionRequestKey); userObj.put("key", ipPositionRequestKey);

if (okHttpUtil == null) {
okHttpUtil = new OkHttpUtil();
}
JSONObject json = okHttpUtil.postRequestWithJson(ipPositionRequestPath, null, userObj); JSONObject json = okHttpUtil.postRequestWithJson(ipPositionRequestPath, null, userObj);
if (ObjectUtils.isNotEmpty(json)) { if (ObjectUtils.isNotEmpty(json)) {
String province = (String) json.get("province"); String province = (String) json.get("province");
@@ -174,6 +189,9 @@ public class DipperAstPosAsyncTaskServiceImpl implements IDipperAstPosAsyncTaskS
} }


String lonAndAlt; String lonAndAlt;
if (redisUtil == null) {
redisUtil = new RedisUtil();
}
if (redisUtil.hasKey(centerAddress)) { if (redisUtil.hasKey(centerAddress)) {
// 获取省会城市定位信息 // 获取省会城市定位信息
lonAndAlt= (String) redisUtil.get(centerAddress); lonAndAlt= (String) redisUtil.get(centerAddress);


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

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


import com.telpo.dipperposition.common.HexConvert; import com.telpo.dipperposition.common.HexConvert;
import com.telpo.dipperposition.common.SocketClient; import com.telpo.dipperposition.common.SocketClient;
import com.telpo.dipperposition.service.IDipperAstPosAsyncTaskService;
import com.telpo.dipperposition.service.IDipperAstTimeAsyncTaskService; import com.telpo.dipperposition.service.IDipperAstTimeAsyncTaskService;
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.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@@ -20,6 +22,17 @@ import java.time.LocalDateTime;
@Slf4j @Slf4j
public class DipperAstTimeAsyncTaskServiceImpl implements IDipperAstTimeAsyncTaskService { public class DipperAstTimeAsyncTaskServiceImpl implements IDipperAstTimeAsyncTaskService {



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

@Override @Override
@Async("asyncServiceExecutor") @Async("asyncServiceExecutor")
public String pushAstTime() { public String pushAstTime() {


+ 12
- 0
src/main/java/com/telpo/dipperposition/service/impl/DipperDataAsyncTaskServiceImpl.java View File

@@ -4,6 +4,7 @@ import com.telpo.dipperposition.common.HexConvert;
import com.telpo.dipperposition.common.RedisUtil; import com.telpo.dipperposition.common.RedisUtil;
import com.telpo.dipperposition.common.SocketClient; import com.telpo.dipperposition.common.SocketClient;
import com.telpo.dipperposition.config.SchedulingExecutorConfig; import com.telpo.dipperposition.config.SchedulingExecutorConfig;
import com.telpo.dipperposition.service.IDipperAstPosAsyncTaskService;
import com.telpo.dipperposition.service.IDipperDataAsyncTaskService; 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.Autowired;
@@ -29,6 +30,17 @@ public class DipperDataAsyncTaskServiceImpl implements IDipperDataAsyncTaskServi
@Autowired @Autowired
private SchedulingExecutorConfig schedulingExecutorConfig; private SchedulingExecutorConfig schedulingExecutorConfig;



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

@Override @Override
public void pullAstEPH() { public void pullAstEPH() {
// (1) 发送bds获取星历数据 // (1) 发送bds获取星历数据


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

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


import com.telpo.dipperposition.entity.mongo.IPProvinceEntity; import com.telpo.dipperposition.entity.mongo.IPProvinceEntity;
import com.telpo.dipperposition.mapper.IPProvinceMapper; import com.telpo.dipperposition.mapper.IPProvinceMapper;
import com.telpo.dipperposition.service.IDipperDataAsyncTaskService;
import com.telpo.dipperposition.service.IPProvinceService; import com.telpo.dipperposition.service.IPProvinceService;
import com.telpo.dipperposition.vo.IPProvinceVo; import com.telpo.dipperposition.vo.IPProvinceVo;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@@ -24,6 +25,15 @@ public class IPProvinceServiceImpl implements IPProvinceService {
@Autowired @Autowired
private IPProvinceMapper iPProvinceMapper; private IPProvinceMapper iPProvinceMapper;


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


Loading…
Cancel
Save