From 9d6f25decd9d01a85fec002ecb59ecb742fe0e70 Mon Sep 17 00:00:00 2001 From: huangxiaoqiang <huangxiaoqiang@hnkhzn.com> Date: 星期四, 12 六月 2025 16:10:02 +0800 Subject: [PATCH] 添加火命令逻辑在 `CommonStackerCraneJob.cs` 和 `CommonStackerStationCraneJob.cs` 文件中,添加了 `FireCommand` 属性的设置逻辑,该属性的值根据 `task.TaskType` 判断,并增加了对任务类型组的判断,以确定是否为入库任务。 --- CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs | 197 ++++++++++++++++++++++++++++++++++++------------- 1 files changed, 144 insertions(+), 53 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 497571a..7cf111a 100644 --- a/CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs +++ b/CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs @@ -1086,11 +1086,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) // 鎺掑簭 @@ -1115,7 +1115,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, @@ -1678,7 +1678,6 @@ /// 鑾峰彇浠诲姟淇℃伅 /// </summary> /// <returns></returns> - /// public WebResponseContent GetTaskInfo() { WebResponseContent content = new WebResponseContent(); @@ -1740,10 +1739,12 @@ /// 鑾峰彇璐т綅鐘舵�� /// </summary> /// <returns></returns> - public WebResponseContent GetStockQuantity() { + public WebResponseContent GetStockQuantity() + { WebResponseContent content = new WebResponseContent(); - try { - var location= _locationRepository.Db.Queryable<DtLocationInfo>().ToList(); + try + { + var location = _locationRepository.Db.Queryable<DtLocationInfo>().ToList(); return content.OK(data: location); @@ -1756,11 +1757,29 @@ public WebResponseContent Getproductionvolume() { WebResponseContent content = new WebResponseContent(); - try { + 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(); + 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) @@ -1770,16 +1789,85 @@ } #endregion + public WebResponseContent GetTimeout() + { + WebResponseContent content = new WebResponseContent(); + try + { + var now = DateTime.Now; + // 浣跨敤Subtract鏂规硶 + var threeHoursAgo = now.Subtract(TimeSpan.FromHours(3)); - #endregion 澶栭儴鎺ュ彛鏂规硶 + 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); + } - #region 鍐呴儴璋冪敤鏂规硶 + } - /// <summary> - /// 鍒涘缓涓�涓柊鐨勪换鍔� - /// </summary> - /// <param name="model">浠诲姟妯″瀷</param> - /// <returns>鍒涘缓鐨勪换鍔�</returns> + 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 鍐呴儴璋冪敤鏂规硶 + + /// <summary> + /// 鍒涘缓涓�涓柊鐨勪换鍔� + /// </summary> + /// <param name="model">浠诲姟妯″瀷</param> + /// <returns>鍒涘缓鐨勪换鍔�</returns> public async Task<Dt_Task> Create(Dt_Task model) { return await BaseDal.Create(model); @@ -1821,20 +1909,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("鍒犻櫎鎴愬姛!"); } @@ -2064,32 +2155,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 // 娣诲姞鍘嗗彶浠诲姟 -- Gitblit v1.9.3