Commit 1d2fd0a379d4d3cc91d2984c630b14c7edd1f728
1 parent
d2d36a99
1.特权操作,获取车辆当前执行班次
Showing
1 changed file
with
220 additions
and
215 deletions
src/main/java/com/bsth/controller/realcontrol/AdminUtilsController.java
| 1 | -package com.bsth.controller.realcontrol; | ||
| 2 | - | ||
| 3 | -import java.text.SimpleDateFormat; | ||
| 4 | -import java.util.Date; | ||
| 5 | -import java.util.HashMap; | ||
| 6 | -import java.util.List; | ||
| 7 | -import java.util.Map; | ||
| 8 | - | ||
| 9 | -import org.slf4j.Logger; | ||
| 10 | -import org.slf4j.LoggerFactory; | ||
| 11 | -import org.springframework.beans.factory.annotation.Autowired; | ||
| 12 | -import org.springframework.web.bind.annotation.RequestMapping; | ||
| 13 | -import org.springframework.web.bind.annotation.RequestParam; | ||
| 14 | -import org.springframework.web.bind.annotation.RestController; | ||
| 15 | - | ||
| 16 | -import com.bsth.common.ResponseCode; | ||
| 17 | -import com.bsth.data.directive.DayOfDirectives; | ||
| 18 | -import com.bsth.data.directive.DirectivesPstThread; | ||
| 19 | -import com.bsth.data.gpsdata_v2.cache.GeoCacheData; | ||
| 20 | -import com.bsth.data.gpsdata_v2.handlers.overspeed.OverspeedProcess; | ||
| 21 | -import com.bsth.data.gpsdata_v2.thread.GpsDataLoaderThread; | ||
| 22 | -import com.bsth.data.msg_queue.DirectivePushQueue; | ||
| 23 | -import com.bsth.data.msg_queue.WebSocketPushQueue; | ||
| 24 | -import com.bsth.data.pilot80.PilotReport; | ||
| 25 | -import com.bsth.data.schedule.DayOfSchedule; | ||
| 26 | -import com.bsth.entity.realcontrol.ScheduleRealInfo; | ||
| 27 | -import com.bsth.websocket.handler.SendUtils; | ||
| 28 | - | ||
| 29 | -import ch.qos.logback.classic.Level; | ||
| 30 | -import ch.qos.logback.classic.LoggerContext; | ||
| 31 | - | ||
| 32 | -/** | ||
| 33 | - * Created by panzhao on 2017/4/14. | ||
| 34 | - */ | ||
| 35 | -@RestController | ||
| 36 | -@RequestMapping("adminUtils") | ||
| 37 | -public class AdminUtilsController { | ||
| 38 | - | ||
| 39 | - | ||
| 40 | - Logger logger = LoggerFactory.getLogger(this.getClass()); | ||
| 41 | - | ||
| 42 | - @Autowired | ||
| 43 | - DayOfSchedule dayOfSchedule; | ||
| 44 | - | ||
| 45 | - @Autowired | ||
| 46 | - GeoCacheData geoCacheData; | ||
| 47 | - | ||
| 48 | - @Autowired | ||
| 49 | - DayOfDirectives dayOfDirectives; | ||
| 50 | - | ||
| 51 | - @Autowired | ||
| 52 | - SendUtils sendUtils; | ||
| 53 | - | ||
| 54 | - @Autowired | ||
| 55 | - PilotReport pilotReport; | ||
| 56 | - | ||
| 57 | - /** | ||
| 58 | - * 出现重复班次的车辆 | ||
| 59 | - * | ||
| 60 | - * @param | ||
| 61 | - * @RequestMapping(value = "/schRepeat", method = RequestMethod.POST) | ||
| 62 | - * public void schRepeat(@RequestParam String nbbm){ | ||
| 63 | - * logger.info("前端通知,车辆 " + nbbm + "出现重复班次,开始检测..."); | ||
| 64 | - * List<ScheduleRealInfo> list = dayOfSchedule.findByNbbm(nbbm); | ||
| 65 | - * logger.info("检测前,车辆班次数量:" + list.size()); | ||
| 66 | - * <p> | ||
| 67 | - * Map<Long, ScheduleRealInfo> map = new HashMap<>(); | ||
| 68 | - * for(ScheduleRealInfo sch : list){ | ||
| 69 | - * if(map.containsKey(sch.getId())){ | ||
| 70 | - * logger.info("检测到重复ID: " + sch.getId()); | ||
| 71 | - * } | ||
| 72 | - * map.put(sch.getId(), sch); | ||
| 73 | - * } | ||
| 74 | - * <p> | ||
| 75 | - * logger.info("检测后,车辆班次数量:" + list.size()); | ||
| 76 | - * if(map.values().size() > 0){ | ||
| 77 | - * dayOfSchedule.replaceByNbbm(nbbm, map.values()); | ||
| 78 | - * } | ||
| 79 | - * } | ||
| 80 | - */ | ||
| 81 | - | ||
| 82 | -/* @RequestMapping(value = "/directivePushQueue") | ||
| 83 | - public void directivePushQueue(){ | ||
| 84 | - DirectivePushQueue.start(); | ||
| 85 | - }*/ | ||
| 86 | - @RequestMapping(value = "/directiveQueueSize") | ||
| 87 | - public void directiveQueueSize() { | ||
| 88 | - DirectivePushQueue.size(); | ||
| 89 | - } | ||
| 90 | - | ||
| 91 | - /*@RequestMapping(value = "/webSocketPushQueue") | ||
| 92 | - public void webSocketPushQueue(){ | ||
| 93 | - WebSocketPushQueue.start(); | ||
| 94 | - }*/ | ||
| 95 | - | ||
| 96 | - @RequestMapping(value = "/webSocketQueueSize") | ||
| 97 | - public void webSocketQueueSize() { | ||
| 98 | - WebSocketPushQueue.size(); | ||
| 99 | - } | ||
| 100 | - | ||
| 101 | - @RequestMapping(value = "/setHttpFlag") | ||
| 102 | - public void setHttpFlag(@RequestParam int flag) { | ||
| 103 | - if (flag != 0 && flag != -1) | ||
| 104 | - return; | ||
| 105 | - GpsDataLoaderThread.setFlag(flag); | ||
| 106 | - } | ||
| 107 | - | ||
| 108 | - @RequestMapping(value = "/updateCacheBuff") | ||
| 109 | - public void updateCacheBuff() { | ||
| 110 | - geoCacheData.loadData(); | ||
| 111 | - } | ||
| 112 | - | ||
| 113 | - @RequestMapping(value = "/reCalcLpSch") | ||
| 114 | - public void reCalcLpSch() { | ||
| 115 | - dayOfSchedule._test_reCalcLpSch(); | ||
| 116 | - } | ||
| 117 | - | ||
| 118 | - @RequestMapping(value = "/findSchByLpName") | ||
| 119 | - public List<ScheduleRealInfo> findSchByLpName(@RequestParam String lpName) { | ||
| 120 | - return dayOfSchedule.getLpScheduleMap().get(lpName); | ||
| 121 | - } | ||
| 122 | - | ||
| 123 | - @RequestMapping(value = "/findSchByNbbm") | ||
| 124 | - public List<ScheduleRealInfo> findSchByNbbm(@RequestParam String nbbm) { | ||
| 125 | - return dayOfSchedule.findByNbbm(nbbm); | ||
| 126 | - } | ||
| 127 | - | ||
| 128 | - @RequestMapping(value = "/removeExecPlan") | ||
| 129 | - public int removeExecPlan(@RequestParam String nbbm) { | ||
| 130 | - dayOfSchedule.removeExecPlan(nbbm); | ||
| 131 | - return 1; | ||
| 132 | - } | ||
| 133 | - | ||
| 134 | - @RequestMapping(value = "/sch_re_calc_id_maps") | ||
| 135 | - public int reCalcIdMaps() { | ||
| 136 | - return dayOfSchedule.reCalcIdMaps(); | ||
| 137 | - } | ||
| 138 | - | ||
| 139 | - @RequestMapping(value = "/sch_size_string") | ||
| 140 | - public String schSizeString() { | ||
| 141 | - return dayOfSchedule.sizeString(); | ||
| 142 | - } | ||
| 143 | - | ||
| 144 | - @RequestMapping(value = "/containerSize") | ||
| 145 | - public Map<String, Integer> containerSize() { | ||
| 146 | - Map<String, Integer> rs = new HashMap<>(); | ||
| 147 | - rs.put("60_size", dayOfDirectives.all60().size()); | ||
| 148 | - rs.put("80_size", pilotReport.findAll().size()); | ||
| 149 | - rs.put("nbbm_sch_size", dayOfSchedule.findAll().size()); | ||
| 150 | - rs.put("lp_sch_size", dayOfSchedule.findAllByLpContainer().size()); | ||
| 151 | - rs.put("id_sch_size", dayOfSchedule.findAllByIdContainer().size()); | ||
| 152 | - rs.put("pst_sch_size", dayOfSchedule.getPstSize()); | ||
| 153 | - rs.put("speeds_size", OverspeedProcess.size()); | ||
| 154 | - return rs; | ||
| 155 | - } | ||
| 156 | - | ||
| 157 | - @RequestMapping(value = "/websocketRadioText") | ||
| 158 | - public int radioText(String t, String lineCode) { | ||
| 159 | - sendUtils.sendRadioText(t, lineCode); | ||
| 160 | - return 0; | ||
| 161 | - } | ||
| 162 | - | ||
| 163 | - @Autowired | ||
| 164 | - DirectivesPstThread directivesPstThread; | ||
| 165 | - | ||
| 166 | - @RequestMapping(value = "/_sd_60_pst") | ||
| 167 | - public void sd_60_pst() { | ||
| 168 | - logger.info("手动入库指令...."); | ||
| 169 | - directivesPstThread.run(); | ||
| 170 | - } | ||
| 171 | - | ||
| 172 | - /** | ||
| 173 | - * 删除班次,删除内存中未清理掉的非当天的班次 | ||
| 174 | - * @createDate 2019.05.13 | ||
| 175 | - * @author zhangxianzhou | ||
| 176 | - * @param id 线路id | ||
| 177 | - * @return 被删除的班次信息 | ||
| 178 | - */ | ||
| 179 | - @RequestMapping("/deleteSchduleBC") | ||
| 180 | - public Map<String, Object> deleteSchduleBC(Long id) { | ||
| 181 | - Map<String, Object> rs = new HashMap<>(); | ||
| 182 | - rs.put("status", ResponseCode.ERROR); | ||
| 183 | - ScheduleRealInfo sch = null; | ||
| 184 | - try { | ||
| 185 | - sch = dayOfSchedule.get(id); | ||
| 186 | - if (sch == null) { | ||
| 187 | - rs.put("msg", "无效的id号"); | ||
| 188 | - return rs; | ||
| 189 | - } | ||
| 190 | - | ||
| 191 | - //内存中删除 | ||
| 192 | - dayOfSchedule.deleteBC(sch); | ||
| 193 | - rs.put("delete", sch); | ||
| 194 | - rs.put("status", ResponseCode.SUCCESS); | ||
| 195 | - | ||
| 196 | - } catch (Exception e) { | ||
| 197 | - logger.error("", e); | ||
| 198 | - rs.put("msg", e.getMessage()); | ||
| 199 | - sch.setDeleted(false); | ||
| 200 | - } | ||
| 201 | - | ||
| 202 | - return rs; | ||
| 203 | - } | ||
| 204 | - | ||
| 205 | - @RequestMapping("/changeLogLevel") | ||
| 206 | - public Map<String, Object> changeLogLevel(@RequestParam String level) { | ||
| 207 | - Map<String, Object> rs = new HashMap<>(); | ||
| 208 | - rs.put("errCode", 1); | ||
| 209 | - LoggerContext context = (LoggerContext)LoggerFactory.getILoggerFactory(); | ||
| 210 | - context.getLogger("root").setLevel(Level.toLevel(level)); | ||
| 211 | - rs.put("errCode", 0); | ||
| 212 | - rs.put("errMsg", "成功"); | ||
| 213 | - | ||
| 214 | - return rs; | ||
| 215 | - } | 1 | +package com.bsth.controller.realcontrol; |
| 2 | + | ||
| 3 | +import java.text.SimpleDateFormat; | ||
| 4 | +import java.util.Date; | ||
| 5 | +import java.util.HashMap; | ||
| 6 | +import java.util.List; | ||
| 7 | +import java.util.Map; | ||
| 8 | + | ||
| 9 | +import org.slf4j.Logger; | ||
| 10 | +import org.slf4j.LoggerFactory; | ||
| 11 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 12 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
| 13 | +import org.springframework.web.bind.annotation.RequestParam; | ||
| 14 | +import org.springframework.web.bind.annotation.RestController; | ||
| 15 | + | ||
| 16 | +import com.bsth.common.ResponseCode; | ||
| 17 | +import com.bsth.data.directive.DayOfDirectives; | ||
| 18 | +import com.bsth.data.directive.DirectivesPstThread; | ||
| 19 | +import com.bsth.data.gpsdata_v2.cache.GeoCacheData; | ||
| 20 | +import com.bsth.data.gpsdata_v2.handlers.overspeed.OverspeedProcess; | ||
| 21 | +import com.bsth.data.gpsdata_v2.thread.GpsDataLoaderThread; | ||
| 22 | +import com.bsth.data.msg_queue.DirectivePushQueue; | ||
| 23 | +import com.bsth.data.msg_queue.WebSocketPushQueue; | ||
| 24 | +import com.bsth.data.pilot80.PilotReport; | ||
| 25 | +import com.bsth.data.schedule.DayOfSchedule; | ||
| 26 | +import com.bsth.entity.realcontrol.ScheduleRealInfo; | ||
| 27 | +import com.bsth.websocket.handler.SendUtils; | ||
| 28 | + | ||
| 29 | +import ch.qos.logback.classic.Level; | ||
| 30 | +import ch.qos.logback.classic.LoggerContext; | ||
| 31 | + | ||
| 32 | +/** | ||
| 33 | + * Created by panzhao on 2017/4/14. | ||
| 34 | + */ | ||
| 35 | +@RestController | ||
| 36 | +@RequestMapping("adminUtils") | ||
| 37 | +public class AdminUtilsController { | ||
| 38 | + | ||
| 39 | + | ||
| 40 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | ||
| 41 | + | ||
| 42 | + @Autowired | ||
| 43 | + DayOfSchedule dayOfSchedule; | ||
| 44 | + | ||
| 45 | + @Autowired | ||
| 46 | + GeoCacheData geoCacheData; | ||
| 47 | + | ||
| 48 | + @Autowired | ||
| 49 | + DayOfDirectives dayOfDirectives; | ||
| 50 | + | ||
| 51 | + @Autowired | ||
| 52 | + SendUtils sendUtils; | ||
| 53 | + | ||
| 54 | + @Autowired | ||
| 55 | + PilotReport pilotReport; | ||
| 56 | + | ||
| 57 | + /** | ||
| 58 | + * 出现重复班次的车辆 | ||
| 59 | + * | ||
| 60 | + * @param | ||
| 61 | + * @RequestMapping(value = "/schRepeat", method = RequestMethod.POST) | ||
| 62 | + * public void schRepeat(@RequestParam String nbbm){ | ||
| 63 | + * logger.info("前端通知,车辆 " + nbbm + "出现重复班次,开始检测..."); | ||
| 64 | + * List<ScheduleRealInfo> list = dayOfSchedule.findByNbbm(nbbm); | ||
| 65 | + * logger.info("检测前,车辆班次数量:" + list.size()); | ||
| 66 | + * <p> | ||
| 67 | + * Map<Long, ScheduleRealInfo> map = new HashMap<>(); | ||
| 68 | + * for(ScheduleRealInfo sch : list){ | ||
| 69 | + * if(map.containsKey(sch.getId())){ | ||
| 70 | + * logger.info("检测到重复ID: " + sch.getId()); | ||
| 71 | + * } | ||
| 72 | + * map.put(sch.getId(), sch); | ||
| 73 | + * } | ||
| 74 | + * <p> | ||
| 75 | + * logger.info("检测后,车辆班次数量:" + list.size()); | ||
| 76 | + * if(map.values().size() > 0){ | ||
| 77 | + * dayOfSchedule.replaceByNbbm(nbbm, map.values()); | ||
| 78 | + * } | ||
| 79 | + * } | ||
| 80 | + */ | ||
| 81 | + | ||
| 82 | +/* @RequestMapping(value = "/directivePushQueue") | ||
| 83 | + public void directivePushQueue(){ | ||
| 84 | + DirectivePushQueue.start(); | ||
| 85 | + }*/ | ||
| 86 | + @RequestMapping(value = "/directiveQueueSize") | ||
| 87 | + public void directiveQueueSize() { | ||
| 88 | + DirectivePushQueue.size(); | ||
| 89 | + } | ||
| 90 | + | ||
| 91 | + /*@RequestMapping(value = "/webSocketPushQueue") | ||
| 92 | + public void webSocketPushQueue(){ | ||
| 93 | + WebSocketPushQueue.start(); | ||
| 94 | + }*/ | ||
| 95 | + | ||
| 96 | + @RequestMapping(value = "/webSocketQueueSize") | ||
| 97 | + public void webSocketQueueSize() { | ||
| 98 | + WebSocketPushQueue.size(); | ||
| 99 | + } | ||
| 100 | + | ||
| 101 | + @RequestMapping(value = "/setHttpFlag") | ||
| 102 | + public void setHttpFlag(@RequestParam int flag) { | ||
| 103 | + if (flag != 0 && flag != -1) | ||
| 104 | + return; | ||
| 105 | + GpsDataLoaderThread.setFlag(flag); | ||
| 106 | + } | ||
| 107 | + | ||
| 108 | + @RequestMapping(value = "/updateCacheBuff") | ||
| 109 | + public void updateCacheBuff() { | ||
| 110 | + geoCacheData.loadData(); | ||
| 111 | + } | ||
| 112 | + | ||
| 113 | + @RequestMapping(value = "/reCalcLpSch") | ||
| 114 | + public void reCalcLpSch() { | ||
| 115 | + dayOfSchedule._test_reCalcLpSch(); | ||
| 116 | + } | ||
| 117 | + | ||
| 118 | + @RequestMapping(value = "/findSchByLpName") | ||
| 119 | + public List<ScheduleRealInfo> findSchByLpName(@RequestParam String lpName) { | ||
| 120 | + return dayOfSchedule.getLpScheduleMap().get(lpName); | ||
| 121 | + } | ||
| 122 | + | ||
| 123 | + @RequestMapping(value = "/findSchByNbbm") | ||
| 124 | + public List<ScheduleRealInfo> findSchByNbbm(@RequestParam String nbbm) { | ||
| 125 | + return dayOfSchedule.findByNbbm(nbbm); | ||
| 126 | + } | ||
| 127 | + | ||
| 128 | + @RequestMapping(value = "/executeCurr") | ||
| 129 | + public ScheduleRealInfo executeCurr(@RequestParam String nbbm) { | ||
| 130 | + return dayOfSchedule.executeCurr(nbbm); | ||
| 131 | + }; | ||
| 132 | + | ||
| 133 | + @RequestMapping(value = "/removeExecPlan") | ||
| 134 | + public int removeExecPlan(@RequestParam String nbbm) { | ||
| 135 | + dayOfSchedule.removeExecPlan(nbbm); | ||
| 136 | + return 1; | ||
| 137 | + } | ||
| 138 | + | ||
| 139 | + @RequestMapping(value = "/sch_re_calc_id_maps") | ||
| 140 | + public int reCalcIdMaps() { | ||
| 141 | + return dayOfSchedule.reCalcIdMaps(); | ||
| 142 | + } | ||
| 143 | + | ||
| 144 | + @RequestMapping(value = "/sch_size_string") | ||
| 145 | + public String schSizeString() { | ||
| 146 | + return dayOfSchedule.sizeString(); | ||
| 147 | + } | ||
| 148 | + | ||
| 149 | + @RequestMapping(value = "/containerSize") | ||
| 150 | + public Map<String, Integer> containerSize() { | ||
| 151 | + Map<String, Integer> rs = new HashMap<>(); | ||
| 152 | + rs.put("60_size", dayOfDirectives.all60().size()); | ||
| 153 | + rs.put("80_size", pilotReport.findAll().size()); | ||
| 154 | + rs.put("nbbm_sch_size", dayOfSchedule.findAll().size()); | ||
| 155 | + rs.put("lp_sch_size", dayOfSchedule.findAllByLpContainer().size()); | ||
| 156 | + rs.put("id_sch_size", dayOfSchedule.findAllByIdContainer().size()); | ||
| 157 | + rs.put("pst_sch_size", dayOfSchedule.getPstSize()); | ||
| 158 | + rs.put("speeds_size", OverspeedProcess.size()); | ||
| 159 | + return rs; | ||
| 160 | + } | ||
| 161 | + | ||
| 162 | + @RequestMapping(value = "/websocketRadioText") | ||
| 163 | + public int radioText(String t, String lineCode) { | ||
| 164 | + sendUtils.sendRadioText(t, lineCode); | ||
| 165 | + return 0; | ||
| 166 | + } | ||
| 167 | + | ||
| 168 | + @Autowired | ||
| 169 | + DirectivesPstThread directivesPstThread; | ||
| 170 | + | ||
| 171 | + @RequestMapping(value = "/_sd_60_pst") | ||
| 172 | + public void sd_60_pst() { | ||
| 173 | + logger.info("手动入库指令...."); | ||
| 174 | + directivesPstThread.run(); | ||
| 175 | + } | ||
| 176 | + | ||
| 177 | + /** | ||
| 178 | + * 删除班次,删除内存中未清理掉的非当天的班次 | ||
| 179 | + * @createDate 2019.05.13 | ||
| 180 | + * @author zhangxianzhou | ||
| 181 | + * @param id 线路id | ||
| 182 | + * @return 被删除的班次信息 | ||
| 183 | + */ | ||
| 184 | + @RequestMapping("/deleteSchduleBC") | ||
| 185 | + public Map<String, Object> deleteSchduleBC(Long id) { | ||
| 186 | + Map<String, Object> rs = new HashMap<>(); | ||
| 187 | + rs.put("status", ResponseCode.ERROR); | ||
| 188 | + ScheduleRealInfo sch = null; | ||
| 189 | + try { | ||
| 190 | + sch = dayOfSchedule.get(id); | ||
| 191 | + if (sch == null) { | ||
| 192 | + rs.put("msg", "无效的id号"); | ||
| 193 | + return rs; | ||
| 194 | + } | ||
| 195 | + | ||
| 196 | + //内存中删除 | ||
| 197 | + dayOfSchedule.deleteBC(sch); | ||
| 198 | + rs.put("delete", sch); | ||
| 199 | + rs.put("status", ResponseCode.SUCCESS); | ||
| 200 | + | ||
| 201 | + } catch (Exception e) { | ||
| 202 | + logger.error("", e); | ||
| 203 | + rs.put("msg", e.getMessage()); | ||
| 204 | + sch.setDeleted(false); | ||
| 205 | + } | ||
| 206 | + | ||
| 207 | + return rs; | ||
| 208 | + } | ||
| 209 | + | ||
| 210 | + @RequestMapping("/changeLogLevel") | ||
| 211 | + public Map<String, Object> changeLogLevel(@RequestParam String level) { | ||
| 212 | + Map<String, Object> rs = new HashMap<>(); | ||
| 213 | + rs.put("errCode", 1); | ||
| 214 | + LoggerContext context = (LoggerContext)LoggerFactory.getILoggerFactory(); | ||
| 215 | + context.getLogger("root").setLevel(Level.toLevel(level)); | ||
| 216 | + rs.put("errCode", 0); | ||
| 217 | + rs.put("errMsg", "成功"); | ||
| 218 | + | ||
| 219 | + return rs; | ||
| 220 | + } | ||
| 216 | } | 221 | } |
| 217 | \ No newline at end of file | 222 | \ No newline at end of file |