From 5732962e2fe146d81273b4b02faaec87c05f0417 Mon Sep 17 00:00:00 2001
From: wangxinhui <wangxinhui@hnkhzn.com>
Date: 星期一, 30 十二月 2024 00:29:19 +0800
Subject: [PATCH] 1

---
 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs |   23 ++++++++++++++++++-----
 1 files changed, 18 insertions(+), 5 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 f7e3c24..2080ff3 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)
                         {
@@ -186,8 +189,9 @@
                     }
                     else
                     {
-                        if(item.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
+                        if (item.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
                         {
+                            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)
                             {
@@ -197,18 +201,27 @@
 
                             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 = router?.NextPosi ?? "";
-                            task.DeviceCode = "AGV";
+                            task.NextAddress = stationManger?.AGVStationCode ?? "";
+                            task.DeviceCode = "AGV_CSJ";
+                            task.TaskState = TaskStatusEnum.AGV_Execute.ObjToInt();
                         }
                     }
 

--
Gitblit v1.9.3