Browse Source

feat(设备监听及鉴权模块): 新增功能

gjs 3 years ago
parent
commit
cf08f7e227
29 changed files with 864 additions and 339 deletions
  1. 0 8
      Dockerfile
  2. 85 84
      pom.xml
  3. 11 2
      src/main/java/com/macro/mall/tiny/common/config/BaseRedisConfig.java
  4. 61 0
      src/main/java/com/macro/mall/tiny/common/util/EprdmsHttpUtils.java
  5. 53 0
      src/main/java/com/macro/mall/tiny/common/util/SpringUtils.java
  6. 3 0
      src/main/java/com/macro/mall/tiny/config/RestTemplateConfig.java
  7. 1 1
      src/main/java/com/macro/mall/tiny/config/WebConfig.java
  8. 14 0
      src/main/java/com/macro/mall/tiny/config/WebSocketConfig.java
  9. 1 5
      src/main/java/com/macro/mall/tiny/modules/business/controller/FileController.java
  10. 26 4
      src/main/java/com/macro/mall/tiny/modules/business/controller/KrBSensorController.java
  11. 194 0
      src/main/java/com/macro/mall/tiny/modules/business/controller/WebSocketServer.java
  12. 25 0
      src/main/java/com/macro/mall/tiny/modules/business/dto/SensorListenParam.java
  13. 7 4
      src/main/java/com/macro/mall/tiny/modules/business/model/KrBSensor.java
  14. 65 0
      src/main/java/com/macro/mall/tiny/modules/business/model/SensorDataVo.java
  15. 6 0
      src/main/java/com/macro/mall/tiny/modules/business/service/KrBSensorService.java
  16. 64 0
      src/main/java/com/macro/mall/tiny/modules/business/service/RedisSubscribeListener.java
  17. 82 0
      src/main/java/com/macro/mall/tiny/modules/business/service/impl/KrBSensorServiceImpl.java
  18. 2 2
      src/main/java/com/macro/mall/tiny/security/util/ShiroAuthUtil.java
  19. 16 0
      src/main/resources/config/application-dev.yml
  20. 19 0
      src/main/resources/config/application-prod.yml
  21. 29 0
      src/main/resources/config/application-test.yml
  22. 81 0
      src/main/resources/config/application.yml
  23. 19 0
      src/main/resources/config/bootstrap.yml
  24. 0 15
      src/main/resources/mapper/ums/UmsAdminLoginLogMapper.xml
  25. 0 67
      src/main/resources/mapper/ums/UmsAdminMapper.xml
  26. 0 61
      src/main/resources/mapper/ums/UmsMenuMapper.xml
  27. 0 53
      src/main/resources/mapper/ums/UmsResourceMapper.xml
  28. 0 22
      src/main/resources/mapper/ums/UmsRoleMapper.xml
  29. 0 11
      src/main/resources/mapper/ums/UmsRoleResourceRelationMapper.xml

+ 0 - 8
Dockerfile

@@ -1,8 +0,0 @@
-FROM java:8
-EXPOSE 8080
-ARG JAR_FILE
-ADD target/${JAR_FILE} /file-collect.jar
-ADD target/lib /lib
-ADD src/main/resources/bootstrap.yml /bootstrap.yml
-
-ENTRYPOINT ["java", "-jar","/file-collect.jar"]

+ 85 - 84
pom.xml

@@ -25,6 +25,10 @@
         <jjwt.version>0.9.0</jjwt.version>
         <mybatis-plus.version>3.3.2</mybatis-plus.version>
         <velocity.version>2.2</velocity.version>
+        <!-- 独立打包存放的库文件路径 -->
+        <module.auth.library.path>./docker-compose/devops/lib</module.auth.library.path>
+        <module.auth.jar.output.path>./docker-compose/devops/dockerfile/file_collect</module.auth.jar.output.path>
+        <docker.container.externel.lib.path>lib/</docker.container.externel.lib.path>
     </properties>
 
     <parent>
@@ -179,128 +183,125 @@
             <artifactId>eprdms_auth_client</artifactId>
             <version>V100R001C00B020</version>
         </dependency>
+
+        <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-websocket -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-websocket</artifactId>
+            <version>2.6.2</version>
+        </dependency>
+
     </dependencies>
 
     <build>
         <plugins>
-            <!-- 基于maven-jar-plugin插件实现把依赖jar定义写入输出jar的META-INFO/MANIFEST文件 -->
+            <!-- 打包配置 -->
             <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-jar-plugin</artifactId>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <version>${spring-boot.version}</version>
+                <executions>
+                    <execution>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>repackage</goal>
+                        </goals>
+                    </execution>
+                </executions>
                 <configuration>
-                    <archive>
-                        <manifest>
-                            <addClasspath>true</addClasspath>
-                            <classpathPrefix>lib/</classpathPrefix>
-                            <useUniqueVersions>false</useUniqueVersions>
-                        </manifest>
-                    </archive>
+                    <fork>true</fork>
+                    <layout>ZIP</layout>
+                    <!-- 不包含任何jar包依赖 -->
+                    <includes>
+                        <include>
+                            <groupId>null</groupId>
+                            <artifactId>null</artifactId>
+                        </include>
+                    </includes>
+                    <outputDirectory>${module.auth.jar.output.path}</outputDirectory>
+                    <mainClass>com.macro.mall.tiny.PowerSystemApplication</mainClass>
                 </configuration>
             </plugin>
-            <!-- 拷贝项目所有依赖jar文件到构建lib目录下 -->
+
+            <!-- 拷贝jar包配置 -->
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-dependency-plugin</artifactId>
                 <executions>
                     <execution>
-                        <id>copy-dependencies</id>
+                        <id>copy-lib</id>
                         <phase>package</phase>
                         <goals>
                             <goal>copy-dependencies</goal>
                         </goals>
                         <configuration>
-                            <!--
-                            各子模块按照实际层级定义各模块对应的属性值,检查所有微服务模块依赖jar文件合并复制到同一个目录
-                            详见各子模块中 boot-jar-output 属性定义
-                            -->
-                            <outputDirectory>${project.build.directory}/lib</outputDirectory>
                             <excludeTransitive>false</excludeTransitive>
                             <stripVersion>false</stripVersion>
                             <silent>false</silent>
                         </configuration>
                     </execution>
                 </executions>
+                <configuration>
+                    <outputDirectory>${module.auth.library.path}</outputDirectory>
+                </configuration>
             </plugin>
-            <!-- Spring Boot模块jar构建 -->
+
+            <!-- 基于maven-jar-plugin插件实现把依赖jar定义写入输出jar的META-INFO/MANIFEST文件 -->
             <plugin>
-                <groupId>org.springframework.boot</groupId>
-                <artifactId>spring-boot-maven-plugin</artifactId>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jar-plugin</artifactId>
+                <version>3.2.0</version>
                 <configuration>
-                    <includes>
-                        <!-- 不存在的include引用,相当于排除所有maven依赖jar,没有任何三方jar文件打入输出jar -->
-                        <include>
-                            <groupId>null</groupId>
-                            <artifactId>null</artifactId>
-                        </include>
-                    </includes>
-                    <layout>ZIP</layout>
-                    <!--
-                    基于maven-jar-plugin输出微服务jar文件进行二次spring boot重新打包文件的输出目录
-                    所有微服务构建输出jar文件统一输出到与lib同一个目录,便于共同引用同一个lib目录
-                    详见各子模块中boot-jar-output属性定义
-                    -->
-                    <!--  -->
-                    <outputDirectory>${project.build.directory}</outputDirectory>
+                    <archive>
+                        <manifest>
+                            <addClasspath>true</addClasspath>
+                            <classpathPrefix>${docker.container.externel.lib.path}</classpathPrefix>
+                            <useUniqueVersions>false</useUniqueVersions>
+                        </manifest>
+                    </archive>
                 </configuration>
-                <executions>
-                    <execution>
-                        <goals>
-                            <goal>repackage</goal>
-                        </goals>
-                    </execution>
-                </executions>
             </plugin>
 
-
+            <!-- 拷贝项目所有依赖jar文件到构建lib目录下 -->
             <plugin>
-                <groupId>com.spotify</groupId>
-                <artifactId>dockerfile-maven-plugin</artifactId>
-                <version>1.4.13</version>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-resources-plugin</artifactId>
+                <version>2.7</version>
+                <dependencies>
+                    <dependency>
+                        <groupId>org.apache.maven.shared</groupId>
+                        <artifactId>maven-filtering</artifactId>
+                        <version>1.3</version>
+                    </dependency>
+                </dependencies>
                 <executions>
                     <execution>
-                        <id>default</id>
+                        <id>copy-resource</id>
+                        <phase>package</phase>
                         <goals>
-                            <goal>build</goal>
-                            <goal>push</goal>
+                            <goal>copy-resources</goal>
                         </goals>
+                        <configuration>
+                            <outputDirectory>${module.auth.jar.output.path}</outputDirectory>
+                            <resources>
+                                <resource>
+                                    <directory>src/main/resources</directory>
+<!--                                    <includes>-->
+<!--                                        <exclude>**/*.yml</exclude>-->
+<!--                                        <exclude>**/*.properties</exclude>-->
+<!--                                    </includes>-->
+                                    <excludes>
+                                        <exclude>generator.properties</exclude>
+                                    </excludes>
+                                    <filtering>true</filtering>
+                                </resource>
+                            </resources>
+                            <encoding>UTF-8</encoding>
+                        </configuration>
                     </execution>
                 </executions>
-                <configuration>
-                    <repository>${docker.image.prefix}/${project.artifactId}</repository>
-                    <tag>${project.version}</tag>
-                    <buildArgs>
-                        <JAR_FILE>${project.build.finalName}.jar</JAR_FILE>
-                    </buildArgs>
-                </configuration>
             </plugin>
-            <!--            <plugin>-->
-            <!--                <groupId>com.spotify</groupId>-->
-            <!--                <artifactId>docker-maven-plugin</artifactId>-->
-            <!--                <version>${docker.maven.plugin.version}</version>-->
-            <!--                <executions>-->
-            <!--                    <execution>-->
-            <!--                        <id>build-image</id>-->
-            <!--                        <phase>package</phase>-->
-            <!--                        <goals>-->
-            <!--                            <goal>build</goal>-->
-            <!--                        </goals>-->
-            <!--                    </execution>-->
-            <!--                </executions>-->
-            <!--                <configuration>-->
-            <!--                    <imageName>file-collect/${project.artifactId}:${project.version}</imageName>-->
-            <!--                    <dockerHost>${docker.host}</dockerHost>-->
-            <!--                    <baseImage>java:8</baseImage>-->
-            <!--                    <entryPoint>["java", "-jar","/${project.build.finalName}.jar"]-->
-            <!--                    </entryPoint>-->
-            <!--                    <resources>-->
-            <!--                        <resource>-->
-            <!--                            <targetPath>/</targetPath>-->
-            <!--                            <directory>${project.build.directory}</directory>-->
-            <!--                            <include>${project.build.finalName}.jar</include>-->
-            <!--                        </resource>-->
-            <!--                    </resources>-->
-            <!--                </configuration>-->
-            <!--            </plugin>-->
+
         </plugins>
     </build>
 

+ 11 - 2
src/main/java/com/macro/mall/tiny/common/config/BaseRedisConfig.java

@@ -12,6 +12,7 @@ import org.springframework.data.redis.cache.RedisCacheManager;
 import org.springframework.data.redis.cache.RedisCacheWriter;
 import org.springframework.data.redis.connection.RedisConnectionFactory;
 import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.listener.RedisMessageListenerContainer;
 import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
 import org.springframework.data.redis.serializer.RedisSerializationContext;
 import org.springframework.data.redis.serializer.RedisSerializer;
@@ -45,7 +46,7 @@ public class BaseRedisConfig {
         ObjectMapper objectMapper = new ObjectMapper();
         objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
         //必须设置,否则无法将JSON转化为对象,会转化成Map类型
-        objectMapper.activateDefaultTyping(LaissezFaireSubTypeValidator.instance,ObjectMapper.DefaultTyping.NON_FINAL);
+        objectMapper.activateDefaultTyping(LaissezFaireSubTypeValidator.instance, ObjectMapper.DefaultTyping.NON_FINAL);
         serializer.setObjectMapper(objectMapper);
         return serializer;
     }
@@ -61,8 +62,16 @@ public class BaseRedisConfig {
 
 
     @Bean
-    public RedisService redisService(){
+    public RedisService redisService() {
         return new RedisServiceImpl();
     }
 
+    @Bean
+    RedisMessageListenerContainer container(RedisConnectionFactory connectionFactory) {
+        RedisMessageListenerContainer container = new RedisMessageListenerContainer();
+        container.setConnectionFactory(connectionFactory);
+//                监听的主题由服务器提供,资料汇编系统固定监听:COLLECT_DATA 通道,线上机器人后台系 统固定监听:EPRDMS 通道
+//        container.addMessageListener(new RedisSubscribeListener(), new PatternTopic("COLLECT_DATA"));
+        return container;
+    }
 }

+ 61 - 0
src/main/java/com/macro/mall/tiny/common/util/EprdmsHttpUtils.java

@@ -0,0 +1,61 @@
+package com.macro.mall.tiny.common.util;
+
+import cn.hutool.json.JSONObject;
+import com.alibaba.fastjson.JSON;
+import com.keystar.eprdms.core.result.ResponseResult;
+import com.keystar.eprdms.core.shiro.entity.UserPermissionEntity;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Component;
+import org.springframework.web.client.RestTemplate;
+
+import java.util.Map;
+
+/**
+ * @author gjs
+ * @description
+ * @date 2022/1/9 15:32
+ */
+@Component
+@Slf4j
+public class EprdmsHttpUtils {
+
+    private static RestTemplate restTemplate;
+
+    @Autowired
+    public void setRedis(RestTemplate restTemplate){
+        EprdmsHttpUtils.restTemplate = restTemplate;
+    }
+
+    public static <T> T getForEprdms(String requestUrl, Map<String, String> paramMap, Class<T> responseType) {
+        ResponseEntity<JSONObject> responseEntity = restTemplate.getForEntity(requestUrl, JSONObject.class, paramMap);
+        JSONObject entityBody = responseEntity.getBody();
+        if (entityBody != null && ResponseResult.SUCCESSFUL_CODE.equals(entityBody.get("code"))) {
+            return entityBody.get("data", responseType);
+        } else {
+            log.error("远程请求失败,requestUrl:{},paramMap:{}", requestUrl, paramMap.toString());
+            return null;
+        }
+    }
+
+    public static <T> T PostForEprdms(String requestUrl, JSONObject params, Class<T> responseType) {
+        HttpHeaders headers = new HttpHeaders();
+        MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
+        headers.setContentType(type);
+        headers.add("Accept", MediaType.APPLICATION_JSON.toString());
+
+        HttpEntity<String> formEntity = new HttpEntity<>(params.toString(), headers);
+        ResponseEntity<JSONObject> responseEntity = restTemplate.postForEntity(requestUrl, formEntity, JSONObject.class);
+        JSONObject entityBody = responseEntity.getBody();
+        if (entityBody != null && ResponseResult.SUCCESSFUL_CODE.equals(entityBody.get("code"))) {
+            return entityBody.get("data", responseType);
+        } else {
+            log.error("远程请求失败,requestUrl:{},params:{}", requestUrl, params.toString());
+            return null;
+        }
+    }
+}

+ 53 - 0
src/main/java/com/macro/mall/tiny/common/util/SpringUtils.java

@@ -0,0 +1,53 @@
+package com.macro.mall.tiny.common.util;
+
+import org.springframework.beans.BeansException;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+import org.springframework.stereotype.Component;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+import org.springframework.web.servlet.LocaleResolver;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.Locale;
+
+/**
+ * SpringUtils工具类获取bean
+ * Description: <br/>
+ * date: 2020/4/26 14:59<br/>
+ *
+ * @author lvxk<br />
+ * @since JDK 1.8
+ */
+@Component
+public class SpringUtils implements ApplicationContextAware {
+    private static ApplicationContext applicationContext;
+
+    @Override
+    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
+        this.applicationContext = applicationContext;
+    }
+
+    public static <T> T getBean(Class<T> tClass){
+        return applicationContext.getBean(tClass);
+    }
+
+    public static <T> T getBean(String name, Class<T> type) {
+        return applicationContext.getBean(name, type);
+    }
+
+    public static HttpServletRequest getCurrentReq() {
+        ServletRequestAttributes requestAttrs = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
+        if (requestAttrs == null) {
+            return null;
+        }
+        return requestAttrs.getRequest();
+    }
+
+    public static String getMessage(String code, Object... args) {
+        LocaleResolver localeResolver = getBean(LocaleResolver.class);
+        Locale locale = localeResolver.resolveLocale(getCurrentReq());
+        return applicationContext.getMessage(code, args, locale);
+    }
+
+}

+ 3 - 0
src/main/java/com/macro/mall/tiny/config/RestTemplateConfig.java

@@ -1,12 +1,15 @@
 package com.macro.mall.tiny.config;
 
+import cn.hutool.json.JSONObject;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.http.ResponseEntity;
 import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
 import org.springframework.http.converter.StringHttpMessageConverter;
 import org.springframework.web.client.RestTemplate;
 
 import java.nio.charset.StandardCharsets;
+import java.util.Map;
 
 /**
  * RestTemplate配置类

+ 1 - 1
src/main/java/com/macro/mall/tiny/common/config/WebConfig.java → src/main/java/com/macro/mall/tiny/config/WebConfig.java

@@ -1,4 +1,4 @@
-package com.macro.mall.tiny.common.config;
+package com.macro.mall.tiny.config;
 
 import com.macro.mall.tiny.modules.business.converter.EnumConvertFactory;
 import org.springframework.beans.factory.annotation.Autowired;

+ 14 - 0
src/main/java/com/macro/mall/tiny/config/WebSocketConfig.java

@@ -0,0 +1,14 @@
+package com.macro.mall.tiny.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.stereotype.Component;
+import org.springframework.web.socket.server.standard.ServerEndpointExporter;
+
+@Component
+public class WebSocketConfig {
+
+    @Bean
+    public ServerEndpointExporter serverEndpointExporter() {
+        return new ServerEndpointExporter();
+    }
+}

+ 1 - 5
src/main/java/com/macro/mall/tiny/modules/business/controller/FileController.java

@@ -216,11 +216,7 @@ public class FileController {
     @PostMapping("/delete")
     public CommonResult<String> delete(@RequestBody Map<String,String> params) throws IOException {
         boolean deleteFile = fileService.deleteFile(params.get("path"));
-        if (deleteFile) {
-            return CommonResult.success("删除成功");
-        } else {
-            return CommonResult.failed("删除失败");
-        }
+        return deleteFile ? CommonResult.success("删除成功") : CommonResult.failed("删除失败");
     }
 
 }

+ 26 - 4
src/main/java/com/macro/mall/tiny/modules/business/controller/KrBSensorController.java

@@ -9,11 +9,9 @@ import com.macro.mall.tiny.modules.business.service.KrBSensorService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
+import javax.websocket.server.PathParam;
 import java.util.List;
 
 /**
@@ -71,5 +69,29 @@ public class KrBSensorController {
         }
         return CommonResult.failed();
     }
+
+    @ApiOperation("按照线路ID查询传感器列表列表")
+    @RequestMapping(value = "/findByLineId", method = RequestMethod.GET)
+    @ResponseBody
+    public CommonResult<List<KrBSensor>> findSensorByLine(@RequestParam @PathParam(value = "lineId") Long lineId) {
+        List<KrBSensor> sensors = sensorService.findSensorByLine(lineId);
+        return CommonResult.success(sensors);
+    }
+
+//    @ApiOperation("按照线路ID开启传感器监听")
+//    @RequestMapping(value = "/openListenByLineId", method = RequestMethod.GET)
+//    @ResponseBody
+//    public CommonResult<String> openListenByLine(@RequestParam @PathParam(value = "lineId") Long lineId) {
+//        boolean result = sensorService.openListenByLine(lineId);
+//        return result ? CommonResult.success("开启监听成功") : CommonResult.failed("开启监听失败");
+//    }
+
+//    @ApiOperation("按照线路ID关闭传感器监听")
+//    @RequestMapping(value = "/closeListenByLineId", method = RequestMethod.GET)
+//    @ResponseBody
+//    public CommonResult<String> closeListenByLine(@RequestParam @PathParam(value = "lineId") Long lineId) {
+//        boolean result = sensorService.closeListenByLine(lineId);
+//        return result ? CommonResult.success("关闭监听成功") : CommonResult.failed("关闭监听失败");
+//    }
 }
 

+ 194 - 0
src/main/java/com/macro/mall/tiny/modules/business/controller/WebSocketServer.java

@@ -0,0 +1,194 @@
+package com.macro.mall.tiny.modules.business.controller;
+
+import cn.hutool.json.JSONArray;
+import cn.hutool.json.JSONObject;
+import cn.hutool.json.JSONUtil;
+import com.macro.mall.tiny.common.util.EprdmsHttpUtils;
+import com.macro.mall.tiny.common.util.SpringUtils;
+import com.macro.mall.tiny.modules.business.dto.SensorListenParam;
+import com.macro.mall.tiny.modules.business.service.RedisSubscribeListener;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.data.redis.listener.ChannelTopic;
+import org.springframework.data.redis.listener.RedisMessageListenerContainer;
+import org.springframework.stereotype.Component;
+
+import javax.websocket.*;
+import javax.websocket.server.ServerEndpoint;
+import java.io.IOException;
+import java.util.*;
+import java.util.concurrent.atomic.AtomicInteger;
+
+@Component
+@ServerEndpoint("/sensor/websocket")
+@Slf4j
+public class WebSocketServer {
+
+    /**
+     * 因为@ServerEndpoint不支持注入,所以使用SpringUtils获取IOC实例
+     */
+    private final RedisMessageListenerContainer redisMessageListenerContainer = SpringUtils.getBean(RedisMessageListenerContainer.class);
+
+    //静态变量,用来记录当前在线连接数。应该把它设计成线程安全的。
+    private static final AtomicInteger onlineCount = new AtomicInteger(0);
+
+    //concurrent包的线程安全Set,用来存放每个客户端对应的webSocket对象。若要实现服务端与单一客户端通信的话,可以使用Map来存放,其中Key可以为用户标识
+//    private static final CopyOnWriteArraySet<WebSocketServer> webSocketSet = new CopyOnWriteArraySet<>();
+
+    //与某个客户端的连接会话,需要通过它来给客户端发送数据
+    private Session session;
+
+    // 监听的设备列表
+    private HashSet<String> sensorMacSet;
+
+    private static Map<String, Integer> sensorMacCountMap;
+
+    private RedisSubscribeListener subscribeListener;
+
+    @Value("${keystar.eprdms.url:localhost:18060}")
+    private String eprdmsUrl;
+    private static final String OPEN_LISTEN_URL = "/eprdms/meteorology/sensor/start/listen";
+    private static final String CLOSE_LISTEN_URL = "/eprdms/meteorology/sensor/start/listen";
+
+    /**
+     * 连接建立成功调用的方法
+     *
+     * @param session 可选的参数。session为与某个客户端的连接会话,需要通过它来给客户端发送数据
+     */
+
+    @OnOpen
+    public void onOpen(Session session) {
+        this.session = session;
+        addOnlineCount();           //在线数加1
+        log.info("websocket有新连接加入!当前在线人数为" + getOnlineCount());
+        subscribeListener = new RedisSubscribeListener();
+        subscribeListener.setSession(session);
+        sensorMacSet = new HashSet<>();
+        subscribeListener.setSensorMacSet(sensorMacSet);
+        //设置订阅topic
+        redisMessageListenerContainer.addMessageListener(subscribeListener, new ChannelTopic("COLLECT_DATA"));
+    }
+
+    /**
+     * 连接关闭调用的方法
+     */
+    @OnClose
+    public void onClose() {
+        removeSensorMac();
+        subOnlineCount();           //在线数减1
+        redisMessageListenerContainer.removeMessageListener(subscribeListener);
+        log.info("websocket有一连接关闭!当前在线人数为" + getOnlineCount());
+    }
+
+
+    /**
+     * 收到客户端消息后调用的方法
+     *
+     * @param message 客户端发送过来的消息
+     * @param session 可选的参数
+     */
+    @OnMessage
+    public void onMessage(String message, Session session) {
+        log.debug("websocket来自客户端的消息:" + message);
+        if (!sensorMacSet.isEmpty()) {
+            removeSensorMac();
+        }
+        sensorMacSet.addAll(Arrays.asList(message.split(",")));
+        addSensorMac();
+    }
+
+
+    /**
+     * 发生错误时调用
+     *
+     * @param session
+     * @param error
+     */
+    @OnError
+    public void onError(Session session, Throwable error) {
+        log.error("websocket发生错误:", error);
+    }
+
+
+    /**
+     * 这个方法与上面几个方法不一样。没有用注解,是根据自己需要添加的方法。
+     *
+     * @param message
+     * @throws IOException
+     */
+    public void sendMessage(String message) throws IOException {
+        this.session.getBasicRemote().sendText(message);
+    }
+
+
+    public int getOnlineCount() {
+        return onlineCount.get();
+    }
+
+
+    public void addOnlineCount() {
+        WebSocketServer.onlineCount.getAndIncrement();
+    }
+
+
+    public void subOnlineCount() {
+        WebSocketServer.onlineCount.getAndDecrement();
+    }
+
+    private void addSensorMac() {
+        List<String> openMacList = new ArrayList<>();
+        sensorMacSet.forEach(sensorMac -> {
+            Integer count = sensorMacCountMap.getOrDefault(sensorMac, 0);
+            count++;
+            if (count == 1) {
+                openMacList.add(sensorMac);
+            }
+            sensorMacCountMap.put(sensorMac, count);
+        });
+        if (openMacList.isEmpty()) return;
+        SensorListenParam sensorListenParam = new SensorListenParam(openMacList);
+        JSONObject paramJsonObject = JSONUtil.parseObj(sensorListenParam);
+        JSONArray resultArray = EprdmsHttpUtils.PostForEprdms(eprdmsUrl + OPEN_LISTEN_URL, paramJsonObject, JSONArray.class);
+        if (resultArray == null) return;
+        StringBuilder logSb = new StringBuilder("开启监听:").append("\r\n");
+        resultArray.jsonIter().forEach(jsonObject -> {
+            logSb.append("deviceMac:")
+                    .append(jsonObject.getStr("deviceMac"))
+                    .append(",result:")
+                    .append(jsonObject.getStr("result"))
+                    .append("\r\n");
+        });
+        log.info(logSb.toString());
+    }
+
+    private void removeSensorMac() {
+        List<String> closeMacList = new ArrayList<>();
+        sensorMacSet.forEach(sensorMac -> {
+            Integer count = sensorMacCountMap.get(sensorMac);
+            if (count == null) return;
+            count--;
+            if (count < 1) {
+                sensorMacCountMap.remove(sensorMac);
+                closeMacList.add(sensorMac);
+            } else {
+                sensorMacCountMap.put(sensorMac, count);
+            }
+        });
+        if (closeMacList.isEmpty()) return;
+        SensorListenParam sensorListenParam = new SensorListenParam(closeMacList);
+        JSONObject paramJsonObject = JSONUtil.parseObj(sensorListenParam);
+        JSONArray resultArray = EprdmsHttpUtils.PostForEprdms(eprdmsUrl + CLOSE_LISTEN_URL, paramJsonObject, JSONArray.class);
+        if (resultArray == null) return;
+        StringBuilder logSb = new StringBuilder("关闭监听:").append("\r\n");
+        resultArray.jsonIter().forEach(jsonObject -> {
+            logSb.append("deviceMac:")
+                    .append(jsonObject.getStr("deviceMac"))
+                    .append(",result:")
+                    .append(jsonObject.getStr("result"))
+                    .append("\r\n");
+        });
+        log.info(logSb.toString());
+        sensorMacSet.clear();
+    }
+
+}

+ 25 - 0
src/main/java/com/macro/mall/tiny/modules/business/dto/SensorListenParam.java

@@ -0,0 +1,25 @@
+package com.macro.mall.tiny.modules.business.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.List;
+
+/**
+ * @author gjs
+ * @description
+ * @date 2022/1/9 14:57
+ */
+@Setter
+@Getter
+@AllArgsConstructor
+public class SensorListenParam {
+
+    @ApiModelProperty(value = "汇编系统识别码")
+    private final String client = "COLLECT_DATA";
+
+    @ApiModelProperty(value = "设备Mac列表")
+    private List<String> deviceMacs;
+}

+ 7 - 4
src/main/java/com/macro/mall/tiny/modules/business/model/KrBSensor.java

@@ -1,5 +1,6 @@
 package com.macro.mall.tiny.modules.business.model;
 
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.baomidou.mybatisplus.annotation.IdType;
 import java.util.Date;
@@ -14,7 +15,7 @@ import lombok.EqualsAndHashCode;
 
 /**
  * <p>
- * 
+ *
  * </p>
  *
  * @author macro
@@ -23,10 +24,10 @@ import lombok.EqualsAndHashCode;
 @Data
 @EqualsAndHashCode(callSuper = false)
 @TableName("kr_b_sensor")
-@ApiModel(value="KrBSensor对象", description="")
+@ApiModel(value = "KrBSensor对象", description = "")
 public class KrBSensor implements Serializable {
 
-    private static final long serialVersionUID=1L;
+    private static final long serialVersionUID = 1L;
 
     @ApiModelProperty(value = "传感器表")
     @TableId(value = "id", type = IdType.AUTO)
@@ -48,5 +49,7 @@ public class KrBSensor implements Serializable {
     @ApiModelProperty(value = "备注消息")
     private String remark;
 
-
+    @ApiModelProperty(value = "设备是否在线")
+    @TableField(exist = false)
+    private int isOnline;
 }

+ 65 - 0
src/main/java/com/macro/mall/tiny/modules/business/model/SensorDataVo.java

@@ -0,0 +1,65 @@
+package com.macro.mall.tiny.modules.business.model;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.io.Serializable;
+
+@ApiModel(value = "SensorDataVo对象", description = "传感器数据")
+public class SensorDataVo implements Serializable {
+      /**
+      * @ 2021-10-19 16:34
+      *    设备物理地址
+      **/
+      @ApiModelProperty(value = "设备物理地址")
+      private String deviceMac;
+
+      /**
+      * @ 2021-05-13 14:06
+      *    空气温度
+      **/
+      @ApiModelProperty(value = "空气温度")
+      private String temperature;
+
+      /**
+      * @ 2021-05-13 14:06
+      *    空气湿度
+      **/
+      @ApiModelProperty(value = "空气湿度")
+      private String humidity;
+
+      /**
+      * @ 2021-05-13 14:06
+      *    大气压强
+      **/
+      @ApiModelProperty(value = "大气压强")
+      private String pressure;
+
+      /**
+      * @ 2021-05-13 14:07
+      *    风速
+      **/
+      @ApiModelProperty(value = "风速")
+      private String windSpeed;
+
+      /**
+      * @ 2021-05-13 14:07
+      *    风向
+      **/
+      @ApiModelProperty(value = "风向")
+      private String windDirection;
+
+      /**
+      * @ 2021-05-13 14:07
+      *    10分钟雨量
+      **/
+      @ApiModelProperty(value = "10分钟雨量")
+      private String rainFall;
+
+      /**
+      * @ 2021-05-13 14:07
+      *    光照
+      **/
+      @ApiModelProperty(value = "光照")
+      private String light;
+}

+ 6 - 0
src/main/java/com/macro/mall/tiny/modules/business/service/KrBSensorService.java

@@ -16,4 +16,10 @@ import java.util.List;
 public interface KrBSensorService extends IService<KrBSensor> {
 
     List<KrBSensor> get(String lineName, String deviceMac);
+
+    List<KrBSensor> findSensorByLine(Long lineId);
+
+    boolean openListenByLine(Long lineId);
+
+    boolean closeListenByLine(Long lineId);
 }

+ 64 - 0
src/main/java/com/macro/mall/tiny/modules/business/service/RedisSubscribeListener.java

@@ -0,0 +1,64 @@
+package com.macro.mall.tiny.modules.business.service;
+
+import cn.hutool.json.JSONObject;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.data.redis.connection.Message;
+import org.springframework.data.redis.connection.MessageListener;
+import org.springframework.stereotype.Component;
+
+import javax.websocket.Session;
+import java.io.IOException;
+import java.util.Set;
+
+/**
+ * redis消息订阅监听者
+ */
+@Component
+@Slf4j
+public class RedisSubscribeListener implements MessageListener {
+
+
+    //webSocket客户端会话对象
+    private Session session;
+
+    private Set<String> sensorMacSet;
+
+    /**
+     * 接收发布者消息
+     *
+     * @param message
+     * @param bytes
+     */
+    @Override
+    public void onMessage(Message message, byte[] bytes) {
+        String msg = new String(message.getBody());
+        log.debug("[{}]主题发布:{}", new String(bytes), msg);
+        if (session != null && session.isOpen()) {
+            String deviceMac = new JSONObject(msg).getStr("deviceMac");
+            if (!sensorMacSet.contains(deviceMac)) {
+                return;
+            }
+            try {
+                session.getBasicRemote().sendText(msg);
+            } catch (IOException e) {
+                log.error("[redis监听器]发布消息异常:", e);
+            }
+        }
+    }
+
+    public Session getSession() {
+        return session;
+    }
+
+    public void setSession(Session session) {
+        this.session = session;
+    }
+
+    public Set<String> getSensorMacSet() {
+        return sensorMacSet;
+    }
+
+    public void setSensorMacSet(Set<String> sensorMacSet) {
+        this.sensorMacSet = sensorMacSet;
+    }
+}

+ 82 - 0
src/main/java/com/macro/mall/tiny/modules/business/service/impl/KrBSensorServiceImpl.java

@@ -1,9 +1,14 @@
 package com.macro.mall.tiny.modules.business.service.impl;
 
+import cn.hutool.json.JSONArray;
+import cn.hutool.json.JSONObject;
+import cn.hutool.json.JSONUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.google.common.collect.Lists;
+import com.macro.mall.tiny.common.util.EprdmsHttpUtils;
+import com.macro.mall.tiny.modules.business.dto.SensorListenParam;
 import com.macro.mall.tiny.modules.business.mapper.KrBLineMapper;
 import com.macro.mall.tiny.modules.business.mapper.KrBSensorMapper;
 import com.macro.mall.tiny.modules.business.mapper.KrBTowerMapper;
@@ -11,12 +16,17 @@ import com.macro.mall.tiny.modules.business.model.KrBLine;
 import com.macro.mall.tiny.modules.business.model.KrBSensor;
 import com.macro.mall.tiny.modules.business.model.KrBTower;
 import com.macro.mall.tiny.modules.business.service.KrBSensorService;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
+import org.springframework.web.client.RestTemplate;
 
 import java.util.List;
+import java.util.Map;
 import java.util.stream.Collectors;
+import java.util.stream.StreamSupport;
 
 /**
  * <p>
@@ -27,6 +37,7 @@ import java.util.stream.Collectors;
  * @since 2021-10-20
  */
 @Service
+@Slf4j
 public class KrBSensorServiceImpl extends ServiceImpl<KrBSensorMapper, KrBSensor> implements KrBSensorService {
 
     @Autowired
@@ -38,6 +49,16 @@ public class KrBSensorServiceImpl extends ServiceImpl<KrBSensorMapper, KrBSensor
     @Autowired
     private KrBTowerMapper towerMapper;
 
+    @Autowired
+    private RestTemplate restTemplate;
+
+    @Value("${keystar.eprdms.url:localhost:18060}")
+    private String eprdmsUrl;
+
+    private static final String CHECK_ONLINE_URL = "/eprdms/meteorology/sensor/check/online";
+    private static final String OPEN_LISTEN_URL = "/eprdms/meteorology/sensor/start/listen";
+    private static final String CLOSE_LISTEN_URL = "/eprdms/meteorology/sensor/start/listen";
+
     @Override
     public List<KrBSensor> get(String lineName, String deviceMac) {
         LambdaQueryWrapper<KrBSensor> sensorQueryWrapper;
@@ -59,4 +80,65 @@ public class KrBSensorServiceImpl extends ServiceImpl<KrBSensorMapper, KrBSensor
         return sensorList;
     }
 
+    @Override
+    public List<KrBSensor> findSensorByLine(Long lineId) {
+        List<KrBSensor> sensorList = findBaseSensorByLine(lineId);
+        List<String> sensorMacList = sensorList.stream().map(KrBSensor::getDeviceMac).filter(StringUtils::isNotBlank).collect(Collectors.toList());
+        SensorListenParam sensorListenParam = new SensorListenParam(sensorMacList);
+        JSONObject paramJsonObject = JSONUtil.parseObj(sensorListenParam);
+        JSONArray resultArray = EprdmsHttpUtils.PostForEprdms(eprdmsUrl + CHECK_ONLINE_URL, paramJsonObject, JSONArray.class);
+        if (resultArray==null) return sensorList;
+        Map<String, Boolean> onlineMap = StreamSupport.stream(resultArray.jsonIter().spliterator(), true).collect(Collectors.toMap(jsonObject -> jsonObject.getStr("deviceMac"), jsonObject -> jsonObject.getBool("isOnline")));
+        sensorList.forEach(sensor -> sensor.setIsOnline(onlineMap.getOrDefault(sensor.getDeviceMac(), false) ? 1 : 0));
+        return sensorList;
+    }
+
+    @Override
+    public boolean openListenByLine(Long lineId) {
+        List<KrBSensor> sensorList = findBaseSensorByLine(lineId);
+        List<String> sensorMacList = sensorList.stream().map(KrBSensor::getDeviceMac).filter(StringUtils::isNotBlank).collect(Collectors.toList());
+        SensorListenParam sensorListenParam = new SensorListenParam(sensorMacList);
+        JSONObject paramJsonObject = JSONUtil.parseObj(sensorListenParam);
+        JSONArray resultArray = EprdmsHttpUtils.PostForEprdms(eprdmsUrl + OPEN_LISTEN_URL, paramJsonObject, JSONArray.class);
+        if (resultArray==null) return false;
+        StringBuilder logSb = new StringBuilder("开启监听,lineId:").append(lineId).append("\r\n");
+        resultArray.jsonIter().forEach(jsonObject -> {
+            logSb.append("deviceMac:")
+                    .append(jsonObject.getStr("deviceMac"))
+                    .append(",result:")
+                    .append(jsonObject.getStr("result"))
+                    .append("\r\n");
+        });
+        log.info(logSb.toString());
+        return true;
+    }
+
+    @Override
+    public boolean closeListenByLine(Long lineId) {
+        List<KrBSensor> sensorList = findBaseSensorByLine(lineId);
+        List<String> sensorMacList = sensorList.stream().map(KrBSensor::getDeviceMac).filter(StringUtils::isNotBlank).collect(Collectors.toList());
+        SensorListenParam sensorListenParam = new SensorListenParam(sensorMacList);
+        JSONObject paramJsonObject = JSONUtil.parseObj(sensorListenParam);
+        JSONArray resultArray = EprdmsHttpUtils.PostForEprdms(eprdmsUrl + CLOSE_LISTEN_URL, paramJsonObject, JSONArray.class);
+        if (resultArray==null) return false;
+        StringBuilder logSb = new StringBuilder("关闭监听,lineId:").append(lineId).append("\r\n");
+        resultArray.jsonIter().forEach(jsonObject -> {
+            logSb.append("deviceMac:")
+                    .append(jsonObject.getStr("deviceMac"))
+                    .append(",result:")
+                    .append(jsonObject.getStr("result"))
+                    .append("\r\n");
+        });
+        log.info(logSb.toString());
+        return true;
+    }
+
+    private List<KrBSensor> findBaseSensorByLine(Long lineId) {
+        LambdaQueryWrapper<KrBTower> towerQueryWrapper = new QueryWrapper<KrBTower>().lambda().eq(KrBTower::getLineId, lineId);
+        List<KrBTower> towerList = towerMapper.selectList(towerQueryWrapper);
+        List<Long> towerIdList = towerList.stream().map(KrBTower::getId).collect(Collectors.toList());
+        LambdaQueryWrapper<KrBSensor> sensorQueryWrapper = new QueryWrapper<KrBSensor>().lambda().in(KrBSensor::getTowerId, towerIdList);
+        return sensorMap.selectList(sensorQueryWrapper);
+    }
+
 }

+ 2 - 2
src/main/java/com/macro/mall/tiny/security/util/ShiroAuthUtil.java

@@ -10,8 +10,8 @@ import org.apache.shiro.subject.Subject;
  */
 public class ShiroAuthUtil {
 
-    public static final String ACCESS = "fileCollect:accessKeyFile";
-    public static final String EDIT = "fileCollect:editKeyFile";
+    public static final String ACCESS = "handle:accessKeyFile";
+    public static final String EDIT = "handle:editKeyFile";
 
     public static boolean checkAccess(String permission) {
         return SecurityUtils.getSubject().isPermitted(permission);

+ 16 - 0
src/main/resources/config/application-dev.yml

@@ -0,0 +1,16 @@
+spring:
+  datasource:
+    url: jdbc:mysql://localhost:3306/file_collect?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
+    username: root
+    password: root
+  redis:
+    host: localhost # Redis服务器地址
+    database: 0 # Redis数据库索引(默认为0)
+    port: 6379 # Redis服务器连接端口
+    password: # Redis服务器连接密码(默认为空)
+    timeout: 3000ms # 连接超时时间(毫秒)
+
+logging:
+  level:
+    root: info
+    com.macro.mall: debug

+ 19 - 0
src/main/resources/config/application-prod.yml

@@ -0,0 +1,19 @@
+spring:
+  datasource:
+    url: jdbc:mysql://localhost:3306/file_collect?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
+    username: root
+    password: root
+  redis:
+    host: localhost # Redis服务器地址
+    database: 0 # Redis数据库索引(默认为0)
+    port: 6379 # Redis服务器连接端口
+    password: # Redis服务器连接密码(默认为空)
+    timeout: 3000ms # 连接超时时间(毫秒)
+
+logging:
+  file:
+    path: /var/logs
+    max-size: 1GB
+  level:
+    root: info
+    com.macro.mall: info

+ 29 - 0
src/main/resources/config/application-test.yml

@@ -0,0 +1,29 @@
+spring:
+  datasource:
+    url: jdbc:mysql://47.107.126.107:3396/eprdms_data?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
+    username: user01
+    password: test@1234
+  redis:
+    host: 47.107.126.107 # Redis服务器地址
+    database: 0 # Redis数据库索引(默认为0)
+    port: 16733 # Redis服务器连接端口
+    password: # Redis服务器连接密码(默认为空)
+    timeout: 3000ms # 连接超时时间(毫秒)
+
+logging:
+  level:
+    root: info
+    com.macro.mall: debug
+
+
+com:
+  keystar:
+  shiro:
+  jwt-encrypt: RG0xYUtaa2YyIzhAZ1U0OVlr
+  shiro-security-cache-info: 47.107.126.107:16733
+#  shiro-security-cache-password: keystar.Redis@107#
+  application-key: 398688e7-2ce0-4165-bb18-856bff2ca4b4
+  anon-urls:
+#    - /eprdms/meteorology/webSocket/openSensor
+#    - /eprdms/meteorology/restart/delete
+#    - /eprdms/meteorology/restart/get

+ 81 - 0
src/main/resources/config/application.yml

@@ -0,0 +1,81 @@
+server:
+  port: 8080
+
+spring:
+  application:
+    name: file-collect
+  profiles:
+    active: dev
+  servlet:
+    multipart:
+      max-file-size: 10737418240
+      max-request-size: 10737418240
+
+mybatis-plus:
+  mapper-locations: classpath:/mapper/**/*.xml
+  global-config:
+    db-config:
+      id-type: auto
+  configuration:
+    auto-mapping-behavior: partial
+    map-underscore-to-camel-case: true
+
+jwt:
+  tokenHeader: Authorization #JWT存储的请求头
+  secret: mall-admin-secret #JWT加解密使用的密钥
+  expiration: 604800 #JWT的超期限时间(60*60*24*7)
+  tokenHead: 'Bearer '  #JWT负载中拿到开头
+
+redis:
+  database: power
+  key:
+    admin: 'ums:admin'
+    resourceList: 'ums:resourceList'
+    provinceList: 'business:provinceList'
+    lineList: 'business:lineList'
+    directory: 'business:directory'
+  expire:
+    common: 86400 # 24小时
+
+secure:
+  ignored:
+    urls: #安全路径白名单
+      - /swagger-ui.html
+      - /swagger-resources/**
+      - /swagger/**
+      - /**/v2/api-docs
+      - /**/*.js
+      - /**/*.css
+      - /**/*.png
+      - /**/*.ico
+      - /**/*.woff
+      - /**/*.ttf
+      - /**/*.map
+      - /webjars/springfox-swagger-ui/**
+      - /actuator/**
+      - /druid/**
+      - /admin/login
+      - /admin/register
+      - /admin/info
+      - /admin/logout
+      - /
+      - /index.html
+      - /line/findByKeySimple
+      - /line/detail/**
+      - /device/**
+upload:
+  temp-path: ./temp/
+  path: ./upload/ #文件上传路径
+  power-path: ./power/
+
+thread:
+  pool:
+    corePoolSize: 10
+    maxPoolSize: 20
+    keepAliveSeconds: 5
+    queueCapacity: 512
+
+
+weather:
+  REQUEST_URL: https://devapi.qweather.com/v7/weather/now
+  KEY: b7942152d9844b958862bd612297b471

+ 19 - 0
src/main/resources/config/bootstrap.yml

@@ -0,0 +1,19 @@
+spring:
+  application:
+    name: file-collect
+  profiles:
+    active: test
+  cloud:
+    nacos:
+      config:
+        server-addr: 47.107.126.107:18848
+        file-extension: yml
+        #没有使用命名空间的话,可以不用配置,默认为public
+        namespace: 398688e7-2ce0-4165-bb18-856bff2ca4b4
+        username: nacos
+        password: qxiaupmqbuz3udwO4A
+        group: FILE_COLLECT_GROUP
+
+keystar:
+  eprdms:
+    url: http://120.237.146.228:18060

+ 0 - 15
src/main/resources/mapper/ums/UmsAdminLoginLogMapper.xml

@@ -1,15 +0,0 @@
-<?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">
-<mapper namespace="com.macro.mall.tiny.modules.ums.mapper.UmsAdminLoginLogMapper">
-
-    <!-- 通用查询映射结果 -->
-    <resultMap id="BaseResultMap" type="com.macro.mall.tiny.modules.ums.model.UmsAdminLoginLog">
-        <id column="id" property="id" />
-        <result column="admin_id" property="adminId" />
-        <result column="create_time" property="createTime" />
-        <result column="ip" property="ip" />
-        <result column="address" property="address" />
-        <result column="user_agent" property="userAgent" />
-    </resultMap>
-
-</mapper>

+ 0 - 67
src/main/resources/mapper/ums/UmsAdminMapper.xml

@@ -1,67 +0,0 @@
-<?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">
-<mapper namespace="com.macro.mall.tiny.modules.ums.mapper.UmsAdminMapper">
-
-    <!-- 通用查询映射结果 -->
-    <resultMap id="BaseResultMap" type="com.macro.mall.tiny.modules.ums.model.UmsAdmin">
-        <id column="id" property="id"/>
-        <result column="username" property="username"/>
-        <result column="password" property="password"/>
-        <result column="icon" property="icon"/>
-        <result column="email" property="email"/>
-        <result column="nick_name" property="nickName"/>
-        <result column="note" property="note"/>
-        <result column="create_time" property="createTime"/>
-        <result column="login_time" property="loginTime"/>
-        <result column="status" property="status"/>
-    </resultMap>
-
-    <!-- 通用查询映射结果 -->
-    <resultMap id="BaseResultMap2" type="com.macro.mall.tiny.modules.ums.model.UmsAdmin">
-        <id column="id" property="id"/>
-        <result column="username" property="username"/>
-        <result column="password" property="password"/>
-        <result column="icon" property="icon"/>
-        <result column="email" property="email"/>
-        <result column="nick_name" property="nickName"/>
-        <result column="note" property="note"/>
-        <result column="create_time" property="createTime"/>
-        <result column="login_time" property="loginTime"/>
-        <result column="status" property="status"/>
-        <collection property="roleList" ofType="com.macro.mall.tiny.modules.ums.model.UmsRole" column="id">
-            <id column="r_id" property="id"/>
-            <result column="r_name" property="name"/>
-        </collection>
-    </resultMap>
-
-    <select id="getAdminIdList" resultType="java.lang.Long">
-        SELECT DISTINCT ar.admin_id
-        FROM ums_role_resource_relation rr
-                 LEFT JOIN ums_admin_role_relation ar ON rr.role_id = ar.role_id
-        WHERE rr.resource_id = #{resourceId}
-    </select>
-
-    <select id="findListByKey" resultMap="BaseResultMap2">
-        SELECT a.id,
-        a.username,
-        a.password,
-        a.icon,
-        a.email,
-        a.nick_name,
-        a.note,
-        a.create_time,
-        a.login_time,
-        a.status,
-        r.id r_id,
-        r.name r_name
-        FROM ums_admin a
-        LEFT JOIN ums_admin_role_relation ar ON ar.admin_id = a.id
-        LEFT JOIN ums_role r ON ar.role_id = r.id
-        WHERE 1 = 1
-        <if test="keyword!=null and keyword!=''">
-            AND a.username like CONCAT('%', #{keyword}, '%')
-            OR a.nick_name like concat('%', #{keyword}, '%');
-        </if>
-    </select>
-
-</mapper>

+ 0 - 61
src/main/resources/mapper/ums/UmsMenuMapper.xml

@@ -1,61 +0,0 @@
-<?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">
-<mapper namespace="com.macro.mall.tiny.modules.ums.mapper.UmsMenuMapper">
-
-    <!-- 通用查询映射结果 -->
-    <resultMap id="BaseResultMap" type="com.macro.mall.tiny.modules.ums.model.UmsMenu">
-        <id column="id" property="id" />
-        <result column="parent_id" property="parentId" />
-        <result column="create_time" property="createTime" />
-        <result column="title" property="title" />
-        <result column="level" property="level" />
-        <result column="sort" property="sort" />
-        <result column="name" property="name" />
-        <result column="icon" property="icon" />
-        <result column="hidden" property="hidden" />
-    </resultMap>
-
-    <select id="getMenuList" resultType="com.macro.mall.tiny.modules.ums.model.UmsMenu">
-        SELECT
-            m.id id,
-            m.parent_id parentId,
-            m.create_time createTime,
-            m.title title,
-            m.level level,
-            m.sort sort,
-            m.name name,
-            m.icon icon,
-            m.hidden hidden
-        FROM
-            ums_admin_role_relation arr
-                LEFT JOIN ums_role r ON arr.role_id = r.id
-                LEFT JOIN ums_role_menu_relation rmr ON r.id = rmr.role_id
-                LEFT JOIN ums_menu m ON rmr.menu_id = m.id
-        WHERE
-            arr.admin_id = #{adminId}
-          AND m.id IS NOT NULL
-        GROUP BY
-            m.id
-    </select>
-    <select id="getMenuListByRoleId" resultType="com.macro.mall.tiny.modules.ums.model.UmsMenu">
-        SELECT
-            m.id id,
-            m.parent_id parentId,
-            m.create_time createTime,
-            m.title title,
-            m.level level,
-            m.sort sort,
-            m.name name,
-            m.icon icon,
-            m.hidden hidden
-        FROM
-            ums_role_menu_relation rmr
-                LEFT JOIN ums_menu m ON rmr.menu_id = m.id
-        WHERE
-            rmr.role_id = #{roleId}
-          AND m.id IS NOT NULL
-        GROUP BY
-            m.id
-    </select>
-
-</mapper>

+ 0 - 53
src/main/resources/mapper/ums/UmsResourceMapper.xml

@@ -1,53 +0,0 @@
-<?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">
-<mapper namespace="com.macro.mall.tiny.modules.ums.mapper.UmsResourceMapper">
-
-    <!-- 通用查询映射结果 -->
-    <resultMap id="BaseResultMap" type="com.macro.mall.tiny.modules.ums.model.UmsResource">
-        <id column="id" property="id" />
-        <result column="create_time" property="createTime" />
-        <result column="name" property="name" />
-        <result column="url" property="url" />
-        <result column="description" property="description" />
-        <result column="category_id" property="categoryId" />
-    </resultMap>
-
-    <select id="getResourceList" resultType="com.macro.mall.tiny.modules.ums.model.UmsResource">
-        SELECT
-            ur.id id,
-            ur.create_time createTime,
-            ur.`name` `name`,
-            ur.url url,
-            ur.description description,
-            ur.category_id categoryId
-        FROM
-            ums_admin_role_relation ar
-                LEFT JOIN ums_role r ON ar.role_id = r.id
-                LEFT JOIN ums_role_resource_relation rrr ON r.id = rrr.role_id
-                LEFT JOIN ums_resource ur ON ur.id = rrr.resource_id
-        WHERE
-            ar.admin_id = #{adminId}
-          AND ur.id IS NOT NULL
-        GROUP BY
-            ur.id
-    </select>
-
-    <select id="getResourceListByRoleId" resultType="com.macro.mall.tiny.modules.ums.model.UmsResource">
-        SELECT
-            r.id id,
-            r.create_time createTime,
-            r.`name` `name`,
-            r.url url,
-            r.description description,
-            r.category_id categoryId
-        FROM
-            ums_role_resource_relation rrr
-                LEFT JOIN ums_resource r ON rrr.resource_id = r.id
-        WHERE
-            rrr.role_id = #{roleId}
-          AND r.id IS NOT NULL
-        GROUP BY
-            r.id
-    </select>
-
-</mapper>

+ 0 - 22
src/main/resources/mapper/ums/UmsRoleMapper.xml

@@ -1,22 +0,0 @@
-<?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">
-<mapper namespace="com.macro.mall.tiny.modules.ums.mapper.UmsRoleMapper">
-
-    <!-- 通用查询映射结果 -->
-    <resultMap id="BaseResultMap" type="com.macro.mall.tiny.modules.ums.model.UmsRole">
-        <id column="id" property="id" />
-        <result column="name" property="name" />
-        <result column="description" property="description" />
-        <result column="admin_count" property="adminCount" />
-        <result column="create_time" property="createTime" />
-        <result column="status" property="status" />
-        <result column="sort" property="sort" />
-    </resultMap>
-
-    <select id="getRoleList" resultType="com.macro.mall.tiny.modules.ums.model.UmsRole">
-        select r.*
-        from ums_admin_role_relation ar left join ums_role r on ar.role_id = r.id
-        where ar.admin_id = #{adminId}
-    </select>
-
-</mapper>

+ 0 - 11
src/main/resources/mapper/ums/UmsRoleResourceRelationMapper.xml

@@ -1,11 +0,0 @@
-<?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">
-<mapper namespace="com.macro.mall.tiny.modules.ums.mapper.UmsRoleResourceRelationMapper">
-
-    <!-- 通用查询映射结果 -->
-    <resultMap id="BaseResultMap" type="com.macro.mall.tiny.modules.ums.model.UmsRoleResourceRelation">
-        <id column="id" property="id" />
-        <result column="role_id" property="roleId" />
-        <result column="resource_id" property="resourceId" />
-    </resultMap>
-</mapper>