diff --git a/xxl-job-executor-samples/executor-collection-dispatcher/pom.xml b/xxl-job-executor-samples/executor-collection-dispatcher/pom.xml new file mode 100644 index 00000000..19670acd --- /dev/null +++ b/xxl-job-executor-samples/executor-collection-dispatcher/pom.xml @@ -0,0 +1,127 @@ + + + 4.0.0 + + com.xuxueli + xxl-job-executor-samples + 1.9.1-SNAPSHOT + + executor-collection-dispatcher + jar + + ${project.artifactId} + Example executor project for spring boot. + http://www.xuxueli.com/ + + + UTF-8 + UTF-8 + 1.7 + + + + + + + org.springframework.boot + spring-boot-starter-parent + ${spring-boot.version} + pom + import + + + + org.eclipse.jetty + jetty-server + ${jetty-server.version} + + + org.eclipse.jetty + jetty-util + ${jetty-server.version} + + + org.eclipse.jetty + jetty-http + ${jetty-server.version} + + + org.eclipse.jetty + jetty-io + ${jetty-server.version} + + + + + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-test + test + + + + org.springframework.boot + spring-boot-starter-jdbc + + + org.mybatis.spring.boot + mybatis-spring-boot-starter + 1.3.1 + + + mysql + mysql-connector-java + runtime + + + + com.xuxueli + xxl-job-core + ${project.parent.version} + + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + repackage + + + + + + + org.mybatis.generator + mybatis-generator-maven-plugin + 1.3.2 + + ${basedir}/src/main/resources/generator/generatorConfig.xml + true + true + + + + + + + \ No newline at end of file diff --git a/xxl-job-executor-samples/executor-collection-dispatcher/src/main/java/com/infincash/statistics/risk/RiskService.java b/xxl-job-executor-samples/executor-collection-dispatcher/src/main/java/com/infincash/statistics/risk/RiskService.java new file mode 100644 index 00000000..68d5f9d0 --- /dev/null +++ b/xxl-job-executor-samples/executor-collection-dispatcher/src/main/java/com/infincash/statistics/risk/RiskService.java @@ -0,0 +1,11 @@ +package com.infincash.statistics.risk; + +import java.util.List; + +import com.infincash.statistics.risk.table.prd.extend.RiskStatsDTO; + +public interface RiskService { + List countRecentRisk(); + + int writeRecentRisk(List list); +} diff --git a/xxl-job-executor-samples/executor-collection-dispatcher/src/main/java/com/infincash/statistics/risk/RiskServiceImpl.java b/xxl-job-executor-samples/executor-collection-dispatcher/src/main/java/com/infincash/statistics/risk/RiskServiceImpl.java new file mode 100644 index 00000000..c4b0661f --- /dev/null +++ b/xxl-job-executor-samples/executor-collection-dispatcher/src/main/java/com/infincash/statistics/risk/RiskServiceImpl.java @@ -0,0 +1,30 @@ +package com.infincash.statistics.risk; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import com.infincash.statistics.risk.mapper.prd.TRiskRuleMapper; +import com.infincash.statistics.risk.mapper.stats.TStatsRiskDetailMapper; +import com.infincash.statistics.risk.table.prd.extend.RiskStatsDTO; + +@Service +public class RiskServiceImpl implements RiskService { + + @Autowired + private TRiskRuleMapper readMapper;//这里会报错,但是并不会影响 + + @Autowired + private TStatsRiskDetailMapper writeMapper; + + @Override + public List countRecentRisk() { + return readMapper.countRiskRule(); + } + + @Override + public int writeRecentRisk(List list) { + return writeMapper.insertBatch(list); + } +} diff --git a/xxl-job-executor-samples/executor-collection-dispatcher/src/main/java/com/infincash/statistics/risk/mapper/prd/TRiskRuleMapper.java b/xxl-job-executor-samples/executor-collection-dispatcher/src/main/java/com/infincash/statistics/risk/mapper/prd/TRiskRuleMapper.java new file mode 100644 index 00000000..007bbf51 --- /dev/null +++ b/xxl-job-executor-samples/executor-collection-dispatcher/src/main/java/com/infincash/statistics/risk/mapper/prd/TRiskRuleMapper.java @@ -0,0 +1,9 @@ +package com.infincash.statistics.risk.mapper.prd; + +import java.util.List; + +import com.infincash.statistics.risk.table.prd.extend.RiskStatsDTO; + +public interface TRiskRuleMapper { + List countRiskRule(); +} \ No newline at end of file diff --git a/xxl-job-executor-samples/executor-collection-dispatcher/src/main/java/com/infincash/statistics/risk/mapper/stats/TStatsRiskDetailMapper.java b/xxl-job-executor-samples/executor-collection-dispatcher/src/main/java/com/infincash/statistics/risk/mapper/stats/TStatsRiskDetailMapper.java new file mode 100644 index 00000000..2ed592e0 --- /dev/null +++ b/xxl-job-executor-samples/executor-collection-dispatcher/src/main/java/com/infincash/statistics/risk/mapper/stats/TStatsRiskDetailMapper.java @@ -0,0 +1,10 @@ +package com.infincash.statistics.risk.mapper.stats; + +import java.util.List; + +import com.infincash.statistics.risk.table.prd.extend.RiskStatsDTO; + + +public interface TStatsRiskDetailMapper { + int insertBatch(List list); +} \ No newline at end of file diff --git a/xxl-job-executor-samples/executor-collection-dispatcher/src/main/java/com/infincash/statistics/risk/table/prd/extend/RiskStatsDTO.java b/xxl-job-executor-samples/executor-collection-dispatcher/src/main/java/com/infincash/statistics/risk/table/prd/extend/RiskStatsDTO.java new file mode 100644 index 00000000..f51e7f5e --- /dev/null +++ b/xxl-job-executor-samples/executor-collection-dispatcher/src/main/java/com/infincash/statistics/risk/table/prd/extend/RiskStatsDTO.java @@ -0,0 +1,28 @@ +package com.infincash.statistics.risk.table.prd.extend; + +import java.util.Date; + +public class RiskStatsDTO { + String riskRuleId; + int count; + Date time; + + public Date getTime() { + return time; + } + public void setTime(Date time) { + this.time = time; + } + public String getRiskRuleId() { + return riskRuleId; + } + public void setRiskRuleId(String riskRuleId) { + this.riskRuleId = riskRuleId; + } + public int getCount() { + return count; + } + public void setCount(int count) { + this.count = count; + } +} diff --git a/xxl-job-executor-samples/executor-collection-dispatcher/src/main/java/com/xxl/job/executor/Application.java b/xxl-job-executor-samples/executor-collection-dispatcher/src/main/java/com/xxl/job/executor/Application.java new file mode 100644 index 00000000..c98c3811 --- /dev/null +++ b/xxl-job-executor-samples/executor-collection-dispatcher/src/main/java/com/xxl/job/executor/Application.java @@ -0,0 +1,19 @@ +package com.xxl.job.executor; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; + +/** + * 禁掉DataSourceAutoConfiguration,因为它会读取application.properties文件的spring.datasource.*属性并自动配置单数据源 + * @author caishuxiao + * + */ +@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}) +public class Application { + + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } + +} \ No newline at end of file diff --git a/xxl-job-executor-samples/executor-collection-dispatcher/src/main/java/com/xxl/job/executor/core/config/DataSourceConfig.java b/xxl-job-executor-samples/executor-collection-dispatcher/src/main/java/com/xxl/job/executor/core/config/DataSourceConfig.java new file mode 100644 index 00000000..b5411e32 --- /dev/null +++ b/xxl-job-executor-samples/executor-collection-dispatcher/src/main/java/com/xxl/job/executor/core/config/DataSourceConfig.java @@ -0,0 +1,25 @@ +package com.xxl.job.executor.core.config; + +import javax.sql.DataSource; + +import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class DataSourceConfig { + + @Bean(name = "prd") + @ConfigurationProperties(prefix = "spring.datasource.prd") // application.properteis中对应属性的前缀 + public DataSource dataSource1() { + return DataSourceBuilder.create().build(); + } + + @Bean(name = "stats") + @ConfigurationProperties(prefix = "spring.datasource.stats") // application.properteis中对应属性的前缀 + public DataSource dataSource2() { + return DataSourceBuilder.create().build(); + } + +} \ No newline at end of file diff --git a/xxl-job-executor-samples/executor-collection-dispatcher/src/main/java/com/xxl/job/executor/core/config/PrdDbConfig.java b/xxl-job-executor-samples/executor-collection-dispatcher/src/main/java/com/xxl/job/executor/core/config/PrdDbConfig.java new file mode 100644 index 00000000..c890aa05 --- /dev/null +++ b/xxl-job-executor-samples/executor-collection-dispatcher/src/main/java/com/xxl/job/executor/core/config/PrdDbConfig.java @@ -0,0 +1,39 @@ +package com.xxl.job.executor.core.config; + +import javax.sql.DataSource; + +import org.apache.ibatis.session.SqlSessionFactory; +import org.mybatis.spring.SqlSessionFactoryBean; +import org.mybatis.spring.SqlSessionTemplate; +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.io.support.PathMatchingResourcePatternResolver; + +@Configuration +@MapperScan(basePackages = {"com.infincash.statistics.risk.mapper.prd"}, sqlSessionFactoryRef = "sqlSessionFactoryPrd") +public class PrdDbConfig { + static final String MAPPER_LOCATION = "classpath:mapping/prd/*.xml"; + + @Autowired + @Qualifier("prd") + private DataSource prd; + + @Bean + public SqlSessionFactory sqlSessionFactoryPrd() throws Exception { + SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean(); + factoryBean.setDataSource(prd); + factoryBean.setMapperLocations( + new PathMatchingResourcePatternResolver().getResources(MAPPER_LOCATION) + ); + return factoryBean.getObject(); + } + + @Bean + public SqlSessionTemplate sqlSessionTemplatePrd() throws Exception { + SqlSessionTemplate template = new SqlSessionTemplate(sqlSessionFactoryPrd()); + return template; + } +} \ No newline at end of file diff --git a/xxl-job-executor-samples/executor-collection-dispatcher/src/main/java/com/xxl/job/executor/core/config/StatsDbConfig.java b/xxl-job-executor-samples/executor-collection-dispatcher/src/main/java/com/xxl/job/executor/core/config/StatsDbConfig.java new file mode 100644 index 00000000..ce4fb563 --- /dev/null +++ b/xxl-job-executor-samples/executor-collection-dispatcher/src/main/java/com/xxl/job/executor/core/config/StatsDbConfig.java @@ -0,0 +1,39 @@ +package com.xxl.job.executor.core.config; + +import javax.sql.DataSource; + +import org.apache.ibatis.session.SqlSessionFactory; +import org.mybatis.spring.SqlSessionFactoryBean; +import org.mybatis.spring.SqlSessionTemplate; +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.io.support.PathMatchingResourcePatternResolver; + +@Configuration +@MapperScan(basePackages = {"com.infincash.statistics.risk.mapper.stats"}, sqlSessionFactoryRef = "sqlSessionFactoryStats") +public class StatsDbConfig { + static final String MAPPER_LOCATION = "classpath:mapping/stats/*.xml"; + + @Autowired + @Qualifier("stats") + private DataSource stats; + + @Bean + public SqlSessionFactory sqlSessionFactoryStats() throws Exception { + SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean(); + factoryBean.setDataSource(stats); + factoryBean.setMapperLocations( + new PathMatchingResourcePatternResolver().getResources(MAPPER_LOCATION) + ); + return factoryBean.getObject(); + } + + @Bean + public SqlSessionTemplate sqlSessionTemplateStats() throws Exception { + SqlSessionTemplate template = new SqlSessionTemplate(sqlSessionFactoryStats()); // 使用上面配置的Factory + return template; + } +} \ No newline at end of file diff --git a/xxl-job-executor-samples/executor-collection-dispatcher/src/main/java/com/xxl/job/executor/core/config/XxlJobConfig.java b/xxl-job-executor-samples/executor-collection-dispatcher/src/main/java/com/xxl/job/executor/core/config/XxlJobConfig.java new file mode 100644 index 00000000..76436502 --- /dev/null +++ b/xxl-job-executor-samples/executor-collection-dispatcher/src/main/java/com/xxl/job/executor/core/config/XxlJobConfig.java @@ -0,0 +1,58 @@ +package com.xxl.job.executor.core.config; + +import com.xxl.job.core.executor.XxlJobExecutor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +/** + * xxl-job config + * + * @author xuxueli 2017-04-28 + */ +@Configuration +@ComponentScan(basePackages = "com.xxl.job.executor.service.jobhandler,com.infincash.*") +public class XxlJobConfig { + private Logger logger = LoggerFactory.getLogger(XxlJobConfig.class); + + @Value("${xxl.job.admin.addresses}") + private String adminAddresses; + + @Value("${xxl.job.executor.appname}") + private String appName; + + @Value("${xxl.job.executor.ip}") + private String ip; + + @Value("${xxl.job.executor.port}") + private int port; + + @Value("${xxl.job.accessToken}") + private String accessToken; + + @Value("${xxl.job.executor.logpath}") + private String logPath; + + @Value("${xxl.job.executor.logretentiondays}") + private int logRetentionDays; + + + @Bean(initMethod = "start", destroyMethod = "destroy") + public XxlJobExecutor xxlJobExecutor() { + logger.info(">>>>>>>>>>> xxl-job config init."); + XxlJobExecutor xxlJobExecutor = new XxlJobExecutor(); + xxlJobExecutor.setAdminAddresses(adminAddresses); + xxlJobExecutor.setAppName(appName); + xxlJobExecutor.setIp(ip); + xxlJobExecutor.setPort(port); + xxlJobExecutor.setAccessToken(accessToken); + xxlJobExecutor.setLogPath(logPath); + xxlJobExecutor.setLogRetentionDays(logRetentionDays); + + return xxlJobExecutor; + } + +} \ No newline at end of file diff --git a/xxl-job-executor-samples/executor-collection-dispatcher/src/main/java/com/xxl/job/executor/mvc/controller/IndexController.java b/xxl-job-executor-samples/executor-collection-dispatcher/src/main/java/com/xxl/job/executor/mvc/controller/IndexController.java new file mode 100644 index 00000000..37c90719 --- /dev/null +++ b/xxl-job-executor-samples/executor-collection-dispatcher/src/main/java/com/xxl/job/executor/mvc/controller/IndexController.java @@ -0,0 +1,18 @@ +//package com.xxl.job.executor.mvc.controller; +// +//import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +//import org.springframework.stereotype.Controller; +//import org.springframework.web.bind.annotation.RequestMapping; +//import org.springframework.web.bind.annotation.ResponseBody; +// +//@Controller +//@EnableAutoConfiguration +//public class IndexController { +// +// @RequestMapping("/") +// @ResponseBody +// String index() { +// return "xxl job executor running."; +// } +// +//} \ No newline at end of file diff --git a/xxl-job-executor-samples/executor-collection-dispatcher/src/main/java/com/xxl/job/executor/service/jobhandler/RiskCountStatisticsJobHandler.java b/xxl-job-executor-samples/executor-collection-dispatcher/src/main/java/com/xxl/job/executor/service/jobhandler/RiskCountStatisticsJobHandler.java new file mode 100644 index 00000000..4928b69b --- /dev/null +++ b/xxl-job-executor-samples/executor-collection-dispatcher/src/main/java/com/xxl/job/executor/service/jobhandler/RiskCountStatisticsJobHandler.java @@ -0,0 +1,41 @@ +package com.xxl.job.executor.service.jobhandler; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import com.infincash.statistics.risk.RiskService; +import com.infincash.statistics.risk.table.prd.extend.RiskStatsDTO; +import com.xxl.job.core.biz.model.ReturnT; +import com.xxl.job.core.handler.IJobHandler; +import com.xxl.job.core.handler.annotation.JobHandler; +import com.xxl.job.core.log.XxlJobLogger; + +/** + * 任务Handler示例(Bean模式) + * + * 开发步骤: 1、继承"IJobHandler":“com.xxl.job.core.handler.IJobHandler”; + * 2、注册到Spring容器:添加“@Component”注解,被Spring容器扫描为Bean实例; + * 3、注册到执行器工厂:添加“@JobHandler(value="自定义jobhandler名称")”注解,注解value值对应的是调度中心新建任务的JobHandler属性的值。 + * 4、执行日志:需要通过 "XxlJobLogger.log" 打印执行日志; + * + * @author xuxueli 2015-12-19 19:43:36 + */ +@JobHandler(value = "risk-count-statistics") +@Component +public class RiskCountStatisticsJobHandler extends IJobHandler { + @Autowired + RiskService service; + + @Override + public ReturnT execute(String param) throws Exception { + List list = service.countRecentRisk(); + int res = service.writeRecentRisk(list); + XxlJobLogger.log("res: " + res); + if(res < list.size()){ + return FAIL; + } + return SUCCESS; + } +} diff --git a/xxl-job-executor-samples/executor-collection-dispatcher/src/main/java/com/xxl/job/executor/service/jobhandler/ShardingJobHandler.java b/xxl-job-executor-samples/executor-collection-dispatcher/src/main/java/com/xxl/job/executor/service/jobhandler/ShardingJobHandler.java new file mode 100644 index 00000000..b58871fe --- /dev/null +++ b/xxl-job-executor-samples/executor-collection-dispatcher/src/main/java/com/xxl/job/executor/service/jobhandler/ShardingJobHandler.java @@ -0,0 +1,39 @@ +package com.xxl.job.executor.service.jobhandler; + +import com.xxl.job.core.biz.model.ReturnT; +import com.xxl.job.core.handler.IJobHandler; +import com.xxl.job.core.handler.annotation.JobHandler; +import com.xxl.job.core.log.XxlJobLogger; +import com.xxl.job.core.util.ShardingUtil; +import org.springframework.stereotype.Service; + + +/** + * 分片广播任务 + * + * @author xuxueli 2017-07-25 20:56:50 + */ +@JobHandler(value="shardingJobHandler") +@Service +public class ShardingJobHandler extends IJobHandler { + + @Override + public ReturnT execute(String param) throws Exception { + + // 分片参数 + ShardingUtil.ShardingVO shardingVO = ShardingUtil.getShardingVo(); + XxlJobLogger.log("分片参数:当前分片序号 = {0}, 总分片数 = {1}", shardingVO.getIndex(), shardingVO.getTotal()); + + // 业务逻辑 + for (int i = 0; i < shardingVO.getTotal(); i++) { + if (i == shardingVO.getIndex()) { + XxlJobLogger.log("第 {0} 片, 命中分片开始处理", i); + } else { + XxlJobLogger.log("第 {0} 片, 忽略", i); + } + } + + return SUCCESS; + } + +} diff --git a/xxl-job-executor-samples/executor-collection-dispatcher/src/main/resources/application.properties b/xxl-job-executor-samples/executor-collection-dispatcher/src/main/resources/application.properties new file mode 100644 index 00000000..e477c3a0 --- /dev/null +++ b/xxl-job-executor-samples/executor-collection-dispatcher/src/main/resources/application.properties @@ -0,0 +1,36 @@ +spring.datasource.prd.url=jdbc:mysql://172.16.16.98:3306/microfinance?autoReconnect=true&useUnicode=true&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&rewriteBatchedStatements=true&useSSL=false +spring.datasource.prd.username=jobopr +spring.datasource.prd.password=jobopr666 +spring.datasource.prd.driver-class-name=com.mysql.jdbc.Driver + +spring.datasource.stats.url=jdbc:mysql://172.16.16.99:3306/microfinance1?autoReconnect=true&useUnicode=true&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&rewriteBatchedStatements=true&useSSL=false +spring.datasource.stats.username=jobopr +spring.datasource.stats.password=jobopr666 +spring.datasource.stats.driver-class-name=com.mysql.jdbc.Driver + +# multi datasource no need declare here +#mybatis.mapper-locations=classpath:mapping/*.xml +#mybatis.type-aliases-package=com.infincash.statistics.risk.table +# web port +server.port=9001 + +# log config +logging.config=classpath:logback.xml + + +### xxl-job admin address list, such as "http://address" or "http://address01,http://address02" +xxl.job.admin.addresses=http://127.0.0.1:8090 +#xxl.job.admin.addresses=http://dispatch-center.infincash.com + +### xxl-job executor address +xxl.job.executor.appname=executor-001 +xxl.job.executor.ip= +xxl.job.executor.port=9002 + +### xxl-job, access token +xxl.job.accessToken= + +### xxl-job log path +xxl.job.executor.logpath=/data/applogs/xxl-job/jobhandler +### xxl-job log retention days +xxl.job.executor.logretentiondays=-1 diff --git a/xxl-job-executor-samples/executor-collection-dispatcher/src/main/resources/generator/generatorConfig.xml b/xxl-job-executor-samples/executor-collection-dispatcher/src/main/resources/generator/generatorConfig.xml new file mode 100644 index 00000000..2e14bde5 --- /dev/null +++ b/xxl-job-executor-samples/executor-collection-dispatcher/src/main/resources/generator/generatorConfig.xml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
\ No newline at end of file diff --git a/xxl-job-executor-samples/executor-collection-dispatcher/src/main/resources/logback.xml b/xxl-job-executor-samples/executor-collection-dispatcher/src/main/resources/logback.xml new file mode 100644 index 00000000..bbea067c --- /dev/null +++ b/xxl-job-executor-samples/executor-collection-dispatcher/src/main/resources/logback.xml @@ -0,0 +1,37 @@ + + + + logback + + + + + + %d{HH:mm:ss.SSS} %contextName [%thread] %-5level %logger{36} - %msg%n + + + + + ${log.path} + + ${log.path}.%d{yyyy-MM-dd}.zip + + + %date %level [%thread] %logger{36} [%file : %line] %msg%n + + + + + + + + + + + + \ No newline at end of file diff --git a/xxl-job-executor-samples/executor-collection-dispatcher/src/main/resources/mapping/prd/TRiskRuleMapper.xml b/xxl-job-executor-samples/executor-collection-dispatcher/src/main/resources/mapping/prd/TRiskRuleMapper.xml new file mode 100644 index 00000000..2934299a --- /dev/null +++ b/xxl-job-executor-samples/executor-collection-dispatcher/src/main/resources/mapping/prd/TRiskRuleMapper.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/xxl-job-executor-samples/executor-collection-dispatcher/src/main/resources/mapping/stats/TStatsRiskDetailMapper.xml b/xxl-job-executor-samples/executor-collection-dispatcher/src/main/resources/mapping/stats/TStatsRiskDetailMapper.xml new file mode 100644 index 00000000..97eab6bc --- /dev/null +++ b/xxl-job-executor-samples/executor-collection-dispatcher/src/main/resources/mapping/stats/TStatsRiskDetailMapper.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + insert into t_stats_risk_detail + (stats_time, a_hour_count, risk_rule_id) + VALUES + + ( + #{oneItem.time}, #{oneItem.count},#{oneItem.riskRuleId} + ) + + + \ No newline at end of file diff --git a/xxl-job-executor-samples/executor-collection-dispatcher/src/test/java/com/xxl/job/executor/test/XxlJobExecutorExampleBootApplicationTests.java b/xxl-job-executor-samples/executor-collection-dispatcher/src/test/java/com/xxl/job/executor/test/XxlJobExecutorExampleBootApplicationTests.java new file mode 100644 index 00000000..9739989a --- /dev/null +++ b/xxl-job-executor-samples/executor-collection-dispatcher/src/test/java/com/xxl/job/executor/test/XxlJobExecutorExampleBootApplicationTests.java @@ -0,0 +1,24 @@ +package com.xxl.job.executor.test; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +import com.xxl.job.executor.Application; +import com.xxl.job.executor.service.jobhandler.RiskCountStatisticsJobHandler; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = Application.class ,webEnvironment= SpringBootTest.WebEnvironment.RANDOM_PORT) +public class XxlJobExecutorExampleBootApplicationTests { + + @Autowired + RiskCountStatisticsJobHandler jobHandler; + + @Test + public void test() throws Exception { + jobHandler.execute(""); + } + +} \ No newline at end of file