|
|
|
|
|
|
|
|
{ |
|
|
{ |
|
|
service.Connecting += (client, e) => |
|
|
service.Connecting += (client, e) => |
|
|
{ |
|
|
{ |
|
|
Log($"{client.ID}正在建立连接"); |
|
|
|
|
|
|
|
|
Log($"{client.IP}:{client.Port.ToString()}正在建立连接"); |
|
|
};//有客户端正在连接 |
|
|
};//有客户端正在连接 |
|
|
service.Connected += (client, e) => |
|
|
service.Connected += (client, e) => |
|
|
{ |
|
|
{ |
|
|
Log($"已从{client.ID}建立连接"); |
|
|
|
|
|
|
|
|
Log($"已从{client.IP}:{client.Port.ToString()}建立连接"); |
|
|
Application.Current.Dispatcher.Invoke(() => |
|
|
Application.Current.Dispatcher.Invoke(() => |
|
|
{ |
|
|
{ |
|
|
ListClients.Add(new TimeFlagModel<SocketClient>(client)); |
|
|
ListClients.Add(new TimeFlagModel<SocketClient>(client)); |
|
|
|
|
|
|
|
|
};//有客户端连接 |
|
|
};//有客户端连接 |
|
|
service.Disconnected += (client, e) => |
|
|
service.Disconnected += (client, e) => |
|
|
{ |
|
|
{ |
|
|
Log($"已从{client.ID}断开连接"); |
|
|
|
|
|
|
|
|
Log($"已从{client.IP}:{client.Port.ToString()}断开连接"); |
|
|
Application.Current.Dispatcher.Invoke(() => |
|
|
Application.Current.Dispatcher.Invoke(() => |
|
|
{ |
|
|
{ |
|
|
lock (ListClients) |
|
|
lock (ListClients) |
|
|
|
|
|
|
|
|
{ |
|
|
{ |
|
|
Application.Current.Dispatcher.BeginInvoke(new Action(() => |
|
|
Application.Current.Dispatcher.BeginInvoke(new Action(() => |
|
|
{ |
|
|
{ |
|
|
Log($"Received from:{client.IP}"); |
|
|
|
|
|
|
|
|
Log($"Received from:{client.IP}:{client.Port.ToString()}"); |
|
|
EleMedKitData? data = requestInfo as EleMedKitData; |
|
|
EleMedKitData? data = requestInfo as EleMedKitData; |
|
|
if (data == null) |
|
|
if (data == null) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
|| d.UsageCode == DrugUsageCodes.LastUsed) |
|
|
|| d.UsageCode == DrugUsageCodes.LastUsed) |
|
|
{ |
|
|
{ |
|
|
PortableStorageItemLot inventoryLot = portableStorageItemLotBLL.GetByItemBarcode(d.Barcode); |
|
|
PortableStorageItemLot inventoryLot = portableStorageItemLotBLL.GetByItemBarcode(d.Barcode); |
|
|
//if (inventoryLot == null) |
|
|
|
|
|
//{ |
|
|
|
|
|
// Log("未找到药品条码标签:" + d.Barcode, -1); |
|
|
|
|
|
// drugHandleFlag = false; |
|
|
|
|
|
// break; |
|
|
|
|
|
//} |
|
|
|
|
|
//if (inventoryLot.PortableStorageItem.Item.Key.ToString() != d.DrugKey) |
|
|
//if (inventoryLot.PortableStorageItem.Item.Key.ToString() != d.DrugKey) |
|
|
//{ |
|
|
//{ |
|
|
// Log("上传的药品ID与数据库不符:" + d.DrugKey, -1); |
|
|
// Log("上传的药品ID与数据库不符:" + d.DrugKey, -1); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
usageWithInventory.Add(new Tuple<PortableStorageItemLot, int>(inventoryLot, (Int32)usageState)); |
|
|
usageWithInventory.Add(new Tuple<PortableStorageItemLot, int>(inventoryLot, (Int32)usageState)); |
|
|
} |
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
Log("未找到药品条码标签:" + d.Barcode, -1); |
|
|
|
|
|
//drugHandleFlag = false; |
|
|
|
|
|
// break; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
ItemTransaction itemTransaction = transactions.First().ItemTransaction; |
|
|
ItemTransaction itemTransaction = transactions.First().ItemTransaction; |
|
|
itemTransaction.Ext10 = "1"; |
|
|
itemTransaction.Ext10 = "1"; |
|
|
itemTransactionBLL.Update(itemTransaction); |
|
|
itemTransactionBLL.Update(itemTransaction); |
|
|
|
|
|
#region 更新药箱库存 |
|
|
|
|
|
PortableStorageItemBLL portableStorageItemBLL = new PortableStorageItemBLL(); |
|
|
|
|
|
PortableStorageItemLotBLL portableStorageItemLotBLL = new PortableStorageItemLotBLL(); |
|
|
|
|
|
foreach (SPILItemTransaction t in transactions) |
|
|
|
|
|
{ |
|
|
|
|
|
PortableStorageItem inventoryItem = portableStorageItemBLL.GetByStorageAndItem( |
|
|
|
|
|
requestStorageLink.PortableStorage.Code, |
|
|
|
|
|
t.ItemTransaction.ItemKey.GetValueOrDefault()); |
|
|
|
|
|
if (inventoryItem != null) |
|
|
|
|
|
{ |
|
|
|
|
|
inventoryItem.CurrentQuantity = inventoryItem.CurrentQuantity.GetValueOrDefault() + 1; |
|
|
|
|
|
portableStorageItemBLL.Update(inventoryItem); |
|
|
|
|
|
PortableStorageItemLot inventoryItemLot = new PortableStorageItemLot(); |
|
|
|
|
|
inventoryItemLot.Quantity = 1; |
|
|
|
|
|
inventoryItemLot.Key = Guid.NewGuid(); |
|
|
|
|
|
inventoryItemLot.ItemKey = t.ItemTransaction.ItemKey; |
|
|
|
|
|
inventoryItemLot.LotKey = t.ItemLotKey; |
|
|
|
|
|
inventoryItemLot.CreateTime = DateTime.Now; |
|
|
|
|
|
inventoryItemLot.PortableStorageItemkey = inventoryItem.Key; |
|
|
|
|
|
inventoryItemLot.Ext01 = t.Ext06; |
|
|
|
|
|
portableStorageItemLotBLL.Save(inventoryItemLot); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
#endregion |
|
|
|
|
|
#region 测试 |
|
|
//ResponseLendDrugProtocol response = new ResponseLendDrugProtocol(); |
|
|
//ResponseLendDrugProtocol response = new ResponseLendDrugProtocol(); |
|
|
//response.EleMedKitCode = requestLendProtocol.EleMedKitCode; |
|
|
//response.EleMedKitCode = requestLendProtocol.EleMedKitCode; |
|
|
//response.ListLendResult = new List<SimpleDrugLotProtocol>(); |
|
|
//response.ListLendResult = new List<SimpleDrugLotProtocol>(); |
|
|
|
|
|
|
|
|
// DrugKey = "39383086-f0aa-4ed0-bbe8-e1bf7fba719f", |
|
|
// DrugKey = "39383086-f0aa-4ed0-bbe8-e1bf7fba719f", |
|
|
// DrugLotCode = "20230817", |
|
|
// DrugLotCode = "20230817", |
|
|
//}); |
|
|
//}); |
|
|
//responseData = response; |
|
|
|
|
|
|
|
|
//responseData = response; |
|
|
|
|
|
#endregion |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
catch (Exception ex) |
|
|
catch (Exception ex) |