Warehouses #1
@@ -10,7 +10,7 @@ namespace FaKrosnoApi.Controllers;
|
|||||||
|
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Route("api/[controller]")]
|
[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")]
|
[HttpGet("generate-meyle")]
|
||||||
public async Task GeneratePackListForMeyle(Guid packListId)
|
public async Task GeneratePackListForMeyle(Guid packListId)
|
||||||
@@ -96,6 +96,7 @@ public class ExcelGeneratorController(IWzHeaderService wzHeaderService, IMateria
|
|||||||
public async Task GeneratePackListForMarelli(Guid packListId)
|
public async Task GeneratePackListForMarelli(Guid packListId)
|
||||||
{
|
{
|
||||||
WzHeaderDto wzHeader = await wzHeaderService.GetByIdMarelli(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);
|
MaterialTransactionDto? materialTransaction = await materialTransactionService.GetByWzNumber(wzHeader.WzRowsMarelli.First().WzNumber);
|
||||||
|
|
||||||
using ExcelEngine excelEngine = new ExcelEngine();
|
using ExcelEngine excelEngine = new ExcelEngine();
|
||||||
@@ -124,7 +125,7 @@ public class ExcelGeneratorController(IWzHeaderService wzHeaderService, IMateria
|
|||||||
worksheet["A4"].Value = "Packing List nr";
|
worksheet["A4"].Value = "Packing List nr";
|
||||||
worksheet["A4"].CellStyle = boldFontStyle;
|
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["B4"].CellStyle = boldFontStyle;
|
||||||
|
|
||||||
worksheet["A6"].Value = "Date";
|
worksheet["A6"].Value = "Date";
|
||||||
@@ -132,6 +133,16 @@ public class ExcelGeneratorController(IWzHeaderService wzHeaderService, IMateria
|
|||||||
|
|
||||||
worksheet["B6"].DateTime = materialTransaction?.CreateDate ?? DateTime.Now;
|
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;
|
int currentRow = 12;
|
||||||
|
|
||||||
for (int i = 0; i < mainHeaders.Count; i++)
|
for (int i = 0; i < mainHeaders.Count; i++)
|
||||||
|
|||||||
@@ -14,4 +14,11 @@ public class WzClientController(IWzClientService service) : Controller
|
|||||||
IEnumerable<WzClientDto> wzClients = await service.GetAll();
|
IEnumerable<WzClientDto> wzClients = await service.GetAll();
|
||||||
return Ok(wzClients);
|
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);
|
int count = WzRowsMarelli.Count(x => x.PalletNumber == null);
|
||||||
_isValid = true;
|
_isValid = true;
|
||||||
_isValid = count == 0;
|
// _isValid = count == 0;
|
||||||
_isValid = _isValid && !string.IsNullOrWhiteSpace(EmailAddresses);
|
// _isValid = _isValid && !string.IsNullOrWhiteSpace(EmailAddresses);
|
||||||
|
|
||||||
if (_isValid)
|
if (_isValid)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,4 +5,5 @@ namespace SytelineSaAppEfDataModel.Services;
|
|||||||
public interface IWzClientService
|
public interface IWzClientService
|
||||||
{
|
{
|
||||||
Task<IEnumerable<WzClientDto>> GetAll();
|
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();
|
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