* Additional Functions added to services

* Changes in MaterialTransaction mapping
This commit is contained in:
2025-04-02 21:25:13 +02:00
parent 3f0da4ba79
commit 94c4586c35
9 changed files with 86 additions and 58 deletions

View File

@@ -10,5 +10,8 @@ namespace FaKrosnoEfDataModel.Services
public interface IScheduleOrderDetailsService public interface IScheduleOrderDetailsService
{ {
Task<IEnumerable<ScheduleOrderDetailDto>?> GetScheduleOrderDetailsAsync(int scheduleOrderId); Task<IEnumerable<ScheduleOrderDetailDto>?> GetScheduleOrderDetailsAsync(int scheduleOrderId);
Task<IEnumerable<ScheduleOrderDetailMiscDto>?> GetScheduleOrderDetailMiscsAsync(
IList<int> scheduleOrderDetailIds, string miscName);
} }
} }

View File

@@ -12,6 +12,7 @@ namespace FaKrosnoEfDataModel.Services
Task<IEnumerable<ScheduleOrderDto?>> GetEntities(); Task<IEnumerable<ScheduleOrderDto?>> GetEntities();
Task<ScheduleOrderDto?> GetById(int id); Task<ScheduleOrderDto?> GetById(int id);
Task<IEnumerable<ScheduleOrderDto?>> GetByRecipientId(int recipientId); Task<IEnumerable<ScheduleOrderDto?>> GetByRecipientId(int recipientId);
Task<IList<ScheduleOrderDto>> GetByPurchaserId(int purchaserId);
Task<IEnumerable<ScheduleOrderDto?>> GetEntitiesByLastUpdateDate(DateTime date); Task<IEnumerable<ScheduleOrderDto?>> GetEntitiesByLastUpdateDate(DateTime date);
Task<IEnumerable<ScheduleOrderDto?>> GetByRecipientAndLastUpdateDate(int recipientId, DateTime date); Task<IEnumerable<ScheduleOrderDto?>> GetByRecipientAndLastUpdateDate(int recipientId, DateTime date);
} }

View File

@@ -21,5 +21,11 @@ namespace FaKrosnoEfDataModel.Services
return await Context.ScheduleOrderDetails.Where(x => x.ScheduleOrderID == scheduleOrderId) return await Context.ScheduleOrderDetails.Where(x => x.ScheduleOrderID == scheduleOrderId)
.ProjectTo<ScheduleOrderDetailDto>(Mapper.ConfigurationProvider).ToListAsync(); .ProjectTo<ScheduleOrderDetailDto>(Mapper.ConfigurationProvider).ToListAsync();
} }
public async Task<IEnumerable<ScheduleOrderDetailMiscDto>?> GetScheduleOrderDetailMiscsAsync(IList<int> scheduleOrderDetailIds, string miscName)
{
return await Context.ScheduleOrderDetailMiscs.Where(x => x.ID == scheduleOrderDetailIds.First())
.ProjectTo<ScheduleOrderDetailMiscDto>(Mapper.ConfigurationProvider).ToListAsync();
}
} }
} }

View File

@@ -26,6 +26,15 @@ namespace FaKrosnoEfDataModel.Services
return scheduleOrders.Where(x => x?.RecipientID == recipientId); return scheduleOrders.Where(x => x?.RecipientID == recipientId);
} }
public async Task<IList<ScheduleOrderDto>> GetByPurchaserId(int purchaserId)
{
return await Context.ScheduleOrders.Include(x => x.Recipient).ThenInclude(x => x.Purchaser)
.Include(x => x.ScheduleOrderDetails).ThenInclude(x => x.ScheduleOrderDetailMiscs)
.Include(x => x.ScheduleOrderDetails).ThenInclude(x => x.ScheduleOrderDetailDetails)
.Where(x => x.Recipient.Purchaser.ID == purchaserId).Select(x => Mapper.Map<ScheduleOrderDto>(x))
.ToListAsync();
}
public async Task<IEnumerable<ScheduleOrderDto?>> GetByRecipientAndLastUpdateDate(int recipientId, DateTime date) public async Task<IEnumerable<ScheduleOrderDto?>> GetByRecipientAndLastUpdateDate(int recipientId, DateTime date)
{ {
IList<ScheduleOrderDto?> scheduleOrders = (await GetEntitiesByLastUpdateDate(date)).ToList(); IList<ScheduleOrderDto?> scheduleOrders = (await GetEntitiesByLastUpdateDate(date)).ToList();

View File

@@ -2,40 +2,40 @@ namespace SytelineSaAppEfDataModel.Dtos;
public class MaterialTransactionDto public class MaterialTransactionDto
{ {
public string MTGroup { get; set; } public string? MTGroup { get; set; }
public string MTGroupNum { get; set; } public string? MTGroupNum { get; set; }
public long TransNum { get; set; } public decimal? TransNum { get; set; }
public string Item { get; set; } public string? Item { get; set; }
public DateTime? TransDate { get; set; } public DateTime? TransDate { get; set; }
public decimal? Qty { get; set; } public decimal? Qty { get; set; }
public decimal? Cost { get; set; } public decimal? Cost { get; set; }
public string Whse { get; set; } public string? Whse { get; set; }
public string Loc { get; set; } public string? Loc { get; set; }
public string RefNum { get; set; } public string? RefNum { get; set; }
public short? RefLineSuf { get; set; } public short? RefLineSuf { get; set; }
public short? RefRelease { get; set; } public short? RefRelease { get; set; }
public string ReasonCode { get; set; } public string? ReasonCode { get; set; }
public string TransType { get; set; } public string? TransType { get; set; }
public string RefType { get; set; } public string? RefType { get; set; }
public string MTReasonType { get; set; } public string? MTReasonType { get; set; }
public string PrefixId { get; set; } public long? PrefixId { get; set; }
public string SequenceId { get; set; } public long? SequenceId { get; set; }
public string WhseSequenceId { get; set; } public long? WhseSequenceId { get; set; }
public bool WhseSplit { get; set; } public bool? WhseSplit { get; set; }
public Guid? VariableId { get; set; } public Guid? VariableId { get; set; }
public string FormName { get; set; } public string? FormName { get; set; }
public bool InWorkflow { get; set; } public bool? InWorkflow { get; set; }
public bool NoteExistsFlag { get; set; } public bool? NoteExistsFlag { get; set; }
public DateTime RecordDate { get; set; } public DateTime? RecordDate { get; set; }
public Guid RowPointer { get; set; } public Guid? RowPointer { get; set; }
public string CreatedBy { get; set; } public string? CreatedBy { get; set; }
public string UpdatedBy { get; set; } public string? UpdatedBy { get; set; }
public DateTime CreateDate { get; set; } public DateTime? CreateDate { get; set; }
public string CustNum { get; set; } public string? CustNum { get; set; }
public string VendNum { get; set; } public string? VendNum { get; set; }
public int? RecipNum { get; set; } public int? RecipNum { get; set; }
public string Uf_FKR_internal_num_matltran_zn { get; set; } public string? Uf_FKR_internal_num_matltran_zn { get; set; }
public Guid? Session_Id { get; set; } public Guid? Session_Id { get; set; }
public string Uf_MobileAppUser { get; set; } public string? Uf_MobileAppUser { get; set; }
public string NR_KARTY_KONTROLNEJ { get; set; } public string? NR_KARTY_KONTROLNEJ { get; set; }
} }

View File

@@ -2,40 +2,40 @@ namespace SytelineSaAppEfDataModel.Entities;
public class MaterialTransaction public class MaterialTransaction
{ {
public string MTGroup { get; set; } public string? MTGroup { get; set; }
public string MTGroupNum { get; set; } public string? MTGroupNum { get; set; }
public long TransNum { get; set; } public decimal? TransNum { get; set; }
public string Item { get; set; } public string? Item { get; set; }
public DateTime? TransDate { get; set; } public DateTime? TransDate { get; set; }
public decimal? Qty { get; set; } public decimal? Qty { get; set; }
public decimal? Cost { get; set; } public decimal? Cost { get; set; }
public string Whse { get; set; } public string? Whse { get; set; }
public string Loc { get; set; } public string? Loc { get; set; }
public string RefNum { get; set; } public string? RefNum { get; set; }
public short? RefLineSuf { get; set; } public short? RefLineSuf { get; set; }
public short? RefRelease { get; set; } public short? RefRelease { get; set; }
public string ReasonCode { get; set; } public string? ReasonCode { get; set; }
public string TransType { get; set; } public string? TransType { get; set; }
public string RefType { get; set; } public string? RefType { get; set; }
public string MTReasonType { get; set; } public string? MTReasonType { get; set; }
public string PrefixId { get; set; } public long? PrefixId { get; set; }
public string SequenceId { get; set; } public long? SequenceId { get; set; }
public string WhseSequenceId { get; set; } public long? WhseSequenceId { get; set; }
public bool WhseSplit { get; set; } public bool? WhseSplit { get; set; }
public Guid? VariableId { get; set; } public Guid? VariableId { get; set; }
public string FormName { get; set; } public string? FormName { get; set; }
public bool InWorkflow { get; set; } public bool? InWorkflow { get; set; }
public bool NoteExistsFlag { get; set; } public bool? NoteExistsFlag { get; set; }
public DateTime RecordDate { get; set; } public DateTime? RecordDate { get; set; }
public Guid RowPointer { get; set; } public Guid? RowPointer { get; set; }
public string CreatedBy { get; set; } public string? CreatedBy { get; set; }
public string UpdatedBy { get; set; } public string? UpdatedBy { get; set; }
public DateTime CreateDate { get; set; } public DateTime? CreateDate { get; set; }
public string CustNum { get; set; } public string? CustNum { get; set; }
public string VendNum { get; set; } public string? VendNum { get; set; }
public int? RecipNum { get; set; } public int? RecipNum { get; set; }
public string Uf_FKR_internal_num_matltran_zn { get; set; } public string? Uf_FKR_internal_num_matltran_zn { get; set; }
public Guid? Session_Id { get; set; } public Guid? Session_Id { get; set; }
public string Uf_MobileAppUser { get; set; } public string? Uf_MobileAppUser { get; set; }
public string NR_KARTY_KONTROLNEJ { get; set; } public string? NR_KARTY_KONTROLNEJ { get; set; }
} }

View File

@@ -6,5 +6,6 @@ public interface IMaterialTransactionService
{ {
Task<IEnumerable<MaterialTransactionDto>> GetAll(); Task<IEnumerable<MaterialTransactionDto>> GetAll();
Task<MaterialTransactionDto?> GetByWzNumber(string wzNumber); Task<MaterialTransactionDto?> GetByWzNumber(string wzNumber);
Task<IEnumerable<MaterialTransactionDto?>> GetByWzNumbers(ISet<string> wzNumbers);
Task<IEnumerable<MaterialTransactionDto?>> GetByOrderNumber(string orderNumber); Task<IEnumerable<MaterialTransactionDto?>> GetByOrderNumber(string orderNumber);
} }

View File

@@ -17,6 +17,13 @@ public class MaterialTransactionService(SytelineSaAppDbContext context, IMapper
.Where(x => x.MTGroupNum == wzNumber) .Where(x => x.MTGroupNum == wzNumber)
.Select(x => mapper.Map<MaterialTransactionDto>(x)).FirstOrDefaultAsync(); .Select(x => mapper.Map<MaterialTransactionDto>(x)).FirstOrDefaultAsync();
} }
public async Task<IEnumerable<MaterialTransactionDto?>> GetByWzNumbers(ISet<string> wzNumbers)
{
return await context.MaterialTransactions
.Where(x => !string.IsNullOrWhiteSpace(x.MTGroupNum) && wzNumbers.Contains(x.MTGroupNum))
.Select(x => mapper.Map<MaterialTransactionDto>(x)).ToListAsync();
}
public async Task<IEnumerable<MaterialTransactionDto?>> GetByOrderNumber(string orderNumber) public async Task<IEnumerable<MaterialTransactionDto?>> GetByOrderNumber(string orderNumber)
{ {

View File

@@ -714,7 +714,7 @@ namespace SytelineSaAppEfDataModel
entity.Property(e => e.TransNum) entity.Property(e => e.TransNum)
.HasColumnName("trans_num") .HasColumnName("trans_num")
.HasColumnType("bigint"); .HasColumnType("decimal");
entity.Property(e => e.Item) entity.Property(e => e.Item)
.HasColumnName("item") .HasColumnName("item")
@@ -795,7 +795,8 @@ namespace SytelineSaAppEfDataModel
entity.Property(e => e.WhseSplit) entity.Property(e => e.WhseSplit)
.HasColumnName("WhseSplit") .HasColumnName("WhseSplit")
.HasColumnType("tinyint"); .HasColumnType("tinyint")
.IsRequired(false);;
entity.Property(e => e.VariableId) entity.Property(e => e.VariableId)
.HasColumnName("VariableId") .HasColumnName("VariableId")