| | |
| | | using WIDESEA_Core.Seed; |
| | | using WIDESEA_Core.Utilities; |
| | | using WIDESEA_DTO.Basic; |
| | | using WIDESEA_DTO.Task; |
| | | using WIDESEA_IBasicService; |
| | | using WIDESEA_Model.Models; |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | public string AccessingTunnel(int WarehouseId, int LocationType) |
| | | public string AccessingTunnel(int WarehouseId, int LocationType, List<RoadwayTaskCount> roadwayTaskCounts) |
| | | { |
| | | List<Dt_LocationInfo> locationData = BaseDal.QueryData(x => x.WarehouseId == WarehouseId); |
| | | var roadwayGroups = locationData.Where(x => x.LocationType == LocationType && x.EnableStatus== (int)EnableStatusEnum.Normal).GroupBy(x => x.RoadwayNo) |
| | | .Select(g => new |
| | | |
| | | // å° roadwayTaskCounts 转æ¢ä¸ºåå
¸ï¼ä¾¿äºå¿«éæ¥æ¾ |
| | | var taskCountDict = roadwayTaskCounts?.ToDictionary(x => x.Roadway, x => x.TaskCount) ?? new Dictionary<string, int>(); |
| | | |
| | | var roadwayGroups = locationData.Where(x => x.LocationType == LocationType && x.LocationStatus == (int)LocationStatusEnum.Free && x.EnableStatus == (int)EnableStatusEnum.Normal) |
| | | .GroupBy(x => x.RoadwayNo) |
| | | .Select(g => new |
| | | { |
| | | RoadwayNo = g.Key, |
| | | FreeCount = g.Count(), |
| | | TaskCount = taskCountDict.ContainsKey(g.Key) ? taskCountDict[g.Key] : 0, |
| | | AvailableCount = g.Count() - (taskCountDict.ContainsKey(g.Key) ? taskCountDict[g.Key] : 0) |
| | | }) |
| | | .Where(g => g.AvailableCount > 0) |
| | | .ToList(); |
| | | |
| | | int minRequired = 3; |
| | | |
| | | if (WarehouseId == (int)WarehouseEnum.YMYL) |
| | | { |
| | | RoadwayNo = g.Key, |
| | | LocationCount = g.Count(), |
| | | }).OrderByDescending(g => g.LocationCount).ToList(); |
| | | if (LocationType == 2) minRequired = 2; |
| | | |
| | | int minRequired = 15; |
| | | if(WarehouseId== (int)WarehouseEnum.YMYL) |
| | | { |
| | | if (LocationType == 2) minRequired = 6; |
| | | // è¿é鿩巷é1æè
2ï¼å
æ¾ä»»å¡æå°çï¼å¦æä¸æ ·ï¼éæ©åºåå¨å¤ç |
| | | var targetRoadways = roadwayGroups |
| | | .Where(g => (g.RoadwayNo == "1" || g.RoadwayNo == "2") && g.AvailableCount >= minRequired) |
| | | .OrderBy(g => g.TaskCount) // å
æä»»å¡æ°ååºï¼ä»»å¡å°çä¼å
ï¼ |
| | | .ThenByDescending(g => g.FreeCount) // ä»»å¡ç¸åæ¶æç©ºé²æ°éåºï¼åºåå¤çä¼å
ï¼ |
| | | .ToList(); |
| | | |
| | | var selectedRoadway = roadwayGroups.FirstOrDefault(g => g.LocationCount >= minRequired); |
| | | if(selectedRoadway!=null) return selectedRoadway.RoadwayNo; |
| | | |
| | | var selectedRoadway = targetRoadways.FirstOrDefault(); |
| | | if (selectedRoadway != null) |
| | | return selectedRoadway.RoadwayNo; |
| | | } |
| | | else |
| | | { |
| | | var selectedRoadway = roadwayGroups.FirstOrDefault(g => g.LocationCount >= minRequired); |
| | | if(selectedRoadway == null) |
| | | { |
| | | selectedRoadway = roadwayGroups.FirstOrDefault(g => g.RoadwayNo == "5" && g.LocationCount != 0); |
| | | // è¿é鿩巷é3æè
4æè
5ï¼å
æ¾ä»»å¡æå°çï¼å¦æä¸æ ·ï¼éæ©åºåå¨å¤ç |
| | | var targetRoadways = roadwayGroups |
| | | .Where(g => (g.RoadwayNo == "3" || g.RoadwayNo == "4" || g.RoadwayNo == "5") && g.AvailableCount >= minRequired) |
| | | .OrderBy(g => g.TaskCount) // å
æä»»å¡æ°ååºï¼ä»»å¡å°çä¼å
ï¼ |
| | | .ThenByDescending(g => g.FreeCount) // ä»»å¡ç¸åæ¶æç©ºé²æ°éåºï¼åºåå¤çä¼å
ï¼ |
| | | .ToList(); |
| | | |
| | | var selectedRoadway = targetRoadways.FirstOrDefault(); |
| | | if (selectedRoadway == null) |
| | | { |
| | | // å¦ææ²¡ææ»¡è¶³æä½è¦æ±çï¼å°è¯éæ©å··é5ï¼åªè¦æå¯ç¨åºä½å°±è¡ï¼ |
| | | selectedRoadway = roadwayGroups |
| | | .Where(g => g.RoadwayNo == "5" && g.AvailableCount > 0) |
| | | .FirstOrDefault(); |
| | | } |
| | | if(selectedRoadway != null) return selectedRoadway.RoadwayNo; |
| | | |
| | | if (selectedRoadway != null) |
| | | return selectedRoadway.RoadwayNo; |
| | | } |
| | | |
| | | return "0"; |
| | | } |
| | | |
| | | |
| | | |
| | | public Dt_LocationInfo? ShallowGetLocation(string roadway, int Locationtype,int row ,int Layer, int Column) |
| | | { |
| | | return BaseDal.QueryData(x => x.RoadwayNo == roadway && x.LocationType == Locationtype && x.Row==row && x.Layer== Layer && x.Column== Column).FirstOrDefault(); |
| | | } |
| | | |
| | | public Dt_LocationInfo? FindStorageLocation(string LocationCode) |
| | | { |
| | | return BaseDal.QueryData(x => x.LocationCode == LocationCode).FirstOrDefault(); |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | private int judgmentRow(string RoadwayNo, int locrow) |
| | | public int judgmentRow(string RoadwayNo, int locrow) |
| | | { |
| | | if (RoadwayNo == "1" || RoadwayNo == "3") |
| | | { |
| | |
| | | |
| | | public DateTime DateTime { get; set; } |
| | | } |
| | | |
| | | |
| | | |
| | | public WebResponseContent GetArea() |
| | | { |
| | | // WarehouseIdåç»ï¼ç¶åæ¯RoadwayNo |
| | | var result = BaseDal.QueryData() |
| | | .GroupBy(x => x.WarehouseId) |
| | | .Select(g => new { |
| | | WarehouseId = g.Key, |
| | | RoadwayNo = g.Select(x => x.RoadwayNo).Distinct().ToList() |
| | | }) |
| | | .ToList(); |
| | | return WebResponseContent.Instance.OK("æå", result); |
| | | } |
| | | |
| | | public WebResponseContent GetLocationStatus(int WarehouseId, string RoadwayNo) |
| | | { |
| | | // æ ¼å¼{å±,{è¿ä¸å±çåæ°æ®}} |
| | | var locations = BaseDal.QueryData(x => x.WarehouseId == WarehouseId && x.RoadwayNo == RoadwayNo) |
| | | .Select(x => new |
| | | { |
| | | x.RoadwayNo, |
| | | x.LocationCode, |
| | | x.WarehouseId, |
| | | x.Row, |
| | | x.Column, |
| | | x.Layer, |
| | | x.Depth, |
| | | x.LocationType, |
| | | x.LocationStatus, |
| | | x.EnableStatus |
| | | }) |
| | | .ToList(); |
| | | |
| | | // å¦ææ²¡ææ¾å°æ°æ®ï¼è¿å空å表è䏿¯null |
| | | if (locations == null || !locations.Any()) |
| | | { |
| | | return WebResponseContent.Instance.OK("æªæ¾å°å¯¹åºå··éçè´§ä½æ°æ®", new List<object>()); |
| | | } |
| | | |
| | | // ä¿®æ¹ä¸ºå±ä¸é¢æ¾ææåçä¿¡æ¯ |
| | | var result = locations |
| | | .GroupBy(x => x.Layer) // æå±åç» |
| | | .Select(layerGroup => new |
| | | { |
| | | layer = layerGroup.Key, |
| | | columns = layerGroup.GroupBy(x => x.Column) // æ¯å±ä¸æååç» |
| | | .Select(columnGroup => new |
| | | { |
| | | column = columnGroup.Key, |
| | | depths = columnGroup.Select(d => new |
| | | { |
| | | row = d.Row, |
| | | LocationCode = d.LocationCode, |
| | | depth = d.Depth, |
| | | locationType = d.LocationType, |
| | | locationStatus = d.LocationStatus, |
| | | enableStatus = d.EnableStatus |
| | | }).ToList() |
| | | }).ToList() |
| | | }).ToList(); |
| | | |
| | | return WebResponseContent.Instance.OK("æå", result); |
| | | } |
| | | // ç»§ç»åï¼WarehouseId =1ï¼æä¸¤ä¸ªä¸åçè´§ç©ï¼LocationType =1å2 |
| | | public WebResponseContent GetWarehouseCapacity() |
| | | { |
| | | // æ¥è¯¢ææä»åºçè´§ä½æ°æ®ï¼å
å«è´§ä½ç±»å |
| | | var allLocations = BaseDal.QueryData() |
| | | .Select(x => new |
| | | { |
| | | x.WarehouseId, |
| | | x.LocationStatus, |
| | | x.LocationType // æ·»å è´§ä½ç±»å |
| | | }) |
| | | .ToList(); |
| | | |
| | | // å¦ææ²¡ææ°æ®ï¼è¿å空å表 |
| | | if (allLocations == null || !allLocations.Any()) |
| | | { |
| | | return WebResponseContent.Instance.OK("æªæ¾å°ä»»ä½è´§ä½æ°æ®", new List<object>()); |
| | | } |
| | | |
| | | // æä»åºåè´§ä½ç±»ååç»ç»è®¡ |
| | | var result = allLocations |
| | | .GroupBy(x => new { x.WarehouseId, x.LocationType }) |
| | | .Select(g => new |
| | | { |
| | | WarehouseId = g.Key.WarehouseId, |
| | | LocationType = g.Key.LocationType, |
| | | TotalLocations = g.Count(), |
| | | FreeLocations = g.Count(x => x.LocationStatus == 0), |
| | | UsedLocations = g.Count(x => x.LocationStatus == 1), |
| | | OccupancyRate = (int)Math.Round((double)g.Count(x => x.LocationStatus == 1) / g.Count() * 100), |
| | | RemainingCapacityPercentage = (int)Math.Round((double)g.Count(x => x.LocationStatus == 0) / g.Count() * 100) |
| | | }) |
| | | .OrderBy(x => x.WarehouseId) |
| | | .ThenBy(x => x.LocationType) |
| | | .ToList(); |
| | | |
| | | return WebResponseContent.Instance.OK("æå", result); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// ä¸é®å¯ç¨å··éææè´§ä½ |
| | | /// </summary> |
| | | /// <param name="warehouseId">ä»åºID</param> |
| | | /// <param name="roadwayNo">å··éç¼å·</param> |
| | | /// <returns></returns> |
| | | public WebResponseContent EnableAllLocationsInRoadway(string roadwayNo) |
| | | { |
| | | if (string.IsNullOrEmpty(roadwayNo)) |
| | | return WebResponseContent.Instance.Error("å··éç¼å·ä¸è½ä¸ºç©º"); |
| | | |
| | | var locations = Repository.QueryData(x => |
| | | x.RoadwayNo == roadwayNo && |
| | | x.EnableStatus != EnableStatusEnum.Normal.ObjToInt()); |
| | | |
| | | if (locations == null || locations.Count == 0) |
| | | return WebResponseContent.Instance.OK("è¯¥å··éæ²¡æéè¦å¯ç¨çè´§ä½"); |
| | | |
| | | locations.ForEach(x => x.EnableStatus = EnableStatusEnum.Normal.ObjToInt()); |
| | | Repository.UpdateData(locations); |
| | | |
| | | return WebResponseContent.Instance.OK($"æåå¯ç¨å··é[{roadwayNo}]ç{locations.Count}个货ä½"); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// ä¸é®ç¦ç¨å··éææè´§ä½ |
| | | /// </summary> |
| | | /// <param name="warehouseId">ä»åºID</param> |
| | | /// <param name="roadwayNo">å··éç¼å·</param> |
| | | /// <returns></returns> |
| | | public WebResponseContent DisableAllLocationsInRoadway(string roadwayNo) |
| | | { |
| | | if (string.IsNullOrEmpty(roadwayNo)) |
| | | return WebResponseContent.Instance.Error("å··éç¼å·ä¸è½ä¸ºç©º"); |
| | | var locations = Repository.QueryData(x => |
| | | x.RoadwayNo == roadwayNo && |
| | | x.EnableStatus != EnableStatusEnum.Disable.ObjToInt()); |
| | | if (locations == null || locations.Count == 0) |
| | | return WebResponseContent.Instance.OK("è¯¥å··éæ²¡æéè¦ç¦ç¨çè´§ä½"); |
| | | // æ£æ¥è´§ä½æ¯å¦æåºå |
| | | var locationIds = locations.Select(x => x.Id).ToList(); |
| | | locations.ForEach(x => x.EnableStatus = EnableStatusEnum.Disable.ObjToInt()); |
| | | Repository.UpdateData(locations); |
| | | return WebResponseContent.Instance.OK($"æåç¦ç¨å··é[{roadwayNo}]ç{locations.Count}个货ä½"); |
| | | } |
| | | } |
| | | } |