得益于前期的基础投入,借助代码生成的加持,本来计划用一周实现质控物维护界面,实际用来四小时左右完成质控物维护主体,效率大大超过预期。
JRT从设计之初就是为了证明Spring打包模式不适合软件服务模式,觉得Spring打包模式开发效率太低、维护不现实、做不到分钟级别的需求响应。从开发环境、部署、脚本化、码表、代码生成、打印导出都用java实现等都是优秀考虑的效率。
质控物是下面这个界面,涉及增删改数据9个表,查树三个表,工作量自己估计,别看表多,增删改查的功能点多,基于JRT、实际写的代码不多,都是用生成代码加级联查询组装的。
代码结构,没多余概念,只有界面和后台
主体后台-可以看后台了解JRT推荐的业务范式
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",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]);
//删除质控浓度
EntityManager().RemoveByColVal(BTQCMaterialLevel.class, "MaterialDR", id);
//删除质控标识
EntityManager().RemoveByColVal(BTQCMachineQC.class, "MaterialDR", id);
//删除质控规则
EntityManager().RemoveByColVal(BTQCMaterialRules.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);
}
}
/**
* 删除数据,多个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<>();
if(dataList!=null&&dataList.size()>0)
{
for(BTQCMaterialTestCodeDto 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);
}
/**
* 查询能够开通的项目或者已经开通的项目
* @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;
}
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;
int ret=EntityManager().Save(dto,key,ErrRet());
if(ret!=1)
{
throw new Exception(Err.GetString());
}
}
return Helper.Success();
}
/**
* 查询数据,前台按表的属性名提交
* @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;
}
}
主体界面代码太多,博客放不下,放个质控规则维护的界面前端,前后台交互通过ajax
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>质控规则维护</title>
<link rel="shortcut icon" href="../../resource/common/images/favicon.ico" />
<script src="../../resource/common/js/JRTBSBase.js" type="text/javascript"></script>
<link href="../../resource/plug/spectrum/css/spectrum.css" rel="stylesheet" type="text/css" />
<script src="../../resource/plug/spectrum/js/spectrum.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
SYSPageCommonInfo.Init();
var BasePath = '';
var ResourcePath = '';
var WebServicAddress = SYSPageCommonInfo.Data.WebServicAddress;
var UserID = SYSPageCommonInfo.Data.Sesssion.UserID;
var GroupID = SYSPageCommonInfo.Data.Sesssion.GroupID;
var SessionStr = SYSPageCommonInfo.Data.SessionStr;
</script>
<script type="text/javascript">
//全局变量
var me = {
actionUrl: '../ashx/ashBTQCRules.ashx'
};
//jquery入口
$(function () {
//规则颜色
$("#txtBTQCRulesColor").spectrum({
showInput: true,
showPalette: true,
color: "",
cancelText:"取消",
chooseText:"选择",
clearText:"清空选择",
palette: [
["#333333", "#449be2", "#50b90c", "#39c6c8", "afd17e", "#A85B93"],
["#FFD572", "#ff32a1", "#d952d1", "#9152d9", "#494dee", "#327eb2"],
["#f3723b", "#21be97", "#2ab66a", "#aade5f", "#ffb746", "#ff793e"],
["#ff5252", "#f16e57", "#fd930c", "#d07605", "#955606", "#8be451"],
["#ec90da", "#338001", "#fda632", "#0670c6", "#135890", "#afd17e"],
["#c00eb5", "#891082", "#7dba56", "#f4d44f", "#6abfef", "c0c0c0"]
]
});
//质控状态
$("#txtBTQCRulesStatus").combogrid({
panelWidth: 350,
idField: 'RowID',
width: 205,
textField: 'CName',
data:[
{
RowID:"W",
CName:"警告"
},
{
RowID:"R",
CName:"失控"
}
],
columns: [[
{ field: 'RowID', title: '主键', width: 60 },
{ field: 'CName', title: '名称', width: 260 }
]]
});
//新增数据点击
$("#btnAddBTQCRules").click(function () {
$("#txtBTQCRulesRowID").val("");
$('#winEditBTQCRules').window({
title: TranslateDataMTHD('Add Data', '新增数据', ''),
modal: true
});
});
//修改数据点击
$("#btnUpdateBTQCRules").click(function () {
UpdateBTQCRules();
});
//修改数据
function UpdateBTQCRules(row)
{
var selectRow = $('#dgBTQCRules').datagrid("getSelected");
if(row!=null)
{
selectRow=row;
}
if (selectRow == null) {
$.messager.alert(TranslateDataMTHD('Info', '提示', ''), TranslateDataMTHD('Please select the data to modify', '请选择要修改的数据!', ''), 'info');
return;
}
$("#formBTQCRules").form('load', selectRow);
$("#txtBTQCRulesColor").spectrum("set",selectRow.Color);
$('#winEditBTQCRules').window({
title: TranslateDataMTHD('Update Data', '修改数据', ''),
modal: true
});
}
//删除数据点击
$("#btnDeleteBTQCRules").click(function () {
var checkRow = $('#dgBTQCRules').datagrid("getChecked");
var selectRow = $('#dgBTQCRules').datagrid("getSelected");
if ((checkRow == null || checkRow.length == 0)&&selectRow==null) {
$.messager.alert(TranslateDataMTHD('Info', '提示', ''), TranslateDataMTHD('Please select the data to delete', '请勾选要删除的数据!', ''), 'info');
return;
}
if ((checkRow == null || checkRow.length == 0)) {
checkRow=[selectRow];
}
var RowIDS = "";
for (var i = 0; i < checkRow.length; i++) {
if (i == 0) {
RowIDS = checkRow[i].RowID;
}
else {
RowIDS += "^" + checkRow[i].RowID;
}
}
$.messager.confirm(TranslateDataMTHD('Info', '提示', ''), TranslateDataMTHD('Do you want to delete the selected data', '是否要删除选择的数据?', '') , function (r) {
if (r) {
//开启等待
$.messager.progress({ text: TranslateDataMTHD("Deleting data","正在删除数据", ""), interval: 500 });
setTimeout(function () {
$.messager.progress('close');
}, 8000);
//往后台提交数据
$.ajax({
type: "post",
dataType: "json",
cache: false, //
async: true, //为true时,异步,不等待后台返回值,为false时强制等待;-asir
url: me.actionUrl + '?Method=DeleteBTQCRules',
data: { RowIDS: RowIDS },
success: function (data, status) {
$.messager.progress('close');
if (!FilterBackData(data)) {
return;
}
if (!data.IsOk) {
$.messager.alert(TranslateDataMTHD("Error message", "错误提示", ""), TranslateDataMTHD("failed to dalete data, error message:", "删除失败,错误信息:", "") + data.Message);
}
else {
QryBTQCRules();
$.messager.show({
title: TranslateDataMTHD("Info", "提示", ""),
msg: TranslateDataMTHD("Successfully deleted!", "删除成功!", ""),
timeout: 500,
showType: 'slide'
});
}
}
});
}
});
});
//保存数据
$("#btnSaveBTQCRules").click(function () {
var saveData = jQuery.parseJSON($("#formBTQCRules").serializeObject());
var Color = $("#txtBTQCRulesColor").spectrum('get').toHexString();
saveData.Color=Color;
//开启等待
$.messager.progress({ text: TranslateDataMTHD("Saving data","正在保存数据", ""), interval: 500 });
setTimeout(function () {
$.messager.progress('close');
}, 8000);
//往后台提交数据
$.ajax({
type: "post",
dataType: "json",
cache: false, //
async: true, //为true时,异步,不等待后台返回值,为false时强制等待;-asir
url: me.actionUrl + '?Method=SaveBTQCRules',
data: saveData,
success: function (data, status) {
$.messager.progress('close');
if (!FilterBackData(data)) {
return;
}
if (!data.IsOk) {
$.messager.alert(TranslateDataMTHD("Error message", "错误提示", ""), TranslateDataMTHD("failed to dalete data, error message:", "删除失败,错误信息:", "") + data.Message);
}
else {
QryBTQCRules();
$.messager.show({
title: TranslateDataMTHD("Info", "提示", ""),
msg: TranslateDataMTHD("Successfully saveed!", "保存成功!", ""),
timeout: 500,
showType: 'slide'
});
$('#winEditBTQCRules').window("close");
}
}
});
});
//关闭窗口
$("#btnCloseBTQCRules").click(function () {
$('#winEditBTQCRules').window("close");
});
//构造查询事件
$("#txtFilterBTQCRules").searchbox({
searcher: function (value, name) {
QryBTQCRules();
},
prompt: TranslateDataMTHD('Enter query', '回车查询', '')
});
//激活布尔渲染
$('#txtBTQCRulesActive').combobox({
valueField:'RowID',
textField:'CName',
width: 205,
data: [{"RowID":false,"CName":TranslateDataMTHD('No', '否', '')},{"RowID":true,"CName":TranslateDataMTHD('Yes', '是', '')}]
});
//BTQCRules表格
$('#dgBTQCRules').datagrid({
remoteSort:false,
singleSelect: true,
toolbar: "#dgBTQCRulesToolBar",
fit: true,
onSelect: function (index, row) {
//方便拷贝到子表查询用
var selectBTQCRules=$('#dgBTQCRules').datagrid("getSelected");
},
onDblClickRow: function (index, row) {
UpdateBTQCRules(row);
},
columns: [[
{ field: 'ChkFlag', title: TranslateDataMTHD('Check', '选择', ''), width: 20, sortable: true, align: 'center', checkbox: true },
{ field: 'RowID', title: TranslateDataMTHD('RowID', '主键', '') , width: 50, sortable: true },
{ field: 'Code', title: TranslateDataMTHD('Code', '代码', '') , width: 60, sortable: true },
{ field: 'CName', title: TranslateDataMTHD('CName', '名称', '') , width: 120, sortable: true },
{ field: 'Status', title: TranslateDataMTHD('Status', '状态', '') , width: 80, sortable: true },
{ field: 'Color', title: TranslateDataMTHD('Color', '颜色', '') , width: 80, sortable: true,
formatter: function (value, rowData, rowIndex) {
if (value == "") {
var LevelNoIndex = rowData.LevelNo - 1;
value = AllLineColor[LevelNoIndex];
}
return '<span style="color:' + value + ';font-weight:bold;">' + TranslateDataMTHD('Color', '颜色', "") + '</span>'
}
},
{ field: 'Remark', title: TranslateDataMTHD('Remark', '说明', '') , width: 650, sortable: true },
{ field: 'Sequence', title: TranslateDataMTHD('Sequence', '序号', '') , width: 60, sortable: true },
{ field: 'Active', title: TranslateDataMTHD('Active', '激活', '') , width: 60, sortable: true,
formatter: function (value, rowData, rowIndex) {
return rowData.Active == true ? '<img src="../images/icon/active.png" alt="激活" title="激活"/>' : '<img src="../images/icon/cross.png" alt="未激活" title="未激活"/>';
}
}
]]
});
//查询BTQCRules
function QryBTQCRules() {
var Filter = $("#txtFilterBTQCRules").searchbox("getValue");
//开启等待,默认注释,在单击事件调用的逻辑启用等待会冲掉双击事件,按需要开启
//$.messager.progress({ text: TranslateDataMTHD("Querying data","正在查询数据", ""), interval: 500 });
//setTimeout(function () {
//$.messager.progress('close');
//}, 8000);
$.ajax({
type: "post",
dataType: "json",
cache: false, //
async: true, //为true时,异步,不等待后台返回值,为false时强制等待;-asir
url: me.actionUrl + '?Method=QryBTQCRules',
data: { Filter: Filter },
success: function (data, status) {
//结束等待
//$.messager.progress('close');
if (!FilterBackData(data)) {
return;
}
$('#dgBTQCRules').datagrid("loadData", data);
}
});
};
//执行查询数据
QryBTQCRules();
});
</script>
</head>
<body>
<div class="easyui-layout" fit="true" style="border: none;">
<div data-options="region:'center',title:''" style="border: none;">
<div id="dgBTQCRulesToolBar" style="padding: 3px 0px 3px 10px;">
<a id="btnAddBTQCRules" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-add'" plain="true" listranslate="html~Add">新增</a>
<a id="btnUpdateBTQCRules" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-write-order'" plain="true" listranslate="html~Mod">修改</a>
<a id="btnDeleteBTQCRules" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" plain="true" listranslate="html~Del">删除</a>
<input id="txtFilterBTQCRules" style="margin-left: 14px; width: 240px;"></input>
</div>
<table id="dgBTQCRules" title="" iconcls="icon-paper" listranslate="title~BTQCRules"></table>
</div>
<div id="winEditBTQCRules" style="padding: 10px 0px 0px 10px;width:550px;height:318px;display: none;">
<form id="formBTQCRules" name="edit_form" method="post">
<input type="hidden" id="txtBTQCRulesRowID" name="RowID" value="0" />
<table>
<tr>
<td class="lisar" jrttranslate="html~Code">代码</td>
<td class="lisal"><input id="txtBTQCRulesCode" type="text" name="Code" style="width:200px;" class="easyui-validatebox" maxlength="10"/></td>
<td class="lisar" jrttranslate="html~CName">名称</td>
<td class="lisal"><input id="txtBTQCRulesCName" type="text" name="CName" style="width:200px;" class="easyui-validatebox" maxlength="40"/></td>
</tr>
<tr>
<td class="lisar" jrttranslate="html~Status">状态</td>
<td class="lisal"><input id="txtBTQCRulesStatus" type="text" name="Status" style="width:200px;" class="easyui-validatebox" maxlength="1"/></td>
<td class="lisar" jrttranslate="html~Color">颜色</td>
<td class="lisal"><input id="txtBTQCRulesColor" type="text" name="Color" style="width:200px;" class="easyui-validatebox" maxlength="10"/></td>
</tr>
<tr>
<td class="lisar" jrttranslate="html~Remark">说明</td>
<td class="lisal" colspan="3">
<textarea id="txtBTQCRulesRemark" name="Remark" style="width:460px;height: 90px; resize: none;" rows="3" class="easyui-validatebox" maxlength="200" cols="40" ></textarea>
</td>
</tr>
<tr>
<td class="lisar" jrttranslate="html~Sequence">序号</td>
<td class="lisal"><input id="txtBTQCRulesSequence" type="text" name="Sequence" style="width:200px;" class="easyui-validatebox" maxlength="10"/></td>
<td class="lisar" jrttranslate="html~Active">激活</td>
<td class="lisal"><input id="txtBTQCRulesActive" type="text" name="Active" style="width:200px;" class="easyui-validatebox" maxlength="1"/></td>
</tr>
</table>
<div region="south" border="fale" style="text-align: center; padding: 5px 0 0;">
<a id="btnSaveBTQCRules" href="#" class="easyui-linkbutton" plain="false" listranslate="html~Save">保存</a>
<span class="sp6"></span>
<a id="btnCloseBTQCRules" href="#" class="easyui-linkbutton" plain="false" listranslate="html~Cancel">取消</a>
</div>
</form>
</div>
</div>
</body>
</html>