DeviceActiveSchedulerJob.java
1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package cn.com.glsx.schedulerjob.task.taskscheduler;
import cn.com.glsx.schedulerjob.task.modules.service.DeviceActiveSchedulerJobService;
import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import com.dangdang.elasticjob.lite.annotation.ElasticSimpleJob;
import com.glsx.plat.common.utils.DateUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Date;
/**
* 更新设备激活定位数据
*
* @author yangll
*/
@Slf4j
@Component
@ElasticSimpleJob(jobName = "DeviceActiveSchedulerJob", cron = "0 30 5 * * ?")
public class DeviceActiveSchedulerJob implements SimpleJob {
@Autowired
private DeviceActiveSchedulerJobService deviceActiveSchedulerJobService;
@Override
public void execute(ShardingContext shardingContext) {
log.info("Thread ID: {}, 作业分片总数: {}, " +
"当前分片项: {}.当前参数: {}," +
"作业名称: {}.作业自定义参数: {}",
Thread.currentThread().getId(),
shardingContext.getShardingTotalCount(),
shardingContext.getShardingItem(),
shardingContext.getShardingParameter(),
shardingContext.getJobName(),
shardingContext.getJobParameter()
);
String normalDate = DateUtils.formatNormal(new Date());
log.info("---------------{}-开始----------------", normalDate);
deviceActiveSchedulerJobService.updateDeviceActiveInfoEveryDay();
log.info("---------------{}-结束--------------", normalDate);
}
}