Browse Source

增加药箱开启手术接口

master
lirenjie 8 months ago
parent
commit
c7aa4d6381

+ 4
- 0
Rdh.SocketServer.Client/Models/EleMedKitCommand.cs View File

/// </summary> /// </summary>
public const String RequestDrugLend = "0G"; public const String RequestDrugLend = "0G";
/// <summary> /// <summary>
/// 药箱开始手术取药
/// </summary>
public const String RequestStartPatientOperation = "0H";
/// <summary>
/// 药箱同步时钟 /// 药箱同步时钟
/// </summary> /// </summary>
public const String RequestClock = "TT"; public const String RequestClock = "TT";

+ 8
- 0
Rdh.SocketServer.Client/Models/EleMedKitProtocol/BaseEleMedKitProtocol.cs View File

public abstract class BaseEleMedKitProtocol public abstract class BaseEleMedKitProtocol
{ {
public virtual string? Command { get; set; } public virtual string? Command { get; set; }
/// <summary>
/// 获取或设置数据的最小行数
/// </summary>
public virtual int MinLines { get; set; } = 1; public virtual int MinLines { get; set; } = 1;
public virtual string AddLineContent(string? line) public virtual string AddLineContent(string? line)
{ {
return builder.ToString(); return builder.ToString();
} }
public abstract string GetContent(); public abstract string GetContent();
/// <summary>
/// 检验数据行并进行解析
/// </summary>
/// <param name="lines"></param>
/// <returns>是否检验成功</returns>
public virtual bool ParseContent(string[] lines) public virtual bool ParseContent(string[] lines)
{ {
if (lines == null || lines.Length < 1) if (lines == null || lines.Length < 1)

+ 12
- 0
Rdh.SocketServer.Client/Models/EleMedKitProtocol/EleMedKitProtocolFlags.cs View File

public const string Start = "*"; public const string Start = "*";
public const string LineStart = "#"; public const string LineStart = "#";
public const string LineEnd = "\r\n"; public const string LineEnd = "\r\n";
/// <summary>
/// 行内分隔符
/// </summary>
public const string BlockSpiltor = "|"; public const string BlockSpiltor = "|";
/// <summary>
/// 行分割符
/// </summary>
public const string LineSpiltor = "<>"; public const string LineSpiltor = "<>";
/// <summary>
/// 数字边补符
/// </summary>
public const string LinePad = "0"; public const string LinePad = "0";
public const string End = "@"; public const string End = "@";
/// <summary>
/// 数字边补长度
/// </summary>
public const int LinePadTotalLenght = 3; public const int LinePadTotalLenght = 3;
} }
} }

+ 40
- 0
Rdh.SocketServer.Client/Models/EleMedKitProtocol/RequestStartPatientOperationProtocol.cs View File

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;
}
}
}

+ 5
- 0
Rdh.SocketServer.Client/Models/EleMedKitProtocolHelper.cs View File

{ {
private static readonly Char[] _lineSpiltor = new char[] { '\n' }; private static readonly Char[] _lineSpiltor = new char[] { '\n' };
private static readonly char[] _blockSpiltor = new char[] { '|' }; private static readonly char[] _blockSpiltor = new char[] { '|' };
/// <summary>
/// 将数据按照行拆分
/// </summary>
/// <param name="body"></param>
/// <returns>拆分后的所有行(行内容中去除了标识符)</returns>
public static String[] GetContentLines(String body) public static String[] GetContentLines(String body)
{ {
String[] lines = body.Split(_lineSpiltor, StringSplitOptions.RemoveEmptyEntries); String[] lines = body.Split(_lineSpiltor, StringSplitOptions.RemoveEmptyEntries);

+ 43
- 0
Rdh.SocketServer.Client/ViewModels/MainWindowViewModel.cs View File

Log("借药出错:" + ex.Message, -1); Log("借药出错:" + ex.Message, -1);
} }
break; 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) if (responseData != null)
{ {

Loading…
Cancel
Save