From b0b0dcb6d68752f539122b47c54e41d263480ba6 Mon Sep 17 00:00:00 2001
From: 刘磊 <1161824510@qq.com>
Date: 星期一, 25 十一月 2024 16:17:22 +0800
Subject: [PATCH] 同步

---
 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs |   70 ++++++++++++++++++++++++++++-------
 1 files changed, 56 insertions(+), 14 deletions(-)

diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs
index fa3ef06..fae1f1e 100644
--- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs
+++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs
@@ -12,6 +12,7 @@
 using WIDESEA_StorageBasicRepository;
 using WIDESEA_StorageTaskRepository;
 using WIDESEA_StoragIntegrationServices;
+using WIDESEAWCS_BasicInfoRepository;
 
 namespace WIDESEA_StorageOutTaskServices;
 
@@ -38,6 +39,7 @@
     private readonly IDt_AreaInfoRepository _areaInfoRepository; //鍖哄煙
     private readonly IAgingInOrOutInputService _agingInOrOutInputService; //闈欑疆\闄堝寲
     private readonly IProductionRepository _productionRepository; //鐢熶骇
+    private readonly IDt_StationManagerRepository _stationManagerRepository;
 
     public Dt_TaskService(IDt_TaskRepository BaseDal,
                                 IUnitOfWorkManage unitOfWorkManage,
@@ -59,7 +61,8 @@
                                 IDt_AreaInfoRepository areaInfoRepository,
                                 IAgingInOrOutInputService agingInOrOutInputService,
                                 IStockInfoDetailRepository stockInfoDetailRepository,
-                                IProductionRepository productionRepository) : base(BaseDal)
+                                IProductionRepository productionRepository,
+                                IDt_StationManagerRepository stationManagerRepository) : base(BaseDal)
     {
         _unitOfWorkManage = unitOfWorkManage;
         _outOrderRepository = outOrderRepository;
@@ -81,6 +84,7 @@
         _agingInOrOutInputService = agingInOrOutInputService;
         _stockInfoDetailRepository = stockInfoDetailRepository;
         _productionRepository = productionRepository;
+        _stationManagerRepository = stationManagerRepository;
     }
 
     #region 澶栭儴鎺ュ彛鏂规硶
@@ -98,10 +102,12 @@
                 //var process = await SqlSugarHelper.Db.Queryable<Dt_EquipmentProcess>()
                 //    .FirstAsync(x => x.EquipmentName == task.Roadway);
                 //var info = JsonConvert.DeserializeObject<ResponseEqptRunDto>(process.ProcessValue);
-
-                var agingOutputDto = MapToAgingOutputDto(stock);
-                content = await _agingInOrOutInputService.GetOCVOutputAsync(agingOutputDto);
-                ValidateResponse(content);
+                if (!task.Roadway.Contains("FR"))  //闈炲垎瀹瑰簱鍖哄潎涓婃姤MOM鍑哄叆绔�
+                {
+                    var agingOutputDto = MapToAgingOutputDto(stock);
+                    content = await _agingInOrOutInputService.GetOCVOutputAsync(agingOutputDto);
+                    ValidateResponse(content);
+                }
             }
 
             // 鏇存柊搴撳瓨鐘舵�佸拰浠诲姟鐘舵��
@@ -177,7 +183,7 @@
 
     private (DtLocationInfo, Dt_Task) UpdateStockAndTaskStatus(DtStockInfo stock, Dt_Task task)
     {
-        var location = _locationRepository.QueryFirst(x => x.LocationCode == task.SourceAddress);
+        var location = _locationRepository.QueryFirst(x => x.LocationCode == task.SourceAddress && x.RoadwayNo == task.Roadway);
         //var details = _stockInfoDetailRepository.QueryData(x => x.StockId == stock.Id);
 
         location.LocationStatus = (int)LocationEnum.Free;
@@ -308,6 +314,7 @@
             // 鏍规嵁鏄惁鏈夌粍鐩樹俊鎭垱寤哄簱瀛樺疄渚嬫ā鍨�
             DtStockInfo stock = boxing == null ? CreateEmptyPalletStock(task, locationInf) : CreateFullPalletStock(task, locationInf, boxing);
 
+
             // 鎵ц鏁版嵁搴撲簨鍔�
             bool isResult = await ExecuteTransaction(stock, taskHty, locationInf, task.TaskId);
             if (isResult)
@@ -343,13 +350,41 @@
             CreateDate = DateTime.Now,
             Creater = "system",
             IsFull = false,
-            AreaCode = area.AreaCode,
+            AreaCode = area.AreaCode ?? "",
             LocationId = loation.Id,
             StockInfoDetails = new List<DtStockInfoDetail>()
             {
                 new DtStockInfoDetail()
                 {
                     MaterielCode = "绌烘墭鐩�",
+                    Id = 0,
+                    Status = (int)StockStateEmun.宸插叆搴�
+                }
+            }
+        };
+    }
+
+    /// <summary>
+    /// 鍒涘缓鍒嗗鐨勫疄鎵樼洏鐨勫簱瀛樺疄渚嬫ā鍨�
+    /// </summary>
+    private DtStockInfo CreateFullPalletStockByFR(Dt_Task task, DtLocationInfo locationInf)
+    {
+        var loation = _locationRepository.QueryFirst(x => x.RoadwayNo == task.Roadway && x.LocationCode == task.TargetAddress);
+        var area = _areaInfoRepository.QueryFirst(x => x.AreaID == loation.AreaId);
+        return new DtStockInfo()
+        {
+            PalletCode = task.PalletCode,
+            LocationCode = task.TargetAddress,
+            CreateDate = DateTime.Now,
+            Creater = "system",
+            IsFull = false,
+            AreaCode = area.AreaCode ?? "",
+            LocationId = loation.Id,
+            StockInfoDetails = new List<DtStockInfoDetail>()
+            {
+                new DtStockInfoDetail()
+                {
+                    MaterielCode = "瀹炴墭鐩�",
                     Id = 0,
                     Status = (int)StockStateEmun.宸插叆搴�
                 }
@@ -433,6 +468,11 @@
             return content.Error("浠诲姟涓嶅瓨鍦�");
         }
         LogFactory.GetLog("浠诲姟瀹屾垚").InfoFormat(true, "楠岃瘉浠诲姟鏄惁瀛樺湪", JsonConvert.SerializeObject(task));
+
+        if (task.TaskType == (int)TaskOutboundTypeEnum.InToOut)
+        {
+            return await CompleteInToOutTaskAsync(task);
+        }
 
         // 楠岃瘉搴撳瓨鏄惁瀛樺湪
         var stock = await _stockInfoRepository.QueryFirstNavAsync(x => x.PalletCode == task.PalletCode);
@@ -549,7 +589,7 @@
 
             // 璋冪敤CreateBoxingInfo鏂规硶锛屽垱寤虹粍鐩樹俊鎭�
 
-            var boxing = await CreateBoxingInfo(result, input.PalletCode);
+            var boxing = CreateBoxingInfo(result, input.PalletCode);
             if (boxing == null) return content.Error("缁勭洏澶辫触");
 
             // 璋冪敤GetProcessApplyAsync鏂规硶锛岃幏鍙栧伐鑹鸿矾绾�
@@ -667,7 +707,7 @@
     }
 
     // 鑾峰彇缁勭洏淇℃伅
-    private async Task<DtBoxingInfo> CreateBoxingInfo(ResultTrayCellsStatus result, string palletCode)
+    private DtBoxingInfo CreateBoxingInfo(ResultTrayCellsStatus result, string palletCode)
     {
         return new DtBoxingInfo
         {
@@ -1173,12 +1213,14 @@
             {
                 // 娣诲姞搴撳瓨
                 isUpdateStock = await _stockInfoRepository.AddDataNavAsync(stock);
-                isDeleteBoxing = await _boxingInfoRepository.Db.DeleteNav<DtBoxingInfo>(x => x.Id == boxingInfo.Id)
-                   .Include(x => x.BoxingInfoDetails)
-                   .ExecuteCommandAsync();
+                if (boxingInfo != null)
+                {
+                    isDeleteBoxing = await _boxingInfoRepository.Db.DeleteNav<DtBoxingInfo>(x => x.Id == boxingInfo.Id)
+                .Include(x => x.BoxingInfoDetails)
+                .ExecuteCommandAsync();
+                }
+
             }
-
-
 
             // 娣诲姞鍘嗗彶浠诲姟
             var isTaskHtyAdd = await _task_HtyRepository.AddDataAsync(taskHty) > 0;

--
Gitblit v1.9.3