|
|
@@ -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(); |
|
|
|