| | |
| | | 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 partial class OutStockLockInfoService |
| | | { |
| | | IStockService _stockService; |
| | | |
| | | /// <summary> |
| | | /// 忣 |
| | | /// </summary> |
| | | /// <param name="palletCode">æçå·</param> |
| | | /// <returns></returns> |
| | | public WebResponseContent MaterialPick(string palletCode) |
| | | { |
| | | try |
| | |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°è¯¥æçåºåä¿¡æ¯"); |
| | | } |
| | | if (stockInfo.StockStatus != StockStatusEmun.åºåºå®æ.ObjToInt()) |
| | | { |
| | | return WebResponseContent.Instance.Error($"该æçè¿æªåºåºå®æ"); |
| | | } |
| | | List<Dt_OutStockLockInfo> outStockLockInfos = Repository.QueryData(x => x.PalletCode == palletCode); |
| | | for (int i = 0; i < outStockLockInfos.Count; i++) |
| | | { |
| | | float assignQuantity = outStockLockInfos[i].AssignQuantity; |
| | | List<Dt_StockInfoDetail> stockInfoDetails = stockInfo.Details.Where(x => x.MaterielCode == outStockLockInfos[i].MaterielCode).ToList(); |
| | | for (int j = 0; j < stockInfoDetails.Count; j++) |
| | | 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>(); |
| | | for (int i = 0; i < stockInfo.Details.Count; i++) |
| | | { |
| | | if (stockInfo.Details[i].OutboundQuantity > 0) |
| | | { |
| | | // if(assignQuantity > stockInfoDetails[j]) |
| | | if (stockInfo.Details[i].StockQuantity > stockInfo.Details[i].OutboundQuantity) |
| | | { |
| | | stockInfo.Details[i].StockQuantity -= stockInfo.Details[i].OutboundQuantity; |
| | | updateDetailList.Add(stockInfo.Details[i]); |
| | | } |
| | | else |
| | | { |
| | | deleteDetailList.Add(stockInfo.Details[i]); |
| | | } |
| | | } |
| | | } |
| | | |
| | | List<string> mCodes = stockInfo.Details.GroupBy(x => x.MaterielCode).Select(x => x.Key).ToList(); |
| | | foreach (string code in mCodes) |
| | | { |
| | | _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfo, updateDetailList, deleteDetailList, StockChangeTypeEnum.Outbound); |
| | | } |
| | | |
| | | updateDetailList.ForEach(x => |
| | | { |
| | | x.OutboundQuantity = 0; |
| | | }); |
| | | |
| | | //_stockService.StockInfoDetailService.Repository.DeleteAndMoveIntoHty(deleteDetailList, OperateTypeEnum.èªå¨å®æ); |
| | | _stockService.StockInfoDetailService.Repository.UpdateData(updateDetailList); |
| | | BaseDal.UpdateData(outStockLockInfos); |
| | | |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |