GetSchedulePlanThread.java
2.07 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
package com.bsth.service.realcontrol.buffer;
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 sdfHHmm = new SimpleDateFormat("HH:mm");
@Override
public void run() {
try{
String dateStr = /*sdf.format(new Date())*/"2016-06-01";
List<SchedulePlanInfo> list = schedulePlanInfoRepository.findByDate(dateStr);
//实际排班计划
List<ScheduleRealInfo> realList = JSONArray.parseArray(JSON.toJSONString(list), ScheduleRealInfo.class);
Date zdDate;
for(ScheduleRealInfo item : realList){
item.syncTime();
//计划终点时间
if(item.getBcsj() != null){
zdDate = new Date(item.getFcsjT() + (item.getBcsj() * 60 * 1000));
item.setZdsjT(zdDate.getTime());
item.setZdsj(sdfHHmm.format(zdDate));
}
}
//new BatchSaveUtils<ScheduleRealInfo>().saveList(realList, ScheduleRealInfo.class);
//写入缓存
ScheduleBuffer.init(realList);
logger.info("获取当天实际排班计划数量:" + realList.size());
}catch(Exception e){
logger.error("",e);
}
}
}