Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
n8n
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhouwei
n8n
Commits
68b5387b
Commit
68b5387b
authored
Apr 09, 2025
by
马超
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
510e901c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
354 additions
and
0 deletions
+354
-0
webhook_crimemap.json
20250409/webhook_crimemap.json
+354
-0
No files found.
20250409/webhook_crimemap.json
0 → 100644
View file @
68b5387b
{
"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
\n
function isEmptyString(value) {
\n
// 方法1: 直接检查是否为空字符串或null
\n
if (!value || value.trim() === '') {
\n
return true;
\n
}
\n
return false;
\n
};
\n
info_data_list = JSON.parse($('Webhook').item.json.body.info);
\n
output_all = [];
\n
output_all_data = {};
\n
output_news_data_str =
\"\"
;
\n
news_item_data =
\"\"
;
\n
zone_data = {};
\n
zone_data['lat'] = info_data_list.lat;
\n
zone_data['lon'] = info_data_list.lng;
\n
zone_data_str = JSON.stringify(zone_data);
\n
news_item_data = news_item_data+
\"
(
\"
;
\n
news_item_data +=
\"
'
\"
+zone_data_str+
\"
'
\"
;
\n
news_item_data += ',';
\n
news_item_data += '
\"
'+info_data_list.Description+'
\"
';
\n
news_item_data += ',';
\n
news_item_data += '
\"
'+info_data_list.Type_url+'
\"
';
\n
// news_item_data += ',';
\n
// news_item_data += '
\"
0
\"
';
\n
news_item_data += ',';
\n
news_item_data += '
\"
en
\"
';
\n
news_item_data += ',';
\n
if(!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
};
\n
news_item_data += '
\"
'+info_data_list.Type+'
\"
';
\n
news_item_data += ',';
\n
news_item_data += '
\"
'+info_data_list.Location+'
\"
';
\n
news_item_data += ',';
\n
news_item_data += '
\"
'+info_data_list.Incident+'
\"
';
\n
news_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);
\n
output_all_data['safe_data'] = news_item_data;
\n
output_all.push(output_all_data);
\n
return 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\n
INSERT 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\n
COMMIT;"
,
"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
\n
function isEmptyString(value) {
\n
// 方法1: 直接检查是否为空字符串或null
\n
if (!value || value.trim() === '') {
\n
return true;
\n
}
\n
return false;
\n
};
\n
info_data_list = JSON.parse($('Webhook').item.json.body.info);
\n
output_all = [];
\n
output_all_data = {};
\n
output_news_data_str =
\"\"
;
\n
news_item_data =
\"\"
;
\n
zone_data = {};
\n
zone_data['lat'] = info_data_list.lat;
\n
zone_data['lon'] = info_data_list.lng;
\n
zone_data_str = JSON.stringify(zone_data);
\n
news_item_data = news_item_data+
\"
(
\"
;
\n
news_item_data +=
\"
'
\"
+zone_data_str+
\"
'
\"
;
\n
news_item_data += ',';
\n
news_item_data += '
\"
'+info_data_list.Description+'
\"
';
\n
news_item_data += ',';
\n
news_item_data += '
\"
'+info_data_list.Type_url+'
\"
';
\n
// news_item_data += ',';
\n
// news_item_data += '
\"
0
\"
';
\n
news_item_data += ',';
\n
news_item_data += '
\"
en
\"
';
\n
news_item_data += ',';
\n
if(!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
};
\n
news_item_data += '
\"
'+info_data_list.Type+'
\"
';
\n
news_item_data += ',';
\n
news_item_data += '
\"
'+info_data_list.Location+'
\"
';
\n
news_item_data += ',';
\n
news_item_data += '
\"
'+info_data_list.Incident+'
\"
';
\n
news_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);
\n
output_all_data['safe_data'] = news_item_data;
\n
output_all.push(output_all_data);
\n
return 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\n
INSERT 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\n
COMMIT;"
,
"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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment