更新配置和代码逻辑,优化异常处理
- 更新 .gitignore,添加忽略规则。
- 修改 appsettings.json 中的数据库连接字符串,使用新的 IP 地址。
- 在 CommonConveyorLineJob.cs 中调整代码格式,增加异常处理和日志记录。
- 更新 RequestInbound.cs 中的任务状态枚举值,并添加入库请求逻辑。
- 注释掉 CommonStackerCraneJob.cs 和 CommonStackerStationCraneJob.cs 中的调试输出,减少冗余信息。
- 在 Dt_TaskService.cs 中添加异常记录逻辑,以便更好地追踪问题。
| | |
| | | /CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/bin/Debug/net6.0/publish/runtimes/linux-arm/native/libSystem.IO.Ports.Native.so |
| | | /项目资料/项目图纸/前段线体点位图/08三楼输送布局点位图1107.dwl2 |
| | | *.txt |
| | | /项目资料/项目图纸/前段线体点位图/08三楼输送布局点位图1107.dwg.bak |
| | | /项目资料/项目图纸/前段线体点位图/08三楼输送布局点位图1107.DWG.lck |
| | | *.lck |
| | |
| | | "ConnectionStringsEncryption": false, |
| | | "MainDB": "DB_WIDESEA", //当前项目的主库,所对应的连接字符串的Enabled必须为true |
| | | //连接字符串 |
| | | "ConnectionString": "Data Source=192.168.90.253;Initial Catalog=WIDESEA_WCSDB3F;User ID=sa;Password=P@ssw0rd;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False", |
| | | "ConnectionString": "Data Source=192.168.65.253;Initial Catalog=WIDESEA_WCSDB_BB3F;User ID=sa;Password=P@ssw0rd;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False", |
| | | //"ConnectionString": "Data Source=127.0.0.1;Initial Catalog=WIDESEA_WCSDB_BB3F;User ID=sa;Password=P@ssw0rd;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False", |
| | | //跨域 |
| | | "Cors": { |
| | | "PolicyName": "CorsIpAccess", //策略名称 |
| | |
| | | command.InteractiveSignal = commandWrite.WriteInteractiveSignal; |
| | | // 调用处理方法 |
| | | method.Invoke(this, new object[] { conveyorLine, command, childDeviceCode, count, platform }); |
| | | }; |
| | | } |
| | | ; |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | return Task.CompletedTask; |
| | | } |
| | | |
| | | #region 入库 |
| | | |
| | | /// <summary> |
| | |
| | | } |
| | | } |
| | | |
| | | public string RequestInboundPlatform(string childDeviceCode,string productLine,bool IsTrayBarcode) |
| | | public string RequestInboundPlatform(string childDeviceCode, string productLine, bool IsTrayBarcode) |
| | | { |
| | | try |
| | | { |
| | |
| | | IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == platform.PLCCode); |
| | | if (device != null) |
| | | { |
| | | int x = 3; |
| | | CommonConveyorLine conveyorLine = (CommonConveyorLine)device; |
| | | foreach (var item in Location) |
| | | { |
| | | x--; |
| | | ConveyorLineTaskCommand command1 = conveyorLine.ReadCustomer<ConveyorLineTaskCommand>(item); |
| | | if (command1.InteractiveSignal != 2) |
| | | { |
| | | var tasks = _taskRepository.QueryData(x => (x.TaskType == (int)TaskInboundTypeEnum.InTray || x.TaskType == (int)TaskOutboundTypeEnum.OutTray) && x.TargetAddress == childDeviceCode); |
| | | |
| | | // 如果已有任务数量小于指定索引 |
| | | if (tasks.Count < Location.Count) |
| | | if (tasks.Count < Location.Count && tasks.Count < x) |
| | | { |
| | | return childDeviceCode; |
| | | } |
| | |
| | | { |
| | | ConsoleHelper.WriteErrorLine($"方法RequestInboundPlatform:{ex.Message}"); |
| | | } |
| | | |
| | | |
| | | return null; |
| | | } |
| | | |
| | |
| | | /// <param name="conveyorLine">输送线实例对象</param> |
| | | /// <param name="command">读取的请求信息</param> |
| | | /// <param name="childDeviceCode">子设备编号</param> |
| | | public void RequestInNextAddress(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode,int ProtocalDetailValue) |
| | | public void RequestInNextAddress(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode, int ProtocalDetailValue) |
| | | { |
| | | var log = $"【{conveyorLine._deviceName}】任务号:【{command.TaskNum}】,托盘条码:【{command.Barcode}】已到达【{childDeviceCode}】请求入库下一地址"; |
| | | ConsoleHelper.WriteWarningLine(log); |
| | | |
| | | _noticeService.Logs(userTokenIds, new { conveyorLine.DeviceName, log = log, time = DateTime.Now.ToString("G"), color = "red" }); |
| | | WriteInfo(conveyorLine.DeviceName, log); |
| | | if (childDeviceCode == "1279") |
| | | { |
| | | var stationManager = _stationManagerRepository.QueryFirst(x => x.stationChildCode == childDeviceCode && x.stationPLC == conveyorLine.DeviceCode); |
| | | CreateAndSendEmptyTrayTask(conveyorLine, command, childDeviceCode, ProtocalDetailValue, stationManager); |
| | | } |
| | | //if (childDeviceCode == "1279") |
| | | //{ |
| | | // var stationManager = _stationManagerRepository.QueryFirst(x => x.stationChildCode == childDeviceCode && x.stationPLC == conveyorLine.DeviceCode); |
| | | // CreateAndSendEmptyTrayTask(conveyorLine, command, childDeviceCode, ProtocalDetailValue, stationManager); |
| | | //} |
| | | |
| | | |
| | | Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode); |
| | | if (task != null) |
| | | { |
| | |
| | | |
| | | #endregion 出库 |
| | | |
| | | |
| | | #region 输送线交互完成 |
| | | |
| | | /// <summary> |
| | | /// 输送线交互完成 |
| | | /// </summary> |
| | |
| | | conveyorLine.Communicator.Write(DeviceProAddress, value); |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #endregion |
| | | |
| | | #region 检测空盘实盘任务 |
| | | |
| | |
| | | |
| | | #endregion 设备NG口入库 |
| | | |
| | | |
| | | #region 输出日志 |
| | | |
| | | public async Task LogAndWarn(string deviceName, string log, string color = "red") |
| | | { |
| | | ConsoleHelper.WriteWarningLine(log); |
| | |
| | | |
| | | #endregion |
| | | |
| | | |
| | | private (ConveyorLineTaskCommand, ConveyorLineTaskCommandWrite) ReadCommands(Dt_StationManager station, CommonConveyorLine conveyorLine) |
| | | { |
| | | ConveyorLineTaskCommand command = conveyorLine.ReadCustomer<ConveyorLineTaskCommand>(station.stationChildCode); |
| | | ConveyorLineTaskCommandWrite commandWrite = conveyorLine.ReadCustomer<ConveyorLineTaskCommandWrite>(station.stationChildCode, "DeviceCommand"); |
| | | return (command, commandWrite); |
| | | } |
| | | |
| | | } |
| | | } |
| | |
| | | RoadWay = childDeviceCode, |
| | | SourceAddress = childDeviceCode, |
| | | TargetAddress = isTrue, |
| | | TaskState = (int)TaskOutStatusEnum.OutNew, |
| | | TaskState = (int)TaskOutStatusEnum.SC_OutFinish, |
| | | Id = 0, |
| | | TaskType = (int)TaskOutboundTypeEnum.TrayInToOut, |
| | | ProductionLine = result.ProductionLine, |
| | |
| | | /// <exception cref="InvalidOperationException"></exception> |
| | | private async Task JZRequestInBound(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode, int ProtocalDetailValue, Dt_StationManager stationManager) |
| | | { |
| | | |
| | | ExecuteConveyorLineTask(conveyorLine, command, ProtocalDetailValue, childDeviceCode); |
| | | |
| | | ResultTrayCellsStatus resultTrayCellsStatus = GetResultTrayCellsStatus(command, stationManager); |
| | | |
| | | |
| | | //todo判断是否为空框 |
| | | var serialNosError = resultTrayCellsStatus.SerialNos.Where(x => x.SerialNoStatus != 1 && x.SerialNoStatus != 4).ToList(); |
| | | if (serialNosError.Count > 0) |
| | |
| | | List<string> childDeviceCodes = _routerService.QueryAllPositions(conveyorLine.DeviceCode); |
| | | foreach (string childDeviceCode in childDeviceCodes) |
| | | { |
| | | //ConveyorLineTaskCommand_After command = null; |
| | | //if (childDeviceCode == "2236") |
| | | //{ |
| | | // var stationPLC = _stationManagerRepository.QueryFirst(x => x.stationType == 1 && x.stationChildCode == childDeviceCode).stationPLC; |
| | | // IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationPLC); |
| | | // CommonConveyorLine_After conveyorLine1 = (CommonConveyorLine_After)device; |
| | | // command = conveyorLine1.ReadCustomer<ConveyorLineTaskCommand_After>(childDeviceCode); |
| | | //} |
| | | //else |
| | | //{ |
| | | // command = conveyorLine.ReadCustomer<ConveyorLineTaskCommand_After>(childDeviceCode); |
| | | //} |
| | | ConveyorLineTaskCommand_After command = conveyorLine.ReadCustomer<ConveyorLineTaskCommand_After>(childDeviceCode); |
| | | if (command == null) continue; |
| | | if (command.ConveyorLineBarcode.Trim().Contains("\0")) command.ConveyorLineBarcode = ""; |
| | |
| | | } |
| | | } |
| | | |
| | | if (childDeviceCode == "1670" || childDeviceCode == "1666" || childDeviceCode == "1548" || childDeviceCode == "1448") |
| | | if (childDeviceCode == "3464" || childDeviceCode == "3460" || childDeviceCode == "3456" ) |
| | | { |
| | | Platform platform = _platFormRepository.QueryFirst(x => x.PLCCode == conveyorLine.DeviceCode && x.PlatCode == childDeviceCode && x.Status == "Active"); |
| | | if (platform != null) |
| | |
| | | taskCommand.ConveyorLineTargetAddress = Convert.ToInt16(stationManager.stationLocation); |
| | | } |
| | | |
| | | if ((stationManager.stationPLC == "1018" && stationManager.stationArea == "Cache") || task.TaskType == (int)TaskOutboundTypeEnum.OutTray) //更新在途数据 |
| | | if ((stationManager.stationPLC == "1007" && stationManager.stationArea == "Cache") || task.TaskType == (int)TaskOutboundTypeEnum.OutTray) //更新在途数据 |
| | | { |
| | | dt_needBarcode needBarcode = _needBarcodeRepository.QueryFirst(x => x.productLine == stationManager.productLine && x.toArea == stationManager.stationChildCode); |
| | | |
| | |
| | | { |
| | | try |
| | | { |
| | | WriteInfo("出库", $"【{JsonConvert.SerializeObject(platform)}】"); |
| | | TaskOutboundTypeEnum taskOutboundTypeEnum; |
| | | if (platform.PlatformType.Contains("OutTray")) |
| | | taskOutboundTypeEnum = TaskOutboundTypeEnum.OutTray; |
| | |
| | | return; |
| | | |
| | | taskDTO = JsonConvert.DeserializeObject<WMSTaskDTO>(content.Data.ToString()); |
| | | |
| | | WriteInfo("出库", $"【{JsonConvert.SerializeObject(taskDTO)}】"); |
| | | #endregion 调用WMS获取出库任务 |
| | | |
| | | CreateAndSendTask(taskDTO); |
| | |
| | | using Mapster; |
| | | using Masuit.Tools; |
| | | using Newtonsoft.Json; |
| | | using Quartz; |
| | | using System.Diagnostics.CodeAnalysis; |
| | | using System.Text; |
| | | using WIDESEAWCS_BasicInfoRepository; |
| | | using WIDESEAWCS_Common; |
| | | using WIDESEAWCS_Common.TaskEnum; |
| | |
| | | bool sendFlag = commonStackerCrane.SendCommand(stackerCraneTaskCommand); |
| | | if (sendFlag) |
| | | { |
| | | StringBuilder builder = new StringBuilder(); |
| | | builder.AppendLine(); |
| | | builder.AppendLine($"【{commonStackerCrane.DeviceName}】堆垛机状态:【{commonStackerCrane.StackerCraneStatusDes}】,时间:【{DateTime.Now}】"); |
| | | builder.AppendLine($"【{commonStackerCrane.DeviceName}】手自动状态:【{commonStackerCrane.StackerCraneAutoStatusDes}】,时间:【{DateTime.Now}】"); |
| | | builder.AppendLine($"【{commonStackerCrane.DeviceName}】作业状态:【{commonStackerCrane.StackerCraneWorkStatusDes}】,时间:【{DateTime.Now}】"); |
| | | builder.AppendLine($"【{commonStackerCrane.DeviceName}】下发任务成功,【{JsonConvert.SerializeObject(stackerCraneTaskCommand, Formatting.Indented)}】"); |
| | | builder.AppendLine($"时间:【{DateTime.Now}】"); |
| | | builder.AppendLine(); |
| | | ConsoleHelper.WriteColorLine(builder, ConsoleColor.Blue); |
| | | //StringBuilder builder = new StringBuilder(); |
| | | //builder.AppendLine(); |
| | | //builder.AppendLine($"【{commonStackerCrane.DeviceName}】堆垛机状态:【{commonStackerCrane.StackerCraneStatusDes}】,时间:【{DateTime.Now}】"); |
| | | //builder.AppendLine($"【{commonStackerCrane.DeviceName}】手自动状态:【{commonStackerCrane.StackerCraneAutoStatusDes}】,时间:【{DateTime.Now}】"); |
| | | //builder.AppendLine($"【{commonStackerCrane.DeviceName}】作业状态:【{commonStackerCrane.StackerCraneWorkStatusDes}】,时间:【{DateTime.Now}】"); |
| | | //builder.AppendLine($"【{commonStackerCrane.DeviceName}】下发任务成功,【{JsonConvert.SerializeObject(stackerCraneTaskCommand, Formatting.Indented)}】"); |
| | | //builder.AppendLine($"时间:【{DateTime.Now}】"); |
| | | //builder.AppendLine(); |
| | | //ConsoleHelper.WriteColorLine(builder, ConsoleColor.Blue); |
| | | commonStackerCrane.LastTaskType = task.TaskType; |
| | | _taskService.UpdateTaskStatusToNext(task.TaskNum); |
| | | } |
| | |
| | | } |
| | | |
| | | var content = _taskService.StackCraneTaskCompleted(e.TaskNum); |
| | | if (commonStackerCrane.DeviceCode.Contains("CH") && task.TaskType == (int)TaskOutboundTypeEnum.Outbound) |
| | | if ((commonStackerCrane.DeviceCode.Contains("CH") || commonStackerCrane.DeviceCode.Contains("JZ")) && task.TaskType == (int)TaskOutboundTypeEnum.Outbound) |
| | | { |
| | | task = _taskRepository.QueryFirst(x => x.TaskNum == e.TaskNum); |
| | | Dt_Task? newTask = _taskService.UpdatePosition(task.TaskNum, task.CurrentAddress); |
| | |
| | | { |
| | | var value = _sys_ConfigService.GetByConfigKey(CateGoryConst.CONFIG_SYS_InStation, SysConfigKeyConst.JZNGInBoundStation).ConfigValue; |
| | | var valueList = value.Split(',').ToList(); |
| | | if ((valueList.Contains(task.SourceAddress)) && task.Roadway.Contains("CH") || task.Roadway.Contains("JZ")) |
| | | if ((valueList.Contains(task.SourceAddress)) && (task.Roadway.Contains("CH") || task.Roadway.Contains("JZ"))) |
| | | { |
| | | string[] souredCodes = task.CurrentAddress.Split("-"); |
| | | if (souredCodes.Length == 3) |
| | |
| | | bool sendFlag = commonStackerCrane.SendCommand(stackerCraneTaskCommand); |
| | | if (sendFlag) |
| | | { |
| | | StringBuilder builder = new StringBuilder(); |
| | | builder.AppendLine(); |
| | | builder.AppendLine($"【{commonStackerCrane.DeviceName}】堆垛机状态:【{commonStackerCrane.StackerCraneStatusDes}】,时间:【{DateTime.Now}】"); |
| | | builder.AppendLine($"【{commonStackerCrane.DeviceName}】手自动状态:【{commonStackerCrane.StackerCraneAutoStatusDes}】,时间:【{DateTime.Now}】"); |
| | | builder.AppendLine($"【{commonStackerCrane.DeviceName}】作业状态:【{commonStackerCrane.StackerCraneWorkStatusDes}】,时间:【{DateTime.Now}】"); |
| | | builder.AppendLine($"【{commonStackerCrane.DeviceName}】下发任务成功,【{JsonConvert.SerializeObject(stackerCraneTaskCommand, Formatting.Indented)}】"); |
| | | builder.AppendLine($"时间:【{DateTime.Now}】"); |
| | | builder.AppendLine(); |
| | | ConsoleHelper.WriteColorLine(builder, ConsoleColor.Blue); |
| | | //StringBuilder builder = new StringBuilder(); |
| | | //builder.AppendLine(); |
| | | //builder.AppendLine($"【{commonStackerCrane.DeviceName}】堆垛机状态:【{commonStackerCrane.StackerCraneStatusDes}】,时间:【{DateTime.Now}】"); |
| | | //builder.AppendLine($"【{commonStackerCrane.DeviceName}】手自动状态:【{commonStackerCrane.StackerCraneAutoStatusDes}】,时间:【{DateTime.Now}】"); |
| | | //builder.AppendLine($"【{commonStackerCrane.DeviceName}】作业状态:【{commonStackerCrane.StackerCraneWorkStatusDes}】,时间:【{DateTime.Now}】"); |
| | | //builder.AppendLine($"【{commonStackerCrane.DeviceName}】下发任务成功,【{JsonConvert.SerializeObject(stackerCraneTaskCommand, Formatting.Indented)}】"); |
| | | //builder.AppendLine($"时间:【{DateTime.Now}】"); |
| | | //builder.AppendLine(); |
| | | //ConsoleHelper.WriteColorLine(builder, ConsoleColor.Blue); |
| | | commonStackerCrane.LastTaskType = task.TaskType; |
| | | _taskService.UpdateTaskStatusToNext(task.TaskNum); |
| | | } |
| | |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | // 记录异常信息并抛出 |
| | | LogFactory.GetLog($"{position}请求{productionLine}任务").Info(true, $"{position}-{tag}-{areaCode}-{JsonConvert.SerializeObject(areaCodes)}-{productionLine}"); |
| | | // 根据托盘类型查询库存信息 |
| | | DtStockInfo stockInfo = tag == (int)TaskOutboundTypeEnum.Outbound |
| | | ? areaCode != "CWSC1" ? await QueryStockInfoForRealTrayAsync(areaCode, areaCodes, productionLine) : await QueryStockInfoForRealTrayCWAsync(areaCodes, productionLine) |
| | |
| | | "urls": "http://*:5000", |
| | | "MainDB": "DB_WIDESEA", //当前项目的主库,所对应的连接字符串的Enabled必须为true |
| | | //连接字符串 |
| | | "ConnectionString": "Data Source=127.0.0.1;Initial Catalog=WIDESEA_WMS2F08;User ID=sa;Password=P@ssw0rd;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False", |
| | | "ConnectionStringWCS": "Data Source=127.0.0.1;Initial Catalog=WIDESEA_WCS2F08;User ID=sa;Password=P@ssw0rd;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False", |
| | | //"ConnectionString": "Data Source=127.0.0.1;Initial Catalog=WIDESEA_WMS2F08;User ID=sa;Password=P@ssw0rd;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False", |
| | | //"ConnectionStringWCS": "Data Source=127.0.0.1;Initial Catalog=WIDESEA_WCS2F08;User ID=sa;Password=P@ssw0rd;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False", |
| | | "ConnectionString": "Data Source=192.168.65.253;Initial Catalog=WIDESEA_WMSDB_BB3F;User ID=sa;Password=P@ssw0rd;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False", |
| | | "ConnectionStringWCS": "Data Source=192.168.65.253;Initial Catalog=WIDESEA_WCSDB_BB3F;User ID=sa;Password=P@ssw0rd;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False", |
| | | //跨域 |
| | | "Cors": { |
| | | "PolicyName": "CorsIpAccess", //策略名称 |