Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
D
docker-iot-v3
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
deploy
docker-iot-v3
Commits
42cb1bb7
Commit
42cb1bb7
authored
Aug 08, 2023
by
吴文龙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
up
parent
5ba0b5cd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
7 deletions
+0
-7
job.sql
db/job.sql
+0
-7
No files found.
db/job.sql
View file @
42cb1bb7
...
...
@@ -89,13 +89,6 @@ CREATE TABLE `xxl_job_info` (
PRIMARY
KEY
(
`id`
)
USING
BTREE
)
ENGINE
=
InnoDB
AUTO_INCREMENT
=
30
CHARACTER
SET
=
utf8mb4
COLLATE
=
utf8mb4_0900_ai_ci
;
-- ----------------------------
-- Records of xxl_job_info
-- ----------------------------
BEGIN
;
INSERT
INTO
`xxl_job_info`
(
`id`
,
`job_group`
,
`job_desc`
,
`add_time`
,
`update_time`
,
`author`
,
`alarm_email`
,
`schedule_type`
,
`schedule_conf`
,
`misfire_strategy`
,
`executor_route_strategy`
,
`executor_handler`
,
`executor_param`
,
`executor_block_strategy`
,
`executor_timeout`
,
`executor_fail_retry_count`
,
`glue_type`
,
`glue_source`
,
`glue_remark`
,
`glue_updatetime`
,
`child_jobid`
,
`trigger_status`
,
`trigger_last_time`
,
`trigger_next_time`
)
VALUES
(
1
,
1
,
'测试任务1'
,
'2018-11-03 22:21:31'
,
'2018-11-03 22:21:31'
,
'XXL'
,
''
,
'CRON'
,
'0 0 0 * * ? *'
,
'DO_NOTHING'
,
'FIRST'
,
'demoJobHandler'
,
''
,
'SERIAL_EXECUTION'
,
0
,
0
,
'BEAN'
,
''
,
'GLUE代码初始化'
,
'2018-11-03 22:21:31'
,
''
,
0
,
0
,
0
),
(
2
,
4
,
'????'
,
'2022-09-23 12:32:13'
,
'2022-09-29 00:10:13'
,
'dbapi'
,
NULL
,
'CRON'
,
'*/5 * * * * ? *'
,
'DO_NOTHING'
,
'FIRST'
,
NULL
,
'http://localhost:8520/api/dbapi/f_test'
,
'SERIAL_EXECUTION'
,
0
,
0
,
'GLUE_GROOVY'
,
'package com.xxl.job.service.handler;
\n\n
import com.xxl.job.core.context.XxlJobHelper;
\n
import com.xxl.job.core.handler.IJobHandler;
\n\n
import java.io.BufferedReader;
\n
import java.io.InputStream;
\n
import java.io.InputStreamReader;
\n
import java.net.HttpURLConnection;
\n
import java.net.URL;
\n
import java.util.Arrays;
\n
import java.util.Iterator;
\n
import org.slf4j.Logger;
\n
import org.slf4j.LoggerFactory;
\n\n
public class DemoGlueJobHandler extends IJobHandler {
\n
private static Logger logger = LoggerFactory.getLogger(DemoGlueJobHandler.class);
\n\n
@Override
\n
public void execute() throws Exception {
\n
XxlJobHelper.log(
\"
GLUE(Java)任务执行了!
\"
);
\n
logger.info(
\"
GLUE(Java)任务执行了!
\"
);
\n
executeWhile(XxlJobHelper.getJobParam());
\n
}
\n\n
private void executeWhile(String params) {
\n
logger.info(
\"
GLUE(Java)任务参数为:
\"
+ params);
\n
String[] paramsArray = params.split(
\"
,
\"
);
\n
Iterator<String> iterator = Arrays.stream(paramsArray).iterator();
\n
while (iterator.hasNext()) {
\n
executeApi(iterator.next());
\n
}
\n
}
\n\n
private static void executeApi(String httpUrl) {
\n
String result = null;
\n
InputStream input = null;
\n
HttpURLConnection urlcon = null;
\n
BufferedReader buffer = null;
\n
try {
\n
URL url = new URL(httpUrl);
\n
urlcon = (HttpURLConnection) url.openConnection();
\n
urlcon.setRequestMethod(
\"
POST
\"
);
\n
urlcon.connect();// 获取连接
\n
input = urlcon.getInputStream();
\n
buffer = new BufferedReader(new InputStreamReader(
\n
input,
\"
UTF-8
\"
));
\n
StringBuffer bs = new StringBuffer();
\n
String line = null;
\n
while ((line = buffer.readLine()) != null) {
\n
bs.append(line);
\n
}
\n
result = bs.toString();
\n
XxlJobHelper.log(
\"
result:
\"
+ result);
\n
logger.info(
\"
调用接口【{}】返回值result:{}
\"
, httpUrl, result);
\n
} catch (Exception e) {
\n
XxlJobHelper.log(
\"
[请求异常][地址:
\"
+ httpUrl +
\"
][错误信息:
\"
+ e.getMessage()
\n
+
\"
]
\"
);
\n
logger.error(
\"
GLUE(Java)任务执行异常:
\"
, e);
\n
} finally {
\n
try {
\n
if (null != input) {
\n
input.close();
\n
}
\n
if (urlcon != null) {
\n
urlcon.disconnect();
\n
}
\n
if (buffer != null) {
\n
buffer.close();
\n
}
\n
} catch (Exception e2) {
\n
XxlJobHelper.log(
\"
[关闭流异常][错误信息:
\"
+ e2.getMessage() +
\"
]
\"
);
\n
logger.error(
\"
[关闭流异常][错误信息:
\"
+ e2.getMessage() +
\"
]
\"
);
\n
}
\n
}
\n
}
\n\n\n\n
}
\n
'
,
'GLUE代码初始化'
,
'2022-09-23 12:32:13'
,
NULL
,
0
,
0
,
0
),
(
3
,
4
,
'junlin_hous_key'
,
'2022-09-24 08:05:07'
,
'2022-10-20 21:23:29'
,
'dbapi'
,
NULL
,
'CRON'
,
'*/10 * * * * ? *'
,
'DO_NOTHING'
,
'FIRST'
,
NULL
,
'http://localhost:8520/api/junlin_hous_key'
,
'SERIAL_EXECUTION'
,
0
,
0
,
'GLUE_GROOVY'
,
'package com.xxl.job.service.handler;
\n\n
import com.xxl.job.core.context.XxlJobHelper;
\n
import com.xxl.job.core.handler.IJobHandler;
\n\n
import java.io.BufferedReader;
\n
import java.io.InputStream;
\n
import java.io.InputStreamReader;
\n
import java.net.HttpURLConnection;
\n
import java.net.URL;
\n
import java.util.Arrays;
\n
import java.util.Iterator;
\n
import org.slf4j.Logger;
\n
import org.slf4j.LoggerFactory;
\n\n
public class DemoGlueJobHandler extends IJobHandler {
\n
private static Logger logger = LoggerFactory.getLogger(DemoGlueJobHandler.class);
\n\n
@Override
\n
public void execute() throws Exception {
\n
XxlJobHelper.log(
\"
GLUE(Java)任务执行了!
\"
);
\n
logger.info(
\"
GLUE(Java)任务执行了!
\"
);
\n
executeWhile(XxlJobHelper.getJobParam());
\n
}
\n\n
private void executeWhile(String params) {
\n
logger.info(
\"
GLUE(Java)任务参数为:
\"
+ params);
\n
String[] paramsArray = params.split(
\"
,
\"
);
\n
Iterator<String> iterator = Arrays.stream(paramsArray).iterator();
\n
while (iterator.hasNext()) {
\n
executeApi(iterator.next());
\n
}
\n
}
\n\n
private static void executeApi(String httpUrl) {
\n
String result = null;
\n
InputStream input = null;
\n
HttpURLConnection urlcon = null;
\n
BufferedReader buffer = null;
\n
try {
\n
URL url = new URL(httpUrl);
\n
urlcon = (HttpURLConnection) url.openConnection();
\n
urlcon.setRequestMethod(
\"
POST
\"
);
\n
urlcon.connect();// 获取连接
\n
input = urlcon.getInputStream();
\n
buffer = new BufferedReader(new InputStreamReader(
\n
input,
\"
UTF-8
\"
));
\n
StringBuffer bs = new StringBuffer();
\n
String line = null;
\n
while ((line = buffer.readLine()) != null) {
\n
bs.append(line);
\n
}
\n
result = bs.toString();
\n
XxlJobHelper.log(
\"
result:
\"
+ result);
\n
logger.info(
\"
调用接口【{}】返回值result:{}
\"
, httpUrl, result);
\n
} catch (Exception e) {
\n
XxlJobHelper.log(
\"
[请求异常][地址:
\"
+ httpUrl +
\"
][错误信息:
\"
+ e.getMessage()
\n
+
\"
]
\"
);
\n
logger.error(
\"
GLUE(Java)任务执行异常:
\"
, e);
\n
} finally {
\n
try {
\n
if (null != input) {
\n
input.close();
\n
}
\n
if (urlcon != null) {
\n
urlcon.disconnect();
\n
}
\n
if (buffer != null) {
\n
buffer.close();
\n
}
\n
} catch (Exception e2) {
\n
XxlJobHelper.log(
\"
[关闭流异常][错误信息:
\"
+ e2.getMessage() +
\"
]
\"
);
\n
logger.error(
\"
[关闭流异常][错误信息:
\"
+ e2.getMessage() +
\"
]
\"
);
\n
}
\n
}
\n
}
\n\n\n\n
}
\n
'
,
'GLUE代码初始化'
,
'2022-09-24 08:05:07'
,
NULL
,
0
,
0
,
0
),
(
4
,
4
,
'set_tcode_base'
,
'2022-09-24 09:24:21'
,
'2022-10-20 14:30:03'
,
'dbapi'
,
''
,
'CRON'
,
'0 */5 * * * ? *'
,
'DO_NOTHING'
,
'FIRST'
,
''
,
'http://localhost:8520/api/set_tcode_base'
,
'SERIAL_EXECUTION'
,
0
,
0
,
'GLUE_GROOVY'
,
'package com.xxl.job.service.handler;
\n\n
import com.xxl.job.core.context.XxlJobHelper;
\n
import com.xxl.job.core.handler.IJobHandler;
\n\n
import java.io.BufferedReader;
\n
import java.io.InputStream;
\n
import java.io.InputStreamReader;
\n
import java.net.HttpURLConnection;
\n
import java.net.URL;
\n
import java.util.Arrays;
\n
import java.util.Iterator;
\n
import org.slf4j.Logger;
\n
import org.slf4j.LoggerFactory;
\n\n
public class DemoGlueJobHandler extends IJobHandler {
\n
private static Logger logger = LoggerFactory.getLogger(DemoGlueJobHandler.class);
\n\n
@Override
\n
public void execute() throws Exception {
\n
XxlJobHelper.log(
\"
GLUE(Java)任务执行了!
\"
);
\n
logger.info(
\"
GLUE(Java)任务执行了!
\"
);
\n
executeWhile(XxlJobHelper.getJobParam());
\n
}
\n\n
private void executeWhile(String params) {
\n
logger.info(
\"
GLUE(Java)任务参数为:
\"
+ params);
\n
String[] paramsArray = params.split(
\"
,
\"
);
\n
Iterator<String> iterator = Arrays.stream(paramsArray).iterator();
\n
while (iterator.hasNext()) {
\n
executeApi(iterator.next());
\n
}
\n
}
\n\n
private static void executeApi(String httpUrl) {
\n
String result = null;
\n
InputStream input = null;
\n
HttpURLConnection urlcon = null;
\n
BufferedReader buffer = null;
\n
try {
\n
URL url = new URL(httpUrl);
\n
urlcon = (HttpURLConnection) url.openConnection();
\n
urlcon.setRequestMethod(
\"
POST
\"
);
\n
urlcon.connect();// 获取连接
\n
input = urlcon.getInputStream();
\n
buffer = new BufferedReader(new InputStreamReader(
\n
input,
\"
UTF-8
\"
));
\n
StringBuffer bs = new StringBuffer();
\n
String line = null;
\n
while ((line = buffer.readLine()) != null) {
\n
bs.append(line);
\n
}
\n
result = bs.toString();
\n
XxlJobHelper.log(
\"
result:
\"
+ result);
\n
logger.info(
\"
调用接口【{}】返回值result:{}
\"
, httpUrl, result);
\n
} catch (Exception e) {
\n
XxlJobHelper.log(
\"
[请求异常][地址:
\"
+ httpUrl +
\"
][错误信息:
\"
+ e.getMessage()
\n
+
\"
]
\"
);
\n
logger.error(
\"
GLUE(Java)任务执行异常:
\"
, e);
\n
} finally {
\n
try {
\n
if (null != input) {
\n
input.close();
\n
}
\n
if (urlcon != null) {
\n
urlcon.disconnect();
\n
}
\n
if (buffer != null) {
\n
buffer.close();
\n
}
\n
} catch (Exception e2) {
\n
XxlJobHelper.log(
\"
[关闭流异常][错误信息:
\"
+ e2.getMessage() +
\"
]
\"
);
\n
logger.error(
\"
[关闭流异常][错误信息:
\"
+ e2.getMessage() +
\"
]
\"
);
\n
}
\n
}
\n
}
\n\n\n\n
}
\n
'
,
'GLUE代码初始化'
,
'2022-09-24 09:24:21'
,
''
,
0
,
0
,
0
),
(
5
,
4
,
'f_rep_hour_key_detail'
,
'2022-09-24 09:49:48'
,
'2022-11-04 00:37:17'
,
'dbapi'
,
NULL
,
'CRON'
,
'*/5 * * * * ? *'
,
'DO_NOTHING'
,
'FIRST'
,
NULL
,
'http://localhost:8520/api/dbapi/f_rep_hour_key_detail'
,
'SERIAL_EXECUTION'
,
0
,
0
,
'GLUE_GROOVY'
,
'package com.xxl.job.service.handler;
\n\n
import com.xxl.job.core.context.XxlJobHelper;
\n
import com.xxl.job.core.handler.IJobHandler;
\n\n
import java.io.BufferedReader;
\n
import java.io.InputStream;
\n
import java.io.InputStreamReader;
\n
import java.net.HttpURLConnection;
\n
import java.net.URL;
\n
import java.util.Arrays;
\n
import java.util.Iterator;
\n
import org.slf4j.Logger;
\n
import org.slf4j.LoggerFactory;
\n\n
public class DemoGlueJobHandler extends IJobHandler {
\n
private static Logger logger = LoggerFactory.getLogger(DemoGlueJobHandler.class);
\n\n
@Override
\n
public void execute() throws Exception {
\n
XxlJobHelper.log(
\"
GLUE(Java)任务执行了!
\"
);
\n
logger.info(
\"
GLUE(Java)任务执行了!
\"
);
\n
executeWhile(XxlJobHelper.getJobParam());
\n
}
\n\n
private void executeWhile(String params) {
\n
logger.info(
\"
GLUE(Java)任务参数为:
\"
+ params);
\n
String[] paramsArray = params.split(
\"
,
\"
);
\n
Iterator<String> iterator = Arrays.stream(paramsArray).iterator();
\n
while (iterator.hasNext()) {
\n
executeApi(iterator.next());
\n
}
\n
}
\n\n
private static void executeApi(String httpUrl) {
\n
String result = null;
\n
InputStream input = null;
\n
HttpURLConnection urlcon = null;
\n
BufferedReader buffer = null;
\n
try {
\n
URL url = new URL(httpUrl);
\n
urlcon = (HttpURLConnection) url.openConnection();
\n
urlcon.setRequestMethod(
\"
POST
\"
);
\n
urlcon.connect();// 获取连接
\n
input = urlcon.getInputStream();
\n
buffer = new BufferedReader(new InputStreamReader(
\n
input,
\"
UTF-8
\"
));
\n
StringBuffer bs = new StringBuffer();
\n
String line = null;
\n
while ((line = buffer.readLine()) != null) {
\n
bs.append(line);
\n
}
\n
result = bs.toString();
\n
XxlJobHelper.log(
\"
result:
\"
+ result);
\n
logger.info(
\"
调用接口【{}】返回值result:{}
\"
, httpUrl, result);
\n
} catch (Exception e) {
\n
XxlJobHelper.log(
\"
[请求异常][地址:
\"
+ httpUrl +
\"
][错误信息:
\"
+ e.getMessage()
\n
+
\"
]
\"
);
\n
logger.error(
\"
GLUE(Java)任务执行异常:
\"
, e);
\n
} finally {
\n
try {
\n
if (null != input) {
\n
input.close();
\n
}
\n
if (urlcon != null) {
\n
urlcon.disconnect();
\n
}
\n
if (buffer != null) {
\n
buffer.close();
\n
}
\n
} catch (Exception e2) {
\n
XxlJobHelper.log(
\"
[关闭流异常][错误信息:
\"
+ e2.getMessage() +
\"
]
\"
);
\n
logger.error(
\"
[关闭流异常][错误信息:
\"
+ e2.getMessage() +
\"
]
\"
);
\n
}
\n
}
\n
}
\n\n\n\n
}
\n
'
,
'GLUE代码初始化'
,
'2022-09-24 09:49:48'
,
NULL
,
0
,
0
,
0
),
(
6
,
4
,
'f_func_rep_test'
,
'2022-09-24 23:20:41'
,
'2022-09-24 23:47:39'
,
'dbapi'
,
NULL
,
'CRON'
,
'*/5 * * * * ? *'
,
'DO_NOTHING'
,
'FIRST'
,
NULL
,
'http://localhost:8520/api/f_func_rep_test'
,
'SERIAL_EXECUTION'
,
0
,
0
,
'GLUE_GROOVY'
,
'package com.xxl.job.service.handler;
\n\n
import com.xxl.job.core.context.XxlJobHelper;
\n
import com.xxl.job.core.handler.IJobHandler;
\n\n
import java.io.BufferedReader;
\n
import java.io.InputStream;
\n
import java.io.InputStreamReader;
\n
import java.net.HttpURLConnection;
\n
import java.net.URL;
\n
import java.util.Arrays;
\n
import java.util.Iterator;
\n
import org.slf4j.Logger;
\n
import org.slf4j.LoggerFactory;
\n\n
public class DemoGlueJobHandler extends IJobHandler {
\n
private static Logger logger = LoggerFactory.getLogger(DemoGlueJobHandler.class);
\n\n
@Override
\n
public void execute() throws Exception {
\n
XxlJobHelper.log(
\"
GLUE(Java)任务执行了!
\"
);
\n
logger.info(
\"
GLUE(Java)任务执行了!
\"
);
\n
executeWhile(XxlJobHelper.getJobParam());
\n
}
\n\n
private void executeWhile(String params) {
\n
logger.info(
\"
GLUE(Java)任务参数为:
\"
+ params);
\n
String[] paramsArray = params.split(
\"
,
\"
);
\n
Iterator<String> iterator = Arrays.stream(paramsArray).iterator();
\n
while (iterator.hasNext()) {
\n
executeApi(iterator.next());
\n
}
\n
}
\n\n
private static void executeApi(String httpUrl) {
\n
String result = null;
\n
InputStream input = null;
\n
HttpURLConnection urlcon = null;
\n
BufferedReader buffer = null;
\n
try {
\n
URL url = new URL(httpUrl);
\n
urlcon = (HttpURLConnection) url.openConnection();
\n
urlcon.setRequestMethod(
\"
POST
\"
);
\n
urlcon.connect();// 获取连接
\n
input = urlcon.getInputStream();
\n
buffer = new BufferedReader(new InputStreamReader(
\n
input,
\"
UTF-8
\"
));
\n
StringBuffer bs = new StringBuffer();
\n
String line = null;
\n
while ((line = buffer.readLine()) != null) {
\n
bs.append(line);
\n
}
\n
result = bs.toString();
\n
XxlJobHelper.log(
\"
result:
\"
+ result);
\n
logger.info(
\"
调用接口【{}】返回值result:{}
\"
, httpUrl, result);
\n
} catch (Exception e) {
\n
XxlJobHelper.log(
\"
[请求异常][地址:
\"
+ httpUrl +
\"
][错误信息:
\"
+ e.getMessage()
\n
+
\"
]
\"
);
\n
logger.error(
\"
GLUE(Java)任务执行异常:
\"
, e);
\n
} finally {
\n
try {
\n
if (null != input) {
\n
input.close();
\n
}
\n
if (urlcon != null) {
\n
urlcon.disconnect();
\n
}
\n
if (buffer != null) {
\n
buffer.close();
\n
}
\n
} catch (Exception e2) {
\n
XxlJobHelper.log(
\"
[关闭流异常][错误信息:
\"
+ e2.getMessage() +
\"
]
\"
);
\n
logger.error(
\"
[关闭流异常][错误信息:
\"
+ e2.getMessage() +
\"
]
\"
);
\n
}
\n
}
\n
}
\n\n\n\n
}
\n
'
,
'GLUE代码初始化'
,
'2022-09-24 23:20:41'
,
NULL
,
0
,
0
,
0
),
(
7
,
4
,
'f_rep_hour_key_sum'
,
'2022-09-25 22:26:44'
,
'2022-11-03 15:23:25'
,
'dbapi'
,
NULL
,
'CRON'
,
'*/5 * * * * ? *'
,
'DO_NOTHING'
,
'FIRST'
,
NULL
,
'http://localhost:8520/api/dbapi/f_rep_hour_key_sum'
,
'SERIAL_EXECUTION'
,
0
,
0
,
'GLUE_GROOVY'
,
'package com.xxl.job.service.handler;
\n\n
import com.xxl.job.core.context.XxlJobHelper;
\n
import com.xxl.job.core.handler.IJobHandler;
\n\n
import java.io.BufferedReader;
\n
import java.io.InputStream;
\n
import java.io.InputStreamReader;
\n
import java.net.HttpURLConnection;
\n
import java.net.URL;
\n
import java.util.Arrays;
\n
import java.util.Iterator;
\n
import org.slf4j.Logger;
\n
import org.slf4j.LoggerFactory;
\n\n
public class DemoGlueJobHandler extends IJobHandler {
\n
private static Logger logger = LoggerFactory.getLogger(DemoGlueJobHandler.class);
\n\n
@Override
\n
public void execute() throws Exception {
\n
XxlJobHelper.log(
\"
GLUE(Java)任务执行了!
\"
);
\n
logger.info(
\"
GLUE(Java)任务执行了!
\"
);
\n
executeWhile(XxlJobHelper.getJobParam());
\n
}
\n\n
private void executeWhile(String params) {
\n
logger.info(
\"
GLUE(Java)任务参数为:
\"
+ params);
\n
String[] paramsArray = params.split(
\"
,
\"
);
\n
Iterator<String> iterator = Arrays.stream(paramsArray).iterator();
\n
while (iterator.hasNext()) {
\n
executeApi(iterator.next());
\n
}
\n
}
\n\n
private static void executeApi(String httpUrl) {
\n
String result = null;
\n
InputStream input = null;
\n
HttpURLConnection urlcon = null;
\n
BufferedReader buffer = null;
\n
try {
\n
URL url = new URL(httpUrl);
\n
urlcon = (HttpURLConnection) url.openConnection();
\n
urlcon.setRequestMethod(
\"
POST
\"
);
\n
urlcon.connect();// 获取连接
\n
input = urlcon.getInputStream();
\n
buffer = new BufferedReader(new InputStreamReader(
\n
input,
\"
UTF-8
\"
));
\n
StringBuffer bs = new StringBuffer();
\n
String line = null;
\n
while ((line = buffer.readLine()) != null) {
\n
bs.append(line);
\n
}
\n
result = bs.toString();
\n
XxlJobHelper.log(
\"
result:
\"
+ result);
\n
logger.info(
\"
调用接口【{}】返回值result:{}
\"
, httpUrl, result);
\n
} catch (Exception e) {
\n
XxlJobHelper.log(
\"
[请求异常][地址:
\"
+ httpUrl +
\"
][错误信息:
\"
+ e.getMessage()
\n
+
\"
]
\"
);
\n
logger.error(
\"
GLUE(Java)任务执行异常:
\"
, e);
\n
} finally {
\n
try {
\n
if (null != input) {
\n
input.close();
\n
}
\n
if (urlcon != null) {
\n
urlcon.disconnect();
\n
}
\n
if (buffer != null) {
\n
buffer.close();
\n
}
\n
} catch (Exception e2) {
\n
XxlJobHelper.log(
\"
[关闭流异常][错误信息:
\"
+ e2.getMessage() +
\"
]
\"
);
\n
logger.error(
\"
[关闭流异常][错误信息:
\"
+ e2.getMessage() +
\"
]
\"
);
\n
}
\n
}
\n
}
\n\n\n\n
}
\n
'
,
'GLUE代码初始化'
,
'2022-09-25 22:26:44'
,
NULL
,
0
,
0
,
0
),
(
8
,
4
,
'生产-每小时保存能耗数据'
,
'2022-09-26 13:38:16'
,
'2022-11-15 22:41:30'
,
'dbapi'
,
NULL
,
'CRON'
,
'*/10 * * * * ? *'
,
'DO_NOTHING'
,
'FIRST'
,
NULL
,
'http://localhost:8520/api/dbapi/f_set_hour_key_detail'
,
'SERIAL_EXECUTION'
,
0
,
0
,
'GLUE_GROOVY'
,
'package com.xxl.job.service.handler;
\n\n
import com.xxl.job.core.context.XxlJobHelper;
\n
import com.xxl.job.core.handler.IJobHandler;
\n\n
import java.io.BufferedReader;
\n
import java.io.InputStream;
\n
import java.io.InputStreamReader;
\n
import java.net.HttpURLConnection;
\n
import java.net.URL;
\n
import java.util.Arrays;
\n
import java.util.Iterator;
\n
import org.slf4j.Logger;
\n
import org.slf4j.LoggerFactory;
\n\n
public class DemoGlueJobHandler extends IJobHandler {
\n
private static Logger logger = LoggerFactory.getLogger(DemoGlueJobHandler.class);
\n\n
@Override
\n
public void execute() throws Exception {
\n
XxlJobHelper.log(
\"
GLUE(Java)任务执行了!
\"
);
\n
logger.info(
\"
GLUE(Java)任务执行了!
\"
);
\n
executeWhile(XxlJobHelper.getJobParam());
\n
}
\n\n
private void executeWhile(String params) {
\n
logger.info(
\"
GLUE(Java)任务参数为:
\"
+ params);
\n
String[] paramsArray = params.split(
\"
,
\"
);
\n
Iterator<String> iterator = Arrays.stream(paramsArray).iterator();
\n
while (iterator.hasNext()) {
\n
executeApi(iterator.next());
\n
}
\n
}
\n\n
private static void executeApi(String httpUrl) {
\n
String result = null;
\n
InputStream input = null;
\n
HttpURLConnection urlcon = null;
\n
BufferedReader buffer = null;
\n
try {
\n
URL url = new URL(httpUrl);
\n
urlcon = (HttpURLConnection) url.openConnection();
\n
urlcon.setRequestMethod(
\"
POST
\"
);
\n
urlcon.connect();// 获取连接
\n
input = urlcon.getInputStream();
\n
buffer = new BufferedReader(new InputStreamReader(
\n
input,
\"
UTF-8
\"
));
\n
StringBuffer bs = new StringBuffer();
\n
String line = null;
\n
while ((line = buffer.readLine()) != null) {
\n
bs.append(line);
\n
}
\n
result = bs.toString();
\n
XxlJobHelper.log(
\"
result:
\"
+ result);
\n
logger.info(
\"
调用接口【{}】返回值result:{}
\"
, httpUrl, result);
\n
} catch (Exception e) {
\n
XxlJobHelper.log(
\"
[请求异常][地址:
\"
+ httpUrl +
\"
][错误信息:
\"
+ e.getMessage()
\n
+
\"
]
\"
);
\n
logger.error(
\"
GLUE(Java)任务执行异常:
\"
, e);
\n
} finally {
\n
try {
\n
if (null != input) {
\n
input.close();
\n
}
\n
if (urlcon != null) {
\n
urlcon.disconnect();
\n
}
\n
if (buffer != null) {
\n
buffer.close();
\n
}
\n
} catch (Exception e2) {
\n
XxlJobHelper.log(
\"
[关闭流异常][错误信息:
\"
+ e2.getMessage() +
\"
]
\"
);
\n
logger.error(
\"
[关闭流异常][错误信息:
\"
+ e2.getMessage() +
\"
]
\"
);
\n
}
\n
}
\n
}
\n\n\n\n
}
\n
'
,
'GLUE代码初始化'
,
'2022-09-26 13:38:16'
,
NULL
,
1
,
1669636330000
,
1669636340000
),
(
10
,
4
,
'f_rep_days_hours_device'
,
'2022-09-27 23:30:01'
,
'2022-09-29 13:47:12'
,
'dbapi'
,
NULL
,
'CRON'
,
'*/5 * * * * ? *'
,
'DO_NOTHING'
,
'FIRST'
,
NULL
,
'http://localhost:8520/api/dbapi/f_rep_days_hours_device'
,
'SERIAL_EXECUTION'
,
0
,
0
,
'GLUE_GROOVY'
,
'package com.xxl.job.service.handler;
\n\n
import com.xxl.job.core.context.XxlJobHelper;
\n
import com.xxl.job.core.handler.IJobHandler;
\n\n
import java.io.BufferedReader;
\n
import java.io.InputStream;
\n
import java.io.InputStreamReader;
\n
import java.net.HttpURLConnection;
\n
import java.net.URL;
\n
import java.util.Arrays;
\n
import java.util.Iterator;
\n
import org.slf4j.Logger;
\n
import org.slf4j.LoggerFactory;
\n\n
public class DemoGlueJobHandler extends IJobHandler {
\n
private static Logger logger = LoggerFactory.getLogger(DemoGlueJobHandler.class);
\n\n
@Override
\n
public void execute() throws Exception {
\n
XxlJobHelper.log(
\"
GLUE(Java)任务执行了!
\"
);
\n
logger.info(
\"
GLUE(Java)任务执行了!
\"
);
\n
executeWhile(XxlJobHelper.getJobParam());
\n
}
\n\n
private void executeWhile(String params) {
\n
logger.info(
\"
GLUE(Java)任务参数为:
\"
+ params);
\n
String[] paramsArray = params.split(
\"
,
\"
);
\n
Iterator<String> iterator = Arrays.stream(paramsArray).iterator();
\n
while (iterator.hasNext()) {
\n
executeApi(iterator.next());
\n
}
\n
}
\n\n
private static void executeApi(String httpUrl) {
\n
String result = null;
\n
InputStream input = null;
\n
HttpURLConnection urlcon = null;
\n
BufferedReader buffer = null;
\n
try {
\n
URL url = new URL(httpUrl);
\n
urlcon = (HttpURLConnection) url.openConnection();
\n
urlcon.setRequestMethod(
\"
POST
\"
);
\n
urlcon.connect();// 获取连接
\n
input = urlcon.getInputStream();
\n
buffer = new BufferedReader(new InputStreamReader(
\n
input,
\"
UTF-8
\"
));
\n
StringBuffer bs = new StringBuffer();
\n
String line = null;
\n
while ((line = buffer.readLine()) != null) {
\n
bs.append(line);
\n
}
\n
result = bs.toString();
\n
XxlJobHelper.log(
\"
result:
\"
+ result);
\n
logger.info(
\"
调用接口【{}】返回值result:{}
\"
, httpUrl, result);
\n
} catch (Exception e) {
\n
XxlJobHelper.log(
\"
[请求异常][地址:
\"
+ httpUrl +
\"
][错误信息:
\"
+ e.getMessage()
\n
+
\"
]
\"
);
\n
logger.error(
\"
GLUE(Java)任务执行异常:
\"
, e);
\n
} finally {
\n
try {
\n
if (null != input) {
\n
input.close();
\n
}
\n
if (urlcon != null) {
\n
urlcon.disconnect();
\n
}
\n
if (buffer != null) {
\n
buffer.close();
\n
}
\n
} catch (Exception e2) {
\n
XxlJobHelper.log(
\"
[关闭流异常][错误信息:
\"
+ e2.getMessage() +
\"
]
\"
);
\n
logger.error(
\"
[关闭流异常][错误信息:
\"
+ e2.getMessage() +
\"
]
\"
);
\n
}
\n
}
\n
}
\n\n\n\n
}
\n
'
,
'GLUE代码初始化'
,
'2022-09-27 23:30:01'
,
NULL
,
0
,
0
,
0
),
(
11
,
4
,
'f_junlin_rep_out_key'
,
'2022-09-28 14:49:53'
,
'2022-09-28 14:49:53'
,
'dbapi'
,
NULL
,
'CRON'
,
'*/5 * * * * ? *'
,
'DO_NOTHING'
,
'FIRST'
,
NULL
,
'http://localhost:8520/api/f_junlin_rep_out_key'
,
'SERIAL_EXECUTION'
,
0
,
0
,
'GLUE_GROOVY'
,
'package com.xxl.job.service.handler;
\n\n
import com.xxl.job.core.context.XxlJobHelper;
\n
import com.xxl.job.core.handler.IJobHandler;
\n\n
import java.io.BufferedReader;
\n
import java.io.InputStream;
\n
import java.io.InputStreamReader;
\n
import java.net.HttpURLConnection;
\n
import java.net.URL;
\n
import java.util.Arrays;
\n
import java.util.Iterator;
\n
import org.slf4j.Logger;
\n
import org.slf4j.LoggerFactory;
\n\n
public class DemoGlueJobHandler extends IJobHandler {
\n
private static Logger logger = LoggerFactory.getLogger(DemoGlueJobHandler.class);
\n\n
@Override
\n
public void execute() throws Exception {
\n
XxlJobHelper.log(
\"
GLUE(Java)任务执行了!
\"
);
\n
logger.info(
\"
GLUE(Java)任务执行了!
\"
);
\n
executeWhile(XxlJobHelper.getJobParam());
\n
}
\n\n
private void executeWhile(String params) {
\n
logger.info(
\"
GLUE(Java)任务参数为:
\"
+ params);
\n
String[] paramsArray = params.split(
\"
,
\"
);
\n
Iterator<String> iterator = Arrays.stream(paramsArray).iterator();
\n
while (iterator.hasNext()) {
\n
executeApi(iterator.next());
\n
}
\n
}
\n\n
private static void executeApi(String httpUrl) {
\n
String result = null;
\n
InputStream input = null;
\n
HttpURLConnection urlcon = null;
\n
BufferedReader buffer = null;
\n
try {
\n
URL url = new URL(httpUrl);
\n
urlcon = (HttpURLConnection) url.openConnection();
\n
urlcon.setRequestMethod(
\"
POST
\"
);
\n
urlcon.connect();// 获取连接
\n
input = urlcon.getInputStream();
\n
buffer = new BufferedReader(new InputStreamReader(
\n
input,
\"
UTF-8
\"
));
\n
StringBuffer bs = new StringBuffer();
\n
String line = null;
\n
while ((line = buffer.readLine()) != null) {
\n
bs.append(line);
\n
}
\n
result = bs.toString();
\n
XxlJobHelper.log(
\"
result:
\"
+ result);
\n
logger.info(
\"
调用接口【{}】返回值result:{}
\"
, httpUrl, result);
\n
} catch (Exception e) {
\n
XxlJobHelper.log(
\"
[请求异常][地址:
\"
+ httpUrl +
\"
][错误信息:
\"
+ e.getMessage()
\n
+
\"
]
\"
);
\n
logger.error(
\"
GLUE(Java)任务执行异常:
\"
, e);
\n
} finally {
\n
try {
\n
if (null != input) {
\n
input.close();
\n
}
\n
if (urlcon != null) {
\n
urlcon.disconnect();
\n
}
\n
if (buffer != null) {
\n
buffer.close();
\n
}
\n
} catch (Exception e2) {
\n
XxlJobHelper.log(
\"
[关闭流异常][错误信息:
\"
+ e2.getMessage() +
\"
]
\"
);
\n
logger.error(
\"
[关闭流异常][错误信息:
\"
+ e2.getMessage() +
\"
]
\"
);
\n
}
\n
}
\n
}
\n\n\n\n
}
\n
'
,
'GLUE代码初始化'
,
'2022-09-28 14:49:53'
,
NULL
,
0
,
0
,
0
),
(
12
,
4
,
'生产-保存班组能耗数据'
,
'2022-09-29 14:32:10'
,
'2022-11-15 21:31:37'
,
'dbapi'
,
NULL
,
'CRON'
,
'*/10 * * * * ? *'
,
'DO_NOTHING'
,
'FIRST'
,
NULL
,
'http://localhost:8520/api/dbapi/f_set_trep_group_detail'
,
'SERIAL_EXECUTION'
,
0
,
0
,
'GLUE_GROOVY'
,
'package com.xxl.job.service.handler;
\n\n
import com.xxl.job.core.context.XxlJobHelper;
\n
import com.xxl.job.core.handler.IJobHandler;
\n\n
import java.io.BufferedReader;
\n
import java.io.InputStream;
\n
import java.io.InputStreamReader;
\n
import java.net.HttpURLConnection;
\n
import java.net.URL;
\n
import java.util.Arrays;
\n
import java.util.Iterator;
\n
import org.slf4j.Logger;
\n
import org.slf4j.LoggerFactory;
\n\n
public class DemoGlueJobHandler extends IJobHandler {
\n
private static Logger logger = LoggerFactory.getLogger(DemoGlueJobHandler.class);
\n\n
@Override
\n
public void execute() throws Exception {
\n
XxlJobHelper.log(
\"
GLUE(Java)任务执行了!
\"
);
\n
logger.info(
\"
GLUE(Java)任务执行了!
\"
);
\n
executeWhile(XxlJobHelper.getJobParam());
\n
}
\n\n
private void executeWhile(String params) {
\n
logger.info(
\"
GLUE(Java)任务参数为:
\"
+ params);
\n
String[] paramsArray = params.split(
\"
,
\"
);
\n
Iterator<String> iterator = Arrays.stream(paramsArray).iterator();
\n
while (iterator.hasNext()) {
\n
executeApi(iterator.next());
\n
}
\n
}
\n\n
private static void executeApi(String httpUrl) {
\n
String result = null;
\n
InputStream input = null;
\n
HttpURLConnection urlcon = null;
\n
BufferedReader buffer = null;
\n
try {
\n
URL url = new URL(httpUrl);
\n
urlcon = (HttpURLConnection) url.openConnection();
\n
urlcon.setRequestMethod(
\"
POST
\"
);
\n
urlcon.connect();// 获取连接
\n
input = urlcon.getInputStream();
\n
buffer = new BufferedReader(new InputStreamReader(
\n
input,
\"
UTF-8
\"
));
\n
StringBuffer bs = new StringBuffer();
\n
String line = null;
\n
while ((line = buffer.readLine()) != null) {
\n
bs.append(line);
\n
}
\n
result = bs.toString();
\n
XxlJobHelper.log(
\"
result:
\"
+ result);
\n
logger.info(
\"
调用接口【{}】返回值result:{}
\"
, httpUrl, result);
\n
} catch (Exception e) {
\n
XxlJobHelper.log(
\"
[请求异常][地址:
\"
+ httpUrl +
\"
][错误信息:
\"
+ e.getMessage()
\n
+
\"
]
\"
);
\n
logger.error(
\"
GLUE(Java)任务执行异常:
\"
, e);
\n
} finally {
\n
try {
\n
if (null != input) {
\n
input.close();
\n
}
\n
if (urlcon != null) {
\n
urlcon.disconnect();
\n
}
\n
if (buffer != null) {
\n
buffer.close();
\n
}
\n
} catch (Exception e2) {
\n
XxlJobHelper.log(
\"
[关闭流异常][错误信息:
\"
+ e2.getMessage() +
\"
]
\"
);
\n
logger.error(
\"
[关闭流异常][错误信息:
\"
+ e2.getMessage() +
\"
]
\"
);
\n
}
\n
}
\n
}
\n\n\n\n
}
\n
'
,
'GLUE代码初始化'
,
'2022-09-29 14:32:10'
,
NULL
,
1
,
1669636330000
,
1669636340000
),
(
13
,
4
,
'f_trep_group_detail'
,
'2022-09-29 15:11:37'
,
'2022-11-17 10:25:20'
,
'dbapi'
,
NULL
,
'CRON'
,
'*/5 * * * * ? *'
,
'DO_NOTHING'
,
'FIRST'
,
NULL
,
'http://localhost:8520/api/f_trep_group_detail'
,
'SERIAL_EXECUTION'
,
0
,
0
,
'GLUE_GROOVY'
,
'package com.xxl.job.service.handler;
\n\n
import com.xxl.job.core.context.XxlJobHelper;
\n
import com.xxl.job.core.handler.IJobHandler;
\n\n
import java.io.BufferedReader;
\n
import java.io.InputStream;
\n
import java.io.InputStreamReader;
\n
import java.net.HttpURLConnection;
\n
import java.net.URL;
\n
import java.util.Arrays;
\n
import java.util.Iterator;
\n
import org.slf4j.Logger;
\n
import org.slf4j.LoggerFactory;
\n\n
public class DemoGlueJobHandler extends IJobHandler {
\n
private static Logger logger = LoggerFactory.getLogger(DemoGlueJobHandler.class);
\n\n
@Override
\n
public void execute() throws Exception {
\n
XxlJobHelper.log(
\"
GLUE(Java)任务执行了!
\"
);
\n
logger.info(
\"
GLUE(Java)任务执行了!
\"
);
\n
executeWhile(XxlJobHelper.getJobParam());
\n
}
\n\n
private void executeWhile(String params) {
\n
logger.info(
\"
GLUE(Java)任务参数为:
\"
+ params);
\n
String[] paramsArray = params.split(
\"
,
\"
);
\n
Iterator<String> iterator = Arrays.stream(paramsArray).iterator();
\n
while (iterator.hasNext()) {
\n
executeApi(iterator.next());
\n
}
\n
}
\n\n
private static void executeApi(String httpUrl) {
\n
String result = null;
\n
InputStream input = null;
\n
HttpURLConnection urlcon = null;
\n
BufferedReader buffer = null;
\n
try {
\n
URL url = new URL(httpUrl);
\n
urlcon = (HttpURLConnection) url.openConnection();
\n
urlcon.setRequestMethod(
\"
POST
\"
);
\n
urlcon.connect();// 获取连接
\n
input = urlcon.getInputStream();
\n
buffer = new BufferedReader(new InputStreamReader(
\n
input,
\"
UTF-8
\"
));
\n
StringBuffer bs = new StringBuffer();
\n
String line = null;
\n
while ((line = buffer.readLine()) != null) {
\n
bs.append(line);
\n
}
\n
result = bs.toString();
\n
XxlJobHelper.log(
\"
result:
\"
+ result);
\n
logger.info(
\"
调用接口【{}】返回值result:{}
\"
, httpUrl, result);
\n
} catch (Exception e) {
\n
XxlJobHelper.log(
\"
[请求异常][地址:
\"
+ httpUrl +
\"
][错误信息:
\"
+ e.getMessage()
\n
+
\"
]
\"
);
\n
logger.error(
\"
GLUE(Java)任务执行异常:
\"
, e);
\n
} finally {
\n
try {
\n
if (null != input) {
\n
input.close();
\n
}
\n
if (urlcon != null) {
\n
urlcon.disconnect();
\n
}
\n
if (buffer != null) {
\n
buffer.close();
\n
}
\n
} catch (Exception e2) {
\n
XxlJobHelper.log(
\"
[关闭流异常][错误信息:
\"
+ e2.getMessage() +
\"
]
\"
);
\n
logger.error(
\"
[关闭流异常][错误信息:
\"
+ e2.getMessage() +
\"
]
\"
);
\n
}
\n
}
\n
}
\n\n\n\n
}
\n
'
,
'GLUE代码初始化'
,
'2022-09-29 15:11:37'
,
NULL
,
0
,
0
,
0
),
(
14
,
4
,
'f_trep_day_detail'
,
'2022-10-09 23:36:54'
,
'2022-11-15 15:55:42'
,
'dbapi'
,
NULL
,
'CRON'
,
'*/5 * * * * ? *'
,
'DO_NOTHING'
,
'FIRST'
,
NULL
,
'http://localhost:8520/api/f_trep_day_detail'
,
'SERIAL_EXECUTION'
,
0
,
0
,
'GLUE_GROOVY'
,
'package com.xxl.job.service.handler;
\n\n
import com.xxl.job.core.context.XxlJobHelper;
\n
import com.xxl.job.core.handler.IJobHandler;
\n\n
import java.io.BufferedReader;
\n
import java.io.InputStream;
\n
import java.io.InputStreamReader;
\n
import java.net.HttpURLConnection;
\n
import java.net.URL;
\n
import java.util.Arrays;
\n
import java.util.Iterator;
\n
import org.slf4j.Logger;
\n
import org.slf4j.LoggerFactory;
\n\n
public class DemoGlueJobHandler extends IJobHandler {
\n
private static Logger logger = LoggerFactory.getLogger(DemoGlueJobHandler.class);
\n\n
@Override
\n
public void execute() throws Exception {
\n
XxlJobHelper.log(
\"
GLUE(Java)任务执行了!
\"
);
\n
logger.info(
\"
GLUE(Java)任务执行了!
\"
);
\n
executeWhile(XxlJobHelper.getJobParam());
\n
}
\n\n
private void executeWhile(String params) {
\n
logger.info(
\"
GLUE(Java)任务参数为:
\"
+ params);
\n
String[] paramsArray = params.split(
\"
,
\"
);
\n
Iterator<String> iterator = Arrays.stream(paramsArray).iterator();
\n
while (iterator.hasNext()) {
\n
executeApi(iterator.next());
\n
}
\n
}
\n\n
private static void executeApi(String httpUrl) {
\n
String result = null;
\n
InputStream input = null;
\n
HttpURLConnection urlcon = null;
\n
BufferedReader buffer = null;
\n
try {
\n
URL url = new URL(httpUrl);
\n
urlcon = (HttpURLConnection) url.openConnection();
\n
urlcon.setRequestMethod(
\"
POST
\"
);
\n
urlcon.connect();// 获取连接
\n
input = urlcon.getInputStream();
\n
buffer = new BufferedReader(new InputStreamReader(
\n
input,
\"
UTF-8
\"
));
\n
StringBuffer bs = new StringBuffer();
\n
String line = null;
\n
while ((line = buffer.readLine()) != null) {
\n
bs.append(line);
\n
}
\n
result = bs.toString();
\n
XxlJobHelper.log(
\"
result:
\"
+ result);
\n
logger.info(
\"
调用接口【{}】返回值result:{}
\"
, httpUrl, result);
\n
} catch (Exception e) {
\n
XxlJobHelper.log(
\"
[请求异常][地址:
\"
+ httpUrl +
\"
][错误信息:
\"
+ e.getMessage()
\n
+
\"
]
\"
);
\n
logger.error(
\"
GLUE(Java)任务执行异常:
\"
, e);
\n
} finally {
\n
try {
\n
if (null != input) {
\n
input.close();
\n
}
\n
if (urlcon != null) {
\n
urlcon.disconnect();
\n
}
\n
if (buffer != null) {
\n
buffer.close();
\n
}
\n
} catch (Exception e2) {
\n
XxlJobHelper.log(
\"
[关闭流异常][错误信息:
\"
+ e2.getMessage() +
\"
]
\"
);
\n
logger.error(
\"
[关闭流异常][错误信息:
\"
+ e2.getMessage() +
\"
]
\"
);
\n
}
\n
}
\n
}
\n\n\n\n
}
\n
'
,
'GLUE代码初始化'
,
'2022-10-09 23:36:54'
,
NULL
,
0
,
0
,
0
),
(
15
,
4
,
'f_rep_device_days_detail'
,
'2022-10-10 11:38:43'
,
'2022-10-11 12:06:28'
,
'dbapi'
,
NULL
,
'CRON'
,
'*/5 * * * * ? *'
,
'DO_NOTHING'
,
'FIRST'
,
NULL
,
'http://localhost:8520/api/dbapi/f_rep_device_days_detail'
,
'SERIAL_EXECUTION'
,
0
,
0
,
'GLUE_GROOVY'
,
'package com.xxl.job.service.handler;
\n\n
import com.xxl.job.core.context.XxlJobHelper;
\n
import com.xxl.job.core.handler.IJobHandler;
\n\n
import java.io.BufferedReader;
\n
import java.io.InputStream;
\n
import java.io.InputStreamReader;
\n
import java.net.HttpURLConnection;
\n
import java.net.URL;
\n
import java.util.Arrays;
\n
import java.util.Iterator;
\n
import org.slf4j.Logger;
\n
import org.slf4j.LoggerFactory;
\n\n
public class DemoGlueJobHandler extends IJobHandler {
\n
private static Logger logger = LoggerFactory.getLogger(DemoGlueJobHandler.class);
\n\n
@Override
\n
public void execute() throws Exception {
\n
XxlJobHelper.log(
\"
GLUE(Java)任务执行了!
\"
);
\n
logger.info(
\"
GLUE(Java)任务执行了!
\"
);
\n
executeWhile(XxlJobHelper.getJobParam());
\n
}
\n\n
private void executeWhile(String params) {
\n
logger.info(
\"
GLUE(Java)任务参数为:
\"
+ params);
\n
String[] paramsArray = params.split(
\"
,
\"
);
\n
Iterator<String> iterator = Arrays.stream(paramsArray).iterator();
\n
while (iterator.hasNext()) {
\n
executeApi(iterator.next());
\n
}
\n
}
\n\n
private static void executeApi(String httpUrl) {
\n
String result = null;
\n
InputStream input = null;
\n
HttpURLConnection urlcon = null;
\n
BufferedReader buffer = null;
\n
try {
\n
URL url = new URL(httpUrl);
\n
urlcon = (HttpURLConnection) url.openConnection();
\n
urlcon.setRequestMethod(
\"
POST
\"
);
\n
urlcon.connect();// 获取连接
\n
input = urlcon.getInputStream();
\n
buffer = new BufferedReader(new InputStreamReader(
\n
input,
\"
UTF-8
\"
));
\n
StringBuffer bs = new StringBuffer();
\n
String line = null;
\n
while ((line = buffer.readLine()) != null) {
\n
bs.append(line);
\n
}
\n
result = bs.toString();
\n
XxlJobHelper.log(
\"
result:
\"
+ result);
\n
logger.info(
\"
调用接口【{}】返回值result:{}
\"
, httpUrl, result);
\n
} catch (Exception e) {
\n
XxlJobHelper.log(
\"
[请求异常][地址:
\"
+ httpUrl +
\"
][错误信息:
\"
+ e.getMessage()
\n
+
\"
]
\"
);
\n
logger.error(
\"
GLUE(Java)任务执行异常:
\"
, e);
\n
} finally {
\n
try {
\n
if (null != input) {
\n
input.close();
\n
}
\n
if (urlcon != null) {
\n
urlcon.disconnect();
\n
}
\n
if (buffer != null) {
\n
buffer.close();
\n
}
\n
} catch (Exception e2) {
\n
XxlJobHelper.log(
\"
[关闭流异常][错误信息:
\"
+ e2.getMessage() +
\"
]
\"
);
\n
logger.error(
\"
[关闭流异常][错误信息:
\"
+ e2.getMessage() +
\"
]
\"
);
\n
}
\n
}
\n
}
\n\n\n\n
}
\n
'
,
'GLUE代码初始化'
,
'2022-10-10 11:38:43'
,
NULL
,
0
,
0
,
0
),
(
16
,
4
,
'f_rep_device_groups_detail'
,
'2022-10-10 12:27:08'
,
'2022-11-04 00:33:28'
,
'dbapi'
,
NULL
,
'CRON'
,
'*/5 * * * * ? *'
,
'DO_NOTHING'
,
'FIRST'
,
NULL
,
'http://localhost:8520/api/dbapi/f_rep_device_groups_detail'
,
'SERIAL_EXECUTION'
,
0
,
0
,
'GLUE_GROOVY'
,
'package com.xxl.job.service.handler;
\n\n
import com.xxl.job.core.context.XxlJobHelper;
\n
import com.xxl.job.core.handler.IJobHandler;
\n\n
import java.io.BufferedReader;
\n
import java.io.InputStream;
\n
import java.io.InputStreamReader;
\n
import java.net.HttpURLConnection;
\n
import java.net.URL;
\n
import java.util.Arrays;
\n
import java.util.Iterator;
\n
import org.slf4j.Logger;
\n
import org.slf4j.LoggerFactory;
\n\n
public class DemoGlueJobHandler extends IJobHandler {
\n
private static Logger logger = LoggerFactory.getLogger(DemoGlueJobHandler.class);
\n\n
@Override
\n
public void execute() throws Exception {
\n
XxlJobHelper.log(
\"
GLUE(Java)任务执行了!
\"
);
\n
logger.info(
\"
GLUE(Java)任务执行了!
\"
);
\n
executeWhile(XxlJobHelper.getJobParam());
\n
}
\n\n
private void executeWhile(String params) {
\n
logger.info(
\"
GLUE(Java)任务参数为:
\"
+ params);
\n
String[] paramsArray = params.split(
\"
,
\"
);
\n
Iterator<String> iterator = Arrays.stream(paramsArray).iterator();
\n
while (iterator.hasNext()) {
\n
executeApi(iterator.next());
\n
}
\n
}
\n\n
private static void executeApi(String httpUrl) {
\n
String result = null;
\n
InputStream input = null;
\n
HttpURLConnection urlcon = null;
\n
BufferedReader buffer = null;
\n
try {
\n
URL url = new URL(httpUrl);
\n
urlcon = (HttpURLConnection) url.openConnection();
\n
urlcon.setRequestMethod(
\"
POST
\"
);
\n
urlcon.connect();// 获取连接
\n
input = urlcon.getInputStream();
\n
buffer = new BufferedReader(new InputStreamReader(
\n
input,
\"
UTF-8
\"
));
\n
StringBuffer bs = new StringBuffer();
\n
String line = null;
\n
while ((line = buffer.readLine()) != null) {
\n
bs.append(line);
\n
}
\n
result = bs.toString();
\n
XxlJobHelper.log(
\"
result:
\"
+ result);
\n
logger.info(
\"
调用接口【{}】返回值result:{}
\"
, httpUrl, result);
\n
} catch (Exception e) {
\n
XxlJobHelper.log(
\"
[请求异常][地址:
\"
+ httpUrl +
\"
][错误信息:
\"
+ e.getMessage()
\n
+
\"
]
\"
);
\n
logger.error(
\"
GLUE(Java)任务执行异常:
\"
, e);
\n
} finally {
\n
try {
\n
if (null != input) {
\n
input.close();
\n
}
\n
if (urlcon != null) {
\n
urlcon.disconnect();
\n
}
\n
if (buffer != null) {
\n
buffer.close();
\n
}
\n
} catch (Exception e2) {
\n
XxlJobHelper.log(
\"
[关闭流异常][错误信息:
\"
+ e2.getMessage() +
\"
]
\"
);
\n
logger.error(
\"
[关闭流异常][错误信息:
\"
+ e2.getMessage() +
\"
]
\"
);
\n
}
\n
}
\n
}
\n\n\n\n
}
\n
'
,
'GLUE代码初始化'
,
'2022-10-10 12:27:08'
,
NULL
,
0
,
0
,
0
),
(
17
,
4
,
'f_rep_device_months_detail'
,
'2022-10-10 12:30:16'
,
'2022-10-11 12:13:20'
,
'dbapi'
,
NULL
,
'CRON'
,
'*/5 * * * * ? *'
,
'DO_NOTHING'
,
'FIRST'
,
NULL
,
'http://localhost:8520/api/dbapi/f_rep_device_months_detail'
,
'SERIAL_EXECUTION'
,
0
,
0
,
'GLUE_GROOVY'
,
'package com.xxl.job.service.handler;
\n\n
import com.xxl.job.core.context.XxlJobHelper;
\n
import com.xxl.job.core.handler.IJobHandler;
\n\n
import java.io.BufferedReader;
\n
import java.io.InputStream;
\n
import java.io.InputStreamReader;
\n
import java.net.HttpURLConnection;
\n
import java.net.URL;
\n
import java.util.Arrays;
\n
import java.util.Iterator;
\n
import org.slf4j.Logger;
\n
import org.slf4j.LoggerFactory;
\n\n
public class DemoGlueJobHandler extends IJobHandler {
\n
private static Logger logger = LoggerFactory.getLogger(DemoGlueJobHandler.class);
\n\n
@Override
\n
public void execute() throws Exception {
\n
XxlJobHelper.log(
\"
GLUE(Java)任务执行了!
\"
);
\n
logger.info(
\"
GLUE(Java)任务执行了!
\"
);
\n
executeWhile(XxlJobHelper.getJobParam());
\n
}
\n\n
private void executeWhile(String params) {
\n
logger.info(
\"
GLUE(Java)任务参数为:
\"
+ params);
\n
String[] paramsArray = params.split(
\"
,
\"
);
\n
Iterator<String> iterator = Arrays.stream(paramsArray).iterator();
\n
while (iterator.hasNext()) {
\n
executeApi(iterator.next());
\n
}
\n
}
\n\n
private static void executeApi(String httpUrl) {
\n
String result = null;
\n
InputStream input = null;
\n
HttpURLConnection urlcon = null;
\n
BufferedReader buffer = null;
\n
try {
\n
URL url = new URL(httpUrl);
\n
urlcon = (HttpURLConnection) url.openConnection();
\n
urlcon.setRequestMethod(
\"
POST
\"
);
\n
urlcon.connect();// 获取连接
\n
input = urlcon.getInputStream();
\n
buffer = new BufferedReader(new InputStreamReader(
\n
input,
\"
UTF-8
\"
));
\n
StringBuffer bs = new StringBuffer();
\n
String line = null;
\n
while ((line = buffer.readLine()) != null) {
\n
bs.append(line);
\n
}
\n
result = bs.toString();
\n
XxlJobHelper.log(
\"
result:
\"
+ result);
\n
logger.info(
\"
调用接口【{}】返回值result:{}
\"
, httpUrl, result);
\n
} catch (Exception e) {
\n
XxlJobHelper.log(
\"
[请求异常][地址:
\"
+ httpUrl +
\"
][错误信息:
\"
+ e.getMessage()
\n
+
\"
]
\"
);
\n
logger.error(
\"
GLUE(Java)任务执行异常:
\"
, e);
\n
} finally {
\n
try {
\n
if (null != input) {
\n
input.close();
\n
}
\n
if (urlcon != null) {
\n
urlcon.disconnect();
\n
}
\n
if (buffer != null) {
\n
buffer.close();
\n
}
\n
} catch (Exception e2) {
\n
XxlJobHelper.log(
\"
[关闭流异常][错误信息:
\"
+ e2.getMessage() +
\"
]
\"
);
\n
logger.error(
\"
[关闭流异常][错误信息:
\"
+ e2.getMessage() +
\"
]
\"
);
\n
}
\n
}
\n
}
\n\n\n\n
}
\n
'
,
'GLUE代码初始化'
,
'2022-10-10 12:30:16'
,
NULL
,
0
,
0
,
0
),
(
18
,
4
,
'生产-当前状态持续时长统计'
,
'2022-10-16 00:45:28'
,
'2022-11-16 16:19:49'
,
'dbapi'
,
NULL
,
'CRON'
,
'*/20 * * * * ? *'
,
'DO_NOTHING'
,
'FIRST'
,
NULL
,
'http://localhost:8520/api/f_set_sta_detail'
,
'SERIAL_EXECUTION'
,
0
,
0
,
'GLUE_GROOVY'
,
'package com.xxl.job.service.handler;
\n\n
import com.xxl.job.core.context.XxlJobHelper;
\n
import com.xxl.job.core.handler.IJobHandler;
\n\n
import java.io.BufferedReader;
\n
import java.io.InputStream;
\n
import java.io.InputStreamReader;
\n
import java.net.HttpURLConnection;
\n
import java.net.URL;
\n
import java.util.Arrays;
\n
import java.util.Iterator;
\n
import org.slf4j.Logger;
\n
import org.slf4j.LoggerFactory;
\n\n
public class DemoGlueJobHandler extends IJobHandler {
\n
private static Logger logger = LoggerFactory.getLogger(DemoGlueJobHandler.class);
\n\n
@Override
\n
public void execute() throws Exception {
\n
XxlJobHelper.log(
\"
GLUE(Java)任务执行了!
\"
);
\n
logger.info(
\"
GLUE(Java)任务执行了!
\"
);
\n
executeWhile(XxlJobHelper.getJobParam());
\n
}
\n\n
private void executeWhile(String params) {
\n
logger.info(
\"
GLUE(Java)任务参数为:
\"
+ params);
\n
String[] paramsArray = params.split(
\"
,
\"
);
\n
Iterator<String> iterator = Arrays.stream(paramsArray).iterator();
\n
while (iterator.hasNext()) {
\n
executeApi(iterator.next());
\n
}
\n
}
\n\n
private static void executeApi(String httpUrl) {
\n
String result = null;
\n
InputStream input = null;
\n
HttpURLConnection urlcon = null;
\n
BufferedReader buffer = null;
\n
try {
\n
URL url = new URL(httpUrl);
\n
urlcon = (HttpURLConnection) url.openConnection();
\n
urlcon.setRequestMethod(
\"
POST
\"
);
\n
urlcon.connect();// 获取连接
\n
input = urlcon.getInputStream();
\n
buffer = new BufferedReader(new InputStreamReader(
\n
input,
\"
UTF-8
\"
));
\n
StringBuffer bs = new StringBuffer();
\n
String line = null;
\n
while ((line = buffer.readLine()) != null) {
\n
bs.append(line);
\n
}
\n
result = bs.toString();
\n
XxlJobHelper.log(
\"
result:
\"
+ result);
\n
logger.info(
\"
调用接口【{}】返回值result:{}
\"
, httpUrl, result);
\n
} catch (Exception e) {
\n
XxlJobHelper.log(
\"
[请求异常][地址:
\"
+ httpUrl +
\"
][错误信息:
\"
+ e.getMessage()
\n
+
\"
]
\"
);
\n
logger.error(
\"
GLUE(Java)任务执行异常:
\"
, e);
\n
} finally {
\n
try {
\n
if (null != input) {
\n
input.close();
\n
}
\n
if (urlcon != null) {
\n
urlcon.disconnect();
\n
}
\n
if (buffer != null) {
\n
buffer.close();
\n
}
\n
} catch (Exception e2) {
\n
XxlJobHelper.log(
\"
[关闭流异常][错误信息:
\"
+ e2.getMessage() +
\"
]
\"
);
\n
logger.error(
\"
[关闭流异常][错误信息:
\"
+ e2.getMessage() +
\"
]
\"
);
\n
}
\n
}
\n
}
\n\n\n\n
}
\n
'
,
'GLUE代码初始化'
,
'2022-10-16 00:45:28'
,
NULL
,
1
,
1669636320000
,
1669636340000
),
(
19
,
4
,
'生产-保存每日能耗数据-停用'
,
'2022-11-02 16:48:27'
,
'2022-11-16 01:45:39'
,
'dbapi'
,
NULL
,
'CRON'
,
'*/30 * * * * ? *'
,
'DO_NOTHING'
,
'FIRST'
,
NULL
,
'http://localhost:8520/api/f_set_days_key_detail'
,
'SERIAL_EXECUTION'
,
0
,
0
,
'GLUE_GROOVY'
,
'package com.xxl.job.service.handler;
\n\n
import com.xxl.job.core.context.XxlJobHelper;
\n
import com.xxl.job.core.handler.IJobHandler;
\n\n
import java.io.BufferedReader;
\n
import java.io.InputStream;
\n
import java.io.InputStreamReader;
\n
import java.net.HttpURLConnection;
\n
import java.net.URL;
\n
import java.util.Arrays;
\n
import java.util.Iterator;
\n
import org.slf4j.Logger;
\n
import org.slf4j.LoggerFactory;
\n\n
public class DemoGlueJobHandler extends IJobHandler {
\n
private static Logger logger = LoggerFactory.getLogger(DemoGlueJobHandler.class);
\n\n
@Override
\n
public void execute() throws Exception {
\n
XxlJobHelper.log(
\"
GLUE(Java)任务执行了!
\"
);
\n
logger.info(
\"
GLUE(Java)任务执行了!
\"
);
\n
executeWhile(XxlJobHelper.getJobParam());
\n
}
\n\n
private void executeWhile(String params) {
\n
logger.info(
\"
GLUE(Java)任务参数为:
\"
+ params);
\n
String[] paramsArray = params.split(
\"
,
\"
);
\n
Iterator<String> iterator = Arrays.stream(paramsArray).iterator();
\n
while (iterator.hasNext()) {
\n
executeApi(iterator.next());
\n
}
\n
}
\n\n
private static void executeApi(String httpUrl) {
\n
String result = null;
\n
InputStream input = null;
\n
HttpURLConnection urlcon = null;
\n
BufferedReader buffer = null;
\n
try {
\n
URL url = new URL(httpUrl);
\n
urlcon = (HttpURLConnection) url.openConnection();
\n
urlcon.setRequestMethod(
\"
POST
\"
);
\n
urlcon.connect();// 获取连接
\n
input = urlcon.getInputStream();
\n
buffer = new BufferedReader(new InputStreamReader(
\n
input,
\"
UTF-8
\"
));
\n
StringBuffer bs = new StringBuffer();
\n
String line = null;
\n
while ((line = buffer.readLine()) != null) {
\n
bs.append(line);
\n
}
\n
result = bs.toString();
\n
XxlJobHelper.log(
\"
result:
\"
+ result);
\n
logger.info(
\"
调用接口【{}】返回值result:{}
\"
, httpUrl, result);
\n
} catch (Exception e) {
\n
XxlJobHelper.log(
\"
[请求异常][地址:
\"
+ httpUrl +
\"
][错误信息:
\"
+ e.getMessage()
\n
+
\"
]
\"
);
\n
logger.error(
\"
GLUE(Java)任务执行异常:
\"
, e);
\n
} finally {
\n
try {
\n
if (null != input) {
\n
input.close();
\n
}
\n
if (urlcon != null) {
\n
urlcon.disconnect();
\n
}
\n
if (buffer != null) {
\n
buffer.close();
\n
}
\n
} catch (Exception e2) {
\n
XxlJobHelper.log(
\"
[关闭流异常][错误信息:
\"
+ e2.getMessage() +
\"
]
\"
);
\n
logger.error(
\"
[关闭流异常][错误信息:
\"
+ e2.getMessage() +
\"
]
\"
);
\n
}
\n
}
\n
}
\n\n\n\n
}
\n
'
,
'GLUE代码初始化'
,
'2022-11-02 16:48:27'
,
NULL
,
0
,
0
,
0
),
(
20
,
4
,
'f_rep_group_key_sum'
,
'2022-11-03 17:42:59'
,
'2022-11-04 00:12:10'
,
'dbapi'
,
NULL
,
'CRON'
,
'*/5 * * * * ? *'
,
'DO_NOTHING'
,
'FIRST'
,
NULL
,
'http://localhost:8520/api/dbapi/f_rep_group_key_sum'
,
'SERIAL_EXECUTION'
,
0
,
0
,
'GLUE_GROOVY'
,
'package com.xxl.job.service.handler;
\n\n
import com.xxl.job.core.context.XxlJobHelper;
\n
import com.xxl.job.core.handler.IJobHandler;
\n\n
import java.io.BufferedReader;
\n
import java.io.InputStream;
\n
import java.io.InputStreamReader;
\n
import java.net.HttpURLConnection;
\n
import java.net.URL;
\n
import java.util.Arrays;
\n
import java.util.Iterator;
\n
import org.slf4j.Logger;
\n
import org.slf4j.LoggerFactory;
\n\n
public class DemoGlueJobHandler extends IJobHandler {
\n
private static Logger logger = LoggerFactory.getLogger(DemoGlueJobHandler.class);
\n\n
@Override
\n
public void execute() throws Exception {
\n
XxlJobHelper.log(
\"
GLUE(Java)任务执行了!
\"
);
\n
logger.info(
\"
GLUE(Java)任务执行了!
\"
);
\n
executeWhile(XxlJobHelper.getJobParam());
\n
}
\n\n
private void executeWhile(String params) {
\n
logger.info(
\"
GLUE(Java)任务参数为:
\"
+ params);
\n
String[] paramsArray = params.split(
\"
,
\"
);
\n
Iterator<String> iterator = Arrays.stream(paramsArray).iterator();
\n
while (iterator.hasNext()) {
\n
executeApi(iterator.next());
\n
}
\n
}
\n\n
private static void executeApi(String httpUrl) {
\n
String result = null;
\n
InputStream input = null;
\n
HttpURLConnection urlcon = null;
\n
BufferedReader buffer = null;
\n
try {
\n
URL url = new URL(httpUrl);
\n
urlcon = (HttpURLConnection) url.openConnection();
\n
urlcon.setRequestMethod(
\"
POST
\"
);
\n
urlcon.connect();// 获取连接
\n
input = urlcon.getInputStream();
\n
buffer = new BufferedReader(new InputStreamReader(
\n
input,
\"
UTF-8
\"
));
\n
StringBuffer bs = new StringBuffer();
\n
String line = null;
\n
while ((line = buffer.readLine()) != null) {
\n
bs.append(line);
\n
}
\n
result = bs.toString();
\n
XxlJobHelper.log(
\"
result:
\"
+ result);
\n
logger.info(
\"
调用接口【{}】返回值result:{}
\"
, httpUrl, result);
\n
} catch (Exception e) {
\n
XxlJobHelper.log(
\"
[请求异常][地址:
\"
+ httpUrl +
\"
][错误信息:
\"
+ e.getMessage()
\n
+
\"
]
\"
);
\n
logger.error(
\"
GLUE(Java)任务执行异常:
\"
, e);
\n
} finally {
\n
try {
\n
if (null != input) {
\n
input.close();
\n
}
\n
if (urlcon != null) {
\n
urlcon.disconnect();
\n
}
\n
if (buffer != null) {
\n
buffer.close();
\n
}
\n
} catch (Exception e2) {
\n
XxlJobHelper.log(
\"
[关闭流异常][错误信息:
\"
+ e2.getMessage() +
\"
]
\"
);
\n
logger.error(
\"
[关闭流异常][错误信息:
\"
+ e2.getMessage() +
\"
]
\"
);
\n
}
\n
}
\n
}
\n\n\n\n
}
\n
'
,
'GLUE代码初始化'
,
'2022-11-03 17:42:59'
,
NULL
,
0
,
0
,
0
),
(
21
,
4
,
'f_rep_yesterday_key_sum'
,
'2022-11-03 17:43:35'
,
'2022-11-03 18:25:47'
,
'dbapi'
,
NULL
,
'CRON'
,
'*/5 * * * * ? *'
,
'DO_NOTHING'
,
'FIRST'
,
NULL
,
'http://localhost:8520/api/dbapi/f_rep_yesterday_key_sum'
,
'SERIAL_EXECUTION'
,
0
,
0
,
'GLUE_GROOVY'
,
'package com.xxl.job.service.handler;
\n\n
import com.xxl.job.core.context.XxlJobHelper;
\n
import com.xxl.job.core.handler.IJobHandler;
\n\n
import java.io.BufferedReader;
\n
import java.io.InputStream;
\n
import java.io.InputStreamReader;
\n
import java.net.HttpURLConnection;
\n
import java.net.URL;
\n
import java.util.Arrays;
\n
import java.util.Iterator;
\n
import org.slf4j.Logger;
\n
import org.slf4j.LoggerFactory;
\n\n
public class DemoGlueJobHandler extends IJobHandler {
\n
private static Logger logger = LoggerFactory.getLogger(DemoGlueJobHandler.class);
\n\n
@Override
\n
public void execute() throws Exception {
\n
XxlJobHelper.log(
\"
GLUE(Java)任务执行了!
\"
);
\n
logger.info(
\"
GLUE(Java)任务执行了!
\"
);
\n
executeWhile(XxlJobHelper.getJobParam());
\n
}
\n\n
private void executeWhile(String params) {
\n
logger.info(
\"
GLUE(Java)任务参数为:
\"
+ params);
\n
String[] paramsArray = params.split(
\"
,
\"
);
\n
Iterator<String> iterator = Arrays.stream(paramsArray).iterator();
\n
while (iterator.hasNext()) {
\n
executeApi(iterator.next());
\n
}
\n
}
\n\n
private static void executeApi(String httpUrl) {
\n
String result = null;
\n
InputStream input = null;
\n
HttpURLConnection urlcon = null;
\n
BufferedReader buffer = null;
\n
try {
\n
URL url = new URL(httpUrl);
\n
urlcon = (HttpURLConnection) url.openConnection();
\n
urlcon.setRequestMethod(
\"
POST
\"
);
\n
urlcon.connect();// 获取连接
\n
input = urlcon.getInputStream();
\n
buffer = new BufferedReader(new InputStreamReader(
\n
input,
\"
UTF-8
\"
));
\n
StringBuffer bs = new StringBuffer();
\n
String line = null;
\n
while ((line = buffer.readLine()) != null) {
\n
bs.append(line);
\n
}
\n
result = bs.toString();
\n
XxlJobHelper.log(
\"
result:
\"
+ result);
\n
logger.info(
\"
调用接口【{}】返回值result:{}
\"
, httpUrl, result);
\n
} catch (Exception e) {
\n
XxlJobHelper.log(
\"
[请求异常][地址:
\"
+ httpUrl +
\"
][错误信息:
\"
+ e.getMessage()
\n
+
\"
]
\"
);
\n
logger.error(
\"
GLUE(Java)任务执行异常:
\"
, e);
\n
} finally {
\n
try {
\n
if (null != input) {
\n
input.close();
\n
}
\n
if (urlcon != null) {
\n
urlcon.disconnect();
\n
}
\n
if (buffer != null) {
\n
buffer.close();
\n
}
\n
} catch (Exception e2) {
\n
XxlJobHelper.log(
\"
[关闭流异常][错误信息:
\"
+ e2.getMessage() +
\"
]
\"
);
\n
logger.error(
\"
[关闭流异常][错误信息:
\"
+ e2.getMessage() +
\"
]
\"
);
\n
}
\n
}
\n
}
\n\n\n\n
}
\n
'
,
'GLUE代码初始化'
,
'2022-11-03 17:43:35'
,
NULL
,
0
,
0
,
0
),
(
22
,
4
,
'f_rep_device_lastDays_detail'
,
'2022-11-03 18:39:46'
,
'2022-11-03 18:44:56'
,
'dbapi'
,
NULL
,
'CRON'
,
'*/5 * * * * ? *'
,
'DO_NOTHING'
,
'FIRST'
,
NULL
,
'http://localhost:8520/api/dbapi/f_rep_device_lastDays_detail'
,
'SERIAL_EXECUTION'
,
0
,
0
,
'GLUE_GROOVY'
,
'package com.xxl.job.service.handler;
\n\n
import com.xxl.job.core.context.XxlJobHelper;
\n
import com.xxl.job.core.handler.IJobHandler;
\n\n
import java.io.BufferedReader;
\n
import java.io.InputStream;
\n
import java.io.InputStreamReader;
\n
import java.net.HttpURLConnection;
\n
import java.net.URL;
\n
import java.util.Arrays;
\n
import java.util.Iterator;
\n
import org.slf4j.Logger;
\n
import org.slf4j.LoggerFactory;
\n\n
public class DemoGlueJobHandler extends IJobHandler {
\n
private static Logger logger = LoggerFactory.getLogger(DemoGlueJobHandler.class);
\n\n
@Override
\n
public void execute() throws Exception {
\n
XxlJobHelper.log(
\"
GLUE(Java)任务执行了!
\"
);
\n
logger.info(
\"
GLUE(Java)任务执行了!
\"
);
\n
executeWhile(XxlJobHelper.getJobParam());
\n
}
\n\n
private void executeWhile(String params) {
\n
logger.info(
\"
GLUE(Java)任务参数为:
\"
+ params);
\n
String[] paramsArray = params.split(
\"
,
\"
);
\n
Iterator<String> iterator = Arrays.stream(paramsArray).iterator();
\n
while (iterator.hasNext()) {
\n
executeApi(iterator.next());
\n
}
\n
}
\n\n
private static void executeApi(String httpUrl) {
\n
String result = null;
\n
InputStream input = null;
\n
HttpURLConnection urlcon = null;
\n
BufferedReader buffer = null;
\n
try {
\n
URL url = new URL(httpUrl);
\n
urlcon = (HttpURLConnection) url.openConnection();
\n
urlcon.setRequestMethod(
\"
POST
\"
);
\n
urlcon.connect();// 获取连接
\n
input = urlcon.getInputStream();
\n
buffer = new BufferedReader(new InputStreamReader(
\n
input,
\"
UTF-8
\"
));
\n
StringBuffer bs = new StringBuffer();
\n
String line = null;
\n
while ((line = buffer.readLine()) != null) {
\n
bs.append(line);
\n
}
\n
result = bs.toString();
\n
XxlJobHelper.log(
\"
result:
\"
+ result);
\n
logger.info(
\"
调用接口【{}】返回值result:{}
\"
, httpUrl, result);
\n
} catch (Exception e) {
\n
XxlJobHelper.log(
\"
[请求异常][地址:
\"
+ httpUrl +
\"
][错误信息:
\"
+ e.getMessage()
\n
+
\"
]
\"
);
\n
logger.error(
\"
GLUE(Java)任务执行异常:
\"
, e);
\n
} finally {
\n
try {
\n
if (null != input) {
\n
input.close();
\n
}
\n
if (urlcon != null) {
\n
urlcon.disconnect();
\n
}
\n
if (buffer != null) {
\n
buffer.close();
\n
}
\n
} catch (Exception e2) {
\n
XxlJobHelper.log(
\"
[关闭流异常][错误信息:
\"
+ e2.getMessage() +
\"
]
\"
);
\n
logger.error(
\"
[关闭流异常][错误信息:
\"
+ e2.getMessage() +
\"
]
\"
);
\n
}
\n
}
\n
}
\n\n\n\n
}
\n
'
,
'GLUE代码初始化'
,
'2022-11-03 18:39:46'
,
NULL
,
0
,
0
,
0
),
(
23
,
4
,
'生产-每小时保存开停机变化数据'
,
'2022-11-12 13:35:21'
,
'2022-11-14 13:52:42'
,
'dbapi'
,
NULL
,
'CRON'
,
'*/20 * * * * ? *'
,
'DO_NOTHING'
,
'FIRST'
,
NULL
,
'http://localhost:8520/api/f_set_hours_switch_detail'
,
'SERIAL_EXECUTION'
,
0
,
0
,
'GLUE_GROOVY'
,
'package com.xxl.job.service.handler;
\n\n
import com.xxl.job.core.context.XxlJobHelper;
\n
import com.xxl.job.core.handler.IJobHandler;
\n\n
import java.io.BufferedReader;
\n
import java.io.InputStream;
\n
import java.io.InputStreamReader;
\n
import java.net.HttpURLConnection;
\n
import java.net.URL;
\n
import java.util.Arrays;
\n
import java.util.Iterator;
\n
import org.slf4j.Logger;
\n
import org.slf4j.LoggerFactory;
\n\n
public class DemoGlueJobHandler extends IJobHandler {
\n
private static Logger logger = LoggerFactory.getLogger(DemoGlueJobHandler.class);
\n\n
@Override
\n
public void execute() throws Exception {
\n
XxlJobHelper.log(
\"
GLUE(Java)任务执行了!
\"
);
\n
logger.info(
\"
GLUE(Java)任务执行了!
\"
);
\n
executeWhile(XxlJobHelper.getJobParam());
\n
}
\n\n
private void executeWhile(String params) {
\n
logger.info(
\"
GLUE(Java)任务参数为:
\"
+ params);
\n
String[] paramsArray = params.split(
\"
,
\"
);
\n
Iterator<String> iterator = Arrays.stream(paramsArray).iterator();
\n
while (iterator.hasNext()) {
\n
executeApi(iterator.next());
\n
}
\n
}
\n\n
private static void executeApi(String httpUrl) {
\n
String result = null;
\n
InputStream input = null;
\n
HttpURLConnection urlcon = null;
\n
BufferedReader buffer = null;
\n
try {
\n
URL url = new URL(httpUrl);
\n
urlcon = (HttpURLConnection) url.openConnection();
\n
urlcon.setRequestMethod(
\"
POST
\"
);
\n
urlcon.connect();// 获取连接
\n
input = urlcon.getInputStream();
\n
buffer = new BufferedReader(new InputStreamReader(
\n
input,
\"
UTF-8
\"
));
\n
StringBuffer bs = new StringBuffer();
\n
String line = null;
\n
while ((line = buffer.readLine()) != null) {
\n
bs.append(line);
\n
}
\n
result = bs.toString();
\n
XxlJobHelper.log(
\"
result:
\"
+ result);
\n
logger.info(
\"
调用接口【{}】返回值result:{}
\"
, httpUrl, result);
\n
} catch (Exception e) {
\n
XxlJobHelper.log(
\"
[请求异常][地址:
\"
+ httpUrl +
\"
][错误信息:
\"
+ e.getMessage()
\n
+
\"
]
\"
);
\n
logger.error(
\"
GLUE(Java)任务执行异常:
\"
, e);
\n
} finally {
\n
try {
\n
if (null != input) {
\n
input.close();
\n
}
\n
if (urlcon != null) {
\n
urlcon.disconnect();
\n
}
\n
if (buffer != null) {
\n
buffer.close();
\n
}
\n
} catch (Exception e2) {
\n
XxlJobHelper.log(
\"
[关闭流异常][错误信息:
\"
+ e2.getMessage() +
\"
]
\"
);
\n
logger.error(
\"
[关闭流异常][错误信息:
\"
+ e2.getMessage() +
\"
]
\"
);
\n
}
\n
}
\n
}
\n\n\n\n
}
\n
'
,
'GLUE代码初始化'
,
'2022-11-12 13:35:21'
,
NULL
,
1
,
1669636320000
,
1669636340000
);
INSERT
INTO
`xxl_job_info`
(
`id`
,
`job_group`
,
`job_desc`
,
`add_time`
,
`update_time`
,
`author`
,
`alarm_email`
,
`schedule_type`
,
`schedule_conf`
,
`misfire_strategy`
,
`executor_route_strategy`
,
`executor_handler`
,
`executor_param`
,
`executor_block_strategy`
,
`executor_timeout`
,
`executor_fail_retry_count`
,
`glue_type`
,
`glue_source`
,
`glue_remark`
,
`glue_updatetime`
,
`child_jobid`
,
`trigger_status`
,
`trigger_last_time`
,
`trigger_next_time`
)
VALUES
(
24
,
4
,
'生产-班组保存开停机状态'
,
'2022-11-12 13:36:01'
,
'2022-11-14 13:52:57'
,
'dbapi'
,
NULL
,
'CRON'
,
'*/20 * * * * ? *'
,
'DO_NOTHING'
,
'FIRST'
,
NULL
,
'http://localhost:8520/api/f_set_group_switch_detail'
,
'SERIAL_EXECUTION'
,
0
,
0
,
'GLUE_GROOVY'
,
'package com.xxl.job.service.handler;
\n\n
import com.xxl.job.core.context.XxlJobHelper;
\n
import com.xxl.job.core.handler.IJobHandler;
\n\n
import java.io.BufferedReader;
\n
import java.io.InputStream;
\n
import java.io.InputStreamReader;
\n
import java.net.HttpURLConnection;
\n
import java.net.URL;
\n
import java.util.Arrays;
\n
import java.util.Iterator;
\n
import org.slf4j.Logger;
\n
import org.slf4j.LoggerFactory;
\n\n
public class DemoGlueJobHandler extends IJobHandler {
\n
private static Logger logger = LoggerFactory.getLogger(DemoGlueJobHandler.class);
\n\n
@Override
\n
public void execute() throws Exception {
\n
XxlJobHelper.log(
\"
GLUE(Java)任务执行了!
\"
);
\n
logger.info(
\"
GLUE(Java)任务执行了!
\"
);
\n
executeWhile(XxlJobHelper.getJobParam());
\n
}
\n\n
private void executeWhile(String params) {
\n
logger.info(
\"
GLUE(Java)任务参数为:
\"
+ params);
\n
String[] paramsArray = params.split(
\"
,
\"
);
\n
Iterator<String> iterator = Arrays.stream(paramsArray).iterator();
\n
while (iterator.hasNext()) {
\n
executeApi(iterator.next());
\n
}
\n
}
\n\n
private static void executeApi(String httpUrl) {
\n
String result = null;
\n
InputStream input = null;
\n
HttpURLConnection urlcon = null;
\n
BufferedReader buffer = null;
\n
try {
\n
URL url = new URL(httpUrl);
\n
urlcon = (HttpURLConnection) url.openConnection();
\n
urlcon.setRequestMethod(
\"
POST
\"
);
\n
urlcon.connect();// 获取连接
\n
input = urlcon.getInputStream();
\n
buffer = new BufferedReader(new InputStreamReader(
\n
input,
\"
UTF-8
\"
));
\n
StringBuffer bs = new StringBuffer();
\n
String line = null;
\n
while ((line = buffer.readLine()) != null) {
\n
bs.append(line);
\n
}
\n
result = bs.toString();
\n
XxlJobHelper.log(
\"
result:
\"
+ result);
\n
logger.info(
\"
调用接口【{}】返回值result:{}
\"
, httpUrl, result);
\n
} catch (Exception e) {
\n
XxlJobHelper.log(
\"
[请求异常][地址:
\"
+ httpUrl +
\"
][错误信息:
\"
+ e.getMessage()
\n
+
\"
]
\"
);
\n
logger.error(
\"
GLUE(Java)任务执行异常:
\"
, e);
\n
} finally {
\n
try {
\n
if (null != input) {
\n
input.close();
\n
}
\n
if (urlcon != null) {
\n
urlcon.disconnect();
\n
}
\n
if (buffer != null) {
\n
buffer.close();
\n
}
\n
} catch (Exception e2) {
\n
XxlJobHelper.log(
\"
[关闭流异常][错误信息:
\"
+ e2.getMessage() +
\"
]
\"
);
\n
logger.error(
\"
[关闭流异常][错误信息:
\"
+ e2.getMessage() +
\"
]
\"
);
\n
}
\n
}
\n
}
\n\n\n\n
}
\n
'
,
'GLUE代码初始化'
,
'2022-11-12 13:36:01'
,
NULL
,
1
,
1669636320000
,
1669636340000
),
(
25
,
4
,
'生产-每日保存开停机数据'
,
'2022-11-12 13:36:37'
,
'2022-11-14 13:53:12'
,
'dbapi'
,
NULL
,
'CRON'
,
'*/20 * * * * ? *'
,
'DO_NOTHING'
,
'FIRST'
,
NULL
,
'http://localhost:8520/api/f_set_day_switch_detail'
,
'SERIAL_EXECUTION'
,
0
,
0
,
'GLUE_GROOVY'
,
'package com.xxl.job.service.handler;
\n\n
import com.xxl.job.core.context.XxlJobHelper;
\n
import com.xxl.job.core.handler.IJobHandler;
\n\n
import java.io.BufferedReader;
\n
import java.io.InputStream;
\n
import java.io.InputStreamReader;
\n
import java.net.HttpURLConnection;
\n
import java.net.URL;
\n
import java.util.Arrays;
\n
import java.util.Iterator;
\n
import org.slf4j.Logger;
\n
import org.slf4j.LoggerFactory;
\n\n
public class DemoGlueJobHandler extends IJobHandler {
\n
private static Logger logger = LoggerFactory.getLogger(DemoGlueJobHandler.class);
\n\n
@Override
\n
public void execute() throws Exception {
\n
XxlJobHelper.log(
\"
GLUE(Java)任务执行了!
\"
);
\n
logger.info(
\"
GLUE(Java)任务执行了!
\"
);
\n
executeWhile(XxlJobHelper.getJobParam());
\n
}
\n\n
private void executeWhile(String params) {
\n
logger.info(
\"
GLUE(Java)任务参数为:
\"
+ params);
\n
String[] paramsArray = params.split(
\"
,
\"
);
\n
Iterator<String> iterator = Arrays.stream(paramsArray).iterator();
\n
while (iterator.hasNext()) {
\n
executeApi(iterator.next());
\n
}
\n
}
\n\n
private static void executeApi(String httpUrl) {
\n
String result = null;
\n
InputStream input = null;
\n
HttpURLConnection urlcon = null;
\n
BufferedReader buffer = null;
\n
try {
\n
URL url = new URL(httpUrl);
\n
urlcon = (HttpURLConnection) url.openConnection();
\n
urlcon.setRequestMethod(
\"
POST
\"
);
\n
urlcon.connect();// 获取连接
\n
input = urlcon.getInputStream();
\n
buffer = new BufferedReader(new InputStreamReader(
\n
input,
\"
UTF-8
\"
));
\n
StringBuffer bs = new StringBuffer();
\n
String line = null;
\n
while ((line = buffer.readLine()) != null) {
\n
bs.append(line);
\n
}
\n
result = bs.toString();
\n
XxlJobHelper.log(
\"
result:
\"
+ result);
\n
logger.info(
\"
调用接口【{}】返回值result:{}
\"
, httpUrl, result);
\n
} catch (Exception e) {
\n
XxlJobHelper.log(
\"
[请求异常][地址:
\"
+ httpUrl +
\"
][错误信息:
\"
+ e.getMessage()
\n
+
\"
]
\"
);
\n
logger.error(
\"
GLUE(Java)任务执行异常:
\"
, e);
\n
} finally {
\n
try {
\n
if (null != input) {
\n
input.close();
\n
}
\n
if (urlcon != null) {
\n
urlcon.disconnect();
\n
}
\n
if (buffer != null) {
\n
buffer.close();
\n
}
\n
} catch (Exception e2) {
\n
XxlJobHelper.log(
\"
[关闭流异常][错误信息:
\"
+ e2.getMessage() +
\"
]
\"
);
\n
logger.error(
\"
[关闭流异常][错误信息:
\"
+ e2.getMessage() +
\"
]
\"
);
\n
}
\n
}
\n
}
\n\n\n\n
}
\n
'
,
'GLUE代码初始化'
,
'2022-11-12 13:36:37'
,
NULL
,
1
,
1669636320000
,
1669636340000
),
(
26
,
4
,
'南泰君霖对外接口-班组能耗查询'
,
'2022-11-15 13:25:47'
,
'2022-11-17 10:26:07'
,
'dbapi'
,
NULL
,
'CRON'
,
'*/5 * * * * ? *'
,
'DO_NOTHING'
,
'FIRST'
,
NULL
,
'http://localhost:8520/api/v1_group_detail'
,
'SERIAL_EXECUTION'
,
0
,
0
,
'GLUE_GROOVY'
,
'package com.xxl.job.service.handler;
\n\n
import com.xxl.job.core.context.XxlJobHelper;
\n
import com.xxl.job.core.handler.IJobHandler;
\n\n
import java.io.BufferedReader;
\n
import java.io.InputStream;
\n
import java.io.InputStreamReader;
\n
import java.net.HttpURLConnection;
\n
import java.net.URL;
\n
import java.util.Arrays;
\n
import java.util.Iterator;
\n
import org.slf4j.Logger;
\n
import org.slf4j.LoggerFactory;
\n\n
public class DemoGlueJobHandler extends IJobHandler {
\n
private static Logger logger = LoggerFactory.getLogger(DemoGlueJobHandler.class);
\n\n
@Override
\n
public void execute() throws Exception {
\n
XxlJobHelper.log(
\"
GLUE(Java)任务执行了!
\"
);
\n
logger.info(
\"
GLUE(Java)任务执行了!
\"
);
\n
executeWhile(XxlJobHelper.getJobParam());
\n
}
\n\n
private void executeWhile(String params) {
\n
logger.info(
\"
GLUE(Java)任务参数为:
\"
+ params);
\n
String[] paramsArray = params.split(
\"
,
\"
);
\n
Iterator<String> iterator = Arrays.stream(paramsArray).iterator();
\n
while (iterator.hasNext()) {
\n
executeApi(iterator.next());
\n
}
\n
}
\n\n
private static void executeApi(String httpUrl) {
\n
String result = null;
\n
InputStream input = null;
\n
HttpURLConnection urlcon = null;
\n
BufferedReader buffer = null;
\n
try {
\n
URL url = new URL(httpUrl);
\n
urlcon = (HttpURLConnection) url.openConnection();
\n
urlcon.setRequestMethod(
\"
POST
\"
);
\n
urlcon.connect();// 获取连接
\n
input = urlcon.getInputStream();
\n
buffer = new BufferedReader(new InputStreamReader(
\n
input,
\"
UTF-8
\"
));
\n
StringBuffer bs = new StringBuffer();
\n
String line = null;
\n
while ((line = buffer.readLine()) != null) {
\n
bs.append(line);
\n
}
\n
result = bs.toString();
\n
XxlJobHelper.log(
\"
result:
\"
+ result);
\n
logger.info(
\"
调用接口【{}】返回值result:{}
\"
, httpUrl, result);
\n
} catch (Exception e) {
\n
XxlJobHelper.log(
\"
[请求异常][地址:
\"
+ httpUrl +
\"
][错误信息:
\"
+ e.getMessage()
\n
+
\"
]
\"
);
\n
logger.error(
\"
GLUE(Java)任务执行异常:
\"
, e);
\n
} finally {
\n
try {
\n
if (null != input) {
\n
input.close();
\n
}
\n
if (urlcon != null) {
\n
urlcon.disconnect();
\n
}
\n
if (buffer != null) {
\n
buffer.close();
\n
}
\n
} catch (Exception e2) {
\n
XxlJobHelper.log(
\"
[关闭流异常][错误信息:
\"
+ e2.getMessage() +
\"
]
\"
);
\n
logger.error(
\"
[关闭流异常][错误信息:
\"
+ e2.getMessage() +
\"
]
\"
);
\n
}
\n
}
\n
}
\n\n\n\n
}
\n
'
,
'GLUE代码初始化'
,
'2022-11-15 13:25:47'
,
NULL
,
0
,
0
,
0
),
(
27
,
4
,
'南泰君霖对外接口-班组开停机状态查询'
,
'2022-11-15 13:55:43'
,
'2022-11-15 14:05:44'
,
'dbapi'
,
NULL
,
'CRON'
,
'*/5 * * * * ? *'
,
'DO_NOTHING'
,
'FIRST'
,
NULL
,
'http://localhost:8520/api/v1_switch_detail'
,
'SERIAL_EXECUTION'
,
0
,
0
,
'GLUE_GROOVY'
,
'package com.xxl.job.service.handler;
\n\n
import com.xxl.job.core.context.XxlJobHelper;
\n
import com.xxl.job.core.handler.IJobHandler;
\n\n
import java.io.BufferedReader;
\n
import java.io.InputStream;
\n
import java.io.InputStreamReader;
\n
import java.net.HttpURLConnection;
\n
import java.net.URL;
\n
import java.util.Arrays;
\n
import java.util.Iterator;
\n
import org.slf4j.Logger;
\n
import org.slf4j.LoggerFactory;
\n\n
public class DemoGlueJobHandler extends IJobHandler {
\n
private static Logger logger = LoggerFactory.getLogger(DemoGlueJobHandler.class);
\n\n
@Override
\n
public void execute() throws Exception {
\n
XxlJobHelper.log(
\"
GLUE(Java)任务执行了!
\"
);
\n
logger.info(
\"
GLUE(Java)任务执行了!
\"
);
\n
executeWhile(XxlJobHelper.getJobParam());
\n
}
\n\n
private void executeWhile(String params) {
\n
logger.info(
\"
GLUE(Java)任务参数为:
\"
+ params);
\n
String[] paramsArray = params.split(
\"
,
\"
);
\n
Iterator<String> iterator = Arrays.stream(paramsArray).iterator();
\n
while (iterator.hasNext()) {
\n
executeApi(iterator.next());
\n
}
\n
}
\n\n
private static void executeApi(String httpUrl) {
\n
String result = null;
\n
InputStream input = null;
\n
HttpURLConnection urlcon = null;
\n
BufferedReader buffer = null;
\n
try {
\n
URL url = new URL(httpUrl);
\n
urlcon = (HttpURLConnection) url.openConnection();
\n
urlcon.setRequestMethod(
\"
POST
\"
);
\n
urlcon.connect();// 获取连接
\n
input = urlcon.getInputStream();
\n
buffer = new BufferedReader(new InputStreamReader(
\n
input,
\"
UTF-8
\"
));
\n
StringBuffer bs = new StringBuffer();
\n
String line = null;
\n
while ((line = buffer.readLine()) != null) {
\n
bs.append(line);
\n
}
\n
result = bs.toString();
\n
XxlJobHelper.log(
\"
result:
\"
+ result);
\n
logger.info(
\"
调用接口【{}】返回值result:{}
\"
, httpUrl, result);
\n
} catch (Exception e) {
\n
XxlJobHelper.log(
\"
[请求异常][地址:
\"
+ httpUrl +
\"
][错误信息:
\"
+ e.getMessage()
\n
+
\"
]
\"
);
\n
logger.error(
\"
GLUE(Java)任务执行异常:
\"
, e);
\n
} finally {
\n
try {
\n
if (null != input) {
\n
input.close();
\n
}
\n
if (urlcon != null) {
\n
urlcon.disconnect();
\n
}
\n
if (buffer != null) {
\n
buffer.close();
\n
}
\n
} catch (Exception e2) {
\n
XxlJobHelper.log(
\"
[关闭流异常][错误信息:
\"
+ e2.getMessage() +
\"
]
\"
);
\n
logger.error(
\"
[关闭流异常][错误信息:
\"
+ e2.getMessage() +
\"
]
\"
);
\n
}
\n
}
\n
}
\n\n\n\n
}
\n
'
,
'GLUE代码初始化'
,
'2022-11-15 13:55:43'
,
NULL
,
0
,
0
,
0
),
(
28
,
4
,
'南泰君霖对外接口-设备实时采集数据查询'
,
'2022-11-15 14:26:00'
,
'2022-11-15 14:27:36'
,
'dbapi'
,
NULL
,
'CRON'
,
'*/5 * * * * ? *'
,
'DO_NOTHING'
,
'FIRST'
,
NULL
,
'http://localhost:8520/api/v1_device_detail'
,
'SERIAL_EXECUTION'
,
0
,
0
,
'GLUE_GROOVY'
,
'package com.xxl.job.service.handler;
\n\n
import com.xxl.job.core.context.XxlJobHelper;
\n
import com.xxl.job.core.handler.IJobHandler;
\n\n
import java.io.BufferedReader;
\n
import java.io.InputStream;
\n
import java.io.InputStreamReader;
\n
import java.net.HttpURLConnection;
\n
import java.net.URL;
\n
import java.util.Arrays;
\n
import java.util.Iterator;
\n
import org.slf4j.Logger;
\n
import org.slf4j.LoggerFactory;
\n\n
public class DemoGlueJobHandler extends IJobHandler {
\n
private static Logger logger = LoggerFactory.getLogger(DemoGlueJobHandler.class);
\n\n
@Override
\n
public void execute() throws Exception {
\n
XxlJobHelper.log(
\"
GLUE(Java)任务执行了!
\"
);
\n
logger.info(
\"
GLUE(Java)任务执行了!
\"
);
\n
executeWhile(XxlJobHelper.getJobParam());
\n
}
\n\n
private void executeWhile(String params) {
\n
logger.info(
\"
GLUE(Java)任务参数为:
\"
+ params);
\n
String[] paramsArray = params.split(
\"
,
\"
);
\n
Iterator<String> iterator = Arrays.stream(paramsArray).iterator();
\n
while (iterator.hasNext()) {
\n
executeApi(iterator.next());
\n
}
\n
}
\n\n
private static void executeApi(String httpUrl) {
\n
String result = null;
\n
InputStream input = null;
\n
HttpURLConnection urlcon = null;
\n
BufferedReader buffer = null;
\n
try {
\n
URL url = new URL(httpUrl);
\n
urlcon = (HttpURLConnection) url.openConnection();
\n
urlcon.setRequestMethod(
\"
POST
\"
);
\n
urlcon.connect();// 获取连接
\n
input = urlcon.getInputStream();
\n
buffer = new BufferedReader(new InputStreamReader(
\n
input,
\"
UTF-8
\"
));
\n
StringBuffer bs = new StringBuffer();
\n
String line = null;
\n
while ((line = buffer.readLine()) != null) {
\n
bs.append(line);
\n
}
\n
result = bs.toString();
\n
XxlJobHelper.log(
\"
result:
\"
+ result);
\n
logger.info(
\"
调用接口【{}】返回值result:{}
\"
, httpUrl, result);
\n
} catch (Exception e) {
\n
XxlJobHelper.log(
\"
[请求异常][地址:
\"
+ httpUrl +
\"
][错误信息:
\"
+ e.getMessage()
\n
+
\"
]
\"
);
\n
logger.error(
\"
GLUE(Java)任务执行异常:
\"
, e);
\n
} finally {
\n
try {
\n
if (null != input) {
\n
input.close();
\n
}
\n
if (urlcon != null) {
\n
urlcon.disconnect();
\n
}
\n
if (buffer != null) {
\n
buffer.close();
\n
}
\n
} catch (Exception e2) {
\n
XxlJobHelper.log(
\"
[关闭流异常][错误信息:
\"
+ e2.getMessage() +
\"
]
\"
);
\n
logger.error(
\"
[关闭流异常][错误信息:
\"
+ e2.getMessage() +
\"
]
\"
);
\n
}
\n
}
\n
}
\n\n\n\n
}
\n
'
,
'GLUE代码初始化'
,
'2022-11-15 14:26:00'
,
NULL
,
0
,
0
,
0
),
(
29
,
4
,
'生产-君霖定制处理缓存数据'
,
'2022-11-16 02:05:50'
,
'2022-11-16 02:06:04'
,
'dbapi'
,
NULL
,
'CRON'
,
'*/20 * * * * ? *'
,
'DO_NOTHING'
,
'FIRST'
,
NULL
,
'http://localhost:8520/api/f_junlin_temp_cache'
,
'SERIAL_EXECUTION'
,
0
,
0
,
'GLUE_GROOVY'
,
'package com.xxl.job.service.handler;
\n\n
import com.xxl.job.core.context.XxlJobHelper;
\n
import com.xxl.job.core.handler.IJobHandler;
\n\n
import java.io.BufferedReader;
\n
import java.io.InputStream;
\n
import java.io.InputStreamReader;
\n
import java.net.HttpURLConnection;
\n
import java.net.URL;
\n
import java.util.Arrays;
\n
import java.util.Iterator;
\n
import org.slf4j.Logger;
\n
import org.slf4j.LoggerFactory;
\n\n
public class DemoGlueJobHandler extends IJobHandler {
\n
private static Logger logger = LoggerFactory.getLogger(DemoGlueJobHandler.class);
\n\n
@Override
\n
public void execute() throws Exception {
\n
XxlJobHelper.log(
\"
GLUE(Java)任务执行了!
\"
);
\n
logger.info(
\"
GLUE(Java)任务执行了!
\"
);
\n
executeWhile(XxlJobHelper.getJobParam());
\n
}
\n\n
private void executeWhile(String params) {
\n
logger.info(
\"
GLUE(Java)任务参数为:
\"
+ params);
\n
String[] paramsArray = params.split(
\"
,
\"
);
\n
Iterator<String> iterator = Arrays.stream(paramsArray).iterator();
\n
while (iterator.hasNext()) {
\n
executeApi(iterator.next());
\n
}
\n
}
\n\n
private static void executeApi(String httpUrl) {
\n
String result = null;
\n
InputStream input = null;
\n
HttpURLConnection urlcon = null;
\n
BufferedReader buffer = null;
\n
try {
\n
URL url = new URL(httpUrl);
\n
urlcon = (HttpURLConnection) url.openConnection();
\n
urlcon.setRequestMethod(
\"
POST
\"
);
\n
urlcon.connect();// 获取连接
\n
input = urlcon.getInputStream();
\n
buffer = new BufferedReader(new InputStreamReader(
\n
input,
\"
UTF-8
\"
));
\n
StringBuffer bs = new StringBuffer();
\n
String line = null;
\n
while ((line = buffer.readLine()) != null) {
\n
bs.append(line);
\n
}
\n
result = bs.toString();
\n
XxlJobHelper.log(
\"
result:
\"
+ result);
\n
logger.info(
\"
调用接口【{}】返回值result:{}
\"
, httpUrl, result);
\n
} catch (Exception e) {
\n
XxlJobHelper.log(
\"
[请求异常][地址:
\"
+ httpUrl +
\"
][错误信息:
\"
+ e.getMessage()
\n
+
\"
]
\"
);
\n
logger.error(
\"
GLUE(Java)任务执行异常:
\"
, e);
\n
} finally {
\n
try {
\n
if (null != input) {
\n
input.close();
\n
}
\n
if (urlcon != null) {
\n
urlcon.disconnect();
\n
}
\n
if (buffer != null) {
\n
buffer.close();
\n
}
\n
} catch (Exception e2) {
\n
XxlJobHelper.log(
\"
[关闭流异常][错误信息:
\"
+ e2.getMessage() +
\"
]
\"
);
\n
logger.error(
\"
[关闭流异常][错误信息:
\"
+ e2.getMessage() +
\"
]
\"
);
\n
}
\n
}
\n
}
\n\n\n\n
}
\n
'
,
'GLUE代码初始化'
,
'2022-11-16 02:05:50'
,
NULL
,
1
,
1669636320000
,
1669636340000
);
COMMIT
;
-- ----------------------------
-- Table structure for xxl_job_lock
...
...
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