@@ -37,6 +37,10 @@ namespace Rdh.SocketServer.Client.Models | |||
/// </summary> | |||
public const String RequestDrugLend = "0G"; | |||
/// <summary> | |||
/// 药箱开始手术取药 | |||
/// </summary> | |||
public const String RequestStartPatientOperation = "0H"; | |||
/// <summary> | |||
/// 药箱同步时钟 | |||
/// </summary> | |||
public const String RequestClock = "TT"; |
@@ -10,6 +10,9 @@ namespace Rdh.SocketServer.Client.Models | |||
public abstract class BaseEleMedKitProtocol | |||
{ | |||
public virtual string? Command { get; set; } | |||
/// <summary> | |||
/// 获取或设置数据的最小行数 | |||
/// </summary> | |||
public virtual int MinLines { get; set; } = 1; | |||
public virtual string AddLineContent(string? line) | |||
{ | |||
@@ -47,6 +50,11 @@ namespace Rdh.SocketServer.Client.Models | |||
return builder.ToString(); | |||
} | |||
public abstract string GetContent(); | |||
/// <summary> | |||
/// 检验数据行并进行解析 | |||
/// </summary> | |||
/// <param name="lines"></param> | |||
/// <returns>是否检验成功</returns> | |||
public virtual bool ParseContent(string[] lines) | |||
{ | |||
if (lines == null || lines.Length < 1) |
@@ -11,10 +11,22 @@ namespace Rdh.SocketServer.Client.Models | |||
public const string Start = "*"; | |||
public const string LineStart = "#"; | |||
public const string LineEnd = "\r\n"; | |||
/// <summary> | |||
/// 行内分隔符 | |||
/// </summary> | |||
public const string BlockSpiltor = "|"; | |||
/// <summary> | |||
/// 行分割符 | |||
/// </summary> | |||
public const string LineSpiltor = "<>"; | |||
/// <summary> | |||
/// 数字边补符 | |||
/// </summary> | |||
public const string LinePad = "0"; | |||
public const string End = "@"; | |||
/// <summary> | |||
/// 数字边补长度 | |||
/// </summary> | |||
public const int LinePadTotalLenght = 3; | |||
} | |||
} |
@@ -0,0 +1,40 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace Rdh.SocketServer.Client.Models | |||
{ | |||
/// <summary> | |||
/// 表示药箱开启手术用药的请求的协议类 | |||
/// </summary> | |||
public class RequestStartPatientOperationProtocol : EleMedKitProtocol | |||
{ | |||
public RequestStartPatientOperationProtocol() | |||
{ | |||
base.Command = EleMedKitCommand.RequestStartPatientOperation; | |||
MinLines = 4; | |||
} | |||
/// <summary> | |||
/// 获取或设置基站编号 | |||
/// </summary> | |||
public string? PatientOperationID { get; set; } | |||
public override string GetContent() | |||
{ | |||
return base.GetContent() | |||
+ AddLineContent(PatientOperationID) | |||
+ AddLineContent(CountFlag); | |||
} | |||
public override bool ParseContent(string[] lines) | |||
{ | |||
if (!base.ParseContent(lines) | |||
|| lines.Length < MinLines) | |||
{ | |||
return false; | |||
} | |||
PatientOperationID = EleMedKitProtocolHelper.GetLineContent(lines[2]); | |||
return true; | |||
} | |||
} | |||
} |
@@ -11,6 +11,11 @@ namespace Rdh.SocketServer.Client.Models | |||
{ | |||
private static readonly Char[] _lineSpiltor = new char[] { '\n' }; | |||
private static readonly char[] _blockSpiltor = new char[] { '|' }; | |||
/// <summary> | |||
/// 将数据按照行拆分 | |||
/// </summary> | |||
/// <param name="body"></param> | |||
/// <returns>拆分后的所有行(行内容中去除了标识符)</returns> | |||
public static String[] GetContentLines(String body) | |||
{ | |||
String[] lines = body.Split(_lineSpiltor, StringSplitOptions.RemoveEmptyEntries); |
@@ -723,6 +723,49 @@ namespace Rdh.SocketServer.Client.ViewModels | |||
Log("借药出错:" + ex.Message, -1); | |||
} | |||
break; | |||
case EleMedKitCommand.RequestStartPatientOperation: | |||
try | |||
{ | |||
Log("开启手术"); | |||
RequestStartPatientOperationProtocol requestLendProtocol = (RequestStartPatientOperationProtocol)curPocket.Data.ProtocolDataInfo; | |||
StorageSpacePortableLink? requestStorageLink = null; | |||
String? state = null; | |||
using (ConnectionSessionScope conn = new ConnectionSessionScope()) | |||
{ | |||
requestStorageLink = GetRequestStorageLink(null, requestLendProtocol.EleMedKitCode, out state); | |||
if (state != null | |||
|| requestStorageLink == null) | |||
{ | |||
Log("检查药箱信息不通过", -1); | |||
break; | |||
} | |||
#region 检查手术ID | |||
Guid operationKey; | |||
if (!Guid.TryParse(requestLendProtocol.PatientOperationID, out operationKey)) | |||
{ | |||
Log("手术排班ID无效:" + requestLendProtocol.PatientOperationID, -1); | |||
break; | |||
} | |||
PatientOperationInfoBLL patientOperationInfoBLL = new PatientOperationInfoBLL(); | |||
PatientOperationInfo requestOperation = patientOperationInfoBLL.Get(new PatientOperationInfo | |||
{ | |||
Key = operationKey | |||
}); | |||
if (requestOperation == null) | |||
{ | |||
Log("未找到请求的手术排班:" + requestLendProtocol.PatientOperationID, -1); | |||
break; | |||
} | |||
#endregion | |||
requestOperation.ClientTime = DateTime.Now; | |||
patientOperationInfoBLL.Update(requestOperation); | |||
} | |||
} | |||
catch (Exception ex) | |||
{ | |||
Log("开启手术出错:" + ex.Message, -1); | |||
} | |||
break; | |||
} | |||
if (responseData != null) | |||
{ |