From dcacc1fbcb885a958d6a9715c360ebb4aeac0894 Mon Sep 17 00:00:00 2001 From: 肖洋 <cathay_xy@163.com> Date: 星期二, 17 十二月 2024 19:40:59 +0800 Subject: [PATCH] 新增多个库页面:常温库、分容库、高温库,并更新导航栏以包含这些新页面 --- Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs | 157 ++++++++++++++++++++++++++-------------------------- 1 files changed, 79 insertions(+), 78 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 19379e7..dc1480b 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,20 +1,12 @@ -锘� -using AngleSharp.Io; -using log4net.Core; -using Mapster; +锘縰sing Mapster; using Masuit.Tools; -using OfficeOpenXml.FormulaParsing.Excel.Functions.Math; -using SixLabors.Fonts.Tables.AdvancedTypographic; +using System.Text.RegularExpressions; using WIDESEA_Core.Const; using WIDESEA_DTO.MOM; using WIDESEA_DTO.WMS; using WIDESEA_IServices; using WIDESEA_IStoragIntegrationServices; -using WIDESEA_Model.Models; -using WIDESEA_Services; -using WIDESEA_StorageBasicRepository; using WIDESEAWCS_BasicInfoRepository; -using WIDESEAWCS_Model.Models; namespace WIDESEA_StorageTaskServices; @@ -76,7 +68,6 @@ #region 鍑哄簱浠诲姟瀹屾垚 - public async Task<WebResponseContent> CompleteStackTaskAsync(Dt_Task task, DtStockInfo stock) { WebResponseContent content = new WebResponseContent(); @@ -102,6 +93,7 @@ // 鏇存柊搴撳瓨鐘舵�佸拰浠诲姟鐘舵�� (var loc, var tas) = UpdateStockAndTaskStatus(stock, task); + var taskHty = task.Adapt<Dt_Task_Hty>(); // 浜嬪姟澶勭悊 await _unitOfWorkManage.UseTranAsync(async () => @@ -114,6 +106,7 @@ await UpdateLocationAsync(loc); //if (task.Roadway.Contains("FR") || task.Roadway.Contains("GW") || task.TaskType == (int)TaskOutboundTypeEnum.OutTray) //濡傛灉鏄垎瀹规垨楂樻俯鍑哄簱 灏嗕换鍔″垹闄� await DeleteTaskAsync(task.TaskId); + await AddTaskHtyAsync(taskHty); }); return content.OK("浠诲姟瀹屾垚鎴愬姛", task.Remark); @@ -182,7 +175,6 @@ private void ValidateResponse(WebResponseContent content) { - } private (DtLocationInfo, Dt_Task) UpdateStockAndTaskStatus(DtStockInfo stock, Dt_Task task) @@ -236,6 +228,15 @@ } } + private async Task AddTaskHtyAsync(Dt_Task_Hty taskHty) + { + var isTaskAdd = await _task_HtyRepository.AddDataAsync(taskHty) > 0; + if (!isTaskAdd) + { + throw new Exception("鍘嗗彶浠诲姟淇℃伅娣诲姞澶辫触"); + } + } + #endregion 鍑哄簱浠诲姟瀹屾垚 #region 绉诲簱浠诲姟瀹屾垚 @@ -251,12 +252,12 @@ try { // 鏇存柊璐т綅鍜屽簱瀛樹俊鎭� - (DtStockInfo updateStock, DtLocationInfo locationInf) = UpdateStockLocation(stock, task.NextAddress); + (DtStockInfo updateStock, DtLocationInfo locationInForm, DtLocationInfo locationInfoTo) = UpdateStockLocation(stock, task); var taskHty = CreateHistoricalTask(task); - LogFactory.GetLog("浠诲姟瀹屾垚").InfoFormat(true, "绉诲簱浠诲姟瀹屾垚", $"璐т綅鍦板潃锛歿task.TargetAddress},淇敼鍚庡簱瀛樻暟鎹細{JsonConvert.SerializeObject(updateStock)}锛屽師鍏堣揣浣嶆暟鎹細{locationInf}"); + LogFactory.GetLog("浠诲姟瀹屾垚").InfoFormat(true, "绉诲簱浠诲姟瀹屾垚", $"璐т綅鍦板潃锛歿task.TargetAddress},淇敼鍚庡簱瀛樻暟鎹細{JsonConvert.SerializeObject(updateStock)}锛屽師鍏堣揣浣嶆暟鎹細{locationInForm}"); // 鎵ц鏁版嵁搴撲簨鍔� - bool isResult = await ExecuteTransaction(updateStock, taskHty, locationInf, task.TaskId); + bool isResult = await ExecuteTransaction(updateStock, taskHty, locationInForm, locationInfoTo, task.TaskId); if (isResult) content.OK("绉诲簱浠诲姟瀹屾垚鎴愬姛"); else @@ -293,7 +294,6 @@ // 鎵ц鏁版嵁搴撲簨鍔� await _unitOfWorkManage.UseTranAsync(async () => { - // 娣诲姞鍘嗗彶浠诲姟 var isTaskHtyAdd = await _task_HtyRepository.AddDataAsync(taskHtyNG) > 0; @@ -315,9 +315,15 @@ // 鍒涘缓鍘嗗彶浠诲姟瀹炰緥妯″瀷 var taskHty = CreateHistoricalTask(task); + if (task.TaskType == (int)TaskInboundTypeEnum.InQuality) + { + await _locationRepository.UpdateDataAsync(locationInf); + await _task_HtyRepository.AddDataAsync(taskHty); + await BaseDal.DeleteDataAsync(task); + return content.OK("鍏ュ簱浠诲姟瀹屾垚鎴愬姛"); + } // 鏍规嵁鏄惁鏈夌粍鐩樹俊鎭垱寤哄簱瀛樺疄渚嬫ā鍨� DtStockInfo stock = boxing == null ? CreateEmptyPalletStock(task, locationInf) : CreateFullPalletStock(task, locationInf, boxing); - // 鎵ц鏁版嵁搴撲簨鍔� bool isResult = await ExecuteTransaction(stock, taskHty, locationInf, task.TaskId, boxing); @@ -421,7 +427,6 @@ throw new Exception("鏈壘鍒板搴斿尯鍩熶俊鎭�"); } - var boxDetail = boxing.BoxingInfoDetails.Adapt<List<DtStockInfoDetail>>(); boxDetail.ForEach(x => { x.Status = (int)StockStateEmun.宸插叆搴�; }); var stock = new DtStockInfo() @@ -434,6 +439,9 @@ AreaCode = area.AreaCode, LocationId = loation.Id, StockInfoDetails = boxDetail, + ProcessCode = boxing.ProcessCode, + NextProcessCode = boxing.NextProcessCode, + Remark = boxing.BoxingInfoDetails.Count().ToString(), }; // 澶勭悊璇锋眰鍙傛暟 @@ -450,6 +458,10 @@ var result = _agingInOrOutInputService.GetOCVInputAsync(agingInputDto).Result; var respone = JsonConvert.DeserializeObject<ResponeAgingInputDto>(result.Data.ToString()); + if (respone.ProductionLine == null || respone.ParameterInfos == null || respone.SpecialParameterDuration.IsNullOrEmpty()) + { + throw new Exception("MOM鏁版嵁杩斿洖閿欒"); + } stock.LinedProcessFeedbackTime = respone.LinedProcessFeedbackTime; stock.SpecialParameterDuration = respone.SpecialParameterDuration; //2024骞�11鏈�16鏃ワ細鏂板瀛楁璁$畻搴斿嚭搴撴椂闂� @@ -511,6 +523,9 @@ LogFactory.GetLog("浠诲姟瀹屾垚").InfoFormat(true, "鍑哄簱浠诲姟", ""); return await CompleteStackTaskAsync(task, stock); + case (int)TaskRelocationTypeEnum.Relocation: + return await CompleteTransferTaskAsync(task, stock); + default: return content.Error("浠诲姟绫诲瀷涓嶅瓨鍦�"); } @@ -521,6 +536,7 @@ #region 璇锋眰浠诲姟鍏ュ簱 #region + /// <summary> /// 璇锋眰浠诲姟宸烽亾 /// </summary> @@ -555,7 +571,6 @@ return content.OK(data: taskDTO); } } - var stock = await _stockInfoRepository.QueryFirstNavAsync(x => x.PalletCode == input.PalletCode && x.IsFull); if (stock != null) @@ -708,18 +723,23 @@ case "CH01": areaIn = "CH001"; break; + case "JZ01": areaIn = "JZ001"; break; + case "GW01": areaIn = "GWSC1"; break; + case "CW01": areaIn = "CWSC1"; break; + case "CW02": areaIn = "CWSC2"; break; + default: break; } @@ -751,7 +771,7 @@ return content; } - #endregion + #endregion 璇锋眰浠诲姟鍏ュ簱 public async Task<WebResponseContent> RequestTaskAsync(RequestTaskDto input) { @@ -782,7 +802,7 @@ PalletCode = stock.PalletCode, SourceAddress = input.Position, CurrentAddress = input.Position, - TaskState = (int)TaskInStatusEnum.InNew, + TaskState = stock.LocationInfo.RoadwayNo.Contains("CH") ? (int)TaskInStatusEnum.InNew : (int)TaskInStatusEnum.Line_InFinish, TaskType = (int)TaskInboundTypeEnum.InQuality, TaskNum = BaseDal.GetTaskNo().Result, Creater = "System", // 淇鎷煎啓閿欒 @@ -790,12 +810,15 @@ TaskId = 0, }; - var taskDTO = CreateTaskDTO(task); + var taskDTO = CreateTaskDTO(taskNew); + BaseDal.AddData(taskNew); + return content.OK(data: taskDTO); // TODO璐ㄦ鍥炲簱 } // 鏍规嵁浣嶇疆鏌ヨ鍖哄煙淇℃伅 - var area = await QueryAreaInfoByPosition(input.Position.Replace("-1", "")); + var areaCode = Regex.Replace(input.Position, @"-(\d+)", ""); + var area = await QueryAreaInfoByPosition(areaCode); if (area == null) { return content.Error("璇ョ偣浣嶄笉鍦ㄥ尯鍩熷垪琛ㄤ腑瀛樺湪"); @@ -825,7 +848,6 @@ return await HandleErrorCells(input, area, serialNosError); } - var boxing = CreateBoxingInfo(result, input.PalletCode); if (boxing == null) return content.Error("缁勭洏澶辫触"); @@ -840,6 +862,7 @@ return content; } + /// <summary> /// 鏇存柊浠诲姟璐т綅 /// </summary> @@ -855,11 +878,9 @@ return content.Error($"鏆傛湭鎵惧埌銆恵input.PalletCode}銆戠殑浠诲姟"); return content = await UpdateExistingTask(input, task); - } catch (Exception err) { - throw; } } @@ -874,7 +895,6 @@ WebResponseContent content = new WebResponseContent(); try { - // 璋冪敤BaseDal.QueryFirstAsync鏂规硶锛屾煡璇换鍔� var task = await BaseDal.QueryFirstAsync(x => x.PalletCode == input.PalletCode); if (task != null && task.TaskState == (int)TaskInStatusEnum.InNew) @@ -895,7 +915,6 @@ return content.OK(data: task); } - var stationManagers = _stationManagerRepository.QueryData(x => x.stationType == 6 && x.stationChildCode == input.Position).FirstOrDefault(); if (stationManagers == null) { @@ -910,7 +929,6 @@ } catch (Exception) { - throw; } } @@ -955,7 +973,7 @@ }; } - #endregion 璇锋眰浠诲姟鍏ュ簱 + #endregion 澶栭儴鎺ュ彛鏂规硶 #region 璇锋眰鍑哄簱锛堝疄鐩�&绌虹洏锛� @@ -967,15 +985,15 @@ /// <param name="areaCode">鍖哄煙缂栫爜</param> /// <param name="roadways">宸烽亾缂栫爜闆嗗悎</param> /// <returns>杩斿洖缁撴灉闆�</returns> - public async Task<WebResponseContent> RequestTrayOutTaskAsync(string position, int tag, string areaCode, List<string> roadways) + public async Task<WebResponseContent> RequestTrayOutTaskAsync(string position, int tag, string areaCode, string productionLine) { WebResponseContent content = new WebResponseContent(); try { // 鏍规嵁鎵樼洏绫诲瀷鏌ヨ搴撳瓨淇℃伅 DtStockInfo stockInfo = tag == (int)TaskOutboundTypeEnum.Outbound - ? QueryStockInfoForRealTrayAsync(areaCode, roadways).Result - : QueryStockInfoForEmptyTrayAsync(areaCode, roadways).Result; + ? QueryStockInfoForRealTrayAsync(areaCode, productionLine).Result + : QueryStockInfoForEmptyTrayAsync(areaCode).Result; if (stockInfo == null) { @@ -1022,7 +1040,7 @@ /// <summary> /// 鏌ヨ瀹炵洏搴撳瓨淇℃伅 /// </summary> - private async Task<DtStockInfo> QueryStockInfoForRealTrayAsync(string areaCode, List<string> roadways) + private async Task<DtStockInfo> QueryStockInfoForRealTrayAsync(string areaCode, string productionLine) { var area = await _areaInfoRepository.QueryFirstAsync(x => x.AreaCode == areaCode); @@ -1030,6 +1048,7 @@ .Includes(x => x.LocationInfo) // 棰勫姞杞絃ocationInfo .Includes(x => x.StockInfoDetails) // 棰勫姞杞絊tockInfoDetails .Where(x => x.AreaCode == areaCode && x.OutboundTime < DateTime.Now && x.IsFull == true) // 杩囨护鏉′欢 + .WhereIF(!productionLine.IsNullOrEmpty(), x => x.ProductionLine == productionLine) .Where(x => x.LocationInfo.LocationStatus == (int)LocationEnum.InStock && x.LocationInfo.AreaId == area.AreaID) // 杩囨护鏉′欢 .OrderBy(x => x.OutboundTime) // 鎺掑簭 .FirstAsync(); // 鑾峰彇绗竴涓厓绱� @@ -1043,7 +1062,7 @@ /// <summary> /// 鏌ヨ绌虹洏搴撳瓨淇℃伅 /// </summary> - private async Task<DtStockInfo> QueryStockInfoForEmptyTrayAsync(string areaCode, List<string> roadways) + private async Task<DtStockInfo> QueryStockInfoForEmptyTrayAsync(string areaCode) { var area = await _areaInfoRepository.QueryFirstAsync(x => x.AreaCode == areaCode); @@ -1106,7 +1125,7 @@ }; } - #endregion 璇锋眰鍑哄簱 + #endregion 璇锋眰鍑哄簱锛堝疄鐩�&绌虹洏锛� #region 浠诲姟鐘舵�佹洿鏀� @@ -1156,34 +1175,7 @@ return content; } - #endregion - - #region 鍑哄簱瑙g洏 - - /// <summary> - /// 鍑哄簱瑙g洏鎺ュ彛 - /// </summary> - /// <param name="taskNum"></param> - /// <returns></returns> - public async Task<WebResponseContent> OutUnblockInterface(int taskNum) - { - WebResponseContent content = new WebResponseContent(); - try - { - var task = await BaseDal.QueryFirstAsync(x => x.TaskNum == taskNum); - if (task == null) - return content.Error("鏈壘鍒颁换鍔�"); - task.TaskState = (int)TaskOutStatusEnum.Line_OutFinish; - var taskHty = CreateHistoricalTask(task); - } - catch (Exception ex) - { - content.Error(ex.Message); - } - return content; - } - - #endregion + #endregion 浠诲姟鐘舵�佹洿鏀� #region 鎸囧畾浠诲姟鍑哄簱 @@ -1210,8 +1202,19 @@ taskType = (int)TaskOutboundTypeEnum.OutQuality; else taskType = (int)TaskOutboundTypeEnum.OutTray; - // 鍒涘缓骞舵坊鍔犱换鍔″埌鏁版嵁搴� - task = CreateTask(stockInfo, "1020-1", taskType); + + if (stockInfo.AreaCode.Contains("CH")) + { + // 鍒涘缓骞舵坊鍔犱换鍔″埌鏁版嵁搴� + task = CreateTask(stockInfo, "1020-1", taskType); + } + else + { + if (stockInfo.LocationInfo.RoadwayNo == "JZSC1") + { + task = CreateTask(stockInfo, "1359-4", taskType); + } + } //var taskId = await BaseDal.AddDataAsync(task); //if (taskId <= 0) //{ @@ -1249,6 +1252,7 @@ return content; } + private string GetWCSIpReceiveTask() { var configs = _configService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress); @@ -1261,7 +1265,7 @@ return wmsBase + ipAddress; } - #endregion + #endregion 鎸囧畾浠诲姟鍑哄簱 #endregion 澶栭儴鎺ュ彛鏂规硶 @@ -1438,20 +1442,19 @@ /// <param name="stock">搴撳瓨瀵硅薄</param> /// <param name="toLocation">鐩爣浣嶇疆</param> // 鏇存柊搴撳瓨鍜屼綅缃俊鎭� - private (DtStockInfo, DtLocationInfo) UpdateStockLocation(DtStockInfo stock, string toLocation) + private (DtStockInfo, DtLocationInfo, DtLocationInfo) UpdateStockLocation(DtStockInfo stock, Dt_Task task) { - // 鑾峰彇搴撳瓨淇℃伅 - var locationInfo = _locationRepository.QueryFirst(x => x.LocationCode == stock.LocationCode); - // 灏嗗簱瀛樼姸鎬佽缃负鍦ㄥ簱 - locationInfo.LocationStatus = LocationEnum.InStock.ObjToInt(); + //淇敼鏉ユ簮搴撲綅鍜� 鐩爣搴撲綅鐘舵�� + var fromLocation = _locationRepository.QueryFirst(x => x.LocationCode == task.SourceAddress && x.RoadwayNo == task.Roadway); + fromLocation.LocationStatus = LocationEnum.Free.ObjToInt(); + var toLocation = _locationRepository.QueryFirst(x => x.LocationCode == task.SourceAddress && x.RoadwayNo == task.Roadway); + toLocation.LocationStatus = LocationEnum.InStock.ObjToInt(); // 灏嗗簱瀛樹綅缃缃负鐩爣浣嶇疆 - stock.LocationCode = toLocation; - // 灏嗗簱瀛樼姸鎬佽缃负鍦ㄥ簱 - stock.LocationInfo.LocationStatus = LocationEnum.InStock.ObjToInt(); + stock.LocationCode = task.TargetAddress; // 杩斿洖鏇存柊鍚庣殑搴撳瓨鍜屼綅缃俊鎭� - return (stock, locationInfo); + return (stock, fromLocation, toLocation); } /// <summary> @@ -1483,7 +1486,6 @@ .Include(x => x.BoxingInfoDetails) .ExecuteCommandAsync(); } - } var stocks = _stockInfoRepository.QueryData(x => x.AreaCode == stock.AreaCode && x.ProductionLine == stock.ProductionLine && x.SpecialParameterDuration != stock.SpecialParameterDuration); @@ -1595,7 +1597,6 @@ _unitOfWorkManage.CommitTran(); return content.OK(data: task); } - } catch (Exception ex) { -- Gitblit v1.9.3