wenhongquan 2 ani în urmă
părinte
comite
4b779f5346

+ 4 - 1
ruoyi-admin/src/main/resources/application.yml

@@ -6,6 +6,7 @@ ruoyi:
   version: ${revision}
   # 版权年份
   copyrightYear: 2024
+  deviceenable: false
 
 captcha:
   enable: false
@@ -22,7 +23,7 @@ captcha:
 # 开发环境配置
 server:
   # 服务器的HTTP端口,默认为8080
-  port: 8089
+  port: 8080
   servlet:
     # 应用的访问路径
     context-path: /
@@ -266,3 +267,5 @@ websocket:
 camel:
   springboot:
     name: SampleCamel
+
+

+ 4 - 0
ruoyi-modules/ruoyi-khy/pom.xml

@@ -133,6 +133,10 @@
             <artifactId>camel-xml-jaxb-dsl-starter</artifactId>
             <version>${camel.version}</version>
         </dependency>
+        <dependency>
+            <groupId>org.dromara</groupId>
+            <artifactId>ruoyi-system</artifactId>
+        </dependency>
 
 
     </dependencies>

+ 1 - 5
ruoyi-modules/ruoyi-khy/src/main/java/org/dromara/system/domain/TblCarPath.java

@@ -22,7 +22,7 @@ public class TblCarPath extends BaseEntity {
     private static final long serialVersionUID = 1L;
 
     /**
-     * 
+     *
      */
     @TableId(value = "id")
     private Long id;
@@ -37,10 +37,6 @@ public class TblCarPath extends BaseEntity {
      */
     private String stationList;
 
-    /**
-     * 车辆信息
-     */
-    private Long carId;
 
     /**
      * 司机

+ 1 - 8
ruoyi-modules/ruoyi-khy/src/main/java/org/dromara/system/domain/TblCarSchedule.java

@@ -39,15 +39,8 @@ public class TblCarSchedule extends BaseEntity {
      */
     private Date scheduleDate;
 
-    /**
-     * 创建时间
-     */
-    private Date cTime;
 
-    /**
-     * 跟新时间
-     */
-    private Date uTime;
+    private String carNum;
 
 
 }

+ 0 - 4
ruoyi-modules/ruoyi-khy/src/main/java/org/dromara/system/domain/bo/TblCarPathBo.java

@@ -35,10 +35,6 @@ public class TblCarPathBo extends BaseEntity {
      */
     private String stationList;
 
-    /**
-     * 车辆信息
-     */
-    private Long carId;
 
     /**
      * 司机

+ 2 - 7
ruoyi-modules/ruoyi-khy/src/main/java/org/dromara/system/domain/bo/TblCarScheduleBo.java

@@ -38,14 +38,9 @@ public class TblCarScheduleBo extends BaseEntity {
     private Date scheduleDate;
 
     /**
-     * 创建时间
+     * 车辆
      */
-    private Date cTime;
-
-    /**
-     * 跟新时间
-     */
-    private Date uTime;
+    private String carNum;
 
 
 }

+ 1 - 6
ruoyi-modules/ruoyi-khy/src/main/java/org/dromara/system/domain/vo/TblCarPathVo.java

@@ -29,7 +29,7 @@ public class TblCarPathVo implements Serializable {
     private static final long serialVersionUID = 1L;
 
     /**
-     * 
+     *
      */
     @ExcelProperty(value = "")
     private Long id;
@@ -47,11 +47,6 @@ public class TblCarPathVo implements Serializable {
     @ExcelDictFormat(readConverterExp = "包=括场站编号及路过场站的时间")
     private String stationList;
 
-    /**
-     * 车辆信息
-     */
-    @ExcelProperty(value = "车辆信息")
-    private Long carId;
 
     /**
      * 司机

+ 2 - 12
ruoyi-modules/ruoyi-khy/src/main/java/org/dromara/system/domain/vo/TblCarScheduleVo.java

@@ -48,17 +48,7 @@ public class TblCarScheduleVo implements Serializable {
     @ExcelProperty(value = "日期")
     private Date scheduleDate;
 
-    /**
-     * 创建时间
-     */
-    @ExcelProperty(value = "创建时间")
-    private Date cTime;
-
-    /**
-     * 跟新时间
-     */
-    @ExcelProperty(value = "跟新时间")
-    private Date uTime;
-
+    @ExcelProperty(value = "车牌")
+    private String carNum;
 
 }

+ 2 - 1
ruoyi-modules/ruoyi-khy/src/main/java/org/dromara/system/service/impl/TblCarInfoServiceImpl.java

@@ -76,7 +76,8 @@ public class TblCarInfoServiceImpl implements ITblCarInfoService {
         LambdaQueryWrapper<TblCarInfo> lqw = Wrappers.lambdaQuery();
         lqw.eq(StringUtils.isNotBlank(bo.getCarNum()), TblCarInfo::getCarNum, bo.getCarNum());
         lqw.eq(StringUtils.isNotBlank(bo.getCarType()), TblCarInfo::getCarType, bo.getCarType());
-        lqw.eq(StringUtils.isNotBlank(bo.getDeviceInfos()), TblCarInfo::getDeviceInfos, bo.getDeviceInfos());
+        lqw.like(StringUtils.isNotBlank(bo.getDeviceInfos()), TblCarInfo::getDeviceInfos, bo.getDeviceInfos());
+//        lqw.eq(StringUtils.isNotBlank(bo.getDeviceInfos()), TblCarInfo::getDeviceInfos, bo.getDeviceInfos());
         lqw.eq(StringUtils.isNotBlank(bo.getRepairInfo()), TblCarInfo::getRepairInfo, bo.getRepairInfo());
         lqw.eq(StringUtils.isNotBlank(bo.getMaintenanceInfo()), TblCarInfo::getMaintenanceInfo, bo.getMaintenanceInfo());
         lqw.eq(StringUtils.isNotBlank(bo.getInsuranceInfo()), TblCarInfo::getInsuranceInfo, bo.getInsuranceInfo());

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

@@ -63,8 +63,6 @@ public class TblCarScheduleServiceImpl implements ITblCarScheduleService {
         LambdaQueryWrapper<TblCarSchedule> lqw = Wrappers.lambdaQuery();
         lqw.eq(StringUtils.isNotBlank(bo.getPathInfo()), TblCarSchedule::getPathInfo, bo.getPathInfo());
         lqw.eq(bo.getScheduleDate() != null, TblCarSchedule::getScheduleDate, bo.getScheduleDate());
-        lqw.eq(bo.getCTime() != null, TblCarSchedule::getCTime, bo.getCTime());
-        lqw.eq(bo.getUTime() != null, TblCarSchedule::getUTime, bo.getUTime());
         return lqw;
     }
 

+ 59 - 0
ruoyi-modules/ruoyi-khy/src/main/java/org/dromara/util/CamelDataUtil.java

@@ -6,12 +6,24 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.camel.CamelContext;
 import org.apache.camel.Exchange;
 import org.apache.camel.ProducerTemplate;
+import org.dromara.common.core.constant.Constants;
+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.TblCarInfo;
+import org.dromara.system.domain.bo.TblCarInfoBo;
+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.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
 import java.io.UnsupportedEncodingException;
+import java.time.Duration;
+import java.util.List;
 import java.util.Map;
 
 @Slf4j
@@ -23,6 +35,19 @@ public class CamelDataUtil {
     @Autowired
     ITblGpsDataService gpsDataService;
 
+
+    @Autowired
+    ITblCarInfoService tblCarInfoService;
+
+    @Autowired
+    ITblCarPathService tablCarPathService;
+
+    @Autowired
+    ISysDictDataService sysDictDataService;
+
+
+    private StandardThreadExecutor threadPoolExecutor=new StandardThreadExecutor();
+
     public void SendData(String endrouter,Object payload,String headerkey,Object headervalue){
         ProducerTemplate template = camelContext.createProducerTemplate();
         template.sendBodyAndHeader(endrouter,payload,headerkey,headervalue);
@@ -44,6 +69,40 @@ public class CamelDataUtil {
             gpsData.setSpeed(JSONUtil.parseObj(body).getDouble("SPD"));
             log.info("body:{}",JSONUtil.toJsonStr(gpsData));
             gpsDataService.insertData(gpsData);
+
+            //缓存最新数据到redis
+            RedisUtils.setCacheObject(StringUtils.format("gps_{}", devicecode), gpsData);
+
+//            GpsData gpsData1 = RedisUtils.getCacheObject(StringUtils.format("gps_{}", devicecode));
+//            System.out.println("ss");
+            //TODO 需要计算位置做预报及广播  在其他线程中做运算
+
+
+            threadPoolExecutor.execute(new Runnable() {
+                @Override
+                public void run() {
+
+                    TblCarInfoBo carInfoBo = new TblCarInfoBo();
+                    carInfoBo.setDeviceInfos(devicecode);
+                    List<TblCarInfoVo> carInfoVos =  tblCarInfoService.queryList(carInfoBo);
+                    if(carInfoVos.size()>0){
+                        TblCarInfoVo carInfoVo = carInfoVos.get(0);
+                        if(StringUtils.isNotEmpty(carInfoVo.getCarNum())){
+                            //查询车辆信息
+                            TblCarInfoBo carInfoBo1 = new TblCarInfoBo();
+                            carInfoBo1.setCarNum(carInfoVo.getCarNum());
+                            List<TblCarInfoVo> carInfoVos1 =  tblCarInfoService.queryList(carInfoBo1);
+                            if(carInfoVos1.size()>0){
+                                TblCarInfoVo carInfoVo1 = carInfoVos1.get(0);
+                            }
+                        }
+
+                    }
+
+                    // 查询车辆信息 查询路线信息 查询下个站点信息(包括站点设备) 计算经纬距离 满足条件播报(led or 广播)
+                    System.out.println("---------");
+                }
+            });
         }
 
         log.info("body:{}",body);

+ 49 - 0
ruoyi-modules/ruoyi-khy/src/main/java/org/dromara/util/ExecutorQueue.java

@@ -0,0 +1,49 @@
+package org.dromara.util;
+
+import java.util.concurrent.LinkedTransferQueue;
+import java.util.concurrent.RejectedExecutionException;
+
+public class ExecutorQueue extends LinkedTransferQueue<Runnable> {
+    private static final long serialVersionUID = -265236426751004839L;
+    private transient StandardThreadExecutor threadPoolExecutor;
+
+    public ExecutorQueue() {
+        super();
+    }
+
+    public void setStandardThreadExecutor(StandardThreadExecutor threadPoolExecutor) {
+        this.threadPoolExecutor = threadPoolExecutor;
+    }
+
+    // 注:代码来源于 tomcat
+    public boolean force(Runnable o) {
+        if (threadPoolExecutor.isShutdown()) {
+            throw new RejectedExecutionException("Executor not running, can't force a command into the queue");
+        }
+        // forces the item onto the queue, to be used if the task is rejected
+        return super.offer(o);
+    }
+
+    // 注:tomcat的代码进行一些小变更
+    @Override
+    public boolean offer(Runnable o) {
+        int poolSize = threadPoolExecutor.getPoolSize();
+
+        // we are maxed out on threads, simply queue the object
+        if (poolSize == threadPoolExecutor.getMaximumPoolSize()) {
+            return super.offer(o);
+        }
+        // we have idle threads, just add it to the queue
+        // note that we don't use getActiveCount(), see BZ 49730
+        if (poolSize >= threadPoolExecutor.getSubmittedTasksCount()) {
+            return super.offer(o);
+        }
+        // if we have less threads than maximum force creation of a new
+        // thread
+        if (poolSize < threadPoolExecutor.getMaximumPoolSize()) {
+            return false;
+        }
+        // if we reached here, we need to add it to the queue
+        return super.offer(o);
+    }
+}

+ 92 - 0
ruoyi-modules/ruoyi-khy/src/main/java/org/dromara/util/StandardThreadExecutor.java

@@ -0,0 +1,92 @@
+package org.dromara.util;
+
+
+import lombok.extern.slf4j.Slf4j;
+
+import java.util.concurrent.*;
+import java.util.concurrent.atomic.AtomicInteger;
+
+@Slf4j
+public class StandardThreadExecutor extends ThreadPoolExecutor {
+
+	public static final int DEFAULT_MIN_THREADS = 20;
+	public static final int DEFAULT_MAX_THREADS = 200;
+	public static final int DEFAULT_MAX_IDLE_TIME = 60000; // 1 minutes
+
+	protected AtomicInteger submittedTasksCount;	// 正在处理的任务数
+	private int maxSubmittedTaskCount;				// 最大允许同时处理的任务数
+
+	public StandardThreadExecutor() {
+		this(DEFAULT_MIN_THREADS, DEFAULT_MAX_THREADS);
+	}
+
+	public StandardThreadExecutor(int coreThread, int maxThreads) {
+		this(coreThread, maxThreads, maxThreads);
+	}
+
+	public StandardThreadExecutor(int coreThread, int maxThreads, long keepAliveTime, TimeUnit unit) {
+		this(coreThread, maxThreads, keepAliveTime, unit, maxThreads);
+	}
+
+	public StandardThreadExecutor(int coreThreads, int maxThreads, int queueCapacity) {
+		this(coreThreads, maxThreads, queueCapacity, Executors.defaultThreadFactory());
+	}
+
+	public StandardThreadExecutor(int coreThreads, int maxThreads, int queueCapacity, ThreadFactory threadFactory) {
+		this(coreThreads, maxThreads, DEFAULT_MAX_IDLE_TIME, TimeUnit.MILLISECONDS, queueCapacity, threadFactory);
+	}
+
+	public StandardThreadExecutor(int coreThreads, int maxThreads, long keepAliveTime, TimeUnit unit, int queueCapacity) {
+		this(coreThreads, maxThreads, keepAliveTime, unit, queueCapacity, Executors.defaultThreadFactory());
+	}
+
+	public StandardThreadExecutor(int coreThreads, int maxThreads, long keepAliveTime, TimeUnit unit,
+			int queueCapacity, ThreadFactory threadFactory) {
+		this(coreThreads, maxThreads, keepAliveTime, unit, queueCapacity, threadFactory, new AbortPolicy());
+	}
+
+	public StandardThreadExecutor(int coreThreads, int maxThreads, long keepAliveTime, TimeUnit unit,
+			int queueCapacity, ThreadFactory threadFactory, RejectedExecutionHandler handler) {
+		super(coreThreads, maxThreads, keepAliveTime, unit, new ExecutorQueue(), threadFactory, handler);
+		((ExecutorQueue) getQueue()).setStandardThreadExecutor(this);
+
+		submittedTasksCount = new AtomicInteger(0);
+
+		// 最大并发任务限制: 队列buffer数 + 最大线程数
+		maxSubmittedTaskCount = queueCapacity + maxThreads;
+	}
+
+	@Override
+	public void execute(Runnable command) {
+		int count = submittedTasksCount.incrementAndGet();
+
+		// 超过最大的并发任务限制,进行 reject
+		// 依赖的LinkedTransferQueue没有长度限制,因此这里进行控制
+		if (count > maxSubmittedTaskCount) {
+			submittedTasksCount.decrementAndGet();
+			getRejectedExecutionHandler().rejectedExecution(command, this);
+		}
+
+		try {
+			super.execute(command);
+		} catch (RejectedExecutionException rx) {
+			// there could have been contention around the queue
+			if (!((ExecutorQueue) getQueue()).force(command)) {
+				submittedTasksCount.decrementAndGet();
+				getRejectedExecutionHandler().rejectedExecution(command, this);
+			}
+			log.error(rx.getMessage());
+		}
+	}
+
+	public int getSubmittedTasksCount() {
+		return this.submittedTasksCount.get();
+	}
+
+	@Override
+	protected void afterExecute(Runnable r, Throwable t) {
+		submittedTasksCount.decrementAndGet();
+	}
+}
+
+

+ 1 - 0
ruoyi-modules/ruoyi-khy/src/main/resources/mapper/system/TblCarInfoMapper.xml

@@ -4,4 +4,5 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="org.dromara.system.mapper.TblCarInfoMapper">
 
+
 </mapper>