|
|
@@ -1,28 +1,37 @@
|
|
|
package org.dromara.util;
|
|
|
|
|
|
import cn.hutool.json.JSON;
|
|
|
+import cn.hutool.json.JSONArray;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.camel.CamelContext;
|
|
|
import org.apache.camel.Exchange;
|
|
|
import org.apache.camel.ProducerTemplate;
|
|
|
+import org.apache.commons.lang3.time.DateFormatUtils;
|
|
|
import org.dromara.common.core.constant.Constants;
|
|
|
+import org.dromara.common.core.utils.DateUtils;
|
|
|
+import org.dromara.common.core.utils.SpringUtils;
|
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
|
import org.dromara.common.redis.utils.RedisUtils;
|
|
|
import org.dromara.sms4j.api.universal.RedisUtil;
|
|
|
import org.dromara.system.domain.GpsData;
|
|
|
+import org.dromara.system.domain.SysDictData;
|
|
|
import org.dromara.system.domain.TblCarInfo;
|
|
|
+import org.dromara.system.domain.bo.SysDictDataBo;
|
|
|
import org.dromara.system.domain.bo.TblCarInfoBo;
|
|
|
+import org.dromara.system.domain.bo.TblCarScheduleBo;
|
|
|
+import org.dromara.system.domain.vo.SysDictDataVo;
|
|
|
import org.dromara.system.domain.vo.TblCarInfoVo;
|
|
|
-import org.dromara.system.service.ISysDictDataService;
|
|
|
-import org.dromara.system.service.ITblCarInfoService;
|
|
|
-import org.dromara.system.service.ITblCarPathService;
|
|
|
-import org.dromara.system.service.ITblGpsDataService;
|
|
|
+import org.dromara.system.domain.vo.TblCarScheduleVo;
|
|
|
+import org.dromara.system.service.*;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import cn.hutool.json.JSONObject;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
import java.time.Duration;
|
|
|
+import java.util.Calendar;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
@@ -40,7 +49,7 @@ public class CamelDataUtil {
|
|
|
ITblCarInfoService tblCarInfoService;
|
|
|
|
|
|
@Autowired
|
|
|
- ITblCarPathService tablCarPathService;
|
|
|
+ ITblCarScheduleService tblCarScheduleService;
|
|
|
|
|
|
@Autowired
|
|
|
ISysDictDataService sysDictDataService;
|
|
|
@@ -93,14 +102,81 @@ public class CamelDataUtil {
|
|
|
carInfoBo1.setCarNum(carInfoVo.getCarNum());
|
|
|
List<TblCarInfoVo> carInfoVos1 = tblCarInfoService.queryList(carInfoBo1);
|
|
|
if(carInfoVos1.size()>0){
|
|
|
+ // 查询车辆信息
|
|
|
TblCarInfoVo carInfoVo1 = carInfoVos1.get(0);
|
|
|
+ TblCarScheduleBo tblCarScheduleBo = new TblCarScheduleBo();
|
|
|
+ tblCarScheduleBo.setCarNum(carInfoVo1.getCarNum());
|
|
|
+ Map<String, Object> map = Map.of("scheduleDate", DateUtils.parseDate(DateUtils.getDate()+" 00:00:00") );
|
|
|
+ tblCarScheduleBo.setParams(map);
|
|
|
+ List<TblCarScheduleVo> list = tblCarScheduleService.queryList(tblCarScheduleBo);
|
|
|
+ if(list.size()>0){
|
|
|
+ long t0 = 10;
|
|
|
+ TblCarScheduleVo scheduleVo = null;
|
|
|
+ for (TblCarScheduleVo vo : list) {
|
|
|
+ if(vo.getScheduleDate().getTime()-DateUtils.getNowDate().getTime()<0){
|
|
|
+ if(t0>0){
|
|
|
+ t0 = vo.getScheduleDate().getTime()-DateUtils.getNowDate().getTime();
|
|
|
+ scheduleVo = vo;
|
|
|
+ }
|
|
|
+ if(t0<vo.getScheduleDate().getTime()-DateUtils.getNowDate().getTime()){
|
|
|
+ t0 = vo.getScheduleDate().getTime()-DateUtils.getNowDate().getTime();
|
|
|
+ scheduleVo = vo;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 查询路线信息
|
|
|
+ if(scheduleVo!=null){
|
|
|
+ try{
|
|
|
+ JSONArray lines = JSONUtil.parseObj(scheduleVo.getPathInfo()).getJSONArray("pathLine");
|
|
|
+ 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 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error("---------------------");
|
|
|
+ log.error(e.getMessage());
|
|
|
+ log.error("---------------------");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
- // 查询车辆信息 查询路线信息 查询下个站点信息(包括站点设备) 计算经纬距离 满足条件播报(led or 广播)
|
|
|
- System.out.println("---------");
|
|
|
}
|
|
|
});
|
|
|
}
|