| | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Propagation; |
| | |
| | | * @author ltkj |
| | | * @date 2022-12-06 |
| | | */ |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("/system/report") |
| | | @Api(tags = "体检报告") |
| | | @Api(tags = "AAAA_体检报告") |
| | | @Transactional |
| | | public class TjReportController extends BaseController { |
| | | @Resource |
| | |
| | | private ITjBigPositiveService tjBigPositiveService; |
| | | @Autowired |
| | | private HisPDFUtil hisPDFUtil; |
| | | @Autowired |
| | | private IDictHospService dictHospService; |
| | | |
| | | @GetMapping("/savePdf") |
| | | @ApiOperation(value = "从本地存储模板到数据库") |
| | | public AjaxResult savePdf() { |
| | | //从文件地址读入PDF文件 仅存储一次 |
| | | String base64String = PDFBinaryUtil.getPDFBinary(configService.selectConfigByKey("default_pdf5Template")); |
| | | reportTemplateService.remove(new LambdaQueryWrapper<TjReportTemplate>().eq(TjReportTemplate::getName,"体检报告模板5")); |
| | | TjReportTemplate tem = new TjReportTemplate(); |
| | | tem.setName("体检报告模板5"); |
| | | tem.setRemark("体检报告模板5"); |
| | | tem.setTemplate(base64String); |
| | | tem.setFlag("1"); |
| | | tem.setOpen("0"); |
| | | tem.setCreateTime(DateUtil.date()); |
| | | final boolean save = reportTemplateService.save(tem); |
| | | if (save) { |
| | | return AjaxResult.success("保存成功"); |
| | |
| | | // return error; |
| | | // } |
| | | // return AjaxResult.success("该用户体检未完成,不能打印报告!!!"); |
| | | int num = tjOrderRemarkService.getTjYqOrderRemarkByTjNum(tjNumber); |
| | | if (num > 0) { |
| | | return AjaxResult.error("有延期项目暂不能生成报告!!!"); |
| | | String config = configService.selectConfigByKey("sfjcwjhyqxm"); |
| | | if(null != config && config.equalsIgnoreCase("Y")){ |
| | | int num = tjOrderRemarkService.getTjYqOrderRemarkByTjNum(tjNumber); |
| | | if (num > 0) return AjaxResult.error("存在未检或延期项目暂不能生成报告!!!"); |
| | | } |
| | | |
| | | // String configByKey = configService.selectConfigByKey("sfkqdyhis"); |
| | |
| | | return shengchengbgmoban(tjNumber, tjOrder, tjCustomer, reportTemplate); |
| | | } catch (Exception e) { |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | e.printStackTrace(); |
| | | log.error(String.valueOf(e)); |
| | | // 调用撤销 |
| | | // tjReportController.backOnlyCheckType(tjNumber); |
| | | logger.error("生成报告异常"); |
| | |
| | | return AjaxResult.error(); |
| | | } |
| | | |
| | | public AjaxResult shengchengbgmoban(String tjNumber, TjOrder tjOrder, TjCustomer tjCustomer, TjReportTemplate reportTemplate) throws Exception { |
| | | AjaxResult ajaxResult = hisPDFUtil.hisPDF(tjOrder, tjCustomer, reportTemplate); |
| | | public AjaxResult shengchengbgmoban(String tjNumber, TjOrder tjOrder, TjCustomer tjCustomer, TjReportTemplate reportTemplate) { |
| | | AjaxResult ajaxResult = null; |
| | | try { |
| | | // ajaxResult = hisPDFUtil.hisPDF(tjOrder, tjCustomer, reportTemplate); |
| | | ajaxResult = hisPDFUtil.hisPDFNew(tjOrder, tjCustomer, reportTemplate); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | log.error(String.valueOf(e)); |
| | | } |
| | | if (!ajaxResult.get("code").toString().equals("200")) { |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | } else { |
| | |
| | | TjReport tjReport = new TjReport(); |
| | | tjReport.setTjNumber(String.valueOf(tjNumber)); |
| | | tjReport.setPath(urlValue + outputFileName1); |
| | | String outputPath1 = value + "\\"; |
| | | String outputPath1 = value + File.separator; |
| | | String pdfBinary = getPDFBinary(outputPath1 + outputFileName1); |
| | | tjReport.setReport(pdfBinary); |
| | | tjReport.setType("体检报告"); |
| | |
| | | System.out.println("文件保存前耗时:" + (fujianEnd - pdfMkStart)); |
| | | // 保存pdf文件 |
| | | copy.close(); |
| | | String outputPath1 = value + "\\"; |
| | | String outputPath1 = value + File.separator; |
| | | String outputFileName1 = userId + tjNumber + tjCustomer.getCusName() + "new_体检报告.pdf"; |
| | | File file = new File(outputPath1 + outputFileName1); |
| | | BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(file)); |
| | |
| | | // 设置正文字体样式:12号 |
| | | Font textFont = PdfUtils.setFont(9); |
| | | //创建表格 将表头字体和正文字体放进去 |
| | | PdfPTable table = PdfUtils.setTable(headFont, textFont, titles, value); |
| | | DictHosp dictHosp = dictHospService.list().get(0); |
| | | PdfPTable table = PdfUtils.setTable(headFont, textFont, titles, value,dictHosp.equals("澄合矿务局中心医院")); |
| | | document.add(paragraph); |
| | | document.add(table); |
| | | //判断备注是否为空 空不能显示null |
| | |
| | | } |
| | | |
| | | private AjaxResult oldFun(String tjNumber) { |
| | | DictHosp dictHosp = dictHospService.list().get(0); |
| | | long startTime = System.currentTimeMillis(); |
| | | int num = tjOrderRemarkService.getTjYqOrderRemarkByTjNum(tjNumber); |
| | | if (num > 0) return AjaxResult.error("有延期项目暂不能生成报告!!!"); |
| | |
| | | String template = reportTemplate.getTemplate(); |
| | | String userId = SecurityUtils.getLoginUser().getUsername(); |
| | | if (template != null) { |
| | | PDFBinaryUtil.base64StringToPDF(template, FileUtil.mkdir(value).getPath() + "\\" + userId + "体检报告封面模板.pdf"); |
| | | PDFBinaryUtil.base64StringToPDF(template, FileUtil.mkdir(value).getPath() + File.separator + userId + "体检报告封面模板.pdf"); |
| | | } |
| | | // --------以上------- 根据数据库中的模板二进制文件 转pdf 创建文件夹 将pdf放进本地文件夹 |
| | | |
| | |
| | | tjOrderDetail.setProject(tjProject); |
| | | } |
| | | |
| | | String inputFileName = value + "\\" + userId + "体检报告封面模板.pdf"; |
| | | String outputFileName = value + "\\" + userId + "体检报告封面页.pdf"; |
| | | String inputFileName = value + File.separator + userId + "体检报告封面模板.pdf"; |
| | | String outputFileName = value + File.separator + userId + "体检报告封面页.pdf"; |
| | | OutputStream os = null; |
| | | PdfStamper ps = null; |
| | | PdfReader reader = null; |
| | |
| | | //设置文档的页边距就是距离页面边上的距离,分别为:左边距,右边距,上边距,下边距 |
| | | document.setMargins(70, 70, 40, 40); |
| | | //生成pdf的位置以及名称 |
| | | String fileName = value + "\\" + userId + tjNumber + "体检报告项目详情页.pdf"; |
| | | String fileName = value + File.separator + userId + tjNumber + "体检报告项目详情页.pdf"; |
| | | OutputStream outputStream = Files.newOutputStream(Paths.get(fileName)); |
| | | PdfWriter pdfWriter = PdfWriter.getInstance(document, outputStream); |
| | | |
| | |
| | | // 设置正文字体样式:12号 |
| | | Font textFont = PdfUtils.setFont(9); |
| | | //创建表格 将表头字体和正文字体放进去 |
| | | PdfPTable table = PdfUtils.setTable(headFont, textFont, titles, value); |
| | | PdfPTable table = PdfUtils.setTable(headFont, textFont, titles, value,dictHosp.equals("澄合矿务局中心医院")); |
| | | document.add(paragraph); |
| | | document.add(table); |
| | | |
| | |
| | | // TjReport one11111 = tjReportService.getOne(rtwq1); |
| | | // if(null !=one11111){ |
| | | // String report1 = one11111.getReport(); |
| | | // PDFBinaryUtil.base64StringToPDF(report1, FileUtil.mkdir(value).getPath() + "\\" + userId + "医学名词.pdf"); |
| | | // PDFBinaryUtil.base64StringToPDF(report1, FileUtil.mkdir(value).getPath() + File.separator + userId + "医学名词.pdf"); |
| | | // } |
| | | |
| | | LambdaQueryWrapper<TjReport> rtwq = new LambdaQueryWrapper<>(); |
| | |
| | | TjReport one1111 = tjReportService.getOne(rtwq); |
| | | if (null != one1111) { |
| | | String report = one1111.getReport(); |
| | | PDFBinaryUtil.base64StringToPDF(report, FileUtil.mkdir(value).getPath() + "\\" + tjNumber + userId + "心电图.pdf"); |
| | | PDFBinaryUtil.base64StringToPDF(report, FileUtil.mkdir(value).getPath() + File.separator + tjNumber + userId + "心电图.pdf"); |
| | | } |
| | | |
| | | LambdaQueryWrapper<TjReport> rtwq12 = new LambdaQueryWrapper<>(); |
| | |
| | | TjReport one111112 = tjReportService.getOne(rtwq12); |
| | | if (null != one111112) { |
| | | String report12 = one111112.getReport(); |
| | | PDFBinaryUtil.base64StringToPDF(report12, FileUtil.mkdir(value).getPath() + "\\" + tjNumber + userId + "附件.pdf"); |
| | | PDFBinaryUtil.base64StringToPDF(report12, FileUtil.mkdir(value).getPath() + File.separator + tjNumber + userId + "附件.pdf"); |
| | | } |
| | | |
| | | //合并 |
| | | String[] files1 = null; |
| | | if (one1111 != null) { |
| | | if (one111112 != null) { |
| | | files1 = new String[]{value + "\\" + userId + "体检报告封面页.pdf", value + "\\" + userId + tjNumber + "体检报告项目详情页.pdf", value + "\\" + tjNumber + userId + "附件.pdf", value + "\\" + tjNumber + userId + "心电图.pdf"}; |
| | | files1 = new String[]{value + File.separator + userId + "体检报告封面页.pdf", value + File.separator + userId + tjNumber + "体检报告项目详情页.pdf", value + File.separator + tjNumber + userId + "附件.pdf", value + File.separator + tjNumber + userId + "心电图.pdf"}; |
| | | } else { |
| | | files1 = new String[]{value + "\\" + userId + "体检报告封面页.pdf", value + "\\" + userId + tjNumber + "体检报告项目详情页.pdf", value + "\\" + tjNumber + userId + "心电图.pdf"}; |
| | | files1 = new String[]{value + File.separator + userId + "体检报告封面页.pdf", value + File.separator + userId + tjNumber + "体检报告项目详情页.pdf", value + File.separator + tjNumber + userId + "心电图.pdf"}; |
| | | } |
| | | } else { |
| | | if (one111112 != null) { |
| | | files1 = new String[]{value + "\\" + userId + "体检报告封面页.pdf", value + "\\" + userId + tjNumber + "体检报告项目详情页.pdf", value + "\\" + tjNumber + userId + "附件.pdf"}; |
| | | files1 = new String[]{value + File.separator + userId + "体检报告封面页.pdf", value + File.separator + userId + tjNumber + "体检报告项目详情页.pdf", value + File.separator + tjNumber + userId + "附件.pdf"}; |
| | | } else { |
| | | files1 = new String[]{value + "\\" + userId + "体检报告封面页.pdf", value + "\\" + userId + tjNumber + "体检报告项目详情页.pdf"}; |
| | | files1 = new String[]{value + File.separator + userId + "体检报告封面页.pdf", value + File.separator + userId + tjNumber + "体检报告项目详情页.pdf"}; |
| | | } |
| | | } |
| | | //合并 |
| | | // String[] files1 = {value + "\\" + userId + "体检报告封面页.pdf", value + "\\" + userId + tjNumber+"体检报告项目详情页.pdf", value + "\\" +tjNumber+ userId + "附件.pdf", value + "\\" + tjNumber + userId + "心电图.pdf"}; |
| | | String outputPath1 = value + "\\"; |
| | | // String[] files1 = {value + File.separator + userId + "体检报告封面页.pdf", value + File.separator + userId + tjNumber+"体检报告项目详情页.pdf", value + File.separator +tjNumber+ userId + "附件.pdf", value + File.separator + tjNumber + userId + "心电图.pdf"}; |
| | | String outputPath1 = value + File.separator; |
| | | String outputFileName1 = userId + tjNumber + tjCustomer.getCusName() + "_体检报告.pdf"; |
| | | |
| | | File file1 = new File(outputPath1 + outputFileName1); |
| | |
| | | tjReport.setPrint("pdf"); |
| | | tjReportService.save(tjReport); |
| | | |
| | | //FileUtil.del(value + "\\" + tjNumber + "体检报告.pdf"); |
| | | //FileUtil.del(value + "\\" + userId + "体检报告封面模板.pdf"); |
| | | //FileUtil.del(value + "\\" + userId +tjNumber+ "体检报告项目详情页.pdf"); |
| | | //FileUtil.del(value + "\\" + userId + "体检报告封面页.pdf"); |
| | | //FileUtil.del(value + "\\" + userId + "心电图.pdf"); |
| | | //FileUtil.del(value + File.separator + tjNumber + "体检报告.pdf"); |
| | | //FileUtil.del(value + File.separator + userId + "体检报告封面模板.pdf"); |
| | | //FileUtil.del(value + File.separator + userId +tjNumber+ "体检报告项目详情页.pdf"); |
| | | //FileUtil.del(value + File.separator + userId + "体检报告封面页.pdf"); |
| | | //FileUtil.del(value + File.separator + userId + "心电图.pdf"); |
| | | |
| | | |
| | | //修改order表中的打印报告时间为当前时间 |
| | |
| | | } |
| | | |
| | | String userId = SecurityUtils.getLoginUser().getUsername(); |
| | | PDFBinaryUtil.base64StringToPDF(one.getReport(), FileUtil.mkdir(value).getPath() + "\\" + userId + tjNumber + tjCustomer.getCusName() + "_体检报告.pdf"); |
| | | PDFBinaryUtil.base64StringToPDF(one.getReport(), FileUtil.mkdir(value).getPath() + File.separator + userId + tjNumber + tjCustomer.getCusName() + "_体检报告.pdf"); |
| | | //String filePath = one.getPath(); |
| | | String filePath = value + "\\" + userId + tjNumber + tjCustomer.getCusName() + "_体检报告.pdf"; |
| | | String filePath = value + File.separator + userId + tjNumber + tjCustomer.getCusName() + "_体检报告.pdf"; |
| | | File f = new File(filePath); |
| | | if (filePath.isEmpty()) { |
| | | System.out.println("文件不存在!"); |
| | |
| | | } else { |
| | | one.setStatus(TjConstants.TJ_CONFIRM); |
| | | } |
| | | one.setReportTime(null); |
| | | one.setCheckTime(null); |
| | | //将状态改为未审核 |
| | | // UpdateWrapper updateWrapper=new UpdateWrapper(); |
| | | // updateWrapper.eq("tj_number",tjNumber); |