最近客户端打磨完了,又来推进质控了。之前演示的打印都是Demo示例,这次真正的写质控图的打印,数据就是质控数据录入界面录入的数据。其中质控图打印应该算最复杂的类型了。涉及JS的绘图,打印表格等,表格比较简单、还没做,难点是把JS的绘图和模板融合。
效果,这里打印和Web一体的优势就出来了,可以实现在线预览:
模板维护
质控图
打印虚拟M
import JRT.Core.DataGrid.GridDto;
import JRT.Core.DataGrid.IGridChangePage;
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.BaseHttpHandler;
import JRTBLLBase.Helper;import java.util.ArrayList;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;/*** 质控公共打印的虚拟M,实现LJ图、Z分数图、定性质控图、WestGard图打印控制*/
public class QCPrintCommon extends BaseHttpHandler 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) {//画数据元素PrintData(template, retList, printDataMap);//画标签元素PrintLabel(template, retList);//画线元素PrintLine(template, retList);}/*** 执行质控打印绘制逻辑** @param Param* @param Session* @param Output* @return*/public String QueryPrintData(Parameters Param, OutValue Session, OutValue Output) throws Exception {//从参数对象取参数String QCPara = Param.P0;String UserCode = Param.P1;String TemplateCode = Param.P2;//分割提取数据ID和图片路径String[] TemplateCodeArr = TemplateCode.split("\\^");//数据主键String DataRowIDS = TemplateCodeArr[2];//图片路径String ImagePath = TemplateCodeArr[1];TemplateCode = TemplateCodeArr[0];//分割提取参数String[] ParaArr = QCPara.split("\\^");int StartDate = Helper.ValidParam(ParaArr[0], 0);int EndDate = Helper.ValidParam(ParaArr[1], 0);int MachineParameterDR = Convert.ToInt32(ParaArr[2]);String MaterialDR = ParaArr[3];String FMatLotDR = ParaArr[4];int TestCodeDR = Convert.ToInt32(ParaArr[5]);String Level = ParaArr[6];String QcRule = ParaArr[7];String PointRange = ParaArr[8];String FMapTitlePrintInfo = ParaArr[9];String FPrintExtraData = ParaArr[10];String IsShowDetail = ParaArr[11];//查询模板数据template = GetOneTemplate(null, TemplateCode);//得到质控打印Data数据GetQCDataData(StartDate, EndDate, MachineParameterDR, TestCodeDR, Level, QcRule, PointRange, MaterialDR, TemplateCode);//得到质控结果,给打印表格用List<QCTestResultDto> qcResList = GetQCResult(StartDate, EndDate, MachineParameterDR, TestCodeDR, Level, QcRule, PointRange, MaterialDR);//画图片元素PrintImage(template, retList, ImagePath);//画数据元素PrintData(template, retList, printDataMap);//画标签元素PrintLabel(template, retList);//画线元素PrintLine(template, retList);ZW("图", retList);//画表格元素//PrintDataGrid(template, retList, repResList);return Helper.Object2Json(retList);}/*** 输出报告结果** @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")) {//得到表格定义GridDto defGrid = (GridDto) Helper.Json2Object(ele.PrintText, GridDto.class);int lastY = PrintDrawProtocol.DrawGrid(retList, defGrid, null, repResList, "ReportRes", this);}}}/*** 输出图片** @param template* @param template 模板* @param retList 元素列表* @param ImagePath 图片路径*/private void PrintImage(JRTPrintTemplateDto template, List<PrintElement> retList, String ImagePath) throws Exception {for (JRTPrintTemplateEle ele : template.EleList) {//输出图片if (ele.PrintType.equals("Graph")) {//不是图片元素退出if (!ele.DataField.equals("P")) {continue;}int addHeigth = 0;String[] arr = ImagePath.split(";");for (String one : arr) {PrintElement printEle = PrintDrawProtocol.DrawGraph(ele.PrintX, ele.PrintY + addHeigth, ele.PrintWidth, ele.PrintHeight, "CMD", false, false);printEle.PrintFlag = one;retList.add(printEle);addHeigth += ele.PrintHeight + 5;}}}}/*** 输出数据** @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")) {int width = ele.PrintWidth;int height = ele.PrintHeight;int endX = ele.PrintX + width;int endY = ele.PrintY;int 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);}}}public void GetQCDataData(int StartDate, int EndDate, int MachineParameterDR, int TestCodeDR, String Level, String QcRule, String PointRange, String MaterialDR, String TemplateCode) throws Exception {//仪器数据BTMIMachineParameter miDto = EntityManager().DolerGet(BTMIMachineParameter.class, MachineParameterDR);BTWorkGroupMachine wgmDto = EntityManager().DolerGet(BTWorkGroupMachine.class, miDto.WorkGroupMachineDR);BTWorkGroup wgDto = EntityManager().DolerGet(BTWorkGroup.class, wgmDto.WorkGroupDR);BTHospital hosDto = EntityManager().DolerGet(BTHospital.class, miDto.HospitalDR);String title = hosDto.CName;String titleWG = wgDto.CName;if (TemplateCode.equals("QCPrintZ")) {title = title + "Z分数图";titleWG = titleWG + "Z分数图";} else if (TemplateCode.equals("QCPrintQualitative")) {title = title + "定性质控图";titleWG = titleWG + "定性质控图";} else if (TemplateCode.equals("QCPrintLJ")) {title = title + "L-J图";titleWG = titleWG + "L-J图";} else if (TemplateCode.equals("QCPrintWestGard")) {title = title + "Levey-Jenning图";titleWG = titleWG + "Levey-Jenning图";}//存打印的Data数据printDataMap = new Hashtable<>();printDataMap.put("标题", title);printDataMap.put("查询日期", Helper.DateIntToStr(StartDate) + " " + Helper.DateIntToStr(EndDate));printDataMap.put("仪器代码", miDto.Code);printDataMap.put("仪器", miDto.CName);BTQCMaterial matDto = EntityManager().DolerGet(BTQCMaterial.class, Convert.ToInt32(MaterialDR));BTTestCode tsDto = EntityManager().DolerGet(BTTestCode.class, TestCodeDR);printDataMap.put("质控物代码", matDto.Code);printDataMap.put("质控物", matDto.CName);printDataMap.put("波长", matDto.WaveLength);printDataMap.put("项目名称", tsDto.CName);printDataMap.put("浓度单位", "");printDataMap.put("实验方法", "");printDataMap.put("浓度", "");printDataMap.put("使用规则", "");printDataMap.put("批号", "");printDataMap.put("校正液批号", "");printDataMap.put("校正液效期", "");printDataMap.put("校正液", "");printDataMap.put("试剂厂商", "");printDataMap.put("失控处理", "");printDataMap.put("质控评价", "");printDataMap.put("主波长", "");printDataMap.put("次波长", "");printDataMap.put("试剂批号", "");printDataMap.put("质控批号", "");printDataMap.put("批次浓度", "");printDataMap.put("打印时间", "");printDataMap.put("目标CV", "");printDataMap.put("失效日期", "");printDataMap.put("打印人", "");printDataMap.put("试剂有效期", "");printDataMap.put("工作组", wgDto.CName);printDataMap.put("工作小组", wgmDto.CName);printDataMap.put("开始日期", Helper.DateIntToStr(StartDate));printDataMap.put("结束日期", Helper.DateIntToStr(EndDate));printDataMap.put("生产日期", "");printDataMap.put("仪器简称", miDto.LName);printDataMap.put("工作组标题", titleWG);printDataMap.put("质控审阅人", "");printDataMap.put("签字", "");printDataMap.put("质控物厂家", "");printDataMap.put("质控审阅人签名", "");printDataMap.put("签字签名", "");printDataMap.put("确认日期", "");printDataMap.put("审核日期", "");}public List<QCTestResultDto> GetQCResult(int StartDate, int EndDate, int MachineParameterDR, int TestCodeDR, String Level, String QcRule, String PointRange, String MaterialDR) throws Exception {HashParam hs = new HashParam();hs.Add("MachineParameterDR", MachineParameterDR);hs.Add("TestCodeDR", TestCodeDR);List<String> operater = new ArrayList<>();operater.add("=");operater.add("=");hs.Add("TestDate", StartDate);hs.Add("TestDate", EndDate);operater.add(">=");operater.add("<=");//质控物浓度映射HashMap<Integer, BTQCMaterialLevel> matLevMap = new HashMap<>();//筛选质控物if (!MaterialDR.isEmpty()) {hs.Add("MaterialDR", Convert.ToInt32(MaterialDR));//质控浓度List<BTQCMaterialLevel> levList = EntityManager().FindByColVal(BTQCMaterialLevel.class, "MaterialDR", Convert.ToInt32(MaterialDR));if (levList != null && levList.size() > 0) {for (BTQCMaterialLevel lev : levList) {matLevMap.put(lev.LevelNo, lev);}}}//浓度筛选图HashMap levMap = Helper.GetSplitMap(Level, ",");//查询仪器、项目、日期范围的所有质控数据List<QCTestResultDto> allData = EntityManager().FindAllSimple(QCTestResultDto.class, hs, "LevelNo asc,TestDate asc,TestTime asc", -1, null, operater);//存处理后的数据List<QCTestResultDto> dealedData = new ArrayList<>();if (allData != null && allData.size() > 0) {for (QCTestResultDto one : allData) {//筛选浓度if (levMap.size() > 0 && !levMap.containsKey(String.valueOf(one.LevelNo))) {continue;}dealedData.add(one);}}return dealedData;}/*** 通过模板主键或者代码得到模板数据供打印使用** @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()) {System.out.println(code);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;}/*** 存获得的一个模板数据*/public static class JRTPrintTemplateDto extends JRTPrintTemplate {/*** 模板元素*/public List<JRTPrintTemplateEle> EleList;}/*** 返回到前台的数据实体*/public static class QCTestResultDto extends QCTestResult {/*** 当前浓度*/public int CurLevelNo;/*** 点类型*/public String CurPointType;/*** 数量*/public int Num;/*** 日期*/public String CurdateNum;/*** 测试时间*/public String TestRTime;/*** 用户名*/public String UserName;/*** 画图结果*/public String PicResult;/*** 结果*/public String PicX;/*** 规则代码*/public String CurRuleCode;/*** 规则颜色*/public String CurRuleColour;/*** 规则状态*/public String CurRuleStatus;/*** 规则名称*/public String CurRuleName;/*** 靶值*/public String TCX;/*** SD*/public String TCSD;/*** 项目名称*/public String TCName;/*** 项目代码*/public String CurTestCode;/*** 浓度名称*/public String CurLevelName;/*** CV*/public String TCCV;/*** 计算均值*/public String CalX;/*** 计算SD*/public String CalSD;/*** 计算CV*/public String CalCV;/*** 计算类型*/public String CalcType;/*** 计算均值*/public String AccMean;/*** 计算均值*/public String AccSD;/*** 计算均值*/public String AccCV;/*** 计算均值*/public String SetCV;/*** 计算均值*/public String TargetCV;/*** 计算均值*/public String LotNo;/*** 计算均值*/public String Event;/*** 计算均值*/public String ReagentLot;/*** 计算均值*/public String ResRemark;/*** 计算均值*/public String AutUserName;/*** 计算均值*/public String OriginalRes;/*** 失控处理说明*/public String TransactionRemark;/*** 失控类型*/public String TransactionType;/*** 处理方法*/public String TransactionMethod;/*** 失控处理结果*/public String TransactionRes;/*** 失控处理人*/public String TransactionUser;/*** 全部批号*/public String LotNoAll;/*** 结果和靶值的偏差*/public Double Offset;}
}
借助虚拟M实现的质控图公共查询逻辑
import JRT.Core.Dto.HashParam;
import JRT.Core.Dto.OutValue;
import JRT.Core.Util.Convert;
import JRT.Model.Bussiness.Parameters;
import JRT.Model.Entity.*;
import JRTBLLBase.BaseHttpHandler;
import JRTBLLBase.Helper;import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;/*** 画质控图公共查询逻辑,所有的质控图都通过虚拟M调过来,钙类实现规则判断等*/
public class QCDrawCommon extends BaseHttpHandler {/*** 质控绘图公共查数据* @param Param* @param Session* @param Output* @return* @throws Exception*/public String QueryQcDrawData(Parameters Param, OutValue Session, OutValue Output) throws Exception {int StartDate= Helper.ValidParam(Param.P0,0);int EndDate=Helper.ValidParam(Param.P1,0);int MachineParameterDR= Convert.ToInt32(Param.P2);int TestCodeDR=Convert.ToInt32(Param.P3);String Level=Param.P4;String QcRule=Param.P5;String PointRange=Param.P6;String MaterialDR=Param.P7;String UseFL=Param.P8;String LotNo=Param.P9;HashParam hs=new HashParam();hs.Add("MachineParameterDR",MachineParameterDR);hs.Add("TestCodeDR",TestCodeDR);List<String> operater=new ArrayList<>();operater.add("=");operater.add("=");hs.Add("TestDate",StartDate);hs.Add("TestDate",EndDate);operater.add(">=");operater.add("<=");//质控物浓度映射HashMap<Integer,BTQCMaterialLevel> matLevMap=new HashMap<>();//筛选质控物if(!MaterialDR.isEmpty()){hs.Add("MaterialDR",Convert.ToInt32(MaterialDR));//质控浓度List<BTQCMaterialLevel> levList=EntityManager().FindByColVal(BTQCMaterialLevel.class,"MaterialDR",Convert.ToInt32(MaterialDR));if(levList!=null&&levList.size()>0){for(BTQCMaterialLevel lev:levList){matLevMap.put(lev.LevelNo,lev);}}}//浓度筛选图HashMap levMap=Helper.GetSplitMap(Level,",");//查询仪器、项目、日期范围的所有质控数据List<QCTestResultDto> allData=EntityManager().FindAllSimple(QCTestResultDto.class,hs,"LevelNo asc,TestDate asc,TestTime asc",-1,null,operater);//存处理后的数据List<QCTestResultDto> dealedData=new ArrayList<>();//1:所有质控点 2:去除排除点 6:所有在控点 11:去除平行点 12:仅平行点 4:去除复查点 10:只查最后一点//7:最好点连线 8:最后一点连线 9:只查最好点//辅助判断复查点HashMap redoMap=new HashMap();//最好点的图HashMap<String,QCTestResultDto> bestMap=new HashMap();HashMap<Integer, Boolean> bestRowIDMap=new HashMap();//最后点的图HashMap<String,QCTestResultDto> lastMap=new HashMap();HashMap<Integer, Boolean> lastRowIDMap=new HashMap();if(allData!=null&&allData.size()>0){for(QCTestResultDto one:allData){//筛选浓度if(levMap.size()>0&&!levMap.containsKey(String.valueOf(one.LevelNo))){continue;}//去除排除点if(PointRange.equals("2")&&one.ExcludeType.equals("2")){continue;}//所有在控点if(PointRange.equals("6")&&one.CurRuleStatus.equals("R")){continue;}//仅平行点if(PointRange.equals("11")&&!one.IsParallel.equals("!")){continue;}//去除平行点if(PointRange.equals("12")&&one.IsParallel.equals("!")){continue;}//去除复查点if(PointRange.equals("4")&&redoMap.containsKey(one.LevelNo+"-"+one.TestDate)){continue;}//只查最后一点if(PointRange.equals("10")&&redoMap.containsKey(one.LevelNo+"-"+one.TestDate)){continue;}//当天第一个数据redoMap.put(one.LevelNo+"-"+one.TestDate,true);one.CurLevelNo=one.LevelNo;one.CurPointType="";one.Num=1;one.CurdateNum=Helper.DateIntToStr(one.TestDate);one.TestRTime=Helper.TimeIntToStr(one.TestTime);one.UserName="";if(one.AddUserDR!=null){SYSUser user=EntityManager().DolerGet(SYSUser.class,one.AddUserDR);one.UserName=user.CName;}one.PicResult=one.Result;one.PicX=one.PicResult;one.CurRuleCode="";one.CurRuleColour="";one.CurRuleStatus="";one.CurRuleName="";if(one.QCRulesDR!=null){BTQCRules rule=EntityManager().DolerGet(BTQCRules.class,one.QCRulesDR);one.CurRuleCode=rule.Code;one.CurRuleColour=rule.Color;one.CurRuleStatus=rule.Status;one.CurRuleName=rule.CName;}//参数QCResMaterialTestCode para=EntityManager().DolerGet(QCResMaterialTestCode.class,one.ResMaterialTestCodeDR);//结果和均值的差one.Offset=Math.abs(Convert.ToInt32(one.Result)-para.Mean);//找到最好结果if(!bestMap.containsKey(one.LevelNo+"-"+one.TestDate)){bestMap.put(one.LevelNo+"-"+one.TestDate,one);}else{QCTestResultDto pre=bestMap.get(one.LevelNo+"-"+one.TestDate);if(pre.Offset>one.Offset){bestMap.put(one.LevelNo+"-"+one.TestDate,one);}}//最后点lastMap.put(one.LevelNo+"-"+one.TestDate,one);one.TCX=String.valueOf(para.Mean);one.TCSD=String.valueOf(para.SD);BTTestCode testCode=EntityManager().DolerGet(BTTestCode.class,one.TestCodeDR);one.TCName=testCode.CName;one.CurTestCode=testCode.Code;one.CurLevelName=matLevMap.get(one.LevelNo).CName;one.TCCV=String.valueOf(para.SetCV);one.CalX="";one.CalSD="";one.CalCV="";one.CalcType="";one.AccMean="";one.AccSD="";one.AccCV="";one.SetCV=String.valueOf(para.SetCV);one.TargetCV=para.TargetCV;one.LotNo=para.LotNo;one.Event="";one.ReagentLot=para.RgLot;one.ResRemark=one.Remark;one.AutUserName="";one.OriginalRes=one.TextRes;one.TransactionRemark="";one.TransactionMethod="";one.TransactionRes="";one.TransactionType="";one.TransactionUser="";one.LotNoAll="";dealedData.add(one);}//转换成主键mapfor (Map.Entry<String,QCTestResultDto> entry : bestMap.entrySet()) {bestRowIDMap.put(entry.getValue().RowID,true);}//转换成主键mapfor (Map.Entry<String,QCTestResultDto> entry : lastMap.entrySet()) {lastRowIDMap.put(entry.getValue().RowID,true);}//第二次处理数据for(int i=0;i<dealedData.size();i++){//只查最好点if(PointRange.equals("9")){if(!bestRowIDMap.containsKey(dealedData.get(i).RowID)){dealedData.remove(i);i--;continue;}}//只查最后点if(PointRange.equals("10")){if(!lastRowIDMap.containsKey(dealedData.get(i).RowID)){dealedData.remove(i);i--;continue;}}//最好点连线if(PointRange.equals("7")){if(!bestRowIDMap.containsKey(dealedData.get(i).RowID)){dealedData.get(i).CurPointType="0";}}//最后点连线else{if(!lastRowIDMap.containsKey(dealedData.get(i).RowID)){dealedData.get(i).CurPointType="0";}}}}return Helper.Object2Json(dealedData);}/*** 返回到前台的数据实体*/public static class QCTestResultDto extends QCTestResult{/*** 当前浓度*/public int CurLevelNo;/*** 点类型*/public String CurPointType;/*** 数量*/public int Num;/*** 日期*/public String CurdateNum;/*** 测试时间*/public String TestRTime;/*** 用户名*/public String UserName;/*** 画图结果*/public String PicResult;/*** 结果*/public String PicX;/*** 规则代码*/public String CurRuleCode;/*** 规则颜色*/public String CurRuleColour;/*** 规则状态*/public String CurRuleStatus;/*** 规则名称*/public String CurRuleName;/*** 靶值*/public String TCX;/*** SD*/public String TCSD;/*** 项目名称*/public String TCName;/*** 项目代码*/public String CurTestCode;/*** 浓度名称*/public String CurLevelName;/*** CV*/public String TCCV;/*** 计算均值*/public String CalX;/*** 计算SD*/public String CalSD;/*** 计算CV*/public String CalCV;/*** 计算类型*/public String CalcType;/*** 计算均值*/public String AccMean;/*** 计算均值*/public String AccSD;/*** 计算均值*/public String AccCV;/*** 计算均值*/public String SetCV;/*** 计算均值*/public String TargetCV;/*** 计算均值*/public String LotNo;/*** 计算均值*/public String Event;/*** 计算均值*/public String ReagentLot;/*** 计算均值*/public String ResRemark;/*** 计算均值*/public String AutUserName;/*** 计算均值*/public String OriginalRes;/*** 失控处理说明*/public String TransactionRemark;/*** 失控类型*/public String TransactionType;/*** 处理方法*/public String TransactionMethod;/*** 失控处理结果*/public String TransactionRes;/*** 失控处理人*/public String TransactionUser;/*** 全部批号*/public String LotNoAll;/*** 结果和靶值的偏差*/public Double Offset;}
}
WestGard图对接
import JRT.Core.Dto.HashParam;
import JRT.Core.Dto.OutValue;
import JRT.Core.MultiPlatform.JRTContext;
import JRT.Core.Util.Convert;
import JRT.Model.Bussiness.Parameters;
import JRT.Model.Entity.*;
import JRTBLLBase.BaseHttpHandler;
import JRTBLLBase.Helper;import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;/*** 绘制质控WestGard图的后台*/
public class ashQCDrawWestGard extends BaseHttpHandler {/*** 查询质控浓度数据** @return*/public String QueryQCLeaveData() throws Exception {int MaterialDR = Helper.ValidParam(JRTContext.GetRequest(Request, "MaterialDR"), 0);List<BTQCMaterialLevel> retList = EntityManager().FindByColVal(BTQCMaterialLevel.class, "MaterialDR", MaterialDR);return Helper.Object2Json(retList);}/*** 查询质控数据* @return*/public String QueryWestGardData() throws Exception{//参数Parameters param = new Parameters();//开始日期param.P0 = JRTContext.GetRequest(Request, "StartDate");//结束日期param.P1 = JRTContext.GetRequest(Request, "EndDate");//仪器代码param.P2 = JRTContext.GetRequest(Request, "InstrumentCode");//项目代码param.P3 = JRTContext.GetRequest(Request, "TcCode");//浓度串String leavelStr = Helper.ValidParam(JRTContext.GetRequest(Request, "Leavel"), "");//浓度param.P4 = JRTContext.GetRequest(Request, "Leavel");//质控规则param.P5 = JRTContext.GetRequest(Request, "QcRule");//点类型param.P6 = JRTContext.GetRequest(Request, "PointRange");//质控物param.P7 = JRTContext.GetRequest(Request, "MaterialCode");param.P8 = Helper.ValidParam(JRTContext.GetRequest(Request, "UseFL"), "");param.P9 = Helper.ValidParam(JRTContext.GetRequest(Request, "LotNo"), "");OutValue Session=new OutValue();Session.Value=UserLogin().SessionStr;OutValue Output=new OutValue();String json=Helper.GetVMData("qc.ashx.QCDrawCommon","QueryQcDrawData",param,Session,Output);String ShowStr="[]";String statJson="[]";String result = "{ \"DrawData\":" + json + ",\"StartDate\":\"" + param.P0+ "\",\"MaxDate\":\"" + param.P1 + "\",\"ShowStr\":" + ShowStr + ",\"State\":" + statJson + "}";//返回查询结果return result;}/*** 查询工作组数据* @return* @throws Exception*/public String QueryWorkGroupData() throws Exception{//得到用户的角色List<SYSUserRoleDto> roleList = EntityManager().FindByColVal(SYSUserRoleDto.class, "UserDR", Convert.ToInt32(UserLogin().UserID));if (roleList != null && roleList.size() > 0) {for (SYSUserRoleDto one : roleList) {BTWorkGroup wgDto = EntityManager().DolerGet(BTWorkGroup.class, one.WorkGroupDR);one.WorkGroupName = wgDto.CName;one.CurWorkGroupDR = UserLogin().GroupID;}}return Helper.Object2Json(roleList);}/*** 查询仪器** @return*/public String QryMachineParameter() throws Exception {int WorkGroupDR = Helper.ValidParam(JRTContext.GetRequest(Request, "WorkGroupDR"), 0);List<BTWorkGroupMachine> wgmList = EntityManager().FindByColVal(BTWorkGroupMachine.class, "WorkGroupDR", WorkGroupDR);List<BTMIMachineParameter> retList = new ArrayList<>();if (wgmList != null && wgmList.size() > 0) {for (BTWorkGroupMachine wgm : wgmList) {//查询工作小组下的所有仪器List<BTMIMachineParameter> machList = EntityManager().FindByColVal(BTMIMachineParameter.class, "WorkGroupMachineDR", wgm.RowID);retList.addAll(machList);}}return Helper.Object2Json(retList);}/*** 查询仪器项目** @return*/public String QryMachineTestCode() throws Exception {int MachineParameterDR = Helper.ValidParam(JRTContext.GetRequest(Request, "MachineParameterDR"), 0);int StartDate = Helper.ValidParam(JRTContext.GetRequest(Request, "StartDate"), 0);int EndDate = Helper.ValidParam(JRTContext.GetRequest(Request, "EndDate"), 0);HashParam hs = new HashParam();hs.Add("StartDate", StartDate);List<String> operators = new ArrayList<>();operators.add("<=");//先找小于开始日期的最近数据List<BTQCMaterialTestCode> lastData = EntityManager().FindAllSimple(BTQCMaterialTestCode.class, hs, "StartDate desc", 1, null, operators);//然后安装最近开始日期和结束日期找模板数据HashParam hsFind = new HashParam();//结束日期hsFind.Add("StartDate", EndDate);List<String> operatorsFind = new ArrayList<>();operatorsFind.add("<=");List<String> joinerFind = new ArrayList<>();if (lastData != null && lastData.size() > 0) {joinerFind.add("and");operatorsFind.add(">=");//开始日期hsFind.Add("StartDate", lastData.get(0).StartDate);}//目标数据List<BTQCMaterialTestCodeDto> perData = EntityManager().FindAllSimple(BTQCMaterialTestCodeDto.class, hsFind, "StartDate asc", -1, joinerFind, operatorsFind);//返回的数据List<BTQCMaterialTestCodeDto> retData = new ArrayList<>();HashMap map = new HashMap();if (perData != null && perData.size() > 0) {for (BTQCMaterialTestCodeDto one : perData) {BTQCMaterial matDto = EntityManager().DolerGet(BTQCMaterial.class, one.MaterialDR);one.MaterialName = matDto.CName;BTTestCode tsDto = EntityManager().DolerGet(BTTestCode.class, one.TestCodeDR);one.CName = tsDto.CName;one.Code = tsDto.Code;one.Synonym = tsDto.Synonym;if (!map.containsKey(one.MaterialDR + "-" + one.TestCodeDR)) {retData.add(one);map.put(one.MaterialDR + "-" + one.TestCodeDR, true);}one.QcFlag="0";one.HasDoc="";one.LotNoJson="[]";}}return Helper.Object2Json(retData);}/*** 查询批次项目实体*/public static class BTQCMaterialTestCodeDto extends BTQCMaterialTestCode {/*** 质控物名称*/public String MaterialName;/*** 项目名称*/public String CName;/*** 项目缩写*/public String Synonym;/*** 项目代码*/public String Code;/*** 质控标识*/public String QcFlag;/*** 是否归档*/public String HasDoc;/*** 批号*/public String LotNoJson;}/*** 角色查询实体*/public static class SYSUserRoleDto extends SYSUserRole {//工作组名称public String WorkGroupName;//当前工作组public String CurWorkGroupDR;}
}
前期的基础打好了就可以实现不错的效果,越写越简单了