Browse Source

排序问题

pengjing 1 year ago
parent
commit
be10507176

+ 2 - 0
YLShipBuildLandMap.Entity/ViewModel/Build/DepOrServicePointView.cs

@@ -12,6 +12,8 @@ namespace YLShipBuildLandMap.Entity.ViewModel.Build
         public string FloorName { get; set; }
         public string RoomName { get; set; }
         public string ImgUrl { get; set; }
+        public int? Sort { get; set; }
+        public int? FloorSort { get; set; }
     }
 
     public class DepOrServicePointRoomView

+ 11 - 6
YLShipBuildLandMap.Services/Build/DepOrServicePointService.cs

@@ -50,11 +50,13 @@ namespace YLShipBuildLandMap.Services.Build
                          FloorName = f.Name,
                          b.BuildingId,
                          BuildingName = b.Name,
-                         RoomName = r.Name
+                         RoomName = r.Name,
+                         RoomSort = r.Sort,
+                         FloorSort = f.Sort
                      }
                 ) on ds.DepartmentOrServicePointId equals room.DepartmentOrServicePointId into dbBdDepartmentOrServicePointBmBuildingFloorRoom
                 from rds in dbBdDepartmentOrServicePointBmBuildingFloorRoom.DefaultIfEmpty()
-                group new { rds.RoomName } by new
+                group new { rds.RoomName, rds.RoomSort } by new
                 {
                     ds.DepartmentOrServicePointId,
                     ds.Name,
@@ -69,7 +71,8 @@ namespace YLShipBuildLandMap.Services.Build
                     rds.FloorName,
                     rds.BuildingName,
                     rds.BuildingId,
-                    rds.BuildingFloorId
+                    rds.BuildingFloorId,
+                    rds.FloorSort
                 } into g
                 select new DepOrServicePointView
                 {
@@ -87,7 +90,9 @@ namespace YLShipBuildLandMap.Services.Build
                     BuildingId = g.Key.BuildingId,
                     FloorName = g.Key.FloorName,
                     FloorId = g.Key.BuildingFloorId,
-                   /* RoomName = string.Join("、", g.Select(s => s.RoomName).ToList())*/
+                    /* RoomName = string.Join("、", g.Select(s => s.RoomName).ToList())*/
+                    Sort = g.Min(s => s.RoomSort),
+                    FloorSort = g.Key.FloorSort
                 };
 
             return query;
@@ -126,7 +131,7 @@ namespace YLShipBuildLandMap.Services.Build
             var query = GetDepOrServicePointQuery(exp)
                 .WhereIf(floorId.HasValue, e => e.FloorId == floorId)
                 .WhereIf(buildingId.HasValue, e => e.BuildingId == buildingId)
-                .OrderBy(e => e.BuildingName).ThenBy(e => e.FloorName).ThenBy(e => e.Name);
+                .OrderBy(e => e.BuildingName).ThenBy(e => e.FloorSort).ThenBy(e => e.Sort).ThenBy(e => e.Name);
 
             var dataResult = query.ToGridResultSet(pageIndex, pageSize);
 
@@ -136,7 +141,7 @@ namespace YLShipBuildLandMap.Services.Build
 
             dataResult.rows.ForEach(item =>
             {
-                item.RoomName = string.Join("、", roomList.Where(e => e.DepartmentOrServicePointId == item.DepartmentOrServicePointId && e.FloorId == item.FloorId).OrderBy(e => e.RoomSort).Select(s => s.RoomName).ToList());
+                item.RoomName = string.Join("、", roomList.Where(e => e.DepartmentOrServicePointId == item.DepartmentOrServicePointId && e.FloorId == item.FloorId).OrderBy(e => e.RoomSort).ThenBy(e => e.RoomName).Select(s => s.RoomName).ToList());
                 item.ImgUrl = fileList.Where(e => e.ReferenceId == item.DepartmentOrServicePointId).FirstOrDefault()?.Url;
             });