|
@@ -160,7 +160,7 @@ public class CmBehaviorRecordServiceImpl implements CmBehaviorRecordService {
|
|
|
String value = split1[1];
|
|
|
String trim = value.trim();
|
|
|
if (StringUtils.isNotBlank(trim)) {
|
|
|
- log.info("referer============》"+trim);
|
|
|
+// log.info("referer============》"+trim);
|
|
|
// 浏览器链接
|
|
|
cmBehaviorRecordPo.setReferer(trim);
|
|
|
// 访问来源
|
|
@@ -169,6 +169,24 @@ public class CmBehaviorRecordServiceImpl implements CmBehaviorRecordService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ // 设置删除标记 判定爬虫
|
|
|
+ cmBehaviorRecordPo.setDelFlag("0");
|
|
|
+ // 浏览器userAgent
|
|
|
+ if (str.startsWith("userAgent") && str.contains("=")) {
|
|
|
+ String[] split1 = str.split("=");
|
|
|
+ if (split1.length > 1) {
|
|
|
+ String value = split1[1];
|
|
|
+ String trim = value.trim();
|
|
|
+ if (StringUtils.isNotBlank(trim)) {
|
|
|
+ log.info("userAgent============》"+trim);
|
|
|
+ // 浏览器userAgent
|
|
|
+ cmBehaviorRecordPo.setUserAgent(trim);
|
|
|
+ if (boolReptiles(trim)) {
|
|
|
+ cmBehaviorRecordPo.setDelFlag("1");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -254,6 +272,36 @@ public class CmBehaviorRecordServiceImpl implements CmBehaviorRecordService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void updateBehaviorUser() {
|
|
|
+ log.info("====合并IP====");
|
|
|
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ Date date = new Date();
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ calendar.setTime(date);
|
|
|
+ calendar.add(Calendar.DAY_OF_MONTH,-1);
|
|
|
+ Date time = calendar.getTime();
|
|
|
+ String format = dateFormat.format(time);
|
|
|
+ // 前一天数据身份中是否只有 机构-游客、供应商-游客
|
|
|
+ List<CmBehaviorRecordPo> countNumList = recordMapper.countNum(format);
|
|
|
+ if (countNumList.size() != 0 && countNumList != null) {
|
|
|
+ for (CmBehaviorRecordPo countNum: countNumList) {
|
|
|
+ if (countNum.getCount() == 2) {
|
|
|
+ // 查询机构/供应商ip、userID,用于调整游客数据
|
|
|
+ CmBehaviorRecordPo recordPo = recordMapper.userIdAcc(countNum.getIP(), format);
|
|
|
+ // 查询游客数据
|
|
|
+ List<CmBehaviorRecordPo> behaviorList = recordMapper.selBehaviorList(countNum.getIP(), format);
|
|
|
+ // 将游客数据中的ip和userId修改为机构/供应商数据
|
|
|
+ for (CmBehaviorRecordPo cmBehaviorRecordPo : behaviorList) {
|
|
|
+ cmBehaviorRecordPo.setIP(recordPo.getIP());
|
|
|
+ cmBehaviorRecordPo.setUserId(recordPo.getUserId());
|
|
|
+ recordMapper.updateBehavior(cmBehaviorRecordPo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
// 获取IP对应地址 ---- 太平洋
|
|
|
public static String recordIp(String ip) throws IOException {
|
|
@@ -288,7 +336,7 @@ public class CmBehaviorRecordServiceImpl implements CmBehaviorRecordService {
|
|
|
e.printStackTrace();
|
|
|
} finally {
|
|
|
if (connection != null) {
|
|
|
- connection.disconnect(); //关闭谅解
|
|
|
+ connection.disconnect(); //关闭连接
|
|
|
}
|
|
|
}
|
|
|
return region;
|
|
@@ -324,4 +372,12 @@ public class CmBehaviorRecordServiceImpl implements CmBehaviorRecordService {
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
+ private boolean boolReptiles(String userAgent) {
|
|
|
+ if (userAgent.contains("serpstatbot") || userAgent.contains("spider") || userAgent.contains("Googlebot") || userAgent.contains("bingbot")
|
|
|
+ || userAgent.contains("SeznamBot") || userAgent.contains("YisouSpider") || userAgent.contains("petalbot") || userAgent.contains("YandexBot")
|
|
|
+ || userAgent.contains("AhrefsBot")) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|