diff --git a/eladmin-system/pom.xml b/eladmin-system/pom.xml
index 9ad3b09..fc66362 100644
--- a/eladmin-system/pom.xml
+++ b/eladmin-system/pom.xml
@@ -63,6 +63,12 @@
1.1.0
+
+ com.google.guava
+ guava
+ 22.0
+
+
io.jsonwebtoken
diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/uploadnew/service/impl/TbUploadFileNewServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/uploadnew/service/impl/TbUploadFileNewServiceImpl.java
index 7e38ded..6474d18 100644
--- a/eladmin-system/src/main/java/me/zhengjie/modules/uploadnew/service/impl/TbUploadFileNewServiceImpl.java
+++ b/eladmin-system/src/main/java/me/zhengjie/modules/uploadnew/service/impl/TbUploadFileNewServiceImpl.java
@@ -189,7 +189,7 @@ public class TbUploadFileNewServiceImpl implements TbUploadFileNewService {
break;
case FileConstant.CSV_FILE_SUB_NAME:
fileFormat = "csv文件";
- count = ToolExcelUtils.countSizeByUrl(eachFilePath);
+ count = ToolExcelUtils.countSizeByCsv(eachFilePath);
break;
default:
}
diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/uploadnew/task/SaveToFileNewTask.java b/eladmin-system/src/main/java/me/zhengjie/modules/uploadnew/task/SaveToFileNewTask.java
index 7289fb1..3fd8fc1 100644
--- a/eladmin-system/src/main/java/me/zhengjie/modules/uploadnew/task/SaveToFileNewTask.java
+++ b/eladmin-system/src/main/java/me/zhengjie/modules/uploadnew/task/SaveToFileNewTask.java
@@ -152,11 +152,11 @@ public class SaveToFileNewTask {
private int handleEachFileContent(String filePath, TbUploadFileNewDto tbUploadFileNewDto) {
List phoneList = Lists.newArrayList();
-
+ String fileFormat = tbUploadFileNewDto.getFileFormat();
//根据文件类型进行解析
- List listT = tbUploadFileNewDto.getFileFormat().contains(FileConstant.TXT_FILE_SUB_NAME) ?
- TxtUtils.txtParseListVyUrl(filePath) :
- ToolExcelUtils.excelParseListByUrl(filePath);
+ List listT = fileFormat.contains(FileConstant.TXT_FILE_SUB_NAME) ?
+ TxtUtils.txtParseListVyUrl(filePath) : fileFormat.contains(FileConstant.CSV_FILE_SUB_NAME)
+ ? ToolExcelUtils.csvParseListByUrl(filePath) : ToolExcelUtils.excelParseListByUrl(filePath);
Map> preEncryptNumMap = listT.stream().filter
(phone -> phone.trim().getBytes(StandardCharsets.UTF_8).length == DefaultConstant.ELEVEN_NUMBER)
@@ -164,7 +164,7 @@ public class SaveToFileNewTask {
if (CollectionUtil.isNotEmpty(preEncryptNumMap)) {
// 分批调用接口进行加密
List list = preEncryptNumMap.get(PRE_SEND_NUM_LENGTH);
- phoneList = Lists.newArrayList(Sets.newHashSet(list));
+ phoneList = Lists.newArrayList(Sets.newHashSet(list));
if (CollectionUtil.isNotEmpty(phoneList)) {
batchSendToEncrypt(filePath, phoneList);
}
diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/uploadnew/task/SendMessageTask.java b/eladmin-system/src/main/java/me/zhengjie/modules/uploadnew/task/SendMessageTask.java
index fd7376d..78afe63 100644
--- a/eladmin-system/src/main/java/me/zhengjie/modules/uploadnew/task/SendMessageTask.java
+++ b/eladmin-system/src/main/java/me/zhengjie/modules/uploadnew/task/SendMessageTask.java
@@ -93,8 +93,8 @@ public class SendMessageTask {
String fileFormat, SmsConfigurationDto smsConfigurationDto) {
//根据文件类型进行解析
List list = fileFormat.contains(FileConstant.TXT_FILE_SUB_NAME) ?
- TxtUtils.txtParseListVyUrl(filePath) :
- ToolExcelUtils.excelParseListByUrl(filePath);
+ TxtUtils.txtParseListVyUrl(filePath) : fileFormat.contains(FileConstant.CSV_FILE_SUB_NAME)
+ ? ToolExcelUtils.csvParseListByUrl(filePath) : ToolExcelUtils.excelParseListByUrl(filePath);
if (!CollectionUtils.isEmpty(list)) {
List stringList = list.stream().filter
diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/uploadnew/util/ToolExcelUtils.java b/eladmin-system/src/main/java/me/zhengjie/modules/uploadnew/util/ToolExcelUtils.java
index 0094d42..17a6933 100644
--- a/eladmin-system/src/main/java/me/zhengjie/modules/uploadnew/util/ToolExcelUtils.java
+++ b/eladmin-system/src/main/java/me/zhengjie/modules/uploadnew/util/ToolExcelUtils.java
@@ -1,8 +1,11 @@
package me.zhengjie.modules.uploadnew.util;
-import cn.hutool.core.util.StrUtil;
+import cn.hutool.core.text.csv.CsvData;
+import cn.hutool.core.text.csv.CsvReader;
+import cn.hutool.core.text.csv.CsvUtil;
import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil;
+import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import me.zhengjie.modules.constant.DefaultConstant;
import org.apache.commons.collections4.CollectionUtils;
@@ -42,4 +45,28 @@ public class ToolExcelUtils {
return DefaultConstant.ZERO_NUMBER;
}
+
+ public static int countSizeByCsv(String fileUrl) {
+ CsvReader reader = CsvUtil.getReader();
+ // 解析文件
+ CsvData data = reader.read(cn.hutool.core.io.FileUtil.file(fileUrl));
+ if (CollectionUtils.isNotEmpty(data.getRows())) {
+ return data.getRows().size();
+ }
+ return DefaultConstant.ZERO_NUMBER;
+ }
+
+
+ public static List csvParseListByUrl(String fileUrl) {
+ List list = Lists.newArrayList();
+ CsvReader reader = CsvUtil.getReader();
+ // 解析文件
+ CsvData data = reader.read(cn.hutool.core.io.FileUtil.file(fileUrl));
+ if (CollectionUtils.isNotEmpty(data.getRows())) {
+ data.getRows().forEach(clue -> list.add
+ (clue.get(DefaultConstant.ZERO_NUMBER)));
+ }
+ return list;
+ }
+
}
diff --git a/eladmin-system/src/test/java/me/zhengjie/CategorizeTest.java b/eladmin-system/src/test/java/me/zhengjie/CategorizeTest.java
new file mode 100644
index 0000000..1bba59d
--- /dev/null
+++ b/eladmin-system/src/test/java/me/zhengjie/CategorizeTest.java
@@ -0,0 +1,70 @@
+package me.zhengjie;
+
+import cn.hutool.poi.excel.ExcelUtil;
+import cn.hutool.poi.excel.ExcelWriter;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+import me.zhengjie.modules.constant.DefaultConstant;
+import me.zhengjie.modules.uploadnew.util.ExcelUtils;
+import me.zhengjie.modules.uploadnew.util.ToolExcelUtils;
+import me.zhengjie.modules.uploadnew.util.TxtUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * @author Enzo
+ * @date : 2022/5/5
+ */
+public class CategorizeTest {
+ public static List getAllFile(String directoryPath,boolean isAddDirectory) {
+ List list = new ArrayList();
+ File baseFile = new File(directoryPath);
+ if (baseFile.isFile() || !baseFile.exists()) {
+ return list;
+ }
+ File[] files = baseFile.listFiles();
+ for (File file : files) {
+ if (file.isDirectory() && !file.getAbsolutePath().equals("xyk")) {
+
+ list.addAll(getAllFile(file.getAbsolutePath(),isAddDirectory));
+ } else {
+ list.add(file.getAbsolutePath());
+ }
+ }
+ return list;
+ }
+ public static void main(String[] args) throws IOException {
+ List allFile = getAllFile("F:\\新建文件夹\\电销名单", true);
+
+ List resultList = Lists.newArrayList();
+
+ for (String value : allFile) {
+ if (value.endsWith("xls") || value.endsWith("xlsx") ){
+ List strings = ToolExcelUtils.excelParseListByUrl(value);
+ resultList.addAll(strings);
+ }
+ }
+ List strings = Lists.newArrayList(Sets.newHashSet(resultList));
+
+ int i = strings.size() / 600000;
+
+ for (int j = 0; j < i + 1; j++) {
+ // 通过工具类创建writer
+ ExcelWriter chinaWriter = ExcelUtil.getBigWriter("C:\\Users\\a\\Desktop\\号码" + (j + 1) + ".xlsx");
+
+ //todo 设置自动换行(时间)
+ chinaWriter.setColumnWidth(4, 25);
+ // 一次性写出内容,使用默认样式,强制输出标题
+ chinaWriter.write(strings.subList(j * 600000, Math.min((j + 1) * 600000, strings.size())), true);
+ // 关闭writer,释放内存
+ chinaWriter.close();
+ }
+
+ }
+
+}
diff --git a/eladmin-system/src/test/java/me/zhengjie/DemoTest.java b/eladmin-system/src/test/java/me/zhengjie/DemoTest.java
index a10cac4..e5b9130 100644
--- a/eladmin-system/src/test/java/me/zhengjie/DemoTest.java
+++ b/eladmin-system/src/test/java/me/zhengjie/DemoTest.java
@@ -1,18 +1,63 @@
package me.zhengjie;
import cn.hutool.core.util.RandomUtil;
+import cn.hutool.poi.excel.ExcelReader;
+import cn.hutool.poi.excel.ExcelUtil;
+import cn.hutool.poi.excel.ExcelWriter;
+import me.zhengjie.modules.constant.DefaultConstant;
+import me.zhengjie.modules.uploadnew.util.ExcelUtils;
+import me.zhengjie.modules.uploadnew.util.ToolExcelUtils;
import me.zhengjie.utils.FileUtil;
+import org.apache.commons.collections4.CollectionUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.io.File;
+import java.util.ArrayList;
import java.util.HashSet;
+import java.util.List;
import java.util.Set;
+import java.util.regex.Pattern;
public class DemoTest {
+ public static void main(String[] args) {
+ List list = new ArrayList<>();
+ String s = "C:\\Users\\a\\Desktop\\客户信息2(1)(1).xlsx";
+ ExcelReader reader = ExcelUtil.getReader(cn.hutool.core.io.FileUtil.file(s));
+
+ if (CollectionUtils.isNotEmpty(reader.read())) {
+ for (List