From 2b39b654975aa9cb40254f20e545b9f389a82de7 Mon Sep 17 00:00:00 2001 From: zjh <1084500556@qq.com> Date: 星期五, 24 一月 2025 18:24:33 +0800 Subject: [PATCH] zjh20250124 --- ltkj-admin/src/main/java/com/ltkj/web/controller/his/HisPDFUtil.java | 244 ++++++++++++++++++++++++++---------------------- 1 files changed, 134 insertions(+), 110 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 6877a75..a3fbce1 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 @@ -46,6 +46,7 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.math.BigDecimal; +import java.text.Collator; import java.text.SimpleDateFormat; import java.util.*; import java.util.List; @@ -141,7 +142,7 @@ return data; } - public void putData(JSONObject jsonObject, AjaxResult result, String key) { +/* public void putData(JSONObject jsonObject, AjaxResult result, String key) { if (Integer.parseInt(result.get("code").toString()) == 200) { List<Map<String, Object>> data = (List<Map<String, Object>>) result.get("data"); jsonObject.putOpt(key, data); @@ -859,7 +860,7 @@ String outputFileName1 = customer.getCusId() + tjOrder.getTjNumber() + customer.getCusName() + "_鎶ュ憡.pdf"; savePDFFile(outputFileName1, tjOrder, customer, finalOutput); return AjaxResult.success(); - } + }*/ public AjaxResult hisPDFNew2(TjOrder tjOrder, TjCustomer customer, TjReportTemplate tjReportTemplate, TjReportTemplate zongJianYiShiQianMing) throws Exception { String s1 = sysConfigService.selectConfigByKey("tjreport_font_size_second_page_info"); @@ -920,7 +921,23 @@ 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(i -> i.getDeptId() + "_" + i.getDeptName())); +// Map<String, List<CsProVo>> listMap = list.stream() +// .collect(Collectors.groupingBy(i -> i.getDeptId() + "_" + i.getDeptName())); + Map<String, List<CsProVo>> listMap = list.stream() + .collect(Collectors.groupingBy( + i -> i.getDeptId() + "_" + i.getDeptName(), + TreeMap::new, // 鎸夐敭鎺掑簭 + Collectors.mapping( + i -> i, + Collectors.collectingAndThen( + Collectors.toList(), + l -> l.stream() + .sorted(Comparator.comparing(CsProVo::getDeptId)) // 瀵� List 鎺掑簭 + .collect(Collectors.toList()) + ) + ) + )); + // List<CsProVo> sortedList = list.stream() // .sorted(Comparator.comparingLong(CsProVo::getProId)) // .collect(Collectors.toList()); @@ -1101,6 +1118,9 @@ if (!entry.getKey().equals(proVo.getProId())) continue; List<TjOrderDetail> details = entry.getValue(); if(null !=details && !details.isEmpty()){ + details= details.stream() + .sorted(Comparator.comparing(TjOrderDetail::getProName)) + .collect(Collectors.toList()); boolean isXmWrite = false; int index = 1; int index1 = 1; @@ -2054,7 +2074,7 @@ // document1.add(table); // if (dictHosp.getHospName().equals("婢勫悎鐭垮姟灞�涓績鍖婚櫌") && !value.isEmpty()){ - if (true && !value.isEmpty()) { + if (!value.isEmpty()) { if (value.size() > 1) { if (value.get(0).getPid().equals("1862852701533012001")) { Font remarkFonts = PdfUtils.setFont(DEFAULT_FONT_SIZE); @@ -2175,7 +2195,7 @@ entry.getKey().setRemark(""); } // if (!dictHosp.getHospName().equals("婢勫悎鐭垮姟灞�涓績鍖婚櫌")){ - if (!true) { + if (false) { String remark = "澶囨敞锛�" + entry.getKey().getRemark(); if (entry.getKey().getRemark().length() > 50) { int j = 0; @@ -2202,42 +2222,34 @@ zhuJianYiShi(document1, entry, orderRemark.getCreateTime(), dictHosp); //鍒嗗壊绾� // if (!dictHosp.getHospName().equals("婢勫悎鐭垮姟灞�涓績鍖婚櫌")) { - if (!true) { + if (false) { LineSeparator objectName = new LineSeparator(); document1.add(objectName); } } else { - if (null != one11) { - if (entry.getValue().get(0).getProName().contains(";")) - titleName = entry.getValue().get(0).getProName(); - else titleName = one11.getProName(); - } else { - titleName = entry.getKey().getProName(); - } + if (entry.getValue().get(0).getProName().contains(";")) + titleName = entry.getValue().get(0).getProName(); + else titleName = one11.getProName(); // 璁剧疆鏍囬瀛椾綋鏍峰紡 Font titleFonts = PdfUtils.setFont(DEFAULT_FONT_SIZE); Paragraph paragraph = PdfUtils.setParagraph(titleFonts, titleName); // if (dictHosp.getHospName().equals("婢勫悎鐭垮姟灞�涓績鍖婚櫌")) { - if (true) { - 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); - 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); - } else { - document1.add(paragraph); + 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); + 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); // String[] titles = {"浣撴椤圭洰", "浣撴缁撴灉", "鍗曚綅"}; // Font headFont = PdfUtils.setFont(9); @@ -2246,7 +2258,7 @@ // document1.add(table); // if (dictHosp.getHospName().equals("婢勫悎鐭垮姟灞�涓績鍖婚櫌") && !value.isEmpty()){ - if (true && !value.isEmpty()) { + if (!value.isEmpty()) { if (value.size() > 1) { if (value.get(0).getPid().equals("1862852701533012001")) { Font remarkFonts = PdfUtils.setFont(DEFAULT_FONT_SIZE); @@ -2493,78 +2505,87 @@ LambdaQueryWrapper<LtkjHybgd> ltkjHybgdLambdaQueryWrapper = new LambdaQueryWrapper<>(); ltkjHybgdLambdaQueryWrapper.eq(LtkjHybgd::getTmh, hysqd.getTmh()); List<LtkjHybgd> hybgds = ltkjHybgdService.list(ltkjHybgdLambdaQueryWrapper); - // 澶х被椤圭洰鍚嶇О - String xmmc = hysqd.getXmmc(); - ArrayList<List<String>> lists = new ArrayList<>(); - HashSet<String> hashSet = new HashSet<>(); - String shsj = ""; - for (LtkjHybgd hybgd : hybgds) { - shsj = hybgd.getShsj(); - // 妫�鏌ラ」鐩� - String jcxm = hybgd.getJcxm() != null ? hybgd.getJcxm().trim() : null; - // 妫�楠岀粨鏋� - String jyjg = hybgd.getJyjg() != null ? hybgd.getJyjg().trim() : null; - // 缁撴灉鍗曚綅 - String jgdw = hybgd.getJgdw() != null ? hybgd.getJgdw().trim() : null; - // 鑼冨洿鍊� - String fwz = hybgd.getFwz() != null ? hybgd.getFwz().trim() : null; - // 妫�楠屽尰甯� -// String jyys = hybgd.getJyys(); - //瀹℃牳鍖荤敓 - String shysmc = hybgd.getShysmc() != null ? hybgd.getShysmc().trim() : null; - // 瀹℃牳鍖诲笀缂栫爜 - String shys = hybgd.getShys() != null ? hybgd.getShys().trim() : null; - String ycbz = ""; + if(null !=hybgds && !hybgds.isEmpty()){ +// hybgds=hybgds.stream().sorted(Comparator.comparing(LtkjHybgd::getJcxm, Collator.getInstance(Locale.CHINA))).collect(Collectors.toList()); +// hybgds = hybgds.stream() +// .sorted(Comparator.comparingInt( +// a -> a.getJcxm().length() // 鏍规嵁鍚嶅瓧鐨勯暱搴︽帓搴� +// )) +// .collect(Collectors.toList()); - if (jyjg != null && StrUtil.isNotBlank(jyjg) && fwz != null && StrUtil.isNotBlank(fwz)) { - try { - String[] fwzs = fwz.split("-"); - BigDecimal min = new BigDecimal(fwzs[0]); - BigDecimal max = new BigDecimal(fwzs[1]); - BigDecimal jyjgval = new BigDecimal(jyjg); - // 姣旇緝妫�楠岀粨鏋滃拰鑼冨洿鍊� - if (jyjgval.compareTo(min) < 0) { - // jyjg 灏忎簬鑼冨洿鏈�灏忓�硷紝娣诲姞涓嬬澶� + // 澶х被椤圭洰鍚嶇О + String xmmc = hysqd.getXmmc(); + ArrayList<List<String>> lists = new ArrayList<>(); + HashSet<String> hashSet = new HashSet<>(); + String shsj = ""; + for (LtkjHybgd hybgd : hybgds) { + shsj = hybgd.getShsj(); + // 妫�鏌ラ」鐩� + String jcxm = hybgd.getJcxm() != null ? hybgd.getJcxm().trim() : null; + // 妫�楠岀粨鏋� + String jyjg = hybgd.getJyjg() != null ? hybgd.getJyjg().trim() : null; + // 缁撴灉鍗曚綅 + String jgdw = hybgd.getJgdw() != null ? hybgd.getJgdw().trim() : null; + // 鑼冨洿鍊� + String fwz = hybgd.getFwz() != null ? hybgd.getFwz().trim() : null; + // 妫�楠屽尰甯� +// String jyys = hybgd.getJyys(); + //瀹℃牳鍖荤敓 + String shysmc = hybgd.getShysmc() != null ? hybgd.getShysmc().trim() : null; + // 瀹℃牳鍖诲笀缂栫爜 + String shys = hybgd.getShys() != null ? hybgd.getShys().trim() : null; + String ycbz = ""; + + if (jyjg != null && StrUtil.isNotBlank(jyjg) && fwz != null && StrUtil.isNotBlank(fwz)) { + try { + String[] fwzs = fwz.split("-"); + BigDecimal min = new BigDecimal(fwzs[0]); + BigDecimal max = new BigDecimal(fwzs[1]); + BigDecimal jyjgval = new BigDecimal(jyjg); + // 姣旇緝妫�楠岀粨鏋滃拰鑼冨洿鍊� + if (jyjgval.compareTo(min) < 0) { + // jyjg 灏忎簬鑼冨洿鏈�灏忓�硷紝娣诲姞涓嬬澶� // jyjg = jyjg + " 鈫�"; - ycbz = "鈫�"; - } else if (jyjgval.compareTo(max) > 0) { - // jyjg 澶т簬鑼冨洿鏈�澶у�硷紝娣诲姞涓婄澶� + ycbz = "鈫�"; + } else if (jyjgval.compareTo(max) > 0) { + // jyjg 澶т簬鑼冨洿鏈�澶у�硷紝娣诲姞涓婄澶� // jyjg = jyjg + " 鈫�"; - ycbz = "鈫�"; + ycbz = "鈫�"; + } + } catch (Exception ignored) { } - } catch (Exception ignored) { } - } // LambdaQueryWrapper<SysUser> queryWrapper = new LambdaQueryWrapper<>(); // queryWrapper.eq(SysUser::getUserName,jyys); // List<SysUser> sysUsers = userService.list(queryWrapper); // if (!sysUsers.isEmpty()) // hashSet.add(sysUsers.get(0).getNickName()); - String key = sysConfigService.selectConfigByKey("is_report_pdf_use_ysqm"); - if (null != shys && null != shysmc && key.equals("Y")) { - hashSet.add(shysmc + "|" + shys); - } else { - if (null != shysmc) hashSet.add(shysmc); + String key = sysConfigService.selectConfigByKey("is_report_pdf_use_ysqm"); + if (null != shys && null != shysmc && key.equals("Y")) { + hashSet.add(shysmc + "|" + shys); + } else { + if (null != shysmc) hashSet.add(shysmc); + } + ArrayList<String> strings = new ArrayList<>(); + strings.add(jcxm); + strings.add(jyjg); + strings.add(ycbz); + strings.add(jgdw); + strings.add(fwz); + strings.add(hybgd.getJcxmid()); + strings.add(hysqd.getXmid()); + lists.add(strings); } - ArrayList<String> strings = new ArrayList<>(); - strings.add(jcxm); - strings.add(jyjg); - strings.add(ycbz); - strings.add(jgdw); - strings.add(fwz); - strings.add(hybgd.getJcxmid()); - strings.add(hysqd.getXmid()); - lists.add(strings); - } - if (!lists.isEmpty()) { - HashMap<String, Object> map = new HashMap<>(); - map.put("data", lists); - map.put("jyys", hashSet); - if (StrUtil.isNotBlank(shsj)) { - shsj = shsj.split(" ")[0]; + if (!lists.isEmpty()) { + HashMap<String, Object> map = new HashMap<>(); + map.put("data", lists); + map.put("jyys", hashSet); + if (StrUtil.isNotBlank(shsj)) { + shsj = shsj.split(" ")[0]; + } + map.put("shsj", shsj); + data.put(xmmc, map); } - map.put("shsj", shsj); - data.put(xmmc, map); } } return data; @@ -2757,16 +2778,9 @@ 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()); tjOrderDetails = tjOrderDetails.stream().filter(i -> StrUtil.isNotBlank(i.getProResult())).collect(Collectors.toList()); - tjOrderDetails = new ArrayList<>(tjOrderDetails.stream().collect(Collectors.toMap(TjOrderDetail::getProId, i -> i, (existing, replacement) -> existing)).values()); + tjOrderDetails = new ArrayList<>(tjOrderDetails.stream() + .collect(Collectors.toMap(TjOrderDetail::getProId, i -> i, (existing, replacement) -> existing)).values()); for (TjOrderDetail tjOrderDetail : tjOrderDetails) { TjProject tjProject = projectService.getById(String.valueOf(tjOrderDetail.getProId())); if (null != tjProject && tjProject.getNeedReport().equals("Y")) { @@ -2784,19 +2798,21 @@ } tjPdfVO.setProId(String.valueOf(tjOrderDetail.getProject().getProId())); tjPdfVO.setPid(String.valueOf(tjProject.getProParentId())); - LambdaQueryWrapper<LtkjExamJcbgd> wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(LtkjExamJcbgd::getTjh, tjNumber); - wrapper.eq(LtkjExamJcbgd::getXmdm, String.valueOf(tjOrderDetail.getProject().getProParentId())); -// LtkjExamJcbgd jcbgd = jcbgdService.getOne(wrapper); -// if (jcbgd != null){ -// tjPdfVO.setTs(jcbgd.getYxbx()); -// tjPdfVO.setSj(jcbgd.getBgNr()); -// tjPdfVO.setShys(jcbgd.getShysxm()); -// } +// LambdaQueryWrapper<LtkjExamJcbgd> wrapper = new LambdaQueryWrapper<>(); +// wrapper.eq(LtkjExamJcbgd::getTjh, tjNumber); +// wrapper.eq(LtkjExamJcbgd::getXmdm, String.valueOf(tjOrderDetail.getProject().getProParentId())); tjPdfVOS.add(tjPdfVO); } } } +// 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()); +// } printReport.put(entry.getKey(), tjPdfVOS); } } @@ -2854,6 +2870,14 @@ } } } +// 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()); +// } printReport.put(entry.getKey(), tjPdfVOS); } } -- Gitblit v1.8.0