{"product":"happytree-node.workflows","formatVersion":1,"workflows":[{"id":"workflow-1","workflow":{"product":"happytree-node.workflow","formatVersion":1,"blueprint":{"name":"E01 00 \u2014 Demonstracao sem mensagens","nodes":[{"id":"inicio","type":"data.object","settings":{"json":"{}"},"x":80,"y":80},{"id":"etapa-1","type":"workflows.call","settings":{"workflowId":"workflow-2"},"x":450,"y":80},{"id":"etapa-2","type":"workflows.call","settings":{"workflowId":"workflow-3"},"x":820,"y":80},{"id":"resultado","type":"files.save-json","settings":{"name":"ebook01-00-resultado.json"},"x":1190,"y":80}],"edges":[{"source":"inicio","target":"etapa-1"},{"source":"etapa-1","target":"etapa-2"},{"source":"etapa-2","target":"resultado"}],"schemaVersion":1},"requiredBindings":[]}},{"id":"workflow-2","workflow":{"product":"happytree-node.workflow","formatVersion":1,"blueprint":{"name":"E01 01 \u2014 Atualizar as tres planilhas","nodes":[{"id":"entrada","type":"workflows.input","settings":{},"x":80,"y":80},{"id":"vencimentos-arquivo","type":"files.load-local","settings":{"maxMegabytes":1,"path":"__htn_configurar__"},"x":450,"y":80},{"id":"vencimentos-tabela","type":"tables.artifact-csv","settings":{"delimiter":";"},"x":820,"y":80},{"id":"vencimentos-unicos","type":"tables.distinct","settings":{"keys":"id","keep":"\u00DAltimo","ignoreCase":false},"x":1190,"y":80},{"id":"vencimentos-valor","type":"numbers.column","settings":{"column":"valor","target":"N\u00FAmero","format":"Ponto","nulls":"Falhar"},"x":80,"y":320},{"id":"vencimentos-ativo","type":"numbers.column","settings":{"column":"ativo","target":"N\u00FAmero","format":"Ponto","nulls":"Falhar"},"x":450,"y":320},{"id":"vencimentos-cada","type":"flow.foreach","settings":{"maxItems":100},"x":820,"y":320},{"id":"vencimentos-gravar","type":"database.command-data","settings":{"maxAffectedRows":1,"sql":"INSERT INTO vencimentos(id,descricao,valor,vencimento,status,ocorrencia,ativo) VALUES (@id,@descricao,@valor,@vencimento,@status,@ocorrencia,@ativo) ON CONFLICT(id) DO UPDATE SET descricao=excluded.descricao,valor=excluded.valor,vencimento=excluded.vencimento,status=excluded.status,ocorrencia=excluded.ocorrencia,ativo=excluded.ativo","parameters":"{}","connectionId":"__htn_configurar__"},"x":1190,"y":320},{"id":"vencimentos-fim","type":"flow.end","settings":{"loopId":"vencimentos-cada"},"x":80,"y":560},{"id":"estoque-arquivo","type":"files.load-local","settings":{"maxMegabytes":1,"path":"__htn_configurar__"},"x":450,"y":560},{"id":"estoque-tabela","type":"tables.artifact-csv","settings":{"delimiter":";"},"x":820,"y":560},{"id":"estoque-unicos","type":"tables.distinct","settings":{"keys":"produto_id","keep":"\u00DAltimo","ignoreCase":false},"x":1190,"y":560},{"id":"estoque-saldo","type":"numbers.column","settings":{"column":"saldo","target":"N\u00FAmero","format":"Ponto","nulls":"Falhar"},"x":80,"y":800},{"id":"estoque-minimo","type":"numbers.column","settings":{"column":"minimo","target":"N\u00FAmero","format":"Ponto","nulls":"Falhar"},"x":450,"y":800},{"id":"estoque-ativo","type":"numbers.column","settings":{"column":"ativo","target":"N\u00FAmero","format":"Ponto","nulls":"Falhar"},"x":820,"y":800},{"id":"estoque-cada","type":"flow.foreach","settings":{"maxItems":100},"x":1190,"y":800},{"id":"estoque-gravar","type":"database.command-data","settings":{"maxAffectedRows":1,"sql":"INSERT INTO estoque(produto_id,produto,saldo,minimo,ocorrencia,ativo) VALUES (@produto_id,@produto,@saldo,@minimo,@ocorrencia,@ativo) ON CONFLICT(produto_id) DO UPDATE SET produto=excluded.produto,saldo=excluded.saldo,minimo=excluded.minimo,ocorrencia=excluded.ocorrencia,ativo=excluded.ativo","parameters":"{}","connectionId":"__htn_configurar__"},"x":80,"y":1040},{"id":"estoque-fim","type":"flow.end","settings":{"loopId":"estoque-cada"},"x":450,"y":1040},{"id":"pedidos-arquivo","type":"files.load-local","settings":{"maxMegabytes":1,"path":"__htn_configurar__"},"x":820,"y":1040},{"id":"pedidos-tabela","type":"tables.artifact-csv","settings":{"delimiter":";"},"x":1190,"y":1040},{"id":"pedidos-unicos","type":"tables.distinct","settings":{"keys":"pedido_id","keep":"\u00DAltimo","ignoreCase":false},"x":80,"y":1280},{"id":"pedidos-ativo","type":"numbers.column","settings":{"column":"ativo","target":"N\u00FAmero","format":"Ponto","nulls":"Falhar"},"x":450,"y":1280},{"id":"pedidos-cada","type":"flow.foreach","settings":{"maxItems":100},"x":820,"y":1280},{"id":"pedidos-gravar","type":"database.command-data","settings":{"maxAffectedRows":1,"sql":"INSERT INTO pedidos(pedido_id,cliente,status,ocorrencia,ativo) VALUES (@pedido_id,@cliente,@status,@ocorrencia,@ativo) ON CONFLICT(pedido_id) DO UPDATE SET cliente=excluded.cliente,status=excluded.status,ocorrencia=excluded.ocorrencia,ativo=excluded.ativo","parameters":"{}","connectionId":"__htn_configurar__"},"x":1190,"y":1280},{"id":"pedidos-fim","type":"flow.end","settings":{"loopId":"pedidos-cada"},"x":80,"y":1520},{"id":"importacoes","type":"data.build-list","settings":{"mode":"Entradas"},"x":450,"y":1520},{"id":"resultado","type":"data.build-object","settings":{"fields":"{\u0022contexto\u0022: {\u0022input\u0022: 1, \u0022pointer\u0022: \u0022\u0022}, \u0022resultado\u0022: {\u0022input\u0022: 2, \u0022pointer\u0022: \u0022\u0022}}"},"x":820,"y":1520},{"id":"retorno","type":"workflows.return","settings":{},"x":1190,"y":1520}],"edges":[{"source":"vencimentos-arquivo","target":"vencimentos-tabela"},{"source":"vencimentos-tabela","target":"vencimentos-unicos"},{"source":"vencimentos-unicos","target":"vencimentos-valor"},{"source":"vencimentos-valor","target":"vencimentos-ativo"},{"source":"vencimentos-ativo","target":"vencimentos-cada"},{"source":"vencimentos-cada","target":"vencimentos-gravar"},{"source":"vencimentos-gravar","target":"vencimentos-fim"},{"source":"estoque-arquivo","target":"estoque-tabela"},{"source":"estoque-tabela","target":"estoque-unicos"},{"source":"estoque-unicos","target":"estoque-saldo"},{"source":"estoque-saldo","target":"estoque-minimo"},{"source":"estoque-minimo","target":"estoque-ativo"},{"source":"estoque-ativo","target":"estoque-cada"},{"source":"estoque-cada","target":"estoque-gravar"},{"source":"estoque-gravar","target":"estoque-fim"},{"source":"pedidos-arquivo","target":"pedidos-tabela"},{"source":"pedidos-tabela","target":"pedidos-unicos"},{"source":"pedidos-unicos","target":"pedidos-ativo"},{"source":"pedidos-ativo","target":"pedidos-cada"},{"source":"pedidos-cada","target":"pedidos-gravar"},{"source":"pedidos-gravar","target":"pedidos-fim"},{"source":"vencimentos-fim","target":"importacoes","order":0},{"source":"estoque-fim","target":"importacoes","order":1},{"source":"pedidos-fim","target":"importacoes","order":2},{"source":"entrada","target":"resultado","order":0},{"source":"importacoes","target":"resultado","order":1},{"source":"resultado","target":"retorno"}],"schemaVersion":1},"requiredBindings":[{"nodeId":"vencimentos-arquivo","nodeName":"Carregar arquivo da pasta","property":"path","title":"Arquivo no Servidor Local","kind":"local-file"},{"nodeId":"vencimentos-gravar","nodeName":"Executar comando SQL com dados","property":"connectionId","title":"Conex\u00E3o","kind":"connection"},{"nodeId":"estoque-arquivo","nodeName":"Carregar arquivo da pasta","property":"path","title":"Arquivo no Servidor Local","kind":"local-file"},{"nodeId":"estoque-gravar","nodeName":"Executar comando SQL com dados","property":"connectionId","title":"Conex\u00E3o","kind":"connection"},{"nodeId":"pedidos-arquivo","nodeName":"Carregar arquivo da pasta","property":"path","title":"Arquivo no Servidor Local","kind":"local-file"},{"nodeId":"pedidos-gravar","nodeName":"Executar comando SQL com dados","property":"connectionId","title":"Conex\u00E3o","kind":"connection"}]}},{"id":"workflow-3","workflow":{"product":"happytree-node.workflow","formatVersion":1,"blueprint":{"name":"E01 02 \u2014 Diagnostico sem envio","nodes":[{"id":"entrada","type":"workflows.input","settings":{},"x":80,"y":80},{"id":"variaveis","type":"data.variables","settings":{},"x":450,"y":80},{"id":"alertas","type":"database.query-data","settings":{"maxRows":100,"rowLimitMode":"Falhar se ultrapassar","sql":"SELECT * FROM (SELECT \u0027ven:\u0027||id||\u0027:\u0027||vencimento||\u0027:\u0027||ocorrencia AS evento_id,\u0027Vencimento\u0027 AS categoria,id AS registro_id,\u0027Vencimento: \u0027||descricao||\u0027 | data \u0027||vencimento||\u0027 | R$ \u0027||printf(\u0027%.2f\u0027,valor) AS resumo,@ebook01_grupo AS destino FROM vencimentos WHERE ativo=1 AND status=\u0027Aberto\u0027 AND date(vencimento)\u003C=date(COALESCE(NULLIF(@ebook01_data_referencia,\u0027\u0027),date(\u0027now\u0027,\u0027localtime\u0027)),\u0027\u002B3 days\u0027)\nUNION ALL SELECT \u0027est:\u0027||produto_id||\u0027:\u0027||ocorrencia,\u0027Estoque\u0027,produto_id,\u0027Estoque: \u0027||produto||\u0027 | saldo \u0027||printf(\u0027%g\u0027,saldo)||\u0027 | minimo \u0027||printf(\u0027%g\u0027,minimo),@ebook01_grupo FROM estoque WHERE ativo=1 AND saldo\u003C=minimo\nUNION ALL SELECT \u0027ped:\u0027||pedido_id||\u0027:\u0027||ocorrencia,\u0027Pedido\u0027,pedido_id,\u0027Pedido: \u0027||pedido_id||\u0027 | \u0027||cliente||\u0027 | status \u0027||status,@ebook01_grupo FROM pedidos WHERE ativo=1 AND status IN (\u0027Atrasado\u0027,\u0027Aguardando pagamento\u0027,\u0027Separacao pendente\u0027)) AS c ORDER BY categoria,registro_id","parameters":"{}","connectionId":"__htn_configurar__"},"x":820,"y":80},{"id":"excel","type":"tables.export-xlsx","settings":{"name":"e01-alertas.xlsx"},"x":1190,"y":80},{"id":"json","type":"tables.json","settings":{},"x":80,"y":320},{"id":"arquivo-json","type":"files.save-json","settings":{"name":"e01-alertas.json"},"x":450,"y":320},{"id":"texto","type":"tables.text","settings":{"template":"\u2022 {{/categoria}} | {{/registro_id}} | {{/resumo}}","separator":"Nova linha"},"x":820,"y":320},{"id":"arquivo-texto","type":"files.save-text","settings":{"name":"e01-alertas.txt"},"x":1190,"y":320},{"id":"resultado","type":"data.build-object","settings":{"fields":"{\u0022contexto\u0022: {\u0022input\u0022: 1, \u0022pointer\u0022: \u0022\u0022}, \u0022resultado\u0022: {\u0022input\u0022: 2, \u0022pointer\u0022: \u0022\u0022}}"},"x":80,"y":560},{"id":"retorno","type":"workflows.return","settings":{},"x":450,"y":560}],"edges":[{"source":"variaveis","target":"alertas"},{"source":"alertas","target":"excel"},{"source":"alertas","target":"json"},{"source":"json","target":"arquivo-json"},{"source":"alertas","target":"texto"},{"source":"texto","target":"arquivo-texto"},{"source":"entrada","target":"resultado","order":0},{"source":"json","target":"resultado","order":1},{"source":"resultado","target":"retorno"}],"schemaVersion":1},"requiredBindings":[{"nodeId":"alertas","nodeName":"Consultar SQL com dados","property":"connectionId","title":"Conex\u00E3o","kind":"connection"}]}},{"id":"workflow-4","workflow":{"product":"happytree-node.workflow","formatVersion":1,"blueprint":{"name":"E01 03 \u2014 Preparar mensagens para revisao","nodes":[{"id":"entrada","type":"workflows.input","settings":{},"x":80,"y":80},{"id":"variaveis","type":"data.variables","settings":{},"x":450,"y":80},{"id":"novos","type":"database.query-data","settings":{"maxRows":100,"rowLimitMode":"Falhar se ultrapassar","sql":"SELECT * FROM (SELECT \u0027ven:\u0027||id||\u0027:\u0027||vencimento||\u0027:\u0027||ocorrencia AS evento_id,\u0027Vencimento\u0027 AS categoria,id AS registro_id,\u0027Vencimento: \u0027||descricao||\u0027 | data \u0027||vencimento||\u0027 | R$ \u0027||printf(\u0027%.2f\u0027,valor) AS resumo,@ebook01_grupo AS destino FROM vencimentos WHERE ativo=1 AND status=\u0027Aberto\u0027 AND date(vencimento)\u003C=date(COALESCE(NULLIF(@ebook01_data_referencia,\u0027\u0027),date(\u0027now\u0027,\u0027localtime\u0027)),\u0027\u002B3 days\u0027)\nUNION ALL SELECT \u0027est:\u0027||produto_id||\u0027:\u0027||ocorrencia,\u0027Estoque\u0027,produto_id,\u0027Estoque: \u0027||produto||\u0027 | saldo \u0027||printf(\u0027%g\u0027,saldo)||\u0027 | minimo \u0027||printf(\u0027%g\u0027,minimo),@ebook01_grupo FROM estoque WHERE ativo=1 AND saldo\u003C=minimo\nUNION ALL SELECT \u0027ped:\u0027||pedido_id||\u0027:\u0027||ocorrencia,\u0027Pedido\u0027,pedido_id,\u0027Pedido: \u0027||pedido_id||\u0027 | \u0027||cliente||\u0027 | status \u0027||status,@ebook01_grupo FROM pedidos WHERE ativo=1 AND status IN (\u0027Atrasado\u0027,\u0027Aguardando pagamento\u0027,\u0027Separacao pendente\u0027)) AS c WHERE NOT EXISTS (SELECT 1 FROM historico_eventos h WHERE h.evento_id=c.evento_id) ORDER BY categoria,registro_id","parameters":"{}","connectionId":"__htn_configurar__"},"x":820,"y":80},{"id":"cada","type":"flow.foreach","settings":{"maxItems":100},"x":1190,"y":80},{"id":"preparar","type":"communications.whatsapp-data","settings":{"key":"ebook01:{{/evento_id}}","targetType":"Grupo","to":"{{/destino}}","body":"HappyTreeNode | Alerta interno\n{{/resumo}}\nEvento: {{/evento_id}}\nConfira a planilha antes de agir.","browser":"Microsoft Edge","sendMode":"Somente preparar","closeAfterSend":true,"batchDelaySeconds":8,"attachmentSourceId":"","attachmentMode":"Documento"},"x":80,"y":320},{"id":"parametros","type":"data.build-object","settings":{"fields":"{\u0022evento_id\u0022: {\u0022input\u0022: 1, \u0022pointer\u0022: \u0022/evento_id\u0022}, \u0022categoria\u0022: {\u0022input\u0022: 1, \u0022pointer\u0022: \u0022/categoria\u0022}, \u0022registro_id\u0022: {\u0022input\u0022: 1, \u0022pointer\u0022: \u0022/registro_id\u0022}, \u0022resumo\u0022: {\u0022input\u0022: 1, \u0022pointer\u0022: \u0022/resumo\u0022}, \u0022destino\u0022: {\u0022input\u0022: 1, \u0022pointer\u0022: \u0022/destino\u0022}, \u0022rascunho_id\u0022: {\u0022input\u0022: 2, \u0022pointer\u0022: \u0022/draftId\u0022}, \u0022estado_htn\u0022: {\u0022input\u0022: 2, \u0022pointer\u0022: \u0022/status\u0022}}"},"x":450,"y":320},{"id":"historico","type":"database.command-data","settings":{"maxAffectedRows":1,"sql":"INSERT INTO historico_eventos(evento_id,categoria,registro_id,resumo,destino,estado,modo,rascunho_id,estado_htn) SELECT @evento_id,@categoria,@registro_id,@resumo,@destino,\u0027preparado\u0027,\u0027revisao\u0027,@rascunho_id,@estado_htn WHERE NOT EXISTS (SELECT 1 FROM historico_eventos WHERE evento_id=@evento_id)","parameters":"{}","connectionId":"__htn_configurar__"},"x":820,"y":320},{"id":"fim","type":"flow.end","settings":{"loopId":"cada"},"x":1190,"y":320},{"id":"resultado","type":"data.build-object","settings":{"fields":"{\u0022contexto\u0022: {\u0022input\u0022: 1, \u0022pointer\u0022: \u0022\u0022}, \u0022resultado\u0022: {\u0022input\u0022: 2, \u0022pointer\u0022: \u0022\u0022}}"},"x":80,"y":560},{"id":"retorno","type":"workflows.return","settings":{},"x":450,"y":560}],"edges":[{"source":"variaveis","target":"novos"},{"source":"novos","target":"cada"},{"source":"cada","target":"preparar","order":0},{"source":"cada","target":"parametros","order":0},{"source":"preparar","target":"parametros","order":1},{"source":"parametros","target":"historico"},{"source":"historico","target":"fim"},{"source":"entrada","target":"resultado","order":0},{"source":"fim","target":"resultado","order":1},{"source":"resultado","target":"retorno"}],"schemaVersion":1},"requiredBindings":[{"nodeId":"novos","nodeName":"Consultar SQL com dados","property":"connectionId","title":"Conex\u00E3o","kind":"connection"},{"nodeId":"historico","nodeName":"Executar comando SQL com dados","property":"connectionId","title":"Conex\u00E3o","kind":"connection"}]}},{"id":"workflow-5","workflow":{"product":"happytree-node.workflow","formatVersion":1,"blueprint":{"name":"E01 04 \u2014 Sincronizar estado do historico","nodes":[{"id":"entrada","type":"workflows.input","settings":{},"x":80,"y":80},{"id":"consultar","type":"database.query","settings":{"maxRows":100,"rowLimitMode":"Falhar se ultrapassar","sql":"SELECT evento_id,rascunho_id AS draftId FROM historico_eventos WHERE rascunho_id\u003C\u003E\u0027\u0027 ORDER BY evento_id","parameters":"{}","connectionId":"__htn_configurar__"},"x":450,"y":80},{"id":"cada","type":"flow.foreach","settings":{"maxItems":100},"x":820,"y":80},{"id":"estado","type":"communications.status","settings":{},"x":1190,"y":80},{"id":"parametros","type":"data.build-object","settings":{"fields":"{\u0022evento_id\u0022: {\u0022input\u0022: 1, \u0022pointer\u0022: \u0022/evento_id\u0022}, \u0022estado_htn\u0022: {\u0022input\u0022: 2, \u0022pointer\u0022: \u0022/status\u0022}, \u0022codigo_htn\u0022: {\u0022input\u0022: 2, \u0022pointer\u0022: \u0022/code\u0022}}"},"x":80,"y":320},{"id":"atualizar","type":"database.command-data","settings":{"maxAffectedRows":1,"sql":"UPDATE historico_eventos SET estado=CASE WHEN @estado_htn IN (\u0027sent\u0027,\u0027send_clicked\u0027,\u0027accepted\u0027) THEN \u0027processado\u0027 WHEN @estado_htn IN (\u0027pending\u0027,\u0027approved\u0027,\u0027prepared\u0027) THEN \u0027preparado\u0027 ELSE \u0027incerto\u0027 END,estado_htn=@estado_htn,codigo_htn=COALESCE(@codigo_htn,\u0027\u0027),atualizado_em=strftime(\u0027%Y-%m-%dT%H:%M:%fZ\u0027,\u0027now\u0027) WHERE evento_id=@evento_id","parameters":"{}","connectionId":"__htn_configurar__"},"x":450,"y":320},{"id":"fim","type":"flow.end","settings":{"loopId":"cada"},"x":820,"y":320},{"id":"resultado","type":"data.build-object","settings":{"fields":"{\u0022contexto\u0022: {\u0022input\u0022: 1, \u0022pointer\u0022: \u0022\u0022}, \u0022resultado\u0022: {\u0022input\u0022: 2, \u0022pointer\u0022: \u0022\u0022}}"},"x":1190,"y":320},{"id":"retorno","type":"workflows.return","settings":{},"x":80,"y":560}],"edges":[{"source":"consultar","target":"cada"},{"source":"cada","target":"estado"},{"source":"cada","target":"parametros","order":0},{"source":"estado","target":"parametros","order":1},{"source":"parametros","target":"atualizar"},{"source":"atualizar","target":"fim"},{"source":"entrada","target":"resultado","order":0},{"source":"fim","target":"resultado","order":1},{"source":"resultado","target":"retorno"}],"schemaVersion":1},"requiredBindings":[{"nodeId":"consultar","nodeName":"Consultar SQL","property":"connectionId","title":"Conex\u00E3o","kind":"connection"},{"nodeId":"atualizar","nodeName":"Executar comando SQL com dados","property":"connectionId","title":"Conex\u00E3o","kind":"connection"}]}},{"id":"workflow-6","workflow":{"product":"happytree-node.workflow","formatVersion":1,"blueprint":{"name":"E01 05 \u2014 Notificar automaticamente (opcional)","nodes":[{"id":"entrada","type":"workflows.input","settings":{},"x":80,"y":80},{"id":"variaveis","type":"data.variables","settings":{},"x":450,"y":80},{"id":"habilitado","type":"flow.condition","settings":{"pointer":"/ebook01_automatico","operator":"Igual a","valueType":"L\u00F3gico","value":"true","ignoreCase":false},"x":820,"y":80},{"id":"novos","type":"database.query-data","settings":{"maxRows":5,"rowLimitMode":"Falhar se ultrapassar","sql":"SELECT * FROM (SELECT \u0027ven:\u0027||id||\u0027:\u0027||vencimento||\u0027:\u0027||ocorrencia AS evento_id,\u0027Vencimento\u0027 AS categoria,id AS registro_id,\u0027Vencimento: \u0027||descricao||\u0027 | data \u0027||vencimento||\u0027 | R$ \u0027||printf(\u0027%.2f\u0027,valor) AS resumo,@ebook01_grupo AS destino FROM vencimentos WHERE ativo=1 AND status=\u0027Aberto\u0027 AND date(vencimento)\u003C=date(COALESCE(NULLIF(@ebook01_data_referencia,\u0027\u0027),date(\u0027now\u0027,\u0027localtime\u0027)),\u0027\u002B3 days\u0027)\nUNION ALL SELECT \u0027est:\u0027||produto_id||\u0027:\u0027||ocorrencia,\u0027Estoque\u0027,produto_id,\u0027Estoque: \u0027||produto||\u0027 | saldo \u0027||printf(\u0027%g\u0027,saldo)||\u0027 | minimo \u0027||printf(\u0027%g\u0027,minimo),@ebook01_grupo FROM estoque WHERE ativo=1 AND saldo\u003C=minimo\nUNION ALL SELECT \u0027ped:\u0027||pedido_id||\u0027:\u0027||ocorrencia,\u0027Pedido\u0027,pedido_id,\u0027Pedido: \u0027||pedido_id||\u0027 | \u0027||cliente||\u0027 | status \u0027||status,@ebook01_grupo FROM pedidos WHERE ativo=1 AND status IN (\u0027Atrasado\u0027,\u0027Aguardando pagamento\u0027,\u0027Separacao pendente\u0027)) AS c WHERE NOT EXISTS (SELECT 1 FROM historico_eventos h WHERE h.evento_id=c.evento_id) ORDER BY categoria,registro_id","parameters":"{}","connectionId":"__htn_configurar__"},"x":1190,"y":80},{"id":"cada","type":"flow.foreach","settings":{"maxItems":5},"x":80,"y":320},{"id":"reservar","type":"database.command-data","settings":{"maxAffectedRows":1,"sql":"INSERT INTO historico_eventos(evento_id,categoria,registro_id,resumo,destino,estado,modo,estado_htn,codigo_htn) SELECT @evento_id,@categoria,@registro_id,@resumo,@destino,\u0027incerto\u0027,\u0027automatico\u0027,\u0027reserva\u0027,\u0027verificar_se_interrompido\u0027 WHERE NOT EXISTS (SELECT 1 FROM historico_eventos WHERE evento_id=@evento_id)","parameters":"{}","connectionId":"__htn_configurar__"},"x":450,"y":320},{"id":"reserva-e-evento","type":"data.build-object","settings":{"fields":"{\u0022evento\u0022: {\u0022input\u0022: 1, \u0022pointer\u0022: \u0022\u0022}, \u0022reserva\u0022: {\u0022input\u0022: 2, \u0022pointer\u0022: \u0022\u0022}}"},"x":820,"y":320},{"id":"reserva-nova","type":"flow.condition","settings":{"pointer":"/reserva/affectedRows","operator":"Maior que","valueType":"N\u00FAmero","value":"0","ignoreCase":false},"x":1190,"y":320},{"id":"evento","type":"data.path","settings":{"pointer":"/evento"},"x":80,"y":560},{"id":"notificar","type":"communications.notify-whatsapp-data","settings":{"key":"ebook01:auto:{{/evento_id}}","targetType":"Grupo","to":"{{/destino}}","body":"HappyTreeNode | Alerta interno\n{{/resumo}}\nEvento: {{/evento_id}}\nConfira a planilha antes de agir.","browser":"Microsoft Edge","batchDelaySeconds":15,"attachmentSourceId":"","attachmentMode":"Documento"},"x":450,"y":560},{"id":"sucesso","type":"data.build-object","settings":{"fields":"{\u0022evento_id\u0022: {\u0022input\u0022: 1, \u0022pointer\u0022: \u0022/evento_id\u0022}, \u0022rascunho_id\u0022: {\u0022input\u0022: 2, \u0022pointer\u0022: \u0022/draftId\u0022}, \u0022estado_htn\u0022: {\u0022input\u0022: 2, \u0022pointer\u0022: \u0022/status\u0022}}"},"x":820,"y":560},{"id":"processado","type":"database.command-data","settings":{"maxAffectedRows":1,"sql":"UPDATE historico_eventos SET estado=\u0027processado\u0027,rascunho_id=@rascunho_id,estado_htn=@estado_htn,codigo_htn=\u0027\u0027,atualizado_em=strftime(\u0027%Y-%m-%dT%H:%M:%fZ\u0027,\u0027now\u0027) WHERE evento_id=@evento_id AND estado=\u0027incerto\u0027 AND modo=\u0027automatico\u0027","parameters":"{}","connectionId":"__htn_configurar__"},"x":1190,"y":560},{"id":"reunir-reserva","type":"flow.merge","settings":{},"x":80,"y":800},{"id":"fim","type":"flow.end","settings":{"loopId":"cada"},"x":450,"y":800},{"id":"desligado","type":"data.build-object","settings":{"fields":"{\u0022automatico\u0022: {\u0022literal\u0022: false}, \u0022orientacao\u0022: {\u0022literal\u0022: \u0022Nenhuma notificacao: mantenha false ate concluir a conferencia.\u0022}}"},"x":820,"y":800},{"id":"reunir-modos","type":"flow.merge","settings":{},"x":1190,"y":800},{"id":"resultado","type":"data.build-object","settings":{"fields":"{\u0022contexto\u0022: {\u0022input\u0022: 1, \u0022pointer\u0022: \u0022\u0022}, \u0022resultado\u0022: {\u0022input\u0022: 2, \u0022pointer\u0022: \u0022\u0022}}"},"x":80,"y":1040},{"id":"retorno","type":"workflows.return","settings":{},"x":450,"y":1040}],"edges":[{"source":"variaveis","target":"habilitado"},{"source":"habilitado","target":"novos","branch":"true"},{"source":"novos","target":"cada"},{"source":"cada","target":"reservar"},{"source":"cada","target":"reserva-e-evento","order":0},{"source":"reservar","target":"reserva-e-evento","order":1},{"source":"reserva-e-evento","target":"reserva-nova"},{"source":"reserva-nova","target":"evento","branch":"true"},{"source":"evento","target":"notificar","order":0},{"source":"evento","target":"sucesso","order":0},{"source":"notificar","target":"sucesso","order":1},{"source":"sucesso","target":"processado"},{"source":"processado","target":"reunir-reserva","order":0},{"source":"reserva-nova","target":"reunir-reserva","branch":"false","order":1},{"source":"reunir-reserva","target":"fim"},{"source":"habilitado","target":"desligado","branch":"false","order":0},{"source":"fim","target":"reunir-modos","order":0},{"source":"desligado","target":"reunir-modos","order":1},{"source":"entrada","target":"resultado","order":0},{"source":"reunir-modos","target":"resultado","order":1},{"source":"resultado","target":"retorno"}],"schemaVersion":1},"requiredBindings":[{"nodeId":"novos","nodeName":"Consultar SQL com dados","property":"connectionId","title":"Conex\u00E3o","kind":"connection"},{"nodeId":"reservar","nodeName":"Executar comando SQL com dados","property":"connectionId","title":"Conex\u00E3o","kind":"connection"},{"nodeId":"processado","nodeName":"Executar comando SQL com dados","property":"connectionId","title":"Conex\u00E3o","kind":"connection"}]}},{"id":"workflow-7","workflow":{"product":"happytree-node.workflow","formatVersion":1,"blueprint":{"name":"E01 06 \u2014 Rotina com revisao (30 min)","nodes":[{"id":"inicio","type":"data.object","settings":{"json":"{}"},"x":80,"y":80},{"id":"etapa-1","type":"workflows.call","settings":{"workflowId":"workflow-2"},"x":450,"y":80},{"id":"etapa-2","type":"workflows.call","settings":{"workflowId":"workflow-3"},"x":820,"y":80},{"id":"etapa-3","type":"workflows.call","settings":{"workflowId":"workflow-4"},"x":1190,"y":80},{"id":"etapa-4","type":"workflows.call","settings":{"workflowId":"workflow-5"},"x":80,"y":320},{"id":"resultado","type":"files.save-json","settings":{"name":"ebook01-06-resultado.json"},"x":450,"y":320}],"edges":[{"source":"inicio","target":"etapa-1"},{"source":"etapa-1","target":"etapa-2"},{"source":"etapa-2","target":"etapa-3"},{"source":"etapa-3","target":"etapa-4"},{"source":"etapa-4","target":"resultado"}],"schemaVersion":1},"requiredBindings":[]}},{"id":"workflow-8","workflow":{"product":"happytree-node.workflow","formatVersion":1,"blueprint":{"name":"E01 07 \u2014 Rotina automatica opcional (30 min)","nodes":[{"id":"inicio","type":"data.object","settings":{"json":"{}"},"x":80,"y":80},{"id":"etapa-1","type":"workflows.call","settings":{"workflowId":"workflow-2"},"x":450,"y":80},{"id":"etapa-2","type":"workflows.call","settings":{"workflowId":"workflow-3"},"x":820,"y":80},{"id":"etapa-3","type":"workflows.call","settings":{"workflowId":"workflow-5"},"x":1190,"y":80},{"id":"etapa-4","type":"workflows.call","settings":{"workflowId":"workflow-6"},"x":80,"y":320},{"id":"resultado","type":"files.save-json","settings":{"name":"ebook01-07-resultado.json"},"x":450,"y":320}],"edges":[{"source":"inicio","target":"etapa-1"},{"source":"etapa-1","target":"etapa-2"},{"source":"etapa-2","target":"etapa-3"},{"source":"etapa-3","target":"etapa-4"},{"source":"etapa-4","target":"resultado"}],"schemaVersion":1},"requiredBindings":[]}}]}