|
@@ -21,6 +21,8 @@ import java.net.URL;
|
|
|
import java.text.DecimalFormat;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
+import java.util.regex.Matcher;
|
|
|
+import java.util.regex.Pattern;
|
|
|
|
|
|
/**
|
|
|
* Description
|
|
@@ -35,6 +37,8 @@ public class CmBehaviorRecordServiceImpl implements CmBehaviorRecordService {
|
|
|
@Autowired
|
|
|
private CmBehaviorRecordMapper recordMapper;
|
|
|
|
|
|
+ private Pattern pattern = Pattern.compile("[a-zA-Z]");
|
|
|
+
|
|
|
@Override
|
|
|
public void insertRecord(IpSavePo ipSavePo) {
|
|
|
if ("/user/record/Statistics".equals(ipSavePo.getRequestUrl().trim()) && !ipSavePo.getIp().equals("106.55.202.118")) {
|
|
@@ -318,6 +322,8 @@ public class CmBehaviorRecordServiceImpl implements CmBehaviorRecordService {
|
|
|
if (StringUtils.isBlank(pageLabel) || StringUtils.isEmpty(pageLabel)) {
|
|
|
// 为空查询页面标签、或者使用初始默认数据
|
|
|
pageLabel = recordMapper.getPageLabel(cmBehaviorRecordPo.getPageType());
|
|
|
+ } else {
|
|
|
+ pageLabel = " ";
|
|
|
}
|
|
|
cmBehaviorRecordPo.setPageLabel(pageLabel);
|
|
|
}
|
|
@@ -552,8 +558,20 @@ public class CmBehaviorRecordServiceImpl implements CmBehaviorRecordService {
|
|
|
ArrayList<String> shopNames = new ArrayList();
|
|
|
// 当ip过长,有多个ip时已第一个IP为准
|
|
|
if (data.getIP().contains(",")) {
|
|
|
- String[] split = data.getIP().split(",");
|
|
|
- data.setIP(split[0].trim());
|
|
|
+ String[] splitArray = data.getIP().split(",");
|
|
|
+ for (String split : splitArray) {
|
|
|
+ Matcher matcher = pattern.matcher(split);
|
|
|
+ if (!matcher.find()) {
|
|
|
+ data.setIP(split);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Matcher matcher = pattern.matcher(data.getIP());
|
|
|
+ if (matcher.find()) {
|
|
|
+ data.setIP(splitArray[1]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (data.getIP().length() > 20) {
|
|
|
+ data.setDelFlag("1");
|
|
|
}
|
|
|
int num = 0;
|
|
|
for (CmBehaviorRecordPo recordPo : selDataList) {
|
|
@@ -595,6 +613,9 @@ public class CmBehaviorRecordServiceImpl implements CmBehaviorRecordService {
|
|
|
// 获取该用户该天页面类型
|
|
|
List<Integer> behaviorPageType = recordMapper.getBehaviorPageType(data.getIP(), data.getAccessDate(), data.getUserId());
|
|
|
data.setPageTypes(StringUtils.strip(behaviorPageType.toString(), "[]"));
|
|
|
+ if (StringUtils.isBlank(data.getPageLabel()) || StringUtils.isEmpty(data.getPageLabel())) {
|
|
|
+ data.setPageLabels(" ");
|
|
|
+ }
|
|
|
// 数据插入
|
|
|
recordMapper.insertYesterdayList(data);
|
|
|
}
|
|
@@ -624,8 +645,21 @@ public class CmBehaviorRecordServiceImpl implements CmBehaviorRecordService {
|
|
|
ArrayList<String> shopNames = new ArrayList();
|
|
|
// 当ip过长,有多个ip时已第一个IP为准
|
|
|
if (data.getIP().contains(",")) {
|
|
|
- String[] split = data.getIP().split(",");
|
|
|
- data.setIP(split[0].trim());
|
|
|
+ String[] splitArray = data.getIP().split(",");
|
|
|
+
|
|
|
+ for (String split : splitArray) {
|
|
|
+ Matcher matcher = pattern.matcher(split);
|
|
|
+ if (!matcher.find()) {
|
|
|
+ data.setIP(split);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Matcher matcher = pattern.matcher(data.getIP());
|
|
|
+ if (matcher.find()) {
|
|
|
+ data.setIP(splitArray[1]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (data.getIP().length() > 20) {
|
|
|
+ data.setDelFlag("1");
|
|
|
}
|
|
|
int num = 0;
|
|
|
data.setRecordID(id);
|
|
@@ -662,6 +696,7 @@ public class CmBehaviorRecordServiceImpl implements CmBehaviorRecordService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
data.setLabel(StringUtils.strip(item.toString(), "[]"));
|
|
|
data.setRelevanceShop(StringUtils.strip(shopNames.toString(), "[]"));
|
|
|
// 获取该用户该天页面标签
|
|
@@ -670,6 +705,9 @@ public class CmBehaviorRecordServiceImpl implements CmBehaviorRecordService {
|
|
|
// 获取该用户该天页面类型
|
|
|
List<Integer> behaviorPageType = recordMapper.getBehaviorPageType(data.getIP(), data.getAccessDate(), data.getUserId());
|
|
|
data.setPageTypes(StringUtils.strip(behaviorPageType.toString(), "[]"));
|
|
|
+ if (StringUtils.isBlank(data.getPageLabel()) || StringUtils.isEmpty(data.getPageLabel())) {
|
|
|
+ data.setPageLabels(" ");
|
|
|
+ }
|
|
|
recordMapper.inBehaviorToday(data);
|
|
|
log.info("====今日用户行为列表数据已生成====");
|
|
|
}
|