JRT1.7连仪器在线演示视频
JRT1.5实现质控主体、1.6基本完成质控;本次版本推进到1.7,1.7集菜单权限、登录、打印导出客户端、初始化、质控、Linux客户端、仪器连接和监控体系各种功能大全,上十年写系统用到的都全了。
这次直接挑战检验最难类型的仪器连接(西比亚蛋白电泳、固定电泳、尿蛋白电泳),同时实现Linux上连接和TCP连接,充分验证仪器连接的可靠性。西比亚的难点有数据解析、有绘图。借助仪器连接同时展示了JRT业务脚本化的在应对修改的优越性。
设计理想在JRT下一一实现。
西比亚数据
P0001 000 00000g/dl TS 2201202410β2微球蛋白 溶菌酶 视黄醇结合蛋白 游离轻链 α1微球蛋白 游离轻链二聚体 白蛋白 转铁蛋白 IgG&IgA 结合珠蛋白 010.8009.2006.8005.5004.9028.1007.3004.9011.0011.500000000000000000000000000000000000000000000000000 000.0000.0000.0000.000000000000000000000000.0001.00 000300A0100000000000000000000000000000000008005000800A500CC00B6007C004200290016000E000B000C000C000C000C000B000900070004000400BF01E2034D03EE03E8038202BF01F3C1210149021A033B036702B701DE0161416F014F012300C500830055004700430039002B001A0011000B000800050003000180000000000100040007000B000E00110028007C00E30134011100F100F201360153011500BA00620048005D00AD0105012C00FF00AD00610036001E0010000A00060004000300050007000900070004800100010002000300030002000100010003000500060007004100E801AE023201DB014900BC00B800D800F400CD0090004E002F001BC011003E008D00ED00FE00CE0081004A00310024003B006A00A400AE008D005A003500220016001B004E009100CD00BB008A004C002D001D001500120011001300140012800E00120040011B0243037B04BD075F0A3A0C040A1806FD03B70251018C013D00EA00A0005A003780240039009E015C021E02BC02D102B80212017500CA00760044002A001B0011000A00050002800200020006004C00D6017701B6016B012301040134011B00D90080004700290018000D000700038002000200040006001700380066009900B100B7008E00650072015A028B039F03340257013300BA0067003C00210013000D004A00BF014D0186014600DB0073004500250015000C0008000500030001800100020004000500050003000200040009000D000D000A000800080008000B0034007200B800BA00940059004C006D00A700FE013D0171014700F70091004F002D0019000F000A00070056016702C003CB03670279015500C700088002|**
仪器接口代码片段
仪器控制界面后台
import JRT.Core.MultiPlatform.JRTContext;
import JRT.Core.Socket.MachManager;
import JRT.Core.Util.Convert;
import JRT.Model.Entity.BTMIMachineParameter;
import JRT.Model.Entity.BTWorkGroup;
import JRT.Model.Entity.BTWorkGroupMachine;
import JRTBLLBase.BaseHttpHandler;
import JRTBLLBase.Helper;import java.util.ArrayList;
import java.util.List;/*** 仪器控制界面的后台逻辑*/
public class ashMachineControl extends BaseHttpHandler {/*** 查询仪器* @return* @throws Exception*/public String QueryMachine() throws Exception{String FindAll = Helper.ValidParam(JRTContext.GetRequest(Request, "FindAll"), "");//考虑仪器不多,直接查询全部List<BTMIMachineParameterDto> allMachine=EntityManager().FindAllSimple(BTMIMachineParameterDto.class,null);List<BTMIMachineParameterDto> retList=new ArrayList<>();if(allMachine!=null&&allMachine.size()>0){for(BTMIMachineParameterDto one : allMachine){//查当前工作组的仪器if(FindAll.equals("0")){BTWorkGroupMachine wgm=EntityManager().DolerGet(BTWorkGroupMachine.class,one.WorkGroupMachineDR);BTWorkGroup wg=EntityManager().DolerGet(BTWorkGroup.class,wgm.WorkGroupDR);if(wg.RowID!= Convert.ToInt32(UserLogin().GroupID)){continue;}}//有端口的才是TCP仪器if(one.PortNo!=null&&!one.PortNo.isEmpty()){if(one.IPAddress!=null&&!one.IPAddress.isEmpty()){one.TcpType="客户端";}else{one.TcpType="服务端";}BTWorkGroupMachine wgm=EntityManager().DolerGet(BTWorkGroupMachine.class,one.WorkGroupMachineDR);one.WorkGroupMachineName=wgm.CName;retList.add(one);}}}return Helper.Object2Json(retList);}/*** 启动仪器* @return*/public String StartMachine() throws Exception{int MachineDR = Helper.ValidParam(JRTContext.GetRequest(Request, "MachineDR"), 0);BTMIMachineParameter machDto=EntityManager().DolerGet(BTMIMachineParameter.class,MachineDR);String err=(String) Helper.GetBllMethodData(machDto.IFProgram,"Start",MachineDR);if(!err.isEmpty()){machDto.IsStart=false;machDto.OpMessage="启动失败";return Helper.Error(err);}else{machDto.IsStart=true;machDto.OpMessage="启动成功:"+Helper.GetNowDateStr()+" "+Helper.GetNowTimeStr();}EntityManager().Update(machDto,ErrRet(),null);return Helper.Success();}/*** 停止仪器* @return*/public String StopMachine() throws Exception{int MachineDR = Helper.ValidParam(JRTContext.GetRequest(Request, "MachineDR"), 0);BTMIMachineParameter machDto=EntityManager().DolerGet(BTMIMachineParameter.class,MachineDR);String err=MachManager.StopMachSocketByKey(String.valueOf(MachineDR));if(!err.isEmpty()){machDto.OpMessage="停止失败";return Helper.Error(err);}else{machDto.IsStart=false;machDto.OpMessage="停止成功:"+Helper.GetNowDateStr()+" "+Helper.GetNowTimeStr();}EntityManager().Update(machDto,ErrRet(),null);return Helper.Success();}/*** 返回实体*/public static class BTMIMachineParameterDto extends BTMIMachineParameter{/*** TCP连接类型*/public String TcpType="";/*** 工作小组*/public String WorkGroupMachineName="";}
}
仪器控制界面前端
<!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/ashMachineControl.ashx'};//jquery入口$(function () {//查询范围$('#cmbFindAll').combobox({data:[{RowID:"0",CName:"当前工作组"},{RowID:"1",CName:"全部仪器"}],valueField:'RowID',textField:'CName'});$('#cmbFindAll').combobox("setValue","0");//查询$("#btnSelect").click(function () {SelectMachine();});//启动仪器$("#btnStart").click(function () {var selectRow=$('#dgData').datagrid("getSelected");if(selectRow==null){$.messager.alert('提示','请选择一个仪器');return;}$.ajax({type: "POST",dataType: "json", //text, json, xmlcache: false, //async: true, //为true时,异步,不等待后台返回值,为false时强制等待;-asirurl: me.actionUrl + '?Method=StartMachine',data:{MachineDR:selectRow.RowID},success: function (result, status) {SelectMachine();}});});//停止仪器$("#btnStop").click(function () {var selectRow=$('#dgData').datagrid("getSelected");if(selectRow==null){$.messager.alert('提示','请选择一个仪器');return;}$.ajax({type: "POST",dataType: "json", //text, json, xmlcache: false, //async: true, //为true时,异步,不等待后台返回值,为false时强制等待;-asirurl: me.actionUrl + '?Method=StopMachine',data:{MachineDR:selectRow.RowID},success: function (result, status) {SelectMachine();}});});//仪器$('#dgData').datagrid({singleSelect:true,fitColumns:true,columns:[[{ field: 'RowID', title: TranslateDataMTHD('RowID', '主键', '') , width: 40, sortable: true },{ field: 'Code', title: TranslateDataMTHD('Code', '代码', '') , width: 60, sortable: true },{ field: 'CName', title: TranslateDataMTHD('CName', '名称', '') , width: 150, sortable: true },{ field: 'WorkGroupMachineName', title: TranslateDataMTHD('WorkGroupMachineName', '工作小组', '') , width: 150, sortable: true },{ field: 'IPAddress', title: TranslateDataMTHD('IPAddress', 'IP地址', '') , width: 120, sortable: true },{ field: 'PortNo', title: TranslateDataMTHD('PortNo', '端口号', '') , width: 60, sortable: true },{ field: 'TcpType', title: TranslateDataMTHD('TcpType', 'Tcp类型', '') , width: 60, sortable: true },{ field: 'IFProgram', title: TranslateDataMTHD('IFProgram', '接口程序', '') , width: 180, sortable: true },{ field: 'Sequence', title: TranslateDataMTHD('Sequence', '序号', '') , width: 50, sortable: true },{ field: 'Active', title: TranslateDataMTHD('Active', '状态', '') , width: 50, sortable: true },{ field: 'IsStart', title: TranslateDataMTHD('IsStart', '启动', '') , width: 50, sortable: true,formatter: function (value, rowData, rowIndex) {return rowData.IsStart == true ? '<img src="../../resource/common/images/active.png" alt="激活" title="激活"/>' : '<img src="../../resource/common/images/cross.png" alt="未激活" title="未激活"/>';}},{ field: 'OpMessage', title: TranslateDataMTHD('OpMessage', '操作信息', '') , width: 150, sortable: true },{ field: 'ComPort', title: TranslateDataMTHD('ComPort', '串口号', '') , width: 60, sortable: true },{ field: 'BaudRate', title: TranslateDataMTHD('BaudRate', '波特率', '') , width: 60, sortable: true },{ field: 'DataBits', title: TranslateDataMTHD('DataBits', '数据位', '') , width: 60, sortable: true },{ field: 'StopBits', title: TranslateDataMTHD('StopBits', '停止位', '') , width: 60, sortable: true },{ field: 'Parity', title: TranslateDataMTHD('Parity', '校验位', '') , width: 60, sortable: true },]]});//查询仪器function SelectMachine() {$.ajax({type: "POST",dataType: "json", //text, json, xmlcache: false, //async: true, //为true时,异步,不等待后台返回值,为false时强制等待;-asirurl: me.actionUrl + '?Method=QueryMachine',data:{FindAll:$('#cmbFindAll').combobox("getValue")},success: function (result, status) {//工作组$("#dgData").datagrid("loadData", result);}});}SelectMachine();});</script>
</head>
<body>
<div class="easyui-layout" fit="true"><div data-options="region:'north',title:'',split:true" style="height:48px;padding: 5px 0 0 10px;"><span>查询范围</span><span class="jrtsp6"></span><input id="cmbFindAll" style="width: 120px;"/><span class="jrtsp"></span><a id="btnSelect" href="#" class="easyui-linkbutton">查询</a><a id="btnStart" href="#" class="easyui-linkbutton">启动</a><a id="btnStop" href="#" class="easyui-linkbutton">停止</a></div><div data-options="region:'center',title:''" style="border: none;"><table id="dgData" fit="true"></table></div>
</div>
</body>
</html>
仪器数据监控界面
<!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/ashMachineDataMonitor.ashx'};//jquery入口$(function () {//查询$("#btnSelect").click(function () {var MachineDR=$("#cmbMachine").combogrid("getValue");if(MachineDR==null||MachineDR==""){$.messager.alert('提示','请选择一个仪器');return;}$.ajax({type: "POST",dataType: "json", //text, json, xmlcache: false, //async: true, //为true时,异步,不等待后台返回值,为false时强制等待;-asirurl: me.actionUrl + '?Method=QueryTraceData&MachineDR='+MachineDR,success: function (result, status) {$('#dgData').datagrid("loadData",result);}});});//清空$("#btnClear").click(function () {var MachineDR=$("#cmbMachine").combogrid("getValue");if(MachineDR==null||MachineDR==""){$.messager.alert('提示','请选择一个仪器');return;}$.ajax({type: "POST",dataType: "json", //text, json, xmlcache: false, //async: true, //为true时,异步,不等待后台返回值,为false时强制等待;-asirurl: me.actionUrl + '?Method=ClearTraceData&MachineDR='+MachineDR,success: function (result, status) {//对数据进行筛选,是后台抛的信息的话,就提示,以及决定是否继续if (!FilterBackData(result)) {return;}if (result.IsOk) {$('#dgData').datagrid("loadData",[]);}}});});//查看传输$("#btnSelectTrans").click(function () {var MachineDR=$("#cmbMachine").combogrid("getValue");if(MachineDR==null||MachineDR==""){$.messager.alert('提示','请选择一个仪器');return;}showwin("#winCommon", TranslateDataMTHD('Machine Extract', '查看传输数据', ""), SYSSessionURL("frmRPMachineExtract.html?MachineID=" + MachineDR), $(document).width() - 130, 690, true, "10px");});//查看图片$("#btnSelectImage").click(function () {var MachineDR=$("#cmbMachine").combogrid("getValue");if(MachineDR==null||MachineDR==""){$.messager.alert('提示','请选择一个仪器');return;}showwin("#winCommon", TranslateDataMTHD('Machine Image', '仪器图片', ""), SYSSessionURL("frmRPMachineImage.html?MachineID=" + MachineDR), $(document).width() - 130, 690, true, "10px");});//仪器结果$("#btnMachineRes").click(function () {var MachineDR=$("#cmbMachine").combogrid("getValue");if(MachineDR==null||MachineDR==""){$.messager.alert('提示','请选择一个仪器');return;}showwin("#winCommon", TranslateDataMTHD('Machine Result', '仪器结果', ""), SYSSessionURL("frmRPMachineResult.html?MachineID=" + MachineDR), $(document).width() - 130, 690, true, "10px");});//工作组$("#cmbWG").combogrid({width: 160,idField: 'WorkGroupDR',textField: 'WorkGroupName',method: 'get',editable: false,columns:[[{field:'WorkGroupName',title:'名称',width:140}]],onSelect: function (date) {me.cmbMach.combobox("setValue","")QueryMachData();}});$("#cmbWG").combogrid("showSelectWin");//仪器$("#cmbMachine").combogrid({width: 160,panelWidth:260,idField: 'RowID',textField: 'CName',method: 'get',editable: true,columns:[[{field:'RowID',title:'主键',width:40},{field:'Code',title:'代码',width:60},{field:'CName',title:'名称',width:140}]],onSelect: function (data) {}});$("#cmbMachine").combogrid("showSelectWin");//请求工作组数据,并设置默认选项$.ajax({type: "POST",dataType: "json", //text, json, xmlcache: false, //async: true, //为true时,异步,不等待后台返回值,为false时强制等待;-asirurl: me.actionUrl + '?Method=QueryWorkGroupData',success: function (result, status) {//工作组$("#cmbWG").combogrid("grid").datagrid("loadData", result);}});//查询仪器数据function QueryMachData(){$.ajax({type: "POST",dataType: "json", //text, json, xmlcache: false, //async: true, //为true时,异步,不等待后台返回值,为false时强制等待;-asirurl: me.actionUrl + '?Method=QryMachineParameter&WorkGroupDR='+$("#cmbWG").combogrid("getValue"),success: function (result, status) {//仪器$("#cmbMachine").combogrid("grid").datagrid("loadData", result);}});}QueryMachData();$('#dgData').datagrid({fitColumns:true,columns:[[{field:'Seq',title:'序号',width:50,fixed:true},{field:'Data',title:'日志',width:100}]]});});</script>
</head>
<body>
<div class="easyui-layout" fit="true"><div data-options="region:'north',title:'',split:true" style="height:48px;padding: 5px 0 0 10px;"><span>工作组</span><span class="jrtsp6"></span><input id="cmbWG" style="width: 120px;"/><span class="jrtsp"></span><span>仪器</span><input id="cmbMachine" style="width:120px;"/><span class="jrtsp6"></span><a id="btnSelect" href="#" class="easyui-linkbutton">查询</a><a id="btnClear" href="#" class="easyui-linkbutton">清空</a><a id="btnSelectTrans" href="#" class="easyui-linkbutton">查看传输</a><a id="btnSelectImage" href="#" class="easyui-linkbutton">查看图片</a><a id="btnMachineRes" href="#" class="easyui-linkbutton">仪器结果</a></div><div data-options="region:'center',title:''" style="border: none;"><table id="dgData" fit="true"></table></div><div id="winCommon"></div>
</div>
</body>
</html>
仪器数据监控后台
import JRT.Core.Debug.TraceManager;
import JRT.Core.Debug.TraceQueue;
import JRT.Core.MultiPlatform.JRTContext;
import JRT.Core.Util.Convert;
import JRT.Model.Entity.BTMIMachineParameter;
import JRT.Model.Entity.BTWorkGroup;
import JRT.Model.Entity.BTWorkGroupMachine;
import JRT.Model.Entity.SYSUserRole;
import JRTBLLBase.BaseHttpHandler;
import JRTBLLBase.Helper;import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;public class ashMachineDataMonitor extends BaseHttpHandler {/*** 查询工作组数据** @return*/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<BTMIMachineParameter> retList = new ArrayList<>();String [] arr=UserLogin().SessionStr.split("\\^");String hospitalDR=arr[4];//查询工作小组下的所有仪器List<BTMIMachineParameter> machList = EntityManager().FindByColVal(BTMIMachineParameter.class, "HospitalDR", Convert.ToInt32(hospitalDR));for (BTMIMachineParameter mi : machList) {BTWorkGroupMachine wgm=EntityManager().DolerGet(BTWorkGroupMachine.class,mi.WorkGroupMachineDR);BTWorkGroup wg=EntityManager().DolerGet(BTWorkGroup.class,wgm.WorkGroupDR);if(WorkGroupDR>0&&wg.RowID!=WorkGroupDR){continue;}retList.add(mi);}return Helper.Object2Json(retList);}/*** 清空跟踪日志* @return* @throws Exception*/public String ClearTraceData() throws Exception {String MachineDR = Helper.ValidParam(JRTContext.GetRequest(Request, "MachineDR"), "");TraceQueue trace = TraceManager.GetTraceHandler(MachineDR, -1);trace.Clear();return Helper.Success();}/*** 查询日志数据* @return*/public String QueryTraceData() throws Exception{String MachineDR = Helper.ValidParam(JRTContext.GetRequest(Request, "MachineDR"), "");TraceQueue trace = TraceManager.GetTraceHandler(MachineDR, -1);List<String> logList=trace.GetTraceData();List<HashMap> retList=new ArrayList<>();if(logList!=null&&logList.size()>0){int Seq=0;for(String one:logList){Seq++;HashMap hs=new HashMap();hs.put("Data",one);hs.put("Seq",Seq);retList.add(hs);}}return Helper.Object2Json(retList);}/*** 角色查询实体*/public static class SYSUserRoleDto extends SYSUserRole {//工作组名称public String WorkGroupName="";//当前工作组public String CurWorkGroupDR="";}
}
TCP仪器接口代码
import JRT.Core.Dto.OutValue;
import JRT.Core.Socket.IMachDealData;
import JRT.Core.Socket.MachSocketBase;
import JRT.Core.Util.Convert;
import JRT.Model.Bussiness.Parameters;
import JRT.Model.Entity.BTMIMachineParameter;
import JRTBLLBase.BaseHttpHandlerMachine;
import JRTBLLBase.Helper;import java.io.PrintWriter;
import java.net.Socket;/*** 南比亚TCP仪器接口*/
public class miNanBia extends BaseHttpHandlerMachine implements IMachDealData {/*** 启动仪器控制* @param mi 仪器* @return 空或失败原因*/public String Start(int mi){try {BTMIMachineParameter machDto = EntityManager().DolerGet(BTMIMachineParameter.class, mi);MachSocketBase base=JRT.Core.Socket.MachManager.GetMachSocketBase(machDto.IPAddress, Convert.ToInt32(machDto.PortNo),Long.valueOf(5000),this,"GBK",String.valueOf(mi));}catch (Exception ex){Trace(String.valueOf(mi),Helper.GetExceptionStr(ex),"H->M");return Helper.GetExceptionStr(ex);}return "";}/*** 处理上传定时器接口* @param sender Socket对象,用来发送比特用* @param writer 用来发布初始化指定的字符用* @param mi 仪器主键*/public void DealUpTimer(Socket sender, PrintWriter writer,String mi){try {if(writer!=null) {String sendStr = "H->M:我主动定时给你推送的数据</br>";//返回数据writer.print(sendStr);writer.flush();Trace(mi, sendStr, "H->M");}}catch (Exception ex){Trace(mi,Helper.GetExceptionStr(ex),"H->M");}}/*** 处理数据接收* @param data 公共层处理成字符串的数据* @param buf 没处理的比特数组* @param sender Socket对象,用来发送比特用* @param writer 用来发布初始化指定的字符用* @param mi 仪器主键*/public void DealReceive(String data, byte[] buf, Socket sender, PrintWriter writer,String mi){try {Parameters para = new Parameters();para.P0 = mi;para.P1 = data;para.P2 = "";para.P3 = "";para.P4 = "";OutValue session = new OutValue();OutValue outPut = new OutValue();writer.print("ACK");writer.flush();Trace(mi,"ACK","H->M");//调用处理文件的逻辑String ret=(String)Helper.GetBllMethodData("mi.miSebia", "SaveData", para, session, outPut);Trace(mi,ret,"返回");}catch (Exception ex){Trace(mi,Helper.GetExceptionStr(ex),"M->H");}}
}
解落三秋叶
能开二月花
过江千尺浪
入竹万竿斜
为了梦想十年如一日的推进进度
2024-05-26 小乌鱼