Merge branch '标准拆分译文变更'

# Conflicts:
#	laws-modules/src/main/java/com/jero/modules/split/service/impl/FileSplitItemsEOServiceImpl.java
This commit is contained in:
lijiarao
2024-08-15 10:37:15 +08:00
8 changed files with 259 additions and 37 deletions
@@ -41,6 +41,10 @@ public class ProcessStandardInterpretClause extends BaseEntity {
@TableField(exist = false)
@Excel(name = "条款内容", width = 15)
private String itemContent;
/**译文*/
@ApiModelProperty(value = "译文")
@TableField(exist = false)
private String translation;
/**各涉及部门解读人*/
@ApiModelProperty(value = "各涉及部门解读人")
@Excel(name = "各涉及部门解读人", width = 18, dictTable = "sys_user", dicCode = "id", dicText = "CONCAT(realname, '(', username, ')')")
@@ -51,6 +51,7 @@ public class ProcessStandardInterpretClauseSublist extends BaseEntity {
/**译文*/
@ApiModelProperty(value = "译文")
@Excel(name = "译文", width = 15)
@TableField(exist = false)
private String translation;
/**是否与上一版相同(字典:1:是,0:否)*/
@ApiModelProperty(value = "是否与上一版相同(字典:1:是,0:否)")
@@ -8,6 +8,7 @@
IF(lds.id is not null, lds.standard_number, lds2.item_num) itemNum,
IF(lds.id is not null, lds.standard_name, lds2.item_title) itemTitle,
IF(lds.id is not null, null, lds2.item_content) itemContent,
lds2.translation,
standard_interpret_id,
psic.clause_id,
interpret_person_ids,
@@ -9,7 +9,7 @@
standard_interpret_clause_id,
clause_id,
interpret_person_id,
`translation`,
psic2.translation,
is_same_as_prev_version,
change_description,
regulatory_notes,
@@ -50,6 +50,7 @@
IF(lds.id is not null, lds.standard_number, lds2.item_num) itemNum,
IF(lds.id is not null, lds.standard_name, lds2.item_title) itemTitle,
IF(lds.id is not null, null, lds2.item_content) itemContent,
lds2.translation,
standard_interpret_id
from process_standard_interpret_clause psic
left join laws_domestic_standard lds on psic.clause_id = lds.id and lds.del_flag = 0
@@ -268,6 +268,7 @@ public class StandardInterpretFlowServiceImpl implements StandardInterpretFlowSe
lawsDocumentSplit.setItemNum(null);
lawsDocumentSplit.setItemTitle(null);
lawsDocumentSplit.setItemContent(null);
lawsDocumentSplit.setTranslation(null);
LawsDomesticStandard lawsDomesticStandard =
lawsDomesticStandardService.getById(standardInterpretClauseSublist.getClauseId());
if (!Objects.isNull(lawsDomesticStandard)){
@@ -479,8 +480,6 @@ public class StandardInterpretFlowServiceImpl implements StandardInterpretFlowSe
// 合并
first.setInterpretPersonId(mergeString(first.getInterpretPersonId(),
standardInterpretClauseSublist.getInterpretPersonId()));
first.setTranslation(mergeString(first.getTranslation(),
standardInterpretClauseSublist.getTranslation()));
first.setIsSameAsPrevVersion(mergeString(first.getIsSameAsPrevVersion(),
standardInterpretClauseSublist.getIsSameAsPrevVersion()));
first.setChangeDescription(mergeString(first.getChangeDescription(),
@@ -809,6 +808,10 @@ public class StandardInterpretFlowServiceImpl implements StandardInterpretFlowSe
.map(SarFileSplitItemsValEO::getItemContent)
.collect(Collectors.joining("\n\r"));
processStandardInterpretClause.setItemContent(itemContents);
String translation = sarFileSplitItemsValEOS.stream()
.map(SarFileSplitItemsValEO::getTranslation)
.collect(Collectors.joining("\n\r"));
processStandardInterpretClause.setTranslation(translation);
}
}
@@ -949,6 +952,10 @@ public class StandardInterpretFlowServiceImpl implements StandardInterpretFlowSe
.map(SarFileSplitItemsValEO::getItemContent)
.collect(Collectors.joining("\n\r"));
processStandardInterpretClauseSublist.setItemContent(itemContents);
String translation = sarFileSplitItemsValEOS.stream()
.map(SarFileSplitItemsValEO::getTranslation)
.collect(Collectors.joining("\n\r"));
processStandardInterpretClauseSublist.setTranslation(translation);
}
}
}else {
@@ -977,6 +984,10 @@ public class StandardInterpretFlowServiceImpl implements StandardInterpretFlowSe
.map(SarFileSplitItemsValEO::getItemContent)
.collect(Collectors.joining("\n\r"));
processStandardInterpretClause.setItemContent(itemContents);
String translation = sarFileSplitItemsValEOS.stream()
.map(SarFileSplitItemsValEO::getTranslation)
.collect(Collectors.joining("\n\r"));
processStandardInterpretClause.setTranslation(translation);
}
}
@@ -1318,6 +1329,7 @@ public class StandardInterpretFlowServiceImpl implements StandardInterpretFlowSe
data.setClauseId(lawsDocumentSplits.getId());
data.setItemTitle(lawsDocumentSplits.getItemTitle());
data.setItemContent(lawsDocumentSplits.getItemContent());
data.setTranslation(lawsDocumentSplits.getTranslation());
}
}
@@ -4,7 +4,7 @@
<insert id="addBatchItemsVal">
insert into SAR_FILE_SPLIT_ITEMS_VAL
(id, type, item_id, valid_flag, creation_user, creation_time, modify_time, modify_user, display_seq, img_name, item_content, index_item)
(id, type, item_id, valid_flag, creation_user, creation_time, modify_time, modify_user, display_seq, img_name, item_content, translation, index_item)
values
<foreach collection="valList" item="item" index="index" separator=",">(
#{item.id, jdbcType=VARCHAR}, #{item.type, jdbcType=VARCHAR},
@@ -14,6 +14,7 @@
#{item.modifyUser, jdbcType=VARCHAR}, #{item.displaySeq, jdbcType=INTEGER},
#{item.imgName, jdbcType=INTEGER},
#{item.itemContent, jdbcType=CLOB},
#{item.translation, jdbcType=CLOB},
#{item.indexItem, jdbcType=INTEGER})
</foreach>
</insert>
@@ -511,6 +511,7 @@ public class DocumentSplitServiceImpl implements IDocumentSplitService {
List<SarFileSplitItemsValEO> valList = JSON.parseArray(JSON.toJSONString(parameter.get("itemValEOList")), SarFileSplitItemsValEO.class);
parameter.remove("itemValEOList");
parameter.putIfAbsent(ITEM_CONTENT, "");
parameter.putIfAbsent(TRANSLATION, "");
// 条文解读
List<SarFileSplitItemsValEO> articlesList = JSON.parseArray(JSON.toJSONString(parameter.get(INTERPRETATION_ARTICLES_LIST)), SarFileSplitItemsValEO.class);
parameter.remove(INTERPRETATION_ARTICLES_LIST);
@@ -520,6 +521,10 @@ public class DocumentSplitServiceImpl implements IDocumentSplitService {
if (ITEM_CONTENT.equals(k)){
v = itemContentJoin(valList, (String) parameter.get(ID));
}
// 条文内容拼接
if (TRANSLATION.equals(k)){
v = translationJoin(valList, (String) parameter.get(ID));
}
// 条文解读
if (INTERPRETATION_ARTICLES.equals(k)){
v = articlesJoin(articlesList, (String) parameter.get(ID));
@@ -587,6 +592,42 @@ public class DocumentSplitServiceImpl implements IDocumentSplitService {
return valContent.toString();
}
private String translationJoin(List<SarFileSplitItemsValEO> valList, String itemId) {
StringBuilder valContent = new StringBuilder();
if (!Objects.isNull(valList) && !valList.isEmpty()){
int index = 0;
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
for (SarFileSplitItemsValEO sarFileSplitItemsValEO : valList) {
String translation = sarFileSplitItemsValEO.getTranslation();
// 条文内容拼接
if (DocumentSplitCommon.TEXT.equals(sarFileSplitItemsValEO.getType())) {
if (StringUtils.isNotBlank(translation)){
sarFileSplitItemsValEO.setTranslation(translation
.replace("<", "&lt;").replace(">", "&gt;"));
}
valContent.append("<p>").append(translation).append("</p>");
} else if (DocumentSplitCommon.IMG.equals(sarFileSplitItemsValEO.getType())) {
valContent.append("<img class=\"wordImg\" style=\"width:100%;height:100%\" src=\"")
.append(translation).append("\">");
} else if (DocumentSplitCommon.TABLE.equals(sarFileSplitItemsValEO.getType())) {
valContent.append(translation);
}
// 条目信息
index += 1;
sarFileSplitItemsValEO.setId(UUIDUtils.randomUUID20());
sarFileSplitItemsValEO.setItemId(itemId);
sarFileSplitItemsValEO.setDisplaySeq(index);
sarFileSplitItemsValEO.setValidFlag(0);
sarFileSplitItemsValEO.setCreationTime(new Date());
sarFileSplitItemsValEO.setModifyTime(new Date());
sarFileSplitItemsValEO.setCreationUser(sysUser.getId());
sarFileSplitItemsValEO.setModifyUser(sysUser.getId());
}
}
return valContent.toString();
}
private String itemContentJoin(List<SarFileSplitItemsValEO> valList, String itemId) {
StringBuilder valContent = new StringBuilder();
if (!Objects.isNull(valList) && !valList.isEmpty()){
@@ -1445,6 +1445,9 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
String importDtoId = UUID.randomUUID().toString().replace("-", "");
importDto.put("id", importDtoId); // 记得去掉
importDto.put("info_id", infoId);
String[] valArr = importDto.get("item_content").toString().split("\n");
String[] translationArr = importDto.get("translation").toString().split("\n");
int j = translationArr.length;
List<SarFileSplitItemsValEO> addItemValList = new ArrayList<>();
if (addItemsEOList != null && !addItemsEOList.isEmpty()) {
Map<String, Object> oldItems = addItemsEOList.get(addItemsEOList.size()-1);
@@ -1456,7 +1459,6 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
addItemValList = (List<SarFileSplitItemsValEO>) oldItems.get("itemValEOList");
String itemContent = oldItems.get("item_content").toString() + importDto.get("item_content").toString();
oldItems.put("item_content", itemContent);
String[] valArr = importDto.get("item_content").toString().split("\n");
if (valArr != null && valArr.length > 0) {
for (int i=0;i<valArr.length;i++) {
SarFileSplitItemsValEO valEO = new SarFileSplitItemsValEO();
@@ -1469,6 +1471,13 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
valEO.setItemContent(splitTableInfo.getTableHtml());
}
}
if (i < j) {
for (SplitTableInfo splitTableInfo1 : getSheetTableList) {
if (splitTableInfo1.getTableName().equals(translationArr[i])) {
valEO.setTranslation(splitTableInfo1.getTableHtml());
}
}
}
}
List<File> nowfilelist = FileUnZip.readFileByFilename(filepath, valArr[i]);
if (nowfilelist != null && !nowfilelist.isEmpty()) {
@@ -1508,6 +1517,20 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
ossFileService.save(ossFile);
valEO.setType("IMG");
valEO.setItemContent(splitUrl+upload.replace("temp\\", ""));
if (i < j) {
List<File> translationfilelist = FileUnZip.readFileByFilename(filepath, translationArr[i]);
if (CollectionUtil.isNotEmpty(translationfilelist)) {
String urlTranslation = translationfilelist.get(0).getPath();
MultipartFile multipartFileTranslation = createMfileByPath(urlTranslation);
String uploadTranslation = ObsBootUtil.upload(multipartFileTranslation, "temp");
OSSFile ossFileTranslation = new OSSFile();
ossFileTranslation.setId(String.valueOf(SnowflakeUtils.snowflake()));
ossFileTranslation.setFileName(multipartFileTranslation.getName());
ossFileTranslation.setUrl(uploadTranslation);
ossFileService.save(ossFileTranslation);
valEO.setTranslation(splitUrl+uploadTranslation.replace("temp\\", ""));
}
}
} catch (Exception e) {
e.printStackTrace();
}
@@ -1516,6 +1539,9 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
if (isText) {
valEO.setType("TEXT");
valEO.setItemContent(valArr[i]);
if(i < j){
valEO.setTranslation(translationArr[i]);
}
}
addItemValList.add(valEO);
}
@@ -1523,7 +1549,6 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
oldItems.put("itemValEOList", addItemValList);
}else {
if(ObjectUtil.isNotEmpty(importDto.get("item_content"))) {
String[] valArr = importDto.get("item_content").toString().split("\n");
if (valArr != null && valArr.length > 0) {
for (int i = 0; i < valArr.length; i++) {
SarFileSplitItemsValEO valEO = new SarFileSplitItemsValEO();
@@ -1536,6 +1561,13 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
valEO.setItemContent(splitTableInfo.getTableHtml());
}
}
if (i < j) {
for (SplitTableInfo splitTableInfo1 : getSheetTableList) {
if (splitTableInfo1.getTableName().equals(translationArr[i])) {
valEO.setTranslation(splitTableInfo1.getTableHtml());
}
}
}
}
List<File> nowfilelist = FileUnZip.readFileByFilename(filepath, valArr[i]);
if (nowfilelist != null && !nowfilelist.isEmpty()) {
@@ -1575,6 +1607,20 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
ossFileService.save(ossFile);
valEO.setType("IMG");
valEO.setItemContent(splitUrl+upload.replace("temp\\", ""));
if (i < j) {
List<File> translationfilelist = FileUnZip.readFileByFilename(filepath, translationArr[i]);
if (CollectionUtil.isNotEmpty(translationfilelist)) {
String urlTranslation = translationfilelist.get(0).getPath();
MultipartFile multipartFileTranslation = createMfileByPath(urlTranslation);
String uploadTranslation = ObsBootUtil.upload(multipartFileTranslation, "temp");
OSSFile ossFileTranslation = new OSSFile();
ossFileTranslation.setId(String.valueOf(SnowflakeUtils.snowflake()));
ossFileTranslation.setFileName(multipartFileTranslation.getName());
ossFileTranslation.setUrl(uploadTranslation);
ossFileService.save(ossFileTranslation);
valEO.setTranslation(splitUrl+uploadTranslation.replace("temp\\", ""));
}
}
} catch (Exception e) {
e.printStackTrace();
}
@@ -1582,6 +1628,9 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
if (isText) {
valEO.setType("TEXT");
valEO.setItemContent(valArr[i]);
if(i < j){
valEO.setTranslation(translationArr[i]);
}
}
addItemValList.add(valEO);
}
@@ -1592,7 +1641,6 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
}
} else {
if(ObjectUtil.isNotEmpty(importDto.get("item_content"))) {
String[] valArr = importDto.get("item_content").toString().split("\n");
if (valArr != null && valArr.length > 0) {
for (int i = 0; i < valArr.length; i++) {
SarFileSplitItemsValEO valEO = new SarFileSplitItemsValEO();
@@ -1605,6 +1653,13 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
valEO.setItemContent(splitTableInfo.getTableHtml());
}
}
if (i < j) {
for (SplitTableInfo splitTableInfo1 : getSheetTableList) {
if (splitTableInfo1.getTableName().equals(translationArr[i])) {
valEO.setTranslation(splitTableInfo1.getTableHtml());
}
}
}
}
List<File> nowfilelist = FileUnZip.readFileByFilename(filepath, valArr[i]);
if (nowfilelist != null && !nowfilelist.isEmpty()) {
@@ -1638,6 +1693,20 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
ossFileService.save(ossFile);
valEO.setType("IMG");
valEO.setItemContent(splitUrl+upload.replace("temp\\", ""));
if (i < j) {
List<File> translationfilelist = FileUnZip.readFileByFilename(filepath, translationArr[i]);
if (CollectionUtil.isNotEmpty(translationfilelist)) {
String urlTranslation = translationfilelist.get(0).getPath();
MultipartFile multipartFileTranslation = createMfileByPath(urlTranslation);
String uploadTranslation = ObsBootUtil.upload(multipartFileTranslation, "temp");
OSSFile ossFileTranslation = new OSSFile();
ossFileTranslation.setId(String.valueOf(SnowflakeUtils.snowflake()));
ossFileTranslation.setFileName(multipartFileTranslation.getName());
ossFileTranslation.setUrl(uploadTranslation);
ossFileService.save(ossFileTranslation);
valEO.setTranslation(splitUrl+uploadTranslation.replace("temp\\", ""));
}
}
} catch (Exception e) {
e.printStackTrace();
}
@@ -1645,6 +1714,9 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
if (isText) {
valEO.setType("TEXT");
valEO.setItemContent(valArr[i]);
if(i < j){
valEO.setTranslation(translationArr[i]);
}
}
addItemValList.add(valEO);
}
@@ -2995,20 +3067,34 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
//添加val表数据
List<SarFileSplitItemsValEO> getValList = (List<SarFileSplitItemsValEO>) sarFileSplitItemsEO.get("itemValEOList");
String itemConditions = "";
String itemConditionsTranslation = "";
int ind = 1;
if (getValList != null && !getValList.isEmpty()) {
for (SarFileSplitItemsValEO valEO : getValList) {
String type = valEO.getType();
String itemContent = valEO.getItemContent();
String translation = valEO.getTranslation();
// 当前段内容
String valContent = "";
if ("TEXT".equals(valEO.getType())) {
valContent += "<p>" + valEO.getItemContent() + "</p>";
} else if ("IMG".equals(valEO.getType())) {
valContent += "<img class=\"wordImg\" style=\"width:100%;height:100%\" src=\""+ valEO.getItemContent() +"\">";
// valContent += valEO.getItemContent();
} else if ("TABLE".equals(valEO.getType())) {
valContent += valEO.getItemContent();
String valContentTranslation = "";
if ("TEXT".equals(type)) {
valContent += "<p>" + itemContent + "</p>";
if (StringUtils.isNotBlank(translation)){
valContentTranslation += "<p>" + translation + "</p>";
}
} else if ("IMG".equals(type)) {
valContent += "<img class=\"wordImg\" style=\"width:100%;height:100%\" src=\""+ itemContent +"\">";
if (StringUtils.isNotBlank(translation)){
valContentTranslation += "<img class=\"wordImg\" style=\"width:100%;height:100%\" src=\""+ translation +"\">";
}
} else if ("TABLE".equals(type)) {
valContent += itemContent;
if (StringUtils.isNotBlank(translation)){
valContentTranslation += translation;
}
}
itemConditions += valContent;
itemConditionsTranslation += valContentTranslation;
// val表信息
valEO.setId(UUIDUtils.randomUUID20());
// valEO.setItemId(itemsId);
@@ -3023,6 +3109,7 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
}
sarFileSplitItemsValEOMapper.insertForeach(getValList);
sarFileSplitItemsEO.put("item_content", itemConditions);
sarFileSplitItemsEO.put("translation", itemConditionsTranslation);
}
String id = (String)sarFileSplitItemsEO.get("id");
sarFileSplitItemsEO.remove("id");
@@ -3930,6 +4017,7 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
tableExportDto.setTableName("tableSheet" + tableName);
// tableExportDto.setTableEOList(tableList);
tableExportDto.setTableHtCon(itemsValEO.getItemContent());
tableExportDto.setTableHtConTranslation(itemsValEO.getTranslation());
allTableList.add(tableExportDto);
tableIndex++;
page.setTableIndex(tableIndex);
@@ -3938,6 +4026,7 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
splitContext(valContent);
String imgContent = itemsValEO.getItemContent();
String imgTranslation = itemsValEO.getTranslation();
String imgUUIndex = "img" + String.valueOf(imgIndex);
if (MyStringUtils.isNotEmpty(imgContent)){
lastOne.setValContent(imgUUIndex+".png");
@@ -3945,8 +4034,10 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
FileSplitValImgExportDto fileSplitValImgExportDto = new FileSplitValImgExportDto();
fileSplitValImgExportDto.setImgName(imgUUIndex+".png");
String url = imgContent.substring(imgContent.lastIndexOf("=") + 1);
String urlTranslation = imgTranslation.substring(imgTranslation.lastIndexOf("=") + 1);
fileSplitValImgExportDto.setImgPath(url);
fileSplitValImgExportDto.setImgPathTranslation(urlTranslation);
allImgList.add(fileSplitValImgExportDto);
imgIndex++;
@@ -4010,22 +4101,38 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
@Override
public void downLoadImgList(List<FileSplitValImgExportDto> allImgList, String fileNowPath) {
for(FileSplitValImgExportDto imgExportDto : allImgList){
String oldPath = "temp\\" + imgExportDto.getImgPath();
String newPath = fileNowPath + File.separator + "附件" + File.separator + imgExportDto.getImgName();
// if (MinioUtil.doesObjectExist(oldPath)){
try (InputStream in = ObsBootUtil.getOssFile(oldPath);) {
File file = new File(fileNowPath + File.separator + "附件");
if (!file.exists()){
file.mkdir();
}
copyFile1(in, newPath);
String imgName = imgExportDto.getImgName();
String fileName = imgExportDto.getImgPath();
String oldPath = getPath(fileName);
String newPath = fileNowPath + File.separator + "附件" + File.separator + imgName;
try (InputStream in = ObsBootUtil.getOssFile(oldPath)) {
File file = new File(fileNowPath + File.separator + "附件");
if (!file.exists()){
file.mkdir();
}
copyFile1(in, newPath);
} catch (IOException e) {
log.error(e.getMessage(), e);
}
String fileNameTranslation = imgExportDto.getImgPathTranslation();
if (StringUtils.isNotBlank(fileNameTranslation)){
String imgNameTranslation = imgName.substring(0,imgName.indexOf("."))+"translation.png";
String oldPathTranslation = getPath(fileNameTranslation);
String newPathTranslation = fileNowPath + File.separator + "附件" + File.separator + imgNameTranslation;
try (InputStream in = ObsBootUtil.getOssFile(oldPathTranslation)) {
copyFile1(in, newPathTranslation);
} catch (IOException e) {
e.printStackTrace();
log.error(e.getMessage(), e);
}
// }
}
}
}
private String getPath(String fileName){
if (!fileName.contains("temp")){
fileName = "temp\\" + fileName;
}
return fileName.replace("\\\\", "\\");
}
@Override
@@ -4182,12 +4289,15 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
HSSFRow row1 = sheetItems.createRow(allRow);
// 开始向单元格添加数据
for(int cellNum = 0; cellNum < fieldList.size(); cellNum++){
if (!"item_content".equals(fieldList.get(cellNum)) &&
!"interpretation_articles".equals(fieldList.get(cellNum)) &&
ObjectUtils.isNotEmpty(exportDto.get(fieldList.get(cellNum)))) {
String fieldName = fieldList.get(cellNum);
FileSplitValExportDto fileSplitValExportDto = valList.get(valRow);
if (!"item_content".equals(fieldName) &&
!"interpretation_articles".equals(fieldName) &&
!"translation".equals(fieldName) &&
ObjectUtils.isNotEmpty(exportDto.get(fieldName))) {
// 处理文件
if(fileList.contains(fieldList.get(cellNum))) {
String connectId = (String) exportDto.get(fieldList.get(cellNum));
if(fileList.contains(fieldName)) {
String connectId = (String) exportDto.get(fieldName);
List<OSSFile> ossFileList = ossFileService.getFileInfosByConnectId(connectId);
List<String> fileNameList = new ArrayList<>();
if (ossFileList != null && !ossFileList.isEmpty()) {
@@ -4212,15 +4322,16 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
allRelevFileList.addAll(ossFileList);
}
} else {
row1.createCell(cellNum).setCellValue(exportDto.get(fieldList.get(cellNum)).toString());
row1.createCell(cellNum).setCellValue(exportDto.get(fieldName).toString());
row1.getCell(cellNum).setCellStyle(cellStyle);
}
} else if ("item_content".equals(fieldList.get(cellNum))) {
}
else if ("item_content".equals(fieldName)) {
// 条款内容特殊处理
HSSFCell cell2 = row1.createCell(cellNum);
row1.getCell(cellNum).setCellStyle(cellStyle);
String content = valList.get(valRow).getValContent();
String content = fileSplitValExportDto.getValContent();
if (StringUtils.isNotEmpty(content)) {
content = content.replaceAll("null","");
if (content.lastIndexOf("\n") > -1) {
@@ -4228,7 +4339,7 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
}
}
if("TABLE".equals(valList.get(valRow).getValType())){
if("TABLE".equals(fileSplitValExportDto.getValType())){
/* 连接跳转*/
CreationHelper createHelper = workbook.getCreationHelper();
Hyperlink hyperlink1 = createHelper.createHyperlink(HyperlinkType.DOCUMENT);
@@ -4236,9 +4347,43 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
hyperlink1.setAddress(tableName);
cell2.setHyperlink(hyperlink1);// 链接
row1.getCell(cellNum).setCellStyle(cellStyleLink);
} else if ("IMG".equals(valList.get(valRow).getValType())) {
} else if ("IMG".equals(fileSplitValExportDto.getValType())) {
/* 连接跳转*/
CreationHelper createHelper = workbook.getCreationHelper();
Hyperlink hyperlink1 = createHelper.createHyperlink(HyperlinkType.FILE);
String imgName = content;
hyperlink1.setAddress(imgName);
cell2.setHyperlink(hyperlink1);// 链接
row1.getCell(cellNum).setCellStyle(cellStyleLink);
}
cell2.setCellValue(content); // IllegalArgumentException异常excel单元格最大字符长度有限制
}
else if ("translation".equals(fieldName)) {
// 条款内容特殊处理
HSSFCell cell2 = row1.createCell(cellNum);
row1.getCell(cellNum).setCellStyle(cellStyle);
String content = exportDto.get(fieldName).toString();
if (StringUtils.isNotEmpty(content)) {
content = content.replaceAll("null","");
if (content.lastIndexOf("\n") > -1) {
content = content.substring(0,content.lastIndexOf("\n"));
}
}
if("TABLE".equals(fileSplitValExportDto.getValType())){
/* 连接跳转*/
content = fileSplitValExportDto.getValContent()+"translation";
CreationHelper createHelper = workbook.getCreationHelper();
Hyperlink hyperlink1 = createHelper.createHyperlink(HyperlinkType.DOCUMENT);
String tableName = "#\'"+ content + "\'!A1";
hyperlink1.setAddress(tableName);
cell2.setHyperlink(hyperlink1);// 链接
row1.getCell(cellNum).setCellStyle(cellStyleLink);
} else if ("IMG".equals(fileSplitValExportDto.getValType())) {
/* 连接跳转*/
content = fileSplitValExportDto.getValContent();
content = content.substring(0,content.indexOf("."))+"translation.png";
CreationHelper createHelper = workbook.getCreationHelper();
// Hyperlink hyperlink1 = createHelper.createHyperlink(HyperlinkType.FILE);
String imgName = content;
// hyperlink1.setAddress("附件\\" + imgName);
@@ -4249,7 +4394,8 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
row1.getCell(cellNum).setCellStyle(cellStyleLink);
}
cell2.setCellValue(content); // IllegalArgumentException异常excel单元格最大字符长度有限制
} else if ("interpretation_articles".equals(fieldList.get(cellNum))) {
}
else if ("interpretation_articles".equals(fieldName)) {
// 条文解读特殊处理
HSSFCell cell2 = row1.createCell(cellNum);
row1.getCell(cellNum).setCellStyle(cellStyle);
@@ -4267,7 +4413,8 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
}
if (allRow > startRow) {
for(int cellNum = 0; cellNum < fieldList.size(); cellNum++) {
if (!"item_content".equals(fieldList.get(cellNum))) {
String s = fieldList.get(cellNum);
if (!"item_content".equals(s) && !"translation".equals(s)) {
sheetItems.addMergedRegion(new CellRangeAddress(startRow, allRow, cellNum, cellNum));
}
}
@@ -4333,6 +4480,8 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
// HSSFSheet sheetTable = workbook.createSheet(tableExportDto.getTableName());
String tableName = tableExportDto.getTableName();
String tableHtml = tableExportDto.getTableHtCon();
String tableHtmlTranslation = tableExportDto.getTableHtConTranslation();
if (StringUtils.isNotEmpty(tableHtml) && tableHtml.indexOf("<tbody>") < 0) {
if (tableHtml.indexOf("<thead>") < 0) {
tableHtml = tableHtml.replaceFirst("<tr>","<tbody><tr>");
@@ -4345,6 +4494,18 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
String cnt = "\n";
tableHtml = tableHtml.replaceAll("<[\\s]*?br[^>]*?>|<[\\s]*?\\/[\\s]*?br[\\s]*?>", cnt);
workbook = ConvertHtml2Excel.table2Excel(tableHtml,workbook,tableName);
if (StringUtils.isNotEmpty(tableHtmlTranslation) && tableHtmlTranslation.indexOf("<tbody>") < 0) {
if (tableHtmlTranslation.indexOf("<thead>") < 0) {
tableHtmlTranslation = tableHtmlTranslation.replaceFirst("<tr>","<tbody><tr>");
tableHtmlTranslation = tableHtmlTranslation.replaceFirst("</table>","</tbody></table>");
} else {
tableHtmlTranslation = tableHtmlTranslation.replaceFirst("</thead>","</thead><tbody>");
tableHtmlTranslation = tableHtmlTranslation.replaceFirst("</table>","</tbody></table>");
}
}
tableHtmlTranslation = tableHtmlTranslation.replaceAll("<[\\s]*?br[^>]*?>|<[\\s]*?\\/[\\s]*?br[\\s]*?>", cnt);
workbook = ConvertHtml2Excel.table2Excel(tableHtmlTranslation,workbook,tableName+"translation");
// for (int r=0;r<rowtableList.size();r++) {
// List<SarFileSplitItemsTableEO> colTableList = rowtableList.get(r);
// HSSFRow tRow = sheetTable.createRow(colTableList.get(0).getRowNum()-1);