This commit is contained in:
Cunha 2026-05-19 10:32:21 -03:00
parent 628c84683b
commit 7bc745e4d7
6 changed files with 87 additions and 26 deletions

View File

@ -6,3 +6,4 @@
2026-05-12 08:45:43,538 [Worker-5: Loading available Gradle versions] INFO o.e.b.c.i.u.g.PublishedGradleVersions - Gradle version information cache is out-of-date. Trying to update.
2026-05-13 08:52:02,273 [Worker-4: Loading available Gradle versions] INFO o.e.b.c.i.u.g.PublishedGradleVersions - Gradle version information cache is out-of-date. Trying to update.
2026-05-15 08:38:54,281 [Worker-4: Loading available Gradle versions] INFO o.e.b.c.i.u.g.PublishedGradleVersions - Gradle version information cache is out-of-date. Trying to update.
2026-05-19 10:21:23,094 [Worker-6: Loading available Gradle versions] INFO o.e.b.c.i.u.g.PublishedGradleVersions - Gradle version information cache is out-of-date. Trying to update.

View File

@ -1,2 +1,14 @@
INDEX VERSION 1.4+C:\Users\andrey.cunha\eclipse-workspace.new\Fluig novo\.metadata\.plugins\org.eclipse.wst.jsdt.core\indexes
3974601650.index
2378767110.index
1979626790.index
689185822.index
2072538917.index
1124494010.index
2904386551.index
636540028.index
2173043530.index
2447630285.index
1053508610.index
1223765803.index
1053469344.index

View File

@ -2,13 +2,13 @@
"version": "1.0.0",
"configurations": [
{
"id": "s220blnhijmp1hrc14fyurof1h5bo",
"id": "q7ea9knyu7mpco81suuc482gafgxi",
"name": "Ginseng Produção",
"host": "comerciode188006.fluig.cloudtotvs.com.br",
"ssl": true,
"port": 443,
"username": "andrey.cunha",
"password": "eyJpdiI6IjYwM2Y4MjdmODAyMWNiMTE3ZmFiNmNlZTc4Yzk3NTkyIiwic2FsdCI6ImQ0Nzg1N2I1OGYxNWUxZTQxYTg3MGMzYzRlMTdiM2JiIiwidGV4dCI6IjdiOTZkMTVlYmIzYjBmOTk0YjE2YmQ3YWFiZmY1MjFlIn0=",
"password": "eyJpdiI6ImVlZTgwOTZiMzhlNjhiMGU5N2MzNjQzY2UwMzRlOGVhIiwic2FsdCI6IjcyOWFhNjRkMjZlYTZkOGJkZjY5NWI2N2Q5MTI4NDZkIiwidGV4dCI6ImNmMmEyN2NmMWJkNTA3MzgyZGZjM2Y4NzE4NjkwYjllIn0=",
"userCode": "andrey.cunha",
"confirmExporting": false,
"hasBrowser": false,

View File

@ -313,18 +313,20 @@
<span class="required text-danger"><strong> * </strong></span>
<input type="zoom" class="form-control requiredInput" name="estabelecimento" id="estabelecimento"
data-zoom="{
'displayKey':'estabelecimento',
'datasetId':'dsFiliais',
'placeholder': 'Pesquisar nome do estabelecimento ou filial.',
'fields':[
{
'field':'estabelecimento',
'label':'Estabelecimento',
'standard':'true',
'search':'true'
}
]
}" />
'displayKey':'LOJA',
'datasetId':'dsFiliais',
'placeholder': 'Pesquisar por nome do estabelecimento.',
'fields':[
{'field':'LOJA','label':'Filial','standard':'true','search':'true'},
{'field':'REGIONAL','label':'REGIONAL','standard':'true'},
{'field':'UF','label':'UF','standard':'true'},
{'field':'RESPONSAVEL_LOJA','label':'RESPONSAVEL_LOJA','visible':'false'},
{'field':'PDV','label':'PDV','visible':'false'},
{'field':'PROTHEUS','label':'PROTHEUS','visible':'false'},
{'field':'COLLEAGUE_ID','label':'COLLEAGUE_ID','visible':'false'},
{'field':'LOGIN_LOJA','label':'LOGIN_LOJA','visible':'false'}
]
}"/>
<p class="text-danger text-error">
Preenchimento obrigatório.
</p>

View File

@ -651,6 +651,7 @@
<input type="hidden" name="horaCadastroSCProtheus" id="horaCadastroSCProtheus">
<input type="hidden" name="cotacaoSCProtheus" id="cotacaoSCProtheus">
<input type="hidden" name="pedidoSCProtheus" id="pedidoSCProtheus">
<input type="hidden" name="contratoSCProtheus" id="contratoSCProtheus">
<input type="hidden" name="statusAtendimento" id="statusAtendimento">
<input type="hidden" name="valorTotalCotacao" id="valorTotalCotacao" value="0">
@ -914,7 +915,7 @@
<div class="sc-value" id="cotacaoSC_label">-</div>
</div>
<div class="sc-info sc-info--primary">
<div class="sc-label">Pedido</div>
<div class="sc-label" id="pedidoContratoTipo_label">Pedido</div>
<div class="sc-value" id="pedidoSC_label">-</div>
</div>
</div>
@ -953,7 +954,7 @@
<span class="sc-cotacao-kpi-value">0</span>
</div>
<div class="sc-cotacao-kpi">
<span class="sc-cotacao-kpi-label">Com pedido</span>
<span class="sc-cotacao-kpi-label">Com documento</span>
<span class="sc-cotacao-kpi-value">0</span>
</div>
<div class="sc-cotacao-kpi">

View File

@ -510,17 +510,28 @@ function documentoEhPlaceholder(valor) {
return /^X+$/.test(v);
}
function contratoEhValido(valor) {
var v = String(valor || "").trim();
if (!v) return false;
if (/^0+$/.test(v)) return false;
return true;
}
function linhaCotacaoVencedora(row) {
var pedido = String(row.C8_NUMPED || "").trim();
var itemPedido = String(row.C8_ITEMPED || "").trim();
var fornece = String(row.C8_FORNECE || "").trim();
var loja = String(row.C8_LOJA || "").trim();
if (documentoEhPlaceholder(pedido)) return false;
if (documentoEhPlaceholder(itemPedido)) return false;
if (!fornece || !loja) return false;
return true;
// Pedido gerado
if (!documentoEhPlaceholder(pedido) && !documentoEhPlaceholder(itemPedido)) return true;
// Contrato gerado
if (contratoEhValido(row.C8_NUMCON)) return true;
return false;
}
function possuiFornecedorCotacao(row) {
@ -557,7 +568,8 @@ function classificarLinhaCotacao(row) {
var status = String(row.STATUS || "").trim().toUpperCase();
if (linhaCotacaoVencedora(row)) {
return { tipo: "PEDIDO_GERADO", label: "GANHOU", badge: "badge bg-success", tipoFornecedor: "Fornecedor homologado" };
var tipoDoc = contratoEhValido(row.C8_NUMCON) ? "CONTRATO_GERADO" : "PEDIDO_GERADO";
return { tipo: tipoDoc, label: "GANHOU", badge: "badge bg-success", tipoFornecedor: "Fornecedor homologado" };
}
if (possuiFornecedorCotacao(row)) {
@ -1010,6 +1022,7 @@ function montarResumoCotacaoPorLinhas(rows, cotacao) {
preco: row.C8_PRECO,
total: row.C8_TOTAL,
pedido: String(row.C8_NUMPED || "").trim(),
contrato: String(row.C8_NUMCON || "").trim(),
statusApi: String(row.STATUS || "").trim(),
tipo: classif.tipo,
label: classif.label,
@ -1046,11 +1059,13 @@ function montarResumoCotacaoPorLinhas(rows, cotacao) {
if (vencedorPedido) {
qtdPedidoGerado++;
var tipoVencedor = contratoEhValido(vencedorPedido.C8_NUMCON) ? "CONTRATO_GERADO" : "PEDIDO_GERADO";
itens.push({
item: item,
fornecedor: String(vencedorPedido.C8_FORNECE || "").trim() + "/" + String(vencedorPedido.C8_LOJA || "").trim(),
pedido: String(vencedorPedido.C8_NUMPED || "").trim(),
tipo: "PEDIDO_GERADO"
contrato: String(vencedorPedido.C8_NUMCON || "").trim(),
tipo: tipoVencedor
});
return;
}
@ -1169,7 +1184,19 @@ function alternarTimelineSC() {
focarTimelineSC();
}
function montarStatusAndamento(scRow, cotacao, pedido) {
function extrairContratoDoResumoCotacao(resumo) {
if (!resumo || !resumo.detalhes) return "";
for (var i = 0; i < resumo.detalhes.length; i++) {
var d = resumo.detalhes[i];
if (d.tipo === "CONTRATO_GERADO" && contratoEhValido(d.contrato)) {
return normalizarCodigoComparacao(d.contrato);
}
}
return "";
}
function montarStatusAndamento(scRow, cotacao, pedido, contrato) {
if (contrato) return "Contrato gerado";
if (pedido) return "Pedido gerado";
if (cotacao) return "Cotacao gerada";
@ -1195,15 +1222,22 @@ function preencherResumoSC(resumoCotacao, erroCotacao, resumoPedido, erroPedido)
var horaCadastro = valorCampo("horaCadastroSCProtheus");
var cotacao = limparNumeroDocumento(valorCampo("cotacaoSCProtheus"));
var pedido = limparNumeroDocumento(valorCampo("pedidoSCProtheus"));
var contrato = limparNumeroDocumento(valorCampo("contratoSCProtheus"));
var andamento = valorCampo("statusAtendimento");
var statusCadastroPadrao = normalizarStatusCadastro(statusCadastro, numero);
// Fallback: extrair contrato do resumo de cotação se ainda não salvo no campo
if (!contrato && resumoCotacao) {
contrato = extrairContratoDoResumoCotacao(resumoCotacao);
}
if (!andamento && numero) {
if (pedido) andamento = "Pedido gerado";
if (contrato) andamento = "Contrato gerado";
else if (pedido) andamento = "Pedido gerado";
else if (cotacao) andamento = "Cotacao gerada";
else andamento = "Em andamento";
}
andamento = normalizarAndamento(andamento, cotacao, pedido);
andamento = normalizarAndamento(andamento, cotacao, pedido || contrato);
setLabel("numeroSCProtheus_label", numero);
setLabel("solicitanteSCProtheus_label", solicitante);
@ -1212,7 +1246,8 @@ function preencherResumoSC(resumoCotacao, erroCotacao, resumoPedido, erroPedido)
setLabel("dataCadastroSCProtheus_label", dataCadastro);
setLabel("horaCadastroSCProtheus_label", horaCadastro);
setLabel("cotacaoSC_label", cotacao);
setLabel("pedidoSC_label", pedido);
setLabel("pedidoSC_label", contrato || pedido);
$("#pedidoContratoTipo_label").text(contrato ? "Contrato" : "Pedido");
setBadge("#statusSCProtheus_label", statusCadastroPadrao || (numero ? "SC cadastrada com sucesso" : ""));
setBadge("#statusSC_label", andamento);
@ -1264,14 +1299,16 @@ function consultarAndamentoSC() {
var cotacao = limparNumeroDocumento(row.C1_COTACAO);
var pedido = limparNumeroDocumento(row.C1_PEDIDO);
var contrato = limparNumeroDocumento(row.C1_CONTRATO || "");
if (cotacao) $("#cotacaoSCProtheus").val(cotacao);
if (pedido) $("#pedidoSCProtheus").val(pedido);
if (contrato) $("#contratoSCProtheus").val(contrato);
if (row.C1_SOLICIT) $("#solicitanteSCProtheus").val(String(row.C1_SOLICIT).trim());
if (row.C1_EMISSAO) $("#emissaoSCProtheus").val(normalizarDataProtheus(row.C1_EMISSAO));
var andamento = montarStatusAndamento(row, cotacao, pedido);
var andamento = montarStatusAndamento(row, cotacao, pedido, contrato);
if (andamento) $("#statusAtendimento").val(andamento);
var resumoCotacao = null;
@ -1281,6 +1318,14 @@ function consultarAndamentoSC() {
try {
var cotacoes = JSON.parse(jsonCotacoes);
resumoCotacao = montarResumoCotacaoPorLinhas(cotacoes, cotacao);
// Persistir contrato extraído das cotações no campo hidden para recargas futuras
if (!contrato && resumoCotacao) {
var contratoExtraido = extrairContratoDoResumoCotacao(resumoCotacao);
if (contratoExtraido) {
contrato = contratoExtraido;
$("#contratoSCProtheus").val(contrato);
}
}
} catch (eCot) {
if (!erroCotacao) erroCotacao = "Falha ao ler cotacoes retornadas pelo ds_consultaSC";
}