128 lines
6.7 KiB
C#
128 lines
6.7 KiB
C#
using NTP.Application.Common;
|
|
|
|
namespace NTP.Application.Grains.Permits;
|
|
|
|
/// <summary>Criteria after the service has applied the caller's company restriction.</summary>
|
|
public sealed record PermitSearchCriteria(
|
|
string? Tn, string? Pn, string? Status, long? DestAddressId, DateTime? TenderOrderDate, string? ShipmentMode,
|
|
DateTime? CreationDate, long? CompanyCode);
|
|
|
|
public sealed class TruckRegistrationRow
|
|
{
|
|
public long? TcsCac { get; set; }
|
|
public string? HeadType { get; set; }
|
|
public string? StatusCode { get; set; }
|
|
}
|
|
|
|
public sealed class OwnershipRow
|
|
{
|
|
public string? OwnershipCode { get; set; }
|
|
public string? TruckTypeCode { get; set; }
|
|
}
|
|
|
|
public sealed class ActiveConflictRow
|
|
{
|
|
public long Id { get; set; }
|
|
public string? Pn { get; set; }
|
|
}
|
|
|
|
public sealed class PermitOrderRow
|
|
{
|
|
public long Id { get; set; }
|
|
public long? Scrn { get; set; }
|
|
public string? Ct { get; set; }
|
|
}
|
|
|
|
public sealed class OrderForPermitRow
|
|
{
|
|
public long Id { get; set; }
|
|
public DateTime? OrderDate { get; set; }
|
|
public long? Shift { get; set; }
|
|
public string? Ct { get; set; }
|
|
public string? Type { get; set; }
|
|
public long? Destination { get; set; }
|
|
public long? CargoType { get; set; }
|
|
public long? Location { get; set; }
|
|
}
|
|
|
|
public sealed class DistributionLogRow
|
|
{
|
|
public long Id { get; set; }
|
|
public DateTime? OrderDate { get; set; }
|
|
public long? PermitId { get; set; }
|
|
public long? CargoType { get; set; }
|
|
public string? Tn { get; set; }
|
|
}
|
|
|
|
public sealed class NewBlacklistEntry
|
|
{
|
|
public string Category { get; set; } = "PHONEDECLINE";
|
|
public string EntityType { get; set; } = "PERMIT";
|
|
public long EntityId { get; set; }
|
|
public string CreatedBy { get; set; } = string.Empty;
|
|
public DateTime ExpiryDate { get; set; }
|
|
public string Remarks { get; set; } = string.Empty;
|
|
}
|
|
|
|
/// <summary>Permits: lists, details, order lifecycle (grains.cfc getGNPermits ... submitOrder, Accept, revoke ...).</summary>
|
|
public interface IPermitRepository
|
|
{
|
|
// ---- lists / detail
|
|
Task<PagedResult<PermitListItem>> SearchAsync(PermitSearchCriteria c, PageRequest page, CancellationToken ct = default);
|
|
Task<PagedResult<GatePermitItem>> SearchGateListAsync(GatePermitQuery q, string domain, long? companyCode, bool restrictToCompany,
|
|
PageRequest page, CancellationToken ct = default);
|
|
Task<PermitRow?> GetAsync(long id, CancellationToken ct = default);
|
|
Task<PermitRow?> GetByPnAsync(string pn, CancellationToken ct = default);
|
|
Task<PermitInfoRow?> GetInfoAsync(long id, CancellationToken ct = default);
|
|
Task<IReadOnlyList<PermitEventDto>> GetEventsAsync(long permitId, CancellationToken ct = default);
|
|
|
|
// ---- truck / trailer / driver lookups (domain GN)
|
|
Task<TruckInfoRow?> GetTruckInfoAsync(string tn, long? companyCode, CancellationToken ct = default);
|
|
Task<TruckInfoRow?> GetTrailerInfoAsync(string trn, long? companyCode, CancellationToken ct = default);
|
|
Task<long?> GetTrailerScacAsync(string trn, CancellationToken ct = default);
|
|
Task<DriverInfoRow?> GetDriverInfoAsync(string nnpn, CancellationToken ct = default);
|
|
Task<TruckRegistrationRow?> GetTruckRegistrationAsync(string tn, CancellationToken ct = default);
|
|
Task<bool> DriverIsRegisteredAsync(string nnpn, CancellationToken ct = default);
|
|
Task<string?> GetTruckStatusAsync(long scac, string tn, CancellationToken ct = default);
|
|
Task<string?> GetTrailerStatusAsync(string trn, CancellationToken ct = default);
|
|
Task<string?> GetDriverStatusAsync(string nnpn, CancellationToken ct = default);
|
|
Task<IReadOnlyList<OwnershipRow>> GetMotTruckAsync(long scac, string tn, CancellationToken ct = default);
|
|
Task<ActiveConflictRow?> FindActiveConflictAsync(string column, string value, long excludePermitId, CancellationToken ct = default);
|
|
Task<PermitOrderRow?> GetPermitOrderAsync(long permitId, CancellationToken ct = default);
|
|
|
|
// ---- order lifecycle writes
|
|
Task SubmitAsync(long id, SubmitOrderRequest r, DateTime? dled, string userId, CancellationToken ct = default);
|
|
Task UpdateOrderAsync(long id, UpdateOrderRequest r, DateTime? dled, string userId, CancellationToken ct = default);
|
|
Task SetStatusAsync(long id, string newStatus, string userId, CancellationToken ct = default);
|
|
Task ResetTruckValidationAsync(string tn, string userId, CancellationToken ct = default);
|
|
Task ResetToOpenAsync(long id, string userId, CancellationToken ct = default);
|
|
Task RevokeNextOpenPermitsAsync(long permitId, string userId, CancellationToken ct = default);
|
|
Task<ActiveConflictRow?> FindOpenConflictForReactivationAsync(PermitRow permit, CancellationToken ct = default);
|
|
Task<PermitRow?> FindClosablePermitAsync(string pn, CancellationToken ct = default);
|
|
|
|
// ---- stored weights
|
|
Task<StoredWeightsDto?> GetStoredWeightsAsync(string pn, long badiyaScac, CancellationToken ct = default);
|
|
Task<long?> GetStoredWeightsIdAsync(long permitId, CancellationToken ct = default);
|
|
Task UpsertStoredWeightsAsync(long permitId, long? existingId, SaveWeightsRequest r, string userId, CancellationToken ct = default);
|
|
Task LogActivationAsync(string type, string userId, string roleCode, string json, CancellationToken ct = default);
|
|
}
|
|
|
|
/// <summary>Phone confirmation / rejection data access (addPhoneAcceptEvent / addPhoneRejectEvent / BL_addToBlacklist).</summary>
|
|
public interface IPhoneEventRepository
|
|
{
|
|
Task<bool> HasClosedDistributionAsync(long permitId, long orderId, CancellationToken ct = default);
|
|
Task CloseDistributionAsync(long permitId, long orderId, string notes, CancellationToken ct = default);
|
|
Task<string?> GetTruckPhoneAsync(string tn, CancellationToken ct = default);
|
|
Task<long> InsertBlacklistAsync(NewBlacklistEntry entry, string lastUpdateUser, CancellationToken ct = default);
|
|
Task DecrementQueueCounterAsync(long queueId, CancellationToken ct = default);
|
|
Task<(string? Code, string? Type)> GetQueueInfoAsync(long queueId, CancellationToken ct = default);
|
|
Task DecrementCompanyBulkQueueAsync(long scac, CancellationToken ct = default);
|
|
Task<double> GetOrderDateDiffDaysAsync(long orderId, CancellationToken ct = default);
|
|
Task<DistributionLogRow?> GetClosedDistributionAsync(long permitId, long orderId, CancellationToken ct = default);
|
|
Task PostponeApprovedDistributionAsync(DistributionLogRow current, long permitId, long orderId, long blacklistId, string note,
|
|
CancellationToken ct = default);
|
|
Task MarkDistributionRevokedAsync(long id, long blacklistId, string note, CancellationToken ct = default);
|
|
Task MarkPendingDistributionAsync(long permitId, long blacklistId, string note, bool revoke, CancellationToken ct = default);
|
|
Task<bool> HasPhoneEventTodayAsync(long permitId, CancellationToken ct = default);
|
|
}
|