|
|
@@ -238,6 +238,81 @@ public class CamelDataUtil {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ else{
|
|
|
+ //无路线无排班车辆
|
|
|
+
|
|
|
+ String configdistance = SpringUtils.getBean(ISysConfigService.class).selectConfigByKey("sys.car5.distance");
|
|
|
+ String configtime = SpringUtils.getBean(ISysConfigService.class).selectConfigByKey("sys.car5.time");
|
|
|
+ if(StrUtil.isEmptyIfStr(configdistance)) configdistance="500";
|
|
|
+ if(StrUtil.isEmptyIfStr(configtime)) configtime="180000";
|
|
|
+ //查询所有站点经纬
|
|
|
+ SysDictDataBo bo =new SysDictDataBo();
|
|
|
+ bo.setDictType("tbl_sites");
|
|
|
+ List<SysDictDataVo> allstations = sysDictDataService.selectDictDataList(bo);
|
|
|
+ //循环计算站点与车的距离
|
|
|
+ for (SysDictDataVo station : allstations){
|
|
|
+ if(station.getDictValue()!=null && StrUtil.isNotEmpty(station.getDictValue()) && station.getDictValue().contains(",")){
|
|
|
+ try{
|
|
|
+ if(DistanceCalculator.calculateDistance(station.getDictValue(),StringUtils.format("{},{}", gpsData.getLng(),gpsData.getLat()))<Integer.parseInt(configdistance)){
|
|
|
+ //在范围内
|
|
|
+ //查看是否在单位时间内播报过
|
|
|
+ Long time = RedisUtils.getCacheObject(StringUtils.format("car_{}_{}_station",carInfoVo1.getCarNum(),station.getDictCode()));
|
|
|
+ boolean canbobao = false;
|
|
|
+ if(time==null){
|
|
|
+ //未报过
|
|
|
+ canbobao = true;
|
|
|
+ }else{
|
|
|
+ if(System.currentTimeMillis()-time<Integer.parseInt(configtime)){
|
|
|
+ //在单位时间内播报过
|
|
|
+ continue;
|
|
|
+ }else{
|
|
|
+ //在单位时间内未播报过
|
|
|
+ canbobao = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(canbobao){
|
|
|
+ Long lastStationCode = RedisUtils.getCacheObject(StringUtils.format("car_{}_last_bb_station",carInfoVo1.getCarNum()));
|
|
|
+ if(lastStationCode!=null && lastStationCode.equals(station.getDictCode())){
|
|
|
+ canbobao = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(canbobao){
|
|
|
+
|
|
|
+ //设置播报站播报时间
|
|
|
+ RedisUtils.setCacheObject(StringUtils.format("car_{}_{}_station",carInfoVo1.getCarNum(),station.getDictCode()),DateUtil.current());
|
|
|
+ //设置播报站
|
|
|
+ RedisUtils.setCacheObject(StringUtils.format("car_{}_last_bb_station",carInfoVo1.getCarNum()),station.getDictCode());
|
|
|
+
|
|
|
+ //满足条件播报(led or 广播)
|
|
|
+ String message = StringUtils.format("{}即将到达{},即将到达,请准备接货。", carInfoVo1.getCarNum(),station.getDictLabel());
|
|
|
+ if(StringUtils.isNotEmpty(station.getRemark())){
|
|
|
+ List<JSONObject> devicedatas = JSONUtil.parseArray( station.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{
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error("--------5座车计算经纬错误-------------");
|
|
|
+ log.error(e.getMessage());
|
|
|
+ log.error("-------5座车计算经纬错误--------------");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|