AdminUtilsController.java
7.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
package com.bsth.controller.realcontrol;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.bsth.common.ResponseCode;
import com.bsth.data.directive.DayOfDirectives;
import com.bsth.data.directive.DirectivesPstThread;
import com.bsth.data.gpsdata_v2.cache.GeoCacheData;
import com.bsth.data.gpsdata_v2.handlers.overspeed.OverspeedProcess;
import com.bsth.data.gpsdata_v2.thread.GpsDataLoaderThread;
import com.bsth.data.msg_queue.DirectivePushQueue;
import com.bsth.data.msg_queue.WebSocketPushQueue;
import com.bsth.data.pilot80.PilotReport;
import com.bsth.data.schedule.DayOfSchedule;
import com.bsth.entity.realcontrol.ScheduleRealInfo;
import com.bsth.websocket.handler.SendUtils;
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.LoggerContext;
/**
* Created by panzhao on 2017/4/14.
*/
@RestController
@RequestMapping("adminUtils")
public class AdminUtilsController {
Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
DayOfSchedule dayOfSchedule;
@Autowired
GeoCacheData geoCacheData;
@Autowired
DayOfDirectives dayOfDirectives;
@Autowired
SendUtils sendUtils;
@Autowired
PilotReport pilotReport;
/**
* 出现重复班次的车辆
*
* @param
* @RequestMapping(value = "/schRepeat", method = RequestMethod.POST)
* public void schRepeat(@RequestParam String nbbm){
* logger.info("前端通知,车辆 " + nbbm + "出现重复班次,开始检测...");
* List<ScheduleRealInfo> list = dayOfSchedule.findByNbbm(nbbm);
* logger.info("检测前,车辆班次数量:" + list.size());
* <p>
* Map<Long, ScheduleRealInfo> map = new HashMap<>();
* for(ScheduleRealInfo sch : list){
* if(map.containsKey(sch.getId())){
* logger.info("检测到重复ID: " + sch.getId());
* }
* map.put(sch.getId(), sch);
* }
* <p>
* logger.info("检测后,车辆班次数量:" + list.size());
* if(map.values().size() > 0){
* dayOfSchedule.replaceByNbbm(nbbm, map.values());
* }
* }
*/
/* @RequestMapping(value = "/directivePushQueue")
public void directivePushQueue(){
DirectivePushQueue.start();
}*/
@RequestMapping(value = "/directiveQueueSize")
public void directiveQueueSize() {
DirectivePushQueue.size();
}
/*@RequestMapping(value = "/webSocketPushQueue")
public void webSocketPushQueue(){
WebSocketPushQueue.start();
}*/
@RequestMapping(value = "/webSocketQueueSize")
public void webSocketQueueSize() {
WebSocketPushQueue.size();
}
@RequestMapping(value = "/setHttpFlag")
public void setHttpFlag(@RequestParam int flag) {
if (flag != 0 && flag != -1)
return;
GpsDataLoaderThread.setFlag(flag);
}
@RequestMapping(value = "/updateCacheBuff")
public void updateCacheBuff() {
geoCacheData.loadData();
}
@RequestMapping(value = "/reCalcLpSch")
public void reCalcLpSch() {
dayOfSchedule._test_reCalcLpSch();
}
@RequestMapping(value = "/findSchByLpName")
public List<ScheduleRealInfo> findSchByLpName(@RequestParam String lpName) {
return dayOfSchedule.getLpScheduleMap().get(lpName);
}
@RequestMapping(value = "/findSchByNbbm")
public List<ScheduleRealInfo> findSchByNbbm(@RequestParam String nbbm) {
return dayOfSchedule.findByNbbm(nbbm);
}
@RequestMapping(value = "/removeExecPlan")
public int removeExecPlan(@RequestParam String nbbm) {
dayOfSchedule.removeExecPlan(nbbm);
return 1;
}
@RequestMapping(value = "/sch_re_calc_id_maps")
public int reCalcIdMaps() {
return dayOfSchedule.reCalcIdMaps();
}
@RequestMapping(value = "/sch_size_string")
public String schSizeString() {
return dayOfSchedule.sizeString();
}
@RequestMapping(value = "/containerSize")
public Map<String, Integer> containerSize() {
Map<String, Integer> rs = new HashMap<>();
rs.put("60_size", dayOfDirectives.all60().size());
rs.put("80_size", pilotReport.findAll().size());
rs.put("nbbm_sch_size", dayOfSchedule.findAll().size());
rs.put("lp_sch_size", dayOfSchedule.findAllByLpContainer().size());
rs.put("id_sch_size", dayOfSchedule.findAllByIdContainer().size());
rs.put("pst_sch_size", dayOfSchedule.getPstSize());
rs.put("speeds_size", OverspeedProcess.size());
return rs;
}
@RequestMapping(value = "/websocketRadioText")
public int radioText(String t, String lineCode) {
sendUtils.sendRadioText(t, lineCode);
return 0;
}
@Autowired
DirectivesPstThread directivesPstThread;
@RequestMapping(value = "/_sd_60_pst")
public void sd_60_pst() {
logger.info("手动入库指令....");
directivesPstThread.run();
}
/**
* 删除班次,删除内存中未清理掉的非当天的班次
* @createDate 2019.05.13
* @author zhangxianzhou
* @param id 线路id
* @return 被删除的班次信息
*/
@RequestMapping("/deleteSchduleBC")
public Map deleteSchduleBC(Long id) {
Map<String, Object> rs = new HashMap<>();
rs.put("status", ResponseCode.ERROR);
ScheduleRealInfo sch = null;
try {
sch = dayOfSchedule.get(id);
if (sch == null) {
rs.put("msg", "无效的id号");
return rs;
}
Date date=new Date();
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
String dateStr=sdf.format(date);
if (sch.getScheduleDateStr().equals(dateStr)){
rs.put("msg", "不能删除当日排班");
return rs;
}
//内存中删除
dayOfSchedule.deleteBC(sch);
rs.put("delete", sch);
rs.put("status", ResponseCode.SUCCESS);
} catch (Exception e) {
logger.error("", e);
rs.put("msg", e.getMessage());
sch.setDeleted(false);
}
return rs;
}
@RequestMapping("/changeLogLevel")
public Map<String, Object> changeLogLevel(@RequestParam String level) {
Map<String, Object> rs = new HashMap<>();
rs.put("errCode", 1);
LoggerContext context = (LoggerContext)LoggerFactory.getILoggerFactory();
context.getLogger("root").setLevel(Level.toLevel(level));
rs.put("errCode", 0);
rs.put("errMsg", "成功");
return rs;
}
}