Warehouses #1
@@ -10,7 +10,7 @@ namespace FaKrosnoApi.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
public class ExcelGeneratorController(IWzHeaderService wzHeaderService, IMaterialTransactionService materialTransactionService, IConfiguration configuration) : Controller
|
||||
public class ExcelGeneratorController(IWzHeaderService wzHeaderService, IWzClientService wzClientService, IMaterialTransactionService materialTransactionService, IConfiguration configuration) : Controller
|
||||
{
|
||||
[HttpGet("generate-meyle")]
|
||||
public async Task GeneratePackListForMeyle(Guid packListId)
|
||||
@@ -96,6 +96,7 @@ public class ExcelGeneratorController(IWzHeaderService wzHeaderService, IMateria
|
||||
public async Task GeneratePackListForMarelli(Guid packListId)
|
||||
{
|
||||
WzHeaderDto wzHeader = await wzHeaderService.GetByIdMarelli(packListId);
|
||||
WzClientDto? wzClient = await wzClientService.GetById(wzHeader.FK_Client ?? Guid.NewGuid());
|
||||
MaterialTransactionDto? materialTransaction = await materialTransactionService.GetByWzNumber(wzHeader.WzRowsMarelli.First().WzNumber);
|
||||
|
||||
using ExcelEngine excelEngine = new ExcelEngine();
|
||||
@@ -124,14 +125,24 @@ public class ExcelGeneratorController(IWzHeaderService wzHeaderService, IMateria
|
||||
worksheet["A4"].Value = "Packing List nr";
|
||||
worksheet["A4"].CellStyle = boldFontStyle;
|
||||
|
||||
worksheet["B4"].Value = string.Join(", ", wzHeader.WzRowsMeyle.Select(x => x.WzNumber).Distinct());
|
||||
worksheet["B4"].Value = string.Join(", ", wzHeader.WzRowsMarelli.Select(x => x.WzNumber).Distinct());
|
||||
worksheet["B4"].CellStyle = boldFontStyle;
|
||||
|
||||
worksheet["A6"].Value = "Date";
|
||||
worksheet["A6"].CellStyle = boldFontStyle;
|
||||
|
||||
worksheet["B6"].DateTime = materialTransaction?.CreateDate ?? DateTime.Now;
|
||||
|
||||
|
||||
if (!string.IsNullOrEmpty(wzClient?.LogoBase64))
|
||||
{
|
||||
byte[] logoBytes = Convert.FromBase64String(wzClient.LogoBase64);
|
||||
|
||||
worksheet.Range["D1:F6"].Merge();
|
||||
|
||||
using MemoryStream imageStream = new MemoryStream(logoBytes);
|
||||
worksheet.Pictures.AddPicture(1, 4, imageStream);
|
||||
}
|
||||
|
||||
int currentRow = 12;
|
||||
|
||||
for (int i = 0; i < mainHeaders.Count; i++)
|
||||
|
||||
@@ -14,4 +14,11 @@ public class WzClientController(IWzClientService service) : Controller
|
||||
IEnumerable<WzClientDto> wzClients = await service.GetAll();
|
||||
return Ok(wzClients);
|
||||
}
|
||||
|
||||
[HttpGet("by-id")]
|
||||
public async Task<ActionResult<WzClientDto>> GetById(Guid id)
|
||||
{
|
||||
WzClientDto? wzClient = await service.GetById(id);
|
||||
return Ok(wzClient);
|
||||
}
|
||||
}
|
||||
@@ -260,8 +260,8 @@
|
||||
{
|
||||
int count = WzRowsMarelli.Count(x => x.PalletNumber == null);
|
||||
_isValid = true;
|
||||
_isValid = count == 0;
|
||||
_isValid = _isValid && !string.IsNullOrWhiteSpace(EmailAddresses);
|
||||
// _isValid = count == 0;
|
||||
// _isValid = _isValid && !string.IsNullOrWhiteSpace(EmailAddresses);
|
||||
|
||||
if (_isValid)
|
||||
{
|
||||
|
||||
@@ -5,4 +5,5 @@ namespace SytelineSaAppEfDataModel.Services;
|
||||
public interface IWzClientService
|
||||
{
|
||||
Task<IEnumerable<WzClientDto>> GetAll();
|
||||
Task<WzClientDto?> GetById(Guid id);
|
||||
}
|
||||
@@ -10,4 +10,10 @@ public class WzClientService(SytelineSaAppDbContext context, IMapper mapper) : I
|
||||
{
|
||||
return await context.WzClients.Select(x => mapper.Map<WzClientDto>(x)).ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<WzClientDto?> GetById(Guid id)
|
||||
{
|
||||
var entity = await context.WzClients.FirstOrDefaultAsync(x => x.ID == id);
|
||||
return entity == null ? null : mapper.Map<WzClientDto>(entity);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user