From e61bb0e26530b2aa9055737fade9e77ccb1feebf Mon Sep 17 00:00:00 2001 From: 肖洋 <cathay_xy@163.com> Date: 星期二, 07 一月 2025 10:06:16 +0800 Subject: [PATCH] 更新多个文件,优化逻辑与配置 --- Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs | 54 ++++++++++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 48 insertions(+), 6 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 3b6a326..931a2e7 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 @@ -14,6 +14,7 @@ using WIDESEA_StorageBasicRepository; using WIDESEA_StoragIntegrationServices; using WIDESEAWCS_BasicInfoRepository; +using WIDESEAWCS_QuartzJob.Models; namespace WIDESEA_StorageTaskServices; @@ -300,7 +301,7 @@ private async Task AddStockInfoHtyAsync(DtStockInfo_Hty dtStock) { - var isStockAdd = await SqlSugarHelper.Db.InsertNav(dtStock).IncludesAllFirstLayer().ExecuteCommandAsync(); + var isStockAdd = await SqlSugarHelper.DbWMS.InsertNav(dtStock).IncludesAllFirstLayer().ExecuteCommandAsync(); if (!isStockAdd) { throw new Exception("搴撳瓨鍘嗗彶淇℃伅娣诲姞澶辫触"); @@ -1229,14 +1230,19 @@ /// </summary> private async Task<DtStockInfo> QueryStockInfoForRealTrayCWAsync(List<string> areaCodes, string productionLine) { - var area = await _areaInfoRepository.QueryFirstAsync(x => x.AreaCode == "CWSC1"); + var areaId = (await _areaInfoRepository.QueryDataAsync(x => areaCodes.Contains(x.AreaCode))).Select(x => x.AreaID).ToList(); + if (areaId.Count == 0) + { + ConsoleHelper.WriteErrorLine($"鏌ヨ甯告俯瀹炵洏搴撳瓨淇℃伅鏃�,鏈壘鍒板尯鍩熶唬鐮佷负{JsonConvert.SerializeObject(areaCodes)}鐨勬暟鎹�"); + return null; + } var result = await _stockInfoRepository.Db.Queryable<DtStockInfo>() .Includes(x => x.LocationInfo) // 棰勫姞杞絃ocationInfo .Includes(x => x.StockInfoDetails) // 棰勫姞杞絊tockInfoDetails .Where(x => areaCodes.Contains(x.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 && x.LocationInfo.EnalbeStatus == (int)EnableEnum.Enable) // 杩囨护鏉′欢 + .Where(x => x.LocationInfo.LocationStatus == (int)LocationEnum.InStock && areaId.Contains(x.LocationInfo.AreaId) && x.LocationInfo.EnalbeStatus == (int)EnableEnum.Enable) // 杩囨护鏉′欢 .OrderBy(x => x.OutboundTime) // 鎺掑簭 .FirstAsync(); // 鑾峰彇绗竴涓厓绱� @@ -1669,7 +1675,39 @@ content.OK(data: taskDTO); } else - content.Error(result.MOMMessage); + { + var location = await GetLocationDistributeAsync(station.Roadway); + var task = new Dt_Task + { + CurrentAddress = station.stationLocation, + Grade = 1, + Roadway = station.Roadway, + TargetAddress = location.LocationCode, + Dispatchertime = DateTime.Now, + MaterialNo = "", + NextAddress = location.LocationCode, + OrderNo = null, + PalletCode = palletCode, + SourceAddress = position, + TaskState = (int)TaskInStatusEnum.Line_InFinish, + TaskType = (int)TaskInboundTypeEnum.InTray, + TaskNum = await BaseDal.GetTaskNo(), + Creater = "Systeam" + }; + // 鍒涘缓WMS浠诲姟 + WMSTaskDTO taskDTO = CreateWMSTaskDTO(task); + + await _unitOfWorkManage.UseTranAsync(async () => + { + // 娣诲姞浠诲姟鍒版暟鎹簱 + await BaseDal.AddDataAsync(task); + // 鏇存柊搴撳瓨浣嶇疆鐘舵�佷负涓嶅彲鐢� + location.LocationStatus = (int)LocationEnum.Lock; + await _locationRepository.UpdateDataAsync(location); + }); + + content.OK(data: taskDTO); + } } else { @@ -1697,7 +1735,7 @@ Grade = 1, PalletCode = taskOld.PalletCode, RoadWay = taskOld.Roadway, - SourceAddress = taskOld.CurrentAddress, + SourceAddress = taskOld.SourceAddress, TargetAddress = taskOld.TargetAddress, TaskState = taskOld.TaskState.Value, Id = 0, @@ -2259,7 +2297,11 @@ /// <returns></returns> public async Task<string> GetRoadWayAsync(List<string> process) { - var minGroup = _locationRepository.QueryData(x => process.Contains(x.RoadwayNo) && x.LocationStatus == (int)LocationEnum.Free) + var deviceCode = await SqlSugarHelper.DbWCS.Queryable<Dt_DeviceInfo>() + .Where(x => x.DeviceStatus == 1.ToString() && process.Contains(x.DeviceCode)) + .Select(x => x.DeviceCode).ToListAsync(); + + var minGroup = _locationRepository.QueryData(x => deviceCode.Contains(x.RoadwayNo) && x.LocationStatus == (int)LocationEnum.Free) .GroupBy(x => x.RoadwayNo) .OrderByDescending(g => g.Count()) // 鏍规嵁姣忎釜缁勭殑鍏冪礌鏁伴噺鎺掑簭 .ToList(); // 鍙栧嚭鏁伴噺鏈�澶氱殑缁� -- Gitblit v1.9.3