From cf877c780cb964b8b1d8eefec521c46d76130836 Mon Sep 17 00:00:00 2001 From: huangxiaoqiang <huangxiaoqiang@hnkhzn.com> Date: 星期一, 30 六月 2025 14:37:44 +0800 Subject: [PATCH] 更新超时信息相关接口和服务 - 修改 `Dt_OutTime.vue` 中的 `url` 字段。 - 更新 `AssemblyInformationalVersion` 属性值。 - 新增 `IStockInfoTimeoutRepository` 和 `IStockInfoTimeoutService` 接口。 - 实现 `StockInfoTimeoutRepository` 和 `StockInfoTimeoutService` 类。 - 在 `Dt_TaskService.cs` 中添加必要的 `using` 语句。 - 新增 `StockInfoTimeoutController` 控制器。 --- CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs | 329 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 311 insertions(+), 18 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 fd00670..7095436 100644 --- a/CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs +++ b/CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs @@ -2,7 +2,9 @@ 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; using WIDESEA_Core; using WIDESEA_Core.Const; @@ -276,6 +278,36 @@ #endregion 鍑哄簱浠诲姟瀹屾垚 + #region 鐏浠诲姟瀹屾垚 + public async Task<WebResponseContent> CompleteOutFireAlarmTaskAsync(Dt_Task task, DtStockInfo stock) + { + WebResponseContent content = new WebResponseContent(); + (var loc, var tas) = UpdateStockAndTaskStatus(stock, task); + var taskHty = task.Adapt<Dt_Task_Hty>(); + taskHty.FinishTime = DateTime.Now; + taskHty.OperateType = App.User.UserName != null ? (int)OperateTypeEnum.浜哄伐瀹屾垚 : (int)OperateTypeEnum.鑷姩瀹屾垚; + taskHty.Creater = App.User.UserName != null ? App.User.UserName : "System"; + + DtStockInfo_Hty stockInfo_Hty = stock.Adapt<DtStockInfo_Hty>(); + stockInfo_Hty.ModifyDate = DateTime.Now; + + // 浜嬪姟澶勭悊 + await _unitOfWorkManage.UseTranAsync(async () => + { + if (task.TaskType != (int)TaskOutboundTypeEnum.OutQuality) + { + await DeleteStockInfoAsync(stock.Id); + await DeleteStockInfoDetailsAsync(stock.StockInfoDetails); + await AddStockInfoHtyAsync(stockInfo_Hty); + await UpdateLocationAsync(loc); //璐ㄦ浠诲姟闇�瑕佹寔缁攣瀹氬簱浣� + } + await DeleteTaskAsync(task.TaskId); + await AddTaskHtyAsync(taskHty); + }); + return content.OK("浠诲姟瀹屾垚鎴愬姛", task.Remark); + } + #endregion + #region 绉诲簱浠诲姟瀹屾垚 /// <summary> @@ -322,7 +354,7 @@ WebResponseContent content = new WebResponseContent(); try { - if (task.TaskType == (int)TaskInboundTypeEnum.InNG || task.TaskType == (int)TaskInboundTypeEnum.InQuality) + if (task.TaskType == (int)TaskInboundTypeEnum.InNG) { task.TaskState = (int)TaskInStatusEnum.SC_InFinish; // 鍒涘缓鍘嗗彶浠诲姟瀹炰緥妯″瀷 @@ -389,6 +421,9 @@ Console.WriteLine(err.Message.ToString()); LogFactory.GetLog("浠诲姟瀹屾垚").Error(true, err); content.Error(err.Message); + task.ErrorMessage = err.Message; + task.TaskState = (int)TaskInStatusEnum.SC_InExecuting; + await BaseDal.Update(task); } return content; } @@ -596,6 +631,11 @@ case (int)TaskOutboundTypeEnum.OutNG: LogFactory.GetLog("浠诲姟瀹屾垚").InfoFormat(true, "鍑哄簱浠诲姟", ""); return await CompleteStackTaskAsync(task, stock); + + case (int)TaskOutboundTypeEnum.OutFireAlarm: + + LogFactory.GetLog("浠诲姟瀹屾垚").InfoFormat(true, "鐏浠诲姟", ""); + return await CompleteOutFireAlarmTaskAsync(task, stock); case (int)TaskRelocationTypeEnum.Relocation: return await CompleteTransferTaskAsync(task, stock); @@ -1047,11 +1087,11 @@ .ToList().Select(x => x.DeviceCode).ToList(); var result = await _stockInfoRepository.Db.Queryable<DtStockInfo>() - .Where(x => x.ProductionLine == station.productLine) + .WhereIF(!station.Roadway.Contains("JZSC"), x => x.ProductionLine == station.productLine) .Where(x => x.AreaCode == areaCode && x.IsFull == false) - .Includes(x=>x.StockInfoDetails) + .Includes(x => x.StockInfoDetails) .Where(x => x.StockInfoDetails.Any(y => y.MaterielCode == "绌烘墭鐩�")) - .Includes(x=>x.LocationInfo) + .Includes(x => x.LocationInfo) .WhereIF(!deviceCode.IsNullOrEmpty(), x => deviceCode.Contains(x.LocationInfo.RoadwayNo)) .Where(x => x.LocationInfo.LocationStatus == (int)LocationEnum.InStock && x.LocationInfo.AreaId == area.AreaID && x.LocationInfo.EnalbeStatus == (int)EnableEnum.Enable) // 杩囨护鏉′欢 .OrderBy(x => x.CreateDate) // 鎺掑簭 @@ -1076,7 +1116,7 @@ { return new Dt_Task { - Grade = tag == 104 ? (stockInfo.LocationInfo.RoadwayNo.Contains("CWSC") ? 1 : 2) : (stockInfo.LocationInfo.RoadwayNo.Contains("CWSC") ? 2 : 1), + Grade = tag == 104 ? (stockInfo.LocationInfo.RoadwayNo.Contains("CWSC")|| stockInfo.LocationInfo.RoadwayNo.Contains("JZSC") ? 1 : 2) : (stockInfo.LocationInfo.RoadwayNo.Contains("CWSC") || stockInfo.LocationInfo.RoadwayNo.Contains("JZSC") ? 2 : 1), Roadway = stockInfo.LocationInfo.RoadwayNo, TargetAddress = position, Dispatchertime = DateTime.Now, @@ -1611,6 +1651,215 @@ #endregion + #region 鏌ヨ闈欑疆绌洪棽搴撲綅 + public WebResponseContent QueryLocationFreeJZ(string RoadwayNo) + { + WebResponseContent content = new WebResponseContent(); + try + { + var result = _locationRepository.QueryData(x => x.EnalbeStatus != (int)EnableEnum.Disable && x.LocationStatus == (int)LocationEnum.Free && x.RoadwayNo.Contains("JZSC")); + LogFactory.GetLog($"闈欑疆{RoadwayNo}鏌ヨ绌洪棽搴撲綅").Info(true, $"{JsonConvert.SerializeObject(result)}"); + if (result.Count > 5) + { + return content.OK(); + } + return content.Error("搴撲綅宸叉弧"); + } + catch (Exception ex) + { + return content.Error(ex.Message); + } + } + + #endregion + + #region 澶у睆鎺ュ彛 + + /// <summary> + /// 鑾峰彇浠诲姟淇℃伅 + /// </summary> + /// <returns></returns> + public WebResponseContent GetTaskInfo() + { + WebResponseContent content = new WebResponseContent(); + try + { + var task = BaseDal.QueryData(x => true).ToList(); + var newTask = task.Select(x => new + { + x.PalletCode, + x.Roadway, + x.SourceAddress, + x.TargetAddress, + x.ProductionLine, + TaskType = new List<string> { GetTaskTypeDesc(x.TaskType) }[0], // 姣忎釜浠诲姟鐙珛鐢熸垚 TaskType + TaskState = new List<string> { GetTaskStateDesc(x.TaskState) }[0] // 姣忎釜浠诲姟鐙珛鐢熸垚 TaskState + }).ToList(); + + return content.OK(data: newTask); + } + catch (Exception ex) + { + return content.Error(ex.Message); + } + } + /// <summary> + /// 鑾峰彇搴撳瓨淇℃伅 + /// </summary> + /// <returns></returns> + public WebResponseContent GetStockInfo() + { + WebResponseContent content = new WebResponseContent(); + try + { + var now = DateTime.Now; + var startOfDay = new DateTime(now.Year, now.Month, now.Day); + var endOfDay = startOfDay.AddDays(1); + var filteredItems = _stockInfoRepository.Db.Queryable<DtStockInfo>() + .Where(x => x.OutboundTime >= startOfDay && x.OutboundTime < endOfDay && x.IsFull) + .Includes(x => x.StockInfoDetails) + .ToList(); + + var result = filteredItems + .GroupBy(x => x.AreaCode) + .Select(g => new GroupedStockInfo + { + AreaCode = g.Key, + TotalQuantity = g.Sum(item => item.StockInfoDetails?.Count ?? 0), + Items = g.ToList() + }) + .ToList(); + return content.OK(data: result); + } + catch (Exception ex) + { + return content.Error(ex.Message); + } + } + /// <summary> + /// 鑾峰彇璐т綅鐘舵�� + /// </summary> + /// <returns></returns> + public WebResponseContent GetStockQuantity() + { + WebResponseContent content = new WebResponseContent(); + try + { + var location = _locationRepository.Db.Queryable<DtLocationInfo>().ToList(); + + return content.OK(data: location); + + } + catch (Exception ex) + { + return content.Error(ex.Message); + } + } + public WebResponseContent Getproductionvolume() + { + WebResponseContent content = new WebResponseContent(); + try + { + var now = DateTime.Now; + var startOfDay = new DateTime(now.Year, now.Month, now.Day); + var endOfDay1 = startOfDay.AddDays(-7); + var taskHty = _task_HtyRepository.Db.Queryable<Dt_Task_Hty>().Where(it => it.CreateDate > endOfDay1).ToList(); + return content.OK(data: taskHty); + } + catch (Exception ex) + { + return content.Error(ex.Message); + } + + } + + public WebResponseContent Getoutput() + { + WebResponseContent content = new WebResponseContent(); + try + { + var now = DateTime.Now; + var firstDayOfYear = new DateTime(now.Year, 1, 1); + var taskHty = _task_HtyRepository.Db.Queryable<Dt_Task_Hty>().Where(it => it.CreateDate > firstDayOfYear&&it.TaskType==100).ToList(); + return content.OK(data: taskHty); + } + catch (Exception ex) + { + return content.Error(ex.Message); + } + + } + #endregion + public WebResponseContent GetTimeout() + { + WebResponseContent content = new WebResponseContent(); + try + { + var now = DateTime.Now; + // 浣跨敤Subtract鏂规硶 + var threeHoursAgo = now.Subtract(TimeSpan.FromHours(3)); + + List<DtStockInfo> dtStocks = _stockInfoRepository.Db.Queryable<DtStockInfo>() + .Where(x => x.OutboundTime < threeHoursAgo).ToList(); + return content.OK1(total1: dtStocks.Count, data: dtStocks); + } + catch (Exception ex) + { + return content.Error(ex.Message); + } + + } + + public WebResponseContent Getproductionstatistics() + { + WebResponseContent content = new WebResponseContent(); + try + { + var now = DateTime.Now; + var thirtyDaysAgo = now.AddDays(-30); + var roadwayMappings = new Dictionary<string, string> { + { "JZ", "闈欑疆搴�" }, + { "CH", "闄堝寲搴�" }, + { "FR", "鍒嗗搴�" }, + { "GW", "楂樻俯搴�" }, + { "CW", "甯告俯搴�" } + }; + + var roadwayKeys = roadwayMappings.Keys.ToArray(); + + var taskHty = _task_HtyRepository.Db.Queryable<Dt_Task_Hty>() + .Where(it => + it.CreateDate >= thirtyDaysAgo && + it.CreateDate <= now && + it.TaskType == 100 && + roadwayKeys.Any(rk => it.Roadway.Contains(rk))) + .ToList() + .Select(t => new { + OriginalRoadway = t.Roadway, + MatchedKey = roadwayKeys.FirstOrDefault(rk => t.Roadway.Contains(rk)), + CreateDate = t.CreateDate + }) + .Where(t => t.MatchedKey != null) + .GroupBy(t => new { + RoadwayKey = t.MatchedKey, + Date = t.CreateDate.Date, + Hour = t.CreateDate.Hour + }) + .OrderByDescending(group => group.Key.Date) + .ThenByDescending(group => group.Key.Hour) + .Select(group => new { + Hour = $"{group.Key.Date:yyyy/M/d} {group.Key.Hour}:00", + Count = group.Count(), + Roadway = roadwayMappings[group.Key.RoadwayKey] // 鏄犲皠涓轰腑鏂囧悕绉� + }) + .ToList(); + return content.OK1(total1: taskHty.Count, data: taskHty); + } + catch (Exception ex) + { + return content.Error(ex.Message); + } + } #endregion 澶栭儴鎺ュ彛鏂规硶 #region 鍐呴儴璋冪敤鏂规硶 @@ -1661,20 +1910,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("鍒犻櫎鎴愬姛!"); } @@ -1787,6 +2039,44 @@ #endregion 鍐呴儴璋冪敤鏂规硶 #region private 鍐呴儴鏂规硶 + + + /// <summary> + /// 鑾峰彇浠诲姟绫诲瀷鎻忚堪鏂规硶 + /// </summary> + /// <param name="taskType"></param> + /// <returns></returns> + private string GetTaskTypeDesc(int taskType) + { + return taskType switch + { + (int)TaskInboundTypeEnum.Inbound => TaskInboundTypeEnum.Inbound.GetIntegralRuleTypeEnumDesc(), + (int)TaskInboundTypeEnum.InTray => TaskInboundTypeEnum.InTray.GetIntegralRuleTypeEnumDesc(), + (int)TaskInboundTypeEnum.InNG => TaskInboundTypeEnum.InNG.GetIntegralRuleTypeEnumDesc(), + (int)TaskInboundTypeEnum.InQuality => TaskInboundTypeEnum.InQuality.GetIntegralRuleTypeEnumDesc(), + (int)TaskOutboundTypeEnum.OutTray => TaskOutboundTypeEnum.OutTray.GetIntegralRuleTypeEnumDesc(), + (int)TaskOutboundTypeEnum.Outbound => TaskOutboundTypeEnum.Outbound.GetIntegralRuleTypeEnumDesc(), + (int)TaskOutboundTypeEnum.OutNG => TaskOutboundTypeEnum.OutNG.GetIntegralRuleTypeEnumDesc(), + }; + } + + // 瀹氫箟鑾峰彇浠诲姟鐘舵�佹弿杩版柟娉� + private string GetTaskStateDesc(int? taskState) + { + return taskState switch + { + (int)TaskInStatusEnum.InNew => TaskInStatusEnum.InNew.GetIntegralRuleTypeEnumDesc(), + (int)TaskInStatusEnum.Line_InExecuting => TaskInStatusEnum.Line_InExecuting.GetIntegralRuleTypeEnumDesc(), + (int)TaskInStatusEnum.Line_InFinish => TaskInStatusEnum.Line_InFinish.GetIntegralRuleTypeEnumDesc(), + (int)TaskInStatusEnum.SC_InExecuting => TaskInStatusEnum.SC_InExecuting.GetIntegralRuleTypeEnumDesc(), + (int)TaskInStatusEnum.SC_InFinish => TaskInStatusEnum.SC_InFinish.GetIntegralRuleTypeEnumDesc(), + (int)TaskOutStatusEnum.OutNew => TaskOutStatusEnum.OutNew.GetIntegralRuleTypeEnumDesc(), + (int)TaskOutStatusEnum.SC_OutExecuting => TaskOutStatusEnum.SC_OutExecuting.GetIntegralRuleTypeEnumDesc(), + (int)TaskOutStatusEnum.SC_OutFinish => TaskOutStatusEnum.SC_OutFinish.GetIntegralRuleTypeEnumDesc(), + (int)TaskOutStatusEnum.Line_OutExecuting => TaskOutStatusEnum.Line_OutExecuting.GetIntegralRuleTypeEnumDesc(), + (int)TaskOutStatusEnum.Line_OutFinish => TaskOutStatusEnum.Line_OutFinish.GetIntegralRuleTypeEnumDesc(), + }; + } /// <summary> /// 鍒涘缓鍘嗗彶浠诲姟璁板綍 @@ -2066,7 +2356,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