Commit 68b5387b authored by 马超's avatar 马超

Upload New File

parent 510e901c
{
"createdAt": "2025-02-13T05:21:02.506Z",
"updatedAt": "2025-03-07T05:33:55.000Z",
"id": "bQ05yfERnnrZ8DMJ",
"name": "webhook_crimemap",
"active": true,
"nodes": [
{
"parameters": {
"operation": "executeQuery",
"query": "select IFNULL(count(id), 0) as source_num from crime_mapping cm where cm.source_id ={{JSON.stringify(JSON.parse($json.body.info).Incident)}};\n\n",
"options": {}
},
"id": "195caf2a-b22a-4c30-83d1-a3cee02793c6",
"name": "is_safe_exist",
"type": "n8n-nodes-base.mySql",
"typeVersion": 2.4,
"position": [
-440,
340
],
"credentials": {
"mySql": {
"id": "YpVIiGwzmmkf7vR7",
"name": "SL-DB-PRD"
}
}
},
{
"parameters": {
"jsCode": "// Loop over input items and add a new field called 'myNewField' to the JSON of each one\nfunction isEmptyString(value) {\n // 方法1: 直接检查是否为空字符串或null\n if (!value || value.trim() === '') {\n return true;\n }\n return false;\n};\ninfo_data_list = JSON.parse($('Webhook').item.json.body.info);\noutput_all = [];\noutput_all_data = {};\noutput_news_data_str = \"\";\nnews_item_data = \"\";\nzone_data = {};\nzone_data['lat'] = info_data_list.lat;\nzone_data['lon'] = info_data_list.lng;\nzone_data_str = JSON.stringify(zone_data);\nnews_item_data = news_item_data+\"(\";\nnews_item_data += \"'\"+zone_data_str+\"'\";\nnews_item_data += ',';\nnews_item_data += '\"'+info_data_list.Description+'\"';\nnews_item_data += ',';\nnews_item_data += '\"'+info_data_list.Type_url+'\"';\n// news_item_data += ',';\n// news_item_data += '\"0\"';\nnews_item_data += ',';\nnews_item_data += '\"en\"';\nnews_item_data += ',';\nif(!isEmptyString(info_data_list.Date)){\n news_item_data += 'STR_TO_DATE(\"'+info_data_list.Date+'\",\"%Y-%m-%d %H:%i:%s\")';\n news_item_data += ',';\n}else{\n // news_item_data += 'NOW()';\n news_item_data += 'STR_TO_DATE(\"\",\"%Y-%m-%d %H:%i:%s\")';\n news_item_data += ',';\n};\nnews_item_data += '\"'+info_data_list.Type+'\"';\nnews_item_data += ',';\nnews_item_data += '\"'+info_data_list.Location+'\"';\nnews_item_data += ',';\nnews_item_data += '\"'+info_data_list.Incident+'\"';\nnews_item_data += ')';\ncity_code = info_data_list.city_code;\nitem_data = \"(\";\nitem_data += '\"'+city_code+'\"';\nitem_data += ',';\nitem_data += '@last_insert_id';\nitem_data += ')';\noutput_news_data_str += item_data;\noutput_all_data['city_data'] = output_news_data_str.slice(0,output_news_data_str.length);\noutput_all_data['safe_data'] = news_item_data;\noutput_all.push(output_all_data);\nreturn output_all;"
},
"id": "426acf11-f41c-4872-8e63-19a066912c98",
"name": "get_safe_sql",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
60,
240
]
},
{
"parameters": {
"operation": "executeQuery",
"query": "START TRANSACTION;\n\nINSERT INTO crime_mapping (zone,content,icon,lang_code,event_time,event,address,source_id) VALUES {{ $json.safe_data }};\n\nSET @last_insert_id = LAST_INSERT_ID();\n\nINSERT INTO city_guide (city_code, source_id)\nVALUES {{ $json.city_data }};\n\nCOMMIT;",
"options": {}
},
"id": "186b2435-54c0-43d5-81a9-9fe4782c508c",
"name": "insert_safe",
"type": "n8n-nodes-base.mySql",
"typeVersion": 2.4,
"position": [
300,
240
],
"credentials": {
"mySql": {
"id": "YpVIiGwzmmkf7vR7",
"name": "SL-DB-PRD"
}
}
},
{
"parameters": {
"jsCode": "// Loop over input items and add a new field called 'myNewField' to the JSON of each one\nfunction isEmptyString(value) {\n // 方法1: 直接检查是否为空字符串或null\n if (!value || value.trim() === '') {\n return true;\n }\n return false;\n};\ninfo_data_list = JSON.parse($('Webhook').item.json.body.info);\noutput_all = [];\noutput_all_data = {};\noutput_news_data_str = \"\";\nnews_item_data = \"\";\nzone_data = {};\nzone_data['lat'] = info_data_list.lat;\nzone_data['lon'] = info_data_list.lng;\nzone_data_str = JSON.stringify(zone_data);\nnews_item_data = news_item_data+\"(\";\nnews_item_data += \"'\"+zone_data_str+\"'\";\nnews_item_data += ',';\nnews_item_data += '\"'+info_data_list.Description+'\"';\nnews_item_data += ',';\nnews_item_data += '\"'+info_data_list.Type_url+'\"';\n// news_item_data += ',';\n// news_item_data += '\"0\"';\nnews_item_data += ',';\nnews_item_data += '\"en\"';\nnews_item_data += ',';\nif(!isEmptyString(info_data_list.Date)){\n news_item_data += 'STR_TO_DATE(\"'+info_data_list.Date+'\",\"%Y-%m-%d %H:%i:%s\")';\n news_item_data += ',';\n}else{\n // news_item_data += 'NOW()';\n news_item_data += 'STR_TO_DATE(\"\",\"%Y-%m-%d %H:%i:%s\")';\n news_item_data += ',';\n};\nnews_item_data += '\"'+info_data_list.Type+'\"';\nnews_item_data += ',';\nnews_item_data += '\"'+info_data_list.Location+'\"';\nnews_item_data += ',';\nnews_item_data += '\"'+info_data_list.Incident+'\"';\nnews_item_data += ')';\n// city_code = info_data_list.city_code;\n// item_data = \"(\";\n// item_data += '\"'+city_code+'\"';\n// item_data += ',';\n// item_data += '@last_insert_id';\n// item_data += ')';\n// output_news_data_str += item_data;\n// output_all_data['city_data'] = output_news_data_str.slice(0,output_news_data_str.length);\noutput_all_data['safe_data'] = news_item_data;\noutput_all.push(output_all_data);\nreturn output_all;"
},
"id": "c9e9c09e-cff1-47d1-aaa1-f88a984f3279",
"name": "get_safe_sql1",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
300,
480
]
},
{
"parameters": {
"operation": "executeQuery",
"query": "START TRANSACTION;\n\nINSERT INTO crime_mapping (zone,content,icon,lang_code,event_time,event,address,source_id) VALUES {{ $json.safe_data }};\n\n-- SET @last_insert_id = LAST_INSERT_ID();\n\n-- INSERT INTO city_guide (city_code, source_id)\n-- VALUES {{ $json.city_data }};\n\nCOMMIT;",
"options": {}
},
"id": "a03b8434-2792-4fda-a47b-ce621da16fac",
"name": "insert_safe1",
"type": "n8n-nodes-base.mySql",
"typeVersion": 2.4,
"position": [
500,
480
],
"credentials": {
"mySql": {
"id": "YpVIiGwzmmkf7vR7",
"name": "SL-DB-PRD"
}
}
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict"
},
"conditions": [
{
"id": "37fd1a36-8c69-4438-8fdc-6181956dfae3",
"leftValue": "={{ $json.source_num.toString()}}",
"rightValue": "0",
"operator": {
"type": "string",
"operation": "equals",
"name": "filter.operator.equals"
}
},
{
"id": "e8a93e70-faee-4ad7-865b-c76ee1fc6270",
"leftValue": "={{ JSON.parse($('Webhook').item.json.body.info).city_code }}",
"rightValue": "",
"operator": {
"type": "string",
"operation": "notEmpty",
"singleValue": true
}
}
],
"combinator": "and"
},
"options": {}
},
"id": "27ab6f03-fce6-4cab-8fcb-05411292caba",
"name": "If_1",
"type": "n8n-nodes-base.if",
"typeVersion": 2,
"position": [
-240,
340
]
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict"
},
"conditions": [
{
"id": "37fd1a36-8c69-4438-8fdc-6181956dfae3",
"leftValue": "={{ $json.source_num.toString()}}",
"rightValue": "0",
"operator": {
"type": "string",
"operation": "equals",
"name": "filter.operator.equals"
}
},
{
"id": "e8a93e70-faee-4ad7-865b-c76ee1fc6270",
"leftValue": "={{ JSON.parse($('Webhook').item.json.body.info).city_code }}",
"rightValue": "",
"operator": {
"type": "string",
"operation": "empty",
"singleValue": true
}
}
],
"combinator": "and"
},
"options": {}
},
"id": "6d7ffe8d-a49c-4924-acab-4c4b95564f7a",
"name": "If_2",
"type": "n8n-nodes-base.if",
"typeVersion": 2,
"position": [
60,
500
]
},
{
"parameters": {
"httpMethod": "POST",
"path": "crime/save",
"authentication": "headerAuth",
"options": {
"allowedOrigins": "*",
"rawBody": false
}
},
"id": "50ff17b5-bf4a-4352-803c-d726dac3248e",
"name": "Webhook",
"type": "n8n-nodes-base.webhook",
"typeVersion": 2,
"position": [
-660,
340
],
"webhookId": "e495a29c-8f43-4175-bdb8-277e03b60b07",
"credentials": {
"httpHeaderAuth": {
"id": "U87Wvnvu9oQ5Zapo",
"name": "Header Auth account"
}
}
}
],
"connections": {
"is_safe_exist": {
"main": [
[
{
"node": "If_1",
"type": "main",
"index": 0
}
]
]
},
"get_safe_sql": {
"main": [
[
{
"node": "insert_safe",
"type": "main",
"index": 0
}
]
]
},
"get_safe_sql1": {
"main": [
[
{
"node": "insert_safe1",
"type": "main",
"index": 0
}
]
]
},
"If_1": {
"main": [
[
{
"node": "get_safe_sql",
"type": "main",
"index": 0
}
],
[
{
"node": "If_2",
"type": "main",
"index": 0
}
]
]
},
"If_2": {
"main": [
[
{
"node": "get_safe_sql1",
"type": "main",
"index": 0
}
]
]
},
"Webhook": {
"main": [
[
{
"node": "is_safe_exist",
"type": "main",
"index": 0
}
]
]
}
},
"settings": {
"executionOrder": "v1"
},
"staticData": null,
"meta": {
"templateCredsSetupCompleted": true
},
"pinData": {},
"versionId": "97bb9ef7-18fd-45a2-ab2f-f9e5aef1279f",
"triggerCount": 1,
"shared": [
{
"createdAt": "2025-02-13T05:21:02.515Z",
"updatedAt": "2025-02-13T05:21:02.515Z",
"role": "workflow:owner",
"workflowId": "bQ05yfERnnrZ8DMJ",
"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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment