Compare commits
No commits in common. "dfa34e0f5f798c9ceca1a52a38617541d5e9f1b3" and "dfce34f64d0534e63b7b0eecbf333e3dce147af3" have entirely different histories.
dfa34e0f5f
...
dfce34f64d
|
|
@ -400,7 +400,6 @@ namespace line_gestao_api.Controllers
|
|||
Skeelo = req.Skeelo,
|
||||
VivoNewsPlus = req.VivoNewsPlus,
|
||||
VivoTravelMundo = req.VivoTravelMundo,
|
||||
VivoSync = req.VivoSync,
|
||||
VivoGestaoDispositivo = req.VivoGestaoDispositivo,
|
||||
ValorContratoVivo = req.ValorContratoVivo,
|
||||
FranquiaLine = req.FranquiaLine,
|
||||
|
|
@ -409,7 +408,6 @@ namespace line_gestao_api.Controllers
|
|||
ValorContratoLine = req.ValorContratoLine,
|
||||
Desconto = req.Desconto,
|
||||
Lucro = req.Lucro,
|
||||
TipoDeChip = req.TipoDeChip?.Trim(),
|
||||
|
||||
CreatedAt = now,
|
||||
UpdatedAt = now
|
||||
|
|
@ -462,7 +460,6 @@ namespace line_gestao_api.Controllers
|
|||
x.Skeelo = req.Skeelo;
|
||||
x.VivoNewsPlus = req.VivoNewsPlus;
|
||||
x.VivoTravelMundo = req.VivoTravelMundo;
|
||||
x.VivoSync = req.VivoSync;
|
||||
x.VivoGestaoDispositivo = req.VivoGestaoDispositivo;
|
||||
x.ValorContratoVivo = req.ValorContratoVivo;
|
||||
x.FranquiaLine = req.FranquiaLine;
|
||||
|
|
@ -480,7 +477,6 @@ namespace line_gestao_api.Controllers
|
|||
x.DataEntregaOpera = ToUtc(req.DataEntregaOpera);
|
||||
x.DataEntregaCliente = ToUtc(req.DataEntregaCliente);
|
||||
x.VencConta = req.VencConta?.Trim();
|
||||
x.TipoDeChip = req.TipoDeChip?.Trim();
|
||||
|
||||
ApplyReservaRule(x);
|
||||
x.UpdatedAt = DateTime.UtcNow;
|
||||
|
|
@ -580,7 +576,6 @@ namespace line_gestao_api.Controllers
|
|||
Skeelo = TryDecimal(GetCellByHeaderAny(ws, r, map, "SKEELO")),
|
||||
VivoNewsPlus = TryDecimal(GetCellByHeaderAny(ws, r, map, "VIVO NEWS PLUS")),
|
||||
VivoTravelMundo = TryDecimal(GetCellByHeaderAny(ws, r, map, "VIVO TRAVEL MUNDO")),
|
||||
VivoSync = TryDecimal(GetCellByHeaderAny(ws, r, map, "VIVO SYNC")),
|
||||
VivoGestaoDispositivo = TryDecimal(GetCellByHeaderAny(ws, r, map, "VIVO GESTAO DISPOSITIVO")),
|
||||
ValorContratoVivo = TryDecimal(GetCellByHeaderAny(ws, r, map, "VALOR CONTRATO VIVO", "VALOR DO CONTRATO VIVO")),
|
||||
FranquiaLine = TryDecimal(GetCellByHeaderAny(ws, r, map, "FRANQUIA LINE", "FRAQUIA LINE")),
|
||||
|
|
@ -598,7 +593,6 @@ namespace line_gestao_api.Controllers
|
|||
DataEntregaOpera = TryDate(ws, r, map, "DATA DA ENTREGA OPERA."),
|
||||
DataEntregaCliente = TryDate(ws, r, map, "DATA DA ENTREGA CLIENTE"),
|
||||
VencConta = GetCellByHeader(ws, r, map, "VENC. DA CONTA"),
|
||||
TipoDeChip = GetCellByHeaderAny(ws, r, map, "TIPO DE CHIP", "TIPO CHIP"),
|
||||
CreatedAt = now,
|
||||
UpdatedAt = now
|
||||
};
|
||||
|
|
@ -1526,9 +1520,9 @@ namespace line_gestao_api.Controllers
|
|||
|
||||
private async Task ImportResumoTabela1(IXLWorksheet ws, DateTime now)
|
||||
{
|
||||
var lastRowUsed = ws.LastRowUsed()?.RowNumber() ?? 1;
|
||||
var headerRow = FindHeaderRowForMacrophonyPlans(ws, 1, lastRowUsed);
|
||||
if (headerRow == 0) return;
|
||||
const int headerRow = 5;
|
||||
const int totalRow = 72;
|
||||
var lastRow = Math.Min(totalRow - 1, ws.LastRowUsed()?.RowNumber() ?? totalRow - 1);
|
||||
|
||||
var map = BuildHeaderMap(ws.Row(headerRow));
|
||||
var colPlano = GetCol(map, "PLANO CONTRATO");
|
||||
|
|
@ -1539,15 +1533,8 @@ namespace line_gestao_api.Controllers
|
|||
var colValorTotal = GetCol(map, "VALOR TOTAL");
|
||||
|
||||
var buffer = new List<ResumoMacrophonyPlan>(200);
|
||||
string? lastPlanoContrato = null;
|
||||
decimal? lastGb = null;
|
||||
var dataStarted = false;
|
||||
var emptyDataStreak = 0;
|
||||
int? totalRowIndex = null;
|
||||
var missingPlanoCount = 0;
|
||||
var missingGbCount = 0;
|
||||
|
||||
for (int r = headerRow + 1; r <= lastRowUsed; r++)
|
||||
for (int r = headerRow + 1; r <= lastRow; r++)
|
||||
{
|
||||
var plano = GetCellString(ws, r, colPlano);
|
||||
var gb = GetCellString(ws, r, colGb);
|
||||
|
|
@ -1556,90 +1543,27 @@ namespace line_gestao_api.Controllers
|
|||
var totalLinhas = GetCellString(ws, r, colTotalLinhas);
|
||||
var valorTotal = GetCellString(ws, r, colValorTotal);
|
||||
|
||||
var isPlanoTotal = !string.IsNullOrWhiteSpace(plano)
|
||||
&& NormalizeHeader(plano) == NormalizeHeader("TOTAL");
|
||||
|
||||
if (isPlanoTotal)
|
||||
{
|
||||
totalRowIndex = r;
|
||||
break;
|
||||
}
|
||||
|
||||
var hasAnyValue = !(string.IsNullOrWhiteSpace(plano)
|
||||
if (string.IsNullOrWhiteSpace(plano)
|
||||
&& string.IsNullOrWhiteSpace(gb)
|
||||
&& string.IsNullOrWhiteSpace(valorInd)
|
||||
&& string.IsNullOrWhiteSpace(franquia)
|
||||
&& string.IsNullOrWhiteSpace(totalLinhas)
|
||||
&& string.IsNullOrWhiteSpace(valorTotal));
|
||||
|
||||
if (!hasAnyValue)
|
||||
{
|
||||
if (dataStarted)
|
||||
{
|
||||
emptyDataStreak++;
|
||||
if (emptyDataStreak >= 2) break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
emptyDataStreak = 0;
|
||||
|
||||
var franquiaValue = TryDecimal(franquia);
|
||||
var totalLinhasValue = TryNullableInt(totalLinhas);
|
||||
var isDataRow = franquiaValue.HasValue || totalLinhasValue.HasValue;
|
||||
if (isDataRow) dataStarted = true;
|
||||
if (!isDataRow && dataStarted)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (!isDataRow)
|
||||
&& string.IsNullOrWhiteSpace(valorTotal))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var planoNormalized = NormalizeHeader(plano);
|
||||
if (!string.IsNullOrWhiteSpace(plano)
|
||||
&& planoNormalized != NormalizeHeader("PLANO CONTRATO")
|
||||
&& planoNormalized != NormalizeHeader("TOTAL"))
|
||||
{
|
||||
lastPlanoContrato = plano.Trim();
|
||||
}
|
||||
|
||||
var gbValue = TryDecimal(gb);
|
||||
if (gbValue.HasValue)
|
||||
{
|
||||
lastGb = gbValue;
|
||||
}
|
||||
|
||||
var resolvedPlano = isDataRow
|
||||
? (string.IsNullOrWhiteSpace(plano) ? lastPlanoContrato : plano.Trim())
|
||||
: (string.IsNullOrWhiteSpace(plano) ? null : plano.Trim());
|
||||
|
||||
var resolvedGb = isDataRow
|
||||
? (gbValue ?? lastGb)
|
||||
: gbValue;
|
||||
|
||||
if (isDataRow && string.IsNullOrWhiteSpace(resolvedPlano))
|
||||
{
|
||||
missingPlanoCount++;
|
||||
}
|
||||
|
||||
if (isDataRow && !resolvedGb.HasValue)
|
||||
{
|
||||
missingGbCount++;
|
||||
}
|
||||
|
||||
var vivoTravelCell = ws.Cell(r, 8).GetString();
|
||||
var vivoTravel = !string.IsNullOrWhiteSpace(vivoTravelCell)
|
||||
&& vivoTravelCell.Contains("VIVO TRAVEL", StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
buffer.Add(new ResumoMacrophonyPlan
|
||||
{
|
||||
PlanoContrato = string.IsNullOrWhiteSpace(resolvedPlano) ? null : resolvedPlano,
|
||||
Gb = resolvedGb,
|
||||
PlanoContrato = string.IsNullOrWhiteSpace(plano) ? null : plano.Trim(),
|
||||
Gb = TryDecimal(gb),
|
||||
ValorIndividualComSvas = TryDecimal(valorInd),
|
||||
FranquiaGb = franquiaValue,
|
||||
TotalLinhas = totalLinhasValue,
|
||||
FranquiaGb = TryDecimal(franquia),
|
||||
TotalLinhas = TryNullableInt(totalLinhas),
|
||||
ValorTotal = TryDecimal(valorTotal),
|
||||
VivoTravel = vivoTravel,
|
||||
CreatedAt = now,
|
||||
|
|
@ -1653,21 +1577,11 @@ namespace line_gestao_api.Controllers
|
|||
await _db.SaveChangesAsync();
|
||||
}
|
||||
|
||||
if (missingPlanoCount > 0 || missingGbCount > 0)
|
||||
{
|
||||
throw new InvalidOperationException($"Import RESUMO/MACROPHONY: {missingPlanoCount} linhas sem PLANO CONTRATO e {missingGbCount} linhas sem GB.");
|
||||
}
|
||||
|
||||
if (totalRowIndex == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var total = new ResumoMacrophonyTotal
|
||||
{
|
||||
FranquiaGbTotal = TryDecimal(GetCellString(ws, totalRowIndex.Value, colFranquiaGb)),
|
||||
TotalLinhasTotal = TryNullableInt(GetCellString(ws, totalRowIndex.Value, colTotalLinhas)),
|
||||
ValorTotal = TryDecimal(GetCellString(ws, totalRowIndex.Value, colValorTotal)),
|
||||
FranquiaGbTotal = TryDecimal(GetCellString(ws, totalRow, colFranquiaGb)),
|
||||
TotalLinhasTotal = TryNullableInt(GetCellString(ws, totalRow, colTotalLinhas)),
|
||||
ValorTotal = TryDecimal(GetCellString(ws, totalRow, colValorTotal)),
|
||||
CreatedAt = now,
|
||||
UpdatedAt = now
|
||||
};
|
||||
|
|
@ -1676,27 +1590,6 @@ namespace line_gestao_api.Controllers
|
|||
await _db.SaveChangesAsync();
|
||||
}
|
||||
|
||||
private static int FindHeaderRowForMacrophonyPlans(IXLWorksheet ws, int startRow, int lastRow)
|
||||
{
|
||||
for (int r = startRow; r <= lastRow; r++)
|
||||
{
|
||||
var row = ws.Row(r);
|
||||
if (!row.CellsUsed().Any()) continue;
|
||||
|
||||
var map = BuildHeaderMap(row);
|
||||
var hasPlano = GetCol(map, "PLANO CONTRATO") > 0;
|
||||
var hasGb = GetCol(map, "GB") > 0;
|
||||
var hasTotalLinhas = GetColAny(map, "TOTAL DE LINHAS", "TOTAL LINHAS") > 0;
|
||||
|
||||
if (hasPlano && hasGb && hasTotalLinhas)
|
||||
{
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private async Task ImportResumoTabela2(IXLWorksheet ws, DateTime now)
|
||||
{
|
||||
const int headerRow = 5;
|
||||
|
|
@ -1821,9 +1714,9 @@ namespace line_gestao_api.Controllers
|
|||
|
||||
private async Task ImportResumoTabela4(IXLWorksheet ws, DateTime now)
|
||||
{
|
||||
var lastRowUsed = ws.LastRowUsed()?.RowNumber() ?? 1;
|
||||
var headerRow = FindHeaderRowForPlanoContratoResumo(ws, 1, lastRowUsed);
|
||||
if (headerRow == 0) return;
|
||||
const int headerRow = 74;
|
||||
const int totalRow = 81;
|
||||
var lastRow = Math.Min(totalRow - 1, ws.LastRowUsed()?.RowNumber() ?? totalRow - 1);
|
||||
|
||||
var map = BuildHeaderMap(ws.Row(headerRow));
|
||||
var colPlano = GetCol(map, "PLANO CONTRATO");
|
||||
|
|
@ -1832,17 +1725,10 @@ namespace line_gestao_api.Controllers
|
|||
var colFranquiaGb = GetColAny(map, "FRANQUIA GB", "FRAQUIA GB");
|
||||
var colTotalLinhas = GetColAny(map, "TOTAL DE LINHAS", "TOTAL LINHAS");
|
||||
var colValorTotal = GetCol(map, "VALOR TOTAL");
|
||||
var colCliente = GetCol(map, "CLIENTE");
|
||||
var colQtdLinhas = GetColAny(map, "QTD DE LINHAS", "QTD. DE LINHAS", "QTD LINHAS");
|
||||
|
||||
var buffer = new List<ResumoPlanoContratoResumo>(200);
|
||||
string? lastPlanoContrato = null;
|
||||
var dataStarted = false;
|
||||
var emptyDataStreak = 0;
|
||||
int? totalRowIndex = null;
|
||||
var missingPlanoCount = 0;
|
||||
|
||||
for (int r = headerRow + 1; r <= lastRowUsed; r++)
|
||||
for (int r = headerRow + 1; r <= lastRow; r++)
|
||||
{
|
||||
var plano = GetCellString(ws, r, colPlano);
|
||||
var gb = GetCellString(ws, r, colGb);
|
||||
|
|
@ -1850,68 +1736,20 @@ namespace line_gestao_api.Controllers
|
|||
var franquia = GetCellString(ws, r, colFranquiaGb);
|
||||
var totalLinhas = GetCellString(ws, r, colTotalLinhas);
|
||||
var valorTotal = GetCellString(ws, r, colValorTotal);
|
||||
var cliente = GetCellString(ws, r, colCliente);
|
||||
var qtdLinhas = GetCellString(ws, r, colQtdLinhas);
|
||||
|
||||
var isPlanoTotal = !string.IsNullOrWhiteSpace(plano)
|
||||
&& NormalizeHeader(plano) == NormalizeHeader("TOTAL");
|
||||
|
||||
if (isPlanoTotal)
|
||||
{
|
||||
totalRowIndex = r;
|
||||
break;
|
||||
}
|
||||
|
||||
var hasAnyValue = !(string.IsNullOrWhiteSpace(plano)
|
||||
if (string.IsNullOrWhiteSpace(plano)
|
||||
&& string.IsNullOrWhiteSpace(gb)
|
||||
&& string.IsNullOrWhiteSpace(valorInd)
|
||||
&& string.IsNullOrWhiteSpace(franquia)
|
||||
&& string.IsNullOrWhiteSpace(totalLinhas)
|
||||
&& string.IsNullOrWhiteSpace(valorTotal)
|
||||
&& string.IsNullOrWhiteSpace(cliente)
|
||||
&& string.IsNullOrWhiteSpace(qtdLinhas));
|
||||
|
||||
if (!hasAnyValue)
|
||||
&& string.IsNullOrWhiteSpace(valorTotal))
|
||||
{
|
||||
if (dataStarted)
|
||||
{
|
||||
emptyDataStreak++;
|
||||
if (emptyDataStreak >= 2) break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
emptyDataStreak = 0;
|
||||
|
||||
var isDataRow = !string.IsNullOrWhiteSpace(cliente) || TryNullableInt(qtdLinhas).HasValue;
|
||||
|
||||
var planoNormalized = NormalizeHeader(plano);
|
||||
if (!string.IsNullOrWhiteSpace(plano)
|
||||
&& planoNormalized != NormalizeHeader("PLANO CONTRATO")
|
||||
&& planoNormalized != NormalizeHeader("TOTAL"))
|
||||
{
|
||||
lastPlanoContrato = plano.Trim();
|
||||
}
|
||||
|
||||
if (!isDataRow && dataStarted)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (isDataRow) dataStarted = true;
|
||||
|
||||
var resolvedPlano = isDataRow
|
||||
? (string.IsNullOrWhiteSpace(plano) ? lastPlanoContrato : plano.Trim())
|
||||
: (string.IsNullOrWhiteSpace(plano) ? null : plano.Trim());
|
||||
|
||||
if (isDataRow && string.IsNullOrWhiteSpace(resolvedPlano))
|
||||
{
|
||||
missingPlanoCount++;
|
||||
}
|
||||
|
||||
buffer.Add(new ResumoPlanoContratoResumo
|
||||
{
|
||||
PlanoContrato = string.IsNullOrWhiteSpace(resolvedPlano) ? null : resolvedPlano,
|
||||
PlanoContrato = string.IsNullOrWhiteSpace(plano) ? null : plano.Trim(),
|
||||
Gb = TryDecimal(gb),
|
||||
ValorIndividualComSvas = TryDecimal(valorInd),
|
||||
FranquiaGb = TryDecimal(franquia),
|
||||
|
|
@ -1928,19 +1766,9 @@ namespace line_gestao_api.Controllers
|
|||
await _db.SaveChangesAsync();
|
||||
}
|
||||
|
||||
if (missingPlanoCount > 0)
|
||||
{
|
||||
throw new InvalidOperationException($"Import RESUMO/PLANO CONTRATO: {missingPlanoCount} linhas de dados ficaram sem PLANO CONTRATO.");
|
||||
}
|
||||
|
||||
if (totalRowIndex == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var total = new ResumoPlanoContratoTotal
|
||||
{
|
||||
ValorTotal = TryDecimal(GetCellString(ws, totalRowIndex.Value, colValorTotal)),
|
||||
ValorTotal = TryDecimal(ws.Cell(totalRow, 7).GetString()),
|
||||
CreatedAt = now,
|
||||
UpdatedAt = now
|
||||
};
|
||||
|
|
@ -1949,27 +1777,6 @@ namespace line_gestao_api.Controllers
|
|||
await _db.SaveChangesAsync();
|
||||
}
|
||||
|
||||
private static int FindHeaderRowForPlanoContratoResumo(IXLWorksheet ws, int startRow, int lastRow)
|
||||
{
|
||||
for (int r = startRow; r <= lastRow; r++)
|
||||
{
|
||||
var row = ws.Row(r);
|
||||
if (!row.CellsUsed().Any()) continue;
|
||||
|
||||
var map = BuildHeaderMap(row);
|
||||
var hasPlano = GetCol(map, "PLANO CONTRATO") > 0;
|
||||
var hasCliente = GetCol(map, "CLIENTE") > 0;
|
||||
var hasQtd = GetColAny(map, "QTD DE LINHAS", "QTD. DE LINHAS", "QTD LINHAS") > 0;
|
||||
|
||||
if (hasPlano && hasCliente && hasQtd)
|
||||
{
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private async Task ImportResumoTabela5(IXLWorksheet ws, DateTime now)
|
||||
{
|
||||
const int headerRow = 83;
|
||||
|
|
@ -2007,111 +1814,65 @@ namespace line_gestao_api.Controllers
|
|||
|
||||
private async Task ImportResumoTabela6(IXLWorksheet ws, DateTime now)
|
||||
{
|
||||
var lastRowUsed = ws.LastRowUsed()?.RowNumber() ?? 1;
|
||||
var sectionRow = FindSectionRow(ws, "LINHAS NA RESERVA");
|
||||
if (sectionRow == 0) return;
|
||||
|
||||
var headerRow = FindHeaderRowForReserva(ws, sectionRow + 1, lastRowUsed);
|
||||
if (headerRow == 0) return;
|
||||
const int headerRow = 91;
|
||||
const int totalRow = 139;
|
||||
var lastRow = Math.Min(totalRow - 1, ws.LastRowUsed()?.RowNumber() ?? totalRow - 1);
|
||||
|
||||
var map = BuildHeaderMap(ws.Row(headerRow));
|
||||
var colDdd = GetCol(map, "DDD");
|
||||
var colFranquiaGb = GetColAny(map, "FRANQUIA GB", "FRAQUIA GB");
|
||||
var colQtdLinhas = GetColAny(map, "QTD. DE LINHAS", "QTD DE LINHAS", "QTD. LINHAS", "QTDLINHAS");
|
||||
var colQtdLinhas = GetColAny(map, "QTD. DE LINHAS", "QTD DE LINHAS", "QTD. LINHAS");
|
||||
var colTotal = GetCol(map, "TOTAL");
|
||||
|
||||
var buffer = new List<ResumoReservaLine>(200);
|
||||
string? lastDddValid = null;
|
||||
var dataStarted = false;
|
||||
var emptyRowStreak = 0;
|
||||
int? totalRowIndex = null;
|
||||
decimal? lastTotal = null;
|
||||
|
||||
for (int r = headerRow + 1; r <= lastRowUsed; r++)
|
||||
for (int r = headerRow + 1; r <= lastRow; r++)
|
||||
{
|
||||
var ddd = GetCellString(ws, r, colDdd);
|
||||
var franquia = GetCellString(ws, r, colFranquiaGb);
|
||||
var qtdLinhas = GetCellString(ws, r, colQtdLinhas);
|
||||
var total = GetCellString(ws, r, colTotal);
|
||||
|
||||
var hasAnyValue = !(string.IsNullOrWhiteSpace(ddd)
|
||||
if (string.IsNullOrWhiteSpace(ddd)
|
||||
&& string.IsNullOrWhiteSpace(franquia)
|
||||
&& string.IsNullOrWhiteSpace(qtdLinhas)
|
||||
&& string.IsNullOrWhiteSpace(total));
|
||||
|
||||
if (!hasAnyValue)
|
||||
&& string.IsNullOrWhiteSpace(total))
|
||||
{
|
||||
if (dataStarted)
|
||||
{
|
||||
emptyRowStreak++;
|
||||
if (emptyRowStreak >= 2) break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
emptyRowStreak = 0;
|
||||
|
||||
var franquiaValue = TryDecimal(franquia);
|
||||
var qtdValue = TryNullableInt(qtdLinhas);
|
||||
var isDataRow = franquiaValue.HasValue || qtdValue.HasValue;
|
||||
var dddCandidate = NullIfEmptyDigits(ddd);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(dddCandidate))
|
||||
{
|
||||
lastDddValid = dddCandidate;
|
||||
}
|
||||
|
||||
var isTotalRow = !isDataRow && !string.IsNullOrWhiteSpace(total);
|
||||
if (isTotalRow)
|
||||
{
|
||||
totalRowIndex = r;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!isDataRow && dataStarted)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (isDataRow) dataStarted = true;
|
||||
|
||||
var resolvedDdd = isDataRow
|
||||
? (dddCandidate ?? lastDddValid)
|
||||
: dddCandidate;
|
||||
|
||||
var totalValue = TryDecimal(total);
|
||||
if (!totalValue.HasValue && lastTotal.HasValue)
|
||||
{
|
||||
totalValue = lastTotal;
|
||||
}
|
||||
else if (totalValue.HasValue)
|
||||
{
|
||||
lastTotal = totalValue;
|
||||
}
|
||||
|
||||
buffer.Add(new ResumoReservaLine
|
||||
{
|
||||
Ddd = string.IsNullOrWhiteSpace(resolvedDdd) ? null : resolvedDdd,
|
||||
FranquiaGb = franquiaValue,
|
||||
QtdLinhas = qtdValue,
|
||||
Ddd = string.IsNullOrWhiteSpace(ddd) ? null : ddd.Trim(),
|
||||
FranquiaGb = TryDecimal(franquia),
|
||||
QtdLinhas = TryNullableInt(qtdLinhas),
|
||||
Total = totalValue,
|
||||
CreatedAt = now,
|
||||
UpdatedAt = now
|
||||
});
|
||||
}
|
||||
|
||||
var missingDddCount = buffer.Count(x => x.Ddd == null && (x.FranquiaGb.HasValue || x.QtdLinhas.HasValue));
|
||||
if (missingDddCount > 0)
|
||||
{
|
||||
throw new InvalidOperationException($"Import RESUMO/RESERVA: {missingDddCount} linhas de dados ficaram sem DDD.");
|
||||
}
|
||||
|
||||
if (buffer.Count > 0)
|
||||
{
|
||||
await _db.ResumoReservaLines.AddRangeAsync(buffer);
|
||||
await _db.SaveChangesAsync();
|
||||
}
|
||||
|
||||
if (totalRowIndex == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var totalEntity = new ResumoReservaTotal
|
||||
{
|
||||
QtdLinhasTotal = TryNullableInt(GetCellString(ws, totalRowIndex.Value, colQtdLinhas)),
|
||||
Total = TryDecimal(GetCellString(ws, totalRowIndex.Value, colTotal)),
|
||||
QtdLinhasTotal = TryNullableInt(GetCellString(ws, totalRow, colQtdLinhas)),
|
||||
Total = TryDecimal(GetCellString(ws, totalRow, colTotal)),
|
||||
CreatedAt = now,
|
||||
UpdatedAt = now
|
||||
};
|
||||
|
|
@ -2120,43 +1881,6 @@ namespace line_gestao_api.Controllers
|
|||
await _db.SaveChangesAsync();
|
||||
}
|
||||
|
||||
private static int FindSectionRow(IXLWorksheet ws, string sectionName)
|
||||
{
|
||||
var normalizedTarget = NormalizeHeader(sectionName);
|
||||
foreach (var row in ws.RowsUsed())
|
||||
{
|
||||
foreach (var cell in row.CellsUsed())
|
||||
{
|
||||
var key = NormalizeHeader(cell.GetString());
|
||||
if (string.IsNullOrWhiteSpace(key)) continue;
|
||||
if (key.Contains(normalizedTarget)) return row.RowNumber();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static int FindHeaderRowForReserva(IXLWorksheet ws, int startRow, int lastRow)
|
||||
{
|
||||
for (int r = startRow; r <= lastRow; r++)
|
||||
{
|
||||
var row = ws.Row(r);
|
||||
if (!row.CellsUsed().Any()) continue;
|
||||
|
||||
var map = BuildHeaderMap(row);
|
||||
var hasDdd = GetCol(map, "DDD") > 0;
|
||||
var hasFranquia = GetColAny(map, "FRANQUIA GB", "FRAQUIA GB") > 0;
|
||||
var hasQtd = GetColAny(map, "QTD. DE LINHAS", "QTD DE LINHAS", "QTD. LINHAS", "QTDLINHAS") > 0;
|
||||
|
||||
if (hasDdd && hasFranquia && hasQtd)
|
||||
{
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private async Task ImportControleRecebidosSheet(IXLWorksheet ws, int year)
|
||||
{
|
||||
var buffer = new List<ControleRecebidoLine>(500);
|
||||
|
|
@ -2435,7 +2159,6 @@ namespace line_gestao_api.Controllers
|
|||
Skeelo = x.Skeelo,
|
||||
VivoNewsPlus = x.VivoNewsPlus,
|
||||
VivoTravelMundo = x.VivoTravelMundo,
|
||||
VivoSync = x.VivoSync,
|
||||
VivoGestaoDispositivo = x.VivoGestaoDispositivo,
|
||||
ValorContratoVivo = x.ValorContratoVivo,
|
||||
FranquiaLine = x.FranquiaLine,
|
||||
|
|
@ -2452,8 +2175,7 @@ namespace line_gestao_api.Controllers
|
|||
Solicitante = x.Solicitante,
|
||||
DataEntregaOpera = x.DataEntregaOpera,
|
||||
DataEntregaCliente = x.DataEntregaCliente,
|
||||
VencConta = x.VencConta,
|
||||
TipoDeChip = x.TipoDeChip
|
||||
VencConta = x.VencConta
|
||||
};
|
||||
|
||||
private static void ApplyReservaRule(MobileLine x)
|
||||
|
|
|
|||
|
|
@ -49,7 +49,6 @@ namespace line_gestao_api.Dtos
|
|||
public decimal? Skeelo { get; set; }
|
||||
public decimal? VivoNewsPlus { get; set; }
|
||||
public decimal? VivoTravelMundo { get; set; }
|
||||
public decimal? VivoSync { get; set; }
|
||||
public decimal? VivoGestaoDispositivo { get; set; }
|
||||
public decimal? ValorContratoVivo { get; set; }
|
||||
|
||||
|
|
@ -66,10 +65,5 @@ namespace line_gestao_api.Dtos
|
|||
// ==========================
|
||||
public decimal? Desconto { get; set; }
|
||||
public decimal? Lucro { get; set; }
|
||||
|
||||
// ==========================
|
||||
// Identificação adicional
|
||||
// ==========================
|
||||
public string? TipoDeChip { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -33,7 +33,6 @@
|
|||
public decimal? Skeelo { get; set; }
|
||||
public decimal? VivoNewsPlus { get; set; }
|
||||
public decimal? VivoTravelMundo { get; set; }
|
||||
public decimal? VivoSync { get; set; }
|
||||
public decimal? VivoGestaoDispositivo { get; set; }
|
||||
public decimal? ValorContratoVivo { get; set; }
|
||||
|
||||
|
|
@ -54,7 +53,6 @@
|
|||
public DateTime? DataEntregaOpera { get; set; }
|
||||
public DateTime? DataEntregaCliente { get; set; }
|
||||
public string? VencConta { get; set; }
|
||||
public string? TipoDeChip { get; set; }
|
||||
}
|
||||
|
||||
// ✅ UPDATE REQUEST (SEM Id)
|
||||
|
|
@ -74,7 +72,6 @@
|
|||
public decimal? Skeelo { get; set; }
|
||||
public decimal? VivoNewsPlus { get; set; }
|
||||
public decimal? VivoTravelMundo { get; set; }
|
||||
public decimal? VivoSync { get; set; }
|
||||
public decimal? VivoGestaoDispositivo { get; set; }
|
||||
public decimal? ValorContratoVivo { get; set; }
|
||||
|
||||
|
|
@ -95,7 +92,6 @@
|
|||
public DateTime? DataEntregaOpera { get; set; }
|
||||
public DateTime? DataEntregaCliente { get; set; }
|
||||
public string? VencConta { get; set; }
|
||||
public string? TipoDeChip { get; set; }
|
||||
}
|
||||
|
||||
public class ImportResultDto
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ namespace line_gestao_api.Models
|
|||
public decimal? Skeelo { get; set; }
|
||||
public decimal? VivoNewsPlus { get; set; }
|
||||
public decimal? VivoTravelMundo { get; set; }
|
||||
public decimal? VivoSync { get; set; }
|
||||
public decimal? VivoGestaoDispositivo { get; set; }
|
||||
public decimal? ValorContratoVivo { get; set; }
|
||||
|
||||
|
|
@ -60,8 +59,6 @@ namespace line_gestao_api.Models
|
|||
|
||||
[MaxLength(50)]
|
||||
public string? VencConta { get; set; }
|
||||
[MaxLength(80)]
|
||||
public string? TipoDeChip { get; set; }
|
||||
|
||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||
public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;
|
||||
|
|
|
|||
Loading…
Reference in New Issue