Commit c2dd7da44f5103412e95167263a3386738049cb9
Merge branch 'master' into minhang
Showing
16 changed files
with
579 additions
and
27 deletions
src/main/java/com/bsth/Application.java
| @@ -10,6 +10,8 @@ import org.springframework.context.annotation.Bean; | @@ -10,6 +10,8 @@ import org.springframework.context.annotation.Bean; | ||
| 10 | import org.springframework.context.annotation.Primary; | 10 | import org.springframework.context.annotation.Primary; |
| 11 | import org.springframework.transaction.annotation.EnableTransactionManagement; | 11 | import org.springframework.transaction.annotation.EnableTransactionManagement; |
| 12 | 12 | ||
| 13 | +import java.util.Calendar; | ||
| 14 | +import java.util.Date; | ||
| 13 | import java.util.concurrent.Executors; | 15 | import java.util.concurrent.Executors; |
| 14 | import java.util.concurrent.ScheduledExecutorService; | 16 | import java.util.concurrent.ScheduledExecutorService; |
| 15 | 17 |
src/main/java/com/bsth/controller/gps/GpsController.java
| @@ -4,11 +4,15 @@ import com.bsth.data.BasicData; | @@ -4,11 +4,15 @@ import com.bsth.data.BasicData; | ||
| 4 | import com.bsth.data.gpsdata.GpsEntity; | 4 | import com.bsth.data.gpsdata.GpsEntity; |
| 5 | import com.bsth.data.gpsdata.GpsRealData; | 5 | import com.bsth.data.gpsdata.GpsRealData; |
| 6 | import com.bsth.service.gps.GpsService; | 6 | import com.bsth.service.gps.GpsService; |
| 7 | +import com.bsth.service.gps.entity.GpsSpeed; | ||
| 7 | import com.google.common.base.Splitter; | 8 | import com.google.common.base.Splitter; |
| 8 | import org.springframework.beans.factory.annotation.Autowired; | 9 | import org.springframework.beans.factory.annotation.Autowired; |
| 9 | import org.springframework.web.bind.annotation.*; | 10 | import org.springframework.web.bind.annotation.*; |
| 10 | 11 | ||
| 11 | import javax.servlet.http.HttpServletResponse; | 12 | import javax.servlet.http.HttpServletResponse; |
| 13 | + | ||
| 14 | +import java.text.ParseException; | ||
| 15 | +import java.util.ArrayList; | ||
| 12 | import java.util.List; | 16 | import java.util.List; |
| 13 | import java.util.Map; | 17 | import java.util.Map; |
| 14 | 18 | ||
| @@ -178,4 +182,13 @@ public class GpsController { | @@ -178,4 +182,13 @@ public class GpsController { | ||
| 178 | @RequestParam(defaultValue = "DESC") String direction){ | 182 | @RequestParam(defaultValue = "DESC") String direction){ |
| 179 | return gpsService.safeDrivList(map , page, size, order, direction); | 183 | return gpsService.safeDrivList(map , page, size, order, direction); |
| 180 | } | 184 | } |
| 185 | + | ||
| 186 | + @RequestMapping(value = "/findPosition", method = RequestMethod.GET) | ||
| 187 | + public List<GpsSpeed> findPosition(@RequestParam String vehicle,@RequestParam String startdate,@RequestParam String enddate) throws ParseException { | ||
| 188 | + String deviceid = BasicData.deviceId2NbbmMap.inverse().get(vehicle); | ||
| 189 | + List<GpsSpeed> listGpsSpeed = new ArrayList<GpsSpeed>(); | ||
| 190 | + listGpsSpeed = gpsService.findPosition(deviceid,startdate,enddate); | ||
| 191 | + return listGpsSpeed; | ||
| 192 | + } | ||
| 193 | + | ||
| 181 | } | 194 | } |
src/main/java/com/bsth/controller/sys/IntervalController.java
0 → 100644
| 1 | +package com.bsth.controller.sys; | ||
| 2 | + | ||
| 3 | +import java.util.Map; | ||
| 4 | + | ||
| 5 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 6 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
| 7 | +import org.springframework.web.bind.annotation.RequestMethod; | ||
| 8 | +import org.springframework.web.bind.annotation.RequestParam; | ||
| 9 | +import org.springframework.web.bind.annotation.RestController; | ||
| 10 | + | ||
| 11 | +import com.alibaba.fastjson.JSON; | ||
| 12 | +import com.bsth.entity.sys.Interval; | ||
| 13 | +import com.bsth.service.sys.IntervalService; | ||
| 14 | + | ||
| 15 | +@RestController | ||
| 16 | +@RequestMapping("interval") | ||
| 17 | +public class IntervalController { | ||
| 18 | + | ||
| 19 | + @Autowired | ||
| 20 | + IntervalService intervalService; | ||
| 21 | + | ||
| 22 | + @RequestMapping(value = "/save", method = RequestMethod.POST) | ||
| 23 | + public Map<String, Object> save(@RequestParam String array){ | ||
| 24 | + return intervalService.saveList(JSON.parseArray(array, Interval.class)); | ||
| 25 | + } | ||
| 26 | +} |
src/main/java/com/bsth/entity/excep/Speeding.java
| @@ -52,6 +52,33 @@ public class Speeding { | @@ -52,6 +52,33 @@ public class Speeding { | ||
| 52 | private Float lat; | 52 | private Float lat; |
| 53 | 53 | ||
| 54 | /** | 54 | /** |
| 55 | + * 超速结束时的经度 | ||
| 56 | + */ | ||
| 57 | + private Float endlon; | ||
| 58 | + | ||
| 59 | + public Float getEndlon() { | ||
| 60 | + return endlon; | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + public void setEndlon(Float endlon) { | ||
| 64 | + this.endlon = endlon; | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + public Float getEndlat() { | ||
| 68 | + return endlat; | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + public void setEndlat(Float endlat) { | ||
| 72 | + this.endlat = endlat; | ||
| 73 | + } | ||
| 74 | + | ||
| 75 | + /** | ||
| 76 | + * 超速结束时的纬度 | ||
| 77 | + */ | ||
| 78 | + private Float endlat; | ||
| 79 | + | ||
| 80 | + | ||
| 81 | + /** | ||
| 55 | * 速度 | 82 | * 速度 |
| 56 | */ | 83 | */ |
| 57 | private Float speed; | 84 | private Float speed; |
src/main/java/com/bsth/entity/sys/Interval.java
src/main/java/com/bsth/repository/sys/IntervalRepository.java
0 → 100644
src/main/java/com/bsth/service/excep/impl/SpeedingServiceImpl.java
| @@ -9,6 +9,7 @@ import java.text.SimpleDateFormat; | @@ -9,6 +9,7 @@ import java.text.SimpleDateFormat; | ||
| 9 | import java.util.ArrayList; | 9 | import java.util.ArrayList; |
| 10 | import java.util.Date; | 10 | import java.util.Date; |
| 11 | import java.util.HashMap; | 11 | import java.util.HashMap; |
| 12 | +import java.util.Iterator; | ||
| 12 | import java.util.List; | 13 | import java.util.List; |
| 13 | import java.util.Map; | 14 | import java.util.Map; |
| 14 | 15 | ||
| @@ -24,6 +25,8 @@ import com.bsth.service.excep.SpeedingService; | @@ -24,6 +25,8 @@ import com.bsth.service.excep.SpeedingService; | ||
| 24 | import com.bsth.util.EchartConver; | 25 | import com.bsth.util.EchartConver; |
| 25 | import com.bsth.util.PageHelper; | 26 | import com.bsth.util.PageHelper; |
| 26 | import com.bsth.util.PageObject; | 27 | import com.bsth.util.PageObject; |
| 28 | +import com.bsth.util.TransGPS; | ||
| 29 | +import com.bsth.util.TransGPS.Location; | ||
| 27 | import com.bsth.util.db.DBUtils_MS; | 30 | import com.bsth.util.db.DBUtils_MS; |
| 28 | import com.github.abel533.echarts.Option; | 31 | import com.github.abel533.echarts.Option; |
| 29 | import com.google.gson.Gson; | 32 | import com.google.gson.Gson; |
| @@ -39,7 +42,7 @@ public class SpeedingServiceImpl implements SpeedingService { | @@ -39,7 +42,7 @@ public class SpeedingServiceImpl implements SpeedingService { | ||
| 39 | ResultSet rs = null; | 42 | ResultSet rs = null; |
| 40 | int page=Integer.parseInt(map.get("page").toString()); | 43 | int page=Integer.parseInt(map.get("page").toString()); |
| 41 | List<Speeding> list=new ArrayList<Speeding>(); | 44 | List<Speeding> list=new ArrayList<Speeding>(); |
| 42 | - String sql="select * from bsth_c_speeding where 1=1 "; | 45 | + String sql="select * from bsth_c_speeding where speed > 60 "; |
| 43 | Object line=map.get("line"); | 46 | Object line=map.get("line"); |
| 44 | Object nbbm=map.get("nbbm"); | 47 | Object nbbm=map.get("nbbm"); |
| 45 | Object updown=map.get("updown"); | 48 | Object updown=map.get("updown"); |
| @@ -83,7 +86,6 @@ public class SpeedingServiceImpl implements SpeedingService { | @@ -83,7 +86,6 @@ public class SpeedingServiceImpl implements SpeedingService { | ||
| 83 | 86 | ||
| 84 | } | 87 | } |
| 85 | 88 | ||
| 86 | - | ||
| 87 | /*sql +=" order by id limit ?,?";*/ | 89 | /*sql +=" order by id limit ?,?";*/ |
| 88 | 90 | ||
| 89 | 91 | ||
| @@ -104,17 +106,23 @@ public class SpeedingServiceImpl implements SpeedingService { | @@ -104,17 +106,23 @@ public class SpeedingServiceImpl implements SpeedingService { | ||
| 104 | } | 106 | } |
| 105 | 107 | ||
| 106 | static List<Speeding> resultSet2Set(ResultSet rs) throws SQLException{ | 108 | static List<Speeding> resultSet2Set(ResultSet rs) throws SQLException{ |
| 107 | - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); | 109 | + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| 108 | List<Speeding> list=new ArrayList<Speeding>(); | 110 | List<Speeding> list=new ArrayList<Speeding>(); |
| 109 | Speeding speeding; | 111 | Speeding speeding; |
| 112 | + Float lon, lat; | ||
| 113 | + Location location; | ||
| 110 | while(rs.next()){ | 114 | while(rs.next()){ |
| 115 | + lon = rs.getFloat("lon"); | ||
| 116 | + lat = rs.getFloat("lat"); | ||
| 117 | + location = TransGPS.LocationMake(lon, lat); | ||
| 118 | + location = TransGPS.bd_encrypt(TransGPS.transformFromWGSToGCJ(location)); | ||
| 111 | speeding=new Speeding(); | 119 | speeding=new Speeding(); |
| 112 | speeding.setId(Integer.valueOf(rs.getObject("id").toString())); | 120 | speeding.setId(Integer.valueOf(rs.getObject("id").toString())); |
| 113 | - speeding.setLat(Float.valueOf(rs.getObject("lat").toString())); | 121 | + speeding.setLon((float)location.getLng()); |
| 122 | + speeding.setLat((float)location.getLat()); | ||
| 114 | speeding.setLine(Integer.valueOf(rs.getObject("line").toString())); | 123 | speeding.setLine(Integer.valueOf(rs.getObject("line").toString())); |
| 115 | //run 时注解 | 124 | //run 时注解 |
| 116 | speeding.setLineName(BasicData.lineCode2NameMap.get(speeding.getLine().toString())); | 125 | speeding.setLineName(BasicData.lineCode2NameMap.get(speeding.getLine().toString())); |
| 117 | - speeding.setLon(Float.valueOf(rs.getObject("lon").toString())); | ||
| 118 | speeding.setSpeed(Float.valueOf(rs.getObject("speed").toString())); | 126 | speeding.setSpeed(Float.valueOf(rs.getObject("speed").toString())); |
| 119 | speeding.setTimestamp((Long.valueOf(rs.getObject("timestamp").toString()))); | 127 | speeding.setTimestamp((Long.valueOf(rs.getObject("timestamp").toString()))); |
| 120 | speeding.setTimestampDate(sdf.format(new Date(speeding.getTimestamp()))); | 128 | speeding.setTimestampDate(sdf.format(new Date(speeding.getTimestamp()))); |
| @@ -127,14 +135,12 @@ public class SpeedingServiceImpl implements SpeedingService { | @@ -127,14 +135,12 @@ public class SpeedingServiceImpl implements SpeedingService { | ||
| 127 | 135 | ||
| 128 | @Override | 136 | @Override |
| 129 | public PageObject<Speeding> Pagequery(Map<String, Object> map) { | 137 | public PageObject<Speeding> Pagequery(Map<String, Object> map) { |
| 130 | - String sql="select count(*) record from bsth_c_speeding where 1=1 "; | 138 | +/* String sql="select count(*) record from bsth_c_speeding where 1=1 "; |
| 131 | Object line=map.get("line"); | 139 | Object line=map.get("line"); |
| 132 | Object nbbm=map.get("nbbm"); | 140 | Object nbbm=map.get("nbbm"); |
| 133 | Object updown=map.get("updown"); | 141 | Object updown=map.get("updown"); |
| 134 | Object startDate=map.get("startDate"); | 142 | Object startDate=map.get("startDate"); |
| 135 | Object endDate=map.get("endDate"); | 143 | Object endDate=map.get("endDate"); |
| 136 | - //时间转换 | ||
| 137 | - SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | ||
| 138 | 144 | ||
| 139 | if(line!=null){ | 145 | if(line!=null){ |
| 140 | sql +=" and line like'%"+line.toString().trim()+"%'"; | 146 | sql +=" and line like'%"+line.toString().trim()+"%'"; |
| @@ -186,14 +192,17 @@ public class SpeedingServiceImpl implements SpeedingService { | @@ -186,14 +192,17 @@ public class SpeedingServiceImpl implements SpeedingService { | ||
| 186 | e.printStackTrace(); | 192 | e.printStackTrace(); |
| 187 | }finally { | 193 | }finally { |
| 188 | DBUtils_MS.close(rs, ps, conn); | 194 | DBUtils_MS.close(rs, ps, conn); |
| 189 | - } | 195 | + }*/ |
| 190 | 196 | ||
| 197 | + //时间转换 | ||
| 198 | + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | ||
| 191 | List<Speeding> list=findAll(map); | 199 | List<Speeding> list=findAll(map); |
| 192 | List<Speeding> listResult = new ArrayList<Speeding>(); | 200 | List<Speeding> listResult = new ArrayList<Speeding>(); |
| 193 | int curPage;//页码 | 201 | int curPage;//页码 |
| 194 | int pageData;//每页的记录条数 | 202 | int pageData;//每页的记录条数 |
| 195 | int start;//起始数据下标 | 203 | int start;//起始数据下标 |
| 196 | int totalPage;//总页数 | 204 | int totalPage;//总页数 |
| 205 | + int totalData = 0; | ||
| 197 | if(list.size()>1){ | 206 | if(list.size()>1){ |
| 198 | Speeding speedingNow;//下标为i的车 | 207 | Speeding speedingNow;//下标为i的车 |
| 199 | Speeding speedingLast;//下标为i-1的车 | 208 | Speeding speedingLast;//下标为i-1的车 |
| @@ -206,11 +215,20 @@ public class SpeedingServiceImpl implements SpeedingService { | @@ -206,11 +215,20 @@ public class SpeedingServiceImpl implements SpeedingService { | ||
| 206 | strLast = speedingLast.getVehicle()+speedingLast.getLine()+speedingLast.getUpDown(); | 215 | strLast = speedingLast.getVehicle()+speedingLast.getLine()+speedingLast.getUpDown(); |
| 207 | //同一车辆同一线路同一方向并且该记录的超速的开始时间减去上一条超速记录的结束时间小于等于10s,证明该车超速。//PS:祛除数据库中的重复发送数据 | 216 | //同一车辆同一线路同一方向并且该记录的超速的开始时间减去上一条超速记录的结束时间小于等于10s,证明该车超速。//PS:祛除数据库中的重复发送数据 |
| 208 | if(strNow.equals(strLast) && Math.abs(speedingNow.getTimestamp()-speedingLast.getTimestamp())<=10*1000 && (speedingNow.getTimestamp()-speedingLast.getTimestamp()!=0)){ | 217 | if(strNow.equals(strLast) && Math.abs(speedingNow.getTimestamp()-speedingLast.getTimestamp())<=10*1000 && (speedingNow.getTimestamp()-speedingLast.getTimestamp()!=0)){ |
| 209 | - speedingLast.setEndtimestamp(speedingNow.getTimestamp()); | 218 | + speedingLast.setEndtimestamp(speedingNow.getTimestamp());//设置结束时间时间戳 |
| 210 | speedingLast.setEndtimestampDate(sdf.format(new Date(speedingNow.getTimestamp())));//设置结束时间 | 219 | speedingLast.setEndtimestampDate(sdf.format(new Date(speedingNow.getTimestamp())));//设置结束时间 |
| 220 | + speedingLast.setEndlon(speedingNow.getLon());//设置结束时的经度 | ||
| 221 | + speedingLast.setEndlat(speedingNow.getLat());//设置结束时的纬度 | ||
| 211 | listResult.add(speedingLast); | 222 | listResult.add(speedingLast); |
| 212 | } | 223 | } |
| 213 | } | 224 | } |
| 225 | + Iterator<Speeding> speedIt = listResult.iterator(); | ||
| 226 | + while(speedIt.hasNext()){ | ||
| 227 | + Speeding speeding = speedIt.next(); | ||
| 228 | + if(speeding.getEndtimestamp()-speeding.getTimestamp()<=1000){ | ||
| 229 | + speedIt.remove(); | ||
| 230 | + } | ||
| 231 | + } | ||
| 214 | 232 | ||
| 215 | totalData = listResult.size();//总记录条数。 | 233 | totalData = listResult.size();//总记录条数。 |
| 216 | if(map.get("curPage") == null || map.get("curPage").equals("0")){ | 234 | if(map.get("curPage") == null || map.get("curPage").equals("0")){ |
src/main/java/com/bsth/service/gps/GpsService.java
| 1 | package com.bsth.service.gps; | 1 | package com.bsth.service.gps; |
| 2 | 2 | ||
| 3 | +import com.bsth.data.gpsdata.GpsEntity; | ||
| 3 | import com.bsth.service.gps.entity.GpsOutbound_DTO; | 4 | import com.bsth.service.gps.entity.GpsOutbound_DTO; |
| 5 | +import com.bsth.service.gps.entity.GpsSpeed; | ||
| 4 | import com.bsth.service.gps.entity.GpsSpeed_DTO; | 6 | import com.bsth.service.gps.entity.GpsSpeed_DTO; |
| 5 | 7 | ||
| 6 | import javax.servlet.http.HttpServletResponse; | 8 | import javax.servlet.http.HttpServletResponse; |
| 9 | + | ||
| 10 | +import java.text.ParseException; | ||
| 7 | import java.util.List; | 11 | import java.util.List; |
| 8 | import java.util.Map; | 12 | import java.util.Map; |
| 9 | 13 | ||
| @@ -38,4 +42,7 @@ public interface GpsService { | @@ -38,4 +42,7 @@ public interface GpsService { | ||
| 38 | void abnormalExcel(String nbbm, long st, long et, HttpServletResponse resp); | 42 | void abnormalExcel(String nbbm, long st, long et, HttpServletResponse resp); |
| 39 | 43 | ||
| 40 | void arrivalExcel(String nbbm, long st, long et, HttpServletResponse resp); | 44 | void arrivalExcel(String nbbm, long st, long et, HttpServletResponse resp); |
| 45 | + | ||
| 46 | + List<GpsSpeed> findPosition(String deviceid, String startdate, | ||
| 47 | + String enddate) throws ParseException; | ||
| 41 | } | 48 | } |
src/main/java/com/bsth/service/gps/GpsServiceImpl.java
| @@ -45,6 +45,8 @@ import java.sql.Connection; | @@ -45,6 +45,8 @@ import java.sql.Connection; | ||
| 45 | import java.sql.PreparedStatement; | 45 | import java.sql.PreparedStatement; |
| 46 | import java.sql.ResultSet; | 46 | import java.sql.ResultSet; |
| 47 | import java.text.DecimalFormat; | 47 | import java.text.DecimalFormat; |
| 48 | +import java.text.ParseException; | ||
| 49 | +import java.text.SimpleDateFormat; | ||
| 48 | import java.util.*; | 50 | import java.util.*; |
| 49 | 51 | ||
| 50 | @Service | 52 | @Service |
| @@ -975,4 +977,57 @@ public class GpsServiceImpl implements GpsService { | @@ -975,4 +977,57 @@ public class GpsServiceImpl implements GpsService { | ||
| 975 | } | 977 | } |
| 976 | return true; | 978 | return true; |
| 977 | } | 979 | } |
| 980 | + | ||
| 981 | + @Override | ||
| 982 | + public List<GpsSpeed> findPosition(String deviceid, String startdate, | ||
| 983 | + String enddate) throws ParseException{ | ||
| 984 | + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | ||
| 985 | + Calendar c = Calendar.getInstance(); | ||
| 986 | + Date date = sdf.parse(startdate); | ||
| 987 | + c.setTime(date); | ||
| 988 | + int daysYear = c.get(Calendar.DAY_OF_YEAR);//获取当前是今年的第几天。 | ||
| 989 | + | ||
| 990 | + long startTime = sdf.parse(startdate).getTime(); | ||
| 991 | + long endTime = sdf.parse(enddate).getTime(); | ||
| 992 | + | ||
| 993 | + String sql = "select DEVICE_ID,LON,LAT,TS,INOUT_STOP,SERVICE_STATE ,speed_gps from bsth_c_gps_info where days_year=? and device_id=? and ts >= ? and ts <= ?" + | ||
| 994 | + " ORDER BY TS "; | ||
| 995 | + Connection conn = null; | ||
| 996 | + PreparedStatement ps = null; | ||
| 997 | + ResultSet rs = null; | ||
| 998 | + List<GpsSpeed> listResult = new ArrayList<GpsSpeed>(); | ||
| 999 | + GpsSpeed gpsSpeed = null; | ||
| 1000 | + try { | ||
| 1001 | + conn = DBUtils_MS.getConnection(); | ||
| 1002 | + ps = conn.prepareStatement(sql); | ||
| 1003 | + ps.setInt(1, daysYear); | ||
| 1004 | + ps.setString(2, deviceid); | ||
| 1005 | + ps.setLong(3,startTime); | ||
| 1006 | + ps.setLong(4,endTime); | ||
| 1007 | + rs = ps.executeQuery(); | ||
| 1008 | + Float lon, lat; | ||
| 1009 | + Location location; | ||
| 1010 | + while (rs.next()) { | ||
| 1011 | + gpsSpeed = new GpsSpeed(); | ||
| 1012 | + // to 百度坐标 | ||
| 1013 | + lon = rs.getFloat("LON"); | ||
| 1014 | + lat = rs.getFloat("LAT"); | ||
| 1015 | + location = TransGPS.LocationMake(lon, lat); | ||
| 1016 | + location = TransGPS.bd_encrypt(TransGPS.transformFromWGSToGCJ(location)); | ||
| 1017 | + gpsSpeed.setVehicle(rs.getString("device_id")); | ||
| 1018 | + gpsSpeed.setLon((float)location.getLng()); | ||
| 1019 | + gpsSpeed.setLat((float)location.getLat()); | ||
| 1020 | + gpsSpeed.setSpeed(rs.getFloat("speed_gps")); | ||
| 1021 | + gpsSpeed.setTimestamp(rs.getLong("TS")); | ||
| 1022 | + // 上下行 | ||
| 1023 | + listResult.add(gpsSpeed); | ||
| 1024 | + } | ||
| 1025 | + } catch (Exception e) { | ||
| 1026 | + e.printStackTrace(); | ||
| 1027 | + } finally { | ||
| 1028 | + DBUtils_MS.close(rs, ps, conn); | ||
| 1029 | + } | ||
| 1030 | + return listResult; | ||
| 1031 | + | ||
| 1032 | + } | ||
| 978 | } | 1033 | } |
src/main/java/com/bsth/service/sys/IntervalService.java
0 → 100644
| 1 | +package com.bsth.service.sys; | ||
| 2 | + | ||
| 3 | +import java.util.List; | ||
| 4 | +import java.util.Map; | ||
| 5 | + | ||
| 6 | +import com.bsth.entity.sys.Interval; | ||
| 7 | +import com.bsth.service.BaseService; | ||
| 8 | + | ||
| 9 | +public interface IntervalService extends BaseService<Interval, Integer> { | ||
| 10 | + | ||
| 11 | + Map<String, Object> saveList(List<Interval> parseArray); | ||
| 12 | + | ||
| 13 | +} |
src/main/java/com/bsth/service/sys/impl/IntervalServiceImpl.java
0 → 100644
| 1 | +package com.bsth.service.sys.impl; | ||
| 2 | + | ||
| 3 | +import java.util.HashMap; | ||
| 4 | +import java.util.List; | ||
| 5 | +import java.util.Map; | ||
| 6 | + | ||
| 7 | +import org.slf4j.Logger; | ||
| 8 | +import org.slf4j.LoggerFactory; | ||
| 9 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 10 | +import org.springframework.stereotype.Service; | ||
| 11 | + | ||
| 12 | +import com.bsth.common.ResponseCode; | ||
| 13 | +import com.bsth.entity.sys.Interval; | ||
| 14 | +import com.bsth.repository.sys.IntervalRepository; | ||
| 15 | +import com.bsth.service.impl.BaseServiceImpl; | ||
| 16 | +import com.bsth.service.sys.IntervalService; | ||
| 17 | + | ||
| 18 | +@Service | ||
| 19 | +public class IntervalServiceImpl extends BaseServiceImpl<Interval, Integer> implements IntervalService { | ||
| 20 | + | ||
| 21 | + @Autowired | ||
| 22 | + IntervalRepository intervalRepository; | ||
| 23 | + | ||
| 24 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | ||
| 25 | + | ||
| 26 | + @Override | ||
| 27 | + public Map<String, Object> saveList(List<Interval> parseArray) { | ||
| 28 | + Map<String, Object> map = new HashMap<>(); | ||
| 29 | + try{ | ||
| 30 | + intervalRepository.save(parseArray); | ||
| 31 | + map.put("status", ResponseCode.SUCCESS); | ||
| 32 | + }catch(Exception e){ | ||
| 33 | + map.put("status", ResponseCode.ERROR); | ||
| 34 | + logger.error("", e); | ||
| 35 | + } | ||
| 36 | + return map; | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | +} |
src/main/resources/static/pages/base/interval/list.html
0 → 100644
| 1 | +<!-- <link href="/pages/base/line/css/animate.css" rel="stylesheet" type="text/css" /> | ||
| 2 | +<link href="/pages/base/line/css/tipso.css" rel="stylesheet" type="text/css" /> --> | ||
| 3 | +<!-- 片段标题 START --> | ||
| 4 | +<div class="page-head"> | ||
| 5 | + <div class="page-title"> | ||
| 6 | + <h1>大间隔信息</h1> | ||
| 7 | + </div> | ||
| 8 | +</div> | ||
| 9 | +<!-- 片段标题 END --> | ||
| 10 | + | ||
| 11 | +<!-- 线路信息导航栏组件 START --> | ||
| 12 | +<ul class="page-breadcrumb breadcrumb"> | ||
| 13 | + <li><a href="/pages/home.html" data-pjax>首页</a> <i class="fa fa-circle"></i></li> | ||
| 14 | + <li><span class="active">基础信息</span> <i class="fa fa-circle"></i></li> | ||
| 15 | + <li><span class="active">大间隔信息</span></li> | ||
| 16 | +</ul> | ||
| 17 | +<!-- 线路信息导航栏组件 END --> | ||
| 18 | + | ||
| 19 | +<div class="row"> | ||
| 20 | + <div class="col-md-12"> | ||
| 21 | + <div class="portlet light porttlet-fit bordered"> | ||
| 22 | + <div class="portlet-title"> | ||
| 23 | + <div class="tipso-animation"> | ||
| 24 | + </div> | ||
| 25 | + <div class="caption"> | ||
| 26 | + <i class="fa fa-info-circle font-dark"></i> | ||
| 27 | + <span class="caption-subject font-dark sbold uppercase">线路信息</span> | ||
| 28 | + </div> | ||
| 29 | + <div class="actions"> | ||
| 30 | + <div class="btn-group btn-group-devided" data-toggle="buttons"> | ||
| 31 | + <a class="btn btn-circle blue" href="add.html" data-pjax><i class="fa fa-plus"></i> 添加线路</a> | ||
| 32 | + </div> | ||
| 33 | + </div> | ||
| 34 | + </div> | ||
| 35 | + <div class="portlet-body"> | ||
| 36 | + <div class="table-container" style="margin-top: 10px"> | ||
| 37 | + <table class="table table-striped table-bordered table-hover table-checkable" id="datatable_line"> | ||
| 38 | + <thead> | ||
| 39 | + <tr role="row" class="heading"> | ||
| 40 | + <th >#</th> | ||
| 41 | + <th >序号</th> | ||
| 42 | + <th >大间隔ID</th> | ||
| 43 | + <th >大间隔等级</th> | ||
| 44 | + <th >高峰间隔时间</th> | ||
| 45 | + <th >低谷间隔时间</th> | ||
| 46 | + <th >操作</th> | ||
| 47 | + </tr> | ||
| 48 | + <tr role="row" class="filter"> | ||
| 49 | + <td>#</td> | ||
| 50 | + <td></td> | ||
| 51 | + <td></td> | ||
| 52 | + <td></td> | ||
| 53 | + <td></td> | ||
| 54 | + <td></td> | ||
| 55 | + <td> | ||
| 56 | + <button class="btn btn-sm green btn-outline filter-submit margin-bottom" > | ||
| 57 | + <i class="fa fa-search"></i> 搜索 | ||
| 58 | + </button> | ||
| 59 | + | ||
| 60 | + <button class="btn btn-sm red btn-outline filter-cancel" id="notification-trigger"> | ||
| 61 | + <i class="fa fa-times"></i> 重置 | ||
| 62 | + </button> | ||
| 63 | + </td> | ||
| 64 | + </tr> | ||
| 65 | + </thead> | ||
| 66 | + <tbody></tbody> | ||
| 67 | + </table> | ||
| 68 | + <div style="text-align: right;"> | ||
| 69 | + <ul id="pagination" class="pagination"></ul> | ||
| 70 | + </div> | ||
| 71 | + </div> | ||
| 72 | + </div> | ||
| 73 | + </div> | ||
| 74 | + </div> | ||
| 75 | +</div> | ||
| 76 | +<script type="text/html" id="line_list_temp"> | ||
| 77 | + {{each list as obj i }} | ||
| 78 | + <tr> | ||
| 79 | + <td style="vertical-align: middle;"> | ||
| 80 | + <input type="checkbox" class="group-checkable icheck" value="{{obj.name}}" id="{{obj.id}}" data-id="{{obj.id}}" data-lineName="{{obj.name}}"> | ||
| 81 | + </td> | ||
| 82 | + <td style="vertical-align: middle;"> | ||
| 83 | + {{(list.page*10)+(i+1)}} | ||
| 84 | + </td> | ||
| 85 | + <td> | ||
| 86 | + {{obj.lineCode}} | ||
| 87 | + </td> | ||
| 88 | + <td> | ||
| 89 | + {{obj.name}} | ||
| 90 | + </td> | ||
| 91 | + <td> | ||
| 92 | + {{if obj.nature == 'lj'}} | ||
| 93 | + 路救 | ||
| 94 | + {{else if obj.nature == 'bc'}} | ||
| 95 | + 备车 | ||
| 96 | + {{else if obj.nature == 'dbc'}} | ||
| 97 | + 定班车 | ||
| 98 | + {{else if obj.nature == 'yxl'}} | ||
| 99 | + 夜宵路 | ||
| 100 | + {{else if obj.nature == 'cgxl'}} | ||
| 101 | + 常规线路 | ||
| 102 | + {{else if obj.nature == 'gjxl'}} | ||
| 103 | + 过江线路 | ||
| 104 | + {{else if obj.nature == 'csbs'}} | ||
| 105 | + 穿梭巴士 | ||
| 106 | + {{else if obj.nature == 'tyxl'}} | ||
| 107 | + 特约线路 | ||
| 108 | + {{else if obj.nature == 'qt'}} | ||
| 109 | + 其他 | ||
| 110 | + {{else if obj.nature == 'cctxl'}} | ||
| 111 | + 村村通线路 | ||
| 112 | + {{/if}} | ||
| 113 | + </td> | ||
| 114 | + <td> | ||
| 115 | + {{if obj.level == '1'}} | ||
| 116 | + 一级线路 | ||
| 117 | + {{else if obj.level == '2'}} | ||
| 118 | + 二级线路 | ||
| 119 | + {{else if obj.level == '0'}} | ||
| 120 | + 未知等级 | ||
| 121 | + {{/if}} | ||
| 122 | + </td> | ||
| 123 | + <td> | ||
| 124 | + {{obj.shanghaiLinecode}} | ||
| 125 | + </td> | ||
| 126 | + <td> | ||
| 127 | + {{if obj.destroy == 1}} | ||
| 128 | + <span style="font-weight: bold; color: red; padding: 5px; background-color: #FFE4E1; margin: 5px; font-size: 9px;border-radius: 4px;">撤销</span> | ||
| 129 | + {{else if obj.destroy == 0}} | ||
| 130 | + <span style="font-weight: bold; color: #07824e; padding: 5px; background-color: #FFE4E1; margin: 5px; font-size: 9px;border-radius: 4px;">运营</span> | ||
| 131 | + {{/if}} | ||
| 132 | + </td> | ||
| 133 | + <td> | ||
| 134 | + <a href="/pages/base/lineinformation/list.html?no={{obj.id}}" class="btn default blue-stripe btn-sm" data-pjax> 查看 </a> | ||
| 135 | + </td> | ||
| 136 | + <td> | ||
| 137 | + <a href="/pages/base/stationroute/list.html?no={{obj.id}}" class="btn default blue-stripe btn-sm" data-pjax> 查看 </a> | ||
| 138 | + </td> | ||
| 139 | + <td> | ||
| 140 | + <a href="details.html?no={{obj.id}}" class="btn default blue-stripe btn-sm" data-pjax> 详细 </a> | ||
| 141 | + <a href="edit.html?no={{obj.id}}" class="btn default blue-stripe btn-sm" data-pjax> 修改 </a> | ||
| 142 | + </td> | ||
| 143 | + </tr> | ||
| 144 | + {{/each}} | ||
| 145 | + {{if list.length == 0}} | ||
| 146 | + <tr> | ||
| 147 | + <td colspan=13><h6 class="muted">没有找到相关数据</h6></td> | ||
| 148 | + </tr> | ||
| 149 | + {{/if}} | ||
| 150 | +</script> | ||
| 151 | +<!-- <script src="/pages/base/line/js/tipso.js"></script> --> | ||
| 152 | +<!-- 线路信息片段JS模块 --> | ||
| 153 | +<script src="/pages/base/line/js/line-list-table.js"></script> | ||
| 0 | \ No newline at end of file | 154 | \ No newline at end of file |
src/main/resources/static/pages/excep/js/outboundmap-load.js
| @@ -8,7 +8,6 @@ $(function(){ | @@ -8,7 +8,6 @@ $(function(){ | ||
| 8 | 8 | ||
| 9 | // 获取参数线路ID | 9 | // 获取参数线路ID |
| 10 | var no = $.url().param('no'); | 10 | var no = $.url().param('no'); |
| 11 | - var up = $.url().param('up'); | ||
| 12 | var paramArr = new Array(); | 11 | var paramArr = new Array(); |
| 13 | paramArr = no.split(",");// 在每个逗号(,)处进行分解。 | 12 | paramArr = no.split(",");// 在每个逗号(,)处进行分解。 |
| 14 | /*paramArr[0]:id | 13 | /*paramArr[0]:id |
src/main/resources/static/pages/excep/js/speeding-map.js
0 → 100644
| 1 | +/** | ||
| 2 | + * 百度地图 | ||
| 3 | + * | ||
| 4 | + * - - - - - -》init:地图初始化 | ||
| 5 | + * | ||
| 6 | + * - - - - - -》lineInfoPanl:从百度地图抓去站点与路段数据 | ||
| 7 | + * | ||
| 8 | + * - - - - - -》getDistanceAndDuration:获取距离与时间 | ||
| 9 | + * | ||
| 10 | + * - - - - - -》pointsPolygon:地图画多边行 | ||
| 11 | + * | ||
| 12 | + * - - - - - -》pointsCircle:画圆 | ||
| 13 | + * | ||
| 14 | + * - - - - - -》localSearchFromAdreesToPoint:根据地理名称获取百度经纬度坐标 | ||
| 15 | + * | ||
| 16 | + * - - - - - -》drawingUpline:在地图上画出上行线路走向 | ||
| 17 | + * | ||
| 18 | + * - - - - - -》stationsNameToPoints:站点名称获取百度坐标(手动规划) | ||
| 19 | + * | ||
| 20 | + * - - - - - -》getDistanceAndTotime:根据坐标点获取两点之间的时间与距离(手动规划) | ||
| 21 | + * | ||
| 22 | + * - - - - - -》getSectionListPlonly:根据坐标点获取两点之间的折线路段(手动规划) | ||
| 23 | + */ | ||
| 24 | + | ||
| 25 | +var SpeedingMap = function () { | ||
| 26 | + | ||
| 27 | + /** WorldsBMap 全局变量定义 mapBValue:地图对象;polygon:多边形;polyUpline:走向折线;circle:圆 *//* | ||
| 28 | + var mapBValue = '';polygon='',polyUpline='',circle='',iseditStatus = false;*/ | ||
| 29 | + | ||
| 30 | + var Bmap = { | ||
| 31 | + | ||
| 32 | + init : function() { | ||
| 33 | + // 设置中心点, | ||
| 34 | + var CENTER_POINT = {lng : 121.528733,lat : 31.237425}; | ||
| 35 | + | ||
| 36 | + // 百度API Key | ||
| 37 | + var bdKey = 'IGGrr4UjwIYzatoCRFKEL8sT'; | ||
| 38 | + | ||
| 39 | + // 初始化百度地图 | ||
| 40 | + mapBValue = new BMap.Map("speedingMap"); | ||
| 41 | + | ||
| 42 | + //中心点和缩放级别 | ||
| 43 | + mapBValue.centerAndZoom(new BMap.Point(CENTER_POINT.lng,CENTER_POINT.lat), 15); | ||
| 44 | + | ||
| 45 | + //启用地图拖拽事件,默认启用(可不写) | ||
| 46 | + mapBValue.enableDragging(); | ||
| 47 | + | ||
| 48 | + //启用地图滚轮放大缩小 | ||
| 49 | + mapBValue.enableScrollWheelZoom(); | ||
| 50 | + | ||
| 51 | + //禁用鼠标双击放大 | ||
| 52 | + mapBValue.disableDoubleClickZoom(); | ||
| 53 | + | ||
| 54 | + //启用键盘上下左右键移动地图 | ||
| 55 | + mapBValue.enableKeyboard(); | ||
| 56 | + | ||
| 57 | + return mapBValue; | ||
| 58 | + }, | ||
| 59 | + | ||
| 60 | + /** 获取地图对象 @return 地图对象map */ | ||
| 61 | + getmapBValue : function() { | ||
| 62 | + | ||
| 63 | + return mapBValue; | ||
| 64 | + | ||
| 65 | + }, | ||
| 66 | + | ||
| 67 | + /* drawTravelRoute:function(data){ | ||
| 68 | + var driving = Bmap.DrivingRoute(map, {renderOptions:{map: map}}) | ||
| 69 | + | ||
| 70 | + }*/ | ||
| 71 | + | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + return Bmap; | ||
| 75 | + | ||
| 76 | +}(); | ||
| 0 | \ No newline at end of file | 77 | \ No newline at end of file |
src/main/resources/static/pages/excep/speedingListmh.html
| @@ -146,7 +146,10 @@ | @@ -146,7 +146,10 @@ | ||
| 146 | {{(obj.endtimestamp-obj.timestamp)/1000}}秒 | 146 | {{(obj.endtimestamp-obj.timestamp)/1000}}秒 |
| 147 | </td> | 147 | </td> |
| 148 | <td> | 148 | <td> |
| 149 | - <a class="btn default blue-stripe btn-sm lookTrajectory" data-pjax> | 149 | + <a class="btn default blue-stripe btn-sm lookTrajectory" data-vehicle ="{{obj.vehicle}}" |
| 150 | + data-startdate="{{obj.timestampDate}}" data-enddate="{{obj.endtimestampDate}}" | ||
| 151 | + data-lon="{{obj.lon}}" data-lat="{{obj.lat}}" | ||
| 152 | + data-endlon="{{obj.endlon}}" data-endlat="{{obj.endlat}}" > | ||
| 150 | 查看轨迹 | 153 | 查看轨迹 |
| 151 | </a> | 154 | </a> |
| 152 | </td> | 155 | </td> |
| @@ -162,6 +165,8 @@ | @@ -162,6 +165,8 @@ | ||
| 162 | {{/if}} | 165 | {{/if}} |
| 163 | </script> | 166 | </script> |
| 164 | 167 | ||
| 168 | +<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=IGGrr4UjwIYzatoCRFKEL8sT"></script> | ||
| 169 | + | ||
| 165 | <script> | 170 | <script> |
| 166 | $(function(){ | 171 | $(function(){ |
| 167 | var page = 0, initPagination; | 172 | var page = 0, initPagination; |
| @@ -185,7 +190,20 @@ $(function(){ | @@ -185,7 +190,20 @@ $(function(){ | ||
| 185 | var parameter = new Object(); | 190 | var parameter = new Object(); |
| 186 | parameter.endDate = $("input[name='endDate']")[0].value; | 191 | parameter.endDate = $("input[name='endDate']")[0].value; |
| 187 | parameter.startDate = $("input[name='startDate']")[0].value; | 192 | parameter.startDate = $("input[name='startDate']")[0].value; |
| 188 | - jsDoQuery(parameter,true); | 193 | + |
| 194 | + //搜索线路 | ||
| 195 | + $.get('/basic/lineCode2Name',function(result){ | ||
| 196 | + var data=[]; | ||
| 197 | + data.push({id: " ", text: "全部线路"}); | ||
| 198 | + for(var code in result){ | ||
| 199 | + data.push({id: code, text: result[code]}); | ||
| 200 | + } | ||
| 201 | + initPinYinSelect2($('#line'),data,function(ldmcSelector) { | ||
| 202 | + ldmcSelector.select2("val",data[1].id);//因为数据量太大,所以默认一条线路作为查询参数 | ||
| 203 | + }); | ||
| 204 | + parameter.line = data[1].id; | ||
| 205 | + jsDoQuery(parameter,true); | ||
| 206 | + }); | ||
| 189 | 207 | ||
| 190 | //时间戳转换为年月日 | 208 | //时间戳转换为年月日 |
| 191 | function timeToData(time){ | 209 | function timeToData(time){ |
| @@ -223,7 +241,7 @@ $(function(){ | @@ -223,7 +241,7 @@ $(function(){ | ||
| 223 | /* | 241 | /* |
| 224 | * 获取数据 p: 要提交的参数, pagination: 是否重新分页 | 242 | * 获取数据 p: 要提交的参数, pagination: 是否重新分页 |
| 225 | */ | 243 | */ |
| 226 | - function jsDoQuery(p, pagination){ | 244 | + function jsDoQuery(p, pagination){ |
| 227 | var params = {}; | 245 | var params = {}; |
| 228 | if(p) | 246 | if(p) |
| 229 | params = p; | 247 | params = p; |
| @@ -243,7 +261,27 @@ $(function(){ | @@ -243,7 +261,27 @@ $(function(){ | ||
| 243 | } | 261 | } |
| 244 | layer.close(i); | 262 | layer.close(i); |
| 245 | $(".lookTrajectory").click(function(){ | 263 | $(".lookTrajectory").click(function(){ |
| 246 | - layer.alert("暂未开放此功能!"); | 264 | + var vehicle = $(this).data('vehicle'); |
| 265 | + var startDate = $(this).data('startdate'); | ||
| 266 | + var endDate = $(this).data('enddate'); | ||
| 267 | + var lon = $(this).data('lon'); | ||
| 268 | + var lat = $(this).data('lat'); | ||
| 269 | + var endLon = $(this).data('endlon'); | ||
| 270 | + var endLat = $(this).data('endlat'); | ||
| 271 | + var storage = window.localStorage; | ||
| 272 | + storage.setItem("zbhAndDate",vehicle+","+startDate+","+endDate+","+lon+","+lat+","+endLon+","+endLat); | ||
| 273 | + $.get('/pages/excep/speedingMap.html?',function (result) { | ||
| 274 | + layer.open({ | ||
| 275 | + type: 1, | ||
| 276 | + title:'<i class="uk-icon-play-circle"></i>轨迹回放', | ||
| 277 | + shadeClose: true, | ||
| 278 | + shade: true, | ||
| 279 | + scrollbar: false, | ||
| 280 | + maxmin: false, //开启最大化最小化按钮 | ||
| 281 | + area: ['100%', '100%'], | ||
| 282 | + content:result,//内容 | ||
| 283 | + }); | ||
| 284 | + }); | ||
| 247 | }) | 285 | }) |
| 248 | }); | 286 | }); |
| 249 | } | 287 | } |
| @@ -307,17 +345,6 @@ $(function(){ | @@ -307,17 +345,6 @@ $(function(){ | ||
| 307 | $('tr.filter .filter-submit').click(); | 345 | $('tr.filter .filter-submit').click(); |
| 308 | }); | 346 | }); |
| 309 | }); | 347 | }); |
| 310 | - | ||
| 311 | - //搜索线路 | ||
| 312 | - $.get('/basic/lineCode2Name',function(result){ | ||
| 313 | - var data=[]; | ||
| 314 | - data.push({id: " ", text: "全部线路"}); | ||
| 315 | - for(var code in result){ | ||
| 316 | - data.push({id: code, text: result[code]}); | ||
| 317 | - } | ||
| 318 | - initPinYinSelect2('#line',data,''); | ||
| 319 | - | ||
| 320 | - }); | ||
| 321 | 348 | ||
| 322 | $("#line").on("change",initXl); | 349 | $("#line").on("change",initXl); |
| 323 | function initXl(){ | 350 | function initXl(){ |
| @@ -334,6 +361,7 @@ $('#nbbm').select2({ | @@ -334,6 +361,7 @@ $('#nbbm').select2({ | ||
| 334 | xlbm:$('#line').val()}; | 361 | xlbm:$('#line').val()}; |
| 335 | }, | 362 | }, |
| 336 | processResults: function (data) { | 363 | processResults: function (data) { |
| 364 | + console.log(data); | ||
| 337 | return { | 365 | return { |
| 338 | results: data | 366 | results: data |
| 339 | }; | 367 | }; |
| @@ -370,7 +398,6 @@ $('#nbbm').select2({ | @@ -370,7 +398,6 @@ $('#nbbm').select2({ | ||
| 370 | 398 | ||
| 371 | //改变状态 | 399 | //改变状态 |
| 372 | function changeEnabled(id,enabled){ | 400 | function changeEnabled(id,enabled){ |
| 373 | - debugger | ||
| 374 | $get('/user/changeEnabled',{id:id,enabled:enabled},function(result){ | 401 | $get('/user/changeEnabled',{id:id,enabled:enabled},function(result){ |
| 375 | jsDoQuery(null, true); | 402 | jsDoQuery(null, true); |
| 376 | }) | 403 | }) |
src/main/resources/static/pages/excep/speedingMap.html
0 → 100644
| 1 | +<style> | ||
| 2 | + .play_back-layer .layui-layer-title{ | ||
| 3 | + height: 36px; | ||
| 4 | + border-bottom: none; | ||
| 5 | + } | ||
| 6 | +</style> | ||
| 7 | + | ||
| 8 | +<div id="titleMap"> | ||
| 9 | +<button id="run" style="margin-left:10px" class="btn btn-sm green btn-outline filter-submit margin-bottom">运行</button> | ||
| 10 | +</div> | ||
| 11 | +<div id="speedingMap"> | ||
| 12 | +</div> | ||
| 13 | +<style type="text/css"> | ||
| 14 | + | ||
| 15 | +#speedingMap{ | ||
| 16 | + width: 100%; | ||
| 17 | + border: 2px solid #fdfdfd; | ||
| 18 | + height: calc(100% - 30px); | ||
| 19 | + overflow: hidden; | ||
| 20 | +} | ||
| 21 | +</style> | ||
| 22 | +<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=IGGrr4UjwIYzatoCRFKEL8sT"></script> | ||
| 23 | +<script type="text/javascript" src="/pages/excep/js/speeding-map.js"></script> | ||
| 24 | +<script type="text/javascript"> | ||
| 25 | +$(function(){ | ||
| 26 | + var dataArr = window.localStorage.zbhAndDate.split(",");//获取页面传递过来的车辆自编号以及超速起始时间和超速结束时间 | ||
| 27 | + var vehicle = dataArr[0]; | ||
| 28 | + var startdate = dataArr[1]; | ||
| 29 | + var enddate = dataArr[2]; | ||
| 30 | + var lon = dataArr[3];//起点经度 | ||
| 31 | + var lat = dataArr[4];//起点纬度 | ||
| 32 | + var endLon = dataArr[5];//终点经度 | ||
| 33 | + var endLat = dataArr[6];//终点纬度 | ||
| 34 | + var Points = []; | ||
| 35 | + $.ajax({ | ||
| 36 | + type: "GET", | ||
| 37 | + async:false, | ||
| 38 | + url: '/gps/findPosition', | ||
| 39 | + data: {vehicle:vehicle,startdate:startdate,enddate:enddate}, | ||
| 40 | + success: function(data){ | ||
| 41 | + console.log("123"+data); | ||
| 42 | + $.each(data,function(i,item){ | ||
| 43 | + console.log(item); | ||
| 44 | + if(item.lon>1 && item.lat>1){ | ||
| 45 | + var point = new BMap.Point(item.lon,item.lat); | ||
| 46 | + Points.push(point); | ||
| 47 | + } | ||
| 48 | + }); | ||
| 49 | + } | ||
| 50 | + }); | ||
| 51 | + setTimeout(function(){ | ||
| 52 | + var map = SpeedingMap.init();//创建地图 | ||
| 53 | + var myP1 = new BMap.Point(lon,lat); //起点 | ||
| 54 | + var myP2 = new BMap.Point(endLon,endLat); //终点 | ||
| 55 | + map.centerAndZoom(myP1,18);//地图中心点坐标 | ||
| 56 | + console.log(Points); | ||
| 57 | + var polyline = new BMap.Polyline(Points, {strokeColor:"blue", strokeWeight:5, strokeOpacity:0.5}); //创建折线 | ||
| 58 | + var myIcon = new BMap.Icon("/pages/excep/img/bus.png", new BMap.Size(32, 70), {//小车图片 | ||
| 59 | + imageOffset: new BMap.Size(5,20) //图片的偏移量。为了是图片底部中心对准坐标点。 | ||
| 60 | + }); | ||
| 61 | + $(document).on('click', '#run', function() { | ||
| 62 | + map.clearOverlays();//清空上一次的轨迹 | ||
| 63 | + map.addOverlay(polyline);//增加折线 | ||
| 64 | + var paths = Points.length;//获得有几个点 | ||
| 65 | + var carMk = new BMap.Marker(Points[0],{icon:myIcon}); | ||
| 66 | + map.addOverlay(carMk); | ||
| 67 | + i=0; | ||
| 68 | + function resetMkPoint(i){ | ||
| 69 | + carMk.setPosition(Points[i]); | ||
| 70 | + if(i < paths){ | ||
| 71 | + setTimeout(function(){ | ||
| 72 | + i++; | ||
| 73 | + resetMkPoint(i); | ||
| 74 | + },100); | ||
| 75 | + } | ||
| 76 | + } | ||
| 77 | + setTimeout(function(){ | ||
| 78 | + resetMkPoint(0); | ||
| 79 | + },100) | ||
| 80 | + }); | ||
| 81 | + }); | ||
| 82 | +}, 100); | ||
| 83 | +</script> | ||
| 84 | + | ||
| 85 | + |