From 88676143aeceaeec3bd108f9cd609c4f3470ba96 Mon Sep 17 00:00:00 2001
From: wangxinhui <wangxinhui@hnkhzn.com>
Date: 星期三, 30 七月 2025 15:07:32 +0800
Subject: [PATCH] Merge branch 'master' of http://115.159.85.185:8098/r/MeiRuiAn/HuaiAn

---
 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/成品仓/ConveyorLineJob_CP.cs |   33 ++++++++++++++++++++++-----------
 1 files changed, 22 insertions(+), 11 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 e098a47..1b4c87b 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"
@@ -1,4 +1,5 @@
-锘縰sing Newtonsoft.Json;
+锘縰sing Microsoft.AspNetCore.Components.Routing;
+using Newtonsoft.Json;
 using Quartz;
 using SqlSugar.Extensions;
 using System;
@@ -77,7 +78,7 @@
                     DeviceProDTO? deviceProWrite = device.DeviceProDTOs.Where(x => x.DeviceChildCode == item.StationCode && x.DeviceProParamType == nameof(W_ConveyorLineCPDB)).OrderBy(x => x.DeviceProOffset).FirstOrDefault();
                     if (item.StationType==StationTypeEnum.StationType_OnlyInbound.ObjToInt() && deviceProWrite!=null)
                     {
-                        Dt_Task task = _taskRepository.QueryFirst(x => x.CurrentAddress == item.StationCode && _taskService.TaskInboundTypes.Contains(x.TaskType) && (x.TaskState == TaskStatusEnum.New.ObjToInt()) && x.WarehouseId == warehouseDevice.WarehouseId);
+                        Dt_Task task = _taskRepository.QueryFirst(x => x.CurrentAddress == item.StationCode && _taskService.TaskInboundTypes.Contains(x.TaskType) && (x.TaskState == TaskStatusEnum.New.ObjToInt()) && x.DeviceCode == device.DeviceCode);
                         if (task!=null)
                         {
                             //鑾峰彇绔欏彴
@@ -94,30 +95,40 @@
                                 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);
                             device.SetValue(W_ConveyorLineCPDB.WorkType, task.PalletType, item.StationCode);
                             device.SetValue(W_ConveyorLineCPDB.WorkMode, 1, item.StationCode);
+                            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);
+                            }
                         }
                     }
                     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.WarehouseId == warehouseDevice.WarehouseId && x.TaskNum == conveyorLineInfoRead.TaskNum.ObjToInt());
+                                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)
@@ -138,12 +149,12 @@
                                         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);
                                 }
                             }
 
                         }
-                        
+
                     }
                 }
             }

--
Gitblit v1.9.3