434 lines
16 KiB
C#
434 lines
16 KiB
C#
using System.Text.Json.Serialization;
|
|
|
|
namespace NTP.Application.Grains.Registry;
|
|
|
|
// ------------------------------------------------------------------ shared / lookups
|
|
|
|
/// <summary>Who the caller is, as far as the registry rules care (legacy session.stkid / companycodeno / userrolecode).</summary>
|
|
public sealed record RegistryScope(bool CompanyOnly, long? CompanyCodeNo, bool IsGoo);
|
|
|
|
public sealed class RegistryPermissionsDto
|
|
{
|
|
public bool IsBadiyaCompany { get; set; }
|
|
public bool IsCompanyUser { get; set; }
|
|
public long? CompanyCodeNo { get; set; }
|
|
public bool CanAddTruck { get; set; }
|
|
public bool CanAddTrailer { get; set; }
|
|
public bool CanAddDriver { get; set; }
|
|
public bool CanEditTruck { get; set; }
|
|
public bool CanEditTrailer { get; set; }
|
|
public bool CanRevokeTruck { get; set; }
|
|
public bool CanRevokeTrailer { get; set; }
|
|
public bool CanRevokeDriver { get; set; }
|
|
public bool CanAcceptTruck { get; set; }
|
|
public bool CanAcceptTrailer { get; set; }
|
|
public bool CanAcceptDriver { get; set; }
|
|
/// <summary>Action 107: pick / see destinations (truck form, company 327 only).</summary>
|
|
public bool CanManageDestinations { get; set; }
|
|
/// <summary>Roles GTO, GOO, GNAC may export the truck report (legacy report icon).</summary>
|
|
public bool CanExportTruckReport { get; set; }
|
|
public bool CanExportDriverReport { get; set; }
|
|
public bool CanCancelBlacklist { get; set; }
|
|
}
|
|
|
|
public sealed class RegistryOptionDto
|
|
{
|
|
public string Value { get; set; } = string.Empty;
|
|
public string Label { get; set; } = string.Empty;
|
|
}
|
|
|
|
public sealed class TenderCompanyDto
|
|
{
|
|
public long Scac { get; set; }
|
|
public string? Name { get; set; }
|
|
}
|
|
|
|
public sealed class TruckKindDto
|
|
{
|
|
/// <summary>TRUCKKINDS.TRUCKKINDCODE: S (single), T (tractor head), HTR (half trailer), TR (trailer).</summary>
|
|
public string Kind { get; set; } = string.Empty;
|
|
/// <summary>TRUCKKINDS.ID: stored in AXIALS.</summary>
|
|
public long Id { get; set; }
|
|
public string? Name { get; set; }
|
|
}
|
|
|
|
public sealed class RegistryLocationDto
|
|
{
|
|
public long Id { get; set; }
|
|
public string? Name { get; set; }
|
|
}
|
|
|
|
public sealed class RegistryNationalityDto
|
|
{
|
|
public string Code { get; set; } = string.Empty;
|
|
public string? Name { get; set; }
|
|
}
|
|
|
|
public sealed class RegistryDestinationOptionsDto
|
|
{
|
|
/// <summary>gn_type PCKD (legacy "مشول").</summary>
|
|
public IReadOnlyList<RegistryLocationDto> Packed { get; set; } = [];
|
|
/// <summary>gn_type BULK (legacy "سائب").</summary>
|
|
public IReadOnlyList<RegistryLocationDto> Bulk { get; set; } = [];
|
|
/// <summary>gn_type BULK_GALLAB (legacy "سائب - قلابات").</summary>
|
|
public IReadOnlyList<RegistryLocationDto> BulkGallab { get; set; } = [];
|
|
}
|
|
|
|
public sealed class RegistryAttachmentDto
|
|
{
|
|
public string FileName { get; set; } = string.Empty;
|
|
public string OriginalName { get; set; } = string.Empty;
|
|
/// <summary>truck | trailer | driver (route segment of the download endpoint).</summary>
|
|
public string Kind { get; set; } = string.Empty;
|
|
}
|
|
|
|
public sealed record RegistryTempFileDto(string Id, string Name, long Size);
|
|
|
|
public sealed record RegistryDownload(Stream Content, string ContentType, string FileName);
|
|
|
|
/// <summary>Result of a write: <c>message</c> is shown verbatim by the front end (legacy Arabic MSG).</summary>
|
|
public sealed record RegistryResult(string Message, long? Id = null);
|
|
|
|
// ------------------------------------------------------------------ list queries
|
|
|
|
public sealed record TruckListQuery(string? SearchType, string? Tn, string? ChasesNumber, string? StatusCode, string? HeadType, long? Tcscac);
|
|
public sealed record TrailerListQuery(string? Tn, string? ChasesNumber, string? StatusCode, long? Tcscac);
|
|
public sealed record DriverListQuery(string? Nnpn, string? Name, string? StatusCode);
|
|
public sealed record BlacklistQuery(string? EntityId, string? Category, string? StatusCode);
|
|
|
|
public sealed class TruckGridRowDto
|
|
{
|
|
public long Id { get; set; }
|
|
public string Tn { get; set; } = string.Empty;
|
|
/// <summary>TN (truck) or TRN (trailer) - what the row represents.</summary>
|
|
public string EntityType { get; set; } = "TN";
|
|
public string? ChasesNumber { get; set; }
|
|
public DateTime? CreateTimestamp { get; set; }
|
|
public DateTime? RegDate { get; set; }
|
|
public string? CreateUserId { get; set; }
|
|
public string StatusCode { get; set; } = string.Empty;
|
|
public string? StatusCaption { get; set; }
|
|
public string? CompName { get; set; }
|
|
/// <summary>For trailer rows: the connected truck id (NTP_TRAILERS.TN_ID).</summary>
|
|
public long? TnId { get; set; }
|
|
}
|
|
|
|
public sealed class TrailerGridRowDto
|
|
{
|
|
public long Id { get; set; }
|
|
public string Tn { get; set; } = string.Empty;
|
|
public string? ChasesNumber { get; set; }
|
|
public DateTime? CreateTimestamp { get; set; }
|
|
public DateTime? RegDate { get; set; }
|
|
public string? CreateUserId { get; set; }
|
|
public string StatusCode { get; set; } = string.Empty;
|
|
public string? StatusCaption { get; set; }
|
|
public string? CompName { get; set; }
|
|
public string? OwnerName { get; set; }
|
|
public string? OwnerNnpn { get; set; }
|
|
}
|
|
|
|
public sealed class DriverGridRowDto
|
|
{
|
|
public long Id { get; set; }
|
|
public string Nnpn { get; set; } = string.Empty;
|
|
public string? Name { get; set; }
|
|
public string? Dln { get; set; }
|
|
public DateTime? Dled { get; set; }
|
|
public DateTime? CreateTimestamp { get; set; }
|
|
public string? CreateUserId { get; set; }
|
|
public string? CompName { get; set; }
|
|
public string StatusCode { get; set; } = string.Empty;
|
|
public string? StatusCaption { get; set; }
|
|
}
|
|
|
|
public sealed class BlacklistGridRowDto
|
|
{
|
|
public long Id { get; set; }
|
|
public string? Category { get; set; }
|
|
public string? CategoryCaption { get; set; }
|
|
public string? EntityType { get; set; }
|
|
public string? EntityTypeCaption { get; set; }
|
|
/// <summary>Permit number for PERMIT entries, the raw number for driver/truck/trailer entries.</summary>
|
|
public string? EntityNumber { get; set; }
|
|
public DateTime? CreationDate { get; set; }
|
|
public string? CreatedBy { get; set; }
|
|
public DateTime? LastUpdateDate { get; set; }
|
|
public string? LastUpdateUser { get; set; }
|
|
public DateTime? ExpiryDate { get; set; }
|
|
public string StatusCode { get; set; } = string.Empty;
|
|
public string? StatusCaption { get; set; }
|
|
public string? Remarks { get; set; }
|
|
}
|
|
|
|
// ------------------------------------------------------------------ details
|
|
|
|
public sealed class PendingDestinationDto
|
|
{
|
|
public string? User { get; set; }
|
|
public string? Time { get; set; }
|
|
}
|
|
|
|
public sealed class TruckDetailDto
|
|
{
|
|
public long Id { get; set; }
|
|
public string Tn { get; set; } = string.Empty;
|
|
public string? ChasesNumber { get; set; }
|
|
public DateTime? RegDate { get; set; }
|
|
public long? Axials { get; set; }
|
|
/// <summary>S when AXIALS < 7, otherwise T (legacy form radio).</summary>
|
|
public string? AxialsKind { get; set; }
|
|
public string StatusCode { get; set; } = string.Empty;
|
|
public string? StatusCaption { get; set; }
|
|
public string? OwnerName { get; set; }
|
|
public string? OwnerNnpn { get; set; }
|
|
public string? Color { get; set; }
|
|
public string? Model { get; set; }
|
|
public string? ManifactureYear { get; set; }
|
|
public string? PhoneNumber { get; set; }
|
|
public string? HeadType { get; set; }
|
|
public long? Tcscac { get; set; }
|
|
public string? CompName { get; set; }
|
|
public string? LastUpdateUserId { get; set; }
|
|
public DateTime? LastUpdateTimestamp { get; set; }
|
|
public long? TrailerId { get; set; }
|
|
public string? TrailerTn { get; set; }
|
|
/// <summary>Active destination location ids (only for users who may see destinations: action 107 or role GOO).</summary>
|
|
public IReadOnlyList<long>? DestinationIds { get; set; }
|
|
public PendingDestinationDto? PendingDestination { get; set; }
|
|
public IReadOnlyList<RegistryAttachmentDto> Attachments { get; set; } = [];
|
|
}
|
|
|
|
public sealed class TrailerDetailDto
|
|
{
|
|
public long Id { get; set; }
|
|
public string Tn { get; set; } = string.Empty;
|
|
public string? ChasesNumber { get; set; }
|
|
public DateTime? RegDate { get; set; }
|
|
public long? Axials { get; set; }
|
|
/// <summary>TR when AXIALS < 12, otherwise HTR (legacy form radio).</summary>
|
|
public string? AxialsKind { get; set; }
|
|
public string StatusCode { get; set; } = string.Empty;
|
|
public string? StatusCaption { get; set; }
|
|
public string? OwnerName { get; set; }
|
|
public string? OwnerNnpn { get; set; }
|
|
public string? PhoneNumber { get; set; }
|
|
public long? TruckId { get; set; }
|
|
public long? Tcscac { get; set; }
|
|
public string? CompName { get; set; }
|
|
public IReadOnlyList<RegistryAttachmentDto> Attachments { get; set; } = [];
|
|
}
|
|
|
|
public sealed class DriverDetailDto
|
|
{
|
|
public long Id { get; set; }
|
|
public string Nnpn { get; set; } = string.Empty;
|
|
public string? Name { get; set; }
|
|
public string? Dln { get; set; }
|
|
public DateTime? Dled { get; set; }
|
|
public string StatusCode { get; set; } = string.Empty;
|
|
public string? StatusCaption { get; set; }
|
|
public string? Nat { get; set; }
|
|
public string? Cat { get; set; }
|
|
public string? Mobile1 { get; set; }
|
|
public string? Mobile2 { get; set; }
|
|
/// <summary>Owning company (used for the company-user scope check only).</summary>
|
|
[JsonIgnore]
|
|
public long? Tcscac { get; set; }
|
|
public IReadOnlyList<RegistryAttachmentDto> Attachments { get; set; } = [];
|
|
}
|
|
|
|
// ------------------------------------------------------------------ requests
|
|
|
|
/// <summary>Destinations picked on the truck form (location ids per group).</summary>
|
|
public sealed class TruckDestinationsRequest
|
|
{
|
|
public List<long> Packed { get; set; } = [];
|
|
public List<long> Bulk { get; set; } = [];
|
|
public List<long> BulkGallab { get; set; } = [];
|
|
|
|
public IReadOnlyList<long> All() => [.. Packed, .. Bulk, .. BulkGallab];
|
|
}
|
|
|
|
[JsonNumberHandling(JsonNumberHandling.AllowReadingFromString)]
|
|
public sealed class SaveTruckRequest
|
|
{
|
|
public string? Tn { get; set; }
|
|
public string? ChasesNumber { get; set; }
|
|
public long? Axials { get; set; }
|
|
public DateTime? RegDate { get; set; }
|
|
public string? OwnerName { get; set; }
|
|
public string? OwnerNnpn { get; set; }
|
|
public string? Color { get; set; }
|
|
public string? Model { get; set; }
|
|
public string? ManifactureYear { get; set; }
|
|
public string? PhoneNumber { get; set; }
|
|
public string? HeadType { get; set; }
|
|
public long? Tcscac { get; set; }
|
|
/// <summary>Temp ids returned by POST files/temp.</summary>
|
|
public List<string>? AttachmentIds { get; set; }
|
|
/// <summary>Only honoured for users with action 107. On update: null = leave destinations untouched.</summary>
|
|
public TruckDestinationsRequest? Destinations { get; set; }
|
|
}
|
|
|
|
[JsonNumberHandling(JsonNumberHandling.AllowReadingFromString)]
|
|
public sealed class SaveTrailerRequest
|
|
{
|
|
public string? Tn { get; set; }
|
|
public string? ChasesNumber { get; set; }
|
|
public long? Axials { get; set; }
|
|
public DateTime? RegDate { get; set; }
|
|
public string? OwnerName { get; set; }
|
|
public string? OwnerNnpn { get; set; }
|
|
public string? PhoneNumber { get; set; }
|
|
public long? Tcscac { get; set; }
|
|
/// <summary>The truck to connect the trailer to (legacy TNID). Optional.</summary>
|
|
public long? TruckId { get; set; }
|
|
public List<string>? AttachmentIds { get; set; }
|
|
}
|
|
|
|
[JsonNumberHandling(JsonNumberHandling.AllowReadingFromString)]
|
|
public sealed class SaveDriverRequest
|
|
{
|
|
public string? Nnpn { get; set; }
|
|
public string? Name { get; set; }
|
|
public string? Dln { get; set; }
|
|
public DateTime? Dled { get; set; }
|
|
public string? Nat { get; set; }
|
|
public string? Cat { get; set; }
|
|
public string? Mobile1 { get; set; }
|
|
public string? Mobile2 { get; set; }
|
|
public List<string>? AttachmentIds { get; set; }
|
|
}
|
|
|
|
[JsonNumberHandling(JsonNumberHandling.AllowReadingFromString)]
|
|
public sealed class AddBlacklistRequest
|
|
{
|
|
/// <summary>PERMIT (default, the only value the legacy page sends), DRIVERNUMBER, TRUCKNUMBER, TRAILERNUMBER.</summary>
|
|
public string? EntityType { get; set; }
|
|
/// <summary>Permit number (PN), or the permit id when <see cref="IsId"/>; the number for the other entity types.</summary>
|
|
public string? EntityNum { get; set; }
|
|
public bool IsId { get; set; }
|
|
public string? Category { get; set; }
|
|
/// <summary>Number of days (legacy EXPIRYDATE select: 1,2,3,4,5,10,14,30).</summary>
|
|
public int ExpiryDays { get; set; }
|
|
public string? Remarks { get; set; }
|
|
}
|
|
|
|
public sealed class CancelBlacklistRequest
|
|
{
|
|
public string? Remarks { get; set; }
|
|
}
|
|
|
|
public sealed record BlacklistAddedDto(string Message, long BlacklistId, DateTime ExpiryDate);
|
|
|
|
[JsonNumberHandling(JsonNumberHandling.AllowReadingFromString)]
|
|
public sealed class SaveWeighbridgeControlRequest
|
|
{
|
|
public string? Tn { get; set; }
|
|
public long? LocationId { get; set; }
|
|
public string? Notes { get; set; }
|
|
public DateTime? ExpiryDate { get; set; }
|
|
}
|
|
|
|
public sealed class SaveGrainsWeightsRequest
|
|
{
|
|
public string? Pn { get; set; }
|
|
public string? EmptyWeight { get; set; }
|
|
public string? GrossWeight { get; set; }
|
|
public string? DocumentNumber { get; set; }
|
|
}
|
|
|
|
[JsonNumberHandling(JsonNumberHandling.AllowReadingFromString)]
|
|
public sealed class FleetCheckRequest
|
|
{
|
|
public long Tn { get; set; }
|
|
public long Scac { get; set; }
|
|
}
|
|
|
|
public sealed record FleetCheckResult(bool Allowed, string? Message, int TotalFleet, int Turn);
|
|
|
|
// ------------------------------------------------------------------ permit-screen lookups (grains.cfc)
|
|
|
|
public sealed class LocationTruckCountDto
|
|
{
|
|
public string? Loc { get; set; }
|
|
public long Cnt { get; set; }
|
|
}
|
|
|
|
public sealed class DriverFromPermitDto
|
|
{
|
|
public string? Drvr { get; set; }
|
|
public string? Cat { get; set; }
|
|
public DateTime? Dled { get; set; }
|
|
public string? Dln { get; set; }
|
|
public string? Nat { get; set; }
|
|
}
|
|
|
|
public sealed class TruckFromPermitDto
|
|
{
|
|
public string? Tn { get; set; }
|
|
public string? Trn { get; set; }
|
|
public string? Trnat { get; set; }
|
|
public string? Tt { get; set; }
|
|
public string? Drvr { get; set; }
|
|
public string? Cat { get; set; }
|
|
public string? Dln { get; set; }
|
|
public DateTime? Dled { get; set; }
|
|
public string? Nat { get; set; }
|
|
public string? Nnpn { get; set; }
|
|
public long? RoutingTemplateId { get; set; }
|
|
public long? OriginAddressId { get; set; }
|
|
public long? DestinationAddressId { get; set; }
|
|
public string? Firms { get; set; }
|
|
public string? Asrn { get; set; }
|
|
public string? Can { get; set; }
|
|
public string? CanName { get; set; }
|
|
}
|
|
|
|
public sealed class TrailerInUseDto
|
|
{
|
|
public string? Pn { get; set; }
|
|
public string? CreationDate { get; set; }
|
|
}
|
|
|
|
public sealed class PermitByTruckDto
|
|
{
|
|
public long Id { get; set; }
|
|
public string? Drvr { get; set; }
|
|
public string? Tn { get; set; }
|
|
public string? Pn { get; set; }
|
|
public string? ShipmentStatusCode { get; set; }
|
|
}
|
|
|
|
public sealed class TruckInfoForPermitDto
|
|
{
|
|
public string? Message { get; set; }
|
|
public bool CloseModal { get; set; }
|
|
public string? Tn { get; set; }
|
|
public string? ChasesNumber { get; set; }
|
|
public string? Axials { get; set; }
|
|
public DateTime? RegDate { get; set; }
|
|
}
|
|
|
|
public sealed class TrailerInfoForPermitDto
|
|
{
|
|
public string? Message { get; set; }
|
|
public string? ChasesNumber { get; set; }
|
|
public string? Axials { get; set; }
|
|
public DateTime? RegDate { get; set; }
|
|
}
|
|
|
|
public sealed class DriverInfoForPermitDto
|
|
{
|
|
public string? Name { get; set; }
|
|
public string? Dln { get; set; }
|
|
public DateTime? Dled { get; set; }
|
|
}
|
|
|
|
public sealed class TrailerOfTruckDto
|
|
{
|
|
public long TrailerId { get; set; }
|
|
public string? TrailerNumber { get; set; }
|
|
}
|