最近没写jrt系列博客,不是中途而废了。而是在写微生物系统。今天终于把微生物大体完成了,伴随着业务的实现,框架趋于完善和稳定。构建一套完美而强大的打印体系一直是我的理想,从最开始C#的winform打印控件到刚接触bs时候用js打印html,到bs驱动cs,一路走来探索打印,虽然一直在进步,但是总归有点瑕疵。
这次我所有的打印期待在JRT上都完美的实现,为一直以为检验的打印可以算得上最复杂梯队了。
检验需要考虑下面问题:
1.打印质控图
2.打印各种报告和特殊报告
3.不光检验系统自己打印报告,还要给自助机打印,his打印,其他第三方打印
4.报告单要批量处理成pdf给第三方
5.融合自己内部打印和外部PDF文件打印
6.实现A5和A4报告混合成A4打印两个A5
7.支持打印跨平台
之前的打印报告演示是demo实例,那么这次提供完整真实的打印实现,下面是效果和代码。
调用方式
jrt打印微生物报告
/*
本代码权归属于JRT计划,任何单位或个人未经许可,不得以任何方式复制、传播、展示、发布、分发、重新分发、修改、反编译、
反向编译或以其他方式使用本框架的任何部分,包括但不限于源代码、二进制文件、文档、演示文稿、示例代码和API。
使用本框架的用户需遵守以下条款:
用户只能以个人学习和研究为目的使用本框架,不得将其用于商业用途。
用户在使用本框架时,应遵守所有适用的法律和法规,包括但不限于版权法、商标法、专利法和隐私权法。
用户在使用本框架时,应自行承担风险和责任,并确保不会侵犯任何知识产权或个人权利。
本框架的使用仅限于用户自己使用,不得将其分发给其他用户或将其用于任何形式的共享或传播。
在使用本框架时,用户应尊重和保护其他用户的隐私和个人信息,不得将其泄露给任何第三方。
违反以上条款将视为侵权行为,将采取法律手段维护JRT合法权益。
*/
import JRT.Core.DataGrid.*;
import JRT.Core.Dto.HashParam;
import JRT.Core.Dto.OutValue;
import JRT.Core.Dto.PrintElement;
import JRT.Core.Util.Convert;
import JRT.Core.Util.PrintDrawProtocol;
import JRT.Model.Bussiness.Parameters;
import JRT.Model.Entity.*;
import JRTBLLBase.BaseHttpHandlerNoSession;
import JRTBLLBase.Helper;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
/**
* 实现jrt检验报告的打印逻辑,包含检验报告和微生物报告
*/
public class LISPrintReport extends BaseHttpHandlerNoSession implements IGridChangePage {
/**
* 打印元素
*/
private List<PrintElement> retList = new ArrayList<>();
/**
* 打印模板数据
*/
JRTPrintTemplateDto template = null;
/**
* 存打印的Data数据
*/
Hashtable<String, String> printDataMap = null;
/**
* 表格换页之前要执行的逻辑
*
* @param gridKey
* @param maxY
*/
public void PreChangePageDo(String gridKey, int maxY) {
}
/**
* 表格换页之后要执行的逻辑
*
* @param gridKey
* @param maxY
*/
public void AfterChangePageDo(String gridKey, int maxY) {
System.out.println("换页后执行逻辑");
//画固定图片元素
PrintFixImage(template, retList);
//画数据元素
PrintData(template, retList, printDataMap);
//画标签元素
PrintLabel(template, retList);
//画线元素
PrintLine(template, retList);
}
/**
* 按传入的ReportDRS输出符合打印元素绘制协议的数据来实现打印控制,多个报告用上尖号分割
*
* @param Param 参数
* @param Session
* @param Output
* @return
*/
public String QueryPrintData(Parameters Param, OutValue Session, OutValue Output) throws Exception {
String ReportDRS = Param.P0;
String[] repArr = ReportDRS.split("\\^");
//循环打印每个报告
for (String repStr : repArr) {
if (Helper.IsEmptyStr(repStr)) {
continue;
}
long reportDR = Convert.ToLong(repStr);
//查询模板数据
template = GetOneTemplate(null, "ReportPrint");
//换报告之后无脑输出一个分页
retList.add(PrintDrawProtocol.ChangePage());
//查询并且填充Data
MakePrintDataMap(reportDR);
//存打印的图数据
HashMap<String, String> imgData = MakePrintImageData(reportDR);
//查询结果数据
List<Object> repResList = MakePrintResultData(reportDR);
//画固定图片元素
PrintFixImage(template, retList);
//画数据元素
PrintData(template, retList, printDataMap);
//画标签元素
PrintLabel(template, retList);
//画线元素
PrintLine(template, retList);
//画表格元素
PrintDataGrid(template, retList, repResList);
//打印报告图片
PrintReportImage(template, retList, imgData);
}
return Helper.Object2Json(retList);
}
/**
* 构造打印的报告结果数据
*
* @param reportDR 报告主键
* @return
*/
private List<Object> MakePrintResultData(long reportDR) throws Exception {
List<Object> retList = new ArrayList<>();
List<RPVisitNumberReportResult> resList = EntityManager().FindByColVal(RPVisitNumberReportResult.class, "VisitNumberReportDR", reportDR);
if (resList != null && resList.size() > 0) {
for (RPVisitNumberReportResult res : resList) {
if (res.IsNotAllowPrint != null && res.IsNotAllowPrint == true) {
continue;
}
if (Helper.IsEmptyStr(res.TextRes)) {
continue;
}
BTTestCode tsDto = EntityManager().DolerGet(BTTestCode.class, res.TestCodeDR);
HashMap out = new HashMap();
out.put("序号", retList.size() + 1);
out.put("项目名称", tsDto.CName);
out.put("缩写", tsDto.Synonym);
out.put("结果", res.TextRes);
out.put("标志", TransAbFlag(res.AbFlag));
out.put("单位", res.Unit);
out.put("参考范围", res.RefRanges);
out.put("实验方法", EntityManager().DolerGetCName(BTTestMethod.class, res.MethodDR));
out.put("多耐药", res.MultipleResChild);
if (tsDto.ResultFormat.equals("M")) {
out.put("菌落计数", res.Unit);
out.put("单位", "");
} else {
out.put("菌落计数", "");
}
out.put("专家规则", res.ExpertRule);
out.put("备注", res.ResNoes);
out.put("耐药机制", "");
//微生物取药敏结果
if (tsDto.ResultFormat.equals("M")) {
//查询药敏书记
List<RPVisitNumberReportResSen> senList = EntityManager().FindByColVal(RPVisitNumberReportResSen.class, "VisitNumberReportResultDR", res.RowID);
if (senList != null && senList.size() > 0) {
List<HashMap> senOutList = new ArrayList<>();
for (RPVisitNumberReportResSen sen : senList) {
BTAntibiotics ant = EntityManager().DolerGet(BTAntibiotics.class, sen.AntibioticsDR);
HashMap outSen = new HashMap();
outSen.put("序号", senOutList.size() + 1);
outSen.put("抗生素名称", ant.CName);
outSen.put("KB", Helper.ToStr(sen.KbValue));
outSen.put("MIC", Helper.ToStr(sen.MicValue));
outSen.put("ET", Helper.ToStr(sen.EtestValue));
outSen.put("敏感度", EntityManager().DolerGetCName(BTSensitivity.class, sen.SensitivityDR));
outSen.put("折点S", sen.SRanges);
outSen.put("折点I", sen.IRanges);
outSen.put("折点R", sen.RRanges);
outSen.put("折点SDD", sen.SDDRanges);
senOutList.add(outSen);
}
out.put("AntSen", senOutList);
}
//查询耐药机制书记
List<RPVisitNumberRepResRst> rstList=EntityManager().FindByColVal(RPVisitNumberRepResRst.class, "VisitNumberReportResultDR", res.RowID);
if(rstList!=null&&rstList.size()>0)
{
String rstStr="";
for(RPVisitNumberRepResRst rst:rstList)
{
if(Helper.IsEmptyStr(rst.TextResult))
{
continue;
}
BTMCResistanceItem rstItem=EntityManager().DolerGet(BTMCResistanceItem.class,rst.ResistanceItemDR);
rstStr+=rstItem.CName+":"+rst.TextResult+" ";
}
out.put("耐药机制", rstStr);
}
}
retList.add(out);
}
}
return retList;
}
/**
* 往打印单个数据里面塞入数据
*
* @param reportDR 报告主键
*/
private void MakePrintDataMap(long reportDR) throws Exception {
RPVisitNumberReport rep = EntityManager().DolerGet(RPVisitNumberReport.class, reportDR);
RPVisitNumberReportExt repExt = EntityManager().DolerGet(RPVisitNumberReportExt.class, rep.VisitNumberReportExtID);
RPVisitNumber vis = EntityManager().DolerGet(RPVisitNumber.class, rep.VisitNumberDR);
RPVisitNumberExt visExt = EntityManager().DolerGet(RPVisitNumberExt.class, vis.VisitNumberExtID);
//存打印的Data数据
printDataMap = new Hashtable<>();
printDataMap.put("姓名", vis.SurName);
printDataMap.put("性别", EntityManager().DolerGetCName(BTSpecies.class, vis.SpeciesDR));
printDataMap.put("年龄", vis.AgeDesc);
printDataMap.put("登记号", vis.RegNo);
printDataMap.put("检验号", vis.VisitNumber);
printDataMap.put("科室", EntityManager().DolerGetCName(BTLocation.class, vis.LocationDR));
printDataMap.put("标本", Helper.ToStr(EntityManager().DolerGetCol(BTSpecimen.class, vis.SpecimenDR, "IName")));
printDataMap.put("床号", vis.BedNo);
printDataMap.put("诊断", visExt.Symptom);
printDataMap.put("采集日期", Helper.DateIntToStr(vis.CollectDate));
printDataMap.put("采集时间", Helper.TimeIntToStr(vis.CollectTime));
printDataMap.put("医嘱备注", visExt.ReqNotes);
printDataMap.put("医嘱名称", rep.TestSetName);
printDataMap.put("申请医生", EntityManager().DolerGetCName(BTDoctor.class, vis.DoctorDR));
printDataMap.put("申请日期", Helper.DateIntToStr(vis.RequestDate));
printDataMap.put("初审者", EntityManager().DolerGetCName(SYSUser.class, rep.EntryUserDR));
printDataMap.put("初审者签名", Helper.ToStr(EntityManager().DolerGetCol(SYSUser.class, rep.EntryUserDR, "Code")));
printDataMap.put("初审日期", Helper.DateIntToStr(rep.EntryDate));
printDataMap.put("初审时间", Helper.TimeIntToStr(rep.EntryTime));
printDataMap.put("审核者", EntityManager().DolerGetCName(SYSUser.class, rep.AuthUserDR));
printDataMap.put("审核日期", Helper.DateIntToStr(rep.AuthDate));
printDataMap.put("审核时间", Helper.TimeIntToStr(rep.AuthTime));
printDataMap.put("审核者签名", Helper.ToStr(EntityManager().DolerGetCol(SYSUser.class, rep.AuthUserDR, "Code")));
printDataMap.put("出生日期", Helper.DateIntToStr(visExt.BirthDate));
printDataMap.put("仪器名称", "");
printDataMap.put("流水号", rep.EpisodeNo);
printDataMap.put("病案号", vis.MedicalRecordNo);
printDataMap.put("病区", EntityManager().DolerGetCName(BTWard.class, vis.WardDR));
printDataMap.put("血型", EntityManager().DolerGetCName(BTABOBG.class, visExt.AboDR) + EntityManager().DolerGetCName(BTRHBG.class, visExt.RhDR));
printDataMap.put("电话", visExt.MobileNo);
printDataMap.put("地址", visExt.Address);
printDataMap.put("接收者", EntityManager().DolerGetCName(SYSUser.class, vis.ReceiveUserDR));
printDataMap.put("接收者签名", Helper.ToStr(EntityManager().DolerGetCol(SYSUser.class, vis.ReceiveUserDR, "Code")));
printDataMap.put("接收日期", Helper.DateIntToStr(vis.ReceiveDate));
printDataMap.put("接收时间", Helper.TimeIntToStr(vis.ReceiveTime));
printDataMap.put("打印时间", Helper.GetNowDateStr());
printDataMap.put("核收日期", Helper.DateIntToStr(rep.AcceptDate));
printDataMap.put("核收时间", Helper.TimeIntToStr(rep.AcceptTime));
printDataMap.put("核收者", EntityManager().DolerGetCName(SYSUser.class, rep.AcceptUserDR));
printDataMap.put("核收者签名", Helper.ToStr(EntityManager().DolerGetCol(SYSUser.class, rep.AcceptUserDR, "Code")));
printDataMap.put("报告评价", repExt.MajorConclusion);
printDataMap.put("标本质量", EntityManager().DolerGetCName(BTSpecimenQuality.class, vis.SpecimenQualityDR));
BTWorkGroupMachine wgm = EntityManager().DolerGet(BTWorkGroupMachine.class, rep.WorkGroupMachineDR);
printDataMap.put("工作小组", wgm.CName);
BTWorkGroup wg = EntityManager().DolerGet(BTWorkGroup.class, wgm.WorkGroupDR);
printDataMap.put("工作组", wg.CName);
printDataMap.put("报告说明", repExt.ReportRemark);
BTHospital hos = EntityManager().DolerGet(BTHospital.class, vis.HospitalDR);
printDataMap.put("标题", hos.CName + wg.CName + "检验报告单");
printDataMap.put("采集部位", EntityManager().DolerGetCName(BTAnatomicalSite.class, vis.AnatomicalSiteDR));
printDataMap.put("患者类型", EntityManager().DolerGetCName(BTAdmissionType.class, vis.AdmissionTypeDR));
printDataMap.put("证件类型", EntityManager().DolerGetCName(BTCertType.class, visExt.CertTypeDR));
printDataMap.put("证件号", visExt.CertNo);
if (vis.Urgent != null && vis.Urgent == 1) {
printDataMap.put("加急", "急");
} else {
printDataMap.put("加急", "");
}
printDataMap.put("身份证号", vis.IDNumber);
printDataMap.put("采集者", EntityManager().DolerGetCName(SYSUser.class, vis.CollectUserDR));
printDataMap.put("采集者签名", Helper.ToStr(EntityManager().DolerGetCol(SYSUser.class, vis.CollectUserDR, "Code")));
}
/**
* 得到报告图片数据
*
* @param reprtDR
* @return
*/
private HashMap<String, String> MakePrintImageData(long reprtDR) throws Exception {
HashMap<String, String> out = new HashMap<>();
List<RPVisitNumberReportImage> imgList = EntityManager().FindByColVal(RPVisitNumberReportImage.class, "VisitNumberReportDR", reprtDR);
if (imgList != null && imgList.size() > 0) {
String fileService = (String) Helper.GetBllMethodData("common.GetParaCommon", "GetFileServiceAddr", EntityManager());
for (RPVisitNumberReportImage img : imgList) {
out.put(img.ImageClass, fileService + img.FileName);
}
}
return out;
}
/**
* 输出报告结果
*
* @param template
* @param template 模板
* @param retList 元素列表
* @param repResList 报告结果列表
*/
private void PrintDataGrid(JRTPrintTemplateDto template, List<PrintElement> retList, List<Object> repResList) throws Exception {
for (JRTPrintTemplateEle ele : template.EleList) {
//输出表格
if (ele.PrintType.equals("DataGrid")) {
if (!ele.DataField.equals("Result")) {
continue;
}
//得到表格定义
GridDto defGrid = (GridDto) Helper.Json2Object(ele.PrintText, GridDto.class);
int lastY = PrintDrawProtocol.DrawGrid(retList, defGrid, null, repResList, "ReportRes", this);
int index = 0;
for (Object one : repResList) {
HashMap repRes = (HashMap) one;
//有药敏结果的输出药敏
if (repRes.containsKey("AntSen")) {
List<Object> antSenList = (List<Object>) repRes.get("AntSen");
GridDto antGrid = GetAntGridDef();
index++;
if (index == 1) {
//第一个菌接着结果后面打印
antGrid.PageList.get(0).Top = lastY;
} else {
//第二个菌从结果位置打印
antGrid.PageList.get(0).Top = ele.PrintY.intValue();
}
if (antGrid != null&&antSenList.size()>0) {
lastY = PrintDrawProtocol.DrawGrid(retList, antGrid, null, antSenList, "AntSen", this);
}
//打印专家规则
String expertRule=(String)repRes.get("专家规则");
if(Helper.IsNotEmptyStr(expertRule)) {
List<Object> expertList=new ArrayList<>();
HashMap expertHs=new HashMap();
expertHs.put("data","专家规则:");
expertList.add(expertHs);
expertHs=new HashMap();
expertHs.put("data",expertRule);
expertList.add(expertHs);
GridDto def=GetOneColGrid(antGrid.PageList.get(0).Left,lastY-antGrid.RowHeight, GridDraw.GetGridWidth(antGrid));
lastY = PrintDrawProtocol.DrawGrid(retList, def, null, expertList, "ExpertRule", this);
}
//打印备注
String remark=(String)repRes.get("备注");
if(Helper.IsNotEmptyStr(remark)) {
List<Object> remarkList=new ArrayList<>();
HashMap eremarkHs=new HashMap();
eremarkHs.put("data","备注:");
remarkList.add(eremarkHs);
eremarkHs=new HashMap();
eremarkHs.put("data",remark);
remarkList.add(eremarkHs);
GridDto def=GetOneColGrid(antGrid.PageList.get(0).Left,lastY-antGrid.RowHeight, GridDraw.GetGridWidth(antGrid));
lastY = PrintDrawProtocol.DrawGrid(retList, def, null, remarkList, "Remark", this);
}
//打印耐药机制
String rstRes=(String)repRes.get("耐药机制");
if(Helper.IsNotEmptyStr(rstRes)) {
List<Object> rstResList=new ArrayList<>();
HashMap rstResHs=new HashMap();
rstResHs.put("data","耐药机制:");
rstResList.add(rstResHs);
rstResHs=new HashMap();
rstResHs.put("data",rstRes);
rstResList.add(rstResHs);
GridDto def=GetOneColGrid(antGrid.PageList.get(0).Left,lastY-antGrid.RowHeight, GridDraw.GetGridWidth(antGrid));
lastY = PrintDrawProtocol.DrawGrid(retList, def, null, rstResList, "RstRes", this);
}
//不同的菌输出一个换页
retList.add(PrintDrawProtocol.ChangePage());
}
}
}
}
}
/**
* 得到只有一列的无边框表格来画长的换行串
* @param left 左边
* @param top 顶部
* @param width 宽度
* @return
*/
private GridDto GetOneColGrid(int left,int top,int width)
{
//这部分由设计器维护的Json得到表格维护信息
GridDto def = new GridDto();
//边框宽度
def.BoderWidth=0;
//列数
def.Cols=1;
//是否左填充
def.ColsLeftFull=0;
//第一页控制参数
GridPageDto page = new GridPageDto();
//换页行数
page.ChangePageRowNum=999;
page.Left=left;
//顶部
page.Top=top;
def.PageList.add(page);
//定义表格的列
GridColDto col = new GridColDto();
col = new GridColDto();
col.DataField = "data";
col.Width = width;
def.DataCol.add(col);
return def;
}
/**
* 输出固定图片
*
* @param template
* @param template 模板
* @param retList 元素列表
*/
private void PrintFixImage(JRTPrintTemplateDto template, List<PrintElement> retList) {
for (JRTPrintTemplateEle ele : template.EleList) {
try {
//输出图片
if (ele.PrintType.equals("Graph")) {
boolean isSign = false;
if (ele.PrintFlag.equals("D")) {
isSign = true;
}
String dataField = ele.DataField;
//不是图标的,且不包含https的不打印
if (isSign == false && !dataField.contains("http")) {
continue;
}
//取图标书记
if (isSign) {
HashParam hs = new HashParam();
hs.Add("Code", dataField);
hs.Add("ImgType", "DEF");
JRTPrintImage printImage = EntityManager().GetByPara(JRTPrintImage.class, hs);
if (printImage != null) {
dataField = printImage.ImgBase64String;
}
}
PrintElement printEle = PrintDrawProtocol.DrawGraph(ele.PrintX, ele.PrintY, ele.PrintWidth, ele.PrintHeight, dataField, isSign, false);
retList.add(printEle);
}
}
catch (Exception ex)
{
Helper.WriteExceptionLog("打印图片异常",ex);
}
}
}
/**
* 输出报告图片
*
* @param template
* @param template 模板
* @param retList 元素列表
* @param printDataMap 数据图
*/
private void PrintReportImage(JRTPrintTemplateDto template, List<PrintElement> retList, HashMap<String, String> printDataMap) {
for (JRTPrintTemplateEle ele : template.EleList) {
//输出图片
if (ele.PrintType.equals("Graph")) {
boolean isSign = false;
if (ele.PrintFlag.equals("D")) {
isSign = true;
}
String dataField = ele.DataField;
if (!ele.DataField.isEmpty() && printDataMap.containsKey(ele.DataField)) {
dataField = printDataMap.get(ele.DataField);
} else {
continue;
}
PrintElement printEle = PrintDrawProtocol.DrawGraph(ele.PrintX, ele.PrintY, ele.PrintWidth, ele.PrintHeight, dataField, isSign, false);
retList.add(printEle);
}
}
}
/**
* 输出数据
*
* @param template 模板
* @param retList 元素列表
* @param printDataMap 数据哈希
*/
private void PrintData(JRTPrintTemplateDto template, List<PrintElement> retList, Hashtable<String, String> printDataMap) {
for (JRTPrintTemplateEle ele : template.EleList) {
//输出标签
if (ele.PrintType.equals("Data")) {
String dataFiled = ele.DataField;
if (!dataFiled.isEmpty() && printDataMap.containsKey(dataFiled)) {
//带字的条码
if (ele.PrintFlag.contains("BarCode")) {
String BarType = ele.PrintFlag.replace("BarCode", "");
PrintElement printEle = PrintDrawProtocol.DrawBarCode(ele.PrintX, ele.PrintY, printDataMap.get(dataFiled), true, ele.PrintWidth, ele.PrintHeight, BarType, ele.PrintFont, Convert.ToDouble(ele.PrintFontSize).intValue(), ele.PrintFontStyle, PrintDrawProtocol.GetPrintAlignment(ele.PrintAlignment), ele.Color, ele.Angle);
retList.add(printEle);
}
//不带字的条码
else if (ele.PrintFlag.contains("BarCodeN")) {
String BarType = ele.PrintFlag.replace("BarCodeN", "");
PrintElement printEle = PrintDrawProtocol.DrawBarCode(ele.PrintX, ele.PrintY, printDataMap.get(dataFiled), false, ele.PrintWidth, ele.PrintHeight, BarType, ele.PrintFont, Convert.ToDouble(ele.PrintFontSize).intValue(), ele.PrintFontStyle, PrintDrawProtocol.GetPrintAlignment(ele.PrintAlignment), ele.Color, ele.Angle);
retList.add(printEle);
}
//画普通数据
else {
PrintElement printEle = PrintDrawProtocol.DrawLabel(ele.PrintX, ele.PrintY, printDataMap.get(dataFiled), ele.PrintFont, Convert.ToDouble(ele.PrintFontSize).intValue(), ele.PrintFontStyle, PrintDrawProtocol.GetPrintAlignment(ele.PrintAlignment), ele.Color, "", ele.Angle);
retList.add(printEle);
}
}
}
}
}
/**
* 输出标签
*
* @param template
* @param retList
*/
private void PrintLabel(JRTPrintTemplateDto template, List<PrintElement> retList) {
for (JRTPrintTemplateEle ele : template.EleList) {
//输出标签
if (ele.PrintType.equals("Label")) {
PrintElement printEle = PrintDrawProtocol.DrawLabel(ele.PrintX, ele.PrintY, ele.PrintText, ele.PrintFont, Convert.ToDouble(ele.PrintFontSize).intValue(), ele.PrintFontStyle, PrintDrawProtocol.GetPrintAlignment(ele.PrintAlignment), ele.Color, "", ele.Angle);
retList.add(printEle);
}
}
}
/**
* 输出线
*
* @param template
* @param retList
*/
private void PrintLine(JRTPrintTemplateDto template, List<PrintElement> retList) {
for (JRTPrintTemplateEle ele : template.EleList) {
//输出先
if (ele.PrintType.equals("ILineN")) {
long width = ele.PrintWidth;
long height = ele.PrintHeight;
long endX = ele.PrintX + width;
long endY = ele.PrintY;
long lineWidth = height;
if (height > width) {
endX = ele.PrintX;
endY = ele.PrintY;
lineWidth = width;
}
PrintElement printEle = PrintDrawProtocol.DrawLine(ele.PrintX, ele.PrintY, endX, endY, lineWidth, ele.PrintFlag, ele.Color);
retList.add(printEle);
}
}
}
/**
* 通过模板主键或者代码得到模板数据供打印使用
*
* @param rowID
* @param code
* @return
*/
private JRTPrintTemplateDto GetOneTemplate(Integer rowID, String code) throws Exception {
JRTPrintTemplateDto retDto = null;
//按主键取
if (rowID != null) {
retDto = EntityManager().GetById(JRTPrintTemplateDto.class, rowID);
}
//按代码取
else if (code != null && !code.isEmpty()) {
retDto = EntityManager().GetByColVal(JRTPrintTemplateDto.class, "Code", code);
}
if (retDto != null) {
HashParam hs = new HashParam();
hs.Add("PrintTemplateDR", retDto.RowID);
retDto.EleList = EntityManager().FindAllSimple(JRTPrintTemplateEle.class, hs);
}
return retDto;
}
/**
* 得到抗生素表格定义
*
* @return
* @throws Exception
*/
private GridDto GetAntGridDef() throws Exception {
for (JRTPrintTemplateEle ele : template.EleList) {
//输出表格
if (ele.PrintType.equals("DataGrid")) {
if (!ele.DataField.equals("AntSen")) {
continue;
}
//得到表格定义
GridDto defGrid = (GridDto) Helper.Json2Object(ele.PrintText, GridDto.class);
return defGrid;
}
}
return null;
}
/**
* 翻译结果标识
*
* @param abFlag
* @return
*/
private String TransAbFlag(String abFlag) {
if (abFlag == null) {
return "";
}
if (abFlag.equals("L")) {
abFlag = "↓";
} else if (abFlag.equals("H")) {
abFlag = "↑";
} else if (abFlag.equals("PL")) {
abFlag = "↓↓↓";
} else if (abFlag.equals("PH")) {
abFlag = "↑↑↑";
} else if (abFlag.equals("A")) {
abFlag = "*";
} else if (abFlag.equals("S")) {
abFlag = "***";
}
return abFlag;
}
/**
* 存获得的一个模板数据
*/
public static class JRTPrintTemplateDto extends JRTPrintTemplate {
/**
* 模板元素
*/
public List<JRTPrintTemplateEle> EleList;
}
}