【死磕jeesite源码】Jeesite配置定时任务
一、主要是注意XML文件中设置3个地方和类文件中配置

第三步配置:开启任务
类中注解配置:如下
@Service 或者Component
@Lazy(false)
public class ImportGamexxjh5 {
private static Logger logger = LoggerFactory.getLogger(ImportGamexxjh5.class);
@Autowired
Gamexxjh5Service gamexxjh5Service;
@Autowired
TfAnaysisResultTyhxService tfAnaysisResultTyhxService; @Scheduled(cron = "0 4 18 * * ?")
public void importGameXXJH5() {
logger.info("-------执行importGameXXJH5开始------->"+ DateUtils.getDateTime());
SimpleDateFormat myFmt = new SimpleDateFormat("yyMMdd");
Date date = new Date();
String nowdate = myFmt.format(date);
String tablename="order_"+nowdate;
rundata(tablename);
logger.info("-------导入H5数据库中"+tablename+"表的渠道汇总数据----");
logger.info("-------执行importGameXXJH5结束------->"+DateUtils.getDateTime());
} public void rundata(String tablename) {
//数据源切至H5数据库,获取按渠道按天汇总数据
DynamicDataSource.setCurrentLookupKey("h5_dataSource");
List<Gamexxjh5> gList = gamexxjh5Service.queryAll(tablename);
//数据源切换回至版权数据库
DynamicDataSource.setCurrentLookupKey("dataSource");
//将数据导入至版权的数据表中
for (Gamexxjh5 item : gList) {
TfAnaysisResultTyhx tfAnaysisResultTyhx =new TfAnaysisResultTyhx();
tfAnaysisResultTyhx.setChannelid(item.getChannelid());
tfAnaysisResultTyhx.setChannelname(item.getChannelname());
tfAnaysisResultTyhx.setDaypayment(item.getDaypayment());
tfAnaysisResultTyhx.setStatdate(item.getStatdate()); tfAnaysisResultTyhx.setGameid("41");
tfAnaysisResultTyhx.setGamename("新仙剑H5");
tfAnaysisResultTyhx.setGameEnglishName("xinxianjianH5");
tfAnaysisResultTyhx.setResult("Y");
tfAnaysisResultTyhx.setChanneltype("");
tfAnaysisResultTyhx.setIpowner("大宇资讯股份有限公司");
tfAnaysisResultTyhx.setIpownerid("8");
tfAnaysisResultTyhx.setMoneycl(item.getDaypayment());
tfAnaysisResultTyhx.setMoney(item.getDaypayment());
tfAnaysisResultTyhxService.save(tfAnaysisResultTyhx);
}
}
}
二、总结:
- xmlns:task="http://www.springframework.org/schema/task"
- http://www.springframework.org/schema/task
- http://www.springframework.org/schema/task/spring-task-4.1.xsd
- <task:annotation-driven />
- @Service 或者Component
- @Lazy(false)
- @Scheduled(cron = "0 4 18 * * ?")
- 类中引用其他service层用属性注入 @Autowired即可
三、注意事项
【死磕jeesite源码】Jeesite配置定时任务的更多相关文章
- 死磕Spring源码之AliasRegistry
死磕Spring源码之AliasRegistry 父子关系 graph TD; AliasRegistry-->BeanDefinitionRegistry; 代码实现 作为bean定义的最顶层 ...
- 【死磕jeestie源码】类型后面三个点(String...)和数组(String[])的区别
类型后面三个点(String...),是从Java 5开始,Java语言对方法参数支持一种新写法,叫可变长度参数列表,其语法就是类型后跟...,表示此处接受的参数为0到多个Object类型的对象,或者 ...
- 死磕itchat源码--core.py
core.py文件中的Core类定义了itchat的所有接口.且,仅仅是定义了接口,全部在component包中实现重构.其用法如下表述: 缺省 源码如下: # -*- encoding: utf-8 ...
- 死磕itchat源码--config.py
itchat的配置文件,源码: import os, platform # 版本及微信的url,二维码等 VERSION = '1.3.10' BASE_URL = 'https://login.we ...
- 死磕itchat源码--content.py
content.py中定义了接受消息的类型,即,用于注册消息函数时的参数类型.源码如下: TEXT = 'Text' MAP = 'Map' CARD = 'Card' NOTE = 'Note' S ...
- 死磕itchat源码--__init__.py
itchat包中的__init__.py是该库的入口:在该文件中的源码如下: # -*- coding: utf-8 -*- from . import content from .core impo ...
- 死磕itchat源码--目录结构
阅读itchat源码时,先弄清itchat的目录结构 itchat │ config.py │ content.py │ core.py │ log.py │ returnvalues.py │ ut ...
- 死磕abstractqueuedsynchronizer源码
第一次写博客,先练练手. 1.AQS是什么? 在Lock中,用到了一个同步队列AQS,全称为AbstractQueuedSynchronizer,它是一个同步工具也是lock用来实现线程同步的核心组件 ...
- 死磕Spring源码系列
一.Spring总体架构 1.架构图 2.SpringIOC:核心容器提供 Spring 框架的基本功能.核心容器的主要组件是 BeanFactory,它是工厂模式的实现.BeanFactory 使用 ...
- Eureka详解系列(四)--Eureka Client部分的源码和配置
简介 按照原定的计划,我将分三个部分来分析 Eureka 的源码: Eureka 的配置体系(已经写完,见Eureka详解系列(三)--探索Eureka强大的配置体系): Eureka Client ...
随机推荐
- [Go] 理解 golang 中的 nil
nil是什么 相信写过Golang的程序员对下面一段代码是非常非常熟悉的了: if err != nil { // do something.... } 当出现不等于nil的时候,说明出现某些错误了, ...
- .Net Standard HttpClient封装Htt请求常用操作整理
一.常用Http操作 1.Get请求,有参数,无参数 2.Post 请求,有参数,无参数 3.文件简单下载 修改NetHelper中Post请求方法Bug:请求编码默认UTF8,字符串内存流读取后这是 ...
- (转) Java RandomAccessFile与MappedByteBuffer
RandomAccessFile RandomAccessFile是用来访问那些保存数据记录的文件的,你就可以用seek( )方法来访问记录,并进行读写了.这些记录的大小不必相同:但是其大小和位置必须 ...
- grep 多行 正则匹配
https://stackoverflow.com/questions/2686147/how-to-find-patterns-across-multiple-lines-using-grep I ...
- 如何在 Github 上发现优秀的开源项目?
之前发过一系列有关 GitHub 的文章,有同学问了,GitHub 我大概了解了,Git 也差不多会使用了,但是还是搞不清 GitHub 如何帮助我的工作,怎么提升我的工作效率? 问到点子上了,Git ...
- C++11中的右值引用及move语义编程
C++0x中加入了右值引用,和move函数.右值引用出现之前我们只能用const引用来关联临时对象(右值)(造孽的VS可以用非const引用关联临时对象,请忽略VS),所以我们不能修临时对象的内容,右 ...
- springboot本地读取resources/images没问题,上传到云服务器打成jar包就读取不到问题
//String watermarkfileName = this.getClass().getClassLoader().getResource("images/watermark.png ...
- redis 连接 docker容器 6379端口失败
redis部署在docker容器中Could not connect to Redis 容器内redis-cli是可以直接连上的,但是在另一台服务器上就不能用外网ip来连了 虽然我创建redis容器时 ...
- 在 Visual Studio 生成项目时,会发现一些 dll 并没有被复制到输出目录,导致最终程序的执行错误
发现与解决 检查了一下项目文件,发现是因为这些 dll 文件的引用其中一个叫做 嵌入互操作类型(EmbedInteropTypes)的属性被设为了 True,此时 复制本地 属性会被强制设为 Fals ...
- C#根据字符串名称 得到对应的方法
public string GetMethod(string methodName, BookingRequest bookingId) { EmailTemplate p1 = new EmailT ...