需求背景
做一个OCR识别的功能,需要导出原图和识别出来的结果的图纸,将数据导出.
解决方案
EasyPOI中可以用字节类型,导出图片,可以将图片存放的url 转成字节,然后导出.但是整个导出过程耗时较久。
具体代码
/*** 草图OCR识别记录-导出.** @param response: HttpServletResponse.* @param pageQueryBO:筛选条件.*/@RequestMapping(value = "/exportExcel", method = RequestMethod.POST)public ResponseEntity<ByteArrayResource> exportExcel(@RequestBody BuOrcPicOssRecordPageQueryBO pageQueryBO, HttpServletResponse response) throws IOException {//导出数据List<BuOrcPicOssRecordExportBO> list = new ArrayList<>();// 导出的数据不需要分页pageQueryBO.setNoNeedPaging(true);ResultBO<PageBO<List<BuOrcPicOssRecordBO>>> pageBOResultBO = buOrcPicOssRecordService.selectOrcPicOssRecordPageList(pageQueryBO);List<BuOrcPicOssRecordBO> dataList = pageBOResultBO.getData().getDataList();if(ObjectUtils.isNotEmpty(dataList)){list = ModelMapperUtil.mapList(dataList,BuOrcPicOssRecordExportBO.class);}// 导出原先的图片和识别后的图片BASE64Decoder base64Decoder = new BASE64Decoder();// 解码操作for(BuOrcPicOssRecordExportBO item:list ){// Base64 转字节流显示图片if(ObjectUtils.isNotEmpty(item.getRoofPicUrl())){byte[] bytes = base64Decoder.decodeBuffer(item.getRoofPicUrl().replace("data:image/png;base64,"