|
|
|
@ -1,343 +1,343 @@
|
|
|
|
|
/* */ package com.archive.project.browse.controller
|
|
|
|
|
package com.archive.project.browse.controller
|
|
|
|
|
|
|
|
|
|
;
|
|
|
|
|
/* */ import com.archive.common.archiveUtil.MetadataUtil;
|
|
|
|
|
/* */ import com.archive.common.archiveUtil.TableUtil;
|
|
|
|
|
/* */ import com.archive.common.ocr.ImageOcr;
|
|
|
|
|
/* */ import com.archive.common.ocr.PdfOcr;
|
|
|
|
|
/* */ import com.archive.common.utils.StringUtils;
|
|
|
|
|
/* */ import com.archive.common.utils.http.HttpUtils;
|
|
|
|
|
import com.archive.common.archiveUtil.MetadataUtil;
|
|
|
|
|
import com.archive.common.archiveUtil.TableUtil;
|
|
|
|
|
import com.archive.common.ocr.ImageOcr;
|
|
|
|
|
import com.archive.common.ocr.PdfOcr;
|
|
|
|
|
import com.archive.common.utils.StringUtils;
|
|
|
|
|
import com.archive.common.utils.http.HttpUtils;
|
|
|
|
|
import com.archive.framework.config.ArchiveConfig;
|
|
|
|
|
/* */ import com.archive.framework.web.controller.BaseController;
|
|
|
|
|
/* */ import com.archive.framework.web.domain.AjaxResult;
|
|
|
|
|
/* */ import com.archive.project.browse.service.IBrowseService;
|
|
|
|
|
/* */ import com.archive.project.dajs.jsgl.service.IJsglService;
|
|
|
|
|
/* */ import com.archive.project.dasz.ccgl.service.ICcglService;
|
|
|
|
|
/* */ import com.archive.project.system.config.service.IConfigService;
|
|
|
|
|
/* */ import java.io.File;
|
|
|
|
|
/* */ import java.io.FileInputStream;
|
|
|
|
|
/* */ import java.io.IOException;
|
|
|
|
|
/* */ import java.util.ArrayList;
|
|
|
|
|
/* */ import java.util.HashMap;
|
|
|
|
|
/* */ import java.util.List;
|
|
|
|
|
/* */ import java.util.Map;
|
|
|
|
|
/* */ import javax.servlet.ServletOutputStream;
|
|
|
|
|
/* */ import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
/* */ import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
/* */ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
/* */ import org.springframework.stereotype.Controller;
|
|
|
|
|
/* */ import org.springframework.ui.ModelMap;
|
|
|
|
|
/* */ import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
|
/* */ import org.springframework.web.bind.annotation.PathVariable;
|
|
|
|
|
/* */ import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
/* */ import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
|
|
/* */ import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
/* */
|
|
|
|
|
/* */ @Controller
|
|
|
|
|
/* */ @RequestMapping({"/browse"})
|
|
|
|
|
/* */ public class BrowseController extends BaseController {
|
|
|
|
|
/* 36 */ private String prefix = "browse";
|
|
|
|
|
/* */
|
|
|
|
|
/* */ @Autowired
|
|
|
|
|
/* */ private IConfigService configService;
|
|
|
|
|
/* */
|
|
|
|
|
/* */ @Autowired
|
|
|
|
|
/* */ private IJsglService jsglService;
|
|
|
|
|
/* */
|
|
|
|
|
/* */ @Autowired
|
|
|
|
|
/* */ private IBrowseService iBrowseService;
|
|
|
|
|
/* */
|
|
|
|
|
/* */ @Autowired
|
|
|
|
|
/* */ private ICcglService ccglService;
|
|
|
|
|
/* */
|
|
|
|
|
/* */ @Autowired
|
|
|
|
|
/* */ private ArchiveConfig archiveConfig;
|
|
|
|
|
/* */
|
|
|
|
|
/* */ @GetMapping({"/browse/{archiveId}/{id}"})
|
|
|
|
|
/* */ public String browse(@PathVariable("archiveId") long archiveId, @PathVariable("id") String id, ModelMap mmap) {
|
|
|
|
|
/* 55 */ long tableId = TableUtil.getTableIdByArchiveTypeId(archiveId);
|
|
|
|
|
/* 56 */ mmap.put("archiveTypeId", Long.valueOf(archiveId));
|
|
|
|
|
/* 57 */ mmap.put("tableId", Long.valueOf(tableId));
|
|
|
|
|
/* 58 */ mmap.put("id", id);
|
|
|
|
|
/* 59 */ boolean browseServerEnabled = this.archiveConfig.isBrowseServerEnabled();
|
|
|
|
|
/* */
|
|
|
|
|
/* 61 */ if (browseServerEnabled) {
|
|
|
|
|
/* 62 */ return this.prefix + "/browse";
|
|
|
|
|
/* */ }
|
|
|
|
|
/* 64 */ return this.prefix + "/browsesimple";
|
|
|
|
|
/* */ }
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */ @GetMapping({"/appendAddForm/{archiveTypeId}/{type}/{id}"})
|
|
|
|
|
/* */ @ResponseBody
|
|
|
|
|
/* */ public String appendAddForm(@PathVariable("archiveTypeId") String archiveTypeId, @PathVariable("type") String type, @PathVariable("id") String id) {
|
|
|
|
|
/* 79 */ return this.jsglService.appendAddFormByDataId(archiveTypeId, type, id, "true");
|
|
|
|
|
/* */ }
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */ @GetMapping({"/getDocumentListByFileTableIdAndFileId/{fileTableId}/{fileId}"})
|
|
|
|
|
/* */ @ResponseBody
|
|
|
|
|
/* */ public AjaxResult getDocumentListByFileTableIdAndFileId(@PathVariable("fileTableId") String fileTableId, @PathVariable("fileId") String fileId) {
|
|
|
|
|
/* 91 */ List<Map<String, String>> list = this.iBrowseService.getDocumentListByFileTableIdAndFileId(fileTableId, fileId);
|
|
|
|
|
/* 92 */ return AjaxResult.success(list);
|
|
|
|
|
/* */ }
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */ @GetMapping({"/getDocumentList/{fileTableId}/{fileId}"})
|
|
|
|
|
/* */ @ResponseBody
|
|
|
|
|
/* */ public AjaxResult getDocumentList(@PathVariable("fileTableId") String fileTableId, @PathVariable("fileId") String fileId) {
|
|
|
|
|
/* 104 */ List<Map<String, String>> list = this.iBrowseService.getDocumentList(fileTableId, fileId);
|
|
|
|
|
/* 105 */ return AjaxResult.success(list);
|
|
|
|
|
/* */ }
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */ @GetMapping({"/getDocument/{documentTableId}/{documentId}"})
|
|
|
|
|
/* */ @ResponseBody
|
|
|
|
|
/* */ public Object getDocument(@PathVariable("documentTableId") String documentTableId, @PathVariable("documentId") String documentId, HttpServletRequest request, HttpServletResponse response) {
|
|
|
|
|
/* 120 */ FileInputStream fis = null;
|
|
|
|
|
/* 121 */ ServletOutputStream ops = null;
|
|
|
|
|
/* 122 */ String filepath = this.iBrowseService.getDocumentPath(documentTableId, documentId, "false");
|
|
|
|
|
/* */ try {
|
|
|
|
|
/* 124 */ File f = new File(filepath);
|
|
|
|
|
/* 125 */ if (f.exists()) {
|
|
|
|
|
/* 126 */ System.out.println(filepath + "===cunzai");
|
|
|
|
|
/* 127 */ response.addHeader("Content-Disposition", "attachment;filename=\"" + new String(f.getName().getBytes("UTF-8"), "ISO8859-1") + "\"");
|
|
|
|
|
/* 128 */ response.setContentType("application/octet-stream; charset=GBK");
|
|
|
|
|
/* 129 */ response.setHeader("Content-Length", String.valueOf(f.length()));
|
|
|
|
|
/* 130 */ response.setHeader("Pragma", "No-cache");
|
|
|
|
|
/* 131 */ response.setHeader("Cache-Control", "No-cache");
|
|
|
|
|
/* 132 */ response.setDateHeader("Expires", 0L);
|
|
|
|
|
/* 133 */ fis = new FileInputStream(f);
|
|
|
|
|
/* 134 */ ops = response.getOutputStream();
|
|
|
|
|
/* 135 */ byte[] bf = new byte[1024];
|
|
|
|
|
/* 136 */ int rl = fis.read(bf);
|
|
|
|
|
/* 137 */ while (rl > 0) {
|
|
|
|
|
/* 138 */ ops.write(bf, 0, rl);
|
|
|
|
|
/* 139 */ rl = fis.read(bf);
|
|
|
|
|
/* */ }
|
|
|
|
|
/* 141 */ ops.flush();
|
|
|
|
|
/* 142 */ ops.close();
|
|
|
|
|
/* 143 */ fis.close();
|
|
|
|
|
/* */ } else {
|
|
|
|
|
/* 145 */ System.out.println(filepath + "===bucunzai");
|
|
|
|
|
/* 146 */ response.sendRedirect("common/404.jsp");
|
|
|
|
|
/* */ }
|
|
|
|
|
/* 148 */ } catch (Exception e) {
|
|
|
|
|
/* 149 */ e.printStackTrace();
|
|
|
|
|
/* */ } finally {
|
|
|
|
|
/* */ try {
|
|
|
|
|
/* 152 */ if (fis != null)
|
|
|
|
|
/* 153 */ {
|
|
|
|
|
import com.archive.framework.web.controller.BaseController;
|
|
|
|
|
import com.archive.framework.web.domain.AjaxResult;
|
|
|
|
|
import com.archive.project.browse.service.IBrowseService;
|
|
|
|
|
import com.archive.project.dajs.jsgl.service.IJsglService;
|
|
|
|
|
import com.archive.project.dasz.ccgl.service.ICcglService;
|
|
|
|
|
import com.archive.project.system.config.service.IConfigService;
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.io.FileInputStream;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import javax.servlet.ServletOutputStream;
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
|
|
import org.springframework.ui.ModelMap;
|
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
|
|
|
|
@Controller
|
|
|
|
|
@RequestMapping({"/browse"})
|
|
|
|
|
public class BrowseController extends BaseController {
|
|
|
|
|
private String prefix = "browse";
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private IConfigService configService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private IJsglService jsglService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private IBrowseService iBrowseService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private ICcglService ccglService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private ArchiveConfig archiveConfig;
|
|
|
|
|
|
|
|
|
|
@GetMapping({"/browse/{archiveId}/{id}"})
|
|
|
|
|
public String browse(@PathVariable("archiveId") long archiveId, @PathVariable("id") String id, ModelMap mmap) {
|
|
|
|
|
long tableId = TableUtil.getTableIdByArchiveTypeId(archiveId);
|
|
|
|
|
mmap.put("archiveTypeId", Long.valueOf(archiveId));
|
|
|
|
|
mmap.put("tableId", Long.valueOf(tableId));
|
|
|
|
|
mmap.put("id", id);
|
|
|
|
|
boolean browseServerEnabled = this.archiveConfig.isBrowseServerEnabled();
|
|
|
|
|
|
|
|
|
|
if (browseServerEnabled) {
|
|
|
|
|
return this.prefix + "/browse";
|
|
|
|
|
}
|
|
|
|
|
return this.prefix + "/browsesimple";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping({"/appendAddForm/{archiveTypeId}/{type}/{id}"})
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public String appendAddForm(@PathVariable("archiveTypeId") String archiveTypeId, @PathVariable("type") String type, @PathVariable("id") String id) {
|
|
|
|
|
return this.jsglService.appendAddFormByDataId(archiveTypeId, type, id, "true");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping({"/getDocumentListByFileTableIdAndFileId/{fileTableId}/{fileId}"})
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public AjaxResult getDocumentListByFileTableIdAndFileId(@PathVariable("fileTableId") String fileTableId, @PathVariable("fileId") String fileId) {
|
|
|
|
|
List<Map<String, String>> list = this.iBrowseService.getDocumentListByFileTableIdAndFileId(fileTableId, fileId);
|
|
|
|
|
return AjaxResult.success(list);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping({"/getDocumentList/{fileTableId}/{fileId}"})
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public AjaxResult getDocumentList(@PathVariable("fileTableId") String fileTableId, @PathVariable("fileId") String fileId) {
|
|
|
|
|
List<Map<String, String>> list = this.iBrowseService.getDocumentList(fileTableId, fileId);
|
|
|
|
|
return AjaxResult.success(list);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping({"/getDocument/{documentTableId}/{documentId}"})
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public Object getDocument(@PathVariable("documentTableId") String documentTableId, @PathVariable("documentId") String documentId, HttpServletRequest request, HttpServletResponse response) {
|
|
|
|
|
FileInputStream fis = null;
|
|
|
|
|
ServletOutputStream ops = null;
|
|
|
|
|
String filepath = this.iBrowseService.getDocumentPath(documentTableId, documentId, "false");
|
|
|
|
|
try {
|
|
|
|
|
File f = new File(filepath);
|
|
|
|
|
if (f.exists()) {
|
|
|
|
|
System.out.println(filepath + "===cunzai");
|
|
|
|
|
response.addHeader("Content-Disposition", "attachment;filename=\"" + new String(f.getName().getBytes("UTF-8"), "ISO8859-1") + "\"");
|
|
|
|
|
response.setContentType("application/octet-stream; charset=GBK");
|
|
|
|
|
response.setHeader("Content-Length", String.valueOf(f.length()));
|
|
|
|
|
response.setHeader("Pragma", "No-cache");
|
|
|
|
|
response.setHeader("Cache-Control", "No-cache");
|
|
|
|
|
response.setDateHeader("Expires", 0L);
|
|
|
|
|
fis = new FileInputStream(f);
|
|
|
|
|
ops = response.getOutputStream();
|
|
|
|
|
byte[] bf = new byte[1024];
|
|
|
|
|
int rl = fis.read(bf);
|
|
|
|
|
while (rl > 0) {
|
|
|
|
|
ops.write(bf, 0, rl);
|
|
|
|
|
rl = fis.read(bf);
|
|
|
|
|
}
|
|
|
|
|
ops.flush();
|
|
|
|
|
ops.close();
|
|
|
|
|
fis.close();
|
|
|
|
|
} else {
|
|
|
|
|
System.out.println(filepath + "===bucunzai");
|
|
|
|
|
response.sendRedirect("common/404.jsp");
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
} finally {
|
|
|
|
|
try {
|
|
|
|
|
if (fis != null)
|
|
|
|
|
{
|
|
|
|
|
fis.close();
|
|
|
|
|
}
|
|
|
|
|
/* 154 */ if (ops != null)
|
|
|
|
|
/* 155 */ {
|
|
|
|
|
if (ops != null)
|
|
|
|
|
{
|
|
|
|
|
ops.close();
|
|
|
|
|
}
|
|
|
|
|
/* 156 */ } catch (Exception e) {
|
|
|
|
|
/* 157 */ fis = null;
|
|
|
|
|
/* 158 */ ops = null;
|
|
|
|
|
/* */ }
|
|
|
|
|
/* */ }
|
|
|
|
|
/* 161 */ return null;
|
|
|
|
|
/* */ }
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */ @GetMapping({"/FileOcr/{documentTableId}/{documentId}"})
|
|
|
|
|
/* */ @ResponseBody
|
|
|
|
|
/* */ public AjaxResult FileOcr(@PathVariable("documentTableId") String documentTableId, @PathVariable("documentId") String documentId) {
|
|
|
|
|
/* 174 */ String filepath = this.iBrowseService.getDocumentPath(documentTableId, documentId, "false");
|
|
|
|
|
/* 175 */ String result2 = "";
|
|
|
|
|
/* 176 */ String pdfSpiltImagePath = this.ccglService.getPathByLjbs("archive.pdfSpiltImagePath");
|
|
|
|
|
/* */ try {
|
|
|
|
|
/* 178 */ String filepath1 = filepath.toLowerCase();
|
|
|
|
|
/* 179 */ if (filepath1.contains(".jpg") || filepath1.contains(".png") || filepath1.contains(".gif") || filepath1.contains(".jpeg") || filepath1.contains(".tif")) {
|
|
|
|
|
/* 180 */ result2 = ImageOcr.ImageOcr(filepath);
|
|
|
|
|
/* 181 */ } else if (filepath1.contains(".pdf")) {
|
|
|
|
|
/* */
|
|
|
|
|
/* 183 */ result2 = PdfOcr.getTextFromPdf(filepath, pdfSpiltImagePath);
|
|
|
|
|
/* 184 */ } else if (filepath1.contains(".ofd")) {
|
|
|
|
|
/* */
|
|
|
|
|
/* 186 */ result2 = "";
|
|
|
|
|
/* */ }
|
|
|
|
|
/* 188 */ } catch (Exception e) {
|
|
|
|
|
/* 189 */ System.out.println(e.getMessage());
|
|
|
|
|
/* */ }
|
|
|
|
|
/* 191 */ return AjaxResult.success(result2);
|
|
|
|
|
/* */ }
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */ @GetMapping({"/metaData/{documentTableId}/{documentId}"})
|
|
|
|
|
/* */ public String metaData(@PathVariable("documentTableId") String documentTableId, @PathVariable("documentId") String documentId, ModelMap mmap) {
|
|
|
|
|
/* 203 */ mmap.put("documentTableId", documentTableId);
|
|
|
|
|
/* 204 */ mmap.put("documentId", documentId);
|
|
|
|
|
/* 205 */ return this.prefix + "/metadata";
|
|
|
|
|
/* */ }
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */ @GetMapping({"/metaDataForm/{documentTableId}/{documentId}"})
|
|
|
|
|
/* */ @ResponseBody
|
|
|
|
|
/* */ public String metaDataForm(@PathVariable("documentTableId") String documentTableId, @PathVariable("documentId") String documentId, ModelMap mmap) {
|
|
|
|
|
/* 218 */ String filepath = this.iBrowseService.getDocumentPath(documentTableId, documentId, "false");
|
|
|
|
|
/* 219 */ List<Map<String, String>> list = MetadataUtil.getMetadataAllByFile(filepath);
|
|
|
|
|
/* 220 */ StringBuilder html = new StringBuilder();
|
|
|
|
|
/* 221 */ for (int i = 1; i <= list.size(); i++) {
|
|
|
|
|
/* */
|
|
|
|
|
/* 223 */ if (i % 2 != 0) {
|
|
|
|
|
/* 224 */ html.append("<div class=\"row\">");
|
|
|
|
|
/* */ }
|
|
|
|
|
/* */
|
|
|
|
|
/* 227 */ html.append("<div class=\"col-sm-6\">\r\n\t<div class=\"form-group\">\r\n\t\t<label class=\"col-sm-4 control-label is-required\">" + (String)((Map)list
|
|
|
|
|
/* */
|
|
|
|
|
/* 229 */ .get(i - 1)).get("propety") + ":</label>\r\n\t\t<div class=\"col-sm-8\">\r\n\t\t\t<input required=\"required\" value=\"" + (String)((Map)list
|
|
|
|
|
/* */
|
|
|
|
|
/* 231 */ .get(i - 1)).get("propetyValue") + "\" class=\"form-control\" type=\"text\">\r\n\t\t</div>\r\n\t</div>\r\n </div>");
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* 237 */ if (i % 2 == 0 || i == list.size()) {
|
|
|
|
|
/* 238 */ html.append("</div>");
|
|
|
|
|
/* */ }
|
|
|
|
|
/* */ }
|
|
|
|
|
/* 241 */ return html.toString();
|
|
|
|
|
/* */ }
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */ @GetMapping({"/getPreviewUrl/{docTableId}/{docId}"})
|
|
|
|
|
/* */ @ResponseBody
|
|
|
|
|
/* */ public Map<String, String> getPreviewUrl(HttpServletRequest request, @PathVariable("docTableId") String docTableId, @PathVariable("docId") String docId) {
|
|
|
|
|
/* 254 */ Map<String, String> map = new HashMap<>();
|
|
|
|
|
/* 255 */ String originUrl = "";
|
|
|
|
|
/* 256 */ String fileName = this.iBrowseService.getFileName(docTableId, docId);
|
|
|
|
|
/* 257 */ if (StringUtils.isNotEmpty(fileName)) {
|
|
|
|
|
/* 258 */ StringBuffer url = request.getRequestURL();
|
|
|
|
|
/* 259 */ originUrl = url.toString();
|
|
|
|
|
/* 260 */ originUrl = originUrl.substring(0, originUrl.indexOf("getPreviewUrl"));
|
|
|
|
|
/* 261 */ originUrl = originUrl + "browseDocument?docTableId=" + docTableId + "&docId=" + docId + "&fullfilename=" + fileName;
|
|
|
|
|
/* */ }
|
|
|
|
|
/* */
|
|
|
|
|
/* 264 */ String browseServer = this.archiveConfig.getBrowseServer();
|
|
|
|
|
/* 265 */ if (StringUtils.isNotEmpty(browseServer)) {
|
|
|
|
|
/* 266 */ boolean flag = HttpUtils.urlWhetherReachable(browseServer, 2000);
|
|
|
|
|
/* 267 */ if (flag) {
|
|
|
|
|
/* 268 */ if (browseServer.endsWith("/")) {
|
|
|
|
|
/* 269 */ browseServer = browseServer + "onlinePreview?url=";
|
|
|
|
|
/* */ } else {
|
|
|
|
|
/* 271 */ browseServer = browseServer + "/onlinePreview?url=";
|
|
|
|
|
/* */ }
|
|
|
|
|
/* */ } else {
|
|
|
|
|
/* 274 */ browseServer = "";
|
|
|
|
|
/* */ }
|
|
|
|
|
/* */ }
|
|
|
|
|
/* 277 */ map.put("originUrl", originUrl);
|
|
|
|
|
/* 278 */ map.put("browseServer", browseServer);
|
|
|
|
|
/* 279 */ return map;
|
|
|
|
|
/* */ }
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */ @RequestMapping(value = {"/browseDocument"}, method = {RequestMethod.GET})
|
|
|
|
|
/* */ public void browseDocument(HttpServletRequest request, HttpServletResponse response) {
|
|
|
|
|
/* 289 */ String docTableId = request.getParameter("docTableId");
|
|
|
|
|
/* 290 */ String docId = request.getParameter("docId");
|
|
|
|
|
/* 291 */ String filePath = this.iBrowseService.getDocumentFilePath(docTableId, docId);
|
|
|
|
|
/* 292 */ File file = new File(filePath);
|
|
|
|
|
/* 293 */ if (file.exists()) {
|
|
|
|
|
/* 294 */ byte[] data = null;
|
|
|
|
|
/* 295 */ FileInputStream input = null;
|
|
|
|
|
/* */ try {
|
|
|
|
|
/* 297 */ input = new FileInputStream(file);
|
|
|
|
|
/* 298 */ data = new byte[input.available()];
|
|
|
|
|
/* 299 */ input.read(data);
|
|
|
|
|
/* 300 */ response.getOutputStream().write(data);
|
|
|
|
|
/* 301 */ } catch (Exception e) {
|
|
|
|
|
/* 302 */ e.printStackTrace();
|
|
|
|
|
/* */ } finally {
|
|
|
|
|
/* */ try {
|
|
|
|
|
/* 305 */ if (input != null) {
|
|
|
|
|
/* 306 */ input.close();
|
|
|
|
|
/* */ }
|
|
|
|
|
/* 308 */ } catch (IOException e) {
|
|
|
|
|
/* 309 */ e.printStackTrace();
|
|
|
|
|
/* */ }
|
|
|
|
|
/* */ }
|
|
|
|
|
/* */ }
|
|
|
|
|
/* */ }
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */ @GetMapping({"/getMetaData/{documentTableId}/{documentId}"})
|
|
|
|
|
/* */ @ResponseBody
|
|
|
|
|
/* */ public AjaxResult getMetaData(@PathVariable("documentTableId") String documentTableId, @PathVariable("documentId") String documentId) {
|
|
|
|
|
/* 324 */ String filepath = this.iBrowseService.getDocumentPath(documentTableId, documentId, "false");
|
|
|
|
|
/* 325 */ List<Map<String, String>> list = new ArrayList<>();
|
|
|
|
|
/* */ try {
|
|
|
|
|
/* 327 */ list = MetadataUtil.getMetadataAllByFile(filepath);
|
|
|
|
|
/* 328 */ } catch (Exception e) {
|
|
|
|
|
/* 329 */ e.printStackTrace();
|
|
|
|
|
/* */ }
|
|
|
|
|
/* 331 */ return AjaxResult.success(list);
|
|
|
|
|
/* */ }
|
|
|
|
|
/* */ }
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
fis = null;
|
|
|
|
|
ops = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping({"/FileOcr/{documentTableId}/{documentId}"})
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public AjaxResult FileOcr(@PathVariable("documentTableId") String documentTableId, @PathVariable("documentId") String documentId) {
|
|
|
|
|
String filepath = this.iBrowseService.getDocumentPath(documentTableId, documentId, "false");
|
|
|
|
|
String result2 = "";
|
|
|
|
|
String pdfSpiltImagePath = this.ccglService.getPathByLjbs("archive.pdfSpiltImagePath");
|
|
|
|
|
try {
|
|
|
|
|
String filepath1 = filepath.toLowerCase();
|
|
|
|
|
if (filepath1.contains(".jpg") || filepath1.contains(".png") || filepath1.contains(".gif") || filepath1.contains(".jpeg") || filepath1.contains(".tif")) {
|
|
|
|
|
result2 = ImageOcr.ImageOcr(filepath);
|
|
|
|
|
} else if (filepath1.contains(".pdf")) {
|
|
|
|
|
|
|
|
|
|
result2 = PdfOcr.getTextFromPdf(filepath, pdfSpiltImagePath);
|
|
|
|
|
} else if (filepath1.contains(".ofd")) {
|
|
|
|
|
|
|
|
|
|
result2 = "";
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
System.out.println(e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
return AjaxResult.success(result2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping({"/metaData/{documentTableId}/{documentId}"})
|
|
|
|
|
public String metaData(@PathVariable("documentTableId") String documentTableId, @PathVariable("documentId") String documentId, ModelMap mmap) {
|
|
|
|
|
mmap.put("documentTableId", documentTableId);
|
|
|
|
|
mmap.put("documentId", documentId);
|
|
|
|
|
return this.prefix + "/metadata";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping({"/metaDataForm/{documentTableId}/{documentId}"})
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public String metaDataForm(@PathVariable("documentTableId") String documentTableId, @PathVariable("documentId") String documentId, ModelMap mmap) {
|
|
|
|
|
String filepath = this.iBrowseService.getDocumentPath(documentTableId, documentId, "false");
|
|
|
|
|
List<Map<String, String>> list = MetadataUtil.getMetadataAllByFile(filepath);
|
|
|
|
|
StringBuilder html = new StringBuilder();
|
|
|
|
|
for (int i = 1; i <= list.size(); i++) {
|
|
|
|
|
|
|
|
|
|
if (i % 2 != 0) {
|
|
|
|
|
html.append("<div class=\"row\">");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html.append("<div class=\"col-sm-6\">\r\n\t<div class=\"form-group\">\r\n\t\t<label class=\"col-sm-4 control-label is-required\">" + (String)((Map)list
|
|
|
|
|
|
|
|
|
|
.get(i - 1)).get("propety") + ":</label>\r\n\t\t<div class=\"col-sm-8\">\r\n\t\t\t<input required=\"required\" value=\"" + (String)((Map)list
|
|
|
|
|
|
|
|
|
|
.get(i - 1)).get("propetyValue") + "\" class=\"form-control\" type=\"text\">\r\n\t\t</div>\r\n\t</div>\r\n </div>");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (i % 2 == 0 || i == list.size()) {
|
|
|
|
|
html.append("</div>");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return html.toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping({"/getPreviewUrl/{docTableId}/{docId}"})
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public Map<String, String> getPreviewUrl(HttpServletRequest request, @PathVariable("docTableId") String docTableId, @PathVariable("docId") String docId) {
|
|
|
|
|
Map<String, String> map = new HashMap<>();
|
|
|
|
|
String originUrl = "";
|
|
|
|
|
String fileName = this.iBrowseService.getFileName(docTableId, docId);
|
|
|
|
|
if (StringUtils.isNotEmpty(fileName)) {
|
|
|
|
|
StringBuffer url = request.getRequestURL();
|
|
|
|
|
originUrl = url.toString();
|
|
|
|
|
originUrl = originUrl.substring(0, originUrl.indexOf("getPreviewUrl"));
|
|
|
|
|
originUrl = originUrl + "browseDocument?docTableId=" + docTableId + "&docId=" + docId + "&fullfilename=" + fileName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String browseServer = this.archiveConfig.getBrowseServer();
|
|
|
|
|
if (StringUtils.isNotEmpty(browseServer)) {
|
|
|
|
|
boolean flag = HttpUtils.urlWhetherReachable(browseServer, 2000);
|
|
|
|
|
if (flag) {
|
|
|
|
|
if (browseServer.endsWith("/")) {
|
|
|
|
|
browseServer = browseServer + "onlinePreview?url=";
|
|
|
|
|
} else {
|
|
|
|
|
browseServer = browseServer + "/onlinePreview?url=";
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
browseServer = "";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
map.put("originUrl", originUrl);
|
|
|
|
|
map.put("browseServer", browseServer);
|
|
|
|
|
return map;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = {"/browseDocument"}, method = {RequestMethod.GET})
|
|
|
|
|
public void browseDocument(HttpServletRequest request, HttpServletResponse response) {
|
|
|
|
|
String docTableId = request.getParameter("docTableId");
|
|
|
|
|
String docId = request.getParameter("docId");
|
|
|
|
|
String filePath = this.iBrowseService.getDocumentFilePath(docTableId, docId);
|
|
|
|
|
File file = new File(filePath);
|
|
|
|
|
if (file.exists()) {
|
|
|
|
|
byte[] data = null;
|
|
|
|
|
FileInputStream input = null;
|
|
|
|
|
try {
|
|
|
|
|
input = new FileInputStream(file);
|
|
|
|
|
data = new byte[input.available()];
|
|
|
|
|
input.read(data);
|
|
|
|
|
response.getOutputStream().write(data);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
} finally {
|
|
|
|
|
try {
|
|
|
|
|
if (input != null) {
|
|
|
|
|
input.close();
|
|
|
|
|
}
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping({"/getMetaData/{documentTableId}/{documentId}"})
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public AjaxResult getMetaData(@PathVariable("documentTableId") String documentTableId, @PathVariable("documentId") String documentId) {
|
|
|
|
|
String filepath = this.iBrowseService.getDocumentPath(documentTableId, documentId, "false");
|
|
|
|
|
List<Map<String, String>> list = new ArrayList<>();
|
|
|
|
|
try {
|
|
|
|
|
list = MetadataUtil.getMetadataAllByFile(filepath);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
return AjaxResult.success(list);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\project\browse\controller\BrowseController.class
|
|
|
|
|