From 9e0aca43040a03537ff09513f9781cc126395506 Mon Sep 17 00:00:00 2001 From: wxyclub Date: Thu, 23 Nov 2023 18:14:57 +0800 Subject: [PATCH] =?UTF-8?q?bug:=20=E6=94=BF=E7=AD=96=E6=B3=95=E8=A7=84?= =?UTF-8?q?=E8=B5=84=E6=96=99=E5=AF=BC=E5=85=A5=E5=B8=A6=E9=99=84=E4=BB=B6?= =?UTF-8?q?=EF=BC=8C=E5=86=85=E5=A4=96=E9=83=A8=E4=BC=9A=E8=AE=AE=E5=AF=BC?= =?UTF-8?q?=E5=85=A5=E5=B8=A6=E9=99=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../InsideOutSideMeetingController.java | 4 +- .../entity/MeetingTopic.java | 3 + .../impl/InsideOutsideMeetingServiceImpl.java | 107 ++++++++++++++++-- .../SarLawsInformationController.java | 13 ++- .../entity/SarLawsInformation.java | 1 + .../entity/SarLawsInformationExport.java | 102 +++++++++++++++++ .../impl/SarLawsInformationServiceImpl.java | 77 ++++++++++--- .../adc/da/utils/util/FieldConvertUtil.java | 6 +- 8 files changed, 284 insertions(+), 29 deletions(-) create mode 100644 adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsInformation/entity/SarLawsInformationExport.java diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/InsideOntSideMeeting/controller/InsideOutSideMeetingController.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/InsideOntSideMeeting/controller/InsideOutSideMeetingController.java index 78a5f5c3..7edbaff5 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/InsideOntSideMeeting/controller/InsideOutSideMeetingController.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/InsideOntSideMeeting/controller/InsideOutSideMeetingController.java @@ -169,9 +169,9 @@ public class InsideOutSideMeetingController extends BaseController agendaMaterialsList; @ApiModelProperty(value = "汇报人") @TableField("REPORTER") diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/InsideOntSideMeeting/service/impl/InsideOutsideMeetingServiceImpl.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/InsideOntSideMeeting/service/impl/InsideOutsideMeetingServiceImpl.java index 92ec22ac..cbffcfa3 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/InsideOntSideMeeting/service/impl/InsideOutsideMeetingServiceImpl.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/InsideOntSideMeeting/service/impl/InsideOutsideMeetingServiceImpl.java @@ -2,6 +2,7 @@ package com.adc.da.slrs.InsideOntSideMeeting.service.impl; import com.adc.da.att.entity.AttFileEO; import com.adc.da.att.service.IAttFileEOService; +import com.adc.da.att.vo.AttFileVo; import com.adc.da.common.FileUnZip; import com.adc.da.http.ResponseMessage; import com.adc.da.http.Result; @@ -83,6 +84,16 @@ public class InsideOutsideMeetingServiceImpl extends ServiceImpl meetingTopicList = meetingTopicService.list(wrapper); + for (MeetingTopic meetingTopic : meetingTopicList) { + if (StringUtils.isNotBlank(meetingTopic.getAgendaMaterials())) { + List agendaMaterialsList = new ArrayList<>(); + for (String attId : meetingTopic.getAgendaMaterials().split(",")) { + AttFileEO fileInfo = attFileEOService.getFileInfo(attId); + agendaMaterialsList.add(fileInfo); + } + meetingTopic.setAgendaMaterialsList(agendaMaterialsList); + } + } insideOutsideMeeting.setMeetingTopicList(meetingTopicList); } return insideOutsideMeeting; @@ -244,19 +255,32 @@ public class InsideOutsideMeetingServiceImpl extends ServiceImpl fileList = readImpExcelFile(zipEntryName); //判断获取到的文件数量 - if (fileList.size() != 1) { - return Result.error("上传的文件只能有一个"); + if (fileList.size() < 1) { + return Result.error("上传的文件不能为空"); } - File importFile = fileList.get(0); - if (!importFile.getName().contains(".xls") && !importFile.getName().contains(".xlsx")) { - return Result.error("文件必须是EXCEL文件"); + File excelFile = null; + int excelCount = 0; + // 将文件转换为Map,文件名为建,文件为值 + Map fileMap = new HashMap<>(); + for (File file1 : fileList) { + fileMap.put(file1.getName(), file1); + if (file1.getName().toLowerCase().contains(".xls") || file1.getName().toLowerCase().contains(".xlsx")) { + excelFile = file1; + excelCount ++; + } + } + if (excelCount > 1) { + return Result.error("导入了多个Excel文件"); + } + if (excelCount < 1){ + return Result.error("文件必须包含一个EXCEL文件"); } Workbook workbook = null; try { - workbook = WorkbookFactory.create(importFile); + workbook = WorkbookFactory.create(excelFile); } catch (IOException e) { FileUnZip.deleteDir(saveDirectory); - return Result.error("导入失败,需要导入的数据有问题或导入的企标标号和企标名称已存在"); + return Result.error("导入失败,需要导入的数据有问题"); } SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Sheet sheet = workbook.getSheetAt(0); @@ -267,7 +291,7 @@ public class InsideOutsideMeetingServiceImpl extends ServiceImpl headerList = new ArrayList<>(); // 获取excel表头 Row headerRow = sheet.getRow(1); - for (int i = 0; i <= 12; i++) { + for (int i = 0; i <= 14; i++) { headerList.add(headerRow.getCell(i).getStringCellValue()); } @@ -292,7 +316,7 @@ public class InsideOutsideMeetingServiceImpl extends ServiceImpl rowMap = new LinkedHashMap<>(); // 总列数 - int columnNum = 13; + int columnNum = 15; // 遍历每个单元格 for (int columnIndex = 0; columnIndex < columnNum; columnIndex++) { // 获取单元格 @@ -349,9 +373,25 @@ public class InsideOutsideMeetingServiceImpl extends ServiceImpl fileMap, int count) throws Exception { + if (fileNameStr != null) { + List fileAttList = new ArrayList<>(); + for (String meetingMinutesFileName : fileNameStr.split(",")) { + int lastIndexOf = meetingMinutesFileName.lastIndexOf("."); + if (meetingMinutesFileName.lastIndexOf(".") != -1) { + String lastName = meetingMinutesFileName.substring(lastIndexOf + 1).toLowerCase(); + if (lastName.equals("pdf") || lastName.equals("ppt") || lastName.equals("pptx") || lastName.equals("doc") || lastName.equals("docx")) { + File file1 = fileMap.get(meetingMinutesFileName); + if (file1 == null) { + throw new Exception("会议纪要中第" + (count+1) +"行" + meetingMinutesFileName + "文件不存在,请上传pdf/ppt/pptx/doc/docx格式的附件"); + } + AttFileVo attFileVo = attFileEOService.saveFileInfo(file1); + if (StringUtils.isNotBlank(attFileVo.getId())) { + fileAttList.add(attFileVo.getAttId()); + } + } else { + throw new Exception("会议纪要中第" + (count+1) +"行" + meetingMinutesFileName + "格式不正确,请上传pdf/ppt/pptx/doc/docx格式的附件"); + } + } else { + throw new Exception("会议纪要中第" + (count+1) +"行" + meetingMinutesFileName + "格式不正确,请上传pdf/ppt/pptx/doc/docx格式的附件"); + } + } + return String.join(",", fileAttList); + } + return null; + } } diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsInformation/controller/SarLawsInformationController.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsInformation/controller/SarLawsInformationController.java index 61e11b15..0dd2c655 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsInformation/controller/SarLawsInformationController.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsInformation/controller/SarLawsInformationController.java @@ -12,6 +12,7 @@ import com.adc.da.http.PageInfo; import com.adc.da.http.ResponseMessage; import com.adc.da.http.Result; import com.adc.da.slrs.sarLawsInformation.entity.SarLawsInformation; +import com.adc.da.slrs.sarLawsInformation.entity.SarLawsInformationExport; import com.adc.da.slrs.sarLawsInformation.service.SarLawsInformationService; import com.adc.da.util.UUIDUtils; import com.adc.da.utils.util.FieldConvertUtil; @@ -26,6 +27,7 @@ import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.util.IOUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; @@ -35,6 +37,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.*; import java.text.ParseException; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -124,10 +127,16 @@ public class SarLawsInformationController extends BaseController datasExport = new ArrayList<>(); + for (SarLawsInformation data : datas) { + SarLawsInformationExport dataExport = new SarLawsInformationExport(); + BeanUtils.copyProperties(data,dataExport); + datasExport.add(dataExport); + } ExportParams exportParams = new ExportParams(); exportParams.setType(ExcelType.XSSF); exportParams.setSheetName(sarLawsInformation.getExportName()); - workbook = ExcelExportUtil.exportExcel(exportParams,SarLawsInformation.class,datas); + workbook = ExcelExportUtil.exportExcel(exportParams, SarLawsInformationExport.class,datasExport); os = response.getOutputStream(); workbook.write(os); os.flush(); @@ -170,7 +179,7 @@ public class SarLawsInformationController extends BaseController wrapper = new LambdaQueryWrapper<>(); wrapper.in(SarLawsInformation::getId, idList); List sarLawsInformationList = this.baseMapper.selectList(wrapper); -// for (SarLawsInformation sarLawsInformation : sarLawsInformationList) { -// // 将字典编号变更为字典值 -// convertCodeToName(sarLawsInformation); -// } + for (SarLawsInformation sarLawsInformation : sarLawsInformationList) { + // 将字典编号变更为字典值 + convertCodeToName(sarLawsInformation); + } return sarLawsInformationList; } @@ -372,7 +374,7 @@ public class SarLawsInformationServiceImpl extends ServiceImpl sarLawsInformationList = this.baseMapper.getAllLawsInformation(sarLawsInformation); for (SarLawsInformation lawsInformation : sarLawsInformationList) { // 将字典编号变更为字典值 -// convertCodeToName(lawsInformation); + convertCodeToName(lawsInformation); // 查询文件信息 if (StringUtils.isNotBlank(lawsInformation.getInformationFile())) { String[] split = lawsInformation.getInformationFile().split(","); @@ -387,6 +389,7 @@ public class SarLawsInformationServiceImpl extends ServiceImpl importLawsInformationInfo(MultipartFile file) { //获取文件全称 @@ -427,19 +430,32 @@ public class SarLawsInformationServiceImpl extends ServiceImpl fileList = readImpExcelFile(zipEntryName); //判断获取到的文件数量 - if (fileList.size() != 1) { - return Result.error("上传的文件只能有一个"); + if (fileList.size() < 1) { + return Result.error("上传的文件不能为空"); } - File importFile = fileList.get(0); - if (!importFile.getName().contains(".xls") && !importFile.getName().contains(".xlsx")) { - return Result.error("文件必须是EXCEL文件"); + File excelFile = null; + int excelCount = 0; + // 将文件转换为Map,文件名为建,文件为值 + Map fileMap = new HashMap<>(); + for (File file1 : fileList) { + fileMap.put(file1.getName(), file1); + if (file1.getName().toLowerCase().contains(".xls") || file1.getName().toLowerCase().contains(".xlsx")) { + excelFile = file1; + excelCount ++; + } + } + if (excelCount > 1) { + return Result.error("导入了多个Excel文件"); + } + if (excelCount < 1){ + return Result.error("文件必须包含一个EXCEL文件"); } Workbook workbook = null; try { - workbook = WorkbookFactory.create(importFile); + workbook = WorkbookFactory.create(excelFile); } catch (IOException e) { FileUnZip.deleteDir(saveDirectory); - return Result.error("导入失败,需要导入的数据有问题或导入的企标标号和企标名称已存在"); + return Result.error("导入失败,需要导入的数据有问题"); } SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Sheet sheet = workbook.getSheetAt(0); @@ -450,7 +466,7 @@ public class SarLawsInformationServiceImpl extends ServiceImpl headerList = new ArrayList<>(); // 获取excel表头 Row headerRow = sheet.getRow(1); - for (int i = 0; i < 8; i++) { + for (int i = 0; i < 9; i++) { headerList.add(headerRow.getCell(i).getStringCellValue()); } @@ -545,6 +561,13 @@ public class SarLawsInformationServiceImpl extends ServiceImpl fileMap, int count) throws Exception { + if (fileNameStr != null) { + List fileAttList = new ArrayList<>(); + for (String meetingMinutesFileName : fileNameStr.split(",")) { + int lastIndexOf = meetingMinutesFileName.lastIndexOf("."); + if (meetingMinutesFileName.lastIndexOf(".") != -1) { + String lastName = meetingMinutesFileName.substring(lastIndexOf + 1).toLowerCase(); + if (lastName.equals("pdf") || lastName.equals("ppt") || lastName.equals("pptx") || lastName.equals("doc") || lastName.equals("docx")) { + File file1 = fileMap.get(meetingMinutesFileName); + if (file1 == null) { + throw new Exception("会议纪要中第" + (count+1) +"行" + meetingMinutesFileName + "文件不存在,请上传pdf/ppt/pptx/doc/docx格式的附件"); + } + AttFileVo attFileVo = attFileEOService.saveFileInfo(file1); + if (StringUtils.isNotBlank(attFileVo.getId())) { + fileAttList.add(attFileVo.getAttId()); + } + } else { + throw new Exception("会议纪要中第" + (count+1) +"行" + meetingMinutesFileName + "格式不正确,请上传pdf/ppt/pptx/doc/docx格式的附件"); + } + } else { + throw new Exception("会议纪要中第" + (count+1) +"行" + meetingMinutesFileName + "格式不正确,请上传pdf/ppt/pptx/doc/docx格式的附件"); + } + } + return String.join(",", fileAttList); + } + return null; + } } diff --git a/adc-da-slrs/src/main/java/com/adc/da/utils/util/FieldConvertUtil.java b/adc-da-slrs/src/main/java/com/adc/da/utils/util/FieldConvertUtil.java index 1d63b5c6..4e612aa9 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/utils/util/FieldConvertUtil.java +++ b/adc-da-slrs/src/main/java/com/adc/da/utils/util/FieldConvertUtil.java @@ -65,12 +65,12 @@ public class FieldConvertUtil { public static String exportFieldNamesEsRevisePlan = "企标类别,企标编号,企标名称,计划状态,制修订类型,起草人,内部评审责任人,技术委员会评审负责人,计划标准初稿完成时间,计划标准发布时间,起草责任单位,实际标准发布时间,质量评分"; // 内外部会议 表头 - public static String exportFieldNamesInsideOutsideMeeting = "会议名称,课题名称,会议主办单位,会议时间,会议地点,参会人员,会议主要内容,一级会议类别,二级会议类别"; + public static String exportFieldNamesInsideOutsideMeeting = "会议名称,课题名称,会议主办单位,会议时间,会议地点,参会人员,会议纪要,会议主要内容,一级会议类别,二级会议类别"; // 内外部会议关联表 表头 - public static String exportFieldNamesMeetingTopic = "议题名称,汇报人,汇报单位,议题主要内容"; + public static String exportFieldNamesMeetingTopic = "议题名称,议题材料,汇报人,汇报单位,议题主要内容"; // 政策法规资料 表头 - public static String exportFieldLawsInformation = "1级资料分类,2级资料分类,3级资料分类,4级资料分类,资料名称,资料归属部门,作者,资料说明"; + public static String exportFieldLawsInformation = "1级资料分类,2级资料分类,3级资料分类,4级资料分类,资料名称,资料归属部门,作者,资料说明,资料文件"; // 政策课题 表头 public static String exportFieldLawsTopic = "课题名称,课题承办单位,课题指导单位,课题参与单位,开始时间,结题时间,课题费用(万元),课题组会议列表,课题组联系方式,内部联系方式";