Commit 6de382f4db581d2dbc94c2a74096e138f11acddf

Authored by 潘钊
1 parent 2d30c614

update...

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