代码拉取完成,页面将自动刷新
高检 2.0 对接项目
基于 springboot-2.1.6.RELEASE, JDK1.8, lombok-1.18.8
项目运行时所依赖的外部集成方,比如订单系统会依赖于会员系统;
各个环境的访问方式,数据库连接等;
统一的编码实践,比如异常处理原则、分页封装等;
开发过程中常见问题的解答。
view-procuracy
: 父工程, 定义通用依赖及配置view-procuracy-common
: 通用组件工程, 包含: 工具类, 公共异常类, 结果码, POJO 等
├── aspect: 通用切面逻辑
│── enums: 通用枚举类
│── exception: 工程统一异常封装, 每个子模块可以继承后定义自己的异常
│── result: 统一的结果对象, 包括分页结果对象, 统一 web 响应对象
│── util: 通用的工具类
view-procuracy-tools
: 底层引擎调用的简单封装, 不包含业务逻辑
├── cont: 编目能力
│── elle: 要素抽取能力
│── ocr: 图文识别能力
view-procuracy-ocr
: OCR工程view-procuracy-card
: 案卡工程view-procuracy-cont
: 编目工程view-procuracy-web
: 项目入口 web 工程对应版本号2.2.7
解决方法:通过判断数据库中待识别任务执行时间是否超过3分钟去删除失败任务 对应版本号2.2.16
//通过ImageMagic工具将失真的jpg(有损压缩)转成png(无损压缩)后可成功生成pdf
public static void main(String[] args) throws Exception {
String filePath = "D:\\test\\15.jpg";
File file = new File(filePath);
byte[] fileBytes = FileUtil.readBytes(file);
String outPath = "D:\\test\\15_result_pdf.pdf";
String SERVER_URL = "http://172.31.96.176:8085/"+"/tuling/ocr/v2/file/{trackId}";
Result<String> ocrResult = null;
String trackId = UUID.randomUUID().toString();
String serviceUrl = StringUtils.replace(SERVER_URL, "{trackId}", trackId);
serviceUrl=serviceUrl +"?params={params}";
JSONObject params = new JSONObject();
params.put("pagetype", "page");
params.put("funclist", "");
params.put("resultlevel", "3");
params.put("pagetype", "page");
//DEFAULT_PARAMS_JSON.put("funclist", "ocr,od");
params.put("funclist", "");
//od 朝向检测 ;ic 图片分类; er 证据检出(签章、收印、插图、手写体)
params.put("resultlevel", "3");
HttpHeaders headers = new HttpHeaders();
//headers.setContentType(MediaType.MULTIPART_FORM_DATA_VALUE.toString());
headers.add("Content-Type", MediaType.MULTIPART_FORM_DATA_VALUE);
FileSystemResource resource = new FileSystemResource(file);
MultiValueMap<String, Object> form = new LinkedMultiValueMap<>();
form.add("picFile", resource);
HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity<>(form, headers);
String finalServiceUrl = serviceUrl;
String paramJson = params.toJSONString();
RestTemplate restTemplate = new RestTemplate();
String resp = restTemplate.postForObject(finalServiceUrl, httpEntity, String.class, paramJson);
Result<String> body = Result.success(JSONUtil.getProp(JSONUtil.toJsonNode(resp), "body", String.class));
String ocrJson = body.getData();
byte[] bytes = new PdfComposeUtil().handleCompose(fileBytes, ocrJson);
FileUtil.writeBytes(bytes,outPath);
}
/* Image image = Image.getInstance(filePath);
image.getPlainHeight();*/
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。