Commit b2a494ef386f5e87e33560b34feab19b910402b0
1 parent
60a7e7e7
update...
Showing
3 changed files
with
281 additions
and
305 deletions
src/main/java/com/bsth/data/pilot80/PilotReport.java
| @@ -2,7 +2,6 @@ package com.bsth.data.pilot80; | @@ -2,7 +2,6 @@ package com.bsth.data.pilot80; | ||
| 2 | 2 | ||
| 3 | import com.bsth.data.BasicData; | 3 | import com.bsth.data.BasicData; |
| 4 | import com.bsth.data.LineConfigData; | 4 | import com.bsth.data.LineConfigData; |
| 5 | -import com.bsth.data.gpsdata.GpsEntity; | ||
| 6 | import com.bsth.data.gpsdata.GpsRealData; | 5 | import com.bsth.data.gpsdata.GpsRealData; |
| 7 | import com.bsth.data.msg_queue.DirectivePushQueue; | 6 | import com.bsth.data.msg_queue.DirectivePushQueue; |
| 8 | import com.bsth.data.schedule.DayOfSchedule; | 7 | import com.bsth.data.schedule.DayOfSchedule; |
| @@ -16,7 +15,6 @@ import com.bsth.repository.directive.D80Repository; | @@ -16,7 +15,6 @@ import com.bsth.repository.directive.D80Repository; | ||
| 16 | import com.bsth.repository.directive.DC0A4Repository; | 15 | import com.bsth.repository.directive.DC0A4Repository; |
| 17 | import com.bsth.service.directive.DirectiveService; | 16 | import com.bsth.service.directive.DirectiveService; |
| 18 | import com.bsth.websocket.handler.SendUtils; | 17 | import com.bsth.websocket.handler.SendUtils; |
| 19 | -import com.google.common.collect.ArrayListMultimap; | ||
| 20 | import org.apache.commons.lang3.StringUtils; | 18 | import org.apache.commons.lang3.StringUtils; |
| 21 | import org.slf4j.Logger; | 19 | import org.slf4j.Logger; |
| 22 | import org.slf4j.LoggerFactory; | 20 | import org.slf4j.LoggerFactory; |
| @@ -26,289 +24,278 @@ import org.springframework.stereotype.Component; | @@ -26,289 +24,278 @@ import org.springframework.stereotype.Component; | ||
| 26 | import java.util.ArrayList; | 24 | import java.util.ArrayList; |
| 27 | import java.util.Collection; | 25 | import java.util.Collection; |
| 28 | import java.util.List; | 26 | import java.util.List; |
| 27 | +import java.util.concurrent.ConcurrentHashMap; | ||
| 29 | 28 | ||
| 30 | /** | 29 | /** |
| 31 | - * | ||
| 32 | - * @ClassName: PilotReport | ||
| 33 | - * @Description: TODO(设备80协议上报处理) | ||
| 34 | * @author PanZhao | 30 | * @author PanZhao |
| 35 | - * @date 2016年8月14日 下午11:37:51 | ||
| 36 | - * | 31 | + * @ClassName: PilotReport |
| 32 | + * @Description: TODO(设备80协议上报处理) | ||
| 33 | + * @date 2016年8月14日 下午11:37:51 | ||
| 37 | */ | 34 | */ |
| 38 | @Component | 35 | @Component |
| 39 | public class PilotReport { | 36 | public class PilotReport { |
| 40 | - | ||
| 41 | - @Autowired | ||
| 42 | - D80Repository d80Repository; | ||
| 43 | - @Autowired | ||
| 44 | - DayOfSchedule dayOfSchedule; | ||
| 45 | - @Autowired | ||
| 46 | - LineConfigData lineConfigData; | ||
| 47 | - @Autowired | ||
| 48 | - DirectiveService directiveService; | ||
| 49 | - @Autowired | ||
| 50 | - GpsRealData gpsRealData; | ||
| 51 | - @Autowired | ||
| 52 | - SendUtils sendUtils; | ||
| 53 | - | ||
| 54 | - @Autowired | ||
| 55 | - DC0A4Repository dc0A4Repository; | ||
| 56 | - | ||
| 57 | - private static ArrayListMultimap<String, D80> d80MultiMap; | ||
| 58 | - | ||
| 59 | - Logger logger = LoggerFactory.getLogger(PilotReport.class); | ||
| 60 | - | ||
| 61 | - static{ | ||
| 62 | - d80MultiMap = ArrayListMultimap.create(); | ||
| 63 | - } | ||
| 64 | - | ||
| 65 | - public void report(D80 d80){ | ||
| 66 | - //入库 | ||
| 67 | - d80Repository.save(d80); | ||
| 68 | - //入缓存 | ||
| 69 | - d80MultiMap.put(d80.getData().getLineId().toString(), d80); | ||
| 70 | - | ||
| 71 | - String nbbm = BasicData.deviceId2NbbmMap.get(d80.getDeviceId()); | ||
| 72 | - //处理 | ||
| 73 | - switch (d80.getData().getRequestCode()) { | ||
| 74 | - case 0xA3: | ||
| 75 | - //出场请求 | ||
| 76 | - ScheduleRealInfo outSch = dayOfSchedule.searchNearByBcType(nbbm, "out"); | ||
| 77 | - //如果有对应出场班次 | ||
| 78 | - if(outSch != null){ | ||
| 79 | - //没有计划里程的出场班次,出场既是首发站,发送下一班次的营运指令 | ||
| 80 | - if(outSch.getJhlc() == null) | ||
| 81 | - outSch = dayOfSchedule.next(outSch); | ||
| 82 | - | ||
| 83 | - //下发调度指令 | ||
| 84 | - DirectivePushQueue.put6002(outSch, dayOfSchedule.doneSum(nbbm), "请出@系统"); | ||
| 85 | - //directiveService.send60Dispatch(outSch, dayOfSchedule.doneSum(nbbm), "请出@系统"); | ||
| 86 | - //下发线路切换指令 | ||
| 87 | - DirectivePushQueue.put64(outSch.getClZbh(), outSch.getXlBm(), "请出@系统"); | ||
| 88 | - //directiveService.lineChange(outSch.getClZbh(), outSch.getXlBm(), "请出@系统"); | ||
| 89 | - }else | ||
| 90 | - d80.setRemarks("没有出场计划"); | ||
| 91 | - | ||
| 92 | - break; | ||
| 93 | - | ||
| 94 | - case 0xA5: | ||
| 95 | - //进场请求 | ||
| 96 | - //ScheduleRealInfo inSch = dayOfSchedule.nextByBcType(nbbm, "in"); | ||
| 97 | - //如果有对应出场班次 | ||
| 98 | - //if(inSch != null){ | ||
| 99 | - /*d80.setRemarks("计划进场时间:" + inSch.getDfsj()); | ||
| 100 | - //当前GPS位置 | ||
| 101 | - GpsEntity gps = gpsRealData.get(d80.getDeviceId()); | ||
| 102 | - if(null != gps) | ||
| 103 | - d80.addRemarks("<br> 位置:" + coordHtmlStr(gps));*/ | ||
| 104 | - //}/*else | ||
| 105 | - // d80.setRemarks("没有进场计划");*/ | ||
| 106 | - break; | ||
| 107 | - } | ||
| 108 | - | ||
| 109 | - //推送到页面 | ||
| 110 | - sendUtils.send80ToPage(d80); | ||
| 111 | - } | ||
| 112 | - | ||
| 113 | - public void report(DC0_A4 c0a4){ | ||
| 114 | - String deviceId = c0a4.getData().getDeviceId(); | ||
| 115 | - if(StringUtils.isNotEmpty(deviceId)) | ||
| 116 | - c0a4.setId(deviceId); | ||
| 117 | - | ||
| 118 | - //入库 | ||
| 119 | - dc0A4Repository.save(c0a4); | ||
| 120 | - } | ||
| 121 | - | ||
| 122 | - /** | ||
| 123 | - * | ||
| 124 | - * @Title: reply | ||
| 125 | - * @Description: TODO(调度员回复) | ||
| 126 | - */ | ||
| 127 | - public void reply(D80 d80){ | ||
| 128 | - String nbbm = BasicData.deviceId2NbbmMap.get(d80.getDeviceId()); | ||
| 129 | - Short reqCode = d80.getData().getRequestCode(); | ||
| 130 | - //默认短语回复 | ||
| 131 | - //defaultReply(nbbm, reqCode, d80.getConfirmRs() == 0?true:false); | ||
| 132 | - | ||
| 133 | - switch (reqCode) { | ||
| 134 | - case 0xA3: | ||
| 135 | - //出场请求回复 | ||
| 136 | - applyOutReply(d80); | ||
| 137 | - break; | ||
| 138 | - case 0xA5: | ||
| 139 | - //进场请求回复 | ||
| 140 | - applyInReply(d80); | ||
| 141 | - break; | ||
| 142 | - } | ||
| 143 | - } | ||
| 144 | - | ||
| 145 | - /** | ||
| 146 | - * | ||
| 147 | - * @Title: applyOutReply | ||
| 148 | - * @Description: TODO(出场请求回复) | ||
| 149 | - */ | ||
| 150 | - public void applyOutReply(D80 d80){ | ||
| 151 | - //同意 | ||
| 152 | - if(d80.getConfirmRs() == 0){ | ||
| 153 | - String nbbm = BasicData.deviceId2NbbmMap.get(d80.getDeviceId()); | ||
| 154 | - | ||
| 155 | - ScheduleRealInfo sch = dayOfSchedule.nextByBcType(nbbm, "out"); | ||
| 156 | - if(null == sch) | ||
| 157 | - return; | ||
| 158 | - | ||
| 159 | - LineConfig conf = lineConfigData.get(sch.getXlBm()); | ||
| 160 | - if(conf.getOutConfig() == 1){ | ||
| 161 | - //为相关班次写入请求出场时间 | ||
| 162 | - sch.setFcsjActualAll(d80.getTimestamp()); | ||
| 163 | - | ||
| 164 | - dayOfSchedule.save(sch); | ||
| 165 | - //通知页面 | ||
| 166 | - sendUtils.refreshSch(sch); | ||
| 167 | - } | ||
| 168 | - } | ||
| 169 | - } | ||
| 170 | - | ||
| 171 | - /** | ||
| 172 | - * | ||
| 173 | - * @Title: applyInReply | ||
| 174 | - * @Description: TODO(进场请求回复) | ||
| 175 | - */ | ||
| 176 | - public void applyInReply(D80 d80){ | ||
| 177 | - //同意 | ||
| 178 | - if(d80.getConfirmRs() == 0){ | ||
| 179 | - String nbbm = BasicData.deviceId2NbbmMap.get(d80.getDeviceId()); | ||
| 180 | - | ||
| 181 | - ScheduleRealInfo sch = dayOfSchedule.nextByBcType(nbbm, "in"); | ||
| 182 | - if(null == sch) | ||
| 183 | - return; | ||
| 184 | - | ||
| 185 | - LineConfig conf = lineConfigData.get(sch.getXlBm()); | ||
| 186 | - if(conf.getOutConfig() == 1){ | ||
| 187 | - //为相关班次写入进场时间 | ||
| 188 | - sch.setZdsjActualAll(d80.getTimestamp()); | ||
| 189 | - | ||
| 190 | - //没有里程的进场班次 | ||
| 191 | - if(isEmpty(sch.getBcsj()) && isEmpty(sch.getJhlc())) | ||
| 192 | - sch.setFcsjActualAll(d80.getTimestamp()); | ||
| 193 | - | ||
| 194 | - dayOfSchedule.save(sch); | ||
| 195 | - //通知页面 | ||
| 196 | - sendUtils.refreshSch(sch); | ||
| 197 | - } | ||
| 198 | - } | ||
| 199 | - } | ||
| 200 | - | ||
| 201 | - public boolean isEmpty(Integer v){ | ||
| 202 | - return v == null || v.equals(0); | ||
| 203 | - } | ||
| 204 | - | ||
| 205 | - public boolean isEmpty(Double v){ | ||
| 206 | - return v == null || v.equals(0); | ||
| 207 | - } | ||
| 208 | - | ||
| 209 | - public void defaultReply(String nbbm, short requestCode, boolean agree){ | ||
| 210 | - Line line = BasicData.nbbm2LineMap.get(nbbm); | ||
| 211 | - String lineCode = null; | ||
| 212 | - | ||
| 213 | - if(line != null) | ||
| 214 | - lineCode = line.getLineCode(); | ||
| 215 | - else{ | ||
| 216 | - try{ | ||
| 217 | - lineCode = gpsRealData.get(BasicData.deviceId2NbbmMap.inverse().get(nbbm)).getLineId().toString(); | ||
| 218 | - }catch(Exception e){ | ||
| 219 | - logger.error("", e); | ||
| 220 | - } | ||
| 221 | - } | ||
| 222 | - | ||
| 223 | - if(null == lineCode) | ||
| 224 | - return; | ||
| 225 | - | ||
| 226 | - LineConfig conf = lineConfigData.get(lineCode); | ||
| 227 | - D80ReplyTemp temp = conf.findByCode(requestCode); | ||
| 228 | - | ||
| 229 | - if(null == temp) | ||
| 230 | - return; | ||
| 231 | - | ||
| 232 | - String text; | ||
| 233 | - if(agree) | ||
| 234 | - text = temp.getAgreeText(); | ||
| 235 | - else | ||
| 236 | - text = temp.getRejectText(); | ||
| 237 | - | ||
| 238 | - directiveService.send60Phrase(nbbm, text, "系统"); | ||
| 239 | - } | ||
| 240 | - | ||
| 241 | - /** | ||
| 242 | - * | ||
| 243 | - * @Title: resumeOperation | ||
| 244 | - * @Description: TODO(恢复营运) | ||
| 245 | - */ | ||
| 246 | - public void resumeOperation(D80 d80){ | ||
| 247 | - | ||
| 248 | - } | ||
| 249 | - | ||
| 250 | - /** | ||
| 251 | - * | ||
| 252 | - * @Title: applyTiaodang | ||
| 253 | - * @Description: TODO(申请调档) | ||
| 254 | - */ | ||
| 255 | - public void applyTiaodang(D80 d80){ | ||
| 256 | - | ||
| 257 | - } | ||
| 258 | - | ||
| 259 | - /** | ||
| 260 | - * | ||
| 261 | - * @Title: unconfirmed80 | ||
| 262 | - * @Description: TODO(根据lineCode 获取未处理的80数据) | ||
| 263 | - */ | ||
| 264 | - public List<D80> unconfirmed80(Integer lineCode){ | ||
| 265 | - List<D80> lineAll = d80MultiMap.get(lineCode.toString()) | ||
| 266 | - ,rs = new ArrayList<>(); | ||
| 267 | - | ||
| 268 | - for(D80 d80 : lineAll) | ||
| 269 | - if(!d80.isConfirm()) | ||
| 270 | - rs.add(d80); | ||
| 271 | - | ||
| 272 | - return rs; | ||
| 273 | - } | ||
| 274 | - | ||
| 275 | - public D80 findById(int id){ | ||
| 276 | - Collection<D80> all = d80MultiMap.values(); | ||
| 277 | - | ||
| 278 | - for(D80 d80 : all){ | ||
| 279 | - if(d80.getId() == id) | ||
| 280 | - return d80; | ||
| 281 | - } | ||
| 282 | - | ||
| 283 | - return null; | ||
| 284 | - } | ||
| 285 | - | ||
| 286 | - public String coordHtmlStr(GpsEntity gps){ | ||
| 287 | - | ||
| 288 | - return "<span class=\"nt-coord\" data-lon=\""+gps.getLon()+"\" data-lat=\""+gps.getLat()+"\"></span>"; | ||
| 289 | - } | ||
| 290 | - | ||
| 291 | - public Collection<D80> findAll(){ | ||
| 292 | - return d80MultiMap.values(); | ||
| 293 | - } | ||
| 294 | - | ||
| 295 | - public void clear(String lineCode){ | ||
| 296 | - logger.info("清除 80数据 before: " + d80MultiMap.size()); | ||
| 297 | - d80MultiMap.removeAll(lineCode); | ||
| 298 | - logger.info("清除 80数据 after: " + d80MultiMap.size()); | ||
| 299 | - } | ||
| 300 | - | ||
| 301 | - public Collection<? extends D80> findByCar(String nbbm) { | ||
| 302 | - List<D80> rs = new ArrayList<>(); | ||
| 303 | - String deviceId = BasicData.deviceId2NbbmMap.inverse().get(nbbm); | ||
| 304 | - if(null == deviceId) | ||
| 305 | - return rs; | ||
| 306 | - | ||
| 307 | - Collection<D80> all = findAll(); | ||
| 308 | - for(D80 d80 : all){ | ||
| 309 | - if(d80.getDeviceId().equals(deviceId)) | ||
| 310 | - rs.add(d80); | ||
| 311 | - } | ||
| 312 | - return rs; | ||
| 313 | - } | 37 | + |
| 38 | + @Autowired | ||
| 39 | + D80Repository d80Repository; | ||
| 40 | + @Autowired | ||
| 41 | + DayOfSchedule dayOfSchedule; | ||
| 42 | + @Autowired | ||
| 43 | + LineConfigData lineConfigData; | ||
| 44 | + @Autowired | ||
| 45 | + DirectiveService directiveService; | ||
| 46 | + @Autowired | ||
| 47 | + GpsRealData gpsRealData; | ||
| 48 | + @Autowired | ||
| 49 | + SendUtils sendUtils; | ||
| 50 | + | ||
| 51 | + @Autowired | ||
| 52 | + DC0A4Repository dc0A4Repository; | ||
| 53 | + | ||
| 54 | + //private static ArrayListMultimap<String, D80> d80MultiMap; | ||
| 55 | + | ||
| 56 | + private static ConcurrentHashMap<Integer, D80> d80Maps; | ||
| 57 | + | ||
| 58 | + Logger logger = LoggerFactory.getLogger(PilotReport.class); | ||
| 59 | + | ||
| 60 | + static { | ||
| 61 | + //d80MultiMap = ArrayListMultimap.create(); | ||
| 62 | + d80Maps = new ConcurrentHashMap<>(); | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + public void report(D80 d80) { | ||
| 66 | + if (d80 == null) | ||
| 67 | + return; | ||
| 68 | + try { | ||
| 69 | + //入库 | ||
| 70 | + d80Repository.save(d80); | ||
| 71 | + //入缓存 | ||
| 72 | + d80Maps.put(d80.getId(), d80); | ||
| 73 | + //d80MultiMap.put(d80.getData().getLineId().toString(), d80); | ||
| 74 | + | ||
| 75 | + String nbbm = BasicData.deviceId2NbbmMap.get(d80.getDeviceId()); | ||
| 76 | + //处理 | ||
| 77 | + switch (d80.getData().getRequestCode()) { | ||
| 78 | + //出场请求 | ||
| 79 | + case 0xA3: | ||
| 80 | + ScheduleRealInfo outSch = dayOfSchedule.searchNearByBcType(nbbm, "out"); | ||
| 81 | + //如果有对应出场班次 | ||
| 82 | + if (outSch != null) { | ||
| 83 | + //没有计划里程的出场班次,出场既是首发站,发送下一班次的营运指令 | ||
| 84 | + if (outSch.getJhlc() == null) | ||
| 85 | + outSch = dayOfSchedule.next(outSch); | ||
| 86 | + | ||
| 87 | + //下发调度指令 | ||
| 88 | + DirectivePushQueue.put6002(outSch, dayOfSchedule.doneSum(nbbm), "请出@系统"); | ||
| 89 | + //下发线路切换指令 | ||
| 90 | + DirectivePushQueue.put64(outSch.getClZbh(), outSch.getXlBm(), "请出@系统"); | ||
| 91 | + } | ||
| 92 | + break; | ||
| 93 | + } | ||
| 94 | + | ||
| 95 | + //推送到页面 | ||
| 96 | + sendUtils.send80ToPage(d80); | ||
| 97 | + } catch (Exception e) { | ||
| 98 | + logger.error("", e); | ||
| 99 | + } | ||
| 100 | + } | ||
| 101 | + | ||
| 102 | + public void report(DC0_A4 c0a4) { | ||
| 103 | + String deviceId = c0a4.getData().getDeviceId(); | ||
| 104 | + if (StringUtils.isNotEmpty(deviceId)) | ||
| 105 | + c0a4.setId(deviceId); | ||
| 106 | + | ||
| 107 | + //入库 | ||
| 108 | + dc0A4Repository.save(c0a4); | ||
| 109 | + } | ||
| 110 | + | ||
| 111 | + /** | ||
| 112 | + * @Title: reply | ||
| 113 | + * @Description: TODO(调度员回复) | ||
| 114 | + */ | ||
| 115 | + public void reply(D80 d80) { | ||
| 116 | + String nbbm = BasicData.deviceId2NbbmMap.get(d80.getDeviceId()); | ||
| 117 | + Short reqCode = d80.getData().getRequestCode(); | ||
| 118 | + //默认短语回复 | ||
| 119 | + //defaultReply(nbbm, reqCode, d80.getConfirmRs() == 0?true:false); | ||
| 120 | + | ||
| 121 | + switch (reqCode) { | ||
| 122 | + case 0xA3: | ||
| 123 | + //出场请求回复 | ||
| 124 | + applyOutReply(d80); | ||
| 125 | + break; | ||
| 126 | + case 0xA5: | ||
| 127 | + //进场请求回复 | ||
| 128 | + applyInReply(d80); | ||
| 129 | + break; | ||
| 130 | + } | ||
| 131 | + } | ||
| 132 | + | ||
| 133 | + /** | ||
| 134 | + * @Title: applyOutReply | ||
| 135 | + * @Description: TODO(出场请求回复) | ||
| 136 | + */ | ||
| 137 | + public void applyOutReply(D80 d80) { | ||
| 138 | + //同意 | ||
| 139 | + if (d80.getConfirmRs() == 0) { | ||
| 140 | + String nbbm = BasicData.deviceId2NbbmMap.get(d80.getDeviceId()); | ||
| 141 | + | ||
| 142 | + ScheduleRealInfo sch = dayOfSchedule.nextByBcType(nbbm, "out"); | ||
| 143 | + if (null == sch) | ||
| 144 | + return; | ||
| 145 | + | ||
| 146 | + LineConfig conf = lineConfigData.get(sch.getXlBm()); | ||
| 147 | + if (conf.getOutConfig() == 1) { | ||
| 148 | + //为相关班次写入请求出场时间 | ||
| 149 | + sch.setFcsjActualAll(d80.getTimestamp()); | ||
| 150 | + | ||
| 151 | + dayOfSchedule.save(sch); | ||
| 152 | + //通知页面 | ||
| 153 | + sendUtils.refreshSch(sch); | ||
| 154 | + } | ||
| 155 | + } | ||
| 156 | + } | ||
| 157 | + | ||
| 158 | + /** | ||
| 159 | + * @Title: applyInReply | ||
| 160 | + * @Description: TODO(进场请求回复) | ||
| 161 | + */ | ||
| 162 | + public void applyInReply(D80 d80) { | ||
| 163 | + //同意 | ||
| 164 | + if (d80.getConfirmRs() == 0) { | ||
| 165 | + String nbbm = BasicData.deviceId2NbbmMap.get(d80.getDeviceId()); | ||
| 166 | + | ||
| 167 | + ScheduleRealInfo sch = dayOfSchedule.nextByBcType(nbbm, "in"); | ||
| 168 | + if (null == sch) | ||
| 169 | + return; | ||
| 170 | + | ||
| 171 | + LineConfig conf = lineConfigData.get(sch.getXlBm()); | ||
| 172 | + if (conf.getOutConfig() == 1) { | ||
| 173 | + //为相关班次写入进场时间 | ||
| 174 | + sch.setZdsjActualAll(d80.getTimestamp()); | ||
| 175 | + | ||
| 176 | + //没有里程的进场班次 | ||
| 177 | + if (isEmpty(sch.getBcsj()) && isEmpty(sch.getJhlc())) | ||
| 178 | + sch.setFcsjActualAll(d80.getTimestamp()); | ||
| 179 | + | ||
| 180 | + dayOfSchedule.save(sch); | ||
| 181 | + //通知页面 | ||
| 182 | + sendUtils.refreshSch(sch); | ||
| 183 | + } | ||
| 184 | + } | ||
| 185 | + } | ||
| 186 | + | ||
| 187 | + public boolean isEmpty(Integer v) { | ||
| 188 | + return v == null || v.equals(0); | ||
| 189 | + } | ||
| 190 | + | ||
| 191 | + public boolean isEmpty(Double v) { | ||
| 192 | + return v == null || v.equals(0); | ||
| 193 | + } | ||
| 194 | + | ||
| 195 | + public void defaultReply(String nbbm, short requestCode, boolean agree) { | ||
| 196 | + Line line = BasicData.nbbm2LineMap.get(nbbm); | ||
| 197 | + String lineCode = null; | ||
| 198 | + | ||
| 199 | + if (line != null) | ||
| 200 | + lineCode = line.getLineCode(); | ||
| 201 | + else { | ||
| 202 | + try { | ||
| 203 | + lineCode = gpsRealData.get(BasicData.deviceId2NbbmMap.inverse().get(nbbm)).getLineId().toString(); | ||
| 204 | + } catch (Exception e) { | ||
| 205 | + logger.error("", e); | ||
| 206 | + } | ||
| 207 | + } | ||
| 208 | + | ||
| 209 | + if (null == lineCode) | ||
| 210 | + return; | ||
| 211 | + | ||
| 212 | + LineConfig conf = lineConfigData.get(lineCode); | ||
| 213 | + D80ReplyTemp temp = conf.findByCode(requestCode); | ||
| 214 | + | ||
| 215 | + if (null == temp) | ||
| 216 | + return; | ||
| 217 | + | ||
| 218 | + String text; | ||
| 219 | + if (agree) | ||
| 220 | + text = temp.getAgreeText(); | ||
| 221 | + else | ||
| 222 | + text = temp.getRejectText(); | ||
| 223 | + | ||
| 224 | + directiveService.send60Phrase(nbbm, text, "系统"); | ||
| 225 | + } | ||
| 226 | + | ||
| 227 | + /** | ||
| 228 | + * @Title: resumeOperation | ||
| 229 | + * @Description: TODO(恢复营运) | ||
| 230 | + */ | ||
| 231 | + public void resumeOperation(D80 d80) { | ||
| 232 | + | ||
| 233 | + } | ||
| 234 | + | ||
| 235 | + /** | ||
| 236 | + * @Title: applyTiaodang | ||
| 237 | + * @Description: TODO(申请调档) | ||
| 238 | + */ | ||
| 239 | + public void applyTiaodang(D80 d80) { | ||
| 240 | + | ||
| 241 | + } | ||
| 242 | + | ||
| 243 | + /** | ||
| 244 | + * @Title: unconfirmed80 | ||
| 245 | + * @Description: TODO(根据lineCode 获取未处理的80数据) | ||
| 246 | + */ | ||
| 247 | + public List<D80> unconfirmed80(String lineCode) { | ||
| 248 | + List<D80> lineAll = findByLine(lineCode), rs = new ArrayList<>(); | ||
| 249 | + | ||
| 250 | + for (D80 d80 : lineAll) | ||
| 251 | + if (!d80.isConfirm()) | ||
| 252 | + rs.add(d80); | ||
| 253 | + | ||
| 254 | + return rs; | ||
| 255 | + } | ||
| 256 | + | ||
| 257 | + public List<D80> findByLine(String lineCode) { | ||
| 258 | + List<D80> rs = new ArrayList<>(); | ||
| 259 | + for (D80 d80 : d80Maps.values()) { | ||
| 260 | + if (d80 != null && d80.getData().getLineId().equals(lineCode)) | ||
| 261 | + rs.add(d80); | ||
| 262 | + } | ||
| 263 | + return rs; | ||
| 264 | + } | ||
| 265 | + | ||
| 266 | + public D80 findById(int id) { | ||
| 267 | + return d80Maps.get(id); | ||
| 268 | + } | ||
| 269 | + | ||
| 270 | +/* public String coordHtmlStr(GpsEntity gps) { | ||
| 271 | + | ||
| 272 | + return "<span class=\"nt-coord\" data-lon=\"" + gps.getLon() + "\" data-lat=\"" + gps.getLat() + "\"></span>"; | ||
| 273 | + }*/ | ||
| 274 | + | ||
| 275 | + public Collection<D80> findAll() { | ||
| 276 | + return d80Maps.values(); | ||
| 277 | + } | ||
| 278 | + | ||
| 279 | + public void clear(String lineCode) { | ||
| 280 | + logger.info("清除 80数据 before: " + d80Maps.size()); | ||
| 281 | + List<D80> rems = findByLine(lineCode); | ||
| 282 | + for (D80 d80 : rems) { | ||
| 283 | + d80Maps.remove(d80.getId()); | ||
| 284 | + } | ||
| 285 | + logger.info("清除 80数据 after: " + d80Maps.size()); | ||
| 286 | + } | ||
| 287 | + | ||
| 288 | + public Collection<? extends D80> findByCar(String nbbm) { | ||
| 289 | + List<D80> rs = new ArrayList<>(); | ||
| 290 | + String deviceId = BasicData.deviceId2NbbmMap.inverse().get(nbbm); | ||
| 291 | + if (null == deviceId) | ||
| 292 | + return rs; | ||
| 293 | + | ||
| 294 | + Collection<D80> all = findAll(); | ||
| 295 | + for (D80 d80 : all) { | ||
| 296 | + if (d80.getDeviceId().equals(deviceId)) | ||
| 297 | + rs.add(d80); | ||
| 298 | + } | ||
| 299 | + return rs; | ||
| 300 | + } | ||
| 314 | } | 301 | } |
src/main/java/com/bsth/entity/directive/D80.java
| 1 | package com.bsth.entity.directive; | 1 | package com.bsth.entity.directive; |
| 2 | 2 | ||
| 3 | -import java.util.Date; | ||
| 4 | - | ||
| 5 | -import javax.persistence.CascadeType; | ||
| 6 | -import javax.persistence.Embeddable; | ||
| 7 | -import javax.persistence.Entity; | ||
| 8 | -import javax.persistence.FetchType; | ||
| 9 | -import javax.persistence.GeneratedValue; | ||
| 10 | -import javax.persistence.Id; | ||
| 11 | -import javax.persistence.NamedAttributeNode; | ||
| 12 | -import javax.persistence.NamedEntityGraph; | ||
| 13 | -import javax.persistence.NamedEntityGraphs; | ||
| 14 | -import javax.persistence.OneToOne; | ||
| 15 | -import javax.persistence.Table; | ||
| 16 | -import javax.persistence.Transient; | ||
| 17 | - | ||
| 18 | import com.bsth.entity.directive.DC0.DC0Data; | 3 | import com.bsth.entity.directive.DC0.DC0Data; |
| 19 | 4 | ||
| 5 | +import javax.persistence.*; | ||
| 6 | +import java.util.Date; | ||
| 7 | + | ||
| 20 | /** | 8 | /** |
| 21 | * | 9 | * |
| 22 | * @ClassName: D80 | 10 | * @ClassName: D80 |
| @@ -92,7 +80,7 @@ public class D80 { | @@ -92,7 +80,7 @@ public class D80 { | ||
| 92 | /** | 80 | /** |
| 93 | * 线路编码 | 81 | * 线路编码 |
| 94 | */ | 82 | */ |
| 95 | - private Integer lineId; | 83 | + private String lineId; |
| 96 | 84 | ||
| 97 | /** | 85 | /** |
| 98 | * 车辆内部编码 | 86 | * 车辆内部编码 |
| @@ -116,13 +104,6 @@ public class D80 { | @@ -116,13 +104,6 @@ public class D80 { | ||
| 116 | this.requestCode = requestCode; | 104 | this.requestCode = requestCode; |
| 117 | } | 105 | } |
| 118 | 106 | ||
| 119 | - public Integer getLineId() { | ||
| 120 | - return lineId; | ||
| 121 | - } | ||
| 122 | - | ||
| 123 | - public void setLineId(Integer lineId) { | ||
| 124 | - this.lineId = lineId; | ||
| 125 | - } | ||
| 126 | 107 | ||
| 127 | public String getNbbm() { | 108 | public String getNbbm() { |
| 128 | return nbbm; | 109 | return nbbm; |
| @@ -131,6 +112,14 @@ public class D80 { | @@ -131,6 +112,14 @@ public class D80 { | ||
| 131 | public void setNbbm(String nbbm) { | 112 | public void setNbbm(String nbbm) { |
| 132 | this.nbbm = nbbm; | 113 | this.nbbm = nbbm; |
| 133 | } | 114 | } |
| 115 | + | ||
| 116 | + public String getLineId() { | ||
| 117 | + return lineId; | ||
| 118 | + } | ||
| 119 | + | ||
| 120 | + public void setLineId(String lineId) { | ||
| 121 | + this.lineId = lineId; | ||
| 122 | + } | ||
| 134 | } | 123 | } |
| 135 | 124 | ||
| 136 | @Transient | 125 | @Transient |
src/main/java/com/bsth/service/directive/DirectiveServiceImpl.java
| @@ -302,7 +302,7 @@ public class DirectiveServiceImpl extends BaseServiceImpl<D60, Integer> implemen | @@ -302,7 +302,7 @@ public class DirectiveServiceImpl extends BaseServiceImpl<D60, Integer> implemen | ||
| 302 | 302 | ||
| 303 | Map<String, List<D80>> rs = new HashMap<>(); | 303 | Map<String, List<D80>> rs = new HashMap<>(); |
| 304 | for (String code : lineList) | 304 | for (String code : lineList) |
| 305 | - rs.put(code, pilotReport.unconfirmed80(Integer.parseInt(code))); | 305 | + rs.put(code, pilotReport.unconfirmed80(code)); |
| 306 | 306 | ||
| 307 | return rs; | 307 | return rs; |
| 308 | } | 308 | } |