Commit 3ced2fc6fb8d0ffc16e3f7d9fd156ab94b269535
Merge branch 'pudong' of http://222.66.0.204:8090/panzhaov5/bsth_control into pudong
Showing
22 changed files
with
2060 additions
and
2080 deletions
Too many changes to show.
To preserve performance only 22 of 37 files are displayed.
src/main/java/com/bsth/XDApplication.java
| ... | ... | @@ -160,7 +160,7 @@ public class XDApplication implements CommandLineRunner { |
| 160 | 160 | |
| 161 | 161 | /** 线调业务 */ |
| 162 | 162 | sexec.scheduleWithFixedDelay(scheduleRefreshThread, 10, 120, TimeUnit.SECONDS);//班次更新线程 |
| 163 | - sexec.scheduleWithFixedDelay(scheduleLateThread, 140, 30, TimeUnit.SECONDS);//检查班次误点 | |
| 163 | + sexec.scheduleWithFixedDelay(scheduleLateThread, 140, 20, TimeUnit.SECONDS);//检查班次误点 | |
| 164 | 164 | sexec.scheduleWithFixedDelay(gpsDataLoader, 100, 2, TimeUnit.SECONDS);//抓取GPS数据 |
| 165 | 165 | sexec.scheduleWithFixedDelay(fixedCheckStationCodeThread, 60, 60 * 5, TimeUnit.SECONDS);//检查班次站点编码 |
| 166 | 166 | ... | ... |
src/main/java/com/bsth/controller/realcontrol/ServiceDataInterface.java
src/main/java/com/bsth/data/gpsdata_v2/handlers/InStationProcess.java
| ... | ... | @@ -146,8 +146,8 @@ public class InStationProcess { |
| 146 | 146 | dayOfSchedule.removeExecPlan(nbbm); |
| 147 | 147 | |
| 148 | 148 | //通知误点停靠程序,有车辆到站 |
| 149 | - //LateAdjustHandle.carArrive(gps, next); | |
| 150 | - LateAdjustHandle.carArrive(gps); | |
| 149 | + LateAdjustHandle.carArrive(gps, next); | |
| 150 | + //LateAdjustHandle.carArrive(gps); | |
| 151 | 151 | |
| 152 | 152 | //路牌的下一个班次,页面显示起点实际到达时间 |
| 153 | 153 | ScheduleRealInfo lpNext = dayOfSchedule.nextByLp(sch); | ... | ... |
src/main/java/com/bsth/data/schedule/late_adjust/LateAdjustHandle.java
| 1 | 1 | |
| 2 | 2 | package com.bsth.data.schedule.late_adjust; |
| 3 | 3 | |
| 4 | -import com.bsth.data.BasicData; | |
| 5 | 4 | import com.bsth.data.LineConfigData; |
| 6 | 5 | import com.bsth.data.gpsdata_v2.entity.GpsEntity; |
| 7 | 6 | import com.bsth.entity.realcontrol.LineConfig; |
| 8 | 7 | import com.bsth.entity.realcontrol.ScheduleRealInfo; |
| 9 | 8 | import com.bsth.util.Arith; |
| 10 | 9 | import com.bsth.websocket.handler.SendUtils; |
| 11 | -import com.google.common.collect.ArrayListMultimap; | |
| 12 | -import org.apache.commons.lang3.StringUtils; | |
| 13 | 10 | import org.slf4j.Logger; |
| 14 | 11 | import org.slf4j.LoggerFactory; |
| 15 | 12 | import org.springframework.beans.BeansException; |
| ... | ... | @@ -18,7 +15,8 @@ import org.springframework.context.ApplicationContextAware; |
| 18 | 15 | import org.springframework.stereotype.Component; |
| 19 | 16 | |
| 20 | 17 | import java.util.Collection; |
| 21 | -import java.util.List; | |
| 18 | +import java.util.concurrent.ConcurrentHashMap; | |
| 19 | +import java.util.concurrent.ConcurrentMap; | |
| 22 | 20 | |
| 23 | 21 | /** |
| 24 | 22 | * 误点自动调整待发 处理程序 |
| ... | ... | @@ -35,17 +33,11 @@ public class LateAdjustHandle implements ApplicationContextAware { |
| 35 | 33 | static Logger logger = LoggerFactory.getLogger(LateAdjustHandle.class); |
| 36 | 34 | |
| 37 | 35 | /** |
| 38 | - * 应发未到车辆 和 班次 | |
| 39 | - * <p> | |
| 40 | - * 起点相同的,保留最后一个班次 | |
| 36 | + * 应发未到的班次 key : id | |
| 41 | 37 | */ |
| 42 | - private static ArrayListMultimap lateSchMaps; | |
| 38 | + private static ConcurrentMap<Long, ScheduleRealInfo> lateSchMap = new ConcurrentHashMap<>(); | |
| 43 | 39 | |
| 44 | 40 | |
| 45 | - static { | |
| 46 | - lateSchMaps = ArrayListMultimap.create(); | |
| 47 | - } | |
| 48 | - | |
| 49 | 41 | /** |
| 50 | 42 | * 新增一个误点班次 |
| 51 | 43 | * |
| ... | ... | @@ -65,15 +57,14 @@ public class LateAdjustHandle implements ApplicationContextAware { |
| 65 | 57 | if (sch.getDfsj().compareTo(config.getYjtkStart()) > 0 |
| 66 | 58 | && sch.getDfsj().compareTo(config.getYjtkEnd()) <= 0) { |
| 67 | 59 | |
| 68 | - ScheduleRealInfo old = popLateSch(sch); | |
| 69 | - | |
| 70 | - //班次被压入 | |
| 71 | - if (lateSchMaps.containsEntry(sch.getClZbh(), sch)) { | |
| 60 | + //班次压入 | |
| 61 | + if (!lateSchMap.containsKey(sch.getId())) { | |
| 62 | + logger.info("29【应发未到 班次 " + sch.getClZbh() + " -" + sch.getDfsj() + " -id: " + sch.getId() + " -加入误点调整!"); | |
| 72 | 63 | |
| 73 | - logger.info("21【应发未到 -多个(" + lateSchMaps.get(sch.getClZbh()).size() + ")】班次 " + sch.getClZbh() + " -" + sch.getDfsj() + " -id: " + sch.getId() + " -加入误点调整!"); | |
| 74 | - //通知客户端 | |
| 75 | 64 | sch.setLate2(true); |
| 76 | - sendUtils.sendAutoWdtz(sch, old); | |
| 65 | + lateSchMap.put(sch.getId(), sch); | |
| 66 | + //通知客户端 | |
| 67 | + sendUtils.sendAutoWdtz(sch, null); | |
| 77 | 68 | } |
| 78 | 69 | } |
| 79 | 70 | |
| ... | ... | @@ -82,51 +73,6 @@ public class LateAdjustHandle implements ApplicationContextAware { |
| 82 | 73 | } |
| 83 | 74 | } |
| 84 | 75 | |
| 85 | - /** | |
| 86 | - * 压入新的误点班次 | |
| 87 | - * | |
| 88 | - * @param sch | |
| 89 | - * @return 返回被移除的误点班次 | |
| 90 | - */ | |
| 91 | - private static ScheduleRealInfo popLateSch(ScheduleRealInfo sch) { | |
| 92 | - List<ScheduleRealInfo> list = lateSchMaps.get(sch.getClZbh()); | |
| 93 | - | |
| 94 | - if (null == list || list.size() == 0) | |
| 95 | - lateSchMaps.put(sch.getClZbh(), sch); | |
| 96 | - else { | |
| 97 | - ScheduleRealInfo old = findExistQdz(list, sch.getQdzCode(), sch.getQdzName(), ""); | |
| 98 | - | |
| 99 | - if (null == old) | |
| 100 | - lateSchMaps.put(sch.getClZbh(), sch); | |
| 101 | - else if (old.getDfsjT() < sch.getDfsjT()) { | |
| 102 | - //同一个起点,保留时间最大的班次 | |
| 103 | - lateSchMaps.remove(old.getClZbh(), old); | |
| 104 | - lateSchMaps.put(sch.getClZbh(), sch); | |
| 105 | - | |
| 106 | - logger.info(sch.getClZbh() + "【应发未到】old 班次 " + old.getId() + " -被覆盖!"); | |
| 107 | - return old; | |
| 108 | - } | |
| 109 | - } | |
| 110 | - | |
| 111 | - return null; | |
| 112 | - } | |
| 113 | - | |
| 114 | - /** | |
| 115 | - * 搜索同样起点的班次 | |
| 116 | - * | |
| 117 | - * @param list | |
| 118 | - * @return | |
| 119 | - */ | |
| 120 | - private static ScheduleRealInfo findExistQdz(List<ScheduleRealInfo> list, String qdzCode, String nam1, String name2) { | |
| 121 | - for (ScheduleRealInfo item : list) { | |
| 122 | - if (item.getQdzCode().equals(qdzCode) | |
| 123 | - || item.getQdzName().equals(nam1) | |
| 124 | - || item.getQdzName().equals(name2)) | |
| 125 | - return item; | |
| 126 | - } | |
| 127 | - return null; | |
| 128 | - } | |
| 129 | - | |
| 130 | 76 | |
| 131 | 77 | /** |
| 132 | 78 | * 获取所有应发未到的班次 |
| ... | ... | @@ -134,13 +80,13 @@ public class LateAdjustHandle implements ApplicationContextAware { |
| 134 | 80 | * @return |
| 135 | 81 | */ |
| 136 | 82 | public static Collection<ScheduleRealInfo> allLateSch() { |
| 137 | - return lateSchMaps.values(); | |
| 83 | + return lateSchMap.values(); | |
| 138 | 84 | } |
| 139 | 85 | |
| 140 | 86 | public static void remove(ScheduleRealInfo sch) { |
| 141 | 87 | try { |
| 142 | - if (lateSchMaps.containsEntry(sch.getClZbh(), sch)) { | |
| 143 | - lateSchMaps.remove(sch.getClZbh(), sch); | |
| 88 | + if (lateSchMap.containsKey(sch.getId())) { | |
| 89 | + lateSchMap.remove(sch.getId()); | |
| 144 | 90 | |
| 145 | 91 | sch.setLate2(false); |
| 146 | 92 | sch.setLateMinute(0); |
| ... | ... | @@ -154,61 +100,47 @@ public class LateAdjustHandle implements ApplicationContextAware { |
| 154 | 100 | } |
| 155 | 101 | |
| 156 | 102 | /** |
| 157 | - * 车辆到站 | |
| 103 | + * 车辆到站 进站 进 的哪个班次,就调该车辆的下一个班次 | |
| 158 | 104 | * |
| 159 | 105 | * @param gps |
| 160 | 106 | */ |
| 161 | - public static void carArrive(GpsEntity gps) { | |
| 107 | + public static void carArrive(GpsEntity gps, ScheduleRealInfo sch) { | |
| 162 | 108 | try { |
| 163 | - if (gps.getInstation() <= 0) { | |
| 164 | - return; | |
| 165 | - } | |
| 166 | - | |
| 167 | - List<ScheduleRealInfo> list = lateSchMaps.get(gps.getNbbm()); | |
| 168 | - | |
| 169 | - if (null == list || list.size() == 0) | |
| 109 | + if (gps.getInstation() <= 0 || null == sch) | |
| 170 | 110 | return; |
| 171 | 111 | |
| 112 | + if (!lateSchMap.containsKey(sch.getId())) { | |
| 113 | + //班次是否误点(可能处于误点线程扫描的空隙,所以再判定一次) | |
| 114 | + if (sch.getDfsjT() <= gps.getTimestamp()) { | |
| 115 | + putLate(sch); | |
| 172 | 116 | |
| 173 | - String key = gps.getLineId() + "_" + gps.getUpDown() + "_" + gps.getStopNo(), name1 = BasicData.stationCode2NameMap.get(key)//站点名称 | |
| 174 | - , name2 = null; | |
| 175 | - if (StringUtils.isNotEmpty(gps.getCarparkNo())) { | |
| 176 | - name2 = BasicData.stationCode2NameMap.get(gps.getCarparkNo()); | |
| 177 | - } | |
| 117 | + if (!lateSchMap.containsKey(sch.getId())) | |
| 118 | + return; | |
| 178 | 119 | |
| 179 | - if (gps.getInstation() == 2) { | |
| 180 | - name1 = name2;//进场,没有站 | |
| 120 | + logger.info("线程空隙漏掉的误点,id: " + sch.getId()); | |
| 121 | + } else | |
| 122 | + return; | |
| 181 | 123 | } |
| 182 | 124 | |
| 183 | - gps.setStationName(name1); | |
| 184 | - //根据起点站获取误点班次 | |
| 185 | - ScheduleRealInfo sch = findExistQdz(list, gps.getStopNo(), name1, name2); | |
| 186 | - | |
| 187 | - if (null == sch) | |
| 188 | - return; | |
| 189 | 125 | |
| 190 | 126 | //可能是延迟信号,gps时间没有误点 |
| 191 | 127 | if (gps.getTimestamp() <= sch.getDfsjT()) { |
| 192 | 128 | sch.setLate2(false); |
| 193 | - lateSchMaps.remove(sch.getClZbh(), sch); | |
| 129 | + lateSchMap.remove(sch.getId()); | |
| 194 | 130 | return; |
| 195 | 131 | } |
| 196 | 132 | |
| 197 | - if (gps.getStationName().equals(sch.getQdzName()) | |
| 198 | - || gps.getStopNo().equals(sch.getQdzCode()) | |
| 199 | - || sch.getQdzName().equals(name2)) { | |
| 200 | 133 | |
| 201 | - //自动调整待发 到达时间 + 停靠时间 | |
| 202 | - long dt = Arith.addLong(gps.getTimestamp(), (sch.getLateMinute() * 60 * 1000)); | |
| 134 | + //自动调整待发 到达时间 + 停靠时间 | |
| 135 | + long dt = Arith.addLong(gps.getTimestamp(), (sch.getLateMinute() * 60 * 1000)); | |
| 203 | 136 | |
| 204 | - sch.setDfsjAll(dt); | |
| 205 | - sch.setDfAuto(true); | |
| 206 | - //取消应发未到标记 | |
| 207 | - sch.setLate2(false); | |
| 137 | + sch.setDfsjAll(dt); | |
| 138 | + sch.setDfAuto(true); | |
| 139 | + //取消应发未到标记 | |
| 140 | + sch.setLate2(false); | |
| 208 | 141 | |
| 209 | - lateSchMaps.remove(sch.getClZbh(), sch); | |
| 210 | - logger.info("【应发未到】车辆到站 " + sch.getClZbh() + " -" + sch.getDfsj() + " -到站时间:" + gps.getTimestamp() + " -停靠时间:" + sch.getLateMinute() + " -自动设置的待发时间:" + dt); | |
| 211 | - } | |
| 142 | + lateSchMap.remove(sch.getId()); | |
| 143 | + logger.info("【应发未到】车辆到站 " + sch.getClZbh() + " -" + sch.getDfsj() + " -到站时间:" + gps.getTimestamp() + " -停靠时间:" + sch.getLateMinute() + " -自动设置的待发时间:" + dt + " -id:" + sch.getId()); | |
| 212 | 144 | } catch (Exception e) { |
| 213 | 145 | e.printStackTrace(); |
| 214 | 146 | logger.error("late2 car arrive", e); |
| ... | ... | @@ -216,47 +148,6 @@ public class LateAdjustHandle implements ApplicationContextAware { |
| 216 | 148 | } |
| 217 | 149 | |
| 218 | 150 | |
| 219 | - /** | |
| 220 | - * 车辆到站, 进站 进 的哪个班次,就调该车辆的下一个班次 | |
| 221 | - * | |
| 222 | - * @param gps | |
| 223 | - * @param sch public static void carArrive(GpsEntity gps, ScheduleRealInfo sch) { | |
| 224 | - * try { | |
| 225 | - * if (gps.getInstation() <= 0 || null == sch) { | |
| 226 | - * return; | |
| 227 | - * } | |
| 228 | - * <p> | |
| 229 | - * List<ScheduleRealInfo> list = lateSchMaps.get(gps.getNbbm()); | |
| 230 | - * <p> | |
| 231 | - * if (null == list || list.size() == 0 || !list.contains(sch)) { | |
| 232 | - * return; | |
| 233 | - * } | |
| 234 | - * <p> | |
| 235 | - * //可能是延迟信号,gps时间没有误点 | |
| 236 | - * if (gps.getTimestamp() <= sch.getDfsjT()) { | |
| 237 | - * sch.setLate2(false); | |
| 238 | - * lateSchMaps.remove(sch.getClZbh(), sch); | |
| 239 | - * return; | |
| 240 | - * } | |
| 241 | - * <p> | |
| 242 | - * <p> | |
| 243 | - * //自动调整待发 到达时间 + 停靠时间 | |
| 244 | - * long dt = Arith.addLong(gps.getTimestamp(), (sch.getLateMinute() * 60 * 1000)); | |
| 245 | - * <p> | |
| 246 | - * sch.setDfsjAll(dt); | |
| 247 | - * sch.setDfAuto(true); | |
| 248 | - * //取消应发未到标记 | |
| 249 | - * sch.setLate2(false); | |
| 250 | - * <p> | |
| 251 | - * lateSchMaps.remove(sch.getClZbh(), sch); | |
| 252 | - * logger.info("【应发未到】车辆到站 " + sch.getClZbh() + " -" + sch.getDfsj() + " -到站时间:" + gps.getTimestamp() + " -停靠时间:" + sch.getLateMinute() + " -自动设置的待发时间:" + dt); | |
| 253 | - * } catch (Exception e) { | |
| 254 | - * e.printStackTrace(); | |
| 255 | - * logger.error("late2 car arrive", e); | |
| 256 | - * } | |
| 257 | - * } | |
| 258 | - */ | |
| 259 | - | |
| 260 | 151 | @Override |
| 261 | 152 | public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { |
| 262 | 153 | lineConfigData = applicationContext.getBean(LineConfigData.class); | ... | ... |
src/main/java/com/bsth/repository/realcontrol/ScheduleRealInfoRepository.java
| ... | ... | @@ -105,7 +105,7 @@ public interface ScheduleRealInfoRepository extends BaseRepository<ScheduleRealI |
| 105 | 105 | // List<ScheduleRealInfo> queryListWaybill3(String jName,String clZbh,String date,String gsbm,String fgsbm); |
| 106 | 106 | |
| 107 | 107 | @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) |
| 108 | - @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm = ?1 and s.scheduleDateStr = ?2 order by s.xlBm,s.clZbh,s.jGh,s.adjustExps,s.fcsj") | |
| 108 | + @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm = ?1 and s.scheduleDateStr = ?2 order by s.xlBm,s.clZbh,s.jGh,s.realExecDate,s.fcsj") | |
| 109 | 109 | List<ScheduleRealInfo> scheduleByDateAndLineTjrb(String line,String date); |
| 110 | 110 | |
| 111 | 111 | @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) |
| ... | ... | @@ -170,7 +170,7 @@ public interface ScheduleRealInfoRepository extends BaseRepository<ScheduleRealI |
| 170 | 170 | List<ScheduleRealInfo> scheduleByDateAndLineQp2(String line,String date); |
| 171 | 171 | |
| 172 | 172 | @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) |
| 173 | - @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm = ?1 and s.scheduleDateStr = ?2 and s.bcType not in ('in','out','ldks') order by s.xlBm,s.adjustExps,s.fcsj") | |
| 173 | + @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm = ?1 and s.scheduleDateStr = ?2 and s.bcType not in ('in','out','ldks') order by s.xlBm,s.realExecDate,s.fcsj") | |
| 174 | 174 | List<ScheduleRealInfo> scheduleByDateAndLine2(String line,String date); |
| 175 | 175 | |
| 176 | 176 | //按月统计 | ... | ... |
src/main/java/com/bsth/service/gps/GpsServiceImpl.java
| ... | ... | @@ -150,9 +150,9 @@ public class GpsServiceImpl implements GpsService { |
| 150 | 150 | * @return -1无效 0上行 1下行 |
| 151 | 151 | */ |
| 152 | 152 | public static byte getUpOrDown(long serviceState) { |
| 153 | - if ((serviceState & 0x00020000) == 0x00020000 || (serviceState & 0x80000000) == 0x80000000 | |
| 153 | + /*if ((serviceState & 0x00020000) == 0x00020000 || (serviceState & 0x80000000) == 0x80000000 | |
| 154 | 154 | || (serviceState & 0x01000000) == 0x01000000 || (serviceState & 0x08000000) == 0x08000000) |
| 155 | - return -1; | |
| 155 | + return -1;*/ | |
| 156 | 156 | return (byte) (((serviceState & 0x10000000) == 0x10000000) ? 1 : 0); |
| 157 | 157 | } |
| 158 | 158 | |
| ... | ... | @@ -162,8 +162,8 @@ public class GpsServiceImpl implements GpsService { |
| 162 | 162 | * @return -1无效 0运营 1未运营 |
| 163 | 163 | */ |
| 164 | 164 | public static byte getService(long serviceState) { |
| 165 | - if ((serviceState & 0x00020000) == 0x00020000 || (serviceState & 0x80000000) == 0x80000000) | |
| 166 | - return -1; | |
| 165 | + /*if ((serviceState & 0x00020000) == 0x00020000 || (serviceState & 0x80000000) == 0x80000000) | |
| 166 | + return -1;*/ | |
| 167 | 167 | return (byte) (((serviceState & 0x02000000) == 0x02000000) ? 1 : 0); |
| 168 | 168 | } |
| 169 | 169 | |
| ... | ... | @@ -743,11 +743,12 @@ public class GpsServiceImpl implements GpsService { |
| 743 | 743 | row.setHeight((short) (1.5 * 256)); |
| 744 | 744 | row.createCell(0).setCellValue("序号"); |
| 745 | 745 | row.createCell(1).setCellValue("车辆"); |
| 746 | - row.createCell(2).setCellValue("所在道路"); | |
| 747 | - row.createCell(3).setCellValue("经度"); | |
| 748 | - row.createCell(4).setCellValue("纬度"); | |
| 749 | - row.createCell(5).setCellValue("时间"); | |
| 750 | - row.createCell(6).setCellValue("速度"); | |
| 746 | + row.createCell(2).setCellValue("牌照号"); | |
| 747 | + row.createCell(3).setCellValue("所在道路"); | |
| 748 | + row.createCell(4).setCellValue("经度"); | |
| 749 | + row.createCell(5).setCellValue("纬度"); | |
| 750 | + row.createCell(6).setCellValue("时间"); | |
| 751 | + row.createCell(7).setCellValue("速度"); | |
| 751 | 752 | //数据 |
| 752 | 753 | DateTimeFormatter fmtHHmmss = DateTimeFormat.forPattern("HH:mm.ss"), |
| 753 | 754 | fmt = DateTimeFormat.forPattern("yyyyMMddHHmm"); |
| ... | ... | @@ -756,12 +757,13 @@ public class GpsServiceImpl implements GpsService { |
| 756 | 757 | gps = list.get(i); |
| 757 | 758 | row = sheet.createRow(i + 1); |
| 758 | 759 | row.createCell(0).setCellValue(i + 1); |
| 759 | - row.createCell(1).setCellValue(gps.getNbbm()); | |
| 760 | - row.createCell(2).setCellValue(gps.getSection_name()); | |
| 761 | - row.createCell(3).setCellValue(gps.getLon()); | |
| 762 | - row.createCell(4).setCellValue(gps.getLat()); | |
| 763 | - row.createCell(5).setCellValue(fmtHHmmss.print(gps.getTimestamp())); | |
| 764 | - row.createCell(6).setCellValue(gps.getSpeed()); | |
| 760 | + row.createCell(1).setCellValue(nbbm); | |
| 761 | + row.createCell(2).setCellValue(BasicData.nbbmCompanyPlateMap.get(nbbm)); | |
| 762 | + row.createCell(3).setCellValue(gps.getSection_name()); | |
| 763 | + row.createCell(4).setCellValue(gps.getLon()); | |
| 764 | + row.createCell(5).setCellValue(gps.getLat()); | |
| 765 | + row.createCell(6).setCellValue(fmtHHmmss.print(gps.getTimestamp())); | |
| 766 | + row.createCell(7).setCellValue(gps.getSpeed()); | |
| 765 | 767 | } |
| 766 | 768 | |
| 767 | 769 | st = st * 1000; | ... | ... |
src/main/java/com/bsth/service/impl/BusIntervalServiceImpl.java
| ... | ... | @@ -2604,7 +2604,7 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 2604 | 2604 | Map.put("xlName", s.getXlName()); |
| 2605 | 2605 | Map.put("clZbh", s.getClZbh()); |
| 2606 | 2606 | Map.put("plate", BasicData.nbbmCompanyPlateMap.get(s.getClZbh())); |
| 2607 | - Map.put("fcsjActual", s.getFcsjActual()); | |
| 2607 | + Map.put("fcsjActual", s.getFcsjActual()==null?"":s.getFcsjActual()); | |
| 2608 | 2608 | Map.put("zdzName", s.getZdzName()); |
| 2609 | 2609 | Map.put("scheduleDate", s.getScheduleDateStr()); |
| 2610 | 2610 | Map.put("lpName", s.getLpName()); | ... | ... |
src/main/java/com/bsth/service/impl/StationRouteServiceImpl.java
| ... | ... | @@ -743,6 +743,7 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ |
| 743 | 743 | try { |
| 744 | 744 | // 获取线路ID |
| 745 | 745 | Integer lineId = map.get("lineId").equals("") ? 0 : Integer.parseInt(map.get("lineId").toString()); |
| 746 | + Integer fileVersions = map.get("fileVersions").equals("") ? 2 : Integer.parseInt(map.get("fileVersions").toString());// 没有输入就默认2 | |
| 746 | 747 | /** 查询线路信息 @param:<lineId:线路ID> */ |
| 747 | 748 | Line line = lineRepository.findOne(lineId); |
| 748 | 749 | /** 查询线路信息下的站点路由信息 @param:<lineId:线路ID> */ |
| ... | ... | @@ -778,7 +779,7 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ |
| 778 | 779 | textStr = newTextFileToFTP(objects,lineId);/** 双向行单文件内容 @param:<objects:站点路由;lineId:线路ID>*/ |
| 779 | 780 | else |
| 780 | 781 | resultMap.put("status","NOLinePlayType");// 线路无线路规划类型 |
| 781 | - textStr = line.getName() + " " + "2" + "\r" + textStr; | |
| 782 | + textStr = line.getName() + " " + fileVersions + "\r" + textStr; | |
| 782 | 783 | InputStream input = new ByteArrayInputStream(textStr.getBytes("gbk")); |
| 783 | 784 | /** 生成txt文件,上传ftp */ |
| 784 | 785 | clientUtils.uploadFile(url, port, username, password, remotePath, textFileName, input); | ... | ... |
src/main/java/com/bsth/service/schedule/datatools/TTinfoDetailDynamicData.java
| 1 | -package com.bsth.service.schedule.datatools; | |
| 2 | - | |
| 3 | -import com.bsth.service.schedule.exception.ScheduleException; | |
| 4 | -import com.bsth.service.schedule.utils.DataToolsFile; | |
| 5 | -import com.bsth.service.schedule.utils.DataToolsFileType; | |
| 6 | -import com.fasterxml.jackson.annotation.JsonCreator; | |
| 7 | -import com.fasterxml.jackson.annotation.JsonValue; | |
| 8 | - | |
| 9 | -import java.util.List; | |
| 10 | - | |
| 11 | -/** | |
| 12 | - * 动态时刻表数据。 | |
| 13 | - */ | |
| 14 | -public interface TTinfoDetailDynamicData { | |
| 15 | - | |
| 16 | - //---------------------- 生成时刻表用对象(以下) ---------------------// | |
| 17 | - enum BcType { // 班次类型枚举 | |
| 18 | - IN("in"), // 进场 | |
| 19 | - OUT("out"), // 出场 | |
| 20 | - BD("bd"), // 早例保 | |
| 21 | - LC("lc"), // 晚例保 | |
| 22 | - NORMAL("normal"); // 正常 | |
| 23 | - private String flag; | |
| 24 | - | |
| 25 | - @JsonCreator | |
| 26 | - private BcType(String flag) { | |
| 27 | - this.flag = flag; | |
| 28 | - } | |
| 29 | - | |
| 30 | - @JsonValue | |
| 31 | - public String getFlag() { | |
| 32 | - return flag; | |
| 33 | - } | |
| 34 | - | |
| 35 | - public void setFlag(String flag) { | |
| 36 | - this.flag = flag; | |
| 37 | - } | |
| 38 | - } | |
| 39 | - | |
| 40 | - class BcObj { // 班次对象 | |
| 41 | - /** 班次时间 */ | |
| 42 | - private Integer bcsj; | |
| 43 | - /** 停站时间 */ | |
| 44 | - private Integer ssj; | |
| 45 | - /** 吃饭时间 */ | |
| 46 | - private Integer eatsj; | |
| 47 | - | |
| 48 | - /** 停车场id */ | |
| 49 | - private Integer tccid; | |
| 50 | - /** 起点站id */ | |
| 51 | - private Integer qdzid; | |
| 52 | - /** 终点站id */ | |
| 53 | - private Integer zdzid; | |
| 54 | - | |
| 55 | - /** 是否上行 */ | |
| 56 | - private Boolean isUp; | |
| 57 | - | |
| 58 | - /** 是否分班 */ | |
| 59 | - private Boolean isFb; | |
| 60 | - | |
| 61 | - /** 班次类型 */ | |
| 62 | - private BcType bcType; | |
| 63 | - /** 发车时刻 */ | |
| 64 | - private String fcsj; | |
| 65 | - /** 用于统计的发车时间描述(把进出场,保养,吃饭时间写在一起) */ | |
| 66 | - private String fcsjDesc; | |
| 67 | - | |
| 68 | - /** 第几圈(从1开始) */ | |
| 69 | - private Integer groupNo; | |
| 70 | - /** 圈里第几个班次(1或者2) */ | |
| 71 | - private Integer groupBcNo; | |
| 72 | - | |
| 73 | - public Integer getBcsj() { | |
| 74 | - return bcsj; | |
| 75 | - } | |
| 76 | - | |
| 77 | - public void setBcsj(Integer bcsj) { | |
| 78 | - this.bcsj = bcsj; | |
| 79 | - } | |
| 80 | - | |
| 81 | - public Integer getSsj() { | |
| 82 | - return ssj; | |
| 83 | - } | |
| 84 | - | |
| 85 | - public void setSsj(Integer ssj) { | |
| 86 | - this.ssj = ssj; | |
| 87 | - } | |
| 88 | - | |
| 89 | - public Integer getEatsj() { | |
| 90 | - return eatsj; | |
| 91 | - } | |
| 92 | - | |
| 93 | - public void setEatsj(Integer eatsj) { | |
| 94 | - this.eatsj = eatsj; | |
| 95 | - } | |
| 96 | - | |
| 97 | - public Integer getTccid() { | |
| 98 | - return tccid; | |
| 99 | - } | |
| 100 | - | |
| 101 | - public void setTccid(Integer tccid) { | |
| 102 | - this.tccid = tccid; | |
| 103 | - } | |
| 104 | - | |
| 105 | - public Integer getQdzid() { | |
| 106 | - return qdzid; | |
| 107 | - } | |
| 108 | - | |
| 109 | - public void setQdzid(Integer qdzid) { | |
| 110 | - this.qdzid = qdzid; | |
| 111 | - } | |
| 112 | - | |
| 113 | - public Integer getZdzid() { | |
| 114 | - return zdzid; | |
| 115 | - } | |
| 116 | - | |
| 117 | - public void setZdzid(Integer zdzid) { | |
| 118 | - this.zdzid = zdzid; | |
| 119 | - } | |
| 120 | - | |
| 121 | - public BcType getBcType() { | |
| 122 | - return bcType; | |
| 123 | - } | |
| 124 | - | |
| 125 | - public void setBcType(BcType bcType) { | |
| 126 | - this.bcType = bcType; | |
| 127 | - } | |
| 128 | - | |
| 129 | - public String getFcsj() { | |
| 130 | - return fcsj; | |
| 131 | - } | |
| 132 | - | |
| 133 | - public void setFcsj(String fcsj) { | |
| 134 | - this.fcsj = fcsj; | |
| 135 | - } | |
| 136 | - | |
| 137 | - public Boolean getIsUp() { | |
| 138 | - return isUp; | |
| 139 | - } | |
| 140 | - | |
| 141 | - public void setIsUp(Boolean isUp) { | |
| 142 | - this.isUp = isUp; | |
| 143 | - } | |
| 144 | - | |
| 145 | - public Integer getGroupNo() { | |
| 146 | - return groupNo; | |
| 147 | - } | |
| 148 | - | |
| 149 | - public void setGroupNo(Integer groupNo) { | |
| 150 | - this.groupNo = groupNo; | |
| 151 | - } | |
| 152 | - | |
| 153 | - public Integer getGroupBcNo() { | |
| 154 | - return groupBcNo; | |
| 155 | - } | |
| 156 | - | |
| 157 | - public void setGroupBcNo(Integer groupBcNo) { | |
| 158 | - this.groupBcNo = groupBcNo; | |
| 159 | - } | |
| 160 | - | |
| 161 | - public String getFcsjDesc() { | |
| 162 | - return fcsjDesc; | |
| 163 | - } | |
| 164 | - | |
| 165 | - public void setFcsjDesc(String fcsjDesc) { | |
| 166 | - this.fcsjDesc = fcsjDesc; | |
| 167 | - } | |
| 168 | - | |
| 169 | - public Boolean getIsFb() { | |
| 170 | - return isFb; | |
| 171 | - } | |
| 172 | - | |
| 173 | - public void setIsFb(Boolean fb) { | |
| 174 | - isFb = fb; | |
| 175 | - } | |
| 176 | - } | |
| 177 | - | |
| 178 | - class LpObj { // 路牌对象 | |
| 179 | - /** 路牌名字 */ | |
| 180 | - private String lpname; | |
| 181 | - /** 每圈的第一个班次是否上行 */ | |
| 182 | - private Boolean isUp; | |
| 183 | - | |
| 184 | - /** 第一个班次起点站路由id */ | |
| 185 | - private Integer stationRouteId1; | |
| 186 | - /** 第二个班次起点站路由id */ | |
| 187 | - private Integer stationRouteId2; | |
| 188 | - | |
| 189 | - /** 班次列表 */ | |
| 190 | - private List<BcObj> bcObjList; | |
| 191 | - /** 总圈数 */ | |
| 192 | - private Integer groupCount; | |
| 193 | - | |
| 194 | - //---------------- 路牌统计 ---------------// | |
| 195 | - /** 总里程 */ | |
| 196 | - private Double zlc; | |
| 197 | - /** 营运里程 */ | |
| 198 | - private Double yylc; | |
| 199 | - /** 空驶里程 */ | |
| 200 | - private Double kslc; | |
| 201 | - /** 总工时 */ | |
| 202 | - private Double zgs; | |
| 203 | - /** 总班次 */ | |
| 204 | - private Integer zbc; | |
| 205 | - /** 营运工时 */ | |
| 206 | - private Double yygs; | |
| 207 | - /** 营运班次 */ | |
| 208 | - private Integer yybc; | |
| 209 | - | |
| 210 | - public String getLpname() { | |
| 211 | - return lpname; | |
| 212 | - } | |
| 213 | - | |
| 214 | - public void setLpname(String lpname) { | |
| 215 | - this.lpname = lpname; | |
| 216 | - } | |
| 217 | - | |
| 218 | - public Boolean getIsUp() { | |
| 219 | - return isUp; | |
| 220 | - } | |
| 221 | - | |
| 222 | - public void setIsUp(Boolean isUp) { | |
| 223 | - this.isUp = isUp; | |
| 224 | - } | |
| 225 | - | |
| 226 | - public List<BcObj> getBcObjList() { | |
| 227 | - return bcObjList; | |
| 228 | - } | |
| 229 | - | |
| 230 | - public void setBcObjList(List<BcObj> bcObjList) { | |
| 231 | - this.bcObjList = bcObjList; | |
| 232 | - } | |
| 233 | - | |
| 234 | - public Integer getGroupCount() { | |
| 235 | - return groupCount; | |
| 236 | - } | |
| 237 | - | |
| 238 | - public void setGroupCount(Integer groupCount) { | |
| 239 | - this.groupCount = groupCount; | |
| 240 | - } | |
| 241 | - | |
| 242 | - public Integer getStationRouteId1() { | |
| 243 | - return stationRouteId1; | |
| 244 | - } | |
| 245 | - | |
| 246 | - public void setStationRouteId1(Integer stationRouteId1) { | |
| 247 | - this.stationRouteId1 = stationRouteId1; | |
| 248 | - } | |
| 249 | - | |
| 250 | - public Integer getStationRouteId2() { | |
| 251 | - return stationRouteId2; | |
| 252 | - } | |
| 253 | - | |
| 254 | - public void setStationRouteId2(Integer stationRouteId2) { | |
| 255 | - this.stationRouteId2 = stationRouteId2; | |
| 256 | - } | |
| 257 | - | |
| 258 | - public Boolean getUp() { | |
| 259 | - return isUp; | |
| 260 | - } | |
| 261 | - | |
| 262 | - public void setUp(Boolean up) { | |
| 263 | - isUp = up; | |
| 264 | - } | |
| 265 | - | |
| 266 | - public Double getZlc() { | |
| 267 | - return zlc; | |
| 268 | - } | |
| 269 | - | |
| 270 | - public void setZlc(Double zlc) { | |
| 271 | - this.zlc = zlc; | |
| 272 | - } | |
| 273 | - | |
| 274 | - public Double getYylc() { | |
| 275 | - return yylc; | |
| 276 | - } | |
| 277 | - | |
| 278 | - public void setYylc(Double yylc) { | |
| 279 | - this.yylc = yylc; | |
| 280 | - } | |
| 281 | - | |
| 282 | - public Double getKslc() { | |
| 283 | - return kslc; | |
| 284 | - } | |
| 285 | - | |
| 286 | - public void setKslc(Double kslc) { | |
| 287 | - this.kslc = kslc; | |
| 288 | - } | |
| 289 | - | |
| 290 | - public Double getZgs() { | |
| 291 | - return zgs; | |
| 292 | - } | |
| 293 | - | |
| 294 | - public void setZgs(Double zgs) { | |
| 295 | - this.zgs = zgs; | |
| 296 | - } | |
| 297 | - | |
| 298 | - public Integer getZbc() { | |
| 299 | - return zbc; | |
| 300 | - } | |
| 301 | - | |
| 302 | - public void setZbc(Integer zbc) { | |
| 303 | - this.zbc = zbc; | |
| 304 | - } | |
| 305 | - | |
| 306 | - public Double getYygs() { | |
| 307 | - return yygs; | |
| 308 | - } | |
| 309 | - | |
| 310 | - public void setYygs(Double yygs) { | |
| 311 | - this.yygs = yygs; | |
| 312 | - } | |
| 313 | - | |
| 314 | - public Integer getYybc() { | |
| 315 | - return yybc; | |
| 316 | - } | |
| 317 | - | |
| 318 | - public void setYybc(Integer yybc) { | |
| 319 | - this.yybc = yybc; | |
| 320 | - } | |
| 321 | - | |
| 322 | - } | |
| 323 | - | |
| 324 | - class StatInfo { // 统计数据对象 | |
| 325 | - /** 统计项目 */ | |
| 326 | - private String statItem; | |
| 327 | - /** 统计值 */ | |
| 328 | - private Double statValue; | |
| 329 | - | |
| 330 | - public String getStatItem() { | |
| 331 | - return statItem; | |
| 332 | - } | |
| 333 | - | |
| 334 | - public void setStatItem(String statItem) { | |
| 335 | - this.statItem = statItem; | |
| 336 | - } | |
| 337 | - | |
| 338 | - public Double getStatValue() { | |
| 339 | - return statValue; | |
| 340 | - } | |
| 341 | - | |
| 342 | - public void setStatValue(Double statValue) { | |
| 343 | - this.statValue = statValue; | |
| 344 | - } | |
| 345 | - } | |
| 346 | - | |
| 347 | - class ParameterInfo { // 生成参数对象 | |
| 348 | - /** 参数项目名称 */ | |
| 349 | - private String paramItem; | |
| 350 | - /** 参数项目值 */ | |
| 351 | - private String paramValue; | |
| 352 | - | |
| 353 | - public String getParamItem() { | |
| 354 | - return paramItem; | |
| 355 | - } | |
| 356 | - | |
| 357 | - public void setParamItem(String paramItem) { | |
| 358 | - this.paramItem = paramItem; | |
| 359 | - } | |
| 360 | - | |
| 361 | - public String getParamValue() { | |
| 362 | - return paramValue; | |
| 363 | - } | |
| 364 | - | |
| 365 | - public void setParamValue(String paramValue) { | |
| 366 | - this.paramValue = paramValue; | |
| 367 | - } | |
| 368 | - } | |
| 369 | - | |
| 370 | - class DTInfos { // 所有数据信息 | |
| 371 | - /** 路牌班次数据列表 */ | |
| 372 | - private List<LpObj> lpObjList; | |
| 373 | - /** 统计数据列表 */ | |
| 374 | - private List<StatInfo> statInfoList; | |
| 375 | - /** 参数对象信息 */ | |
| 376 | - private List<ParameterInfo> parameterInfoList; | |
| 377 | - | |
| 378 | - public List<LpObj> getLpObjList() { | |
| 379 | - return lpObjList; | |
| 380 | - } | |
| 381 | - | |
| 382 | - public void setLpObjList(List<LpObj> lpObjList) { | |
| 383 | - this.lpObjList = lpObjList; | |
| 384 | - } | |
| 385 | - | |
| 386 | - public List<StatInfo> getStatInfoList() { | |
| 387 | - return statInfoList; | |
| 388 | - } | |
| 389 | - | |
| 390 | - public void setStatInfoList(List<StatInfo> statInfoList) { | |
| 391 | - this.statInfoList = statInfoList; | |
| 392 | - } | |
| 393 | - | |
| 394 | - public List<ParameterInfo> getParameterInfoList() { | |
| 395 | - return parameterInfoList; | |
| 396 | - } | |
| 397 | - | |
| 398 | - public void setParameterInfoList(List<ParameterInfo> parameterInfoList) { | |
| 399 | - this.parameterInfoList = parameterInfoList; | |
| 400 | - } | |
| 401 | - } | |
| 402 | - | |
| 403 | - //---------------------- 生成时刻表用对象(以上) ---------------------// | |
| 404 | - | |
| 405 | - /** | |
| 406 | - * 导出动态时刻表数据。 | |
| 407 | - * @param dtInfos | |
| 408 | - * @return | |
| 409 | - * @throws ScheduleException | |
| 410 | - */ | |
| 411 | - DataToolsFile exportDynamicTTinfo(DTInfos dtInfos, DataToolsFileType type) throws ScheduleException; | |
| 412 | -} | |
| 1 | +package com.bsth.service.schedule.datatools; | |
| 2 | + | |
| 3 | +import com.bsth.service.schedule.exception.ScheduleException; | |
| 4 | +import com.bsth.service.schedule.utils.DataToolsFile; | |
| 5 | +import com.bsth.service.schedule.utils.DataToolsFileType; | |
| 6 | +import com.fasterxml.jackson.annotation.JsonCreator; | |
| 7 | +import com.fasterxml.jackson.annotation.JsonValue; | |
| 8 | + | |
| 9 | +import java.util.List; | |
| 10 | + | |
| 11 | +/** | |
| 12 | + * 动态时刻表数据。 | |
| 13 | + */ | |
| 14 | +public interface TTinfoDetailDynamicData { | |
| 15 | + | |
| 16 | + //---------------------- 生成时刻表用对象(以下) ---------------------// | |
| 17 | + enum BcType { // 班次类型枚举 | |
| 18 | + IN("in"), // 进场 | |
| 19 | + OUT("out"), // 出场 | |
| 20 | + BD("bd"), // 早例保 | |
| 21 | + LC("lc"), // 晚例保 | |
| 22 | + NORMAL("normal"); // 正常 | |
| 23 | + private String flag; | |
| 24 | + | |
| 25 | + @JsonCreator | |
| 26 | + private BcType(String flag) { | |
| 27 | + this.flag = flag; | |
| 28 | + } | |
| 29 | + | |
| 30 | + @JsonValue | |
| 31 | + public String getFlag() { | |
| 32 | + return flag; | |
| 33 | + } | |
| 34 | + | |
| 35 | + public void setFlag(String flag) { | |
| 36 | + this.flag = flag; | |
| 37 | + } | |
| 38 | + } | |
| 39 | + | |
| 40 | + class BcObj { // 班次对象 | |
| 41 | + /** 班次时间 */ | |
| 42 | + private Integer bcsj; | |
| 43 | + /** 停站时间 */ | |
| 44 | + private Integer ssj; | |
| 45 | + /** 吃饭时间 */ | |
| 46 | + private Integer eatsj; | |
| 47 | + | |
| 48 | + /** 停车场id */ | |
| 49 | + private Integer tccid; | |
| 50 | + /** 起点站id */ | |
| 51 | + private Integer qdzid; | |
| 52 | + /** 终点站id */ | |
| 53 | + private Integer zdzid; | |
| 54 | + | |
| 55 | + /** 是否上行 */ | |
| 56 | + private Boolean isUp; | |
| 57 | + | |
| 58 | + /** 是否分班 */ | |
| 59 | + private Boolean isFb; | |
| 60 | + | |
| 61 | + /** 班次类型 */ | |
| 62 | + private BcType bcType; | |
| 63 | + /** 发车时刻 */ | |
| 64 | + private String fcsj; | |
| 65 | + /** 用于统计的发车时间描述(把进出场,保养,吃饭时间写在一起) */ | |
| 66 | + private String fcsjDesc; | |
| 67 | + | |
| 68 | + /** 第几圈(从1开始) */ | |
| 69 | + private Integer groupNo; | |
| 70 | + /** 圈里第几个班次(1或者2) */ | |
| 71 | + private Integer groupBcNo; | |
| 72 | + | |
| 73 | + public Integer getBcsj() { | |
| 74 | + return bcsj; | |
| 75 | + } | |
| 76 | + | |
| 77 | + public void setBcsj(Integer bcsj) { | |
| 78 | + this.bcsj = bcsj; | |
| 79 | + } | |
| 80 | + | |
| 81 | + public Integer getSsj() { | |
| 82 | + return ssj; | |
| 83 | + } | |
| 84 | + | |
| 85 | + public void setSsj(Integer ssj) { | |
| 86 | + this.ssj = ssj; | |
| 87 | + } | |
| 88 | + | |
| 89 | + public Integer getEatsj() { | |
| 90 | + return eatsj; | |
| 91 | + } | |
| 92 | + | |
| 93 | + public void setEatsj(Integer eatsj) { | |
| 94 | + this.eatsj = eatsj; | |
| 95 | + } | |
| 96 | + | |
| 97 | + public Integer getTccid() { | |
| 98 | + return tccid; | |
| 99 | + } | |
| 100 | + | |
| 101 | + public void setTccid(Integer tccid) { | |
| 102 | + this.tccid = tccid; | |
| 103 | + } | |
| 104 | + | |
| 105 | + public Integer getQdzid() { | |
| 106 | + return qdzid; | |
| 107 | + } | |
| 108 | + | |
| 109 | + public void setQdzid(Integer qdzid) { | |
| 110 | + this.qdzid = qdzid; | |
| 111 | + } | |
| 112 | + | |
| 113 | + public Integer getZdzid() { | |
| 114 | + return zdzid; | |
| 115 | + } | |
| 116 | + | |
| 117 | + public void setZdzid(Integer zdzid) { | |
| 118 | + this.zdzid = zdzid; | |
| 119 | + } | |
| 120 | + | |
| 121 | + public BcType getBcType() { | |
| 122 | + return bcType; | |
| 123 | + } | |
| 124 | + | |
| 125 | + public void setBcType(BcType bcType) { | |
| 126 | + this.bcType = bcType; | |
| 127 | + } | |
| 128 | + | |
| 129 | + public String getFcsj() { | |
| 130 | + return fcsj; | |
| 131 | + } | |
| 132 | + | |
| 133 | + public void setFcsj(String fcsj) { | |
| 134 | + this.fcsj = fcsj; | |
| 135 | + } | |
| 136 | + | |
| 137 | + public Boolean getIsUp() { | |
| 138 | + return isUp; | |
| 139 | + } | |
| 140 | + | |
| 141 | + public void setIsUp(Boolean isUp) { | |
| 142 | + this.isUp = isUp; | |
| 143 | + } | |
| 144 | + | |
| 145 | + public Integer getGroupNo() { | |
| 146 | + return groupNo; | |
| 147 | + } | |
| 148 | + | |
| 149 | + public void setGroupNo(Integer groupNo) { | |
| 150 | + this.groupNo = groupNo; | |
| 151 | + } | |
| 152 | + | |
| 153 | + public Integer getGroupBcNo() { | |
| 154 | + return groupBcNo; | |
| 155 | + } | |
| 156 | + | |
| 157 | + public void setGroupBcNo(Integer groupBcNo) { | |
| 158 | + this.groupBcNo = groupBcNo; | |
| 159 | + } | |
| 160 | + | |
| 161 | + public String getFcsjDesc() { | |
| 162 | + return fcsjDesc; | |
| 163 | + } | |
| 164 | + | |
| 165 | + public void setFcsjDesc(String fcsjDesc) { | |
| 166 | + this.fcsjDesc = fcsjDesc; | |
| 167 | + } | |
| 168 | + | |
| 169 | + public Boolean getIsFb() { | |
| 170 | + return isFb; | |
| 171 | + } | |
| 172 | + | |
| 173 | + public void setIsFb(Boolean fb) { | |
| 174 | + isFb = fb; | |
| 175 | + } | |
| 176 | + } | |
| 177 | + | |
| 178 | + class LpObj { // 路牌对象 | |
| 179 | + /** 路牌名字 */ | |
| 180 | + private String lpname; | |
| 181 | + /** 每圈的第一个班次是否上行 */ | |
| 182 | + private Boolean isUp; | |
| 183 | + | |
| 184 | + /** 第一个班次起点站路由id */ | |
| 185 | + private Integer stationRouteId1; | |
| 186 | + /** 第二个班次起点站路由id */ | |
| 187 | + private Integer stationRouteId2; | |
| 188 | + | |
| 189 | + /** 班次列表 */ | |
| 190 | + private List<BcObj> bcObjList; | |
| 191 | + /** 总圈数 */ | |
| 192 | + private Integer groupCount; | |
| 193 | + | |
| 194 | + //---------------- 路牌统计 ---------------// | |
| 195 | + /** 总里程 */ | |
| 196 | + private Double zlc; | |
| 197 | + /** 营运里程 */ | |
| 198 | + private Double yylc; | |
| 199 | + /** 空驶里程 */ | |
| 200 | + private Double kslc; | |
| 201 | + /** 总工时 */ | |
| 202 | + private Double zgs; | |
| 203 | + /** 总班次 */ | |
| 204 | + private Integer zbc; | |
| 205 | + /** 营运工时 */ | |
| 206 | + private Double yygs; | |
| 207 | + /** 营运班次 */ | |
| 208 | + private Integer yybc; | |
| 209 | + | |
| 210 | + public String getLpname() { | |
| 211 | + return lpname; | |
| 212 | + } | |
| 213 | + | |
| 214 | + public void setLpname(String lpname) { | |
| 215 | + this.lpname = lpname; | |
| 216 | + } | |
| 217 | + | |
| 218 | + public Boolean getIsUp() { | |
| 219 | + return isUp; | |
| 220 | + } | |
| 221 | + | |
| 222 | + public void setIsUp(Boolean isUp) { | |
| 223 | + this.isUp = isUp; | |
| 224 | + } | |
| 225 | + | |
| 226 | + public List<BcObj> getBcObjList() { | |
| 227 | + return bcObjList; | |
| 228 | + } | |
| 229 | + | |
| 230 | + public void setBcObjList(List<BcObj> bcObjList) { | |
| 231 | + this.bcObjList = bcObjList; | |
| 232 | + } | |
| 233 | + | |
| 234 | + public Integer getGroupCount() { | |
| 235 | + return groupCount; | |
| 236 | + } | |
| 237 | + | |
| 238 | + public void setGroupCount(Integer groupCount) { | |
| 239 | + this.groupCount = groupCount; | |
| 240 | + } | |
| 241 | + | |
| 242 | + public Integer getStationRouteId1() { | |
| 243 | + return stationRouteId1; | |
| 244 | + } | |
| 245 | + | |
| 246 | + public void setStationRouteId1(Integer stationRouteId1) { | |
| 247 | + this.stationRouteId1 = stationRouteId1; | |
| 248 | + } | |
| 249 | + | |
| 250 | + public Integer getStationRouteId2() { | |
| 251 | + return stationRouteId2; | |
| 252 | + } | |
| 253 | + | |
| 254 | + public void setStationRouteId2(Integer stationRouteId2) { | |
| 255 | + this.stationRouteId2 = stationRouteId2; | |
| 256 | + } | |
| 257 | + | |
| 258 | + public Boolean getUp() { | |
| 259 | + return isUp; | |
| 260 | + } | |
| 261 | + | |
| 262 | + public void setUp(Boolean up) { | |
| 263 | + isUp = up; | |
| 264 | + } | |
| 265 | + | |
| 266 | + public Double getZlc() { | |
| 267 | + return zlc; | |
| 268 | + } | |
| 269 | + | |
| 270 | + public void setZlc(Double zlc) { | |
| 271 | + this.zlc = zlc; | |
| 272 | + } | |
| 273 | + | |
| 274 | + public Double getYylc() { | |
| 275 | + return yylc; | |
| 276 | + } | |
| 277 | + | |
| 278 | + public void setYylc(Double yylc) { | |
| 279 | + this.yylc = yylc; | |
| 280 | + } | |
| 281 | + | |
| 282 | + public Double getKslc() { | |
| 283 | + return kslc; | |
| 284 | + } | |
| 285 | + | |
| 286 | + public void setKslc(Double kslc) { | |
| 287 | + this.kslc = kslc; | |
| 288 | + } | |
| 289 | + | |
| 290 | + public Double getZgs() { | |
| 291 | + return zgs; | |
| 292 | + } | |
| 293 | + | |
| 294 | + public void setZgs(Double zgs) { | |
| 295 | + this.zgs = zgs; | |
| 296 | + } | |
| 297 | + | |
| 298 | + public Integer getZbc() { | |
| 299 | + return zbc; | |
| 300 | + } | |
| 301 | + | |
| 302 | + public void setZbc(Integer zbc) { | |
| 303 | + this.zbc = zbc; | |
| 304 | + } | |
| 305 | + | |
| 306 | + public Double getYygs() { | |
| 307 | + return yygs; | |
| 308 | + } | |
| 309 | + | |
| 310 | + public void setYygs(Double yygs) { | |
| 311 | + this.yygs = yygs; | |
| 312 | + } | |
| 313 | + | |
| 314 | + public Integer getYybc() { | |
| 315 | + return yybc; | |
| 316 | + } | |
| 317 | + | |
| 318 | + public void setYybc(Integer yybc) { | |
| 319 | + this.yybc = yybc; | |
| 320 | + } | |
| 321 | + | |
| 322 | + } | |
| 323 | + | |
| 324 | + class StatInfo { // 统计数据对象 | |
| 325 | + /** 统计项目 */ | |
| 326 | + private String statItem; | |
| 327 | + /** 统计值 */ | |
| 328 | + private Double statValue; | |
| 329 | + | |
| 330 | + public String getStatItem() { | |
| 331 | + return statItem; | |
| 332 | + } | |
| 333 | + | |
| 334 | + public void setStatItem(String statItem) { | |
| 335 | + this.statItem = statItem; | |
| 336 | + } | |
| 337 | + | |
| 338 | + public Double getStatValue() { | |
| 339 | + return statValue; | |
| 340 | + } | |
| 341 | + | |
| 342 | + public void setStatValue(Double statValue) { | |
| 343 | + this.statValue = statValue; | |
| 344 | + } | |
| 345 | + } | |
| 346 | + | |
| 347 | + class ParameterInfo { // 生成参数对象 | |
| 348 | + /** 参数项目名称 */ | |
| 349 | + private String paramItem; | |
| 350 | + /** 参数项目值 */ | |
| 351 | + private String paramValue; | |
| 352 | + | |
| 353 | + public String getParamItem() { | |
| 354 | + return paramItem; | |
| 355 | + } | |
| 356 | + | |
| 357 | + public void setParamItem(String paramItem) { | |
| 358 | + this.paramItem = paramItem; | |
| 359 | + } | |
| 360 | + | |
| 361 | + public String getParamValue() { | |
| 362 | + return paramValue; | |
| 363 | + } | |
| 364 | + | |
| 365 | + public void setParamValue(String paramValue) { | |
| 366 | + this.paramValue = paramValue; | |
| 367 | + } | |
| 368 | + } | |
| 369 | + | |
| 370 | + class DTInfos { // 所有数据信息 | |
| 371 | + /** 路牌班次数据列表 */ | |
| 372 | + private List<LpObj> lpObjList; | |
| 373 | + /** 统计数据列表 */ | |
| 374 | + private List<StatInfo> statInfoList; | |
| 375 | + /** 参数对象信息 */ | |
| 376 | + private List<ParameterInfo> parameterInfoList; | |
| 377 | + | |
| 378 | + public List<LpObj> getLpObjList() { | |
| 379 | + return lpObjList; | |
| 380 | + } | |
| 381 | + | |
| 382 | + public void setLpObjList(List<LpObj> lpObjList) { | |
| 383 | + this.lpObjList = lpObjList; | |
| 384 | + } | |
| 385 | + | |
| 386 | + public List<StatInfo> getStatInfoList() { | |
| 387 | + return statInfoList; | |
| 388 | + } | |
| 389 | + | |
| 390 | + public void setStatInfoList(List<StatInfo> statInfoList) { | |
| 391 | + this.statInfoList = statInfoList; | |
| 392 | + } | |
| 393 | + | |
| 394 | + public List<ParameterInfo> getParameterInfoList() { | |
| 395 | + return parameterInfoList; | |
| 396 | + } | |
| 397 | + | |
| 398 | + public void setParameterInfoList(List<ParameterInfo> parameterInfoList) { | |
| 399 | + this.parameterInfoList = parameterInfoList; | |
| 400 | + } | |
| 401 | + } | |
| 402 | + | |
| 403 | + //---------------------- 生成时刻表用对象(以上) ---------------------// | |
| 404 | + | |
| 405 | + /** | |
| 406 | + * 导出动态时刻表数据。 | |
| 407 | + * @param dtInfos | |
| 408 | + * @return | |
| 409 | + * @throws ScheduleException | |
| 410 | + */ | |
| 411 | + DataToolsFile exportDynamicTTinfo(DTInfos dtInfos, DataToolsFileType type) throws ScheduleException; | |
| 412 | +} | ... | ... |
src/main/resources/fatso/start.js
| 1 | 1 | /** |
| 2 | - * @author PanZhao | |
| 3 | - * @date 2016年3月17日 下午12:44:06 | |
| 2 | + * @author PanZhao | |
| 3 | + * @date 2016年3月17日 下午12:44:06 | |
| 4 | 4 | */ |
| 5 | 5 | var fs = require('fs') |
| 6 | - ,colors = require('colors') | |
| 7 | - ,child_process = require('child_process') | |
| 8 | - ,EventProxy = require('eventproxy') | |
| 9 | - ,parse = require('./parse') | |
| 10 | - ,minifier = require('./minifier') | |
| 11 | - ,crypto = require("crypto") | |
| 12 | - ,handle_real_ctl = require('./handle_real_ctl'); | |
| 6 | + , colors = require('colors') | |
| 7 | + , child_process = require('child_process') | |
| 8 | + , EventProxy = require('eventproxy') | |
| 9 | + , parse = require('./parse') | |
| 10 | + , minifier = require('./minifier') | |
| 11 | + , crypto = require("crypto") | |
| 12 | + , handle_real_ctl = require('./handle_real_ctl'); | |
| 13 | 13 | |
| 14 | 14 | |
| 15 | 15 | var platform = process.platform; |
| 16 | -var iswin = platform=='win32'; | |
| 17 | -var sp = platform=='win32'?'\\':'/'; | |
| 16 | +var iswin = platform == 'win32'; | |
| 17 | +var sp = platform == 'win32' ? '\\' : '/'; | |
| 18 | 18 | //不参与的目录 |
| 19 | -var excludes = ['scheduleApp', 'trafficManage', 'control', 'permission'+sp+'authorize_all', 'summary', 'history_sch' ,'report'+sp+'oil','base'+sp+'geo_data_edit','base'+sp+'carpark','forms','mforms', 'report', 'punctual'] | |
| 20 | - ,ep = new EventProxy() | |
| 21 | - ,pName = 'bsth_control' | |
| 22 | - ,path = process.cwd() | |
| 23 | - //根目录 | |
| 24 | - ,root = path.substr(0, path.indexOf(sp + 'src'+sp+'main')) | |
| 25 | - ,workspace = root.substr(0, root.lastIndexOf(sp + pName)) | |
| 26 | - //临时目录 | |
| 27 | - ,dest = (workspace + sp + pName+'@fatso_copy') | |
| 28 | - ,_static = sp + 'src'+sp+'main'+sp+'resources'+sp+'static' | |
| 29 | - ,_pages = dest + _static + sp + 'pages'; | |
| 19 | +var excludes = ['scheduleApp', 'trafficManage', 'control', 'permission' + sp + 'authorize_all', 'summary', 'history_sch', 'report' + sp + 'oil', 'base' + sp + 'geo_data_edit', 'base' + sp + 'carpark', 'forms', 'mforms', 'report', 'punctual', 'base' + sp + 'timesmodel'] | |
| 20 | + , ep = new EventProxy() | |
| 21 | + , pName = 'bsth_control' | |
| 22 | + , path = process.cwd() | |
| 23 | + //根目录 | |
| 24 | + , root = path.substr(0, path.indexOf(sp + 'src' + sp + 'main')) | |
| 25 | + , workspace = root.substr(0, root.lastIndexOf(sp + pName)) | |
| 26 | + //临时目录 | |
| 27 | + , dest = (workspace + sp + pName + '@fatso_copy') | |
| 28 | + , _static = sp + 'src' + sp + 'main' + sp + 'resources' + sp + 'static' | |
| 29 | + , _pages = dest + _static + sp + 'pages'; | |
| 30 | 30 | |
| 31 | 31 | |
| 32 | 32 | //创建临时目录 |
| 33 | -fs.mkdir(dest, function(e){ | |
| 34 | - if(e) | |
| 35 | - logError('创建临时目录出错,请检查目录 ' + dest + '是否存在'); | |
| 36 | - | |
| 37 | - setTimeout(function(){ | |
| 38 | - ep.emit('mvn-clean'); | |
| 39 | - }, 500); | |
| 33 | +fs.mkdir(dest, function (e) { | |
| 34 | + if (e) | |
| 35 | + logError('创建临时目录出错,请检查目录 ' + dest + '是否存在'); | |
| 36 | + | |
| 37 | + setTimeout(function () { | |
| 38 | + ep.emit('mvn-clean'); | |
| 39 | + }, 500); | |
| 40 | 40 | }); |
| 41 | 41 | //子进程 |
| 42 | 42 | var cProcess; |
| 43 | 43 | |
| 44 | -ep.tail('mvn-clean',function(){ | |
| 45 | - //ep.emit('copy-project'); | |
| 46 | - //清理target | |
| 47 | - logInfo('mvn clean...'); | |
| 48 | - cProcess = child_process.exec("mvn clean",{cwd: workspace + sp + pName},function(error){ | |
| 49 | - if(error) | |
| 50 | - logError(error); | |
| 51 | - | |
| 52 | - logSuccess('mvn clean success'); | |
| 53 | - | |
| 54 | - ep.emit('copy-project'); | |
| 55 | - }); | |
| 56 | - output(cProcess); | |
| 44 | +ep.tail('mvn-clean', function () { | |
| 45 | + //ep.emit('copy-project'); | |
| 46 | + //清理target | |
| 47 | + logInfo('mvn clean...'); | |
| 48 | + cProcess = child_process.exec("mvn clean", {cwd: workspace + sp + pName}, function (error) { | |
| 49 | + if (error) | |
| 50 | + logError(error); | |
| 51 | + | |
| 52 | + logSuccess('mvn clean success'); | |
| 53 | + | |
| 54 | + ep.emit('copy-project'); | |
| 55 | + }); | |
| 56 | + output(cProcess); | |
| 57 | 57 | }); |
| 58 | 58 | |
| 59 | 59 | //复制项目副本 |
| 60 | -ep.tail('copy-project',function(){ | |
| 61 | - logInfo('copy project...'); | |
| 62 | - var xcopyCom; | |
| 63 | - if(iswin) | |
| 64 | - xcopyCom = 'XCOPY '+ root.replace(/\//g,'\\') + ' ' + dest +' /e /exclude:'+path+'\\exclude.txt'; | |
| 65 | - else | |
| 66 | - xcopyCom = 'cp -a ' + root + '/. ' + dest; | |
| 67 | - | |
| 68 | - cProcess = child_process.exec(xcopyCom,{cwd: workspace, maxBuffer: 5000*1024},function(error){ | |
| 69 | - if(error) | |
| 70 | - logError(error); | |
| 71 | - | |
| 72 | - logSuccess('copy project success'); | |
| 73 | - | |
| 74 | - ep.emit('check-js'); | |
| 75 | - }); | |
| 76 | - //output(cProcess); | |
| 60 | +ep.tail('copy-project', function () { | |
| 61 | + logInfo('copy project...'); | |
| 62 | + var xcopyCom; | |
| 63 | + if (iswin) | |
| 64 | + xcopyCom = 'XCOPY ' + root.replace(/\//g, '\\') + ' ' + dest + ' /e /exclude:' + path + '\\exclude.txt'; | |
| 65 | + else | |
| 66 | + xcopyCom = 'cp -a ' + root + '/. ' + dest; | |
| 67 | + | |
| 68 | + cProcess = child_process.exec(xcopyCom, {cwd: workspace, maxBuffer: 5000 * 1024}, function (error) { | |
| 69 | + if (error) | |
| 70 | + logError(error); | |
| 71 | + | |
| 72 | + logSuccess('copy project success'); | |
| 73 | + | |
| 74 | + ep.emit('check-js'); | |
| 75 | + }); | |
| 76 | + //output(cProcess); | |
| 77 | 77 | }); |
| 78 | 78 | |
| 79 | 79 | //检查JS |
| 80 | -ep.tail('check-js', function(){ | |
| 81 | - ep.emit('minifier-js'); | |
| 80 | +ep.tail('check-js', function () { | |
| 81 | + ep.emit('minifier-js'); | |
| 82 | 82 | }); |
| 83 | 83 | |
| 84 | 84 | //合并压缩JS |
| 85 | -ep.tail('minifier-js', function(){ | |
| 86 | - logInfo('handle index.html...'); | |
| 87 | - | |
| 88 | - //再处理首页 | |
| 89 | - ep.emit('handle-index', function(){ | |
| 90 | - //递归处理片段 | |
| 91 | - walk(dest + _static + sp + 'pages', function(item){ | |
| 92 | - ep.emit('handle-fragment', item); | |
| 93 | - }, | |
| 94 | - function(){ | |
| 95 | - //处理线调首页 | |
| 96 | - handle_real_ctl.handleMain(function () { | |
| 97 | - //处理线调地图 | |
| 98 | - handle_real_ctl.handleMap(function () { | |
| 99 | - //处理单屏地图页面 | |
| 100 | - handle_real_ctl.handleAlonePage(function () { | |
| 101 | - //处理单屏主页 | |
| 102 | - handle_real_ctl.handleAloneHomePage(function () { | |
| 103 | - ep.emit('package-jar'); | |
| 104 | - }); | |
| 105 | - }); | |
| 106 | - }); | |
| 107 | - }); | |
| 108 | - }); | |
| 109 | - }); | |
| 85 | +ep.tail('minifier-js', function () { | |
| 86 | + logInfo('handle index.html...'); | |
| 87 | + | |
| 88 | + //再处理首页 | |
| 89 | + ep.emit('handle-index', function () { | |
| 90 | + //递归处理片段 | |
| 91 | + walk(dest + _static + sp + 'pages', function (item) { | |
| 92 | + ep.emit('handle-fragment', item); | |
| 93 | + }, | |
| 94 | + function () { | |
| 95 | + //处理线调首页 | |
| 96 | + handle_real_ctl.handleMain(function () { | |
| 97 | + //处理线调地图 | |
| 98 | + handle_real_ctl.handleMap(function () { | |
| 99 | + //处理单屏地图页面 | |
| 100 | + handle_real_ctl.handleAlonePage(function () { | |
| 101 | + //处理单屏主页 | |
| 102 | + handle_real_ctl.handleAloneHomePage(function () { | |
| 103 | + ep.emit('package-jar'); | |
| 104 | + }); | |
| 105 | + }); | |
| 106 | + }); | |
| 107 | + }); | |
| 108 | + }); | |
| 109 | + }); | |
| 110 | 110 | }); |
| 111 | 111 | |
| 112 | 112 | //打包 |
| 113 | -ep.tail('package-jar', function(file){ | |
| 114 | - var packageCom = 'mvn clean package -DskipTests'; | |
| 115 | - cProcess = child_process.exec(packageCom,{maxBuffer: 5000*1024, cwd: dest},function(error){ | |
| 116 | - if(error) | |
| 117 | - logError(error); | |
| 118 | - | |
| 119 | - logSuccess('mvn package success'); | |
| 120 | - | |
| 121 | - console.log(('成功打包在 ' + dest + sp + 'target 目录下').cyan); | |
| 122 | - }); | |
| 123 | - | |
| 124 | - output(cProcess); | |
| 113 | +ep.tail('package-jar', function (file) { | |
| 114 | + var packageCom = 'mvn clean package -DskipTests'; | |
| 115 | + cProcess = child_process.exec(packageCom, {maxBuffer: 5000 * 1024, cwd: dest}, function (error) { | |
| 116 | + if (error) | |
| 117 | + logError(error); | |
| 118 | + | |
| 119 | + logSuccess('mvn package success'); | |
| 120 | + | |
| 121 | + console.log(('成功打包在 ' + dest + sp + 'target 目录下').cyan); | |
| 122 | + }); | |
| 123 | + | |
| 124 | + output(cProcess); | |
| 125 | 125 | }); |
| 126 | 126 | |
| 127 | 127 | //处理片段 |
| 128 | -ep.tail('handle-fragment', function(file){ | |
| 129 | - //要排除的文件 | |
| 130 | - for(var i = 0, ex; ex = excludes[i++];){ | |
| 131 | - if(file.indexOf(_pages + sp + ex) != -1) | |
| 132 | - return false; | |
| 133 | - } | |
| 134 | - handleJavascript(file, function(mini, $){ | |
| 135 | - var jsMini; | |
| 136 | - if(mini.inside) | |
| 137 | - jsMini = '(function(){' + mini.inside + '\n' + mini.outside + '})();'; | |
| 138 | - else | |
| 139 | - jsMini = '(function(){' + mini.outside + '})();'; | |
| 140 | - | |
| 141 | - write(file, $.html() + '<script>' + jsMini + '</script>'); | |
| 142 | - }); | |
| 143 | - | |
| 128 | +ep.tail('handle-fragment', function (file) { | |
| 129 | + //要排除的文件 | |
| 130 | + for (var i = 0, ex; ex = excludes[i++];) { | |
| 131 | + if (file.indexOf(_pages + sp + ex) != -1) | |
| 132 | + return false; | |
| 133 | + } | |
| 134 | + handleJavascript(file, function (mini, $) { | |
| 135 | + var jsMini; | |
| 136 | + if (mini.inside) | |
| 137 | + jsMini = '(function(){' + mini.inside + '\n' + mini.outside + '})();'; | |
| 138 | + else | |
| 139 | + jsMini = '(function(){' + mini.outside + '})();'; | |
| 140 | + | |
| 141 | + write(file, $.html() + '<script>' + jsMini + '</script>'); | |
| 142 | + }); | |
| 143 | + | |
| 144 | 144 | }); |
| 145 | 145 | |
| 146 | 146 | //处理首页 |
| 147 | -ep.tail('handle-index', function(cb){ | |
| 148 | - var index = dest + _static + sp + 'index.html'; | |
| 149 | - handleJavascript(index, function(mini, $){ | |
| 150 | - var jsMiniText = mini.inside + mini.outside; | |
| 151 | - | |
| 152 | - var code = md5(jsMiniText); | |
| 153 | - fs.open( dest + _static + sp + 'assets'+sp+'js' + sp + code + '.js', 'a', function(err, fd){ | |
| 154 | - if(err) | |
| 155 | - logError(err); | |
| 156 | - | |
| 157 | - fs.write(fd,jsMiniText, function(){ | |
| 158 | - var ss = $('script'); | |
| 159 | - | |
| 160 | - $(ss[ss.length - 1]).before('<script src="/assets/js/'+code+'.js"></script>\n'); | |
| 161 | - for(var i = 0, s; s = ss[i++];){ | |
| 162 | - $(s).removeAttr('data-exclude') | |
| 163 | - .removeAttr('flag') | |
| 164 | - .removeAttr('data-autocephaly'); | |
| 165 | - } | |
| 166 | - write(index, $.html()); | |
| 167 | - | |
| 168 | - cb && cb(); | |
| 169 | - }); | |
| 170 | - }); | |
| 171 | - }); | |
| 147 | +ep.tail('handle-index', function (cb) { | |
| 148 | + var index = dest + _static + sp + 'index.html'; | |
| 149 | + handleJavascript(index, function (mini, $) { | |
| 150 | + var jsMiniText = mini.inside + mini.outside; | |
| 151 | + | |
| 152 | + var code = md5(jsMiniText); | |
| 153 | + fs.open(dest + _static + sp + 'assets' + sp + 'js' + sp + code + '.js', 'a', function (err, fd) { | |
| 154 | + if (err) | |
| 155 | + logError(err); | |
| 156 | + | |
| 157 | + fs.write(fd, jsMiniText, function () { | |
| 158 | + var ss = $('script'); | |
| 159 | + | |
| 160 | + $(ss[ss.length - 1]).before('<script src="/assets/js/' + code + '.js"></script>\n'); | |
| 161 | + for (var i = 0, s; s = ss[i++];) { | |
| 162 | + $(s).removeAttr('data-exclude') | |
| 163 | + .removeAttr('flag') | |
| 164 | + .removeAttr('data-autocephaly'); | |
| 165 | + } | |
| 166 | + write(index, $.html()); | |
| 167 | + | |
| 168 | + cb && cb(); | |
| 169 | + }); | |
| 170 | + }); | |
| 171 | + }); | |
| 172 | 172 | }); |
| 173 | 173 | |
| 174 | 174 | |
| 175 | -function handleJavascript(item, cb){ | |
| 176 | - //解析页面 | |
| 177 | - var htmlResult = parse.html(item, dest + _static) | |
| 178 | - ,jsArray = htmlResult.jsArray | |
| 179 | - ,$ = htmlResult.$ | |
| 180 | - ,scrStr = htmlResult.scriptString; | |
| 181 | - | |
| 182 | - //合并压缩 | |
| 183 | - var mini = minifier.mergeAndMini(jsArray, scrStr, dest + _static, item); | |
| 184 | - | |
| 185 | - cb && cb(mini, $); | |
| 175 | +function handleJavascript(item, cb) { | |
| 176 | + //解析页面 | |
| 177 | + var htmlResult = parse.html(item, dest + _static) | |
| 178 | + , jsArray = htmlResult.jsArray | |
| 179 | + , $ = htmlResult.$ | |
| 180 | + , scrStr = htmlResult.scriptString; | |
| 181 | + | |
| 182 | + //合并压缩 | |
| 183 | + var mini = minifier.mergeAndMini(jsArray, scrStr, dest + _static, item); | |
| 184 | + | |
| 185 | + cb && cb(mini, $); | |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | -function removeJsLink(s, e){ | |
| 189 | - var newArray = [], flag; | |
| 190 | - | |
| 191 | - for(var i = 0, si; si = s[i++];){ | |
| 192 | - flag = 0; | |
| 193 | - for(var j = 0,ei; ei = e[j++];){ | |
| 194 | - if(si.indexOf(ei) != -1){ | |
| 195 | - flag = -1; | |
| 196 | - break; | |
| 197 | - } | |
| 198 | - } | |
| 199 | - | |
| 200 | - if(flag == 0){ | |
| 201 | - newArray.push(si); | |
| 202 | - } | |
| 203 | - } | |
| 204 | - return newArray; | |
| 188 | +function removeJsLink(s, e) { | |
| 189 | + var newArray = [], flag; | |
| 190 | + | |
| 191 | + for (var i = 0, si; si = s[i++];) { | |
| 192 | + flag = 0; | |
| 193 | + for (var j = 0, ei; ei = e[j++];) { | |
| 194 | + if (si.indexOf(ei) != -1) { | |
| 195 | + flag = -1; | |
| 196 | + break; | |
| 197 | + } | |
| 198 | + } | |
| 199 | + | |
| 200 | + if (flag == 0) { | |
| 201 | + newArray.push(si); | |
| 202 | + } | |
| 203 | + } | |
| 204 | + return newArray; | |
| 205 | 205 | } |
| 206 | 206 | |
| 207 | -function write(file, text){ | |
| 208 | - fs.writeFile(file, text, function (err) { | |
| 209 | - if (err){ | |
| 210 | - console.log(err.toString().red); | |
| 211 | - process.exit(); | |
| 212 | - } | |
| 213 | - //console.log(file.green); | |
| 214 | - }); | |
| 207 | +function write(file, text) { | |
| 208 | + fs.writeFile(file, text, function (err) { | |
| 209 | + if (err) { | |
| 210 | + console.log(err.toString().red); | |
| 211 | + process.exit(); | |
| 212 | + } | |
| 213 | + //console.log(file.green); | |
| 214 | + }); | |
| 215 | 215 | } |
| 216 | 216 | |
| 217 | -function md5(text){ | |
| 218 | - return crypto.createHash("md5").update(text).digest("hex"); | |
| 217 | +function md5(text) { | |
| 218 | + return crypto.createHash("md5").update(text).digest("hex"); | |
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | |
| 222 | -function walk(path ,handleFile, over) { | |
| 223 | - fs.readdir(path, function(err, files) { | |
| 224 | - if (err) { | |
| 225 | - console.log('read dir error'.red); | |
| 226 | - } else { | |
| 227 | - files.forEach(function(item) { | |
| 222 | +function walk(path, handleFile, over) { | |
| 223 | + fs.readdir(path, function (err, files) { | |
| 224 | + if (err) { | |
| 225 | + console.log('read dir error'.red); | |
| 226 | + } else { | |
| 227 | + files.forEach(function (item) { | |
| 228 | 228 | var tmpPath = path + sp + item; |
| 229 | - fs.stat(tmpPath, function(err1, stats) { | |
| 230 | - if (err1) { | |
| 231 | - console.log('stat error'); | |
| 232 | - } else { | |
| 233 | - if (stats.isDirectory()) { | |
| 234 | - walk(tmpPath, handleFile); | |
| 235 | - } else if(item.indexOf('.html') != -1){ | |
| 236 | - handleFile(tmpPath); | |
| 237 | - } | |
| 238 | - } | |
| 239 | - }) | |
| 229 | + fs.stat(tmpPath, function (err1, stats) { | |
| 230 | + if (err1) { | |
| 231 | + console.log('stat error'); | |
| 232 | + } else { | |
| 233 | + if (stats.isDirectory()) { | |
| 234 | + walk(tmpPath, handleFile); | |
| 235 | + } else if (item.indexOf('.html') != -1) { | |
| 236 | + handleFile(tmpPath); | |
| 237 | + } | |
| 238 | + } | |
| 239 | + }) | |
| 240 | 240 | }); |
| 241 | - | |
| 241 | + | |
| 242 | 242 | over && over(); |
| 243 | - } | |
| 244 | - }); | |
| 245 | -} | |
| 243 | + } | |
| 244 | + }); | |
| 245 | +} | |
| 246 | 246 | |
| 247 | -function logInfo(t){ | |
| 248 | - console.log(t); | |
| 247 | +function logInfo(t) { | |
| 248 | + console.log(t); | |
| 249 | 249 | } |
| 250 | 250 | |
| 251 | -function logSuccess(t){ | |
| 252 | - console.log(t.green); | |
| 251 | +function logSuccess(t) { | |
| 252 | + console.log(t.green); | |
| 253 | 253 | } |
| 254 | 254 | |
| 255 | -function logError(e){ | |
| 256 | - console.log(e.toString().red); | |
| 257 | - process.exit(); | |
| 255 | +function logError(e) { | |
| 256 | + console.log(e.toString().red); | |
| 257 | + process.exit(); | |
| 258 | 258 | } |
| 259 | 259 | |
| 260 | -function output(cProcess){ | |
| 261 | - //标准输出 | |
| 262 | - cProcess.stdout.on('data', function (s) { | |
| 263 | - console.log(s); | |
| 264 | - }); | |
| 260 | +function output(cProcess) { | |
| 261 | + //标准输出 | |
| 262 | + cProcess.stdout.on('data', function (s) { | |
| 263 | + console.log(s); | |
| 264 | + }); | |
| 265 | 265 | } |
| 266 | 266 | \ No newline at end of file | ... | ... |
src/main/resources/static/index.html
| ... | ... | @@ -630,7 +630,8 @@ |
| 630 | 630 | <script |
| 631 | 631 | src="http://webapi.amap.com/maps?v=1.3&key=16cb1c5043847e09ef9edafdd77befda" |
| 632 | 632 | data-exclude=1></script> |
| 633 | - | |
| 633 | +<!-- echarts --> | |
| 634 | +<script src="/metronic_v4.5.4/plugins/echarts4/echarts.min.js"></script> | |
| 634 | 635 | <script src="/real_control_v2/assets/plugins/perfect-scrollbar/perfect-scrollbar.jquery.js" merge="plugins"></script> |
| 635 | 636 | |
| 636 | 637 | </body> | ... | ... |
src/main/resources/static/pages/base/geo_data_edit/js/search.js
| ... | ... | @@ -27,8 +27,8 @@ var gb_ct_search = function () { |
| 27 | 27 | }); |
| 28 | 28 | |
| 29 | 29 | var searchComplete = function (e) { |
| 30 | - //console.log('e.wr', e); | |
| 31 | - var htmlStr = template('geo_d_e_search_result-temp', {list: e.yr}); | |
| 30 | + console.log('e.wr', e); | |
| 31 | + var htmlStr = template('geo_d_e_search_result-temp', {list: e.Br}); | |
| 32 | 32 | $('.ct_search_result').html(htmlStr); |
| 33 | 33 | |
| 34 | 34 | }; | ... | ... |
src/main/resources/static/pages/base/line/edit.html
src/main/resources/static/pages/base/line/js/line-edit-form.js
| ... | ... | @@ -236,7 +236,7 @@ |
| 236 | 236 | // 表单序列化 |
| 237 | 237 | var params = form.serializeJSON(); |
| 238 | 238 | // 查询线路编码的顺延号 |
| 239 | - $get('/line/all', {lineCode_prefixLike: params.lineCode},function(lineCode){ | |
| 239 | + $get('/line/all', {lineCode_eq: params.lineCode},function(lineCode){ | |
| 240 | 240 | // 定义返回值的长度 |
| 241 | 241 | var len = lineCode.length; |
| 242 | 242 | // 如果大于零,则已存在录入的线路编码;否则不存在 | ... | ... |
src/main/resources/static/pages/base/line/js/line-list-table.js
| ... | ... | @@ -338,30 +338,54 @@ |
| 338 | 338 | layer.msg('请选中一条线路!'); |
| 339 | 339 | return ; |
| 340 | 340 | }else { |
| 341 | - id = arrChk.data('id'); | |
| 342 | - lineName = arrChk.val(); | |
| 343 | - // 请求参数 | |
| 344 | - var params = {lineId:id}; | |
| 345 | - // 弹出正在加载层 | |
| 346 | - var index = layer.load(0); | |
| 347 | - /** 生成线路行单 @pararm:<params:请求参数> */ | |
| 348 | - $post('/stationroute/usingSingle',params,function(data) { | |
| 349 | - // 关闭弹出框 | |
| 350 | - layer.close(index); | |
| 351 | - if(data.status=='SUCCESS') { | |
| 352 | - // 弹出添加成功提示消息 | |
| 353 | - layer.msg('生成线路【'+ lineName +'】路单文件成功!'); | |
| 354 | - }else if(data.status=='ERROR'){ | |
| 355 | - // 弹出添加成功提示消息 | |
| 356 | - layer.msg('生成线路【'+ lineName +'】路单文件失败!'); | |
| 357 | - }else if(data.status=='NOTDATA') { | |
| 358 | - // 弹出添加成功提示消息 | |
| 359 | - layer.msg('系统无线路【'+ lineName +'】的站点与路段信息!'); | |
| 360 | - }else if(data.status=='NOLinePlayType') { | |
| 361 | - // 弹出添加成功提示消息 | |
| 362 | - layer.msg('无法识别【'+ lineName +'】的线路规划类型,请设置为双向/环线!'); | |
| 363 | - } | |
| 364 | - }); | |
| 341 | + layer.open({ | |
| 342 | + id:1, | |
| 343 | + type: 1, | |
| 344 | + title: "线路文件版本号", | |
| 345 | + // skin:'layui-layer-rim', | |
| 346 | + area:['450px', 'auto'], | |
| 347 | + | |
| 348 | + content: '<div class="col-sm-12">' | |
| 349 | + +'<div class="input-group">' | |
| 350 | + +'<span class="input-group-addon"> 线路文件版本号 :</span>' | |
| 351 | + +'<input id="fileVersionsInput" type="text" class="form-control" placeholder="没有填写默认为2">' | |
| 352 | + +'</div>' | |
| 353 | + +'</div>', | |
| 354 | + btn:['确定','取消'], | |
| 355 | + btn1: function (index,layero) { | |
| 356 | + var fileVersions = $('#fileVersionsInput').val(); | |
| 357 | + id = arrChk.data('id'); | |
| 358 | + lineName = arrChk.val(); | |
| 359 | + // 请求参数 | |
| 360 | + var params = {lineId:id, fileVersions:fileVersions}; | |
| 361 | + // 弹出正在加载层 | |
| 362 | + var index = layer.load(0); | |
| 363 | + /** 生成线路行单 @pararm:<params:请求参数> */ | |
| 364 | + $post('/stationroute/usingSingle',params,function(data) { | |
| 365 | + // 关闭弹出框 | |
| 366 | + layer.close(index); | |
| 367 | + if(data.status=='SUCCESS') { | |
| 368 | + // 弹出添加成功提示消息 | |
| 369 | + layer.msg('生成线路【'+ lineName +'】路单文件成功!'); | |
| 370 | + }else if(data.status=='ERROR'){ | |
| 371 | + // 弹出添加成功提示消息 | |
| 372 | + layer.msg('生成线路【'+ lineName +'】路单文件失败!'); | |
| 373 | + }else if(data.status=='NOTDATA') { | |
| 374 | + // 弹出添加成功提示消息 | |
| 375 | + layer.msg('系统无线路【'+ lineName +'】的站点与路段信息!'); | |
| 376 | + }else if(data.status=='NOLinePlayType') { | |
| 377 | + // 弹出添加成功提示消息 | |
| 378 | + layer.msg('无法识别【'+ lineName +'】的线路规划类型,请设置为双向/环线!'); | |
| 379 | + } | |
| 380 | + }); | |
| 381 | + }, | |
| 382 | + btn2:function (index,layero) { | |
| 383 | + layer.close(index); | |
| 384 | + } | |
| 385 | + | |
| 386 | + }); | |
| 387 | + | |
| 388 | + | |
| 365 | 389 | } |
| 366 | 390 | }); |
| 367 | 391 | /** 生成路线(路段和站点) */ | ... | ... |
src/main/resources/static/pages/base/stationroute/edit.html
| ... | ... | @@ -190,7 +190,11 @@ $('#edit_station_mobal').on('editSelectMobal_show', function(e, map_,ajaxd,stati |
| 190 | 190 | fun.linePanlThree(addLine.id,data,add_direction_v); |
| 191 | 191 | }); |
| 192 | 192 | fun.editMapStatusRemove(); |
| 193 | - } | |
| 193 | + setTimeout(function () { | |
| 194 | + var stationArray = map_.getStationArray(); | |
| 195 | + map_.openStationInfoWin(stationArray[editStationParmasObj.stationRouteId]); | |
| 196 | + },1000); | |
| 197 | + } | |
| 194 | 198 | // 编辑表单元素 |
| 195 | 199 | var form = $('#edit_station_form'); |
| 196 | 200 | // 获取错误提示元素 |
| ... | ... | @@ -206,9 +210,9 @@ $('#edit_station_mobal').on('editSelectMobal_show', function(e, map_,ajaxd,stati |
| 206 | 210 | errorClass : 'help-block help-block-error', |
| 207 | 211 | focusInvalid : false, |
| 208 | 212 | rules : { |
| 209 | - 'zdmc' : { required : true,maxlength : 50,},// 站点名称 必填项 | |
| 210 | - 'stationName' : { required : true,maxlength : 50,},// 站点名称 必填项 | |
| 211 | - 'stationCod': {required : true,},// 站点编码 必填项 | |
| 213 | + 'zdmc' : { required : true,maxlength : 50},// 站点名称 必填项 | |
| 214 | + 'stationName' : { required : true,maxlength : 50},// 站点名称 必填项 | |
| 215 | + 'stationCod': {required : true},// 站点编码 必填项 | |
| 212 | 216 | 'directions' : {required : true,dirIs : true},// 站点方向 必填项 必填项 |
| 213 | 217 | 'stationRouteCode' : {isStart : true},// 站点序号 |
| 214 | 218 | 'stationMark' : {required : true},// 站点类型 必填项 | ... | ... |
src/main/resources/static/pages/base/stationroute/edit_select.html
| ... | ... | @@ -14,10 +14,6 @@ |
| 14 | 14 | <button class="close" data-close="alert"></button> |
| 15 | 15 | 站点名称为必填项 |
| 16 | 16 | </div> |
| 17 | - <div class="alert alert-danger display-hide" id="serchrname"> | |
| 18 | - <button class="close" data-close="alert"></button> | |
| 19 | - 系统无法生成,请选择其他方式新增 | |
| 20 | - </div> | |
| 21 | 17 | <div class="form-group" id="formRequ"> |
| 22 | 18 | <label class="col-md-3 control-label"><span class="required"> * </span>站点名称:</label> |
| 23 | 19 | <div class="col-md-9" id="errorInfo"> |
| ... | ... | @@ -29,10 +25,13 @@ |
| 29 | 25 | <div class="col-md-9"> |
| 30 | 26 | <div class="icheck-list"> |
| 31 | 27 | <label> |
| 32 | - <input type="radio" class="icheck" name="editselect" value=0> 重新绘制位置 | |
| 28 | + <input type="radio" class="icheck" name="editselect" value=0> 重新绘制为多边形 | |
| 33 | 29 | </label> |
| 34 | 30 | <label> |
| 35 | - <input type="radio" class="icheck" name="editselect" value=1 checked> 编辑原始位置 | |
| 31 | + <input type="radio" class="icheck" name="editselect" value=1> 重新绘制为圆形 | |
| 32 | + </label> | |
| 33 | + <label> | |
| 34 | + <input type="radio" class="icheck" name="editselect" value=2 checked> 编辑原始位置 | |
| 36 | 35 | </label> |
| 37 | 36 | </div> |
| 38 | 37 | </div> |
| ... | ... | @@ -124,6 +123,19 @@ $('#edit_select_mobal').on('editSelectMobal_show', function(e, map_,drw,ajaxd,ed |
| 124 | 123 | map_.localtionPoint(editStationName+"公交站点"); |
| 125 | 124 | fun.editMapStatus(); |
| 126 | 125 | }else if(params.editselect==1){ |
| 126 | + WorldsBMap.localSearchFromAdreesToPoint(editStationName+"公交站点", function (Points) { | |
| 127 | + if (Points) { | |
| 128 | + Station.stationJwpoints = Points; | |
| 129 | + } | |
| 130 | + Station.stationShapesType = 'r'; | |
| 131 | + Station.stationGPloyonGrid = null; | |
| 132 | + Station.stationRadius = 100; | |
| 133 | + editStationObj.setEitdStation(Station); | |
| 134 | + editStationObj.setEitdStationName(editStationName); | |
| 135 | + map_.editShapes(editStationObj); | |
| 136 | + }); | |
| 137 | + fun.editMapStatus(); | |
| 138 | + }else if(params.editselect==2){ | |
| 127 | 139 | editStationObj.setEitdStation(Station); |
| 128 | 140 | editStationObj.setEitdStationName(editStationName); |
| 129 | 141 | map_.clearMark(); | ... | ... |
src/main/resources/static/pages/base/stationroute/editsection.html
| ... | ... | @@ -110,6 +110,9 @@ $('#edit_section_mobal').on('editSectionMobal_show', function(e, map_,ajaxd,p,fu |
| 110 | 110 | ajaxd.getSectionRouteInfo(lineId,dir,function(data) { |
| 111 | 111 | fun.linePanlThree(lineId,data,dir); |
| 112 | 112 | }); |
| 113 | + setTimeout(function () { | |
| 114 | + map_.openSectionInfoWin(p); | |
| 115 | + },1000); | |
| 113 | 116 | } |
| 114 | 117 | // 编辑表单元素 |
| 115 | 118 | var form = $('#edit_section__form'); | ... | ... |
src/main/resources/static/pages/base/stationroute/js/stationroute-list-map.js
| ... | ... | @@ -24,9 +24,19 @@ |
| 24 | 24 | |
| 25 | 25 | window.WorldsBMap = function () { |
| 26 | 26 | |
| 27 | - /** WorldsBMap 全局变量定义 mapBValue:地图对象;polygon:多边形;polyUpline:走向折线;circle:圆; road_win_show_p:信息窗口打开状态的路段,map_status:地图编辑状态,drawingManager:绘画工具*/ | |
| 28 | - var mapBValue = '',polygon = '', polyUpline = '', circle = '', iseditStatus = false, road_win_show_p = '', editPolyline = '', sectionArray = [], stationArray = new Map(),map_status = 0, | |
| 29 | - drawingManager; | |
| 27 | + /** WorldsBMap 全局变量定义 mapBValue:地图对象; road_win_show_p:信息窗口打开状态的路段, | |
| 28 | + * sectionArray: 路段集合,stationArray: 站点集合 | |
| 29 | + * map_status:地图编辑状态,drawingManager:绘画工具, topOverlay:置顶视图*/ | |
| 30 | + var mapBValue = '', iseditStatus = false, road_win_show_p = '', editPolyline = '', | |
| 31 | + sectionArray = [], stationArray = new Map(), | |
| 32 | + map_status = 0,drawingManager,topOverlay; | |
| 33 | + | |
| 34 | + /** | |
| 35 | + * 编辑缓冲区 | |
| 36 | + * stationMarkers: 站点图标集合 | |
| 37 | + */ | |
| 38 | + var editCircle, editPolygon, dragMarker, stationMarkers = new Map(),centerPoint; | |
| 39 | + | |
| 30 | 40 | var styleOptions = { |
| 31 | 41 | strokeColor:"blue", //边线颜色。 |
| 32 | 42 | fillColor:"blue", //填充颜色。当参数为空时,圆形将没有填充效果。 |
| ... | ... | @@ -34,7 +44,39 @@ window.WorldsBMap = function () { |
| 34 | 44 | strokeOpacity: 0.7, //边线透明度,取值范围0 - 1。 |
| 35 | 45 | fillOpacity: 0.6, //填充的透明度,取值范围0 - 1。 |
| 36 | 46 | strokeStyle: 'solid' //边线的样式,solid或dashed。 |
| 37 | - } | |
| 47 | + }; | |
| 48 | + | |
| 49 | + // 覆盖物置顶 | |
| 50 | + var setTop = function(overlay) { | |
| 51 | + if (topOverlay) | |
| 52 | + topOverlay.setTop(false); | |
| 53 | + overlay.setTop(true); | |
| 54 | + topOverlay = overlay; | |
| 55 | + }; | |
| 56 | + | |
| 57 | + var setDragMarker = function (marker) { | |
| 58 | + marker.enableDragging(); | |
| 59 | + dragMarker = marker; | |
| 60 | + dragMarker._old_point = dragMarker._position; | |
| 61 | + //监听拖拽事件 dragging | |
| 62 | + dragMarker.addEventListener('dragging', dragMarkerDragEvent); | |
| 63 | + }; | |
| 64 | + | |
| 65 | + var dragMarkerDragEvent = function (e) { | |
| 66 | + if (editPolygon) { | |
| 67 | + if (!BMapLib.GeoUtils.isPointInPolygon(e.target._position, editPolygon)) | |
| 68 | + dragMarker.setPosition(dragMarker._old_point);//还原位置 | |
| 69 | + | |
| 70 | + centerPoint = e.target._position; | |
| 71 | + } | |
| 72 | + else if (editCircle) { | |
| 73 | + editCircle.disableEditing(); | |
| 74 | + //缓冲区跟随点位运动 | |
| 75 | + editCircle.setCenter(e.target._position); | |
| 76 | + editCircle.enableEditing(); | |
| 77 | + centerPoint = e.target._position; | |
| 78 | + } | |
| 79 | + }; | |
| 38 | 80 | |
| 39 | 81 | var Bmap = { |
| 40 | 82 | |
| ... | ... | @@ -44,7 +86,7 @@ window.WorldsBMap = function () { |
| 44 | 86 | // 百度API Key |
| 45 | 87 | var bdKey = 'IGGrr4UjwIYzatoCRFKEL8sT'; |
| 46 | 88 | // 初始化百度地图 |
| 47 | - mapBValue = new BMap.Map("bmap_basic"); | |
| 89 | + mapBValue = new BMap.Map("bmap_basic" , {enableMapClick: false}); | |
| 48 | 90 | //中心点和缩放级别 |
| 49 | 91 | mapBValue.centerAndZoom(new BMap.Point(CENTER_POINT.lng, CENTER_POINT.lat), 15); |
| 50 | 92 | //启用地图拖拽事件,默认启用(可不写) |
| ... | ... | @@ -62,24 +104,21 @@ window.WorldsBMap = function () { |
| 62 | 104 | getmapBValue: function () { |
| 63 | 105 | return mapBValue; |
| 64 | 106 | }, |
| 65 | - getPolygon: function () { | |
| 66 | - return polygon; | |
| 67 | - }, | |
| 68 | - getPolyUpline: function () { | |
| 69 | - return polyUpline; | |
| 70 | - }, | |
| 71 | - getCircle: function () { | |
| 72 | - return circle; | |
| 107 | + setMap_status : function (i) { | |
| 108 | + map_status = i; | |
| 73 | 109 | }, |
| 74 | 110 | getIsEditStatus: function () { |
| 75 | 111 | return iseditStatus; |
| 76 | 112 | }, |
| 77 | - setMap_status : function (i) { | |
| 78 | - map_status = i; | |
| 79 | - }, | |
| 80 | 113 | setIsEditStatus: function (v) { |
| 81 | 114 | iseditStatus = v; |
| 82 | 115 | }, |
| 116 | + getStationArray: function () { | |
| 117 | + return stationArray; | |
| 118 | + }, | |
| 119 | + setStationArray : function (s) { | |
| 120 | + stationArray = s; | |
| 121 | + }, | |
| 83 | 122 | /*initDrawingManager: function (map, styleOptions) { |
| 84 | 123 | },*/ |
| 85 | 124 | getDrawingManagerObj: function () { |
| ... | ... | @@ -100,59 +139,35 @@ window.WorldsBMap = function () { |
| 100 | 139 | |
| 101 | 140 | /** 获取距离与时间 @param <points:坐标点集合> */ |
| 102 | 141 | getDistanceAndDuration: function (points, callback) { |
| 103 | - | |
| 104 | 142 | // 获取长度 |
| 105 | 143 | var len = points.length; |
| 106 | - | |
| 107 | 144 | (function () { |
| 108 | - | |
| 109 | 145 | if (!arguments.callee.count) { |
| 110 | - | |
| 111 | 146 | arguments.callee.count = 0; |
| 112 | - | |
| 113 | 147 | } |
| 114 | - | |
| 115 | 148 | arguments.callee.count++; |
| 116 | - | |
| 117 | 149 | var index = parseInt(arguments.callee.count) - 1; |
| 118 | - | |
| 119 | 150 | if (index >= len - 1) { |
| 120 | - | |
| 121 | 151 | callback && callback(points); |
| 122 | - | |
| 123 | 152 | return; |
| 124 | 153 | } |
| 125 | - | |
| 126 | 154 | // 当函数被调用时,它的arguments.callee对象就会指向自身,也就是一个对自己的引用。(当前正在执行的函数。) |
| 127 | 155 | var f = arguments.callee; |
| 128 | - | |
| 129 | 156 | // 起点坐标 <坐标格式:40.056878,116.30815> |
| 130 | 157 | var origin = points[index].potion.lat + ',' + points[index].potion.lng; |
| 131 | - | |
| 132 | 158 | // 终点坐标 <坐标格式:40.056878,116.30815> |
| 133 | 159 | var destination = points[index + 1].potion.lat + ',' + points[index + 1].potion.lng; |
| 134 | - | |
| 135 | 160 | var region = '上海'; |
| 136 | - | |
| 137 | 161 | var origin_region = '上海'; |
| 138 | - | |
| 139 | 162 | var destination_region = '上海'; |
| 140 | - | |
| 141 | 163 | var output = 'json'; |
| 142 | - | |
| 143 | 164 | var ak_My = 'wjlITmXeCek5MxyU3ZUBkTeU8B0o0npk'; |
| 144 | - | |
| 145 | 165 | /** |
| 146 | 166 | * origin:起点名称或经纬度; |
| 147 | - * | |
| 148 | 167 | * destination:终点名称或经纬度; |
| 149 | - * | |
| 150 | 168 | * origin_region:起始点所在城市,驾车导航时必填。 |
| 151 | - * | |
| 152 | 169 | * destination_region:终点所在城市,驾车导航时必填。 |
| 153 | - * | |
| 154 | 170 | * output :表示输出类型,可设置为xml或json,默认为xml。 |
| 155 | - * | |
| 156 | 171 | **/ |
| 157 | 172 | var paramsB = { |
| 158 | 173 | origin: origin, |
| ... | ... | @@ -166,60 +181,40 @@ window.WorldsBMap = function () { |
| 166 | 181 | |
| 167 | 182 | /** @description :未认证开发者默认配额为:2000次/天。 */ |
| 168 | 183 | $.ajax({ |
| 169 | - | |
| 170 | 184 | // 百度地图根据坐标获取两点之间的时间与距离 |
| 171 | 185 | url: 'http://api.map.baidu.com/direction/v1?mode=transit', |
| 172 | - | |
| 173 | 186 | data: paramsB, |
| 174 | - | |
| 175 | 187 | dataType: 'jsonp', |
| 176 | - | |
| 177 | 188 | success: function (r) { |
| 178 | - | |
| 179 | 189 | if (r) { |
| 180 | - | |
| 181 | 190 | if (r.message == 'ok') { |
| 182 | - | |
| 183 | 191 | if (r.result.taxi == null) { |
| 184 | - | |
| 185 | 192 | // 获取距离(单位:米) |
| 186 | 193 | points[index + 1].distance = 0; |
| 187 | - | |
| 188 | 194 | // 获取时间(单位:秒) |
| 189 | 195 | points[index + 1].duration = 0; |
| 190 | - | |
| 191 | 196 | } else { |
| 192 | - | |
| 193 | 197 | // 获取距离(单位:米) |
| 194 | 198 | points[index + 1].distance = r.result.taxi.distance; |
| 195 | - | |
| 196 | 199 | // 获取时间(单位:秒) |
| 197 | 200 | points[index + 1].duration = r.result.taxi.duration; |
| 198 | - | |
| 199 | 201 | } |
| 200 | - | |
| 201 | - | |
| 202 | 202 | } |
| 203 | - | |
| 204 | 203 | } |
| 205 | - | |
| 206 | 204 | f(); |
| 207 | 205 | } |
| 208 | 206 | }); |
| 209 | - | |
| 210 | 207 | })(); |
| 211 | - | |
| 212 | 208 | }, |
| 209 | + | |
| 213 | 210 | // 打开站点信息窗口 |
| 214 | 211 | openStationInfoWin : function (objStation) { |
| 215 | 212 | // 将视图切换到指定的缩放等级,中心点坐标不变。注意:当有信息窗口在地图上打开时,地图缩放将保证信息窗口所在的坐标位置不动。(自1.2新增) |
| 216 | - mapBValue.setZoom(25); | |
| 217 | 213 | if (objStation) { |
| 218 | 214 | // 站点形状 |
| 219 | 215 | var shapes = objStation.stationShapesType; |
| 220 | 216 | // 获取中心坐标点字符串分割 |
| 221 | 217 | var BJwpoints = objStation.stationJwpoints.split(' '); |
| 222 | - | |
| 223 | 218 | // 中心坐标点 |
| 224 | 219 | var point = new BMap.Point(BJwpoints[0], BJwpoints[1]); |
| 225 | 220 | var width = WorldsBMap.strGetLength(objStation.stationRouteName) * 11; |
| ... | ... | @@ -270,102 +265,59 @@ window.WorldsBMap = function () { |
| 270 | 265 | //开启信息窗口 |
| 271 | 266 | mapBValue.openInfoWindow(infoWindow_target, point); |
| 272 | 267 | }, 100); |
| 273 | - // 是否在平移过程中禁止动画。(自1.2新增) | |
| 274 | - var PanOptions_ = {noAnimation: true}; | |
| 275 | 268 | // 将地图的中心点更改为给定的点。 |
| 276 | - mapBValue.panTo(point, PanOptions_); | |
| 277 | - // mapBValue.panBy(10, -150, PanOptions_); | |
| 269 | + mapBValue.panTo(point); | |
| 278 | 270 | } |
| 279 | 271 | }, |
| 280 | 272 | |
| 281 | - editPolyUpline: function () { | |
| 282 | - // 禁止覆盖物在map.clearOverlays方法中被清除。(自 1.1 新增) | |
| 283 | - polyUpline.disableMassClear(); | |
| 284 | - WorldsBMap.clearMarkAndOverlays(); | |
| 285 | - // 允许覆盖物在map.clearOverlays方法中被清除。(自 1.1 新增) | |
| 286 | - polyUpline.enableMassClear(); | |
| 287 | - // 开启线路编辑 | |
| 288 | - polyUpline.enableEditing(); | |
| 289 | - // 添加双击折线保存事件 | |
| 290 | - polyUpline.addEventListener('dblclick', function (e) { | |
| 291 | - // 关闭 | |
| 292 | - layer.closeAll(); | |
| 293 | - polyUpline.disableEditing(); | |
| 294 | - // 获取折线坐标集合 | |
| 295 | - var editPloyLineArray = polyUpline.getPath(); | |
| 296 | - EditSectionObj.setEitdBsectionVector(JSON.stringify(editPloyLineArray)); | |
| 297 | - polyUpline = ''; | |
| 298 | - // 加载修改路段弹出层mobal页面 | |
| 299 | - $.get('editsection.html', function (m) { | |
| 300 | - $(pjaxContainer).append(m); | |
| 301 | - $('#edit_section_mobal').trigger('editSectionMobal_show', [WorldsBMap, GetAjaxData, EditSectionObj, PublicFunctions]); | |
| 302 | - }); | |
| 303 | - }); | |
| 304 | - }, | |
| 305 | - | |
| 306 | 273 | // 根据地理名称获取百度经纬度坐标 |
| 307 | 274 | localSearchFromAdreesToPoint: function (Address, callback) { |
| 308 | - | |
| 309 | 275 | // 创建一个搜索类实例 |
| 310 | 276 | var localSearch = new BMap.LocalSearch(mapBValue); |
| 311 | - | |
| 312 | 277 | // 检索完成后的回调函数。 |
| 313 | 278 | localSearch.setSearchCompleteCallback(function (searchResult) { |
| 314 | - | |
| 315 | 279 | var resultPoints = ''; |
| 316 | - | |
| 317 | 280 | if (searchResult) { |
| 318 | - | |
| 319 | 281 | // 返回索引指定的结果。索引0表示第1条结果 |
| 320 | 282 | var poi = searchResult.getPoi(0); |
| 321 | - | |
| 322 | 283 | if (poi) { |
| 323 | - | |
| 324 | 284 | //获取经度和纬度 |
| 325 | 285 | resultPoints = poi.point.lng + ' ' + poi.point.lat; |
| 326 | - | |
| 327 | 286 | callback && callback(resultPoints); |
| 328 | - | |
| 329 | 287 | } else { |
| 330 | - | |
| 331 | 288 | callback && callback(false); |
| 332 | - | |
| 333 | 289 | } |
| 334 | - | |
| 335 | 290 | } else { |
| 336 | - | |
| 337 | 291 | callback && callback(false); |
| 338 | 292 | } |
| 339 | - | |
| 340 | 293 | }); |
| 341 | - | |
| 342 | 294 | // 根据检索词发起检索。 |
| 343 | 295 | localSearch.search(Address); |
| 344 | - | |
| 345 | 296 | }, |
| 346 | 297 | |
| 347 | - // 编辑图形 | |
| 298 | + // 编辑站点 | |
| 348 | 299 | editShapes: function (obj) { |
| 349 | 300 | // 关闭信息窗口 |
| 350 | 301 | mapBValue.closeInfoWindow(); |
| 351 | - | |
| 352 | 302 | // 清除marker |
| 353 | 303 | // mapBValue.removeOverlay(marker); |
| 354 | 304 | var station = obj.getEitdStation(); |
| 355 | 305 | var stationShapesTypeV = station.stationShapesType; |
| 306 | + setDragMarker(stationMarkers[station.stationRouteId]); | |
| 356 | 307 | // 编辑圆 |
| 357 | 308 | if (stationShapesTypeV == 'r') { |
| 358 | - | |
| 359 | 309 | // 获取中心坐标点字符串分割 |
| 360 | 310 | var BJwpoints = station.stationJwpoints.split(' '); |
| 361 | 311 | // 中心坐标点 |
| 362 | 312 | var point = new BMap.Point(BJwpoints[0], BJwpoints[1]); |
| 363 | 313 | //创建圆 |
| 364 | - circle = new BMap.Circle(point, station.stationRadius, { | |
| 314 | + var circle = new BMap.Circle(point, station.stationRadius, { | |
| 365 | 315 | strokeColor: "blue", |
| 366 | 316 | strokeWeight: 2, |
| 367 | 317 | strokeOpacity: 0.7 |
| 368 | 318 | }); |
| 319 | + mapBValue.centerAndZoom(point, 18); | |
| 320 | + editCircle = circle; | |
| 369 | 321 | // 允许覆盖物在map.clearOverlays方法中被清除 |
| 370 | 322 | circle.enableMassClear(); |
| 371 | 323 | // 百度地图添加覆盖物圆 |
| ... | ... | @@ -378,7 +330,7 @@ window.WorldsBMap = function () { |
| 378 | 330 | var newRadius = circle.getRadius(); |
| 379 | 331 | // 返回圆形的中心点坐标。 |
| 380 | 332 | var newCenter = circle.getCenter().lng + ' ' + circle.getCenter().lat; |
| 381 | - var centre_New = [{potion: {lng: circle.getCenter().lng, lat: circle.getCenter().lat}}]; | |
| 333 | + // var centre_points = [{potion: {lng: circle.getCenter().lng, lat: circle.getCenter().lat}}]; | |
| 382 | 334 | /** 设置修改站点集合对象站点中心点百度坐标属性值 @param:<bJwpoints:中心点百度坐标) */ |
| 383 | 335 | EditStationObj.setEitdStationJwpoints(newCenter); |
| 384 | 336 | /** 设置修改站点集合对象范围图形类型属性值 @param:<shapesType:范围图形类型) */ |
| ... | ... | @@ -387,13 +339,14 @@ window.WorldsBMap = function () { |
| 387 | 339 | EditStationObj.setEitdStationRadius(Math.round(newRadius)); |
| 388 | 340 | /** 设置修改站点集合对象图形百度坐标集合属性值 @param:<bPolygonGrid:图形百度坐标集合) */ |
| 389 | 341 | EditStationObj.setEitdBPolygonGrid(''); |
| 342 | + // 清除正在编辑的站点 | |
| 343 | + editCircle = null; | |
| 390 | 344 | // 加载编辑页面 |
| 391 | 345 | $.get('edit.html', function (m) { |
| 392 | 346 | $(pjaxContainer).append(m); |
| 393 | 347 | $('#edit_station_mobal').trigger('editSelectMobal_show', [WorldsBMap, GetAjaxData, EditStationObj, LineObj, PublicFunctions]); |
| 394 | 348 | }); |
| 395 | 349 | }); |
| 396 | - | |
| 397 | 350 | // 编辑多变行 |
| 398 | 351 | } else if (stationShapesTypeV == 'd') { |
| 399 | 352 | // 获取中心点坐标字符串 |
| ... | ... | @@ -413,9 +366,8 @@ window.WorldsBMap = function () { |
| 413 | 366 | for (var v = 0; v < pointPolygonArray.length; v++) { |
| 414 | 367 | polygonP.push(new BMap.Point(pointPolygonArray[v].split(" ")[0], pointPolygonArray[v].split(" ")[1])); |
| 415 | 368 | } |
| 416 | - | |
| 417 | 369 | // 画多边形 |
| 418 | - polygon = new BMap.Polygon(polygonP, { | |
| 370 | + var polygon = new BMap.Polygon(polygonP, { | |
| 419 | 371 | // 线条显色 |
| 420 | 372 | strokeColor: "blue", |
| 421 | 373 | // 边线的宽度,以像素为单位。 |
| ... | ... | @@ -423,92 +375,46 @@ window.WorldsBMap = function () { |
| 423 | 375 | // 边线透明度,取值范围0 - 1。 |
| 424 | 376 | strokeOpacity: 0.7 |
| 425 | 377 | }); |
| 426 | - | |
| 378 | + mapBValue.centerAndZoom(pointPolygon, 18); | |
| 379 | + editPolygon = polygon; | |
| 427 | 380 | // 增加地图覆盖物多边形 |
| 428 | 381 | mapBValue.addOverlay(polygon); |
| 429 | - | |
| 430 | 382 | // 开启编辑功能(自 1.1 新增) |
| 431 | 383 | polygon.enableEditing(); |
| 432 | - | |
| 433 | 384 | // 添加多变行编辑事件 |
| 434 | 385 | polygon.addEventListener('dblclick', function (e) { |
| 435 | - | |
| 436 | 386 | // 获取编辑的多边形对象 |
| 437 | 387 | var edit_pointE = polygon; |
| 438 | - | |
| 439 | 388 | var edit_bPloygonGrid = ""; |
| 440 | - | |
| 441 | 389 | var editPolyGonLen_ = edit_pointE.getPath().length; |
| 442 | - | |
| 443 | 390 | for (var k = 0; k < editPolyGonLen_; k++) { |
| 444 | - | |
| 445 | 391 | if (k == 0) { |
| 446 | - | |
| 447 | 392 | edit_bPloygonGrid = edit_pointE.getPath()[k].lng + ' ' + edit_pointE.getPath()[k].lat; |
| 448 | - | |
| 449 | 393 | } else { |
| 450 | - | |
| 451 | 394 | edit_bPloygonGrid = edit_bPloygonGrid + ',' + edit_pointE.getPath()[k].lng + ' ' + edit_pointE.getPath()[k].lat; |
| 452 | - | |
| 453 | 395 | } |
| 454 | - | |
| 455 | 396 | } |
| 456 | - | |
| 457 | 397 | edit_bPloygonGrid = edit_bPloygonGrid + ',' + edit_pointE.getPath()[0].lng + ' ' + edit_pointE.getPath()[0].lat; |
| 458 | - | |
| 459 | 398 | // 多边形中心点 |
| 460 | - var centre_points = edit_pointE.getBounds().getCenter().lng + ' ' + edit_pointE.getBounds().getCenter().lat; | |
| 461 | - | |
| 462 | - /** 设置修改站点集合对象站点中心点百度坐标属性值 @param:<bJwpoints:中心点百度坐标) */ | |
| 463 | - EditStationObj.setEitdStationJwpoints(centre_points); | |
| 464 | - | |
| 399 | + // var centre = edit_pointE.getBounds().getCenter().lng + ' ' + edit_pointE.getBounds().getCenter().lat; | |
| 400 | + /** 设置修改站点集合对象站点中心点百度坐标属性值 @param:<bJwpoints:中心点百度坐标) centerPoint可拖动点 */ | |
| 401 | + EditStationObj.setEitdStationJwpoints(centerPoint.lng+' '+centerPoint.lat); | |
| 465 | 402 | /** 设置修改站点集合对象范围图形类型属性值 @param:<shapesType:范围图形类型) */ |
| 466 | 403 | EditStationObj.setEitdStationShapesType('d'); |
| 467 | - | |
| 468 | 404 | /** 设置修改站点集合对象圆形半径属性值 @param:<radius:圆形半径) */ |
| 469 | 405 | EditStationObj.setEitdStationRadius(''); |
| 470 | - | |
| 471 | 406 | /** 设置修改站点集合对象图形百度坐标集合属性值 @param:<bPolygonGrid:图形百度坐标集合) */ |
| 472 | 407 | EditStationObj.setEitdBPolygonGrid(edit_bPloygonGrid); |
| 473 | - | |
| 408 | + // 清除正在编辑的站点 | |
| 409 | + editPolygon = null; | |
| 474 | 410 | $.get('edit.html', function (m) { |
| 475 | - | |
| 476 | 411 | $(pjaxContainer).append(m); |
| 477 | - | |
| 478 | 412 | $('#edit_station_mobal').trigger('editSelectMobal_show', [WorldsBMap, GetAjaxData, EditStationObj, LineObj, PublicFunctions]); |
| 479 | - | |
| 480 | 413 | }); |
| 481 | - | |
| 482 | 414 | }); |
| 483 | - | |
| 484 | 415 | } |
| 485 | - | |
| 486 | 416 | }, |
| 487 | 417 | |
| 488 | - // 在地图上画出上行线路走向 | |
| 489 | - /*drawingUpline: function (polylineArray, polyline_center, data) { | |
| 490 | - /!*WorldsBMap.clearMarkAndOverlays();*!/ | |
| 491 | - polyUpline = ''; | |
| 492 | - // 创建线路走向 | |
| 493 | - polyUpline = new BMap.Polyline(polylineArray, {strokeColor: "red", strokeWeight: 6, strokeOpacity: 0.7}); | |
| 494 | - // polyUpline.data = data; | |
| 495 | - // 把折线添加到地图上 | |
| 496 | - mapBValue.addOverlay(polyUpline); | |
| 497 | - /!*var ceter_index = Math.round(resultdata.length / 2); | |
| 498 | - | |
| 499 | - var ceterPointsStr = resultdata[ceter_index].bJwpoints; | |
| 500 | - | |
| 501 | - var ceterPointsArray = ceterPointsStr.split(' '); | |
| 502 | - | |
| 503 | - var polyline_center = new BMap.Point(ceterPointsArray[0],ceterPointsArray[1]);*!/ | |
| 504 | - var PanOptions_ = {noAnimation: true}; | |
| 505 | - mapBValue.reset(); | |
| 506 | - mapBValue.panTo(polyline_center, PanOptions_); | |
| 507 | - mapBValue.panBy(500, -510, PanOptions_); | |
| 508 | - mapBValue.setZoom(14); | |
| 509 | - },*/ | |
| 510 | - | |
| 511 | - | |
| 512 | 418 | // 画路段走向 |
| 513 | 419 | drawingUpline01: function (polyline_center, datas) { |
| 514 | 420 | if (polyline_center && datas) { |
| ... | ... | @@ -558,8 +464,9 @@ window.WorldsBMap = function () { |
| 558 | 464 | }); |
| 559 | 465 | sectionArray.push(polyUpline01); |
| 560 | 466 | } |
| 561 | - mapBValue.setCenter(polyline_center); | |
| 562 | - mapBValue.setZoom(15); | |
| 467 | + // mapBValue.setCenter(polyline_center); | |
| 468 | + mapBValue.panTo(polyline_center); | |
| 469 | + // mapBValue.setZoom(15); | |
| 563 | 470 | // 禁止覆盖物在map.clearOverlays方法中被清除。(自 1.1 新增) |
| 564 | 471 | // polyUpline01.disableMassClear(); |
| 565 | 472 | } |
| ... | ... | @@ -595,6 +502,7 @@ window.WorldsBMap = function () { |
| 595 | 502 | WorldsBMap.openStationInfoWin(station); |
| 596 | 503 | }); |
| 597 | 504 | stationArray[station.stationRouteId] = station; |
| 505 | + stationMarkers[station.stationRouteId] = myRichMarker1; | |
| 598 | 506 | }, |
| 599 | 507 | |
| 600 | 508 | // 站点名称获取百度坐标(手动规划) |
| ... | ... | @@ -725,99 +633,44 @@ window.WorldsBMap = function () { |
| 725 | 633 | localtionPoint: function (stationNameV) { |
| 726 | 634 | // 关闭信息窗口 |
| 727 | 635 | mapBValue.closeInfoWindow(); |
| 728 | - | |
| 729 | 636 | WorldsBMap.localSearchFromAdreesToPoint(stationNameV, function (Points) { |
| 730 | - | |
| 731 | 637 | if (Points) { |
| 732 | - | |
| 733 | 638 | var BJwpointsArray = Points.split(' '); |
| 734 | - | |
| 735 | 639 | var stationNameChangePoint = new BMap.Point(BJwpointsArray[0], BJwpointsArray[1]); |
| 736 | - | |
| 737 | 640 | var marker_stargt2 = new BMap.Marker(stationNameChangePoint); |
| 738 | - | |
| 739 | - var PanOptions = {noAnimation: true}; | |
| 740 | - | |
| 741 | - mapBValue.panTo(stationNameChangePoint, PanOptions); | |
| 742 | - | |
| 743 | - mapBValue.panBy(0, -100); | |
| 744 | - | |
| 641 | + mapBValue.panTo(stationNameChangePoint); | |
| 745 | 642 | // 将标注添加到地图中 |
| 746 | 643 | mapBValue.addOverlay(marker_stargt2); |
| 747 | - | |
| 748 | 644 | //跳动的动画 |
| 749 | 645 | marker_stargt2.setAnimation(BMAP_ANIMATION_BOUNCE); |
| 750 | - | |
| 751 | 646 | } |
| 752 | - | |
| 753 | 647 | }); |
| 754 | - | |
| 755 | 648 | }, |
| 756 | 649 | |
| 757 | 650 | /** 系统规划抓去数据 @param lineNameValue:线路名称;i:方向*/ |
| 758 | 651 | getBmapStationNames: function (lineNameValue, i, callback) { |
| 759 | - | |
| 760 | 652 | var busline = new BMap.BusLineSearch(mapBValue, { |
| 761 | - | |
| 762 | 653 | // 设置公交列表查询后的回调函数。参数:rs: BusListResult类型 |
| 763 | 654 | onGetBusListComplete: function (BusListResult) { |
| 764 | - | |
| 765 | 655 | // 如果不为空 |
| 766 | 656 | if (BusListResult) { |
| 767 | - | |
| 768 | 657 | //获取第一个公交列表显示到map上 |
| 769 | 658 | var fstLine = BusListResult.getBusListItem(i); |
| 770 | - | |
| 771 | - /*if(fstLine==undefined){ | |
| 772 | - | |
| 773 | - layer.confirm('系统无法生成该线路【'+lineNameValue+'】的站点与路段!请点击返回选择其它方式规划', {btn : [ '返回' ],icon: 3, title:'提示' }, function(index){ | |
| 774 | - | |
| 775 | - layer.closeAll(); | |
| 776 | - | |
| 777 | - if(i==0){ | |
| 778 | - | |
| 779 | - $('#upToolsMobal').show(); | |
| 780 | - | |
| 781 | - }else if(i==1){ | |
| 782 | - | |
| 783 | - $('#downToolsMobal').show(); | |
| 784 | - | |
| 785 | - } | |
| 786 | - | |
| 787 | - return; | |
| 788 | - }); | |
| 789 | - | |
| 790 | - }*/ | |
| 791 | - | |
| 792 | 659 | if (fstLine == undefined) { |
| 793 | - | |
| 794 | - | |
| 795 | 660 | callback && callback(null); |
| 796 | - | |
| 797 | 661 | } |
| 798 | - | |
| 799 | 662 | busline.getBusLine(fstLine); |
| 800 | - | |
| 801 | 663 | } |
| 802 | - | |
| 803 | 664 | }, |
| 804 | - | |
| 805 | 665 | //设置公交线路查询后的回调函数.参数:rs: BusLine类型 |
| 806 | 666 | onGetBusLineComplete: function (BusLine) { |
| 807 | - | |
| 808 | 667 | // 如果不为空 |
| 809 | 668 | if (BusLine) { |
| 810 | - | |
| 811 | 669 | callback && callback(BusLine); |
| 812 | - | |
| 813 | 670 | } |
| 814 | - | |
| 815 | 671 | } |
| 816 | - | |
| 817 | 672 | }); |
| 818 | - | |
| 819 | 673 | busline.getBusList(lineNameValue); |
| 820 | - | |
| 821 | 674 | }, |
| 822 | 675 | // 修改站点 |
| 823 | 676 | editStation: function (stationRouteId) { |
| ... | ... | @@ -952,6 +805,9 @@ window.WorldsBMap = function () { |
| 952 | 805 | break; |
| 953 | 806 | } |
| 954 | 807 | } |
| 808 | + // 路段中间点为中心 | |
| 809 | + var c = p.ia[Math.floor(p.ia.length/2)]; | |
| 810 | + mapBValue.centerAndZoom(new BMap.Point(c.lng, c.lat), 18); | |
| 955 | 811 | p.addEventListener('dblclick', function () { |
| 956 | 812 | /** 设置修改路段集合对象为空 */ |
| 957 | 813 | editPolyline = ''; |
| ... | ... | @@ -1230,8 +1086,7 @@ window.WorldsBMap = function () { |
| 1230 | 1086 | }); |
| 1231 | 1087 | //开启信息窗口 |
| 1232 | 1088 | mapBValue.openInfoWindow(infoWindow_target, centerPoint); |
| 1233 | - mapBValue.setZoom(18); | |
| 1234 | - mapBValue.setCenter(centerPoint); | |
| 1089 | + mapBValue.panTo(centerPoint); | |
| 1235 | 1090 | }, |
| 1236 | 1091 | /** |
| 1237 | 1092 | * 绘制新增路段 |
| ... | ... | @@ -1310,7 +1165,7 @@ window.WorldsBMap = function () { |
| 1310 | 1165 | strGetLength: function (str) { |
| 1311 | 1166 | return str.replace(/[\u0391-\uFFE5]/g, "aa").length; //先把中文替换成两个字节的英文,在计算长度 |
| 1312 | 1167 | } |
| 1313 | - } | |
| 1168 | + }; | |
| 1314 | 1169 | |
| 1315 | 1170 | return Bmap; |
| 1316 | 1171 | ... | ... |
src/main/resources/static/pages/base/stationroute/list.html
src/main/resources/static/pages/base/timesmodel/js/v2/AdjustTripStrategy.js
0 → 100644
| 1 | +//------------------ 策略模块(以下) -----------------// | |
| 2 | + | |
| 3 | +var AdjustTripS1 = (function() { | |
| 4 | + | |
| 5 | + function _f1(aBc, schedule, paramObj, fre) { | |
| 6 | + if (fre > 0) { | |
| 7 | + aBc.sort(function (o1, o2) { | |
| 8 | + if (o1.getFcTimeObj().isBefore(o2.getFcTimeObj())) { | |
| 9 | + return -1; | |
| 10 | + } else { | |
| 11 | + return 1; | |
| 12 | + } | |
| 13 | + }); | |
| 14 | + | |
| 15 | + var i; | |
| 16 | + var j; | |
| 17 | + | |
| 18 | + var iBcCountOfGroup = 3; // 3个班次取一次计算 | |
| 19 | + var aBcOfGroup; // 3个班次列表 | |
| 20 | + var aBcIntervalOfGroup; // 班次间隔列表,如:3个班次,2个间隔 | |
| 21 | + var oBcFcTime; // 班次发车时间 | |
| 22 | + | |
| 23 | + for (i = 0; i <= aBc.length - iBcCountOfGroup; i++) { | |
| 24 | + aBcOfGroup = []; | |
| 25 | + aBcIntervalOfGroup = []; | |
| 26 | + for (j = i; j < i + iBcCountOfGroup; j++) { | |
| 27 | + aBcOfGroup.push(aBc[j]); | |
| 28 | + } | |
| 29 | + | |
| 30 | + for (j = 0; j < aBcOfGroup.length; j++) { | |
| 31 | + if (j < aBcOfGroup.length - 1) { | |
| 32 | + aBcIntervalOfGroup.push(aBcOfGroup[j + 1].getFcTimeObj().diff( | |
| 33 | + aBcOfGroup[j].getFcTimeObj(), "m")); | |
| 34 | + } | |
| 35 | + } | |
| 36 | + | |
| 37 | + // 判定规则 | |
| 38 | + oBcFcTime = aBcOfGroup[1].getFcTimeObj(); | |
| 39 | + | |
| 40 | + // 第一个班次发车时间不动,根据间隔,调整中间一个班次 | |
| 41 | + // 如果3个班次2个间隔时间差1分钟,不调整 | |
| 42 | + // 如果第一个间隔大,调整第二个班次往前1分钟 | |
| 43 | + // 如果第二个间隔大,调整第二个班次往后1分钟 | |
| 44 | + | |
| 45 | + if (paramObj.isTroughBc(oBcFcTime) && | |
| 46 | + aBcIntervalOfGroup[0] > paramObj.getTroughMaxFcjx()) { | |
| 47 | + | |
| 48 | + // aBcOfGroup[1].addMinuteToFcsj(-1); | |
| 49 | + | |
| 50 | + // 判定是否能调整发车时间 | |
| 51 | + // if (aBcOfGroup[1].getGroup().getLp().isModifyBcFcsj(aBcOfGroup[1], -1, _paramObj)) { | |
| 52 | + aBcOfGroup[1]._$_fcsjObj.add(-1, "m"); | |
| 53 | + aBcOfGroup[1].setArrTimeObj(paramObj.addMinute( | |
| 54 | + aBcOfGroup[1].getFcTimeObj(), | |
| 55 | + paramObj.calcuTravelTime( | |
| 56 | + aBcOfGroup[1].getFcTimeObj(), | |
| 57 | + aBcOfGroup[1].isUp()) | |
| 58 | + )); | |
| 59 | + | |
| 60 | + // } | |
| 61 | + } | |
| 62 | + | |
| 63 | + //else if (_paramObj.isMPeakBc(oBcFcTime) && | |
| 64 | + // aBcIntervalOfGroup[0] < _paramObj.getMPeakMinFcjx()) { | |
| 65 | + // aBcOfGroup[1].addMinuteToFcsj(1); | |
| 66 | + //} else if (_paramObj.isMPeakBc(oBcFcTime) && | |
| 67 | + // aBcIntervalOfGroup[0] > _paramObj.getMPeakMaxFcjx()) { | |
| 68 | + // aBcOfGroup[1].addMinuteToFcsj(-1); | |
| 69 | + //} else if (_paramObj.isEPeakBc(oBcFcTime) && | |
| 70 | + // aBcIntervalOfGroup[0] < _paramObj.getEPeakMinFcjx()) { | |
| 71 | + // aBcOfGroup[1].addMinuteToFcsj(1); | |
| 72 | + //} else if (_paramObj.isEPeakBc(oBcFcTime) && | |
| 73 | + // aBcIntervalOfGroup[0] > _paramObj.getEPeakMaxFcjx()) { | |
| 74 | + // aBcOfGroup[1].addMinuteToFcsj(-1); | |
| 75 | + //} | |
| 76 | + | |
| 77 | + | |
| 78 | + else { | |
| 79 | + if (Math.abs(aBcIntervalOfGroup[0] - aBcIntervalOfGroup[1]) <= 1) { | |
| 80 | + //continue; | |
| 81 | + } else if (aBcIntervalOfGroup[0] > aBcIntervalOfGroup[1]) { | |
| 82 | + | |
| 83 | + | |
| 84 | + // 判定是否能调整发车时间 | |
| 85 | + // if (aBcOfGroup[1].getGroup().getLp().isModifyBcFcsj(aBcOfGroup[1], -1, _paramObj)) { | |
| 86 | + aBcOfGroup[1]._$_fcsjObj.add(-1, "m"); | |
| 87 | + aBcOfGroup[1].setArrTimeObj(paramObj.addMinute( | |
| 88 | + aBcOfGroup[1].getFcTimeObj(), | |
| 89 | + paramObj.calcuTravelTime( | |
| 90 | + aBcOfGroup[1].getFcTimeObj(), | |
| 91 | + aBcOfGroup[1].isUp()) | |
| 92 | + )); | |
| 93 | + // } | |
| 94 | + | |
| 95 | + // aBcOfGroup[1].addMinuteToFcsj(-1); | |
| 96 | + } else { | |
| 97 | + // aBcOfGroup[1].addMinuteToFcsj(1); | |
| 98 | + | |
| 99 | + // 判定是否能调整发车时间 | |
| 100 | + // if (aBcOfGroup[1].getGroup().getLp().isModifyBcFcsj(aBcOfGroup[1], 1, _paramObj)) { | |
| 101 | + aBcOfGroup[1]._$_fcsjObj.add(1, "m"); | |
| 102 | + aBcOfGroup[1].setArrTimeObj(paramObj.addMinute( | |
| 103 | + aBcOfGroup[1].getFcTimeObj(), | |
| 104 | + paramObj.calcuTravelTime( | |
| 105 | + aBcOfGroup[1].getFcTimeObj(), | |
| 106 | + aBcOfGroup[1].isUp()) | |
| 107 | + )); | |
| 108 | + // } | |
| 109 | + } | |
| 110 | + } | |
| 111 | + | |
| 112 | + //if (Math.abs(aBcIntervalOfGroup[0] - aBcIntervalOfGroup[1]) <= 1) { | |
| 113 | + // //continue; | |
| 114 | + //} else if (aBcIntervalOfGroup[0] > aBcIntervalOfGroup[1]) { | |
| 115 | + // aBcOfGroup[1].addMinuteToFcsj(-1); | |
| 116 | + //} else { | |
| 117 | + // aBcOfGroup[1].addMinuteToFcsj(1); | |
| 118 | + //} | |
| 119 | + | |
| 120 | + | |
| 121 | + } | |
| 122 | + | |
| 123 | + _f1(aBc, schedule, paramObj, fre - 1); | |
| 124 | + | |
| 125 | + } | |
| 126 | + } | |
| 127 | + | |
| 128 | + | |
| 129 | + function f1(aUpBc, aDownBc, schedule, paramObj) { | |
| 130 | + // TODO:9、调整纵向班次间隔 | |
| 131 | + _f1(aUpBc, schedule, paramObj, 5); | |
| 132 | + _f1(aDownBc, schedule, paramObj, 5); | |
| 133 | + | |
| 134 | + schedule.fnAdjustLpBcInterval(1); | |
| 135 | + | |
| 136 | + _f1(aUpBc, schedule, paramObj, 5); | |
| 137 | + _f1(aDownBc, schedule, paramObj, 5); | |
| 138 | + } | |
| 139 | + | |
| 140 | + return f1; | |
| 141 | +}()); | |
| 142 | + | |
| 143 | +//------------------ 策略模块(以上) -----------------// | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | +// 调整班次策略类 | |
| 150 | +var AdjustTripStrategy = (function() { | |
| 151 | + | |
| 152 | + /** | |
| 153 | + * 内部策略配置封装类。 | |
| 154 | + * @constructor | |
| 155 | + */ | |
| 156 | + function InternalStrategy() { | |
| 157 | + // 策略函数对应,每个函数都由一个标识符号对应,类似配置函数 | |
| 158 | + this._oSTRATIGIS = { | |
| 159 | + "ADJUST_TRIP": AdjustTripS1 | |
| 160 | + }; | |
| 161 | + } | |
| 162 | + | |
| 163 | + /** | |
| 164 | + * 返回策略函数 | |
| 165 | + * @param str 标识 | |
| 166 | + * @returns {function} | |
| 167 | + */ | |
| 168 | + InternalStrategy.prototype.sFn = function(str) { | |
| 169 | + if (!this._oSTRATIGIS[str]) { | |
| 170 | + throw "指定标识" + str + "策略函数不存在!"; | |
| 171 | + } | |
| 172 | + return this._oSTRATIGIS[str]; | |
| 173 | + }; | |
| 174 | + /** | |
| 175 | + * 替换策略配置 | |
| 176 | + * @param str 策略函数标识 | |
| 177 | + * @param fn 策略函数 | |
| 178 | + */ | |
| 179 | + InternalStrategy.prototype.sConfig = function(str, fn) { | |
| 180 | + this._oSTRATIGIS[str] = fn; | |
| 181 | + }; | |
| 182 | + | |
| 183 | + return new InternalStrategy(); | |
| 184 | +}()); | |
| 0 | 185 | \ No newline at end of file | ... | ... |
src/main/resources/static/pages/base/timesmodel/js/v2/core/InternalLpObj.js
| 1 | -/** | |
| 2 | - * 内部路牌对象。 | |
| 3 | - * @constructor | |
| 4 | - */ | |
| 5 | -var InternalLpObj = function( | |
| 6 | - orilpObj, // 原始路牌对象 | |
| 7 | - qCount, // 总共多少圈 | |
| 8 | - isUp // 圈是以上行开始还是下行开始 | |
| 9 | -) { | |
| 10 | - // TODO:原始路牌对象(这个路牌是对接外部gantt图像,以后有机会改了) | |
| 11 | - this._$$_orign_lp_obj = orilpObj; | |
| 12 | - | |
| 13 | - this._$_isUp = isUp; | |
| 14 | - | |
| 15 | - // 路牌的圈数,注意每个路牌的圈数都是一致的, | |
| 16 | - // 但并不是每一圈都有值 | |
| 17 | - // 第1圈从上标线开始 | |
| 18 | - // 第0圈表示中标线的第一个班次组成的半圈 | |
| 19 | - // 有多少圈根据最终迭代的结果来看 | |
| 20 | - this._$_qCount = qCount; | |
| 21 | - // 保存的是 InternalGroupBcObj 对象 | |
| 22 | - this._$_groupBcArray = new Array(qCount); | |
| 23 | - | |
| 24 | - var i; | |
| 25 | - for (i = 0; i < this._$_qCount; i++) { | |
| 26 | - this._$_groupBcArray[i] = new InternalGroupObj( | |
| 27 | - this, this._$_isUp, undefined, undefined); | |
| 28 | - } | |
| 29 | - | |
| 30 | - // 距离上一个路牌的最小发车间隔时间 | |
| 31 | - // 用于纵向添加班次的时候使用 | |
| 32 | - // 默认第一个路牌为0 | |
| 33 | - this._$_minVerticalIntervalTime = 0; | |
| 34 | - | |
| 35 | - // 详细记录每圈每个方向上的发车间隔时间 | |
| 36 | - // 第一维度表示圈数,第二维度表示第一个方向,第二个方向 | |
| 37 | - // 第一个方向是否上行由 _$_isUp 决定 | |
| 38 | - // 这里的间隔表示下一个路牌上的班次距离本路牌的班次发车时间间隔 | |
| 39 | - // 如果当前是最后一个路牌,表示第一个路牌的下一圈同方向班次距离本班次的间隔 | |
| 40 | - this._$_aVerticalIntervalTime = new Array(this._$_qCount); | |
| 41 | - for (i = 0; i < this._$_aVerticalIntervalTime.length; i++) { | |
| 42 | - this._$_aVerticalIntervalTime[i] = new Array(2); | |
| 43 | - } | |
| 44 | - | |
| 45 | - // 班型的相关变量 | |
| 46 | - this._$_bx_isLb = false; // 是否连班 | |
| 47 | - this._$_bx_isfb = false; // 是否分班 | |
| 48 | - this._$_bx_isfb_5_2 = false; // 是否5休2分班 | |
| 49 | - this._$_bx_desc; // 班型描述(默认为路牌编号) | |
| 50 | - | |
| 51 | - // 其他班次(进出场,例包,吃饭等),TODO:以后再拆 | |
| 52 | - this._$_other_bc_array = []; | |
| 53 | - | |
| 54 | - // TODO: | |
| 55 | - | |
| 56 | -}; | |
| 57 | - | |
| 58 | -//------------------- get/set 方法 -------------------// | |
| 59 | - | |
| 60 | -InternalLpObj.prototype.getOtherBcArray = function() { | |
| 61 | - return this._$_other_bc_array; | |
| 62 | -}; | |
| 63 | -InternalLpObj.prototype.addOtherBcArray = function(ba) { | |
| 64 | - this._$_other_bc_array = this._$_other_bc_array.concat(ba); | |
| 65 | -}; | |
| 66 | - | |
| 67 | -/** | |
| 68 | - * 获取圈 | |
| 69 | - * @param qIndex 圈index | |
| 70 | - */ | |
| 71 | -InternalLpObj.prototype.getGroup = function(qIndex) { | |
| 72 | - return this._$_groupBcArray[qIndex]; | |
| 73 | -}; | |
| 74 | - | |
| 75 | -/** | |
| 76 | - * 获取路牌圈数。 | |
| 77 | - * @returns {*} | |
| 78 | - */ | |
| 79 | -InternalLpObj.prototype.fnGetGroupCount = function() { | |
| 80 | - return this._$_qCount; | |
| 81 | -}; | |
| 82 | - | |
| 83 | -/** | |
| 84 | - * 是否上行。 | |
| 85 | - * @returns boolean | |
| 86 | - */ | |
| 87 | -InternalLpObj.prototype.isUp = function() { | |
| 88 | - return this._$_isUp; | |
| 89 | -}; | |
| 90 | - | |
| 91 | -/** | |
| 92 | - * 获取班次。 | |
| 93 | - * @param qIndex 第几圈 | |
| 94 | - * @param bcIndex 第几个班次 | |
| 95 | - */ | |
| 96 | -InternalLpObj.prototype.getBc = function(qIndex, bcIndex) { | |
| 97 | - var group = this._$_groupBcArray[qIndex]; | |
| 98 | - var bc; | |
| 99 | - if (bcIndex == 0) { | |
| 100 | - bc = group.getBc1(); | |
| 101 | - } else if (bcIndex == 1) { | |
| 102 | - bc = group.getBc2(); | |
| 103 | - } | |
| 104 | - return bc; | |
| 105 | -}; | |
| 106 | - | |
| 107 | -/** | |
| 108 | - * 在具体位置设置班次。 | |
| 109 | - * @param qIndex 第几圈 | |
| 110 | - * @param bcIndex 第几个班次 | |
| 111 | - * @param bc 班次对象 | |
| 112 | - */ | |
| 113 | -InternalLpObj.prototype.setBc = function(qIndex, bcIndex, bc) { | |
| 114 | - var group = this._$_groupBcArray[qIndex]; | |
| 115 | - if (bcIndex == 0) { | |
| 116 | - group.setBc1(bc); | |
| 117 | - bc.setGroup(group); | |
| 118 | - } else if (bcIndex == 1) { | |
| 119 | - group.setBc2(bc); | |
| 120 | - bc.setGroup(group); | |
| 121 | - } | |
| 122 | -}; | |
| 123 | - | |
| 124 | -/** | |
| 125 | - * 设置原始路牌对象。 | |
| 126 | - * @param lpObj 原始路牌对象 | |
| 127 | - */ | |
| 128 | -InternalLpObj.prototype.setLp = function(lpObj) { | |
| 129 | - this._$$_orign_lp_obj = lpObj; | |
| 130 | - var i; | |
| 131 | - var group; | |
| 132 | - for (i = 0; i < this._$_groupBcArray.length; i++) { | |
| 133 | - group = this._$_groupBcArray[i]; | |
| 134 | - if (group) { | |
| 135 | - group.setLp(this); // 圈和班次保存都是 InternalLpObj 对象 | |
| 136 | - } | |
| 137 | - } | |
| 138 | -}; | |
| 139 | - | |
| 140 | -InternalLpObj.prototype.getLpNo = function() { | |
| 141 | - return this._$$_orign_lp_obj.lpNo; | |
| 142 | -}; | |
| 143 | -InternalLpObj.prototype.getLpName = function() { | |
| 144 | - return this._$$_orign_lp_obj.lpName; | |
| 145 | -}; | |
| 146 | -InternalLpObj.prototype.setBxFb5_2 = function(fb) { | |
| 147 | - this._$_bx_isfb_5_2 = fb; | |
| 148 | -}; | |
| 149 | -InternalLpObj.prototype.isBxFb5_2 = function() { | |
| 150 | - return this._$_bx_isfb_5_2; | |
| 151 | -}; | |
| 152 | -InternalLpObj.prototype.setBxLb = function(lb) { | |
| 153 | - this._$_bx_isLb = lb; | |
| 154 | -}; | |
| 155 | -InternalLpObj.prototype.isBxLb = function() { | |
| 156 | - return this._$_bx_isLb; | |
| 157 | -}; | |
| 158 | - | |
| 159 | -InternalLpObj.prototype.setBxFb = function(fb) { | |
| 160 | - this._$_bx_isfb = fb; | |
| 161 | -}; | |
| 162 | -InternalLpObj.prototype.isBxFb = function() { | |
| 163 | - return this._$_bx_isfb; | |
| 164 | -}; | |
| 165 | - | |
| 166 | -/** | |
| 167 | - * 设置路牌的班型描述(最终是设置班次的路牌名字)。 | |
| 168 | - * @param desc 描述 | |
| 169 | - */ | |
| 170 | -InternalLpObj.prototype.setBxDesc = function(desc) { | |
| 171 | - // 最终原始路牌的名字 | |
| 172 | - this._$$_orign_lp_obj.lpName = desc + "_" + this._$$_orign_lp_obj.lpNo; | |
| 173 | - // 内部对象的班型描述 | |
| 174 | - this._$_bx_desc = desc; | |
| 175 | -}; | |
| 176 | -/** | |
| 177 | - * 获取版型描述 | |
| 178 | - * @returns string | |
| 179 | - */ | |
| 180 | -InternalLpObj.prototype.getBxDesc = function() { | |
| 181 | - return this._$_bx_desc; | |
| 182 | -}; | |
| 183 | - | |
| 184 | -/** | |
| 185 | - * 设置纵向最小发车间隔时间。 | |
| 186 | - * @param v | |
| 187 | - */ | |
| 188 | -InternalLpObj.prototype.setVerticalMinIntervalTime = function(v) { | |
| 189 | - // 第一个路牌,都为0 | |
| 190 | - this._$_minVerticalIntervalTime = v; | |
| 191 | -}; | |
| 192 | -/** | |
| 193 | - * 获取纵向最小发车间隔时间。 | |
| 194 | - * @returns {number|*} | |
| 195 | - */ | |
| 196 | -InternalLpObj.prototype.getVerticalMinIntervalTime = function() { | |
| 197 | - return this._$_minVerticalIntervalTime; | |
| 198 | -}; | |
| 199 | - | |
| 200 | -/** | |
| 201 | - * 设置纵向发车间隔。 | |
| 202 | - * @param iQindex 圈index | |
| 203 | - * @param iBindex 班次index | |
| 204 | - * @param iTime 间隔时间 | |
| 205 | - */ | |
| 206 | -InternalLpObj.prototype.fnSetVerticalIntervalTime = function(iQindex, iBindex, iTime) { | |
| 207 | - this._$_aVerticalIntervalTime[iQindex][iBindex] = iTime; | |
| 208 | -}; | |
| 209 | - | |
| 210 | -/** | |
| 211 | - * 返回纵向发车间隔。 | |
| 212 | - * @param iQindex 圈index | |
| 213 | - * @param iBindex 班次index | |
| 214 | - */ | |
| 215 | -InternalLpObj.prototype.fnGetVerticalIntervalTime = function(iQindex, iBindex) { | |
| 216 | - return this._$_aVerticalIntervalTime[iQindex][iBindex]; | |
| 217 | -}; | |
| 218 | - | |
| 219 | -//-------------------- 班次操作方法(查询,统计,删除) -----------------------// | |
| 220 | - | |
| 221 | -/** | |
| 222 | - * 返回总共班次数。 | |
| 223 | - */ | |
| 224 | -InternalLpObj.prototype.getBcCount = function() { | |
| 225 | - var i; | |
| 226 | - var group; | |
| 227 | - var bccount = 0; | |
| 228 | - for (i = 0; i < this._$_groupBcArray.length; i++) { | |
| 229 | - group = this._$_groupBcArray[i]; | |
| 230 | - if (group) { | |
| 231 | - if (group.getBc1()) { | |
| 232 | - bccount += 1; | |
| 233 | - } | |
| 234 | - if (group.getBc2()) { | |
| 235 | - bccount += 1; | |
| 236 | - } | |
| 237 | - } | |
| 238 | - } | |
| 239 | - | |
| 240 | - return bccount; | |
| 241 | -}; | |
| 242 | - | |
| 243 | -/** | |
| 244 | - * 返回班次列表,过滤空的班次,将所有存在的班次连成连续的对象数组返回。 | |
| 245 | - * @returns arrays (InternalBcObj) | |
| 246 | - */ | |
| 247 | -InternalLpObj.prototype.getBcArray = function() { | |
| 248 | - var bcArray = []; | |
| 249 | - var i; | |
| 250 | - var group; | |
| 251 | - for (i = 0; i < this._$_groupBcArray.length; i++) { | |
| 252 | - group = this._$_groupBcArray[i]; | |
| 253 | - if (group) { | |
| 254 | - group.getBc1() ? bcArray.push(group.getBc1()) : ""; | |
| 255 | - group.getBc2() ? bcArray.push(group.getBc2()) : ""; | |
| 256 | - } | |
| 257 | - } | |
| 258 | - | |
| 259 | - return bcArray; | |
| 260 | -}; | |
| 261 | - | |
| 262 | -/** | |
| 263 | - * 获取最小(最早)班次对象。 | |
| 264 | - * @returns [{圈index},{班次index}] | |
| 265 | - */ | |
| 266 | -InternalLpObj.prototype.getMinBcObjPosition = function() { | |
| 267 | - var i; | |
| 268 | - var bIndex = []; | |
| 269 | - for (i = 0; i < this._$_groupBcArray.length; i++) { | |
| 270 | - if (this._$_groupBcArray[i].getBc1()) { | |
| 271 | - bIndex.push(i); | |
| 272 | - bIndex.push(0); | |
| 273 | - break; | |
| 274 | - } | |
| 275 | - if (this._$_groupBcArray[i].getBc2()) { | |
| 276 | - bIndex.push(i); | |
| 277 | - bIndex.push(1); | |
| 278 | - break; | |
| 279 | - } | |
| 280 | - } | |
| 281 | - return bIndex; | |
| 282 | -}; | |
| 283 | - | |
| 284 | -/** | |
| 285 | - * 获取最大(最晚)班次对象。 | |
| 286 | - * @returns [{圈index},{班次index}] | |
| 287 | - */ | |
| 288 | -InternalLpObj.prototype.getMaxBcObjPosition = function() { | |
| 289 | - var i; | |
| 290 | - var bIndex = []; | |
| 291 | - for (i = this._$_groupBcArray.length - 1; i >= 0; i--) { | |
| 292 | - if (this._$_groupBcArray[i].getBc2()) { | |
| 293 | - bIndex.push(i); | |
| 294 | - bIndex.push(1); | |
| 295 | - break; | |
| 296 | - } | |
| 297 | - if (this._$_groupBcArray[i].getBc1()) { | |
| 298 | - bIndex.push(i); | |
| 299 | - bIndex.push(0); | |
| 300 | - break; | |
| 301 | - } | |
| 302 | - } | |
| 303 | - return bIndex; | |
| 304 | -}; | |
| 305 | - | |
| 306 | -InternalLpObj.prototype.getMinBcObj = function() { | |
| 307 | - var i; | |
| 308 | - var bcObj; | |
| 309 | - for (i = 0; i < this._$_groupBcArray.length; i++) { | |
| 310 | - bcObj = this._$_groupBcArray[i].getBc1(); | |
| 311 | - if (bcObj) { | |
| 312 | - break; | |
| 313 | - } | |
| 314 | - bcObj = this._$_groupBcArray[i].getBc2(); | |
| 315 | - if (bcObj) { | |
| 316 | - break; | |
| 317 | - } | |
| 318 | - } | |
| 319 | - return bcObj; | |
| 320 | -}; | |
| 321 | -InternalLpObj.prototype.getMaxBcObj = function() { | |
| 322 | - var i; | |
| 323 | - var bcObj; | |
| 324 | - for (i = this._$_groupBcArray.length - 1; i >= 0; i--) { | |
| 325 | - bcObj = this._$_groupBcArray[i].getBc2(); | |
| 326 | - if (bcObj) { | |
| 327 | - break; | |
| 328 | - } | |
| 329 | - bcObj = this._$_groupBcArray[i].getBc1(); | |
| 330 | - if (bcObj) { | |
| 331 | - break; | |
| 332 | - } | |
| 333 | - } | |
| 334 | - return bcObj; | |
| 335 | -}; | |
| 336 | - | |
| 337 | -/** | |
| 338 | - * 获取车次链信息。 | |
| 339 | - * @param num 第几个车次链 | |
| 340 | - * @returns object {s_q: {开始圈索引},s_b : {开始班次索引},e_q : {结束圈索引},e_b : {结束班次索引}, bcount : {班次数}} | |
| 341 | - */ | |
| 342 | -InternalLpObj.prototype.fnGetBcChainInfo = function(num) { | |
| 343 | - // 计算总的车次链信息 | |
| 344 | - var aChainInfo = []; | |
| 345 | - var oChainInfo; | |
| 346 | - var aBcIndex = this.getMinBcObjPosition(); | |
| 347 | - var oBc; | |
| 348 | - var iQIndex; | |
| 349 | - var iBcIndex; | |
| 350 | - var i; | |
| 351 | - var bFlag; | |
| 352 | - | |
| 353 | - var iBcount = 0; | |
| 354 | - | |
| 355 | - if (aBcIndex.length == 2) { | |
| 356 | - iBcount = 1; | |
| 357 | - oChainInfo = {s_q : aBcIndex[0], s_b : aBcIndex[1], e_q : aBcIndex[0], e_b : aBcIndex[1], bcount: 1}; | |
| 358 | - aChainInfo.push(oChainInfo); | |
| 359 | - bFlag = true; | |
| 360 | - | |
| 361 | - // 下一个班次的索引 | |
| 362 | - iQIndex = aBcIndex[1] == 0 ? aBcIndex[0] : aBcIndex[0] + 1; | |
| 363 | - iBcIndex = aBcIndex[1] == 0 ? 1 : 0; | |
| 364 | - | |
| 365 | - for (i = iQIndex; i < this._$_qCount; i++) { | |
| 366 | - while (iBcIndex <= 1) { | |
| 367 | - oBc = this.getBc(i, iBcIndex); | |
| 368 | - if (!oBc) { | |
| 369 | - if (bFlag) { | |
| 370 | - // 车次链结尾是这个班次的前一个班次 | |
| 371 | - oChainInfo.e_q = iBcIndex == 0 ? i - 1 : i; | |
| 372 | - oChainInfo.e_b = iBcIndex == 0 ? 1 : 0; | |
| 373 | - oChainInfo.bcount = iBcount; | |
| 374 | - } | |
| 375 | - | |
| 376 | - bFlag = false; | |
| 377 | - } else { | |
| 378 | - if (bFlag) { | |
| 379 | - iBcount ++; | |
| 380 | - oChainInfo.bcount = iBcount; | |
| 381 | - } else { | |
| 382 | - // 下一个车次链开始 | |
| 383 | - iBcount = 1; | |
| 384 | - oChainInfo = {s_q : i, s_b : iBcIndex, e_q : i, e_b : iBcIndex, bcount: 1}; | |
| 385 | - aChainInfo.push(oChainInfo); | |
| 386 | - bFlag = true; | |
| 387 | - } | |
| 388 | - } | |
| 389 | - | |
| 390 | - | |
| 391 | - iBcIndex ++; | |
| 392 | - } | |
| 393 | - iBcIndex = 0; | |
| 394 | - } | |
| 395 | - | |
| 396 | - } | |
| 397 | - | |
| 398 | - return aChainInfo[num]; | |
| 399 | -}; | |
| 400 | - | |
| 401 | -/** | |
| 402 | - * 获取车次链的个数。 | |
| 403 | - * @returns int | |
| 404 | - */ | |
| 405 | -InternalLpObj.prototype.fnGetBcChainCount = function() { | |
| 406 | - var iChainCount = 0; | |
| 407 | - var aBcIndex = this.getMinBcObjPosition(); | |
| 408 | - | |
| 409 | - var oBc; | |
| 410 | - var iQIndex; | |
| 411 | - var iBcIndex; | |
| 412 | - var i; | |
| 413 | - var bFlag; | |
| 414 | - | |
| 415 | - if (aBcIndex.length == 2) { | |
| 416 | - iChainCount = 1; | |
| 417 | - bFlag = true; | |
| 418 | - | |
| 419 | - // 下一个班次的索引 | |
| 420 | - iQIndex = aBcIndex[1] == 0 ? aBcIndex[0] : aBcIndex[0] + 1; | |
| 421 | - iBcIndex = aBcIndex[1] == 0 ? 1 : 0; | |
| 422 | - | |
| 423 | - for (i = iQIndex; i < this._$_qCount; i++) { | |
| 424 | - while (iBcIndex <= 1) { | |
| 425 | - oBc = this.getBc(i, iBcIndex); | |
| 426 | - if (!oBc) { | |
| 427 | - bFlag = false; | |
| 428 | - } else { | |
| 429 | - if (bFlag) { | |
| 430 | - | |
| 431 | - } else { | |
| 432 | - iChainCount ++; | |
| 433 | - bFlag = true; | |
| 434 | - } | |
| 435 | - } | |
| 436 | - | |
| 437 | - | |
| 438 | - iBcIndex ++; | |
| 439 | - } | |
| 440 | - iBcIndex = 0; | |
| 441 | - } | |
| 442 | - | |
| 443 | - } | |
| 444 | - | |
| 445 | - | |
| 446 | - return iChainCount; | |
| 447 | -}; | |
| 448 | - | |
| 449 | -/** | |
| 450 | - * 在具体位置移除班次。 | |
| 451 | - * @param qIndex 第几圈 | |
| 452 | - * @param bcIndex 第几个班次 | |
| 453 | - */ | |
| 454 | -InternalLpObj.prototype.removeBc = function(qIndex, bcIndex) { | |
| 455 | - var group = this._$_groupBcArray[qIndex]; | |
| 456 | - if (bcIndex == 0) { | |
| 457 | - group.removeBc1(); | |
| 458 | - } else if (bcIndex == 1) { | |
| 459 | - group.removeBc2(); | |
| 460 | - } | |
| 461 | -}; | |
| 462 | - | |
| 463 | -/** | |
| 464 | - * 使用指定时间匹配返回离之最近的第几圈第几个班次, | |
| 465 | - * 使用时间差的绝度值,比较,取最小的 | |
| 466 | - * 如果有两个一样的时间差,取比fctime大的时间 | |
| 467 | - * @param fctime moment 比较用时间 | |
| 468 | - * @param groupArray 圈数组 | |
| 469 | - * @param hasUp boolean 计算上行班次 | |
| 470 | - * @param hasDown boolean 计算下行班次 | |
| 471 | - * @returns [{第几圈},{第几个班次}] | |
| 472 | - */ | |
| 473 | -InternalLpObj.prototype.fnGetQBcIndexWithFcTimeFromGroupArray = function( | |
| 474 | - fctime, groupArray, hasUp, hasDown | |
| 475 | -) { | |
| 476 | - var i; | |
| 477 | - var timediff; // 时间差取绝对值 | |
| 478 | - var qIndex; | |
| 479 | - var bcIndex; | |
| 480 | - | |
| 481 | - var group; | |
| 482 | - var bc1time; | |
| 483 | - var bc2time; | |
| 484 | - | |
| 485 | - var tempdiff; | |
| 486 | - | |
| 487 | - console.log("比较时间=" + fctime.format("HH:mm")); | |
| 488 | - | |
| 489 | - var oBc; | |
| 490 | - | |
| 491 | - for (i = 0; i < this._$_qCount; i++) { | |
| 492 | - group = groupArray[i]; | |
| 493 | - if (group) { | |
| 494 | - oBc = group.getBc1(); | |
| 495 | - | |
| 496 | - if (oBc != undefined && ((hasUp && hasDown) || (hasUp && (oBc.isUp() == hasUp)) || (hasDown && (!oBc.isUp() == hasDown)))) { | |
| 497 | - bc1time = group.getBc1().getFcTimeObj(); | |
| 498 | - console.log("bc1time=" + bc1time.format("HH:mm") + " tempdiff=" + tempdiff); | |
| 499 | - tempdiff = Math.abs(bc1time.diff(fctime)); | |
| 500 | - | |
| 501 | - if (!timediff) { | |
| 502 | - timediff = Math.abs(tempdiff); | |
| 503 | - qIndex = i; | |
| 504 | - bcIndex = 0; | |
| 505 | - } else { | |
| 506 | - if (tempdiff < timediff) { | |
| 507 | - timediff = tempdiff; | |
| 508 | - qIndex = i; | |
| 509 | - bcIndex = 0; | |
| 510 | - } if (Math.abs(tempdiff) == timediff) { | |
| 511 | - if (bc1time.isAfter(fctime)) { | |
| 512 | - timediff = tempdiff; | |
| 513 | - qIndex = i; | |
| 514 | - bcIndex = 0; | |
| 515 | - } | |
| 516 | - | |
| 517 | - } | |
| 518 | - } | |
| 519 | - } | |
| 520 | - | |
| 521 | - oBc = group.getBc2(); | |
| 522 | - if (oBc != undefined && ((hasUp && hasDown) || (hasUp && (oBc.isUp() == hasUp)) || (hasDown && (!oBc.isUp() == hasDown)))) { | |
| 523 | - bc2time = group.getBc2().getFcTimeObj(); | |
| 524 | - console.log("bc2time=" + bc2time.format("HH:mm") + " tempdiff=" + tempdiff); | |
| 525 | - tempdiff = Math.abs(bc2time.diff(fctime)); | |
| 526 | - | |
| 527 | - if (!timediff) { | |
| 528 | - timediff = Math.abs(tempdiff); | |
| 529 | - qIndex = i; | |
| 530 | - bcIndex = 1; | |
| 531 | - } else { | |
| 532 | - if (tempdiff < timediff) { | |
| 533 | - timediff = tempdiff; | |
| 534 | - qIndex = i; | |
| 535 | - bcIndex = 1; | |
| 536 | - } if (Math.abs(tempdiff) == timediff) { | |
| 537 | - if (bc2time.isBefore(fctime)) { | |
| 538 | - timediff = tempdiff; | |
| 539 | - qIndex = i; | |
| 540 | - bcIndex = 1; | |
| 541 | - } | |
| 542 | - | |
| 543 | - } | |
| 544 | - } | |
| 545 | - } | |
| 546 | - } | |
| 547 | - } | |
| 548 | - | |
| 549 | - console.log("中标线对应数组索引=" + qIndex); | |
| 550 | - | |
| 551 | - var rst = []; | |
| 552 | - rst.push(qIndex); | |
| 553 | - rst.push(bcIndex); | |
| 554 | - | |
| 555 | - return rst; | |
| 556 | -}; | |
| 557 | - | |
| 558 | -/** | |
| 559 | - * 使用指定时间匹配返回离之最近的第几圈第几个班次, | |
| 560 | - * 使用时间差的绝度值,比较,取最小的 | |
| 561 | - * 如果有两个一样的时间差,取比fctime大的时间 | |
| 562 | - * @param fctime moment 比较用时间 | |
| 563 | - * @param hasUp boolean 计算上行班次 | |
| 564 | - * @param hasDown boolean 计算下行班次 | |
| 565 | - * @returns [{第几圈},{第几个班次}] | |
| 566 | - */ | |
| 567 | -InternalLpObj.prototype.getQBcIndexWithFcTime = function( | |
| 568 | - fctime, hasUp, hasDown | |
| 569 | -) { | |
| 570 | - return this.fnGetQBcIndexWithFcTimeFromGroupArray(fctime, this._$_groupBcArray, hasUp, hasDown); | |
| 571 | -}; | |
| 572 | - | |
| 573 | -//---------------------- 内部数据初始化方法(不同于构造函数)---------------------// | |
| 574 | - | |
| 575 | -/** | |
| 576 | - * 从指定开始时间到结束时间创建不间断班次(连班),并初始化路牌 | |
| 577 | - * 注意,之前有班次会删除后再创建。 | |
| 578 | - * @param startTime 开始时间 | |
| 579 | - * @param endTime 结束时间 | |
| 580 | - * @param isUp 第一个班次是上行还是下行 | |
| 581 | - * @param fromQ 从第几圈开始加入 | |
| 582 | - * @param paramObj 参数对象 | |
| 583 | - * @param factory 工厂对象 | |
| 584 | - */ | |
| 585 | -InternalLpObj.prototype.initDataFromTimeToTime = function( | |
| 586 | - startTime, | |
| 587 | - endTime, | |
| 588 | - isUp, | |
| 589 | - fromQ, | |
| 590 | - paramObj, | |
| 591 | - factory) { | |
| 592 | - | |
| 593 | - var bcData = []; // 班次数组 | |
| 594 | - var bcObj; | |
| 595 | - var kssj = startTime; | |
| 596 | - var fcno = 1; // 发车顺序号 | |
| 597 | - var bcCount = 1; // 班次数 | |
| 598 | - do { | |
| 599 | - bcObj = factory.createBcObj( | |
| 600 | - this, "normal", isUp, fcno, kssj, paramObj); // this就是所属路牌对象 | |
| 601 | - bcData.push(bcObj); | |
| 602 | - | |
| 603 | - kssj = paramObj.addMinute(kssj, bcObj.getBcTime() + bcObj.getStopTime()); | |
| 604 | - fcno ++; | |
| 605 | - bcCount ++; | |
| 606 | - isUp = !isUp; | |
| 607 | - } while(kssj.isBefore(endTime)); | |
| 608 | - bcCount--; | |
| 609 | - | |
| 610 | - //console.log("last -1;" + bcData[bcCount -2].getFcTimeObj().format("HH:mm")); | |
| 611 | - //console.log("last;" + bcData[bcCount -1].getFcTimeObj().format("HH:mm")); | |
| 612 | - //console.log("endtime: " + endTime.format("HH:mm")); | |
| 613 | - | |
| 614 | - //if (bcCount > 0 && bcData[bcCount - 1].getArrTimeObj().isAfter(endTime)) { | |
| 615 | - // // 如果最后一个班次的到达时间超过结束时间,也要去除 | |
| 616 | - // bcData.splice(bcCount - 1, 1); | |
| 617 | - //} | |
| 618 | - | |
| 619 | - this._initDataFromLbBcArray(bcData, fromQ); | |
| 620 | - | |
| 621 | -}; | |
| 622 | - | |
| 623 | -/** | |
| 624 | - * 使用连班的班次数组初始化路牌(相应的圈会被覆盖)。 | |
| 625 | - * @param bcArray 连班班次数组 | |
| 626 | - * @param fromQ 从第几圈开始加入 | |
| 627 | - */ | |
| 628 | -InternalLpObj.prototype._initDataFromLbBcArray = function( | |
| 629 | - bcArray, | |
| 630 | - fromQ | |
| 631 | -) { | |
| 632 | - var _bc1Obj; | |
| 633 | - var _bc2Obj; | |
| 634 | - var _qObj; | |
| 635 | - | |
| 636 | - // 第一班次是上行还是下行 | |
| 637 | - var isUp = bcArray[0].isUp(); | |
| 638 | - | |
| 639 | - if (bcArray.length > 0 && fromQ < this._$_qCount) { | |
| 640 | - // 构造圈数 | |
| 641 | - if (isUp != this._$_isUp) { | |
| 642 | - // 如果方向不一致,意味着第一个班次是半圈 | |
| 643 | - // 加半圈,并加在bc2上 | |
| 644 | - _bc2Obj = bcArray.slice(0, 1)[0]; | |
| 645 | - _qObj = new InternalGroupObj( | |
| 646 | - this, | |
| 647 | - this._$_isUp, | |
| 648 | - undefined, | |
| 649 | - _bc2Obj | |
| 650 | - ); | |
| 651 | - _bc2Obj.setGroup(_qObj); | |
| 652 | - this._$_groupBcArray[fromQ] = _qObj; | |
| 653 | - | |
| 654 | - bcArray.splice(0, 1); | |
| 655 | - fromQ ++; | |
| 656 | - } | |
| 657 | - | |
| 658 | - var qCount1 = Math.floor(bcArray.length / 2); // 需要添加多少圈 | |
| 659 | - var qCount2 = bcArray.length % 2; // 最后是否有半圈 | |
| 660 | - | |
| 661 | - while (fromQ < this._$_qCount) { | |
| 662 | - if (qCount1 > 0) { | |
| 663 | - _bc1Obj = bcArray.slice(0, 1)[0]; | |
| 664 | - _bc2Obj = bcArray.slice(1, 2)[0]; | |
| 665 | - _qObj = new InternalGroupObj( | |
| 666 | - this, | |
| 667 | - this._$_isUp, | |
| 668 | - _bc1Obj, | |
| 669 | - _bc2Obj | |
| 670 | - ); | |
| 671 | - _bc1Obj.setGroup(_qObj); | |
| 672 | - _bc2Obj.setGroup(_qObj); | |
| 673 | - this._$_groupBcArray[fromQ] = _qObj; | |
| 674 | - | |
| 675 | - bcArray.splice(0, 2); | |
| 676 | - qCount1 --; | |
| 677 | - } else if (qCount2 > 0) { | |
| 678 | - // 加半圈,并加在bc1上 | |
| 679 | - _bc1Obj = bcArray.slice(0, 1)[0]; | |
| 680 | - _qObj = new InternalGroupObj( | |
| 681 | - this, | |
| 682 | - this._$_isUp, | |
| 683 | - _bc1Obj, | |
| 684 | - undefined | |
| 685 | - ); | |
| 686 | - _bc1Obj.setGroup(_qObj); | |
| 687 | - this._$_groupBcArray[fromQ] = _qObj; | |
| 688 | - | |
| 689 | - bcArray.splice(0, 1); | |
| 690 | - qCount2 --; | |
| 691 | - } else { | |
| 692 | - break; | |
| 693 | - } | |
| 694 | - | |
| 695 | - fromQ ++; | |
| 696 | - } | |
| 697 | - } | |
| 698 | -}; | |
| 699 | - | |
| 700 | -//-------------------------- 其他方法 ----------------------------// | |
| 701 | - | |
| 702 | -/** | |
| 703 | - * 从指定位置的班次开始,往后所有的班次修正发车时间 | |
| 704 | - * @param groupIndex | |
| 705 | - * @param bcIndex | |
| 706 | - * @param time | |
| 707 | - */ | |
| 708 | -InternalLpObj.prototype.fnAddMinuteToBcFcsj = function(groupIndex, bcIndex, time) { | |
| 709 | - var i; | |
| 710 | - var oCurBc; | |
| 711 | - | |
| 712 | - // 修正之前班次的停站时间 | |
| 713 | - //oCurBc = this.getBc( | |
| 714 | - // bcIndex == 0 ? groupIndex - 1 : groupIndex, | |
| 715 | - // bcIndex == 1 ? 0 : 1 | |
| 716 | - //); | |
| 717 | - //if (oCurBc) { | |
| 718 | - // oCurBc.setStopTime(oCurBc.getStopTime() + time); | |
| 719 | - //} | |
| 720 | - | |
| 721 | - | |
| 722 | - for (i = groupIndex; i < this._$_qCount; i++) { | |
| 723 | - if (bcIndex == 0) { | |
| 724 | - oCurBc = this.getBc(i, 0); | |
| 725 | - if (oCurBc) { | |
| 726 | - oCurBc.addMinuteToFcsj(time); | |
| 727 | - } | |
| 728 | - oCurBc = this.getBc(i, 1); | |
| 729 | - if (oCurBc) { | |
| 730 | - oCurBc.addMinuteToFcsj(time); | |
| 731 | - } | |
| 732 | - | |
| 733 | - } else { | |
| 734 | - oCurBc = this.getBc(i, 1); | |
| 735 | - if (oCurBc) { | |
| 736 | - oCurBc.addMinuteToFcsj(time); | |
| 737 | - } | |
| 738 | - | |
| 739 | - } | |
| 740 | - | |
| 741 | - bcIndex = 0; | |
| 742 | - } | |
| 743 | -}; | |
| 744 | - | |
| 745 | -/** | |
| 746 | - * 在指定位置添加一个吃饭班次。 | |
| 747 | - * 注1:吃饭班次不是普通班次,不记录进圈,记录进_$_other_bc_array | |
| 748 | - * 注2:添加吃饭班次时,会修改之前班次的停战时间,所以导致之后的班次的停战都会发生变化 | |
| 749 | - * @param groupIndex | |
| 750 | - * @param bcIndex | |
| 751 | - * @param factory | |
| 752 | - * @param paramObj | |
| 753 | - * @returns int 相差时间(吃饭时间距离和停站时间相差值) | |
| 754 | - */ | |
| 755 | -InternalLpObj.prototype.fnAddEatBc = function(groupIndex, bcIndex, factory, paramObj) { | |
| 756 | - var oPreBc; | |
| 757 | - var oEatBc; | |
| 758 | - var iBcModifyTime; | |
| 759 | - | |
| 760 | - if (!this.getBc(groupIndex, bcIndex)) { // | |
| 761 | - return 0; | |
| 762 | - } | |
| 763 | - | |
| 764 | - oPreBc = this.getBc( // 前一个邻接班次 | |
| 765 | - bcIndex == 0 ? groupIndex - 1 : groupIndex, | |
| 766 | - bcIndex == 1 ? 0 : 1); | |
| 767 | - if (oPreBc) { // 存在前一个班次 | |
| 768 | - oEatBc = factory.createBcObj( | |
| 769 | - this, | |
| 770 | - "cf", | |
| 771 | - !oPreBc.isUp(), // 和上一个班次方向相反 | |
| 772 | - 1, | |
| 773 | - paramObj.addMinute(oPreBc.getArrTimeObj(), oPreBc.getStopTime()), // 使用上一个班次的到达时间作为开始时间 | |
| 774 | - paramObj | |
| 775 | - ); | |
| 776 | - | |
| 777 | - //iBcModifyTime = oEatBc.getBcTime() - oPreBc.getStopTime(); // 后续班次要调整的时间 | |
| 778 | - | |
| 779 | - // 修正之后的班次发车时间 | |
| 780 | - // 注意:之后那个班次发车时间就是吃饭班次的到达时间 | |
| 781 | - iBcModifyTime = oEatBc.getArrTimeObj().diff(this.getBc(groupIndex, bcIndex).getFcTimeObj(), "m"); | |
| 782 | - this.fnAddMinuteToBcFcsj(groupIndex, bcIndex, iBcModifyTime); | |
| 783 | - | |
| 784 | - oPreBc.setStopTime(0); // 不重置停站时间 | |
| 785 | - oPreBc.fnSetEatTime(oEatBc.getBcTime()); | |
| 786 | - | |
| 787 | - //this._$_other_bc_array.push(oEatBc); | |
| 788 | - | |
| 789 | - return iBcModifyTime; | |
| 790 | - } else { | |
| 791 | - return false; | |
| 792 | - } | |
| 793 | - | |
| 794 | -}; | |
| 795 | - | |
| 796 | -/** | |
| 797 | - * 调整路牌的班次,通过调整停站时间,或者班次发车时间,不能让班次的到达时间和下一个班次的发车时间重叠。 | |
| 798 | - * @param iPeakAverStopTime 高峰平均停站时间 | |
| 799 | - * @param iTroughAverStopTime 低谷平均停站时间 | |
| 800 | - * @param oParam 参数对象 | |
| 801 | - */ | |
| 802 | -InternalLpObj.prototype.fnAdjustBcInterval = function(iPeakAverStopTime, iTroughAverStopTime, oParam) { | |
| 803 | - // 获取车次链个数 | |
| 804 | - var iBcChainCount = this.fnGetBcChainCount(); | |
| 805 | - | |
| 806 | - var i; | |
| 807 | - var j; | |
| 808 | - var oBcIndex; | |
| 809 | - var iQIndex; | |
| 810 | - var iBcIndex; | |
| 811 | - var iBcCount; | |
| 812 | - var oBc; | |
| 813 | - var oNextBc; | |
| 814 | - | |
| 815 | - var iBcStopTime; | |
| 816 | - | |
| 817 | - for (i = 0; i < iBcChainCount; i++) { | |
| 818 | - oBcIndex = this.fnGetBcChainInfo(i); | |
| 819 | - iQIndex = oBcIndex["s_q"]; | |
| 820 | - iBcIndex = oBcIndex["s_b"]; | |
| 821 | - iBcCount = oBcIndex["bcount"]; | |
| 822 | - | |
| 823 | - for (j = 0; j < iBcCount - 1; j++) { | |
| 824 | - oBc = this.getBc(iQIndex, iBcIndex); | |
| 825 | - oNextBc = this.getBc( | |
| 826 | - iBcIndex == 0 ? iQIndex : iQIndex + 1, | |
| 827 | - iBcIndex == 0 ? 1 : 0); | |
| 828 | - | |
| 829 | - if (oNextBc.fnIsFirstBc()) { // 如果同一路牌连续2个方向首站班次,都不做处理 | |
| 830 | - continue; | |
| 831 | - } | |
| 832 | - | |
| 833 | - // 不改变当前班次的行驶时间,修正停站时间和下一个班次的发车时间 | |
| 834 | - iBcStopTime = oNextBc.getFcTimeObj().diff(oBc.getArrTimeObj(), "m"); | |
| 835 | - if (iBcStopTime < 0) { | |
| 836 | - // 当前班次使用最小停站时间 | |
| 837 | - oBc.setStopTime(oParam.fnCalcuFixedMinStopNumber(oBc.getArrTimeObj(), oBc.isUp())); | |
| 838 | - oNextBc.addMinuteToFcsj(oBc.getStopTime() + oBc.fnGetEatTime() - iBcStopTime); | |
| 839 | - | |
| 840 | - } else { | |
| 841 | - if (iBcStopTime == oBc.getStopTime() + oBc.fnGetEatTime()) { | |
| 842 | - // 停站时间一致,没有问题 | |
| 843 | - | |
| 844 | - | |
| 845 | - } else { | |
| 846 | - // TODO:当前班次使用最小停站时间 | |
| 847 | - oBc.setStopTime(oParam.fnCalcuFixedMinStopNumber(oBc.getArrTimeObj(), oBc.isUp())); | |
| 848 | - oNextBc.addMinuteToFcsj(oBc.getStopTime() + oBc.fnGetEatTime() - iBcStopTime); | |
| 849 | - | |
| 850 | - } | |
| 851 | - } | |
| 852 | - | |
| 853 | - iBcIndex = iBcIndex == 0 ? 1 : 0; | |
| 854 | - iQIndex = iBcIndex == 0 ? iQIndex + 1 : iQIndex; | |
| 855 | - } | |
| 856 | - | |
| 857 | - this.getBc(iQIndex, iBcIndex).setStopTime(0); | |
| 858 | - } | |
| 859 | - | |
| 860 | - | |
| 861 | -}; | |
| 862 | - | |
| 863 | -/** | |
| 864 | - * 返回指定班次的上一个班次。 | |
| 865 | - * @param oBc {moment} 指定班次 | |
| 866 | - * @returns {object} 上一个班次,如果没有,返回false | |
| 867 | - */ | |
| 868 | -InternalLpObj.prototype.getPreBc = function(oBc) { | |
| 869 | - // 获取车次链个数 | |
| 870 | - var iBcChainCount = this.fnGetBcChainCount(); | |
| 871 | - | |
| 872 | - var i; | |
| 873 | - var j; | |
| 874 | - var oBcIndex; | |
| 875 | - var iQIndex; | |
| 876 | - var iBcIndex; | |
| 877 | - var iBcCount; | |
| 878 | - var _oPreBc; | |
| 879 | - var _bFindCurrentBc = false; | |
| 880 | - | |
| 881 | - for (i = 0; i < iBcChainCount; i++) { | |
| 882 | - oBcIndex = this.fnGetBcChainInfo(i); | |
| 883 | - iQIndex = oBcIndex["s_q"]; | |
| 884 | - iBcIndex = oBcIndex["s_b"]; | |
| 885 | - iBcCount = oBcIndex["bcount"]; | |
| 886 | - | |
| 887 | - for (j = 0; j < iBcCount - 1; j++) { | |
| 888 | - if (oBc.getFcTimeObj().format("HH:mm") == | |
| 889 | - this.getBc(iQIndex, iBcIndex).getFcTimeObj().format("HH:mm")) { | |
| 890 | - _bFindCurrentBc = true; | |
| 891 | - break; | |
| 892 | - } | |
| 893 | - | |
| 894 | - // 进入到下一圈 | |
| 895 | - iBcIndex = iBcIndex == 0 ? 1 : 0; | |
| 896 | - iQIndex = iBcIndex == 0 ? iQIndex + 1 : iQIndex; | |
| 897 | - } | |
| 898 | - | |
| 899 | - if (_bFindCurrentBc) { | |
| 900 | - if (iQIndex == oBcIndex["s_q"] && iBcIndex == oBcIndex["s_q"]) { // 第一个班次 | |
| 901 | - break; | |
| 902 | - } else { | |
| 903 | - _oPreBc = this.getBc( | |
| 904 | - iBcIndex == 0 ? iQIndex - 1 : iQIndex, | |
| 905 | - iBcIndex == 0 ? 1 : 0); | |
| 906 | - } | |
| 907 | - } | |
| 908 | - | |
| 909 | - } | |
| 910 | - | |
| 911 | - return _oPreBc || false; | |
| 912 | - | |
| 913 | -}; | |
| 914 | - | |
| 915 | -/** | |
| 916 | - * 通过修改layover时间,修正班次的发车,到达时间。 | |
| 917 | - * 如果layover时间不符合范围要求,修改成平均时间。 | |
| 918 | - * @param oParam {ParameterObj} 参数对象 | |
| 919 | - */ | |
| 920 | -InternalLpObj.prototype.fnAdjustBcTime_layover = function(oParam) { | |
| 921 | - // 获取车次链个数(连班路牌1个,分班路牌2个) | |
| 922 | - var iBlockCount = this.fnGetBcChainCount(); | |
| 923 | - | |
| 924 | - var i; | |
| 925 | - var j; | |
| 926 | - var aTrip; // 每个block关联的trip列表 | |
| 927 | - var trip; // 当前班次 | |
| 928 | - var nextTrip; // 下一个班次 | |
| 929 | - var layOverTime; | |
| 930 | - var aLayOverTimeRange; | |
| 931 | - | |
| 932 | - var oBcIndex; | |
| 933 | - var iQIndex; // block开始第几圈缩影 | |
| 934 | - var iBcIndex; // block开始第几个班次 | |
| 935 | - var iBcCount; // block的trip数目 | |
| 936 | - | |
| 937 | - | |
| 938 | - for (i = 0; i < iBlockCount; i++) { | |
| 939 | - // 获取block关联的trip列表 | |
| 940 | - oBcIndex = this.fnGetBcChainInfo(i); | |
| 941 | - iQIndex = oBcIndex["s_q"]; | |
| 942 | - iBcIndex = oBcIndex["s_b"]; | |
| 943 | - iBcCount = oBcIndex["bcount"]; | |
| 944 | - | |
| 945 | - aTrip = []; | |
| 946 | - for (j = 0; j < iBcCount; j++) { | |
| 947 | - aTrip.push(this.getBc(iQIndex, iBcIndex)); | |
| 948 | - iBcIndex = iBcIndex == 0 ? 1 : 0; | |
| 949 | - iQIndex = iBcIndex == 0 ? iQIndex + 1 : iQIndex; | |
| 950 | - } | |
| 951 | - | |
| 952 | - if (aTrip.length < 2) { | |
| 953 | - // 两个trip一起处理,只有1个trip的block不处理 | |
| 954 | - continue; | |
| 955 | - } | |
| 956 | - // 迭代block,处理trip的发车,到达,停站时间 | |
| 957 | - for (j = 0; j < aTrip.length - 1; j++) { | |
| 958 | - trip = aTrip[j]; | |
| 959 | - nextTrip = aTrip[j + 1]; | |
| 960 | - | |
| 961 | - if (trip.fnIsFirstBc() && nextTrip.fnIsFirstBc()) { | |
| 962 | - // 如果两个方向的首班车都在一个block上 | |
| 963 | - // 则停站时间不考虑范围,直接发车时间-到达时间 | |
| 964 | - layOverTime = nextTrip.getFcTimeObj().diff(trip.getArrTimeObj(), "m"); | |
| 965 | - trip.setStopTime(layOverTime); | |
| 966 | - continue; | |
| 967 | - } | |
| 968 | - | |
| 969 | - //------------- 吃饭班次处理 -----------// | |
| 970 | - // 获取当前trip的layover的范围 | |
| 971 | - aLayOverTimeRange = oParam.calcuTripLayoverTimeRange( | |
| 972 | - trip.getArrTimeObj(), trip.isUp(), trip.getBcTime() | |
| 973 | - ); | |
| 974 | - // 重新计算当前班次layover时间 | |
| 975 | - layOverTime = nextTrip.getFcTimeObj().diff(trip.getArrTimeObj(), "m"); | |
| 976 | - if (trip.fnGetEatTime() > 0) { | |
| 977 | - // 如果当前班次layover是要吃饭的 | |
| 978 | - // 则停站时间没有,变成吃饭时间 | |
| 979 | - trip.setStopTime(0); | |
| 980 | - // 修改下一个班次的发车时间,到达时间 | |
| 981 | - nextTrip.setFcTimeObj(oParam.addMinute( | |
| 982 | - trip.getArrTimeObj(), | |
| 983 | - trip.fnGetEatTime()) | |
| 984 | - ); | |
| 985 | - nextTrip.setBcTime(oParam.calcuTravelTime(nextTrip.getFcTimeObj(), nextTrip.isUp())); | |
| 986 | - nextTrip.setArrTimeObj(oParam.addMinute(nextTrip.getFcTimeObj(), nextTrip.getBcTime())); | |
| 987 | - continue; | |
| 988 | - } | |
| 989 | - | |
| 990 | - //------------- 正常班次处理 -----------// | |
| 991 | - if (layOverTime < aLayOverTimeRange[0] || layOverTime > aLayOverTimeRange[1]) { | |
| 992 | - // 如果layover时间在范围之外,使用平均值 | |
| 993 | - layOverTime = oParam.fnCalcuFixedStopNumber( | |
| 994 | - trip.getArrTimeObj(), | |
| 995 | - trip.isUp(), | |
| 996 | - oParam.calcuTravelTime( | |
| 997 | - trip.getFcTimeObj(), | |
| 998 | - trip.isUp()) | |
| 999 | - ); | |
| 1000 | - | |
| 1001 | - trip.setStopTime(layOverTime); | |
| 1002 | - nextTrip.setFcTimeObj(oParam.addMinute( | |
| 1003 | - trip.getArrTimeObj(), | |
| 1004 | - trip.getStopTime()) | |
| 1005 | - ); | |
| 1006 | - nextTrip.setBcTime(oParam.calcuTravelTime(nextTrip.getFcTimeObj(), nextTrip.isUp())); | |
| 1007 | - nextTrip.setArrTimeObj(oParam.addMinute(nextTrip.getFcTimeObj(), nextTrip.getBcTime())); | |
| 1008 | - } | |
| 1009 | - } | |
| 1010 | - // 最后一个trip的layover时间为0 | |
| 1011 | - aTrip[j].setStopTime(0); | |
| 1012 | - | |
| 1013 | - } | |
| 1014 | -}; | |
| 1015 | - | |
| 1016 | -// TODO | |
| 1017 | - | |
| 1018 | -/** | |
| 1019 | - * | |
| 1020 | - * | |
| 1021 | - */ | |
| 1022 | -InternalLpObj.prototype.calcuLpBx = function() { | |
| 1023 | - | |
| 1024 | -}; | |
| 1025 | - | |
| 1026 | - | |
| 1 | +/** | |
| 2 | + * 内部路牌对象。 | |
| 3 | + * @constructor | |
| 4 | + */ | |
| 5 | +var InternalLpObj = function( | |
| 6 | + orilpObj, // 原始路牌对象 | |
| 7 | + qCount, // 总共多少圈 | |
| 8 | + isUp // 圈是以上行开始还是下行开始 | |
| 9 | +) { | |
| 10 | + // TODO:原始路牌对象(这个路牌是对接外部gantt图像,以后有机会改了) | |
| 11 | + this._$$_orign_lp_obj = orilpObj; | |
| 12 | + | |
| 13 | + this._$_isUp = isUp; | |
| 14 | + | |
| 15 | + // 路牌的圈数,注意每个路牌的圈数都是一致的, | |
| 16 | + // 但并不是每一圈都有值 | |
| 17 | + // 第1圈从上标线开始 | |
| 18 | + // 第0圈表示中标线的第一个班次组成的半圈 | |
| 19 | + // 有多少圈根据最终迭代的结果来看 | |
| 20 | + this._$_qCount = qCount; | |
| 21 | + // 保存的是 InternalGroupBcObj 对象 | |
| 22 | + this._$_groupBcArray = new Array(qCount); | |
| 23 | + | |
| 24 | + var i; | |
| 25 | + for (i = 0; i < this._$_qCount; i++) { | |
| 26 | + this._$_groupBcArray[i] = new InternalGroupObj( | |
| 27 | + this, this._$_isUp, undefined, undefined); | |
| 28 | + } | |
| 29 | + | |
| 30 | + // 距离上一个路牌的最小发车间隔时间 | |
| 31 | + // 用于纵向添加班次的时候使用 | |
| 32 | + // 默认第一个路牌为0 | |
| 33 | + this._$_minVerticalIntervalTime = 0; | |
| 34 | + | |
| 35 | + // 详细记录每圈每个方向上的发车间隔时间 | |
| 36 | + // 第一维度表示圈数,第二维度表示第一个方向,第二个方向 | |
| 37 | + // 第一个方向是否上行由 _$_isUp 决定 | |
| 38 | + // 这里的间隔表示下一个路牌上的班次距离本路牌的班次发车时间间隔 | |
| 39 | + // 如果当前是最后一个路牌,表示第一个路牌的下一圈同方向班次距离本班次的间隔 | |
| 40 | + this._$_aVerticalIntervalTime = new Array(this._$_qCount); | |
| 41 | + for (i = 0; i < this._$_aVerticalIntervalTime.length; i++) { | |
| 42 | + this._$_aVerticalIntervalTime[i] = new Array(2); | |
| 43 | + } | |
| 44 | + | |
| 45 | + // 班型的相关变量 | |
| 46 | + this._$_bx_isLb = false; // 是否连班 | |
| 47 | + this._$_bx_isfb = false; // 是否分班 | |
| 48 | + this._$_bx_isfb_5_2 = false; // 是否5休2分班 | |
| 49 | + this._$_bx_desc; // 班型描述(默认为路牌编号) | |
| 50 | + | |
| 51 | + // 其他班次(进出场,例包,吃饭等),TODO:以后再拆 | |
| 52 | + this._$_other_bc_array = []; | |
| 53 | + | |
| 54 | + // TODO: | |
| 55 | + | |
| 56 | +}; | |
| 57 | + | |
| 58 | +//------------------- get/set 方法 -------------------// | |
| 59 | + | |
| 60 | +InternalLpObj.prototype.getOtherBcArray = function() { | |
| 61 | + return this._$_other_bc_array; | |
| 62 | +}; | |
| 63 | +InternalLpObj.prototype.addOtherBcArray = function(ba) { | |
| 64 | + this._$_other_bc_array = this._$_other_bc_array.concat(ba); | |
| 65 | +}; | |
| 66 | + | |
| 67 | +/** | |
| 68 | + * 获取圈 | |
| 69 | + * @param qIndex 圈index | |
| 70 | + */ | |
| 71 | +InternalLpObj.prototype.getGroup = function(qIndex) { | |
| 72 | + return this._$_groupBcArray[qIndex]; | |
| 73 | +}; | |
| 74 | + | |
| 75 | +/** | |
| 76 | + * 获取路牌圈数。 | |
| 77 | + * @returns {*} | |
| 78 | + */ | |
| 79 | +InternalLpObj.prototype.fnGetGroupCount = function() { | |
| 80 | + return this._$_qCount; | |
| 81 | +}; | |
| 82 | + | |
| 83 | +/** | |
| 84 | + * 是否上行。 | |
| 85 | + * @returns boolean | |
| 86 | + */ | |
| 87 | +InternalLpObj.prototype.isUp = function() { | |
| 88 | + return this._$_isUp; | |
| 89 | +}; | |
| 90 | + | |
| 91 | +/** | |
| 92 | + * 获取班次。 | |
| 93 | + * @param qIndex 第几圈 | |
| 94 | + * @param bcIndex 第几个班次 | |
| 95 | + */ | |
| 96 | +InternalLpObj.prototype.getBc = function(qIndex, bcIndex) { | |
| 97 | + var group = this._$_groupBcArray[qIndex]; | |
| 98 | + var bc; | |
| 99 | + if (bcIndex == 0) { | |
| 100 | + bc = group.getBc1(); | |
| 101 | + } else if (bcIndex == 1) { | |
| 102 | + bc = group.getBc2(); | |
| 103 | + } | |
| 104 | + return bc; | |
| 105 | +}; | |
| 106 | + | |
| 107 | +/** | |
| 108 | + * 在具体位置设置班次。 | |
| 109 | + * @param qIndex 第几圈 | |
| 110 | + * @param bcIndex 第几个班次 | |
| 111 | + * @param bc 班次对象 | |
| 112 | + */ | |
| 113 | +InternalLpObj.prototype.setBc = function(qIndex, bcIndex, bc) { | |
| 114 | + var group = this._$_groupBcArray[qIndex]; | |
| 115 | + if (bcIndex == 0) { | |
| 116 | + group.setBc1(bc); | |
| 117 | + bc.setGroup(group); | |
| 118 | + } else if (bcIndex == 1) { | |
| 119 | + group.setBc2(bc); | |
| 120 | + bc.setGroup(group); | |
| 121 | + } | |
| 122 | +}; | |
| 123 | + | |
| 124 | +/** | |
| 125 | + * 设置原始路牌对象。 | |
| 126 | + * @param lpObj 原始路牌对象 | |
| 127 | + */ | |
| 128 | +InternalLpObj.prototype.setLp = function(lpObj) { | |
| 129 | + this._$$_orign_lp_obj = lpObj; | |
| 130 | + var i; | |
| 131 | + var group; | |
| 132 | + for (i = 0; i < this._$_groupBcArray.length; i++) { | |
| 133 | + group = this._$_groupBcArray[i]; | |
| 134 | + if (group) { | |
| 135 | + group.setLp(this); // 圈和班次保存都是 InternalLpObj 对象 | |
| 136 | + } | |
| 137 | + } | |
| 138 | +}; | |
| 139 | + | |
| 140 | +InternalLpObj.prototype.getLpNo = function() { | |
| 141 | + return this._$$_orign_lp_obj.lpNo; | |
| 142 | +}; | |
| 143 | +InternalLpObj.prototype.getLpName = function() { | |
| 144 | + return this._$$_orign_lp_obj.lpName; | |
| 145 | +}; | |
| 146 | +InternalLpObj.prototype.setBxFb5_2 = function(fb) { | |
| 147 | + this._$_bx_isfb_5_2 = fb; | |
| 148 | +}; | |
| 149 | +InternalLpObj.prototype.isBxFb5_2 = function() { | |
| 150 | + return this._$_bx_isfb_5_2; | |
| 151 | +}; | |
| 152 | +InternalLpObj.prototype.setBxLb = function(lb) { | |
| 153 | + this._$_bx_isLb = lb; | |
| 154 | +}; | |
| 155 | +InternalLpObj.prototype.isBxLb = function() { | |
| 156 | + return this._$_bx_isLb; | |
| 157 | +}; | |
| 158 | + | |
| 159 | +InternalLpObj.prototype.setBxFb = function(fb) { | |
| 160 | + this._$_bx_isfb = fb; | |
| 161 | +}; | |
| 162 | +InternalLpObj.prototype.isBxFb = function() { | |
| 163 | + return this._$_bx_isfb; | |
| 164 | +}; | |
| 165 | + | |
| 166 | +/** | |
| 167 | + * 设置路牌的班型描述(最终是设置班次的路牌名字)。 | |
| 168 | + * @param desc 描述 | |
| 169 | + */ | |
| 170 | +InternalLpObj.prototype.setBxDesc = function(desc) { | |
| 171 | + // 最终原始路牌的名字 | |
| 172 | + this._$$_orign_lp_obj.lpName = desc + "_" + this._$$_orign_lp_obj.lpNo; | |
| 173 | + // 内部对象的班型描述 | |
| 174 | + this._$_bx_desc = desc; | |
| 175 | +}; | |
| 176 | +/** | |
| 177 | + * 获取版型描述 | |
| 178 | + * @returns string | |
| 179 | + */ | |
| 180 | +InternalLpObj.prototype.getBxDesc = function() { | |
| 181 | + return this._$_bx_desc; | |
| 182 | +}; | |
| 183 | + | |
| 184 | +/** | |
| 185 | + * 设置纵向最小发车间隔时间。 | |
| 186 | + * @param v | |
| 187 | + */ | |
| 188 | +InternalLpObj.prototype.setVerticalMinIntervalTime = function(v) { | |
| 189 | + // 第一个路牌,都为0 | |
| 190 | + this._$_minVerticalIntervalTime = v; | |
| 191 | +}; | |
| 192 | +/** | |
| 193 | + * 获取纵向最小发车间隔时间。 | |
| 194 | + * @returns {number|*} | |
| 195 | + */ | |
| 196 | +InternalLpObj.prototype.getVerticalMinIntervalTime = function() { | |
| 197 | + return this._$_minVerticalIntervalTime; | |
| 198 | +}; | |
| 199 | + | |
| 200 | +/** | |
| 201 | + * 设置纵向发车间隔。 | |
| 202 | + * @param iQindex 圈index | |
| 203 | + * @param iBindex 班次index | |
| 204 | + * @param iTime 间隔时间 | |
| 205 | + */ | |
| 206 | +InternalLpObj.prototype.fnSetVerticalIntervalTime = function(iQindex, iBindex, iTime) { | |
| 207 | + this._$_aVerticalIntervalTime[iQindex][iBindex] = iTime; | |
| 208 | +}; | |
| 209 | + | |
| 210 | +/** | |
| 211 | + * 返回纵向发车间隔。 | |
| 212 | + * @param iQindex 圈index | |
| 213 | + * @param iBindex 班次index | |
| 214 | + */ | |
| 215 | +InternalLpObj.prototype.fnGetVerticalIntervalTime = function(iQindex, iBindex) { | |
| 216 | + return this._$_aVerticalIntervalTime[iQindex][iBindex]; | |
| 217 | +}; | |
| 218 | + | |
| 219 | +//-------------------- 班次操作方法(查询,统计,删除) -----------------------// | |
| 220 | + | |
| 221 | +/** | |
| 222 | + * 返回总共班次数。 | |
| 223 | + */ | |
| 224 | +InternalLpObj.prototype.getBcCount = function() { | |
| 225 | + var i; | |
| 226 | + var group; | |
| 227 | + var bccount = 0; | |
| 228 | + for (i = 0; i < this._$_groupBcArray.length; i++) { | |
| 229 | + group = this._$_groupBcArray[i]; | |
| 230 | + if (group) { | |
| 231 | + if (group.getBc1()) { | |
| 232 | + bccount += 1; | |
| 233 | + } | |
| 234 | + if (group.getBc2()) { | |
| 235 | + bccount += 1; | |
| 236 | + } | |
| 237 | + } | |
| 238 | + } | |
| 239 | + | |
| 240 | + return bccount; | |
| 241 | +}; | |
| 242 | + | |
| 243 | +/** | |
| 244 | + * 返回班次列表,过滤空的班次,将所有存在的班次连成连续的对象数组返回。 | |
| 245 | + * @returns arrays (InternalBcObj) | |
| 246 | + */ | |
| 247 | +InternalLpObj.prototype.getBcArray = function() { | |
| 248 | + var bcArray = []; | |
| 249 | + var i; | |
| 250 | + var group; | |
| 251 | + for (i = 0; i < this._$_groupBcArray.length; i++) { | |
| 252 | + group = this._$_groupBcArray[i]; | |
| 253 | + if (group) { | |
| 254 | + group.getBc1() ? bcArray.push(group.getBc1()) : ""; | |
| 255 | + group.getBc2() ? bcArray.push(group.getBc2()) : ""; | |
| 256 | + } | |
| 257 | + } | |
| 258 | + | |
| 259 | + return bcArray; | |
| 260 | +}; | |
| 261 | + | |
| 262 | +/** | |
| 263 | + * 获取最小(最早)班次对象。 | |
| 264 | + * @returns [{圈index},{班次index}] | |
| 265 | + */ | |
| 266 | +InternalLpObj.prototype.getMinBcObjPosition = function() { | |
| 267 | + var i; | |
| 268 | + var bIndex = []; | |
| 269 | + for (i = 0; i < this._$_groupBcArray.length; i++) { | |
| 270 | + if (this._$_groupBcArray[i].getBc1()) { | |
| 271 | + bIndex.push(i); | |
| 272 | + bIndex.push(0); | |
| 273 | + break; | |
| 274 | + } | |
| 275 | + if (this._$_groupBcArray[i].getBc2()) { | |
| 276 | + bIndex.push(i); | |
| 277 | + bIndex.push(1); | |
| 278 | + break; | |
| 279 | + } | |
| 280 | + } | |
| 281 | + return bIndex; | |
| 282 | +}; | |
| 283 | + | |
| 284 | +/** | |
| 285 | + * 获取最大(最晚)班次对象。 | |
| 286 | + * @returns [{圈index},{班次index}] | |
| 287 | + */ | |
| 288 | +InternalLpObj.prototype.getMaxBcObjPosition = function() { | |
| 289 | + var i; | |
| 290 | + var bIndex = []; | |
| 291 | + for (i = this._$_groupBcArray.length - 1; i >= 0; i--) { | |
| 292 | + if (this._$_groupBcArray[i].getBc2()) { | |
| 293 | + bIndex.push(i); | |
| 294 | + bIndex.push(1); | |
| 295 | + break; | |
| 296 | + } | |
| 297 | + if (this._$_groupBcArray[i].getBc1()) { | |
| 298 | + bIndex.push(i); | |
| 299 | + bIndex.push(0); | |
| 300 | + break; | |
| 301 | + } | |
| 302 | + } | |
| 303 | + return bIndex; | |
| 304 | +}; | |
| 305 | + | |
| 306 | +InternalLpObj.prototype.getMinBcObj = function() { | |
| 307 | + var i; | |
| 308 | + var bcObj; | |
| 309 | + for (i = 0; i < this._$_groupBcArray.length; i++) { | |
| 310 | + bcObj = this._$_groupBcArray[i].getBc1(); | |
| 311 | + if (bcObj) { | |
| 312 | + break; | |
| 313 | + } | |
| 314 | + bcObj = this._$_groupBcArray[i].getBc2(); | |
| 315 | + if (bcObj) { | |
| 316 | + break; | |
| 317 | + } | |
| 318 | + } | |
| 319 | + return bcObj; | |
| 320 | +}; | |
| 321 | +InternalLpObj.prototype.getMaxBcObj = function() { | |
| 322 | + var i; | |
| 323 | + var bcObj; | |
| 324 | + for (i = this._$_groupBcArray.length - 1; i >= 0; i--) { | |
| 325 | + bcObj = this._$_groupBcArray[i].getBc2(); | |
| 326 | + if (bcObj) { | |
| 327 | + break; | |
| 328 | + } | |
| 329 | + bcObj = this._$_groupBcArray[i].getBc1(); | |
| 330 | + if (bcObj) { | |
| 331 | + break; | |
| 332 | + } | |
| 333 | + } | |
| 334 | + return bcObj; | |
| 335 | +}; | |
| 336 | + | |
| 337 | +/** | |
| 338 | + * 获取车次链信息。 | |
| 339 | + * @param num 第几个车次链 | |
| 340 | + * @returns object {s_q: {开始圈索引},s_b : {开始班次索引},e_q : {结束圈索引},e_b : {结束班次索引}, bcount : {班次数}} | |
| 341 | + */ | |
| 342 | +InternalLpObj.prototype.fnGetBcChainInfo = function(num) { | |
| 343 | + // 计算总的车次链信息 | |
| 344 | + var aChainInfo = []; | |
| 345 | + var oChainInfo; | |
| 346 | + var aBcIndex = this.getMinBcObjPosition(); | |
| 347 | + var oBc; | |
| 348 | + var iQIndex; | |
| 349 | + var iBcIndex; | |
| 350 | + var i; | |
| 351 | + var bFlag; | |
| 352 | + | |
| 353 | + var iBcount = 0; | |
| 354 | + | |
| 355 | + if (aBcIndex.length == 2) { | |
| 356 | + iBcount = 1; | |
| 357 | + oChainInfo = {s_q : aBcIndex[0], s_b : aBcIndex[1], e_q : aBcIndex[0], e_b : aBcIndex[1], bcount: 1}; | |
| 358 | + aChainInfo.push(oChainInfo); | |
| 359 | + bFlag = true; | |
| 360 | + | |
| 361 | + // 下一个班次的索引 | |
| 362 | + iQIndex = aBcIndex[1] == 0 ? aBcIndex[0] : aBcIndex[0] + 1; | |
| 363 | + iBcIndex = aBcIndex[1] == 0 ? 1 : 0; | |
| 364 | + | |
| 365 | + for (i = iQIndex; i < this._$_qCount; i++) { | |
| 366 | + while (iBcIndex <= 1) { | |
| 367 | + oBc = this.getBc(i, iBcIndex); | |
| 368 | + if (!oBc) { | |
| 369 | + if (bFlag) { | |
| 370 | + // 车次链结尾是这个班次的前一个班次 | |
| 371 | + oChainInfo.e_q = iBcIndex == 0 ? i - 1 : i; | |
| 372 | + oChainInfo.e_b = iBcIndex == 0 ? 1 : 0; | |
| 373 | + oChainInfo.bcount = iBcount; | |
| 374 | + } | |
| 375 | + | |
| 376 | + bFlag = false; | |
| 377 | + } else { | |
| 378 | + if (bFlag) { | |
| 379 | + iBcount ++; | |
| 380 | + oChainInfo.bcount = iBcount; | |
| 381 | + } else { | |
| 382 | + // 下一个车次链开始 | |
| 383 | + iBcount = 1; | |
| 384 | + oChainInfo = {s_q : i, s_b : iBcIndex, e_q : i, e_b : iBcIndex, bcount: 1}; | |
| 385 | + aChainInfo.push(oChainInfo); | |
| 386 | + bFlag = true; | |
| 387 | + } | |
| 388 | + } | |
| 389 | + | |
| 390 | + | |
| 391 | + iBcIndex ++; | |
| 392 | + } | |
| 393 | + iBcIndex = 0; | |
| 394 | + } | |
| 395 | + | |
| 396 | + } | |
| 397 | + | |
| 398 | + return aChainInfo[num]; | |
| 399 | +}; | |
| 400 | + | |
| 401 | +/** | |
| 402 | + * 获取车次链的个数。 | |
| 403 | + * @returns int | |
| 404 | + */ | |
| 405 | +InternalLpObj.prototype.fnGetBcChainCount = function() { | |
| 406 | + var iChainCount = 0; | |
| 407 | + var aBcIndex = this.getMinBcObjPosition(); | |
| 408 | + | |
| 409 | + var oBc; | |
| 410 | + var iQIndex; | |
| 411 | + var iBcIndex; | |
| 412 | + var i; | |
| 413 | + var bFlag; | |
| 414 | + | |
| 415 | + if (aBcIndex.length == 2) { | |
| 416 | + iChainCount = 1; | |
| 417 | + bFlag = true; | |
| 418 | + | |
| 419 | + // 下一个班次的索引 | |
| 420 | + iQIndex = aBcIndex[1] == 0 ? aBcIndex[0] : aBcIndex[0] + 1; | |
| 421 | + iBcIndex = aBcIndex[1] == 0 ? 1 : 0; | |
| 422 | + | |
| 423 | + for (i = iQIndex; i < this._$_qCount; i++) { | |
| 424 | + while (iBcIndex <= 1) { | |
| 425 | + oBc = this.getBc(i, iBcIndex); | |
| 426 | + if (!oBc) { | |
| 427 | + bFlag = false; | |
| 428 | + } else { | |
| 429 | + if (bFlag) { | |
| 430 | + | |
| 431 | + } else { | |
| 432 | + iChainCount ++; | |
| 433 | + bFlag = true; | |
| 434 | + } | |
| 435 | + } | |
| 436 | + | |
| 437 | + | |
| 438 | + iBcIndex ++; | |
| 439 | + } | |
| 440 | + iBcIndex = 0; | |
| 441 | + } | |
| 442 | + | |
| 443 | + } | |
| 444 | + | |
| 445 | + | |
| 446 | + return iChainCount; | |
| 447 | +}; | |
| 448 | + | |
| 449 | +/** | |
| 450 | + * 在具体位置移除班次。 | |
| 451 | + * @param qIndex 第几圈 | |
| 452 | + * @param bcIndex 第几个班次 | |
| 453 | + */ | |
| 454 | +InternalLpObj.prototype.removeBc = function(qIndex, bcIndex) { | |
| 455 | + var group = this._$_groupBcArray[qIndex]; | |
| 456 | + if (bcIndex == 0) { | |
| 457 | + group.removeBc1(); | |
| 458 | + } else if (bcIndex == 1) { | |
| 459 | + group.removeBc2(); | |
| 460 | + } | |
| 461 | +}; | |
| 462 | + | |
| 463 | +/** | |
| 464 | + * 使用指定时间匹配返回离之最近的第几圈第几个班次, | |
| 465 | + * 使用时间差的绝度值,比较,取最小的 | |
| 466 | + * 如果有两个一样的时间差,取比fctime大的时间 | |
| 467 | + * @param fctime moment 比较用时间 | |
| 468 | + * @param groupArray 圈数组 | |
| 469 | + * @param hasUp boolean 计算上行班次 | |
| 470 | + * @param hasDown boolean 计算下行班次 | |
| 471 | + * @returns [{第几圈},{第几个班次}] | |
| 472 | + */ | |
| 473 | +InternalLpObj.prototype.fnGetQBcIndexWithFcTimeFromGroupArray = function( | |
| 474 | + fctime, groupArray, hasUp, hasDown | |
| 475 | +) { | |
| 476 | + var i; | |
| 477 | + var timediff; // 时间差取绝对值 | |
| 478 | + var qIndex; | |
| 479 | + var bcIndex; | |
| 480 | + | |
| 481 | + var group; | |
| 482 | + var bc1time; | |
| 483 | + var bc2time; | |
| 484 | + | |
| 485 | + var tempdiff; | |
| 486 | + | |
| 487 | + console.log("比较时间=" + fctime.format("HH:mm")); | |
| 488 | + | |
| 489 | + var oBc; | |
| 490 | + | |
| 491 | + for (i = 0; i < this._$_qCount; i++) { | |
| 492 | + group = groupArray[i]; | |
| 493 | + if (group) { | |
| 494 | + oBc = group.getBc1(); | |
| 495 | + | |
| 496 | + if (oBc != undefined && ((hasUp && hasDown) || (hasUp && (oBc.isUp() == hasUp)) || (hasDown && (!oBc.isUp() == hasDown)))) { | |
| 497 | + bc1time = group.getBc1().getFcTimeObj(); | |
| 498 | + console.log("bc1time=" + bc1time.format("HH:mm") + " tempdiff=" + tempdiff); | |
| 499 | + tempdiff = Math.abs(bc1time.diff(fctime)); | |
| 500 | + | |
| 501 | + if (!timediff) { | |
| 502 | + timediff = Math.abs(tempdiff); | |
| 503 | + qIndex = i; | |
| 504 | + bcIndex = 0; | |
| 505 | + } else { | |
| 506 | + if (tempdiff < timediff) { | |
| 507 | + timediff = tempdiff; | |
| 508 | + qIndex = i; | |
| 509 | + bcIndex = 0; | |
| 510 | + } if (Math.abs(tempdiff) == timediff) { | |
| 511 | + if (bc1time.isAfter(fctime)) { | |
| 512 | + timediff = tempdiff; | |
| 513 | + qIndex = i; | |
| 514 | + bcIndex = 0; | |
| 515 | + } | |
| 516 | + | |
| 517 | + } | |
| 518 | + } | |
| 519 | + } | |
| 520 | + | |
| 521 | + oBc = group.getBc2(); | |
| 522 | + if (oBc != undefined && ((hasUp && hasDown) || (hasUp && (oBc.isUp() == hasUp)) || (hasDown && (!oBc.isUp() == hasDown)))) { | |
| 523 | + bc2time = group.getBc2().getFcTimeObj(); | |
| 524 | + console.log("bc2time=" + bc2time.format("HH:mm") + " tempdiff=" + tempdiff); | |
| 525 | + tempdiff = Math.abs(bc2time.diff(fctime)); | |
| 526 | + | |
| 527 | + if (!timediff) { | |
| 528 | + timediff = Math.abs(tempdiff); | |
| 529 | + qIndex = i; | |
| 530 | + bcIndex = 1; | |
| 531 | + } else { | |
| 532 | + if (tempdiff < timediff) { | |
| 533 | + timediff = tempdiff; | |
| 534 | + qIndex = i; | |
| 535 | + bcIndex = 1; | |
| 536 | + } if (Math.abs(tempdiff) == timediff) { | |
| 537 | + if (bc2time.isBefore(fctime)) { | |
| 538 | + timediff = tempdiff; | |
| 539 | + qIndex = i; | |
| 540 | + bcIndex = 1; | |
| 541 | + } | |
| 542 | + | |
| 543 | + } | |
| 544 | + } | |
| 545 | + } | |
| 546 | + } | |
| 547 | + } | |
| 548 | + | |
| 549 | + console.log("中标线对应数组索引=" + qIndex); | |
| 550 | + | |
| 551 | + var rst = []; | |
| 552 | + rst.push(qIndex); | |
| 553 | + rst.push(bcIndex); | |
| 554 | + | |
| 555 | + return rst; | |
| 556 | +}; | |
| 557 | + | |
| 558 | +/** | |
| 559 | + * 使用指定时间匹配返回离之最近的第几圈第几个班次, | |
| 560 | + * 使用时间差的绝度值,比较,取最小的 | |
| 561 | + * 如果有两个一样的时间差,取比fctime大的时间 | |
| 562 | + * @param fctime moment 比较用时间 | |
| 563 | + * @param hasUp boolean 计算上行班次 | |
| 564 | + * @param hasDown boolean 计算下行班次 | |
| 565 | + * @returns [{第几圈},{第几个班次}] | |
| 566 | + */ | |
| 567 | +InternalLpObj.prototype.getQBcIndexWithFcTime = function( | |
| 568 | + fctime, hasUp, hasDown | |
| 569 | +) { | |
| 570 | + return this.fnGetQBcIndexWithFcTimeFromGroupArray(fctime, this._$_groupBcArray, hasUp, hasDown); | |
| 571 | +}; | |
| 572 | + | |
| 573 | +//---------------------- 内部数据初始化方法(不同于构造函数)---------------------// | |
| 574 | + | |
| 575 | +/** | |
| 576 | + * 从指定开始时间到结束时间创建不间断班次(连班),并初始化路牌 | |
| 577 | + * 注意,之前有班次会删除后再创建。 | |
| 578 | + * @param startTime 开始时间 | |
| 579 | + * @param endTime 结束时间 | |
| 580 | + * @param isUp 第一个班次是上行还是下行 | |
| 581 | + * @param fromQ 从第几圈开始加入 | |
| 582 | + * @param paramObj 参数对象 | |
| 583 | + * @param factory 工厂对象 | |
| 584 | + */ | |
| 585 | +InternalLpObj.prototype.initDataFromTimeToTime = function( | |
| 586 | + startTime, | |
| 587 | + endTime, | |
| 588 | + isUp, | |
| 589 | + fromQ, | |
| 590 | + paramObj, | |
| 591 | + factory) { | |
| 592 | + | |
| 593 | + var bcData = []; // 班次数组 | |
| 594 | + var bcObj; | |
| 595 | + var kssj = startTime; | |
| 596 | + var fcno = 1; // 发车顺序号 | |
| 597 | + var bcCount = 1; // 班次数 | |
| 598 | + do { | |
| 599 | + bcObj = factory.createBcObj( | |
| 600 | + this, "normal", isUp, fcno, kssj, paramObj); // this就是所属路牌对象 | |
| 601 | + bcData.push(bcObj); | |
| 602 | + | |
| 603 | + kssj = paramObj.addMinute(kssj, bcObj.getBcTime() + bcObj.getStopTime()); | |
| 604 | + fcno ++; | |
| 605 | + bcCount ++; | |
| 606 | + isUp = !isUp; | |
| 607 | + } while(kssj.isBefore(endTime)); | |
| 608 | + bcCount--; | |
| 609 | + | |
| 610 | + //console.log("last -1;" + bcData[bcCount -2].getFcTimeObj().format("HH:mm")); | |
| 611 | + //console.log("last;" + bcData[bcCount -1].getFcTimeObj().format("HH:mm")); | |
| 612 | + //console.log("endtime: " + endTime.format("HH:mm")); | |
| 613 | + | |
| 614 | + //if (bcCount > 0 && bcData[bcCount - 1].getArrTimeObj().isAfter(endTime)) { | |
| 615 | + // // 如果最后一个班次的到达时间超过结束时间,也要去除 | |
| 616 | + // bcData.splice(bcCount - 1, 1); | |
| 617 | + //} | |
| 618 | + | |
| 619 | + this._initDataFromLbBcArray(bcData, fromQ); | |
| 620 | + | |
| 621 | +}; | |
| 622 | + | |
| 623 | +/** | |
| 624 | + * 使用连班的班次数组初始化路牌(相应的圈会被覆盖)。 | |
| 625 | + * @param bcArray 连班班次数组 | |
| 626 | + * @param fromQ 从第几圈开始加入 | |
| 627 | + */ | |
| 628 | +InternalLpObj.prototype._initDataFromLbBcArray = function( | |
| 629 | + bcArray, | |
| 630 | + fromQ | |
| 631 | +) { | |
| 632 | + var _bc1Obj; | |
| 633 | + var _bc2Obj; | |
| 634 | + var _qObj; | |
| 635 | + | |
| 636 | + // 第一班次是上行还是下行 | |
| 637 | + var isUp = bcArray[0].isUp(); | |
| 638 | + | |
| 639 | + if (bcArray.length > 0 && fromQ < this._$_qCount) { | |
| 640 | + // 构造圈数 | |
| 641 | + if (isUp != this._$_isUp) { | |
| 642 | + // 如果方向不一致,意味着第一个班次是半圈 | |
| 643 | + // 加半圈,并加在bc2上 | |
| 644 | + _bc2Obj = bcArray.slice(0, 1)[0]; | |
| 645 | + _qObj = new InternalGroupObj( | |
| 646 | + this, | |
| 647 | + this._$_isUp, | |
| 648 | + undefined, | |
| 649 | + _bc2Obj | |
| 650 | + ); | |
| 651 | + _bc2Obj.setGroup(_qObj); | |
| 652 | + this._$_groupBcArray[fromQ] = _qObj; | |
| 653 | + | |
| 654 | + bcArray.splice(0, 1); | |
| 655 | + fromQ ++; | |
| 656 | + } | |
| 657 | + | |
| 658 | + var qCount1 = Math.floor(bcArray.length / 2); // 需要添加多少圈 | |
| 659 | + var qCount2 = bcArray.length % 2; // 最后是否有半圈 | |
| 660 | + | |
| 661 | + while (fromQ < this._$_qCount) { | |
| 662 | + if (qCount1 > 0) { | |
| 663 | + _bc1Obj = bcArray.slice(0, 1)[0]; | |
| 664 | + _bc2Obj = bcArray.slice(1, 2)[0]; | |
| 665 | + _qObj = new InternalGroupObj( | |
| 666 | + this, | |
| 667 | + this._$_isUp, | |
| 668 | + _bc1Obj, | |
| 669 | + _bc2Obj | |
| 670 | + ); | |
| 671 | + _bc1Obj.setGroup(_qObj); | |
| 672 | + _bc2Obj.setGroup(_qObj); | |
| 673 | + this._$_groupBcArray[fromQ] = _qObj; | |
| 674 | + | |
| 675 | + bcArray.splice(0, 2); | |
| 676 | + qCount1 --; | |
| 677 | + } else if (qCount2 > 0) { | |
| 678 | + // 加半圈,并加在bc1上 | |
| 679 | + _bc1Obj = bcArray.slice(0, 1)[0]; | |
| 680 | + _qObj = new InternalGroupObj( | |
| 681 | + this, | |
| 682 | + this._$_isUp, | |
| 683 | + _bc1Obj, | |
| 684 | + undefined | |
| 685 | + ); | |
| 686 | + _bc1Obj.setGroup(_qObj); | |
| 687 | + this._$_groupBcArray[fromQ] = _qObj; | |
| 688 | + | |
| 689 | + bcArray.splice(0, 1); | |
| 690 | + qCount2 --; | |
| 691 | + } else { | |
| 692 | + break; | |
| 693 | + } | |
| 694 | + | |
| 695 | + fromQ ++; | |
| 696 | + } | |
| 697 | + } | |
| 698 | +}; | |
| 699 | + | |
| 700 | +//-------------------------- 其他方法 ----------------------------// | |
| 701 | + | |
| 702 | +/** | |
| 703 | + * 从指定位置的班次开始,往后所有的班次修正发车时间 | |
| 704 | + * @param groupIndex | |
| 705 | + * @param bcIndex | |
| 706 | + * @param time | |
| 707 | + */ | |
| 708 | +InternalLpObj.prototype.fnAddMinuteToBcFcsj = function(groupIndex, bcIndex, time) { | |
| 709 | + var i; | |
| 710 | + var oCurBc; | |
| 711 | + | |
| 712 | + // 修正之前班次的停站时间 | |
| 713 | + //oCurBc = this.getBc( | |
| 714 | + // bcIndex == 0 ? groupIndex - 1 : groupIndex, | |
| 715 | + // bcIndex == 1 ? 0 : 1 | |
| 716 | + //); | |
| 717 | + //if (oCurBc) { | |
| 718 | + // oCurBc.setStopTime(oCurBc.getStopTime() + time); | |
| 719 | + //} | |
| 720 | + | |
| 721 | + | |
| 722 | + for (i = groupIndex; i < this._$_qCount; i++) { | |
| 723 | + if (bcIndex == 0) { | |
| 724 | + oCurBc = this.getBc(i, 0); | |
| 725 | + if (oCurBc) { | |
| 726 | + oCurBc.addMinuteToFcsj(time); | |
| 727 | + } | |
| 728 | + oCurBc = this.getBc(i, 1); | |
| 729 | + if (oCurBc) { | |
| 730 | + oCurBc.addMinuteToFcsj(time); | |
| 731 | + } | |
| 732 | + | |
| 733 | + } else { | |
| 734 | + oCurBc = this.getBc(i, 1); | |
| 735 | + if (oCurBc) { | |
| 736 | + oCurBc.addMinuteToFcsj(time); | |
| 737 | + } | |
| 738 | + | |
| 739 | + } | |
| 740 | + | |
| 741 | + bcIndex = 0; | |
| 742 | + } | |
| 743 | +}; | |
| 744 | + | |
| 745 | +/** | |
| 746 | + * 在指定位置添加一个吃饭班次。 | |
| 747 | + * 注1:吃饭班次不是普通班次,不记录进圈,记录进_$_other_bc_array | |
| 748 | + * 注2:添加吃饭班次时,会修改之前班次的停战时间,所以导致之后的班次的停战都会发生变化 | |
| 749 | + * @param groupIndex | |
| 750 | + * @param bcIndex | |
| 751 | + * @param factory | |
| 752 | + * @param paramObj | |
| 753 | + * @returns int 相差时间(吃饭时间距离和停站时间相差值) | |
| 754 | + */ | |
| 755 | +InternalLpObj.prototype.fnAddEatBc = function(groupIndex, bcIndex, factory, paramObj) { | |
| 756 | + var oPreBc; | |
| 757 | + var oEatBc; | |
| 758 | + var iBcModifyTime; | |
| 759 | + | |
| 760 | + if (!this.getBc(groupIndex, bcIndex)) { // | |
| 761 | + return 0; | |
| 762 | + } | |
| 763 | + | |
| 764 | + oPreBc = this.getBc( // 前一个邻接班次 | |
| 765 | + bcIndex == 0 ? groupIndex - 1 : groupIndex, | |
| 766 | + bcIndex == 1 ? 0 : 1); | |
| 767 | + if (oPreBc) { // 存在前一个班次 | |
| 768 | + oEatBc = factory.createBcObj( | |
| 769 | + this, | |
| 770 | + "cf", | |
| 771 | + !oPreBc.isUp(), // 和上一个班次方向相反 | |
| 772 | + 1, | |
| 773 | + paramObj.addMinute(oPreBc.getArrTimeObj(), oPreBc.getStopTime()), // 使用上一个班次的到达时间作为开始时间 | |
| 774 | + paramObj | |
| 775 | + ); | |
| 776 | + | |
| 777 | + //iBcModifyTime = oEatBc.getBcTime() - oPreBc.getStopTime(); // 后续班次要调整的时间 | |
| 778 | + | |
| 779 | + // 修正之后的班次发车时间 | |
| 780 | + // 注意:之后那个班次发车时间就是吃饭班次的到达时间 | |
| 781 | + iBcModifyTime = oEatBc.getArrTimeObj().diff(this.getBc(groupIndex, bcIndex).getFcTimeObj(), "m"); | |
| 782 | + this.fnAddMinuteToBcFcsj(groupIndex, bcIndex, iBcModifyTime); | |
| 783 | + | |
| 784 | + oPreBc.setStopTime(0); // 不重置停站时间 | |
| 785 | + oPreBc.fnSetEatTime(oEatBc.getBcTime()); | |
| 786 | + | |
| 787 | + //this._$_other_bc_array.push(oEatBc); | |
| 788 | + | |
| 789 | + return iBcModifyTime; | |
| 790 | + } else { | |
| 791 | + return false; | |
| 792 | + } | |
| 793 | + | |
| 794 | +}; | |
| 795 | + | |
| 796 | +/** | |
| 797 | + * 调整路牌的班次,通过调整停站时间,或者班次发车时间,不能让班次的到达时间和下一个班次的发车时间重叠。 | |
| 798 | + * @param iPeakAverStopTime 高峰平均停站时间 | |
| 799 | + * @param iTroughAverStopTime 低谷平均停站时间 | |
| 800 | + * @param oParam 参数对象 | |
| 801 | + */ | |
| 802 | +InternalLpObj.prototype.fnAdjustBcInterval = function(iPeakAverStopTime, iTroughAverStopTime, oParam) { | |
| 803 | + // 获取车次链个数 | |
| 804 | + var iBcChainCount = this.fnGetBcChainCount(); | |
| 805 | + | |
| 806 | + var i; | |
| 807 | + var j; | |
| 808 | + var oBcIndex; | |
| 809 | + var iQIndex; | |
| 810 | + var iBcIndex; | |
| 811 | + var iBcCount; | |
| 812 | + var oBc; | |
| 813 | + var oNextBc; | |
| 814 | + | |
| 815 | + var iBcStopTime; | |
| 816 | + | |
| 817 | + for (i = 0; i < iBcChainCount; i++) { | |
| 818 | + oBcIndex = this.fnGetBcChainInfo(i); | |
| 819 | + iQIndex = oBcIndex["s_q"]; | |
| 820 | + iBcIndex = oBcIndex["s_b"]; | |
| 821 | + iBcCount = oBcIndex["bcount"]; | |
| 822 | + | |
| 823 | + for (j = 0; j < iBcCount - 1; j++) { | |
| 824 | + oBc = this.getBc(iQIndex, iBcIndex); | |
| 825 | + oNextBc = this.getBc( | |
| 826 | + iBcIndex == 0 ? iQIndex : iQIndex + 1, | |
| 827 | + iBcIndex == 0 ? 1 : 0); | |
| 828 | + | |
| 829 | + if (oNextBc.fnIsFirstBc()) { // 如果同一路牌连续2个方向首站班次,都不做处理 | |
| 830 | + continue; | |
| 831 | + } | |
| 832 | + | |
| 833 | + // 不改变当前班次的行驶时间,修正停站时间和下一个班次的发车时间 | |
| 834 | + iBcStopTime = oNextBc.getFcTimeObj().diff(oBc.getArrTimeObj(), "m"); | |
| 835 | + if (iBcStopTime < 0) { | |
| 836 | + // 当前班次使用最小停站时间 | |
| 837 | + oBc.setStopTime(oParam.fnCalcuFixedMinStopNumber(oBc.getArrTimeObj(), oBc.isUp())); | |
| 838 | + oNextBc.addMinuteToFcsj(oBc.getStopTime() + oBc.fnGetEatTime() - iBcStopTime); | |
| 839 | + | |
| 840 | + } else { | |
| 841 | + if (iBcStopTime == oBc.getStopTime() + oBc.fnGetEatTime()) { | |
| 842 | + // 停站时间一致,没有问题 | |
| 843 | + | |
| 844 | + | |
| 845 | + } else { | |
| 846 | + // TODO:当前班次使用最小停站时间 | |
| 847 | + oBc.setStopTime(oParam.fnCalcuFixedMinStopNumber(oBc.getArrTimeObj(), oBc.isUp())); | |
| 848 | + oNextBc.addMinuteToFcsj(oBc.getStopTime() + oBc.fnGetEatTime() - iBcStopTime); | |
| 849 | + | |
| 850 | + } | |
| 851 | + } | |
| 852 | + | |
| 853 | + iBcIndex = iBcIndex == 0 ? 1 : 0; | |
| 854 | + iQIndex = iBcIndex == 0 ? iQIndex + 1 : iQIndex; | |
| 855 | + } | |
| 856 | + | |
| 857 | + this.getBc(iQIndex, iBcIndex).setStopTime(0); | |
| 858 | + } | |
| 859 | + | |
| 860 | + | |
| 861 | +}; | |
| 862 | + | |
| 863 | +/** | |
| 864 | + * 返回指定班次的上一个班次。 | |
| 865 | + * @param oBc {moment} 指定班次 | |
| 866 | + * @returns {object} 上一个班次,如果没有,返回false | |
| 867 | + */ | |
| 868 | +InternalLpObj.prototype.getPreBc = function(oBc) { | |
| 869 | + // 获取车次链个数 | |
| 870 | + var iBcChainCount = this.fnGetBcChainCount(); | |
| 871 | + | |
| 872 | + var i; | |
| 873 | + var j; | |
| 874 | + var oBcIndex; | |
| 875 | + var iQIndex; | |
| 876 | + var iBcIndex; | |
| 877 | + var iBcCount; | |
| 878 | + var _oPreBc; | |
| 879 | + var _bFindCurrentBc = false; | |
| 880 | + | |
| 881 | + for (i = 0; i < iBcChainCount; i++) { | |
| 882 | + oBcIndex = this.fnGetBcChainInfo(i); | |
| 883 | + iQIndex = oBcIndex["s_q"]; | |
| 884 | + iBcIndex = oBcIndex["s_b"]; | |
| 885 | + iBcCount = oBcIndex["bcount"]; | |
| 886 | + | |
| 887 | + for (j = 0; j < iBcCount - 1; j++) { | |
| 888 | + if (oBc.getFcTimeObj().format("HH:mm") == | |
| 889 | + this.getBc(iQIndex, iBcIndex).getFcTimeObj().format("HH:mm")) { | |
| 890 | + _bFindCurrentBc = true; | |
| 891 | + break; | |
| 892 | + } | |
| 893 | + | |
| 894 | + // 进入到下一圈 | |
| 895 | + iBcIndex = iBcIndex == 0 ? 1 : 0; | |
| 896 | + iQIndex = iBcIndex == 0 ? iQIndex + 1 : iQIndex; | |
| 897 | + } | |
| 898 | + | |
| 899 | + if (_bFindCurrentBc) { | |
| 900 | + if (iQIndex == oBcIndex["s_q"] && iBcIndex == oBcIndex["s_q"]) { // 第一个班次 | |
| 901 | + break; | |
| 902 | + } else { | |
| 903 | + _oPreBc = this.getBc( | |
| 904 | + iBcIndex == 0 ? iQIndex - 1 : iQIndex, | |
| 905 | + iBcIndex == 0 ? 1 : 0); | |
| 906 | + } | |
| 907 | + } | |
| 908 | + | |
| 909 | + } | |
| 910 | + | |
| 911 | + return _oPreBc || false; | |
| 912 | + | |
| 913 | +}; | |
| 914 | + | |
| 915 | +/** | |
| 916 | + * 通过修改layover时间,修正班次的发车,到达时间。 | |
| 917 | + * 如果layover时间不符合范围要求,修改成平均时间。 | |
| 918 | + * @param oParam {ParameterObj} 参数对象 | |
| 919 | + */ | |
| 920 | +InternalLpObj.prototype.fnAdjustBcTime_layover = function(oParam) { | |
| 921 | + // 获取车次链个数(连班路牌1个,分班路牌2个) | |
| 922 | + var iBlockCount = this.fnGetBcChainCount(); | |
| 923 | + | |
| 924 | + var i; | |
| 925 | + var j; | |
| 926 | + var aTrip; // 每个block关联的trip列表 | |
| 927 | + var trip; // 当前班次 | |
| 928 | + var nextTrip; // 下一个班次 | |
| 929 | + var layOverTime; | |
| 930 | + var aLayOverTimeRange; | |
| 931 | + | |
| 932 | + var oBcIndex; | |
| 933 | + var iQIndex; // block开始第几圈缩影 | |
| 934 | + var iBcIndex; // block开始第几个班次 | |
| 935 | + var iBcCount; // block的trip数目 | |
| 936 | + | |
| 937 | + | |
| 938 | + for (i = 0; i < iBlockCount; i++) { | |
| 939 | + // 获取block关联的trip列表 | |
| 940 | + oBcIndex = this.fnGetBcChainInfo(i); | |
| 941 | + iQIndex = oBcIndex["s_q"]; | |
| 942 | + iBcIndex = oBcIndex["s_b"]; | |
| 943 | + iBcCount = oBcIndex["bcount"]; | |
| 944 | + | |
| 945 | + aTrip = []; | |
| 946 | + for (j = 0; j < iBcCount; j++) { | |
| 947 | + aTrip.push(this.getBc(iQIndex, iBcIndex)); | |
| 948 | + iBcIndex = iBcIndex == 0 ? 1 : 0; | |
| 949 | + iQIndex = iBcIndex == 0 ? iQIndex + 1 : iQIndex; | |
| 950 | + } | |
| 951 | + | |
| 952 | + if (aTrip.length < 2) { | |
| 953 | + // 两个trip一起处理,只有1个trip的block不处理 | |
| 954 | + continue; | |
| 955 | + } | |
| 956 | + // 迭代block,处理trip的发车,到达,停站时间 | |
| 957 | + for (j = 0; j < aTrip.length - 1; j++) { | |
| 958 | + trip = aTrip[j]; | |
| 959 | + nextTrip = aTrip[j + 1]; | |
| 960 | + | |
| 961 | + if (trip.fnIsFirstBc() && nextTrip.fnIsFirstBc()) { | |
| 962 | + // 如果两个方向的首班车都在一个block上 | |
| 963 | + // 则停站时间不考虑范围,直接发车时间-到达时间 | |
| 964 | + layOverTime = nextTrip.getFcTimeObj().diff(trip.getArrTimeObj(), "m"); | |
| 965 | + trip.setStopTime(layOverTime); | |
| 966 | + continue; | |
| 967 | + } | |
| 968 | + | |
| 969 | + //------------- 吃饭班次处理 -----------// | |
| 970 | + // 获取当前trip的layover的范围 | |
| 971 | + aLayOverTimeRange = oParam.calcuTripLayoverTimeRange( | |
| 972 | + trip.getArrTimeObj(), trip.isUp(), trip.getBcTime() | |
| 973 | + ); | |
| 974 | + // 重新计算当前班次layover时间 | |
| 975 | + layOverTime = nextTrip.getFcTimeObj().diff(trip.getArrTimeObj(), "m"); | |
| 976 | + if (trip.fnGetEatTime() > 0) { | |
| 977 | + // 如果当前班次layover是要吃饭的 | |
| 978 | + // 则停站时间没有,变成吃饭时间 | |
| 979 | + trip.setStopTime(0); | |
| 980 | + // 修改下一个班次的发车时间,到达时间 | |
| 981 | + nextTrip.setFcTimeObj(oParam.addMinute( | |
| 982 | + trip.getArrTimeObj(), | |
| 983 | + trip.fnGetEatTime()) | |
| 984 | + ); | |
| 985 | + nextTrip.setBcTime(oParam.calcuTravelTime(nextTrip.getFcTimeObj(), nextTrip.isUp())); | |
| 986 | + nextTrip.setArrTimeObj(oParam.addMinute(nextTrip.getFcTimeObj(), nextTrip.getBcTime())); | |
| 987 | + continue; | |
| 988 | + } | |
| 989 | + | |
| 990 | + //------------- 正常班次处理 -----------// | |
| 991 | + if (layOverTime < aLayOverTimeRange[0] || layOverTime > aLayOverTimeRange[1]) { | |
| 992 | + // 如果layover时间在范围之外,使用平均值 | |
| 993 | + layOverTime = oParam.fnCalcuFixedStopNumber( | |
| 994 | + trip.getArrTimeObj(), | |
| 995 | + trip.isUp(), | |
| 996 | + oParam.calcuTravelTime( | |
| 997 | + trip.getFcTimeObj(), | |
| 998 | + trip.isUp()) | |
| 999 | + ); | |
| 1000 | + | |
| 1001 | + trip.setStopTime(layOverTime); | |
| 1002 | + nextTrip.setFcTimeObj(oParam.addMinute( | |
| 1003 | + trip.getArrTimeObj(), | |
| 1004 | + trip.getStopTime()) | |
| 1005 | + ); | |
| 1006 | + nextTrip.setBcTime(oParam.calcuTravelTime(nextTrip.getFcTimeObj(), nextTrip.isUp())); | |
| 1007 | + nextTrip.setArrTimeObj(oParam.addMinute(nextTrip.getFcTimeObj(), nextTrip.getBcTime())); | |
| 1008 | + } | |
| 1009 | + } | |
| 1010 | + // 最后一个trip的layover时间为0 | |
| 1011 | + aTrip[j].setStopTime(0); | |
| 1012 | + | |
| 1013 | + } | |
| 1014 | +}; | |
| 1015 | + | |
| 1016 | +// TODO | |
| 1017 | + | |
| 1018 | +/** | |
| 1019 | + * | |
| 1020 | + * | |
| 1021 | + */ | |
| 1022 | +InternalLpObj.prototype.calcuLpBx = function() { | |
| 1023 | + | |
| 1024 | +}; | |
| 1025 | + | |
| 1026 | + | ... | ... |