真正的跨数据库

jrt不同于主流Spring+mybats框架宣传的多数据支持。引入mybats之后多数据库支持基本就是无稽之谈,一堆Mapper写SQL语句,多数据库支持从最开始就变成只能连多种数据库,而不是业务程序可以跑在多种数据库上面不用改动。一个框架如果不能解决常规业务查询需求和级联取数据,那么必然就要暴露SQL执行的api,暴露SQL之后业务程序跨库就无从谈起,只能是镜花水月。

jrt所宣传的多数据库支持是指真实的业务程序不用修改就能轻松换数据库运行,要满足这个就必然要加强数据访问层,满足业务查询述求,才能让业务摆脱写SQL。

jrt提供系列api解决业务查询述求,就以一些质控物维护的业务场景来说:
按某列的值查询列表,来满足用外键查询子数据
在这里插入图片描述

按某列值删除数据来满足业务快速删子数据
在这里插入图片描述

DolerGet来满足多维取数据,主要是一级级取参照的数据,这样就不用写复杂的关联查询
在这里插入图片描述
事务注解来满足申明式事务
在这里插入图片描述

拷贝属性方法满足页面实现数据拷贝功能
在这里插入图片描述
传入排序和分页来满足分页查询需求
在这里插入图片描述
提供按条件CheckHas检测是否有数据,方便业务判断指定数据是否存在,后台使用top 1来提高性能
在这里插入图片描述
支持实体表的子表查询数据,这样就可以得到一个表的数据,然后再DolerGet爬行周边数据,核心就是支持子类查询配合DolerGet用
在这里插入图片描述

在这里插入图片描述

经过一系列操作数据的api提供,jrt写业务可以不用写SQL就可以高效优雅的完成,从而确保jrt多数据库支持的真实可靠性。

质控物维护后台主代码,虽然涉及10几个表的多级关系,但是还是优雅的用jrt的api实现了

import JRT.Core.CustomAttributes.Trans;
import JRT.Core.Dto.OutValue;
import JRT.Core.Util.ReflectUtil;
import JRTBLLBase.BaseHttpHandler;
import JRTBLLBase.Helper;
import JRT.Core.Dto.HashParam;
import JRT.Core.Dto.ParamDto;
import JRT.Core.Dto.OutParam;
import JRT.Model.Entity.*;
import JRT.Core.Util.Convert;
import JRT.Core.MultiPlatform.JRTContext;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
*由代码生成器生成的后台代码
*/
public class ashBTQCMaterial extends BaseHttpHandler {

	/**
	 * 得到仪器树
	 * @return
	 */
	public String GetMachineTree() throws Exception
	{
		List<MachineTreeDto> retList=new ArrayList<>();
		//得到用户可以访问的工作组
		List<SYSUserRole> roleList=EntityManager().FindByColVal(SYSUserRole.class,"UserDR",Convert.ToInt32(UserLogin().UserID));
		if(roleList!=null&&roleList.size()>0)
		{
			HashMap hasOutWG=new HashMap();
			for(SYSUserRole role:roleList)
			{
				//每个工作组只输出一次
				if(hasOutWG.containsKey(role.WorkGroupDR))
				{
					continue;
				}
				hasOutWG.put(role.WorkGroupDR,true);
				//工作组树节点
				MachineTreeDto wgTree=new MachineTreeDto();
				wgTree.RowID=role.WorkGroupDR;
				wgTree.id="WG-"+role.WorkGroupDR;
				BTWorkGroup wgDto=EntityManager().DolerGet(BTWorkGroup.class,role.WorkGroupDR);
				wgTree.text=wgDto.CName;
				wgTree.children=new ArrayList<>();
				wgTree.Type="WG";
				retList.add(wgTree);
				//查询所有工作小组
				List<BTWorkGroupMachine> wgmList=EntityManager().FindByColVal(BTWorkGroupMachine.class,"WorkGroupDR",role.WorkGroupDR);
				if(wgmList!=null&&wgmList.size()>0)
				{
					for(BTWorkGroupMachine wgm:wgmList)
					{
						//工作小组树节点
						MachineTreeDto wgmTree=new MachineTreeDto();
						wgmTree.RowID=wgm.RowID;
						wgmTree.id="WGM-"+wgm.RowID;
						wgmTree.text=wgm.CName;
						wgmTree.children=new ArrayList<>();
						wgmTree.Type="WGM";
						wgTree.children.add(wgmTree);
						//查询工作小组下的所有仪器
						List<BTMIMachineParameter> machList=EntityManager().FindByColVal(BTMIMachineParameter.class,"WorkGroupMachineDR",wgm.RowID);
						if(machList!=null&&machList.size()>0)
						{
							for(BTMIMachineParameter mi:machList)
							{
								//仪器树节点
								MachineTreeDto miTree=new MachineTreeDto();
								miTree.RowID=mi.RowID;
								miTree.id="MI-"+mi.RowID;
								miTree.text=mi.CName;
								miTree.Type="MI";
								wgmTree.children.add(miTree);
							}
						}
					}
				}
			}
		}
		//删除没有仪器的节点
		DealNoMachineTree(retList);
		return Helper.Object2Json(retList);
	}


	/**
	 * 保存数据,前台按表的属性名提交
	 * @return 字符串
	 */
	@Trans
	public String SaveBTQCMaterial() throws Exception
    {
		BTQCMaterial dto=new BTQCMaterial();
		//主键  
		dto.RowID=Helper.ValidParam(JRTContext.GetRequest(Request, "RowID"), dto.RowID);
		//代码  
		dto.Code=Helper.ValidParam(JRTContext.GetRequest(Request, "Code"), dto.Code);
		//名称  
		dto.CName=Helper.ValidParam(JRTContext.GetRequest(Request, "CName"), dto.CName);
		//仪器  
		dto.MachineDR=Helper.ValidParam(JRTContext.GetRequest(Request, "MachineDR"), dto.MachineDR);
		//浓度数  
		dto.Levels=Helper.ValidParam(JRTContext.GetRequest(Request, "Levels"), dto.Levels);
		//波长  
		dto.WaveLength=Helper.ValidParam(JRTContext.GetRequest(Request, "WaveLength"), dto.WaveLength);
		//是否自动入库  {1:true,0:false}
		dto.AutoSave=Helper.ValidParam(JRTContext.GetRequest(Request, "AutoSave"), dto.AutoSave);
		//说明  
		dto.Remark=Helper.ValidParam(JRTContext.GetRequest(Request, "Remark"), dto.Remark);
		//序号  
		dto.Sequence=Helper.ValidParam(JRTContext.GetRequest(Request, "Sequence"), dto.Sequence);
		//激活  {1:true,0:false}
		dto.Active=Helper.ValidParam(JRTContext.GetRequest(Request, "Active"), dto.Active);
		//是否覆盖数据  {1:true,0:false}
		dto.IsOverWriteData=Helper.ValidParam(JRTContext.GetRequest(Request, "IsOverWriteData"), dto.IsOverWriteData);
		//不允许日间质控  {1:true,0:false}
		dto.NotAllowDay=Helper.ValidParam(JRTContext.GetRequest(Request, "NotAllowDay"), dto.NotAllowDay);
		//日间质控没做不显示  {1:true,0:false}
		dto.NotShowNullDay=Helper.ValidParam(JRTContext.GetRequest(Request, "NotShowNullDay"), dto.NotShowNullDay);
		OutValue key=new OutValue();
		int ret=0;
		//更新
		if(dto.RowID>0)
		{
			ret=EntityManager().Update(dto,null, ErrRet(), null, null, null);
		}
		//插入数据
		else
		{
			ret=EntityManager().Save(dto,key,ErrRet());
			if(ret==1) {
				for (int i = 0; i < dto.Levels; i++) {
					BTQCMaterialLevel levDto = new BTQCMaterialLevel();
					levDto.CName = "浓度" + (i + 1);
					levDto.Color = "";
					levDto.LevelNo = i + 1;
					levDto.MaterialDR = dto.RowID;
					EntityManager().Save(levDto,key,ErrRet());
				}
			}
			else
			{
				throw new Exception(Err.GetString());
			}
		}
		if(ret==1)
		{
			return Helper.Success();
		}
		else
		{
			return Helper.Error();
		}
    }



	/**
	 * 删除数据,多个RowID以上尖号分割
	 * @return 字符串
	 */
	@Trans
	public String DeleteBTQCMaterial() throws Exception
    {
		String RowIDS=Helper.ValidParam(JRTContext.GetRequest(Request, "RowIDS"), "");
		if(RowIDS.isEmpty())
		{
			return Helper.Error("请传入要删除数据的RowID,多个以^分割!");
		}
		//分割主键
		String [] arr=RowIDS.split("^");
		//out参数
		OutParam out=new OutParam();
		//循环删除数据
		for(int i=0;i<arr.length;i++)
		{
			int id = Convert.ToInt32(arr[i]);
			//质控结果数量
			int resCount=EntityManager().GetCoutNum(QCTestResult.class,"MaterialDR",id);
			if(resCount>100)
			{
				throw new Exception("质控结果数量大于100了,不允许删除!");
			}
			//删除批次公共信息
			EntityManager().RemoveByColVal(BTQCMaterialLot.class, "MaterialDR", id);
			//删除质控浓度
			EntityManager().RemoveByColVal(BTQCMaterialLevel.class, "MaterialDR", id);
			//删除质控标识
			EntityManager().RemoveByColVal(BTQCMachineQC.class, "MaterialDR", id);
			//删除质控规则
			EntityManager().RemoveByColVal(BTQCMaterialRules.class, "MaterialDR", id);
			//删除质控项目批次
			EntityManager().RemoveByColVal(BTQCMaterialTestCode.class, "MaterialDR", id);
			//删除质控项目规则
			EntityManager().RemoveByColVal(BTQCMaterialTCRules.class, "MaterialDR", id);
			//删除定性质控显示信息
			EntityManager().RemoveByColVal(BTQCQualitativeShow.class, "MaterialDR", id);
			//删除质控项目批次的业务数据
			EntityManager().RemoveByColVal(QCResMaterialTestCode.class, "MaterialDR", id);
			int ret=EntityManager().RemoveById(BTQCMaterial.class,id,out);
			if(ret!=1)
			{
				return Helper.Error(out);
			}
		}
		return Helper.Success();
	}


	/**
	 * 查询选择树的仪器
	 * @return 字符串
	 */
	public String QrySelectMachine() throws Exception {
		List<BTMIMachineParameter> retist = new ArrayList<>();
		//工作组
		String WorkGroupDR = Helper.ValidParam(JRTContext.GetRequest(Request, "WorkGroupDR"), "");
		//工作小组
		String WorkGroupMachineDR = Helper.ValidParam(JRTContext.GetRequest(Request, "WorkGroupMachineDR"), "");
		//仪器
		String MachineDR = Helper.ValidParam(JRTContext.GetRequest(Request, "MachineDR"), "");
		//选择工作组
		if(!WorkGroupDR.isEmpty()) {
			//查工作小组
			List<BTWorkGroupMachine> wgmList=EntityManager().FindByColVal(BTWorkGroupMachine.class,"WorkGroupDR",Integer.valueOf(WorkGroupDR));
			if(wgmList!=null&&wgmList.size()>0)
			{
				for(BTWorkGroupMachine wgm:wgmList)
				{
					//查仪器
					List<BTMIMachineParameter> miList=EntityManager().FindByColVal(BTMIMachineParameter.class,"WorkGroupMachineDR",wgm.RowID);
					retist.addAll(miList);
				}
			}
		}
		//选择工作小组
		else if(!WorkGroupMachineDR.isEmpty()) {
			//查仪器
			List<BTMIMachineParameter> miList=EntityManager().FindByColVal(BTMIMachineParameter.class,"WorkGroupMachineDR",Integer.valueOf(WorkGroupMachineDR));
			retist.addAll(miList);
		}
		//选择仪器
		else if(!MachineDR.isEmpty()) {
			BTMIMachineParameter mi=EntityManager().DolerGet(BTMIMachineParameter.class,Integer.valueOf(MachineDR));
			retist.add(mi);
		}
		return Helper.Object2Json(retist);
	}


	/**
	 * 查询数据,前台按表的属性名提交
	 * @return 字符串
	 */
	public String QryBTQCMaterial() throws Exception
    {
		List<BTQCMaterialDto> retlist=new ArrayList<>();
		//工作组
		String WorkGroupDR=Helper.ValidParam(JRTContext.GetRequest(Request, "WorkGroupDR"), "");
		//工作小组
		String WorkGroupMachineDR=Helper.ValidParam(JRTContext.GetRequest(Request, "WorkGroupMachineDR"), "");
		//仪器
		String MachineDR=Helper.ValidParam(JRTContext.GetRequest(Request, "MachineDR"), "");
		//存仪器
		List<BTMIMachineParameter> machList=new ArrayList<>();
		//选择工作组
		if(!WorkGroupDR.isEmpty()) {
			//查工作小组
			List<BTWorkGroupMachine> wgmList=EntityManager().FindByColVal(BTWorkGroupMachine.class,"WorkGroupDR",Integer.valueOf(WorkGroupDR));
			if(wgmList!=null&&wgmList.size()>0)
			{
				for(BTWorkGroupMachine wgm:wgmList)
				{
					//查仪器
					List<BTMIMachineParameter> miList=EntityManager().FindByColVal(BTMIMachineParameter.class,"WorkGroupMachineDR",wgm.RowID);
					machList.addAll(miList);
				}
			}
		}
		//选择工作小组
		else if(!WorkGroupMachineDR.isEmpty()) {
			//查仪器
			List<BTMIMachineParameter> miList=EntityManager().FindByColVal(BTMIMachineParameter.class,"WorkGroupMachineDR",Integer.valueOf(WorkGroupMachineDR));
			machList.addAll(miList);
		}
		//选择仪器
		else if(!MachineDR.isEmpty()) {
			BTMIMachineParameter mi=EntityManager().DolerGet(BTMIMachineParameter.class,Integer.valueOf(MachineDR));
			machList.add(mi);
		}
		if(machList.size()>0)
		{
			for(BTMIMachineParameter mi:machList)
			{
				List<BTQCMaterialDto> miMats=EntityManager().FindByColVal(BTQCMaterialDto.class,"MachineDR",mi.RowID);
				if(miMats!=null&&miMats.size()>0) {
					for(BTQCMaterialDto one:miMats)
					{

						one.WorkGroupMachineDR=mi.WorkGroupMachineDR;
						BTWorkGroupMachine wgm=EntityManager().DolerGet(BTWorkGroupMachine.class,mi.WorkGroupMachineDR);
						one.WorkGroupMachineName=wgm.CName;
						one.WorkGroupDR=wgm.WorkGroupDR;
						BTWorkGroup wg=EntityManager().DolerGet(BTWorkGroup.class,wgm.WorkGroupDR);
						one.WorkGroupName=wg.CName;
						one.MachineName=mi.CName;
					}
					retlist.addAll(miMats);
				}
			}
		}
		return Helper.Object2Json(retlist);
	}


	/**
	 * 保存数据,前台按表的属性名提交
	 * @return 字符串
	 */
	public String SaveBTQCMaterialTestCode() throws Exception
	{
		BTQCMaterialTestCode dto=new BTQCMaterialTestCode();
		//主键
		dto.RowID=Helper.ValidParam(JRTContext.GetRequest(Request, "RowID"), dto.RowID);
		//质控物
		dto.MaterialDR=Helper.ValidParam(JRTContext.GetRequest(Request, "MaterialDR"), dto.MaterialDR);
		//项目
		dto.TestCodeDR=Helper.ValidParam(JRTContext.GetRequest(Request, "TestCodeDR"), dto.TestCodeDR);
		//浓度
		dto.LevelNo=Helper.ValidParam(JRTContext.GetRequest(Request, "LevelNo"), dto.LevelNo);
		//开始日期
		dto.StartDate=Helper.ValidParam(JRTContext.GetRequest(Request, "StartDate"), dto.StartDate);
		//靶子
		dto.Mean=Helper.ValidParam(JRTContext.GetRequest(Request, "Mean"), dto.Mean);
		//标准差
		dto.SD=Helper.ValidParam(JRTContext.GetRequest(Request, "SD"), dto.SD);
		//设置CV
		dto.SetCV=Helper.ValidParam(JRTContext.GetRequest(Request, "SetCV"), dto.SetCV);
		//目标CV
		dto.TargetCV=Helper.ValidParam(JRTContext.GetRequest(Request, "TargetCV"), dto.TargetCV);
		//质控品批号
		dto.LotNo=Helper.ValidParam(JRTContext.GetRequest(Request, "LotNo"), dto.LotNo);
		//质控物厂家
		dto.MatManufacturer=Helper.ValidParam(JRTContext.GetRequest(Request, "MatManufacturer"), dto.MatManufacturer);
		//厂家均值
		dto.ManufacturerMean=Helper.ValidParam(JRTContext.GetRequest(Request, "ManufacturerMean"), dto.ManufacturerMean);
		//厂家标准差
		dto.ManufacturerSD=Helper.ValidParam(JRTContext.GetRequest(Request, "ManufacturerSD"), dto.ManufacturerSD);
		//试剂批号
		dto.RgLot=Helper.ValidParam(JRTContext.GetRequest(Request, "RgLot"), dto.RgLot);
		//试剂厂家
		dto.RgManufacturer=Helper.ValidParam(JRTContext.GetRequest(Request, "RgManufacturer"), dto.RgManufacturer);
		//测试方法
		dto.TestMethod=Helper.ValidParam(JRTContext.GetRequest(Request, "TestMethod"), dto.TestMethod);
		//计算类型
		dto.CalcType=Helper.ValidParam(JRTContext.GetRequest(Request, "CalcType"), dto.CalcType);
		//精度
		dto.Precision=Helper.ValidParam(JRTContext.GetRequest(Request, "Precision"), dto.Precision);
		//稀释倍数
		dto.Dilutions=Helper.ValidParam(JRTContext.GetRequest(Request, "Dilutions"), dto.Dilutions);
		//说明
		dto.Remark=Helper.ValidParam(JRTContext.GetRequest(Request, "Remark"), dto.Remark);
		//浓度单位
		dto.LevelUnit=Helper.ValidParam(JRTContext.GetRequest(Request, "LevelUnit"), dto.LevelUnit);
		//CV来源
		dto.CVSource=Helper.ValidParam(JRTContext.GetRequest(Request, "CVSource"), dto.CVSource);
		//生产日期
		dto.ProductDate=Helper.ValidParam(JRTContext.GetRequest(Request, "ProductDate"), dto.ProductDate);
		//有效日期
		dto.ExpiryDate=Helper.ValidParam(JRTContext.GetRequest(Request, "ExpiryDate"), dto.ExpiryDate);
		//关闭日期
		dto.ClosingDate=Helper.ValidParam(JRTContext.GetRequest(Request, "ClosingDate"), dto.ClosingDate);
		//校正液批次
		dto.AmendLiquidLot=Helper.ValidParam(JRTContext.GetRequest(Request, "AmendLiquidLot"), dto.AmendLiquidLot);
		//主波长
		dto.WaveLengthMian=Helper.ValidParam(JRTContext.GetRequest(Request, "WaveLengthMian"), dto.WaveLengthMian);
		//波长
		dto.WaveLength=Helper.ValidParam(JRTContext.GetRequest(Request, "WaveLength"), dto.WaveLength);
		//生效日期
		dto.RgEffectiveDate=Helper.ValidParam(JRTContext.GetRequest(Request, "RgEffectiveDate"), dto.RgEffectiveDate);
		//校准液有效期
		dto.AmendLiquidDate=Helper.ValidParam(JRTContext.GetRequest(Request, "AmendLiquidDate"), dto.AmendLiquidDate);
		//校准液
		dto.AmendLiquid=Helper.ValidParam(JRTContext.GetRequest(Request, "AmendLiquid"), dto.AmendLiquid);
		//偏离图SD
		dto.DeviationRatioSD=Helper.ValidParam(JRTContext.GetRequest(Request, "DeviationRatioSD"), dto.DeviationRatioSD);
		//规则说明
		dto.RuleRemark=Helper.ValidParam(JRTContext.GetRequest(Request, "RuleRemark"), dto.RuleRemark);
		//序号
		dto.Sequence=Helper.ValidParam(JRTContext.GetRequest(Request, "Sequence"), dto.Sequence);
		//激活  {1:true,0:false}
		dto.Active=Helper.ValidParam(JRTContext.GetRequest(Request, "Active"), dto.Active);
		//计算靶值
		dto.FloatMean=Helper.ValidParam(JRTContext.GetRequest(Request, "FloatMean"), dto.FloatMean);
		//计算标准差
		dto.FloatSD=Helper.ValidParam(JRTContext.GetRequest(Request, "FloatSD"), dto.FloatSD);
		//累计总数
		dto.AccSum=Helper.ValidParam(JRTContext.GetRequest(Request, "AccSum"), dto.AccSum);
		//累计均值
		dto.AccMean=Helper.ValidParam(JRTContext.GetRequest(Request, "AccMean"), dto.AccMean);
		//累计标准差
		dto.AccSD=Helper.ValidParam(JRTContext.GetRequest(Request, "AccSD"), dto.AccSD);
		//在控个数
		dto.InControlNum=Helper.ValidParam(JRTContext.GetRequest(Request, "InControlNum"), dto.InControlNum);
		//在控均值
		dto.InControlMean=Helper.ValidParam(JRTContext.GetRequest(Request, "InControlMean"), dto.InControlMean);
		//在控标准差
		dto.InControlSD=Helper.ValidParam(JRTContext.GetRequest(Request, "InControlSD"), dto.InControlSD);
		OutParam out=new OutParam();
		int ret=0;
		//更新
		if(dto.RowID>0)
		{
			ret=EntityManager().Update(dto,null, out, null, null, null);
		}
		//插入数据
		else
		{
			ret=EntityManager().Save(dto,out);
		}
		if(ret==1)
		{
			return Helper.Success();
		}
		else
		{
			return Helper.Error(out);
		}
	}

	/**
	 * 复制质控物
	 * @return
	 */
	@Trans
	public String CopyBTQCMaterial() throws Exception
	{
		//要复制的质控物
		int RowID=Helper.ValidParam(JRTContext.GetRequest(Request, "RowID"), 0);
		//新质控物信息
		int NewMachDR=Helper.ValidParam(JRTContext.GetRequest(Request, "NewMachDR"), 0);
		String NewCode=Helper.ValidParam(JRTContext.GetRequest(Request, "NewCode"), "");
		String NewName=Helper.ValidParam(JRTContext.GetRequest(Request, "NewName"), "");
		BTQCMaterial matOld=EntityManager().DolerGet(BTQCMaterial.class,RowID);
		BTQCMaterial matNew=new BTQCMaterial();
		//拷贝属性
		Helper.CopyProperties(matOld,matNew);
		matNew.Code=NewCode;
		matNew.CName=NewName;
		matNew.MachineDR=NewMachDR;
		OutValue key=new OutValue();
		int ret=EntityManager().Save(matNew,key,ErrRet());
		if(ret==1)
		{
			//拷贝浓度
			List<BTQCMaterialLevel> levList=EntityManager().FindByColVal(BTQCMaterialLevel.class,"MaterialDR",RowID);
			if(levList!=null&&levList.size()>0)
			{
				for(BTQCMaterialLevel lev:levList)
				{
					BTQCMaterialLevel newLev=new BTQCMaterialLevel();
					Helper.CopyProperties(lev,newLev);
					newLev.MaterialDR=key.GetInerger();
					int ret1=EntityManager().Save(newLev,ErrRet());
					if(ret1!=1)
					{
						throw new Exception("拷贝质控浓度失败:"+Err.GetString());
					}
				}
			}
			//拷贝标识
			List<BTQCMachineQC> machQCList=EntityManager().FindByColVal(BTQCMachineQC.class,"MaterialDR",RowID);
			if(machQCList!=null&&machQCList.size()>0)
			{
				for(BTQCMachineQC machQC:machQCList)
				{
					BTQCMachineQC newMachQC=new BTQCMachineQC();
					Helper.CopyProperties(machQC,newMachQC);
					newMachQC.MaterialDR=key.GetInerger();
					int ret1=EntityManager().Save(newMachQC,ErrRet());
					if(ret1!=1)
					{
						throw new Exception("拷贝质控标识失败:"+Err.GetString());
					}
				}
			}
			//拷贝项目批次
			List<BTQCMaterialTestCode> matTSList=EntityManager().FindByColVal(BTQCMaterialTestCode.class,"MaterialDR",RowID);
			if(matTSList!=null&&matTSList.size()>0)
			{
				for(BTQCMaterialTestCode matTS:matTSList)
				{
					BTQCMaterialTestCode newMatTS=new BTQCMaterialTestCode();
					Helper.CopyProperties(matTS,newMatTS);
					newMatTS.MaterialDR=key.GetInerger();
					int ret1=EntityManager().Save(newMatTS,ErrRet());
					if(ret1!=1)
					{
						throw new Exception("拷贝质控项目批次失败:"+Err.GetString());
					}
				}
			}
			//拷贝批次公共信息
			List<BTQCMaterialLot> matLotList=EntityManager().FindByColVal(BTQCMaterialLot.class,"MaterialDR",RowID);
			if(matLotList!=null&&matLotList.size()>0)
			{
				for(BTQCMaterialLot matLot:matLotList)
				{
					BTQCMaterialLot newMatLot=new BTQCMaterialLot();
					Helper.CopyProperties(matLot,newMatLot);
					newMatLot.MaterialDR=key.GetInerger();
					int ret1=EntityManager().Save(newMatLot,ErrRet());
					if(ret1!=1)
					{
						throw new Exception("拷贝质控批次公共信息失败:"+Err.GetString());
					}
				}
			}
			//拷贝质控规则
			List<BTQCMaterialRules> matRuleList=EntityManager().FindByColVal(BTQCMaterialRules.class,"MaterialDR",RowID);
			if(matRuleList!=null&&matRuleList.size()>0)
			{
				for(BTQCMaterialRules matRule:matRuleList)
				{
					BTQCMaterialRules newMatRule=new BTQCMaterialRules();
					Helper.CopyProperties(matRule,newMatRule);
					newMatRule.MaterialDR=key.GetInerger();
					int ret1=EntityManager().Save(newMatRule,ErrRet());
					if(ret1!=1)
					{
						throw new Exception("拷贝质控规则失败:"+Err.GetString());
					}
				}
			}
			//拷贝项目质控规则
			List<BTQCMaterialTCRules> matTCRuleList=EntityManager().FindByColVal(BTQCMaterialTCRules.class,"MaterialDR",RowID);
			if(matTCRuleList!=null&&matTCRuleList.size()>0)
			{
				for(BTQCMaterialTCRules matTCRule:matTCRuleList)
				{
					BTQCMaterialTCRules newMatTCRule=new BTQCMaterialTCRules();
					Helper.CopyProperties(matTCRule,newMatTCRule);
					newMatTCRule.MaterialDR=key.GetInerger();
					int ret1=EntityManager().Save(newMatTCRule,ErrRet());
					if(ret1!=1)
					{
						throw new Exception("拷贝项目质控规则失败:"+Err.GetString());
					}
				}
			}
			//拷贝定性显示
			List<BTQCQualitativeShow> qlitiList=EntityManager().FindByColVal(BTQCQualitativeShow.class,"MaterialDR",RowID);
			if(qlitiList!=null&&qlitiList.size()>0)
			{
				for(BTQCQualitativeShow qliti:qlitiList)
				{
					BTQCQualitativeShow newQliti=new BTQCQualitativeShow();
					Helper.CopyProperties(qliti,newQliti);
					newQliti.MaterialDR=key.GetInerger();
					int ret1=EntityManager().Save(newQliti,ErrRet());
					if(ret1!=1)
					{
						throw new Exception("拷贝定性显示失败:"+Err.GetString());
					}
				}
			}
		}
		return Helper.Success();
	}

	/**
	 * 批量修改批次项目属性
	 * @return 字符串
	 */
	@Trans
	public String UpdateLotBTQCMaterialTestCode() throws Exception
	{
		String RowIDS=Helper.ValidParam(JRTContext.GetRequest(Request, "RowIDS"), "");
		List<String> upCol=new ArrayList<>();
		String StartDate=Helper.ValidParam(JRTContext.GetRequest(Request, "StartDate"), "");
		if(!StartDate.isEmpty())
		{
			upCol.add("StartDate");
		}
		String LotNo=Helper.ValidParam(JRTContext.GetRequest(Request, "LotNo"), "");
		if(!LotNo.isEmpty())
		{
			upCol.add("LotNo");
		}
		String MatManufacturer=Helper.ValidParam(JRTContext.GetRequest(Request, "MatManufacturer"), "");
		if(!MatManufacturer.isEmpty())
		{
			upCol.add("MatManufacturer");
		}
		String RgLot=Helper.ValidParam(JRTContext.GetRequest(Request, "RgLot"), "");
		if(!RgLot.isEmpty())
		{
			upCol.add("RgLot");
		}
		String RgManufacturer=Helper.ValidParam(JRTContext.GetRequest(Request, "RgManufacturer"), "");
		if(!RgManufacturer.isEmpty())
		{
			upCol.add("RgManufacturer");
		}
		String RgEffectiveDate=Helper.ValidParam(JRTContext.GetRequest(Request, "RgEffectiveDate"), "");
		if(!RgEffectiveDate.isEmpty())
		{
			upCol.add("RgEffectiveDate");
		}
		String TestMethod=Helper.ValidParam(JRTContext.GetRequest(Request, "TestMethod"), "");
		if(!TestMethod.isEmpty())
		{
			upCol.add("TestMethod");
		}
		String CalcType=Helper.ValidParam(JRTContext.GetRequest(Request, "CalcType"), "");
		if(!CalcType.isEmpty())
		{
			upCol.add("CalcType");
		}
		String Precision=Helper.ValidParam(JRTContext.GetRequest(Request, "Precision"), "");
		if(!Precision.isEmpty())
		{
			upCol.add("Precision");
		}
		String Dilutions=Helper.ValidParam(JRTContext.GetRequest(Request, "Dilutions"), "");
		if(!Dilutions.isEmpty())
		{
			upCol.add("Dilutions");
		}
		String Remark=Helper.ValidParam(JRTContext.GetRequest(Request, "Remark"), "");
		if(!Remark.isEmpty())
		{
			upCol.add("Remark");
		}
		String LevelUnit=Helper.ValidParam(JRTContext.GetRequest(Request, "LevelUnit"), "");
		if(!LevelUnit.isEmpty())
		{
			upCol.add("LevelUnit");
		}
		String TargetCV=Helper.ValidParam(JRTContext.GetRequest(Request, "TargetCV"), "");
		if(!TargetCV.isEmpty())
		{
			upCol.add("TargetCV");
		}
		String CVSource=Helper.ValidParam(JRTContext.GetRequest(Request, "CVSource"), "");
		if(!CVSource.isEmpty())
		{
			upCol.add("CVSource");
		}
		String Sequence=Helper.ValidParam(JRTContext.GetRequest(Request, "Sequence"), "");
		if(!Sequence.isEmpty())
		{
			upCol.add("Sequence");
		}
		String ProductDate=Helper.ValidParam(JRTContext.GetRequest(Request, "ProductDate"), "");
		if(!ProductDate.isEmpty())
		{
			upCol.add("ProductDate");
		}
		String ExpiryDate=Helper.ValidParam(JRTContext.GetRequest(Request, "ExpiryDate"), "");
		if(!ExpiryDate.isEmpty())
		{
			upCol.add("ExpiryDate");
		}
		String ClosingDate=Helper.ValidParam(JRTContext.GetRequest(Request, "ClosingDate"), "");
		if(!ClosingDate.isEmpty())
		{
			upCol.add("ClosingDate");
		}
		String WaveLengthMian=Helper.ValidParam(JRTContext.GetRequest(Request, "WaveLengthMian"), "");
		if(!WaveLengthMian.isEmpty())
		{
			upCol.add("WaveLengthMian");
		}
		String WaveLength=Helper.ValidParam(JRTContext.GetRequest(Request, "WaveLength"), "");
		if(!WaveLength.isEmpty())
		{
			upCol.add("WaveLength");
		}
		String Active=Helper.ValidParam(JRTContext.GetRequest(Request, "Active"), "");
		if(!Active.isEmpty())
		{
			upCol.add("Active");
		}
		String AmendLiquidLot=Helper.ValidParam(JRTContext.GetRequest(Request, "AmendLiquidLot"), "");
		if(!AmendLiquidLot.isEmpty())
		{
			upCol.add("AmendLiquidLot");
		}
		String AmendLiquidDate=Helper.ValidParam(JRTContext.GetRequest(Request, "AmendLiquidDate"), "");
		if(!AmendLiquidDate.isEmpty())
		{
			upCol.add("AmendLiquidDate");
		}
		String AmendLiquid=Helper.ValidParam(JRTContext.GetRequest(Request, "AmendLiquid"), "");
		if(!AmendLiquid.isEmpty())
		{
			upCol.add("AmendLiquid");
		}
		String RuleRemark=Helper.ValidParam(JRTContext.GetRequest(Request, "RuleRemark"), "");
		if(!RuleRemark.isEmpty())
		{
			upCol.add("RuleRemark");
		}
		String [] arr=RowIDS.split("\\^");
		for(int i=0;i<arr.length;i++)
		{
			int RowID=Convert.ToInt32(arr[i]);
			BTQCMaterialTestCode dto=EntityManager().DolerGet(BTQCMaterialTestCode.class,RowID);
			if(!StartDate.isEmpty())
			{
				dto.StartDate=Helper.DateToInt(StartDate);
			}
			if(!LotNo.isEmpty())
			{
				dto.LotNo=LotNo;
			}
			if(!MatManufacturer.isEmpty())
			{
				dto.MatManufacturer=MatManufacturer;
			}
			if(!RgLot.isEmpty())
			{
				dto.RgLot=RgLot;
			}
			if(!RgManufacturer.isEmpty())
			{
				dto.RgManufacturer=RgManufacturer;
			}
			if(!RgEffectiveDate.isEmpty())
			{
				dto.RgEffectiveDate=Helper.DateToInt(RgEffectiveDate);
			}
			if(!TestMethod.isEmpty())
			{
				dto.TestMethod=TestMethod;
			}
			if(!CalcType.isEmpty())
			{
				dto.CalcType=CalcType;
			}
			if(!Precision.isEmpty())
			{
				dto.Precision=Convert.ToInt32(Precision);
			}
			if(!Dilutions.isEmpty())
			{
				dto.Dilutions=Dilutions;
			}
			if(!Remark.isEmpty())
			{
				dto.Remark=Remark;
			}
			if(!LevelUnit.isEmpty())
			{
				dto.LevelUnit=LevelUnit;
			}
			if(!TargetCV.isEmpty())
			{
				dto.TargetCV=TargetCV;
			}
			if(!CVSource.isEmpty())
			{
				dto.CVSource=CVSource;
			}
			if(!Sequence.isEmpty())
			{
				dto.Sequence=Convert.ToInt32(Sequence);
			}
			if(!ProductDate.isEmpty())
			{
				dto.ProductDate=Helper.DateToInt(ProductDate);
			}
			if(!ExpiryDate.isEmpty())
			{
				dto.ExpiryDate=Helper.DateToInt(ExpiryDate);
			}
			if(!ClosingDate.isEmpty())
			{
				dto.ClosingDate=Helper.DateToInt(ClosingDate);
			}
			if(!WaveLengthMian.isEmpty())
			{
				dto.WaveLengthMian=WaveLengthMian;
			}
			if(!WaveLength.isEmpty())
			{
				dto.WaveLength=WaveLength;
			}
			if(!Active.isEmpty())
			{
				dto.Active=Helper.ValidParam(Active,true);
			}
			if(!AmendLiquidLot.isEmpty())
			{
				dto.AmendLiquidLot=AmendLiquidLot;
			}
			if(!AmendLiquidDate.isEmpty())
			{
				dto.AmendLiquidDate=Helper.DateToInt(AmendLiquidDate);
			}
			if(!AmendLiquid.isEmpty())
			{
				dto.AmendLiquid=AmendLiquid;
			}
			if(!RuleRemark.isEmpty())
			{
				dto.RuleRemark=RuleRemark;
			}
			int ret=EntityManager().Update(dto,ErrRet(),upCol);
			if(ret!=1)
			{
				throw new Exception("更新项目批次失败:"+Err.GetString());
			}
		}
		return Helper.Success();
	}



	/**
	 * 删除数据,多个RowID以上尖号分割
	 * @return 字符串
	 */
	public String DeleteBTQCMaterialTestCode() throws Exception
	{
		String RowIDS=Helper.ValidParam(JRTContext.GetRequest(Request, "RowIDS"), "");
		if(RowIDS.isEmpty())
		{
			return Helper.Error("请传入要删除数据的RowID,多个以^分割!");
		}
		//分割主键
		String [] arr=RowIDS.split("\\^");
		//out参数
		OutParam out=new OutParam();
		//循环删除数据
		for(int i=0;i<arr.length;i++)
		{
			int ret=EntityManager().RemoveById(BTQCMaterialTestCode.class,Convert.ToInt32(arr[i]),out);
			if(ret!=1)
			{
				return Helper.Error(out);
			}
		}
		return Helper.Success();
	}



	/**
	 * 查询数据,前台按表的属性名提交
	 * @return 字符串
	 */
	public String QryBTQCMaterialTestCode() throws Exception
	{
		//分页
		int pageSize = Helper.ValidParam(JRT.Core.MultiPlatform.JRTContext.GetRequest(Request, "rows"), -1);
		int pageIndex = Helper.ValidParam(JRT.Core.MultiPlatform.JRTContext.GetRequest(Request, "page"), -1);
		//质控物
		int MaterialDR=Helper.ValidParam(JRTContext.GetRequest(Request, "MaterialDR"), 0);
		//按项目和浓度筛选
		String TestCodeDR=Helper.ValidParam(JRTContext.GetRequest(Request, "TestCodeDR"), "");
		String LevelNo=Helper.ValidParam(JRTContext.GetRequest(Request, "LevelNo"), "");
		//筛选
		String Filter=Helper.ValidParam(JRTContext.GetRequest(Request, "Filter"), "");
		//质控浓度数据
		List<BTQCMaterialLevel> levList=EntityManager().FindByColVal(BTQCMaterialLevel.class,"MaterialDR",MaterialDR);
		HashParam hs=new HashParam();
		hs.Add("MaterialDR",MaterialDR);
		if(!TestCodeDR.isEmpty())
		{
			hs.Add("TestCodeDR",Convert.ToInt32(TestCodeDR));
		}
		if(!LevelNo.isEmpty())
		{
			hs.Add("LevelNo",Convert.ToInt32(LevelNo));
		}
		OutValue totalNum=new OutValue();
		//分页查询
		List<BTQCMaterialTestCodeDto> dataList=EntityManager().FindAll(BTQCMaterialTestCodeDto.class,hs,"StartDate desc",pageSize,pageIndex,"",null,null,totalNum);
		List<BTQCMaterialTestCodeDto> retList=new ArrayList<>();
		//标识最后的批次项目
		HashMap lastMap=new HashMap();
		if(dataList!=null&&dataList.size()>0)
		{
			for(BTQCMaterialTestCodeDto one:dataList)
			{
				//打上标识
				if(!lastMap.containsKey(one.TestCodeDR+"-"+one.LevelNo))
				{
					one.IsLast=true;
					lastMap.put(one.TestCodeDR+"-"+one.LevelNo,true);
				}
				else
				{
					one.IsLast=false;
				}
				one.LevelNoName="";
				for(BTQCMaterialLevel lev:levList)
				{
					if(lev.LevelNo==one.LevelNo)
					{
						one.LevelNoName=lev.CName;
					}
				}
				//项目数据
				BTTestCode tsDto=EntityManager().DolerGet(BTTestCode.class,one.TestCodeDR);
				one.TestCodeCode=tsDto.Code;
				one.TestCodeDR=tsDto.RowID;
				one.TestCodeSynonym=tsDto.Synonym;
				one.TestCodeName=tsDto.CName;
				boolean isPerData=false;
				if(!Filter.isEmpty()&&one.LevelNoName.contains(Filter))
				{
					isPerData=true;
				}
				if(!Filter.isEmpty()&&one.TestCodeName.contains(Filter))
				{
					isPerData=true;
				}
				if(!Filter.isEmpty()&&one.TestCodeCode.equals(Filter))
				{
					isPerData=true;
				}
				if(!Filter.isEmpty()&&one.LotNo.equals(Filter))
				{
					isPerData=true;
				}
				if(!Filter.isEmpty()&&one.RgLot.equals(Filter))
				{
					isPerData=true;
				}
				if(!Filter.isEmpty()&&one.Remark.contains(Filter))
				{
					isPerData=true;
				}
				if(!Filter.isEmpty()&&one.MatManufacturer.equals(Filter))
				{
					isPerData=true;
				}
				if(!Filter.isEmpty()&&one.RgManufacturer.equals(Filter))
				{
					isPerData=true;
				}
				if(Filter.isEmpty()||isPerData==true)
				{
					retList.add(one);
				}
			}
		}
		return Helper.MakeTotalJson(retList,totalNum);
	}

	/**
	 * 查询能够开通的项目或者已经开通的项目
	 * @return
	 */
	public String QueryOpenTestCode() throws Exception
	{
		//查是否有开通项目
		boolean HasOpen=Helper.ValidParam(JRTContext.GetRequest(Request, "HasOpen"), false);
		//质控物主键
		int MaterialDR=Helper.ValidParam(JRTContext.GetRequest(Request, "MaterialDR"), 0);
		//得到质控物的数据
		BTQCMaterial matDto=EntityManager().DolerGet(BTQCMaterial.class,MaterialDR);
		//仪器数据
		BTMIMachineParameter machDto=EntityManager().DolerGet(BTMIMachineParameter.class,matDto.MachineDR);
		//查询仪器项目
		List<BTMIMachineTestCode> machTsList=EntityManager().FindByColVal(BTMIMachineTestCode.class,"MachineParameterDR",matDto.MachineDR);
		//质控浓度数据
		List<BTQCMaterialLevel> levList=EntityManager().FindByColVal(BTQCMaterialLevel.class,"MaterialDR",MaterialDR);
		//返回列表
		List<BTMIMachineTestCodeDto> retList=new ArrayList<>();
		if(machTsList!=null&&machTsList.size()>0)
		{
			for(int i=0;i<machTsList.size();i++)
			{
				//没激活的不要
				if(machTsList.get(i).Active!=null&&machTsList.get(i).Active==false)
				{
					continue;
				}
				//没维护通道的不算质控
				if(machTsList.get(i).ResultChannel==null||machTsList.get(i).ResultChannel.isEmpty())
				{
					continue;
				}
				for(int j=1;j<=matDto.Levels;j++)
				{
					HashParam hs=new HashParam();
					hs.Add("MaterialDR",matDto.RowID);
					hs.Add("TestCodeDR",machTsList.get(i).TestCodeDR);
					hs.Add("LevelNo",j);
					//按条件检查是否有数据
					boolean hasOpen=EntityManager().CheckHasData(BTQCMaterialTestCode.class,hs,null,null);
					//根据开通决定输出
					if(hasOpen==HasOpen)
					{
						BTMIMachineTestCodeDto one=new BTMIMachineTestCodeDto();
						one.MaterialDR=matDto.RowID;
						one.MachineDR=machDto.RowID;
						one.LevelNo=j;
						one.LevelNoName="";
						for(BTQCMaterialLevel lev:levList)
						{
							if(lev.LevelNo==j)
							{
								one.LevelNoName=lev.CName;
							}
						}
						//项目数据
						BTTestCode tsDto=EntityManager().DolerGet(BTTestCode.class,machTsList.get(i).TestCodeDR);
						one.TestCodeCode=tsDto.Code;
						one.TestCodeDR=tsDto.RowID;
						one.TestCodeSynonym=tsDto.Synonym;
						one.TestCodeName=tsDto.CName;
						retList.add(one);
					}
				}
			}
		}
		return Helper.Object2Json(retList);
	}

	/**
	 * 开通质控项目
	 * @return
	 */
	@Trans
	public String OpenBTQCMaterialTestCode() throws Exception
	{
		int MaterialDR=Helper.ValidParam(JRTContext.GetRequest(Request, "MaterialDR"), 0);
		int MaterialLotDR=Helper.ValidParam(JRTContext.GetRequest(Request, "MaterialLotDR"), 0);
		String OpenTsLev=Helper.ValidParam(JRTContext.GetRequest(Request, "OpenTsLev"), "");
		String [] arr=OpenTsLev.split("\\^");
		//公共信息
		BTQCMaterialLot lotDto=EntityManager().DolerGet(BTQCMaterialLot.class,MaterialLotDR);
		OutValue key=new OutValue();
		for(String one:arr)
		{
			String [] tsLev=one.split("-");
			int TestCodeDR=Convert.ToInt32(tsLev[0]);
			int LevelNo=Convert.ToInt32(tsLev[1]);
			BTQCMaterialTestCode dto=new BTQCMaterialTestCode();
			//拷贝相同的属性值
			ReflectUtil.CopyProperties(lotDto,dto);
			dto.MaterialDR=MaterialDR;
			dto.TestCodeDR=TestCodeDR;
			dto.LevelNo=LevelNo;
			dto.Active=true;
			dto.Sequence=1;
			int ret=EntityManager().Save(dto,key,ErrRet());
			if(ret!=1)
			{
				throw new Exception(Err.GetString());
			}

		}
		return Helper.Success();
	}

	/**
	 * 更换项目批次
	 * @return
	 */
	@Trans
	public String ChangeBTQCMaterialTestCode() throws Exception
	{
		int MaterialDR=Helper.ValidParam(JRTContext.GetRequest(Request, "MaterialDR"), 0);
		int MaterialLotDR=Helper.ValidParam(JRTContext.GetRequest(Request, "MaterialLotDR"), 0);
		String RowIDS=Helper.ValidParam(JRTContext.GetRequest(Request, "RowIDS"), "");
		String [] arr=RowIDS.split("\\^");
		//公共信息
		BTQCMaterialLot lotDto=EntityManager().DolerGet(BTQCMaterialLot.class,MaterialLotDR);
		OutValue key=new OutValue();
		List<String> upCol=new ArrayList<>();
		upCol.add("Active");
		for(String one:arr)
		{
			int MatTestCodeDR=Convert.ToInt32(one);
			BTQCMaterialTestCode dto=EntityManager().DolerGet(BTQCMaterialTestCode.class,MatTestCodeDR);
			int TestCodeDR=dto.TestCodeDR;
			int LevelNo=dto.LevelNo;
			dto.Active=false;
			//之前的数据设置不激活
			EntityManager().Update(dto,upCol);
			dto.Sequence=dto.Sequence+1;
			//拷贝相同的属性值,null和空串的不拷贝
			ReflectUtil.CopyProperties(lotDto,dto,true);
			dto.MaterialDR=MaterialDR;
			dto.TestCodeDR=TestCodeDR;
			dto.LevelNo=LevelNo;
			dto.Active=true;
			dto.Sequence=1;
			int ret=EntityManager().Save(dto,key,ErrRet());
			if(ret!=1)
			{
				throw new Exception(Err.GetString());
			}

		}
		return Helper.Success();
	}

	/**
	 * 查询能更换批次的项目
	 * @return
	 */
	public String QueryChangeTestCode() throws Exception
	{
		//质控物主键
		int MaterialDR=Helper.ValidParam(JRTContext.GetRequest(Request, "MaterialDR"), 0);
		//得到质控物的数据
		BTQCMaterial matDto=EntityManager().DolerGet(BTQCMaterial.class,MaterialDR);
		//仪器数据
		BTMIMachineParameter machDto=EntityManager().DolerGet(BTMIMachineParameter.class,matDto.MachineDR);
		//查询仪器项目
		List<BTMIMachineTestCode> machTsList=EntityManager().FindByColVal(BTMIMachineTestCode.class,"MachineParameterDR",matDto.MachineDR);
		//质控浓度数据
		List<BTQCMaterialLevel> levList=EntityManager().FindByColVal(BTQCMaterialLevel.class,"MaterialDR",MaterialDR);
		//返回列表
		List<BTQCMaterialTestCodeDto> retList=new ArrayList<>();
		if(machTsList!=null&&machTsList.size()>0)
		{
			for(int i=0;i<machTsList.size();i++)
			{
				//没激活的不要
				if(machTsList.get(i).Active!=null&&machTsList.get(i).Active==false)
				{
					continue;
				}
				for(int j=1;j<=matDto.Levels;j++)
				{
					HashParam hs=new HashParam();
					hs.Add("MaterialDR",matDto.RowID);
					hs.Add("TestCodeDR",machTsList.get(i).TestCodeDR);
					hs.Add("LevelNo",j);
					//按条件检查是否有数据
					boolean hasOpen=EntityManager().CheckHasData(BTQCMaterialTestCode.class,hs,null,null);
					//根据开通决定输出
					if(hasOpen==true)
					{
						List<BTQCMaterialTestCodeDto> oneList=EntityManager().FindAllSimple(BTQCMaterialTestCodeDto.class,hs,"StartDate desc",1,null,null);
						BTQCMaterialTestCodeDto one=oneList.get(0);
						one.LevelNoName="";
						for(BTQCMaterialLevel lev:levList)
						{
							if(lev.LevelNo==one.LevelNo)
							{
								one.LevelNoName=lev.CName;
							}
						}
						//项目数据
						BTTestCode tsDto=EntityManager().DolerGet(BTTestCode.class,one.TestCodeDR);
						one.TestCodeCode=tsDto.Code;
						one.TestCodeDR=tsDto.RowID;
						one.TestCodeSynonym=tsDto.Synonym;
						one.TestCodeName=tsDto.CName;
						retList.add(one);

					}
				}
			}
		}
		return Helper.Object2Json(retList);
	}


	/**
	 * 查询数据,前台按表的属性名提交
	 * @return 字符串
	 */
	public String QryQCResMaterialTestCode() throws Exception
	{
		//分页
		int pageSize = Helper.ValidParam(JRT.Core.MultiPlatform.JRTContext.GetRequest(Request, "rows"), -1);
		int pageIndex = Helper.ValidParam(JRT.Core.MultiPlatform.JRTContext.GetRequest(Request, "page"), -1);
		//质控物
		int MaterialDR=Helper.ValidParam(JRTContext.GetRequest(Request, "MaterialDR"), 0);
		//按项目和浓度筛选
		String TestCodeDR=Helper.ValidParam(JRTContext.GetRequest(Request, "TestCodeDR"), "");
		String LevelNo=Helper.ValidParam(JRTContext.GetRequest(Request, "LevelNo"), "");
		//筛选
		String Filter=Helper.ValidParam(JRTContext.GetRequest(Request, "Filter"), "");
		//质控浓度数据
		List<BTQCMaterialLevel> levList=EntityManager().FindByColVal(BTQCMaterialLevel.class,"MaterialDR",MaterialDR);
		HashParam hs=new HashParam();
		hs.Add("MaterialDR",MaterialDR);
		if(!TestCodeDR.isEmpty())
		{
			hs.Add("TestCodeDR",Convert.ToInt32(TestCodeDR));
		}
		if(!LevelNo.isEmpty())
		{
			hs.Add("LevelNo",Convert.ToInt32(LevelNo));
		}
		OutValue totalNum=new OutValue();
		//分页查询
		List<QCResMaterialTestCodeDto> dataList=EntityManager().FindAll(QCResMaterialTestCodeDto.class,hs,"TestDate desc",pageSize,pageIndex,"",null,null,totalNum);
		List<QCResMaterialTestCodeDto> retList=new ArrayList<>();
		if(dataList!=null&&dataList.size()>0)
		{
			for(QCResMaterialTestCodeDto one:dataList)
			{

				one.LevelNoName="";
				for(BTQCMaterialLevel lev:levList)
				{
					if(lev.LevelNo==one.LevelNo)
					{
						one.LevelNoName=lev.CName;
					}
				}
				//项目数据
				BTTestCode tsDto=EntityManager().DolerGet(BTTestCode.class,one.TestCodeDR);
				one.TestCodeCode=tsDto.Code;
				one.TestCodeDR=tsDto.RowID;
				one.TestCodeSynonym=tsDto.Synonym;
				one.TestCodeName=tsDto.CName;
				boolean isPerData=false;
				if(!Filter.isEmpty()&&one.LevelNoName.contains(Filter))
				{
					isPerData=true;
				}
				if(!Filter.isEmpty()&&one.TestCodeName.contains(Filter))
				{
					isPerData=true;
				}
				if(!Filter.isEmpty()&&one.TestCodeCode.equals(Filter))
				{
					isPerData=true;
				}
				if(!Filter.isEmpty()&&one.LotNo.equals(Filter))
				{
					isPerData=true;
				}
				if(!Filter.isEmpty()&&one.RgLot.equals(Filter))
				{
					isPerData=true;
				}
				if(!Filter.isEmpty()&&one.Remark.contains(Filter))
				{
					isPerData=true;
				}
				if(!Filter.isEmpty()&&one.MatManufacturer.equals(Filter))
				{
					isPerData=true;
				}
				if(!Filter.isEmpty()&&one.RgManufacturer.equals(Filter))
				{
					isPerData=true;
				}
				if(Filter.isEmpty()||isPerData==true)
				{
					retList.add(one);
				}
			}
		}
		return Helper.MakeTotalJson(retList,totalNum);
	}


	/**
	 * 去除没有仪器的树节点
	 * @param retList 树节点集合
	 */
	private void DealNoMachineTree(List<MachineTreeDto> retList) throws Exception
	{
		if(retList!=null&&retList.size()>0)
		{
			for(int i=0;i<retList.size();i++)
			{
				//没有工作小组的工作组删掉
				if(retList.get(i).children.size()==0)
				{
					retList.remove(i);

					i--;
				}
				else
				{
					//检查每个工作小组
					for(int j=0;j<retList.get(i).children.size();j++)
					{
						//工作小组下没有仪器
						if(retList.get(i).children.get(j).children.size()==0)
						{
							retList.get(i).children.remove(j);
							j--;
						}
					}
					//没有小组就把工作组节点也删了
					if(retList.get(i).children.size()==0)
					{
						retList.remove(i);
						i--;
					}
				}
			}
		}
	}

	/**
	 * 质控业务数据的批次项目信息
	 */
	public static class QCResMaterialTestCodeDto extends QCResMaterialTestCode
	{
		/**
		 * 浓度名称
		 */
		public String LevelNoName;

		/**
		 * 项目代码
		 */
		public String TestCodeCode;

		/**
		 * 项目名称
		 */
		public String TestCodeName;

		/**
		 * 项目缩写
		 */
		public String TestCodeSynonym;
	}

	/**
	 * 返回仪器项目的数据
	 */
	public static class BTMIMachineTestCodeDto
	{
		/**
		 * 质控物主键
		 */
		public int MaterialDR;

		/**
		 * 仪器主键
		 */
		public int MachineDR;

		/**
		 * 项目主键
		 */
		public int TestCodeDR;

		/**
		 * 浓度
		 */
		public int LevelNo;

		/**
		 * 浓度名称
		 */
		public String LevelNoName;

		/**
		 * 项目代码
		 */
		public String TestCodeCode;

		/**
		 * 项目名称
		 */
		public String TestCodeName;

		/**
		 * 项目缩写
		 */
		public String TestCodeSynonym;
	}

	/**
	 * 质控仪器树实体
	 */
	public static class MachineTreeDto {

		/**
		 * 数据唯一键
		 */
		public int RowID;

		/**
		 * 树id
		 */
		public String id;

		/**
		 * 树文本
		 */
		public String text;

		/**
		 * 是否选择
		 */
		public String checked;

		/**
		 * 子节点
		 */
		public List<MachineTreeDto> children;

		/**
		 * 节点类型
		 */
		public String Type;

	}

	/**
	 * 质控物实体
	 */
	public  static class BTQCMaterialDto  extends BTQCMaterial
	{
		/**
		 * 工作组主键
		 */
		public int WorkGroupDR;

		/**
		 * 工作组名称
		 */
		public String WorkGroupName;

		/**
		 * 工作小组主键
		 */
		public int WorkGroupMachineDR;

		/**
		 * 工作小组名称
		 */
		public String WorkGroupMachineName;

		/**
		 * 仪器名称
		 */
		public String MachineName;


	}

	/**
	 * 质控项目的返回实体
	 */
	public static class BTQCMaterialTestCodeDto extends BTQCMaterialTestCode
	{
		/**
		 * 浓度名称
		 */
		public String LevelNoName;

		/**
		 * 项目代码
		 */
		public String TestCodeCode;

		/**
		 * 项目名称
		 */
		public String TestCodeName;

		/**
		 * 项目缩写
		 */
		public String TestCodeSynonym;

		/**
		 * 是否最后的批次项目
		 */
		public boolean IsLast;
	}


}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/548742.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

盘点入驻天府锋巢直播产业基地,能够享受哪些政策优惠?

直播产业谱写了互联网时代下最新的狂想曲&#xff0c;在短短几年时间&#xff0c;各数资本、品牌、MCN、主播不断涌入其中。根据招商证券预测&#xff0c;直播产业将是一个万亿级市场&#xff0c;在宏大的趋势面前&#xff0c;没有人能视而不见&#xff0c;直播电商的未来已来。…

算法题解记录13+++杨辉三角(百日筑基)

本题是动态规划的问题&#xff0c;我也在此阐述我对动态规划的理解&#xff0c;如有不准确、缺失、错误&#xff0c;敬请斧正。 题目描述&#xff1a; 给定一个非负整数 numRows&#xff0c;生成「杨辉三角」的前 numRows 行。 在「杨辉三角」中&#xff0c;每个数是它左上方和…

Elasticsearch的使用教程

Elasticsearch简介 Elasticsearch 是一个分布式、RESTful 风格的搜索和数据分析引擎&#xff0c;能够解决不断涌现出的各种用例。作为 Elastic Stack 的核心&#xff0c;Elasticsearch 会集中存储您的数据&#xff0c;让您飞快完成搜索&#xff0c;微调相关性&#xff0c;进行…

Pytorch-张量形状操作

&#x1f606;&#x1f606;&#x1f606;感谢大家的观看&#x1f606;&#x1f606; &#x1f339; reshape 函数 transpose 和 permute 函数 view 和 contigous 函数 squeeze 和 unsqueeze 函数 在搭建网络模型时&#xff0c;掌握对张量形状的操作是非常重要的&#xff…

智慧电网数据可视化运维云平台解决方案

智慧电力概述 智慧电力是通过采用先进的大数据、云计算、物联网、边缘计算等技术&#xff0c;实现生产信息与管理信息的智慧&#xff0c;实现人、技术、经营目标和管理方法的集成&#xff0c;是企业管理思想的一个新突破。智慧电厂建设具备智能化、一体化、可观测、可互动、自…

实验一:配置IP地址

1.实验环境 主机A和主机B通过一根网线相连 2.需求描述 为两台主机配置IP地址&#xff0c;验证IP地址是否生效&#xff0c;验证 同一网段的两台主机可以互通&#xff0c;不同网段的主机不能 直接互通 3.推荐步骤 1. 为两台主机配置P地址&#xff0c;主机A为10.0.10.10&#…

python 头文件怎么写

本文主要以python2为例。首先介绍一下Python头文件的编程风格&#xff0c;然后再给大家详细介绍import部分的基本用法。这两个部分就是Python中头文件的组成模块。 编程风格 #!/usr/bin/env python #在文件头部 ( 第一行 ) 加上 设置 Python 解释器 # -*- coding: utf…

pyqt的人脸识别 基于face_recognition库

参考文献&#xff1a; 1、python face_recognition实现人脸识别系统_python facerecognition检测人脸-CSDN博客 2、cv2.VideoCapture()_cv2.videocapture(0)-CSDN博客 1、camera.py文件代码如下&#xff1b;目录如下 import sys from PyQt5.QtWidgets import QApplication, …

FTP服务器的搭建(windows)

一、开启FTP功能 1.控制面板 2.卸载程序 3. 启用或关闭windows功能 4.勾选 5.确定 二、创建登录ftp的账户 1.此电脑右击管理 三、创建FTP服务器 1.win键&#xff0c;输入iis 2.点击IIS管理器 四、测试 1.查看本机ip地址 2.打开一个文件夹&#xff0c;输入ftp://192.168.103…

UE5学习日记——实现自定义输入及监听输入,组合出不同的按键输入~

UE5的自定义按键和UE4有所不同&#xff0c;在这里记录一下。 本文主要是记录如何设置UE5的自定义按键&#xff0c;重点是学会原理&#xff0c;实际开发时结合实际情况操作。 输入映射 1. 创建输入操作 输入操作并不是具体的按键映射&#xff0c;而是按键的激活方式&#xff0…

python代码打包exe文件

创建和激活虚拟环境 创建虚拟环境 首先让我们创建一个虚拟环境。你可以使用 venv 模块来创建一个虚拟环境。以下是创建虚拟环境的步骤&#xff1a; 打开终端&#xff08;或命令提示符&#xff09;&#xff1a;进入你想要创建虚拟环境的目录。 运行以下命令来创建虚拟环境&a…

OLAP引擎优缺点简单对比

总结&#xff1a; 数据压缩率Clickhouse好&#xff1b;ClickHouse单表查询性能优势巨大&#xff1b;Join查询两者各有优劣&#xff0c;数据量小情况下Clickhouse好&#xff0c;数据量大Doris好&#xff1b;Doris对SQL支持情况要好&#xff1b;

Java集合进阶——泛型

1.泛型 介绍&#xff1a; 泛型可以在编译阶段约束操作的数据类型&#xff0c;并进行检查。 应用场景&#xff1a; 如果在定义类、方法、接口的时候&#xff0c;如果类型不确定&#xff0c;就可以使用泛型。 格式&#xff1a; <数据类型> 注意&#xff1a; 泛型只支持引…

暴力破解密码自动阻断

1 re模块 re 模块是 Python 中用于正则表达式操作的模块。正则表达式&#xff08;Regular Expression&#xff09;是一种强大的文本处理工具&#xff0c;它使用一种特殊的字符序列来表示字符串中的模式&#xff0c;并可以通过模式匹配、查找、替换等操作对文本进行高效处理。 …

springboot 使用 mybatis 快速上手

创建数据库表对应的实体类 Data public class Template {private int id;private String name;private String type;private int productId;private Timestamp createTime;private Timestamp updateTime;private Timestamp deleteTime; }创建 TemplateMapper.java Mapper pub…

Spring GA、PRE、SNAPSHOT 版本含义及区别

GA:General Availability: 正式发布的版本&#xff0c;推荐使用&#xff08;主要是稳定&#xff09;&#xff0c;与maven的releases类似&#xff1b; PRE: 预览版,内部测试版。主要是给开发人员和测试人员测试和找BUG用的&#xff0c;不建议使用&#xff1b; SNAPSHOT: 快照…

InnoDB架构:内存篇

InnoDB架构&#xff1a;内存篇 InnoDB是MySQL数据库中默认的存储引擎&#xff0c;它为数据库提供了事务安全型&#xff08;ACID兼容&#xff09;、行级锁定和外键支持等功能。InnoDB的架构设计优化了对于读取密集和写入密集型应用的性能表现&#xff0c;是一个高度优化的存储系…

# Nacos 服务发现-Spring Cloud Alibaba 综合架构实战(四) -实现 service2 子模块。

Nacos 服务发现-Spring Cloud Alibaba 综合架构实战&#xff08;四&#xff09; -实现 service2 子模块。 1、在 service2 子模块下的 service-2-api 二级子工程中&#xff0c;定义服务接口 创建 ProviderService.java /*** C:\java-test\idea2019\nacos_discovery\nacos-mi…

Python 入门指南(二)

原文&#xff1a;zh.annas-archive.org/md5/97bc15629f1b51a0671040c56db61b92 译者&#xff1a;飞龙 协议&#xff1a;CC BY-NC-SA 4.0 第三章&#xff1a;迭代和做决定 “疯狂就是一遍又一遍地做同样的事情&#xff0c;却期待不同的结果。”- 阿尔伯特爱因斯坦 在上一章中&…

k8s基础入门

前言 开始学习K8S了&#xff0c;下面就是笔记整理 简介 k8s是谷歌开源得容器管理系统&#xff0c;主要功能包括 基于容器得应用部署&#xff0c;维护和滚动升级负载均衡和服务发现跨机器和跨地区得集群调度自动伸缩无状态服务和有状态服务广泛得Volume支持插件保持扩展性 …