update:修改社团管理导出全部压缩包的层级

This commit is contained in:
sunzheng
2024-10-10 10:23:52 +08:00
parent 2225925ed8
commit ee647da320
9 changed files with 102 additions and 76 deletions
@@ -48,7 +48,7 @@ public class LawsClubJoinTeam implements Serializable {
@ApiModelProperty(value = "社团职务担任者id") @ApiModelProperty(value = "社团职务担任者id")
@Dict(dictTable = "sys_user", dicCode = "id", dicText = "realname") @Dict(dictTable = "sys_user", dicCode = "id", dicText = "realname")
@Excel(name = "社团职务担任者", width = 20) @Excel(name = "社团职务担任者", width = 20, dictTable = "sys_user", dicCode = "id", dicText = "CONCAT(realname, '(', username, ')')")
private String leadId; private String leadId;
@ApiModelProperty(value = "入团经费") @ApiModelProperty(value = "入团经费")
@@ -70,8 +70,8 @@ public class LawsClubJoinTeam implements Serializable {
private String specializedModule; private String specializedModule;
@ApiModelProperty(value = "申请人的id") @ApiModelProperty(value = "申请人的id")
@Excel(name = "申请人", width = 20)
@Dict(dictTable = "sys_user", dicCode = "id", dicText = "realname") @Dict(dictTable = "sys_user", dicCode = "id", dicText = "realname")
@Excel(name = "申请人", width = 20, dictTable = "sys_user", dicCode = "id", dicText = "CONCAT(realname, '(', username, ')')")
private String proposerId; private String proposerId;
@ApiModelProperty(value = "秘书处") @ApiModelProperty(value = "秘书处")
@@ -69,7 +69,7 @@ public class LawsClubMeeting implements Serializable {
@ApiModelProperty(value = "通知人id") @ApiModelProperty(value = "通知人id")
@Dict(dictTable = "sys_user", dicCode = "id", dicText = "realname") @Dict(dictTable = "sys_user", dicCode = "id", dicText = "realname")
@Excel(name = "通知人", width = 20) @Excel(name = "通知人", width = 20, dictTable = "sys_user", dicCode = "id", dicText = "CONCAT(realname, '(', username, ')')")
private String notifierId; private String notifierId;
@ApiModelProperty(value = "通知部门id") @ApiModelProperty(value = "通知部门id")
@@ -40,8 +40,8 @@ public class LawsClubMeetingMember implements Serializable {
private String meetingId; private String meetingId;
@ApiModelProperty(value = "参会人员的id") @ApiModelProperty(value = "参会人员的id")
@Excel(name = "参会人员", width = 20)
@Dict(dictTable = "sys_user", dicCode = "id", dicText = "realname") @Dict(dictTable = "sys_user", dicCode = "id", dicText = "realname")
@Excel(name = "参会人员", width = 20, dictTable = "sys_user", dicCode = "id", dicText = "CONCAT(realname, '(', username, ')')")
private String memberId; private String memberId;
@@ -56,7 +56,7 @@ public class LawsClubMeetingMember implements Serializable {
private String meetingSpecializedModule; private String meetingSpecializedModule;
@ApiModelProperty(value = "参会报告文件id") @ApiModelProperty(value = "参会报告文件id")
@Excel(name = "参会报告文件", width = 20, dictTable = "oss_file", dicCode = "id", dicText = "file_name") @Excel(name = "参会报告文件", width = 20)
@Dict(dictTable = "oss_file", dicCode = "id", dicText = "file_name") @Dict(dictTable = "oss_file", dicCode = "id", dicText = "file_name")
private String meetingFileId; private String meetingFileId;
@@ -62,7 +62,7 @@ public class LawsClubResearchInformation implements Serializable {
@ApiModelProperty(value = "专业接口人") @ApiModelProperty(value = "专业接口人")
@Dict(dictTable = "sys_user", dicCode = "id", dicText = "realname") @Dict(dictTable = "sys_user", dicCode = "id", dicText = "realname")
@Excel(name = "专业接口人", width = 20) @Excel(name = "专业接口人", width = 20, dictTable = "sys_user", dicCode = "id", dicText = "CONCAT(realname, '(', username, ')')")
private String specializedInterfacePerson; private String specializedInterfacePerson;
@ApiModelProperty(value = "专业模块") @ApiModelProperty(value = "专业模块")
@@ -71,8 +71,8 @@ public class LawsClubResearchInformation implements Serializable {
private String specializedModule; private String specializedModule;
@ApiModelProperty(value = "反馈人") @ApiModelProperty(value = "反馈人")
@Excel(name = "反馈人", width = 20)
@Dict(dictTable = "sys_user", dicCode = "id", dicText = "realname") @Dict(dictTable = "sys_user", dicCode = "id", dicText = "realname")
@Excel(name = "反馈人", width = 20, dictTable = "sys_user", dicCode = "id", dicText = "CONCAT(realname, '(', username, ')')")
private String feedbackPerson; private String feedbackPerson;
@ApiModelProperty(value = "反馈部门") @ApiModelProperty(value = "反馈部门")
@@ -42,7 +42,7 @@ public class LawsClubWorkingGroupFile implements Serializable {
@ApiModelProperty(value = "文件id") @ApiModelProperty(value = "文件id")
@Dict(dictTable = "oss_file", dicCode = "id", dicText = "file_name") @Dict(dictTable = "oss_file", dicCode = "id", dicText = "file_name")
@Excel(name = "文件名称", width = 20, dicText = "file_name", dicCode = "id", dictTable = "oss_file") @Excel(name = "文件名称", width = 20)
private String fileId; private String fileId;
@ApiModelProperty(value = "文件类型 1:报批稿 2:送审稿 3:征求意见稿 4:月报 5:咨询月报 6:会议资料 7:通知 8:其他") @ApiModelProperty(value = "文件类型 1:报批稿 2:送审稿 3:征求意见稿 4:月报 5:咨询月报 6:会议资料 7:通知 8:其他")
@@ -116,7 +116,7 @@ public class LawsClubMeetingServiceImpl extends ServiceImpl<LawsClubMeetingMappe
if(MessageUtils.getLanguage().getValue().equals(LanguageEnum.CN.getValue())){ if(MessageUtils.getLanguage().getValue().equals(LanguageEnum.CN.getValue())){
templateName = "参会信息导入模板.xls"; templateName = "参会信息导入模板.xls";
}else{ }else{
templateName = "Conference InformationImport Template.xls"; templateName = "Conference Information Import Template.xls";
} }
ZipEntry entry = new ZipEntry( templateName); ZipEntry entry = new ZipEntry( templateName);
zos.putNextEntry(entry); zos.putNextEntry(entry);
@@ -166,7 +166,7 @@ public class LawsClubMeetingServiceImpl extends ServiceImpl<LawsClubMeetingMappe
if(MessageUtils.getLanguage().getValue().equals(LanguageEnum.CN.getValue())){ if(MessageUtils.getLanguage().getValue().equals(LanguageEnum.CN.getValue())){
templateName = "参会信息导入模板.xls"; templateName = "参会信息导入模板.xls";
}else{ }else{
templateName = "Conference InformationImport Template.xls"; templateName = "Conference Information Import Template.xls";
} }
Map<String, File> unZipFileMap = ZipUtils.analyzeZipFile(file,uploadpath,templateName); Map<String, File> unZipFileMap = ZipUtils.analyzeZipFile(file,uploadpath,templateName);
saveDirectory = unZipFileMap.get("saveDirectory"); saveDirectory = unZipFileMap.get("saveDirectory");
@@ -471,55 +471,41 @@ public class LawsClubServiceImpl extends ServiceImpl<LawsClubMapper, LawsClub> i
club.setContactNumber(encryptNumber); club.setContactNumber(encryptNumber);
} }
} }
List<String> fileIdList = new ArrayList<>(); List<String> meetingFileIdList = new ArrayList<>();
List<String> userIds = new ArrayList<>(); List<String> workGroupFileIdList = new ArrayList<>();
List<String> ids = clubList.stream().map(LawsClub::getId).collect(Collectors.toList()); List<String> ids = clubList.stream().map(LawsClub::getId).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(ids)) { if (!CollectionUtils.isEmpty(ids)) {
// 入团信息 // 入团信息
lawsClubJoinTeams = lawsClubJoinTeamService.list(new LambdaQueryWrapper<LawsClubJoinTeam>().in(LawsClubJoinTeam::getClubId, ids)); lawsClubJoinTeams = lawsClubJoinTeamService.list(new LambdaQueryWrapper<LawsClubJoinTeam>().in(LawsClubJoinTeam::getClubId, ids));
List<String> leadIds = lawsClubJoinTeams.stream().map(LawsClubJoinTeam::getLeadId).filter(Objects::nonNull).collect(Collectors.toList());
List<String> proposerId = lawsClubJoinTeams.stream().map(LawsClubJoinTeam::getProposerId).filter(Objects::nonNull).collect(Collectors.toList());
userIds.addAll(leadIds);
userIds.addAll(proposerId);
// 支付信息 // 支付信息
lawsClubPayments = lawsClubPaymentService.list(new LambdaQueryWrapper<LawsClubPayment>().in(LawsClubPayment::getClubId, ids)); lawsClubPayments = lawsClubPaymentService.list(new LambdaQueryWrapper<LawsClubPayment>().in(LawsClubPayment::getClubId, ids));
// 参会信息 // 参会信息
lawsClubMeetings = lawsClubMeetingService.list(new LambdaQueryWrapper<LawsClubMeeting>().in(LawsClubMeeting::getClubId, ids)); lawsClubMeetings = lawsClubMeetingService.list(new LambdaQueryWrapper<LawsClubMeeting>().in(LawsClubMeeting::getClubId, ids));
List<String> notifierIds = lawsClubMeetings.stream().map(LawsClubMeeting::getNotifierId).filter(Objects::nonNull).collect(Collectors.toList());
userIds.addAll(notifierIds);
for (LawsClubMeeting lawsClubMeeting : lawsClubMeetings) { for (LawsClubMeeting lawsClubMeeting : lawsClubMeetings) {
List<LawsClubMeetingMember> memberList = lawsClubMeetingMemberService.list(new LambdaQueryWrapper<LawsClubMeetingMember>().eq(LawsClubMeetingMember::getMeetingId, lawsClubMeeting.getId())); List<LawsClubMeetingMember> memberList = lawsClubMeetingMemberService.list(new LambdaQueryWrapper<LawsClubMeetingMember>().eq(LawsClubMeetingMember::getMeetingId, lawsClubMeeting.getId()));
List<String> meetingFileIds = memberList.stream().map(LawsClubMeetingMember::getMeetingFileId).filter(Objects::nonNull).collect(Collectors.toList()); List<String> meetingFileIds = memberList.stream().map(LawsClubMeetingMember::getMeetingFileId).filter(Objects::nonNull).collect(Collectors.toList());
List<String> memberIds = memberList.stream().map(LawsClubMeetingMember::getMemberId).filter(Objects::nonNull).collect(Collectors.toList()); meetingFileIdList.addAll(meetingFileIds);
userIds.addAll(memberIds);
fileIdList.addAll(meetingFileIds);
lawsClubMeeting.setMeetingMemberList(memberList); lawsClubMeeting.setMeetingMemberList(memberList);
} }
// 征集调研信息 // 征集调研信息
lawsClubResearchInformations = lawsClubResearchInformationService.list(new LambdaQueryWrapper<LawsClubResearchInformation>().in(LawsClubResearchInformation::getClubId, ids)); lawsClubResearchInformations = lawsClubResearchInformationService.list(new LambdaQueryWrapper<LawsClubResearchInformation>().in(LawsClubResearchInformation::getClubId, ids));
List<String> interFacePersonIds = lawsClubResearchInformations.stream().map(LawsClubResearchInformation::getSpecializedInterfacePerson).filter(Objects::nonNull).collect(Collectors.toList());
List<String> feedBackPersonIds = lawsClubResearchInformations.stream().map(LawsClubResearchInformation::getFeedbackPerson).filter(Objects::nonNull).collect(Collectors.toList());
userIds.addAll(interFacePersonIds);
userIds.addAll(feedBackPersonIds);
// 工作组资料信息 // 工作组资料信息
lawsClubWorkingGroupFiles = lawsClubWorkingGroupFileService.list(new LambdaQueryWrapper<LawsClubWorkingGroupFile>().in(LawsClubWorkingGroupFile::getClubId, ids)); lawsClubWorkingGroupFiles = lawsClubWorkingGroupFileService.list(new LambdaQueryWrapper<LawsClubWorkingGroupFile>().in(LawsClubWorkingGroupFile::getClubId, ids));
List<String> fileIds = lawsClubWorkingGroupFiles.stream().map(LawsClubWorkingGroupFile::getFileId).filter(Objects::nonNull).collect(Collectors.toList()); List<String> fileIds = lawsClubWorkingGroupFiles.stream().map(LawsClubWorkingGroupFile::getFileId).filter(Objects::nonNull).collect(Collectors.toList());
fileIdList.addAll(fileIds); workGroupFileIdList.addAll(fileIds);
// 赋值用户相关字段,变为真实姓名(工作)的格式 for (LawsClubWorkingGroupFile lawsClubWorkingGroupFile : lawsClubWorkingGroupFiles) {
Map<String, String> userRealNameAndUsernameMap = getUserRealNameAndUsernameMap(userIds); if (StringUtils.isNotBlank(lawsClubWorkingGroupFile.getFileId())) {
for (LawsClubJoinTeam lawsClubJoinTeam : lawsClubJoinTeams) { OSSFile ossFile = iossFileService.getById(lawsClubWorkingGroupFile.getFileId());
lawsClubJoinTeam.setLeadId(userRealNameAndUsernameMap.get(lawsClubJoinTeam.getLeadId())); lawsClubWorkingGroupFile.setFileId("工作组资料/" + ossFile.getFileName());
lawsClubJoinTeam.setProposerId(userRealNameAndUsernameMap.get(lawsClubJoinTeam.getProposerId())); }
}
for (LawsClubResearchInformation lawsClubResearchInformation : lawsClubResearchInformations) {
lawsClubResearchInformation.setSpecializedInterfacePerson(userRealNameAndUsernameMap.get(lawsClubResearchInformation.getSpecializedInterfacePerson()));
lawsClubResearchInformation.setFeedbackPerson(userRealNameAndUsernameMap.get(lawsClubResearchInformation.getFeedbackPerson()));
} }
for (LawsClubMeeting lawsClubMeeting : lawsClubMeetings) { for (LawsClubMeeting lawsClubMeeting : lawsClubMeetings) {
lawsClubMeeting.setNotifierId(userRealNameAndUsernameMap.get(lawsClubMeeting.getNotifierId()));
List<LawsClubMeetingMember> meetingMemberList = lawsClubMeeting.getMeetingMemberList(); List<LawsClubMeetingMember> meetingMemberList = lawsClubMeeting.getMeetingMemberList();
for (LawsClubMeetingMember lawsClubMeetingMember : meetingMemberList) { for (LawsClubMeetingMember lawsClubMeetingMember : meetingMemberList) {
lawsClubMeetingMember.setMemberId(userRealNameAndUsernameMap.get(lawsClubMeetingMember.getMemberId())); if (StringUtils.isNotBlank(lawsClubMeetingMember.getMeetingFileId())) {
OSSFile ossFile = iossFileService.getById(lawsClubMeetingMember.getMeetingFileId());
lawsClubMeetingMember.setMeetingFileId("参会信息/" + ossFile.getFileName());
}
} }
} }
} }
@@ -574,7 +560,7 @@ public class LawsClubServiceImpl extends ServiceImpl<LawsClubMapper, LawsClub> i
}else{ }else{
excelName = "Club Management Form.xls"; excelName = "Club Management Form.xls";
} }
createZipWithAttachments(response, excelBytes, excelName, "参会信息", fileIdList); createAllZipWithAttachments(response, excelBytes, excelName, "参会信息", meetingFileIdList, workGroupFileIdList);
} catch (IOException e) { } catch (IOException e) {
log.error("导出失败" + e.getMessage()); log.error("导出失败" + e.getMessage());
} }
@@ -594,16 +580,6 @@ public class LawsClubServiceImpl extends ServiceImpl<LawsClubMapper, LawsClub> i
if (!CollectionUtils.isEmpty(ids)) { if (!CollectionUtils.isEmpty(ids)) {
excelList = lawsClubJoinTeamService.list(new LambdaQueryWrapper<LawsClubJoinTeam>().in(LawsClubJoinTeam::getClubId, ids)); excelList = lawsClubJoinTeamService.list(new LambdaQueryWrapper<LawsClubJoinTeam>().in(LawsClubJoinTeam::getClubId, ids));
} }
List<String> userIds = new ArrayList<>();
List<String> leadIds = excelList.stream().map(LawsClubJoinTeam::getLeadId).filter(Objects::nonNull).collect(Collectors.toList());
List<String> proposerId = excelList.stream().map(LawsClubJoinTeam::getProposerId).filter(Objects::nonNull).collect(Collectors.toList());
userIds.addAll(leadIds);
userIds.addAll(proposerId);
Map<String, String> userRealNameAndUsernameMap = getUserRealNameAndUsernameMap(userIds);
for (LawsClubJoinTeam lawsClubJoinTeam : excelList) {
lawsClubJoinTeam.setLeadId(userRealNameAndUsernameMap.get(lawsClubJoinTeam.getLeadId()));
lawsClubJoinTeam.setProposerId(userRealNameAndUsernameMap.get(lawsClubJoinTeam.getProposerId()));
}
//导出文件名称 //导出文件名称
mv.addObject(JeroController.FILE_NAME, "入团信息统计表"); mv.addObject(JeroController.FILE_NAME, "入团信息统计表");
mv.addObject(JeroController.CLASS, LawsClubJoinTeam.class); mv.addObject(JeroController.CLASS, LawsClubJoinTeam.class);
@@ -645,26 +621,22 @@ public class LawsClubServiceImpl extends ServiceImpl<LawsClubMapper, LawsClub> i
List<String> ids = list.stream().map(LawsClub::getId).collect(Collectors.toList()); List<String> ids = list.stream().map(LawsClub::getId).collect(Collectors.toList());
List<LawsClubMeeting> excelList = new ArrayList<>(); List<LawsClubMeeting> excelList = new ArrayList<>();
List<String> fileIdList = new ArrayList<>(); List<String> fileIdList = new ArrayList<>();
List<String> userIds = new ArrayList<>();
if (!CollectionUtils.isEmpty(ids)) { if (!CollectionUtils.isEmpty(ids)) {
excelList = lawsClubMeetingService.list(new LambdaQueryWrapper<LawsClubMeeting>().in(LawsClubMeeting::getClubId, ids)); excelList = lawsClubMeetingService.list(new LambdaQueryWrapper<LawsClubMeeting>().in(LawsClubMeeting::getClubId, ids));
List<String> userIds1 = excelList.stream().map(LawsClubMeeting::getNotifierId).filter(Objects::nonNull).collect(Collectors.toList());
userIds.addAll(userIds1);
for (LawsClubMeeting lawsClubMeeting : excelList) { for (LawsClubMeeting lawsClubMeeting : excelList) {
List<LawsClubMeetingMember> memberList = lawsClubMeetingMemberService.list(new LambdaQueryWrapper<LawsClubMeetingMember>().eq(LawsClubMeetingMember::getMeetingId, lawsClubMeeting.getId())); List<LawsClubMeetingMember> memberList = lawsClubMeetingMemberService.list(new LambdaQueryWrapper<LawsClubMeetingMember>().eq(LawsClubMeetingMember::getMeetingId, lawsClubMeeting.getId()));
List<String> meetingFileIds = memberList.stream().map(LawsClubMeetingMember::getMeetingFileId).filter(Objects::nonNull).collect(Collectors.toList()); List<String> meetingFileIds = memberList.stream().map(LawsClubMeetingMember::getMeetingFileId).filter(Objects::nonNull).collect(Collectors.toList());
List<String> memberIds = memberList.stream().map(LawsClubMeetingMember::getMemberId).filter(Objects::nonNull).collect(Collectors.toList());
userIds.addAll(memberIds);
fileIdList.addAll(meetingFileIds); fileIdList.addAll(meetingFileIds);
lawsClubMeeting.setMeetingMemberList(memberList); lawsClubMeeting.setMeetingMemberList(memberList);
} }
} }
Map<String, String> userRealNameAndUsernameMap = getUserRealNameAndUsernameMap(userIds);
for (LawsClubMeeting lawsClubMeeting : excelList) { for (LawsClubMeeting lawsClubMeeting : excelList) {
lawsClubMeeting.setNotifierId(userRealNameAndUsernameMap.get(lawsClubMeeting.getNotifierId()));
List<LawsClubMeetingMember> meetingMemberList = lawsClubMeeting.getMeetingMemberList(); List<LawsClubMeetingMember> meetingMemberList = lawsClubMeeting.getMeetingMemberList();
for (LawsClubMeetingMember lawsClubMeetingMember : meetingMemberList) { for (LawsClubMeetingMember lawsClubMeetingMember : meetingMemberList) {
lawsClubMeetingMember.setMemberId(userRealNameAndUsernameMap.get(lawsClubMeetingMember.getMemberId())); if (StringUtils.isNotBlank(lawsClubMeetingMember.getMeetingFileId())) {
OSSFile ossFile = iossFileService.getById(lawsClubMeetingMember.getMeetingFileId());
lawsClubMeetingMember.setMeetingFileId("附件/" + ossFile.getFileName());
}
} }
} }
// 生成 Workbook // 生成 Workbook
@@ -678,7 +650,7 @@ public class LawsClubServiceImpl extends ServiceImpl<LawsClubMapper, LawsClub> i
if(MessageUtils.getLanguage().getValue().equals(LanguageEnum.CN.getValue())){ if(MessageUtils.getLanguage().getValue().equals(LanguageEnum.CN.getValue())){
excelName = "参会信息表.xls"; excelName = "参会信息表.xls";
}else{ }else{
excelName = "Participation Information Form.xls"; excelName = "Conference Information.xls";
} }
createZipWithAttachments(response, excelBytes, excelName, "参会信息", fileIdList); createZipWithAttachments(response, excelBytes, excelName, "参会信息", fileIdList);
} catch (IOException e) { } catch (IOException e) {
@@ -702,6 +674,12 @@ public class LawsClubServiceImpl extends ServiceImpl<LawsClubMapper, LawsClub> i
excelList = lawsClubWorkingGroupFileService.list(new LambdaQueryWrapper<LawsClubWorkingGroupFile>().in(LawsClubWorkingGroupFile::getClubId, ids)); excelList = lawsClubWorkingGroupFileService.list(new LambdaQueryWrapper<LawsClubWorkingGroupFile>().in(LawsClubWorkingGroupFile::getClubId, ids));
} }
List<String> fileIdList = excelList.stream().map(LawsClubWorkingGroupFile::getFileId).filter(Objects::nonNull).collect(Collectors.toList()); List<String> fileIdList = excelList.stream().map(LawsClubWorkingGroupFile::getFileId).filter(Objects::nonNull).collect(Collectors.toList());
for (LawsClubWorkingGroupFile lawsClubWorkingGroupFile : excelList) {
if (StringUtils.isNotBlank(lawsClubWorkingGroupFile.getFileId())) {
OSSFile ossFile = iossFileService.getById(lawsClubWorkingGroupFile.getFileId());
lawsClubWorkingGroupFile.setFileId("附件/" + ossFile.getFileName());
}
}
// 生成 Workbook // 生成 Workbook
Workbook workbook = ExcelExportUtil.exportExcel(createExportParams("密级:核心商密□普通商密□内部资料■外部公开□", "工作组资料"), LawsClubWorkingGroupFile.class,excelList); Workbook workbook = ExcelExportUtil.exportExcel(createExportParams("密级:核心商密□普通商密□内部资料■外部公开□", "工作组资料"), LawsClubWorkingGroupFile.class,excelList);
try (ByteArrayOutputStream baos = new ByteArrayOutputStream(); try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -714,7 +692,7 @@ public class LawsClubServiceImpl extends ServiceImpl<LawsClubMapper, LawsClub> i
if(MessageUtils.getLanguage().getValue().equals(LanguageEnum.CN.getValue())){ if(MessageUtils.getLanguage().getValue().equals(LanguageEnum.CN.getValue())){
excelName = "工作组资料表.xls"; excelName = "工作组资料表.xls";
}else{ }else{
excelName = "WorkingGroup File Form.xls"; excelName = "Working Group Information.xls";
} }
createZipWithAttachments(response, excelBytes, excelName, "工作组资料", fileIdList); createZipWithAttachments(response, excelBytes, excelName, "工作组资料", fileIdList);
} catch (IOException e) { } catch (IOException e) {
@@ -738,16 +716,6 @@ public class LawsClubServiceImpl extends ServiceImpl<LawsClubMapper, LawsClub> i
if (!CollectionUtils.isEmpty(ids)) { if (!CollectionUtils.isEmpty(ids)) {
excelList = lawsClubResearchInformationService.list(new LambdaQueryWrapper<LawsClubResearchInformation>().in(LawsClubResearchInformation::getClubId, ids)); excelList = lawsClubResearchInformationService.list(new LambdaQueryWrapper<LawsClubResearchInformation>().in(LawsClubResearchInformation::getClubId, ids));
} }
List<String> userIds = new ArrayList<>();
List<String> userId1 = excelList.stream().map(LawsClubResearchInformation::getSpecializedInterfacePerson).filter(Objects::nonNull).collect(Collectors.toList());
List<String> userId2 = excelList.stream().map(LawsClubResearchInformation::getFeedbackPerson).filter(Objects::nonNull).collect(Collectors.toList());
userIds.addAll(userId1);
userIds.addAll(userId2);
Map<String, String> userRealNameAndUsernameMap = getUserRealNameAndUsernameMap(userIds);
for (LawsClubResearchInformation lawsClubResearchInformation : excelList) {
lawsClubResearchInformation.setSpecializedInterfacePerson(userRealNameAndUsernameMap.get(lawsClubResearchInformation.getSpecializedInterfacePerson()));
lawsClubResearchInformation.setFeedbackPerson(userRealNameAndUsernameMap.get(lawsClubResearchInformation.getFeedbackPerson()));
}
//导出文件名称 //导出文件名称
mv.addObject(JeroController.FILE_NAME, "征集调研信统计表"); mv.addObject(JeroController.FILE_NAME, "征集调研信统计表");
mv.addObject(JeroController.CLASS, LawsClubResearchInformation.class); mv.addObject(JeroController.CLASS, LawsClubResearchInformation.class);
@@ -884,6 +852,41 @@ public class LawsClubServiceImpl extends ServiceImpl<LawsClubMapper, LawsClub> i
return msg; return msg;
} }
private void createAllZipWithAttachments(HttpServletResponse response, byte[] excelBytes, String excelName, String zipFileName, List<String> meetingFileIdList, List<String> workGroupFileIdList) throws IOException {
try (ByteArrayOutputStream baosZip = new ByteArrayOutputStream();
ZipOutputStream zos = new ZipOutputStream(baosZip)) {
// 将 Excel 文件写入 ZIP
ZipEntry entry = new ZipEntry(excelName);
zos.putNextEntry(entry);
zos.write(excelBytes);
zos.closeEntry(); // 必须关闭当前的 ZipEntry
// 创建两个文件夹 "参会信息" 和 "工作组资料"
String meetingFolderPath = "参会信息/";
String workGroupFolderPath = "工作组资料/";
Set<String> addedEntries = new HashSet<>();
// 添加 "参会信息" 文件夹中的文件
for (String fileId : meetingFileIdList) {
addFileToZip(fileId, zos, meetingFolderPath, addedEntries);
}
// 添加 "工作组资料" 文件夹中的文件
for (String fileId : workGroupFileIdList) {
addFileToZip(fileId, zos, workGroupFolderPath, addedEntries);
}
// 确保关闭所有条目后再关闭 ZipOutputStream
zos.finish();
// 设置 HTTP 响应头,处理文件名乱码
response.setContentType("application/zip;charset=UTF-8");
response.setCharacterEncoding("UTF-8");
String encodedFileName = URLEncoder.encode(zipFileName, StandardCharsets.UTF_8.name()).replace("+", "%20");
response.setHeader("Content-Disposition", "attachment; filename*=UTF-8''" + encodedFileName + ".zip");
// 输出 ZIP 文件到响应流中
try (OutputStream out = response.getOutputStream()) {
baosZip.writeTo(out); // 将最终的 ZIP 字节流写入响应
out.flush(); // 确保输出完整
}
}
}
private void createZipWithAttachments(HttpServletResponse response, byte[] excelBytes, String excelName, String zipFileName, List<String> fileIdList) throws IOException { private void createZipWithAttachments(HttpServletResponse response, byte[] excelBytes, String excelName, String zipFileName, List<String> fileIdList) throws IOException {
try (ByteArrayOutputStream baosZip = new ByteArrayOutputStream(); try (ByteArrayOutputStream baosZip = new ByteArrayOutputStream();
ZipOutputStream zos = new ZipOutputStream(baosZip)) { ZipOutputStream zos = new ZipOutputStream(baosZip)) {
@@ -913,7 +916,6 @@ public class LawsClubServiceImpl extends ServiceImpl<LawsClubMapper, LawsClub> i
} }
} }
// 将文件添加到 ZIP 中,放入指定的文件夹内,处理文件重复和 null 的情况 // 将文件添加到 ZIP 中,放入指定的文件夹内,处理文件重复和 null 的情况
private void addFileToZip(String fileId, ZipOutputStream zipos, String folderPath, Set<String> addedEntries) throws IOException { private void addFileToZip(String fileId, ZipOutputStream zipos, String folderPath, Set<String> addedEntries) throws IOException {
OSSFile ossFile = iossFileService.getById(fileId); OSSFile ossFile = iossFileService.getById(fileId);
@@ -924,9 +926,21 @@ public class LawsClubServiceImpl extends ServiceImpl<LawsClubMapper, LawsClub> i
if (Objects.isNull(inputStream)) { if (Objects.isNull(inputStream)) {
return; return;
} }
String entryPath = folderPath + ossFile.getFileName(); String originalEntryPath = folderPath + ossFile.getFileName();
if (addedEntries.contains(entryPath)) { String entryPath = originalEntryPath;
return; // 如果文件已经被添加,跳过 int duplicateCount = 1;
// 如果文件已存在,增加 (1), (2), ...
while (addedEntries.contains(entryPath)) {
String fileExtension = "";
String baseName = entryPath;
int dotIndex = originalEntryPath.lastIndexOf(".");
if (dotIndex != -1) {
baseName = originalEntryPath.substring(0, dotIndex);
fileExtension = originalEntryPath.substring(dotIndex);
}
entryPath = baseName + "(" + duplicateCount + ")" + fileExtension;
duplicateCount++;
} }
zipos.putNextEntry(new ZipEntry(entryPath)); zipos.putNextEntry(new ZipEntry(entryPath));
try (InputStream is = inputStream) { try (InputStream is = inputStream) {
@@ -942,6 +956,7 @@ public class LawsClubServiceImpl extends ServiceImpl<LawsClubMapper, LawsClub> i
addedEntries.add(entryPath); // 记录已添加的文件,防止重复添加 addedEntries.add(entryPath); // 记录已添加的文件,防止重复添加
} }
private ExportParams createExportParams(String title, String sheetName) { private ExportParams createExportParams(String title, String sheetName) {
ExportParams exportParams = new ExportParams(); ExportParams exportParams = new ExportParams();
exportParams.setTitle(title); exportParams.setTitle(title);
@@ -104,7 +104,7 @@ public class LawsClubWorkingGroupFileServiceImpl extends ServiceImpl<LawsClubWor
if(MessageUtils.getLanguage().getValue().equals(LanguageEnum.CN.getValue())){ if(MessageUtils.getLanguage().getValue().equals(LanguageEnum.CN.getValue())){
templateName = "工作组资料导入模板.xls"; templateName = "工作组资料导入模板.xls";
}else{ }else{
templateName = "WorkingGroup File Template.xls"; templateName = "Workgroup Data Import Template.xls";
} }
ZipEntry entry = new ZipEntry( templateName); ZipEntry entry = new ZipEntry( templateName);
zos.putNextEntry(entry); zos.putNextEntry(entry);
@@ -145,7 +145,7 @@ public class LawsClubWorkingGroupFileServiceImpl extends ServiceImpl<LawsClubWor
if(MessageUtils.getLanguage().getValue().equals(LanguageEnum.CN.getValue())){ if(MessageUtils.getLanguage().getValue().equals(LanguageEnum.CN.getValue())){
templateName = "工作组资料导入模板.xls"; templateName = "工作组资料导入模板.xls";
}else{ }else{
templateName = "WorkingGroup File Template.xls"; templateName = "Workgroup Data Import Template.xls";
} }
Map<String, File> unZipFileMap = ZipUtils.analyzeZipFile(file, uploadpath, templateName); Map<String, File> unZipFileMap = ZipUtils.analyzeZipFile(file, uploadpath, templateName);
saveDirectory = unZipFileMap.get("saveDirectory"); saveDirectory = unZipFileMap.get("saveDirectory");
@@ -10,6 +10,7 @@ import com.jero.common.api.vo.ResultCommon;
import com.jero.common.exception.JeroBootException; import com.jero.common.exception.JeroBootException;
import com.jero.common.system.base.controller.JeroController; import com.jero.common.system.base.controller.JeroController;
import com.jero.common.util.oConvertUtils; import com.jero.common.util.oConvertUtils;
import com.jero.modules.laws.club.config.CustomExcelExportStyler;
import com.jero.modules.laws.club.entity.LawsCompanyStandardStatistics; import com.jero.modules.laws.club.entity.LawsCompanyStandardStatistics;
import com.jero.modules.laws.club.mapper.LawsCompanyStandardStatisticsMapper; import com.jero.modules.laws.club.mapper.LawsCompanyStandardStatisticsMapper;
import com.jero.modules.laws.club.service.ILawsCompanyStandardStatisticsService; import com.jero.modules.laws.club.service.ILawsCompanyStandardStatisticsService;
@@ -17,6 +18,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.jeecgframework.poi.excel.def.NormalExcelConstants; import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams; import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.enmus.ExcelType;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView; import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@@ -135,9 +137,18 @@ public class LawsCompanyStandardStatisticsServiceImpl extends ServiceImpl<LawsCo
//导出文件名称 //导出文件名称
mv.addObject(JeroController.FILE_NAME, "公司参与标准统计"); mv.addObject(JeroController.FILE_NAME, "公司参与标准统计");
mv.addObject(JeroController.CLASS, LawsCompanyStandardStatistics.class); mv.addObject(JeroController.CLASS, LawsCompanyStandardStatistics.class);
ExportParams exportParams = new ExportParams(null, "公司参与标准统计"); mv.addObject(JeroController.PARAMS, createExportParams("密级:核心商密□普通商密□内部资料■外部公开□", "公司参与标准统计"));
mv.addObject(JeroController.PARAMS, exportParams); mv.addObject(NormalExcelConstants.DATA_LIST, excelList);
mv.addObject(NormalExcelConstants.DATA_LIST, excelList); mv.addObject(NormalExcelConstants.DATA_LIST, excelList);
return mv; return mv;
} }
private ExportParams createExportParams(String title, String sheetName) {
ExportParams exportParams = new ExportParams();
exportParams.setTitle(title);
exportParams.setType(ExcelType.HSSF);
exportParams.setSheetName(sheetName);
exportParams.setStyle(CustomExcelExportStyler.class); // 使用自定义的样式
return exportParams;
}
} }