Commit 1c14c85c4185434861192d9e813f562d8c3eb8fc

Authored by 王通
1 parent 9e555437

1.

src/main/java/com/bsth/data/gpsdata_v2/DataHandleProcess.java
... ... @@ -7,6 +7,7 @@ import com.bsth.data.gpsdata_v2.handlers.*;
7 7 import com.bsth.email.SendEmailController;
8 8 import com.bsth.email.entity.EmailBean;
9 9 import com.bsth.util.IpUtils;
  10 +import com.fasterxml.jackson.databind.JsonNode;
10 11 import com.fasterxml.jackson.databind.ObjectMapper;
11 12 import com.google.common.collect.ArrayListMultimap;
12 13 import org.apache.commons.lang3.StringUtils;
... ... @@ -94,10 +95,10 @@ public class DataHandleProcess {
94 95 dataListMap.putAll(threadIndex, multimap.get(deviceList.get(i)));
95 96 }
96 97 Set<Integer> ks = dataListMap.keySet();
97   - logger.info("analyse gps size: " + list.size() + ", ks: " + ks.size());
  98 + logger.info("gps: " + JSON.toJSONString(list));
98 99 CountDownLatch count = new CountDownLatch(ks.size());
99 100  
100   - logger.info(JSON.toJSONString(ks));
  101 + logger.info("ks: " + JSON.toJSONString(ks));
101 102 for (Integer index : ks) {
102 103 threadPool.execute(new SignalHandleThread(dataListMap.get(index), count));
103 104 }
... ...
src/main/java/com/bsth/data/gpsdata_v2/entity/GpsEntity.java
... ... @@ -118,6 +118,11 @@ public class GpsEntity implements Cloneable{
118 118 */
119 119 private int energy = -1;
120 120  
  121 + /**
  122 + * 站内外 -1无效 0站外 1站内
  123 + */
  124 + private int inOrOutStation;
  125 +
121 126 public Object clone() {
122 127 try {
123 128 return super.clone();
... ... @@ -418,4 +423,12 @@ public class GpsEntity implements Cloneable{
418 423 public void setEnergy(int energy) {
419 424 this.energy = energy;
420 425 }
  426 +
  427 + public int getInOrOutStation() {
  428 + return inOrOutStation;
  429 + }
  430 +
  431 + public void setInOrOutStation(int inOrOutStation) {
  432 + this.inOrOutStation = inOrOutStation;
  433 + }
421 434 }
... ...
src/main/java/com/bsth/data/gpsdata_v2/handlers/StationInsideProcess.java
1   -package com.bsth.data.gpsdata_v2.handlers;
2   -
3   -import com.bsth.data.gpsdata_v2.cache.GeoCacheData;
4   -import com.bsth.data.gpsdata_v2.cache.GpsCacheData;
5   -import com.bsth.data.gpsdata_v2.entity.GpsEntity;
6   -import com.bsth.data.gpsdata_v2.entity.StationRoute;
7   -import com.bsth.data.gpsdata_v2.utils.GeoUtils;
8   -import org.springframework.stereotype.Component;
9   -
10   -import java.util.List;
11   -
12   -/**
13   - * 站内 场内判定
14   - * Created by panzhao on 2017/11/16.
15   - */
16   -@Component
17   -public class StationInsideProcess {
18   -
19   - public void process(GpsEntity gps) {
20   - //是否在场内
21   - String parkCode = GeoUtils.gpsInCarpark(gps);
22   -
23   - if (parkCode != null) {
24   - gps.setInstation(2);
25   - gps.setStopNo(parkCode);
26   - gps.setCarparkNo(parkCode);
27   - }
28   -
29   - //是否在站内
30   - List<StationRoute> srs = GeoCacheData.getStationRoute(gps.getLineId(), gps.getUpDown());
31   - StationRoute station = GeoUtils.gpsInStation(gps, srs);
32   - if (station != null) {
33   - gps.setInstation(1);
34   - gps.setStopNo(station.getCode());
35   - gps.setStation(station);
36   - }
37   -
38   - //是否在进站前置围栏内
39   - String premiseCode = GeoUtils.gpsInPremiseGeo(gps);
40   - gps.setPremiseCode(premiseCode);
41   -
42   - //上一个点位
43   - GpsEntity prev = GpsCacheData.getPrev(gps);
44   -
45   - if (null != prev) {
46   - //继承前置围栏状态
47   - if (null == premiseCode && null != prev.getPremiseCode())
48   - gps.setPremiseCode(prev.getPremiseCode());
49   -
50   - //在场,站外
51   - if (gps.getInstation() == 0) {
52   - gps.setStopNo(prev.getStopNo());//继承上一个点的站点编码
53   - }
54   - }
55   - }
56   -}
  1 +package com.bsth.data.gpsdata_v2.handlers;
  2 +
  3 +import com.bsth.data.gpsdata_v2.cache.GeoCacheData;
  4 +import com.bsth.data.gpsdata_v2.cache.GpsCacheData;
  5 +import com.bsth.data.gpsdata_v2.entity.GpsEntity;
  6 +import com.bsth.data.gpsdata_v2.entity.StationRoute;
  7 +import com.bsth.data.gpsdata_v2.utils.GeoUtils;
  8 +import com.bsth.entity.Station;
  9 +import org.springframework.stereotype.Component;
  10 +
  11 +import java.util.List;
  12 +
  13 +/**
  14 + * 站内 场内判定
  15 + * Created by panzhao on 2017/11/16.
  16 + */
  17 +@Component
  18 +public class StationInsideProcess {
  19 +
  20 + public void process(GpsEntity gps) {
  21 + //是否在场内
  22 + String parkCode = GeoUtils.gpsInCarpark(gps);
  23 +
  24 + if (parkCode != null) {
  25 + gps.setInstation(2);
  26 + gps.setCarparkNo(parkCode);
  27 + }
  28 +
  29 + //是否在站内
  30 + List<StationRoute> srs = GeoCacheData.getStationRoute(gps.getLineId(), gps.getUpDown());
  31 + StationRoute station = null;
  32 + for (StationRoute sr : srs) {
  33 + if (sr.getCode().equals(gps.getStopNo())) {
  34 + station = sr;
  35 + }
  36 + }
  37 + if (gps.getInOrOutStation() == 1) {
  38 + gps.setInstation(1);
  39 + gps.setStation(station);
  40 + }
  41 +
  42 + //是否在进站前置围栏内
  43 + String premiseCode = GeoUtils.gpsInPremiseGeo(gps);
  44 + gps.setPremiseCode(premiseCode);
  45 +
  46 + //上一个点位
  47 + GpsEntity prev = GpsCacheData.getPrev(gps);
  48 +
  49 + if (null != prev) {
  50 + //继承前置围栏状态
  51 + if (null == premiseCode && null != prev.getPremiseCode())
  52 + gps.setPremiseCode(prev.getPremiseCode());
  53 +
  54 + //在场,站外
  55 + if (gps.getInstation() == 0) {
  56 + gps.setStopNo(prev.getStopNo());//继承上一个点的站点编码
  57 + }
  58 + }
  59 + }
  60 +}
... ...