|
|
|
|
|
|
|
|
IEnumerable<OperationTakeItem> takeHistory = operationTakeItemBLL.ListTakeItemsByTakeBag(curTakeBag); |
|
|
IEnumerable<OperationTakeItem> takeHistory = operationTakeItemBLL.ListTakeItemsByTakeBag(curTakeBag); |
|
|
Boolean drugHandleFlag = true; |
|
|
Boolean drugHandleFlag = true; |
|
|
#region 根据请求的标签获取对应库存 |
|
|
#region 根据请求的标签获取对应库存 |
|
|
List<PortableStorageItemLot> usageWithInventory = new List<PortableStorageItemLot>(); |
|
|
|
|
|
|
|
|
List<Tuple<PortableStorageItemLot, Int32>> usageWithInventory = new List<Tuple<PortableStorageItemLot, Int32>>(); |
|
|
foreach (DrugUsageProtocol d in requestUsageProtocol.ListDrugs) |
|
|
foreach (DrugUsageProtocol d in requestUsageProtocol.ListDrugs) |
|
|
{ |
|
|
{ |
|
|
OperationTakeItem? historyItem = takeHistory == null |
|
|
OperationTakeItem? historyItem = takeHistory == null |
|
|
|
|
|
|
|
|
//} |
|
|
//} |
|
|
if (inventoryLot != null) |
|
|
if (inventoryLot != null) |
|
|
{ |
|
|
{ |
|
|
usageWithInventory.Add(inventoryLot); |
|
|
|
|
|
|
|
|
EleMedKitDrugUsageStates usageState = EleMedKitDrugUsageStates.Normal; |
|
|
|
|
|
switch (d.UsageCode) |
|
|
|
|
|
{ |
|
|
|
|
|
case DrugUsageCodes.Lost: |
|
|
|
|
|
usageState = EleMedKitDrugUsageStates.Lost; |
|
|
|
|
|
break; |
|
|
|
|
|
case DrugUsageCodes.LastUsed: |
|
|
|
|
|
usageState = EleMedKitDrugUsageStates.LastUsed; |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
usageWithInventory.Add(new Tuple<PortableStorageItemLot, int>(inventoryLot, (Int32)usageState)); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
#endregion |
|
|
#endregion |
|
|
#region 更新库存和业务记录 |
|
|
#region 更新库存和业务记录 |
|
|
IEnumerable<IGrouping<Guid, PortableStorageItemLot>> inventoryLogGroup = usageWithInventory |
|
|
|
|
|
.GroupBy(x => x.LotKey.GetValueOrDefault()); |
|
|
|
|
|
|
|
|
IEnumerable<IGrouping<Guid, Tuple<PortableStorageItemLot, Int32>>> inventoryLogGroup = usageWithInventory |
|
|
|
|
|
.GroupBy(x => x.Item1.LotKey.GetValueOrDefault()); |
|
|
//保存OperationTakeItem |
|
|
//保存OperationTakeItem |
|
|
foreach (IGrouping<Guid, PortableStorageItemLot> g in inventoryLogGroup) |
|
|
|
|
|
|
|
|
foreach (IGrouping<Guid, Tuple<PortableStorageItemLot, Int32>> g in inventoryLogGroup) |
|
|
{ |
|
|
{ |
|
|
OperationTakeItem operationTakeItem = new OperationTakeItem |
|
|
OperationTakeItem operationTakeItem = new OperationTakeItem |
|
|
{ |
|
|
{ |
|
|
Key = Guid.NewGuid(), |
|
|
Key = Guid.NewGuid(), |
|
|
SnapshotKey = Guid.NewGuid(), |
|
|
SnapshotKey = Guid.NewGuid(), |
|
|
ItemKey = g.First().ItemKey, |
|
|
|
|
|
Ext01 = g.First().LotKey.GetValueOrDefault().ToString(), |
|
|
|
|
|
|
|
|
ItemKey = g.First().Item1.ItemKey, |
|
|
|
|
|
Ext01 = g.First().Item1.LotKey.GetValueOrDefault().ToString(), |
|
|
TakeBagKey = curTakeBag.Key, |
|
|
TakeBagKey = curTakeBag.Key, |
|
|
TakeQuantity = g.Count(), |
|
|
TakeQuantity = g.Count(), |
|
|
}; |
|
|
}; |
|
|
operationTakeItemBLL.Save(operationTakeItem); |
|
|
operationTakeItemBLL.Save(operationTakeItem); |
|
|
//更新PortableStorageItem |
|
|
//更新PortableStorageItem |
|
|
PortableStorageItem psi = g.First().PortableStorageItem; |
|
|
|
|
|
|
|
|
PortableStorageItem psi = g.First().Item1.PortableStorageItem; |
|
|
psi.CurrentQuantity = psi.CurrentQuantity.GetValueOrDefault() - g.Count(); |
|
|
psi.CurrentQuantity = psi.CurrentQuantity.GetValueOrDefault() - g.Count(); |
|
|
portableStorageItemBLL.Update(psi); |
|
|
portableStorageItemBLL.Update(psi); |
|
|
//保存StorageSpaceItemTransaction |
|
|
//保存StorageSpaceItemTransaction |
|
|
|
|
|
|
|
|
storageSpaceItemTransactionBLL.Save(ssiTransaction); |
|
|
storageSpaceItemTransactionBLL.Save(ssiTransaction); |
|
|
} |
|
|
} |
|
|
//更新批号库存 |
|
|
//更新批号库存 |
|
|
foreach (PortableStorageItemLot psil in usageWithInventory) |
|
|
|
|
|
|
|
|
foreach (Tuple<PortableStorageItemLot, Int32> psil in usageWithInventory) |
|
|
{ |
|
|
{ |
|
|
SPILItemTransaction sPILItemTransaction = new SPILItemTransaction() |
|
|
SPILItemTransaction sPILItemTransaction = new SPILItemTransaction() |
|
|
{ |
|
|
{ |
|
|
Key = Guid.NewGuid(), |
|
|
Key = Guid.NewGuid(), |
|
|
StorageSpaceItemLotKey = psil.Key, |
|
|
|
|
|
|
|
|
StorageSpaceItemLotKey = psil.Item1.Key, |
|
|
Quantity = 1, |
|
|
Quantity = 1, |
|
|
ItemTransactionKey = curTakeBag.Key.GetValueOrDefault(), |
|
|
ItemTransactionKey = curTakeBag.Key.GetValueOrDefault(), |
|
|
ItemLotKey = psil.LotKey, |
|
|
|
|
|
Ext01 = psil.Ext01, |
|
|
|
|
|
|
|
|
ItemLotKey = psil.Item1.LotKey, |
|
|
|
|
|
Ext01 = psil.Item1.Ext01, |
|
|
|
|
|
Ext09 = psil.Item2.ToString(), |
|
|
}; |
|
|
}; |
|
|
sPILItemTransactionBLL.Save(sPILItemTransaction); |
|
|
sPILItemTransactionBLL.Save(sPILItemTransaction); |
|
|
portableStorageItemLotBLL.Delete(psil); |
|
|
|
|
|
|
|
|
portableStorageItemLotBLL.Delete(psil.Item1); |
|
|
} |
|
|
} |
|
|
#endregion |
|
|
#endregion |
|
|
#region 更新手术状态 |
|
|
#region 更新手术状态 |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
catch (Exception ex) |
|
|
catch (Exception ex) |
|
|
{ |
|
|
{ |
|
|
|
|
|
RemovePocket(curPocket); |
|
|
Log("服务器反馈出错:" + ex.Message, -1); |
|
|
Log("服务器反馈出错:" + ex.Message, -1); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |