CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_After/CommonConveyorLine_AfterJob.cs
@@ -185,7 +185,7 @@ var taskNew = _taskRepository.QueryData(x => x.TargetAddress == stationInfo.stationChildCode && x.TaskType == (int)TaskOutboundTypeEnum.OutTray); var need = _needBarcodeRepository.QueryFirst(x => x.toArea == stationInfo.stationChildCode && x.productLine == stationInfo.productLine); var cache = command.Reserved5; if (taskNew.Count < need.cacheNum) //不存在空框出库任务 则请求WMS出空库 if (taskNew.Count + 2 < cache) //不存在空框出库任务 则请求WMS出空库 { //ConsoleHelper.WriteWarningLine("请求空托盘"); if (_taskService.RequestTask(command.ConveyorLineBarcode, stationInfo).Result.Status) CodeManagement/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/copilot-chat/bef6627e/sessions/04d18d8c-b910-43c8-aa25-623d0e81cddcBinary files differ
CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MCS/Partial/NotifyFinishTest.cs
@@ -108,7 +108,6 @@ location.LocationStatus = (int) LocationEnum.InStockDisable; _locationRepository.UpdateData(location); _simpleCacheService.HashDel<DtStockInfo>(WIDESEA_Cache.CacheConst.Cache_DtStockInfo, new string[] { taskDTO.PalletCode }); } else CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicServices/Stock/StockInfoService.cs
@@ -115,7 +115,6 @@ _locationStatusChangeRecordRepository.AddLocationStatusChangeRecord(location, lastStatus, (int)StatusChangeTypeEnum.ManualOperation, 0); } _simpleCacheService.HashDel<DtStockInfo>(CacheConst.Cache_DtStockInfo, stocks.ToArray()); var hty = BaseDal.Db.InsertNav(stockInfos) .Include(x => x.StockInfoDetails) .ExecuteCommand(); CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/AspNetCoreSchedule.cs
@@ -48,10 +48,9 @@ if (area == null) { return; } IDictionary<string, DtStockInfo>? stockInfos = _simpleCacheService.HashGetAll<DtStockInfo>(WIDESEA_Cache.CacheConst.Cache_DtStockInfo); List<DtStockInfo> stockInfoList = stockInfos.Values.ToList(); var stockInfo = stockInfoList.Where(x => x.AreaCode == area.AreaCode && x.OutboundTime < DateTime.Now && x.IsFull == true) // 过滤条件 var stockInfo = _stockInfoRepository.Db.Queryable<DtStockInfo>() .IncludesAllFirstLayer() .Where(x => x.AreaCode == area.AreaCode && x.OutboundTime < DateTime.Now && x.IsFull == true) // 过滤条件 .Where(x => x.LocationInfo != null && x.LocationInfo.LocationStatus == (int)LocationEnum.InStock && x.LocationInfo.AreaId == area.AreaID) // 过滤条件 .OrderBy(x => x.OutboundTime) // 排序 .ToList(); // 获取第一个元素 @@ -67,10 +66,18 @@ } string position = string.Empty; if (item.LocationInfo.RoadwayNo == "GWSC1") position = "1059"; else position = "1065"; switch (item.LocationInfo.RoadwayNo) { case "GWSC1": position = "3101"; break; case "GWSC2": position = "3104"; break; default: position = "3107"; break; } var task = CreateTask(item, position, (int)TaskOutboundTypeEnum.Outbound); task.NextAddress = "002-000-002"; @@ -93,7 +100,6 @@ _taskRepository.AddData(task); // 更新库存位置状态为不可用 item.LocationInfo.LocationStatus = (int)LocationEnum.InStockDisable; _simpleCacheService.HashDel<DtStockInfo>(WIDESEA_Cache.CacheConst.Cache_DtStockInfo, new string[] { taskDTO.PalletCode }); _locationRepository.UpdateData(item.LocationInfo); } } CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs
@@ -135,20 +135,6 @@ await DeleteTaskAsync(task.TaskId); await AddTaskHtyAsync(taskHty); }); try { //using (_simpleCacheService.AcquireLock(WIDESEA_Cache.CacheConst.Cache_DtStockInfo, 2000)) //{ _simpleCacheService.HashDel<DtStockInfo>(WIDESEA_Cache.CacheConst.Cache_DtStockInfo, new string[] { stock.PalletCode }); //} } catch (Exception ex) { LogFactory.GetLog("删除缓存失败").Error(true, $"{stock.PalletCode}_删除缓存失败,异常信息:{ex.Message}"); //using (_simpleCacheService.AcquireLock(WIDESEA_Cache.CacheConst.Cache_DtStockInfo, 2000)) //{ //} } return content.OK("任务完成成功", task.Remark); } @@ -386,16 +372,6 @@ stock.StockInfoDetails = new List<DtStockInfoDetail>() { { stock.StockInfoDetails[0] } }; stock.LocationInfo = locationInf; //using(_simpleCacheService.AcquireLock(WIDESEA_Cache.CacheConst.Cache_DtStockInfo, 2000)) //{ try { _simpleCacheService.HashAdd(WIDESEA_Cache.CacheConst.Cache_DtStockInfo, stock.PalletCode, stock); } catch (Exception ex) { LogFactory.GetLog("添加缓存失败").Error(true, $"{stock.PalletCode}_添加缓存失败,异常信息:{ex.Message}"); } content.OK("入库任务完成成功"); } @@ -659,7 +635,6 @@ var taskDTOs = CreateTaskDTO(taskNews); BaseDal.AddData(taskNews); return content.OK(data: taskDTOs); // 查询任务 var task = await QueryTaskByPalletCode(input.PalletCode); @@ -989,34 +964,26 @@ .ToList() : null; IDictionary<string, DtStockInfo>? stockInfos = _simpleCacheService.HashGetAll<DtStockInfo>(WIDESEA_Cache.CacheConst.Cache_DtStockInfo); List<DtStockInfo> stockInfoList = stockInfos.Values.ToList(); var result = new DtStockInfo(); //if (stockInfoList.IsNullOrEmpty()) //{ // stockInfoList = await _stockInfoRepository.Db.Queryable<DtStockInfo>() // .Where(x => x.LocationInfo.LocationStatus == (int)LocationEnum.InStock).IncludesAllFirstLayer().ToListAsync(); //} result = stockInfoList.Where(x => x.AreaCode == areaCode && x.OutboundTime < DateTime.Now && x.IsFull) result = await _stockInfoRepository.Db.Queryable<DtStockInfo>() .IncludesAllFirstLayer() .Where(x => x.AreaCode == areaCode && x.OutboundTime < DateTime.Now && x.IsFull) .WhereIF(!productionLine.IsNullOrEmpty(), x => x.ProductionLine == productionLine) .Where(x => x.LocationInfo != null && x.LocationInfo.LocationStatus == (int)LocationEnum.InStock && x.LocationInfo.AreaId == area.AreaID && x.LocationInfo.EnalbeStatus == (int)EnableEnum.Enable) .WhereIF(!devices.IsNullOrEmpty(), x => devices.Contains(x.LocationInfo.RoadwayNo)) .WhereIF(!materielCodes.IsNullOrEmpty(), x => x.StockInfoDetails != null && x.StockInfoDetails.Any(y => materielCodes.Contains(y.MaterielCode))) .OrderBy(x => x.OutboundTime) .FirstOrDefault(); .FirstAsync(); if (result != null) _simpleCacheService.HashDel<DtStockInfo>(WIDESEA_Cache.CacheConst.Cache_DtStockInfo, new string[] { result.PalletCode }); else ConsoleHelper.WriteErrorLine("QueryStockInfoForRealTrayAsync查询实盘库存信息失败:未找到符合条件的数据"); if (result.IsNullOrEmpty()) ConsoleHelper.WriteErrorLine($"{area.AreaName}-{productionLine}查询实盘库存信息失败:未找到符合条件的数据"); return result; } catch (Exception ex) { ConsoleHelper.WriteErrorLine("QueryStockInfoForRealTrayAsync查询实盘库存信息失败:" + ex.Message + "\r\n" + ex.StackTrace); ConsoleHelper.WriteErrorLine("查询实盘库存信息失败:" + ex.Message + "\r\n" + ex.StackTrace); return null; } } @@ -1053,27 +1020,19 @@ .Where(x => x.DeviceStatus == "1") .Where(x => x.DeviceCode.Contains("CWSC")) .ToList().Select(x => x.DeviceCode).ToList(); //var deviceCode = devices.Select(x => x.DeviceCode).ToList(); IDictionary<string, DtStockInfo>? stockInfos = _simpleCacheService.HashGetAll<DtStockInfo>(WIDESEA_Cache.CacheConst.Cache_DtStockInfo); List<DtStockInfo> stockInfoList = stockInfos.Values.ToList(); var result = stockInfoList.Where(x => areaCodes.Contains(x.AreaCode) && x.OutboundTime < DateTime.Now && x.IsFull == true) // 过滤条件 var result = await _stockInfoRepository.Db.Queryable<DtStockInfo>() .IncludesAllFirstLayer() .Where(x => areaCodes.Contains(x.AreaCode) && x.OutboundTime < DateTime.Now && x.IsFull == true) // 过滤条件 .WhereIF(!productionLine.IsNullOrEmpty(), x => x.ProductionLine == productionLine) .Where(x => x.LocationInfo != null && x.LocationInfo.LocationStatus == (int)LocationEnum.InStock && areaId.Contains(x.LocationInfo.AreaId) && x.LocationInfo.EnalbeStatus == (int)EnableEnum.Enable) // 过滤条件 .WhereIF(!deviceCode.IsNullOrEmpty(), x => deviceCode.Contains(x.LocationInfo.RoadwayNo)) .WhereIF(!materielCodes.IsNullOrEmpty(), x => x.StockInfoDetails != null && x.StockInfoDetails.Any(y => materielCodes.Contains(y.MaterielCode))) .OrderBy(x => x.OutboundTime) // 排序 .FirstOrDefault(); // 获取第一个元素 .FirstAsync(); // 获取第一个元素 if (result != null) { _simpleCacheService.HashDel<DtStockInfo>(WIDESEA_Cache.CacheConst.Cache_DtStockInfo, new string[] { result.PalletCode }); } else { ConsoleHelper.WriteErrorLine("QueryStockInfoForRealTrayCWAsync查询常温实盘库存信息失败:未找到符合条件的数据"); } if (result.IsNullOrEmpty()) ConsoleHelper.WriteErrorLine($"{JsonConvert.SerializeObject(areaCodes)}-{productionLine}查询常温实盘库存信息失败:未找到符合条件的数据"); return result; } @@ -1104,27 +1063,24 @@ .Where(x => stackers.Contains(x.DeviceCode)) .ToList().Select(x => x.DeviceCode).ToList(); IDictionary<string, DtStockInfo>? stockInfos = _simpleCacheService.HashGetAll<DtStockInfo>(WIDESEA_Cache.CacheConst.Cache_DtStockInfo); List<DtStockInfo> stockInfoList = stockInfos.Values.ToList(); var result = stockInfoList.Where(x => x.ProductionLine == station.productLine) var result = await _stockInfoRepository.Db.Queryable<DtStockInfo>() .IncludesAllFirstLayer() .Where(x => x.ProductionLine == station.productLine) .Where(x => x.AreaCode == areaCode && x.IsFull == false) .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) // 过滤条件 .WhereIF(!deviceCode.IsNullOrEmpty(), x => deviceCode.Contains(x.LocationInfo.RoadwayNo)) .OrderBy(x => x.CreateDate) // 排序 .FirstOrDefault(); // 转换为列表 .FirstAsync(); // 转换为列表 if (result != null) _simpleCacheService.HashDel<DtStockInfo>(WIDESEA_Cache.CacheConst.Cache_DtStockInfo, new string[] { result.PalletCode }); else ConsoleHelper.WriteErrorLine("QueryStockInfoForEmptyTrayAsync查询空盘库存信息失败:未找到符合条件的数据"); if (result.IsNullOrEmpty()) ConsoleHelper.WriteErrorLine($"{area}-{station.productLine}查询空盘库存信息失败:未找到符合条件的数据"); return result; } catch (Exception ex) { ConsoleHelper.WriteErrorLine("QueryStockInfoForEmptyTrayAsync查询实盘库存信息失败:" + ex.Message + "\r\n" + ex.StackTrace); ConsoleHelper.WriteErrorLine($"QueryStockInfoForEmptyTrayAsync查询实盘库存信息失败:" + ex.Message + "\r\n" + ex.StackTrace); return null; } } CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/Dt_TaskService.cs
@@ -540,15 +540,6 @@ { 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(); //var stockinfo1 = stockInfoList.OrderBy(x => x.CreateDate) // .ToList(); //var strings = stationManager.Roadway.Split(","); //var stockinfo = stockinfo1.Where(x => x.LocationInfo != null && !x.IsFull && strings.Contains(x.LocationInfo.RoadwayNo)) // .FirstOrDefault(); var stockInfo = await QueryStockInfoForEmptyTrayFRAsync("CWSC1", "10086", input.ProductionLine); if (stockInfo == null) return null; @@ -571,7 +562,6 @@ Creater = "System", ProductionLine = stockInfo.ProductionLine, }; _simpleCacheService.HashDel<DtStockInfo>(WIDESEA_Cache.CacheConst.Cache_DtStockInfo, new string[] { task.PalletCode }); return task; } catch (Exception ex) @@ -981,24 +971,18 @@ .Where(x => stackers.Contains(x.DeviceCode)) .ToList().Select(x => x.DeviceCode).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) var result = await _stockInfoRepository.Db.Queryable<DtStockInfo>() .IncludesAllFirstLayer().Where(x => x.ProductionLine == productLine) .Where(x => x.AreaCode == areaCode && x.IsFull == false) .Where(x => x.StockInfoDetails != null && x.StockInfoDetails.Any(y => y.MaterielCode == "空托盘")) .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(); // 获取第一个元素 .OrderBy(x => x.CreateDate) // 排序 .FirstAsync(); if (result != null) _simpleCacheService.HashDel<DtStockInfo>(WIDESEA_Cache.CacheConst.Cache_DtStockInfo, new string[] { result.PalletCode }); else if (result.IsNullOrEmpty()) ConsoleHelper.WriteColorLine($"常温{productLine}空托盘库存不足", ConsoleColor.Red); return result; } @@ -1028,25 +1012,20 @@ .Where(x => x.DeviceCode.Contains("CWSC")) // 过滤条件 .ToList().Select(x => x.DeviceCode).ToList(); // 从缓存中获取库存信息 IDictionary<string, DtStockInfo>? stockInfos = _simpleCacheService.HashGetAll<DtStockInfo>(WIDESEA_Cache.CacheConst.Cache_DtStockInfo); List<DtStockInfo> stockInfoList = stockInfos.Values.ToList(); // 修改后的查询代码 var stockInfo1 = stockInfoList var stockInfo = await _stockInfoRepository.Db.Queryable<DtStockInfo>() .IncludesAllFirstLayer() .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)) .FirstOrDefault(); .OrderBy(x => x.OutboundTime) .FirstAsync(); if (stockInfo == null) throw new Exception($"库内{station.productLine}无满足条件的库存可出库"); if (stockInfo.IsNullOrEmpty()) throw new Exception($"库内{station.productLine}无满足条件的库存可出库"); DtLocationInfo locationInfo = _locationRepository.QueryFirst(x => x.AreaId == 5 && x.LocationCode == stockInfo.LocationCode); @@ -1081,7 +1060,6 @@ stockInfo.LocationInfo.LocationStatus = (int)LocationEnum.InStockDisable; _locationRepository.UpdateData(stockInfo.LocationInfo); _simpleCacheService.HashDel<DtStockInfo>(WIDESEA_Cache.CacheConst.Cache_DtStockInfo, new string[] { taskDTO.PalletCode }); _locationStatusChangeRecordRepository.AddLocationStatusChangeRecord(stockInfo.LocationInfo, lastStatus, (int)StatusChangeTypeEnum.AutomaticDelivery, task.TaskNum);