Commit a917eba4f47e4995e824391d5495ff172eefed16
1 parent
1888aaab
update...
Showing
2 changed files
with
25 additions
and
4 deletions
src/main/java/com/bsth/controller/realcontrol/AdminUtilsController.java
| @@ -7,7 +7,7 @@ import com.bsth.data.msg_queue.DirectivePushQueue; | @@ -7,7 +7,7 @@ import com.bsth.data.msg_queue.DirectivePushQueue; | ||
| 7 | import com.bsth.data.msg_queue.WebSocketPushQueue; | 7 | import com.bsth.data.msg_queue.WebSocketPushQueue; |
| 8 | import com.bsth.data.schedule.DayOfSchedule; | 8 | import com.bsth.data.schedule.DayOfSchedule; |
| 9 | import com.bsth.entity.realcontrol.ScheduleRealInfo; | 9 | import com.bsth.entity.realcontrol.ScheduleRealInfo; |
| 10 | -import com.bsth.websocket.handler.RealControlSocketHandler; | 10 | +import com.bsth.websocket.handler.SendUtils; |
| 11 | import org.slf4j.Logger; | 11 | import org.slf4j.Logger; |
| 12 | import org.slf4j.LoggerFactory; | 12 | import org.slf4j.LoggerFactory; |
| 13 | import org.springframework.beans.factory.annotation.Autowired; | 13 | import org.springframework.beans.factory.annotation.Autowired; |
| @@ -39,7 +39,7 @@ public class AdminUtilsController { | @@ -39,7 +39,7 @@ public class AdminUtilsController { | ||
| 39 | DayOfDirectives dayOfDirectives; | 39 | DayOfDirectives dayOfDirectives; |
| 40 | 40 | ||
| 41 | @Autowired | 41 | @Autowired |
| 42 | - RealControlSocketHandler realControlSocketHandler; | 42 | + SendUtils sendUtils; |
| 43 | 43 | ||
| 44 | /** | 44 | /** |
| 45 | * 出现重复班次的车辆 | 45 | * 出现重复班次的车辆 |
| @@ -140,8 +140,8 @@ public class AdminUtilsController { | @@ -140,8 +140,8 @@ public class AdminUtilsController { | ||
| 140 | } | 140 | } |
| 141 | 141 | ||
| 142 | @RequestMapping(value = "/websocketRadioText") | 142 | @RequestMapping(value = "/websocketRadioText") |
| 143 | - public int radioText(String t){ | ||
| 144 | - realControlSocketHandler.sendMessage(t); | 143 | + public int radioText(String t, String lineCode){ |
| 144 | + sendUtils.sendRadioText(t, lineCode); | ||
| 145 | return 0; | 145 | return 0; |
| 146 | } | 146 | } |
| 147 | } | 147 | } |
src/main/java/com/bsth/websocket/handler/SendUtils.java
| @@ -10,6 +10,7 @@ import com.bsth.entity.realcontrol.ScheduleRealInfo; | @@ -10,6 +10,7 @@ import com.bsth.entity.realcontrol.ScheduleRealInfo; | ||
| 10 | import com.bsth.websocket.dto.WsScheduleRealInfo; | 10 | import com.bsth.websocket.dto.WsScheduleRealInfo; |
| 11 | import com.fasterxml.jackson.core.JsonProcessingException; | 11 | import com.fasterxml.jackson.core.JsonProcessingException; |
| 12 | import com.fasterxml.jackson.databind.ObjectMapper; | 12 | import com.fasterxml.jackson.databind.ObjectMapper; |
| 13 | +import org.apache.commons.lang3.StringUtils; | ||
| 13 | import org.slf4j.Logger; | 14 | import org.slf4j.Logger; |
| 14 | import org.slf4j.LoggerFactory; | 15 | import org.slf4j.LoggerFactory; |
| 15 | import org.springframework.beans.factory.annotation.Autowired; | 16 | import org.springframework.beans.factory.annotation.Autowired; |
| @@ -195,4 +196,24 @@ public class SendUtils{ | @@ -195,4 +196,24 @@ public class SendUtils{ | ||
| 195 | logger.error("", e); | 196 | logger.error("", e); |
| 196 | } | 197 | } |
| 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 | + } | ||
| 198 | } | 219 | } |