fix 餐次数据补充
This commit is contained in:
@@ -43,9 +43,9 @@ public class BusinessPlacesController : ControllerBase
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet("list")]
|
[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>
|
/// <summary>
|
||||||
@@ -100,7 +100,7 @@ public class BusinessPlacesController : ControllerBase
|
|||||||
/// <param name="request"></param>
|
/// <param name="request"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet("devicenos")]
|
[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);
|
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>
|
/// <summary>
|
||||||
/// 餐次code
|
/// 餐别code
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Guid? ShiftCode { get; set; }
|
public Guid? ShiftCode { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 餐次名称
|
/// 餐别名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string ShiftName { get; set; }
|
public string ShiftName { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ public interface IBusinessPlaceService : IScopeDependency
|
|||||||
/// 获取可用的营业点
|
/// 获取可用的营业点
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<List<BusinessPlaceResponse>> GetOpenedListAsync();
|
Task<List<BusinessPlaceListResponse>> GetOpenedListAsync(Guid? placeCode);
|
||||||
|
|
||||||
/// <summary>
|
/// <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>()
|
||||||
.Where(x => x.Status == CanteenBusinessPlaceStatusEnumType.Opened)
|
.LeftJoin<BusinessPlaceShiftRelationshipEntity>((x, ps) => x.Code == ps.PlaceCode)
|
||||||
.Select<BusinessPlaceResponse>()
|
.LeftJoin<BusinessShiftEntity>((x, ps, s) => s.Code == ps.ShiftCode)
|
||||||
|
.Where(x => x.Status == CanteenBusinessPlaceStatusEnumType.Opened)
|
||||||
|
.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();
|
.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