Commit 47fed13e2442a62c46ecded0312984a00294b24e
1 parent
8aefd9d3
优化轨迹回放
Showing
23 changed files
with
407 additions
and
170 deletions
src/main/java/com/bsth/StartCommand.java
| @@ -21,6 +21,8 @@ import org.springframework.beans.factory.annotation.Autowired; | @@ -21,6 +21,8 @@ import org.springframework.beans.factory.annotation.Autowired; | ||
| 21 | import org.springframework.boot.CommandLineRunner; | 21 | import org.springframework.boot.CommandLineRunner; |
| 22 | import org.springframework.stereotype.Component; | 22 | import org.springframework.stereotype.Component; |
| 23 | 23 | ||
| 24 | +import java.util.Timer; | ||
| 25 | +import java.util.TimerTask; | ||
| 24 | import java.util.concurrent.Executors; | 26 | import java.util.concurrent.Executors; |
| 25 | import java.util.concurrent.ScheduledExecutorService; | 27 | import java.util.concurrent.ScheduledExecutorService; |
| 26 | import java.util.concurrent.TimeUnit; | 28 | import java.util.concurrent.TimeUnit; |
| @@ -133,22 +135,26 @@ public class StartCommand implements CommandLineRunner{ | @@ -133,22 +135,26 @@ public class StartCommand implements CommandLineRunner{ | ||
| 133 | */ | 135 | */ |
| 134 | scheduler.scheduleWithFixedDelay(firstScheduleIssuedThread, 60 , 60 * 2, TimeUnit.SECONDS); | 136 | scheduler.scheduleWithFixedDelay(firstScheduleIssuedThread, 60 , 60 * 2, TimeUnit.SECONDS); |
| 135 | 137 | ||
| 136 | - //延迟一会 | 138 | + |
| 137 | /* new Timer().schedule(new TimerTask() { | 139 | /* new Timer().schedule(new TimerTask() { |
| 138 | 140 | ||
| 139 | @Override | 141 | @Override |
| 140 | public void run() { | 142 | public void run() { |
| 141 | - //临时全量刷车辆线路 | ||
| 142 | List<CarConfigInfo> ccis = carConfigInfoRepository.findAll(); | 143 | List<CarConfigInfo> ccis = carConfigInfoRepository.findAll(); |
| 143 | Cars car; | 144 | Cars car; |
| 144 | Line line; | 145 | Line line; |
| 145 | String lineCode; | 146 | String lineCode; |
| 146 | - int code; | 147 | + System.out.println("ccis size: " + ccis.size()); |
| 147 | for(CarConfigInfo cci : ccis){ | 148 | for(CarConfigInfo cci : ccis){ |
| 148 | car = cci.getCl(); | 149 | car = cci.getCl(); |
| 149 | line = cci.getXl(); | 150 | line = cci.getXl(); |
| 150 | lineCode = line.getLineCode(); | 151 | lineCode = line.getLineCode(); |
| 151 | - System.out.println("车辆:" + car.getInsideCode() + "切换线路:" + line.getLineCode()); | 152 | + |
| 153 | + String data = directiveService.createDeviceRefreshData(CommonMapped.vehicDeviceBiMap.inverse().get(car.getInsideCode()) | ||
| 154 | + , Integer.parseInt(lineCode)); | ||
| 155 | + System.out.println(data); | ||
| 156 | + int code = HttpUtils.postJson(data); | ||
| 157 | + System.out.println("车辆:" + car.getInsideCode() + "刷新线路:" + line.getLineCode()); | ||
| 152 | code = directiveService.lineChange(car.getInsideCode(), Integer.parseInt(lineCode)); | 158 | code = directiveService.lineChange(car.getInsideCode(), Integer.parseInt(lineCode)); |
| 153 | //directiveService.send60Phrase(car.getInsideCode(), ""); | 159 | //directiveService.send60Phrase(car.getInsideCode(), ""); |
| 154 | System.out.println("返回值:" + code); | 160 | System.out.println("返回值:" + code); |
src/main/java/com/bsth/Test.java
0 → 100644
| 1 | +//package com.bsth; | ||
| 2 | +// | ||
| 3 | +//import java.io.ByteArrayOutputStream; | ||
| 4 | +//import java.io.IOException; | ||
| 5 | +//import java.io.InputStream; | ||
| 6 | +//import java.io.OutputStream; | ||
| 7 | +//import java.net.HttpURLConnection; | ||
| 8 | +//import java.net.URL; | ||
| 9 | +//import java.util.HashMap; | ||
| 10 | +//import java.util.Map; | ||
| 11 | +// | ||
| 12 | +//import org.apache.commons.io.IOUtils; | ||
| 13 | +// | ||
| 14 | +//import com.fasterxml.jackson.databind.ObjectMapper; | ||
| 15 | +// | ||
| 16 | +//public class Test { | ||
| 17 | +// | ||
| 18 | +// public static void main(String[] args) { | ||
| 19 | +// Map<String, Object> map = new HashMap<>(); | ||
| 20 | +// map.put("timestamp", 1469764939000L); | ||
| 21 | +// map.put("operCode", 128); | ||
| 22 | +// map.put("deviceId", "66ML0007"); | ||
| 23 | +// | ||
| 24 | +// Map<String , Object> dataMap = new HashMap<>(); | ||
| 25 | +// dataMap.put("requestCode", 161); | ||
| 26 | +// dataMap.put("lineId", 1025); | ||
| 27 | +// dataMap.put("operCode2", 38); | ||
| 28 | +// | ||
| 29 | +// map.put("data", dataMap); | ||
| 30 | +// request(map, "http://192.168.168.171:9088/control/upstream"); | ||
| 31 | +// | ||
| 32 | +// } | ||
| 33 | +// | ||
| 34 | +// private static Map<String, Object> request(Map<String, Object> map, String url) { | ||
| 35 | +// InputStream in = null; | ||
| 36 | +// OutputStream out = null; | ||
| 37 | +// HttpURLConnection con = null; | ||
| 38 | +// try { | ||
| 39 | +// con = (HttpURLConnection)new URL(url).openConnection(); | ||
| 40 | +// con.setRequestMethod("POST"); | ||
| 41 | +// con.setRequestProperty("keep-alive", "true"); | ||
| 42 | +// con.setRequestProperty("accept", "*/*"); | ||
| 43 | +// con.setDoInput(true); | ||
| 44 | +// con.setDoOutput(true); | ||
| 45 | +// con.setReadTimeout(2500); | ||
| 46 | +// con.setConnectTimeout(2500); | ||
| 47 | +// out = con.getOutputStream(); | ||
| 48 | +// out.write("json=".getBytes()); | ||
| 49 | +// out.write(new ObjectMapper().writeValueAsBytes(map)); | ||
| 50 | +// out.flush(); | ||
| 51 | +// System.out.println("con.getResponseCode(): " + con.getResponseCode()); | ||
| 52 | +// if (con.getResponseCode() == 200) { | ||
| 53 | +// in = con.getInputStream(); | ||
| 54 | +// ByteArrayOutputStream bout = new ByteArrayOutputStream(); | ||
| 55 | +// IOUtils.copy(in, bout); bout.close(); | ||
| 56 | +// System.out.println("Message:" + new String(bout.toByteArray())); | ||
| 57 | +// return new ObjectMapper().readValue(bout.toByteArray(), Map.class); | ||
| 58 | +// } | ||
| 59 | +// } catch (IOException e) { | ||
| 60 | +// e.printStackTrace(); | ||
| 61 | +// } finally { | ||
| 62 | +// con.disconnect(); | ||
| 63 | +// try { | ||
| 64 | +// if (in != null) in.close(); | ||
| 65 | +// if (out != null) out.close(); | ||
| 66 | +// } catch (IOException e) { | ||
| 67 | +// e.printStackTrace(); | ||
| 68 | +// } | ||
| 69 | +// } | ||
| 70 | +// return null; | ||
| 71 | +// } | ||
| 72 | +//} |
src/main/java/com/bsth/controller/realcontrol/ScheduleRealInfoController.java
| @@ -255,8 +255,8 @@ public class ScheduleRealInfoController extends BaseController<ScheduleRealInfo, | @@ -255,8 +255,8 @@ public class ScheduleRealInfoController extends BaseController<ScheduleRealInfo, | ||
| 255 | * @throws | 255 | * @throws |
| 256 | */ | 256 | */ |
| 257 | @RequestMapping(value = "/findRouteByLine") | 257 | @RequestMapping(value = "/findRouteByLine") |
| 258 | - public Map<String, Object> findRouteByLine(@RequestParam Integer lineId){ | ||
| 259 | - return scheduleRealInfoService.findRouteByLine(lineId); | 258 | + public Map<String, Object> findRouteByLine(@RequestParam Integer lineCode){ |
| 259 | + return scheduleRealInfoService.findRouteByLine(lineCode); | ||
| 260 | } | 260 | } |
| 261 | 261 | ||
| 262 | @RequestMapping(value = "/test/getSch") | 262 | @RequestMapping(value = "/test/getSch") |
src/main/java/com/bsth/filter/AccessLogFilter.java
| @@ -38,7 +38,7 @@ public class AccessLogFilter extends BaseFilter { | @@ -38,7 +38,7 @@ public class AccessLogFilter extends BaseFilter { | ||
| 38 | HttpServletResponse response, FilterChain chain) | 38 | HttpServletResponse response, FilterChain chain) |
| 39 | throws IOException, ServletException { | 39 | throws IOException, ServletException { |
| 40 | 40 | ||
| 41 | - String username = SecurityUtils.getCurrentUser().getName(); //等集成shiro之后再取 | 41 | + String username = /*SecurityUtils.getCurrentUser().getName()*/"test"; //等集成shiro之后再取 |
| 42 | String jsessionId = request.getRequestedSessionId(); | 42 | String jsessionId = request.getRequestedSessionId(); |
| 43 | String ip = IpUtils.getIpAddr(request); | 43 | String ip = IpUtils.getIpAddr(request); |
| 44 | String userAgent = request.getHeader("User-Agent"); | 44 | String userAgent = request.getHeader("User-Agent"); |
src/main/java/com/bsth/service/realcontrol/ScheduleRealInfoService.java
| @@ -80,7 +80,7 @@ public interface ScheduleRealInfoService extends BaseService<ScheduleRealInfo, L | @@ -80,7 +80,7 @@ public interface ScheduleRealInfoService extends BaseService<ScheduleRealInfo, L | ||
| 80 | 80 | ||
| 81 | Map<String, Object> outgoAdjustAll(String params); | 81 | Map<String, Object> outgoAdjustAll(String params); |
| 82 | 82 | ||
| 83 | - Map<String, Object> findRouteByLine(Integer lineId); | 83 | + Map<String, Object> findRouteByLine(Integer lineCode); |
| 84 | 84 | ||
| 85 | List<Map<String,String>> findLine(String line); | 85 | List<Map<String,String>> findLine(String line); |
| 86 | 86 |
src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
| @@ -757,9 +757,10 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf | @@ -757,9 +757,10 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf | ||
| 757 | } | 757 | } |
| 758 | 758 | ||
| 759 | @Override | 759 | @Override |
| 760 | - public Map<String, Object> findRouteByLine(Integer lineId) { | 760 | + public Map<String, Object> findRouteByLine(Integer lineCode) { |
| 761 | Map<String, Object> map = new HashMap<>(); | 761 | Map<String, Object> map = new HashMap<>(); |
| 762 | //上行 | 762 | //上行 |
| 763 | + Integer lineId = CommonMapped.lineIdToCode.inverse().get(lineCode); | ||
| 763 | map.put("line.id_eq", lineId); | 764 | map.put("line.id_eq", lineId); |
| 764 | map.put("directions_eq", 0); | 765 | map.put("directions_eq", 0); |
| 765 | List<Map<String, Object>> upList = sectionRouteService.getSectionRoute(map); | 766 | List<Map<String, Object>> upList = sectionRouteService.getSectionRoute(map); |
src/main/java/com/bsth/vehicle/UpstreamEntrance.java
| @@ -32,7 +32,7 @@ public class UpstreamEntrance { | @@ -32,7 +32,7 @@ public class UpstreamEntrance { | ||
| 32 | DirectiveBuffer directiveBuffer; | 32 | DirectiveBuffer directiveBuffer; |
| 33 | 33 | ||
| 34 | @RequestMapping(value = "/upstream", method = RequestMethod.POST) | 34 | @RequestMapping(value = "/upstream", method = RequestMethod.POST) |
| 35 | - public int main(@RequestParam String json) { | 35 | + public String main(@RequestParam String json) { |
| 36 | logger.info("upstream: " + json); | 36 | logger.info("upstream: " + json); |
| 37 | try { | 37 | try { |
| 38 | JSONObject jsonParam = JSONObject.parseObject(json); | 38 | JSONObject jsonParam = JSONObject.parseObject(json); |
| @@ -66,6 +66,6 @@ public class UpstreamEntrance { | @@ -66,6 +66,6 @@ public class UpstreamEntrance { | ||
| 66 | } catch (Exception e) { | 66 | } catch (Exception e) { |
| 67 | logger.error("", e); | 67 | logger.error("", e); |
| 68 | } | 68 | } |
| 69 | - return 0; | 69 | + return "{\"errCode\":0}"; |
| 70 | } | 70 | } |
| 71 | } | 71 | } |
src/main/java/com/bsth/vehicle/common/CommonMapped.java
| @@ -5,7 +5,6 @@ import java.util.Map; | @@ -5,7 +5,6 @@ import java.util.Map; | ||
| 5 | 5 | ||
| 6 | import com.bsth.entity.Line; | 6 | import com.bsth.entity.Line; |
| 7 | import com.bsth.entity.StationRoute; | 7 | import com.bsth.entity.StationRoute; |
| 8 | -import com.google.common.collect.ArrayListMultimap; | ||
| 9 | import com.google.common.collect.BiMap; | 8 | import com.google.common.collect.BiMap; |
| 10 | import com.google.common.collect.TreeMultimap; | 9 | import com.google.common.collect.TreeMultimap; |
| 11 | 10 | ||
| @@ -54,12 +53,17 @@ public class CommonMapped { | @@ -54,12 +53,17 @@ public class CommonMapped { | ||
| 54 | * 线路站点路由对照 | 53 | * 线路站点路由对照 |
| 55 | * (K:线路编码, V:站点路由) | 54 | * (K:线路编码, V:站点路由) |
| 56 | */ | 55 | */ |
| 57 | - public static Map<Integer, List<StationRoute>> lineStationRouteMap; | 56 | + //public static Map<Integer, List<StationRoute>> lineStationRouteMap; |
| 58 | 57 | ||
| 59 | /** | 58 | /** |
| 60 | * 线路和用户名对照 | 59 | * 线路和用户名对照 |
| 61 | * 用于webSocket定向推送消息 | 60 | * 用于webSocket定向推送消息 |
| 62 | */ | 61 | */ |
| 63 | public static TreeMultimap<Integer, String> lineUserMap = TreeMultimap.create(); | 62 | public static TreeMultimap<Integer, String> lineUserMap = TreeMultimap.create(); |
| 63 | + | ||
| 64 | + /** | ||
| 65 | + * 线路ID和code 对照 | ||
| 66 | + */ | ||
| 67 | + public static BiMap<Integer, Integer> lineIdToCode; | ||
| 64 | 68 | ||
| 65 | } | 69 | } |
src/main/java/com/bsth/vehicle/common/CommonRefreshThread.java
| @@ -21,6 +21,7 @@ import com.bsth.entity.StationRoute; | @@ -21,6 +21,7 @@ import com.bsth.entity.StationRoute; | ||
| 21 | import com.bsth.entity.schedule.CarConfigInfo; | 21 | import com.bsth.entity.schedule.CarConfigInfo; |
| 22 | import com.bsth.repository.CarParkRepository; | 22 | import com.bsth.repository.CarParkRepository; |
| 23 | import com.bsth.repository.CarsRepository; | 23 | import com.bsth.repository.CarsRepository; |
| 24 | +import com.bsth.repository.LineRepository; | ||
| 24 | import com.bsth.repository.StationRepository; | 25 | import com.bsth.repository.StationRepository; |
| 25 | import com.bsth.repository.StationRouteRepository; | 26 | import com.bsth.repository.StationRouteRepository; |
| 26 | import com.bsth.repository.schedule.CarConfigInfoRepository; | 27 | import com.bsth.repository.schedule.CarConfigInfoRepository; |
| @@ -53,6 +54,9 @@ public class CommonRefreshThread extends Thread{ | @@ -53,6 +54,9 @@ public class CommonRefreshThread extends Thread{ | ||
| 53 | @Autowired | 54 | @Autowired |
| 54 | StationRouteRepository sRouteRepository; | 55 | StationRouteRepository sRouteRepository; |
| 55 | 56 | ||
| 57 | + @Autowired | ||
| 58 | + LineRepository lineRepository; | ||
| 59 | + | ||
| 56 | Logger logger = LoggerFactory.getLogger(this.getClass()); | 60 | Logger logger = LoggerFactory.getLogger(this.getClass()); |
| 57 | 61 | ||
| 58 | @Override | 62 | @Override |
| @@ -62,7 +66,9 @@ public class CommonRefreshThread extends Thread{ | @@ -62,7 +66,9 @@ public class CommonRefreshThread extends Thread{ | ||
| 62 | initStationCodeMap(); | 66 | initStationCodeMap(); |
| 63 | initVehicLineMap(); | 67 | initVehicLineMap(); |
| 64 | 68 | ||
| 65 | - initLineStationRouteMap(); | 69 | + //initLineStationRouteMap(); |
| 70 | + | ||
| 71 | + initLineIdToCode(); | ||
| 66 | } catch (Exception e) { | 72 | } catch (Exception e) { |
| 67 | e.printStackTrace(); | 73 | e.printStackTrace(); |
| 68 | logger.error("", e); | 74 | logger.error("", e); |
| @@ -75,7 +81,7 @@ public class CommonRefreshThread extends Thread{ | @@ -75,7 +81,7 @@ public class CommonRefreshThread extends Thread{ | ||
| 75 | * @Description: TODO(加载线路站点路由信息) | 81 | * @Description: TODO(加载线路站点路由信息) |
| 76 | * @throws | 82 | * @throws |
| 77 | */ | 83 | */ |
| 78 | - private void initLineStationRouteMap() { | 84 | +/* private void initLineStationRouteMap() { |
| 79 | List<StationRoute> routes = sRouteRepository.findAll2(); | 85 | List<StationRoute> routes = sRouteRepository.findAll2(); |
| 80 | 86 | ||
| 81 | Map<Integer, List<StationRoute>> map = new HashMap<>(); | 87 | Map<Integer, List<StationRoute>> map = new HashMap<>(); |
| @@ -97,6 +103,19 @@ public class CommonRefreshThread extends Thread{ | @@ -97,6 +103,19 @@ public class CommonRefreshThread extends Thread{ | ||
| 97 | temp = iterator.next(); | 103 | temp = iterator.next(); |
| 98 | Collections.sort(temp, sRouteComp); | 104 | Collections.sort(temp, sRouteComp); |
| 99 | } | 105 | } |
| 106 | + }*/ | ||
| 107 | + | ||
| 108 | + private void initLineIdToCode() { | ||
| 109 | + Iterator<Line> iterator = lineRepository.findAll().iterator(); | ||
| 110 | + | ||
| 111 | + Line line; | ||
| 112 | + BiMap<Integer, Integer> biMap = HashBiMap.create(); | ||
| 113 | + while(iterator.hasNext()){ | ||
| 114 | + line = iterator.next(); | ||
| 115 | + biMap.put(line.getId(), Integer.parseInt(line.getLineCode())); | ||
| 116 | + } | ||
| 117 | + | ||
| 118 | + CommonMapped.lineIdToCode = biMap; | ||
| 100 | } | 119 | } |
| 101 | 120 | ||
| 102 | /** | 121 | /** |
src/main/java/com/bsth/vehicle/directive/service/DirectiveService.java
| @@ -77,4 +77,6 @@ public interface DirectiveService extends BaseService<Directive60, Integer>{ | @@ -77,4 +77,6 @@ public interface DirectiveService extends BaseService<Directive60, Integer>{ | ||
| 77 | Map<String, Object> reply80(int id, int reply); | 77 | Map<String, Object> reply80(int id, int reply); |
| 78 | 78 | ||
| 79 | Map<String, Object> findDirective(String nbbm, int dType, int page, int size); | 79 | Map<String, Object> findDirective(String nbbm, int dType, int page, int size); |
| 80 | + | ||
| 81 | + String createDeviceRefreshData(String deviceId, Integer lineId); | ||
| 80 | } | 82 | } |
src/main/java/com/bsth/vehicle/directive/service/DirectiveServiceImpl.java
| 1 | package com.bsth.vehicle.directive.service; | 1 | package com.bsth.vehicle.directive.service; |
| 2 | 2 | ||
| 3 | import java.text.SimpleDateFormat; | 3 | import java.text.SimpleDateFormat; |
| 4 | +import java.util.ArrayList; | ||
| 4 | import java.util.Collections; | 5 | import java.util.Collections; |
| 5 | import java.util.Date; | 6 | import java.util.Date; |
| 6 | import java.util.HashMap; | 7 | import java.util.HashMap; |
| @@ -307,7 +308,7 @@ public class DirectiveServiceImpl extends BaseServiceImpl<Directive60, Integer> | @@ -307,7 +308,7 @@ public class DirectiveServiceImpl extends BaseServiceImpl<Directive60, Integer> | ||
| 307 | param.put("operCode", 0Xc0); | 308 | param.put("operCode", 0Xc0); |
| 308 | 309 | ||
| 309 | Map<String, Object> data = new HashMap<String, Object>(); | 310 | Map<String, Object> data = new HashMap<String, Object>(); |
| 310 | - data.put("operCode", 0xa1); | 311 | + data.put("operCode2", 0xa1); |
| 311 | data.put("cityCode", cityCode); | 312 | data.put("cityCode", cityCode); |
| 312 | data.put("deviceId", deviceId); | 313 | data.put("deviceId", deviceId); |
| 313 | data.put("timestamp", t); | 314 | data.put("timestamp", t); |
| @@ -409,8 +410,15 @@ public class DirectiveServiceImpl extends BaseServiceImpl<Directive60, Integer> | @@ -409,8 +410,15 @@ public class DirectiveServiceImpl extends BaseServiceImpl<Directive60, Integer> | ||
| 409 | // 时间倒序 | 410 | // 时间倒序 |
| 410 | Collections.sort(list, new DirectiveBuffer.DComparator()); | 411 | Collections.sort(list, new DirectiveBuffer.DComparator()); |
| 411 | if(StringUtils.isNotBlank(nbbm)){ | 412 | if(StringUtils.isNotBlank(nbbm)){ |
| 413 | + String deviceId = CommonMapped.vehicDeviceBiMap.inverse().get(nbbm); | ||
| 412 | //按车辆过滤 | 414 | //按车辆过滤 |
| 413 | - | 415 | + List<Directive> subList = new ArrayList<>(); |
| 416 | + for(Directive d : list){ | ||
| 417 | + if(d.getDeviceId().equals(deviceId)){ | ||
| 418 | + subList.add(d); | ||
| 419 | + } | ||
| 420 | + } | ||
| 421 | + list = subList; | ||
| 414 | } | 422 | } |
| 415 | 423 | ||
| 416 | int count = list.size(); | 424 | int count = list.size(); |
src/main/java/com/bsth/vehicle/gpsdata/arrival/match/ScheduleRealMatcher.java
| @@ -155,15 +155,16 @@ public class ScheduleRealMatcher implements ApplicationContextAware{ | @@ -155,15 +155,16 @@ public class ScheduleRealMatcher implements ApplicationContextAware{ | ||
| 155 | } | 155 | } |
| 156 | 156 | ||
| 157 | finish = ScheduleBuffer.getFinishSchNo(sch.getClZbh()); | 157 | finish = ScheduleBuffer.getFinishSchNo(sch.getClZbh()); |
| 158 | - upDown = Integer.parseInt(sch.getXlDir()); | 158 | + |
| 159 | if(nextSch != null){ | 159 | if(nextSch != null){ |
| 160 | //发送下一班次的调度指令 | 160 | //发送下一班次的调度指令 |
| 161 | directiveService.send60Dispatch(nextSch, finish); | 161 | directiveService.send60Dispatch(nextSch, finish); |
| 162 | + upDown = Integer.parseInt(nextSch.getXlDir()); | ||
| 162 | //切换下一个班次的走向 | 163 | //切换下一个班次的走向 |
| 163 | - logger.info(sch.getClZbh() + " 切换下一班次走向"); | ||
| 164 | directiveService.send60Operation(nextSch.getClZbh(), 0, upDown, nextSch); | 164 | directiveService.send60Operation(nextSch.getClZbh(), 0, upDown, nextSch); |
| 165 | } | 165 | } |
| 166 | else{ | 166 | else{ |
| 167 | + upDown = Integer.parseInt(sch.getXlDir()); | ||
| 167 | //没有下一个班次了,切换为非营运状态 | 168 | //没有下一个班次了,切换为非营运状态 |
| 168 | logger.info(sch.getClZbh() + " 完成所有班次,切换为非营运状态"); | 169 | logger.info(sch.getClZbh() + " 完成所有班次,切换为非营运状态"); |
| 169 | directiveService.send60Operation(sch.getClZbh(), 1, upDown, sch); | 170 | directiveService.send60Operation(sch.getClZbh(), 1, upDown, sch); |
src/main/java/com/bsth/vehicle/gpsdata/buffer/GpsRealDataBuffer.java
| @@ -103,11 +103,9 @@ public class GpsRealDataBuffer { | @@ -103,11 +103,9 @@ public class GpsRealDataBuffer { | ||
| 103 | 103 | ||
| 104 | //更新GPS点 | 104 | //更新GPS点 |
| 105 | for(GpsRealData newGps : upGpsList){ | 105 | for(GpsRealData newGps : upGpsList){ |
| 106 | - if(t - newGps.getTimestamp() < OFFLINE_TIME | ||
| 107 | - && !newGps.isOnline()){ | ||
| 108 | - logger.info("设备:" + newGps.getDeviceId() + " 上线"); | 106 | + |
| 107 | + if(t - newGps.getTimestamp() < OFFLINE_TIME ) | ||
| 109 | newGps.setOnline(true); | 108 | newGps.setOnline(true); |
| 110 | - } | ||
| 111 | 109 | ||
| 112 | deviceGpsMap.put(newGps.getDeviceId(), newGps); | 110 | deviceGpsMap.put(newGps.getDeviceId(), newGps); |
| 113 | } | 111 | } |
src/main/resources/static/pages/control/line/child_pages/historyDirective.html
| @@ -22,8 +22,8 @@ | @@ -22,8 +22,8 @@ | ||
| 22 | <table class="table table-hover" style="table-layout: fixed;"> | 22 | <table class="table table-hover" style="table-layout: fixed;"> |
| 23 | <thead> | 23 | <thead> |
| 24 | <tr> | 24 | <tr> |
| 25 | - <th width="9%">车辆</th> | ||
| 26 | <th width="7%">时间</th> | 25 | <th width="7%">时间</th> |
| 26 | + <th width="9%">车辆</th> | ||
| 27 | <th width="47%">内容</th> | 27 | <th width="47%">内容</th> |
| 28 | <th width="8%">发送人</th> | 28 | <th width="8%">发送人</th> |
| 29 | <th width="17%">状态</th> | 29 | <th width="17%">状态</th> |
| @@ -40,8 +40,8 @@ | @@ -40,8 +40,8 @@ | ||
| 40 | <script id="history_directive_list_temp" type="text/html"> | 40 | <script id="history_directive_list_temp" type="text/html"> |
| 41 | {{each list as item i}} | 41 | {{each list as item i}} |
| 42 | <tr> | 42 | <tr> |
| 43 | - <td>{{item.nbbm}}</td> | ||
| 44 | <td>{{item.timeHHmm}}</td> | 43 | <td>{{item.timeHHmm}}</td> |
| 44 | + <td>{{item.nbbm}}</td> | ||
| 45 | <td> | 45 | <td> |
| 46 | <div class="text-furl"> | 46 | <div class="text-furl"> |
| 47 | {{item.data.txtContent}} | 47 | {{item.data.txtContent}} |
| @@ -54,8 +54,7 @@ | @@ -54,8 +54,7 @@ | ||
| 54 | {{else}} | 54 | {{else}} |
| 55 | {{if item.reply46 != 0}} | 55 | {{if item.reply46 != 0}} |
| 56 | <span class="label label-sm label-danger">设备无响应</span> | 56 | <span class="label label-sm label-danger">设备无响应</span> |
| 57 | - {{/if}} | ||
| 58 | - {{if item.reply47 != 0}} | 57 | + {{else if item.reply47 != 0}} |
| 59 | <span class="label label-sm label-warning">驾驶员未确认</span> | 58 | <span class="label label-sm label-warning">驾驶员未确认</span> |
| 60 | {{/if}} | 59 | {{/if}} |
| 61 | 60 |
src/main/resources/static/pages/control/line/index.html
| @@ -290,5 +290,6 @@ function interceptPOST(e, xhr, t){ | @@ -290,5 +290,6 @@ function interceptPOST(e, xhr, t){ | ||
| 290 | layer.msg('监控模式!',{offset: 'ct', shift : 6}); | 290 | layer.msg('监控模式!',{offset: 'ct', shift : 6}); |
| 291 | } | 291 | } |
| 292 | } | 292 | } |
| 293 | + | ||
| 293 | </script> | 294 | </script> |
| 294 | <script src="/pages/control/line/js/webSocketHandle.js"></script> | 295 | <script src="/pages/control/line/js/webSocketHandle.js"></script> |
| 295 | \ No newline at end of file | 296 | \ No newline at end of file |
src/main/resources/static/pages/control/lineallot/allot.html
| @@ -326,7 +326,7 @@ $(function(){ | @@ -326,7 +326,7 @@ $(function(){ | ||
| 326 | var f = arguments.callee | 326 | var f = arguments.callee |
| 327 | ,item = lsData[i]; | 327 | ,item = lsData[i]; |
| 328 | 328 | ||
| 329 | - $.get('/realSchedule/findRouteByLine', {lineId: item.id}, function(rs){ | 329 | + $.get('/realSchedule/findRouteByLine', {lineCode: item.lineCode}, function(rs){ |
| 330 | if(rs && rs.lineId){ | 330 | if(rs && rs.lineId){ |
| 331 | cacheData[item.lineCode] = rs; | 331 | cacheData[item.lineCode] = rs; |
| 332 | i ++; | 332 | i ++; |
src/main/resources/static/pages/mapmonitor/real/css/real.css
| @@ -93,7 +93,7 @@ label.BMapLabel{ | @@ -93,7 +93,7 @@ label.BMapLabel{ | ||
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | .mapRightWrap.playBack{ | 95 | .mapRightWrap.playBack{ |
| 96 | - min-height: 454px; | 96 | + min-height: 374px; |
| 97 | width: 390px; | 97 | width: 390px; |
| 98 | height: auto; | 98 | height: auto; |
| 99 | } | 99 | } |
| @@ -710,8 +710,8 @@ display: none; | @@ -710,8 +710,8 @@ display: none; | ||
| 710 | } | 710 | } |
| 711 | 711 | ||
| 712 | .play-back-btns .dropdown-menu{ | 712 | .play-back-btns .dropdown-menu{ |
| 713 | - min-width: 70px; | ||
| 714 | - width: 70px; | 713 | + min-width: 80px; |
| 714 | + width: 80px; | ||
| 715 | } | 715 | } |
| 716 | 716 | ||
| 717 | .play-back-btns>i.playBtn{ | 717 | .play-back-btns>i.playBtn{ |
| @@ -803,3 +803,15 @@ display: none; | @@ -803,3 +803,15 @@ display: none; | ||
| 803 | color: #5f5d5d; | 803 | color: #5f5d5d; |
| 804 | margin-left: 7px; | 804 | margin-left: 7px; |
| 805 | } */ | 805 | } */ |
| 806 | + | ||
| 807 | +.layui-layer-msg.layer-bg-green{ | ||
| 808 | + background: #1bbc9b; | ||
| 809 | + border: 1px solid #1bbc9b; | ||
| 810 | + color: white; | ||
| 811 | +} | ||
| 812 | + | ||
| 813 | +.layui-layer-msg.layer-bg-red{ | ||
| 814 | + background: red; | ||
| 815 | + border: 1px solid red; | ||
| 816 | + color: white; | ||
| 817 | +} |
src/main/resources/static/pages/mapmonitor/real/js/map_platform.js
| @@ -277,6 +277,10 @@ var realMap = (function() { | @@ -277,6 +277,10 @@ var realMap = (function() { | ||
| 277 | //居中marker | 277 | //居中marker |
| 278 | markerToCenter: function(marker){ | 278 | markerToCenter: function(marker){ |
| 279 | currentMap.map.panTo(marker.getPosition()); | 279 | currentMap.map.panTo(marker.getPosition()); |
| 280 | + }, | ||
| 281 | + //删除marker | ||
| 282 | + removeMarker: function(marker){ | ||
| 283 | + currentMap.map.removeOverlay(marker); | ||
| 280 | } | 284 | } |
| 281 | }, | 285 | }, |
| 282 | //高德地图 | 286 | //高德地图 |
src/main/resources/static/pages/mapmonitor/real/js/playBack.js
| @@ -3,6 +3,8 @@ | @@ -3,6 +3,8 @@ | ||
| 3 | */ | 3 | */ |
| 4 | 4 | ||
| 5 | var playBack = (function() { | 5 | var playBack = (function() { |
| 6 | + //默认车辆 | ||
| 7 | + var defaultCar, defaultLine; | ||
| 6 | //css3动画结束事件 | 8 | //css3动画结束事件 |
| 7 | var animationend = 'webkitAnimationEnd animationend'; | 9 | var animationend = 'webkitAnimationEnd animationend'; |
| 8 | var prgTimer; | 10 | var prgTimer; |
| @@ -10,6 +12,13 @@ var playBack = (function() { | @@ -10,6 +12,13 @@ var playBack = (function() { | ||
| 10 | var sTime; | 12 | var sTime; |
| 11 | //结束时间戳 | 13 | //结束时间戳 |
| 12 | var eTime; | 14 | var eTime; |
| 15 | + //当前时间戳 | ||
| 16 | + var cTime; | ||
| 17 | + //每步走10秒 | ||
| 18 | + var step = 10; | ||
| 19 | + //1个px多少秒 | ||
| 20 | + var secondPX; | ||
| 21 | + | ||
| 13 | var tRange; | 22 | var tRange; |
| 14 | //进度条宽度 | 23 | //进度条宽度 |
| 15 | var pWidth; | 24 | var pWidth; |
| @@ -20,11 +29,12 @@ var playBack = (function() { | @@ -20,11 +29,12 @@ var playBack = (function() { | ||
| 20 | //上层运动的进度条 | 29 | //上层运动的进度条 |
| 21 | var $pmk = $('.play-back-progress-mark'); | 30 | var $pmk = $('.play-back-progress-mark'); |
| 22 | //单元格 | 31 | //单元格 |
| 23 | - var cell/*, minCell = 5, cellSecond*/; | 32 | + //var cell/*, minCell = 5, cellSecond*/; |
| 24 | //GPS轨迹点 | 33 | //GPS轨迹点 |
| 25 | var gpsArray; | 34 | var gpsArray; |
| 26 | //播放到的轨迹坐标点 | 35 | //播放到的轨迹坐标点 |
| 27 | var cIndex = 0; | 36 | var cIndex = 0; |
| 37 | + //GPS点数量 | ||
| 28 | var size; | 38 | var size; |
| 29 | //播放速度 | 39 | //播放速度 |
| 30 | var speed = parseInt($('#playSpeedText').text()); | 40 | var speed = parseInt($('#playSpeedText').text()); |
| @@ -32,8 +42,10 @@ var playBack = (function() { | @@ -32,8 +42,10 @@ var playBack = (function() { | ||
| 32 | var markerMap = {}; | 42 | var markerMap = {}; |
| 33 | //线路路由数据 | 43 | //线路路由数据 |
| 34 | var lineRoute; | 44 | var lineRoute; |
| 35 | - //默认以第一辆车为焦点 | 45 | + //首辆车自编号 |
| 36 | var firstCar; | 46 | var firstCar; |
| 47 | + //是否启用焦点跟踪 | ||
| 48 | + var isEnableFocus; | ||
| 37 | 49 | ||
| 38 | function getCurrMap(){ | 50 | function getCurrMap(){ |
| 39 | return realMap[realMap.getMap().fName]; | 51 | return realMap[realMap.getMap().fName]; |
| @@ -61,7 +73,8 @@ var playBack = (function() { | @@ -61,7 +73,8 @@ var playBack = (function() { | ||
| 61 | }).mouseout(hideMarkTextMouse) | 73 | }).mouseout(hideMarkTextMouse) |
| 62 | .on('click', function(e){ | 74 | .on('click', function(e){ |
| 63 | var w = e.clientX - 20; | 75 | var w = e.clientX - 20; |
| 64 | - goTo(w); | 76 | + //goTo(w); |
| 77 | + goToByTime(sTime + w * secondPX); | ||
| 65 | hideMarkTextMouse(); | 78 | hideMarkTextMouse(); |
| 66 | }); | 79 | }); |
| 67 | 80 | ||
| @@ -92,37 +105,12 @@ var playBack = (function() { | @@ -92,37 +105,12 @@ var playBack = (function() { | ||
| 92 | }); | 105 | }); |
| 93 | 106 | ||
| 94 | function showMarkText(w){ | 107 | function showMarkText(w){ |
| 95 | - var t = showMark($presMark, w); | ||
| 96 | - //时间戳找gps | ||
| 97 | - var gps; | ||
| 98 | - var marker; | ||
| 99 | - for(;cIndex < size; cIndex ++){ | ||
| 100 | - gps = gpsArray[cIndex]; | ||
| 101 | - if(gps.ts <= t){ | ||
| 102 | - marker = markerMap[gps.nbbm]; | ||
| 103 | - if(marker) | ||
| 104 | - getCurrMap().moveMarker(marker, gps);//移动marker | ||
| 105 | - else{ | ||
| 106 | - markerMap[gps.nbbm] = getCurrMap().addHistoryMarker(gps);//添加marker | ||
| 107 | - //定位到marker | ||
| 108 | - //getCurrMap().markerToCenter(markerMap[gps.nbbm]); | ||
| 109 | - } | ||
| 110 | - | ||
| 111 | - if(gps.inout_stop != -1){ | ||
| 112 | - //到离站信息 | ||
| 113 | - addInOutText(gps); | ||
| 114 | - } | ||
| 115 | - } | ||
| 116 | - else{ | ||
| 117 | - break; | ||
| 118 | - } | ||
| 119 | - } | ||
| 120 | - //定位焦点 | ||
| 121 | - /*if(markerMap[firstCar]){ | ||
| 122 | - getCurrMap().markerToCenter(markerMap[firstCar]); | ||
| 123 | - }*/ | 108 | + var text = moment(cTime * 1000).format('HH:mm.ss'); |
| 109 | + | ||
| 110 | + $presMark.text(text).css('left', w - $presMark.width() / 2).show(); | ||
| 124 | } | 111 | } |
| 125 | 112 | ||
| 113 | + //添加进出站日志 | ||
| 126 | function addInOutText(gps){ | 114 | function addInOutText(gps){ |
| 127 | var info = gps.inout_stop_info | 115 | var info = gps.inout_stop_info |
| 128 | ,date = moment(gps.ts).format('HH:mm.ss'); | 116 | ,date = moment(gps.ts).format('HH:mm.ss'); |
| @@ -149,22 +137,13 @@ var playBack = (function() { | @@ -149,22 +137,13 @@ var playBack = (function() { | ||
| 149 | } | 137 | } |
| 150 | 138 | ||
| 151 | function showMarkTextMouse(w){ | 139 | function showMarkTextMouse(w){ |
| 152 | - showMark($presMarkMouse, w); | 140 | + var text = moment((sTime + w * secondPX) * 1000).format('HH:mm.ss'); |
| 141 | + $presMarkMouse.text(text).css('left', w - $presMarkMouse.width() / 2).show(); | ||
| 153 | } | 142 | } |
| 154 | function hideMarkTextMouse(){ | 143 | function hideMarkTextMouse(){ |
| 155 | $presMarkMouse.hide(); | 144 | $presMarkMouse.hide(); |
| 156 | } | 145 | } |
| 157 | 146 | ||
| 158 | - function showMark(mark, w, anim){ | ||
| 159 | - var t = parseInt((sTime + w / cell) * 1000) | ||
| 160 | - ,text = moment(t).format('HH:mm.ss'); | ||
| 161 | - | ||
| 162 | - mark.text(text).css('left', w - mark.width() / 2) | ||
| 163 | - .show(); | ||
| 164 | - | ||
| 165 | - return t; | ||
| 166 | - } | ||
| 167 | - | ||
| 168 | //日志区域滚动条 | 147 | //日志区域滚动条 |
| 169 | $('.pback-logs').slimscroll({ | 148 | $('.pback-logs').slimscroll({ |
| 170 | height: '100%', | 149 | height: '100%', |
| @@ -173,132 +152,243 @@ var playBack = (function() { | @@ -173,132 +152,243 @@ var playBack = (function() { | ||
| 173 | 152 | ||
| 174 | var exports = { | 153 | var exports = { |
| 175 | init : function() { | 154 | init : function() { |
| 176 | - var htmlStr = template('play_back_panel_temp', {}); | 155 | + //清空地图 |
| 156 | + getCurrMap().clear(); | ||
| 157 | + | ||
| 158 | + vehiclePanel.clear(); | ||
| 159 | + | ||
| 160 | + var htmlStr = template('play_back_panel_temp', {}) | ||
| 161 | + ,carSel = '.mapRightWrap select[name="nbbm[]"]'; | ||
| 177 | $('.mapRightWrap').html(htmlStr); | 162 | $('.mapRightWrap').html(htmlStr); |
| 163 | + //初始选中的车辆 | ||
| 164 | + if(defaultCar){ | ||
| 165 | + $(carSel).html('<option selected value="'+defaultCar+'">'+defaultCar+'</option>'); | ||
| 166 | + defaultCar = null; | ||
| 167 | + } | ||
| 178 | //车辆搜索框 | 168 | //车辆搜索框 |
| 179 | - createVehSearch($('.mapRightWrap select[name="nbbm[]"]')); | ||
| 180 | - //线路下拉框 | ||
| 181 | - var lineData = [{id:'-1', text: '请选择...'}]; | ||
| 182 | - $get('/line/all', null, function(array){ | ||
| 183 | - $.each(array, function(){ | ||
| 184 | - lineData.push({id: this.id, text: this.name}); | 169 | + createVehSearch($(carSel)).on('select2:select', function(e){ |
| 170 | + //获取对应线路 | ||
| 171 | + defaultLine = e.params.data.lineCode; | ||
| 185 | }); | 172 | }); |
| 186 | - initPinYinSelect2('.mapRightWrap select[name=lineCode]', lineData); | ||
| 187 | - }); | ||
| 188 | 173 | ||
| 189 | //点击轨迹回放按钮 | 174 | //点击轨迹回放按钮 |
| 190 | - $('#playBackBtn').on('click', function(){ | ||
| 191 | - //表单校验 | ||
| 192 | - if(!customFormValidate('#playBackForm')) | 175 | + $('#playBackBtn').on('click', playBackBtnClick); |
| 176 | + | ||
| 177 | + //默认值,当前时间前后各一个小时 | ||
| 178 | + var m = moment() | ||
| 179 | + ,rq='YYYY-MM-DD', sj='HH:mm'; | ||
| 180 | + $('input[name=sDate]').val(m.format(rq)); | ||
| 181 | + $('input[name=sTime]').val(m.subtract(1, 'hours').format(sj)); | ||
| 182 | + $('input[name=eDate]').val(m.add(2, 'hours').format(rq)); | ||
| 183 | + $('input[name=eTime]').val(m.format('HH:mm')); | ||
| 184 | + } | ||
| 185 | + ,setDefaultCar: function(nbbm, lineCode){ | ||
| 186 | + defaultCar = nbbm; | ||
| 187 | + defaultLine = lineCode; | ||
| 188 | + } | ||
| 189 | + }; | ||
| 190 | + | ||
| 191 | + function playBackBtnClick(){ | ||
| 192 | + //表单校验 | ||
| 193 | + if(!customFormValidate('#playBackForm')) | ||
| 194 | + return; | ||
| 195 | + | ||
| 196 | + var params = $('#playBackForm').serializeJSON(); | ||
| 197 | + //查询历史gps数据 | ||
| 198 | + var fs = 'YYYY-MM-DDHH:mm' | ||
| 199 | + ,st = moment(params.sDate + params.sTime, fs).format('X') | ||
| 200 | + ,et = moment(params.eDate + params.eTime, fs).format('X') | ||
| 201 | + ,nbbm = params.nbbm; | ||
| 202 | + | ||
| 203 | + console.log(params); | ||
| 204 | + isEnableFocus = params.enableFocus; | ||
| 205 | + layer.msg('查询历史GPS...', {icon: 16, time: 0,shade:0.3}); | ||
| 206 | + $.ajax({ | ||
| 207 | + url: '/gps/gpsHistory/multiple', | ||
| 208 | + traditional: true, | ||
| 209 | + data: {nbbmArray: params.nbbm, st: st, et: et}, | ||
| 210 | + success:function(rs){ | ||
| 211 | + if(!rs || rs.length == 0){ | ||
| 212 | + layer.alert('服务器没有返回数据,请检查你的输入参数!', {icon: 3}); | ||
| 193 | return; | 213 | return; |
| 214 | + } | ||
| 194 | 215 | ||
| 195 | - var params = $('#playBackForm').serializeJSON(); | ||
| 196 | - //查询历史gps数据 | ||
| 197 | - var fs = 'YYYY-MM-DDHH:mm' | ||
| 198 | - ,st = moment(params.sDate + params.sTime, fs).format('X') | ||
| 199 | - ,et = moment(params.eDate + params.eTime, fs).format('X') | ||
| 200 | - ,nbbm = params.nbbm; | 216 | + gpsArray = rs; |
| 217 | + size = gpsArray.length; | ||
| 218 | + layer.closeAll(); | ||
| 219 | + //切出轨迹回放面板 | ||
| 220 | + $('.mapRightWrap,.mapTools,.leftUtilsWrap').fadeOut(); | ||
| 221 | + $('.play-back-list,.play-back-btns,.progress-wrap').show(); | ||
| 222 | + //初始化时间戳 | ||
| 223 | + sTime = parseInt(st); | ||
| 224 | + eTime = parseInt(et); | ||
| 225 | + tRange = et - st; | ||
| 201 | 226 | ||
| 202 | - layer.msg('查询历史GPS...', {icon: 16, time: 0,shade:0.3}); | ||
| 203 | - $.ajax({ | ||
| 204 | - url: '/gps/gpsHistory/multiple', | ||
| 205 | - traditional: true, | ||
| 206 | - data: {nbbmArray: params.nbbm, st: st, et: et}, | ||
| 207 | - success:function(rs){ | ||
| 208 | - gpsArray = rs; | ||
| 209 | - size = gpsArray.length; | ||
| 210 | - layer.closeAll(); | ||
| 211 | - //切出轨迹回放面板 | ||
| 212 | - $('.mapRightWrap,.mapTools,.leftUtilsWrap').fadeOut(); | ||
| 213 | - $('.play-back-list,.play-back-btns,.progress-wrap').show(); | ||
| 214 | - //初始化时间戳 | ||
| 215 | - sTime = parseInt(st); | ||
| 216 | - eTime = parseInt(et); | ||
| 217 | - tRange = et - st; | ||
| 218 | - | ||
| 219 | - //获取进度条宽度 | ||
| 220 | - pWidth = $('.progress-body').width(); | ||
| 221 | - cell = pWidth / tRange; | ||
| 222 | - //清理地图 | ||
| 223 | - getCurrMap().clear(); | 227 | + //获取进度条宽度 |
| 228 | + pWidth = $('.progress-body').width(); | ||
| 229 | + secondPX = tRange / pWidth; | ||
| 230 | + //清理地图 | ||
| 231 | + getCurrMap().clear(); | ||
| 232 | + | ||
| 233 | + firstCar = params.nbbm[0]; | ||
| 234 | + | ||
| 235 | + if(defaultLine){ | ||
| 236 | + layer.msg('加载线路图层数据...', {icon: 16, time: 0,shade:0.3}); | ||
| 237 | + $.get('/realSchedule/findRouteByLine', {lineCode: defaultLine} | ||
| 238 | + ,function(route){ | ||
| 239 | + lineRoute = route; | ||
| 240 | + getCurrMap().drawLine(lineRoute); | ||
| 224 | 241 | ||
| 225 | - firstCar = params.nbbm[0]; | 242 | + cTime = sTime; |
| 243 | + play(); | ||
| 226 | 244 | ||
| 227 | - var lineCode = $('.mapRightWrap select[name=lineCode]').val(); | ||
| 228 | - if(lineCode != -1){ | ||
| 229 | - layer.msg('加载线路图层数据...', {icon: 16, time: 0,shade:0.3}); | ||
| 230 | - $.get('/realSchedule/findRouteByLine', {lineId: lineCode} | ||
| 231 | - ,function(route){ | ||
| 232 | - lineRoute = route; | ||
| 233 | - getCurrMap().drawLine(lineRoute); | ||
| 234 | - layer.closeAll(); | ||
| 235 | - play(); | ||
| 236 | - }); | 245 | + //自动定位到第一辆车的第一个点 |
| 246 | + var nbbm = params.nbbm[0] | ||
| 247 | + ,firstTime = searchFirst(gpsArray, nbbm); | ||
| 248 | + if(firstTime){ | ||
| 249 | + layer.msg('从该时区内 ' + nbbm + ' 的首个信号点,' + moment(firstTime).format('HH:mm') + '开始' | ||
| 250 | + ,{offset: 'ct', shift : 5, skin: 'layer-bg-green'}); | ||
| 251 | + | ||
| 252 | + goToByTime(firstTime / 1000); | ||
| 237 | } | 253 | } |
| 238 | else | 254 | else |
| 239 | - play(); | ||
| 240 | - } | ||
| 241 | - }); | ||
| 242 | - }); | ||
| 243 | - | ||
| 244 | - //默认值 | ||
| 245 | - /* $('input[name=sDate]').val('2016-04-24'); | ||
| 246 | - $('input[name=sTime]').val('04:00'); | ||
| 247 | - $('input[name=eDate]').val('2016-04-24'); | ||
| 248 | - $('input[name=eTime]').val('05:40');*/ | 255 | + layer.closeAll(); |
| 256 | + }); | ||
| 257 | + } | ||
| 258 | + else | ||
| 259 | + play(); | ||
| 260 | + } | ||
| 261 | + }); | ||
| 262 | + } | ||
| 263 | + | ||
| 264 | + //搜索时间范围内第一个gps点的时间 | ||
| 265 | + function searchFirst(list, nbbm){ | ||
| 266 | + var time; | ||
| 267 | + for(var i = 0, gps; gps = list[i++];){ | ||
| 268 | + if(gps.nbbm == nbbm){ | ||
| 269 | + time = gps.ts; | ||
| 270 | + break; | ||
| 271 | + } | ||
| 249 | } | 272 | } |
| 250 | - }; | 273 | + |
| 274 | + return time; | ||
| 275 | + } | ||
| 251 | 276 | ||
| 252 | function stop(){ | 277 | function stop(){ |
| 278 | + _stopFocusTimer = 1; | ||
| 279 | + clearInterval(focusTimer); | ||
| 280 | + //停止播放 | ||
| 253 | clearInterval(prgTimer); | 281 | clearInterval(prgTimer); |
| 254 | $('.play-back-btns .playBtn').removeClass('fa-pause').addClass('fa-play').data('status', 0); | 282 | $('.play-back-btns .playBtn').removeClass('fa-pause').addClass('fa-play').data('status', 0); |
| 255 | prgTimer = null; | 283 | prgTimer = null; |
| 256 | } | 284 | } |
| 257 | 285 | ||
| 258 | function play(){ | 286 | function play(){ |
| 259 | - if(topW == pWidth){ | ||
| 260 | - //从头再来 | ||
| 261 | - reset(); | ||
| 262 | - } | ||
| 263 | $('#progress-mark-time').show(); | 287 | $('#progress-mark-time').show(); |
| 264 | $('.play-back-btns .playBtn').removeClass('fa-play').addClass('fa-pause').data('status', 1); | 288 | $('.play-back-btns .playBtn').removeClass('fa-play').addClass('fa-pause').data('status', 1); |
| 289 | + //开始播放 | ||
| 265 | start(); | 290 | start(); |
| 291 | + | ||
| 292 | + //启动焦点定位(单独用一个定时器做缓冲) | ||
| 293 | + console.log('isEnableFocus', isEnableFocus); | ||
| 294 | + if(isEnableFocus){ | ||
| 295 | + _stopFocusTimer = null; | ||
| 296 | + startTrackFocus(); | ||
| 297 | + } | ||
| 266 | } | 298 | } |
| 267 | 299 | ||
| 268 | - function reset(){ | ||
| 269 | - topW = 0; | ||
| 270 | - $pmk.css('width', topW + 'px'); | ||
| 271 | - cIndex = 0; | ||
| 272 | - $('.pback-logs').html(''); | 300 | + var _stopFocusTimer, focusTimer; |
| 301 | + function startTrackFocus(){ | ||
| 302 | + trackFocus(); | ||
| 303 | + if(!_stopFocusTimer) | ||
| 304 | + focusTimer = setTimeout(startTrackFocus, 1800); | ||
| 305 | + } | ||
| 306 | + | ||
| 307 | + function trackFocus(){ | ||
| 308 | + //定位焦点 | ||
| 309 | + if(markerMap[firstCar]) | ||
| 310 | + getCurrMap().markerToCenter(markerMap[firstCar]); | ||
| 273 | } | 311 | } |
| 274 | 312 | ||
| 275 | - var topW = 0; | ||
| 276 | function start(){ | 313 | function start(){ |
| 277 | - prgTimer = setTimeout(start, 1000); | 314 | + prgTimer = setTimeout(start, 1000 / speed); |
| 278 | run(); | 315 | run(); |
| 279 | } | 316 | } |
| 280 | 317 | ||
| 318 | + var cw = 0; | ||
| 281 | function run(){ | 319 | function run(){ |
| 282 | - topW += (cell * speed); | ||
| 283 | - showMarkText(topW); | ||
| 284 | - if(topW >= pWidth){ | 320 | + cTime += step; |
| 321 | + | ||
| 322 | + cw = (cTime - sTime) / secondPX; | ||
| 323 | + //显示时间标记 | ||
| 324 | + showMarkText(cw); | ||
| 325 | + //移动GPS点 | ||
| 326 | + moveGpsByTime(cTime); | ||
| 327 | + | ||
| 328 | + if(cw >= pWidth){ | ||
| 285 | stop(); | 329 | stop(); |
| 286 | $('#progress-mark-time').hide(); | 330 | $('#progress-mark-time').hide(); |
| 287 | - topW = pWidth; | 331 | + cw = pWidth; |
| 332 | + | ||
| 333 | + layer.msg('本次轨迹回放已结束' | ||
| 334 | + ,{offset: 'ct', shift : 5 , skin: 'layer-bg-red'}); | ||
| 288 | } | 335 | } |
| 289 | - $pmk.css('width', topW + 'px'); | 336 | + $pmk.css('width', cw + 'px'); |
| 290 | } | 337 | } |
| 291 | 338 | ||
| 292 | - function goTo(w){ | ||
| 293 | - $('.pback-logs').html(''); | 339 | + //根据时间移动GPS |
| 340 | + function moveGpsByTime(t){ | ||
| 341 | + t = t * 1000; | ||
| 342 | + var rs = {}, gps; | ||
| 343 | + for(;cIndex < size; cIndex ++){ | ||
| 344 | + gps = gpsArray[cIndex]; | ||
| 345 | + if(gps.ts <= t) | ||
| 346 | + rs[gps.nbbm] = gps; | ||
| 347 | + else | ||
| 348 | + break; | ||
| 349 | + | ||
| 350 | + //到离站信息 | ||
| 351 | + if(gps.inout_stop != -1) | ||
| 352 | + addInOutText(gps); | ||
| 353 | + } | ||
| 354 | + | ||
| 355 | + //绘制到地图 | ||
| 356 | + var marker; | ||
| 357 | + for(var nbbm in rs){ | ||
| 358 | + gps = rs[nbbm]; | ||
| 359 | + marker = markerMap[gps.nbbm]; | ||
| 360 | + | ||
| 361 | + if(marker) | ||
| 362 | + getCurrMap().moveMarker(marker, gps);//移动marker | ||
| 363 | + else | ||
| 364 | + markerMap[gps.nbbm] = getCurrMap().addHistoryMarker(gps);//添加marker | ||
| 365 | + } | ||
| 366 | + | ||
| 367 | + } | ||
| 368 | + | ||
| 369 | + function goToByTime(time){ | ||
| 370 | + //停止播放 | ||
| 371 | + clearInterval(prgTimer); | ||
| 372 | + prgTimer = null; | ||
| 294 | cIndex = 0; | 373 | cIndex = 0; |
| 295 | - stop(); | ||
| 296 | - topW = w; | ||
| 297 | - showMarkText(w); | ||
| 298 | - //$pmk.css('width', w); | 374 | + |
| 375 | + cTime = time; | ||
| 376 | + //清空右侧日志信息 | ||
| 377 | + $('.pback-logs').html(''); | ||
| 378 | + //清除GPS点 | ||
| 379 | + removeAllGps(); | ||
| 299 | play(); | 380 | play(); |
| 300 | } | 381 | } |
| 301 | 382 | ||
| 383 | + | ||
| 384 | + //removeMarker | ||
| 385 | + function removeAllGps(){ | ||
| 386 | + for(var nbbm in markerMap) | ||
| 387 | + getCurrMap().removeMarker(markerMap[nbbm]); | ||
| 388 | + | ||
| 389 | + markerMap = {}; | ||
| 390 | + } | ||
| 391 | + | ||
| 302 | /** | 392 | /** |
| 303 | * 自定义表单校验 | 393 | * 自定义表单校验 |
| 304 | */ | 394 | */ |
src/main/resources/static/pages/mapmonitor/real/js/vehicle.js
| @@ -38,6 +38,12 @@ var vehiclePanel = (function() { | @@ -38,6 +38,12 @@ var vehiclePanel = (function() { | ||
| 38 | }); | 38 | }); |
| 39 | }); | 39 | }); |
| 40 | 40 | ||
| 41 | + //跳转到轨迹回放 | ||
| 42 | + function toPlayBack(nbbm, lineCode){ | ||
| 43 | + playBack.setDefaultCar(nbbm, lineCode); | ||
| 44 | + $('.mapTools .item[data-click=playBack]').click(); | ||
| 45 | + } | ||
| 46 | + | ||
| 41 | //绘制线路和GPS | 47 | //绘制线路和GPS |
| 42 | function drawLineAndGps(lineCode, callFun){ | 48 | function drawLineAndGps(lineCode, callFun){ |
| 43 | //过滤出该线路的GPS点 | 49 | //过滤出该线路的GPS点 |
| @@ -169,7 +175,11 @@ var vehiclePanel = (function() { | @@ -169,7 +175,11 @@ var vehiclePanel = (function() { | ||
| 169 | for(var deviceId in allGps) | 175 | for(var deviceId in allGps) |
| 170 | array.push(allGps[deviceId]); | 176 | array.push(allGps[deviceId]); |
| 171 | return array; | 177 | return array; |
| 172 | - } | 178 | + }, |
| 179 | + clear: function(){ | ||
| 180 | + cLineCode = null; | ||
| 181 | + }, | ||
| 182 | + toPlayBack:toPlayBack | ||
| 173 | }; | 183 | }; |
| 174 | 184 | ||
| 175 | return exports; | 185 | return exports; |
src/main/resources/static/pages/mapmonitor/real/real.html
| @@ -55,9 +55,12 @@ | @@ -55,9 +55,12 @@ | ||
| 55 | <i class="fa fa-close"></i><span id="playSpeedText">10</span><i class="fa fa-angle-up" ></i> | 55 | <i class="fa fa-close"></i><span id="playSpeedText">10</span><i class="fa fa-angle-up" ></i> |
| 56 | </span> | 56 | </span> |
| 57 | <ul class="dropdown-menu play-speed-select" > | 57 | <ul class="dropdown-menu play-speed-select" > |
| 58 | - <li data-speed=10><a href="javascript:;">10秒 </a></li> | ||
| 59 | - <li data-speed=5><a href="javascript:;">5秒 </a></li> | ||
| 60 | - <li data-speed=1><a href="javascript:;">1秒</a></li> | 58 | + <li data-speed=30><a href="javascript:;">1秒30帧 </a></li> |
| 59 | + <li data-speed=20><a href="javascript:;">1秒20帧 </a></li> | ||
| 60 | + <li data-speed=10><a href="javascript:;">1秒10帧 </a></li> | ||
| 61 | + <li data-speed=7><a href="javascript:;">1秒7帧 </a></li> | ||
| 62 | + <li data-speed=5><a href="javascript:;">1秒5帧 </a></li> | ||
| 63 | + <li data-speed=1><a href="javascript:;">1秒1帧 </a></li> | ||
| 61 | </ul> | 64 | </ul> |
| 62 | </div> | 65 | </div> |
| 63 | 66 |
src/main/resources/static/pages/mapmonitor/real/temps/playBack.html
| @@ -8,7 +8,8 @@ | @@ -8,7 +8,8 @@ | ||
| 8 | <div class="form-group"> | 8 | <div class="form-group"> |
| 9 | <label class="col-md-3 control-label">车辆编码</label> | 9 | <label class="col-md-3 control-label">车辆编码</label> |
| 10 | <div class="col-md-9"> | 10 | <div class="col-md-9"> |
| 11 | - <select class="form-control" name="nbbm[]" placeholder="车辆编码" multiple="multiple" required=1 style="width:100%;"></select> | 11 | + <select class="form-control" name="nbbm[]" placeholder="车辆编码" multiple="multiple" required=1 style="width:100%;"> |
| 12 | + </select> | ||
| 12 | </div> | 13 | </div> |
| 13 | </div> | 14 | </div> |
| 14 | 15 | ||
| @@ -26,15 +27,21 @@ | @@ -26,15 +27,21 @@ | ||
| 26 | <input type="time" name="eTime" class="form-control" placeholder="时间" required=1> | 27 | <input type="time" name="eTime" class="form-control" placeholder="时间" required=1> |
| 27 | </div> | 28 | </div> |
| 28 | </div> | 29 | </div> |
| 29 | - </div> | ||
| 30 | -</form> | ||
| 31 | -<form class="form-horizontal" role="form" style="padding-top: 0px;"> | 30 | + |
| 32 | <div class="form-group"> | 31 | <div class="form-group"> |
| 33 | - <label class="col-md-3 control-label">线路图层</label> | 32 | + <label class="col-md-3 control-label"></label> |
| 34 | <div class="col-md-9"> | 33 | <div class="col-md-9"> |
| 35 | - <select class="form-control" name="lineCode" style="width:100%;"></select> | 34 | + <div class="checkbox-list" style="font-size: 13px;"> |
| 35 | + <label> | ||
| 36 | + <div class="checker" style="display: inline-block;vertical-align: middle;"> | ||
| 37 | + <span> | ||
| 38 | + <input type="checkbox" name="enableFocus"> | ||
| 39 | + </span> | ||
| 40 | + </div> 当前选中的首辆车为焦点 </label> | ||
| 41 | + </div> | ||
| 36 | </div> | 42 | </div> |
| 37 | </div> | 43 | </div> |
| 44 | + </div> | ||
| 38 | </form> | 45 | </form> |
| 39 | <hr> | 46 | <hr> |
| 40 | <div class="form-actions"> | 47 | <div class="form-actions"> |
| @@ -44,4 +51,4 @@ | @@ -44,4 +51,4 @@ | ||
| 44 | </div> | 51 | </div> |
| 45 | </div> | 52 | </div> |
| 46 | </div> | 53 | </div> |
| 47 | -</script> | ||
| 48 | \ No newline at end of file | 54 | \ No newline at end of file |
| 55 | +</script> |
src/main/resources/static/pages/mapmonitor/real/temps/vehicle.html
| @@ -88,6 +88,6 @@ | @@ -88,6 +88,6 @@ | ||
| 88 | 下一班{{nextSch.qdzName}} {{nextSch.fcsj}} 发车 | 88 | 下一班{{nextSch.qdzName}} {{nextSch.fcsj}} 发车 |
| 89 | {{/if}} | 89 | {{/if}} |
| 90 | </p> | 90 | </p> |
| 91 | -<a href="javascript:void(0)" style="color:#006600;font-size:12px;">轨迹回放</a> | 91 | +<a href="javascript:vehiclePanel.toPlayBack('{{nbbm}}', '{{lineId}}')" class="link_to_pback" style="color:#006600;font-size:12px;">轨迹回放</a> |
| 92 | </div> | 92 | </div> |
| 93 | </script> | 93 | </script> |
| 94 | \ No newline at end of file | 94 | \ No newline at end of file |