ParkingLotHeatMapDayJob.java
3.17 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package com.zteits.park.job;
import org.apache.commons.lang3.StringUtils;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import com.zteits.park.dao.ParkinglotHeatmapDayDao;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
/**
* 企业云平台-->停车热力分布图-->按照天.<br/>
*
* Copyright: Copyright (c) 2017 zteits
*
* @ClassName: ParkingLotHeatMapHourJob.java
* @Description:
* @version: v1.0.0
* @author: wangfs
* @date: 2017年7月10日 下午5:24:36
* Modification History:
* Date Author Version Description
*---------------------------------------------------------*
* 2017年7月10日 wangfs v1.0.0 创建
*/
@Component
public class ParkingLotHeatMapDayJob{
private static final Logger logger = LoggerFactory.getLogger(ParkingLotHeatMapDayJob.class);
@Autowired
private ParkinglotHeatmapDayDao parkinglotHeatmapDayDao;
/**
* 企业云平台-->停车热力分布图-->按照天.<br/>
* 描述:1.每天 2点 执行, 0 0 2 * * ? *
*
*
*/
@XxlJob("ParkingLotHeatMapDayJob")
public ReturnT<String> execute(String... params) throws Exception {
String param = XxlJobHelper.getJobParam();
if (StringUtils.isNotEmpty(param) && params == null) {
params = param.split(",");
}
SimpleDateFormat formart = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
SimpleDateFormat formartDate = new SimpleDateFormat("yyyy-MM-dd");
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
cal.add(Calendar.DAY_OF_MONTH, -1);
Integer insertCount = 0 ;
this.log("--begin---企业云平台-->停车热力分布图-->按照天..."+formart.format(new Date()));
try{
this.log("插入数据DayTime= "+formartDate.format(cal.getTime()));
Date heatmapTime = formartDate.parse(formartDate.format(cal.getTime()));
insertCount = this.executeparkinglotHeatmapDay(heatmapTime);
}catch (Exception e) {
if (e instanceof InterruptedException) {
throw e;
}
logger.warn("{}", e);
}
this.log("--end---企业云平台-->停车热力分布图-->按照天..."+formart.format(new Date()));
return insertCount >0 ? ReturnT.SUCCESS :ReturnT.FAIL;
}
private Integer executeparkinglotHeatmapDay(Date heatmapTime){
SimpleDateFormat formartDate = new SimpleDateFormat("yyyy-MM-dd");
this.log("begin删除数据,入参="+formartDate.format(heatmapTime));
Integer deleteCount = parkinglotHeatmapDayDao.deleteParkinglotHeatmapDayByheatmapTime(heatmapTime);
this.log("end删除数据,结果,删除条数="+deleteCount+" 条。");
this.log("begin插入数据,入参="+formartDate.format(heatmapTime));
Integer insertCount = parkinglotHeatmapDayDao.insertParkinglotHeatmapDayList(heatmapTime);
this.log("end插入数据,结果,插入条数="+insertCount+" 条。");
return insertCount;
}
private void log(String msg){
XxlJobHelper.log(msg);
logger.info(msg);
}
}