package com.ltkj.web.controller.his;
|
|
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.json.JSONArray;
|
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.pdf.*;
|
import com.itextpdf.text.pdf.draw.LineSeparator;
|
import com.ltkj.common.core.domain.AjaxResult;
|
import com.ltkj.common.core.domain.entity.SysUser;
|
import com.ltkj.common.utils.DateUtils;
|
import com.ltkj.common.utils.StringUtils;
|
import com.ltkj.framework.config.MatchUtils;
|
import com.ltkj.hosp.domain.*;
|
import com.ltkj.hosp.service.*;
|
import com.ltkj.hosp.sqlDomain.LtkjHybgd;
|
import com.ltkj.hosp.sqlDomain.LtkjHysqd;
|
import com.ltkj.mall.mallOrderUtils.TjConstants;
|
import com.ltkj.system.service.ISysUserService;
|
import com.ltkj.web.config.pdfutils.PdfUtils;
|
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 java.io.*;
|
import java.lang.reflect.Field;
|
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.Method;
|
import java.math.BigDecimal;
|
import java.util.*;
|
import java.util.List;
|
|
import static com.ltkj.web.config.pdfutils.PDFBinaryUtil.getPDFBinary;
|
|
/**
|
* 检查 检验报告pdf生成
|
*/
|
@Slf4j
|
@Component
|
public class HisPDFUtil {
|
@Autowired
|
private HisApiGetMethodService apiGetMethodService;
|
@Autowired
|
private ITjOrderService tjOrderService;
|
@Autowired
|
private ITjCustomerService tjCustomerService;
|
@Autowired
|
private ITjReportService tjReportService;
|
@Autowired
|
private ITjProjectService projectService;
|
@Autowired
|
private ITjOrderRemarkService tjOrderRemarkService;
|
@Autowired
|
private ITjOrderDetailService tjOrderDetailService;
|
@Autowired
|
private ITjStandardService tjStandardService;
|
@Autowired
|
private ISysUserService userService;
|
@Autowired
|
private IDictCompService dictCompService;
|
@Autowired
|
private ITjBigPositiveService tjBigPositiveService;
|
@Autowired
|
private LtkjHybgdService ltkjHybgdService;
|
@Autowired
|
private LtkjHysqdService ltkjHysqdService;
|
@Value("${path.filePath}")
|
private String value;
|
@Value("${path.reportServer}")
|
private String urlValue;
|
|
// private static final
|
|
/**
|
* 通过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 List<Map<String, Object>> makePDFInfo(HashMap<String, Object> map, AjaxResult ajaxResult, String key) {
|
List<Map<String, Object>> data = null;
|
if (Integer.parseInt(ajaxResult.get("code").toString()) == 200) {
|
data = (List<Map<String, Object>>) ajaxResult.get("data");
|
List<Map<String, Object>> parent = (List<Map<String, Object>>) map.get(key);
|
if (parent != null) {
|
parent.addAll(data);
|
} else {
|
map.put(key, data);
|
}
|
}
|
return data;
|
}
|
|
public void putData(JSONObject jsonObject, AjaxResult result, String key) {
|
if (Integer.parseInt(result.get("code").toString()) == 200) {
|
List<Map<String, Object>> data = (List<Map<String, Object>>) result.get("data");
|
jsonObject.putOpt(key, data);
|
}
|
}
|
|
public AjaxResult hisPDF(TjOrder tjOrder,TjCustomer customer,TjReportTemplate tjReportTemplate) throws DocumentException {
|
HashMap<String, Object> pdfChangGui = makePDFInfo(tjOrder, customer, tjReportTemplate);
|
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;
|
try {
|
pdfWriter = PdfWriter.getInstance(document1, byteArrayOutputStream1);
|
} catch (DocumentException e) {
|
e.printStackTrace();
|
return AjaxResult.error();
|
}
|
document1.setMargins(70, 70, 40, 40);
|
document1.open();
|
// 非化验项目报告
|
Map<TjOrderRemark, List<TjPdfVO>> printReport = new HashMap<>();
|
notHuaYanData(tjOrder.getTjNumber(), printReport,tjOrder,customer);
|
try {
|
notHuaYanTable(document1, printReport);
|
} catch (DocumentException e) {
|
log.error("非化验项目填充表格异常");
|
e.printStackTrace();
|
return AjaxResult.error();
|
}
|
// 组装检验数据
|
HashMap<String, Object> map = makeHisJianYan(tjOrder, customer);
|
makeHisJianYanTable(document1, map);
|
|
document1.close();
|
pdfWriter.close();
|
PdfReader reader = null;
|
try {
|
reader = new PdfReader(byteArrayOutputStream1.toByteArray());
|
int numberOfPages1 = reader.getNumberOfPages();
|
for (int i = 1; i <= numberOfPages1; i++) {
|
PdfImportedPage page = copy.getImportedPage(reader, i);
|
copy.addPage(page);
|
}
|
reader.close();
|
byteArrayOutputStream1.close();
|
document.close();
|
copy.close();
|
} catch (IOException e) {
|
log.error("拷贝pdf异常");
|
e.printStackTrace();
|
return AjaxResult.error();
|
}
|
String outputFileName1 = customer.getCusId() + tjOrder.getTjNumber() + customer.getCusName() + "_报告.pdf";
|
savePDFFile(outputFileName1,tjOrder, customer, finalOutPut);
|
TjReport tjReport = new TjReport();
|
String tjNumber = tjOrder.getTjNumber();
|
tjReport.setTjNumber(String.valueOf(tjNumber));
|
tjReport.setPath(urlValue + outputFileName1);
|
// TODO 文件配置
|
// 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);
|
return AjaxResult.success();
|
}
|
|
/**
|
* PDF文件存储至本地
|
* @param tjOrder
|
* @param customer
|
* @param finalOutPut
|
*/
|
private void savePDFFile(String outputFileName1,TjOrder tjOrder, TjCustomer customer, ByteArrayOutputStream finalOutPut) {
|
// TODO 文件配置
|
// 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();
|
}
|
}
|
|
/**
|
* 填充检验表格数据
|
* @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};
|
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 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);
|
}
|
}
|
}
|
|
/**
|
* 非化验项目表格填充
|
* @param document1
|
* @param printReport
|
* @throws DocumentException
|
*/
|
private void notHuaYanTable(Document document1, Map<TjOrderRemark, List<TjPdfVO>> printReport) 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 (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);
|
}
|
}
|
}
|
|
public HashMap<String, Object> makeHisJianYan(TjOrder tjOrder, TjCustomer customer){
|
// TODO 这里先使用查全部测试
|
LambdaQueryWrapper<LtkjHysqd> ltkjHysqdLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
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());
|
List<LtkjHybgd> hybgds = ltkjHybgdService.list(ltkjHybgdLambdaQueryWrapper);
|
// 大类项目名称
|
String xmmc = hysqd.getXmmc();
|
ArrayList<List<String>> lists = new ArrayList<>();
|
HashSet<String> hashSet = new HashSet<>();
|
for (LtkjHybgd hybgd : hybgds) {
|
// 检查项目
|
String jcxm = hybgd.getJcxm();
|
// 检验结果
|
String jyjg = hybgd.getJyjg();
|
// 结果单位
|
String jgdw = hybgd.getJgdw();
|
// 范围值
|
String fwz = hybgd.getFwz();
|
// 检验医师
|
String jyys = hybgd.getJyys();
|
if (jyjg != null && StrUtil.isNotBlank(jyjg) && fwz != null && StrUtil.isNotBlank(fwz)){
|
try {
|
String[] fwzs = fwz.split("-");
|
BigDecimal min = new BigDecimal(fwzs[0]);
|
BigDecimal max = new BigDecimal(fwzs[1]);
|
BigDecimal jyjgval = new BigDecimal(jyjg);
|
// 比较检验结果和范围值
|
if (jyjgval.compareTo(min) < 0) {
|
// jyjg 小于范围最小值,添加下箭头
|
jyjg = jyjg + " ↓";
|
} else if (jyjgval.compareTo(max) > 0) {
|
// jyjg 大于范围最大值,添加上箭头
|
jyjg = jyjg + " ↑";
|
}
|
} 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());
|
ArrayList<String> strings = new ArrayList<>();
|
strings.add(jcxm);
|
strings.add(jyjg);
|
strings.add(jgdw);
|
strings.add(fwz);
|
lists.add(strings);
|
}
|
if (!lists.isEmpty()) {
|
HashMap<String, Object> map = new HashMap<>();
|
map.put("data",lists);
|
map.put("jyys",hashSet);
|
data.put(xmmc, map);
|
}
|
}
|
return data;
|
}
|
|
/**
|
* 生成PDF模版以及用户信息部分
|
* @param tjOrder
|
* @param reportTemplate
|
*/
|
public HashMap<String ,Object> makePDFInfo(TjOrder tjOrder,TjCustomer tjCustomer,TjReportTemplate reportTemplate){
|
String tjNumber = tjOrder.getTjNumber();
|
String template = reportTemplate.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());
|
//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);
|
}
|
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
PdfReader reader = null;
|
PdfStamper pdfStamper = null;
|
try {
|
reader = new PdfReader(new ByteArrayInputStream(Base64.getDecoder().decode(template)));
|
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();
|
HashMap<String, Object> map = new HashMap<>();
|
map.put("document",document);
|
map.put("copy",copy);
|
map.put("stream",finalOutPut);
|
return map;
|
} catch (IOException | DocumentException e) {
|
e.printStackTrace();
|
return null;
|
}
|
}
|
|
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);
|
}
|
// 生成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";
|
// TODO 文件配置
|
// 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;
|
}
|
|
// 组合非化验项目报告数据
|
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);
|
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());
|
for (TjOrderDetail tjOrderDetail : tjOrderDetails) {
|
TjProject tjProject = projectService.getById(tjOrderDetail.getProId());
|
if (null != tjProject) {
|
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(" ");
|
} else {
|
tjPdfVO.setCompany(tjOrderDetail.getStandard().getCompany());
|
}
|
// TODO 设置单位
|
//最大值和最小值
|
String tjStandardGtValue = tjOrderDetail.getStandard().getTjStandardGtValue();
|
String tjStandardLtValue = tjOrderDetail.getStandard().getTjStandardLtValue();
|
if (tjStandardGtValue == null) {
|
tjStandardGtValue = " ";
|
}
|
if (tjStandardLtValue == null) {
|
tjStandardLtValue = " ";
|
}
|
tjPdfVO.setStandardValue(tjStandardLtValue + "-" + tjStandardGtValue);
|
}
|
tjPdfVOS.add(tjPdfVO);
|
}
|
}
|
printReport.put(entry.getKey(), tjPdfVOS);
|
}
|
}
|
|
/**
|
* 设置用户信息
|
*
|
* @param tjNumber
|
* @param tjOrder
|
* @param tjCustomer
|
* @param data
|
*/
|
private void setUserInfo(String tjNumber, TjOrder tjOrder, TjCustomer tjCustomer, Map<String, Object> data) {
|
//填充性别:判断男女
|
Long cusSex = tjCustomer.getCusSex();
|
String sex;
|
String name1;
|
String tjtype;
|
if (cusSex == 0) {
|
sex = "男";
|
name1 = tjCustomer.getCusName() + "先生";
|
} else {
|
sex = "女";
|
name1 = tjCustomer.getCusName() + "女士";
|
}
|
data.put("name", tjCustomer.getCusName());
|
data.put("cusId", tjCustomer.getCusId());
|
data.put("name1", name1);
|
if ("1".equals(tjOrder.getTjType())) {
|
tjtype = "团队";
|
data.put("tjtype", tjtype);
|
} else {
|
tjtype = "个人";
|
data.put("tjtype", tjtype);
|
}
|
data.put("dstype", "统一");
|
data.put("sex", sex);
|
data.put("age", DateUtil.ageOfNow(tjCustomer.getCusBrithday()));
|
data.put("tjnumber", tjNumber);
|
data.put("tjdate", DateUtils.parseDateToStr("yyyy/MM/dd", tjOrder.getCreateTime()));
|
data.put("phone", tjCustomer.getCusPhone());
|
data.put("idcard", MatchUtils.hideIdCardNum(tjCustomer.getCusIdcard()));
|
data.put("num2", 0);
|
data.put("num3", 4);
|
}
|
|
/**
|
*
|
* @param document
|
* @param titleName
|
* @param titles
|
* @param titlesWidth
|
* @param list
|
* @throws DocumentException
|
* @deprecated 数据从数据库查有具体的实体类
|
*/
|
@Deprecated
|
private static void addTable(Document document, String titleName, String[] titles, float[] titlesWidth, ArrayList<TjPdfVO> list) throws DocumentException {
|
Font titleFont = PdfUtils.setFont(9);
|
Paragraph paragraph = new Paragraph(titleName, titleFont);
|
// 设置文字居中
|
paragraph.setAlignment(Element.ALIGN_LEFT);
|
// 行间距
|
paragraph.setLeading(5f);
|
// 设置段落上空白
|
paragraph.setSpacingBefore(10f);
|
// 设置段落下空白
|
paragraph.setSpacingAfter(10f);
|
document.add(paragraph);
|
// 创建一个表格并添加到文档
|
Font headFont = PdfUtils.setFont(9);
|
Font textFont = PdfUtils.setFont(9);
|
PdfPTable table = new PdfPTable(titlesWidth);
|
table.setTotalWidth(PageSize.A4.getWidth() - 100); // 设置表格总宽度
|
table.setLockedWidth(true); // 锁定表格宽度
|
table.setHorizontalAlignment(Element.ALIGN_LEFT);
|
table.getDefaultCell().setBorder(0);
|
table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
|
for (String title : titles) {
|
PdfPCell cell = new PdfPCell(new Paragraph(title, headFont));
|
cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
|
cell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
cell.setBorder(Rectangle.NO_BORDER); // 移除单元格边框
|
table.addCell(cell);
|
}
|
for (TjPdfVO item : list) {
|
Class<? extends TjPdfVO> aClass = item.getClass();
|
Field[] fields = aClass.getDeclaredFields();
|
ArrayList<String> values = new ArrayList<>();
|
for (Field field : fields) {
|
String fieldName = field.getName();
|
String getterName = "get" + Character.toUpperCase(fieldName.charAt(0)) + fieldName.substring(1);
|
try {
|
Method method = aClass.getDeclaredMethod(getterName);
|
if (method != null) {
|
Object invoke = method.invoke(item);
|
if (invoke != null) {
|
values.add(String.valueOf(invoke));
|
}
|
}
|
} catch (NoSuchMethodException e) {
|
log.error("根据字段获取get方法异常 ->{}", e.getMessage());
|
} catch (InvocationTargetException | IllegalAccessException e) {
|
log.error("反射获取类字段异常 ->{}", e.getMessage());
|
}
|
}
|
for (int i = 0; i < values.size(); i++) {
|
String value = String.valueOf(values.get(i));
|
Paragraph elements = null;
|
if (StrUtil.isBlank(value) || value.equals("null")) {
|
elements = new Paragraph("", textFont);
|
} else {
|
elements = new Paragraph(value, textFont);
|
}
|
PdfPCell nameCell = new PdfPCell();
|
nameCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
|
nameCell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
nameCell.setPhrase(elements);
|
nameCell.setBorder(Rectangle.NO_BORDER); // 移除单元格边框
|
table.addCell(nameCell);
|
}
|
}
|
// 将表格添加到文档
|
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);
|
Paragraph paragraph = new Paragraph(titleName, titleFont);
|
// 设置文字居中
|
paragraph.setAlignment(Element.ALIGN_LEFT);
|
// 行间距
|
paragraph.setLeading(5f);
|
// 设置段落上空白
|
paragraph.setSpacingBefore(10f);
|
// 设置段落下空白
|
paragraph.setSpacingAfter(10f);
|
document.add(paragraph);
|
// 创建一个表格并添加到文档
|
Font headFont = PdfUtils.setFont(9);
|
Font textFont = PdfUtils.setFont(9);
|
PdfPTable table = new PdfPTable(titlesWidth);
|
table.setTotalWidth(PageSize.A4.getWidth() - 100); // 设置表格总宽度
|
table.setLockedWidth(true); // 锁定表格宽度
|
table.setHorizontalAlignment(Element.ALIGN_LEFT);
|
table.getDefaultCell().setBorder(0);
|
table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
|
for (String title : titles) {
|
PdfPCell cell = new PdfPCell(new Paragraph(title, headFont));
|
cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
|
cell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
cell.setBorder(Rectangle.NO_BORDER); // 移除单元格边框
|
table.addCell(cell);
|
}
|
for (List<String> list : lists) {
|
for (String s : list) {
|
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); // 移除单元格边框
|
table.addCell(nameCell);
|
}
|
}
|
document.add(table);
|
}
|
|
/**
|
* 创建检查pdf
|
* @param xm
|
* @param xb
|
* @param nl
|
* @param jcks
|
* @param zyh
|
* @param ch
|
* @param sjks
|
* @param jcsb
|
* @param jch
|
* @param jcxm
|
* @param ms
|
* @param ts
|
* @param files
|
* @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) {
|
try {
|
Document document = new Document(PageSize.A4);
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
PdfWriter writer = PdfWriter.getInstance(document, baos);
|
writer.setPageEvent(new Footer(footer));
|
document.open();
|
document.setMargins(70, 70, 40, 40);
|
|
// 创建第一个表格:图片之前的内容
|
PdfPTable table1 = new PdfPTable(10);
|
table1.setWidthPercentage(100);
|
table1.setSpacingBefore(10f);
|
table1.setSpacingAfter(10f);
|
|
Font titleFont = PdfUtils.setFont(12);
|
PdfPCell mergedCell = new PdfPCell(new Phrase("泾 川 县 人 民 医 院", titleFont));
|
mergedCell.setBorder(Rectangle.NO_BORDER);
|
mergedCell.setColspan(10);
|
mergedCell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
table1.addCell(mergedCell);
|
|
mergedCell = new PdfPCell(new Phrase(" "));
|
mergedCell.setBorder(Rectangle.NO_BORDER);
|
mergedCell.setColspan(10);
|
mergedCell.setFixedHeight(1f);
|
table1.addCell(mergedCell);
|
|
titleFont = PdfUtils.setFont(15);
|
mergedCell = new PdfPCell(new Phrase("检查报告单", titleFont));
|
mergedCell.setBorder(Rectangle.NO_BORDER);
|
mergedCell.setColspan(10);
|
mergedCell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
table1.addCell(mergedCell);
|
|
mergedCell = new PdfPCell(new Phrase(" "));
|
mergedCell.setBorder(Rectangle.NO_BORDER);
|
mergedCell.setColspan(10);
|
table1.addCell(mergedCell);
|
|
titleFont = PdfUtils.setFont(10);
|
PdfPCell textFieldCell = new PdfPCell();
|
|
mergedCell = new PdfPCell(new Phrase("姓 名:", titleFont));
|
mergedCell.setBorder(Rectangle.TOP);
|
mergedCell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
mergedCell.setColspan(1);
|
table1.addCell(mergedCell);
|
|
mergedCell = new PdfPCell(new Phrase(xm, titleFont));
|
mergedCell.setBorder(Rectangle.TOP);
|
mergedCell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
mergedCell.setColspan(1);
|
table1.addCell(mergedCell);
|
|
mergedCell = new PdfPCell(new Phrase("性 别:", titleFont));
|
mergedCell.setBorder(Rectangle.TOP);
|
mergedCell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
mergedCell.setColspan(1);
|
table1.addCell(mergedCell);
|
|
mergedCell = new PdfPCell(new Phrase(xb, titleFont));
|
mergedCell.setBorder(Rectangle.TOP);
|
mergedCell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
mergedCell.setColspan(1);
|
table1.addCell(mergedCell);
|
|
mergedCell = new PdfPCell(new Phrase("年 龄:", titleFont));
|
mergedCell.setBorder(Rectangle.TOP);
|
mergedCell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
mergedCell.setColspan(1);
|
table1.addCell(mergedCell);
|
|
mergedCell = new PdfPCell(new Phrase(nl, titleFont));
|
mergedCell.setBorder(Rectangle.TOP);
|
mergedCell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
mergedCell.setColspan(1);
|
table1.addCell(mergedCell);
|
|
mergedCell = new PdfPCell(new Phrase("检查科室:", titleFont));
|
mergedCell.setBorder(Rectangle.TOP);
|
mergedCell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
mergedCell.setColspan(1);
|
table1.addCell(mergedCell);
|
|
mergedCell = new PdfPCell(new Phrase(jcks, titleFont));
|
mergedCell.setBorder(Rectangle.TOP);
|
mergedCell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
mergedCell.setColspan(3);
|
table1.addCell(mergedCell);
|
|
mergedCell = new PdfPCell(new Phrase("住 院 号:", titleFont));
|
mergedCell.setBorder(Rectangle.NO_BORDER);
|
mergedCell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
mergedCell.setColspan(1);
|
table1.addCell(mergedCell);
|
|
mergedCell = new PdfPCell(new Phrase(zyh, titleFont));
|
mergedCell.setBorder(Rectangle.NO_BORDER);
|
mergedCell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
mergedCell.setColspan(1);
|
table1.addCell(mergedCell);
|
|
mergedCell = new PdfPCell(new Phrase("床 号:", titleFont));
|
mergedCell.setBorder(Rectangle.NO_BORDER);
|
mergedCell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
mergedCell.setColspan(1);
|
table1.addCell(mergedCell);
|
|
mergedCell = new PdfPCell(new Phrase(ch, titleFont));
|
mergedCell.setBorder(Rectangle.NO_BORDER);
|
mergedCell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
mergedCell.setColspan(1);
|
table1.addCell(mergedCell);
|
|
mergedCell = new PdfPCell(new Phrase("送检科室:", titleFont));
|
mergedCell.setBorder(Rectangle.NO_BORDER);
|
mergedCell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
mergedCell.setColspan(1);
|
table1.addCell(mergedCell);
|
|
mergedCell = new PdfPCell(new Phrase(sjks, titleFont));
|
mergedCell.setBorder(Rectangle.NO_BORDER);
|
mergedCell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
mergedCell.setColspan(2);
|
table1.addCell(mergedCell);
|
|
mergedCell = new PdfPCell(new Phrase("检查设备:", titleFont));
|
mergedCell.setBorder(Rectangle.NO_BORDER);
|
mergedCell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
mergedCell.setColspan(1);
|
table1.addCell(mergedCell);
|
|
mergedCell = new PdfPCell(new Phrase(jcsb, titleFont));
|
mergedCell.setBorder(Rectangle.NO_BORDER);
|
mergedCell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
mergedCell.setColspan(2);
|
table1.addCell(mergedCell);
|
|
mergedCell = new PdfPCell(new Phrase("检查号:", titleFont));
|
mergedCell.setBorder(Rectangle.BOTTOM);
|
mergedCell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
mergedCell.setColspan(1);
|
table1.addCell(mergedCell);
|
|
mergedCell = new PdfPCell(new Phrase(jch, titleFont));
|
mergedCell.setBorder(Rectangle.BOTTOM);
|
mergedCell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
mergedCell.setColspan(2);
|
table1.addCell(mergedCell);
|
|
mergedCell = new PdfPCell(new Phrase("检查项目:", titleFont));
|
mergedCell.setBorder(Rectangle.BOTTOM);
|
mergedCell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
mergedCell.setColspan(1);
|
table1.addCell(mergedCell);
|
|
mergedCell = new PdfPCell(new Phrase(jcxm, titleFont));
|
mergedCell.setBorder(Rectangle.BOTTOM);
|
mergedCell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
mergedCell.setColspan(6);
|
table1.addCell(mergedCell);
|
|
// 创建第二个表格:显示图片部分
|
PdfPTable table2 = new PdfPTable(10);
|
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){
|
int imageIndex = 0;
|
while (imageIndex < files.length) {
|
// 第一张图片占位符
|
if (imageIndex < files.length) {
|
PdfPCell imageCell = createImageCell(files[imageIndex].getPath());
|
imageCell.setColspan(4);
|
table2.addCell(imageCell);
|
imageIndex++;
|
}
|
// 调整这个单元格占用的宽度 不影响其他行
|
PdfPCell middleBlankCell = new PdfPCell(new Phrase(""));
|
middleBlankCell.setColspan(2);
|
middleBlankCell.setBorder(Rectangle.NO_BORDER);
|
table2.addCell(middleBlankCell);
|
// 第二张图片占位符
|
if (imageIndex < files.length) {
|
PdfPCell imageCell = createImageCell(files[imageIndex].getPath());
|
imageCell.setColspan(4);
|
table2.addCell(imageCell);
|
imageIndex++;
|
}
|
// 完成当前行
|
table2.completeRow();
|
}
|
}
|
// 创建第三个表格:图片之后的内容
|
PdfPTable table3 = new PdfPTable(10);
|
table3.setWidthPercentage(100);
|
table3.setSpacingBefore(10f);
|
table3.setSpacingAfter(10f);
|
|
mergedCell = new PdfPCell(new Phrase("描述:", titleFont));
|
mergedCell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
mergedCell.setBorder(Rectangle.NO_BORDER);
|
table3.addCell(mergedCell);
|
|
mergedCell = new PdfPCell(new Phrase(""));
|
mergedCell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
mergedCell.setBorder(Rectangle.NO_BORDER);
|
mergedCell.setColspan(9);
|
table3.addCell(mergedCell);
|
|
mergedCell = new PdfPCell(new Phrase("", titleFont));
|
mergedCell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
mergedCell.setBorder(Rectangle.NO_BORDER);
|
table3.addCell(mergedCell);
|
|
Phrase phrase = new Phrase(ms, titleFont);
|
PdfPCell textCell = new PdfPCell(phrase);
|
textCell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
textCell.setBorder(Rectangle.NO_BORDER);
|
textCell.setColspan(10);
|
table3.addCell(textCell);
|
|
mergedCell = new PdfPCell(new Phrase("提示:", titleFont));
|
mergedCell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
mergedCell.setBorder(Rectangle.NO_BORDER);
|
table3.addCell(mergedCell);
|
|
mergedCell = new PdfPCell(new Phrase(""));
|
mergedCell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
mergedCell.setBorder(Rectangle.NO_BORDER);
|
mergedCell.setColspan(9);
|
table3.addCell(mergedCell);
|
|
mergedCell = new PdfPCell(new Phrase("", titleFont));
|
mergedCell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
mergedCell.setBorder(Rectangle.NO_BORDER);
|
table3.addCell(mergedCell);
|
|
mergedCell = new PdfPCell(new Phrase(ts, titleFont));
|
mergedCell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
mergedCell.setBorder(Rectangle.NO_BORDER);
|
mergedCell.setColspan(9);
|
table3.addCell(mergedCell);
|
|
// 添加表格到文档
|
document.add(table1);
|
document.add(table2);
|
// 在添加表格前,检查当前页是否有足够空间,如果没有则添加新页。
|
if (writer.getVerticalPosition(true) - table3.getTotalHeight() < document.bottomMargin()) {
|
document.newPage();
|
}
|
document.add(table3);
|
document.close();
|
writer.close();
|
return baos;
|
} catch (DocumentException | IOException e) {
|
e.printStackTrace();
|
}
|
return null;
|
}
|
|
private static PdfPCell createImageCell(String path) throws IOException, BadElementException {
|
Image image = Image.getInstance(path);
|
image.scaleToFit(150, 150);
|
PdfPCell cell = new PdfPCell(image);
|
cell.setBorder(Rectangle.NO_BORDER);
|
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
|
// cell.setPadding(5);
|
return cell;
|
}
|
|
static class Footer extends PdfPageEventHelper {
|
private String footerText;
|
private Font footerFont = PdfUtils.setFont(10);
|
|
public Footer(String footerText) {
|
this.footerText = footerText;
|
}
|
|
@Override
|
public void onEndPage(PdfWriter writer, Document document) {
|
PdfPTable footer = new PdfPTable(1);
|
footer.setTotalWidth(523);
|
footer.setWidthPercentage(100);
|
footer.getDefaultCell().setBorder(Rectangle.NO_BORDER);
|
footer.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
|
footer.addCell(new Phrase(footerText, footerFont));
|
|
footer.writeSelectedRows(0, -1, 36, 36, writer.getDirectContent());
|
}
|
}
|
}
|