This commit is contained in:
2026-05-06 16:01:10 -03:00
parent f31f809ce7
commit 4a31410351
26 changed files with 22041 additions and 2083 deletions
File diff suppressed because it is too large Load Diff
@@ -1,10 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<java version="1.8.0_461" class="java.beans.XMLDecoder">
<java version="1.8.0_202" class="java.beans.XMLDecoder">
<object class="java.util.HashMap">
<void method="put">
<string>camposFormulario, documentoId = 2297</string>
<array class="java.lang.String" length="0"/>
</void>
<void method="put">
<string>volume</string>
<array class="java.lang.String" length="1">
@@ -13,81 +9,6 @@
</void>
</array>
</void>
<void method="put">
<string>mecanismoGrupo</string>
<object class="java.util.ArrayList">
<void method="add">
<object class="com.totvs.tds.ecm.foundation.ws.GroupDto">
<void property="groupDescription">
<string>Aprovadores Compras Nvl 3</string>
</void>
<void property="groupId">
<string>AprovadoresComprasNvl3</string>
</void>
</object>
</void>
<void method="add">
<object class="com.totvs.tds.ecm.foundation.ws.GroupDto">
<void property="groupDescription">
<string>Compras Indiretos</string>
</void>
<void property="groupId">
<string>ComprasIndiretos</string>
</void>
</object>
</void>
<void method="add">
<object class="com.totvs.tds.ecm.foundation.ws.GroupDto">
<void property="groupDescription">
<string>Obras e manutenção</string>
</void>
<void property="groupId">
<string>Manutencao</string>
</void>
</object>
</void>
<void method="add">
<object class="com.totvs.tds.ecm.foundation.ws.GroupDto">
<void property="groupDescription">
<string>Motoristas</string>
</void>
<void property="groupId">
<string>Motoristas</string>
</void>
</object>
</void>
<void method="add">
<object class="com.totvs.tds.ecm.foundation.ws.GroupDto">
<void property="groupDescription">
<string>Recrutamento</string>
</void>
<void property="groupId">
<string>Recrutamento</string>
</void>
</object>
</void>
<void method="add">
<object class="com.totvs.tds.ecm.foundation.ws.GroupDto">
<void property="groupDescription">
<string>Requisitantes de Vaga</string>
</void>
<void property="groupId">
<string>Requisitantesdevaga</string>
</void>
</object>
</void>
<void method="add">
<object class="com.totvs.tds.ecm.foundation.ws.GroupDto">
<void property="groupDescription">
<string>Tecnologia e Comunicação</string>
</void>
<void property="groupId">
<string>TIC</string>
</void>
</object>
</void>
</object>
</void>
<void method="put">
<string>expediente</string>
<array class="java.lang.String" length="4">
@@ -107,7 +28,7 @@
</void>
<void method="put">
<string>mecanismo</string>
<array class="[Ljava.lang.Object;" length="10">
<array class="[Ljava.lang.Object;" length="12">
<void index="0">
<array class="java.lang.Object" length="2">
<void index="0">
@@ -129,6 +50,26 @@
</array>
</void>
<void index="2">
<array class="java.lang.Object" length="2">
<void index="0">
<string>dpf_di_emp_filial_filtro</string>
</void>
<void index="1">
<string>dpf_di_emp_filial_filtro</string>
</void>
</array>
</void>
<void index="3">
<array class="java.lang.Object" length="2">
<void index="0">
<string>dpf_di_inicio_diadmissao</string>
</void>
<void index="1">
<string>dpf_di_inicio_diadmissao</string>
</void>
</array>
</void>
<void index="4">
<array class="java.lang.Object" length="2">
<void index="0">
<string>Atribuição por Executor de Atividade</string>
@@ -138,7 +79,7 @@
</void>
</array>
</void>
<void index="3">
<void index="5">
<array class="java.lang.Object" length="2">
<void index="0">
<string>Atribuição por Grupo</string>
@@ -148,7 +89,7 @@
</void>
</array>
</void>
<void index="4">
<void index="6">
<array class="java.lang.Object" length="2">
<void index="0">
<string>Atribuição por Grupos do Colaborador</string>
@@ -158,7 +99,7 @@
</void>
</array>
</void>
<void index="5">
<void index="7">
<array class="java.lang.Object" length="2">
<void index="0">
<string>mecCustomAprov</string>
@@ -168,7 +109,7 @@
</void>
</array>
</void>
<void index="6">
<void index="8">
<array class="java.lang.Object" length="2">
<void index="0">
<string>Atribuição por Papel</string>
@@ -178,7 +119,7 @@
</void>
</array>
</void>
<void index="7">
<void index="9">
<array class="java.lang.Object" length="2">
<void index="0">
<string>Atribuição para um Grupo</string>
@@ -188,7 +129,7 @@
</void>
</array>
</void>
<void index="8">
<void index="10">
<array class="java.lang.Object" length="2">
<void index="0">
<string>Atribuição para um Papel</string>
@@ -198,7 +139,7 @@
</void>
</array>
</void>
<void index="9">
<void index="11">
<array class="java.lang.Object" length="2">
<void index="0">
<string>Atribuição por Usuário</string>
@@ -210,482 +151,5 @@
</void>
</array>
</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>
</object>
</void>
<void method="put">
<string>camposFormulario, documentoId = 9305</string>
<array class="java.lang.String" length="69">
<void index="0">
<string>activity</string>
</void>
<void index="1">
<string>centro_custo</string>
</void>
<void index="2">
<string>ceo_validacao_aprova</string>
</void>
<void index="3">
<string>codigocentroCusto</string>
</void>
<void index="4">
<string>Codproduto</string>
</void>
<void index="5">
<string>cotacaoSCProtheus</string>
</void>
<void index="6">
<string>currentUserId</string>
</void>
<void index="7">
<string>currentUsermail</string>
</void>
<void index="8">
<string>currentUserName</string>
</void>
<void index="9">
<string>dataCadastroSCProtheus</string>
</void>
<void index="10">
<string>dataNec</string>
</void>
<void index="11">
<string>dataValidacaoItens</string>
</void>
<void index="12">
<string>data_validacao_aprova</string>
</void>
<void index="13">
<string>data_validacao_aprova_ceo</string>
</void>
<void index="14">
<string>data_validacao_aprova_gerf</string>
</void>
<void index="15">
<string>data_validacao_aprova_gestor</string>
</void>
<void index="16">
<string>data_validacao_gestor</string>
</void>
<void index="17">
<string>descProduto</string>
</void>
<void index="18">
<string>emailSolicitante</string>
</void>
<void index="19">
<string>emissaoSCProtheus</string>
</void>
<void index="20">
<string>empresa</string>
</void>
<void index="21">
<string>estabelecimento</string>
</void>
<void index="22">
<string>fdComprovante</string>
</void>
<void index="23">
<string>filialdest</string>
</void>
<void index="24">
<string>filialest</string>
</void>
<void index="25">
<string>filialprotheus</string>
</void>
<void index="26">
<string>fnComprovante</string>
</void>
<void index="27">
<string>formMode</string>
</void>
<void index="28">
<string>gerf_validacao_aprova</string>
</void>
<void index="29">
<string>gestor_cc</string>
</void>
<void index="30">
<string>gestor_validacao_aprova</string>
</void>
<void index="31">
<string>horaCadastroSCProtheus</string>
</void>
<void index="32">
<string>item</string>
</void>
<void index="33">
<string>justificativaDecisaoItens</string>
</void>
<void index="34">
<string>justificativaValidaProblema</string>
</void>
<void index="35">
<string>justi_decisao_aprova</string>
</void>
<void index="36">
<string>justi_decisao_aprova_ceo</string>
</void>
<void index="37">
<string>justi_decisao_aprova_gerente</string>
</void>
<void index="38">
<string>justi_decisao_aprova_gestor</string>
</void>
<void index="39">
<string>justi_decisao_gestor</string>
</void>
<void index="40">
<string>moreInfo</string>
</void>
<void index="41">
<string>numeroSCProtheus</string>
</void>
<void index="42">
<string>observacoes</string>
</void>
<void index="43">
<string>pedidoSCProtheus</string>
</void>
<void index="44">
<string>preco</string>
</void>
<void index="45">
<string>produto</string>
</void>
<void index="46">
<string>produtoCod</string>
</void>
<void index="47">
<string>produtoDesc</string>
</void>
<void index="48">
<string>produtoLink</string>
</void>
<void index="49">
<string>qtd</string>
</void>
<void index="50">
<string>qtdc</string>
</void>
<void index="51">
<string>qtdItensSCProtheus</string>
</void>
<void index="52">
<string>quantidade</string>
</void>
<void index="53">
<string>requesterId</string>
</void>
<void index="54">
<string>requesterMail</string>
</void>
<void index="55">
<string>selecionado</string>
</void>
<void index="56">
<string>solicitanteSCProtheus</string>
</void>
<void index="57">
<string>statusAtendimento</string>
</void>
<void index="58">
<string>statusSCProtheus</string>
</void>
<void index="59">
<string>tipoSolicitacao</string>
</void>
<void index="60">
<string>total</string>
</void>
<void index="61">
<string>urgencia</string>
</void>
<void index="62">
<string>userValidacaoItens</string>
</void>
<void index="63">
<string>user_validacao_aprova</string>
</void>
<void index="64">
<string>user_validacao_gestor</string>
</void>
<void index="65">
<string>usuarioSolicitante</string>
</void>
<void index="66">
<string>validacaoItens</string>
</void>
<void index="67">
<string>valorTotalCotacao</string>
</void>
<void index="68">
<string>WKNumProces</string>
</void>
</array>
</void>
</object>
</java>
@@ -29,7 +29,7 @@
<processDefinitionVersionPK>
<companyId>1</companyId>
<processId>Solicitação de compra - Ginseng</processId>
<version>8</version>
<version>86</version>
</processDefinitionVersionPK>
<versionDescription></versionDescription>
<formId>9305</formId>
@@ -1009,7 +1009,7 @@
<companyId>1</companyId>
<processId>Solicitação de compras </processId>
<expressionOrder>1</expressionOrder>
<version>8</version>
<version>86</version>
<sequence>46</sequence>
</conditionProcessStatePK>
<condition>hAPI.getCardValue(&quot;validacaoItens&quot;) == &quot;entregue&quot;</condition>
@@ -1021,7 +1021,7 @@
<companyId>1</companyId>
<processId>Solicitação de compras </processId>
<expressionOrder>2</expressionOrder>
<version>8</version>
<version>86</version>
<sequence>46</sequence>
</conditionProcessStatePK>
<condition>true</condition>
@@ -1033,7 +1033,7 @@
<companyId>1</companyId>
<processId>Solicitação de compras </processId>
<expressionOrder>1</expressionOrder>
<version>8</version>
<version>86</version>
<sequence>128</sequence>
</conditionProcessStatePK>
<condition>parseFloat(hAPI.getCardValue(&quot;valorTotalCotacao&quot;)) &lt;= 100000.00</condition>
@@ -1047,7 +1047,7 @@
<companyId>1</companyId>
<processId>Solicitação de compras </processId>
<expressionOrder>1</expressionOrder>
<version>8</version>
<version>86</version>
<sequence>150</sequence>
</conditionProcessStatePK>
<condition>parseFloat(hAPI.getCardValue(&quot;valorTotalCotacao&quot;)) &gt;= 5001.00 &amp;&amp; &#xd;
@@ -1063,7 +1063,7 @@ parseFloat(hAPI.getCardValue(&quot;valorTotalCotacao&quot;)) &lt;= 50000.00&#xd;
<companyId>1</companyId>
<processId>Solicitação de compras </processId>
<expressionOrder>2</expressionOrder>
<version>8</version>
<version>86</version>
<sequence>150</sequence>
</conditionProcessStatePK>
<condition>true</condition>
@@ -1077,7 +1077,7 @@ parseFloat(hAPI.getCardValue(&quot;valorTotalCotacao&quot;)) &lt;= 50000.00&#xd;
<companyId>1</companyId>
<processId>Solicitação de compras </processId>
<expressionOrder>1</expressionOrder>
<version>8</version>
<version>86</version>
<sequence>154</sequence>
</conditionProcessStatePK>
<condition>parseFloat(hAPI.getCardValue(&quot;valorTotalCotacao&quot;)) &gt; 50000.00</condition>
@@ -1091,7 +1091,7 @@ parseFloat(hAPI.getCardValue(&quot;valorTotalCotacao&quot;)) &lt;= 50000.00&#xd;
<companyId>1</companyId>
<processId>Solicitação de compras </processId>
<expressionOrder>2</expressionOrder>
<version>8</version>
<version>86</version>
<sequence>154</sequence>
</conditionProcessStatePK>
<condition>parseFloat(hAPI.getCardValue(&quot;valorTotalCotacao&quot;)) &lt; 50000.00</condition>
@@ -1536,102 +1536,110 @@ parseFloat(hAPI.getCardValue(&quot;valorTotalCotacao&quot;)) &lt;= 50000.00&#xd;
<processId>Solicitação de compras </processId>
<version>1</version>
</workflowProcessEventPK>
<eventDescription>function toProtheusDate(d) {
if (!d) return &quot;&quot;;
if (d.indexOf(&quot;/&quot;) &gt; -1) {
var parts = d.split(&quot;/&quot;);
return parts[2] + parts[1] + parts[0]; // dd/MM/yyyy -&gt; yyyyMMdd
}
if (d.indexOf(&quot;-&quot;) &gt; -1) {
return d.replace(/-/g, &quot;&quot;); // yyyy-MM-dd -&gt; yyyyMMdd
}
return d; // já está no formato certo
}
function hojeProtheus() {
var d = new Date();
var yyyy = d.getFullYear();
var mm = d.getMonth() + 1;
var dd = d.getDate();
if (mm &lt; 10) mm = &quot;0&quot; + mm;
if (dd &lt; 10) dd = &quot;0&quot; + dd;
return &quot;&quot; + yyyy + mm + dd; // yyyyMMdd
}
function servicetask82(attempt, message) {
log.info(&quot;🚀 Iniciando servicetask82&quot;);
var qtdItens = hAPI.getChildrenIndexes(&quot;tbItens&quot;);
log.info(&quot;📦 Total de itens na tabela: &quot; + qtdItens.length);
var itens = [];
for (var i = 0; i &lt; qtdItens.length; i++) {
var index = qtdItens[i];
var item = {
&quot;C1_PRODUTO&quot;: String(hAPI.getCardValue(&quot;Codproduto___&quot; + index)),
&quot;C1_QUANT&quot;: Number(hAPI.getCardValue(&quot;qtd___&quot; + index)),
&quot;C1_DATPRF&quot;: toProtheusDate(String(hAPI.getCardValue(&quot;dataNec___&quot; + index)))
};
itens.push(item);
log.info(&quot;📌 Item adicionado: &quot; + JSON.stringify(item));
}
var payload = {
&quot;C1_SOLICIT&quot;: String(hAPI.getCardValue(&quot;usuarioSolicitante&quot;)),
&quot;C1_EMISSAO&quot;: hojeProtheus(),
&quot;C1_FILENT&quot;: String(hAPI.getCardValue(&quot;filialProtheus&quot;)).trim(),
&quot;C1_OBS&quot;: String(hAPI.getCardValue(&quot;observacoes&quot;)),
&quot;itens&quot;: itens
};
log.info(&quot;📦 Payload montado:&quot;);
log.info(JSON.stringify(payload));
var data1 = {
companyId: &apos;1&apos;,
serviceCode: &apos;Postprod&apos;,
endpoint: &apos;/rest/UF_MATA110&apos;,
method: &apos;post&apos;,
timeoutService: &apos;100&apos;,
params: payload, // objeto puro
headers: {
&apos;Content-Type&apos;: &apos;application/json&apos;
}
};
try {
var clientService = fluigAPI.getAuthorizeClientService();
var response = clientService.invoke(JSON.stringify(data1)); // SEMPRE stringify aqui
log.info(&quot;📬 Resposta da API Protheus:&quot;);
log.dir(response);
if (response &amp;&amp; response.getResult()) {
var result = JSON.parse(response.getResult());
if (result.sucesso) {
hAPI.setCardValue(&quot;numeroSCProtheus&quot;, result.C1_NUM || &quot;&quot;);
hAPI.setCardValue(&quot;statusSCProtheus&quot;, &quot;SC cadastrada com sucesso&quot;);
hAPI.setCardValue(&quot;solicitanteSCProtheus&quot;, result.C1_SOLICIT || &quot;&quot;);
hAPI.setCardValue(&quot;emissaoSCProtheus&quot;, result.C1_EMISSAO || &quot;&quot;);
hAPI.setCardValue(&quot;qtdItensSCProtheus&quot;, String(result.quantidade_itens || &quot;&quot;));
hAPI.setCardValue(&quot;dataCadastroSCProtheus&quot;, result.data_cadastro || &quot;&quot;);
hAPI.setCardValue(&quot;horaCadastroSCProtheus&quot;, result.hora_cadastro || &quot;&quot;);
} else {
hAPI.setCardValue(&quot;statusSCProtheus&quot;, &quot;Erro: &quot; + result.erro);
throw &quot;Erro Protheus: &quot; + result.message;
}
} else {
throw &quot;Sem resposta da API Protheus&quot;;
}
} catch (e) {
log.error(&quot;❌ Erro ao enviar SC para o Protheus: &quot; + e);
throw e;
}
log.info(&quot;🏁 Finalização da servicetask82&quot;);
}
<eventDescription>function toProtheusDate(d) {&#xd;
if (!d) return &quot;&quot;;&#xd;
if (d.indexOf(&quot;/&quot;) &gt; -1) {&#xd;
var parts = d.split(&quot;/&quot;);&#xd;
return parts[2] + parts[1] + parts[0]; // dd/MM/yyyy -&gt; yyyyMMdd&#xd;
}&#xd;
if (d.indexOf(&quot;-&quot;) &gt; -1) {&#xd;
return d.replace(/-/g, &quot;&quot;); // yyyy-MM-dd -&gt; yyyyMMdd&#xd;
}&#xd;
return d; // já está no formato certo&#xd;
}&#xd;
&#xd;
function hojeProtheus() {&#xd;
var d = new Date();&#xd;
var yyyy = d.getFullYear();&#xd;
var mm = d.getMonth() + 1;&#xd;
var dd = d.getDate();&#xd;
if (mm &lt; 10) mm = &quot;0&quot; + mm;&#xd;
if (dd &lt; 10) dd = &quot;0&quot; + dd;&#xd;
return &quot;&quot; + yyyy + mm + dd; // yyyyMMdd&#xd;
}&#xd;
&#xd;
function servicetask82(attempt, message) {&#xd;
log.info(&quot;🚀 Iniciando servicetask82&quot;);&#xd;
&#xd;
var qtdItens = hAPI.getChildrenIndexes(&quot;tbItens&quot;);&#xd;
log.info(&quot;📦 Total de itens na tabela: &quot; + qtdItens.length);&#xd;
&#xd;
var itens = [];&#xd;
for (var i = 0; i &lt; qtdItens.length; i++) {&#xd;
var index = qtdItens[i];&#xd;
var item = {&#xd;
&quot;C1_PRODUTO&quot;: String(hAPI.getCardValue(&quot;Codproduto___&quot; + index)),&#xd;
&quot;C1_QUANT&quot;: Number(hAPI.getCardValue(&quot;qtd___&quot; + index)),&#xd;
&quot;C1_DATPRF&quot;: toProtheusDate(String(hAPI.getCardValue(&quot;dataNec___&quot; + index)))&#xd;
};&#xd;
itens.push(item);&#xd;
log.info(&quot;📌 Item adicionado: &quot; + JSON.stringify(item));&#xd;
}&#xd;
&#xd;
var filial = String(hAPI.getCardValue(&quot;filialprotheus&quot;) || hAPI.getCardValue(&quot;filialProtheus&quot;) || &quot;&quot;).trim();&#xd;
if (!filial) {&#xd;
throw &quot;Campo de filial não preenchido no formulário (filialprotheus).&quot;;&#xd;
}&#xd;
&#xd;
var payload = {&#xd;
&quot;C1_SOLICIT&quot;: String(hAPI.getCardValue(&quot;usuarioSolicitante&quot;)),&#xd;
&quot;C1_EMISSAO&quot;: hojeProtheus(),&#xd;
&quot;C1_FILENT&quot;: filial,&#xd;
&quot;C1_OBS&quot;: String(hAPI.getCardValue(&quot;observacoes&quot;)),&#xd;
&quot;itens&quot;: itens&#xd;
};&#xd;
&#xd;
log.info(&quot;📦 Payload montado:&quot;);&#xd;
log.info(JSON.stringify(payload));&#xd;
&#xd;
var data1 = {&#xd;
companyId: &apos;1&apos;,&#xd;
serviceCode: &apos;Postprod&apos;,&#xd;
endpoint: &apos;/UF_MATA110&apos;,&#xd;
method: &apos;post&apos;,&#xd;
timeoutService: &apos;60000&apos;,&#xd;
params: payload, // objeto puro&#xd;
headers: {&#xd;
&apos;Content-Type&apos;: &apos;application/json&apos;&#xd;
}&#xd;
};&#xd;
&#xd;
try {&#xd;
var clientService = fluigAPI.getAuthorizeClientService();&#xd;
var response = clientService.invoke(JSON.stringify(data1)); // SEMPRE stringify aqui&#xd;
&#xd;
log.info(&quot;📬 Resposta da API Protheus:&quot;);&#xd;
if (response) {&#xd;
log.info(&quot;HTTP status: &quot; + response.getHttpStatusResult());&#xd;
log.info(&quot;Body: &quot; + response.getResult());&#xd;
}&#xd;
&#xd;
if (response &amp;&amp; response.getResult()) {&#xd;
var result = JSON.parse(response.getResult());&#xd;
if (result.sucesso) {&#xd;
hAPI.setCardValue(&quot;numeroSCProtheus&quot;, result.C1_NUM || &quot;&quot;);&#xd;
hAPI.setCardValue(&quot;statusSCProtheus&quot;, &quot;SC cadastrada com sucesso&quot;);&#xd;
hAPI.setCardValue(&quot;solicitanteSCProtheus&quot;, result.C1_SOLICIT || &quot;&quot;);&#xd;
hAPI.setCardValue(&quot;emissaoSCProtheus&quot;, result.C1_EMISSAO || &quot;&quot;);&#xd;
hAPI.setCardValue(&quot;qtdItensSCProtheus&quot;, String(result.quantidade_itens || &quot;&quot;));&#xd;
hAPI.setCardValue(&quot;dataCadastroSCProtheus&quot;, result.data_cadastro || &quot;&quot;);&#xd;
hAPI.setCardValue(&quot;horaCadastroSCProtheus&quot;, result.hora_cadastro || &quot;&quot;);&#xd;
} else {&#xd;
hAPI.setCardValue(&quot;statusSCProtheus&quot;, &quot;Erro: &quot; + result.erro);&#xd;
throw &quot;Erro Protheus: &quot; + result.message;&#xd;
}&#xd;
} else {&#xd;
throw &quot;Sem resposta da API Protheus&quot;;&#xd;
}&#xd;
} catch (e) {&#xd;
log.error(&quot;❌ Erro ao enviar SC para o Protheus: &quot; + e);&#xd;
throw e;&#xd;
}&#xd;
&#xd;
&#xd;
&#xd;
log.info(&quot;🏁 Finalização da servicetask82&quot;);&#xd;
}&#xd;
</eventDescription>
</WorkflowProcessEvent>
<WorkflowProcessEvent>
@@ -1641,25 +1649,25 @@ function servicetask82(attempt, message) {
<processId>Solicitação de compras </processId>
<version>1</version>
</workflowProcessEventPK>
<eventDescription>function servicetask114(attempt, message) {
log.info(&quot;🚀 ST92 — Verifica se já existe código de cotação no formulário&quot;);
var numSC = hAPI.getCardValue(&quot;numeroSCProtheus&quot;);
var numCot = hAPI.getCardValue(&quot;cotacaoSCProtheus&quot;);
log.info(&quot;📌 SC: &quot; + numSC + &quot; | Cotação: &quot; + numCot);
if (!numSC) {
throw &quot;❌ Número da SC não informado no formulário.&quot;;
}
// se não tiver cotação ainda, força o loop da atividade
if (!numCot || numCot === &quot;000000&quot; || numCot === &quot;000001&quot;) {
throw &quot;⏳ Cotação ainda não disponível para a SC &quot; + numSC;
}
// se já tiver código, só registra log e deixa o processo seguir
log.info(&quot;✅ Cotação &quot; + numCot + &quot; encontrada no formulário. Processo segue.&quot;);
<eventDescription>function servicetask114(attempt, message) {&#xd;
log.info(&quot;🚀 ST92 — Verifica se já existe código de cotação no formulário&quot;);&#xd;
&#xd;
var numSC = hAPI.getCardValue(&quot;numeroSCProtheus&quot;);&#xd;
var numCot = hAPI.getCardValue(&quot;cotacaoSCProtheus&quot;);&#xd;
&#xd;
log.info(&quot;📌 SC: &quot; + numSC + &quot; | Cotação: &quot; + numCot);&#xd;
&#xd;
if (!numSC) {&#xd;
throw &quot;❌ Número da SC não informado no formulário.&quot;;&#xd;
}&#xd;
&#xd;
// se não tiver cotação ainda, força o loop da atividade&#xd;
if (!numCot || numCot === &quot;000000&quot; || numCot === &quot;000001&quot;) {&#xd;
throw &quot;⏳ Cotação ainda não disponível para a SC &quot; + numSC;&#xd;
}&#xd;
&#xd;
// se já tiver código, só registra log e deixa o processo seguir&#xd;
log.info(&quot;✅ Cotação &quot; + numCot + &quot; encontrada no formulário. Processo segue.&quot;);&#xd;
}</eventDescription>
</WorkflowProcessEvent>
</list>
@@ -1801,7 +1809,7 @@ function servicetask82(attempt, message) {
<processLinkBendPK>
<companyId>1</companyId>
<processId>Solicitação de compras </processId>
<version>8</version>
<version>86</version>
<linkSequence>26</linkSequence>
<bendSequence>1</bendSequence>
</processLinkBendPK>
@@ -1812,7 +1820,7 @@ function servicetask82(attempt, message) {
<processLinkBendPK>
<companyId>1</companyId>
<processId>Solicitação de compras </processId>
<version>8</version>
<version>86</version>
<linkSequence>125</linkSequence>
<bendSequence>1</bendSequence>
</processLinkBendPK>
@@ -1823,7 +1831,7 @@ function servicetask82(attempt, message) {
<processLinkBendPK>
<companyId>1</companyId>
<processId>Solicitação de compras </processId>
<version>8</version>
<version>86</version>
<linkSequence>126</linkSequence>
<bendSequence>1</bendSequence>
</processLinkBendPK>
@@ -1834,7 +1842,7 @@ function servicetask82(attempt, message) {
<processLinkBendPK>
<companyId>1</companyId>
<processId>Solicitação de compras </processId>
<version>8</version>
<version>86</version>
<linkSequence>127</linkSequence>
<bendSequence>1</bendSequence>
</processLinkBendPK>
@@ -1845,7 +1853,7 @@ function servicetask82(attempt, message) {
<processLinkBendPK>
<companyId>1</companyId>
<processId>Solicitação de compras </processId>
<version>8</version>
<version>86</version>
<linkSequence>129</linkSequence>
<bendSequence>1</bendSequence>
</processLinkBendPK>
@@ -1856,7 +1864,7 @@ function servicetask82(attempt, message) {
<processLinkBendPK>
<companyId>1</companyId>
<processId>Solicitação de compras </processId>
<version>8</version>
<version>86</version>
<linkSequence>142</linkSequence>
<bendSequence>1</bendSequence>
</processLinkBendPK>
@@ -1867,7 +1875,7 @@ function servicetask82(attempt, message) {
<processLinkBendPK>
<companyId>1</companyId>
<processId>Solicitação de compras </processId>
<version>8</version>
<version>86</version>
<linkSequence>144</linkSequence>
<bendSequence>1</bendSequence>
</processLinkBendPK>
@@ -1878,7 +1886,7 @@ function servicetask82(attempt, message) {
<processLinkBendPK>
<companyId>1</companyId>
<processId>Solicitação de compras </processId>
<version>8</version>
<version>86</version>
<linkSequence>152</linkSequence>
<bendSequence>1</bendSequence>
</processLinkBendPK>
@@ -1889,7 +1897,7 @@ function servicetask82(attempt, message) {
<processLinkBendPK>
<companyId>1</companyId>
<processId>Solicitação de compras </processId>
<version>8</version>
<version>86</version>
<linkSequence>152</linkSequence>
<bendSequence>2</bendSequence>
</processLinkBendPK>
@@ -1900,7 +1908,7 @@ function servicetask82(attempt, message) {
<processLinkBendPK>
<companyId>1</companyId>
<processId>Solicitação de compras </processId>
<version>8</version>
<version>86</version>
<linkSequence>161</linkSequence>
<bendSequence>1</bendSequence>
</processLinkBendPK>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 62 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

@@ -9089,7 +9089,7 @@
<bpmn2:BpmnEndEvent extendedFields="&lt;list/&gt;" id="endcancel39" incoming="flow124" name="Cancelado" notificaRequisitante="true" signalId="0" type="65"/>
<bpmn2:BpmnGateway condition="&lt;list&gt;&#10; &lt;org.eclipse.bpmn2.impl.ConditionImpl&gt;&#10; &lt;order&gt;1&lt;/order&gt;&#10; &lt;expression&gt;hAPI.getCardValue(&amp;quot;validacaoItens&amp;quot;) == &amp;quot;entregue&amp;quot;&lt;/expression&gt;&#10; &lt;targetTask&gt;endevent52&lt;/targetTask&gt;&#10; &lt;conditionType&gt;0&lt;/conditionType&gt;&#10; &lt;/org.eclipse.bpmn2.impl.ConditionImpl&gt;&#10; &lt;org.eclipse.bpmn2.impl.ConditionImpl&gt;&#10; &lt;order&gt;2&lt;/order&gt;&#10; &lt;expression&gt;true&lt;/expression&gt;&#10; &lt;targetTask&gt;task24&lt;/targetTask&gt;&#10; &lt;conditionType&gt;0&lt;/conditionType&gt;&#10; &lt;/org.eclipse.bpmn2.impl.ConditionImpl&gt;&#10;&lt;/list&gt;" extendedFields="&lt;list/&gt;" id="exclusivegateway46" incoming="flow47" name="Validar compra" outgoing="flow48 flow78" type="120"/>
<bpmn2:BpmnEndEvent extendedFields="&lt;list/&gt;" id="endevent52" incoming="flow78" name="Fim" signalId="0" type="60"/>
<bpmn2:BpmnProcess author="" cardIndex="9305" category="Compras - Testes" complementsLevel="1" descriptorFields="&lt;list&gt;&#10; &lt;org.eclipse.bpmn2.impl.BpmnProcessFormField&gt;&#10; &lt;id&gt;descProduto&lt;/id&gt;&#10; &lt;label&gt;descProduto&lt;/label&gt;&#10; &lt;cardIndex&gt;9305 - compras_digital&lt;/cardIndex&gt;&#10; &lt;/org.eclipse.bpmn2.impl.BpmnProcessFormField&gt;&#10; &lt;org.eclipse.bpmn2.impl.BpmnProcessFormField&gt;&#10; &lt;id&gt;empresa&lt;/id&gt;&#10; &lt;label&gt;empresa&lt;/label&gt;&#10; &lt;cardIndex&gt;9305 - compras_digital&lt;/cardIndex&gt;&#10; &lt;/org.eclipse.bpmn2.impl.BpmnProcessFormField&gt;&#10; &lt;org.eclipse.bpmn2.impl.BpmnProcessFormField&gt;&#10; &lt;id&gt;estabelecimento&lt;/id&gt;&#10; &lt;label&gt;estabelecimento&lt;/label&gt;&#10; &lt;cardIndex&gt;9305 - compras_digital&lt;/cardIndex&gt;&#10; &lt;/org.eclipse.bpmn2.impl.BpmnProcessFormField&gt;&#10; &lt;org.eclipse.bpmn2.impl.BpmnProcessFormField&gt;&#10; &lt;id&gt;filialdest&lt;/id&gt;&#10; &lt;label&gt;filialdest&lt;/label&gt;&#10; &lt;cardIndex&gt;9305 - compras_digital&lt;/cardIndex&gt;&#10; &lt;/org.eclipse.bpmn2.impl.BpmnProcessFormField&gt;&#10; &lt;org.eclipse.bpmn2.impl.BpmnProcessFormField&gt;&#10; &lt;id&gt;numeroSCProtheus&lt;/id&gt;&#10; &lt;label&gt;numeroSCProtheus&lt;/label&gt;&#10; &lt;cardIndex&gt;9305 - compras_digital&lt;/cardIndex&gt;&#10; &lt;/org.eclipse.bpmn2.impl.BpmnProcessFormField&gt;&#10; &lt;org.eclipse.bpmn2.impl.BpmnProcessFormField&gt;&#10; &lt;id&gt;pedidoSCProtheus&lt;/id&gt;&#10; &lt;label&gt;pedidoSCProtheus&lt;/label&gt;&#10; &lt;cardIndex&gt;9305 - compras_digital&lt;/cardIndex&gt;&#10; &lt;/org.eclipse.bpmn2.impl.BpmnProcessFormField&gt;&#10; &lt;org.eclipse.bpmn2.impl.BpmnProcessFormField&gt;&#10; &lt;id&gt;quantidade&lt;/id&gt;&#10; &lt;label&gt;quantidade&lt;/label&gt;&#10; &lt;cardIndex&gt;9305 - compras_digital&lt;/cardIndex&gt;&#10; &lt;/org.eclipse.bpmn2.impl.BpmnProcessFormField&gt;&#10; &lt;org.eclipse.bpmn2.impl.BpmnProcessFormField&gt;&#10; &lt;id&gt;solicitanteSCProtheus&lt;/id&gt;&#10; &lt;label&gt;solicitanteSCProtheus&lt;/label&gt;&#10; &lt;cardIndex&gt;9305 - compras_digital&lt;/cardIndex&gt;&#10; &lt;/org.eclipse.bpmn2.impl.BpmnProcessFormField&gt;&#10; &lt;org.eclipse.bpmn2.impl.BpmnProcessFormField&gt;&#10; &lt;id&gt;urgencia&lt;/id&gt;&#10; &lt;label&gt;urgencia&lt;/label&gt;&#10; &lt;cardIndex&gt;9305 - compras_digital&lt;/cardIndex&gt;&#10; &lt;/org.eclipse.bpmn2.impl.BpmnProcessFormField&gt;&#10; &lt;org.eclipse.bpmn2.impl.BpmnProcessFormField&gt;&#10; &lt;id&gt;valorTotalCotacao&lt;/id&gt;&#10; &lt;label&gt;valorTotalCotacao&lt;/label&gt;&#10; &lt;cardIndex&gt;9305 - compras_digital&lt;/cardIndex&gt;&#10; &lt;/org.eclipse.bpmn2.impl.BpmnProcessFormField&gt;&#10;&lt;/list&gt;" expedient="Default" extendedFields="&lt;list/&gt;" formSource="server" id="Solicita&#231;&#227;o de compras " instruction="Este flow permite abertura de solicita&#231;&#227;o de compras automatizadas, informando qual item ser&#225; comprado e direcionado para as aprova&#231;&#245;es corretas." keyWord="" managerAssignmentController="&lt;org.eclipse.bpmn2.impl.AssignmentControllerGroup&gt;&#10; &lt;groupId&gt;TIC&lt;/groupId&gt;&#10; &lt;mechanismName&gt;Grupo&lt;/mechanismName&gt;&#10;&lt;/org.eclipse.bpmn2.impl.AssignmentControllerGroup&gt;" name="Solicita&#231;&#227;o de compra - Ginseng" notifyRequisitionerComplements="true" notifyResponsibleComplements="true" serverId="Ginseng Produ&#231;&#227;o" version="8" volume="Default"/>
<bpmn2:BpmnProcess author="" cardIndex="9305" category="Compras - Testes" complementsLevel="1" descriptorFields="&lt;list&gt;&#10; &lt;org.eclipse.bpmn2.impl.BpmnProcessFormField&gt;&#10; &lt;id&gt;descProduto&lt;/id&gt;&#10; &lt;label&gt;descProduto&lt;/label&gt;&#10; &lt;cardIndex&gt;9305 - compras_digital&lt;/cardIndex&gt;&#10; &lt;/org.eclipse.bpmn2.impl.BpmnProcessFormField&gt;&#10; &lt;org.eclipse.bpmn2.impl.BpmnProcessFormField&gt;&#10; &lt;id&gt;empresa&lt;/id&gt;&#10; &lt;label&gt;empresa&lt;/label&gt;&#10; &lt;cardIndex&gt;9305 - compras_digital&lt;/cardIndex&gt;&#10; &lt;/org.eclipse.bpmn2.impl.BpmnProcessFormField&gt;&#10; &lt;org.eclipse.bpmn2.impl.BpmnProcessFormField&gt;&#10; &lt;id&gt;estabelecimento&lt;/id&gt;&#10; &lt;label&gt;estabelecimento&lt;/label&gt;&#10; &lt;cardIndex&gt;9305 - compras_digital&lt;/cardIndex&gt;&#10; &lt;/org.eclipse.bpmn2.impl.BpmnProcessFormField&gt;&#10; &lt;org.eclipse.bpmn2.impl.BpmnProcessFormField&gt;&#10; &lt;id&gt;filialdest&lt;/id&gt;&#10; &lt;label&gt;filialdest&lt;/label&gt;&#10; &lt;cardIndex&gt;9305 - compras_digital&lt;/cardIndex&gt;&#10; &lt;/org.eclipse.bpmn2.impl.BpmnProcessFormField&gt;&#10; &lt;org.eclipse.bpmn2.impl.BpmnProcessFormField&gt;&#10; &lt;id&gt;numeroSCProtheus&lt;/id&gt;&#10; &lt;label&gt;numeroSCProtheus&lt;/label&gt;&#10; &lt;cardIndex&gt;9305 - compras_digital&lt;/cardIndex&gt;&#10; &lt;/org.eclipse.bpmn2.impl.BpmnProcessFormField&gt;&#10; &lt;org.eclipse.bpmn2.impl.BpmnProcessFormField&gt;&#10; &lt;id&gt;pedidoSCProtheus&lt;/id&gt;&#10; &lt;label&gt;pedidoSCProtheus&lt;/label&gt;&#10; &lt;cardIndex&gt;9305 - compras_digital&lt;/cardIndex&gt;&#10; &lt;/org.eclipse.bpmn2.impl.BpmnProcessFormField&gt;&#10; &lt;org.eclipse.bpmn2.impl.BpmnProcessFormField&gt;&#10; &lt;id&gt;quantidade&lt;/id&gt;&#10; &lt;label&gt;quantidade&lt;/label&gt;&#10; &lt;cardIndex&gt;9305 - compras_digital&lt;/cardIndex&gt;&#10; &lt;/org.eclipse.bpmn2.impl.BpmnProcessFormField&gt;&#10; &lt;org.eclipse.bpmn2.impl.BpmnProcessFormField&gt;&#10; &lt;id&gt;solicitanteSCProtheus&lt;/id&gt;&#10; &lt;label&gt;solicitanteSCProtheus&lt;/label&gt;&#10; &lt;cardIndex&gt;9305 - compras_digital&lt;/cardIndex&gt;&#10; &lt;/org.eclipse.bpmn2.impl.BpmnProcessFormField&gt;&#10; &lt;org.eclipse.bpmn2.impl.BpmnProcessFormField&gt;&#10; &lt;id&gt;urgencia&lt;/id&gt;&#10; &lt;label&gt;urgencia&lt;/label&gt;&#10; &lt;cardIndex&gt;9305 - compras_digital&lt;/cardIndex&gt;&#10; &lt;/org.eclipse.bpmn2.impl.BpmnProcessFormField&gt;&#10; &lt;org.eclipse.bpmn2.impl.BpmnProcessFormField&gt;&#10; &lt;id&gt;valorTotalCotacao&lt;/id&gt;&#10; &lt;label&gt;valorTotalCotacao&lt;/label&gt;&#10; &lt;cardIndex&gt;9305 - compras_digital&lt;/cardIndex&gt;&#10; &lt;/org.eclipse.bpmn2.impl.BpmnProcessFormField&gt;&#10;&lt;/list&gt;" expedient="Default" extendedFields="&lt;list/&gt;" formSource="server" id="Solicita&#231;&#227;o de compras " instruction="Este flow permite abertura de solicita&#231;&#227;o de compras automatizadas, informando qual item ser&#225; comprado e direcionado para as aprova&#231;&#245;es corretas." keyWord="" managerAssignmentController="&lt;org.eclipse.bpmn2.impl.AssignmentControllerGroup&gt;&#10; &lt;groupId&gt;TIC&lt;/groupId&gt;&#10; &lt;mechanismName&gt;Grupo&lt;/mechanismName&gt;&#10;&lt;/org.eclipse.bpmn2.impl.AssignmentControllerGroup&gt;" name="Solicita&#231;&#227;o de compra - Ginseng" notifyRequisitionerComplements="true" notifyResponsibleComplements="true" serverId="Ginseng Produ&#231;&#227;o" version="86" volume="Default"/>
<bpmn2:SequenceFlow atividadeFluxo="" atividadeRetorno="" extendedFields="&lt;list/&gt;" id="flow26" name="" sourceRef="task24" targetRef="task18"/>
<bpmn2:SequenceFlow atividadeFluxo="" atividadeRetorno="" extendedFields="&lt;list/&gt;" id="flow47" name="" sourceRef="task18" targetRef="exclusivegateway46"/>
<bpmn2:SequenceFlow atividadeFluxo="" atividadeRetorno="" extendedFields="&lt;list/&gt;" id="flow48" name="Reprovar" sourceRef="exclusivegateway46" targetRef="task24"/>
@@ -9134,5 +9134,5 @@
<bpmn2:BpmnTask authNotify="true" esforcoCalculo="0" executionAttempts="0" expediente="" frequency="0" id="task158" incoming="flow159" loopType="0" name="Aprova&#231;&#227;o CEO" outgoing="flow160" selecionaColaboradores="1" type="80"/>
<bpmn2:SequenceFlow atividadeFluxo="" atividadeRetorno="" extendedFields="&lt;list/&gt;" id="flow159" name="" sourceRef="exclusivegateway154" targetRef="task158"/>
<bpmn2:SequenceFlow atividadeFluxo="" atividadeRetorno="" extendedFields="&lt;list/&gt;" id="flow160" name="" sourceRef="task158" targetRef="task18"/>
<bpmn2:SequenceFlow atividadeFluxo="Ajustar Solicita&#231;&#227;o" atividadeRetorno="" id="flow161" name="" sourceRef="task121" targetRef="startevent1"/>
<bpmn2:SequenceFlow atividadeFluxo="Ajustar Solicita&#231;&#227;o" atividadeRetorno="" extendedFields="&lt;list/&gt;" id="flow161" name="" sourceRef="task121" targetRef="startevent1"/>
</xmi:XMI>
@@ -38,10 +38,21 @@ function servicetask82(attempt, message) {
log.info("📌 Item adicionado: " + JSON.stringify(item));
}
var filial = String(
hAPI.getCardValue("filialprotheus") ||
hAPI.getCardValue("filialProtheus") ||
hAPI.getCardValue("codigocentroCusto") ||
""
).trim();
if (!filial) {
throw "Campo PROTHEUS da filial não preenchido no formulário (filialprotheus).";
}
log.info("🏬 Filial PROTHEUS enviada no C1_FILENT: " + filial);
var payload = {
"C1_SOLICIT": String(hAPI.getCardValue("usuarioSolicitante")),
"C1_EMISSAO": hojeProtheus(),
"C1_FILENT": String(hAPI.getCardValue("filialProtheus")).trim(),
"C1_FILENT": filial,
"C1_OBS": String(hAPI.getCardValue("observacoes")),
"itens": itens
};
@@ -52,9 +63,9 @@ function servicetask82(attempt, message) {
var data1 = {
companyId: '1',
serviceCode: 'Postprod',
endpoint: '/rest/UF_MATA110',
endpoint: '/UF_MATA110',
method: 'post',
timeoutService: '100',
timeoutService: '60000',
params: payload, // objeto puro
headers: {
'Content-Type': 'application/json'
@@ -66,21 +77,27 @@ function servicetask82(attempt, message) {
var response = clientService.invoke(JSON.stringify(data1)); // SEMPRE stringify aqui
log.info("📬 Resposta da API Protheus:");
log.dir(response);
if (response) {
log.info("HTTP status: " + response.getHttpStatusResult());
log.info("Body: " + response.getResult());
}
if (response && response.getResult()) {
var result = JSON.parse(response.getResult());
if (result.sucesso) {
hAPI.setCardValue("numeroSCProtheus", result.C1_NUM || "");
hAPI.setCardValue("statusSCProtheus", "SC cadastrada com sucesso");
hAPI.setCardValue("statusAtendimento", "Em andamento");
hAPI.setCardValue("solicitanteSCProtheus", result.C1_SOLICIT || "");
hAPI.setCardValue("emissaoSCProtheus", result.C1_EMISSAO || "");
hAPI.setCardValue("qtdItensSCProtheus", String(result.quantidade_itens || ""));
hAPI.setCardValue("dataCadastroSCProtheus", result.data_cadastro || "");
hAPI.setCardValue("horaCadastroSCProtheus", result.hora_cadastro || "");
} else {
hAPI.setCardValue("statusSCProtheus", "Erro: " + result.erro);
throw "Erro Protheus: " + result.message;
var erroMsg = result.erro || result.message || JSON.stringify(result);
hAPI.setCardValue("statusSCProtheus", "Erro: " + erroMsg);
hAPI.setCardValue("statusAtendimento", "Erro no envio");
throw "Erro Protheus: " + erroMsg;
}
} else {
throw "Sem resposta da API Protheus";