This commit is contained in:
Cunha 2026-03-22 16:12:12 -03:00
parent 4bb50f0716
commit 822aa68197
15 changed files with 2878 additions and 1318 deletions

View File

@ -2,13 +2,13 @@
"version": "1.0.0", "version": "1.0.0",
"configurations": [ "configurations": [
{ {
"id": "1v6yi27yg82mmzgeg2todjqzi42g7", "id": "5i6o3b75rrmmn0z5dbms6ldputs2v",
"name": "teste", "name": "teste",
"host": "comerciode188007.fluig.cloudtotvs.com.br", "host": "comerciode188007.fluig.cloudtotvs.com.br",
"ssl": true, "ssl": true,
"port": 443, "port": 443,
"username": "andrey.cunha", "username": "andrey.cunha",
"password": "eyJpdiI6Ijk2Mzg4MGUwODVkYTVkZmI0YjQ2ZTdmNmNlYTJlMGI2Iiwic2FsdCI6ImI0ODMzZTAyNDkxNWYzNGFkNDVkYjE5ZThkMGNlOTM3IiwidGV4dCI6IjY3NDBmZjM2MTE1YjhiODAyM2IzYjVjZDYyYzEwYWRiIn0=", "password": "eyJpdiI6ImE1ZmNlY2U2NjVlMjFlMzJiM2U1NzFjM2RlNTU3NDQyIiwic2FsdCI6ImU5ZDQ5MWUzNjA5OWZmYmFlZjgxZTRmODFmM2M1ZDNlIiwidGV4dCI6IjRkYTIxY2E1Mjg0ZDkxNTkzZTk0MTliYTljZGQ1ZjUzIn0=",
"userCode": "andrey.cunha", "userCode": "andrey.cunha",
"confirmExporting": false, "confirmExporting": false,
"hasBrowser": false, "hasBrowser": false,

View File

@ -95,6 +95,10 @@ function validateForm(form) {
message += getMessage("Data da entrega", 1, form); message += getMessage("Data da entrega", 1, form);
hasErros = true; hasErros = true;
} }
if (String(form.getValue("nomerecebedor") || "").trim() == "") {
message += getMessage("Nome de quem recebeu a mercadoria", 1, form);
hasErros = true;
}
break; break;
case RECEBIMENTO: case RECEBIMENTO:

View File

@ -353,30 +353,67 @@ function clearZoomField(fieldId) {
$("#" + fieldId).val(""); $("#" + fieldId).val("");
} }
var MOTORISTAS_GROUP_ID = "Motoristas"; var MOTORISTAS_GROUP_DEFAULT_ID = "Motoristas";
var motoristasEntregaCache = null; var MOTORISTAS_GROUP_BY_UF = {
var motoristasEntregaLoading = false; AL: "motoristaAL",
BA: "motoristaBA",
SE: "motoristaSE"
};
var motoristasEntregaCacheByGroup = {};
var motoristasEntregaLoadingByGroup = {};
var motoristaEntregaGroupAtual = "";
function normalizeUfCode(value) {
return String(value || "").toUpperCase().replace(/[^A-Z]/g, "").substring(0, 2);
}
function resolveMotoristasGroupIdByUf(uf) {
var ufCode = normalizeUfCode(uf);
if (!ufCode) {
return MOTORISTAS_GROUP_DEFAULT_ID;
}
if (MOTORISTAS_GROUP_BY_UF[ufCode]) {
return String(MOTORISTAS_GROUP_BY_UF[ufCode] || "").trim() || MOTORISTAS_GROUP_DEFAULT_ID;
}
// Convencao para facilitar novos estados sem precisar alterar o JS.
return "motorista" + ufCode;
}
function getMotoristasEntregaQueryContext() {
var uf = normalizeUfCode($("#ufDestino").val());
var groupId = resolveMotoristasGroupIdByUf(uf);
return {
uf: uf,
groupId: groupId,
cacheKey: groupId
};
}
function loadMotoristasEntregaSelect(forceReload) { function loadMotoristasEntregaSelect(forceReload) {
var select = $("#motoristaEntregaSelecionado"); var select = $("#motoristaEntregaSelecionado");
if (!select.length) return; if (!select.length) return;
if (!forceReload && motoristasEntregaCache && motoristasEntregaCache.length) { var context = getMotoristasEntregaQueryContext();
renderMotoristasEntregaOptions(motoristasEntregaCache); var cacheKey = context.cacheKey;
motoristaEntregaGroupAtual = context.groupId;
if (!forceReload && Object.prototype.hasOwnProperty.call(motoristasEntregaCacheByGroup, cacheKey)) {
renderMotoristasEntregaOptions(motoristasEntregaCacheByGroup[cacheKey], context);
return; return;
} }
if (motoristasEntregaLoading) return; if (motoristasEntregaLoadingByGroup[cacheKey]) return;
motoristasEntregaLoading = true; motoristasEntregaLoadingByGroup[cacheKey] = true;
select.prop("disabled", true);
var requestPayload = { var requestPayload = {
name: "ds_motoristas_grupo", name: "ds_motoristas_grupo",
fields: null, fields: null,
constraints: [{ constraints: [{
_field: "GROUP_ID", _field: "GROUP_ID",
_initialValue: MOTORISTAS_GROUP_ID, _initialValue: context.groupId,
_finalValue: MOTORISTAS_GROUP_ID, _finalValue: context.groupId,
_type: 1 _type: 1
}], }],
order: null order: null
@ -390,14 +427,22 @@ function loadMotoristasEntregaSelect(forceReload) {
data: JSON.stringify(requestPayload) data: JSON.stringify(requestPayload)
}).done(function (response) { }).done(function (response) {
var values = ((((response || {}).content || {}).values) || []); var values = ((((response || {}).content || {}).values) || []);
motoristasEntregaCache = normalizeMotoristasEntregaRows(values); var rows = normalizeMotoristasEntregaRows(values);
renderMotoristasEntregaOptions(motoristasEntregaCache); motoristasEntregaCacheByGroup[cacheKey] = rows;
if (motoristaEntregaGroupAtual === context.groupId) {
renderMotoristasEntregaOptions(rows, context);
}
}).fail(function (xhr) { }).fail(function (xhr) {
console.error("Falha ao carregar motoristas do dataset:", xhr); console.error("Falha ao carregar motoristas do dataset (" + context.groupId + "):", xhr);
motoristasEntregaCache = []; motoristasEntregaCacheByGroup[cacheKey] = [];
renderMotoristasEntregaOptions([]); if (motoristaEntregaGroupAtual === context.groupId) {
renderMotoristasEntregaOptions([], context);
}
}).always(function () { }).always(function () {
motoristasEntregaLoading = false; motoristasEntregaLoadingByGroup[cacheKey] = false;
if (motoristaEntregaGroupAtual === context.groupId) {
select.prop("disabled", false);
}
}); });
} }
@ -429,14 +474,21 @@ function normalizeMotoristasEntregaRows(values) {
return out; return out;
} }
function renderMotoristasEntregaOptions(rows) { function renderMotoristasEntregaOptions(rows, context) {
var select = $("#motoristaEntregaSelecionado"); var select = $("#motoristaEntregaSelecionado");
if (!select.length) return; if (!select.length) return;
var selectedValue = String($("#motoristaEntregaLogin").val() || select.val() || "").trim(); var selectedValue = String($("#motoristaEntregaLogin").val() || select.val() || "").trim();
var placeholder = "Selecione o motorista";
if (context && context.uf) {
placeholder = "Selecione o motorista da UF " + context.uf;
}
if ((rows || []).length === 0 && context && context.uf) {
placeholder = "Sem motoristas cadastrados para UF " + context.uf;
}
select.empty(); select.empty();
select.append($("<option></option>").val("").text("Selecione o motorista")); select.append($("<option></option>").val("").text(placeholder));
for (var i = 0; i < rows.length; i++) { for (var i = 0; i < rows.length; i++) {
var row = rows[i]; var row = rows[i];
@ -462,6 +514,12 @@ function renderMotoristasEntregaOptions(rows) {
applySelectedMotoristaEntregaOption(); applySelectedMotoristaEntregaOption();
} }
function refreshMotoristasEntregaByUf(forceReload) {
var escolha = String($("input[name='tipoMotoristaEntrega']:checked").val() || "");
if (escolha !== "outro") return;
loadMotoristasEntregaSelect(forceReload === true);
}
function syncMotoristaEntregaSelectFromHidden() { function syncMotoristaEntregaSelectFromHidden() {
var select = $("#motoristaEntregaSelecionado"); var select = $("#motoristaEntregaSelecionado");
if (!select.length) return; if (!select.length) return;
@ -1043,7 +1101,7 @@ var beforeSendValidate = function (numState, nextState) {
throw "'Complemento' é obrigatório."; throw "'Complemento' é obrigatório.";
} else if ($("#justificativa").val() == "") { } else if ($("#justificativa").val() == "") {
$("#justificativa").parent("div").addClass("errorValidate"); $("#justificativa").parent("div").addClass("errorValidate");
throw "'Qual o motivo da compra?' é obrigatório."; throw "'Qual o motivo da transferência?' é obrigatório.";
} else { } else {
$("input[id^='quantidadeItem___']").each(function (index, value) { $("input[id^='quantidadeItem___']").each(function (index, value) {
var linha = $(value).attr("name").split("___")[1]; var linha = $(value).attr("name").split("___")[1];
@ -1152,6 +1210,9 @@ var beforeSendValidate = function (numState, nextState) {
if ($("#dataEntrega").val() == "") { if ($("#dataEntrega").val() == "") {
throw "'Data da entrega' é obrigatória."; throw "'Data da entrega' é obrigatória.";
} }
if (String($("#nomerecebedor").val() || "").trim() == "") {
throw "'Nome de quem recebeu a mercadoria' é obrigatório.";
}
} else if (numState == 18) { } else if (numState == 18) {
var validacaoItens = $("input[name='validacaoItens']:checked").val(); var validacaoItens = $("input[name='validacaoItens']:checked").val();
if (validacaoItens == "" || validacaoItens == undefined) { if (validacaoItens == "" || validacaoItens == undefined) {
@ -1224,6 +1285,7 @@ function setSelectedZoomItem(selectedItem) {
$("#gestorEmail").val(selectedItem["emailGestor"] || ""); $("#gestorEmail").val(selectedItem["emailGestor"] || "");
$("#gestor_cc").val(selectedItem["COLLEAGUE_ID"] || ""); $("#gestor_cc").val(selectedItem["COLLEAGUE_ID"] || "");
$("#ufDestino").val(selectedItem["UF"] || ""); $("#ufDestino").val(selectedItem["UF"] || "");
refreshMotoristasEntregaByUf(true);
} }
if (name_item == "estabelecimento") { if (name_item == "estabelecimento") {
@ -1275,6 +1337,7 @@ function removedZoomItem(removedItem) {
$("#gestorEmail").val(""); $("#gestorEmail").val("");
$("#gestor_cc").val(""); $("#gestor_cc").val("");
$("#ufDestino").val(""); $("#ufDestino").val("");
refreshMotoristasEntregaByUf(true);
} else if (name_item == "estabelecimento") { } else if (name_item == "estabelecimento") {
$("#gestorNomeE").val(""); $("#gestorNomeE").val("");
$("#gestorEmailE").val(""); $("#gestorEmailE").val("");

View File

@ -0,0 +1,57 @@
<div style="font-family: Arial, sans-serif; background-color:#f4f6f8; padding:20px;">
<div style="max-width:600px; margin:auto; background:#ffffff; border-radius:8px; overflow:hidden; box-shadow:0 2px 8px rgba(0,0,0,0.1);">
<!-- 🔷 HEADER -->
<div style="background:#0a6d8d; padding:15px; text-align:center; color:#ffffff;">
<h2 style="margin:0;">Transferências Ginseng</h2>
<p style="margin:0; font-size:13px;">Notificação de Processo</p>
</div>
<!-- 📄 BODY -->
<div style="padding:25px; color:#333;">
<h3 style="margin-top:0; color:#0a6d8d;">Nota Fiscal Emitida ✅</h3>
<p>Olá,</p>
<p>
Sua solicitação teve a <b>Nota Fiscal emitida com sucesso</b>.
</p>
<!-- 🔹 CARD INFO -->
<div style="background:#f1f5f9; padding:15px; border-radius:6px; margin:20px 0;">
<p style="margin:5px 0;"><b>Nº Solicitação:</b> ${WKNumProces}</p>
<p style="margin:5px 0;"><b>Chave NFe:</b> ${chaveNfe}</p>
</div>
<p>
Clique no botão abaixo para acessar o processo:
</p>
<!-- 🔘 BOTÃO -->
<div style="text-align:center; margin:25px 0;">
<a href="${linkSolicitacao}"
target="_blank"
style="display:inline-block; background:#0a6d8d; color:#ffffff; padding:12px 20px; text-decoration:none; border-radius:5px; font-weight:bold;">
Acessar Solicitação
</a>
</div>
<p style="font-size:12px; color:#888; margin-top:-10px;">
Se o botao nao abrir, copie e cole este link no navegador:<br/>
<span>${linkSolicitacao}</span>
</p>
<p style="font-size:13px; color:#777;">
Este é um e-mail automático, não responda.
</p>
</div>
<!-- 🔻 FOOTER -->
<div style="background:#f1f5f9; text-align:center; padding:10px; font-size:12px; color:#777;">
© Ginseng
</div>
</div>
</div>

View File

@ -517,8 +517,14 @@
<input type="text" class="form-control transfer-input inputAnexo" name="fdAnexo_Entrega" id="fdAnexo_Entrega" placeholder="Nenhum anexo selecionado" readonly /> <input type="text" class="form-control transfer-input inputAnexo" name="fdAnexo_Entrega" id="fdAnexo_Entrega" placeholder="Nenhum anexo selecionado" readonly />
</div> </div>
</div> </div>
<div class="row">
<div class="col-md-6 col-sm-12">
<label class="transfer-label" for="nomerecebedor">Nome de quem recebeu a mercadoria:</label>
<input type="text" class="form-control transfer-input" name="nomerecebedor" id="nomerecebedor" />
</div>
</div>
</section> </section>
<section class="transfer-card activity activity-18"> <section class="transfer-card activity activity-18">
<h2 class="card-title">Validação do Recebimento</h2> <h2 class="card-title">Validação do Recebimento</h2>
<div class="row" style="margin-top:16px;" id="blocoConferenciaNfe"> <div class="row" style="margin-top:16px;" id="blocoConferenciaNfe">

View File

@ -0,0 +1,44 @@
<div style="font-family: Arial, sans-serif; background-color:#f4f6f8; padding:20px;">
<div style="max-width:600px; margin:auto; background:#ffffff; border-radius:8px; overflow:hidden; box-shadow:0 2px 8px rgba(0,0,0,0.1);">
<div style="background:#0a6d8d; padding:15px; text-align:center; color:#ffffff;">
<h2 style="margin:0;">Transferências Ginseng</h2>
<p style="margin:0; font-size:13px;">Notificação de Processo</p>
</div>
<div style="padding:25px; color:#333;">
<h3 style="margin-top:0; color:#0a6d8d;">Coleta Realizada</h3>
<p>Olá,</p>
<p>O motorista <b>${motoristaColetaNome}</b> coletou o produto na data <b>${dataColeta}</b>.</p>
<p>O motorista <b>${motoristaEntregaNome}</b> irá realizar a entrega.</p>
<div style="background:#f1f5f9; padding:15px; border-radius:6px; margin:20px 0;">
<p style="margin:5px 0;"><b>Nº Solicitação:</b> ${WKNumProces}</p>
<p style="margin:5px 0;"><b>Chave NFe:</b> ${chaveNfe}</p>
</div>
<p>Clique no botão abaixo para acessar o processo:</p>
<div style="text-align:center; margin:25px 0;">
<a href="${linkSolicitacao}"
target="_blank"
style="display:inline-block; background:#0a6d8d; color:#ffffff; padding:12px 20px; text-decoration:none; border-radius:5px; font-weight:bold;">
Acessar Solicitação
</a>
</div>
<p style="font-size:12px; color:#888; margin-top:-10px;">
Se o botão não abrir, copie e cole este link no navegador:<br/>
<span>${linkSolicitacao}</span>
</p>
<p style="font-size:13px; color:#777;">
Este é um e-mail automático, não responda.
</p>
</div>
<div style="background:#f1f5f9; text-align:center; padding:10px; font-size:12px; color:#777;">
© Ginseng
</div>
</div>
</div>

View File

@ -0,0 +1,44 @@
<div style="font-family: Arial, sans-serif; background-color:#f4f6f8; padding:20px;">
<div style="max-width:600px; margin:auto; background:#ffffff; border-radius:8px; overflow:hidden; box-shadow:0 2px 8px rgba(0,0,0,0.1);">
<div style="background:#0a6d8d; padding:15px; text-align:center; color:#ffffff;">
<h2 style="margin:0;">Transferências Ginseng</h2>
<p style="margin:0; font-size:13px;">Notificação de Processo</p>
</div>
<div style="padding:25px; color:#333;">
<h3 style="margin-top:0; color:#0a6d8d;">Entrega Realizada</h3>
<p>Olá,</p>
<p>O motorista <b>${motoristaEntregaNome}</b> entregou a mercadoria na data <b>${dataEntrega}</b>.</p>
<p>Quem recebeu foi: <b>${nomerecebedor}</b>.</p>
<div style="background:#f1f5f9; padding:15px; border-radius:6px; margin:20px 0;">
<p style="margin:5px 0;"><b>Nº Solicitação:</b> ${WKNumProces}</p>
<p style="margin:5px 0;"><b>Chave NFe:</b> ${chaveNfe}</p>
</div>
<p>Clique no botão abaixo para acessar o processo:</p>
<div style="text-align:center; margin:25px 0;">
<a href="${linkSolicitacao}"
target="_blank"
style="display:inline-block; background:#0a6d8d; color:#ffffff; padding:12px 20px; text-decoration:none; border-radius:5px; font-weight:bold;">
Acessar Solicitação
</a>
</div>
<p style="font-size:12px; color:#888; margin-top:-10px;">
Se o botão não abrir, copie e cole este link no navegador:<br/>
<span>${linkSolicitacao}</span>
</p>
<p style="font-size:13px; color:#777;">
Este é um e-mail automático, não responda.
</p>
</div>
<div style="background:#f1f5f9; text-align:center; padding:10px; font-size:12px; color:#777;">
© Ginseng
</div>
</div>
</div>

View File

@ -8,10 +8,10 @@
<instruction>Este flow permite abertura de solicitação de transferências automatizadas, informando qual item será transferido e direcionado para as aprovações corretas.</instruction> <instruction>Este flow permite abertura de solicitação de transferências automatizadas, informando qual item será transferido e direcionado para as aprovações corretas.</instruction>
<active>true</active> <active>true</active>
<publicProcess>false</publicProcess> <publicProcess>false</publicProcess>
<volumeId>Fluig teste</volumeId> <volumeId>Default</volumeId>
<categoryId>Transferência</categoryId> <categoryId>Transferência</categoryId>
<managerEngineAllocationId>Usuário</managerEngineAllocationId> <managerEngineAllocationId>Grupo</managerEngineAllocationId>
<managerEngineAllocationConfiguration>&lt;AssignmentController&gt;&lt;User&gt;projetos&lt;/User&gt;&lt;/AssignmentController&gt;</managerEngineAllocationConfiguration> <managerEngineAllocationConfiguration>&lt;AssignmentController&gt;&lt;Group&gt;CD&lt;/Group&gt;&lt;/AssignmentController&gt;</managerEngineAllocationConfiguration>
<snapshotFrequency>0</snapshotFrequency> <snapshotFrequency>0</snapshotFrequency>
<baseDay>0</baseDay> <baseDay>0</baseDay>
<baseMonth>0</baseMonth> <baseMonth>0</baseMonth>
@ -29,11 +29,10 @@
<processDefinitionVersionPK> <processDefinitionVersionPK>
<companyId>1</companyId> <companyId>1</companyId>
<processId>Transferência Ginseng</processId> <processId>Transferência Ginseng</processId>
<version>46</version> <version>65</version>
</processDefinitionVersionPK> </processDefinitionVersionPK>
<versionDescription></versionDescription> <versionDescription></versionDescription>
<formId>590</formId> <formId>590</formId>
<formIdV2>0</formIdV2>
<editionMode>true</editionMode> <editionMode>true</editionMode>
<updateAttachmentsVersion>true</updateAttachmentsVersion> <updateAttachmentsVersion>true</updateAttachmentsVersion>
<controlsAttachmentsSecurity>false</controlsAttachmentsSecurity> <controlsAttachmentsSecurity>false</controlsAttachmentsSecurity>
@ -127,8 +126,8 @@
<notifyAuthorityFollowUp>true</notifyAuthorityFollowUp> <notifyAuthorityFollowUp>true</notifyAuthorityFollowUp>
<notifyRequisitionerFollowUp>true</notifyRequisitionerFollowUp> <notifyRequisitionerFollowUp>true</notifyRequisitionerFollowUp>
<automatic>false</automatic> <automatic>false</automatic>
<positionX>490</positionX> <positionX>500</positionX>
<positionY>281</positionY> <positionY>280</positionY>
<forecastedEffortType>0</forecastedEffortType> <forecastedEffortType>0</forecastedEffortType>
<forecastedEffort>0</forecastedEffort> <forecastedEffort>0</forecastedEffort>
<notifyManagerFollowUp>false</notifyManagerFollowUp> <notifyManagerFollowUp>false</notifyManagerFollowUp>
@ -179,7 +178,7 @@
<notifyAuthorityFollowUp>true</notifyAuthorityFollowUp> <notifyAuthorityFollowUp>true</notifyAuthorityFollowUp>
<notifyRequisitionerFollowUp>true</notifyRequisitionerFollowUp> <notifyRequisitionerFollowUp>true</notifyRequisitionerFollowUp>
<automatic>false</automatic> <automatic>false</automatic>
<positionX>490</positionX> <positionX>500</positionX>
<positionY>490</positionY> <positionY>490</positionY>
<forecastedEffortType>0</forecastedEffortType> <forecastedEffortType>0</forecastedEffortType>
<forecastedEffort>0</forecastedEffort> <forecastedEffort>0</forecastedEffort>
@ -232,7 +231,7 @@
<notifyRequisitionerFollowUp>true</notifyRequisitionerFollowUp> <notifyRequisitionerFollowUp>true</notifyRequisitionerFollowUp>
<automatic>false</automatic> <automatic>false</automatic>
<positionX>1170</positionX> <positionX>1170</positionX>
<positionY>270</positionY> <positionY>284</positionY>
<forecastedEffortType>0</forecastedEffortType> <forecastedEffortType>0</forecastedEffortType>
<forecastedEffort>0</forecastedEffort> <forecastedEffort>0</forecastedEffort>
<notifyManagerFollowUp>false</notifyManagerFollowUp> <notifyManagerFollowUp>false</notifyManagerFollowUp>
@ -283,7 +282,7 @@
<notifyAuthorityFollowUp>true</notifyAuthorityFollowUp> <notifyAuthorityFollowUp>true</notifyAuthorityFollowUp>
<notifyRequisitionerFollowUp>true</notifyRequisitionerFollowUp> <notifyRequisitionerFollowUp>true</notifyRequisitionerFollowUp>
<automatic>false</automatic> <automatic>false</automatic>
<positionX>1410</positionX> <positionX>1400</positionX>
<positionY>479</positionY> <positionY>479</positionY>
<forecastedEffortType>0</forecastedEffortType> <forecastedEffortType>0</forecastedEffortType>
<forecastedEffort>0</forecastedEffort> <forecastedEffort>0</forecastedEffort>
@ -319,8 +318,7 @@
<deadlineFieldName></deadlineFieldName> <deadlineFieldName></deadlineFieldName>
<joint>false</joint> <joint>false</joint>
<agreementPercentage>0</agreementPercentage> <agreementPercentage>0</agreementPercentage>
<engineAllocationId>Pool Grupo</engineAllocationId> <engineAllocationId></engineAllocationId>
<engineAllocationConfiguration>&lt;AssignmentController&gt;&lt;Group&gt;Motoristas&lt;/Group&gt;&lt;/AssignmentController&gt;</engineAllocationConfiguration>
<selectColleague>1</selectColleague> <selectColleague>1</selectColleague>
<initialState>false</initialState> <initialState>false</initialState>
<notifyAuthorityDelay>false</notifyAuthorityDelay> <notifyAuthorityDelay>false</notifyAuthorityDelay>
@ -439,7 +437,7 @@
<notifyRequisitionerFollowUp>false</notifyRequisitionerFollowUp> <notifyRequisitionerFollowUp>false</notifyRequisitionerFollowUp>
<automatic>false</automatic> <automatic>false</automatic>
<positionX>1600</positionX> <positionX>1600</positionX>
<positionY>260</positionY> <positionY>284</positionY>
<forecastedEffortType>0</forecastedEffortType> <forecastedEffortType>0</forecastedEffortType>
<forecastedEffort>0</forecastedEffort> <forecastedEffort>0</forecastedEffort>
<notifyManagerFollowUp>false</notifyManagerFollowUp> <notifyManagerFollowUp>false</notifyManagerFollowUp>
@ -541,7 +539,7 @@
<notifyRequisitionerFollowUp>false</notifyRequisitionerFollowUp> <notifyRequisitionerFollowUp>false</notifyRequisitionerFollowUp>
<automatic>false</automatic> <automatic>false</automatic>
<positionX>1660</positionX> <positionX>1660</positionX>
<positionY>260</positionY> <positionY>284</positionY>
<forecastedEffortType>0</forecastedEffortType> <forecastedEffortType>0</forecastedEffortType>
<forecastedEffort>0</forecastedEffort> <forecastedEffort>0</forecastedEffort>
<notifyManagerFollowUp>false</notifyManagerFollowUp> <notifyManagerFollowUp>false</notifyManagerFollowUp>
@ -598,8 +596,33 @@
<subProcessId></subProcessId> <subProcessId></subProcessId>
<formFolder>0</formFolder> <formFolder>0</formFolder>
<automatic>true</automatic> <automatic>true</automatic>
<positionX>1430</positionX> <positionX>1420</positionX>
<positionY>250</positionY> <positionY>268</positionY>
<inhibitTransfer>false</inhibitTransfer>
<stateType>1</stateType>
<bpmnType>120</bpmnType>
<signalId>0</signalId>
<openInstances>0</openInstances>
<destinationStates/>
<digitalSignature>false</digitalSignature>
</ProcessState>
<ProcessState>
<processStatePK>
<companyId>1</companyId>
<processId>Transferência Ginseng</processId>
<version>1</version>
<sequence>107</sequence>
</processStatePK>
<stateName>Validar rota</stateName>
<stateDescription>Validar rota</stateDescription>
<joint>false</joint>
<initialState>false</initialState>
<transferAttachments>false</transferAttachments>
<subProcessId></subProcessId>
<formFolder>0</formFolder>
<automatic>true</automatic>
<positionX>520</positionX>
<positionY>663</positionY>
<inhibitTransfer>false</inhibitTransfer> <inhibitTransfer>false</inhibitTransfer>
<stateType>1</stateType> <stateType>1</stateType>
<bpmnType>120</bpmnType> <bpmnType>120</bpmnType>
@ -778,8 +801,8 @@
<notifyAuthorityFollowUp>false</notifyAuthorityFollowUp> <notifyAuthorityFollowUp>false</notifyAuthorityFollowUp>
<notifyRequisitionerFollowUp>false</notifyRequisitionerFollowUp> <notifyRequisitionerFollowUp>false</notifyRequisitionerFollowUp>
<automatic>false</automatic> <automatic>false</automatic>
<positionX>1780</positionX> <positionX>1777</positionX>
<positionY>280</positionY> <positionY>300</positionY>
<forecastedEffortType>0</forecastedEffortType> <forecastedEffortType>0</forecastedEffortType>
<forecastedEffort>0</forecastedEffort> <forecastedEffort>0</forecastedEffort>
<notifyManagerFollowUp>false</notifyManagerFollowUp> <notifyManagerFollowUp>false</notifyManagerFollowUp>
@ -803,7 +826,7 @@
<companyId>1</companyId> <companyId>1</companyId>
<processId>Transferência Ginseng</processId> <processId>Transferência Ginseng</processId>
<expressionOrder>1</expressionOrder> <expressionOrder>1</expressionOrder>
<version>46</version> <version>65</version>
<sequence>2</sequence> <sequence>2</sequence>
</conditionProcessStatePK> </conditionProcessStatePK>
<condition>hAPI.getCardValue(&quot;gestor_cce&quot;) != &quot;&quot;</condition> <condition>hAPI.getCardValue(&quot;gestor_cce&quot;) != &quot;&quot;</condition>
@ -817,7 +840,7 @@
<companyId>1</companyId> <companyId>1</companyId>
<processId>Transferência Ginseng</processId> <processId>Transferência Ginseng</processId>
<expressionOrder>2</expressionOrder> <expressionOrder>2</expressionOrder>
<version>46</version> <version>65</version>
<sequence>2</sequence> <sequence>2</sequence>
</conditionProcessStatePK> </conditionProcessStatePK>
<condition>true</condition> <condition>true</condition>
@ -831,7 +854,7 @@
<companyId>1</companyId> <companyId>1</companyId>
<processId>Transferência Ginseng</processId> <processId>Transferência Ginseng</processId>
<expressionOrder>1</expressionOrder> <expressionOrder>1</expressionOrder>
<version>46</version> <version>65</version>
<sequence>46</sequence> <sequence>46</sequence>
</conditionProcessStatePK> </conditionProcessStatePK>
<condition>hAPI.getCardValue(&quot;validacaoItens&quot;) == &quot;entregue&quot; &amp;&amp; hAPI.getCardValue(&quot;dataEntradaNfeConsulta&quot;) != &quot;&quot;</condition> <condition>hAPI.getCardValue(&quot;validacaoItens&quot;) == &quot;entregue&quot; &amp;&amp; hAPI.getCardValue(&quot;dataEntradaNfeConsulta&quot;) != &quot;&quot;</condition>
@ -843,13 +866,69 @@
<companyId>1</companyId> <companyId>1</companyId>
<processId>Transferência Ginseng</processId> <processId>Transferência Ginseng</processId>
<expressionOrder>2</expressionOrder> <expressionOrder>2</expressionOrder>
<version>46</version> <version>65</version>
<sequence>46</sequence> <sequence>46</sequence>
</conditionProcessStatePK> </conditionProcessStatePK>
<condition>true</condition> <condition>true</condition>
<destinationSequenceId>24</destinationSequenceId> <destinationSequenceId>24</destinationSequenceId>
<conditionType>0</conditionType> <conditionType>0</conditionType>
</ConditionProcessState> </ConditionProcessState>
<ConditionProcessState>
<conditionProcessStatePK>
<companyId>1</companyId>
<processId>Transferência Ginseng</processId>
<expressionOrder>1</expressionOrder>
<version>65</version>
<sequence>107</sequence>
</conditionProcessStatePK>
<condition>hAPI.getCardValue(&quot;ufOrigem&quot;) == &quot;AL&quot;</condition>
<destinationSequenceId>31</destinationSequenceId>
<engineAllocationConfiguration>&lt;AssignmentController&gt;&lt;Group&gt;motoristaAL&lt;/Group&gt;&lt;/AssignmentController&gt;</engineAllocationConfiguration>
<engineAllocationId>Pool Grupo</engineAllocationId>
<conditionType>0</conditionType>
</ConditionProcessState>
<ConditionProcessState>
<conditionProcessStatePK>
<companyId>1</companyId>
<processId>Transferência Ginseng</processId>
<expressionOrder>2</expressionOrder>
<version>65</version>
<sequence>107</sequence>
</conditionProcessStatePK>
<condition>hAPI.getCardValue(&quot;ufOrigem&quot;) == &quot;BA&quot;</condition>
<destinationSequenceId>31</destinationSequenceId>
<engineAllocationConfiguration>&lt;AssignmentController&gt;&lt;Group&gt;motoristaBA&lt;/Group&gt;&lt;/AssignmentController&gt;</engineAllocationConfiguration>
<engineAllocationId>Pool Grupo</engineAllocationId>
<conditionType>0</conditionType>
</ConditionProcessState>
<ConditionProcessState>
<conditionProcessStatePK>
<companyId>1</companyId>
<processId>Transferência Ginseng</processId>
<expressionOrder>3</expressionOrder>
<version>65</version>
<sequence>107</sequence>
</conditionProcessStatePK>
<condition>hAPI.getCardValue(&quot;ufOrigem&quot;) == &quot;SE&quot;</condition>
<destinationSequenceId>31</destinationSequenceId>
<engineAllocationConfiguration>&lt;AssignmentController&gt;&lt;Group&gt;motoristaSE&lt;/Group&gt;&lt;/AssignmentController&gt;</engineAllocationConfiguration>
<engineAllocationId>Pool Grupo</engineAllocationId>
<conditionType>0</conditionType>
</ConditionProcessState>
<ConditionProcessState>
<conditionProcessStatePK>
<companyId>1</companyId>
<processId>Transferência Ginseng</processId>
<expressionOrder>4</expressionOrder>
<version>65</version>
<sequence>107</sequence>
</conditionProcessStatePK>
<condition>hAPI.getCardValue(&quot;ufOrigem&quot;) == &quot;&quot;</condition>
<destinationSequenceId>31</destinationSequenceId>
<engineAllocationConfiguration>&lt;AssignmentController&gt;&lt;Group&gt;CD&lt;/Group&gt;&lt;/AssignmentController&gt;</engineAllocationConfiguration>
<engineAllocationId>Pool Grupo</engineAllocationId>
<conditionType>0</conditionType>
</ConditionProcessState>
</list> </list>
<list> <list>
<ProcessLink> <ProcessLink>
@ -913,12 +992,12 @@
<version>1</version> <version>1</version>
<linkSequence>26</linkSequence> <linkSequence>26</linkSequence>
</processLinkPK> </processLinkPK>
<actionLabel></actionLabel> <actionLabel>Ajuste realizado</actionLabel>
<returnPermited>false</returnPermited> <returnPermited>false</returnPermited>
<initialStateSequence>24</initialStateSequence> <initialStateSequence>24</initialStateSequence>
<finalStateSequence>18</finalStateSequence> <finalStateSequence>18</finalStateSequence>
<returnLabel></returnLabel> <returnLabel></returnLabel>
<name></name> <name>Ajuste de transferência</name>
<automaticLink>false</automaticLink> <automaticLink>false</automaticLink>
<defaultLink>false</defaultLink> <defaultLink>false</defaultLink>
<type>0</type> <type>0</type>
@ -947,12 +1026,12 @@
<version>1</version> <version>1</version>
<linkSequence>47</linkSequence> <linkSequence>47</linkSequence>
</processLinkPK> </processLinkPK>
<actionLabel></actionLabel> <actionLabel>Confirmar recebimento</actionLabel>
<returnPermited>false</returnPermited> <returnPermited>false</returnPermited>
<initialStateSequence>18</initialStateSequence> <initialStateSequence>18</initialStateSequence>
<finalStateSequence>46</finalStateSequence> <finalStateSequence>46</finalStateSequence>
<returnLabel></returnLabel> <returnLabel></returnLabel>
<name></name> <name>Confirmar recebimento</name>
<automaticLink>false</automaticLink> <automaticLink>false</automaticLink>
<defaultLink>false</defaultLink> <defaultLink>false</defaultLink>
<type>0</type> <type>0</type>
@ -1015,7 +1094,7 @@
<version>1</version> <version>1</version>
<linkSequence>85</linkSequence> <linkSequence>85</linkSequence>
</processLinkPK> </processLinkPK>
<actionLabel>Produtos entregue</actionLabel> <actionLabel>Transferência entregue</actionLabel>
<returnPermited>false</returnPermited> <returnPermited>false</returnPermited>
<initialStateSequence>57</initialStateSequence> <initialStateSequence>57</initialStateSequence>
<finalStateSequence>18</finalStateSequence> <finalStateSequence>18</finalStateSequence>
@ -1025,23 +1104,6 @@
<defaultLink>false</defaultLink> <defaultLink>false</defaultLink>
<type>0</type> <type>0</type>
</ProcessLink> </ProcessLink>
<ProcessLink>
<processLinkPK>
<companyId>1</companyId>
<processId>Transferência Ginseng</processId>
<version>1</version>
<linkSequence>95</linkSequence>
</processLinkPK>
<actionLabel>Enviar para coleta</actionLabel>
<returnPermited>false</returnPermited>
<initialStateSequence>68</initialStateSequence>
<finalStateSequence>31</finalStateSequence>
<returnLabel></returnLabel>
<name>Enviar para coleta</name>
<automaticLink>false</automaticLink>
<defaultLink>false</defaultLink>
<type>0</type>
</ProcessLink>
<ProcessLink> <ProcessLink>
<processLinkPK> <processLinkPK>
<companyId>1</companyId> <companyId>1</companyId>
@ -1066,12 +1128,12 @@
<version>1</version> <version>1</version>
<linkSequence>98</linkSequence> <linkSequence>98</linkSequence>
</processLinkPK> </processLinkPK>
<actionLabel></actionLabel> <actionLabel>Pedido coletado</actionLabel>
<returnPermited>false</returnPermited> <returnPermited>false</returnPermited>
<initialStateSequence>31</initialStateSequence> <initialStateSequence>31</initialStateSequence>
<finalStateSequence>57</finalStateSequence> <finalStateSequence>57</finalStateSequence>
<returnLabel></returnLabel> <returnLabel></returnLabel>
<name></name> <name>Entregar produto</name>
<automaticLink>false</automaticLink> <automaticLink>false</automaticLink>
<defaultLink>false</defaultLink> <defaultLink>false</defaultLink>
<type>0</type> <type>0</type>
@ -1144,9 +1206,292 @@
<defaultLink>false</defaultLink> <defaultLink>false</defaultLink>
<type>0</type> <type>0</type>
</ProcessLink> </ProcessLink>
<ProcessLink>
<processLinkPK>
<companyId>1</companyId>
<processId>Transferência Ginseng</processId>
<version>1</version>
<linkSequence>108</linkSequence>
</processLinkPK>
<actionLabel>Enviar para coleta</actionLabel>
<returnPermited>false</returnPermited>
<initialStateSequence>6</initialStateSequence>
<finalStateSequence>107</finalStateSequence>
<returnLabel></returnLabel>
<name>Enviar para rota</name>
<automaticLink>false</automaticLink>
<defaultLink>false</defaultLink>
<type>0</type>
</ProcessLink>
<ProcessLink>
<processLinkPK>
<companyId>1</companyId>
<processId>Transferência Ginseng</processId>
<version>1</version>
<linkSequence>109</linkSequence>
</processLinkPK>
<actionLabel></actionLabel>
<returnPermited>false</returnPermited>
<initialStateSequence>107</initialStateSequence>
<finalStateSequence>31</finalStateSequence>
<returnLabel></returnLabel>
<name></name>
<automaticLink>false</automaticLink>
<defaultLink>false</defaultLink>
<type>0</type>
</ProcessLink>
</list> </list>
<list/> <list/>
<list> <list>
<WorkflowProcessEvent>
<workflowProcessEventPK>
<companyId>1</companyId>
<eventId>beforeTaskSave</eventId>
<processId>Transferência Ginseng</processId>
<version>1</version>
</workflowProcessEventPK>
<eventDescription>function beforeTaskSave(colleagueId, nextSequenceId, userList) {
try {
var currentState = parseInt(getValue(&quot;WKNumState&quot;), 10);
var completeTask = String(getValue(&quot;WKCompletTask&quot;) || &quot;false&quot;);
var nextState = parseInt(String(nextSequenceId || &quot;0&quot;), 10);
if (completeTask !== &quot;true&quot;) return;
if (currentState === 6) {
// Fluxo de cancelamento saindo da atividade 6 nao deve disparar template de nota emitida.
if (nextState === 97) return;
enviarNotificacaoNotaEmitida();
return;
}
if (currentState === 31) {
enviarNotificacaoColetaRealizada();
return;
}
if (currentState === 57) {
// 61 = cancelamento no diagrama.
if (nextState === 61) return;
enviarNotificacaoEntregaRealizada();
}
} catch (e) {
log.error(&quot;[Transferencia.beforeTaskSave] Erro no beforeTaskSave: &quot; + e);
}
}
function enviarNotificacaoNotaEmitida() {
var envio = montarContextoEnvio();
if (!envio.ok) return;
var params = buildCommonParams(envio.processNumber, envio.chaveNfe, envio.processLink);
notifyTemplate(&quot;tpl_nota_emitida&quot;, envio.destinoEmail, envio.requesterId, params, envio.processNumber, envio.processLink);
}
function enviarNotificacaoColetaRealizada() {
var envio = montarContextoEnvio();
if (!envio.ok) return;
var motoristaColetaNome = safeTrim(hAPI.getCardValue(&quot;motoristaColetaNome&quot;));
var dataColeta = safeTrim(hAPI.getCardValue(&quot;dataColeta&quot;));
var motoristaEntregaNome = safeTrim(hAPI.getCardValue(&quot;motoristaEntregaNome&quot;));
var tipoMotoristaEntrega = safeTrim(hAPI.getCardValue(&quot;tipoMotoristaEntrega&quot;));
if (motoristaEntregaNome === &quot;&quot; &amp;&amp; tipoMotoristaEntrega === &quot;mesmo&quot;) {
motoristaEntregaNome = motoristaColetaNome;
}
var params = buildCommonParams(envio.processNumber, envio.chaveNfe, envio.processLink);
params.put(&quot;motoristaColetaNome&quot;, motoristaColetaNome);
params.put(&quot;dataColeta&quot;, dataColeta);
params.put(&quot;motoristaEntregaNome&quot;, motoristaEntregaNome);
notifyTemplate(&quot;tpl_coleta_realizada&quot;, envio.destinoEmail, envio.requesterId, params, envio.processNumber, envio.processLink);
}
function enviarNotificacaoEntregaRealizada() {
var envio = montarContextoEnvio();
if (!envio.ok) return;
var motoristaEntregaNome = safeTrim(hAPI.getCardValue(&quot;motoristaEntregaNome&quot;));
var dataEntrega = safeTrim(hAPI.getCardValue(&quot;dataEntrega&quot;));
var nomerecebedor = safeTrim(hAPI.getCardValue(&quot;nomerecebedor&quot;));
var params = buildCommonParams(envio.processNumber, envio.chaveNfe, envio.processLink);
params.put(&quot;motoristaEntregaNome&quot;, motoristaEntregaNome);
params.put(&quot;dataEntrega&quot;, dataEntrega);
params.put(&quot;nomerecebedor&quot;, nomerecebedor);
notifyTemplate(&quot;tpl_entrega_realizada&quot;, envio.destinoEmail, envio.requesterId, params, envio.processNumber, envio.processLink);
}
function montarContextoEnvio() {
var requesterId = safeTrim(hAPI.getCardValue(&quot;requesterId&quot;));
var requesterMail = safeTrim(hAPI.getCardValue(&quot;requesterMail&quot;));
if (requesterId === &quot;&quot; &amp;&amp; requesterMail !== &quot;&quot;) {
requesterId = findColleagueIdByMail(requesterMail);
}
// Prioriza email explicito salvo no formulario; fallback para email do colleague.
var destinoEmail = requesterMail;
if (!isValidEmail(destinoEmail)) {
destinoEmail = resolveEmailByColleagueId(requesterId);
}
if (!isValidEmail(destinoEmail)) {
log.warn(&quot;[Transferencia.beforeTaskSave] Email do solicitante invalido. requesterId=&quot; + requesterId + &quot;, requesterMail=[&quot; + requesterMail + &quot;], destinoEmail=[&quot; + destinoEmail + &quot;]&quot;);
return { ok: false };
}
var processNumber = safeTrim(getValue(&quot;WKNumProces&quot;));
var chaveNfe = onlyDigits(hAPI.getCardValue(&quot;chaveNfe&quot;));
if (chaveNfe === &quot;&quot;) chaveNfe = safeTrim(hAPI.getCardValue(&quot;chaveNfe&quot;));
var processLink = buildProcessLink(processNumber);
return {
ok: true,
requesterId: requesterId,
destinoEmail: destinoEmail,
processNumber: processNumber,
chaveNfe: chaveNfe,
processLink: processLink
};
}
function buildCommonParams(processNumber, chaveNfe, processLink) {
var params = new java.util.HashMap();
params.put(&quot;WKNumProces&quot;, processNumber);
params.put(&quot;chaveNfe&quot;, chaveNfe);
params.put(&quot;linkSolicitacao&quot;, processLink);
params.put(&quot;link&quot;, processLink);
return params;
}
function notifyTemplate(templateCode, destinoEmail, requesterId, params, processNumber, processLink) {
var NOTIFIER_SENDER_USER = &quot;admin&quot;;
var recipients = new java.util.ArrayList();
recipients.add(destinoEmail);
notifier.notify(NOTIFIER_SENDER_USER, templateCode, params, recipients, &quot;text/html&quot;);
log.info(&quot;[Transferencia.beforeTaskSave] &quot; + templateCode + &quot; enviado. processo=&quot; + processNumber + &quot;, destino=&quot; + destinoEmail + &quot;, requesterId=&quot; + requesterId + &quot;, link=[&quot; + processLink + &quot;]&quot;);
}
function buildProcessLink(processNumber) {
var BASE_URL_FALLBACK = &quot;https://comerciode188007.fluig.cloudtotvs.com.br&quot;;
var baseUrl = safeTrim(getValue(&quot;WKServerURL&quot;));
var companyId = safeTrim(getValue(&quot;WKCompany&quot;));
if (baseUrl === &quot;&quot;) baseUrl = BASE_URL_FALLBACK;
if (baseUrl.indexOf(&quot;http://&quot;) !== 0 &amp;&amp; baseUrl.indexOf(&quot;https://&quot;) !== 0) {
baseUrl = &quot;https://&quot; + baseUrl;
}
if (baseUrl.charAt(baseUrl.length - 1) === &quot;/&quot;) baseUrl = baseUrl.substring(0, baseUrl.length - 1);
if (companyId === &quot;&quot;) companyId = &quot;1&quot;;
if (baseUrl === &quot;&quot; || safeTrim(processNumber) === &quot;&quot;) return &quot;&quot;;
return baseUrl + &quot;/portal/p/&quot; + companyId + &quot;/pageworkflowview?app_ecm_workflowview_detailsProcessInstanceID=&quot; + processNumber;
}
function findColleagueIdByMail(mail) {
var email = safeTrim(mail);
if (email === &quot;&quot;) return &quot;&quot;;
try {
var cMail = DatasetFactory.createConstraint(&quot;mail&quot;, email, email, ConstraintType.MUST);
var dsColleague = DatasetFactory.getDataset(&quot;colleague&quot;, null, [cMail], null);
if (!dsColleague || dsColleague.rowsCount &lt; 1) return &quot;&quot;;
return safeTrim(
dsColleague.getValue(0, &quot;colleaguePK.colleagueId&quot;) ||
dsColleague.getValue(0, &quot;colleagueId&quot;) ||
dsColleague.getValue(0, &quot;login&quot;)
);
} catch (e) {
log.warn(&quot;[Transferencia.beforeTaskSave] Falha ao buscar solicitante por mail: &quot; + e);
return &quot;&quot;;
}
}
function resolveEmailByColleagueId(colleagueId) {
var id = safeTrim(colleagueId);
if (id === &quot;&quot;) return &quot;&quot;;
try {
var cActive = DatasetFactory.createConstraint(&quot;active&quot;, &quot;true&quot;, &quot;true&quot;, ConstraintType.MUST);
var cId = DatasetFactory.createConstraint(&quot;colleaguePK.colleagueId&quot;, id, id, ConstraintType.MUST);
var byId = DatasetFactory.getDataset(&quot;colleague&quot;, null, [cId, cActive], null);
if (byId &amp;&amp; byId.rowsCount &gt; 0) {
return safeTrim(byId.getValue(0, &quot;mail&quot;));
}
var cLogin = DatasetFactory.createConstraint(&quot;login&quot;, id, id, ConstraintType.MUST);
var byLogin = DatasetFactory.getDataset(&quot;colleague&quot;, null, [cLogin, cActive], null);
if (byLogin &amp;&amp; byLogin.rowsCount &gt; 0) {
return safeTrim(byLogin.getValue(0, &quot;mail&quot;));
}
} catch (e) {
log.warn(&quot;[Transferencia.beforeTaskSave] Falha ao buscar email do solicitante por colleagueId: &quot; + e);
}
return &quot;&quot;;
}
function isValidEmail(email) {
var v = safeTrim(email);
if (v === &quot;&quot;) return false;
if (/\s/.test(v)) return false;
var at = v.indexOf(&quot;@&quot;);
if (at &lt;= 0 || at !== v.lastIndexOf(&quot;@&quot;)) return false;
var dot = v.lastIndexOf(&quot;.&quot;);
return dot &gt; at + 1 &amp;&amp; dot &lt; (v.length - 1);
}
function safeTrim(value) {
return String(value == null ? &quot;&quot; : value).trim();
}
function onlyDigits(value) {
return String(value == null ? &quot;&quot; : value).replace(/\D/g, &quot;&quot;);
}
</eventDescription>
</WorkflowProcessEvent>
<WorkflowProcessEvent>
<workflowProcessEventPK>
<companyId>1</companyId>
<eventId>onNotify</eventId>
<processId>Transferência Ginseng</processId>
<version>1</version>
</workflowProcessEventPK>
<eventDescription>function onNotify(subject, receivers, template, params) {&#xd;
&#xd;
log.info(&quot;===== onNotify GLOBAL ===== Template: &quot; + template);&#xd;
&#xd;
var validos = new java.util.ArrayList();&#xd;
&#xd;
for (var i = 0; i &lt; receivers.size(); i++) {&#xd;
&#xd;
var email = receivers.get(i);&#xd;
&#xd;
log.info(&quot;Receiver original: [&quot; + email + &quot;]&quot;);&#xd;
&#xd;
if (email &amp;&amp; email.indexOf(&quot;@&quot;) &gt; 0 &amp;&amp; email.indexOf(&quot;.&quot;) &gt; 0) {&#xd;
validos.add(email);&#xd;
} else {&#xd;
log.warn(&quot;REMOVIDO EMAIL INVALIDO: [&quot; + email + &quot;] TEMPLATE: &quot; + template);&#xd;
}&#xd;
}&#xd;
&#xd;
receivers.clear();&#xd;
&#xd;
for (var j = 0; j &lt; validos.size(); j++) {&#xd;
receivers.add(validos.get(j));&#xd;
}&#xd;
&#xd;
log.info(&quot;TOTAL FINAL RECEIVERS: &quot; + receivers.size());&#xd;
}</eventDescription>
</WorkflowProcessEvent>
<WorkflowProcessEvent> <WorkflowProcessEvent>
<workflowProcessEventPK> <workflowProcessEventPK>
<companyId>1</companyId> <companyId>1</companyId>
@ -1154,54 +1499,54 @@
<processId>Transferência Ginseng</processId> <processId>Transferência Ginseng</processId>
<version>1</version> <version>1</version>
</workflowProcessEventPK> </workflowProcessEventPK>
<eventDescription>function servicetask99(attempt, message) {&#xd; <eventDescription>function servicetask99(attempt, message) {
try {&#xd; try {
var validacaoItens = safeTrim(hAPI.getCardValue(&quot;validacaoItens&quot;));&#xd; var validacaoItens = safeTrim(hAPI.getCardValue(&quot;validacaoItens&quot;));
&#xd;
// Só precisa consultar entrada da NFe quando o recebimento foi validado como entregue.&#xd; // Só precisa consultar entrada da NFe quando o recebimento foi validado como entregue.
if (validacaoItens !== &quot;entregue&quot;) return;&#xd; if (validacaoItens !== &quot;entregue&quot;) return;
&#xd;
var dataEntrada = safeTrim(hAPI.getCardValue(&quot;dataEntradaNfeConsulta&quot;));&#xd; var dataEntrada = safeTrim(hAPI.getCardValue(&quot;dataEntradaNfeConsulta&quot;));
if (dataEntrada !== &quot;&quot;) return;&#xd; if (dataEntrada !== &quot;&quot;) return;
&#xd;
var chaveNfe = onlyDigits(hAPI.getCardValue(&quot;chaveNfe&quot;));&#xd; var chaveNfe = onlyDigits(hAPI.getCardValue(&quot;chaveNfe&quot;));
if (chaveNfe === &quot;&quot;) {&#xd; if (chaveNfe === &quot;&quot;) {
log.warn(&quot;[servicetask99] Chave NFe vazia. Nao foi possivel consultar entrada.&quot;);&#xd; log.warn(&quot;[servicetask99] Chave NFe vazia. Nao foi possivel consultar entrada.&quot;);
return;&#xd; return;
}&#xd; }
&#xd;
var cKey = DatasetFactory.createConstraint(&quot;key&quot;, chaveNfe, chaveNfe, ConstraintType.MUST);&#xd; var cKey = DatasetFactory.createConstraint(&quot;key&quot;, chaveNfe, chaveNfe, ConstraintType.MUST);
var dsNfe = DatasetFactory.getDataset(&quot;ds_fiscal_invoice_by_keys&quot;, null, [cKey], null);&#xd; var dsNfe = DatasetFactory.getDataset(&quot;ds_fiscal_invoice_by_keys&quot;, null, [cKey], null);
&#xd;
if (!dsNfe || dsNfe.rowsCount &lt; 1) {&#xd; if (!dsNfe || dsNfe.rowsCount &lt; 1) {
log.warn(&quot;[servicetask99] Dataset sem retorno para chave: &quot; + chaveNfe);&#xd; log.warn(&quot;[servicetask99] Dataset sem retorno para chave: &quot; + chaveNfe);
return;&#xd; return;
}&#xd; }
&#xd;
var dsSuccess = safeTrim(dsNfe.getValue(0, &quot;success&quot;)).toLowerCase() === &quot;true&quot;;&#xd; var dsSuccess = safeTrim(dsNfe.getValue(0, &quot;success&quot;)).toLowerCase() === &quot;true&quot;;
var dsUpdatedAt = safeTrim(dsNfe.getValue(0, &quot;updatedAt&quot;));&#xd; var dsUpdatedAt = safeTrim(dsNfe.getValue(0, &quot;updatedAt&quot;));
&#xd;
if (dsSuccess &amp;&amp; dsUpdatedAt !== &quot;&quot;) {&#xd; if (dsSuccess &amp;&amp; dsUpdatedAt !== &quot;&quot;) {
hAPI.setCardValue(&quot;dataEntradaNfeConsulta&quot;, dsUpdatedAt);&#xd; hAPI.setCardValue(&quot;dataEntradaNfeConsulta&quot;, dsUpdatedAt);
log.info(&quot;[servicetask99] Data de entrada atualizada automaticamente: &quot; + dsUpdatedAt);&#xd; log.info(&quot;[servicetask99] Data de entrada atualizada automaticamente: &quot; + dsUpdatedAt);
return;&#xd; return;
}&#xd; }
&#xd;
var dsMessage = safeTrim(dsNfe.getValue(0, &quot;message&quot;));&#xd; var dsMessage = safeTrim(dsNfe.getValue(0, &quot;message&quot;));
log.warn(&quot;[servicetask99] Consulta executada sem data de entrada. message=&quot; + dsMessage);&#xd; log.warn(&quot;[servicetask99] Consulta executada sem data de entrada. message=&quot; + dsMessage);
} catch (e) {&#xd; } catch (e) {
log.error(&quot;[servicetask99] Erro na consulta automatica da NFe: &quot; + e);&#xd; log.error(&quot;[servicetask99] Erro na consulta automatica da NFe: &quot; + e);
throw e;&#xd; throw e;
}&#xd; }
}&#xd; }
&#xd;
function safeTrim(value) {&#xd; function safeTrim(value) {
return String(value == null ? &quot;&quot; : value).trim();&#xd; return String(value == null ? &quot;&quot; : value).trim();
}&#xd; }
&#xd;
function onlyDigits(value) {&#xd; function onlyDigits(value) {
return String(value == null ? &quot;&quot; : value).replace(/\D/g, &quot;&quot;);&#xd; return String(value == null ? &quot;&quot; : value).replace(/\D/g, &quot;&quot;);
}&#xd; }
</eventDescription> </eventDescription>
</WorkflowProcessEvent> </WorkflowProcessEvent>
</list> </list>
@ -1210,7 +1555,7 @@ function onlyDigits(value) {&#xd;
<SwimLane> <SwimLane>
<color>FFFFFF</color> <color>FFFFFF</color>
<height>794</height> <height>794</height>
<width>1791</width> <width>1861</width>
<positionX>20</positionX> <positionX>20</positionX>
<positionY>20</positionY> <positionY>20</positionY>
<stateName>Solicitação de Transferência</stateName> <stateName>Solicitação de Transferência</stateName>
@ -1226,7 +1571,7 @@ function onlyDigits(value) {&#xd;
<SwimLane> <SwimLane>
<color>82b0b7</color> <color>82b0b7</color>
<height>198</height> <height>198</height>
<width>1761</width> <width>1831</width>
<positionX>50</positionX> <positionX>50</positionX>
<positionY>218</positionY> <positionY>218</positionY>
<stateName>Gerente de loja</stateName> <stateName>Gerente de loja</stateName>
@ -1242,7 +1587,7 @@ function onlyDigits(value) {&#xd;
<SwimLane> <SwimLane>
<color>d0daae</color> <color>d0daae</color>
<height>198</height> <height>198</height>
<width>1761</width> <width>1831</width>
<positionX>50</positionX> <positionX>50</positionX>
<positionY>416</positionY> <positionY>416</positionY>
<stateName>Logistica</stateName> <stateName>Logistica</stateName>
@ -1258,7 +1603,7 @@ function onlyDigits(value) {&#xd;
<SwimLane> <SwimLane>
<color>d6e0d0</color> <color>d6e0d0</color>
<height>198</height> <height>198</height>
<width>1761</width> <width>1831</width>
<positionX>50</positionX> <positionX>50</positionX>
<positionY>20</positionY> <positionY>20</positionY>
<stateName>Analista de suprimentos</stateName> <stateName>Analista de suprimentos</stateName>
@ -1274,7 +1619,7 @@ function onlyDigits(value) {&#xd;
<SwimLane> <SwimLane>
<color>adc9ac</color> <color>adc9ac</color>
<height>200</height> <height>200</height>
<width>1761</width> <width>1831</width>
<positionX>50</positionX> <positionX>50</positionX>
<positionY>614</positionY> <positionY>614</positionY>
<stateName>Motorista</stateName> <stateName>Motorista</stateName>
@ -1295,7 +1640,7 @@ function onlyDigits(value) {&#xd;
<processLinkBendPK> <processLinkBendPK>
<companyId>1</companyId> <companyId>1</companyId>
<processId>Transferência Ginseng</processId> <processId>Transferência Ginseng</processId>
<version>46</version> <version>65</version>
<linkSequence>5</linkSequence> <linkSequence>5</linkSequence>
<bendSequence>1</bendSequence> <bendSequence>1</bendSequence>
</processLinkBendPK> </processLinkBendPK>
@ -1306,7 +1651,7 @@ function onlyDigits(value) {&#xd;
<processLinkBendPK> <processLinkBendPK>
<companyId>1</companyId> <companyId>1</companyId>
<processId>Transferência Ginseng</processId> <processId>Transferência Ginseng</processId>
<version>46</version> <version>65</version>
<linkSequence>5</linkSequence> <linkSequence>5</linkSequence>
<bendSequence>2</bendSequence> <bendSequence>2</bendSequence>
</processLinkBendPK> </processLinkBendPK>
@ -1317,7 +1662,7 @@ function onlyDigits(value) {&#xd;
<processLinkBendPK> <processLinkBendPK>
<companyId>1</companyId> <companyId>1</companyId>
<processId>Transferência Ginseng</processId> <processId>Transferência Ginseng</processId>
<version>46</version> <version>65</version>
<linkSequence>7</linkSequence> <linkSequence>7</linkSequence>
<bendSequence>1</bendSequence> <bendSequence>1</bendSequence>
</processLinkBendPK> </processLinkBendPK>
@ -1328,7 +1673,7 @@ function onlyDigits(value) {&#xd;
<processLinkBendPK> <processLinkBendPK>
<companyId>1</companyId> <companyId>1</companyId>
<processId>Transferência Ginseng</processId> <processId>Transferência Ginseng</processId>
<version>46</version> <version>65</version>
<linkSequence>26</linkSequence> <linkSequence>26</linkSequence>
<bendSequence>1</bendSequence> <bendSequence>1</bendSequence>
</processLinkBendPK> </processLinkBendPK>
@ -1339,7 +1684,7 @@ function onlyDigits(value) {&#xd;
<processLinkBendPK> <processLinkBendPK>
<companyId>1</companyId> <companyId>1</companyId>
<processId>Transferência Ginseng</processId> <processId>Transferência Ginseng</processId>
<version>46</version> <version>65</version>
<linkSequence>61</linkSequence> <linkSequence>61</linkSequence>
<bendSequence>1</bendSequence> <bendSequence>1</bendSequence>
</processLinkBendPK> </processLinkBendPK>
@ -1350,37 +1695,17 @@ function onlyDigits(value) {&#xd;
<processLinkBendPK> <processLinkBendPK>
<companyId>1</companyId> <companyId>1</companyId>
<processId>Transferência Ginseng</processId> <processId>Transferência Ginseng</processId>
<version>46</version> <version>65</version>
<linkSequence>85</linkSequence> <linkSequence>85</linkSequence>
<bendSequence>1</bendSequence> <bendSequence>1</bendSequence>
</processLinkBendPK> </processLinkBendPK>
<positionX>1149</positionX> <positionX>1149</positionX>
<positionY>308</positionY> <positionY>308</positionY>
</ProcessLinkBend> </ProcessLinkBend>
<ProcessLinkBend>
<processLinkBendPK>
<companyId>1</companyId>
<processId>Transferência Ginseng</processId>
<version>46</version>
<linkSequence>95</linkSequence>
<bendSequence>1</bendSequence>
</processLinkBendPK>
<positionX>543</positionX>
<positionY>717</positionY>
</ProcessLinkBend>
</list> </list>
<list/> <list/>
<list/> <list/>
<list> <list>
<ProcessFormField>
<processFormFieldPK>
<companyId>1</companyId>
<processId>Transferência Ginseng</processId>
<fieldId>anexo_lista1</fieldId>
</processFormFieldPK>
<fieldDescription>Nome do arquivo</fieldDescription>
<slotId>1</slotId>
</ProcessFormField>
<ProcessFormField> <ProcessFormField>
<processFormFieldPK> <processFormFieldPK>
<companyId>1</companyId> <companyId>1</companyId>
@ -1388,7 +1713,7 @@ function onlyDigits(value) {&#xd;
<fieldId>centroCusto</fieldId> <fieldId>centroCusto</fieldId>
</processFormFieldPK> </processFormFieldPK>
<fieldDescription>Filial Destino</fieldDescription> <fieldDescription>Filial Destino</fieldDescription>
<slotId>2</slotId> <slotId>1</slotId>
</ProcessFormField> </ProcessFormField>
<ProcessFormField> <ProcessFormField>
<processFormFieldPK> <processFormFieldPK>
@ -1397,6 +1722,15 @@ function onlyDigits(value) {&#xd;
<fieldId>dataAbertura</fieldId> <fieldId>dataAbertura</fieldId>
</processFormFieldPK> </processFormFieldPK>
<fieldDescription>Data de abertura</fieldDescription> <fieldDescription>Data de abertura</fieldDescription>
<slotId>2</slotId>
</ProcessFormField>
<ProcessFormField>
<processFormFieldPK>
<companyId>1</companyId>
<processId>Transferência Ginseng</processId>
<fieldId>dataEmissaoNfe</fieldId>
</processFormFieldPK>
<fieldDescription>dataEmissaoNfe</fieldDescription>
<slotId>3</slotId> <slotId>3</slotId>
</ProcessFormField> </ProcessFormField>
<ProcessFormField> <ProcessFormField>
@ -1421,9 +1755,9 @@ function onlyDigits(value) {&#xd;
<processFormFieldPK> <processFormFieldPK>
<companyId>1</companyId> <companyId>1</companyId>
<processId>Transferência Ginseng</processId> <processId>Transferência Ginseng</processId>
<fieldId>userSolicitante</fieldId> <fieldId>requesterName</fieldId>
</processFormFieldPK> </processFormFieldPK>
<fieldDescription>Solicitante</fieldDescription> <fieldDescription>requesterName</fieldDescription>
<slotId>6</slotId> <slotId>6</slotId>
</ProcessFormField> </ProcessFormField>
</list> </list>
@ -1446,7 +1780,7 @@ function onlyDigits(value) {&#xd;
<id>0</id> <id>0</id>
<tenantId>0</tenantId> <tenantId>0</tenantId>
<processId>Transferência Ginseng</processId> <processId>Transferência Ginseng</processId>
<processVersion>46</processVersion> <processVersion>65</processVersion>
<stateSequence>4</stateSequence> <stateSequence>4</stateSequence>
<appKey>approval</appKey> <appKey>approval</appKey>
<appField>title</appField> <appField>title</appField>
@ -1456,7 +1790,7 @@ function onlyDigits(value) {&#xd;
<id>0</id> <id>0</id>
<tenantId>0</tenantId> <tenantId>0</tenantId>
<processId>Transferência Ginseng</processId> <processId>Transferência Ginseng</processId>
<processVersion>46</processVersion> <processVersion>65</processVersion>
<stateSequence>4</stateSequence> <stateSequence>4</stateSequence>
<appKey>approval</appKey> <appKey>approval</appKey>
<appField>description</appField> <appField>description</appField>
@ -1466,7 +1800,7 @@ function onlyDigits(value) {&#xd;
<id>0</id> <id>0</id>
<tenantId>0</tenantId> <tenantId>0</tenantId>
<processId>Transferência Ginseng</processId> <processId>Transferência Ginseng</processId>
<processVersion>46</processVersion> <processVersion>65</processVersion>
<stateSequence>4</stateSequence> <stateSequence>4</stateSequence>
<appKey>approval</appKey> <appKey>approval</appKey>
<appField>highlight</appField> <appField>highlight</appField>
@ -1476,7 +1810,7 @@ function onlyDigits(value) {&#xd;
<id>0</id> <id>0</id>
<tenantId>0</tenantId> <tenantId>0</tenantId>
<processId>Transferência Ginseng</processId> <processId>Transferência Ginseng</processId>
<processVersion>46</processVersion> <processVersion>65</processVersion>
<stateSequence>4</stateSequence> <stateSequence>4</stateSequence>
<appKey>approval</appKey> <appKey>approval</appKey>
<appField>approve</appField> <appField>approve</appField>
@ -1486,7 +1820,7 @@ function onlyDigits(value) {&#xd;
<id>0</id> <id>0</id>
<tenantId>0</tenantId> <tenantId>0</tenantId>
<processId>Transferência Ginseng</processId> <processId>Transferência Ginseng</processId>
<processVersion>46</processVersion> <processVersion>65</processVersion>
<stateSequence>4</stateSequence> <stateSequence>4</stateSequence>
<appKey>approval</appKey> <appKey>approval</appKey>
<appField>reject</appField> <appField>reject</appField>
@ -1496,7 +1830,7 @@ function onlyDigits(value) {&#xd;
<id>0</id> <id>0</id>
<tenantId>0</tenantId> <tenantId>0</tenantId>
<processId>Transferência Ginseng</processId> <processId>Transferência Ginseng</processId>
<processVersion>46</processVersion> <processVersion>65</processVersion>
<stateSequence>6</stateSequence> <stateSequence>6</stateSequence>
<appKey>approval</appKey> <appKey>approval</appKey>
<appField>title</appField> <appField>title</appField>
@ -1506,7 +1840,7 @@ function onlyDigits(value) {&#xd;
<id>0</id> <id>0</id>
<tenantId>0</tenantId> <tenantId>0</tenantId>
<processId>Transferência Ginseng</processId> <processId>Transferência Ginseng</processId>
<processVersion>46</processVersion> <processVersion>65</processVersion>
<stateSequence>6</stateSequence> <stateSequence>6</stateSequence>
<appKey>approval</appKey> <appKey>approval</appKey>
<appField>description</appField> <appField>description</appField>
@ -1516,7 +1850,7 @@ function onlyDigits(value) {&#xd;
<id>0</id> <id>0</id>
<tenantId>0</tenantId> <tenantId>0</tenantId>
<processId>Transferência Ginseng</processId> <processId>Transferência Ginseng</processId>
<processVersion>46</processVersion> <processVersion>65</processVersion>
<stateSequence>6</stateSequence> <stateSequence>6</stateSequence>
<appKey>approval</appKey> <appKey>approval</appKey>
<appField>highlight</appField> <appField>highlight</appField>
@ -1526,7 +1860,7 @@ function onlyDigits(value) {&#xd;
<id>0</id> <id>0</id>
<tenantId>0</tenantId> <tenantId>0</tenantId>
<processId>Transferência Ginseng</processId> <processId>Transferência Ginseng</processId>
<processVersion>46</processVersion> <processVersion>65</processVersion>
<stateSequence>6</stateSequence> <stateSequence>6</stateSequence>
<appKey>approval</appKey> <appKey>approval</appKey>
<appField>approve</appField> <appField>approve</appField>
@ -1536,7 +1870,7 @@ function onlyDigits(value) {&#xd;
<id>0</id> <id>0</id>
<tenantId>0</tenantId> <tenantId>0</tenantId>
<processId>Transferência Ginseng</processId> <processId>Transferência Ginseng</processId>
<processVersion>46</processVersion> <processVersion>65</processVersion>
<stateSequence>6</stateSequence> <stateSequence>6</stateSequence>
<appKey>approval</appKey> <appKey>approval</appKey>
<appField>reject</appField> <appField>reject</appField>
@ -1546,7 +1880,7 @@ function onlyDigits(value) {&#xd;
<id>0</id> <id>0</id>
<tenantId>0</tenantId> <tenantId>0</tenantId>
<processId>Transferência Ginseng</processId> <processId>Transferência Ginseng</processId>
<processVersion>46</processVersion> <processVersion>65</processVersion>
<stateSequence>24</stateSequence> <stateSequence>24</stateSequence>
<appKey>approval</appKey> <appKey>approval</appKey>
<appField>title</appField> <appField>title</appField>
@ -1556,7 +1890,7 @@ function onlyDigits(value) {&#xd;
<id>0</id> <id>0</id>
<tenantId>0</tenantId> <tenantId>0</tenantId>
<processId>Transferência Ginseng</processId> <processId>Transferência Ginseng</processId>
<processVersion>46</processVersion> <processVersion>65</processVersion>
<stateSequence>24</stateSequence> <stateSequence>24</stateSequence>
<appKey>approval</appKey> <appKey>approval</appKey>
<appField>description</appField> <appField>description</appField>
@ -1566,7 +1900,7 @@ function onlyDigits(value) {&#xd;
<id>0</id> <id>0</id>
<tenantId>0</tenantId> <tenantId>0</tenantId>
<processId>Transferência Ginseng</processId> <processId>Transferência Ginseng</processId>
<processVersion>46</processVersion> <processVersion>65</processVersion>
<stateSequence>24</stateSequence> <stateSequence>24</stateSequence>
<appKey>approval</appKey> <appKey>approval</appKey>
<appField>highlight</appField> <appField>highlight</appField>
@ -1576,7 +1910,7 @@ function onlyDigits(value) {&#xd;
<id>0</id> <id>0</id>
<tenantId>0</tenantId> <tenantId>0</tenantId>
<processId>Transferência Ginseng</processId> <processId>Transferência Ginseng</processId>
<processVersion>46</processVersion> <processVersion>65</processVersion>
<stateSequence>24</stateSequence> <stateSequence>24</stateSequence>
<appKey>approval</appKey> <appKey>approval</appKey>
<appField>approve</appField> <appField>approve</appField>
@ -1586,7 +1920,7 @@ function onlyDigits(value) {&#xd;
<id>0</id> <id>0</id>
<tenantId>0</tenantId> <tenantId>0</tenantId>
<processId>Transferência Ginseng</processId> <processId>Transferência Ginseng</processId>
<processVersion>46</processVersion> <processVersion>65</processVersion>
<stateSequence>24</stateSequence> <stateSequence>24</stateSequence>
<appKey>approval</appKey> <appKey>approval</appKey>
<appField>reject</appField> <appField>reject</appField>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 49 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 22 KiB

View File

@ -511,6 +511,197 @@
</void> </void>
</array> </array>
</void> </void>
<void method="put">
<string>camposFormulario, documentoId = 590</string>
<array class="java.lang.String" length="62">
<void index="0">
<string>activity</string>
</void>
<void index="1">
<string>centroCusto</string>
</void>
<void index="2">
<string>chaveNfe</string>
</void>
<void index="3">
<string>codigoItem</string>
</void>
<void index="4">
<string>codigoProdutoItem</string>
</void>
<void index="5">
<string>currentUserId</string>
</void>
<void index="6">
<string>currentUsermail</string>
</void>
<void index="7">
<string>currentUserName</string>
</void>
<void index="8">
<string>dataAbertura</string>
</void>
<void index="9">
<string>dataColeta</string>
</void>
<void index="10">
<string>dataEmissaoApiNfe</string>
</void>
<void index="11">
<string>dataEmissaoNfe</string>
</void>
<void index="12">
<string>dataEntradaNfeConsulta</string>
</void>
<void index="13">
<string>dataEntrega</string>
</void>
<void index="14">
<string>dataValidacaoGestor</string>
</void>
<void index="15">
<string>descricao</string>
</void>
<void index="16">
<string>emailSolicitante</string>
</void>
<void index="17">
<string>estabelecimento</string>
</void>
<void index="18">
<string>excelUpload</string>
</void>
<void index="19">
<string>fdAnexo_Coleta</string>
</void>
<void index="20">
<string>fdAnexo_Entrega</string>
</void>
<void index="21">
<string>fdAnexo_recebimento</string>
</void>
<void index="22">
<string>fnAnexo_Nfe</string>
</void>
<void index="23">
<string>formMode</string>
</void>
<void index="24">
<string>fornecedorNfeConsulta</string>
</void>
<void index="25">
<string>gestorEmail</string>
</void>
<void index="26">
<string>gestorEmailE</string>
</void>
<void index="27">
<string>gestorNome</string>
</void>
<void index="28">
<string>gestorNomeE</string>
</void>
<void index="29">
<string>gestor_cc</string>
</void>
<void index="30">
<string>gestor_cce</string>
</void>
<void index="31">
<string>invoiceIdNfeConsulta</string>
</void>
<void index="32">
<string>itensNfeConsulta</string>
</void>
<void index="33">
<string>itensNfeJson</string>
</void>
<void index="34">
<string>justificativa</string>
</void>
<void index="35">
<string>justificativaDecisaoGestor</string>
</void>
<void index="36">
<string>justificativaDecisaoItens</string>
</void>
<void index="37">
<string>lojaNfeConsulta</string>
</void>
<void index="38">
<string>motoristaColetaLogin</string>
</void>
<void index="39">
<string>motoristaColetaNome</string>
</void>
<void index="40">
<string>motoristaEntregaLogin</string>
</void>
<void index="41">
<string>motoristaEntregaNome</string>
</void>
<void index="42">
<string>motoristaEntregaSelecionado</string>
</void>
<void index="43">
<string>numeroNfeConsulta</string>
</void>
<void index="44">
<string>operacaoNfeConsulta</string>
</void>
<void index="45">
<string>productIdItem</string>
</void>
<void index="46">
<string>qtdDivergenciasNfe</string>
</void>
<void index="47">
<string>quantidadeItem</string>
</void>
<void index="48">
<string>requesterId</string>
</void>
<void index="49">
<string>requesterMail</string>
</void>
<void index="50">
<string>requesterName</string>
</void>
<void index="51">
<string>serieNfeConsulta</string>
</void>
<void index="52">
<string>situacaoNfeConsulta</string>
</void>
<void index="53">
<string>storeIdNfeConsulta</string>
</void>
<void index="54">
<string>tipoMotoristaEntrega</string>
</void>
<void index="55">
<string>ufDestino</string>
</void>
<void index="56">
<string>ufOrigem</string>
</void>
<void index="57">
<string>userValidacaoGestor</string>
</void>
<void index="58">
<string>usuarioEmissorNfe</string>
</void>
<void index="59">
<string>validacaoItens</string>
</void>
<void index="60">
<string>valorNfeConsulta</string>
</void>
<void index="61">
<string>WKNumProces</string>
</void>
</array>
</void>
<void method="put"> <void method="put">
<string>mecanismo</string> <string>mecanismo</string>
<array class="[Ljava.lang.Object;" length="12"> <array class="[Ljava.lang.Object;" length="12">
@ -636,5 +827,530 @@
</void> </void>
</array> </array>
</void> </void>
<void method="put">
<string>forms</string>
<object class="java.util.LinkedList">
<void method="add">
<object class="com.totvs.technology.ecmrestclient.cardindexpublisher.FormVO">
<void property="datasetName">
<string>FLUIGADHOC</string>
</void>
<void property="documentDescription">
<string>FLUIGADHOC</string>
</void>
<void property="documentId">
<int>3</int>
</void>
</object>
</void>
<void method="add">
<object class="com.totvs.technology.ecmrestclient.cardindexpublisher.FormVO">
<void property="datasetName">
<string>FLUIGADHOCPROCESS</string>
</void>
<void property="documentDescription">
<string>FLUIGADHOCPROCESS</string>
</void>
<void property="documentId">
<int>4</int>
</void>
</object>
</void>
<void method="add">
<object class="com.totvs.technology.ecmrestclient.cardindexpublisher.FormVO">
<void property="datasetName">
<string>totvsflow_dataset_tipo_ocorrencia</string>
</void>
<void property="documentDescription">
<string>totvsflow_dataset_tipo_ocorrencia</string>
</void>
<void property="documentId">
<int>14</int>
</void>
</object>
</void>
<void method="add">
<object class="com.totvs.technology.ecmrestclient.cardindexpublisher.FormVO">
<void property="datasetName">
<string>totvsflow_abertura_chamado</string>
</void>
<void property="documentDescription">
<string>totvsflow_abertura_chamado</string>
</void>
<void property="documentId">
<int>15</int>
</void>
</object>
</void>
<void method="add">
<object class="com.totvs.technology.ecmrestclient.cardindexpublisher.FormVO">
<void property="datasetName">
<string>DSFormulariodeAberturadechamado</string>
</void>
<void property="documentDescription">
<string>Formulário de Abertura de chamado</string>
</void>
<void property="documentId">
<int>20</int>
</void>
</object>
</void>
<void method="add">
<object class="com.totvs.technology.ecmrestclient.cardindexpublisher.FormVO">
<void property="datasetName">
<string>Abertura_de_chamados</string>
</void>
<void property="documentDescription">
<string>Solicitação de abertura de chamados</string>
</void>
<void property="documentId">
<int>21</int>
</void>
</object>
</void>
<void method="add">
<object class="com.totvs.technology.ecmrestclient.cardindexpublisher.FormVO">
<void property="datasetName">
<string>DSvistoriadeServico</string>
</void>
<void property="documentDescription">
<string>vistoriadeServico</string>
</void>
<void property="documentId">
<int>24</int>
</void>
</object>
</void>
<void method="add">
<object class="com.totvs.technology.ecmrestclient.cardindexpublisher.FormVO">
<void property="datasetName">
<string>DSFormulariodeReservadesala</string>
</void>
<void property="documentDescription">
<string>Formulário de Reserva de sala</string>
</void>
<void property="documentId">
<int>34</int>
</void>
</object>
</void>
<void method="add">
<object class="com.totvs.technology.ecmrestclient.cardindexpublisher.FormVO">
<void property="datasetName">
<string>totvsflow_dataset_centrocusto</string>
</void>
<void property="documentDescription">
<string>totvsflow_dataset_centrocusto</string>
</void>
<void property="documentId">
<int>103</int>
</void>
</object>
</void>
<void method="add">
<object class="com.totvs.technology.ecmrestclient.cardindexpublisher.FormVO">
<void property="datasetName">
<string>totvsflow_dataset_cadastro_item</string>
</void>
<void property="documentDescription">
<string>totvsflow_dataset_cadastro_item</string>
</void>
<void property="documentId">
<int>104</int>
</void>
</object>
</void>
<void method="add">
<object class="com.totvs.technology.ecmrestclient.cardindexpublisher.FormVO">
<void property="datasetName">
<string>totvsflow_dataset_estabelecimento</string>
</void>
<void property="documentDescription">
<string>totvsflow_dataset_estabelecimento</string>
</void>
<void property="documentId">
<int>105</int>
</void>
</object>
</void>
<void method="add">
<object class="com.totvs.technology.ecmrestclient.cardindexpublisher.FormVO">
<void property="datasetName">
<string>totvsflow_solicitacao_compras</string>
</void>
<void property="documentDescription">
<string>totvsflow_solicitacao_compras</string>
</void>
<void property="documentId">
<int>165</int>
</void>
</object>
</void>
<void method="add">
<object class="com.totvs.technology.ecmrestclient.cardindexpublisher.FormVO">
<void property="datasetName">
<string>aberturadechamado_manutencao</string>
</void>
<void property="documentDescription">
<string>aberturadechamado_manutencao</string>
</void>
<void property="documentId">
<int>400</int>
</void>
</object>
</void>
<void method="add">
<object class="com.totvs.technology.ecmrestclient.cardindexpublisher.FormVO">
<void property="datasetName">
<string>Solicitacao_transferencia</string>
</void>
<void property="documentDescription">
<string>Solicitacao_transferencia</string>
</void>
<void property="documentId">
<int>590</int>
</void>
</object>
</void>
<void method="add">
<object class="com.totvs.technology.ecmrestclient.cardindexpublisher.FormVO">
<void property="datasetName">
<string>recrutamento</string>
</void>
<void property="documentDescription">
<string>recrutamento</string>
</void>
<void property="documentId">
<int>823</int>
</void>
</object>
</void>
<void method="add">
<object class="com.totvs.technology.ecmrestclient.cardindexpublisher.FormVO">
<void property="datasetName">
<string>kit_aniversariantes</string>
</void>
<void property="documentDescription">
<string>Aniversariantes</string>
</void>
<void property="documentId">
<int>7690</int>
</void>
</object>
</void>
<void method="add">
<object class="com.totvs.technology.ecmrestclient.cardindexpublisher.FormVO">
<void property="datasetName">
<string>kit_cardapio</string>
</void>
<void property="documentDescription">
<string>Cardápio do Dia</string>
</void>
<void property="documentId">
<int>7695</int>
</void>
</object>
</void>
<void method="add">
<object class="com.totvs.technology.ecmrestclient.cardindexpublisher.FormVO">
<void property="datasetName">
<string>kit_convenios</string>
</void>
<void property="documentDescription">
<string>Convênios</string>
</void>
<void property="documentId">
<int>7703</int>
</void>
</object>
</void>
<void method="add">
<object class="com.totvs.technology.ecmrestclient.cardindexpublisher.FormVO">
<void property="datasetName">
<string>kit_news</string>
</void>
<void property="documentDescription">
<string>Notícias</string>
</void>
<void property="documentId">
<int>7709</int>
</void>
</object>
</void>
<void method="add">
<object class="com.totvs.technology.ecmrestclient.cardindexpublisher.FormVO">
<void property="datasetName">
<string>compras_digital</string>
</void>
<void property="documentDescription">
<string>compras_digital</string>
</void>
<void property="documentId">
<int>9305</int>
</void>
</object>
</void>
<void method="add">
<object class="com.totvs.technology.ecmrestclient.cardindexpublisher.FormVO">
<void property="datasetName">
<string>dpf_di_formulario_processo_admissao</string>
</void>
<void property="documentDescription">
<string>Digte_Public_Form_Di_Formulario_Processo_Admissao_Protheus</string>
</void>
<void property="documentId">
<int>9626</int>
</void>
</object>
</void>
<void method="add">
<object class="com.totvs.technology.ecmrestclient.cardindexpublisher.FormVO">
<void property="datasetName">
<string>dpf_cadastro_status</string>
</void>
<void property="documentDescription">
<string>Digte_Public_Form_Status</string>
</void>
<void property="documentId">
<int>9627</int>
</void>
</object>
</void>
<void method="add">
<object class="com.totvs.technology.ecmrestclient.cardindexpublisher.FormVO">
<void property="datasetName">
<string>dpf_configuracoes</string>
</void>
<void property="documentDescription">
<string>Digte_Public_Form_Configuracoes</string>
</void>
<void property="documentId">
<int>9628</int>
</void>
</object>
</void>
<void method="add">
<object class="com.totvs.technology.ecmrestclient.cardindexpublisher.FormVO">
<void property="datasetName">
<string>dpf_cadastro_jornada</string>
</void>
<void property="documentDescription">
<string>Digte_Public_Form_Jornada</string>
</void>
<void property="documentId">
<int>9629</int>
</void>
</object>
</void>
<void method="add">
<object class="com.totvs.technology.ecmrestclient.cardindexpublisher.FormVO">
<void property="datasetName">
<string>dpf_tipo_documento</string>
</void>
<void property="documentDescription">
<string>Digte_Public_Form_Tipo_Documento</string>
</void>
<void property="documentId">
<int>9630</int>
</void>
</object>
</void>
<void method="add">
<object class="com.totvs.technology.ecmrestclient.cardindexpublisher.FormVO">
<void property="datasetName">
<string>dpf_dataset</string>
</void>
<void property="documentDescription">
<string>Digte_Public_Form_Dataset</string>
</void>
<void property="documentId">
<int>9631</int>
</void>
</object>
</void>
<void method="add">
<object class="com.totvs.technology.ecmrestclient.cardindexpublisher.FormVO">
<void property="datasetName">
<string>dpf_di_configuracao</string>
</void>
<void property="documentDescription">
<string>Digte_Public_Form_Di_Configuracoes</string>
</void>
<void property="documentId">
<int>9632</int>
</void>
</object>
</void>
<void method="add">
<object class="com.totvs.technology.ecmrestclient.cardindexpublisher.FormVO">
<void property="datasetName">
<string>dpf_di_beneficio</string>
</void>
<void property="documentDescription">
<string>Digte_Public_Form_Di_Beneficios</string>
</void>
<void property="documentId">
<int>9633</int>
</void>
</object>
</void>
<void method="add">
<object class="com.totvs.technology.ecmrestclient.cardindexpublisher.FormVO">
<void property="datasetName">
<string>dpf_di_compl_contrato</string>
</void>
<void property="documentDescription">
<string>Digte_Public_Form_Di_Comp_Contrato</string>
</void>
<void property="documentId">
<int>9634</int>
</void>
</object>
</void>
<void method="add">
<object class="com.totvs.technology.ecmrestclient.cardindexpublisher.FormVO">
<void property="datasetName">
<string>dpf_di_funcao_jornada</string>
</void>
<void property="documentDescription">
<string>Digte_Public_Form_Di_Funcao_Jornada</string>
</void>
<void property="documentId">
<int>9635</int>
</void>
</object>
</void>
<void method="add">
<object class="com.totvs.technology.ecmrestclient.cardindexpublisher.FormVO">
<void property="datasetName">
<string>dpf_dataset_estrutura</string>
</void>
<void property="documentDescription">
<string>Digte_Public_Form_Di_Dataset_Estrutura</string>
</void>
<void property="documentId">
<int>9636</int>
</void>
</object>
</void>
<void method="add">
<object class="com.totvs.technology.ecmrestclient.cardindexpublisher.FormVO">
<void property="datasetName">
<string>dpf_grupo_tipo_contrato</string>
</void>
<void property="documentDescription">
<string>Digte_Public_Form_Grupo_Tipo_Contrato</string>
</void>
<void property="documentId">
<int>9637</int>
</void>
</object>
</void>
<void method="add">
<object class="com.totvs.technology.ecmrestclient.cardindexpublisher.FormVO">
<void property="datasetName">
<string>dpf_tipo_contrato</string>
</void>
<void property="documentDescription">
<string>Digte_Public_Form_Tipo_Contrato</string>
</void>
<void property="documentId">
<int>9638</int>
</void>
</object>
</void>
<void method="add">
<object class="com.totvs.technology.ecmrestclient.cardindexpublisher.FormVO">
<void property="datasetName">
<string>dpf_di_traducao_campo_valor</string>
</void>
<void property="documentDescription">
<string>Digte_Public_Form_Di_Traducao_Campo_Valor</string>
</void>
<void property="documentId">
<int>9639</int>
</void>
</object>
</void>
<void method="add">
<object class="com.totvs.technology.ecmrestclient.cardindexpublisher.FormVO">
<void property="datasetName">
<string>dpf_di_restricoes_cpf</string>
</void>
<void property="documentDescription">
<string>Digte_Public_Form_Di_Formulario_Restricao_CPF</string>
</void>
<void property="documentId">
<int>9640</int>
</void>
</object>
</void>
<void method="add">
<object class="com.totvs.technology.ecmrestclient.cardindexpublisher.FormVO">
<void property="datasetName">
<string>dpf_di_compl_vt</string>
</void>
<void property="documentDescription">
<string>Digte_Public_Form_Di_Compl_VT</string>
</void>
<void property="documentId">
<int>9641</int>
</void>
</object>
</void>
<void method="add">
<object class="com.totvs.technology.ecmrestclient.cardindexpublisher.FormVO">
<void property="datasetName">
<string>dpf_di_traducao_campo</string>
</void>
<void property="documentDescription">
<string>Digte_Public_Form_Di_Traducao_Campo</string>
</void>
<void property="documentId">
<int>9995</int>
</void>
</object>
</void>
<void method="add">
<object class="com.totvs.technology.ecmrestclient.cardindexpublisher.FormVO">
<void property="datasetName">
<string>desligamento</string>
</void>
<void property="documentDescription">
<string>desligamento</string>
</void>
<void property="documentId">
<int>12959</int>
</void>
</object>
</void>
<void method="add">
<object class="com.totvs.technology.ecmrestclient.cardindexpublisher.FormVO">
<void property="datasetName">
<string>form_param_sla_csc</string>
</void>
<void property="documentDescription">
<string>Formulário de Parametrização de SLA - Atendimento de Chamado TI</string>
</void>
<void property="documentId">
<int>28647</int>
</void>
</object>
</void>
<void method="add">
<object class="com.totvs.technology.ecmrestclient.cardindexpublisher.FormVO">
<void property="datasetName">
<string>totvsflow_lancamento_documento</string>
</void>
<void property="documentDescription">
<string>totvsflow_lancamento_documento</string>
</void>
<void property="documentId">
<int>32331</int>
</void>
</object>
</void>
</object>
</void>
</object> </object>
</java> </java>

View File

@ -0,0 +1,205 @@
function beforeTaskSave(colleagueId, nextSequenceId, userList) {
try {
var currentState = parseInt(getValue("WKNumState"), 10);
var completeTask = String(getValue("WKCompletTask") || "false");
var nextState = parseInt(String(nextSequenceId || "0"), 10);
if (completeTask !== "true") return;
if (currentState === 6) {
// Fluxo de cancelamento saindo da atividade 6 nao deve disparar template de nota emitida.
if (nextState === 97) return;
enviarNotificacaoNotaEmitida();
return;
}
if (currentState === 31) {
enviarNotificacaoColetaRealizada();
return;
}
if (currentState === 57) {
// 61 = cancelamento no diagrama.
if (nextState === 61) return;
enviarNotificacaoEntregaRealizada();
}
} catch (e) {
log.error("[Transferencia.beforeTaskSave] Erro no beforeTaskSave: " + e);
}
}
function enviarNotificacaoNotaEmitida() {
var envio = montarContextoEnvio();
if (!envio.ok) return;
var params = buildCommonParams(envio.processNumber, envio.chaveNfe, envio.processLink);
notifyTemplate("tpl_nota_emitida", envio.destinoEmail, envio.requesterId, params, envio.processNumber, envio.processLink);
}
function enviarNotificacaoColetaRealizada() {
var envio = montarContextoEnvio();
if (!envio.ok) return;
var motoristaColetaNome = safeTrim(hAPI.getCardValue("motoristaColetaNome"));
var dataColeta = safeTrim(hAPI.getCardValue("dataColeta"));
var motoristaEntregaNome = safeTrim(hAPI.getCardValue("motoristaEntregaNome"));
var tipoMotoristaEntrega = safeTrim(hAPI.getCardValue("tipoMotoristaEntrega"));
if (motoristaEntregaNome === "" && tipoMotoristaEntrega === "mesmo") {
motoristaEntregaNome = motoristaColetaNome;
}
var params = buildCommonParams(envio.processNumber, envio.chaveNfe, envio.processLink);
params.put("motoristaColetaNome", motoristaColetaNome);
params.put("dataColeta", dataColeta);
params.put("motoristaEntregaNome", motoristaEntregaNome);
notifyTemplate("tpl_coleta_realizada", envio.destinoEmail, envio.requesterId, params, envio.processNumber, envio.processLink);
}
function enviarNotificacaoEntregaRealizada() {
var envio = montarContextoEnvio();
if (!envio.ok) return;
var motoristaEntregaNome = safeTrim(hAPI.getCardValue("motoristaEntregaNome"));
var dataEntrega = safeTrim(hAPI.getCardValue("dataEntrega"));
var nomerecebedor = safeTrim(hAPI.getCardValue("nomerecebedor"));
var params = buildCommonParams(envio.processNumber, envio.chaveNfe, envio.processLink);
params.put("motoristaEntregaNome", motoristaEntregaNome);
params.put("dataEntrega", dataEntrega);
params.put("nomerecebedor", nomerecebedor);
notifyTemplate("tpl_entrega_realizada", envio.destinoEmail, envio.requesterId, params, envio.processNumber, envio.processLink);
}
function montarContextoEnvio() {
var requesterId = safeTrim(hAPI.getCardValue("requesterId"));
var requesterMail = safeTrim(hAPI.getCardValue("requesterMail"));
if (requesterId === "" && requesterMail !== "") {
requesterId = findColleagueIdByMail(requesterMail);
}
// Prioriza email explicito salvo no formulario; fallback para email do colleague.
var destinoEmail = requesterMail;
if (!isValidEmail(destinoEmail)) {
destinoEmail = resolveEmailByColleagueId(requesterId);
}
if (!isValidEmail(destinoEmail)) {
log.warn("[Transferencia.beforeTaskSave] Email do solicitante invalido. requesterId=" + requesterId + ", requesterMail=[" + requesterMail + "], destinoEmail=[" + destinoEmail + "]");
return { ok: false };
}
var processNumber = safeTrim(getValue("WKNumProces"));
var chaveNfe = onlyDigits(hAPI.getCardValue("chaveNfe"));
if (chaveNfe === "") chaveNfe = safeTrim(hAPI.getCardValue("chaveNfe"));
var processLink = buildProcessLink(processNumber);
return {
ok: true,
requesterId: requesterId,
destinoEmail: destinoEmail,
processNumber: processNumber,
chaveNfe: chaveNfe,
processLink: processLink
};
}
function buildCommonParams(processNumber, chaveNfe, processLink) {
var params = new java.util.HashMap();
params.put("WKNumProces", processNumber);
params.put("chaveNfe", chaveNfe);
params.put("linkSolicitacao", processLink);
params.put("link", processLink);
return params;
}
function notifyTemplate(templateCode, destinoEmail, requesterId, params, processNumber, processLink) {
var NOTIFIER_SENDER_USER = "admin";
var recipients = new java.util.ArrayList();
recipients.add(destinoEmail);
notifier.notify(NOTIFIER_SENDER_USER, templateCode, params, recipients, "text/html");
log.info("[Transferencia.beforeTaskSave] " + templateCode + " enviado. processo=" + processNumber + ", destino=" + destinoEmail + ", requesterId=" + requesterId + ", link=[" + processLink + "]");
}
function buildProcessLink(processNumber) {
var BASE_URL_FALLBACK = "https://comerciode188007.fluig.cloudtotvs.com.br";
var baseUrl = safeTrim(getValue("WKServerURL"));
var companyId = safeTrim(getValue("WKCompany"));
if (baseUrl === "") baseUrl = BASE_URL_FALLBACK;
if (baseUrl.indexOf("http://") !== 0 && baseUrl.indexOf("https://") !== 0) {
baseUrl = "https://" + baseUrl;
}
if (baseUrl.charAt(baseUrl.length - 1) === "/") baseUrl = baseUrl.substring(0, baseUrl.length - 1);
if (companyId === "") companyId = "1";
if (baseUrl === "" || safeTrim(processNumber) === "") return "";
return baseUrl + "/portal/p/" + companyId + "/pageworkflowview?app_ecm_workflowview_detailsProcessInstanceID=" + processNumber;
}
function findColleagueIdByMail(mail) {
var email = safeTrim(mail);
if (email === "") return "";
try {
var cMail = DatasetFactory.createConstraint("mail", email, email, ConstraintType.MUST);
var dsColleague = DatasetFactory.getDataset("colleague", null, [cMail], null);
if (!dsColleague || dsColleague.rowsCount < 1) return "";
return safeTrim(
dsColleague.getValue(0, "colleaguePK.colleagueId") ||
dsColleague.getValue(0, "colleagueId") ||
dsColleague.getValue(0, "login")
);
} catch (e) {
log.warn("[Transferencia.beforeTaskSave] Falha ao buscar solicitante por mail: " + e);
return "";
}
}
function resolveEmailByColleagueId(colleagueId) {
var id = safeTrim(colleagueId);
if (id === "") return "";
try {
var cActive = DatasetFactory.createConstraint("active", "true", "true", ConstraintType.MUST);
var cId = DatasetFactory.createConstraint("colleaguePK.colleagueId", id, id, ConstraintType.MUST);
var byId = DatasetFactory.getDataset("colleague", null, [cId, cActive], null);
if (byId && byId.rowsCount > 0) {
return safeTrim(byId.getValue(0, "mail"));
}
var cLogin = DatasetFactory.createConstraint("login", id, id, ConstraintType.MUST);
var byLogin = DatasetFactory.getDataset("colleague", null, [cLogin, cActive], null);
if (byLogin && byLogin.rowsCount > 0) {
return safeTrim(byLogin.getValue(0, "mail"));
}
} catch (e) {
log.warn("[Transferencia.beforeTaskSave] Falha ao buscar email do solicitante por colleagueId: " + e);
}
return "";
}
function isValidEmail(email) {
var v = safeTrim(email);
if (v === "") return false;
if (/\s/.test(v)) return false;
var at = v.indexOf("@");
if (at <= 0 || at !== v.lastIndexOf("@")) return false;
var dot = v.lastIndexOf(".");
return dot > at + 1 && dot < (v.length - 1);
}
function safeTrim(value) {
return String(value == null ? "" : value).trim();
}
function onlyDigits(value) {
return String(value == null ? "" : value).replace(/\D/g, "");
}

View File

@ -0,0 +1,27 @@
function onNotify(subject, receivers, template, params) {
log.info("===== onNotify GLOBAL ===== Template: " + template);
var validos = new java.util.ArrayList();
for (var i = 0; i < receivers.size(); i++) {
var email = receivers.get(i);
log.info("Receiver original: [" + email + "]");
if (email && email.indexOf("@") > 0 && email.indexOf(".") > 0) {
validos.add(email);
} else {
log.warn("REMOVIDO EMAIL INVALIDO: [" + email + "] TEMPLATE: " + template);
}
}
receivers.clear();
for (var j = 0; j < validos.size(); j++) {
receivers.add(validos.get(j));
}
log.info("TOTAL FINAL RECEIVERS: " + receivers.size());
}

View File

@ -18,4 +18,6 @@ function beforeTaskSave(colleagueId,nextSequenceId,userList){
log.error("Erro ao buscar os dados do dataset 'colleague'."); log.error("Erro ao buscar os dados do dataset 'colleague'.");
} }
} }