From 9f225bb1f1e26d25c1652d3e1ec2a8f239f69615 Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期二, 18 三月 2025 10:41:29 +0800
Subject: [PATCH] 1

---
 项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs |  186 +--------------------------------------------
 1 files changed, 7 insertions(+), 179 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs"
index bb6c530..0baab83 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs"
@@ -25,6 +25,7 @@
 using System.Text;
 using System.Threading.Tasks;
 using WIDESEAWCS_Common.ConveyorLineEnum;
+using WIDESEAWCS_Common.ShuttleCarEnum;
 using WIDESEAWCS_Common.TaskEnum;
 using WIDESEAWCS_Core;
 using WIDESEAWCS_Core.Helper;
@@ -34,24 +35,27 @@
 using WIDESEAWCS_QuartzJob;
 using WIDESEAWCS_QuartzJob.ConveyorLine.Enum;
 using WIDESEAWCS_QuartzJob.DTO;
+using WIDESEAWCS_QuartzJob.Repository;
 using WIDESEAWCS_QuartzJob.Service;
 using WIDESEAWCS_Tasks.ConveyorLineJob;
 
 namespace WIDESEAWCS_Tasks
 {
     [DisallowConcurrentExecution]
-    public class CommonConveyorLineJob : IJob
+    public partial class CommonConveyorLineJob : JobBase, IJob
     {
         private readonly ITaskService _taskService;
         private readonly ITaskExecuteDetailService _taskExecuteDetailService;
         private readonly IRouterService _routerService;
+        private readonly IRouterRepository _routerRepository;
         private readonly IMapper _mapper;
 
-        public CommonConveyorLineJob(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, IRouterService routerService, IMapper mapper)
+        public CommonConveyorLineJob(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, IRouterService routerService, IRouterRepository routerRepository, IMapper mapper)
         {
             _taskService = taskService;
             _taskExecuteDetailService = taskExecuteDetailService;
             _routerService = routerService;
+            _routerRepository = routerRepository;
             _mapper = mapper;
         }
 
@@ -62,35 +66,7 @@
                 CommonConveyorLine conveyorLine = (CommonConveyorLine)context.JobDetail.JobDataMap.Get("JobParams");
                 if (conveyorLine != null)
                 {
-                    List<string> childDeviceCodes = _routerService.QueryAllPositions(conveyorLine.DeviceCode);
-                    List<Task> tasks = new List<Task>();
-                    foreach (string childDeviceCode in childDeviceCodes)
-                    {
-                        ConveyorLineTaskCommandR command = conveyorLine.ReadCustomer<ConveyorLineTaskCommandR>(childDeviceCode);
-                        if (command != null && command.Status == (ushort)ConveyorStatus.Stored)//娣诲姞杈撻�佺嚎鐘舵�丆onveyorLineStatus enum
-                        {
-                            switch (childDeviceCode)
-                            {
-                                case "102":
-                                    RequestInbound(conveyorLine, command, childDeviceCode);
-                                    break;
-                                case "104":
-                                    ConveyorLineInFinish(conveyorLine, command, childDeviceCode);
-                                    break;
-                                case "105":
-                                    RequestOutbound(conveyorLine, command, childDeviceCode);
-                                    break;
-                                case "108":
-                                    ConveyorLineOutFinish(conveyorLine, command, childDeviceCode);
-                                    break;
-                                default:
-                                    RequestInNextAddress(conveyorLine, command, childDeviceCode);
-                                    RequestOutNextAddress(conveyorLine, command, childDeviceCode);
-                                    break;
-                            }
-                        }
-                    }
-                    Task.WaitAll(tasks.ToArray());
+                    ConveyorLineExtend(conveyorLine);
                 }
             }
             catch (Exception ex)
@@ -102,154 +78,6 @@
                 //Console.Out.WriteLine(DateTime.Now);
             }
             return Task.CompletedTask;
-        }
-
-        /// <summary>
-        /// 杈撻�佺嚎璇锋眰鍏ュ簱
-        /// </summary>
-        /// <param name="conveyorLine">杈撻�佺嚎瀹炰緥瀵硅薄</param>
-        /// <param name="command">璇诲彇鐨勮姹備俊鎭�</param>
-        /// <param name="childDeviceCode">瀛愯澶囩紪鍙�</param>
-        public void RequestInbound(CommonConveyorLine conveyorLine, ConveyorLineTaskCommandR command, string childDeviceCode)
-        {
-            Dt_Task task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode, command.Barcode);
-            if (task != null)
-            {
-                ConveyorLineDTO lineDTO = new ConveyorLineDTO()
-                {
-                    TaskNum = task.TaskNum,
-                    stationCode = childDeviceCode,
-                    Barcode = command.Barcode,
-                    Spec = command.Spec,
-                    Weight = command.Weight,
-                };
-                var content = _taskService.RequestWMSTask(lineDTO);
-
-                if (content.Status)
-                {
-                    task.TargetAddress = "104";
-                    task.NextAddress = "103";
-                    ConveyorLineTaskCommandW taskCommand = _mapper.Map<ConveyorLineTaskCommandW>(task);
-
-                    if (conveyorLine.SendCommand(taskCommand, childDeviceCode))
-                        _taskService.UpdateTaskStatusToNext(task);
-                }
-                else
-                {
-                    if (content.Code == 404)//淇敼缁堢偣鍦板潃
-                    {
-                        task.TargetAddress = "101";
-                        task.NextAddress = "101";
-                        task.ExceptionMessage = content.Message;
-                        task.TaskState = (int)TaskInStatusEnum.InException;
-                        ConveyorLineTaskCommandW taskCommand = _mapper.Map<ConveyorLineTaskCommandW>(task);
-                        if (conveyorLine.SendCommand(taskCommand, childDeviceCode)) _taskService.UpdateData(task);
-                    }
-                }
-            }
-        }
-
-        /// <summary>
-        /// 杈撻�佺嚎璇锋眰鍏ュ簱涓嬩竴鍦板潃
-        /// </summary>
-        /// <param name="conveyorLine">杈撻�佺嚎瀹炰緥瀵硅薄</param>
-        /// <param name="command">璇诲彇鐨勮姹備俊鎭�</param>
-        /// <param name="childDeviceCode">瀛愯澶囩紪鍙�</param>
-        public void RequestInNextAddress(CommonConveyorLine conveyorLine, ConveyorLineTaskCommandR command, string childDeviceCode)
-        {
-            Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode);
-            if (task != null)
-            {
-                Dt_Task? newTask = _taskService.UpdatePosition(task.TaskNum, task.CurrentAddress);
-                //if (newTask != null)
-                //{
-                //    ConveyorLineTaskCommandW taskCommand = _mapper.Map<ConveyorLineTaskCommandW>(newTask);
-
-                //    conveyorLine.SendCommand(taskCommand, childDeviceCode);
-                //}
-            }
-        }
-
-        /// <summary>
-        /// 杈撻�佺嚎鍏ュ簱瀹屾垚
-        /// </summary>
-        /// <param name="conveyorLine">杈撻�佺嚎瀹炰緥瀵硅薄</param>
-        /// <param name="command">璇诲彇鐨勮姹備俊鎭�</param>
-        /// <param name="childDeviceCode">瀛愯澶囩紪鍙�</param>
-        public void ConveyorLineInFinish(CommonConveyorLine conveyorLine, ConveyorLineTaskCommandR command, string childDeviceCode)
-        {
-            Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode);
-            if (task != null) _taskService.UpdateTaskStatusToNext(task);
-
-            task = _taskService.QueryCompletedConveyorLineTask(command.TaskNum, childDeviceCode);
-            if (task != null && string.IsNullOrEmpty(task.TargetAddress))
-            {
-                _taskService.StackerCraneRequestInbound(task);
-            }
-            //if (task != null)
-            //{
-            //    //conveyorLine.SetValue(ConveyorLineDBName.WriteInteractiveSignal, 0, childDeviceCode);
-            //    //鍚慦MS鏇存柊浠诲姟鐘舵�侊紝WMS杩斿洖鍏ュ簱浠诲姟缁堢偣
-            //    WebResponseContent content = _taskService.UpdateTaskStatusToNext(task);
-            //    //Console.Out.WriteLine(content.Serialize());
-            //}
-        }
-
-        /// <summary>
-        /// 杈撻�佺嚎璇锋眰鍑轰俊鎭�
-        /// </summary>
-        /// <param name="conveyorLine">杈撻�佺嚎瀹炰緥瀵硅薄</param>
-        /// <param name="command">璇诲彇鐨勮姹備俊鎭�</param>
-        /// <param name="childDeviceCode">瀛愯澶囩紪鍙�</param>
-        public void RequestOutbound(CommonConveyorLine conveyorLine, ConveyorLineTaskCommandR command, string childDeviceCode)
-        {
-            Dt_Task task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode, command.Barcode);
-            if (task != null)
-            {
-                ConveyorLineTaskCommandW taskCommand = _mapper.Map<ConveyorLineTaskCommandW>(task);
-
-                conveyorLine.SendCommand(taskCommand, childDeviceCode);
-
-                _taskService.UpdateTaskStatusToNext(task);
-            }
-        }
-
-        /// <summary>
-        /// 杈撻�佺嚎璇锋眰鍑哄簱涓嬩竴鍦板潃
-        /// </summary>
-        /// <param name="conveyorLine">杈撻�佺嚎瀹炰緥瀵硅薄</param>
-        /// <param name="command">璇诲彇鐨勮姹備俊鎭�</param>
-        /// <param name="childDeviceCode">瀛愯澶囩紪鍙�</param>
-        public void RequestOutNextAddress(CommonConveyorLine conveyorLine, ConveyorLineTaskCommandR command, string childDeviceCode)
-        {
-            Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode);
-            if (task != null)
-            {
-                Dt_Task? newTask = _taskService.UpdatePosition(task.TaskNum, task.CurrentAddress);
-                //if (newTask != null)
-                //{
-                //    ConveyorLineTaskCommandW taskCommand = _mapper.Map<ConveyorLineTaskCommandW>(newTask);
-
-                //    conveyorLine.SendCommand(taskCommand, childDeviceCode);
-                //}
-            }
-        }
-
-        /// <summary>
-        /// 杈撻�佺嚎鍑哄簱瀹屾垚
-        /// </summary>
-        /// <param name="conveyorLine">杈撻�佺嚎瀹炰緥瀵硅薄</param>
-        /// <param name="command">璇诲彇鐨勮姹備俊鎭�</param>
-        /// <param name="childDeviceCode">瀛愯澶囩紪鍙�</param>
-        public void ConveyorLineOutFinish(CommonConveyorLine conveyorLine, ConveyorLineTaskCommandR command, string childDeviceCode)
-        {
-            Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode);
-            if (task != null)
-            {
-                //conveyorLine.SetValue(ConveyorLineDBName.WriteInteractiveSignal, 0, childDeviceCode);
-                WebResponseContent content = _taskService.UpdateTaskStatusToNext(task);
-                //Console.Out.WriteLine(content.Serialize());
-            }
         }
     }
 }

--
Gitblit v1.9.3