Commit 480b541185c46f9673545a11407852f5c58eedfc
1 parent
aaabf008
1.rfid逻辑变更,加rfid状态列造成某些功能异常
Showing
12 changed files
with
2336 additions
and
2229 deletions
src/main/java/com/bsth/XDApplication.java
| @@ -203,14 +203,14 @@ public class XDApplication implements CommandLineRunner { | @@ -203,14 +203,14 @@ public class XDApplication implements CommandLineRunner { | ||
| 203 | WebSocketPushQueue.start();//消息队列 -webSocket ,推送至线调web页面的 | 203 | WebSocketPushQueue.start();//消息队列 -webSocket ,推送至线调web页面的 |
| 204 | 204 | ||
| 205 | /** 线调为其他程序提供的数据 --写入数据库 */ | 205 | /** 线调为其他程序提供的数据 --写入数据库 */ |
| 206 | - sexec.scheduleWithFixedDelay(fcxxUpdateThread, 160, 30, TimeUnit.SECONDS);//发车信息(发车屏、信息发布) | 206 | + //sexec.scheduleWithFixedDelay(fcxxUpdateThread, 160, 30, TimeUnit.SECONDS);//发车信息(发车屏、信息发布) |
| 207 | //线路首末班数据(网关用,班次更新时写入) | 207 | //线路首末班数据(网关用,班次更新时写入) |
| 208 | //com.bsth.data.schedule.f_a_l.FirstAndLastHandler | 208 | //com.bsth.data.schedule.f_a_l.FirstAndLastHandler |
| 209 | - sexec.scheduleWithFixedDelay(schSiginUpdateDBThread, 160, 60 * 30, TimeUnit.SECONDS);//无法自动完成的班次信息(网关用,补信号) | 209 | + //sexec.scheduleWithFixedDelay(schSiginUpdateDBThread, 160, 60 * 30, TimeUnit.SECONDS);//无法自动完成的班次信息(网关用,补信号) |
| 210 | 210 | ||
| 211 | //运管处静态数据提交 | 211 | //运管处静态数据提交 |
| 212 | - log.info(timeDiff / 1000 / 60 + "分钟之后提交到运管处"); | ||
| 213 | - sexec.scheduleAtFixedRate(submitToTrafficManage, timeDiffTraffic / 1000, 60 * 60 * 24, TimeUnit.SECONDS); | 212 | + //log.info(timeDiff / 1000 / 60 + "分钟之后提交到运管处"); |
| 213 | + //sexec.scheduleAtFixedRate(submitToTrafficManage, timeDiffTraffic / 1000, 60 * 60 * 24, TimeUnit.SECONDS); | ||
| 214 | //计算油、公里加注 | 214 | //计算油、公里加注 |
| 215 | sexec.scheduleAtFixedRate(calcOilThread, timeDiff / 1000, 60 * 60 * 24, TimeUnit.SECONDS); | 215 | sexec.scheduleAtFixedRate(calcOilThread, timeDiff / 1000, 60 * 60 * 24, TimeUnit.SECONDS); |
| 216 | 216 | ||
| @@ -222,7 +222,7 @@ public class XDApplication implements CommandLineRunner { | @@ -222,7 +222,7 @@ public class XDApplication implements CommandLineRunner { | ||
| 222 | } | 222 | } |
| 223 | 223 | ||
| 224 | public void testInit(){ | 224 | public void testInit(){ |
| 225 | - log.info("prodInit..."); | 225 | + log.info("testInit..."); |
| 226 | ScheduledExecutorService sexec = Application.mainServices; | 226 | ScheduledExecutorService sexec = Application.mainServices; |
| 227 | //安全驾驶 | 227 | //安全驾驶 |
| 228 | sexec.scheduleWithFixedDelay(safeDrivDataLoadThread, 180, 10, TimeUnit.SECONDS); | 228 | sexec.scheduleWithFixedDelay(safeDrivDataLoadThread, 180, 10, TimeUnit.SECONDS); |
src/main/java/com/bsth/data/gpsdata_v2/handlers/InStationProcess.java
| 1 | -package com.bsth.data.gpsdata_v2.handlers; | ||
| 2 | - | ||
| 3 | -import com.bsth.data.LineConfigData; | ||
| 4 | -import com.bsth.data.gpsdata_v2.cache.GeoCacheData; | ||
| 5 | -import com.bsth.data.gpsdata_v2.cache.GpsCacheData; | ||
| 6 | -import com.bsth.data.gpsdata_v2.entity.GpsEntity; | ||
| 7 | -import com.bsth.data.gpsdata_v2.entity.StationRoute; | ||
| 8 | -import com.bsth.data.gpsdata_v2.status_manager.GpsStatusManager; | ||
| 9 | -import com.bsth.data.gpsdata_v2.utils.GeoUtils; | ||
| 10 | -import com.bsth.data.msg_queue.DirectivePushQueue; | ||
| 11 | -import com.bsth.data.schedule.DayOfSchedule; | ||
| 12 | -import com.bsth.data.schedule.late_adjust.LateAdjustHandle; | ||
| 13 | -import com.bsth.entity.realcontrol.LineConfig; | ||
| 14 | -import com.bsth.entity.realcontrol.ScheduleRealInfo; | ||
| 15 | -import com.bsth.websocket.handler.SendUtils; | ||
| 16 | -import org.apache.commons.lang3.StringUtils; | ||
| 17 | -import org.slf4j.Logger; | ||
| 18 | -import org.slf4j.LoggerFactory; | ||
| 19 | -import org.springframework.beans.factory.annotation.Autowired; | ||
| 20 | -import org.springframework.stereotype.Component; | ||
| 21 | - | ||
| 22 | -import java.util.List; | ||
| 23 | - | ||
| 24 | -/** | ||
| 25 | - * 车辆到站处理程序 | ||
| 26 | - * Created by panzhao on 2017/11/16. | ||
| 27 | - */ | ||
| 28 | -@Component | ||
| 29 | -public class InStationProcess { | ||
| 30 | - | ||
| 31 | - @Autowired | ||
| 32 | - DayOfSchedule dayOfSchedule; | ||
| 33 | - | ||
| 34 | - @Autowired | ||
| 35 | - LineConfigData lineConfigData; | ||
| 36 | - | ||
| 37 | - @Autowired | ||
| 38 | - SendUtils sendUtils; | ||
| 39 | - | ||
| 40 | - @Autowired | ||
| 41 | - GpsStatusManager gpsStatusManager; | ||
| 42 | - | ||
| 43 | - Logger logger = LoggerFactory.getLogger(this.getClass()); | ||
| 44 | - | ||
| 45 | - public void process(GpsEntity gps) { | ||
| 46 | - //自动执行的班次信号,滚蛋 | ||
| 47 | - LineConfig config = lineConfigData.get(gps.getLineId()); | ||
| 48 | - if (null != config && config.isAutoExec()) | ||
| 49 | - return; | ||
| 50 | - | ||
| 51 | - GpsEntity prev = GpsCacheData.getPrev(gps); | ||
| 52 | - | ||
| 53 | - if (null == prev) | ||
| 54 | - return; | ||
| 55 | - | ||
| 56 | - //从站外到站内 | ||
| 57 | - if (prev.getInstation() == 0 && gps.getInstation() > 0) { | ||
| 58 | - inStation(gps, prev); | ||
| 59 | - } | ||
| 60 | - | ||
| 61 | - //从站内到另一个站内 | ||
| 62 | - if (prev.getInstation() == 1 && gps.getInstation() == 1 | ||
| 63 | - && !prev.getStopNo().equals(gps.getStopNo()) | ||
| 64 | - && !prev.getStation().getName().equals(gps.getStation().getName())) | ||
| 65 | - inStation(gps, prev); | ||
| 66 | - | ||
| 67 | - //从场内到站内 | ||
| 68 | - if (prev.getInstation() == 2 && gps.getInstation() == 1) { | ||
| 69 | - inStation(gps, prev); | ||
| 70 | - } | ||
| 71 | - | ||
| 72 | - //被起点站覆盖的情况下进场 | ||
| 73 | - if (isInPark(gps, prev)) | ||
| 74 | - inStation(gps, prev); | ||
| 75 | - } | ||
| 76 | - | ||
| 77 | - /** | ||
| 78 | - * 进站 | ||
| 79 | - * | ||
| 80 | - * @param gps | ||
| 81 | - * @param prev | ||
| 82 | - */ | ||
| 83 | - private void inStation(GpsEntity gps, GpsEntity prev) { | ||
| 84 | - logger.info("进站记录(到达时间:" + gps.getArrTime() + " 进出站状态:" + gps.getInstation() + " 站点编号:" + gps.getStopNo() + " deviceId:" + gps.getDeviceId() + " nbbm:" + gps.getNbbm() + ")"); | ||
| 85 | - ScheduleRealInfo sch = dayOfSchedule.executeCurr(gps.getNbbm()); | ||
| 86 | - boolean flow = true; | ||
| 87 | - //要经过2个中途站才能进 | ||
| 88 | - int count = GpsCacheData.lastInTrailsSize(gps); | ||
| 89 | - if (null != sch) | ||
| 90 | - logger.info("班次id: -" + sch.getId() + " count:" + count+" sch.getZdzCode(): "+sch.getZdzCode()+" sch.getZdzCode(): "+sch.getZdzCode()+" gps.getCarparkNo() :"+gps.getCarparkNo()); | ||
| 91 | - else | ||
| 92 | - logger.info("sch is null...."); | ||
| 93 | - List<StationRoute> routes = GeoCacheData.getStationRoute(gps.getLineId(), gps.getUpDown()); | ||
| 94 | - if (null != sch && isNormalSch(sch) && gps.getInstation() == 1 && routes.size() > 4 | ||
| 95 | - && count < 2) { | ||
| 96 | - logger.info("没有进中途站,拒绝进站... -" + gps.getNbbm() + " -time:" + gps.getTimestamp()); | ||
| 97 | - flow = false; | ||
| 98 | - } | ||
| 99 | - | ||
| 100 | - boolean isEnd = false; | ||
| 101 | - | ||
| 102 | - //进终点 | ||
| 103 | - if (flow && null != sch && | ||
| 104 | - ((sch.getZdzCode().equals(gps.getStopNo()) && gps.getInstation() > 0) || sch.getZdzCode().equals(gps.getCarparkNo()))) { | ||
| 105 | - inEndStation(sch, gps); | ||
| 106 | - isEnd = true; | ||
| 107 | - } | ||
| 108 | - | ||
| 109 | - GpsCacheData.in(gps, isEnd); | ||
| 110 | - } | ||
| 111 | - | ||
| 112 | - private boolean isNormalSch(ScheduleRealInfo sch) { | ||
| 113 | - return sch.getBcType().equals("normal"); | ||
| 114 | - } | ||
| 115 | - | ||
| 116 | - private boolean isNotInOut(ScheduleRealInfo sch) { | ||
| 117 | - return !sch.getBcType().equals("in") && !sch.getBcType().equals("out"); | ||
| 118 | - } | ||
| 119 | - | ||
| 120 | - /** | ||
| 121 | - * 进班次终点 | ||
| 122 | - * | ||
| 123 | - * @param gps | ||
| 124 | - */ | ||
| 125 | - private void inEndStation(ScheduleRealInfo sch, GpsEntity gps) { | ||
| 126 | - String nbbm = sch.getClZbh(); | ||
| 127 | - //校验进站前置约束 | ||
| 128 | - if (!validInPremise(gps) && isNormalSch(sch)) | ||
| 129 | - return; | ||
| 130 | - | ||
| 131 | - //实达时间不覆盖 | ||
| 132 | - if (StringUtils.isNotEmpty(sch.getZdsjActual())) | ||
| 133 | - return; | ||
| 134 | - | ||
| 135 | - //应用到离站缓冲区设置参数 | ||
| 136 | - long rsT = lineConfigData.applyIn(sch, gps.getTimestamp()); | ||
| 137 | - | ||
| 138 | - sch.setZdsjActualAll(rsT); | ||
| 139 | - sch.setSiginCompate(2); | ||
| 140 | - | ||
| 141 | - //持久化 | ||
| 142 | - dayOfSchedule.save(sch); | ||
| 143 | - | ||
| 144 | - //车辆的下一个班次 | ||
| 145 | - ScheduleRealInfo next = dayOfSchedule.next(sch); | ||
| 146 | - if (next != null) { | ||
| 147 | - dayOfSchedule.addExecPlan(next); | ||
| 148 | - inStationAndInPark(sch, next);//进站既进场 | ||
| 149 | - } | ||
| 150 | - else | ||
| 151 | - dayOfSchedule.removeExecPlan(nbbm); | ||
| 152 | - | ||
| 153 | - //通知误点停靠程序,有车辆到站 | ||
| 154 | - LateAdjustHandle.carArrive(gps, next); | ||
| 155 | - //LateAdjustHandle.carArrive(gps); | ||
| 156 | - | ||
| 157 | - //路牌的下一个班次,页面显示起点实际到达时间 | ||
| 158 | - ScheduleRealInfo lpNext = dayOfSchedule.nextByLp(sch); | ||
| 159 | - if (lpNext != null) { | ||
| 160 | - lpNext.setQdzArrDatesj(sch.getZdsjActual()); | ||
| 161 | - } | ||
| 162 | - | ||
| 163 | - //已完成班次数 | ||
| 164 | - int doneSum = dayOfSchedule.doneSum(nbbm); | ||
| 165 | - //webSocket | ||
| 166 | - sendUtils.sendZdsj(sch, lpNext, doneSum); | ||
| 167 | - | ||
| 168 | - logger.info("车辆:" + nbbm + " 班次:" + sch.getDfsj() + "到终点, 时间:" + sch.getZdsjActual() + " -stopNo: " + gps.getStopNo()); | ||
| 169 | - | ||
| 170 | - //清除车辆误点调整监听 | ||
| 171 | - LateAdjustHandle.remove(sch); | ||
| 172 | - | ||
| 173 | - //将gps转换成下一个班次走向的站内信号(应对只有一个站内信号 即 发出时) | ||
| 174 | - transformUpDown(gps, next); | ||
| 175 | - | ||
| 176 | - //套跑 -下发线路切换指令 | ||
| 177 | - if (null != next && !next.getXlBm().equals(sch.getXlBm())) { | ||
| 178 | - gpsStatusManager.changeLine(next.getClZbh(), next.getXlBm(), "套跑@系统"); | ||
| 179 | - } | ||
| 180 | - | ||
| 181 | - /** | ||
| 182 | - * 注意: | ||
| 183 | - * 要先发运营指令,再发调度指令 | ||
| 184 | - */ | ||
| 185 | - if(null == next && gps.isService()){ | ||
| 186 | - nonService(sch, "结束@系统");//营运结束 | ||
| 187 | - } | ||
| 188 | - | ||
| 189 | - /** | ||
| 190 | - * 下一班不是全程班次的时候,下发运营指令 | ||
| 191 | - * 全程班次时,由网关根据进出起终点,自动切换走向 | ||
| 192 | - | ||
| 193 | - if(null != next && !next.getBcType().equals("normal")) | ||
| 194 | - DirectivePushQueue.put6003(next, "到站@系统"); | ||
| 195 | - */ | ||
| 196 | - //下发调度指令 | ||
| 197 | - DirectivePushQueue.put6002(next, doneSum, "到站@系统", ""); | ||
| 198 | - } | ||
| 199 | - | ||
| 200 | - /** | ||
| 201 | - * 校验进站前置约束 | ||
| 202 | - * | ||
| 203 | - * @param gps | ||
| 204 | - * @return | ||
| 205 | - */ | ||
| 206 | - private boolean validInPremise(GpsEntity gps) { | ||
| 207 | - StationRoute sr = gps.getStation(); | ||
| 208 | - if (null == sr || !sr.isPremise()) | ||
| 209 | - return true; | ||
| 210 | - | ||
| 211 | - String premiseCode = gps.getPremiseCode(); | ||
| 212 | - | ||
| 213 | - if (StringUtils.isNotEmpty(premiseCode) && premiseCode.equals(gps.getStopNo())) { | ||
| 214 | - logger.info("满足前置进站约束 " + premiseCode); | ||
| 215 | - return true; | ||
| 216 | - } else { | ||
| 217 | - logger.info(gps.getNbbm() + " not premiseCode 不满足前置进站约束 " + premiseCode); | ||
| 218 | - } | ||
| 219 | - return false; | ||
| 220 | - } | ||
| 221 | - | ||
| 222 | - /** | ||
| 223 | - * 进站既进场 | ||
| 224 | - * | ||
| 225 | - * @param sch | ||
| 226 | - */ | ||
| 227 | - private void inStationAndInPark(ScheduleRealInfo sch, ScheduleRealInfo next) { | ||
| 228 | - LineConfig config = lineConfigData.get(sch.getXlBm()); | ||
| 229 | - //限定出站既出场的停车场 | ||
| 230 | - List<String> parks = config.findTwinsParkList(); | ||
| 231 | - boolean limitPark = null != parks && parks.size() > 0; | ||
| 232 | - | ||
| 233 | - | ||
| 234 | - if (next.getBcType().equals("in") && config.getOutConfig() == 2 && isEmptyMileage(next) | ||
| 235 | - && (!limitPark || parks.contains(next.getZdzCode()))) { | ||
| 236 | - | ||
| 237 | - endSch(next, sch.getZdsjActualTime()); | ||
| 238 | - | ||
| 239 | - sendUtils.refreshSch(next); | ||
| 240 | - dayOfSchedule.save(next); | ||
| 241 | - | ||
| 242 | - //分班的时候,需要再跳过1个班次 | ||
| 243 | - next = dayOfSchedule.next(next); | ||
| 244 | - if (next != null) | ||
| 245 | - dayOfSchedule.addExecPlan(next); | ||
| 246 | - | ||
| 247 | - //进场,切换成非营运状态 | ||
| 248 | - nonService(sch, "进场@系统"); | ||
| 249 | - } | ||
| 250 | - } | ||
| 251 | - | ||
| 252 | - | ||
| 253 | - private boolean isEmptyMileage(ScheduleRealInfo sch) { | ||
| 254 | - return sch.getBcsj() == 0 || sch.getJhlcOrig().intValue() == 0; | ||
| 255 | - } | ||
| 256 | - | ||
| 257 | - | ||
| 258 | - /** | ||
| 259 | - * 切换为非营运状态 | ||
| 260 | - * | ||
| 261 | - * @param sch | ||
| 262 | - * @param sender | ||
| 263 | - */ | ||
| 264 | - private void nonService(ScheduleRealInfo sch, String sender) { | ||
| 265 | - gpsStatusManager.changeServiceState(sch.getClZbh(), sch.getXlDir(), 1, sender); | ||
| 266 | - } | ||
| 267 | - | ||
| 268 | - private void endSch(ScheduleRealInfo sch, Long t) { | ||
| 269 | - sch.setFcsjActualAll(t); | ||
| 270 | - sch.setZdsjActualAll(t); | ||
| 271 | - } | ||
| 272 | - | ||
| 273 | - private void transformUpDown(GpsEntity gps, ScheduleRealInfo sch) { | ||
| 274 | - if (null == sch) | ||
| 275 | - return; | ||
| 276 | - byte upDown = Byte.parseByte(sch.getXlDir()); | ||
| 277 | - //gps 切换走向 | ||
| 278 | - gps.setUpDown(upDown); | ||
| 279 | - gps.setPremiseCode(null); | ||
| 280 | - | ||
| 281 | - List<StationRoute> srs = GeoCacheData.getStationRoute(sch.getXlBm(), upDown); | ||
| 282 | - StationRoute station = GeoUtils.gpsInStation(gps, srs); | ||
| 283 | - if (station != null) { | ||
| 284 | - gps.setStopNo(station.getCode()); | ||
| 285 | - } | ||
| 286 | - } | ||
| 287 | - | ||
| 288 | - private boolean isInPark(GpsEntity gps, GpsEntity prve) { | ||
| 289 | - if (StringUtils.isNotEmpty(gps.getCarparkNo()) && StringUtils.isEmpty(prve.getCarparkNo())) | ||
| 290 | - return true; | ||
| 291 | - return false; | ||
| 292 | - } | 1 | +package com.bsth.data.gpsdata_v2.handlers; |
| 2 | + | ||
| 3 | +import com.bsth.data.LineConfigData; | ||
| 4 | +import com.bsth.data.gpsdata_v2.cache.GeoCacheData; | ||
| 5 | +import com.bsth.data.gpsdata_v2.cache.GpsCacheData; | ||
| 6 | +import com.bsth.data.gpsdata_v2.entity.GpsEntity; | ||
| 7 | +import com.bsth.data.gpsdata_v2.entity.StationRoute; | ||
| 8 | +import com.bsth.data.gpsdata_v2.rfid.handle.RfidDataHandler; | ||
| 9 | +import com.bsth.data.gpsdata_v2.status_manager.GpsStatusManager; | ||
| 10 | +import com.bsth.data.gpsdata_v2.utils.GeoUtils; | ||
| 11 | +import com.bsth.data.msg_queue.DirectivePushQueue; | ||
| 12 | +import com.bsth.data.schedule.DayOfSchedule; | ||
| 13 | +import com.bsth.data.schedule.late_adjust.LateAdjustHandle; | ||
| 14 | +import com.bsth.entity.realcontrol.LineConfig; | ||
| 15 | +import com.bsth.entity.realcontrol.ScheduleRealInfo; | ||
| 16 | +import com.bsth.websocket.handler.SendUtils; | ||
| 17 | +import org.apache.commons.lang3.StringUtils; | ||
| 18 | +import org.slf4j.Logger; | ||
| 19 | +import org.slf4j.LoggerFactory; | ||
| 20 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 21 | +import org.springframework.stereotype.Component; | ||
| 22 | + | ||
| 23 | +import java.util.List; | ||
| 24 | + | ||
| 25 | +/** | ||
| 26 | + * 车辆到站处理程序 | ||
| 27 | + * Created by panzhao on 2017/11/16. | ||
| 28 | + */ | ||
| 29 | +@Component | ||
| 30 | +public class InStationProcess { | ||
| 31 | + | ||
| 32 | + @Autowired | ||
| 33 | + DayOfSchedule dayOfSchedule; | ||
| 34 | + | ||
| 35 | + @Autowired | ||
| 36 | + LineConfigData lineConfigData; | ||
| 37 | + | ||
| 38 | + @Autowired | ||
| 39 | + SendUtils sendUtils; | ||
| 40 | + | ||
| 41 | + @Autowired | ||
| 42 | + GpsStatusManager gpsStatusManager; | ||
| 43 | + | ||
| 44 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | ||
| 45 | + | ||
| 46 | + public void process(GpsEntity gps) { | ||
| 47 | + //自动执行的班次信号,滚蛋 | ||
| 48 | + LineConfig config = lineConfigData.get(gps.getLineId()); | ||
| 49 | + if (null != config && config.isAutoExec()) | ||
| 50 | + return; | ||
| 51 | + | ||
| 52 | + GpsEntity prev = GpsCacheData.getPrev(gps); | ||
| 53 | + | ||
| 54 | + if (null == prev) | ||
| 55 | + return; | ||
| 56 | + | ||
| 57 | + //从站外到站内 | ||
| 58 | + if (prev.getInstation() == 0 && gps.getInstation() > 0) { | ||
| 59 | + inStation(gps, prev); | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + //从站内到另一个站内 | ||
| 63 | + if (prev.getInstation() == 1 && gps.getInstation() == 1 | ||
| 64 | + && !prev.getStopNo().equals(gps.getStopNo()) | ||
| 65 | + && !prev.getStation().getName().equals(gps.getStation().getName())) | ||
| 66 | + inStation(gps, prev); | ||
| 67 | + | ||
| 68 | + //从场内到站内 | ||
| 69 | + if (prev.getInstation() == 2 && gps.getInstation() == 1) { | ||
| 70 | + inStation(gps, prev); | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + //被起点站覆盖的情况下进场 | ||
| 74 | + if (isInPark(gps, prev)) | ||
| 75 | + inStation(gps, prev); | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | + /** | ||
| 79 | + * 进站 | ||
| 80 | + * | ||
| 81 | + * @param gps | ||
| 82 | + * @param prev | ||
| 83 | + */ | ||
| 84 | + private void inStation(GpsEntity gps, GpsEntity prev) { | ||
| 85 | + logger.info("进站记录(到达时间:" + gps.getArrTime() + " 进出站状态:" + gps.getInstation() + " 站点编号:" + gps.getStopNo() + " deviceId:" + gps.getDeviceId() + " nbbm:" + gps.getNbbm() + ")"); | ||
| 86 | + ScheduleRealInfo sch = dayOfSchedule.executeCurr(gps.getNbbm()); | ||
| 87 | + boolean flow = true; | ||
| 88 | + //要经过2个中途站才能进 | ||
| 89 | + int count = GpsCacheData.lastInTrailsSize(gps); | ||
| 90 | + if (null != sch) | ||
| 91 | + logger.info("班次id: -" + sch.getId() + " count:" + count+" sch.getZdzCode(): "+sch.getZdzCode()+" sch.getZdzCode(): "+sch.getZdzCode()+" gps.getCarparkNo() :"+gps.getCarparkNo()); | ||
| 92 | + else | ||
| 93 | + logger.info("sch is null...."); | ||
| 94 | + List<StationRoute> routes = GeoCacheData.getStationRoute(gps.getLineId(), gps.getUpDown()); | ||
| 95 | + if (null != sch && isNormalSch(sch) && gps.getInstation() == 1 && routes.size() > 4 | ||
| 96 | + && count < 2) { | ||
| 97 | + logger.info("没有进中途站,拒绝进站... -" + gps.getNbbm() + " -time:" + gps.getTimestamp()); | ||
| 98 | + flow = false; | ||
| 99 | + } | ||
| 100 | + | ||
| 101 | + //进起点 rfid状态复位 | ||
| 102 | + if (null != sch && ((sch.getQdzCode().equals(gps.getStopNo()) && gps.getInstation() > 0) || sch.getQdzCode().equals(gps.getCarparkNo()))) { | ||
| 103 | + resetRfid(sch); | ||
| 104 | + } | ||
| 105 | + | ||
| 106 | + boolean isEnd = false; | ||
| 107 | + | ||
| 108 | + //进终点 rfid状态复位 | ||
| 109 | + if (flow && null != sch && | ||
| 110 | + ((sch.getZdzCode().equals(gps.getStopNo()) && gps.getInstation() > 0) || sch.getZdzCode().equals(gps.getCarparkNo()))) { | ||
| 111 | + inEndStation(sch, gps); | ||
| 112 | + isEnd = true; | ||
| 113 | + resetRfid(sch); | ||
| 114 | + } | ||
| 115 | + | ||
| 116 | + GpsCacheData.in(gps, isEnd); | ||
| 117 | + } | ||
| 118 | + | ||
| 119 | + private boolean isNormalSch(ScheduleRealInfo sch) { | ||
| 120 | + return sch.getBcType().equals("normal"); | ||
| 121 | + } | ||
| 122 | + | ||
| 123 | + private boolean isNotInOut(ScheduleRealInfo sch) { | ||
| 124 | + return !sch.getBcType().equals("in") && !sch.getBcType().equals("out"); | ||
| 125 | + } | ||
| 126 | + | ||
| 127 | + /** | ||
| 128 | + * 进班次终点 | ||
| 129 | + * | ||
| 130 | + * @param gps | ||
| 131 | + */ | ||
| 132 | + private void inEndStation(ScheduleRealInfo sch, GpsEntity gps) { | ||
| 133 | + String nbbm = sch.getClZbh(); | ||
| 134 | + //校验进站前置约束 | ||
| 135 | + if (!validInPremise(gps) && isNormalSch(sch)) | ||
| 136 | + return; | ||
| 137 | + | ||
| 138 | + //实达时间不覆盖 | ||
| 139 | + if (StringUtils.isNotEmpty(sch.getZdsjActual())) | ||
| 140 | + return; | ||
| 141 | + | ||
| 142 | + //应用到离站缓冲区设置参数 | ||
| 143 | + long rsT = lineConfigData.applyIn(sch, gps.getTimestamp()); | ||
| 144 | + | ||
| 145 | + sch.setZdsjActualAll(rsT); | ||
| 146 | + sch.setSiginCompate(2); | ||
| 147 | + | ||
| 148 | + //持久化 | ||
| 149 | + dayOfSchedule.save(sch); | ||
| 150 | + | ||
| 151 | + //车辆的下一个班次 | ||
| 152 | + ScheduleRealInfo next = dayOfSchedule.next(sch); | ||
| 153 | + if (next != null) { | ||
| 154 | + dayOfSchedule.addExecPlan(next); | ||
| 155 | + inStationAndInPark(sch, next);//进站既进场 | ||
| 156 | + } | ||
| 157 | + else | ||
| 158 | + dayOfSchedule.removeExecPlan(nbbm); | ||
| 159 | + | ||
| 160 | + //通知误点停靠程序,有车辆到站 | ||
| 161 | + LateAdjustHandle.carArrive(gps, next); | ||
| 162 | + //LateAdjustHandle.carArrive(gps); | ||
| 163 | + | ||
| 164 | + //路牌的下一个班次,页面显示起点实际到达时间 | ||
| 165 | + ScheduleRealInfo lpNext = dayOfSchedule.nextByLp(sch); | ||
| 166 | + if (lpNext != null) { | ||
| 167 | + lpNext.setQdzArrDatesj(sch.getZdsjActual()); | ||
| 168 | + } | ||
| 169 | + | ||
| 170 | + //已完成班次数 | ||
| 171 | + int doneSum = dayOfSchedule.doneSum(nbbm); | ||
| 172 | + //webSocket | ||
| 173 | + sendUtils.sendZdsj(sch, lpNext, doneSum); | ||
| 174 | + | ||
| 175 | + logger.info("车辆:" + nbbm + " 班次:" + sch.getDfsj() + "到终点, 时间:" + sch.getZdsjActual() + " -stopNo: " + gps.getStopNo()); | ||
| 176 | + | ||
| 177 | + //清除车辆误点调整监听 | ||
| 178 | + LateAdjustHandle.remove(sch); | ||
| 179 | + | ||
| 180 | + //将gps转换成下一个班次走向的站内信号(应对只有一个站内信号 即 发出时) | ||
| 181 | + transformUpDown(gps, next); | ||
| 182 | + | ||
| 183 | + //套跑 -下发线路切换指令 | ||
| 184 | + if (null != next && !next.getXlBm().equals(sch.getXlBm())) { | ||
| 185 | + gpsStatusManager.changeLine(next.getClZbh(), next.getXlBm(), "套跑@系统"); | ||
| 186 | + } | ||
| 187 | + | ||
| 188 | + /** | ||
| 189 | + * 注意: | ||
| 190 | + * 要先发运营指令,再发调度指令 | ||
| 191 | + */ | ||
| 192 | + if(null == next && gps.isService()){ | ||
| 193 | + nonService(sch, "结束@系统");//营运结束 | ||
| 194 | + } | ||
| 195 | + | ||
| 196 | + /** | ||
| 197 | + * 下一班不是全程班次的时候,下发运营指令 | ||
| 198 | + * 全程班次时,由网关根据进出起终点,自动切换走向 | ||
| 199 | + | ||
| 200 | + if(null != next && !next.getBcType().equals("normal")) | ||
| 201 | + DirectivePushQueue.put6003(next, "到站@系统"); | ||
| 202 | + */ | ||
| 203 | + //下发调度指令 | ||
| 204 | + DirectivePushQueue.put6002(next, doneSum, "到站@系统", ""); | ||
| 205 | + } | ||
| 206 | + | ||
| 207 | + /** | ||
| 208 | + * 校验进站前置约束 | ||
| 209 | + * | ||
| 210 | + * @param gps | ||
| 211 | + * @return | ||
| 212 | + */ | ||
| 213 | + private boolean validInPremise(GpsEntity gps) { | ||
| 214 | + StationRoute sr = gps.getStation(); | ||
| 215 | + if (null == sr || !sr.isPremise()) | ||
| 216 | + return true; | ||
| 217 | + | ||
| 218 | + String premiseCode = gps.getPremiseCode(); | ||
| 219 | + | ||
| 220 | + if (StringUtils.isNotEmpty(premiseCode) && premiseCode.equals(gps.getStopNo())) { | ||
| 221 | + logger.info("满足前置进站约束 " + premiseCode); | ||
| 222 | + return true; | ||
| 223 | + } else { | ||
| 224 | + logger.info(gps.getNbbm() + " not premiseCode 不满足前置进站约束 " + premiseCode); | ||
| 225 | + } | ||
| 226 | + return false; | ||
| 227 | + } | ||
| 228 | + | ||
| 229 | + /** | ||
| 230 | + * 进站既进场 | ||
| 231 | + * | ||
| 232 | + * @param sch | ||
| 233 | + */ | ||
| 234 | + private void inStationAndInPark(ScheduleRealInfo sch, ScheduleRealInfo next) { | ||
| 235 | + LineConfig config = lineConfigData.get(sch.getXlBm()); | ||
| 236 | + //限定出站既出场的停车场 | ||
| 237 | + List<String> parks = config.findTwinsParkList(); | ||
| 238 | + boolean limitPark = null != parks && parks.size() > 0; | ||
| 239 | + | ||
| 240 | + | ||
| 241 | + if (next.getBcType().equals("in") && config.getOutConfig() == 2 && isEmptyMileage(next) | ||
| 242 | + && (!limitPark || parks.contains(next.getZdzCode()))) { | ||
| 243 | + | ||
| 244 | + endSch(next, sch.getZdsjActualTime()); | ||
| 245 | + | ||
| 246 | + sendUtils.refreshSch(next); | ||
| 247 | + dayOfSchedule.save(next); | ||
| 248 | + | ||
| 249 | + //分班的时候,需要再跳过1个班次 | ||
| 250 | + next = dayOfSchedule.next(next); | ||
| 251 | + if (next != null) | ||
| 252 | + dayOfSchedule.addExecPlan(next); | ||
| 253 | + | ||
| 254 | + //进场,切换成非营运状态 | ||
| 255 | + nonService(sch, "进场@系统"); | ||
| 256 | + } | ||
| 257 | + } | ||
| 258 | + | ||
| 259 | + | ||
| 260 | + private boolean isEmptyMileage(ScheduleRealInfo sch) { | ||
| 261 | + return sch.getBcsj() == 0 || sch.getJhlcOrig().intValue() == 0; | ||
| 262 | + } | ||
| 263 | + | ||
| 264 | + | ||
| 265 | + /** | ||
| 266 | + * 切换为非营运状态 | ||
| 267 | + * | ||
| 268 | + * @param sch | ||
| 269 | + * @param sender | ||
| 270 | + */ | ||
| 271 | + private void nonService(ScheduleRealInfo sch, String sender) { | ||
| 272 | + gpsStatusManager.changeServiceState(sch.getClZbh(), sch.getXlDir(), 1, sender); | ||
| 273 | + } | ||
| 274 | + | ||
| 275 | + private void endSch(ScheduleRealInfo sch, Long t) { | ||
| 276 | + sch.setFcsjActualAll(t); | ||
| 277 | + sch.setZdsjActualAll(t); | ||
| 278 | + } | ||
| 279 | + | ||
| 280 | + private void transformUpDown(GpsEntity gps, ScheduleRealInfo sch) { | ||
| 281 | + if (null == sch) | ||
| 282 | + return; | ||
| 283 | + byte upDown = Byte.parseByte(sch.getXlDir()); | ||
| 284 | + //gps 切换走向 | ||
| 285 | + gps.setUpDown(upDown); | ||
| 286 | + gps.setPremiseCode(null); | ||
| 287 | + | ||
| 288 | + List<StationRoute> srs = GeoCacheData.getStationRoute(sch.getXlBm(), upDown); | ||
| 289 | + StationRoute station = GeoUtils.gpsInStation(gps, srs); | ||
| 290 | + if (station != null) { | ||
| 291 | + gps.setStopNo(station.getCode()); | ||
| 292 | + } | ||
| 293 | + } | ||
| 294 | + | ||
| 295 | + private boolean isInPark(GpsEntity gps, GpsEntity prve) { | ||
| 296 | + if (StringUtils.isNotEmpty(gps.getCarparkNo()) && StringUtils.isEmpty(prve.getCarparkNo())) | ||
| 297 | + return true; | ||
| 298 | + return false; | ||
| 299 | + } | ||
| 300 | + | ||
| 301 | + private void resetRfid(ScheduleRealInfo sch) { | ||
| 302 | + sch.setRfidState(0); | ||
| 303 | + sch.setFirstRfidState(0); | ||
| 304 | + } | ||
| 293 | } | 305 | } |
| 294 | \ No newline at end of file | 306 | \ No newline at end of file |
src/main/java/com/bsth/data/gpsdata_v2/handlers/OutStationProcess.java
| 1 | -package com.bsth.data.gpsdata_v2.handlers; | ||
| 2 | - | ||
| 3 | -import com.bsth.data.LineConfigData; | ||
| 4 | -import com.bsth.data.gpsdata_v2.cache.GpsCacheData; | ||
| 5 | -import com.bsth.data.gpsdata_v2.entity.GpsEntity; | ||
| 6 | -import com.bsth.data.gpsdata_v2.status_manager.GpsStatusManager; | ||
| 7 | -import com.bsth.data.gpsdata_v2.utils.SignalSchPlanMatcher; | ||
| 8 | -import com.bsth.data.schedule.DayOfSchedule; | ||
| 9 | -import com.bsth.data.schedule.late_adjust.LateAdjustHandle; | ||
| 10 | -import com.bsth.entity.realcontrol.LineConfig; | ||
| 11 | -import com.bsth.entity.realcontrol.ScheduleRealInfo; | ||
| 12 | -import com.bsth.websocket.handler.SendUtils; | ||
| 13 | -import org.apache.commons.lang3.StringUtils; | ||
| 14 | -import org.slf4j.Logger; | ||
| 15 | -import org.slf4j.LoggerFactory; | ||
| 16 | -import org.springframework.beans.factory.annotation.Autowired; | ||
| 17 | -import org.springframework.stereotype.Component; | ||
| 18 | - | ||
| 19 | -import java.util.List; | ||
| 20 | - | ||
| 21 | -/** | ||
| 22 | - * 车辆出站处理程序 | ||
| 23 | - * Created by panzhao on 2017/11/16. | ||
| 24 | - */ | ||
| 25 | -@Component | ||
| 26 | -public class OutStationProcess { | ||
| 27 | - | ||
| 28 | - @Autowired | ||
| 29 | - DayOfSchedule dayOfSchedule; | ||
| 30 | - | ||
| 31 | - Logger logger = LoggerFactory.getLogger(this.getClass()); | ||
| 32 | - | ||
| 33 | - @Autowired | ||
| 34 | - LineConfigData lineConfigData; | ||
| 35 | - | ||
| 36 | - @Autowired | ||
| 37 | - SendUtils sendUtils; | ||
| 38 | - | ||
| 39 | - @Autowired | ||
| 40 | - SignalSchPlanMatcher signalSchPlanMatcher; | ||
| 41 | - | ||
| 42 | - @Autowired | ||
| 43 | - GpsStatusManager gpsStatusManager; | ||
| 44 | - private final static int MAX_BEFORE_TIME = 1000 * 60 * 60 * 3; | ||
| 45 | - | ||
| 46 | - public void process(GpsEntity gps) { | ||
| 47 | - //自动执行的线路,滚蛋 | ||
| 48 | - LineConfig config = lineConfigData.get(gps.getLineId()); | ||
| 49 | - if (null != config && config.isAutoExec()) | ||
| 50 | - return; | ||
| 51 | - | ||
| 52 | - GpsEntity prev = GpsCacheData.getPrev(gps); | ||
| 53 | - | ||
| 54 | - if (null == prev) | ||
| 55 | - return; | ||
| 56 | - | ||
| 57 | - //从站内到站外 | ||
| 58 | - if (prev.getInstation() > 0 && gps.getInstation() == 0) | ||
| 59 | - outStation(gps, prev); | ||
| 60 | - | ||
| 61 | - //从站内到另一个站内 | ||
| 62 | - if (prev.getInstation() > 0 && gps.getInstation() > 0 | ||
| 63 | - && !prev.getStopNo().equals(gps.getStopNo())) | ||
| 64 | - outStation(gps, prev); | ||
| 65 | - | ||
| 66 | - //在被起点站覆盖的情况下出场 | ||
| 67 | - if (isOutPark(gps, prev)) | ||
| 68 | - outStation(gps, prev); | ||
| 69 | - } | ||
| 70 | - | ||
| 71 | - /** | ||
| 72 | - * 出站 | ||
| 73 | - * | ||
| 74 | - * @param gps | ||
| 75 | - */ | ||
| 76 | - private void outStation(GpsEntity gps, GpsEntity prev) { | ||
| 77 | - logger.info("出站记录(到达时间:" + gps.getArrTime() + " 进出站状态:" + gps.getInstation() + " 站点编号:" + gps.getStopNo() + " deviceId:" + gps.getDeviceId() + " nbbm:" + gps.getNbbm() + ")"); | ||
| 78 | - ScheduleRealInfo sch = dayOfSchedule.executeCurr(gps.getNbbm()); | ||
| 79 | - | ||
| 80 | - if (null != sch) | ||
| 81 | - logger.info("班次id: " + sch.getId() + " sch.getQdzCode():" + sch.getQdzCode() + " prev.getStopNo():" + prev.getStopNo() + " prev.getStopNo():" + prev.getStopNo() + " sch.getQdzCode():" + sch.getQdzCode() +" prev.getCarparkNo() :"+prev.getCarparkNo()+" diff :"+((int) (sch.getDfsjT() - gps.getTimestamp()))+" dayOfSchedule.isFirstOut(sch) && diff"+(dayOfSchedule.isFirstOut(sch))+" sch.getFcsjActual():"+sch.getFcsjActual()+" StringUtils.isNotEmpty(sch.getFcsjActual())&& !outManyFit(gps, sch) :"+(StringUtils.isNotEmpty(sch.getFcsjActual())&& !outManyFit(gps, sch))+ ")"); | ||
| 82 | - else | ||
| 83 | - logger.info("sch is null...."); | ||
| 84 | - //起点发车 | ||
| 85 | - if (null != sch && | ||
| 86 | - ((sch.getQdzCode().equals(prev.getStopNo()) | ||
| 87 | - && (gps.getInstation() == 0 || !gps.getStopNo().equals(prev.getStopNo()))) | ||
| 88 | - || sch.getQdzCode().equals(prev.getCarparkNo()))) { | ||
| 89 | - //发车班次匹配 | ||
| 90 | - if (!signalSchPlanMatcher.outMatch(gps, sch)) { | ||
| 91 | - outStation(gps, prev); | ||
| 92 | - return; | ||
| 93 | - } | ||
| 94 | - | ||
| 95 | - int diff = (int) (sch.getDfsjT() - gps.getTimestamp()); | ||
| 96 | - //首班出场最多提前3小时 | ||
| 97 | - if (dayOfSchedule.isFirstOut(sch) && diff > MAX_BEFORE_TIME) | ||
| 98 | - return; | ||
| 99 | - | ||
| 100 | - gps.setPremiseCode(null);//清除前置围栏标记 | ||
| 101 | - | ||
| 102 | - if (StringUtils.isNotEmpty(sch.getFcsjActual()) | ||
| 103 | - && !outManyFit(gps, sch)) { | ||
| 104 | - return;//班次已经实发 | ||
| 105 | - } | ||
| 106 | - | ||
| 107 | - //应用到离站缓冲区设置参数 | ||
| 108 | - long rsT = lineConfigData.applyOut(sch, gps.getTimestamp()); | ||
| 109 | - //实发时间 | ||
| 110 | - sch.setFcsjActualAll(rsT); | ||
| 111 | - sch.setSiginCompate(1); | ||
| 112 | - | ||
| 113 | - //出站既出场 | ||
| 114 | - outStationAndOutPark(sch); | ||
| 115 | - | ||
| 116 | - //webSocket | ||
| 117 | - sendUtils.sendFcsj(sch); | ||
| 118 | - | ||
| 119 | - //持久化 | ||
| 120 | - dayOfSchedule.save(sch); | ||
| 121 | - | ||
| 122 | - //清理应发未发标记 | ||
| 123 | - LateAdjustHandle.remove(sch); | ||
| 124 | - | ||
| 125 | - //发车的时候,同步一下状态 | ||
| 126 | - /*if (!gps.isService() && !dayOfSchedule.emptyService(sch)) | ||
| 127 | - gpsStatusManager.changeServiceState(sch.getClZbh(), sch.getXlDir(), 0, "发车@系统"); | ||
| 128 | -*/ | ||
| 129 | - logger.info("车辆:" + sch.getClZbh() + " 班次:" + sch.getDfsj() + "发车, 时间:" + sch.getFcsjActual()); | ||
| 130 | - } | ||
| 131 | - | ||
| 132 | - GpsCacheData.out(gps); | ||
| 133 | - } | ||
| 134 | - | ||
| 135 | - /** | ||
| 136 | - * 是否是一个更合适的发车信号 | ||
| 137 | - * | ||
| 138 | - * @param gps | ||
| 139 | - * @param sch | ||
| 140 | - * @return | ||
| 141 | - */ | ||
| 142 | - private boolean outManyFit(GpsEntity gps, ScheduleRealInfo sch) { | ||
| 143 | - LineConfig conf = lineConfigData.get(sch.getXlBm()); | ||
| 144 | - if (null != conf && conf.isLockFirstOutTime()) | ||
| 145 | - return false; | ||
| 146 | - | ||
| 147 | - if (StringUtils.isNotEmpty(sch.getZdsjActual())) | ||
| 148 | - return false; | ||
| 149 | - | ||
| 150 | - long t1 = sch.getFcsjActualTime(); | ||
| 151 | - long t2 = gps.getTimestamp(); | ||
| 152 | - long c = sch.getDfsjT(); | ||
| 153 | - | ||
| 154 | - int threshold = 1000 * 60 * 5; | ||
| 155 | - if (Math.abs(t2 - c) < threshold && c - t1 > threshold) { | ||
| 156 | - return true; | ||
| 157 | - } | ||
| 158 | - | ||
| 159 | - if (c - t1 > 1000 * 60 * 60 * 2 && Math.abs(t2 - c) < c - t1) { | ||
| 160 | - return true; | ||
| 161 | - } | ||
| 162 | - return false; | ||
| 163 | - } | ||
| 164 | - | ||
| 165 | - private void outStationAndOutPark(ScheduleRealInfo sch) { | ||
| 166 | - try { | ||
| 167 | - LineConfig config = lineConfigData.get(sch.getXlBm()); | ||
| 168 | - //限定出站既出场的停车场 | ||
| 169 | - List<String> parks = config.findTwinsParkList(); | ||
| 170 | - boolean limitPark = null != parks && parks.size() > 0; | ||
| 171 | - | ||
| 172 | - if (config != null && config.getOutConfig() == 2) { | ||
| 173 | - //出站既出场 | ||
| 174 | - ScheduleRealInfo schPrev = dayOfSchedule.prev(sch); | ||
| 175 | - if (isOut(schPrev) && isEmptyMileage(schPrev) | ||
| 176 | - && (!limitPark || parks.contains(schPrev.getQdzCode()))) { | ||
| 177 | - | ||
| 178 | - endSch(schPrev, sch.getFcsjActualTime()); | ||
| 179 | - | ||
| 180 | - //起点实到 | ||
| 181 | - sch.setQdzArrDatesj(schPrev.getZdsjActual()); | ||
| 182 | - | ||
| 183 | - sendUtils.refreshSch(schPrev); | ||
| 184 | - dayOfSchedule.save(schPrev); | ||
| 185 | - } | ||
| 186 | - } | ||
| 187 | - } catch (Exception e) { | ||
| 188 | - logger.error("", e); | ||
| 189 | - } | ||
| 190 | - } | ||
| 191 | - | ||
| 192 | - private boolean isEmptyMileage(ScheduleRealInfo sch) { | ||
| 193 | - return sch.getBcsj() == 0 || sch.getJhlcOrig().intValue() == 0; | ||
| 194 | - } | ||
| 195 | - | ||
| 196 | - private boolean isOut(ScheduleRealInfo sch) { | ||
| 197 | - return sch != null && sch.getBcType().equals("out"); | ||
| 198 | - } | ||
| 199 | - | ||
| 200 | - private void endSch(ScheduleRealInfo sch, Long t) { | ||
| 201 | - sch.setFcsjActualAll(t); | ||
| 202 | - sch.setZdsjActualAll(t); | ||
| 203 | - } | ||
| 204 | - | ||
| 205 | - private boolean isOutPark(GpsEntity gps, GpsEntity prve) { | ||
| 206 | - if (StringUtils.isNotEmpty(prve.getCarparkNo()) && StringUtils.isEmpty(gps.getCarparkNo())) | ||
| 207 | - return true; | ||
| 208 | - return false; | ||
| 209 | - } | 1 | +package com.bsth.data.gpsdata_v2.handlers; |
| 2 | + | ||
| 3 | +import com.bsth.data.LineConfigData; | ||
| 4 | +import com.bsth.data.gpsdata_v2.cache.GpsCacheData; | ||
| 5 | +import com.bsth.data.gpsdata_v2.entity.GpsEntity; | ||
| 6 | +import com.bsth.data.gpsdata_v2.status_manager.GpsStatusManager; | ||
| 7 | +import com.bsth.data.gpsdata_v2.utils.SignalSchPlanMatcher; | ||
| 8 | +import com.bsth.data.schedule.DayOfSchedule; | ||
| 9 | +import com.bsth.data.schedule.late_adjust.LateAdjustHandle; | ||
| 10 | +import com.bsth.entity.realcontrol.LineConfig; | ||
| 11 | +import com.bsth.entity.realcontrol.ScheduleRealInfo; | ||
| 12 | +import com.bsth.websocket.handler.SendUtils; | ||
| 13 | +import org.apache.commons.lang3.StringUtils; | ||
| 14 | +import org.slf4j.Logger; | ||
| 15 | +import org.slf4j.LoggerFactory; | ||
| 16 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 17 | +import org.springframework.stereotype.Component; | ||
| 18 | + | ||
| 19 | +import java.util.List; | ||
| 20 | + | ||
| 21 | +/** | ||
| 22 | + * 车辆出站处理程序 | ||
| 23 | + * Created by panzhao on 2017/11/16. | ||
| 24 | + */ | ||
| 25 | +@Component | ||
| 26 | +public class OutStationProcess { | ||
| 27 | + | ||
| 28 | + @Autowired | ||
| 29 | + DayOfSchedule dayOfSchedule; | ||
| 30 | + | ||
| 31 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | ||
| 32 | + | ||
| 33 | + @Autowired | ||
| 34 | + LineConfigData lineConfigData; | ||
| 35 | + | ||
| 36 | + @Autowired | ||
| 37 | + SendUtils sendUtils; | ||
| 38 | + | ||
| 39 | + @Autowired | ||
| 40 | + SignalSchPlanMatcher signalSchPlanMatcher; | ||
| 41 | + | ||
| 42 | + @Autowired | ||
| 43 | + GpsStatusManager gpsStatusManager; | ||
| 44 | + private final static int MAX_BEFORE_TIME = 1000 * 60 * 60 * 3; | ||
| 45 | + | ||
| 46 | + public void process(GpsEntity gps) { | ||
| 47 | + //自动执行的线路,滚蛋 | ||
| 48 | + LineConfig config = lineConfigData.get(gps.getLineId()); | ||
| 49 | + if (null != config && config.isAutoExec()) | ||
| 50 | + return; | ||
| 51 | + | ||
| 52 | + GpsEntity prev = GpsCacheData.getPrev(gps); | ||
| 53 | + | ||
| 54 | + if (null == prev) | ||
| 55 | + return; | ||
| 56 | + | ||
| 57 | + //从站内到站外 | ||
| 58 | + if (prev.getInstation() > 0 && gps.getInstation() == 0) | ||
| 59 | + outStation(gps, prev); | ||
| 60 | + | ||
| 61 | + //从站内到另一个站内 | ||
| 62 | + if (prev.getInstation() > 0 && gps.getInstation() > 0 | ||
| 63 | + && !prev.getStopNo().equals(gps.getStopNo())) | ||
| 64 | + outStation(gps, prev); | ||
| 65 | + | ||
| 66 | + //在被起点站覆盖的情况下出场 | ||
| 67 | + if (isOutPark(gps, prev)) | ||
| 68 | + outStation(gps, prev); | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + /** | ||
| 72 | + * 出站 | ||
| 73 | + * | ||
| 74 | + * @param gps | ||
| 75 | + */ | ||
| 76 | + private void outStation(GpsEntity gps, GpsEntity prev) { | ||
| 77 | + logger.info("出站记录(到达时间:" + gps.getArrTime() + " 进出站状态:" + gps.getInstation() + " 站点编号:" + gps.getStopNo() + " deviceId:" + gps.getDeviceId() + " nbbm:" + gps.getNbbm() + ")"); | ||
| 78 | + ScheduleRealInfo sch = dayOfSchedule.executeCurr(gps.getNbbm()); | ||
| 79 | + | ||
| 80 | + if (null != sch) | ||
| 81 | + logger.info("班次id: " + sch.getId() + " sch.getQdzCode():" + sch.getQdzCode() + " prev.getStopNo():" + prev.getStopNo() + " prev.getStopNo():" + prev.getStopNo() + " sch.getQdzCode():" + sch.getQdzCode() +" prev.getCarparkNo() :"+prev.getCarparkNo()+" diff :"+((int) (sch.getDfsjT() - gps.getTimestamp()))+" dayOfSchedule.isFirstOut(sch) && diff"+(dayOfSchedule.isFirstOut(sch))+" sch.getFcsjActual():"+sch.getFcsjActual()+" StringUtils.isNotEmpty(sch.getFcsjActual())&& !outManyFit(gps, sch) :"+(StringUtils.isNotEmpty(sch.getFcsjActual())&& !outManyFit(gps, sch))+ ")"); | ||
| 82 | + else | ||
| 83 | + logger.info("sch is null...."); | ||
| 84 | + //起点发车 | ||
| 85 | + if (null != sch && | ||
| 86 | + ((sch.getQdzCode().equals(prev.getStopNo()) | ||
| 87 | + && (gps.getInstation() == 0 || !gps.getStopNo().equals(prev.getStopNo()))) | ||
| 88 | + || sch.getQdzCode().equals(prev.getCarparkNo()))) { | ||
| 89 | + //发车班次匹配 | ||
| 90 | + if (!signalSchPlanMatcher.outMatch(gps, sch)) { | ||
| 91 | + outStation(gps, prev); | ||
| 92 | + return; | ||
| 93 | + } | ||
| 94 | + | ||
| 95 | + int diff = (int) (sch.getDfsjT() - gps.getTimestamp()); | ||
| 96 | + //首班出场最多提前3小时 | ||
| 97 | + if (dayOfSchedule.isFirstOut(sch) && diff > MAX_BEFORE_TIME) | ||
| 98 | + return; | ||
| 99 | + | ||
| 100 | + gps.setPremiseCode(null);//清除前置围栏标记 | ||
| 101 | + | ||
| 102 | + if (StringUtils.isNotEmpty(sch.getFcsjActual()) | ||
| 103 | + && !outManyFit(gps, sch)) { | ||
| 104 | + return;//班次已经实发 | ||
| 105 | + } | ||
| 106 | + | ||
| 107 | + //应用到离站缓冲区设置参数 | ||
| 108 | + long rsT = lineConfigData.applyOut(sch, gps.getTimestamp()); | ||
| 109 | + //实发时间 | ||
| 110 | + sch.setFcsjActualAll(rsT); | ||
| 111 | + sch.setSiginCompate(1); | ||
| 112 | + | ||
| 113 | + //出站既出场 | ||
| 114 | + outStationAndOutPark(sch); | ||
| 115 | + | ||
| 116 | + //webSocket | ||
| 117 | + sendUtils.sendFcsj(sch); | ||
| 118 | + | ||
| 119 | + //起点站rfid状态确定 | ||
| 120 | + sch.setFirstRfidState(sch.getRfidState()); | ||
| 121 | + | ||
| 122 | + //持久化 | ||
| 123 | + dayOfSchedule.save(sch); | ||
| 124 | + | ||
| 125 | + //清理应发未发标记 | ||
| 126 | + LateAdjustHandle.remove(sch); | ||
| 127 | + | ||
| 128 | + //发车的时候,同步一下状态 | ||
| 129 | + /*if (!gps.isService() && !dayOfSchedule.emptyService(sch)) | ||
| 130 | + gpsStatusManager.changeServiceState(sch.getClZbh(), sch.getXlDir(), 0, "发车@系统"); | ||
| 131 | +*/ | ||
| 132 | + logger.info("车辆:" + sch.getClZbh() + " 班次:" + sch.getDfsj() + "发车, 时间:" + sch.getFcsjActual()); | ||
| 133 | + } | ||
| 134 | + | ||
| 135 | + GpsCacheData.out(gps); | ||
| 136 | + } | ||
| 137 | + | ||
| 138 | + /** | ||
| 139 | + * 是否是一个更合适的发车信号 | ||
| 140 | + * | ||
| 141 | + * @param gps | ||
| 142 | + * @param sch | ||
| 143 | + * @return | ||
| 144 | + */ | ||
| 145 | + private boolean outManyFit(GpsEntity gps, ScheduleRealInfo sch) { | ||
| 146 | + LineConfig conf = lineConfigData.get(sch.getXlBm()); | ||
| 147 | + if (null != conf && conf.isLockFirstOutTime()) | ||
| 148 | + return false; | ||
| 149 | + | ||
| 150 | + if (StringUtils.isNotEmpty(sch.getZdsjActual())) | ||
| 151 | + return false; | ||
| 152 | + | ||
| 153 | + long t1 = sch.getFcsjActualTime(); | ||
| 154 | + long t2 = gps.getTimestamp(); | ||
| 155 | + long c = sch.getDfsjT(); | ||
| 156 | + | ||
| 157 | + int threshold = 1000 * 60 * 5; | ||
| 158 | + if (Math.abs(t2 - c) < threshold && c - t1 > threshold) { | ||
| 159 | + return true; | ||
| 160 | + } | ||
| 161 | + | ||
| 162 | + if (c - t1 > 1000 * 60 * 60 * 2 && Math.abs(t2 - c) < c - t1) { | ||
| 163 | + return true; | ||
| 164 | + } | ||
| 165 | + return false; | ||
| 166 | + } | ||
| 167 | + | ||
| 168 | + private void outStationAndOutPark(ScheduleRealInfo sch) { | ||
| 169 | + try { | ||
| 170 | + LineConfig config = lineConfigData.get(sch.getXlBm()); | ||
| 171 | + //限定出站既出场的停车场 | ||
| 172 | + List<String> parks = config.findTwinsParkList(); | ||
| 173 | + boolean limitPark = null != parks && parks.size() > 0; | ||
| 174 | + | ||
| 175 | + if (config != null && config.getOutConfig() == 2) { | ||
| 176 | + //出站既出场 | ||
| 177 | + ScheduleRealInfo schPrev = dayOfSchedule.prev(sch); | ||
| 178 | + if (isOut(schPrev) && isEmptyMileage(schPrev) | ||
| 179 | + && (!limitPark || parks.contains(schPrev.getQdzCode()))) { | ||
| 180 | + | ||
| 181 | + endSch(schPrev, sch.getFcsjActualTime()); | ||
| 182 | + | ||
| 183 | + //起点实到 | ||
| 184 | + sch.setQdzArrDatesj(schPrev.getZdsjActual()); | ||
| 185 | + | ||
| 186 | + sendUtils.refreshSch(schPrev); | ||
| 187 | + dayOfSchedule.save(schPrev); | ||
| 188 | + } | ||
| 189 | + } | ||
| 190 | + } catch (Exception e) { | ||
| 191 | + logger.error("", e); | ||
| 192 | + } | ||
| 193 | + } | ||
| 194 | + | ||
| 195 | + private boolean isEmptyMileage(ScheduleRealInfo sch) { | ||
| 196 | + return sch.getBcsj() == 0 || sch.getJhlcOrig().intValue() == 0; | ||
| 197 | + } | ||
| 198 | + | ||
| 199 | + private boolean isOut(ScheduleRealInfo sch) { | ||
| 200 | + return sch != null && sch.getBcType().equals("out"); | ||
| 201 | + } | ||
| 202 | + | ||
| 203 | + private void endSch(ScheduleRealInfo sch, Long t) { | ||
| 204 | + sch.setFcsjActualAll(t); | ||
| 205 | + sch.setZdsjActualAll(t); | ||
| 206 | + } | ||
| 207 | + | ||
| 208 | + private boolean isOutPark(GpsEntity gps, GpsEntity prve) { | ||
| 209 | + if (StringUtils.isNotEmpty(prve.getCarparkNo()) && StringUtils.isEmpty(gps.getCarparkNo())) | ||
| 210 | + return true; | ||
| 211 | + return false; | ||
| 212 | + } | ||
| 210 | } | 213 | } |
| 211 | \ No newline at end of file | 214 | \ No newline at end of file |
src/main/java/com/bsth/data/gpsdata_v2/rfid/handle/RfidDataHandler.java
| @@ -42,22 +42,37 @@ public class RfidDataHandler { | @@ -42,22 +42,37 @@ public class RfidDataHandler { | ||
| 42 | public void handle(List<RfidInfo> list){ | 42 | public void handle(List<RfidInfo> list){ |
| 43 | for (RfidInfo ri : list) { | 43 | for (RfidInfo ri : list) { |
| 44 | RfidInfo rfidInfo = nbbm2rfid.get(ri.getNbbm()); | 44 | RfidInfo rfidInfo = nbbm2rfid.get(ri.getNbbm()); |
| 45 | - if (rfidInfo == null || rfidInfo.getRecogTime().getTime() != ri.getRecogTime().getTime()) { | 45 | + // 接口获取的RFID和本地缓存识别时间不同并且识别时间在5分钟内 |
| 46 | + boolean isValid = rfidInfo == null || ri.getRecogTime() != null && rfidInfo.getRecogTime().getTime() != ri.getRecogTime().getTime() && ri.getRecogTime().getTime() > System.currentTimeMillis() - 300000; | ||
| 47 | + if (isValid) { | ||
| 46 | nbbm2rfid.put(ri.getNbbm(), ri); | 48 | nbbm2rfid.put(ri.getNbbm(), ri); |
| 47 | ScheduleRealInfo scheduleRealInfo = dayOfSchedule.executeCurr(ri.getNbbm()); | 49 | ScheduleRealInfo scheduleRealInfo = dayOfSchedule.executeCurr(ri.getNbbm()); |
| 48 | if (scheduleRealInfo == null) { | 50 | if (scheduleRealInfo == null) { |
| 49 | continue; | 51 | continue; |
| 50 | } | 52 | } |
| 51 | - int state = 0; | 53 | + if (isInout(scheduleRealInfo)) { |
| 54 | + scheduleRealInfo.setFirstRfidState(0); | ||
| 55 | + continue; | ||
| 56 | + } | ||
| 57 | + int state = 1; | ||
| 52 | if (ri.getLabelid() != null) { | 58 | if (ri.getLabelid() != null) { |
| 53 | - state |= 1; | 59 | + state |= 2; |
| 54 | } | 60 | } |
| 55 | if (ri.getEmployeeCard() != null) { | 61 | if (ri.getEmployeeCard() != null) { |
| 56 | - state |= 2; | 62 | + state |= 4; |
| 57 | } | 63 | } |
| 64 | + int firstRfidState = scheduleRealInfo.getFirstRfidState(); | ||
| 58 | if (scheduleRealInfo.getRfidState() < state) { | 65 | if (scheduleRealInfo.getRfidState() < state) { |
| 59 | scheduleRealInfo.setRfidState(state); | 66 | scheduleRealInfo.setRfidState(state); |
| 60 | sendUtils.sendRfid(scheduleRealInfo); | 67 | sendUtils.sendRfid(scheduleRealInfo); |
| 68 | + dayOfSchedule.save(scheduleRealInfo); | ||
| 69 | + logger.info("rfid:" + scheduleRealInfo.getClZbh() + "," + scheduleRealInfo.getRfidState()); | ||
| 70 | + } | ||
| 71 | + if ((firstRfidState & 0xFF0000) == 0) { | ||
| 72 | + scheduleRealInfo.setFirstRfidState(firstRfidState | 0xFF0000); | ||
| 73 | + sendUtils.sendRfid(scheduleRealInfo); | ||
| 74 | + dayOfSchedule.save(scheduleRealInfo); | ||
| 75 | + logger.info("rfid:" + scheduleRealInfo.getClZbh() + "," + scheduleRealInfo.getRfidState()); | ||
| 61 | } | 76 | } |
| 62 | } | 77 | } |
| 63 | } | 78 | } |
| @@ -65,10 +80,6 @@ public class RfidDataHandler { | @@ -65,10 +80,6 @@ public class RfidDataHandler { | ||
| 65 | //checkValid(); | 80 | //checkValid(); |
| 66 | } | 81 | } |
| 67 | 82 | ||
| 68 | - public static void resetRfid(String nbbm) { | ||
| 69 | - nbbm2rfid.remove(nbbm); | ||
| 70 | - } | ||
| 71 | - | ||
| 72 | /** | 83 | /** |
| 73 | * 检查rfid状态是否有效,超过5分钟的rfid信号标记为无效 | 84 | * 检查rfid状态是否有效,超过5分钟的rfid信号标记为无效 |
| 74 | */ | 85 | */ |
| @@ -89,4 +100,8 @@ public class RfidDataHandler { | @@ -89,4 +100,8 @@ public class RfidDataHandler { | ||
| 89 | } | 100 | } |
| 90 | } | 101 | } |
| 91 | } | 102 | } |
| 103 | + | ||
| 104 | + private boolean isInout(ScheduleRealInfo scheduleRealInfo) { | ||
| 105 | + return "in".equals(scheduleRealInfo.getBcType()) || "out".equals(scheduleRealInfo.getBcType()); | ||
| 106 | + } | ||
| 92 | } | 107 | } |
| 93 | \ No newline at end of file | 108 | \ No newline at end of file |
src/main/java/com/bsth/data/schedule/DayOfSchedule.java
| @@ -444,8 +444,8 @@ public class DayOfSchedule { | @@ -444,8 +444,8 @@ public class DayOfSchedule { | ||
| 444 | try{ | 444 | try{ |
| 445 | final List<ScheduleRealInfo> pstList = list; | 445 | final List<ScheduleRealInfo> pstList = list; |
| 446 | //写入 | 446 | //写入 |
| 447 | - jdbcTemplate.batchUpdate("insert into bsth_c_s_sp_info_real(id,bc_type,bcs,bcsj,cl_zbh,create_date,dfsj,directive_state,fcno,fcsj,fcsj_actual,j_gh,j_name,jhlc,lp_name,qdz_code,qdz_name,real_exec_date,remarks,s_gh,s_name,schedule_date,schedule_date_str,sflj,sp_id,status,update_date,xl_bm,xl_dir,xl_name,zdsj,zdsj_actual,zdz_code,zdz_name,ccno,df_auto,fgs_bm,fgs_name,gs_bm,gs_name,online,adjust_exps,reissue,jhlc_orig,sigin_compate,drift_status,cc_service,major_station_name)" + | ||
| 448 | - " VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", new BatchPreparedStatementSetter() { | 447 | + jdbcTemplate.batchUpdate("insert into bsth_c_s_sp_info_real(id,bc_type,bcs,bcsj,cl_zbh,create_date,dfsj,directive_state,fcno,fcsj,fcsj_actual,j_gh,j_name,jhlc,lp_name,qdz_code,qdz_name,real_exec_date,remarks,s_gh,s_name,schedule_date,schedule_date_str,sflj,sp_id,status,update_date,xl_bm,xl_dir,xl_name,zdsj,zdsj_actual,zdz_code,zdz_name,ccno,df_auto,fgs_bm,fgs_name,gs_bm,gs_name,online,adjust_exps,reissue,jhlc_orig,sigin_compate,drift_status,cc_service,major_station_name,rfid_state,first_rfid_state)" + |
| 448 | + " VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", new BatchPreparedStatementSetter() { | ||
| 449 | @Override | 449 | @Override |
| 450 | public void setValues(PreparedStatement ps, int i) throws SQLException { | 450 | public void setValues(PreparedStatement ps, int i) throws SQLException { |
| 451 | ScheduleRealInfo sch = pstList.get(i); | 451 | ScheduleRealInfo sch = pstList.get(i); |
| @@ -497,6 +497,8 @@ public class DayOfSchedule { | @@ -497,6 +497,8 @@ public class DayOfSchedule { | ||
| 497 | ps.setInt(46, sch.getDriftStatus()); | 497 | ps.setInt(46, sch.getDriftStatus()); |
| 498 | ps.setBoolean(47, sch.isCcService()); | 498 | ps.setBoolean(47, sch.isCcService()); |
| 499 | ps.setString(48, sch.getMajorStationName()); | 499 | ps.setString(48, sch.getMajorStationName()); |
| 500 | + ps.setInt(49, sch.getRfidState()); | ||
| 501 | + ps.setInt(50, sch.getFirstRfidState()); | ||
| 500 | } | 502 | } |
| 501 | 503 | ||
| 502 | @Override | 504 | @Override |
| @@ -904,9 +906,6 @@ public class DayOfSchedule { | @@ -904,9 +906,6 @@ public class DayOfSchedule { | ||
| 904 | else | 906 | else |
| 905 | carExecutePlanMap.remove(sch.getClZbh()); | 907 | carExecutePlanMap.remove(sch.getClZbh()); |
| 906 | 908 | ||
| 907 | - // rfid需要在新的执行班次前复位 | ||
| 908 | - RfidDataHandler.resetRfid(sch.getClZbh()); | ||
| 909 | - | ||
| 910 | return executeCurr(sch.getClZbh()) != oldExec; | 909 | return executeCurr(sch.getClZbh()) != oldExec; |
| 911 | } | 910 | } |
| 912 | 911 |
src/main/java/com/bsth/data/schedule/thread/SchedulePstThread.java
| 1 | -package com.bsth.data.schedule.thread; | ||
| 2 | - | ||
| 3 | -import com.bsth.data.schedule.DayOfSchedule; | ||
| 4 | -import com.bsth.entity.realcontrol.ScheduleRealInfo; | ||
| 5 | -import com.bsth.repository.realcontrol.ScheduleRealInfoRepository; | ||
| 6 | -import org.slf4j.Logger; | ||
| 7 | -import org.slf4j.LoggerFactory; | ||
| 8 | -import org.springframework.beans.factory.annotation.Autowired; | ||
| 9 | -import org.springframework.jdbc.core.BatchPreparedStatementSetter; | ||
| 10 | -import org.springframework.jdbc.core.JdbcTemplate; | ||
| 11 | -import org.springframework.jdbc.datasource.DataSourceTransactionManager; | ||
| 12 | -import org.springframework.stereotype.Component; | ||
| 13 | -import org.springframework.transaction.TransactionDefinition; | ||
| 14 | -import org.springframework.transaction.TransactionStatus; | ||
| 15 | -import org.springframework.transaction.support.DefaultTransactionDefinition; | ||
| 16 | - | ||
| 17 | -import java.sql.PreparedStatement; | ||
| 18 | -import java.sql.SQLException; | ||
| 19 | -import java.util.ArrayList; | ||
| 20 | -import java.util.List; | ||
| 21 | - | ||
| 22 | -/** | ||
| 23 | - * @author PanZhao | ||
| 24 | - * @ClassName: SchedulePstThread | ||
| 25 | - * @Description: TODO(班次异步持久化) | ||
| 26 | - * @date 2016年8月24日 上午1:47:05 | ||
| 27 | - */ | ||
| 28 | -@Component | ||
| 29 | -public class SchedulePstThread extends Thread { | ||
| 30 | - | ||
| 31 | - @Autowired | ||
| 32 | - ScheduleRealInfoRepository scheduleRepository; | ||
| 33 | - | ||
| 34 | - @Autowired | ||
| 35 | - JdbcTemplate jdbcTemplate; | ||
| 36 | - | ||
| 37 | - @Autowired | ||
| 38 | - DayOfSchedule dayOfSchedule; | ||
| 39 | - | ||
| 40 | - Logger logger = LoggerFactory.getLogger(this.getClass()); | ||
| 41 | - | ||
| 42 | - static List<ScheduleRealInfo> saveList = new ArrayList<>(); | ||
| 43 | - | ||
| 44 | - @Override | ||
| 45 | - public void run() { | ||
| 46 | - | ||
| 47 | - try{ | ||
| 48 | - ScheduleRealInfo schedule; | ||
| 49 | - for (int i = 0; i < 500; i++) { | ||
| 50 | - schedule = DayOfSchedule.pstBuffer.poll(); | ||
| 51 | - if (null == schedule) | ||
| 52 | - break; | ||
| 53 | - | ||
| 54 | - if (schedule.isDeleted()) { | ||
| 55 | - logger.error("save 发现 deleted=true 的班次,id: " + schedule.getId()); | ||
| 56 | - continue; | ||
| 57 | - } | ||
| 58 | - | ||
| 59 | - saveList.add(schedule); | ||
| 60 | - } | ||
| 61 | - | ||
| 62 | - //写入数据库 | ||
| 63 | - save(); | ||
| 64 | - }catch (Exception e){ | ||
| 65 | - logger.error("", e); | ||
| 66 | - } | ||
| 67 | - } | ||
| 68 | - | ||
| 69 | - private void save(){ | ||
| 70 | - if(saveList.size() == 0) | ||
| 71 | - return; | ||
| 72 | - //记录同步数据 | ||
| 73 | - logger.info("real schedule update size: " + saveList.size()); | ||
| 74 | - | ||
| 75 | - //批量入库 | ||
| 76 | - update2Db(); | ||
| 77 | - | ||
| 78 | - //清空容器 | ||
| 79 | - saveList.clear(); | ||
| 80 | - logger.info("update end! "); | ||
| 81 | - } | ||
| 82 | - | ||
| 83 | - private void update2Db(){ | ||
| 84 | - final List<ScheduleRealInfo> pstList = saveList; | ||
| 85 | - //编程式事务 | ||
| 86 | - DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource()); | ||
| 87 | - DefaultTransactionDefinition def = new DefaultTransactionDefinition(); | ||
| 88 | - def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); | ||
| 89 | - TransactionStatus status = tran.getTransaction(def); | ||
| 90 | - | ||
| 91 | - try{ | ||
| 92 | - //更新 | ||
| 93 | - jdbcTemplate.batchUpdate("update bsth_c_s_sp_info_real set bc_type=?,bcs=?,bcsj=?,cl_zbh=?,create_date=?" + | ||
| 94 | - ",dfsj=?,directive_state=?,fcno=?,fcsj=?,fcsj_actual=?,j_gh=?,j_name=?,jhlc=?,lp_name=?,qdz_code=?" + | ||
| 95 | - ",qdz_name=?,real_exec_date=?,remarks=?,s_gh=?,s_name=?,schedule_date=?,schedule_date_str=?,sflj=?" + | ||
| 96 | - ",sp_id=?,status=?,update_date=?,xl_bm=?,xl_dir=?,xl_name=?,zdsj=?,zdsj_actual=?,zdz_code=?,zdz_name=?" + | ||
| 97 | - ",ccno=?,df_auto=?,fgs_bm=?,fgs_name=?,gs_bm=?,gs_name=?,online=?,adjust_exps=?,reissue=?,jhlc_orig=?" + | ||
| 98 | - ",sigin_compate=?,drift_status=?,cc_service=?,major_station_name=? where id=?", new BatchPreparedStatementSetter() { | ||
| 99 | - @Override | ||
| 100 | - public void setValues(PreparedStatement ps, int i) throws SQLException { | ||
| 101 | - ScheduleRealInfo sch = pstList.get(i); | ||
| 102 | - ps.setString(1, sch.getBcType()); | ||
| 103 | - ps.setInt(2, sch.getBcs()==null?0:sch.getBcs()); | ||
| 104 | - ps.setInt(3, sch.getBcsj()==null?0:sch.getBcsj()); | ||
| 105 | - ps.setString(4, sch.getClZbh()); | ||
| 106 | - ps.setTimestamp(5, new java.sql.Timestamp(sch.getCreateDate().getTime())); | ||
| 107 | - ps.setString(6, sch.getDfsj()); | ||
| 108 | - ps.setInt(7, sch.getDirectiveState()); | ||
| 109 | - ps.setInt(8, sch.getFcno()==null?0:sch.getFcno()); | ||
| 110 | - ps.setString(9, sch.getFcsj()); | ||
| 111 | - ps.setString(10, sch.getFcsjActual()); | ||
| 112 | - ps.setString(11, sch.getjGh()); | ||
| 113 | - ps.setString(12, sch.getjName()); | ||
| 114 | - ps.setDouble(13, sch.getJhlc()); | ||
| 115 | - ps.setString(14, sch.getLpName()); | ||
| 116 | - ps.setString(15, sch.getQdzCode()); | ||
| 117 | - ps.setString(16, sch.getQdzName()); | ||
| 118 | - ps.setString(17, sch.getRealExecDate()); | ||
| 119 | - ps.setString(18, sch.getRemarks()); | ||
| 120 | - ps.setString(19, sch.getsGh()); | ||
| 121 | - ps.setString(20, sch.getsName()); | ||
| 122 | - ps.setTimestamp(21, new java.sql.Timestamp(sch.getScheduleDate().getTime())); | ||
| 123 | - ps.setString(22, sch.getScheduleDateStr()); | ||
| 124 | - ps.setBoolean(23, sch.isSflj()); | ||
| 125 | - ps.setLong(24, sch.getSpId()); | ||
| 126 | - ps.setInt(25, sch.getStatus()); | ||
| 127 | - ps.setTimestamp(26, new java.sql.Timestamp(sch.getUpdateDate().getTime())); | ||
| 128 | - ps.setString(27, sch.getXlBm()); | ||
| 129 | - ps.setString(28, sch.getXlDir()); | ||
| 130 | - ps.setString(29, sch.getXlName()); | ||
| 131 | - ps.setString(30, sch.getZdsj()); | ||
| 132 | - ps.setString(31, sch.getZdsjActual()); | ||
| 133 | - ps.setString(32, sch.getZdzCode()); | ||
| 134 | - ps.setString(33, sch.getZdzName()); | ||
| 135 | - ps.setInt(34, sch.getCcno()==null?0:sch.getCcno()); | ||
| 136 | - ps.setBoolean(35, sch.isDfAuto()); | ||
| 137 | - ps.setString(36, sch.getFgsBm()); | ||
| 138 | - ps.setString(37, sch.getFgsName()); | ||
| 139 | - ps.setString(38, sch.getGsBm()); | ||
| 140 | - ps.setString(39, sch.getGsName()); | ||
| 141 | - ps.setBoolean(40, sch.isOnline()); | ||
| 142 | - ps.setString(41, sch.getAdjustExps()); | ||
| 143 | - ps.setBoolean(42, sch.isReissue()); | ||
| 144 | - ps.setDouble(43, sch.getJhlcOrig()==null?0:sch.getJhlcOrig()); | ||
| 145 | - ps.setInt(44, sch.getSiginCompate()); | ||
| 146 | - ps.setInt(45, sch.getDriftStatus()); | ||
| 147 | - ps.setBoolean(46, sch.isCcService()); | ||
| 148 | - ps.setString(47, sch.getMajorStationName()); | ||
| 149 | - | ||
| 150 | - ps.setLong(48, sch.getId()); | ||
| 151 | - } | ||
| 152 | - | ||
| 153 | - @Override | ||
| 154 | - public int getBatchSize() { | ||
| 155 | - return pstList.size(); | ||
| 156 | - } | ||
| 157 | - }); | ||
| 158 | - | ||
| 159 | - tran.commit(status); | ||
| 160 | - }catch (Exception e){ | ||
| 161 | - tran.rollback(status); | ||
| 162 | - logger.error("同步数据库失败," , e); | ||
| 163 | - } | ||
| 164 | - } | ||
| 165 | -} | 1 | +package com.bsth.data.schedule.thread; |
| 2 | + | ||
| 3 | +import com.bsth.data.schedule.DayOfSchedule; | ||
| 4 | +import com.bsth.entity.realcontrol.ScheduleRealInfo; | ||
| 5 | +import com.bsth.repository.realcontrol.ScheduleRealInfoRepository; | ||
| 6 | +import org.slf4j.Logger; | ||
| 7 | +import org.slf4j.LoggerFactory; | ||
| 8 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 9 | +import org.springframework.jdbc.core.BatchPreparedStatementSetter; | ||
| 10 | +import org.springframework.jdbc.core.JdbcTemplate; | ||
| 11 | +import org.springframework.jdbc.datasource.DataSourceTransactionManager; | ||
| 12 | +import org.springframework.stereotype.Component; | ||
| 13 | +import org.springframework.transaction.TransactionDefinition; | ||
| 14 | +import org.springframework.transaction.TransactionStatus; | ||
| 15 | +import org.springframework.transaction.support.DefaultTransactionDefinition; | ||
| 16 | + | ||
| 17 | +import java.sql.PreparedStatement; | ||
| 18 | +import java.sql.SQLException; | ||
| 19 | +import java.util.ArrayList; | ||
| 20 | +import java.util.List; | ||
| 21 | + | ||
| 22 | +/** | ||
| 23 | + * @author PanZhao | ||
| 24 | + * @ClassName: SchedulePstThread | ||
| 25 | + * @Description: TODO(班次异步持久化) | ||
| 26 | + * @date 2016年8月24日 上午1:47:05 | ||
| 27 | + */ | ||
| 28 | +@Component | ||
| 29 | +public class SchedulePstThread extends Thread { | ||
| 30 | + | ||
| 31 | + @Autowired | ||
| 32 | + ScheduleRealInfoRepository scheduleRepository; | ||
| 33 | + | ||
| 34 | + @Autowired | ||
| 35 | + JdbcTemplate jdbcTemplate; | ||
| 36 | + | ||
| 37 | + @Autowired | ||
| 38 | + DayOfSchedule dayOfSchedule; | ||
| 39 | + | ||
| 40 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | ||
| 41 | + | ||
| 42 | + static List<ScheduleRealInfo> saveList = new ArrayList<>(); | ||
| 43 | + | ||
| 44 | + @Override | ||
| 45 | + public void run() { | ||
| 46 | + | ||
| 47 | + try{ | ||
| 48 | + ScheduleRealInfo schedule; | ||
| 49 | + for (int i = 0; i < 500; i++) { | ||
| 50 | + schedule = DayOfSchedule.pstBuffer.poll(); | ||
| 51 | + if (null == schedule) | ||
| 52 | + break; | ||
| 53 | + | ||
| 54 | + if (schedule.isDeleted()) { | ||
| 55 | + logger.error("save 发现 deleted=true 的班次,id: " + schedule.getId()); | ||
| 56 | + continue; | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + saveList.add(schedule); | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + //写入数据库 | ||
| 63 | + save(); | ||
| 64 | + }catch (Exception e){ | ||
| 65 | + logger.error("", e); | ||
| 66 | + } | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + private void save(){ | ||
| 70 | + if(saveList.size() == 0) | ||
| 71 | + return; | ||
| 72 | + //记录同步数据 | ||
| 73 | + logger.info("real schedule update size: " + saveList.size()); | ||
| 74 | + | ||
| 75 | + //批量入库 | ||
| 76 | + update2Db(); | ||
| 77 | + | ||
| 78 | + //清空容器 | ||
| 79 | + saveList.clear(); | ||
| 80 | + logger.info("update end! "); | ||
| 81 | + } | ||
| 82 | + | ||
| 83 | + private void update2Db(){ | ||
| 84 | + final List<ScheduleRealInfo> pstList = saveList; | ||
| 85 | + //编程式事务 | ||
| 86 | + DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource()); | ||
| 87 | + DefaultTransactionDefinition def = new DefaultTransactionDefinition(); | ||
| 88 | + def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); | ||
| 89 | + TransactionStatus status = tran.getTransaction(def); | ||
| 90 | + | ||
| 91 | + try{ | ||
| 92 | + //更新 | ||
| 93 | + jdbcTemplate.batchUpdate("update bsth_c_s_sp_info_real set bc_type=?,bcs=?,bcsj=?,cl_zbh=?,create_date=?" + | ||
| 94 | + ",dfsj=?,directive_state=?,fcno=?,fcsj=?,fcsj_actual=?,j_gh=?,j_name=?,jhlc=?,lp_name=?,qdz_code=?" + | ||
| 95 | + ",qdz_name=?,real_exec_date=?,remarks=?,s_gh=?,s_name=?,schedule_date=?,schedule_date_str=?,sflj=?" + | ||
| 96 | + ",sp_id=?,status=?,update_date=?,xl_bm=?,xl_dir=?,xl_name=?,zdsj=?,zdsj_actual=?,zdz_code=?,zdz_name=?" + | ||
| 97 | + ",ccno=?,df_auto=?,fgs_bm=?,fgs_name=?,gs_bm=?,gs_name=?,online=?,adjust_exps=?,reissue=?,jhlc_orig=?" + | ||
| 98 | + ",sigin_compate=?,drift_status=?,cc_service=?,major_station_name=?,rfid_state=?,first_rfid_state=? where id=?", new BatchPreparedStatementSetter() { | ||
| 99 | + @Override | ||
| 100 | + public void setValues(PreparedStatement ps, int i) throws SQLException { | ||
| 101 | + ScheduleRealInfo sch = pstList.get(i); | ||
| 102 | + ps.setString(1, sch.getBcType()); | ||
| 103 | + ps.setInt(2, sch.getBcs()==null?0:sch.getBcs()); | ||
| 104 | + ps.setInt(3, sch.getBcsj()==null?0:sch.getBcsj()); | ||
| 105 | + ps.setString(4, sch.getClZbh()); | ||
| 106 | + ps.setTimestamp(5, new java.sql.Timestamp(sch.getCreateDate().getTime())); | ||
| 107 | + ps.setString(6, sch.getDfsj()); | ||
| 108 | + ps.setInt(7, sch.getDirectiveState()); | ||
| 109 | + ps.setInt(8, sch.getFcno()==null?0:sch.getFcno()); | ||
| 110 | + ps.setString(9, sch.getFcsj()); | ||
| 111 | + ps.setString(10, sch.getFcsjActual()); | ||
| 112 | + ps.setString(11, sch.getjGh()); | ||
| 113 | + ps.setString(12, sch.getjName()); | ||
| 114 | + ps.setDouble(13, sch.getJhlc()); | ||
| 115 | + ps.setString(14, sch.getLpName()); | ||
| 116 | + ps.setString(15, sch.getQdzCode()); | ||
| 117 | + ps.setString(16, sch.getQdzName()); | ||
| 118 | + ps.setString(17, sch.getRealExecDate()); | ||
| 119 | + ps.setString(18, sch.getRemarks()); | ||
| 120 | + ps.setString(19, sch.getsGh()); | ||
| 121 | + ps.setString(20, sch.getsName()); | ||
| 122 | + ps.setTimestamp(21, new java.sql.Timestamp(sch.getScheduleDate().getTime())); | ||
| 123 | + ps.setString(22, sch.getScheduleDateStr()); | ||
| 124 | + ps.setBoolean(23, sch.isSflj()); | ||
| 125 | + ps.setLong(24, sch.getSpId()); | ||
| 126 | + ps.setInt(25, sch.getStatus()); | ||
| 127 | + ps.setTimestamp(26, new java.sql.Timestamp(sch.getUpdateDate().getTime())); | ||
| 128 | + ps.setString(27, sch.getXlBm()); | ||
| 129 | + ps.setString(28, sch.getXlDir()); | ||
| 130 | + ps.setString(29, sch.getXlName()); | ||
| 131 | + ps.setString(30, sch.getZdsj()); | ||
| 132 | + ps.setString(31, sch.getZdsjActual()); | ||
| 133 | + ps.setString(32, sch.getZdzCode()); | ||
| 134 | + ps.setString(33, sch.getZdzName()); | ||
| 135 | + ps.setInt(34, sch.getCcno()==null?0:sch.getCcno()); | ||
| 136 | + ps.setBoolean(35, sch.isDfAuto()); | ||
| 137 | + ps.setString(36, sch.getFgsBm()); | ||
| 138 | + ps.setString(37, sch.getFgsName()); | ||
| 139 | + ps.setString(38, sch.getGsBm()); | ||
| 140 | + ps.setString(39, sch.getGsName()); | ||
| 141 | + ps.setBoolean(40, sch.isOnline()); | ||
| 142 | + ps.setString(41, sch.getAdjustExps()); | ||
| 143 | + ps.setBoolean(42, sch.isReissue()); | ||
| 144 | + ps.setDouble(43, sch.getJhlcOrig()==null?0:sch.getJhlcOrig()); | ||
| 145 | + ps.setInt(44, sch.getSiginCompate()); | ||
| 146 | + ps.setInt(45, sch.getDriftStatus()); | ||
| 147 | + ps.setBoolean(46, sch.isCcService()); | ||
| 148 | + ps.setString(47, sch.getMajorStationName()); | ||
| 149 | + ps.setInt(48, sch.getRfidState()); | ||
| 150 | + ps.setInt(49, sch.getFirstRfidState()); | ||
| 151 | + | ||
| 152 | + ps.setLong(50, sch.getId()); | ||
| 153 | + } | ||
| 154 | + | ||
| 155 | + @Override | ||
| 156 | + public int getBatchSize() { | ||
| 157 | + return pstList.size(); | ||
| 158 | + } | ||
| 159 | + }); | ||
| 160 | + | ||
| 161 | + tran.commit(status); | ||
| 162 | + }catch (Exception e){ | ||
| 163 | + tran.rollback(status); | ||
| 164 | + logger.error("同步数据库失败," , e); | ||
| 165 | + } | ||
| 166 | + } | ||
| 167 | +} |
src/main/java/com/bsth/entity/realcontrol/ScheduleRealInfo.java
| @@ -238,6 +238,11 @@ public class ScheduleRealInfo { | @@ -238,6 +238,11 @@ public class ScheduleRealInfo { | ||
| 238 | */ | 238 | */ |
| 239 | private int rfidState; | 239 | private int rfidState; |
| 240 | 240 | ||
| 241 | + /** | ||
| 242 | + * 起点站rfid状态 | ||
| 243 | + */ | ||
| 244 | + private int firstRfidState; | ||
| 245 | + | ||
| 241 | public Integer getLpChange() { | 246 | public Integer getLpChange() { |
| 242 | return lpChange; | 247 | return lpChange; |
| 243 | } | 248 | } |
| @@ -1003,4 +1008,12 @@ public class ScheduleRealInfo { | @@ -1003,4 +1008,12 @@ public class ScheduleRealInfo { | ||
| 1003 | public void setRfidState(int rfidState) { | 1008 | public void setRfidState(int rfidState) { |
| 1004 | this.rfidState = rfidState; | 1009 | this.rfidState = rfidState; |
| 1005 | } | 1010 | } |
| 1011 | + | ||
| 1012 | + public int getFirstRfidState() { | ||
| 1013 | + return firstRfidState; | ||
| 1014 | + } | ||
| 1015 | + | ||
| 1016 | + public void setFirstRfidState(int firstRfidState) { | ||
| 1017 | + this.firstRfidState = firstRfidState; | ||
| 1018 | + } | ||
| 1006 | } | 1019 | } |
src/main/java/com/bsth/websocket/dto/WsScheduleRealInfo.java
| @@ -67,6 +67,7 @@ public class WsScheduleRealInfo { | @@ -67,6 +67,7 @@ public class WsScheduleRealInfo { | ||
| 67 | wss.fgsBm = sch.getFgsBm(); | 67 | wss.fgsBm = sch.getFgsBm(); |
| 68 | wss.ccService = sch.isCcService(); | 68 | wss.ccService = sch.isCcService(); |
| 69 | wss.rfidState = sch.getRfidState(); | 69 | wss.rfidState = sch.getRfidState(); |
| 70 | + wss.firstRfidState = sch.getFirstRfidState(); | ||
| 70 | return wss; | 71 | return wss; |
| 71 | } | 72 | } |
| 72 | 73 | ||
| @@ -221,6 +222,11 @@ public class WsScheduleRealInfo { | @@ -221,6 +222,11 @@ public class WsScheduleRealInfo { | ||
| 221 | */ | 222 | */ |
| 222 | private int rfidState; | 223 | private int rfidState; |
| 223 | 224 | ||
| 225 | + /** | ||
| 226 | + * 起点站rfid状态 | ||
| 227 | + */ | ||
| 228 | + private int firstRfidState; | ||
| 229 | + | ||
| 224 | public Long getId() { | 230 | public Long getId() { |
| 225 | return id; | 231 | return id; |
| 226 | } | 232 | } |
| @@ -604,4 +610,12 @@ public class WsScheduleRealInfo { | @@ -604,4 +610,12 @@ public class WsScheduleRealInfo { | ||
| 604 | public void setRfidState(int rfidState) { | 610 | public void setRfidState(int rfidState) { |
| 605 | this.rfidState = rfidState; | 611 | this.rfidState = rfidState; |
| 606 | } | 612 | } |
| 613 | + | ||
| 614 | + public int getFirstRfidState() { | ||
| 615 | + return firstRfidState; | ||
| 616 | + } | ||
| 617 | + | ||
| 618 | + public void setFirstRfidState(int firstRfidState) { | ||
| 619 | + this.firstRfidState = firstRfidState; | ||
| 620 | + } | ||
| 607 | } | 621 | } |
src/main/resources/static/real_control_v2/css/line_schedule.css
| @@ -313,22 +313,37 @@ span.fcsj-diff { | @@ -313,22 +313,37 @@ span.fcsj-diff { | ||
| 313 | border-top: 1px solid #d9d9d9 !important; | 313 | border-top: 1px solid #d9d9d9 !important; |
| 314 | } | 314 | } |
| 315 | 315 | ||
| 316 | -.tl-green { | ||
| 317 | - background: green; | 316 | +.tl-green-green { |
| 317 | + background: linear-gradient(to right, green 0%,green 50%,green 51%,green 100%); | ||
| 318 | color: green; | 318 | color: green; |
| 319 | } | 319 | } |
| 320 | 320 | ||
| 321 | -.tl-yellow { | ||
| 322 | - background: yellow; | 321 | +.tl-yellow-yellow { |
| 322 | + background: linear-gradient(to right, yellow 0%,yellow 50%,yellow 51%,yellow 100%); | ||
| 323 | color: yellow; | 323 | color: yellow; |
| 324 | } | 324 | } |
| 325 | 325 | ||
| 326 | -.tl-grey { | ||
| 327 | - background: grey; | 326 | +.tl-yellow-green { |
| 327 | + background: linear-gradient(to right, yellow 0%,yellow 50%,green 51%,green 100%); | ||
| 328 | + color: yellow; | ||
| 329 | +} | ||
| 330 | + | ||
| 331 | +.tl-grey-grey { | ||
| 332 | + background: linear-gradient(to right, grey 0%,grey 50%,grey 51%,grey 100%); | ||
| 328 | color: grey; | 333 | color: grey; |
| 329 | } | 334 | } |
| 330 | 335 | ||
| 331 | -.tl-white { | 336 | +.tl-grey-yellow { |
| 337 | + background: linear-gradient(to right, grey 0%,grey 50%,yellow 51%,yellow 100%); | ||
| 338 | + color: grey; | ||
| 339 | +} | ||
| 340 | + | ||
| 341 | +.tl-grey-green { | ||
| 342 | + background: linear-gradient(to right, grey 0%,grey 50%,green 51%,green 100%); | ||
| 343 | + color: grey; | ||
| 344 | +} | ||
| 345 | + | ||
| 346 | +.tl-white-white { | ||
| 332 | background: white; | 347 | background: white; |
| 333 | color: white; | 348 | color: white; |
| 334 | } | 349 | } |
| @@ -589,16 +604,29 @@ div.drop-rail[data-type="car"]:before { | @@ -589,16 +604,29 @@ div.drop-rail[data-type="car"]:before { | ||
| 589 | border: 1px dashed #b3b2b2; | 604 | border: 1px dashed #b3b2b2; |
| 590 | } | 605 | } |
| 591 | 606 | ||
| 592 | -dl.relevance-active dd:nth-child(n+2) { | 607 | +dl.relevance-active dd:nth-child(2) { |
| 608 | + background: #d2d2d2 !important; | ||
| 609 | +} | ||
| 610 | + | ||
| 611 | +dl.relevance-active dd:nth-child(n+4) { | ||
| 593 | background: #d2d2d2 !important; | 612 | background: #d2d2d2 !important; |
| 594 | } | 613 | } |
| 595 | 614 | ||
| 596 | -dl.relevance-active.intimity dd:nth-child(n+2) { | 615 | +dl.relevance-active.intimity dd:nth-child(2) { |
| 597 | background: #8baabf !important; | 616 | background: #8baabf !important; |
| 598 | color: white; | 617 | color: white; |
| 599 | } | 618 | } |
| 600 | 619 | ||
| 601 | -dl.relevance-active.intimity dd:nth-child(n+2) a { | 620 | +dl.relevance-active.intimity dd:nth-child(n+4) { |
| 621 | + background: #8baabf !important; | ||
| 622 | + color: white; | ||
| 623 | +} | ||
| 624 | + | ||
| 625 | +dl.relevance-active.intimity dd:nth-child(2) a { | ||
| 626 | + color: white !important; | ||
| 627 | +} | ||
| 628 | + | ||
| 629 | +dl.relevance-active.intimity dd:nth-child(n+4) a { | ||
| 602 | color: white !important; | 630 | color: white !important; |
| 603 | } | 631 | } |
| 604 | 632 | ||
| @@ -651,24 +679,39 @@ dl.relevance-active.intimity dd.tl-xxfc { | @@ -651,24 +679,39 @@ dl.relevance-active.intimity dd.tl-xxfc { | ||
| 651 | background: linear-gradient(to right, #8baabf, rgb(43, 185, 185), rgb(0,255,255)) !important; | 679 | background: linear-gradient(to right, #8baabf, rgb(43, 185, 185), rgb(0,255,255)) !important; |
| 652 | } | 680 | } |
| 653 | 681 | ||
| 654 | -dl.relevance-active dd.tl-green, | ||
| 655 | -dl.relevance-active.intimity dd.tl-green { | ||
| 656 | - background: linear-gradient(to right, green, green, #8baabf) !important; | 682 | +dl.relevance-active dd.tl-green-green, |
| 683 | +dl.relevance-active.intimity dd.tl-green-green { | ||
| 684 | + background: linear-gradient(to right, green 0%,green 50%,green 51%,green 100%); !important; | ||
| 685 | +} | ||
| 686 | + | ||
| 687 | +dl.relevance-active dd.tl-yellow-yellow, | ||
| 688 | +dl.relevance-active.intimity dd.tl-yellow-yellow { | ||
| 689 | + background: linear-gradient(to right, yellow 0%,yellow 50%,yellow 51%,yellow 100%); !important; | ||
| 690 | +} | ||
| 691 | + | ||
| 692 | +dl.relevance-active dd.tl-yellow-green, | ||
| 693 | +dl.relevance-active.intimity dd.tl-yellow-green { | ||
| 694 | + background: linear-gradient(to right, yellow 0%,yellow 50%,green 51%,green 100%); !important; | ||
| 695 | +} | ||
| 696 | + | ||
| 697 | +dl.relevance-active dd.tl-grey-grey, | ||
| 698 | +dl.relevance-active.intimity dd.tl-grey-grey { | ||
| 699 | + background: linear-gradient(to right, grey 0%,grey 50%,grey 51%,grey 100%); !important; | ||
| 657 | } | 700 | } |
| 658 | 701 | ||
| 659 | -dl.relevance-active dd.tl-yellow, | ||
| 660 | -dl.relevance-active.intimity dd.tl-yellow { | ||
| 661 | - background: linear-gradient(to right, yellow, yellow, #8baabf) !important; | 702 | +dl.relevance-active dd.tl-grey-yellow, |
| 703 | +dl.relevance-active.intimity dd.tl-grey-yellow { | ||
| 704 | + background: linear-gradient(to right, grey 0%,grey 50%,yellow 51%,yellow 100%); !important; | ||
| 662 | } | 705 | } |
| 663 | 706 | ||
| 664 | -dl.relevance-active dd.tl-grey, | ||
| 665 | -dl.relevance-active.intimity dd.tl-grey { | ||
| 666 | - background: linear-gradient(to right, grey, grey, #8baabf) !important; | 707 | +dl.relevance-active dd.tl-grey-green, |
| 708 | +dl.relevance-active.intimity dd.tl-grey-green { | ||
| 709 | + background: linear-gradient(to right, grey 0%,grey 50%,green 51%,green 100%); !important; | ||
| 667 | } | 710 | } |
| 668 | 711 | ||
| 669 | -dl.relevance-active dd.tl-white, | ||
| 670 | -dl.relevance-active.intimity dd.tl-white { | ||
| 671 | - background: linear-gradient(to right, #ffffff, #ffffff, #8baabf) !important; | 712 | +dl.relevance-active dd.tl-white-white, |
| 713 | +dl.relevance-active.intimity dd.tl-white-white { | ||
| 714 | + background: linear-gradient(to right, white 0%,white 50%,white 51%,white 100%); !important; | ||
| 672 | } | 715 | } |
| 673 | 716 | ||
| 674 | dl.relevance-active.intimity dd span.fcsj-diff { | 717 | dl.relevance-active.intimity dd span.fcsj-diff { |
src/main/resources/static/real_control_v2/fragments/line_schedule/sch_table.html
| 1 | -<div> | ||
| 2 | - <script id="line-schedule-table-temp" type="text/html"> | ||
| 3 | - <div class="schedule-wrap {{if dir==0}}up{{else}}down{{/if}}"> | ||
| 4 | - <h3 class="header-title"> | ||
| 5 | - {{if dir==0}} | ||
| 6 | - {{line.startStationName}} | ||
| 7 | - {{else}} | ||
| 8 | - {{line.endStationName}} | ||
| 9 | - {{/if}} | ||
| 10 | - <i class="uk-icon-question-circle uk-icon-hover"></i> | ||
| 11 | - <div class="fixed_legend"> | ||
| 12 | - <div> | ||
| 13 | - <span class="tl-xxfc">消息发出</span> | ||
| 14 | - <span class="tl-xxsd">消息收到</span> | ||
| 15 | - <span class="tl-xxrd">消息阅读</span> | ||
| 16 | - | ||
| 17 | - <span class="tl-wd">误点</span> | ||
| 18 | - <span class="tl-zzzx">正在执行</span> | ||
| 19 | - <span class="tl-qrlb"></span> | ||
| 20 | - <span class="tl-yzx">已执行</span> | ||
| 21 | - <a> | ||
| 22 | - <i class="uk-icon-angle-double-up fixed_legend_close"></i> | ||
| 23 | - </a> | ||
| 24 | - </div> | ||
| 25 | - </div> | ||
| 26 | - <i class="uk-icon-eye uk-icon-hover ct_eye_icon"></i> | ||
| 27 | - <i class="uk-icon-qrcode uk-icon-hover ct_calu_icon" data-toggle="tooltip" data-placement="bottom" title="计算应到实到时间对比"></i> | ||
| 28 | - | ||
| 29 | - <!--<i class="uk-icon-share-alt uk-icon-hover tp_info_icon" ></i>--> | ||
| 30 | - | ||
| 31 | - <span class="warn_multi_station" data-updown="{{dir}}" data-code="{{line.lineCode}}"></span> | ||
| 32 | - <div class="search_sch_panel"> | ||
| 33 | - <form class="uk-form" onsubmit="javascript:return false;"> | ||
| 34 | - <div class="uk-autocomplete sch-search-autocom"> | ||
| 35 | - <div class="uk-form-icon"> | ||
| 36 | - <i class="uk-icon-search"></i> | ||
| 37 | - <input type="text" placeholder="搜索"> | ||
| 38 | - <i class="cancel uk-icon-times-circle" data-uk-tooltip="{pos:'right'}" title="取消过滤"></i> | ||
| 39 | - </div> | ||
| 40 | - </div> | ||
| 41 | - </form> | ||
| 42 | - </div> | ||
| 43 | - </h3> | ||
| 44 | - <div class="schedule-body"> | ||
| 45 | - <div class="ct_table_wrap"> | ||
| 46 | - <div class="ct_table line-schedule-table"> | ||
| 47 | - <div class="ct_table_head"> | ||
| 48 | - <dl> | ||
| 49 | - <dt>序号</dt> | ||
| 50 | - <dt>路牌</dt> | ||
| 51 | - <dt>RFID</dt> | ||
| 52 | - <dt>车辆</dt> | ||
| 53 | - <dt>应到</dt> | ||
| 54 | - <dt>实到</dt> | ||
| 55 | - <dt sort-field>计发</dt> | ||
| 56 | - <dt sort-field>待发</dt> | ||
| 57 | - <dt>实发</dt> | ||
| 58 | - <dt>原因</dt> | ||
| 59 | - </dl> | ||
| 60 | - </div> | ||
| 61 | - <div class="ct_table_body"> | ||
| 62 | - {{each list as sch i}} | ||
| 63 | - <dl data-id="{{sch.id}}"> | ||
| 64 | - <dd class="seq_no">{{i + 1}}</dd> | ||
| 65 | - <dd class="lpName"><a>{{sch.lpName}}</a></dd> | ||
| 66 | - <dd class="{{if !sch.qdzArrDatesj}}tl-white{{else if (sch.rfidState & 1) == 1 && (sch.rfidState & 2) == 2}}tl-green{{else if (sch.rfidState & 1) == 1}}tl-yellow{{else}}tl-grey{{/if}}"></dd> | ||
| 67 | - <dd data-nbbm="{{sch.clZbh}}" | ||
| 68 | - class="{{if sch.directiveState == 60}}tl-xxfc{{else if sch.directiveState == 100}}tl-xxsd{{else if sch.directiveState == 200}}tl-xxrd{{/if}}"> | ||
| 69 | - {{sch.clZbh}} | ||
| 70 | - </dd> | ||
| 71 | - <dd>{{sch.qdzArrDatejh}}</dd> | ||
| 72 | - <dd class="qdzArrDatesjDD"><span class="qdzArrDatesjSPAN">{{sch.qdzArrDatesj}}</span><span class="arrsj-diff">{{sch.arrsj_diff}}</span></dd> | ||
| 73 | - <dd data-sort-val={{sch.fcsjT}}> | ||
| 74 | - {{sch.fcsj}} | ||
| 75 | - {{if sch.bcType == "out"}} | ||
| 76 | - <span class="uk-badge uk-badge-success out">出场</span> | ||
| 77 | - {{else if sch.bcType == "in"}} | ||
| 78 | - <span class="uk-badge uk-badge-warning in">进场</span> | ||
| 79 | - {{else if sch.bcType == "venting"}} | ||
| 80 | - <span class="uk-badge uk-badge-danger">直放</span> | ||
| 81 | - {{else if sch.bcType == "major"}} | ||
| 82 | - <span class="uk-badge uk-badge-danger">放站</span> | ||
| 83 | - {{else if sch.bcType == "region"}} | ||
| 84 | - <span class="uk-badge sch_region">区间</span> | ||
| 85 | - {{else if sch.bcType == "ldks"}} | ||
| 86 | - <span class="uk-badge sch_ldks">空驶</span> | ||
| 87 | - {{/if}} | ||
| 88 | - {{if sch.sflj}} | ||
| 89 | - <span class="uk-badge uk-badge-danger">临加</span> | ||
| 90 | - {{/if}} | ||
| 91 | - {{if sch.cTasks.length > 0}} | ||
| 92 | - <span class="uk-badge uk-badge-notification c_task {{if sch.c_t_mileage_status==-1}}c_task_mileage_error{{/if}}">{{sch.cTasks.length}}</span> | ||
| 93 | - {{/if}} | ||
| 94 | - {{if sch.lpChange==1}} | ||
| 95 | - <span class="uk-badge uk-badge-success out">换</span> | ||
| 96 | - {{/if}} | ||
| 97 | - </dd> | ||
| 98 | - <dd data-sort-val={{sch.dfsjT}} dbclick dbclick-type="dfsj" dbclick-val="{{sch.dfsj}}"> | ||
| 99 | - {{sch.dfsj}} | ||
| 100 | - {{if sch.late2}} | ||
| 101 | - <span class="late-badge">?+{{sch.lateMinute}}</span> | ||
| 102 | - {{/if}} | ||
| 103 | - </dd> | ||
| 104 | - <dd data-uk-observe class=" | ||
| 105 | - {{if sch.status==-1}} | ||
| 106 | - tl-qrlb | ||
| 107 | - {{else if sch.status==2}} | ||
| 108 | - tl-yzx | ||
| 109 | - {{else if sch.status==1}} | ||
| 110 | - tl-zzzx | ||
| 111 | - {{else if sch.status ==4}} | ||
| 112 | - tl-wfyd | ||
| 113 | - {{else if sch.status == 0 && sch.late}} | ||
| 114 | - tl-wd | ||
| 115 | - {{/if}} fcsjActualCell"> | ||
| 116 | - {{sch.fcsjActual}}<span class="fcsj-diff">{{sch.fcsj_diff}}</span> | ||
| 117 | - </dd> | ||
| 118 | - <dd data-uk-observe> | ||
| 119 | - | ||
| 120 | - <span title="{{sch.remarks}}" | ||
| 121 | - data-uk-tooltip="{pos:'top-left'}">{{sch.remarks}}</span> | ||
| 122 | - </dd> | ||
| 123 | - </dl> | ||
| 124 | - {{/each}} | ||
| 125 | - </div> | ||
| 126 | - </div> | ||
| 127 | - </div> | ||
| 128 | - </div> | ||
| 129 | - </div> | ||
| 130 | - </script> | ||
| 131 | - | ||
| 132 | - <script id="line-schedule-fcsj-temp" type="text/html"> | ||
| 133 | - <dd data-sort-val={{fcsjT}}> | ||
| 134 | - {{fcsj}} | ||
| 135 | - {{if bcType == "out"}} | ||
| 136 | - <span class="uk-badge uk-badge-success out">出场</span> | ||
| 137 | - {{else if bcType == "in"}} | ||
| 138 | - <span class="uk-badge uk-badge-warning in">进场</span> | ||
| 139 | - {{else if bcType == "venting"}} | ||
| 140 | - <span class="uk-badge uk-badge-danger">直放</span> | ||
| 141 | - {{else if bcType == "major"}} | ||
| 142 | - <span class="uk-badge uk-badge-danger">放站</span> | ||
| 143 | - {{else if bcType == "region"}} | ||
| 144 | - <span class="uk-badge sch_region">区间</span> | ||
| 145 | - {{else if bcType == "ldks"}} | ||
| 146 | - <span class="uk-badge sch_ldks">空驶</span> | ||
| 147 | - {{/if}} | ||
| 148 | - {{if sflj}} | ||
| 149 | - <span class="uk-badge uk-badge-danger">临加</span> | ||
| 150 | - {{/if}} | ||
| 151 | - {{if cTasks.length > 0}} | ||
| 152 | - <span class="uk-badge uk-badge-notification c_task {{if c_t_mileage_status==-1}}c_task_mileage_error{{/if}}">{{cTasks.length}}</span> | ||
| 153 | - {{/if}} | ||
| 154 | - </dd> | ||
| 155 | - </script> | ||
| 156 | - | ||
| 157 | - <script id="line-schedule-sfsj-temp" type="text/html"> | ||
| 158 | - <dd data-uk-observe class=" | ||
| 159 | - {{if status==-1}} | ||
| 160 | - tl-qrlb | ||
| 161 | - {{else if status==2}} | ||
| 162 | - tl-yzx | ||
| 163 | - {{else if status==1}} | ||
| 164 | - tl-zzzx | ||
| 165 | - {{else if status == 0 && late}} | ||
| 166 | - tl-wd | ||
| 167 | - {{/if}} fcsjActualCell"> | ||
| 168 | - {{fcsjActual}}<span class="fcsj-diff">{{fcsj_diff}}</span> | ||
| 169 | - </dd> | ||
| 170 | - </script> | ||
| 171 | - | ||
| 172 | - <script id="line-schedule-nbbm-temp" type="text/html"> | ||
| 173 | - <dd data-nbbm="{{clZbh}}" | ||
| 174 | - class="{{if directiveState == 60}}tl-xxfc{{else if directiveState == 100}}tl-xxsd{{else if directiveState == 200}}tl-xxrd{{/if}}"> | ||
| 175 | - {{clZbh}} | ||
| 176 | - </dd> | ||
| 177 | - </script> | ||
| 178 | - | ||
| 179 | - <script id="sfsj_sch-detail-temp" type="text/html"> | ||
| 180 | - <ul class="sfsj-sch-detail"> | ||
| 181 | - <li><span>路牌:</span>{{lpName}}</li> | ||
| 182 | - <li><span>车辆:</span>{{clZbh}}</li> | ||
| 183 | - <li><span>计发:</span>{{fcsj}}</li> | ||
| 184 | - <li><span>实发:</span>{{fcsjActual}}</li> | ||
| 185 | - <li><span>计达:</span>{{zdsj}}</li> | ||
| 186 | - <li><span>实达:</span>{{zdsjActual}}</li> | ||
| 187 | - <li><span>驾驶员:</span>{{jGh}}/{{jName}}</li> | ||
| 188 | - <li><span>售票员:</span>{{sGh}}/{{sName}}</li> | ||
| 189 | - <li><span>终点站:</span>{{zdzName}}</li> | ||
| 190 | - </ul> | ||
| 191 | - </script> | ||
| 192 | - | ||
| 193 | - <script id="last-sch-sunken-temp" type="text/html"> | ||
| 194 | - <div class="last-sch-sunken"> | ||
| 195 | - <span class="_badge">{{zdsj}}/{{zdsjActual}}</span> | ||
| 196 | - </div> | ||
| 197 | - </script> | ||
| 198 | - | ||
| 199 | - <script id="sch-lp-mileage-tip-temp" type="text/html"> | ||
| 200 | - {{each data as obj i}} | ||
| 201 | - {{if i > 0}}<hr>{{/if}} | ||
| 202 | - | ||
| 203 | - <h5 class="_title"> <span class="lp_name">{{lpName}}</span> <a>{{obj.key}}</a></h5> | ||
| 204 | - <div class="LD_item"> | ||
| 205 | - <span>营运:<a>{{obj.serviceMileage}}</a></span> | ||
| 206 | - <span>烂班:<a>{{obj.destroyMileage}}</a></span> | ||
| 207 | - <span>空驶:<a>{{obj.emptyMileage}}</a></span> | ||
| 208 | - </div> | ||
| 209 | - {{/each}} | ||
| 210 | - </script> | ||
| 211 | -</div> | 1 | +<div> |
| 2 | + <script id="line-schedule-table-temp" type="text/html"> | ||
| 3 | + <div class="schedule-wrap {{if dir==0}}up{{else}}down{{/if}}"> | ||
| 4 | + <h3 class="header-title"> | ||
| 5 | + {{if dir==0}} | ||
| 6 | + {{line.startStationName}} | ||
| 7 | + {{else}} | ||
| 8 | + {{line.endStationName}} | ||
| 9 | + {{/if}} | ||
| 10 | + <i class="uk-icon-question-circle uk-icon-hover"></i> | ||
| 11 | + <div class="fixed_legend"> | ||
| 12 | + <div> | ||
| 13 | + <span class="tl-xxfc">消息发出</span> | ||
| 14 | + <span class="tl-xxsd">消息收到</span> | ||
| 15 | + <span class="tl-xxrd">消息阅读</span> | ||
| 16 | + | ||
| 17 | + <span class="tl-wd">误点</span> | ||
| 18 | + <span class="tl-zzzx">正在执行</span> | ||
| 19 | + <span class="tl-qrlb"></span> | ||
| 20 | + <span class="tl-yzx">已执行</span> | ||
| 21 | + <a> | ||
| 22 | + <i class="uk-icon-angle-double-up fixed_legend_close"></i> | ||
| 23 | + </a> | ||
| 24 | + </div> | ||
| 25 | + </div> | ||
| 26 | + <i class="uk-icon-eye uk-icon-hover ct_eye_icon"></i> | ||
| 27 | + <i class="uk-icon-qrcode uk-icon-hover ct_calu_icon" data-toggle="tooltip" data-placement="bottom" title="计算应到实到时间对比"></i> | ||
| 28 | + | ||
| 29 | + <!--<i class="uk-icon-share-alt uk-icon-hover tp_info_icon" ></i>--> | ||
| 30 | + | ||
| 31 | + <span class="warn_multi_station" data-updown="{{dir}}" data-code="{{line.lineCode}}"></span> | ||
| 32 | + <div class="search_sch_panel"> | ||
| 33 | + <form class="uk-form" onsubmit="javascript:return false;"> | ||
| 34 | + <div class="uk-autocomplete sch-search-autocom"> | ||
| 35 | + <div class="uk-form-icon"> | ||
| 36 | + <i class="uk-icon-search"></i> | ||
| 37 | + <input type="text" placeholder="搜索"> | ||
| 38 | + <i class="cancel uk-icon-times-circle" data-uk-tooltip="{pos:'right'}" title="取消过滤"></i> | ||
| 39 | + </div> | ||
| 40 | + </div> | ||
| 41 | + </form> | ||
| 42 | + </div> | ||
| 43 | + </h3> | ||
| 44 | + <div class="schedule-body"> | ||
| 45 | + <div class="ct_table_wrap"> | ||
| 46 | + <div class="ct_table line-schedule-table"> | ||
| 47 | + <div class="ct_table_head"> | ||
| 48 | + <dl> | ||
| 49 | + <dt>序号</dt> | ||
| 50 | + <dt>路牌</dt> | ||
| 51 | + <dt>RFID</dt> | ||
| 52 | + <dt>车辆</dt> | ||
| 53 | + <dt>应到</dt> | ||
| 54 | + <dt>实到</dt> | ||
| 55 | + <dt sort-field>计发</dt> | ||
| 56 | + <dt sort-field>待发</dt> | ||
| 57 | + <dt>实发</dt> | ||
| 58 | + <dt>原因</dt> | ||
| 59 | + </dl> | ||
| 60 | + </div> | ||
| 61 | + <div class="ct_table_body"> | ||
| 62 | + {{each list as sch i}} | ||
| 63 | + <dl data-id="{{sch.id}}"> | ||
| 64 | + <dd class="seq_no">{{i + 1}}</dd> | ||
| 65 | + <dd class="lpName"><a>{{sch.lpName}}</a></dd> | ||
| 66 | + <dd class="{{if !sch.qdzArrDatesj}}tl-white{{else if (sch.firstRfidState & 2) == 2 && (sch.firstRfidState & 4) == 4}}tl-green{{else if (sch.firstRfidState & 2) == 2}}tl-yellow{{else}}tl-grey{{/if}}{{if !sch.qdzArrDatesj}}-white{{else if (sch.rfidState & 2) == 2 && (sch.rfidState & 4) == 4}}-green{{else if (sch.rfidState & 2) == 2}}-yellow{{else}}-grey{{/if}}"></dd> | ||
| 67 | + <dd data-nbbm="{{sch.clZbh}}" | ||
| 68 | + class="{{if sch.directiveState == 60}}tl-xxfc{{else if sch.directiveState == 100}}tl-xxsd{{else if sch.directiveState == 200}}tl-xxrd{{/if}}"> | ||
| 69 | + {{sch.clZbh}} | ||
| 70 | + </dd> | ||
| 71 | + <dd>{{sch.qdzArrDatejh}}</dd> | ||
| 72 | + <dd class="qdzArrDatesjDD"><span class="qdzArrDatesjSPAN">{{sch.qdzArrDatesj}}</span><span class="arrsj-diff">{{sch.arrsj_diff}}</span></dd> | ||
| 73 | + <dd data-sort-val={{sch.fcsjT}}> | ||
| 74 | + {{sch.fcsj}} | ||
| 75 | + {{if sch.bcType == "out"}} | ||
| 76 | + <span class="uk-badge uk-badge-success out">出场</span> | ||
| 77 | + {{else if sch.bcType == "in"}} | ||
| 78 | + <span class="uk-badge uk-badge-warning in">进场</span> | ||
| 79 | + {{else if sch.bcType == "venting"}} | ||
| 80 | + <span class="uk-badge uk-badge-danger">直放</span> | ||
| 81 | + {{else if sch.bcType == "major"}} | ||
| 82 | + <span class="uk-badge uk-badge-danger">放站</span> | ||
| 83 | + {{else if sch.bcType == "region"}} | ||
| 84 | + <span class="uk-badge sch_region">区间</span> | ||
| 85 | + {{else if sch.bcType == "ldks"}} | ||
| 86 | + <span class="uk-badge sch_ldks">空驶</span> | ||
| 87 | + {{/if}} | ||
| 88 | + {{if sch.sflj}} | ||
| 89 | + <span class="uk-badge uk-badge-danger">临加</span> | ||
| 90 | + {{/if}} | ||
| 91 | + {{if sch.cTasks.length > 0}} | ||
| 92 | + <span class="uk-badge uk-badge-notification c_task {{if sch.c_t_mileage_status==-1}}c_task_mileage_error{{/if}}">{{sch.cTasks.length}}</span> | ||
| 93 | + {{/if}} | ||
| 94 | + {{if sch.lpChange==1}} | ||
| 95 | + <span class="uk-badge uk-badge-success out">换</span> | ||
| 96 | + {{/if}} | ||
| 97 | + </dd> | ||
| 98 | + <dd data-sort-val={{sch.dfsjT}} dbclick dbclick-type="dfsj" dbclick-val="{{sch.dfsj}}"> | ||
| 99 | + {{sch.dfsj}} | ||
| 100 | + {{if sch.late2}} | ||
| 101 | + <span class="late-badge">?+{{sch.lateMinute}}</span> | ||
| 102 | + {{/if}} | ||
| 103 | + </dd> | ||
| 104 | + <dd data-uk-observe class=" | ||
| 105 | + {{if sch.status==-1}} | ||
| 106 | + tl-qrlb | ||
| 107 | + {{else if sch.status==2}} | ||
| 108 | + tl-yzx | ||
| 109 | + {{else if sch.status==1}} | ||
| 110 | + tl-zzzx | ||
| 111 | + {{else if sch.status ==4}} | ||
| 112 | + tl-wfyd | ||
| 113 | + {{else if sch.status == 0 && sch.late}} | ||
| 114 | + tl-wd | ||
| 115 | + {{/if}} fcsjActualCell"> | ||
| 116 | + {{sch.fcsjActual}}<span class="fcsj-diff">{{sch.fcsj_diff}}</span> | ||
| 117 | + </dd> | ||
| 118 | + <dd data-uk-observe> | ||
| 119 | + | ||
| 120 | + <span title="{{sch.remarks}}" | ||
| 121 | + data-uk-tooltip="{pos:'top-left'}">{{sch.remarks}}</span> | ||
| 122 | + </dd> | ||
| 123 | + </dl> | ||
| 124 | + {{/each}} | ||
| 125 | + </div> | ||
| 126 | + </div> | ||
| 127 | + </div> | ||
| 128 | + </div> | ||
| 129 | + </div> | ||
| 130 | + </script> | ||
| 131 | + | ||
| 132 | + <script id="line-schedule-fcsj-temp" type="text/html"> | ||
| 133 | + <dd data-sort-val={{fcsjT}}> | ||
| 134 | + {{fcsj}} | ||
| 135 | + {{if bcType == "out"}} | ||
| 136 | + <span class="uk-badge uk-badge-success out">出场</span> | ||
| 137 | + {{else if bcType == "in"}} | ||
| 138 | + <span class="uk-badge uk-badge-warning in">进场</span> | ||
| 139 | + {{else if bcType == "venting"}} | ||
| 140 | + <span class="uk-badge uk-badge-danger">直放</span> | ||
| 141 | + {{else if bcType == "major"}} | ||
| 142 | + <span class="uk-badge uk-badge-danger">放站</span> | ||
| 143 | + {{else if bcType == "region"}} | ||
| 144 | + <span class="uk-badge sch_region">区间</span> | ||
| 145 | + {{else if bcType == "ldks"}} | ||
| 146 | + <span class="uk-badge sch_ldks">空驶</span> | ||
| 147 | + {{/if}} | ||
| 148 | + {{if sflj}} | ||
| 149 | + <span class="uk-badge uk-badge-danger">临加</span> | ||
| 150 | + {{/if}} | ||
| 151 | + {{if cTasks.length > 0}} | ||
| 152 | + <span class="uk-badge uk-badge-notification c_task {{if c_t_mileage_status==-1}}c_task_mileage_error{{/if}}">{{cTasks.length}}</span> | ||
| 153 | + {{/if}} | ||
| 154 | + </dd> | ||
| 155 | + </script> | ||
| 156 | + | ||
| 157 | + <script id="line-schedule-sfsj-temp" type="text/html"> | ||
| 158 | + <dd data-uk-observe class=" | ||
| 159 | + {{if status==-1}} | ||
| 160 | + tl-qrlb | ||
| 161 | + {{else if status==2}} | ||
| 162 | + tl-yzx | ||
| 163 | + {{else if status==1}} | ||
| 164 | + tl-zzzx | ||
| 165 | + {{else if status == 0 && late}} | ||
| 166 | + tl-wd | ||
| 167 | + {{/if}} fcsjActualCell"> | ||
| 168 | + {{fcsjActual}}<span class="fcsj-diff">{{fcsj_diff}}</span> | ||
| 169 | + </dd> | ||
| 170 | + </script> | ||
| 171 | + | ||
| 172 | + <script id="line-schedule-nbbm-temp" type="text/html"> | ||
| 173 | + <dd data-nbbm="{{clZbh}}" | ||
| 174 | + class="{{if directiveState == 60}}tl-xxfc{{else if directiveState == 100}}tl-xxsd{{else if directiveState == 200}}tl-xxrd{{/if}}"> | ||
| 175 | + {{clZbh}} | ||
| 176 | + </dd> | ||
| 177 | + </script> | ||
| 178 | + | ||
| 179 | + <script id="sfsj_sch-detail-temp" type="text/html"> | ||
| 180 | + <ul class="sfsj-sch-detail"> | ||
| 181 | + <li><span>路牌:</span>{{lpName}}</li> | ||
| 182 | + <li><span>车辆:</span>{{clZbh}}</li> | ||
| 183 | + <li><span>计发:</span>{{fcsj}}</li> | ||
| 184 | + <li><span>实发:</span>{{fcsjActual}}</li> | ||
| 185 | + <li><span>计达:</span>{{zdsj}}</li> | ||
| 186 | + <li><span>实达:</span>{{zdsjActual}}</li> | ||
| 187 | + <li><span>驾驶员:</span>{{jGh}}/{{jName}}</li> | ||
| 188 | + <li><span>售票员:</span>{{sGh}}/{{sName}}</li> | ||
| 189 | + <li><span>终点站:</span>{{zdzName}}</li> | ||
| 190 | + </ul> | ||
| 191 | + </script> | ||
| 192 | + | ||
| 193 | + <script id="last-sch-sunken-temp" type="text/html"> | ||
| 194 | + <div class="last-sch-sunken"> | ||
| 195 | + <span class="_badge">{{zdsj}}/{{zdsjActual}}</span> | ||
| 196 | + </div> | ||
| 197 | + </script> | ||
| 198 | + | ||
| 199 | + <script id="sch-lp-mileage-tip-temp" type="text/html"> | ||
| 200 | + {{each data as obj i}} | ||
| 201 | + {{if i > 0}}<hr>{{/if}} | ||
| 202 | + | ||
| 203 | + <h5 class="_title"> <span class="lp_name">{{lpName}}</span> <a>{{obj.key}}</a></h5> | ||
| 204 | + <div class="LD_item"> | ||
| 205 | + <span>营运:<a>{{obj.serviceMileage}}</a></span> | ||
| 206 | + <span>烂班:<a>{{obj.destroyMileage}}</a></span> | ||
| 207 | + <span>空驶:<a>{{obj.emptyMileage}}</a></span> | ||
| 208 | + </div> | ||
| 209 | + {{/each}} | ||
| 210 | + </script> | ||
| 211 | +</div> |
src/main/resources/static/real_control_v2/js/line_schedule/sch_table.js
| 1 | -/** schedule table */ | ||
| 2 | - | ||
| 3 | -var gb_schedule_table = (function () { | ||
| 4 | - | ||
| 5 | - var temps; | ||
| 6 | - //线路分组的班次数据 | ||
| 7 | - var line2Schedule = {}; | ||
| 8 | - //车辆应发未发车辆数 | ||
| 9 | - var car_yfwf_map = {}; | ||
| 10 | - //班次站点编码和实际不符数据 | ||
| 11 | - var errorCodeData = {}; | ||
| 12 | - | ||
| 13 | - var bcTypeOrderMap = { | ||
| 14 | - 'out':0, | ||
| 15 | - 'normal':1, | ||
| 16 | - 'region':2, | ||
| 17 | - 'major':3, | ||
| 18 | - 'venting':4, | ||
| 19 | - 'ldks':5, | ||
| 20 | - 'in':6 | ||
| 21 | - }; | ||
| 22 | - var typeOrder = function (type) { | ||
| 23 | - return bcTypeOrderMap[type]?bcTypeOrderMap[type]:0; | ||
| 24 | - }; | ||
| 25 | - var schedule_sort = function (s1, s2) { | ||
| 26 | - var diff = s1['fcsjT'] - s2['fcsjT']; | ||
| 27 | - return diff!=0?diff:typeOrder(s1['bcType'])-typeOrder(s2['bcType']); | ||
| 28 | - }; | ||
| 29 | - | ||
| 30 | - var show = function (cb) { | ||
| 31 | - //从服务器获取班次数据 | ||
| 32 | - $.get('/realSchedule/lines', { | ||
| 33 | - lines: gb_data_basic.line_idx | ||
| 34 | - }, function (rs) { | ||
| 35 | - for (var lineCode in rs) { | ||
| 36 | - line2Schedule[lineCode] = {}; | ||
| 37 | - | ||
| 38 | - //排序 | ||
| 39 | - rs[lineCode].sort(schedule_sort); | ||
| 40 | - //calc shift | ||
| 41 | - $.each(rs[lineCode], function () { | ||
| 42 | - if(this.status==-1) | ||
| 43 | - clearActualTime(this); | ||
| 44 | - calc_sch_real_shift(this); | ||
| 45 | - wfydcolor(this); | ||
| 46 | - line2Schedule[lineCode][this.id] = this; | ||
| 47 | - //子任务公里是否与计划平 | ||
| 48 | - this.c_t_mileage_status = calcCTaskMileageStatus(this); | ||
| 49 | - }); | ||
| 50 | - //计算应发未发 | ||
| 51 | - calc_yfwf_num(lineCode); | ||
| 52 | - } | ||
| 53 | - ep.emit('data', rs); | ||
| 54 | - }); | ||
| 55 | - | ||
| 56 | - //加载班次表格渲染模板 | ||
| 57 | - $.get('/real_control_v2/fragments/line_schedule/sch_table.html', function (dom) { | ||
| 58 | - ep.emit('temp', gb_common.compileTempByDom(dom, { | ||
| 59 | - compress: true | ||
| 60 | - })); | ||
| 61 | - }); | ||
| 62 | - | ||
| 63 | - var ep = EventProxy.create("data", "temp", function (data, temp) { | ||
| 64 | - temps = temp; | ||
| 65 | - var lineCode, dirData, htmlStr; | ||
| 66 | - $('#main-tab-content .line_schedule').each(function () { | ||
| 67 | - lineCode = $(this).data('id'); | ||
| 68 | - if (arrayIsNull(data[lineCode])) | ||
| 69 | - return true; | ||
| 70 | - dirData = gb_common.groupBy(data[lineCode], 'xlDir'); | ||
| 71 | - for (var upDown in dirData) { | ||
| 72 | - htmlStr = temps['line-schedule-table-temp']({ | ||
| 73 | - dir: upDown, | ||
| 74 | - line: gb_data_basic.codeToLine[lineCode], | ||
| 75 | - list: dirData[upDown] | ||
| 76 | - }); | ||
| 77 | - | ||
| 78 | - $('.schedule-wrap .card-panel:eq(' + upDown + ')', this) | ||
| 79 | - .html(htmlStr); | ||
| 80 | - } | ||
| 81 | - | ||
| 82 | - //标记路牌最后一个班次 | ||
| 83 | - markerLastByLine(lineCode); | ||
| 84 | - //初始化图例相关,dbclick 不能代理事件 | ||
| 85 | - //gb_sch_legend.init(this); | ||
| 86 | - }); | ||
| 87 | - //初始化图例 | ||
| 88 | - gb_sch_legend.init(); | ||
| 89 | - var content = $('.line_schedule .ct_table_wrap'); | ||
| 90 | - //初始化滚动条 | ||
| 91 | - content.perfectScrollbar({suppressScrollX: true}); | ||
| 92 | - //fixed table head | ||
| 93 | - gb_ct_table.fixedHead(content); | ||
| 94 | - //enable sort | ||
| 95 | - gb_ct_table.enableSort($('.ct_table', content), reset_seq_no, gb_schedule_table_dbclick.init); | ||
| 96 | - //dbclick event | ||
| 97 | - gb_schedule_table_dbclick.init(); | ||
| 98 | - //双击实发 | ||
| 99 | - gb_schedule_table_dbclick.sfsjCellClick($('dd.fcsjActualCell')); | ||
| 100 | - //双击车辆 | ||
| 101 | - gb_schedule_table_dbclick.carCellClick($('.ct_table_body dd[data-nbbm]')); | ||
| 102 | - //搜索框初始化 | ||
| 103 | - gb_sch_search.init(); | ||
| 104 | - | ||
| 105 | - //监听gps车辆信息 | ||
| 106 | - gb_data_gps.registerCallback(renderCarRemark); | ||
| 107 | - gb_sch_legend.showYdSdDb(); | ||
| 108 | - cb && cb(); | ||
| 109 | - }); | ||
| 110 | - | ||
| 111 | - }; | ||
| 112 | - | ||
| 113 | - var renderCarRemark = function () { | ||
| 114 | - try{ | ||
| 115 | - var $activeTab = $('.north-tabs>ul>li.tab-line.uk-active');//.data('code'); | ||
| 116 | - if($activeTab.length==0) | ||
| 117 | - return; | ||
| 118 | - var lineCode = $activeTab.data('code'); | ||
| 119 | - var array = gb_common.get_vals(line2Schedule[lineCode]); | ||
| 120 | - var nbbms = {}; | ||
| 121 | - for(var i=0,sch;sch=array[i++];){ | ||
| 122 | - nbbms[sch.clZbh]=1; | ||
| 123 | - } | ||
| 124 | - | ||
| 125 | - var $activeWrap = $('#main-tab-content .line_schedule.uk-active .schedule-wrap .schedule-body'); | ||
| 126 | - var gps, e; | ||
| 127 | - for(var nbbm in nbbms){ | ||
| 128 | - gps = gb_data_gps.findGpsByNbbm(nbbm); | ||
| 129 | - e = $('.ct_table_body dl>dd[data-nbbm='+nbbm+']', $activeWrap); | ||
| 130 | - $('i', e).remove(); | ||
| 131 | - | ||
| 132 | - if(gps && gps['planCode']!=lineCode && gps.remark) | ||
| 133 | - $(e).append('<i class="uk-icon-exclamation-circle" data-uk-tooltip title="'+gps.remark+'"></i>'); | ||
| 134 | - } | ||
| 135 | - }catch (e){ | ||
| 136 | - console.log(e); | ||
| 137 | - } | ||
| 138 | - }; | ||
| 139 | - | ||
| 140 | - /** | ||
| 141 | - * 计算子任务公里是否和计划平 | ||
| 142 | - * @param sch | ||
| 143 | - */ | ||
| 144 | - var calcCTaskMileageStatus = function (sch) { | ||
| 145 | - if(!sch.cTasks || sch.cTasks.length==0) | ||
| 146 | - return 0; | ||
| 147 | - var sum = 0; | ||
| 148 | - $.each(sch.cTasks, function () { | ||
| 149 | - if (this.mileageType == 'service') { | ||
| 150 | - sum = gb_common.accAdd(sum, this.mileage); | ||
| 151 | - } | ||
| 152 | - }); | ||
| 153 | - | ||
| 154 | - if (sum != sch.jhlcOrig) { | ||
| 155 | - return -1; | ||
| 156 | - } | ||
| 157 | - return 0; | ||
| 158 | - }; | ||
| 159 | - | ||
| 160 | - | ||
| 161 | - //重置序号 | ||
| 162 | - var reset_seq_no = function (dls) { | ||
| 163 | - dls.each(function (i, dl) { | ||
| 164 | - $('dd:eq(0)', dl).text(i + 1); | ||
| 165 | - }); | ||
| 166 | - }; | ||
| 167 | - | ||
| 168 | - //计算实发时间差值 | ||
| 169 | - var calc_sch_real_shift = function (sch) { | ||
| 170 | - if (sch['fcsjActualTime']){ | ||
| 171 | - var fs = 'YYYY-MM-DD HH:mm' | ||
| 172 | - ,m1 = moment(sch['fcsjActualTime']).format(fs) | ||
| 173 | - ,m2 = moment(sch['dfsjT']).format(fs);//去掉秒 | ||
| 174 | - console.log(moment(m1, fs).format('X')) | ||
| 175 | - console.log(moment(m2, fs).format('X')) | ||
| 176 | - var diff = moment(m1, fs).format('X') - moment(m2, fs).format('X') | ||
| 177 | - ,fcsj_diff = parseInt(diff / 60, 10);; | ||
| 178 | - | ||
| 179 | - if(fcsj_diff > 0) | ||
| 180 | - sch.fcsj_diff = '( +' + fcsj_diff + ' )'; | ||
| 181 | - else if (fcsj_diff < 0) | ||
| 182 | - sch.fcsj_diff = '( ' + fcsj_diff + ' )'; | ||
| 183 | - else | ||
| 184 | - sch.fcsj_diff = ''; | ||
| 185 | - } | ||
| 186 | - }; | ||
| 187 | - //无发有到时间 | ||
| 188 | - var wfydcolor=function (sch) { | ||
| 189 | - if (sch.fcsjActual==null&&sch.zdsjActual!=null&&sch.zdsjActual!=''&&sch.status!=-1) {//sch.qdzArrDatesj!=''&&sch.qdzArrDatesj!=null&& | ||
| 190 | - sch.status=4; | ||
| 191 | - } | ||
| 192 | - } | ||
| 193 | - | ||
| 194 | - | ||
| 195 | - | ||
| 196 | - function arrayIsNull(array) { | ||
| 197 | - return !array || array.length == 0; | ||
| 198 | - } | ||
| 199 | - | ||
| 200 | - var findScheduleByLine = function (lineCode) { | ||
| 201 | - return line2Schedule[lineCode]; | ||
| 202 | - }; | ||
| 203 | - | ||
| 204 | - //新增一个班次,附带更新的班次 | ||
| 205 | - var insertSchedule = function (sch, upArr) { | ||
| 206 | - var xls = {}; | ||
| 207 | - xls[sch.xlBm] = 1; | ||
| 208 | - line2Schedule[sch.xlBm][sch.id] = sch; | ||
| 209 | - //update | ||
| 210 | - if (isArray(upArr)) { | ||
| 211 | - $.each(upArr, function () { | ||
| 212 | - line2Schedule[this.xlBm][this.id] = this; | ||
| 213 | - xls[this.xlBm] = 1; | ||
| 214 | - }); | ||
| 215 | - } | ||
| 216 | - | ||
| 217 | - //重新渲染表格 | ||
| 218 | - for(var xlBm in xls){ | ||
| 219 | - reRenderTable(sch.xlBm); | ||
| 220 | - } | ||
| 221 | - //定位到新添加的班次 | ||
| 222 | - scroToDl(sch); | ||
| 223 | - }; | ||
| 224 | - | ||
| 225 | - /** | ||
| 226 | - * 重新渲染表格 | ||
| 227 | - */ | ||
| 228 | - var reRenderTable = function (lineCode) { | ||
| 229 | - var data = gb_common.get_vals(line2Schedule[lineCode]).sort(schedule_sort), | ||
| 230 | - dirData = gb_common.groupBy(data, 'xlDir'), | ||
| 231 | - tabCont = $('li.line_schedule[data-id=' + lineCode + ']'), | ||
| 232 | - htmlStr; | ||
| 233 | - | ||
| 234 | - if($.isEmptyObject(dirData)){ | ||
| 235 | - $('.schedule-wrap .card-panel', tabCont).html(''); | ||
| 236 | - } | ||
| 237 | - else { | ||
| 238 | - for (var upDown in dirData) { | ||
| 239 | - htmlStr = temps['line-schedule-table-temp']({ | ||
| 240 | - dir: upDown, | ||
| 241 | - line: gb_data_basic.codeToLine[lineCode], | ||
| 242 | - list: dirData[upDown] | ||
| 243 | - }); | ||
| 244 | - $('.schedule-wrap .card-panel:eq(' + upDown + ')', tabCont).html(htmlStr); | ||
| 245 | - } | ||
| 246 | - //图例相关 | ||
| 247 | - gb_sch_legend.init(tabCont); | ||
| 248 | - //标记末班 | ||
| 249 | - markerLastByLine(lineCode); | ||
| 250 | - //计算应发未发 | ||
| 251 | - calc_yfwf_num(lineCode); | ||
| 252 | - //重新固定表头 | ||
| 253 | - gb_ct_table.fixedHead($('.schedule-wrap .ct_table_wrap', tabCont)); | ||
| 254 | - | ||
| 255 | - //重新初始化排序 | ||
| 256 | - gb_ct_table.enableSort($('.ct_table', tabCont), reset_seq_no, gb_schedule_table_dbclick.init); | ||
| 257 | - //重新初始化双击待发调整 | ||
| 258 | - gb_schedule_table_dbclick.init(); | ||
| 259 | - //重新初始化双击实发发车信息微调 | ||
| 260 | - gb_schedule_table_dbclick.sfsjCellClick($('dd.fcsjActualCell', tabCont)); | ||
| 261 | - //重新初始化双击车辆 | ||
| 262 | - gb_schedule_table_dbclick.carCellClick($('.ct_table_body dd[data-nbbm]')); | ||
| 263 | - //滚动条 | ||
| 264 | - $('.schedule-wrap .ct_table_wrap', tabCont).perfectScrollbar({suppressScrollX: true}); | ||
| 265 | - | ||
| 266 | - //搜索模板初始化 | ||
| 267 | - gb_sch_search.init(); | ||
| 268 | - } | ||
| 269 | - }; | ||
| 270 | - | ||
| 271 | - | ||
| 272 | - /** | ||
| 273 | - * 重新从服务器加载数据,并刷新表格 | ||
| 274 | - * @param lineCode | ||
| 275 | - */ | ||
| 276 | - var reLoadAndRefresh = function (lineCode) { | ||
| 277 | - $.get('/realSchedule/lines', { | ||
| 278 | - lines: lineCode + ',' | ||
| 279 | - }, function (rs) { | ||
| 280 | - if(!rs || $.isEmptyObject(rs)){ | ||
| 281 | - line2Schedule[lineCode] = {}; | ||
| 282 | - } | ||
| 283 | - else{ | ||
| 284 | - //排序 | ||
| 285 | - rs[lineCode].sort(schedule_sort); | ||
| 286 | - line2Schedule[lineCode] = {}; | ||
| 287 | - //calc shift | ||
| 288 | - $.each(rs[lineCode], function () { | ||
| 289 | - calc_sch_real_shift(this); | ||
| 290 | - line2Schedule[lineCode][this.id] = this; | ||
| 291 | - }); | ||
| 292 | - } | ||
| 293 | - //计算应发未发 | ||
| 294 | - calc_yfwf_num(lineCode); | ||
| 295 | - //重新渲染 | ||
| 296 | - reRenderTable(lineCode); | ||
| 297 | - }); | ||
| 298 | - }; | ||
| 299 | - | ||
| 300 | - //删除一个班次 | ||
| 301 | - var deheteSchedule = function (sch) { | ||
| 302 | - sch = line2Schedule[sch.xlBm][sch.id]; | ||
| 303 | - if (sch) { | ||
| 304 | - var dl = $('li.line_schedule[data-id=' + sch.xlBm + '] .ct_table_body dl[data-id=' + sch.id + ']'), | ||
| 305 | - dls = dl.parent().find('dl'); | ||
| 306 | - delete line2Schedule[sch.xlBm][sch.id]; | ||
| 307 | - dl.remove(); | ||
| 308 | - reset_seq_no(dls); | ||
| 309 | - calc_yfwf_num(sch.xlBm); | ||
| 310 | - } | ||
| 311 | - }; | ||
| 312 | - | ||
| 313 | - /** | ||
| 314 | - * 更新班次 | ||
| 315 | - * @param schArr | ||
| 316 | - */ | ||
| 317 | - var updateSchedule = function (schArr) { | ||
| 318 | - | ||
| 319 | - if (!isArray(schArr)) | ||
| 320 | - schArr = [schArr]; | ||
| 321 | - | ||
| 322 | - //var tMaps = {}; | ||
| 323 | - $.each(schArr, function () { | ||
| 324 | - try { | ||
| 325 | - if(this.status==-1) | ||
| 326 | - clearActualTime(this); | ||
| 327 | - //子任务公里是否与计划平 | ||
| 328 | - this.c_t_mileage_status = calcCTaskMileageStatus(this); | ||
| 329 | - line2Schedule[this.xlBm][this.id] = this; | ||
| 330 | - updateDom(this); | ||
| 331 | - }catch(e){} | ||
| 332 | - }); | ||
| 333 | - | ||
| 334 | - /* //重新标记末班 | ||
| 335 | - var ts=[]; | ||
| 336 | - for(var k in tMaps){ | ||
| 337 | - ts = k.split('_'); | ||
| 338 | - markerLastByNbbm(ts[0], ts[1]); | ||
| 339 | - }*/ | ||
| 340 | - }; | ||
| 341 | - | ||
| 342 | - | ||
| 343 | - /** | ||
| 344 | - * 更新班次 -只更新数据,不更新dom | ||
| 345 | - * @param schArr | ||
| 346 | - */ | ||
| 347 | - var updateData = function (schArr) { | ||
| 348 | - if (!isArray(schArr)) | ||
| 349 | - schArr = [schArr]; | ||
| 350 | - $.each(schArr, function () { | ||
| 351 | - if(this.status==-1) | ||
| 352 | - clearActualTime(this); | ||
| 353 | - line2Schedule[this.xlBm][this.id] = this; | ||
| 354 | - }); | ||
| 355 | - }; | ||
| 356 | - | ||
| 357 | - //update dom | ||
| 358 | - var updateDom = function (sch) { | ||
| 359 | - if (!sch) return; | ||
| 360 | - var dl = $('li.line_schedule[data-id=' + sch.xlBm + '] .ct_table_body dl[data-id=' + sch.id + ']'); | ||
| 361 | - var dds = $('dd', dl); | ||
| 362 | - $(dds[1]).find('a').text(sch.lpName); | ||
| 363 | - var light = !sch.qdzArrDatesj ? 'tl-white' : 'tl-grey'; | ||
| 364 | - if (sch.rfidState & 1 == 1) { | ||
| 365 | - light = 'tl-yellow'; | ||
| 366 | - if (sch.rfidState & 2 == 2) { | ||
| 367 | - light = 'tl-green'; | ||
| 368 | - } | ||
| 369 | - } | ||
| 370 | - $(dds[2]).style('background', light); | ||
| 371 | - | ||
| 372 | - //车辆自编号 | ||
| 373 | - var $newDds3 = $(temps['line-schedule-nbbm-temp'](sch)); | ||
| 374 | - $(dds[3]).replaceWith($newDds3); | ||
| 375 | - //车辆双击 | ||
| 376 | - gb_schedule_table_dbclick.carCellClick($newDds3); | ||
| 377 | - $(dds[4]).text(sch.qdzArrDatejh ? sch.qdzArrDatejh : ''); | ||
| 378 | - $(dds[5]).text(sch.qdzArrDatesj ? sch.qdzArrDatesj : ''); | ||
| 379 | - | ||
| 380 | - //计发时间 | ||
| 381 | - var d5html = temps['line-schedule-fcsj-temp'](sch); | ||
| 382 | - if (sch.lpChange == 1) { | ||
| 383 | - d5html = d5html.replace('</dd>', '') + '<span class="uk-badge uk-badge-success out">换</span>' + '</dd>'; | ||
| 384 | - } | ||
| 385 | - $(dds[6]).replaceWith(d5html); | ||
| 386 | - //待发时间 | ||
| 387 | - var dfHtmlStr = sch.dfsj + (sch.late2?'<span class="late-badge">?+'+sch.lateMinute+'</span>':''); | ||
| 388 | - $(dds[7]).attr('data-sort-val', sch.dfsjT).attr('dbclick-val', sch.dfsj).html(dfHtmlStr); | ||
| 389 | - | ||
| 390 | - //实发时间 | ||
| 391 | - calc_sch_real_shift(sch); | ||
| 392 | - var sfsjDd = $(temps['line-schedule-sfsj-temp'](sch)); | ||
| 393 | - //双击 | ||
| 394 | - gb_schedule_table_dbclick.sfsjCellClick(sfsjDd); | ||
| 395 | - $(dds[8]).replaceWith(sfsjDd); | ||
| 396 | - if (sch.remarks) | ||
| 397 | - $(dds[9]).html('<span title="' + sch.remarks + '" data-uk-tooltip="{pos:\'top-left\'}">' + sch.remarks + '</span>'); | ||
| 398 | - else | ||
| 399 | - $(dds[9]).html(''); | ||
| 400 | - | ||
| 401 | - //信号状态标记 | ||
| 402 | - gb_signal_state.marker_sch(sch); | ||
| 403 | - //班次是车辆的最后一班 | ||
| 404 | - if (dl.hasClass('dl-last-sch')) | ||
| 405 | - markerLastSch([sch]); | ||
| 406 | - | ||
| 407 | - renderCarRemark(); | ||
| 408 | - }; | ||
| 409 | - | ||
| 410 | - //单击实发单元格显示详细信息 | ||
| 411 | - $(document).on('click', 'dd.fcsjActualCell', function () { | ||
| 412 | - var that = this; | ||
| 413 | - $(that).qtip({ | ||
| 414 | - show: true, | ||
| 415 | - content: { | ||
| 416 | - text: function (e) { | ||
| 417 | - var lineCode = $(that).parents('li.line_schedule').data('id') | ||
| 418 | - , id = $(that).parents('dl').data('id') | ||
| 419 | - , sch = line2Schedule[lineCode][id]; | ||
| 420 | - return temps['sfsj_sch-detail-temp'](sch); | ||
| 421 | - } | ||
| 422 | - } | ||
| 423 | - , style: { | ||
| 424 | - classes: 'qtip-dark qtip-rounded qtip-shadow' | ||
| 425 | - }, | ||
| 426 | - hide: { | ||
| 427 | - fixed: true, | ||
| 428 | - delay: 300 | ||
| 429 | - }, | ||
| 430 | - position: { | ||
| 431 | - target: that, | ||
| 432 | - my: 'center left', | ||
| 433 | - at: 'center right' | ||
| 434 | - }, | ||
| 435 | - events: { | ||
| 436 | - hidden: function (event, api) { | ||
| 437 | - $(this).qtip('destroy', true); | ||
| 438 | - } | ||
| 439 | - } | ||
| 440 | - }); | ||
| 441 | - | ||
| 442 | - //车辆rect 闪烁、 | ||
| 443 | - var wrap = $(that).parents('li.line_schedule'); | ||
| 444 | - var nbbm = $(that).parents('dl').find('dd:eq(2)').data('nbbm'); | ||
| 445 | - var device = gb_data_basic.nbbm2deviceMap()[nbbm]; | ||
| 446 | - var $rect = $('svg.line-chart g.gps-wrap rect[_id=rct_' + device + ']', wrap); | ||
| 447 | - | ||
| 448 | - //merge_hide | ||
| 449 | - if ($rect.hasClass('merge_hide') || $rect.attr('y') < 0) | ||
| 450 | - return; | ||
| 451 | - $rect.attr('class', 'twinkle').one('animationend', function () { | ||
| 452 | - $(this).removeAttr('class'); | ||
| 453 | - }); | ||
| 454 | - }); | ||
| 455 | - | ||
| 456 | - //拖拽选中... | ||
| 457 | - var seq_nos = '.line-schedule-table .ct_table_body>dl>dd.seq_no'; | ||
| 458 | - var drag_strat; | ||
| 459 | - $(document).on('mousedown', seq_nos, function (e) { | ||
| 460 | - if (e.button != 0) return; | ||
| 461 | - var dl = $(this).parent(); | ||
| 462 | - if (dl.hasClass('drag-active')) | ||
| 463 | - dl.removeClass('drag-active'); | ||
| 464 | - else | ||
| 465 | - dl.addClass('drag-active'); | ||
| 466 | - | ||
| 467 | - drag_strat = parseInt($(this).text()) - 1; | ||
| 468 | - }).on('mouseup', function () { | ||
| 469 | - drag_strat = null; | ||
| 470 | - }).on('mouseover', seq_nos, function () { | ||
| 471 | - if (drag_strat != null) { | ||
| 472 | - var e = parseInt($(this).text()), | ||
| 473 | - dls = $(this).parents('.ct_table_body').find('dl'); | ||
| 474 | - | ||
| 475 | - reset_drag_active_all(this); | ||
| 476 | - //向上选中 | ||
| 477 | - if (e <= drag_strat) { | ||
| 478 | - for (var i = drag_strat; i > e - 2; i--) | ||
| 479 | - $(dls[i]).addClass('drag-active'); | ||
| 480 | - } | ||
| 481 | - //向下选中 | ||
| 482 | - else { | ||
| 483 | - for (var j = drag_strat; j < e; j++) | ||
| 484 | - $(dls[j]).addClass('drag-active'); | ||
| 485 | - } | ||
| 486 | - } | ||
| 487 | - }).on('click', seq_nos, function () { | ||
| 488 | - reset_relevance_active(this); | ||
| 489 | - }); | ||
| 490 | - //非seq_no 单元格点击 | ||
| 491 | - $(document).on('click', '.line-schedule-table .ct_table_body dl dd[class!=seq_no][class!=lpName]', function () { | ||
| 492 | - reset_drag_active_all(this); | ||
| 493 | - //选中相关班次 | ||
| 494 | - var id = $(this).parent().data('id'), | ||
| 495 | - contWrap = $(this).parents('li.line_schedule'), | ||
| 496 | - lineCode = contWrap.data('id'), | ||
| 497 | - sch = line2Schedule[lineCode][id], | ||
| 498 | - schArr = gb_common.get_vals(line2Schedule[lineCode]).filter(function (item) { | ||
| 499 | - return item.clZbh == sch.clZbh; | ||
| 500 | - }).sort(schedule_sort), | ||
| 501 | - nextSch, tempDL; | ||
| 502 | - | ||
| 503 | - getDl(sch).addClass('intimity'); | ||
| 504 | - $.each(schArr, function (i) { | ||
| 505 | - tempDL = $('dl[data-id=' + this.id + ']', contWrap); | ||
| 506 | - tempDL.addClass('relevance-active'); | ||
| 507 | - if (i < schArr.length - 1 && this.id == id) { | ||
| 508 | - nextSch = schArr[i + 1]; | ||
| 509 | - } | ||
| 510 | - }); | ||
| 511 | - | ||
| 512 | - if (nextSch) { | ||
| 513 | - $('dl[data-id=' + nextSch.id + ']', contWrap).addClass('intimity'); | ||
| 514 | - /*if (nextSch.xlDir == sch.xlDir) | ||
| 515 | - return;*/ | ||
| 516 | - //滚动到下一个班次 | ||
| 517 | - if(nextSch.xlDir != sch.xlDir) | ||
| 518 | - scroToDl(nextSch); | ||
| 519 | - | ||
| 520 | - } | ||
| 521 | - | ||
| 522 | - //如果有打开轨迹回放 | ||
| 523 | - if($('.layui-layer.play_back-layer').is(':visible')){ | ||
| 524 | - gb_map_play_back.setParam(sch); | ||
| 525 | - } | ||
| 526 | - }); | ||
| 527 | - | ||
| 528 | - //路牌点击 | ||
| 529 | - $(document).on('click', '.line-schedule-table .ct_table_body dl dd[class=lpName]', function () { | ||
| 530 | - reset_drag_active_all(this); | ||
| 531 | - //选中路牌下相关班次 | ||
| 532 | - var id = $(this).parent().data('id'), | ||
| 533 | - contWrap = $(this).parents('li.line_schedule'), | ||
| 534 | - lineCode = contWrap.data('id'), | ||
| 535 | - sch = line2Schedule[lineCode][id], | ||
| 536 | - schArr = gb_common.get_vals(line2Schedule[lineCode]).filter(function (item) { | ||
| 537 | - return item.lpName == sch.lpName; | ||
| 538 | - }).sort(schedule_sort); | ||
| 539 | - $.each(schArr, function (i) { | ||
| 540 | - $('dl[data-id=' + this.id + ']', contWrap).addClass('relevance-active intimity'); | ||
| 541 | - }); | ||
| 542 | - | ||
| 543 | - //notify_succ('高亮路牌 ' + sch.lpName); | ||
| 544 | - showLpMileageTip(lineCode, sch.lpName, schArr); | ||
| 545 | - }); | ||
| 546 | - | ||
| 547 | - var showLpMileageTipBySch = function (sch) { | ||
| 548 | - if(!$('.mileage_elec_panel', $('.line_schedule[data-id='+sch.xlBm+']')).is(':visible')) | ||
| 549 | - return; | ||
| 550 | - | ||
| 551 | - var schArr = gb_common.get_vals(line2Schedule[sch.xlBm]).filter(function (item) { | ||
| 552 | - return item.lpName == sch.lpName; | ||
| 553 | - }).sort(schedule_sort); | ||
| 554 | - | ||
| 555 | - showLpMileageTip(sch.xlBm, sch.lpName, schArr); | ||
| 556 | - }; | ||
| 557 | - /** | ||
| 558 | - * 弹出路牌公里统计tip | ||
| 559 | - * @param lineCode | ||
| 560 | - * @param lpName | ||
| 561 | - * @param array | ||
| 562 | - */ | ||
| 563 | - var showLpMileageTip = function (lineCode, lpName, array) { | ||
| 564 | - var wrap = $('.line_schedule[data-id='+lineCode+']'); | ||
| 565 | - //按驾驶员&车辆分组统计 | ||
| 566 | - var data=mileageTipGroupData(array); | ||
| 567 | - //统计公里 | ||
| 568 | - var list=[]; | ||
| 569 | - for(var key in data){ | ||
| 570 | - list.push({ | ||
| 571 | - key : key, | ||
| 572 | - serviceMileage: gb_sch_mileage_count.serviceMileage(data[key]), | ||
| 573 | - destroyMileage: gb_sch_mileage_count.destroyMileage(data[key]), | ||
| 574 | - emptyMileage: gb_sch_mileage_count.emptyMileage(data[key]) | ||
| 575 | - }) | ||
| 576 | - } | ||
| 577 | - var htmlStr = temps['sch-lp-mileage-tip-temp']({data: list, lpName:lpName}); | ||
| 578 | - $('.mileage_elec_panel', wrap).html(htmlStr).addClass('uk-animation-slide-bottom').show() | ||
| 579 | - .one('animationEnd', function () { | ||
| 580 | - $(this).removeClass('uk-animation-slide-bottom'); | ||
| 581 | - }); | ||
| 582 | - }; | ||
| 583 | - | ||
| 584 | - /** | ||
| 585 | - * 分组数据,处理子任务里的中途换车 | ||
| 586 | - * @param array | ||
| 587 | - */ | ||
| 588 | - var mileageTipGroupData = function (arr) { | ||
| 589 | - var list = JSON.parse(JSON.stringify(arr)); | ||
| 590 | - var cts; | ||
| 591 | - var zthcArray=[]; | ||
| 592 | - var sch; | ||
| 593 | - for(var i=0,len=list.length;i<len;i++){ | ||
| 594 | - sch = list[i]; | ||
| 595 | - cts = sch['cTasks']; | ||
| 596 | - if(!cts || cts.length==0) | ||
| 597 | - continue; | ||
| 598 | - | ||
| 599 | - sch['cTasks'] = []; | ||
| 600 | - //有子任务 | ||
| 601 | - for(var j=0,ct;ct=cts[j++];){ | ||
| 602 | - if(!ct.nbbm || ct.nbbm==sch.clZbh){ | ||
| 603 | - sch['cTasks'].push(ct); | ||
| 604 | - continue; | ||
| 605 | - } | ||
| 606 | - | ||
| 607 | - zthcArray.push(cloneByCTask(sch, ct)); | ||
| 608 | - } | ||
| 609 | - } | ||
| 610 | - | ||
| 611 | - if(zthcArray.length > 0) | ||
| 612 | - list = list.concat(zthcArray); | ||
| 613 | - | ||
| 614 | - var data={},key; | ||
| 615 | - for(var i=0,len=list.length;i<len;i++){ | ||
| 616 | - key = list[i].clZbh+'/'+list[i].jGh+'('+list[i].jName+')'; | ||
| 617 | - if(!data[key]) | ||
| 618 | - data[key] = []; | ||
| 619 | - data[key].push(list[i]); | ||
| 620 | - } | ||
| 621 | - return data; | ||
| 622 | - }; | ||
| 623 | - | ||
| 624 | - var cloneByCTask = function (sch, ct) { | ||
| 625 | - var newObj = JSON.parse(JSON.stringify(sch)); | ||
| 626 | - newObj['cTasks']=[]; | ||
| 627 | - newObj.clZbh = ct.nbbm; | ||
| 628 | - newObj.fcsjActual = ct.startDate; | ||
| 629 | - newObj.zdsjActual = ct.endDate; | ||
| 630 | - newObj.jhlc = ct.mileage; | ||
| 631 | - newObj.jhlcOrig = ct.mileage; | ||
| 632 | - | ||
| 633 | - if(ct.type2=='1') | ||
| 634 | - newObj.bcType='normal'; | ||
| 635 | - else if(ct.type2=='2'){ | ||
| 636 | - newObj.bcType='in'; | ||
| 637 | - }else if(ct.type2=='3') | ||
| 638 | - newObj.bcType='out'; | ||
| 639 | - | ||
| 640 | - return newObj; | ||
| 641 | - }; | ||
| 642 | - | ||
| 643 | - //头部点击去掉选中光标 | ||
| 644 | - $(document).on('click', '.header-title', function () { | ||
| 645 | - reset_drag_active_all(this); | ||
| 646 | - }); | ||
| 647 | - | ||
| 648 | - var scroToDl = function (sch) { | ||
| 649 | - var dl = getDl(sch), | ||
| 650 | - cont = dl.parents('.ct_table_wrap'), | ||
| 651 | - diff = cont.height() / 2; | ||
| 652 | - cont.animate({ | ||
| 653 | - scrollTop: dl.offset().top - cont.offset().top + cont.scrollTop() - diff | ||
| 654 | - }, 500); | ||
| 655 | - | ||
| 656 | - return dl; | ||
| 657 | - }; | ||
| 658 | - | ||
| 659 | - var getDl = function (sch) { | ||
| 660 | - return $('dl[data-id=' + sch.id + ']', $('.line_schedule[data-id=' + sch.xlBm + ']')); | ||
| 661 | - }; | ||
| 662 | - | ||
| 663 | - var reset_drag_active_all = function (dd) { | ||
| 664 | - $(dd).parents('.schedule-wrap').find('dl.drag-active').removeClass('drag-active'); | ||
| 665 | - reset_relevance_active(dd); | ||
| 666 | - | ||
| 667 | - $('.mileage_elec_panel', $(dd).parents('.top-container')).hide().remove('uk-animation-slide-bottom'); | ||
| 668 | - }; | ||
| 669 | - | ||
| 670 | - var reset_relevance_active = function (dd) { | ||
| 671 | - $(dd).parents('.uk-grid.schedule-wrap').find('.relevance-active').removeClass('relevance-active intimity'); | ||
| 672 | - }; | ||
| 673 | - | ||
| 674 | - | ||
| 675 | - //计算应发未发数量 car_yfwf_map | ||
| 676 | - var calc_yfwf_num = function (lineCode) { | ||
| 677 | - | ||
| 678 | - var schArr = gb_common.get_vals(line2Schedule[lineCode]).sort(schedule_sort), | ||
| 679 | - yfwf_num = 0, | ||
| 680 | - t = new Date().valueOf(); | ||
| 681 | - | ||
| 682 | - var carYfwfMap = {}, nbbm; | ||
| 683 | - $.each(schArr, function () { | ||
| 684 | - /*if (this.dfsjT > t) | ||
| 685 | - return false;*/ | ||
| 686 | - | ||
| 687 | - if (this.dfsjT < t && | ||
| 688 | - this.fcsjActual == null && this.fcsjActualTime == null && this.status != -1) { | ||
| 689 | - yfwf_num++; | ||
| 690 | - nbbm = this.clZbh; | ||
| 691 | - if (carYfwfMap[nbbm]) | ||
| 692 | - carYfwfMap[nbbm]++; | ||
| 693 | - else | ||
| 694 | - carYfwfMap[nbbm] = 1; | ||
| 695 | - } | ||
| 696 | - }); | ||
| 697 | - car_yfwf_map[lineCode] = carYfwfMap; | ||
| 698 | - | ||
| 699 | - $('#badge_yfwf_num_' + lineCode).text(yfwf_num); | ||
| 700 | - }; | ||
| 701 | - | ||
| 702 | - //标记终点时间 -线路 | ||
| 703 | - var markerLastByLine = function (lineCode) { | ||
| 704 | - var data = gb_common.groupBy(gb_common.get_vals(line2Schedule[lineCode]).filter(schDestroyFilter), 'lpName'); | ||
| 705 | - | ||
| 706 | - var array, lastSch, dl; | ||
| 707 | - for (var nbbm in data) { | ||
| 708 | - array = data[nbbm].sort(schedule_sort); | ||
| 709 | - markerLastSch(array); | ||
| 710 | - } | ||
| 711 | - }; | ||
| 712 | - | ||
| 713 | - //标记终点时间 -车辆 | ||
| 714 | - var markerLastByNbbm = function (lineCode, nbbm) { | ||
| 715 | - var array = gb_common.get_vals(line2Schedule[lineCode]).filter(function (a) { | ||
| 716 | - return a.clZbh == nbbm && a.status != -1; | ||
| 717 | - }).sort(schedule_sort); | ||
| 718 | - | ||
| 719 | - removeMarkers(lineCode, array); | ||
| 720 | - markerLastSch(array); | ||
| 721 | - }; | ||
| 722 | - | ||
| 723 | - var markerLastSch = function (array) { | ||
| 724 | - var lastSch = array[array.length - 1]; | ||
| 725 | - | ||
| 726 | - if (!lastSch.jhlc) | ||
| 727 | - return; | ||
| 728 | - | ||
| 729 | - var dl = getDl(lastSch); | ||
| 730 | - dl.addClass('dl-last-sch'); | ||
| 731 | - | ||
| 732 | - $('dd.fcsjActualCell', dl).append(temps['last-sch-sunken-temp'](lastSch)); | ||
| 733 | - }; | ||
| 734 | - | ||
| 735 | - //清除线路下指定班次的 末班标记 | ||
| 736 | - var removeMarkers = function (lineCode, array) { | ||
| 737 | - var idx = []; | ||
| 738 | - $.each(array, function () { | ||
| 739 | - idx.push(this.id); | ||
| 740 | - }); | ||
| 741 | - | ||
| 742 | - $('dl.dl-last-sch', 'li.line_schedule[data-id=' + lineCode + ']').each(function () { | ||
| 743 | - if ($(this).hasClass('dl-last-sch') && idx.indexOf($(this).data('id'))) { | ||
| 744 | - $(this).removeClass('dl-last-sch').find('.last-sch-sunken').remove(); | ||
| 745 | - } | ||
| 746 | - }); | ||
| 747 | - }; | ||
| 748 | - | ||
| 749 | - var schDestroyFilter = function (a) { | ||
| 750 | - return a.status != -1; | ||
| 751 | - }; | ||
| 752 | - | ||
| 753 | - /* 下一个班次 */ | ||
| 754 | - var getNextSch = function (sch) { | ||
| 755 | - var array = gb_common.get_vals(line2Schedule[sch.xlBm]).filter(function (a) { | ||
| 756 | - return a.clZbh == sch.clZbh; | ||
| 757 | - }).sort(schedule_sort); | ||
| 758 | - | ||
| 759 | - for (var i = 0, item; item = array[i++];) { | ||
| 760 | - if (array[i].id == sch.id) { | ||
| 761 | - return i < array.length ? array[i + 1] : null; | ||
| 762 | - } | ||
| 763 | - } | ||
| 764 | - }; | ||
| 765 | - | ||
| 766 | - /* 下一个班次普通班次 */ | ||
| 767 | - var getNextNormalSch = function (sch) { | ||
| 768 | - | ||
| 769 | - var array = gb_common.get_vals(line2Schedule[sch.xlBm]).filter(function (a) { | ||
| 770 | - return a.clZbh == sch.clZbh && a.bcType=='normal'; | ||
| 771 | - }).sort(schedule_sort); | ||
| 772 | - | ||
| 773 | - for (var i = 0; i < array.length; i++) { | ||
| 774 | - if (array[i].id == sch.id) { | ||
| 775 | - return i < array.length ? array[i + 1] : null; | ||
| 776 | - } | ||
| 777 | - } | ||
| 778 | - }; | ||
| 779 | - | ||
| 780 | - /** 添加备注信息 */ | ||
| 781 | - var addRemarks = function (list, remarks) { | ||
| 782 | - //if(!list || list) | ||
| 783 | - var i = 0, sch; | ||
| 784 | - | ||
| 785 | - (function () { | ||
| 786 | - var f = arguments.callee; | ||
| 787 | - if(i >= list.length){ | ||
| 788 | - return; | ||
| 789 | - } | ||
| 790 | - sch = list[i]; | ||
| 791 | - gb_common.$post('/realSchedule/addRemarks', {id: sch.id, remarks: remarks}, function (rs) { | ||
| 792 | - if(rs.t){ | ||
| 793 | - sch = rs.t; | ||
| 794 | - line2Schedule[sch.xlBm][sch.id] = sch; | ||
| 795 | - updateDom(sch); | ||
| 796 | - i++; | ||
| 797 | - f(); | ||
| 798 | - } | ||
| 799 | - }); | ||
| 800 | - })(); | ||
| 801 | - }; | ||
| 802 | - | ||
| 803 | - /** | ||
| 804 | - * 显示误点停靠时间标记 | ||
| 805 | - * @param id | ||
| 806 | - * @param minute | ||
| 807 | - */ | ||
| 808 | - var showLateBadge = function (lineCode, id, minute) { | ||
| 809 | - var dfCell = cancelLateBadge(lineCode, id); | ||
| 810 | - $(dfCell).append('<span class="late-badge">?+'+minute+'</span>'); | ||
| 811 | - }; | ||
| 812 | - | ||
| 813 | - /** | ||
| 814 | - * 取消误点标记 | ||
| 815 | - * @param lineCode | ||
| 816 | - * @param id | ||
| 817 | - */ | ||
| 818 | - var cancelLateBadge = function (lineCode, id) { | ||
| 819 | - var $dl = getDl({id: id, xlBm: lineCode}); | ||
| 820 | - var dfCell = $dl.find('dd')[6]; | ||
| 821 | - $('.late-badge',dfCell).remove(); | ||
| 822 | - return dfCell; | ||
| 823 | - }; | ||
| 824 | - | ||
| 825 | - | ||
| 826 | - /** | ||
| 827 | - * 刷新页面的所有线路班次 | ||
| 828 | - */ | ||
| 829 | - var refreshAll = function () { | ||
| 830 | - show(); | ||
| 831 | - }; | ||
| 832 | - | ||
| 833 | - /** | ||
| 834 | - * 获取线路下营运的车辆 | ||
| 835 | - */ | ||
| 836 | - var findNbbmByLineCode = function (lineCode) { | ||
| 837 | - try{ | ||
| 838 | - return gb_common.get_keys(gb_common.extractNbbm(gb_common.get_vals(line2Schedule[lineCode]))); | ||
| 839 | - }catch (e){ | ||
| 840 | - return []; | ||
| 841 | - } | ||
| 842 | - }; | ||
| 843 | - | ||
| 844 | - var clearActualTime = function (sch) { | ||
| 845 | - try{ | ||
| 846 | - sch.fcsjActual=null; | ||
| 847 | - sch.fcsjActualTime=null; | ||
| 848 | - sch.zdsjActual=null; | ||
| 849 | - sch.zdsjActualTime=null; | ||
| 850 | - }catch (e){ | ||
| 851 | - console.log(e); | ||
| 852 | - } | ||
| 853 | - }; | ||
| 854 | - | ||
| 855 | - /** | ||
| 856 | - * 班次站点编码异常信息 | ||
| 857 | - * @param list | ||
| 858 | - */ | ||
| 859 | - var putSCodeErrorInfo = function (list) { | ||
| 860 | - //按线路走向分组 | ||
| 861 | - var data = {}; | ||
| 862 | - var k; | ||
| 863 | - for(var i=0,obj;obj=list[i++];){ | ||
| 864 | - k = obj.lineCode+'_'+obj.upDown; | ||
| 865 | - | ||
| 866 | - if(obj.realStationCode && obj.realStationCode.indexOf('^') != -1) | ||
| 867 | - obj.realStationCode = obj.realStationCode.split('^')[0]; | ||
| 868 | - | ||
| 869 | - if(!data[k]) | ||
| 870 | - data[k] = []; | ||
| 871 | - data[k].push(obj); | ||
| 872 | - } | ||
| 873 | - | ||
| 874 | - var wrap; | ||
| 875 | - for(var k in data){ | ||
| 876 | - wrap = $('.line_schedule[data-id=' + (k.split('_')[0]) + ']'); | ||
| 877 | - if(wrap.length==0) | ||
| 878 | - continue; | ||
| 879 | - | ||
| 880 | - $(".schedule-wrap span.warn_multi_station[data-updown="+(k.split('_')[1])+"]", wrap) | ||
| 881 | - .html('o(* ̄▽ ̄*)o 班次和站点关联有点问题!!').show(); | ||
| 882 | - } | ||
| 883 | - | ||
| 884 | - errorCodeData = data; | ||
| 885 | - }; | ||
| 886 | - | ||
| 887 | - var findSCodeErrorInfo = function (lineCode, upDown) { | ||
| 888 | - return errorCodeData[lineCode+'_'+upDown]; | ||
| 889 | - }; | ||
| 890 | - | ||
| 891 | - var refreshRfid = function (sch) { | ||
| 892 | - var $dl = getDl({id: sch.id, xlBm: sch.xlBm}); | ||
| 893 | - var dfCell = $dl.find('dd')[2]; | ||
| 894 | - var light = !sch.qdzArrDatesj ? 'tl-white' : 'tl-grey'; | ||
| 895 | - if (sch.rfidState & 1 == 1) { | ||
| 896 | - light = 'tl-yellow'; | ||
| 897 | - if (sch.rfidState & 2 == 2) { | ||
| 898 | - light = 'tl-green'; | ||
| 899 | - } | ||
| 900 | - } | ||
| 901 | - $(dfCell).attr('class', light); | ||
| 902 | - }; | ||
| 903 | - | ||
| 904 | - return { | ||
| 905 | - show: show, | ||
| 906 | - findScheduleByLine: findScheduleByLine, | ||
| 907 | - updateSchedule: updateSchedule, | ||
| 908 | - updateData: updateData, | ||
| 909 | - deheteSchedule: deheteSchedule, | ||
| 910 | - insertSchedule: insertSchedule, | ||
| 911 | - schedule_sort: schedule_sort, | ||
| 912 | - calc_yfwf_num: calc_yfwf_num, | ||
| 913 | - car_yfwf_map: function (lineCode) { | ||
| 914 | - return car_yfwf_map[lineCode]; | ||
| 915 | - }, | ||
| 916 | - scroToDl: scroToDl, | ||
| 917 | - reset_drag_active_all: reset_drag_active_all, | ||
| 918 | - getDl: getDl, | ||
| 919 | - getNextSch: getNextSch, | ||
| 920 | - addRemarks: addRemarks, | ||
| 921 | - reLoadAndRefresh: reLoadAndRefresh, | ||
| 922 | - showLateBadge: showLateBadge, | ||
| 923 | - cancelLateBadge: cancelLateBadge, | ||
| 924 | - refreshAll: refreshAll, | ||
| 925 | - getNextNormalSch: getNextNormalSch, | ||
| 926 | - findNbbmByLineCode:findNbbmByLineCode, | ||
| 927 | - showLpMileageTipBySch: showLpMileageTipBySch, | ||
| 928 | - renderCarRemark: renderCarRemark, | ||
| 929 | - putSCodeErrorInfo: putSCodeErrorInfo, | ||
| 930 | - findSCodeErrorInfo: findSCodeErrorInfo, | ||
| 931 | - refreshRfid: refreshRfid | ||
| 932 | - }; | ||
| 933 | -})(); | 1 | +/** schedule table */ |
| 2 | + | ||
| 3 | +var gb_schedule_table = (function () { | ||
| 4 | + | ||
| 5 | + var temps; | ||
| 6 | + //线路分组的班次数据 | ||
| 7 | + var line2Schedule = {}; | ||
| 8 | + //车辆应发未发车辆数 | ||
| 9 | + var car_yfwf_map = {}; | ||
| 10 | + //班次站点编码和实际不符数据 | ||
| 11 | + var errorCodeData = {}; | ||
| 12 | + | ||
| 13 | + var bcTypeOrderMap = { | ||
| 14 | + 'out':0, | ||
| 15 | + 'normal':1, | ||
| 16 | + 'region':2, | ||
| 17 | + 'major':3, | ||
| 18 | + 'venting':4, | ||
| 19 | + 'ldks':5, | ||
| 20 | + 'in':6 | ||
| 21 | + }; | ||
| 22 | + var typeOrder = function (type) { | ||
| 23 | + return bcTypeOrderMap[type]?bcTypeOrderMap[type]:0; | ||
| 24 | + }; | ||
| 25 | + var schedule_sort = function (s1, s2) { | ||
| 26 | + var diff = s1['fcsjT'] - s2['fcsjT']; | ||
| 27 | + return diff!=0?diff:typeOrder(s1['bcType'])-typeOrder(s2['bcType']); | ||
| 28 | + }; | ||
| 29 | + | ||
| 30 | + var show = function (cb) { | ||
| 31 | + //从服务器获取班次数据 | ||
| 32 | + $.get('/realSchedule/lines', { | ||
| 33 | + lines: gb_data_basic.line_idx | ||
| 34 | + }, function (rs) { | ||
| 35 | + for (var lineCode in rs) { | ||
| 36 | + line2Schedule[lineCode] = {}; | ||
| 37 | + | ||
| 38 | + //排序 | ||
| 39 | + rs[lineCode].sort(schedule_sort); | ||
| 40 | + //calc shift | ||
| 41 | + $.each(rs[lineCode], function () { | ||
| 42 | + if(this.status==-1) | ||
| 43 | + clearActualTime(this); | ||
| 44 | + calc_sch_real_shift(this); | ||
| 45 | + wfydcolor(this); | ||
| 46 | + line2Schedule[lineCode][this.id] = this; | ||
| 47 | + //子任务公里是否与计划平 | ||
| 48 | + this.c_t_mileage_status = calcCTaskMileageStatus(this); | ||
| 49 | + }); | ||
| 50 | + //计算应发未发 | ||
| 51 | + calc_yfwf_num(lineCode); | ||
| 52 | + } | ||
| 53 | + ep.emit('data', rs); | ||
| 54 | + }); | ||
| 55 | + | ||
| 56 | + //加载班次表格渲染模板 | ||
| 57 | + $.get('/real_control_v2/fragments/line_schedule/sch_table.html', function (dom) { | ||
| 58 | + ep.emit('temp', gb_common.compileTempByDom(dom, { | ||
| 59 | + compress: true | ||
| 60 | + })); | ||
| 61 | + }); | ||
| 62 | + | ||
| 63 | + var ep = EventProxy.create("data", "temp", function (data, temp) { | ||
| 64 | + temps = temp; | ||
| 65 | + var lineCode, dirData, htmlStr; | ||
| 66 | + $('#main-tab-content .line_schedule').each(function () { | ||
| 67 | + lineCode = $(this).data('id'); | ||
| 68 | + if (arrayIsNull(data[lineCode])) | ||
| 69 | + return true; | ||
| 70 | + dirData = gb_common.groupBy(data[lineCode], 'xlDir'); | ||
| 71 | + for (var upDown in dirData) { | ||
| 72 | + htmlStr = temps['line-schedule-table-temp']({ | ||
| 73 | + dir: upDown, | ||
| 74 | + line: gb_data_basic.codeToLine[lineCode], | ||
| 75 | + list: dirData[upDown] | ||
| 76 | + }); | ||
| 77 | + | ||
| 78 | + $('.schedule-wrap .card-panel:eq(' + upDown + ')', this) | ||
| 79 | + .html(htmlStr); | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + //标记路牌最后一个班次 | ||
| 83 | + markerLastByLine(lineCode); | ||
| 84 | + //初始化图例相关,dbclick 不能代理事件 | ||
| 85 | + //gb_sch_legend.init(this); | ||
| 86 | + }); | ||
| 87 | + //初始化图例 | ||
| 88 | + gb_sch_legend.init(); | ||
| 89 | + var content = $('.line_schedule .ct_table_wrap'); | ||
| 90 | + //初始化滚动条 | ||
| 91 | + content.perfectScrollbar({suppressScrollX: true}); | ||
| 92 | + //fixed table head | ||
| 93 | + gb_ct_table.fixedHead(content); | ||
| 94 | + //enable sort | ||
| 95 | + gb_ct_table.enableSort($('.ct_table', content), reset_seq_no, gb_schedule_table_dbclick.init); | ||
| 96 | + //dbclick event | ||
| 97 | + gb_schedule_table_dbclick.init(); | ||
| 98 | + //双击实发 | ||
| 99 | + gb_schedule_table_dbclick.sfsjCellClick($('dd.fcsjActualCell')); | ||
| 100 | + //双击车辆 | ||
| 101 | + gb_schedule_table_dbclick.carCellClick($('.ct_table_body dd[data-nbbm]')); | ||
| 102 | + //搜索框初始化 | ||
| 103 | + gb_sch_search.init(); | ||
| 104 | + | ||
| 105 | + //监听gps车辆信息 | ||
| 106 | + gb_data_gps.registerCallback(renderCarRemark); | ||
| 107 | + gb_sch_legend.showYdSdDb(); | ||
| 108 | + cb && cb(); | ||
| 109 | + }); | ||
| 110 | + | ||
| 111 | + }; | ||
| 112 | + | ||
| 113 | + var renderCarRemark = function () { | ||
| 114 | + try{ | ||
| 115 | + var $activeTab = $('.north-tabs>ul>li.tab-line.uk-active');//.data('code'); | ||
| 116 | + if($activeTab.length==0) | ||
| 117 | + return; | ||
| 118 | + var lineCode = $activeTab.data('code'); | ||
| 119 | + var array = gb_common.get_vals(line2Schedule[lineCode]); | ||
| 120 | + var nbbms = {}; | ||
| 121 | + for(var i=0,sch;sch=array[i++];){ | ||
| 122 | + nbbms[sch.clZbh]=1; | ||
| 123 | + } | ||
| 124 | + | ||
| 125 | + var $activeWrap = $('#main-tab-content .line_schedule.uk-active .schedule-wrap .schedule-body'); | ||
| 126 | + var gps, e; | ||
| 127 | + for(var nbbm in nbbms){ | ||
| 128 | + gps = gb_data_gps.findGpsByNbbm(nbbm); | ||
| 129 | + e = $('.ct_table_body dl>dd[data-nbbm='+nbbm+']', $activeWrap); | ||
| 130 | + $('i', e).remove(); | ||
| 131 | + | ||
| 132 | + if(gps && gps['planCode']!=lineCode && gps.remark) | ||
| 133 | + $(e).append('<i class="uk-icon-exclamation-circle" data-uk-tooltip title="'+gps.remark+'"></i>'); | ||
| 134 | + } | ||
| 135 | + }catch (e){ | ||
| 136 | + console.log(e); | ||
| 137 | + } | ||
| 138 | + }; | ||
| 139 | + | ||
| 140 | + /** | ||
| 141 | + * 计算子任务公里是否和计划平 | ||
| 142 | + * @param sch | ||
| 143 | + */ | ||
| 144 | + var calcCTaskMileageStatus = function (sch) { | ||
| 145 | + if(!sch.cTasks || sch.cTasks.length==0) | ||
| 146 | + return 0; | ||
| 147 | + var sum = 0; | ||
| 148 | + $.each(sch.cTasks, function () { | ||
| 149 | + if (this.mileageType == 'service') { | ||
| 150 | + sum = gb_common.accAdd(sum, this.mileage); | ||
| 151 | + } | ||
| 152 | + }); | ||
| 153 | + | ||
| 154 | + if (sum != sch.jhlcOrig) { | ||
| 155 | + return -1; | ||
| 156 | + } | ||
| 157 | + return 0; | ||
| 158 | + }; | ||
| 159 | + | ||
| 160 | + | ||
| 161 | + //重置序号 | ||
| 162 | + var reset_seq_no = function (dls) { | ||
| 163 | + dls.each(function (i, dl) { | ||
| 164 | + $('dd:eq(0)', dl).text(i + 1); | ||
| 165 | + }); | ||
| 166 | + }; | ||
| 167 | + | ||
| 168 | + //计算实发时间差值 | ||
| 169 | + var calc_sch_real_shift = function (sch) { | ||
| 170 | + if (sch['fcsjActualTime']){ | ||
| 171 | + var fs = 'YYYY-MM-DD HH:mm' | ||
| 172 | + ,m1 = moment(sch['fcsjActualTime']).format(fs) | ||
| 173 | + ,m2 = moment(sch['dfsjT']).format(fs);//去掉秒 | ||
| 174 | + console.log(moment(m1, fs).format('X')) | ||
| 175 | + console.log(moment(m2, fs).format('X')) | ||
| 176 | + var diff = moment(m1, fs).format('X') - moment(m2, fs).format('X') | ||
| 177 | + ,fcsj_diff = parseInt(diff / 60, 10);; | ||
| 178 | + | ||
| 179 | + if(fcsj_diff > 0) | ||
| 180 | + sch.fcsj_diff = '( +' + fcsj_diff + ' )'; | ||
| 181 | + else if (fcsj_diff < 0) | ||
| 182 | + sch.fcsj_diff = '( ' + fcsj_diff + ' )'; | ||
| 183 | + else | ||
| 184 | + sch.fcsj_diff = ''; | ||
| 185 | + } | ||
| 186 | + }; | ||
| 187 | + //无发有到时间 | ||
| 188 | + var wfydcolor=function (sch) { | ||
| 189 | + if (sch.fcsjActual==null&&sch.zdsjActual!=null&&sch.zdsjActual!=''&&sch.status!=-1) {//sch.qdzArrDatesj!=''&&sch.qdzArrDatesj!=null&& | ||
| 190 | + sch.status=4; | ||
| 191 | + } | ||
| 192 | + } | ||
| 193 | + | ||
| 194 | + | ||
| 195 | + | ||
| 196 | + function arrayIsNull(array) { | ||
| 197 | + return !array || array.length == 0; | ||
| 198 | + } | ||
| 199 | + | ||
| 200 | + var findScheduleByLine = function (lineCode) { | ||
| 201 | + return line2Schedule[lineCode]; | ||
| 202 | + }; | ||
| 203 | + | ||
| 204 | + //新增一个班次,附带更新的班次 | ||
| 205 | + var insertSchedule = function (sch, upArr) { | ||
| 206 | + var xls = {}; | ||
| 207 | + xls[sch.xlBm] = 1; | ||
| 208 | + line2Schedule[sch.xlBm][sch.id] = sch; | ||
| 209 | + //update | ||
| 210 | + if (isArray(upArr)) { | ||
| 211 | + $.each(upArr, function () { | ||
| 212 | + line2Schedule[this.xlBm][this.id] = this; | ||
| 213 | + xls[this.xlBm] = 1; | ||
| 214 | + }); | ||
| 215 | + } | ||
| 216 | + | ||
| 217 | + //重新渲染表格 | ||
| 218 | + for(var xlBm in xls){ | ||
| 219 | + reRenderTable(sch.xlBm); | ||
| 220 | + } | ||
| 221 | + //定位到新添加的班次 | ||
| 222 | + scroToDl(sch); | ||
| 223 | + }; | ||
| 224 | + | ||
| 225 | + /** | ||
| 226 | + * 重新渲染表格 | ||
| 227 | + */ | ||
| 228 | + var reRenderTable = function (lineCode) { | ||
| 229 | + var data = gb_common.get_vals(line2Schedule[lineCode]).sort(schedule_sort), | ||
| 230 | + dirData = gb_common.groupBy(data, 'xlDir'), | ||
| 231 | + tabCont = $('li.line_schedule[data-id=' + lineCode + ']'), | ||
| 232 | + htmlStr; | ||
| 233 | + | ||
| 234 | + if($.isEmptyObject(dirData)){ | ||
| 235 | + $('.schedule-wrap .card-panel', tabCont).html(''); | ||
| 236 | + } | ||
| 237 | + else { | ||
| 238 | + for (var upDown in dirData) { | ||
| 239 | + htmlStr = temps['line-schedule-table-temp']({ | ||
| 240 | + dir: upDown, | ||
| 241 | + line: gb_data_basic.codeToLine[lineCode], | ||
| 242 | + list: dirData[upDown] | ||
| 243 | + }); | ||
| 244 | + $('.schedule-wrap .card-panel:eq(' + upDown + ')', tabCont).html(htmlStr); | ||
| 245 | + } | ||
| 246 | + //图例相关 | ||
| 247 | + gb_sch_legend.init(tabCont); | ||
| 248 | + //标记末班 | ||
| 249 | + markerLastByLine(lineCode); | ||
| 250 | + //计算应发未发 | ||
| 251 | + calc_yfwf_num(lineCode); | ||
| 252 | + //重新固定表头 | ||
| 253 | + gb_ct_table.fixedHead($('.schedule-wrap .ct_table_wrap', tabCont)); | ||
| 254 | + | ||
| 255 | + //重新初始化排序 | ||
| 256 | + gb_ct_table.enableSort($('.ct_table', tabCont), reset_seq_no, gb_schedule_table_dbclick.init); | ||
| 257 | + //重新初始化双击待发调整 | ||
| 258 | + gb_schedule_table_dbclick.init(); | ||
| 259 | + //重新初始化双击实发发车信息微调 | ||
| 260 | + gb_schedule_table_dbclick.sfsjCellClick($('dd.fcsjActualCell', tabCont)); | ||
| 261 | + //重新初始化双击车辆 | ||
| 262 | + gb_schedule_table_dbclick.carCellClick($('.ct_table_body dd[data-nbbm]')); | ||
| 263 | + //滚动条 | ||
| 264 | + $('.schedule-wrap .ct_table_wrap', tabCont).perfectScrollbar({suppressScrollX: true}); | ||
| 265 | + | ||
| 266 | + //搜索模板初始化 | ||
| 267 | + gb_sch_search.init(); | ||
| 268 | + } | ||
| 269 | + }; | ||
| 270 | + | ||
| 271 | + | ||
| 272 | + /** | ||
| 273 | + * 重新从服务器加载数据,并刷新表格 | ||
| 274 | + * @param lineCode | ||
| 275 | + */ | ||
| 276 | + var reLoadAndRefresh = function (lineCode) { | ||
| 277 | + $.get('/realSchedule/lines', { | ||
| 278 | + lines: lineCode + ',' | ||
| 279 | + }, function (rs) { | ||
| 280 | + if(!rs || $.isEmptyObject(rs)){ | ||
| 281 | + line2Schedule[lineCode] = {}; | ||
| 282 | + } | ||
| 283 | + else{ | ||
| 284 | + //排序 | ||
| 285 | + rs[lineCode].sort(schedule_sort); | ||
| 286 | + line2Schedule[lineCode] = {}; | ||
| 287 | + //calc shift | ||
| 288 | + $.each(rs[lineCode], function () { | ||
| 289 | + calc_sch_real_shift(this); | ||
| 290 | + line2Schedule[lineCode][this.id] = this; | ||
| 291 | + }); | ||
| 292 | + } | ||
| 293 | + //计算应发未发 | ||
| 294 | + calc_yfwf_num(lineCode); | ||
| 295 | + //重新渲染 | ||
| 296 | + reRenderTable(lineCode); | ||
| 297 | + }); | ||
| 298 | + }; | ||
| 299 | + | ||
| 300 | + //删除一个班次 | ||
| 301 | + var deheteSchedule = function (sch) { | ||
| 302 | + sch = line2Schedule[sch.xlBm][sch.id]; | ||
| 303 | + if (sch) { | ||
| 304 | + var dl = $('li.line_schedule[data-id=' + sch.xlBm + '] .ct_table_body dl[data-id=' + sch.id + ']'), | ||
| 305 | + dls = dl.parent().find('dl'); | ||
| 306 | + delete line2Schedule[sch.xlBm][sch.id]; | ||
| 307 | + dl.remove(); | ||
| 308 | + reset_seq_no(dls); | ||
| 309 | + calc_yfwf_num(sch.xlBm); | ||
| 310 | + } | ||
| 311 | + }; | ||
| 312 | + | ||
| 313 | + /** | ||
| 314 | + * 更新班次 | ||
| 315 | + * @param schArr | ||
| 316 | + */ | ||
| 317 | + var updateSchedule = function (schArr) { | ||
| 318 | + | ||
| 319 | + if (!isArray(schArr)) | ||
| 320 | + schArr = [schArr]; | ||
| 321 | + | ||
| 322 | + //var tMaps = {}; | ||
| 323 | + $.each(schArr, function () { | ||
| 324 | + try { | ||
| 325 | + if(this.status==-1) | ||
| 326 | + clearActualTime(this); | ||
| 327 | + //子任务公里是否与计划平 | ||
| 328 | + this.c_t_mileage_status = calcCTaskMileageStatus(this); | ||
| 329 | + line2Schedule[this.xlBm][this.id] = this; | ||
| 330 | + updateDom(this); | ||
| 331 | + }catch(e){} | ||
| 332 | + }); | ||
| 333 | + | ||
| 334 | + /* //重新标记末班 | ||
| 335 | + var ts=[]; | ||
| 336 | + for(var k in tMaps){ | ||
| 337 | + ts = k.split('_'); | ||
| 338 | + markerLastByNbbm(ts[0], ts[1]); | ||
| 339 | + }*/ | ||
| 340 | + }; | ||
| 341 | + | ||
| 342 | + | ||
| 343 | + /** | ||
| 344 | + * 更新班次 -只更新数据,不更新dom | ||
| 345 | + * @param schArr | ||
| 346 | + */ | ||
| 347 | + var updateData = function (schArr) { | ||
| 348 | + if (!isArray(schArr)) | ||
| 349 | + schArr = [schArr]; | ||
| 350 | + $.each(schArr, function () { | ||
| 351 | + if(this.status==-1) | ||
| 352 | + clearActualTime(this); | ||
| 353 | + line2Schedule[this.xlBm][this.id] = this; | ||
| 354 | + }); | ||
| 355 | + }; | ||
| 356 | + | ||
| 357 | + //update dom | ||
| 358 | + var updateDom = function (sch) { | ||
| 359 | + if (!sch) return; | ||
| 360 | + var dl = $('li.line_schedule[data-id=' + sch.xlBm + '] .ct_table_body dl[data-id=' + sch.id + ']'); | ||
| 361 | + var dds = $('dd', dl); | ||
| 362 | + $(dds[1]).find('a').text(sch.lpName); | ||
| 363 | + | ||
| 364 | + $(dds[2]).attr('class', rfidColor(sch)); | ||
| 365 | + | ||
| 366 | + //车辆自编号 | ||
| 367 | + var $newDds3 = $(temps['line-schedule-nbbm-temp'](sch)); | ||
| 368 | + $(dds[3]).replaceWith($newDds3); | ||
| 369 | + //车辆双击 | ||
| 370 | + gb_schedule_table_dbclick.carCellClick($newDds3); | ||
| 371 | + $(dds[4]).text(sch.qdzArrDatejh ? sch.qdzArrDatejh : ''); | ||
| 372 | + $(dds[5]).text(sch.qdzArrDatesj ? sch.qdzArrDatesj : ''); | ||
| 373 | + | ||
| 374 | + //计发时间 | ||
| 375 | + var d5html = temps['line-schedule-fcsj-temp'](sch); | ||
| 376 | + if (sch.lpChange == 1) { | ||
| 377 | + d5html = d5html.replace('</dd>', '') + '<span class="uk-badge uk-badge-success out">换</span>' + '</dd>'; | ||
| 378 | + } | ||
| 379 | + $(dds[6]).replaceWith(d5html); | ||
| 380 | + //待发时间 | ||
| 381 | + var dfHtmlStr = sch.dfsj + (sch.late2?'<span class="late-badge">?+'+sch.lateMinute+'</span>':''); | ||
| 382 | + $(dds[7]).attr('data-sort-val', sch.dfsjT).attr('dbclick-val', sch.dfsj).html(dfHtmlStr); | ||
| 383 | + | ||
| 384 | + //实发时间 | ||
| 385 | + calc_sch_real_shift(sch); | ||
| 386 | + var sfsjDd = $(temps['line-schedule-sfsj-temp'](sch)); | ||
| 387 | + //双击 | ||
| 388 | + gb_schedule_table_dbclick.sfsjCellClick(sfsjDd); | ||
| 389 | + $(dds[8]).replaceWith(sfsjDd); | ||
| 390 | + if (sch.remarks) | ||
| 391 | + $(dds[9]).html('<span title="' + sch.remarks + '" data-uk-tooltip="{pos:\'top-left\'}">' + sch.remarks + '</span>'); | ||
| 392 | + else | ||
| 393 | + $(dds[9]).html(''); | ||
| 394 | + | ||
| 395 | + //信号状态标记 | ||
| 396 | + gb_signal_state.marker_sch(sch); | ||
| 397 | + //班次是车辆的最后一班 | ||
| 398 | + if (dl.hasClass('dl-last-sch')) | ||
| 399 | + markerLastSch([sch]); | ||
| 400 | + | ||
| 401 | + renderCarRemark(); | ||
| 402 | + }; | ||
| 403 | + | ||
| 404 | + //单击实发单元格显示详细信息 | ||
| 405 | + $(document).on('click', 'dd.fcsjActualCell', function () { | ||
| 406 | + var that = this; | ||
| 407 | + $(that).qtip({ | ||
| 408 | + show: true, | ||
| 409 | + content: { | ||
| 410 | + text: function (e) { | ||
| 411 | + var lineCode = $(that).parents('li.line_schedule').data('id') | ||
| 412 | + , id = $(that).parents('dl').data('id') | ||
| 413 | + , sch = line2Schedule[lineCode][id]; | ||
| 414 | + return temps['sfsj_sch-detail-temp'](sch); | ||
| 415 | + } | ||
| 416 | + } | ||
| 417 | + , style: { | ||
| 418 | + classes: 'qtip-dark qtip-rounded qtip-shadow' | ||
| 419 | + }, | ||
| 420 | + hide: { | ||
| 421 | + fixed: true, | ||
| 422 | + delay: 300 | ||
| 423 | + }, | ||
| 424 | + position: { | ||
| 425 | + target: that, | ||
| 426 | + my: 'center left', | ||
| 427 | + at: 'center right' | ||
| 428 | + }, | ||
| 429 | + events: { | ||
| 430 | + hidden: function (event, api) { | ||
| 431 | + $(this).qtip('destroy', true); | ||
| 432 | + } | ||
| 433 | + } | ||
| 434 | + }); | ||
| 435 | + | ||
| 436 | + //车辆rect 闪烁、 | ||
| 437 | + var wrap = $(that).parents('li.line_schedule'); | ||
| 438 | + var nbbm = $(that).parents('dl').find('dd:eq(2)').data('nbbm'); | ||
| 439 | + var device = gb_data_basic.nbbm2deviceMap()[nbbm]; | ||
| 440 | + var $rect = $('svg.line-chart g.gps-wrap rect[_id=rct_' + device + ']', wrap); | ||
| 441 | + | ||
| 442 | + //merge_hide | ||
| 443 | + if ($rect.hasClass('merge_hide') || $rect.attr('y') < 0) | ||
| 444 | + return; | ||
| 445 | + $rect.attr('class', 'twinkle').one('animationend', function () { | ||
| 446 | + $(this).removeAttr('class'); | ||
| 447 | + }); | ||
| 448 | + }); | ||
| 449 | + | ||
| 450 | + //拖拽选中... | ||
| 451 | + var seq_nos = '.line-schedule-table .ct_table_body>dl>dd.seq_no'; | ||
| 452 | + var drag_strat; | ||
| 453 | + $(document).on('mousedown', seq_nos, function (e) { | ||
| 454 | + if (e.button != 0) return; | ||
| 455 | + var dl = $(this).parent(); | ||
| 456 | + if (dl.hasClass('drag-active')) | ||
| 457 | + dl.removeClass('drag-active'); | ||
| 458 | + else | ||
| 459 | + dl.addClass('drag-active'); | ||
| 460 | + | ||
| 461 | + drag_strat = parseInt($(this).text()) - 1; | ||
| 462 | + }).on('mouseup', function () { | ||
| 463 | + drag_strat = null; | ||
| 464 | + }).on('mouseover', seq_nos, function () { | ||
| 465 | + if (drag_strat != null) { | ||
| 466 | + var e = parseInt($(this).text()), | ||
| 467 | + dls = $(this).parents('.ct_table_body').find('dl'); | ||
| 468 | + | ||
| 469 | + reset_drag_active_all(this); | ||
| 470 | + //向上选中 | ||
| 471 | + if (e <= drag_strat) { | ||
| 472 | + for (var i = drag_strat; i > e - 2; i--) | ||
| 473 | + $(dls[i]).addClass('drag-active'); | ||
| 474 | + } | ||
| 475 | + //向下选中 | ||
| 476 | + else { | ||
| 477 | + for (var j = drag_strat; j < e; j++) | ||
| 478 | + $(dls[j]).addClass('drag-active'); | ||
| 479 | + } | ||
| 480 | + } | ||
| 481 | + }).on('click', seq_nos, function () { | ||
| 482 | + reset_relevance_active(this); | ||
| 483 | + }); | ||
| 484 | + //非seq_no 单元格点击 | ||
| 485 | + $(document).on('click', '.line-schedule-table .ct_table_body dl dd[class!=seq_no][class!=lpName]', function () { | ||
| 486 | + reset_drag_active_all(this); | ||
| 487 | + //选中相关班次 | ||
| 488 | + var id = $(this).parent().data('id'), | ||
| 489 | + contWrap = $(this).parents('li.line_schedule'), | ||
| 490 | + lineCode = contWrap.data('id'), | ||
| 491 | + sch = line2Schedule[lineCode][id], | ||
| 492 | + schArr = gb_common.get_vals(line2Schedule[lineCode]).filter(function (item) { | ||
| 493 | + return item.clZbh == sch.clZbh; | ||
| 494 | + }).sort(schedule_sort), | ||
| 495 | + nextSch, tempDL; | ||
| 496 | + | ||
| 497 | + getDl(sch).addClass('intimity'); | ||
| 498 | + $.each(schArr, function (i) { | ||
| 499 | + tempDL = $('dl[data-id=' + this.id + ']', contWrap); | ||
| 500 | + tempDL.addClass('relevance-active'); | ||
| 501 | + if (i < schArr.length - 1 && this.id == id) { | ||
| 502 | + nextSch = schArr[i + 1]; | ||
| 503 | + } | ||
| 504 | + }); | ||
| 505 | + | ||
| 506 | + if (nextSch) { | ||
| 507 | + $('dl[data-id=' + nextSch.id + ']', contWrap).addClass('intimity'); | ||
| 508 | + /*if (nextSch.xlDir == sch.xlDir) | ||
| 509 | + return;*/ | ||
| 510 | + //滚动到下一个班次 | ||
| 511 | + if(nextSch.xlDir != sch.xlDir) | ||
| 512 | + scroToDl(nextSch); | ||
| 513 | + | ||
| 514 | + } | ||
| 515 | + | ||
| 516 | + //如果有打开轨迹回放 | ||
| 517 | + if($('.layui-layer.play_back-layer').is(':visible')){ | ||
| 518 | + gb_map_play_back.setParam(sch); | ||
| 519 | + } | ||
| 520 | + }); | ||
| 521 | + | ||
| 522 | + //路牌点击 | ||
| 523 | + $(document).on('click', '.line-schedule-table .ct_table_body dl dd[class=lpName]', function () { | ||
| 524 | + reset_drag_active_all(this); | ||
| 525 | + //选中路牌下相关班次 | ||
| 526 | + var id = $(this).parent().data('id'), | ||
| 527 | + contWrap = $(this).parents('li.line_schedule'), | ||
| 528 | + lineCode = contWrap.data('id'), | ||
| 529 | + sch = line2Schedule[lineCode][id], | ||
| 530 | + schArr = gb_common.get_vals(line2Schedule[lineCode]).filter(function (item) { | ||
| 531 | + return item.lpName == sch.lpName; | ||
| 532 | + }).sort(schedule_sort); | ||
| 533 | + $.each(schArr, function (i) { | ||
| 534 | + $('dl[data-id=' + this.id + ']', contWrap).addClass('relevance-active intimity'); | ||
| 535 | + }); | ||
| 536 | + | ||
| 537 | + //notify_succ('高亮路牌 ' + sch.lpName); | ||
| 538 | + showLpMileageTip(lineCode, sch.lpName, schArr); | ||
| 539 | + }); | ||
| 540 | + | ||
| 541 | + var showLpMileageTipBySch = function (sch) { | ||
| 542 | + if(!$('.mileage_elec_panel', $('.line_schedule[data-id='+sch.xlBm+']')).is(':visible')) | ||
| 543 | + return; | ||
| 544 | + | ||
| 545 | + var schArr = gb_common.get_vals(line2Schedule[sch.xlBm]).filter(function (item) { | ||
| 546 | + return item.lpName == sch.lpName; | ||
| 547 | + }).sort(schedule_sort); | ||
| 548 | + | ||
| 549 | + showLpMileageTip(sch.xlBm, sch.lpName, schArr); | ||
| 550 | + }; | ||
| 551 | + /** | ||
| 552 | + * 弹出路牌公里统计tip | ||
| 553 | + * @param lineCode | ||
| 554 | + * @param lpName | ||
| 555 | + * @param array | ||
| 556 | + */ | ||
| 557 | + var showLpMileageTip = function (lineCode, lpName, array) { | ||
| 558 | + var wrap = $('.line_schedule[data-id='+lineCode+']'); | ||
| 559 | + //按驾驶员&车辆分组统计 | ||
| 560 | + var data=mileageTipGroupData(array); | ||
| 561 | + //统计公里 | ||
| 562 | + var list=[]; | ||
| 563 | + for(var key in data){ | ||
| 564 | + list.push({ | ||
| 565 | + key : key, | ||
| 566 | + serviceMileage: gb_sch_mileage_count.serviceMileage(data[key]), | ||
| 567 | + destroyMileage: gb_sch_mileage_count.destroyMileage(data[key]), | ||
| 568 | + emptyMileage: gb_sch_mileage_count.emptyMileage(data[key]) | ||
| 569 | + }) | ||
| 570 | + } | ||
| 571 | + var htmlStr = temps['sch-lp-mileage-tip-temp']({data: list, lpName:lpName}); | ||
| 572 | + $('.mileage_elec_panel', wrap).html(htmlStr).addClass('uk-animation-slide-bottom').show() | ||
| 573 | + .one('animationEnd', function () { | ||
| 574 | + $(this).removeClass('uk-animation-slide-bottom'); | ||
| 575 | + }); | ||
| 576 | + }; | ||
| 577 | + | ||
| 578 | + /** | ||
| 579 | + * 分组数据,处理子任务里的中途换车 | ||
| 580 | + * @param array | ||
| 581 | + */ | ||
| 582 | + var mileageTipGroupData = function (arr) { | ||
| 583 | + var list = JSON.parse(JSON.stringify(arr)); | ||
| 584 | + var cts; | ||
| 585 | + var zthcArray=[]; | ||
| 586 | + var sch; | ||
| 587 | + for(var i=0,len=list.length;i<len;i++){ | ||
| 588 | + sch = list[i]; | ||
| 589 | + cts = sch['cTasks']; | ||
| 590 | + if(!cts || cts.length==0) | ||
| 591 | + continue; | ||
| 592 | + | ||
| 593 | + sch['cTasks'] = []; | ||
| 594 | + //有子任务 | ||
| 595 | + for(var j=0,ct;ct=cts[j++];){ | ||
| 596 | + if(!ct.nbbm || ct.nbbm==sch.clZbh){ | ||
| 597 | + sch['cTasks'].push(ct); | ||
| 598 | + continue; | ||
| 599 | + } | ||
| 600 | + | ||
| 601 | + zthcArray.push(cloneByCTask(sch, ct)); | ||
| 602 | + } | ||
| 603 | + } | ||
| 604 | + | ||
| 605 | + if(zthcArray.length > 0) | ||
| 606 | + list = list.concat(zthcArray); | ||
| 607 | + | ||
| 608 | + var data={},key; | ||
| 609 | + for(var i=0,len=list.length;i<len;i++){ | ||
| 610 | + key = list[i].clZbh+'/'+list[i].jGh+'('+list[i].jName+')'; | ||
| 611 | + if(!data[key]) | ||
| 612 | + data[key] = []; | ||
| 613 | + data[key].push(list[i]); | ||
| 614 | + } | ||
| 615 | + return data; | ||
| 616 | + }; | ||
| 617 | + | ||
| 618 | + var cloneByCTask = function (sch, ct) { | ||
| 619 | + var newObj = JSON.parse(JSON.stringify(sch)); | ||
| 620 | + newObj['cTasks']=[]; | ||
| 621 | + newObj.clZbh = ct.nbbm; | ||
| 622 | + newObj.fcsjActual = ct.startDate; | ||
| 623 | + newObj.zdsjActual = ct.endDate; | ||
| 624 | + newObj.jhlc = ct.mileage; | ||
| 625 | + newObj.jhlcOrig = ct.mileage; | ||
| 626 | + | ||
| 627 | + if(ct.type2=='1') | ||
| 628 | + newObj.bcType='normal'; | ||
| 629 | + else if(ct.type2=='2'){ | ||
| 630 | + newObj.bcType='in'; | ||
| 631 | + }else if(ct.type2=='3') | ||
| 632 | + newObj.bcType='out'; | ||
| 633 | + | ||
| 634 | + return newObj; | ||
| 635 | + }; | ||
| 636 | + | ||
| 637 | + //头部点击去掉选中光标 | ||
| 638 | + $(document).on('click', '.header-title', function () { | ||
| 639 | + reset_drag_active_all(this); | ||
| 640 | + }); | ||
| 641 | + | ||
| 642 | + var scroToDl = function (sch) { | ||
| 643 | + var dl = getDl(sch), | ||
| 644 | + cont = dl.parents('.ct_table_wrap'), | ||
| 645 | + diff = cont.height() / 2; | ||
| 646 | + cont.animate({ | ||
| 647 | + scrollTop: dl.offset().top - cont.offset().top + cont.scrollTop() - diff | ||
| 648 | + }, 500); | ||
| 649 | + | ||
| 650 | + return dl; | ||
| 651 | + }; | ||
| 652 | + | ||
| 653 | + var getDl = function (sch) { | ||
| 654 | + return $('dl[data-id=' + sch.id + ']', $('.line_schedule[data-id=' + sch.xlBm + ']')); | ||
| 655 | + }; | ||
| 656 | + | ||
| 657 | + var reset_drag_active_all = function (dd) { | ||
| 658 | + $(dd).parents('.schedule-wrap').find('dl.drag-active').removeClass('drag-active'); | ||
| 659 | + reset_relevance_active(dd); | ||
| 660 | + | ||
| 661 | + $('.mileage_elec_panel', $(dd).parents('.top-container')).hide().remove('uk-animation-slide-bottom'); | ||
| 662 | + }; | ||
| 663 | + | ||
| 664 | + var reset_relevance_active = function (dd) { | ||
| 665 | + $(dd).parents('.uk-grid.schedule-wrap').find('.relevance-active').removeClass('relevance-active intimity'); | ||
| 666 | + }; | ||
| 667 | + | ||
| 668 | + | ||
| 669 | + //计算应发未发数量 car_yfwf_map | ||
| 670 | + var calc_yfwf_num = function (lineCode) { | ||
| 671 | + | ||
| 672 | + var schArr = gb_common.get_vals(line2Schedule[lineCode]).sort(schedule_sort), | ||
| 673 | + yfwf_num = 0, | ||
| 674 | + t = new Date().valueOf(); | ||
| 675 | + | ||
| 676 | + var carYfwfMap = {}, nbbm; | ||
| 677 | + $.each(schArr, function () { | ||
| 678 | + /*if (this.dfsjT > t) | ||
| 679 | + return false;*/ | ||
| 680 | + | ||
| 681 | + if (this.dfsjT < t && | ||
| 682 | + this.fcsjActual == null && this.fcsjActualTime == null && this.status != -1) { | ||
| 683 | + yfwf_num++; | ||
| 684 | + nbbm = this.clZbh; | ||
| 685 | + if (carYfwfMap[nbbm]) | ||
| 686 | + carYfwfMap[nbbm]++; | ||
| 687 | + else | ||
| 688 | + carYfwfMap[nbbm] = 1; | ||
| 689 | + } | ||
| 690 | + }); | ||
| 691 | + car_yfwf_map[lineCode] = carYfwfMap; | ||
| 692 | + | ||
| 693 | + $('#badge_yfwf_num_' + lineCode).text(yfwf_num); | ||
| 694 | + }; | ||
| 695 | + | ||
| 696 | + //标记终点时间 -线路 | ||
| 697 | + var markerLastByLine = function (lineCode) { | ||
| 698 | + var data = gb_common.groupBy(gb_common.get_vals(line2Schedule[lineCode]).filter(schDestroyFilter), 'lpName'); | ||
| 699 | + | ||
| 700 | + var array, lastSch, dl; | ||
| 701 | + for (var nbbm in data) { | ||
| 702 | + array = data[nbbm].sort(schedule_sort); | ||
| 703 | + markerLastSch(array); | ||
| 704 | + } | ||
| 705 | + }; | ||
| 706 | + | ||
| 707 | + //标记终点时间 -车辆 | ||
| 708 | + var markerLastByNbbm = function (lineCode, nbbm) { | ||
| 709 | + var array = gb_common.get_vals(line2Schedule[lineCode]).filter(function (a) { | ||
| 710 | + return a.clZbh == nbbm && a.status != -1; | ||
| 711 | + }).sort(schedule_sort); | ||
| 712 | + | ||
| 713 | + removeMarkers(lineCode, array); | ||
| 714 | + markerLastSch(array); | ||
| 715 | + }; | ||
| 716 | + | ||
| 717 | + var markerLastSch = function (array) { | ||
| 718 | + var lastSch = array[array.length - 1]; | ||
| 719 | + | ||
| 720 | + if (!lastSch.jhlc) | ||
| 721 | + return; | ||
| 722 | + | ||
| 723 | + var dl = getDl(lastSch); | ||
| 724 | + dl.addClass('dl-last-sch'); | ||
| 725 | + | ||
| 726 | + $('dd.fcsjActualCell', dl).append(temps['last-sch-sunken-temp'](lastSch)); | ||
| 727 | + }; | ||
| 728 | + | ||
| 729 | + //清除线路下指定班次的 末班标记 | ||
| 730 | + var removeMarkers = function (lineCode, array) { | ||
| 731 | + var idx = []; | ||
| 732 | + $.each(array, function () { | ||
| 733 | + idx.push(this.id); | ||
| 734 | + }); | ||
| 735 | + | ||
| 736 | + $('dl.dl-last-sch', 'li.line_schedule[data-id=' + lineCode + ']').each(function () { | ||
| 737 | + if ($(this).hasClass('dl-last-sch') && idx.indexOf($(this).data('id'))) { | ||
| 738 | + $(this).removeClass('dl-last-sch').find('.last-sch-sunken').remove(); | ||
| 739 | + } | ||
| 740 | + }); | ||
| 741 | + }; | ||
| 742 | + | ||
| 743 | + var schDestroyFilter = function (a) { | ||
| 744 | + return a.status != -1; | ||
| 745 | + }; | ||
| 746 | + | ||
| 747 | + /* 下一个班次 */ | ||
| 748 | + var getNextSch = function (sch) { | ||
| 749 | + var array = gb_common.get_vals(line2Schedule[sch.xlBm]).filter(function (a) { | ||
| 750 | + return a.clZbh == sch.clZbh; | ||
| 751 | + }).sort(schedule_sort); | ||
| 752 | + | ||
| 753 | + for (var i = 0, item; item = array[i++];) { | ||
| 754 | + if (array[i].id == sch.id) { | ||
| 755 | + return i < array.length ? array[i + 1] : null; | ||
| 756 | + } | ||
| 757 | + } | ||
| 758 | + }; | ||
| 759 | + | ||
| 760 | + /* 下一个班次普通班次 */ | ||
| 761 | + var getNextNormalSch = function (sch) { | ||
| 762 | + | ||
| 763 | + var array = gb_common.get_vals(line2Schedule[sch.xlBm]).filter(function (a) { | ||
| 764 | + return a.clZbh == sch.clZbh && a.bcType=='normal'; | ||
| 765 | + }).sort(schedule_sort); | ||
| 766 | + | ||
| 767 | + for (var i = 0; i < array.length; i++) { | ||
| 768 | + if (array[i].id == sch.id) { | ||
| 769 | + return i < array.length ? array[i + 1] : null; | ||
| 770 | + } | ||
| 771 | + } | ||
| 772 | + }; | ||
| 773 | + | ||
| 774 | + /** 添加备注信息 */ | ||
| 775 | + var addRemarks = function (list, remarks) { | ||
| 776 | + //if(!list || list) | ||
| 777 | + var i = 0, sch; | ||
| 778 | + | ||
| 779 | + (function () { | ||
| 780 | + var f = arguments.callee; | ||
| 781 | + if(i >= list.length){ | ||
| 782 | + return; | ||
| 783 | + } | ||
| 784 | + sch = list[i]; | ||
| 785 | + gb_common.$post('/realSchedule/addRemarks', {id: sch.id, remarks: remarks}, function (rs) { | ||
| 786 | + if(rs.t){ | ||
| 787 | + sch = rs.t; | ||
| 788 | + line2Schedule[sch.xlBm][sch.id] = sch; | ||
| 789 | + updateDom(sch); | ||
| 790 | + i++; | ||
| 791 | + f(); | ||
| 792 | + } | ||
| 793 | + }); | ||
| 794 | + })(); | ||
| 795 | + }; | ||
| 796 | + | ||
| 797 | + /** | ||
| 798 | + * 显示误点停靠时间标记 | ||
| 799 | + * @param id | ||
| 800 | + * @param minute | ||
| 801 | + */ | ||
| 802 | + var showLateBadge = function (lineCode, id, minute) { | ||
| 803 | + var dfCell = cancelLateBadge(lineCode, id); | ||
| 804 | + $(dfCell).append('<span class="late-badge">?+'+minute+'</span>'); | ||
| 805 | + }; | ||
| 806 | + | ||
| 807 | + /** | ||
| 808 | + * 取消误点标记 | ||
| 809 | + * @param lineCode | ||
| 810 | + * @param id | ||
| 811 | + */ | ||
| 812 | + var cancelLateBadge = function (lineCode, id) { | ||
| 813 | + var $dl = getDl({id: id, xlBm: lineCode}); | ||
| 814 | + var dfCell = $dl.find('dd')[6]; | ||
| 815 | + $('.late-badge',dfCell).remove(); | ||
| 816 | + return dfCell; | ||
| 817 | + }; | ||
| 818 | + | ||
| 819 | + | ||
| 820 | + /** | ||
| 821 | + * 刷新页面的所有线路班次 | ||
| 822 | + */ | ||
| 823 | + var refreshAll = function () { | ||
| 824 | + show(); | ||
| 825 | + }; | ||
| 826 | + | ||
| 827 | + /** | ||
| 828 | + * 获取线路下营运的车辆 | ||
| 829 | + */ | ||
| 830 | + var findNbbmByLineCode = function (lineCode) { | ||
| 831 | + try{ | ||
| 832 | + return gb_common.get_keys(gb_common.extractNbbm(gb_common.get_vals(line2Schedule[lineCode]))); | ||
| 833 | + }catch (e){ | ||
| 834 | + return []; | ||
| 835 | + } | ||
| 836 | + }; | ||
| 837 | + | ||
| 838 | + var clearActualTime = function (sch) { | ||
| 839 | + try{ | ||
| 840 | + sch.fcsjActual=null; | ||
| 841 | + sch.fcsjActualTime=null; | ||
| 842 | + sch.zdsjActual=null; | ||
| 843 | + sch.zdsjActualTime=null; | ||
| 844 | + }catch (e){ | ||
| 845 | + console.log(e); | ||
| 846 | + } | ||
| 847 | + }; | ||
| 848 | + | ||
| 849 | + /** | ||
| 850 | + * 班次站点编码异常信息 | ||
| 851 | + * @param list | ||
| 852 | + */ | ||
| 853 | + var putSCodeErrorInfo = function (list) { | ||
| 854 | + //按线路走向分组 | ||
| 855 | + var data = {}; | ||
| 856 | + var k; | ||
| 857 | + for(var i=0,obj;obj=list[i++];){ | ||
| 858 | + k = obj.lineCode+'_'+obj.upDown; | ||
| 859 | + | ||
| 860 | + if(obj.realStationCode && obj.realStationCode.indexOf('^') != -1) | ||
| 861 | + obj.realStationCode = obj.realStationCode.split('^')[0]; | ||
| 862 | + | ||
| 863 | + if(!data[k]) | ||
| 864 | + data[k] = []; | ||
| 865 | + data[k].push(obj); | ||
| 866 | + } | ||
| 867 | + | ||
| 868 | + var wrap; | ||
| 869 | + for(var k in data){ | ||
| 870 | + wrap = $('.line_schedule[data-id=' + (k.split('_')[0]) + ']'); | ||
| 871 | + if(wrap.length==0) | ||
| 872 | + continue; | ||
| 873 | + | ||
| 874 | + $(".schedule-wrap span.warn_multi_station[data-updown="+(k.split('_')[1])+"]", wrap) | ||
| 875 | + .html('o(* ̄▽ ̄*)o 班次和站点关联有点问题!!').show(); | ||
| 876 | + } | ||
| 877 | + | ||
| 878 | + errorCodeData = data; | ||
| 879 | + }; | ||
| 880 | + | ||
| 881 | + var findSCodeErrorInfo = function (lineCode, upDown) { | ||
| 882 | + return errorCodeData[lineCode+'_'+upDown]; | ||
| 883 | + }; | ||
| 884 | + | ||
| 885 | + var refreshRfid = function (sch) { | ||
| 886 | + var $dl = getDl({id: sch.id, xlBm: sch.xlBm}); | ||
| 887 | + var dfCell = $dl.find('dd')[2]; | ||
| 888 | + | ||
| 889 | + $(dfCell).attr('class', rfidColor(sch)); | ||
| 890 | + }; | ||
| 891 | + | ||
| 892 | + var rfidColor = function(sch) { | ||
| 893 | + var left = !sch.qdzArrDatesj ? 'tl-white' : 'tl-grey', right = !sch.qdzArrDatesj ? '-white' : '-grey'; | ||
| 894 | + if ((sch.firstFfidState & 2) == 2) { | ||
| 895 | + left = 'tl-yellow'; | ||
| 896 | + if ((sch.firstFfidState & 4) == 4) { | ||
| 897 | + left = 'tl-green'; | ||
| 898 | + } | ||
| 899 | + } | ||
| 900 | + if ((sch.rfidState & 2) == 2) { | ||
| 901 | + right = '-yellow'; | ||
| 902 | + if ((sch.rfidState & 4) == 4) { | ||
| 903 | + right = '-green'; | ||
| 904 | + } | ||
| 905 | + } | ||
| 906 | + | ||
| 907 | + return left + right; | ||
| 908 | + } | ||
| 909 | + | ||
| 910 | + return { | ||
| 911 | + show: show, | ||
| 912 | + findScheduleByLine: findScheduleByLine, | ||
| 913 | + updateSchedule: updateSchedule, | ||
| 914 | + updateData: updateData, | ||
| 915 | + deheteSchedule: deheteSchedule, | ||
| 916 | + insertSchedule: insertSchedule, | ||
| 917 | + schedule_sort: schedule_sort, | ||
| 918 | + calc_yfwf_num: calc_yfwf_num, | ||
| 919 | + car_yfwf_map: function (lineCode) { | ||
| 920 | + return car_yfwf_map[lineCode]; | ||
| 921 | + }, | ||
| 922 | + scroToDl: scroToDl, | ||
| 923 | + reset_drag_active_all: reset_drag_active_all, | ||
| 924 | + getDl: getDl, | ||
| 925 | + getNextSch: getNextSch, | ||
| 926 | + addRemarks: addRemarks, | ||
| 927 | + reLoadAndRefresh: reLoadAndRefresh, | ||
| 928 | + showLateBadge: showLateBadge, | ||
| 929 | + cancelLateBadge: cancelLateBadge, | ||
| 930 | + refreshAll: refreshAll, | ||
| 931 | + getNextNormalSch: getNextNormalSch, | ||
| 932 | + findNbbmByLineCode:findNbbmByLineCode, | ||
| 933 | + showLpMileageTipBySch: showLpMileageTipBySch, | ||
| 934 | + renderCarRemark: renderCarRemark, | ||
| 935 | + putSCodeErrorInfo: putSCodeErrorInfo, | ||
| 936 | + findSCodeErrorInfo: findSCodeErrorInfo, | ||
| 937 | + refreshRfid: refreshRfid | ||
| 938 | + }; | ||
| 939 | +})(); |
src/main/resources/static/real_control_v2/js/line_schedule/search.js
| 1 | -/** 班次搜索 */ | ||
| 2 | -var gb_sch_search = (function() { | ||
| 3 | - | ||
| 4 | - //搜索结果模板,和art-template冲突。 用字符串渲染 | ||
| 5 | - var result_template = '<script type="text/autocomplete">' + | ||
| 6 | - ' <ul class="uk-nav uk-nav-autocomplete uk-autocomplete-results sch-search-results">' + | ||
| 7 | - ' {{~items}}' + | ||
| 8 | - ' <li data-value="{{ $item.value }}">' + | ||
| 9 | - ' <a>' + | ||
| 10 | - ' {{ $item.text }}' + | ||
| 11 | - ' <small >{{$item.exec}}</small>' + | ||
| 12 | - ' <small class="search-result-desc">{{{ $item.desc }}}</small>' + | ||
| 13 | - ' </a>' + | ||
| 14 | - ' </li>' + | ||
| 15 | - ' {{/items}}' + | ||
| 16 | - ' </ul>' + | ||
| 17 | - '</script>'; | ||
| 18 | - | ||
| 19 | - var ips = '.search_sch_panel input', | ||
| 20 | - _input, schArr, lineCode, group_cars, lp_pinyins, jsy_pinyins, searchType; | ||
| 21 | - $(document) | ||
| 22 | - .on('focus', ips, function() { | ||
| 23 | - $(this).parent().addClass('active'); | ||
| 24 | - lineCode = $(this).parents('li.line_schedule').data('id'); | ||
| 25 | - schArr = gb_common.get_vals(gb_schedule_table.findScheduleByLine(lineCode)); | ||
| 26 | - | ||
| 27 | - group_cars = gb_common.groupBy(schArr, 'clZbh'); | ||
| 28 | - var group_lp = gb_common.extractLpName(schArr); | ||
| 29 | - //路牌对照 | ||
| 30 | - lp_pinyins = []; | ||
| 31 | - for(var lp in group_lp){ | ||
| 32 | - lp_pinyins.push({ | ||
| 33 | - fullChars: pinyin.getFullChars(lp).toUpperCase(), | ||
| 34 | - camelChars: pinyin.getCamelChars(lp), | ||
| 35 | - lp: lp | ||
| 36 | - }); | ||
| 37 | - } | ||
| 38 | - //驾驶员对照 | ||
| 39 | - /* var group_jsy = gb_common.extractJsy(schArr); | ||
| 40 | - jsy_pinyins = []; | ||
| 41 | - for(var jsy in group_jsy){ | ||
| 42 | - jsy_pinyins.push({ | ||
| 43 | - fullChars: pinyin.getFullChars(jsy).toUpperCase(), | ||
| 44 | - camelChars: pinyin.getCamelChars(jsy), | ||
| 45 | - val: jsy | ||
| 46 | - }); | ||
| 47 | - }*/ | ||
| 48 | - _input = $(this); | ||
| 49 | - }) | ||
| 50 | - .on('blur', ips, function() { | ||
| 51 | - if ($(this).val() == ''){ | ||
| 52 | - reset_all($(this).parents('li.line_schedule')); | ||
| 53 | - } | ||
| 54 | - }); | ||
| 55 | - | ||
| 56 | - $(document).on('click', '.search_sch_panel i.cancel', function(){ | ||
| 57 | - reset_all($(this).parents('li.line_schedule')); | ||
| 58 | - }); | ||
| 59 | - | ||
| 60 | - var elements = '.search_sch_panel .sch-search-autocom'; | ||
| 61 | - var init = function() { | ||
| 62 | - $(elements).each(function() { | ||
| 63 | - if($('script[type="text/autocomplete"]', this).length > 0) | ||
| 64 | - return true; | ||
| 65 | - | ||
| 66 | - $(this).append(result_template); | ||
| 67 | - constructor(this); | ||
| 68 | - }); | ||
| 69 | - }; | ||
| 70 | - | ||
| 71 | - var constructor = function(e) { | ||
| 72 | - UIkit.autocomplete(e, { | ||
| 73 | - minLength: 1, | ||
| 74 | - delay: 10, | ||
| 75 | - source: autocomplete_source | ||
| 76 | - }).on('selectitem.uk.autocomplete', selectitem); | ||
| 77 | - } | ||
| 78 | - | ||
| 79 | - /** | ||
| 80 | - * 车辆搜索函数 | ||
| 81 | - * @param v | ||
| 82 | - * @param release | ||
| 83 | - */ | ||
| 84 | - var searchCar = function (v, release) { | ||
| 85 | - var rs = [], gps; | ||
| 86 | - //应发未发数据 | ||
| 87 | - var yfwf_map = gb_schedule_table.car_yfwf_map(lineCode); | ||
| 88 | - for (var car in group_cars) { | ||
| 89 | - if (car.indexOf(v) != -1) { | ||
| 90 | - //车辆对应的gps | ||
| 91 | - gps = gb_data_gps.findGpsByNbbm(car) | ||
| 92 | - rs.push({ | ||
| 93 | - text: car, | ||
| 94 | - value: car, | ||
| 95 | - desc: '应发未发:' + (yfwf_map[car] == null ? 0 : yfwf_map[car]), | ||
| 96 | - exec: execSch(gps) | ||
| 97 | - }); | ||
| 98 | - } | ||
| 99 | - } | ||
| 100 | - | ||
| 101 | - searchType = 'car'; | ||
| 102 | - release && release(rs); | ||
| 103 | - } | ||
| 104 | - | ||
| 105 | - /** | ||
| 106 | - * 路牌搜索函数 | ||
| 107 | - * @param v | ||
| 108 | - * @param release | ||
| 109 | - */ | ||
| 110 | - var searchLp = function (v, release) { | ||
| 111 | - var rs = []; | ||
| 112 | - v = v.split('LP')[1]; | ||
| 113 | - | ||
| 114 | - $.each(lp_pinyins, function () { | ||
| 115 | - if(this.lp.indexOf(v) != -1 || this.fullChars.indexOf(v) != -1 || this.camelChars.indexOf(v) != -1){ | ||
| 116 | - rs.push({ | ||
| 117 | - text: this.lp, | ||
| 118 | - value: 'lp' + this.lp, | ||
| 119 | - desc: '', | ||
| 120 | - exec: '路牌' | ||
| 121 | - }); | ||
| 122 | - } | ||
| 123 | - }); | ||
| 124 | - searchType = 'lp'; | ||
| 125 | - release && release(rs); | ||
| 126 | - } | ||
| 127 | - | ||
| 128 | - /** | ||
| 129 | - * 按时间范围搜索 | ||
| 130 | - */ | ||
| 131 | - var dt = 1000 * 60 * 60 * 24; | ||
| 132 | - var gbRange = {}; | ||
| 133 | - var searchTimeRange = function (v, release) { | ||
| 134 | - var sm, em, text,value, fs = 'HH:mm',fs2='HHmm'; | ||
| 135 | - var start = v.indexOf('ST')==0; | ||
| 136 | - var ei = v.indexOf('ET'); | ||
| 137 | - var end = ei!=-1 && v.length > ei + 2; | ||
| 138 | - | ||
| 139 | - if(start && !end){ | ||
| 140 | - sm = strToTime(v.substr(2)); | ||
| 141 | - text = '搜索' + sm.format(fs) + '之后的班次'; | ||
| 142 | - value = 'st' + sm.format(fs2); | ||
| 143 | - } | ||
| 144 | - else if(!start && end){ | ||
| 145 | - em = strToTime(v.substr(2)); | ||
| 146 | - text = '搜索' + em.format(fs) + '之前的班次'; | ||
| 147 | - value = 'et' + em.format(fs2); | ||
| 148 | - } | ||
| 149 | - else if(start && end){ | ||
| 150 | - sm = strToTime(v.substring(2, ei)); | ||
| 151 | - em = strToTime(v.substr(ei + 2)); | ||
| 152 | - text = '搜索' + sm.format(fs) + ' 至 ' + em.format(fs) + '之间的班次'; | ||
| 153 | - value = 'st' + sm.format(fs2) + 'et' + em.format(fs2); | ||
| 154 | - } | ||
| 155 | - | ||
| 156 | - var threeBefore = moment().format('HH') < '02'; | ||
| 157 | - | ||
| 158 | - if(sm) { | ||
| 159 | - gbRange.st = sm.format('x'); | ||
| 160 | - if (threeBefore) | ||
| 161 | - gbRange.st -= dt; | ||
| 162 | - } | ||
| 163 | - if(em){ | ||
| 164 | - gbRange.et = em.format('x'); | ||
| 165 | - if (threeBefore) | ||
| 166 | - gbRange.et -= dt; | ||
| 167 | - } | ||
| 168 | - searchType = 'timeRange'; | ||
| 169 | - release && release([{ | ||
| 170 | - text: text, | ||
| 171 | - value: value, | ||
| 172 | - desc: '', | ||
| 173 | - exec: '' | ||
| 174 | - }]); | ||
| 175 | - } | ||
| 176 | - | ||
| 177 | - /** | ||
| 178 | - * 按驾驶员搜索 | ||
| 179 | - | ||
| 180 | - var searchJsy = function (v, release) { | ||
| 181 | - var rs = []; | ||
| 182 | - v = v.split('JSY')[1]; | ||
| 183 | - | ||
| 184 | - $.each(jsy_pinyins, function () { | ||
| 185 | - if(this.val.indexOf(v) != -1 || this.fullChars.indexOf(v) != -1 || this.camelChars.indexOf(v) != -1){ | ||
| 186 | - rs.push({ | ||
| 187 | - text: this.val, | ||
| 188 | - value: 'jsy' + this.val, | ||
| 189 | - desc: '', | ||
| 190 | - exec: '驾驶员' | ||
| 191 | - }); | ||
| 192 | - } | ||
| 193 | - }); | ||
| 194 | - searchType = 'jsy'; | ||
| 195 | - release && release(rs); | ||
| 196 | - }*/ | ||
| 197 | - | ||
| 198 | - var defaultHandler = searchCar; | ||
| 199 | - var searchHandlerMapp = {'LP': searchLp/*,'JSY': searchJsy*/, 'ST': searchTimeRange, 'ET': searchTimeRange}; | ||
| 200 | - var autocomplete_source = function(release) { | ||
| 201 | - var v = _input.val().toUpperCase(); | ||
| 202 | - | ||
| 203 | - for(var k in searchHandlerMapp){ | ||
| 204 | - if(v.indexOf(k) == 0 && v!=k){ | ||
| 205 | - searchHandlerMapp[k](v, release); | ||
| 206 | - return; | ||
| 207 | - } | ||
| 208 | - } | ||
| 209 | - //搜索车辆 | ||
| 210 | - searchCar(v, release); | ||
| 211 | - } | ||
| 212 | - | ||
| 213 | - var reset_all = function(cont) { | ||
| 214 | - //var cont = 'li.line_schedule[data-id=' + lineCode + ']'; | ||
| 215 | - //uikit 会记住上一次搜索值,触发keyup以清空该值 | ||
| 216 | - $('.sch-search-autocom input', cont).val('').trigger('keyup').parent().removeClass('active'); | ||
| 217 | - $('.line-schedule-table .ct_table_body', cont).removeClass('search_result_body').find('dl._search_hide').removeClass('_search_hide'); | ||
| 218 | - //更新滚动条高度 | ||
| 219 | - $('.ct_table_wrap', cont).perfectScrollbar('update'); | ||
| 220 | - } | ||
| 221 | - | ||
| 222 | - function execSch(gps) { | ||
| 223 | - if (gps && gps.schId) { | ||
| 224 | - var sch = gb_schedule_table.findScheduleByLine(gps.lineId)[gps.schId]; | ||
| 225 | - if (sch) | ||
| 226 | - return '(执行' + (sch.xlDir == 0 ? '上行' : '下行') + sch.dfsj + ')'; | ||
| 227 | - } | ||
| 228 | - return ''; | ||
| 229 | - } | ||
| 230 | - | ||
| 231 | - var selectitem = function(event, data, acobject) { | ||
| 232 | - var cont = 'li.line_schedule[data-id=' + lineCode + ']', | ||
| 233 | - tbodys = $('.line-schedule-table .ct_table_body', cont); | ||
| 234 | - | ||
| 235 | - tbodys.addClass('search_result_body'); | ||
| 236 | - $('.sch-search-autocom input', cont).val(data.value).parent().addClass('active'); | ||
| 237 | - | ||
| 238 | - var v = splitVal(data.value, searchType); | ||
| 239 | - $.each(tbodys, function() { | ||
| 240 | - if(searchType=='car') | ||
| 241 | - filterScheduleByNbbm(this, v); | ||
| 242 | - if(searchType=='lp') | ||
| 243 | - filterScheduleByLpName(this, v); | ||
| 244 | - if(searchType=='timeRange') | ||
| 245 | - filterScheduleByTimeRange(this); | ||
| 246 | - /*if(searchType=='jsy') | ||
| 247 | - filterScheduleByJsy(this, v);*/ | ||
| 248 | - }); | ||
| 249 | - gbRange = {}; | ||
| 250 | - } | ||
| 251 | - | ||
| 252 | - /** | ||
| 253 | - * 根据车辆过滤表格 | ||
| 254 | - * @param tbody | ||
| 255 | - * @param car | ||
| 256 | - */ | ||
| 257 | - var filterScheduleByNbbm = function(tbody, car) { | ||
| 258 | - var dls = $('dl', tbody), | ||
| 259 | - dds; | ||
| 260 | - dls.removeClass('_search_hide'); | ||
| 261 | - $.each(dls, function() { | ||
| 262 | - dds = $('dd', this); | ||
| 263 | - if (car != $(dds[2]).data('nbbm')) | ||
| 264 | - $(this).addClass('_search_hide'); | ||
| 265 | - }); | ||
| 266 | - | ||
| 267 | - //滚动条置顶 | ||
| 268 | - $(tbody).parents('.ct_table_wrap')[0].scrollTop = 0; | ||
| 269 | - } | ||
| 270 | - | ||
| 271 | - /** | ||
| 272 | - * 根据路牌过滤表格 | ||
| 273 | - * @param tbody | ||
| 274 | - * @param lpName | ||
| 275 | - */ | ||
| 276 | - var filterScheduleByLpName = function (tbody, lpName) { | ||
| 277 | - var dls = $('dl', tbody), | ||
| 278 | - dds; | ||
| 279 | - dls.removeClass('_search_hide'); | ||
| 280 | - $.each(dls, function() { | ||
| 281 | - dds = $('dd', this); | ||
| 282 | - if (lpName != $('a', dds[1]).text()) | ||
| 283 | - $(this).addClass('_search_hide'); | ||
| 284 | - }); | ||
| 285 | - | ||
| 286 | - //滚动条置顶 | ||
| 287 | - $(tbody).parents('.ct_table_wrap')[0].scrollTop = 0; | ||
| 288 | - } | ||
| 289 | - | ||
| 290 | - /** | ||
| 291 | - * 根据时间范围过滤表格 | ||
| 292 | - * @param tbody | ||
| 293 | - */ | ||
| 294 | - var filterScheduleByTimeRange = function (tbody) { | ||
| 295 | - var dls = $('dl', tbody), | ||
| 296 | - dds; | ||
| 297 | - dls.removeClass('_search_hide'); | ||
| 298 | - $.each(dls, function() { | ||
| 299 | - dds = $('dd', this); | ||
| 300 | - var t = $(dds[6]).data('sort-val'); | ||
| 301 | - if((gbRange.st && t < gbRange.st) | ||
| 302 | - || (gbRange.et && t > gbRange.et)){ | ||
| 303 | - $(this).addClass('_search_hide'); | ||
| 304 | - } | ||
| 305 | - }); | ||
| 306 | - | ||
| 307 | - //滚动条置顶 | ||
| 308 | - $(tbody).parents('.ct_table_wrap')[0].scrollTop = 0; | ||
| 309 | - } | ||
| 310 | - | ||
| 311 | - /** | ||
| 312 | - * 根据驾驶员过滤表格 | ||
| 313 | - | ||
| 314 | - var filterScheduleByJsy = function (tbody, jsy) { | ||
| 315 | - | ||
| 316 | - }*/ | ||
| 317 | - | ||
| 318 | - | ||
| 319 | - function splitVal(v, type) { | ||
| 320 | - if(type=='car') | ||
| 321 | - return v; | ||
| 322 | - if(type=='lp') | ||
| 323 | - return v.split('lp')[1]; | ||
| 324 | - } | ||
| 325 | - | ||
| 326 | - function strToTime(str) { | ||
| 327 | - var len=str.length, array=new Array(2); | ||
| 328 | - str = str.replace(new RegExp(':','gm'),':'); | ||
| 329 | - if(str.indexOf(':') != -1){ | ||
| 330 | - array = str.split(':'); | ||
| 331 | - array[0] = splitBefore(array[0], 2); | ||
| 332 | - array[1] = splitBefore(array[1], 2); | ||
| 333 | - } | ||
| 334 | - else{ | ||
| 335 | - if(len == 1) | ||
| 336 | - str = '0'+str+'00'; | ||
| 337 | - else { | ||
| 338 | - str = splitBefore2(str); | ||
| 339 | - } | ||
| 340 | - array[0] = str.substr(0, 2); | ||
| 341 | - array[1] = str.substr(2, 2); | ||
| 342 | - } | ||
| 343 | - | ||
| 344 | - return moment(array[0]+array[1], 'HHmm'); | ||
| 345 | - } | ||
| 346 | - | ||
| 347 | - function splitBefore(str, size) { | ||
| 348 | - var len = str.length; | ||
| 349 | - if(len==size) | ||
| 350 | - return str; | ||
| 351 | - else if(len > size) | ||
| 352 | - return str.substr(0, 2); | ||
| 353 | - else{ | ||
| 354 | - var coverStr=''; | ||
| 355 | - var c = size - len; | ||
| 356 | - for(var i = 0; i < c; i ++) | ||
| 357 | - coverStr+='0'; | ||
| 358 | - return coverStr + str; | ||
| 359 | - } | ||
| 360 | - } | ||
| 361 | - | ||
| 362 | - function splitBefore2(str, size) { | ||
| 363 | - var len = str.length; | ||
| 364 | - if(len==size) | ||
| 365 | - return str; | ||
| 366 | - else if(len > size) | ||
| 367 | - return str.substr(0, 2); | ||
| 368 | - else{ | ||
| 369 | - var coverStr=''; | ||
| 370 | - var c = size - len; | ||
| 371 | - for(var i = 0; i < c; i ++) | ||
| 372 | - coverStr+='0'; | ||
| 373 | - return str + coverStr; | ||
| 374 | - } | ||
| 375 | - } | ||
| 376 | - return { | ||
| 377 | - init: init | ||
| 378 | - }; | ||
| 379 | -})(); | 1 | +/** 班次搜索 */ |
| 2 | +var gb_sch_search = (function() { | ||
| 3 | + | ||
| 4 | + //搜索结果模板,和art-template冲突。 用字符串渲染 | ||
| 5 | + var result_template = '<script type="text/autocomplete">' + | ||
| 6 | + ' <ul class="uk-nav uk-nav-autocomplete uk-autocomplete-results sch-search-results">' + | ||
| 7 | + ' {{~items}}' + | ||
| 8 | + ' <li data-value="{{ $item.value }}">' + | ||
| 9 | + ' <a>' + | ||
| 10 | + ' {{ $item.text }}' + | ||
| 11 | + ' <small >{{$item.exec}}</small>' + | ||
| 12 | + ' <small class="search-result-desc">{{{ $item.desc }}}</small>' + | ||
| 13 | + ' </a>' + | ||
| 14 | + ' </li>' + | ||
| 15 | + ' {{/items}}' + | ||
| 16 | + ' </ul>' + | ||
| 17 | + '</script>'; | ||
| 18 | + | ||
| 19 | + var ips = '.search_sch_panel input', | ||
| 20 | + _input, schArr, lineCode, group_cars, lp_pinyins, jsy_pinyins, searchType; | ||
| 21 | + $(document) | ||
| 22 | + .on('focus', ips, function() { | ||
| 23 | + $(this).parent().addClass('active'); | ||
| 24 | + lineCode = $(this).parents('li.line_schedule').data('id'); | ||
| 25 | + schArr = gb_common.get_vals(gb_schedule_table.findScheduleByLine(lineCode)); | ||
| 26 | + | ||
| 27 | + group_cars = gb_common.groupBy(schArr, 'clZbh'); | ||
| 28 | + var group_lp = gb_common.extractLpName(schArr); | ||
| 29 | + //路牌对照 | ||
| 30 | + lp_pinyins = []; | ||
| 31 | + for(var lp in group_lp){ | ||
| 32 | + lp_pinyins.push({ | ||
| 33 | + fullChars: pinyin.getFullChars(lp).toUpperCase(), | ||
| 34 | + camelChars: pinyin.getCamelChars(lp), | ||
| 35 | + lp: lp | ||
| 36 | + }); | ||
| 37 | + } | ||
| 38 | + //驾驶员对照 | ||
| 39 | + /* var group_jsy = gb_common.extractJsy(schArr); | ||
| 40 | + jsy_pinyins = []; | ||
| 41 | + for(var jsy in group_jsy){ | ||
| 42 | + jsy_pinyins.push({ | ||
| 43 | + fullChars: pinyin.getFullChars(jsy).toUpperCase(), | ||
| 44 | + camelChars: pinyin.getCamelChars(jsy), | ||
| 45 | + val: jsy | ||
| 46 | + }); | ||
| 47 | + }*/ | ||
| 48 | + _input = $(this); | ||
| 49 | + }) | ||
| 50 | + .on('blur', ips, function() { | ||
| 51 | + if ($(this).val() == ''){ | ||
| 52 | + reset_all($(this).parents('li.line_schedule')); | ||
| 53 | + } | ||
| 54 | + }); | ||
| 55 | + | ||
| 56 | + $(document).on('click', '.search_sch_panel i.cancel', function(){ | ||
| 57 | + reset_all($(this).parents('li.line_schedule')); | ||
| 58 | + }); | ||
| 59 | + | ||
| 60 | + var elements = '.search_sch_panel .sch-search-autocom'; | ||
| 61 | + var init = function() { | ||
| 62 | + $(elements).each(function() { | ||
| 63 | + if($('script[type="text/autocomplete"]', this).length > 0) | ||
| 64 | + return true; | ||
| 65 | + | ||
| 66 | + $(this).append(result_template); | ||
| 67 | + constructor(this); | ||
| 68 | + }); | ||
| 69 | + }; | ||
| 70 | + | ||
| 71 | + var constructor = function(e) { | ||
| 72 | + UIkit.autocomplete(e, { | ||
| 73 | + minLength: 1, | ||
| 74 | + delay: 10, | ||
| 75 | + source: autocomplete_source | ||
| 76 | + }).on('selectitem.uk.autocomplete', selectitem); | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | + /** | ||
| 80 | + * 车辆搜索函数 | ||
| 81 | + * @param v | ||
| 82 | + * @param release | ||
| 83 | + */ | ||
| 84 | + var searchCar = function (v, release) { | ||
| 85 | + var rs = [], gps; | ||
| 86 | + //应发未发数据 | ||
| 87 | + var yfwf_map = gb_schedule_table.car_yfwf_map(lineCode); | ||
| 88 | + for (var car in group_cars) { | ||
| 89 | + if (car.indexOf(v) != -1) { | ||
| 90 | + //车辆对应的gps | ||
| 91 | + gps = gb_data_gps.findGpsByNbbm(car) | ||
| 92 | + rs.push({ | ||
| 93 | + text: car, | ||
| 94 | + value: car, | ||
| 95 | + desc: '应发未发:' + (yfwf_map[car] == null ? 0 : yfwf_map[car]), | ||
| 96 | + exec: execSch(gps) | ||
| 97 | + }); | ||
| 98 | + } | ||
| 99 | + } | ||
| 100 | + | ||
| 101 | + searchType = 'car'; | ||
| 102 | + release && release(rs); | ||
| 103 | + } | ||
| 104 | + | ||
| 105 | + /** | ||
| 106 | + * 路牌搜索函数 | ||
| 107 | + * @param v | ||
| 108 | + * @param release | ||
| 109 | + */ | ||
| 110 | + var searchLp = function (v, release) { | ||
| 111 | + var rs = []; | ||
| 112 | + v = v.split('LP')[1]; | ||
| 113 | + | ||
| 114 | + $.each(lp_pinyins, function () { | ||
| 115 | + if(this.lp.indexOf(v) != -1 || this.fullChars.indexOf(v) != -1 || this.camelChars.indexOf(v) != -1){ | ||
| 116 | + rs.push({ | ||
| 117 | + text: this.lp, | ||
| 118 | + value: 'lp' + this.lp, | ||
| 119 | + desc: '', | ||
| 120 | + exec: '路牌' | ||
| 121 | + }); | ||
| 122 | + } | ||
| 123 | + }); | ||
| 124 | + searchType = 'lp'; | ||
| 125 | + release && release(rs); | ||
| 126 | + } | ||
| 127 | + | ||
| 128 | + /** | ||
| 129 | + * 按时间范围搜索 | ||
| 130 | + */ | ||
| 131 | + var dt = 1000 * 60 * 60 * 24; | ||
| 132 | + var gbRange = {}; | ||
| 133 | + var searchTimeRange = function (v, release) { | ||
| 134 | + var sm, em, text,value, fs = 'HH:mm',fs2='HHmm'; | ||
| 135 | + var start = v.indexOf('ST')==0; | ||
| 136 | + var ei = v.indexOf('ET'); | ||
| 137 | + var end = ei!=-1 && v.length > ei + 2; | ||
| 138 | + | ||
| 139 | + if(start && !end){ | ||
| 140 | + sm = strToTime(v.substr(2)); | ||
| 141 | + text = '搜索' + sm.format(fs) + '之后的班次'; | ||
| 142 | + value = 'st' + sm.format(fs2); | ||
| 143 | + } | ||
| 144 | + else if(!start && end){ | ||
| 145 | + em = strToTime(v.substr(2)); | ||
| 146 | + text = '搜索' + em.format(fs) + '之前的班次'; | ||
| 147 | + value = 'et' + em.format(fs2); | ||
| 148 | + } | ||
| 149 | + else if(start && end){ | ||
| 150 | + sm = strToTime(v.substring(2, ei)); | ||
| 151 | + em = strToTime(v.substr(ei + 2)); | ||
| 152 | + text = '搜索' + sm.format(fs) + ' 至 ' + em.format(fs) + '之间的班次'; | ||
| 153 | + value = 'st' + sm.format(fs2) + 'et' + em.format(fs2); | ||
| 154 | + } | ||
| 155 | + | ||
| 156 | + var threeBefore = moment().format('HH') < '02'; | ||
| 157 | + | ||
| 158 | + if(sm) { | ||
| 159 | + gbRange.st = sm.format('x'); | ||
| 160 | + if (threeBefore) | ||
| 161 | + gbRange.st -= dt; | ||
| 162 | + } | ||
| 163 | + if(em){ | ||
| 164 | + gbRange.et = em.format('x'); | ||
| 165 | + if (threeBefore) | ||
| 166 | + gbRange.et -= dt; | ||
| 167 | + } | ||
| 168 | + searchType = 'timeRange'; | ||
| 169 | + release && release([{ | ||
| 170 | + text: text, | ||
| 171 | + value: value, | ||
| 172 | + desc: '', | ||
| 173 | + exec: '' | ||
| 174 | + }]); | ||
| 175 | + } | ||
| 176 | + | ||
| 177 | + /** | ||
| 178 | + * 按驾驶员搜索 | ||
| 179 | + | ||
| 180 | + var searchJsy = function (v, release) { | ||
| 181 | + var rs = []; | ||
| 182 | + v = v.split('JSY')[1]; | ||
| 183 | + | ||
| 184 | + $.each(jsy_pinyins, function () { | ||
| 185 | + if(this.val.indexOf(v) != -1 || this.fullChars.indexOf(v) != -1 || this.camelChars.indexOf(v) != -1){ | ||
| 186 | + rs.push({ | ||
| 187 | + text: this.val, | ||
| 188 | + value: 'jsy' + this.val, | ||
| 189 | + desc: '', | ||
| 190 | + exec: '驾驶员' | ||
| 191 | + }); | ||
| 192 | + } | ||
| 193 | + }); | ||
| 194 | + searchType = 'jsy'; | ||
| 195 | + release && release(rs); | ||
| 196 | + }*/ | ||
| 197 | + | ||
| 198 | + var defaultHandler = searchCar; | ||
| 199 | + var searchHandlerMapp = {'LP': searchLp/*,'JSY': searchJsy*/, 'ST': searchTimeRange, 'ET': searchTimeRange}; | ||
| 200 | + var autocomplete_source = function(release) { | ||
| 201 | + var v = _input.val().toUpperCase(); | ||
| 202 | + | ||
| 203 | + for(var k in searchHandlerMapp){ | ||
| 204 | + if(v.indexOf(k) == 0 && v!=k){ | ||
| 205 | + searchHandlerMapp[k](v, release); | ||
| 206 | + return; | ||
| 207 | + } | ||
| 208 | + } | ||
| 209 | + //搜索车辆 | ||
| 210 | + searchCar(v, release); | ||
| 211 | + } | ||
| 212 | + | ||
| 213 | + var reset_all = function(cont) { | ||
| 214 | + //var cont = 'li.line_schedule[data-id=' + lineCode + ']'; | ||
| 215 | + //uikit 会记住上一次搜索值,触发keyup以清空该值 | ||
| 216 | + $('.sch-search-autocom input', cont).val('').trigger('keyup').parent().removeClass('active'); | ||
| 217 | + $('.line-schedule-table .ct_table_body', cont).removeClass('search_result_body').find('dl._search_hide').removeClass('_search_hide'); | ||
| 218 | + //更新滚动条高度 | ||
| 219 | + $('.ct_table_wrap', cont).perfectScrollbar('update'); | ||
| 220 | + } | ||
| 221 | + | ||
| 222 | + function execSch(gps) { | ||
| 223 | + if (gps && gps.schId) { | ||
| 224 | + var sch = gb_schedule_table.findScheduleByLine(gps.lineId)[gps.schId]; | ||
| 225 | + if (sch) | ||
| 226 | + return '(执行' + (sch.xlDir == 0 ? '上行' : '下行') + sch.dfsj + ')'; | ||
| 227 | + } | ||
| 228 | + return ''; | ||
| 229 | + } | ||
| 230 | + | ||
| 231 | + var selectitem = function(event, data, acobject) { | ||
| 232 | + var cont = 'li.line_schedule[data-id=' + lineCode + ']', | ||
| 233 | + tbodys = $('.line-schedule-table .ct_table_body', cont); | ||
| 234 | + | ||
| 235 | + tbodys.addClass('search_result_body'); | ||
| 236 | + $('.sch-search-autocom input', cont).val(data.value).parent().addClass('active'); | ||
| 237 | + | ||
| 238 | + var v = splitVal(data.value, searchType); | ||
| 239 | + $.each(tbodys, function() { | ||
| 240 | + if(searchType=='car') | ||
| 241 | + filterScheduleByNbbm(this, v); | ||
| 242 | + if(searchType=='lp') | ||
| 243 | + filterScheduleByLpName(this, v); | ||
| 244 | + if(searchType=='timeRange') | ||
| 245 | + filterScheduleByTimeRange(this); | ||
| 246 | + /*if(searchType=='jsy') | ||
| 247 | + filterScheduleByJsy(this, v);*/ | ||
| 248 | + }); | ||
| 249 | + gbRange = {}; | ||
| 250 | + } | ||
| 251 | + | ||
| 252 | + /** | ||
| 253 | + * 根据车辆过滤表格 | ||
| 254 | + * @param tbody | ||
| 255 | + * @param car | ||
| 256 | + */ | ||
| 257 | + var filterScheduleByNbbm = function(tbody, car) { | ||
| 258 | + var dls = $('dl', tbody), | ||
| 259 | + dds; | ||
| 260 | + dls.removeClass('_search_hide'); | ||
| 261 | + $.each(dls, function() { | ||
| 262 | + dds = $('dd', this); | ||
| 263 | + if (car != $(dds[3]).data('nbbm')) | ||
| 264 | + $(this).addClass('_search_hide'); | ||
| 265 | + }); | ||
| 266 | + | ||
| 267 | + //滚动条置顶 | ||
| 268 | + $(tbody).parents('.ct_table_wrap')[0].scrollTop = 0; | ||
| 269 | + } | ||
| 270 | + | ||
| 271 | + /** | ||
| 272 | + * 根据路牌过滤表格 | ||
| 273 | + * @param tbody | ||
| 274 | + * @param lpName | ||
| 275 | + */ | ||
| 276 | + var filterScheduleByLpName = function (tbody, lpName) { | ||
| 277 | + var dls = $('dl', tbody), | ||
| 278 | + dds; | ||
| 279 | + dls.removeClass('_search_hide'); | ||
| 280 | + $.each(dls, function() { | ||
| 281 | + dds = $('dd', this); | ||
| 282 | + if (lpName != $('a', dds[1]).text()) | ||
| 283 | + $(this).addClass('_search_hide'); | ||
| 284 | + }); | ||
| 285 | + | ||
| 286 | + //滚动条置顶 | ||
| 287 | + $(tbody).parents('.ct_table_wrap')[0].scrollTop = 0; | ||
| 288 | + } | ||
| 289 | + | ||
| 290 | + /** | ||
| 291 | + * 根据时间范围过滤表格 | ||
| 292 | + * @param tbody | ||
| 293 | + */ | ||
| 294 | + var filterScheduleByTimeRange = function (tbody) { | ||
| 295 | + var dls = $('dl', tbody), | ||
| 296 | + dds; | ||
| 297 | + dls.removeClass('_search_hide'); | ||
| 298 | + $.each(dls, function() { | ||
| 299 | + dds = $('dd', this); | ||
| 300 | + var t = $(dds[7]).data('sort-val'); | ||
| 301 | + if((gbRange.st && t < gbRange.st) | ||
| 302 | + || (gbRange.et && t > gbRange.et)){ | ||
| 303 | + $(this).addClass('_search_hide'); | ||
| 304 | + } | ||
| 305 | + }); | ||
| 306 | + | ||
| 307 | + //滚动条置顶 | ||
| 308 | + $(tbody).parents('.ct_table_wrap')[0].scrollTop = 0; | ||
| 309 | + } | ||
| 310 | + | ||
| 311 | + /** | ||
| 312 | + * 根据驾驶员过滤表格 | ||
| 313 | + | ||
| 314 | + var filterScheduleByJsy = function (tbody, jsy) { | ||
| 315 | + | ||
| 316 | + }*/ | ||
| 317 | + | ||
| 318 | + | ||
| 319 | + function splitVal(v, type) { | ||
| 320 | + if(type=='car') | ||
| 321 | + return v; | ||
| 322 | + if(type=='lp') | ||
| 323 | + return v.split('lp')[1]; | ||
| 324 | + } | ||
| 325 | + | ||
| 326 | + function strToTime(str) { | ||
| 327 | + var len=str.length, array=new Array(2); | ||
| 328 | + str = str.replace(new RegExp(':','gm'),':'); | ||
| 329 | + if(str.indexOf(':') != -1){ | ||
| 330 | + array = str.split(':'); | ||
| 331 | + array[0] = splitBefore(array[0], 2); | ||
| 332 | + array[1] = splitBefore(array[1], 2); | ||
| 333 | + } | ||
| 334 | + else{ | ||
| 335 | + if(len == 1) | ||
| 336 | + str = '0'+str+'00'; | ||
| 337 | + else { | ||
| 338 | + str = splitBefore2(str); | ||
| 339 | + } | ||
| 340 | + array[0] = str.substr(0, 2); | ||
| 341 | + array[1] = str.substr(2, 2); | ||
| 342 | + } | ||
| 343 | + | ||
| 344 | + return moment(array[0]+array[1], 'HHmm'); | ||
| 345 | + } | ||
| 346 | + | ||
| 347 | + function splitBefore(str, size) { | ||
| 348 | + var len = str.length; | ||
| 349 | + if(len==size) | ||
| 350 | + return str; | ||
| 351 | + else if(len > size) | ||
| 352 | + return str.substr(0, 2); | ||
| 353 | + else{ | ||
| 354 | + var coverStr=''; | ||
| 355 | + var c = size - len; | ||
| 356 | + for(var i = 0; i < c; i ++) | ||
| 357 | + coverStr+='0'; | ||
| 358 | + return coverStr + str; | ||
| 359 | + } | ||
| 360 | + } | ||
| 361 | + | ||
| 362 | + function splitBefore2(str, size) { | ||
| 363 | + var len = str.length; | ||
| 364 | + if(len==size) | ||
| 365 | + return str; | ||
| 366 | + else if(len > size) | ||
| 367 | + return str.substr(0, 2); | ||
| 368 | + else{ | ||
| 369 | + var coverStr=''; | ||
| 370 | + var c = size - len; | ||
| 371 | + for(var i = 0; i < c; i ++) | ||
| 372 | + coverStr+='0'; | ||
| 373 | + return str + coverStr; | ||
| 374 | + } | ||
| 375 | + } | ||
| 376 | + return { | ||
| 377 | + init: init | ||
| 378 | + }; | ||
| 379 | +})(); |