优化
This commit is contained in:
@ -67,6 +67,15 @@ public class AppBgtMessageController extends BaseController {
|
||||
return AjaxResult.success(iBgtMessageService.updateById(bgtMessage));
|
||||
}
|
||||
|
||||
@ApiOperation("已操作")
|
||||
@PutMapping("/operation/{id}")
|
||||
public AjaxResult<Boolean> operation(@PathVariable(value = "id") Long id) {
|
||||
BgtMessage bgtMessage = new BgtMessage();
|
||||
bgtMessage.setId(id);
|
||||
bgtMessage.setIsOperation("2");
|
||||
return AjaxResult.success(iBgtMessageService.updateById(bgtMessage));
|
||||
}
|
||||
|
||||
@ApiOperation("App务工者消息个人详情")
|
||||
@GetMapping("/userInfo")
|
||||
public AjaxResult<WgzAppPersonalBasicInformationRes> wgzMessageInformation(Long userId, Long recruitApplyId) {
|
||||
|
@ -1,7 +1,8 @@
|
||||
package com.ruoyi.web.controller.bgt;
|
||||
|
||||
import com.ruoyi.bgt.domain.dto.BgtReissueacardListDTO;
|
||||
import com.ruoyi.bgt.domain.dto.BgtAuditListDTO;
|
||||
import com.ruoyi.bgt.domain.dto.BgtReissueacardUpdateDTO;
|
||||
import com.ruoyi.bgt.domain.vo.BgtAuditResultVO;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.annotation.RepeatSubmit;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
@ -9,7 +10,7 @@ import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.wgz.bo.res.WgzAppUserReplacementCardRecordDetailsRes;
|
||||
import com.ruoyi.wgz.bo.res.WgzReplacementCardRecordRes;
|
||||
import com.ruoyi.wgz.service.IWgzLeaveService;
|
||||
import com.ruoyi.wgz.service.IWgzReissueacardService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@ -36,13 +37,21 @@ public class AppBgtReissueacardController extends BaseController {
|
||||
|
||||
private final IWgzReissueacardService iWgzReissueacardService;
|
||||
|
||||
private final IWgzLeaveService iWgzLeaveService;
|
||||
|
||||
/**
|
||||
* 查询补卡申请列表
|
||||
*/
|
||||
@ApiOperation("查询补卡申请列表")
|
||||
@ApiOperation("查询审批申请列表")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<WgzReplacementCardRecordRes> list(@Validated BgtReissueacardListDTO dto) {
|
||||
return iWgzReissueacardService.appQueryPageList(dto);
|
||||
public TableDataInfo<BgtAuditResultVO> list(@Validated BgtAuditListDTO dto) {
|
||||
TableDataInfo<BgtAuditResultVO> result = new TableDataInfo<>();
|
||||
if(dto.getDataType().equals("1")){
|
||||
result = iWgzReissueacardService.appQueryPageList(dto);
|
||||
} else if (dto.getDataType().equals("2")) {
|
||||
result = iWgzLeaveService.bgtLeaveAudit(dto);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
@ -0,0 +1,192 @@
|
||||
package com.ruoyi.web.controller.common;
|
||||
|
||||
import com.ruoyi.bgt.domain.BgtProjectRecruit;
|
||||
import com.ruoyi.bgt.domain.dto.BgtUploadDTO;
|
||||
import com.ruoyi.bgt.service.IBgtProjectRecruitService;
|
||||
import com.ruoyi.wgz.domain.WgzUser;
|
||||
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.core.io.FileSystemResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
/**
|
||||
* 登录验证
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Api(value = "网页模板下载", tags = {"网页模板下载"})
|
||||
@RequiredArgsConstructor(onConstructor_ = @Autowired)
|
||||
@RestController
|
||||
public class TemplateDownloadController {
|
||||
|
||||
@Autowired
|
||||
private IWgzUserService wgzUserService;
|
||||
|
||||
@Autowired
|
||||
private IBgtProjectRecruitService recruitService;
|
||||
|
||||
private static final String TEMP_DIR = "ruoyi/uploadPath/temporary";
|
||||
|
||||
@ApiOperation("下载模板")
|
||||
@PostMapping("/download-folders")
|
||||
public ResponseEntity<Resource> downloadFolders(@RequestBody BgtUploadDTO dto) {
|
||||
|
||||
BgtProjectRecruit recruit = recruitService.queryById(dto.getRecruitId());
|
||||
String firstLevelFolderName = recruit.getId() + "_" + recruit.getRecruitName();
|
||||
File baseDir = new File(TEMP_DIR);
|
||||
File folderToZip = new File(baseDir, firstLevelFolderName);
|
||||
File zipFile = new File(baseDir, folderToZip.getName() + ".zip");
|
||||
|
||||
// 在生成文件夹和压缩文件之前,检查并删除已存在的文件夹和压缩文件
|
||||
if (folderToZip.exists()) {
|
||||
deleteFolder(folderToZip);
|
||||
}
|
||||
if (zipFile.exists()) {
|
||||
if (!zipFile.delete()) {
|
||||
System.err.println("无法删除已存在的压缩文件: " + zipFile.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
generateFolders(dto);
|
||||
try {
|
||||
zipFolder(folderToZip, zipFile);
|
||||
System.out.println("文件夹已压缩为: " + zipFile.getName());
|
||||
|
||||
Resource resource = new FileSystemResource(zipFile);
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.add(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=" + zipFile.getName());
|
||||
|
||||
ResponseEntity<Resource> response = ResponseEntity.ok()
|
||||
.headers(headers)
|
||||
.contentLength(zipFile.length())
|
||||
.contentType(MediaType.APPLICATION_OCTET_STREAM)
|
||||
.body(resource);
|
||||
|
||||
return response;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return ResponseEntity.status(500).body(null);
|
||||
}
|
||||
}
|
||||
|
||||
public void generateFolders(BgtUploadDTO dto) {
|
||||
List<Long> userIds = dto.getUserIds();
|
||||
|
||||
// 获取招工名
|
||||
BgtProjectRecruit recruit = recruitService.queryById(dto.getRecruitId());
|
||||
// 第一层文件夹名
|
||||
String firstLevelFolderName = recruit.getId() + "_" + recruit.getRecruitName();
|
||||
File baseDir = new File(TEMP_DIR);
|
||||
if (!baseDir.exists()) {
|
||||
if (!baseDir.mkdirs()) {
|
||||
System.err.println("无法创建基础目录: " + TEMP_DIR);
|
||||
return;
|
||||
}
|
||||
}
|
||||
File firstLevelFolder = new File(baseDir, firstLevelFolderName);
|
||||
if (!firstLevelFolder.exists()) {
|
||||
if (firstLevelFolder.mkdirs()) {
|
||||
System.out.println("创建第一层文件夹: " + firstLevelFolderName);
|
||||
} else {
|
||||
System.err.println("无法创建第一层文件夹: " + firstLevelFolderName);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// 遍历每个用户 ID
|
||||
for (Long userId : userIds) {
|
||||
// 获取用户信息
|
||||
WgzUser wgzUser = wgzUserService.findByUserId(userId);
|
||||
String userName = wgzUser.getUsername();
|
||||
String idCard = wgzUser.getIdentityCard();
|
||||
// 第二层文件夹名
|
||||
String secondLevelFolderName = userName + "_" + idCard;
|
||||
File secondLevelFolder = new File(firstLevelFolder, secondLevelFolderName);
|
||||
if (!secondLevelFolder.exists()) {
|
||||
if (secondLevelFolder.mkdirs()) {
|
||||
System.out.println("创建第二层文件夹: " + secondLevelFolderName);
|
||||
} else {
|
||||
System.err.println("无法创建第二层文件夹: " + secondLevelFolderName);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// 创建第三层的两个固定文件夹
|
||||
String[] thirdLevelFolderNames = {"劳务合同", "保险"};
|
||||
for (String thirdLevelFolderName : thirdLevelFolderNames) {
|
||||
File thirdLevelFolder = new File(secondLevelFolder, thirdLevelFolderName);
|
||||
if (!thirdLevelFolder.exists()) {
|
||||
if (thirdLevelFolder.mkdirs()) {
|
||||
System.out.println("创建第三层文件夹: " + thirdLevelFolderName);
|
||||
} else {
|
||||
System.err.println("无法创建第三层文件夹: " + thirdLevelFolderName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void zipFolder(File folder, File zipFile) throws IOException {
|
||||
try (ZipOutputStream zipOut = new ZipOutputStream(new FileOutputStream(zipFile))) {
|
||||
// 添加根文件夹
|
||||
zipOut.putNextEntry(new ZipEntry(folder.getName() + "/"));
|
||||
zipOut.closeEntry();
|
||||
zipFilesInFolder(folder, folder.getName(), zipOut);
|
||||
}
|
||||
}
|
||||
|
||||
private static void zipFilesInFolder(File folder, String parentPath, ZipOutputStream zipOut) throws IOException {
|
||||
File[] files = folder.listFiles();
|
||||
if (files != null) {
|
||||
for (File file : files) {
|
||||
if (file.isDirectory()) {
|
||||
// 添加文件夹条目
|
||||
zipOut.putNextEntry(new ZipEntry(parentPath + "/" + file.getName() + "/"));
|
||||
zipOut.closeEntry();
|
||||
zipFilesInFolder(file, parentPath + "/" + file.getName(), zipOut);
|
||||
} else {
|
||||
ZipEntry zipEntry = new ZipEntry(parentPath + "/" + file.getName());
|
||||
zipOut.putNextEntry(zipEntry);
|
||||
try (FileInputStream fis = new FileInputStream(file)) {
|
||||
byte[] bytes = new byte[1024];
|
||||
int length;
|
||||
while ((length = fis.read(bytes)) >= 0) {
|
||||
zipOut.write(bytes, 0, length);
|
||||
}
|
||||
}
|
||||
zipOut.closeEntry();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user