| | |
| | | @Autowired |
| | | private ISysDictDataService sysDictDataService; |
| | | |
| | | private Integer pdfPage = 0; |
| | | |
| | | private static final int DEFAULT_FONT_SIZE = 10; |
| | | private static final int DEFAULT_TITLE_FONT_SIZE = 12; |
| | | |
| | | private List<Map<String, Object>> makePDFInfo(HashMap<String, Object> map, AjaxResult ajaxResult, String key) { |
| | | List<Map<String, Object>> data = null; |
| | | if (Integer.parseInt(ajaxResult.get("code").toString()) == 200) { |
| | |
| | | } |
| | | } |
| | | if (StrUtil.isBlank(sex)) sex = "未知"; |
| | | pdfWriter.setPageEvent(new FooterHeaderPageEvent("澄合矿务局中心医院",customer.getCusName(),tjOrder.getTjNumber(),sex,String.valueOf(DateUtil.ageOfNow(customer.getCusBrithday())))); |
| | | pdfWriter.setPageEvent(new FooterHeaderPageEvent("澄合矿务局中心医院",customer.getCusName(),tjOrder.getTjNumber(),sex,String.valueOf(DateUtil.ageOfNow(customer.getCusBrithday())),null)); |
| | | pageSize = pdfWriter.getPageNumber(); |
| | | } |
| | | } catch (DocumentException e) { |
| | |
| | | try { |
| | | notHuaYanTable(document1, printReport,dictHosp,color); |
| | | } catch (DocumentException e) { |
| | | log.error("非化验项目填充表格异常"); |
| | | log.error("pacs项目填充表格异常"); |
| | | log.error(String.valueOf(e)); |
| | | return AjaxResult.error(); |
| | | } |
| | |
| | | // 组装检验数据 |
| | | makeHisJianYanTable(document1, map,dictHosp,color); |
| | | } |
| | | |
| | | |
| | | List<ByteArrayOutputStream> jianchas = makeHisJianChaTable(tjOrder); |
| | | // List<ByteArrayOutputStream> jianchas = makeCcgcHisJianChaTable(tjOrder); |
| | | document1.close(); |
| | | |
| | | PdfReader reader = null; |
| | | try { |
| | | reader = new PdfReader(byteArrayOutputStream1.toByteArray()); |
| | | int numberOfPages1 = reader.getNumberOfPages(); |
| | | for (int i = 1; i <= numberOfPages1; i++) { |
| | | PdfImportedPage page = copy.getImportedPage(reader, i); |
| | | copy.addPage(page); |
| | | } |
| | | for (ByteArrayOutputStream jiancha : jianchas) { |
| | | reader = new PdfReader(jiancha.toByteArray()); |
| | | numberOfPages1 = reader.getNumberOfPages(); |
| | | for (int i = 1; i <= numberOfPages1; i++) { |
| | | PdfImportedPage page = copy.getImportedPage(reader, i); |
| | | copy.addPage(page); |
| | | } |
| | | jiancha.close(); |
| | | } |
| | | reader.close(); |
| | | byteArrayOutputStream1.close(); |
| | | document.close(); |
| | | copy.close(); |
| | | } catch (IOException e) { |
| | | log.error("拷贝pdf异常"); |
| | | log.error(String.valueOf(e)); |
| | | return AjaxResult.error(); |
| | | reader = new PdfReader(byteArrayOutputStream1.toByteArray()); |
| | | int numberOfPages1 = reader.getNumberOfPages(); |
| | | for (int i = 1; i <= numberOfPages1; i++) { |
| | | PdfImportedPage page = copy.getImportedPage(reader, i); |
| | | copy.addPage(page); |
| | | } |
| | | |
| | | if (!dictHosp.getHospName().equals("澄合矿务局中心医院")){ |
| | | List<ByteArrayOutputStream> jianchas = makeHisJianChaTable(tjOrder); |
| | | // List<ByteArrayOutputStream> jianchas = makeCcgcHisJianChaTable(tjOrder); |
| | | try { |
| | | for (ByteArrayOutputStream jiancha : jianchas) { |
| | | reader = new PdfReader(jiancha.toByteArray()); |
| | | numberOfPages1 = reader.getNumberOfPages(); |
| | | for (int i = 1; i <= numberOfPages1; i++) { |
| | | PdfImportedPage page = copy.getImportedPage(reader, i); |
| | | copy.addPage(page); |
| | | } |
| | | jiancha.close(); |
| | | } |
| | | } catch (IOException e) { |
| | | log.error("拷贝pdf异常"); |
| | | log.error(String.valueOf(e)); |
| | | return AjaxResult.error(); |
| | | } |
| | | } |
| | | reader.close(); |
| | | byteArrayOutputStream1.close(); |
| | | document.close(); |
| | | copy.close(); |
| | | |
| | | String outputFileName1 = customer.getCusId() + tjOrder.getTjNumber() + customer.getCusName() + "_报告.pdf"; |
| | | try { |
| | | PdfReader pdfReader = new PdfReader(finalOutPut.toByteArray()); |
| | |
| | | } |
| | | |
| | | public AjaxResult hisPDFNew(TjOrder tjOrder, TjCustomer customer, TjReportTemplate tjReportTemplate) throws Exception { |
| | | pdfPage = 0; |
| | | DictHosp dictHosp = dictHospService.list().get(0); |
| | | String color = sysConfigService.selectConfigByKey("report_title_color"); |
| | | List<SysDictData> sysUserSex = sysDictDataService.list(new LambdaQueryWrapper<SysDictData>().eq(SysDictData::getDictType, "sys_user_sex")); |
| | | // 检验数据 |
| | | HashMap<String, Object> map = makeHisJianYan(tjOrder, customer); |
| | | String sex = ""; |
| | | if (customer.getCusSex() != null) { |
| | | for (SysDictData userSex : sysUserSex) { |
| | | if (userSex.getDictValue().equals(String.valueOf(customer.getCusSex()))) { |
| | | sex = userSex.getDictLabel(); |
| | | } |
| | | } |
| | | } |
| | | if (StrUtil.isBlank(sex)) sex = "未知"; |
| | | |
| | | |
| | | |
| | | // 生成 document2 并将其内容保存到 byteArrayOutputStream2 中 |
| | | ByteArrayOutputStream byteArrayOutputStream2 = new ByteArrayOutputStream(); |
| | | Document document2 = new Document(PageSize.A4); |
| | | PdfWriter writer2 = PdfWriter.getInstance(document2, byteArrayOutputStream2); |
| | | |
| | | writer2.setPageEvent(new FooterHeaderPageEvent(dictHosp.getHospName(), customer.getCusName(), tjOrder.getTjNumber(), sex, String.valueOf(DateUtil.ageOfNow(customer.getCusBrithday())),0)); |
| | | |
| | | document2.setMargins(50, 70, 40, 40); |
| | | document2.open(); |
| | | |
| | | List<CsProVo> list = tjOrderRemarkService.cSWebGetProByTjNumAndOrderId(tjOrder.getTjNumber(), false); |
| | | |
| | | Font defaultFont = PdfUtils.setFont(DEFAULT_FONT_SIZE); |
| | | Font defaultTitleFont = PdfUtils.setFont(DEFAULT_FONT_SIZE); |
| | | defaultTitleFont.setStyle(Font.BOLD); |
| | | Paragraph paragraph = PdfUtils.setParagraph(defaultTitleFont, "检查科室与检查项目"); |
| | | document2.add(paragraph); |
| | | |
| | | PdfPTable table = new PdfPTable(new float[]{80, 100, 80, 80}); |
| | | table.setTotalWidth(PageSize.A4.getWidth() - 100); |
| | | table.setLockedWidth(true); |
| | | table.setHorizontalAlignment(Element.ALIGN_LEFT); |
| | | String[] titles = {"科室", "体检项目", "检查状态", "检查时间"}; |
| | | |
| | | for (String head : titles) { |
| | | table.addCell(PdfUtils.createCell(head, defaultFont, Rectangle.BOX, Element.ALIGN_CENTER,5f,5f)); |
| | | } |
| | | Map<String, List<CsProVo>> listMap = list.stream().collect(Collectors.groupingBy(CsProVo::getDeptName)); |
| | | for (Map.Entry<String, List<CsProVo>> entry : listMap.entrySet()) { |
| | | String dept = entry.getKey(); |
| | | List<CsProVo> proVos = entry.getValue(); |
| | | PdfPCell deptCell = new PdfPCell(); |
| | | deptCell.setVerticalAlignment(Element.ALIGN_MIDDLE); |
| | | deptCell.setHorizontalAlignment(Element.ALIGN_CENTER); |
| | | deptCell.setPhrase(new Phrase(dept, defaultFont)); |
| | | deptCell.setPaddingTop(5f); |
| | | deptCell.setPaddingBottom(5f); |
| | | deptCell.setRowspan(proVos.size()); |
| | | table.addCell(deptCell); |
| | | proVos.forEach(proVo -> { |
| | | table.addCell(PdfUtils.createCell(proVo.getProName(), defaultFont,Rectangle.BOX,Element.ALIGN_CENTER,5f,5f)); |
| | | String tjType = ""; |
| | | switch (proVo.getType()) { |
| | | case 0: |
| | | tjType = "未检"; |
| | | break; |
| | | case 1: |
| | | tjType = "已检"; |
| | | break; |
| | | case 2: |
| | | tjType = "弃检"; |
| | | break; |
| | | case 3: |
| | | tjType = "延期"; |
| | | break; |
| | | } |
| | | table.addCell(PdfUtils.createCell(tjType, defaultFont,Rectangle.BOX,Element.ALIGN_CENTER,5f,5f)); |
| | | String tjTime = ""; |
| | | if (proVo.getQdcreateTime() != null) { |
| | | tjTime = new SimpleDateFormat("yyyy-MM-dd").format(proVo.getQdcreateTime()); |
| | | } |
| | | table.addCell(PdfUtils.createCell(tjTime, defaultFont,Rectangle.BOX,Element.ALIGN_CENTER,5f,5f)); |
| | | }); |
| | | } |
| | | document2.add(table); |
| | | |
| | | for (int i = 0; i < 2; i++) { |
| | | paragraph = PdfUtils.setParagraph(defaultFont, ""); |
| | | document2.add(paragraph); |
| | | } |
| | | |
| | | paragraph = PdfUtils.setParagraph(defaultTitleFont, "体检异常项目与分析"); |
| | | document2.add(paragraph); |
| | | for (Map.Entry<String, Object> item : map.entrySet()) { |
| | | String xmmc = item.getKey(); |
| | | HashMap<String, Object> entryValue = (HashMap<String, Object>) item.getValue(); |
| | | ArrayList<List<String>> lists = (ArrayList<List<String>>) entryValue.get("data"); |
| | | boolean isXmWrite = false; |
| | | int index = 1; |
| | | for (List<String> i : lists) { |
| | | if (i.contains("↓") || i.contains("↑")) { |
| | | if (!isXmWrite) { |
| | | paragraph = new Paragraph(xmmc,defaultFont); |
| | | paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | document2.add(paragraph); |
| | | isXmWrite = true; |
| | | } |
| | | String content = " ("+index + ") " + i.get(0) + ":" + i.get(1) + " " + i.get(3) + " " + i.get(4); |
| | | paragraph = new Paragraph(content,defaultFont); |
| | | paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | document2.add(paragraph); |
| | | index++; |
| | | } |
| | | } |
| | | paragraph = PdfUtils.setParagraph(defaultFont, ""); |
| | | document2.add(paragraph); |
| | | } |
| | | |
| | | for (int i = 0; i < 2; i++) { |
| | | paragraph = PdfUtils.setParagraph(defaultFont, ""); |
| | | document2.add(paragraph); |
| | | } |
| | | |
| | | paragraph = PdfUtils.setParagraph(defaultTitleFont, "医生建议:"); |
| | | document2.add(paragraph); |
| | | if (tjOrder.getCheckAdvice() == null) { |
| | | paragraph = PdfUtils.setParagraph(defaultFont, "无"); |
| | | document2.add(paragraph); |
| | | } else { |
| | | paragraph = PdfUtils.setParagraph(defaultFont, tjOrder.getCheckAdvice()); |
| | | document2.add(paragraph); |
| | | } |
| | | document2.close(); |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); |
| | | Document document = new Document(PageSize.A4); |
| | | PdfWriter pdfWriter = null; |
| | | int pageSize = 0; |
| | | try { |
| | | // int pageSize = 0; |
| | | // try { |
| | | pdfWriter = PdfWriter.getInstance(document, byteArrayOutputStream); |
| | | String sex = ""; |
| | | if (customer.getCusSex() != null) { |
| | | for (SysDictData userSex : sysUserSex) { |
| | | if (userSex.getDictValue().equals(String.valueOf(customer.getCusSex()))) { |
| | | sex = userSex.getDictLabel(); |
| | | } |
| | | } |
| | | } |
| | | if (StrUtil.isBlank(sex)) sex = "未知"; |
| | | pdfWriter.setPageEvent(new FooterHeaderPageEvent(dictHosp.getHospName(),customer.getCusName(),tjOrder.getTjNumber(),sex,String.valueOf(DateUtil.ageOfNow(customer.getCusBrithday())))); |
| | | pageSize = pdfWriter.getPageNumber(); |
| | | } catch (DocumentException e) { |
| | | log.error(String.valueOf(e)); |
| | | return AjaxResult.error(); |
| | | } |
| | | pdfWriter.setPageEvent(new FooterHeaderPageEvent(dictHosp.getHospName(), customer.getCusName(), tjOrder.getTjNumber(), sex, String.valueOf(DateUtil.ageOfNow(customer.getCusBrithday())),null)); |
| | | // pageSize = pdfWriter.getPageNumber(); |
| | | // } catch (DocumentException e) { |
| | | // log.error(String.valueOf(e)); |
| | | // return AjaxResult.error(); |
| | | // } |
| | | // 后面页码数量 |
| | | int dataPageNumer = pdfWriter.getPageNumber(); |
| | | document.setMargins(70, 70, 40, 40); |
| | | document.open(); |
| | | |
| | | Map<TjOrderRemark, List<TjPdfVO>> printReport = new HashMap<>(); |
| | | notHuaYanData(tjOrder.getTjNumber(), printReport, tjOrder, customer); |
| | | try { |
| | | notHuaYanTable(document, printReport,dictHosp,color); |
| | | notHuaYanTable(document, printReport, dictHosp, color); |
| | | } catch (DocumentException e) { |
| | | log.error("非化验项目填充表格异常"); |
| | | log.error(String.valueOf(e)); |
| | | return AjaxResult.error(); |
| | | } |
| | | PdfReader reader = null; |
| | | makeHisJianYanTable(document, map, dictHosp, color); |
| | | |
| | | // 检验数据 |
| | | HashMap<String, Object> map = makeHisJianYan(tjOrder, customer); |
| | | makeHisJianYanTable(document, map,dictHosp,color); |
| | | List<ByteArrayOutputStream> jianchas = makeHisJianChaTable(tjOrder); |
| | | document.close(); |
| | | |
| | | Document document1 = new Document(PageSize.A4); |
| | | ByteArrayOutputStream finalOutPut = new ByteArrayOutputStream(); |
| | | PdfCopy copy = new PdfCopy(document1, finalOutPut); |
| | | byte[] bytes = byteArrayOutputStream.toByteArray(); |
| | | document1.open(); |
| | | reader = new PdfReader(bytes); |
| | | |
| | | int numberOfPages = reader.getNumberOfPages(); |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | printReport = new HashMap<>(); |
| | | pacsJianChaData(tjOrder.getTjNumber(), printReport, tjOrder, customer); |
| | | try { |
| | | reader = new PdfReader(byteArrayOutputStream.toByteArray()); |
| | | int numberOfPages1 = reader.getNumberOfPages(); |
| | | for (int i = 1; i <= numberOfPages1; i++) { |
| | | PdfImportedPage page = copy.getImportedPage(reader, i); |
| | | copy.addPage(page); |
| | | } |
| | | for (ByteArrayOutputStream jiancha : jianchas) { |
| | | reader = new PdfReader(jiancha.toByteArray()); |
| | | numberOfPages1 = reader.getNumberOfPages(); |
| | | for (int i = 1; i <= numberOfPages1; i++) { |
| | | PdfImportedPage page = copy.getImportedPage(reader, i); |
| | | copy.addPage(page); |
| | | } |
| | | jiancha.close(); |
| | | } |
| | | reader.close(); |
| | | byteArrayOutputStream.close(); |
| | | document.close(); |
| | | copy.close(); |
| | | } catch (IOException e) { |
| | | log.error("拷贝pdf异常"); |
| | | notHuaYanTable(document, printReport, dictHosp, color); |
| | | } catch (DocumentException e) { |
| | | log.error("pacs项目填充表格异常"); |
| | | log.error(String.valueOf(e)); |
| | | return AjaxResult.error(); |
| | | } |
| | | document.close(); |
| | | |
| | | |
| | | |
| | | |
| | | /* |
| | | * 第二页检查状态信息 检查科室与检查项目 |
| | | * <span v-if="scope.row.type == '0'">未检</span> |
| | | * <span v-if="scope.row.type == '1'">已检</span> |
| | | * <span v-if="scope.row.type == '2'">弃检</span> |
| | | * <span v-if="scope.row.type == '3'">延期</span> |
| | | * */ |
| | | List<CsProVo> list = tjOrderRemarkService.cSWebGetProByTjNumAndOrderId(tjOrder.getTjNumber(),false); |
| | | |
| | | // 首页表单 |
| | | String tjNumber = tjOrder.getTjNumber(); |
| | | String template = tjReportTemplate.getTemplate(); |
| | | LambdaQueryWrapper<DictComp> wq111 = new LambdaQueryWrapper<>(); |
| | | wq111.eq(DictComp::getDrugManufacturerId, tjOrder.getFirmId()); |
| | | DictComp dictComp = dictCompService.getOne(wq111); |
| | | LambdaQueryWrapper<TjOrderDetail> wq2 = new LambdaQueryWrapper<>(); |
| | | wq2.eq(TjOrderDetail::getOrderId, tjOrder.getOrderId()); |
| | | wq2.isNotNull(TjOrderDetail::getFlowingWaterId); |
| | | List<TjOrderDetail> detailList = tjOrderDetailService.list(wq2); |
| | | for (TjOrderDetail tjOrderDetail : detailList) { |
| | | TjProject tjProject = projectService.selectTjProjectByProId(tjOrderDetail.getProId()); |
| | | tjOrderDetail.setProject(tjProject); |
| | | } |
| | | ByteArrayOutputStream byteArrayOutputStream4 = new ByteArrayOutputStream(); |
| | | PdfReader reader4 = null; |
| | | PdfStamper pdfStamper = null; |
| | | |
| | | reader4 = new PdfReader(new ByteArrayInputStream(Base64.getDecoder().decode(template))); |
| | | pdfStamper = new PdfStamper(reader4, byteArrayOutputStream4); |
| | | AcroFields acroFields = pdfStamper.getAcroFields(); |
| | | BaseFont bf = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); |
| | | acroFields.addSubstitutionFont(bf); |
| | | HashMap<String, Object> data = new HashMap<>(); |
| | | Long cusSex = customer.getCusSex(); |
| | | String tjtype; |
| | | if (cusSex == 0) { |
| | | sex = "男"; |
| | | } else { |
| | | sex = "女"; |
| | | } |
| | | HashMap<String, String> hashMap = new HashMap<>(); |
| | | hashMap.put("name", customer.getCusName()); |
| | | if ("1".equals(tjOrder.getTjType())) { |
| | | tjtype = "团队"; |
| | | hashMap.put("tjtype", tjtype); |
| | | } else { |
| | | tjtype = "个人"; |
| | | hashMap.put("tjtype", tjtype); |
| | | } |
| | | if (dictComp == null) { |
| | | hashMap.put("work", "无"); |
| | | } else { |
| | | hashMap.put("work", dictComp.getCnName()); |
| | | } |
| | | hashMap.put("sex", sex); |
| | | hashMap.put("tjnumber", tjNumber); |
| | | hashMap.put("tjdate", DateUtils.parseDateToStr("yyyy/MM/dd", tjOrder.getCreateTime())); |
| | | hashMap.put("phone", customer.getCusPhone()); |
| | | for (String key : hashMap.keySet()) { |
| | | acroFields.setFieldProperty(key, "textsize", DEFAULT_FONT_SIZE, null); |
| | | acroFields.setField(key, hashMap.get(key)); |
| | | } |
| | | pdfStamper.setFormFlattening(true); |
| | | pdfStamper.close(); |
| | | reader4.close(); |
| | | // 将修改后的PDF内容写入 |
| | | byte[] bytes = byteArrayOutputStream4.toByteArray(); |
| | | |
| | | |
| | | |
| | | ByteArrayOutputStream finalOutput = new ByteArrayOutputStream(); |
| | | Document mergedDocument = new Document(PageSize.A4); |
| | | PdfCopy copy = new PdfCopy(mergedDocument, finalOutput); |
| | | mergedDocument.open(); |
| | | |
| | | reader4 = new PdfReader(new ByteArrayInputStream(bytes)); |
| | | int numberOfPages = reader4.getNumberOfPages(); |
| | | for (int i = 1; i <= numberOfPages; i++) { |
| | | copy.addPage(copy.getImportedPage(reader4, i)); |
| | | } |
| | | |
| | | PdfReader reader2 = new PdfReader(byteArrayOutputStream2.toByteArray()); |
| | | int numberOfPages2 = reader2.getNumberOfPages(); |
| | | for (int i = 1; i <= numberOfPages2; i++) { |
| | | PdfImportedPage page = copy.getImportedPage(reader2, i); |
| | | copy.addPage(page); |
| | | } |
| | | reader2.close(); |
| | | |
| | | PdfReader reader1 = new PdfReader(byteArrayOutputStream.toByteArray()); |
| | | int numberOfPages1 = reader1.getNumberOfPages(); |
| | | for (int i = 1; i <= numberOfPages1; i++) { |
| | | PdfImportedPage page = copy.getImportedPage(reader1, i); |
| | | copy.addPage(page); |
| | | } |
| | | reader1.close(); |
| | | mergedDocument.close(); |
| | | |
| | | String outputFileName1 = customer.getCusId() + tjOrder.getTjNumber() + customer.getCusName() + "_报告.pdf"; |
| | | savePDFFile(outputFileName1, tjOrder, customer, finalOutput); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | |
| | | String shsj = entryValue.get("shsj").toString(); |
| | | addJianYanTable(document1, titleName, titles, titlesWidth, lists,dictHosp,colorStr); |
| | | if (!jyys.isEmpty()) { |
| | | Font doctorFonts = PdfUtils.setFont(11); |
| | | Font doctorFonts = PdfUtils.setFont(DEFAULT_FONT_SIZE); |
| | | String doctors = ""; |
| | | Paragraph elements = new Paragraph(); |
| | | elements.setLeading(5f); |
| | |
| | | LambdaQueryWrapper<TjProject> wqqq = new LambdaQueryWrapper<>(); |
| | | wqqq.eq(TjProject::getProId, entry.getKey().getProId()); |
| | | TjProject one11 = projectService.getOne(wqqq); |
| | | if (entry.getValue().isEmpty()) continue; |
| | | if (entry.getValue() == null || entry.getValue().isEmpty()) continue; |
| | | //判断该项目是否需要打印报告 |
| | | if (null != one11 && "Y".equals(one11.getNeedReport())) { |
| | | TjOrderRemark orderRemark = entry.getKey(); |
| | | List<TjPdfVO> value = entry.getValue(); |
| | | if (StrUtil.isBlank(value.get(0).getProResult()) && (StrUtil.isBlank(value.get(0).getTs()) && StrUtil.isBlank(value.get(0).getSj()))){ |
| | | continue; |
| | | } |
| | | String titleName = null; |
| | | if (null != one11 && "1".equals(one11.getResultType())) { |
| | | if ("1".equals(one11.getResultType())) { |
| | | titleName = one11.getProName(); |
| | | // 设置标题字体样式 |
| | | Font titleFonts = PdfUtils.setFont(9); |
| | | Paragraph paragraph = PdfUtils.setParagraph(titleFonts, titleName); |
| | | |
| | | if (dictHosp.getHospName().equals("澄合矿务局中心医院")) { |
| | | Font titleFont = PdfUtils.setFont(11); |
| | | Font titleFont = PdfUtils.setFont(DEFAULT_TITLE_FONT_SIZE); |
| | | titleFont.setStyle(Font.BOLD); |
| | | PdfPCell cellTitle = new PdfPCell(PdfUtils.setParagraph(titleFont, titleName)); |
| | | cellTitle.setBorder(Rectangle.NO_BORDER); |
| | |
| | | if (dictHosp.getHospName().equals("澄合矿务局中心医院") && !value.isEmpty()){ |
| | | if (value.size()>1){ |
| | | String[] titles = {"体检项目", "体检结果", "单位"}; |
| | | Font headFont = PdfUtils.setFont(9); |
| | | Font textFont = PdfUtils.setFont(9); |
| | | Font headFont = PdfUtils.setFont(DEFAULT_FONT_SIZE); |
| | | Font textFont = PdfUtils.setFont(DEFAULT_FONT_SIZE); |
| | | PdfPTable table = PdfUtils.setTable2(headFont, textFont, titles, value,dictHosp.getHospName().equals("澄合矿务局中心医院")); |
| | | document1.add(table); |
| | | }else { |
| | | Font remarkFonts = PdfUtils.setFont(9); |
| | | Font remarkFonts = PdfUtils.setFont(DEFAULT_FONT_SIZE); |
| | | Paragraph pp = PdfUtils.setParagraph(remarkFonts, "检查所见:"); |
| | | document1.add(pp); |
| | | Paragraph ppp = new Paragraph(value.get(0).getSj(), remarkFonts); |
| | |
| | | } |
| | | }else { |
| | | String[] titles = {"体检项目", "体检结果", "单位"}; |
| | | Font headFont = PdfUtils.setFont(9); |
| | | Font textFont = PdfUtils.setFont(9); |
| | | Font headFont = PdfUtils.setFont(DEFAULT_FONT_SIZE); |
| | | Font textFont = PdfUtils.setFont(DEFAULT_FONT_SIZE); |
| | | PdfPTable table = PdfUtils.setTable2(headFont, textFont, titles, value,dictHosp.getHospName().equals("澄合矿务局中心医院")); |
| | | document1.add(table); |
| | | } |
| | |
| | | int j = 0; |
| | | for (int i = 0; i < remark.length() / 50; i++) { |
| | | String substring = remark.substring(j, j + 50); |
| | | Font remarkFonts = PdfUtils.setFont(9); |
| | | Font remarkFonts = PdfUtils.setFont(DEFAULT_FONT_SIZE); |
| | | Paragraph pp = PdfUtils.setParagraph(remarkFonts, substring); |
| | | document1.add(pp); |
| | | j = j + 50; |
| | | } |
| | | if (remark.length() % 50 != 0) { |
| | | String substring = remark.substring((remark.length() / 50) * 50, remark.length() - 1); |
| | | Font remarkFonts = PdfUtils.setFont(9); |
| | | Font remarkFonts = PdfUtils.setFont(DEFAULT_FONT_SIZE); |
| | | Paragraph pp = PdfUtils.setParagraph(remarkFonts, substring); |
| | | document1.add(pp); |
| | | } |
| | | } else { |
| | | Font remarkFonts = PdfUtils.setFont(9); |
| | | Font remarkFonts = PdfUtils.setFont(DEFAULT_FONT_SIZE); |
| | | Paragraph pp = PdfUtils.setParagraph(remarkFonts, remark); |
| | | document1.add(pp); |
| | | } |
| | |
| | | titleName = entry.getKey().getProName(); |
| | | } |
| | | // 设置标题字体样式 |
| | | Font titleFonts = PdfUtils.setFont(9); |
| | | Font titleFonts = PdfUtils.setFont(DEFAULT_FONT_SIZE); |
| | | Paragraph paragraph = PdfUtils.setParagraph(titleFonts, titleName); |
| | | |
| | | if (dictHosp.getHospName().equals("澄合矿务局中心医院")) { |
| | | Font titleFont = PdfUtils.setFont(11); |
| | | if (StrUtil.isBlank(value.get(0).getProResult()) && (StrUtil.isBlank(value.get(0).getTs()) && StrUtil.isBlank(value.get(0).getSj()))){ |
| | | continue; |
| | | } |
| | | Font titleFont = PdfUtils.setFont(DEFAULT_TITLE_FONT_SIZE); |
| | | titleFont.setStyle(Font.BOLD); |
| | | PdfPCell cellTitle = new PdfPCell(PdfUtils.setParagraph(titleFont, titleName)); |
| | | cellTitle.setBorder(Rectangle.NO_BORDER); |
| | |
| | | // document1.add(table); |
| | | |
| | | if (dictHosp.getHospName().equals("澄合矿务局中心医院") && !value.isEmpty()){ |
| | | System.out.println("value = " + value); |
| | | if (value.size()>1){ |
| | | String[] titles = {"体检项目", "体检结果", "单位"}; |
| | | Font headFont = PdfUtils.setFont(9); |
| | | Font textFont = PdfUtils.setFont(9); |
| | | Font headFont = PdfUtils.setFont(DEFAULT_FONT_SIZE); |
| | | Font textFont = PdfUtils.setFont(DEFAULT_FONT_SIZE); |
| | | PdfPTable table = PdfUtils.setTable2(headFont, textFont, titles, value,dictHosp.getHospName().equals("澄合矿务局中心医院")); |
| | | document1.add(table); |
| | | }else { |
| | | Font remarkFonts = PdfUtils.setFont(9); |
| | | Font remarkFonts = PdfUtils.setFont(DEFAULT_FONT_SIZE); |
| | | Paragraph pp = PdfUtils.setParagraph(remarkFonts, "检查所见:"); |
| | | document1.add(pp); |
| | | Paragraph ppp = new Paragraph(value.get(0).getSj(), remarkFonts); |
| | | Paragraph ppp = new Paragraph(value.get(0).getSj() != null ? value.get(0).getSj() : value.get(0).getProResult(), remarkFonts); |
| | | paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | paragraph.setLeading(5f); |
| | | document1.add(ppp); |
| | | pp = PdfUtils.setParagraph(remarkFonts, "结论:"); |
| | | document1.add(pp); |
| | | ppp = new Paragraph(value.get(0).getTs(), remarkFonts); |
| | | ppp = new Paragraph(value.get(0).getTs() != null ? value.get(0).getTs() : value.get(0).getProResult(), remarkFonts); |
| | | paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | paragraph.setLeading(5f); |
| | | document1.add(ppp); |
| | | } |
| | | }else { |
| | | String[] titles = {"体检项目", "体检结果", "单位"}; |
| | | Font headFont = PdfUtils.setFont(9); |
| | | Font textFont = PdfUtils.setFont(9); |
| | | Font headFont = PdfUtils.setFont(DEFAULT_FONT_SIZE); |
| | | Font textFont = PdfUtils.setFont(DEFAULT_FONT_SIZE); |
| | | PdfPTable table = PdfUtils.setTable(headFont, textFont, titles, value,dictHosp.getHospName().equals("澄合矿务局中心医院")); |
| | | document1.add(table); |
| | | } |
| | |
| | | int j = 0; |
| | | for (int i = 0; i < remark.length() / 50; i++) { |
| | | String substring = remark.substring(j, j + 50); |
| | | Font remarkFonts = PdfUtils.setFont(9); |
| | | Font remarkFonts = PdfUtils.setFont(DEFAULT_FONT_SIZE); |
| | | Paragraph pp = PdfUtils.setParagraph(remarkFonts, substring); |
| | | document1.add(pp); |
| | | j = j + 50; |
| | | } |
| | | if (remark.length() % 50 != 0) { |
| | | String substring = remark.substring((remark.length() / 50) * 50, remark.length() - 1); |
| | | Font remarkFonts = PdfUtils.setFont(9); |
| | | Font remarkFonts = PdfUtils.setFont(DEFAULT_FONT_SIZE); |
| | | Paragraph pp = PdfUtils.setParagraph(remarkFonts, substring); |
| | | document1.add(pp); |
| | | } |
| | | } else { |
| | | Font remarkFonts = PdfUtils.setFont(9); |
| | | Font remarkFonts = PdfUtils.setFont(DEFAULT_FONT_SIZE); |
| | | Paragraph pp = PdfUtils.setParagraph(remarkFonts, remark); |
| | | document1.add(pp); |
| | | } |
| | |
| | | for (Map.Entry<TjOrderRemark, List<TjPdfVO>> entry : printReport.entrySet()) { |
| | | List<TjPdfVO> tjPdfVOS = new ArrayList<>(); |
| | | List<TjOrderDetail> tjOrderDetails = tjOrderDetailService.getDetailByOrderIdAndParId(one.getOrderId(), entry.getKey().getProId()); |
| | | // tjOrderDetails = new ArrayList<>(tjOrderDetails.stream() |
| | | // .filter(i -> StrUtil.isNotBlank(i.getProResult())) |
| | | // .collect(Collectors.toMap( |
| | | // TjOrderDetail::getProId, |
| | | // i -> i, |
| | | // (existing, replacement) -> existing |
| | | // )) |
| | | // .values()); // 获取去重后的 List |
| | | tjOrderDetails = tjOrderDetails.stream().filter(i -> StrUtil.isNotBlank(i.getProResult())).collect(Collectors.toList()); |
| | | System.out.println("tjOrderDetails = " + JSONUtil.toJsonStr(tjOrderDetails)); |
| | | tjOrderDetails = new ArrayList<>(tjOrderDetails.stream().collect(Collectors.toMap(TjOrderDetail::getProId, i -> i, (existing, replacement) -> existing)).values()); // 获取去重后的 List |
| | | System.out.println("tjOrderDetails = " + JSONUtil.toJsonStr(tjOrderDetails)); |
| | | for (TjOrderDetail tjOrderDetail : tjOrderDetails) { |
| | | TjProject tjProject = projectService.getById(tjOrderDetail.getProId()); |
| | | TjProject tjProject = projectService.getById(String.valueOf(tjOrderDetail.getProId())); |
| | | if (null != tjProject && tjProject.getNeedReport().equals("Y")) { |
| | | tjOrderDetail.setProject(tjProject); |
| | | |
| | |
| | | |
| | | private static void addJianYanTable(Document document, String titleName, String[] titles, float[] titlesWidth, ArrayList<List<String>> lists,DictHosp dictHosp,String colorStr) throws DocumentException { |
| | | // 大项标题 |
| | | Font titleFont = PdfUtils.setFont(10); |
| | | Font titleFont = PdfUtils.setFont(DEFAULT_TITLE_FONT_SIZE); |
| | | if (dictHosp.getHospName().equals("澄合矿务局中心医院")) { |
| | | titleFont.setSize(11); |
| | | titleFont.setSize(DEFAULT_TITLE_FONT_SIZE); |
| | | titleFont.setStyle(Font.BOLD); |
| | | } |
| | | Paragraph paragraph = new Paragraph(titleName, titleFont); |
| | |
| | | document.add(paragraph); |
| | | } |
| | | // 创建一个表格并添加到文档 |
| | | Font headFont = PdfUtils.setFont(10); |
| | | Font textFont = PdfUtils.setFont(10); |
| | | Font headFont = PdfUtils.setFont(DEFAULT_FONT_SIZE); |
| | | Font textFont = PdfUtils.setFont(DEFAULT_FONT_SIZE); |
| | | PdfPTable table = new PdfPTable(titlesWidth); |
| | | table.setTotalWidth(PageSize.A4.getWidth() - 10); // 设置表格总宽度 |
| | | //table.setLockedWidth(true); // 锁定表格宽度 |
| | |
| | | |
| | | for (List<String> list : lists) { |
| | | boolean isYc = false; |
| | | textFont = PdfUtils.setFont(10); |
| | | textFont = PdfUtils.setFont(DEFAULT_FONT_SIZE); |
| | | if (dictHosp.getHospName().equals("澄合矿务局中心医院")){ |
| | | if (list.contains("↓") || list.contains("↑")){ |
| | | isYc = true; |
| | |
| | | } |
| | | |
| | | // 自定义页脚和页眉的绘制 |
| | | static class FooterHeaderPageEvent extends PdfPageEventHelper { |
| | | class FooterHeaderPageEvent extends PdfPageEventHelper { |
| | | |
| | | private String name; // 页眉的名字 |
| | | private String tjName; |
| | | private String tjNumber; |
| | | private String sex; |
| | | private String age; |
| | | private Integer page; |
| | | |
| | | public FooterHeaderPageEvent(String name,String tjName,String tjNumber,String sex,String age) { |
| | | public FooterHeaderPageEvent(String name,String tjName,String tjNumber,String sex,String age,Integer page) { |
| | | this.name = name; |
| | | this.tjNumber = tjNumber; |
| | | this.tjName = tjName; |
| | | this.sex = sex; |
| | | this.age = age; |
| | | this.page = page; |
| | | } |
| | | |
| | | // 在每一页的顶部绘制页眉 |
| | |
| | | footerTable.addCell(hospitalNameCell); |
| | | |
| | | // 创建页码的单元格:右对齐 |
| | | // String pageText = "第 " + writer.getPageNumber() + 1 + " 页,共 " + writer.getPageNumber() + " 页"; // 页码 |
| | | String pageText = "第 " + (writer.getPageNumber() + 1) + " 页"; // 页码 |
| | | String pageText; |
| | | // if (page != null) pageText = "第 " + writer.getPageNumber() + 1 + " 页,共 " + page + " 页"; // 页码 |
| | | // else pageText = "第 " + (writer.getPageNumber() + 1) + " 页"; // 页码 |
| | | |
| | | // if (page == null) { |
| | | // pageText = "第 " + (writer.getPageNumber() + 1) + " 页"; // 页码 |
| | | // } else { |
| | | // pageText = "第 " + (page + 1) + " 页"; // 页码 |
| | | // } |
| | | pageText = "第 " + (++pdfPage) + " 页"; |
| | | PdfPCell pageCell = new PdfPCell(new Phrase(pageText, PdfUtils.setFont(8))); |
| | | pageCell.setHorizontalAlignment(Element.ALIGN_RIGHT); // 右对齐 |
| | | pageCell.setVerticalAlignment(Element.ALIGN_TOP); // 垂直对齐到底部 |