From b51a65433d6102f2f8f00226404d9ca3808404af Mon Sep 17 00:00:00 2001
From: hutongqing <hutongqing@hnkhzn.com>
Date: 星期四, 02 一月 2025 22:23:17 +0800
Subject: [PATCH] 打印托盘号

---
 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs |   47 +++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 39 insertions(+), 8 deletions(-)

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 3ab0634..20acae2 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"
@@ -34,6 +34,7 @@
 using WIDESEAWCS_Core.Enums;
 using WIDESEAWCS_Core.Helper;
 using WIDESEAWCS_DTO.BasicInfo;
+using WIDESEAWCS_DTO.System;
 using WIDESEAWCS_DTO.TaskInfo;
 using WIDESEAWCS_IBasicInfoRepository;
 using WIDESEAWCS_ITaskInfoRepository;
@@ -56,6 +57,7 @@
         private readonly ITaskExecuteDetailRepository _taskExecuteDetailRepository;
         private readonly IStationMangerRepository _stationMangerRepository;
         private readonly IRouterRepository _routerRepository;
+        private readonly IApiInfoRepository _apiInfoRepository;
         private List<Dt_ApiInfo> apiInfos;
 
         private Dictionary<string, OrderByType> _taskOrderBy = new()
@@ -72,7 +74,7 @@
 
         public List<int> TaskOutboundTypes => typeof(TaskTypeEnum).GetEnumIndexList().Where(x => x >= 100 && x < 500).ToList();
 
-        public TaskService(ITaskRepository BaseDal, IMapper mapper, ICacheService cacheService, IRouterService routerService, ITaskExecuteDetailService taskExecuteDetailService, ITaskExecuteDetailRepository taskExecuteDetailRepository, IStationMangerRepository stationMangerRepository, IRouterRepository routerRepository) : base(BaseDal)
+        public TaskService(ITaskRepository BaseDal, IMapper mapper, ICacheService cacheService, IRouterService routerService, ITaskExecuteDetailService taskExecuteDetailService, ITaskExecuteDetailRepository taskExecuteDetailRepository, IStationMangerRepository stationMangerRepository, IRouterRepository routerRepository, IApiInfoRepository apiInfoRepository) : base(BaseDal)
         {
             _mapper = mapper;
             _cacheService = cacheService;
@@ -81,6 +83,7 @@
             _taskExecuteDetailRepository = taskExecuteDetailRepository;
             _stationMangerRepository = stationMangerRepository;
             _routerRepository = routerRepository;
+            _apiInfoRepository = apiInfoRepository;
 
             string? cacheStr = _cacheService.Get(nameof(Dt_Warehouse));
             if (!string.IsNullOrEmpty(cacheStr))
@@ -102,7 +105,6 @@
                     apiInfos = infos;
                 }
             }
-
         }
 
         public WebResponseContent TaskCompleted(int taskNum)
@@ -161,6 +163,7 @@
 
                     if (string.IsNullOrEmpty(item.AGVArea))
                     {
+                        //task.AgvTaskNum = "AGV-" + DateTime.Now.ToString("yyyyMMdd") + item.TaskNum;
                         Dt_StationManger stationManger = _stationMangerRepository.QueryFirst(x => x.StationCode == item.SourceAddress || x.StackerCraneCode == item.RoadWay);
                         if (stationManger == null)
                         {
@@ -176,22 +179,50 @@
                         if (routers.Count == 1)
                         {
                             task.NextAddress = router?.NextPosi ?? "";
+                            task.DeviceCode = stationManger.StationDeviceCode;
                         }
                         else
                         {
                             task.NextAddress = "";
+                            task.DeviceCode = "";
                         }
                     }
                     else
                     {
-                        List<Dt_Router> routers = _routerRepository.QueryData(x => x.InOutType == item.TaskType && item.AGVArea == x.StartPosi);
-                        if (routers.FirstOrDefault() == null)
+                        if (item.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
                         {
-                            return WebResponseContent.Instance.Error($"鏈壘鍒拌矾鐢遍厤缃俊鎭�");
-                        }
-                        router = routers.FirstOrDefault();
+                            task.AgvTaskNum = "AGV-" + DateTime.Now.ToString("yyyyMMdd") + item.TaskNum;
+                            List<Dt_Router> routers = _routerRepository.QueryData(x => x.InOutType == item.TaskType && item.AGVArea == x.NextPosi);
+                            if (routers.FirstOrDefault() == null)
+                            {
+                                return WebResponseContent.Instance.Error($"鏈壘鍒拌矾鐢遍厤缃俊鎭�");
+                            }
+                            router = routers.FirstOrDefault();
 
-                        task.NextAddress = router?.NextPosi ?? "";
+                            task.NextAddress = router?.StartPosi ?? "";
+                            task.DeviceCode = item.RoadWay;
+                            task.TaskState = TaskStatusEnum.SC_Execute.ObjToInt();
+                        }
+                        else
+                        {
+                            task.AgvTaskNum = "AGV-" + DateTime.Now.ToString("yyyyMMdd") + item.TaskNum;
+                            List<Dt_Router> routers = _routerRepository.QueryData(x => x.InOutType == item.TaskType && item.AGVArea == x.StartPosi);
+                            if (routers.FirstOrDefault() == null)
+                            {
+                                return WebResponseContent.Instance.Error($"鏈壘鍒拌矾鐢遍厤缃俊鎭�");
+                            }
+                            router = routers.FirstOrDefault();
+                            string stationCode = router?.NextPosi ?? "";
+                            Dt_StationManger? stationManger = _stationMangerRepository.QueryFirst(x => x.StationCode == stationCode);
+                            if (stationManger == null)
+                            {
+                                return WebResponseContent.Instance.Error($"鏈壘鍒扮珯鍙伴厤缃俊鎭�");
+                            }
+
+                            task.NextAddress = stationManger?.AGVStationCode ?? "";
+                            task.DeviceCode = stationManger?.Remark ?? "";
+                            task.TaskState = TaskStatusEnum.AGV_Execute.ObjToInt();
+                        }
                     }
 
                     tasks.Add(task);

--
Gitblit v1.9.3