diff --git a/src/main/java/com/telpo/dipperposition/handler/NettyServerHandler.java b/src/main/java/com/telpo/dipperposition/handler/NettyServerHandler.java index f82c58b..1234f48 100644 --- a/src/main/java/com/telpo/dipperposition/handler/NettyServerHandler.java +++ b/src/main/java/com/telpo/dipperposition/handler/NettyServerHandler.java @@ -123,7 +123,7 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter { // if (Integer.parseInt(posAsycServerPort) == channel.localAddress().getPort()) { //if (AST_POS_CMD.equals(recvmg)) { - if (AST_TIME_CMD.equals(msg)) { + if (AST_POS_CMD.equals(msg)) { // channelAns = dipperAstPosAsyncTaskService.pushAstPos(ipAddress, // positionConfig.getCenterProvinceFilePath(), // positionConfig.getCenterProvince(), diff --git a/src/main/java/com/telpo/dipperposition/mapper/IPProvinceMapper.java b/src/main/java/com/telpo/dipperposition/mapper/IPProvinceMapper.java index b050e1d..a61925c 100644 --- a/src/main/java/com/telpo/dipperposition/mapper/IPProvinceMapper.java +++ b/src/main/java/com/telpo/dipperposition/mapper/IPProvinceMapper.java @@ -21,16 +21,19 @@ public class IPProvinceMapper extends BaseMongoDbDao { return IPProvinceEntity.class; } - @Override @MongoSwitch("common") - public void save(IPProvinceEntity entity, String collectionName) { - super.save(entity, collectionName); + public void saveIp(IPProvinceEntity entity) { + this.save(entity); + } + + @MongoSwitch("common") + public void saveIp(IPProvinceEntity entity, String collectionName) { + this.save(entity, collectionName); } - @Override @MongoSwitch("common") - public void updateFirst(IPProvinceEntity srcObj, IPProvinceEntity targetObj) { - super.updateFirst(srcObj, targetObj); + public void updateIpFirst(IPProvinceEntity srcObj, IPProvinceEntity targetObj) { + this.updateFirst(srcObj, targetObj); } @Override @@ -38,21 +41,18 @@ public class IPProvinceMapper extends BaseMongoDbDao { return super.getPage(object, start, size); } - @Override @MongoSwitch("common") - public List queryList(IPProvinceEntity object) { - return super.queryList(object); + public List queryIpList(IPProvinceEntity object) { + return this.queryList(object); } - @Override @MongoSwitch("common") - public List queryList(IPProvinceEntity object, String collectionName) { - return super.queryList(object, collectionName); + public List queryIpList(IPProvinceEntity object, String collectionName) { + return this.queryList(object, collectionName); } - @Override @MongoSwitch("common") - public void deleteById(String id) { - super.deleteById(id); + public void deleteIpById(String id) { + this.deleteById(id); } } diff --git a/src/main/java/com/telpo/dipperposition/service/IPProvinceService.java b/src/main/java/com/telpo/dipperposition/service/IPProvinceService.java index f8e3c66..de80294 100644 --- a/src/main/java/com/telpo/dipperposition/service/IPProvinceService.java +++ b/src/main/java/com/telpo/dipperposition/service/IPProvinceService.java @@ -17,7 +17,7 @@ public interface IPProvinceService { * @param entity * @return */ - boolean saveIPProvince(IPProvinceEntity entity); + boolean saveIpProvince(IPProvinceEntity entity); /** * 更新IP省份 @@ -41,5 +41,5 @@ public interface IPProvinceService { * @param ipAddress * 获取IP省份 */ - IPProvinceEntity getIPProvince(String ipAddress); + IPProvinceEntity getIpProvince(String ipAddress); } 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 9ba510e..892988c 100644 --- a/src/main/java/com/telpo/dipperposition/service/impl/DipperAstPosAsyncTaskServiceImpl.java +++ b/src/main/java/com/telpo/dipperposition/service/impl/DipperAstPosAsyncTaskServiceImpl.java @@ -98,7 +98,7 @@ public class DipperAstPosAsyncTaskServiceImpl implements IDipperAstPosAsyncTaskS if(iPProvinceService == null) { iPProvinceService = new IPProvinceServiceImpl(); } - IPProvinceEntity ipProvinceEntity = iPProvinceService.getIPProvince(ipAddress); + IPProvinceEntity ipProvinceEntity = iPProvinceService.getIpProvince(ipAddress); if (ipProvinceEntity == null) { // 匹配不到,再请求高德IP定位服务。 JSONObject userObj = new JSONObject(); @@ -131,12 +131,12 @@ public class DipperAstPosAsyncTaskServiceImpl implements IDipperAstPosAsyncTaskS if(iPProvinceService == null) { iPProvinceService = new IPProvinceServiceImpl(); } - IPProvinceEntity ipProvinceEntity = iPProvinceService.getIPProvince(ipAddress); + 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); + iPProvinceService.saveIpProvince(ipProvinceEntity); // } else { // // ipProvinceEntity.setProvince(province); 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 aec944e..9515fd2 100644 --- a/src/main/java/com/telpo/dipperposition/service/impl/DipperDataAsyncTaskServiceImpl.java +++ b/src/main/java/com/telpo/dipperposition/service/impl/DipperDataAsyncTaskServiceImpl.java @@ -39,6 +39,9 @@ public class DipperDataAsyncTaskServiceImpl implements IDipperDataAsyncTaskServi log.error("获取星历数据错误,取不到星历数据。"); } else { // 保存到DB或者缓存 + if (redisUtil == null) { + redisUtil = new RedisUtil(); + } redisUtil.set(DIPPER_DATA_KEY,dipperData); } } @@ -63,6 +66,9 @@ public class DipperDataAsyncTaskServiceImpl implements IDipperDataAsyncTaskServi @Override @Async("asyncServiceExecutor") public String getAstEPH(){ + if (redisUtil == null) { + redisUtil = new RedisUtil(); + } return (String)redisUtil.get(DIPPER_DATA_KEY); } } diff --git a/src/main/java/com/telpo/dipperposition/service/impl/IPProvinceServiceImpl.java b/src/main/java/com/telpo/dipperposition/service/impl/IPProvinceServiceImpl.java index 61282e7..de38265 100644 --- a/src/main/java/com/telpo/dipperposition/service/impl/IPProvinceServiceImpl.java +++ b/src/main/java/com/telpo/dipperposition/service/impl/IPProvinceServiceImpl.java @@ -25,11 +25,11 @@ public class IPProvinceServiceImpl implements IPProvinceService { private IPProvinceMapper iPProvinceMapper; @Override - public boolean saveIPProvince(IPProvinceEntity entity) { + public boolean saveIpProvince(IPProvinceEntity entity) { if (iPProvinceMapper == null) { iPProvinceMapper = new IPProvinceMapper(); } - iPProvinceMapper.save(entity); + iPProvinceMapper.saveIp(entity); return true; } @@ -39,7 +39,7 @@ public class IPProvinceServiceImpl implements IPProvinceService { if (iPProvinceMapper == null) { iPProvinceMapper = new IPProvinceMapper(); } - iPProvinceMapper.updateFirst(query, update); + iPProvinceMapper.updateIpFirst(query, update); return true; } @@ -48,19 +48,19 @@ public class IPProvinceServiceImpl implements IPProvinceService { if (iPProvinceMapper == null) { iPProvinceMapper = new IPProvinceMapper(); } - iPProvinceMapper.deleteById(id); + iPProvinceMapper.deleteIpById(id); return false; } @Override - public IPProvinceEntity getIPProvince(String ipAddress) { + public IPProvinceEntity getIpProvince(String ipAddress) { try { IPProvinceEntity query = new IPProvinceEntity(); query.setIp(ipAddress); if (iPProvinceMapper == null) { iPProvinceMapper = new IPProvinceMapper(); } - List pushRecords = iPProvinceMapper.queryList(query); + List pushRecords = iPProvinceMapper.queryIpList(query); if (ObjectUtils.isNotEmpty(pushRecords)) { return pushRecords.get(0); } else {