bug: 政策课题带附件导入
This commit is contained in:
+10
-10
@@ -563,7 +563,7 @@ public class SarLawsInformationServiceImpl extends ServiceImpl<SarLawsInformatio
|
||||
}
|
||||
String informationFileAtt = null;
|
||||
try {
|
||||
informationFileAtt = getFileAtt(sarLawsInformation.getInformationFile(), fileMap, index);
|
||||
informationFileAtt = getFileAtt("资料文件",sarLawsInformation.getInformationFile(), fileMap, index);
|
||||
} catch (Exception e) {
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
@@ -722,27 +722,27 @@ public class SarLawsInformationServiceImpl extends ServiceImpl<SarLawsInformatio
|
||||
return results;
|
||||
}
|
||||
|
||||
public String getFileAtt(String fileNameStr, Map<String, File> fileMap, int count) throws Exception {
|
||||
public String getFileAtt(String fieldName,String fileNameStr, Map<String, File> fileMap, int count) throws Exception {
|
||||
if (fileNameStr != null) {
|
||||
List<String> fileAttList = new ArrayList<>();
|
||||
for (String meetingMinutesFileName : fileNameStr.split(",")) {
|
||||
int lastIndexOf = meetingMinutesFileName.lastIndexOf(".");
|
||||
if (meetingMinutesFileName.lastIndexOf(".") != -1) {
|
||||
String lastName = meetingMinutesFileName.substring(lastIndexOf + 1).toLowerCase();
|
||||
for (String fileName : fileNameStr.split(",")) {
|
||||
int lastIndexOf = fileName.lastIndexOf(".");
|
||||
if (fileName.lastIndexOf(".") != -1) {
|
||||
String lastName = fileName.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);
|
||||
File file1 = fileMap.get(fileName);
|
||||
if (file1 == null) {
|
||||
throw new Exception("会议纪要中第" + (count+1) +"行" + meetingMinutesFileName + "文件不存在,请上传pdf/ppt/pptx/doc/docx格式的附件");
|
||||
throw new Exception(fieldName + "中第" + (count+1) +"行" + fileName + "文件不存在,请上传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格式的附件");
|
||||
throw new Exception(fieldName + "中第" + (count+1) +"行" + fileName + "格式不正确,请上传pdf/ppt/pptx/doc/docx格式的附件");
|
||||
}
|
||||
} else {
|
||||
throw new Exception("会议纪要中第" + (count+1) +"行" + meetingMinutesFileName + "格式不正确,请上传pdf/ppt/pptx/doc/docx格式的附件");
|
||||
throw new Exception(fieldName + "中第" + (count+1) +"行" + fileName + "格式不正确,请上传pdf/ppt/pptx/doc/docx格式的附件");
|
||||
}
|
||||
}
|
||||
return String.join(",", fileAttList);
|
||||
|
||||
+55
-25
@@ -13,6 +13,7 @@ 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.sarLawsTopic.entity.SarLawsTopic;
|
||||
import com.adc.da.slrs.sarLawsTopic.entity.SarLawsTopicExport;
|
||||
import com.adc.da.slrs.sarLawsTopic.entity.SarLawsTopicVO;
|
||||
import com.adc.da.slrs.sarLawsTopic.service.SarLawsTopicService;
|
||||
import com.adc.da.util.UUIDUtils;
|
||||
@@ -27,6 +28,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;
|
||||
@@ -36,6 +38,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;
|
||||
|
||||
@@ -123,10 +126,16 @@ public class SarLawsTopicController extends BaseController<SarLawsTopicVO> {
|
||||
// 导出所有数据
|
||||
datas = lawsTopicService.getAllLawsTopic(sarLawsTopicVO);
|
||||
}
|
||||
List<SarLawsTopicExport> dataExportList = new ArrayList<>();
|
||||
for (SarLawsTopicVO data : datas) {
|
||||
SarLawsTopicExport dataExport = new SarLawsTopicExport();
|
||||
BeanUtils.copyProperties(data, dataExport);
|
||||
dataExportList.add(dataExport);
|
||||
}
|
||||
ExportParams exportParams = new ExportParams();
|
||||
exportParams.setType(ExcelType.XSSF);
|
||||
exportParams.setSheetName(sarLawsTopicVO.getExportName());
|
||||
workbook = ExcelExportUtil.exportExcel(exportParams, SarLawsTopicVO.class, datas);
|
||||
workbook = ExcelExportUtil.exportExcel(exportParams, SarLawsTopicExport.class, dataExportList);
|
||||
os = response.getOutputStream();
|
||||
workbook.write(os);
|
||||
os.flush();
|
||||
@@ -171,14 +180,14 @@ public class SarLawsTopicController extends BaseController<SarLawsTopicVO> {
|
||||
HSSFSheet sheetItems = workbook.createSheet("模板");
|
||||
sheetItems.setDefaultColumnWidth(13);
|
||||
Row rowHeader = sheetItems.createRow(1);//开始创建标题行
|
||||
sheetItems.addMergedRegion(new CellRangeAddress(0, 0, 0, 21));
|
||||
sheetItems.addMergedRegion(new CellRangeAddress(0, 0, 0, 31));
|
||||
Row row2 = sheetItems.createRow(0);//开始创建填写说明
|
||||
|
||||
// 表头样式
|
||||
HSSFCellStyle cellStyle1 = workbook.createCellStyle();
|
||||
cellStyle1.setAlignment(HorizontalAlignment.CENTER);
|
||||
cellStyle1.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||
String exportFieldName = "课题名称,课题承办单位,课题指导单位,课题参与单位,启动时间,结题时间,课题费用(万元)";
|
||||
String exportFieldName = "课题名称,课题承办单位,课题指导单位,课题参与单位,启动时间,结题时间,课题费用(万元),协议";
|
||||
String[] headerArr = exportFieldName.split(",");
|
||||
for (int i=0;i < headerArr.length; i++) {
|
||||
Cell cell = rowHeader.createCell(i);
|
||||
@@ -186,33 +195,54 @@ public class SarLawsTopicController extends BaseController<SarLawsTopicVO> {
|
||||
sheetItems.addMergedRegion(new CellRangeAddress(1,2,i,i));
|
||||
cell.setCellStyle(cellStyle1);
|
||||
}
|
||||
|
||||
String exportFieldListName = "课题组会议列表,课题组联系方式,内部联系方式";
|
||||
String[] headerListArr = exportFieldListName.split(",");
|
||||
for (int i=0;i < headerListArr.length; i++) {
|
||||
Cell cell = rowHeader.createCell(7 + (i * 5));
|
||||
cell.setCellValue(headerListArr[i]);
|
||||
sheetItems.addMergedRegion(new CellRangeAddress(1,1,7+(i*5),7+(i*5)+4));
|
||||
cell.setCellStyle(cellStyle1);
|
||||
}
|
||||
HSSFRow rowHeader2 = sheetItems.createRow(2);
|
||||
Cell cell = rowHeader.createCell(8);
|
||||
cell.setCellValue("课题组资料");
|
||||
sheetItems.addMergedRegion(new CellRangeAddress(1,1,8,12));
|
||||
cell.setCellStyle(cellStyle1);
|
||||
String exportFieldMeetingName = "会议名称,会议时间,会议地点,参会人员(内部),会议主要内容";
|
||||
String[] headerMeetingListArr = exportFieldMeetingName.split(",");
|
||||
HSSFRow rowHeader2 = sheetItems.createRow(2);
|
||||
for (int i=0;i < headerMeetingListArr.length; i++) {
|
||||
Cell cell = rowHeader2.createCell(7 + i);
|
||||
cell.setCellValue(headerMeetingListArr[i]);
|
||||
cell.setCellStyle(cellStyle1);
|
||||
}
|
||||
String exportFieldContactName = "姓名,单位,电话,邮箱,身份";
|
||||
String[] headerContactListArr = exportFieldContactName.split(",");
|
||||
for (int i=0;i < headerContactListArr.length; i++) {
|
||||
Cell cell1 = rowHeader2.createCell(12 + i);
|
||||
cell1.setCellValue(headerContactListArr[i]);
|
||||
cell1.setCellStyle(cellStyle1);
|
||||
Cell cell2 = rowHeader2.createCell(17 + i);
|
||||
cell2.setCellValue(headerContactListArr[i]);
|
||||
Cell cell2 = rowHeader2.createCell(8 + i);
|
||||
cell2.setCellValue(headerMeetingListArr[i]);
|
||||
cell2.setCellStyle(cellStyle1);
|
||||
}
|
||||
String topicGroupFieldName = "课题组研究方案,课题组研究成果,课题组其他,课题组会议资料";
|
||||
headerArr = topicGroupFieldName.split(",");
|
||||
for (int i=0;i < headerArr.length; i++) {
|
||||
Cell cell2 = rowHeader.createCell(13+i);
|
||||
cell2.setCellValue(headerArr[i]);
|
||||
sheetItems.addMergedRegion(new CellRangeAddress(1,2,i+13,i+13));
|
||||
cell2.setCellStyle(cellStyle1);
|
||||
}
|
||||
Cell cell3 = rowHeader.createCell(17);
|
||||
cell3.setCellValue("课题组联系方式");
|
||||
sheetItems.addMergedRegion(new CellRangeAddress(1,1,17,21));
|
||||
cell3.setCellStyle(cellStyle1);
|
||||
String exportFieldContactName = "姓名,单位,电话,邮箱,身份";
|
||||
headerMeetingListArr = exportFieldContactName.split(",");
|
||||
for (int i=0;i < headerMeetingListArr.length; i++) {
|
||||
Cell cell4 = rowHeader2.createCell(17 + i);
|
||||
cell4.setCellValue(headerMeetingListArr[i]);
|
||||
cell4.setCellStyle(cellStyle1);
|
||||
}
|
||||
String insideFieldName = "内部立项报告,内部研究方案,内部会议资料,内部研究成果,内部其他";
|
||||
headerArr = insideFieldName.split(",");
|
||||
for (int i=0;i < headerArr.length; i++) {
|
||||
Cell cell5 = rowHeader.createCell(22+i);
|
||||
cell5.setCellValue(headerArr[i]);
|
||||
sheetItems.addMergedRegion(new CellRangeAddress(1,2,i+22,i+22));
|
||||
cell5.setCellStyle(cellStyle1);
|
||||
}
|
||||
Cell cell6 = rowHeader.createCell(27);
|
||||
cell6.setCellValue("内部联系方式");
|
||||
sheetItems.addMergedRegion(new CellRangeAddress(1,1,27,31));
|
||||
cell6.setCellStyle(cellStyle1);
|
||||
for (int i=0;i < headerMeetingListArr.length; i++) {
|
||||
Cell cell7 = rowHeader2.createCell(27 + i);
|
||||
cell7.setCellValue(headerMeetingListArr[i]);
|
||||
cell7.setCellStyle(cellStyle1);
|
||||
}
|
||||
Cell cellA2 = row2.createCell(0);
|
||||
cellA2.setCellValue(FieldConvertUtil.exportLawsTopicDesc);
|
||||
//sheetItems.setColumnWidth(0, 20 * 150);
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
package com.adc.da.slrs.sarLawsTopic.entity;
|
||||
|
||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||
import cn.afterturn.easypoi.excel.annotation.ExcelCollection;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author tjzdw
|
||||
* @description
|
||||
* @date 2023/11/23
|
||||
*/
|
||||
@Data
|
||||
public class SarLawsTopicExport {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 课题名称
|
||||
*/
|
||||
@Excel(name = "课题名称", orderNum = "0", type = 1, needMerge = true)
|
||||
private String topicName;
|
||||
|
||||
/**
|
||||
* 课题承办单位
|
||||
*/
|
||||
@Excel(name = "课题承办单位", orderNum = "1",type = 1, needMerge = true)
|
||||
private String organizer;
|
||||
|
||||
/**
|
||||
* 课题指导单位
|
||||
*/
|
||||
@Excel(name = "课题指导单位", orderNum = "2", type = 1, needMerge = true)
|
||||
private String guidanceUnit;
|
||||
|
||||
/**
|
||||
* 课题参与单位
|
||||
*/
|
||||
@Excel(name = "课题参与单位", orderNum = "3", type = 1, needMerge = true)
|
||||
private String participatingUnit;
|
||||
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
@Excel(name = "启动时间", orderNum = "4", exportFormat = "yyyy-MM-dd", needMerge = true)
|
||||
private Date startTime;
|
||||
|
||||
/**
|
||||
* 结题时间
|
||||
*/
|
||||
@Excel(name = "结题时间", orderNum = "5", exportFormat = "yyyy-MM-dd", needMerge = true)
|
||||
private Date closeTime;
|
||||
|
||||
/**
|
||||
* 课题状态
|
||||
*/
|
||||
@Excel(name = "课题状态", orderNum = "6", type = 1, needMerge = true)
|
||||
private String topicStatus;
|
||||
|
||||
/**
|
||||
* 课题费用(万元)
|
||||
*/
|
||||
@Excel(name = "课题费用(万元)", orderNum = "7", type = 1, needMerge = true)
|
||||
private String topicCost;
|
||||
|
||||
/**
|
||||
* 课题组会议列表
|
||||
*/
|
||||
@ExcelCollection(name = "课题组会议列表", orderNum = "8")
|
||||
private List<SarLawsTopicMeeting> meetingList;
|
||||
|
||||
/**
|
||||
* 课题组联系方式
|
||||
*/
|
||||
@ExcelCollection(name = "课题组联系方式", orderNum = "9")
|
||||
private List<SarLawsContactInformation> topicContactInformationList;
|
||||
|
||||
/**
|
||||
* 内部联系方式
|
||||
*/
|
||||
@ExcelCollection(name = "内部联系方式", orderNum = "10")
|
||||
private List<SarLawsContactInformation> insideContactInformationList;
|
||||
}
|
||||
@@ -82,6 +82,7 @@ public class SarLawsTopicVO extends BasePage {
|
||||
/**
|
||||
* 协议
|
||||
*/
|
||||
@Excel(name = "协议", orderNum = "8", type = 1, needMerge = true)
|
||||
private String agreement;
|
||||
|
||||
private List<AttFileEO> agreementList;
|
||||
@@ -89,7 +90,7 @@ public class SarLawsTopicVO extends BasePage {
|
||||
/**
|
||||
* 课题组会议列表
|
||||
*/
|
||||
@ExcelCollection(name = "课题组会议列表", orderNum = "8")
|
||||
@ExcelCollection(name = "课题组会议列表", orderNum = "9")
|
||||
private List<SarLawsTopicMeeting> meetingList;
|
||||
|
||||
/**
|
||||
@@ -123,6 +124,7 @@ public class SarLawsTopicVO extends BasePage {
|
||||
/**
|
||||
* 课题组研究方案
|
||||
*/
|
||||
@Excel(name = "课题组研究方案", orderNum = "10",type = 1, needMerge = true)
|
||||
private String researchPlan;
|
||||
|
||||
private List<AttFileEO> researchPlanList;
|
||||
@@ -130,6 +132,7 @@ public class SarLawsTopicVO extends BasePage {
|
||||
/**
|
||||
* 课题组研究成果
|
||||
*/
|
||||
@Excel(name = "课题组研究成果", orderNum = "11",type = 1, needMerge = true)
|
||||
private String researchFindings;
|
||||
|
||||
private List<AttFileEO> researchFindingsList;
|
||||
@@ -137,6 +140,7 @@ public class SarLawsTopicVO extends BasePage {
|
||||
/**
|
||||
* 课题组其他
|
||||
*/
|
||||
@Excel(name = "课题组其他", orderNum = "12",type = 1, needMerge = true)
|
||||
private String researchGroupOther;
|
||||
|
||||
private List<AttFileEO> researchGroupOtherList;
|
||||
@@ -144,6 +148,7 @@ public class SarLawsTopicVO extends BasePage {
|
||||
/**
|
||||
* 课题组会议资料
|
||||
*/
|
||||
@Excel(name = "课题组会议资料", orderNum = "13",type = 1, needMerge = true)
|
||||
private String conferenceMaterials;
|
||||
|
||||
private List<AttFileEO> conferenceMaterialsList;
|
||||
@@ -151,7 +156,7 @@ public class SarLawsTopicVO extends BasePage {
|
||||
/**
|
||||
* 课题组联系方式
|
||||
*/
|
||||
@ExcelCollection(name = "课题组联系方式", orderNum = "9")
|
||||
@ExcelCollection(name = "课题组联系方式", orderNum = "14")
|
||||
private List<SarLawsContactInformation> topicContactInformationList;
|
||||
|
||||
// 课题组用户名称
|
||||
@@ -168,6 +173,7 @@ public class SarLawsTopicVO extends BasePage {
|
||||
/**
|
||||
* 内部资料立项报告
|
||||
*/
|
||||
@Excel(name = "内部立项报告", orderNum = "15", needMerge = true)
|
||||
private String insideProjectProposalRepost;
|
||||
|
||||
private List<AttFileEO> insideProjectProposalRepostList;
|
||||
@@ -175,6 +181,7 @@ public class SarLawsTopicVO extends BasePage {
|
||||
/**
|
||||
* 内部资料研究方案
|
||||
*/
|
||||
@Excel(name = "内部研究方案", orderNum = "16", needMerge = true)
|
||||
private String insideResearchPlan;
|
||||
|
||||
private List<AttFileEO> insideResearchPlanList;
|
||||
@@ -182,6 +189,7 @@ public class SarLawsTopicVO extends BasePage {
|
||||
/**
|
||||
* 内部资料会议资料
|
||||
*/
|
||||
@Excel(name = "内部会议资料", orderNum = "17", needMerge = true)
|
||||
private String insideConferenceMaterials;
|
||||
|
||||
private List<AttFileEO> insideConferenceMaterialsList;
|
||||
@@ -189,6 +197,7 @@ public class SarLawsTopicVO extends BasePage {
|
||||
/**
|
||||
* 内部会议研究成果
|
||||
*/
|
||||
@Excel(name = "内部研究成果", orderNum = "18", needMerge = true)
|
||||
private String insideResearchFindings;
|
||||
|
||||
private List<AttFileEO> insideResearchFindingsList;
|
||||
@@ -196,6 +205,7 @@ public class SarLawsTopicVO extends BasePage {
|
||||
/**
|
||||
* 内部会议其他
|
||||
*/
|
||||
@Excel(name = "内部其他", orderNum = "19", needMerge = true)
|
||||
private String insideOther;
|
||||
|
||||
private List<AttFileEO> insideOtherList;
|
||||
@@ -203,7 +213,7 @@ public class SarLawsTopicVO extends BasePage {
|
||||
/**
|
||||
* 内部联系方式
|
||||
*/
|
||||
@ExcelCollection(name = "内部联系方式", orderNum = "10")
|
||||
@ExcelCollection(name = "内部联系方式", orderNum = "20")
|
||||
private List<SarLawsContactInformation> insideContactInformationList;
|
||||
|
||||
// 内部人员名称
|
||||
|
||||
+136
-10
@@ -4,6 +4,7 @@ import cn.afterturn.easypoi.excel.ExcelImportUtil;
|
||||
import cn.afterturn.easypoi.excel.entity.ImportParams;
|
||||
import com.adc.da.att.entity.AttFileEO;
|
||||
import com.adc.da.att.service.impl.AttFileEOServiceImpl;
|
||||
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;
|
||||
@@ -276,36 +277,61 @@ public class SarLawsTopicServiceImpl extends ServiceImpl<SarLawsTopicMapper, Sar
|
||||
//获取文件信息
|
||||
List<File> 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<String, File> 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);
|
||||
if (sheet == null) {
|
||||
return Result.error("工作表为空");
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
// 获取excel表头
|
||||
List<String> headerList = new ArrayList<>();
|
||||
Row headerRow = sheet.getRow(1);
|
||||
for (int i = 0; i < 7; i++) {
|
||||
for (int i = 0; i < 8; i++) {
|
||||
headerList.add(headerRow.getCell(i).getStringCellValue());
|
||||
}
|
||||
for (int i = 13; i < 17; i++) {
|
||||
headerList.add(headerRow.getCell(i).getStringCellValue());
|
||||
}
|
||||
for (int i = 22; i < 27; i++) {
|
||||
headerList.add(headerRow.getCell(i).getStringCellValue());
|
||||
}
|
||||
// 获取关联表表头
|
||||
Row relationRow = sheet.getRow(2);
|
||||
List<String> relationList = new ArrayList<>();
|
||||
for (int i = 7; i < 22; i++) {
|
||||
for (int i = 8; i < 13; i++) {
|
||||
relationList.add(relationRow.getCell(i).getStringCellValue());
|
||||
}
|
||||
for (int i = 17; i < 22; i++) {
|
||||
relationList.add(relationRow.getCell(i).getStringCellValue());
|
||||
}
|
||||
for (int i = 27; i < 32; i++) {
|
||||
relationList.add(relationRow.getCell(i).getStringCellValue());
|
||||
}
|
||||
|
||||
@@ -327,6 +353,7 @@ public class SarLawsTopicServiceImpl extends ServiceImpl<SarLawsTopicMapper, Sar
|
||||
importParams.setHeadRows(2);
|
||||
List<SarLawsTopicVO> lawsTopicVOList = ExcelImportUtil.importExcel(readImpExcelFile(zipEntryName).get(0), SarLawsTopicVO.class, importParams);
|
||||
// 去除空数据
|
||||
int index = 0;
|
||||
for (SarLawsTopicVO lawsTopicVO : lawsTopicVOList) {
|
||||
if (StringUtils.isNotBlank(lawsTopicVO.getTopicName())) {
|
||||
// 存入数据库
|
||||
@@ -337,8 +364,79 @@ public class SarLawsTopicServiceImpl extends ServiceImpl<SarLawsTopicMapper, Sar
|
||||
} else {
|
||||
sarLawsTopic.setTopicStatus("进行中");
|
||||
}
|
||||
String agreementFileAtt = null;
|
||||
try {
|
||||
agreementFileAtt = getFileAtt("协议",sarLawsTopic.getAgreement(), fileMap, index);
|
||||
} catch (Exception e) {
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
sarLawsTopic.setAgreement(agreementFileAtt);
|
||||
String researchPlanFileAtt = null;
|
||||
try {
|
||||
researchPlanFileAtt = getFileAtt("课题组研究方案",sarLawsTopic.getResearchPlan(), fileMap, index);
|
||||
} catch (Exception e) {
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
sarLawsTopic.setResearchPlan(researchPlanFileAtt);
|
||||
String researchFindingsFileAtt = null;
|
||||
try {
|
||||
researchFindingsFileAtt = getFileAtt("课题组研究成果",sarLawsTopic.getResearchFindings(), fileMap, index);
|
||||
} catch (Exception e) {
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
sarLawsTopic.setResearchFindings(researchFindingsFileAtt);
|
||||
String researchGroupOtherFileAtt = null;
|
||||
try {
|
||||
researchGroupOtherFileAtt = getFileAtt("课题组其他",sarLawsTopic.getResearchGroupOther(), fileMap, index);
|
||||
} catch (Exception e) {
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
sarLawsTopic.setResearchGroupOther(researchGroupOtherFileAtt);
|
||||
String conferenceMaterialsFileAtt = null;
|
||||
try {
|
||||
conferenceMaterialsFileAtt = getFileAtt("课题组会议资料",sarLawsTopic.getConferenceMaterials(), fileMap, index);
|
||||
} catch (Exception e) {
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
sarLawsTopic.setConferenceMaterials(conferenceMaterialsFileAtt);
|
||||
String insideProjectProposalRepostFileAtt = null;
|
||||
try {
|
||||
insideProjectProposalRepostFileAtt = getFileAtt("内部立项报告",sarLawsTopic.getInsideProjectProposalRepost(), fileMap, index);
|
||||
} catch (Exception e) {
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
sarLawsTopic.setInsideProjectProposalRepost(insideProjectProposalRepostFileAtt);
|
||||
String insideResearchPlanFileAtt = null;
|
||||
try {
|
||||
insideResearchPlanFileAtt = getFileAtt("内部研究方案",sarLawsTopic.getInsideResearchPlan(), fileMap, index);
|
||||
} catch (Exception e) {
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
sarLawsTopic.setInsideResearchPlan(insideResearchPlanFileAtt);
|
||||
String insideConferenceMaterialsFileAtt = null;
|
||||
try {
|
||||
insideConferenceMaterialsFileAtt = getFileAtt("内部会议资料",sarLawsTopic.getInsideConferenceMaterials(), fileMap, index);
|
||||
} catch (Exception e) {
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
sarLawsTopic.setInsideConferenceMaterials(insideConferenceMaterialsFileAtt);
|
||||
String insideResearchFindingsFileAtt = null;
|
||||
try {
|
||||
insideResearchFindingsFileAtt = getFileAtt("内部研究成果",sarLawsTopic.getInsideResearchFindings(), fileMap, index);
|
||||
} catch (Exception e) {
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
sarLawsTopic.setInsideResearchFindings(insideResearchFindingsFileAtt);
|
||||
String insideOtherFileAtt = null;
|
||||
try {
|
||||
insideOtherFileAtt = getFileAtt("内部其他",sarLawsTopic.getInsideOther(), fileMap, index);
|
||||
} catch (Exception e) {
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
sarLawsTopic.setInsideOther(insideOtherFileAtt);
|
||||
addLawsTopicInfo(sarLawsTopic);
|
||||
}
|
||||
index++;
|
||||
}
|
||||
return Result.success("导入成功");
|
||||
}
|
||||
@@ -494,6 +592,34 @@ public class SarLawsTopicServiceImpl extends ServiceImpl<SarLawsTopicMapper, Sar
|
||||
}
|
||||
return resultlist;
|
||||
}
|
||||
|
||||
public String getFileAtt(String fieldName,String fileNameStr, Map<String, File> fileMap, int count) throws Exception {
|
||||
if (fileNameStr != null) {
|
||||
List<String> fileAttList = new ArrayList<>();
|
||||
for (String fileName : fileNameStr.split(",")) {
|
||||
int lastIndexOf = fileName.lastIndexOf(".");
|
||||
if (fileName.lastIndexOf(".") != -1) {
|
||||
String lastName = fileName.substring(lastIndexOf + 1).toLowerCase();
|
||||
if (lastName.equals("pdf") || lastName.equals("ppt") || lastName.equals("pptx") || lastName.equals("doc") || lastName.equals("docx")) {
|
||||
File file1 = fileMap.get(fileName);
|
||||
if (file1 == null) {
|
||||
throw new Exception(fieldName + "中第" + (count+1) +"行" + fileName + "文件不存在,请上传pdf/ppt/pptx/doc/docx格式的附件");
|
||||
}
|
||||
AttFileVo attFileVo = attFileEOService.saveFileInfo(file1);
|
||||
if (StringUtils.isNotBlank(attFileVo.getId())) {
|
||||
fileAttList.add(attFileVo.getAttId());
|
||||
}
|
||||
} else {
|
||||
throw new Exception(fieldName + "中第" + (count+1) +"行" + fileName + "格式不正确,请上传pdf/ppt/pptx/doc/docx格式的附件");
|
||||
}
|
||||
} else {
|
||||
throw new Exception(fieldName + "中第" + (count+1) +"行" + fileName + "格式不正确,请上传pdf/ppt/pptx/doc/docx格式的附件");
|
||||
}
|
||||
}
|
||||
return String.join(",", fileAttList);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ public class FieldConvertUtil {
|
||||
public static String exportFieldLawsInformation = "1级资料分类,2级资料分类,3级资料分类,4级资料分类,资料名称,资料归属部门,作者,资料说明,资料文件";
|
||||
|
||||
// 政策课题 表头
|
||||
public static String exportFieldLawsTopic = "课题名称,课题承办单位,课题指导单位,课题参与单位,开始时间,结题时间,课题费用(万元),课题组会议列表,课题组联系方式,内部联系方式";
|
||||
public static String exportFieldLawsTopic = "课题名称,课题承办单位,课题指导单位,课题参与单位,开始时间,结题时间,课题费用(万元),协议,课题组会议列表,课题组研究方案,课题组研究成果,课题组其他,课题组会议资料,课题组联系方式,内部立项报告,内部研究方案,内部会议资料,内部研究成果,内部其他,内部联系方式";
|
||||
// 政策课题关联表 表头
|
||||
public static String exportFieldLawsTopicRelation = "会议名称,会议时间,会议地点,参会人员(内部),会议主要内容,姓名,单位,电话,邮箱,身份,姓名,单位,电话,邮箱,身份";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user