Commit 39ac8765819dfd3cd2af2778b5066391eeb85996
1 parent
bf72abb6
update
Showing
9 changed files
with
139 additions
and
33 deletions
src/main/java/com/bsth/entity/schedule/SchedulePlanInfo.java
| @@ -135,11 +135,11 @@ public class SchedulePlanInfo { | @@ -135,11 +135,11 @@ public class SchedulePlanInfo { | ||
| 135 | 135 | ||
| 136 | 136 | ||
| 137 | @ManyToOne(cascade = CascadeType.PERSIST, fetch = FetchType.LAZY) | 137 | @ManyToOne(cascade = CascadeType.PERSIST, fetch = FetchType.LAZY) |
| 138 | -/* @JoinTable( | 138 | + @JoinTable( |
| 139 | name = "bsth_c_s_sp_r_info", | 139 | name = "bsth_c_s_sp_r_info", |
| 140 | joinColumns = @JoinColumn(name = "sp_info_id"), | 140 | joinColumns = @JoinColumn(name = "sp_info_id"), |
| 141 | inverseJoinColumns = @JoinColumn(name = "sp_id") | 141 | inverseJoinColumns = @JoinColumn(name = "sp_id") |
| 142 | - )*/ | 142 | + ) |
| 143 | private SchedulePlan schedulePlan; | 143 | private SchedulePlan schedulePlan; |
| 144 | 144 | ||
| 145 | public SchedulePlanInfo() {} | 145 | public SchedulePlanInfo() {} |
src/main/java/com/bsth/service/realcontrol/buffer/GetSchedulePlanThread.java
| @@ -41,8 +41,10 @@ public class GetSchedulePlanThread extends Thread{ | @@ -41,8 +41,10 @@ public class GetSchedulePlanThread extends Thread{ | ||
| 41 | @Override | 41 | @Override |
| 42 | public void run() { | 42 | public void run() { |
| 43 | try{ | 43 | try{ |
| 44 | + ScheduleBuffer.clear(); | ||
| 45 | + | ||
| 44 | List<ScheduleRealInfo> realList = null; | 46 | List<ScheduleRealInfo> realList = null; |
| 45 | - String dateStr = /*sdf.format(new Date())*/"2016-06-01"; | 47 | + String dateStr = sdfyyyyMMdd.format(new Date()); |
| 46 | Date cDate = sdfyyyyMMdd.parse(dateStr); | 48 | Date cDate = sdfyyyyMMdd.parse(dateStr); |
| 47 | //查询数据库是否有今日排班 | 49 | //查询数据库是否有今日排班 |
| 48 | int size = scheduleRealInfoRepository.countByDate(cDate); | 50 | int size = scheduleRealInfoRepository.countByDate(cDate); |
src/main/java/com/bsth/vehicle/directive/service/DirectiveServiceImpl.java
| @@ -110,7 +110,6 @@ public class DirectiveServiceImpl extends BaseServiceImpl<Directive60, Integer> | @@ -110,7 +110,6 @@ public class DirectiveServiceImpl extends BaseServiceImpl<Directive60, Integer> | ||
| 110 | directive.setDispatch(true); | 110 | directive.setDispatch(true); |
| 111 | directive.setSch(sch); | 111 | directive.setSch(sch); |
| 112 | DirectiveBuffer.put(directive); | 112 | DirectiveBuffer.put(directive); |
| 113 | - | ||
| 114 | //通知页面,消息已发出 | 113 | //通知页面,消息已发出 |
| 115 | sendDirectiveState(sch); | 114 | sendDirectiveState(sch); |
| 116 | }else{ | 115 | }else{ |
src/main/java/com/bsth/vehicle/directive/thread/FirstScheduleIssuedThread.java
| @@ -35,7 +35,9 @@ public class FirstScheduleIssuedThread extends Thread{ | @@ -35,7 +35,9 @@ public class FirstScheduleIssuedThread extends Thread{ | ||
| 35 | 35 | ||
| 36 | sch = linkedList.getFirst(); | 36 | sch = linkedList.getFirst(); |
| 37 | 37 | ||
| 38 | - if(sch.getFcsjActual() == null) | 38 | + //没有完成班次,且头班车没有发车时间 |
| 39 | + if(!ScheduleBuffer.finishLinkedMap.containsKey(nbbm) | ||
| 40 | + && sch.getFcsjActual() == null) | ||
| 39 | directiveService.send60Dispatch(sch, 0); | 41 | directiveService.send60Dispatch(sch, 0); |
| 40 | } | 42 | } |
| 41 | } | 43 | } |
src/main/java/com/bsth/vehicle/gpsdata/GpsArrivalStationThread.java
| @@ -8,7 +8,9 @@ import java.text.SimpleDateFormat; | @@ -8,7 +8,9 @@ import java.text.SimpleDateFormat; | ||
| 8 | import java.util.ArrayList; | 8 | import java.util.ArrayList; |
| 9 | import java.util.Calendar; | 9 | import java.util.Calendar; |
| 10 | import java.util.Date; | 10 | import java.util.Date; |
| 11 | +import java.util.HashSet; | ||
| 11 | import java.util.Iterator; | 12 | import java.util.Iterator; |
| 13 | +import java.util.LinkedList; | ||
| 12 | import java.util.List; | 14 | import java.util.List; |
| 13 | import java.util.Set; | 15 | import java.util.Set; |
| 14 | 16 | ||
| @@ -22,6 +24,7 @@ import com.bsth.entity.realcontrol.ScheduleRealInfo; | @@ -22,6 +24,7 @@ import com.bsth.entity.realcontrol.ScheduleRealInfo; | ||
| 22 | import com.bsth.service.realcontrol.buffer.ScheduleBuffer; | 24 | import com.bsth.service.realcontrol.buffer.ScheduleBuffer; |
| 23 | import com.bsth.util.DateUtils; | 25 | import com.bsth.util.DateUtils; |
| 24 | import com.bsth.util.db.DBUtils_MS; | 26 | import com.bsth.util.db.DBUtils_MS; |
| 27 | +import com.bsth.vehicle.common.CommonMapped; | ||
| 25 | import com.bsth.vehicle.directive.service.DirectiveService; | 28 | import com.bsth.vehicle.directive.service.DirectiveService; |
| 26 | import com.bsth.vehicle.gpsdata.buffer.GpsArrivalDataBuffer; | 29 | import com.bsth.vehicle.gpsdata.buffer.GpsArrivalDataBuffer; |
| 27 | import com.bsth.vehicle.gpsdata.entity.ArrivalInfo; | 30 | import com.bsth.vehicle.gpsdata.entity.ArrivalInfo; |
| @@ -57,7 +60,33 @@ public class GpsArrivalStationThread extends Thread{ | @@ -57,7 +60,33 @@ public class GpsArrivalStationThread extends Thread{ | ||
| 57 | } catch (ParseException e) { | 60 | } catch (ParseException e) { |
| 58 | e.printStackTrace(); | 61 | e.printStackTrace(); |
| 59 | } | 62 | } |
| 63 | + //缓存 | ||
| 60 | GpsArrivalDataBuffer.putAll(list); | 64 | GpsArrivalDataBuffer.putAll(list); |
| 65 | + | ||
| 66 | + //车辆 | ||
| 67 | + Set<String> set = new HashSet<>(); | ||
| 68 | + for(ArrivalInfo arr : list) | ||
| 69 | + set.add(CommonMapped.vehicDeviceBiMap.get(arr.getDeviceId())); | ||
| 70 | + | ||
| 71 | + List<ArrivalInfo> rsList = null; | ||
| 72 | + LinkedList<ScheduleRealInfo> linked = null; | ||
| 73 | + int[] status; | ||
| 74 | + ScheduleRealInfo sch; | ||
| 75 | + for(String nbbm : set){ | ||
| 76 | + rsList = GpsArrivalDataBuffer.pops(nbbm); | ||
| 77 | + //和该车辆未执行班次进行匹配 | ||
| 78 | + linked = ScheduleBuffer.vehLinkedMap.get(nbbm); | ||
| 79 | + | ||
| 80 | + if(null == linked || linked.size() == 0) | ||
| 81 | + continue; | ||
| 82 | + //第一个未执行班次 | ||
| 83 | + sch = linked.getFirst(); | ||
| 84 | + | ||
| 85 | + //匹配结果 | ||
| 86 | + status = match(rsList, sch); | ||
| 87 | + } | ||
| 88 | + // | ||
| 89 | + /*GpsArrivalDataBuffer.putAll(list); | ||
| 61 | //实际到离站和计划排班相匹配 | 90 | //实际到离站和计划排班相匹配 |
| 62 | 91 | ||
| 63 | Set<String> keySet = GpsArrivalDataBuffer.allMap.keySet(); | 92 | Set<String> keySet = GpsArrivalDataBuffer.allMap.keySet(); |
| @@ -68,7 +97,42 @@ public class GpsArrivalStationThread extends Thread{ | @@ -68,7 +97,42 @@ public class GpsArrivalStationThread extends Thread{ | ||
| 68 | if(null != schList) | 97 | if(null != schList) |
| 69 | match(GpsArrivalDataBuffer.allMap.get(key), schList); | 98 | match(GpsArrivalDataBuffer.allMap.get(key), schList); |
| 70 | } | 99 | } |
| 71 | - System.out.println("结束..."); | 100 | + System.out.println("结束...");*/ |
| 101 | + } | ||
| 102 | + | ||
| 103 | + public int[] match(List<ArrivalInfo> arrList, ScheduleRealInfo sch){ | ||
| 104 | + //进出分组 | ||
| 105 | + List<ArrivalInfo> in = new ArrayList<>(), out = new ArrayList<>(); | ||
| 106 | + for(ArrivalInfo arr : arrList){ | ||
| 107 | + if(arr.getInOut() == 0) | ||
| 108 | + in.add(arr); | ||
| 109 | + else | ||
| 110 | + out.add(arr); | ||
| 111 | + } | ||
| 112 | + int s1 = 0, s2 = 0; | ||
| 113 | + //匹配发车时间 | ||
| 114 | + if(sch.getFcsjActual() == null) | ||
| 115 | + s1 = matchOut(arrList, sch); | ||
| 116 | + | ||
| 117 | + //匹配终点时间 | ||
| 118 | + if(sch.getZdsjActual() == null) | ||
| 119 | + s2 = matchIn(arrList, sch); | ||
| 120 | + | ||
| 121 | + return new int[]{s1,s2}; | ||
| 122 | + } | ||
| 123 | + | ||
| 124 | + public int matchOut(List<ArrivalInfo> arrList, ScheduleRealInfo sch){ | ||
| 125 | + | ||
| 126 | + for(ArrivalInfo arr : arrList){ | ||
| 127 | + if(arr.getStopNo().equals(sch.getQdzCode())){ | ||
| 128 | + | ||
| 129 | + } | ||
| 130 | + } | ||
| 131 | + return 0; | ||
| 132 | + } | ||
| 133 | + | ||
| 134 | + public int matchIn(List<ArrivalInfo> arrList, ScheduleRealInfo sch){ | ||
| 135 | + return 0; | ||
| 72 | } | 136 | } |
| 73 | 137 | ||
| 74 | 138 | ||
| @@ -80,21 +144,21 @@ public class GpsArrivalStationThread extends Thread{ | @@ -80,21 +144,21 @@ public class GpsArrivalStationThread extends Thread{ | ||
| 80 | * @param @param schList 计划排班链表 | 144 | * @param @param schList 计划排班链表 |
| 81 | * @throws | 145 | * @throws |
| 82 | */ | 146 | */ |
| 83 | - public void match(List<ArrivalInfo> arrList, List<ScheduleRealInfo> schList){ | 147 | + /*public void match(List<ArrivalInfo> arrList, List<ScheduleRealInfo> schList){ |
| 84 | Iterator<ScheduleRealInfo> schIterator = schList.iterator(); | 148 | Iterator<ScheduleRealInfo> schIterator = schList.iterator(); |
| 85 | 149 | ||
| 86 | while(schIterator.hasNext()) | 150 | while(schIterator.hasNext()) |
| 87 | match(schIterator.next(), arrList); | 151 | match(schIterator.next(), arrList); |
| 88 | - } | 152 | + }*/ |
| 89 | 153 | ||
| 90 | 154 | ||
| 91 | - public void match(ScheduleRealInfo scInfo, List<ArrivalInfo> arrList){ | 155 | + /*public void match(ScheduleRealInfo scInfo, List<ArrivalInfo> arrList){ |
| 92 | for(ArrivalInfo arr : arrList){ | 156 | for(ArrivalInfo arr : arrList){ |
| 93 | match(scInfo, arr); | 157 | match(scInfo, arr); |
| 94 | } | 158 | } |
| 95 | - } | 159 | + }*/ |
| 96 | 160 | ||
| 97 | - public void match(ScheduleRealInfo scInfo, ArrivalInfo arr){ | 161 | +/* public void match(ScheduleRealInfo scInfo, ArrivalInfo arr){ |
| 98 | try{ | 162 | try{ |
| 99 | //匹配起点 | 163 | //匹配起点 |
| 100 | matchStart(scInfo, arr); | 164 | matchStart(scInfo, arr); |
| @@ -104,7 +168,7 @@ public class GpsArrivalStationThread extends Thread{ | @@ -104,7 +168,7 @@ public class GpsArrivalStationThread extends Thread{ | ||
| 104 | }catch(Exception e){ | 168 | }catch(Exception e){ |
| 105 | e.printStackTrace(); | 169 | e.printStackTrace(); |
| 106 | } | 170 | } |
| 107 | - } | 171 | + }*/ |
| 108 | 172 | ||
| 109 | /** | 173 | /** |
| 110 | * | 174 | * |
src/main/java/com/bsth/vehicle/gpsdata/buffer/GpsArrivalDataBuffer.java
| @@ -2,7 +2,9 @@ package com.bsth.vehicle.gpsdata.buffer; | @@ -2,7 +2,9 @@ package com.bsth.vehicle.gpsdata.buffer; | ||
| 2 | 2 | ||
| 3 | import java.util.Collections; | 3 | import java.util.Collections; |
| 4 | import java.util.Comparator; | 4 | import java.util.Comparator; |
| 5 | +import java.util.HashMap; | ||
| 5 | import java.util.List; | 6 | import java.util.List; |
| 7 | +import java.util.Map; | ||
| 6 | 8 | ||
| 7 | import com.bsth.vehicle.common.CommonMapped; | 9 | import com.bsth.vehicle.common.CommonMapped; |
| 8 | import com.bsth.vehicle.gpsdata.entity.ArrivalInfo; | 10 | import com.bsth.vehicle.gpsdata.entity.ArrivalInfo; |
| @@ -10,54 +12,74 @@ import com.google.common.collect.LinkedListMultimap; | @@ -10,54 +12,74 @@ import com.google.common.collect.LinkedListMultimap; | ||
| 10 | 12 | ||
| 11 | /** | 13 | /** |
| 12 | * | 14 | * |
| 13 | - * @ClassName: GpsArrivalDataBuffer | ||
| 14 | - * @Description: TODO(GPS到离站数据缓存) | 15 | + * @ClassName: GpsArrivalDataBuffer |
| 16 | + * @Description: TODO(GPS到离站数据缓存) | ||
| 15 | * @author PanZhao | 17 | * @author PanZhao |
| 16 | - * @date 2016年6月27日 下午1:08:35 | 18 | + * @date 2016年6月27日 下午1:08:35 |
| 17 | * | 19 | * |
| 18 | */ | 20 | */ |
| 19 | public class GpsArrivalDataBuffer { | 21 | public class GpsArrivalDataBuffer { |
| 20 | 22 | ||
| 21 | /** | 23 | /** |
| 22 | - * 车辆 时间戳排序的进出站链表 | 24 | + * 车辆 时间戳排序的进出站链表 |
| 23 | */ | 25 | */ |
| 24 | public static LinkedListMultimap<String, ArrivalInfo> allMap; | 26 | public static LinkedListMultimap<String, ArrivalInfo> allMap; |
| 25 | - | 27 | + |
| 28 | + /** | ||
| 29 | + * 车辆 和 进出站链表索引 | ||
| 30 | + */ | ||
| 31 | + public static Map<String, Integer> markMap; | ||
| 32 | + | ||
| 26 | /** | 33 | /** |
| 27 | * 时间戳标记,从数据库增量查询时起始时间 | 34 | * 时间戳标记,从数据库增量查询时起始时间 |
| 28 | */ | 35 | */ |
| 29 | public static Long markTime; | 36 | public static Long markTime; |
| 30 | - | ||
| 31 | - | ||
| 32 | - static{ | 37 | + |
| 38 | + public static List<ArrivalInfo> pops(String nbbm) { | ||
| 39 | + Integer mark = null; | ||
| 40 | + if (!markMap.containsKey(nbbm)) | ||
| 41 | + mark = 0; | ||
| 42 | + else | ||
| 43 | + mark = markMap.get(nbbm); | ||
| 44 | + | ||
| 45 | + List<ArrivalInfo> all = allMap.get(nbbm); | ||
| 46 | + int size = all.size(); | ||
| 47 | + if(size == 0) | ||
| 48 | + return null; | ||
| 49 | + | ||
| 50 | + List<ArrivalInfo> rs = all.subList(mark, size); | ||
| 51 | + | ||
| 52 | + markMap.put(nbbm, size); | ||
| 53 | + return rs; | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + static { | ||
| 33 | allMap = LinkedListMultimap.create(); | 57 | allMap = LinkedListMultimap.create(); |
| 58 | + markMap = new HashMap<>(); | ||
| 34 | } | 59 | } |
| 35 | - | 60 | + |
| 36 | /** | 61 | /** |
| 37 | * | 62 | * |
| 38 | - * @Title: putAll | ||
| 39 | - * @Description: TODO(将增量数据添加到缓存) | ||
| 40 | - * @param @param list 设定文件 | ||
| 41 | - * @return void 返回类型 | ||
| 42 | - * @throws | 63 | + * @Title: putAll @Description: TODO(将增量数据添加到缓存) @param @param list |
| 64 | + * 设定文件 @return void 返回类型 @throws | ||
| 43 | */ | 65 | */ |
| 44 | - public static void putAll(List<ArrivalInfo> list){ | ||
| 45 | - //按时间戳排序 | 66 | + public static void putAll(List<ArrivalInfo> list) { |
| 67 | + // 按时间戳排序 | ||
| 46 | Collections.sort(list, new Comparator<ArrivalInfo>() { | 68 | Collections.sort(list, new Comparator<ArrivalInfo>() { |
| 47 | @Override | 69 | @Override |
| 48 | public int compare(ArrivalInfo o1, ArrivalInfo o2) { | 70 | public int compare(ArrivalInfo o1, ArrivalInfo o2) { |
| 49 | return (int) (o1.getTs() - o2.getTs()); | 71 | return (int) (o1.getTs() - o2.getTs()); |
| 50 | } | 72 | } |
| 51 | }); | 73 | }); |
| 52 | - | 74 | + |
| 53 | int len = list.size(); | 75 | int len = list.size(); |
| 54 | ArrivalInfo arrival; | 76 | ArrivalInfo arrival; |
| 55 | String nbbm; | 77 | String nbbm; |
| 56 | - for(int i = 0; i < len; i ++){ | 78 | + for (int i = 0; i < len; i++) { |
| 57 | arrival = list.get(i); | 79 | arrival = list.get(i); |
| 58 | nbbm = CommonMapped.vehicDeviceBiMap.get(arrival.getDeviceId()); | 80 | nbbm = CommonMapped.vehicDeviceBiMap.get(arrival.getDeviceId()); |
| 59 | - | ||
| 60 | - if(null != nbbm) | 81 | + |
| 82 | + if (null != nbbm) | ||
| 61 | allMap.put(nbbm, arrival); | 83 | allMap.put(nbbm, arrival); |
| 62 | } | 84 | } |
| 63 | } | 85 | } |
src/main/resources/static/pages/control/line/index.html
| @@ -176,6 +176,11 @@ | @@ -176,6 +176,11 @@ | ||
| 176 | </button> | 176 | </button> |
| 177 | </li> | 177 | </li> |
| 178 | <li class="menu-separator"></li> | 178 | <li class="menu-separator"></li> |
| 179 | + <li class="menu-item" > | ||
| 180 | + <button type="button" class="menu-btn" data-method="showState"> | ||
| 181 | + <span class="menu-text">车辆状态查看</span> | ||
| 182 | + </button> | ||
| 183 | + </li> | ||
| 179 | <li class="menu-item submenu"> | 184 | <li class="menu-item submenu"> |
| 180 | <button type="button" class="menu-btn"> | 185 | <button type="button" class="menu-btn"> |
| 181 | <span class="menu-text">车辆状态发送</span> | 186 | <span class="menu-text">车辆状态发送</span> |
src/main/resources/static/pages/control/line/js/homeMenu.js
| @@ -74,6 +74,18 @@ var _home_menu = (function(){ | @@ -74,6 +74,18 @@ var _home_menu = (function(){ | ||
| 74 | else | 74 | else |
| 75 | layer.alert('发送指令失败!', {icon: 2, title: '操作失败'}); | 75 | layer.alert('发送指令失败!', {icon: 2, title: '操作失败'}); |
| 76 | }); | 76 | }); |
| 77 | + }, | ||
| 78 | + //车辆状态查看 | ||
| 79 | + showState: function(nbbm){ | ||
| 80 | + /*var index = layer.open({ | ||
| 81 | + type: 1, | ||
| 82 | + area: '370px', | ||
| 83 | + maxmin: true, | ||
| 84 | + content: template('', data), | ||
| 85 | + shift: 5, | ||
| 86 | + title: '---' + nbbm + '---', | ||
| 87 | + success: function(){} | ||
| 88 | + });*/ | ||
| 77 | } | 89 | } |
| 78 | } | 90 | } |
| 79 | })(); | 91 | })(); |
src/main/resources/static/pages/control/line/temps/home_tp.html
| @@ -121,7 +121,7 @@ | @@ -121,7 +121,7 @@ | ||
| 121 | 121 | ||
| 122 | <script id="home_table_temp" type="text/html"> | 122 | <script id="home_table_temp" type="text/html"> |
| 123 | {{each list as obj i}} | 123 | {{each list as obj i}} |
| 124 | -<tr data-nbbm="{{obj.nbbm}}"> | 124 | +<tr data-nbbm="{{obj.nbbm}}" data-device="{{obj.deviceId}}"> |
| 125 | <td style="width: 22%;"> {{obj.nbbm}} </td> | 125 | <td style="width: 22%;"> {{obj.nbbm}} </td> |
| 126 | <td style="width: 17%;"> | 126 | <td style="width: 17%;"> |
| 127 | {{if obj.currSch != null}} | 127 | {{if obj.currSch != null}} |