| | |
| | | import cn.hutool.json.JSONObject; |
| | | import cn.hutool.json.JSONUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.itextpdf.text.*; |
| | | import com.itextpdf.text.Font; |
| | | import com.itextpdf.text.Image; |
| | | import com.itextpdf.text.Rectangle; |
| | | import com.itextpdf.text.pdf.*; |
| | | import com.itextpdf.text.pdf.draw.LineSeparator; |
| | | import com.ltkj.common.core.domain.AjaxResult; |
| | | import com.ltkj.common.core.domain.entity.SysDictData; |
| | | import com.ltkj.common.core.domain.entity.SysUser; |
| | | import com.ltkj.common.utils.DateUtils; |
| | | import com.ltkj.common.utils.StringUtils; |
| | | import com.ltkj.common.utils.SecurityUtils; |
| | | import com.ltkj.framework.config.MatchUtils; |
| | | import com.ltkj.hosp.domain.*; |
| | | import com.ltkj.hosp.mapper.DictUserInfoMapper; |
| | | import com.ltkj.hosp.mapper.TjOrderDetailMapper; |
| | | import com.ltkj.hosp.mapper.TjOrderRemarkMapper; |
| | | import com.ltkj.hosp.mapper.TjRulesMapper; |
| | | import com.ltkj.hosp.service.*; |
| | | import com.ltkj.hosp.sqlDomain.LtkjExamJcbgd; |
| | | import com.ltkj.hosp.sqlDomain.LtkjHybgd; |
| | | import com.ltkj.hosp.sqlDomain.LtkjHysqd; |
| | | import com.ltkj.mall.mallOrderUtils.TjConstants; |
| | | import com.ltkj.hosp.vodomain.CsProVo; |
| | | import com.ltkj.system.service.ISysConfigService; |
| | | import com.ltkj.system.service.ISysDictDataService; |
| | | import com.ltkj.system.service.ISysUserService; |
| | | import com.ltkj.web.config.pdfutils.PdfUtils; |
| | | import com.ltkj.web.controller.system.SysDeptController; |
| | | import lombok.SneakyThrows; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.awt.*; |
| | | import java.io.*; |
| | | import java.lang.reflect.Field; |
| | | import java.lang.reflect.InvocationTargetException; |
| | | import java.lang.reflect.Method; |
| | | import java.math.BigDecimal; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.List; |
| | | import java.util.concurrent.atomic.AtomicInteger; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static com.ltkj.web.config.pdfutils.PDFBinaryUtil.getPDFBinary; |
| | | import static com.ltkj.common.utils.pdfutils.PdfUtils.createTable; |
| | | |
| | | /** |
| | | * 检查 检验报告pdf生成 |
| | |
| | | private String value; |
| | | @Value("${path.reportServer}") |
| | | private String urlValue; |
| | | @Autowired |
| | | private DictUserInfoMapper dictUserInfoMapper; |
| | | @Autowired |
| | | private ISysConfigService sysConfigService; |
| | | @Resource |
| | | private LtkjExamJcbgdService jcbgdService; |
| | | @Resource |
| | | private LtkjExamJcsqdService jcsqdService; |
| | | @Autowired |
| | | private IDictHospService dictHospService; |
| | | @Autowired |
| | | private ISysDictDataService sysDictDataService; |
| | | @Autowired |
| | | private ITjRulesService tjRulesService; |
| | | @Autowired |
| | | private TjRulesMapper tjRulesMapper; |
| | | @Autowired |
| | | private TjOrderRemarkMapper tjOrderRemarkMapper; |
| | | @Autowired |
| | | private TjOrderDetailMapper tjOrderDetailMapper; |
| | | @Autowired |
| | | private SysDeptController sysDeptController; |
| | | @Autowired |
| | | private ITjProAdvicerulesService tjProAdvicerulesService; |
| | | @Autowired |
| | | private TjOrderYcxmService ycxmService; |
| | | |
| | | // private static final |
| | | private Integer pdfPage = 0; |
| | | |
| | | /** |
| | | * 通过his API请求获取数据生成PDF |
| | | * @param pdfInfoMap |
| | | * @param params |
| | | * @param tjOrder |
| | | * @param tjReportTemplate |
| | | * @return |
| | | * @deprecated 有数据同步不在调用接口获取数据直接查数据库拿数据生成 |
| | | */ |
| | | @Deprecated |
| | | public AjaxResult execHisRequest(HashMap<String, Object> pdfInfoMap, Map<String, Object> params,TjOrder tjOrder,TjReportTemplate tjReportTemplate) { |
| | | List<Map<String, Object>> list; |
| | | String hisRegistrationId = params.get("his_registration_id").toString(); |
| | | AjaxResult getlabreportinfo = apiGetMethodService.getHISDataNew("Getlabreportinfo", params); |
| | | list = makePDFInfo(pdfInfoMap, getlabreportinfo, "获取检验报告记录信息"); |
| | | JSONArray jsonArray = JSONUtil.createArray(); |
| | | if (list != null) { |
| | | params.clear(); |
| | | for (Map<String, Object> stringObjectMap : list) { |
| | | if (stringObjectMap == null) |
| | | continue; |
| | | JSONObject obj = JSONUtil.createObj(); |
| | | obj.putOpt("报告记录", stringObjectMap); |
| | | String jybgid = stringObjectMap.get("JYBGID").toString(); |
| | | params.put("jybgid", jybgid); |
| | | // 获取检验结果记录信息 |
| | | AjaxResult getlabdetailinfo = apiGetMethodService.getHISDataNew("Getlabdetailinfo", params); |
| | | putData(obj, getlabdetailinfo, "检验结果记录"); |
| | | // 获取微生物报告记录信息 |
| | | AjaxResult getlabgermrepinfo = apiGetMethodService.getHISDataNew("Getlabgermrepinfo", params); |
| | | putData(obj, getlabgermrepinfo, "微生物报告记录"); |
| | | // 获取微生物药敏信息 |
| | | AjaxResult getlabgermdetailinfo = apiGetMethodService.getHISDataNew("Getlabgermdetailinfo", params); |
| | | putData(obj, getlabgermdetailinfo, "微生物药敏信息"); |
| | | // 获取危急值信息 |
| | | AjaxResult getlaburgentinfo = apiGetMethodService.getHISDataNew("Getlaburgentinfo", params); |
| | | putData(obj, getlaburgentinfo, "危机值信息"); |
| | | jsonArray.put(obj); |
| | | } |
| | | // 获取检查报告信息 |
| | | params.clear(); |
| | | params.put("his_registration_id", hisRegistrationId); |
| | | params.put("ksmc", ""); |
| | | params.put("pationid", ""); |
| | | params.put("ksrq", ""); |
| | | params.put("jsrq", ""); |
| | | params.put("pagecount", 100); |
| | | params.put("page", 1); |
| | | params.put("status", ""); |
| | | AjaxResult getexamreportinfo = apiGetMethodService.getHISDataNew("Getexamreportinfo", params); |
| | | JSONObject object = JSONUtil.parseObj(getexamreportinfo.get("result")); |
| | | JSONObject response = JSONUtil.parseObj(object.get("Response")); |
| | | if (!response.getStr("ResultCode").equals("0")) { |
| | | if (!response.getStr("ResultContent").contains("查询失败")) |
| | | return AjaxResult.error("生成超时,请重试"); |
| | | } |
| | | JSONObject obj = JSONUtil.createObj(); |
| | | putData(obj, getexamreportinfo, "检查报告"); |
| | | jsonArray.put(obj); |
| | | // System.out.println(JSONUtil.toJsonStr(jsonArray)); |
| | | if (makePDF(hisRegistrationId, jsonArray,tjOrder,tjReportTemplate)) { |
| | | log.info("已生成报告"); |
| | | return AjaxResult.success("已生成报告!可直接点击预览!"); |
| | | } else return AjaxResult.error(); |
| | | } else { |
| | | return AjaxResult.error("未获取到检验报告记录信息"); |
| | | } |
| | | } |
| | | private static int DEFAULT_FONT_SIZE = 10; |
| | | private static int DEFAULT_LITTLE_TITLE_FONT_SIZE = 11; |
| | | private static int DEFAULT_TITLE_FONT_SIZE = 12; |
| | | private static int DEFAULT_ZONGJIAN_FONT_SIZE = 15; |
| | | private static String HOSP_NAME; |
| | | |
| | | private List<Map<String, Object>> makePDFInfo(HashMap<String, Object> map, AjaxResult ajaxResult, String key) { |
| | | List<Map<String, Object>> data = null; |
| | |
| | | } |
| | | } |
| | | |
| | | public AjaxResult hisPDF(TjOrder tjOrder,TjCustomer customer,TjReportTemplate tjReportTemplate) throws DocumentException { |
| | | HashMap<String, Object> pdfChangGui = makePDFInfo(tjOrder, customer, tjReportTemplate); |
| | | public AjaxResult hisPDF(TjOrder tjOrder, TjCustomer customer, TjReportTemplate tjReportTemplate) throws Exception { |
| | | DictHosp dictHosp = dictHospService.list().get(0); |
| | | String color = sysConfigService.selectConfigByKey("report_title_color"); |
| | | // list.get(0).getHospName().equals("澄合矿务局中心医院") |
| | | List<SysDictData> sysUserSex = sysDictDataService.list(new LambdaQueryWrapper<SysDictData>().eq(SysDictData::getDictType, "sys_user_sex")); |
| | | HashMap<String, Object> map = makeHisJianYan(tjOrder, customer); |
| | | HashMap<String, Object> pdfChangGui = makePDFInfo(tjOrder, customer, tjReportTemplate, dictHosp, map); |
| | | if (pdfChangGui == null) |
| | | return AjaxResult.error(); |
| | | Document document = (Document) pdfChangGui.get("document"); |
| | | PdfCopy copy = (PdfCopy) pdfChangGui.get("copy"); |
| | | ByteArrayOutputStream finalOutPut = (ByteArrayOutputStream) pdfChangGui.get("stream"); |
| | | ByteArrayOutputStream byteArrayOutputStream1 = new ByteArrayOutputStream(); |
| | | Document document1 = new Document(PageSize.A4); |
| | | PdfWriter pdfWriter = null; |
| | | int pageSize = 0; |
| | | try { |
| | | pdfWriter = PdfWriter.getInstance(document1, byteArrayOutputStream1); |
| | | pdfWriter = PdfWriter.getInstance(document1, byteArrayOutputStream1); |
| | | // if (dictHosp.getHospName().equals("澄合矿务局中心医院")){ |
| | | if (true) { |
| | | 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("澄合矿务局中心医院",customer.getCusName(),tjOrder.getTjNumber(),sex,String.valueOf(DateUtil.ageOfNow(customer.getCusBrithday())),null)); |
| | | pdfWriter.setPageEvent(new FooterHeaderPageEvent(dictHosp.getHospName(), customer.getCusName(), tjOrder.getTjNumber(), sex, String.valueOf(DateUtil.ageOfNow(customer.getCusBrithday())), null)); |
| | | pageSize = pdfWriter.getPageNumber(); |
| | | } |
| | | } catch (DocumentException e) { |
| | | e.printStackTrace(); |
| | | log.error(String.valueOf(e)); |
| | | return AjaxResult.error(); |
| | | } |
| | | document1.setMargins(70, 70, 40, 40); |
| | | document1.open(); |
| | | // 非化验项目报告 |
| | | Map<TjOrderRemark, List<TjPdfVO>> printReport = new HashMap<>(); |
| | | notHuaYanData(tjOrder.getTjNumber(), printReport,tjOrder,customer); |
| | | |
| | | // if (dictHosp.getHospName().equals("澄合矿务局中心医院")){ |
| | | if (true) { |
| | | // 组装体检检查项目报告 |
| | | Map<TjOrderRemark, List<TjPdfVO>> printReport = new HashMap<>(); |
| | | notHuaYanData(tjOrder.getTjNumber(), printReport, tjOrder, customer); |
| | | try { |
| | | notHuaYanTable(document1, printReport, dictHosp, color, false); |
| | | } catch (DocumentException e) { |
| | | log.error("非化验项目填充表格异常"); |
| | | log.error(String.valueOf(e)); |
| | | return AjaxResult.error(); |
| | | } |
| | | // 组装检验数据 |
| | | makeHisJianYanTable(document1, map, dictHosp, color); |
| | | |
| | | // 组装pacs检查数据 |
| | | printReport = new HashMap<>(); |
| | | pacsJianChaData(tjOrder.getTjNumber(), printReport, tjOrder, customer); |
| | | try { |
| | | notHuaYanTable(document1, printReport, dictHosp, color, true); |
| | | } catch (DocumentException e) { |
| | | log.error("pacs项目填充表格异常"); |
| | | log.error(String.valueOf(e)); |
| | | return AjaxResult.error(); |
| | | } |
| | | } else { |
| | | // 非化验项目报告 |
| | | Map<TjOrderRemark, List<TjPdfVO>> printReport = new HashMap<>(); |
| | | notHuaYanData(tjOrder.getTjNumber(), printReport, tjOrder, customer); |
| | | try { |
| | | notHuaYanTable(document1, printReport, dictHosp, color, true); |
| | | } catch (DocumentException e) { |
| | | log.error("非化验项目填充表格异常"); |
| | | log.error(String.valueOf(e)); |
| | | return AjaxResult.error(); |
| | | } |
| | | // 组装检验数据 |
| | | makeHisJianYanTable(document1, map, dictHosp, color); |
| | | } |
| | | document1.close(); |
| | | |
| | | PdfReader reader = null; |
| | | 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("澄合矿务局中心医院")){ |
| | | if (!true) { |
| | | 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 { |
| | | notHuaYanTable(document1, printReport); |
| | | PdfReader pdfReader = new PdfReader(finalOutPut.toByteArray()); |
| | | int pages = pdfReader.getNumberOfPages(); |
| | | ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
| | | PdfStamper pdfStamper = new PdfStamper(pdfReader, outputStream); |
| | | // if (!dictHosp.getHospName().equals("澄合矿务局中心医院")){ |
| | | if (!true) { |
| | | PdfContentByte contentByte; |
| | | BaseFont baseFont = PdfUtils.createBaseFont(null); |
| | | for (int i = 2; i <= pages; i++) { |
| | | contentByte = pdfStamper.getOverContent(i); |
| | | contentByte.beginText(); |
| | | contentByte.setFontAndSize(baseFont, 11); |
| | | float x = contentByte.getPdfDocument().getPageSize().getWidth() / 2; |
| | | float y = 20; |
| | | contentByte.showTextAligned(PdfContentByte.ALIGN_CENTER, String.valueOf(i - 1), x, y, 0); |
| | | contentByte.endText(); |
| | | } |
| | | } |
| | | pdfStamper.close(); |
| | | pdfReader.close(); |
| | | finalOutPut = outputStream; |
| | | } catch (IOException e) { |
| | | log.error(String.valueOf(e)); |
| | | return AjaxResult.error(); |
| | | } |
| | | savePDFFile(outputFileName1, tjOrder, customer, finalOutPut); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | 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, 50); |
| | | document2.open(); |
| | | |
| | | List<CsProVo> list = tjOrderRemarkService.cSWebGetProByTjNumAndOrderId(tjOrder.getTjNumber(), false); |
| | | |
| | | Font defaultFont = PdfUtils.setFont(DEFAULT_FONT_SIZE); |
| | | Font defaultTitleFont = PdfUtils.setFont(DEFAULT_LITTLE_TITLE_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); |
| | | } |
| | | |
| | | |
| | | // List<TjOrderRemark> remarks = tjOrderRemarkMapper.getzongjianyishengchakanyichangxiangmu3( tjOrder.getTjNumber()); |
| | | List<TjOrderDetail> orderDetails = tjOrderDetailMapper.getzongjianyishengchakanyichangxiangmu4(tjOrder.getTjNumber()); |
| | | // List<Map<String, Object>> jiancha = new ArrayList<>(); |
| | | |
| | | |
| | | paragraph = PdfUtils.setParagraph(defaultTitleFont, "检查综述:"); |
| | | paragraph.setSpacingBefore(3f); |
| | | paragraph.setSpacingAfter(2f); |
| | | document2.add(paragraph); |
| | | |
| | | int xmXh = 1; |
| | | for (Map.Entry<Long, List<TjOrderDetail>> entry : orderDetails.stream().collect(Collectors.groupingBy(TjOrderDetail::getProId)).entrySet()) { |
| | | List<TjOrderDetail> details = entry.getValue(); |
| | | String xmmc = details.get(0).getProName(); |
| | | boolean isXmWrite = false; |
| | | for (TjOrderDetail detail : details) { |
| | | if (!isXmWrite) { |
| | | paragraph = new Paragraph(xmXh + ". " + xmmc, defaultFont); |
| | | paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | document2.add(paragraph); |
| | | isXmWrite = true; |
| | | } |
| | | String result = detail.getProResult(); |
| | | if (StrUtil.isNotBlank(result)) { |
| | | int index = 1; |
| | | result = result.replaceAll("本报告仅对本次检查负责,临床医生依据病情如有疑问,请及时复查或进一步检查", ""); |
| | | String[] split = result.split("\n"); |
| | | StringBuilder builder = new StringBuilder(); |
| | | for (String s : split) { |
| | | if (StrUtil.isBlank(s.replaceAll("\n", "").trim())) continue; |
| | | builder.append(" (").append(index).append(")").append(s).append("\n"); |
| | | index++; |
| | | } |
| | | result = builder.toString(); |
| | | } |
| | | paragraph = new Paragraph(result, defaultFont); |
| | | paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | document2.add(paragraph); |
| | | } |
| | | paragraph = PdfUtils.setParagraph(defaultFont, ""); |
| | | paragraph.setLeading(0f); |
| | | paragraph.setSpacingBefore(0f); |
| | | paragraph.setSpacingAfter(5f); |
| | | document2.add(paragraph); |
| | | xmXh++; |
| | | } |
| | | |
| | | 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(xmXh + ". " + 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) + " " + i.get(2); |
| | | paragraph = new Paragraph(content, defaultFont); |
| | | paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | document2.add(paragraph); |
| | | index++; |
| | | } |
| | | } |
| | | paragraph = PdfUtils.setParagraph(defaultFont, ""); |
| | | paragraph.setSpacingBefore(0f); |
| | | paragraph.setSpacingAfter(5f); |
| | | document2.add(paragraph); |
| | | xmXh++; |
| | | } |
| | | |
| | | |
| | | paragraph = PdfUtils.setParagraph(defaultFont, ""); |
| | | paragraph.setLeading(0f); |
| | | paragraph.setSpacingBefore(10f); |
| | | paragraph.setSpacingAfter(10f); |
| | | document2.add(paragraph); |
| | | |
| | | |
| | | paragraph = PdfUtils.setParagraph(defaultTitleFont, "医生建议:"); |
| | | paragraph.setSpacingBefore(3f); |
| | | paragraph.setSpacingAfter(2f); |
| | | document2.add(paragraph); |
| | | xmXh = 0; |
| | | 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) { |
| | | xmXh++; |
| | | paragraph = new Paragraph("【" + xmXh + "." + 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) + " " + i.get(2); |
| | | paragraph = new Paragraph(content, defaultFont); |
| | | paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | document2.add(paragraph); |
| | | // 第六位是lis项目id |
| | | // LambdaQueryWrapper<TjProject> wrapper = new LambdaQueryWrapper<>(); |
| | | // wrapper.eq(TjProject::getLisXmbm,i.get(5)); |
| | | // TjProject project = projectService.getOne(wrapper); |
| | | // if (project != null) { |
| | | // LambdaQueryWrapper<TjRules> queryWrapper = new LambdaQueryWrapper<>(); |
| | | // queryWrapper.eq(TjRules::getProId,project.getProId()); |
| | | // List<TjRules> rules = tjRulesService.list(queryWrapper); |
| | | // if (!rules.isEmpty()){ |
| | | // |
| | | // } |
| | | String str = " "; |
| | | List<Map<String, Object>> maps = tjRulesService.getyichangxiangmujianyiguize(i.get(5), "", i.get(2), tjOrder.getTjNumber(), i.get(5), ""); |
| | | if (!maps.isEmpty()) { |
| | | for (Map<String, Object> objectMap : maps) { |
| | | // paragraph = new Paragraph(str+"建议标题",defaultFont); |
| | | // paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | // document2.add(paragraph); |
| | | // |
| | | // paragraph = new Paragraph(str+objectMap.get("bt").toString(),defaultFont); |
| | | // paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | // document2.add(paragraph); |
| | | // |
| | | // paragraph = new Paragraph(str+"建议内容",defaultFont); |
| | | // paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | // document2.add(paragraph); |
| | | // |
| | | // paragraph = new Paragraph(str+objectMap.get("nr").toString(),defaultFont); |
| | | // paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | // document2.add(paragraph); |
| | | String content1 = str + objectMap.get("bt").toString().trim() + objectMap.get("nr").toString().trim(); |
| | | if (StrUtil.isBlank(content1)) |
| | | content1 = " 本报告仅对本次检查负责,临床医生依据病情如有疑问,请及时复查或进一步检查"; |
| | | |
| | | paragraph = new Paragraph(content1, defaultFont); |
| | | paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | document2.add(paragraph); |
| | | } |
| | | paragraph = PdfUtils.setParagraph(defaultFont, ""); |
| | | paragraph.setSpacingBefore(2f); |
| | | paragraph.setSpacingAfter(5f); |
| | | document2.add(paragraph); |
| | | } |
| | | // } |
| | | index++; |
| | | } |
| | | } |
| | | paragraph = PdfUtils.setParagraph(defaultFont, ""); |
| | | paragraph.setSpacingBefore(0f); |
| | | paragraph.setSpacingAfter(5f); |
| | | document2.add(paragraph); |
| | | } |
| | | |
| | | |
| | | for (Map.Entry<Long, List<TjOrderDetail>> entry : orderDetails.stream().collect(Collectors.groupingBy(TjOrderDetail::getProId)).entrySet()) { |
| | | List<TjOrderDetail> details = entry.getValue(); |
| | | String xmmc = details.get(0).getProName(); |
| | | boolean isXmWrite = false; |
| | | int index = 1; |
| | | for (TjOrderDetail detail : details) { |
| | | if (!isXmWrite) { |
| | | xmXh++; |
| | | paragraph = new Paragraph("【" + xmXh + "." + xmmc + "】", defaultFont); |
| | | paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | document2.add(paragraph); |
| | | isXmWrite = true; |
| | | } |
| | | String result = detail.getProResult(); |
| | | if (StrUtil.isNotBlank(result)) { |
| | | // result = result.replaceAll(" ","").replaceAll("\t",""); |
| | | // result = result.replaceAll("\n本报告仅对本次检查负责,临床医生依据病情如有疑问,请及时复查或进一步检查", ""); |
| | | // result = "\n " + result.replaceAll("\n", "\n "); |
| | | int index1 = 1; |
| | | String[] split = result.split("\n"); |
| | | boolean contains = result.contains("本报告仅对本次检查负责,临床医生依据病情如有疑问,请及时复查或进一步检查"); |
| | | StringBuilder builder = new StringBuilder(); |
| | | for (String s : split) { |
| | | if (StrUtil.isBlank(s.replaceAll("\n", "").trim())) continue; |
| | | builder.append(" (").append(index1).append(")").append(s).append("\n"); |
| | | index1++; |
| | | } |
| | | if (!contains) |
| | | builder.append(" (").append(index1).append(")").append("本报告仅对本次检查负责,临床医生依据病情如有疑问,请及时复查或进一步检查"); |
| | | else builder.substring(0, builder.length() - 1); |
| | | result = builder.toString(); |
| | | } |
| | | // String content = " (" + index + ") " + detail.getProName() + ":" + result; |
| | | // content = content.replaceAll("[\\n\\r]+$", ""); |
| | | // content = content.replaceAll("\\s+$", ""); |
| | | // paragraph = new Paragraph(content, defaultFont); |
| | | paragraph = new Paragraph(result, defaultFont); |
| | | paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | document2.add(paragraph); |
| | | String str = " "; |
| | | List<Map<String, Object>> maps = tjRulesService.getyichangxiangmujianyiguize(entry.getKey().toString(), "", "", tjOrder.getTjNumber(), detail.getProName(), ""); |
| | | for (Map<String, Object> objectMap : maps) { |
| | | String content1 = str + objectMap.get("bt").toString() + objectMap.get("nr").toString(); |
| | | if (StrUtil.isBlank(content1)) |
| | | content1 = " 本报告仅对本次检查负责,临床医生依据病情如有疑问,请及时复查或进一步检查"; |
| | | |
| | | paragraph = new Paragraph(content1, defaultFont); |
| | | paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | document2.add(paragraph); |
| | | } |
| | | index++; |
| | | paragraph = PdfUtils.setParagraph(defaultFont, ""); |
| | | paragraph.setLeading(0f); |
| | | paragraph.setSpacingBefore(0f); |
| | | paragraph.setSpacingAfter(5f); |
| | | document2.add(paragraph); |
| | | } |
| | | } |
| | | |
| | | |
| | | for (int i = 0; i < 1; 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); |
| | | } |
| | | |
| | | |
| | | Paragraph paragraphNone = new Paragraph("", defaultFont); |
| | | paragraphNone.setAlignment(Element.ALIGN_LEFT); |
| | | //行间距 |
| | | paragraphNone.setLeading(5f); |
| | | paragraphNone.setSpacingBefore(10f); |
| | | paragraphNone.setSpacingAfter(10f); |
| | | document2.add(paragraphNone); |
| | | paragraphNone = new Paragraph("", defaultFont); |
| | | paragraphNone.setAlignment(Element.ALIGN_LEFT); |
| | | //行间距 |
| | | paragraphNone.setLeading(5f); |
| | | paragraphNone.setSpacingBefore(10f); |
| | | paragraphNone.setSpacingAfter(10f); |
| | | document2.add(paragraphNone); |
| | | |
| | | |
| | | PdfPTable tableQz = new PdfPTable(new float[]{100f, 100f, 50f}); |
| | | tableQz.setTotalWidth(PageSize.A4.getWidth() - 100); |
| | | tableQz.setLockedWidth(true); |
| | | tableQz.setHorizontalAlignment(Element.ALIGN_LEFT); |
| | | tableQz.getDefaultCell().setBorder(0); |
| | | tableQz.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT); |
| | | |
| | | Font zongJianFont = PdfUtils.setFont(DEFAULT_ZONGJIAN_FONT_SIZE); |
| | | Font zongJianTitleFont = PdfUtils.setFont(DEFAULT_ZONGJIAN_FONT_SIZE); |
| | | zongJianTitleFont.setStyle(Font.BOLD); |
| | | |
| | | for (int i = 0; i < 3; i++) { |
| | | PdfPCell cell = new PdfPCell(); |
| | | cell.setVerticalAlignment(Element.ALIGN_MIDDLE); |
| | | cell.setHorizontalAlignment(Element.ALIGN_RIGHT); |
| | | cell.setPhrase(new Phrase("", defaultFont)); |
| | | cell.setBorder(Rectangle.NO_BORDER); |
| | | tableQz.addCell(cell); |
| | | } |
| | | |
| | | |
| | | PdfPCell cell = new PdfPCell(); |
| | | cell.setBorder(Rectangle.NO_BORDER); |
| | | cell.setVerticalAlignment(Element.ALIGN_MIDDLE); |
| | | cell.setHorizontalAlignment(Element.ALIGN_RIGHT); |
| | | cell.setPhrase(new Phrase("", defaultFont)); |
| | | cell.setRowspan(3); |
| | | tableQz.addCell(cell); |
| | | |
| | | cell = new PdfPCell(); |
| | | cell.setBorder(Rectangle.NO_BORDER); |
| | | cell.setVerticalAlignment(Element.ALIGN_MIDDLE); |
| | | cell.setHorizontalAlignment(Element.ALIGN_RIGHT); |
| | | cell.setPaddingTop(10); |
| | | cell.setPaddingBottom(10); |
| | | cell.setPhrase(new Phrase("体检单位盖章:", zongJianTitleFont)); |
| | | |
| | | tableQz.addCell(cell); |
| | | |
| | | cell = new PdfPCell(); |
| | | cell.setBorder(Rectangle.NO_BORDER); |
| | | cell.setVerticalAlignment(Element.ALIGN_MIDDLE); |
| | | cell.setHorizontalAlignment(Element.ALIGN_RIGHT); |
| | | cell.setPaddingTop(10); |
| | | cell.setPaddingBottom(10); |
| | | cell.setPhrase(new Phrase("", zongJianFont)); |
| | | tableQz.addCell(cell); |
| | | |
| | | |
| | | cell = new PdfPCell(); |
| | | cell.setBorder(Rectangle.NO_BORDER); |
| | | cell.setVerticalAlignment(Element.ALIGN_MIDDLE); |
| | | cell.setHorizontalAlignment(Element.ALIGN_RIGHT); |
| | | cell.setPaddingTop(10); |
| | | cell.setPaddingBottom(10); |
| | | cell.setPhrase(new Phrase("总检医师:", zongJianTitleFont)); |
| | | tableQz.addCell(cell); |
| | | |
| | | cell = new PdfPCell(); |
| | | cell.setBorder(Rectangle.NO_BORDER); |
| | | cell.setVerticalAlignment(Element.ALIGN_MIDDLE); |
| | | cell.setHorizontalAlignment(Element.ALIGN_CENTER); |
| | | cell.setPaddingTop(10); |
| | | cell.setPaddingBottom(10); |
| | | // cell.setPhrase(new Phrase("何小婷", zongJianFont)); |
| | | cell.setPhrase(new Phrase(sysConfigService.selectConfigByKey("pdf_report_zongjianysname"), zongJianFont)); |
| | | tableQz.addCell(cell); |
| | | |
| | | cell = new PdfPCell(); |
| | | cell.setBorder(Rectangle.NO_BORDER); |
| | | cell.setVerticalAlignment(Element.ALIGN_MIDDLE); |
| | | cell.setHorizontalAlignment(Element.ALIGN_RIGHT); |
| | | cell.setPaddingTop(10); |
| | | cell.setPaddingBottom(10); |
| | | cell.setPhrase(new Phrase("总检日期:", zongJianTitleFont)); |
| | | tableQz.addCell(cell); |
| | | |
| | | cell = new PdfPCell(); |
| | | cell.setBorder(Rectangle.NO_BORDER); |
| | | cell.setVerticalAlignment(Element.ALIGN_MIDDLE); |
| | | cell.setHorizontalAlignment(Element.ALIGN_CENTER); |
| | | cell.setPaddingTop(10); |
| | | cell.setPaddingBottom(10); |
| | | cell.setPhrase(new Phrase(new SimpleDateFormat("yyyy-MM-dd").format(tjOrder.getCheckTime()), zongJianFont)); |
| | | tableQz.addCell(cell); |
| | | |
| | | document2.add(tableQz); |
| | | |
| | | document2.close(); |
| | | |
| | | |
| | | ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); |
| | | Document document = new Document(PageSize.A4); |
| | | PdfWriter pdfWriter = null; |
| | | // int pageSize = 0; |
| | | // try { |
| | | pdfWriter = PdfWriter.getInstance(document, byteArrayOutputStream); |
| | | 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, false); |
| | | } catch (DocumentException e) { |
| | | log.error("非化验项目填充表格异常"); |
| | | e.printStackTrace(); |
| | | log.error(String.valueOf(e)); |
| | | return AjaxResult.error(); |
| | | } |
| | | // 组装检验数据 |
| | | HashMap<String, Object> map = makeHisJianYan(tjOrder, customer); |
| | | makeHisJianYanTable(document1, map); |
| | | List<ByteArrayOutputStream> jianchas = makeHisJianChaTable(tjOrder); |
| | | document1.close(); |
| | | pdfWriter.close(); |
| | | PdfReader reader = null; |
| | | makeHisJianYanTable(document, map, dictHosp, color); |
| | | |
| | | printReport = new HashMap<>(); |
| | | pacsJianChaData(tjOrder.getTjNumber(), printReport, tjOrder, customer); |
| | | 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异常"); |
| | | e.printStackTrace(); |
| | | notHuaYanTable(document, printReport, dictHosp, color, true); |
| | | } catch (DocumentException e) { |
| | | log.error("pacs项目填充表格异常"); |
| | | log.error(String.valueOf(e)); |
| | | return AjaxResult.error(); |
| | | } |
| | | String outputFileName1 = customer.getCusId() + tjOrder.getTjNumber() + customer.getCusName() + "_报告.pdf"; |
| | | savePDFFile(outputFileName1,tjOrder, customer, finalOutPut); |
| | | TjReport tjReport = new TjReport(); |
| | | document.close(); |
| | | |
| | | |
| | | // 首页表单 |
| | | String tjNumber = tjOrder.getTjNumber(); |
| | | tjReport.setTjNumber(String.valueOf(tjNumber)); |
| | | tjReport.setPath(urlValue + outputFileName1); |
| | | // 文件配置 |
| | | // String outputPath1 = "/Users/chacca/开发相关/代码/"; |
| | | String outputPath1 = value+"\\"; |
| | | String pdfBinary = getPDFBinary(outputPath1 + outputFileName1); |
| | | tjReport.setReport(pdfBinary); |
| | | tjReport.setType("体检报告"); |
| | | tjReport.setPrint("pdf"); |
| | | tjReportService.save(tjReport); |
| | | LambdaUpdateWrapper<TjOrder> updateWrapper = new LambdaUpdateWrapper<>(); |
| | | updateWrapper.eq(TjOrder::getTjNumber, tjNumber); |
| | | updateWrapper.set(TjOrder::getReportTime, new Date()); |
| | | updateWrapper.set(TjOrder::getPrintLastTime, new Date()); |
| | | updateWrapper.set(TjOrder::getDownloadLastTime, new Date()); |
| | | updateWrapper.set(TjOrder::getStatus, TjConstants.TJ_END); |
| | | tjOrderService.update(updateWrapper); |
| | | 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(); |
| | | } |
| | | |
| | | public AjaxResult hisPDFNew2(TjOrder tjOrder, TjCustomer customer, TjReportTemplate tjReportTemplate, TjReportTemplate zongJianYiShiQianMing) throws Exception { |
| | | String s1 = sysConfigService.selectConfigByKey("tjreport_font_size_second_page_info"); |
| | | String s2 = sysConfigService.selectConfigByKey("tjreport_font_size_second_page_title"); |
| | | String s3 = sysConfigService.selectConfigByKey("tjreport_font_size_result_title"); |
| | | String s4 = sysConfigService.selectConfigByKey("tjreport_font_size_zongjian"); |
| | | // String hospName = sysDeptController.getdangqiandengluyuanqu().get("msg").toString(); |
| | | if (StrUtil.isNotBlank(s1) && Integer.parseInt(s1) > 10) DEFAULT_FONT_SIZE = Integer.parseInt(s1); |
| | | else DEFAULT_FONT_SIZE = 10; |
| | | if (StrUtil.isNotBlank(s2) && Integer.parseInt(s2) > 10) DEFAULT_LITTLE_TITLE_FONT_SIZE = Integer.parseInt(s2); |
| | | else DEFAULT_LITTLE_TITLE_FONT_SIZE = 10; |
| | | if (StrUtil.isNotBlank(s3) && Integer.parseInt(s3) > 10) DEFAULT_TITLE_FONT_SIZE = Integer.parseInt(s3); |
| | | else DEFAULT_TITLE_FONT_SIZE = 10; |
| | | if (StrUtil.isNotBlank(s4) && Integer.parseInt(s4) > 10) DEFAULT_ZONGJIAN_FONT_SIZE = Integer.parseInt(s4); |
| | | else DEFAULT_ZONGJIAN_FONT_SIZE = 10; |
| | | pdfPage = 0; |
| | | DictHosp dictHosp = dictHospService.list().get(0); |
| | | HOSP_NAME = dictHosp.getHospName(); |
| | | 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, 50); |
| | | document2.open(); |
| | | |
| | | List<CsProVo> list = tjOrderRemarkService.cSWebGetProByTjNumAndOrderId(tjOrder.getTjNumber(), false); |
| | | |
| | | Font defaultFont = PdfUtils.setFont(DEFAULT_FONT_SIZE); |
| | | Font defaultTitleFont = PdfUtils.setFont(DEFAULT_LITTLE_TITLE_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(i -> i.getDeptId() + "_" + i.getDeptName())); |
| | | // List<CsProVo> sortedList = list.stream() |
| | | // .sorted(Comparator.comparingLong(CsProVo::getProId)) |
| | | // .collect(Collectors.toList()); |
| | | for (Map.Entry<String, List<CsProVo>> entry : listMap.entrySet()) { |
| | | String dept = entry.getKey().split("_")[1]; |
| | | List<CsProVo> proVos = entry.getValue(); |
| | | proVos = proVos.stream() |
| | | .sorted(Comparator.comparingLong(CsProVo::getProId)) |
| | | .collect(Collectors.toList()); |
| | | 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); |
| | | if (proVos.size() > 1) |
| | | 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); |
| | | } |
| | | |
| | | |
| | | // List<TjOrderRemark> remarks = tjOrderRemarkMapper.getzongjianyishengchakanyichangxiangmu3( tjOrder.getTjNumber()); |
| | | List<TjOrderDetail> orderDetails = tjOrderDetailMapper.getzongjianyishengchakanyichangxiangmu4(tjOrder.getTjNumber()); |
| | | // List<Map<String, Object>> jiancha = new ArrayList<>(); |
| | | |
| | | |
| | | paragraph = PdfUtils.setParagraph(defaultTitleFont, "检查综述:"); |
| | | paragraph.setSpacingBefore(3f); |
| | | paragraph.setSpacingAfter(2f); |
| | | document2.add(paragraph); |
| | | |
| | | int xmXh = 1; |
| | | |
| | | Map<Long, List<TjOrderDetail>> collect = orderDetails.stream().collect(Collectors.groupingBy(TjOrderDetail::getProId)); |
| | | for (Map.Entry<String, List<CsProVo>> deptEntry : listMap.entrySet()) { |
| | | List<CsProVo> proVos = deptEntry.getValue(); |
| | | if (proVos.size() > 1) { |
| | | proVos = proVos.stream() |
| | | .sorted(Comparator.comparingLong(CsProVo::getProId)) |
| | | .collect(Collectors.toList()); |
| | | } |
| | | // 已经遍历过的 |
| | | ArrayList<String> jianYanYiDa = new ArrayList<>(); |
| | | for (CsProVo proVo : proVos) { |
| | | |
| | | // 检查 |
| | | for (Map.Entry<Long, List<TjOrderDetail>> entry : collect.entrySet()) { |
| | | if (!entry.getKey().equals(proVo.getProId())) continue; |
| | | List<TjOrderDetail> details = entry.getValue(); |
| | | String xmmc = details.get(0).getProName(); |
| | | boolean isXmWrite = false; |
| | | for (TjOrderDetail detail : details) { |
| | | if (!isXmWrite) { |
| | | paragraph = new Paragraph(xmXh + ". " + xmmc, defaultFont); |
| | | paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | document2.add(paragraph); |
| | | isXmWrite = true; |
| | | } |
| | | String result = detail.getProResult(); |
| | | if (StrUtil.isNotBlank(result)) { |
| | | int index = 1; |
| | | result = result.replaceAll("本报告仅对本次检查负责,临床医生依据病情如有疑问,请及时复查或进一步检查", ""); |
| | | // result = result.replaceAll("", ""); |
| | | String[] split = result.split("\n"); |
| | | StringBuilder builder = new StringBuilder(); |
| | | for (String s : split) { |
| | | if (StrUtil.isBlank(s.replaceAll("\n", "").trim())) continue; |
| | | builder.append(" (").append(index).append(")").append(s).append("\n"); |
| | | index++; |
| | | } |
| | | result = builder.toString(); |
| | | } |
| | | paragraph = new Paragraph(result, defaultFont); |
| | | paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | document2.add(paragraph); |
| | | } |
| | | if (isXmWrite) { |
| | | paragraph = PdfUtils.setParagraph(defaultFont, ""); |
| | | paragraph.setLeading(0f); |
| | | paragraph.setSpacingBefore(0f); |
| | | paragraph.setSpacingAfter(5f); |
| | | document2.add(paragraph); |
| | | xmXh++; |
| | | } |
| | | } |
| | | |
| | | // 检验 |
| | | 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.get(6).contains(String.valueOf(proVo.getProId()))) continue; |
| | | if (i.contains("↓") || i.contains("↑")) { |
| | | if (jianYanYiDa.contains(i.get(5))) continue; |
| | | jianYanYiDa.add(i.get(5)); |
| | | if (!isXmWrite) { |
| | | paragraph = new Paragraph(xmXh + ". " + 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) + " " + i.get(2); |
| | | paragraph = new Paragraph(content, defaultFont); |
| | | paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | document2.add(paragraph); |
| | | index++; |
| | | } |
| | | } |
| | | if (isXmWrite) { |
| | | paragraph = PdfUtils.setParagraph(defaultFont, ""); |
| | | paragraph.setSpacingBefore(0f); |
| | | paragraph.setSpacingAfter(5f); |
| | | document2.add(paragraph); |
| | | xmXh++; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | paragraph = PdfUtils.setParagraph(defaultFont, ""); |
| | | paragraph.setLeading(0f); |
| | | paragraph.setSpacingBefore(10f); |
| | | paragraph.setSpacingAfter(10f); |
| | | document2.add(paragraph); |
| | | paragraph = PdfUtils.setParagraph(defaultTitleFont, "医生建议:"); |
| | | paragraph.setSpacingBefore(3f); |
| | | paragraph.setSpacingAfter(2f); |
| | | document2.add(paragraph); |
| | | xmXh = 0; |
| | | LambdaQueryWrapper<TjOrderYcxm> wq = new LambdaQueryWrapper<>(); |
| | | wq.eq(TjOrderYcxm::getTjh, tjOrder.getTjNumber()); |
| | | List<TjOrderYcxm> ycxms = ycxmService.list(wq); |
| | | if (null != ycxms && !ycxms.isEmpty()) { |
| | | for (Map.Entry<String, List<CsProVo>> deptEntry : listMap.entrySet()) { |
| | | List<CsProVo> proVos = deptEntry.getValue(); |
| | | if (proVos.size() > 1) { |
| | | proVos = proVos.stream() |
| | | .sorted(Comparator.comparingLong(CsProVo::getProId)) |
| | | .collect(Collectors.toList()); |
| | | } |
| | | ArrayList<String> jianYanYiDa = new ArrayList<>(); |
| | | for (CsProVo proVo : proVos) { |
| | | // 检查 |
| | | for (Map.Entry<Long, List<TjOrderDetail>> entry : collect.entrySet()) { |
| | | if (!entry.getKey().equals(proVo.getProId())) continue; |
| | | List<TjOrderDetail> details = entry.getValue(); |
| | | if(null !=details && !details.isEmpty()){ |
| | | boolean isXmWrite = false; |
| | | int index = 1; |
| | | int index1 = 1; |
| | | for (TjOrderDetail detail : details) { |
| | | String xmmc = detail.getProName(); |
| | | if (!isXmWrite) { |
| | | xmXh++; |
| | | paragraph = new Paragraph("【" + xmXh + "." + xmmc + "】", defaultFont); |
| | | paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | document2.add(paragraph); |
| | | isXmWrite = true; |
| | | } |
| | | String result = detail.getProResult(); |
| | | if (StrUtil.isNotBlank(result)) { |
| | | String[] split = result.split("\n"); |
| | | StringBuilder builder = new StringBuilder(); |
| | | for (String s : split) { |
| | | if (StrUtil.isBlank(s.replaceAll("\n", "").trim())) continue; |
| | | builder.append(" (").append(index1).append(")").append(s).append("\n"); |
| | | index1++; |
| | | } |
| | | result = builder.toString(); |
| | | } |
| | | if (StrUtil.isNotBlank(result)) { |
| | | paragraph = new Paragraph(result, defaultFont); |
| | | paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | document2.add(paragraph); |
| | | } else { |
| | | paragraph = new Paragraph("建议定期复查", defaultFont); |
| | | paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | document2.add(paragraph); |
| | | } |
| | | String str = " "; |
| | | List<Map<String, Object>> maps = new ArrayList<>(); |
| | | |
| | | LambdaQueryWrapper<TjOrderYcxm> ycwq=new LambdaQueryWrapper<>(); |
| | | ycwq.eq(TjOrderYcxm::getTjh,tjOrder.getTjNumber()); |
| | | ycwq.eq(TjOrderYcxm::getJcxm,xmmc); |
| | | TjOrderYcxm ycxm = ycxmService.getOne(ycwq); |
| | | if(null !=ycxm){ |
| | | String jynr = ycxm.getJynr(); |
| | | JSONArray array = JSONUtil.parseArray(jynr); |
| | | for (Object object : array) { |
| | | Map<String,Object> objectMap=new HashMap<>(); |
| | | JSONObject jsonObject = (JSONObject) object; |
| | | String bt = jsonObject.getStr("bt"); |
| | | String nr = jsonObject.getStr("nr"); |
| | | objectMap.put("bt",bt); |
| | | objectMap.put("nr",nr); |
| | | if(null !=bt || null !=nr) maps.add(objectMap); |
| | | } |
| | | List<Map<String, Object>> collect1 = maps.stream().distinct().collect(Collectors.toList()); |
| | | for (Map<String, Object> objectMap : collect1) { |
| | | String content = str + objectMap.get("bt").toString() + objectMap.get("nr").toString(); |
| | | if (StrUtil.isBlank(content)) content = " "; |
| | | paragraph = new Paragraph(content, defaultFont); |
| | | paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | document2.add(paragraph); |
| | | } |
| | | } |
| | | index++; |
| | | paragraph = PdfUtils.setParagraph(defaultFont, ""); |
| | | paragraph.setLeading(0f); |
| | | paragraph.setSpacingBefore(0f); |
| | | paragraph.setSpacingAfter(5f); |
| | | 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.get(6).contains(String.valueOf(proVo.getProId()))) continue; |
| | | if (i.contains("↓") || i.contains("↑")) { |
| | | if (jianYanYiDa.contains(i.get(5))) continue; |
| | | jianYanYiDa.add(i.get(5)); |
| | | if (!isXmWrite) { |
| | | xmXh++; |
| | | paragraph = new Paragraph("【" + xmXh + "." + 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) + " " + i.get(2); |
| | | paragraph = new Paragraph(content, defaultFont); |
| | | paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | document2.add(paragraph); |
| | | String str = " "; |
| | | |
| | | LambdaQueryWrapper<TjOrderYcxm> ycwq=new LambdaQueryWrapper<>(); |
| | | ycwq.eq(TjOrderYcxm::getTjh,tjOrder.getTjNumber()); |
| | | ycwq.eq(TjOrderYcxm::getJcxm,i.get(0)); |
| | | TjOrderYcxm ycxm = ycxmService.getOne(ycwq); |
| | | if(null !=ycxm){ |
| | | String jynr = ycxm.getJynr(); |
| | | JSONArray array = JSONUtil.parseArray(jynr); |
| | | for (Object object : array) { |
| | | JSONObject jsonObject = (JSONObject) object; |
| | | String bt = jsonObject.getStr("bt"); |
| | | String nr = jsonObject.getStr("nr"); |
| | | if(null !=bt || null !=nr) { |
| | | String content1 = str + bt + nr; |
| | | if (StrUtil.isBlank(content)) content1 = " "; |
| | | paragraph = new Paragraph(content1, defaultFont); |
| | | } |
| | | paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | document2.add(paragraph); |
| | | } |
| | | paragraph = PdfUtils.setParagraph(defaultFont, ""); |
| | | paragraph.setSpacingBefore(2f); |
| | | paragraph.setSpacingAfter(5f); |
| | | document2.add(paragraph); |
| | | index++; |
| | | } |
| | | } |
| | | } |
| | | if (isXmWrite) { |
| | | paragraph = PdfUtils.setParagraph(defaultFont, ""); |
| | | paragraph.setSpacingBefore(0f); |
| | | paragraph.setSpacingAfter(5f); |
| | | document2.add(paragraph); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } else { |
| | | for (Map.Entry<String, List<CsProVo>> deptEntry : listMap.entrySet()) { |
| | | List<CsProVo> proVos = deptEntry.getValue(); |
| | | if (proVos.size() > 1) { |
| | | proVos = proVos.stream() |
| | | .sorted(Comparator.comparingLong(CsProVo::getProId)) |
| | | .collect(Collectors.toList()); |
| | | } |
| | | ArrayList<String> jianYanYiDa = new ArrayList<>(); |
| | | for (CsProVo proVo : proVos) { |
| | | // 检查 |
| | | for (Map.Entry<Long, List<TjOrderDetail>> entry : collect.entrySet()) { |
| | | if (!entry.getKey().equals(proVo.getProId())) continue; |
| | | List<TjOrderDetail> details = entry.getValue(); |
| | | String xmmc = details.get(0).getProName(); |
| | | boolean isXmWrite = false; |
| | | int index = 1; |
| | | for (TjOrderDetail detail : details) { |
| | | if (!isXmWrite) { |
| | | xmXh++; |
| | | paragraph = new Paragraph("【" + xmXh + "." + xmmc + "】", defaultFont); |
| | | paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | document2.add(paragraph); |
| | | isXmWrite = true; |
| | | } |
| | | String result = detail.getProResult(); |
| | | if (StrUtil.isNotBlank(result)) { |
| | | // result = result.replaceAll(" ","").replaceAll("\t",""); |
| | | // result = result.replaceAll("\n本报告仅对本次检查负责,临床医生依据病情如有疑问,请及时复查或进一步检查", ""); |
| | | // result = "\n " + result.replaceAll("\n", "\n "); |
| | | int index1 = 1; |
| | | String[] split = result.split("\n"); |
| | | // boolean contains = result.contains("本报告仅对本次检查负责,临床医生依据病情如有疑问,请及时复查或进一步检查"); |
| | | boolean contains = result.contains(" "); |
| | | StringBuilder builder = new StringBuilder(); |
| | | for (String s : split) { |
| | | if (StrUtil.isBlank(s.replaceAll("\n", "").trim())) continue; |
| | | builder.append(" (").append(index1).append(")").append(s).append("\n"); |
| | | index1++; |
| | | } |
| | | // if (!contains) builder.append(" (").append(index1).append(")").append("本报告仅对本次检查负责,临床医生依据病情如有疑问,请及时复查或进一步检查"); |
| | | // if (!contains) builder.append(" (").append(index1).append(")").append(" "); |
| | | // else builder.substring(0,builder.length() - 1); |
| | | result = builder.toString(); |
| | | } |
| | | // String content = " (" + index + ") " + detail.getProName() + ":" + result; |
| | | // content = content.replaceAll("[\\n\\r]+$", ""); |
| | | // content = content.replaceAll("\\s+$", ""); |
| | | // paragraph = new Paragraph(content, defaultFont); |
| | | if (StrUtil.isNotBlank(result)) { |
| | | paragraph = new Paragraph(result, defaultFont); |
| | | paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | document2.add(paragraph); |
| | | } else { |
| | | paragraph = new Paragraph("建议定期复查", defaultFont); |
| | | paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | document2.add(paragraph); |
| | | } |
| | | String str = " "; |
| | | // List<Map<String, Object>> maps = tjRulesService.getyichangxiangmujianyiguize(entry.getKey().toString(),"", |
| | | // detail.getYcbz(),tjOrder.getTjNumber(),detail.getProName().replaceAll("[((][^))]*[))]", "") |
| | | // .replaceAll("[ 测定检测]",""),detail.getProResult()); |
| | | List<Map<String, Object>> maps = new ArrayList<>(); |
| | | if (detail.getDeptId().equals("2")) { |
| | | String[] split = result.split("。|,|,"); |
| | | for (String s : split) { |
| | | s = s.replaceAll("\n", "").replaceAll("[((][^))]*[))]", ""); |
| | | // Map<String,Object> mapss= tjRulesService.getyichangxiangmujianyiguizeJianCha(s); |
| | | Map<String, Object> mapss = tjProAdvicerulesService.getyichangxiangmujianyiguizeJianCha(detail.getKs(), s, "0"); |
| | | if (null != mapss) { |
| | | Object bt = mapss.get("bt"); |
| | | Object nr = mapss.get("nr"); |
| | | if (null != bt && null != nr) maps.add(mapss); |
| | | } |
| | | } |
| | | } |
| | | List<Map<String, Object>> collect1 = maps.stream().distinct().collect(Collectors.toList()); |
| | | |
| | | for (Map<String, Object> objectMap : collect1) { |
| | | String content = str + objectMap.get("bt").toString() + objectMap.get("nr").toString(); |
| | | // if (StrUtil.isBlank(content)) content = " 本报告仅对本次检查负责,临床医生依据病情如有疑问,请及时复查或进一步检查"; |
| | | if (StrUtil.isBlank(content)) content = " "; |
| | | paragraph = new Paragraph(content, defaultFont); |
| | | paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | document2.add(paragraph); |
| | | } |
| | | index++; |
| | | paragraph = PdfUtils.setParagraph(defaultFont, ""); |
| | | paragraph.setLeading(0f); |
| | | paragraph.setSpacingBefore(0f); |
| | | paragraph.setSpacingAfter(5f); |
| | | 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.get(6).contains(String.valueOf(proVo.getProId()))) continue; |
| | | if (i.contains("↓") || i.contains("↑")) { |
| | | if (jianYanYiDa.contains(i.get(5))) continue; |
| | | jianYanYiDa.add(i.get(5)); |
| | | if (!isXmWrite) { |
| | | xmXh++; |
| | | paragraph = new Paragraph("【" + xmXh + "." + 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) + " " + i.get(2); |
| | | paragraph = new Paragraph(content, defaultFont); |
| | | paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | document2.add(paragraph); |
| | | // 第六位是lis项目id |
| | | // LambdaQueryWrapper<TjProject> wrapper = new LambdaQueryWrapper<>(); |
| | | // wrapper.eq(TjProject::getLisXmbm,i.get(5)); |
| | | // TjProject project = projectService.getOne(wrapper); |
| | | // if (project != null) { |
| | | // LambdaQueryWrapper<TjRules> queryWrapper = new LambdaQueryWrapper<>(); |
| | | // queryWrapper.eq(TjRules::getProId,project.getProId()); |
| | | // List<TjRules> rules = tjRulesService.list(queryWrapper); |
| | | // if (!rules.isEmpty()){ |
| | | // |
| | | // } |
| | | 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)); |
| | | if (!maps.isEmpty()) { |
| | | for (Map<String, Object> objectMap : maps) { |
| | | // paragraph = new Paragraph(str+"建议标题",defaultFont); |
| | | // paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | // document2.add(paragraph); |
| | | // |
| | | // paragraph = new Paragraph(str+objectMap.get("bt").toString(),defaultFont); |
| | | // paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | // document2.add(paragraph); |
| | | // |
| | | // paragraph = new Paragraph(str+"建议内容",defaultFont); |
| | | // paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | // document2.add(paragraph); |
| | | // |
| | | // paragraph = new Paragraph(str+objectMap.get("nr").toString(),defaultFont); |
| | | // paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | // document2.add(paragraph); |
| | | Object bt = objectMap.get("bt"); |
| | | Object nr = objectMap.get("nr"); |
| | | if (null != bt && null != nr) { |
| | | String content1 = str + bt.toString() + nr.toString().trim(); |
| | | if (StrUtil.isBlank(content)) content1 = " "; |
| | | paragraph = new Paragraph(content1, defaultFont); |
| | | } |
| | | // if (StrUtil.isBlank(content)) content1 = " 本报告仅对本次检查负责,临床医生依据病情如有疑问,请及时复查或进一步检查"; |
| | | paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | document2.add(paragraph); |
| | | } |
| | | paragraph = PdfUtils.setParagraph(defaultFont, ""); |
| | | paragraph.setSpacingBefore(2f); |
| | | paragraph.setSpacingAfter(5f); |
| | | document2.add(paragraph); |
| | | } |
| | | // } |
| | | index++; |
| | | } |
| | | } |
| | | if (isXmWrite) { |
| | | paragraph = PdfUtils.setParagraph(defaultFont, ""); |
| | | paragraph.setSpacingBefore(0f); |
| | | paragraph.setSpacingAfter(5f); |
| | | document2.add(paragraph); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | for (int i = 0; i < 1; 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 paragraphs = new Paragraph(tjOrder.getCheckAdvice(), defaultFont); |
| | | //设置文字居中 |
| | | paragraphs.setAlignment(Element.ALIGN_LEFT); |
| | | //行间距 |
| | | // paragraphs.setLeading(5f); |
| | | //设置段落上空白 |
| | | paragraphs.setSpacingBefore(10f); |
| | | //设置段落下空白 |
| | | paragraphs.setSpacingAfter(10f); |
| | | // paragraph = PdfUtils.setParagraph(defaultFont, tjOrder.getCheckAdvice()); |
| | | document2.add(paragraphs); |
| | | } |
| | | |
| | | |
| | | Paragraph paragraphNone = new Paragraph("", defaultFont); |
| | | paragraphNone.setAlignment(Element.ALIGN_LEFT); |
| | | //行间距 |
| | | paragraphNone.setLeading(5f); |
| | | paragraphNone.setSpacingBefore(10f); |
| | | paragraphNone.setSpacingAfter(10f); |
| | | document2.add(paragraphNone); |
| | | paragraphNone = new Paragraph("", defaultFont); |
| | | paragraphNone.setAlignment(Element.ALIGN_LEFT); |
| | | //行间距 |
| | | paragraphNone.setLeading(5f); |
| | | paragraphNone.setSpacingBefore(10f); |
| | | paragraphNone.setSpacingAfter(10f); |
| | | document2.add(paragraphNone); |
| | | |
| | | |
| | | PdfPTable tableQz = new PdfPTable(new float[]{100f, 100f, 50f}); |
| | | tableQz.setTotalWidth(PageSize.A4.getWidth() - 100); |
| | | tableQz.setLockedWidth(true); |
| | | tableQz.setHorizontalAlignment(Element.ALIGN_LEFT); |
| | | tableQz.getDefaultCell().setBorder(0); |
| | | tableQz.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT); |
| | | |
| | | Font zongJianFont = PdfUtils.setFont(DEFAULT_ZONGJIAN_FONT_SIZE); |
| | | Font zongJianTitleFont = PdfUtils.setFont(DEFAULT_ZONGJIAN_FONT_SIZE); |
| | | zongJianTitleFont.setStyle(Font.BOLD); |
| | | |
| | | for (int i = 0; i < 3; i++) { |
| | | PdfPCell cell = new PdfPCell(); |
| | | cell.setVerticalAlignment(Element.ALIGN_MIDDLE); |
| | | cell.setHorizontalAlignment(Element.ALIGN_RIGHT); |
| | | cell.setPhrase(new Phrase("", defaultFont)); |
| | | cell.setBorder(Rectangle.NO_BORDER); |
| | | tableQz.addCell(cell); |
| | | } |
| | | |
| | | |
| | | PdfPCell cell = new PdfPCell(); |
| | | cell.setBorder(Rectangle.NO_BORDER); |
| | | cell.setVerticalAlignment(Element.ALIGN_MIDDLE); |
| | | cell.setHorizontalAlignment(Element.ALIGN_RIGHT); |
| | | cell.setPhrase(new Phrase("", defaultFont)); |
| | | cell.setRowspan(3); |
| | | tableQz.addCell(cell); |
| | | |
| | | cell = new PdfPCell(); |
| | | cell.setBorder(Rectangle.NO_BORDER); |
| | | cell.setVerticalAlignment(Element.ALIGN_MIDDLE); |
| | | cell.setHorizontalAlignment(Element.ALIGN_RIGHT); |
| | | cell.setPaddingTop(10); |
| | | cell.setPaddingBottom(10); |
| | | cell.setPhrase(new Phrase("体检单位盖章:", zongJianTitleFont)); |
| | | |
| | | tableQz.addCell(cell); |
| | | |
| | | File file = new File(value + File.separator + "yinzhang.png"); |
| | | cell = new PdfPCell(); |
| | | cell.setBorder(Rectangle.NO_BORDER); |
| | | cell.setVerticalAlignment(Element.ALIGN_MIDDLE); |
| | | cell.setHorizontalAlignment(Element.ALIGN_RIGHT); |
| | | cell.setPaddingTop(10); |
| | | cell.setPaddingBottom(10); |
| | | if (!file.exists()) { |
| | | cell.setPhrase(new Phrase("", zongJianFont)); |
| | | }else { |
| | | FileInputStream fileInputStream = new FileInputStream(file); |
| | | byte[] fileBytes = new byte[(int) file.length()]; |
| | | fileInputStream.read(fileBytes); |
| | | fileInputStream.close(); |
| | | Image image = Image.getInstance(Base64.getDecoder().decode(Base64.getEncoder().encodeToString(fileBytes))); |
| | | image.scaleToFit(90, 90); |
| | | cell.addElement(image); |
| | | } |
| | | tableQz.addCell(cell); |
| | | |
| | | cell = new PdfPCell(); |
| | | cell.setBorder(Rectangle.NO_BORDER); |
| | | cell.setVerticalAlignment(Element.ALIGN_MIDDLE); |
| | | cell.setHorizontalAlignment(Element.ALIGN_RIGHT); |
| | | cell.setPaddingTop(10); |
| | | cell.setPaddingBottom(10); |
| | | cell.setPhrase(new Phrase("总检医师:", zongJianTitleFont)); |
| | | tableQz.addCell(cell); |
| | | |
| | | |
| | | cell = new PdfPCell(); |
| | | cell.setBorder(Rectangle.NO_BORDER); |
| | | cell.setVerticalAlignment(Element.ALIGN_MIDDLE); |
| | | cell.setHorizontalAlignment(Element.ALIGN_CENTER); |
| | | cell.setPaddingTop(10); |
| | | cell.setPaddingBottom(10); |
| | | String zongjianysname = sysConfigService.selectConfigByKey("pdf_report_zongjianysname"); |
| | | if (zongJianYiShiQianMing == null && StrUtil.isNotBlank(zongjianysname) && !zongjianysname.equals("无")) { |
| | | cell.setPhrase(new Phrase(zongjianysname, zongJianFont)); |
| | | tableQz.addCell(cell); |
| | | } else if (zongJianYiShiQianMing == null && zongjianysname.equals("无")) { |
| | | String nickName = SecurityUtils.getLoginUser().getUser().getNickName(); |
| | | cell.setPhrase(new Phrase(nickName, zongJianFont)); |
| | | tableQz.addCell(cell); |
| | | } else { |
| | | byte[] bytes = Base64.getDecoder().decode(zongJianYiShiQianMing.getTemplate()); |
| | | Image image = Image.getInstance(bytes); |
| | | image.scaleToFit(100, 100); |
| | | cell.addElement(image); |
| | | tableQz.addCell(cell); |
| | | } |
| | | |
| | | cell = new PdfPCell(); |
| | | cell.setBorder(Rectangle.NO_BORDER); |
| | | cell.setVerticalAlignment(Element.ALIGN_MIDDLE); |
| | | cell.setHorizontalAlignment(Element.ALIGN_RIGHT); |
| | | cell.setPaddingTop(10); |
| | | cell.setPaddingBottom(10); |
| | | cell.setPhrase(new Phrase("总检日期:", zongJianTitleFont)); |
| | | tableQz.addCell(cell); |
| | | |
| | | cell = new PdfPCell(); |
| | | cell.setBorder(Rectangle.NO_BORDER); |
| | | cell.setVerticalAlignment(Element.ALIGN_MIDDLE); |
| | | cell.setHorizontalAlignment(Element.ALIGN_CENTER); |
| | | cell.setPaddingTop(10); |
| | | cell.setPaddingBottom(10); |
| | | cell.setPhrase(new Phrase(new SimpleDateFormat("yyyy-MM-dd").format(tjOrder.getCheckTime()), zongJianFont)); |
| | | tableQz.addCell(cell); |
| | | |
| | | document2.add(tableQz); |
| | | |
| | | document2.close(); |
| | | |
| | | |
| | | ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); |
| | | Document document = new Document(PageSize.A4); |
| | | PdfWriter pdfWriter = null; |
| | | // int pageSize = 0; |
| | | // try { |
| | | pdfWriter = PdfWriter.getInstance(document, byteArrayOutputStream); |
| | | 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, false); |
| | | } catch (DocumentException e) { |
| | | log.error("非化验项目填充表格异常"); |
| | | log.error(String.valueOf(e)); |
| | | return AjaxResult.error(); |
| | | } |
| | | PdfReader reader = null; |
| | | makeHisJianYanTable(document, map, dictHosp, color); |
| | | |
| | | printReport = new HashMap<>(); |
| | | pacsJianChaData(tjOrder.getTjNumber(), printReport, tjOrder, customer); |
| | | try { |
| | | notHuaYanTable(document, printReport, dictHosp, color, true); |
| | | } catch (DocumentException e) { |
| | | log.error("pacs项目填充表格异常"); |
| | | log.error(String.valueOf(e)); |
| | | return AjaxResult.error(); |
| | | } |
| | | document.close(); |
| | | |
| | | |
| | | // 首页表单 |
| | | String tjNumber = tjOrder.getTjNumber(); |
| | | String template = tjReportTemplate.getTemplate(); |
| | | |
| | | 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 (StrUtil.isNotBlank(tjOrder.getFirmName())) { |
| | | hashMap.put("work", tjOrder.getFirmName()); |
| | | } else { |
| | | // LambdaQueryWrapper<DictComp> wq111 = new LambdaQueryWrapper<>(); |
| | | // wq111.eq(DictComp::getDrugManufacturerId, tjOrder.getFirmId()); |
| | | // DictComp dictComp = dictCompService.getOne(wq111); |
| | | |
| | | if (StrUtil.isBlank(tjOrder.getFirmName())) { |
| | | hashMap.put("work", "无"); |
| | | } else { |
| | | hashMap.put("work", tjOrder.getFirmName()); |
| | | } |
| | | } |
| | | if (StrUtil.isBlank(tjOrder.getFirmDeptName())) { |
| | | hashMap.put("bumen", "无"); |
| | | } else { |
| | | hashMap.put("bumen", tjOrder.getFirmDeptName()); |
| | | } |
| | | 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(); |
| | | } |
| | | |
| | | /** |
| | | * 生成检查表格 |
| | | * |
| | | * @param tjOrder |
| | | * @return |
| | | */ |
| | | private List<ByteArrayOutputStream> makeHisJianChaTable(TjOrder tjOrder) { |
| | | private List<ByteArrayOutputStream> makeHisJianChaTable(TjOrder tjOrder) throws Exception { |
| | | LambdaQueryWrapper<LtkjGetexamreportinfo> lambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | lambdaQueryWrapper.eq(LtkjGetexamreportinfo::getHisRegistrationId, tjOrder.getCardId()); |
| | | lambdaQueryWrapper.eq(LtkjGetexamreportinfo::getRequestParamsHisRegistrationId, tjOrder.getCardId()); |
| | | lambdaQueryWrapper.groupBy(LtkjGetexamreportinfo::getJcbgid); |
| | | List<LtkjGetexamreportinfo> list = ltkjGetexamreportinfoService.list(lambdaQueryWrapper); |
| | | // List<LtkjGetexamreportinfo> list = ltkjGetexamreportinfoService.list(); |
| | | List<ByteArrayOutputStream> jianchas = new ArrayList<>(); |
| | | Paragraph elements = new Paragraph(); |
| | | elements.setLeading(5f); |
| | | elements.setSpacingBefore(10f); |
| | | elements.setSpacingAfter(10f); |
| | | elements.setAlignment(Element.ALIGN_RIGHT); |
| | | Phrase phrase = new Phrase(); |
| | | Font doctorFonts = PdfUtils.setFont(11); |
| | | for (LtkjGetexamreportinfo getexamreportinfo : list) { |
| | | String xm = getexamreportinfo.getHzxm(); |
| | | String xb = getexamreportinfo.getHzxb().equals("2") ? "女" : "男"; |
| | |
| | | String sqrxm = getexamreportinfo.getSqrxm(); |
| | | String zyh = ""; |
| | | String ch = ""; |
| | | String footer = "申请人:"+sqrxm + " 审核医师:"+shysqm+" 医师签名:"+bgysqm; |
| | | ByteArrayOutputStream outputStream = makeJcPDFByteArrayStream(xm, xb, nl, jcks, zyh, ch, sjks, jcsb, jch, jcxm, ms, ts, null,footer); |
| | | String sqrbh = getexamreportinfo.getSqrbh(); |
| | | String shysbh = getexamreportinfo.getShysbh(); |
| | | String bgysbh = getexamreportinfo.getBgysbh(); |
| | | String jcysqm = getexamreportinfo.getJcysqm(); |
| | | String jcysbh = getexamreportinfo.getJcysbh(); |
| | | StringBuilder builder; |
| | | String footer; |
| | | // 检查返回的医师编码不属于his医师id 暂注释 |
| | | // String key = sysConfigService.selectConfigByKey("is_report_pdf_use_ysqm"); |
| | | // if (key.equals("Y")){ |
| | | // footer = null; |
| | | // if (null != sqrbh && StrUtil.isNotBlank(sqrbh)){ |
| | | // makeYiShiInfoLine(phrase, doctorFonts, sqrxm, sqrbh,"申请人:"); |
| | | // } |
| | | // if (null != jcysbh && StrUtil.isNotBlank(jcysbh)){ |
| | | // makeYiShiInfoLine(phrase, doctorFonts, jcysqm, jcysbh," 检查医师:"); |
| | | // } |
| | | // if (null != shysbh && StrUtil.isNotBlank(shysbh)){ |
| | | // makeYiShiInfoLine(phrase, doctorFonts, shysqm, shysbh," 审核医师:"); |
| | | // } |
| | | // if (null != bgysbh && StrUtil.isNotBlank(bgysbh)){ |
| | | // makeYiShiInfoLine(phrase, doctorFonts, bgysqm, bgysbh," 报告医师:"); |
| | | // } |
| | | // }else { |
| | | builder = new StringBuilder(); |
| | | if (null != sqrxm && StrUtil.isNotBlank(sqrxm)) { |
| | | builder.append("申请人:").append(sqrxm); |
| | | } |
| | | if (null != jcysqm && StrUtil.isNotBlank(jcysqm)) { |
| | | builder.append(" 检查医师:").append(jcysqm); |
| | | } |
| | | if (null != shysqm && StrUtil.isNotBlank(shysqm)) { |
| | | builder.append(" 审核医师:").append(shysqm); |
| | | } |
| | | if (null != bgysqm && StrUtil.isNotBlank(bgysqm)) { |
| | | builder.append(" 报告医师:").append(bgysqm); |
| | | } |
| | | footer = builder.toString().trim(); |
| | | // } |
| | | // elements.add(phrase); |
| | | ByteArrayOutputStream outputStream = makeJcPDFByteArrayStream(xm, xb, nl, jcks, zyh, ch, sjks, jcsb, jch, jcxm, ms, ts, null, footer, elements); |
| | | if (outputStream == null) |
| | | throw new Exception(); |
| | | jianchas.add(outputStream); |
| | | } |
| | | return jianchas; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 生成检查表格存储过程时用 |
| | | * |
| | | * @param tjOrder |
| | | * @return |
| | | */ |
| | | private List<ByteArrayOutputStream> makeCcgcHisJianChaTable(TjOrder tjOrder) throws Exception { |
| | | |
| | | TjCustomer customer = tjCustomerService.getById(tjOrder.getUserId()); |
| | | |
| | | List<LtkjExamJcbgd> list = jcbgdService.getJianJcBaoGaoDanByTjh(tjOrder.getCardId()); |
| | | |
| | | List<ByteArrayOutputStream> jianchas = new ArrayList<>(); |
| | | Paragraph elements = new Paragraph(); |
| | | elements.setLeading(5f); |
| | | elements.setSpacingBefore(10f); |
| | | elements.setSpacingAfter(10f); |
| | | elements.setAlignment(Element.ALIGN_RIGHT); |
| | | |
| | | for (LtkjExamJcbgd getexamreportinfo : list) { |
| | | String xm = customer.getCusName(); |
| | | String xb = customer.getCusSex() == 2 ? "女" : "男"; |
| | | String nl = customer.getAge(); |
| | | String jcks = "体检中心"; |
| | | String sjks = ""; |
| | | String jcsb = ""; |
| | | String jch = getexamreportinfo.getTmh(); |
| | | String jcxm = getexamreportinfo.getXmmc(); |
| | | String ms = getexamreportinfo.getYxbx(); |
| | | String ts = getexamreportinfo.getYxzd(); |
| | | String bgysqm = getexamreportinfo.getShysxm(); |
| | | String shysqm = getexamreportinfo.getShysdm(); |
| | | String sqrxm = "王健萍"; |
| | | String zyh = ""; |
| | | String ch = ""; |
| | | String jcysqm = getexamreportinfo.getShysdm(); |
| | | StringBuilder builder; |
| | | String footer; |
| | | builder = new StringBuilder(); |
| | | if (null != sqrxm && StrUtil.isNotBlank(sqrxm)) { |
| | | builder.append("申请人:").append(sqrxm); |
| | | } |
| | | if (null != jcysqm && StrUtil.isNotBlank(jcysqm)) { |
| | | builder.append(" 检查医师:").append(jcysqm); |
| | | } |
| | | if (null != shysqm && StrUtil.isNotBlank(shysqm)) { |
| | | builder.append(" 审核医师:").append(shysqm); |
| | | } |
| | | if (null != bgysqm && StrUtil.isNotBlank(bgysqm)) { |
| | | builder.append(" 报告医师:").append(bgysqm); |
| | | } |
| | | footer = builder.toString().trim(); |
| | | ByteArrayOutputStream outputStream = makeJcPDFByteArrayStream(xm, xb, nl, jcks, zyh, ch, sjks, jcsb, jch, jcxm, ms, ts, null, footer, elements); |
| | | if (outputStream == null) |
| | | throw new Exception(); |
| | | jianchas.add(outputStream); |
| | | } |
| | | return jianchas; |
| | | } |
| | | |
| | | /** |
| | | * PDF文件存储至本地 |
| | | * @param tjOrder |
| | | * @param customer |
| | | * @param finalOutPut |
| | | * 医师信息行 |
| | | * |
| | | * @param phrase |
| | | * @param doctorFonts |
| | | * @param sqrxm |
| | | * @param sqrbh |
| | | * @throws BadElementException |
| | | */ |
| | | private void savePDFFile(String outputFileName1,TjOrder tjOrder, TjCustomer customer, ByteArrayOutputStream finalOutPut) { |
| | | // 文件配置 |
| | | // String outputPath1 = "/Users/chacca/开发相关/代码/"; |
| | | String outputPath1 = value+"\\"; |
| | | File file = new File(outputPath1 + outputFileName1); |
| | | BufferedOutputStream outputStream = null; |
| | | try { |
| | | outputStream = new BufferedOutputStream(new FileOutputStream(file)); |
| | | outputStream.write(finalOutPut.toByteArray()); |
| | | outputStream.flush(); |
| | | outputStream.close(); |
| | | finalOutPut.close(); |
| | | } catch (IOException e) { |
| | | log.error("本地存储pdf异常"); |
| | | e.printStackTrace(); |
| | | private void makeYiShiInfoLine(Phrase phrase, Font doctorFonts, String sqrxm, String sqrbh, String title) throws BadElementException { |
| | | String qmImg = dictUserInfoMapper.selectQmImgInnerJoinUserByHisDictCode(sqrbh); |
| | | // String qmImg = dictUserInfoMapper.selectQmImgInnerJoinUserByUserId(sqrbh); |
| | | if (null != qmImg && StrUtil.isNotBlank(qmImg)) { |
| | | byte[] decode = Base64.getDecoder().decode(qmImg); |
| | | Image image = null; |
| | | try { |
| | | image = Image.getInstance(decode); |
| | | image.scaleToFit(60, 25); |
| | | phrase.add(new Chunk(title, doctorFonts)); |
| | | phrase.add(new Chunk(image, 0, -10, true)); |
| | | } catch (IOException e) { |
| | | phrase.add(new Chunk(title + sqrxm, doctorFonts)); |
| | | } |
| | | } else { |
| | | phrase.add(new Chunk(title + sqrxm, doctorFonts)); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * PDF文件存储至本地 |
| | | * |
| | | * @param tjOrder |
| | | * @param customer |
| | | * @param finalOutPut |
| | | */ |
| | | private void savePDFFile(String outputFileName1, TjOrder tjOrder, TjCustomer customer, ByteArrayOutputStream finalOutPut) throws IOException, DocumentException, InterruptedException { |
| | | // 第一步:生成文件并保存 |
| | | String outputPath1 = value + File.separator; |
| | | File file = new File(outputPath1 + outputFileName1); |
| | | BufferedOutputStream outputStream = null; |
| | | outputStream = new BufferedOutputStream(new FileOutputStream(file)); |
| | | outputStream.write(finalOutPut.toByteArray()); |
| | | outputStream.flush(); |
| | | outputStream.close(); |
| | | finalOutPut.close(); |
| | | |
| | | // Thread.sleep(2000); |
| | | // |
| | | // FileInputStream fileInputStream = new FileInputStream(file); |
| | | // FileOutputStream fileOutputStream = new FileOutputStream(file); |
| | | // |
| | | // PdfReader pdfReader = new PdfReader(fileInputStream); |
| | | // PdfStamper pdfStamper = new PdfStamper(pdfReader, fileOutputStream); |
| | | // AcroFields form = pdfStamper.getAcroFields(); |
| | | // |
| | | // List<String> fieldNames = new ArrayList<>(form.getFields().keySet()); |
| | | // if (fieldNames.contains("page")) { |
| | | // form.setField("page", "1111"); |
| | | // } |
| | | // |
| | | // pdfStamper.setFormFlattening(true); // 设置为 true 后表单字段不可编辑 |
| | | // |
| | | // pdfStamper.close(); |
| | | // pdfReader.close(); |
| | | // fileInputStream.close(); |
| | | // fileOutputStream.close(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 填充检验表格数据 |
| | | * |
| | | * @param document1 |
| | | * @param map |
| | | * @throws DocumentException |
| | | */ |
| | | private static void makeHisJianYanTable(Document document1, HashMap<String, Object> map) throws DocumentException { |
| | | if (!map.isEmpty()){ |
| | | String[] titles = new String[]{"体检项目", "体检结果", "单位", "参考范围"}; |
| | | float[] titlesWidth = new float[]{120, 120, 120, 120}; |
| | | private void makeHisJianYanTable(Document document1, HashMap<String, Object> map, DictHosp dictHosp, String colorStr) throws DocumentException { |
| | | if (!map.isEmpty()) { |
| | | String[] titles = new String[]{"体检项目", "体检结果", "提示", "单位", "参考范围"}; |
| | | float[] titlesWidth = new float[]{280, 100, 40, 100, 120}; |
| | | for (Map.Entry<String, Object> entry : map.entrySet()) { |
| | | String titleName = entry.getKey().trim(); |
| | | HashMap<String, Object> entryValue = (HashMap<String, Object>) entry.getValue(); |
| | | HashSet<String> jyys = (HashSet<String>) entryValue.get("jyys"); |
| | | ArrayList<List<String>> lists = (ArrayList<List<String>>) entryValue.get("data"); |
| | | addJianYanTable(document1,titleName,titles,titlesWidth,lists); |
| | | Font doctorFonts = PdfUtils.setFont(9); |
| | | String doctors = ""; |
| | | for (String s : jyys) { |
| | | doctors+=s+"、"; |
| | | String shsj = entryValue.get("shsj").toString(); |
| | | addJianYanTable(document1, titleName, titles, titlesWidth, lists, dictHosp, colorStr); |
| | | if (!jyys.isEmpty()) { |
| | | Font doctorFonts = PdfUtils.setFont(DEFAULT_FONT_SIZE); |
| | | String doctors = ""; |
| | | Paragraph elements = new Paragraph(); |
| | | elements.setLeading(5f); |
| | | elements.setSpacingBefore(10f); |
| | | elements.setSpacingAfter(10f); |
| | | elements.setAlignment(Element.ALIGN_RIGHT); |
| | | Phrase phrase = new Phrase(); |
| | | phrase.add(new Chunk("检查日期:" + shsj + " 审核医师:", doctorFonts)); |
| | | boolean flag = false; |
| | | for (String s : jyys) { |
| | | if (s.contains("|")) { |
| | | flag = true; |
| | | String[] split = s.split("\\|"); |
| | | String qmImg = dictUserInfoMapper.selectQmImgInnerJoinUserByHisDictCode(split[1]); |
| | | if (null != qmImg && StrUtil.isNotBlank(qmImg)) { |
| | | byte[] decode = Base64.getDecoder().decode(qmImg); |
| | | Image image = null; |
| | | try { |
| | | image = Image.getInstance(decode); |
| | | image.scaleToFit(60, 25); |
| | | phrase.add(new Chunk(image, 0, -10, true)); |
| | | } catch (IOException e) { |
| | | phrase.add(new Chunk(split[0].trim(), doctorFonts)); |
| | | } |
| | | } else { |
| | | phrase.add(new Chunk(split[0].trim(), doctorFonts)); |
| | | } |
| | | } else { |
| | | doctors += s.trim() + "、"; |
| | | } |
| | | } |
| | | if (!flag) { |
| | | String substring = doctors.substring(0, doctors.length() - 1).trim(); |
| | | Paragraph df = PdfUtils.setParagraph(doctorFonts, "检查日期:" + shsj + " 审核医师:" + substring); |
| | | df.setAlignment(Element.ALIGN_RIGHT); |
| | | document1.add(df); |
| | | } else { |
| | | elements.add(phrase); |
| | | document1.add(elements); |
| | | } |
| | | } |
| | | String substring = doctors.substring(0, doctors.length() - 1); |
| | | Paragraph df = PdfUtils.setParagraph(doctorFonts, "检验医师:"+substring); |
| | | df.setAlignment(Element.ALIGN_RIGHT); |
| | | document1.add(df); |
| | | //分割线 |
| | | LineSeparator objectName = new LineSeparator(); |
| | | document1.add(objectName); |
| | | // if (!dictHosp.getHospName().equals("澄合矿务局中心医院")) { |
| | | if (!true) { |
| | | LineSeparator objectName = new LineSeparator(); |
| | | objectName.setOffset(-5); |
| | | document1.add(objectName); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 非化验项目表格填充 |
| | | * |
| | | * @param document1 |
| | | * @param printReport |
| | | * @throws DocumentException |
| | | */ |
| | | private void notHuaYanTable(Document document1, Map<TjOrderRemark, List<TjPdfVO>> printReport) throws DocumentException { |
| | | private void notHuaYanTable(Document document1, Map<TjOrderRemark, List<TjPdfVO>> printReport, DictHosp dictHosp, String colorStr, boolean isPacs) throws DocumentException { |
| | | for (Map.Entry<TjOrderRemark, List<TjPdfVO>> entry : printReport.entrySet()) { |
| | | List<TjPdfVO> value = entry.getValue(); |
| | | LambdaQueryWrapper<TjProject> wqqq = new LambdaQueryWrapper<>(); |
| | | wqqq.eq(TjProject::getProId, entry.getKey().getProId()); |
| | | TjProject one11 = projectService.getOne(wqqq); |
| | | if (entry.getValue() == null || entry.getValue().isEmpty()) continue; |
| | | //判断该项目是否需要打印报告 |
| | | if (null != one11 && "N".equals(one11.getNeedReport())) { |
| | | continue; |
| | | } |
| | | String titleName = null; |
| | | if (null != one11 && "1".equals(one11.getResultType())) { |
| | | titleName = one11.getProName(); |
| | | // TODO 单位 |
| | | // 设置标题字体样式 |
| | | Font titleFonts = PdfUtils.setFont(9); |
| | | Paragraph paragraph = PdfUtils.setParagraph(titleFonts, titleName); |
| | | String[] titles = {"体检项目", "体检结果","单位"}; |
| | | // 获取列表数据 |
| | | //设置表头字体样式 |
| | | Font headFont = PdfUtils.setFont(9); |
| | | // 设置正文字体样式:12号 |
| | | Font textFont = PdfUtils.setFont(9); |
| | | //创建表格 将表头字体和正文字体放进去 |
| | | PdfPTable table = PdfUtils.setTable2(headFont, textFont, titles, value); |
| | | document1.add(paragraph); |
| | | document1.add(table); |
| | | //判断备注是否为空 空不能显示null |
| | | if (entry.getKey().getRemark() == null) { |
| | | entry.getKey().setRemark(""); |
| | | 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 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(9); |
| | | 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); |
| | | Paragraph pp = PdfUtils.setParagraph(remarkFonts, substring); |
| | | document1.add(pp); |
| | | } |
| | | } else { |
| | | Font remarkFonts = PdfUtils.setFont(9); |
| | | Paragraph pp = PdfUtils.setParagraph(remarkFonts, remark); |
| | | document1.add(pp); |
| | | } |
| | | //判断主检医师是否为空 空不能显示null |
| | | if (null != entry.getKey().getDoctorName() && null != userService.getById(entry.getKey().getDoctorName())) { |
| | | //主检医师 |
| | | String doctorName = "主检医师:" + userService.getById(entry.getKey().getDoctorName()).getNickName(); |
| | | Font doctorFonts = PdfUtils.setFont(9); |
| | | Paragraph df = PdfUtils.setParagraph(doctorFonts, doctorName); |
| | | df.setAlignment(Element.ALIGN_RIGHT); |
| | | document1.add(df); |
| | | } else { |
| | | String doctorName = "主检医师:" + "无"; |
| | | Font doctorFonts = PdfUtils.setFont(9); |
| | | Paragraph df = PdfUtils.setParagraph(doctorFonts, doctorName); |
| | | df.setAlignment(Element.ALIGN_RIGHT); |
| | | document1.add(df); |
| | | } |
| | | //分割线 |
| | | LineSeparator objectName = new LineSeparator(); |
| | | document1.add(objectName); |
| | | } else { |
| | | if (null != one11) { |
| | | String titleName = null; |
| | | if ("1".equals(one11.getResultType())) { |
| | | titleName = one11.getProName(); |
| | | } else { |
| | | titleName = entry.getKey().getProName(); |
| | | } |
| | | // 设置标题字体样式 |
| | | Font titleFonts = PdfUtils.setFont(9); |
| | | Paragraph paragraph = PdfUtils.setParagraph(titleFonts, titleName); |
| | | String[] titles = {"体检项目", "体检结果", "单位", "参考范围"}; |
| | | // 获取列表数据 |
| | | //设置表头字体样式 |
| | | Font headFont = PdfUtils.setFont(9); |
| | | // 设置正文字体样式:12号 |
| | | Font textFont = PdfUtils.setFont(9); |
| | | //创建表格 将表头字体和正文字体放进去 |
| | | PdfPTable table = PdfUtils.setTable(headFont, textFont, titles, value); |
| | | document1.add(paragraph); |
| | | document1.add(table); |
| | | //判断备注是否为空 空不能显示null |
| | | if (entry.getKey().getRemark() == null) { |
| | | entry.getKey().setRemark(""); |
| | | } |
| | | 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(9); |
| | | Paragraph pp = PdfUtils.setParagraph(remarkFonts, substring); |
| | | document1.add(pp); |
| | | j = j + 50; |
| | | // 设置标题字体样式 |
| | | Font titleFonts = PdfUtils.setFont(9); |
| | | Paragraph paragraph = PdfUtils.setParagraph(titleFonts, titleName); |
| | | |
| | | // if (dictHosp.getHospName().equals("澄合矿务局中心医院")) { |
| | | if (true) { |
| | | 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(colorStr); |
| | | 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 (remark.length() % 50 != 0) { |
| | | String substring = remark.substring((remark.length() / 50) * 50, remark.length() - 1); |
| | | Font remarkFonts = PdfUtils.setFont(9); |
| | | Paragraph pp = PdfUtils.setParagraph(remarkFonts, substring); |
| | | document1.add(pp); |
| | | |
| | | |
| | | // String[] titles = {"体检项目", "体检结果", "单位"}; |
| | | // Font headFont = PdfUtils.setFont(9); |
| | | // Font textFont = PdfUtils.setFont(9); |
| | | // PdfPTable table = PdfUtils.setTable2(headFont, textFont, titles, value,dictHosp.getHospName().equals("澄合矿务局中心医院")); |
| | | // document1.add(table); |
| | | |
| | | // if (dictHosp.getHospName().equals("澄合矿务局中心医院") && !value.isEmpty()){ |
| | | if (true && !value.isEmpty()) { |
| | | if (value.size() > 1) { |
| | | if (value.get(0).getPid().equals("1862852701533012001")) { |
| | | Font remarkFonts = PdfUtils.setFont(DEFAULT_FONT_SIZE); |
| | | Paragraph ppp = new Paragraph("阳性参考值:", remarkFonts); |
| | | paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | paragraph.setLeading(5f); |
| | | document1.add(ppp); |
| | | |
| | | ppp = new Paragraph("DOB值: ≥ 4.0 HP-阳性", remarkFonts); |
| | | paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | paragraph.setLeading(5f); |
| | | document1.add(ppp); |
| | | |
| | | ppp = new Paragraph(" < 4.0 正常", remarkFonts); |
| | | paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | paragraph.setLeading(5f); |
| | | document1.add(ppp); |
| | | |
| | | |
| | | ppp = new Paragraph("检测结果: DOB=" + value.get(0).getProResult(), remarkFonts); |
| | | paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | paragraph.setLeading(5f); |
| | | document1.add(ppp); |
| | | |
| | | ppp = new Paragraph("", remarkFonts); |
| | | paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | paragraph.setLeading(5f); |
| | | document1.add(ppp); |
| | | ppp = new Paragraph("", remarkFonts); |
| | | paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | paragraph.setLeading(5f); |
| | | document1.add(ppp); |
| | | if (StrUtil.isNotBlank(entry.getKey().getRemark())) { |
| | | ppp = new Paragraph("结论:" + entry.getKey().getRemark(), remarkFonts); |
| | | paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | paragraph.setLeading(5f); |
| | | document1.add(ppp); |
| | | } |
| | | } 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 = PdfUtils.setParagraph(remarkFonts, "检查所见:"); |
| | | document1.add(pp); |
| | | Paragraph ppp = new Paragraph(value.get(0).getSj(), 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); |
| | | paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | paragraph.setLeading(5f); |
| | | document1.add(ppp); |
| | | } else { |
| | | if (value.get(0).getPid().equals("1862852701533012001")) { |
| | | remarkFonts = PdfUtils.setFont(DEFAULT_FONT_SIZE); |
| | | Paragraph ppp = new Paragraph("阳性参考值:", remarkFonts); |
| | | paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | paragraph.setLeading(5f); |
| | | document1.add(ppp); |
| | | |
| | | ppp = new Paragraph("DOB值: ≥ 4.0 HP-阳性", remarkFonts); |
| | | paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | paragraph.setLeading(5f); |
| | | document1.add(ppp); |
| | | |
| | | ppp = new Paragraph(" < 4.0 正常", remarkFonts); |
| | | paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | paragraph.setLeading(5f); |
| | | document1.add(ppp); |
| | | |
| | | |
| | | ppp = new Paragraph("检测结果: DOB=" + value.get(0).getProResult(), remarkFonts); |
| | | paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | paragraph.setLeading(5f); |
| | | document1.add(ppp); |
| | | |
| | | ppp = new Paragraph("", remarkFonts); |
| | | paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | paragraph.setLeading(5f); |
| | | document1.add(ppp); |
| | | ppp = new Paragraph("", remarkFonts); |
| | | paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | paragraph.setLeading(5f); |
| | | document1.add(ppp); |
| | | if (StrUtil.isNotBlank(entry.getKey().getRemark())) { |
| | | ppp = new Paragraph("结论:" + entry.getKey().getRemark(), remarkFonts); |
| | | paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | paragraph.setLeading(5f); |
| | | document1.add(ppp); |
| | | } |
| | | } 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.setTable2(headFont, textFont, titles, value, isPacs, new float[]{240, 240, 240}); |
| | | document1.add(table); |
| | | } |
| | | //判断备注是否为空 空不能显示null |
| | | 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); |
| | | } |
| | | } |
| | | //判断主检医师是否为空 空不能显示null |
| | | zhuJianYiShi(document1, entry, orderRemark.getCreateTime(), dictHosp); |
| | | //分割线 |
| | | // if (!dictHosp.getHospName().equals("澄合矿务局中心医院")) { |
| | | if (!true) { |
| | | LineSeparator objectName = new LineSeparator(); |
| | | document1.add(objectName); |
| | | } |
| | | } else { |
| | | Font remarkFonts = PdfUtils.setFont(9); |
| | | Paragraph pp = PdfUtils.setParagraph(remarkFonts, remark); |
| | | document1.add(pp); |
| | | 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(); |
| | | } |
| | | // 设置标题字体样式 |
| | | 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); |
| | | } |
| | | |
| | | // String[] titles = {"体检项目", "体检结果", "单位"}; |
| | | // Font headFont = PdfUtils.setFont(9); |
| | | // Font textFont = PdfUtils.setFont(9); |
| | | // PdfPTable table = PdfUtils.setTable(headFont, textFont, titles, value,dictHosp.getHospName().equals("澄合矿务局中心医院")); |
| | | // document1.add(table); |
| | | |
| | | // if (dictHosp.getHospName().equals("澄合矿务局中心医院") && !value.isEmpty()){ |
| | | if (true && !value.isEmpty()) { |
| | | if (value.size() > 1) { |
| | | if (value.get(0).getPid().equals("1862852701533012001")) { |
| | | Font remarkFonts = PdfUtils.setFont(DEFAULT_FONT_SIZE); |
| | | Paragraph ppp = new Paragraph("阳性参考值:", remarkFonts); |
| | | paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | paragraph.setLeading(5f); |
| | | document1.add(ppp); |
| | | |
| | | ppp = new Paragraph("DOB值: ≥ 4.0 HP-阳性", remarkFonts); |
| | | paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | paragraph.setLeading(5f); |
| | | document1.add(ppp); |
| | | |
| | | ppp = new Paragraph(" < 4.0 正常", remarkFonts); |
| | | paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | paragraph.setLeading(5f); |
| | | document1.add(ppp); |
| | | |
| | | |
| | | ppp = new Paragraph("检测结果: DOB=" + value.get(0).getProResult(), remarkFonts); |
| | | paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | paragraph.setLeading(5f); |
| | | document1.add(ppp); |
| | | |
| | | ppp = new Paragraph("", remarkFonts); |
| | | paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | paragraph.setLeading(5f); |
| | | document1.add(ppp); |
| | | ppp = new Paragraph("", remarkFonts); |
| | | paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | paragraph.setLeading(5f); |
| | | document1.add(ppp); |
| | | if (StrUtil.isNotBlank(entry.getKey().getRemark())) { |
| | | ppp = new Paragraph("结论:" + entry.getKey().getRemark(), remarkFonts); |
| | | paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | paragraph.setLeading(5f); |
| | | document1.add(ppp); |
| | | } |
| | | } 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 = PdfUtils.setParagraph(remarkFonts, "检查所见:"); |
| | | document1.add(pp); |
| | | 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() != null ? value.get(0).getTs() : value.get(0).getProResult(), remarkFonts); |
| | | paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | paragraph.setLeading(5f); |
| | | document1.add(ppp); |
| | | } else { |
| | | if (value.get(0).getPid().equals("1862852701533012001")) { |
| | | remarkFonts = PdfUtils.setFont(DEFAULT_FONT_SIZE); |
| | | Paragraph ppp = new Paragraph("阳性参考值:", remarkFonts); |
| | | paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | paragraph.setLeading(5f); |
| | | document1.add(ppp); |
| | | |
| | | ppp = new Paragraph("DOB值: ≥ 4.0 HP-阳性", remarkFonts); |
| | | paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | paragraph.setLeading(5f); |
| | | document1.add(ppp); |
| | | |
| | | ppp = new Paragraph(" < 4.0 正常", remarkFonts); |
| | | paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | paragraph.setLeading(5f); |
| | | document1.add(ppp); |
| | | |
| | | |
| | | ppp = new Paragraph("检测结果: DOB=" + value.get(0).getProResult(), remarkFonts); |
| | | paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | paragraph.setLeading(5f); |
| | | document1.add(ppp); |
| | | |
| | | ppp = new Paragraph("", remarkFonts); |
| | | paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | paragraph.setLeading(5f); |
| | | document1.add(ppp); |
| | | ppp = new Paragraph("", remarkFonts); |
| | | paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | paragraph.setLeading(5f); |
| | | document1.add(ppp); |
| | | if (StrUtil.isNotBlank(entry.getKey().getRemark())) { |
| | | ppp = new Paragraph("结论:" + entry.getKey().getRemark(), remarkFonts); |
| | | paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | paragraph.setLeading(5f); |
| | | document1.add(ppp); |
| | | } |
| | | } 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); |
| | | } |
| | | |
| | | |
| | | //判断备注是否为空 空不能显示null |
| | | 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); |
| | | } |
| | | } |
| | | //判断主检医师是否为空 空不能显示null |
| | | zhuJianYiShi(document1, entry, orderRemark.getCreateTime(), dictHosp); |
| | | // if (!dictHosp.getHospName().equals("澄合矿务局中心医院")) { |
| | | if (!true) { |
| | | //分割线 |
| | | LineSeparator objectName = new LineSeparator(); |
| | | document1.add(objectName); |
| | | } |
| | | } |
| | | //判断主检医师是否为空 空不能显示null |
| | | if (null != entry.getKey().getDoctorName() && null != userService.getById(entry.getKey().getDoctorName())) { |
| | | //主检医师 |
| | | String doctorName = "主检医师:" + userService.getById(entry.getKey().getDoctorName()).getNickName(); |
| | | Font doctorFonts = PdfUtils.setFont(9); |
| | | Paragraph df = PdfUtils.setParagraph(doctorFonts, doctorName); |
| | | df.setAlignment(Element.ALIGN_RIGHT); |
| | | document1.add(df); |
| | | } else { |
| | | String doctorName = "主检医师:" + "无"; |
| | | Font doctorFonts = PdfUtils.setFont(9); |
| | | Paragraph df = PdfUtils.setParagraph(doctorFonts, doctorName); |
| | | df.setAlignment(Element.ALIGN_RIGHT); |
| | | document1.add(df); |
| | | } |
| | | //分割线 |
| | | LineSeparator objectName = new LineSeparator(); |
| | | document1.add(objectName); |
| | | } |
| | | } |
| | | } |
| | | |
| | | public HashMap<String, Object> makeHisJianYan(TjOrder tjOrder, TjCustomer customer){ |
| | | // TODO 这里先使用查全部测试 |
| | | /** |
| | | * 主见医师行显示设置 |
| | | * |
| | | * @param document1 |
| | | * @param entry |
| | | * @throws DocumentException |
| | | */ |
| | | private void zhuJianYiShi(Document document1, Map.Entry<TjOrderRemark, List<TjPdfVO>> entry, Date createTime, DictHosp dictHosp) throws DocumentException { |
| | | // if ((null != entry.getKey().getDoctorName() && null != userService.getById(entry.getKey().getDoctorName())) || dictHosp.getHospName().equals("澄合矿务局中心医院") ) { |
| | | if ((null != entry.getKey().getDoctorName() && null != userService.getById(entry.getKey().getDoctorName())) || true) { |
| | | //主检医师 |
| | | String key = sysConfigService.selectConfigByKey("is_report_pdf_use_ysqm"); |
| | | SysUser sysUser = userService.getById(entry.getKey().getDoctorName()); |
| | | String doctorNameDefault = "无"; |
| | | if (sysUser != null) doctorNameDefault = sysUser.getNickName(); |
| | | // if (!entry.getValue().isEmpty() && StrUtil.isNotBlank(entry.getValue().get(0).getShys()) && dictHosp.getHospName().equals("澄合矿务局中心医院")){ |
| | | if (!entry.getValue().isEmpty() && StrUtil.isNotBlank(entry.getValue().get(0).getShys()) && true) { |
| | | doctorNameDefault = entry.getValue().get(0).getShys(); |
| | | } |
| | | Font doctorFonts = PdfUtils.setFont(9); |
| | | if (key.equals("Y")) { |
| | | String qmImg = dictUserInfoMapper.selectQmImgInnerJoinUserByUserId(String.valueOf(sysUser.getUserId())); |
| | | if (null != qmImg && StrUtil.isNotBlank(qmImg)) { |
| | | Paragraph elements = new Paragraph(); |
| | | elements.setLeading(5f); |
| | | elements.setSpacingBefore(10f); |
| | | elements.setSpacingAfter(10f); |
| | | elements.setAlignment(Element.ALIGN_RIGHT); |
| | | Phrase phrase = new Phrase(); |
| | | if (createTime != null) { |
| | | phrase.add(new Chunk("检查时间:" + new SimpleDateFormat("yyyy-MM-dd").format(createTime) + " 主检医师:", doctorFonts)); |
| | | } else { |
| | | phrase.add(new Chunk("主检医师:", doctorFonts)); |
| | | } |
| | | byte[] decode = Base64.getDecoder().decode(qmImg); |
| | | Image image = null; |
| | | try { |
| | | image = Image.getInstance(decode); |
| | | image.scaleToFit(60, 25); |
| | | phrase.add(new Chunk(image, 0, -10, true)); |
| | | elements.add(phrase); |
| | | document1.add(elements); |
| | | } catch (IOException e) { |
| | | String doctorName = "主检医师:" + doctorNameDefault; |
| | | if (createTime != null) |
| | | doctorName = "检查时间:" + new SimpleDateFormat("yyyy-MM-dd").format(createTime) + " 主检医师:" + doctorNameDefault; |
| | | Paragraph df = PdfUtils.setParagraph(doctorFonts, doctorName); |
| | | df.setAlignment(Element.ALIGN_RIGHT); |
| | | document1.add(df); |
| | | } |
| | | } else { |
| | | String doctorName = "主检医师:" + doctorNameDefault; |
| | | if (createTime != null) |
| | | doctorName = "检查时间:" + new SimpleDateFormat("yyyy-MM-dd").format(createTime) + " 主检医师:" + doctorNameDefault; |
| | | Paragraph df = PdfUtils.setParagraph(doctorFonts, doctorName); |
| | | df.setAlignment(Element.ALIGN_RIGHT); |
| | | document1.add(df); |
| | | } |
| | | } else { |
| | | String doctorName = "主检医师:" + doctorNameDefault; |
| | | if (createTime != null) |
| | | doctorName = "检查时间:" + new SimpleDateFormat("yyyy-MM-dd").format(createTime) + " 主检医师:" + doctorNameDefault; |
| | | Paragraph df = PdfUtils.setParagraph(doctorFonts, doctorName); |
| | | df.setAlignment(Element.ALIGN_RIGHT); |
| | | document1.add(df); |
| | | } |
| | | } else { |
| | | String doctorName = "主检医师:" + "无"; |
| | | if (createTime != null) |
| | | doctorName = "检查时间:" + new SimpleDateFormat("yyyy-MM-dd").format(createTime) + " 主检医师:" + "无"; |
| | | Font doctorFonts = PdfUtils.setFont(9); |
| | | Paragraph df = PdfUtils.setParagraph(doctorFonts, doctorName); |
| | | df.setAlignment(Element.ALIGN_RIGHT); |
| | | document1.add(df); |
| | | } |
| | | } |
| | | |
| | | public HashMap<String, Object> makeHisJianYan(TjOrder tjOrder, TjCustomer customer) { |
| | | LambdaQueryWrapper<LtkjHysqd> ltkjHysqdLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | ltkjHysqdLambdaQueryWrapper.eq(LtkjHysqd::getTjh,tjOrder.getCardId()); |
| | | ltkjHysqdLambdaQueryWrapper.eq(LtkjHysqd::getTjh, tjOrder.getCardId()); |
| | | List<LtkjHysqd> list = ltkjHysqdService.list(ltkjHysqdLambdaQueryWrapper); |
| | | // List<LtkjHysqd> list = ltkjHysqdService.list(); |
| | | HashMap<String, Object> data = new HashMap<>(); |
| | | for (LtkjHysqd hysqd : list) { |
| | | LambdaQueryWrapper<LtkjHybgd> ltkjHybgdLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | ltkjHybgdLambdaQueryWrapper.eq(LtkjHybgd::getTmh,hysqd.getTmh()); |
| | | 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(); |
| | | String jcxm = hybgd.getJcxm() != null ? hybgd.getJcxm().trim() : null; |
| | | // 检验结果 |
| | | String jyjg = hybgd.getJyjg(); |
| | | String jyjg = hybgd.getJyjg() != null ? hybgd.getJyjg().trim() : null; |
| | | // 结果单位 |
| | | String jgdw = hybgd.getJgdw(); |
| | | String jgdw = hybgd.getJgdw() != null ? hybgd.getJgdw().trim() : null; |
| | | // 范围值 |
| | | String fwz = hybgd.getFwz(); |
| | | String fwz = hybgd.getFwz() != null ? hybgd.getFwz().trim() : null; |
| | | // 检验医师 |
| | | String jyys = hybgd.getJyys(); |
| | | if (jyjg != null && StrUtil.isNotBlank(jyjg) && fwz != null && StrUtil.isNotBlank(fwz)){ |
| | | // 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]); |
| | |
| | | // 比较检验结果和范围值 |
| | | if (jyjgval.compareTo(min) < 0) { |
| | | // jyjg 小于范围最小值,添加下箭头 |
| | | jyjg = jyjg + " ↓"; |
| | | // jyjg = jyjg + " ↓"; |
| | | ycbz = "↓"; |
| | | } else if (jyjgval.compareTo(max) > 0) { |
| | | // jyjg 大于范围最大值,添加上箭头 |
| | | jyjg = jyjg + " ↑"; |
| | | // jyjg = jyjg + " ↑"; |
| | | 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()); |
| | | // 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); |
| | | } |
| | | 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); |
| | | map.put("data", lists); |
| | | map.put("jyys", hashSet); |
| | | if (StrUtil.isNotBlank(shsj)) { |
| | | shsj = shsj.split(" ")[0]; |
| | | } |
| | | map.put("shsj", shsj); |
| | | data.put(xmmc, map); |
| | | } |
| | | } |
| | |
| | | |
| | | /** |
| | | * 生成PDF模版以及用户信息部分 |
| | | * |
| | | * @param tjOrder |
| | | * @param reportTemplate |
| | | */ |
| | | public HashMap<String ,Object> makePDFInfo(TjOrder tjOrder,TjCustomer tjCustomer,TjReportTemplate reportTemplate){ |
| | | public HashMap<String, Object> makePDFInfo(TjOrder tjOrder, TjCustomer tjCustomer, TjReportTemplate reportTemplate, DictHosp dictHosp, HashMap<String, Object> jianYanMap) { |
| | | String tjNumber = tjOrder.getTjNumber(); |
| | | String template = reportTemplate.getTemplate(); |
| | | LambdaQueryWrapper<DictComp> wq111 = new LambdaQueryWrapper<>(); |
| | |
| | | } |
| | | //拼接重大阳性结果 |
| | | StringBuffer str = new StringBuffer(); |
| | | str.append("【重大阳性项目】\n"); |
| | | LambdaQueryWrapper<TjBigPositive> bigPositiveLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | bigPositiveLambdaQueryWrapper.eq(TjBigPositive::getTjNumber, tjNumber); |
| | | List<TjBigPositive> list1 = tjBigPositiveService.list(bigPositiveLambdaQueryWrapper); |
| | | if (list1 != null && list1.size() > 0) { |
| | | for (int i = 0; i < list1.size(); i++) { |
| | | str.append((i + 1) + "、" + list1.get(i).getProName() + ";\n"); |
| | | // if (!dictHosp.getHospName().equals("澄合矿务局中心医院")) { |
| | | if (!true) { |
| | | str.append("【重大阳性项目】\n"); |
| | | LambdaQueryWrapper<TjBigPositive> bigPositiveLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | bigPositiveLambdaQueryWrapper.eq(TjBigPositive::getTjNumber, tjNumber); |
| | | List<TjBigPositive> list1 = tjBigPositiveService.list(bigPositiveLambdaQueryWrapper); |
| | | if (list1 != null && list1.size() > 0) { |
| | | for (int i = 0; i < list1.size(); i++) { |
| | | str.append((i + 1) + "、" + list1.get(i).getProName() + ";\n"); |
| | | } |
| | | } else { |
| | | str.append(" 无;\n"); |
| | | } |
| | | } else { |
| | | str.append(" 无;\n"); |
| | | } |
| | | //拼接异常项目 |
| | | str.append("【异常情况项目】\n"); |
| | | if (list.size() > 0) { |
| | | for (int i = 0; i < list.size(); i++) { |
| | | if (list.get(i).getExceptionDesc() == 1) { |
| | | str.append((i + 1) + "、" + projectService.getById(list.get(i).getProId()).getProName() + ";\n"); |
| | | // if (!dictHosp.getHospName().equals("澄合矿务局中心医院")) { |
| | | if (!true) { |
| | | if (list.size() > 0) { |
| | | for (int i = 0; i < list.size(); i++) { |
| | | if (list.get(i).getExceptionDesc() == 1) { |
| | | str.append((i + 1) + "、" + projectService.getById(list.get(i).getProId()).getProName() + ";\n"); |
| | | } |
| | | } |
| | | } else { |
| | | str.append(" 无;\n"); |
| | | } |
| | | } else { |
| | | str.append(" 无;\n"); |
| | | int maxProjectLength = 0; |
| | | for (Map.Entry<String, Object> item : jianYanMap.entrySet()) { |
| | | HashMap<String, Object> entryValue = (HashMap<String, Object>) item.getValue(); |
| | | ArrayList<List<String>> lists = (ArrayList<List<String>>) entryValue.get("data"); |
| | | for (List<String> i : lists) { |
| | | maxProjectLength = Math.max(maxProjectLength, i.get(0).length()); |
| | | } |
| | | } |
| | | int projectWidth = maxProjectLength * 2; |
| | | int resultWidth = 8; |
| | | int flagWidth = 8; |
| | | int unitWidth = 8; |
| | | int rangeWidth = 15; |
| | | str.append(padRight("项目", projectWidth)) |
| | | .append(padRight("结果", resultWidth)) |
| | | .append(padRight("标志", flagWidth)) |
| | | .append(padRight("单位", unitWidth)) |
| | | .append(padRight("参考范围", rangeWidth)) |
| | | .append("\n"); |
| | | for (Map.Entry<String, Object> item : jianYanMap.entrySet()) { |
| | | HashMap<String, Object> entryValue = (HashMap<String, Object>) item.getValue(); |
| | | ArrayList<List<String>> lists = (ArrayList<List<String>>) entryValue.get("data"); |
| | | for (List<String> i : lists) { |
| | | if (i.contains("↓") || i.contains("↑")) { |
| | | int currentProjectWidth = i.get(0).length() + (maxProjectLength - i.get(0).length()) * 2 + 2; |
| | | str.append(padRight(i.get(0), currentProjectWidth)); |
| | | str.append(padRight(i.get(1), resultWidth)); |
| | | str.append(padRight(i.get(2), flagWidth)); |
| | | str.append(padRight(i.get(3), unitWidth)); |
| | | str.append(padRight(i.get(4), rangeWidth)); |
| | | str.append("\n"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | //异常项目 |
| | | data.put("yichang", str.toString()); |
| | | data.put("zjrq", new SimpleDateFormat("yyyy-MM-dd").format(tjOrder.getCheckTime())); |
| | | // 遍历data 给pdf表单表格赋值 |
| | | for (String key : data.keySet()) { |
| | | acroFields.setField(key, data.get(key).toString()); |
| | |
| | | // 添加详情页 |
| | | document.newPage(); |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | map.put("document",document); |
| | | map.put("copy",copy); |
| | | map.put("stream",finalOutPut); |
| | | map.put("document", document); |
| | | map.put("copy", copy); |
| | | map.put("stream", finalOutPut); |
| | | map.put("form", pdfStamper); |
| | | return map; |
| | | } catch (IOException | DocumentException e) { |
| | | e.printStackTrace(); |
| | |
| | | } |
| | | } |
| | | |
| | | public Boolean makePDF(String cardId, JSONArray jsonArray,TjOrder tjOrder,TjReportTemplate reportTemplate) { |
| | | String tjNumber = tjOrder.getTjNumber(); |
| | | String template = reportTemplate.getTemplate(); |
| | | LambdaQueryWrapper<TjCustomer> wq1 = new LambdaQueryWrapper<>(); |
| | | wq1.eq(TjCustomer::getCusId, tjOrder.getUserId()); |
| | | TjCustomer tjCustomer = tjCustomerService.getOne(wq1); |
| | | Long userId = tjCustomer.getCusId(); |
| | | 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()); |
| | | //20230306判断该项目是否退费/缴费 |
| | | wq2.isNotNull(TjOrderDetail::getFlowingWaterId); |
| | | //20230323判断该项目是否弃检/未检 |
| | | // wq2.eq(TjOrderDetail::getTjStatus,1); |
| | | List<TjOrderDetail> list = tjOrderDetailService.list(wq2); |
| | | for (TjOrderDetail tjOrderDetail : list) { |
| | | TjProject tjProject = projectService.selectTjProjectByProId(tjOrderDetail.getProId()); |
| | | tjOrderDetail.setProject(tjProject); |
| | | public static String padRight(String str, int length) { |
| | | StringBuilder sb = new StringBuilder(str); |
| | | while (sb.length() < length) { |
| | | sb.append(" "); |
| | | } |
| | | // 生成pdf |
| | | try { |
| | | ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); |
| | | PdfReader reader = new PdfReader(new ByteArrayInputStream(Base64.getDecoder().decode(template))); |
| | | PdfStamper pdfStamper = new PdfStamper(reader, byteArrayOutputStream); |
| | | // 获取pdf表单 |
| | | 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<>(); |
| | | // 设置用户信息 |
| | | setUserInfo(tjNumber, tjOrder, tjCustomer, data); |
| | | //异常项目 |
| | | if (dictComp == null) { |
| | | data.put("work", "无"); |
| | | } else { |
| | | data.put("work", dictComp.getCnName()); |
| | | } |
| | | //封面页下面的总检建议显示 |
| | | if (tjOrder.getCheckAdvice() == null) { |
| | | data.put("remark", "无"); |
| | | } else { |
| | | data.put("remark", tjOrder.getCheckAdvice()); |
| | | } |
| | | //封面页下面的总检建议显示 |
| | | if (tjOrder.getCheckDoctor() == null) { |
| | | data.put("docname", "无"); |
| | | } else { |
| | | data.put("docname", tjOrder.getCheckDoctor()); |
| | | } |
| | | //拼接重大阳性结果 |
| | | StringBuffer str = new StringBuffer(); |
| | | str.append("【重大阳性项目】\n"); |
| | | LambdaQueryWrapper<TjBigPositive> bigPositiveLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | bigPositiveLambdaQueryWrapper.eq(TjBigPositive::getTjNumber, tjNumber); |
| | | List<TjBigPositive> list1 = tjBigPositiveService.list(bigPositiveLambdaQueryWrapper); |
| | | if (list1 != null && list1.size() > 0) { |
| | | for (int i = 0; i < list1.size(); i++) { |
| | | str.append((i + 1) + "、" + list1.get(i).getProName() + ";\n"); |
| | | } |
| | | } else { |
| | | str.append(" 无;\n"); |
| | | } |
| | | //拼接异常项目 |
| | | str.append("【异常情况项目】\n"); |
| | | if (list.size() > 0) { |
| | | for (int i = 0; i < list.size(); i++) { |
| | | if (list.get(i).getExceptionDesc() == 1) { |
| | | str.append((i + 1) + "、" + projectService.getById(list.get(i).getProId()).getProName() + ";\n"); |
| | | } |
| | | } |
| | | } else { |
| | | str.append(" 无;\n"); |
| | | } |
| | | |
| | | //异常项目 |
| | | data.put("yichang", str.toString()); |
| | | // 遍历data 给pdf表单表格赋值 |
| | | for (String key : data.keySet()) { |
| | | acroFields.setField(key, data.get(key).toString()); |
| | | } |
| | | //设置为无法编辑 |
| | | pdfStamper.setFormFlattening(true); |
| | | pdfStamper.close(); |
| | | reader.close(); |
| | | // 将修改后的PDF内容写入 |
| | | byte[] bytes = byteArrayOutputStream.toByteArray(); |
| | | // 创建新的PDF文档 |
| | | Document document = new Document(PageSize.A4); |
| | | ByteArrayOutputStream finalOutPut = new ByteArrayOutputStream(); |
| | | PdfCopy copy = new PdfCopy(document, finalOutPut); |
| | | document.open(); |
| | | reader = new PdfReader(bytes); |
| | | int numberOfPages = reader.getNumberOfPages(); |
| | | for (int i = 1; i <= numberOfPages; i++) { |
| | | PdfImportedPage page = copy.getImportedPage(reader, i); |
| | | copy.addPage(page); |
| | | } |
| | | // 添加详情页 |
| | | document.newPage(); |
| | | ByteArrayOutputStream byteArrayOutputStream1 = new ByteArrayOutputStream(); |
| | | Document document1 = new Document(PageSize.A4); |
| | | PdfWriter pdfWriter = PdfWriter.getInstance(document1, byteArrayOutputStream1); |
| | | document1.setMargins(70, 70, 40, 40); |
| | | document1.open(); |
| | | // 非化验项目报告 |
| | | Map<TjOrderRemark, List<TjPdfVO>> printReport = new HashMap<>(); |
| | | notHuaYanData(tjNumber, printReport,tjOrder,tjCustomer); |
| | | for (Map.Entry<TjOrderRemark, List<TjPdfVO>> entry : printReport.entrySet()) { |
| | | List<TjPdfVO> value = entry.getValue(); |
| | | LambdaQueryWrapper<TjProject> wqqq = new LambdaQueryWrapper<>(); |
| | | wqqq.eq(TjProject::getProId, entry.getKey().getProId()); |
| | | TjProject one11 = projectService.getOne(wqqq); |
| | | //判断该项目是否需要打印报告 |
| | | if (null != one11 && "N".equals(one11.getNeedReport())) { |
| | | continue; |
| | | } |
| | | String titleName = null; |
| | | if (null != one11 && "1".equals(one11.getResultType())) { |
| | | titleName = one11.getProName(); |
| | | // TODO 单位 |
| | | // 设置标题字体样式 |
| | | Font titleFonts = PdfUtils.setFont(9); |
| | | Paragraph paragraph = PdfUtils.setParagraph(titleFonts, titleName); |
| | | String[] titles = {"体检项目", "体检结果","单位"}; |
| | | // 获取列表数据 |
| | | //设置表头字体样式 |
| | | Font headFont = PdfUtils.setFont(9); |
| | | // 设置正文字体样式:12号 |
| | | Font textFont = PdfUtils.setFont(9); |
| | | //创建表格 将表头字体和正文字体放进去 |
| | | PdfPTable table = PdfUtils.setTable2(headFont, textFont, titles, value); |
| | | document1.add(paragraph); |
| | | document1.add(table); |
| | | //判断备注是否为空 空不能显示null |
| | | if (entry.getKey().getRemark() == null) { |
| | | entry.getKey().setRemark(""); |
| | | } |
| | | 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(9); |
| | | 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); |
| | | Paragraph pp = PdfUtils.setParagraph(remarkFonts, substring); |
| | | document1.add(pp); |
| | | } |
| | | } else { |
| | | Font remarkFonts = PdfUtils.setFont(9); |
| | | Paragraph pp = PdfUtils.setParagraph(remarkFonts, remark); |
| | | document1.add(pp); |
| | | } |
| | | //判断主检医师是否为空 空不能显示null |
| | | if (null != entry.getKey().getDoctorName() && null != userService.getById(entry.getKey().getDoctorName())) { |
| | | //主检医师 |
| | | String doctorName = "主检医师:" + userService.getById(entry.getKey().getDoctorName()).getNickName(); |
| | | Font doctorFonts = PdfUtils.setFont(9); |
| | | Paragraph df = PdfUtils.setParagraph(doctorFonts, doctorName); |
| | | df.setAlignment(Element.ALIGN_RIGHT); |
| | | document1.add(df); |
| | | } else { |
| | | String doctorName = "主检医师:" + "无"; |
| | | Font doctorFonts = PdfUtils.setFont(9); |
| | | Paragraph df = PdfUtils.setParagraph(doctorFonts, doctorName); |
| | | df.setAlignment(Element.ALIGN_RIGHT); |
| | | document1.add(df); |
| | | } |
| | | //分割线 |
| | | LineSeparator objectName = new LineSeparator(); |
| | | document1.add(objectName); |
| | | } else { |
| | | if (null != one11) { |
| | | titleName = one11.getProName(); |
| | | } else { |
| | | titleName = entry.getKey().getProName(); |
| | | } |
| | | // 设置标题字体样式 |
| | | Font titleFonts = PdfUtils.setFont(9); |
| | | Paragraph paragraph = PdfUtils.setParagraph(titleFonts, titleName); |
| | | String[] titles = {"体检项目", "体检结果", "单位", "参考范围"}; |
| | | // 获取列表数据 |
| | | //设置表头字体样式 |
| | | Font headFont = PdfUtils.setFont(9); |
| | | // 设置正文字体样式:12号 |
| | | Font textFont = PdfUtils.setFont(9); |
| | | //创建表格 将表头字体和正文字体放进去 |
| | | PdfPTable table = PdfUtils.setTable(headFont, textFont, titles, value); |
| | | document1.add(paragraph); |
| | | document1.add(table); |
| | | //判断备注是否为空 空不能显示null |
| | | if (entry.getKey().getRemark() == null) { |
| | | entry.getKey().setRemark(""); |
| | | } |
| | | 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(9); |
| | | 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); |
| | | Paragraph pp = PdfUtils.setParagraph(remarkFonts, substring); |
| | | document1.add(pp); |
| | | } |
| | | } else { |
| | | Font remarkFonts = PdfUtils.setFont(9); |
| | | Paragraph pp = PdfUtils.setParagraph(remarkFonts, remark); |
| | | document1.add(pp); |
| | | } |
| | | //判断主检医师是否为空 空不能显示null |
| | | if (null != entry.getKey().getDoctorName() && null != userService.getById(entry.getKey().getDoctorName())) { |
| | | //主检医师 |
| | | String doctorName = "主检医师:" + userService.getById(entry.getKey().getDoctorName()).getNickName(); |
| | | Font doctorFonts = PdfUtils.setFont(9); |
| | | Paragraph df = PdfUtils.setParagraph(doctorFonts, doctorName); |
| | | df.setAlignment(Element.ALIGN_RIGHT); |
| | | document1.add(df); |
| | | } else { |
| | | String doctorName = "主检医师:" + "无"; |
| | | Font doctorFonts = PdfUtils.setFont(9); |
| | | Paragraph df = PdfUtils.setParagraph(doctorFonts, doctorName); |
| | | df.setAlignment(Element.ALIGN_RIGHT); |
| | | document1.add(df); |
| | | } |
| | | //分割线 |
| | | LineSeparator objectName = new LineSeparator(); |
| | | document1.add(objectName); |
| | | } |
| | | } |
| | | List<ByteArrayOutputStream> jianchas = new ArrayList<>(); |
| | | for (Object o : jsonArray) { |
| | | JSONObject jsonObject = (JSONObject) o; |
| | | // 检验报告以及结果信息 |
| | | JSONObject reportInfo = jsonObject.getJSONObject("报告记录"); |
| | | String titleName = ""; |
| | | if (reportInfo != null) { |
| | | titleName = reportInfo.getStr("JYXMMC").trim(); |
| | | } |
| | | JSONArray reportDetails = jsonObject.getJSONArray("检验结果记录"); |
| | | ArrayList<TjPdfVO> listPdf = new ArrayList<>(); |
| | | String[] titles = null; |
| | | float[] titlesWidth = null; |
| | | // 结果信息 |
| | | if (reportDetails != null && reportDetails.size() > 0) { |
| | | for (Object reportDetail : reportDetails) { |
| | | JSONObject detail = (JSONObject) reportDetail; |
| | | TjPdfVO tjPdfVO = new TjPdfVO(); |
| | | tjPdfVO.setProName(detail.getStr("JCZBMC")); |
| | | tjPdfVO.setProResult(detail.getStr("JCZBJG")); |
| | | tjPdfVO.setVal1(detail.getStr("JLDW")); |
| | | tjPdfVO.setVal2(detail.getStr("CKZFW")); |
| | | listPdf.add(tjPdfVO); |
| | | } |
| | | titles = new String[]{"体检项目", "体检结果", "单位", "参考范围"}; |
| | | titlesWidth = new float[]{120, 120, 120, 120}; |
| | | addTable(document1, titleName, titles, titlesWidth, listPdf); |
| | | // 主检医师 |
| | | String bgysqm = reportInfo.getStr("BGYSQM"); |
| | | String doctorName = "主检医师:" + bgysqm; |
| | | Font doctorFonts = PdfUtils.setFont(9); |
| | | Paragraph df = PdfUtils.setParagraph(doctorFonts, doctorName); |
| | | df.setAlignment(Element.ALIGN_RIGHT); |
| | | document1.add(df); |
| | | //分割线 |
| | | LineSeparator objectName = new LineSeparator(); |
| | | document1.add(objectName); |
| | | } |
| | | // 微生物报告记录信息 |
| | | JSONArray labgermrepInfos = jsonObject.getJSONArray("微生物报告记录"); |
| | | if (labgermrepInfos != null && labgermrepInfos.size() > 0) { |
| | | listPdf = new ArrayList<>(); |
| | | for (Object info : labgermrepInfos) { |
| | | JSONObject object = (JSONObject) info; |
| | | TjPdfVO tjPdfVO = new TjPdfVO(); |
| | | tjPdfVO.setProName(object.getStr("XJMC")); |
| | | tjPdfVO.setProResult(object.getStr("JCJG")); |
| | | listPdf.add(tjPdfVO); |
| | | } |
| | | titles = new String[]{"体检项目", "体检结果"}; |
| | | titlesWidth = new float[]{120, 120}; |
| | | addTable(document1, titleName, titles, titlesWidth, listPdf); |
| | | //分割线 |
| | | LineSeparator objectName = new LineSeparator(); |
| | | document1.add(objectName); |
| | | } |
| | | // 微生物药敏信息 |
| | | JSONArray labgermdetailinfos = jsonObject.getJSONArray("微生物药敏信息"); |
| | | if (labgermdetailinfos != null && labgermdetailinfos.size() > 0) { |
| | | listPdf = new ArrayList<>(); |
| | | for (Object info : labgermdetailinfos) { |
| | | JSONObject object = (JSONObject) info; |
| | | TjPdfVO tjPdfVO = new TjPdfVO(); |
| | | tjPdfVO.setProName(object.getStr("YMMC")); |
| | | tjPdfVO.setProResult(object.getStr("JCJG")); |
| | | tjPdfVO.setVal1(object.getStr("ZPHYL")); |
| | | tjPdfVO.setVal2(object.getStr("YJND")); |
| | | tjPdfVO.setVal3(object.getStr("YJHZJ")); |
| | | listPdf.add(tjPdfVO); |
| | | } |
| | | titles = new String[]{"药敏名称", "检查结果", "纸片含药量", "抑菌浓度", "抑菌环直径"}; |
| | | titlesWidth = new float[]{90, 90, 90, 90, 90}; |
| | | addTable(document1, titleName, titles, titlesWidth, listPdf); |
| | | //分割线 |
| | | LineSeparator objectName = new LineSeparator(); |
| | | document1.add(objectName); |
| | | } |
| | | // 危急值信息 |
| | | JSONArray laburgentinfos = jsonObject.getJSONArray("危机值信息"); |
| | | if (laburgentinfos != null && laburgentinfos.size() > 0) { |
| | | listPdf = new ArrayList<>(); |
| | | for (Object info : laburgentinfos) { |
| | | JSONObject object = (JSONObject) info; |
| | | TjPdfVO tjPdfVO = new TjPdfVO(); |
| | | tjPdfVO.setProName(object.getStr("zbmc")); |
| | | tjPdfVO.setProResult(object.getStr("jg")); |
| | | tjPdfVO.setVal1(object.getStr("clfs")); |
| | | tjPdfVO.setVal2(object.getStr("bgcljg")); |
| | | listPdf.add(tjPdfVO); |
| | | } |
| | | titles = new String[]{"指标名称", "危急值结果", "处理方式", "处理意见"}; |
| | | titlesWidth = new float[]{120, 120, 120, 120}; |
| | | addTable(document1, titleName, titles, titlesWidth, listPdf); |
| | | //分割线 |
| | | LineSeparator objectName = new LineSeparator(); |
| | | document1.add(objectName); |
| | | } |
| | | JSONArray object = jsonObject.getJSONArray("检查报告"); |
| | | if (object != null && object.size() > 0) { |
| | | for (Object info : object) { |
| | | JSONObject obj = (JSONObject) info; |
| | | String xm = obj.getStr("HZXM"); |
| | | String xb = obj.getStr("HZXB").equals("2") ? "女" : "男"; |
| | | String nl = obj.getStr("HZNL"); |
| | | if (StrUtil.isNotBlank(nl) && nl.contains(".")) { |
| | | String[] split = nl.split("\\."); |
| | | nl = split[0]; |
| | | } |
| | | String jcks = obj.getStr("JCKSMC"); |
| | | String zyh = ""; |
| | | String sqks = obj.getStr("SQKSMC"); |
| | | String sjks = obj.getStr("ZDJGMC"); |
| | | String jcsb = obj.getStr("SBBM"); |
| | | String jch = obj.getStr("JCH"); |
| | | String jcxm = obj.getStr("JCXMMC"); |
| | | String ms = obj.getStr("YXBX"); |
| | | String ts = obj.getStr("YXZD"); |
| | | String ch = obj.getStr("BZBCH"); |
| | | // 报告医师签名 |
| | | String bgysqm = obj.getStr("BGYSQM"); |
| | | // 审核医师签名 |
| | | String shysqm = obj.getStr("SHYSQM"); |
| | | // 申请人 |
| | | String sqrxm = obj.getStr("SQRXM"); |
| | | String footer = "申请人:"+sqrxm + " 审核医师:"+shysqm+" "+bgysqm; |
| | | ByteArrayOutputStream outputStream = makeJcPDFByteArrayStream(xm, xb, nl, jcks, zyh, ch, sjks, jcsb, jch, jcxm, ms, ts, null,footer); |
| | | jianchas.add(outputStream); |
| | | } |
| | | } |
| | | } |
| | | document1.close(); |
| | | pdfWriter.close(); |
| | | 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(); |
| | | } |
| | | byteArrayOutputStream1.close(); |
| | | document.close(); |
| | | copy.close(); |
| | | reader.close(); |
| | | String outputFileName1 = userId + tjNumber + tjCustomer.getCusName() + "_报告.pdf"; |
| | | // 文件配置 |
| | | // String outputPath1 = "/Users/chacca/开发相关/代码/"; |
| | | String outputPath1 = value+"\\"; |
| | | File file = new File(outputPath1 + outputFileName1); |
| | | BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(file)); |
| | | outputStream.write(finalOutPut.toByteArray()); |
| | | outputStream.flush(); |
| | | outputStream.close(); |
| | | finalOutPut.close(); |
| | | reader.close(); |
| | | // 保存数据 |
| | | TjReport tjReport = new TjReport(); |
| | | tjReport.setTjNumber(String.valueOf(tjNumber)); |
| | | tjReport.setPath(urlValue + outputFileName1); |
| | | String pdfBinary = getPDFBinary(outputPath1 + outputFileName1); |
| | | tjReport.setReport(pdfBinary); |
| | | tjReport.setType("体检报告"); |
| | | tjReport.setPrint("pdf"); |
| | | tjReportService.save(tjReport); |
| | | //修改order表中的打印报告时间为当前时间 |
| | | LambdaUpdateWrapper<TjOrder> updateWrapper = new LambdaUpdateWrapper<>(); |
| | | updateWrapper.eq(TjOrder::getTjNumber, tjNumber); |
| | | updateWrapper.set(TjOrder::getReportTime, new Date()); |
| | | updateWrapper.set(TjOrder::getPrintLastTime, new Date()); |
| | | updateWrapper.set(TjOrder::getDownloadLastTime, new Date()); |
| | | updateWrapper.set(TjOrder::getStatus, TjConstants.TJ_END); |
| | | tjOrderService.update(updateWrapper); |
| | | } catch (IOException | DocumentException e) { |
| | | e.printStackTrace(); |
| | | return false; |
| | | } |
| | | return true; |
| | | return sb.toString(); |
| | | } |
| | | |
| | | /** |
| | | * 组合非化验项目报告数据 |
| | | * |
| | | * @param tjNumber |
| | | * @param printReport |
| | | * @param one |
| | | * @param customer |
| | | */ |
| | | private void notHuaYanData(String tjNumber, Map<TjOrderRemark, List<TjPdfVO>> printReport,TjOrder one,TjCustomer customer) { |
| | | LambdaQueryWrapper<TjOrderRemark> wqq = new LambdaQueryWrapper<>(); |
| | | wqq.eq(TjOrderRemark::getTjNumber, tjNumber); |
| | | wqq.ne(TjOrderRemark::getDeptId, "241"); |
| | | wqq.in(TjOrderRemark::getDeptId, "269", "270", "253", "254", "255", "257", "251", "271"); |
| | | wqq.notIn(TjOrderRemark::getProId, projectService.getNneedReprotProId()); |
| | | List<TjOrderRemark> tjOrderRemarks = tjOrderRemarkService.list(wqq); |
| | | private void notHuaYanData(String tjNumber, Map<TjOrderRemark, List<TjPdfVO>> printReport, TjOrder one, TjCustomer customer) { |
| | | // LambdaQueryWrapper<TjOrderRemark> wqq = new LambdaQueryWrapper<>(); |
| | | // wqq.eq(TjOrderRemark::getTjNumber, tjNumber); |
| | | // wqq.ne(TjOrderRemark::getDeptId, "241"); |
| | | // wqq.in(TjOrderRemark::getDeptId, "269", "270", "253", "254", "255", "257"); |
| | | // wqq.notIn(TjOrderRemark::getProId, projectService.getNneedReprotProId()); |
| | | // List<TjOrderRemark> tjOrderRemarks = tjOrderRemarkService.list(wqq); |
| | | List<TjOrderRemark> tjOrderRemarks = tjOrderRemarkService.notHuaYanData(tjNumber); |
| | | for (TjOrderRemark tjOrderRemark : tjOrderRemarks) { |
| | | printReport.put(tjOrderRemark, null); |
| | | } |
| | | 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()); |
| | | for (TjOrderDetail tjOrderDetail : tjOrderDetails) { |
| | | TjProject tjProject = projectService.getById(String.valueOf(tjOrderDetail.getProId())); |
| | | if (null != tjProject && tjProject.getNeedReport().equals("Y")) { |
| | | tjOrderDetail.setProject(tjProject); |
| | | |
| | | if (tjOrderDetail.getProject().getProParentId().equals(entry.getKey().getProId()) && entry.getKey().getType() == 1) { |
| | | TjPdfVO tjPdfVO = new TjPdfVO(); |
| | | tjPdfVO.setProName(tjOrderDetail.getProject().getProName()); |
| | | tjPdfVO.setProResult(tjOrderDetail.getProResult()); |
| | | tjPdfVO.setExc(tjOrderDetail.getExceptionDesc()); |
| | | if (null != tjProject.getProMetering()) { |
| | | tjPdfVO.setCompany(tjProject.getProMetering()); |
| | | } else { |
| | | tjPdfVO.setCompany("/"); |
| | | } |
| | | 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()); |
| | | // } |
| | | tjPdfVOS.add(tjPdfVO); |
| | | } |
| | | } |
| | | } |
| | | printReport.put(entry.getKey(), tjPdfVOS); |
| | | } |
| | | } |
| | | |
| | | private void pacsJianChaData(String tjNumber, Map<TjOrderRemark, List<TjPdfVO>> printReport, TjOrder one, TjCustomer customer) { |
| | | // LambdaQueryWrapper<TjOrderRemark> wqq = new LambdaQueryWrapper<>(); |
| | | // wqq.eq(TjOrderRemark::getTjNumber, tjNumber); |
| | | // wqq.ne(TjOrderRemark::getDeptId, "241"); |
| | | // wqq.in(TjOrderRemark::getDeptId, "269", "270", "253", "254", "255", "257"); |
| | | // wqq.notIn(TjOrderRemark::getProId, projectService.getNneedReprotProId()); |
| | | // List<TjOrderRemark> tjOrderRemarks = tjOrderRemarkService.list(wqq); |
| | | List<TjOrderRemark> tjOrderRemarks = tjOrderRemarkService.pacsJianChaData(tjNumber); |
| | | for (TjOrderRemark tjOrderRemark : tjOrderRemarks) { |
| | | printReport.put(tjOrderRemark, null); |
| | | } |
| | | String ids = ""; |
| | | 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().collect(Collectors.toMap(TjOrderDetail::getProId, i -> i, (existing, replacement) -> existing)).values()); |
| | | for (TjOrderDetail tjOrderDetail : tjOrderDetails) { |
| | | TjProject tjProject = projectService.getById(tjOrderDetail.getProId()); |
| | | if (null != tjProject) { |
| | | if (null != tjProject && tjProject.getNeedReport().equals("Y")) { |
| | | tjOrderDetail.setProject(tjProject); |
| | | } |
| | | if (tjOrderDetail.getProject().getProParentId().equals(entry.getKey().getProId())) { |
| | | LambdaQueryWrapper<TjStandard> wq6 = new LambdaQueryWrapper<>(); |
| | | wq6.eq(TjStandard::getProId, tjOrderDetail.getProId()); |
| | | List<TjStandard> list2 = tjStandardService.list(wq6); |
| | | if (list2.size() == 0) { |
| | | TjStandard s = new TjStandard(); |
| | | s.setCompany(" "); |
| | | s.setTjStandardLtValue(" "); |
| | | s.setTjStandardGtValue(" "); |
| | | tjOrderDetail.setStandard(s); |
| | | } else if (list2.size() == 1) { |
| | | tjOrderDetail.setStandard(list2.get(0)); |
| | | } else { |
| | | Long cusSex = customer.getCusSex(); |
| | | Date cusBrithday = customer.getCusBrithday(); |
| | | int age = DateUtil.ageOfNow(cusBrithday); |
| | | for (TjStandard tjStandard : list2) { |
| | | LambdaQueryWrapper<TjStandard> wq8 = new LambdaQueryWrapper<>(); |
| | | if (tjStandard.getTjSex() != null) { |
| | | wq8.eq(TjStandard::getTjSex, cusSex); |
| | | } |
| | | if (tjStandard.getTjType() != null) { |
| | | wq8.eq(TjStandard::getTjType, StringUtils.getAgeType(age)); |
| | | } |
| | | TjStandard standard = tjStandardService.getOne(wq8); |
| | | tjOrderDetail.setStandard(standard); |
| | | } |
| | | } |
| | | TjPdfVO tjPdfVO = new TjPdfVO(); |
| | | tjPdfVO.setProName(tjOrderDetail.getProject().getProName()); |
| | | tjPdfVO.setProResult(tjOrderDetail.getProResult()); |
| | | tjPdfVO.setExc(tjOrderDetail.getExceptionDesc()); |
| | | if (tjOrderDetail.getStandard() != null) { |
| | | //单位 |
| | | if (tjOrderDetail.getStandard().getCompany() == null) { |
| | | tjPdfVO.setCompany(" "); |
| | | |
| | | if (tjOrderDetail.getProject().getProParentId().equals(entry.getKey().getProId()) |
| | | && entry.getKey().getType() == 1 |
| | | && !ids.contains(String.valueOf(tjOrderDetail.getProject().getProParentId()))) { |
| | | TjPdfVO tjPdfVO = new TjPdfVO(); |
| | | tjPdfVO.setProName(tjOrderDetail.getProject().getProName()); |
| | | tjPdfVO.setProResult(tjOrderDetail.getProResult()); |
| | | tjPdfVO.setExc(tjOrderDetail.getExceptionDesc()); |
| | | if (null != tjProject.getProMetering()) { |
| | | tjPdfVO.setCompany(tjProject.getProMetering()); |
| | | } else { |
| | | tjPdfVO.setCompany(tjOrderDetail.getStandard().getCompany()); |
| | | tjPdfVO.setCompany("/"); |
| | | } |
| | | // TODO 设置单位 |
| | | //最大值和最小值 |
| | | String tjStandardGtValue = tjOrderDetail.getStandard().getTjStandardGtValue(); |
| | | String tjStandardLtValue = tjOrderDetail.getStandard().getTjStandardLtValue(); |
| | | if (tjStandardGtValue == null) { |
| | | tjStandardGtValue = " "; |
| | | tjPdfVO.setProId(String.valueOf(tjOrderDetail.getProject().getProId())); |
| | | LambdaQueryWrapper<LtkjExamJcbgd> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.eq(LtkjExamJcbgd::getTjh, tjNumber); |
| | | wrapper.like(LtkjExamJcbgd::getXmdm, String.valueOf(tjOrderDetail.getProject().getProParentId())); |
| | | wrapper.orderByDesc(LtkjExamJcbgd::getZdsj); |
| | | List<LtkjExamJcbgd> list = jcbgdService.list(wrapper); |
| | | if (null != list && !list.isEmpty()) { |
| | | LtkjExamJcbgd jcbgd = list.get(0); |
| | | if (jcbgd != null) { |
| | | tjPdfVO.setTs(jcbgd.getYxbx()); |
| | | tjPdfVO.setSj(jcbgd.getBgNr()); |
| | | tjPdfVO.setShys(jcbgd.getShysxm()); |
| | | tjPdfVO.setProName(jcbgd.getXmmc()); |
| | | ids += "|" + jcbgd.getXmdm(); |
| | | } |
| | | } |
| | | if (tjStandardLtValue == null) { |
| | | tjStandardLtValue = " "; |
| | | } |
| | | tjPdfVO.setStandardValue(tjStandardLtValue + "-" + tjStandardGtValue); |
| | | tjPdfVOS.add(tjPdfVO); |
| | | } |
| | | tjPdfVOS.add(tjPdfVO); |
| | | } |
| | | } |
| | | printReport.put(entry.getKey(), tjPdfVOS); |
| | |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * @param document |
| | | * @param titleName |
| | | * @param titles |
| | |
| | | document.add(table); |
| | | } |
| | | |
| | | private static void addJianYanTable(Document document, String titleName, String[] titles, float[] titlesWidth, ArrayList<List<String >> lists) throws DocumentException { |
| | | Font titleFont = PdfUtils.setFont(9); |
| | | 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(DEFAULT_TITLE_FONT_SIZE); |
| | | // if (dictHosp.getHospName().equals("澄合矿务局中心医院")) { |
| | | if (true) { |
| | | titleFont.setSize(DEFAULT_TITLE_FONT_SIZE); |
| | | titleFont.setStyle(Font.BOLD); |
| | | } |
| | | Paragraph paragraph = new Paragraph(titleName, titleFont); |
| | | // 设置文字居中 |
| | | paragraph.setAlignment(Element.ALIGN_LEFT); |
| | | // 行间距 |
| | | paragraph.setLeading(5f); |
| | |
| | | paragraph.setSpacingBefore(10f); |
| | | // 设置段落下空白 |
| | | paragraph.setSpacingAfter(10f); |
| | | document.add(paragraph); |
| | | // if (dictHosp.getHospName().equals("澄合矿务局中心医院")) { |
| | | if (true) { |
| | | // 行间距 |
| | | paragraph.setLeading(7f); |
| | | // 设置段落上空白 |
| | | paragraph.setSpacingBefore(12f); |
| | | // 设置段落下空白 |
| | | paragraph.setSpacingAfter(12f); |
| | | // 大项 |
| | | PdfPCell cellTitle = new PdfPCell(paragraph); |
| | | cellTitle.setBorder(Rectangle.NO_BORDER); |
| | | Color color = Color.decode(colorStr); |
| | | cellTitle.setBackgroundColor(new BaseColor(color.getRed(), color.getGreen(), color.getBlue())); // 设置背景颜色(十六进制 RGB) |
| | | // 创建表格并添加单元格 |
| | | PdfPTable tableTitle = new PdfPTable(1); |
| | | tableTitle.setWidthPercentage(100); |
| | | tableTitle.addCell(cellTitle); |
| | | |
| | | // 将表格添加到文档中 |
| | | document.add(tableTitle); |
| | | } else { |
| | | document.add(paragraph); |
| | | } |
| | | // 创建一个表格并添加到文档 |
| | | 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 = new PdfPTable(titlesWidth); |
| | | table.setTotalWidth(PageSize.A4.getWidth() - 100); // 设置表格总宽度 |
| | | table.setLockedWidth(true); // 锁定表格宽度 |
| | | table.setTotalWidth(PageSize.A4.getWidth() - 10); // 设置表格总宽度 |
| | | //table.setLockedWidth(true); // 锁定表格宽度 |
| | | table.setHorizontalAlignment(Element.ALIGN_LEFT); |
| | | table.getDefaultCell().setBorder(0); |
| | | table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT); |
| | |
| | | cell.setVerticalAlignment(Element.ALIGN_MIDDLE); |
| | | cell.setHorizontalAlignment(Element.ALIGN_LEFT); |
| | | cell.setBorder(Rectangle.NO_BORDER); // 移除单元格边框 |
| | | |
| | | // Color color = Color.decode(colorStr); |
| | | // cell.setBackgroundColor(new BaseColor(color.getRed(), color.getGreen(), color.getBlue())); // 设置背景颜色(十六进制 RGB) |
| | | |
| | | table.addCell(cell); |
| | | } |
| | | |
| | | for (List<String> list : lists) { |
| | | boolean isYc = false; |
| | | textFont = PdfUtils.setFont(DEFAULT_FONT_SIZE); |
| | | // if (dictHosp.getHospName().equals("澄合矿务局中心医院")){ |
| | | if (true) { |
| | | if (list.contains("↓") || list.contains("↑")) { |
| | | isYc = true; |
| | | } |
| | | } |
| | | int index = 1; |
| | | for (String s : list) { |
| | | // 跳过项目id |
| | | if (index == 6) continue; |
| | | PdfPCell nameCell = new PdfPCell(); |
| | | nameCell.setVerticalAlignment(Element.ALIGN_MIDDLE); |
| | | nameCell.setHorizontalAlignment(Element.ALIGN_LEFT); |
| | | nameCell.setPhrase(new Paragraph(s, textFont)); |
| | | |
| | | nameCell.setBorder(Rectangle.NO_BORDER); // 移除单元格边框 |
| | | if (isYc) { |
| | | textFont.setStyle(Font.BOLD); |
| | | nameCell.setPhrase(new Paragraph(s, textFont)); |
| | | nameCell.setBorder(Rectangle.NO_BORDER); |
| | | // Color color = Color.decode("#0033cc"); |
| | | // nameCell.setBackgroundColor(new BaseColor(color.getRed(), color.getGreen(), color.getBlue())); // 设置背景颜色(十六进制 RGB) |
| | | } else { |
| | | nameCell.setPhrase(new Paragraph(s, textFont)); |
| | | } |
| | | table.addCell(nameCell); |
| | | index++; |
| | | } |
| | | } |
| | | document.add(table); |
| | |
| | | |
| | | /** |
| | | * 创建检查pdf |
| | | * |
| | | * @param xm |
| | | * @param xb |
| | | * @param nl |
| | |
| | | * @param footer |
| | | * @return bytearrayoutputstream |
| | | */ |
| | | public static ByteArrayOutputStream makeJcPDFByteArrayStream(String xm, String xb, String nl, String jcks, String zyh, String ch, String sjks, String jcsb, String jch, String jcxm, String ms, String ts, File[] files,String footer) { |
| | | public static ByteArrayOutputStream makeJcPDFByteArrayStream(String xm, String xb, String nl, String jcks, String zyh, String ch, String sjks, String jcsb, String jch |
| | | , String jcxm, String ms, String ts, File[] files, String footer, Paragraph elements) { |
| | | try { |
| | | Document document = new Document(PageSize.A4); |
| | | ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
| | | PdfWriter writer = PdfWriter.getInstance(document, baos); |
| | | writer.setPageEvent(new Footer(footer)); |
| | | if (footer != null) { |
| | | writer.setPageEvent(new Footer(footer)); |
| | | } else { |
| | | writer.setPageEvent(new Footer(elements)); |
| | | } |
| | | document.open(); |
| | | document.setMargins(70, 70, 40, 40); |
| | | |
| | |
| | | table1.setSpacingAfter(10f); |
| | | |
| | | Font titleFont = PdfUtils.setFont(12); |
| | | PdfPCell mergedCell = new PdfPCell(new Phrase("泾 川 县 人 民 医 院", titleFont)); |
| | | // PdfPCell mergedCell = new PdfPCell(new Phrase("陕健医澄合矿务局中心医院", titleFont)); |
| | | PdfPCell mergedCell = new PdfPCell(new Phrase(HOSP_NAME, titleFont)); |
| | | mergedCell.setBorder(Rectangle.NO_BORDER); |
| | | mergedCell.setColspan(10); |
| | | mergedCell.setHorizontalAlignment(Element.ALIGN_CENTER); |
| | |
| | | float[] columnWidths = {0.8f, 0.8f, 0.8f, 0.8f, 0.1f, 0.1f, 0.8f, 0.8f, 0.8f, 0.8f}; |
| | | table2.setWidths(columnWidths); |
| | | |
| | | if(files != null){ |
| | | if (files != null) { |
| | | int imageIndex = 0; |
| | | while (imageIndex < files.length) { |
| | | // 第一张图片占位符 |
| | |
| | | return baos; |
| | | } catch (DocumentException | IOException e) { |
| | | e.printStackTrace(); |
| | | return null; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | private static PdfPCell createImageCell(String path) throws IOException, BadElementException { |
| | |
| | | static class Footer extends PdfPageEventHelper { |
| | | private String footerText; |
| | | private Font footerFont = PdfUtils.setFont(10); |
| | | private Paragraph paragraph; |
| | | |
| | | public Footer(String footerText) { |
| | | this.footerText = footerText; |
| | | } |
| | | |
| | | public Footer(Paragraph paragraph) { |
| | | this.paragraph = paragraph; |
| | | } |
| | | |
| | | @Override |
| | |
| | | footer.setWidthPercentage(100); |
| | | footer.getDefaultCell().setBorder(Rectangle.NO_BORDER); |
| | | footer.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); |
| | | footer.addCell(new Phrase(footerText, footerFont)); |
| | | if (footerText != null) |
| | | footer.addCell(new Phrase(footerText, footerFont)); |
| | | if (paragraph != null) |
| | | footer.addCell(paragraph); |
| | | footer.writeSelectedRows(0, -1, 36, 50, writer.getDirectContent()); |
| | | } |
| | | } |
| | | |
| | | footer.writeSelectedRows(0, -1, 36, 36, writer.getDirectContent()); |
| | | // 自定义页脚和页眉的绘制 |
| | | 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, Integer page) { |
| | | this.name = name; |
| | | this.tjNumber = tjNumber; |
| | | this.tjName = tjName; |
| | | this.sex = sex; |
| | | this.age = age; |
| | | this.page = page; |
| | | } |
| | | |
| | | // 在每一页的顶部绘制页眉 |
| | | @Override |
| | | public void onStartPage(PdfWriter writer, Document document) { |
| | | // 获取页面宽度和高度 |
| | | float width = document.getPageSize().getWidth(); |
| | | float margin = document.leftMargin(); |
| | | |
| | | // 创建页眉表格:2行,第一行包含姓名、性别、年龄和体检号,第二行是分割线 |
| | | PdfPTable headerTable = new PdfPTable(2); // 2列:第一列为姓名、性别、年龄,第二列为体检号 |
| | | headerTable.setWidthPercentage(100); // 设置宽度为100% |
| | | headerTable.setSpacingAfter(10); // 页眉与内容之间的间距 |
| | | |
| | | // 设置列宽度 |
| | | float[] columnWidths = {0.6f, 0.4f}; // 第一列占 60%,第二列占 40% |
| | | try { |
| | | headerTable.setWidths(columnWidths); |
| | | } catch (DocumentException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | // 第一行:姓名、性别、年龄以及体检号 |
| | | PdfPCell infoCell = new PdfPCell(new Phrase("姓名:" + tjName + " 性别:" + sex + " 年龄:" + age, PdfUtils.setFont(8))); |
| | | infoCell.setBorder(Rectangle.NO_BORDER); |
| | | infoCell.setHorizontalAlignment(Element.ALIGN_LEFT); // 第一列左对齐 |
| | | infoCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 垂直居中 |
| | | headerTable.addCell(infoCell); |
| | | |
| | | PdfPCell idCell = new PdfPCell(new Phrase("体检号:" + tjNumber, PdfUtils.setFont(8))); |
| | | idCell.setBorder(Rectangle.NO_BORDER); |
| | | idCell.setHorizontalAlignment(Element.ALIGN_RIGHT); // 第二列右对齐 |
| | | idCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 垂直居中 |
| | | headerTable.addCell(idCell); |
| | | |
| | | // 第二行:淡灰色分割线 |
| | | PdfPCell separatorCell = new PdfPCell(); |
| | | separatorCell.setBorder(Rectangle.TOP); // 设置上边框 |
| | | separatorCell.setBorderColor(BaseColor.LIGHT_GRAY); // 设置为淡灰色 |
| | | separatorCell.setBorderWidthTop(0.5f); // 设置上边框的宽度 |
| | | separatorCell.setColspan(2); // 合并两列 |
| | | headerTable.addCell(separatorCell); |
| | | |
| | | // 将页眉表格添加到文档 |
| | | try { |
| | | document.add(headerTable); |
| | | } catch (DocumentException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | // 在每一页的底部绘制页脚 |
| | | @SneakyThrows |
| | | @Override |
| | | public void onEndPage(PdfWriter writer, Document document) { |
| | | // 获取页面宽度和高度 |
| | | float width = document.getPageSize().getWidth(); |
| | | float height = document.getPageSize().getHeight(); |
| | | float margin = document.leftMargin(); |
| | | |
| | | // 页脚距离底部的位置,确保其位于页面底部 增加是上移 减少是下移 |
| | | float footerPositionY = document.bottomMargin(); |
| | | |
| | | // 页脚表格:2行2列,第一行医院名和页码,第二行祝福语 |
| | | PdfPTable footerTable = new PdfPTable(2); // 2列,第一列医院名,第二列页码 |
| | | footerTable.setWidthPercentage(100); // 设置宽度为100%,使其水平居中 |
| | | footerTable.setTotalWidth(width - margin * 2 + 10); // 设置总宽度,避免与页边距重叠 |
| | | footerTable.setSpacingBefore(0); // 去除表格顶部的间距 |
| | | footerTable.setSpacingAfter(0); // 去除表格底部的间距 |
| | | footerTable.getDefaultCell().setBorder(Rectangle.NO_BORDER); // 去除所有单元格的边框 |
| | | float[] columnWidths = {2.5f, 2f}; // 第一列占 1,第二列占 2 |
| | | footerTable.setWidths(columnWidths); // 设置列宽比例 |
| | | |
| | | // 第一行:医院名和页码 |
| | | PdfPCell hospitalNameCell = new PdfPCell(new Phrase(name, PdfUtils.setFont(8))); |
| | | hospitalNameCell.setHorizontalAlignment(Element.ALIGN_RIGHT); // 水平居中 |
| | | hospitalNameCell.setVerticalAlignment(Element.ALIGN_TOP); // 垂直对齐到底部 |
| | | hospitalNameCell.setMinimumHeight(12f); // 设置最小高度,避免高度过大 |
| | | hospitalNameCell.setBorder(Rectangle.TOP); // 设置上边框 |
| | | hospitalNameCell.setBorderColor(BaseColor.LIGHT_GRAY); // 设置上边框为淡灰色 |
| | | hospitalNameCell.setBorderWidthTop(0.5f); // 设置上边框宽度 |
| | | footerTable.addCell(hospitalNameCell); |
| | | |
| | | // 创建页码的单元格:右对齐 |
| | | 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); // 垂直对齐到底部 |
| | | pageCell.setMinimumHeight(12f); // 设置最小高度,避免高度过大 |
| | | pageCell.setBorder(Rectangle.TOP); // 设置上边框 |
| | | pageCell.setBorderColor(BaseColor.LIGHT_GRAY); // 设置上边框为淡灰色 |
| | | pageCell.setBorderWidthTop(0.5f); // 设置上边框宽度 |
| | | footerTable.addCell(pageCell); |
| | | |
| | | // 第二行:祝福语,合并两列 |
| | | PdfPCell footerTextCell = new PdfPCell(new Phrase("本体检报告仅供临床参考,不作为临床依据,祝您身体健康!!!", PdfUtils.setFont(8))); |
| | | footerTextCell.setColspan(2); // 合并两列 |
| | | footerTextCell.setHorizontalAlignment(Element.ALIGN_CENTER); // 居中 |
| | | footerTextCell.setVerticalAlignment(Element.ALIGN_TOP); // 垂直对齐到底部 |
| | | footerTextCell.setMinimumHeight(14f); // 设置最小高度,避免高度过大 |
| | | footerTextCell.setBorder(Rectangle.NO_BORDER); // 去除所有边框 |
| | | footerTable.addCell(footerTextCell); |
| | | |
| | | // 页脚表格的位置:将表格写入页脚,Y 坐标需要设置为距离页面底部指定的位置 |
| | | footerTable.writeSelectedRows(0, -1, margin, footerPositionY, writer.getDirectContent()); |
| | | } |
| | | } |
| | | } |