Commit 79962640ce2496b98d81f665f9eab7cb0a3559da

Authored by 潘钊
1 parent b6d02551

update...

src/main/java/com/bsth/data/gpsdata/GpsEntity.java
@@ -315,7 +315,7 @@ public class GpsEntity { @@ -315,7 +315,7 @@ public class GpsEntity {
315 this.setAbnormalStatus("offline"); 315 this.setAbnormalStatus("offline");
316 } 316 }
317 317
318 - public boolean isOnline(){ 318 +/* public boolean isOnline(){
319 if(isOffline()) 319 if(isOffline())
320 return false; 320 return false;
321 321
@@ -329,7 +329,7 @@ public class GpsEntity { @@ -329,7 +329,7 @@ public class GpsEntity {
329 return false; 329 return false;
330 } 330 }
331 return true; 331 return true;
332 - } 332 + }*/
333 333
334 /** 334 /**
335 * 是否营运 335 * 是否营运
src/main/java/com/bsth/data/gpsdata/arrival/GeoCacheData.java
@@ -144,29 +144,17 @@ public class GeoCacheData { @@ -144,29 +144,17 @@ public class GeoCacheData {
144 } 144 }
145 145
146 private void loadRoadsData() { 146 private void loadRoadsData() {
  147 + //加载线路下路段空间数据
147 String sql = "select r.LINE_CODE,r.SECTION_CODE,r.SECTIONROUTE_CODE,s.SECTION_NAME,ST_AsText(s.GSECTION_VECTOR) as GSECTION_VECTOR, r.DIRECTIONS, s.CROSES_ROAD from bsth_c_sectionroute r INNER JOIN bsth_c_section s on r.section=s.id where r.destroy=0 and GSECTION_VECTOR is not null order by line_code,directions,sectionroute_code"; 148 String sql = "select r.LINE_CODE,r.SECTION_CODE,r.SECTIONROUTE_CODE,s.SECTION_NAME,ST_AsText(s.GSECTION_VECTOR) as GSECTION_VECTOR, r.DIRECTIONS, s.CROSES_ROAD from bsth_c_sectionroute r INNER JOIN bsth_c_section s on r.section=s.id where r.destroy=0 and GSECTION_VECTOR is not null order by line_code,directions,sectionroute_code";
148 List<Map<String, Object>> secList = jdbcTemplate.queryForList(sql); 149 List<Map<String, Object>> secList = jdbcTemplate.queryForList(sql);
149 150
150 String polygonStr, key; 151 String polygonStr, key;
151 String[] coords; 152 String[] coords;
152 int i, len; 153 int i, len;
153 -  
154 ArrayListMultimap<String, LineString> sectionCacheTempMap = ArrayListMultimap.create(); 154 ArrayListMultimap<String, LineString> sectionCacheTempMap = ArrayListMultimap.create();
155 - Map<String, String> sectionCode2NameTemp = new HashMap<>();  
156 -  
157 Coordinate[] cds; 155 Coordinate[] cds;
158 String[] temps1, temps2; 156 String[] temps1, temps2;
159 - String name = null, code;  
160 for (Map<String, Object> tMap : secList) { 157 for (Map<String, Object> tMap : secList) {
161 - //编码和名称对照  
162 - if(tMap.get("CROSES_ROAD") != null && StringUtils.isNotEmpty(tMap.get("CROSES_ROAD").toString()))  
163 - name = tMap.get("CROSES_ROAD").toString();  
164 - else if(tMap.get("SECTION_NAME") != null && StringUtils.isNotEmpty(tMap.get("SECTION_NAME").toString()))  
165 - name = tMap.get("SECTION_NAME").toString();  
166 -  
167 - code = tMap.get("SECTION_CODE").toString();  
168 - sectionCode2NameTemp.put(code, name);  
169 -  
170 //空间数据映射 158 //空间数据映射
171 polygonStr = tMap.get("GSECTION_VECTOR").toString(); 159 polygonStr = tMap.get("GSECTION_VECTOR").toString();
172 key = tMap.get("LINE_CODE") + "_" + tMap.get("DIRECTIONS"); 160 key = tMap.get("LINE_CODE") + "_" + tMap.get("DIRECTIONS");
@@ -188,6 +176,22 @@ public class GeoCacheData { @@ -188,6 +176,22 @@ public class GeoCacheData {
188 176
189 if(sectionCacheTempMap.size() > 0) 177 if(sectionCacheTempMap.size() > 0)
190 sectionCacheMap = sectionCacheTempMap; 178 sectionCacheMap = sectionCacheTempMap;
  179 +
  180 + Map<String, String> sectionCode2NameTemp = new HashMap<>();
  181 +
  182 + //加载全量路段编码和名称对照
  183 + sql = "select SECTION_CODE,SECTION_NAME,CROSES_ROAD from bsth_c_section";
  184 + secList = jdbcTemplate.queryForList(sql);
  185 + String name = null, code;
  186 + for (Map<String, Object> tMap : secList) {
  187 + if(tMap.get("CROSES_ROAD") != null && StringUtils.isNotEmpty(tMap.get("CROSES_ROAD").toString()))
  188 + name = tMap.get("CROSES_ROAD").toString();
  189 + else if(tMap.get("SECTION_NAME") != null && StringUtils.isNotEmpty(tMap.get("SECTION_NAME").toString()))
  190 + name = tMap.get("SECTION_NAME").toString();
  191 +
  192 + code = tMap.get("SECTION_CODE").toString();
  193 + sectionCode2NameTemp.put(code, name);
  194 + }
191 if(sectionCode2NameTemp.size() > 0) 195 if(sectionCode2NameTemp.size() > 0)
192 sectionCode2Name = sectionCode2NameTemp; 196 sectionCode2Name = sectionCode2NameTemp;
193 } 197 }
src/main/java/com/bsth/service/gps/GpsServiceImpl.java
@@ -821,7 +821,7 @@ public class GpsServiceImpl implements GpsService { @@ -821,7 +821,7 @@ public class GpsServiceImpl implements GpsService {
821 @Override 821 @Override
822 public List<GpsSpeed_DTO> speeds(String nbbm, long st, long et) { 822 public List<GpsSpeed_DTO> speeds(String nbbm, long st, long et) {
823 String deviceId = BasicData.deviceId2NbbmMap.inverse().get(nbbm); 823 String deviceId = BasicData.deviceId2NbbmMap.inverse().get(nbbm);
824 - String sql = "select vehicle, line, up_down, lon, lat, speed,timestamp from bsth_c_GpsSpeed where vehicle=? and timestamp>? and timestamp<?"; 824 + String sql = "select vehicle, line, up_down, lon, lat, speed,timestamp from bsth_c_speeding where vehicle=? and timestamp>? and timestamp<?";
825 825
826 return GpsSpeed_DTO.create(new JdbcTemplate(DBUtils_MS.getDataSource()).queryForList(sql, deviceId, st * 1000, et * 1000)); 826 return GpsSpeed_DTO.create(new JdbcTemplate(DBUtils_MS.getDataSource()).queryForList(sql, deviceId, st * 1000, et * 1000));
827 } 827 }
@@ -999,20 +999,20 @@ public class GpsServiceImpl implements GpsService { @@ -999,20 +999,20 @@ public class GpsServiceImpl implements GpsService {
999 return true; 999 return true;
1000 } 1000 }
1001 1001
1002 - @Override  
1003 - public List<GpsSpeed> findPosition(String deviceid, String startdate,  
1004 - String enddate) throws ParseException{  
1005 - SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  
1006 - Calendar c = Calendar.getInstance();  
1007 - Date date = sdf.parse(startdate);  
1008 - c.setTime(date);  
1009 - int daysYear = c.get(Calendar.DAY_OF_YEAR);//获取当前是今年的第几天。  
1010 -  
1011 - long startTime = sdf.parse(startdate).getTime();  
1012 - long endTime = sdf.parse(enddate).getTime();  
1013 - 1002 + @Override
  1003 + public List<GpsSpeed> findPosition(String deviceid, String startdate,
  1004 + String enddate) throws ParseException{
  1005 + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  1006 + Calendar c = Calendar.getInstance();
  1007 + Date date = sdf.parse(startdate);
  1008 + c.setTime(date);
  1009 + int daysYear = c.get(Calendar.DAY_OF_YEAR);//获取当前是今年的第几天。
  1010 +
  1011 + long startTime = sdf.parse(startdate).getTime();
  1012 + long endTime = sdf.parse(enddate).getTime();
  1013 +
1014 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 <= ?" + 1014 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 <= ?" +
1015 - " ORDER BY TS "; 1015 + " ORDER BY TS ";
1016 Connection conn = null; 1016 Connection conn = null;
1017 PreparedStatement ps = null; 1017 PreparedStatement ps = null;
1018 ResultSet rs = null; 1018 ResultSet rs = null;
@@ -1029,7 +1029,7 @@ public class GpsServiceImpl implements GpsService { @@ -1029,7 +1029,7 @@ public class GpsServiceImpl implements GpsService {
1029 Float lon, lat; 1029 Float lon, lat;
1030 Location location; 1030 Location location;
1031 while (rs.next()) { 1031 while (rs.next()) {
1032 - gpsSpeed = new GpsSpeed(); 1032 + gpsSpeed = new GpsSpeed();
1033 // to 百度坐标 1033 // to 百度坐标
1034 lon = rs.getFloat("LON"); 1034 lon = rs.getFloat("LON");
1035 lat = rs.getFloat("LAT"); 1035 lat = rs.getFloat("LAT");
@@ -1049,184 +1049,184 @@ public class GpsServiceImpl implements GpsService { @@ -1049,184 +1049,184 @@ public class GpsServiceImpl implements GpsService {
1049 DBUtils_MS.close(rs, ps, conn); 1049 DBUtils_MS.close(rs, ps, conn);
1050 } 1050 }
1051 return listResult; 1051 return listResult;
1052 -  
1053 - }  
1054 -  
1055 - @Override  
1056 - public PageObject<GpsSpeed> Pagequery(Map<String, Object> map) {  
1057 -  
1058 - SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  
1059 - List<GpsSpeed> list=findAll(map);  
1060 - List<GpsSpeed> listResult = new ArrayList<GpsSpeed>();  
1061 - int curPage;//页码  
1062 - int pageData;//每页的记录条数  
1063 - int start;//起始数据下标  
1064 - int totalPage;//总页数  
1065 - int totalData = 0;  
1066 - if(list.size()>1){  
1067 - GpsSpeed GpsSpeedNow;//下标为i的车辆行驶记录  
1068 - GpsSpeed GpsSpeedLast;//下标为i-1的车辆行驶记录  
1069 - GpsSpeed spped = null;//整合后的车辆行驶记录  
1070 - String strNow;  
1071 - String strLast;  
1072 - boolean Flag = false;//判断是否有连续超速记录,默认没有  
1073 - for(int i = 1;i<list.size();i++){  
1074 - GpsSpeedNow = list.get(i);  
1075 - GpsSpeedLast = list.get(i-1);  
1076 - strNow = GpsSpeedNow.getVehicle()+GpsSpeedNow.getLine()+GpsSpeedNow.getUp_down();  
1077 - strLast = GpsSpeedLast.getVehicle()+GpsSpeedLast.getLine()+GpsSpeedLast.getUp_down();  
1078 - if(GpsSpeedNow.getSpeed()>60 && GpsSpeedLast.getSpeed()>60 && strNow.equals(strLast)){//如果两条连续的记录都是超速且属于同一辆车。  
1079 - if(Flag==false){//  
1080 - spped = new GpsSpeed();  
1081 - spped.setLine(GpsSpeedLast.getLine());//设置连续超速记录线路  
1082 - spped.setLineName(GpsSpeedLast.getLineName());//设置连续超速记录线路名称  
1083 - spped.setVehicle(GpsSpeedLast.getVehicle());//设置连续超速记录的车辆编号  
1084 - spped.setUp_down(GpsSpeedLast.getUp_down());//设置上下行  
1085 - spped.setLon(GpsSpeedLast.getLon());//设置开始时经度  
1086 - spped.setLat(GpsSpeedLast.getLat());//设置开始时纬度  
1087 - spped.setTimestamp(GpsSpeedLast.getTimestamp());//设置连续超速记录的开始时间  
1088 - spped.setTimestampDate(GpsSpeedLast.getTimestampDate());//设置连续超速记录的开始时间戳  
1089 - }  
1090 - spped.setEndtimestamp(GpsSpeedNow.getTimestamp());//设置结束时间戳  
1091 - spped.setEndtimestampDate(sdf.format(new Date(GpsSpeedNow.getTimestamp())));//设置结束时间  
1092 - spped.setEndlon(GpsSpeedNow.getLon());//设置结束时的经度  
1093 - spped.setEndlat(GpsSpeedNow.getLat());//设置结束时的纬度  
1094 - Flag = true;  
1095 - }else{  
1096 - if(Flag){//如果上一条记录超速。  
1097 - listResult.add(spped);  
1098 - Flag = false;  
1099 - }  
1100 - }  
1101 - }  
1102 - Iterator<GpsSpeed> speedIt = listResult.iterator();  
1103 - while(speedIt.hasNext()){  
1104 - GpsSpeed GpsSpeed = speedIt.next();  
1105 - if(GpsSpeed.getEndtimestamp()-GpsSpeed.getTimestamp()<=1000){  
1106 - speedIt.remove();  
1107 - }  
1108 - }  
1109 -  
1110 - totalData = listResult.size();//总记录条数。  
1111 - if(map.get("curPage") == null || map.get("curPage").equals("0")){  
1112 - curPage = 0;  
1113 - }else{  
1114 - curPage = Integer.parseInt((String) map.get("curPage"));  
1115 - }  
1116 - pageData = Integer.parseInt((String) map.get("pageData"));//每页的记录条数  
1117 - start = (curPage - 0) * pageData; //起始记录下标。  
1118 - totalPage = totalData % pageData == 0 ? totalData / pageData : totalData / pageData +1;//总页数  
1119 - if(curPage == totalPage-1){//如果当前页等于总页数。  
1120 - listResult = listResult.subList(start, totalData);  
1121 - }else{  
1122 - listResult = listResult.subList(start, start+pageData);  
1123 - }  
1124 - }else{  
1125 - curPage = 1;  
1126 - pageData = Integer.parseInt((String) map.get("pageData"));//每页的记录条数  
1127 - totalPage =1;  
1128 - }  
1129 - Map<String,Object> paramMap = new HashMap<String,Object>();  
1130 - paramMap.put("totalPage", totalPage);  
1131 - paramMap.put("curPage", curPage);  
1132 - paramMap.put("pageData", pageData);  
1133 - PageHelper pageHelper = new PageHelper(totalData, paramMap);  
1134 - pageHelper.getMap();  
1135 - PageObject<GpsSpeed> pageObject = pageHelper.getPageObject();  
1136 - pageObject.setDataList(listResult);  
1137 - return pageObject;  
1138 - }  
1139 -  
1140 - static List<GpsSpeed> findAll(Map<String, Object> map) {  
1141 - Connection conn = null;  
1142 - PreparedStatement ps = null;  
1143 - ResultSet rs = null;  
1144 - int page=Integer.parseInt(map.get("page").toString());  
1145 - List<GpsSpeed> list=new ArrayList<GpsSpeed>();  
1146 - String sql="select * from bsth_c_gps_info where 1=1 ";  
1147 - Object line=map.get("line");  
1148 - Object nbbm=map.get("nbbm");  
1149 - Object updown=map.get("updown");  
1150 - Object startDate=map.get("startDate");  
1151 - Object endDate=map.get("endDate");  
1152 -  
1153 - SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  
1154 - if(line!=null){  
1155 - sql +=" and line_id like'%"+line.toString().trim()+"%'";  
1156 - }  
1157 -  
1158 - if(nbbm!=null){  
1159 - nbbm=BasicData.deviceId2NbbmMap.inverse().get(nbbm);  
1160 - if(nbbm!=null)  
1161 - sql +=" and vehicle like '%"+nbbm.toString()+"%'";  
1162 - }  
1163 -  
1164 - if(updown!=null){  
1165 - sql +="and industry_code like '%"+updown.toString()+"%'";  
1166 - }  
1167 - if(startDate!=null){  
1168 - if (startDate.toString().length()>0) {  
1169 - try {  
1170 - Long t1=sdf.parse(startDate.toString()+" 00:00:00").getTime();  
1171 - sql += " and ts >="+t1;  
1172 - } catch (ParseException e) {  
1173 - e.printStackTrace();  
1174 - }  
1175 - }  
1176 -  
1177 - }  
1178 - if(endDate!=null){  
1179 - if (endDate.toString().length()>0) {  
1180 - try {  
1181 - Long t2=sdf.parse(endDate.toString()+" 23:59:59").getTime();  
1182 - sql += " and ts <="+t2;  
1183 - } catch (ParseException e) {  
1184 - e.printStackTrace();  
1185 - }  
1186 - }  
1187 -  
1188 - }  
1189 -  
1190 - try {  
1191 - conn = DBUtils_MS.getConnection();  
1192 - ps = conn.prepareStatement(sql);  
1193 - rs = ps.executeQuery();  
1194 - list = resultSet2Set(rs);  
1195 - } catch (SQLException e) {  
1196 - e.printStackTrace();  
1197 - }finally {  
1198 - DBUtils_MS.close(rs, ps, conn);  
1199 - }  
1200 -  
1201 - return list;  
1202 - }  
1203 -  
1204 - static List<GpsSpeed> resultSet2Set(ResultSet rs) throws SQLException{  
1205 - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  
1206 - List<GpsSpeed> list=new ArrayList<GpsSpeed>();  
1207 - GpsSpeed GpsSpeed;  
1208 - Float lon, lat;  
1209 - Location location;  
1210 - while(rs.next()){  
1211 - lon = rs.getFloat("lon");  
1212 - lat = rs.getFloat("lat"); 1052 +
  1053 + }
  1054 +
  1055 + @Override
  1056 + public PageObject<GpsSpeed> Pagequery(Map<String, Object> map) {
  1057 +
  1058 + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  1059 + List<GpsSpeed> list=findAll(map);
  1060 + List<GpsSpeed> listResult = new ArrayList<GpsSpeed>();
  1061 + int curPage;//页码
  1062 + int pageData;//每页的记录条数
  1063 + int start;//起始数据下标
  1064 + int totalPage;//总页数
  1065 + int totalData = 0;
  1066 + if(list.size()>1){
  1067 + GpsSpeed GpsSpeedNow;//下标为i的车辆行驶记录
  1068 + GpsSpeed GpsSpeedLast;//下标为i-1的车辆行驶记录
  1069 + GpsSpeed spped = null;//整合后的车辆行驶记录
  1070 + String strNow;
  1071 + String strLast;
  1072 + boolean Flag = false;//判断是否有连续超速记录,默认没有
  1073 + for(int i = 1;i<list.size();i++){
  1074 + GpsSpeedNow = list.get(i);
  1075 + GpsSpeedLast = list.get(i-1);
  1076 + strNow = GpsSpeedNow.getVehicle()+GpsSpeedNow.getLine()+GpsSpeedNow.getUp_down();
  1077 + strLast = GpsSpeedLast.getVehicle()+GpsSpeedLast.getLine()+GpsSpeedLast.getUp_down();
  1078 + if(GpsSpeedNow.getSpeed()>60 && GpsSpeedLast.getSpeed()>60 && strNow.equals(strLast)){//如果两条连续的记录都是超速且属于同一辆车。
  1079 + if(Flag==false){//
  1080 + spped = new GpsSpeed();
  1081 + spped.setLine(GpsSpeedLast.getLine());//设置连续超速记录线路
  1082 + spped.setLineName(GpsSpeedLast.getLineName());//设置连续超速记录线路名称
  1083 + spped.setVehicle(GpsSpeedLast.getVehicle());//设置连续超速记录的车辆编号
  1084 + spped.setUp_down(GpsSpeedLast.getUp_down());//设置上下行
  1085 + spped.setLon(GpsSpeedLast.getLon());//设置开始时经度
  1086 + spped.setLat(GpsSpeedLast.getLat());//设置开始时纬度
  1087 + spped.setTimestamp(GpsSpeedLast.getTimestamp());//设置连续超速记录的开始时间
  1088 + spped.setTimestampDate(GpsSpeedLast.getTimestampDate());//设置连续超速记录的开始时间戳
  1089 + }
  1090 + spped.setEndtimestamp(GpsSpeedNow.getTimestamp());//设置结束时间戳
  1091 + spped.setEndtimestampDate(sdf.format(new Date(GpsSpeedNow.getTimestamp())));//设置结束时间
  1092 + spped.setEndlon(GpsSpeedNow.getLon());//设置结束时的经度
  1093 + spped.setEndlat(GpsSpeedNow.getLat());//设置结束时的纬度
  1094 + Flag = true;
  1095 + }else{
  1096 + if(Flag){//如果上一条记录超速。
  1097 + listResult.add(spped);
  1098 + Flag = false;
  1099 + }
  1100 + }
  1101 + }
  1102 + Iterator<GpsSpeed> speedIt = listResult.iterator();
  1103 + while(speedIt.hasNext()){
  1104 + GpsSpeed GpsSpeed = speedIt.next();
  1105 + if(GpsSpeed.getEndtimestamp()-GpsSpeed.getTimestamp()<=1000){
  1106 + speedIt.remove();
  1107 + }
  1108 + }
  1109 +
  1110 + totalData = listResult.size();//总记录条数。
  1111 + if(map.get("curPage") == null || map.get("curPage").equals("0")){
  1112 + curPage = 0;
  1113 + }else{
  1114 + curPage = Integer.parseInt((String) map.get("curPage"));
  1115 + }
  1116 + pageData = Integer.parseInt((String) map.get("pageData"));//每页的记录条数
  1117 + start = (curPage - 0) * pageData; //起始记录下标。
  1118 + totalPage = totalData % pageData == 0 ? totalData / pageData : totalData / pageData +1;//总页数
  1119 + if(curPage == totalPage-1){//如果当前页等于总页数。
  1120 + listResult = listResult.subList(start, totalData);
  1121 + }else{
  1122 + listResult = listResult.subList(start, start+pageData);
  1123 + }
  1124 + }else{
  1125 + curPage = 1;
  1126 + pageData = Integer.parseInt((String) map.get("pageData"));//每页的记录条数
  1127 + totalPage =1;
  1128 + }
  1129 + Map<String,Object> paramMap = new HashMap<String,Object>();
  1130 + paramMap.put("totalPage", totalPage);
  1131 + paramMap.put("curPage", curPage);
  1132 + paramMap.put("pageData", pageData);
  1133 + PageHelper pageHelper = new PageHelper(totalData, paramMap);
  1134 + pageHelper.getMap();
  1135 + PageObject<GpsSpeed> pageObject = pageHelper.getPageObject();
  1136 + pageObject.setDataList(listResult);
  1137 + return pageObject;
  1138 + }
  1139 +
  1140 + static List<GpsSpeed> findAll(Map<String, Object> map) {
  1141 + Connection conn = null;
  1142 + PreparedStatement ps = null;
  1143 + ResultSet rs = null;
  1144 + int page=Integer.parseInt(map.get("page").toString());
  1145 + List<GpsSpeed> list=new ArrayList<GpsSpeed>();
  1146 + String sql="select * from bsth_c_gps_info where 1=1 ";
  1147 + Object line=map.get("line");
  1148 + Object nbbm=map.get("nbbm");
  1149 + Object updown=map.get("updown");
  1150 + Object startDate=map.get("startDate");
  1151 + Object endDate=map.get("endDate");
  1152 +
  1153 + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  1154 + if(line!=null){
  1155 + sql +=" and line_id like'%"+line.toString().trim()+"%'";
  1156 + }
  1157 +
  1158 + if(nbbm!=null){
  1159 + nbbm=BasicData.deviceId2NbbmMap.inverse().get(nbbm);
  1160 + if(nbbm!=null)
  1161 + sql +=" and vehicle like '%"+nbbm.toString()+"%'";
  1162 + }
  1163 +
  1164 + if(updown!=null){
  1165 + sql +="and industry_code like '%"+updown.toString()+"%'";
  1166 + }
  1167 + if(startDate!=null){
  1168 + if (startDate.toString().length()>0) {
  1169 + try {
  1170 + Long t1=sdf.parse(startDate.toString()+" 00:00:00").getTime();
  1171 + sql += " and ts >="+t1;
  1172 + } catch (ParseException e) {
  1173 + e.printStackTrace();
  1174 + }
  1175 + }
  1176 +
  1177 + }
  1178 + if(endDate!=null){
  1179 + if (endDate.toString().length()>0) {
  1180 + try {
  1181 + Long t2=sdf.parse(endDate.toString()+" 23:59:59").getTime();
  1182 + sql += " and ts <="+t2;
  1183 + } catch (ParseException e) {
  1184 + e.printStackTrace();
  1185 + }
  1186 + }
  1187 +
  1188 + }
  1189 +
  1190 + try {
  1191 + conn = DBUtils_MS.getConnection();
  1192 + ps = conn.prepareStatement(sql);
  1193 + rs = ps.executeQuery();
  1194 + list = resultSet2Set(rs);
  1195 + } catch (SQLException e) {
  1196 + e.printStackTrace();
  1197 + }finally {
  1198 + DBUtils_MS.close(rs, ps, conn);
  1199 + }
  1200 +
  1201 + return list;
  1202 + }
  1203 +
  1204 + static List<GpsSpeed> resultSet2Set(ResultSet rs) throws SQLException{
  1205 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  1206 + List<GpsSpeed> list=new ArrayList<GpsSpeed>();
  1207 + GpsSpeed GpsSpeed;
  1208 + Float lon, lat;
  1209 + Location location;
  1210 + while(rs.next()){
  1211 + lon = rs.getFloat("lon");
  1212 + lat = rs.getFloat("lat");
1213 location = TransGPS.LocationMake(lon, lat); 1213 location = TransGPS.LocationMake(lon, lat);
1214 location = TransGPS.bd_encrypt(TransGPS.transformFromWGSToGCJ(location)); 1214 location = TransGPS.bd_encrypt(TransGPS.transformFromWGSToGCJ(location));
1215 - GpsSpeed=new GpsSpeed();  
1216 - GpsSpeed.setLon((float)location.getLng());  
1217 - GpsSpeed.setLat((float)location.getLat());  
1218 - GpsSpeed.setLine(rs.getObject("line_id").toString());  
1219 - //run 时注解  
1220 - GpsSpeed.setLineName(BasicData.lineCode2NameMap.get(GpsSpeed.getLine().toString()));  
1221 - GpsSpeed.setSpeed(Float.valueOf(rs.getObject("speed_gps").toString()));  
1222 - GpsSpeed.setTimestamp((Long.valueOf(rs.getObject("ts").toString())));  
1223 - GpsSpeed.setTimestampDate(sdf.format(new Date(GpsSpeed.getTimestamp())));  
1224 - GpsSpeed.setUp_down(((Integer.valueOf(rs.getObject("service_state").toString())) & 0x10000000)==0?0:1);  
1225 - GpsSpeed.setVehicle(BasicData.deviceId2NbbmMap.get(rs.getObject("device_id").toString()));  
1226 - list.add(GpsSpeed);  
1227 - }  
1228 - return list;  
1229 - }  
1230 - 1215 + GpsSpeed=new GpsSpeed();
  1216 + GpsSpeed.setLon((float)location.getLng());
  1217 + GpsSpeed.setLat((float)location.getLat());
  1218 + GpsSpeed.setLine(rs.getObject("line_id").toString());
  1219 + //run 时注解
  1220 + GpsSpeed.setLineName(BasicData.lineCode2NameMap.get(GpsSpeed.getLine().toString()));
  1221 + GpsSpeed.setSpeed(Float.valueOf(rs.getObject("speed_gps").toString()));
  1222 + GpsSpeed.setTimestamp((Long.valueOf(rs.getObject("ts").toString())));
  1223 + GpsSpeed.setTimestampDate(sdf.format(new Date(GpsSpeed.getTimestamp())));
  1224 + GpsSpeed.setUp_down(((Integer.valueOf(rs.getObject("service_state").toString())) & 0x10000000)==0?0:1);
  1225 + GpsSpeed.setVehicle(BasicData.deviceId2NbbmMap.get(rs.getObject("device_id").toString()));
  1226 + list.add(GpsSpeed);
  1227 + }
  1228 + return list;
  1229 + }
  1230 +
1231 } 1231 }
1232 1232
src/main/resources/static/pages/control/lineallot/allot.html
@@ -324,6 +324,17 @@ @@ -324,6 +324,17 @@
324 } 324 }
325 325
326 showLoad('更新缓存信息...'); 326 showLoad('更新缓存信息...');
  327 + //清理一下localStorage
  328 + var rms=[];
  329 + for (var i=0, len = storage.length; i < len; i++){
  330 + var key = storage.key(i);
  331 + if(key=='car2DeviceId' || key.endsWith('_route'))
  332 + rms.push(key);
  333 + }
  334 + $.each(rms, function () {
  335 + storage.removeItem(this);
  336 + });
  337 +
327 //将选择的线路写入localstorage 338 //将选择的线路写入localstorage
328 var lsData = []; 339 var lsData = [];
329 $.each(lines, function (i, e) { 340 $.each(lines, function (i, e) {
@@ -337,9 +348,9 @@ @@ -337,9 +348,9 @@
337 348
338 var ep = new EventProxy(); 349 var ep = new EventProxy();
339 //缓存车辆自编号和设备号对照 350 //缓存车辆自编号和设备号对照
340 - cacheCar2DeviceId(function () { 351 + //cacheCar2DeviceId(function () {
341 delayEmit(ep, 'cacheRoute'); 352 delayEmit(ep, 'cacheRoute');
342 - }); 353 + //});
343 354
344 //缓存线路路由 355 //缓存线路路由
345 ep.tail('cacheRoute', function () { 356 ep.tail('cacheRoute', function () {
@@ -367,11 +378,8 @@ @@ -367,11 +378,8 @@
367 378
368 //进入线调 379 //进入线调
369 ep.tail('gotoControl', function () { 380 ep.tail('gotoControl', function () {
370 - //alert('进入线调');  
371 layer.closeAll(); 381 layer.closeAll();
372 - //loadPage('/pages/control/line/index.html');  
373 window.location.href = "/real_control/v2"; 382 window.location.href = "/real_control/v2";
374 - //window.open("/real_control/v2");  
375 }); 383 });
376 }); 384 });
377 385
@@ -411,13 +419,13 @@ @@ -411,13 +419,13 @@
411 })(); 419 })();
412 } 420 }
413 421
414 - function cacheCar2DeviceId(cb) { 422 +/* function cacheCar2DeviceId(cb) {
415 //showLoad('缓存基础对照信息...'); 423 //showLoad('缓存基础对照信息...');
416 $.get('/gps/Car2DeviceId', function (rs) { 424 $.get('/gps/Car2DeviceId', function (rs) {
417 storage.setItem('car2DeviceId', JSON.stringify(rs)); 425 storage.setItem('car2DeviceId', JSON.stringify(rs));
418 cb && cb(); 426 cb && cb();
419 }); 427 });
420 - } 428 + }*/
421 429
422 function cacheRoute(lsData, cb) { 430 function cacheRoute(lsData, cb) {
423 //showLoad('缓存线路路由信息...'); 431 //showLoad('缓存线路路由信息...');
src/main/resources/static/real_control_v2/css/main.css
@@ -1580,4 +1580,20 @@ ul.left_tabs_lg li{ @@ -1580,4 +1580,20 @@ ul.left_tabs_lg li{
1580 margin-left: 25px; 1580 margin-left: 25px;
1581 vertical-align: bottom; 1581 vertical-align: bottom;
1582 color: #929292; 1582 color: #929292;
1583 -}  
1584 \ No newline at end of file 1583 \ No newline at end of file
  1584 +}
  1585 +
  1586 +#all-devices-modal .search-form input{
  1587 + width: 160px;
  1588 +}
  1589 +
  1590 +#all-devices-modal .uk-margin-small-top {
  1591 + margin-top: 0 !important;
  1592 +}
  1593 +
  1594 +#history-sch-maintain-modal .add_lp_link{
  1595 + display: inline-block;
  1596 + vertical-align: bottom;
  1597 + margin-left: 15px;
  1598 + text-decoration: underline;
  1599 + font-size: 13px;
  1600 +}
src/main/resources/static/real_control_v2/fragments/north/nav/all_devices.html
@@ -33,6 +33,10 @@ @@ -33,6 +33,10 @@
33 <option value="0">转发</option> 33 <option value="0">转发</option>
34 </select> 34 </select>
35 </div> 35 </div>
  36 + <span class="horizontal-field">程序版本</span>
  37 + <div class="uk-autocomplete uk-form " >
  38 + <input type="text" name="version" placeholder="程序版本" style="width: 110px;">
  39 + </div>
36 <button class="uk-button">检索</button> 40 <button class="uk-button">检索</button>
37 </fieldset> 41 </fieldset>
38 </form> 42 </form>
@@ -46,7 +50,7 @@ @@ -46,7 +50,7 @@
46 <th style="width: 11%;">车辆</th> 50 <th style="width: 11%;">车辆</th>
47 <th style="width: 11%;">设备号</th> 51 <th style="width: 11%;">设备号</th>
48 <th style="width: 9%;">速度</th> 52 <th style="width: 9%;">速度</th>
49 - <th style="width: 9%;">上下行</th> 53 + <th style="width: 9%;">走向/营运</th>
50 <th style="width: 10%;">程序版本</th> 54 <th style="width: 10%;">程序版本</th>
51 <th>最后GPS时间</th> 55 <th>最后GPS时间</th>
52 <th style="width: 8%;">来源</th> 56 <th style="width: 8%;">来源</th>
@@ -69,7 +73,7 @@ @@ -69,7 +73,7 @@
69 <td>{{gps.nbbm}}</td> 73 <td>{{gps.nbbm}}</td>
70 <td>{{gps.deviceId}}</td> 74 <td>{{gps.deviceId}}</td>
71 <td>{{gps.speed}}</td> 75 <td>{{gps.speed}}</td>
72 - <td>{{gps.upDown}}</td> 76 + <td>{{gps.upDown}}/{{gps.state}}</td>
73 <td>{{gps.version}}</td> 77 <td>{{gps.version}}</td>
74 <td>{{gps.timeStr}}</td> 78 <td>{{gps.timeStr}}</td>
75 <td> 79 <td>
src/main/resources/static/real_control_v2/fragments/north/nav/history_sch/h_add_temp_sch.html
@@ -758,7 +758,7 @@ @@ -758,7 +758,7 @@
758 disabled_submit_btn(f); 758 disabled_submit_btn(f);
759 var data = $(f).serializeJSON(); 759 var data = $(f).serializeJSON();
760 submitScheduleForm(data, function (rs) { 760 submitScheduleForm(data, function (rs) {
761 - $('#history-sch-maintain-modal').trigger('refresh'); 761 + $('#history-sch-maintain-modal').trigger('refresh', {lpName: sch.lpName});
762 UIkit.modal(modal).hide(); 762 UIkit.modal(modal).hide();
763 }); 763 });
764 }); 764 });
src/main/resources/static/real_control_v2/fragments/north/nav/history_sch_maintain.html
@@ -36,6 +36,7 @@ @@ -36,6 +36,7 @@
36 <input type="text" name="jGh_like" placeholder="驾驶员"> 36 <input type="text" name="jGh_like" placeholder="驾驶员">
37 </div> 37 </div>
38 <button class="uk-button">检索</button> 38 <button class="uk-button">检索</button>
  39 + <a class="add_lp_link" ><i class="uk-icon-plus"></i> 临加路牌</a>
39 </fieldset> 40 </fieldset>
40 </form> 41 </form>
41 </div> 42 </div>
@@ -140,7 +141,13 @@ @@ -140,7 +141,13 @@
140 }); 141 });
141 }); 142 });
142 143
143 - $(modal).on('refresh', jsQuery); 144 + $(modal).on('refresh', function (e, data) {
  145 + var lpName = data.lpName;
  146 + if(is_new_temp_lp(lpName)){
  147 + $('[name=lpName_eq]', modal).append('<option value="'+lpName+'" selected>'+lpName+'</option>');
  148 + }
  149 + jsQuery();
  150 + });
144 151
145 $(modal).on('click', '.h-s-time li,.h-s-line li', function () { 152 $(modal).on('click', '.h-s-time li,.h-s-line li', function () {
146 if(loading) 153 if(loading)
@@ -167,7 +174,7 @@ @@ -167,7 +174,7 @@
167 var reLoadLp; 174 var reLoadLp;
168 var nbbmArray,jsyArray,lpArray,loading; 175 var nbbmArray,jsyArray,lpArray,loading;
169 var schArray;//主键映射 176 var schArray;//主键映射
170 - function jsQuery() { 177 + function jsQuery(cb) {
171 var data = $('.search-form', modal).serializeJSON(); 178 var data = $('.search-form', modal).serializeJSON();
172 var rq = $('.h-s-time li.uk-active', modal).text(), 179 var rq = $('.h-s-time li.uk-active', modal).text(),
173 lineCode = $('.h-s-line li.uk-active', modal).data('id'); 180 lineCode = $('.h-s-line li.uk-active', modal).data('id');
@@ -221,6 +228,8 @@ @@ -221,6 +228,8 @@
221 228
222 //更新滚动条高度 229 //更新滚动条高度
223 $('.history-sch-wrap', modal).perfectScrollbar('update'); 230 $('.history-sch-wrap', modal).perfectScrollbar('update');
  231 +
  232 + cb && cb();
224 }); 233 });
225 } 234 }
226 235
@@ -313,6 +322,11 @@ @@ -313,6 +322,11 @@
313 var str = '<h3>确定要删除临加班次<span style="color:red;margin: 0 5px;">' + sch.clZbh + '( ' + sch.dfsj + ' )</span>?</h3><h5 style="color: #6c6c6c;font-size: 12px;">班次删除后,调度指令会保留</h5>'; 322 var str = '<h3>确定要删除临加班次<span style="color:red;margin: 0 5px;">' + sch.clZbh + '( ' + sch.dfsj + ' )</span>?</h3><h5 style="color: #6c6c6c;font-size: 12px;">班次删除后,调度指令会保留</h5>';
314 alt_confirm(str, function () { 323 alt_confirm(str, function () {
315 gb_common.$del('/realSchedule/history/' + sch.id, function (rs) { 324 gb_common.$del('/realSchedule/history/' + sch.id, function (rs) {
  325 + if($('.history-sch-table .ct_table_body dl', modal).length == 1){
  326 + $('[name=lpName_eq]', modal).val('');
  327 + reLoadLp = true;
  328 + }
  329 +
316 jsQuery(); 330 jsQuery();
317 }); 331 });
318 }, '确定删除'); 332 }, '确定删除');
@@ -352,6 +366,51 @@ @@ -352,6 +366,51 @@
352 } 366 }
353 } 367 }
354 }); 368 });
  369 +
  370 + //临加路牌
  371 + $('.add_lp_link', modal).on('click', function () {
  372 + var index = 0, max;
  373 + $.each(lpArray, function (i, obj) {
  374 + var lp = obj.value;
  375 + if (lp.indexOf('临') != -1) {
  376 + max = lp.substr(lp.indexOf('临') + 1);
  377 + if (!isNaN(max))
  378 + index = parseInt(max);
  379 + }
  380 + });
  381 +
  382 + var lpName = '临' + (index + 1);
  383 + var rq = $('.h-s-time li.uk-active', modal).text(),
  384 + lineName = $('.h-s-line li.uk-active', modal).text(),
  385 + lineCode = $('.h-s-line li.uk-active', modal).data('id');
  386 +
  387 + var sch = {
  388 + scheduleDateStr: rq,
  389 + xlBm: lineCode,
  390 + xlName: lineName,
  391 + lpName: lpName
  392 + };
  393 +
  394 + open_modal(folder + '/h_add_temp_sch.html', {
  395 + sch: sch
  396 + }, modal_opts);
  397 + });
  398 +
  399 + /**
  400 + * 是否是临加路牌
  401 + * @param lpName
  402 + */
  403 + function is_new_temp_lp(lpName) {
  404 + if(lpName.indexOf('临') ==-1)
  405 + return false;
  406 +
  407 + for(var i=0,obj;obj=lpArray[i++];){
  408 + if(obj.value==lpName)
  409 + return false;
  410 + }
  411 +
  412 + return true;
  413 + }
355 })(); 414 })();
356 </script> 415 </script>
357 </div> 416 </div>
358 \ No newline at end of file 417 \ No newline at end of file