From bb5657ca40708598c869d901794067333c46fbcd Mon Sep 17 00:00:00 2001 From: yinglong zhang <1679309912@qq.com> Date: Tue, 22 Jun 2021 17:34:38 +0800 Subject: [PATCH] =?UTF-8?q?feat=20=E8=A7=A3=E5=86=B3=E5=86=B2=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/SarStandardsInfoServiceImpl.java | 241 +++++++++--------- 1 file changed, 125 insertions(+), 116 deletions(-) diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/service/impl/SarStandardsInfoServiceImpl.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/service/impl/SarStandardsInfoServiceImpl.java index dd9aec44..0bf861b2 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/service/impl/SarStandardsInfoServiceImpl.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/service/impl/SarStandardsInfoServiceImpl.java @@ -10,7 +10,6 @@ import com.adc.da.person.dao.PersonCollectEODao; import com.adc.da.person.dao.PersonShareEODao; import com.adc.da.person.entity.PersonMsgEO; import com.adc.da.person.service.IPersonCollectEOService; -import com.adc.da.search.service.StandLawsSearchService; import com.adc.da.slrs.sarLawsInfo.entity.SarLawsInfo; import com.adc.da.slrs.sarLawsInfo.page.SarLawsInfoEOPage; import com.adc.da.slrs.sarLawsInfo.page.SarLawsItemsEOPage; @@ -160,8 +159,8 @@ public class SarStandardsInfoServiceImpl extends ServiceImpl attrInfoMap) { - Set keys = attrInfoMap.keySet(); - for (String key:keys) { - String value = String.valueOf(attrInfoMap.get(key)); - if (com.adc.da.util.utils.StringUtils.isNotBlank(value) && !"null".equals(value) && !"SVPPS".equals(key)){ - value = value.replace(" , ",","); - value = value.replace(","," , "); - attrInfoMap.put(key,value); - } - } - // 根据文件attid 读取文件内容 - if (org.apache.commons.lang.StringUtils.isNotEmpty(String.valueOf(attrInfoMap.get("content")))) { - String[] attidlist = String.valueOf(attrInfoMap.get("content")).split(" , "); - StringBuilder content = new StringBuilder(""); - for (int i = 0; i < attidlist.length; i++) { - if(org.apache.commons.lang.StringUtils.isNotEmpty(attidlist[i]) ){ - AttFileEO attFileEO = attFileEOService.getFileInfo(attidlist[i]); - String readFilePath = filePath + "/" + attFileEO.getFilePath() + attFileEO.getFileName(); - try { - // 判断文件是docx还是PDF - if (null != attFileEO.getFileSuffix() && (attFileEO.getFileSuffix().equals("docx") || attFileEO.getFileSuffix().equals("doc") || attFileEO.getFileSuffix().equals("ppt") || attFileEO.getFileSuffix().equals("pptx"))) { - if(attFileEO.getFileSuffix().equals("doc")){ - FileInputStream fis = new FileInputStream(readFilePath); - WordExtractor wordExtractor = new WordExtractor(fis); - String txt = wordExtractor.getText(); - content.append(txt); - }else { - OPCPackage opcPackage = XWPFDocument.openPackage(readFilePath); - XWPFWordExtractor extractor = new XWPFWordExtractor(opcPackage); - String txt = extractor.getText(); - content.append(txt); - } - } else { - PDDocument document = PDDocument.load(new File(readFilePath)); - document.getClass(); - if (!document.isEncrypted()) { - PDFTextStripperByArea stripper = new PDFTextStripperByArea(); - stripper.setSortByPosition(true); - PDFTextStripper tStripper = new PDFTextStripper(); - String pdfFileInText = tStripper.getText(document); - // String[] lines = pdfFileInText.split("\\r?\\n"); - content.append(pdfFileInText); - } - } - } catch (Exception e) { - logger.error("搜索中心新增数据读取文档内容时失败"); - logger.error(e.getMessage(),e); - } - /*catch (IOException | OpenXML4JException | XmlException e) { - logger.error(e.getMessage(),e); - }*/ - attrInfoMap.put("content",content.toString()); - } - } - } - else{ - attrInfoMap.put("content",""); - } - standLawsSearchService.addStandLawsSearchForMap(attrInfoMap); + } @Override public void updateIntoIndexForMap(Map attrInfoMap) { - Set keys = attrInfoMap.keySet(); - for (String key:keys) { - String value = String.valueOf(attrInfoMap.get(key)); - if (com.adc.da.util.utils.StringUtils.isNotBlank(value) && !"null".equals(value) && !"SVPPS".equals(key) && !"content".equals(key)){ - value = value.replace(" , ",","); - value = value.replace(","," , "); - attrInfoMap.put(key,value); - } - } - // 根据文件attid 读取文件内容 - if (org.apache.commons.lang.StringUtils.isNotEmpty(String.valueOf(attrInfoMap.get("content")))) { - String[] attidlist = String.valueOf(attrInfoMap.get("content")).split(" , "); - StringBuilder content = new StringBuilder(""); - for (int i = 0; i < attidlist.length; i++) { - if(org.apache.commons.lang.StringUtils.isNotEmpty(attidlist[i]) && !"null".equals(attidlist[i])){ - AttFileEO attFileEO = attFileEOService.getFileInfo(attidlist[i]); - String readFilePath = filePath + "/" + attFileEO.getFilePath() + attFileEO.getFileName(); - try { - // 判断文件是docx还是PDF - if (attFileEO.getFileSuffix().equals("docx") || attFileEO.getFileSuffix().equals("doc")) { - if(attFileEO.getFileSuffix().equals("doc")){ - FileInputStream fis = new FileInputStream(readFilePath); - WordExtractor wordExtractor = new WordExtractor(fis); - String txt = wordExtractor.getText(); - content.append(txt); - }else { - OPCPackage opcPackage = XWPFDocument.openPackage(readFilePath); - XWPFWordExtractor extractor = new XWPFWordExtractor(opcPackage); - String txt = extractor.getText(); - content.append(txt); - } - } else if (attFileEO.getFileSuffix().equals("pdf")){ - PDDocument document = PDDocument.load(new File(readFilePath)); - document.getClass(); - if (!document.isEncrypted()) { - PDFTextStripperByArea stripper = new PDFTextStripperByArea(); - stripper.setSortByPosition(true); - PDFTextStripper tStripper = new PDFTextStripper(); - String pdfFileInText = tStripper.getText(document); - // String[] lines = pdfFileInText.split("\\r?\\n"); - content.append(pdfFileInText); - } - } - } catch (Exception e) { - logger.error("搜索中心修改数据读取文档内容时失败"); - logger.error(e.getMessage(),e); - } - attrInfoMap.put("content",content.toString()); - } - } - } - else{ - attrInfoMap.put("content",""); - } - standLawsSearchService.updateStandLawsSearchForMap(attrInfoMap); + } +// +// @Override +// public void insertIntoIndexForMap(Map attrInfoMap) { +// Set keys = attrInfoMap.keySet(); +// for (String key:keys) { +// String value = String.valueOf(attrInfoMap.get(key)); +// if (com.adc.da.util.utils.StringUtils.isNotBlank(value) && !"null".equals(value) && !"SVPPS".equals(key)){ +// value = value.replace(" , ",","); +// value = value.replace(","," , "); +// attrInfoMap.put(key,value); +// } +// } +// // 根据文件attid 读取文件内容 +// if (org.apache.commons.lang.StringUtils.isNotEmpty(String.valueOf(attrInfoMap.get("content")))) { +// String[] attidlist = String.valueOf(attrInfoMap.get("content")).split(" , "); +// StringBuilder content = new StringBuilder(""); +// for (int i = 0; i < attidlist.length; i++) { +// if(org.apache.commons.lang.StringUtils.isNotEmpty(attidlist[i]) ){ +// AttFileEO attFileEO = attFileEOService.getFileInfo(attidlist[i]); +// String readFilePath = filePath + "/" + attFileEO.getFilePath() + attFileEO.getFileName(); +// try { +// // 判断文件是docx还是PDF +// if (null != attFileEO.getFileSuffix() && (attFileEO.getFileSuffix().equals("docx") || attFileEO.getFileSuffix().equals("doc") || attFileEO.getFileSuffix().equals("ppt") || attFileEO.getFileSuffix().equals("pptx"))) { +// if(attFileEO.getFileSuffix().equals("doc")){ +// FileInputStream fis = new FileInputStream(readFilePath); +// WordExtractor wordExtractor = new WordExtractor(fis); +// String txt = wordExtractor.getText(); +// content.append(txt); +// }else { +// OPCPackage opcPackage = XWPFDocument.openPackage(readFilePath); +// XWPFWordExtractor extractor = new XWPFWordExtractor(opcPackage); +// String txt = extractor.getText(); +// content.append(txt); +// } +// } else { +// PDDocument document = PDDocument.load(new File(readFilePath)); +// document.getClass(); +// if (!document.isEncrypted()) { +// PDFTextStripperByArea stripper = new PDFTextStripperByArea(); +// stripper.setSortByPosition(true); +// PDFTextStripper tStripper = new PDFTextStripper(); +// String pdfFileInText = tStripper.getText(document); +// // String[] lines = pdfFileInText.split("\\r?\\n"); +// content.append(pdfFileInText); +// } +// } +// } catch (Exception e) { +// logger.error("搜索中心新增数据读取文档内容时失败"); +// logger.error(e.getMessage(),e); +// } +// /*catch (IOException | OpenXML4JException | XmlException e) { +// logger.error(e.getMessage(),e); +// }*/ +// attrInfoMap.put("content",content.toString()); +// } +// } +// } +// else{ +// attrInfoMap.put("content",""); +// } +// standLawsSearchService.addStandLawsSearchForMap(attrInfoMap); +// } +// +// @Override +// public void updateIntoIndexForMap(Map attrInfoMap) { +// Set keys = attrInfoMap.keySet(); +// for (String key:keys) { +// String value = String.valueOf(attrInfoMap.get(key)); +// if (com.adc.da.util.utils.StringUtils.isNotBlank(value) && !"null".equals(value) && !"SVPPS".equals(key) && !"content".equals(key)){ +// value = value.replace(" , ",","); +// value = value.replace(","," , "); +// attrInfoMap.put(key,value); +// } +// } +// // 根据文件attid 读取文件内容 +// if (org.apache.commons.lang.StringUtils.isNotEmpty(String.valueOf(attrInfoMap.get("content")))) { +// String[] attidlist = String.valueOf(attrInfoMap.get("content")).split(" , "); +// StringBuilder content = new StringBuilder(""); +// for (int i = 0; i < attidlist.length; i++) { +// if(org.apache.commons.lang.StringUtils.isNotEmpty(attidlist[i]) && !"null".equals(attidlist[i])){ +// AttFileEO attFileEO = attFileEOService.getFileInfo(attidlist[i]); +// String readFilePath = filePath + "/" + attFileEO.getFilePath() + attFileEO.getFileName(); +// try { +// // 判断文件是docx还是PDF +// if (attFileEO.getFileSuffix().equals("docx") || attFileEO.getFileSuffix().equals("doc")) { +// if(attFileEO.getFileSuffix().equals("doc")){ +// FileInputStream fis = new FileInputStream(readFilePath); +// WordExtractor wordExtractor = new WordExtractor(fis); +// String txt = wordExtractor.getText(); +// content.append(txt); +// }else { +// OPCPackage opcPackage = XWPFDocument.openPackage(readFilePath); +// XWPFWordExtractor extractor = new XWPFWordExtractor(opcPackage); +// String txt = extractor.getText(); +// content.append(txt); +// } +// } else if (attFileEO.getFileSuffix().equals("pdf")){ +// PDDocument document = PDDocument.load(new File(readFilePath)); +// document.getClass(); +// if (!document.isEncrypted()) { +// PDFTextStripperByArea stripper = new PDFTextStripperByArea(); +// stripper.setSortByPosition(true); +// PDFTextStripper tStripper = new PDFTextStripper(); +// String pdfFileInText = tStripper.getText(document); +// // String[] lines = pdfFileInText.split("\\r?\\n"); +// content.append(pdfFileInText); +// } +// } +// } catch (Exception e) { +// logger.error("搜索中心修改数据读取文档内容时失败"); +// logger.error(e.getMessage(),e); +// } +// attrInfoMap.put("content",content.toString()); +// } +// } +// } +// else{ +// attrInfoMap.put("content",""); +// } +// standLawsSearchService.updateStandLawsSearchForMap(attrInfoMap); +// } public void getStandDetailsForAct (SarStandardsInfoEOPage page,String[] idArr,String standState,List standList) throws Exception{ page.setPageSize(100);