Commit afe65a2d98714567c3063c213f2d4070b797bded

Authored by 王通
1 parent 1b122441

1.调度加入异常停车提示

Too many changes to show.

To preserve performance only 7 of 12 files are displayed.

src/main/java/com/bsth/Application.java
1   -package com.bsth;
2   -
3   -import com.fasterxml.jackson.databind.ObjectMapper;
4   -import com.fasterxml.jackson.databind.SerializationFeature;
5   -import org.springframework.boot.SpringApplication;
6   -import org.springframework.boot.autoconfigure.SpringBootApplication;
7   -import org.springframework.boot.builder.SpringApplicationBuilder;
8   -import org.springframework.boot.context.web.SpringBootServletInitializer;
9   -import org.springframework.context.annotation.Bean;
10   -import org.springframework.context.annotation.Primary;
11   -import org.springframework.transaction.annotation.EnableTransactionManagement;
12   -
13   -import java.util.concurrent.Executors;
14   -import java.util.concurrent.ScheduledExecutorService;
15   -
16   -@EnableTransactionManagement
17   -@SpringBootApplication
18   -public class Application extends SpringBootServletInitializer {
19   -
20   - public static ScheduledExecutorService mainServices = Executors.newScheduledThreadPool(18);
21   -
22   - @Override
23   - protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
24   - return application.sources(Application.class);
25   - }
26   -
27   - @Bean
28   - @Primary
29   - public ObjectMapper objectMapper() {
30   - ObjectMapper objectMapper = new ObjectMapper();
31   - objectMapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
32   -
33   - return objectMapper;
34   - }
35   -
36   - public static void main(String[] args) throws Exception {
37   - SpringApplication.run(Application.class, args);
38   - }
  1 +package com.bsth;
  2 +
  3 +import com.fasterxml.jackson.databind.ObjectMapper;
  4 +import com.fasterxml.jackson.databind.SerializationFeature;
  5 +import org.springframework.boot.SpringApplication;
  6 +import org.springframework.boot.autoconfigure.SpringBootApplication;
  7 +import org.springframework.boot.builder.SpringApplicationBuilder;
  8 +import org.springframework.boot.context.web.SpringBootServletInitializer;
  9 +import org.springframework.context.annotation.Bean;
  10 +import org.springframework.context.annotation.Primary;
  11 +import org.springframework.scheduling.annotation.EnableScheduling;
  12 +import org.springframework.transaction.annotation.EnableTransactionManagement;
  13 +
  14 +import java.util.concurrent.Executors;
  15 +import java.util.concurrent.ScheduledExecutorService;
  16 +
  17 +@EnableScheduling
  18 +@EnableTransactionManagement
  19 +@SpringBootApplication
  20 +public class Application extends SpringBootServletInitializer {
  21 +
  22 + public static ScheduledExecutorService mainServices = Executors.newScheduledThreadPool(18);
  23 +
  24 + @Override
  25 + protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
  26 + return application.sources(Application.class);
  27 + }
  28 +
  29 + @Bean
  30 + @Primary
  31 + public ObjectMapper objectMapper() {
  32 + ObjectMapper objectMapper = new ObjectMapper();
  33 + objectMapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
  34 +
  35 + return objectMapper;
  36 + }
  37 +
  38 + public static void main(String[] args) throws Exception {
  39 + SpringApplication.run(Application.class, args);
  40 + }
39 41 }
40 42 \ No newline at end of file
... ...
src/main/java/com/bsth/common/SystemParamKeys.java
... ... @@ -6,4 +6,6 @@ package com.bsth.common;
6 6 public class SystemParamKeys {
7 7  
8 8 public static final String SPECIAL_ROLES = "special.roles";
  9 +
  10 + public static final String API_URL_CARERRORSTOP = "api.url.carerrorstop";
9 11 }
... ...
src/main/java/com/bsth/entity/CarErrorStop.java 0 → 100644
  1 +package com.bsth.entity;
  2 +
  3 +import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
  4 +import org.joda.time.format.DateTimeFormat;
  5 +import org.joda.time.format.DateTimeFormatter;
  6 +import org.springframework.util.StringUtils;
  7 +
  8 +/**
  9 + * 企业信息化运行监控中心
  10 + * 车辆异常停车(理论上超过5分钟)
  11 + * @author Hill
  12 + */
  13 +@JsonIgnoreProperties(ignoreUnknown = true)
  14 +public class CarErrorStop {
  15 +
  16 + /**
  17 + * ID
  18 + */
  19 + private long id;
  20 +
  21 + /**
  22 + * 日期
  23 + */
  24 + private String rq;
  25 +
  26 + /**
  27 + * 公司编码
  28 + */
  29 + private String company;
  30 +
  31 + /**
  32 + * 分公司名称
  33 + */
  34 + private String branchCompany;
  35 +
  36 + /**
  37 + * 线路名称
  38 + */
  39 + private String line;
  40 +
  41 + /**
  42 + * 线路代码
  43 + */
  44 + private String lineId;
  45 +
  46 + /**
  47 + * 车辆内部编码
  48 + */
  49 + private String nbbm;
  50 +
  51 + private String carCode;
  52 +
  53 + private String driver;
  54 +
  55 + private double lat;
  56 +
  57 + private double lon;
  58 +
  59 + /**
  60 + * 发生地址
  61 + */
  62 + private String address;
  63 +
  64 + /**
  65 + * 异常停车起始时间
  66 + */
  67 + private String startTime;
  68 +
  69 + private long startTimestamp;
  70 +
  71 + /**
  72 + * 异常停车结束时间
  73 + */
  74 + private String endTime;
  75 +
  76 + private long endTimestamp;
  77 +
  78 + /**
  79 + * 上下行
  80 + */
  81 + private int upDown;
  82 +
  83 + /**
  84 + * 备注
  85 + */
  86 + private String remark;
  87 +
  88 + private static DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
  89 +
  90 + public long getId() {
  91 + return id;
  92 + }
  93 +
  94 + public void setId(long id) {
  95 + this.id = id;
  96 + }
  97 +
  98 + public String getRq() {
  99 + return rq;
  100 + }
  101 +
  102 + public void setRq(String rq) {
  103 + this.rq = rq;
  104 + }
  105 +
  106 + public String getCompany() {
  107 + return company;
  108 + }
  109 +
  110 + public void setCompany(String company) {
  111 + this.company = company;
  112 + }
  113 +
  114 + public String getBranchCompany() {
  115 + return branchCompany;
  116 + }
  117 +
  118 + public void setBranchCompany(String branchCompany) {
  119 + this.branchCompany = branchCompany;
  120 + }
  121 +
  122 + public String getLine() {
  123 + return line;
  124 + }
  125 +
  126 + public void setLine(String line) {
  127 + this.line = line;
  128 + }
  129 +
  130 + public String getLineId() {
  131 + return lineId;
  132 + }
  133 +
  134 + public void setLineId(String lineId) {
  135 + this.lineId = lineId;
  136 + }
  137 +
  138 + public String getNbbm() {
  139 + return nbbm;
  140 + }
  141 +
  142 + public void setNbbm(String nbbm) {
  143 + this.nbbm = nbbm;
  144 + }
  145 +
  146 + public String getCarCode() {
  147 + return carCode;
  148 + }
  149 +
  150 + public void setCarCode(String carCode) {
  151 + this.carCode = carCode;
  152 + }
  153 +
  154 + public String getDriver() {
  155 + return driver;
  156 + }
  157 +
  158 + public void setDriver(String driver) {
  159 + this.driver = driver;
  160 + }
  161 +
  162 + public double getLat() {
  163 + return lat;
  164 + }
  165 +
  166 + public void setLat(double lat) {
  167 + this.lat = lat;
  168 + }
  169 +
  170 + public double getLon() {
  171 + return lon;
  172 + }
  173 +
  174 + public void setLon(double lon) {
  175 + this.lon = lon;
  176 + }
  177 +
  178 + public String getAddress() {
  179 + return address;
  180 + }
  181 +
  182 + public void setAddress(String address) {
  183 + this.address = address;
  184 + }
  185 +
  186 + public String getStartTime() {
  187 + return startTime;
  188 + }
  189 +
  190 + public void setStartTime(String startTime) {
  191 + this.startTime = startTime;
  192 + if (StringUtils.hasLength(startTime)) {
  193 + this.startTimestamp = formatter.parseDateTime(startTime).getMillis();
  194 + }
  195 + }
  196 +
  197 + public long getStartTimestamp() {
  198 + return startTimestamp;
  199 + }
  200 +
  201 + public void setStartTimestamp(long startTimestamp) {
  202 + this.startTimestamp = startTimestamp;
  203 + }
  204 +
  205 + public String getEndTime() {
  206 + return endTime;
  207 + }
  208 +
  209 + public void setEndTime(String endTime) {
  210 + this.endTime = endTime;
  211 + if (StringUtils.hasLength(endTime)) {
  212 + this.endTimestamp = formatter.parseDateTime(endTime).getMillis();
  213 + }
  214 + }
  215 +
  216 + public long getEndTimestamp() {
  217 + return endTimestamp;
  218 + }
  219 +
  220 + public void setEndTimestamp(long endTimestamp) {
  221 + this.endTimestamp = endTimestamp;
  222 + }
  223 +
  224 + public int getUpDown() {
  225 + return upDown;
  226 + }
  227 +
  228 + public void setUpDown(int upDown) {
  229 + this.upDown = upDown;
  230 + }
  231 +
  232 + public String getRemark() {
  233 + return remark;
  234 + }
  235 +
  236 + public void setRemark(String remark) {
  237 + this.remark = remark;
  238 + }
  239 +
  240 + @Override
  241 + public boolean equals(Object o) {
  242 + return this.id == ((CarErrorStop) o).id;
  243 + }
  244 +
  245 + @Override
  246 + public int hashCode() {
  247 + return Long.hashCode(id);
  248 + }
  249 +}
... ...
src/main/java/com/bsth/task/TimedTask.java 0 → 100644
  1 +package com.bsth.task;
  2 +
  3 +import com.bsth.common.SystemParamKeys;
  4 +import com.bsth.data.BasicData;
  5 +import com.bsth.entity.CarErrorStop;
  6 +import com.bsth.entity.SystemParam;
  7 +import com.bsth.util.HttpClientUtils;
  8 +import com.bsth.websocket.handler.SendUtils;
  9 +import com.fasterxml.jackson.databind.ObjectMapper;
  10 +import org.joda.time.DateTime;
  11 +import org.slf4j.Logger;
  12 +import org.slf4j.LoggerFactory;
  13 +import org.springframework.beans.factory.annotation.Autowired;
  14 +import org.springframework.scheduling.annotation.Scheduled;
  15 +import org.springframework.stereotype.Component;
  16 +
  17 +import java.util.HashSet;
  18 +import java.util.List;
  19 +import java.util.Set;
  20 +
  21 +@Component
  22 +public class TimedTask {
  23 +
  24 + private final static Logger log = LoggerFactory.getLogger(TimedTask.class);
  25 +
  26 + private ObjectMapper mapper = new ObjectMapper();
  27 +
  28 + @Autowired
  29 + private SendUtils sendUtils;
  30 +
  31 + private Set<CarErrorStop> carErrorStopSet = new HashSet<>();
  32 +
  33 + @Scheduled(cron = "10 0 0 * * *")
  34 + public void clear() {
  35 + carErrorStopSet.clear();
  36 + }
  37 +
  38 + @Scheduled(initialDelay = 10000, fixedDelay = 10000)
  39 + public void carErrorStopTask() {
  40 + SystemParam param = BasicData.getSystemParam().get(SystemParamKeys.API_URL_CARERRORSTOP);
  41 + String url = null;
  42 + if (param != null && param.getValue() != null) {
  43 + url = param.getValue();
  44 + }
  45 + if (url == null) {
  46 + log.error("carErrorStopTask url is null");
  47 + return;
  48 + }
  49 + url = String.format(url, new DateTime().toString("yyyyMMdd"));
  50 + try {
  51 + StringBuilder sb = HttpClientUtils.get(url);
  52 + if (sb != null) {
  53 + List<CarErrorStop> carErrorStopList = mapper.readValue(sb.toString(), mapper.getTypeFactory().constructParametricType(List.class, CarErrorStop.class));
  54 + for (CarErrorStop carErrorStop : carErrorStopList) {
  55 + //if (!carErrorStopSet.contains(carErrorStop)) {
  56 + // carErrorStopSet.add(carErrorStop);
  57 + sendUtils.sendCarErrorStop(carErrorStop);
  58 + //}
  59 + }
  60 + }
  61 + } catch (Exception e) {
  62 + log.error("getAndSendCarErrorStop异常", e);
  63 + }
  64 + }
  65 +}
... ...
src/main/java/com/bsth/websocket/handler/SendUtils.java
1   -package com.bsth.websocket.handler;
2   -
3   -import com.alibaba.fastjson.JSONObject;
4   -import com.bsth.data.BasicData;
5   -import com.bsth.data.LineConfigData;
6   -import com.bsth.data.gpsdata_v2.entity.GpsEntity;
7   -import com.bsth.data.safe_driv.SafeDriv;
8   -import com.bsth.entity.directive.D80;
9   -import com.bsth.entity.realcontrol.ScheduleRealInfo;
10   -import com.bsth.websocket.dto.WsScheduleRealInfo;
11   -import com.fasterxml.jackson.core.JsonProcessingException;
12   -import com.fasterxml.jackson.databind.ObjectMapper;
13   -import org.apache.commons.lang3.StringUtils;
14   -import org.slf4j.Logger;
15   -import org.slf4j.LoggerFactory;
16   -import org.springframework.beans.factory.annotation.Autowired;
17   -import org.springframework.stereotype.Component;
18   -
19   -import java.text.SimpleDateFormat;
20   -import java.util.*;
21   -
22   -@Component
23   -public class SendUtils{
24   -
25   - @Autowired
26   - private RealControlSocketHandler socketHandler;
27   -
28   - @Autowired
29   - LineConfigData lineConfigData;
30   -
31   - private static SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
32   -
33   - private static Logger logger = LoggerFactory.getLogger(SendUtils.class);
34   -
35   - /**
36   - * @throws JsonProcessingException
37   - * TODO(推送发车信息)
38   - */
39   - public void sendFcsj(ScheduleRealInfo sch) {
40   -
41   - Map<String, Object> map = new HashMap<>();
42   - map.put("fn", "faChe");
43   - map.put("t", WsScheduleRealInfo.getInstance(sch));
44   - map.put("dataStr", sdf.format(new Date()));
45   -
46   - ObjectMapper mapper = new ObjectMapper();
47   -
48   - try {
49   - socketHandler.sendMessageToLine(sch.getXlBm(), mapper.writeValueAsString(map));
50   - } catch (Exception e) {
51   - logger.error("", e);
52   - }
53   - }
54   -
55   - /**
56   - *
57   - * @Title: sendFcsjArtificial
58   - * @Description: TODO(要求页面刷新班次)
59   - * @throws
60   - */
61   - public void refreshSch(List<ScheduleRealInfo> list){
62   - if(null == list || list.size() == 0)
63   - return;
64   -
65   - Map<String, Object> map = new HashMap<>();
66   - map.put("fn", "refreshSch");
67   - map.put("ts", WsScheduleRealInfo.getMultiInstance(list));
68   -
69   - ObjectMapper mapper = new ObjectMapper();
70   -
71   - try {
72   - socketHandler.sendMessageToLine(list.get(0).getXlBm(), mapper.writeValueAsString(map));
73   - } catch (Exception e) {
74   - logger.error("", e);
75   - }
76   - }
77   -
78   - /**
79   - * @throws JsonProcessingException
80   - * @throws NumberFormatException @Title: sendFcsj @Description:
81   - * TODO(推送到达终点时间) @param @param schedule 班次 @throws
82   - */
83   - public void sendZdsj(ScheduleRealInfo sch, ScheduleRealInfo nextSch, int finish) {
84   -
85   - Map<String, Object> map = new HashMap<>();
86   - map.put("fn", "zhongDian");
87   - map.put("t", WsScheduleRealInfo.getInstance(sch));
88   - map.put("nt", WsScheduleRealInfo.getInstance(nextSch));
89   - map.put("finish", finish);
90   - map.put("dataStr", sdf.format(new Date()));
91   -
92   - ObjectMapper mapper = new ObjectMapper();
93   -
94   - try {
95   - socketHandler.sendMessageToLine(sch.getXlBm(), mapper.writeValueAsString(map));
96   - } catch (Exception e) {
97   - logger.error("", e);
98   - }
99   - }
100   -
101   - /**
102   - * 推送班次信号状态
103   - * @param state
104   -
105   - public void sendSignalState(SignalState state){
106   - Map<String, Object> map = new HashMap<>();
107   - map.put("fn", "signal_state");
108   - map.put("data", state);
109   -
110   - ObjectMapper mapper = new ObjectMapper();
111   -
112   - try {
113   - socketHandler.sendMessageToLine(state.getLineCode(), mapper.writeValueAsString(map));
114   - } catch (Exception e) {
115   - logger.error("", e);
116   - }
117   - }*/
118   -
119   - /**
120   - *
121   - * @Title: sendDirectiveToPage
122   - * @Description: TODO(调度指令状态推送)
123   - */
124   - public void sendDirectiveToPage(ScheduleRealInfo sch) {
125   -
126   - Map<String, Object> map = new HashMap<>();
127   - map.put("fn", "directive");
128   - map.put("t", WsScheduleRealInfo.getInstance(sch));;
129   -
130   - ObjectMapper mapper = new ObjectMapper();
131   -
132   - try {
133   - socketHandler.sendMessageToLine(sch.getXlBm(), mapper.writeValueAsString(map));
134   - } catch (JsonProcessingException e) {
135   - logger.error("", e);
136   - }
137   - }
138   -
139   - public void send80ToPage(D80 d80) {
140   - d80.getData().setNbbm(BasicData.deviceId2NbbmMap.get(d80.getDeviceId()));
141   - JSONObject json = JSONObject.parseObject(JSONObject.toJSONString(d80));
142   - json.put("fn", "report80");
143   - socketHandler.sendMessageToLine(d80.getData().getLineId().toString(), json.toJSONString());
144   - }
145   -
146   - public void refreshSch(ScheduleRealInfo sch) {
147   - List<ScheduleRealInfo> list = new ArrayList<>();
148   - list.add(sch);
149   - refreshSch(list);
150   - }
151   -
152   - public void deviceOffline(GpsEntity gps){
153   - Map<String, Object> map = new HashMap<>();
154   - map.put("fn", "deviceOffline");
155   - map.put("gps", gps);
156   - ObjectMapper mapper = new ObjectMapper();
157   -
158   - try {
159   - socketHandler.sendMessageToLine(gps.getLineId().toString(), mapper.writeValueAsString(map));
160   - } catch (JsonProcessingException e) {
161   - logger.error("", e);
162   - }
163   - }
164   -
165   - public void sendSafeDriv(SafeDriv sd){
166   - Map<String, Object> map = new HashMap<>();
167   - map.put("fn", "safeDriv");
168   - map.put("t", sd);;
169   - ObjectMapper mapper = new ObjectMapper();
170   -
171   - try {
172   - socketHandler.sendMessageToLine(sd.getXlbm(), mapper.writeValueAsString(map));
173   - } catch (JsonProcessingException e) {
174   - logger.error("", e);
175   - }
176   - }
177   -
178   - /**
179   - * 通知客户端,开始进行误点调整
180   - * @param sch
181   - */
182   - public void sendAutoWdtz(ScheduleRealInfo sch, ScheduleRealInfo cancel){
183   - Map<String, Object> map = new HashMap<>();
184   - map.put("fn", "auto_wdtz");
185   - map.put("id", sch.getId());
186   - if(cancel != null)
187   - map.put("cancelId", cancel.getId());
188   - map.put("lineCode", sch.getXlBm());
189   - map.put("minute", sch.getLateMinute());
190   - ObjectMapper mapper = new ObjectMapper();
191   -
192   - try {
193   - socketHandler.sendMessageToLine(sch.getXlBm() ,mapper.writeValueAsString(map));
194   -
195   - } catch (JsonProcessingException e) {
196   - logger.error("", e);
197   - }
198   - }
199   -
200   - /**
201   - * 对所有线调用户进行广播
202   - * @param t
203   - */
204   - public void sendRadioText(String t, String lineCode){
205   - Map<String, Object> map = new HashMap<>();
206   - map.put("fn", "admin_radio_text");
207   - map.put("t", t);
208   - ObjectMapper mapper = new ObjectMapper();
209   -
210   - try {
211   - if(StringUtils.isNotEmpty(lineCode))
212   - socketHandler.sendMessageToLine(lineCode, mapper.writeValueAsString(map));
213   - else
214   - socketHandler.sendMessage(mapper.writeValueAsString(map));
215   - } catch (JsonProcessingException e) {
216   - logger.error("", e);
217   - }
218   - }
219   -}
  1 +package com.bsth.websocket.handler;
  2 +
  3 +import com.alibaba.fastjson.JSONObject;
  4 +import com.bsth.data.BasicData;
  5 +import com.bsth.data.LineConfigData;
  6 +import com.bsth.data.gpsdata_v2.entity.GpsEntity;
  7 +import com.bsth.data.safe_driv.SafeDriv;
  8 +import com.bsth.entity.directive.D80;
  9 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
  10 +import com.bsth.entity.CarErrorStop;
  11 +import com.bsth.websocket.dto.WsScheduleRealInfo;
  12 +import com.fasterxml.jackson.core.JsonProcessingException;
  13 +import com.fasterxml.jackson.databind.ObjectMapper;
  14 +import org.apache.commons.lang3.StringUtils;
  15 +import org.slf4j.Logger;
  16 +import org.slf4j.LoggerFactory;
  17 +import org.springframework.beans.factory.annotation.Autowired;
  18 +import org.springframework.stereotype.Component;
  19 +
  20 +import java.text.SimpleDateFormat;
  21 +import java.util.*;
  22 +
  23 +@Component
  24 +public class SendUtils{
  25 +
  26 + @Autowired
  27 + private RealControlSocketHandler socketHandler;
  28 +
  29 + @Autowired
  30 + LineConfigData lineConfigData;
  31 +
  32 + private static SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
  33 +
  34 + private static Logger logger = LoggerFactory.getLogger(SendUtils.class);
  35 +
  36 + /**
  37 + * @throws JsonProcessingException
  38 + * TODO(推送发车信息)
  39 + */
  40 + public void sendFcsj(ScheduleRealInfo sch) {
  41 +
  42 + Map<String, Object> map = new HashMap<>();
  43 + map.put("fn", "faChe");
  44 + map.put("t", WsScheduleRealInfo.getInstance(sch));
  45 + map.put("dataStr", sdf.format(new Date()));
  46 +
  47 + ObjectMapper mapper = new ObjectMapper();
  48 +
  49 + try {
  50 + socketHandler.sendMessageToLine(sch.getXlBm(), mapper.writeValueAsString(map));
  51 + } catch (Exception e) {
  52 + logger.error("", e);
  53 + }
  54 + }
  55 +
  56 + /**
  57 + *
  58 + * @Title: sendFcsjArtificial
  59 + * @Description: TODO(要求页面刷新班次)
  60 + * @throws
  61 + */
  62 + public void refreshSch(List<ScheduleRealInfo> list){
  63 + if(null == list || list.size() == 0)
  64 + return;
  65 +
  66 + Map<String, Object> map = new HashMap<>();
  67 + map.put("fn", "refreshSch");
  68 + map.put("ts", WsScheduleRealInfo.getMultiInstance(list));
  69 +
  70 + ObjectMapper mapper = new ObjectMapper();
  71 +
  72 + try {
  73 + socketHandler.sendMessageToLine(list.get(0).getXlBm(), mapper.writeValueAsString(map));
  74 + } catch (Exception e) {
  75 + logger.error("", e);
  76 + }
  77 + }
  78 +
  79 + /**
  80 + * @throws JsonProcessingException
  81 + * @throws NumberFormatException @Title: sendFcsj @Description:
  82 + * TODO(推送到达终点时间) @param @param schedule 班次 @throws
  83 + */
  84 + public void sendZdsj(ScheduleRealInfo sch, ScheduleRealInfo nextSch, int finish) {
  85 +
  86 + Map<String, Object> map = new HashMap<>();
  87 + map.put("fn", "zhongDian");
  88 + map.put("t", WsScheduleRealInfo.getInstance(sch));
  89 + map.put("nt", WsScheduleRealInfo.getInstance(nextSch));
  90 + map.put("finish", finish);
  91 + map.put("dataStr", sdf.format(new Date()));
  92 +
  93 + ObjectMapper mapper = new ObjectMapper();
  94 +
  95 + try {
  96 + socketHandler.sendMessageToLine(sch.getXlBm(), mapper.writeValueAsString(map));
  97 + } catch (Exception e) {
  98 + logger.error("", e);
  99 + }
  100 + }
  101 +
  102 + /**
  103 + * 推送班次信号状态
  104 + * @param state
  105 +
  106 + public void sendSignalState(SignalState state){
  107 + Map<String, Object> map = new HashMap<>();
  108 + map.put("fn", "signal_state");
  109 + map.put("data", state);
  110 +
  111 + ObjectMapper mapper = new ObjectMapper();
  112 +
  113 + try {
  114 + socketHandler.sendMessageToLine(state.getLineCode(), mapper.writeValueAsString(map));
  115 + } catch (Exception e) {
  116 + logger.error("", e);
  117 + }
  118 + }*/
  119 +
  120 + /**
  121 + *
  122 + * @Title: sendDirectiveToPage
  123 + * @Description: TODO(调度指令状态推送)
  124 + */
  125 + public void sendDirectiveToPage(ScheduleRealInfo sch) {
  126 +
  127 + Map<String, Object> map = new HashMap<>();
  128 + map.put("fn", "directive");
  129 + map.put("t", WsScheduleRealInfo.getInstance(sch));;
  130 +
  131 + ObjectMapper mapper = new ObjectMapper();
  132 +
  133 + try {
  134 + socketHandler.sendMessageToLine(sch.getXlBm(), mapper.writeValueAsString(map));
  135 + } catch (JsonProcessingException e) {
  136 + logger.error("", e);
  137 + }
  138 + }
  139 +
  140 + public void send80ToPage(D80 d80) {
  141 + d80.getData().setNbbm(BasicData.deviceId2NbbmMap.get(d80.getDeviceId()));
  142 + JSONObject json = JSONObject.parseObject(JSONObject.toJSONString(d80));
  143 + json.put("fn", "report80");
  144 + socketHandler.sendMessageToLine(d80.getData().getLineId().toString(), json.toJSONString());
  145 + }
  146 +
  147 + public void refreshSch(ScheduleRealInfo sch) {
  148 + List<ScheduleRealInfo> list = new ArrayList<>();
  149 + list.add(sch);
  150 + refreshSch(list);
  151 + }
  152 +
  153 + public void deviceOffline(GpsEntity gps){
  154 + Map<String, Object> map = new HashMap<>();
  155 + map.put("fn", "deviceOffline");
  156 + map.put("gps", gps);
  157 + ObjectMapper mapper = new ObjectMapper();
  158 +
  159 + try {
  160 + socketHandler.sendMessageToLine(gps.getLineId().toString(), mapper.writeValueAsString(map));
  161 + } catch (JsonProcessingException e) {
  162 + logger.error("", e);
  163 + }
  164 + }
  165 +
  166 + public void sendSafeDriv(SafeDriv sd){
  167 + Map<String, Object> map = new HashMap<>();
  168 + map.put("fn", "safeDriv");
  169 + map.put("t", sd);;
  170 + ObjectMapper mapper = new ObjectMapper();
  171 +
  172 + try {
  173 + socketHandler.sendMessageToLine(sd.getXlbm(), mapper.writeValueAsString(map));
  174 + } catch (JsonProcessingException e) {
  175 + logger.error("", e);
  176 + }
  177 + }
  178 +
  179 + /**
  180 + * 通知客户端,开始进行误点调整
  181 + * @param sch
  182 + */
  183 + public void sendAutoWdtz(ScheduleRealInfo sch, ScheduleRealInfo cancel){
  184 + Map<String, Object> map = new HashMap<>();
  185 + map.put("fn", "auto_wdtz");
  186 + map.put("id", sch.getId());
  187 + if(cancel != null)
  188 + map.put("cancelId", cancel.getId());
  189 + map.put("lineCode", sch.getXlBm());
  190 + map.put("minute", sch.getLateMinute());
  191 + ObjectMapper mapper = new ObjectMapper();
  192 +
  193 + try {
  194 + socketHandler.sendMessageToLine(sch.getXlBm() ,mapper.writeValueAsString(map));
  195 +
  196 + } catch (JsonProcessingException e) {
  197 + logger.error("", e);
  198 + }
  199 + }
  200 +
  201 + /**
  202 + * 对所有线调用户进行广播
  203 + * @param t
  204 + */
  205 + public void sendRadioText(String t, String lineCode){
  206 + Map<String, Object> map = new HashMap<>();
  207 + map.put("fn", "admin_radio_text");
  208 + map.put("t", t);
  209 + ObjectMapper mapper = new ObjectMapper();
  210 +
  211 + try {
  212 + if(StringUtils.isNotEmpty(lineCode))
  213 + socketHandler.sendMessageToLine(lineCode, mapper.writeValueAsString(map));
  214 + else
  215 + socketHandler.sendMessage(mapper.writeValueAsString(map));
  216 + } catch (JsonProcessingException e) {
  217 + logger.error("", e);
  218 + }
  219 + }
  220 +
  221 + /**
  222 + * 将车辆异常停车发送至线调页面
  223 + */
  224 + public void sendCarErrorStop(CarErrorStop carErrorStop) {
  225 + Map<String, Object> map = new HashMap<>();
  226 + map.put("fn", "carErrorStop");
  227 + map.put("data", carErrorStop);
  228 + ObjectMapper mapper = new ObjectMapper();
  229 +
  230 + try {
  231 + if (carErrorStop.getLineId() != null) {
  232 + socketHandler.sendMessageToLine(carErrorStop.getLineId(), mapper.writeValueAsString(map));
  233 + }
  234 + } catch (JsonProcessingException e) {
  235 + logger.error("sendCarErrorStop", e);
  236 + }
  237 + }
  238 +}
... ...
src/main/resources/application-prod.properties
... ... @@ -2,13 +2,15 @@ server.port=9088
2 2 management.port= 9001
3 3 management.address= 127.0.0.1
4 4  
  5 +spring.task.scheduling.pool.size= 5
  6 +
5 7 spring.jpa.hibernate.ddl-auto= none
6 8 spring.jpa.hibernate.naming_strategy= org.hibernate.cfg.ImprovedNamingStrategy
7 9 #DATABASE
8 10 spring.jpa.database= MYSQL
9 11 spring.jpa.show-sql= false
10 12 spring.datasource.driver-class-name= com.mysql.jdbc.Driver
11   -spring.datasource.url= jdbc:mysql://192.168.168.171:3306/control?useUnicode=true&characterEncoding=utf-8&useSSL=false
  13 +spring.datasource.url= jdbc:mysql://192.168.168.171/control?useUnicode=true&characterEncoding=utf-8&useSSL=false
12 14 spring.datasource.username= root
13 15 spring.datasource.password= root2jsp
14 16 #DATASOURCE
... ...
src/main/resources/application.properties
1 1 spring.profiles.active= test
2 2  
3   -spring.mvc.view.suffix=.html
4   -server.session.timeout=-1
5   -security.basic.enabled=false
  3 +spring.mvc.view.suffix= .html
  4 +server.session.timeout= -1
  5 +security.basic.enabled= false
6 6  
7 7 # \u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F\u9650\u5236\u914D\u7F6E
8 8 # File size limit
9   -multipart.maxFileSize = -1
  9 +multipart.maxFileSize= -1
10 10 # Total request size for a multipart/form-data
11   -multipart.maxRequestSize = -1
  11 +multipart.maxRequestSize= -1
12 12  
13   -server.compression.enabled=true
14   -server.compression.mime-types=application/json,application/xml,text/html,text/xml,text/plain,text/javascript,text/css,application/javascript
  13 +server.compression.enabled= true
  14 +server.compression.mime-types= application/json,application/xml,text/html,text/xml,text/plain,text/javascript,text/css,application/javascript
15 15  
16 16 # batch insert
17   -hibernate.jdbc.batch_size = 50
18   -debug=true
  17 +hibernate.jdbc.batch_size= 50
19 18 \ No newline at end of file
... ...