From 18d2f40bbf40469b033de6f07ca8a8e3bc191132 Mon Sep 17 00:00:00 2001 From: dengjunjie <dengjunjie@hnkhzn.com> Date: 星期六, 26 四月 2025 19:21:40 +0800 Subject: [PATCH] 优化代码 --- 项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/ConveyorLineExtend/ConveyorLineExtend.cs | 69 ++++++++++++---------------------- 1 files changed, 25 insertions(+), 44 deletions(-) diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/ConveyorLineExtend/ConveyorLineExtend.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/ConveyorLineExtend/ConveyorLineExtend.cs" index 34261ee..8cfa2a4 100644 --- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/ConveyorLineExtend/ConveyorLineExtend.cs" +++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/ConveyorLineExtend/ConveyorLineExtend.cs" @@ -26,12 +26,15 @@ public List<Task> ConveyorLineExtend(CommonConveyorLine conveyorLine) { List<string> childDeviceCodes = _routerService.QueryAllPositions(conveyorLine.DeviceCode); + List<string> strings = new List<string>() { "1003", "1006", "1007" }; + childDeviceCodes.AddRange(strings); List<Task> tasks = new List<Task>(); foreach (string childDeviceCode in childDeviceCodes) { try { ConveyorLineTaskCommandR command = conveyorLine.ReadCustomer<ConveyorLineTaskCommandR>(childDeviceCode); + _cacheService.AddOrUpdate(childDeviceCode, command); if (command != null) { if (childDeviceCode == "1002" && command.Status == (ushort)ConveyorStatus.Wait) @@ -42,60 +45,29 @@ { ConveyorLineInFinish(conveyorLine, command, childDeviceCode); } - //else if (childDeviceCode == "1005" && command.Status == (ushort)ConveyorStatus.Stored) - //{ - // Dt_Task task = _taskService.QueryConveyorLineTaskNum(conveyorLine.DeviceCode, childDeviceCode, command.TaskNum); - // if (task != null) - // { - // task.TaskState = TaskOutStatusEnum.Line_OutExecuting.ObjToInt(); - // _taskService.UpdateData(task); - // ConveyorLineTaskCommandW taskCommand = _mapper.Map<ConveyorLineTaskCommandW>(task); - // taskCommand.WriterTrue = (short)command.inRead; - // conveyorLine.SendCommand(taskCommand, childDeviceCode); - // } - //} else if (childDeviceCode == "1008" && command.Status == (ushort)ConveyorStatus.Stored) { Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode); if (task != null) { - List<Dt_Router> routers = _routerRepository.QueryData(x => x.StartPosi == task.NextAddress && x.ChildPosiDeviceCode == "AGV" && x.Remark == "鏈崰鐢�"); - if (routers.Count > 0) + List<Dt_Router> routers = _routerRepository.QueryData(x => x.StartPosi == task.TargetAddress && x.ChildPosiDeviceCode == "AGV" && x.Remark == "鏈崰鐢�"); + if (routers != null && routers.Count > 0) { - + var router = routers.FirstOrDefault(); + if (router != null) + { + task.TaskState = TaskOutStatusEnum.Line_OutFinish.ObjToInt(); + task.CurrentAddress = childDeviceCode; + task.NextAddress = router.NextPosi; + task.TargetAddress = task.NextAddress; + router.Remark = "鍗犵敤"; + _routerRepository.UpdateData(router); + _taskService.UpdateData(task); + } } - task.TaskState = TaskOutStatusEnum.Line_OutFinish.ObjToInt(); - _taskService.UpdateData(task); } } } - #region MyRegion - - //if (command != null && command.Status == (ushort)ConveyorStatus.Stored)//娣诲姞杈撻�佺嚎鐘舵�丆onveyorLineStatus enum - //{ - // switch (childDeviceCode) - // { - // case "1002": - // { - // RequestInbound(conveyorLine, command, childDeviceCode); - // } - // break; - // case "1004": - // ConveyorLineInFinish(conveyorLine, command, childDeviceCode); - // break; - // //case "105": - // // RequestOutbound(conveyorLine, command, childDeviceCode); - // // break; - // case "1008": - // ConveyorLineOutFinish(conveyorLine, command, childDeviceCode); - // break; - // //default: - // // RequestInNextAddress(conveyorLine, command, childDeviceCode); - // // RequestOutNextAddress(conveyorLine, command, childDeviceCode); - // // break; - // } - //} - #endregion } catch (Exception ex) { @@ -174,6 +146,15 @@ // //} //} } + else + { + Dt_Task _Task = new Dt_Task(); + _Task.TaskNum = Convert.ToInt32(DateTime.Now.ToString("HHmmss")); + _Task.CurrentAddress = childDeviceCode; + _Task.NextAddress = "1001"; + ConveyorLineTaskCommandW taskCommand = _mapper.Map<ConveyorLineTaskCommandW>(_Task); + taskCommand.WriterTrue = (short)command.inRead; + } } /// <summary> -- Gitblit v1.9.3