From ec78ebdad429c6438f8965941aa912865c71a949 Mon Sep 17 00:00:00 2001 From: hutongqing <hutongqing@hnkhzn.com> Date: 星期三, 15 一月 2025 17:34:16 +0800 Subject: [PATCH] 修改板材退库交互 --- 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/AssignInboundTaskLocation_BC.cs | 121 +++++++++++++++++++++++++++++++++++++++ 1 files changed, 119 insertions(+), 2 deletions(-) diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/AssignInboundTaskLocation_BC.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/AssignInboundTaskLocation_BC.cs" index 34f74bb..aca5552 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/AssignInboundTaskLocation_BC.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/AssignInboundTaskLocation_BC.cs" @@ -24,7 +24,7 @@ /// <param name="taskNum">浠诲姟鍙�</param> /// <param name="roadwayNos">宸烽亾鍙�</param> /// <returns></returns> - public WebResponseContent AssignRoadway(List<string> roadwayNos, int taskNum, int heightType = 0) + public WebResponseContent AssignRoadwayByHeight(List<string> roadwayNos, int taskNum, int heightType = 0) { try { @@ -70,6 +70,123 @@ } /// <summary> + /// + /// </summary> + /// <param name="roadwayNos"></param> + /// <param name="palletCode"></param> + /// <param name="heightType"></param> + /// <returns></returns> + public WebResponseContent AssignRoadwayByHeightAndCode(List<string> roadwayNos, string palletCode, int heightType = 0) + { + try + { + if (heightType == 0 || heightType > 3) + { + return WebResponseContent.Instance.Error($"楂樺害閿欒"); + } + if (roadwayNos == null || roadwayNos.Count == 0) + { + return WebResponseContent.Instance.Error($"宸烽亾涓嶈兘涓虹┖"); + } + Dt_LocationInfo locationInfo = _basicRepository.LocationInfoRepository.QueryFirst(x => x.RoadwayNo == roadwayNos[0]); + if (locationInfo == null) + { + return WebResponseContent.Instance.Error($"鏈壘鍒板贩閬撳搴旇揣浣�"); + } + Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseId == locationInfo.WarehouseId); + if (warehouse == null) + { + return WebResponseContent.Instance.Error($"鏈壘鍒板贩閬撳搴斾粨搴撲俊鎭�"); + } + + int palletType = _inboundOrderService.GetPalletType(warehouse, palletCode); + if (palletType == -1) + { + return WebResponseContent.Instance.Error($"鎵樼洏鍙疯В鏋愭墭鐩樼被鍨嬮敊璇�"); + } + + string roadwayNo = ""; + if (heightType == 1) + { + List<LocationCount> locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => (x.LocationType == palletType || x.LocationType == LocationTypeEnum.Undefined.ObjToInt()) && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && roadwayNos.Contains(x.RoadwayNo) && x.Layer <= 3).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).ToList(); + roadwayNo = locationCounts.OrderBy(x => x.Count).FirstOrDefault()?.RoadwayNo ?? ""; + } + else if (heightType == 2) + { + List<LocationCount> locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => (x.LocationType == palletType || x.LocationType == LocationTypeEnum.Undefined.ObjToInt()) && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && roadwayNos.Contains(x.RoadwayNo) && x.Layer == 4).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).ToList(); + roadwayNo = locationCounts.OrderBy(x => x.Count).FirstOrDefault()?.RoadwayNo ?? ""; + } + else if (heightType == 3) + { + List<LocationCount> locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => (x.LocationType == palletType || x.LocationType == LocationTypeEnum.Undefined.ObjToInt()) && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && roadwayNos.Contains(x.RoadwayNo) && x.Layer == 5).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).ToList(); + roadwayNo = locationCounts.OrderBy(x => x.Count).FirstOrDefault()?.RoadwayNo ?? ""; + } + + return !string.IsNullOrEmpty(roadwayNo) ? WebResponseContent.Instance.OK(data: roadwayNo) : WebResponseContent.Instance.Error("鏈壘鍒板彲鍒嗛厤宸烽亾"); + } + catch (Exception ex) + { + _unitOfWorkManage.RollbackTran(); + return WebResponseContent.Instance.Error(ex.Message); + } + } + + public string AssignRoadwayNo(List<string> roadwayNos, string palletCode, int heightType = 0) + { + try + { + if (heightType == 0 || heightType > 3) + { + throw new Exception($"楂樺害閿欒"); + } + if (roadwayNos == null || roadwayNos.Count == 0) + { + throw new Exception($"宸烽亾涓嶈兘涓虹┖"); + } + Dt_LocationInfo locationInfo = _basicRepository.LocationInfoRepository.QueryFirst(x => x.RoadwayNo == roadwayNos[0]); + if (locationInfo == null) + { + throw new Exception($"鏈壘鍒板贩閬撳搴旇揣浣�"); + } + Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseId == locationInfo.WarehouseId); + if (warehouse == null) + { + throw new Exception($"鏈壘鍒板贩閬撳搴斾粨搴撲俊鎭�"); + } + + int palletType = _inboundOrderService.GetPalletType(warehouse, palletCode); + if (palletType == -1) + { + throw new Exception($"鎵樼洏鍙疯В鏋愭墭鐩樼被鍨嬮敊璇�"); + } + + string roadwayNo = ""; + if (heightType == 1) + { + List<LocationCount> locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => (x.LocationType == palletType || x.LocationType == LocationTypeEnum.Undefined.ObjToInt()) && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && roadwayNos.Contains(x.RoadwayNo) && x.Layer <= 3).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).ToList(); + roadwayNo = locationCounts.OrderBy(x => x.Count).FirstOrDefault()?.RoadwayNo ?? ""; + } + else if (heightType == 2) + { + List<LocationCount> locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => (x.LocationType == palletType || x.LocationType == LocationTypeEnum.Undefined.ObjToInt()) && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && roadwayNos.Contains(x.RoadwayNo) && x.Layer == 4).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).ToList(); + roadwayNo = locationCounts.OrderBy(x => x.Count).FirstOrDefault()?.RoadwayNo ?? ""; + } + else if (heightType == 3) + { + List<LocationCount> locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => (x.LocationType == palletType || x.LocationType == LocationTypeEnum.Undefined.ObjToInt()) && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && roadwayNos.Contains(x.RoadwayNo) && x.Layer == 5).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).ToList(); + roadwayNo = locationCounts.OrderBy(x => x.Count).FirstOrDefault()?.RoadwayNo ?? ""; + } + + return !string.IsNullOrEmpty(roadwayNo) ? ( roadwayNo) : throw new Exception("鏈壘鍒板彲鍒嗛厤宸烽亾"); + } + catch (Exception ex) + { + _unitOfWorkManage.RollbackTran(); + throw new Exception(ex.Message); + } + } + + /// <summary> /// 鍏ュ簱浠诲姟鐢宠鍒嗛厤璐т綅 /// </summary> /// <param name="taskNum">浠诲姟鍙�</param> @@ -108,7 +225,7 @@ /// </summary> /// <param name="roadwayNos">宸烽亾鍙�</param> /// <returns></returns> - public WebResponseContent AssignRoadway(List<string> roadwayNos) + public WebResponseContent SingleAssignRoadway(List<string> roadwayNos) { try { -- Gitblit v1.9.3