更新多个文件,优化逻辑和异常处理
更新 .gitignore,忽略所有 XML 文件。
在 `HttpHelper.cs` 的 `PostAsync` 方法中优化请求跟踪和异常处理。
增强 `CommonConveyorLineJob.cs` 中对 `DeviceProAddress` 的处理逻辑。
扩展 `CommonStackerCraneJob.cs` 中设备状态判断的条件逻辑,更新异常信息。
在 `ProcessApplyService.cs` 中改进库存查询和异常反馈。
在 `Dt_TaskService.cs` 中强化反序列化处理,确保所有异常电芯状态被捕获。
| | |
| | | /Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/obj/Debug/net6.0/WIDESEA_WMSServer.csproj.CopyComplete |
| | | /Code Management/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/copilot-chat/bef6627e/sessions/22de66c6-d93f-400b-aaa1-cc12e218c2e7 |
| | | /Code Management/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/copilot-chat/bef6627e/sessions/36708593-3f69-4656-815a-651b3ad17c7d |
| | | *.xml |
| | |
| | | { |
| | | try |
| | | { |
| | | // 将 JSON 字符串转换为字典 |
| | | var parameters = JsonConvert.DeserializeObject<Dictionary<string, object>>(requestJson); |
| | | |
| | | // 创建一个新的字典,排除 RequestTime 和 SessionId |
| | | var filteredParameters = parameters.Where(p => p.Key != "RequestTime" && p.Key != "SessionId").ToDictionary(p => p.Key, p => p.Value); |
| | | |
| | | string requestKey = $"{serviceAddress}:{JsonConvert.SerializeObject(filteredParameters)}"; |
| | | |
| | | // 检查请求次数和时间限制 |
| | | if (requestTracker.TryGetValue(requestKey, out var requestInfo)) |
| | | if (serviceAddress.Contains("http://c24-cellmi3:12020")) |
| | | { |
| | | if (requestInfo.Count >= 5 && DateTime.Now < requestInfo.LastRequestTime.AddMinutes(10)) |
| | | // 将 JSON 字符串转换为字典 |
| | | var parameters = JsonConvert.DeserializeObject<Dictionary<string, object>>(requestJson); |
| | | |
| | | // 创建一个新的字典,排除 RequestTime 和 SessionId |
| | | var filteredParameters = parameters.Where(p => p.Key != "RequestTime" && p.Key != "SessionId").ToDictionary(p => p.Key, p => p.Value); |
| | | |
| | | string requestKey = $"{serviceAddress}:{JsonConvert.SerializeObject(filteredParameters)}"; |
| | | |
| | | // 检查请求次数和时间限制 |
| | | if (requestTracker.TryGetValue(requestKey, out var requestInfo)) |
| | | { |
| | | // 如果请求次数超过限制且未超过10分钟,抛出异常 |
| | | throw new InvalidOperationException("请求次数已达到限制,请稍后再试。"); |
| | | if (requestInfo.Count >= 5 && DateTime.Now < requestInfo.LastRequestTime.AddMinutes(10)) |
| | | { |
| | | // 如果请求次数超过限制且未超过10分钟,抛出异常 |
| | | throw new InvalidOperationException("请求次数已达到限制,请稍后再试。"); |
| | | } |
| | | } |
| | | |
| | | // 更新请求跟踪信息 |
| | | if (requestTracker.ContainsKey(requestKey)) |
| | | { |
| | | requestTracker[requestKey] = (requestInfo.Count + 1, DateTime.Now); |
| | | } |
| | | else |
| | | { |
| | | requestTracker[requestKey] = (1, DateTime.Now); |
| | | } |
| | | } |
| | | |
| | | // 更新请求跟踪信息 |
| | | if (requestTracker.ContainsKey(requestKey)) |
| | | { |
| | | requestTracker[requestKey] = (requestInfo.Count + 1, DateTime.Now); |
| | | } |
| | | else |
| | | { |
| | | requestTracker[requestKey] = (1, DateTime.Now); |
| | | } |
| | | |
| | | string result = string.Empty; |
| | | using (HttpContent httpContent = new StringContent(requestJson)) |
| | | { |
| | |
| | | // 将修改后的数组x重新拼接成字符串,作为新的DeviceProAddress |
| | | string DeviceProAddress = string.Join(".", x); |
| | | |
| | | // 使用conveyorLine的Communicator对象的Write方法,将value写入新的DeviceProAddress地址 |
| | | conveyorLine.Communicator.Write(DeviceProAddress, value); |
| | | var writeBool = conveyorLine.Communicator.Read<bool>(DeviceProAddress); |
| | | if (writeBool != value) |
| | | { |
| | | // 使用conveyorLine的Communicator对象的Write方法,将value写入新的DeviceProAddress地址 |
| | | conveyorLine.Communicator.Write(DeviceProAddress, value); |
| | | } |
| | | } |
| | | |
| | | #region 检测空盘实盘任务 |
| | |
| | | } |
| | | else |
| | | { |
| | | //Dt_Router? router = _routerService.QueryNextRoutes(task.Roadway, task.NextAddress).FirstOrDefault(); |
| | | if (router != null) |
| | | if ((task.NextAddress == ("002-021-001") || task.NextAddress == ("001-021-001")) && task.Roadway.Contains("JZ")) |
| | | { |
| | | IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == router.ChildPosiDeviceCode); |
| | | if (device != null) |
| | | return task; |
| | | } |
| | | else |
| | | { |
| | | //Dt_Router? router = _routerService.QueryNextRoutes(task.Roadway, task.NextAddress).FirstOrDefault(); |
| | | if (router != null) |
| | | { |
| | | CommonConveyorLine conveyorLine = (CommonConveyorLine)device; |
| | | if (conveyorLine.IsOccupiedx(router.ChildPosi))//出库站台未被占用 |
| | | IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == router.ChildPosiDeviceCode); |
| | | if (device != null) |
| | | { |
| | | return task; |
| | | CommonConveyorLine conveyorLine = (CommonConveyorLine)device; |
| | | if (conveyorLine.IsOccupiedx(router.ChildPosi))//出库站台未被占用 |
| | | { |
| | | return task; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"未找到出库站台【{router.ChildPosiDeviceCode}】对应的通讯对象,无法判断出库站台是否被占用"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"未找到出库站台【{router.ChildPosiDeviceCode}】对应的通讯对象,无法判断出库站台是否被占用"); |
| | | _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"未找到站台【{task.NextAddress}】信息,无法校验站台"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"未找到站台【{task.NextAddress}】信息,无法校验站台"); |
| | | } |
| | | } |
| | | return null; |
| | |
| | | var result = JsonConvert.DeserializeObject<ResultTrayCellsStatus>(content.Data.ToString()); |
| | | if (result.SerialNos.Count > 0) |
| | | { |
| | | var stockHty = await SqlSugarHelper.DbWMS.Queryable<DtStockInfo>().IncludesAllFirstLayer().FirstAsync(); |
| | | if (stockHty != null) |
| | | var stock = await SqlSugarHelper.DbWMS.Queryable<DtStockInfo>().FirstAsync(x => x.PalletCode == palletCode); |
| | | if (stock != null) |
| | | { |
| | | var parameterInfo = JsonConvert.DeserializeObject<List<ParameterInfo>>(stockHty.ParameterInfos).FirstOrDefault(y => y.Description.Contains("时间")); |
| | | var parameterInfo = JsonConvert.DeserializeObject<List<ParameterInfo>>(stock.ParameterInfos).FirstOrDefault(y => y.Description.Contains("时间")); |
| | | if (parameterInfo == null) throw new Exception(""); |
| | | |
| | | var outHours = (DateTime.Now - (stockHty.LinedProcessFeedbackTime == null ? stockHty.ModifyDate.Value : stockHty.LinedProcessFeedbackTime.ToDateTime())).TotalHours; |
| | | var outHours = (DateTime.Now - (stock.LinedProcessFeedbackTime == null ? stock.ModifyDate.Value : stock.LinedProcessFeedbackTime.ToDateTime())).TotalHours; |
| | | var isNG = outHours > parameterInfo.LowerSpecificationsLimit.ToDouble() && outHours < parameterInfo.UpperSpecificationsLimit.ToDouble(); |
| | | |
| | | var defectCode = string.Empty; |
| | |
| | | }; |
| | | content = await _gingInOrOutInputService.GetOCVOutputAsync(outputDto); |
| | | } |
| | | else |
| | | { |
| | | var stockHty = await SqlSugarHelper.DbWMS.Queryable<DtStockInfo_Hty>().Where(x => x.PalletCode == palletCode).OrderByDescending(x => x.CreateDate).FirstAsync(); |
| | | if (stockHty != null) |
| | | { |
| | | var parameterInfo = JsonConvert.DeserializeObject<List<ParameterInfo>>(stockHty.ParameterInfos).FirstOrDefault(y => y.Description.Contains("时间")); |
| | | if (parameterInfo == null) throw new Exception(""); |
| | | |
| | | var outHours = (DateTime.Now - (stockHty.LinedProcessFeedbackTime == null ? "2025-01-08 15:59:34.310".ToDateTime() : stockHty.LinedProcessFeedbackTime.ToDateTime())).TotalHours; |
| | | var isNG = outHours > parameterInfo.LowerSpecificationsLimit.ToDouble() && outHours < parameterInfo.UpperSpecificationsLimit.ToDouble(); |
| | | |
| | | var defectCode = string.Empty; |
| | | if (!isNG) defectCode = "TQCK"; |
| | | var outputDto = new AgingOutputDto |
| | | { |
| | | OpFlag = 1, |
| | | Software = area.Spare3, |
| | | EquipmentCode = area.Spare2, |
| | | TrayBarcode = palletCode, |
| | | SerialNos = result.SerialNos.Select(x => new SerialNoOutDto |
| | | { |
| | | SlotNo = x.PositionNo, |
| | | SerialNo = x.SerialNo, |
| | | SerialNoResult = true, //isNG, |
| | | ParameterInfo = new List<ParameterInfoOutput> { |
| | | new ParameterInfoOutput() { |
| | | Value = outHours.ToString(), |
| | | ParameterCode =parameterInfo.ParameterCode, |
| | | ParameterDesc = parameterInfo.Description, |
| | | ParameterResult = "OK", //isNG.ToString(), |
| | | TargetValue = parameterInfo.TargetValue, |
| | | LowerLimit = parameterInfo.LowerSpecificationsLimit, |
| | | UpperLimit = parameterInfo.UpperSpecificationsLimit, |
| | | DefectCode = defectCode, |
| | | UOMCode = parameterInfo.UOMCode, |
| | | } |
| | | } |
| | | }).ToList() |
| | | }; |
| | | content = await _gingInOrOutInputService.GetOCVOutputAsync(outputDto); |
| | | } |
| | | else |
| | | { |
| | | content.Error("杀杀杀"); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | |
| | | // 组盘信息 |
| | | // 将content.Data转换为ResultTrayCellsStatus对象 |
| | | var result = JsonConvert.DeserializeObject<ResultTrayCellsStatus>(content.Data.ToString()); |
| | | |
| | | if (!result.Success) |
| | | { |
| | | var taskNG = new Dt_Task |
| | | { |
| | | CurrentAddress = input.Position, |
| | | Grade = 1, |
| | | Roadway = input.Roadways, |
| | | TargetAddress = stationManager.stationNGLocation, |
| | | Dispatchertime = DateTime.Now, |
| | | MaterialNo = "", |
| | | NextAddress = stationManager.stationNGChildCode, |
| | | OrderNo = null, |
| | | PalletCode = input.PalletCode, |
| | | SourceAddress = stationManager.stationLocation, |
| | | TaskState = (int)TaskInStatusEnum.Line_InFinish, |
| | | TaskType = (int)TaskOutboundTypeEnum.InToOut, |
| | | TaskNum = await BaseDal.GetTaskNo(), |
| | | Creater = "Systeam" |
| | | }; |
| | | return taskNG; |
| | | } |
| | | |
| | | if (result.SerialNos.Count <= 0) |
| | | { |
| | | ConsoleHelper.WriteErrorLine(result.MOMMessage); |
| | |
| | | } |
| | | |
| | | // 处理异常电芯情况 |
| | | var serialNosError = result.SerialNos.Where(x => x.SerialNoStatus != 1).ToList(); |
| | | var serialNosError = result.SerialNos.Where(x => x.SerialNoStatus != 1 && x.SerialNoStatus != 4).ToList(); |
| | | if (serialNosError.Count > 0) |
| | | { |
| | | if (stationManager.stationType != 3) |