GetSchedulePlanThread.java
1.86 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
package com.bsth.vehicle;
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;
/**
*
* @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");
SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@Override
public void run() {
try{
List<SchedulePlanInfo> list = schedulePlanInfoRepository.findByDate(/*sdf.format(new Date())*/"2016-06-01");
logger.info("开始................." + sdf2.format(new Date(System.currentTimeMillis())));
//写入到实际计划表
List<ScheduleRealInfo> realList = JSONArray.parseArray(JSON.toJSONString(list), ScheduleRealInfo.class);
for(ScheduleRealInfo item : realList){
item.setDfsj(item.getFcsj());
}
scheduleRealInfoRepository.save(realList);
logger.info("结束................." + sdf2.format(new Date(System.currentTimeMillis())));
}catch(Exception e){
logger.error("",e);
}
}
}