wenhongquan 2 лет назад
Родитель
Сommit
2aae745a38

+ 4 - 0
ruoyi-modules/ruoyi-khy/src/main/java/org/dromara/system/service/impl/TblGpsDataServiceImpl.java

@@ -1,10 +1,12 @@
 package org.dromara.system.service.impl;
 
+import cn.hutool.json.JSONUtil;
 import com.baomidou.dynamic.datasource.annotation.DS;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
 import org.dromara.common.core.utils.MapstructUtils;
 import org.dromara.common.core.utils.StringUtils;
 import org.dromara.common.mybatis.core.page.PageQuery;
@@ -29,6 +31,7 @@ import java.util.Map;
  */
 @RequiredArgsConstructor
 @DS("slave")
+@Slf4j
 @Service
 public class TblGpsDataServiceImpl implements ITblGpsDataService {
 
@@ -49,6 +52,7 @@ public class TblGpsDataServiceImpl implements ITblGpsDataService {
     public TableDataInfo<GpsDataVo> queryPageList(GpsDataBo bo, PageQuery pageQuery) {
         LambdaQueryWrapper<GpsData> lqw = buildQueryWrapper(bo);
         Page<GpsDataVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
+//        log.info(JSONUtil.toJsonStr(result.getRecords()));
         return TableDataInfo.build(result);
     }
 

+ 18 - 11
ruoyi-modules/ruoyi-khy/src/main/java/org/dromara/util/CamelDataUtil.java

@@ -118,7 +118,8 @@ public class CamelDataUtil {
                                 if(scheduleVo!=null){
                                     try{
                                         JSONArray lines = JSONUtil.parseObj(scheduleVo.getPathInfo()).getJSONArray("pathLine");
-                                        List<JSONObject> lines1 = lines.toList(JSONObject.class);
+                                        List<JSONObject> lines1 = new ArrayList<>();
+                                        RedisUtils.setCacheObject(StringUtils.format("car_{}_{}_current_station",carInfoVo1.getCarNum(),DateFormatUtils.format( scheduleVo.getScheduleDate(),DateUtils.YYYYMMDDHHMMSS)),"");
                                         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");
@@ -144,8 +145,10 @@ public class CamelDataUtil {
                                             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));
-                                            //开始播报
+                                            if(!stationName.contains(jsonObject.getStr("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"));
@@ -153,16 +156,19 @@ public class CamelDataUtil {
                                             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);
+                                                String message = StringUtils.format("{}即将到达{},即将到达,请准备接货。", carInfoVo1.getCarNum(),stations.get(0).getDictLabel());
+                                                if(StringUtils.isNotEmpty(stations.get(0).getRemark())){
+                                                    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{
@@ -173,6 +179,7 @@ public class CamelDataUtil {
                                     }catch (Exception e){
                                         log.error("---------------------");
                                         log.error(e.getMessage());
+
                                         log.error("---------------------");
                                     }
                                 }

+ 1 - 1
ruoyi-modules/ruoyi-khy/src/main/java/org/dromara/util/DistanceCalculator.java

@@ -17,7 +17,7 @@ public class DistanceCalculator {
 
     public static double calculateDistance(String location1, String location2) {
         String[] loat1 = location1.split(",");
-        String[] loat2 = location1.split(",");
+        String[] loat2 = location2.split(",");
         return calculateDistance(Double.parseDouble(loat1[1]), Double.parseDouble(loat1[0]), Double.parseDouble(loat2[1]), Double.parseDouble(loat2[0]));
     }
 

+ 1 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysDictDataServiceImpl.java

@@ -57,6 +57,7 @@ public class SysDictDataServiceImpl implements ISysDictDataService {
         lqw.like(StringUtils.isNotBlank(bo.getDictLabel()), SysDictData::getDictLabel, bo.getDictLabel());
         lqw.eq(StringUtils.isNotBlank(bo.getDictType()), SysDictData::getDictType, bo.getDictType());
         lqw.orderByAsc(SysDictData::getDictSort);
+        lqw.orderByAsc(SysDictData::getCreateTime);
         return lqw;
     }