From ad7bfeb2c3c948a5fc83e4459c51bfbeb0e271a5 Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期六, 28 十二月 2024 13:58:30 +0800
Subject: [PATCH] PDA

---
 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs |   57 +++++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 39 insertions(+), 18 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs"
index 6a05e7a..607c8f4 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs"
@@ -25,6 +25,7 @@
 using WIDESEA_Common.OrderEnum;
 using WIDESEA_Common.StockEnum;
 using WIDESEA_Common.TaskEnum;
+using WIDESEA_Common.WareHouseEnum;
 using WIDESEA_Core;
 using WIDESEA_Core.BaseRepository;
 using WIDESEA_Core.BaseServices;
@@ -33,8 +34,10 @@
 using WIDESEA_DTO.Inbound;
 using WIDESEA_DTO.Stock;
 using WIDESEA_DTO.Task;
+using WIDESEA_External.ERPService;
 using WIDESEA_IBasicRepository;
 using WIDESEA_IBasicService;
+using WIDESEA_IInboundRepository;
 using WIDESEA_IInboundService;
 using WIDESEA_IOutboundRepository;
 using WIDESEA_IOutboundService;
@@ -57,6 +60,10 @@
         private readonly IRecordService _recordService;
         private readonly IOutboundService _outboundService;
         private readonly IStockService _stockService;
+        private readonly IBasicRepository _basicRepository;
+        private readonly IApiInfoRepository _apiInfoRepository;
+        private readonly IInvokeERPService _invokeERPService;
+        private readonly IInboundRepository _inboundRepository;
 
         public ITaskRepository Repository => BaseDal;
 
@@ -66,11 +73,11 @@
                 {nameof(Dt_Task.CreateDate),OrderByType.Asc},
             };
 
-        public List<int> TaskInboundTypes => typeof(TaskInboundTypeEnum).GetEnumIndexList();
+        public List<int> TaskTypes => typeof(TaskTypeEnum).GetEnumIndexList();
 
-        public List<int> TaskOutboundTypes => typeof(TaskOutboundTypeEnum).GetEnumIndexList();
+        public List<int> TaskOutboundTypes => typeof(TaskTypeEnum).GetEnumIndexList();
 
-        public TaskService(ITaskRepository BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IStockRepository stockRepository, IBasicService basicService, IRecordService recordService, IOutboundService outboundService, IStockService stockService) : base(BaseDal)
+        public TaskService(ITaskRepository BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IStockRepository stockRepository, IBasicService basicService, IRecordService recordService, IOutboundService outboundService, IStockService stockService, IBasicRepository basicRepository, IApiInfoRepository apiInfoRepository, IInvokeERPService invokeERPService, IInboundRepository inboundRepository) : base(BaseDal)
         {
             _mapper = mapper;
             _unitOfWorkManage = unitOfWorkManage;
@@ -79,20 +86,25 @@
             _recordService = recordService;
             _outboundService = outboundService;
             _stockService = stockService;
+            _basicRepository = basicRepository;
+            _apiInfoRepository = apiInfoRepository;
+            _invokeERPService = invokeERPService;
+            _inboundRepository = inboundRepository;
         }
 
         /// <summary>
         /// 浠诲姟淇℃伅鎺ㄩ�佽嚦WCS
         /// </summary>
         /// <returns></returns>
-        public WebResponseContent PushTasksToWCS()
+        public WebResponseContent PushTasksToWCS(List<Dt_Task> tasks, string agvDescription = "")
         {
             try
             {
-                List<Dt_Task> tasks = BaseDal.QueryData(x => (TaskInboundTypes.Contains(x.TaskType) && x.TaskStatus == (int)TaskInStatusEnum.InNew || TaskOutboundTypes.Contains(x.TaskType) && x.TaskStatus == (int)TaskOutStatusEnum.OutNew));
-
                 List<WMSTaskDTO> taskDTOs = _mapper.Map<List<WMSTaskDTO>>(tasks);
-
+                taskDTOs.ForEach(x =>
+                {
+                    x.AGVArea = agvDescription;
+                });
                 string response = HttpHelper.Post("http://127.0.0.1:9291/api/Task/ReceiveTask", taskDTOs.Serialize());
 
                 return JsonConvert.DeserializeObject<WebResponseContent>(response) ?? WebResponseContent.Instance.Error("杩斿洖閿欒");
@@ -118,12 +130,12 @@
                     return WebResponseContent.Instance.Error($"鏈壘鍒拌浠诲姟淇℃伅");
                 }
 
-                if (task.TaskType != TaskInboundTypeEnum.Inbound.ObjToInt())
+                if (task.TaskType != TaskTypeEnum.Inbound.ObjToInt())
                 {
                     return WebResponseContent.Instance.Error($"浠诲姟绫诲瀷閿欒");
                 }
 
-                Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.PalletCode == task.PalletCode).Includes(x => x.Details).First();
+                Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.PalletCode == task.PalletCode && x.WarehouseId==task.WarehouseId).Includes(x => x.Details).First();
                 if (stockInfo == null)
                 {
                     return WebResponseContent.Instance.Error($"鏈壘鍒版墭鐩樺搴旂殑缁勭洏淇℃伅");
@@ -134,7 +146,7 @@
                     return WebResponseContent.Instance.Error($"璇ユ墭鐩樺凡缁戝畾璐т綅");
                 }
 
-                if (stockInfo.Details == null || stockInfo.Details.Count == 0)
+                if (stockInfo.Details.Count == 0)
                 {
                     return WebResponseContent.Instance.Error($"鏈壘鍒拌鎵樼洏搴撳瓨鏄庣粏淇℃伅");
                 }
@@ -152,25 +164,34 @@
 
                 LocationStatusEnum lastStatus = (LocationStatusEnum)locationInfo.LocationStatus;
                 locationInfo.LocationStatus = LocationStatusEnum.InStock.ObjToInt();
-
+                Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x=>x.WarehouseId== task.WarehouseId);
                 //娴嬭瘯鏋跺叆搴撳簱瀛樼姸鎬�
-                if (task.TaskType == TaskInboundTypeEnum.TestInbound.ObjToInt())
+                if (task.TaskType == TaskTypeEnum.Inbound.ObjToInt() && warehouse.WarehouseCode==WarehouseEnum.HA64.ToString())
                 {
                     stockInfo.StockStatus = StockStatusEmun.鍏ュ簱瀹屾垚鏈缓鍑哄簱鍗�.ObjToInt();
                 }
                 else
                 {
                     stockInfo.StockStatus = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt();
+                    
                 }
+                stockInfo.Details.ForEach(x =>
+                {
+                    x.Status = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt();
+                });
                 stockInfo.LocationCode = locationInfo.LocationCode;
+                //鎺ㄩ�佸叆搴撳畬鎴愮粰Erp
+                //鑾峰彇鍏ュ簱鍗曟洿鏂板叆搴撳崟
+                //Dt_InboundOrder inboundOrder = _inboundRepository.InboundOrderRepository.Db.Queryable<Dt_InboundOrder>().Where(x=>x.InboundOrderNo);
+                if (true)
+                {
 
+                }
                 _unitOfWorkManage.BeginTran();
                 BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId > 0 ? OperateTypeEnum.浜哄伐瀹屾垚 : OperateTypeEnum.鑷姩瀹屾垚);
-
-                _basicService.LocationInfoService.Repository.UpdateData(locationInfo);
-
+                _basicService.LocationInfoService.UpdateLocationStatus(locationInfo, (PalletTypeEnum)stockInfo.PalletType, LocationStatusEnum.InStock, stockInfo.WarehouseId);
                 _stockRepository.StockInfoRepository.UpdateData(stockInfo);
-
+                _stockRepository.StockInfoDetailRepository.UpdateData(stockInfo.Details);
                 _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, lastStatus, LocationChangeType.InboundCompleted);
                 _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfo, stockInfo.Details, stockInfo.Details.Sum(x => x.StockQuantity), stockInfo.Details.Sum(x => x.StockQuantity), StockChangeTypeEnum.Inbound, taskNum);
                 _unitOfWorkManage.CommitTran();
@@ -240,12 +261,12 @@
 
                 int beforeStatus = locationInfo.LocationStatus;
                 locationInfo.LocationStatus = LocationStatusEnum.Free.ObjToInt();
-                _basicService.LocationInfoService.Repository.UpdateData(locationInfo);
+                _basicService.LocationInfoService.UpdateLocationStatus(locationInfo, (PalletTypeEnum)stockInfo.PalletType, LocationStatusEnum.Free, stockInfo.WarehouseId);
                 BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateTypeEnum.鑷姩瀹屾垚 : OperateTypeEnum.浜哄伐瀹屾垚);
 
                 _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, (LocationStatusEnum)beforeStatus, LocationChangeType.OutboundCompleted, stockInfo.Details.FirstOrDefault()?.OrderNo ?? "", task.TaskNum);
                 _unitOfWorkManage.CommitTran();
-
+                //鎺ㄩ�佸嚭搴撳畬鎴�
                 return WebResponseContent.Instance.OK();
             }
             catch (Exception ex)

--
Gitblit v1.9.3