|
@@ -2,6 +2,7 @@ package com.caimei365.tools.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.caimei365.tools.mapper.CmBehaviorRecordMapper;
|
|
|
+import com.caimei365.tools.model.po.AddressPo;
|
|
|
import com.caimei365.tools.model.po.CmBehaviorRecordPo;
|
|
|
import com.caimei365.tools.model.po.CmUserPo;
|
|
|
import com.caimei365.tools.model.po.IpSavePo;
|
|
@@ -368,7 +369,7 @@ public class CmBehaviorRecordServiceImpl implements CmBehaviorRecordService {
|
|
|
int num = 0;
|
|
|
for (CmBehaviorRecordPo recordPo : selDataList) {
|
|
|
if (recordPo.getIP().equals(data.getIP()) && recordPo.getUserId().equals(data.getUserId())) {
|
|
|
- if (num < 5) {
|
|
|
+ if (num < 10) {
|
|
|
if (!item.contains(recordPo.getPageLabel())) {
|
|
|
item.add(recordPo.getPageLabel());
|
|
|
num++;
|
|
@@ -413,7 +414,7 @@ public class CmBehaviorRecordServiceImpl implements CmBehaviorRecordService {
|
|
|
for (CmBehaviorRecordPo recordPo : selDataList) {
|
|
|
if (recordPo.getIP().equals(data.getIP()) && recordPo.getUserId().equals(data.getUserId())) {
|
|
|
// 标签信息
|
|
|
- if (num < 5) {
|
|
|
+ if (num < 10) {
|
|
|
if (!item.contains(recordPo.getPageLabel())) {
|
|
|
item.add(recordPo.getPageLabel());
|
|
|
num++;
|
|
@@ -431,6 +432,53 @@ public class CmBehaviorRecordServiceImpl implements CmBehaviorRecordService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void updateClubAddress(Integer startId, Integer endId) {
|
|
|
+ List<CmBehaviorRecordPo> recordPoList = recordMapper.selRegisterIP(startId, endId);
|
|
|
+ if (recordPoList.size() > 0) {
|
|
|
+ recordPoList.forEach(r -> {
|
|
|
+ if (StringUtils.isNotBlank(r.getRegisterIp()) && (null == r.getProvinceId() && null == r.getCityId())) {
|
|
|
+ log.info("个人机构地址初始化=====》"+r.getClubId());
|
|
|
+ try {
|
|
|
+ Map<String, String> map = recordAddress(r.getRegisterIp());
|
|
|
+ if (!map.isEmpty()) {
|
|
|
+ // 省份
|
|
|
+ String regionPro = map.get("regionPro");
|
|
|
+ Integer provinceId = recordMapper.selProvince(regionPro);
|
|
|
+ // 市
|
|
|
+ String regionCity = map.get("regionCity");
|
|
|
+ AddressPo addressPo = recordMapper.selCity(regionCity);
|
|
|
+
|
|
|
+ Integer cityId = null;
|
|
|
+ if (null != provinceId) {
|
|
|
+ if (null != addressPo) {
|
|
|
+ if (null != addressPo.getProvinceId()) {
|
|
|
+ if (addressPo.getProvinceId().equals(provinceId)) {
|
|
|
+ // 省份id与地址表的省份地址对应 取地址表地址 机构给予 省、市地址
|
|
|
+ recordMapper.upClubAddress(r.getClubId(), provinceId, addressPo.getCityId());
|
|
|
+ } else {
|
|
|
+ // 省份id与地址表的省份地址不对应 取地址表地址
|
|
|
+ provinceId = addressPo.getProvinceId();
|
|
|
+ recordMapper.upClubAddress(r.getClubId(), provinceId, addressPo.getCityId());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 地址表没有省份id 机构给予省份地址Id
|
|
|
+ recordMapper.upClubAddress(r.getClubId(), provinceId, cityId);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 省份不为空 市为空,机构给予省份地址Id
|
|
|
+ recordMapper.upClubAddress(r.getClubId(), provinceId, cityId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
// 获取IP对应地址 ---- 太平洋
|
|
|
public static String recordIp(String ip) throws IOException {
|
|
@@ -470,6 +518,52 @@ public class CmBehaviorRecordServiceImpl implements CmBehaviorRecordService {
|
|
|
}
|
|
|
return region;
|
|
|
}
|
|
|
+ // 获取IP对应地址 ---- 太平洋
|
|
|
+ public static Map<String, String> recordAddress(String ip) throws IOException {
|
|
|
+ URL url = null;
|
|
|
+ HttpURLConnection connection = null;
|
|
|
+ String encoding = "gbk";
|
|
|
+ String text = "";
|
|
|
+ String line = "";
|
|
|
+ String regionPro = "";
|
|
|
+ String regionCity = "";
|
|
|
+ Map<String,String> map = new HashMap<>();
|
|
|
+ String urlStr = "http://whois.pconline.com.cn/ipJson.jsp?ip=" + ip + "&json=true";
|
|
|
+ try {
|
|
|
+ url = new URL(urlStr);
|
|
|
+ connection = (HttpURLConnection) url.openConnection(); //新建链接实例
|
|
|
+ connection.setConnectTimeout(20000); //设置链接超时时间,单位毫秒
|
|
|
+ connection.setReadTimeout(20000); //设置读取数据超时时间,单位毫秒
|
|
|
+ connection.setDoOutput(true); //是否打开输出流true|false
|
|
|
+ connection.setDoInput(true); //是否打开输入流true|false
|
|
|
+ connection.setRequestMethod("GET"); // 提交方式get|post
|
|
|
+ connection.setUseCaches(false); // 是否加入缓存true|false
|
|
|
+ connection.connect(); //打开链接端口
|
|
|
+
|
|
|
+ BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), encoding)); // 往对端写完数据对端服务器返回数据。以BufferedReader流来读取
|
|
|
+
|
|
|
+ while ((line = reader.readLine()) != null) {
|
|
|
+ text += line + "\n";
|
|
|
+ }
|
|
|
+ reader.close();
|
|
|
+
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(text);
|
|
|
+ // 省份
|
|
|
+ regionPro = jsonObject.get("pro").toString();
|
|
|
+ map.put("regionPro", regionPro);
|
|
|
+ // 市区
|
|
|
+ regionCity = jsonObject.get("city").toString();
|
|
|
+ map.put("regionCity", regionCity);
|
|
|
+
|
|
|
+ } catch (MalformedURLException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } finally {
|
|
|
+ if (connection != null) {
|
|
|
+ connection.disconnect(); //关闭连接
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
|
|
|
private String source(String link) {
|
|
|
if (link.contains("www.baidu.com")) {
|