From 79818d99d38f3fb1380e2ee282359b4a88a2a142 Mon Sep 17 00:00:00 2001 From: lijiarao Date: Thu, 1 Aug 2024 14:08:05 +0800 Subject: [PATCH] =?UTF-8?q?add=20=E6=96=87=E6=A1=A3=E6=8B=86=E5=88=86?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=AF=91=E6=96=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/SarFileSplitItemsVal.java | 5 + .../mapper/xml/DocumentSplitMapper.xml | 10 +- .../split/entity/SarFileSplitItemsValEO.java | 5 + .../xml/SarFileSplitItemsValEOMapper.xml | 15 +- .../impl/FileSplitItemsEOServiceImpl.java | 203 +++++++++--------- 5 files changed, 124 insertions(+), 114 deletions(-) diff --git a/laws-modules/src/main/java/com/jero/modules/laws/documenttool/entity/SarFileSplitItemsVal.java b/laws-modules/src/main/java/com/jero/modules/laws/documenttool/entity/SarFileSplitItemsVal.java index 5d37916b..849c9bc5 100644 --- a/laws-modules/src/main/java/com/jero/modules/laws/documenttool/entity/SarFileSplitItemsVal.java +++ b/laws-modules/src/main/java/com/jero/modules/laws/documenttool/entity/SarFileSplitItemsVal.java @@ -40,6 +40,11 @@ public class SarFileSplitItemsVal implements Serializable { */ @ApiModelProperty("条目内容") private String itemContent; + /** + * 译文 + */ + @ApiModelProperty("译文") + private String translation; /** * 排序 */ diff --git a/laws-modules/src/main/java/com/jero/modules/laws/documenttool/mapper/xml/DocumentSplitMapper.xml b/laws-modules/src/main/java/com/jero/modules/laws/documenttool/mapper/xml/DocumentSplitMapper.xml index 015e7106..41223719 100644 --- a/laws-modules/src/main/java/com/jero/modules/laws/documenttool/mapper/xml/DocumentSplitMapper.xml +++ b/laws-modules/src/main/java/com/jero/modules/laws/documenttool/mapper/xml/DocumentSplitMapper.xml @@ -40,10 +40,10 @@ - insert into sar_file_split_items_val(id, sys_org_code, item_id, type, item_content, display_seq, valid_flag, img_name, index_item, creation_time, modify_user, modify_time, creation_user) + insert into sar_file_split_items_val(id, sys_org_code, item_id, type, item_content, translation, display_seq, valid_flag, img_name, index_item, creation_time, modify_user, modify_time, creation_user) values - (#{entity.id}, #{entity.sysOrgCode}, #{entity.itemId}, #{entity.type}, #{entity.itemContent}, #{entity.displaySeq}, #{entity.validFlag}, #{entity.imgName}, #{entity.indexItem}, #{entity.creationTime}, #{entity.modifyUser}, #{entity.modifyTime}, #{entity.creationUser}) + (#{entity.id}, #{entity.sysOrgCode}, #{entity.itemId}, #{entity.type}, #{entity.itemContent}, #{entity.translation}, #{entity.displaySeq}, #{entity.validFlag}, #{entity.imgName}, #{entity.indexItem}, #{entity.creationTime}, #{entity.modifyUser}, #{entity.modifyTime}, #{entity.creationUser}) @@ -139,7 +139,7 @@ - select id, sys_org_code, item_id, type, item_content, display_seq, valid_flag, + select id, sys_org_code, item_id, type, item_content, translation, display_seq, valid_flag, img_name, index_item, creation_time, modify_user, modify_time, creation_user from sar_file_split_items_val where valid_flag = 0 and item_id = #{itemId} diff --git a/laws-modules/src/main/java/com/jero/modules/split/entity/SarFileSplitItemsValEO.java b/laws-modules/src/main/java/com/jero/modules/split/entity/SarFileSplitItemsValEO.java index fc0ef843..5a22bb90 100644 --- a/laws-modules/src/main/java/com/jero/modules/split/entity/SarFileSplitItemsValEO.java +++ b/laws-modules/src/main/java/com/jero/modules/split/entity/SarFileSplitItemsValEO.java @@ -39,6 +39,11 @@ public class SarFileSplitItemsValEO implements Serializable { */ @ApiModelProperty("条文内容") private String itemContent; + /** + * 译文 + */ + @ApiModelProperty("译文") + private String translation; /** * 有效标识 */ diff --git a/laws-modules/src/main/java/com/jero/modules/split/mapper/xml/SarFileSplitItemsValEOMapper.xml b/laws-modules/src/main/java/com/jero/modules/split/mapper/xml/SarFileSplitItemsValEOMapper.xml index a4fec6fc..940722c8 100644 --- a/laws-modules/src/main/java/com/jero/modules/split/mapper/xml/SarFileSplitItemsValEOMapper.xml +++ b/laws-modules/src/main/java/com/jero/modules/split/mapper/xml/SarFileSplitItemsValEOMapper.xml @@ -7,6 +7,7 @@ + @@ -19,7 +20,7 @@ - id, type, item_id, item_content, valid_flag, creation_user, creation_time, modify_time, modify_user, display_seq,img_name,index_item + id, type, item_id, item_content, translation, valid_flag, creation_user, creation_time, modify_time, modify_user, display_seq,img_name,index_item @@ -77,7 +78,7 @@ SELECT SEQ_SAR_FILE_SPLIT_ITEMS_VAL.NEXTVAL FROM DUAL --> insert into SAR_FILE_SPLIT_ITEMS_VAL() - values (#{id, jdbcType=VARCHAR}, #{type, jdbcType=VARCHAR}, #{itemId, jdbcType=VARCHAR}, #{itemContent, jdbcType=CLOB}, #{validFlag, jdbcType=INTEGER}, #{creationUser, jdbcType=VARCHAR}, #{creationTime, jdbcType=TIMESTAMP}, #{modifyTime, jdbcType=TIMESTAMP}, #{modifyUser, jdbcType=VARCHAR}, #{displaySeq, jdbcType=INTEGER}) + values (#{id, jdbcType=VARCHAR}, #{type, jdbcType=VARCHAR}, #{itemId, jdbcType=VARCHAR}, #{itemContent, jdbcType=CLOB}, #{translation, jdbcType=CLOB}, #{validFlag, jdbcType=INTEGER}, #{creationUser, jdbcType=VARCHAR}, #{creationTime, jdbcType=TIMESTAMP}, #{modifyTime, jdbcType=TIMESTAMP}, #{modifyUser, jdbcType=VARCHAR}, #{displaySeq, jdbcType=INTEGER}) @@ -91,6 +92,7 @@ type, item_id, item_content, + translation, valid_flag, creation_user, creation_time, @@ -105,6 +107,7 @@ #{type, jdbcType=VARCHAR}, #{itemId, jdbcType=VARCHAR}, #{itemContent, jdbcType=CLOB}, + #{translation}, #{validFlag, jdbcType=INTEGER}, #{creationUser, jdbcType=VARCHAR}, #{creationTime, jdbcType=TIMESTAMP}, @@ -122,6 +125,7 @@ set type = #{type}, item_id = #{itemId}, item_content = #{itemContent}, + translation = #{translation}, valid_flag = #{validFlag}, creation_user = #{creationUser}, creation_time = #{creationTime}, @@ -144,6 +148,9 @@ item_content = #{itemContent}, + + translation = #{translation}, + valid_flag = #{validFlag}, @@ -226,7 +233,7 @@ 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 ( #{item.id, jdbcType=VARCHAR}, #{item.type, jdbcType=VARCHAR}, @@ -236,6 +243,7 @@ #{item.modifyUser, jdbcType=VARCHAR}, #{item.displaySeq, jdbcType=INTEGER}, #{item.imgName, jdbcType=INTEGER}, #{item.itemContent, jdbcType=CLOB}, + #{item.translation}, #{item.indexItem, jdbcType=INTEGER}) @@ -316,6 +324,7 @@ item_id, type, item_content, + translation, display_seq, valid_flag, img_name, diff --git a/laws-modules/src/main/java/com/jero/modules/split/service/impl/FileSplitItemsEOServiceImpl.java b/laws-modules/src/main/java/com/jero/modules/split/service/impl/FileSplitItemsEOServiceImpl.java index b92a2f4c..e192a147 100644 --- a/laws-modules/src/main/java/com/jero/modules/split/service/impl/FileSplitItemsEOServiceImpl.java +++ b/laws-modules/src/main/java/com/jero/modules/split/service/impl/FileSplitItemsEOServiceImpl.java @@ -1436,6 +1436,9 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl addItemValList = new ArrayList<>(); if (addItemsEOList != null && !addItemsEOList.isEmpty()) { Map oldItems = addItemsEOList.get(addItemsEOList.size()-1); @@ -1447,7 +1450,6 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl) 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 nowfilelist = FileUnZip.readFileByFilename(filepath, valArr[i]); if (nowfilelist != null && !nowfilelist.isEmpty()) { 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"; -// } -// OSSFile oSSFile = ossFileService.uploadLocalForSplit(multipartFile, "",state,null); -// if(oSSFile!=null){ -// oSSFile = ossFileService.getById(oSSFile.getId()); isText = false; - -//// BASE64Encoder base64Encoder = new BASE64Encoder(); -//// String encode = base64Encoder.encode(oSSFile.getUrl().getBytes(StandardCharsets.UTF_8)); -// String path = oSSFile.getUrl(); -//// String path = imgpath + oSSFile.getUrl().substring(oSSFile.getUrl().lastIndexOf(File.separator)+1); -//// String imgCon = ""; -// valEO.setType("IMG"); -//// valEO.setItemContent(imgCon); -// valEO.setItemContent(path); -// -// String imageName = UUIDUtils.randomUUID10() + multipartFile.getName(); -// String filepathandname = uploadCospath + "/" + imageName; try { -// String paths = splitUrl+imageName; -// MinioUtil.uploadByte(bytev, filepathandname); String upload = ObsBootUtil.upload(multipartFile, "temp"); OSSFile ossFile = new OSSFile(); ossFile.setId(String.valueOf(SnowflakeUtils.snowflake())); @@ -1498,6 +1484,20 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl 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(); } @@ -1506,6 +1506,9 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl 0) { for (int i = 0; i < valArr.length; i++) { SarFileSplitItemsValEO valEO = new SarFileSplitItemsValEO(); @@ -1526,36 +1528,20 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl nowfilelist = FileUnZip.readFileByFilename(filepath, valArr[i]); if (nowfilelist != null && !nowfilelist.isEmpty()) { 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"; -// } -// OSSFile oSSFile = ossFileService.uploadLocalOfCos(multipartFile, "", state,null); -// OSSFile oSSFile = ossFileService.uploadLocalForSplit(multipartFile, "",state,null); -// oSSFile = ossFileService.getById(oSSFile.getId()); -// if (oSSFile != null) { -// oSSFile = ossFileService.getById(oSSFile.getId()); isText = false; - -//// BASE64Encoder base64Encoder = new BASE64Encoder(); -//// String encode = base64Encoder.encode(oSSFile.getUrl().getBytes(StandardCharsets.UTF_8)); -// String path = oSSFile.getUrl(); -//// String path = imgpath + oSSFile.getUrl().substring(oSSFile.getUrl().lastIndexOf(File.separator)+1); -//// String imgCon = ""; -// valEO.setType("IMG"); -//// valEO.setItemContent(imgCon); -// valEO.setItemContent(path); -// } try { -// String paths = splitUrl+imageName; -// MinioUtil.uploadByte(bytev, filepathandname); String upload = ObsBootUtil.upload(multipartFile, "temp"); OSSFile ossFile = new OSSFile(); ossFile.setId(String.valueOf(SnowflakeUtils.snowflake())); @@ -1564,6 +1550,20 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl 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(); } @@ -1571,6 +1571,9 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl 0) { for (int i = 0; i < valArr.length; i++) { SarFileSplitItemsValEO valEO = new SarFileSplitItemsValEO(); @@ -1594,30 +1596,20 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl nowfilelist = FileUnZip.readFileByFilename(filepath, valArr[i]); if (nowfilelist != null && !nowfilelist.isEmpty()) { String url = nowfilelist.get(0).getPath(); MultipartFile multipartFile = createMfileByPath(url); - String state = "0"; -// OSSFile oSSFile = ossFileService.uploadLocalOfCos(multipartFile, "", state,null); -// OSSFile oSSFile = ossFileService.uploadLocalForSplit(multipartFile, "",state,null); -//// oSSFile = ossFileService.getById(oSSFile.getId()); -// if (oSSFile != null) { isText = false; - -//// BASE64Encoder base64Encoder = new BASE64Encoder(); -//// String encode = base64Encoder.encode(oSSFile.getUrl().getBytes(StandardCharsets.UTF_8)); -// String path = oSSFile.getUrl(); -//// String path = imgpath + oSSFile.getUrl().substring(oSSFile.getUrl().lastIndexOf(File.separator)+1); -//// String imgCon = ""; -// valEO.setType("IMG"); -//// valEO.setItemContent(imgCon); -// valEO.setItemContent(path); -// } try { -// String paths = splitUrl+imageName; -// MinioUtil.uploadByte(bytev, filepathandname); String upload = ObsBootUtil.upload(multipartFile, "temp"); OSSFile ossFile = new OSSFile(); ossFile.setId(String.valueOf(SnowflakeUtils.snowflake())); @@ -1626,6 +1618,20 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl 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(); } @@ -1633,6 +1639,9 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl itemNumList = new ArrayList<>(); - for(SarFileSplitItemsEO sarFileSplitItemsEO : addItemsEOList){ - String[] str = sarFileSplitItemsEO.getItemsNum().split("."); - if(str.length == finalLevelNum){ - itemNumList.add(sarFileSplitItemsEO); - } - }*/ - // 2022-03-31 注释 -// List itemNumList = addItemsEOList.stream() -// .filter(e->e.getItemsNum().split("\\.").length == finalLevelNum || e.getItemsNum().contains("附录")) -// .collect(Collectors.toList()); //构造目录树 HashMap menuAndItemMap = new HashMap<>(); -// if(CollectionUtils.isNotEmpty(itemNumList)) { List> itemsEOList = new ArrayList<>(addItemsEOList); List treeList = buildTree(itemsEOList, treeListDisplay, menuId); @@ -1699,9 +1678,6 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl itemsEO : addItemsEOList) { if(menuAndItemMap.get(itemsEO.get("id")) != null) { @@ -2950,20 +2926,34 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl getValList = (List) 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 += "

" + valEO.getItemContent() + "

"; - } else if ("IMG".equals(valEO.getType())) { - valContent += ""; -// valContent += valEO.getItemContent(); - } else if ("TABLE".equals(valEO.getType())) { - valContent += valEO.getItemContent(); + String valContentTranslation = ""; + if ("TEXT".equals(type)) { + valContent += "

" + itemContent + "

"; + if (StringUtils.isNotBlank(translation)){ + valContentTranslation += "

" + translation + "

"; + } + } else if ("IMG".equals(type)) { + valContent += ""; + if (StringUtils.isNotBlank(translation)){ + valContentTranslation += ""; + } + } 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); @@ -2978,6 +2968,7 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl