ltkj-admin/src/main/java/com/ltkj/web/controller/his/HisPDFUtil.java
@@ -1476,9 +1476,11 @@ paragraph.setAlignment(Element.ALIGN_LEFT); document2.add(paragraph); String str = " "; List<Map<String, Object>> maps = tjRulesService.getyichangxiangmujianyiguize(i.get(5), "", i.get(2), tjOrder.getTjNumber(), i.get(0).replaceAll("[((][^))]*[))]", "") .replaceAll("[ 测定检测]", ""), i.get(1)); List<Map<String, Object>> maps = tjRulesService.getyichangxiangmujianyiguize(i.get(5), i.get(0).replaceAll("[((][^))]*[))]", "") .replaceAll("[ 测定检测]", "").replaceAll("\\[.*?\\]", ""), i.get(2), tjOrder.getTjNumber(), i.get(0).replaceAll("[((][^))]*[\u4e00-\u9fa5]+[^))]*[))]", "") .replaceAll("[ 测定检测]", "").replaceAll("\\[.*?\\]", ""), i.get(1)); if (!maps.isEmpty()) { for (Map<String, Object> objectMap : maps) { Object bt = objectMap.get("bt"); ltkj-admin/src/main/java/com/ltkj/web/controller/service/TjSysAsyncServiceImpl.java
@@ -618,11 +618,13 @@ if(null !=ycxm){ ycxm.setJcjg(detail.getProResult()); List<Map<String,Object>> maps= rulesService.getyichangxiangmujianyiguize(detail.getProId().toString() ,"","",order.getTjNumber() ,detail.getProName().replaceAll("[((][^))]*[))]", "") .replaceAll("[ 测定检测]","") .replaceAll("[ 测定检测]","").replaceAll("\\[.*?\\]", ""),"",order.getTjNumber() ,detail.getProName().replaceAll("[((][^))]*[\u4e00-\u9fa5]+[^))]*[))]", "") .replaceAll("[ 测定检测]","").replaceAll("\\[.*?\\]", "") ,detail.getProResult()); String[] split = detail.getProResult().split("。|,|,"); List<Map<String,Object>> mapList=new ArrayList<>(); for (String s : split) { ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjCheckController.java
@@ -1748,13 +1748,17 @@ if(null !=tjOrderDetail.getProId()&& null !=tjOrderDetail.getYcbz()){ if(!tjOrderDetail.getDeptId().equals("2")){ List<Map<String,Object>> maps= rulesService.getyichangxiangmujianyiguize(tjOrderDetail.getProId().toString() ,"",tjOrderDetail.getYcbz().replaceAll(" ", ""),tjNumber ,tjOrderDetail.getProName().replaceAll("[((][^))]*[))]", "") .replaceAll("[ 测定检测]","") .replaceAll("[ 测定检测]","").replaceAll("\\[.*?\\]", ""),tjOrderDetail.getYcbz().replaceAll(" ", ""),tjNumber ,tjOrderDetail.getProName().replaceAll("[((][^))]*[\u4e00-\u9fa5]+[^))]*[))]", "") .replaceAll("[ 测定检测]","").replaceAll("\\[.*?\\]", "") ,tjOrderDetail.getProResult()); if(null !=maps && !maps.isEmpty()){ tjOrderDetail.setAdvices(maps); } }else { String[] split = tjOrderDetail.getProResult().split("。|,|,"); List<Map<String,Object>> mapList=new ArrayList<>(); ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjReportController.java
@@ -1005,7 +1005,6 @@ 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=" @@ -1021,17 +1020,6 @@ 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(); @@ -1073,13 +1061,9 @@ 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; ltkj-admin/src/test/java/zjhTest.java
@@ -129,9 +129,10 @@ // BigDecimal multiply = ordPrice.multiply((new BigDecimal("6.5").divide(BigDecimal.valueOf(10)))); // System.out.println(multiply); String a="抗甲状腺球蛋白抗体(TGAb)检测,1111,2222。33333:555555:666666"; String[] split = a.split(",|,|。|:|:"); System.out.println(split); String a="白细胞(陕HR)(WBC)"; String s = a.replaceAll("[((][^))]*[\u4e00-\u9fa5]+[^))]*[))]", "") .replaceAll("[ 测定检测]", ""); System.out.println(s); } ltkj-hosp/src/main/java/com/ltkj/hosp/service/impl/TjReportServiceImpl.java
@@ -2,6 +2,7 @@ import java.io.*; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.*; import java.util.List; @@ -26,6 +27,7 @@ import com.ltkj.common.utils.pdfutils.MyHeaderFooter; import com.ltkj.common.utils.pdfutils.PDFBinaryUtil; import com.ltkj.common.utils.pdfutils.PdfUtils; import com.ltkj.db.DataSourceContextHolder; import com.ltkj.hosp.domain.*; import com.ltkj.hosp.service.*; import com.ltkj.mall.mallOrderUtils.TjConstants; @@ -75,7 +77,8 @@ private ITjOrderRemarkService tjOrderRemarkService; @Resource private ITjStandardService tjStandardService; @Autowired private ITjReportPrintService printService; /** * 查询体检报告存储 * @@ -529,39 +532,62 @@ * @return */ private AjaxResult sqlGetReportToMake(List<String> tjNumbers) { LambdaQueryWrapper<TjReport> tjReportLambdaQueryWrapper = new LambdaQueryWrapper<>(); tjReportLambdaQueryWrapper.in(TjReport::getTjNumber, tjNumbers); List<TjReport> list = tjReportService.list(tjReportLambdaQueryWrapper); // LambdaQueryWrapper<TjReport> tjReportLambdaQueryWrapper = new LambdaQueryWrapper<>(); // tjReportLambdaQueryWrapper.in(TjReport::getTjNumber, tjNumbers); // List<TjReport> list = tjReportService.list(tjReportLambdaQueryWrapper); ArrayList<String> base64Pdfs = new ArrayList<>(); for (TjReport report : list) { if (report == null || report.getReport() == null) { // 没有该报告 直接跳过 continue; // for (TjReport report : list) { // if (report == null || report.getReport() == null) { // // 没有该报告 直接跳过 // continue; // } // base64Pdfs.add(report.getReport()); // } String key = DataSourceContextHolder.getDataSourceKey(); key = key.replace("ltkjpeis10_",""); if(null !=tjNumbers && !tjNumbers.isEmpty()){ for (String number : tjNumbers) { TjOrder order = tjOrderService.getOrderByTjNum(number); TjCustomer tjCustomer = tjCustomerService.getById( order.getUserId()); String filePath = value + File.separator + key + File.separator + tjCustomer.getCusId() + order.getTjNumber() + tjCustomer.getCusName() + "_报告.pdf"; try { // 读取文件为字节数组 Path path = Paths.get(filePath); byte[] fileBytes = Files.readAllBytes(path); // 将字节数组转换为 Base64 字符串 String base64String = Base64.getEncoder().encodeToString(fileBytes); base64Pdfs.add(base64String); // 输出 Base64 编码的字符串 // System.out.println(base64String); TjReportPrint print=new TjReportPrint(); print.setTjNumber(order.getTjNumber()); print.setPrintBy(SecurityUtils.getLoginUser().getUser().getNickName()); print.setPrintTime(new Date()); print.setPrintStatus("已打印"); if (printService.save(print)) { order.setPrintLastTime(new Date()); order.setStatus(TjConstants.TJ_END); tjOrderService.updateById(order); } } catch (IOException e) { e.printStackTrace(); log.error(String.valueOf(e)); } } base64Pdfs.add(report.getReport()); try { byte[] mergePDF = PDFDocumentUtil.mergePDFs(base64Pdfs); String s = Base64.getEncoder().encodeToString(mergePDF); return AjaxResult.success().put("file",s); } catch (DocumentException | IOException e) { e.printStackTrace(); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); return AjaxResult.error("批量生成失败"); } } tjNumbers.forEach(tjNumber ->{ LambdaUpdateWrapper<TjOrder> updateWrapper = new LambdaUpdateWrapper<>(); updateWrapper.eq(TjOrder::getTjNumber, tjNumber); updateWrapper.set(TjOrder::getPrintLastTime, new Date()); updateWrapper.set(TjOrder::getDownloadLastTime, new Date()); updateWrapper.set(TjOrder::getStatus, TjConstants.TJ_END); tjOrderService.update(updateWrapper); }); try { byte[] mergePDF = PDFDocumentUtil.mergePDFs(base64Pdfs); String s = Base64.getEncoder().encodeToString(mergePDF); return AjaxResult.success().put("file",s); // 本地生成测试 // String PDF_FILE = "d:\\Users\\w\\Desktop\\test.pdf"; // BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(PDF_FILE)); // outputStream.write(mergePDF); // outputStream.flush(); // outputStream.close(); } catch (DocumentException | IOException e) { e.printStackTrace(); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); return AjaxResult.error("批量生成失败"); } return AjaxResult.error("批量生成失败"); } }