From dfa5a59a434b7598a4b8b956405d46b94e0b91cb Mon Sep 17 00:00:00 2001 From: linwl <304115325@qq.com> Date: Tue, 19 Jan 2021 10:47:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=B0docker=E5=A4=96?= =?UTF-8?q?=E8=BF=90=E8=A1=8C=E7=8E=AF=E5=A2=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dipperposition/common/RedisUtil.java | 10 ++-- .../DipperAstPosAsyncTaskServiceImpl.java | 49 ------------------- .../impl/DipperDataAsyncTaskServiceImpl.java | 12 +---- 3 files changed, 6 insertions(+), 65 deletions(-) diff --git a/src/main/java/com/telpo/dipperposition/common/RedisUtil.java b/src/main/java/com/telpo/dipperposition/common/RedisUtil.java index 33b262a..f1e85eb 100644 --- a/src/main/java/com/telpo/dipperposition/common/RedisUtil.java +++ b/src/main/java/com/telpo/dipperposition/common/RedisUtil.java @@ -25,11 +25,11 @@ public class RedisUtil { @Resource private RedisTemplate redisTemplate; - public static RedisUtil redisUtil; - @PostConstruct - public void init() { - redisUtil = this; - } +// public static RedisUtil redisUtil; +// @PostConstruct +// public void init() { +// redisUtil = this; +// } // =============================common============================ /** * 指定缓存失效时间 diff --git a/src/main/java/com/telpo/dipperposition/service/impl/DipperAstPosAsyncTaskServiceImpl.java b/src/main/java/com/telpo/dipperposition/service/impl/DipperAstPosAsyncTaskServiceImpl.java index b2e42d8..726a305 100644 --- a/src/main/java/com/telpo/dipperposition/service/impl/DipperAstPosAsyncTaskServiceImpl.java +++ b/src/main/java/com/telpo/dipperposition/service/impl/DipperAstPosAsyncTaskServiceImpl.java @@ -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(); diff --git a/src/main/java/com/telpo/dipperposition/service/impl/DipperDataAsyncTaskServiceImpl.java b/src/main/java/com/telpo/dipperposition/service/impl/DipperDataAsyncTaskServiceImpl.java index 5ccce12..dee9a3e 100644 --- a/src/main/java/com/telpo/dipperposition/service/impl/DipperDataAsyncTaskServiceImpl.java +++ b/src/main/java/com/telpo/dipperposition/service/impl/DipperDataAsyncTaskServiceImpl.java @@ -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); }