This commit is contained in:
zt
2025-04-16 19:37:48 +08:00
parent f7dec1b2d0
commit 3451d32ef5
3 changed files with 24 additions and 23 deletions

View File

@ -126,7 +126,7 @@ public class TemplateDownloadController {
String userName = wgzUser.getUsername();
String idCard = wgzUser.getIdentityCard();
// 第二层文件夹名
String secondLevelFolderName = PinYinUtil.getChineseNameInitials(userName) + "_" + idCard;
String secondLevelFolderName = PinYinUtil.chineseToFullPinyin(userName) + "_" + idCard;
byte[] bytes2 = secondLevelFolderName.getBytes(StandardCharsets.UTF_8);
// 将 UTF - 8 字节数组转换回字符串

View File

@ -1,6 +1,7 @@
package com.ruoyi.web.controller.common;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.crypto.digest.DigestUtil;
import com.ruoyi.bgt.domain.BgtProjectRecruit;
import com.ruoyi.bgt.domain.BgtProjectRecruitApply;
import com.ruoyi.bgt.service.IBgtProjectRecruitApplyService;
@ -29,7 +30,7 @@ import org.springframework.web.multipart.MultipartFile;
import javax.validation.constraints.NotNull;
import java.io.*;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
@ -78,8 +79,8 @@ public class UploadZipController {
if(split.length != 2 || !split[0].equals(recruitId.toString())){
throw new BaseException("文件名与所选择招工不匹配");
}
if(recruitService.queryById(recruitId) == null){
BgtProjectRecruit recruit = recruitService.queryById(recruitId);
if( recruit== null){
throw new BaseException("招工信息不存在!");
}
@ -92,15 +93,15 @@ public class UploadZipController {
String firstLevelFolderName ="";
try {
// 保存上传的压缩文件
File zipFile = new File(TEMP_DIR, file.getOriginalFilename());
String s = DigestUtil.md5Hex(recruit.getRecruitName());
firstLevelFolderName = recruitId + "_" + s;
File zipFile = new File(TEMP_DIR, firstLevelFolderName);
ensureDirectoryExists(zipFile.getParentFile());
try (OutputStream os = new FileOutputStream(zipFile)) {
os.write(file.getBytes());
}
// 解压压缩文件
BgtProjectRecruit recruit = recruitService.queryById(recruitId);
firstLevelFolderName = recruit.getId() + "_" + recruit.getRecruitName();
File extractDir = new File(TEMP_DIR, firstLevelFolderName);
ensureDirectoryExists(extractDir);
extractZipFile(zipFile, extractDir);
@ -163,7 +164,7 @@ public class UploadZipController {
}
private void extractZipFile(File zipFile, File extractDir) throws IOException {
try (ZipInputStream zis = new ZipInputStream(new FileInputStream(zipFile), Charset.forName("GBK"))) {
try (ZipInputStream zis = new ZipInputStream(new FileInputStream(zipFile), StandardCharsets.UTF_8)) {
ZipEntry zipEntry;
while ((zipEntry = zis.getNextEntry()) != null) {
File newFile = newFile(extractDir, zipEntry);
@ -235,10 +236,10 @@ public class UploadZipController {
File[] thirdLevelFiles = secondLevelFile.listFiles();
if (thirdLevelFiles != null && thirdLevelFiles.length > 0) {
// 删除数据库里的附件
if ("保险".equals(secondLevelFolderName)) {
if ("BaoXian".equals(secondLevelFolderName)) {
insurance.add(wgzUser.getUserId());
}
if ("劳务合同".equals(secondLevelFolderName)) {
if ("HeTong".equals(secondLevelFolderName)) {
contract.add(wgzUser.getUserId());
}
}
@ -335,10 +336,10 @@ public class UploadZipController {
String name = destination.getName();
System.out.println("上一级文件名: " + name);
String type = "";
if ("保险".equals(name)) {
if ("BaoXian".equals(name)) {
type = "2";
}
if ("劳务合同".equals(name)) {
if ("HeTong".equals(name)) {
type = "1";
}
Annex annex = new Annex();
@ -411,10 +412,10 @@ public class UploadZipController {
String name = destination.getName();
String type = "";
if ("保险".equals(name)) {
if ("BaoXian".equals(name)) {
type = "2";
}
if ("劳务合同".equals(name)) {
if ("HeTong".equals(name)) {
type = "1";
}