|
|
@@ -1,6 +1,7 @@
|
|
|
package org.dromara.util;
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
+import cn.hutool.core.thread.ThreadUtil;
|
|
|
import cn.hutool.core.util.CharsetUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.json.JSON;
|
|
|
@@ -109,7 +110,7 @@ public class CamelDataUtil {
|
|
|
RedisUtils.setCacheObject(StringUtils.format("gps_{}", gpsData.getDevicecode()), gpsData);
|
|
|
|
|
|
|
|
|
- threadPoolExecutor.execute(new Runnable() {
|
|
|
+ ThreadUtil.execAsync(new Runnable() {
|
|
|
@Override
|
|
|
public void run() {
|
|
|
|
|
|
@@ -240,6 +241,7 @@ public class CamelDataUtil {
|
|
|
CamelDataUtil.setPlayList(carInfoVo1.getCarNum(),o);
|
|
|
for (JSONObject i :devicedatas) {
|
|
|
if(i.getStr("type").equals("led")){
|
|
|
+ RedisUtils.setCacheMapValue("station_led",stations.get(0).getDictLabel(), DateUtil.current());
|
|
|
MessageUtils.sendLed(i.getStr("code"), message);
|
|
|
}
|
|
|
if(i.getStr("type").equals("tts")){
|
|
|
@@ -264,83 +266,86 @@ public class CamelDataUtil {
|
|
|
}
|
|
|
}else{
|
|
|
//无路线无排班车辆
|
|
|
-
|
|
|
- String configdistance = SpringUtils.getBean(ISysConfigService.class).selectConfigByKey("sys.car5.distance");
|
|
|
- String configtime = SpringUtils.getBean(ISysConfigService.class).selectConfigByKey("sys.car5.time");
|
|
|
- String text = SpringUtils.getBean(ISysConfigService.class).selectConfigByKey("sys.car5.text");
|
|
|
- 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{
|
|
|
- //在单位时间内未播报过
|
|
|
+ if(carInfoVo1.getCarType().equals("1")){
|
|
|
+ //五座车报站
|
|
|
+ String configdistance = SpringUtils.getBean(ISysConfigService.class).selectConfigByKey("sys.car5.distance");
|
|
|
+ String configtime = SpringUtils.getBean(ISysConfigService.class).selectConfigByKey("sys.car5.time");
|
|
|
+ String text = SpringUtils.getBean(ISysConfigService.class).selectConfigByKey("sys.car5.text");
|
|
|
+ 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){
|
|
|
- String lastStationCode = RedisUtils.getCacheObject(StringUtils.format("car_{}_last_bb_station",carInfoVo1.getCarNum()));
|
|
|
- if(lastStationCode!=null && lastStationCode.equals(station.getDictCode().toString())){
|
|
|
- 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().toString());
|
|
|
-
|
|
|
- //满足条件播报(led or 广播)
|
|
|
- String message = StringUtils.format(text, carInfoVo1.getCarNum(),station.getDictLabel());
|
|
|
- if(StringUtils.isNotEmpty(station.getRemark())){
|
|
|
- List<JSONObject> devicedatas = JSONUtil.parseArray( station.getRemark()).toList(JSONObject.class);
|
|
|
- Map<String,String> o = new HashMap<>();
|
|
|
- o.put("station",station.getDictLabel());
|
|
|
- o.put("time",DateUtil.now());
|
|
|
- o.put("carNum",carInfoVo1.getCarNum());
|
|
|
- o.put("type",carInfoVo1.getCarType());
|
|
|
- o.put("msg",message);
|
|
|
- CamelDataUtil.setPlayList(carInfoVo1.getCarNum(),o);
|
|
|
- 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);
|
|
|
+ if(canbobao){
|
|
|
+ String lastStationCode = RedisUtils.getCacheObject(StringUtils.format("car_{}_last_bb_station",carInfoVo1.getCarNum()));
|
|
|
+ if(lastStationCode!=null && lastStationCode.equals(station.getDictCode().toString())){
|
|
|
+ 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().toString());
|
|
|
+
|
|
|
+ //满足条件播报(led or 广播)
|
|
|
+ String message = StringUtils.format(text, carInfoVo1.getCarNum(),station.getDictLabel());
|
|
|
+ if(StringUtils.isNotEmpty(station.getRemark())){
|
|
|
+ List<JSONObject> devicedatas = JSONUtil.parseArray( station.getRemark()).toList(JSONObject.class);
|
|
|
+ Map<String,String> o = new HashMap<>();
|
|
|
+ o.put("station",station.getDictLabel());
|
|
|
+ o.put("time",DateUtil.now());
|
|
|
+ o.put("carNum",carInfoVo1.getCarNum());
|
|
|
+ o.put("type",carInfoVo1.getCarType());
|
|
|
+ o.put("msg",message);
|
|
|
+ CamelDataUtil.setPlayList(carInfoVo1.getCarNum(),o);
|
|
|
+ for (JSONObject i :devicedatas) {
|
|
|
+ if(i.getStr("type").equals("led")){
|
|
|
+ RedisUtils.setCacheMapValue("station_led",station.getDictLabel(), DateUtil.current());
|
|
|
+ MessageUtils.sendLed(i.getStr("code"), message);
|
|
|
+ }
|
|
|
+ if(i.getStr("type").equals("tts")){
|
|
|
+ MessageUtils.sendTTs(i.getStr("code"), message);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ }else{
|
|
|
+ continue;
|
|
|
}
|
|
|
|
|
|
- }else{
|
|
|
- continue;
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error("--------5座车计算经纬错误-------------");
|
|
|
+ log.error(e.getMessage());
|
|
|
+ log.error("-------5座车计算经纬错误--------------");
|
|
|
}
|
|
|
-
|
|
|
- }catch (Exception e){
|
|
|
- log.error("--------5座车计算经纬错误-------------");
|
|
|
- log.error(e.getMessage());
|
|
|
- log.error("-------5座车计算经纬错误--------------");
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|
|
|
@@ -423,8 +428,11 @@ public class CamelDataUtil {
|
|
|
countData.setTslong(iCreatedTime*1000);
|
|
|
countDataService.insertData(countData);
|
|
|
}else{
|
|
|
- log.error("{}:时间错误",iCreatedTime);
|
|
|
-
|
|
|
+ log.error("{}--{}:时间错误",sn,iCreatedTime);
|
|
|
+ //断开
|
|
|
+// NettyChannelHandlerContext ctx = ChannelMapCache.get(((ChannelHandlerContext)exchange.getIn().getHeader("CamelNettyChannelHandlerContext")).channel().toString());
|
|
|
+// ctx.getChannelHandlerContext().close();
|
|
|
+// return;
|
|
|
}
|
|
|
//存储数据
|
|
|
// log.info("{},{},{},{},{}",sn,type,in,out,iCreatedTime);
|