|  |  |  | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return WebResponseContent.Instance.Error($"该æçè¿æªåºåºå®æ"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<Dt_OutStockLockInfo> outStockLockInfos = Repository.QueryData(x => x.PalletCode == palletCode); | 
|---|
|  |  |  | List<Dt_OutStockLockInfo> outStockLockInfos = Repository.QueryData(x => x.PalletCode == palletCode && x.Status == OutLockStockStatusEnum.åºåºå®æ.ObjToInt()); | 
|---|
|  |  |  | if (outStockLockInfos == null || outStockLockInfos.Count == 0) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return WebResponseContent.Instance.Error("该æçå·²å
¨é¨åæ£å®æ"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | for (int i = 0; i < outStockLockInfos.Count; i++) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | outStockLockInfos[i].Status = OutLockStockStatusEnum.æ£é宿.ObjToInt(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<Dt_StockInfoDetail> beforeDetaile = stockInfo.Details.GroupBy(x => x.MaterielCode).Select(x => new Dt_StockInfoDetail { MaterielCode = x.Key, StockQuantity = x.Sum(v => v.StockQuantity) }).ToList(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<Dt_StockInfoDetail> updateDetailList = new List<Dt_StockInfoDetail>(); | 
|---|
|  |  |  | List<Dt_StockInfoDetail> deleteDetailList = new List<Dt_StockInfoDetail>(); | 
|---|
|  |  |  | List<Dt_StockInfoDetail> residueDetailList = new List<Dt_StockInfoDetail>(); | 
|---|
|  |  |  | for (int i = 0; i < stockInfo.Details.Count; i++) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | if (stockInfo.Details[i].OutboundQuantity > 0) | 
|---|
|  |  |  | 
|---|
|  |  |  | deleteDetailList.Add(stockInfo.Details[i]); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | residueDetailList.Add(stockInfo.Details[i]); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | stockInfo.StockStatus = StockStatusEmun.æ£é宿.ObjToInt(); | 
|---|
|  |  |  | List<string> mCodes = stockInfo.Details.GroupBy(x => x.MaterielCode).Select(x => x.Key).ToList(); | 
|---|
|  |  |  | _unitOfWorkManage.BeginTran(); | 
|---|
|  |  |  | foreach (string code in mCodes) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfo, updateDetailList, deleteDetailList, StockChangeTypeEnum.Outbound); | 
|---|
|  |  |  | _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfo, residueDetailList, updateDetailList, deleteDetailList, StockChangeTypeEnum.Outbound); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | updateDetailList.ForEach(x => | 
|---|
|  |  |  | { | 
|---|
|  |  |  | x.OutboundQuantity = 0; | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //_stockService.StockInfoDetailService.Repository.DeleteAndMoveIntoHty(deleteDetailList, OperateTypeEnum.èªå¨å®æ); | 
|---|
|  |  |  | if (stockInfo.Details.Count > deleteDetailList.Count) | 
|---|
|  |  |  | _stockService.StockInfoService.Repository.UpdateData(stockInfo); | 
|---|
|  |  |  | else | 
|---|
|  |  |  | _stockService.StockInfoService.Repository.DeleteAndMoveIntoHty(stockInfo, OperateTypeEnum.èªå¨å®æ); | 
|---|
|  |  |  | _stockService.StockInfoDetailService.Repository.DeleteAndMoveIntoHty(deleteDetailList, OperateTypeEnum.èªå¨å®æ); | 
|---|
|  |  |  | _stockService.StockInfoDetailService.Repository.UpdateData(updateDetailList); | 
|---|
|  |  |  | //_stockService.StockInfoDetailService.Repository.DeleteData(deleteDetailList); | 
|---|
|  |  |  | BaseDal.UpdateData(outStockLockInfos); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | _unitOfWorkManage.CommitTran(); | 
|---|
|  |  |  | return WebResponseContent.Instance.OK(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | catch (Exception ex) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | _unitOfWorkManage.RollbackTran(); | 
|---|
|  |  |  | return WebResponseContent.Instance.Error(ex.Message); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|