|
@@ -2,6 +2,7 @@ package com.caimei365.tools.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.caimei365.tools.mapper.CmBehaviorRecordMapper;
|
|
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.CmBehaviorRecordPo;
|
|
import com.caimei365.tools.model.po.CmUserPo;
|
|
import com.caimei365.tools.model.po.CmUserPo;
|
|
import com.caimei365.tools.model.po.IpSavePo;
|
|
import com.caimei365.tools.model.po.IpSavePo;
|
|
@@ -362,16 +363,36 @@ public class CmBehaviorRecordServiceImpl implements CmBehaviorRecordService {
|
|
List<CmBehaviorRecordPo> yesterdayList = recordMapper.selYesterdayList(format);
|
|
List<CmBehaviorRecordPo> yesterdayList = recordMapper.selYesterdayList(format);
|
|
// 详细数据
|
|
// 详细数据
|
|
List<CmBehaviorRecordPo> selDataList = recordMapper.selDataList(format);
|
|
List<CmBehaviorRecordPo> selDataList = recordMapper.selDataList(format);
|
|
|
|
+ // 获取供应商关联所有标签
|
|
|
|
+ List<String> keywords = recordMapper.shopKeyword();
|
|
for (CmBehaviorRecordPo data : yesterdayList) {
|
|
for (CmBehaviorRecordPo data : yesterdayList) {
|
|
ArrayList<String> item = new ArrayList();
|
|
ArrayList<String> item = new ArrayList();
|
|
ArrayList<String> shopNames = new ArrayList();
|
|
ArrayList<String> shopNames = new ArrayList();
|
|
int num = 0;
|
|
int num = 0;
|
|
for (CmBehaviorRecordPo recordPo : selDataList) {
|
|
for (CmBehaviorRecordPo recordPo : selDataList) {
|
|
if (recordPo.getIP().equals(data.getIP()) && recordPo.getUserId().equals(data.getUserId())) {
|
|
if (recordPo.getIP().equals(data.getIP()) && recordPo.getUserId().equals(data.getUserId())) {
|
|
- if (num < 5) {
|
|
|
|
- if (!item.contains(recordPo.getPageLabel())) {
|
|
|
|
- item.add(recordPo.getPageLabel());
|
|
|
|
- num++;
|
|
|
|
|
|
+ // 标签信息 对多存储10个
|
|
|
|
+ if (num < 10) {
|
|
|
|
+ if (StringUtils.isNotBlank(recordPo.getPageLabel())) {
|
|
|
|
+ if (recordPo.getPageLabel().contains(",")) {
|
|
|
|
+ String[] split = recordPo.getPageLabel().split(",");
|
|
|
|
+ for (String s : split) {
|
|
|
|
+ if (keywords.contains(s)) {
|
|
|
|
+ if (!item.contains(s)) {
|
|
|
|
+ item.add(s);
|
|
|
|
+ num++;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ if (keywords.contains(recordPo.getPageLabel())) {
|
|
|
|
+ if (!item.contains(recordPo.getPageLabel())) {
|
|
|
|
+ item.add(recordPo.getPageLabel());
|
|
|
|
+ num++;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (StringUtils.isNotBlank(recordPo.getRelevanceShop()) && !shopNames.contains(recordPo.getRelevanceShop())) {
|
|
if (StringUtils.isNotBlank(recordPo.getRelevanceShop()) && !shopNames.contains(recordPo.getRelevanceShop())) {
|
|
@@ -404,6 +425,7 @@ public class CmBehaviorRecordServiceImpl implements CmBehaviorRecordService {
|
|
int id = 1;
|
|
int id = 1;
|
|
// 所有用户供应商数据
|
|
// 所有用户供应商数据
|
|
List<CmBehaviorRecordPo> selDataList = recordMapper.selDataList(format);
|
|
List<CmBehaviorRecordPo> selDataList = recordMapper.selDataList(format);
|
|
|
|
+ List<String> keywords = recordMapper.shopKeyword();
|
|
for (CmBehaviorRecordPo data : todayData) {
|
|
for (CmBehaviorRecordPo data : todayData) {
|
|
ArrayList<String> item = new ArrayList();
|
|
ArrayList<String> item = new ArrayList();
|
|
ArrayList<String> shopNames = new ArrayList();
|
|
ArrayList<String> shopNames = new ArrayList();
|
|
@@ -413,10 +435,27 @@ public class CmBehaviorRecordServiceImpl implements CmBehaviorRecordService {
|
|
for (CmBehaviorRecordPo recordPo : selDataList) {
|
|
for (CmBehaviorRecordPo recordPo : selDataList) {
|
|
if (recordPo.getIP().equals(data.getIP()) && recordPo.getUserId().equals(data.getUserId())) {
|
|
if (recordPo.getIP().equals(data.getIP()) && recordPo.getUserId().equals(data.getUserId())) {
|
|
// 标签信息
|
|
// 标签信息
|
|
- if (num < 5) {
|
|
|
|
- if (!item.contains(recordPo.getPageLabel())) {
|
|
|
|
- item.add(recordPo.getPageLabel());
|
|
|
|
- num++;
|
|
|
|
|
|
+ if (num < 10) {
|
|
|
|
+ if (StringUtils.isNotBlank(recordPo.getPageLabel())) {
|
|
|
|
+ if (recordPo.getPageLabel().contains(",")) {
|
|
|
|
+ String[] split = recordPo.getPageLabel().split(",");
|
|
|
|
+ for (String s : split) {
|
|
|
|
+ if (keywords.contains(s)) {
|
|
|
|
+ if (!item.contains(s)) {
|
|
|
|
+ item.add(s);
|
|
|
|
+ num++;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ if (keywords.contains(recordPo.getPageLabel())) {
|
|
|
|
+ if (!item.contains(recordPo.getPageLabel())) {
|
|
|
|
+ item.add(recordPo.getPageLabel());
|
|
|
|
+ num++;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// 供应商
|
|
// 供应商
|
|
@@ -428,6 +467,54 @@ public class CmBehaviorRecordServiceImpl implements CmBehaviorRecordService {
|
|
data.setLabel(StringUtils.strip(item.toString(), "[]"));
|
|
data.setLabel(StringUtils.strip(item.toString(), "[]"));
|
|
data.setRelevanceShop(StringUtils.strip(shopNames.toString(), "[]"));
|
|
data.setRelevanceShop(StringUtils.strip(shopNames.toString(), "[]"));
|
|
recordMapper.inBehaviorToday(data);
|
|
recordMapper.inBehaviorToday(data);
|
|
|
|
+ log.info("====今日用户行为列表数据已生成====");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @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();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -470,6 +557,52 @@ public class CmBehaviorRecordServiceImpl implements CmBehaviorRecordService {
|
|
}
|
|
}
|
|
return region;
|
|
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) {
|
|
private String source(String link) {
|
|
if (link.contains("www.baidu.com")) {
|
|
if (link.contains("www.baidu.com")) {
|