Parcourir la source

修改到docker外运行环境

tags/v1.0.0^2
林万龙 il y a 3 ans
Parent
révision
dfa5a59a43
3 fichiers modifiés avec 6 ajouts et 65 suppressions
  1. +5
    -5
      src/main/java/com/telpo/dipperposition/common/RedisUtil.java
  2. +0
    -49
      src/main/java/com/telpo/dipperposition/service/impl/DipperAstPosAsyncTaskServiceImpl.java
  3. +1
    -11
      src/main/java/com/telpo/dipperposition/service/impl/DipperDataAsyncTaskServiceImpl.java

+ 5
- 5
src/main/java/com/telpo/dipperposition/common/RedisUtil.java Voir le fichier

@@ -25,11 +25,11 @@ public class RedisUtil {

@Resource private RedisTemplate<String, Object> redisTemplate;

public static RedisUtil redisUtil;
@PostConstruct
public void init() {
redisUtil = this;
}
// public static RedisUtil redisUtil;
// @PostConstruct
// public void init() {
// redisUtil = this;
// }
// =============================common============================
/**
* 指定缓存失效时间


+ 0
- 49
src/main/java/com/telpo/dipperposition/service/impl/DipperAstPosAsyncTaskServiceImpl.java Voir le fichier

@@ -35,50 +35,14 @@ 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;
/**
* spring会自动从ioc容器当中根据IDipperAstPosAsyncTaskService类型找到dipperAstPosAsyncTaskService,当做参数传进来
*
*/
// @Override
// public void setDipperAstPosAsyncTaskService(IDipperAstPosAsyncTaskService dipperAstPosAsyncTaskService) {
// this.dipperAstPosAsyncTaskService = dipperAstPosAsyncTaskService;
// }

private String centerProvince;
private String centerProvinceFilePath;
private String ipPositionRequestPath;
private String ipPositionRequestKey;
// private String getAstPos(String ipAddress) throws UnsupportedEncodingException {
//
// String centerAddress = getIpPositionProvince(ipAddress);
// if (ObjectUtils.isEmpty(centerAddress) || centerAddress.equals("0")) {
// log.warn("IP地址非法,无法获取辅助位置信息!");
// // 返回武汉的定位数据
// centerAddress = centerProvince;
// } else {
// // 保存到mongoDB
// createIPProvince(ipAddress, centerAddress);
// }
//
// String lonAndAlt;
// if (redisUtil.hasKey(centerAddress)) {
// // 获取省会城市定位信息
// lonAndAlt= (String) redisUtil.get(centerAddress);
// } else {
// // 请求高德IP定位服务
// this.getPosFromFile(centerAddress);
// lonAndAlt = (String) redisUtil.get(centerAddress);
// }
//
// return lonAndAlt;
// }

// 从CSV文件读取省会城市中心点位置信息
private void getPosFromFile(String centerAddress) {
@@ -135,14 +99,9 @@ public class DipperAstPosAsyncTaskServiceImpl implements IDipperAstPosAsyncTaskS
try {
IpProvinceEntity ipProvinceEntity = ipProvinceService.getIpProvince(ipAddress);
if (ipProvinceEntity == null) {
//DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
ipProvinceEntity.setIp(ipAddress);
ipProvinceEntity.setProvince(province);
ipProvinceService.saveIpProvince(ipProvinceEntity);
// } else {
//
// ipProvinceEntity.setProvince(province);
// iPProvinceService.updateIPProvince(ipProvinceEntity, ipProvinceEntity);
}
} catch (Exception e) {
log.error("创建推送失败记录异常:", e);
@@ -155,11 +114,6 @@ public class DipperAstPosAsyncTaskServiceImpl implements IDipperAstPosAsyncTaskS
*/
@Override
@Async("asyncServiceExecutor")
// 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();
@@ -202,9 +156,6 @@ public class DipperAstPosAsyncTaskServiceImpl implements IDipperAstPosAsyncTaskS
// 组装命令发送给设备
private String getCmdOfPos(String astPos) {

// 创建Socket客户端实例;
// SocketClient client = new SocketClient(astServer, posAstPort, astTimeout);

// 时间和位置不是从服务器获取,而是本地生成
String[] astPosArray = astPos.split(",");
String lan = astPosArray[0].trim();


+ 1
- 11
src/main/java/com/telpo/dipperposition/service/impl/DipperDataAsyncTaskServiceImpl.java Voir le fichier

@@ -4,7 +4,6 @@ import com.telpo.dipperposition.common.HexConvert;
import com.telpo.dipperposition.common.RedisUtil;
import com.telpo.dipperposition.common.SocketClient;
import com.telpo.dipperposition.config.SchedulingExecutorConfig;
import com.telpo.dipperposition.service.IDipperAstTimeAsyncTaskService;
import com.telpo.dipperposition.service.IDipperDataAsyncTaskService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@@ -31,15 +30,6 @@ 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;
// }

@Override
public void pullAstEPH() {
@@ -74,7 +64,7 @@ public class DipperDataAsyncTaskServiceImpl implements IDipperDataAsyncTaskServi
}

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


Chargement…
Annuler
Enregistrer