add:工作组-全部文件导出的接口
This commit is contained in:
+14
-7
@@ -17,7 +17,6 @@ import com.jero.common.util.oConvertUtils;
|
|||||||
import com.jero.contract.entity.PayIncomeContract;
|
import com.jero.contract.entity.PayIncomeContract;
|
||||||
import com.jero.contract.service.IPayIncomeContractService;
|
import com.jero.contract.service.IPayIncomeContractService;
|
||||||
import com.jero.mail.commont.constant;
|
import com.jero.mail.commont.constant;
|
||||||
import com.jero.meeting.entity.PayMeetingQuestion;
|
|
||||||
import com.jero.project.common.PayProjectCommon;
|
import com.jero.project.common.PayProjectCommon;
|
||||||
import com.jero.project.entity.PayWorkingGroup;
|
import com.jero.project.entity.PayWorkingGroup;
|
||||||
import com.jero.project.entity.PayWorkingGroupSubItem;
|
import com.jero.project.entity.PayWorkingGroupSubItem;
|
||||||
@@ -34,18 +33,14 @@ import org.apache.shiro.SecurityUtils;
|
|||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description: 工作组项目
|
* @Description: 工作组项目
|
||||||
* @Author: jeecg-boot
|
* @Author: jeecg-boot
|
||||||
* @Date: 2021-08-27
|
* @Date: 2021-08-27
|
||||||
@@ -466,4 +461,16 @@ public class PayWorkingGroupController extends JeroController<PayWorkingGroup, I
|
|||||||
return super.importExcel(request, response, PayWorkingGroup.class);
|
return super.importExcel(request, response, PayWorkingGroup.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 全部文件导出
|
||||||
|
* @param request
|
||||||
|
* @param response
|
||||||
|
*/
|
||||||
|
// @RequiresPermissions("workingGroupProject:exportAllFile")
|
||||||
|
@ApiOperation(value="全部文件导出", notes="全部文件导出")
|
||||||
|
@GetMapping(value = "/exportAllFile")
|
||||||
|
public void exportAllFile(HttpServletRequest request, HttpServletResponse response) {
|
||||||
|
payWorkingGroupService.exportAllFile(request, response);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-1
@@ -9,7 +9,8 @@ import com.jero.project.vo.PayWorkingGroupVO;
|
|||||||
import com.jero.project.entity.PayWorkingGroup;
|
import com.jero.project.entity.PayWorkingGroup;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.jero.statistics.entity.*;
|
import com.jero.statistics.entity.*;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -248,4 +249,11 @@ public interface IPayWorkingGroupService extends IService<PayWorkingGroup> {
|
|||||||
* @param payWorkingGroupSubItem 工作组成员
|
* @param payWorkingGroupSubItem 工作组成员
|
||||||
*/
|
*/
|
||||||
void validAndSetDefaultValue(PayWorkingGroupSubItem payWorkingGroupSubItem);
|
void validAndSetDefaultValue(PayWorkingGroupSubItem payWorkingGroupSubItem);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 全部文件导出
|
||||||
|
* @param request
|
||||||
|
* @param response
|
||||||
|
*/
|
||||||
|
void exportAllFile(HttpServletRequest request, HttpServletResponse response);
|
||||||
}
|
}
|
||||||
|
|||||||
+224
-1
@@ -23,6 +23,8 @@ import com.jero.contract.service.IPayIncomeContractAssociatedService;
|
|||||||
import com.jero.meeting.common.MeetingCommon;
|
import com.jero.meeting.common.MeetingCommon;
|
||||||
import com.jero.meeting.entity.PayMeeting;
|
import com.jero.meeting.entity.PayMeeting;
|
||||||
import com.jero.meeting.service.IPayMeetingService;
|
import com.jero.meeting.service.IPayMeetingService;
|
||||||
|
import com.jero.modules.oss.entity.OSSFile;
|
||||||
|
import com.jero.modules.oss.service.IOSSFileService;
|
||||||
import com.jero.modules.system.entity.SysUser;
|
import com.jero.modules.system.entity.SysUser;
|
||||||
import com.jero.modules.system.service.ISysUserService;
|
import com.jero.modules.system.service.ISysUserService;
|
||||||
import com.jero.project.common.PayProjectCommon;
|
import com.jero.project.common.PayProjectCommon;
|
||||||
@@ -30,6 +32,7 @@ import com.jero.project.entity.*;
|
|||||||
import com.jero.project.mapper.PayWorkingGroupMapper;
|
import com.jero.project.mapper.PayWorkingGroupMapper;
|
||||||
import com.jero.project.mapper.PayWorkingGroupSubItemContactsMapper;
|
import com.jero.project.mapper.PayWorkingGroupSubItemContactsMapper;
|
||||||
import com.jero.project.service.IPayResearchProjectService;
|
import com.jero.project.service.IPayResearchProjectService;
|
||||||
|
import com.jero.project.service.IPayWorkingGroupDataFileService;
|
||||||
import com.jero.project.service.IPayWorkingGroupService;
|
import com.jero.project.service.IPayWorkingGroupService;
|
||||||
import com.jero.project.service.IPayWorkingGroupSubItemService;
|
import com.jero.project.service.IPayWorkingGroupSubItemService;
|
||||||
import com.jero.project.vo.PayWorkingGroupVO;
|
import com.jero.project.vo.PayWorkingGroupVO;
|
||||||
@@ -43,16 +46,21 @@ import org.apache.commons.lang3.ObjectUtils;
|
|||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.shiro.SecurityUtils;
|
import org.apache.shiro.SecurityUtils;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.*;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.zip.ZipEntry;
|
||||||
|
import java.util.zip.ZipOutputStream;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -89,6 +97,12 @@ public class PayWorkingGroupServiceImpl extends ServiceImpl<PayWorkingGroupMappe
|
|||||||
private PayWorkingGroupSubItemContactsMapper payWorkingGroupSubItemContactsMapper;
|
private PayWorkingGroupSubItemContactsMapper payWorkingGroupSubItemContactsMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private IPayMeetingService payMeetingService;
|
private IPayMeetingService payMeetingService;
|
||||||
|
@Resource
|
||||||
|
private IPayWorkingGroupDataFileService payWorkingGroupDataFileService;
|
||||||
|
@Resource
|
||||||
|
private IOSSFileService iossFileService;
|
||||||
|
@Value("${jero.path.upload}")
|
||||||
|
private String upLoadPath;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IPage<PayWorkingGroupVO> queryPageList(Page<PayWorkingGroupVO> page, PayWorkingGroup payWorkingGroup) {
|
public IPage<PayWorkingGroupVO> queryPageList(Page<PayWorkingGroupVO> page, PayWorkingGroup payWorkingGroup) {
|
||||||
@@ -805,5 +819,214 @@ public class PayWorkingGroupServiceImpl extends ServiceImpl<PayWorkingGroupMappe
|
|||||||
return yearMonthList;
|
return yearMonthList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 全部文件导出
|
||||||
|
*
|
||||||
|
* @param request
|
||||||
|
* @param response
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void exportAllFile(HttpServletRequest request, HttpServletResponse response) {
|
||||||
|
String selections = request.getParameter("selections");
|
||||||
|
if (StringUtils.isEmpty(selections)) {
|
||||||
|
throw new JeroBootException("至少选择一个工作组项目");
|
||||||
|
}
|
||||||
|
List<String> selectionList = Arrays.asList(selections.split(","));
|
||||||
|
Set<String> addedEntries = new HashSet<>(); // 用于记录已添加的条目路径
|
||||||
|
|
||||||
|
try (ZipOutputStream zipos = new ZipOutputStream(new BufferedOutputStream(response.getOutputStream()))) {
|
||||||
|
response.reset();
|
||||||
|
response.setCharacterEncoding("utf-8");
|
||||||
|
response.setContentType("multipart/form-data");
|
||||||
|
// 设置压缩包的名字
|
||||||
|
String downloadName = UUID.randomUUID().toString() + ".zip";
|
||||||
|
String agent = request.getHeader("USER-AGENT");
|
||||||
|
try {
|
||||||
|
if (agent.contains("MSIE") || agent.contains("Trident")) {
|
||||||
|
downloadName = java.net.URLEncoder.encode(downloadName, "UTF-8");
|
||||||
|
} else {
|
||||||
|
downloadName = new String(downloadName.getBytes("UTF-8"), "ISO-8859-1");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
response.setHeader("Content-Disposition", "attachment;fileName=\"" + downloadName + "\"");
|
||||||
|
|
||||||
|
// 处理工作组资料
|
||||||
|
for (String projectId : selectionList) {
|
||||||
|
PayWorkingGroupDataFile payWorkingGroupDataFile = new PayWorkingGroupDataFile();
|
||||||
|
payWorkingGroupDataFile.setProjectId(projectId);
|
||||||
|
payWorkingGroupDataFile.setProjectType(PayProjectCommon.PROJECT_TYPE_FILE1);
|
||||||
|
List<PayWorkingGroupDataFile> fileList = payWorkingGroupDataFileService.queryListExport(payWorkingGroupDataFile);
|
||||||
|
PayWorkingGroup payWorkingGroup = payWorkingGroupService.getById(projectId);
|
||||||
|
if (payWorkingGroup == null) {
|
||||||
|
throw new JeroBootException("工作组不存在!");
|
||||||
|
}
|
||||||
|
String groupName = payWorkingGroup.getWorkingGroupProject(); // 获取工作组名称
|
||||||
|
String groupFolderPath = "工作组资料/" + groupName + "/";
|
||||||
|
String researchProjectFolderPath = groupFolderPath + "在研项目/";
|
||||||
|
String otherFilesFolderPath = groupFolderPath + "其他分发资料/";
|
||||||
|
|
||||||
|
// 创建工作组文件夹
|
||||||
|
zipos.putNextEntry(new ZipEntry(groupFolderPath));
|
||||||
|
zipos.closeEntry();
|
||||||
|
// 创建在研项目文件夹
|
||||||
|
zipos.putNextEntry(new ZipEntry(researchProjectFolderPath));
|
||||||
|
zipos.closeEntry();
|
||||||
|
// 创建分发资料文件夹
|
||||||
|
zipos.putNextEntry(new ZipEntry(otherFilesFolderPath));
|
||||||
|
zipos.closeEntry();
|
||||||
|
|
||||||
|
// 在研项目的文件
|
||||||
|
LambdaQueryWrapper<PayResearchProject> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(PayResearchProject::getWorkingGroupId, projectId);
|
||||||
|
List<PayResearchProject> payResearchProjectList = payResearchProjectService.list(queryWrapper);
|
||||||
|
for (PayResearchProject payResearchProject : payResearchProjectList) {
|
||||||
|
String projectName = payResearchProject.getProjectName();
|
||||||
|
String projectFolderPath = researchProjectFolderPath + projectName + "/";
|
||||||
|
|
||||||
|
// 创建在研项目名文件夹
|
||||||
|
zipos.putNextEntry(new ZipEntry(projectFolderPath));
|
||||||
|
zipos.closeEntry();
|
||||||
|
|
||||||
|
List<String> researchProjectFileIds = new ArrayList<>();
|
||||||
|
if (!StringUtils.isEmpty(payResearchProject.getFiles())) {
|
||||||
|
researchProjectFileIds.addAll(Arrays.asList(payResearchProject.getFiles().split(",")));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 添加在研项目的文件到在研项目名文件夹
|
||||||
|
for (String fileId : researchProjectFileIds) {
|
||||||
|
OSSFile ossFile = iossFileService.getById(fileId.trim());
|
||||||
|
if (ossFile == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
File file = new File(upLoadPath + File.separator + ossFile.getUrl());
|
||||||
|
if (!file.exists()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String entryPath = projectFolderPath + ossFile.getFileName();
|
||||||
|
// 检查是否已经添加过相同路径的条目
|
||||||
|
if (addedEntries.contains(entryPath)) {
|
||||||
|
// 如果已经存在相同路径的条目,可以修改文件名或者跳过处理
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// 添加到压缩包中
|
||||||
|
zipos.putNextEntry(new ZipEntry(entryPath));
|
||||||
|
try (InputStream is = new FileInputStream(file)) {
|
||||||
|
byte[] b = new byte[1024];
|
||||||
|
int length;
|
||||||
|
while ((length = is.read(b)) != -1) {
|
||||||
|
zipos.write(b, 0, length);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
zipos.closeEntry(); // 关闭当前条目
|
||||||
|
addedEntries.add(entryPath); // 记录已添加的条目路径
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 添加工作组资料文件到分发资料文件夹
|
||||||
|
for (PayWorkingGroupDataFile dataFile : fileList) {
|
||||||
|
OSSFile ossFile = iossFileService.getById(dataFile.getFileId());
|
||||||
|
if (ossFile == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
File file = new File(upLoadPath + File.separator + ossFile.getUrl());
|
||||||
|
if (!file.exists()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String entryPath = otherFilesFolderPath + ossFile.getFileName();
|
||||||
|
// 检查是否已经添加过相同路径的条目
|
||||||
|
if (addedEntries.contains(entryPath)) {
|
||||||
|
// 如果已经存在相同路径的条目,可以修改文件名或者跳过处理
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// 添加到压缩包中
|
||||||
|
zipos.putNextEntry(new ZipEntry(entryPath));
|
||||||
|
try (InputStream is = new FileInputStream(file)) {
|
||||||
|
byte[] b = new byte[1024];
|
||||||
|
int length;
|
||||||
|
while ((length = is.read(b)) != -1) {
|
||||||
|
zipos.write(b, 0, length);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
zipos.closeEntry(); // 关闭当前条目
|
||||||
|
addedEntries.add(entryPath); // 记录已添加的条目路径
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理工作组会议资料
|
||||||
|
for (String projectId : selectionList) {
|
||||||
|
LambdaQueryWrapper<PayMeeting> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
lambdaQueryWrapper.eq(PayMeeting::getWorkingGroupId, projectId);
|
||||||
|
lambdaQueryWrapper.eq(PayMeeting::getMeetingType, MeetingCommon.WORKING_GROUP_MEETING_INT);
|
||||||
|
List<PayMeeting> list = payMeetingService.list(lambdaQueryWrapper);
|
||||||
|
for (PayMeeting payMeeting : list) {
|
||||||
|
String meetingName = payMeeting.getMeetingName();
|
||||||
|
String meetingFolderPath = "会议资料/" + meetingName + "/";
|
||||||
|
String meetingMinutesFolderPath = meetingFolderPath + "会议纪要/";
|
||||||
|
String meetingDataFolderPath = meetingFolderPath + "上传文件/";
|
||||||
|
|
||||||
|
// 创建会议文件夹
|
||||||
|
zipos.putNextEntry(new ZipEntry(meetingFolderPath));
|
||||||
|
zipos.closeEntry();
|
||||||
|
// 创建会议纪要文件夹
|
||||||
|
zipos.putNextEntry(new ZipEntry(meetingMinutesFolderPath));
|
||||||
|
zipos.closeEntry();
|
||||||
|
// 创建上传文件文件夹
|
||||||
|
zipos.putNextEntry(new ZipEntry(meetingDataFolderPath));
|
||||||
|
zipos.closeEntry();
|
||||||
|
|
||||||
|
List<String> fileIds = new ArrayList<>();
|
||||||
|
if (!StringUtils.isEmpty(payMeeting.getMeetingMinute())) {
|
||||||
|
fileIds.addAll(Arrays.asList(payMeeting.getMeetingMinute().split(",")));
|
||||||
|
}
|
||||||
|
if (!StringUtils.isEmpty(payMeeting.getMeetingData())) {
|
||||||
|
fileIds.addAll(Arrays.asList(payMeeting.getMeetingData().split(",")));
|
||||||
|
}
|
||||||
|
for (String fileId : fileIds) {
|
||||||
|
OSSFile ossFile = iossFileService.getById(fileId.trim());
|
||||||
|
if (ossFile == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
File file = new File(upLoadPath + File.separator + ossFile.getUrl());
|
||||||
|
if (!file.exists()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// 根据文件类型,放入对应的文件夹
|
||||||
|
String entryPath;
|
||||||
|
if (payMeeting.getMeetingMinute() != null && Arrays.asList(payMeeting.getMeetingMinute().split(",")).contains(fileId)) {
|
||||||
|
entryPath = meetingMinutesFolderPath + ossFile.getFileName();
|
||||||
|
} else {
|
||||||
|
entryPath = meetingDataFolderPath + ossFile.getFileName();
|
||||||
|
}
|
||||||
|
// 检查是否已经添加过相同路径的条目
|
||||||
|
if (addedEntries.contains(entryPath)) {
|
||||||
|
// 如果已经存在相同路径的条目,可以修改文件名或者跳过处理
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// 添加到压缩包中
|
||||||
|
zipos.putNextEntry(new ZipEntry(entryPath));
|
||||||
|
try (InputStream is = new FileInputStream(file)) {
|
||||||
|
byte[] b = new byte[1024];
|
||||||
|
int length;
|
||||||
|
while ((length = is.read(b)) != -1) {
|
||||||
|
zipos.write(b, 0, length);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
zipos.closeEntry(); // 关闭当前条目
|
||||||
|
addedEntries.add(entryPath); // 记录已添加的条目路径
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
zipos.flush();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user