From ec0820fc856263aeaea385f6ceb35d2512a6b694 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A9=AC=E8=B6=85?= <machao@ssish.com> Date: Wed, 9 Apr 2025 15:01:54 +0800 Subject: [PATCH] Upload New File --- 20250409/webhook_guidesafe.json | 230 ++++++++++++++++++++++++++++++++ 1 file changed, 230 insertions(+) create mode 100644 20250409/webhook_guidesafe.json diff --git a/20250409/webhook_guidesafe.json b/20250409/webhook_guidesafe.json new file mode 100644 index 0000000..b130ce7 --- /dev/null +++ b/20250409/webhook_guidesafe.json @@ -0,0 +1,230 @@ +{ + "createdAt": "2024-09-10T03:53:54.535Z", + "updatedAt": "2024-09-12T02:05:13.000Z", + "id": "s6zsznwVs6N4L2Hx", + "name": "webhook-guidesafe", + "active": false, + "nodes": [ + { + "parameters": { + "table": { + "__rl": true, + "value": "city_safe_guide", + "mode": "list", + "cachedResultName": "city_safe_guide" + }, + "options": {} + }, + "id": "3897d8b1-7614-45ff-9aa5-a6cc289973ac", + "name": "MySQL", + "type": "n8n-nodes-base.mySql", + "typeVersion": 2.4, + "position": [ + 760, + 220 + ], + "credentials": { + "mySql": { + "id": "09oRI0DULmEzD9l8", + "name": "MySQL account" + } + } + }, + { + "parameters": { + "collection": "results_ls_fww", + "options": {}, + "query": "{ \"schedule_id\": \"19\"}" + }, + "id": "844aced7-ac0f-414e-a8d9-8f3973ebfb3a", + "name": "MongoDB", + "type": "n8n-nodes-base.mongoDb", + "typeVersion": 1.1, + "position": [ + 180, + 320 + ], + "credentials": { + "mongoDb": { + "id": "D2GwCG2UAtnWPY8f", + "name": "MongoDB account" + } + } + }, + { + "parameters": { + "language": "python", + "pythonCode": "# Loop over input items and add a new field called 'myNewField' to the JSON of each one\n\n import json,requests,time\n import pymysql,json\n from dbutils.pooled_db import PooledDB\n # 测试数æ®åº“\n mincached = 10 #è¿žæŽ¥æ± ä¸ç©ºé—²è¿žæŽ¥çš„åˆå§‹æ•°é‡\n maxcached = 20 #è¿žæŽ¥æ± ä¸ç©ºé—²è¿žæŽ¥çš„æœ€å¤§æ•°é‡\n maxshared = 10 #共享连接的最大数é‡\n maxconnections = 200 #åˆ›å»ºè¿žæŽ¥æ± çš„æœ€å¤§æ•°é‡\n blocking = True #è¶…è¿‡æœ€å¤§è¿žæŽ¥æ•°é‡æ—¶å€™çš„表现,为Trueç‰å¾…连接数é‡ä¸‹é™ï¼Œä¸ºfalse直接报错处ç†\n maxusage = 100 #å•个连接的最大é‡å¤ä½¿ç”¨æ¬¡æ•°\n maxsize = 10 #è¿žæŽ¥æ± æœ€å¤§è¿žæŽ¥æ•°\n minsize = 1 #è¿žæŽ¥æ± æœ€å°è¿žæŽ¥æ•°\n autocommit = True # 是å¦è‡ªåЍæäº¤\n setsession = None #optional list of SQL commands that may serve to prepare the session, e.g. [\"set datestyle to ...\", \"set time zone ...\"]\n reset = True #how connections should be reset when returned to the pool(False or None to rollback transcations started with begin(),True to always issue a rollback for safety's sake)\n host = 'sldb-mysql.c368qw68qa1w.ap-east-1.rds.amazonaws.com' #æ•°æ®åº“ipåœ°å€ sldb-mysql.c368qw68qa1w.ap-east-1.rds.amazonaws.com\n port = 3306 #æ•°æ®åº“端å£\n db = 'qa' #库å\n user = 'admin_sl_mysql' #用户å\n passwd = '2024mysql07sl' #密ç \n charset = 'utf8mb4' #å—符编ç \n max_workers = 5 # çº¿ç¨‹æ± æœ€å¤§çº¿ç¨‹æ•°\n \n class MysqlClient(object):\n def __init__(self, mincached=mincached, maxcached=maxcached,\n maxshared=maxshared, maxconnections=maxconnections,\n blocking=blocking, maxusage=maxusage,\n setsession=setsession, reset=reset,\n host=host, port=port, db=db,\n user=user, passwd=passwd, charset=charset):\n \n self.__pool = PooledDB(pymysql,\n mincached, maxcached,\n maxshared, maxconnections, blocking,\n maxusage, setsession, reset,\n host=host, port=port, db=db,\n user=user, passwd=passwd,\n charset=charset,\n cursorclass=pymysql.cursors.DictCursor\n )\n \n \n def connect(self):\n _conn = self.__pool.connection()\n _cursor = _conn.cursor()\n return _conn,_cursor\n \n def select_table(self,sql, value_list):\n conn,cur = self.connect()\n try:\n cur.execute(sql, value_list)\n data = cur.fetchall()\n cur.close()\n conn.close()\n if data.__len__() > 0:\n return data\n else:\n return []\n except Exception as e:\n return []\n \n def dify_completion_messages(parse_text,out_data):\n post_url = 'http://47.99.137.247/v1/completion-messages'\n post_headers = {\n 'Authorization': \"Bearer app-ApuLSwN3ahfsL3CVAyKs3F0s\",\n 'Content-Type': 'application/json'\n }\n post_data = {\n \"inputs\": {\"query\": parse_text+\" 请将上述内容按照以下jsonæ ¼å¼è¾“出,并需è¦ç¬¦åˆjson schema规范 \"+json.dumps(out_data)},\n \"response_mode\": \"blocking\",\n \"user\": \"mc\"\n }\n try:\n response = requests.post(post_url, headers=post_headers, data=json.dumps(post_data))\n # 检查å“应状æ€ç \n if response.status_code == 200:\n # 如果请求æˆåŠŸï¼Œå¤„ç†å“应数æ®\n response_data = json.loads(response.text)\n answer = response_data.get(\"answer\")\n start = answer.find(\"```\")\n indices = []\n while start != -1:\n indices.append(start)\n start = answer.find(\"```\", start + 1)\n print(indices)\n answer_data = json.loads(answer[indices[0] + 7:indices[1]])\n print(\"Response:\", response_data)\n return answer_data\n else:\n # 如果请求失败,打å°é”™è¯¯ä¿¡æ¯\n print(f\"Request failed with status code {response.status_code}: {response.text}\")\n return None\n except Exception as e:\n print(f\"An error occurred: {e}\")\n return None\n \n mysql_client = MysqlClient()\n QUERY_CODE_NAME = \"select id,name_cn from code a where group_id = '10' and status = '0'\"\n # æ ¹æ®è®¡åˆ’id查询\n QUERY_LOCATION = \"select location from schedule a where a.id = '#1'\"\n code_data_list = mysql_client.select_table(QUERY_CODE_NAME, [])\n out_data = {}\n code_id_data = {}\n for code_data in code_data_list:\n id = code_data.get(\"id\")\n name_cn = code_data.get(\"name_cn\")\n out_data[name_cn] = 'xxx'\n code_id_data[name_cn] = id\n _output_all = []\n for item in _input.all():\n schedule_id = item.json.schedule_id\n location_data_list = mysql_client.select_table(QUERY_LOCATION.replace(\"#1\",schedule_id), [])\n location = None\n if location_data_list is not None and len(location_data_list) >0:\n location = json.loads(location_data_list[0].get(\"location\"))\n info = json.loads(item.json.content).get(\"实用信æ¯\")\n dify_result_data = dify_completion_messages(info,out_data)\n if location is not None and len(location)>0 and dify_result_data is not None and len(dify_result_data)>0:\n for location_data in location:\n cityCode = location_data.get(\"cityCode\")\n for name_cn, data in dify_result_data.items():\n data_item = {}\n data_item['city_code'] = cityCode\n data_item['recommend'] = json.dumps(data)\n data_item['classification_id'] = code_id_data.get(\"name_cn\")\n _output_all.append(data_item) \n return _output_all\n " + }, + "id": "93a88188-7975-4815-b9f9-38cd7013d531", + "name": "Code", + "type": "n8n-nodes-base.code", + "typeVersion": 2, + "position": [ + 540, + 220 + ] + }, + { + "parameters": { + "path": "e495a29c-8f43-4175-bdb8-277e03b60b07", + "options": {} + }, + "id": "c5626b71-d366-4b9b-9239-aacdecefdb5b", + "name": "Webhook", + "type": "n8n-nodes-base.webhook", + "typeVersion": 2, + "position": [ + -220, + 220 + ], + "webhookId": "e495a29c-8f43-4175-bdb8-277e03b60b07" + }, + { + "parameters": { + "operation": "select", + "table": { + "__rl": true, + "value": "code", + "mode": "list", + "cachedResultName": "code" + }, + "options": {} + }, + "id": "5979f414-7b71-4579-81b7-d64e8a95438d", + "name": "MySQL1", + "type": "n8n-nodes-base.mySql", + "typeVersion": 2.4, + "position": [ + 180, + 0 + ], + "credentials": { + "mySql": { + "id": "09oRI0DULmEzD9l8", + "name": "MySQL account" + } + } + } + ], + "connections": { + "MongoDB": { + "main": [ + [ + { + "node": "Code", + "type": "main", + "index": 0 + } + ] + ] + }, + "Code": { + "main": [ + [ + { + "node": "MySQL", + "type": "main", + "index": 0 + } + ] + ] + }, + "Webhook": { + "main": [ + [ + { + "node": "MongoDB", + "type": "main", + "index": 0 + }, + { + "node": "MySQL1", + "type": "main", + "index": 0 + } + ] + ] + }, + "MySQL1": { + "main": [ + [ + { + "node": "Code", + "type": "main", + "index": 0 + } + ] + ] + } + }, + "settings": { + "executionOrder": "v1" + }, + "staticData": null, + "meta": { + "templateCredsSetupCompleted": true + }, + "pinData": {}, + "versionId": "d971e77d-442e-4852-8e08-c812d5e77bb4", + "triggerCount": 1, + "shared": [ + { + "createdAt": "2024-09-10T03:53:54.544Z", + "updatedAt": "2024-09-10T03:53:54.544Z", + "role": "workflow:owner", + "workflowId": "s6zsznwVs6N4L2Hx", + "projectId": "C7zKoCDdmGgzUqSW", + "project": { + "createdAt": "2024-08-23T06:31:21.275Z", + "updatedAt": "2024-08-23T06:41:43.608Z", + "id": "C7zKoCDdmGgzUqSW", + "name": "周 å« <zhouwei@ssish.com>", + "type": "personal", + "projectRelations": [ + { + "createdAt": "2024-08-23T06:31:21.275Z", + "updatedAt": "2024-08-23T06:31:21.275Z", + "role": "project:personalOwner", + "userId": "3f0021b4-d0a7-4db6-af21-5ef829c47882", + "projectId": "C7zKoCDdmGgzUqSW", + "user": { + "createdAt": "2024-08-23T06:31:16.119Z", + "updatedAt": "2025-03-19T06:19:26.514Z", + "id": "3f0021b4-d0a7-4db6-af21-5ef829c47882", + "email": "zhouwei@ssish.com", + "firstName": "周", + "lastName": "å«", + "personalizationAnswers": { + "companyType": "education", + "role": "business-owner", + "automationBeneficiary": "my-team", + "companySize": "20-99", + "reportedSource": "friend", + "version": "v4", + "personalization_survey_submitted_at": "2024-08-23T06:57:52.856Z", + "personalization_survey_n8n_version": "1.55.3" + }, + "settings": { + "userActivated": true, + "firstSuccessfulWorkflowId": "s6zsznwVs6N4L2Hx", + "userActivatedAt": 1725957335278, + "npsSurvey": { + "responded": true, + "lastShownAt": 1742365155724 + }, + "isOnboarded": true + }, + "role": "global:owner", + "disabled": false, + "mfaEnabled": false, + "isPending": false, + "isOwner": true + } + } + ] + } + } + ], + "tags": [] +} \ No newline at end of file -- 2.22.0