Commit 87d15eee4cd61fc842ee6e01c18e303858bfed0a

Authored by 潘钊
2 parents 4e3dbb9c d849b94b

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

src/main/java/com/bsth/controller/excep/SpeedingController.java
1 1 package com.bsth.controller.excep;
2 2  
  3 +import java.text.ParseException;
  4 +import java.util.ArrayList;
3 5 import java.util.HashMap;
  6 +import java.util.List;
4 7 import java.util.Map;
5 8  
6 9 import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -11,11 +14,13 @@ import org.springframework.web.bind.annotation.ResponseBody;
11 14 import org.springframework.web.bind.annotation.RestController;
12 15  
13 16 import com.bsth.controller.BaseController;
  17 +import com.bsth.data.BasicData;
14 18 import com.bsth.entity.excep.Offline;
15 19 import com.bsth.entity.excep.Speeding;
16 20 import com.bsth.entity.sys.SysUser;
17 21 import com.bsth.service.excep.OfflineService;
18 22 import com.bsth.service.excep.SpeedingService;
  23 +import com.bsth.service.gps.entity.GpsSpeed;
19 24 import com.bsth.util.PageObject;
20 25  
21 26 @RestController
... ... @@ -45,5 +50,11 @@ public class SpeedingController extends BaseController<SysUser, Integer>{
45 50 return modelMap;
46 51 }
47 52  
  53 + @RequestMapping(value = "/findPosition", method = RequestMethod.GET)
  54 + public List<Speeding> findPosition(@RequestParam String vehicle,@RequestParam String startdate,@RequestParam String enddate) throws ParseException {
  55 + String deviceid = BasicData.deviceId2NbbmMap.inverse().get(vehicle);
  56 + List<Speeding> listSpeeding = speedingService.findPosition(deviceid,startdate,enddate);
  57 + return listSpeeding;
  58 + }
48 59  
49 60 }
... ...
src/main/java/com/bsth/entity/excep/Speeding.java
... ... @@ -35,7 +35,11 @@ public class Speeding {
35 35 */
36 36 private String lineName;
37 37  
38   -
  38 + /**
  39 + * 线路ID
  40 + */
  41 + private Integer lineId;
  42 +
39 43 /**
40 44 * 上下行(0 上行 , 1 下行 , -1 无效)
41 45 */
... ... @@ -243,4 +247,12 @@ public class Speeding {
243 247 this.endtimestamp = endtimestamp;
244 248 }
245 249  
  250 + public Integer getLineId() {
  251 + return lineId;
  252 + }
  253 +
  254 + public void setLineId(Integer lineId) {
  255 + this.lineId = lineId;
  256 + }
  257 +
246 258 }
... ...
src/main/java/com/bsth/service/excep/SpeedingService.java
1 1 package com.bsth.service.excep;
2 2  
  3 +import java.util.List;
3 4 import java.util.Map;
4 5  
5 6 import com.bsth.entity.excep.Speeding;
... ... @@ -8,4 +9,6 @@ import com.bsth.util.PageObject;
8 9 public interface SpeedingService {
9 10 PageObject <Speeding> Pagequery(Map<String, Object> map) ;
10 11 Map<String, Object> getReport( Map<String, Object> map);
  12 + List<Speeding> findPosition(String deviceid, String startdate,
  13 + String enddate);
11 14 }
... ...
src/main/java/com/bsth/service/excep/impl/SpeedingServiceImpl.java
... ... @@ -7,6 +7,7 @@ import java.sql.SQLException;
7 7 import java.text.ParseException;
8 8 import java.text.SimpleDateFormat;
9 9 import java.util.ArrayList;
  10 +import java.util.Calendar;
10 11 import java.util.Date;
11 12 import java.util.HashMap;
12 13 import java.util.Iterator;
... ... @@ -18,8 +19,10 @@ import org.springframework.stereotype.Service;
18 19 import org.springframework.beans.factory.annotation.Autowired;
19 20  
20 21 import com.bsth.data.BasicData;
  22 +import com.bsth.entity.excep.Outbound;
21 23 import com.bsth.entity.excep.Speeding;
22 24 import com.bsth.service.excep.SpeedingService;
  25 +import com.bsth.service.gps.entity.GpsSpeed;
23 26 import com.bsth.util.EchartConver;
24 27 import com.bsth.util.PageHelper;
25 28 import com.bsth.util.PageObject;
... ... @@ -40,24 +43,17 @@ public class SpeedingServiceImpl implements SpeedingService {
40 43 ResultSet rs = null;
41 44 int page=Integer.parseInt(map.get("page").toString());
42 45 List<Speeding> list=new ArrayList<Speeding>();
43   - String sql="select * from bsth_c_speeding where 1=1 ";
  46 + String sql="select * from bsth_c_speedingmh where 1=1 ";
44 47 Object line=map.get("line");
45   - Object nbbm=map.get("nbbm");
46 48 Object updown=map.get("updown");
47 49 Object startDate=map.get("startDate");
48 50 Object endDate=map.get("endDate");
  51 + Object times=map.get("times");
49 52  
50 53 SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
51 54 if(line!=null){
52 55 sql +=" and line like'%"+line.toString().trim()+"%'";
53 56 }
54   -
55   - if(nbbm!=null){
56   - nbbm=BasicData.deviceId2NbbmMap.inverse().get(nbbm);
57   - if(nbbm!=null)
58   - sql +=" and vehicle like '%"+nbbm.toString()+"%'";
59   - }
60   -
61 57 if(updown!=null){
62 58 sql +="and up_down like '%"+updown.toString()+"%'";
63 59 }
... ... @@ -65,41 +61,42 @@ public class SpeedingServiceImpl implements SpeedingService {
65 61 if (startDate.toString().length()>0) {
66 62 try {
67 63 Long t1=sdf.parse(startDate.toString()+" 00:00:00").getTime();
68   - sql += " and timestamp >="+t1;
  64 + sql += " and startTimestamp >="+t1;
69 65 } catch (ParseException e) {
70 66 e.printStackTrace();
71 67 }
72 68 }
73   -
74 69 }
75 70 if(endDate!=null){
76 71 if (endDate.toString().length()>0) {
77 72 try {
78 73 Long t2=sdf.parse(endDate.toString()+" 23:59:59").getTime();
79   - sql += " and timestamp <="+t2;
  74 + sql += " and endTimestamp <="+t2;
80 75 } catch (ParseException e) {
81 76 e.printStackTrace();
82 77 }
83 78 }
84 79  
85 80 }
86   -
87   - /*sql +=" order by id limit ?,?";*/
88 81  
  82 + if(times!=null && times.toString().length()>0){
  83 + sql +=" and (endTimestamp-startTimestamp) >="+Integer.valueOf(times.toString())*1000;
  84 + }
  85 +
  86 + sql +=" order by startTimestamp limit ?,?";
89 87  
90 88 try {
91 89 conn = DBUtils_MS.getConnection();
92 90 ps = conn.prepareStatement(sql);
93   - /* ps.setInt(1, page*10); // O-最大条数 -- M-起始条数
  91 + ps.setInt(1, page*10); // O-最大条数 -- M-起始条数
94 92 ps.setInt(2, 10); // O-最小条数 -- M-显示条数
95   -*/ rs = ps.executeQuery();
  93 + rs = ps.executeQuery();
96 94 list = resultSet2Set(rs);
97 95 } catch (SQLException e) {
98 96 e.printStackTrace();
99 97 }finally {
100 98 DBUtils_MS.close(rs, ps, conn);
101 99 }
102   -
103 100 return list;
104 101 }
105 102  
... ... @@ -107,25 +104,27 @@ public class SpeedingServiceImpl implements SpeedingService {
107 104 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
108 105 List<Speeding> list=new ArrayList<Speeding>();
109 106 Speeding speeding;
110   - Float lon, lat;
111 107 Location location;
112 108 while(rs.next()){
113   - lon = rs.getFloat("lon");
114   - lat = rs.getFloat("lat");
115   - location = TransGPS.LocationMake(lon, lat);
116   - location = TransGPS.bd_encrypt(TransGPS.transformFromWGSToGCJ(location));
117 109 speeding=new Speeding();
118   - speeding.setId(Integer.valueOf(rs.getObject("id").toString()));
119   - speeding.setLon((float)location.getLng());
120   - speeding.setLat((float)location.getLat());
121   - speeding.setLine(Integer.valueOf(rs.getObject("line").toString()));
  110 + speeding.setId(rs.getInt("id"));
  111 + speeding.setVehicle(BasicData.deviceId2NbbmMap.get(rs.getObject("vehicle").toString()));
  112 + speeding.setLine(rs.getInt("line"));
122 113 //run 时注解
123 114 speeding.setLineName(BasicData.lineCode2NameMap.get(speeding.getLine().toString()));
124   - speeding.setSpeed(Float.valueOf(rs.getObject("speed").toString()));
125   - speeding.setTimestamp((Long.valueOf(rs.getObject("timestamp").toString())));
  115 + speeding.setLineId(BasicData.lineId2CodeMap.inverse().get(speeding.getLine().toString()));
  116 + speeding.setUpDown(rs.getInt("up_down"));
  117 + //将gps的经纬度转成百度的经纬度
  118 + location = TransGPS.bd_encrypt(TransGPS.transformFromWGSToGCJ(TransGPS.LocationMake(rs.getFloat("startLon"), rs.getFloat("startLat"))));
  119 + speeding.setLon((float)location.getLng());
  120 + speeding.setLat((float)location.getLat());
  121 + location = TransGPS.bd_encrypt(TransGPS.transformFromWGSToGCJ(TransGPS.LocationMake(rs.getFloat("endLon"), rs.getFloat("endLat"))));
  122 + speeding.setEndlon((float)location.getLng());
  123 + speeding.setEndlat((float)location.getLat());
  124 + speeding.setTimestamp((Long.valueOf(rs.getObject("startTimestamp").toString())));
126 125 speeding.setTimestampDate(sdf.format(new Date(speeding.getTimestamp())));
127   - speeding.setUpDown(Integer.valueOf(rs.getObject("up_down").toString()));
128   - speeding.setVehicle(BasicData.deviceId2NbbmMap.get(rs.getObject("vehicle").toString()));
  126 + speeding.setEndtimestamp((Long.valueOf(rs.getObject("endTimestamp").toString())));
  127 + speeding.setEndtimestampDate(sdf.format(new Date(speeding.getEndtimestamp())));
129 128 list.add(speeding);
130 129 }
131 130 return list;
... ... @@ -133,52 +132,49 @@ public class SpeedingServiceImpl implements SpeedingService {
133 132  
134 133 @Override
135 134 public PageObject<Speeding> Pagequery(Map<String, Object> map) {
136   -/* String sql="select count(*) record from bsth_c_speeding where 1=1 ";
  135 + String sql="select count(*) record from bsth_c_speedingmh where 1=1 ";
  136 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
137 137 Object line=map.get("line");
138   - Object nbbm=map.get("nbbm");
139 138 Object updown=map.get("updown");
140 139 Object startDate=map.get("startDate");
141 140 Object endDate=map.get("endDate");
  141 + Object times=map.get("times");
142 142  
143 143 if(line!=null){
144 144 sql +=" and line like'%"+line.toString().trim()+"%'";
145 145 }
146   -
147   - if(nbbm!=null){
148   - nbbm=BasicData.deviceId2NbbmMap.inverse().get(nbbm);
149   - if(nbbm!=null)
150   - sql +=" and vehicle like '%"+nbbm.toString()+"%'";
151   - }
152 146 if(updown!=null){
153 147 sql +="and up_down like '%"+updown.toString()+"%'";
154 148 }
155 149 if(startDate!=null){
156 150 if (startDate.toString().length()>0) {
157 151 try {
158   - Long t1=sdf.parse(startDate.toString()+" 00:00:00").getTime();
159   - sql += " and timestamp >="+t1;
  152 + Long t1 = sdf.parse(startDate.toString()+" 00:00:00").getTime();
  153 + sql += " and startTimestamp >="+t1;
160 154 } catch (ParseException e) {
161 155 e.printStackTrace();
162 156 }
163 157 }
164   -
165 158 }
166 159 if(endDate!=null){
167 160 if (endDate.toString().length()>0) {
168 161 try {
169 162 Long t2=sdf.parse(endDate.toString()+" 23:59:59").getTime();
170   - sql += " and timestamp <="+t2;
  163 + sql += " and endTimestamp <="+t2;
171 164 } catch (ParseException e) {
172 165 e.printStackTrace();
173 166 }
174 167 }
175   -
176 168 }
  169 +
  170 + if(times!=null && times.toString().length()>0){
  171 + sql +=" and (endTimestamp-startTimestamp) >="+Integer.valueOf(times.toString())*1000;
  172 + }
  173 +
177 174 Connection conn = null;
178 175 PreparedStatement ps = null;
179 176 ResultSet rs = null;
180 177 int totalData = 0;
181   -
182 178 try {
183 179 conn = DBUtils_MS.getConnection();
184 180 ps = conn.prepareStatement(sql);
... ... @@ -190,93 +186,14 @@ public class SpeedingServiceImpl implements SpeedingService {
190 186 e.printStackTrace();
191 187 }finally {
192 188 DBUtils_MS.close(rs, ps, conn);
193   - }*/
194   -
195   - //时间转换
196   - SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
197   - List<Speeding> list=findAll(map);
198   - List<Speeding> listResult = new ArrayList<Speeding>();
199   - int curPage;//页码
200   - int pageData;//每页的记录条数
201   - int start;//起始数据下标
202   - int totalPage;//总页数
203   - int totalData = 0;
204   - if(list.size()>1){
205   - Speeding speedingNow;//下标为i的车辆行驶记录
206   - Speeding speedingLast;//下标为i-1的车辆行驶记录
207   - Speeding spped = null;//整合后的车辆行驶记录
208   - String strNow;
209   - String strLast;
210   - boolean Flag = false;//判断是否有连续超速记录,默认没有
211   - for(int i = 1;i<list.size();i++){
212   - speedingNow = list.get(i);
213   - speedingLast = list.get(i-1);
214   - strNow = speedingNow.getVehicle()+speedingNow.getLine()+speedingNow.getUpDown();
215   - strLast = speedingLast.getVehicle()+speedingLast.getLine()+speedingLast.getUpDown();
216   - if(speedingNow.getSpeed()>60 && speedingLast.getSpeed()>60 && strNow.equals(strLast)){//如果两条连续的记录都是超速且属于同一辆车。
217   - if(Flag==false){//
218   - spped = new Speeding();
219   - spped.setId(speedingLast.getId());//设置连续超速记录Id
220   - spped.setLine(speedingLast.getLine());//设置连续超速记录线路
221   - spped.setLineName(speedingLast.getLineName());//设置连续超速记录线路名称
222   - spped.setVehicle(speedingLast.getVehicle());//设置连续超速记录的车辆编号
223   - spped.setUpDown(speedingLast.getUpDown());//设置上下行
224   - spped.setLon(speedingLast.getLon());//设置开始时经度
225   - spped.setLat(speedingLast.getLat());//设置开始时纬度
226   - spped.setTimestamp(speedingLast.getTimestamp());//设置连续超速记录的开始时间
227   - spped.setTimestampDate(speedingLast.getTimestampDate());//设置连续超速记录的开始时间戳
228   - }
229   - spped.setEndtimestamp(speedingNow.getTimestamp());//设置结束时间戳
230   - spped.setEndtimestampDate(sdf.format(new Date(speedingNow.getTimestamp())));//设置结束时间
231   - spped.setEndlon(speedingNow.getLon());//设置结束时的经度
232   - spped.setEndlat(speedingNow.getLat());//设置结束时的纬度
233   - Flag = true;
234   - }else{
235   - if(Flag){//如果上一条记录超速。
236   - listResult.add(spped);
237   - Flag = false;
238   - }
239   - }
240   - }
241   - Iterator<Speeding> speedIt = listResult.iterator();
242   - while(speedIt.hasNext()){
243   - Speeding speeding = speedIt.next();
244   - if(speeding.getEndtimestamp()-speeding.getTimestamp()<=1000){
245   - speedIt.remove();
246   - }
247   - }
248   -
249   - totalData = listResult.size();//总记录条数。
250   - if(map.get("curPage") == null || map.get("curPage").equals("0")){
251   - curPage = 0;
252   - }else{
253   - curPage = Integer.parseInt((String) map.get("curPage"));
254   - }
255   - pageData = Integer.parseInt((String) map.get("pageData"));//每页的记录条数
256   - start = (curPage - 0) * pageData; //起始记录下标。
257   - totalPage = totalData % pageData == 0 ? totalData / pageData : totalData / pageData +1;//总页数
258   - if(curPage == totalPage-1){//如果当前页等于总页数。
259   - listResult = listResult.subList(start, totalData);
260   - }else{
261   - listResult = listResult.subList(start, start+pageData);
262   - }
263   - }else{
264   - curPage = 1;
265   - pageData = Integer.parseInt((String) map.get("pageData"));//每页的记录条数
266   - totalPage =1;
267 189 }
268   - Map<String,Object> paramMap = new HashMap<String,Object>();
269   - paramMap.put("totalPage", totalPage);
270   - paramMap.put("curPage", curPage);
271   - paramMap.put("pageData", pageData);
272   - PageHelper pageHelper = new PageHelper(totalData, paramMap);
273   - pageHelper.getMap();
  190 + PageHelper pageHelper = new PageHelper(totalData, map);
  191 + List<Speeding> list=findAll(pageHelper.getMap());
274 192 PageObject<Speeding> pageObject = pageHelper.getPageObject();
275   - pageObject.setDataList(listResult);
  193 + pageObject.setDataList(list);
276 194 return pageObject;
277 195 }
278 196  
279   -
280 197 @Override
281 198 public Map<String, Object> getReport(Map<String, Object> map) {
282 199 String chartStr = "";
... ... @@ -393,5 +310,46 @@ public class SpeedingServiceImpl implements SpeedingService {
393 310 }
394 311  
395 312  
  313 + @Override
  314 + public List<Speeding> findPosition(String deviceid, String startdate,
  315 + String enddate){
  316 + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  317 + String sql = "select id,vehicle,line,up_down,lon,lat,speed,timestamp from bsth_c_speeding where vehicle = ? and timestamp >= ? and timestamp <= ? order by timestamp ";
  318 + Connection conn = null;
  319 + PreparedStatement ps = null;
  320 + ResultSet rs = null;
  321 + List<Speeding> listResult = new ArrayList<Speeding>();
  322 + Speeding speed = null;
  323 + try {
  324 + conn = DBUtils_MS.getConnection();
  325 + ps = conn.prepareStatement(sql);
  326 + long startTime = sdf.parse(startdate).getTime();
  327 + long endTime = sdf.parse(enddate).getTime();
  328 + ps.setString(1, deviceid);
  329 + ps.setLong(2,startTime);
  330 + ps.setLong(3,endTime);
  331 + rs = ps.executeQuery();
  332 + Location location;
  333 + while (rs.next()) {
  334 + speed = new Speeding();
  335 + speed.setVehicle(rs.getString("vehicle"));
  336 + location = TransGPS.LocationMake(rs.getFloat("lon"), rs.getFloat("lat"));
  337 + location = TransGPS.bd_encrypt(TransGPS.transformFromWGSToGCJ(location));
  338 + speed.setLon((float)location.getLng());
  339 + speed.setLat((float)location.getLat());
  340 + speed.setSpeed(rs.getFloat("speed"));
  341 + speed.setTimestamp(rs.getLong("timestamp"));
  342 + // 上下行
  343 + listResult.add(speed);
  344 + }
  345 + } catch (Exception e) {
  346 + e.printStackTrace();
  347 + } finally {
  348 + DBUtils_MS.close(rs, ps, conn);
  349 + }
  350 + return listResult;
  351 +
  352 + }
  353 +
396 354  
397 355 }
... ...
src/main/resources/static/pages/excep/boundList.html
... ... @@ -262,8 +262,8 @@ $(function(){
262 262 }
263 263 }
264 264 });
265   - page = num - 1;
266   - jsDoQuery(params, false);
  265 + page = num - 1;
  266 + jsDoQuery(params, false);
267 267 }
268 268 });
269 269 }
... ...
src/main/resources/static/pages/excep/js/speeding-map.js
... ... @@ -3,33 +3,23 @@
3 3 *
4 4 * - - - - - -》init:地图初始化
5 5 *
6   - * - - - - - -》lineInfoPanl:从百度地图抓去站点与路段数据
7   - *
8 6 * - - - - - -》getDistanceAndDuration:获取距离与时间
9 7 *
10   - * - - - - - -》pointsPolygon:地图画多边行
11   - *
12   - * - - - - - -》pointsCircle:画圆
13   - *
14   - * - - - - - -》localSearchFromAdreesToPoint:根据地理名称获取百度经纬度坐标
15   - *
16 8 * - - - - - -》drawingUpline:在地图上画出上行线路走向
17 9 *
18   - * - - - - - -》stationsNameToPoints:站点名称获取百度坐标(手动规划)
19   - *
20   - * - - - - - -》getDistanceAndTotime:根据坐标点获取两点之间的时间与距离(手动规划)
21   - *
22   - * - - - - - -》getSectionListPlonly:根据坐标点获取两点之间的折线路段(手动规划)
  10 + * - - - - - -》stationsPointsToLibraryPoint:根据站点坐标匹配库中的公交站点(手动规划)
23 11 */
24 12  
25 13 var SpeedingMap = function () {
26 14  
27   - /** WorldsBMap 全局变量定义 mapBValue:地图对象;polygon:多边形;polyUpline:走向折线;circle:圆 *//*
28   - var mapBValue = '';polygon='',polyUpline='',circle='',iseditStatus = false;*/
  15 + /** SpeedingMap 全局变量定义 mapBValue:地图对象;polyUpline:走向折线;sectionList:截取过的路段 ;pointIndex:计算路段被切的次数;
  16 + * firstPoint:截取路段的第一个点;iseditStatus:路段是否在编辑状态;isCutSection : 获取路段是否在截取状态*/
  17 + var mapBValue = '', polyUpline='', sectionList = [], pointIndex = 0, iseditStatus = false, firstPoint = {}, isCutSection = false;
29 18  
30 19 var Bmap = {
31 20  
32 21 init : function() {
  22 +
33 23 // 设置中心点,
34 24 var CENTER_POINT = {lng : 121.528733,lat : 31.237425};
35 25  
... ... @@ -40,7 +30,7 @@ var SpeedingMap = function () {
40 30 mapBValue = new BMap.Map("speedingMap");
41 31  
42 32 //中心点和缩放级别
43   - mapBValue.centerAndZoom(new BMap.Point(CENTER_POINT.lng,CENTER_POINT.lat), 15);
  33 + mapBValue.centerAndZoom(new BMap.Point(CENTER_POINT.lng,CENTER_POINT.lat),15);
44 34  
45 35 //启用地图拖拽事件,默认启用(可不写)
46 36 mapBValue.enableDragging();
... ... @@ -56,7 +46,10 @@ var SpeedingMap = function () {
56 46  
57 47 return mapBValue;
58 48 },
59   -
  49 + /** 获取第一个切路段的点 @return Point*/
  50 + getFirstPoint : function() {
  51 + return firstPoint;
  52 + },
60 53 /** 获取地图对象 @return 地图对象map */
61 54 getmapBValue : function() {
62 55  
... ... @@ -64,10 +57,337 @@ var SpeedingMap = function () {
64 57  
65 58 },
66 59  
67   - /* drawTravelRoute:function(data){
68   - var driving = Bmap.DrivingRoute(map, {renderOptions:{map: map}})
  60 + getPolyUpline : function() {
  61 +
  62 + return polyUpline;
  63 + },
  64 +
  65 + /** 获取截取过的路段 @return 路段对象List */
  66 + getSectionList : function() {
  67 +
  68 + return sectionList;
  69 +
  70 + },
  71 + setSectionList : function(list) {
  72 +
  73 + sectionList = list;
  74 + },
  75 + initCutSectionPoint : function() {
  76 + sectionList = [];
  77 + var tbodyHtml = template('section_list',{list : sectionList});
  78 + $('#section_table tbody').html(tbodyHtml);
  79 + },
  80 + /** 获取切路段的点下标 @return int*/
  81 + setPointIndex : function(index) {
  82 + pointIndex = index;
  83 + },
  84 + getPointIndex : function() {
  85 +
  86 + return pointIndex;
  87 +
  88 + },
  89 + /** 获取路段是否在编辑状态 @return boolean*/
  90 + getIsEditStatus : function() {
  91 + return iseditStatus;
  92 + },
  93 + setIsEditStatus : function(v) {
  94 + iseditStatus = v ;
  95 + },
  96 +
  97 + /** 获取路段是否在截取状态 @return boolean*/
  98 + getIsCutSection : function() {
  99 + return isCutSection;
  100 + },
  101 + setIsCutSection : function(v) {
  102 + isCutSection = v ;
  103 + },
  104 +
  105 + /** 获取距离与时间 @param <points:坐标点集合> */
  106 + getDistanceAndDuration : function(points,callback){
  107 +
  108 + // 获取长度
  109 + var len = points.length;
  110 + (function(){
  111 +
  112 + if (!arguments.callee.count) {
  113 +
  114 + arguments.callee.count = 0;
  115 +
  116 + }
  117 +
  118 + arguments.callee.count++;
  119 +
  120 + var index = parseInt(arguments.callee.count) - 1;
  121 +
  122 + if (index >= len-1) {
  123 +
  124 + callback && callback(points);
  125 +
  126 + return;
  127 + }
  128 +
  129 + // 当函数被调用时,它的arguments.callee对象就会指向自身,也就是一个对自己的引用。(当前正在执行的函数。)
  130 + var f = arguments.callee;
  131 + // 起点坐标 <坐标格式:40.056878,116.30815>
  132 + var origin = points[index].potion.lat + ',' + points[index].potion.lng;
  133 +
  134 + // 终点坐标 <坐标格式:40.056878,116.30815>
  135 + var destination = points[index+1].potion.lat + ',' + points[index+1].potion.lng;
  136 + var region = '上海';
  137 +
  138 + var origin_region = '上海';
  139 +
  140 + var destination_region = '上海';
  141 +
  142 + var output = 'json';
  143 +
  144 + var ak_My = 'wjlITmXeCek5MxyU3ZUBkTeU8B0o0npk';
  145 +
  146 + /**
  147 + * origin:起点名称或经纬度;
  148 + *
  149 + * destination:终点名称或经纬度;
  150 + *
  151 + * origin_region:起始点所在城市,驾车导航时必填。
  152 + *
  153 + * destination_region:终点所在城市,驾车导航时必填。
  154 + *
  155 + * output :表示输出类型,可设置为xml或json,默认为xml。
  156 + *
  157 + **/
  158 + var paramsB = {origin:origin,destination:destination,region:region,origin_region:origin_region,destination_region:destination_region,output:output,ak:ak_My};
  159 +
  160 + /** @description :未认证开发者默认配额为:2000次/天。 */
  161 + $.ajax({
  162 +
  163 + // 百度地图根据坐标获取两点之间的时间与距离
  164 + url: 'http://api.map.baidu.com/direction/v1?mode=transit',
  165 +
  166 + data: paramsB,
  167 +
  168 + dataType: 'jsonp',
  169 +
  170 + success: function(r){
  171 +
  172 + if(r) {
  173 +
  174 + if(r.message=='ok') {
  175 +
  176 + if(r.result.taxi==null) {
  177 +
  178 + // 获取距离(单位:米)
  179 + points[index+1].distance = 0;
  180 +
  181 + // 获取时间(单位:秒)
  182 + points[index+1].duration = 0;
  183 +
  184 + }else {
  185 +
  186 + // 获取距离(单位:米)
  187 + points[index+1].distance = r.result.taxi.distance;
  188 +
  189 + // 获取时间(单位:秒)
  190 + points[index+1].duration = r.result.taxi.duration;
  191 +
  192 + }
  193 +
  194 +
  195 + }
  196 +
  197 + }
  198 +
  199 + f();
  200 + }
  201 + });
  202 +
  203 + })();
  204 +
  205 + },
  206 + // 在地图上画出上行线路走向
  207 + drawingUpline01 : function (polylineArray,polyline_center,data) {
  208 + var polyUpline01 = 'polyline' + '_' + data.sectionrouteId;
  209 + // 创建线路走向
  210 + polyUpline01 = new BMap.Polyline(polylineArray, {strokeColor : "blue",strokeWeight : 6,strokeOpacity : 0.5});
  211 + polyUpline01.data = data;
  212 + // 把折线添加到地图上
  213 + mapBValue.addOverlay(polyUpline01);
  214 + var sectionPoint = [];
  215 + // 线路单击事件
  216 + polyUpline01.addEventListener('click',function(e) {
  217 + if(SpeedingMap.getIsEditStatus()) {
  218 + layer.msg('请先保存正在编辑的路段信息...');
  219 + return false;
  220 + }
  221 + if(SpeedingMap.getIsCutSection()) {
  222 + layer.msg('请先撤销所有切路段的点...');
  223 + return false;
  224 + }
  225 + polyUpline01.enableEditing();
  226 + SpeedingMap.setIsEditStatus(true);
  227 + });
  228 +
  229 + // 添加路段双击事件
  230 + polyUpline01.addEventListener("dblclick",function(e){
  231 + if(SpeedingMap.getIsCutSection()) {
  232 + layer.msg('请先撤销所有切路段的点...');
  233 + return false;
  234 + }
  235 + SpeedingMap.setIsEditStatus(false);
  236 + // 关闭
  237 + layer.closeAll();
  238 + polyUpline01.disableEditing();
  239 + EditSectionObj.setEitdSection(polyUpline01.data);
  240 + // 获取折线坐标集合
  241 + var editPloyLineArray = polyUpline01.getPath();
  242 + EditSectionObj.setEitdBsectionVector(JSON.stringify(editPloyLineArray));
  243 + sectionList = [];
  244 + var tbodyHtml = template('section_list',{list : sectionList});
  245 + // 截取路段
  246 + $('#section_table tbody').html(tbodyHtml);
  247 + // 加载修改路段弹出层mobal页面
  248 + $.get('editsection.html', function(m){
  249 + $(pjaxContainer).append(m);
  250 + $('#edit_section_mobal_cache').trigger('editSectionMobalCache_show', [SpeedingMap,GetAjaxData,EditSectionObj,PublicFunctions]);
  251 + });
  252 + });
  253 +
  254 + // 路段右击事件
  255 + var editSection = function(e,ee,marker){
  256 + if(SpeedingMap.getIsEditStatus()) {
  257 + layer.msg('请先保存正在编辑的路段信息...');
  258 + return false;
  259 + }
  260 + var lng = e.lng;
  261 + var lat = e.lat;
  262 + var sectionName = null;
  263 + var marker = new BMap.Marker(new BMap.Point(lng, lat)); // 创建点
  264 + marker.isFlag = true;
  265 + if(pointIndex == 0) {
  266 + sectionPoint[pointIndex] = {lng:lng , lat:lat};
  267 + layer.msg('进入切路段状态,请选择本路段的终点!');
  268 + mapBValue.addOverlay(marker);// 添加覆盖物
  269 + firstPoint = {lng:lng, lat:lat};
  270 + pointIndex++;
  271 + EditSectionObj.setEitdSection(polyUpline01.data);
  272 + // 获取折线坐标集合
  273 + var editPloyLineArray = polyUpline01.getPath();
  274 + EditSectionObj.setEitdBsectionVector(JSON.stringify(editPloyLineArray));
  275 + } else if (pointIndex > 0) {
  276 + layer.prompt({title: '请输入路段名!'}, function(sectionName, index){
  277 + pointList = [];
  278 + sectionPoint[pointIndex] = {lng:lng , lat:lat};
  279 + pointList[0] = sectionPoint[pointIndex-1];
  280 + pointList[1] = sectionPoint[pointIndex];
  281 + sectionList.push({name:sectionName, section:pointList});
  282 + layer.close(index);
  283 + layer.msg('路段截取成功,请选择下一个路段的终点');
  284 + mapBValue.addOverlay(marker);// 添加覆盖物
  285 + var tbodyHtml = template('section_list',{list : sectionList});
  286 + // 截取路段
  287 + $('#section_table tbody').html(tbodyHtml);
  288 + pointIndex++;
  289 + });
  290 + }
  291 + SpeedingMap.setIsCutSection(true);
  292 + }
  293 + var markerMenu=new BMap.ContextMenu();
  294 + markerMenu.addItem(new BMap.MenuItem('切路段',editSection.bind(polyUpline01)));
  295 + polyUpline01.addContextMenu(markerMenu);
  296 +
  297 +
  298 + var PanOptions_ ={noAnimation :true};
  299 + mapBValue.reset();
  300 + mapBValue.panTo(polyline_center,PanOptions_);
  301 + mapBValue.panBy(500,-510,PanOptions_);
  302 + mapBValue.setZoom(14);
  303 + },
  304 + // 删除点刷新cutSectionTable
  305 + refreshCutSectionTable : function() {
  306 + var tbodyHtml = template('section_list',{list : sectionList});
  307 + $('#section_table tbody').html(tbodyHtml);
  308 + },
  309 + // 删除点刷新覆盖物
  310 + deleteCutSectionPoint : function(point) {
  311 + var lng = point.lng;
  312 + var lat = point.lat;
  313 + var allOverlay = mapBValue.getOverlays();
  314 + // 删除最后一个点
  315 + for (var i = 0; i < allOverlay.length -1; i++){
  316 + if(allOverlay[i].isFlag) {
  317 + if(allOverlay[i].point.lng == lng && allOverlay[i].point.lat == lat){
  318 + mapBValue.removeOverlay(allOverlay[i]);
  319 + break;
  320 + }
  321 + }
  322 + }
  323 + },
  324 + /** 在地图上画点 @param:<point_center:中心坐标点> */
  325 + drawingUpStationPoint : function(point_center,stationName,s) {
  326 +
  327 + // 自定义标注物图片
  328 + var icon_target = new BMap.Icon('/pages/base/stationroute/css/img/gjzd.png',new BMap.Size(10, 10));
  329 +
  330 + var html2 = '<div style="position: absolute; margin: 0pt; padding: 0pt; width: 160px; height: 26px; left: -10px; top: -35px; overflow: hidden;">'
  331 + + '<img class="rm3_image" style="border:none;left:0px; top:0px; position:absolute;" src="/pages/base/stationroute/css/img/back160.png">'
  332 + + '</div>'
  333 + + '<label class=" BMapLabel" unselectable="on" style="position: absolute; -moz-user-select: none; display: inline; cursor: inherit; border: 0px none; padding: 2px 1px 1px; white-space: nowrap; font: 12px arial,simsun; z-index: 80; color: rgb(255, 102, 0); left: 15px; top: -35px;"><span style="float: left; color: #fdfdfd; margin-left: -22px; font-size: 6px;">'+ s+'</span>'+ stationName+'</label>';
  334 +
  335 +
  336 + var myRichMarker1 = new BMapLib.RichMarker(html2, point_center,{
  337 + "anchor" : new BMap.Size(-10,8),
  338 + "enableDragging" : true});
  339 +
  340 +
  341 + myRichMarker1.disableDragging();
  342 + mapBValue.addOverlay(myRichMarker1);
  343 +
  344 +
  345 + // 创建标注物
  346 + marker = new BMap.Marker(point_center,{icon : icon_target});
  347 +
  348 + // 允许覆盖物在map.clearOverlays方法中被清除。
  349 + marker.enableMassClear();
  350 +
  351 + mapBValue.addOverlay(marker);
  352 + },
  353 +
  354 + // 根据站点坐标匹配库中的公交站点(手动规划)
  355 + stationsPointsToLibraryPoint : function(arra,callback) {
  356 + // 获取长度
  357 + var len = arra.length;
  358 + var station = {};
  359 + var stationList = [];
  360 + (function(){
  361 + if (!arguments.callee.count) {
  362 + arguments.callee.count = 0;
  363 + }
  364 + arguments.callee.count++;
  365 + var index = parseInt(arguments.callee.count) - 1;
  366 + if (index >= len) {
  367 + callback && callback(stationList);
  368 + return ;
  369 + }
  370 + var f = arguments.callee;
  371 + station = arra[index];
  372 + if(arra[index].name!=''){
  373 +
  374 + $.get('/station/matchStation',station,function(resultStation) {
  375 + stationList.push({name:resultStation.name ,wgs:arra[index].wgs,potion:{lng:resultStation.potion_lng, lat:resultStation.potion_lat}, isHave:resultStation.isHave , id:resultStation.id});
  376 + f();
  377 + });
  378 + }else {
  379 + f();
  380 + }
  381 + })()
  382 + },
  383 + clearMarkAndOverlays : function() {
  384 +
  385 + // 清楚地图覆盖物
  386 + mapBValue.clearOverlays();
  387 +
  388 + mapBValue.removeOverlay();
69 389  
70   - }*/
  390 + }
71 391  
72 392 }
73 393  
... ...
src/main/resources/static/pages/excep/speedingListmh.html
... ... @@ -59,15 +59,16 @@
59 59 <option value="1">下行</option>
60 60 <option value="-1">无效</option>
61 61 </select>
62   - </td>
  62 + </td>
63 63 <td>
64 64 <input class="form-control" type="date" name="startDate" />
65   - -
66   - <input class="form-control" type="date" name="endDate" />
67 65 </td>
68 66 <td>
  67 + <input class="form-control" type="date" name="endDate" />
69 68 </td>
70 69 <td>
  70 + >=<input class="form-control" type="text" name="times" style="width:50px;display:inline!important"
  71 + onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();"/>
71 72 </td>
72 73 <td>
73 74 </td>
... ... @@ -104,9 +105,9 @@
104 105 {{obj.vehicle}}
105 106 </td>
106 107 <td>
107   - {{if obj.up_down==0}}
  108 + {{if obj.upDown==0}}
108 109 上行
109   - {{else if obj.up_down==1}}
  110 + {{else if obj.upDown==1}}
110 111 下行
111 112 {{else}}
112 113 无效
... ... @@ -124,9 +125,9 @@
124 125 <td>
125 126 <a class="btn default blue-stripe btn-sm lookTrajectory" data-vehicle ="{{obj.vehicle}}"
126 127 data-startdate="{{obj.timestampDate}}" data-enddate="{{obj.endtimestampDate}}"
127   - data-lon="{{obj.lon}}" data-lat="{{obj.lat}}"
128   - data-endlon="{{obj.endlon}}" data-endlat="{{obj.endlat}}" >
129   - 查看轨迹
  128 + data-lon="{{obj.lon}}" data-lat="{{obj.lat}}" data-endlon="{{obj.endlon}}"
  129 + data-endlat="{{obj.endlat}}" data-lineid="{{obj.lineId}}" data-updown="{{obj.upDown}}">
  130 + 查看轨迹
130 131 </a>
131 132 </td>
132 133 <td>
... ... @@ -163,7 +164,7 @@ $(function(){
163 164 var parameter = new Object();
164 165 parameter.endDate = $("input[name='endDate']")[0].value;
165 166 parameter.startDate = $("input[name='startDate']")[0].value;
166   -
  167 + jsDoQuery(parameter, true);
167 168 //搜索线路
168 169 $.get('/basic/lineCode2Name',function(result){
169 170 var data=[];
... ... @@ -171,11 +172,7 @@ $(function(){
171 172 for(var code in result){
172 173 data.push({id: code, text: result[code]});
173 174 }
174   - initPinYinSelect2($('#line'),data,function(ldmcSelector) {
175   - ldmcSelector.select2("val",data[1].id);//因为数据量太大,所以默认一条线路作为查询参数
176   - });
177   - parameter.line = data[1].id;
178   - jsDoQuery(parameter,true);
  175 + initPinYinSelect2('#line',data,'');
179 176 });
180 177  
181 178 //时间戳转换为年月日
... ... @@ -222,12 +219,12 @@ $(function(){
222 219 params['order'] = 'lastLoginDate';
223 220 params['page'] = page;
224 221 var i = layer.load(2);
225   - $.get('/gps/pagequery' ,params, function(data){
226   - var bodyHtm = template('speeding_list_temp', {list: data.list});
  222 + $get('/speeding/pagequery' ,params, function(data){
  223 + var bodyHtm = template('speeding_list_temp', {list: data.dataList});
227 224 $('#datatable_speeding tbody').html(bodyHtm)
228 225 .find('.icheck').iCheck(icheckOptions)
229 226 .on('ifChanged', iCheckChange);
230   - if(pagination){
  227 + if(pagination && data.dataList.length > 0){
231 228 //重新分页
232 229 initPagination = true;
233 230 showPagination(data);
... ... @@ -241,8 +238,10 @@ $(function(){
241 238 var lat = $(this).data('lat');
242 239 var endLon = $(this).data('endlon');
243 240 var endLat = $(this).data('endlat');
  241 + var lineid = $(this).data('lineid');
  242 + var upDown = $(this).data('updown');
244 243 var storage = window.localStorage;
245   - storage.setItem("zbhAndDate",vehicle+","+startDate+","+endDate+","+lon+","+lat+","+endLon+","+endLat);
  244 + storage.setItem("zbhAndDate",vehicle+","+startDate+","+endDate+","+lon+","+lat+","+endLon+","+endLat+","+lineid+","+upDown);
246 245 $.get('/pages/excep/speedingMap.html?',function (result) {
247 246 layer.open({
248 247 type: 1,
... ... @@ -288,25 +287,24 @@ $(function(){
288 287 initPagination = false;
289 288 return;
290 289 }
291   - page = num - 1;
292 290 var cells = $('tr.filter')[0].cells
293 291 ,params = {}
294 292 ,name;
295   - $.each(cells, function(i, cell){
296   - var items = $('input,select', cell);
297   - for(var j = 0, item; item = items[j++];){
298   - name = $(item).attr('name');
299   - if(name){
300   - params[name] = $(item).val();
301   - }
  293 + $.each(cells, function(i, cell){
  294 + var items = $('input,select', cell);
  295 + for(var j = 0, item; item = items[j++];){
  296 + name = $(item).attr('name');
  297 + if(name){
  298 + params[name] = $(item).val();
302 299 }
303   - });
304   - jsDoQuery(params, false);
  300 + }
  301 + });
  302 + page = num - 1;
  303 + jsDoQuery(params, false);
305 304 }
306 305 });
307 306 }
308 307  
309   -
310 308 //删除
311 309 $('#removeButton').on('click', function(){
312 310 if($(this).attr('disabled'))
... ... @@ -334,7 +332,6 @@ $(&#39;#nbbm&#39;).select2({
334 332 xlbm:$('#line').val()};
335 333 },
336 334 processResults: function (data) {
337   - console.log(data);
338 335 return {
339 336 results: data
340 337 };
... ...
src/main/resources/static/pages/excep/speedingMap.html
... ... @@ -20,6 +20,8 @@
20 20 }
21 21 </style>
22 22 <script type="text/javascript" src="/pages/excep/js/speeding-map.js"></script>
  23 +<script type="text/javascript" src="/pages/excep/js/line-list-function.js"></script>
  24 +
23 25 <script type="text/javascript">
24 26 $(function(){
25 27 var dataArr = window.localStorage.zbhAndDate.split(",");//获取页面传递过来的车辆自编号以及超速起始时间和超速结束时间
... ... @@ -30,13 +32,15 @@ $(function(){
30 32 var lat = dataArr[4];//起点纬度
31 33 var endLon = dataArr[5];//终点经度
32 34 var endLat = dataArr[6];//终点纬度
  35 + var lineid = dataArr[7];
  36 + var directionData = dataArr[8];
33 37 var pointObj;//坐标和速度组成的对象
34 38 var Points = [];//坐标和速度对象的集合
35 39 var coordinateArr = [];//坐标点数组
36 40 $.ajax({
37 41 type: "GET",
38 42 async:false,
39   - url: '/gps/findPosition',
  43 + url: '/speeding/findPosition',
40 44 data: {vehicle:vehicle,startdate:startdate,enddate:enddate},
41 45 success: function(data){
42 46 $.each(data,function(i,item){
... ... @@ -44,6 +48,7 @@ $(function(){
44 48 pointObj = new Object();
45 49 pointObj.coordinate = new BMap.Point(item.lon,item.lat);
46 50 pointObj.speed = item.speed;
  51 + pointObj.vehicle = item.vehicle;
47 52 Points.push(pointObj);
48 53 }
49 54 });
... ... @@ -51,38 +56,44 @@ $(function(){
51 56 });
52 57 setTimeout(function(){
53 58 var map = SpeedingMap.init();//创建地图
  59 + $get('/sectionroute/findSection',{'line.id_eq' : lineid , 'directions_eq' :directionData},function(data) {
  60 + // 在地图上画出线路走向
  61 + PublicFunctions.linePanlThree(lineid,data,directionData);
  62 + });
54 63 var myP1 = new BMap.Point(lon,lat); //起点
55 64 var myP2 = new BMap.Point(endLon,endLat); //终点
56   - var centerLon = (parseFloat(lon)+parseFloat(endLon))/2;
  65 +/* var centerLon = (parseFloat(lon)+parseFloat(endLon))/2;
57 66 var centerLat = (parseFloat(lat)+parseFloat(endLat))/2;
58   - map.centerAndZoom(new BMap.Point(centerLon,centerLat),18);//地图中心点坐标
59   -
  67 + map.centerAndZoom(new BMap.Point(centerLon,centerLat),18);//地图中心点坐标 */
60 68 for(i in Points){
61 69 coordinateArr.push(Points[i].coordinate);
62 70 }
63   - var polyline = new BMap.Polyline(coordinateArr, {strokeColor:"blue", strokeWeight:5, strokeOpacity:0.5});//创建折线
  71 + var polyline = new BMap.Polyline(coordinateArr, {strokeColor:"red", strokeWeight:5, strokeOpacity:0.5});//创建折线
64 72 var myIcon = new BMap.Icon("/pages/excep/img/bus.png", new BMap.Size(32, 70), {//小车图片
65 73 imageOffset: new BMap.Size(5,20) //图片的偏移量。为了是图片底部中心对准坐标点。
66 74 });
67 75  
  76 + var carMk;
68 77 $(document).on('click', '#run', function() {
69   - map.clearOverlays();//清空上一次的轨迹
  78 + map.centerAndZoom(new BMap.Point(lon,lat),16);//地图中心点坐标 */
  79 + if(typeof(carMk)!="undefined"){
  80 + map.removeOverlay(carMk);//清空上一次的轨迹
  81 + }
  82 + carMk = new BMap.Marker(coordinateArr[0],{icon:myIcon});
70 83 map.addOverlay(polyline);//增加折线
71 84 var paths = coordinateArr.length;//获得有几个点
72   - var carMk = new BMap.Marker(coordinateArr[0],{icon:myIcon});
73 85 map.addOverlay(carMk);
74   - var sContent ="车辆即时速度:"+Points[0].speed;
  86 + var sContent ="车辆编号:"+Points[0].vehicle+"</br>车辆速度:"+Points[0].speed+"km/h";
75 87 var infoWindow = new BMap.InfoWindow(sContent);// 创建信息窗口对象
76 88 map.openInfoWindow(infoWindow,coordinateArr[0]); //开启信息窗口
77 89 i=0;
78   -
79 90 setTimeout(function(){
80 91 resetMkPoint(0);
81 92 },500);
82 93  
83 94 function resetMkPoint(i){
84 95 carMk.setPosition(coordinateArr[i]);
85   - sContent ="车辆即时速度是:"+Points[i].speed;
  96 + sContent ="车辆编号:"+Points[i].vehicle+"</br>车辆速度:"+Points[i].speed+"km/h";
86 97 infoWindow = new BMap.InfoWindow(sContent);// 创建信息窗口对象
87 98 map.openInfoWindow(infoWindow,coordinateArr[i]); //开启信息窗口
88 99 if(i < paths-1){
... ... @@ -91,9 +102,10 @@ $(function(){
91 102 resetMkPoint(i);
92 103 },500);
93 104 }
94   - };
  105 + };
  106 +
95 107 });
96   -}, 500);
  108 + }, 500);
97 109 });
98 110 </script>
99 111  
... ...