Commit afac5507c94d3f31fbd853c78fa302ecc377fd43

Authored by 王通
2 parents a72fee72 c0a9b893

Merge branch 'pudong' of http://192.168.168.201:8888/panzhaov5/bsth_control.git into pudong

src/main/java/com/bsth/controller/realcontrol/AdminUtilsController.java
1 package com.bsth.controller.realcontrol; 1 package com.bsth.controller.realcontrol;
2 2
  3 +import com.bsth.common.ResponseCode;
3 import com.bsth.data.directive.DayOfDirectives; 4 import com.bsth.data.directive.DayOfDirectives;
4 import com.bsth.data.directive.DirectivesPstThread; 5 import com.bsth.data.directive.DirectivesPstThread;
5 import com.bsth.data.gpsdata_v2.cache.GeoCacheData; 6 import com.bsth.data.gpsdata_v2.cache.GeoCacheData;
@@ -18,6 +19,8 @@ import org.springframework.web.bind.annotation.RequestMapping; @@ -18,6 +19,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
18 import org.springframework.web.bind.annotation.RequestParam; 19 import org.springframework.web.bind.annotation.RequestParam;
19 import org.springframework.web.bind.annotation.RestController; 20 import org.springframework.web.bind.annotation.RestController;
20 21
  22 +import java.text.SimpleDateFormat;
  23 +import java.util.Date;
21 import java.util.HashMap; 24 import java.util.HashMap;
22 import java.util.List; 25 import java.util.List;
23 import java.util.Map; 26 import java.util.Map;
@@ -49,35 +52,35 @@ public class AdminUtilsController { @@ -49,35 +52,35 @@ public class AdminUtilsController {
49 52
50 /** 53 /**
51 * 出现重复班次的车辆 54 * 出现重复班次的车辆
  55 + *
52 * @param 56 * @param
53 -  
54 - @RequestMapping(value = "/schRepeat", method = RequestMethod.POST)  
55 - public void schRepeat(@RequestParam String nbbm){  
56 - logger.info("前端通知,车辆 " + nbbm + "出现重复班次,开始检测...");  
57 - List<ScheduleRealInfo> list = dayOfSchedule.findByNbbm(nbbm);  
58 - logger.info("检测前,车辆班次数量:" + list.size());  
59 -  
60 - Map<Long, ScheduleRealInfo> map = new HashMap<>();  
61 - for(ScheduleRealInfo sch : list){  
62 - if(map.containsKey(sch.getId())){  
63 - logger.info("检测到重复ID: " + sch.getId());  
64 - }  
65 - map.put(sch.getId(), sch);  
66 - }  
67 -  
68 - logger.info("检测后,车辆班次数量:" + list.size());  
69 - if(map.values().size() > 0){  
70 - dayOfSchedule.replaceByNbbm(nbbm, map.values());  
71 - }  
72 - }*/ 57 + * @RequestMapping(value = "/schRepeat", method = RequestMethod.POST)
  58 + * public void schRepeat(@RequestParam String nbbm){
  59 + * logger.info("前端通知,车辆 " + nbbm + "出现重复班次,开始检测...");
  60 + * List<ScheduleRealInfo> list = dayOfSchedule.findByNbbm(nbbm);
  61 + * logger.info("检测前,车辆班次数量:" + list.size());
  62 + * <p>
  63 + * Map<Long, ScheduleRealInfo> map = new HashMap<>();
  64 + * for(ScheduleRealInfo sch : list){
  65 + * if(map.containsKey(sch.getId())){
  66 + * logger.info("检测到重复ID: " + sch.getId());
  67 + * }
  68 + * map.put(sch.getId(), sch);
  69 + * }
  70 + * <p>
  71 + * logger.info("检测后,车辆班次数量:" + list.size());
  72 + * if(map.values().size() > 0){
  73 + * dayOfSchedule.replaceByNbbm(nbbm, map.values());
  74 + * }
  75 + * }
  76 + */
73 77
74 /* @RequestMapping(value = "/directivePushQueue") 78 /* @RequestMapping(value = "/directivePushQueue")
75 public void directivePushQueue(){ 79 public void directivePushQueue(){
76 DirectivePushQueue.start(); 80 DirectivePushQueue.start();
77 }*/ 81 }*/
78 -  
79 @RequestMapping(value = "/directiveQueueSize") 82 @RequestMapping(value = "/directiveQueueSize")
80 - public void directiveQueueSize(){ 83 + public void directiveQueueSize() {
81 DirectivePushQueue.size(); 84 DirectivePushQueue.size();
82 } 85 }
83 86
@@ -87,55 +90,55 @@ public class AdminUtilsController { @@ -87,55 +90,55 @@ public class AdminUtilsController {
87 }*/ 90 }*/
88 91
89 @RequestMapping(value = "/webSocketQueueSize") 92 @RequestMapping(value = "/webSocketQueueSize")
90 - public void webSocketQueueSize(){ 93 + public void webSocketQueueSize() {
91 WebSocketPushQueue.size(); 94 WebSocketPushQueue.size();
92 } 95 }
93 96
94 @RequestMapping(value = "/setHttpFlag") 97 @RequestMapping(value = "/setHttpFlag")
95 - public void setHttpFlag(@RequestParam int flag){  
96 - if(flag != 0 && flag != -1) 98 + public void setHttpFlag(@RequestParam int flag) {
  99 + if (flag != 0 && flag != -1)
97 return; 100 return;
98 GpsDataLoaderThread.setFlag(flag); 101 GpsDataLoaderThread.setFlag(flag);
99 } 102 }
100 103
101 @RequestMapping(value = "/updateCacheBuff") 104 @RequestMapping(value = "/updateCacheBuff")
102 - public void updateCacheBuff(){ 105 + public void updateCacheBuff() {
103 geoCacheData.loadData(); 106 geoCacheData.loadData();
104 } 107 }
105 108
106 @RequestMapping(value = "/reCalcLpSch") 109 @RequestMapping(value = "/reCalcLpSch")
107 - public void reCalcLpSch(){ 110 + public void reCalcLpSch() {
108 dayOfSchedule._test_reCalcLpSch(); 111 dayOfSchedule._test_reCalcLpSch();
109 } 112 }
110 113
111 @RequestMapping(value = "/findSchByLpName") 114 @RequestMapping(value = "/findSchByLpName")
112 - public List<ScheduleRealInfo> findSchByLpName(@RequestParam String lpName){ 115 + public List<ScheduleRealInfo> findSchByLpName(@RequestParam String lpName) {
113 return dayOfSchedule.getLpScheduleMap().get(lpName); 116 return dayOfSchedule.getLpScheduleMap().get(lpName);
114 } 117 }
115 118
116 @RequestMapping(value = "/findSchByNbbm") 119 @RequestMapping(value = "/findSchByNbbm")
117 - public List<ScheduleRealInfo> findSchByNbbm(@RequestParam String nbbm){ 120 + public List<ScheduleRealInfo> findSchByNbbm(@RequestParam String nbbm) {
118 return dayOfSchedule.findByNbbm(nbbm); 121 return dayOfSchedule.findByNbbm(nbbm);
119 } 122 }
120 123
121 @RequestMapping(value = "/removeExecPlan") 124 @RequestMapping(value = "/removeExecPlan")
122 - public int removeExecPlan(@RequestParam String nbbm){ 125 + public int removeExecPlan(@RequestParam String nbbm) {
123 dayOfSchedule.removeExecPlan(nbbm); 126 dayOfSchedule.removeExecPlan(nbbm);
124 return 1; 127 return 1;
125 } 128 }
126 129
127 @RequestMapping(value = "/sch_re_calc_id_maps") 130 @RequestMapping(value = "/sch_re_calc_id_maps")
128 - public int reCalcIdMaps(){ 131 + public int reCalcIdMaps() {
129 return dayOfSchedule.reCalcIdMaps(); 132 return dayOfSchedule.reCalcIdMaps();
130 } 133 }
131 134
132 @RequestMapping(value = "/sch_size_string") 135 @RequestMapping(value = "/sch_size_string")
133 - public String schSizeString(){ 136 + public String schSizeString() {
134 return dayOfSchedule.sizeString(); 137 return dayOfSchedule.sizeString();
135 } 138 }
136 139
137 @RequestMapping(value = "/containerSize") 140 @RequestMapping(value = "/containerSize")
138 - public Map<String, Integer> containerSize(){ 141 + public Map<String, Integer> containerSize() {
139 Map<String, Integer> rs = new HashMap<>(); 142 Map<String, Integer> rs = new HashMap<>();
140 rs.put("60_size", dayOfDirectives.all60().size()); 143 rs.put("60_size", dayOfDirectives.all60().size());
141 rs.put("80_size", pilotReport.findAll().size()); 144 rs.put("80_size", pilotReport.findAll().size());
@@ -148,7 +151,7 @@ public class AdminUtilsController { @@ -148,7 +151,7 @@ public class AdminUtilsController {
148 } 151 }
149 152
150 @RequestMapping(value = "/websocketRadioText") 153 @RequestMapping(value = "/websocketRadioText")
151 - public int radioText(String t, String lineCode){ 154 + public int radioText(String t, String lineCode) {
152 sendUtils.sendRadioText(t, lineCode); 155 sendUtils.sendRadioText(t, lineCode);
153 return 0; 156 return 0;
154 } 157 }
@@ -157,8 +160,47 @@ public class AdminUtilsController { @@ -157,8 +160,47 @@ public class AdminUtilsController {
157 DirectivesPstThread directivesPstThread; 160 DirectivesPstThread directivesPstThread;
158 161
159 @RequestMapping(value = "/_sd_60_pst") 162 @RequestMapping(value = "/_sd_60_pst")
160 - public void sd_60_pst(){ 163 + public void sd_60_pst() {
161 logger.info("手动入库指令...."); 164 logger.info("手动入库指令....");
162 directivesPstThread.run(); 165 directivesPstThread.run();
163 } 166 }
  167 +
  168 + /**
  169 + * 删除班次,删除内存中未清理掉的非当天的班次
  170 + * @createDate 2019.05.13
  171 + * @author zhangxianzhou
  172 + * @param id 线路id
  173 + * @return 被删除的班次信息
  174 + */
  175 + @RequestMapping("/deleteSchduleBC")
  176 + public Map deleteSchduleBC(Long id) {
  177 + Map<String, Object> rs = new HashMap<>();
  178 + rs.put("status", ResponseCode.ERROR);
  179 + ScheduleRealInfo sch = null;
  180 + try {
  181 + sch = dayOfSchedule.get(id);
  182 + if (sch == null) {
  183 + rs.put("msg", "无效的id号");
  184 + return rs;
  185 + }
  186 + Date date=new Date();
  187 + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
  188 + String dateStr=sdf.format(date);
  189 + if (sch.getScheduleDateStr().equals(dateStr)){
  190 + rs.put("msg", "不能删除当日排班");
  191 + return rs;
  192 + }
  193 + //内存中删除
  194 + dayOfSchedule.deleteBC(sch);
  195 + rs.put("delete", sch);
  196 + rs.put("status", ResponseCode.SUCCESS);
  197 +
  198 + } catch (Exception e) {
  199 + logger.error("", e);
  200 + rs.put("msg", e.getMessage());
  201 + sch.setDeleted(false);
  202 + }
  203 +
  204 + return rs;
  205 + }
164 } 206 }
165 \ No newline at end of file 207 \ No newline at end of file
src/main/java/com/bsth/data/gpsdata_v2/handlers/InStationProcess.java
@@ -86,6 +86,10 @@ public class InStationProcess { @@ -86,6 +86,10 @@ public class InStationProcess {
86 boolean flow = true; 86 boolean flow = true;
87 //要经过2个中途站才能进 87 //要经过2个中途站才能进
88 int count = GpsCacheData.lastInTrailsSize(gps); 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....");
89 List<StationRoute> routes = GeoCacheData.getStationRoute(gps.getLineId(), gps.getUpDown()); 93 List<StationRoute> routes = GeoCacheData.getStationRoute(gps.getLineId(), gps.getUpDown());
90 if (null != sch && isNormalSch(sch) && gps.getInstation() == 1 && routes.size() > 4 94 if (null != sch && isNormalSch(sch) && gps.getInstation() == 1 && routes.size() > 4
91 && count < 2) { 95 && count < 2) {
src/main/java/com/bsth/data/gpsdata_v2/handlers/OutStationProcess.java
@@ -77,6 +77,10 @@ public class OutStationProcess { @@ -77,6 +77,10 @@ public class OutStationProcess {
77 logger.info("出站记录(到达时间:" + gps.getArrTime() + " 进出站状态:" + gps.getInstation() + " 站点编号:" + gps.getStopNo() + " deviceId:" + gps.getDeviceId() + " nbbm:" + gps.getNbbm() + ")"); 77 logger.info("出站记录(到达时间:" + gps.getArrTime() + " 进出站状态:" + gps.getInstation() + " 站点编号:" + gps.getStopNo() + " deviceId:" + gps.getDeviceId() + " nbbm:" + gps.getNbbm() + ")");
78 ScheduleRealInfo sch = dayOfSchedule.executeCurr(gps.getNbbm()); 78 ScheduleRealInfo sch = dayOfSchedule.executeCurr(gps.getNbbm());
79 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....");
80 //起点发车 84 //起点发车
81 if (null != sch && 85 if (null != sch &&
82 ((sch.getQdzCode().equals(prev.getStopNo()) 86 ((sch.getQdzCode().equals(prev.getStopNo())
src/main/java/com/bsth/data/schedule/DayOfSchedule.java
@@ -1162,4 +1162,20 @@ public class DayOfSchedule { @@ -1162,4 +1162,20 @@ public class DayOfSchedule {
1162 public Collection<ScheduleRealInfo> findByGsbm(String gsbm){ 1162 public Collection<ScheduleRealInfo> findByGsbm(String gsbm){
1163 return gsBmScheduleMap.get(gsbm); 1163 return gsBmScheduleMap.get(gsbm);
1164 } 1164 }
  1165 + /**
  1166 + * 删除班次,删除内存中未清理掉的非当天的班次
  1167 + * @createDate 2019.05.13
  1168 + * @author zhangxianzhou
  1169 + * @param sch
  1170 + */
  1171 + public void deleteBC(ScheduleRealInfo sch) {
  1172 + nbbmScheduleMap.remove(sch.getClZbh(), sch);
  1173 + id2SchedulMap.remove(sch.getId());
  1174 + lpScheduleMap.remove(sch.getXlBm() + "_" + sch.getLpName(), sch);
  1175 + //如果正在执行该班次
  1176 + if (carExecutePlanMap.get(sch.getClZbh()) == sch) {
  1177 + //重新计算车辆当前执行班次
  1178 + reCalcExecPlan(sch.getClZbh());
  1179 + }
  1180 + }
1165 } 1181 }
1166 \ No newline at end of file 1182 \ No newline at end of file