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