Commit 078baab1f6eaaaf434c78e58154c0bfb1881ac9d
1 parent
ad4380bd
update
Showing
24 changed files
with
470 additions
and
104 deletions
src/main/java/com/bsth/StartCommand.java
| ... | ... | @@ -16,6 +16,7 @@ import com.bsth.service.realcontrol.buffer.GetSchedulePlanThread; |
| 16 | 16 | import com.bsth.service.realcontrol.buffer.SchedulePersistenceThread; |
| 17 | 17 | import com.bsth.vehicle.common.CommonRefreshThread; |
| 18 | 18 | import com.bsth.vehicle.directive.DirectivePersistenceThread; |
| 19 | +import com.bsth.vehicle.directive.FirstScheduleIssuedThread; | |
| 19 | 20 | import com.bsth.vehicle.gpsdata.GpsArrivalStationThread; |
| 20 | 21 | import com.bsth.vehicle.gpsdata.GpsRefreshThread; |
| 21 | 22 | |
| ... | ... | @@ -32,7 +33,7 @@ public class StartCommand implements CommandLineRunner{ |
| 32 | 33 | @Autowired |
| 33 | 34 | SecurityMetadataSourceService invocationSecurityMetadataSourceService; |
| 34 | 35 | |
| 35 | - public static ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(6); | |
| 36 | + public static ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(7); | |
| 36 | 37 | |
| 37 | 38 | @Autowired |
| 38 | 39 | GpsRefreshThread gpsRefreshThread; |
| ... | ... | @@ -46,6 +47,8 @@ public class StartCommand implements CommandLineRunner{ |
| 46 | 47 | SchedulePersistenceThread SchedulePersistenceThread; |
| 47 | 48 | @Autowired |
| 48 | 49 | GpsArrivalStationThread gpsArrivalStationThread; |
| 50 | + @Autowired | |
| 51 | + FirstScheduleIssuedThread firstScheduleIssuedThread; | |
| 49 | 52 | |
| 50 | 53 | @Override |
| 51 | 54 | public void run(String... arg0){ |
| ... | ... | @@ -54,20 +57,48 @@ public class StartCommand implements CommandLineRunner{ |
| 54 | 57 | //启动时加载所有资源 |
| 55 | 58 | invocationSecurityMetadataSourceService.loadResourceDefine(); |
| 56 | 59 | |
| 57 | - //GPS实时数据更新线程,每次执行完成4秒后开始下一次 | |
| 58 | - scheduler.scheduleWithFixedDelay(gpsRefreshThread, 0, 4, TimeUnit.SECONDS); | |
| 59 | - //定时0点从计划排班表抓取当天实际排班 | |
| 60 | + /** | |
| 61 | + * GPS实时数据更新 线程 | |
| 62 | + * 每8秒和网关HTTP接口同步一次 | |
| 63 | + */ | |
| 64 | + scheduler.scheduleWithFixedDelay(gpsRefreshThread, 0, 8, TimeUnit.SECONDS); | |
| 65 | + | |
| 66 | + /** | |
| 67 | + * 每天 0点 抓取当天实际排班 | |
| 68 | + */ | |
| 60 | 69 | scheduler.scheduleAtFixedRate(getSchedulePlanThread |
| 61 | 70 | , 0//DateUtils.getTimesnight() + 5 - System.currentTimeMillis() / 1000 |
| 62 | 71 | , 60 * 60 * 24, TimeUnit.SECONDS); |
| 63 | - //两分钟调度指令入库一次 | |
| 64 | - scheduler.scheduleWithFixedDelay(directivePersistenceThread, 20, 60 * 1, TimeUnit.SECONDS); | |
| 65 | - //两小时刷新一次对照数据 | |
| 72 | + | |
| 73 | + /** | |
| 74 | + * 调度指令两分钟入库一次 | |
| 75 | + * 指令会缓存在内存,直到收到所有响应再入库 | |
| 76 | + */ | |
| 77 | + scheduler.scheduleWithFixedDelay(directivePersistenceThread, 20, 60 * 2, TimeUnit.SECONDS); | |
| 78 | + | |
| 79 | + /** | |
| 80 | + * 车辆,设备,公司等常用的映射数据,每两小时刷新一次 | |
| 81 | + */ | |
| 66 | 82 | scheduler.scheduleWithFixedDelay(commonRefreshThread, 0, 60 * 60 * 2, TimeUnit.SECONDS); |
| 67 | - //一分钟持久化一次实际排班 | |
| 83 | + | |
| 84 | + /** | |
| 85 | + * 每分钟将有变更的班次入库(不包括子任务) | |
| 86 | + * 单纯为了提高 线调操作 的响应速度 | |
| 87 | + */ | |
| 68 | 88 | scheduler.scheduleWithFixedDelay(SchedulePersistenceThread, 60 * 1, 60 * 1, TimeUnit.SECONDS); |
| 69 | - //将实际到离站和排班计划进行匹配 12秒一次 | |
| 89 | + | |
| 90 | + /** | |
| 91 | + * 每15秒从数据库抓取到离站信息和班次匹配 | |
| 92 | + * (网关生成的到离站数据也是延迟批量入库,所以缩短该线程执行周期并不会提高 “实际到离站” 的实时性) | |
| 93 | + */ | |
| 70 | 94 | //scheduler.scheduleWithFixedDelay(gpsArrivalStationThread, 5, 1200, TimeUnit.SECONDS); |
| 95 | + | |
| 96 | + /** | |
| 97 | + * 首个调度指令下发(2分钟运行一次) | |
| 98 | + * 每辆车的第一个调度指令由该线程下发 | |
| 99 | + * 后续班次由 “实际终点到达” 事件触发指令下发 | |
| 100 | + */ | |
| 101 | + //scheduler.scheduleWithFixedDelay(firstScheduleIssuedThread, 60 , 60 * 2, TimeUnit.SECONDS); | |
| 71 | 102 | } catch (Exception e) { |
| 72 | 103 | e.printStackTrace(); |
| 73 | 104 | } | ... | ... |
src/main/java/com/bsth/entity/realcontrol/ScheduleRealInfo.java
| ... | ... | @@ -3,9 +3,10 @@ package com.bsth.entity.realcontrol; |
| 3 | 3 | import com.bsth.entity.sys.SysUser; |
| 4 | 4 | |
| 5 | 5 | import javax.persistence.*; |
| 6 | + | |
| 7 | +import java.text.ParseException; | |
| 8 | +import java.text.SimpleDateFormat; | |
| 6 | 9 | import java.util.Date; |
| 7 | -import java.util.HashSet; | |
| 8 | -import java.util.Set; | |
| 9 | 10 | |
| 10 | 11 | /** |
| 11 | 12 | * 实际排班计划明细。 |
| ... | ... | @@ -32,10 +33,10 @@ public class ScheduleRealInfo { |
| 32 | 33 | /** 车辆自编号 */ |
| 33 | 34 | private String clZbh; |
| 34 | 35 | |
| 35 | - /** 报道时间(格式 HH:mm) */ | |
| 36 | - private String bdTime; | |
| 37 | - /** 出场时间(格式 HH:mm) */ | |
| 38 | - private String ccTime; | |
| 36 | + /** 报道时间(格式 HH:mm) | |
| 37 | + private String bdTime; */ | |
| 38 | + /** 出场时间(格式 HH:mm) | |
| 39 | + private String ccTime;*/ | |
| 39 | 40 | |
| 40 | 41 | /** 驾驶员工号 */ |
| 41 | 42 | private String jGh; |
| ... | ... | @@ -80,15 +81,15 @@ public class ScheduleRealInfo { |
| 80 | 81 | private Integer bcsj; |
| 81 | 82 | |
| 82 | 83 | /** |
| 83 | - * 班次类型 TODO:正常班次、出场、进场、加油、临加班次、区间班次、放空班次、放大站班次、两点间空驶 | |
| 84 | + * 班次类型 TODO:正常班次、出场、进场、加油、区间班次、放空班次、放大站班次、两点间空驶 | |
| 84 | 85 | */ |
| 85 | 86 | private String bcType; |
| 86 | 87 | |
| 87 | 88 | /** 创建人 */ |
| 88 | - @ManyToOne(cascade = CascadeType.PERSIST, fetch = FetchType.LAZY) | |
| 89 | + @ManyToOne(fetch = FetchType.LAZY) | |
| 89 | 90 | private SysUser createBy; |
| 90 | 91 | /** 修改人 */ |
| 91 | - @ManyToOne(cascade = CascadeType.PERSIST, fetch = FetchType.LAZY) | |
| 92 | + @ManyToOne(fetch = FetchType.LAZY) | |
| 92 | 93 | private SysUser updateBy; |
| 93 | 94 | /** 创建日期 */ |
| 94 | 95 | @Column(updatable = false, name = "create_date", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP") |
| ... | ... | @@ -133,6 +134,9 @@ public class ScheduleRealInfo { |
| 133 | 134 | @Transient |
| 134 | 135 | private Long dfsjT; |
| 135 | 136 | |
| 137 | + /** 指令下发状态 60: 已发送, 100: 设备确认收到, 200:驾驶员确认 0:失败 */ | |
| 138 | + private Integer directiveState; | |
| 139 | + | |
| 136 | 140 | public void addRemarks(String remark){ |
| 137 | 141 | String newRem = this.getRemarks(); |
| 138 | 142 | if(null == newRem) |
| ... | ... | @@ -189,22 +193,6 @@ public class ScheduleRealInfo { |
| 189 | 193 | this.clZbh = clZbh; |
| 190 | 194 | } |
| 191 | 195 | |
| 192 | - public String getBdTime() { | |
| 193 | - return bdTime; | |
| 194 | - } | |
| 195 | - | |
| 196 | - public void setBdTime(String bdTime) { | |
| 197 | - this.bdTime = bdTime; | |
| 198 | - } | |
| 199 | - | |
| 200 | - public String getCcTime() { | |
| 201 | - return ccTime; | |
| 202 | - } | |
| 203 | - | |
| 204 | - public void setCcTime(String ccTime) { | |
| 205 | - this.ccTime = ccTime; | |
| 206 | - } | |
| 207 | - | |
| 208 | 196 | public String getjGh() { |
| 209 | 197 | return jGh; |
| 210 | 198 | } |
| ... | ... | @@ -476,4 +464,43 @@ public class ScheduleRealInfo { |
| 476 | 464 | public void setDfsjT(Long dfsjT) { |
| 477 | 465 | this.dfsjT = dfsjT; |
| 478 | 466 | } |
| 467 | + | |
| 468 | + @Transient | |
| 469 | + static SimpleDateFormat sdfyyyyMMdd = new SimpleDateFormat("yyyy-MM-dd"); | |
| 470 | + @Transient | |
| 471 | + static SimpleDateFormat sdfyyyyMMddHHmm = new SimpleDateFormat("yyyy-MM-dd HH:mm"); | |
| 472 | + | |
| 473 | + /** | |
| 474 | + * @throws ParseException | |
| 475 | + * | |
| 476 | + * @Title: syncTime | |
| 477 | + * @Description: TODO(计算时间戳,待发时间为计发时间) | |
| 478 | + * @param 设定文件 | |
| 479 | + * @return void 返回类型 | |
| 480 | + * @throws | |
| 481 | + */ | |
| 482 | + public void syncTime(){ | |
| 483 | + try{ | |
| 484 | + this.setDfsj(this.getFcsj()); | |
| 485 | + //发车时间戳 | |
| 486 | + this.setFcsjT(sdfyyyyMMddHHmm.parse(sdfyyyyMMdd.format(this.scheduleDate) + " " + this.getFcsj()).getTime()); | |
| 487 | + //待发时间 | |
| 488 | + this.setDfsjT(this.getFcsjT()); | |
| 489 | + }catch(Exception e){ | |
| 490 | + e.printStackTrace(); | |
| 491 | + } | |
| 492 | + } | |
| 493 | + | |
| 494 | + public Integer getDirectiveState() { | |
| 495 | + return directiveState; | |
| 496 | + } | |
| 497 | + | |
| 498 | + public void setDirectiveState(Integer directiveState) { | |
| 499 | + this.directiveState = directiveState; | |
| 500 | + } | |
| 501 | + | |
| 502 | + @Override | |
| 503 | + public boolean equals(Object obj) { | |
| 504 | + return this.id.equals(((ScheduleRealInfo)obj).getId()); | |
| 505 | + } | |
| 479 | 506 | } | ... | ... |
src/main/java/com/bsth/entity/sys/Module.java
| ... | ... | @@ -11,10 +11,18 @@ import javax.persistence.GeneratedValue; |
| 11 | 11 | import javax.persistence.GenerationType; |
| 12 | 12 | import javax.persistence.Id; |
| 13 | 13 | import javax.persistence.ManyToMany; |
| 14 | +import javax.persistence.NamedAttributeNode; | |
| 15 | +import javax.persistence.NamedEntityGraph; | |
| 16 | +import javax.persistence.NamedEntityGraphs; | |
| 14 | 17 | import javax.persistence.Table; |
| 15 | 18 | |
| 16 | 19 | @Entity |
| 17 | 20 | @Table(name = "bsth_c_sys_module") |
| 21 | +@NamedEntityGraphs({ | |
| 22 | + @NamedEntityGraph(name = "module_roles", attributeNodes = { | |
| 23 | + @NamedAttributeNode("roles") | |
| 24 | + }) | |
| 25 | +}) | |
| 18 | 26 | public class Module { |
| 19 | 27 | |
| 20 | 28 | @Id |
| ... | ... | @@ -45,7 +53,7 @@ public class Module { |
| 45 | 53 | */ |
| 46 | 54 | private String groupType; |
| 47 | 55 | |
| 48 | - @ManyToMany(fetch = FetchType.EAGER, mappedBy = "modules") | |
| 56 | + @ManyToMany(mappedBy = "modules", fetch = FetchType.LAZY) | |
| 49 | 57 | private Set<Role> roles = new LinkedHashSet<>(); |
| 50 | 58 | |
| 51 | 59 | @Column(updatable = false,name = "create_date", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP") | ... | ... |
src/main/java/com/bsth/repository/ModuleRepository.java
| ... | ... | @@ -3,6 +3,8 @@ package com.bsth.repository; |
| 3 | 3 | import java.util.List; |
| 4 | 4 | import java.util.Set; |
| 5 | 5 | |
| 6 | +import org.springframework.data.jpa.domain.Specification; | |
| 7 | +import org.springframework.data.jpa.repository.EntityGraph; | |
| 6 | 8 | import org.springframework.data.jpa.repository.Query; |
| 7 | 9 | import org.springframework.stereotype.Repository; |
| 8 | 10 | |
| ... | ... | @@ -18,4 +20,8 @@ public interface ModuleRepository extends BaseRepository<Module, Integer>{ |
| 18 | 20 | |
| 19 | 21 | @Query("select m from Module m where m.id in ?1") |
| 20 | 22 | Set<Module> findByIds(List<Integer> ids); |
| 23 | + | |
| 24 | + @EntityGraph(value = "carConfigInfo_xl_cl", type = EntityGraph.EntityGraphType.FETCH) | |
| 25 | + @Override | |
| 26 | + List<Module> findAll(Specification<Module> spec); | |
| 21 | 27 | } | ... | ... |
src/main/java/com/bsth/service/realcontrol/buffer/GetSchedulePlanThread.java
| ... | ... | @@ -36,9 +36,7 @@ public class GetSchedulePlanThread extends Thread{ |
| 36 | 36 | @Autowired |
| 37 | 37 | ScheduleRealInfoRepository scheduleRealInfoRepository; |
| 38 | 38 | |
| 39 | - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd") | |
| 40 | - ,sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm") | |
| 41 | - ,sdf3 = new SimpleDateFormat("HH:mm"); | |
| 39 | + SimpleDateFormat sdfHHmm = new SimpleDateFormat("HH:mm"); | |
| 42 | 40 | |
| 43 | 41 | @Override |
| 44 | 42 | public void run() { |
| ... | ... | @@ -51,17 +49,12 @@ public class GetSchedulePlanThread extends Thread{ |
| 51 | 49 | |
| 52 | 50 | Date zdDate; |
| 53 | 51 | for(ScheduleRealInfo item : realList){ |
| 54 | - item.setDfsj(item.getFcsj()); | |
| 55 | - //发车时间戳 | |
| 56 | - item.setFcsjT(sdf2.parse(dateStr + " " + item.getFcsj()).getTime()); | |
| 57 | - //待发时间 | |
| 58 | - item.setDfsjT(item.getFcsjT()); | |
| 59 | - | |
| 52 | + item.syncTime(); | |
| 60 | 53 | //计划终点时间 |
| 61 | 54 | if(item.getBcsj() != null){ |
| 62 | 55 | zdDate = new Date(item.getFcsjT() + (item.getBcsj() * 60 * 1000)); |
| 63 | 56 | item.setZdsjT(zdDate.getTime()); |
| 64 | - item.setZdsj(sdf3.format(zdDate)); | |
| 57 | + item.setZdsj(sdfHHmm.format(zdDate)); | |
| 65 | 58 | } |
| 66 | 59 | } |
| 67 | 60 | ... | ... |
src/main/java/com/bsth/service/realcontrol/buffer/ScheduleBuffer.java
| ... | ... | @@ -12,6 +12,7 @@ import org.slf4j.LoggerFactory; |
| 12 | 12 | |
| 13 | 13 | import com.bsth.entity.realcontrol.ScheduleRealInfo; |
| 14 | 14 | import com.google.common.collect.ArrayListMultimap; |
| 15 | +import com.google.common.collect.LinkedListMultimap; | |
| 15 | 16 | |
| 16 | 17 | /** |
| 17 | 18 | * |
| ... | ... | @@ -32,10 +33,17 @@ public class ScheduleBuffer { |
| 32 | 33 | public static ArrayListMultimap<String, ScheduleRealInfo> schedulListMap; |
| 33 | 34 | |
| 34 | 35 | /** |
| 35 | - * K: 车辆自编号 V: 班次链表 | |
| 36 | + * K: 车辆自编号 V: 未完成班次链表 | |
| 36 | 37 | */ |
| 37 | 38 | public static Map<String, LinkedList<ScheduleRealInfo>> vehLinkedMap; |
| 38 | 39 | |
| 40 | + | |
| 41 | + /** | |
| 42 | + * K: 车辆自编号 V: 已执行班次链表 | |
| 43 | + */ | |
| 44 | + public static LinkedListMultimap<String, ScheduleRealInfo> finishLinkedMap; | |
| 45 | + | |
| 46 | + | |
| 39 | 47 | /** |
| 40 | 48 | * 主键 和 排班映射 |
| 41 | 49 | */ |
| ... | ... | @@ -46,24 +54,22 @@ public class ScheduleBuffer { |
| 46 | 54 | */ |
| 47 | 55 | public static LinkedList<ScheduleRealInfo> persistentList; |
| 48 | 56 | |
| 57 | + static ScheduleComparator scheduleComparator = new ScheduleComparator(); | |
| 58 | + | |
| 49 | 59 | static{ |
| 50 | 60 | schedulListMap = ArrayListMultimap.create(); |
| 51 | 61 | pkSchedulMap = new HashMap<>(); |
| 52 | 62 | persistentList = new LinkedList<>(); |
| 53 | 63 | vehLinkedMap = new HashMap<>(); |
| 64 | + | |
| 65 | + finishLinkedMap = LinkedListMultimap.create(); | |
| 54 | 66 | } |
| 55 | 67 | |
| 56 | 68 | public static int init(List<ScheduleRealInfo> list){ |
| 57 | 69 | |
| 58 | 70 | try{ |
| 59 | 71 | //发车时间排序 |
| 60 | - Collections.sort(list, new Comparator<ScheduleRealInfo>() { | |
| 61 | - | |
| 62 | - @Override | |
| 63 | - public int compare(ScheduleRealInfo o1, ScheduleRealInfo o2) { | |
| 64 | - return (int) (o1.getFcsjT() - o2.getFcsjT()); | |
| 65 | - } | |
| 66 | - }); | |
| 72 | + Collections.sort(list, scheduleComparator); | |
| 67 | 73 | |
| 68 | 74 | String zbh; |
| 69 | 75 | for(ScheduleRealInfo schedul : list){ |
| ... | ... | @@ -83,4 +89,65 @@ public class ScheduleBuffer { |
| 83 | 89 | } |
| 84 | 90 | return 0; |
| 85 | 91 | } |
| 92 | + | |
| 93 | + public static int put(ScheduleRealInfo sch){ | |
| 94 | + schedulListMap.put(sch.getXlBm(), sch); | |
| 95 | + pkSchedulMap.put(sch.getId(), sch); | |
| 96 | + | |
| 97 | + String zbh = sch.getClZbh(); | |
| 98 | + if(!vehLinkedMap.containsKey(zbh)) | |
| 99 | + vehLinkedMap.put(zbh, new LinkedList<ScheduleRealInfo>()); | |
| 100 | + vehLinkedMap.get(zbh).add(sch); | |
| 101 | + | |
| 102 | + //重新排序 | |
| 103 | + Collections.sort(vehLinkedMap.get(zbh), scheduleComparator); | |
| 104 | + return 0; | |
| 105 | + } | |
| 106 | + | |
| 107 | + public static class ScheduleComparator implements Comparator<ScheduleRealInfo>{ | |
| 108 | + | |
| 109 | + @Override | |
| 110 | + public int compare(ScheduleRealInfo o1, ScheduleRealInfo o2) { | |
| 111 | + return (int) (o1.getFcsjT() - o2.getFcsjT()); | |
| 112 | + } | |
| 113 | + } | |
| 114 | + | |
| 115 | + /** | |
| 116 | + * | |
| 117 | + * @Title: finishSch | |
| 118 | + * @Description: TODO(完成一个班次) | |
| 119 | + * @param @param sch | |
| 120 | + * @return ScheduleRealInfo 返回 下一个待执行的班次 | |
| 121 | + * @throws | |
| 122 | + */ | |
| 123 | + public static ScheduleRealInfo finishSch(ScheduleRealInfo sch){ | |
| 124 | + LinkedList<ScheduleRealInfo> list = vehLinkedMap.get(sch.getClZbh()); | |
| 125 | + //状态修改为已执行 | |
| 126 | + sch.setStatus(2); | |
| 127 | + persistentList.add(sch); | |
| 128 | + | |
| 129 | + ScheduleRealInfo temp; | |
| 130 | + int len = list.size(); | |
| 131 | + for(int i = 0; i < len; i ++){ | |
| 132 | + temp = list.poll(); | |
| 133 | + if(temp.equals(sch)){ | |
| 134 | + //加入已执行 | |
| 135 | + finishLinkedMap.put(sch.getClZbh(), sch); | |
| 136 | + break; | |
| 137 | + } | |
| 138 | + } | |
| 139 | + | |
| 140 | + return list.getFirst(); | |
| 141 | + } | |
| 142 | + | |
| 143 | + /** | |
| 144 | + * | |
| 145 | + * @Title: getFinishSchNo | |
| 146 | + * @Description: TODO(获取车辆已完成的班次数) | |
| 147 | + * @param @param nbbm | |
| 148 | + * @throws | |
| 149 | + */ | |
| 150 | + public static int getFinishSchNo(String nbbm){ | |
| 151 | + return finishLinkedMap.get(nbbm) == null ? 0 : finishLinkedMap.get(nbbm).size(); | |
| 152 | + } | |
| 86 | 153 | } | ... | ... |
src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
| ... | ... | @@ -8,6 +8,8 @@ import java.util.HashMap; |
| 8 | 8 | import java.util.List; |
| 9 | 9 | import java.util.Map; |
| 10 | 10 | |
| 11 | +import javax.transaction.Transactional; | |
| 12 | + | |
| 11 | 13 | import org.slf4j.Logger; |
| 12 | 14 | import org.slf4j.LoggerFactory; |
| 13 | 15 | import org.springframework.beans.factory.annotation.Autowired; |
| ... | ... | @@ -19,9 +21,11 @@ import com.bsth.entity.Personnel; |
| 19 | 21 | import com.bsth.entity.realcontrol.ScheduleRealInfo; |
| 20 | 22 | import com.bsth.entity.schedule.CarConfigInfo; |
| 21 | 23 | import com.bsth.entity.schedule.EmployeeConfigInfo; |
| 24 | +import com.bsth.entity.sys.SysUser; | |
| 22 | 25 | import com.bsth.repository.realcontrol.ScheduleRealInfoRepository; |
| 23 | 26 | import com.bsth.repository.schedule.CarConfigInfoRepository; |
| 24 | 27 | import com.bsth.repository.schedule.EmployeeConfigInfoRepository; |
| 28 | +import com.bsth.security.util.SecurityUtils; | |
| 25 | 29 | import com.bsth.service.impl.BaseServiceImpl; |
| 26 | 30 | import com.bsth.service.realcontrol.ScheduleRealInfoService; |
| 27 | 31 | import com.bsth.service.realcontrol.buffer.ScheduleBuffer; |
| ... | ... | @@ -167,7 +171,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 167 | 171 | if(driver != null){ |
| 168 | 172 | map = new HashMap<>(); |
| 169 | 173 | code = driver.getJobCode(); |
| 170 | - map.put("id", code); | |
| 174 | + map.put("id", code + "/" + driver.getPersonnelName()); | |
| 171 | 175 | map.put("text", code + "/" + driver.getPersonnelName()); |
| 172 | 176 | rsList.add(map); |
| 173 | 177 | } |
| ... | ... | @@ -190,7 +194,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 190 | 194 | if(conductor != null){ |
| 191 | 195 | code = conductor.getJobCode(); |
| 192 | 196 | map = new HashMap<>(); |
| 193 | - map.put("id", code); | |
| 197 | + map.put("id", code + "/" + conductor.getPersonnelName()); | |
| 194 | 198 | map.put("text", code + "/" + conductor.getPersonnelName()); |
| 195 | 199 | rsList.add(map); |
| 196 | 200 | } |
| ... | ... | @@ -220,4 +224,22 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 220 | 224 | } |
| 221 | 225 | return rsList; |
| 222 | 226 | } |
| 227 | + | |
| 228 | + /** | |
| 229 | + * 临加班次 | |
| 230 | + */ | |
| 231 | + @Override | |
| 232 | + public Map<String, Object> save(ScheduleRealInfo t) { | |
| 233 | + SysUser user = SecurityUtils.getCurrentUser(); | |
| 234 | + | |
| 235 | + t.setScheduleDate(new Date()); | |
| 236 | + t.setCreateBy(user); | |
| 237 | + t.syncTime(); | |
| 238 | + | |
| 239 | + Map<String, Object> map = super.save(t); | |
| 240 | + | |
| 241 | + //加入缓存 | |
| 242 | + ScheduleBuffer.put(t); | |
| 243 | + return map; | |
| 244 | + } | |
| 223 | 245 | } | ... | ... |
src/main/java/com/bsth/util/TestPad.java
| ... | ... | @@ -11,13 +11,6 @@ public class TestPad { |
| 11 | 11 | double Ec; |
| 12 | 12 | double Ed; |
| 13 | 13 | |
| 14 | - | |
| 15 | - public static void main(String[] args) { | |
| 16 | - | |
| 17 | - TestPad A = new TestPad(121.60613, 31.270115); | |
| 18 | - TestPad B = new TestPad(121.605239 ,31.269705); | |
| 19 | - System.out.println(TestPad.angle(A, B)); | |
| 20 | - } | |
| 21 | 14 | public TestPad(double longitude, double latitude) |
| 22 | 15 | { |
| 23 | 16 | m_LoDeg = (int)longitude; | ... | ... |
src/main/java/com/bsth/vehicle/directive/FirstScheduleIssuedThread.java
0 → 100644
| 1 | +package com.bsth.vehicle.directive; | |
| 2 | + | |
| 3 | +import java.util.LinkedList; | |
| 4 | +import java.util.Set; | |
| 5 | + | |
| 6 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 7 | +import org.springframework.stereotype.Component; | |
| 8 | + | |
| 9 | +import com.bsth.entity.realcontrol.ScheduleRealInfo; | |
| 10 | +import com.bsth.service.realcontrol.buffer.ScheduleBuffer; | |
| 11 | +import com.bsth.vehicle.directive.service.DirectiveService; | |
| 12 | + | |
| 13 | +/** | |
| 14 | + * | |
| 15 | + * @ClassName: ScheduleIssuedThread | |
| 16 | + * @Description: TODO(首班调度指令下发线程) | |
| 17 | + * @author PanZhao | |
| 18 | + * @date 2016年6月29日 下午11:09:39 | |
| 19 | + * | |
| 20 | + */ | |
| 21 | +@Component | |
| 22 | +public class FirstScheduleIssuedThread extends Thread{ | |
| 23 | + | |
| 24 | + @Autowired | |
| 25 | + DirectiveService directiveService; | |
| 26 | + | |
| 27 | + @Override | |
| 28 | + public void run() { | |
| 29 | + | |
| 30 | + Set<String> keys = ScheduleBuffer.vehLinkedMap.keySet(); | |
| 31 | + LinkedList<ScheduleRealInfo> linkedList; | |
| 32 | + ScheduleRealInfo sch; | |
| 33 | + for(String nbbm : keys){ | |
| 34 | + linkedList = ScheduleBuffer.vehLinkedMap.get(nbbm); | |
| 35 | + | |
| 36 | + sch = linkedList.getFirst(); | |
| 37 | + | |
| 38 | + if(sch.getFcsjActual() == null) | |
| 39 | + directiveService.send60Dispatch(sch, 0); | |
| 40 | + } | |
| 41 | + } | |
| 42 | +} | ... | ... |
src/main/java/com/bsth/vehicle/directive/buffer/DirectiveBuffer.java
| ... | ... | @@ -105,13 +105,17 @@ public class DirectiveBuffer { |
| 105 | 105 | directive.setReply47((short)0); |
| 106 | 106 | break; |
| 107 | 107 | } |
| 108 | + | |
| 109 | + if(directive.isDispatch()){ | |
| 110 | + directive.getSch().setDirectiveState(reply.getStatus() * 100); | |
| 111 | + } | |
| 108 | 112 | transientList.add(directive); |
| 109 | 113 | } |
| 110 | 114 | |
| 111 | 115 | /** |
| 112 | 116 | * |
| 113 | 117 | * @Title: reply64 |
| 114 | - * @Description: TODO(64协议响应) | |
| 118 | + * @Description: TODO(64 协议响应) | |
| 115 | 119 | * @throws |
| 116 | 120 | */ |
| 117 | 121 | public void reply64(JSONObject json){ | ... | ... |
src/main/java/com/bsth/vehicle/directive/entity/Directive.java
| ... | ... | @@ -4,9 +4,12 @@ import javax.persistence.Embeddable; |
| 4 | 4 | import javax.persistence.Entity; |
| 5 | 5 | import javax.persistence.GeneratedValue; |
| 6 | 6 | import javax.persistence.Id; |
| 7 | +import javax.persistence.ManyToOne; | |
| 7 | 8 | import javax.persistence.Table; |
| 8 | 9 | import javax.persistence.Transient; |
| 9 | 10 | |
| 11 | +import com.bsth.entity.realcontrol.ScheduleRealInfo; | |
| 12 | + | |
| 10 | 13 | |
| 11 | 14 | /** |
| 12 | 15 | * |
| ... | ... | @@ -62,6 +65,17 @@ public class Directive { |
| 62 | 65 | */ |
| 63 | 66 | private Short reply47; |
| 64 | 67 | |
| 68 | + /** | |
| 69 | + * 是否是调度指令 | |
| 70 | + * 目前调度指令和消息短语都是短语下发,所以从协议上无法区分 | |
| 71 | + */ | |
| 72 | + private boolean isDispatch; | |
| 73 | + | |
| 74 | + /** | |
| 75 | + * 如果是调度指令,则关联到相关的班次 | |
| 76 | + */ | |
| 77 | + @ManyToOne | |
| 78 | + private ScheduleRealInfo sch; | |
| 65 | 79 | |
| 66 | 80 | @Embeddable |
| 67 | 81 | public static class DirectiveData { |
| ... | ... | @@ -235,4 +249,20 @@ public class Directive { |
| 235 | 249 | public void setReply47(Short reply47) { |
| 236 | 250 | this.reply47 = reply47; |
| 237 | 251 | } |
| 252 | + | |
| 253 | + public boolean isDispatch() { | |
| 254 | + return isDispatch; | |
| 255 | + } | |
| 256 | + | |
| 257 | + public void setDispatch(boolean isDispatch) { | |
| 258 | + this.isDispatch = isDispatch; | |
| 259 | + } | |
| 260 | + | |
| 261 | + public ScheduleRealInfo getSch() { | |
| 262 | + return sch; | |
| 263 | + } | |
| 264 | + | |
| 265 | + public void setSch(ScheduleRealInfo sch) { | |
| 266 | + this.sch = sch; | |
| 267 | + } | |
| 238 | 268 | } | ... | ... |
src/main/java/com/bsth/vehicle/directive/service/DirectiveService.java
| 1 | 1 | package com.bsth.vehicle.directive.service; |
| 2 | 2 | |
| 3 | 3 | |
| 4 | +import com.bsth.entity.realcontrol.ScheduleRealInfo; | |
| 4 | 5 | import com.bsth.service.BaseService; |
| 5 | 6 | import com.bsth.vehicle.directive.entity.Directive; |
| 6 | 7 | |
| ... | ... | @@ -17,7 +18,15 @@ public interface DirectiveService extends BaseService<Directive, Integer>{ |
| 17 | 18 | */ |
| 18 | 19 | int send60Phrase(String nbbm, String text); |
| 19 | 20 | |
| 20 | - int send60Dispatch(String nbbm, String text); | |
| 21 | + /** | |
| 22 | + * | |
| 23 | + * @Title: send60Dispatch | |
| 24 | + * @Description: TODO(调度指令下发) | |
| 25 | + * @param @param sch 要下发的班次 | |
| 26 | + * @param @param finish 已完成的班次数 | |
| 27 | + * @throws | |
| 28 | + */ | |
| 29 | + int send60Dispatch(ScheduleRealInfo sch, int finish); | |
| 21 | 30 | |
| 22 | 31 | //60营运指令 |
| 23 | 32 | int send60Operation(String nbbm, int state, int upDown); | ... | ... |
src/main/java/com/bsth/vehicle/directive/service/DirectiveServiceImpl.java
| 1 | 1 | package com.bsth.vehicle.directive.service; |
| 2 | 2 | |
| 3 | 3 | import java.io.IOException; |
| 4 | +import java.text.SimpleDateFormat; | |
| 5 | +import java.util.Date; | |
| 4 | 6 | |
| 5 | 7 | import org.apache.http.client.methods.CloseableHttpResponse; |
| 6 | 8 | import org.apache.http.client.methods.HttpPost; |
| ... | ... | @@ -15,6 +17,7 @@ import org.springframework.stereotype.Service; |
| 15 | 17 | |
| 16 | 18 | import com.alibaba.fastjson.JSON; |
| 17 | 19 | import com.alibaba.fastjson.JSONObject; |
| 20 | +import com.bsth.entity.realcontrol.ScheduleRealInfo; | |
| 18 | 21 | import com.bsth.service.impl.BaseServiceImpl; |
| 19 | 22 | import com.bsth.vehicle.common.CommonMapped; |
| 20 | 23 | import com.bsth.vehicle.directive.Consts; |
| ... | ... | @@ -44,13 +47,17 @@ public class DirectiveServiceImpl extends BaseServiceImpl<Directive, Integer> im |
| 44 | 47 | @Autowired |
| 45 | 48 | LineChangeRepository lineChangeRepository; |
| 46 | 49 | |
| 50 | + SimpleDateFormat sdfHHmm = new SimpleDateFormat("HH点mm分"); | |
| 51 | + | |
| 52 | + static Long schDiff = 1000 * 60 * 6L; | |
| 53 | + | |
| 47 | 54 | @Override |
| 48 | 55 | public int send60Phrase(String nbbm, String text) { |
| 49 | 56 | Directive directive = null; |
| 50 | 57 | try { |
| 51 | 58 | directive = create60Data(nbbm, text, DispatchInstruct.PHRASE); |
| 52 | 59 | } catch (Exception e) { |
| 53 | - logger.error("生成调度指令时出现异常", e); | |
| 60 | + logger.error("发送消息短语出现异常", e); | |
| 54 | 61 | return -1; |
| 55 | 62 | } |
| 56 | 63 | |
| ... | ... | @@ -70,8 +77,40 @@ public class DirectiveServiceImpl extends BaseServiceImpl<Directive, Integer> im |
| 70 | 77 | } |
| 71 | 78 | |
| 72 | 79 | @Override |
| 73 | - public int send60Dispatch(String nbbm, String text) { | |
| 74 | - return 0; | |
| 80 | + public int send60Dispatch(ScheduleRealInfo sch, int finish) { | |
| 81 | + Directive directive = null; | |
| 82 | + try { | |
| 83 | + //如果发车时间距当前时间较远,则不发送 | |
| 84 | + if(Math.abs(sch.getFcsjT() - System.currentTimeMillis()) > schDiff){ | |
| 85 | + return 0; | |
| 86 | + } | |
| 87 | + | |
| 88 | + String text = "已完成" + finish + "个班次,下一发车时间" + sdfHHmm.format(new Date(sch.getFcsjT())) | |
| 89 | + + ",由" + sch.getQdzName() + "发往" + sch.getZdzName(); | |
| 90 | + | |
| 91 | + //目前使用短语协议下发调度指令 | |
| 92 | + directive = create60Data(sch.getClZbh(), text, DispatchInstruct.PHRASE); | |
| 93 | + } catch (Exception e) { | |
| 94 | + logger.error("生成调度指令时出现异常", e); | |
| 95 | + return -1; | |
| 96 | + } | |
| 97 | + | |
| 98 | + if(null == directive) | |
| 99 | + return -1; | |
| 100 | + | |
| 101 | + //发送指令 | |
| 102 | + int code = postJson(JSON.toJSONString(directive)); | |
| 103 | + | |
| 104 | + if(code == 0){ | |
| 105 | + sch.setDirectiveState(60); | |
| 106 | + //添加到缓存,等待入库 | |
| 107 | + directive.setDispatch(true); | |
| 108 | + directive.setSch(sch); | |
| 109 | + DirectiveBuffer.put(directive); | |
| 110 | + }else{ | |
| 111 | + logger.error("send60Phrase error, code: " + code); | |
| 112 | + } | |
| 113 | + return code; | |
| 75 | 114 | } |
| 76 | 115 | |
| 77 | 116 | @Override | ... | ... |
src/main/java/com/bsth/vehicle/gpsdata/GpsArrivalStationThread.java
| ... | ... | @@ -13,12 +13,14 @@ import java.util.Set; |
| 13 | 13 | |
| 14 | 14 | import org.slf4j.Logger; |
| 15 | 15 | import org.slf4j.LoggerFactory; |
| 16 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 16 | 17 | import org.springframework.stereotype.Component; |
| 17 | 18 | |
| 18 | 19 | import com.bsth.entity.realcontrol.ScheduleRealInfo; |
| 19 | 20 | import com.bsth.service.realcontrol.buffer.ScheduleBuffer; |
| 20 | 21 | import com.bsth.util.DateUtils; |
| 21 | 22 | import com.bsth.util.db.DBUtils_MS; |
| 23 | +import com.bsth.vehicle.directive.service.DirectiveService; | |
| 22 | 24 | import com.bsth.vehicle.gpsdata.buffer.GpsArrivalDataBuffer; |
| 23 | 25 | import com.bsth.vehicle.gpsdata.entity.ArrivalInfo; |
| 24 | 26 | |
| ... | ... | @@ -36,6 +38,9 @@ public class GpsArrivalStationThread extends Thread{ |
| 36 | 38 | Logger logger = LoggerFactory.getLogger(this.getClass()); |
| 37 | 39 | SimpleDateFormat sdf = new SimpleDateFormat("HH:mm"); |
| 38 | 40 | |
| 41 | + @Autowired | |
| 42 | + DirectiveService directiveService; | |
| 43 | + | |
| 39 | 44 | private static int diff = 1000 * 60 * 20; |
| 40 | 45 | |
| 41 | 46 | @Override |
| ... | ... | @@ -53,7 +58,7 @@ public class GpsArrivalStationThread extends Thread{ |
| 53 | 58 | System.out.println("开始..."); |
| 54 | 59 | List<ScheduleRealInfo> schList; |
| 55 | 60 | for(String key : keySet){ |
| 56 | - schList = ScheduleBuffer.vehLinkedMap.get(key); | |
| 61 | + schList = extractSched(ScheduleBuffer.vehLinkedMap.get(key)); | |
| 57 | 62 | if(null != schList) |
| 58 | 63 | match(GpsArrivalDataBuffer.allMap.get(key), schList); |
| 59 | 64 | } |
| ... | ... | @@ -104,7 +109,7 @@ public class GpsArrivalStationThread extends Thread{ |
| 104 | 109 | */ |
| 105 | 110 | public void matchStart(ScheduleRealInfo scInfo, ArrivalInfo arr){ |
| 106 | 111 | if(scInfo.getFcsjT() == null |
| 107 | - || arr.getInOut() != 1) | |
| 112 | + || arr.getInOut() != 1 || scInfo.getFcsjActual() != null) | |
| 108 | 113 | return; |
| 109 | 114 | |
| 110 | 115 | Long ts = arr.getTs(); |
| ... | ... | @@ -115,6 +120,8 @@ public class GpsArrivalStationThread extends Thread{ |
| 115 | 120 | scInfo.setFcsjActual(sdf.format(ts)); |
| 116 | 121 | |
| 117 | 122 | System.out.println("成功匹配一个起点..."); |
| 123 | + //班次状态改为正在执行 | |
| 124 | + scInfo.setStatus(1); | |
| 118 | 125 | ScheduleBuffer.persistentList.add(scInfo); |
| 119 | 126 | } |
| 120 | 127 | } |
| ... | ... | @@ -127,7 +134,7 @@ public class GpsArrivalStationThread extends Thread{ |
| 127 | 134 | */ |
| 128 | 135 | public void matchEnd(ScheduleRealInfo scInfo, ArrivalInfo arr){ |
| 129 | 136 | if(scInfo.getZdsjT() == null |
| 130 | - || arr.getInOut() != 0) | |
| 137 | + || arr.getInOut() != 0 || scInfo.getZdsjActual() != null) | |
| 131 | 138 | return; |
| 132 | 139 | |
| 133 | 140 | Long ts = arr.getTs(); |
| ... | ... | @@ -138,7 +145,10 @@ public class GpsArrivalStationThread extends Thread{ |
| 138 | 145 | scInfo.setZdsjActual(sdf.format(ts)); |
| 139 | 146 | |
| 140 | 147 | System.out.println("成功匹配一个终点..."); |
| 141 | - ScheduleBuffer.persistentList.add(scInfo); | |
| 148 | + //完成当前班次 | |
| 149 | + ScheduleRealInfo nextSch = ScheduleBuffer.finishSch(scInfo); | |
| 150 | + //到达终点,发送下一班次的调度指令 | |
| 151 | + directiveService.send60Dispatch(nextSch, ScheduleBuffer.getFinishSchNo(nextSch.getClZbh())); | |
| 142 | 152 | } |
| 143 | 153 | } |
| 144 | 154 | |
| ... | ... | @@ -190,4 +200,26 @@ public class GpsArrivalStationThread extends Thread{ |
| 190 | 200 | } |
| 191 | 201 | return list; |
| 192 | 202 | } |
| 203 | + | |
| 204 | + Long rang = 1000 * 60 * 60L; | |
| 205 | + /** | |
| 206 | + * | |
| 207 | + * @Title: extractSched | |
| 208 | + * @Description: TODO(提取当前时间前后一小时的计划) | |
| 209 | + * @param @param allList | |
| 210 | + * @throws | |
| 211 | + */ | |
| 212 | + public List<ScheduleRealInfo> extractSched(List<ScheduleRealInfo> allList){ | |
| 213 | + List<ScheduleRealInfo> subList = new ArrayList<>(); | |
| 214 | + System.out.println("原计划:" + allList.size()); | |
| 215 | + Long t = System.currentTimeMillis(); | |
| 216 | + for(ScheduleRealInfo sch : allList){ | |
| 217 | + if(Math.abs(sch.getFcsjT() - t) < rang | |
| 218 | + || Math.abs(sch.getZdsjT()) - t < rang){ | |
| 219 | + subList.add(sch); | |
| 220 | + } | |
| 221 | + } | |
| 222 | + System.out.println("按时间提取:" + subList.size()); | |
| 223 | + return subList; | |
| 224 | + } | |
| 193 | 225 | } | ... | ... |
src/main/java/com/bsth/vehicle/gpsdata/GpsRefreshThread.java
| ... | ... | @@ -68,7 +68,6 @@ public class GpsRefreshThread extends Thread{ |
| 68 | 68 | Set<Integer> upLines = new HashSet<>(); |
| 69 | 69 | |
| 70 | 70 | for(GpsRealData newData : newList){ |
| 71 | - | |
| 72 | 71 | oldGps = deviceMap.get(newData.getDeviceId()); |
| 73 | 72 | |
| 74 | 73 | //新的GPS点 |
| ... | ... | @@ -99,8 +98,8 @@ public class GpsRefreshThread extends Thread{ |
| 99 | 98 | * @throws |
| 100 | 99 | */ |
| 101 | 100 | public List<GpsRealData> getterRealGpsData() throws Exception{ |
| 102 | - List<GpsRealData> list = new ArrayList<>(); | |
| 103 | - | |
| 101 | + List<GpsRealData> list = new ArrayList<>() | |
| 102 | + ,rs = new ArrayList<>(); | |
| 104 | 103 | CloseableHttpClient httpClient = null; |
| 105 | 104 | |
| 106 | 105 | try { |
| ... | ... | @@ -122,8 +121,14 @@ public class GpsRefreshThread extends Thread{ |
| 122 | 121 | |
| 123 | 122 | JSONObject jsonObj = JSON.parseObject(stringBuffer.toString()); |
| 124 | 123 | |
| 125 | - if(jsonObj != null) | |
| 124 | + if(jsonObj != null){ | |
| 126 | 125 | list = JSON.parseArray(jsonObj.getString("data"), GpsRealData.class); |
| 126 | + //将无效的经纬度过滤掉 | |
| 127 | + for(GpsRealData gps : list){ | |
| 128 | + if(gps.getLat() != 0 && gps.getLon() != 0) | |
| 129 | + rs.add(gps); | |
| 130 | + } | |
| 131 | + } | |
| 127 | 132 | } |
| 128 | 133 | else |
| 129 | 134 | logger.error("result is null"); |
| ... | ... | @@ -135,6 +140,6 @@ public class GpsRefreshThread extends Thread{ |
| 135 | 140 | if(null != httpClient) |
| 136 | 141 | httpClient.close(); |
| 137 | 142 | } |
| 138 | - return list; | |
| 143 | + return rs; | |
| 139 | 144 | } |
| 140 | 145 | } | ... | ... |
src/main/java/com/bsth/vehicle/gpsdata/buffer/GpsArrivalDataBuffer.java
src/main/java/com/bsth/vehicle/gpsdata/service/GpsDataServiceImpl.java
| ... | ... | @@ -34,7 +34,7 @@ public class GpsDataServiceImpl implements GpsDataService{ |
| 34 | 34 | return null; |
| 35 | 35 | }*/ |
| 36 | 36 | |
| 37 | - String sql = "select DEVICE_ID,LON,LAT,TS,INOUT_STOP,SERVICE_STATE from BSTH_C_GPS_INFO where days_year=? and device_id=? and ts > ? and ts < ?"; | |
| 37 | + String sql = "select DEVICE_ID,LON,LAT,TS,INOUT_STOP,SERVICE_STATE ,STOP_NO from BSTH_C_GPS_INFO where days_year=? and device_id=? and ts > ? and ts < ?"; | |
| 38 | 38 | Connection conn = null; |
| 39 | 39 | PreparedStatement ps = null; |
| 40 | 40 | ResultSet rs = null; |
| ... | ... | @@ -68,6 +68,7 @@ public class GpsDataServiceImpl implements GpsDataService{ |
| 68 | 68 | map.put("lon", location.getLng()); |
| 69 | 69 | map.put("lat", location.getLat()); |
| 70 | 70 | map.put("ts", rs.getLong("TS")); |
| 71 | + map.put("stopNo", rs.getString("STOP_NO")); | |
| 71 | 72 | map.put("inout_stop", rs.getInt("INOUT_STOP")); |
| 72 | 73 | //上下行 |
| 73 | 74 | map.put("upDown", upDown); | ... | ... |
src/main/resources/static/gpsTest/test.html
| ... | ... | @@ -99,6 +99,8 @@ form .item select{ |
| 99 | 99 | |
| 100 | 100 | var inOuts = [outMark, inMark]; |
| 101 | 101 | |
| 102 | + var stationCodeMap = {}; | |
| 103 | + | |
| 102 | 104 | var map = new BMap.Map("mapContainer"); |
| 103 | 105 | map.centerAndZoom(new BMap.Point(121.544336, 31.221315), 15); |
| 104 | 106 | map.enableScrollWheelZoom(); |
| ... | ... | @@ -123,7 +125,9 @@ form .item select{ |
| 123 | 125 | var array = rs[0].children[0].children |
| 124 | 126 | ,coords,circle, cdsArray, points, polygon; |
| 125 | 127 | //画出站点 |
| 128 | + console.log(array); | |
| 126 | 129 | $.each(array, function(){ |
| 130 | + stationCodeMap[this.stationStationCod] = this.name; | |
| 127 | 131 | if(this.stationShapesType === 'r'){ |
| 128 | 132 | //画圆 |
| 129 | 133 | coords = this.stationBJwpoints.split(' '); |
| ... | ... | @@ -158,11 +162,13 @@ form .item select{ |
| 158 | 162 | point = new BMap.Point(this.lon, this.lat); |
| 159 | 163 | marker = new BMap.Marker(point); |
| 160 | 164 | state = this.inout_stop; |
| 161 | - //inOuts | |
| 165 | + | |
| 162 | 166 | if(state == 0 || state == 1){ |
| 163 | 167 | text = state == 0?'出':'进'; |
| 164 | 168 | marker.setIcon(new BMap.Icon(inOuts[this.inout_stop], new BMap.Size(25,25))); |
| 165 | - label = new BMap.Label(moment(this.ts).format('HH:mm') + ' -'+text, {position: point, offset: new BMap.Size(-5,-18)}); | |
| 169 | + label = new BMap.Label( | |
| 170 | + stationCodeMap[this.stopNo] + '/' +moment(this.ts).format('HH:mm') + ' -'+text | |
| 171 | + , {position: point, offset: new BMap.Size(-25,-18)}); | |
| 166 | 172 | marker.setLabel(label); |
| 167 | 173 | } |
| 168 | 174 | map.addOverlay(marker); | ... | ... |
src/main/resources/static/index.html
| ... | ... | @@ -281,9 +281,9 @@ tr.row-active td { |
| 281 | 281 | <script src="http://api.map.baidu.com/api?v=2.0&ak=IGGrr4UjwIYzatoCRFKEL8sT" data-exclude=1></script> |
| 282 | 282 | <script src="http://api.map.baidu.com/library/TrafficControl/1.4/src/TrafficControl_min.js" data-exclude=1></script> |
| 283 | 283 | <script type="text/javascript" src="http://api.map.baidu.com/library/DrawingManager/1.4/src/DrawingManager_min.js" data-exclude=1></script> |
| 284 | -<script type="text/javascript" src="http://api.map.baidu.com/library/RichMarker/1.2/src/RichMarker_min.js "> | |
| 285 | -<script src="/assets/js/baidu/TextIconOverlay.js"></script> | |
| 286 | -<script src="/assets/js/baidu//MarkerClusterer.js"></script> | |
| 284 | +<script type="text/javascript" src="http://api.map.baidu.com/library/RichMarker/1.2/src/RichMarker_min.js " data-exclude=1></script> | |
| 285 | +<script src="/assets/js/baidu/TextIconOverlay.js" data-exclude=1></script> | |
| 286 | +<script src="/assets/js/baidu//MarkerClusterer.js" data-exclude=1></script> | |
| 287 | 287 | <!-- 高德 --> |
| 288 | 288 | <script src="http://webapi.amap.com/maps?v=1.3&key=16cb1c5043847e09ef9edafdd77befda" data-exclude=1></script> |
| 289 | 289 | ... | ... |
src/main/resources/static/pages/control/line/child_pages/child_task.html
| ... | ... | @@ -325,7 +325,6 @@ $(function(){ |
| 325 | 325 | lineInformation = _data.getLineInformation(schedul.xlBm); |
| 326 | 326 | //线路 ——> 路牌 ——> 班次映射 |
| 327 | 327 | scheduleLineMap = _data.getLineLpMap(); |
| 328 | - | |
| 329 | 328 | //线路下拉框数据 |
| 330 | 329 | lineCodeMaps = _data.getLineIds(); |
| 331 | 330 | for(var lineCode in scheduleLineMap){ |
| ... | ... | @@ -369,8 +368,8 @@ $(function(){ |
| 369 | 368 | refreshMainList(); |
| 370 | 369 | }); |
| 371 | 370 | } |
| 372 | - | |
| 373 | - jsyAndSpyInit(lineCode); | |
| 371 | + //更新临加表单的车辆和人员下拉框 | |
| 372 | + carAndPersInit(lineCode); | |
| 374 | 373 | } |
| 375 | 374 | |
| 376 | 375 | /** |
| ... | ... | @@ -388,7 +387,7 @@ $(function(){ |
| 388 | 387 | |
| 389 | 388 | var schArray = []; |
| 390 | 389 | $.each(scheduls, function(){ |
| 391 | - schArray[this.fcno] = this; | |
| 390 | + schArray[this.fcno - 1] = this; | |
| 392 | 391 | }); |
| 393 | 392 | |
| 394 | 393 | var htmlStr = template('child_task_main_table_temp', {list: schArray}); |
| ... | ... | @@ -407,16 +406,20 @@ $(function(){ |
| 407 | 406 | /** ----------- 临加班次相关 ----------*/ |
| 408 | 407 | //初始化临加班次表单 |
| 409 | 408 | $('#schedulTempAddPabel').append(template('schedul_add_form_temp', {})); |
| 410 | - //初始化驾驶员和售票员下拉框,每次切换线路时调用 | |
| 411 | - var jsyAndSpyInit = function(lineCode){ | |
| 409 | + //初始化车辆和人员下拉框,每次切换线路时调用 | |
| 410 | + var carAndPersInit = function(lineCode){ | |
| 412 | 411 | //驾驶员 |
| 413 | 412 | $.get('/realSchedule/driver', {lineCode: lineCode}, function(rs){ |
| 414 | - initPinYinSelect2('select[name=jGh]', rs); | |
| 413 | + initPinYinSelect2('#schedulTempAddPabel select[name=jGh]', rs); | |
| 415 | 414 | |
| 416 | 415 | }); |
| 417 | 416 | //售票员 |
| 418 | 417 | $.get('/realSchedule/conductor', {lineCode: lineCode}, function(rs){ |
| 419 | - initPinYinSelect2('select[name=sGh]', rs); | |
| 418 | + initPinYinSelect2('#schedulTempAddPabel select[name=sGh]', rs); | |
| 419 | + }); | |
| 420 | + //车辆 | |
| 421 | + $.get('/realSchedule/cars', {lineCode: lineCode}, function(rs){ | |
| 422 | + $('#schedulTempAddPabel select[name=clZbh]').select2({data: rs}); | |
| 420 | 423 | }); |
| 421 | 424 | }; |
| 422 | 425 | |
| ... | ... | @@ -429,12 +432,11 @@ $(function(){ |
| 429 | 432 | schAddPanel.on('show', function(e, tr){ |
| 430 | 433 | $(this).show(); |
| 431 | 434 | $('input.no', schAddPanel).val($(tr.cells[0]).text()); |
| 435 | + $('select[name=xlDir]', schAddPanel).trigger('change'); | |
| 432 | 436 | }); |
| 433 | 437 | //切换上下行 |
| 434 | 438 | $(schAddPanel).on('change', 'select[name=xlDir]', function(){ |
| 435 | 439 | var t = $(this).val(); |
| 436 | - if(!t) | |
| 437 | - return; | |
| 438 | 440 | |
| 439 | 441 | var arr = stationRoute[t] |
| 440 | 442 | ,ss = arr[0].stationCode |
| ... | ... | @@ -442,7 +444,6 @@ $(function(){ |
| 442 | 444 | ,ops = createSelectOps(arr, 'stationCode', 'stationName'); |
| 443 | 445 | schAddQdz.html(ops).val(ss); |
| 444 | 446 | schAddZdz.html(ops).val(es); |
| 445 | - | |
| 446 | 447 | //里程 |
| 447 | 448 | var mileage; |
| 448 | 449 | if(t == 0) |
| ... | ... | @@ -452,6 +453,51 @@ $(function(){ |
| 452 | 453 | |
| 453 | 454 | $('input[name=jhlc]', schAddPanel).val(mileage); |
| 454 | 455 | }); |
| 456 | + //切换班次类型 | |
| 457 | + $(schAddPanel).on('change', 'select[name=bcType]', function(){ | |
| 458 | + var type = $(this).val() | |
| 459 | + ,upDown = $('select[name=xlDir]', schAddPanel) | |
| 460 | + ,routes = stationRoute[upDown]; | |
| 461 | + //起点停车场 | |
| 462 | + switch (type) { | |
| 463 | + case 'out': | |
| 464 | + schAddQdz.html(parkSelectOps).val(lineInformation.carPark); | |
| 465 | + break; | |
| 466 | + case 'in': | |
| 467 | + schAddZdz.html(parkSelectOps).val(lineInformation.carPark); | |
| 468 | + break; | |
| 469 | + } | |
| 470 | + | |
| 471 | + var zdHtml = createSelectOps(routes, 'stationCode', 'stationName'); | |
| 472 | + //schAddZdz.html(zdHtml).val(); | |
| 473 | + }); | |
| 474 | + | |
| 475 | + //提交临加班次 | |
| 476 | + $('.confirm', schAddPanel).on('click', function(){ | |
| 477 | + var f = $('form', schAddPanel); | |
| 478 | + var param = f.serializeJSON(); | |
| 479 | + /** 页面组装数据 */ | |
| 480 | + //线路 | |
| 481 | + param.xlBm = lineSelect.val(); | |
| 482 | + param.xlName = _data.getLineIds()[param.xlBm]; | |
| 483 | + //路牌 | |
| 484 | + param.lpName = lpSelect.val(); | |
| 485 | + //拆分驾驶员工号和姓名 | |
| 486 | + param.jName = param.jGh.split('/')[1]; | |
| 487 | + param.jGh = param.jGh.split('/')[0]; | |
| 488 | + //拆分售票员工号和姓名 | |
| 489 | + param.sName = param.sGh.split('/')[1]; | |
| 490 | + param.sGh = param.sGh.split('/')[0]; | |
| 491 | + //附加起终点名称 | |
| 492 | + var route = stationRoute[param.xlDir]; | |
| 493 | + param.qdzName = searchStationName(route, param.qdzCode); | |
| 494 | + param.zdzName = searchStationName(route, param.zdzCode); | |
| 495 | + | |
| 496 | + $post('/realSchedule', param, function(rs){ | |
| 497 | + //前端缓存更新 | |
| 498 | + scheduleLineMap[param.xlBm][param.lpName].push(rs.t); | |
| 499 | + }); | |
| 500 | + }); | |
| 455 | 501 | |
| 456 | 502 | function createSelectOps(selectData, id, text){ |
| 457 | 503 | var ops = ''; |
| ... | ... | @@ -460,5 +506,13 @@ $(function(){ |
| 460 | 506 | }); |
| 461 | 507 | return ops; |
| 462 | 508 | } |
| 509 | + | |
| 510 | + //在路由里根据站点编码搜索站点名 | |
| 511 | + function searchStationName(route, code){ | |
| 512 | + for(var i = 0, r; r = route[i++];){ | |
| 513 | + if(r.stationCode == code) | |
| 514 | + return r.stationName; | |
| 515 | + } | |
| 516 | + } | |
| 463 | 517 | }); |
| 464 | 518 | </script> | ... | ... |
src/main/resources/static/pages/control/line/js/alone.js
src/main/resources/static/pages/control/line/js/data.js
| ... | ... | @@ -85,16 +85,14 @@ var _data = (function(){ |
| 85 | 85 | $.each(list, function(){ |
| 86 | 86 | //发车时间 + 历时 = 终点时间 |
| 87 | 87 | if(this.bcsj){ |
| 88 | - sm = moment(dateStr + ' ' + this.fcsj, 'YYYY-MM-DD HH:mm'); | |
| 88 | + sm = moment(this.fcsjT); | |
| 89 | 89 | em = sm.add(this.bcsj, 'minutes'); |
| 90 | - //发车时间戳 | |
| 91 | - this.fcsjT = sm.valueOf(); | |
| 92 | 90 | this.zdsj = em.format('HH:mm'); |
| 93 | 91 | //终点时间戳 |
| 94 | 92 | this.zdsjT = em.valueOf(); |
| 95 | 93 | } |
| 96 | 94 | |
| 97 | - //缓存实际排班计划 | |
| 95 | + //缓存排班计划 | |
| 98 | 96 | schedules[this.id] = this; |
| 99 | 97 | scheduleList.push(this); |
| 100 | 98 | ... | ... |
src/main/resources/static/pages/control/line/temps/alone_tp.html
| ... | ... | @@ -153,8 +153,8 @@ |
| 153 | 153 | <td data-name="clZbh">{{item.clZbh}}</td> |
| 154 | 154 | <td data-name="zdsj">{{item.zdsj}}</td> |
| 155 | 155 | <td></td> |
| 156 | - <td data-name="fcsj">{{item.fcsj}}</td> | |
| 157 | - <td data-name="dfsj">{{item.dfsj}}</td> | |
| 156 | + <td data-name="fcsj" data-time="{{item.fcsjT}}">{{item.fcsj}}</td> | |
| 157 | + <td data-name="dfsj" data-time="{{item.zdsjT}}">{{item.dfsj}}</td> | |
| 158 | 158 | |
| 159 | 159 | {{if item.status == -1}} |
| 160 | 160 | <td class="tl-qrlb">烂班</td> | ... | ... |
src/main/resources/static/pages/control/line/temps/child_task_case_tp.html
| ... | ... | @@ -421,20 +421,20 @@ |
| 421 | 421 | <div class="row"> |
| 422 | 422 | <div class="col-md-4"> |
| 423 | 423 | <span class="custom-label">班次类型: </span> |
| 424 | - <select class="form-control nt-dictionary" data-group="ScheduleType" name="bcType"></select> | |
| 424 | + <select class="form-control nt-dictionary" data-group="ScheduleType" data-code="normal" name="bcType"></select> | |
| 425 | 425 | </div> |
| 426 | 426 | <div class="col-md-4"> |
| 427 | 427 | </div> |
| 428 | 428 | <div class="col-md-4"> |
| 429 | 429 | <span class="custom-label">上下行: </span> |
| 430 | - <select class="form-control nt-dictionary" data-group="LineTrend" name="xlDir" ></select> | |
| 430 | + <select class="form-control nt-dictionary" data-group="LineTrend" name="xlDir" data-code=0></select> | |
| 431 | 431 | </div> |
| 432 | 432 | </div> |
| 433 | 433 | |
| 434 | 434 | <div class="row"> |
| 435 | 435 | <div class="col-md-4"> |
| 436 | 436 | <span class="custom-label">序号: </span> |
| 437 | - <input class="form-control no" disabled> | |
| 437 | + <input class="form-control no" readonly name="fcno" > | |
| 438 | 438 | </div> |
| 439 | 439 | <div class="col-md-4"> |
| 440 | 440 | <span class="custom-label">开始时间: </span> | ... | ... |