GetSchedulePlanThread.java
2.3 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
package com.bsth.service.realcontrol;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.bsth.entity.realcontrol.ScheduleRealInfo;
import com.bsth.entity.schedule.SchedulePlanInfo;
import com.bsth.repository.realcontrol.ScheduleRealInfoRepository;
import com.bsth.repository.schedule.SchedulePlanInfoRepository;
import com.bsth.util.BatchSaveUtils;
/**
*
* @ClassName: GetSchedulePlanThread
* @Description: TODO(从计划排班表抓取当天实际排班)
* @author PanZhao
* @date 2016年6月6日 下午7:42:43
*
*/
@Component
public class GetSchedulePlanThread extends Thread{
Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
SchedulePlanInfoRepository schedulePlanInfoRepository;
@Autowired
ScheduleRealInfoRepository scheduleRealInfoRepository;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd")
,sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm");
SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@Override
public void run() {
try{
String dateStr = /*sdf.format(new Date())*/"2016-06-01";
List<SchedulePlanInfo> list = schedulePlanInfoRepository.findByDate(dateStr);
logger.info("开始................." + sdf3.format(new Date(System.currentTimeMillis())));
//实际排班计划
List<ScheduleRealInfo> realList = JSONArray.parseArray(JSON.toJSONString(list), ScheduleRealInfo.class);
for(ScheduleRealInfo item : realList){
item.setDfsj(item.getFcsj());
//发车时间戳
item.setFcsjT(sdf2.parse(dateStr + " " + item.getFcsj()).getTime());
}
//scheduleRealInfoRepository.save(realList);
new BatchSaveUtils<ScheduleRealInfo>().saveListMysql(realList, ScheduleRealInfo.class);
//写入缓存
ScheduleBuffer.init(realList);
logger.info("结束................." + sdf3.format(new Date(System.currentTimeMillis())));
logger.info("获取当天实际排班计划数量:" + realList.size());
}catch(Exception e){
logger.error("",e);
}
}
}