| | |
| | | { |
| | | public partial class StockInfoService : ServiceBase<Dt_StockInfo, IStockInfoRepository>, IStockInfoService |
| | | { |
| | | /// <summary> |
| | | /// æ ¹æ®æçå·æ¥è¯¢åºå |
| | | /// </summary> |
| | | /// <param name="palletCode"></param> |
| | | /// <returns></returns> |
| | | public Dt_StockInfo? GetStockByPalletCode(string palletCode) |
| | | { |
| | | Dt_StockInfo stockInfo = BaseDal.QueryFirst(x => x.PalletCode == palletCode); |
| | |
| | | if (stockInfo.Id == 0) |
| | | { |
| | | BaseDal.Db.InsertNav(stockInfo).Include(x => x.Details).ExecuteCommand(); |
| | | //stockQuantityChangeRecords = _mapper.Map<List<Dt_StockQuantityChangeRecord>>(stockInfo.Details); |
| | | //stockQuantityChangeRecords.ForEach(x => |
| | | //{ |
| | | // x.PalleCode = stockInfo.PalletCode; |
| | | // x.BeforeQuantity = 0; |
| | | // x.ChangeQuantity = x.AfterQuantity - x.BeforeQuantity; |
| | | // x.ChangeType = StockChangeType.MaterielGroup.ObjToInt(); |
| | | //}); |
| | | details = stockInfo.Details; |
| | | } |
| | | else |
| | |
| | | |
| | | } |
| | | |
| | | //stockQuantityChangeRecords = _mapper.Map<List<Dt_StockQuantityChangeRecord>>(stockInfo.Details); |
| | | //int index = 0; |
| | | //stockQuantityChangeRecords.ForEach(x => |
| | | //{ |
| | | // x.PalleCode = stockInfo.PalletCode; |
| | | // x.BeforeQuantity = 0; |
| | | // x.ChangeQuantity = x.AfterQuantity - x.BeforeQuantity; |
| | | // x.ChangeType = StockChangeType.MaterielGroup.ObjToInt(); |
| | | // x.StockDetailId = |
| | | // index++; |
| | | //}); |
| | | } |
| | | //_stockQuantityChangeRecordRepository.AddData(stockQuantityChangeRecords); |
| | | stockInfo.Details = details; |
| | | _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfo, stockInfo.Details, beforeQuantity, stockInfo.Details.Sum(x => x.StockQuantity) + beforeQuantity, StockChangeType.MaterielGroup); |
| | | _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfo, stockInfo.Details, beforeQuantity, stockInfo.Details.Sum(x => x.StockQuantity) + beforeQuantity, StockChangeType.MaterielGroup,0); |
| | | } |
| | | |
| | | public List<Dt_StockInfo> GetUseableStocks(string materielCode) |
| | |
| | | |
| | | return BaseDal.GetStockInfos(materielCode, locationCodes); |
| | | } |
| | | |
| | | public List<StockSelectViewDTO> GetStockSelectViews(string materielCode) |
| | | { |
| | | List<string> roadways = _basicRepository.RoadwayInfoRepository.CanOutRoadwayNos; |
| | |
| | | List<int> areaIds = _basicRepository.AreaInfoRepository.GetEnableAreaIds(warehouseIds); |
| | | |
| | | List<string> locationCodes = _basicRepository.LocationInfoRepository.GetCanOutLocationCodes(roadways, areaIds); |
| | | |
| | | |
| | | return BaseDal.QueryTabs<Dt_StockInfo, Dt_StockInfoDetail, StockSelectViewDTO>((a, b) => a.Id == b.StockId, (a, b) => new StockSelectViewDTO |
| | | { |
| | |
| | | int index = 0; |
| | | while (needQuantity > 0) |
| | | { |
| | | |
| | | Dt_StockInfo stockInfo = stockInfos[index]; |
| | | decimal useableStockQuantity = stockInfo.Details.Where(x => x.MaterielCode == materielCode).Sum(x => x.StockQuantity - x.OutboundQuantity); |
| | | if (useableStockQuantity < needQuantity) |