From a89f1faab22c204627d49d6731be9c94d8160184 Mon Sep 17 00:00:00 2001
From: duyongjia <adu_555@163.com>
Date: 星期五, 22 十一月 2024 11:23:47 +0800
Subject: [PATCH] 优化修改提交

---
 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/System/Sys_DictionaryController.cs |   27 +++
 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs        |   56 ++++--
 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/DoubleStackerCraneJob.cs        |  154 ++++++++++++++-----
 代码管理/WCS/WIDESEAWCS_Client/src/views/taskinfo/task.vue                                      |    3 
 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_ITaskInfoService/ITaskService.cs                      |    3 
 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/LocationEnum/LocationTypeEnum.cs               |   14 
 代码管理/WCS/WIDESEAWCS_Client/src/views/basic/locationInfo.vue                                 |    2 
 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/appsettings.json                               |    3 
 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskExecuteDetailService.cs           |   17 ++
 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs                        |   66 ++++---
 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/QuartzJob/SchedulerController.cs   |  115 ++++++++++++++
 11 files changed, 360 insertions(+), 100 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Client/src/views/basic/locationInfo.vue" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Client/src/views/basic/locationInfo.vue"
index dd114ec..84438e1 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Client/src/views/basic/locationInfo.vue"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Client/src/views/basic/locationInfo.vue"
@@ -75,6 +75,7 @@
           required: true,
           field: "areaId",
           type: "string",
+          hidden:true,
         },
         {
           title: "宸烽亾缂栧彿",
@@ -110,6 +111,7 @@
         title: "鍖哄煙涓婚敭",
         type: "string",
         width: 90,
+        hidden:true,
         align: "left",
         bind: {
           key: "areainfo",
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Client/src/views/taskinfo/task.vue" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Client/src/views/taskinfo/task.vue"
index 1c1154f..23d0c1a 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Client/src/views/taskinfo/task.vue"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Client/src/views/taskinfo/task.vue"
@@ -138,6 +138,7 @@
         type: "string",
         width: 120,
         align: "left",
+        hidden: true,
       },
       {
         field: "nextAddress",
@@ -145,6 +146,7 @@
         type: "string",
         width: 120,
         align: "left",
+        hidden: true,
       },
       {
         field: "exceptionMessage",
@@ -167,6 +169,7 @@
         type: "datetime",
         width: 150,
         align: "left",
+        hidden: true,
       },
       {
         field: "wMSId",
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/LocationEnum/LocationTypeEnum.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/LocationEnum/LocationTypeEnum.cs"
index b4a8710..4103c2b 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/LocationEnum/LocationTypeEnum.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/LocationEnum/LocationTypeEnum.cs"
@@ -16,27 +16,27 @@
         Normal = 1,
 
         /// <summary>
-        /// 涓婃枡璐т綅
+        /// 鏆傚瓨浣�
         /// </summary>
-        [Description("涓婃枡璐т綅")]
+        [Description("鏆傚瓨浣�")]
         Feeding= 2,
 
         /// <summary>
         /// 鍏ュ簱鍙h揣浣�
         /// </summary>
-        [Description("鍏ュ簱鍙h揣浣�")]
+        [Description("鎻愬崌鏈�")]
         In = 3,
 
         /// <summary>
-        /// 绌鸿溅鍑哄簱鍙h揣浣�
+        /// 绌鸿溅鍑哄簱鍙�
         /// </summary>
-        [Description("绌鸿溅鍑哄簱鍙h揣浣�")]
+        [Description("杈撻�佺嚎")]
         OutEmpty = 4,
 
         /// <summary>
-        /// 绐戠倝涓婃枡鏈鸿揣浣�
+        /// 缁勭珛鏈轰綅缃�
         /// </summary>
-        [Description("绐戠倝涓婃枡鏈鸿揣浣�")]
+        [Description("缁勭珛鏈�")]
         OutWorkUnit = 5
     }
 }
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_ITaskInfoService/ITaskService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_ITaskInfoService/ITaskService.cs"
index 132957d..15ce43a 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_ITaskInfoService/ITaskService.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_ITaskInfoService/ITaskService.cs"
@@ -214,6 +214,9 @@
         /// <returns>杩斿洖澶勭悊缁撴灉</returns>
         WebResponseContent StackCraneTaskCompleted(int taskNum);
 
+
+
+
         /// <summary>
         /// 鎭㈠鎸傝捣浠诲姟
         /// </summary>
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/QuartzJob/SchedulerController.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/QuartzJob/SchedulerController.cs"
new file mode 100644
index 0000000..2bc7e2a
--- /dev/null
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/QuartzJob/SchedulerController.cs"
@@ -0,0 +1,115 @@
+锘縰sing Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
+using WIDESEAWCS_Core;
+using WIDESEAWCS_QuartzJob;
+using WIDESEAWCS_QuartzJob.DTO;
+using WIDESEAWCS_QuartzJob.QuartzNet;
+
+namespace WIDESEAWCS_Server.Controllers.QuartzJob
+{
+    [Route("api/Scheduler")]
+    [ApiController]
+    public class SchedulerController : ControllerBase
+    {
+        private readonly ISchedulerCenter _scheduler;
+        private readonly QuartzNetExtension _quartzNetExtension;
+        public SchedulerController(ISchedulerCenter scheduler, QuartzNetExtension quartzNetExtension)
+        {
+            _scheduler = scheduler;
+            _quartzNetExtension = quartzNetExtension;
+        }
+
+        [HttpGet, Route("StartSchedule"), AllowAnonymous]
+        public async Task<WebResponseContent> StartSchedule()
+        {
+            try
+            {
+                await _quartzNetExtension.StartAsync();
+                return WebResponseContent.Instance.OK("鍚姩鎴愬姛");
+            }
+            catch (Exception ex)
+            {
+                return WebResponseContent.Instance.Error("鍚姩閿欒锛�" + ex.Message);
+            }
+        }
+
+        [HttpGet, Route("StopSchedule"), AllowAnonymous]
+        public Task<WebResponseContent> StopSchedule()
+        {
+            return _scheduler.StopScheduleAsync();
+        }
+
+        /// <summary>
+        /// 鏆傚仠鎸囧畾鐨勮鍒掍换鍔�
+        /// </summary>
+        /// <param name="sysSchedule"></param>
+        /// <returns></returns>
+        [HttpPost, Route("PauseJob"), AllowAnonymous]
+        public Task<WebResponseContent> PauseJob([FromBody] DispatchInfoDTO sysSchedule)
+        {
+            return _scheduler.PauseJob(sysSchedule);
+        }
+
+        /// <summary>
+        /// 鎭㈠鎸囧畾鐨勮鍒掍换鍔�
+        /// </summary>
+        /// <param name="sysSchedule"></param>
+        /// <returns></returns>
+        [HttpPost, Route("ResumeJob"), AllowAnonymous]
+        public Task<WebResponseContent> ResumeJob([FromBody] DispatchInfoDTO sysSchedule)
+        {
+            return _scheduler.ResumeJob(sysSchedule);
+        }
+
+        /// <summary>
+        /// 娣诲姞涓�涓鍒掍换鍔★紙鏄犲皠绋嬪簭闆嗘寚瀹欼Job瀹炵幇绫伙級
+        /// </summary>
+        /// <param name="sysSchedule"></param>
+        /// <returns></returns>
+        [HttpPost, Route("AddScheduleJob"), AllowAnonymous]
+        public Task<WebResponseContent> AddScheduleJob([FromBody] DispatchInfoDTO sysSchedule)
+        {
+            return _scheduler.AddScheduleJobAsync(sysSchedule);
+        }
+
+        /// <summary>
+        /// 绔嬪嵆鎵ц 涓�涓换鍔� 鎵ц涓�娆�
+        /// </summary>
+        /// <param name="sysSchedule"></param>
+        /// <returns></returns>
+        [HttpPost, Route("ExecuteJob"), AllowAnonymous]
+        public Task<WebResponseContent> ExecuteJob([FromBody] DispatchInfoDTO sysSchedule)
+        {
+            return _scheduler.ExecuteJobAsync(sysSchedule);
+        }
+
+        /// <summary>
+        /// 鏆傚仠鎵�鏈夎鍒掍换鍔�
+        /// </summary>
+        /// <returns></returns>
+        [HttpPost, Route("PauseAllJob"), AllowAnonymous]
+        public Task<WebResponseContent> PauseAllJob()
+        {
+            //return _scheduler.PauseAllJobAsync();
+            return null;
+        }
+
+        /// <summary>
+        /// 鎭㈠鎵�鏈夎鍒掍换鍔�
+        /// </summary>
+        /// <returns></returns>
+        [HttpPost, Route("ResumeAllJob"), AllowAnonymous]
+        public Task<WebResponseContent> ResumeAllJob()
+        {
+            //return _scheduler.ResumeAllJobAsync();
+            return null;
+        }
+
+        [HttpPost, Route("DeleteScheduleJob"), AllowAnonymous]
+        public Task<WebResponseContent> DeleteScheduleJob([FromBody] DispatchInfoDTO sysSchedule)
+        {
+            return _scheduler.StopScheduleJobAsync(sysSchedule);
+        }
+    }
+}
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/System/Sys_DictionaryController.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/System/Sys_DictionaryController.cs"
index 952104b..66ef5dd 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/System/Sys_DictionaryController.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/System/Sys_DictionaryController.cs"
@@ -528,6 +528,33 @@
                             result = new VueDictionaryDTO { DicNo = key, Config = "", Data = data };
                         }
                         break;
+                    case "locationTypeEnum":
+                        {
+                            List<object> data = new List<object>();
+
+                            {
+                                Type type = typeof(LocationTypeEnum);
+                                List<int> enums = Enum.GetValues(typeof(LocationTypeEnum)).Cast<int>().ToList();
+                                int index = 0;
+                                foreach (var item in enums)
+                                {
+                                    FieldInfo? fieldInfo = typeof(LocationTypeEnum).GetField(((LocationTypeEnum)item).ToString());
+                                    DescriptionAttribute? description = fieldInfo.GetCustomAttribute<DescriptionAttribute>();
+                                    if (description != null)
+                                    {
+                                        data.Add(new { key = item.ToString(), value = description.Description });
+                                    }
+                                    else
+                                    {
+                                        data.Add(new { key = item.ToString(), value = item.ToString() });
+                                    }
+                                    index++;
+                                }
+                            }
+
+                            result = new VueDictionaryDTO { DicNo = key, Config = "", Data = data };
+                        }
+                        break;
                     case "stockStatusEmun":
                         {
                             List<object> data = new List<object>();
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/appsettings.json" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/appsettings.json"
index 737a288..04881e9 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/appsettings.json"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/appsettings.json"
@@ -6,7 +6,7 @@
       "Microsoft.AspNetCore": "Warning"
     }
   },
-  "dics": "deviceType,devicePlcType,jobAssembly,jobClassName,deviceStatus,taskType,taskState,inOutType,orderDetailStatusEnum,enableEnum,enableStatusEnum,locationStatusEnum,stockStatusEmun",
+  "dics": "deviceType,devicePlcType,jobAssembly,jobClassName,deviceStatus,taskType,taskState,inOutType,orderDetailStatusEnum,enableEnum,enableStatusEnum,locationStatusEnum,stockStatusEmun,locationTypeEnum",
   "AllowedHosts": "*",
   "ConnectionStringsEncryption": false,
   "MainDB": "DB_WIDESEA", //褰撳墠椤圭洰鐨勪富搴擄紝鎵�瀵瑰簲鐨勮繛鎺ュ瓧绗︿覆鐨凟nabled蹇呴』涓簍rue
@@ -24,6 +24,7 @@
   "ApiName": "WIDESEA",
   "ExpMinutes": 120,
   "QuartzJobAutoStart": true,
+  "LogDeubgEnable": true,
   "MESApi": "http://10.0.250.12:8888/agv/v1/CMD",
   "ConveyorLineApi": "http://10.0.250.12:8888/wcs/goBack" //绌鸿溅鍑哄簱浠诲姟淇℃伅鑾峰彇鍦板潃
 
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskExecuteDetailService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskExecuteDetailService.cs"
index ded5cef..4da2fa5 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskExecuteDetailService.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskExecuteDetailService.cs"
@@ -182,6 +182,23 @@
                     }
                     else if (!int.TryParse(Enum.Parse<TaskOtherTypeEnum>(task.TaskType.ToString()).ToString(), out result))
                     {
+                        steps = Enum.GetValues(typeof(TaskOutStatusEnum)).Cast<int>().Where(x => x <= (int)TaskOutStatusEnum.OutFinish).ToList();
+
+                        foreach (var item in steps)
+                        {
+                            object obj;
+                            FieldInfo? fieldInfo = typeof(TaskOutStatusEnum).GetField(((TaskOutStatusEnum)item).ToString());
+                            DescriptionAttribute? descriptionAttribute = fieldInfo.GetCustomAttribute<DescriptionAttribute>();
+                            if (descriptionAttribute != null)
+                            {
+                                obj = new { title = item, description = descriptionAttribute.Description };
+                            }
+                            else
+                            {
+                                obj = new { title = item, description = ((TaskOutStatusEnum)item).ToString() };
+                            }
+                            list.Add(obj);
+                        }
 
                     }
                     else
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs"
index a9fbbb3..64dd609 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs"
@@ -468,7 +468,7 @@
             }
             catch (Exception ex)
             {
-                ServiceLogger.WriteDebug("ReceiveTask", $"浠诲姟鎺ユ敹閿欒,閿欒淇℃伅:{ex.Message}");
+                ServiceLogger.WriteDebug("ReceiveTask", $"浠诲姟鎺ユ敹閿欒,閿欒淇℃伅:{ex.StackTrace}");
                 content = WebResponseContent.Instance.Error($"浠诲姟鎺ユ敹閿欒,閿欒淇℃伅:{ex.Message}");
             }
             return content;
@@ -884,6 +884,7 @@
                     catch (Exception ex)
                     {
                         _unitOfWorkManage.RollbackTran();
+                        //浠诲姟鎵ц澶辫触锛岃揣浣嶇姸鎬佽繕鍘�
                         ServiceLogger.WriteDebug("StackCraneTaskCompleted", $"澶у爢鍨涙満鎵ц鍑哄簱浠诲姟澶辫触锛�,浠诲姟鍙�:銆恵taskNum}銆�,澶辫触淇℃伅:銆恵ex.Message}銆�");
                         content = WebResponseContent.Instance.Error($"澶у爢鍨涙満鎵ц鍑哄簱浠诲姟澶辫触锛�,浠诲姟鍙�:銆恵taskNum}銆�,澶辫触淇℃伅:銆恵ex.Message}銆�");
                     }
@@ -982,7 +983,7 @@
                 {
                     try
                     {
-                        Dt_LocationInfo srcLocation = _locationInfoRepository.QueryFirst(x => x.LocationCode == task.SourceAddress);
+                        //Dt_LocationInfo srcLocation = _locationInfoRepository.QueryFirst(x => x.LocationCode == task.SourceAddress);
                         //srcLocation.LocationStatus = (int)LocationStatusEnum.Free;
                         
 
@@ -1002,44 +1003,45 @@
                         MESResponse res = ApiInvoke.SendTaskCMD(sendcmd);
                         if (res != null && res.code != 0)
                         {
+                            ServiceLogger.WriteDebug("StackCraneTaskCompleted", $"灏忓爢鍨涙満瀹屾垚鍑哄簱浠诲姟鍚庡洖浼燤ES澶辫触锛�,浠诲姟鍙�:銆恵taskNum}銆�,澶辫触淇℃伅:銆恵res.message}銆�");
                             content = WebResponseContent.Instance.Error($"灏忓爢鍨涙満瀹屾垚鍑哄簱浠诲姟鍚庡洖浼燤ES澶辫触锛�,浠诲姟鍙�:銆恵taskNum}銆�,澶辫触淇℃伅:銆恵res.message}銆�");
                         }
-                        else
-                        {
-                            //鍒ゆ柇鏄惁瀹屾垚鐨勬渶鍚庝竴灞傦紝鑷姩鐢熸垚绌鸿溅鍑哄簱浠诲姟
-                            string[] Levels = task.Remark.Split("-");
-                            if (Levels.Length == 2)
-                            {
-                                if (!string.IsNullOrEmpty(Levels[0])&& !string.IsNullOrEmpty(Levels[1]))
-                                {
-                                    //濡傛灉褰撳墠鎻愬彇灞傛暟绛変簬鎬诲眰鏂欙紝鍒欒〃绀烘枡杞︽墍鏈夌殑灞傛暟鍙栧畬
-                                    if(Convert.ToInt16(Levels[0])== Convert.ToInt16(Levels[1]))
-                                    {
-                                        string[] SourceCodes = task.SourceAddress.Split("-");
-                                        string startPlan = "";
-                                        if (SourceCodes.Length == 4)
-                                        {
-                                            startPlan= "101"+ SourceCodes[2].Substring(1,2);
-                                        }
-                                        DeliveryPlan send = new DeliveryPlan { startPlan = startPlan, isQuit = false, CarId = task.PalletCode };
-                                        string inparam2 = JsonConvert.SerializeObject(send);
-                                        ServiceLogger.WriteDebug("StackCraneTaskCompleted", $"灏忓爢鍨涙満鎵ц鍑哄簱浠诲姟鍥炰紶MES鍏ュ弬{inparam2}");
-                                        ApiInvoke.DeliveryPlanCMD(send);//鍥炶皟MES鎺ュ彛鐢熸垚绌鸿溅鍑哄簱浠诲姟
-                                        //鎵�鏈夌殑灞傛暟閮藉彇瀹岋紝闇�瑕佹妸鏆傚瓨浣嶇姸鎬佹敼涓虹┖闂茬姸鎬�
-                                        srcLocation.LocationStatus = (int)LocationStatusEnum.Free;
-                                        _locationInfoRepository.UpdateData(srcLocation);
-                                    }
+                        //else
+                        //{
+                        //    //鍒ゆ柇鏄惁瀹屾垚鐨勬渶鍚庝竴灞傦紝鑷姩鐢熸垚绌鸿溅鍑哄簱浠诲姟
+                        //    string[] Levels = task.Remark.Split("-");
+                        //    if (Levels.Length == 2)
+                        //    {
+                        //        if (!string.IsNullOrEmpty(Levels[0])&& !string.IsNullOrEmpty(Levels[1]))
+                        //        {
+                        //            //濡傛灉褰撳墠鎻愬彇灞傛暟绛変簬鎬诲眰鏂欙紝鍒欒〃绀烘枡杞︽墍鏈夌殑灞傛暟鍙栧畬
+                        //            if(Convert.ToInt16(Levels[0])== Convert.ToInt16(Levels[1]))
+                        //            {
+                        //                string[] SourceCodes = task.SourceAddress.Split("-");
+                        //                string startPlan = "";
+                        //                if (SourceCodes.Length == 4)
+                        //                {
+                        //                    startPlan = "101" + SourceCodes[2].Substring(1, 2);
+                        //                }
+                        //                DeliveryPlan send = new DeliveryPlan { startPlan = startPlan, isQuit = false, CarId = task.PalletCode };
+                        //                string inparam2 = JsonConvert.SerializeObject(send);
+                        //                ServiceLogger.WriteDebug("StackCraneTaskCompleted", $"灏忓爢鍨涙満鎵ц鍑哄簱浠诲姟鍥炰紶MES鍏ュ弬{inparam2}");
+                        //                ApiInvoke.DeliveryPlanCMD(send);//鍥炶皟MES鎺ュ彛鐢熸垚绌鸿溅鍑哄簱浠诲姟
+                        //                鎵�鏈夌殑灞傛暟閮藉彇瀹岋紝闇�瑕佹妸鏆傚瓨浣嶇姸鎬佹敼涓虹┖闂茬姸鎬�
+                        //                srcLocation.LocationStatus = (int)LocationStatusEnum.Free;
+                        //                _locationInfoRepository.UpdateData(srcLocation);
+                        //            }
 
-                                }
+                        //        }
                               
-                            }
-                        }
+                        //    }
+                        //}
 
                     }
                     catch (Exception ex)
                     {
                         _unitOfWorkManage.RollbackTran();
-                        ServiceLogger.WriteDebug("StackCraneTaskCompleted", $"灏忓爢鍨涙満鎵ц鍑哄簱浠诲姟澶辫触锛�,浠诲姟鍙�:銆恵taskNum}銆�,澶辫触淇℃伅:銆恵ex.Message}銆�");
+                        ServiceLogger.WriteDebug("StackCraneTaskCompleted", $"灏忓爢鍨涙満鎵ц鍑哄簱浠诲姟澶辫触锛�,浠诲姟鍙�:銆恵taskNum}銆�,澶辫触淇℃伅:銆恵ex.StackTrace}銆�");
                         content = WebResponseContent.Instance.Error($"灏忓爢鍨涙満鎵ц鍑哄簱浠诲姟澶辫触锛�,浠诲姟鍙�:銆恵taskNum}銆�,澶辫触淇℃伅:銆恵ex.Message}銆�");
                     }
 
@@ -1060,6 +1062,8 @@
             return content;
         }
 
+
+
         /// <summary>
         /// 鎭㈠鎸傝捣浠诲姟
         /// </summary>
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs"
index 4102b58..2d2c8a0 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs"
@@ -49,6 +49,8 @@
 
         public Task Execute(IJobExecutionContext context)
         {
+            WriteDebug("澶у爢鍨涙満杩愯鏃ュ織", "寮�濮嬫椂闂�" + DateTime.Now);
+            WriteDebug("澶у爢鍨涙満杩愯鏃ュ織", $"澶у爢鍨涙満浠诲姟鎵ц涓�...");
             //CommonStackerCrane commonStackerCrane = (CommonStackerCrane)context.JobDetail.JobDataMap.Get("JobParams");
             CommonStackerCrane commonStackerCrane = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "SC01") as CommonStackerCrane;
             try
@@ -69,6 +71,7 @@
                             Dt_Task? task = GetTask(commonStackerCrane);
                             if (task != null)
                             {
+                                WriteDebug("澶у爢鍨涙満杩愯鏃ュ織", $"澶у爢鍨涙満浠诲姟鍙穥task.TaskNum}");
                                 StackerCraneTaskCommand? stackerCraneTaskCommand = ConvertToStackerCraneTaskCommand(task);
                                 if (stackerCraneTaskCommand != null)
                                 {
@@ -105,13 +108,13 @@
 
 
             //鏌ヨ鎻愬崌鏈�/缁勭珛鏈轰俊鍙�
-            Task.Run(delegate
-            {
+            //Task.Run(delegate
+            //{
                 try
                 {
-                   
                     if (commonStackerCrane != null)
                     {
+                       
                         Dt_Task? task1001 = _taskService.QueryStackerCraneTaskByAGVRequest("SC01");
                         if (task1001 != null)
                         {
@@ -143,12 +146,13 @@
                             int IsWriteTwo = 0;
                             if (task3001.SourceAddress == "SC01-002-000-001")//WMS 1001绔欑偣
                             {
+                                //鎻愬崌鏈烘槸鍚﹀浜庡氨缁姸鎬�
+                                int IsReady= commonStackerCrane.Communicator.Read<short>("DB2.0.0");
                                 //鍐欏叆鎻愬崌淇℃伅
                                 IsWriteOne = commonStackerCrane.Communicator.Read<short>("DB1.0.0");
-                                if(IsWriteOne == 0) 
+                                if(IsWriteOne == 0&& IsReady == 1) 
                                 {
-                                  
-                                   var d= commonStackerCrane.Communicator.Write<short>("DB1.0.0", 1);
+                                   commonStackerCrane.Communicator.Write<short>("DB1.0.0", 1);
                                 }
                                 //璇诲彇鎻愬崌鏈轰俊鍙凤紝纭畾鏄惁鎻愬崌瀹屾垚
                                
@@ -156,9 +160,11 @@
                             }
                             else if (task3001.SourceAddress == "SC01-002-000-002")//WMS 1002绔欑偣
                             {
+                                //鎻愬崌鏈烘槸鍚﹀浜庡氨缁姸鎬�
+                                int IsReady = commonStackerCrane.Communicator.Read<short>("DB2.0.0");
                                 //鍐欏叆鎻愬崌淇℃伅
                                 IsWriteTwo = commonStackerCrane.Communicator.Read<short>("DB1.6.0");
-                                if (IsWriteTwo == 0)
+                                if (IsWriteTwo == 0 && IsReady == 1)
                                 {
                                     commonStackerCrane.Communicator.Write<short>("DB1.6.0", 1);
                                 }    
@@ -176,8 +182,6 @@
                                 {
                                     WriteDebug(nameof(CommonStackerCraneJob), $"鎻愬崌鏈烘彁鍗囧畬鎴愶紝鍥炰紶WMS澶辫触锛佷换鍔″彿{task3001.TaskNum}");
                                 }
-
-
                             }
                         }
 
@@ -195,8 +199,12 @@
                                     if (!string.IsNullOrEmpty(Levels[0]) && !string.IsNullOrEmpty(Levels[1]))
                                     {
                                         int level = Convert.ToInt16(Levels[0]) - Convert.ToInt16(Levels[1]);
+
                                         //鍓╀綑灞傛暟鍐欏叆
                                         bool issuccess = commonStackerCrane.Communicator.Write<short>("DB28." + location.Depth + ".0", Convert.ToInt16(level));
+                                        WriteDebug(nameof(CommonStackerCraneJob), $"鍓╀綑灞傛暟淇″彿鍐欏叆{level}-浠诲姟鍙穥taskSmall.TaskNum}");
+
+
                                         //濡傛灉褰撳墠鎻愬彇灞傛暟绛変簬鎬诲眰鏁帮紝鍒欒〃绀烘枡杞︽墍鏈夌殑灞傛暟鍙栧畬
                                         if (level == 0)
                                         {
@@ -205,8 +213,21 @@
                                             {
                                                 //鏍规嵁鐩爣鍦板潃鏌ヨ缁勭珛鏈虹珯鐐逛俊鎭紝鑾峰彇鍐欏叆鏁磋溅瀹屾垚鐨凞B鍧� Depth
                                                 Dt_LocationInfo location2 = _locationInfoRepository.QueryFirst(x => x.LocationCode == location.Remark);
-                                                //鏁磋溅瀹屾垚鍐欏叆
-                                                bool issuccess2 = commonStackerCrane.Communicator.Write<short>("DB28." + location.Depth+".0", 1);
+                                            //鏁磋溅瀹屾垚鍐欏叆灞傛暟
+                                            int sn = 0;
+                                            if(taskSmall.SourceAddress== "SC01-001-006-001"|| taskSmall.SourceAddress == "SC01-001-012-001"|| taskSmall.SourceAddress == "SC01-001-018-001" || taskSmall.SourceAddress == "SC01-001-022-001"|| taskSmall.SourceAddress == "SC01-001-026-001")
+                                            {
+                                                sn = 1;
+                                            }
+                                            else if(taskSmall.SourceAddress == "SC01-001-007-001" || taskSmall.SourceAddress == "SC01-001-013-001" || taskSmall.SourceAddress == "SC01-001-019-001" || taskSmall.SourceAddress == "SC01-001-023-001" || taskSmall.SourceAddress == "SC01-001-027-001")
+                                            {
+                                                sn = 2;
+                                            }
+                                            else
+                                            {
+                                                sn = 3;
+                                            }
+                                            bool issuccess2 = commonStackerCrane.Communicator.Write<short>("DB28." + location2.Depth+".0", Convert.ToInt16(sn));
                                                 if (issuccess2&&issuccess)
                                                 {
                                                     _taskService.UpdateTaskStatus(taskSmall.TaskId, (int)TaskOutStatusEnum.OutFinish);
@@ -238,20 +259,15 @@
                             }
                             
                         }
-
-
-                    }
+                   
+                }
                 }
                 catch (Exception ex)
                 {
                     WriteError(nameof(CommonStackerCraneJob), "鏌ヨ鎴栧啓鍏LC鐘舵�佸け璐ワ紒", ex);
                 }
-
-
-            });
-
-
-
+            WriteDebug("澶у爢鍨涙満杩愯鏃ュ織", "缁撴潫鏃堕棿" + DateTime.Now);
+            //});
             return Task.CompletedTask;
         }
 
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/DoubleStackerCraneJob.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/DoubleStackerCraneJob.cs"
index fdac4dc..b5d847a 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/DoubleStackerCraneJob.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/DoubleStackerCraneJob.cs"
@@ -1,5 +1,6 @@
 锘縰sing HslCommunication;
 using Microsoft.AspNetCore.Components.Routing;
+using Newtonsoft.Json;
 using Quartz;
 using System;
 using System.Collections.Generic;
@@ -49,29 +50,23 @@
             _locationInfoRepository = locationInfoRepository;
         }
 
-        public Task Execute(IJobExecutionContext context)
+        public  Task Execute(IJobExecutionContext context)
         {
+            WriteDebug("灏忓爢鍨涙満杩愯鏃ュ織", "寮�濮嬫椂闂�" + DateTime.Now);
+            CommonStackerCrane? stackerCraneOne = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "SC02") as CommonStackerCrane;
+            CommonStackerCrane? stackerCraneTwo = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "SC03") as CommonStackerCrane;
+            WriteDebug(nameof(DoubleStackerCraneJob), $"灏忓爢鍨涙満浠诲姟鎵ц涓�...");
+          
             try
             {
-                CommonStackerCrane? stackerCraneOne = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "SC02") as CommonStackerCrane;
-                CommonStackerCrane? stackerCraneTwo = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "SC03") as CommonStackerCrane;
-
-                //Dt_DeviceInfo deviceSC02= _deviceInfoRepository.QueryFirst(x => x.DeviceCode == "SC02");
-                //Dt_DeviceInfo deviceSC03 = _deviceInfoRepository.QueryFirst(x => x.DeviceCode == "SC03");
-                //if(deviceSC02.DeviceStatus=="0")
-                //{
-                //    stackerCraneOne = null;
-                //}
-                //if(deviceSC03.DeviceStatus=="0")
-                //{
-                //    stackerCraneTwo = null;
-                //}
-                stackerCraneOne.CheckStackerCraneTaskCompleted();
+               
                 Dt_Task? task = GetTask();
+                
                 if (task != null)
                 {
-                    CommonStackerCrane? StackerCrane= GetStrackerCrane(task, stackerCraneOne, stackerCraneTwo);
-                    if(StackerCrane != null)
+                    WriteDebug("灏忓爢鍨涙満杩愯鏃ュ織", $"灏忓爢鍨涙満浠诲姟鍙穥task.TaskNum}");
+                    CommonStackerCrane? StackerCrane = GetStrackerCrane(task, stackerCraneOne, stackerCraneTwo);
+                    if (StackerCrane != null)
                     {
                         StackerCraneTaskCommand? stackerCraneTaskCommand = ConvertToStackerCraneTaskCommand(task);
                         if (stackerCraneTaskCommand != null)
@@ -86,16 +81,16 @@
                             else
                             {
                                 _taskService.UpdateTaskExceptionMessage(task.TaskNum, "鍫嗗灈鏈烘墽琛屼换鍔″懡浠ゅけ璐ワ紒");
-                                WriteDebug(nameof(CommonStackerCraneJob), "鍫嗗灈鏈烘墽琛屼换鍔″懡浠ゅけ璐ワ紒");
+                                WriteDebug(nameof(DoubleStackerCraneJob), "鍫嗗灈鏈烘墽琛屼换鍔″懡浠ゅけ璐ワ紒");
                             }
                         }
 
                     }
                     else
                     {
-                        WriteDebug(nameof(CommonStackerCraneJob), "鏈煡璇㈠埌褰撳墠鍙互鎵ц涓婃枡浠诲姟鐨勫皬鍫嗗灈鏈猴紒");
+                        WriteDebug(nameof(DoubleStackerCraneJob), "鏈煡璇㈠埌褰撳墠鍙互鎵ц涓婃枡浠诲姟鐨勫皬鍫嗗灈鏈猴紒");
                     }
-                  
+
                 }
 
             }
@@ -103,6 +98,53 @@
             {
                 WriteError(nameof(CommonStackerCraneJob), "灏忓爢鍨涙満鎵ц浠诲姟寮傚父锛�", ex);
             }
+
+            //璇诲彇鍫嗗灈鏈轰换鍔″彿鍜屼换鍔″畬鎴愮‘璁ょ姸鎬�
+            //Task.Run(delegate
+            //{
+               
+                try
+                {
+                    if (stackerCraneOne != null)
+                    {    
+                        byte IsFinish = stackerCraneOne.Communicator.Read<byte>("DB106.22");
+                        int tasknum = stackerCraneOne.Communicator.Read<int>("DB106.18");
+                        if (IsFinish == 6)
+                        {
+                            if (stackerCraneOne.GetValue<StackerCraneDBName, short>(StackerCraneDBName.WorkType) != 5)
+                            {
+                                //鏆傛椂 鍏堝啓5:瀹屾垚纭 淇″彿
+                                _taskService.StackCraneTaskCompleted(tasknum);
+                                stackerCraneOne.SetValue(StackerCraneDBName.WorkType, 5);
+
+                            }
+                        }
+                    }
+
+                    if (stackerCraneTwo != null)
+                    {
+                        //璇诲彇鍫嗗灈鏈轰换鍔″彿鍜屼换鍔″畬鎴愮‘璁ょ姸鎬�
+                        byte IsFinish = stackerCraneTwo.Communicator.Read<byte>("DB106.22");
+                        int tasknum = stackerCraneTwo.Communicator.Read<int>("DB106.18");
+                        if (IsFinish == 6)
+                        {
+                            if (stackerCraneTwo.GetValue<StackerCraneDBName, short>(StackerCraneDBName.WorkType) != 5)
+                            {
+                                _taskService.StackCraneTaskCompleted(tasknum);
+                                stackerCraneTwo.SetValue(StackerCraneDBName.WorkType, 5);
+                            }
+                        }
+                    }
+                }
+                catch (Exception ex)
+                {
+                    WriteError(nameof(DoubleStackerCraneJob), "鏌ヨ鎴栧啓鍏LC鐘舵�佸け璐ワ紒", ex);
+                }
+
+
+            //});
+
+            WriteDebug("灏忓爢鍨涙満杩愯鏃ュ織", "缁撴潫鏃堕棿" + DateTime.Now);
             return Task.CompletedTask;
         }
 
@@ -147,13 +189,9 @@
             {
                 if (stackerCraneOne != null)
                 {
-                    if (!stackerCraneOne.IsEventSubscribed)
-                    {
-                        stackerCraneOne.StackerCraneTaskCompletedEventHandler += CommonStackerCrane_StackerCraneTaskCompletedEventHandler;//璁㈤槄浠诲姟瀹屾垚浜嬩欢
-                    }
+
                     if (stackerCraneOne.StackerCraneAutoStatusValue == StackerCraneAutoStatus.Automatic && stackerCraneOne.StackerCraneStatusValue == StackerCraneStatus.Normal)
                     {
-                        stackerCraneOne.CheckStackerCraneTaskCompleted();//闃叉浠诲姟瀹屾垚浜嬩欢鐩戞祴瓒呮椂锛屽啀鎵嬪姩瑙﹀彂涓�娆�
                         if (stackerCraneOne.StackerCraneWorkStatusValue == StackerCraneWorkStatus.Standby)
                         {
                             return stackerCraneOne;
@@ -166,15 +204,17 @@
 
                         if (deviceSC02.DeviceStatus=="0"&& stackerCraneTwo != null)
                         {
-                            if (!stackerCraneTwo.IsEventSubscribed)
-                            {
-                                stackerCraneTwo.StackerCraneTaskCompletedEventHandler += CommonStackerCrane_StackerCraneTaskCompletedEventHandler;//璁㈤槄浠诲姟瀹屾垚浜嬩欢
-                            }
+                            //if (!stackerCraneTwo.IsEventSubscribed)
+                            //{
+                            //    stackerCraneTwo.StackerCraneTaskCompletedEventHandler += CommonStackerCrane_StackerCraneTaskCompletedEventHandler;//璁㈤槄浠诲姟瀹屾垚浜嬩欢
+                            //}
                             if (stackerCraneTwo.StackerCraneAutoStatusValue == StackerCraneAutoStatus.Automatic && stackerCraneTwo.StackerCraneStatusValue == StackerCraneStatus.Normal)
                             {
-                                stackerCraneTwo.CheckStackerCraneTaskCompleted();//闃叉浠诲姟瀹屾垚浜嬩欢鐩戞祴瓒呮椂锛屽啀鎵嬪姩瑙﹀彂涓�娆�
+                                //stackerCraneTwo.CheckStackerCraneTaskCompleted();//闃叉浠诲姟瀹屾垚浜嬩欢鐩戞祴瓒呮椂锛屽啀鎵嬪姩瑙﹀彂涓�娆�
                                 if (stackerCraneTwo.StackerCraneWorkStatusValue == StackerCraneWorkStatus.Standby)
                                 {
+                                    //todo:浠诲姟琛ㄤ腑鐨凴oadWay鍒囨崲涓篠C03
+
                                     return stackerCraneTwo;
                                 }
                             }
@@ -184,18 +224,34 @@
 
                     }
                 }
+                else
+                {
+                    if(stackerCraneTwo != null)
+                    {
+                        if (stackerCraneTwo.StackerCraneAutoStatusValue == StackerCraneAutoStatus.Automatic && stackerCraneTwo.StackerCraneStatusValue == StackerCraneStatus.Normal)
+                        {
+                            if (stackerCraneTwo.StackerCraneWorkStatusValue == StackerCraneWorkStatus.Standby)
+                            {
+                                //todo:浠诲姟琛ㄤ腑鐨凴oadWay鍒囨崲涓篠C03
+
+                                return stackerCraneTwo;
+                            }
+                        }
+                    }
+
+                }
             }
             else if (task.Roadway=="SC03")
             {
                 if (stackerCraneTwo != null)
-                {
-                    if (!stackerCraneTwo.IsEventSubscribed)
-                    {
-                        stackerCraneTwo.StackerCraneTaskCompletedEventHandler += CommonStackerCrane_StackerCraneTaskCompletedEventHandler;//璁㈤槄浠诲姟瀹屾垚浜嬩欢
-                    }
+                 {
+                //    if (!stackerCraneTwo.IsEventSubscribed)
+                //    {
+                //        stackerCraneTwo.StackerCraneTaskCompletedEventHandler += CommonStackerCrane_StackerCraneTaskCompletedEventHandler;//璁㈤槄浠诲姟瀹屾垚浜嬩欢
+                //    }
                     if (stackerCraneTwo.StackerCraneAutoStatusValue == StackerCraneAutoStatus.Automatic && stackerCraneOne.StackerCraneStatusValue == StackerCraneStatus.Normal)
                     {
-                        stackerCraneTwo.CheckStackerCraneTaskCompleted();//闃叉浠诲姟瀹屾垚浜嬩欢鐩戞祴瓒呮椂锛屽啀鎵嬪姩瑙﹀彂涓�娆�
+                        //stackerCraneTwo.CheckStackerCraneTaskCompleted();//闃叉浠诲姟瀹屾垚浜嬩欢鐩戞祴瓒呮椂锛屽啀鎵嬪姩瑙﹀彂涓�娆�
                         if (stackerCraneTwo.StackerCraneWorkStatusValue == StackerCraneWorkStatus.Standby)
                         {
                             return stackerCraneTwo;
@@ -206,15 +262,16 @@
                         Dt_DeviceInfo deviceSC03 = _deviceInfoRepository.QueryFirst(x => x.DeviceCode == "SC03");
                         if (deviceSC03.DeviceStatus=="0"&&stackerCraneOne != null)
                         {
-                            if (!stackerCraneOne.IsEventSubscribed)
-                            {
-                                stackerCraneOne.StackerCraneTaskCompletedEventHandler += CommonStackerCrane_StackerCraneTaskCompletedEventHandler;//璁㈤槄浠诲姟瀹屾垚浜嬩欢
-                            }
+                            //if (!stackerCraneOne.IsEventSubscribed)
+                            //{
+                            //    stackerCraneOne.StackerCraneTaskCompletedEventHandler += CommonStackerCrane_StackerCraneTaskCompletedEventHandler;//璁㈤槄浠诲姟瀹屾垚浜嬩欢
+                            //}
                             if (stackerCraneOne.StackerCraneAutoStatusValue == StackerCraneAutoStatus.Automatic && stackerCraneTwo.StackerCraneStatusValue == StackerCraneStatus.Normal)
                             {
-                                stackerCraneOne.CheckStackerCraneTaskCompleted();//闃叉浠诲姟瀹屾垚浜嬩欢鐩戞祴瓒呮椂锛屽啀鎵嬪姩瑙﹀彂涓�娆�
+                                //stackerCraneOne.CheckStackerCraneTaskCompleted();//闃叉浠诲姟瀹屾垚浜嬩欢鐩戞祴瓒呮椂锛屽啀鎵嬪姩瑙﹀彂涓�娆�
                                 if (stackerCraneOne.StackerCraneWorkStatusValue == StackerCraneWorkStatus.Standby)
                                 {
+                                    //todo锛氫换鍔¤〃涓殑RoadWay鍒囨崲涓篠C03
                                     return stackerCraneOne;
                                 }
                             }
@@ -222,6 +279,21 @@
 
                     }
                 }
+                else
+                {
+                    if(stackerCraneOne != null)
+                    {
+                        if (stackerCraneOne.StackerCraneAutoStatusValue == StackerCraneAutoStatus.Automatic && stackerCraneOne.StackerCraneStatusValue == StackerCraneStatus.Normal)
+                        {
+                            if (stackerCraneOne.StackerCraneWorkStatusValue == StackerCraneWorkStatus.Standby)
+                            {
+                                return stackerCraneOne;
+                            }
+
+                        }
+
+                    }
+                }
 
             }
             return null;

--
Gitblit v1.9.3