|
@@ -10,6 +10,9 @@ using Z.EntityFramework.Plus;
|
|
|
using YLShipBuildLandMap.Entity.Extensions;
|
|
|
using Bowin.Common.Linq.Entity;
|
|
|
using YLShipBuildLandMap.Entity.ViewModel.Build;
|
|
|
+using Bowin.Common.Linq;
|
|
|
+using Bowin.Common.Linq.Entity;
|
|
|
+using YLShipBuildLandMap.Entity.ViewModel;
|
|
|
|
|
|
namespace YLShipBuildLandMap.Services.Build
|
|
|
{
|
|
@@ -23,37 +26,126 @@ namespace YLShipBuildLandMap.Services.Build
|
|
|
|
|
|
}
|
|
|
|
|
|
- private IQueryable<DepOrServicePointView> GetDepOrServicePointQuery(Expression<Func<BdDepartmentOrServicePoint, bool>> exp, Expression<Func<BdBuilding, bool>> expBuild, Expression<Func<BdBuildingFloor, bool>> expFloor)
|
|
|
+ private IQueryable<DepOrServicePointView> GetDepOrServicePointQuery(Expression<Func<BdDepartmentOrServicePoint, bool>> exp)
|
|
|
{
|
|
|
- var query = from b in DbContext.BdBuilding
|
|
|
- join f in DbContext.BdBuildingFloor on b.BuildingId equals f.BuildingId
|
|
|
- join r in DbContext.BdBuildingFloorRoom on f.BuildingFloorId equals r.BuildingFloorId
|
|
|
- join rds in DbContext.BdDepartmentOrServicePointBmBuildingFloorRoom on r.BuildingFloorRoomId equals rds.BuildingFloorRoomId
|
|
|
- join ds in DbContext.BdDepartmentOrServicePoint on rds.DepartmentOrServicePointId equals ds.DepartmentOrServicePointId
|
|
|
- select new DepOrServicePointView { };
|
|
|
+ var query =
|
|
|
+ from ds in DbContext.BdDepartmentOrServicePoint.Where(exp)
|
|
|
+ /* join rds in DbContext.BdDepartmentOrServicePointBmBuildingFloorRoom on ds.DepartmentOrServicePointId equals rds.DepartmentOrServicePointId into dbBdDepartmentOrServicePointBmBuildingFloorRoom
|
|
|
+ from rds in dbBdDepartmentOrServicePointBmBuildingFloorRoom.DefaultIfEmpty()
|
|
|
+ join r in DbContext.BdBuildingFloorRoom on rds.BuildingFloorRoomId equals r.BuildingFloorRoomId into dbRoom
|
|
|
+ from r in dbRoom.DefaultIfEmpty()
|
|
|
+ join f in DbContext.BdBuildingFloor on r.BuildingFloorId equals f.BuildingFloorId into dbFloor
|
|
|
+ from f in dbFloor.DefaultIfEmpty()
|
|
|
+ join b in DbContext.BdBuilding on f.BuildingId equals b.BuildingId into dbBuild
|
|
|
+ from b in dbBuild.DefaultIfEmpty()*/
|
|
|
+ join room in (
|
|
|
+ from b in DbContext.BdBuilding
|
|
|
+ join f in DbContext.BdBuildingFloor on b.BuildingId equals f.BuildingId
|
|
|
+ join r in DbContext.BdBuildingFloorRoom on f.BuildingFloorId equals r.BuildingFloorId
|
|
|
+ join rds in DbContext.BdDepartmentOrServicePointBmBuildingFloorRoom on r.BuildingFloorRoomId equals rds.BuildingFloorRoomId
|
|
|
+ select new
|
|
|
+ {
|
|
|
+ rds.DepartmentOrServicePointId,
|
|
|
+ f.BuildingFloorId,
|
|
|
+ FloorName = f.Name,
|
|
|
+ b.BuildingId,
|
|
|
+ BuildingName = b.Name,
|
|
|
+ RoomName = r.Name
|
|
|
+ }
|
|
|
+ ) on ds.DepartmentOrServicePointId equals room.DepartmentOrServicePointId into dbBdDepartmentOrServicePointBmBuildingFloorRoom
|
|
|
+ from rds in dbBdDepartmentOrServicePointBmBuildingFloorRoom.DefaultIfEmpty()
|
|
|
+ group new { rds.RoomName } by new
|
|
|
+ {
|
|
|
+ ds.DepartmentOrServicePointId,
|
|
|
+ ds.Name,
|
|
|
+ ds.OpenTime,
|
|
|
+ ds.ContactType,
|
|
|
+ ds.Description,
|
|
|
+ ds.RecordStatus,
|
|
|
+ ds.CreateUserId,
|
|
|
+ ds.CreateTime,
|
|
|
+ ds.ModifyTime,
|
|
|
+ ds.ModifyUserId,
|
|
|
+ rds.FloorName,
|
|
|
+ rds.BuildingName,
|
|
|
+ rds.BuildingId,
|
|
|
+ rds.BuildingFloorId
|
|
|
+ } into g
|
|
|
+ select new DepOrServicePointView
|
|
|
+ {
|
|
|
+ DepartmentOrServicePointId = g.Key.DepartmentOrServicePointId,
|
|
|
+ Name = g.Key.Name,
|
|
|
+ OpenTime = g.Key.OpenTime,
|
|
|
+ ContactType = g.Key.ContactType,
|
|
|
+ Description = g.Key.Description,
|
|
|
+ RecordStatus = g.Key.RecordStatus,
|
|
|
+ CreateUserId = g.Key.CreateUserId,
|
|
|
+ CreateTime = g.Key.CreateTime,
|
|
|
+ ModifyTime = g.Key.ModifyTime,
|
|
|
+ ModifyUserId = g.Key.ModifyUserId,
|
|
|
+ BuildingName = g.Key.BuildingName,
|
|
|
+ BuildingId = g.Key.BuildingId,
|
|
|
+ FloorName = g.Key.FloorName,
|
|
|
+ FloorId = g.Key.BuildingFloorId,
|
|
|
+ /* RoomName = string.Join("、", g.Select(s => s.RoomName).ToList())*/
|
|
|
+ };
|
|
|
+
|
|
|
+ return query;
|
|
|
+ }
|
|
|
+
|
|
|
+ private IQueryable<DepOrServicePointRoomView> GetDepOrServicePointRoomQuery(Expression<Func<BdDepartmentOrServicePoint, bool>> exp)
|
|
|
+ {
|
|
|
+ var query =
|
|
|
+ from ds in DbContext.BdDepartmentOrServicePoint
|
|
|
+ join rds in DbContext.BdDepartmentOrServicePointBmBuildingFloorRoom on ds.DepartmentOrServicePointId equals rds.DepartmentOrServicePointId
|
|
|
+ join r in DbContext.BdBuildingFloorRoom on rds.BuildingFloorRoomId equals r.BuildingFloorRoomId
|
|
|
+ join f in DbContext.BdBuildingFloor on r.BuildingFloorId equals f.BuildingFloorId
|
|
|
+ join b in DbContext.BdBuilding on f.BuildingId equals b.BuildingId
|
|
|
+ select new DepOrServicePointRoomView
|
|
|
+ {
|
|
|
+ DepartmentOrServicePointId = ds.DepartmentOrServicePointId,
|
|
|
+ FloorId = f.BuildingFloorId,
|
|
|
+ RoomName = r.Name,
|
|
|
+ RoomSort = r.Sort
|
|
|
+ };
|
|
|
|
|
|
return query;
|
|
|
}
|
|
|
|
|
|
- public IGridResultSet<DepOrServicePointView> GetDepOrServicePointList(int pageIndex, int pageSize, Guid? buildingId, Guid? floorId)
|
|
|
+ public IGridResultSet<DepOrServicePointView> GetDepOrServicePointList(int pageIndex, int pageSize, Guid? buildingId, Guid? floorId, string name)
|
|
|
{
|
|
|
Expression<Func<BdDepartmentOrServicePoint, bool>> exp = e => true;
|
|
|
Expression<Func<BdBuilding, bool>> expBuild = e => true;
|
|
|
Expression<Func<BdBuildingFloor, bool>> expFloor = e => true;
|
|
|
|
|
|
+ exp = exp.AndIf(!string.IsNullOrEmpty(name), e => e.Name.Contains(name.Trim()));
|
|
|
+
|
|
|
expFloor = expFloor.AndIf(floorId.HasValue, e => e.BuildingFloorId == floorId);
|
|
|
expBuild = expBuild.AndIf(buildingId.HasValue, e => e.BuildingId == buildingId);
|
|
|
|
|
|
- var query = GetDepOrServicePointQuery(exp, expBuild, expFloor).OrderBy(e => e.BuildingName).ThenBy(e => e.FloorName).ThenBy(e => e.RoomName);
|
|
|
+ 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);
|
|
|
+
|
|
|
+ var dataResult = query.ToGridResultSet(pageIndex, pageSize);
|
|
|
+
|
|
|
+ var depOrServicePointIdList = dataResult.rows.Select(s => s.DepartmentOrServicePointId).ToList();
|
|
|
+ var roomList = GetDepOrServicePointRoomQuery(e => depOrServicePointIdList.Contains(e.DepartmentOrServicePointId)).ToList();
|
|
|
|
|
|
- return query.ToGridResultSet(pageIndex, pageSize);
|
|
|
+ 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());
|
|
|
+ });
|
|
|
+
|
|
|
+ return dataResult;
|
|
|
}
|
|
|
|
|
|
public Task<DepOrServicePointView> GetDepOrServicePointById(Guid? depOrServicePointId)
|
|
|
{
|
|
|
if (depOrServicePointId.HasValue)
|
|
|
{
|
|
|
- return Task.FromResult(GetDepOrServicePointQuery(e => e.DepartmentOrServicePointId == depOrServicePointId, e => true, e => true).FirstOrDefault());
|
|
|
+ return Task.FromResult(GetDepOrServicePointQuery(e => e.DepartmentOrServicePointId == depOrServicePointId).FirstOrDefault());
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -72,6 +164,7 @@ namespace YLShipBuildLandMap.Services.Build
|
|
|
dbData.OpenTime = data.OpenTime;
|
|
|
dbData.ModifyTime = DateTime.Now;
|
|
|
dbData.ModifyUserId = userId;
|
|
|
+ dbData.ContactType = data.ContactType;
|
|
|
DbContext.BdDepartmentOrServicePoint.Update(dbData);
|
|
|
}
|
|
|
else
|
|
@@ -85,7 +178,8 @@ namespace YLShipBuildLandMap.Services.Build
|
|
|
Description = data.Description,
|
|
|
CreateTime = DateTime.Now,
|
|
|
CreateUserId = userId,
|
|
|
- RecordStatus = 1
|
|
|
+ RecordStatus = 1,
|
|
|
+ ContactType = data.ContactType
|
|
|
};
|
|
|
|
|
|
this.DbContext.Add(dbData);
|
|
@@ -93,7 +187,7 @@ namespace YLShipBuildLandMap.Services.Build
|
|
|
|
|
|
await DbContext.BdDepartmentOrServicePointBmBuildingFloorRoom.Where(e => dbData.DepartmentOrServicePointId == e.DepartmentOrServicePointId).DeleteAsync();
|
|
|
|
|
|
- this.DbContext.BdDepartmentOrServicePointBmBuildingFloorRoom.AddRange(roomIdList.Select(s => new BdDepartmentOrServicePointBmBuildingFloorRoom
|
|
|
+ this.DbContext.BdDepartmentOrServicePointBmBuildingFloorRoom.AddRange(roomIdList.Select(s => new BdDepartmentOrServicePointBmBuildingFloorRoom
|
|
|
{
|
|
|
BuildingFloorRoomId = s,
|
|
|
DepartmentOrServicePointId = dbData.DepartmentOrServicePointId
|
|
@@ -110,5 +204,33 @@ namespace YLShipBuildLandMap.Services.Build
|
|
|
return await this.DbContext.SaveChangesAsync();
|
|
|
}
|
|
|
|
|
|
+ public Task<List<RoomView>> GetRoomList(Guid depOrServicePointId)
|
|
|
+ {
|
|
|
+ var query = from b in DbContext.BdBuilding
|
|
|
+ join f in DbContext.BdBuildingFloor on b.BuildingId equals f.BuildingId
|
|
|
+ join r in DbContext.BdBuildingFloorRoom on f.BuildingFloorId equals r.BuildingFloorId
|
|
|
+ join deppoint in DbContext.BdDepartmentOrServicePointBmBuildingFloorRoom on r.BuildingFloorRoomId equals deppoint.BuildingFloorRoomId
|
|
|
+ where deppoint.DepartmentOrServicePointId == depOrServicePointId
|
|
|
+ select new RoomView
|
|
|
+ {
|
|
|
+ BuildingFloorRoomId = r.BuildingFloorRoomId,
|
|
|
+ BuildingFloorId = r.BuildingFloorId,
|
|
|
+ BuildingId = b.BuildingId,
|
|
|
+ Name = r.Name,
|
|
|
+ CreateTime = r.CreateTime,
|
|
|
+ CreateUserId = r.CreateUserId,
|
|
|
+ ModifyTime = r.ModifyTime,
|
|
|
+ ModifyUserId = r.ModifyUserId,
|
|
|
+ RecordStatus = r.RecordStatus,
|
|
|
+ Sort = r.Sort,
|
|
|
+ BuildingName = b.Name,
|
|
|
+ FloorName = f.Name,
|
|
|
+ FloorSort = f.Sort
|
|
|
+ };
|
|
|
+
|
|
|
+ return Task.FromResult(query.OrderBy(e => e.BuildingName).ThenBy(e => e.FloorSort).ThenBy(e => e.Name).ToList());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
}
|