Merge remote-tracking branch 'origin/dev_foton_GJB'
# Conflicts: # adc-da-main/src/main/resources/application.properties
This commit is contained in:
+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);
|
||||
}
|
||||
@@ -313,7 +338,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);
|
||||
@@ -429,19 +455,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("下载文件失败,请重试");
|
||||
|
||||
+63
-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;
|
||||
@@ -69,6 +70,10 @@ public class SarFileSplitInfoEOServiceImpl implements SarFileSplitInfoEOService
|
||||
*/
|
||||
@Value("${file.downloadUrl}")
|
||||
private String downloadUrl;
|
||||
|
||||
@Value("${elasticsearch.img}")
|
||||
private String elasticsearchImg;//图片拆分自调地址
|
||||
|
||||
@Autowired
|
||||
private PersonShareEODao personShareEODao;
|
||||
@Autowired
|
||||
@@ -175,6 +180,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) {
|
||||
@@ -186,6 +193,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)){
|
||||
@@ -340,7 +381,6 @@ public class SarFileSplitInfoEOServiceImpl implements SarFileSplitInfoEOService
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
@@ -489,10 +529,19 @@ public class SarFileSplitInfoEOServiceImpl implements SarFileSplitInfoEOService
|
||||
}
|
||||
String filepathandname = splitFilePath +"/" + imageName;
|
||||
try {
|
||||
File file2 = new File(splitFilePath);
|
||||
if (!file2.exists()) {
|
||||
file2.mkdirs();
|
||||
}
|
||||
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));
|
||||
@@ -780,4 +829,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");
|
||||
|
||||
Reference in New Issue
Block a user