LineConfigData.java
3.06 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
package com.bsth.data;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import com.bsth.entity.Line;
import com.bsth.entity.realcontrol.D80ReplyTemp;
import com.bsth.entity.realcontrol.LineConfig;
import com.bsth.oplog.normal.OpLogger;
import com.bsth.service.LineService;
import com.bsth.service.realcontrol.LineConfigService;
/**
*
* @ClassName: LineConfigData
* @Description: TODO(线路配置数据管理)
* @author PanZhao
* @date 2016年8月15日 下午2:50:19
*
*/
@Component
public class LineConfigData implements CommandLineRunner {
Logger logger = LoggerFactory.getLogger(this.getClass());
// 线路编码和配置
private Map<String, LineConfig> lineConfMap;
@Autowired
LineConfigService lineConfigService;
@Autowired
LineService lineService;
@Autowired
OpLogger opLog;
@Override
public void run(String... arg0) throws Exception {
lineConfMap = new HashMap<>();
Iterator<LineConfig> itr = lineConfigService.findAll().iterator();
while (itr.hasNext())
setBuffer(itr.next());
opLog.info("Line_config_data");
}
public LineConfig get(String lineCode){
return lineConfMap.get(lineCode);
}
public Collection<LineConfig> getAll(){
return lineConfMap.values();
}
public void set(LineConfig conf){
lineConfigService.save(conf);
setBuffer(conf);
}
public void setBuffer(LineConfig conf){
lineConfMap.put(conf.getLine().getLineCode(), conf);
}
/**
*
* @Title: init
* @Description: TODO(初始化配置信息)
*/
public void init(Integer lineCode) throws Exception{
LineConfig conf = new LineConfig();
//线路
Line line = lineService.findByLineCode(lineCode);
if(null == line)
throw new NullPointerException("异常的lineCode");
conf.setLine(line);
//开始运营时间
conf.setStartOpt("02:00");
//托管状态
conf.setTrust(true);
//出场时间类型
conf.setOutConfig(1);
//进场时间类型
conf.setInConfig(1);
//短语模板
conf.setPhraseTemps("");
//调度指令模板
conf.setSchDirectiveTemp("");
//80指令回复
D80ReplyTemp t50 = new D80ReplyTemp(conf, (short)0x50, "同意,回电详谈", "不同意,请回电")
,t60 = new D80ReplyTemp(conf, (short)0x60, "同意,回电详谈", "不同意,请回电")
,tA2 = new D80ReplyTemp(conf, (short)0xA2, "同意,回电详谈", "不同意,请回电")
,t70 = new D80ReplyTemp(conf, (short)0x70, "同意,回电详谈", "不同意,请回电")
,t11 = new D80ReplyTemp(conf, (short)0x11, "同意,回电详谈", "不同意,请回电");
Set<D80ReplyTemp> temps = conf.getD80Temps();
temps.add(t50);
temps.add(t60);
temps.add(tA2);
temps.add(t70);
temps.add(t11);
set(conf);
}
}