Commit 6b59c2a679eb437f13ed5530e0d0faa1039d0fc9
Merge branch 'minhang' of http://222.66.0.204:8090//panzhaov5/bsth_control into minhang
Showing
9 changed files
with
350 additions
and
50 deletions
src/main/java/com/bsth/controller/gps/GpsController.java
| ... | ... | @@ -3,8 +3,10 @@ package com.bsth.controller.gps; |
| 3 | 3 | import com.bsth.data.BasicData; |
| 4 | 4 | import com.bsth.data.gpsdata.GpsEntity; |
| 5 | 5 | import com.bsth.data.gpsdata.GpsRealData; |
| 6 | +import com.bsth.entity.excep.Speeding; | |
| 6 | 7 | import com.bsth.service.gps.GpsService; |
| 7 | 8 | import com.bsth.service.gps.entity.GpsSpeed; |
| 9 | +import com.bsth.util.PageObject; | |
| 8 | 10 | import com.google.common.base.Splitter; |
| 9 | 11 | import org.springframework.beans.factory.annotation.Autowired; |
| 10 | 12 | import org.springframework.web.bind.annotation.*; |
| ... | ... | @@ -192,4 +194,13 @@ public class GpsController { |
| 192 | 194 | return listGpsSpeed; |
| 193 | 195 | } |
| 194 | 196 | |
| 197 | + @RequestMapping(value = "/pagequery",method = RequestMethod.GET) | |
| 198 | + public PageObject<GpsSpeed> pagequery(@RequestParam Map<String, Object> map){ | |
| 199 | + PageObject<GpsSpeed> pageObject = null; | |
| 200 | + map.put("curPage", map.get("page").toString()); | |
| 201 | + map.put("pageData","10"); | |
| 202 | + pageObject=gpsService.Pagequery(map); | |
| 203 | + return pageObject; | |
| 204 | + } | |
| 205 | + | |
| 195 | 206 | } | ... | ... |
src/main/java/com/bsth/service/excep/impl/SpeedingServiceImpl.java
| ... | ... | @@ -14,13 +14,11 @@ import java.util.List; |
| 14 | 14 | import java.util.Map; |
| 15 | 15 | |
| 16 | 16 | import org.springframework.jdbc.core.JdbcTemplate; |
| 17 | -import org.springframework.jdbc.core.RowMapper; | |
| 18 | 17 | import org.springframework.stereotype.Service; |
| 19 | 18 | import org.springframework.beans.factory.annotation.Autowired; |
| 20 | 19 | |
| 21 | 20 | import com.bsth.data.BasicData; |
| 22 | 21 | import com.bsth.entity.excep.Speeding; |
| 23 | -import com.bsth.entity.realcontrol.ScheduleRealInfo; | |
| 24 | 22 | import com.bsth.service.excep.SpeedingService; |
| 25 | 23 | import com.bsth.util.EchartConver; |
| 26 | 24 | import com.bsth.util.PageHelper; |
| ... | ... | @@ -42,7 +40,7 @@ public class SpeedingServiceImpl implements SpeedingService { |
| 42 | 40 | ResultSet rs = null; |
| 43 | 41 | int page=Integer.parseInt(map.get("page").toString()); |
| 44 | 42 | List<Speeding> list=new ArrayList<Speeding>(); |
| 45 | - String sql="select * from bsth_c_speeding where speed > 60 "; | |
| 43 | + String sql="select * from bsth_c_speeding where 1=1 "; | |
| 46 | 44 | Object line=map.get("line"); |
| 47 | 45 | Object nbbm=map.get("nbbm"); |
| 48 | 46 | Object updown=map.get("updown"); |
| ... | ... | @@ -204,22 +202,40 @@ public class SpeedingServiceImpl implements SpeedingService { |
| 204 | 202 | int totalPage;//总页数 |
| 205 | 203 | int totalData = 0; |
| 206 | 204 | if(list.size()>1){ |
| 207 | - Speeding speedingNow;//下标为i的车 | |
| 208 | - Speeding speedingLast;//下标为i-1的车 | |
| 205 | + Speeding speedingNow;//下标为i的车辆行驶记录 | |
| 206 | + Speeding speedingLast;//下标为i-1的车辆行驶记录 | |
| 207 | + Speeding spped = null;//整合后的车辆行驶记录 | |
| 209 | 208 | String strNow; |
| 210 | 209 | String strLast; |
| 210 | + boolean Flag = false;//判断是否有连续超速记录,默认没有 | |
| 211 | 211 | for(int i = 1;i<list.size();i++){ |
| 212 | 212 | speedingNow = list.get(i); |
| 213 | 213 | speedingLast = list.get(i-1); |
| 214 | - strNow = speedingNow.getVehicle()+speedingNow.getLine()+speedingNow.getUpDown();//同一车辆同一线路同一方向 | |
| 214 | + strNow = speedingNow.getVehicle()+speedingNow.getLine()+speedingNow.getUpDown(); | |
| 215 | 215 | strLast = speedingLast.getVehicle()+speedingLast.getLine()+speedingLast.getUpDown(); |
| 216 | - //同一车辆同一线路同一方向并且该记录的超速的开始时间减去上一条超速记录的结束时间小于等于10s,证明该车超速。//PS:祛除数据库中的重复发送数据 | |
| 217 | - if(strNow.equals(strLast) && Math.abs(speedingNow.getTimestamp()-speedingLast.getTimestamp())<=10*1000 && (speedingNow.getTimestamp()-speedingLast.getTimestamp()!=0)){ | |
| 218 | - speedingLast.setEndtimestamp(speedingNow.getTimestamp());//设置结束时间时间戳 | |
| 219 | - speedingLast.setEndtimestampDate(sdf.format(new Date(speedingNow.getTimestamp())));//设置结束时间 | |
| 220 | - speedingLast.setEndlon(speedingNow.getLon());//设置结束时的经度 | |
| 221 | - speedingLast.setEndlat(speedingNow.getLat());//设置结束时的纬度 | |
| 222 | - listResult.add(speedingLast); | |
| 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 | + } | |
| 223 | 239 | } |
| 224 | 240 | } |
| 225 | 241 | Iterator<Speeding> speedIt = listResult.iterator(); | ... | ... |
src/main/java/com/bsth/service/gps/GpsService.java
| ... | ... | @@ -4,6 +4,7 @@ import com.bsth.data.gpsdata.GpsEntity; |
| 4 | 4 | import com.bsth.service.gps.entity.GpsOutbound_DTO; |
| 5 | 5 | import com.bsth.service.gps.entity.GpsSpeed; |
| 6 | 6 | import com.bsth.service.gps.entity.GpsSpeed_DTO; |
| 7 | +import com.bsth.util.PageObject; | |
| 7 | 8 | |
| 8 | 9 | import javax.servlet.http.HttpServletResponse; |
| 9 | 10 | |
| ... | ... | @@ -45,4 +46,6 @@ public interface GpsService { |
| 45 | 46 | |
| 46 | 47 | List<GpsSpeed> findPosition(String deviceid, String startdate, |
| 47 | 48 | String enddate) throws ParseException; |
| 49 | + | |
| 50 | + PageObject<GpsSpeed> Pagequery(Map<String, Object> map); | |
| 48 | 51 | } | ... | ... |
src/main/java/com/bsth/service/gps/GpsServiceImpl.java
| ... | ... | @@ -16,6 +16,8 @@ import com.bsth.repository.StationRepository; |
| 16 | 16 | import com.bsth.repository.realcontrol.ScheduleRealInfoRepository; |
| 17 | 17 | import com.bsth.service.gps.entity.*; |
| 18 | 18 | import com.bsth.util.DateUtils; |
| 19 | +import com.bsth.util.PageHelper; | |
| 20 | +import com.bsth.util.PageObject; | |
| 19 | 21 | import com.bsth.util.TransGPS; |
| 20 | 22 | import com.bsth.util.TransGPS.Location; |
| 21 | 23 | import com.bsth.util.db.DBUtils_MS; |
| ... | ... | @@ -44,6 +46,7 @@ import java.net.URLEncoder; |
| 44 | 46 | import java.sql.Connection; |
| 45 | 47 | import java.sql.PreparedStatement; |
| 46 | 48 | import java.sql.ResultSet; |
| 49 | +import java.sql.SQLException; | |
| 47 | 50 | import java.text.DecimalFormat; |
| 48 | 51 | import java.text.ParseException; |
| 49 | 52 | import java.text.SimpleDateFormat; |
| ... | ... | @@ -806,7 +809,7 @@ public class GpsServiceImpl implements GpsService { |
| 806 | 809 | @Override |
| 807 | 810 | public List<GpsSpeed_DTO> speeds(String nbbm, long st, long et) { |
| 808 | 811 | String deviceId = BasicData.deviceId2NbbmMap.inverse().get(nbbm); |
| 809 | - String sql = "select vehicle, line, up_down, lon, lat, speed,timestamp from bsth_c_speeding where vehicle=? and timestamp>? and timestamp<?"; | |
| 812 | + String sql = "select vehicle, line, up_down, lon, lat, speed,timestamp from bsth_c_GpsSpeed where vehicle=? and timestamp>? and timestamp<?"; | |
| 810 | 813 | |
| 811 | 814 | return GpsSpeed_DTO.create(new JdbcTemplate(DBUtils_MS.getDataSource()).queryForList(sql, deviceId, st * 1000, et * 1000)); |
| 812 | 815 | } |
| ... | ... | @@ -1036,4 +1039,182 @@ public class GpsServiceImpl implements GpsService { |
| 1036 | 1039 | return listResult; |
| 1037 | 1040 | |
| 1038 | 1041 | } |
| 1042 | + | |
| 1043 | + @Override | |
| 1044 | + public PageObject<GpsSpeed> Pagequery(Map<String, Object> map) { | |
| 1045 | + | |
| 1046 | + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |
| 1047 | + List<GpsSpeed> list=findAll(map); | |
| 1048 | + List<GpsSpeed> listResult = new ArrayList<GpsSpeed>(); | |
| 1049 | + int curPage;//页码 | |
| 1050 | + int pageData;//每页的记录条数 | |
| 1051 | + int start;//起始数据下标 | |
| 1052 | + int totalPage;//总页数 | |
| 1053 | + int totalData = 0; | |
| 1054 | + if(list.size()>1){ | |
| 1055 | + GpsSpeed GpsSpeedNow;//下标为i的车辆行驶记录 | |
| 1056 | + GpsSpeed GpsSpeedLast;//下标为i-1的车辆行驶记录 | |
| 1057 | + GpsSpeed spped = null;//整合后的车辆行驶记录 | |
| 1058 | + String strNow; | |
| 1059 | + String strLast; | |
| 1060 | + boolean Flag = false;//判断是否有连续超速记录,默认没有 | |
| 1061 | + for(int i = 1;i<list.size();i++){ | |
| 1062 | + GpsSpeedNow = list.get(i); | |
| 1063 | + GpsSpeedLast = list.get(i-1); | |
| 1064 | + strNow = GpsSpeedNow.getVehicle()+GpsSpeedNow.getLine()+GpsSpeedNow.getUp_down(); | |
| 1065 | + strLast = GpsSpeedLast.getVehicle()+GpsSpeedLast.getLine()+GpsSpeedLast.getUp_down(); | |
| 1066 | + if(GpsSpeedNow.getSpeed()>60 && GpsSpeedLast.getSpeed()>60 && strNow.equals(strLast)){//如果两条连续的记录都是超速且属于同一辆车。 | |
| 1067 | + if(Flag==false){// | |
| 1068 | + spped = new GpsSpeed(); | |
| 1069 | + spped.setLine(GpsSpeedLast.getLine());//设置连续超速记录线路 | |
| 1070 | + spped.setLineName(GpsSpeedLast.getLineName());//设置连续超速记录线路名称 | |
| 1071 | + spped.setVehicle(GpsSpeedLast.getVehicle());//设置连续超速记录的车辆编号 | |
| 1072 | + spped.setUp_down(GpsSpeedLast.getUp_down());//设置上下行 | |
| 1073 | + spped.setLon(GpsSpeedLast.getLon());//设置开始时经度 | |
| 1074 | + spped.setLat(GpsSpeedLast.getLat());//设置开始时纬度 | |
| 1075 | + spped.setTimestamp(GpsSpeedLast.getTimestamp());//设置连续超速记录的开始时间 | |
| 1076 | + spped.setTimestampDate(GpsSpeedLast.getTimestampDate());//设置连续超速记录的开始时间戳 | |
| 1077 | + } | |
| 1078 | + spped.setEndtimestamp(GpsSpeedNow.getTimestamp());//设置结束时间戳 | |
| 1079 | + spped.setEndtimestampDate(sdf.format(new Date(GpsSpeedNow.getTimestamp())));//设置结束时间 | |
| 1080 | + spped.setEndlon(GpsSpeedNow.getLon());//设置结束时的经度 | |
| 1081 | + spped.setEndlat(GpsSpeedNow.getLat());//设置结束时的纬度 | |
| 1082 | + Flag = true; | |
| 1083 | + }else{ | |
| 1084 | + if(Flag){//如果上一条记录超速。 | |
| 1085 | + listResult.add(spped); | |
| 1086 | + Flag = false; | |
| 1087 | + } | |
| 1088 | + } | |
| 1089 | + } | |
| 1090 | + Iterator<GpsSpeed> speedIt = listResult.iterator(); | |
| 1091 | + while(speedIt.hasNext()){ | |
| 1092 | + GpsSpeed GpsSpeed = speedIt.next(); | |
| 1093 | + if(GpsSpeed.getEndtimestamp()-GpsSpeed.getTimestamp()<=1000){ | |
| 1094 | + speedIt.remove(); | |
| 1095 | + } | |
| 1096 | + } | |
| 1097 | + | |
| 1098 | + totalData = listResult.size();//总记录条数。 | |
| 1099 | + if(map.get("curPage") == null || map.get("curPage").equals("0")){ | |
| 1100 | + curPage = 0; | |
| 1101 | + }else{ | |
| 1102 | + curPage = Integer.parseInt((String) map.get("curPage")); | |
| 1103 | + } | |
| 1104 | + pageData = Integer.parseInt((String) map.get("pageData"));//每页的记录条数 | |
| 1105 | + start = (curPage - 0) * pageData; //起始记录下标。 | |
| 1106 | + totalPage = totalData % pageData == 0 ? totalData / pageData : totalData / pageData +1;//总页数 | |
| 1107 | + if(curPage == totalPage-1){//如果当前页等于总页数。 | |
| 1108 | + listResult = listResult.subList(start, totalData); | |
| 1109 | + }else{ | |
| 1110 | + listResult = listResult.subList(start, start+pageData); | |
| 1111 | + } | |
| 1112 | + }else{ | |
| 1113 | + curPage = 1; | |
| 1114 | + pageData = Integer.parseInt((String) map.get("pageData"));//每页的记录条数 | |
| 1115 | + totalPage =1; | |
| 1116 | + } | |
| 1117 | + Map<String,Object> paramMap = new HashMap<String,Object>(); | |
| 1118 | + paramMap.put("totalPage", totalPage); | |
| 1119 | + paramMap.put("curPage", curPage); | |
| 1120 | + paramMap.put("pageData", pageData); | |
| 1121 | + PageHelper pageHelper = new PageHelper(totalData, paramMap); | |
| 1122 | + pageHelper.getMap(); | |
| 1123 | + PageObject<GpsSpeed> pageObject = pageHelper.getPageObject(); | |
| 1124 | + pageObject.setDataList(listResult); | |
| 1125 | + return pageObject; | |
| 1126 | + } | |
| 1127 | + | |
| 1128 | + static List<GpsSpeed> findAll(Map<String, Object> map) { | |
| 1129 | + Connection conn = null; | |
| 1130 | + PreparedStatement ps = null; | |
| 1131 | + ResultSet rs = null; | |
| 1132 | + int page=Integer.parseInt(map.get("page").toString()); | |
| 1133 | + List<GpsSpeed> list=new ArrayList<GpsSpeed>(); | |
| 1134 | + String sql="select * from bsth_c_gps_info where 1=1 "; | |
| 1135 | + Object line=map.get("line"); | |
| 1136 | + Object nbbm=map.get("nbbm"); | |
| 1137 | + Object updown=map.get("updown"); | |
| 1138 | + Object startDate=map.get("startDate"); | |
| 1139 | + Object endDate=map.get("endDate"); | |
| 1140 | + | |
| 1141 | + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |
| 1142 | + if(line!=null){ | |
| 1143 | + sql +=" and line_id like'%"+line.toString().trim()+"%'"; | |
| 1144 | + } | |
| 1145 | + | |
| 1146 | + if(nbbm!=null){ | |
| 1147 | + nbbm=BasicData.deviceId2NbbmMap.inverse().get(nbbm); | |
| 1148 | + if(nbbm!=null) | |
| 1149 | + sql +=" and vehicle like '%"+nbbm.toString()+"%'"; | |
| 1150 | + } | |
| 1151 | + | |
| 1152 | + if(updown!=null){ | |
| 1153 | + sql +="and industry_code like '%"+updown.toString()+"%'"; | |
| 1154 | + } | |
| 1155 | + if(startDate!=null){ | |
| 1156 | + if (startDate.toString().length()>0) { | |
| 1157 | + try { | |
| 1158 | + Long t1=sdf.parse(startDate.toString()+" 00:00:00").getTime(); | |
| 1159 | + sql += " and ts >="+t1; | |
| 1160 | + } catch (ParseException e) { | |
| 1161 | + e.printStackTrace(); | |
| 1162 | + } | |
| 1163 | + } | |
| 1164 | + | |
| 1165 | + } | |
| 1166 | + if(endDate!=null){ | |
| 1167 | + if (endDate.toString().length()>0) { | |
| 1168 | + try { | |
| 1169 | + Long t2=sdf.parse(endDate.toString()+" 23:59:59").getTime(); | |
| 1170 | + sql += " and ts <="+t2; | |
| 1171 | + } catch (ParseException e) { | |
| 1172 | + e.printStackTrace(); | |
| 1173 | + } | |
| 1174 | + } | |
| 1175 | + | |
| 1176 | + } | |
| 1177 | + | |
| 1178 | + try { | |
| 1179 | + conn = DBUtils_MS.getConnection(); | |
| 1180 | + ps = conn.prepareStatement(sql); | |
| 1181 | + rs = ps.executeQuery(); | |
| 1182 | + list = resultSet2Set(rs); | |
| 1183 | + } catch (SQLException e) { | |
| 1184 | + e.printStackTrace(); | |
| 1185 | + }finally { | |
| 1186 | + DBUtils_MS.close(rs, ps, conn); | |
| 1187 | + } | |
| 1188 | + | |
| 1189 | + return list; | |
| 1190 | + } | |
| 1191 | + | |
| 1192 | + static List<GpsSpeed> resultSet2Set(ResultSet rs) throws SQLException{ | |
| 1193 | + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |
| 1194 | + List<GpsSpeed> list=new ArrayList<GpsSpeed>(); | |
| 1195 | + GpsSpeed GpsSpeed; | |
| 1196 | + Float lon, lat; | |
| 1197 | + Location location; | |
| 1198 | + while(rs.next()){ | |
| 1199 | + lon = rs.getFloat("lon"); | |
| 1200 | + lat = rs.getFloat("lat"); | |
| 1201 | + location = TransGPS.LocationMake(lon, lat); | |
| 1202 | + location = TransGPS.bd_encrypt(TransGPS.transformFromWGSToGCJ(location)); | |
| 1203 | + GpsSpeed=new GpsSpeed(); | |
| 1204 | + GpsSpeed.setLon((float)location.getLng()); | |
| 1205 | + GpsSpeed.setLat((float)location.getLat()); | |
| 1206 | + GpsSpeed.setLine(rs.getObject("line_id").toString()); | |
| 1207 | + //run 时注解 | |
| 1208 | + GpsSpeed.setLineName(BasicData.lineCode2NameMap.get(GpsSpeed.getLine().toString())); | |
| 1209 | + GpsSpeed.setSpeed(Float.valueOf(rs.getObject("speed_gps").toString())); | |
| 1210 | + GpsSpeed.setTimestamp((Long.valueOf(rs.getObject("ts").toString()))); | |
| 1211 | + GpsSpeed.setTimestampDate(sdf.format(new Date(GpsSpeed.getTimestamp()))); | |
| 1212 | + GpsSpeed.setUp_down(((Integer.valueOf(rs.getObject("service_state").toString())) & 0x10000000)==0?0:1); | |
| 1213 | + GpsSpeed.setVehicle(BasicData.deviceId2NbbmMap.get(rs.getObject("device_id").toString())); | |
| 1214 | + list.add(GpsSpeed); | |
| 1215 | + } | |
| 1216 | + return list; | |
| 1217 | + } | |
| 1218 | + | |
| 1039 | 1219 | } |
| 1220 | + | ... | ... |
src/main/java/com/bsth/service/gps/entity/GpsSpeed.java
| 1 | 1 | package com.bsth.service.gps.entity; |
| 2 | 2 | |
| 3 | +import javax.persistence.Transient; | |
| 4 | + | |
| 3 | 5 | /** |
| 4 | 6 | * 超速异常 -ms数据库格式 |
| 5 | 7 | * Created by panzhao on 2017/4/7. |
| ... | ... | @@ -15,11 +17,59 @@ public class GpsSpeed { |
| 15 | 17 | private float lon; |
| 16 | 18 | |
| 17 | 19 | private float lat; |
| 20 | + | |
| 21 | + private String lineName; | |
| 22 | + | |
| 23 | + /** | |
| 24 | + * 超速结束时的纬度 | |
| 25 | + */ | |
| 26 | + @Transient | |
| 27 | + private Float endlat; | |
| 28 | + | |
| 29 | + /** | |
| 30 | + * 超速结束时的经度 | |
| 31 | + */ | |
| 32 | + @Transient | |
| 33 | + private Float endlon; | |
| 18 | 34 | |
| 19 | 35 | private float speed; |
| 20 | - | |
| 36 | + | |
| 21 | 37 | private long timestamp; |
| 22 | - | |
| 38 | + | |
| 39 | + @Transient | |
| 40 | + private String timestampDate; | |
| 41 | + | |
| 42 | + public String getTimestampDate() { | |
| 43 | + return timestampDate; | |
| 44 | + } | |
| 45 | + | |
| 46 | + public void setTimestampDate(String timestampDate) { | |
| 47 | + this.timestampDate = timestampDate; | |
| 48 | + } | |
| 49 | + | |
| 50 | + public Long getEndtimestamp() { | |
| 51 | + return endtimestamp; | |
| 52 | + } | |
| 53 | + | |
| 54 | + public void setEndtimestamp(Long endtimestamp) { | |
| 55 | + this.endtimestamp = endtimestamp; | |
| 56 | + } | |
| 57 | + | |
| 58 | + public String getEndtimestampDate() { | |
| 59 | + return endtimestampDate; | |
| 60 | + } | |
| 61 | + | |
| 62 | + public void setEndtimestampDate(String endtimestampDate) { | |
| 63 | + this.endtimestampDate = endtimestampDate; | |
| 64 | + } | |
| 65 | + | |
| 66 | + //结束时间,单位:秒/s | |
| 67 | + @Transient | |
| 68 | + private Long endtimestamp; | |
| 69 | + | |
| 70 | + @Transient | |
| 71 | + private String endtimestampDate; | |
| 72 | + | |
| 23 | 73 | public String getVehicle() { |
| 24 | 74 | return vehicle; |
| 25 | 75 | } |
| ... | ... | @@ -75,4 +125,28 @@ public class GpsSpeed { |
| 75 | 125 | public void setTimestamp(long timestamp) { |
| 76 | 126 | this.timestamp = timestamp; |
| 77 | 127 | } |
| 128 | + | |
| 129 | + public Float getEndlon() { | |
| 130 | + return endlon; | |
| 131 | + } | |
| 132 | + | |
| 133 | + public void setEndlon(Float endlon) { | |
| 134 | + this.endlon = endlon; | |
| 135 | + } | |
| 136 | + | |
| 137 | + public Float getEndlat() { | |
| 138 | + return endlat; | |
| 139 | + } | |
| 140 | + | |
| 141 | + public void setEndlat(Float endlat) { | |
| 142 | + this.endlat = endlat; | |
| 143 | + } | |
| 144 | + | |
| 145 | + public String getLineName() { | |
| 146 | + return lineName; | |
| 147 | + } | |
| 148 | + | |
| 149 | + public void setLineName(String lineName) { | |
| 150 | + this.lineName = lineName; | |
| 151 | + } | |
| 78 | 152 | } | ... | ... |
src/main/resources/application-dev.properties
| ... | ... | @@ -8,9 +8,9 @@ spring.jpa.hibernate.naming_strategy= org.hibernate.cfg.ImprovedNamingStrategy |
| 8 | 8 | spring.jpa.database= MYSQL |
| 9 | 9 | spring.jpa.show-sql= false |
| 10 | 10 | spring.datasource.driver-class-name= com.mysql.jdbc.Driver |
| 11 | -spring.datasource.url= jdbc:mysql://127.0.0.1/control?useUnicode=true&characterEncoding=utf-8&useSSL=false | |
| 11 | +spring.datasource.url= jdbc:mysql://localhost:3306/mhcontrol?useUnicode=true&characterEncoding=utf-8&useSSL=false | |
| 12 | 12 | spring.datasource.username= root |
| 13 | -spring.datasource.password= | |
| 13 | +spring.datasource.password= zhoubing | |
| 14 | 14 | #spring.datasource.url= jdbc:mysql://192.168.168.117/pd_control?useUnicode=true&characterEncoding=utf-8&useSSL=false |
| 15 | 15 | #spring.datasource.username= root |
| 16 | 16 | #spring.datasource.password= root |
| ... | ... | @@ -32,4 +32,4 @@ spring.datasource.validation-query=select 1 |
| 32 | 32 | http.gps.real.url= http://114.80.178.12:18080/transport_server/rtgps/ |
| 33 | 33 | #http.gps.real.url= http://27.115.69.123:8800/transport_server/rtgps/ |
| 34 | 34 | ##\u6D88\u606F\u4E0B\u53D1 |
| 35 | -http.send.directive = http://192.168.168.201:9090/transport_server/message/ | |
| 36 | 35 | \ No newline at end of file |
| 36 | +http.send.directive =http\://192.168.168.201\:9090/transport_server/message/ | |
| 37 | 37 | \ No newline at end of file | ... | ... |
src/main/resources/ms-jdbc.properties
| ... | ... | @@ -4,6 +4,6 @@ |
| 4 | 4 | #ms.mysql.password= 123456 |
| 5 | 5 | |
| 6 | 6 | ms.mysql.driver= com.mysql.jdbc.Driver |
| 7 | -ms.mysql.url= jdbc:mysql://192.168.168.171:3306/ms?useUnicode=true&characterEncoding=utf-8 | |
| 8 | -ms.mysql.username= root | |
| 9 | -ms.mysql.password= root2jsp | |
| 10 | 7 | \ No newline at end of file |
| 8 | +ms.mysql.url= jdbc:mysql://localhost:3306/ms?useUnicode=true&characterEncoding=utf-8&useSSL=false | |
| 9 | +ms.mysql.username=root | |
| 10 | +ms.mysql.password=zhoubing | |
| 11 | 11 | \ No newline at end of file | ... | ... |
src/main/resources/static/pages/excep/speedingListmh.html
| ... | ... | @@ -128,9 +128,9 @@ |
| 128 | 128 | {{obj.vehicle}} |
| 129 | 129 | </td> |
| 130 | 130 | <td> |
| 131 | - {{if obj.upDown==0}} | |
| 131 | + {{if obj.up_down==0}} | |
| 132 | 132 | 上行 |
| 133 | - {{else if obj.upDown==1}} | |
| 133 | + {{else if obj.up_down==1}} | |
| 134 | 134 | 下行 |
| 135 | 135 | {{else}} |
| 136 | 136 | 无效 |
| ... | ... | @@ -249,7 +249,7 @@ $(function(){ |
| 249 | 249 | params['order'] = 'lastLoginDate'; |
| 250 | 250 | params['page'] = page; |
| 251 | 251 | var i = layer.load(2); |
| 252 | - $get('/speeding/pagequery' ,params, function(data){ | |
| 252 | + $get('/gps/pagequery' ,params, function(data){ | |
| 253 | 253 | var bodyHtm = template('speeding_list_temp', {list: data.dataList}); |
| 254 | 254 | $('#datatable_speeding tbody').html(bodyHtm) |
| 255 | 255 | .find('.icheck').iCheck(icheckOptions) | ... | ... |
src/main/resources/static/pages/excep/speedingMap.html
| ... | ... | @@ -19,7 +19,6 @@ |
| 19 | 19 | overflow: hidden; |
| 20 | 20 | } |
| 21 | 21 | </style> |
| 22 | -<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=IGGrr4UjwIYzatoCRFKEL8sT"></script> | |
| 23 | 22 | <script type="text/javascript" src="/pages/excep/js/speeding-map.js"></script> |
| 24 | 23 | <script type="text/javascript"> |
| 25 | 24 | $(function(){ |
| ... | ... | @@ -31,55 +30,71 @@ $(function(){ |
| 31 | 30 | var lat = dataArr[4];//起点纬度 |
| 32 | 31 | var endLon = dataArr[5];//终点经度 |
| 33 | 32 | var endLat = dataArr[6];//终点纬度 |
| 34 | - var Points = []; | |
| 33 | + var pointObj;//坐标和速度组成的对象 | |
| 34 | + var Points = [];//坐标和速度对象的集合 | |
| 35 | + var coordinateArr = [];//坐标点数组 | |
| 35 | 36 | $.ajax({ |
| 36 | 37 | type: "GET", |
| 37 | 38 | async:false, |
| 38 | 39 | url: '/gps/findPosition', |
| 39 | 40 | data: {vehicle:vehicle,startdate:startdate,enddate:enddate}, |
| 40 | 41 | success: function(data){ |
| 41 | - console.log("123"+data); | |
| 42 | 42 | $.each(data,function(i,item){ |
| 43 | - console.log(item); | |
| 44 | 43 | if(item.lon>1 && item.lat>1){ |
| 45 | - var point = new BMap.Point(item.lon,item.lat); | |
| 46 | - Points.push(point); | |
| 44 | + pointObj = new Object(); | |
| 45 | + pointObj.coordinate = new BMap.Point(item.lon,item.lat); | |
| 46 | + pointObj.speed = item.speed; | |
| 47 | + Points.push(pointObj); | |
| 47 | 48 | } |
| 48 | 49 | }); |
| 49 | 50 | } |
| 50 | - }); | |
| 51 | + }); | |
| 51 | 52 | setTimeout(function(){ |
| 52 | 53 | var map = SpeedingMap.init();//创建地图 |
| 53 | 54 | var myP1 = new BMap.Point(lon,lat); //起点 |
| 54 | 55 | 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}); //创建折线 | |
| 56 | + var centerLon = (parseFloat(lon)+parseFloat(endLon))/2; | |
| 57 | + var centerLat = (parseFloat(lat)+parseFloat(endLat))/2; | |
| 58 | + map.centerAndZoom(new BMap.Point(centerLon,centerLat),18);//地图中心点坐标 | |
| 59 | + | |
| 60 | + for(i in Points){ | |
| 61 | + coordinateArr.push(Points[i].coordinate); | |
| 62 | + } | |
| 63 | + var polyline = new BMap.Polyline(coordinateArr, {strokeColor:"blue", strokeWeight:5, strokeOpacity:0.5});//创建折线 | |
| 58 | 64 | var myIcon = new BMap.Icon("/pages/excep/img/bus.png", new BMap.Size(32, 70), {//小车图片 |
| 59 | 65 | imageOffset: new BMap.Size(5,20) //图片的偏移量。为了是图片底部中心对准坐标点。 |
| 60 | 66 | }); |
| 67 | + | |
| 61 | 68 | $(document).on('click', '#run', function() { |
| 62 | 69 | map.clearOverlays();//清空上一次的轨迹 |
| 63 | 70 | map.addOverlay(polyline);//增加折线 |
| 64 | - var paths = Points.length;//获得有几个点 | |
| 65 | - var carMk = new BMap.Marker(Points[0],{icon:myIcon}); | |
| 71 | + var paths = coordinateArr.length;//获得有几个点 | |
| 72 | + var carMk = new BMap.Marker(coordinateArr[0],{icon:myIcon}); | |
| 66 | 73 | map.addOverlay(carMk); |
| 74 | + var sContent ="车辆即时速度:"+Points[0].speed; | |
| 75 | + var infoWindow = new BMap.InfoWindow(sContent);// 创建信息窗口对象 | |
| 76 | + map.openInfoWindow(infoWindow,coordinateArr[0]); //开启信息窗口 | |
| 67 | 77 | 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 | - } | |
| 78 | + | |
| 79 | + setTimeout(function(){ | |
| 80 | + resetMkPoint(0); | |
| 81 | + },500); | |
| 82 | + | |
| 83 | + function resetMkPoint(i){ | |
| 84 | + carMk.setPosition(coordinateArr[i]); | |
| 85 | + sContent ="车辆即时速度是:"+Points[i].speed; | |
| 86 | + infoWindow = new BMap.InfoWindow(sContent);// 创建信息窗口对象 | |
| 87 | + map.openInfoWindow(infoWindow,coordinateArr[i]); //开启信息窗口 | |
| 88 | + if(i < paths-1){ | |
| 89 | + setTimeout(function(){ | |
| 90 | + i++; | |
| 91 | + resetMkPoint(i); | |
| 92 | + },500); | |
| 76 | 93 | } |
| 77 | - setTimeout(function(){ | |
| 78 | - resetMkPoint(0); | |
| 79 | - },100) | |
| 80 | - }); | |
| 94 | + }; | |
| 81 | 95 | }); |
| 82 | -}, 100); | |
| 96 | +}, 500); | |
| 97 | + }); | |
| 83 | 98 | </script> |
| 84 | 99 | |
| 85 | 100 | ... | ... |