From 95e39ae7aecd6e1016c71cf5ae70a680d8f569bb Mon Sep 17 00:00:00 2001
From: wangxinhui <wangxinhui@hnkhzn.com>
Date: 星期二, 29 四月 2025 10:48:30 +0800
Subject: [PATCH] 上传最新代码

---
 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/成品仓/ConveyorLineJob_CP.cs |  102 +++++++++++++++++++++++++++------------------------
 1 files changed, 54 insertions(+), 48 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\346\210\220\345\223\201\344\273\223/ConveyorLineJob_CP.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\346\210\220\345\223\201\344\273\223/ConveyorLineJob_CP.cs"
index 35da841..be2511e 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\346\210\220\345\223\201\344\273\223/ConveyorLineJob_CP.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\346\210\220\345\223\201\344\273\223/ConveyorLineJob_CP.cs"
@@ -95,8 +95,13 @@
                                 WriteError(item.StationName, $"鏈壘鍒拌矾鐢遍厤缃俊鎭�,璁惧缂栧彿:{item.StationCode},浠诲姟鍙�:{task.TaskNum}");
                                 continue;
                             }
-                            _taskService.UpdateTask(task, TaskStatusEnum.Line_Executing, nextAddress: router.NextPosi, targetAddress: router.NextPosi);
-                            device.SetValue(W_ConveyorLineCPDB.StartPos, task.CurrentAddress, item.StationCode);
+                            //string? locationCode = _taskService.RequestAssignLocation(task.TaskNum, "AGV_CP");
+                            //if (string.IsNullOrEmpty(locationCode) && task.TaskType != TaskTypeEnum.EmptyProductBack.ObjToInt())
+                            //{
+                            //    WriteError(item.StationName, $"璇锋眰鍒嗛厤璐т綅杩斿洖淇℃伅閿欒,璁惧缂栧彿:{item.StationCode},浠诲姟鍙�:{task.TaskNum}");
+                            //    continue;
+                            //}
+                            device.SetValue(W_ConveyorLineCPDB.StartPos, router.StartPosi, item.StationCode);
                             device.SetValue(W_ConveyorLineCPDB.EndPos, router.NextPosi, item.StationCode);
                             device.SetValue(W_ConveyorLineCPDB.Barcode, task.PalletCode, item.StationCode);
                             device.SetValue(W_ConveyorLineCPDB.TaskNum, task.TaskNum, item.StationCode);
@@ -105,6 +110,7 @@
                             device.SetValue(W_ConveyorLineCPDB.CheckPos, 1, item.StationCode);
                             //鍚姩鎸囦护
                             device.SetValue(W_ConveyorLineCPDB.ConveyArrival, 1, item.StationCode);
+                            _taskService.UpdateTask(task, TaskStatusEnum.Line_Executing, nextAddress: router.NextPosi, targetAddress: router.NextPosi);
                             if (task.TaskType==TaskTypeEnum.EmptyProductBack.ObjToInt())
                             {
                                 _taskService.TaskCompleted(task.TaskNum);
@@ -114,15 +120,15 @@
                     else if (item.StationType == StationTypeEnum.StationType_InStartAndOutEnd.ObjToInt() && deviceProRead != null)
                     {
                         R_ConveyorLineCPInfo conveyorLineInfoRead = device.Communicator.ReadCustomer<R_ConveyorLineCPInfo>(deviceProRead.DeviceProAddress);
-                        if (conveyorLineInfoRead != null && conveyorLineInfoRead.EndPos.ToString()==item.StationCode)
+                        if (conveyorLineInfoRead != null && conveyorLineInfoRead.EndPos.ToString() == item.StationCode)
                         {
                             short isCanTake = device.GetValue<GroundStationDBName, short>(GroundStationDBName.R_IsCanTake, item.StationCode);
-                            if (conveyorLineInfoRead.ConveyArrivaled==1 && isCanTake==1)
+                            if (conveyorLineInfoRead.ConveyArrivaled == 1 && isCanTake == 1)
                             {
                                 //鑾峰彇浠诲姟
                                 Dt_Task task = _taskRepository.QueryFirst(x => x.NextAddress == item.StationCode && _taskService.TaskInboundTypes.Contains(x.TaskType) && (x.TaskState == TaskStatusEnum.Line_Executing.ObjToInt()) && x.DeviceCode == device.DeviceCode && x.TaskNum == conveyorLineInfoRead.TaskNum.ObjToInt());
                                 //鑾峰彇绔欏彴
-                                if (task!=null)
+                                if (task != null)
                                 {
                                     Dt_StationManger? stationManger = stationMangers.FirstOrDefault(x => x.StationCode == item.StationCode);
                                     if (stationManger == null)
@@ -143,55 +149,55 @@
                                         WriteError(item.StationName, $"璇锋眰鍒嗛厤璐т綅杩斿洖淇℃伅閿欒,璁惧缂栧彿:{item.StationCode},浠诲姟鍙�:{task.TaskNum}");
                                         continue;
                                     }
-                                    _taskService.UpdateTask(task, TaskStatusEnum.AGV_Execute,deviceCode: router.ChildPosiDeviceCode, nextAddress: locationCode, targetAddress: locationCode, currentAddress: router.StartPosi);
+                                    _taskService.UpdateTask(task, TaskStatusEnum.AGV_Execute, deviceCode: router.ChildPosiDeviceCode, currentAddress: router.StartPosi, nextAddress: locationCode, targetAddress: locationCode);
                                 }
                             }
 
                         }
-                        
+
                     }
                 }
-                Dt_StationManger? dt_StationManger = stationMangers.FirstOrDefault(x => x.StationType == StationTypeEnum.StationType_ProductBackTake.ObjToInt());
-                if (dt_StationManger != null)
-                {
-                    DeviceProDTO? deviceProWrite = device.DeviceProDTOs.Where(x => x.DeviceChildCode == dt_StationManger.StationCode && x.DeviceProParamType == nameof(W_ConveyorLineCPDB)).OrderBy(x => x.DeviceProOffset).FirstOrDefault();
-                    List<Dt_StationManger> ProductBackStations = stationMangers.Where(x => x.StationType == StationTypeEnum.StationType_ProductBack.ObjToInt()).ToList();
-                    for (int i = 0; i < ProductBackStations.Count(); i++)
-                    {
-                        short isCanTake = device.GetValue<GroundStationDBName, short>(GroundStationDBName.R_IsCanTake, dt_StationManger.StationCode);
-                        Dt_StationManger stationManger = ProductBackStations[i];
-                        string startDb = "DB29.";
-                        short stationCurrentStatus = device.Communicator.Read<short>(startDb + stationManger.Remark.ToString());
-                        short stationEndStatus = device.Communicator.Read<short>(startDb + (stationManger.Remark.ObjToInt() + 2).ToString());
-                        bool endStatus = true;
-                        if ((i != 2 && i != 5 && i != 8))
-                        {
-                            endStatus = (stationEndStatus == 1);
-                        }
-                        //璇诲彇绾夸綋娈电姸鎬�
-                        if (isCanTake == 1 && stationCurrentStatus == 1 && stationManger.IsOccupied==0 && endStatus)
-                        {
-                            device.SetValue(W_ConveyorLineCPDB.StartPos, dt_StationManger.StationCode, dt_StationManger.StationCode);
-                            device.SetValue(W_ConveyorLineCPDB.EndPos, stationManger.AGVStationCode, dt_StationManger.StationCode);
-                            device.SetValue(W_ConveyorLineCPDB.Barcode, "C00001", dt_StationManger.StationCode);
-                            device.SetValue(W_ConveyorLineCPDB.TaskNum, DateTime.Now.ToString("yyMMddHHmmss"), dt_StationManger.StationCode);
-                            device.SetValue(W_ConveyorLineCPDB.WorkType, 1, dt_StationManger.StationCode);
-                            device.SetValue(W_ConveyorLineCPDB.WorkMode, 1, dt_StationManger.StationCode);
-                            device.SetValue(W_ConveyorLineCPDB.CheckPos, 1, dt_StationManger.StationCode);
-                            //鍚姩鎸囦护
-                            device.SetValue(W_ConveyorLineCPDB.ConveyArrival, 1, dt_StationManger.StationCode);
-                            stationManger.IsOccupied = 1;
-                            _stationMangerRepository.UpdateData(stationManger);
-                            Thread.Sleep(2000);
-                            return Task.CompletedTask;
-                        }
-                        else if(stationManger.IsOccupied == 1 && (stationCurrentStatus == 3))
-                        {
-                            stationManger.IsOccupied = 0;
-                            _stationMangerRepository.UpdateData(stationManger);
-                        }
-                    }
-                }
+                //Dt_StationManger? dt_StationManger = stationMangers.FirstOrDefault(x => x.StationType == StationTypeEnum.StationType_ProductBackTake.ObjToInt());
+                //if (dt_StationManger != null)
+                //{
+                //    DeviceProDTO? deviceProWrite = device.DeviceProDTOs.Where(x => x.DeviceChildCode == dt_StationManger.StationCode && x.DeviceProParamType == nameof(W_ConveyorLineCPDB)).OrderBy(x => x.DeviceProOffset).FirstOrDefault();
+                //    List<Dt_StationManger> ProductBackStations = stationMangers.Where(x => x.StationType == StationTypeEnum.StationType_ProductBack.ObjToInt()).ToList();
+                //    for (int i = 0; i < ProductBackStations.Count(); i++)
+                //    {
+                //        short isCanTake = device.GetValue<GroundStationDBName, short>(GroundStationDBName.R_IsCanTake, dt_StationManger.StationCode);
+                //        Dt_StationManger stationManger = ProductBackStations[i];
+                //        string startDb = "DB29.";
+                //        short stationCurrentStatus = device.Communicator.Read<short>(startDb + stationManger.Remark.ToString());
+                //        short stationEndStatus = device.Communicator.Read<short>(startDb + (stationManger.Remark.ObjToInt() + 2).ToString());
+                //        bool endStatus = true;
+                //        if ((i != 2 && i != 5 && i != 8))
+                //        {
+                //            endStatus = (stationEndStatus == 1);
+                //        }
+                //        //璇诲彇绾夸綋娈电姸鎬�
+                //        if (isCanTake == 1 && stationCurrentStatus == 1 && stationManger.IsOccupied==0 && endStatus)
+                //        {
+                //            device.SetValue(W_ConveyorLineCPDB.StartPos, dt_StationManger.StationCode, dt_StationManger.StationCode);
+                //            device.SetValue(W_ConveyorLineCPDB.EndPos, stationManger.AGVStationCode, dt_StationManger.StationCode);
+                //            device.SetValue(W_ConveyorLineCPDB.Barcode, "C00001", dt_StationManger.StationCode);
+                //            device.SetValue(W_ConveyorLineCPDB.TaskNum, DateTime.Now.ToString("yyMMddHHmmss"), dt_StationManger.StationCode);
+                //            device.SetValue(W_ConveyorLineCPDB.WorkType, 1, dt_StationManger.StationCode);
+                //            device.SetValue(W_ConveyorLineCPDB.WorkMode, 1, dt_StationManger.StationCode);
+                //            device.SetValue(W_ConveyorLineCPDB.CheckPos, 1, dt_StationManger.StationCode);
+                //            //鍚姩鎸囦护
+                //            device.SetValue(W_ConveyorLineCPDB.ConveyArrival, 1, dt_StationManger.StationCode);
+                //            stationManger.IsOccupied = 1;
+                //            _stationMangerRepository.UpdateData(stationManger);
+                //            Thread.Sleep(2000);
+                //            return Task.CompletedTask;
+                //        }
+                //        else if(stationManger.IsOccupied == 1 && (stationCurrentStatus == 3))
+                //        {
+                //            stationManger.IsOccupied = 0;
+                //            _stationMangerRepository.UpdateData(stationManger);
+                //        }
+                //    }
+                //}
                 
             }
             return Task.CompletedTask;

--
Gitblit v1.9.3