From c29940a5ff8b56d96d4fe0fee2076a278e52e9c5 Mon Sep 17 00:00:00 2001
From: Admin <Admin@ADMIN>
Date: 星期三, 28 一月 2026 09:54:45 +0800
Subject: [PATCH] 优化出库

---
 项目代码/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs |   72 ++++++++++++++++++++++++++++++++---
 1 files changed, 65 insertions(+), 7 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs"
index 1059b9f..0b98b42 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs"
@@ -60,6 +60,7 @@
         private readonly ILocationInfoService _locationInfoService;
         private readonly IWarehouseService _warehouseService;
         private readonly IRoadWayinfoService _roadWayinfoService;
+        private readonly ITask_HtyService _task_HtyService;
         private Timer _timer;
         public IRepository<Dt_Task> Repository => BaseDal;
 
@@ -74,7 +75,7 @@
         public List<int> TaskOutboundTypes => typeof(TaskTypeEnum).GetEnumIndexList();
 
         public TaskService(ILogger<TaskService> logger, IRepository<Dt_Task> BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IStockInfoService stockInfoService, ILocationInfoService locationInfoService,
-            IWarehouseService warehouseService, IRoadWayinfoService roadWayinfoService) : base(BaseDal)
+            IWarehouseService warehouseService, IRoadWayinfoService roadWayinfoService, ITask_HtyService task_HtyService) : base(BaseDal)
         {
             _logger = logger;
             _mapper = mapper;
@@ -82,8 +83,8 @@
             _stockInfoService = stockInfoService;
             _locationInfoService = locationInfoService;
             _warehouseService = warehouseService;
-            _roadWayinfoService=roadWayinfoService;
-
+            _roadWayinfoService = roadWayinfoService;
+            _task_HtyService = task_HtyService;
         }
         public string MES_InReporttask = WIDESEA_Core.Helper.AppSettings.Configuration["MES_InReporttask"]; //鍏ュ簱鍙嶉淇℃伅
         public string MES_OutReporttask = WIDESEA_Core.Helper.AppSettings.Configuration["MES_OutReporttask"];   //鍑哄簱鍙嶉淇℃伅
@@ -192,7 +193,7 @@
             {
                 Dt_Task task = BaseDal.QueryFirst(x => x.TaskId == wCSTask.TaskNum && x.PalletCode == wCSTask.PalletCode);
                 if (task == null)
-                    return webResponse.Error("鏈壘鍒颁换鍔′俊鎭�");
+                    return webResponse.Error("鏈壘鍒颁换鍔′俊鎭�", 404);
                 return TaskCompletedtask(task, wCSTask.TaskType);
             }
             catch (Exception ex)
@@ -503,6 +504,8 @@
                         MES_parameter mES_Parameter = AbnormalStorageLocation(task.PalletCode, task.SourceAddress, task.TargetAddress);
                         if (mES_Parameter.Result == "Y")
                         {
+                            Dt_Task dtOutWit=BaseDal.QueryData(x=>x.PalletCode==task.PalletCode && x.TaskStatus== (int)OutTaskStatusEnum.OutWait).FirstOrDefault();
+
                             Dt_LocationInfo OriginalLocation = _locationInfoService.Repository.QueryData(x => x.LocationCode == task.SourceAddress).FirstOrDefault();
                             Dt_LocationInfo NewLocation = _locationInfoService.Repository.QueryData(x => x.LocationCode == task.TargetAddress).FirstOrDefault();
                             Dt_StockInfo dt_StockInfo = _stockInfoService.Repository.QueryData(x => x.LocationCode == task.SourceAddress).FirstOrDefault();
@@ -510,15 +513,22 @@
                             List<Dt_LocationInfo> dt_Locations = new List<Dt_LocationInfo>();
 
                             OriginalLocation.LocationStatus = (int)LocationStatusEnum.Free;
-                            NewLocation.LocationStatus = (int)LocationStatusEnum.InStock;
+                            NewLocation.LocationStatus = dtOutWit != null? (int)LocationStatusEnum.Lock:(int)LocationStatusEnum.InStock;
                             dt_StockInfo.LocationCode = NewLocation.LocationCode;
-                            dt_StockInfo.StockStatus = (int)StockStatusEmun.宸插叆搴�;
+                            dt_StockInfo.StockStatus = dtOutWit != null? (int)StockStatusEmun.鍑哄簱涓�:(int)StockStatusEmun.宸插叆搴�;
                             task.TaskStatus = (int)RelocationTaskStatusEnum.RelocationFinish;
+
+                            dtOutWit.TaskStatus = (int)OutTaskStatusEnum.OutNew;
+                            dtOutWit.SourceAddress = NewLocation.LocationCode;
+                            dtOutWit.CurrentAddress = NewLocation.LocationCode;
+
+
 
                             dt_Locations.Add(OriginalLocation);
                             dt_Locations.Add(NewLocation);
 
                             _unitOfWorkManage.BeginTran();
+                            BaseDal.UpdateData(dtOutWit);
                             _locationInfoService.UpdateData(dt_Locations);
                             _stockInfoService.UpdateData(dt_StockInfo);
                             BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateTypeEnum.鑷姩瀹屾垚 : OperateTypeEnum.浜哄伐瀹屾垚);
@@ -699,11 +709,59 @@
             return BaseDal.QueryData(x => x.TaskStatus == (int)RelocationTaskStatusEnum.RelocationNew && x.CurrentAddress == LocationCode).FirstOrDefault();
         }
 
+        public Dt_Task GeOutCuTaskQueue(string LocationCode)
+        {
+            return BaseDal.QueryData(x => x.TaskStatus == (int)OutTaskStatusEnum.OutNew && x.SourceAddress == LocationCode).FirstOrDefault();
+        }
+
         public bool RelocationTaskProgress(string deviceId)
         {
-            int taskcount = BaseDal.QueryData(x => x.Roadway == deviceId && x.TaskStatus == (int)RelocationTaskStatusEnum.RelocationExecuting).Count();
+            int taskcount = BaseDal.QueryData(x => x.Roadway == deviceId && (x.TaskStatus == (int)RelocationTaskStatusEnum.RelocationExecuting || x.TaskStatus == (int)RelocationTaskStatusEnum.RelocationNew) ).Count();
             if (taskcount == 0) return false;
             return true;
         }
+
+        //浠撳簱瀹归噺鐘舵��
+        public WebResponseContent GetWarehouseCapacity()
+        {
+            return _locationInfoService.GetWarehouseCapacity();
+        }
+
+        //鍑哄叆搴撶被鍨嬪垎甯�
+        public WebResponseContent GetInOutTypeStats()
+        {
+            return _task_HtyService.GetInOutTypeStats();
+        }
+        //娴侀噺鎯呭喌缁熻
+
+        public WebResponseContent GetTodayTrafficStats()
+        {
+            return _task_HtyService.GetTodayInOutStats();
+        }
+        //褰撳墠杩涜鐨勪换鍔�
+        public WebResponseContent GetCurrentTasks()
+        {
+            // 鏌ヨ鎵�浠ヨ繑鍥濼askNum锛孴askType锛孋reateDate锛孴askStatus锛�
+            var tasks = BaseDal.QueryData()
+                        .Select(t => new
+                        {
+                            WarehouseId = t.Roadway == "1" || t.Roadway == "2" ? 1 : 2,
+                            PalletType = t.PalletType,
+                            TaskNum = t.TaskId,
+                            TaskType = t.TaskType,
+                            CreateDate = t.CreateDate,
+                            TaskStatus = t.TaskStatus
+                        })
+                        .ToList();
+            return WebResponseContent.Instance.OK("鎴愬姛", tasks);
+        }
+        //鎬讳綋杩涘害
+        public WebResponseContent GetWarehouseOperationStatistics()
+        {
+            /// <summary>
+            /// 鍘熸枡浠擄紝鎬诲嚭鍏ュ簱浠诲姟鏁伴噺锛屼粖鏃ュ叆搴擄紝浠婃棩鍑哄簱锛屼粖鏃ュ緟瀹屾垚锛屼粖鏃ュ紓甯镐换鍔★紝鎴愬搧浠擄紝鎬诲嚭鍏ュ簱鏁伴噺锛屼粖鏃ュ叆搴擄紝浠婃棩鍑哄簱锛屼粖鏃ュ緟瀹屾垚
+            /// </summary>
+            return _task_HtyService.GetWarehouseOperationStatistics();
+        }
     }
 }

--
Gitblit v1.9.3