From a4254c45c86d19a76147cbf375cba7f1a7aff5d6 Mon Sep 17 00:00:00 2001
From: 肖洋 <cathay_xy@163.com>
Date: 星期五, 29 十一月 2024 13:54:28 +0800
Subject: [PATCH] 忽略项

---
 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs |  100 ++++++++++++++++++++++++++++++++------------------
 1 files changed, 64 insertions(+), 36 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 a1e0369..69b11ac 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
@@ -1,18 +1,9 @@
-锘縰sing log4net.Core;
-using Mapster;
+锘縰sing Mapster;
 using Masuit.Tools;
-using Masuit.Tools.Models;
-using Microsoft.EntityFrameworkCore;
-using System.Linq;
-using System.Threading.Tasks;
 using WIDESEA_DTO.MOM;
 using WIDESEA_DTO.WMS;
-using WIDESEA_IStorageBasicRepository;
 using WIDESEA_IStoragIntegrationServices;
-using WIDESEA_Model.Models;
 using WIDESEA_StorageBasicRepository;
-using WIDESEA_StorageTaskRepository;
-using WIDESEA_StoragIntegrationServices;
 using WIDESEAWCS_BasicInfoRepository;
 
 namespace WIDESEA_StorageOutTaskServices;
@@ -107,7 +98,12 @@
                 {
                     var agingOutputDto = MapToAgingOutputDto(stock);
                     content = await _agingInOrOutInputService.GetOCVOutputAsync(agingOutputDto);
-                    ValidateResponse(content);
+                    //ValidateResponse(content);
+                    var result = JsonConvert.DeserializeObject<BasicResult>(content.Data.ToString());
+                    if (!result.Success)
+                    {
+                        task.Remark = "NG";
+                    }
                 }
             }
 
@@ -120,10 +116,11 @@
                 await UpdateLocationAsync(loc);
                 await DeleteStockInfoAsync(stock.Id);
                 await DeleteStockInfoDetailsAsync(stock.StockInfoDetails);
-                //await DeleteTaskAsync(task.TaskId);
+                if (task.Roadway.Contains("FR") || task.Roadway.Contains("GW"))   //濡傛灉鏄垎瀹规垨楂樻俯鍑哄簱 灏嗕换鍔″垹闄�
+                    await DeleteTaskAsync(task.TaskId);
             });
 
-            return content.OK("浠诲姟瀹屾垚鎴愬姛");
+            return content.OK("浠诲姟瀹屾垚鎴愬姛", task.Remark);
         }
         catch (Exception err)
         {
@@ -146,7 +143,8 @@
 
         var outHours = (DateTime.Now - stock.OutboundTime.Value).TotalHours;
         var isNG = outHours > parameterInfo.LowerSpecificationsLimit.ToDouble() && outHours < parameterInfo.UpperSpecificationsLimit.ToDouble();
-
+        var defectCode = string.Empty;
+        if (!isNG) defectCode = "TQCK";
         return new AgingOutputDto
         {
             OpFlag = 1,
@@ -167,6 +165,7 @@
                         TargetValue = parameterInfo.TargetValue,
                         LowerLomit = parameterInfo.LowerSpecificationsLimit,
                         UpperLimit = parameterInfo.UpperSpecificationsLimit,
+                        DefectCode = defectCode
                     }
                 }
             }).ToList()
@@ -175,16 +174,12 @@
 
     private void ValidateResponse(WebResponseContent content)
     {
-        var result = JsonConvert.DeserializeObject<BasicResult>(content.Data.ToString());
-        if (!result.Success)
-        {
-            throw new Exception(result.MOMMessage);
-        }
+
     }
 
     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;
@@ -304,7 +299,7 @@
 
             // 鑾峰彇瑁呯淇℃伅鍜岀洰鏍囦綅缃俊鎭�
             var boxing = await _boxingInfoRepository.QueryFirstNavAsync(x => x.PalletCode == task.PalletCode);
-            var locationInf = await _locationRepository.QueryFirstAsync(x => x.LocationCode == task.TargetAddress);
+            var locationInf = await _locationRepository.QueryFirstAsync(x => x.LocationCode == task.TargetAddress && x.RoadwayNo == task.Roadway);
 
             // 鏇存柊鐩爣浣嶇疆鐘舵�佷负搴撳瓨涓�
             locationInf.LocationStatus = (int)LocationEnum.InStock;
@@ -315,8 +310,9 @@
             // 鏍规嵁鏄惁鏈夌粍鐩樹俊鎭垱寤哄簱瀛樺疄渚嬫ā鍨�
             DtStockInfo stock = boxing == null ? CreateEmptyPalletStock(task, locationInf) : CreateFullPalletStock(task, locationInf, boxing);
 
+
             // 鎵ц鏁版嵁搴撲簨鍔�
-            bool isResult = await ExecuteTransaction(stock, taskHty, locationInf, task.TaskId);
+            bool isResult = await ExecuteTransaction(stock, taskHty, locationInf, task.TaskId, boxing);
             if (isResult)
             {
                 content.OK("鍏ュ簱浠诲姟瀹屾垚鎴愬姛");
@@ -350,13 +346,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.宸插叆搴�
                 }
@@ -405,7 +429,7 @@
         stock.LinedProcessFeedbackTime = respone.LinedProcessFeedbackTime;
         stock.SpecialParameterDuration = respone.SpecialParameterDuration;
         //2024骞�11鏈�16鏃ワ細鏂板瀛楁璁$畻搴斿嚭搴撴椂闂�
-        stock.OutboundTime = Convert.ToDateTime(respone.LinedProcessFeedbackTime).AddHours(Convert.ToDouble(respone.SpecialParameterDuration));
+        stock.OutboundTime = Convert.ToDateTime(respone.LinedProcessFeedbackTime == null ? DateTime.Now : respone.LinedProcessFeedbackTime).AddHours(Convert.ToDouble(respone.SpecialParameterDuration));
         stock.ProductionLine = respone.ProductionLine;
         stock.ParameterInfos = respone.ParameterInfos.ToJsonString();
         stock.StockStatus = 1;
@@ -441,9 +465,9 @@
         }
         LogFactory.GetLog("浠诲姟瀹屾垚").InfoFormat(true, "楠岃瘉浠诲姟鏄惁瀛樺湪", JsonConvert.SerializeObject(task));
 
-        if(task.TaskType == (int)TaskOutboundTypeEnum.InToOut)
+        if (task.TaskType == (int)TaskOutboundTypeEnum.InToOut)
         {
-           return await CompleteInToOutTaskAsync(task);
+            return await CompleteInToOutTaskAsync(task);
         }
 
         // 楠岃瘉搴撳瓨鏄惁瀛樺湪
@@ -544,7 +568,7 @@
                 // TODO 鍒涘缓浠诲姟閫佽嚦NG鎺掑嚭鍙�
                 var efg = _stationManagerRepository.QueryData(x => x.stationType == 1 && x.stationChildCode == input.Position && x.stationArea == area.AreaCode).ToList();
                 //List<string> NGStation = input.Position == "1088" ? new List<string>() { "1020" } : new List<string>() { "JZSC01" };
-                if(efg.Count <= 0)
+                if (efg.Count <= 0)
                 {
                     throw new Exception("鏈壘鍒癗G鍏ュ簱绔欏彴閰嶇疆");
                 }
@@ -563,6 +587,7 @@
                 content = await RequestTrayInTaskAsync(input);
                 return content;
             }
+            //Console.WriteLine("qqqqq");
 
             // TODO 鑾峰彇鏈湴鏂欐灞炴�т笌鏁寸洏鐢佃姱灞炴�ц幏鍙栫殑鍊艰繘琛屽姣旓紝濡傛灉涓�鑷村垯缁х画锛屽惁鍒欒繑鍥為敊璇俊鎭�
             //var productions = await _productionRepository.QueryDataAsync(x => result.TrayBarcodePropertys.Select(x => x.TrayBarcodeProperty).ToList().Contains(x.TrayBarcodeProperty));
@@ -571,7 +596,8 @@
 
             // 璋冪敤CreateBoxingInfo鏂规硶锛屽垱寤虹粍鐩樹俊鎭�
 
-            var boxing = await CreateBoxingInfo(result, input.PalletCode);
+            var boxing = CreateBoxingInfo(result, input.PalletCode);
+            //Console.WriteLine(boxing.ToJsonString());
             if (boxing == null) return content.Error("缁勭洏澶辫触");
 
             // 璋冪敤GetProcessApplyAsync鏂规硶锛岃幏鍙栧伐鑹鸿矾绾�
@@ -601,8 +627,8 @@
             {
                 throw new Exception("鏈壘鍒癗G鍏ュ簱绔欏彴閰嶇疆");
             }
-            List<string> strings = stationManagers.Select(x=>x.Roadway).ToList();
-            // 璋冪敤CreateNewTask鏂规硶锛屽垱寤烘柊浠诲姟
+            List<string> strings = stationManagers.Select(x => x.Roadway).ToList();
+            //// 璋冪敤CreateNewTask鏂规硶锛屽垱寤烘柊浠诲姟
             content = await CreateNewTask(input, strings);
             if (content.Status)
             {
@@ -702,7 +728,7 @@
     }
 
     // 鑾峰彇缁勭洏淇℃伅
-    private async Task<DtBoxingInfo> CreateBoxingInfo(ResultTrayCellsStatus result, string palletCode)
+    private DtBoxingInfo CreateBoxingInfo(ResultTrayCellsStatus result, string palletCode)
     {
         return new DtBoxingInfo
         {
@@ -1208,12 +1234,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