From d12e3914e9e823a3038335a8f9e0b525343d965b Mon Sep 17 00:00:00 2001
From: zjh <1084500556@qq.com>
Date: 星期五, 04 七月 2025 17:39:38 +0800
Subject: [PATCH] zjh20250704

---
 ltkj-admin/src/main/java/com/ltkj/web/controller/his/HisPDFUtil.java |  204 +++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 196 insertions(+), 8 deletions(-)

diff --git a/ltkj-admin/src/main/java/com/ltkj/web/controller/his/HisPDFUtil.java b/ltkj-admin/src/main/java/com/ltkj/web/controller/his/HisPDFUtil.java
index a7c993f..2a1b6e5 100644
--- a/ltkj-admin/src/main/java/com/ltkj/web/controller/his/HisPDFUtil.java
+++ b/ltkj-admin/src/main/java/com/ltkj/web/controller/his/HisPDFUtil.java
@@ -1337,9 +1337,11 @@
            makeHisJianYanTable(document, map, dictHosp, color);
 
            printReport = new HashMap<>();
-           pacsJianChaData(tjOrder.getTjNumber(), printReport, tjOrder, customer);
+//           pacsJianChaData(tjOrder.getTjNumber(), printReport, tjOrder, customer);
+           newpacsJianChaData(tjOrder.getTjNumber(), printReport, tjOrder, customer);
            try {
-               notHuaYanTable(document, printReport, dictHosp, color, true);
+//               notHuaYanTable(document, printReport, dictHosp, color, true);
+               pacsTable(document, printReport, dictHosp, color, true);
            } catch (DocumentException e) {
                log.error("pacs椤圭洰濉厖琛ㄦ牸寮傚父");
                log.error(String.valueOf(e));
@@ -2118,6 +2120,158 @@
         }
     }
 
+
+    private void pacsTable(Document document1, Map<TjOrderRemark, List<TjPdfVO>> printReport, DictHosp dictHosp, String colorStr, boolean isPacs)throws DocumentException{
+        try {
+            List<TjReportSpecialProject> tjReportSpecialProjects = tjReportSpecialProjectService.list();
+            for (Map.Entry<TjOrderRemark, List<TjPdfVO>> entry : printReport.entrySet()) {
+
+                if (entry.getValue() == null || entry.getValue().isEmpty()) continue;
+                //鍒ゆ柇璇ラ」鐩槸鍚﹂渶瑕佹墦鍗版姤鍛�
+
+                    TjOrderRemark orderRemark = entry.getKey();
+                    List<TjPdfVO> value = entry.getValue().stream().distinct().collect(Collectors.toList());
+                    if (StrUtil.isBlank(value.get(0).getProResult()) && (StrUtil.isBlank(value.get(0).getTs()) && StrUtil.isBlank(value.get(0).getSj()))) {
+                        continue;
+                    }
+                    String titleName = null;
+
+                        if (entry.getValue().get(0).getProName().contains(";"))
+                            titleName = entry.getValue().get(0).getProName();
+                        else titleName = orderRemark.getProName();
+                        // 璁剧疆鏍囬瀛椾綋鏍峰紡
+                        Font titleFonts = PdfUtils.setFont(DEFAULT_FONT_SIZE);
+                        Paragraph paragraph = PdfUtils.setParagraph(titleFonts, titleName);
+
+                        if (StrUtil.isBlank(value.get(0).getProResult()) && (StrUtil.isBlank(value.get(0).getTs().replaceAll("\n",""))
+                                && StrUtil.isBlank(value.get(0).getSj().replaceAll("\n","")))) {
+                            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);
+                        Color color = Color.decode("#B4CDCD");
+                        cellTitle.setBackgroundColor(new BaseColor(color.getRed(), color.getGreen(), color.getBlue())); // 璁剧疆鑳屾櫙棰滆壊锛堝崄鍏繘鍒� RGB锛�
+                        // 鍒涘缓琛ㄦ牸骞舵坊鍔犲崟鍏冩牸
+                        PdfPTable tableTitle = new PdfPTable(1);
+                        tableTitle.setWidthPercentage(100);
+                        tableTitle.addCell(cellTitle);
+                        // 灏嗚〃鏍兼坊鍔犲埌鏂囨。涓�
+                        document1.add(tableTitle);
+
+                        if (!value.isEmpty()) {
+                            if (value.size() > 1) {
+                                Long pid = Long.valueOf(value.get(0).getPid());
+                                Optional<TjReportSpecialProject> match = tjReportSpecialProjects.stream()
+                                        .filter(item -> item.getProId().equals(pid))
+                                        .findFirst();
+                                if (match.isPresent()) {
+                                    reportSpecialProject(document1, entry, paragraph, value,match.get());
+                                } else {
+                                    String[] titles = {"浣撴椤圭洰", "浣撴缁撴灉", "鍗曚綅"};
+                                    Font headFont = PdfUtils.setFont(DEFAULT_FONT_SIZE);
+                                    Font textFont = PdfUtils.setFont(DEFAULT_FONT_SIZE);
+                                    PdfPTable table = PdfUtils.setTable2(headFont, textFont, titles, value, isPacs, new float[]{240, 240, 240});
+                                    document1.add(table);
+                                }
+
+                            } else {
+                                Font remarkFonts = PdfUtils.setFont(DEFAULT_FONT_SIZE);
+
+                                if (isPacs) {
+                                    Paragraph pp;
+                                    Paragraph ppp;
+
+                                    if (StrUtil.isNotBlank(value.get(0).getSj()) || StrUtil.isNotBlank(value.get(0).getProResult())) {
+                                        pp = PdfUtils.setParagraph(remarkFonts, "妫�鏌ユ墍瑙侊細");
+                                        document1.add(pp);
+                                        ppp = new Paragraph(value.get(0).getSj() != null ? value.get(0).getSj().replaceAll("\n","") : value.get(0).getProResult().replaceAll("\n",""), 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() != null ? value.get(0).getTs().replaceAll("\n","") : value.get(0).getProResult().replaceAll("\n","")), remarkFonts);
+                                    paragraph.setAlignment(Element.ALIGN_LEFT);
+                                    paragraph.setLeading(5f);
+                                    document1.add(ppp);
+
+                                } else {
+                                    Long pid = Long.valueOf(value.get(0).getPid());
+                                    Optional<TjReportSpecialProject> match = tjReportSpecialProjects.stream()
+                                            .filter(item -> item.getProId().equals(pid))
+                                            .findFirst();
+                                    if (match.isPresent()) {
+                                        reportSpecialProject(document1, entry, paragraph, value,match.get());
+                                    } else {
+                                        String[] titles = {"浣撴椤圭洰", "浣撴缁撴灉"};
+                                        Font headFont = PdfUtils.setFont(DEFAULT_FONT_SIZE);
+                                        Font textFont = PdfUtils.setFont(DEFAULT_FONT_SIZE);
+                                        PdfPTable table = PdfUtils.setTable2(headFont, textFont, titles, value, false, new float[]{240, 300});
+                                        document1.add(table);
+                                    }
+                                }
+
+                            }
+                        } else {
+                            String[] titles = {"浣撴椤圭洰", "浣撴缁撴灉", "鍗曚綅"};
+                            Font headFont = PdfUtils.setFont(DEFAULT_FONT_SIZE);
+                            Font textFont = PdfUtils.setFont(DEFAULT_FONT_SIZE);
+                            PdfPTable table = PdfUtils.setTable(headFont, textFont, titles, value, isPacs);
+                            document1.add(table);
+                        }
+
+
+                        //鍒ゆ柇澶囨敞鏄惁涓虹┖  绌轰笉鑳芥樉绀簄ull
+                        if (entry.getKey().getRemark() == null) {
+                            entry.getKey().setRemark("");
+                        }
+                        //                    if (!dictHosp.getHospName().equals("婢勫悎鐭垮姟灞�涓績鍖婚櫌")){
+                        if (!true) {
+                            String remark = "澶囨敞锛�" + entry.getKey().getRemark();
+                            if (entry.getKey().getRemark().length() > 50) {
+                                int j = 0;
+                                for (int i = 0; i < remark.length() / 50; i++) {
+                                    String substring = remark.substring(j, j + 50);
+                                    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(DEFAULT_FONT_SIZE);
+                                    Paragraph pp = PdfUtils.setParagraph(remarkFonts, substring);
+                                    document1.add(pp);
+                                }
+                            } else {
+                                Font remarkFonts = PdfUtils.setFont(DEFAULT_FONT_SIZE);
+                                Paragraph pp = PdfUtils.setParagraph(remarkFonts, remark);
+                                document1.add(pp);
+                            }
+                        }
+                        //鍒ゆ柇涓绘鍖诲笀鏄惁涓虹┖  绌轰笉鑳芥樉绀簄ull
+                        zhuJianYiShi(document1, entry, orderRemark.getCreateTime(), dictHosp);
+                        //                    if (!dictHosp.getHospName().equals("婢勫悎鐭垮姟灞�涓績鍖婚櫌")) {
+                        if (!true) {
+                            //鍒嗗壊绾�
+                            LineSeparator objectName = new LineSeparator();
+                            document1.add(objectName);
+                        }
+
+
+            }
+        } catch (NumberFormatException e) {
+            throw new RuntimeException(e);
+        } catch (DocumentException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+
     /**
      * 鐩墠鍐欐 鍙湁纰�13銆�14 妯℃澘閮芥槸涓�鏍风殑鍙笉杩囧弬鑰冨�间笉鍚�
      * 鍑屼簯锛歿"dy":"4.0","xy":"4.0","title":"闃虫�у弬鑰冨�硷細","dystr":"DOB鍊硷細         鈮�      ${dy}                HP-闃虫��","xystr":"                <      ${xy}                  姝e父","en":"DOB"}
@@ -2559,6 +2713,7 @@
                             }
                             tjPdfVO.setProId(String.valueOf(tjOrderDetail.getProject().getProId()));
                             tjPdfVO.setPid(String.valueOf(tjProject.getProParentId()));
+                            tjPdfVO.setXh(tjProject.getXh());
     //                        LambdaQueryWrapper<LtkjExamJcbgd> wrapper = new LambdaQueryWrapper<>();
     //                        wrapper.eq(LtkjExamJcbgd::getTjh, tjNumber);
     //                        wrapper.eq(LtkjExamJcbgd::getXmdm, String.valueOf(tjOrderDetail.getProject().getProParentId()));
@@ -2567,12 +2722,13 @@
                     }
                 }
                 if(!tjPdfVOS.isEmpty()){
-                    tjPdfVOS=tjPdfVOS.stream().sorted(Comparator.comparing(TjPdfVO::getProName, Collator.getInstance(Locale.CHINA))).collect(Collectors.toList());
-                    tjPdfVOS = tjPdfVOS.stream()
-                            .sorted(Comparator.comparingInt(
-                                    tjPdfVO -> tjPdfVO.getProName().length() // 鏍规嵁鍚嶅瓧鐨勯暱搴︽帓搴�
-                            ))
-                            .collect(Collectors.toList());
+//                    tjPdfVOS=tjPdfVOS.stream().sorted(Comparator.comparing(TjPdfVO::getProName, Collator.getInstance(Locale.CHINA))).collect(Collectors.toList());
+//                    tjPdfVOS = tjPdfVOS.stream()
+//                            .sorted(Comparator.comparingInt(
+//                                    tjPdfVO -> tjPdfVO.getProName().length() // 鏍规嵁鍚嶅瓧鐨勯暱搴︽帓搴�
+//                            ))
+//                            .collect(Collectors.toList());
+                    tjPdfVOS=tjPdfVOS.stream().sorted(Comparator.comparing(TjPdfVO::getXh)).collect(Collectors.toList());
                 }
                 printReport.put(entry.getKey(), tjPdfVOS);
             }
@@ -2660,6 +2816,38 @@
         }
     }
 
+
+    private void newpacsJianChaData(String tjNumber, Map<TjOrderRemark, List<TjPdfVO>> printReport, TjOrder one, TjCustomer customer) {
+        try {
+            List<TjOrderRemark> tjOrderRemarks = tjOrderRemarkService.newpacsJianChaData(tjNumber);
+            for (TjOrderRemark tjOrderRemark : tjOrderRemarks) {
+                List<TjPdfVO> tjPdfVOS = new ArrayList<>();
+                TjPdfVO tjPdfVO = new TjPdfVO();
+                tjPdfVO.setProResult(null);
+                tjPdfVO.setExc(0L);
+                tjPdfVO.setCompany("/");
+                tjPdfVO.setProId(tjOrderRemark.getProsId());
+                String yxbx = tjOrderRemark.getRemark();
+                String bgNr = tjOrderRemark.getJgbx();
+                // 姝e垯琛ㄨ揪寮忥細鍖归厤鏁板瓧鍚庤窡 '.' 鎴� '銆�'
+                String regex = "\\d+[\\.,銆乚";
+                // 浣跨敤姝e垯鏇挎崲锛屽尮閰嶇殑鏁板瓧鍚庢坊鍔犳崲琛岀
+                if(StringUtil.isNotBlank(yxbx)) yxbx = yxbx.replaceAll(regex, "\n$0");
+                if(StringUtil.isBlank(bgNr)) bgNr = "";
+                if(StringUtil.isBlank(yxbx)) yxbx = "";
+                tjPdfVO.setTs(yxbx);
+                tjPdfVO.setSj(bgNr);
+                tjPdfVO.setShys(tjOrderRemark.getDoctorName());
+                tjPdfVO.setProName(tjOrderRemark.getProName());
+                tjPdfVOS.add(tjPdfVO);
+                printReport.put(tjOrderRemark, tjPdfVOS);
+            }
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+
     /**
      * 璁剧疆鐢ㄦ埛淇℃伅
      *

--
Gitblit v1.8.0