Commit b8aaaf01 authored by 刘基明's avatar 刘基明

查重边际条件

parent 551bd9ea
...@@ -951,6 +951,9 @@ public class ThemeManager { ...@@ -951,6 +951,9 @@ public class ThemeManager {
} }
/**
* 查重初始化
*/
@Transactional @Transactional
public void initThemeTextCheck() { public void initThemeTextCheck() {
List<ThemeEntity> themeEntities = themeService.queryLatestThemes(30); List<ThemeEntity> themeEntities = themeService.queryLatestThemes(30);
...@@ -959,7 +962,7 @@ public class ThemeManager { ...@@ -959,7 +962,7 @@ public class ThemeManager {
List<ThemeContentQo> content = themeQo.getContent(); List<ThemeContentQo> content = themeQo.getContent();
for (ThemeContentQo themeContentQo : content) { for (ThemeContentQo themeContentQo : content) {
if (themeContentQo.getType().equals(RelTypeEnum.TEXT.type)) { if (themeContentQo.getType().equals(RelTypeEnum.TEXT.type)) {
if (themeContentQo.getValue().length() > 50) if (StringUtils.isNotBlank(themeContentQo.getValue()) && themeContentQo.getValue().length() > 50)
themeTextCheckService.insertInit(themeContentQo.getValue(), themeQo.getThemeId(), themeTextCheckService.insertInit(themeContentQo.getValue(), themeQo.getThemeId(),
themeQo.getAuthorId(), TimeUtils.getDateTimeOfTimestamp(themeQo.getCreateTime()), themeQo.getThemeType()); themeQo.getAuthorId(), TimeUtils.getDateTimeOfTimestamp(themeQo.getCreateTime()), themeQo.getThemeType());
} }
......
...@@ -25,19 +25,23 @@ public class ThemeTextCheckService { ...@@ -25,19 +25,23 @@ public class ThemeTextCheckService {
// 插入 // 插入
public void insert(String content, String themeId, String userId, Integer themeType, String editThemeId) { public void insert(String content, String themeId, String userId, Integer themeType, String editThemeId) {
try{ if (StringUtils.isBlank(content) || content.length() < 50) {
if (StringUtils.isNotBlank(editThemeId)){ return;
}
try {
if (StringUtils.isNotBlank(editThemeId)) {
themeCheckDuplicateMapper.deleteByThemeId(editThemeId); themeCheckDuplicateMapper.deleteByThemeId(editThemeId);
} }
content = content.replaceAll(regex, "。"); content = content.replaceAll(regex, "。");
String[] split = content.split("。"); String[] split = content.split("。");
for (int i = 0; i < split.length; i++) { for (int i = 0; i < split.length; i++) {
String trim = StringUtils.trim(split[i]); String trim = StringUtils.trim(split[i]);
insert(themeId, trim, getHash(trim), i + 1, split.length, userId,themeType); insert(themeId, trim, getHash(trim), i + 1, split.length, userId, themeType);
} }
}catch (Exception e){ } catch (Exception e) {
log.error("文本查重insert失败,themeId:"+themeId); log.error("文本查重insert失败,themeId:" + themeId);
} }
} }
...@@ -47,7 +51,7 @@ public class ThemeTextCheckService { ...@@ -47,7 +51,7 @@ public class ThemeTextCheckService {
themeCheckDuplicateMapper.deleteByThemeId(themeId); themeCheckDuplicateMapper.deleteByThemeId(themeId);
} }
private void insert(String themeId, String partition, Integer partitionHash, Integer num, Integer total, String userId,Integer themeType) { private void insert(String themeId, String partition, Integer partitionHash, Integer num, Integer total, String userId, Integer themeType) {
ThemeCheckDuplicateEntity build = ThemeCheckDuplicateEntity.builder() ThemeCheckDuplicateEntity build = ThemeCheckDuplicateEntity.builder()
.themeId(themeId) .themeId(themeId)
...@@ -103,7 +107,7 @@ public class ThemeTextCheckService { ...@@ -103,7 +107,7 @@ public class ThemeTextCheckService {
} }
// 初始化 // 初始化
public void insertInit(String content, String themeId, String userId, LocalDateTime createTime,Integer themeType) { public void insertInit(String content, String themeId, String userId, LocalDateTime createTime, Integer themeType) {
themeCheckDuplicateMapper.deleteByThemeId(themeId); themeCheckDuplicateMapper.deleteByThemeId(themeId);
content = content.replaceAll(regex, "。"); content = content.replaceAll(regex, "。");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment