Commit 1a61f28ca3768195f32a4b1ca0e8101f29e788b6
1 parent
b49a7d13
优化到离站逻辑
Showing
17 changed files
with
307 additions
and
59 deletions
src/main/java/com/bsth/data/arrival/AnalyseData.java
src/main/java/com/bsth/data/arrival/ArrivalData_GPS.java
| ... | ... | @@ -51,7 +51,7 @@ public class ArrivalData_GPS implements CommandLineRunner{ |
| 51 | 51 | @Override |
| 52 | 52 | public void run(String... arg0) throws Exception { |
| 53 | 53 | logger.info("ArrivalData_GPS,30,10"); |
| 54 | - Application.mainServices.scheduleWithFixedDelay(dataLoaderThread, 30, 600, TimeUnit.SECONDS); | |
| 54 | + Application.mainServices.scheduleWithFixedDelay(dataLoaderThread, 40, 20, TimeUnit.SECONDS); | |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | @Component | ... | ... |
src/main/java/com/bsth/data/arrival/DataLoader.java
| ... | ... | @@ -58,7 +58,7 @@ public class DataLoader { |
| 58 | 58 | PreparedStatement ps = null; |
| 59 | 59 | ResultSet rs = null; |
| 60 | 60 | |
| 61 | - String sql = "select * from bsth_c_arrival_info where weeks_year=? AND create_timestamp > ? AND create_timestamp <=? AND ABS(create_timestamp - ts) < 3600000 order by ts"; | |
| 61 | + String sql = "select * from bsth_c_arrival_info where weeks_year=? AND create_timestamp > ? AND create_timestamp <=? AND ABS(create_timestamp - ts) < 3600000 order by create_date"; | |
| 62 | 62 | try{ |
| 63 | 63 | long t = System.currentTimeMillis(); |
| 64 | 64 | ... | ... |
src/main/java/com/bsth/data/directive/FirstScheduleCheckThread.java
| ... | ... | @@ -8,6 +8,8 @@ import org.slf4j.LoggerFactory; |
| 8 | 8 | import org.springframework.beans.factory.annotation.Autowired; |
| 9 | 9 | import org.springframework.stereotype.Component; |
| 10 | 10 | |
| 11 | +import com.bsth.data.match.Arrival2Schedule; | |
| 12 | +import com.bsth.data.match.ExpectArrivalEnd; | |
| 11 | 13 | import com.bsth.data.schedule.DayOfSchedule; |
| 12 | 14 | import com.bsth.entity.realcontrol.ScheduleRealInfo; |
| 13 | 15 | import com.bsth.service.directive.DirectiveService; |
| ... | ... | @@ -63,6 +65,26 @@ public class FirstScheduleCheckThread extends Thread{ |
| 63 | 65 | && Math.abs(first.getDfsjT() - t) < THREE_MINUTES){ |
| 64 | 66 | |
| 65 | 67 | directiveService.send60Dispatch(first, dayOfSchedule.doneSum(first.getClZbh()), "定补@系统"); |
| 68 | + //期望完成出场班次时间 | |
| 69 | + long endTime; | |
| 70 | + | |
| 71 | + if(first.getZdsj() != null) | |
| 72 | + endTime=first.getZdsjT() - 60000; | |
| 73 | + else | |
| 74 | + endTime=schList.get(1).getDfsjT() - 60000; | |
| 75 | + | |
| 76 | + ExpectArrivalEnd ead = new ExpectArrivalEnd() | |
| 77 | + ,ead2 = new ExpectArrivalEnd(); | |
| 78 | + ead.setNbbm(car); | |
| 79 | + ead.setEndStation(first.getQdzCode()); | |
| 80 | + ead.setEndTime(endTime); | |
| 81 | + | |
| 82 | + ead2.setNbbm(car); | |
| 83 | + ead2.setEndStation(first.getZdzCode()); | |
| 84 | + ead2.setEndTime(endTime); | |
| 85 | + | |
| 86 | + Arrival2Schedule.addExpect(car, ead); | |
| 87 | + Arrival2Schedule.addExpect(car, ead2); | |
| 66 | 88 | } |
| 67 | 89 | } |
| 68 | 90 | } | ... | ... |
src/main/java/com/bsth/data/directive/GatewayHttpUtils.java
| ... | ... | @@ -51,13 +51,13 @@ public class GatewayHttpUtils { |
| 51 | 51 | |
| 52 | 52 | post.setEntity(new StringEntity(jsonStr, "utf-8")); |
| 53 | 53 | |
| 54 | - CloseableHttpResponse response = httpClient.execute(post); | |
| 55 | - | |
| 56 | - JSONObject json = JSONObject.parseObject(EntityUtils.toString(response.getEntity())); | |
| 57 | - if(null != json && json.getInteger("errCode") == 0) | |
| 58 | - code = 0; | |
| 59 | - else | |
| 60 | - logger.error("和网关http通讯失败,rs: " + json); | |
| 54 | +// CloseableHttpResponse response = httpClient.execute(post); | |
| 55 | +// | |
| 56 | +// JSONObject json = JSONObject.parseObject(EntityUtils.toString(response.getEntity())); | |
| 57 | +// if(null != json && json.getInteger("errCode") == 0) | |
| 58 | +// code = 0; | |
| 59 | +// else | |
| 60 | +// logger.error("和网关http通讯失败,rs: " + json); | |
| 61 | 61 | }catch(Exception e){ |
| 62 | 62 | logger.error("", e); |
| 63 | 63 | }finally { | ... | ... |
src/main/java/com/bsth/data/match/Arrival2Schedule.java
| ... | ... | @@ -3,9 +3,7 @@ package com.bsth.data.match; |
| 3 | 3 | import java.text.SimpleDateFormat; |
| 4 | 4 | import java.util.ArrayList; |
| 5 | 5 | import java.util.Collections; |
| 6 | -import java.util.HashMap; | |
| 7 | 6 | import java.util.List; |
| 8 | -import java.util.Map; | |
| 9 | 7 | import java.util.Set; |
| 10 | 8 | |
| 11 | 9 | import org.slf4j.Logger; |
| ... | ... | @@ -15,14 +13,18 @@ import org.springframework.context.ApplicationContext; |
| 15 | 13 | import org.springframework.context.ApplicationContextAware; |
| 16 | 14 | import org.springframework.stereotype.Component; |
| 17 | 15 | |
| 16 | +import com.bsth.data.LineConfigData; | |
| 18 | 17 | import com.bsth.data.arrival.ArrivalComparator; |
| 19 | 18 | import com.bsth.data.arrival.ArrivalData_GPS; |
| 20 | 19 | import com.bsth.data.arrival.ArrivalEntity; |
| 21 | 20 | import com.bsth.data.schedule.DayOfSchedule; |
| 22 | 21 | import com.bsth.data.schedule.ScheduleComparator; |
| 22 | +import com.bsth.entity.realcontrol.LineConfig; | |
| 23 | 23 | import com.bsth.entity.realcontrol.ScheduleRealInfo; |
| 24 | 24 | import com.bsth.service.directive.DirectiveService; |
| 25 | 25 | import com.bsth.websocket.handler.SendUtils; |
| 26 | +import com.google.common.collect.ArrayListMultimap; | |
| 27 | +import com.google.common.collect.ListMultimap; | |
| 26 | 28 | |
| 27 | 29 | /** |
| 28 | 30 | * |
| ... | ... | @@ -38,13 +40,14 @@ public class Arrival2Schedule implements ApplicationContextAware { |
| 38 | 40 | private static DayOfSchedule dayOfSchedule; |
| 39 | 41 | private static SendUtils sendUtils; |
| 40 | 42 | private static DirectiveService directiveService; |
| 43 | + private static LineConfigData lineConfigData; | |
| 41 | 44 | private final static int ONE_MINUTE = 1000 * 60; |
| 42 | 45 | //定一个4小时的范围,基本能对正常班次进行容错。主要防止早上停车场GPS飘导致完成晚上的进场班次 |
| 43 | 46 | private final static int FOUR_HOURS = 1000 * 60 * 60 * 4; |
| 44 | 47 | |
| 45 | 48 | private static Logger logger = LoggerFactory.getLogger(Arrival2Schedule.class); |
| 46 | 49 | |
| 47 | - private static Map<String, ExpectArrivalEnd> expectMap = new HashMap<>(); | |
| 50 | + private static ArrayListMultimap<String, ExpectArrivalEnd> expectMap = ArrayListMultimap.create(); | |
| 48 | 51 | |
| 49 | 52 | /** |
| 50 | 53 | * |
| ... | ... | @@ -61,6 +64,8 @@ public class Arrival2Schedule implements ApplicationContextAware { |
| 61 | 64 | |
| 62 | 65 | public static class SchMatchThread extends Thread{ |
| 63 | 66 | String nbbm; |
| 67 | + LineConfig conf; | |
| 68 | + | |
| 64 | 69 | public SchMatchThread(String nbbm){ |
| 65 | 70 | this.nbbm = nbbm; |
| 66 | 71 | } |
| ... | ... | @@ -73,7 +78,6 @@ public class Arrival2Schedule implements ApplicationContextAware { |
| 73 | 78 | |
| 74 | 79 | @Override |
| 75 | 80 | public void run() { |
| 76 | - | |
| 77 | 81 | //班次列表 |
| 78 | 82 | List<ScheduleRealInfo> schList = dayOfSchedule.findByNbbm(nbbm); |
| 79 | 83 | //进出起终点数据 |
| ... | ... | @@ -82,6 +86,7 @@ public class Arrival2Schedule implements ApplicationContextAware { |
| 82 | 86 | if(schList.size() == 0 || arrList.size() == 0) |
| 83 | 87 | return; |
| 84 | 88 | |
| 89 | + conf = lineConfigData.get(schList.get(0).getXlBm()); | |
| 85 | 90 | //排序 |
| 86 | 91 | Collections.sort(schList, schComparator); |
| 87 | 92 | Collections.sort(arrList, arrComparator); |
| ... | ... | @@ -113,8 +118,8 @@ public class Arrival2Schedule implements ApplicationContextAware { |
| 113 | 118 | if(sch.isDestroy()) |
| 114 | 119 | continue; |
| 115 | 120 | |
| 116 | - //没有里程的不匹配 | |
| 117 | - if(sch.getBcsj() == null && sch.getJhlc() == null) | |
| 121 | + //线路配置出站既出场,并且没有里程的不匹配 | |
| 122 | + if(conf.getOutConfig()==2 && sch.getBcsj() == null && sch.getJhlc() == null) | |
| 118 | 123 | continue; |
| 119 | 124 | |
| 120 | 125 | list.add(sch); |
| ... | ... | @@ -194,7 +199,15 @@ public class Arrival2Schedule implements ApplicationContextAware { |
| 194 | 199 | mr = new MatchResult(); |
| 195 | 200 | mr.sch = sch; |
| 196 | 201 | mr.ts = inArr.getTs(); |
| 197 | - mr.diff = inArr.getTs() - sch.getZdsjT(); | |
| 202 | + //班次没有里程和运送时间的 | |
| 203 | + if(sch.getZdsj() == null){ | |
| 204 | + if(i < schList.size()-1) | |
| 205 | + mr.diff = inArr.getTs() - schList.get(i + 1).getDfsjT(); | |
| 206 | + else | |
| 207 | + mr.diff = inArr.getTs() - sch.getDfsjT(); | |
| 208 | + } | |
| 209 | + else | |
| 210 | + mr.diff = inArr.getTs() - sch.getZdsjT(); | |
| 198 | 211 | mr.success = dayOfSchedule.validEndTime(sch, inArr.getTs()); |
| 199 | 212 | if(Math.abs(mr.diff) < FOUR_HOURS && mr.success) |
| 200 | 213 | mrs.add(mr); |
| ... | ... | @@ -216,13 +229,8 @@ public class Arrival2Schedule implements ApplicationContextAware { |
| 216 | 229 | public void carOut(MatchResult mr){ |
| 217 | 230 | ScheduleRealInfo sch = mr.sch; |
| 218 | 231 | |
| 219 | - if(expectMap.containsKey(nbbm)){ | |
| 220 | - ExpectArrivalEnd ead = expectMap.get(nbbm); | |
| 221 | - if(mr.ts < ead.getEndTime()) | |
| 222 | - return; | |
| 223 | - else | |
| 224 | - expectMap.remove(nbbm); | |
| 225 | - } | |
| 232 | + if(!isExpectOut(mr)) | |
| 233 | + return; | |
| 226 | 234 | //设置发车时间 |
| 227 | 235 | sch.setFcsjActualAll(mr.ts); |
| 228 | 236 | //通知客户端 |
| ... | ... | @@ -231,8 +239,32 @@ public class Arrival2Schedule implements ApplicationContextAware { |
| 231 | 239 | dayOfSchedule.save(sch); |
| 232 | 240 | //车辆当前执行班次 |
| 233 | 241 | dayOfSchedule.addExecPlan(sch); |
| 242 | + | |
| 234 | 243 | //期望车辆到达的终点 |
| 235 | - expectMap.put(nbbm, ExpectArrivalEnd.getEndInstance(sch, mr.ts)); | |
| 244 | + if(sch.getZdsj() != null) | |
| 245 | + expectMap.put(nbbm, ExpectArrivalEnd.getEndInstance(sch, mr.ts)); | |
| 246 | + } | |
| 247 | + | |
| 248 | + /** | |
| 249 | + * | |
| 250 | + * @Title: isExpectOut | |
| 251 | + * @Description: TODO(是否是一个期望的出站匹配结果) | |
| 252 | + */ | |
| 253 | + private boolean isExpectOut(MatchResult mr){ | |
| 254 | + ScheduleRealInfo sch = mr.sch; | |
| 255 | + String nbbm = sch.getClZbh(); | |
| 256 | + if(expectMap.containsKey(nbbm)){ | |
| 257 | + List<ExpectArrivalEnd> eads = expectMap.get(nbbm); | |
| 258 | + for(ExpectArrivalEnd ead : eads){ | |
| 259 | + if(sch.getQdzCode().equals(ead.getEndStation()) | |
| 260 | + || mr.ts > ead.getEndTime()){ | |
| 261 | + expectMap.removeAll(nbbm); | |
| 262 | + return true; | |
| 263 | + } | |
| 264 | + } | |
| 265 | + return false; | |
| 266 | + } | |
| 267 | + return true; | |
| 236 | 268 | } |
| 237 | 269 | |
| 238 | 270 | /** |
| ... | ... | @@ -243,15 +275,8 @@ public class Arrival2Schedule implements ApplicationContextAware { |
| 243 | 275 | public void carInStop(MatchResult mr){ |
| 244 | 276 | ScheduleRealInfo sch = mr.sch; |
| 245 | 277 | String nbbm=sch.getClZbh(); |
| 246 | - if(expectMap.containsKey(nbbm)){ | |
| 247 | - ExpectArrivalEnd ead = expectMap.get(nbbm); | |
| 248 | - if(mr.ts < ead.getEndTime() | |
| 249 | - && !mr.sch.getZdzCode().equals(ead.getEndStation())){ | |
| 250 | - return; | |
| 251 | - } | |
| 252 | - else | |
| 253 | - expectMap.remove(nbbm); | |
| 254 | - } | |
| 278 | + if(!isExpectIn(mr)) | |
| 279 | + return; | |
| 255 | 280 | |
| 256 | 281 | //如果是进停车场,并且实达时间差值大于 30 分钟,并且之前还有未完成班次。 |
| 257 | 282 | if(sch.getBcType().equals("in") && Math.abs(mr.diff) > (1000 * 60 * 30)){ |
| ... | ... | @@ -289,6 +314,28 @@ public class Arrival2Schedule implements ApplicationContextAware { |
| 289 | 314 | |
| 290 | 315 | /** |
| 291 | 316 | * |
| 317 | + * @Title: isExpectOut | |
| 318 | + * @Description: TODO(是否是一个期望的进站匹配结果) | |
| 319 | + */ | |
| 320 | + private boolean isExpectIn(MatchResult mr){ | |
| 321 | + ScheduleRealInfo sch = mr.sch; | |
| 322 | + String nbbm = sch.getClZbh(); | |
| 323 | + if(expectMap.containsKey(nbbm)){ | |
| 324 | + List<ExpectArrivalEnd> eads = expectMap.get(nbbm); | |
| 325 | + for(ExpectArrivalEnd ead : eads){ | |
| 326 | + if(sch.getZdzCode().equals(ead.getEndStation()) | |
| 327 | + || mr.ts > ead.getEndTime()){ | |
| 328 | + expectMap.removeAll(nbbm); | |
| 329 | + return true; | |
| 330 | + } | |
| 331 | + } | |
| 332 | + return false; | |
| 333 | + } | |
| 334 | + return true; | |
| 335 | + } | |
| 336 | + | |
| 337 | + /** | |
| 338 | + * | |
| 292 | 339 | * @Title: correctFirstSignal |
| 293 | 340 | * @Description: TODO(检查并纠正首班出场到离站) |
| 294 | 341 | */ |
| ... | ... | @@ -367,6 +414,7 @@ public class Arrival2Schedule implements ApplicationContextAware { |
| 367 | 414 | sendUtils = arg0.getBean(SendUtils.class); |
| 368 | 415 | dayOfSchedule = arg0.getBean(DayOfSchedule.class); |
| 369 | 416 | directiveService = arg0.getBean(DirectiveService.class); |
| 417 | + lineConfigData = arg0.getBean(LineConfigData.class); | |
| 370 | 418 | } |
| 371 | 419 | |
| 372 | 420 | /** |
| ... | ... | @@ -376,6 +424,10 @@ public class Arrival2Schedule implements ApplicationContextAware { |
| 376 | 424 | * @param @param nbbm |
| 377 | 425 | */ |
| 378 | 426 | public void removeExpect(String nbbm){ |
| 379 | - expectMap.remove(nbbm); | |
| 427 | + expectMap.removeAll(nbbm); | |
| 428 | + } | |
| 429 | + | |
| 430 | + public static void addExpect(String nbbm, ExpectArrivalEnd eae){ | |
| 431 | + expectMap.put(nbbm, eae); | |
| 380 | 432 | } |
| 381 | 433 | } | ... | ... |
src/main/java/com/bsth/data/match/ExpectArrivalEnd.java
| ... | ... | @@ -5,7 +5,7 @@ import com.bsth.entity.realcontrol.ScheduleRealInfo; |
| 5 | 5 | /** |
| 6 | 6 | * |
| 7 | 7 | * @ClassName: ExpectArrivalEnd |
| 8 | - * @Description: TODO(期望车辆在某个时间段到达某个终点........) | |
| 8 | + * @Description: TODO(期望车辆在某个时间段到达某个终点或 发出某个起点........) | |
| 9 | 9 | * @author PanZhao |
| 10 | 10 | * @date 2016年11月2日 下午8:04:43 |
| 11 | 11 | * |
| ... | ... | @@ -29,6 +29,7 @@ public class ExpectArrivalEnd { |
| 29 | 29 | } |
| 30 | 30 | return ead; |
| 31 | 31 | } |
| 32 | + | |
| 32 | 33 | |
| 33 | 34 | public String getNbbm() { |
| 34 | 35 | return nbbm; | ... | ... |
src/main/java/com/bsth/websocket/handler/RealControlSocketHandler.java
| ... | ... | @@ -3,6 +3,7 @@ package com.bsth.websocket.handler; |
| 3 | 3 | import java.io.IOException; |
| 4 | 4 | import java.util.ArrayList; |
| 5 | 5 | import java.util.HashMap; |
| 6 | +import java.util.Iterator; | |
| 6 | 7 | import java.util.List; |
| 7 | 8 | import java.util.Map; |
| 8 | 9 | import java.util.Set; |
| ... | ... | @@ -83,7 +84,7 @@ public class RealControlSocketHandler implements WebSocketHandler { |
| 83 | 84 | default: |
| 84 | 85 | break; |
| 85 | 86 | } |
| 86 | - System.out.println(msg); | |
| 87 | + logger.info(msg.getPayload().toString()); | |
| 87 | 88 | } |
| 88 | 89 | |
| 89 | 90 | @Override |
| ... | ... | @@ -145,22 +146,23 @@ public class RealControlSocketHandler implements WebSocketHandler { |
| 145 | 146 | * @param message |
| 146 | 147 | */ |
| 147 | 148 | public synchronized void sendMessageToLine(String lineCode, String msg) { |
| 148 | - //Set<String> uids = BasicData.lineCode2SocketUserMap.get(lineCode); | |
| 149 | - //if(null == uids || uids.size() == 0) | |
| 150 | - // return; | |
| 151 | 149 | |
| 152 | 150 | TextMessage message = new TextMessage(msg.getBytes()); |
| 153 | 151 | |
| 154 | - List<WebSocketSession> sessList = listenMap.get(lineCode); | |
| 152 | + Iterator<WebSocketSession> iterator = listenMap.get(lineCode).iterator(); | |
| 155 | 153 | |
| 156 | - for (WebSocketSession user : sessList) { | |
| 154 | + WebSocketSession user; | |
| 155 | + while(iterator.hasNext()){ | |
| 156 | + user = iterator.next(); | |
| 157 | 157 | try { |
| 158 | 158 | if (user.isOpen()) { |
| 159 | 159 | user.sendMessage(message); |
| 160 | 160 | } |
| 161 | - } catch (IOException e) { | |
| 161 | + } catch (Exception e) { | |
| 162 | + logger.error("sendMessageToLine error ...."+msg); | |
| 162 | 163 | logger.error("sendMessageToLine error ....", e); |
| 163 | 164 | } |
| 165 | + | |
| 164 | 166 | } |
| 165 | 167 | } |
| 166 | 168 | } | ... | ... |
src/main/resources/static/assets/img/bg_9b9dcb65ff.png
src/main/resources/static/real_control_v2/css/line_schedule.css
| ... | ... | @@ -706,3 +706,26 @@ input.i-cbox[type=checkbox]{ |
| 706 | 706 | .sch-tzrc-table.ct_table>.ct_table_body dl.context-menu-active{ |
| 707 | 707 | background: #e6e6e6; |
| 708 | 708 | } |
| 709 | + | |
| 710 | +.search_sch_panel{ | |
| 711 | + float: right; | |
| 712 | +} | |
| 713 | + | |
| 714 | +.search_sch_panel .uk-form input[type=text]{ | |
| 715 | + width: 80px; | |
| 716 | + background: #fafafa; | |
| 717 | + border: 0; | |
| 718 | + border-bottom: 1px solid #ddd; | |
| 719 | + font-size: 14px; | |
| 720 | + height: 20px; | |
| 721 | + transition: all .3s ease; | |
| 722 | +} | |
| 723 | + | |
| 724 | +.search_sch_panel .uk-form input.active[type=text]{ | |
| 725 | + width: 130px; | |
| 726 | +} | |
| 727 | + | |
| 728 | +.search_sch_panel .uk-form input[type=text]::-webkit-input-placeholder{ | |
| 729 | + font-size: 12px; | |
| 730 | + color: #cecece; | |
| 731 | +} | ... | ... |
src/main/resources/static/real_control_v2/css/sch_autocomp_result.css
0 → 100644
| 1 | +.uk-autocomplete.sch-search-autocom .uk-dropdown { | |
| 2 | + width: 260px; | |
| 3 | + max-height: 500px; | |
| 4 | + overflow: auto; | |
| 5 | +} | |
| 6 | + | |
| 7 | +.sch-search-results>li { | |
| 8 | + position: relative; | |
| 9 | + /*line-height: 18px;*/ | |
| 10 | +} | |
| 11 | + | |
| 12 | +.sch-search-results>li.uk-active small { | |
| 13 | + color: #ebeaea; | |
| 14 | +} | |
| 15 | + | |
| 16 | +.sch-search-results small { | |
| 17 | + /*display: block;*/ | |
| 18 | + color: #9b9797; | |
| 19 | + margin-left: 9px; | |
| 20 | +} | |
| 21 | + | |
| 22 | +.sch-search-results small.search-result-desc { | |
| 23 | + white-space: nowrap; | |
| 24 | + overflow: hidden; | |
| 25 | + display: block; | |
| 26 | + text-overflow: ellipsis; | |
| 27 | + margin-left: 0; | |
| 28 | +} | |
| 29 | + | |
| 30 | + | |
| 31 | +/*.sch-search-results div.exec_sch_badge { | |
| 32 | + position: absolute; | |
| 33 | + top: 8px; | |
| 34 | + right: 3px; | |
| 35 | + background: #96f396; | |
| 36 | + text-indent: 0; | |
| 37 | + padding: 0 3px; | |
| 38 | + border-radius: 5px; | |
| 39 | + color: #7b5d5d; | |
| 40 | +}*/ | ... | ... |
src/main/resources/static/real_control_v2/fragments/line_schedule/sch_table.html
| ... | ... | @@ -7,6 +7,16 @@ |
| 7 | 7 | {{else}} |
| 8 | 8 | 下行/{{line.endStationName}} |
| 9 | 9 | {{/if}} |
| 10 | + <!-- <div class="search_sch_panel"> | |
| 11 | + <form class="uk-form"> | |
| 12 | + <div class="uk-autocomplete sch-search-autocom"> | |
| 13 | + <div class="uk-form-icon"> | |
| 14 | + <i class="uk-icon-search"></i> | |
| 15 | + <input type="text" placeholder="search"> | |
| 16 | + </div> | |
| 17 | + </div> | |
| 18 | + </form> | |
| 19 | + </div> --> | |
| 10 | 20 | </h3> |
| 11 | 21 | <div class="schedule-body"> |
| 12 | 22 | <div class="ct_table_wrap"> | ... | ... |
src/main/resources/static/real_control_v2/js/line_schedule/sch_table.js
| ... | ... | @@ -10,7 +10,7 @@ var gb_schedule_table = (function() { |
| 10 | 10 | return s1.dfsjT - s2.dfsjT; |
| 11 | 11 | } |
| 12 | 12 | |
| 13 | - var show = function() { | |
| 13 | + var show = function(cb) { | |
| 14 | 14 | //从服务器获取班次数据 |
| 15 | 15 | $.get('/realSchedule/lines', { |
| 16 | 16 | lines: gb_data_basic.line_idx |
| ... | ... | @@ -63,6 +63,8 @@ var gb_schedule_table = (function() { |
| 63 | 63 | gb_ct_table.enableSort($('.ct_table', content), reset_seq_no, gb_schedule_table_dbclick.init); |
| 64 | 64 | //dbclick event |
| 65 | 65 | gb_schedule_table_dbclick.init(); |
| 66 | + | |
| 67 | + cb&&cb(); | |
| 66 | 68 | }); |
| 67 | 69 | } |
| 68 | 70 | |
| ... | ... | @@ -189,15 +191,20 @@ var gb_schedule_table = (function() { |
| 189 | 191 | drag_strat = null; |
| 190 | 192 | }).on('mouseover', seq_nos, function() { |
| 191 | 193 | if (drag_strat) { |
| 192 | - var drag_end = parseInt($(this).text()), | |
| 194 | + var e = parseInt($(this).text()), | |
| 193 | 195 | dls = $(this).parents('.ct_table_body').find('dl'); |
| 194 | 196 | |
| 195 | 197 | reset_drag_active_all(this); |
| 196 | - if (drag_end - drag_strat <= 1) | |
| 197 | - return; | |
| 198 | - | |
| 199 | - for (var i = drag_strat; i < drag_end; i++) | |
| 200 | - $(dls[i]).addClass('drag-active'); | |
| 198 | + //向上选中 | |
| 199 | + if(e <= drag_strat){ | |
| 200 | + for (var i = drag_strat; i > e-2; i--) | |
| 201 | + $(dls[i]).addClass('drag-active'); | |
| 202 | + } | |
| 203 | + //向下选中 | |
| 204 | + else{ | |
| 205 | + for (var j = drag_strat; j < e; j++) | |
| 206 | + $(dls[j]).addClass('drag-active'); | |
| 207 | + } | |
| 201 | 208 | } |
| 202 | 209 | }).on('click', seq_nos, function() { |
| 203 | 210 | reset_relevance_active(this); |
| ... | ... | @@ -278,7 +285,7 @@ var gb_schedule_table = (function() { |
| 278 | 285 | //计算应发未发数量 |
| 279 | 286 | var calc_yfwf_num = function(lineCode){ |
| 280 | 287 | |
| 281 | - var schArr=line2Schedule[lineCode] | |
| 288 | + var schArr=gb_common.get_vals(line2Schedule[lineCode]).sort(schedule_sort) | |
| 282 | 289 | ,yfwf_num=0 |
| 283 | 290 | ,t = new Date().valueOf(); |
| 284 | 291 | ... | ... |
src/main/resources/static/real_control_v2/js/line_schedule/search.js
0 → 100644
| 1 | +/** 班次搜索 */ | |
| 2 | +var gb_sch_search = (function() { | |
| 3 | + | |
| 4 | + //搜索结果模板,和art-template冲突。 用字符串渲染 | |
| 5 | + var result_template = '<script type="text/autocomplete">' + | |
| 6 | + ' <ul class="uk-nav uk-nav-autocomplete uk-autocomplete-results sch-search-results">' + | |
| 7 | + ' {{~items}}' + | |
| 8 | + ' <li data-value="{{ $item.value }}">' + | |
| 9 | + ' <a>' + | |
| 10 | + ' {{ $item.value }}' + | |
| 11 | + ' <small >执行班次 07:00</small>' + | |
| 12 | + ' <small class="search-result-desc">{{{ $item.desc }}}</small>' + | |
| 13 | + ' </a>' + | |
| 14 | + ' </li>' + | |
| 15 | + ' {{/items}}' + | |
| 16 | + ' </ul>' + | |
| 17 | + '</script>'; | |
| 18 | + | |
| 19 | + var ips = '.search_sch_panel input', | |
| 20 | + _input, schArr, lineCode, group_cars; | |
| 21 | + $(document) | |
| 22 | + .on('focus', ips, function() { | |
| 23 | + $(this).addClass('active'); | |
| 24 | + lineCode = $(this).parents('li.line_schedule').data('id'); | |
| 25 | + schArr = gb_common.get_vals(gb_schedule_table.findScheduleByLine(lineCode)); | |
| 26 | + | |
| 27 | + group_cars = gb_common.groupBy(schArr, 'clZbh'); | |
| 28 | + _input = $(this); | |
| 29 | + }) | |
| 30 | + .on('blur', ips, function() { | |
| 31 | + if ($(this).val() == '') | |
| 32 | + $(this).removeClass('active'); | |
| 33 | + }); | |
| 34 | + | |
| 35 | + var elements = '.search_sch_panel .sch-search-autocom'; | |
| 36 | + var init = function() { | |
| 37 | + $(elements).each(function() { | |
| 38 | + $(this).append(result_template); | |
| 39 | + constructor(this); | |
| 40 | + }); | |
| 41 | + }; | |
| 42 | + | |
| 43 | + var constructor = function(e) { | |
| 44 | + UIkit.autocomplete(e, { | |
| 45 | + minLength: 1, | |
| 46 | + delay: 50, | |
| 47 | + source: autocomplete_source | |
| 48 | + }).on('selectitem.uk.autocomplete', selectitem); | |
| 49 | + } | |
| 50 | + | |
| 51 | + var autocomplete_source = function(release) { | |
| 52 | + var rs = [], | |
| 53 | + v = _input.val().toUpperCase(); | |
| 54 | + for (var car in group_cars) { | |
| 55 | + if (car.indexOf(v) != -1) | |
| 56 | + rs.push({ | |
| 57 | + value: car, | |
| 58 | + desc: '应发未发:0,已完成 8 个班次' | |
| 59 | + }); | |
| 60 | + } | |
| 61 | + | |
| 62 | + console.log(rs); | |
| 63 | + release && release(rs); | |
| 64 | + } | |
| 65 | + | |
| 66 | + var selectitem = function(event, data, acobject){ | |
| 67 | + var cont='li.line_schedule[data-id='+lineCode+']' | |
| 68 | + ,tbodys=$('.line-schedule-table .ct_table_body', cont); | |
| 69 | + | |
| 70 | + $('.sch-search-autocom input', cont).val(data.value).addClass('active'); | |
| 71 | + console.log(tbodys); | |
| 72 | + } | |
| 73 | + | |
| 74 | + return { | |
| 75 | + init: init | |
| 76 | + }; | |
| 77 | +})(); | ... | ... |
src/main/resources/static/real_control_v2/js/main.js
| ... | ... | @@ -35,7 +35,10 @@ var gb_main_ep = new EventProxy(), |
| 35 | 35 | |
| 36 | 36 | //render schedule table |
| 37 | 37 | eq.once('render-sch-table', function() { |
| 38 | - gb_schedule_table.show(); | |
| 38 | + gb_schedule_table.show(function(){ | |
| 39 | + //搜索框 | |
| 40 | + //gb_sch_search.init(); | |
| 41 | + }); | |
| 39 | 42 | |
| 40 | 43 | //嵌入地图页面 |
| 41 | 44 | $('li.map-panel','#main-tab-content').load('/real_control_v2/mapmonitor/real_monitor/real.html'); | ... | ... |
src/main/resources/static/real_control_v2/js/websocket/sch_websocket.js
| ... | ... | @@ -9,14 +9,7 @@ var gb_sch_websocket = (function() { |
| 9 | 9 | |
| 10 | 10 | schSock.onopen = function(e) { |
| 11 | 11 | console.log('webSocket[realcontrol] onopen'); |
| 12 | - setTimeout(function() { | |
| 13 | - //注册线路监听 | |
| 14 | - var data = { | |
| 15 | - operCode: 'register_line', | |
| 16 | - idx: gb_data_basic.line_idx | |
| 17 | - } | |
| 18 | - schSock.send(JSON.stringify(data)); | |
| 19 | - }, 500); | |
| 12 | + setTimeout(regListen, 500); | |
| 20 | 13 | }; |
| 21 | 14 | //接收消息 |
| 22 | 15 | schSock.onmessage = function(e) { |
| ... | ... | @@ -28,9 +21,22 @@ var gb_sch_websocket = (function() { |
| 28 | 21 | } |
| 29 | 22 | }; |
| 30 | 23 | |
| 24 | + function regListen (){ | |
| 25 | + //注册线路监听 | |
| 26 | + var data = { | |
| 27 | + operCode: 'register_line', | |
| 28 | + idx: gb_data_basic.line_idx | |
| 29 | + } | |
| 30 | + schSock.send(JSON.stringify(data)); | |
| 31 | + console.log('regListen....', data); | |
| 32 | + } | |
| 33 | + | |
| 31 | 34 | //断开 |
| 32 | 35 | schSock.onclose = function(e) { |
| 33 | 36 | alert('和服务器连接断开....'); |
| 37 | + console.log('和服务器连接断开....'); | |
| 38 | + regListen(); | |
| 39 | + | |
| 34 | 40 | }; |
| 35 | 41 | |
| 36 | 42 | //80协议上报 | ... | ... |
src/main/resources/static/real_control_v2/main.html
| ... | ... | @@ -18,6 +18,7 @@ |
| 18 | 18 | <link rel="stylesheet" href="/real_control_v2/css/home.css" /> |
| 19 | 19 | <!-- line style --> |
| 20 | 20 | <link rel="stylesheet" href="/real_control_v2/css/line_schedule.css" /> |
| 21 | + <link rel="stylesheet" href="/real_control_v2/css/sch_autocomp_result.css" /> | |
| 21 | 22 | <!-- custom table --> |
| 22 | 23 | <link rel="stylesheet" href="/real_control_v2/css/ct_table.css" /> |
| 23 | 24 | <!-- jquery contextMenu style --> |
| ... | ... | @@ -118,6 +119,7 @@ |
| 118 | 119 | <script src="/real_control_v2/js/line_schedule/sch_table.js"></script> |
| 119 | 120 | <script src="/real_control_v2/js/line_schedule/context_menu.js"></script> |
| 120 | 121 | <script src="/real_control_v2/js/line_schedule/dbclick.js"></script> |
| 122 | + <script src="/real_control_v2/js/line_schedule/search.js"></script> | |
| 121 | 123 | |
| 122 | 124 | <!-- 字典相关 --> |
| 123 | 125 | <script src="/assets/js/dictionary.js"></script> | ... | ... |