LineConfigServiceImpl.java
3.55 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
118
119
package com.bsth.service.realcontrol.impl;
import com.bsth.common.ResponseCode;
import com.bsth.data.LineConfigData;
import com.bsth.entity.realcontrol.LineConfig;
import com.bsth.repository.realcontrol.LineConfigRepository;
import com.bsth.service.impl.BaseServiceImpl;
import com.bsth.service.realcontrol.LineConfigService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class LineConfigServiceImpl extends BaseServiceImpl<LineConfig, Integer> implements LineConfigService {
@Autowired
LineConfigRepository lineConfigRepository;
@Autowired
LineConfigData lineConfigData;
Logger logger = LoggerFactory.getLogger(this.getClass());
@Override
public Map<String, Object> check(String[] codeArray) {
Map<String, Object> rs = new HashMap<>();
List<String> notArr = new ArrayList<>();
for (String lineCode : codeArray) {
if (null == lineConfigData.get(lineCode + ""))
notArr.add(lineCode);
}
if (notArr.size() > 0) {
rs.put("status", 1);
rs.put("not", notArr);
} else
rs.put("status", 0);
return rs;
}
@Override
public Integer init(String lineCode) throws Exception {
LineConfig conf = lineConfigData.get(lineCode);
if (conf == null)
lineConfigData.init(lineCode);
return 1;
}
@Override
public Map<String, Object> editStartOptTime(String time, String lineCode) {
Map<String, Object> rs = new HashMap<>();
try {
LineConfig conf = lineConfigData.get(lineCode);
conf.setStartOpt(time);
lineConfigData.set(conf);
rs.put("status", ResponseCode.SUCCESS);
rs.put("time", time);
} catch (Exception e) {
rs.put("status", ResponseCode.ERROR);
rs.put("msg", e.getMessage());
logger.error("", e);
}
return rs;
}
@Override
public Map<String, Object> editOutTimeType(String lineCode, int type) {
Map<String, Object> rs = new HashMap<>();
try {
LineConfig conf = lineConfigData.get(lineCode);
conf.setOutConfig(type);
//conf.setInConfig(type);
lineConfigData.set(conf);
rs.put("status", ResponseCode.SUCCESS);
rs.put("type", type);
} catch (Exception e) {
rs.put("status", ResponseCode.ERROR);
rs.put("msg", e.getMessage());
logger.error("", e);
}
return rs;
}
@Override
public LineConfig getByLineCode(String lineCode) {
return lineConfigData.get(lineCode);
}
@Override
public Map<String, Object> enableInParkForSource(String lineCode, int enable) {
Map<String, Object> rs = new HashMap<>();
try {
LineConfig conf = lineConfigData.get(lineCode);
conf.setInParkForSource(enable==1);
lineConfigData.set(conf);
rs.put("status", ResponseCode.SUCCESS);
rs.put("enable", enable);
} catch (Exception e) {
rs.put("status", ResponseCode.ERROR);
rs.put("msg", e.getMessage());
logger.error("", e);
}
return rs;
}
}