From 8aa4fcd006dc25d19f22f0d858dfa146c4493a7d Mon Sep 17 00:00:00 2001
From: wankeda <Administrator@DESKTOP-HAU3ST3>
Date: 星期四, 10 四月 2025 16:10:23 +0800
Subject: [PATCH] 1

---
 代码管理/NEWCode/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs |  179 +++++++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 124 insertions(+), 55 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/NEWCode/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/NEWCode/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs"
index 7ee7a24..2e871c8 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/NEWCode/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/NEWCode/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs"
@@ -1,4 +1,5 @@
 锘�#region << 鐗� 鏈� 娉� 閲� >>
+
 /*----------------------------------------------------------------
  * 鍛藉悕绌洪棿锛歐IDESEAWCS_Tasks.ConveyorLineJob
  * 鍒涘缓鑰咃細鑳$搴�
@@ -11,19 +12,13 @@
  * 淇敼鏃堕棿锛�
  * 鐗堟湰锛歏1.0.1
  * 淇敼璇存槑锛�
- * 
+ *
  *----------------------------------------------------------------*/
+
 #endregion << 鐗� 鏈� 娉� 閲� >>
 
 using AutoMapper;
-using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
 using Quartz;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Reflection;
-using System.Text;
-using System.Threading.Tasks;
 using WIDESEAWCS_Common.TaskEnum;
 using WIDESEAWCS_Core;
 using WIDESEAWCS_Core.Helper;
@@ -31,7 +26,6 @@
 using WIDESEAWCS_ITaskInfoService;
 using WIDESEAWCS_Model.Models;
 using WIDESEAWCS_QuartzJob;
-using WIDESEAWCS_QuartzJob.DTO;
 using WIDESEAWCS_QuartzJob.Service;
 using WIDESEAWCS_Tasks.ConveyorLineJob;
 
@@ -71,57 +65,22 @@
                 // 瀹氫箟绾夸綋瀹炵洏鍏ュ簱璇锋眰鐨勫湴鍧�鍜屼换鍔$被鍨�
                 var requests = new Dictionary<string, string>
                 {
-                    { "DB1002.293.0", "ZJXL-WLX002" },
+                    { "DB1002.1093.0", "ZJXL-WLX002" },
                     { "DB1002.1493.0", "FJXL-WLX002" }
                 };
 
-                foreach (var request in requests)
+                // 瀹氫箟绾夸綋绌虹洏鍥炴祦璇锋眰鐨勫湴鍧�鍜屼换鍔$被鍨�
+                var requestsKP = new Dictionary<string, string>
                 {
-                    var isDownRequest = conveyorLine.Communicator.Read<bool>(request.Key);
-                    if (!isDownRequest)
-                    {
-                        continue;
-                    }
+                    { "DB1002.1893.0", "ZJXL-KPHLX001" },
+                    { "DB1002.2293.0", "FJXL-KPHLX001" }
+                };
 
-                    string fromAdd = request.Value;
-                    string taskType = request.Value.Contains("ZJXL") ? "姝f瀬" : "璐熸瀬";
+                // 澶勭悊瀹炵洏鍏ュ簱璇锋眰
+                ProcessRequests(conveyorLine, requests, "涓嬬嚎璇锋眰鍏ュ簱");
 
-                    // 鏌ヨ鏄惁瀛樺湪宸茬敓鎴愮殑鏂颁换鍔�
-                    var task = _taskRepository.QueryFirst(x => x.SourceAddress == fromAdd && x.TaskState == (int)TaskInStatusEnum.InNew);
-                    if (task != null)
-                    {
-                        ConsoleHelper.WriteInfoLine($"{nameof(CommonConveyorLineJob)}: {taskType}涓嬬嚎璇锋眰鍏ュ簱,浠诲姟宸茬敓鎴愬瓨鍦紝绋嶅悗閲嶈瘯......");
-                        continue;
-                    }
-
-                    // 鏌ヨ浠诲姟绫诲瀷瀵瑰簲鐨刢zTask
-                    DtCZTask czTask = _taskCZRepository.QueryFirst(x => x.TaskType == taskType);
-                    if (czTask == null)
-                    {
-                        ConsoleHelper.WriteInfoLine($"{nameof(CommonConveyorLineJob)}: {taskType}涓嬬嚎璇锋眰鍏ュ簱,{taskType}浠诲姟涓嶅瓨鍦紝绋嶅悗閲嶈瘯......");
-                        continue;
-                    }
-
-                    // 鍒涘缓鏂扮殑浠诲姟骞舵坊鍔犲埌浠诲姟浠撳簱
-                    task = new Dt_Task()
-                    {
-                        TaskNum = _taskService.GetTaskNum(),
-                        CreateDate = DateTime.Now,
-                        Creater = "system",
-                        CurrentAddress = fromAdd,
-                        SourceAddress = fromAdd,
-                        TaskState = (int)TaskInStatusEnum.InNew,
-                        TaskType = (int)TaskInboundTypeEnum.Inbound,
-                        Grade = 1,
-                        PalletCode = czTask.TaskProductCode,
-                        TargetAddress = czTask.TaskEndAddress,
-                        Roadway = $"{taskType}AGV",
-                        WMSId = czTask.Id,
-                        Remark = czTask.TaskOrderNo
-                    };
-                    _taskRepository.AddData(task);
-                    ConsoleHelper.WriteInfoLine($"{nameof(CommonConveyorLineJob)}: {taskType}涓嬬嚎璇锋眰鍏ュ簱,浠诲姟宸茬敓鎴愶紝绛夊緟鎵ц......");
-                }
+                // 澶勭悊绌虹洏鍥炴祦璇锋眰
+                ProcessKpRequests(conveyorLine, requestsKP);
             }
             catch (Exception ex)
             {
@@ -139,6 +98,116 @@
             return Task.CompletedTask;
         }
 
+        private void ProcessRequests(CommonConveyorLine conveyorLine, Dictionary<string, string> requests, string requestType)
+        {
+            foreach (var request in requests)
+            {
+                var isDownRequest = conveyorLine.Communicator.Read<bool>(request.Key);
+                if (!isDownRequest)
+                {
+                    continue;
+                }
+
+                string fromAdd = request.Value;
+                string taskType = request.Value.Contains("ZJXL") ? "姝f瀬" : "璐熸瀬";
+
+                // 鏌ヨ鏄惁瀛樺湪宸茬敓鎴愮殑鏂颁换鍔�
+                var task = _taskRepository.QueryFirst(x => x.SourceAddress == fromAdd && x.TaskState == (int)TaskInStatusEnum.InNew);
+                if (task != null)
+                {
+                    ConsoleHelper.WriteInfoLine($"{nameof(CommonConveyorLineJob)}: {taskType}{requestType},浠诲姟宸茬敓鎴愬瓨鍦紝绋嶅悗閲嶈瘯......");
+                    continue;
+                }
+
+                // 鏌ヨ浠诲姟绫诲瀷瀵瑰簲鐨刢zTask
+                DtCZTask czTask = _taskCZRepository.QueryFirst(x => x.TaskType == taskType);
+                if (czTask == null)
+                {
+                    ConsoleHelper.WriteInfoLine($"{nameof(CommonConveyorLineJob)}: {taskType}{requestType},{taskType}浠诲姟涓嶅瓨鍦紝绋嶅悗閲嶈瘯......");
+                    continue;
+                }
+
+                // 鍒涘缓骞舵坊鍔犳柊浠诲姟鍒颁换鍔′粨搴�
+                task = CreateTask(fromAdd, czTask.TaskEndAddress, czTask.TaskOrderNo, czTask.TaskProductCode, taskType);
+                _taskRepository.AddData(task);
+                ConsoleHelper.WriteInfoLine($"{nameof(CommonConveyorLineJob)}: {taskType}{requestType},浠诲姟宸茬敓鎴愶紝绛夊緟鎵ц......");
+            }
+        }
+
+        private void ProcessKpRequests(CommonConveyorLine conveyorLine, Dictionary<string, string> requestsKP)
+        {
+            foreach (var request in requestsKP)
+            {
+                var isDownRequest = conveyorLine.Communicator.Read<bool>(request.Key);
+                if (!isDownRequest)
+                {
+                    continue;
+                }
+
+                string fromAdd = request.Value;
+                string taskType = request.Value.Contains("ZJXL") ? "姝f瀬" : "璐熸瀬";
+
+                // 鏍规嵁浠诲姟绫诲瀷纭畾璇锋眰鍦板潃
+                (string upRequest, string gmRequest, string gmState) = GetRequestAddresses(taskType);
+
+                var isUpRequest = conveyorLine.Communicator.Read<bool>(upRequest);
+                var isGMRequest = conveyorLine.Communicator.Read<bool>(gmRequest);
+                var isGMState = conveyorLine.Communicator.Read<int>(gmState);
+
+                // 鏍规嵁鏉′欢鍒涘缓浠诲姟瀵硅薄
+                Dt_Task task = null;
+                if (isUpRequest)
+                {
+                    task = CreateTask(fromAdd, "WaitBind", "姝f瀬鐗╂祦绾�002鐨勪笂鏂欒姹�", "绌烘墭鐩�", taskType);
+                }
+                else if (isGMRequest && isGMState == 1)
+                {
+                    task = CreateTask(fromAdd, "WaitBind", "姝f瀬鐗╂祦绾�002鐨勪笂鏂欒姹�", "闅旇啘绌烘墭鐩�", taskType);
+                }
+
+                // 娣诲姞浠诲姟鍒颁换鍔¤〃
+                if (task != null)
+                {
+                    _taskRepository.AddData(task);
+                }
+            }
+        }
+
+        private (string upRequest, string gmRequest, string gmState) GetRequestAddresses(string taskType)
+        {
+            if (taskType == "姝f瀬")
+            {
+                // 鐗╂祦绾�002鐨勪笂鏂欒姹�
+                return ("DB1002.93.0", "DB1002.2493.0", "DB1002.2424.0");
+            }
+            else
+            {
+                // 鐗╂祦绾�002鐨勪笂鏂欒姹�
+                return ("DB1002.1293.0", "DB1002.2893.0", "DB1002.2824.0");
+            }
+        }
+
+        // 杈呭姪鏂规硶锛氬垱寤轰换鍔″璞�
+        private Dt_Task CreateTask(string currentAddress, string targetAddress, string remark, string palletCode, string taskType)
+        {
+            return new Dt_Task
+            {
+                TaskNum = _taskService.GetTaskNum(),
+                CreateDate = DateTime.Now,
+                Creater = "system",
+                CurrentAddress = currentAddress,
+                SourceAddress = currentAddress,
+                TaskState = targetAddress != "WaitBind" ? (int)TaskInStatusEnum.InNew : (int)TaskInStatusEnum.InPending,
+                TaskType = (int)TaskInboundTypeEnum.Inbound,
+                Grade = 1,
+                PalletCode = palletCode,
+                TargetAddress = targetAddress,
+                NextAddress = targetAddress,
+                Roadway = $"{taskType}AGV",
+                WMSId = 0,
+                Remark = remark
+            };
+        }
 
         /// <summary>
         /// 杈撻�佺嚎璇锋眰鍏ュ簱
@@ -262,4 +331,4 @@
             GC.SuppressFinalize(this);
         }
     }
-}
+}
\ No newline at end of file

--
Gitblit v1.9.3