fix 数据问题
This commit is contained in:
@@ -29,29 +29,26 @@ public class BusinessPlaceShiftService : IBusinessPlaceShiftService
|
||||
public async Task<Pagination<BusinessPlaceShiftResponse>> GetPageAsync(BusinessPlaceShiftPageRequest request)
|
||||
{
|
||||
var page = await _dbContext.Queryable<BusinessShiftEntity>()
|
||||
.WhereIF(request.Search.IsPresent(), (shift) => shift.CustomCode.Contains(request.Search) || shift.Name.Contains(request.Search))
|
||||
.Select<BusinessPlaceShiftResponse>()
|
||||
.ToPageListAsync(request);
|
||||
.WhereIF(request.Search.IsPresent(), (shift) => shift.CustomCode.Contains(request.Search) || shift.Name.Contains(request.Search))
|
||||
.Select<BusinessPlaceShiftResponse>()
|
||||
.ToPageListAsync(request);
|
||||
|
||||
var shiftCodes = page.Data.Select(x => x.Code).ToList();
|
||||
|
||||
//下级就餐时间段
|
||||
var mealShifts = await _dbContext.Queryable<BusinessShiftMealRelationshipEntity>()
|
||||
.Where(x => shiftCodes.Contains(x.ShiftCode))
|
||||
.Select((x) => new MealShiftResponse
|
||||
{
|
||||
Id = x.Id,
|
||||
ShiftCode = x.ShiftCode,
|
||||
ShiftType = x.ShiftType,
|
||||
Start = x.Start,
|
||||
End = x.End,
|
||||
})
|
||||
.ToListAsync();
|
||||
.Where(x => shiftCodes.Contains(x.ShiftCode))
|
||||
.Select((x) => new MealShiftResponse
|
||||
{
|
||||
Id = x.Id,
|
||||
ShiftCode = x.ShiftCode,
|
||||
ShiftType = x.ShiftType,
|
||||
Start = x.Start,
|
||||
End = x.End,
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
page.Data.ForEach(x =>
|
||||
{
|
||||
x.MealShifts = mealShifts.Where(item => item.ShiftCode == x.Code).ToList();
|
||||
});
|
||||
page.Data.ForEach(x => { x.MealShifts = mealShifts.Where(item => item.ShiftCode == x.Code).ToList(); });
|
||||
|
||||
return page;
|
||||
}
|
||||
@@ -161,21 +158,17 @@ public class BusinessPlaceShiftService : IBusinessPlaceShiftService
|
||||
|
||||
foreach (BusinessShiftMealRelationshipEntity shiftinfo in shifts)
|
||||
{
|
||||
var name = _dbContext.Queryable<BasicTypeEntity>()
|
||||
.Where(x => x.Code == shiftinfo.ShiftType.ToString())
|
||||
.Select(x => x.Display)
|
||||
.First();
|
||||
|
||||
var shift = new BusinessPlaceShiftTinyResponse
|
||||
{
|
||||
CustomCode = shiftinfo.Id.ToString(),
|
||||
Name = name,
|
||||
Name = shiftinfo.ShiftType.GetDescription(),
|
||||
Start = shiftinfo.Start,
|
||||
End = shiftinfo.End
|
||||
};
|
||||
|
||||
list.Add(shift);
|
||||
}
|
||||
|
||||
return new BusinessPlaceWithShiftResponse
|
||||
{
|
||||
CustomCode = placeCustomCode,
|
||||
@@ -212,6 +205,7 @@ public class BusinessPlaceShiftService : IBusinessPlaceShiftService
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//分页
|
||||
var startIndex = (request.PageIndex - 1) * request.PageSize;
|
||||
var pagedData = list.Skip(startIndex).Take(request.PageSize).ToList();
|
||||
@@ -255,14 +249,14 @@ public class BusinessPlaceShiftService : IBusinessPlaceShiftService
|
||||
private async Task DuplicateTimePeriodAsync(BusinessPlaceShiftSaveMealShiftRequest request)
|
||||
{
|
||||
var periods = await _dbContext.Queryable<BusinessShiftMealRelationshipEntity>()
|
||||
.Where(x => x.ShiftCode == request.ShiftCode)
|
||||
.WhereIF(request.Id.HasValue, x => x.Id != request.Id)
|
||||
.Select(x => new TimePeriod
|
||||
{
|
||||
Start = x.Start,
|
||||
End = x.End,
|
||||
})
|
||||
.ToListAsync();
|
||||
.Where(x => x.ShiftCode == request.ShiftCode)
|
||||
.WhereIF(request.Id.HasValue, x => x.Id != request.Id)
|
||||
.Select(x => new TimePeriod
|
||||
{
|
||||
Start = x.Start,
|
||||
End = x.End,
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
foreach (var period in periods)
|
||||
{
|
||||
@@ -279,9 +273,9 @@ public class BusinessPlaceShiftService : IBusinessPlaceShiftService
|
||||
private async Task CheckExistsAsync(BusinessPlaceShiftSaveRequest request)
|
||||
{
|
||||
var existsSameCustomCode = await _dbContext.Queryable<BusinessShiftEntity>()
|
||||
.Where(x => x.CustomCode == request.CustomCode || x.Name == request.Name)
|
||||
.WhereIF(request.Id.HasValue, x => x.Id != request.Id)
|
||||
.AnyAsync();
|
||||
.Where(x => x.CustomCode == request.CustomCode || x.Name == request.Name)
|
||||
.WhereIF(request.Id.HasValue, x => x.Id != request.Id)
|
||||
.AnyAsync();
|
||||
|
||||
existsSameCustomCode.ThrowIfTrue($"自定义手工号或者名称存在重复,请检查.");
|
||||
}
|
||||
@@ -297,11 +291,11 @@ public class BusinessPlaceShiftService : IBusinessPlaceShiftService
|
||||
private async Task CheckExistsMealShiftAsync(BusinessPlaceShiftSaveMealShiftRequest request)
|
||||
{
|
||||
var exists = await _dbContext.Queryable<BusinessShiftMealRelationshipEntity>()
|
||||
.Where(x => x.ShiftCode == request.ShiftCode)
|
||||
.Where(x => x.ShiftType == request.ShiftType)
|
||||
.WhereIF(request.Id.HasValue, x => x.Id != request.Id)
|
||||
.AnyAsync();
|
||||
.Where(x => x.ShiftCode == request.ShiftCode)
|
||||
.Where(x => x.ShiftType == request.ShiftType)
|
||||
.WhereIF(request.Id.HasValue, x => x.Id != request.Id)
|
||||
.AnyAsync();
|
||||
|
||||
exists.ThrowIfTrue("重复设置!");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user