From 2c889b38311883ceb703c4e0034c798fdaa2e21c Mon Sep 17 00:00:00 2001
From: wangxinhui <wangxinhui@hnkhzn.com>
Date: 星期二, 12 八月 2025 23:11:57 +0800
Subject: [PATCH] 更新代码,货位分配优化等

---
 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/阻焊仓/AGV_ZHExtend.cs |   64 ++++++++++++++++++++++++++++---
 1 files changed, 57 insertions(+), 7 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\351\230\273\347\204\212\344\273\223/AGV_ZHExtend.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\351\230\273\347\204\212\344\273\223/AGV_ZHExtend.cs"
index a4da7dd..5289c17 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\351\230\273\347\204\212\344\273\223/AGV_ZHExtend.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\351\230\273\347\204\212\344\273\223/AGV_ZHExtend.cs"
@@ -7,6 +7,7 @@
 using WIDESEAWCS_Common.APIEnum;
 using WIDESEAWCS_Common.TaskEnum;
 using WIDESEAWCS_Core;
+using WIDESEAWCS_Core.Enums;
 using WIDESEAWCS_Core.Helper;
 using WIDESEAWCS_Model.Models;
 using WIDESEAWCS_QuartzJob;
@@ -43,7 +44,7 @@
                             },
                             new CodePath()
                             {
-                                type="00",
+                                type="04",
                                 positionCode=agvTask.NextAddress
                             }
                             },
@@ -90,6 +91,7 @@
                 var WaitToTasks = _taskService.Db.Queryable<Dt_Task>().Where(x => x.TaskState == TaskStatusEnum.AGV_WaitToExecute.ObjToInt() && nameof(AGV_ZHJob).Contains(x.DeviceCode)).ToList().OrderBy(x => x.Grade).ThenBy(x => x.CreateDate).ToList();
                 foreach (var WaitToTask in WaitToTasks)
                 {
+                    AgvSecureReplyDTO replyDTO = new AgvSecureReplyDTO();
                     if (WaitToTask.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup)
                     {
                         if (WaitToTasks.FirstOrDefault(x => x.TaskState == TaskStatusEnum.AGV_Puting.ObjToInt() || x.TaskState == TaskStatusEnum.Finish.ObjToInt()) != null)
@@ -119,6 +121,14 @@
                             continue;
                         }
                         otherDevice.SetValue(GroundStationDBName.W_PutPalletType, WaitToTask.PalletType, stationManger.StationCode);
+
+                        replyDTO.ReqCode = Guid.NewGuid().ToString().Replace("-", "");//WaitToTask.TaskNum.ToString(),
+                        replyDTO.taskCode = WaitToTask.AgvTaskNum;
+                        replyDTO.nextPositionCode = new CodePath()
+                        {
+                            type="00",
+                            positionCode= stationManger.AGVStationCode
+                        };
                     }
                     else
                     {
@@ -144,13 +154,9 @@
                         {
                             continue;
                         }
+                        replyDTO.ReqCode = Guid.NewGuid().ToString().Replace("-", "");//WaitToTask.TaskNum.ToString(),
+                        replyDTO.taskCode = WaitToTask.AgvTaskNum;
                     }
-
-                    AgvSecureReplyDTO replyDTO = new AgvSecureReplyDTO()
-                    {
-                        ReqCode = Guid.NewGuid().ToString().Replace("-", ""), //WaitToTask.TaskNum.ToString(),
-                        taskCode = WaitToTask.AgvTaskNum,
-                    };
                     WebResponseContent content = _taskService.AgvSecureReply(replyDTO);
                     if (content.Status && WaitToTask.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup)
                     {
@@ -171,6 +177,50 @@
                     }
                 }
                 _taskService.UpdateData(WaitToTasks);
+
+                //鍙栨斁璐у畬鎴愬啓鍏ュ紓甯稿鐞�
+                Dt_Task? TakeErroeTask = _taskService.Db.Queryable<Dt_Task>().Where(x => x.TaskState == TaskStatusEnum.AGV_TakeError.ObjToInt() && nameof(AGV_ZHJob).Contains(x.DeviceCode)).First();
+                if (TakeErroeTask != null)
+                {
+                    Dt_StationManger stationManger = _stationMangerRepository.QueryFirst(x => x.AGVStationCode == TakeErroeTask.CurrentAddress);
+                    if (stationManger == null)
+                    {
+                        throw new Exception($"鏈壘鍒扮珯鍙伴厤缃�");
+                    }
+                    IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationManger.StationDeviceCode);
+                    if (device == null)
+                    {
+                        throw new Exception($"鏈壘鍒板搴旇澶�");
+                    }
+                    OtherDevice otherDevice = (OtherDevice)device;
+                    otherDevice.SetValue(GroundStationDBName.W_TakeFinish, true, stationManger.StationCode);
+                    Thread.Sleep(1000);
+                    otherDevice.SetValue(GroundStationDBName.W_TakeFinish, false, stationManger.StationCode);
+                    TakeErroeTask.TaskState = TaskStatusEnum.AGV_Finish.ObjToInt();
+                    var up = _taskRepository.DeleteAndMoveIntoHty(TakeErroeTask, OperateTypeEnum.鑷姩瀹屾垚);
+                    _taskService.TaskCompleted(TakeErroeTask.TaskNum);
+                }
+                Dt_Task? PutErroeTask = _taskService.Db.Queryable<Dt_Task>().Where(x => x.TaskState == TaskStatusEnum.AGV_PutError.ObjToInt() && nameof(AGV_ZHJob).Contains(x.DeviceCode)).First();
+                if (PutErroeTask != null)
+                {
+                    Dt_StationManger stationManger = _stationMangerRepository.QueryFirst(x => x.AGVStationCode == PutErroeTask.NextAddress);
+                    if (stationManger == null)
+                    {
+                        throw new Exception($"鏈壘鍒扮珯鍙伴厤缃�");
+                    }
+                    IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationManger.StationDeviceCode);
+                    if (device == null)
+                    {
+                        throw new Exception($"鏈壘鍒扮珯鍙伴厤缃�");
+                    }
+                    OtherDevice otherDevice = (OtherDevice)device;
+                    otherDevice.SetValue(GroundStationDBName.W_PutFinish, true, stationManger.StationCode);
+                    PutErroeTask.CurrentAddress = stationManger.StationCode;
+                    PutErroeTask.NextAddress = "";
+                    PutErroeTask.TaskState = TaskStatusEnum.AGV_Finish.ObjToInt();
+                    PutErroeTask.DeviceCode = "SC01_ZH";
+                    var up = _taskRepository.UpdateData(PutErroeTask);
+                }
             }
             catch (Exception ex)
             {

--
Gitblit v1.9.3