|
|
@@ -33,16 +33,16 @@ import java.util.Map;
|
|
|
*/
|
|
|
@Service
|
|
|
@Slf4j
|
|
|
-public class AiwenIpService implements BizHandler<AiwenParam,AiwenParseIpInfoVO>{
|
|
|
+public class AiwenIpService implements BizHandler<AiwenParam,JSONObject>{
|
|
|
|
|
|
@Autowired
|
|
|
private RedisService redisService;
|
|
|
|
|
|
@Autowired
|
|
|
private AiwenAlertConfig aiwenAlertConfig;
|
|
|
-
|
|
|
private Long callExceptionCount=0L;
|
|
|
|
|
|
+
|
|
|
@Autowired
|
|
|
private FeishuMsgSendService feishuMsgSendService;
|
|
|
@Autowired
|
|
|
@@ -67,7 +67,7 @@ public class AiwenIpService implements BizHandler<AiwenParam,AiwenParseIpInfoVO>
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public AiwenParseIpInfoVO handle(AiwenParam aiwenIpParam, IpInterfacePO ipInterfacePO, ApiLogDto logDto) {
|
|
|
+ public JSONObject handle(AiwenParam aiwenIpParam, IpInterfacePO ipInterfacePO, ApiLogDto logDto) {
|
|
|
{
|
|
|
String interfaceConfig = ipInterfacePO.getInterfaceConfig();
|
|
|
AiwenDto aiwenDto = JSON.parseObject(interfaceConfig, AiwenDto.class);
|
|
|
@@ -109,6 +109,7 @@ public class AiwenIpService implements BizHandler<AiwenParam,AiwenParseIpInfoVO>
|
|
|
String yesterday=getYesterday();
|
|
|
String yesternetkey=AiwenCallRedisKeyNetWork+":"+yesterday;
|
|
|
String curnetkey=AiwenCallRedisKeyNetWork+":"+curday;
|
|
|
+ JSONObject ipParseJson = new JSONObject();
|
|
|
try {
|
|
|
|
|
|
ValueOperations<String, Object> valueOps = redisService.redisTemplate.opsForValue();
|
|
|
@@ -171,33 +172,10 @@ public class AiwenIpService implements BizHandler<AiwenParam,AiwenParseIpInfoVO>
|
|
|
// 调用接口解析ip地址信息
|
|
|
String response = HttpClientUtils.get(url, new HashMap());
|
|
|
logDto.setResponseParam(response);
|
|
|
- JSONObject ipParseJson = JSONObject.parseObject(response);
|
|
|
+ ipParseJson = JSONObject.parseObject(response);
|
|
|
logDto.setHttpStatus(ipParseJson.getString("code"));
|
|
|
// 解析ip地址解析后的数据
|
|
|
- if ("Success".equals(ipParseJson.getString("code"))) {
|
|
|
- JSONObject data = ipParseJson.getJSONObject("data");
|
|
|
-
|
|
|
- String province = data.getString("prov");
|
|
|
- String city = data.getString("city");
|
|
|
- if (province != null) {
|
|
|
- ipInfoDTO.setProvince(province.replace("省",""));
|
|
|
- }
|
|
|
- if(city != null){
|
|
|
- ipInfoDTO.setCity(city);
|
|
|
- } else {
|
|
|
- // city字段为空时, 默认采用省份填充
|
|
|
- ipInfoDTO.setCity(province);
|
|
|
- }
|
|
|
-
|
|
|
- ipInfoDTO.setCountry(data.getString("country"));
|
|
|
- ipInfoDTO.setIp(ipParseJson.getString("ip"));
|
|
|
- ipInfoDTO.setSub(data.getString("isp"));
|
|
|
- ipInfoDTO.setInfo("");
|
|
|
- ipInfoDTO.setCityCode(data.getString("adcode"));
|
|
|
- ipInfoDTO.setLat(data.getString("lat"));
|
|
|
- ipInfoDTO.setLng(data.getString("lng"));
|
|
|
- log.info("埃文科技解析isp:{}", ipInfoDTO.getSub());
|
|
|
- }else{
|
|
|
+ if (!"Success".equals(ipParseJson.getString("code"))) {
|
|
|
if ("DailyLimited".equals(ipParseJson.getString("code")) ){
|
|
|
log.error("埃文科技解析ip调用超量了");
|
|
|
logDto.setErrorMessage("埃文科技解析ip调用超量了");
|
|
|
@@ -207,8 +185,9 @@ public class AiwenIpService implements BizHandler<AiwenParam,AiwenParseIpInfoVO>
|
|
|
feishuMsgSendService.dealFeishuMsgSendIpGroup("[异常]" + curday + ",埃文IP调用返回值为已超量,现已达到了redis值["+count.toString()+"]次,"+formattedTime);
|
|
|
}
|
|
|
}
|
|
|
+ }else{
|
|
|
+ logDto.setErrorMessage(ipParseJson.getString("code"));
|
|
|
}
|
|
|
- log.error("埃文ip地址请求失败:{},接口返回数据格式不正确", aiwenIpParam.getIp());
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
log.error("埃文ip地址解析异常, {},{}", aiwenIpParam.getIp(),e.getMessage());
|
|
|
@@ -220,7 +199,7 @@ public class AiwenIpService implements BizHandler<AiwenParam,AiwenParseIpInfoVO>
|
|
|
callExceptionCount++;
|
|
|
}
|
|
|
|
|
|
- return ipInfoDTO;
|
|
|
+ return ipParseJson;
|
|
|
}
|
|
|
}
|
|
|
|