From 7ce41a73f6cddbb4269217fdd68b36aa83475f9b Mon Sep 17 00:00:00 2001 From: zt Date: Thu, 20 Mar 2025 09:32:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B6=88=E6=81=AF=EF=BC=8C=E7=A1=AE=E8=AE=A4?= =?UTF-8?q?=E8=BF=9B=E5=9C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AppBgtProjectRecruitApplyController.java | 9 + .../common/UploadZipController.java | 175 ++++++++++++++++++ .../com/ruoyi/common/enums/AuditStatus.java | 1 + .../bgt/domain/dto/BgtMessageDetailDTO.java | 3 + .../IBgtProjectRecruitApplyService.java | 4 + .../service/impl/BgtMessageServiceImpl.java | 2 + .../BgtProjectRecruitApplyServiceImpl.java | 13 +- .../impl/WgzDailyClockServiceImpl.java | 6 +- .../wgz/service/impl/WgzLeaveServiceImpl.java | 2 +- .../impl/WgzPayCalculationServiceImpl.java | 3 +- .../impl/WgzReissueacardServiceImpl.java | 2 +- 11 files changed, 212 insertions(+), 8 deletions(-) create mode 100644 ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/UploadZipController.java diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/bgt/AppBgtProjectRecruitApplyController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/bgt/AppBgtProjectRecruitApplyController.java index c0cea81..7b30964 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/bgt/AppBgtProjectRecruitApplyController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/bgt/AppBgtProjectRecruitApplyController.java @@ -84,6 +84,15 @@ public class AppBgtProjectRecruitApplyController extends BaseController { return AjaxResult.success(iBgtProjectRecruitApplyService.consent(dto)); } + @ApiOperation("App确认进场") + @Log(title = "App确认进场", businessType = BusinessType.UPDATE) + @RepeatSubmit + @PutMapping("/confirm/{id}") + public AjaxResult confirm(@NotNull(message = "主键不能为空") + @PathVariable("id") Long id) { + return AjaxResult.success(iBgtProjectRecruitApplyService.confirm(id)); + } + @ApiOperation("App务工者退场") @Log(title = "App务工者退场", businessType = BusinessType.UPDATE) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/UploadZipController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/UploadZipController.java new file mode 100644 index 0000000..3ad9717 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/UploadZipController.java @@ -0,0 +1,175 @@ +package com.ruoyi.web.controller.common; + +import com.ruoyi.bgt.service.IBgtProjectRecruitService; +import com.ruoyi.wgz.service.IWgzUserService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; + +import java.io.*; +import java.nio.charset.Charset; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; + +/** + * 登录验证 + * + * @author ruoyi + */ +@Api(value = "网页模板上传", tags = {"网页模板上传"}) +@RequiredArgsConstructor(onConstructor_ = @Autowired) +@RestController() +public class UploadZipController { + + @Autowired + private IWgzUserService wgzUserService; + + @Autowired + private IBgtProjectRecruitService recruitService; + + private static final String TEMP_DIR = "ruoyi/uploadPath/temporary"; + + + @ApiOperation("上传压缩文件") + @PostMapping("/upload-zip") + public ResponseEntity uploadZipFile(@RequestParam("file") MultipartFile file, @RequestParam("recruitId") Long recruitId) { + if (file.isEmpty()) { + return ResponseEntity.badRequest().body("上传的文件为空"); + } + + try { + // 保存上传的压缩文件 + File zipFile = new File(TEMP_DIR, file.getOriginalFilename()); + ensureDirectoryExists(zipFile.getParentFile()); + try (OutputStream os = new FileOutputStream(zipFile)) { + os.write(file.getBytes()); + } + + // 解压压缩文件 + File extractDir = new File(TEMP_DIR, "extracted"); + ensureDirectoryExists(extractDir); + extractZipFile(zipFile, extractDir); + + // 处理解压后的文件夹 + processExtractedFolder(extractDir, recruitId); + + // 删除临时文件和文件夹 + deleteFolder(extractDir); + if (!zipFile.delete()) { + System.err.println("无法删除压缩文件: " + zipFile.getAbsolutePath()); + } + + return ResponseEntity.ok("文件上传并处理成功"); + } catch (IOException e) { + e.printStackTrace(); + return ResponseEntity.status(500).body("文件处理过程中出现错误: " + e.getMessage()); + } + } + + private void ensureDirectoryExists(File directory) throws IOException { + if (!directory.exists()) { + if (!directory.mkdirs()) { + throw new IOException("无法创建目录: " + directory.getAbsolutePath()); + } + } + } + + private void extractZipFile(File zipFile, File extractDir) throws IOException { + try (ZipInputStream zis = new ZipInputStream(new FileInputStream(zipFile), Charset.forName("GBK"))) { + ZipEntry zipEntry; + while ((zipEntry = zis.getNextEntry()) != null) { + File newFile = newFile(extractDir, zipEntry); + if (zipEntry.isDirectory()) { + ensureDirectoryExists(newFile); + } else { + // 为文件创建父目录 + ensureDirectoryExists(newFile.getParentFile()); + + // 写入文件内容 + try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(newFile))) { + byte[] bytesIn = new byte[4096]; + int read; + while ((read = zis.read(bytesIn)) != -1) { + bos.write(bytesIn, 0, read); + } + } + } + } + } + } + + private File newFile(File destinationDir, ZipEntry zipEntry) throws IOException { + File destFile = new File(destinationDir, zipEntry.getName()); + + String destDirPath = destinationDir.getCanonicalPath(); + String destFilePath = destFile.getCanonicalPath(); + + if (!destFilePath.startsWith(destDirPath + File.separator)) { + throw new IOException("Entry is outside of the target dir: " + zipEntry.getName()); + } + + return destFile; + } + + private void processExtractedFolder(File extractDir, Long recruitId) { + File[] firstLevelFiles = extractDir.listFiles(); + if (firstLevelFiles != null) { + for (File firstLevelFile : firstLevelFiles) { + if (firstLevelFile.isDirectory()) { + File[] secondLevelFiles = firstLevelFile.listFiles(); + if (secondLevelFiles != null) { + for (File secondLevelFile : secondLevelFiles) { + if (secondLevelFile.isDirectory()) { + File[] thirdLevelFiles = secondLevelFile.listFiles(); + if (thirdLevelFiles != null) { + for (File thirdLevelFile : thirdLevelFiles) { + if (!thirdLevelFile.isDirectory()) { + String fullPath = firstLevelFile.getName() + "/" + secondLevelFile.getName() + "/" + thirdLevelFile.getName(); + System.out.println("完整路径: " + fullPath); + String thirdLevelFolderName = secondLevelFile.getName(); + System.out.println("第三层文件夹名称: " + thirdLevelFolderName); + // 这里可以添加你需要的处理逻辑,比如保存到数据库等 + // 以下是数据库操作示例,根据实际情况修改 + String folderName = secondLevelFile.getName(); + String[] parts = folderName.split("_"); + if (parts.length > 1) { + String idCard = parts[1]; + System.out.println("身份证: " + idCard); + // 新增逻辑,根据实际情况实现 + // WgzUser user = new WgzUser(); + // user.setRecruitId(recruitId); + // user.setIdentityCard(idCard); + // wgzUserService.save(user); + } + } + } + } + } + } + } + } + } + } + } + + + private static void deleteFolder(File folder) { + if (folder.isDirectory()) { + File[] files = folder.listFiles(); + if (files != null) { + for (File file : files) { + deleteFolder(file); + } + } + } + if (!folder.delete()) { + System.err.println("无法删除文件夹: " + folder.getAbsolutePath()); + } + } +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/enums/AuditStatus.java b/ruoyi-common/src/main/java/com/ruoyi/common/enums/AuditStatus.java index 7ae7c02..aa9876c 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/enums/AuditStatus.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/enums/AuditStatus.java @@ -14,6 +14,7 @@ public enum AuditStatus AUDIT("1", "待审核"), PASS("2", "已同意"), REFUSE("3", "已拒绝"), + READ("5","已读(针对日报的筛选实际数据库中的值为1)"), ; private final String code; diff --git a/ruoyi-system/src/main/java/com/ruoyi/bgt/domain/dto/BgtMessageDetailDTO.java b/ruoyi-system/src/main/java/com/ruoyi/bgt/domain/dto/BgtMessageDetailDTO.java index 7818cb1..3e4acd8 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/bgt/domain/dto/BgtMessageDetailDTO.java +++ b/ruoyi-system/src/main/java/com/ruoyi/bgt/domain/dto/BgtMessageDetailDTO.java @@ -40,4 +40,7 @@ public class BgtMessageDetailDTO { @ApiModelProperty("小类型(字典bgt_message_small_type)") private String messageSmallType; + @ApiModelProperty("是否待处理") + private Boolean isHandle; + } diff --git a/ruoyi-system/src/main/java/com/ruoyi/bgt/service/IBgtProjectRecruitApplyService.java b/ruoyi-system/src/main/java/com/ruoyi/bgt/service/IBgtProjectRecruitApplyService.java index 600e463..3a50f4c 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/bgt/service/IBgtProjectRecruitApplyService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/bgt/service/IBgtProjectRecruitApplyService.java @@ -109,6 +109,10 @@ public interface IBgtProjectRecruitApplyService extends IServicePlus queryDTOPage = new Page<>(); queryDTOPage.setCurrent(dto.getPageNum()); queryDTOPage.setSize(dto.getPageSize()); - if( "5".equals(dto.getAuditorType()) ){ + if( AuditStatus.READ.getCode().equals(dto.getAuditorType()) ){ dto.setIsRead(true); } - if( "1".equals(dto.getAuditorType()) ){ + if( AuditStatus.AUDIT.getCode().equals(dto.getAuditorType()) ){ dto.setIsAudit(true); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/wgz/service/impl/WgzLeaveServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/wgz/service/impl/WgzLeaveServiceImpl.java index e44ab9a..893957f 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wgz/service/impl/WgzLeaveServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wgz/service/impl/WgzLeaveServiceImpl.java @@ -215,7 +215,7 @@ public class WgzLeaveServiceImpl extends ServicePlusImpl