Commit 384a8053 authored by 刘基明's avatar 刘基明

查重

parent 89d143f8
...@@ -959,7 +959,8 @@ public class ThemeManager { ...@@ -959,7 +959,8 @@ 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)) {
themeTextCheckService.insertInit(themeContentQo.getValue(), themeQo.getThemeId(), themeQo.getAuthorId(), TimeUtils.getDateTimeOfTimestamp(themeQo.getCreateTime())); themeTextCheckService.insertInit(themeContentQo.getValue(), themeQo.getThemeId(),
themeQo.getAuthorId(), TimeUtils.getDateTimeOfTimestamp(themeQo.getCreateTime()),themeQo.getThemeType());
} }
} }
} }
......
...@@ -31,7 +31,8 @@ public class ThemeTextCheckService { ...@@ -31,7 +31,8 @@ public class ThemeTextCheckService {
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, getMD5(trim), i + 1, split.length, userId); insert(themeId, trim, getHash(trim), i + 1, split.length, userId,themeType);
} }
} }
...@@ -40,7 +41,7 @@ public class ThemeTextCheckService { ...@@ -40,7 +41,7 @@ public class ThemeTextCheckService {
themeCheckDuplicateMapper.deleteByThemeId(themeId); themeCheckDuplicateMapper.deleteByThemeId(themeId);
} }
private void insert(String themeId, String partition, String partitionHash, Integer num, Integer total, String userId) { private void insert(String themeId, String partition, String partitionHash, Integer num, Integer total, String userId,Integer themeType) {
ThemeCheckDuplicateEntity build = ThemeCheckDuplicateEntity.builder() ThemeCheckDuplicateEntity build = ThemeCheckDuplicateEntity.builder()
.themeId(themeId) .themeId(themeId)
...@@ -49,6 +50,7 @@ public class ThemeTextCheckService { ...@@ -49,6 +50,7 @@ public class ThemeTextCheckService {
.partitionNum(num) .partitionNum(num)
.totalParts(total) .totalParts(total)
.userId(userId) .userId(userId)
.themeType(themeType)
.build(); .build();
themeCheckDuplicateMapper.insert(build); themeCheckDuplicateMapper.insert(build);
} }
...@@ -63,7 +65,7 @@ public class ThemeTextCheckService { ...@@ -63,7 +65,7 @@ public class ThemeTextCheckService {
List<String> list = new ArrayList<>(); List<String> list = new ArrayList<>();
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]);
list.add(getMD5(trim)); list.add(getHash(trim));
} }
// 一年以内 // 一年以内
LambdaQueryWrapper<ThemeCheckDuplicateEntity> w = new LambdaQueryWrapper<ThemeCheckDuplicateEntity>().in(ThemeCheckDuplicateEntity::getPartitionHash, list) LambdaQueryWrapper<ThemeCheckDuplicateEntity> w = new LambdaQueryWrapper<ThemeCheckDuplicateEntity>().in(ThemeCheckDuplicateEntity::getPartitionHash, list)
...@@ -79,7 +81,7 @@ public class ThemeTextCheckService { ...@@ -79,7 +81,7 @@ public class ThemeTextCheckService {
} }
public static String getMD5(String str) { public static String getHash(String str) {
try { try {
// 生成一个MD5加密计算摘要 // 生成一个MD5加密计算摘要
MessageDigest md = MessageDigest.getInstance("MD5"); MessageDigest md = MessageDigest.getInstance("MD5");
...@@ -94,7 +96,7 @@ public class ThemeTextCheckService { ...@@ -94,7 +96,7 @@ public class ThemeTextCheckService {
} }
// 初始化 // 初始化
public void insertInit(String content, String themeId, String userId, LocalDateTime createTime) { 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, "。");
...@@ -105,15 +107,18 @@ public class ThemeTextCheckService { ...@@ -105,15 +107,18 @@ public class ThemeTextCheckService {
ThemeCheckDuplicateEntity build = ThemeCheckDuplicateEntity.builder() ThemeCheckDuplicateEntity build = ThemeCheckDuplicateEntity.builder()
.themeId(themeId) .themeId(themeId)
.partitionText(trim) .partitionText(trim)
.partitionHash(getMD5(split[i])) .partitionHash(getHash(split[i]))
.partitionNum(i + 1) .partitionNum(i + 1)
.totalParts(split.length) .totalParts(split.length)
.userId(userId) .userId(userId)
.themeType(themeType)
.createTime(createTime) .createTime(createTime)
.updateTime(createTime) .updateTime(createTime)
.build(); .build();
themeCheckDuplicateMapper.insert(build); themeCheckDuplicateMapper.insert(build);
} }
} }
} }
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