拆分条款-导出导入文件

This commit is contained in:
liyawei
2022-04-07 20:13:09 +08:00
parent 7da98e7371
commit 3e776f5528
6 changed files with 186 additions and 147 deletions
@@ -192,11 +192,12 @@ public class FileSplitItemsEOController extends JeroController<SarFileSplitItems
@GetMapping(value = "/exportSplitInfoZip")
public void exportSplitInfoZip(@RequestParam(value = "cut") String cut,
@RequestParam(value = "idList", required = false) String idList,
@RequestParam(value = "infoId") String infoId,
@RequestParam(value = "exportName", required = false) String exportName,
@RequestParam(value = "parameter") String parameter,
HttpServletResponse response,
HttpServletRequest request) {
fileSplitItemsEOService.exportSplitInfo(cut, idList, infoId, exportName, response, request);
Map<String, Object> parameterMap = JSONObject.parseObject(parameter);
fileSplitItemsEOService.exportSplitInfo(cut, idList, parameterMap, exportName, response, request);
}
@ApiOperation(value = "文档拆分条款信息-导入拆分结果")
@@ -87,7 +87,7 @@ public class SarFileSplitInfoController extends JeroController<SarFileSplitInfoE
if(bindState){
return Result.OK("回传成功");
} else {
return Result.error("回传失败");
return Result.error("文档库不存在当前文档,回传失败");
}
}
@@ -60,7 +60,7 @@ public interface FileSplitItemsEOMapper extends BaseMapper<SarFileSplitItemsEO>
List<Map<String, Object>> queryByOrdersForExport(@Param("field") String field,
@Param("idList")List<String> idList,
@Param("infoId") String infoId);
@Param("condition") String condition);
int deleteByMenuIds(@Param("idList") List<String> idList);
@@ -81,7 +81,7 @@
select sar_file_split_items.id,${field}
from sar_file_split_items
left join SAR_FILE_SPLIT_MENU on sar_file_split_items.MENU_ID = SAR_FILE_SPLIT_MENU.id
where 1=1 and sar_file_split_items.info_id = #{infoId}
${condition}
<if test="idList != null">
and sar_file_split_items.id in
<foreach collection="idList" index="index" item="item" open="(" separator="," close=")">
@@ -3,6 +3,7 @@ package com.jero.modules.split.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.jero.common.api.vo.Result;
import com.jero.modules.oss.entity.OSSFile;
import com.jero.modules.split.common.SplitTableInfo;
import com.jero.modules.split.dto.FileSpiltValTableExportDto;
import com.jero.modules.split.dto.FileSplitValExportDto;
@@ -61,11 +62,13 @@ public interface IFileSplitItemsEOService extends IService<SarFileSplitItemsEO>
Map<String, Object> filterMap(Map<String, Object> map);
List<Map<String, Object>> queryByOrdersForExport(String cut, String field, List<String> idList, String infoId);
List<Map<String, Object>> queryByOrdersForExport(String cut, String field, List<String> idList, Map<String, Object> parameter);
void downLoadImgList(List<FileSplitValImgExportDto> allImgList,String fileNowPath) throws IOException;
void exportSplitInfo(String cut, String idList, String infoId,String exportName, HttpServletResponse response, HttpServletRequest request);
void downLoadFileList(List<OSSFile> allRelevFileList, String fileNowPath) throws IOException;
void exportSplitInfo(String cut, String idList, Map<String, Object> parameter,String exportName, HttpServletResponse response, HttpServletRequest request);
List<FileSplitValExportDto> combineItemValInfo(List<SarFileSplitItemsValEO> getValList,
List<FileSpiltValTableExportDto> allTableList,
@@ -158,7 +158,7 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
String ossFileId = valEO.getItemContent();
OSSFile ossFile = ossFileService.getById(ossFileId);
String url = ossFile.getUrl();
String imgUrl = imgpath + url.substring(url.lastIndexOf("/")); // TODO 本地是反斜杠,服务器上是正斜杠?
String imgUrl = imgpath + url.substring(url.lastIndexOf(File.separator)+1);
valEO.setItemContent(imgUrl);
valContent = "<img class=\"wordImg\" src=\""+ valEO.getItemContent() +"\">";
// valContent = valEO.getItemContent();
@@ -237,7 +237,7 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
String ossFileId = valEO.getItemContent();
OSSFile ossFile = ossFileService.getById(ossFileId);
String url = ossFile.getUrl();
String imgUrl = imgpath + url.substring(url.lastIndexOf("/"));
String imgUrl = imgpath + url.substring(url.lastIndexOf(File.separator)+1);
valEO.setItemContent(imgUrl);
}
valContent = "<img class=\"wordImg\" src=\"" + valEO.getItemContent() + "\">";
@@ -498,7 +498,7 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
// }
// }
//sql查询条件
String condition = getConditionStr(parameter);
String condition = getConditionStr(parameter, "page");
int pageNo = Integer.parseInt((String) parameter.get("pageNo"));
int pageSize = Integer.parseInt((String) parameter.get("pageSize"));
IPage page = new Page(pageNo, pageSize);
@@ -643,7 +643,7 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
}
@NotNull
private String getConditionStr(Map<String, Object> parameter) {
private String getConditionStr(Map<String, Object> parameter, String type) {
//查询条件
StringBuilder conditionSb = new StringBuilder("where 1 = 1");
@@ -719,7 +719,9 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
}
}
//处理列表表头排序
conditionSb.append(" order by SAR_FILE_SPLIT_MENU.display_seq asc");
if("page".equals(type)) {
conditionSb.append(" order by SAR_FILE_SPLIT_MENU.display_seq asc");
}
String condition = conditionSb.toString();
return condition;
}
@@ -1102,16 +1104,16 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
String url = nowfilelist.get(0).getPath();
MultipartFile multipartFile = createMfileByPath(url);
String state = "0";
String fileSuffix = url.substring(url.lastIndexOf("."));
String fileTypeStr = ".doc,.DOC,.docx,.DOCX,.xls, .XLS,.xlsx,.XLSX,.pdf,.PDF";
if (fileTypeStr.contains(fileSuffix)) {
state = "1";
}
// String fileSuffix = url.substring(url.lastIndexOf("."));
// String fileTypeStr = ".doc,.DOC,.docx,.DOCX,.xls, .XLS,.xlsx,.XLSX,.pdf,.PDF";
// if (fileTypeStr.contains(fileSuffix)) {
// state = "1";
// }
OSSFile oSSFile = ossFileService.uploadLocal(multipartFile, "",state);
if(oSSFile!=null){
oSSFile = ossFileService.getById(oSSFile.getId());
isText = false;
String path = imgpath + oSSFile.getUrl().substring(oSSFile.getUrl().lastIndexOf("/"));
String path = imgpath + oSSFile.getUrl().substring(oSSFile.getUrl().lastIndexOf(File.separator)+1);
String imgCon = "<img class=\"wordImg\" src=\"" + path + "\">";
valEO.setType("IMG");
// valEO.setItemContent(imgCon);
@@ -1147,16 +1149,17 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
String url = nowfilelist.get(0).getPath();
MultipartFile multipartFile = createMfileByPath(url);
String state = "0";
String fileSuffix = url.substring(url.lastIndexOf("."));
String fileTypeStr = ".doc,.DOC,.docx,.DOCX,.xls, .XLS,.xlsx,.XLSX,.pdf,.PDF";
if (fileTypeStr.contains(fileSuffix)) {
state = "1";
}
// String fileSuffix = url.substring(url.lastIndexOf("."));
// String fileTypeStr = ".doc,.DOC,.docx,.DOCX,.xls, .XLS,.xlsx,.XLSX,.pdf,.PDF";
// if (fileTypeStr.contains(fileSuffix)) {
// state = "1";
// }
OSSFile oSSFile = ossFileService.uploadLocal(multipartFile, "", state);
oSSFile = ossFileService.getById(oSSFile.getId());
if (oSSFile != null) {
oSSFile = ossFileService.getById(oSSFile.getId());
isText = false;
String path = imgpath + oSSFile.getUrl().substring(oSSFile.getUrl().lastIndexOf("/"));
String path = imgpath + oSSFile.getUrl().substring(oSSFile.getUrl().lastIndexOf(File.separator)+1);
String imgCon = "<img class=\"wordImg\" src=\"" + path + "\">";
valEO.setType("IMG");
// valEO.setItemContent(imgCon);
@@ -1192,10 +1195,14 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
}
List<File> nowfilelist = FileUnZip.readFileByFilename(filepath, valArr[i]);
if (nowfilelist != null && !nowfilelist.isEmpty()) {
OSSFile oSSFile = ossFileService.uploadLocal((MultipartFile) nowfilelist.get(0), "", "1");
String url = nowfilelist.get(0).getPath();
MultipartFile multipartFile = createMfileByPath(url);
String state = "0";
OSSFile oSSFile = ossFileService.uploadLocal(multipartFile, "", state);
oSSFile = ossFileService.getById(oSSFile.getId());
if (oSSFile != null) {
isText = false;
String path = imgpath + oSSFile.getUrl().substring(oSSFile.getUrl().lastIndexOf("/"));
String path = imgpath + oSSFile.getUrl().substring(oSSFile.getUrl().lastIndexOf(File.separator)+1);
String imgCon = "<img class=\"wordImg\" src=\"" + path + "\">";
valEO.setType("IMG");
// valEO.setItemContent(imgCon);
@@ -1342,10 +1349,10 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
if(!saveDirectory.isDirectory()){
saveDirectory.mkdir();
}
FileUtils.copyInputStreamToFile(file.getInputStream(), new File(path +"/"+ file.getOriginalFilename()));
FileUtils.copyInputStreamToFile(file.getInputStream(), new File(path +File.separator+ file.getOriginalFilename()));
try{
//解压缩
String zipEntryName = FileUnZip.unZipFiles(path +"/"+ file.getOriginalFilename(),path);
String zipEntryName = FileUnZip.unZipFiles(path +File.separator+ file.getOriginalFilename(),path);
// 数据相关处理,
// 1.获取其中的Excel,
List<File> excelfilelist = FileUnZip.readExcelFile(zipEntryName);
@@ -1386,6 +1393,7 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
splitTableInfo.setTableName(sheet.getSheetName());
String tableHtml = POIReadExcelToHtml.readExcelToHtml(workbook,i,false);
tableHtml = tableHtml.replaceAll("\'","\"");
tableHtml = tableHtml.replaceAll("style","border=\"1\" style");// 解决导入的表格没线
splitTableInfo.setTableHtml(tableHtml);
getSheetTableList.add(splitTableInfo);
}
@@ -1473,7 +1481,7 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
FileInputStream fileInputStream = new FileInputStream(file);
String fileName = file.getName();
fileName = fileName.substring((fileName.lastIndexOf("/") + 1));
fileName = fileName.substring((fileName.lastIndexOf(File.separator) + 1));
mFile = new MockMultipartFile(fileName, fileName, ContentType.APPLICATION_OCTET_STREAM.toString(), fileInputStream);
} catch (Exception e) {
log.error("封装文件出现错误:{}", e);
@@ -2100,7 +2108,7 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
String regex = "^[0-9]{0}([0-9]|[.])+$"; //TODO 待优化:数字和点必须交替
for (Map<String, Object> itemEO : addItemsEOList) {
String itemNum = itemEO.get("items_num").toString();
if(itemNum.matches(regex) || itemNum.contains("附录")) {
// if(itemNum.matches(regex) || itemNum.contains("附录")) { // TODO 解除条款号格式限制
SarFileSplitMenuTreeNode treeNode = new SarFileSplitMenuTreeNode();
treeNode.setId(UUIDUtils.randomUUID20());
treeNode.setName(itemNum);
@@ -2128,7 +2136,7 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
treeNode.setItemName(itemEO.get("items_name").toString());
treeNode.setItemId(itemEO.get("id").toString());
treeNodeList.add(treeNode);
}
// }
}
//其他节点
/*for (SarFileSplitItemsEO itemEO : addItemsEOList) {
@@ -2578,11 +2586,14 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
return newMap;
}
public List<Map<String, Object>> queryByOrdersForExport(String cut, String field, List<String> idList, String infoId){
public List<Map<String, Object>> queryByOrdersForExport(String cut, String field, List<String> idList, Map<String, Object> parameter){
if (CollectionUtil.isEmpty(idList)) {
idList = null;
}
List<Map<String, Object>> itemsDataForExport = dao.queryByOrdersForExport(field,idList, infoId);
//sql查询条件
String condition = getConditionStr(parameter, "export");
List<Map<String, Object>> itemsDataForExport = dao.queryByOrdersForExport(field, idList, condition);
// 查询条款表所有字段
List<OnlCgformField> fieldList = onlCgformFieldService.getFieldList(ModuleEnum.FILE_SPLIT_ITEMS.getValue());
// 日期类型字段
@@ -2601,10 +2612,10 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
.collect(Collectors.toList());
List<String> fieldStanList = onlCgformFieldStanList.stream().map(OnlCgformField::getDbFieldName).collect(Collectors.toList());
// 文件字段
List<OnlCgformField> onlCgformFieldFileList = fieldList.stream()
.filter(e -> FieldTypeEnum.FILE.getValue().equals(e.getFieldShowType()))
.collect(Collectors.toList());
List<String> fileList = onlCgformFieldFileList.stream().map(OnlCgformField::getDbFieldName).collect(Collectors.toList());
// List<OnlCgformField> onlCgformFieldFileList = fieldList.stream()
// .filter(e -> FieldTypeEnum.FILE.getValue().equals(e.getFieldShowType()))
// .collect(Collectors.toList());
// List<String> fileList = onlCgformFieldFileList.stream().map(OnlCgformField::getDbFieldName).collect(Collectors.toList());
// 过滤导出字段
if (fieldList.size() != 0) {
@@ -2634,9 +2645,9 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
// 树形结构处理数据字典
treeDictItem(categoryList, entry, treeFieldList, cut);
// 文件类型 获取connectId 用于列表回显文件名
if(fileList.contains(entry.getKey()) && StringUtils.isNotBlank((String)entry.getValue())){
fileIdList.add((String)entry.getValue());
}
// if(fileList.contains(entry.getKey()) && StringUtils.isNotBlank((String)entry.getValue())){
// fileIdList.add((String)entry.getValue());
// }
// 单日期
if(fieldDateList.contains(entry.getKey()) && ObjectUtil.isNotEmpty(entry.getValue())){
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
@@ -2645,12 +2656,14 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
// 人员选择
if(fieldPersonList.contains(entry.getKey()) && StringUtils.isNotBlank((String)entry.getValue())) {
List<SysUser> sysUserList = sysUserService.listByIds(Arrays.asList(entry.getValue().toString().split(",")));
StringBuilder stringBuilder = new StringBuilder();
for(SysUser user : sysUserList){
stringBuilder.append(user.getRealname()).append("(").append(user.getUsername()).append("),");
if(CollectionUtil.isNotEmpty(sysUserList)){
StringBuilder stringBuilder = new StringBuilder();
for(SysUser user : sysUserList){
stringBuilder.append(user.getRealname()).append("(").append(user.getUsername()).append("),");
}
String value = stringBuilder.substring(0, stringBuilder.lastIndexOf(","));
entry.setValue(value);
}
String value = stringBuilder.substring(0, stringBuilder.lastIndexOf(","));
entry.setValue(value);
}
// 标准选择
if(fieldStanList.contains(entry.getKey()) && StringUtils.isNotBlank((String)entry.getValue())) {
@@ -2663,24 +2676,24 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
}
}
// 拼接文件名
if(fileIdList.size() != 0){
List<OSSFile> fileInfos = ossFileService.getFileInfos(StringUtils.join(fileIdList, ","));
if(fileInfos.size() != 0){
for (Map record : itemsDataForExport) {
Map<String, Object> record1 = (Map) record;
for (Map.Entry<String, Object> entry : record1.entrySet()) {
if(fileList.contains(entry.getKey()) && StringUtils.isNotBlank((String) entry.getValue())){
String value = (String) entry.getValue();
List<OSSFile> ossFileList = fileInfos.stream().filter(e -> value.equals(e.getConnectId())).collect(Collectors.toList());
if(ossFileList.size() != 0){
List<String> fileNameList = ossFileList.stream().map(OSSFile::getFileName).collect(Collectors.toList());
entry.setValue(StringUtils.join(fileNameList,","));
}
}
}
}
}
}
// if(fileIdList.size() != 0){
// List<OSSFile> fileInfos = ossFileService.getFileInfos(StringUtils.join(fileIdList, ","));
// if(fileInfos.size() != 0){
// for (Map record : itemsDataForExport) {
// Map<String, Object> record1 = (Map) record;
// for (Map.Entry<String, Object> entry : record1.entrySet()) {
// if(fileList.contains(entry.getKey()) && StringUtils.isNotBlank((String) entry.getValue())){
// String value = (String) entry.getValue();
// List<OSSFile> ossFileList = fileInfos.stream().filter(e -> value.equals(e.getConnectId())).collect(Collectors.toList());
// if(ossFileList.size() != 0){
// List<String> fileNameList = ossFileList.stream().map(OSSFile::getFileName).collect(Collectors.toList());
// entry.setValue(StringUtils.join(fileNameList,","));
// }
// }
// }
// }
// }
// }
return itemsDataForExport;
}
@@ -2724,7 +2737,7 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
valContent.add(lastOne);
FileSplitValImgExportDto fileSplitValImgExportDto = new FileSplitValImgExportDto();
fileSplitValImgExportDto.setImgName(imgUUIndex+".png");
fileSplitValImgExportDto.setImgPath(imgContent.substring(imgContent.lastIndexOf("/")+1));
fileSplitValImgExportDto.setImgPath(imgContent.substring(imgContent.lastIndexOf(File.separator)+1));
allImgList.add(fileSplitValImgExportDto);
imgIndex++;
page.setImgIndex(imgIndex);
@@ -2757,8 +2770,20 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
public void downLoadImgList(List<FileSplitValImgExportDto> allImgList, String fileNowPath) throws IOException {
for(FileSplitValImgExportDto imgExportDto : allImgList){
String oldPath = uploadpath+ "/" + imgExportDto.getImgPath();
String newPath = fileNowPath + "/" + imgExportDto.getImgName();
String oldPath = uploadpath+ File.separator + imgExportDto.getImgPath();
String newPath = fileNowPath + File.separator + imgExportDto.getImgName();
File oldFile = new File(oldPath);
if (oldFile.exists()){
copyFile1(oldPath, newPath);
}
}
}
public void downLoadFileList(List<OSSFile> allRelevFileList,String fileNowPath) throws IOException {
for(OSSFile fileExportDto : allRelevFileList){
String oldPath = fileExportDto.getUrl();
String newPath = fileNowPath + File.separator + fileExportDto.getFileName();
File oldFile = new File(oldPath);
if (oldFile.exists()){
copyFile1(oldPath, newPath);
@@ -2790,7 +2815,7 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
}
@Override
public void exportSplitInfo(String cut, String idList, String infoId,String exportName, HttpServletResponse response, HttpServletRequest request) {
public void exportSplitInfo(String cut, String idList, Map<String, Object> parameter,String exportName, HttpServletResponse response, HttpServletRequest request) {
OutputStream os = null;
OutputStream excelOS = null;
HSSFWorkbook workbook = new HSSFWorkbook();
@@ -2800,7 +2825,7 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
}
try{
//创建临时文件夹
String fileNowPath = uploadpath + "/tempZip/" + UUID.randomUUID().toString().replace("-","") + "/" + fileOriName;
String fileNowPath = uploadpath + "/tempZip/" + UUID.randomUUID().toString().replace("-","") + File.separator + fileOriName;
File nowFile = new File(fileNowPath);
if (nowFile.exists()){
nowFile.delete();
@@ -2825,22 +2850,29 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
// 处理勾选导出相关字段
List<String> itemIdList = new ArrayList<>();
SarFileSplitItemsEOPage page = new SarFileSplitItemsEOPage();
page.setInfoId(infoId);
page.setOrderBy("SAR_FILE_SPLIT_MENU.display_seq asc");
if (org.apache.commons.lang.StringUtils.isNotEmpty(idList)) {
String[] idArr = idList.split(",");
itemIdList = Arrays.asList(idArr);
page.setIdList(itemIdList);
}
// page.setInfoId(infoId);
// page.setOrderBy("SAR_FILE_SPLIT_MENU.display_seq asc");
// if (org.apache.commons.lang.StringUtils.isNotEmpty(idList)) {
// String[] idArr = idList.split(",");
// itemIdList = Arrays.asList(idArr);
// page.setIdList(itemIdList);
// }
// 查询需要导出的字段
String field = getFieldForExport(); // 字符串形式
List<String> fieldList = Arrays.asList(field.split(",")); // list形式
// 查询导出数据
List<Map<String, Object>> allItemsList = queryByOrdersForExport(cut, field, itemIdList, infoId); // id记得去掉
List<Map<String, Object>> allItemsList = queryByOrdersForExport(cut, field, itemIdList, parameter); // id记得去掉
// 文件类型字段
List<OnlCgformField> allFieldList = onlCgformFieldService.getFieldList(ModuleEnum.FILE_SPLIT_ITEMS.getValue()); // 查询条款表所有字段
List<OnlCgformField> onlCgformFieldFileList = allFieldList.stream()
.filter(e -> FieldTypeEnum.FILE.getValue().equals(e.getFieldShowType()))
.collect(Collectors.toList());
List<String> fileList = onlCgformFieldFileList.stream().map(OnlCgformField::getDbFieldName).collect(Collectors.toList());
// 开始处理工作表
List<FileSpiltValTableExportDto> allTableList = new ArrayList<>(); // 存储表格数据
List<FileSplitValImgExportDto> allImgList = new ArrayList<>(); // 存储文件数据
List<OSSFile> allRelevFileList = new ArrayList<>();
int countMaxFile = 1;
if (allItemsList != null && !allItemsList.isEmpty()) {
for (Map<String, Object> itemsExportDto : allItemsList) {
@@ -2881,8 +2913,37 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
// 开始向单元格添加数据
for(int cellNum = 0; cellNum < fieldList.size(); cellNum++){
if (!"iterms_conditions".equals(fieldList.get(cellNum)) && ObjectUtils.isNotEmpty(exportDto.get(fieldList.get(cellNum)))) {
row1.createCell(cellNum).setCellValue(exportDto.get(fieldList.get(cellNum)).toString());
row1.getCell(cellNum).setCellStyle(cellStyle);
// 处理文件
if(fileList.contains(fieldList.get(cellNum))) {
String connectId = (String) exportDto.get(fieldList.get(cellNum));
List<OSSFile> ossFileList = ossFileService.getFileInfosByConnectId(connectId);
List<String> fileNameList = new ArrayList<>();
if (ossFileList != null && !ossFileList.isEmpty()) {
fileNameList = ossFileList.stream().map(OSSFile :: getFileName).collect(Collectors.toList());
row1.createCell(cellNum).setCellValue(StringUtils.join(fileNameList, ","));
row1.getCell(cellNum).setCellStyle(cellStyle);
// if (countMaxFile < fileList.size()) {
// countMaxFile = fileList.size();
// }
// countFile = 0;
// for (OSSFile ossFile : ossFileList) {
/* 连接跳转*/ // 搞不了
// String releFileName = ossFile.getFileName();
// CreationHelper createHelper = workbook.getCreationHelper();
// Hyperlink hyperlink1 = createHelper.createHyperlink(HyperlinkType.URL);
// hyperlink1.setAddress(releFileName);
// row1.createCell(9 + countFile).setHyperlink(hyperlink1);
// row1.createCell(9 + countFile).setCellValue(releFileName);
// row1.getCell(9 + countFile).setCellStyle(cellStyleLink);
// countFile++;
// }
allRelevFileList.addAll(ossFileList);
}
} else {
row1.createCell(cellNum).setCellValue(exportDto.get(fieldList.get(cellNum)).toString());
row1.getCell(cellNum).setCellStyle(cellStyle);
}
} else if ("iterms_conditions".equals(fieldList.get(cellNum))) {
// 条款内容特殊处理
HSSFCell cell2 = row1.createCell(cellNum);
@@ -2914,47 +2975,6 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
cell2.setCellValue(content);
}
}
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
// if (exportDto.getNewcarPutTime() != null) {
// String time= sdf.format(exportDto.getNewcarPutTime());
// row1.createCell(3).setCellValue(time);
// row1.getCell(3).setCellStyle(cellStyle);
// }
// if (exportDto.getProductPutTime() != null) {
// String time= sdf.format(exportDto.getProductPutTime());
// row1.createCell(4).setCellValue(time);
// row1.getCell(4).setCellStyle(cellStyle);
// }
// row1.createCell(5).setCellValue(exportDto.getFunctionTerritory());
// row1.getCell(5).setCellStyle(cellStyle);
// row1.createCell(6).setCellValue(exportDto.getApplyArctic());
// row1.getCell(6).setCellStyle(cellStyle);
// row1.createCell(7).setCellValue(exportDto.getReferenceStand());
// row1.getCell(7).setCellStyle(cellStyle);
// row1.createCell(8).setCellValue(exportDto.getTechnologyTerritory());
// row1.getCell(8).setCellStyle(cellStyle);
// if (StringUtils.isNotEmpty(exportDto.getRelevanceFile())) {
// List<AttFileEO> fileList = attFileEOService.getMultiFileInfos(exportDto.getRelevanceFile());
// if (fileList != null && !fileList.isEmpty()) {
// if (countMaxFile < fileList.size()) {
// countMaxFile = fileList.size();
// }
// countFile = 0;
// for (AttFileEO attFileEO : fileList) {
// /* 连接跳转*/
// String releFileName = attFileEO.getOldFileName();
// CreationHelper createHelper = workbook.getCreationHelper();
// Hyperlink hyperlink1 = createHelper.createHyperlink(HyperlinkType.URL);
//// String addr = new String(releFileName.getBytes(),"UTF-8");
// hyperlink1.setAddress(releFileName);
// row1.createCell(9+countFile).setHyperlink(hyperlink1);
// row1.createCell(9+countFile).setCellValue(releFileName);
// row1.getCell(9+countFile).setCellStyle(cellStyleLink);
// countFile++;
// }
// allRelevFileList.addAll(fileList);
// }
//
}
if (allRow > startRow) {
for(int cellNum = 0; cellNum < fieldList.size(); cellNum++) {
@@ -2973,40 +2993,50 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
HSSFRow row1 = sheetItems.createRow(allRow);
for(int cellNum = 0; cellNum < fieldList.size(); cellNum++){
if (!"iterms_conditions".equals(fieldList.get(cellNum)) && ObjectUtils.isNotEmpty(exportDto.get(fieldList.get(cellNum)))) {
row1.createCell(cellNum).setCellValue(exportDto.get(fieldList.get(cellNum)).toString());
row1.getCell(cellNum).setCellStyle(cellStyle);
// 处理文件
if(fileList.contains(fieldList.get(cellNum))) {
String connectId = (String) exportDto.get(fieldList.get(cellNum));
List<OSSFile> ossFileList = ossFileService.getFileInfosByConnectId(connectId);
List<String> fileNameList = new ArrayList<>();
if (ossFileList != null && !ossFileList.isEmpty()) {
fileNameList = ossFileList.stream().map(OSSFile :: getFileName).collect(Collectors.toList());
row1.createCell(cellNum).setCellValue(StringUtils.join(fileNameList, ","));
row1.getCell(cellNum).setCellStyle(cellStyle);
// if (countMaxFile < fileList.size()) {
// countMaxFile = fileList.size();
// }
// countFile = 0;
// for (OSSFile ossFile : ossFileList) {
/* 连接跳转*/ // 搞不了
// String releFileName = ossFile.getFileName();
// CreationHelper createHelper = workbook.getCreationHelper();
// Hyperlink hyperlink1 = createHelper.createHyperlink(HyperlinkType.URL);
// hyperlink1.setAddress(releFileName);
// row1.createCell(9 + countFile).setHyperlink(hyperlink1);
// row1.createCell(9 + countFile).setCellValue(releFileName);
// row1.getCell(9 + countFile).setCellStyle(cellStyleLink);
// countFile++;
// }
allRelevFileList.addAll(ossFileList);
}
} else {
row1.createCell(cellNum).setCellValue(exportDto.get(fieldList.get(cellNum)).toString());
row1.getCell(cellNum).setCellStyle(cellStyle);
}
} else if ("iterms_conditions".equals(fieldList.get(cellNum))) {
row1.createCell(cellNum).setCellValue("");
row1.getCell(cellNum).setCellStyle(cellStyle);
}
}
// if (StringUtils.isNotEmpty(exportDto.getRelevanceFile())) {
// List<AttFileEO> fileList = attFileEOService.getMultiFileInfos(exportDto.getRelevanceFile());
// if (fileList != null && !fileList.isEmpty()) {
// countFile = 0;
// for (AttFileEO attFileEO : fileList) {
// /* 连接跳转*/
// String releFileName = attFileEO.getOldFileName();
// CreationHelper createHelper = workbook.getCreationHelper();
// Hyperlink hyperlink1 = createHelper.createHyperlink(HyperlinkType.URL);
//// String addr = new String(releFileName.getBytes(),"UTF-8");
// hyperlink1.setAddress(releFileName);
// row1.createCell(9+countFile).setHyperlink(hyperlink1);
// row1.createCell(9+countFile).setCellValue(releFileName);
// row1.getCell(9+countFile).setCellStyle(cellStyleLink);
// countFile++;
// }
// allRelevFileList.addAll(fileList);
// }
// }
}
}
if (countMaxFile > 1) {
for (int i=1;i<countMaxFile;i++) {
sheetItems.setColumnWidth(9+i,40*256);
}
sheetItems.addMergedRegion(new CellRangeAddress(0,0,9,9+countMaxFile-1));
}
// if (countMaxFile > 1) {
// for (int i=1;i<countMaxFile;i++) {
// sheetItems.setColumnWidth(9+i,40*256);
// }
// sheetItems.addMergedRegion(new CellRangeAddress(0,0,9,9+countMaxFile-1));
// }
// 放表格内容
if(allTableList!= null && !allTableList.isEmpty()){
for(FileSpiltValTableExportDto tableExportDto : allTableList){
@@ -3041,9 +3071,14 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
if (allImgList != null && !allImgList.isEmpty()) {
downLoadImgList(allImgList,fileNowPath);
}
//下载关联文件内容
if (allRelevFileList != null && !allRelevFileList.isEmpty()) {
allRelevFileList = allRelevFileList.stream().distinct().collect(Collectors.toList());
downLoadFileList(allRelevFileList,fileNowPath);
}
String repFileName = fileName.replaceAll("/","_");
excelOS = new FileOutputStream(fileNowPath + "/" + repFileName);
excelOS = new FileOutputStream(fileNowPath + File.separator + repFileName);
response.setHeader("Content-Disposition",
"attachment; filename=\""+ ReadExcel.encodeFileName(fileOriName+".zip", request) +"\"");
response.setContentType("application/force-download");