* Added Lot table and service

* Changed behaviour of scanning to scan first PartNumber, select specific record and then scan MeylePartNumber
This commit is contained in:
2025-06-17 08:30:10 +02:00
parent e96bcc95ba
commit a8e3a8be66
15 changed files with 374 additions and 25 deletions

View File

@@ -0,0 +1,10 @@
using SytelineSaAppEfDataModel.Dtos;
namespace SytelineSaAppEfDataModel.Services;
public interface ILotService
{
Task<IEnumerable<LotDto>> GetAll();
Task<LotDto?> GetByItemNumber(string itemNumber);
Task<LotDto?> GetByLotNumber(string lotNumber);
}

View File

@@ -10,4 +10,5 @@ public interface IMaterialTransactionService
Task<IEnumerable<MaterialTransactionDto>> GetByOrderNumber(string orderNumber);
Task<IEnumerable<MaterialTransactionDto>> GetOrderNumbersByWz(ISet<string> wzNumbers);
Task<IEnumerable<MaterialTransactionDto>> GetByCustomerNumber(string customerNumber, int customerSequence);
Task<MaterialTransactionDto?> GetByPartNumber(string partNumber);
}

View File

@@ -0,0 +1,25 @@
using AutoMapper;
using Microsoft.EntityFrameworkCore;
using SytelineSaAppEfDataModel.Dtos;
namespace SytelineSaAppEfDataModel.Services;
public class LotService(SytelineSaAppDbContext context, IMapper mapper) : ILotService
{
public async Task<IEnumerable<LotDto>> GetAll()
{
return await context.Lots.Select(x => mapper.Map<LotDto>(x)).ToListAsync();
}
public async Task<LotDto?> GetByItemNumber(string itemNumber)
{
return await context.Lots.Where(x => x.Item == itemNumber).Select(x => mapper.Map<LotDto>(x))
.FirstOrDefaultAsync();
}
public async Task<LotDto?> GetByLotNumber(string lotNumber)
{
return await context.Lots.Where(x => x.LotNumber == lotNumber).Select(x => mapper.Map<LotDto>(x))
.FirstOrDefaultAsync();
}
}

View File

@@ -83,4 +83,11 @@ public class MaterialTransactionService(SytelineSaAppDbContext context, IMapper
return result.OrderByDescending(x => x.CreateDate);
}
public async Task<MaterialTransactionDto?> GetByPartNumber(string partNumber)
{
return await context.MaterialTransactions
.Where(x => x.NR_KARTY_KONTROLNEJ == partNumber)
.Select(x => mapper.Map<MaterialTransactionDto>(x)).FirstOrDefaultAsync();
}
}