tianyabing 2 vuotta sitten
sitoutus
7824e6e654
27 muutettua tiedostoa jossa 2525 lisäystä ja 0 poistoa
  1. 11 0
      .gitignore
  2. 268 0
      pom.xml
  3. 20 0
      src/main/java/com/sky/ioc/SkyIocApplication.java
  4. 32 0
      src/main/java/com/sky/ioc/config/CorsConfig.java
  5. 75 0
      src/main/java/com/sky/ioc/config/GlobalExceptionHandler.java
  6. 17 0
      src/main/java/com/sky/ioc/config/HttpConverterConfig.java
  7. 46 0
      src/main/java/com/sky/ioc/config/LoginAspect.java
  8. 67 0
      src/main/java/com/sky/ioc/config/MyRedisConfig.java
  9. 9 0
      src/main/java/com/sky/ioc/config/MybatisPlusConfig.java
  10. 72 0
      src/main/java/com/sky/ioc/config/RestTemplateConfig.java
  11. 30 0
      src/main/java/com/sky/ioc/config/SkyConfig.java
  12. 80 0
      src/main/java/com/sky/ioc/config/SwaggerConfig.java
  13. 19 0
      src/main/java/com/sky/ioc/constant/Constant.java
  14. 15 0
      src/main/java/com/sky/ioc/constant/MsgCode.java
  15. 58 0
      src/main/java/com/sky/ioc/tool/CronUtils.java
  16. 516 0
      src/main/java/com/sky/ioc/tool/DateUtil.java
  17. 76 0
      src/main/java/com/sky/ioc/tool/ExcelUtils.java
  18. 470 0
      src/main/java/com/sky/ioc/tool/FalseData.java
  19. 54 0
      src/main/java/com/sky/ioc/tool/GeneralMethod.java
  20. 46 0
      src/main/java/com/sky/ioc/tool/JwtUtil.java
  21. 40 0
      src/main/java/com/sky/ioc/tool/MathUtils.java
  22. 194 0
      src/main/java/com/sky/ioc/tool/Pbkdf2Sha256Digest.java
  23. 24 0
      src/main/java/com/sky/ioc/tool/RedisUtil.java
  24. 71 0
      src/main/java/com/sky/ioc/tool/ReturnMsg.java
  25. 54 0
      src/main/resources/application-dev.yml
  26. 51 0
      src/main/resources/application-publish.yml
  27. 110 0
      src/main/resources/application.yml

+ 11 - 0
.gitignore

@@ -0,0 +1,11 @@
+# Default ignored files
+/workspace.xml
+DMS-Server.iml
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
+
+.idea/
+
+target/
+out/

+ 268 - 0
pom.xml

@@ -0,0 +1,268 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>com.sky</groupId>
+    <artifactId>sky_ioc_server</artifactId>
+    <version>1.0-SNAPSHOT</version>
+    <name>ioc-server</name>
+
+    <description>智慧运营管理中心</description>
+    <packaging>war</packaging>
+
+    <properties>
+        <java.version>1.8</java.version>
+        <maven.compiler.source>8</maven.compiler.source>
+        <maven.compiler.target>8</maven.compiler.target>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <!-- 依赖版本控制 -->
+        <swagger.version>3.0.0</swagger.version>
+        <mybatis.plus.version>3.5.3</mybatis.plus.version>
+        <druid.version>1.2.15</druid.version>
+        <pagehelper.boot.version>1.4.6</pagehelper.boot.version>
+        <commons.io.version>2.11.0</commons.io.version>
+        <commons.fileupload.version>1.4</commons.fileupload.version>
+        <fastjson.version>1.2.83</fastjson.version>
+        <easyexcel.version>3.1.1</easyexcel.version>
+    </properties>
+
+    <parent>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-starter-parent</artifactId>
+        <version>2.5.14</version>
+        <relativePath/>
+    </parent>
+
+    <dependencies>
+        <!--spring web start-->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.springframework.boot</groupId>
+                    <artifactId>spring-boot-starter-tomcat</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+
+        <!--maven打war包配置-->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-tomcat</artifactId>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.htmlparser</groupId>
+            <artifactId>htmlparser</artifactId>
+            <version>2.1</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-test</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>javax.servlet-api</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <!--spring web end-->
+
+        <!-- SpringBoot 拦截器 -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-aop</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>com.auth0</groupId>
+            <artifactId>java-jwt</artifactId>
+            <version>4.3.0</version>
+        </dependency>
+
+        <!-- redis -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-redis</artifactId>
+        </dependency>
+
+        <!-- spring boot 缓存 -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-cache</artifactId>
+        </dependency>
+
+        <!-- springboot quartz定时任务 -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-quartz</artifactId>
+        </dependency>
+
+        <!-- spring boot 日志 -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-logging</artifactId>
+        </dependency>
+
+        <!-- spring boot 校验 -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-validation</artifactId>
+        </dependency>
+
+        <!-- spring boot 测试 -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <!-- 阿里数据库连接池 -->
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>druid-spring-boot-starter</artifactId>
+            <version>${druid.version}</version>
+        </dependency>
+
+        <!--mybatis plus-->
+        <dependency>
+            <groupId>com.baomidou</groupId>
+            <artifactId>mybatis-plus-boot-starter</artifactId>
+            <version>${mybatis.plus.version}</version>
+        </dependency>
+
+        <!-- pagehelper 分页插件 -->
+        <dependency>
+            <groupId>com.github.pagehelper</groupId>
+            <artifactId>pagehelper-spring-boot-starter</artifactId>
+            <version>${pagehelper.boot.version}</version>
+        </dependency>
+
+        <!-- 定时任务 -->
+        <dependency>
+            <groupId>org.quartz-scheduler</groupId>
+            <artifactId>quartz</artifactId>
+            <exclusions>
+                <exclusion>
+                    <groupId>com.mchange</groupId>
+                    <artifactId>c3p0</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+
+        <!-- 常用工具类 -->
+        <dependency>
+            <groupId>commons-io</groupId>
+            <artifactId>commons-io</artifactId>
+            <version>${commons.io.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-lang3</artifactId>
+        </dependency>
+
+        <!-- 文件上传工具类 -->
+        <dependency>
+            <groupId>commons-fileupload</groupId>
+            <artifactId>commons-fileupload</artifactId>
+            <version>${commons.fileupload.version}</version>
+        </dependency>
+
+        <!-- excel工具 含poi -->
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>easyexcel</artifactId>
+            <version>${easyexcel.version}</version>
+        </dependency>
+
+        <!-- mysql 驱动 -->
+        <!-- <dependency> -->
+        <!--     <groupId>mysql</groupId> -->
+        <!--     <artifactId>mysql-connector-java</artifactId> -->
+        <!-- </dependency> -->
+
+        <!-- postgresql 驱动 -->
+        <dependency>
+            <groupId>org.postgresql</groupId>
+            <artifactId>postgresql</artifactId>
+        </dependency>
+
+
+        <!-- swagger3.0 -->
+        <dependency>
+            <groupId>io.springfox</groupId>
+            <artifactId>springfox-boot-starter</artifactId>
+            <version>${swagger.version}</version>
+        </dependency>
+
+        <!-- fastjson -->
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>fastjson</artifactId>
+            <version>${fastjson.version}</version>
+        </dependency>
+
+        <!-- lombok -->
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-amqp</artifactId>
+        </dependency>
+
+        <!-- mqtt -->
+        <dependency>
+            <groupId>org.springframework.integration</groupId>
+            <artifactId>spring-integration-stream</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.integration</groupId>
+            <artifactId>spring-integration-mqtt</artifactId>
+        </dependency>
+
+
+    </dependencies>
+
+    <build>
+        <finalName>${project.name}</finalName>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <version>2.7.2</version>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-war-plugin</artifactId>
+                <version>3.3.1</version>
+                <configuration>
+                    <failOnMissingWebXml>false</failOnMissingWebXml>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.1</version>
+                <configuration>
+                    <source>${java.version}</source>
+                    <target>${java.version}</target>
+                    <encoding>${project.build.sourceEncoding}</encoding>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-resources-plugin</artifactId>
+                <version>3.1.0</version>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

+ 20 - 0
src/main/java/com/sky/ioc/SkyIocApplication.java

@@ -0,0 +1,20 @@
+package com.sky.ioc;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
+
+@SpringBootApplication
+public class SkyIocApplication extends SpringBootServletInitializer {
+
+    @Override
+    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
+        return builder.sources(SkyIocApplication.class);
+    }
+
+    public static void main(String[] args) {
+        SpringApplication.run(SkyIocApplication.class, args);
+    }
+
+}

+ 32 - 0
src/main/java/com/sky/ioc/config/CorsConfig.java

@@ -0,0 +1,32 @@
+package com.sky.ioc.config;
+
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.cors.CorsConfiguration;
+import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
+import org.springframework.web.filter.CorsFilter;
+
+@Configuration
+public class CorsConfig {
+
+    @Bean
+    public CorsFilter corsFilter() {
+        CorsConfiguration corsConfiguration = new CorsConfiguration();
+        // 设置允许跨域请求的域名
+        corsConfiguration.addAllowedOriginPattern("*");
+        // 设置允许跨域请求头
+        corsConfiguration.addAllowedHeader("*");
+        // 设置允许的方法
+        corsConfiguration.addAllowedMethod("*");
+        // 是否允许证书
+        corsConfiguration.setAllowCredentials(true);
+        // 跨域允许时间
+        corsConfiguration.setMaxAge(3600L);
+
+        UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
+        source.registerCorsConfiguration("/**", corsConfiguration);
+        return new CorsFilter(source);
+    }
+
+}

+ 75 - 0
src/main/java/com/sky/ioc/config/GlobalExceptionHandler.java

@@ -0,0 +1,75 @@
+package com.sky.ioc.config;
+
+import com.auth0.jwt.exceptions.JWTVerificationException;
+import com.auth0.jwt.exceptions.TokenExpiredException;
+import com.sky.ioc.constant.Constant;
+import com.sky.ioc.tool.ReturnMsg;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.RestControllerAdvice;
+
+
+/**
+ * @author LunCe
+ *  异常类   (将异常信息返回)
+ *
+ */
+@Slf4j
+@RestControllerAdvice
+public class GlobalExceptionHandler {
+
+    @ExceptionHandler(TokenExpiredException.class)
+    public ReturnMsg tokenExpiredException(Exception e) {
+        log.error(e.getMessage());
+        return ReturnMsg.fail(Constant.MSG_CODE.LOGIN_TIMEOUT, "登录失效");
+    }
+
+    @ExceptionHandler(JWTVerificationException.class)
+    public ReturnMsg JWTVerificationException(Exception e) {
+        log.error(e.getMessage());
+        return ReturnMsg.fail(Constant.MSG_CODE.SERVER_ERROR, "请登录后重试");
+    }
+
+    @ExceptionHandler(Exception.class)
+    public ReturnMsg exception(Exception e) {
+        log.error(e.getMessage());
+        return ReturnMsg.fail(e.getMessage());
+    }
+
+
+
+//    public static String getExceptionAllinformation_01(Exception ex) {
+//        ByteArrayOutputStream out = new ByteArrayOutputStream();
+//        PrintStream pout = new PrintStream(out);
+//        ex.printStackTrace(pout);
+//        String ret = new String(out.toByteArray());
+//        pout.close();
+//        try {
+//            out.close();
+//        } catch (Exception e) {
+//        }
+//        return ret;
+//    }
+
+//    public String getExceptionMessage(Exception ex) {
+//        StringWriter stringWriter= new StringWriter();
+//        PrintWriter writer= new PrintWriter(stringWriter);
+//        ex.printStackTrace(writer);
+//        StringBuffer buffer= stringWriter.getBuffer();
+//        return buffer.toString();
+//    }
+
+//    @ExceptionHandler(IndexOutOfBoundsException.class)
+//    public String arrayOutOfRangeException(Exception e) {
+//        LOGGER.error(e.getMessage(), e);
+//        return "数组越界 "  + e.getMessage();
+//    }
+//
+//    @ExceptionHandler(RuntimeException.class)
+//    public String handleRuntimeException(RuntimeException e, HttpServletRequest request) {
+//        String requestURI = request.getRequestURI();
+//        LOGGER.error("请求地址'{}',发生未知异常.", requestURI, e);
+//        return "请求地址'{"+requestURI+"}',发生异常为:'{"+e.getMessage()+"'}" + e;
+//    }
+}
+

+ 17 - 0
src/main/java/com/sky/ioc/config/HttpConverterConfig.java

@@ -0,0 +1,17 @@
+package com.sky.ioc.config;
+
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+
+@Configuration
+public class HttpConverterConfig implements WebMvcConfigurer {
+
+    @Override
+    public void addResourceHandlers(ResourceHandlerRegistry registry) {
+        //其中image表示访问的前缀。"file:F:/img/"是文件真实的存储路径
+        registry.addResourceHandler("/image/**").addResourceLocations("file:/upload/images/");
+    }
+
+}
+

+ 46 - 0
src/main/java/com/sky/ioc/config/LoginAspect.java

@@ -0,0 +1,46 @@
+package com.sky.ioc.config;
+
+import com.sky.ioc.constant.Constant;
+import com.sky.ioc.tool.JwtUtil;
+import com.sky.ioc.tool.RedisUtil;
+import com.sky.ioc.tool.ReturnMsg;
+import lombok.extern.slf4j.Slf4j;
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.Around;
+import org.aspectj.lang.annotation.Aspect;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.springframework.util.StringUtils;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.Objects;
+
+@Slf4j
+@Component
+@Aspect
+public class LoginAspect {
+
+    @Autowired
+    private RedisUtil redisUtil;
+
+    @Around("execution(* com.sky.ioc..*Controller.*(..))")
+    public Object aroundLog(ProceedingJoinPoint joinPoint) throws Throwable {
+        ServletRequestAttributes sra = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
+        HttpServletRequest request = sra.getRequest();
+        String clientId = request.getHeader("clientId");
+        if (request.getServletPath().contains("login")||(StringUtils.hasText(clientId)&&clientId.equals("99"))) {
+            return joinPoint.proceed(joinPoint.getArgs());
+        }
+        String token = request.getHeader("token");
+        if (StringUtils.hasText(token)) {
+            String username = JwtUtil.parseJWT(token) ;
+            Object o = redisUtil.get("login:" + username);
+            if (!Objects.isNull(o)) {
+                return joinPoint.proceed(joinPoint.getArgs());
+            }
+        }
+        return ReturnMsg.fail(Constant.MSG_CODE.LOGIN_TIMEOUT, "当前未登录");
+    }
+}

+ 67 - 0
src/main/java/com/sky/ioc/config/MyRedisConfig.java

@@ -0,0 +1,67 @@
+package com.sky.ioc.config;
+
+import org.springframework.cache.annotation.EnableCaching;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.redis.connection.RedisConnectionFactory;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
+import org.springframework.data.redis.serializer.RedisSerializer;
+import org.springframework.data.redis.serializer.StringRedisSerializer;
+
+@EnableCaching
+@Configuration
+public class MyRedisConfig {
+
+//    @Primary
+//    @Bean
+//    public CacheManager cacheManager(RedisConnectionFactory redisConnectionFactory){
+//        RedisCacheConfiguration redisCacheConfiguration = RedisCacheConfiguration.defaultCacheConfig();
+//        redisCacheConfiguration = redisCacheConfiguration
+//                // 设置缓存的默认超时时间:30分钟
+//                .entryTtl(Duration.ofMillis(30l))
+//                // 如果是空值,不缓存
+//                .disableCachingNullValues()
+//                // 设置key序列号器
+//                .serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(keySerialization()))
+//                // 设置value序列号器
+//                .serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(valueSerialization()));
+//
+//        return RedisCacheManager
+//                .builder(RedisCacheWriter.nonLockingRedisCacheWriter(redisConnectionFactory))
+//                .cacheDefaults(redisCacheConfiguration)
+//                .build();
+//    }
+//
+//    // key序列号器
+//    private RedisSerializer<String> keySerialization(){
+//        return new StringRedisSerializer();
+//    }
+//    // value序列号器
+//    private RedisSerializer<Object> valueSerialization(){
+//        return new GenericJackson2JsonRedisSerializer();
+//    }
+
+
+    @Bean(name = "redisTemplate")
+    public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory){
+
+        RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
+        ////参照StringRedisTemplate内部实现指定序列化器
+        redisTemplate.setConnectionFactory(redisConnectionFactory);
+        redisTemplate.setKeySerializer(keySerializer());
+        redisTemplate.setHashKeySerializer(keySerializer());
+        redisTemplate.setValueSerializer(valueSerializer());
+        redisTemplate.setHashValueSerializer(valueSerializer());
+        return redisTemplate;
+    }
+
+    private RedisSerializer<String> keySerializer(){
+        return new StringRedisSerializer();
+    }
+
+    //使用Jackson序列化器
+    private RedisSerializer<Object> valueSerializer(){
+        return new GenericJackson2JsonRedisSerializer();
+    }
+}

+ 9 - 0
src/main/java/com/sky/ioc/config/MybatisPlusConfig.java

@@ -0,0 +1,9 @@
+package com.sky.ioc.config;
+
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+@MapperScan("com.sky.**.mapper")
+public class MybatisPlusConfig {
+}

+ 72 - 0
src/main/java/com/sky/ioc/config/RestTemplateConfig.java

@@ -0,0 +1,72 @@
+package com.sky.ioc.config;
+
+import com.sky.ioc.mapper.job.TokenMapper;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.web.client.RestTemplateBuilder;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.http.client.SimpleClientHttpRequestFactory;
+import org.springframework.web.client.RestTemplate;
+
+import javax.annotation.Resource;
+import javax.net.ssl.HttpsURLConnection;
+import java.io.IOException;
+import java.net.HttpURLConnection;
+import java.time.Duration;
+import java.time.temporal.ChronoUnit;
+import java.util.Map;
+
+@Configuration
+public class RestTemplateConfig {
+
+    @Resource
+    TokenMapper tokenMapper;
+
+    @Value("${sky.dataIp}")
+    private String dataIp;
+
+    private static RestTemplateBuilder builder = null;
+
+    static {
+        builder = new RestTemplateBuilder(restTemplate -> restTemplate.setRequestFactory(new SimpleClientHttpRequestFactory() {
+            @Override
+            protected void prepareConnection(HttpURLConnection connection, String httpMethod) throws IOException {
+                if (connection instanceof HttpsURLConnection) {
+                    ((HttpsURLConnection) connection).setHostnameVerifier((s, sslSession) -> true);
+                }
+                super.prepareConnection(connection, httpMethod);
+            }
+        }))
+                // 超时时间
+                .setConnectTimeout(Duration.of(5*60, ChronoUnit.SECONDS))
+                .setReadTimeout(Duration.of(5*60, ChronoUnit.SECONDS));
+    }
+
+    @Bean
+    public RestTemplate restTemplate(){
+        return build();
+    }
+
+
+    public RestTemplate build() {
+        Map<String,String> tokenMap = tokenMapper.getNewToken();
+        String token ="Bearer eyJhbGciOiJIUzUxMiJ9.eyJ1c2VyX2lkIjoxLCJ1c2VyX2tleSI6IjUwZTU1NTRkLWJjYzYtNGRhMS1iZDUxLWFhNTc3YzU4YTFiNCIsInVzZXJuYW1lIjoiYWRtaW4ifQ.X10VPYJfeeRTka7OtqNPOGMpL4QkW3fR_TfCKXCmO-yXbIIrr_40fcwiVnpXfYVENo_BvXWEACRd-Y6nXsbkog";
+        if(tokenMap!=null){
+
+            token = "Bearer "+tokenMap.get("token");
+        }
+        // 默认请求头
+        builder = builder.defaultHeader("authorization", token);
+        return builder.build();
+    }
+
+    public String addBaseUrl(String url) {
+        if (url.startsWith("http")) {
+            return url;
+        }
+        url = StringUtils.removeStart(url, "/");
+        String baseUrl = StringUtils.appendIfMissing("http://"+dataIp, "/");
+        return baseUrl + url;
+    }
+}

+ 30 - 0
src/main/java/com/sky/ioc/config/SkyConfig.java

@@ -0,0 +1,30 @@
+package com.sky.ioc.config;
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+@Component
+@ConfigurationProperties(prefix = "sky")
+public class SkyConfig {
+    /** 项目名称 */
+    private static String name;
+
+    /** 版本 */
+    private static String version;
+
+    public static String getName() {
+        return name;
+    }
+
+    public static void setName(String name) {
+        SkyConfig.name = name;
+    }
+
+    public static String getVersion() {
+        return version;
+    }
+
+    public static void setVersion(String version) {
+        SkyConfig.version = version;
+    }
+}

+ 80 - 0
src/main/java/com/sky/ioc/config/SwaggerConfig.java

@@ -0,0 +1,80 @@
+package com.sky.ioc.config;
+
+import io.swagger.annotations.ApiOperation;
+import io.swagger.v3.oas.annotations.enums.SecuritySchemeIn;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import springfox.documentation.builders.ApiInfoBuilder;
+import springfox.documentation.builders.PathSelectors;
+import springfox.documentation.builders.RequestHandlerSelectors;
+import springfox.documentation.oas.annotations.EnableOpenApi;
+import springfox.documentation.service.*;
+import springfox.documentation.spi.DocumentationType;
+import springfox.documentation.spi.service.contexts.SecurityContext;
+import springfox.documentation.spring.web.plugins.Docket;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * Swagger的接口配置
+ */
+@EnableOpenApi
+@Configuration
+public class SwaggerConfig {
+    /**
+     * 是否开启swagger
+     */
+    @Value("${swagger.enabled}")
+    private boolean enabled;
+
+    /**
+     * 创建API
+     */
+    @Bean
+    public Docket createRestApi() {
+        return new Docket(DocumentationType.OAS_30)
+                .enable(enabled)
+                .apiInfo(apiInfo())
+                .select()
+                .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
+                .paths(PathSelectors.any()).build().securityContexts(Arrays.asList(securityContext()))
+                // ApiKey的name需与SecurityReference的reference保持一致
+                .securitySchemes(Arrays.asList(new ApiKey("token", "token", SecuritySchemeIn.HEADER.name())));
+    }
+
+    /**
+     * 添加摘要信息
+     */
+    private ApiInfo apiInfo() {
+        // 用ApiInfoBuilder进行定制
+        return new ApiInfoBuilder()
+                // 设置标题
+                .title(SkyConfig.getName())
+                // 描述
+                .description("")
+                // 作者信息
+                .contact(new Contact(SkyConfig.getName(), null, null))
+                // 版本
+                .version("版本号:" + SkyConfig.getVersion())
+                .build();
+    }
+
+    private SecurityContext securityContext() {
+        return SecurityContext.builder()
+                .securityReferences(defaultAuth())
+                //.forPaths(PathSelectors.regex("/*.*"))
+                .build();
+    }
+    private List<SecurityReference> defaultAuth() {
+        AuthorizationScope authorizationScope
+                = new AuthorizationScope("global", "accessEverything");
+        AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
+        authorizationScopes[0] = authorizationScope;
+        return Collections.singletonList(
+                new SecurityReference("token", authorizationScopes));
+    }
+
+}

+ 19 - 0
src/main/java/com/sky/ioc/constant/Constant.java

@@ -0,0 +1,19 @@
+package com.sky.ioc.constant;
+
+
+public class Constant {
+
+    public static MsgCode MSG_CODE = new MsgCode();
+
+   public final static  String PHONE_CODE = "089383";
+
+    /**
+     * 正常状态
+     */
+    public static final Integer STATUS_NORMAL = 0;
+
+    /**
+     * 禁用状态
+     */
+    public static final Integer STATUS_DISABLE = -1;
+}

+ 15 - 0
src/main/java/com/sky/ioc/constant/MsgCode.java

@@ -0,0 +1,15 @@
+package com.sky.ioc.constant;
+
+public class MsgCode {
+
+    /** 网络请求返回值 **/
+    public final int SUCCESS = 200;
+    /** 无权限 **/
+    public final int NO_PERMISSION = 201;
+    /** 参数错误 **/
+    public final int PARAM_ERROR = 202;
+
+    public final int LOGIN_TIMEOUT = 203;
+    /** 服务端错误 **/
+    public final int SERVER_ERROR = 500;
+}

+ 58 - 0
src/main/java/com/sky/ioc/tool/CronUtils.java

@@ -0,0 +1,58 @@
+package com.sky.ioc.tool;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+/**
+ * java日期转cron表达式工具类
+ * */
+public class CronUtils {
+
+    /**
+     * 每年时间format格式
+     */
+    private static final String DATEFORMAT_YEAR = "ss mm HH dd MM ? yyyy";
+
+    /**
+     * 每天时间format格式
+     */
+    private static final String DATEFORMAT_EVERYDAY = "ss mm HH * * ?";
+
+    /**
+     * 每周时间format格式
+     */
+    private static final String SUNDAY = "ss mm HH ? * 1";
+    private static final String MONDAY = "ss mm HH ? * 2";
+    private static final String TUESDAY = "ss mm HH ? * 3";
+    private static final String WEDNESDAY = "ss mm HH ? * 4";
+    private static final String THURSDAY = "ss mm HH ? * 5";
+    private static final String FRIDAY = "ss mm HH ? * 6";
+    private static final String SATURADY = "ss mm HH ? * 7";
+
+    public static String formatDateByPattern(Date date, String dateFormat) {
+        SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
+        String formatTimeStr = null;
+        if (date != null) {
+            formatTimeStr = sdf.format(date);
+        }
+        return formatTimeStr;
+    }
+    /**
+     * 时间转换时间表达式
+     */
+    public static String getCron(Date date, String dateFormat) {
+        return formatDateByPattern(date, dateFormat);
+    }
+
+    public static void main(String[] args)throws Exception{
+        String cron = getCron(new Date(), SUNDAY);
+        System.out.println("每周六执行"+cron);
+
+        String cron1 = getCron(new Date("2020/04/06 14:10:00"), DATEFORMAT_EVERYDAY);
+        System.out.println("每天执行"+cron1);
+
+        String cron2 = getCron(new Date(), DATEFORMAT_YEAR);
+        System.out.println("执行一次"+cron2);
+
+    }
+}

+ 516 - 0
src/main/java/com/sky/ioc/tool/DateUtil.java

@@ -0,0 +1,516 @@
+package com.sky.ioc.tool;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.time.Instant;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.time.format.DateTimeFormatter;
+import java.util.*;
+
+/**
+ * @Author : JCccc
+ * @CreateTime : 2020/2/27
+ * @Description :
+ **/
+public class DateUtil {
+
+    /**
+     * 获取今天开始时间和结束时间
+     *
+     * @return
+     */
+    public static Map getTodayTime() {
+        Long startTime = getStartTime();
+        //Long endTime = getEndTime(); //当期时间
+
+        //当期时间
+        Long endTime = System.currentTimeMillis();
+        DateTimeFormatter ftf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+        String startTimeStr = ftf.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(startTime), ZoneId.systemDefault()));
+        String endTimeStr = ftf.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(endTime), ZoneId.systemDefault()));
+        Map map = new HashMap();
+        map.put("startDate", startTimeStr);
+        map.put("endDate", endTimeStr);
+        return map;
+    }
+
+    //获取今天日期 年月日
+    public  static  Date getTodayYmd(){
+        Date now = new Date();
+        Calendar cal1 = Calendar.getInstance();
+        cal1.setTime(now);
+        // 将时分秒,毫秒域清零
+        cal1.set(Calendar.HOUR_OF_DAY, 0);
+        cal1.set(Calendar.MINUTE, 0);
+        cal1.set(Calendar.SECOND, 0);
+        cal1.set(Calendar.MILLISECOND, 0);
+        return cal1.getTime();
+    }
+
+    //获取昨天日期 年月日
+    public static Date getYesterdayYmd() {
+        Calendar cal = new GregorianCalendar();
+        cal.set(Calendar.HOUR_OF_DAY, 0);
+        cal.set(Calendar.MINUTE, 0);
+        cal.set(Calendar.SECOND, 0);
+        cal.set(Calendar.MILLISECOND, 0);
+        cal.add(Calendar.DAY_OF_MONTH, -1);
+        return cal.getTime();
+    }
+
+
+
+
+    /**
+     * 获取昨天开始时间和结束时间
+     *
+     * @return
+     */
+    public static Map getYesterdayTime() {
+        Long startTime = getBeginDayOfYesterday();
+        Long endTime = getEndDayOfYesterDay();
+        DateTimeFormatter ftf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+        String startTimeStr = ftf.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(startTime), ZoneId.systemDefault()));
+        String endTimeStr = ftf.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(endTime), ZoneId.systemDefault()));
+        Map map = new HashMap();
+        map.put("startDate", startTimeStr);
+        map.put("endDate", endTimeStr);
+        return map;
+
+
+
+
+    }
+
+    /**
+     * 获取当月开始时间和结束时间
+     *
+     * @return
+     */
+    public static Map getMonthTime() {
+        Long startTime = getMonthStartTime();
+        Long endTime = getMonthEndTime();
+        DateTimeFormatter ftf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+        String startTimeStr = ftf.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(startTime), ZoneId.systemDefault()));
+        String endTimeStr = ftf.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(endTime), ZoneId.systemDefault()));
+        Map map = new HashMap();
+        map.put("startDate", startTimeStr);
+        map.put("endDate", endTimeStr);
+        return map;
+    }
+
+    /**
+     * 获取上个月月开始时间和结束时间
+     *
+     * @return
+     */
+    public static Map getLastMonthTime() throws Exception {
+        Long startTime = getLastMonthStartTime();
+        Long endTime = getLastMonthEndTime();
+        DateTimeFormatter ftf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+        String startTimeStr = ftf.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(startTime), ZoneId.systemDefault()));
+        String endTimeStr = ftf.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(endTime), ZoneId.systemDefault()));
+        Map map = new HashMap();
+        map.put("startDate", startTimeStr);
+        map.put("endDate", endTimeStr);
+        return map;
+    }
+
+
+    //获取月均开始和结束时间
+    public static Map getAverageTime(String minCreateTime) throws ParseException {
+
+
+        Long yesterdayTimeEnd =getEndDayOfYesterDay();
+
+        DateTimeFormatter ftf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+        //昨天的时间
+        String yesterdayStr = ftf.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(yesterdayTimeEnd), ZoneId.systemDefault()));
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        String yesterdayBefore30Str = "";
+        Calendar calc = Calendar.getInstance();
+
+        calc.setTime(sdf.parse(yesterdayStr));
+        calc.add(Calendar.DATE, -30);
+        calc.set(Calendar.HOUR_OF_DAY, 0);
+        calc.set(Calendar.MINUTE, 0);
+        calc.set(Calendar.SECOND, 0);
+        calc.set(Calendar.MILLISECOND, 0);
+        Date minDate = calc.getTime();
+        yesterdayBefore30Str = sdf.format(minDate);
+
+        int num = daysBetween(yesterdayBefore30Str, yesterdayStr);
+
+        int checkNum = daysBetween(minCreateTime, yesterdayBefore30Str);
+        System.out.println("checkNum:"+checkNum);
+        Map map = new HashMap();
+        if (checkNum < 0) {
+            int numNew = daysBetween(minCreateTime, yesterdayStr);
+            map.put("startDate", minCreateTime);
+            map.put("endDate", yesterdayStr);
+            map.put("num", Math.abs(numNew)); //取绝对值
+            return map;
+        }
+
+        map.put("startDate", yesterdayBefore30Str);
+        map.put("endDate", yesterdayStr);
+        map.put("num", num);
+        return map;
+    }
+
+
+
+
+    public static int daysBetween(String smdate, String bdate)  {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
+        Calendar cal = Calendar.getInstance();
+        try {
+            cal.setTime(sdf.parse(smdate));
+            long time1 = cal.getTimeInMillis();
+            cal.setTime(sdf.parse(bdate));
+            long time2 = cal.getTimeInMillis();
+            long between_days = (time2 - time1) / (1000 * 3600 * 24);
+            return Integer.parseInt(String.valueOf(between_days));
+        } catch (ParseException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+
+    /**
+     * 获取今天开始时间
+     */
+    private static Long getStartTime() {
+        Calendar todayStart = Calendar.getInstance();
+        todayStart.set(Calendar.HOUR_OF_DAY, 0);
+        todayStart.set(Calendar.MINUTE, 0);
+        todayStart.set(Calendar.SECOND, 0);
+        todayStart.set(Calendar.MILLISECOND, 0);
+        return todayStart.getTimeInMillis();
+    }
+
+    /**
+     * 获取今天结束时间
+     */
+    private static Long getEndTime() {
+        Calendar todayEnd = Calendar.getInstance();
+        todayEnd.set(Calendar.HOUR, 23);
+        todayEnd.set(Calendar.MINUTE, 59);
+        todayEnd.set(Calendar.SECOND, 59);
+        todayEnd.set(Calendar.MILLISECOND, 999);
+        return todayEnd.getTime().getTime();
+    }
+
+
+    /**
+     * 获取当月开始时间
+     */
+    public static Long getMonthStartTime() {
+
+        Long currentTime = System.currentTimeMillis();
+
+        String timeZone = "GMT+8:00";
+        Calendar calendar = Calendar.getInstance();// 获取当前日期
+        calendar.setTimeZone(TimeZone.getTimeZone(timeZone));
+        calendar.setTimeInMillis(currentTime);
+        calendar.add(Calendar.YEAR, 0);
+        calendar.add(Calendar.MONTH, 0);
+        calendar.set(Calendar.DAY_OF_MONTH, 1);// 设置为1号,当前日期既为本月第一天
+        calendar.set(Calendar.HOUR_OF_DAY, 0);
+        calendar.set(Calendar.MINUTE, 0);
+        calendar.set(Calendar.SECOND, 0);
+        calendar.set(Calendar.MILLISECOND, 0);
+        return calendar.getTimeInMillis();
+
+
+    }
+
+    /**
+     * 获取当月的结束时间戳
+     */
+    public static Long getMonthEndTime() {
+        Long currentTime = System.currentTimeMillis();
+
+        String timeZone = "GMT+8:00";
+        Calendar calendar = Calendar.getInstance();// 获取当前日期
+        calendar.setTimeZone(TimeZone.getTimeZone(timeZone));
+        calendar.setTimeInMillis(currentTime);
+        calendar.add(Calendar.YEAR, 0);
+        calendar.add(Calendar.MONTH, 0);
+        calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));// 获取当前月最后一天
+        calendar.set(Calendar.HOUR_OF_DAY, 23);
+        calendar.set(Calendar.MINUTE, 59);
+        calendar.set(Calendar.SECOND, 59);
+        calendar.set(Calendar.MILLISECOND, 999);
+        return calendar.getTimeInMillis();
+    }
+
+
+    public static Long getLastMonthStartTime() throws Exception {
+        Long currentTime = System.currentTimeMillis();
+
+        String timeZone = "GMT+8:00";
+        Calendar calendar = Calendar.getInstance();// 获取当前日期
+        calendar.setTimeZone(TimeZone.getTimeZone(timeZone));
+        calendar.setTimeInMillis(currentTime);
+        calendar.add(Calendar.YEAR, 0);
+        calendar.add(Calendar.MONTH, -1);
+        calendar.set(Calendar.DAY_OF_MONTH, 1);// 设置为1号,当前日期既为本月第一天
+        calendar.set(Calendar.HOUR_OF_DAY, 0);
+        calendar.set(Calendar.MINUTE, 0);
+        calendar.set(Calendar.SECOND, 0);
+        calendar.set(Calendar.MILLISECOND, 0);
+
+        return calendar.getTimeInMillis();
+    }
+
+
+    public static Long getLastMonthEndTime() {
+        Long currentTime = System.currentTimeMillis();
+
+        String timeZone = "GMT+8:00";
+        Calendar calendar = Calendar.getInstance();// 获取当前日期
+        calendar.setTimeZone(TimeZone.getTimeZone(timeZone));
+        calendar.setTimeInMillis(currentTime);
+        calendar.add(Calendar.YEAR, 0);
+        calendar.add(Calendar.MONTH, -1);
+        calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));// 获取当前月最后一天
+        calendar.set(Calendar.HOUR_OF_DAY, 23);
+        calendar.set(Calendar.MINUTE, 59);
+        calendar.set(Calendar.SECOND, 59);
+        calendar.set(Calendar.MILLISECOND, 999);
+
+        return calendar.getTimeInMillis();
+    }
+
+
+
+
+
+    public static Long getBeginDayOfYesterday() {
+        Calendar cal = new GregorianCalendar();
+        cal.set(Calendar.HOUR_OF_DAY, 0);
+        cal.set(Calendar.MINUTE, 0);
+        cal.set(Calendar.SECOND, 0);
+        cal.set(Calendar.MILLISECOND, 0);
+        cal.add(Calendar.DAY_OF_MONTH, -1);
+        return cal.getTimeInMillis();
+    }
+
+
+
+
+    public static Long getEndDayOfYesterDay() {
+
+        Calendar cal = new GregorianCalendar();
+        cal.set(Calendar.HOUR_OF_DAY, 23);
+        cal.set(Calendar.MINUTE, 59);
+        cal.set(Calendar.SECOND, 59);
+        cal.add(Calendar.DAY_OF_MONTH, -1);
+
+
+        return cal.getTimeInMillis();
+    }
+
+
+
+
+
+
+
+
+    //获取今年是哪一年
+
+    public static Integer getNowYear() {
+
+        Date date = new Date();
+
+        GregorianCalendar gc = (GregorianCalendar) Calendar.getInstance();
+
+        gc.setTime(date);
+
+        return Integer.valueOf(gc.get(1));
+
+    }
+
+
+    public static Map getThisYearTime() throws Exception {
+        Long startTime = getBeginDayOfYear();
+        Long endTime = getEndDayOfYear();
+        DateTimeFormatter ftf = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+        String startTimeStr = ftf.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(startTime), ZoneId.systemDefault()));
+        String endTimeStr = ftf.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(endTime), ZoneId.systemDefault()));
+        Map map = new HashMap();
+        map.put("startDate", startTimeStr);
+        map.put("endDate", endTimeStr);
+        return map;
+    }
+
+    //获取本年的开始时间
+
+    public static Long getBeginDayOfYear() {
+
+        Calendar cal = Calendar.getInstance();
+
+        cal.set(Calendar.YEAR, getNowYear());
+
+        // cal.set
+
+        cal.set(Calendar.MONTH, Calendar.JANUARY);
+
+        cal.set(Calendar.DATE, 1);
+
+
+
+        return getDayStartTime(cal.getTime());
+
+    }
+
+    //获取本年的结束时间
+
+    public static Long getEndDayOfYear() {
+
+        Calendar cal = Calendar.getInstance();
+
+        cal.set(Calendar.YEAR, getNowYear());
+
+        cal.set(Calendar.MONTH, Calendar.DECEMBER);
+
+        cal.set(Calendar.DATE, 31);
+
+        return getDayEndTime(cal.getTime());
+
+    }
+
+    //获取某个日期的开始时间
+
+    public static Long getDayStartTime(Date d) {
+
+        Calendar calendar = Calendar.getInstance();
+
+        if(null != d) calendar.setTime(d);
+
+        calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH),    calendar.get(Calendar.DAY_OF_MONTH), 0, 0, 0);
+
+        calendar.set(Calendar.MILLISECOND, 0);
+
+        return calendar.getTimeInMillis();
+
+    }
+
+    //获取某个日期的结束时间
+
+    public static Long getDayEndTime(Date d) {
+
+        Calendar calendar = Calendar.getInstance();
+
+        if(null != d) calendar.setTime(d);
+
+        calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH),    calendar.get(Calendar.DAY_OF_MONTH), 23, 59, 59);
+
+        calendar.set(Calendar.MILLISECOND, 999);
+
+        return calendar.getTimeInMillis();
+
+    }
+
+    /**
+     *  获取两个日期之间的所有日期 (年月日)
+     *
+     * @param startTime
+     * @param endTime
+     * @return
+     */
+    public static List<String> getBetweenDays(String startTime, String endTime){
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
+        // 声明保存日期集合
+        List<String> list = new ArrayList<String>();
+        try {
+            // 转化成日期类型
+            Date startDate = sdf.parse(startTime);
+            Date endDate = sdf.parse(endTime);
+            //用Calendar 进行日期比较判断
+            Calendar calendar = Calendar.getInstance();
+            while (startDate.getTime()<=endDate.getTime()){
+                // 把日期添加到集合
+                list.add(sdf.format(startDate));
+                // 设置日期
+                calendar.setTime(startDate);
+                //把日期增加一天
+                calendar.add(Calendar.DATE, 1);
+                // 获取增加后的日期
+                startDate=calendar.getTime();
+            }
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        return list;
+    }
+
+    /**
+     * 计算两个日期直接相差的小时
+     * */
+    public static long hoursBetween(String startTime, String endTime)  {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        long nd = 1000 * 24 * 60 * 60;
+        long nh = 1000 * 60 * 60;
+        long  hour = 0;
+        // 获得两个时间的毫秒时间差异
+        Date startDate = null;
+        try {
+            startDate = sdf.parse(startTime);
+            Date endDate = sdf.parse(endTime);
+            long diff = endDate.getTime() - startDate.getTime();
+            // 计算差多少小时
+            hour = diff / nh;
+        } catch (ParseException e) {
+            throw new RuntimeException(e);
+        }
+
+        return hour;
+    }
+
+    /**
+     * 计算两个日期之间相差的分钟
+     * */
+    public static long minutesBetween(String startTime, String endTime)  {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        long nh = 1000 * 60;
+        long  minutes = 0;
+        // 获得两个时间的毫秒时间差异
+        Date startDate = null;
+        try {
+            startDate = sdf.parse(startTime);
+            Date endDate = sdf.parse(endTime);
+            long diff = endDate.getTime() - startDate.getTime();
+            // 计算差多少小时
+            minutes = diff / nh;
+        } catch (ParseException e) {
+            throw new RuntimeException(e);
+        }
+
+        return minutes;
+    }
+
+    public static void main(String[] args) throws Exception {
+
+      /*  Map todayTime = getTodayTime();
+        System.out.println("今天:" + todayTime.toString());
+
+        Map yesterdayTime = getYesterdayTime();
+        System.out.println("昨天:" + yesterdayTime.toString());
+
+        Map monthTime = getMonthTime();
+        System.out.println("当月:" + monthTime.toString());
+
+        Map lastMonthTime = getLastMonthTime();
+        System.out.println("上个月:" + lastMonthTime.toString());
+*/
+        String startStr = "2021/03/01 00:00:00";
+        String endStr = "2021/03/09 00:00:00";
+      //  List<String> list = getBetweenDays(startStr, endStr);
+        System.out.println(hoursBetween(startStr,endStr));
+    }
+
+}

+ 76 - 0
src/main/java/com/sky/ioc/tool/ExcelUtils.java

@@ -0,0 +1,76 @@
+package com.sky.ioc.tool;
+
+import org.apache.coyote.Response;
+import org.apache.poi.hssf.usermodel.HSSFRow;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.servlet.resource.HttpResource;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.net.URLEncoder;
+import java.util.Base64;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Excel 工具类
+ * */
+public class ExcelUtils {
+
+    /**
+     * 导出excel文件数据
+     * @param sheetName
+     * @param column
+     * @param data
+     * @param request
+     * @param response
+     */
+    public static void exportExcel(String sheetName,List<String> columnName, List<String> columnKey, List<Map<String,Object>> data,
+                                     HttpServletRequest request, HttpServletResponse response) {
+        //创建工作薄
+        HSSFWorkbook hssfWorkbook = new HSSFWorkbook();
+        //创建sheet
+        HSSFSheet sheet = hssfWorkbook.createSheet(sheetName);
+        // 表头
+        HSSFRow headRow = sheet.createRow(0);
+        for (int i = 0; i < columnName.size(); i++){//填充表头数据
+            headRow.createCell(i).setCellValue(columnName.get(i));
+        }
+
+        for (int i = 0; i < data.size(); i++) {//填充表格数据
+            HSSFRow dataRow = sheet.createRow(sheet.getLastRowNum() + 1);
+            for (int x = 0; x < columnKey.size(); x++) {
+                dataRow.createCell(x).setCellValue(data.get(i).get(columnKey.get(x))==null?"":data.get(i).get(columnKey.get(x)).toString());
+            }
+        }
+        response.setContentType("application/vnd.ms-excel");
+        try {
+            //获取浏览器名称
+            String agent=request.getHeader("user-agent");
+            String filename=sheetName+".xls";
+            //不同浏览器需要对文件名做特殊处理
+            if (agent.contains("Firefox")) { // 火狐浏览器
+                Base64.Encoder encoder = Base64.getEncoder();
+                filename = "=?UTF-8?B?" +
+                        encoder.encodeToString(filename.getBytes("utf-8"))
+                     //   + new BASE64Encoder().encode(filename.getBytes("utf-8"))
+                        + "?=";
+                filename = filename.replaceAll("\r\n", "");
+            } else { // IE及其他浏览器
+                filename = URLEncoder.encode(filename, "utf-8");
+                filename = filename.replace("+"," ");
+            }
+            //推送浏览器
+            response.setHeader("Content-Disposition", "attachment;filename=" + filename);//UTF-8
+            ServletOutputStream out = response.getOutputStream();
+            hssfWorkbook.write(out);
+            out.close();
+            hssfWorkbook.close();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+}

+ 470 - 0
src/main/java/com/sky/ioc/tool/FalseData.java

@@ -0,0 +1,470 @@
+package com.sky.ioc.tool;
+
+import com.sky.ioc.entity.domain.canteen.Cuisine;
+import com.sky.ioc.entity.domain.parking.Parking;
+import com.sky.ioc.entity.domain.supermarket.Supermarket;
+import com.sky.ioc.entity.work.Access;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.PostConstruct;
+import java.util.*;
+
+/**
+ * @author LunCe
+ */
+
+@Service
+public class FalseData {
+
+
+    /**
+     * 普通数据报表
+     * */
+    public static Map<Integer,Object>  REPORTFORMSMAP = new HashMap<>();
+    /**
+     * 圆圈报表
+     * */
+    public static List<Map<String,Object>> REPORTFORMSLIST2 = new ArrayList<>();
+
+    /**
+     *  核心指标
+     */
+    public static List<Map<String,Object>> REPORTFORMSLIST4 = new ArrayList<>();
+
+    /**
+     *
+     * 今日菜谱或着三个字段的数据 , arrayList
+     * */
+    public static List<Map<String,Object>> REPORTFORMSLIST3 = new ArrayList<>();
+
+    /**
+     *
+     * 今日菜谱或着四个字段的数据 , arrayList
+     * */
+    public static List<Map<String,Object>> REPORTFORMSLIST5 = new ArrayList<>();
+
+
+    /**餐厅*/
+    public static List<Cuisine> CUISINELIST = new ArrayList<>();
+    /**停车*/
+    public static List<Parking> PARKINGLIST = new ArrayList<>();
+    /**商品*/
+    public static List<Supermarket> SUPERMARKETLIST = new ArrayList<>();
+
+    /**门禁*/
+    public static List<Access> ACCESSLIST = new ArrayList<>();
+    @PostConstruct
+    public void initializeInfo3(){
+        /*CUISINELIST.add(new Cuisine("铁锅炖"));
+        CUISINELIST.add(new Cuisine("酸辣臊子蹄筋"));
+        CUISINELIST.add(new Cuisine("叉烧鱼"));
+        CUISINELIST.add(new Cuisine("复元汤"));
+        CUISINELIST.add(new Cuisine("鸡包鱼翅"));
+        CUISINELIST.add(new Cuisine("酸辣臊子蹄筋"));
+        CUISINELIST.add(new Cuisine("小鸡炖蘑菇"));
+        CUISINELIST.add(new Cuisine("锅贴鸡片"));
+        CUISINELIST.add(new Cuisine("小鸡炖蘑菇"));
+        CUISINELIST.add(new Cuisine("山鸡丁儿"));
+        CUISINELIST.add(new Cuisine("麻酱凤尾"));
+        CUISINELIST.add(new Cuisine("麻酱凤尾"));
+        CUISINELIST.add(new Cuisine("麻酱凤尾"));
+        CUISINELIST.add(new Cuisine("麻酱凤尾"));*/
+
+       /* PARKINGLIST.add(new Parking("B201","李劲","北京电信规划设计院","8","0"));
+        PARKINGLIST.add(new Parking("B202","李良","北京电信规划设计院","8","0"));
+        PARKINGLIST.add(new Parking("B203","宋明宇","北京电信规划设计院","8","0"));
+        PARKINGLIST.add(new Parking("B204","陈涵亮","北京电信规划设计院","8","0"));
+        PARKINGLIST.add(new Parking("B205","李超","北京电信规划设计院","8","0"));
+        PARKINGLIST.add(new Parking("B206","章峰","北京电信规划设计院","8","0"));
+        PARKINGLIST.add(new Parking("B207","梁松","北京电信规划设计院","8","0"));
+        PARKINGLIST.add(new Parking("B208","方运诚","北京电信规划设计院","8","0"));
+        PARKINGLIST.add(new Parking("B101","徐涵衍","北京电信规划设计院","8","0"));
+        PARKINGLIST.add(new Parking("B102","万浩波","北京电信规划设计院","8","0"));
+        PARKINGLIST.add(new Parking("B103","周浩广","北京电信规划设计院","8","0"));
+        PARKINGLIST.add(new Parking("B104","许鸿博","北京电信规划设计院","8","0"));
+        PARKINGLIST.add(new Parking("B105","荣浩博","北京电信规划设计院","8","0"));
+        PARKINGLIST.add(new Parking("B106","许鸿畴","北京电信规划设计院","8","0"));
+        PARKINGLIST.add(new Parking("B107","徐瀚文","北京电信规划设计院","8","0"));
+        PARKINGLIST.add(new Parking("B108","陈浩初","北京电信规划设计院","8","0"));
+        PARKINGLIST.add(new Parking("B109","程涵煦","北京电信规划设计院","8","0"));*/
+
+
+
+        SUPERMARKETLIST.add(new Supermarket("钟薛高"));
+        SUPERMARKETLIST.add(new Supermarket("雪糕"));
+        SUPERMARKETLIST.add(new Supermarket("雪糕"));
+        SUPERMARKETLIST.add(new Supermarket("雪糕"));
+        SUPERMARKETLIST.add(new Supermarket("牛肉饼"));
+        SUPERMARKETLIST.add(new Supermarket("鸭脖"));
+        SUPERMARKETLIST.add(new Supermarket("牛肉饼"));
+        SUPERMARKETLIST.add(new Supermarket("薯片"));
+        SUPERMARKETLIST.add(new Supermarket("薯条"));
+        SUPERMARKETLIST.add(new Supermarket("可乐"));
+        SUPERMARKETLIST.add(new Supermarket("雪碧"));
+        SUPERMARKETLIST.add(new Supermarket("牛板筋"));
+        SUPERMARKETLIST.add(new Supermarket("牛肉干"));
+
+
+
+        ACCESSLIST.add(new Access());
+        ACCESSLIST.add(new Access());
+        ACCESSLIST.add(new Access());
+        ACCESSLIST.add(new Access());
+        ACCESSLIST.add(new Access());
+        ACCESSLIST.add(new Access());
+        ACCESSLIST.add(new Access());
+        ACCESSLIST.add(new Access());
+        ACCESSLIST.add(new Access());
+        ACCESSLIST.add(new Access());
+        ACCESSLIST.add(new Access());
+        ACCESSLIST.add(new Access());
+    }
+
+
+
+
+
+    public @PostConstruct void initializeInfo2(){
+        HashMap<String, Object> objectHashMap1 = new HashMap<>();
+        objectHashMap1.put("truckSpace", "b201");
+        objectHashMap1.put("type", "热菜");
+        objectHashMap1.put("name", "铁锅蘑菇土豆炖菜鸡");
+        objectHashMap1.put("count",25 );
+        REPORTFORMSLIST5.add(objectHashMap1);
+
+
+
+        HashMap<String, Object> objectHashMap2 = new HashMap<>();
+        objectHashMap2.put("truckSpace", "b201");
+        objectHashMap2.put("type", "热菜");
+        objectHashMap2.put("name", "铁锅蘑菇土豆炖菜鸡");
+        objectHashMap2.put("count",25 );
+        REPORTFORMSLIST5.add(objectHashMap2);
+
+        HashMap<String, Object> objectHashMap3 = new HashMap<>();
+        objectHashMap3.put("truckSpace", "b201");
+        objectHashMap3.put("type", "热菜");
+        objectHashMap3.put("name", "铁锅蘑菇土豆炖菜鸡");
+        objectHashMap3.put("count",25 );
+        REPORTFORMSLIST5.add(objectHashMap3);
+
+        HashMap<String, Object> objectHashMap4 = new HashMap<>();
+        objectHashMap4.put("truckSpace", "b201");
+        objectHashMap4.put("type", "热菜");
+        objectHashMap4.put("name", "铁锅蘑菇土豆炖菜鸡");
+        objectHashMap4.put("count",25 );
+        REPORTFORMSLIST5.add(objectHashMap4);
+
+        HashMap<String, Object> objectHashMap5 = new HashMap<>();
+        objectHashMap5.put("truckSpace", "b201");
+        objectHashMap5.put("type", "热菜");
+        objectHashMap5.put("name", "铁锅蘑菇土豆炖菜鸡");
+        objectHashMap5.put("count",25 );
+        REPORTFORMSLIST5.add(objectHashMap5);
+
+
+        HashMap<String, Object> objectHashMap6 = new HashMap<>();
+        objectHashMap6.put("truckSpace", "b201");
+        objectHashMap6.put("type", "热菜");
+        objectHashMap6.put("name", "铁锅蘑菇土豆炖菜鸡");
+        objectHashMap6.put("count",25 );
+        REPORTFORMSLIST5.add(objectHashMap6);
+    }
+
+
+    public @PostConstruct void initializeInfo(){
+
+
+        HashMap<String, Object> objectObjectHashMaplist = new HashMap<>();
+        objectObjectHashMaplist.put("info","当天就餐人数预测");
+        objectObjectHashMaplist.put("personnel",1800);
+        objectObjectHashMaplist.put("rise","0.14%");
+        objectObjectHashMaplist.put("decline","0.14%");
+        REPORTFORMSLIST4.add(objectObjectHashMaplist);
+
+        HashMap<String, Object> objectObjectHashMaplist2 = new HashMap<>();
+        objectObjectHashMaplist2.put("info","累计就餐人数");
+        objectObjectHashMaplist2.put("personnel",1500);
+        objectObjectHashMaplist2.put("rise","0.14%");
+        objectObjectHashMaplist2.put("decline","0.14%");
+        REPORTFORMSLIST4.add(objectObjectHashMaplist2);
+
+        HashMap<String, Object> objectObjectHashMaplist3 = new HashMap<>();
+        objectObjectHashMaplist3.put("info","消费总额");
+        objectObjectHashMaplist3.put("personnel",1800);
+        objectObjectHashMaplist3.put("rise","0.14%");
+        objectObjectHashMaplist3.put("decline","0.14%");
+        REPORTFORMSLIST4.add(objectObjectHashMaplist3);
+
+
+        HashMap<String, Object> objectObjectHashMaplist4 = new HashMap<>();
+        objectObjectHashMaplist4.put("info","订单均价");
+        objectObjectHashMaplist4.put("personnel",18);
+        objectObjectHashMaplist4.put("rise","0.14%");
+        objectObjectHashMaplist4.put("decline","0.14%");
+        REPORTFORMSLIST4.add(objectObjectHashMaplist4);
+
+
+
+
+        HashMap<String, Object> objectObjectHashMap = new HashMap<>();
+        objectObjectHashMap.put("info","线下");
+        objectObjectHashMap.put("count",110);
+        REPORTFORMSLIST2.add(objectObjectHashMap);
+
+
+        HashMap<String, Object> objectObjectHashMap2 = new HashMap<>();
+        objectObjectHashMap2.put("info","线上");
+        objectObjectHashMap2.put("count",120);
+        REPORTFORMSLIST2.add(objectObjectHashMap2);
+
+
+        HashMap<String, Object> objectObjectHashMap3 = new HashMap<>();
+        objectObjectHashMap3.put("info","刷卡");
+        objectObjectHashMap3.put("count",130);
+        REPORTFORMSLIST2.add(objectObjectHashMap3);
+
+        HashMap<String, Object> objectObjectHashMap4 = new HashMap<>();
+        objectObjectHashMap4.put("info","现金");
+        objectObjectHashMap4.put("count",140);
+        REPORTFORMSLIST2.add(objectObjectHashMap4);
+
+
+        HashMap<String, Object> objectHashMap1 = new HashMap<>();
+        objectHashMap1.put("type", "热菜");
+        objectHashMap1.put("name", "铁锅蘑菇土豆炖菜鸡");
+        objectHashMap1.put("count",25 );
+        REPORTFORMSLIST3.add(objectHashMap1);
+
+
+
+        HashMap<String, Object> objectHashMap2 = new HashMap<>();
+        objectHashMap2.put("type", "热菜");
+        objectHashMap2.put("name", "铁锅蘑菇土豆炖菜鸡");
+        objectHashMap2.put("count",25 );
+        REPORTFORMSLIST3.add(objectHashMap2);
+
+        HashMap<String, Object> objectHashMap3 = new HashMap<>();
+        objectHashMap3.put("type", "热菜");
+        objectHashMap3.put("name", "铁锅蘑菇土豆炖菜鸡");
+        objectHashMap3.put("count",25 );
+        REPORTFORMSLIST3.add(objectHashMap3);
+
+        HashMap<String, Object> objectHashMap4 = new HashMap<>();
+        objectHashMap4.put("type", "热菜");
+        objectHashMap4.put("name", "铁锅蘑菇土豆炖菜鸡");
+        objectHashMap4.put("count",25 );
+        REPORTFORMSLIST3.add(objectHashMap4);
+
+        HashMap<String, Object> objectHashMap5 = new HashMap<>();
+        objectHashMap5.put("type", "热菜");
+        objectHashMap5.put("name", "铁锅蘑菇土豆炖菜鸡");
+        objectHashMap5.put("count",25 );
+        REPORTFORMSLIST3.add(objectHashMap5);
+
+
+        HashMap<String, Object> objectHashMap6 = new HashMap<>();
+        objectHashMap6.put("type", "热菜");
+        objectHashMap6.put("name", "铁锅蘑菇土豆炖菜鸡");
+        objectHashMap6.put("count",25 );
+        REPORTFORMSLIST3.add(objectHashMap6);
+
+
+
+
+        //周 , 月 ,年
+        List<Map<String,Object>> listMap = new ArrayList<>();
+
+        HashMap<String, Object> objectHashMapList = new HashMap<>();
+        objectHashMapList.put("info1",300);
+        objectHashMapList.put("info2",1800);
+        objectHashMapList.put("info3",200);
+        objectHashMapList.put("date",1);
+        listMap.add(objectHashMapList);
+
+        HashMap<String, Object> objectHashMapList2 = new HashMap<>();
+        objectHashMapList2.put("info1",300);
+        objectHashMapList2.put("info2",1800);
+        objectHashMapList2.put("info3",200);
+        objectHashMapList2.put("date",2);
+        listMap.add(objectHashMapList2);
+
+
+        HashMap<String, Object> objectHashMapList3 = new HashMap<>();
+        objectHashMapList3.put("info1",300);
+        objectHashMapList3.put("info2",1800);
+        objectHashMapList3.put("info3",200);
+        objectHashMapList3.put("date",3);
+        listMap.add(objectHashMapList3);
+
+        HashMap<String, Object> objectHashMapList4 = new HashMap<>();
+        objectHashMapList4.put("info1",300);
+        objectHashMapList4.put("info2",1800);
+        objectHashMapList4.put("info3",200);
+        objectHashMapList4.put("date",4);
+        listMap.add(objectHashMapList4);
+
+        HashMap<String, Object> objectHashMapList5 = new HashMap<>();
+        objectHashMapList5.put("info1",300);
+        objectHashMapList5.put("info2",1800);
+        objectHashMapList5.put("info3",200);
+        objectHashMapList5.put("date",5);
+        listMap.add(objectHashMapList5);
+
+        HashMap<String, Object> objectHashMapList6 = new HashMap<>();
+        objectHashMapList6.put("info1",300);
+        objectHashMapList6.put("info2",1800);
+        objectHashMapList6.put("info3",200);
+        objectHashMapList6.put("date",6);
+        listMap.add(objectHashMapList6);
+
+
+        HashMap<String, Object> objectHashMapList7 = new HashMap<>();
+        objectHashMapList7.put("info1",300);
+        objectHashMapList7.put("info2",1800);
+        objectHashMapList7.put("info3",200);
+        objectHashMapList7.put("date",7);
+        listMap.add(objectHashMapList7);
+
+        REPORTFORMSMAP.put(1,listMap);
+
+
+
+        List<Map<String,Object>> listMap2 = new ArrayList<>();
+
+        HashMap<String, Object> hashMapList = new HashMap<>();
+        hashMapList.put("info1",300);
+        hashMapList.put("info2",1800);
+        hashMapList.put("info3",200);
+        hashMapList.put("date",1);
+        listMap2.add(hashMapList);
+
+
+        HashMap<String, Object> hashMapList2 = new HashMap<>();
+        hashMapList2.put("info1",300);
+        hashMapList2.put("info2",1800);
+        hashMapList2.put("info3",200);
+        hashMapList2.put("date",2);
+        listMap2.add(hashMapList2);
+
+
+
+        HashMap<String, Object> hashMapList3 = new HashMap<>();
+        hashMapList3.put("info1",300);
+        hashMapList3.put("info2",1800);
+        hashMapList3.put("info3",200);
+        hashMapList3.put("date",3);
+        listMap2.add(hashMapList3);
+
+
+        HashMap<String, Object> hashMapList4 = new HashMap<>();
+        hashMapList4.put("info1",300);
+        hashMapList4.put("info2",1800);
+        hashMapList4.put("info3",200);
+        hashMapList4.put("date",4);
+        listMap2.add(hashMapList4);
+        REPORTFORMSMAP.put(2,listMap2);
+
+
+        List<Map<String,Object>> listMap3 = new ArrayList<>();
+        HashMap<String, Object> hashMap = new HashMap<>();
+        hashMap.put("info1",300);
+        hashMap.put("info2",1800);
+        hashMap.put("info3",200);
+        hashMap.put("date",1);
+        listMap3.add(hashMap);
+
+
+        HashMap<String, Object> hashMap2 = new HashMap<>();
+        hashMap2.put("info1",300);
+        hashMap2.put("info2",1800);
+        hashMap2.put("info3",200);
+        hashMap2.put("date",2);
+        listMap3.add(hashMap2);
+
+
+        HashMap<String, Object> hashMap3 = new HashMap<>();
+        hashMap3.put("info1",300);
+        hashMap3.put("info2",1800);
+        hashMap3.put("info3",200);
+        hashMap3.put("date",3);
+        listMap3.add(hashMap3);
+
+
+        HashMap<String, Object> hashMap4 = new HashMap<>();
+        hashMap4.put("info1",300);
+        hashMap4.put("info2",1800);
+        hashMap4.put("info3",200);
+        hashMap4.put("date",4);
+        listMap3.add(hashMap4);
+
+
+        HashMap<String, Object> hashMap5 = new HashMap<>();
+        hashMap5.put("info1",300);
+        hashMap5.put("info2",1800);
+        hashMap5.put("info3",200);
+        hashMap5.put("date",5);
+        listMap3.add(hashMap5);
+
+        HashMap<String, Object> hashMap6 = new HashMap<>();
+        hashMap6.put("info1",300);
+        hashMap6.put("info2",1800);
+        hashMap6.put("info3",200);
+        hashMap6.put("date",6);
+        listMap3.add(hashMap6);
+
+        HashMap<String, Object> hashMap7 = new HashMap<>();
+        hashMap7.put("info1",300);
+        hashMap7.put("info2",1800);
+        hashMap7.put("info3",200);
+        hashMap7.put("date",7);
+        listMap3.add(hashMap7);
+
+
+
+        HashMap<String, Object> hashMap8 = new HashMap<>();
+        hashMap8.put("info1",300);
+        hashMap8.put("info2",1800);
+        hashMap8.put("info3",200);
+        hashMap8.put("date",8);
+        listMap3.add(hashMap8);
+
+
+        HashMap<String, Object> hashMap9 = new HashMap<>();
+        hashMap9.put("info1",300);
+        hashMap9.put("info2",1800);
+        hashMap9.put("info3",200);
+        hashMap9.put("date",9);
+        listMap3.add(hashMap9);
+
+        HashMap<String, Object> hashMap10 = new HashMap<>();
+        hashMap10.put("info1",300);
+        hashMap10.put("info2",1800);
+        hashMap10.put("info3",200);
+        hashMap10.put("date",10);
+        listMap3.add(hashMap10);
+
+        HashMap<String, Object> hashMap11 = new HashMap<>();
+        hashMap11.put("info1",300);
+        hashMap11.put("info2",1800);
+        hashMap11.put("info3",200);
+        hashMap11.put("date",11);
+        listMap3.add(hashMap11);
+
+        HashMap<String, Object> hashMap12 = new HashMap<>();
+        hashMap12.put("info1",300);
+        hashMap12.put("info2",1800);
+        hashMap12.put("info3",200);
+        hashMap12.put("date",12);
+        listMap3.add(hashMap12);
+
+        REPORTFORMSMAP.put(3,listMap3);
+    }
+
+
+
+
+
+
+
+}

+ 54 - 0
src/main/java/com/sky/ioc/tool/GeneralMethod.java

@@ -0,0 +1,54 @@
+package com.sky.ioc.tool;
+
+import com.alibaba.fastjson.JSONObject;
+import com.sky.ioc.entity.Label;
+import org.apache.poi.ss.formula.functions.T;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.ThreadLocalRandom;
+
+/**
+ * TODO
+ *
+ * @Description  通用方法
+ * @Author LunCe
+ * @Date 2023/3/9 11:42
+ **/
+public class GeneralMethod {
+
+    private volatile static GeneralMethod instance;
+
+    private GeneralMethod(){}
+
+    public static GeneralMethod getInstance(){
+        if (instance == null){
+            synchronized (GeneralMethod.class){
+                if (instance == null){
+                    instance = new GeneralMethod();
+                }
+            }
+        }
+        return instance;
+    }
+
+
+
+    public List<Label> dataGeneration(String[] paramSize, String[] labKey){
+        List<Label> list = new ArrayList<>();
+        ThreadLocalRandom random = ThreadLocalRandom.current();
+        for (int i = 0; i < labKey.length; i++) {
+            Label label = new Label();
+            JSONObject jsonObject = new JSONObject();
+            for (int j = 0; j < paramSize.length; j++) {
+                int i1 = random.nextInt(50, 150);
+                jsonObject.put(paramSize[j],i1);
+            }
+            label.setJsonObject(jsonObject);
+            label.setLabel(labKey[i]);
+            list.add(label);
+        }
+        return list;
+    }
+
+}

+ 46 - 0
src/main/java/com/sky/ioc/tool/JwtUtil.java

@@ -0,0 +1,46 @@
+package com.sky.ioc.tool;
+
+import com.auth0.jwt.JWT;
+import com.auth0.jwt.JWTVerifier;
+import com.auth0.jwt.algorithms.Algorithm;
+import com.auth0.jwt.interfaces.DecodedJWT;
+import com.sky.ioc.entity.domain.system.Users;
+import org.springframework.beans.factory.annotation.Value;
+
+import java.time.Instant;
+import java.time.temporal.ChronoUnit;
+import java.util.Date;
+import java.util.UUID;
+
+public class JwtUtil {
+
+    @Value("${sky.security.key}")
+    private static final String secretKey = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9";
+
+    /**
+     * 生成token
+     *
+     * @param users
+     * @return
+     */
+    public static String genJwtToken(Users users) {
+        String token = JWT.create().withJWTId(UUID.randomUUID().toString()).withAudience("user").withIssuer("sky-ioc-server").withIssuedAt(new Date()).withSubject(users.getUserName()).withClaim("userID", users.getId()).withExpiresAt(Instant.now().plus(16, ChronoUnit.HOURS)).sign(Algorithm.HMAC256(secretKey));
+        return token;
+
+    }
+
+    /**
+     * 解析JWT字符串
+     *
+     * @param token
+     * @return 用户名
+     */
+    public static String parseJWT(String token) {
+        JWTVerifier build = JWT.require(Algorithm.HMAC256(secretKey)).build();
+        DecodedJWT verify = build.verify(token);
+        String username = verify.getSubject();
+        return username;
+    }
+
+}
+

+ 40 - 0
src/main/java/com/sky/ioc/tool/MathUtils.java

@@ -0,0 +1,40 @@
+package com.sky.ioc.tool;
+
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+
+/**
+ * 数字计算
+ * */
+public class MathUtils {
+
+    /**
+     * dividend 被除数
+     * divisor 除数
+     * decimals 保留小数
+     * */
+    public static double division(long dividend,long divisor,Integer decimals){
+        if(dividend==0||divisor==0){
+            return 0;
+        }else{
+            BigDecimal bigDecimal = new BigDecimal(dividend);
+            BigDecimal decimal = bigDecimal.divide(new BigDecimal(divisor), decimals, RoundingMode.HALF_UP);
+            return decimal.doubleValue();
+        }
+    }
+
+    /**
+     * dividend 被除数
+     * divisor 除数
+     * decimals 保留小数
+     * */
+    public static double division(double dividend,double divisor,Integer decimals){
+        if(dividend==0||divisor==0){
+            return 0;
+        }else{
+            BigDecimal bigDecimal = new BigDecimal(dividend);
+            BigDecimal decimal = bigDecimal.divide(new BigDecimal(divisor), decimals, RoundingMode.HALF_UP);
+            return decimal.doubleValue();
+        }
+    }
+}

+ 194 - 0
src/main/java/com/sky/ioc/tool/Pbkdf2Sha256Digest.java

@@ -0,0 +1,194 @@
+package com.sky.ioc.tool;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.crypto.SecretKey;
+import javax.crypto.SecretKeyFactory;
+import javax.crypto.spec.PBEKeySpec;
+import java.math.BigInteger;
+import java.nio.charset.Charset;
+import java.security.NoSuchAlgorithmException;
+import java.security.spec.InvalidKeySpecException;
+import java.security.spec.KeySpec;
+import java.util.Random;
+
+/**
+ * PBKDF2_SHA256加密验证算法
+ */
+public class Pbkdf2Sha256Digest {
+
+    private static final Logger logger = LoggerFactory.getLogger(Pbkdf2Sha256Digest.class);
+
+    /**
+     * 盐的长度
+     */
+    private static final int SALT_BYTE_SIZE = 16;
+
+    /**
+     * 生成密文的长度(例:64 * 4,密文长度为64)
+     */
+    private static final int HASH_BIT_SIZE = 64 * 4;
+
+    /**
+     * 迭代次数(默认迭代次数为 2000)
+     */
+    private static final Integer DEFAULT_ITERATIONS = 260000;
+
+    /**
+     * 算法名称
+     */
+    private static final String algorithm = "pbkdf2:sha256";
+
+    /**
+     * 获取密文
+     * @param password   密码明文
+     * @param salt       加盐
+     * @param iterations 迭代次数
+     * @return
+     */
+    private static String getEncodedHash(String password, String salt, int iterations) {
+        SecretKeyFactory keyFactory = null;
+        try {
+            keyFactory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA256");
+        } catch (NoSuchAlgorithmException e) {
+            logger.error("Could NOT retrieve PBKDF2WithHmacSHA256 algorithm", e);
+        }
+        KeySpec keySpec = new PBEKeySpec(password.toCharArray(), salt.getBytes(Charset.forName("UTF-8")), iterations, HASH_BIT_SIZE);
+        SecretKey secret = null;
+        try {
+            secret = keyFactory.generateSecret(keySpec);
+        } catch (InvalidKeySpecException e) {
+            logger.error("Could NOT generate secret key", e);
+        }
+
+        //使用Base64进行转码密文
+        //        byte[] rawHash = secret.getEncoded();
+        //        byte[] hashBase64 = Base64.getEncoder().encode(rawHash);
+        //        return new String(hashBase64);
+
+        //使用十六进制密文
+        return toHex(secret.getEncoded());
+    }
+
+    /**
+     * 十六进制字符串转二进制字符串
+     * @param hex     十六进制字符串
+     * @return
+     */
+    private static byte[] fromHex(String hex) {
+        byte[] binary = new byte[hex.length() / 2];
+        for (int i = 0; i < binary.length; i++) {
+            binary[i] = (byte) Integer.parseInt(hex.substring(2 * i, 2 * i + 2), 16);
+        }
+        return binary;
+    }
+
+    /**
+     * 二进制字符串转十六进制字符串
+     * @param array     二进制数组
+     * @return
+     */
+    private static String toHex(byte[] array) {
+        BigInteger bi = new BigInteger(1, array);
+        String hex = bi.toString(16);
+        int paddingLength = (array.length * 2) - hex.length();
+        if (paddingLength > 0) {
+            return String.format("%0" + paddingLength + "d", 0) + hex;
+        } else {
+            return hex;
+        }
+    }
+
+    /**
+     * 密文加盐     (获取‘SALT_BYTE_SIZE’长度的盐值)
+     * @return
+     */
+    private static String getsalt() {
+        //盐值使用ASCII表的数字加大小写字母组成
+        int length = SALT_BYTE_SIZE;
+        Random rand = new Random();
+        char[] rs = new char[length];
+        for (int i = 0; i < length; i++) {
+            int t = rand.nextInt(3);
+            if (t == 0) {
+                rs[i] = (char) (rand.nextInt(10) + 48);
+            } else if (t == 1) {
+                rs[i] = (char) (rand.nextInt(26) + 65);
+            } else {
+                rs[i] = (char) (rand.nextInt(26) + 97);
+            }
+        }
+        return new String(rs);
+    }
+
+    /**
+     * 获取密文
+     * 默认迭代次数:2000
+     * @param password      明文密码
+     * @return
+     */
+    public static String encode(String password) {
+        return encode(password, getsalt());
+    }
+
+    /**
+     * 获取密文
+     * @param password      明文密码
+     * @param iterations    迭代次数
+     * @return
+     */
+    private static String encode(String password, int iterations) {
+        return encode(password, getsalt(), iterations);
+    }
+
+    /**
+     * 获取密文
+     * 默认迭代次数:2000
+     * @param password      明文密码
+     * @param salt          盐值
+     * @return
+     */
+    private static String encode(String password, String salt) {
+        return encode(password, salt, DEFAULT_ITERATIONS);
+    }
+
+    /**
+     * 最终返回的整串密文
+     *
+     * 注:此方法返回密文字符串组成:算法名称+迭代次数+盐值+密文
+     * 不需要的直接用getEncodedHash方法返回的密文
+     *
+     * @param password   密码明文
+     * @param salt       加盐
+     * @param iterations 迭代次数
+     * @return
+     */
+    private static String encode(String password, String salt, int iterations) {
+        // returns hashed password, along with algorithm, number of iterations and salt
+        String hash = getEncodedHash(password, salt, iterations);
+        return String.format("%s:%d$%s$%s", algorithm, iterations, salt, hash);
+    }
+
+    /**
+     * 验证密码
+     * @param password       明文
+     * @param hashedPassword 密文
+     * @return
+     */
+    public static boolean verification(String password, String hashedPassword) {
+        //hashedPassword = 算法名称+迭代次数+盐值+密文;
+        String[] parts = hashedPassword.split("\\$");
+        if (parts.length != 3) {
+            return false;
+        }
+        String[] params = parts[0].split(":");
+        //解析得到迭代次数和盐值进行盐值
+        Integer iterations = Integer.parseInt(params[2]);
+        String salt = parts[1];
+        String hash = encode(password, salt, iterations);
+        return hash.equals(hashedPassword);
+    }
+
+}
+

+ 24 - 0
src/main/java/com/sky/ioc/tool/RedisUtil.java

@@ -0,0 +1,24 @@
+package com.sky.ioc.tool;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.stereotype.Component;
+
+@Component
+public class RedisUtil {
+
+    @Autowired
+    private RedisTemplate redisTemplate;
+
+    public void put(String key , Object object) {
+        redisTemplate.opsForValue().set(key, object);
+    }
+
+    public Object get(String key) {
+        return redisTemplate.opsForValue().get(key);
+    }
+
+    public void delete(String key) {
+        redisTemplate.delete(key);
+    }
+}

+ 71 - 0
src/main/java/com/sky/ioc/tool/ReturnMsg.java

@@ -0,0 +1,71 @@
+package com.sky.ioc.tool;
+
+
+import com.sky.ioc.constant.Constant;
+import lombok.Data;
+import lombok.extern.slf4j.Slf4j;
+
+/***
+ * 接口返回消息封装管理工具
+ * @author LunCe
+ */
+@Data
+@Slf4j
+public class ReturnMsg<T> {
+
+    private int code;
+
+    private String msg;
+
+    private T data;
+
+    public static <T> ReturnMsg<T> ok()
+    {
+        return restResult(null, Constant.MSG_CODE.SUCCESS, "操作成功");
+    }
+
+    public static <T> ReturnMsg<T> ok(T data)
+    {
+        return restResult(data, Constant.MSG_CODE.SUCCESS, "操作成功");
+    }
+
+    public static <T> ReturnMsg<T> ok(T data, String msg)
+    {
+        return restResult(data, Constant.MSG_CODE.SUCCESS, msg);
+    }
+
+    public static <T> ReturnMsg<T> fail()
+    {
+        return restResult(null, Constant.MSG_CODE.SERVER_ERROR, "操作失败");
+    }
+
+    public static <T> ReturnMsg<T> fail(String msg)
+    {
+        return restResult(null, Constant.MSG_CODE.SERVER_ERROR, msg);
+    }
+
+    public static <T> ReturnMsg<T> fail(T data)
+    {
+        return restResult(data, Constant.MSG_CODE.SERVER_ERROR, "操作失败");
+    }
+
+    public static <T> ReturnMsg<T> fail(T data, String msg)
+    {
+        return restResult(data, Constant.MSG_CODE.SERVER_ERROR, msg);
+    }
+
+    public static <T> ReturnMsg<T> fail(int code, String msg)
+    {
+        return restResult(null, code, msg);
+    }
+
+    private static <T> ReturnMsg<T> restResult(T data, int code, String msg)
+    {
+        ReturnMsg<T> apiResult = new ReturnMsg<>();
+        apiResult.setCode(code);
+        apiResult.setData(data);
+        apiResult.setMsg(msg);
+        return apiResult;
+    }
+
+}

+ 54 - 0
src/main/resources/application-dev.yml

@@ -0,0 +1,54 @@
+# 开发环境
+server:
+  port: 10099
+  servlet:
+    context-path: /
+
+# 数据源
+spring:
+  ## quartz定时任务,采用数据库方式
+  quartz:
+    #相关属性配置
+    properties:
+      org:
+        quartz:
+          jobStore:
+            driverDelegateClass: org.quartz.impl.jdbcjobstore.PostgreSQLDelegate
+    #数据库方式
+    job-store-type: jdbc
+  datasource:
+    druid:
+      url: jdbc:postgresql://121.43.55.7:5433/building?stringtype=unspecified&u003fuseUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&serverTimezone=PRC&useSSL=false&tinyInt1isBit=false
+      username: postgres
+      password: SKYversation@0816
+  redis:
+    host: 121.43.55.7
+    port: 6380
+    database: 12
+    password: SKYversation
+  rabbitmq:
+    host: 8.130.177.22
+    port: 5672
+    username: admin
+    password: aaaaaa
+  mqtt:
+    url: tcp://10.12.242.162:1883
+    topic: notice/device/status/safety/camera,notice/device/status/energy/device
+    username: device
+    password: device123
+    completionTimeout: 3000
+
+
+
+# 日志配置
+logging:
+  level:
+    com.sky: debug
+
+# Swagger配置
+swagger:
+  enabled: true
+
+# 自定义配置
+sky:
+  dataIp: 192.168.1.45:9001

+ 51 - 0
src/main/resources/application-publish.yml

@@ -0,0 +1,51 @@
+# 开发环境
+server:
+  port: 10099
+  servlet:
+    context-path: /
+
+# 数据源
+spring:
+  ## quartz定时任务,采用数据库方式
+  quartz:
+    #相关属性配置
+    properties:
+      org:
+        quartz:
+          jobStore:
+            driverDelegateClass: org.quartz.impl.jdbcjobstore.PostgreSQLDelegate
+    #数据库方式
+    job-store-type: jdbc
+  datasource:
+    druid:
+      url: jdbc:postgresql://10.12.242.163:5432/building?stringtype=unspecified&u003fuseUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&serverTimezone=PRC&useSSL=false&tinyInt1isBit=false
+      username: postgres
+      password: postgres
+  redis:
+    host: 10.12.242.163
+    port: 6380
+    database: 0
+    password: skyversation
+  rabbitmq:
+    host: 8.130.177.22
+    port: 5672
+    username: admin
+    password: aaaaaa
+  mqtt:
+    url: tcp://10.12.242.162:1883
+    topic: notice/device/status/safety/camera,notice/device/status/energy/device
+    username: device
+    password: device123
+    completionTimeout: 3000
+
+# 日志配置
+logging:
+  level:
+    com.sky: debug
+
+# Swagger配置
+swagger:
+  enabled: true
+# 自定义配置
+sky:
+  dataIp: 10.12.242.162:80

+ 110 - 0
src/main/resources/application.yml

@@ -0,0 +1,110 @@
+server:
+  # 端口
+  port: 10099
+  servlet:
+    # 访问路径
+    context-path: /
+  tomcat:
+    # tomcat的URI编码
+    uri-encoding: UTF-8
+
+# Spring配置
+spring:
+  # 环境设置
+  profiles:
+    active: publish
+  # 数据源配置
+  datasource:
+    type: com.alibaba.druid.pool.DruidDataSource
+    driverClassName: org.postgresql.Driver
+    druid:
+      url: jdbc:postgresql://${IOC_DB_IP:127.0.0.1}:${IOC_DB_PORT:5433}/ioc?currentSchema=public&stringtype=unspecified&u003fuseUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&serverTimezone=PRC&useSSL=false&tinyInt1isBit=false
+      username: ${IOC_DB_USER:postgres}
+      password: ${IOC_DB_PASSWORD:SKYversation0816}
+      # 初始连接数
+      initialSize: 5
+      # 最小连接池数量
+      minIdle: 10
+      # 最大连接池数量
+      maxActive: 20
+      # 配置获取连接等待超时的时间
+      maxWait: 60000
+      # 配置连接超时时间
+      connectTimeout: 30000
+      # 配置网络超时时间
+      socketTimeout: 60000
+      # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
+      timeBetweenEvictionRunsMillis: 60000
+      # 配置一个连接在池中最小生存的时间,单位是毫秒
+      minEvictableIdleTimeMillis: 300000
+      # 配置一个连接在池中最大生存的时间,单位是毫秒
+      maxEvictableIdleTimeMillis: 900000
+      # 配置检测连接是否有效
+      validationQuery: SELECT 1
+      testWhileIdle: true
+      testOnBorrow: false
+      testOnReturn: false
+      webStatFilter:
+        enabled: true
+      # 控制台设置
+      statViewServlet:
+        enabled: true
+        allow:
+        url-pattern: /druid/*
+        login-username: iocDbAdmin
+        login-password: 123456
+      filter:
+        stat:
+          enabled: true
+          # 慢SQL记录
+          log-slow-sql: true
+          slow-sql-millis: 1000
+          merge-sql: true
+        wall:
+          config:
+            multi-statement-allow: true
+  # redis 配置
+  redis:
+    host: ${IOC_REDIS_IP:127.0.0.1}
+    port: ${IOC_REDIS_PORT:6379}
+    database: ${IOC_REDIS_DB:0}
+    password: ${IOC_REDIS_PASSWORD:}
+  # json 配置
+  jackson:
+    time-zone: GMT+8
+    date-format: yyyy-MM-dd HH:mm:ss
+
+# MyBatis
+mybatis-plus:
+  # 搜索指定包别名
+  type-aliases-package: com.sky.**.entity.domain
+  # 配置mapper xml的扫描路径
+  mapperLocations: classpath*:mapper/**/*Mapper.xml
+  configuration:
+    # 字段名驼峰映射
+    map-underscore-to-camel-case: true
+    # 日志输出
+    log-impl: org.apache.ibatis.logging.slf4j.Slf4jImpl
+  global-config:
+    # 启动时logo输出
+    banner: false
+
+# PageHelper分页插件
+pagehelper:
+  helperDialect: postgresql
+  supportMethodsArguments: true
+  params: count=countSql
+
+# Swagger配置
+swagger:
+  # 是否开启swagger
+  enabled: false
+
+# 日志配置
+logging:
+  level:
+    com.sky: info
+
+# 自定义配置
+sky:
+  name: 智慧运营管理中心