|  |  | 
 |  |  | using System.Threading.Tasks; | 
 |  |  | using WIDESEA_Common.StockEnum; | 
 |  |  | using WIDESEA_Core; | 
 |  |  | using WIDESEA_Core.BaseRepository; | 
 |  |  | using WIDESEA_Core.BaseServices; | 
 |  |  | using WIDESEA_Core.Enums; | 
 |  |  | using WIDESEA_Core.Helper; | 
 |  |  | using WIDESEA_IOutboundRepository; | 
 |  |  | using WIDESEA_IRecordService; | 
 |  |  | using WIDESEA_IStockService; | 
 |  |  | using WIDESEA_Model.Models; | 
 |  |  |  | 
 |  |  | namespace WIDESEA_IOutboundService | 
 |  |  | { | 
 |  |  |     public partial class OutStockLockInfoService : ServiceBase<Dt_OutStockLockInfo, IOutStockLockInfoRepository>, IOutStockLockInfoService | 
 |  |  |     { | 
 |  |  |         public IOutStockLockInfoRepository Repository => BaseDal; | 
 |  |  |  | 
 |  |  |         public OutStockLockInfoService(IOutStockLockInfoRepository BaseDal) : base(BaseDal) | 
 |  |  |         private readonly IStockService _stockService; | 
 |  |  |         private readonly IRecordService _recordService; | 
 |  |  |  | 
 |  |  |         public IOutStockLockInfoRepository Repository => BaseDal; | 
 |  |  |         public IUnitOfWorkManage _unitOfWorkManage; | 
 |  |  |  | 
 |  |  |         public OutStockLockInfoService(IOutStockLockInfoRepository BaseDal, IStockService stockService, IRecordService recordService, IUnitOfWorkManage unitOfWorkManage) : base(BaseDal) | 
 |  |  |         { | 
 |  |  |             _recordService = recordService; | 
 |  |  |             _stockService = stockService; | 
 |  |  |             _unitOfWorkManage = unitOfWorkManage; | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         public List<Dt_OutStockLockInfo> GetOutStockLockInfos(Dt_OutboundOrder outboundOrder, Dt_OutboundOrderDetail outboundOrderDetail, List<Dt_StockInfo> outStocks, int? taskNum = null) | 
 |  |  | 
 |  |  |             return outStockLockInfos; | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         public List<Dt_OutStockLockInfo> GetByOrderDetailId(int orderDetailId, OutLockStockStatusEnum outStockStatus) | 
 |  |  |         public Dt_OutStockLockInfo GetOutStockLockInfo(Dt_OutboundOrder outboundOrder, Dt_OutboundOrderDetail outboundOrderDetail, Dt_StockInfo outStock, float assignQuantity, int? taskNum = null) | 
 |  |  |         { | 
 |  |  |             return BaseDal.QueryData(x => x.OrderDetailId == orderDetailId && x.Status == outStockStatus.ObjToInt()); | 
 |  |  |  | 
 |  |  |             Dt_OutStockLockInfo outStockLockInfo = new Dt_OutStockLockInfo() | 
 |  |  |             { | 
 |  |  |                 PalletCode = outStock.PalletCode, | 
 |  |  |                 AssignQuantity = assignQuantity, | 
 |  |  |                 MaterielCode = outboundOrderDetail.MaterielCode, | 
 |  |  |                 BatchNo = outboundOrderDetail.BatchNo ?? outStock.Details.FirstOrDefault()?.BatchNo, | 
 |  |  |                 LocationCode = outStock.LocationCode, | 
 |  |  |                 MaterielName = outboundOrderDetail.MaterielName, | 
 |  |  |                 OrderDetailId = outboundOrderDetail.Id, | 
 |  |  |                 OrderNo = outboundOrder.OrderNo, | 
 |  |  |                 OrderType = outboundOrder.OrderType, | 
 |  |  |                 OriginalQuantity = outStock.Details.Where(x => x.MaterielCode == outboundOrderDetail.MaterielCode).Sum(x => x.StockQuantity), | 
 |  |  |                 Status = taskNum == null ? OutLockStockStatusEnum.å·²åé
.ObjToInt() : OutLockStockStatusEnum.åºåºä¸.ObjToInt(), | 
 |  |  |                 StockId = outStock.Id, | 
 |  |  |                 TaskNum = taskNum, | 
 |  |  |                 OrderQuantity = outboundOrderDetail.OrderQuantity, | 
 |  |  |                 Unit=outboundOrderDetail.Unit, | 
 |  |  |             }; | 
 |  |  |  | 
 |  |  |             return outStockLockInfo; | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         public Dt_OutStockLockInfo GetOutStockLockInfo(Dt_MesOutboundOrder mesOutboundOrder, Dt_StockInfo outStock, float assignQuantity, int? taskNum = null) | 
 |  |  |         { | 
 |  |  |  | 
 |  |  |             Dt_OutStockLockInfo outStockLockInfo = new Dt_OutStockLockInfo() | 
 |  |  |             { | 
 |  |  |                 PalletCode = outStock.PalletCode, | 
 |  |  |                 AssignQuantity = assignQuantity, | 
 |  |  |                 MaterielCode = mesOutboundOrder.MaterialCode, | 
 |  |  |                 BatchNo = outStock.Details.FirstOrDefault()?.BatchNo ?? "", | 
 |  |  |                 LocationCode = outStock.LocationCode, | 
 |  |  |                 MaterielName = mesOutboundOrder.MaterialName, | 
 |  |  |                 OrderDetailId = mesOutboundOrder.Id, | 
 |  |  |                 OrderNo = mesOutboundOrder.OrderNo, | 
 |  |  |                 OrderType = mesOutboundOrder.OrderType, | 
 |  |  |                 OriginalQuantity = outStock.Details.Where(x => x.MaterielCode == mesOutboundOrder.MaterialCode).Sum(x => x.StockQuantity), | 
 |  |  |                 Status = taskNum == null ? OutLockStockStatusEnum.å·²åé
.ObjToInt() : OutLockStockStatusEnum.åºåºä¸.ObjToInt(), | 
 |  |  |                 StockId = outStock.Id, | 
 |  |  |                 TaskNum = taskNum, | 
 |  |  |                 OrderQuantity = mesOutboundOrder.OrderQuantity, | 
 |  |  |                 Unit = mesOutboundOrder.Unit | 
 |  |  |             }; | 
 |  |  |  | 
 |  |  |             return outStockLockInfo; | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         public List<Dt_OutStockLockInfo> GetByOrderDetailId(int orderDetailId, OutLockStockStatusEnum? outStockStatus) | 
 |  |  |         { | 
 |  |  |             return BaseDal.QueryData(x => x.OrderDetailId == orderDetailId && outStockStatus==null?true:x.Status == outStockStatus.ObjToInt()); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         public List<Dt_OutStockLockInfo> GetStockOutboundOrder(SaveModel saveModel) | 
 |  |  | 
 |  |  |                 var palletCode = saveModel.MainData["barcode"].ToString(); | 
 |  |  |                 var warehouseId = saveModel.MainData["warehouseId"].ObjToInt(); | 
 |  |  |                 Dt_StockInfo stockInfo = BaseDal.Db.Queryable<Dt_StockInfo>().Where(x => x.PalletCode == palletCode && x.WarehouseId == warehouseId).Includes(x => x.Details).First(); | 
 |  |  |                 if (stockInfo.StockStatus != StockStatusEmun.åºåºå®æ.ObjToInt()) | 
 |  |  |                 { | 
 |  |  |                     throw new Exception($"该æçè¿æªåºåºå®æ"); | 
 |  |  |                 } | 
 |  |  |                 if (stockInfo == null) | 
 |  |  |                 { | 
 |  |  |                     throw new Exception($"æªæ¾å°åºåä¿¡æ¯"); | 
 |  |  | 
 |  |  |                 { | 
 |  |  |                     throw new Exception($"æªæ¾å°åºå详æ
"); | 
 |  |  |                 } | 
 |  |  |                 List<Dt_OutStockLockInfo> stockLockInfos = BaseDal.QueryData(x => x.StockId == stockInfo.Id); | 
 |  |  |                 List<Dt_OutStockLockInfo> stockLockInfos = BaseDal.QueryData(x => x.StockId == stockInfo.Id && x.Status == OutLockStockStatusEnum.åºåºå®æ.ObjToInt()); | 
 |  |  |                 return stockLockInfos; | 
 |  |  |             } | 
 |  |  |             catch (Exception ex) |