Commit 6de382f4db581d2dbc94c2a74096e138f11acddf
1 parent
2d30c614
update...
Showing
7 changed files
with
49 additions
and
4 deletions
src/main/java/com/bsth/data/directive/DirectiveCreator.java
| @@ -42,7 +42,7 @@ public class DirectiveCreator { | @@ -42,7 +42,7 @@ public class DirectiveCreator { | ||
| 42 | * @return Directive60 返回类型 | 42 | * @return Directive60 返回类型 |
| 43 | * @throws | 43 | * @throws |
| 44 | */ | 44 | */ |
| 45 | - public D60 createD60(String nbbm, String text, Short dispatchInstruct, int upDown, int state) { | 45 | + public D60 createD60(String nbbm, String text, Short dispatchInstruct, int upDown, int state,String lineCode) { |
| 46 | Long timestamp = System.currentTimeMillis(); | 46 | Long timestamp = System.currentTimeMillis(); |
| 47 | 47 | ||
| 48 | Short company = Short.parseShort(BasicData.nbbm2CompanyCodeMap.get(nbbm)); | 48 | Short company = Short.parseShort(BasicData.nbbm2CompanyCodeMap.get(nbbm)); |
| @@ -66,6 +66,7 @@ public class DirectiveCreator { | @@ -66,6 +66,7 @@ public class DirectiveCreator { | ||
| 66 | data.setCompanyCode(company); | 66 | data.setCompanyCode(company); |
| 67 | data.setMsgId(msgId); | 67 | data.setMsgId(msgId); |
| 68 | directive.setData(data); | 68 | directive.setData(data); |
| 69 | + directive.setLineCode(lineCode); | ||
| 69 | long serviceState; | 70 | long serviceState; |
| 70 | try { | 71 | try { |
| 71 | serviceState = Consts.SERVICE_STATE[upDown][state]; | 72 | serviceState = Consts.SERVICE_STATE[upDown][state]; |
src/main/java/com/bsth/data/directive/DirectivesPstThread.java
| @@ -47,6 +47,10 @@ public class DirectivesPstThread extends Thread { | @@ -47,6 +47,10 @@ public class DirectivesPstThread extends Thread { | ||
| 47 | if(d60.isDispatch()){ | 47 | if(d60.isDispatch()){ |
| 48 | ScheduleRealInfo sch = d60.getSch(); | 48 | ScheduleRealInfo sch = d60.getSch(); |
| 49 | //如果关联的班次已经不存在了,放弃入库 | 49 | //如果关联的班次已经不存在了,放弃入库 |
| 50 | + if(sch.isDeleted()){ | ||
| 51 | + logger.warn("save 指令,发现 deleted=true 的班次,id=" + sch.getId()); | ||
| 52 | + continue; | ||
| 53 | + } | ||
| 50 | if(dayOfSchedule.get(sch.getId()) == null){ | 54 | if(dayOfSchedule.get(sch.getId()) == null){ |
| 51 | logger.warn("班次:" + sch.getId() + "不存在了,调度指令放弃入库。"); | 55 | logger.warn("班次:" + sch.getId() + "不存在了,调度指令放弃入库。"); |
| 52 | continue; | 56 | continue; |
src/main/java/com/bsth/data/schedule/thread/SchedulePstThread.java
| @@ -36,6 +36,11 @@ public class SchedulePstThread extends Thread { | @@ -36,6 +36,11 @@ public class SchedulePstThread extends Thread { | ||
| 36 | if (null == schedule) | 36 | if (null == schedule) |
| 37 | break; | 37 | break; |
| 38 | 38 | ||
| 39 | + if(schedule.isDeleted()){ | ||
| 40 | + logger.error("save 发现 deleted=true 的班次,id: " + schedule.getId()); | ||
| 41 | + continue; | ||
| 42 | + } | ||
| 43 | + | ||
| 39 | try { | 44 | try { |
| 40 | scheduleRepository.save(schedule); | 45 | scheduleRepository.save(schedule); |
| 41 | } | 46 | } |
src/main/java/com/bsth/entity/directive/D60.java
| @@ -62,6 +62,11 @@ public class D60 extends Directive { | @@ -62,6 +62,11 @@ public class D60 extends Directive { | ||
| 62 | private boolean isDispatch; | 62 | private boolean isDispatch; |
| 63 | 63 | ||
| 64 | /** | 64 | /** |
| 65 | + * 线路编码 | ||
| 66 | + */ | ||
| 67 | + private String lineCode; | ||
| 68 | + | ||
| 69 | + /** | ||
| 65 | * 相关联的班次 | 70 | * 相关联的班次 |
| 66 | */ | 71 | */ |
| 67 | @JsonIgnore | 72 | @JsonIgnore |
| @@ -84,6 +89,14 @@ public class D60 extends Directive { | @@ -84,6 +89,14 @@ public class D60 extends Directive { | ||
| 84 | this.reply47Time = reply47Time; | 89 | this.reply47Time = reply47Time; |
| 85 | } | 90 | } |
| 86 | 91 | ||
| 92 | + public String getLineCode() { | ||
| 93 | + return lineCode; | ||
| 94 | + } | ||
| 95 | + | ||
| 96 | + public void setLineCode(String lineCode) { | ||
| 97 | + this.lineCode = lineCode; | ||
| 98 | + } | ||
| 99 | + | ||
| 87 | @Embeddable | 100 | @Embeddable |
| 88 | public static class D60Data { | 101 | public static class D60Data { |
| 89 | // 公司代码 | 102 | // 公司代码 |
src/main/java/com/bsth/entity/realcontrol/ScheduleRealInfo.java
| @@ -204,6 +204,11 @@ public class ScheduleRealInfo { | @@ -204,6 +204,11 @@ public class ScheduleRealInfo { | ||
| 204 | @Transient | 204 | @Transient |
| 205 | private int fcpSn; | 205 | private int fcpSn; |
| 206 | 206 | ||
| 207 | + /** 标记班次已被删除 */ | ||
| 208 | + @Transient | ||
| 209 | + @JsonIgnore | ||
| 210 | + private boolean deleted; | ||
| 211 | + | ||
| 207 | public boolean isDfAuto() { | 212 | public boolean isDfAuto() { |
| 208 | return dfAuto; | 213 | return dfAuto; |
| 209 | } | 214 | } |
| @@ -912,4 +917,12 @@ public class ScheduleRealInfo { | @@ -912,4 +917,12 @@ public class ScheduleRealInfo { | ||
| 912 | public boolean _isInout(){ | 917 | public boolean _isInout(){ |
| 913 | return this.getBcType().equals("out") || this.getBcType().equals("in"); | 918 | return this.getBcType().equals("out") || this.getBcType().equals("in"); |
| 914 | } | 919 | } |
| 920 | + | ||
| 921 | + public boolean isDeleted() { | ||
| 922 | + return deleted; | ||
| 923 | + } | ||
| 924 | + | ||
| 925 | + public void setDeleted(boolean deleted) { | ||
| 926 | + this.deleted = deleted; | ||
| 927 | + } | ||
| 915 | } | 928 | } |
src/main/java/com/bsth/service/directive/DirectiveServiceImpl.java
| @@ -119,6 +119,8 @@ public class DirectiveServiceImpl extends BaseServiceImpl<D60, Integer> implemen | @@ -119,6 +119,8 @@ public class DirectiveServiceImpl extends BaseServiceImpl<D60, Integer> implemen | ||
| 119 | 119 | ||
| 120 | d60 = new DirectiveCreator().createD60_01(sch.getClZbh(), text, Integer.parseInt(sch.getXlDir()) | 120 | d60 = new DirectiveCreator().createD60_01(sch.getClZbh(), text, Integer.parseInt(sch.getXlDir()) |
| 121 | , 0, new Date(alarmTime)); | 121 | , 0, new Date(alarmTime)); |
| 122 | + | ||
| 123 | + d60.setLineCode(sch.getXlBm()); | ||
| 122 | } catch (Exception e) { | 124 | } catch (Exception e) { |
| 123 | logger.error("生成调度指令时出现异常", e); | 125 | logger.error("生成调度指令时出现异常", e); |
| 124 | return -1; | 126 | return -1; |
| @@ -190,7 +192,7 @@ public class DirectiveServiceImpl extends BaseServiceImpl<D60, Integer> implemen | @@ -190,7 +192,7 @@ public class DirectiveServiceImpl extends BaseServiceImpl<D60, Integer> implemen | ||
| 190 | logger.info("切换运营状态, nbbm: " + nbbm + " ,state: " + state + " ,upDown:" + upDown); | 192 | logger.info("切换运营状态, nbbm: " + nbbm + " ,state: " + state + " ,upDown:" + upDown); |
| 191 | 193 | ||
| 192 | String text = "切换为 " + (upDown == 0 ? "上行" : "下行") + (state == 0 ? "营运" : "未营运"); | 194 | String text = "切换为 " + (upDown == 0 ? "上行" : "下行") + (state == 0 ? "营运" : "未营运"); |
| 193 | - D60 d60 = new DirectiveCreator().createD60(nbbm, text, (short) 0x03, upDown, state); | 195 | + D60 d60 = new DirectiveCreator().createD60(nbbm, text, (short) 0x03, upDown, state, null); |
| 194 | 196 | ||
| 195 | if (null == d60) | 197 | if (null == d60) |
| 196 | return -1; | 198 | return -1; |
| @@ -257,6 +259,7 @@ public class DirectiveServiceImpl extends BaseServiceImpl<D60, Integer> implemen | @@ -257,6 +259,7 @@ public class DirectiveServiceImpl extends BaseServiceImpl<D60, Integer> implemen | ||
| 257 | public D60 create60Data(String nbbm, String text, Short dispatchInstruct, ScheduleRealInfo sch) { | 259 | public D60 create60Data(String nbbm, String text, Short dispatchInstruct, ScheduleRealInfo sch) { |
| 258 | 260 | ||
| 259 | String deviceId = BasicData.deviceId2NbbmMap.inverse().get(nbbm); | 261 | String deviceId = BasicData.deviceId2NbbmMap.inverse().get(nbbm); |
| 262 | + String lineCode = null; | ||
| 260 | if (null == deviceId) { | 263 | if (null == deviceId) { |
| 261 | logger.error("没有设备号对照的车辆:" + nbbm); | 264 | logger.error("没有设备号对照的车辆:" + nbbm); |
| 262 | return null; | 265 | return null; |
| @@ -281,13 +284,14 @@ public class DirectiveServiceImpl extends BaseServiceImpl<D60, Integer> implemen | @@ -281,13 +284,14 @@ public class DirectiveServiceImpl extends BaseServiceImpl<D60, Integer> implemen | ||
| 281 | } else { | 284 | } else { |
| 282 | upDown = gpsData.getUpDown(); | 285 | upDown = gpsData.getUpDown(); |
| 283 | state = gpsData.getState(); | 286 | state = gpsData.getState(); |
| 287 | + lineCode = gpsData.getLineId(); | ||
| 284 | } | 288 | } |
| 285 | } else { | 289 | } else { |
| 286 | upDown = Byte.parseByte(sch.getXlDir()); | 290 | upDown = Byte.parseByte(sch.getXlDir()); |
| 287 | state = 0; | 291 | state = 0; |
| 288 | } | 292 | } |
| 289 | 293 | ||
| 290 | - return new DirectiveCreator().createD60(nbbm, text, dispatchInstruct, upDown, state); | 294 | + return new DirectiveCreator().createD60(nbbm, text, dispatchInstruct, upDown, state, lineCode); |
| 291 | } | 295 | } |
| 292 | 296 | ||
| 293 | @Override | 297 | @Override |
src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
| @@ -643,8 +643,9 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf | @@ -643,8 +643,9 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf | ||
| 643 | Map<String, Object> rs = new HashMap<>(); | 643 | Map<String, Object> rs = new HashMap<>(); |
| 644 | rs.put("status", ResponseCode.ERROR); | 644 | rs.put("status", ResponseCode.ERROR); |
| 645 | 645 | ||
| 646 | + ScheduleRealInfo sch = null; | ||
| 646 | try { | 647 | try { |
| 647 | - ScheduleRealInfo sch = dayOfSchedule.get(id); | 648 | + sch = dayOfSchedule.get(id); |
| 648 | if (sch == null) { | 649 | if (sch == null) { |
| 649 | rs.put("msg", "无效的id号"); | 650 | rs.put("msg", "无效的id号"); |
| 650 | return rs; | 651 | return rs; |
| @@ -655,6 +656,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf | @@ -655,6 +656,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf | ||
| 655 | return rs; | 656 | return rs; |
| 656 | } | 657 | } |
| 657 | 658 | ||
| 659 | + sch.setDeleted(true); | ||
| 658 | //解除和调度指令的外键约束 | 660 | //解除和调度指令的外键约束 |
| 659 | jdbcTemplate.update(Constants.REMOVE_DIRECTIVE_SCH_FK, id); | 661 | jdbcTemplate.update(Constants.REMOVE_DIRECTIVE_SCH_FK, id); |
| 660 | 662 | ||
| @@ -674,9 +676,12 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf | @@ -674,9 +676,12 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf | ||
| 674 | rs.put("ts", ts); | 676 | rs.put("ts", ts); |
| 675 | rs.put("delete", sch); | 677 | rs.put("delete", sch); |
| 676 | } | 678 | } |
| 679 | + else | ||
| 680 | + sch.setDeleted(false); | ||
| 677 | }catch (Exception e){ | 681 | }catch (Exception e){ |
| 678 | logger.error("", e); | 682 | logger.error("", e); |
| 679 | rs.put("msg", e.getMessage()); | 683 | rs.put("msg", e.getMessage()); |
| 684 | + sch.setDeleted(false); | ||
| 680 | } | 685 | } |
| 681 | 686 | ||
| 682 | return rs; | 687 | return rs; |