update:修改工作组全部文件导出的接口

This commit is contained in:
sunzheng
2024-07-11 14:05:05 +08:00
parent 9aba47aae2
commit fe0884fd47
3 changed files with 44 additions and 15 deletions
@@ -466,11 +466,11 @@ public class PayWorkingGroupController extends JeroController<PayWorkingGroup, I
* @param request
* @param response
*/
@RequiresPermissions("workingGroupMember:exportAllFile")
@RequiresPermissions("workingGroupProject:exportAllFile")
@ApiOperation(value="全部文件导出", notes="全部文件导出")
@GetMapping(value = "/exportAllFile")
public void exportAllFile(HttpServletRequest request, HttpServletResponse response) {
payWorkingGroupService.exportAllFile(request, response);
public void exportAllFile(HttpServletRequest request, HttpServletResponse response, PayWorkingGroup payWorkingGroup) {
payWorkingGroupService.exportAllFile(request, response, payWorkingGroup);
}
}
@@ -255,5 +255,5 @@ public interface IPayWorkingGroupService extends IService<PayWorkingGroup> {
* @param request
* @param response
*/
void exportAllFile(HttpServletRequest request, HttpServletResponse response);
void exportAllFile(HttpServletRequest request, HttpServletResponse response, PayWorkingGroup payWorkingGroup);
}
@@ -15,11 +15,13 @@ import com.jero.common.exception.JeroBootException;
import com.jero.common.service.ContractCreateProjectSendMessageService;
import com.jero.common.service.RolePermissionService;
import com.jero.common.system.vo.LoginUser;
import com.jero.common.util.oConvertUtils;
import com.jero.company.entity.PayContactsManagement;
import com.jero.company.service.IPayContactsManagementService;
import com.jero.config.StaticConfig;
import com.jero.contract.entity.PayIncomeContractAssociated;
import com.jero.contract.service.IPayIncomeContractAssociatedService;
import com.jero.mail.commont.constant;
import com.jero.meeting.common.MeetingCommon;
import com.jero.meeting.entity.PayMeeting;
import com.jero.meeting.service.IPayMeetingService;
@@ -826,14 +828,41 @@ public class PayWorkingGroupServiceImpl extends ServiceImpl<PayWorkingGroupMappe
* @param response
*/
@Override
public void exportAllFile(HttpServletRequest request, HttpServletResponse response) {
String selections = request.getParameter("selections");
if (StringUtils.isEmpty(selections)) {
throw new JeroBootException("至少选择一个工作组项目");
public void exportAllFile(HttpServletRequest request, HttpServletResponse response, PayWorkingGroup payWorkingGroup) {
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
if (StringUtils.isNotBlank(sysUser.getRoleCode())){
List<String> roleCodes = new ArrayList<>(Arrays.asList(sysUser.getRoleCode().split(",")));
//管理员和财务查询全部,其余角色查询自己的
if(!roleCodes.contains(constant.ADMIN)&&!roleCodes.contains(constant.CWRY)){
payWorkingGroup.setPrincipalA(sysUser.getId());
payWorkingGroup.setPrincipalB(sysUser.getId());
}
} else {
throw new JeroBootException("登录用户角色为空!");
}
List<String> selectionList = Arrays.asList(selections.split(","));
Set<String> addedEntries = new HashSet<>(); // 用于记录已添加的条目路径
// 创建一个不分页的 Page 对象
Page<PayWorkingGroupVO> page = new Page<>(-1, -1);
// 处理 workingGroupProject 字段
String workingGroupProject = payWorkingGroup.getWorkingGroupProject();
if (StringUtils.isNotBlank(workingGroupProject)) {
payWorkingGroup.setWorkingGroupProject(oConvertUtils.replaceAllPercent(workingGroupProject));
}
// 查询分页列表
List<PayWorkingGroupVO> pageList = payWorkingGroupService.queryPageList(page, payWorkingGroup).getRecords();
// 获取前端传递的 selections 参数
String selections = request.getParameter("selections");
List<String> ids = pageList.stream()
.map(PayWorkingGroupVO::getId)
.collect(Collectors.toList());
if (oConvertUtils.isNotEmpty(selections)) {
List<String> selectionList = Arrays.asList(selections.split(","));
ids.retainAll(selectionList); // 仅保留在 selections 中的 id
}
if (oConvertUtils.isEmpty(ids)) {
throw new JeroBootException("没有工作组文件可以导出!");
}
Set<String> addedEntries = new HashSet<>(); // 用于记录已添加的条目路径
try (ZipOutputStream zipos = new ZipOutputStream(new BufferedOutputStream(response.getOutputStream()))) {
response.reset();
response.setCharacterEncoding("utf-8");
@@ -853,16 +882,16 @@ public class PayWorkingGroupServiceImpl extends ServiceImpl<PayWorkingGroupMappe
response.setHeader("Content-Disposition", "attachment;fileName=\"" + downloadName + "\"");
// 处理工作组资料
for (String projectId : selectionList) {
for (String projectId : ids) {
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) {
PayWorkingGroup payWorkingGroupDB = payWorkingGroupService.getById(projectId);
if (payWorkingGroupDB == null) {
throw new JeroBootException("工作组不存在!");
}
String groupName = payWorkingGroup.getWorkingGroupProject(); // 获取工作组名称
String groupName = payWorkingGroupDB.getWorkingGroupProject(); // 获取工作组名称
String groupFolderPath = "工作组资料/" + groupName + "/";
String researchProjectFolderPath = groupFolderPath + "在研项目/";
String otherFilesFolderPath = groupFolderPath + "其他分发资料/";
@@ -959,7 +988,7 @@ public class PayWorkingGroupServiceImpl extends ServiceImpl<PayWorkingGroupMappe
}
// 处理工作组会议资料
for (String projectId : selectionList) {
for (String projectId : ids) {
LambdaQueryWrapper<PayMeeting> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(PayMeeting::getWorkingGroupId, projectId);
lambdaQueryWrapper.eq(PayMeeting::getMeetingType, MeetingCommon.WORKING_GROUP_MEETING_INT);