From a1c804eed3b8d936e6392ce3ca82e9ad65e12094 Mon Sep 17 00:00:00 2001 From: 刘磊 <1161824510@qq.com> Date: 星期二, 26 十一月 2024 08:47:47 +0800 Subject: [PATCH] 同步 --- Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs | 120 +++++++++++++++++++++++++++++++++++++++++++++--------------- 1 files changed, 90 insertions(+), 30 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 fa3ef06..980ddb5 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,17 +1,10 @@ -锘縰sing log4net.Core; -using Mapster; +锘縰sing Mapster; using Masuit.Tools; -using Masuit.Tools.Models; -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; @@ -38,6 +31,7 @@ private readonly IDt_AreaInfoRepository _areaInfoRepository; //鍖哄煙 private readonly IAgingInOrOutInputService _agingInOrOutInputService; //闈欑疆\闄堝寲 private readonly IProductionRepository _productionRepository; //鐢熶骇 + private readonly IDt_StationManagerRepository _stationManagerRepository; public Dt_TaskService(IDt_TaskRepository BaseDal, IUnitOfWorkManage unitOfWorkManage, @@ -59,7 +53,8 @@ IDt_AreaInfoRepository areaInfoRepository, IAgingInOrOutInputService agingInOrOutInputService, IStockInfoDetailRepository stockInfoDetailRepository, - IProductionRepository productionRepository) : base(BaseDal) + IProductionRepository productionRepository, + IDt_StationManagerRepository stationManagerRepository) : base(BaseDal) { _unitOfWorkManage = unitOfWorkManage; _outOrderRepository = outOrderRepository; @@ -81,6 +76,7 @@ _agingInOrOutInputService = agingInOrOutInputService; _stockInfoDetailRepository = stockInfoDetailRepository; _productionRepository = productionRepository; + _stationManagerRepository = stationManagerRepository; } #region 澶栭儴鎺ュ彛鏂规硶 @@ -98,10 +94,12 @@ //var process = await SqlSugarHelper.Db.Queryable<Dt_EquipmentProcess>() // .FirstAsync(x => x.EquipmentName == task.Roadway); //var info = JsonConvert.DeserializeObject<ResponseEqptRunDto>(process.ProcessValue); - - var agingOutputDto = MapToAgingOutputDto(stock); - content = await _agingInOrOutInputService.GetOCVOutputAsync(agingOutputDto); - ValidateResponse(content); + if (!task.Roadway.Contains("FR")) //闈炲垎瀹瑰簱鍖哄潎涓婃姤MOM鍑哄叆绔� + { + var agingOutputDto = MapToAgingOutputDto(stock); + content = await _agingInOrOutInputService.GetOCVOutputAsync(agingOutputDto); + ValidateResponse(content); + } } // 鏇存柊搴撳瓨鐘舵�佸拰浠诲姟鐘舵�� @@ -113,7 +111,8 @@ await UpdateLocationAsync(loc); await DeleteStockInfoAsync(stock.Id); await DeleteStockInfoDetailsAsync(stock.StockInfoDetails); - //await DeleteTaskAsync(task.TaskId); + if (task.Roadway.Contains("FR")) //濡傛灉鏄垎瀹� 灏嗕换鍔″垹闄� + await DeleteTaskAsync(task.TaskId); }); return content.OK("浠诲姟瀹屾垚鎴愬姛"); @@ -177,7 +176,7 @@ 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; @@ -308,8 +307,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("鍏ュ簱浠诲姟瀹屾垚鎴愬姛"); @@ -343,13 +343,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.宸插叆搴� } @@ -398,7 +426,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; @@ -433,6 +461,11 @@ return content.Error("浠诲姟涓嶅瓨鍦�"); } 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); @@ -530,7 +563,17 @@ if (serialNosError.Count > 0) { // TODO 鍒涘缓浠诲姟閫佽嚦NG鎺掑嚭鍙� - List<string> NGStation = input.Position == "1088" ? new List<string>() { "1020" } : new List<string>() { "JZSC01" }; + 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) + { + throw new Exception("鏈壘鍒癗G鍏ュ簱绔欏彴閰嶇疆"); + } + List<string> NGStation = efg.Select(x => x.stationNGLocation).ToList(); + if (NGStation.Count <= 0) + { + NGStation = efg.Select(x => x.stationNGChildCode).ToList(); + } content = await CreateNewTask(input, NGStation, 2); return content.Error("瀛樺湪寮傚父鐢佃姱"); } @@ -541,6 +584,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)); @@ -549,7 +593,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鏂规硶锛岃幏鍙栧伐鑹鸿矾绾� @@ -573,8 +618,14 @@ //// 璋冪敤GetProcessResponseAsync鏂规硶锛岃幏鍙栧伐鑹哄搷搴� //var processResponse = await GetProcessResponseAsync(process, input.Position); - List<string> strings = input.Position == "1088" ? new List<string>() { "CHSC01" } : new List<string>() { "JZSC01" }; - // 璋冪敤CreateNewTask鏂规硶锛屽垱寤烘柊浠诲姟 + //List<string> strings = input.Position == "1088" ? new List<string>() { "CHSC01" } : new List<string>() { "JZSC01" }; + var stationManagers = _stationManagerRepository.QueryData(x => x.stationType == 1 && x.stationChildCode == input.Position && x.stationArea == area.AreaCode).ToList(); + if (stationManagers.Count <= 0) + { + throw new Exception("鏈壘鍒癗G鍏ュ簱绔欏彴閰嶇疆"); + } + List<string> strings = stationManagers.Select(x => x.Roadway).ToList(); + //// 璋冪敤CreateNewTask鏂规硶锛屽垱寤烘柊浠诲姟 content = await CreateNewTask(input, strings); if (content.Status) { @@ -647,8 +698,15 @@ return content.OK(data: task); } + var stationManagers = _stationManagerRepository.QueryData(x => x.stationType == 1 && x.stationChildCode == input.Position).ToList(); + if (stationManagers.Count <= 0) + { + throw new Exception("鏈壘鍒扮┖鎵樼洏鍏ュ簱绔欏彴閰嶇疆"); + } + + // 鑾峰彇鐩爣鍦板潃 - List<string> strings = input.Position == "1016" ? new List<string>() { "CHSC01" } : new List<string>() { "JZSC01" }; + List<string> strings = stationManagers.Select(x => x.Roadway).ToList(); return await CreateNewTask(input, strings, 1); } @@ -667,7 +725,7 @@ } // 鑾峰彇缁勭洏淇℃伅 - private async Task<DtBoxingInfo> CreateBoxingInfo(ResultTrayCellsStatus result, string palletCode) + private DtBoxingInfo CreateBoxingInfo(ResultTrayCellsStatus result, string palletCode) { return new DtBoxingInfo { @@ -1173,12 +1231,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