| | |
| | | tjReport.setTjNumber(String.valueOf(tjNumber)); |
| | | tjReport.setPath(urlValue + outputFileName1); |
| | | String outputPath1 = value + File.separator; |
| | | String pdfBinary = getPDFBinary(outputPath1 + outputFileName1); |
| | | tjReport.setReport(pdfBinary); |
| | | // String pdfBinary = getPDFBinary(outputPath1 + outputFileName1); |
| | | // tjReport.setReport(pdfBinary); |
| | | tjReport.setType("体检报告"); |
| | | tjReport.setPrint("pdf"); |
| | | tjReportService.save(tjReport); |
| | |
| | | |
| | | @GetMapping("/preview/{flag}/{TjNumber}") |
| | | @ApiOperation(value = "下载体检报告") |
| | | public void preview(HttpServletResponse response, @PathVariable("flag") boolean flag, @PathVariable("TjNumber") String tjNumber) { |
| | | public void preview(HttpServletResponse response, @PathVariable("flag") boolean flag, @PathVariable("TjNumber") String tjNumber) throws IOException { |
| | | TjOrder tjOrder = tjOrderService.getOrderByTjNum(tjNumber); |
| | | TjCustomer tjCustomer = tjCustomerService.getById( tjOrder.getUserId()); |
| | | // LambdaQueryWrapper<TjReport> we = new LambdaQueryWrapper<>(); |
| | |
| | | if (flag) { |
| | | // 在线打开方式 |
| | | URL u = new URL("file:///" + filePath); |
| | | //System.out.println(u); |
| | | String contentType = u.openConnection().getContentType(); |
| | | response.setContentType(contentType); |
| | | response.setHeader("Content-Disposition", "inline;filename=" |
| | |
| | | while ((len = br.read(bs)) > 0) { |
| | | out.write(bs, 0, len); |
| | | } |
| | | // if(null !=tjOrder.getHeshouTime() && tjOrder.getHeshouStatus()==1){ |
| | | // TjReportPrint print=new TjReportPrint(); |
| | | // print.setTjNumber(tjNumber); |
| | | // print.setPrintBy(SecurityUtils.getLoginUser().getUser().getNickName()); |
| | | // print.setPrintTime(date); |
| | | // print.setPrintStatus("已打印"); |
| | | // if (printService.save(print)) { |
| | | // tjOrder.setPrintLastTime(date); |
| | | // tjOrderService.updateById(tjOrder); |
| | | // } |
| | | // } |
| | | out.flush(); |
| | | out.close(); |
| | | br.close(); |
| | |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | //System.out.println("pdf处理文件异常" + e); |
| | | // response.sendError(HttpServletResponse.SC_NOT_FOUND); |
| | | } finally { |
| | | if (out != null) { |
| | | try { |
| | |
| | | key = key.replace("ltkjpeis10_",""); |
| | | |
| | | // String userId = SecurityUtils.getLoginUser().getUsername(); |
| | | PDFBinaryUtil.base64StringToPDF(one.getReport(), FileUtil.mkdir(value).getPath() + File.separator + key + File.separator + tjCustomer.getCusId() + tjNumber + tjCustomer.getCusName() + "_体检报告.pdf"); |
| | | String filePath = value + File.separator + key + File.separator + tjCustomer.getCusId() + tjNumber + tjCustomer.getCusName() + "_体检报告.pdf"; |
| | | // PDFBinaryUtil.base64StringToPDF(one.getReport(), FileUtil.mkdir(value).getPath() + File.separator + key + File.separator + tjCustomer.getCusId() + tjNumber + tjCustomer.getCusName() + "_体检报告.pdf"); |
| | | String filePath = value + File.separator + key + File.separator + tjCustomer.getCusId() + tjNumber + tjCustomer.getCusName() + "_报告.pdf"; |
| | | File f = new File(filePath); |
| | | if (filePath.isEmpty()) { |
| | | System.out.println("文件不存在!"); |
| | | return; |
| | | } |
| | | BufferedInputStream br = null; |
| | | OutputStream out = null; |
| | | FileInputStream fileInputStream = null; |