|
|
@@ -31,10 +31,7 @@ import org.springframework.stereotype.Component;
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
import java.nio.charset.Charset;
|
|
|
import java.time.Duration;
|
|
|
-import java.util.Calendar;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
|
|
|
@Slf4j
|
|
|
@Component("camelDataUtil")
|
|
|
@@ -121,42 +118,55 @@ public class CamelDataUtil {
|
|
|
if(scheduleVo!=null){
|
|
|
try{
|
|
|
JSONArray lines = JSONUtil.parseObj(scheduleVo.getPathInfo()).getJSONArray("pathLine");
|
|
|
+ List<JSONObject> lines1 = lines.toList(JSONObject.class);
|
|
|
for (JSONObject jsonObject : lines.toList(JSONObject.class)) {
|
|
|
double distance = DistanceCalculator.calculateDistance(jsonObject.getStr("location"),StringUtils.format("{},{}", gpsData.getLng(),gpsData.getLat()));
|
|
|
String configdistance = SpringUtils.getBean(ISysConfigService.class).selectConfigByKey("sys.car.distance");
|
|
|
if(Double.parseDouble(configdistance)>distance){
|
|
|
- //靠近站点
|
|
|
+ String stations = RedisUtils.getCacheObject(StringUtils.format("car_{}_{}_current_station",carInfoVo1.getCarNum(),DateFormatUtils.format( scheduleVo.getScheduleDate(),DateUtils.YYYYMMDDHHMMSS)));
|
|
|
+ RedisUtils.setCacheObject(StringUtils.format("car_{}_{}_current_station",carInfoVo1.getCarNum(),DateFormatUtils.format( scheduleVo.getScheduleDate(),DateUtils.YYYYMMDDHHMMSS)),stations+","+jsonObject.getStr("stationName"));
|
|
|
+ //靠近站点 还得计算当前是否跨站点
|
|
|
String stationName = RedisUtils.getCacheObject(StringUtils.format("car_{}_{}_tip",carInfoVo1.getCarNum(),DateFormatUtils.format( scheduleVo.getScheduleDate(),DateUtils.YYYYMMDDHHMMSS) ));
|
|
|
if(stationName!=null && stationName.contains(jsonObject.getStr("stationName"))){
|
|
|
//提报过的不再提报
|
|
|
-
|
|
|
}else{
|
|
|
- stationName=stationName==null?"":stationName;
|
|
|
- RedisUtils.setCacheObject(StringUtils.format("car_{}_{}_tip",carInfoVo1.getCarNum(), DateFormatUtils.format( scheduleVo.getScheduleDate(),DateUtils.YYYYMMDDHHMMSS) ), stationName+","+jsonObject.getStr("stationName"),Duration.ofSeconds(3600*24));
|
|
|
- //开始播报
|
|
|
- //获取站点设备信息
|
|
|
- SysDictDataBo sysDictData = new SysDictDataBo();
|
|
|
- sysDictData.setDictLabel(jsonObject.getStr("stationName"));
|
|
|
- sysDictData.setDictType("tbl_sites");
|
|
|
- List<SysDictDataVo> stations = sysDictDataService.selectDictDataList(sysDictData);
|
|
|
- if(stations.size()>0){
|
|
|
- //满足条件播报(led or 广播)
|
|
|
- String message = StringUtils.format("{}即将到达,请准备接车,请等待。。。", carInfoVo1.getCarNum());
|
|
|
- List<JSONObject> devicedatas = JSONUtil.parseArray( stations.get(0).getRemark()).toList(JSONObject.class);
|
|
|
- for (JSONObject i :devicedatas) {
|
|
|
- if(i.getStr("type").equals("led")){
|
|
|
- MessageUtils.sendLed(i.getStr("code"), message);
|
|
|
- }
|
|
|
- if(i.getStr("type").equals("tts")){
|
|
|
- MessageUtils.sendTTs(i.getStr("code"), message);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ lines1.add(jsonObject);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ if(lines1.size()>0){
|
|
|
+ //先判断是否跨站点
|
|
|
+ if(lines1.size()>1){
|
|
|
+ lines1.sort(Comparator.comparingInt((JSONObject o) -> o.getInt("order")));
|
|
|
+ }
|
|
|
|
|
|
+ JSONObject jsonObject = lines1.get(0);
|
|
|
+ String stationName = RedisUtils.getCacheObject(StringUtils.format("car_{}_{}_tip",carInfoVo1.getCarNum(),DateFormatUtils.format( scheduleVo.getScheduleDate(),DateUtils.YYYYMMDDHHMMSS) ));
|
|
|
+ stationName=stationName==null?"":stationName;
|
|
|
+ RedisUtils.setCacheObject(StringUtils.format("car_{}_{}_tip",carInfoVo1.getCarNum(), DateFormatUtils.format( scheduleVo.getScheduleDate(),DateUtils.YYYYMMDDHHMMSS) ), stationName+","+jsonObject.getStr("stationName"),Duration.ofSeconds(3600*24));
|
|
|
+ //开始播报
|
|
|
+ //获取站点设备信息
|
|
|
+ SysDictDataBo sysDictData = new SysDictDataBo();
|
|
|
+ sysDictData.setDictLabel(jsonObject.getStr("stationName"));
|
|
|
+ sysDictData.setDictType("tbl_sites");
|
|
|
+ List<SysDictDataVo> stations = sysDictDataService.selectDictDataList(sysDictData);
|
|
|
+ if(stations.size()>0){
|
|
|
+ //满足条件播报(led or 广播)
|
|
|
+ String message = StringUtils.format("{}即将到达,请准备接车,请等待。。。", carInfoVo1.getCarNum());
|
|
|
+ List<JSONObject> devicedatas = JSONUtil.parseArray( stations.get(0).getRemark()).toList(JSONObject.class);
|
|
|
+ for (JSONObject i :devicedatas) {
|
|
|
+ if(i.getStr("type").equals("led")){
|
|
|
+ MessageUtils.sendLed(i.getStr("code"), message);
|
|
|
+ }
|
|
|
+ if(i.getStr("type").equals("tts")){
|
|
|
+ MessageUtils.sendTTs(i.getStr("code"), message);
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
+
|
|
|
+ }else{
|
|
|
+ RedisUtils.setCacheObject(StringUtils.format("car_{}_{}_current_station",carInfoVo1.getCarNum(),DateFormatUtils.format( scheduleVo.getScheduleDate(),DateUtils.YYYYMMDDHHMMSS)),"");
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -191,4 +201,13 @@ public class CamelDataUtil {
|
|
|
|
|
|
log.info("body:{}",body);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+// public static void main(String[] args) {
|
|
|
+// String ss = "{\"pathLine\": [{\"order\": 1, \"location\": \"119.807462,26.958413\", \"planInTime\": \"00:15:00\", \"planOutTime\": \"01:15:00\", \"stationName\": \"松罗乡\"}, {\"order\": 2, \"location\": \"119.723653,26.841206\", \"planInTime\": \"00:30:00\", \"planOutTime\": \"01:15:00\", \"stationName\": \"福安客运站\"}, {\"order\": 3, \"location\": \"119.852881,26.817088\", \"planInTime\": \"01:15:00\", \"planOutTime\": \"04:15:00\", \"stationName\": \"姚澳村\"}], \"driverInfo\": 2, \"attendantInfo\": \"1763485590079639554\"}";
|
|
|
+// JSONArray lines = JSONUtil.parseObj(ss).getJSONArray("pathLine");
|
|
|
+// List<JSONObject> lines1 = lines.toList(JSONObject.class);
|
|
|
+// lines1.sort(Comparator.comparingInt((JSONObject o) -> o.getInt("order")));
|
|
|
+// System.out.println(lines1.get(0).toStringPretty());
|
|
|
+// }
|
|
|
}
|