From b2feeabc23454a2c9e161aa3b26d0edf938e55bd Mon Sep 17 00:00:00 2001 From: huangxiaoqiang <huangxiaoqiang@hnkhzn.com> Date: 星期二, 22 七月 2025 15:03:17 +0800 Subject: [PATCH] 增加超时设置,更新依赖注入和查询逻辑 --- CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs | 116 ++++++++++++++++++++++++++++++++++------------------------ 1 files changed, 68 insertions(+), 48 deletions(-) diff --git a/CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs b/CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs index 840851d..c346b05 100644 --- a/CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs +++ b/CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs @@ -2,6 +2,7 @@ using Masuit.Tools; using SixLabors.Fonts.Tables.AdvancedTypographic; using SqlSugar; +using System.Linq.Expressions; using System.Text.RegularExpressions; using System.Threading.Tasks; using WIDESEA_Cache; @@ -12,6 +13,7 @@ using WIDESEA_IServices; using WIDESEA_IStoragIntegrationServices; using WIDESEA_Model.Models; +using WIDESEA_Repository; using WIDESEAWCS_BasicInfoRepository; using WIDESEAWCS_QuartzJob.Models; @@ -35,6 +37,7 @@ private readonly IAgingInOrOutInputService _agingInOrOutInputService; //闈欑疆\闄堝寲 private readonly IDt_StationManagerRepository _stationManagerRepository; private readonly ISys_ConfigService _configService; + private readonly IDt_ChangeoversRepository _dt_ChangeoversRepository; private readonly ISimpleCacheService _simpleCacheService; public Dt_TaskService(IDt_TaskRepository BaseDal, @@ -54,6 +57,7 @@ IStockInfoDetailRepository stockInfoDetailRepository, IDt_StationManagerRepository stationManagerRepository, ISys_ConfigService configService, + IDt_ChangeoversRepository dt_ChangeoversRepository, ISimpleCacheService simpleCacheService) : base(BaseDal) { _unitOfWorkManage = unitOfWorkManage; @@ -71,6 +75,7 @@ _stockInfoDetailRepository = stockInfoDetailRepository; _stationManagerRepository = stationManagerRepository; _configService = configService; + _dt_ChangeoversRepository = dt_ChangeoversRepository; _simpleCacheService = simpleCacheService; } @@ -608,13 +613,13 @@ } 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); - + if (task.TaskType == (int)TaskOutboundTypeEnum.InToOut) + { + return await CompleteInToOutTaskAsync(task,stock); + } // 鏍规嵁浠诲姟绫诲瀷璋冪敤鐩稿簲鐨勫畬鎴愪换鍔℃柟娉� switch (task.TaskType) { @@ -665,6 +670,11 @@ var stock = await QueryStockInfo(input.PalletCode); if (stock != null) { + List<string> strings = new List<string>() { "GW", "CW", "FR" }; + if (stock.AreaCode.Contains(strings)) + { + return content.Error($"鎵樼洏銆恵stock.PalletCode}銆戝瓨鍦ㄥ簱瀛樹笉鍏佽鍏ュ簱"); + } Dt_Task taskNew = new Dt_Task { Grade = 1, @@ -977,7 +987,9 @@ return null; } - var outBoundMateriel = AppSettings.app<OutBoundMateriel>("OutBoundMateriel"); + //var outBoundMateriel = AppSettings.app<OutBoundMateriel>("OutBoundMateriel"); + + var outBoundMateriel = _dt_ChangeoversRepository.QueryData(x => x.Status == "1").ToList(); List<string>? materielCodes = outBoundMateriel.Count != 0 ? outBoundMateriel.Where(x => x.ProductionLine == productionLine && x.ProcessCode == area.AreaCode) .Select(x => x.MaterielCode) @@ -1030,7 +1042,9 @@ // materielCodes = outBoundMateriel.Where(x => x.ProductionLine == productionLine && x.ProcessCode == areaCodes[0]).Select(x => x.MaterielCode).ToList(); //} - var outBoundMateriel = AppSettings.app<OutBoundMateriel>("OutBoundMateriel"); + //var outBoundMateriel = AppSettings.app<OutBoundMateriel>("OutBoundMateriel"); + + var outBoundMateriel = _dt_ChangeoversRepository.QueryData(x => x.Status == "1").ToList(); List<string>? materielCodes = outBoundMateriel.Count != 0 ? outBoundMateriel.Where(x => x.ProductionLine == productionLine && x.ProcessCode == areaCodes[0]) .Select(x => x.MaterielCode) @@ -1909,20 +1923,23 @@ // 鍒涘缓鍘嗗彶浠诲姟瀹炰緥妯″瀷 try { - Dt_Task task = BaseDal.QueryFirst(x => x.TaskId == Convert.ToInt32(key[0])); - if (task == null) + foreach (var item in key) { - return content.Error("鏈壘鍒颁换鍔′俊鎭�!"); + Dt_Task task = BaseDal.QueryFirst(x => x.TaskId == Convert.ToInt32(key)); + if (task == null) + { + return content.Error("鏈壘鍒颁换鍔′俊鎭�!"); + } + var taskHtyNG = CreateHistoricalTask(task, true); + + // 鎵ц鏁版嵁搴撲簨鍔� + + // 娣诲姞鍘嗗彶浠诲姟 + var isTaskHtyAdd = _task_HtyRepository.AddData(taskHtyNG) > 0; + + // 鍒犻櫎浠诲姟鏁版嵁 + var isTaskDelete = BaseDal.Delete(task.TaskId); } - var taskHtyNG = CreateHistoricalTask(task, true); - - // 鎵ц鏁版嵁搴撲簨鍔� - - // 娣诲姞鍘嗗彶浠诲姟 - var isTaskHtyAdd = _task_HtyRepository.AddData(taskHtyNG) > 0; - - // 鍒犻櫎浠诲姟鏁版嵁 - var isTaskDelete = BaseDal.Delete(task.TaskId); return content.OK("鍒犻櫎鎴愬姛!"); } @@ -2152,32 +2169,32 @@ } #region 鏇存柊搴撳瓨淇℃伅锛堟殏鏃朵笉闇�瑕侊級 - if (stock.IsFull) - { - // 鏌ヨ绗﹀悎鏉′欢鐨勫簱瀛樹俊鎭� - var stocks = _stockInfoRepository.QueryData(x => x.AreaCode == stock.AreaCode && x.ProductionLine == stock.ProductionLine && x.SpecialParameterDuration != stock.SpecialParameterDuration); + //if (stock.IsFull) + //{ + // // 鏌ヨ绗﹀悎鏉′欢鐨勫簱瀛樹俊鎭� + // var stocks = _stockInfoRepository.QueryData(x => x.AreaCode == stock.AreaCode && x.ProductionLine == stock.ProductionLine && x.SpecialParameterDuration != stock.SpecialParameterDuration); - // 鏌ヨ浠诲姟淇℃伅 - var tasks = BaseDal.QueryData(x => x.PalletCode != stock.PalletCode && x.ProductionLine == stock.ProductionLine).Select(x => x.PalletCode).ToList(); + // // 鏌ヨ浠诲姟淇℃伅 + // var tasks = BaseDal.QueryData(x => x.PalletCode != stock.PalletCode && x.ProductionLine == stock.ProductionLine).Select(x => x.PalletCode).ToList(); - if (stocks != null && stocks.Count > 0) - { - // 杩囨护鍑洪渶瑕佹洿鏂扮殑搴撳瓨淇℃伅 - var stocksToUpdate = stocks.Where(item => !tasks.Contains(item.PalletCode)).ToList(); - foreach (var item in stocksToUpdate) - { - // 鏇存柊搴撳瓨淇℃伅鐨勭壒瀹氬弬鏁� - item.SpecialParameterDuration = stock.SpecialParameterDuration; - item.ParameterInfos = stock.ParameterInfos; - item.OutboundTime = Convert.ToDateTime(item.LinedProcessFeedbackTime == null ? item.CreateDate : item.LinedProcessFeedbackTime).AddHours(Convert.ToDouble(stock.SpecialParameterDuration)); - } - if (stocksToUpdate.Count > 0) - { - // 寮傛鏇存柊搴撳瓨淇℃伅 - var isUpdates = await _stockInfoRepository.UpdateDataAsync(stocksToUpdate); - } - } - } + // if (stocks != null && stocks.Count > 0) + // { + // // 杩囨护鍑洪渶瑕佹洿鏂扮殑搴撳瓨淇℃伅 + // var stocksToUpdate = stocks.Where(item => !tasks.Contains(item.PalletCode)).ToList(); + // foreach (var item in stocksToUpdate) + // { + // // 鏇存柊搴撳瓨淇℃伅鐨勭壒瀹氬弬鏁� + // item.SpecialParameterDuration = stock.SpecialParameterDuration; + // item.ParameterInfos = stock.ParameterInfos; + // item.OutboundTime = Convert.ToDateTime(item.LinedProcessFeedbackTime == null ? item.CreateDate : item.LinedProcessFeedbackTime).AddHours(Convert.ToDouble(stock.SpecialParameterDuration)); + // } + // if (stocksToUpdate.Count > 0) + // { + // // 寮傛鏇存柊搴撳瓨淇℃伅 + // var isUpdates = await _stockInfoRepository.UpdateDataAsync(stocksToUpdate); + // } + // } + //} #endregion // 娣诲姞鍘嗗彶浠诲姟 @@ -2234,10 +2251,10 @@ // 鑾峰彇鐩爣鍦板潃鍜屾洿鏂颁换鍔$姸鎬� input.Position = Regex.Replace(input.Position, @"-(\d+)", ""); - if (Convert.ToInt32(input.Position) > 1999) - { - input.Position = (Convert.ToInt32(input.Position) - 1000).ToString(); - } + //if (Convert.ToInt32(input.Position) > 1999) + //{ + // input.Position = (Convert.ToInt32(input.Position) - 1000).ToString(); + //} if (task.TaskType == (int)TaskInboundTypeEnum.InNG) { @@ -2352,7 +2369,10 @@ ToAddress = await GetRoadWayAsync(process); else ToAddress = process[0]; - + if (string.IsNullOrEmpty(ToAddress)) + { + return content.Error("鏃犳硶鑾峰彇鐩爣鍦板潃"); + } // 鍒涘缓鏂颁换鍔″疄渚� var task = new Dt_Task { -- Gitblit v1.9.3