improvements, fixes, etc...
This commit is contained in:
parent
294b1e0970
commit
e1f28f7fe8
|
|
@ -1,8 +1,11 @@
|
|||
using AyCode.Core.Extensions;
|
||||
using AyCode.Utils.Extensions;
|
||||
using FruitBank.Common.Entities;
|
||||
using FruitBank.Common.Interfaces;
|
||||
using LinqToDB.Mapping;
|
||||
using Mango.Nop.Core.Dtos;
|
||||
using Mango.Nop.Core.Interfaces;
|
||||
using Newtonsoft.Json;
|
||||
using Nop.Core;
|
||||
using Nop.Core.Domain.Catalog;
|
||||
using Nop.Core.Domain.Common;
|
||||
|
|
@ -10,13 +13,12 @@ using Nop.Core.Domain.Orders;
|
|||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Globalization;
|
||||
using System.Linq.Expressions;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace FruitBank.Common.Dtos;
|
||||
|
||||
public class OrderDto : MgOrderDto<OrderItemDto, ProductDto>, IOrderDto
|
||||
{
|
||||
[NotColumn]
|
||||
[NotColumn, JsonIgnore, System.Text.Json.Serialization.JsonIgnore]
|
||||
private static Expression<Func<OrderDto, GenericAttribute, bool>> RelationWithGenericAttribute => (orderDto, genericAttribute) =>
|
||||
orderDto.Id == genericAttribute.EntityId && genericAttribute.KeyGroup == nameof(Order);
|
||||
|
||||
|
|
@ -24,6 +26,26 @@ public class OrderDto : MgOrderDto<OrderItemDto, ProductDto>, IOrderDto
|
|||
[Association(ThisKey = nameof(Id), OtherKey = nameof(GenericAttribute.EntityId), ExpressionPredicate = nameof(RelationWithGenericAttribute), CanBeNull = true)]
|
||||
public List<GenericAttribute> GenericAttributes { get; set; }
|
||||
|
||||
[NotColumn, JsonIgnore, System.Text.Json.Serialization.JsonIgnore]
|
||||
public bool IsMeasured => OrderItemDtos.All(oi => oi.IsMeasured);
|
||||
|
||||
[NotColumn, JsonIgnore, System.Text.Json.Serialization.JsonIgnore]
|
||||
public bool IsMeasurable
|
||||
{
|
||||
get => OrderItemDtos.Any(oi => oi.IsMeasurable);
|
||||
set => throw new Exception($"OrderDto.IsMeasurable not set");
|
||||
}
|
||||
|
||||
[NotColumn, JsonIgnore, System.Text.Json.Serialization.JsonIgnore]
|
||||
public DateTime DateOfReceipt
|
||||
{
|
||||
get
|
||||
{
|
||||
var dateOfReceipt = GenericAttributes.SingleOrDefault(x => x.Key == nameof(IOrderDto.DateOfReceipt))?.Value ?? string.Empty;
|
||||
return dateOfReceipt.IsNullOrWhiteSpace() ? CreatedOnUtc : CommonHelper.To<DateTime>(dateOfReceipt);
|
||||
}
|
||||
}
|
||||
|
||||
public OrderDto() :base()
|
||||
{ }
|
||||
public OrderDto(int orderId) : base(orderId)
|
||||
|
|
|
|||
|
|
@ -11,9 +11,9 @@ using Nop.Core.Domain.Orders;
|
|||
|
||||
namespace FruitBank.Common.Dtos;
|
||||
|
||||
public class OrderItemDto : MgOrderItemDto<ProductDto>, IOrderItemDto, IMeasuringNetWeight
|
||||
public class OrderItemDto : MgOrderItemDto<ProductDto>, IOrderItemDto
|
||||
{
|
||||
[NotColumn]
|
||||
[NotColumn, JsonIgnore, System.Text.Json.Serialization.JsonIgnore]
|
||||
private static Expression<Func<OrderItemDto, GenericAttribute, bool>> RelationWithGenericAttribute => (orderItemDto, genericAttribute) =>
|
||||
orderItemDto.Id == genericAttribute.EntityId && genericAttribute.KeyGroup == nameof(OrderItem);
|
||||
|
||||
|
|
@ -24,20 +24,28 @@ public class OrderItemDto : MgOrderItemDto<ProductDto>, IOrderItemDto, IMeasurin
|
|||
[Association(ThisKey = nameof(Id), OtherKey = nameof(OrderItemPallet.OrderItemId), CanBeNull = true)]
|
||||
public List<OrderItemPallet> OrderItemPallets { get; set; }
|
||||
|
||||
[NotColumn]
|
||||
[JsonIgnore]
|
||||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
[NotColumn, JsonIgnore, System.Text.Json.Serialization.JsonIgnore]
|
||||
public double NetWeight
|
||||
{
|
||||
get => CommonHelper.To<double>(GenericAttributes?.FirstOrDefault(x => x.Key == nameof(IMeasuringNetWeight.NetWeight))?.Value ?? "0");
|
||||
get => CommonHelper.To<double>(GenericAttributes.SingleOrDefault(x => x.Key == nameof(IMeasuringNetWeight.NetWeight))?.Value ?? "0");
|
||||
set
|
||||
{
|
||||
//Direkt legyen exception! - J.
|
||||
var ga = GenericAttributes?.FirstOrDefault(x => x.Key == nameof(IMeasuringNetWeight.NetWeight))!;
|
||||
var ga = GenericAttributes?.SingleOrDefault(x => x.Key == nameof(IMeasuringNetWeight.NetWeight))!;
|
||||
ga.Value = value.ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
}
|
||||
|
||||
[NotColumn, JsonIgnore, System.Text.Json.Serialization.JsonIgnore]
|
||||
public bool IsMeasured => OrderItemPallets.All(oip => oip.IsMeasured);
|
||||
|
||||
[NotColumn, JsonIgnore, System.Text.Json.Serialization.JsonIgnore]
|
||||
public bool IsMeasurable
|
||||
{
|
||||
get => ProductDto!.IsMeasurable;
|
||||
set => throw new Exception($"OrderItemDto.IsMeasurable not set");
|
||||
}
|
||||
|
||||
public OrderItemDto() : base()
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,43 @@
|
|||
using FruitBank.Common.Interfaces;
|
||||
using LinqToDB.Mapping;
|
||||
using Mango.Nop.Core.Dtos;
|
||||
using Newtonsoft.Json;
|
||||
using Nop.Core;
|
||||
using Nop.Core.Domain.Catalog;
|
||||
using Nop.Core.Domain.Common;
|
||||
using Nop.Core.Domain.Orders;
|
||||
using System.Globalization;
|
||||
using System.Linq.Expressions;
|
||||
|
||||
namespace FruitBank.Common.Dtos;
|
||||
|
||||
public class ProductDto : MgProductDto, IProductDto
|
||||
{
|
||||
[NotColumn, JsonIgnore, System.Text.Json.Serialization.JsonIgnore]
|
||||
private static Expression<Func<ProductDto, GenericAttribute, bool>> RelationWithGenericAttribute => (orderItemDto, genericAttribute) =>
|
||||
orderItemDto.Id == genericAttribute.EntityId && genericAttribute.KeyGroup == nameof(Product);
|
||||
|
||||
|
||||
[Association(ThisKey = nameof(Id), OtherKey = nameof(GenericAttribute.EntityId), ExpressionPredicate = nameof(RelationWithGenericAttribute), CanBeNull = true)]
|
||||
public List<GenericAttribute> GenericAttributes { get; set; }
|
||||
|
||||
public ProductDto() :base()
|
||||
{ }
|
||||
public ProductDto(int productId) : base(productId)
|
||||
{ }
|
||||
public ProductDto(Product product) : base(product)
|
||||
{ }
|
||||
|
||||
[NotColumn, JsonIgnore, System.Text.Json.Serialization.JsonIgnore]
|
||||
public bool IsMeasurable
|
||||
{
|
||||
get => CommonHelper.To<bool>(GenericAttributes.SingleOrDefault(x => x.Key == nameof(IMeasurable.IsMeasurable))?.Value ?? "false");
|
||||
set
|
||||
{
|
||||
//Direkt legyen exception! - J.
|
||||
var ga = GenericAttributes.SingleOrDefault(x => x.Key == nameof(IMeasurable.IsMeasurable))!;
|
||||
ga.Value = value.ToString();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -14,7 +14,7 @@ public class OrderItemPallet : MeasuringItemPalletBase, IOrderItemPallet
|
|||
set => ForeignItemId = value;
|
||||
}
|
||||
|
||||
[LinqToDB.Mapping.Association(ThisKey = nameof(OrderItemId), OtherKey = nameof(OrderItem.Id), CanBeNull = true)]
|
||||
[Association(ThisKey = nameof(OrderItemId), OtherKey = nameof(OrderItem.Id), CanBeNull = true)]
|
||||
public OrderItem? OrderItem { get; set; }
|
||||
|
||||
public override double CalculateNetWeight() => base.CalculateNetWeight();
|
||||
|
|
|
|||
|
|
@ -31,6 +31,9 @@
|
|||
<Reference Include="AyCode.Services">
|
||||
<HintPath>..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server\bin\FruitBank\Debug\net9.0\AyCode.Services.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="AyCode.Utils">
|
||||
<HintPath>..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server\bin\FruitBank\Debug\net9.0\AyCode.Utils.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Mango.Nop.Core">
|
||||
<HintPath>..\..\NopCommerce.Common\4.70\Libraries\Mango.Nop.Core\bin\FruitBank\Debug\net9.0\Mango.Nop.Core.dll</HintPath>
|
||||
</Reference>
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ namespace FruitBank.Common.Interfaces;
|
|||
public interface ICustomOrderSignalREndpointCommon
|
||||
{
|
||||
Task<List<OrderDto>?> GetAllOrderDtos();
|
||||
Task<OrderDto?> GetOrderDtoById(int orderId);
|
||||
Task<List<OrderDto>?> GetPendingOrderDtos();
|
||||
Task<List<OrderDto>?> GetAllByIds(int[] orderIds);
|
||||
Task<OrderDto?> GetOrderDtoById(int orderId);
|
||||
}
|
||||
|
|
@ -2,5 +2,5 @@
|
|||
|
||||
public interface IMeasured
|
||||
{
|
||||
bool IsMeasured { get; set; }
|
||||
bool IsMeasured { get; }
|
||||
}
|
||||
|
|
@ -4,7 +4,7 @@ using Mango.Nop.Core.Interfaces;
|
|||
|
||||
namespace FruitBank.Common.Interfaces;
|
||||
|
||||
public interface IOrderDto : IMgOrderDto<OrderItemDto, ProductDto>
|
||||
public interface IOrderDto : IMgOrderDto<OrderItemDto, ProductDto>, IMeasured, IMeasurable
|
||||
{
|
||||
|
||||
DateTime DateOfReceipt { get; }
|
||||
}
|
||||
|
|
@ -6,7 +6,7 @@ using Nop.Core.Domain.Catalog;
|
|||
|
||||
namespace FruitBank.Common.Interfaces;
|
||||
|
||||
public interface IOrderItemDto : IMgOrderItemDto<ProductDto>
|
||||
public interface IOrderItemDto : IMgOrderItemDto<ProductDto>, IMeasuringNetWeight, IMeasured, IMeasurable
|
||||
{
|
||||
public List<OrderItemPallet> OrderItemPallets { get; set; }
|
||||
public void InitializeOrderItemPallets(List<OrderItemPallet> orderItemPallets);
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace FruitBank.Common.Interfaces;
|
||||
|
||||
public interface IProductDto : IMgProductDto
|
||||
public interface IProductDto : IMgProductDto, IMeasurable
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -47,6 +47,7 @@ public class SignalRTags : AcSignalRTags
|
|||
|
||||
public const int GetAllOrderDtos = 111;
|
||||
public const int GetOrderDtoById = 112;
|
||||
public const int GetAllByIdList = 114;
|
||||
public const int GetPendingOrderDtos = 115;
|
||||
|
||||
public const int AuthenticateUser = 160;
|
||||
|
|
|
|||
|
|
@ -35,17 +35,6 @@ public sealed class OrderClientTests
|
|||
Assert.IsTrue(orderDtos.All(o => o.OrderItemDtos.All(oi => oi.ProductDto != null && oi.ProductDto.Id == oi.ProductId)));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task GetPendingOrderDtos()
|
||||
{
|
||||
var pendingOrderDtos = await _signalRClient.GetPendingOrderDtos();
|
||||
|
||||
Assert.IsNotNull(pendingOrderDtos);
|
||||
|
||||
Assert.IsTrue(pendingOrderDtos.All(o => o.OrderStatus == OrderStatus.Pending));
|
||||
Assert.IsTrue(pendingOrderDtos.Count != 0);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[DataRow(1)]
|
||||
[DataRow(2)]
|
||||
|
|
@ -59,4 +48,27 @@ public sealed class OrderClientTests
|
|||
Assert.IsTrue(orderDto.OrderStatusId >= 10);
|
||||
Assert.IsTrue(orderDto.CustomOrderNumber == orderId.ToString());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task GetPendingOrderDtos()
|
||||
{
|
||||
var pendingOrderDtos = await _signalRClient.GetPendingOrderDtos();
|
||||
|
||||
Assert.IsNotNull(pendingOrderDtos);
|
||||
|
||||
Assert.IsTrue(pendingOrderDtos.All(o => o.OrderStatus == OrderStatus.Pending));
|
||||
Assert.IsTrue(pendingOrderDtos.Count != 0);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[DataRow(new int[] {1,2,4,7})]
|
||||
public async Task GetOrderDtoById(int[] orderIds)
|
||||
{
|
||||
var orderDtoList = await _signalRClient.GetAllByIds(orderIds);
|
||||
|
||||
Assert.IsNotNull(orderDtoList);
|
||||
|
||||
Assert.IsTrue(orderDtoList.Count == orderIds.Length);
|
||||
Assert.IsTrue(orderDtoList.All(x => orderIds.Contains(x.Id)));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
namespace FruitBankHybrid.Shared.Models;
|
||||
|
||||
public class MeasuringDateSelectorModel
|
||||
{
|
||||
public int ShippingId { get; set; }
|
||||
public DateTime DateTime { get; set; }
|
||||
public bool IsMeasured { get; set; }
|
||||
|
||||
public MeasuringDateSelectorModel(int shippingId, DateTime dateTime, bool isMeasured)
|
||||
{
|
||||
ShippingId = shippingId;
|
||||
DateTime = dateTime;
|
||||
IsMeasured = isMeasured;
|
||||
}
|
||||
}
|
||||
|
|
@ -10,21 +10,21 @@
|
|||
|
||||
<div style="margin-top: 50px;">
|
||||
<DxFormLayout CaptionPosition="CaptionPosition.Vertical" CssClass="w-100">
|
||||
<DxFormLayoutItem Caption="Érkezés dátuma" ColSpanMd="2" CaptionCssClass="@(SelectedShipping != null && _shippingDates.Where(x => DaysEqual(x.DateTime, SelectedShipping.ShippingDate)).All(x => x.IsMeasured) ? "text-success" : "")">
|
||||
<DxFormLayoutItem Caption="Érkezés dátuma" ColSpanMd="2" CaptionCssClass="@(SelectedShipping != null && _measuringDates.Where(x => MeasuringService.DaysEqual(x.DateTime, SelectedShipping.ShippingDate)).All(x => x.IsMeasured) ? "text-success" : "")">
|
||||
<DxDateEdit CssClass="cw-320"
|
||||
DisplayFormat="m"
|
||||
Format="m"
|
||||
Context="ctxShippingDate"
|
||||
Date="@(SelectedShipping?.ShippingDate.Date ?? DateTime.Now.Date)"
|
||||
CustomDisabledDate="@OnCustomDisabledDate"
|
||||
DateChanged="@((DateTime newValue) => OnSelectedShippingDateChanged(newValue))"
|
||||
CustomDisabledDate="@OnCustomDisabledMeasuringDate"
|
||||
DateChanged="@((DateTime newValue) => OnMeasuringDateChanged(newValue))"
|
||||
InputId="deDisabledDates">
|
||||
<DayCellTemplate>
|
||||
@{
|
||||
var cssClass = GetShippingDateCssClassNames(ctxShippingDate);
|
||||
var cssClass = GetMeasuringDateCssClassNames(ctxShippingDate);
|
||||
if (!cssClass.IsNullOrWhiteSpace())
|
||||
{
|
||||
<a class="@GetShippingDateCssClassNames(ctxShippingDate)">@ctxShippingDate.Day.ToString()</a>
|
||||
<a class="@GetMeasuringDateCssClassNames(ctxShippingDate)">@ctxShippingDate.Day.ToString()</a>
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ using FruitBank.Common.Entities;
|
|||
using FruitBank.Common.Helpers;
|
||||
using FruitBank.Common.Interfaces;
|
||||
using FruitBank.Common.Models;
|
||||
using FruitBankHybrid.Shared.Models;
|
||||
using FruitBankHybrid.Shared.Services;
|
||||
using FruitBankHybrid.Shared.Services.Loggers;
|
||||
using FruitBankHybrid.Shared.Services.SignalRs;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
|
@ -13,19 +15,6 @@ using ILogger = Mango.Nop.Core.Loggers.ILogger;
|
|||
|
||||
namespace FruitBankHybrid.Shared.Pages
|
||||
{
|
||||
public class ShippingDateModel
|
||||
{
|
||||
public int ShippingId { get; set; }
|
||||
public DateTime DateTime { get; set; }
|
||||
public bool IsMeasured { get; set; }
|
||||
|
||||
public ShippingDateModel(int shippingId, DateTime dateTime, bool isMeasured)
|
||||
{
|
||||
ShippingId = shippingId;
|
||||
DateTime = dateTime;
|
||||
IsMeasured = isMeasured;
|
||||
}
|
||||
}
|
||||
public partial class MeasuringIn : ComponentBase
|
||||
{
|
||||
[Inject] public required IEnumerable<IAcLogWriterClientBase> LogWriters { get; set; }
|
||||
|
|
@ -40,10 +29,9 @@ namespace FruitBankHybrid.Shared.Pages
|
|||
private ShippingDocument? SelectedShippingDocument { get; set; }
|
||||
private ShippingItem? SelectedShippingItem { get; set; }
|
||||
|
||||
DateTime DateTimeValue { get; set; } = DateTime.Today;
|
||||
protected bool BtnSaveEnabled { get; set; }
|
||||
|
||||
private List<ShippingDateModel> _shippingDates = null!;
|
||||
private List<MeasuringDateSelectorModel> _measuringDates = null!;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
|
|
@ -58,76 +46,25 @@ namespace FruitBankHybrid.Shared.Pages
|
|||
{
|
||||
var shippings = await FruitBankSignalRClient.GetNotMeasuredShippings() ?? [];
|
||||
|
||||
_shippingDates = shippings.Select(shipping => new ShippingDateModel(shipping.Id, shipping.ShippingDate.Date, shipping.IsAllMeasured)).ToList();
|
||||
NotMeasuredShippings = shippings.Where(shipping => DaysEqual(shipping.ShippingDate.Date, dateTime)).ToList();
|
||||
_measuringDates = shippings.Select(shipping => new MeasuringDateSelectorModel(shipping.Id, shipping.ShippingDate.Date, shipping.IsAllMeasured)).ToList();
|
||||
NotMeasuredShippings = shippings.Where(shipping => MeasuringService.DaysEqual(shipping.ShippingDate.Date, dateTime)).ToList();
|
||||
|
||||
SelectedShipping = NotMeasuredShippings.FirstOrDefault();
|
||||
}
|
||||
|
||||
private async Task OnSelectedShippingDateChanged(DateTime selectedDateTime)
|
||||
private async Task OnMeasuringDateChanged(DateTime selectedDateTime)
|
||||
=> await RefreshShippingsFromDb(selectedDateTime);
|
||||
|
||||
|
||||
private void OnCustomDisabledDate(CalendarCustomDisabledDateEventArgs args)
|
||||
=> args.IsDisabled = !_shippingDates.Exists(shippingDateModel => DaysEqual(shippingDateModel.DateTime, args.Date));
|
||||
|
||||
private string GetShippingDateCssClassNames(DateTime date)
|
||||
{
|
||||
if (_shippingDates.Exists(shipping => !shipping.IsMeasured && shipping.DateTime.Date <= DateTime.Now.Date && DaysEqual(shipping.DateTime, date)))
|
||||
return "fw-bold text-danger";
|
||||
private void OnCustomDisabledMeasuringDate(CalendarCustomDisabledDateEventArgs args)
|
||||
=> MeasuringService.OnCustomDisabledDate(args, _measuringDates);
|
||||
|
||||
if (_shippingDates.Exists(shipping => shipping.IsMeasured && DaysEqual(shipping.DateTime, date)))
|
||||
return "fw-bold text-success";
|
||||
private string GetMeasuringDateCssClassNames(DateTime date)
|
||||
=> MeasuringService.GetShippingDateCssClassNames(date, _measuringDates);
|
||||
|
||||
if (_shippingDates.Exists(shipping => !shipping.IsMeasured && DaysEqual(shipping.DateTime, date)))
|
||||
return "fw-bold";
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
private static bool DaysEqual(DateTime date1, DateTime date2)
|
||||
=> (date1.Year == date2.Year && date1.DayOfYear == date2.DayOfYear);
|
||||
|
||||
private string GetShippingPalletsCssClassNames(string fieldName, ShippingItemPallet shippingItemPallet)
|
||||
{
|
||||
//if (shippingItemPallet.NetWeight < 0) return "text-danger";
|
||||
|
||||
switch (fieldName)
|
||||
{
|
||||
case nameof(ShippingItemPallet.TareWeight):
|
||||
return IsShippingitemPalletMeasuredAndValid(shippingItemPallet) ? "text-success" :
|
||||
(shippingItemPallet.TareWeight < 0 || shippingItemPallet.NetWeight < 0 ? "text-danger" : "");
|
||||
break;
|
||||
case nameof(ShippingItemPallet.PalletWeight):
|
||||
return IsShippingitemPalletMeasuredAndValid(shippingItemPallet) ? "text-success" :
|
||||
(shippingItemPallet.PalletWeight < 0 || shippingItemPallet.NetWeight < 0 ? "text-danger" : "");
|
||||
break;
|
||||
case nameof(ShippingItemPallet.Quantity):
|
||||
return IsShippingitemPalletMeasuredAndValid(shippingItemPallet) ? "text-success" :
|
||||
(shippingItemPallet.Quantity < 0 ? "text-danger" : "");
|
||||
break;
|
||||
case nameof(ShippingItemPallet.GrossWeight):
|
||||
return IsShippingitemPalletMeasuredAndValid(shippingItemPallet) ? "text-success" :
|
||||
(shippingItemPallet.GrossWeight < 0 || shippingItemPallet.NetWeight < 0 ? "text-danger" : "");
|
||||
break;
|
||||
case nameof(ShippingItemPallet.NetWeight):
|
||||
return IsShippingitemPalletMeasuredAndValid(shippingItemPallet) ? "text-success" :
|
||||
(shippingItemPallet.NetWeight < 0 ? "text-danger" : "");
|
||||
break;
|
||||
}
|
||||
|
||||
//if (_shippingDates.Exists(shipping => !shipping.IsMeasured && shipping.DateTime.Date <= DateTime.Now.Date && DaysEqual(shipping.DateTime, date)))
|
||||
// return "fw-bold text-danger";
|
||||
|
||||
//if (_shippingDates.Exists(shipping => shipping.IsMeasured && DaysEqual(shipping.DateTime, date)))
|
||||
// return "fw-bold text-success";
|
||||
|
||||
//if (_shippingDates.Exists(shipping => !shipping.IsMeasured && DaysEqual(shipping.DateTime, date)))
|
||||
// return "fw-bold";
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
=> MeasuringService.GetCustomItemPalletsCssClassNames(fieldName, shippingItemPallet, SelectedShippingItem!.IsMeasurable);
|
||||
|
||||
private void OnSelectedShippingChanged(SelectedDataItemChangedEventArgs<Shipping> eventArgs)
|
||||
{
|
||||
SelectedShippingDocument = eventArgs.DataItem?.ShippingDocuments?.FirstOrDefault();
|
||||
|
|
@ -152,7 +89,7 @@ namespace FruitBankHybrid.Shared.Pages
|
|||
SelectedShippingDocument!.IsAllMeasured = SelectedShippingDocument.ShippingItems?.All(si => si.IsMeasured) ?? false;
|
||||
SelectedShipping!.IsAllMeasured = SelectedShipping.ShippingDocuments?.All(sd => sd.IsAllMeasured) ?? false;
|
||||
|
||||
var shippingDate = _shippingDates.FirstOrDefault(shipping => shipping.ShippingId == SelectedShipping.Id);
|
||||
var shippingDate = _measuringDates.FirstOrDefault(shipping => shipping.ShippingId == SelectedShipping.Id);
|
||||
if (shippingDate != null) shippingDate.IsMeasured = SelectedShipping.IsAllMeasured;
|
||||
|
||||
MeasuringValuesHelper.SetShippingItemTotalMeasuringValues(shippingItem);
|
||||
|
|
@ -232,7 +169,7 @@ namespace FruitBankHybrid.Shared.Pages
|
|||
|
||||
|
||||
private bool IsShippingitemPalletMeasuredAndValid(ShippingItemPallet shippingItemPallet)
|
||||
=> shippingItemPallet.IsMeasuredAndValid(SelectedShippingItem!.IsMeasurable);
|
||||
=> MeasuringService.IsCustomItemPalletMeasuredAndValid(shippingItemPallet, SelectedShippingItem!.IsMeasurable);
|
||||
|
||||
private async Task HandleValidSubmit()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,6 +1,136 @@
|
|||
@page "/MeasuringOut"
|
||||
@using AyCode.Utils.Extensions
|
||||
@using FruitBank.Common.Dtos
|
||||
@using FruitBank.Common.Entities
|
||||
@using FruitBankHybrid.Shared.Services
|
||||
<h3>Kimenő mérés</h3>
|
||||
|
||||
|
||||
<div style="margin-top: 50px;">
|
||||
<DxFormLayout CaptionPosition="CaptionPosition.Vertical" CssClass="w-100">
|
||||
<DxFormLayoutItem Caption="Átvétel dátuma" ColSpanMd="2" CaptionCssClass="@(SelectedOrder != null && _measuringDates.Where(x => MeasuringService.DaysEqual(x.DateTime, SelectedOrder.DateOfReceipt)).All(x => x.IsMeasured) ? "text-success" : "")">
|
||||
<DxDateEdit CssClass="cw-320"
|
||||
DisplayFormat="m"
|
||||
Format="m"
|
||||
Context="ctxOrderDate"
|
||||
Date="@(SelectedOrder?.DateOfReceipt.Date ?? DateTime.Now.Date)"
|
||||
CustomDisabledDate="@OnCustomDisabledMeasuringDate"
|
||||
DateChanged="@((DateTime newValue) => OnMeasuringDateChanged(newValue))"
|
||||
InputId="deDisabledDates">
|
||||
<DayCellTemplate>
|
||||
@{
|
||||
var cssClass = GetMeasuringDateCssClassNames(ctxOrderDate);
|
||||
if (!cssClass.IsNullOrWhiteSpace())
|
||||
{
|
||||
<a class="@GetMeasuringDateCssClassNames(ctxOrderDate)">@ctxOrderDate.Day.ToString()</a>
|
||||
}
|
||||
else
|
||||
{
|
||||
<a>@ctxOrderDate.Day.ToString()</a>
|
||||
}
|
||||
}
|
||||
|
||||
</DayCellTemplate>
|
||||
</DxDateEdit>
|
||||
</DxFormLayoutItem>
|
||||
|
||||
<DxFormLayoutItem Caption="Átvétel időpontja:" ColSpanMd="2" CaptionCssClass="@(SelectedOrder?.IsMeasured == true ? "text-success" : "")">
|
||||
<DxComboBox Data="@SelectedDayOrders"
|
||||
@bind-Value="@SelectedOrder"
|
||||
Text="Válasszon időpontot..."
|
||||
ValueFieldName="@nameof(OrderDto.Id)"
|
||||
TextFieldName="@nameof(OrderDto.DateOfReceipt)"
|
||||
CssClass="cw-480"
|
||||
Context="ctxOrder"
|
||||
SelectedDataItemChanged="@((SelectedDataItemChangedEventArgs<OrderDto> args) => OnSelectedOrderChanged(args))"
|
||||
InputId="cbOrders">
|
||||
<ItemDisplayTemplate>
|
||||
<span class="@(ctxOrder.DataItem.IsMeasured ? "text-success" : "")">@ctxOrder.DisplayText</span>
|
||||
</ItemDisplayTemplate>
|
||||
</DxComboBox>
|
||||
</DxFormLayoutItem>
|
||||
|
||||
@*<DxFormLayoutItem Caption="Partner:" ColSpanMd="3" CaptionCssClass="@(SelectedShippingDocument?.IsAllMeasured == true ? "text-success" : "")">
|
||||
<DxComboBox Data="@SelectedShipping?.ShippingDocuments"
|
||||
@bind-Value="@SelectedShippingDocument"
|
||||
Text="Select partner"
|
||||
ValueFieldName="@nameof(ShippingDocument.Id)"
|
||||
TextFieldName="@(nameof(ShippingDocument.Partner) + '.' + nameof(Partner.Name))"
|
||||
CssClass="cw-480"
|
||||
Context="ctxShippingDocument"
|
||||
SelectedDataItemChanged="@((SelectedDataItemChangedEventArgs<ShippingDocument> args) => OnSelectedShippingDocumentChanged(args))"
|
||||
InputId="cbShippingDocument">
|
||||
<ItemDisplayTemplate>
|
||||
<span class="@(ctxShippingDocument.DataItem.IsAllMeasured ? "text-success" : "")">@ctxShippingDocument.DisplayText</span>
|
||||
</ItemDisplayTemplate>
|
||||
</DxComboBox>
|
||||
</DxFormLayoutItem>
|
||||
|
||||
<DxFormLayoutItem Caption="Termék:" ColSpanMd="5" CaptionCssClass="@(SelectedShippingItem?.IsMeasured == true ? "text-success" : "")">
|
||||
<DxComboBox Data="@SelectedShippingDocument?.ShippingItems"
|
||||
@bind-Value="@SelectedShippingItem"
|
||||
Text="Select item"
|
||||
ValueFieldName="@nameof(ShippingItem.Id)"
|
||||
TextFieldName="@(nameof(ShippingItem.Name))"
|
||||
CssClass="cw-480"
|
||||
Context="ctxShippingitem"
|
||||
SelectedDataItemChanged="@((SelectedDataItemChangedEventArgs<ShippingItem> args) => OnSelectedShippingItemChanged(args))"
|
||||
InputId="cbShippingItem">
|
||||
<ItemDisplayTemplate>
|
||||
<span class="@(ctxShippingitem.DataItem.IsMeasured ? "text-success" : "")">@ctxShippingitem.DisplayText)</span>
|
||||
</ItemDisplayTemplate>
|
||||
</DxComboBox>
|
||||
</DxFormLayoutItem> *@
|
||||
</DxFormLayout>
|
||||
|
||||
<div style="margin-top: 50px;">
|
||||
<DxAccordion Data="@SelectedOrder?.OrderItemDtos"
|
||||
ExpandMode="AccordionExpandMode.Single"
|
||||
ExpandCollapseAction="AccordionExpandCollapseAction.HeaderClick"
|
||||
AnimationType="LayoutAnimationType.Slide">
|
||||
<DataMappings>
|
||||
<DxAccordionDataMapping Text="ProductName" Children="OrderItemPallets"></DxAccordionDataMapping>
|
||||
<DxAccordionDataMapping Text="OrderItemId" Level="1"></DxAccordionDataMapping>
|
||||
</DataMappings>
|
||||
<ItemHeaderTextTemplate>
|
||||
@{
|
||||
string text = "empty";
|
||||
if (context.Level == 0)
|
||||
{
|
||||
text = ((OrderItemDto)(context.DataItem)).ProductName + " dfgdfsg";
|
||||
}
|
||||
else if (context.Level == 1)
|
||||
{
|
||||
text = ((OrderItemPallet)(context.DataItem)).OrderItemId.ToString() + " dfgdfsg";
|
||||
}
|
||||
}
|
||||
<span>@text</span>
|
||||
</ItemHeaderTextTemplate>
|
||||
</DxAccordion>
|
||||
|
||||
@* <DxAccordionItem>
|
||||
<ContentTemplate>
|
||||
<div class="py-3 px-3" tabindex="0">
|
||||
aaa
|
||||
@(((OrderItemPallet)context.DataItem).Id.ToString())
|
||||
</div>
|
||||
</ContentTemplate>
|
||||
</DxAccordionItem>
|
||||
*@
|
||||
@* <DxAccordion Data="@Data"
|
||||
ShowFilterPanel="true"
|
||||
RootItemExpandButtonDisplayMode="AccordionExpandButtonDisplayMode.End"
|
||||
SubItemExpandButtonIconCssClass="accordion-icon icon-square-plus"
|
||||
SubItemCollapseButtonIconCssClass="accordion-icon icon-square-minus">
|
||||
<DataMappings>
|
||||
<DxAccordionDataMapping Text="Name"
|
||||
Key="Id"
|
||||
ParentKey="CategoryId"/>
|
||||
</DataMappings>
|
||||
</DxAccordion>
|
||||
*@
|
||||
</div>
|
||||
</div>
|
||||
@code {
|
||||
|
||||
}
|
||||
|
|
@ -1,5 +1,11 @@
|
|||
using AyCode.Core.Loggers;
|
||||
using DevExpress.Blazor;
|
||||
using FruitBank.Common.Dtos;
|
||||
using FruitBank.Common.Entities;
|
||||
using FruitBank.Common.Models;
|
||||
using FruitBankHybrid.Shared.Models;
|
||||
using FruitBankHybrid.Shared.Services;
|
||||
using FruitBankHybrid.Shared.Services.Loggers;
|
||||
using FruitBankHybrid.Shared.Services.SignalRs;
|
||||
using Mango.Nop.Core.Loggers;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
|
@ -18,5 +24,70 @@ namespace FruitBankHybrid.Shared.Pages
|
|||
[Inject] public required LoggedInModel LoggedInModel { get; set; }
|
||||
|
||||
private ILogger _logger = null!;
|
||||
private string _errorText;
|
||||
|
||||
private List<OrderDto> SelectedDayOrders { get; set; } = null!;
|
||||
private OrderDto? SelectedOrder { get; set; }
|
||||
private OrderItemDto? SelectedOrderItem { get; set; }
|
||||
|
||||
private List<MeasuringDateSelectorModel> _measuringDates = null!;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
_logger = new LoggerClient<MeasuringOut>(LogWriters.ToArray());
|
||||
_logger.Info("OnInitializedAsync");
|
||||
|
||||
await RefreshOrdersFromDb(DateTime.Now);
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
|
||||
private async Task RefreshOrdersFromDb(DateTime dateTime)
|
||||
{
|
||||
var orders = await FruitBankSignalRClient.GetPendingOrderDtos() ?? [];
|
||||
|
||||
_measuringDates = orders.Select(order => new MeasuringDateSelectorModel(order.Id, order.DateOfReceipt, order.IsMeasured)).ToList();
|
||||
|
||||
SelectedDayOrders = orders.Where(order => MeasuringService.DaysEqual(order.DateOfReceipt, dateTime)).ToList();
|
||||
SelectedOrder = SelectedDayOrders.FirstOrDefault();
|
||||
|
||||
foreach (var order in SelectedDayOrders)
|
||||
{
|
||||
foreach (var orderItem in order.OrderItemDtos.Where(orderItem => orderItem.OrderItemPallets.Count == 0))
|
||||
{
|
||||
orderItem.OrderItemPallets.Add(new OrderItemPallet
|
||||
{
|
||||
OrderItemId = orderItem.Id,
|
||||
//OrderItem = orderItem,
|
||||
});
|
||||
|
||||
orderItem.OrderItemPallets.Add(new OrderItemPallet
|
||||
{
|
||||
OrderItemId = orderItem.Id,
|
||||
//OrderItem = orderItem,
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task OnMeasuringDateChanged(DateTime selectedDateTime)
|
||||
=> await RefreshOrdersFromDb(selectedDateTime);
|
||||
|
||||
private void OnCustomDisabledMeasuringDate(CalendarCustomDisabledDateEventArgs args)
|
||||
=> MeasuringService.OnCustomDisabledDate(args, _measuringDates);
|
||||
|
||||
private string GetMeasuringDateCssClassNames(DateTime date)
|
||||
=> MeasuringService.GetShippingDateCssClassNames(date, _measuringDates);
|
||||
|
||||
private string GetOrderItemPalletsCssClassNames(string fieldName, OrderItemPallet orderItemPallet)
|
||||
=> MeasuringService.GetCustomItemPalletsCssClassNames(fieldName, orderItemPallet, SelectedOrderItem!.IsMeasurable);
|
||||
|
||||
private bool IsOrderItemPalletMeasuredAndValid(OrderItemPallet orderItemPallet)
|
||||
=> MeasuringService.IsCustomItemPalletMeasuredAndValid(orderItemPallet, SelectedOrderItem!.IsMeasurable);
|
||||
|
||||
private void OnSelectedOrderChanged(SelectedDataItemChangedEventArgs<OrderDto> eventArgs)
|
||||
{
|
||||
//SelectedOrderItem = eventArgs.DataItem?.OrderItemDtos?.FirstOrDefault();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,57 @@
|
|||
using DevExpress.Blazor;
|
||||
using FruitBank.Common.Entities;
|
||||
using FruitBankHybrid.Shared.Models;
|
||||
|
||||
namespace FruitBankHybrid.Shared.Services;
|
||||
|
||||
public class MeasuringService
|
||||
{
|
||||
public static bool DaysEqual(DateTime date1, DateTime date2)
|
||||
=> (date1.Year == date2.Year && date1.DayOfYear == date2.DayOfYear);
|
||||
|
||||
public static void OnCustomDisabledDate(CalendarCustomDisabledDateEventArgs args, List<MeasuringDateSelectorModel> measuringDates)
|
||||
=> args.IsDisabled = !measuringDates.Exists(shippingDateModel => DaysEqual(shippingDateModel.DateTime, args.Date));
|
||||
|
||||
public static string GetShippingDateCssClassNames(DateTime date, List<MeasuringDateSelectorModel> measuringDates)
|
||||
{
|
||||
if (measuringDates.Exists(shipping => !shipping.IsMeasured && shipping.DateTime.Date <= DateTime.Now.Date && DaysEqual(shipping.DateTime, date)))
|
||||
return "fw-bold text-danger";
|
||||
|
||||
if (measuringDates.Exists(shipping => shipping.IsMeasured && DaysEqual(shipping.DateTime, date)))
|
||||
return "fw-bold text-success";
|
||||
|
||||
if (measuringDates.Exists(shipping => !shipping.IsMeasured && DaysEqual(shipping.DateTime, date)))
|
||||
return "fw-bold";
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
public static string GetCustomItemPalletsCssClassNames(string fieldName, MeasuringItemPalletBase shippingItemPallet, bool isMeasurable)
|
||||
{
|
||||
//if (shippingItemPallet.NetWeight < 0) return "text-danger";
|
||||
|
||||
switch (fieldName)
|
||||
{
|
||||
case nameof(ShippingItemPallet.TareWeight):
|
||||
return IsCustomItemPalletMeasuredAndValid(shippingItemPallet, isMeasurable) ? "text-success" : (shippingItemPallet.TareWeight < 0 || shippingItemPallet.NetWeight < 0 ? "text-danger" : "");
|
||||
break;
|
||||
case nameof(ShippingItemPallet.PalletWeight):
|
||||
return IsCustomItemPalletMeasuredAndValid(shippingItemPallet, isMeasurable) ? "text-success" : (shippingItemPallet.PalletWeight < 0 || shippingItemPallet.NetWeight < 0 ? "text-danger" : "");
|
||||
break;
|
||||
case nameof(ShippingItemPallet.Quantity):
|
||||
return IsCustomItemPalletMeasuredAndValid(shippingItemPallet, isMeasurable) ? "text-success" : (shippingItemPallet.Quantity < 0 ? "text-danger" : "");
|
||||
break;
|
||||
case nameof(ShippingItemPallet.GrossWeight):
|
||||
return IsCustomItemPalletMeasuredAndValid(shippingItemPallet, isMeasurable) ? "text-success" : (shippingItemPallet.GrossWeight < 0 || shippingItemPallet.NetWeight < 0 ? "text-danger" : "");
|
||||
break;
|
||||
case nameof(ShippingItemPallet.NetWeight):
|
||||
return IsCustomItemPalletMeasuredAndValid(shippingItemPallet, isMeasurable) ? "text-success" : (shippingItemPallet.NetWeight < 0 ? "text-danger" : "");
|
||||
break;
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
public static bool IsCustomItemPalletMeasuredAndValid(MeasuringItemPalletBase customItemPallet, bool isMeasurable)
|
||||
=> customItemPallet.IsMeasuredAndValid(isMeasurable);
|
||||
}
|
||||
|
|
@ -133,6 +133,10 @@ namespace FruitBankHybrid.Shared.Services.SignalRs
|
|||
|
||||
public Task<List<OrderDto>?> GetPendingOrderDtos()
|
||||
=> GetAllAsync<List<OrderDto>>(SignalRTags.GetPendingOrderDtos);
|
||||
|
||||
public Task<List<OrderDto>?> GetAllByIds(int[] orderIds)
|
||||
=> GetAllAsync<List<OrderDto>>(SignalRTags.GetAllByIdList, [orderIds]);
|
||||
|
||||
#endregion Orders
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue