| | |
| | | if (stationManager.stationType != 7) throw new Exception("错误的调取"); |
| | | |
| | | // 从缓存中获取库存信息 |
| | | IDictionary<string, DtStockInfo>? stockInfos = _simpleCacheService.HashGetAll<DtStockInfo>(WIDESEA_Cache.CacheConst.Cache_DtStockInfo); |
| | | List<DtStockInfo> stockInfoList = stockInfos.Values.ToList(); |
| | | //IDictionary<string, DtStockInfo>? stockInfos = _simpleCacheService.HashGetAll<DtStockInfo>(WIDESEA_Cache.CacheConst.Cache_DtStockInfo); |
| | | //List<DtStockInfo> stockInfoList = stockInfos.Values.ToList(); |
| | | |
| | | var stockinfo1 = stockInfoList.OrderBy(x => x.CreateDate) |
| | | .ToList(); |
| | | var stockinfo = stockinfo1.Where(x => x.LocationInfo != null && !x.IsFull && x.LocationInfo.RoadwayNo == stationManager.Roadway) |
| | | .FirstOrDefault(); |
| | | //var stockinfo1 = stockInfoList.OrderBy(x => x.CreateDate) |
| | | // .ToList(); |
| | | //var stockinfo = stockinfo1.Where(x => x.LocationInfo != null && !x.IsFull && x.LocationInfo.RoadwayNo == stationManager.Roadway) |
| | | // .FirstOrDefault(); |
| | | var stockinfo = await _stockInfoRepository.Db.Queryable<DtStockInfo>() |
| | | .Where(x => !x.IsFull && x.LocationInfo.RoadwayNo == stationManager.Roadway) |
| | | .OrderBy(x=>x.CreateDate) |
| | | .FirstAsync(); |
| | | |
| | | if (stockinfo == null) return null; |
| | | |
| | |
| | | Creater = "System", |
| | | ProductionLine = stockinfo.ProductionLine, |
| | | }; |
| | | _simpleCacheService.HashDel<DtStockInfo>(WIDESEA_Cache.CacheConst.Cache_DtStockInfo, new string[] { task.PalletCode }); |
| | | //_simpleCacheService.HashDel<DtStockInfo>(WIDESEA_Cache.CacheConst.Cache_DtStockInfo, new string[] { task.PalletCode }); |
| | | return task; |
| | | } |
| | | catch (Exception ex) |
| | |
| | | .ToList().Select(x => x.DeviceCode).ToList(); |
| | | |
| | | // 从缓存中获取库存信息 |
| | | IDictionary<string, DtStockInfo>? stockInfos = _simpleCacheService.HashGetAll<DtStockInfo>(WIDESEA_Cache.CacheConst.Cache_DtStockInfo); |
| | | List<DtStockInfo> stockInfoList = stockInfos.Values.ToList(); |
| | | //IDictionary<string, DtStockInfo>? stockInfos = _simpleCacheService.HashGetAll<DtStockInfo>(WIDESEA_Cache.CacheConst.Cache_DtStockInfo); |
| | | //List<DtStockInfo> stockInfoList = stockInfos.Values.ToList(); |
| | | |
| | | var result1 = stockInfoList.Where(x => x.ProductionLine == productLine) |
| | | .Where(x => x.AreaCode == areaCode && x.IsFull == false) |
| | | .WhereIF(!deviceCode.IsNullOrEmpty(), x => x.LocationInfo != null && deviceCode.Contains(x.LocationInfo.RoadwayNo)) |
| | | .OrderBy(x => x.CreateDate) // 排序 |
| | | .ToList(); // 转换为列表 |
| | | //var result1 = stockInfoList.Where(x => x.ProductionLine == productLine) |
| | | // .Where(x => x.AreaCode == areaCode && x.IsFull == false) |
| | | // .WhereIF(!deviceCode.IsNullOrEmpty(), x => x.LocationInfo != null && deviceCode.Contains(x.LocationInfo.RoadwayNo)) |
| | | // .OrderBy(x => x.CreateDate) // 排序 |
| | | // .ToList(); // 转换为列表 |
| | | |
| | | var result = result1.Where(x => x.StockInfoDetails != null && x.StockInfoDetails.Any(y => y.MaterielCode == "空托盘")) |
| | | .Where(x => x.LocationInfo != null && x.LocationInfo.LocationStatus == (int)LocationEnum.InStock && x.LocationInfo.AreaId == area.AreaID && x.LocationInfo.EnalbeStatus == (int)EnableEnum.Enable) // 过滤条件 |
| | | .FirstOrDefault(); // 获取第一个元素 |
| | | //var result = result1.Where(x => x.StockInfoDetails != null && x.StockInfoDetails.Any(y => y.MaterielCode == "空托盘")) |
| | | // .Where(x => x.LocationInfo != null && x.LocationInfo.LocationStatus == (int)LocationEnum.InStock && x.LocationInfo.AreaId == area.AreaID && x.LocationInfo.EnalbeStatus == (int)EnableEnum.Enable) // 过滤条件 |
| | | // .FirstOrDefault(); // 获取第一个元素 |
| | | |
| | | if (result != null) |
| | | _simpleCacheService.HashDel<DtStockInfo>(WIDESEA_Cache.CacheConst.Cache_DtStockInfo, new string[] { result.PalletCode }); |
| | | else |
| | | //if (result != null) |
| | | // _simpleCacheService.HashDel<DtStockInfo>(WIDESEA_Cache.CacheConst.Cache_DtStockInfo, new string[] { result.PalletCode }); |
| | | //else |
| | | // ConsoleHelper.WriteColorLine($"常温{productLine}空托盘库存不足", ConsoleColor.Red); |
| | | var result = await _stockInfoRepository.Db.Queryable<DtStockInfo>() |
| | | .Includes(x => x.LocationInfo) |
| | | .Includes(x => x.StockInfoDetails) |
| | | .Where(x => x.AreaCode == areaCode && x.IsFull == false && x.ProductionLine == productLine) |
| | | .WhereIF(!deviceCode.IsNullOrEmpty(), x => deviceCode.Contains(x.LocationInfo.RoadwayNo)) |
| | | .Where(x => x.LocationInfo.LocationStatus == (int)LocationEnum.InStock && x.LocationInfo.AreaId == area.AreaID && x.LocationInfo.EnalbeStatus == (int)EnableEnum.Enable) // 过滤条件 |
| | | .Where(x => x.StockInfoDetails.Any(y => y.MaterielCode == "空托盘")) |
| | | .OrderBy(x => x.CreateDate) // 排序 |
| | | .FirstAsync(); |
| | | |
| | | if (result.IsNullOrEmpty()) |
| | | ConsoleHelper.WriteColorLine($"常温{productLine}空托盘库存不足", ConsoleColor.Red); |
| | | |
| | | |
| | | return result; |
| | | } |
| | |
| | | .ToList() |
| | | : null; |
| | | |
| | | // 从缓存中获取库存信息 |
| | | IDictionary<string, DtStockInfo>? stockInfos = _simpleCacheService.HashGetAll<DtStockInfo>(WIDESEA_Cache.CacheConst.Cache_DtStockInfo); |
| | | List<DtStockInfo> stockInfoList = stockInfos.Values.ToList(); |
| | | //// 从缓存中获取库存信息 |
| | | //IDictionary<string, DtStockInfo>? stockInfos = _simpleCacheService.HashGetAll<DtStockInfo>(WIDESEA_Cache.CacheConst.Cache_DtStockInfo); |
| | | //List<DtStockInfo> stockInfoList = stockInfos.Values.ToList(); |
| | | |
| | | //// 修改后的查询代码 |
| | | //var stockInfo1 = stockInfoList |
| | | // .Where(x => x.ProductionLine == station.productLine) |
| | | // .Where(x => x.AreaCode == "CWSC3" && x.IsFull == true) |
| | | // .OrderBy(x => x.OutboundTime) |
| | | // .ToList(); |
| | | |
| | | //var stockInfo = stockInfo1 |
| | | // // 增加对 LocationInfo 的空值检查 |
| | | // .Where(x => x.LocationInfo != null && x.LocationInfo.LocationStatus == (int)LocationEnum.InStock) |
| | | // // 增加对 LocationInfo 的空值检查 |
| | | // .WhereIF(!deviceCode.IsNullOrEmpty(), x => x.LocationInfo != null && deviceCode.Contains(x.LocationInfo.RoadwayNo)) |
| | | // .WhereIF(!materielCodes.IsNullOrEmpty(), x => x.StockInfoDetails != null && x.StockInfoDetails.Any(y => materielCodes.Contains(y.MaterielCode))) |
| | | // .FirstOrDefault(); |
| | | // 修改后的查询代码 |
| | | var stockInfo1 = stockInfoList |
| | | .Where(x => x.ProductionLine == station.productLine) |
| | | .Where(x => x.AreaCode == "CWSC3" && x.IsFull == true) |
| | | .OrderBy(x => x.OutboundTime) |
| | | .ToList(); |
| | | var stockInfo = await _stockInfoRepository.Db.Queryable<DtStockInfo>() |
| | | .Includes(x => x.LocationInfo) |
| | | .Includes(x => x.StockInfoDetails) |
| | | .Where(x => x.ProductionLine == station.productLine) |
| | | .Where(x => x.AreaCode == "CWSC3" && x.IsFull == true) |
| | | // 增加对 LocationInfo 的空值检查 |
| | | .Where(x => x.LocationInfo.LocationStatus == (int)LocationEnum.InStock) |
| | | // 增加对 LocationInfo 的空值检查 |
| | | .WhereIF(!deviceCode.IsNullOrEmpty(), x => deviceCode.Contains(x.LocationInfo.RoadwayNo)) |
| | | .WhereIF(!materielCodes.IsNullOrEmpty(), x => x.StockInfoDetails.Any(y => materielCodes.Contains(y.MaterielCode))) |
| | | .OrderBy(x => x.OutboundTime) |
| | | .FirstAsync(); |
| | | |
| | | var stockInfo = stockInfo1 |
| | | // 增加对 LocationInfo 的空值检查 |
| | | .Where(x => x.LocationInfo != null && x.LocationInfo.LocationStatus == (int)LocationEnum.InStock) |
| | | // 增加对 LocationInfo 的空值检查 |
| | | .WhereIF(!deviceCode.IsNullOrEmpty(), x => x.LocationInfo != null && deviceCode.Contains(x.LocationInfo.RoadwayNo)) |
| | | .WhereIF(!materielCodes.IsNullOrEmpty(), x => x.StockInfoDetails != null && x.StockInfoDetails.Any(y => materielCodes.Contains(y.MaterielCode))) |
| | | .FirstOrDefault(); |
| | | |
| | | if (stockInfo == null) throw new Exception($"库内{station.productLine}无满足条件的库存可出库"); |
| | | |
| | |
| | | stockInfo.LocationInfo.LocationStatus = (int)LocationEnum.InStockDisable; |
| | | _locationRepository.UpdateData(stockInfo.LocationInfo); |
| | | |
| | | _simpleCacheService.HashDel<DtStockInfo>(WIDESEA_Cache.CacheConst.Cache_DtStockInfo, new string[] { taskDTO.PalletCode }); |
| | | //_simpleCacheService.HashDel<DtStockInfo>(WIDESEA_Cache.CacheConst.Cache_DtStockInfo, new string[] { taskDTO.PalletCode }); |
| | | |
| | | _locationStatusChangeRecordRepository.AddLocationStatusChangeRecord(stockInfo.LocationInfo, lastStatus, (int)StatusChangeTypeEnum.AutomaticDelivery, task.TaskNum); |
| | | |