fix 餐次数据补充
This commit is contained in:
@@ -43,9 +43,9 @@ public class BusinessPlacesController : ControllerBase
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("list")]
|
||||
public async Task<List<BusinessPlaceResponse>> GetOpenedListAsync()
|
||||
public async Task<List<BusinessPlaceListResponse>> GetOpenedListAsync(Guid? placeCode)
|
||||
{
|
||||
return await _businessPlaceService.GetOpenedListAsync();
|
||||
return await _businessPlaceService.GetOpenedListAsync(placeCode);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -100,7 +100,7 @@ public class BusinessPlacesController : ControllerBase
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("devicenos")]
|
||||
public async Task<Pagination<DeviceCodeNameDetail>> GetDevicesByCode([FromQuery]BusinessPlaceGetByCodeRequest request)
|
||||
public async Task<Pagination<DeviceCodeNameDetail>> GetDevicesByCode([FromQuery] BusinessPlaceGetByCodeRequest request)
|
||||
{
|
||||
return await _businessPlaceShiftService.GetDevicesByCode(request);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
using Dlhis.Entity.Canteen.Enums;
|
||||
|
||||
namespace Dlhis.Basic.BusinessPlace.Response;
|
||||
|
||||
public class BusinessPlaceListResponse : BusinessPlaceResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// 餐次
|
||||
/// </summary>
|
||||
public List<ShiftEnumType> ShiftTypes { get; set; }
|
||||
}
|
||||
@@ -50,12 +50,12 @@ public class BusinessPlaceResponse
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 餐次code
|
||||
/// 餐别code
|
||||
/// </summary>
|
||||
public Guid? ShiftCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 餐次名称
|
||||
/// 餐别名称
|
||||
/// </summary>
|
||||
public string ShiftName { get; set; }
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ public interface IBusinessPlaceService : IScopeDependency
|
||||
/// 获取可用的营业点
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<List<BusinessPlaceResponse>> GetOpenedListAsync();
|
||||
Task<List<BusinessPlaceListResponse>> GetOpenedListAsync(Guid? placeCode);
|
||||
|
||||
/// <summary>
|
||||
/// 保存营业点
|
||||
|
||||
@@ -49,12 +49,44 @@ public class BusinessPlaceService : IBusinessPlaceService
|
||||
}
|
||||
|
||||
|
||||
public async Task<List<BusinessPlaceResponse>> GetOpenedListAsync()
|
||||
public async Task<List<BusinessPlaceListResponse>> GetOpenedListAsync(Guid? placeCode)
|
||||
{
|
||||
return await _dbContext.Queryable<BusinessPlaceEntity>()
|
||||
var list = await _dbContext.Queryable<BusinessPlaceEntity>()
|
||||
.LeftJoin<BusinessPlaceShiftRelationshipEntity>((x, ps) => x.Code == ps.PlaceCode)
|
||||
.LeftJoin<BusinessShiftEntity>((x, ps, s) => s.Code == ps.ShiftCode)
|
||||
.Where(x => x.Status == CanteenBusinessPlaceStatusEnumType.Opened)
|
||||
.Select<BusinessPlaceResponse>()
|
||||
.WhereIF(placeCode.HasValue, x => x.Code == placeCode)
|
||||
.Select((x, ps, s) => new BusinessPlaceListResponse
|
||||
{
|
||||
Id = x.Id,
|
||||
Code = x.Code,
|
||||
Status = x.Status,
|
||||
Name = x.Name,
|
||||
Catalog = x.Catalog,
|
||||
CustomCode = x.CustomCode,
|
||||
Source = x.Source,
|
||||
Supplier = x.Supplier,
|
||||
ShiftCode = s.Code,
|
||||
ShiftName = s.Name,
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
var shiftCodes = list.Where(x => x.ShiftCode.HasValue).Select(x => x.ShiftCode.Value).ToList();
|
||||
|
||||
var shiftTypes = await _dbContext.Queryable<BusinessShiftMealRelationshipEntity>()
|
||||
.Where(x => shiftCodes.Contains(x.ShiftCode))
|
||||
.Select(x => new { x.ShiftCode, x.ShiftType })
|
||||
.ToListAsync();
|
||||
|
||||
list.ForEach(item =>
|
||||
{
|
||||
if (item.ShiftCode.HasValue)
|
||||
{
|
||||
item.ShiftTypes = shiftTypes.Where(x => x.ShiftCode == item.ShiftCode.Value).Select(x => x.ShiftType).ToList();
|
||||
}
|
||||
});
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user