Commit e0659d5d6b45aaca6c96bfbf50a3b51a284bd2d3

Authored by 潘钊
1 parent 4af18242

update...

src/main/java/com/bsth/data/schedule/late_adjust/ScheduleLateThread.java
@@ -6,6 +6,8 @@ import com.bsth.data.schedule.ScheduleComparator; @@ -6,6 +6,8 @@ import com.bsth.data.schedule.ScheduleComparator;
6 import com.bsth.entity.realcontrol.ScheduleRealInfo; 6 import com.bsth.entity.realcontrol.ScheduleRealInfo;
7 import com.bsth.websocket.handler.SendUtils; 7 import com.bsth.websocket.handler.SendUtils;
8 import org.apache.commons.lang3.StringUtils; 8 import org.apache.commons.lang3.StringUtils;
  9 +import org.slf4j.Logger;
  10 +import org.slf4j.LoggerFactory;
9 import org.springframework.beans.factory.annotation.Autowired; 11 import org.springframework.beans.factory.annotation.Autowired;
10 import org.springframework.stereotype.Component; 12 import org.springframework.stereotype.Component;
11 13
@@ -31,43 +33,49 @@ public class ScheduleLateThread extends Thread{ @@ -31,43 +33,49 @@ public class ScheduleLateThread extends Thread{
31 @Autowired 33 @Autowired
32 SendUtils sendUtils; 34 SendUtils sendUtils;
33 35
  36 + Logger logger = LoggerFactory.getLogger(this.getClass());
  37 +
34 private static Comparator<ScheduleRealInfo> cpm = new ScheduleComparator.DFSJ(); 38 private static Comparator<ScheduleRealInfo> cpm = new ScheduleComparator.DFSJ();
35 39
36 @Override 40 @Override
37 public void run() { 41 public void run() {
38 - List<ScheduleRealInfo> all = new ArrayList<>(dayOfSchedule.findAll());  
39 - Collections.sort(all, cpm); 42 + try{
  43 + List<ScheduleRealInfo> all = new ArrayList<>(dayOfSchedule.findAll());
  44 + Collections.sort(all, cpm);
40 45
41 - long t = System.currentTimeMillis();  
42 - int size = all.size(); 46 + long t = System.currentTimeMillis();
  47 + int size = all.size();
43 48
44 - ScheduleRealInfo sch;  
45 - for(int i = 0; i < size; i ++){  
46 - sch = all.get(i);  
47 - if(sch.getDfsjT() > t)  
48 - break; 49 + ScheduleRealInfo sch;
  50 + for(int i = 0; i < size; i ++){
  51 + sch = all.get(i);
  52 + if(sch.getDfsjT() > t)
  53 + break;
49 54
50 - if(sch.isLate())  
51 - continue; 55 + if(sch.isLate())
  56 + continue;
52 57
53 - if(sch.getStatus() == 0  
54 - && StringUtils.isEmpty(sch.getFcsjActual())){ 58 + if(sch.getStatus() == 0
  59 + && StringUtils.isEmpty(sch.getFcsjActual())){
55 60
56 - //检查应发未到 当前班次无起点到达时间  
57 - if(StringUtils.isEmpty(sch.getQdzArrDatesj())){  
58 - ScheduleRealInfo prev = dayOfSchedule.prev(sch);  
59 - //上一个班次也没有实际终点到达时间  
60 - if(prev != null && StringUtils.isEmpty(prev.getZdsjActual())){  
61 - //进入误点调整程序  
62 - LateAdjustHandle.putLate(sch); 61 + //检查应发未到 当前班次无起点到达时间
  62 + if(StringUtils.isEmpty(sch.getQdzArrDatesj())){
  63 + ScheduleRealInfo prev = dayOfSchedule.prev(sch);
  64 + //上一个班次也没有实际终点到达时间
  65 + if(prev != null && StringUtils.isEmpty(prev.getZdsjActual())){
  66 + //进入误点调整程序
  67 + LateAdjustHandle.putLate(sch);
  68 + }
63 } 69 }
64 - }  
65 70
66 - //应发未发  
67 - sch.setLate(true);  
68 - //通知客户端  
69 - sendUtils.refreshSch(sch); 71 + //应发未发
  72 + sch.setLate(true);
  73 + //通知客户端
  74 + sendUtils.refreshSch(sch);
  75 + }
70 } 76 }
  77 + }catch (Exception e){
  78 + logger.error("", e);
71 } 79 }
72 } 80 }
73 } 81 }
74 \ No newline at end of file 82 \ No newline at end of file
src/main/java/com/bsth/entity/directive/D80.java
@@ -241,6 +241,7 @@ public class D80 { @@ -241,6 +241,7 @@ public class D80 {
241 DC0Data data = new DC0Data(); 241 DC0Data data = new DC0Data();
242 data.setOperCode2((short) 0x86); 242 data.setOperCode2((short) 0x86);
243 data.setRequestAck((short) (reply == 0 ? 0x06 : 0x15)); 243 data.setRequestAck((short) (reply == 0 ? 0x06 : 0x15));
  244 + data.setTimestamp(this.getTimestamp());
244 c0.setData(data); 245 c0.setData(data);
245 this.setC0(c0); 246 this.setC0(c0);
246 } 247 }
src/main/java/com/bsth/entity/directive/DC0.java
1 package com.bsth.entity.directive; 1 package com.bsth.entity.directive;
2 2
3 -import javax.persistence.Embeddable;  
4 -import javax.persistence.Entity;  
5 -import javax.persistence.GeneratedValue;  
6 -import javax.persistence.Id;  
7 -import javax.persistence.Table; 3 +import javax.persistence.*;
8 4
9 /** 5 /**
10 * 6 *
@@ -52,6 +48,12 @@ public class DC0 { @@ -52,6 +48,12 @@ public class DC0 {
52 */ 48 */
53 private Short requestAck; 49 private Short requestAck;
54 50
  51 + /**
  52 + * 时间戳
  53 + */
  54 + @Transient
  55 + private Long timestamp;
  56 +
55 public Short getOperCode2() { 57 public Short getOperCode2() {
56 return operCode2; 58 return operCode2;
57 } 59 }
@@ -67,6 +69,14 @@ public class DC0 { @@ -67,6 +69,14 @@ public class DC0 {
67 public void setRequestAck(Short requestAck) { 69 public void setRequestAck(Short requestAck) {
68 this.requestAck = requestAck; 70 this.requestAck = requestAck;
69 } 71 }
  72 +
  73 + public Long getTimestamp() {
  74 + return timestamp;
  75 + }
  76 +
  77 + public void setTimestamp(Long timestamp) {
  78 + this.timestamp = timestamp;
  79 + }
70 } 80 }
71 81
72 public Integer getId() { 82 public Integer getId() {