You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
1.6 KiB
C#
67 lines
1.6 KiB
C#
using DS.Module.Core.Extensions;
|
|
using FluentValidation;
|
|
|
|
namespace DS.WMS.Core.OpenApiModule.Dtos;
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public class TruckRecordInput
|
|
{
|
|
/// <summary>
|
|
/// 车牌号
|
|
/// </summary>
|
|
public string TRUCKNO { get; set; }
|
|
|
|
/// <summary>
|
|
/// 关联ID
|
|
/// </summary>
|
|
public Guid WMSPLANID { get; set; }
|
|
|
|
/// <summary>
|
|
/// 记录时间
|
|
/// </summary>
|
|
public DateTime RecordTime { get; set; } = DateTime.Now;
|
|
|
|
/// <summary>
|
|
/// 磅重
|
|
/// </summary>
|
|
public decimal Weigth { get; set; } = 0;
|
|
|
|
/// <summary>
|
|
/// 实际净重
|
|
/// </summary>
|
|
public decimal? NetWeigth { get; set; } = 0;
|
|
/// <summary>
|
|
/// 0 进 1 出
|
|
/// </summary>
|
|
public int RecordType { get; set; }= 0;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 验证
|
|
/// </summary>
|
|
public class TruckRecordInputValidator : AbstractValidator<TruckRecordInput>
|
|
{
|
|
/// <summary>
|
|
/// 构造函数
|
|
/// </summary>
|
|
public TruckRecordInputValidator()
|
|
{
|
|
|
|
this.RuleFor(o => o.TRUCKNO)
|
|
.NotEmpty().WithName("车牌号");
|
|
this.RuleFor(o => o.WMSPLANID)
|
|
.NotEmpty().WithName("关联ID");
|
|
this.RuleFor(o => o.RecordType)
|
|
// .NotEmpty().WithName("进出类型")
|
|
.InclusiveBetween(0, 1).WithMessage("进出类型输入错误");
|
|
this.RuleFor(o => o.Weigth)
|
|
.GreaterThan(0).WithMessage("磅重必须大于0")
|
|
.Custom((weight, context) => {
|
|
if (weight.ToDecimal()<0)
|
|
{
|
|
context.AddFailure("磅重必须为正数!");
|
|
}
|
|
});
|
|
}
|
|
} |