| | |
| | | |
| | | @GetMapping("/toPdf/{TjNumber}") |
| | | @ApiOperation(value = "打印体检报告为pdf") |
| | | @Transactional |
| | | // @Transactional |
| | | public AjaxResult toPdf(@PathVariable("TjNumber") @ApiParam(value = "体检号") String tjNumber) { |
| | | // AjaxResult error = null; |
| | | // 之前的代码 优化速度 |
| | |
| | | try { |
| | | return shengchengbgmoban(tjNumber, tjOrder, tjCustomer, reportTemplate,zongJianYiShiQianMing); |
| | | } catch (Exception e) { |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | log.error(String.valueOf(e)); |
| | | // TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | log.error("生成报告失败:"+e.getMessage(),String.valueOf(e)); |
| | | tjOrder.setReportTime(null); |
| | | tjOrder.setCheckTime(null); |
| | | tjOrder.setCheckStatus(0); |
| | | tjOrder.setPrintLastTime(null); |
| | | tjOrderService.updateById(tjOrder); |
| | | |
| | | logger.error(String.valueOf(e)); |
| | | // logger.error(String.valueOf(e)); |
| | | return AjaxResult.error("生成报告失败"); |
| | | } |
| | | } else { |
| | |
| | | return AjaxResult.error(); |
| | | } |
| | | |
| | | public AjaxResult shengchengbgmoban(String tjNumber, TjOrder tjOrder, TjCustomer tjCustomer, TjReportTemplate reportTemplate,TjReportTemplate zongJianYiShiQianMing) { |
| | | public AjaxResult shengchengbgmoban(String tjNumber, TjOrder tjOrder, TjCustomer tjCustomer, TjReportTemplate reportTemplate,TjReportTemplate zongJianYiShiQianMing) throws Exception { |
| | | AjaxResult ajaxResult = null; |
| | | try { |
| | | // ajaxResult = hisPDFUtil.hisPDF(tjOrder, tjCustomer, reportTemplate); |
| | |
| | | |
| | | ajaxResult = hisPDFUtil.hisPDFNew2(tjOrder, tjCustomer, reportTemplate,zongJianYiShiQianMing); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | log.error(String.valueOf(e)); |
| | | // e.printStackTrace(); |
| | | // log.error(String.valueOf(e)); |
| | | throw new Exception(e); |
| | | } |
| | | if (!ajaxResult.get("code").toString().equals("200")) { |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | // TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | return AjaxResult.error("生成报告失败"); |
| | | } else { |
| | | Long userId = tjCustomer.getCusId(); |
| | | String outputFileName1 = userId + tjNumber + tjCustomer.getCusName() + "_报告.pdf"; |
| | |
| | | |
| | | TjCustomer tjCustomer = tjCustomerService.getById( tjOrder.getUserId()); |
| | | |
| | | LambdaQueryWrapper<TjReport> we = new LambdaQueryWrapper<>(); |
| | | we.eq(TjReport::getTjNumber, tjNumber); |
| | | we.eq(TjReport::getType, "体检报告"); |
| | | TjReport one = tjReportService.getOne(we); |
| | | if (one == null) { |
| | | return; |
| | | } |
| | | |
| | | String userId = SecurityUtils.getLoginUser().getUsername(); |
| | | PDFBinaryUtil.base64StringToPDF(one.getReport(), FileUtil.mkdir(value).getPath() + File.separator + userId + tjNumber + tjCustomer.getCusName() + "_体检报告.pdf"); |
| | | String filePath = value + File.separator + userId + tjNumber + tjCustomer.getCusName() + "_体检报告.pdf"; |
| | | // LambdaQueryWrapper<TjReport> we = new LambdaQueryWrapper<>(); |
| | | // we.eq(TjReport::getTjNumber, tjNumber); |
| | | // we.eq(TjReport::getType, "体检报告"); |
| | | // TjReport one = tjReportService.getOne(we); |
| | | // if (one == null) { |
| | | // return; |
| | | // } |
| | | // |
| | | // String userId = SecurityUtils.getLoginUser().getUsername(); |
| | | // PDFBinaryUtil.base64StringToPDF(one.getReport(), FileUtil.mkdir(value).getPath() + File.separator + userId + tjNumber + tjCustomer.getCusName() + "_体检报告.pdf"); |
| | | // String filePath = value + File.separator + userId + tjNumber + tjCustomer.getCusName() + "_体检报告.pdf"; |
| | | String filePath = value + File.separator + tjCustomer.getCusId() + tjNumber + tjCustomer.getCusName() + "_报告.pdf"; |
| | | File f = new File(filePath); |
| | | if (filePath.isEmpty()) { |
| | | System.out.println("文件不存在!"); |
| | |
| | | String contentType = u.openConnection().getContentType(); |
| | | response.setContentType(contentType); |
| | | response.setHeader("Content-Disposition", "inline;filename=" |
| | | + userId + tjNumber + ".pdf"); |
| | | + tjCustomer.getCusId() + tjNumber + ".pdf"); |
| | | } else { |
| | | // 纯下载方式 |
| | | response.setContentType("application/x-msdownload"); |
| | | response.setContentType("application/pdf;charset=utf-8"); |
| | | response.setHeader("Content-Disposition", "attachment;filename=" |
| | | + userId + tjNumber + ".pdf"); |
| | | + tjCustomer.getCusId() + tjNumber + ".pdf"); |
| | | } |
| | | out = response.getOutputStream(); |
| | | while ((len = br.read(bs)) > 0) { |