8
n8n 中文网amn8n.com

月度能源发电报告

中级

这是一个Document Extraction, Multimodal AI领域的自动化工作流,包含 7 个节点。主要使用 Code, Gmail, Postgres, HttpRequest, ScheduleTrigger 等节点。 使用 PostgreSQL、PDF.co 和邮件投递自动生成月度能源报告

前置要求
  • Google 账号和 Gmail API 凭证
  • PostgreSQL 数据库连接信息
  • 可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "lFJOVIgGwLDmQa4o",
  "meta": {
    "instanceId": "14e4c77104722ab186539dfea5182e419aecc83d85963fe13f6de862c875ebfa",
    "templateCredsSetupCompleted": true
  },
  "name": "月度能源发电报告(Postgres → PDF → 电子邮件)",
  "tags": [],
  "nodes": [
    {
      "id": "8a74f8aa-d3bf-4a08-9950-e51077071a5e",
      "name": "转换数据",
      "type": "n8n-nodes-base.code",
      "position": [
        360,
        0
      ],
      "parameters": {
        "jsCode": "return {\n  json: {\n    json_string: JSON.stringify({\n      date_range: \"2025-07-01 to 2025-07-03\",\n      records: $input.all().map(record => ({\n        id: record.json.id,\n        site_name: record.json.site_name,\n        generation_date: record.json.generation_date,\n        energy_generated_kwh: record.json.energy_generated_kwh,\n        peak_power_kw: record.json.peak_power_kw,\n        remarks: record.json.remarks\n      })),\n      note: \"TEST\"\n    })\n  }\n};\n"
      },
      "typeVersion": 2
    },
    {
      "id": "7e78ea66-5a79-4904-a514-f5916602b571",
      "name": "将数据转换为PDF",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        580,
        0
      ],
      "parameters": {
        "url": "https://api.pdf.co/v1/pdf/convert/from/html",
        "options": {},
        "sendBody": true,
        "sendQuery": true,
        "sendHeaders": true,
        "bodyParameters": {
          "parameters": [
            {}
          ]
        },
        "queryParameters": {
          "parameters": [
            {}
          ]
        },
        "headerParameters": {
          "parameters": [
            {}
          ]
        }
      },
      "executeOnce": true,
      "typeVersion": 4.2
    },
    {
      "id": "3f834d5f-2239-4842-a14e-9a1c15dbb771",
      "name": "发送报告",
      "type": "n8n-nodes-base.gmail",
      "position": [
        800,
        0
      ],
      "webhookId": "",
      "parameters": {
        "sendTo": "",
        "message": "=Your monthly energy report is as follows  {{ $json.url }}",
        "options": {
          "appendAttribution": true
        },
        "subject": "Energy Report",
        "emailType": "text"
      },
      "credentials": {
        "gmailOAuth2": {}
      },
      "typeVersion": 2.1
    },
    {
      "id": "e8dd1777-6e62-4d14-89dc-e3217b9f7318",
      "name": "获取能源数据",
      "type": "n8n-nodes-base.postgres",
      "position": [
        140,
        0
      ],
      "parameters": {
        "table": {
          "__rl": true,
          "mode": "list",
          "value": "energy_data",
          "cachedResultName": "energy_data"
        },
        "schema": {
          "__rl": true,
          "mode": "list",
          "value": "public",
          "cachedResultName": "public"
        },
        "options": {},
        "operation": "select"
      },
      "typeVersion": 2.6
    },
    {
      "id": "18bb8b25-1532-4b31-9b53-6599c6ee5624",
      "name": "月度触发器",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -80,
        0
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "months",
              "triggerAtMinute": 1
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "72b04ac2-68f3-4e90-9b02-e250f83aeb42",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -140,
        -160
      ],
      "parameters": {
        "color": 4,
        "width": 1140,
        "height": 340,
        "content": "## 月度能源发电报告(Postgres → PDF → 电子邮件)"
      },
      "typeVersion": 1
    },
    {
      "id": "04a42081-91d1-4a4b-b21c-57e26c7343da",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -140,
        220
      ],
      "parameters": {
        "color": 2,
        "width": 1140,
        "height": 400,
        "content": "## **目的**"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {
    "Transform data": [
      {
        "json": {
          "json_string": "{\"date_range\":\"2025-07-01 to 2025-07-03\",\"records\":[{\"id\":1,\"site_name\":\"Solar Plant A\",\"generation_date\":\"2025-06-30T18:30:00.000Z\",\"energy_generated_kwh\":\"1250.50\",\"peak_power_kw\":\"250.75\",\"remarks\":\"Sunny day, optimal generation\"},{\"id\":2,\"site_name\":\"Solar Plant A\",\"generation_date\":\"2025-07-01T18:30:00.000Z\",\"energy_generated_kwh\":\"1150.30\",\"peak_power_kw\":\"240.60\",\"remarks\":\"Partly cloudy\"},{\"id\":3,\"site_name\":\"Solar Plant A\",\"generation_date\":\"2025-07-02T18:30:00.000Z\",\"energy_generated_kwh\":\"980.75\",\"peak_power_kw\":\"220.10\",\"remarks\":\"Cloudy day\"},{\"id\":4,\"site_name\":\"Wind Farm B\",\"generation_date\":\"2025-06-30T18:30:00.000Z\",\"energy_generated_kwh\":\"1800.00\",\"peak_power_kw\":\"350.00\",\"remarks\":\"Strong winds, high generation\"},{\"id\":5,\"site_name\":\"Wind Farm B\",\"generation_date\":\"2025-07-01T18:30:00.000Z\",\"energy_generated_kwh\":\"1700.25\",\"peak_power_kw\":\"340.20\",\"remarks\":\"Normal winds\"},{\"id\":6,\"site_name\":\"Hydro Plant C\",\"generation_date\":\"2025-06-30T18:30:00.000Z\",\"energy_generated_kwh\":\"2200.40\",\"peak_power_kw\":\"400.50\",\"remarks\":\"Stable water flow\"},{\"id\":7,\"site_name\":\"Hydro Plant C\",\"generation_date\":\"2025-07-01T18:30:00.000Z\",\"energy_generated_kwh\":\"2150.10\",\"peak_power_kw\":\"395.75\",\"remarks\":\"Slight drop in flow\"}],\"note\":\"TEST\"}"
        }
      }
    ],
    "Monthly Trigger": [
      {
        "json": {
          "code": 1,
          "name": "First item"
        }
      },
      {
        "json": {
          "code": 2,
          "name": "Second item"
        }
      }
    ],
    "Convert data to pdf": [
      {
        "json": {
          "url": "",
          "name": "",
          "error": false,
          "status": 200,
          "credits": 9,
          "duration": 1915,
          "pageCount": 1,
          "remainingCredits": 9888,
          "outputLinkValidTill": ""
        }
      }
    ]
  },
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "a6822d15-47ba-4c21-8f81-355f80d534a9",
  "connections": {
    "Send Report": {
      "main": [
        []
      ]
    },
    "Transform data": {
      "main": [
        [
          {
            "node": "Convert data to pdf",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get energy data": {
      "main": [
        [
          {
            "node": "Transform data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Monthly Trigger": {
      "main": [
        [
          {
            "node": "Get energy data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert data to pdf": {
      "main": [
        [
          {
            "node": "Send Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

中级 - 文档提取, 多模态 AI

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
中级
节点数量7
分类2
节点类型6
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

作者
WeblineIndia

WeblineIndia

@weblineindia

A Leading Software Engineering, Consulting & Outsourcing Services Company in USA & India serving Clients Globally since 1999.

外部链接
在 n8n.io 查看

分享此工作流