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

查重

parent 6d18b645
...@@ -19,9 +19,9 @@ public class CodeAutoGenerator { ...@@ -19,9 +19,9 @@ public class CodeAutoGenerator {
String currentPath = System.getProperty("user.dir"); String currentPath = System.getProperty("user.dir");
String codeBaseHome = "/community-service/src/main/java"; String codeBaseHome = "/community-service/src/main/java";
String author = "xudong"; String author = "xudong";
String mysqlUserName = "tamp_admin"; String mysqlUserName = "dev";
String mysqlPassword = "@imeng123"; String mysqlPassword = "qimeng123";
String jdbcUrl = "jdbc:mysql://rm-uf6r22t3d798q4kmk.mysql.rds.aliyuncs.com:3306/tamp_community"; String jdbcUrl = "jdbc:mysql://rm-uf6lqwk9969zao53uro.mysql.rds.aliyuncs.com:3306/tamp_community";
// String[] tables = new String[]{"theme"}; // String[] tables = new String[]{"theme"};
String[] tables = new String[]{"theme_check_duplicate"}; String[] tables = new String[]{"theme_check_duplicate"};
String basePackage = "com.tanpu.community"; String basePackage = "com.tanpu.community";
......
...@@ -19,7 +19,7 @@ import java.time.LocalDateTime; ...@@ -19,7 +19,7 @@ import java.time.LocalDateTime;
* </p> * </p>
* *
* @author xudong * @author xudong
* @since 2021-09-08 * @since 2021-09-14
*/ */
@Builder @Builder
@Data @Data
...@@ -44,7 +44,7 @@ public class ThemeCheckDuplicateEntity implements Serializable { ...@@ -44,7 +44,7 @@ public class ThemeCheckDuplicateEntity implements Serializable {
private String partitionText; private String partitionText;
@ApiModelProperty(value = "分块hash") @ApiModelProperty(value = "分块hash")
private String partitionHash; private Integer partitionHash;
@ApiModelProperty(value = "分块号") @ApiModelProperty(value = "分块号")
private Integer partitionNum; private Integer partitionNum;
...@@ -94,11 +94,11 @@ public class ThemeCheckDuplicateEntity implements Serializable { ...@@ -94,11 +94,11 @@ public class ThemeCheckDuplicateEntity implements Serializable {
this.partitionText = partitionText; this.partitionText = partitionText;
} }
public String getPartitionHash() { public Integer getPartitionHash() {
return partitionHash; return partitionHash;
} }
public void setPartitionHash(String partitionHash) { public void setPartitionHash(Integer partitionHash) {
this.partitionHash = partitionHash; this.partitionHash = partitionHash;
} }
......
...@@ -2,7 +2,6 @@ package com.tanpu.community.service; ...@@ -2,7 +2,6 @@ package com.tanpu.community.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tanpu.common.constant.BizStatus; import com.tanpu.common.constant.BizStatus;
import com.tanpu.common.exception.BizException;
import com.tanpu.community.dao.entity.community.ThemeCheckDuplicateEntity; import com.tanpu.community.dao.entity.community.ThemeCheckDuplicateEntity;
import com.tanpu.community.dao.mapper.community.ThemeCheckDuplicateMapper; import com.tanpu.community.dao.mapper.community.ThemeCheckDuplicateMapper;
import com.tanpu.community.util.TimeUtils; import com.tanpu.community.util.TimeUtils;
...@@ -10,8 +9,6 @@ import org.apache.commons.lang3.StringUtils; ...@@ -10,8 +9,6 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -43,7 +40,7 @@ public class ThemeTextCheckService { ...@@ -43,7 +40,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,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)
...@@ -64,7 +61,7 @@ public class ThemeTextCheckService { ...@@ -64,7 +61,7 @@ public class ThemeTextCheckService {
} }
content = content.replaceAll(regex, "。"); content = content.replaceAll(regex, "。");
String[] split = content.split("。"); String[] split = content.split("。");
List<String> list = new ArrayList<>(); List<Integer> 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(getHash(trim)); list.add(getHash(trim));
...@@ -83,18 +80,19 @@ public class ThemeTextCheckService { ...@@ -83,18 +80,19 @@ public class ThemeTextCheckService {
} }
public static String getHash(String str) { public static Integer getHash(String str) {
try { return str.hashCode();
// 生成一个MD5加密计算摘要 // try {
MessageDigest md = MessageDigest.getInstance("MD5"); // // 生成一个MD5加密计算摘要
// 计算md5函数 // MessageDigest md = MessageDigest.getInstance("MD5");
md.update(str.getBytes()); // // 计算md5函数
// digest()最后确定返回md5 hash值,返回值为8为字符串。因为md5 hash值是16位的hex值,实际上就是8位的字符 // md.update(str.getBytes());
// BigInteger函数则将8位的字符串转换成16位hex值,用字符串来表示;得到字符串形式的hash值 // // digest()最后确定返回md5 hash值,返回值为8为字符串。因为md5 hash值是16位的hex值,实际上就是8位的字符
return new BigInteger(1, md.digest()).toString(16); // // BigInteger函数则将8位的字符串转换成16位hex值,用字符串来表示;得到字符串形式的hash值
} catch (Exception e) { // return new BigInteger(1, md.digest()).toString(16);
throw new BizException("MD5加密出现错误"); // } catch (Exception e) {
} // throw new BizException("MD5加密出现错误");
// }
} }
// 初始化 // 初始化
......
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