Code Management/WCS/WIDESEAWCS_Client/src/api/http.js
@@ -20,7 +20,7 @@ } else if (process.env.NODE_ENV == 'production') { axios.defaults.baseURL = 'http://192.168.15.253:9291/'; axios.defaults.baseURL = 'http://192.168.20.253:9291/'; } if (!axios.defaults.baseURL.endsWith('/')) { axios.defaults.baseURL+="/"; Code Management/WCS/WIDESEAWCS_Client/src/extension/system/Sys_User/Sys_UserGridHeader.vue
@@ -62,7 +62,7 @@ "/api/user/modifyUserPwd?password=" + this.password + "&userName=" + this.row.UserName; this.row.userName; this.http.post(url, {}, true).then((x) => { if (!x.status) { return this.$message.error(x.message); Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Communicator/Siemens/SiemensS7Communicator.cs
@@ -159,7 +159,7 @@ { //return true; object? obj = null; for (int i = 0; i < 3; i++) for (int i = 0; i < 5; i++) { T readValue = Read<T>(address); stringBuilder.AppendLine(string.Format(CommunicationInfoMessage.WriteAfterRead, readValue, value)); @@ -169,7 +169,7 @@ stringBuilder.AppendLine(string.Format(CommunicationInfoMessage.WriteAndReadCheckSuccess, address, value, readValue)); return true; } else if (i < 2) else if (i < 4) { Write(address, value); } @@ -608,7 +608,7 @@ if (operateResult.IsSuccess) { object? obj = null; for (int i = 0; i < 2; i++) for (int i = 0; i < 5; i++) { T readValue = ReadCustomer<T>(address); stringBuilder.AppendLine(string.Format(CommunicationInfoMessage.WriteAfterRead, address, JsonConvert.SerializeObject(readValue))); Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_ISystemServices/ISys_UserService.cs
@@ -18,5 +18,7 @@ WebResponseContent GetCurrentUserInfo(); WebResponseContent ModifyPwd(string oldPwd, string newPwd); WebResponseContent ModifyUserPwd(string password, string userName); } } Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/System/Sys_UserController.cs
@@ -44,7 +44,13 @@ { return Json(Service.ModifyPwd(oldPwd, newPwd)); } //只能超级管理员才能修改密码 //2020.08.01增加修改密码功能 [HttpPost, Route("modifyUserPwd")] public IActionResult ModifyUserPwd(string password, string userName) { return Json(Service.ModifyUserPwd(password, userName)); } [HttpGet, Route("getVierificationCode"), AllowAnonymous] public IActionResult GetVierificationCode() { Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_SystemServices/Sys_UserService.cs
@@ -183,5 +183,27 @@ } return content; } public WebResponseContent ModifyUserPwd(string password, string userName) { WebResponseContent webResponse = new WebResponseContent(); if (string.IsNullOrEmpty(password) || string.IsNullOrEmpty(userName)) { return webResponse.Error("参数不完整"); } if (password.Length < 6) return webResponse.Error("密码长度不能少于6位"); Sys_User user = BaseDal.QueryFirst(x => x.UserName == userName); if (user == null) { return webResponse.Error("用户不存在"); } user.UserPwd = password.EncryptDES(AppSecret.User); BaseDal.UpdateData(user); //如果用户在线,强制下线 //UserContext.Current.LogOut(user.User_Id); return webResponse.OK("密码修改成功"); } } } Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs
@@ -646,7 +646,7 @@ task.ModifyDate = DateTime.Now; task.Modifier = "System"; BaseDal.UpdateData(task); _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskId, $"系统自动流程,更新当前位置【{oldCurrentPos} ----> {task.CurrentAddress}】和下一位置【{oldNextPos} ----> {task.NextAddress}】"); return task; Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs
@@ -403,6 +403,7 @@ WriteInfo(conveyorLine.DeviceName, logs); conveyorLine.SendCommand(taskCommand, childDeviceCode); _taskService.UpdateData(newTask); } } } @@ -584,6 +585,8 @@ // 标记输送线发送任务完成 ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true); _taskService.UpdateData(newTask); } } } Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/CommonConveyorLine_GWJob.cs
@@ -244,13 +244,10 @@ Dt_Task? newTask = _taskService.UpdatePosition(task.TaskNum, task.CurrentAddress); if (newTask != null) { //conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTaskNum, newTask.TaskNum, childDeviceCode); //conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTargetAddress, newTask.NextAddress, childDeviceCode); //conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineBarcode, command.ConveyorLineBarcode, childDeviceCode); ConveyorLineTaskCommand_After taskCommand = _mapper.Map<ConveyorLineTaskCommand_After>(newTask); //taskCommand.InteractiveSignal = command.InteractiveSignal; conveyorLine.SendCommand(taskCommand, childDeviceCode); conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, 1, childDeviceCode); _taskService.UpdateData(newTask); } } } @@ -267,8 +264,6 @@ var task = _taskService.QueryExecutingTaskByBarcode(command.ConveyorLineBarcode, childDeviceCode); if (task != null && task.TaskState != (int)TaskInStatusEnum.Line_InFinish) { //ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true); WebResponseContent content = _taskService.UpdateTaskStatusToNext(task); if (content.Status) @@ -350,6 +345,7 @@ ConveyorLineTaskCommand_After taskCommand = _mapper.Map<ConveyorLineTaskCommand_After>(newTask); conveyorLine.SendCommand(taskCommand, childDeviceCode); conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, 1, childDeviceCode); _taskService.UpdateData(newTask); } } else Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs
@@ -196,6 +196,7 @@ { task = _taskRepository.QueryFirst(x => x.TaskNum == e.TaskNum); Dt_Task? newTask = _taskService.UpdatePosition(task.TaskNum, task.CurrentAddress); _taskService.UpdateData(newTask); } if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup && (task.TargetAddress == "002-021-001" || task.TargetAddress == "001-021-001")) { Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MCS/Partial/NotifyFinishTest.cs
@@ -108,7 +108,7 @@ location.LocationStatus = (int) LocationEnum.InStockDisable; _locationRepository.UpdateData(location); _simpleCacheService.HashDel<DtStockInfo>(WIDESEA_Cache.CacheConst.Cache_DtStockInfo, new string[] { taskDTO.PalletCode }); //_simpleCacheService.HashDel<DtStockInfo>(WIDESEA_Cache.CacheConst.Cache_DtStockInfo, new string[] { taskDTO.PalletCode }); } else Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicServices/Stock/StockInfoService.cs
@@ -115,7 +115,14 @@ _locationStatusChangeRecordRepository.AddLocationStatusChangeRecord(location, lastStatus, (int)StatusChangeTypeEnum.ManualOperation, 0); } _simpleCacheService.HashDel<DtStockInfo>(CacheConst.Cache_DtStockInfo, stocks.ToArray()); //_simpleCacheService.HashDel<DtStockInfo>(CacheConst.Cache_DtStockInfo, stocks.ToArray()); //var hty = BaseDal.Db.InsertNav(stockInfos) // .Include(x => x.StockInfoDetails) // .ExecuteCommand(); //var locationd = SqlSugarHelper.DbWMS.Updateable(locationInfos).ExecuteCommandHasChange(); //return base.DeleteData(keys); var hty = BaseDal.Db.InsertNav(stockInfos) .Include(x => x.StockInfoDetails) .ExecuteCommand(); Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/AspNetCoreSchedule.cs
@@ -48,13 +48,21 @@ if (area == null) { return; } 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 stockInfo = stockInfoList.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(); // 获取第一个元素 //var stockInfo = stockInfoList.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(); // 获取第一个元素 var stockInfo = _stockInfoRepository.Db.Queryable<DtStockInfo>() .Where(x => x.AreaCode == area.AreaCode && x.OutboundTime < DateTime.Now && x.IsFull == true) .Includes(x => x.LocationInfo) .Where(x => x.LocationInfo.LocationStatus == (int)LocationEnum.InStock && x.LocationInfo.AreaId == area.AreaID) // 过滤条件 .Includes(x => x.StockInfoDetails) .OrderBy(x => x.OutboundTime) // 排序 .ToList(); // 获取第一个元素 if (stockInfo.Count <= 0) return; foreach (var item in stockInfo) @@ -93,7 +101,7 @@ _taskRepository.AddData(task); // 更新库存位置状态为不可用 item.LocationInfo.LocationStatus = (int)LocationEnum.InStockDisable; _simpleCacheService.HashDel<DtStockInfo>(WIDESEA_Cache.CacheConst.Cache_DtStockInfo, new string[] { taskDTO.PalletCode }); //_simpleCacheService.HashDel<DtStockInfo>(WIDESEA_Cache.CacheConst.Cache_DtStockInfo, new string[] { taskDTO.PalletCode }); _locationRepository.UpdateData(item.LocationInfo); } } Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs
@@ -135,14 +135,14 @@ await DeleteTaskAsync(task.TaskId); await AddTaskHtyAsync(taskHty); }); try { _simpleCacheService.HashDel<DtStockInfo>(WIDESEA_Cache.CacheConst.Cache_DtStockInfo, new string[] { stock.PalletCode }); } catch (Exception ex) { LogFactory.GetLog("删除缓存失败").Error(true, $"{stock.PalletCode}_删除缓存失败,异常信息:{ex.Message}"); } //try //{ // _simpleCacheService.HashDel<DtStockInfo>(WIDESEA_Cache.CacheConst.Cache_DtStockInfo, new string[] { stock.PalletCode }); //} //catch (Exception ex) //{ // LogFactory.GetLog("删除缓存失败").Error(true, $"{stock.PalletCode}_删除缓存失败,异常信息:{ex.Message}"); //} return content.OK("任务完成成功", task.Remark); } @@ -380,16 +380,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("入库任务完成成功"); } @@ -990,28 +980,21 @@ .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 (areaCode == "CH001") { LogFactory.GetLog("CH001").Info(true, JsonConvert.SerializeObject(stockInfoList[0], Formatting.Indented)); } result = await _stockInfoRepository.Db.Queryable<DtStockInfo>() .Includes(x => x.LocationInfo) .Includes(x => x.StockInfoDetails) .Where(x => x.AreaCode == areaCode && x.OutboundTime < DateTime.Now && x.IsFull) .WhereIF(!productionLine.IsNullOrEmpty(), x => x.ProductionLine == productionLine) .WhereIF(!devices.IsNullOrEmpty(), x => devices.Contains(x.LocationInfo.RoadwayNo)) .Where(x => x.LocationInfo.LocationStatus == (int)LocationEnum.InStock && x.LocationInfo.AreaId == area.AreaID && x.LocationInfo.EnalbeStatus == (int)EnableEnum.Enable) .WhereIF(!materielCodes.IsNullOrEmpty(), x => x.StockInfoDetails.Any(y => materielCodes.Contains(y.MaterielCode))) .OrderBy(x => x.OutboundTime) .FirstAsync(); result = stockInfoList.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(); if (result != null) _simpleCacheService.HashDel<DtStockInfo>(WIDESEA_Cache.CacheConst.Cache_DtStockInfo, new string[] { result.PalletCode }); else ConsoleHelper.WriteErrorLine($"{areaCode}-{productionLine}查询实盘库存信息失败:未找到符合条件的数据"); if (result.IsNullOrEmpty()) ConsoleHelper.WriteErrorLine($"{area.AreaName}-{productionLine}查询实盘库存信息失败:未找到符合条件的数据"); return result; } @@ -1054,27 +1037,20 @@ .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>() .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) // 过滤条件 .Includes(x => x.LocationInfo) .WhereIF(!deviceCode.IsNullOrEmpty(), x => deviceCode.Contains(x.LocationInfo.RoadwayNo)) .WhereIF(!materielCodes.IsNullOrEmpty(), x => x.StockInfoDetails != null && x.StockInfoDetails.Any(y => materielCodes.Contains(y.MaterielCode))) .Where(x => x.LocationInfo.LocationStatus == (int)LocationEnum.InStock && areaId.Contains(x.LocationInfo.AreaId) && x.LocationInfo.EnalbeStatus == (int)EnableEnum.Enable) // 过滤条件 .Includes(x => x.StockInfoDetails) .WhereIF(!materielCodes.IsNullOrEmpty(), x => 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; } @@ -1105,21 +1081,19 @@ .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>() .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) // 过滤条件 .Includes(x => x.StockInfoDetails) .Where(x => x.StockInfoDetails.Any(y => y.MaterielCode == "空托盘")) .Includes(x => x.LocationInfo) .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) // 过滤条件 .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; } Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/Dt_TaskService.cs
@@ -541,13 +541,17 @@ 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; @@ -569,7 +573,7 @@ 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) @@ -980,23 +984,36 @@ .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; } @@ -1033,24 +1050,38 @@ .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}无满足条件的库存可出库"); @@ -1087,7 +1118,7 @@ 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);