459242451@qq.com 3 роки тому
батько
коміт
52c8312720
18 змінених файлів з 1212 додано та 726 видалено
  1. 32 0
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/qdtl/TlCommonController.java
  2. 41 3
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/task/XunTask.java
  3. 24 23
      ruoyi-admin/src/main/resources/application.yml
  4. 65 46
      ruoyi-admin/src/main/resources/logback.xml
  5. 71 61
      ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisCache.java
  6. 86 60
      ruoyi-system/src/main/java/com/ruoyi/qdtl/domain/TlInspectionLocation.java
  7. 13 10
      ruoyi-system/src/main/java/com/ruoyi/qdtl/mapper/TlAreaMapper.java
  8. 19 11
      ruoyi-system/src/main/java/com/ruoyi/qdtl/mapper/TlInspectionLocationMapper.java
  9. 3 3
      ruoyi-system/src/main/java/com/ruoyi/qdtl/service/IQdCommonService.java
  10. 12 10
      ruoyi-system/src/main/java/com/ruoyi/qdtl/service/ITlAreaService.java
  11. 18 11
      ruoyi-system/src/main/java/com/ruoyi/qdtl/service/ITlInspectionLocationService.java
  12. 39 0
      ruoyi-system/src/main/java/com/ruoyi/qdtl/service/impl/QdCommonServiceImpl.java
  13. 24 26
      ruoyi-system/src/main/java/com/ruoyi/qdtl/service/impl/TlAreaServiceImpl.java
  14. 45 33
      ruoyi-system/src/main/java/com/ruoyi/qdtl/service/impl/TlInspectionLocationServiceImpl.java
  15. 53 30
      ruoyi-system/src/main/resources/mapper/qdtl/TlAreaMapper.xml
  16. 46 30
      ruoyi-system/src/main/resources/mapper/qdtl/TlInspectionDeviceMapper.xml
  17. 80 38
      ruoyi-system/src/main/resources/mapper/qdtl/TlInspectionLocationMapper.xml
  18. 541 331
      sql/ry_20210908.sql

+ 32 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/qdtl/TlCommonController.java

@@ -8,6 +8,10 @@ import cn.hutool.json.JSONUtil;
 import com.ruoyi.common.core.controller.BaseController;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.core.redis.RedisCache;
+import com.ruoyi.qdtl.domain.TlArea;
+import com.ruoyi.qdtl.domain.TlInspectionLocation;
+import com.ruoyi.qdtl.service.ITlAreaService;
+import com.ruoyi.qdtl.service.ITlInspectionLocationService;
 import com.ruoyi.system.domain.SysConfig;
 import com.ruoyi.system.service.ISysConfigService;
 import lombok.extern.slf4j.Slf4j;
@@ -19,7 +23,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * 监控设备管理Controller
@@ -36,6 +42,10 @@ public class TlCommonController extends BaseController {
     private RedisCache redisCache;
     @Autowired
     private ISysConfigService sysConfigService;
+    @Autowired
+    private ITlAreaService tlAreaService;
+    @Autowired
+    private ITlInspectionLocationService tlInspectionLocationService;
 
     /**
      * 查询监控设备管理列表
@@ -75,5 +85,27 @@ public class TlCommonController extends BaseController {
         return AjaxResult.success(list);
     }
 
+    /**
+     * 地图上各类资源数据
+     *
+     * @return
+     */
+    @GetMapping("/resource")
+    public AjaxResult resource() {
+        Map<String, Object> map = new HashMap<>(8);
+        // 区域
+        List<TlArea> areas = tlAreaService.selectAreaList();
+        map.put("area", areas);
+        // 静态资源
+        // 巡检点
+        List<TlInspectionLocation> staticLocation = tlInspectionLocationService.selectLocationList();
+        map.put("staticLocation", staticLocation);
+
+        // 动态资源
 
+        // 铁路沿线
+        List<SysConfig> railway = sysConfigService.selectConfigByLeftKey("tl.railway.");
+        map.put("railway", railway);
+        return AjaxResult.success(map);
+    }
 }

+ 41 - 3
ruoyi-admin/src/main/java/com/ruoyi/web/controller/task/XunTask.java

@@ -3,15 +3,15 @@ package com.ruoyi.web.controller.task;
 import cn.hutool.json.JSONArray;
 import cn.hutool.json.JSONObject;
 import cn.hutool.json.JSONUtil;
+import com.ruoyi.common.core.redis.RedisCache;
 import com.ruoyi.qdtl.domain.TlInspectionDevice;
-import com.ruoyi.qdtl.domain.XunDevice;
+import com.ruoyi.qdtl.domain.TlInspectionLocation;
 import com.ruoyi.qdtl.service.IQdCommonService;
 import com.ruoyi.qdtl.service.ITlInspectionDeviceService;
+import com.ruoyi.qdtl.service.ITlInspectionLocationService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
-import java.util.List;
-
 /**
  * @Description: TODO
  * @Author: huangcheng
@@ -25,6 +25,10 @@ public class XunTask {
     private IQdCommonService qdCommonService;
     @Autowired
     private ITlInspectionDeviceService tlInspectionDeviceService;
+    @Autowired
+    private ITlInspectionLocationService tlInspectionLocationService;
+    @Autowired
+    private RedisCache redisCache;
 
     /**
      * 同步设备列表
@@ -55,6 +59,40 @@ public class XunTask {
     }
 
     /**
+     * 同步巡检点
+     */
+    public void syncCheckpoint() {
+        JSONArray checkpoints = qdCommonService.getCheckpoint();
+        if (checkpoints != null && checkpoints.size() > 0) {
+            // 获取当前需要更新的版本号
+            int version = qdCommonService.getVersion("tl:version:checkpoint");
+            for (Object checkpoint : checkpoints) {
+                JSONObject jsonObject = JSONUtil.parseObj(checkpoint);
+                String thirdId = jsonObject.getStr("id");
+                String name = jsonObject.getStr("name");
+                String code = jsonObject.getStr("card");
+                // 根据thirdId查询是否存在
+                TlInspectionLocation tlInspectionLocation = tlInspectionLocationService.queryByThirdId(thirdId);
+                if (tlInspectionLocation != null) {
+                    tlInspectionLocation.setLocationCode(code);
+                    tlInspectionLocation.setLocationName(name);
+                    tlInspectionLocation.setVersion(version);
+                    tlInspectionLocationService.updateTlInspectionLocation(tlInspectionLocation);
+                } else {
+                    tlInspectionLocation = new TlInspectionLocation();
+                    tlInspectionLocation.setLocationCode(code);
+                    tlInspectionLocation.setLocationName(name);
+                    tlInspectionLocation.setVersion(version);
+                    tlInspectionLocation.setThirdId(thirdId);
+                    tlInspectionLocationService.insertTlInspectionLocation(tlInspectionLocation);
+                }
+            }
+            // 删除非此版本号的数据
+            tlInspectionLocationService.deleteLocationByVersion(version);
+        }
+    }
+
+    /**
      * 同步巡检记录
      */
     public void syncCheckpointLog() {

+ 24 - 23
ruoyi-admin/src/main/resources/application.yml

@@ -45,15 +45,15 @@ spring:
   messages:
     # 国际化资源文件路径
     basename: i18n/messages
-  profiles: 
+  profiles:
     active: druid
   # 文件上传
   servlet:
-     multipart:
-       # 单个文件大小
-       max-file-size:  10MB
-       # 设置总上传的文件大小
-       max-request-size:  20MB
+    multipart:
+      # 单个文件大小
+      max-file-size: 10MB
+      # 设置总上传的文件大小
+      max-request-size: 20MB
   # 服务模块
   devtools:
     restart:
@@ -68,7 +68,7 @@ spring:
     # 数据库索引
     database: ${REDIS_DB:0}
     # 密码
-    password: 
+    password:
     # 连接超时时间
     timeout: 10s
     lettuce:
@@ -84,27 +84,27 @@ spring:
 
 # token配置
 token:
-    # 令牌自定义标识
-    header: Authorization
-    # 令牌密钥
-    secret: abcdefghijklmnopqrstuvwxyz
-    # 令牌有效期(默认30分钟)
-    expireTime: 10080
-  
+  # 令牌自定义标识
+  header: Authorization
+  # 令牌密钥
+  secret: abcdefghijklmnopqrstuvwxyz
+  # 令牌有效期(默认30分钟)
+  expireTime: 10080
+
 # MyBatis配置
 mybatis:
-    # 搜索指定包别名
-    typeAliasesPackage: com.ruoyi.**.domain
-    # 配置mapper的扫描,找到所有的mapper.xml映射文件
-    mapperLocations: classpath*:mapper/**/*Mapper.xml
-    # 加载全局的配置文件
-    configLocation: classpath:mybatis/mybatis-config.xml
+  # 搜索指定包别名
+  typeAliasesPackage: com.ruoyi.**.domain
+  # 配置mapper的扫描,找到所有的mapper.xml映射文件
+  mapperLocations: classpath*:mapper/**/*Mapper.xml
+  # 加载全局的配置文件
+  configLocation: classpath:mybatis/mybatis-config.xml
 
 # PageHelper分页插件
-pagehelper: 
+pagehelper:
   helperDialect: mysql
   supportMethodsArguments: true
-  params: count=countSql 
+  params: count=countSql
 
 # Swagger配置
 swagger:
@@ -114,7 +114,7 @@ swagger:
   pathMapping: /dev-api
 
 # 防止XSS攻击
-xss: 
+xss:
   # 过滤开关
   enabled: true
   # 排除链接(多个用逗号分隔)
@@ -127,5 +127,6 @@ third:
   xuntoken: https://api.5ixun.com/api/v1/login # 获取token
   xundevice: https://api.5ixun.com/api/v1/device # 设备列表
   xuncheckpointLog: https://api.5ixun.com/api/v1/checkpointLog # 设备巡检历史
+  xuncheckpoint: https://api.5ixun.com/api/v1/checkpoint # 巡检点
   xuntrail: https://api.5ixun.com/api/v1/trail # 设备轨迹
 

+ 65 - 46
ruoyi-admin/src/main/resources/logback.xml

@@ -1,32 +1,51 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <configuration>
     <!-- 日志存放路径 -->
-	<property name="log.path" value="../logs" />
+    <property name="log.path" value="../logs"/>
     <!-- 日志输出格式 -->
-	<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
+    <property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
 
-	<!-- 控制台输出 -->
-	<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
-		<encoder>
-			<pattern>${log.pattern}</pattern>
-		</encoder>
-	</appender>
-	
-	<!-- 系统日志输出 -->
-	<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
-	    <file>${log.path}/sys-info.log</file>
+    <!-- 控制台输出 -->
+    <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder>
+            <pattern>${log.pattern}</pattern>
+        </encoder>
+    </appender>
+
+    <!-- 控制台输出 -->
+    <appender name="file_console" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <file>${log.path}/sys-console.log</file>
+        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+            <!-- 日志文件名格式 -->
+            <fileNamePattern>${log.path}/sys-console.%d{yyyy-MM-dd}.log</fileNamePattern>
+            <!-- 日志最大 1天 -->
+            <maxHistory>1</maxHistory>
+        </rollingPolicy>
+        <encoder>
+            <pattern>${log.pattern}</pattern>
+            <charset>utf-8</charset>
+        </encoder>
+        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
+            <!-- 过滤的级别 -->
+            <level>INFO</level>
+        </filter>
+    </appender>
+
+    <!-- 系统日志输出 -->
+    <appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <file>${log.path}/sys-info.log</file>
         <!-- 循环政策:基于时间创建日志文件 -->
-		<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
+        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
             <!-- 日志文件名格式 -->
-			<fileNamePattern>${log.path}/sys-info.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
-			<!-- 日志最大的历史 60天 -->
-			<maxHistory>60</maxHistory>
+            <fileNamePattern>${log.path}/sys-info.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
+            <!-- 日志最大的历史 60天 -->
+            <maxHistory>60</maxHistory>
             <maxFileSize>20MB</maxFileSize>
-		</rollingPolicy>
-		<encoder>
-			<pattern>${log.pattern}</pattern>
-		</encoder>
-		<filter class="ch.qos.logback.classic.filter.LevelFilter">
+        </rollingPolicy>
+        <encoder>
+            <pattern>${log.pattern}</pattern>
+        </encoder>
+        <filter class="ch.qos.logback.classic.filter.LevelFilter">
             <!-- 过滤的级别 -->
             <level>INFO</level>
             <!-- 匹配时的操作:接收(记录) -->
@@ -34,16 +53,16 @@
             <!-- 不匹配时的操作:拒绝(不记录) -->
             <onMismatch>DENY</onMismatch>
         </filter>
-	</appender>
-	
-	<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
-	    <file>${log.path}/sys-error.log</file>
+    </appender>
+
+    <appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <file>${log.path}/sys-error.log</file>
         <!-- 循环政策:基于时间创建日志文件 -->
         <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
             <!-- 日志文件名格式 -->
             <fileNamePattern>${log.path}/sys-error.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
-			<!-- 日志最大的历史 60天 -->
-			<maxHistory>60</maxHistory>
+            <!-- 日志最大的历史 60天 -->
+            <maxHistory>60</maxHistory>
             <maxFileSize>20MB</maxFileSize>
         </rollingPolicy>
         <encoder>
@@ -52,16 +71,16 @@
         <filter class="ch.qos.logback.classic.filter.LevelFilter">
             <!-- 过滤的级别 -->
             <level>ERROR</level>
-			<!-- 匹配时的操作:接收(记录) -->
+            <!-- 匹配时的操作:接收(记录) -->
             <onMatch>ACCEPT</onMatch>
-			<!-- 不匹配时的操作:拒绝(不记录) -->
+            <!-- 不匹配时的操作:拒绝(不记录) -->
             <onMismatch>DENY</onMismatch>
         </filter>
     </appender>
-	
-	<!-- 用户访问日志输出  -->
+
+    <!-- 用户访问日志输出  -->
     <appender name="sys-user" class="ch.qos.logback.core.rolling.RollingFileAppender">
-		<file>${log.path}/sys-user.log</file>
+        <file>${log.path}/sys-user.log</file>
         <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
             <!-- 按天回滚 daily -->
             <fileNamePattern>${log.path}/sys-user.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
@@ -73,23 +92,23 @@
             <pattern>${log.pattern}</pattern>
         </encoder>
     </appender>
-	
-	<!-- 系统模块日志级别控制  -->
-	<logger name="com.ruoyi" level="info" />
-	<!-- Spring日志级别控制  -->
-	<logger name="org.springframework" level="warn" />
 
-	<root level="info">
-		<appender-ref ref="console" />
-	</root>
-	
-	<!--系统操作日志-->
+    <!-- 系统模块日志级别控制  -->
+    <logger name="com.ruoyi" level="info"/>
+    <!-- Spring日志级别控制  -->
+    <logger name="org.springframework" level="warn"/>
+
     <root level="info">
-        <appender-ref ref="file_info" />
-        <appender-ref ref="file_error" />
+        <appender-ref ref="console"/>
     </root>
-	
-	<!--系统用户操作日志-->
+
+    <!--系统操作日志-->
+    <root level="info">
+        <appender-ref ref="file_info"/>
+        <appender-ref ref="file_error"/>
+    </root>
+
+    <!--系统用户操作日志-->
     <logger name="sys-user" level="info">
         <appender-ref ref="sys-user"/>
     </logger>

+ 71 - 61
ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisCache.java

@@ -1,11 +1,5 @@
 package com.ruoyi.common.core.redis;
 
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.BoundSetOperations;
 import org.springframework.data.redis.core.HashOperations;
@@ -13,64 +7,66 @@ import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.data.redis.core.ValueOperations;
 import org.springframework.stereotype.Component;
 
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+
 /**
  * spring redis 工具类
  *
  * @author ruoyi
  **/
-@SuppressWarnings(value = { "unchecked", "rawtypes" })
+@SuppressWarnings(value = {"unchecked", "rawtypes"})
 @Component
-public class RedisCache
-{
+public class RedisCache {
     @Autowired
     public RedisTemplate redisTemplate;
 
     /**
      * 缓存基本的对象,Integer、String、实体类等
      *
-     * @param key 缓存的键值
+     * @param key   缓存的键值
      * @param value 缓存的值
      */
-    public <T> void setCacheObject(final String key, final T value)
-    {
+    public <T> void setCacheObject(final String key, final T value) {
         redisTemplate.opsForValue().set(key, value);
     }
 
     /**
      * 缓存基本的对象,Integer、String、实体类等
      *
-     * @param key 缓存的键值
-     * @param value 缓存的值
-     * @param timeout 时间
+     * @param key      缓存的键值
+     * @param value    缓存的值
+     * @param timeout  时间
      * @param timeUnit 时间颗粒度
      */
-    public <T> void setCacheObject(final String key, final T value, final Integer timeout, final TimeUnit timeUnit)
-    {
+    public <T> void setCacheObject(final String key, final T value, final Integer timeout, final TimeUnit timeUnit) {
         redisTemplate.opsForValue().set(key, value, timeout, timeUnit);
     }
 
     /**
      * 设置有效时间
      *
-     * @param key Redis键
+     * @param key     Redis键
      * @param timeout 超时时间
      * @return true=设置成功;false=设置失败
      */
-    public boolean expire(final String key, final long timeout)
-    {
+    public boolean expire(final String key, final long timeout) {
         return expire(key, timeout, TimeUnit.SECONDS);
     }
 
     /**
      * 设置有效时间
      *
-     * @param key Redis键
+     * @param key     Redis键
      * @param timeout 超时时间
-     * @param unit 时间单位
+     * @param unit    时间单位
      * @return true=设置成功;false=设置失败
      */
-    public boolean expire(final String key, final long timeout, final TimeUnit unit)
-    {
+    public boolean expire(final String key, final long timeout, final TimeUnit unit) {
         return redisTemplate.expire(key, timeout, unit);
     }
 
@@ -80,8 +76,7 @@ public class RedisCache
      * @param key 缓存键值
      * @return 缓存键值对应的数据
      */
-    public <T> T getCacheObject(final String key)
-    {
+    public <T> T getCacheObject(final String key) {
         ValueOperations<String, T> operation = redisTemplate.opsForValue();
         return operation.get(key);
     }
@@ -91,8 +86,7 @@ public class RedisCache
      *
      * @param key
      */
-    public boolean deleteObject(final String key)
-    {
+    public boolean deleteObject(final String key) {
         return redisTemplate.delete(key);
     }
 
@@ -102,20 +96,18 @@ public class RedisCache
      * @param collection 多个对象
      * @return
      */
-    public long deleteObject(final Collection collection)
-    {
+    public long deleteObject(final Collection collection) {
         return redisTemplate.delete(collection);
     }
 
     /**
      * 缓存List数据
      *
-     * @param key 缓存的键值
+     * @param key      缓存的键值
      * @param dataList 待缓存的List数据
      * @return 缓存的对象
      */
-    public <T> long setCacheList(final String key, final List<T> dataList)
-    {
+    public <T> long setCacheList(final String key, final List<T> dataList) {
         Long count = redisTemplate.opsForList().rightPushAll(key, dataList);
         return count == null ? 0 : count;
     }
@@ -126,24 +118,21 @@ public class RedisCache
      * @param key 缓存的键值
      * @return 缓存键值对应的数据
      */
-    public <T> List<T> getCacheList(final String key)
-    {
+    public <T> List<T> getCacheList(final String key) {
         return redisTemplate.opsForList().range(key, 0, -1);
     }
 
     /**
      * 缓存Set
      *
-     * @param key 缓存键值
+     * @param key     缓存键值
      * @param dataSet 缓存的数据
      * @return 缓存数据的对象
      */
-    public <T> BoundSetOperations<String, T> setCacheSet(final String key, final Set<T> dataSet)
-    {
+    public <T> BoundSetOperations<String, T> setCacheSet(final String key, final Set<T> dataSet) {
         BoundSetOperations<String, T> setOperation = redisTemplate.boundSetOps(key);
         Iterator<T> it = dataSet.iterator();
-        while (it.hasNext())
-        {
+        while (it.hasNext()) {
             setOperation.add(it.next());
         }
         return setOperation;
@@ -155,8 +144,7 @@ public class RedisCache
      * @param key
      * @return
      */
-    public <T> Set<T> getCacheSet(final String key)
-    {
+    public <T> Set<T> getCacheSet(final String key) {
         return redisTemplate.opsForSet().members(key);
     }
 
@@ -166,8 +154,7 @@ public class RedisCache
      * @param key
      * @param dataMap
      */
-    public <T> void setCacheMap(final String key, final Map<String, T> dataMap)
-    {
+    public <T> void setCacheMap(final String key, final Map<String, T> dataMap) {
         if (dataMap != null) {
             redisTemplate.opsForHash().putAll(key, dataMap);
         }
@@ -179,44 +166,40 @@ public class RedisCache
      * @param key
      * @return
      */
-    public <T> Map<String, T> getCacheMap(final String key)
-    {
+    public <T> Map<String, T> getCacheMap(final String key) {
         return redisTemplate.opsForHash().entries(key);
     }
 
     /**
      * 往Hash中存入数据
      *
-     * @param key Redis键
-     * @param hKey Hash键
+     * @param key   Redis键
+     * @param hKey  Hash键
      * @param value 值
      */
-    public <T> void setCacheMapValue(final String key, final String hKey, final T value)
-    {
+    public <T> void setCacheMapValue(final String key, final String hKey, final T value) {
         redisTemplate.opsForHash().put(key, hKey, value);
     }
 
     /**
      * 获取Hash中的数据
      *
-     * @param key Redis键
+     * @param key  Redis键
      * @param hKey Hash键
      * @return Hash中的对象
      */
-    public <T> T getCacheMapValue(final String key, final String hKey)
-    {
+    public <T> T getCacheMapValue(final String key, final String hKey) {
         HashOperations<String, String, T> opsForHash = redisTemplate.opsForHash();
         return opsForHash.get(key, hKey);
     }
 
     /**
      * 删除Hash中的数据
-     * 
+     *
      * @param key
      * @param mapkey
      */
-    public void delCacheMapValue(final String key, final String hkey)
-    {
+    public void delCacheMapValue(final String key, final String hkey) {
         HashOperations hashOperations = redisTemplate.opsForHash();
         hashOperations.delete(key, hkey);
     }
@@ -224,12 +207,11 @@ public class RedisCache
     /**
      * 获取多个Hash中的数据
      *
-     * @param key Redis键
+     * @param key   Redis键
      * @param hKeys Hash键集合
      * @return Hash对象集合
      */
-    public <T> List<T> getMultiCacheMapValue(final String key, final Collection<Object> hKeys)
-    {
+    public <T> List<T> getMultiCacheMapValue(final String key, final Collection<Object> hKeys) {
         return redisTemplate.opsForHash().multiGet(key, hKeys);
     }
 
@@ -239,8 +221,36 @@ public class RedisCache
      * @param pattern 字符串前缀
      * @return 对象列表
      */
-    public Collection<String> keys(final String pattern)
-    {
+    public Collection<String> keys(final String pattern) {
         return redisTemplate.keys(pattern);
     }
+
+    /**
+     * 递增
+     *
+     * @param key   键
+     * @param delta 要增加几(大于0)
+     * @return
+     */
+    public long incr(String key, long delta) {
+        if (delta < 0) {
+            throw new RuntimeException("递增因子必须大于0");
+        }
+        return redisTemplate.opsForValue().increment(key, delta);
+    }
+
+    /**
+     * 判断key是否存在
+     *
+     * @param key 键
+     * @return true 存在 false不存在
+     */
+    public boolean hasKey(String key) {
+        try {
+            return redisTemplate.hasKey(key);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return false;
+        }
+    }
 }

+ 86 - 60
ruoyi-system/src/main/java/com/ruoyi/qdtl/domain/TlInspectionLocation.java

@@ -1,147 +1,157 @@
 package com.ruoyi.qdtl.domain;
 
-import org.apache.commons.lang3.builder.ToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
 import com.ruoyi.common.annotation.Excel;
 import com.ruoyi.common.core.domain.BaseEntity;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
 
 import java.util.List;
 
 /**
  * 巡检点管理对象 tl_inspection_location
- * 
+ *
  * @author ruoyi
  * @date 2022-02-22
  */
-public class TlInspectionLocation extends BaseEntity
-{
+public class TlInspectionLocation extends BaseEntity {
     private static final long serialVersionUID = 1L;
 
-    /** id */
+    /**
+     * id
+     */
     private Long id;
 
-    /** 编号 */
+    /**
+     * 编号
+     */
     @Excel(name = "编号")
     private String locationCode;
 
-    /** 名称 */
+    /**
+     * 名称
+     */
     @Excel(name = "名称")
     private String locationName;
 
-    /** 描述 */
+    /**
+     * 描述
+     */
     @Excel(name = "描述")
     private String detail;
 
-    /** 巡检设备 */
+    /**
+     * 巡检设备
+     */
     @Excel(name = "巡检设备")
     private String deviceIds;
 
     private List<TlInspectionDevice> deviceNames;
 
-    /** 所属区域 */
+    /**
+     * 所属区域
+     */
     @Excel(name = "所属区域")
     private Long areaId;
 
-    /** 经纬度 */
+    /**
+     * 经纬度
+     */
     private String lnglat;
 
-    /** 删除标志(0代表存在 2代表删除) */
+    /**
+     * 删除标志(0代表存在 2代表删除)
+     */
     private String delFlag;
 
     private Integer sortNo;
 
     private Long lineId;
 
-    public void setId(Long id) 
-    {
+    private Integer version;
+
+    private String thirdId;
+
+    public void setId(Long id) {
         this.id = id;
     }
 
-    public Long getId() 
-    {
+    public Long getId() {
         return id;
     }
-    public void setLocationCode(String locationCode) 
-    {
+
+    public void setLocationCode(String locationCode) {
         this.locationCode = locationCode;
     }
 
-    public String getLocationCode() 
-    {
+    public String getLocationCode() {
         return locationCode;
     }
-    public void setLocationName(String locationName) 
-    {
+
+    public void setLocationName(String locationName) {
         this.locationName = locationName;
     }
 
-    public String getLocationName() 
-    {
+    public String getLocationName() {
         return locationName;
     }
-    public void setDetail(String detail) 
-    {
+
+    public void setDetail(String detail) {
         this.detail = detail;
     }
 
-    public String getDetail() 
-    {
+    public String getDetail() {
         return detail;
     }
-    public void setDeviceIds(String deviceIds) 
-    {
+
+    public void setDeviceIds(String deviceIds) {
         this.deviceIds = deviceIds;
     }
 
-    public String getDeviceIds() 
-    {
+    public String getDeviceIds() {
         return deviceIds;
     }
-    public void setAreaId(Long areaId) 
-    {
+
+    public void setAreaId(Long areaId) {
         this.areaId = areaId;
     }
 
-    public Long getAreaId() 
-    {
+    public Long getAreaId() {
         return areaId;
     }
-    public void setLnglat(String lnglat) 
-    {
+
+    public void setLnglat(String lnglat) {
         this.lnglat = lnglat;
     }
 
-    public String getLnglat() 
-    {
+    public String getLnglat() {
         return lnglat;
     }
-    public void setDelFlag(String delFlag) 
-    {
+
+    public void setDelFlag(String delFlag) {
         this.delFlag = delFlag;
     }
 
-    public String getDelFlag() 
-    {
+    public String getDelFlag() {
         return delFlag;
     }
 
     @Override
     public String toString() {
-        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
-            .append("id", getId())
-            .append("locationCode", getLocationCode())
-            .append("locationName", getLocationName())
-            .append("detail", getDetail())
-            .append("deviceIds", getDeviceIds())
-            .append("areaId", getAreaId())
-            .append("lnglat", getLnglat())
-            .append("remark", getRemark())
-            .append("delFlag", getDelFlag())
-            .append("createBy", getCreateBy())
-            .append("createTime", getCreateTime())
-            .append("updateBy", getUpdateBy())
-            .append("updateTime", getUpdateTime())
-            .toString();
+        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
+                .append("id", getId())
+                .append("locationCode", getLocationCode())
+                .append("locationName", getLocationName())
+                .append("detail", getDetail())
+                .append("deviceIds", getDeviceIds())
+                .append("areaId", getAreaId())
+                .append("lnglat", getLnglat())
+                .append("remark", getRemark())
+                .append("delFlag", getDelFlag())
+                .append("createBy", getCreateBy())
+                .append("createTime", getCreateTime())
+                .append("updateBy", getUpdateBy())
+                .append("updateTime", getUpdateTime())
+                .toString();
     }
 
     public List<TlInspectionDevice> getDeviceNames() {
@@ -167,4 +177,20 @@ public class TlInspectionLocation extends BaseEntity
     public void setLineId(Long lineId) {
         this.lineId = lineId;
     }
+
+    public Integer getVersion() {
+        return version;
+    }
+
+    public void setVersion(Integer version) {
+        this.version = version;
+    }
+
+    public String getThirdId() {
+        return thirdId;
+    }
+
+    public void setThirdId(String thirdId) {
+        this.thirdId = thirdId;
+    }
 }

+ 13 - 10
ruoyi-system/src/main/java/com/ruoyi/qdtl/mapper/TlAreaMapper.java

@@ -1,19 +1,19 @@
 package com.ruoyi.qdtl.mapper;
 
-import java.util.List;
 import com.ruoyi.qdtl.domain.TlArea;
 
+import java.util.List;
+
 /**
  * 区域管理Mapper接口
- * 
+ *
  * @author ruoyi
  * @date 2022-02-21
  */
-public interface TlAreaMapper 
-{
+public interface TlAreaMapper {
     /**
      * 查询区域管理
-     * 
+     *
      * @param id 区域管理主键
      * @return 区域管理
      */
@@ -21,7 +21,7 @@ public interface TlAreaMapper
 
     /**
      * 查询区域管理列表
-     * 
+     *
      * @param tlArea 区域管理
      * @return 区域管理集合
      */
@@ -29,7 +29,7 @@ public interface TlAreaMapper
 
     /**
      * 新增区域管理
-     * 
+     *
      * @param tlArea 区域管理
      * @return 结果
      */
@@ -37,7 +37,7 @@ public interface TlAreaMapper
 
     /**
      * 修改区域管理
-     * 
+     *
      * @param tlArea 区域管理
      * @return 结果
      */
@@ -45,7 +45,7 @@ public interface TlAreaMapper
 
     /**
      * 删除区域管理
-     * 
+     *
      * @param id 区域管理主键
      * @return 结果
      */
@@ -53,11 +53,14 @@ public interface TlAreaMapper
 
     /**
      * 批量删除区域管理
-     * 
+     *
      * @param ids 需要删除的数据主键集合
      * @return 结果
      */
     public int deleteTlAreaByIds(Long[] ids);
 
     int selectExist(TlArea tlArea);
+
+    List<TlArea> selectAreaList();
+    
 }

+ 19 - 11
ruoyi-system/src/main/java/com/ruoyi/qdtl/mapper/TlInspectionLocationMapper.java

@@ -1,21 +1,21 @@
 package com.ruoyi.qdtl.mapper;
 
-import java.util.List;
-
 import com.alibaba.fastjson.JSONObject;
 import com.ruoyi.qdtl.domain.TlInspectionLocation;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
  * 巡检点管理Mapper接口
- * 
+ *
  * @author ruoyi
  * @date 2022-02-22
  */
-public interface TlInspectionLocationMapper 
-{
+public interface TlInspectionLocationMapper {
     /**
      * 查询巡检点管理
-     * 
+     *
      * @param id 巡检点管理主键
      * @return 巡检点管理
      */
@@ -23,7 +23,7 @@ public interface TlInspectionLocationMapper
 
     /**
      * 查询巡检点管理列表
-     * 
+     *
      * @param tlInspectionLocation 巡检点管理
      * @return 巡检点管理集合
      */
@@ -31,7 +31,7 @@ public interface TlInspectionLocationMapper
 
     /**
      * 新增巡检点管理
-     * 
+     *
      * @param tlInspectionLocation 巡检点管理
      * @return 结果
      */
@@ -39,7 +39,7 @@ public interface TlInspectionLocationMapper
 
     /**
      * 修改巡检点管理
-     * 
+     *
      * @param tlInspectionLocation 巡检点管理
      * @return 结果
      */
@@ -47,7 +47,7 @@ public interface TlInspectionLocationMapper
 
     /**
      * 删除巡检点管理
-     * 
+     *
      * @param id 巡检点管理主键
      * @return 结果
      */
@@ -55,7 +55,7 @@ public interface TlInspectionLocationMapper
 
     /**
      * 批量删除巡检点管理
-     * 
+     *
      * @param ids 需要删除的数据主键集合
      * @return 结果
      */
@@ -66,4 +66,12 @@ public interface TlInspectionLocationMapper
     List<JSONObject> queryLocationByArea();
 
     List<TlInspectionLocation> queryLocationByLineIds(List<Long> idCollect);
+
+    List<TlInspectionLocation> selectLocationList();
+
+    TlInspectionLocation queryByThirdId(String thirdId);
+
+    int queryMaxVsersion();
+
+    void deleteLocationByVersion(@Param("version") int version);
 }

+ 3 - 3
ruoyi-system/src/main/java/com/ruoyi/qdtl/service/IQdCommonService.java

@@ -1,9 +1,6 @@
 package com.ruoyi.qdtl.service;
 
 import cn.hutool.json.JSONArray;
-import com.ruoyi.qdtl.domain.XunDevice;
-
-import java.util.List;
 
 /**
  * @Description: TODO
@@ -19,6 +16,9 @@ public interface IQdCommonService {
 
     JSONArray getCheckpointLog(String startTime, String endTime);
 
+    JSONArray getCheckpoint();
+
     JSONArray getTrail(String startTime, String endTime, String deviceId);
 
+    int getVersion(String key);
 }

+ 12 - 10
ruoyi-system/src/main/java/com/ruoyi/qdtl/service/ITlAreaService.java

@@ -1,19 +1,19 @@
 package com.ruoyi.qdtl.service;
 
-import java.util.List;
 import com.ruoyi.qdtl.domain.TlArea;
 
+import java.util.List;
+
 /**
  * 区域管理Service接口
- * 
+ *
  * @author ruoyi
  * @date 2022-02-21
  */
-public interface ITlAreaService 
-{
+public interface ITlAreaService {
     /**
      * 查询区域管理
-     * 
+     *
      * @param id 区域管理主键
      * @return 区域管理
      */
@@ -21,7 +21,7 @@ public interface ITlAreaService
 
     /**
      * 查询区域管理列表
-     * 
+     *
      * @param tlArea 区域管理
      * @return 区域管理集合
      */
@@ -29,7 +29,7 @@ public interface ITlAreaService
 
     /**
      * 新增区域管理
-     * 
+     *
      * @param tlArea 区域管理
      * @return 结果
      */
@@ -37,7 +37,7 @@ public interface ITlAreaService
 
     /**
      * 修改区域管理
-     * 
+     *
      * @param tlArea 区域管理
      * @return 结果
      */
@@ -45,7 +45,7 @@ public interface ITlAreaService
 
     /**
      * 批量删除区域管理
-     * 
+     *
      * @param ids 需要删除的区域管理主键集合
      * @return 结果
      */
@@ -53,9 +53,11 @@ public interface ITlAreaService
 
     /**
      * 删除区域管理信息
-     * 
+     *
      * @param id 区域管理主键
      * @return 结果
      */
     public int deleteTlAreaById(Long id);
+
+    List<TlArea> selectAreaList();
 }

+ 18 - 11
ruoyi-system/src/main/java/com/ruoyi/qdtl/service/ITlInspectionLocationService.java

@@ -1,21 +1,20 @@
 package com.ruoyi.qdtl.service;
 
+import com.ruoyi.qdtl.domain.TlInspectionLocation;
+
 import java.util.List;
 import java.util.Map;
 
-import com.ruoyi.qdtl.domain.TlInspectionLocation;
-
 /**
  * 巡检点管理Service接口
- * 
+ *
  * @author ruoyi
  * @date 2022-02-22
  */
-public interface ITlInspectionLocationService 
-{
+public interface ITlInspectionLocationService {
     /**
      * 查询巡检点管理
-     * 
+     *
      * @param id 巡检点管理主键
      * @return 巡检点管理
      */
@@ -23,7 +22,7 @@ public interface ITlInspectionLocationService
 
     /**
      * 查询巡检点管理列表
-     * 
+     *
      * @param tlInspectionLocation 巡检点管理
      * @return 巡检点管理集合
      */
@@ -31,7 +30,7 @@ public interface ITlInspectionLocationService
 
     /**
      * 新增巡检点管理
-     * 
+     *
      * @param tlInspectionLocation 巡检点管理
      * @return 结果
      */
@@ -39,7 +38,7 @@ public interface ITlInspectionLocationService
 
     /**
      * 修改巡检点管理
-     * 
+     *
      * @param tlInspectionLocation 巡检点管理
      * @return 结果
      */
@@ -47,7 +46,7 @@ public interface ITlInspectionLocationService
 
     /**
      * 批量删除巡检点管理
-     * 
+     *
      * @param ids 需要删除的巡检点管理主键集合
      * @return 结果
      */
@@ -55,7 +54,7 @@ public interface ITlInspectionLocationService
 
     /**
      * 删除巡检点管理信息
-     * 
+     *
      * @param id 巡检点管理主键
      * @return 结果
      */
@@ -64,4 +63,12 @@ public interface ITlInspectionLocationService
     Map<String, Integer> queryLocationByArea();
 
     List<TlInspectionLocation> queryLocationByLineIds(List<Long> idCollect);
+
+    List<TlInspectionLocation> selectLocationList();
+
+    TlInspectionLocation queryByThirdId(String thirdId);
+
+    int queryMaxVsersion();
+
+    void deleteLocationByVersion(int version);
 }

+ 39 - 0
ruoyi-system/src/main/java/com/ruoyi/qdtl/service/impl/QdCommonServiceImpl.java

@@ -1,5 +1,6 @@
 package com.ruoyi.qdtl.service.impl;
 
+import cn.hutool.core.convert.Convert;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.http.HttpRequest;
 import cn.hutool.http.HttpUtil;
@@ -9,6 +10,7 @@ import cn.hutool.json.JSONUtil;
 import com.ruoyi.common.core.redis.RedisCache;
 import com.ruoyi.common.exception.ServiceException;
 import com.ruoyi.qdtl.service.IQdCommonService;
+import com.ruoyi.qdtl.service.ITlInspectionLocationService;
 import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -35,11 +37,15 @@ public class QdCommonServiceImpl implements IQdCommonService {
     private String xundeviceUrl;
     @Value("${third.xuncheckpointLog}")
     private String xuncheckpointLogUrl;
+    @Value("${third.xuncheckpoint}")
+    private String xuncheckpointUrl;
     @Value("${third.xuntrail}")
     private String xuntrailUrl;
 
     @Autowired
     private RedisCache redisCache;
+    @Autowired
+    private ITlInspectionLocationService tlInspectionLocationService;
 
     /**
      * 获取巡检接口的token
@@ -109,6 +115,26 @@ public class QdCommonServiceImpl implements IQdCommonService {
     }
 
     /**
+     * 点位列表
+     *
+     * @return
+     */
+    @Override
+    public JSONArray getCheckpoint() {
+        Map<String, Object> paramMap = new HashMap<>();
+        paramMap.put("pageSize", 3000);
+        String get = HttpRequest.get(xuncheckpointUrl).form(paramMap).header("Authorization", this.getXunToken()).execute().body();
+        JSONObject getJson = JSONUtil.parseObj(get);
+        if (200 == getJson.getInt("code")) {
+            JSONObject data = getJson.getJSONObject("data");
+            if (data != null) {
+                return data.getJSONArray("rows");
+            }
+        }
+        return null;
+    }
+
+    /**
      * 查询设备运行轨迹
      *
      * @param startTime
@@ -125,4 +151,17 @@ public class QdCommonServiceImpl implements IQdCommonService {
         String get = HttpRequest.get(xuntrailUrl).form(paramMap).header("Authorization", this.getXunToken()).execute().body();
         return JSONUtil.parseArray(get);
     }
+
+    @Override
+    public int getVersion(String key) {
+        boolean hasKey = redisCache.hasKey(key);
+        if (!hasKey) {
+            // 查询数据库中最大的
+            if (key.equals("tl:version:checkpoint")) {
+                int maxVsersion = tlInspectionLocationService.queryMaxVsersion();
+                redisCache.setCacheObject(key, maxVsersion);
+            }
+        }
+        return Convert.toInt(redisCache.incr(key, 1));
+    }
 }

+ 24 - 26
ruoyi-system/src/main/java/com/ruoyi/qdtl/service/impl/TlAreaServiceImpl.java

@@ -1,60 +1,56 @@
 package com.ruoyi.qdtl.service.impl;
 
-import java.util.List;
-
 import com.ruoyi.common.exception.ServiceException;
 import com.ruoyi.common.utils.DateUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import com.ruoyi.qdtl.mapper.TlAreaMapper;
 import com.ruoyi.qdtl.domain.TlArea;
+import com.ruoyi.qdtl.mapper.TlAreaMapper;
 import com.ruoyi.qdtl.service.ITlAreaService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
 
 /**
  * 区域管理Service业务层处理
- * 
+ *
  * @author ruoyi
  * @date 2022-02-21
  */
 @Service
-public class TlAreaServiceImpl implements ITlAreaService 
-{
+public class TlAreaServiceImpl implements ITlAreaService {
     @Autowired
     private TlAreaMapper tlAreaMapper;
 
     /**
      * 查询区域管理
-     * 
+     *
      * @param id 区域管理主键
      * @return 区域管理
      */
     @Override
-    public TlArea selectTlAreaById(Long id)
-    {
+    public TlArea selectTlAreaById(Long id) {
         return tlAreaMapper.selectTlAreaById(id);
     }
 
     /**
      * 查询区域管理列表
-     * 
+     *
      * @param tlArea 区域管理
      * @return 区域管理
      */
     @Override
-    public List<TlArea> selectTlAreaList(TlArea tlArea)
-    {
+    public List<TlArea> selectTlAreaList(TlArea tlArea) {
         return tlAreaMapper.selectTlAreaList(tlArea);
     }
 
     /**
      * 新增区域管理
-     * 
+     *
      * @param tlArea 区域管理
      * @return 结果
      */
     @Override
-    public int insertTlArea(TlArea tlArea)
-    {
+    public int insertTlArea(TlArea tlArea) {
         tlArea.setCreateTime(DateUtils.getNowDate());
         // 控制编号和名称不能重复
         int count = tlAreaMapper.selectExist(tlArea);
@@ -66,13 +62,12 @@ public class TlAreaServiceImpl implements ITlAreaService
 
     /**
      * 修改区域管理
-     * 
+     *
      * @param tlArea 区域管理
      * @return 结果
      */
     @Override
-    public int updateTlArea(TlArea tlArea)
-    {
+    public int updateTlArea(TlArea tlArea) {
         tlArea.setUpdateTime(DateUtils.getNowDate());
         // 查询原有的数据
         TlArea old = selectTlAreaById(tlArea.getId());
@@ -101,25 +96,28 @@ public class TlAreaServiceImpl implements ITlAreaService
 
     /**
      * 批量删除区域管理
-     * 
+     *
      * @param ids 需要删除的区域管理主键
      * @return 结果
      */
     @Override
-    public int deleteTlAreaByIds(Long[] ids)
-    {
+    public int deleteTlAreaByIds(Long[] ids) {
         return tlAreaMapper.deleteTlAreaByIds(ids);
     }
 
     /**
      * 删除区域管理信息
-     * 
+     *
      * @param id 区域管理主键
      * @return 结果
      */
     @Override
-    public int deleteTlAreaById(Long id)
-    {
+    public int deleteTlAreaById(Long id) {
         return tlAreaMapper.deleteTlAreaById(id);
     }
+
+    @Override
+    public List<TlArea> selectAreaList() {
+        return tlAreaMapper.selectAreaList();
+    }
 }

+ 45 - 33
ruoyi-system/src/main/java/com/ruoyi/qdtl/service/impl/TlInspectionLocationServiceImpl.java

@@ -1,84 +1,78 @@
 package com.ruoyi.qdtl.service.impl;
 
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-
 import com.alibaba.fastjson.JSONObject;
-import com.ruoyi.common.exception.ServiceException;
 import com.ruoyi.common.utils.DateUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import com.ruoyi.qdtl.mapper.TlInspectionLocationMapper;
 import com.ruoyi.qdtl.domain.TlInspectionLocation;
+import com.ruoyi.qdtl.mapper.TlInspectionLocationMapper;
 import com.ruoyi.qdtl.service.ITlInspectionLocationService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * 巡检点管理Service业务层处理
- * 
+ *
  * @author ruoyi
  * @date 2022-02-22
  */
 @Service
-public class TlInspectionLocationServiceImpl implements ITlInspectionLocationService 
-{
+public class TlInspectionLocationServiceImpl implements ITlInspectionLocationService {
     @Autowired
     private TlInspectionLocationMapper tlInspectionLocationMapper;
 
     /**
      * 查询巡检点管理
-     * 
+     *
      * @param id 巡检点管理主键
      * @return 巡检点管理
      */
     @Override
-    public TlInspectionLocation selectTlInspectionLocationById(Long id)
-    {
+    public TlInspectionLocation selectTlInspectionLocationById(Long id) {
         return tlInspectionLocationMapper.selectTlInspectionLocationById(id);
     }
 
     /**
      * 查询巡检点管理列表
-     * 
+     *
      * @param tlInspectionLocation 巡检点管理
      * @return 巡检点管理
      */
     @Override
-    public List<TlInspectionLocation> selectTlInspectionLocationList(TlInspectionLocation tlInspectionLocation)
-    {
+    public List<TlInspectionLocation> selectTlInspectionLocationList(TlInspectionLocation tlInspectionLocation) {
         return tlInspectionLocationMapper.selectTlInspectionLocationList(tlInspectionLocation);
     }
 
     /**
      * 新增巡检点管理
-     * 
+     *
      * @param tlInspectionLocation 巡检点管理
      * @return 结果
      */
     @Override
-    public int insertTlInspectionLocation(TlInspectionLocation tlInspectionLocation)
-    {
+    public int insertTlInspectionLocation(TlInspectionLocation tlInspectionLocation) {
         tlInspectionLocation.setCreateTime(DateUtils.getNowDate());
         // 控制编号和名称不能重复
-        int count = tlInspectionLocationMapper.selectExist(tlInspectionLocation);
+        /*int count = tlInspectionLocationMapper.selectExist(tlInspectionLocation);
         if (count > 0) {
             throw new ServiceException("编号或名称已存在,请更换");
-        }
+        }*/
         return tlInspectionLocationMapper.insertTlInspectionLocation(tlInspectionLocation);
     }
 
     /**
      * 修改巡检点管理
-     * 
+     *
      * @param tlInspectionLocation 巡检点管理
      * @return 结果
      */
     @Override
-    public int updateTlInspectionLocation(TlInspectionLocation tlInspectionLocation)
-    {
+    public int updateTlInspectionLocation(TlInspectionLocation tlInspectionLocation) {
         tlInspectionLocation.setUpdateTime(DateUtils.getNowDate());
         // 查询原有的数据
-        TlInspectionLocation old = selectTlInspectionLocationById(tlInspectionLocation.getId());
+        /*TlInspectionLocation old = selectTlInspectionLocationById(tlInspectionLocation.getId());
         if (old != null) {
             if (!old.getLocationCode().equals(tlInspectionLocation.getLocationCode())) {
                 // 校验是否重复
@@ -98,31 +92,29 @@ public class TlInspectionLocationServiceImpl implements ITlInspectionLocationSer
                     throw new ServiceException("名称已存在,请更换");
                 }
             }
-        }
+        }*/
         return tlInspectionLocationMapper.updateTlInspectionLocation(tlInspectionLocation);
     }
 
     /**
      * 批量删除巡检点管理
-     * 
+     *
      * @param ids 需要删除的巡检点管理主键
      * @return 结果
      */
     @Override
-    public int deleteTlInspectionLocationByIds(Long[] ids)
-    {
+    public int deleteTlInspectionLocationByIds(Long[] ids) {
         return tlInspectionLocationMapper.deleteTlInspectionLocationByIds(ids);
     }
 
     /**
      * 删除巡检点管理信息
-     * 
+     *
      * @param id 巡检点管理主键
      * @return 结果
      */
     @Override
-    public int deleteTlInspectionLocationById(Long id)
-    {
+    public int deleteTlInspectionLocationById(Long id) {
         return tlInspectionLocationMapper.deleteTlInspectionLocationById(id);
     }
 
@@ -136,4 +128,24 @@ public class TlInspectionLocationServiceImpl implements ITlInspectionLocationSer
     public List<TlInspectionLocation> queryLocationByLineIds(List<Long> idCollect) {
         return tlInspectionLocationMapper.queryLocationByLineIds(idCollect);
     }
+
+    @Override
+    public List<TlInspectionLocation> selectLocationList() {
+        return tlInspectionLocationMapper.selectLocationList();
+    }
+
+    @Override
+    public TlInspectionLocation queryByThirdId(String thirdId) {
+        return tlInspectionLocationMapper.queryByThirdId(thirdId);
+    }
+
+    @Override
+    public int queryMaxVsersion() {
+        return tlInspectionLocationMapper.queryMaxVsersion();
+    }
+
+    @Override
+    public void deleteLocationByVersion(int version) {
+        tlInspectionLocationMapper.deleteLocationByVersion(version);
+    }
 }

+ 53 - 30
ruoyi-system/src/main/resources/mapper/qdtl/TlAreaMapper.xml

@@ -1,41 +1,55 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper
-PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.ruoyi.qdtl.mapper.TlAreaMapper">
-    
+
     <resultMap type="TlArea" id="TlAreaResult">
-        <result property="id"    column="id"    />
-        <result property="parentId"    column="parent_id"    />
-        <result property="areaCode"    column="area_code"    />
-        <result property="areaName"    column="area_name"    />
-        <result property="areaType"    column="area_type"    />
-        <result property="detail"    column="detail"    />
-        <result property="remark"    column="remark"    />
-        <result property="fence"    column="fence"    />
-        <result property="lnglat"    column="lnglat"    />
-        <result property="delFlag"    column="del_flag"    />
-        <result property="createBy"    column="create_by"    />
-        <result property="createTime"    column="create_time"    />
-        <result property="updateBy"    column="update_by"    />
-        <result property="updateTime"    column="update_time"    />
+        <result property="id" column="id"/>
+        <result property="parentId" column="parent_id"/>
+        <result property="areaCode" column="area_code"/>
+        <result property="areaName" column="area_name"/>
+        <result property="areaType" column="area_type"/>
+        <result property="detail" column="detail"/>
+        <result property="remark" column="remark"/>
+        <result property="fence" column="fence"/>
+        <result property="lnglat" column="lnglat"/>
+        <result property="delFlag" column="del_flag"/>
+        <result property="createBy" column="create_by"/>
+        <result property="createTime" column="create_time"/>
+        <result property="updateBy" column="update_by"/>
+        <result property="updateTime" column="update_time"/>
     </resultMap>
 
     <sql id="selectTlAreaVo">
-        select id, parent_id, area_code, area_name, area_type, detail, remark, fence, lnglat, del_flag, create_by, create_time, update_by, update_time from tl_area
+        select id,
+               parent_id,
+               area_code,
+               area_name,
+               area_type,
+               detail,
+               remark,
+               fence,
+               lnglat,
+               del_flag,
+               create_by,
+               create_time,
+               update_by,
+               update_time
+        from tl_area
     </sql>
 
     <select id="selectTlAreaList" parameterType="TlArea" resultMap="TlAreaResult">
         <include refid="selectTlAreaVo"/>
-        <where>  
-            <if test="areaCode != null  and areaCode != ''"> and area_code like concat('%', #{areaCode}, '%')</if>
-            <if test="areaName != null  and areaName != ''"> and area_name like concat('%', #{areaName}, '%')</if>
-            <if test="areaType != null  and areaType != ''"> and area_type = #{areaType}</if>
-             and del_flag = '0'
+        <where>
+            <if test="areaCode != null  and areaCode != ''">and area_code like concat('%', #{areaCode}, '%')</if>
+            <if test="areaName != null  and areaName != ''">and area_name like concat('%', #{areaName}, '%')</if>
+            <if test="areaType != null  and areaType != ''">and area_type = #{areaType}</if>
+            and del_flag = '0'
         </where>
         order by create_time desc
     </select>
-    
+
     <select id="selectTlAreaById" parameterType="Long" resultMap="TlAreaResult">
         <include refid="selectTlAreaVo"/>
         where id = #{id}
@@ -43,10 +57,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </select>
 
     <select id="selectExist" resultType="java.lang.Integer">
-        select count(1) from tl_area
+        select count(1)
+        from tl_area
         where (area_code = #{areaCode}
             or area_name = #{areaName})
-            and del_flag = '0'
+          and del_flag = '0'
+    </select>
+
+    <select id="selectAreaList" resultMap="TlAreaResult">
+        <include refid="selectTlAreaVo"/>
+        where fence != ''
+        and del_flag = '0'
     </select>
 
     <insert id="insertTlArea" parameterType="TlArea" useGeneratedKeys="true" keyProperty="id">
@@ -65,7 +86,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="createTime != null">create_time,</if>
             <if test="updateBy != null">update_by,</if>
             <if test="updateTime != null">update_time,</if>
-         </trim>
+        </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="parentId != null">#{parentId},</if>
             <if test="areaCode != null and areaCode != ''">#{areaCode},</if>
@@ -80,7 +101,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="createTime != null">#{createTime},</if>
             <if test="updateBy != null">#{updateBy},</if>
             <if test="updateTime != null">#{updateTime},</if>
-         </trim>
+        </trim>
     </insert>
 
     <update id="updateTlArea" parameterType="TlArea">
@@ -104,11 +125,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </update>
 
     <delete id="deleteTlAreaById" parameterType="Long">
-        delete from tl_area where id = #{id}
+        delete
+        from tl_area
+        where id = #{id}
     </delete>
 
     <delete id="deleteTlAreaByIds" parameterType="String">
-        delete from tl_area where id in 
+        delete from tl_area where id in
         <foreach item="id" collection="array" open="(" separator="," close=")">
             #{id}
         </foreach>

+ 46 - 30
ruoyi-system/src/main/resources/mapper/qdtl/TlInspectionDeviceMapper.xml

@@ -1,41 +1,54 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper
-PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.ruoyi.qdtl.mapper.TlInspectionDeviceMapper">
-    
+
     <resultMap type="TlInspectionDevice" id="TlInspectionDeviceResult">
-        <result property="id"    column="id"    />
-        <result property="deviceCode"    column="device_code"    />
-        <result property="deviceName"    column="device_name"    />
-        <result property="deviceType"    column="device_type"    />
-        <result property="lnglat"    column="lnglat"    />
-        <result property="areaId"    column="area_id"    />
-        <result property="remark"    column="remark"    />
-        <result property="delFlag"    column="del_flag"    />
-        <result property="createBy"    column="create_by"    />
-        <result property="createTime"    column="create_time"    />
-        <result property="updateBy"    column="update_by"    />
-        <result property="updateTime"    column="update_time"    />
-        <result property="thirdId"    column="third_id"    />
+        <result property="id" column="id"/>
+        <result property="deviceCode" column="device_code"/>
+        <result property="deviceName" column="device_name"/>
+        <result property="deviceType" column="device_type"/>
+        <result property="lnglat" column="lnglat"/>
+        <result property="areaId" column="area_id"/>
+        <result property="remark" column="remark"/>
+        <result property="delFlag" column="del_flag"/>
+        <result property="createBy" column="create_by"/>
+        <result property="createTime" column="create_time"/>
+        <result property="updateBy" column="update_by"/>
+        <result property="updateTime" column="update_time"/>
+        <result property="thirdId" column="third_id"/>
     </resultMap>
 
     <sql id="selectTlInspectionDeviceVo">
-        select id, device_code, device_name, device_type, lnglat, area_id, remark, del_flag, create_by, create_time, update_by, update_time, third_id from tl_inspection_device
+        select id,
+               device_code,
+               device_name,
+               device_type,
+               lnglat,
+               area_id,
+               remark,
+               del_flag,
+               create_by,
+               create_time,
+               update_by,
+               update_time,
+               third_id
+        from tl_inspection_device
     </sql>
 
     <select id="selectTlInspectionDeviceList" parameterType="TlInspectionDevice" resultMap="TlInspectionDeviceResult">
         <include refid="selectTlInspectionDeviceVo"/>
-        <where>  
-            <if test="deviceCode != null  and deviceCode != ''"> and device_code like concat('%', #{deviceCode}, '%')</if>
-            <if test="deviceName != null  and deviceName != ''"> and device_name like concat('%', #{deviceName}, '%')</if>
-            <if test="deviceType != null  and deviceType != ''"> and device_type = #{deviceType}</if>
-            <if test="areaId != null "> and area_id = #{areaId}</if>
-             and del_flag = '0'
+        <where>
+            <if test="deviceCode != null  and deviceCode != ''">and device_code like concat('%', #{deviceCode}, '%')</if>
+            <if test="deviceName != null  and deviceName != ''">and device_name like concat('%', #{deviceName}, '%')</if>
+            <if test="deviceType != null  and deviceType != ''">and device_type = #{deviceType}</if>
+            <if test="areaId != null ">and area_id = #{areaId}</if>
+            and del_flag = '0'
         </where>
         order by create_time desc
     </select>
-    
+
     <select id="selectTlInspectionDeviceById" parameterType="Long" resultMap="TlInspectionDeviceResult">
         <include refid="selectTlInspectionDeviceVo"/>
         where id = #{id}
@@ -43,7 +56,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </select>
 
     <select id="selectExist" resultType="java.lang.Integer">
-        select count(1) from tl_inspection_device
+        select count(1)
+        from tl_inspection_device
         where (device_code = #{deviceCode}
             or device_name = #{deviceName})
           and del_flag = '0'
@@ -56,7 +70,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         group by area_id
     </select>
 
-    <select id="queryByThirdId" resultType="com.ruoyi.qdtl.domain.TlInspectionDevice">
+    <select id="queryByThirdId" resultMap="TlInspectionDeviceResult">
         <include refid="selectTlInspectionDeviceVo"/>
         where third_id = #{thirdId}
         and del_flag = '0'
@@ -77,7 +91,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="updateBy != null">update_by,</if>
             <if test="updateTime != null">update_time,</if>
             <if test="thirdId != null">third_id,</if>
-         </trim>
+        </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="deviceCode != null and deviceCode != ''">#{deviceCode},</if>
             <if test="deviceName != null and deviceName != ''">#{deviceName},</if>
@@ -91,7 +105,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="updateBy != null">#{updateBy},</if>
             <if test="updateTime != null">#{updateTime},</if>
             <if test="thirdId != null">#{thirdId},</if>
-         </trim>
+        </trim>
     </insert>
 
     <update id="updateTlInspectionDevice" parameterType="TlInspectionDevice">
@@ -114,11 +128,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </update>
 
     <delete id="deleteTlInspectionDeviceById" parameterType="Long">
-        delete from tl_inspection_device where id = #{id}
+        delete
+        from tl_inspection_device
+        where id = #{id}
     </delete>
 
     <delete id="deleteTlInspectionDeviceByIds" parameterType="String">
-        delete from tl_inspection_device where id in 
+        delete from tl_inspection_device where id in
         <foreach item="id" collection="array" open="(" separator="," close=")">
             #{id}
         </foreach>

+ 80 - 38
ruoyi-system/src/main/resources/mapper/qdtl/TlInspectionLocationMapper.xml

@@ -1,46 +1,64 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper
-PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.ruoyi.qdtl.mapper.TlInspectionLocationMapper">
-    
+
     <resultMap type="TlInspectionLocation" id="TlInspectionLocationResult">
-        <result property="id"    column="id"    />
-        <result property="locationCode"    column="location_code"    />
-        <result property="locationName"    column="location_name"    />
-        <result property="detail"    column="detail"    />
-        <result property="deviceIds"    column="device_ids"    />
-        <result property="areaId"    column="area_id"    />
-        <result property="lnglat"    column="lnglat"    />
-        <result property="remark"    column="remark"    />
-        <result property="delFlag"    column="del_flag"    />
-        <result property="createBy"    column="create_by"    />
-        <result property="createTime"    column="create_time"    />
-        <result property="updateBy"    column="update_by"    />
-        <result property="updateTime"    column="update_time"    />
+        <result property="id" column="id"/>
+        <result property="locationCode" column="location_code"/>
+        <result property="locationName" column="location_name"/>
+        <result property="detail" column="detail"/>
+        <result property="deviceIds" column="device_ids"/>
+        <result property="areaId" column="area_id"/>
+        <result property="lnglat" column="lnglat"/>
+        <result property="version" column="version"/>
+        <result property="thirdId" column="third_id"/>
+        <result property="remark" column="remark"/>
+        <result property="delFlag" column="del_flag"/>
+        <result property="createBy" column="create_by"/>
+        <result property="createTime" column="create_time"/>
+        <result property="updateBy" column="update_by"/>
+        <result property="updateTime" column="update_time"/>
     </resultMap>
 
     <sql id="selectTlInspectionLocationVo">
-        select id, location_code, location_name, detail, device_ids, area_id, lnglat, remark, del_flag, create_by, create_time, update_by, update_time from tl_inspection_location
+        select id,
+               location_code,
+               location_name,
+               detail,
+               device_ids,
+               area_id,
+               lnglat,
+               remark,
+               del_flag,
+               version,
+               third_id,
+               create_by,
+               create_time,
+               update_by,
+               update_time
+        from tl_inspection_location
     </sql>
 
     <select id="selectTlInspectionLocationList" parameterType="TlInspectionLocation" resultMap="TlInspectionLocationResult">
         <include refid="selectTlInspectionLocationVo"/>
-        <where>  
-            <if test="locationCode != null  and locationCode != ''"> and location_code like concat('%', #{locationCode}, '%')</if>
-            <if test="locationName != null  and locationName != ''"> and location_name like concat('%', #{locationName}, '%')</if>
-            <if test="areaId != null "> and area_id = #{areaId}</if>
+        <where>
+            <if test="locationCode != null  and locationCode != ''">and location_code like concat('%', #{locationCode}, '%')</if>
+            <if test="locationName != null  and locationName != ''">and location_name like concat('%', #{locationName}, '%')</if>
+            <if test="areaId != null ">and area_id = #{areaId}</if>
         </where>
         order by create_time desc
     </select>
-    
+
     <select id="selectTlInspectionLocationById" parameterType="Long" resultMap="TlInspectionLocationResult">
         <include refid="selectTlInspectionLocationVo"/>
         where id = #{id}
     </select>
 
     <select id="selectExist" resultType="java.lang.Integer">
-        select count(1) from tl_inspection_location
+        select count(1)
+        from tl_inspection_location
         where (location_code = #{locationCode}
             or location_name = #{locationName})
           and del_flag = '0'
@@ -55,25 +73,41 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="queryLocationByLineIds" resultType="com.ruoyi.qdtl.domain.TlInspectionLocation">
         select t2.id,
-               location_code locationCode,
-               location_name locationName,
-               detail,
-               device_ids deviceIds,
-               area_id areaId,
-               lnglat,
-               remark,
-               t1.sort_no sortNo,
-               t1.line_id lineId
+        location_code locationCode,
+        location_name locationName,
+        detail,
+        device_ids deviceIds,
+        area_id areaId,
+        lnglat,
+        remark,
+        t1.sort_no sortNo,
+        t1.line_id lineId
         from tl_inspection_line_location t1
-                 left join tl_inspection_location t2 on t1.location_id = t2.id
+        left join tl_inspection_location t2 on t1.location_id = t2.id
         where del_flag = 0
-          and t1.line_id in
+        and t1.line_id in
         <foreach collection="list" item="item" open="(" separator="," close=")">
             #{item}
         </foreach>
         order by t1.sort_no
     </select>
 
+    <select id="selectLocationList" resultMap="TlInspectionLocationResult">
+        <include refid="selectTlInspectionLocationVo"/>
+        where lnglat != '' and del_flag = 0
+    </select>
+
+    <select id="queryByThirdId" resultMap="TlInspectionLocationResult">
+        <include refid="selectTlInspectionLocationVo"/>
+        where third_id = #{thirdId}
+        and del_flag = '0'
+    </select>
+
+    <select id="queryMaxVsersion" resultType="java.lang.Integer">
+        select ifnull(max(version), 0)
+        from tl_inspection_location
+    </select>
+
     <insert id="insertTlInspectionLocation" parameterType="TlInspectionLocation" useGeneratedKeys="true" keyProperty="id">
         insert into tl_inspection_location
         <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -89,7 +123,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="createTime != null">create_time,</if>
             <if test="updateBy != null">update_by,</if>
             <if test="updateTime != null">update_time,</if>
-         </trim>
+        </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="locationCode != null">#{locationCode},</if>
             <if test="locationName != null">#{locationName},</if>
@@ -103,7 +137,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="createTime != null">#{createTime},</if>
             <if test="updateBy != null">#{updateBy},</if>
             <if test="updateTime != null">#{updateTime},</if>
-         </trim>
+        </trim>
     </insert>
 
     <update id="updateTlInspectionLocation" parameterType="TlInspectionLocation">
@@ -126,13 +160,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </update>
 
     <delete id="deleteTlInspectionLocationById" parameterType="Long">
-        delete from tl_inspection_location where id = #{id}
+        delete
+        from tl_inspection_location
+        where id = #{id}
     </delete>
 
     <delete id="deleteTlInspectionLocationByIds" parameterType="String">
-        delete from tl_inspection_location where id in 
+        delete from tl_inspection_location where id in
         <foreach item="id" collection="array" open="(" separator="," close=")">
             #{id}
         </foreach>
     </delete>
+
+    <delete id="deleteLocationByVersion">
+        update tl_inspection_location
+        set del_flag = '2'
+        where version != #{version}
+    </delete>
 </mapper>

Різницю між файлами не показано, бо вона завелика
+ 541 - 331
sql/ry_20210908.sql


Деякі файли не було показано, через те що забагато файлів було змінено