Commit 37c2c8268c68cc9ea5f71ce638135eb2fba073c5

Authored by 徐烜
2 parents 20a5c6da 52b38105

Merge branch 'minhang' of http://222.66.0.204:8090//panzhaov5/bsth_control into minhang

Too many changes to show.

To preserve performance only 18 of 56 files are displayed.

src/main/java/com/bsth/controller/StationRouteController.java
... ... @@ -111,7 +111,6 @@ public class StationRouteController extends BaseController<StationRoute, Integer
111 111 */
112 112 @RequestMapping(value = "/findStationRouteInfo",method = RequestMethod.GET)
113 113 public List<Map<String, Object>> findStationRouteInfo(@RequestParam Map<String, Object> map) {
114   -
115 114 return service.findStationRouteInfo(map);
116 115 }
117 116  
... ... @@ -140,4 +139,13 @@ public class StationRouteController extends BaseController&lt;StationRoute, Integer
140 139 return service.updSwitchDir(lineIds);
141 140 }
142 141  
  142 + /**
  143 + *
  144 + * @Title: upddis
  145 + * @Description: TODO(更新站距)
  146 + */
  147 + @RequestMapping(value = "/upddis",method = RequestMethod.POST)
  148 + public Map<String, Object> upddis(@RequestParam Map<String, Object> map) {
  149 + return service.upddis(map);
  150 + }
143 151 }
... ...
src/main/java/com/bsth/data/safe_driv/SafeDriv.java 0 → 100644
  1 +package com.bsth.data.safe_driv;
  2 +
  3 +/**
  4 + * 安全驾驶
  5 + * Created by panzhao on 2017/4/6.
  6 + */
  7 +public class SafeDriv {
  8 +
  9 + /**
  10 + * 时间
  11 + * 2017-04-06 08:00:00.0
  12 + */
  13 + private String Startime;
  14 +
  15 + /**
  16 + * 时间戳
  17 + */
  18 + private Long ts;
  19 +
  20 + /**
  21 + * 设备编号
  22 + */
  23 + private String sbbh;
  24 +
  25 + /**
  26 + * 线路名称
  27 + */
  28 + private String xlmc;
  29 +
  30 + /**
  31 + * 车辆自编号
  32 + */
  33 + private String clzbh;
  34 +
  35 + /**
  36 + * 车牌号
  37 + */
  38 + private String cph;
  39 +
  40 + /**
  41 + * 检查属性
  42 + * 双脱手 0 单脱手 1 其他为0都是异常
  43 + */
  44 + private String jctype;
  45 +
  46 + /**
  47 + * 异常种类
  48 + * 手部检测: 1
  49 + * 脸部检测: 5
  50 + * 摄像头检测: 2
  51 + * 安全带检测: 3
  52 + * 袖章检测: 4
  53 + */
  54 + private String yczltype;
  55 +
  56 + @Override
  57 + public int hashCode() {
  58 + return ("safe_" + (this.getClzbh() + this.getStartime())).hashCode();
  59 + }
  60 +
  61 + @Override
  62 + public boolean equals(Object obj) {
  63 + SafeDriv s2 = (SafeDriv)obj;
  64 + return (this.getClzbh() + this.getStartime()).equals(s2.getClzbh() + s2.getStartime());
  65 + }
  66 +
  67 + public String getStartime() {
  68 + return Startime;
  69 + }
  70 +
  71 + public void setStartime(String startime) {
  72 + Startime = startime;
  73 + }
  74 +
  75 + public String getSbbh() {
  76 + return sbbh;
  77 + }
  78 +
  79 + public void setSbbh(String sbbh) {
  80 + this.sbbh = sbbh;
  81 + }
  82 +
  83 + public String getXlmc() {
  84 + return xlmc;
  85 + }
  86 +
  87 + public void setXlmc(String xlmc) {
  88 + this.xlmc = xlmc;
  89 + }
  90 +
  91 + public String getClzbh() {
  92 + return clzbh;
  93 + }
  94 +
  95 + public void setClzbh(String clzbh) {
  96 + this.clzbh = clzbh;
  97 + }
  98 +
  99 + public String getCph() {
  100 + return cph;
  101 + }
  102 +
  103 + public void setCph(String cph) {
  104 + this.cph = cph;
  105 + }
  106 +
  107 + public String getJctype() {
  108 + return jctype;
  109 + }
  110 +
  111 + public void setJctype(String jctype) {
  112 + this.jctype = jctype;
  113 + }
  114 +
  115 + public String getYczltype() {
  116 + return yczltype;
  117 + }
  118 +
  119 + public void setYczltype(String yczltype) {
  120 + this.yczltype = yczltype;
  121 + }
  122 +
  123 + public Long getTs() {
  124 + return ts;
  125 + }
  126 +
  127 + public void setTs(Long ts) {
  128 + this.ts = ts;
  129 + }
  130 +}
... ...
src/main/java/com/bsth/data/safe_driv/SafeDrivCenter.java 0 → 100644
  1 +package com.bsth.data.safe_driv;
  2 +
  3 +import com.bsth.Application;
  4 +import com.bsth.websocket.handler.SendUtils;
  5 +import org.joda.time.format.DateTimeFormat;
  6 +import org.joda.time.format.DateTimeFormatter;
  7 +import org.springframework.beans.BeansException;
  8 +import org.springframework.beans.factory.annotation.Autowired;
  9 +import org.springframework.boot.CommandLineRunner;
  10 +import org.springframework.context.ApplicationContext;
  11 +import org.springframework.context.ApplicationContextAware;
  12 +import org.springframework.stereotype.Component;
  13 +
  14 +import java.util.HashMap;
  15 +import java.util.HashSet;
  16 +import java.util.Map;
  17 +import java.util.Set;
  18 +import java.util.concurrent.TimeUnit;
  19 +
  20 +/**
  21 + * 安全驾驶
  22 + * Created by panzhao on 2017/4/6.
  23 + */
  24 +@Component
  25 +public class SafeDrivCenter implements CommandLineRunner,ApplicationContextAware {
  26 +
  27 + private static Set<SafeDriv> data;
  28 +
  29 + @Autowired
  30 + SafeDrivDataLoadThread safeDrivDataLoadThread;
  31 +
  32 + static SendUtils sendUtils;
  33 +
  34 + /**
  35 + * 车辆自编号 和 最新一条数据对照
  36 + */
  37 + private static Map<String, SafeDriv> safeMap;
  38 +
  39 + static {
  40 + data = new HashSet<>();
  41 + safeMap = new HashMap<>();
  42 + }
  43 +
  44 + private static DateTimeFormatter fmt = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss.SSS");
  45 + public static void put(SafeDriv sd){
  46 + sd.setTs(fmt.parseMillis(sd.getStartime()));
  47 + data.add(sd);
  48 +
  49 + if(sd.getYczltype().indexOf("A") == -1)
  50 + sd.setYczltype("A" + sd.getYczltype());
  51 +
  52 + SafeDriv old = safeMap.get(sd.getClzbh());
  53 + if(old == null || sd.getTs() > old.getTs()){
  54 + //通知客户端
  55 + sendUtils.sendSafeDriv(sd);
  56 + }
  57 +
  58 + safeMap.put(sd.getClzbh(), sd);
  59 + }
  60 +
  61 + @Override
  62 + public void run(String... strings) throws Exception {
  63 + //定时加载安全驾驶数据
  64 + Application.mainServices.scheduleWithFixedDelay(safeDrivDataLoadThread, 60, 5, TimeUnit.SECONDS);
  65 + }
  66 +
  67 + @Override
  68 + public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
  69 + sendUtils = applicationContext.getBean(SendUtils.class);
  70 + }
  71 +}
... ...
src/main/java/com/bsth/data/safe_driv/SafeDrivDataLoadThread.java 0 → 100644
  1 +package com.bsth.data.safe_driv;
  2 +
  3 +import com.alibaba.fastjson.JSON;
  4 +import org.apache.http.HttpEntity;
  5 +import org.apache.http.client.methods.CloseableHttpResponse;
  6 +import org.apache.http.client.methods.HttpGet;
  7 +import org.apache.http.impl.client.CloseableHttpClient;
  8 +import org.apache.http.impl.client.HttpClients;
  9 +import org.slf4j.Logger;
  10 +import org.slf4j.LoggerFactory;
  11 +import org.springframework.stereotype.Component;
  12 +
  13 +import java.io.BufferedReader;
  14 +import java.io.InputStreamReader;
  15 +import java.util.List;
  16 +
  17 +/**
  18 + * 安全驾驶数据加载线程
  19 + * Created by panzhao on 2017/4/6.
  20 + */
  21 +@Component
  22 +public class SafeDrivDataLoadThread extends Thread{
  23 +
  24 + private final static String url = "http://180.166.5.82:9988//bsth-safedriving/Crlcxb/realtimeInterface.do";
  25 +
  26 + Logger logger = LoggerFactory.getLogger(this.getClass());
  27 +
  28 + @Override
  29 + public void run() {
  30 + List<SafeDriv> list = null;
  31 + CloseableHttpClient httpClient = null;
  32 + CloseableHttpResponse response = null;
  33 + try {
  34 + httpClient = HttpClients.createDefault();
  35 + HttpGet get = new HttpGet(url);
  36 +
  37 + response = httpClient.execute(get);
  38 +
  39 + HttpEntity entity = response.getEntity();
  40 + if (null != entity) {
  41 + BufferedReader br = new BufferedReader(new InputStreamReader(entity.getContent()));
  42 + StringBuffer stringBuffer = new StringBuffer();
  43 + String str = "";
  44 + while ((str = br.readLine()) != null)
  45 + stringBuffer.append(str);
  46 +
  47 +
  48 + list = JSON.parseArray(stringBuffer.toString(), SafeDriv.class);
  49 + /**
  50 + * 模拟数据
  51 +
  52 + SafeDriv sd1 = new SafeDriv();
  53 + sd1.setYczltype("1");
  54 + sd1.setClzbh("W2B-001");
  55 + sd1.setStartime("2017-04-07 08:00:00.0");
  56 +
  57 + SafeDriv sd2 = new SafeDriv();
  58 + sd2.setYczltype("2");
  59 + sd2.setClzbh("W2B-002");
  60 + sd2.setStartime("2017-04-07 08:02:00.0");
  61 +
  62 + SafeDriv sd3 = new SafeDriv();
  63 + sd3.setYczltype("3");
  64 + sd3.setClzbh("W2B-003");
  65 + sd3.setStartime("2017-04-07 08:03:00.0");
  66 +
  67 + SafeDriv sd4 = new SafeDriv();
  68 + sd4.setYczltype("4");
  69 + sd4.setClzbh("W2B-004");
  70 + sd4.setStartime("2017-04-07 08:04:00.0");
  71 +
  72 + SafeDriv sd5 = new SafeDriv();
  73 + sd5.setYczltype("5");
  74 + sd5.setClzbh("W2B-005");
  75 + sd5.setStartime("2017-04-07 08:05:00.0");
  76 +
  77 + list.add(sd1);
  78 + list.add(sd2);
  79 + list.add(sd3);
  80 + list.add(sd4);
  81 + list.add(sd5);
  82 + */
  83 + for(SafeDriv sd : list){
  84 + SafeDrivCenter.put(sd);
  85 + }
  86 + }
  87 +
  88 + httpClient.close();
  89 + response.close();
  90 + } catch (Exception e) {
  91 + logger.error("", e);
  92 + }
  93 + }
  94 +}
... ...
src/main/java/com/bsth/entity/excep/Offline.java
... ... @@ -6,6 +6,7 @@ import javax.persistence.Entity;
6 6 import javax.persistence.GeneratedValue;
7 7 import javax.persistence.Id;
8 8 import javax.persistence.Table;
  9 +import javax.persistence.Transient;
9 10  
10 11 /**
11 12 * 掉线
... ... @@ -65,7 +66,12 @@ public class Offline {
65 66 */
66 67 private Date createDate;
67 68  
68   -
  69 + @Transient
  70 + private String nbbm;
  71 + @Transient
  72 + private String jsy;
  73 + @Transient
  74 + private String lpname;
69 75 public Integer getId() {
70 76 return id;
71 77 }
... ... @@ -146,5 +152,29 @@ public class Offline {
146 152 this.timestampDate = timestampDate;
147 153 }
148 154  
  155 + public String getNbbm() {
  156 + return nbbm;
  157 + }
  158 +
  159 + public void setNbbm(String nbbm) {
  160 + this.nbbm = nbbm;
  161 + }
149 162  
  163 + public String getJsy() {
  164 + return jsy;
  165 + }
  166 +
  167 + public void setJsy(String jsy) {
  168 + this.jsy = jsy;
  169 + }
  170 +
  171 + public String getLpname() {
  172 + return lpname;
  173 + }
  174 +
  175 + public void setLpname(String lpname) {
  176 + this.lpname = lpname;
  177 + }
  178 +
  179 +
150 180 }
... ...
src/main/java/com/bsth/entity/excep/Outbound.java
... ... @@ -6,6 +6,7 @@ import javax.persistence.Entity;
6 6 import javax.persistence.GeneratedValue;
7 7 import javax.persistence.Id;
8 8 import javax.persistence.Table;
  9 +import javax.persistence.Transient;
9 10  
10 11 /**
11 12 * 越界
... ... @@ -72,7 +73,12 @@ public class Outbound {
72 73 * 时间
73 74 */
74 75 private Date createDate;
75   -
  76 + @Transient
  77 + private String nbbm;
  78 + @Transient
  79 + private String jsy;
  80 + @Transient
  81 + private String lpname;
76 82  
77 83 public Integer getId() {
78 84 return id;
... ... @@ -162,5 +168,29 @@ public class Outbound {
162 168 this.timestampDate = timestampDate;
163 169 }
164 170  
  171 + public String getNbbm() {
  172 + return nbbm;
  173 + }
  174 +
  175 + public void setNbbm(String nbbm) {
  176 + this.nbbm = nbbm;
  177 + }
  178 +
  179 + public String getJsy() {
  180 + return jsy;
  181 + }
  182 +
  183 + public void setJsy(String jsy) {
  184 + this.jsy = jsy;
  185 + }
  186 +
  187 + public String getLpname() {
  188 + return lpname;
  189 + }
  190 +
  191 + public void setLpname(String lpname) {
  192 + this.lpname = lpname;
  193 + }
  194 +
165 195  
166 196 }
... ...
src/main/java/com/bsth/entity/excep/Speeding.java
... ... @@ -6,6 +6,7 @@ import javax.persistence.Entity;
6 6 import javax.persistence.GeneratedValue;
7 7 import javax.persistence.Id;
8 8 import javax.persistence.Table;
  9 +import javax.persistence.Transient;
9 10  
10 11 /**
11 12 * 超速
... ... @@ -66,6 +67,13 @@ public class Speeding {
66 67 private String timestampDate;
67 68  
68 69  
  70 + @Transient
  71 + private String nbbm;
  72 + @Transient
  73 + private String jsy;
  74 + @Transient
  75 + private String lpname;
  76 +
69 77 /**
70 78 * 创建时间
71 79 */
... ... @@ -161,6 +169,30 @@ public class Speeding {
161 169 this.timestampDate = timestampDate;
162 170 }
163 171  
  172 + public String getNbbm() {
  173 + return nbbm;
  174 + }
  175 +
  176 + public void setNbbm(String nbbm) {
  177 + this.nbbm = nbbm;
  178 + }
  179 +
  180 + public String getJsy() {
  181 + return jsy;
  182 + }
  183 +
  184 + public void setJsy(String jsy) {
  185 + this.jsy = jsy;
  186 + }
  187 +
  188 + public String getLpname() {
  189 + return lpname;
  190 + }
  191 +
  192 + public void setLpname(String lpname) {
  193 + this.lpname = lpname;
  194 + }
  195 +
164 196  
165 197  
166 198 }
... ...
src/main/java/com/bsth/repository/StationRouteRepository.java
... ... @@ -272,4 +272,8 @@ public interface StationRouteRepository extends BaseRepository&lt;StationRoute, Int
272 272 @Modifying
273 273 @Query(value="update bsth_c_stationroute set directions = case directions when 1 then 0 when 0 then 1 end where line_code = ?1 ", nativeQuery=true)
274 274 public void stationRouteDir(Integer line);
  275 +
  276 + @Modifying
  277 + @Query(value="update bsth_c_stationroute set distances =?2 where id = ?1 ", nativeQuery=true)
  278 + public void upddis(Integer id,Double dis);
275 279 }
... ...
src/main/java/com/bsth/repository/realcontrol/ScheduleRealInfoRepository.java
... ... @@ -137,7 +137,7 @@ public interface ScheduleRealInfoRepository extends BaseRepository&lt;ScheduleRealI
137 137 List<ScheduleRealInfo> scheduleByDateAndLine(String line,String date);
138 138  
139 139 @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH)
140   - @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm like %?1% and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 order by (s.lpName+1), s.realExecDate,s.fcsj")
  140 + @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm =?1 and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 order by (s.lpName+1), s.realExecDate,s.fcsj")
141 141 List<ScheduleRealInfo> scheduleByDateAndLineQp(String line,String date);
142 142  
143 143 @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH)
... ...
src/main/java/com/bsth/service/StationRouteService.java
... ... @@ -82,4 +82,6 @@ public interface StationRouteService extends BaseService&lt;StationRoute, Integer&gt;
82 82 Map<String, Object> findByMultiLine(String lineIds);
83 83  
84 84 Map<String, Object> updSwitchDir(String lineIds);
  85 +
  86 + Map<String, Object> upddis(Map<String, Object> map);
85 87 }
... ...
src/main/java/com/bsth/service/excep/impl/OfflineServiceImpl.java
... ... @@ -12,10 +12,15 @@ import java.util.HashMap;
12 12 import java.util.List;
13 13 import java.util.Map;
14 14  
  15 +import org.springframework.beans.factory.annotation.Autowired;
  16 +import org.springframework.jdbc.core.JdbcTemplate;
  17 +import org.springframework.jdbc.core.RowMapper;
15 18 import org.springframework.stereotype.Service;
16 19  
17 20 import com.bsth.data.BasicData;
18 21 import com.bsth.entity.excep.Offline;
  22 +import com.bsth.entity.oil.Ylb;
  23 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
19 24 import com.bsth.service.excep.OfflineService;
20 25 import com.bsth.util.EchartConver;
21 26 import com.bsth.util.PageHelper;
... ... @@ -27,6 +32,8 @@ import com.google.gson.Gson;
27 32 @Service
28 33 public class OfflineServiceImpl implements OfflineService {
29 34  
  35 + @Autowired
  36 + JdbcTemplate jdbcTemplate;
30 37 // @Override
31 38 static List<Offline> findAll(Map<String, Object> map) {
32 39 // TODO Auto-generated method stub
... ... @@ -53,7 +60,9 @@ public class OfflineServiceImpl implements OfflineService {
53 60 }
54 61  
55 62 if(nbbm!=null){
56   - sql +=" and vehicle like '%"+nbbm.toString()+"%'";
  63 + nbbm=BasicData.deviceId2NbbmMap.inverse().get(nbbm);
  64 + if(nbbm!=null)
  65 + sql +=" and vehicle like '%"+nbbm+"%'";
57 66 }
58 67  
59 68 if(updown!=null){
... ... @@ -61,7 +70,7 @@ public class OfflineServiceImpl implements OfflineService {
61 70 }
62 71 if(date!=null){
63 72 if (date.toString().length()>0) {
64   - SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:MM:SS");
  73 + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
65 74 try {
66 75 Long t1=sdf.parse(date.toString()+" 00:00:00").getTime();
67 76 Long t2=sdf.parse(date.toString()+" 23:59:59").getTime();
... ... @@ -112,7 +121,7 @@ public class OfflineServiceImpl implements OfflineService {
112 121 offline.setTimestamp(Long.valueOf(rs.getObject("timestamp").toString()));
113 122 offline.setTimestampDate(sdf.format(new Date(offline.getTimestamp())));
114 123 offline.setUpDown(Integer.valueOf(rs.getObject("up_down").toString()));
115   - offline.setVehicle(rs.getObject("vehicle").toString());
  124 + offline.setVehicle(BasicData.deviceId2NbbmMap.get(rs.getObject("vehicle").toString()));
116 125 list.add(offline);
117 126 }
118 127 return list;
... ... @@ -135,7 +144,9 @@ public class OfflineServiceImpl implements OfflineService {
135 144 }
136 145  
137 146 if(nbbm!=null){
138   - sql +=" and vehicle like '%"+nbbm.toString()+"%'";
  147 + nbbm=BasicData.deviceId2NbbmMap.inverse().get(nbbm);
  148 + if(nbbm!=null)
  149 + sql +=" and vehicle like '%"+nbbm+"%'";
139 150 }
140 151  
141 152 if(updown!=null){
... ... @@ -143,7 +154,7 @@ public class OfflineServiceImpl implements OfflineService {
143 154 }
144 155 if(date!=null){
145 156 if (date.toString().length()>0) {
146   - SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:MM:SS");
  157 + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
147 158 try {
148 159 Long t1=sdf.parse(date.toString()+" 00:00:00").getTime();
149 160 Long t2=sdf.parse(date.toString()+" 23:59:59").getTime();
... ... @@ -177,8 +188,41 @@ public class OfflineServiceImpl implements OfflineService {
177 188 PageHelper pageHelper = new PageHelper(totalData, map);
178 189 // List<T> list = this.baseDao.queryByObject(pageHelper.getMap());
179 190 List<Offline> list=findAll(pageHelper.getMap());
  191 + for (int i = 0; i < list.size(); i++) {
  192 + String nbbm2=list.get(i).getVehicle() ;
  193 + Long d1=list.get(i).getTimestamp();
  194 + Date datess = new Date(d1);
  195 + String dates=new SimpleDateFormat("yyyy-MM-dd").format(datess);
  196 + String sk=new SimpleDateFormat("HH:mm").format(datess);
  197 + String sqlPbb="select * from bsth_c_s_sp_info_real where cl_zbh='"+nbbm2+"' and"
  198 + + " real_exec_date='"+dates+"' ";
  199 +// + "and fcsj_actual > '"+sk+"' ";
  200 +// + "and '"+sk+"' <dfsj";
  201 + List<ScheduleRealInfo> pbb =jdbcTemplate.query(sqlPbb,
  202 + new RowMapper<ScheduleRealInfo>(){
  203 + @Override
  204 + public ScheduleRealInfo mapRow(ResultSet rs, int rowNum) throws SQLException {
  205 + ScheduleRealInfo s = new ScheduleRealInfo();
  206 + s.setjGh(rs.getString("j_gh"));
  207 + s.setjName(rs.getString("j_name"));
  208 + s.setLpName(rs.getString("lp_name"));
  209 + return s;
  210 + }
  211 + });
  212 + if(pbb.size()>0){
  213 + list.get(i).setJsy(pbb.get(0).getjGh()+"/"+pbb.get(0).getjName());
  214 + list.get(i).setLpname(pbb.get(0).getLpName());
  215 +
  216 + }
  217 +
  218 + }
180 219 PageObject<Offline> pageObject = pageHelper.getPageObject();
181   - pageObject.setDataList(list);
  220 +// for (int i = 0; i < list.size(); i++) {
  221 +// if(list.get(i).getLpname()!=null){
  222 + pageObject.setDataList(list);
  223 +// }
  224 +// }
  225 +
182 226 return pageObject;
183 227 }
184 228 public static void main(String[] args) {
... ...
src/main/java/com/bsth/service/excep/impl/OutboundServiceImpl.java
... ... @@ -12,10 +12,14 @@ import java.util.HashMap;
12 12 import java.util.List;
13 13 import java.util.Map;
14 14  
  15 +import org.springframework.beans.factory.annotation.Autowired;
  16 +import org.springframework.jdbc.core.JdbcTemplate;
  17 +import org.springframework.jdbc.core.RowMapper;
15 18 import org.springframework.stereotype.Service;
16 19  
17 20 import com.bsth.data.BasicData;
18 21 import com.bsth.entity.excep.Outbound;
  22 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
19 23 import com.bsth.service.excep.OutboundService;
20 24 import com.bsth.util.EchartConver;
21 25 import com.bsth.util.PageHelper;
... ... @@ -25,8 +29,9 @@ import com.github.abel533.echarts.Option;
25 29 import com.google.gson.Gson;
26 30 @Service
27 31 public class OutboundServiceImpl implements OutboundService{
28   -
29   - static List<Outbound> findAll(Map<String, Object> map) {
  32 + @Autowired
  33 + JdbcTemplate jdbcTemplate;
  34 + static List<Outbound> findAll(Map<String, Object> map) {
30 35 Connection conn = null;
31 36 PreparedStatement ps = null;
32 37 ResultSet rs = null;
... ... @@ -37,12 +42,13 @@ public class OutboundServiceImpl implements OutboundService{
37 42 Object nbbm=map.get("nbbm");
38 43 Object updown=map.get("updown");
39 44 Object date=map.get("date");
40   -
41 45 if(line!=null){
42 46 sql +=" and line like'%"+line.toString()+"%'";
43 47 }
44 48  
45 49 if(nbbm!=null){
  50 + nbbm=BasicData.deviceId2NbbmMap.inverse().get(nbbm);
  51 + if(nbbm!=null)
46 52 sql +=" and vehicle like '%"+nbbm.toString()+"%'";
47 53 }
48 54  
... ... @@ -51,7 +57,7 @@ public class OutboundServiceImpl implements OutboundService{
51 57 }
52 58 if(date!=null){
53 59 if (date.toString().length()>0) {
54   - SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:MM:SS");
  60 + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
55 61 try {
56 62 Long t1=sdf.parse(date.toString()+" 00:00:00").getTime();
57 63 Long t2=sdf.parse(date.toString()+" 23:59:59").getTime();
... ... @@ -98,7 +104,7 @@ public class OutboundServiceImpl implements OutboundService{
98 104 outbound.setTimestamp((Long.valueOf(rs.getObject("timestamp").toString())));
99 105 outbound.setTimestampDate(sdf.format(new Date(outbound.getTimestamp())));
100 106 outbound.setUpDown(Integer.valueOf(rs.getObject("up_down").toString()));
101   - outbound.setVehicle(rs.getObject("vehicle").toString());
  107 + outbound.setVehicle(BasicData.deviceId2NbbmMap.get(rs.getObject("vehicle").toString()));
102 108 outbound.setLocation(rs.getObject("location")==null?"":rs.getObject("location").toString());
103 109 list.add(outbound);
104 110 }
... ... @@ -119,6 +125,8 @@ public class OutboundServiceImpl implements OutboundService{
119 125 }
120 126  
121 127 if(nbbm!=null){
  128 + nbbm=BasicData.deviceId2NbbmMap.inverse().get(nbbm);
  129 + if(nbbm!=null)
122 130 sql +=" and vehicle like '%"+nbbm.toString()+"%'";
123 131 }
124 132  
... ... @@ -160,7 +168,34 @@ public class OutboundServiceImpl implements OutboundService{
160 168  
161 169 PageHelper pageHelper = new PageHelper(totalData, map);
162 170 List<Outbound> list=findAll(pageHelper.getMap());
163   -
  171 + for (int i = 0; i < list.size(); i++) {
  172 + String nbbm2=list.get(i).getVehicle() ;
  173 + Long d1=list.get(i).getTimestamp();
  174 + Date datess = new Date(d1);
  175 + String dates=new SimpleDateFormat("yyyy-MM-dd").format(datess);
  176 + String sk=new SimpleDateFormat("HH:mm").format(datess);
  177 + String sqlPbb="select * from bsth_c_s_sp_info_real where cl_zbh='"+nbbm2+"' and"
  178 + + " real_exec_date='"+dates+"' ";
  179 +// + "and fcsj_actual > '"+sk+"' ";
  180 +// + "and '"+sk+"' <dfsj";
  181 + List<ScheduleRealInfo> pbb =jdbcTemplate.query(sqlPbb,
  182 + new RowMapper<ScheduleRealInfo>(){
  183 + @Override
  184 + public ScheduleRealInfo mapRow(ResultSet rs, int rowNum) throws SQLException {
  185 + ScheduleRealInfo s = new ScheduleRealInfo();
  186 + s.setjGh(rs.getString("j_gh"));
  187 + s.setjName(rs.getString("j_name"));
  188 + s.setLpName(rs.getString("lp_name"));
  189 + return s;
  190 + }
  191 + });
  192 + if(pbb.size()>0){
  193 + list.get(i).setJsy(pbb.get(0).getjGh()+"/"+pbb.get(0).getjName());
  194 + list.get(i).setLpname(pbb.get(0).getLpName());
  195 +
  196 + }
  197 +
  198 + }
164 199 PageObject<Outbound> pageObject = pageHelper.getPageObject();
165 200 pageObject.setDataList(list);
166 201 return pageObject;
... ...
src/main/java/com/bsth/service/excep/impl/SpeedingServiceImpl.java
... ... @@ -12,10 +12,14 @@ import java.util.HashMap;
12 12 import java.util.List;
13 13 import java.util.Map;
14 14  
  15 +import org.springframework.jdbc.core.JdbcTemplate;
  16 +import org.springframework.jdbc.core.RowMapper;
15 17 import org.springframework.stereotype.Service;
  18 +import org.springframework.beans.factory.annotation.Autowired;
16 19  
17 20 import com.bsth.data.BasicData;
18 21 import com.bsth.entity.excep.Speeding;
  22 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
19 23 import com.bsth.service.excep.SpeedingService;
20 24 import com.bsth.util.EchartConver;
21 25 import com.bsth.util.PageHelper;
... ... @@ -27,7 +31,8 @@ import com.google.gson.Gson;
27 31 @Service
28 32 public class SpeedingServiceImpl implements SpeedingService {
29 33  
30   -
  34 + @Autowired
  35 + JdbcTemplate jdbcTemplate;
31 36 static List<Speeding> findAll(Map<String, Object> map) {
32 37 Connection conn = null;
33 38 PreparedStatement ps = null;
... ... @@ -45,6 +50,8 @@ public class SpeedingServiceImpl implements SpeedingService {
45 50 }
46 51  
47 52 if(nbbm!=null){
  53 + nbbm=BasicData.deviceId2NbbmMap.inverse().get(nbbm);
  54 + if(nbbm!=null)
48 55 sql +=" and vehicle like '%"+nbbm.toString()+"%'";
49 56 }
50 57  
... ... @@ -53,7 +60,7 @@ public class SpeedingServiceImpl implements SpeedingService {
53 60 }
54 61 if(date!=null){
55 62 if (date.toString().length()>0) {
56   - SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:MM:SS");
  63 + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
57 64 try {
58 65 Long t1=sdf.parse(date.toString()+" 00:00:00").getTime();
59 66 Long t2=sdf.parse(date.toString()+" 23:59:59").getTime();
... ... @@ -102,7 +109,7 @@ public class SpeedingServiceImpl implements SpeedingService {
102 109 speeding.setTimestamp((Long.valueOf(rs.getObject("timestamp").toString())));
103 110 speeding.setTimestampDate(sdf.format(new Date(speeding.getTimestamp())));
104 111 speeding.setUpDown(Integer.valueOf(rs.getObject("up_down").toString()));
105   - speeding.setVehicle(rs.getObject("vehicle").toString());
  112 + speeding.setVehicle(BasicData.deviceId2NbbmMap.get(rs.getObject("vehicle").toString()));
106 113 list.add(speeding);
107 114 }
108 115 return list;
... ... @@ -122,9 +129,10 @@ public class SpeedingServiceImpl implements SpeedingService {
122 129 }
123 130  
124 131 if(nbbm!=null){
  132 + nbbm=BasicData.deviceId2NbbmMap.inverse().get(nbbm);
  133 + if(nbbm!=null)
125 134 sql +=" and vehicle like '%"+nbbm.toString()+"%'";
126 135 }
127   -
128 136 if(updown!=null){
129 137 sql +="and up_down like '%"+updown.toString()+"%'";
130 138 }
... ... @@ -163,7 +171,34 @@ public class SpeedingServiceImpl implements SpeedingService {
163 171  
164 172 PageHelper pageHelper = new PageHelper(totalData, map);
165 173 List<Speeding> list=findAll(pageHelper.getMap());
166   -
  174 + for (int i = 0; i < list.size(); i++) {
  175 + String nbbm2=list.get(i).getVehicle() ;
  176 + Long d1=list.get(i).getTimestamp();
  177 + Date datess = new Date(d1);
  178 + String dates=new SimpleDateFormat("yyyy-MM-dd").format(datess);
  179 + String sk=new SimpleDateFormat("HH:mm").format(datess);
  180 + String sqlPbb="select * from bsth_c_s_sp_info_real where cl_zbh='"+nbbm2+"' and"
  181 + + " real_exec_date='"+dates+"' ";
  182 +// + "and fcsj_actual > '"+sk+"' ";
  183 +// + "and '"+sk+"' <dfsj";
  184 + List<ScheduleRealInfo> pbb =jdbcTemplate.query(sqlPbb,
  185 + new RowMapper<ScheduleRealInfo>(){
  186 + @Override
  187 + public ScheduleRealInfo mapRow(ResultSet rs, int rowNum) throws SQLException {
  188 + ScheduleRealInfo s = new ScheduleRealInfo();
  189 + s.setjGh(rs.getString("j_gh"));
  190 + s.setjName(rs.getString("j_name"));
  191 + s.setLpName(rs.getString("lp_name"));
  192 + return s;
  193 + }
  194 + });
  195 + if(pbb.size()>0){
  196 + list.get(i).setJsy(pbb.get(0).getjGh()+"/"+pbb.get(0).getjName());
  197 + list.get(i).setLpname(pbb.get(0).getLpName());
  198 +
  199 + }
  200 +
  201 + }
167 202 PageObject<Speeding> pageObject = pageHelper.getPageObject();
168 203 pageObject.setDataList(list);
169 204 return pageObject;
... ...
src/main/java/com/bsth/service/gps/entity/HistoryGps_DTO.java
1   -package com.bsth.service.gps.entity;
2   -
3   -import com.alibaba.fastjson.JSON;
4   -import com.alibaba.fastjson.JSONObject;
5   -import com.bsth.data.arrival.ArrivalEntity;
6   -import com.fasterxml.jackson.annotation.JsonIgnore;
7   -import com.vividsolutions.jts.geom.Coordinate;
8   -import com.vividsolutions.jts.geom.GeometryFactory;
9   -import com.vividsolutions.jts.geom.Point;
10   -
11   -import java.util.List;
12   -import java.util.Map;
13   -
14   -/**
15   - * 历史GPS DTO
16   - * Created by panzhao on 2017/4/5.
17   - */
18   -public class HistoryGps_DTO {
19   -
20   - public static List<HistoryGps_DTO> craete(List<Map<String, Object>> mapList){
21   - List<HistoryGps_DTO> list = JSONObject.parseArray(JSON.toJSONString(mapList), HistoryGps_DTO.class);
22   -
23   - GeometryFactory geometryFactory = new GeometryFactory();
24   - Point point;
25   - for(HistoryGps_DTO gps : list){
26   - point = geometryFactory.createPoint(new Coordinate(gps.getLat(), gps.getLon()));
27   - gps.setPoint(point);
28   - }
29   - return list;
30   - }
31   -
32   - private double gcj_lon;
33   - private double gcj_lat;
34   -
35   - private double bd_lon;
36   - private double bd_lat;
37   -
38   - private double lon;
39   - private double lat;
40   -
41   - private String deviceId;
42   - private long ts;
43   - private long timestamp;
44   - private String stopNo;
45   - private float direction;
46   -
47   - private String lineId;
48   - private float speed;
49   - private ArrivalEntity inout_stop_info;
50   - private int inout_stop;
51   -
52   - private String nbbm;
53   - private int state;
54   - private int upDown;
55   -
56   - @JsonIgnore
57   - private Point point;
58   -
59   - /** 路段 */
60   - private Road_DTO road;
61   - /** 和路段的最短距离 */
62   - private double roadMinDistance;
63   -
64   - public double getGcj_lon() {
65   - return gcj_lon;
66   - }
67   -
68   - public void setGcj_lon(double gcj_lon) {
69   - this.gcj_lon = gcj_lon;
70   - }
71   -
72   - public double getGcj_lat() {
73   - return gcj_lat;
74   - }
75   -
76   - public void setGcj_lat(double gcj_lat) {
77   - this.gcj_lat = gcj_lat;
78   - }
79   -
80   - public double getBd_lon() {
81   - return bd_lon;
82   - }
83   -
84   - public void setBd_lon(double bd_lon) {
85   - this.bd_lon = bd_lon;
86   - }
87   -
88   - public double getBd_lat() {
89   - return bd_lat;
90   - }
91   -
92   - public void setBd_lat(double bd_lat) {
93   - this.bd_lat = bd_lat;
94   - }
95   -
96   - public String getDeviceId() {
97   - return deviceId;
98   - }
99   -
100   - public void setDeviceId(String deviceId) {
101   - this.deviceId = deviceId;
102   - }
103   -
104   - public long getTs() {
105   - return ts;
106   - }
107   -
108   - public void setTs(long ts) {
109   - this.ts = ts;
110   - }
111   -
112   - public long getTimestamp() {
113   - return timestamp;
114   - }
115   -
116   - public void setTimestamp(long timestamp) {
117   - this.timestamp = timestamp;
118   - }
119   -
120   - public String getStopNo() {
121   - return stopNo;
122   - }
123   -
124   - public void setStopNo(String stopNo) {
125   - this.stopNo = stopNo;
126   - }
127   -
128   - public float getDirection() {
129   - return direction;
130   - }
131   -
132   - public void setDirection(float direction) {
133   - this.direction = direction;
134   - }
135   -
136   - public String getLineId() {
137   - return lineId;
138   - }
139   -
140   - public void setLineId(String lineId) {
141   - this.lineId = lineId;
142   - }
143   -
144   - public float getSpeed() {
145   - return speed;
146   - }
147   -
148   - public void setSpeed(float speed) {
149   - this.speed = speed;
150   - }
151   -
152   - public ArrivalEntity getInout_stop_info() {
153   - return inout_stop_info;
154   - }
155   -
156   - public void setInout_stop_info(ArrivalEntity inout_stop_info) {
157   - this.inout_stop_info = inout_stop_info;
158   - }
159   -
160   - public int getInout_stop() {
161   - return inout_stop;
162   - }
163   -
164   - public void setInout_stop(int inout_stop) {
165   - this.inout_stop = inout_stop;
166   - }
167   -
168   - public String getNbbm() {
169   - return nbbm;
170   - }
171   -
172   - public void setNbbm(String nbbm) {
173   - this.nbbm = nbbm;
174   - }
175   -
176   - public int getState() {
177   - return state;
178   - }
179   -
180   - public void setState(int state) {
181   - this.state = state;
182   - }
183   -
184   - public int getUpDown() {
185   - return upDown;
186   - }
187   -
188   - public void setUpDown(int upDown) {
189   - this.upDown = upDown;
190   - }
191   -
192   - public Road_DTO getRoad() {
193   - return road;
194   - }
195   -
196   - public void setRoad(Road_DTO road) {
197   - this.road = road;
198   - }
199   -
200   - public double getRoadMinDistance() {
201   - return roadMinDistance;
202   - }
203   -
204   - public void setRoadMinDistance(double roadMinDistance) {
205   - this.roadMinDistance = roadMinDistance;
206   - }
207   -
208   - public double getLon() {
209   - return lon;
210   - }
211   -
212   - public void setLon(double lon) {
213   - this.lon = lon;
214   - }
215   -
216   - public double getLat() {
217   - return lat;
218   - }
219   -
220   - public void setLat(double lat) {
221   - this.lat = lat;
222   - }
223   -
224   - public Point getPoint() {
225   - return point;
226   - }
227   -
228   - public void setPoint(Point point) {
229   - this.point = point;
230   - }
231   -}
  1 +package com.bsth.service.gps.entity;
  2 +
  3 +import com.alibaba.fastjson.JSON;
  4 +import com.alibaba.fastjson.JSONObject;
  5 +import com.bsth.data.arrival.ArrivalEntity;
  6 +import com.fasterxml.jackson.annotation.JsonIgnore;
  7 +import com.vividsolutions.jts.geom.Coordinate;
  8 +import com.vividsolutions.jts.geom.GeometryFactory;
  9 +import com.vividsolutions.jts.geom.Point;
  10 +
  11 +import java.util.List;
  12 +import java.util.Map;
  13 +
  14 +/**
  15 + * 历史GPS DTO
  16 + * Created by panzhao on 2017/4/5.
  17 + */
  18 +public class HistoryGps_DTO {
  19 +
  20 + public static List<HistoryGps_DTO> craete(List<Map<String, Object>> mapList){
  21 + List<HistoryGps_DTO> list = JSONObject.parseArray(JSON.toJSONString(mapList), HistoryGps_DTO.class);
  22 +
  23 + GeometryFactory geometryFactory = new GeometryFactory();
  24 + Point point;
  25 + for(HistoryGps_DTO gps : list){
  26 + point = geometryFactory.createPoint(new Coordinate(gps.getLat(), gps.getLon()));
  27 + gps.setPoint(point);
  28 + }
  29 + return list;
  30 + }
  31 +
  32 + private double gcj_lon;
  33 + private double gcj_lat;
  34 +
  35 + private double bd_lon;
  36 + private double bd_lat;
  37 +
  38 + private double lon;
  39 + private double lat;
  40 +
  41 + private String deviceId;
  42 + private long ts;
  43 + private long timestamp;
  44 + private String stopNo;
  45 + private float direction;
  46 +
  47 + private String lineId;
  48 + private float speed;
  49 + private ArrivalEntity inout_stop_info;
  50 + private int inout_stop;
  51 +
  52 + private String nbbm;
  53 + private int state;
  54 + private int upDown;
  55 +
  56 + @JsonIgnore
  57 + private Point point;
  58 +
  59 + /** 路段 */
  60 + private Road_DTO road;
  61 + /** 和路段的最短距离 */
  62 + private double roadMinDistance;
  63 +
  64 + public double getGcj_lon() {
  65 + return gcj_lon;
  66 + }
  67 +
  68 + public void setGcj_lon(double gcj_lon) {
  69 + this.gcj_lon = gcj_lon;
  70 + }
  71 +
  72 + public double getGcj_lat() {
  73 + return gcj_lat;
  74 + }
  75 +
  76 + public void setGcj_lat(double gcj_lat) {
  77 + this.gcj_lat = gcj_lat;
  78 + }
  79 +
  80 + public double getBd_lon() {
  81 + return bd_lon;
  82 + }
  83 +
  84 + public void setBd_lon(double bd_lon) {
  85 + this.bd_lon = bd_lon;
  86 + }
  87 +
  88 + public double getBd_lat() {
  89 + return bd_lat;
  90 + }
  91 +
  92 + public void setBd_lat(double bd_lat) {
  93 + this.bd_lat = bd_lat;
  94 + }
  95 +
  96 + public String getDeviceId() {
  97 + return deviceId;
  98 + }
  99 +
  100 + public void setDeviceId(String deviceId) {
  101 + this.deviceId = deviceId;
  102 + }
  103 +
  104 + public long getTs() {
  105 + return ts;
  106 + }
  107 +
  108 + public void setTs(long ts) {
  109 + this.ts = ts;
  110 + }
  111 +
  112 + public long getTimestamp() {
  113 + return timestamp;
  114 + }
  115 +
  116 + public void setTimestamp(long timestamp) {
  117 + this.timestamp = timestamp;
  118 + }
  119 +
  120 + public String getStopNo() {
  121 + return stopNo;
  122 + }
  123 +
  124 + public void setStopNo(String stopNo) {
  125 + this.stopNo = stopNo;
  126 + }
  127 +
  128 + public float getDirection() {
  129 + return direction;
  130 + }
  131 +
  132 + public void setDirection(float direction) {
  133 + this.direction = direction;
  134 + }
  135 +
  136 + public String getLineId() {
  137 + return lineId;
  138 + }
  139 +
  140 + public void setLineId(String lineId) {
  141 + this.lineId = lineId;
  142 + }
  143 +
  144 + public float getSpeed() {
  145 + return speed;
  146 + }
  147 +
  148 + public void setSpeed(float speed) {
  149 + this.speed = speed;
  150 + }
  151 +
  152 + public ArrivalEntity getInout_stop_info() {
  153 + return inout_stop_info;
  154 + }
  155 +
  156 + public void setInout_stop_info(ArrivalEntity inout_stop_info) {
  157 + this.inout_stop_info = inout_stop_info;
  158 + }
  159 +
  160 + public int getInout_stop() {
  161 + return inout_stop;
  162 + }
  163 +
  164 + public void setInout_stop(int inout_stop) {
  165 + this.inout_stop = inout_stop;
  166 + }
  167 +
  168 + public String getNbbm() {
  169 + return nbbm;
  170 + }
  171 +
  172 + public void setNbbm(String nbbm) {
  173 + this.nbbm = nbbm;
  174 + }
  175 +
  176 + public int getState() {
  177 + return state;
  178 + }
  179 +
  180 + public void setState(int state) {
  181 + this.state = state;
  182 + }
  183 +
  184 + public int getUpDown() {
  185 + return upDown;
  186 + }
  187 +
  188 + public void setUpDown(int upDown) {
  189 + this.upDown = upDown;
  190 + }
  191 +
  192 + public Road_DTO getRoad() {
  193 + return road;
  194 + }
  195 +
  196 + public void setRoad(Road_DTO road) {
  197 + this.road = road;
  198 + }
  199 +
  200 + public double getRoadMinDistance() {
  201 + return roadMinDistance;
  202 + }
  203 +
  204 + public void setRoadMinDistance(double roadMinDistance) {
  205 + this.roadMinDistance = roadMinDistance;
  206 + }
  207 +
  208 + public double getLon() {
  209 + return lon;
  210 + }
  211 +
  212 + public void setLon(double lon) {
  213 + this.lon = lon;
  214 + }
  215 +
  216 + public double getLat() {
  217 + return lat;
  218 + }
  219 +
  220 + public void setLat(double lat) {
  221 + this.lat = lat;
  222 + }
  223 +
  224 + public Point getPoint() {
  225 + return point;
  226 + }
  227 +
  228 + public void setPoint(Point point) {
  229 + this.point = point;
  230 + }
  231 +}
... ...
src/main/java/com/bsth/service/gps/entity/Road_DTO.java
1   -package com.bsth.service.gps.entity;
2   -
3   -import com.alibaba.fastjson.JSON;
4   -import com.alibaba.fastjson.JSONObject;
5   -import com.fasterxml.jackson.annotation.JsonIgnore;
6   -import com.vividsolutions.jts.geom.Coordinate;
7   -import com.vividsolutions.jts.geom.GeometryFactory;
8   -import com.vividsolutions.jts.geom.LineString;
9   -
10   -import java.util.ArrayList;
11   -import java.util.List;
12   -import java.util.Map;
13   -
14   -/**
15   - * 路段信息DTO
16   - * Created by panzhao on 2017/4/5.
17   - */
18   -public class Road_DTO {
19   -
20   - public static List<Road_DTO> craete(List<Map<String, Object>> mapList){
21   - List<Road_DTO> list = JSONObject.parseArray(JSON.toJSONString(mapList), Road_DTO.class);
22   - //处理路段坐标
23   - String polygonStr;
24   - String[] coords;
25   - int i, len;
26   - String[] temps;//1, temps2;
27   - List<Coordinate> cds;
28   -
29   - GeometryFactory geometryFactory = new GeometryFactory();
30   - for(Road_DTO road : list){
31   - polygonStr = road.getGROAD_VECTOR();
32   - coords = polygonStr.substring(11, polygonStr.length() - 1).split(",");
33   - len = coords.length;
34   -
35   - cds = new ArrayList<>();
36   - //每2个点连一条线
37   - for(i = 0; i < len; i ++){
38   - temps = coords[i].split(" ");
39   - cds.add(new Coordinate(Float.parseFloat(temps[1]), Float.parseFloat(temps[0])));
40   - }
41   -
42   - Coordinate[] cdsArray = new Coordinate[cds.size()];
43   - road.setLineStr(geometryFactory.createLineString(cds.toArray(cdsArray)));
44   - }
45   - return list;
46   - }
47   -
48   - private long ID;
49   -
50   - @JsonIgnore
51   - private String GROAD_VECTOR;
52   -
53   - private String ROAD_CODE;
54   -
55   - private String ROAD_NAME;
56   -
57   - private double SPEED;
58   -
59   - @JsonIgnore
60   - private LineString lineStr;
61   -
62   - public long getID() {
63   - return ID;
64   - }
65   -
66   - public void setID(long ID) {
67   - this.ID = ID;
68   - }
69   -
70   - public String getGROAD_VECTOR() {
71   - return GROAD_VECTOR;
72   - }
73   -
74   - public void setGROAD_VECTOR(String GROAD_VECTOR) {
75   - this.GROAD_VECTOR = GROAD_VECTOR;
76   - }
77   -
78   - public String getROAD_CODE() {
79   - return ROAD_CODE;
80   - }
81   -
82   - public void setROAD_CODE(String ROAD_CODE) {
83   - this.ROAD_CODE = ROAD_CODE;
84   - }
85   -
86   - public String getROAD_NAME() {
87   - return ROAD_NAME;
88   - }
89   -
90   - public void setROAD_NAME(String ROAD_NAME) {
91   - this.ROAD_NAME = ROAD_NAME;
92   - }
93   -
94   - public double getSPEED() {
95   - return SPEED;
96   - }
97   -
98   - public void setSPEED(double SPEED) {
99   - this.SPEED = SPEED;
100   - }
101   -
102   - public LineString getLineStr() {
103   - return lineStr;
104   - }
105   -
106   - public void setLineStr(LineString lineStr) {
107   - this.lineStr = lineStr;
108   - }
109   -}
  1 +package com.bsth.service.gps.entity;
  2 +
  3 +import com.alibaba.fastjson.JSON;
  4 +import com.alibaba.fastjson.JSONObject;
  5 +import com.fasterxml.jackson.annotation.JsonIgnore;
  6 +import com.vividsolutions.jts.geom.Coordinate;
  7 +import com.vividsolutions.jts.geom.GeometryFactory;
  8 +import com.vividsolutions.jts.geom.LineString;
  9 +
  10 +import java.util.ArrayList;
  11 +import java.util.List;
  12 +import java.util.Map;
  13 +
  14 +/**
  15 + * 路段信息DTO
  16 + * Created by panzhao on 2017/4/5.
  17 + */
  18 +public class Road_DTO {
  19 +
  20 + public static List<Road_DTO> craete(List<Map<String, Object>> mapList){
  21 + List<Road_DTO> list = JSONObject.parseArray(JSON.toJSONString(mapList), Road_DTO.class);
  22 + //处理路段坐标
  23 + String polygonStr;
  24 + String[] coords;
  25 + int i, len;
  26 + String[] temps;//1, temps2;
  27 + List<Coordinate> cds;
  28 +
  29 + GeometryFactory geometryFactory = new GeometryFactory();
  30 + for(Road_DTO road : list){
  31 + polygonStr = road.getGROAD_VECTOR();
  32 + coords = polygonStr.substring(11, polygonStr.length() - 1).split(",");
  33 + len = coords.length;
  34 +
  35 + cds = new ArrayList<>();
  36 + //每2个点连一条线
  37 + for(i = 0; i < len; i ++){
  38 + temps = coords[i].split(" ");
  39 + cds.add(new Coordinate(Float.parseFloat(temps[1]), Float.parseFloat(temps[0])));
  40 + }
  41 +
  42 + Coordinate[] cdsArray = new Coordinate[cds.size()];
  43 + road.setLineStr(geometryFactory.createLineString(cds.toArray(cdsArray)));
  44 + }
  45 + return list;
  46 + }
  47 +
  48 + private long ID;
  49 +
  50 + @JsonIgnore
  51 + private String GROAD_VECTOR;
  52 +
  53 + private String ROAD_CODE;
  54 +
  55 + private String ROAD_NAME;
  56 +
  57 + private double SPEED;
  58 +
  59 + @JsonIgnore
  60 + private LineString lineStr;
  61 +
  62 + public long getID() {
  63 + return ID;
  64 + }
  65 +
  66 + public void setID(long ID) {
  67 + this.ID = ID;
  68 + }
  69 +
  70 + public String getGROAD_VECTOR() {
  71 + return GROAD_VECTOR;
  72 + }
  73 +
  74 + public void setGROAD_VECTOR(String GROAD_VECTOR) {
  75 + this.GROAD_VECTOR = GROAD_VECTOR;
  76 + }
  77 +
  78 + public String getROAD_CODE() {
  79 + return ROAD_CODE;
  80 + }
  81 +
  82 + public void setROAD_CODE(String ROAD_CODE) {
  83 + this.ROAD_CODE = ROAD_CODE;
  84 + }
  85 +
  86 + public String getROAD_NAME() {
  87 + return ROAD_NAME;
  88 + }
  89 +
  90 + public void setROAD_NAME(String ROAD_NAME) {
  91 + this.ROAD_NAME = ROAD_NAME;
  92 + }
  93 +
  94 + public double getSPEED() {
  95 + return SPEED;
  96 + }
  97 +
  98 + public void setSPEED(double SPEED) {
  99 + this.SPEED = SPEED;
  100 + }
  101 +
  102 + public LineString getLineStr() {
  103 + return lineStr;
  104 + }
  105 +
  106 + public void setLineStr(LineString lineStr) {
  107 + this.lineStr = lineStr;
  108 + }
  109 +}
... ...
src/main/java/com/bsth/service/impl/StationRouteServiceImpl.java
... ... @@ -1100,4 +1100,24 @@ public class StationRouteServiceImpl extends BaseServiceImpl&lt;StationRoute, Integ
1100 1100 }
1101 1101 return rs;
1102 1102 }
  1103 +
  1104 + @Override
  1105 + @Transactional
  1106 + public Map<String, Object> upddis(Map<String, Object> map) {
  1107 + Map<String, Object> rs = new HashMap<>();
  1108 + try{
  1109 + Iterator it = map.entrySet().iterator();
  1110 + while(it.hasNext()){
  1111 + java.util.Map.Entry entry = (java.util.Map.Entry)it.next();
  1112 + Integer id = Integer.parseInt(entry.getKey().toString().split("_")[1]); //返回对应的键
  1113 + Double dis = Double.parseDouble(entry.getValue().toString()) / 1000; //返回对应的值
  1114 + repository.upddis(id, dis);
  1115 + }
  1116 + rs.put("status", ResponseCode.SUCCESS);
  1117 + }catch(Exception e){
  1118 + logger.error("", e);
  1119 + rs.put("status", ResponseCode.ERROR);
  1120 + }
  1121 + return rs;
  1122 + }
1103 1123 }
... ...
src/main/java/com/bsth/websocket/handler/RealControlSocketHandler.java
... ... @@ -94,7 +94,7 @@ public class RealControlSocketHandler implements WebSocketHandler {
94 94 /**
95 95 * 根据线路推送消息
96 96 */
97   - public synchronized void sendMessageToLine(String lineCode, String msg) {
  97 + public void sendMessageToLine(String lineCode, String msg) {
98 98  
99 99 TextMessage message = new TextMessage(msg.getBytes());
100 100  
... ... @@ -117,4 +117,28 @@ public class RealControlSocketHandler implements WebSocketHandler {
117 117 }
118 118 }
119 119 }
  120 +
  121 +
  122 +
  123 + /**
  124 + * 全局推送
  125 + */
  126 + public void sendMessage(String msg) {
  127 +
  128 + TextMessage message = new TextMessage(msg.getBytes());
  129 +
  130 + Iterator<WebSocketSession> iterator = users.iterator();
  131 +
  132 + WebSocketSession user;
  133 + while(iterator.hasNext()){
  134 + user = iterator.next();
  135 + try {
  136 + if (user.isOpen()) {
  137 + user.sendMessage(message);
  138 + }
  139 + } catch (Exception e) {
  140 + logger.error("sendMessage error ...."+msg);
  141 + }
  142 + }
  143 + }
120 144 }
... ...
src/main/java/com/bsth/websocket/handler/SendUtils.java
... ... @@ -5,6 +5,7 @@ import com.bsth.data.BasicData;
5 5 import com.bsth.data.LineConfigData;
6 6 import com.bsth.data.gpsdata.GpsEntity;
7 7 import com.bsth.data.gpsdata.arrival.entity.SignalState;
  8 +import com.bsth.data.safe_driv.SafeDriv;
8 9 import com.bsth.entity.directive.D80;
9 10 import com.bsth.entity.realcontrol.ScheduleRealInfo;
10 11 import com.fasterxml.jackson.core.JsonProcessingException;
... ... @@ -184,4 +185,18 @@ public class SendUtils{
184 185 logger.error("", e);
185 186 }
186 187 }
  188 +
  189 + public void sendSafeDriv(SafeDriv sd){
  190 + Map<String, Object> map = new HashMap<>();
  191 + map.put("fn", "safeDriv");
  192 + map.put("t", sd);;
  193 + ObjectMapper mapper = new ObjectMapper();
  194 +
  195 + try {
  196 + socketHandler.sendMessage(mapper.writeValueAsString(map));
  197 +
  198 + } catch (JsonProcessingException e) {
  199 + logger.error("", e);
  200 + }
  201 + }
187 202 }
... ...