拆分流程图片展示以及导出出片超链接格式
This commit is contained in:
@@ -150,6 +150,9 @@ elasticsearch.port=9306
|
||||
elasticsearch.poolSize=5
|
||||
elas.flag=true
|
||||
|
||||
# 拆分的图片调用 (修改ip时此处也应该被修改)
|
||||
elasticsearch.img=http://localhost:9090
|
||||
|
||||
# \u6587\u6863\u8F6C\u6362TCP\u901A\u8BAF\u5730\u5740
|
||||
convert.host=127.0.0.1
|
||||
|
||||
|
||||
+51
-9
@@ -3,6 +3,7 @@ package com.adc.da.slrs.standardSplit.controller;
|
||||
import cn.afterturn.easypoi.excel.ExcelImportUtil;
|
||||
import cn.afterturn.easypoi.excel.entity.ImportParams;
|
||||
import cn.hutool.core.util.ZipUtil;
|
||||
import com.adc.da.att.controller.AttFileEOController;
|
||||
import com.adc.da.att.entity.AttFileEO;
|
||||
import com.adc.da.att.service.IAttFileEOService;
|
||||
import com.adc.da.base.web.BaseController;
|
||||
@@ -18,11 +19,13 @@ import com.adc.da.sys.util.UUIDUtils;
|
||||
import com.adc.da.util.exception.AdcDaBaseException;
|
||||
import com.adc.da.util.http.ResponseMessage;
|
||||
import com.adc.da.util.http.Result;
|
||||
import com.adc.da.util.utils.FileUtil;
|
||||
import com.adc.da.util.utils.IOUtils;
|
||||
import com.adc.da.utils.util.POIReadExcelToHtml;
|
||||
import com.adc.da.common.ReadExcel;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.poi.common.usermodel.HyperlinkType;
|
||||
@@ -217,12 +220,34 @@ public class SarFileSplitItemsEOController extends BaseController<SarFileSplitIt
|
||||
List<FileSplitValImgExportDto> allImgList = new ArrayList<>();
|
||||
List<AttFileEO> allRelevFileList = new ArrayList<>();
|
||||
int countMaxFile = 1;
|
||||
String fileIds = "";
|
||||
if (allItemsList != null && !allItemsList.isEmpty()) {
|
||||
for (FileSplitItemsExportDto itemsExportDto : allItemsList) {
|
||||
SarFileSplitItemsValEOPage valEOPage = new SarFileSplitItemsValEOPage();
|
||||
valEOPage.setItemId(itemsExportDto.getId());
|
||||
valEOPage.setOrderBy("DISPLAY_SEQ,ID");
|
||||
List<SarFileSplitItemsValEO> getValList = sarFileSplitItemsValEOService.queryByList(valEOPage);
|
||||
|
||||
for (SarFileSplitItemsValEO sarFileSplitItemsValEO : getValList){
|
||||
//判断数据是否是img
|
||||
if(sarFileSplitItemsValEO.getType().equals("img") || sarFileSplitItemsValEO.getType().equals("IMG")){
|
||||
//进行分割
|
||||
String[] split = sarFileSplitItemsValEO.getItemContent().split("=");
|
||||
//获取图片id
|
||||
String[] split1 = split[3].split("'");
|
||||
sarFileSplitItemsValEO.setItemContent(split1[0]);
|
||||
//循环数据 获取id
|
||||
if(StringUtils.isBlank(fileIds)){
|
||||
fileIds = split1[0];
|
||||
}else {
|
||||
fileIds += ","+split1[0];
|
||||
}
|
||||
AttFileEO fileInfo = attFileEOService.getFileInfo(sarFileSplitItemsValEO.getItemContent());
|
||||
String excelImageUrl = "src='file:///E:/data/slrs/file"+fileInfo.getFilePath()+fileInfo.getOldFileName();
|
||||
// 数据加工
|
||||
sarFileSplitItemsValEO.setItemContent(excelImageUrl);
|
||||
}
|
||||
}
|
||||
List<FileSplitValExportDto> valContentList = sarFileSplitItemsEOService.combineItemValInfo(getValList,allTableList,allImgList,page);
|
||||
itemsExportDto.setItemValContent(valContentList);
|
||||
}
|
||||
@@ -278,7 +303,8 @@ public class SarFileSplitItemsEOController extends BaseController<SarFileSplitIt
|
||||
hyperlink1.setAddress(tableName);
|
||||
cell2.setHyperlink(hyperlink1);// 链接
|
||||
row1.getCell(2).setCellStyle(cellStyleLink);
|
||||
} else if ("IMG".equals(valList.get(valRow).getValType())) {
|
||||
} //else if ("IMG".equals(valList.get(valRow).getValType())) {
|
||||
if ("IMG".equals(valList.get(valRow).getValType())) {
|
||||
/* 连接跳转*/
|
||||
CreationHelper createHelper = workbook.getCreationHelper();
|
||||
Hyperlink hyperlink1 = createHelper.createHyperlink(HyperlinkType.FILE);
|
||||
@@ -392,19 +418,35 @@ public class SarFileSplitItemsEOController extends BaseController<SarFileSplitIt
|
||||
"attachment; filename=\""+ ReadExcel.encodeFileName(fileOriName+".zip", request) +"\"");
|
||||
response.setContentType("application/force-download");
|
||||
response.flushBuffer();
|
||||
|
||||
os = response.getOutputStream();
|
||||
workbook.write(excelOS);
|
||||
excelOS.flush();
|
||||
excelOS.close();
|
||||
ZipUtil.zip(fileNowPath,fileNowPath+".zip");
|
||||
FileInputStream fis = new FileInputStream(fileNowPath+".zip");
|
||||
int len = 0;
|
||||
while ((len = fis.read()) != -1) {
|
||||
os.write(len);
|
||||
// ZipUtil.zip(fileNowPath,fileNowPath+".zip");
|
||||
// FileInputStream fis = new FileInputStream(fileNowPath+".zip");
|
||||
// int len = 0;
|
||||
// while ((len = fis.read()) != -1) {
|
||||
// os.write(len);
|
||||
// }
|
||||
// os.flush();
|
||||
// os.close(); // 后开先关
|
||||
// fis.close(); // 先开后关
|
||||
|
||||
List<AttFileEO> multiFileInfos = this.attFileEOService.getMultiFileInfos(fileIds);
|
||||
if(CollectionUtils.isNotEmpty(multiFileInfos)){
|
||||
this.attFileEOService.downLoadFileList(multiFileInfos,fileNowPath);
|
||||
|
||||
ZipUtil.zip(fileNowPath,fileNowPath+".zip");
|
||||
FileInputStream fis = new FileInputStream(fileNowPath+".zip");
|
||||
int len = 0;
|
||||
while ((len = fis.read()) != -1) {
|
||||
os.write(len);
|
||||
}
|
||||
os.flush();
|
||||
os.close(); // 后开先关
|
||||
fis.close(); // 先开后关
|
||||
}
|
||||
os.flush();
|
||||
os.close(); // 后开先关
|
||||
fis.close(); // 先开后关
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
throw new AdcDaBaseException("下载文件失败,请重试");
|
||||
|
||||
+59
-2
@@ -1,6 +1,7 @@
|
||||
package com.adc.da.slrs.standardSplit.service.impl;
|
||||
|
||||
import com.adc.da.att.service.IAttFileEOService;
|
||||
import com.adc.da.att.vo.AttFileVo;
|
||||
import com.adc.da.person.entity.PersonMsgEO;
|
||||
import com.adc.da.slrs.sarStandAttrDetails.service.ISarStandAttrDetailsService;
|
||||
import com.adc.da.slrs.sarStandItems.entity.SarStandItems;
|
||||
@@ -68,6 +69,10 @@ public class SarFileSplitInfoEOServiceImpl implements SarFileSplitInfoEOService
|
||||
*/
|
||||
@Value("${file.downloadUrl}")
|
||||
private String downloadUrl;
|
||||
|
||||
@Value("${elasticsearch.img}")
|
||||
private String elasticsearchImg;//图片拆分自调地址
|
||||
|
||||
@Autowired
|
||||
private PersonShareEODao personShareEODao;
|
||||
@Autowired
|
||||
@@ -174,6 +179,8 @@ public class SarFileSplitInfoEOServiceImpl implements SarFileSplitInfoEOService
|
||||
// 记录word自动生成的编号数据
|
||||
Map numberMap = new HashMap<String,Integer>();
|
||||
boolean menuCanAdd = false; // 判断当前目录下是否可以正常填写数据
|
||||
boolean firstFlag = true;
|
||||
String regex = "^[0-9]*$";
|
||||
for (IBodyElement element : elements) {
|
||||
// 段落
|
||||
if (element instanceof XWPFParagraph) {
|
||||
@@ -185,6 +192,40 @@ public class SarFileSplitInfoEOServiceImpl implements SarFileSplitInfoEOService
|
||||
paragraphString = paragraphString.replace((char) 12288, ' ');
|
||||
paragraphString = paragraphString.trim();
|
||||
}
|
||||
if(StringUtils.isEmpty(paragraphString)){
|
||||
// 处理当前段落仅为图片的情况
|
||||
List<String> imageBundleList = readImageInParagraph((XWPFParagraph) p);
|
||||
if (CollectionUtils.isNotEmpty(imageBundleList)) {
|
||||
if (messageList.size() > 0) {
|
||||
addItermsConditionsImage(messageList.get(messageList.size() - 1), itemValList, p, imageBundleList);
|
||||
//attFileEOService.saveFileInfo();
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
paragraphString = paragraphString.replaceAll("\r\n","");
|
||||
paragraphString = paragraphString.replaceAll("\n","");
|
||||
paragraphString = paragraphString.trim();
|
||||
if ("前言".equals(getChinese(paragraphString)) && (paragraphString.replaceAll("\t", "")
|
||||
.replaceAll("\b", "").replaceAll(" ", "").length() == 2)) { // 前言后面有文本,判定为是目录中的前言
|
||||
firstFlag = false;
|
||||
}
|
||||
if(firstFlag) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (paragraphString.toLowerCase().contains("scope")) {
|
||||
String pp = paragraphString.replaceAll("\t", "")
|
||||
.replaceAll("\b", "").replaceAll(" ", "");
|
||||
if (!pp.substring(pp.length()-1).matches(regex)) {
|
||||
firstFlag = false;
|
||||
}
|
||||
}
|
||||
if (firstFlag) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (StringUtils.isNotEmpty(p.getNumLevelText())&& p.getNumLevelText().indexOf(".")>0) {
|
||||
String numberParent = p.getNumLevelText().substring(0,p.getNumLevelText().lastIndexOf("."));
|
||||
if (numberMap.containsKey(numberParent)){
|
||||
@@ -339,7 +380,6 @@ public class SarFileSplitInfoEOServiceImpl implements SarFileSplitInfoEOService
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
@@ -491,7 +531,12 @@ public class SarFileSplitInfoEOServiceImpl implements SarFileSplitInfoEOService
|
||||
FileOutputStream fos = new FileOutputStream(filepathandname);
|
||||
fos.write(bytev);
|
||||
String path = splitFilePath +"/" + imageName;
|
||||
String imgCon = "<img class=\'wordImg\' src=\'" + path + "\'>";
|
||||
//存入文件
|
||||
File file = new File(path);
|
||||
AttFileVo attFileVo = attFileEOService.saveFileInfo(file);
|
||||
//String imgCon = "<img class=\'wordImg\' src=\'" + path + "\'>";
|
||||
String pathSrc = elasticsearchImg+"/api/att/attFile/getFileInfo?fileId="+attFileVo.getId();
|
||||
String imgCon = "<img class=\'wordImg\' src=\'" + pathSrc + "\'>";
|
||||
message.getItemsCondi().add(imgCon);
|
||||
message.setItermsConditions(message.getItermsConditions() + imgCon);
|
||||
itemsValList.add(getSplitItemsValObject(message.getId(), SplitFilePragraTypeEnum.IMG.getValue(), imgCon, message.getItemsCondi().size(), null));
|
||||
@@ -757,4 +802,16 @@ public class SarFileSplitInfoEOServiceImpl implements SarFileSplitInfoEOService
|
||||
return dao.querySame(sarFileSplitInfoEO);
|
||||
};
|
||||
|
||||
public String getChinese(String source) {
|
||||
char[] chars = source.toCharArray();
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for (char aChar : chars) {
|
||||
int length = String.valueOf(aChar).getBytes().length;
|
||||
if (length == 3) {
|
||||
stringBuilder.append(aChar);
|
||||
}
|
||||
}
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+3
@@ -408,6 +408,9 @@ public class SarFileSplitItemsEOServiceImpl implements SarFileSplitItemsEOServic
|
||||
String imgPath = imgContent.substring(pathIndex+16,imgContent.length()-2);
|
||||
String imgName = imgUUIndex + "-" +imgPath.substring(imgPath.lastIndexOf("/")+1,imgPath.length());
|
||||
lastOne.setValContent(imgUUIndex+".png");
|
||||
final String[] split = imgName.split("-");
|
||||
final String[] split1 = split[1].split("\\.");
|
||||
lastOne.setValContent(split1[0]+".png");
|
||||
valContent.add(lastOne);
|
||||
FileSplitValImgExportDto fileSplitValImgExportDto = new FileSplitValImgExportDto();
|
||||
fileSplitValImgExportDto.setImgName(imgUUIndex+".png");
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
public interface IAttFileEOService extends IService<AttFileEO> {
|
||||
@@ -30,4 +31,5 @@ public interface IAttFileEOService extends IService<AttFileEO> {
|
||||
|
||||
public AttFileVo insertFileInfo(File file,String fileName);
|
||||
|
||||
void downLoadFileList(List<AttFileEO> multiFileInfos, String fileNowPath) throws IOException;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
@@ -426,7 +428,30 @@ public class AttFileEOServiceImpl extends ServiceImpl<AttFileEODao, AttFileEO> i
|
||||
}
|
||||
return fileObj;
|
||||
}
|
||||
|
||||
public void downLoadFileList(List<AttFileEO> AttFileList,String fileNowPath) throws IOException {
|
||||
for(AttFileEO fileExportDto : AttFileList){
|
||||
String oldPath = filePath+ "/" + fileExportDto.getFilePath() + fileExportDto.getFileName();
|
||||
String newPath = fileNowPath + "/" + fileExportDto.getOldFileName();
|
||||
File oldFile = new File(oldPath);
|
||||
if (oldFile.exists()){
|
||||
copyFile1(oldPath, newPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void copyFile1(String srcPath, String destPath) throws IOException {
|
||||
// 打开输入流
|
||||
FileInputStream fis = new FileInputStream(srcPath);
|
||||
// 打开输出流
|
||||
FileOutputStream fos = new FileOutputStream(destPath);
|
||||
// 读取和写入信息
|
||||
int len = 0;
|
||||
while ((len = fis.read()) != -1) {
|
||||
fos.write(len);
|
||||
}
|
||||
// 关闭流 先开后关 后开先关
|
||||
fos.close(); // 后开先关
|
||||
fis.close(); // 先开后关
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user