ZnddMessage.java
3.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
package com.bsth.data.zndd;
import com.bsth.entity.realcontrol.ScheduleRealInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.text.SimpleDateFormat;
import java.util.*;
@RestController
@RequestMapping("/znddmessage")
public class ZnddMessage {
static List<Map> LISTMAPALL= new ArrayList<>(); //返回给前台的班次情况
Logger logger = LoggerFactory.getLogger(this.getClass());
public void saveSch(ScheduleRealInfo sch){
Map m = new HashMap();
m.put("sch",sch);
//防止重复的
for (Map mm : LISTMAPALL){
ScheduleRealInfo sr = (ScheduleRealInfo) mm.get("sch");
if (sr.getClZbh().equals(sch.getClZbh())){
return;
}
}
LISTMAPALL.add(m);
handleAll();
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
@RequestMapping(value="/messagelist",method = RequestMethod.GET)
public List<Map> listAll(){
handleAll();
return LISTMAPALL;
}
//新的请求处理一下
public void handleAll(){
for (Map m : LISTMAPALL){
ScheduleRealInfo sr = (ScheduleRealInfo) m.get("sch");
//1.离线 2.实发时间为空 3.已过待发时间还没发车的
long time = System.currentTimeMillis();//正常大客流添加班次也是在上下5分钟浮动,实际时间+10分钟
//超过待发时间 实发时间还是null的
// if (sr.getFcsjT() + (1000 * 60 * 10) < time && sr.getFcsjT() + (1000 * 60 * 10) > time) { //实际使用 //测试注释
MessageStatus(sr, m);
m.put("sch", sr);
if (m.get("uuid") == null)
m.put("uuid",AutomaticSch.UUID());
// }
if (sr.getMessageDKL() == 10){
LISTMAPALL.remove(m);
return;
}
}
}
public void MessageStatus(ScheduleRealInfo sch, Map map){
switch (sch.getMessageDKL()) {
case 0:
jsy(sch,map);
break;
case 1:
ts_car(sch,map);
break;
case 2:
break;
case 3:
break;
case 4:
break;
}
}
//下发驾驶员
public void jsy(ScheduleRealInfo sch, Map map){
try {
//暂无
sch.setMessageDKL(sch.getMessageDKL()+1);
if (map.get("j_sj") == null)
map.put("j_sj",sdf.format(new Date()));
MessageStatus(sch, map);//继续下一项
}catch (Exception e){
logger.info("下发驾驶员异常---",e);
}finally {
logger.info("驾驶员下发成功");
}
}
//下发车辆
public void ts_car(ScheduleRealInfo sch, Map map){
try {
//暂无
sch.setMessageDKL(sch.getMessageDKL()+1);
if (map.get("car_sj") == null)
map.put("car_sj",sdf.format(new Date()));
MessageStatus(sch, map);//继续下一项
}catch (Exception e){
logger.info("下发车辆异常---",e);
}finally {
logger.info("下发车辆成功");
}
}
}