| | |
| | | package cn.huge.module.file.controller.web; |
| | | |
| | | import cn.huge.base.common.exception.ClientException; |
| | | import cn.huge.module.sys.dto.IdcardOcrResultDTO; |
| | | import cn.huge.module.utils.BaiduOcrUtils; |
| | | import cn.huge.base.common.utils.ContentTypeUtils; |
| | | import cn.huge.base.common.utils.ReturnFailUtils; |
| | |
| | | } |
| | | |
| | | /** |
| | | * ocr识别文字 |
| | | * @url {ctx}/api/web/fileInfo/recognitionText?ownerId=&ownerType= |
| | | * @param request |
| | | * @return Object |
| | | */ |
| | | @PostMapping(value = "/recognitionText") |
| | | public Object recognitionText(MultipartHttpServletRequest request){ |
| | | try{ |
| | | Map<String , Object> result = Maps.newHashMap(); |
| | | Iterator<String> itr = request.getFileNames(); |
| | | while (itr.hasNext()) { |
| | | MultipartFile file = request.getFile(itr.next()); |
| | | try{ |
| | | Map<String , Object> map = BaiduOcrUtils.ocrText(file.getBytes()); |
| | | result.put("ocrResult", map); |
| | | }catch (Exception e){ |
| | | log.error("Controller接口[FileInfoController.recognitionText]请求异常:"+e, e); |
| | | return ReturnFailUtils.getRepInfo("OCR失败!"); |
| | | } |
| | | } |
| | | return ReturnSucUtils.getRepInfo("识别成功", result); |
| | | }catch (Exception e){ |
| | | return ReturnFailUtils.getRepInfo(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 查看附件组件-分类查询附件 |
| | | * @url {ctx}/api/web/fileInfo/listFileByCat |
| | | * @param mainId 所属业务主体编号 |