Commit c9a98e8c456e5fb7c90ed2f51cfff07d7d0df42d

Authored by 潘钊
1 parent fcf32e92

update...

src/main/java/com/bsth/controller/gps/GpsController.java
@@ -3,6 +3,8 @@ package com.bsth.controller.gps; @@ -3,6 +3,8 @@ package com.bsth.controller.gps;
3 import com.bsth.data.BasicData; 3 import com.bsth.data.BasicData;
4 import com.bsth.data.gpsdata_v2.GpsRealData; 4 import com.bsth.data.gpsdata_v2.GpsRealData;
5 import com.bsth.data.gpsdata_v2.entity.GpsEntity; 5 import com.bsth.data.gpsdata_v2.entity.GpsEntity;
  6 +import com.bsth.data.gpsdata_v2.handlers.overspeed.GpsOverspeed;
  7 +import com.bsth.data.gpsdata_v2.handlers.overspeed.OverspeedProcess;
6 import com.bsth.service.gps.GpsService; 8 import com.bsth.service.gps.GpsService;
7 import com.bsth.service.gps.entity.GpsSpeed; 9 import com.bsth.service.gps.entity.GpsSpeed;
8 import com.google.common.base.Splitter; 10 import com.google.common.base.Splitter;
@@ -12,6 +14,7 @@ import org.springframework.web.bind.annotation.*; @@ -12,6 +14,7 @@ import org.springframework.web.bind.annotation.*;
12 import javax.servlet.http.HttpServletResponse; 14 import javax.servlet.http.HttpServletResponse;
13 import java.text.ParseException; 15 import java.text.ParseException;
14 import java.util.ArrayList; 16 import java.util.ArrayList;
  17 +import java.util.HashMap;
15 import java.util.List; 18 import java.util.List;
16 import java.util.Map; 19 import java.util.Map;
17 20
@@ -25,6 +28,9 @@ public class GpsController { @@ -25,6 +28,9 @@ public class GpsController {
25 @Autowired 28 @Autowired
26 GpsService gpsService; 29 GpsService gpsService;
27 30
  31 + @Autowired
  32 + OverspeedProcess overspeedProcess;
  33 +
28 @RequestMapping(value = "/real/all") 34 @RequestMapping(value = "/real/all")
29 public Map<String, Object> search(@RequestParam Map<String, Object> map, 35 public Map<String, Object> search(@RequestParam Map<String, Object> map,
30 @RequestParam(defaultValue = "0") int page, 36 @RequestParam(defaultValue = "0") int page,
@@ -42,8 +48,17 @@ public class GpsController { @@ -42,8 +48,17 @@ public class GpsController {
42 } 48 }
43 49
44 @RequestMapping(value = "/real/line") 50 @RequestMapping(value = "/real/line")
45 - public List<GpsEntity> findByLineCodes(@RequestParam String lineCodes) {  
46 - return gpsRealData.get(Splitter.on(",").splitToList(lineCodes)); 51 + public Map<String, Object> findByLineCodes(@RequestParam String lineCodes) {
  52 + Map<String, Object> rs = new HashMap();
  53 + List<String> lineArray = Splitter.on(",").splitToList(lineCodes);
  54 + //实时gps
  55 + List<GpsEntity> gpsList = gpsRealData.get(lineArray);
  56 +
  57 + //超速信息
  58 + List<GpsOverspeed> overspeedList = overspeedProcess.findByLines(lineArray);
  59 + rs.put("gpsList", gpsList);
  60 + rs.put("overspeedList", overspeedList);
  61 + return rs;
47 } 62 }
48 63
49 @RequestMapping(value = "/allDevices") 64 @RequestMapping(value = "/allDevices")
src/main/java/com/bsth/data/gpsdata_v2/DataHandleProcess.java
1 package com.bsth.data.gpsdata_v2; 1 package com.bsth.data.gpsdata_v2;
2 2
  3 +import com.alibaba.fastjson.JSON;
3 import com.bsth.data.gpsdata_v2.cache.GpsCacheData; 4 import com.bsth.data.gpsdata_v2.cache.GpsCacheData;
4 import com.bsth.data.gpsdata_v2.entity.GpsEntity; 5 import com.bsth.data.gpsdata_v2.entity.GpsEntity;
5 import com.bsth.data.gpsdata_v2.handlers.*; 6 import com.bsth.data.gpsdata_v2.handlers.*;
@@ -11,7 +12,9 @@ import org.springframework.beans.factory.annotation.Autowired; @@ -11,7 +12,9 @@ import org.springframework.beans.factory.annotation.Autowired;
11 import org.springframework.stereotype.Component; 12 import org.springframework.stereotype.Component;
12 13
13 import java.util.*; 14 import java.util.*;
14 -import java.util.concurrent.*; 15 +import java.util.concurrent.CountDownLatch;
  16 +import java.util.concurrent.ExecutorService;
  17 +import java.util.concurrent.Executors;
15 18
16 /** 19 /**
17 * 实时信号数据处理 20 * 实时信号数据处理
@@ -38,7 +41,7 @@ public class DataHandleProcess { @@ -38,7 +41,7 @@ public class DataHandleProcess {
38 41
39 static Logger logger = LoggerFactory.getLogger(DataHandleProcess.class); 42 static Logger logger = LoggerFactory.getLogger(DataHandleProcess.class);
40 43
41 - final static int POOL_SIZE = 25; 44 + final static int POOL_SIZE = 20;
42 45
43 static ExecutorService threadPool = Executors.newFixedThreadPool(POOL_SIZE + 1); 46 static ExecutorService threadPool = Executors.newFixedThreadPool(POOL_SIZE + 1);
44 public static CountDownLatch count; 47 public static CountDownLatch count;
@@ -73,9 +76,10 @@ public class DataHandleProcess { @@ -73,9 +76,10 @@ public class DataHandleProcess {
73 logger.info("analyse gps size: " + list.size() + ", ks: " + ks.size()); 76 logger.info("analyse gps size: " + list.size() + ", ks: " + ks.size());
74 count = new CountDownLatch(ks.size()); 77 count = new CountDownLatch(ks.size());
75 78
76 - List<Future> fRs = new ArrayList<>(ks.size()); 79 + logger.info(JSON.toJSONString(ks));
77 for (Integer index : ks) { 80 for (Integer index : ks) {
78 - threadPool.submit(new SignalHandleThread(dataListMap.get(index), count)); 81 + //logger.info("execute index: " + index);
  82 + threadPool.execute(new SignalHandleThread(dataListMap.get(index), count));
79 } 83 }
80 84
81 85
@@ -108,7 +112,13 @@ public class DataHandleProcess { @@ -108,7 +112,13 @@ public class DataHandleProcess {
108 public void run() { 112 public void run() {
109 try { 113 try {
110 Collections.sort(list, comp); 114 Collections.sort(list, comp);
111 - for (GpsEntity gps : list) { 115 + //logger.info("sort end --" + Thread.currentThread().getName() + " -list size: " + list.size());
  116 +
  117 + GpsEntity gps;
  118 + for(int i = 0,len = list.size(); i< len ;i ++){
  119 + gps = list.get(i);
  120 +
  121 + //logger.info("run |--" + Thread.currentThread().getName() + " -i: " + i);
112 try { 122 try {
113 if (StringUtils.isEmpty(gps.getNbbm())) 123 if (StringUtils.isEmpty(gps.getNbbm()))
114 continue; 124 continue;
@@ -123,16 +133,21 @@ public class DataHandleProcess { @@ -123,16 +133,21 @@ public class DataHandleProcess {
123 inStationProcess.process(gps);//进站 133 inStationProcess.process(gps);//进站
124 outStationProcess.process(gps);//出站 134 outStationProcess.process(gps);//出站
125 135
  136 +
  137 + //logger.info("put start --" + Thread.currentThread().getName() + " -i: " + i);
126 GpsCacheData.putGps(gps);//历史gps缓存 138 GpsCacheData.putGps(gps);//历史gps缓存
127 - } catch (Exception e) { 139 + //logger.info("put end --" + Thread.currentThread().getName() + " -i: " + i);
  140 + } catch (Throwable e) {
128 logger.error("", e); 141 logger.error("", e);
129 } 142 }
130 } 143 }
131 144
  145 + //logger.info("for end --" + Thread.currentThread().getName() + " -list size: " + list.size());
  146 +
132 } finally { 147 } finally {
133 if (count != null) 148 if (count != null)
134 count.countDown(); 149 count.countDown();
135 - logger.info(Thread.currentThread().getName() + " -countDown : " + count.getCount()); 150 + //logger.info(Thread.currentThread().getName() + " -countDown : " + count.getCount());
136 } 151 }
137 } 152 }
138 } 153 }
src/main/java/com/bsth/data/gpsdata_v2/handlers/AbnormalStateProcess.java
@@ -3,8 +3,10 @@ package com.bsth.data.gpsdata_v2.handlers; @@ -3,8 +3,10 @@ package com.bsth.data.gpsdata_v2.handlers;
3 import com.bsth.data.gpsdata_v2.cache.GeoCacheData; 3 import com.bsth.data.gpsdata_v2.cache.GeoCacheData;
4 import com.bsth.data.gpsdata_v2.entity.CtLineString; 4 import com.bsth.data.gpsdata_v2.entity.CtLineString;
5 import com.bsth.data.gpsdata_v2.entity.GpsEntity; 5 import com.bsth.data.gpsdata_v2.entity.GpsEntity;
  6 +import com.bsth.data.gpsdata_v2.handlers.overspeed.OverspeedProcess;
6 import com.bsth.data.gpsdata_v2.utils.GeoUtils; 7 import com.bsth.data.gpsdata_v2.utils.GeoUtils;
7 import com.bsth.util.Geo.Point; 8 import com.bsth.util.Geo.Point;
  9 +import org.springframework.beans.factory.annotation.Autowired;
8 import org.springframework.stereotype.Component; 10 import org.springframework.stereotype.Component;
9 11
10 import java.util.List; 12 import java.util.List;
@@ -17,19 +19,18 @@ import java.util.List; @@ -17,19 +19,18 @@ import java.util.List;
17 public class AbnormalStateProcess { 19 public class AbnormalStateProcess {
18 20
19 /** 21 /**
20 - * 默认限速  
21 - */  
22 - private static final double DEFAULT_SPEED_LIMIT = 60;  
23 - /**  
24 * 越界阈值 22 * 越界阈值
25 */ 23 */
26 private static final double OUT_BOUNDS_THRESHOLD = 100; 24 private static final double OUT_BOUNDS_THRESHOLD = 100;
27 25
  26 + @Autowired
  27 + OverspeedProcess overspeedProcess;
  28 +
28 public void process(GpsEntity gps) { 29 public void process(GpsEntity gps) {
29 if (isOffline(gps)) 30 if (isOffline(gps))
30 return; 31 return;
31 32
32 - if (overspeed(gps)) 33 + if (overspeedProcess.process(gps))
33 return; 34 return;
34 35
35 if (outOfBounds((gps))) 36 if (outOfBounds((gps)))
@@ -41,14 +42,14 @@ public class AbnormalStateProcess { @@ -41,14 +42,14 @@ public class AbnormalStateProcess {
41 } 42 }
42 43
43 44
44 - /** 45 +/* *//**
45 * 是否超速 46 * 是否超速
46 * 47 *
47 * @param gps 48 * @param gps
48 * @return 49 * @return
49 - */ 50 +
50 private boolean overspeed(GpsEntity gps) { 51 private boolean overspeed(GpsEntity gps) {
51 - double maxSpeed = DEFAULT_SPEED_LIMIT; 52 + *//*double maxSpeed = DEFAULT_SPEED_LIMIT;
52 if (GeoCacheData.speedLimit(gps.getLineId()) != null) 53 if (GeoCacheData.speedLimit(gps.getLineId()) != null)
53 maxSpeed = GeoCacheData.speedLimit(gps.getLineId()); 54 maxSpeed = GeoCacheData.speedLimit(gps.getLineId());
54 55
@@ -56,8 +57,9 @@ public class AbnormalStateProcess { @@ -56,8 +57,9 @@ public class AbnormalStateProcess {
56 gps.setAbnormalStatus("overspeed"); 57 gps.setAbnormalStatus("overspeed");
57 return true; 58 return true;
58 } 59 }
59 - return false;  
60 - } 60 + return false;*//*
  61 + return overspeedProcess.process(gps);
  62 + }*/
61 63
62 64
63 /** 65 /**
src/main/java/com/bsth/data/gpsdata_v2/handlers/overspeed/GpsOverspeed.java 0 → 100644
  1 +package com.bsth.data.gpsdata_v2.handlers.overspeed;
  2 +
  3 +/**
  4 + * gps 超速信息
  5 + * Created by panzhao on 2018/1/9.
  6 + */
  7 +public class GpsOverspeed {
  8 +
  9 + private String device;
  10 +
  11 + private String nbbm;
  12 +
  13 + private String lineCode;
  14 +
  15 + /**
  16 + * 开始超速时间 HH:mm
  17 + */
  18 + private String sts;
  19 +
  20 + private long st;
  21 +
  22 + /**
  23 + * 结束超速时间 HH:mm
  24 + */
  25 + private String ets;
  26 +
  27 + /**
  28 + * 最新速度值
  29 + */
  30 + private float speed;
  31 +
  32 + /**
  33 + * 0:结束超速, 1:离线
  34 + */
  35 + private int eType;
  36 +
  37 + public String getDevice() {
  38 + return device;
  39 + }
  40 +
  41 + public void setDevice(String device) {
  42 + this.device = device;
  43 + }
  44 +
  45 + public String getNbbm() {
  46 + return nbbm;
  47 + }
  48 +
  49 + public void setNbbm(String nbbm) {
  50 + this.nbbm = nbbm;
  51 + }
  52 +
  53 + public String getLineCode() {
  54 + return lineCode;
  55 + }
  56 +
  57 + public void setLineCode(String lineCode) {
  58 + this.lineCode = lineCode;
  59 + }
  60 +
  61 + public String getSts() {
  62 + return sts;
  63 + }
  64 +
  65 + public void setSts(String sts) {
  66 + this.sts = sts;
  67 + }
  68 +
  69 + public long getSt() {
  70 + return st;
  71 + }
  72 +
  73 + public void setSt(long st) {
  74 + this.st = st;
  75 + }
  76 +
  77 + public String getEts() {
  78 + return ets;
  79 + }
  80 +
  81 + public void setEts(String ets) {
  82 + this.ets = ets;
  83 + }
  84 +
  85 + public float getSpeed() {
  86 + return speed;
  87 + }
  88 +
  89 + public void setSpeed(float speed) {
  90 + this.speed = speed;
  91 + }
  92 +
  93 + public int geteType() {
  94 + return eType;
  95 + }
  96 +
  97 + public void seteType(int eType) {
  98 + this.eType = eType;
  99 + }
  100 +}
src/main/java/com/bsth/data/gpsdata_v2/handlers/overspeed/OverspeedProcess.java 0 → 100644
  1 +package com.bsth.data.gpsdata_v2.handlers.overspeed;
  2 +
  3 +import com.bsth.data.gpsdata_v2.cache.GeoCacheData;
  4 +import com.bsth.data.gpsdata_v2.entity.GpsEntity;
  5 +import com.google.common.collect.ArrayListMultimap;
  6 +import org.joda.time.format.DateTimeFormat;
  7 +import org.joda.time.format.DateTimeFormatter;
  8 +import org.slf4j.Logger;
  9 +import org.slf4j.LoggerFactory;
  10 +import org.springframework.stereotype.Component;
  11 +
  12 +import java.util.*;
  13 +
  14 +/**
  15 + * 超速处理
  16 + * Created by panzhao on 2018/1/9.
  17 + */
  18 +@Component
  19 +public class OverspeedProcess {
  20 +
  21 +
  22 + private static final double DEFAULT_SPEED_LIMIT = 60;
  23 +
  24 + private static final double INVALID_SPEED_LIMIT = 110;
  25 +
  26 + private static final int CONT_SPEED_SIZE = 6;
  27 +
  28 + private static DateTimeFormatter fmtHHmm = DateTimeFormat.forPattern("HH:mm");
  29 +
  30 + private static GpsOverspeedComp comp = new GpsOverspeedComp();
  31 + /**
  32 + * 按线路分组的超速信息
  33 + */
  34 + private static ArrayListMultimap<String, GpsOverspeed> multimap;
  35 +
  36 + /**
  37 + * 设备号 --> 当前超速
  38 + */
  39 + private static Map<String, GpsOverspeed> realOverspeedMap;
  40 +
  41 + /**
  42 + * 设备号 --> 连续超速次数
  43 + */
  44 + private static Map<String, Integer> contSpeedMap;
  45 +
  46 + Logger logger = LoggerFactory.getLogger(this.getClass());
  47 +
  48 + static{
  49 + multimap = ArrayListMultimap.create();
  50 + contSpeedMap = new HashMap();
  51 + realOverspeedMap = new HashMap();
  52 + }
  53 +
  54 + public static void clear(){
  55 + multimap = null;
  56 + multimap = ArrayListMultimap.create();
  57 +
  58 + contSpeedMap = null;
  59 + contSpeedMap = new HashMap();
  60 +
  61 + realOverspeedMap = null;
  62 + realOverspeedMap = new HashMap();
  63 + }
  64 +
  65 + public boolean process(GpsEntity gps){
  66 + if(gps.getSpeed() >= INVALID_SPEED_LIMIT){
  67 + return false;//无效的速度
  68 + }
  69 +
  70 + Double maxSpeed = GeoCacheData.speedLimit(gps.getLineId());
  71 + if(null == maxSpeed)
  72 + maxSpeed = DEFAULT_SPEED_LIMIT;
  73 +
  74 + if(gps.getSpeed() > maxSpeed){
  75 + overspeed(gps, maxSpeed);
  76 + }
  77 + else if(realOverspeedMap.containsKey(gps.getDeviceId())){
  78 + String device = gps.getDeviceId();
  79 + //结束超速
  80 + GpsOverspeed sp = realOverspeedMap.get(device);
  81 + sp.setEts(fmtHHmm.print(gps.getTimestamp()));
  82 +
  83 + realOverspeedMap.remove(device);
  84 + contSpeedMap.put(device, 0);
  85 + }
  86 + return false;
  87 + }
  88 +
  89 + private void overspeed(GpsEntity gps, Double maxSpeed) {
  90 + String device = gps.getDeviceId();
  91 + Integer cont = contSpeedMap.get(device);
  92 +
  93 + if(null == cont)
  94 + cont = 1;
  95 +
  96 + cont++;
  97 +
  98 + if(gps.getSpeed() - maxSpeed > (maxSpeed * 0.1))
  99 + cont++;
  100 +
  101 + if(cont >= CONT_SPEED_SIZE){
  102 + if(realOverspeedMap.containsKey(device)){
  103 + //正在超速,更新速度
  104 + realOverspeedMap.get(device).setSpeed(gps.getSpeed());
  105 + }
  106 + else{
  107 + logger.info("开始超速..." + gps.getNbbm());
  108 + GpsOverspeed sp = new GpsOverspeed();
  109 + sp.setLineCode(gps.getLineId());
  110 + sp.setDevice(device);
  111 + sp.setSpeed(gps.getSpeed());
  112 + sp.setNbbm(gps.getNbbm());
  113 + sp.setSts(fmtHHmm.print(gps.getTimestamp()));
  114 + sp.setSt(gps.getTimestamp());
  115 +
  116 + realOverspeedMap.put(device, sp);
  117 + multimap.put(sp.getLineCode(), sp);
  118 + }
  119 + //标记gps超速
  120 + gps.setAbnormalStatus("overspeed");
  121 + }
  122 +
  123 + contSpeedMap.put(device, cont);
  124 + }
  125 +
  126 + /**
  127 + * 设备掉线
  128 + * @param device
  129 + */
  130 + public void offline(String device){
  131 + if(realOverspeedMap.containsKey(device)){
  132 + //结束超速
  133 + GpsOverspeed sp = realOverspeedMap.get(device);
  134 + sp.setEts(fmtHHmm.print(System.currentTimeMillis()));
  135 + sp.seteType(1);
  136 +
  137 + realOverspeedMap.remove(device);
  138 + contSpeedMap.put(device, 0);
  139 + }
  140 + }
  141 +
  142 +
  143 + public List<GpsOverspeed> findByLines(List<String> lineArray){
  144 + List<GpsOverspeed> rs = new ArrayList<>();
  145 +
  146 + for(String code : lineArray){
  147 + rs.addAll(multimap.get(code));
  148 + }
  149 +
  150 + //按发送时间排序
  151 + Collections.sort(rs, comp);
  152 + if(rs.size() > 50)
  153 + rs = rs.subList(0, 50);
  154 +
  155 + return rs;
  156 + }
  157 +
  158 +
  159 + public static class GpsOverspeedComp implements Comparator<GpsOverspeed>{
  160 +
  161 + @Override
  162 + public int compare(GpsOverspeed o1, GpsOverspeed o2) {
  163 + return (int) (o2.getSt() - o1.getSt());
  164 + }
  165 + }
  166 +}
src/main/java/com/bsth/data/gpsdata_v2/thread/OfflineMonitorThread.java
@@ -2,6 +2,7 @@ package com.bsth.data.gpsdata_v2.thread; @@ -2,6 +2,7 @@ package com.bsth.data.gpsdata_v2.thread;
2 2
3 import com.bsth.data.gpsdata_v2.GpsRealData; 3 import com.bsth.data.gpsdata_v2.GpsRealData;
4 import com.bsth.data.gpsdata_v2.entity.GpsEntity; 4 import com.bsth.data.gpsdata_v2.entity.GpsEntity;
  5 +import com.bsth.data.gpsdata_v2.handlers.overspeed.OverspeedProcess;
5 import com.bsth.websocket.handler.SendUtils; 6 import com.bsth.websocket.handler.SendUtils;
6 import org.slf4j.Logger; 7 import org.slf4j.Logger;
7 import org.slf4j.LoggerFactory; 8 import org.slf4j.LoggerFactory;
@@ -28,6 +29,9 @@ public class OfflineMonitorThread extends Thread{ @@ -28,6 +29,9 @@ public class OfflineMonitorThread extends Thread{
28 @Autowired 29 @Autowired
29 SendUtils sendUtils; 30 SendUtils sendUtils;
30 31
  32 + @Autowired
  33 + OverspeedProcess overspeedProcess;
  34 +
31 //无任务时 离线阈值 35 //无任务时 离线阈值
32 //private final static int OFFLINE_TIME = 1000 * 60 * 10; 36 //private final static int OFFLINE_TIME = 1000 * 60 * 10;
33 37
@@ -47,6 +51,8 @@ public class OfflineMonitorThread extends Thread{ @@ -47,6 +51,8 @@ public class OfflineMonitorThread extends Thread{
47 if (t - gps.getTimestamp() > LOSE_TIME){ 51 if (t - gps.getTimestamp() > LOSE_TIME){
48 gps.offline(); 52 gps.offline();
49 53
  54 + //结束超速
  55 + overspeedProcess.offline(gps.getDeviceId());
50 //通知页面有设备掉线 56 //通知页面有设备掉线
51 sendUtils.deviceOffline(gps); 57 sendUtils.deviceOffline(gps);
52 } 58 }
src/main/java/com/bsth/data/schedule/thread/CalcOilThread.java
1 package com.bsth.data.schedule.thread; 1 package com.bsth.data.schedule.thread;
2 2
  3 +import com.bsth.data.gpsdata_v2.handlers.overspeed.OverspeedProcess;
3 import com.bsth.service.oil.DlbService; 4 import com.bsth.service.oil.DlbService;
4 import com.bsth.data.safe_driv.SafeDrivCenter; 5 import com.bsth.data.safe_driv.SafeDrivCenter;
5 import com.bsth.service.oil.YlbService; 6 import com.bsth.service.oil.YlbService;
@@ -38,6 +39,8 @@ public class CalcOilThread extends Thread{ @@ -38,6 +39,8 @@ public class CalcOilThread extends Thread{
38 logger.info("计算班次准点率结束!"); 39 logger.info("计算班次准点率结束!");
39 //清除安全驾驶数据 先临时蹭这个线程 40 //清除安全驾驶数据 先临时蹭这个线程
40 SafeDrivCenter.clear(); 41 SafeDrivCenter.clear();
  42 + //清除超速缓存数据
  43 + OverspeedProcess.clear();
41 } catch(Exception e){ 44 } catch(Exception e){
42 logger.error("计算路单里程加注量失败",e); 45 logger.error("计算路单里程加注量失败",e);
43 } 46 }
src/main/resources/static/real_control_v2/alone_page/map/alone_data_gps.js
@@ -41,7 +41,7 @@ var gb_data_gps = (function () { @@ -41,7 +41,7 @@ var gb_data_gps = (function () {
41 upDownChange = []; 41 upDownChange = [];
42 42
43 var schArray; 43 var schArray;
44 - $.each(rs, function () { 44 + $.each(rs.gpsList, function () {
45 old = realData[this.deviceId]; 45 old = realData[this.deviceId];
46 if (old) { 46 if (old) {
47 if (this.timestamp > old.timestamp) { 47 if (this.timestamp > old.timestamp) {
@@ -54,12 +54,12 @@ var gb_data_gps = (function () { @@ -54,12 +54,12 @@ var gb_data_gps = (function () {
54 } else 54 } else
55 addArr.push(this); 55 addArr.push(this);
56 56
57 - /* //班次信息 57 + //班次信息
58 if (this.schId) { 58 if (this.schId) {
59 schArray = gb_schedule_table.findScheduleByLine(this.lineId); 59 schArray = gb_schedule_table.findScheduleByLine(this.lineId);
60 if (schArray) 60 if (schArray)
61 this.sch = schArray[this.schId]; 61 this.sch = schArray[this.schId];
62 - }*/ 62 + }
63 63
64 //时间格式化 64 //时间格式化
65 this.dateStr = moment(this.timestamp).format('YYYY-MM-DD HH:mm:ss'); 65 this.dateStr = moment(this.timestamp).format('YYYY-MM-DD HH:mm:ss');
@@ -69,9 +69,12 @@ var gb_data_gps = (function () { @@ -69,9 +69,12 @@ var gb_data_gps = (function () {
69 //console.log('add array size: ' + addArr.length, 'up array size: ' + upArr.length); 69 //console.log('add array size: ' + addArr.length, 'up array size: ' + upArr.length);
70 //CCCallFuncN 70 //CCCallFuncN
71 $.each(refreshEventCallbacks, function (i, cb) { 71 $.each(refreshEventCallbacks, function (i, cb) {
72 - cb(addArr, upArr, upDownChange); 72 + cb(addArr, upArr, upDownChange, rs.overspeedList);
73 }); 73 });
74 74
  75 + //超速数据回调
  76 + //console.log('超速,,,', rs.overspeedList);
  77 +
75 }; 78 };
76 79
77 var startFixedTime; 80 var startFixedTime;
src/main/resources/static/real_control_v2/css/main.css
@@ -1754,4 +1754,50 @@ dl.active&gt;dd.disabled{ @@ -1754,4 +1754,50 @@ dl.active&gt;dd.disabled{
1754 vertical-align: bottom; 1754 vertical-align: bottom;
1755 color: #ff2f2f; 1755 color: #ff2f2f;
1756 text-decoration: underline; 1756 text-decoration: underline;
  1757 +}
  1758 +
  1759 +.c_b_abnorm_notice {
  1760 + position: absolute;
  1761 + bottom: 0;
  1762 + margin: auto;
  1763 + width: 351px;
  1764 + padding: 7px;
  1765 + background: #ffffff;
  1766 + box-shadow: 5px 5px 15px rgba(90, 90, 90, 0.48);
  1767 + max-height: 290px;
  1768 + overflow-y: auto;
  1769 + min-height: 40px;
  1770 +}
  1771 +
  1772 +.c_b_abnorm_notice:before{
  1773 + content: "-超速报警-";
  1774 + color: #000000;
  1775 + font-size: 12px;
  1776 + font-family: 微软雅黑;
  1777 + position: fixed;
  1778 + background: #ffd967;
  1779 + margin-top: -10px;
  1780 + margin-left: -6px;
  1781 + padding: 0 7px;
  1782 + box-shadow: 2px 4px 7px rgba(90, 90, 90, 0.25);
  1783 +}
  1784 +
  1785 +.c_b_item {
  1786 + margin: 7px 0;
  1787 + padding: 7px 12px;
  1788 + box-shadow: 0px 0px 10px rgba(90, 90, 90, 0.29);
  1789 + color: #FF5722;
  1790 + cursor: pointer;
  1791 +}
  1792 +
  1793 +.c_b_abnorm_notice>.c_b_item:first-child{
  1794 + margin-top: 20px;
  1795 +}
  1796 +
  1797 +.c_b_item.over{
  1798 + color: grey;
  1799 +}
  1800 +
  1801 +.c_b_item>span.c_b_over{
  1802 + float: right;
1757 } 1803 }
1758 \ No newline at end of file 1804 \ No newline at end of file
src/main/resources/static/real_control_v2/js/data/data_gps.js
@@ -14,6 +14,9 @@ var gb_data_gps = (function () { @@ -14,6 +14,9 @@ var gb_data_gps = (function () {
14 refreshEventCallbacks.push(cb); 14 refreshEventCallbacks.push(cb);
15 }; 15 };
16 16
  17 + //超速数据回调
  18 + //var overspeedEventCallbacks = [];
  19 +
17 var refresh = function (cb) { 20 var refresh = function (cb) {
18 $.ajax({ 21 $.ajax({
19 url: '/gps/real/line', 22 url: '/gps/real/line',
@@ -43,7 +46,7 @@ var gb_data_gps = (function () { @@ -43,7 +46,7 @@ var gb_data_gps = (function () {
43 upDownChange = []; 46 upDownChange = [];
44 47
45 var schArray; 48 var schArray;
46 - $.each(rs, function () { 49 + $.each(rs.gpsList, function () {
47 old = realData[this.deviceId]; 50 old = realData[this.deviceId];
48 if (old) { 51 if (old) {
49 if (this.timestamp > old.timestamp) { 52 if (this.timestamp > old.timestamp) {
@@ -71,9 +74,12 @@ var gb_data_gps = (function () { @@ -71,9 +74,12 @@ var gb_data_gps = (function () {
71 //console.log('add array size: ' + addArr.length, 'up array size: ' + upArr.length); 74 //console.log('add array size: ' + addArr.length, 'up array size: ' + upArr.length);
72 //CCCallFuncN 75 //CCCallFuncN
73 $.each(refreshEventCallbacks, function (i, cb) { 76 $.each(refreshEventCallbacks, function (i, cb) {
74 - cb(addArr, upArr, upDownChange); 77 + cb(addArr, upArr, upDownChange, rs.overspeedList);
75 }); 78 });
76 79
  80 + //超速数据回调
  81 + //console.log('超速,,,', rs.overspeedList);
  82 +
77 }; 83 };
78 84
79 var startFixedTime; 85 var startFixedTime;
src/main/resources/static/real_control_v2/mapmonitor/js/gps_tree.js
@@ -233,6 +233,10 @@ var gb_map_gps_tree = (function () { @@ -233,6 +233,10 @@ var gb_map_gps_tree = (function () {
233 var deviceId = gb_data_basic.nbbm2deviceMap()[data.value] 233 var deviceId = gb_data_basic.nbbm2deviceMap()[data.value]
234 ,gps = gb_data_gps.findOne(deviceId); 234 ,gps = gb_data_gps.findOne(deviceId);
235 235
  236 + if(gps.upDown==-1){
  237 + UIkit.notify(data.value + " 未知上下行!", {pos:'top-center'});
  238 + return;
  239 + }
236 //展开线路节点 240 //展开线路节点
237 tree.open_node(tree.get_node('map_tree_line_' + gps.lineId), function () { 241 tree.open_node(tree.get_node('map_tree_line_' + gps.lineId), function () {
238 //展开走向节点 242 //展开走向节点
@@ -287,6 +291,7 @@ var gb_map_gps_tree = (function () { @@ -287,6 +291,7 @@ var gb_map_gps_tree = (function () {
287 create_node: create_node, 291 create_node: create_node,
288 changeUpDown: changeUpDown, 292 changeUpDown: changeUpDown,
289 update_node: update_node, 293 update_node: update_node,
290 - refresh: refresh 294 + refresh: refresh,
  295 + selectitem: selectitem
291 }; 296 };
292 })(); 297 })();
293 \ No newline at end of file 298 \ No newline at end of file
src/main/resources/static/real_control_v2/mapmonitor/js/map_overlay_manager.js
@@ -7,7 +7,8 @@ var gb_map_overlay_mge = (function () { @@ -7,7 +7,8 @@ var gb_map_overlay_mge = (function () {
7 temps = gb_common.compileTempByDom(dom, {compress: true}); 7 temps = gb_common.compileTempByDom(dom, {compress: true});
8 }); 8 });
9 9
10 - var gpsRefresh = function (addArr, upArr, upDownChange) { 10 + var $abnormNoticePanel = $('.c_b_abnorm_notice');
  11 + var gpsRefresh = function (addArr, upArr, upDownChange, overspeedList) {
11 if(!$('.main-container .map-panel').is(':visible')) 12 if(!$('.main-container .map-panel').is(':visible'))
12 return; 13 return;
13 //如果地图正在重绘,暂时不刷新GPS 14 //如果地图正在重绘,暂时不刷新GPS
@@ -16,8 +17,28 @@ var gb_map_overlay_mge = (function () { @@ -16,8 +17,28 @@ var gb_map_overlay_mge = (function () {
16 //var all = addArr.concat(upArr).concat(upDownChange); 17 //var all = addArr.concat(upArr).concat(upDownChange);
17 gpsRefreshAll(addArr, upArr, upDownChange); 18 gpsRefreshAll(addArr, upArr, upDownChange);
18 19
  20 + //渲染超速信息
  21 + overspeedList.sort(overspeed_sort);
  22 + var htmlStr = template('map_abnorm_overspeed_list-temp', {list: overspeedList});
  23 + $abnormNoticePanel.html(htmlStr).scrollTop($abnormNoticePanel[0].scrollHeight);
19 }; 24 };
20 25
  26 + var overspeed_sort = function (a, b) {
  27 + if(a.ets && !b.ets)
  28 + return -1;
  29 + if(!a.ets && b.ets)
  30 + return 1;
  31 + return a.st - b.st;
  32 + };
  33 +
  34 + /**
  35 + * 超速点击
  36 + */
  37 + $abnormNoticePanel.on('click', '.c_b_item', function () {
  38 + var nbbm = $(this).data('nbbm');
  39 + gb_map_gps_tree.selectitem(null, {value: nbbm});
  40 + });
  41 +
21 var gpsRefreshAll = function (addArr, upArr, upDownChange) { 42 var gpsRefreshAll = function (addArr, upArr, upDownChange) {
22 //更新设备树菜单 43 //更新设备树菜单
23 if(gb_map_gps_tree.readyStatus()){ 44 if(gb_map_gps_tree.readyStatus()){
@@ -87,7 +108,11 @@ var gb_map_overlay_mge = (function () { @@ -87,7 +108,11 @@ var gb_map_overlay_mge = (function () {
87 108
88 gb_map_imap.call('clearAll'); 109 gb_map_imap.call('clearAll');
89 110
90 - drawAllSection(); 111 + try{
  112 + drawAllSection();
  113 + }catch (e){
  114 + console.log(e);
  115 + }
91 //重绘GPS 116 //重绘GPS
92 gb_map_imap.call('drawRealGpsMarker', {gpsList: gb_common.get_vals(gb_data_gps.allGps)}); 117 gb_map_imap.call('drawRealGpsMarker', {gpsList: gb_common.get_vals(gb_data_gps.allGps)});
93 118
src/main/resources/static/real_control_v2/mapmonitor/real.html
@@ -53,6 +53,21 @@ @@ -53,6 +53,21 @@
53 </div> 53 </div>
54 </div> 54 </div>
55 55
  56 +
  57 +<div class="c_b_abnorm_notice"></div>
  58 +
  59 +<script id="map_abnorm_overspeed_list-temp" type="text/html">
  60 + {{each list as obj i}}
  61 + <div class="c_b_item {{obj.ets!=null?'over':''}}" data-nbbm="{{obj.nbbm}}">
  62 + {{obj.sts}} - {{obj.nbbm}} 开始超速({{obj.speed}})
  63 +
  64 + {{if obj.ets!=null}}
  65 + <span class="c_b_over"> {{obj.ets}} 结束</span>
  66 + {{/if}}
  67 + </div>
  68 + {{/each}}
  69 +</script>
  70 +
56 <script src="/real_control_v2/assets/js/GeoUtils_min.js" merge="map_plugins"></script> 71 <script src="/real_control_v2/assets/js/GeoUtils_min.js" merge="map_plugins"></script>
57 <script src="/real_control_v2/mapmonitor/js/config.js" merge="map_custom_js"></script> 72 <script src="/real_control_v2/mapmonitor/js/config.js" merge="map_custom_js"></script>
58 <script src="/real_control_v2/mapmonitor/js/gps_tree.js" merge="map_custom_js"></script> 73 <script src="/real_control_v2/mapmonitor/js/gps_tree.js" merge="map_custom_js"></script>