From 680ccbedf08839143215f40dea5273dc2819100c Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期三, 30 十月 2024 23:26:33 +0800
Subject: [PATCH] 优化WMS、WCS用户管理

---
 项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs |   55 ++++++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 44 insertions(+), 11 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 5a9c830..bb6c530 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,8 +25,10 @@
 using System.Text;
 using System.Threading.Tasks;
 using WIDESEAWCS_Common.ConveyorLineEnum;
+using WIDESEAWCS_Common.TaskEnum;
 using WIDESEAWCS_Core;
 using WIDESEAWCS_Core.Helper;
+using WIDESEAWCS_DTO.WMSInfo;
 using WIDESEAWCS_ITaskInfoService;
 using WIDESEAWCS_Model.Models;
 using WIDESEAWCS_QuartzJob;
@@ -110,16 +112,39 @@
         /// <param name="childDeviceCode">瀛愯澶囩紪鍙�</param>
         public void RequestInbound(CommonConveyorLine conveyorLine, ConveyorLineTaskCommandR command, string childDeviceCode)
         {
-            if (_taskService.RequestWMSTask(command.Barcode, childDeviceCode).Status)//闇�娣诲姞鍜學MS鎺ュ彛锛侊紒锛侊紒锛侊紒锛侊紒锛侊紒锛侊紒锛侊紒锛侊紒锛侊紒锛侊紒
+            Dt_Task task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode, command.Barcode);
+            if (task != null)
             {
-                Dt_Task task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode);
-                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);
 
-                    conveyorLine.SendCommand(taskCommand, childDeviceCode);
-
-                    _taskService.UpdateTaskStatusToNext(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);
+                    }
                 }
             }
         }
@@ -154,12 +179,20 @@
         public void ConveyorLineInFinish(CommonConveyorLine conveyorLine, ConveyorLineTaskCommandR command, string childDeviceCode)
         {
             Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode);
-            if (task != null)
+            if (task != null) _taskService.UpdateTaskStatusToNext(task);
+
+            task = _taskService.QueryCompletedConveyorLineTask(command.TaskNum, childDeviceCode);
+            if (task != null && string.IsNullOrEmpty(task.TargetAddress))
             {
-                //conveyorLine.SetValue(ConveyorLineDBName.WriteInteractiveSignal, 0, childDeviceCode);
-                WebResponseContent content = _taskService.UpdateTaskStatusToNext(task);
-                //Console.Out.WriteLine(content.Serialize());
+                _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>
@@ -170,7 +203,7 @@
         /// <param name="childDeviceCode">瀛愯澶囩紪鍙�</param>
         public void RequestOutbound(CommonConveyorLine conveyorLine, ConveyorLineTaskCommandR command, string childDeviceCode)
         {
-            Dt_Task task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode);
+            Dt_Task task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode, command.Barcode);
             if (task != null)
             {
                 ConveyorLineTaskCommandW taskCommand = _mapper.Map<ConveyorLineTaskCommandW>(task);

--
Gitblit v1.9.3