Parcourir la source

提交后端代码

wanxl il y a 2 ans
Parent
commit
29a7b05c1f
100 fichiers modifiés avec 9836 ajouts et 0 suppressions
  1. 38 0
      .gitignore
  2. BIN
      modelProject.zip
  3. 253 0
      pom.xml
  4. 84 0
      src/main/java/com/template/AutoCode.java
  5. 19 0
      src/main/java/com/template/NaYongApplication.java
  6. 12 0
      src/main/java/com/template/annotation/ControllerIsShow.java
  7. 17 0
      src/main/java/com/template/annotation/DESRespondSecret.java
  8. 18 0
      src/main/java/com/template/annotation/ExcelExport.java
  9. 20 0
      src/main/java/com/template/annotation/ExcelImport.java
  10. 28 0
      src/main/java/com/template/annotation/PassToken.java
  11. 14 0
      src/main/java/com/template/annotation/UserLoginCheck.java
  12. 45 0
      src/main/java/com/template/aop/LoginCheckAspect.java
  13. 16 0
      src/main/java/com/template/common/constanst/Constanst.java
  14. 14 0
      src/main/java/com/template/common/exception/EmsException.java
  15. 199 0
      src/main/java/com/template/common/exception/EmsExceptionHandler.java
  16. 29 0
      src/main/java/com/template/common/exception/MyCustomException.java
  17. 43 0
      src/main/java/com/template/common/jh/ReqRespResearchProductQuestionnaireItem.java
  18. 243 0
      src/main/java/com/template/common/jh/SectionUtil.java
  19. 86 0
      src/main/java/com/template/common/mqtt/MqttConfiguration.java
  20. 166 0
      src/main/java/com/template/common/mqtt/MqttPushClient.java
  21. 209 0
      src/main/java/com/template/common/mqtt/PushCallback.java
  22. 35 0
      src/main/java/com/template/common/result/BaseResult.java
  23. 7 0
      src/main/java/com/template/common/result/Code.java
  24. 156 0
      src/main/java/com/template/common/result/CommonResult.java
  25. 63 0
      src/main/java/com/template/common/result/PageUtils.java
  26. 83 0
      src/main/java/com/template/common/result/ResponseStatusEnum.java
  27. 30 0
      src/main/java/com/template/common/result/UnitTimeHelpModel.java
  28. 23 0
      src/main/java/com/template/common/utils/AccessToken.java
  29. 84 0
      src/main/java/com/template/common/utils/AesTestOne.java
  30. 165 0
      src/main/java/com/template/common/utils/AesUtil.java
  31. 199 0
      src/main/java/com/template/common/utils/AesUtils.java
  32. 47 0
      src/main/java/com/template/common/utils/Base64Util.java
  33. 211 0
      src/main/java/com/template/common/utils/CommonUtil.java
  34. 9 0
      src/main/java/com/template/common/utils/DataBliu.java
  35. 241 0
      src/main/java/com/template/common/utils/DateUtils.java
  36. 82 0
      src/main/java/com/template/common/utils/EncryptUtil.java
  37. 41 0
      src/main/java/com/template/common/utils/EncryptionUtil.java
  38. 75 0
      src/main/java/com/template/common/utils/ExcelClassField.java
  39. 22 0
      src/main/java/com/template/common/utils/ExcelUtil3.java
  40. 64 0
      src/main/java/com/template/common/utils/ExcelUtils.java
  41. 1008 0
      src/main/java/com/template/common/utils/ExcelUtils2.java
  42. 76 0
      src/main/java/com/template/common/utils/FileUtils.java
  43. 18 0
      src/main/java/com/template/common/utils/GetVertifyCode.java
  44. 241 0
      src/main/java/com/template/common/utils/HttpClientUtils.java
  45. 112 0
      src/main/java/com/template/common/utils/HttpUtils.java
  46. 530 0
      src/main/java/com/template/common/utils/HttpsClient.java
  47. 54 0
      src/main/java/com/template/common/utils/Md5Utils.java
  48. 548 0
      src/main/java/com/template/common/utils/Message.java
  49. 113 0
      src/main/java/com/template/common/utils/Message2.java
  50. 23 0
      src/main/java/com/template/common/utils/MyX509TrustManager.java
  51. 99 0
      src/main/java/com/template/common/utils/PropertiesUtil.java
  52. 196 0
      src/main/java/com/template/common/utils/RSAUtils.java
  53. 32 0
      src/main/java/com/template/common/utils/RandomTrackAlgorithm.java
  54. 126 0
      src/main/java/com/template/common/utils/RequestUtils.java
  55. 42 0
      src/main/java/com/template/common/utils/SHA1.java
  56. 213 0
      src/main/java/com/template/common/utils/SendSms.java
  57. 731 0
      src/main/java/com/template/common/utils/TimeExchange.java
  58. 628 0
      src/main/java/com/template/common/utils/TimeExchange2.java
  59. 25 0
      src/main/java/com/template/common/utils/UUIDUtil.java
  60. 25 0
      src/main/java/com/template/common/utils/ValidateCode.java
  61. 52 0
      src/main/java/com/template/common/utils/WxConfig.java
  62. 53 0
      src/main/java/com/template/common/utils/WxConstants.java
  63. 385 0
      src/main/java/com/template/common/utils/WxUtil.java
  64. 47 0
      src/main/java/com/template/common/utils/imageUtils.java
  65. 27 0
      src/main/java/com/template/common/utils/paramUtils.java
  66. 25 0
      src/main/java/com/template/common/utils/smsUtil.java
  67. 52 0
      src/main/java/com/template/config/MyBatisPlusConfig.java
  68. 36 0
      src/main/java/com/template/config/smsConfig.java
  69. 79 0
      src/main/java/com/template/controller/CompaniesController.java
  70. 47 0
      src/main/java/com/template/controller/CompaniesPDViewController.java
  71. 21 0
      src/main/java/com/template/controller/ConfigsController.java
  72. 42 0
      src/main/java/com/template/controller/DevicesAlarmController.java
  73. 40 0
      src/main/java/com/template/controller/DevicesCViewController.java
  74. 59 0
      src/main/java/com/template/controller/DevicesController.java
  75. 21 0
      src/main/java/com/template/controller/PostionsController.java
  76. 38 0
      src/main/java/com/template/controller/RecordDViewController.java
  77. 115 0
      src/main/java/com/template/controller/RecordsController.java
  78. 38 0
      src/main/java/com/template/controller/RepairsController.java
  79. 21 0
      src/main/java/com/template/controller/UsersController.java
  80. 21 0
      src/main/java/com/template/controller/UsersOnDevicesController.java
  81. 26 0
      src/main/java/com/template/handle/NonStaticResourceHttpRequestHandler.java
  82. 60 0
      src/main/java/com/template/handler/MyMetaObjectHandler.java
  83. 16 0
      src/main/java/com/template/mapper/CompaniesMapper.java
  84. 16 0
      src/main/java/com/template/mapper/CompaniesPDViewMapper.java
  85. 16 0
      src/main/java/com/template/mapper/ConfigsMapper.java
  86. 16 0
      src/main/java/com/template/mapper/DevicesAlarmMapper.java
  87. 16 0
      src/main/java/com/template/mapper/DevicesCViewMapper.java
  88. 16 0
      src/main/java/com/template/mapper/DevicesMapper.java
  89. 16 0
      src/main/java/com/template/mapper/PostionsMapper.java
  90. 16 0
      src/main/java/com/template/mapper/RecordDViewMapper.java
  91. 31 0
      src/main/java/com/template/mapper/RecordsMapper.java
  92. 27 0
      src/main/java/com/template/mapper/RepairsMapper.java
  93. 16 0
      src/main/java/com/template/mapper/UsersMapper.java
  94. 16 0
      src/main/java/com/template/mapper/UsersOnDevicesMapper.java
  95. 50 0
      src/main/java/com/template/model/Companies.java
  96. 57 0
      src/main/java/com/template/model/CompaniesPDView.java
  97. 37 0
      src/main/java/com/template/model/Configs.java
  98. 74 0
      src/main/java/com/template/model/Devices.java
  99. 65 0
      src/main/java/com/template/model/DevicesAlarm.java
  100. 0 0
      src/main/java/com/template/model/DevicesCView.java

+ 38 - 0
.gitignore

@@ -0,0 +1,38 @@
+# Java
+*.class
+*.jar
+*.war
+*.ear
+
+# Eclipse
+.project
+.classpath
+.settings
+
+# Idea
+.idea
+*.iml
+*.iws
+*.ipr
+
+# OS
+Thumbs.db
+.DS_Store
+
+# Gradle
+.gradle
+!gradle-wrapper.jar
+
+# Maven
+target
+
+# Build
+out
+build
+bin
+
+# Other
+*.log
+*.swp
+*.bak
+

BIN
modelProject.zip


+ 253 - 0
pom.xml

@@ -0,0 +1,253 @@
+<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-starter-parent</artifactId>
+        <version>2.4.0</version>
+        <relativePath/> <!-- lookup parent from repository -->
+    </parent>
+    <groupId>com.template</groupId>
+    <artifactId>nayong</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+    <name>nayong</name>
+    <description>Demo project for Spring Boot</description>
+
+    <properties>
+        <java.version>1.8</java.version>
+        <tencent.qcloudsms.version>1.0.6</tencent.qcloudsms.version>
+    </properties>
+
+    <dependencies>
+
+        <dependency>
+            <groupId>javax.validation</groupId>
+            <artifactId>validation-api</artifactId>
+            <version>2.0.1.Final</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.hibernate</groupId>
+            <artifactId>hibernate-validator</artifactId>
+            <version>6.1.5.Final</version>
+        </dependency>
+
+        <!--   读取excel数据     -->
+        <dependency>
+            <groupId>org.apache.poi</groupId>
+            <artifactId>poi</artifactId>
+            <version>4.1.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.poi</groupId>
+            <artifactId>poi-ooxml</artifactId>
+            <version>4.1.0</version>
+        </dependency>
+
+        <!-- fastjson -->
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>fastjson</artifactId>
+            <version>2.0.12</version>
+        </dependency>
+
+        <!--引入JWT-->
+        <dependency>
+            <groupId>com.auth0</groupId>
+            <artifactId>java-jwt</artifactId>
+            <version>3.10.0</version>
+        </dependency>
+        <dependency>
+            <groupId>io.jsonwebtoken</groupId>
+            <artifactId>jjwt</artifactId>
+            <version>0.9.1</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.github.qcloudsms</groupId>
+            <artifactId>qcloudsms</artifactId>
+            <version>${tencent.qcloudsms.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.tencentcloudapi</groupId>
+            <artifactId>tencentcloud-sdk-java</artifactId>
+            <version>3.1.742</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-aop</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpclient</artifactId>
+            <version>4.5.10</version>
+        </dependency>
+        <dependency>
+            <groupId>com.google.code.gson</groupId>
+            <artifactId>gson</artifactId>
+            <version>2.8.7</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-quartz</artifactId>
+        </dependency>
+        <!-- 数据库驱动 -->
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+        </dependency>
+        <!-- lombok -->
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+        </dependency>
+        <!-- mybatis-plus -->
+        <!-- mybatis-plus 是自己开发,并非官方的! -->
+        <dependency>
+            <groupId>com.baomidou</groupId>
+            <artifactId>mybatis-plus-boot-starter</artifactId>
+            <version>3.0.5</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.junit.vintage</groupId>
+                    <artifactId>junit-vintage-engine</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-web</artifactId>
+            <version>5.3.22</version>
+        </dependency>
+
+        <!-- https://mvnrepository.com/artifact/org.eclipse.jgit/org.eclipse.jgit -->
+        <dependency>
+            <groupId>org.eclipse.jgit</groupId>
+            <artifactId>org.eclipse.jgit</artifactId>
+            <version>5.4.3.201909031940-r</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-configuration-processor</artifactId>
+            <optional>true</optional>
+        </dependency>
+
+        <!-- redis -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-redis</artifactId>
+            <exclusions>
+                <exclusion>
+                    <groupId>io.lettuce</groupId>
+                    <artifactId>lettuce-core</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+
+        <dependency>
+            <groupId>redis.clients</groupId>
+            <artifactId>jedis</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>io.springfox</groupId>
+            <artifactId>springfox-swagger2</artifactId>
+            <version>2.9.2</version>
+        </dependency>
+        <dependency>
+            <groupId>io.springfox</groupId>
+            <artifactId>springfox-swagger-ui</artifactId>
+            <version>2.9.2</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.velocity</groupId>
+            <artifactId>velocity-engine-core</artifactId>
+            <version>2.0</version>
+        </dependency>
+        <dependency>
+            <groupId>jakarta.validation</groupId>
+            <artifactId>jakarta.validation-api</artifactId>
+            <version>2.0.2</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.qcloud</groupId>
+            <artifactId>cos_api</artifactId>
+            <version>5.6.155</version>
+        </dependency>
+
+
+        <!--hutools-->
+        <dependency>
+            <groupId>cn.hutool</groupId>
+            <artifactId>hutool-all</artifactId>
+            <version>5.4.3</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.github.pagehelper</groupId>
+            <artifactId>pagehelper-spring-boot-starter</artifactId>
+            <version>1.4.2</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-test</artifactId>
+            <version>6.0.9</version>
+            <scope>compile</scope>
+        </dependency>
+
+        <!-- 上传文件的依赖 -->
+        <dependency>
+            <!--common-fileupload的依赖组件-->
+            <groupId>commons-io</groupId>
+            <artifactId>commons-io</artifactId>
+            <version>2.6</version>
+        </dependency>
+        <dependency>
+            <groupId>commons-fileupload</groupId>
+            <artifactId>commons-fileupload</artifactId>
+            <version>1.4</version>
+        </dependency>
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>druid</artifactId>
+            <version>1.2.16</version>
+        </dependency>
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>easyexcel</artifactId>
+            <version>2.2.11</version>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.paho</groupId>
+            <artifactId>org.eclipse.paho.client.mqttv3</artifactId>
+            <version>1.2.5</version>
+            <scope>compile</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

+ 84 - 0
src/main/java/com/template/AutoCode.java

@@ -0,0 +1,84 @@
+package com.template;
+
+import com.baomidou.mybatisplus.annotation.DbType;
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.generator.AutoGenerator;
+import com.baomidou.mybatisplus.generator.config.DataSourceConfig;
+import com.baomidou.mybatisplus.generator.config.GlobalConfig;
+import com.baomidou.mybatisplus.generator.config.PackageConfig;
+import com.baomidou.mybatisplus.generator.config.StrategyConfig;
+import com.baomidou.mybatisplus.generator.config.po.TableFill;
+import com.baomidou.mybatisplus.generator.config.rules.DateType;
+import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
+
+import java.util.ArrayList;
+
+/**
+ * @Author: binguo
+ * @Date: 2023/3/30 星期四 15:46
+ * @Description: com.video
+ * @Version: 1.0
+ */
+public class AutoCode {
+    public static void main(String[] args) {
+// 需要构建一个 代码自动生成器 对象
+        AutoGenerator mpg = new AutoGenerator();
+// 配置策略
+// 1、全局配置
+        GlobalConfig gc = new GlobalConfig();
+        String projectPath = System.getProperty("user.dir");
+        gc.setOutputDir(projectPath + "/src/main/java");
+        gc.setAuthor("ceshi");
+        gc.setOpen(false);
+        gc.setFileOverride(false); // 是否覆盖
+        gc.setServiceName("%sService"); // 去Service的I前缀
+        gc.setIdType(IdType.UUID);
+        gc.setDateType(DateType.ONLY_DATE);
+        gc.setSwagger2(true);
+        mpg.setGlobalConfig(gc);
+//2、设置数据源
+        DataSourceConfig dsc = new DataSourceConfig();
+        dsc.setUrl("jdbc:mysql://172.16.40.109:3306/fangcang_new?useUnicode=tru&characterEncoding=UTF-8&useSSL=false&useAffectedRows=true&allowPublicKeyRetrieval=true&allowMultiQueries=true&rewriteBatchedStatements=true&serverTimezone=Asia/Shanghai");
+        dsc.setDriverName("com.mysql.cj.jdbc.Driver");
+        dsc.setUsername("root");
+        dsc.setPassword("Password123.");
+        dsc.setDbType(DbType.MYSQL);
+        mpg.setDataSource(dsc);
+        //3、包的配置
+        PackageConfig pc = new PackageConfig();
+//        pc.setModuleName("nayong");
+        pc.setParent("com.template");
+        pc.setEntity("model");
+        pc.setMapper("mapper");
+        pc.setService("services");
+        pc.setController("controller");
+        mpg.setPackageInfo(pc);
+        //4、策略配置
+        StrategyConfig strategy = new StrategyConfig();
+        strategy.setInclude("devices_alarm"); // 设置要映射的表名
+        strategy.setNaming(NamingStrategy.underline_to_camel);//下划线转驼峰
+        strategy.setColumnNaming(NamingStrategy.underline_to_camel);//下划线转驼峰
+        strategy.setEntityLombokModel(true); // 自动lombok;
+        strategy.setLogicDeleteFieldName("deleted");//逻辑删除 调用service的删除方法不会真删除 会把deleted字段的值改为1 (未删除="0",删除="1")
+        // 自动填充配置
+        TableFill deletedCreate = new TableFill("deleted", FieldFill.INSERT);
+        TableFill timeCreate = new TableFill("create_time", FieldFill.INSERT);
+        TableFill userCreate = new TableFill("create_user", FieldFill.INSERT);
+        TableFill timeModified = new TableFill("update_time", FieldFill.INSERT_UPDATE);
+        TableFill userModified = new TableFill("update_user", FieldFill.INSERT_UPDATE);
+        ArrayList<TableFill> tableFills = new ArrayList<>();
+        tableFills.add(deletedCreate);
+        tableFills.add(timeCreate);
+        tableFills.add(userCreate);
+        tableFills.add(timeModified);
+        tableFills.add(userModified);
+        strategy.setTableFillList(tableFills);
+        // 乐观锁
+        strategy.setVersionFieldName("version");
+        strategy.setRestControllerStyle(true);
+        strategy.setControllerMappingHyphenStyle(true); //localhost:8080/hello_id_2
+        mpg.setStrategy(strategy);
+        mpg.execute(); //执行
+    }
+}

+ 19 - 0
src/main/java/com/template/NaYongApplication.java

@@ -0,0 +1,19 @@
+package com.template;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cache.annotation.EnableCaching;
+import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
+
+@EnableCaching//开启缓存
+@SpringBootApplication
+@EnableTransactionManagement //开启事务回滚
+@EnableScheduling // 开启定时任务
+public class NaYongApplication {
+
+    public static void main(String[] args) {
+
+        SpringApplication.run(NaYongApplication.class, args);
+    }
+}

+ 12 - 0
src/main/java/com/template/annotation/ControllerIsShow.java

@@ -0,0 +1,12 @@
+package com.template.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target(value = {ElementType.METHOD, ElementType.TYPE})
+@Retention(RetentionPolicy.RUNTIME)
+public @interface ControllerIsShow {
+    String value() default "";
+}

+ 17 - 0
src/main/java/com/template/annotation/DESRespondSecret.java

@@ -0,0 +1,17 @@
+package com.template.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * 返回参数加密注解
+ */
+
+//可以作用在类上和方法上
+@Target(value = {ElementType.METHOD, ElementType.TYPE})
+@Retention(RetentionPolicy.RUNTIME)
+public @interface DESRespondSecret {
+    boolean validated() default true;
+}

+ 18 - 0
src/main/java/com/template/annotation/ExcelExport.java

@@ -0,0 +1,18 @@
+package com.template.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target({ElementType.FIELD})
+@Retention(RetentionPolicy.RUNTIME)
+public @interface ExcelExport {
+    String value();
+
+    int sort() default 0;
+
+    String kv() default "";
+
+    String example() default "";
+}

+ 20 - 0
src/main/java/com/template/annotation/ExcelImport.java

@@ -0,0 +1,20 @@
+package com.template.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target({ElementType.FIELD})
+@Retention(RetentionPolicy.RUNTIME)
+public @interface ExcelImport {
+    String value();
+
+    String kv() default "";
+
+    boolean required() default false;
+
+    int maxLength() default 255;
+
+    boolean unique() default false;
+}

+ 28 - 0
src/main/java/com/template/annotation/PassToken.java

@@ -0,0 +1,28 @@
+package com.template.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/** 说明
+ * 在方法上加入本注解 即可接口拦截
+ * @interface:代表当前类是注解
+ * @Target:描述当前的注解可以定义在扫描资源上。
+ * 属性value:
+ *     定义具体的资源。包括:
+ *     ElementType.METHOD:可以定义在方法上
+ *     ElementType.TYPE:可以定义在类上
+ *     ElementType.FIELD:可以定义在属性上
+ *     ElementType.PARAMETER:可以定义在方法参数上
+ * @Retention:当前注解在什么时候有效
+ *     定义具体的生效标记
+ *     RetentionPolicy.RUNTIME:运行时有效
+ *     RetentionPolicy.SOURCE:源码中有效
+ *     RetentionPolicy.CLASS:字节码有效
+ *///说明 该注解要加在控制器中的方法上才会生效 加在api中无法生效
+@Target(value = {ElementType.METHOD, ElementType.TYPE})
+@Retention(RetentionPolicy.RUNTIME)
+public @interface PassToken {
+    boolean requeired() default true;
+}

+ 14 - 0
src/main/java/com/template/annotation/UserLoginCheck.java

@@ -0,0 +1,14 @@
+package com.template.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Target;
+
+/**
+ * @Author: binguo
+ * @Date: 2023/4/10 星期一 14:04
+ * @Description: com.video.services.annotation
+ * @Version: 1.0
+ */
+@Target(ElementType.METHOD)
+public @interface UserLoginCheck {
+}

+ 45 - 0
src/main/java/com/template/aop/LoginCheckAspect.java

@@ -0,0 +1,45 @@
+package com.template.aop;
+
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.After;
+import org.aspectj.lang.annotation.Around;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Before;
+import org.springframework.core.annotation.Order;
+import org.springframework.stereotype.Component;
+
+/**
+ * @Author: binguo
+ * @Date: 2023/4/10 星期一 14:10
+ * @Description: com.video.aop
+ * @Version: 1.0
+ */
+@Aspect//把当前类标识作为一个切面供容器读取
+@Component//将此类标记为Spring容器中的一个Bean
+@Order(0)//order的值越小,优先级越高 order如果不标注数字,默认最低优先级,因为其默认值是int最大值
+public class LoginCheckAspect {
+
+    @Around("@annotation(com.template.annotation.UserLoginCheck)")
+    public Object userLoginCheck(ProceedingJoinPoint process) throws Throwable {
+        System.out.println("用户登录检测机制");
+        if(1 == 1){
+           //通过抛异常方式拦截
+           // throw new Exception("非法登录");
+        }
+
+        Object proceed;
+        proceed = process.proceed();//执行目标方法
+        return proceed;//将执行目标方法后的返回值返回出去
+    }
+
+    @After("@annotation(com.template.annotation.UserLoginCheck)")
+    public void test(){
+        System.out.println("测试After");
+    }
+
+    @Before("@annotation(com.template.annotation.UserLoginCheck)")
+    public void test1(){
+        System.out.println("测试Before");
+    }
+
+}

+ 16 - 0
src/main/java/com/template/common/constanst/Constanst.java

@@ -0,0 +1,16 @@
+package com.template.common.constanst;
+
+/**
+ * <p>Title: Constanst</p>
+ * <p>Description: 系统所用到的常量 </p>
+ * @author fengyong
+ * @date 2018年9月7日
+ */
+public class Constanst {
+	
+	/**
+	 * 自定义加密措施
+	 */
+	public static final String PWD_MD5 = "FeNG#@YOnG";
+
+}

+ 14 - 0
src/main/java/com/template/common/exception/EmsException.java

@@ -0,0 +1,14 @@
+package com.template.common.exception;
+
+import com.template.common.result.ResponseStatusEnum;
+
+/**
+ * 处理异常,统一封装
+ */
+public class EmsException {
+
+    public static void display(ResponseStatusEnum responseStatusEnum) {
+        throw new MyCustomException(responseStatusEnum);
+    }
+
+}

+ 199 - 0
src/main/java/com/template/common/exception/EmsExceptionHandler.java

@@ -0,0 +1,199 @@
+package com.template.common.exception;
+
+import com.fasterxml.jackson.core.JsonParseException;
+import com.template.common.result.CommonResult;
+import com.template.common.result.ResponseStatusEnum;
+import org.mybatis.spring.MyBatisSystemException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.context.support.DefaultMessageSourceResolvable;
+import org.springframework.http.converter.HttpMessageNotReadableException;
+import org.springframework.validation.BindException;
+import org.springframework.validation.BindingResult;
+import org.springframework.validation.FieldError;
+import org.springframework.web.HttpRequestMethodNotSupportedException;
+import org.springframework.web.bind.MethodArgumentNotValidException;
+import org.springframework.web.bind.MissingServletRequestParameterException;
+import org.springframework.web.bind.annotation.ControllerAdvice;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import com.fasterxml.jackson.databind.exc.InvalidFormatException;
+import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
+
+import javax.validation.ConstraintViolation;
+import javax.validation.ConstraintViolationException;
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * 统一异常拦截处理
+ * 可以针对异常的类型进行捕获,然后返回json信息到前端
+ */
+@ControllerAdvice
+public class EmsExceptionHandler {
+
+    //org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'GET' not supported
+    final static Logger logger=LoggerFactory.getLogger(EmsExceptionHandler.class);
+
+    //处理Get请求中 使用@Valid 验证路径中请求实体校验失败后抛出的异常
+    @ExceptionHandler(BindException.class)
+    @ResponseBody
+    public CommonResult BindExceptionHandler(BindException e) {
+        String message = e.getBindingResult().getAllErrors().stream().map(DefaultMessageSourceResolvable::getDefaultMessage).collect(Collectors.joining());
+        logger.error("错误信息",message);
+        return CommonResult.resultValue(ResponseStatusEnum.SYSTEM_NULL_POINTER);
+    }
+
+    //处理请求参数格式错误 @RequestParam上validate失败后抛出的异常是javax.validation.ConstraintViolationException
+    @ExceptionHandler(ConstraintViolationException.class)
+    @ResponseBody
+    public CommonResult ConstraintViolationExceptionHandler(ConstraintViolationException e) {
+        String message = e.getConstraintViolations().stream().map(ConstraintViolation::getMessage).collect(Collectors.joining());
+        logger.error("错误信息",message);
+        return CommonResult.resultValue(ResponseStatusEnum.SYSTEM_NULL_POINTER);
+    }
+
+    @ResponseBody
+    @ExceptionHandler(NullPointerException.class)
+    public CommonResult exception(NullPointerException e) {
+        e.printStackTrace();
+        //String error=e.getFieldError().getDefaultMessage();
+        logger.error("错误信息",e.fillInStackTrace());
+        return CommonResult.resultValue(ResponseStatusEnum.SYSTEM_NULL_POINTER);
+    }
+
+    @ExceptionHandler(Exception.class)
+    @ResponseBody
+    public CommonResult exception(Exception e) {
+        e.printStackTrace();
+        logger.error("错误信息",e.fillInStackTrace());
+        return CommonResult.fail(e.getMessage());
+    }
+
+    //mysql连接超时
+    @ExceptionHandler(MyBatisSystemException.class)
+    @ResponseBody
+    public CommonResult exception(MyBatisSystemException e) {
+        e.printStackTrace();
+        //String error=e.getFieldError().getDefaultMessage();
+        logger.error("错误信息",e.fillInStackTrace());
+        return CommonResult.resultValue(ResponseStatusEnum.SYSTEM_MYSQL_TIMEOUT_ERROR);
+    }
+
+    //请求方式错误
+    @ExceptionHandler(HttpRequestMethodNotSupportedException.class)
+    @ResponseBody
+    public CommonResult httpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e) {
+        e.printStackTrace();
+        logger.error("错误信息",e.fillInStackTrace());
+        //String error=e.getFieldError().getDefaultMessage();
+        return CommonResult.resultValue(ResponseStatusEnum.SYSTEM_REQUEST_METHOD_ERROR);
+    }
+
+    //传参空异常
+    @ExceptionHandler(MissingServletRequestParameterException.class)
+    @ResponseBody
+    public CommonResult missingServletRequestParameterException(MissingServletRequestParameterException e) {
+        String name=  e.getParameterName();
+        logger.error("错误信息",e.fillInStackTrace());
+
+        //String error=e.getFieldError().getDefaultMessage();
+        return CommonResult.fail(name+"不能为空");
+    }
+
+    @ExceptionHandler(MyCustomException.class)
+    @ResponseBody
+    public CommonResult returnMyException(MyCustomException e) {
+        e.printStackTrace();
+        logger.error("错误信息",e.fillInStackTrace());
+        return CommonResult.resultValue(e.getResponseStatusEnum());
+    }
+
+    /**
+     * 传入JSON数据格式错误
+     * @param e
+     * @return
+     */
+    @ExceptionHandler(JsonParseException.class)
+    @ResponseBody
+    public CommonResult returnMyException(JsonParseException e) {
+        logger.error("错误信息",e.fillInStackTrace());
+        e.printStackTrace();
+        return CommonResult.resultValue(ResponseStatusEnum.SEND_PARAMS);
+    }
+
+
+    /**
+     * 传入JSON数据格式转换错误
+     * @param e
+     * @return
+     */
+    @ExceptionHandler(HttpMessageNotReadableException.class)
+    @ResponseBody
+    public CommonResult httpMessageNotReadableException(HttpMessageNotReadableException e) {
+        logger.error("错误信息",e.fillInStackTrace());
+        e.printStackTrace();//
+        if(e.getCause() instanceof  InvalidFormatException){
+            InvalidFormatException e1=   (InvalidFormatException)e.getCause();
+            Object erro1= e1.getValue();
+            Object erro2=e1.getTargetType().getSimpleName();
+            System.out.print(erro1);
+            System.out.print(erro2);
+        }
+
+        String error=e.getMessage();
+        return CommonResult.resultValue(ResponseStatusEnum.SEND_PARAMS_TYPE);
+    }
+
+
+
+
+
+
+
+    /**
+     * 参数验证错误
+     * @param e
+     * @return
+     */
+    @ExceptionHandler(MethodArgumentNotValidException.class)
+    @ResponseBody
+    public CommonResult returnException(MethodArgumentNotValidException e) {
+        logger.error("错误信息",e.fillInStackTrace());
+        BindingResult result = e.getBindingResult();
+        Map<String, String> map = getErrors(result);
+        return CommonResult.fail(map.values().toString().replace("[","").replace("]",""));
+    }
+
+    /**
+     * 参数验证错误
+     * @param e
+     * @return
+     */
+    @ExceptionHandler(MethodArgumentTypeMismatchException.class)
+    @ResponseBody
+    public CommonResult returnException(MethodArgumentTypeMismatchException e) {
+        logger.error("错误信息",e.fillInStackTrace());
+        String value=e.getValue().toString();
+        String paraType=e.getRequiredType().getName().toString();
+
+        return CommonResult.errorMsg(e.getName()+"数据格式转换错误");
+    }
+
+
+    public Map<String, String> getErrors(BindingResult result) {
+        Map<String, String> map = new HashMap<>();
+        List<FieldError> errorList = result.getFieldErrors();
+        for (FieldError error : errorList) {
+            // 发送验证错误的时候所对应的某个属性
+            String field = error.getField();
+            // 验证的错误消息
+            String msg = error.getDefaultMessage();
+            map.put(field, msg);
+        }
+        return map;
+    }
+
+
+}

+ 29 - 0
src/main/java/com/template/common/exception/MyCustomException.java

@@ -0,0 +1,29 @@
+package com.template.common.exception;
+
+import com.template.common.result.ResponseStatusEnum;
+
+/**
+ * 自定义异常
+ * 目的:统一处理异常信息
+ *      便于解耦,service与controller错误的解耦,不会被service返回的类型而限制
+ */
+public class MyCustomException extends RuntimeException {
+
+    private ResponseStatusEnum responseStatusEnum;
+
+    public MyCustomException(ResponseStatusEnum responseStatusEnum) {
+        super("异常状态码为:" + responseStatusEnum.status()
+                + ";具体异常信息为:" + responseStatusEnum.msg());
+        this.responseStatusEnum = responseStatusEnum;
+    }
+
+    public ResponseStatusEnum getResponseStatusEnum() {
+        return responseStatusEnum;
+    }
+
+    public void setResponseStatusEnum(ResponseStatusEnum responseStatusEnum) {
+        this.responseStatusEnum = responseStatusEnum;
+    }
+
+
+}

+ 43 - 0
src/main/java/com/template/common/jh/ReqRespResearchProductQuestionnaireItem.java

@@ -0,0 +1,43 @@
+package com.template.common.jh;
+
+import java.io.Serializable;
+
+public class ReqRespResearchProductQuestionnaireItem implements Serializable {
+    private static final long serialVersionUID = -2850886454687095222L;
+    private String minValue;
+    private String maxValue;
+    //"范围符号:1-大于/2-小于/3-等于/4-不等于/5-大于等于/6-小于等于/7-全闭区间/8-左闭右开区间/9-左开右闭区间/10-全开区间"
+    private Byte symbol;
+
+    public ReqRespResearchProductQuestionnaireItem( String minValue, String maxValue, Byte symbol) {
+        this.minValue = minValue;
+        this.maxValue = maxValue;
+        this.symbol = symbol;
+    }
+
+    public String getMinValue() {
+        return minValue;
+    }
+
+    public void setMinValue(String minValue) {
+        this.minValue = minValue;
+    }
+
+    public String getMaxValue() {
+        return maxValue;
+    }
+
+    public void setMaxValue(String maxValue) {
+        this.maxValue = maxValue;
+    }
+
+    public Byte getSymbol() {
+        return symbol;
+    }
+
+    public void setSymbol(Byte symbol) {
+        this.symbol = symbol;
+    }
+}
+
+

+ 243 - 0
src/main/java/com/template/common/jh/SectionUtil.java

@@ -0,0 +1,243 @@
+package com.template.common.jh;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @description: 区间工具类
+ * @author: wyj
+ * @time: 2020/3/1 15:05
+ */
+public class SectionUtil {
+    //最小值
+    private String min_entity;
+    //最大值
+    private String max_entity;
+    //左侧括号状态:false -开区间  true-- 闭区间
+    private boolean left_sate = false;
+    //右侧括号状态:false -开区间  true-- 闭区间
+    private boolean right_sate = false;
+    private SectionUtil() {
+
+    }
+
+    public SectionUtil(String min_entity, String max_entity, boolean left_sate, boolean right_sate) {
+        this.min_entity = min_entity;
+        this.max_entity = max_entity;
+        this.left_sate = left_sate;
+        this.right_sate = right_sate;
+    }
+
+    public String getMin_entity() {
+        return min_entity;
+    }
+
+    public String getMax_entity() {
+        return max_entity;
+    }
+
+    public boolean isLeft_sate() {
+        return left_sate;
+    }
+
+    public boolean isRight_sate() {
+        return right_sate;
+    }
+
+    /**
+     * @description: 创建负区间((负无穷,X])
+     * @param value 区间最大值
+     * @param right_sate 区间开闭状态
+     * @Date: 2020/3/2 14:37
+     */
+    public static SectionUtil creatFu(String value, boolean right_sate) {
+
+        return new SectionUtil("", value, false, right_sate);
+    }
+    /**
+     * @description: 创建正区间[X,正无穷))
+     * @param value 区间最小值
+     * @param left_sate 区间开闭状态
+     * @Date: 2020/3/2 14:37
+     */
+    public static SectionUtil creatZheng(String value, boolean left_sate) {
+
+        return new SectionUtil(value, "", left_sate, false);
+    }
+    /**
+     * @description: 创建闭合区间([X,Y])
+     * @param min   区间最小值
+     * @param max   区间最大值
+     * @param left_sate 区间左侧开闭状态
+     * @param right_sate 区间右侧开闭状态
+     * @return
+     * @Date: 2020/3/2 14:41
+     */
+    public static SectionUtil creat(String min, boolean left_sate, String max, boolean right_sate) {
+
+        return new SectionUtil(min, max, left_sate, right_sate);
+    }
+    /**
+     * @description:  将实体类转换成区间集合
+     * @param record  待转换的实体类
+     * @return 转换后的区间集合类(不等于时转换后为2个区间,所以采用集合)
+     * @Date: 2020/3/2 14:19
+     */
+    public static List<SectionUtil> getSections(ReqRespResearchProductQuestionnaireItem record) {
+        List<SectionUtil> list = new ArrayList<>();
+        String record_max = record.getMaxValue();
+        String record_min = record.getMinValue();
+        switch (record.getSymbol()) {
+            case 1:
+                list.add(creatZheng(record_max, false));
+                break;
+            case 2:
+                list.add(creatFu(record_max, false));
+                break;
+            case 3:
+                list.add(creat(record_max, true, record_max, true));
+                break;
+            case 4:
+                list.add(creatFu(record_max, false));
+                list.add(creatZheng(record_max, false));
+                break;
+            case 5:
+                list.add(creatZheng(record_max, true));
+                break;
+            case 6:
+                list.add(creatFu(record_max, true));
+                break;
+            case 7:
+                list.add(creat(record_min, true, record_max, true));
+                break;
+            case 8:
+                list.add(creat(record_min, true, record_max, false));
+                break;
+            case 9:
+                list.add(creat(record_min, false, record_max, true));
+                break;
+            case 10:
+                list.add(creat(record_min, false, record_max, false));
+                break;
+        }
+        return list;
+    }
+
+
+
+    public int compareTo(String first_value, String second_value) {
+        //first_value为空表示为正无穷,second_value为空表示为负无穷
+        if (isBlank(first_value) || isBlank(second_value)) {
+            return 1;
+        }
+        return compareToValue(first_value,second_value);
+    }
+    //判断字符串是否为空
+    public static boolean isBlank(String str) {
+        int strLen;
+        if (str == null || (strLen = str.length()) == 0) {
+            return true;
+        }
+        for (int i = 0; i < strLen; i++) {
+            if ((Character.isWhitespace(str.charAt(i)) == false)) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    /**
+     * @param record 判断区间是否有重合
+     * @return true-有重合  false -无重合
+     * @description: 判断当前区间是否和指定区间重合
+     * @Date: 2020/3/2 10:20
+     */
+    public boolean isChonghe(SectionUtil record) {
+        String min_entity = record.getMin_entity();
+        String max_entity = record.getMax_entity();
+        boolean left_sate = record.isLeft_sate();
+        boolean right_sate = record.isRight_sate();
+        boolean left_isok = false;
+        boolean right_isok = false;
+        //重合条件,第一个区间最大值大于第二个区间最小值并且第一个区间的最小值小于第二个区间的最大值
+        //注意传值顺序,第一个值为第一个区间的最大值(此处不能反)
+        int first_result = compareTo(this.max_entity, min_entity);
+        if ((first_result == 0 && this.right_sate && left_sate) || (first_result > 0)) {
+            left_isok = true;
+        }
+        //注意传值顺序,第一个值为第二个区间的最大值(此处不能反)
+        int second_result = compareTo(max_entity, this.min_entity);
+        //此处本应该是second_result<0,但由于上一步参数传递时时反正传递,故此此处为second_result>0
+        if ((second_result == 0 && this.left_sate && right_sate) || second_result > 0) {
+            right_isok = true;
+        }
+        return left_isok && right_isok;
+    }
+    /**
+     * @description:   比较集合中区间是否有重叠
+     * @param list1 待比较集合1
+     * @param list2 待比较集合2
+     * @return
+     * @Date: 2020/3/2 11:49
+     */
+    public static boolean isChonghe(List<SectionUtil> list1, List<SectionUtil> list2) {
+        boolean chonghed = false;
+        for (SectionUtil item1 : list1) {
+            for (SectionUtil item2 : list2) {
+                chonghed = item1.isChonghe(item2);
+                if (chonghed) {
+                    return true;
+                }
+            }
+        }
+        return chonghed;
+    }
+
+    //比较大小
+    public static int compareToValue(String value1, String value2) {
+        BigDecimal b1 = new BigDecimal(value1);
+        BigDecimal b2 = new BigDecimal(value2);
+        return b1.compareTo(b2);
+    }
+
+    /**
+     * @description:   判断集合中区间是否重叠
+     * @param list  待判断集合
+     * @return  fasle-无重叠 true-有重叠
+     * @Date: 2020/3/3 14:51
+     */
+    public static boolean compareSection(List<ReqRespResearchProductQuestionnaireItem> list) {
+        for (int i = 0; i < list.size(); i++) {
+            ReqRespResearchProductQuestionnaireItem record = list.get(i);
+            for (int j = i + 1; j < list.size(); j++) {
+                ReqRespResearchProductQuestionnaireItem item = list.get(j);
+                //判断区间是否有交叉
+                List<SectionUtil> records = SectionUtil.getSections(record);
+                List<SectionUtil> items = SectionUtil.getSections(item);
+                boolean chonghe = SectionUtil.isChonghe(records, items);
+                if (chonghe) {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
+    public static void main(String[] args) {
+        List<ReqRespResearchProductQuestionnaireItem> all = new ArrayList<>();
+        ReqRespResearchProductQuestionnaireItem re1 = new ReqRespResearchProductQuestionnaireItem("110","120", (byte) 7);
+        ReqRespResearchProductQuestionnaireItem re2 = new ReqRespResearchProductQuestionnaireItem("90","112", (byte) 7);
+        ReqRespResearchProductQuestionnaireItem re3 = new ReqRespResearchProductQuestionnaireItem("80","89", (byte) 7);
+        ReqRespResearchProductQuestionnaireItem re4 = new ReqRespResearchProductQuestionnaireItem("60","79", (byte) 7);
+        ReqRespResearchProductQuestionnaireItem re5 = new ReqRespResearchProductQuestionnaireItem("0","59", (byte) 7);
+        all.add(re1);
+        all.add(re2);
+        all.add(re3);
+        all.add(re4);
+        all.add(re5);
+        System.out.println(compareSection(all));
+    }
+}
+
+

+ 86 - 0
src/main/java/com/template/common/mqtt/MqttConfiguration.java

@@ -0,0 +1,86 @@
+//package com.template.common.mqtt;
+//
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.boot.context.properties.ConfigurationProperties;
+//import org.springframework.context.annotation.Bean;
+//import org.springframework.context.annotation.Configuration;
+//import org.springframework.stereotype.Component;
+//
+//@Component
+//@Configuration
+//@ConfigurationProperties(prefix = "mqtt")
+//public class MqttConfiguration {
+//
+//    private String host;
+//    private String clientId;
+//    private String username;
+//    private String password;
+//    private String topic;
+//    private int timeout;
+//    private int KeepAlive;
+//
+//    public String getClientId() {
+//        return clientId;
+//    }
+//
+//    public void setClientId(String clientId) {
+//        this.clientId = clientId;
+//    }
+//
+//    public int getKeepAlive() {
+//        return KeepAlive;
+//    }
+//
+//    public void setKeepAlive(int keepAlive) {
+//        KeepAlive = keepAlive;
+//    }
+//
+//    public String getUsername() {
+//        return username;
+//    }
+//
+//    public void setUsername(String username) {
+//        this.username = username;
+//    }
+//
+//    public String getPassword() {
+//        return password;
+//    }
+//
+//    public void setPassword(String password) {
+//        this.password = password;
+//    }
+//
+//    public String getTopic() {
+//        return topic;
+//    }
+//
+//    public void setTopic(String topic) {
+//        this.topic = topic;
+//    }
+//
+//    public int getTimeout() {
+//        return timeout;
+//    }
+//
+//    public void setTimeout(int timeout) {
+//        this.timeout = timeout;
+//    }
+//
+//
+//    public String getHost() {
+//        return host;
+//    }
+//
+//    public void setHost(String host) {
+//        this.host = host;
+//    }
+//
+//    @Autowired
+//    private MqttPushClient mqttPushClient;
+//    @Bean
+//    public MqttPushClient getMqttPushClient(){
+//        mqttPushClient.connect(host, clientId, username, password, timeout,KeepAlive);
+//        return mqttPushClient;
+//    }
+//}

+ 166 - 0
src/main/java/com/template/common/mqtt/MqttPushClient.java

@@ -0,0 +1,166 @@
+//package com.template.common.mqtt;
+//
+//import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
+//import org.slf4j.Logger;
+//import org.slf4j.LoggerFactory;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.context.annotation.Configuration;
+//
+//@Configuration
+//public class MqttPushClient {
+//
+//
+//    private static MqttConnectOptions option;
+//
+//    @Autowired
+//    private PushCallback pushCallback;
+//    private static final Logger log = LoggerFactory.getLogger(MqttPushClient.class);
+//
+//    private static MqttClient client;
+//
+//    public static MqttClient getClient() {
+//        return client;
+//    }
+//
+//    public static void setClient(MqttClient client) {
+//        MqttPushClient.client = client;
+//    }
+//
+//    private MqttConnectOptions getOption(String userName, String password, int outTime, int KeepAlive) {
+//        //MQTT连接设置
+//         option = new MqttConnectOptions();
+//        //设置是否清空session,false表示服务器会保留客户端的连接记录,true表示每次连接到服务器都以新的身份连接
+//        option.setCleanSession(false);
+//        //设置连接的用户名
+//        option.setUserName(userName);
+//        //设置连接的密码
+//        option.setPassword(password.toCharArray());
+//        //设置超时时间 单位为秒
+//        option.setConnectionTimeout(outTime);
+//        //设置会话心跳时间 单位为秒 服务器会每隔(1.5*keepTime)秒的时间向客户端发送个消息判断客户端是否在线,但这个方法并没有重连的机制
+//        option.setKeepAliveInterval(KeepAlive);
+//        //setWill方法,如果项目中需要知道客户端是否掉线可以调用该方法。设置最终端口的通知消息
+//        //option.setWill(topic, "close".getBytes(), 2, true);
+//        return option;
+//    }
+//
+//    /**
+//     * 连接
+//     * @param host
+//     * @param clientID
+//     * @param username
+//     * @param password
+//     * @param timeout
+//     * @param KeepAlive
+//     */
+//    public void connect(String host, String clientID, String username, String password, int timeout, int KeepAlive){
+//        MqttClient client;
+//        try {
+//            client = new MqttClient(host, clientID, new MemoryPersistence());
+//            MqttConnectOptions options = getOption(username,password,timeout,KeepAlive);
+//            MqttPushClient.setClient(client);
+//            try {
+//                client.setCallback(pushCallback);
+//                if (!client.isConnected()) {
+//                    client.connect(options);
+//                    log.info("MQTT连接成功");
+//                }else {//这里的逻辑是如果连接成功就重新连接
+//                    client.disconnect();
+//                    client.connect(options);
+//                    log.info("MQTT断连成功");
+//                }
+//            } catch (Exception e) {
+//                e.printStackTrace();
+//            }
+//        } catch (Exception e) {
+//            e.printStackTrace();
+//        }
+//    }
+//
+//    /**
+//     * 断线重连
+//     * @throws Exception
+//     */
+//    public Boolean reConnect() throws Exception {
+//        Boolean isConnected = false;
+//       if(null != client) {
+//           client.connect(option);
+//        }
+//
+//        if(client.isConnected()){
+//            isConnected = true;
+//        }
+//        return isConnected;
+//    }
+//
+//    /**
+//     * 发布,默认qos为0,非持久化
+//     * @param topic
+//     * @param pushMessage
+//     */
+//    public void publish(String topic,String pushMessage){
+//        publish(0, false, topic, pushMessage);
+//    }
+//
+//    /**
+//     * 发布
+//     * @param qos
+//     * @param retained
+//     * @param topic
+//     * @param pushMessage
+//     */
+//    public void publish(int qos,boolean retained,String topic,String pushMessage){
+//        MqttClient mqttClient = MqttPushClient.getClient();
+//        try {
+//            mqttClient.publish(topic,pushMessage.getBytes(),qos,retained);
+//        } catch (MqttPersistenceException e) {
+//            e.printStackTrace();
+//        } catch (MqttException e) {
+//            e.printStackTrace();
+//        }
+//    }
+//
+//    public void publish2(int qos,boolean retained,String topic,byte[] pushMessage){
+//        MqttMessage message = new MqttMessage();
+//        message.setQos(qos);
+//        message.setRetained(retained);
+//        message.setPayload(pushMessage);
+//        MqttTopic mTopic = MqttPushClient.getClient().getTopic(topic);
+//        if(mTopic==null){
+//            System.out.println("MQTT topic 不存在");
+//            log.error("MQTT topic 不存在");
+//            return;
+//        }
+//        MqttDeliveryToken token;
+//        try {
+//            token = mTopic.publish(message);
+//            token.waitForCompletion();
+//        } catch (MqttPersistenceException e) {
+//            e.printStackTrace();
+//        } catch (MqttException e) {
+//            e.printStackTrace();
+//        }
+//    }
+//
+//
+//    /**
+//     * 订阅某个主题,qos默认为0
+//     * @param topic
+//     */
+//    public void subscribe(String topic){
+//        subscribe(topic,0);
+//    }
+//
+//    /**
+//     * 订阅某个主题
+//     * @param topic
+//     * @param qos
+//     */
+//    public void subscribe(String topic,int qos){
+//        try {
+//            MqttPushClient.getClient().subscribe(topic, qos);
+//        } catch (MqttException e) {
+//            e.printStackTrace();
+//        }
+//    }
+//}

+ 209 - 0
src/main/java/com/template/common/mqtt/PushCallback.java

@@ -0,0 +1,209 @@
+//package com.template.common.mqtt;
+//
+//import com.alibaba.fastjson.JSON;
+//import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
+//import com.template.common.utils.TimeExchange;
+//import com.template.model.Companies;
+//import com.template.model.vo.SensorRediesDetailVo;
+//import com.template.services.SensorDetailService;
+//import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
+//import org.eclipse.paho.client.mqttv3.MqttCallback;
+//import org.eclipse.paho.client.mqttv3.MqttMessage;
+//import org.slf4j.Logger;
+//import org.slf4j.LoggerFactory;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.data.redis.core.RedisTemplate;
+//import org.springframework.stereotype.Component;
+//import org.springframework.stereotype.Repository;
+//
+//import java.util.Date;
+//
+//import static com.template.common.util.Hex.byte2HexStr;
+//
+//@Component
+//@Repository
+//public class PushCallback implements MqttCallback {
+//
+//    private static final Logger log = LoggerFactory.getLogger(PushCallback.class);
+//
+//    @Autowired
+//    private Companiess sensorDetailService;
+//
+//    @Autowired
+//    private MqttPushClient mqttPushClient;
+//
+//    @Autowired
+//    private RedisTemplate redisTemplate;
+//
+//
+//    @Override
+//    public void connectionLost(Throwable cause) {
+//        // 当连接丢失时,这个方法会被调用
+//        // 连接丢失后,一般在这里面进行重连
+//        System.out.println(TimeExchange.getTime()+"[MQTT] 连接断开,30S之后尝试重连..."+cause);
+//        while (true) {
+//            try {
+//                Thread.sleep(30000);
+////                MqttPushClient mqttPushClient = new MqttPushClient();
+//                if (mqttPushClient.reConnect()) {
+//                    System.out.println("重连成功");
+//                    break;
+//                }
+//            } catch (Exception e) {
+//                e.printStackTrace();
+//                continue;
+//            }
+//        }
+//        System.out.println(cause.getMessage() + "连接断开操作完毕");
+//    }
+//
+//    @Override
+//    public void deliveryComplete(IMqttDeliveryToken token) {
+//        //publish后会执行到这里
+//        log.info("pushComplete---------" + token.isComplete());
+//    }
+//
+//    @Override
+//    public void messageArrived(String topic, MqttMessage message) {
+//        // subscribe后得到的消息会执行到这里面
+//
+//        //说明:发布一次会返回一个设备数据,所以目前循环设备拿数据的时候得sleep十秒
+//        //压力床 罗会把四个设备的数据合成一个传过来
+//            System.out.println(2222222);
+//
+//            log.info("接收消息主题 : " + topic);
+//            log.info("接收消息Qos : " + message.getQos());
+//            String content = byte2HexStr(message.getPayload());
+//            log.info("接收消息内容 : " + content);
+//            //1.创建一个配置对象
+////            JedisPoolConfig config = new JedisPoolConfig();
+////            config.setMaxTotal(100); // 设置最大连接数
+////            config.setMaxIdle(100);  // 设置最大空闲数
+////            config.setMinIdle(100);  // 设置最大空闲数
+////            config.setMaxWaitMillis(60000);  // 设置最大空闲数
+////            JedisPool jedisPool = new JedisPool(config, "101.33.214.65", 6379);//获取链接
+////            Jedis jedis = jedisPool.getResource();
+////            jedis.auth("chuanghai_2023.");
+//        try {
+//            if (topic.equals("outTopic")&&content.length()>50) {
+//
+//                Date nowDate = new Date();
+//                //设备返回回来的数据格式规则:
+//                //前两位是帧头
+//                //去掉帧头后12位是设备号
+//                //去掉帧头和设备号的后六位是十六进制数据,需要转换为十进制,最终单位为克
+//                //最后四位是CRC不知道是干嘛的
+//                //回调接口去把数据存储到redis里
+//                //AA7C87CEB38F2E00000C46DC
+//                SensorRediesDetailVo detail = new SensorRediesDetailVo();
+//                String deviceNo = content.substring(2, 14);
+//                detail.setSensorNo(deviceNo);
+////                String minVlaueStr = jedis.get("minValue");
+//                String minVlaueStr = (String) redisTemplate.opsForValue().get("minValue");
+//                int uploadValueTotal=0;
+//                //负数的话减去FFFFFF的十进制数据
+//                int bzValue = Integer.parseInt("FFFFFF", 16) / 2;
+//                int number=1;
+//                for(int i=14;i<45;i=i+6){
+//                    SensorRediesDetailVo detailTmp = new SensorRediesDetailVo();
+//                    detailTmp.setSensorNo(deviceNo);
+//                    String valueStr = content.substring(i, i+6);
+//                    //十六进制转十进制
+//                    //十六进制转十进制,简单的方法就是使用Integer.parseInt()方法进制转换,一步到位。
+//                    //1.如果输入的是不带0x表示的十六进制数,直接转换即可。
+//                    //2.如果输入的是带有0x标识的十六进制数,需要截去前面两位标识。
+//
+//                    //1、拿到的值转换成十进制后,如果大于  8388607,那么是负数;
+//                    //2、拿到的值转换成十进制后,如果小于 8388607,那么是正数。
+//
+//                    int uploadValue = Integer.parseInt(valueStr, 16);
+//                    if (uploadValue > bzValue) {
+//    //                uploadValue = uploadValue - Integer.parseInt("FFFFFF",16);
+//                        //负数置0
+//                        uploadValue = 0;
+//                    }
+//                    //传感器不去皮,总数去皮
+//                    detailTmp.setDetail(uploadValue);
+//                    detailTmp.setCreateTime(nowDate);
+//                    String redisKey = deviceNo +"-"+number+ ":" + TimeExchange.getDate();
+//                    number++;
+//                    String hasKey = TimeExchange.DateToString(nowDate, "yyyy-MM-dd HH:mm:ss");
+//                    String jsonStr = JSON.toJSON(detailTmp).toString();
+//                    log.info("=============jsonStr: " + jsonStr);
+//                    log.info("=============hasKey: " + hasKey);
+////                    jedis.hset(redisKey, hasKey, jsonStr);
+//                    redisTemplate.opsForHash().put(redisKey, hasKey, jsonStr);
+//                    uploadValueTotal=uploadValueTotal+uploadValue;
+//                    //endregion
+//                }
+//                log.info("=============uploadValueTotal: " + uploadValueTotal);
+//                //region 去皮操作
+//                int minValue = 200000;
+//                if (ObjectUtils.isEmpty(minVlaueStr)) {
+//                    minValue = uploadValueTotal < minValue ? uploadValueTotal : minValue;
+//                } else {
+//                    //设置minvalue初始值
+//                    minValue=Integer.valueOf(minVlaueStr).intValue();
+//                    if(uploadValueTotal < Integer.valueOf(minVlaueStr).intValue()){
+//                        Object valueObj= redisTemplate.opsForHash().get("minValueTmp","value");
+//                        Object countObj= redisTemplate.opsForHash().get("minValueTmp","count");
+//                        if (valueObj!=null&&countObj!=null){
+//                            int count=Integer.parseInt(countObj.toString());
+//                            int value=Integer.parseInt(valueObj.toString());
+//                            int diff=Math.abs(uploadValueTotal - value);
+//                            //取较大的值
+//                            value=uploadValueTotal>value?uploadValueTotal:value;
+//                            //计数超过100存入皮重值清空计数器
+//                            if(count>100){
+//                                minValue=value;
+//                                redisTemplate.opsForHash().delete("minValueTmp","count","value");
+//                                redisTemplate.opsForHash().put("minValueTmp","time",TimeExchange.getTime());
+//                            }else if(diff<2000){
+//                                //数值变动小不更新数值只加数量
+//                                redisTemplate.opsForHash().put("minValueTmp","count",count+1+"");
+//                                redisTemplate.opsForHash().put("minValueTmp","time",TimeExchange.getTime());
+//                            }else{
+//                                //数值变动大更新数值和数量,取大值
+//                                redisTemplate.opsForHash().put("minValueTmp","value",value+"");
+//                                redisTemplate.opsForHash().put("minValueTmp","count",count+1+"");
+//                                redisTemplate.opsForHash().put("minValueTmp","time",TimeExchange.getTime());
+//                            }
+//                        }else{
+//                            redisTemplate.opsForHash().put("minValueTmp","value",uploadValueTotal+"");
+//                            redisTemplate.opsForHash().put("minValueTmp","count",1+"");
+//                            redisTemplate.opsForHash().put("minValueTmp","time",TimeExchange.getTime());
+//                        }
+////                        redisTemplate.opsForValue().set("minValue",String.valueOf(minValue));
+//                        minVlaueStr = (String) redisTemplate.opsForValue().get("minValue");
+//                    }else{
+//                        redisTemplate.opsForHash().delete("minValueTmp","count","value");
+//                        redisTemplate.opsForHash().put("minValueTmp","time",TimeExchange.getTime());
+//                    }
+//                }
+//                redisTemplate.opsForValue().set("minValue",String.valueOf(minValue));
+//                log.info("更新皮重minValue: " + minValue);
+//                int detailValue=uploadValueTotal > minValue?uploadValueTotal-minValue:0;
+//                detail.setDetail((int)((detailValue)*2.224));
+//
+//                detail.setCreateTime(nowDate);
+//
+//                String redisKey = deviceNo + ":" + TimeExchange.getDate();
+//                String hasKey = TimeExchange.DateToString(nowDate, "yyyy-MM-dd HH:mm:ss");
+//                String jsonStr = JSON.toJSON(detail).toString();
+//
+//    //            SensorController sc = new SensorController();
+//    //            sc.getRedisTemplate().opsForHash().put(redisKey, hasKey, "123456");
+//
+//                //存储redis可以定义为:key:设备名+日期      里面的key:
+////                jedis.hset(redisKey, hasKey, jsonStr);
+//                redisTemplate.opsForHash().put(redisKey, hasKey, jsonStr);
+//            }else{
+//                log.info("接收消息内容"+content+"主题: " + topic+"不符;不做处理 ");
+//            }
+//        } catch (NumberFormatException e) {
+//            log.info("异常"+e.getMessage());
+//            e.printStackTrace();
+//        }
+//        //数据处理 存到redis里
+//    }
+//}

+ 35 - 0
src/main/java/com/template/common/result/BaseResult.java

@@ -0,0 +1,35 @@
+package com.template.common.result;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @Author: codingliang
+ * @Description: 接口统一返回基类
+ * @Date: 2021-04-29 12:09
+ * @Version: V1.0
+ **/
+@Data
+public abstract class BaseResult<T> implements Serializable {
+
+    /**
+     * 接口调用结果标识
+     */
+    private boolean success = false;
+
+    /**
+     * 接口调用结果信息
+     */
+    private String message;
+
+    /**
+     * 接口调用业务码
+     */
+    private String code;
+
+    /**
+     * 接口调用返回数据
+     */
+    private T data;
+}

+ 7 - 0
src/main/java/com/template/common/result/Code.java

@@ -0,0 +1,7 @@
+package com.template.common.result;
+
+public interface Code {
+    Integer getStatus();
+    Boolean getSuccess();
+    String getMsg();
+}

+ 156 - 0
src/main/java/com/template/common/result/CommonResult.java

@@ -0,0 +1,156 @@
+package com.template.common.result;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+
+import java.io.Serializable;
+import java.util.Map;
+
+/**
+ * @Author: codingliang
+ * @Description: 接口统一返回
+ * @Date: 2021-04-29 12:10
+ * @Version: V1.0
+ **/
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class CommonResult<T> extends BaseResult implements Serializable {
+
+
+    private Integer status;
+    // 调用是否成功
+    private Boolean success;
+    // 响应消息,可以为成功或者失败的消息
+    private String msg;
+
+    private T data;
+
+    private static final long serialVersionUID = 3616484754899974346L;
+
+
+    public static CommonResult ok() {
+        return ok(Integer.toString(ResponseStatusEnum.SUCCESS.getStatus()), ResponseStatusEnum.SUCCESS.getMsg());
+    }
+
+    public static <T> CommonResult<T> ok(T data) {
+        CommonResult<T> result = new CommonResult<T>(data);
+        return result;
+    }
+
+    public static <T> CommonResult<T> ok(String msg) {
+        return baseCreate(Integer.toString(ResponseStatusEnum.SUCCESS.getStatus()), msg, true);
+    }
+
+    public static <T> CommonResult<T> ok(String code, String msg) {
+        return baseCreate(code, msg, true);
+    }
+
+    public static <T> CommonResult<T> ok(String msg, T data) {
+        return baseCreate(Integer.toString(ResponseStatusEnum.SUCCESS.getStatus()), msg, true, data);
+    }
+
+    public static <T> CommonResult<T> ok(String code, String msg, T data) {
+        return baseCreate(code, msg, true, data);
+    }
+
+    public static CommonResult fail() {
+        return fail(Integer.toString(ResponseStatusEnum.FAILED.getStatus()), ResponseStatusEnum.FAILED.getMsg());
+    }
+
+    public static CommonResult fail(String code, String msg) {
+        return baseCreate(code, msg, false);
+    }
+
+    public static CommonResult fail(String msg) {
+        return baseCreate(Integer.toString(ResponseStatusEnum.FAILED.getStatus()), msg, false);
+    }
+
+    public static CommonResult fail(ResponseStatusEnum EnumCode){
+        return baseCreate(Integer.toString(EnumCode.getStatus()), EnumCode.getMsg(), false);
+    }
+
+    public CommonResult() {}
+
+    /**
+     * 用Code自定义返回信息
+     * 并把数据返回
+     */
+    public CommonResult(Code code, T data) {
+        this.status = code.getStatus();
+        this.msg = code.getMsg();
+        this.success = code.getSuccess();
+        this.data = data;
+    }
+
+    /**
+     * 成功的返回信息
+     */
+    public CommonResult(T data) {
+        this.setCode(Integer.toString(ResponseStatusEnum.SUCCESS.status()));
+        this.setMessage(ResponseStatusEnum.SUCCESS.msg());
+        this.setSuccess(ResponseStatusEnum.SUCCESS.success());
+        this.setData(data);
+    }
+
+    /**
+     * 自定义错误返回信息
+     * @param EnumCode 枚举错误信息
+     * @return
+     */
+    public CommonResult(ResponseStatusEnum EnumCode) {
+        this.setCode(Integer.toString(EnumCode.status()));
+        this.setMessage(EnumCode.msg());
+        this.setSuccess(EnumCode.success());
+    }
+
+
+    private static <T> CommonResult<T> baseCreate(String code, String msg, boolean success) {
+        CommonResult result = new CommonResult();
+        result.setCode(code);
+        result.setSuccess(success);
+        result.setMessage(msg);
+        return result;
+    }
+
+    private static <T> CommonResult<T> baseCreate(String code, String msg, boolean success, T data) {
+        CommonResult result = new CommonResult();
+        result.setCode(code);
+        result.setSuccess(success);
+        result.setMessage(msg);
+        result.setData(data);
+        return result;
+    }
+
+    public static CommonResult resultValue(ResponseStatusEnum responseStatus) {
+        return new CommonResult(responseStatus);
+    }
+
+    /**
+     * 错误返回,map中包含了多条错误信息,可以用于表单验证,把错误统一的全部返回出去
+     *
+     * @param map
+     * @return
+     */
+    public static CommonResult errorMap(Map map) {
+        return new CommonResult(ResponseStatusEnum.FAILED, map);
+    }
+
+    /**
+     * 错误返回,直接返回错误的消息
+     *
+     * @param msg 提示信息
+     * @return
+     */
+    public static CommonResult errorMsg(String msg) {
+        return new CommonResult(ResponseStatusEnum.FAILED, msg);
+    }
+
+    public CommonResult<T> setResult(T data) {
+        this.setData(data);
+        return this;
+    }
+
+    @Override
+    public T getData() {
+        return (T) super.getData();
+    }
+}

+ 63 - 0
src/main/java/com/template/common/result/PageUtils.java

@@ -0,0 +1,63 @@
+package com.template.common.result;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 分页工具类
+ * @author Mark sunlightcs@gmail.com
+ */
+@Data
+public class PageUtils<T> implements Serializable {
+	private static final long serialVersionUID = 1L;
+	/**
+	 * 总记录数
+	 */
+	private int totalCount;
+	/**
+	 * 每页记录数
+	 */
+	private int pageSize;
+	/**
+	 * 总页数
+	 */
+	private int totalPage;
+	/**
+	 * 当前页数
+	 */
+	private int currPage;
+	/**
+	 * 列表数据
+	 */
+	private List<T> list;
+
+	/**
+	 * 分页
+	 * @param list        列表数据
+	 * @param totalCount  总记录数
+	 * @param pageSize    每页记录数
+	 * @param currPage    当前页数
+	 */
+	public PageUtils(List<T> list, int totalCount, int pageSize, int currPage) {
+		this.list = list;
+		this.totalCount = totalCount;
+		this.pageSize = pageSize;
+		this.currPage = currPage;
+		this.totalPage = (int)Math.ceil((double)totalCount/pageSize);
+	}
+
+	/**
+	 * 分页
+	 */
+	public PageUtils(IPage<T> page) {
+		this.list = page.getRecords();
+		this.totalCount = (int)page.getTotal();
+		this.pageSize = (int)page.getSize();
+		this.currPage = (int)page.getCurrent();
+		this.totalPage = (int)page.getPages();
+	}
+
+}

+ 83 - 0
src/main/java/com/template/common/result/ResponseStatusEnum.java

@@ -0,0 +1,83 @@
+package com.template.common.result;
+
+/**
+ * 响应结果枚举,用于提供给GraceJSONResult返回给前端的
+ * 本枚举类中包含了很多的不同的状态码供使用,可以自定义
+ * 便于更优雅的对状态码进行管理,一目了然
+ */
+public enum ResponseStatusEnum implements Code{
+
+
+    SUCCESS(200, true, "操作成功!"),
+    NO_PERMISSION(401,false,"没有权限"),
+    MISSING_REQUEST_HEADER(499,false,"缺少请求头"),
+    FAILED(500, false, "操作失败!"),
+    SEND_PARAMS(501,false,"传入参数数据结构错误"),
+    SEND_PARAMS_TYPE(502,false,"传入参数数据类型错误"),
+    UN_SERVICES_ERROR(505,false,"操作失败,请联系管理员"),
+
+    // 自定义系统级别异常 54x
+    SYSTEM_ERROR(540, false, "系统错误,错误未知!"),
+    SYSTEM_INDEX_OUT_OF_BOUNDS(541, false, "系统错误,数组越界!"),
+    SYSTEM_ARITHMETIC_BY_ZERO(542, false, "系统错误,无法除零!"),
+    SYSTEM_NULL_POINTER(543, false, "系统错误,空指针!"),
+    SYSTEM_NUMBER_FORMAT(544, false, "系统错误,数字转换异常!"),
+    SYSTEM_PARSE(545, false, "系统错误,解析异常!"),
+    SYSTEM_IO(546, false, "系统错误,IO输入输出异常!"),
+    SYSTEM_FILE_NOT_FOUND(547, false, "系统错误,文件未找到!"),
+    SYSTEM_CLASS_CAST(548, false, "系统错误,类型强制转换错误!"),
+    SYSTEM_PARSER_ERROR(549, false, "系统错误,解析出错!"),
+    SYSTEM_DATE_PARSER_ERROR(550, false, "系统错误,日期解析出错!"),
+    SYSTEM_ERROR_GLOBAL(551, false, "系统繁忙,请稍后再试!"),
+    SYSTEM_ERROR_ZUUL(552, false, "请求系统过于繁忙,请稍后再试!"),
+    SYSTEM_REQUEST_METHOD_ERROR(553, false, "请求类型错误"),
+    SYSTEM_MYSQL_TIMEOUT_ERROR(554, false, "Mysql连接超时"),
+    SYSTEM_MONGO_TIMEOUT_ERROR(555, false, "Mongo连接超时"),
+    SYSTEM_PHONE_ERROR(556,false,"手机号格式错误"),
+    SYSTEM_SEND_PHONE_ERROR(557,false,"发送验证码失败"),
+    SYSTEM_TOKEN_ERROR(558,false,"token为空"),
+    SYSTEM_LOGIN_ERROR(559,false,"无效token"),
+    PARAM_ERROR(560, false, "参数不能为空!"),
+    GZH_ERROR(561, false, "设置失败,请先关联公众号!"),
+    EXISTS(999,false,"已存在");
+
+    // 响应业务状态
+    private Integer status;
+    // 调用是否成功
+    private Boolean success;
+    // 响应消息,可以为成功或者失败的消息
+    private String msg;
+
+    ResponseStatusEnum(Integer status, Boolean success, String msg) {
+        this.status = status;
+        this.success = success;
+        this.msg = msg;
+    }
+
+    public Integer status() {
+        return status;
+    }
+    public Boolean success() {
+        return success;
+    }
+    public String msg() {
+        return msg;
+    }
+
+    @Override
+    public Integer getStatus() {
+        return status;
+    }
+
+    @Override
+    public Boolean getSuccess() {
+        return success;
+    }
+
+    @Override
+    public String getMsg() {
+        return msg;
+    }
+
+
+}

+ 30 - 0
src/main/java/com/template/common/result/UnitTimeHelpModel.java

@@ -0,0 +1,30 @@
+package com.template.common.result;
+
+import java.util.Date;
+
+/**
+ * @Author: binguo
+ * @Date: 2023/7/28 星期五 15:09
+ * @Description: com.repair.model.pojo
+ * @Version: 1.0
+ */
+public class UnitTimeHelpModel {
+    private Date StartDate;
+    private Date EndDate;
+
+    public Date getStartDate() {
+        return StartDate;
+    }
+
+    public void setStartDate(Date startDate) {
+        StartDate = startDate;
+    }
+
+    public Date getEndDate() {
+        return EndDate;
+    }
+
+    public void setEndDate(Date endDate) {
+        EndDate = endDate;
+    }
+}

+ 23 - 0
src/main/java/com/template/common/utils/AccessToken.java

@@ -0,0 +1,23 @@
+package com.template.common.utils;
+
+public class AccessToken {
+	private String access_token;// 网页获取用户信息凭证
+	private String expires_in;// 有效时间
+
+	public String getAccess_token() {
+		return access_token;
+	}
+
+	public void setAccess_token(String access_token) {
+		this.access_token = access_token;
+	}
+
+	public String getExpires_in() {
+		return expires_in;
+	}
+
+	public void setExpires_in(String expires_in) {
+		this.expires_in = expires_in;
+	}
+
+}

+ 84 - 0
src/main/java/com/template/common/utils/AesTestOne.java

@@ -0,0 +1,84 @@
+package com.template.common.utils;
+
+import org.apache.commons.codec.binary.Base64;
+
+import javax.annotation.Resource;
+import javax.crypto.Cipher;
+import javax.crypto.spec.IvParameterSpec;
+import javax.crypto.spec.SecretKeySpec;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+
+/**
+ * @Author: binguo
+ * @Date: 2024/1/5 星期五 14:26
+ * @Description: com.template.common.utils
+ * @Version: 1.0
+ */
+public class AesTestOne {
+
+    /**
+     * AES 对称加密(RSA非对称加密)
+     * CBC 有向量 (ECB 无向量)
+     * PKCS5Padding 填充模式(NoPadding 无填充)
+     */
+    private static final String ALG_AES_CBC_PKCS5 = "AES/CBC/PKCS5Padding";
+
+    private static final String ALGORITHM = "AES";
+
+    private static final Charset UTF8 = StandardCharsets.UTF_8;
+
+    //private static String aesKey = "61afd794ed3244e995c5e894e5788193";  // 指定好的秘钥,非Base64和16进制
+
+    private static String aesIv = "activevector4api";   // 偏移量
+
+    private static SecretKeySpec skeySpec;
+
+    private static IvParameterSpec iv;
+
+    /**
+     * 解密方法
+     * @param cipherStr Base64编码的加密字符串
+     * @return 解密后的字符串(UTF8编码)
+     * @throws Exception 异常
+     */
+    public static String decrypt(String cipherStr, String appSecret) throws Exception{
+        // step 1 获得一个密码器
+        Cipher cipher = Cipher.getInstance(ALG_AES_CBC_PKCS5);
+        // step 2 初始化密码器,指定是加密还是解密(Cipher.DECRYPT_MODE 解密; Cipher.ENCRYPT_MODE 加密)
+        // 加密时使用的盐来够造秘钥对象
+        skeySpec = new SecretKeySpec(appSecret.getBytes(),ALGORITHM);
+        // 加密时使用的向量,16位字符串
+        iv = new IvParameterSpec(aesIv.getBytes());
+        cipher.init(Cipher.DECRYPT_MODE, skeySpec, iv);
+        // 对加密报文进行base64解码
+        byte[] encrypted1 = Base64.decodeBase64(cipherStr);
+        // 解密后的报文数组
+        byte[] original = cipher.doFinal(encrypted1);
+        // 输出utf8编码的字符串,输出字符串需要指定编码格式
+        return new String(original, UTF8);
+    }
+
+    /**
+     * 加密
+     * @param plainText 明文
+     * @return Base64编码的密文
+     * @throws Exception  加密异常
+     */
+    public static String encrypt(String plainText, String appSecret) throws Exception{
+        Cipher cipher = Cipher.getInstance(ALG_AES_CBC_PKCS5);
+        skeySpec = new SecretKeySpec(appSecret.getBytes(),ALGORITHM);
+        iv = new IvParameterSpec(aesIv.getBytes());
+        cipher.init(Cipher.ENCRYPT_MODE, skeySpec,iv);
+        // 这里的编码格式需要与解密编码一致
+        byte [] encryptText = cipher.doFinal(plainText.getBytes(UTF8));
+        return Base64.encodeBase64String(encryptText);
+    }
+
+    public static void main(String[] args) throws Exception {
+        // URL解码
+        System.out.println("");
+    }
+}

+ 165 - 0
src/main/java/com/template/common/utils/AesUtil.java

@@ -0,0 +1,165 @@
+package com.template.common.utils;
+
+import javax.crypto.BadPaddingException;
+import javax.crypto.Cipher;
+import javax.crypto.IllegalBlockSizeException;
+import javax.crypto.NoSuchPaddingException;
+import javax.crypto.spec.IvParameterSpec;
+import javax.crypto.spec.SecretKeySpec;
+import java.security.InvalidAlgorithmParameterException;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.util.UUID;
+
+/**
+ * <p>Title: AesUtil</p>
+ * <p>Description: AES加密解密</p>
+ * @author fengyong
+ * @date 2018年9月7日
+ */
+public class AesUtil {
+
+	/**
+	 * 秘钥
+	 */
+	public static final String PASSWORD_SECRET_KEY = "EasyRailEveryday";
+	
+	/**
+	 * 初始向量
+	 */
+	public static final String INITIAL_VECTOR = "EasyRailEasyRail";
+	
+    /**
+     * 加密
+     * @param content 需要加密的内容
+     * @param password  加密密码
+     * @param keySize 密钥长度16,24,32(密码长度为24和32时需要将local_policy.jar/US_export_policy.jar两个jar包放到JRE目录%jre%/lib/security下)
+     * @return
+     */
+    public static byte[] encrypt(String content, String password, int keySize){
+    	try {                              
+        	//密钥长度不够用0补齐。
+    		SecretKeySpec key = new SecretKeySpec(ZeroPadding(password.getBytes(Base64Util.DEFAULT_CHARSET), keySize), "AES");
+    		//定义加密算法AES、算法模式ECB、补码方式PKCS5Padding
+            //Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
+    		//定义加密算法AES 算法模式CBC、补码方式PKCS5Padding
+            Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
+            //CBC模式模式下初始向量 不足16位用0补齐
+            IvParameterSpec iv = new IvParameterSpec(ZeroPadding(INITIAL_VECTOR.getBytes(Base64Util.DEFAULT_CHARSET),16));
+            byte[] byteContent = content.getBytes();  
+            //初始化加密
+            //ECB
+            //cipher.init(Cipher.ENCRYPT_MODE, key);
+            //CBC 
+			cipher.init(Cipher.ENCRYPT_MODE, key,iv);
+            byte[] result = cipher.doFinal(byteContent);
+            return result; 
+        } catch (NoSuchAlgorithmException e) {
+            e.printStackTrace();
+        } catch (NoSuchPaddingException e) {
+            e.printStackTrace();
+        } catch (InvalidKeyException e) {
+            e.printStackTrace();
+        } catch (IllegalBlockSizeException e) {
+            e.printStackTrace();
+        } catch (BadPaddingException e) {
+            e.printStackTrace();
+        } catch (InvalidAlgorithmParameterException e) {
+        	e.printStackTrace();
+        } catch (Exception e) {
+        	e.printStackTrace();
+        }
+        return null;
+    }
+    
+    /**解密
+     * @param content  待解密内容
+     * @param password 解密密钥
+     * @param keySize 密钥长度16,24,32(密码长度为24和32时需要将local_policy.jar/US_export_policy.jar两个jar包放到JRE目录%jre%/lib/security下)
+     * @return
+     */
+    public static String decrypt(byte[] content, String password, int keySize) {
+        try { 
+        	//密钥长度不够用0补齐。
+    		SecretKeySpec key = new SecretKeySpec(ZeroPadding(password.getBytes(), keySize), "AES");
+    		//定义加密算法AES、算法模式ECB、补码方式PKCS5Padding
+            //Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
+    		//定义加密算法AES 算法模式CBC、补码方式PKCS5Padding
+            Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
+            //CBC模式模式下初始向量 不足16位用0补齐
+            IvParameterSpec iv = new IvParameterSpec(ZeroPadding(INITIAL_VECTOR.getBytes(Base64Util.DEFAULT_CHARSET),16));
+            // 初始化解密
+            //ECB
+            //cipher.init(Cipher.DECRYPT_MODE, key);
+            //CBC
+            cipher.init(Cipher.DECRYPT_MODE, key,iv);
+            byte[] result = cipher.doFinal(content);
+            return new String(result,Base64Util.DEFAULT_CHARSET); 
+        } catch (NoSuchAlgorithmException e) {
+        	e.printStackTrace();
+        } catch (NoSuchPaddingException e) {
+        	e.printStackTrace();
+        } catch (InvalidKeyException e) {
+        	e.printStackTrace();
+        } catch (IllegalBlockSizeException e) {
+        	e.printStackTrace();
+        } catch (BadPaddingException e) {
+        	e.printStackTrace();
+        } catch (InvalidAlgorithmParameterException e){
+        	e.printStackTrace();
+        } catch (Exception e){
+        	e.printStackTrace();
+        }
+        return null;
+    }
+    
+    /**将二进制转换成16进制
+     * @param buf
+     * @return
+     */
+    public static String parseByte2HexStr(byte buf[]) {
+        StringBuilder sb = new StringBuilder();
+        for (int i = 0; i < buf.length; i++) {
+            String hex = Integer.toHexString(buf[i] & 0xFF);
+            if (hex.length() == 1) {
+                    hex = '0' + hex;
+            }
+            sb.append(hex.toUpperCase());
+        }
+        return sb.toString();
+    }
+    
+    /**将16进制转换为二进制
+     * @param hexStr
+     * @return
+     */
+    public static byte[] parseHexStr2Byte(String hexStr) {
+        if (hexStr.length() < 1){
+        	return null;
+        }
+        byte[] result = new byte[hexStr.length()/2];
+        for (int i = 0;i< hexStr.length()/2; i++) {
+            int high = Integer.parseInt(hexStr.substring(i*2, i*2+1), 16);
+            int low = Integer.parseInt(hexStr.substring(i*2+1, i*2+2), 16);
+            result[i] = (byte) (high * 16 + low);
+        }
+        return result;
+    }
+    
+    /**
+     * 字符达不到指定长度补0
+     * @param in 字符数组
+     * @param blockSize 长度
+     * @return
+     */
+    public static byte[] ZeroPadding(byte[] in,Integer blockSize){
+    	Integer copyLen = in.length;
+    	if (copyLen > blockSize) {
+			copyLen = blockSize;
+		}
+    	byte[] out = new byte[blockSize];
+    	System.arraycopy(in, 0, out, 0, copyLen);
+    	return out;
+    }
+
+}

+ 199 - 0
src/main/java/com/template/common/utils/AesUtils.java

@@ -0,0 +1,199 @@
+package com.template.common.utils;
+
+import lombok.extern.slf4j.Slf4j;
+import org.bouncycastle.util.encoders.Base64;
+
+import javax.crypto.BadPaddingException;
+import javax.crypto.Cipher;
+import javax.crypto.IllegalBlockSizeException;
+import javax.crypto.NoSuchPaddingException;
+import javax.crypto.spec.SecretKeySpec;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+
+/**
+ * @Author: liujun
+ * @Description: Aes 加解密算法
+ * @Date Create in 上午 9:38$ 2017/12/26 0026$
+ * @Modify By:
+ */
+@Slf4j
+public class AesUtils {
+    private static String password = "52D04DC20036DBD8";
+    /**
+     * @Author liujun
+     * @Description:
+     * @params: * @param content 需要加密的内容
+     * @param password  加密密码
+     * @Date 上午 9:41 2017/12/26 0026
+     */
+    public static String encrypt(String content) {
+
+        if(password.length()<16) {
+            password = password + "0000000000000000".substring(0, 16-password.length());
+        }
+        else if(password.length()>16) {
+            password = password.substring(0, 16);
+        }
+
+        return bytes2HexString(encryptAES(content.getBytes(), password.getBytes()));
+    }
+
+
+    /**
+     * @Author liujun
+     * @Description:
+     * @params: * @param content 待解密内容
+     * @param password 解密密钥
+     * @Date 上午 9:40 2017/12/26 0026
+     */
+    public static String decrypt(String content) {
+        if(password.length()<16) {
+            password = password + "0000000000000000".substring(0, 16-password.length());
+        }
+        else if(password.length()>16) {
+            password = password.substring(0, 16);
+        }
+
+        return new String(decryptAES(hexString2Bytes(content), password.getBytes()));
+    }
+
+    /**
+     * AES 加密
+     *
+     * @param data 明文
+     * @param key  16、24、32 字节秘钥
+     * @return 密文
+     */
+    public static byte[] encryptAES(final byte[] data, final byte[] key) {
+
+        try {
+            SecretKeySpec secretKeySpec = new SecretKeySpec(key, "AES");
+            Cipher cipher = Cipher.getInstance("AES");// 创建密码器
+            byte[] byteContent = data;
+            cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec);// 初始化
+            byte[] result = cipher.doFinal(byteContent);
+            return result; // 加密
+        } catch (NoSuchAlgorithmException e) {
+            log.error(e.getMessage(),e);
+        } catch (NoSuchPaddingException e) {
+            log.error(e.getMessage(),e);
+        } catch (InvalidKeyException e) {
+            log.error(e.getMessage(),e);
+        } catch (IllegalBlockSizeException e) {
+            log.error(e.getMessage(),e);
+        } catch (BadPaddingException e) {
+            log.error(e.getMessage(),e);
+        } catch (Exception e) {
+            log.error(e.getMessage(),e);
+        }
+        return null;
+    }
+
+    /**
+     * AES 解密
+     *
+     * @param data 密文
+     * @param key  16、24、32 字节秘钥
+     * @return 明文
+     */
+    public static byte[] decryptAES(final byte[] data, final byte[] key) {
+
+        try {
+            SecretKeySpec secretKeySpec = new SecretKeySpec(key, "AES");
+            Cipher cipher = Cipher.getInstance("AES");// 创建密码器
+            cipher.init(Cipher.DECRYPT_MODE, secretKeySpec);// 初始化
+            byte[] result = cipher.doFinal(data);
+            return result; // 加密
+        } catch (NoSuchAlgorithmException e) {
+            log.error(e.getMessage(),e);
+        } catch (NoSuchPaddingException e) {
+            log.error(e.getMessage(),e);
+        } catch (InvalidKeyException e) {
+            log.error(e.getMessage(),e);
+        } catch (IllegalBlockSizeException e) {
+            log.error(e.getMessage(),e);
+        } catch (BadPaddingException e) {
+            log.error(e.getMessage(),e);
+        } catch (Exception e) {
+            log.error(e.getMessage(),e);
+        }
+        return null;
+    }
+
+    public static String bytes2HexString(final byte[] bytes) {
+        if (bytes == null) return null;
+        int len = bytes.length;
+        if (len <= 0) return null;
+        char[] ret = new char[len << 1];
+        for (int i = 0, j = 0; i < len; i++) {
+            ret[j++] = hexDigits[bytes[i] >>> 4 & 0x0f];
+            ret[j++] = hexDigits[bytes[i] & 0x0f];
+        }
+        return new String(ret);
+    }
+
+    private static final char hexDigits[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
+
+    public static byte[] hexString2Bytes(String hexString) {
+        if (isSpace(hexString)) return null;
+        int len = hexString.length();
+        if (len % 2 != 0) {
+            hexString = "0" + hexString;
+            len = len + 1;
+        }
+        char[] hexBytes = hexString.toUpperCase().toCharArray();
+        byte[] ret = new byte[len >> 1];
+        for (int i = 0; i < len; i += 2) {
+            ret[i >> 1] = (byte) (hex2Dec(hexBytes[i]) << 4 | hex2Dec(hexBytes[i + 1]));
+        }
+        return ret;
+    }
+
+    private static int hex2Dec(final char hexChar) {
+        if (hexChar >= '0' && hexChar <= '9') {
+            return hexChar - '0';
+        } else if (hexChar >= 'A' && hexChar <= 'F') {
+            return hexChar - 'A' + 10;
+        } else {
+            throw new IllegalArgumentException();
+        }
+    }
+
+    public static byte[] base64Encode(final byte[] input) {
+        return Base64.encode(input);
+    }
+
+    public static byte[] base64Decode(final byte[] input) {
+
+        return Base64.decode(input);
+    }
+
+    private static boolean isSpace(final String s) {
+        if (s == null) return true;
+        for (int i = 0, len = s.length(); i < len; ++i) {
+            if (!Character.isWhitespace(s.charAt(i))) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    public static void main(String[] args) {
+        String s="{\n" +
+                "  \"categoryId\": \"72cf28a8789643bbbbb62d08ee91f17e\",\n" +
+                "     \"luid\": \"80A036D93CFB\",\n" +
+                "     \"type\":\"4\",\n" +
+                "     \"userName\":\"13097286670\",\n" +
+                "     \"startTime\":\"1682389484000\",\n" +
+                "     \"endTime\":\"1684981484000\",\n" +
+                "     \"password\":\"A08E87B5E777EBEE2C6EF3262F069D5A\"\n" +
+                "}";
+        //加密
+        String encryptString = AesUtils.encrypt("548903");
+        System.out.println("加密后字符串:"+encryptString);
+        //解密
+        String decryptString = AesUtils.decrypt(encryptString);
+        System.out.println("解密后字符串:"+decryptString);
+    }
+}

+ 47 - 0
src/main/java/com/template/common/utils/Base64Util.java

@@ -0,0 +1,47 @@
+package com.template.common.utils;
+
+import org.apache.tomcat.util.codec.binary.Base64;
+
+import java.nio.charset.Charset;
+
+/**
+ * <p>Title: Base64Util</p>
+ * <p>Description: Base64Util工具类 --- 加密和解密</p>
+ * @author fengyong
+ * @date 2018年9月7日
+ */
+public class Base64Util {
+	
+	public static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8");
+	/**
+     * 解密
+     * @param str
+     * @return
+     */
+    public static String decodeStr(String str){
+        if (str == null) {
+			return null;
+		}
+		if (str.length() == 0) {
+			return "";
+		}
+		return new String(Base64.decodeBase64(new String(str).getBytes(DEFAULT_CHARSET)),DEFAULT_CHARSET).trim();
+    }
+
+    /**
+     * 加密
+     * 
+     * @param str
+     * @return
+     */
+    public static String encodeStr(String str){
+        if (str == null) {
+			return null;
+		}
+		if (str.length() == 0) {
+			return "";
+		}
+        return new String(Base64.encodeBase64Chunked(str.getBytes(DEFAULT_CHARSET)),DEFAULT_CHARSET).trim();
+    }
+
+}

+ 211 - 0
src/main/java/com/template/common/utils/CommonUtil.java

@@ -0,0 +1,211 @@
+package com.template.common.utils;
+
+import lombok.extern.slf4j.Slf4j;
+
+import javax.servlet.http.HttpServletRequest;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.security.MessageDigest;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.util.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * 公共工具类
+ **/
+@Slf4j
+public class CommonUtil {
+    /**
+     * 检查字符串是否符合正则表达式
+     */
+    public static boolean checkStrByRegx(String regex, String str) {
+        //使用Pattern类的compile()方法编译正则表达式
+        Pattern pattern = Pattern.compile(regex);
+        //使用Matcher类的matcher()方法将正则表达式和字符串进行匹配
+        Matcher matcher = pattern.matcher(str);
+        //返回匹配结果
+        return matcher.matches();
+    }
+
+    /**
+     * 检测客户端参数
+     *
+     * @param code   状态码
+     * @param object 对象
+     * @return 返回类型
+     */
+    public static Map<String, Object> getReturnMap(String code, Object object) {
+        Map<String, Object> returnMap = new HashMap<>();
+        returnMap.put("code", code);
+        returnMap.put("msg", object);
+        return returnMap;
+    }
+
+    public static String getNumberFromString(String string) {
+        Pattern pattern = Pattern.compile("\\d+");
+        Matcher matcher = pattern.matcher(string);
+        if (matcher.find()) {
+            return matcher.group();
+        }
+        return null;
+    }
+
+    /**
+     * 获取ip
+     *
+     * @param request
+     * @return
+     */
+    public static String getIpAddr(HttpServletRequest request) {
+        String ipAddress = null;
+        try {
+            ipAddress = request.getHeader("x-forwarded-for");
+            System.out.println("x-forwarded-for=" + ipAddress);
+            if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) {
+                ipAddress = request.getHeader("Proxy-Client-IP");
+                System.out.println("Proxy-Client-IP=" + ipAddress);
+            }
+            if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) {
+                ipAddress = request.getHeader("WL-Proxy-Client-IP");
+                System.out.println("WL-Proxy-Client-IP=" + ipAddress);
+            }
+            if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) {
+                ipAddress = request.getRemoteAddr();
+                System.out.println("getRemoteAddr=" + ipAddress);
+                if (ipAddress.equals("127.0.0.1")) {
+                    // 根据网卡取本机配置的IP
+                    InetAddress inet = null;
+                    try {
+                        inet = InetAddress.getLocalHost();
+                    } catch (UnknownHostException e) {
+                        e.printStackTrace();
+                    }
+                    ipAddress = inet.getHostAddress();
+                    System.out.println("getHostAddress=" + ipAddress);
+                }
+            }
+            // 对于通过多个代理的情况,第一个IP为客户端真实IP,多个IP按照','分割
+            if (ipAddress != null && ipAddress.length() > 15) {
+                // "***.***.***.***".length()
+                // = 15
+                if (ipAddress.indexOf(",") > 0) {
+                    ipAddress = ipAddress.substring(0, ipAddress.indexOf(","));
+                }
+            }
+        } catch (Exception e) {
+            ipAddress = "";
+        }
+        return ipAddress;
+    }
+
+
+    /**
+     * 获取全部请求头
+     *
+     * @param request
+     * @return
+     */
+    public static Map<String, String> getAllRequestHeader(HttpServletRequest request) {
+        Enumeration<String> headerNames = request.getHeaderNames();
+        Map<String, String> map = new HashMap<>();
+        while (headerNames.hasMoreElements()) {
+            String key = headerNames.nextElement();
+            //根据名称获取请求头的值
+            String value = request.getHeader(key);
+            map.put(key, value);
+        }
+
+        return map;
+    }
+
+
+    /**
+     * MD5加密
+     *
+     * @param data
+     * @return
+     */
+    public static String MD5(String data) {
+        try {
+            MessageDigest md = MessageDigest.getInstance("MD5");
+            byte[] array = md.digest(data.getBytes("UTF-8"));
+            StringBuilder sb = new StringBuilder();
+            for (byte item : array) {
+                sb.append(Integer.toHexString((item & 0xFF) | 0x100).substring(1, 3));
+            }
+
+            return sb.toString().toUpperCase();
+        } catch (Exception exception) {
+        }
+        return null;
+    }
+
+
+    /**
+     * 获取验证码随机数
+     *
+     * @param length
+     * @return
+     */
+    public static String getRandomCode(int length) {
+        String sources = "0123456789";
+        Random random = new Random();
+        StringBuilder sb = new StringBuilder();
+        for (int j = 0; j < length; j++) {
+            sb.append(sources.charAt(random.nextInt(9)));
+        }
+        return sb.toString();
+    }
+
+    /**
+     * 获取当前时间戳
+     *
+     * @return
+     */
+    public static long getCurrentTimestamp() {
+        return System.currentTimeMillis();
+    }
+
+    /**
+     * 生成uuid
+     *
+     * @return
+     */
+    public static String generateUUID() {
+        return UUID.randomUUID().toString().replaceAll("-", "").substring(0, 32);
+    }
+
+    /**
+     * 获取随机长度的串
+     *
+     * @param length
+     * @return
+     */
+    private static final String ALL_CHAR_NUM = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+
+    public static String getStringNumRandom(int length) {
+        //生成随机数字和字母,
+        Random random = new Random();
+        StringBuilder saltString = new StringBuilder(length);
+        for (int i = 1; i <= length; ++i) {
+            saltString.append(ALL_CHAR_NUM.charAt(random.nextInt(ALL_CHAR_NUM.length())));
+        }
+        return saltString.toString();
+    }
+
+    /**
+     * LocalDate 拼接时间转成 LocalDateTime
+     *
+     * @param localDate
+     * @param timeStr   HH:mm:ss
+     * @return
+     */
+    public static LocalDateTime localDateToTime(LocalDate localDate, String timeStr) {
+        LocalTime time = LocalTime.parse(timeStr);
+        return LocalDateTime.of(localDate.getYear(), localDate.getMonth(), localDate.getDayOfMonth(),
+                time.getHour(), time.getMinute(), time.getSecond());
+    }
+}

+ 9 - 0
src/main/java/com/template/common/utils/DataBliu.java

@@ -0,0 +1,9 @@
+package com.template.common.utils;
+
+public class DataBliu {
+
+    public static double getTwo(double d1){
+        return (double) Math.round(d1 * 100) / 100;
+    }
+
+}

+ 241 - 0
src/main/java/com/template/common/utils/DateUtils.java

@@ -0,0 +1,241 @@
+package com.template.common.utils;
+
+import org.springframework.stereotype.Component;
+
+import java.sql.Timestamp;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+
+/**
+ * <p>Title: DateUtils</p>
+ * <p>Description:日期工具类 </p>
+ * 
+ * @author fengyong
+ * @date 2018年9月7日
+ */
+@Component // 加此注解是把此类实例化spring容器中
+public class DateUtils {
+
+	/**
+	 * 默认日期格式
+	 */
+	public static final String DEFAULT_FORMAT = "yyyy-MM-dd HH:mm:ss";
+
+	/**
+	 * 如2018 0901 232211(年月日时分秒)
+	 * 
+	 * @return
+	 */
+	public String yyyyMMddHHmmss() {
+		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
+		return sdf.format(Calendar.getInstance().getTime());
+	}
+
+	/**
+	 * 如20180901
+	 * 
+	 * @return
+	 */
+	public static String getYYYYMMdd() {
+		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
+		return sdf.format(Calendar.getInstance().getTime());
+	}
+
+	/**
+	 * 如180901
+	 * @return
+	 */
+	public String getYYMMdd() {
+		SimpleDateFormat sdf = new SimpleDateFormat("yyMMdd");
+		return sdf.format(Calendar.getInstance().getTime());
+	}
+
+	/**
+	 * 如201809
+	 * @return
+	 */
+	public String getYYYYMM() {
+		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMM");
+		return sdf.format(Calendar.getInstance().getTime());
+	}
+
+	/**
+	 * 如 2018/02/11
+	 * @return
+	 */
+	public String getQueryEndDate() {
+		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+		return sdf.format(Calendar.getInstance().getTime());
+	}
+
+	/**
+	 * 如 2018/02/11
+	 * @return
+	 */
+	public String getQueryStartDate() {
+		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+		Calendar cal = Calendar.getInstance();
+		cal.add(Calendar.DAY_OF_YEAR, -30);
+		return sdf.format(cal.getTime());
+	}
+
+	/**
+	 * 如 2018/02/11 12:30:00
+	 * @return
+	 */
+	public static String getQueryEndTime() {
+		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+		return sdf.format(Calendar.getInstance().getTime());
+	}
+
+	/**
+	 * 如 2018/02/11
+	 * @return
+	 */
+	public String getQueryStartTime() {
+		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+		Calendar cal = Calendar.getInstance();
+		cal.add(Calendar.DAY_OF_YEAR, -30);
+		return sdf.format(cal.getTime());
+	}
+
+	public String getQueryTwoAgoDate() {
+		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+		Calendar cal = Calendar.getInstance();
+		cal.add(Calendar.DAY_OF_YEAR, -2);
+		return sdf.format(cal.getTime());
+	}
+
+	/**
+	 * 字符串转换成日期
+	 * 
+	 * @param str 字符串
+	 * @param format 日期格式
+	 * @return 日期
+	 */
+	public static Date str2Date(String str, String format) {
+		if (null == str || "".equals(str)) {
+			return null;
+		}
+		// 如果没有指定字符串转换的格式,则用默认格式进行转换
+		if (null == format || "".equals(format)) {
+			format = DEFAULT_FORMAT;
+		}
+		SimpleDateFormat sdf = new SimpleDateFormat(format);
+		Date date = null;
+		try {
+			date = sdf.parse(str);
+			return date;
+		} catch (ParseException e) {
+		}
+		return null;
+	}
+
+	/**
+	 * @param date 日期
+	 * @param format 日期格式
+	 * @return 字符串
+	 */
+	public static String date2Str(Date date, String format) {
+		if (null == date) {
+			return null;
+		}
+		SimpleDateFormat sdf = new SimpleDateFormat(format);
+		return sdf.format(date);
+	}
+
+	/**
+	 * 时间戳转换为字符串
+	 * @param time
+	 * @return
+	 */
+	public static String timestamp2Str(Timestamp time) {
+		Date date = new Date(time.getTime());
+		return date2Str(date, DEFAULT_FORMAT);
+	}
+
+	/**
+	 * 字符串转换为时间
+	 * @param str
+	 * @return
+	 */
+	public static Timestamp str2Timestamp(String str) {
+		Date date = str2Date(str, DEFAULT_FORMAT);
+		return new Timestamp(date.getTime());
+	}
+
+	/**
+	 * 字符串转换为时间
+	 * @param str
+	 * @return
+	 */
+	public static Timestamp str2Timestamp(String str, String formatStr) {
+		if (null == str) {
+			return null;
+		}
+		Date date = str2Date(str, formatStr);
+		return new Timestamp(date.getTime());
+	}
+
+	/**
+	 * 获取某年第一天日期
+	 * @param year 年份
+	 * @return Date
+	 */
+	public static Date getYearFirst(int year) {
+		Calendar calendar = Calendar.getInstance();
+		calendar.clear();
+		calendar.set(Calendar.YEAR, year);
+		Date currYearFirst = calendar.getTime();
+		return currYearFirst;
+	}
+
+	/**
+	 * 获取某年最后一天日期
+	 * @param year  年份
+	 * @return Date
+	 */
+	public static Date getYearLast(int year) {
+		Calendar calendar = Calendar.getInstance();
+		calendar.clear();
+		calendar.set(Calendar.YEAR, year);
+		calendar.roll(Calendar.DAY_OF_YEAR, -1);
+		Date currYearLast = calendar.getTime();
+
+		return currYearLast;
+	}
+
+	@SuppressWarnings("static-access")
+	public static Date getnextLast(String datetime, int year) {
+		Calendar calendar = new GregorianCalendar();
+		Date date = null;
+		if (datetime.length() > 7) {
+			date = str2Date(datetime, "yyyy-MM-dd");
+		} else {
+			date = str2Date(datetime, "yyyy-MM");
+		}
+		calendar.setTime(date);
+		calendar.add(calendar.YEAR, year);// 把日期往后增加一年.整数往后推,负数往前移动
+		date = calendar.getTime();
+		return date;
+
+	}
+
+	public static String getrightDate(String datetime, int year) {
+		String date = "";
+		String years = datetime.substring(0, 4);
+		String dates = datetime.substring(4, datetime.length());
+		Integer s = new Integer(years) + year;
+		date = s + dates;
+		return date;
+	}
+
+	public static void main(String[] args) {
+		System.out.println(getrightDate("2018-09", 4));
+		System.out.println(date2Str(getnextLast("2018-09", 4), "yyyy-MM"));
+	}
+
+}

+ 82 - 0
src/main/java/com/template/common/utils/EncryptUtil.java

@@ -0,0 +1,82 @@
+package com.template.common.utils;
+
+import javax.crypto.Cipher;
+import javax.crypto.SecretKey;
+import javax.crypto.SecretKeyFactory;
+import javax.crypto.spec.DESKeySpec;
+import java.security.SecureRandom;
+import java.util.Base64;
+
+/**
+ * 对称加密算法
+ *
+ * @Date: 2024/2/26 星期一 10:31
+ * @Description: com.template.common.utils
+ * @Version: 1.0
+ */
+public class EncryptUtil {
+    public static String secretKeyB = "com.template.common.utils";
+    private final static String DES = "DES";
+
+    //加密
+    public static String encrypt(String data) {
+        byte[] bt;
+        try {
+            bt = encrypt(data.getBytes(), secretKeyB.getBytes());
+            //加密
+            String strs = Base64.getEncoder().encodeToString(bt);
+            return strs;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return null;
+        }
+    }
+
+    //解密
+    public static String decrypt(String data) {
+        if (data == null) {
+            return null;
+        }
+        byte[] buf;
+        byte[] bt;
+        try {
+            //解密
+            buf = Base64.getDecoder().decode(data);
+            bt = decrypt(buf, secretKeyB.getBytes());
+            return new String(bt);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return null;
+        }
+    }
+
+    private static byte[] encrypt(byte[] data, byte[] key) throws Exception {
+        // 生成可信任的随机数源
+        SecureRandom sr = new SecureRandom();
+        // 从原始密钥数据创建DESKeySpec对象
+        DESKeySpec dks = new DESKeySpec(key);
+        // 创建密钥工厂,然后用它把DESKeySpec转换成SecretKey对象
+        SecretKeyFactory keyFactory = SecretKeyFactory.getInstance(DES);
+        SecretKey securekey = keyFactory.generateSecret(dks);
+        // Cipher对象实际完成加密操作
+        Cipher cipher = Cipher.getInstance(DES);
+        // 用密钥初始化Cipher对象
+        cipher.init(Cipher.ENCRYPT_MODE, securekey, sr);
+        return cipher.doFinal(data);
+    }
+
+    private static byte[] decrypt(byte[] data, byte[] key) throws Exception {
+        // 生成可信任的随机数源
+        SecureRandom sr = new SecureRandom();
+        // 从原始密钥数据创建DESKeySpec对象
+        DESKeySpec dks = new DESKeySpec(key);
+        // 创建密钥工厂,然后用它把DESKeySpec转换成SecretKey对象
+        SecretKeyFactory keyFactory = SecretKeyFactory.getInstance(DES);
+        SecretKey securekey = keyFactory.generateSecret(dks);
+        // Cipher对象实际完成解密操作
+        Cipher cipher = Cipher.getInstance(DES);
+        // 用密钥初始化Cipher对象
+        cipher.init(Cipher.DECRYPT_MODE, securekey, sr);
+        return cipher.doFinal(data);
+    }
+}

+ 41 - 0
src/main/java/com/template/common/utils/EncryptionUtil.java

@@ -0,0 +1,41 @@
+package com.template.common.utils;
+
+import java.util.HashMap;
+import java.util.Map;
+
+
+public class EncryptionUtil {
+
+
+    private static final int MAX_JSON_STRING = 40;
+
+    /**
+     * 将需要加密的字段分批加密
+     *
+     * @param jsonString
+     * @param publicKey
+     * @return
+     * @throws Exception
+     */
+    public Map<Object, Object> encryption(String jsonString, String publicKey) throws Exception {
+        int length = jsonString.length();
+        int offset = 0;
+        int i = 0;
+        HashMap<Object, Object> map = new HashMap<>();
+//        判断字符串长度是否大于40,大于就截取前40位,分批加密
+        while (length - offset > 0) {
+            if (length - offset > MAX_JSON_STRING) {
+                String substring = jsonString.substring(offset, offset + MAX_JSON_STRING);
+                String encrypt = RSAUtils.encrypt(substring, RSAUtils.getPublicKey(publicKey));
+                map.put(i, encrypt);
+            } else {
+                String substring = jsonString.substring(offset,length);
+                String encrypt = RSAUtils.encrypt(substring, RSAUtils.getPublicKey(publicKey));
+                map.put(i, encrypt);
+            }
+            i++;
+            offset = i * MAX_JSON_STRING;
+        }
+        return map;
+    }
+}

+ 75 - 0
src/main/java/com/template/common/utils/ExcelClassField.java

@@ -0,0 +1,75 @@
+package com.template.common.utils;
+ 
+import java.util.LinkedHashMap;
+ 
+/**
+ *  */
+public class ExcelClassField {
+ 
+    /** 字段名称 */
+    private String fieldName;
+ 
+    /** 表头名称 */
+    private String name;
+ 
+    /** 映射关系 */
+    private LinkedHashMap<String, String> kvMap;
+ 
+    /** 示例值 */
+    private Object example;
+ 
+    /** 排序 */
+    private int sort;
+ 
+    /** 是否为注解字段:0-否,1-是 */
+    private int hasAnnotation;
+ 
+    public String getFieldName() {
+        return fieldName;
+    }
+ 
+    public void setFieldName(String fieldName) {
+        this.fieldName = fieldName;
+    }
+ 
+    public String getName() {
+        return name;
+    }
+ 
+    public void setName(String name) {
+        this.name = name;
+    }
+ 
+    public LinkedHashMap<String, String> getKvMap() {
+        return kvMap;
+    }
+ 
+    public void setKvMap(LinkedHashMap<String, String> kvMap) {
+        this.kvMap = kvMap;
+    }
+ 
+    public Object getExample() {
+        return example;
+    }
+ 
+    public void setExample(Object example) {
+        this.example = example;
+    }
+ 
+    public int getSort() {
+        return sort;
+    }
+ 
+    public void setSort(int sort) {
+        this.sort = sort;
+    }
+ 
+    public int getHasAnnotation() {
+        return hasAnnotation;
+    }
+ 
+    public void setHasAnnotation(int hasAnnotation) {
+        this.hasAnnotation = hasAnnotation;
+    }
+ 
+}

+ 22 - 0
src/main/java/com/template/common/utils/ExcelUtil3.java

@@ -0,0 +1,22 @@
+package com.template.common.utils;
+
+
+
+import com.alibaba.excel.EasyExcel;
+import com.alibaba.excel.support.ExcelTypeEnum;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.net.URLEncoder;
+import java.util.List;
+
+public class ExcelUtil3 {
+
+    public static void process(String fileName, List target, Class clazs , HttpServletResponse response) throws IOException {
+        response.setCharacterEncoding("UTF-8");
+        response.setContentType("application/vnd.ms-excel");
+        response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "utf-8"));
+        EasyExcel.write(response.getOutputStream(), clazs).excelType(ExcelTypeEnum.XLSX).autoCloseStream(Boolean.TRUE)
+                .sheet("预警报表").doWrite(target);
+    }
+}

+ 64 - 0
src/main/java/com/template/common/utils/ExcelUtils.java

@@ -0,0 +1,64 @@
+package com.template.common.utils;
+
+import lombok.extern.slf4j.Slf4j;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.springframework.boot.system.ApplicationHome;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.*;
+import java.net.URLDecoder;
+import java.net.URLEncoder;
+
+/**
+ * @Author: binguo
+ * @Date: 2023/7/10 星期一 14:21
+ * @Description: com.repair.common.utils
+ * @Version: 1.0
+ */
+@Slf4j
+public class ExcelUtils {
+    public static void fileDownload(String fileName, HttpServletResponse response) {
+        try {
+            ApplicationHome applicationHome = new ApplicationHome(ExcelUtils.class);
+            String pathResouce = applicationHome.getDir().getParentFile().getParentFile().getAbsolutePath();
+            String decode = URLDecoder.decode(pathResouce, "utf-8");
+            File readPath = new File(decode + "/project/repair" + File.separator);
+            File file = new File(readPath.getAbsolutePath() + fileName);
+            // 获取文件名
+            String filename = file.getName();
+            // 获取文件后缀名
+            String ext = filename.substring(filename.lastIndexOf(".") + 1).toLowerCase();
+            InputStream inputStream = new FileInputStream(file);//根据路径获取要下载的文件输入流
+            response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
+            response.setCharacterEncoding("utf-8");
+            response.setHeader("Content-disposition", "attachment;fileName=" + URLEncoder.encode(filename, "UTF-8"));
+            OutputStream out = response.getOutputStream();
+            byte[] b = new byte[1024];  //创建数据缓冲区
+            int length;
+            while ((length = inputStream.read(b)) > 0) {  //把文件流写到缓冲区里
+                out.write(b, 0, length);
+            }
+            out.flush();
+            out.close();
+            inputStream.close();
+        } catch (IOException ex) {
+            System.out.println("模板导出失败:" + ex.getMessage());
+            ex.printStackTrace();
+        }
+    }
+
+    public static void excelDownload(Workbook workbook, String fileName, HttpServletResponse response) {
+        try {
+            response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
+            response.setCharacterEncoding("utf-8");
+            response.setHeader("Content-disposition", "attachment;fileName=" + URLEncoder.encode(fileName, "UTF-8"));
+            OutputStream out = response.getOutputStream();
+            workbook.write(out);
+            out.flush();
+            out.close();
+        } catch (IOException ex) {
+            System.out.println("模板导出失败:" + ex.getMessage());
+            ex.printStackTrace();
+        }
+    }
+}

Fichier diff supprimé car celui-ci est trop grand
+ 1008 - 0
src/main/java/com/template/common/utils/ExcelUtils2.java


+ 76 - 0
src/main/java/com/template/common/utils/FileUtils.java

@@ -0,0 +1,76 @@
+package com.template.common.utils;
+
+
+import org.apache.commons.fileupload.FileItem;
+import org.apache.commons.fileupload.FileItemFactory;
+import org.apache.commons.fileupload.disk.DiskFileItemFactory;
+import org.springframework.http.MediaType;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.commons.CommonsMultipartFile;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+/**
+ * @Author: binguo
+ * @Date: 2023/12/27 星期三 11:08
+ * @Description: com.template.common.utils
+ * @Version: 1.0
+ */
+public class FileUtils {
+
+
+    /**
+     * 获取封装得MultipartFile
+     *
+     * @param inputStream inputStream
+     * @return MultipartFile
+     */
+    public static MultipartFile getMultipartFile(InputStream inputStream, String fileName) {
+        FileItem fileItem = createFileItem(inputStream, fileName);
+        //CommonsMultipartFile是feign对multipartFile的封装,但是要FileItem类对象
+        return new CommonsMultipartFile(fileItem);
+    }
+    /**
+     * FileItem类对象创建
+     *
+     * @param inputStream inputStream
+     * @param fileName    fileName
+     * @return FileItem
+     */
+    public static FileItem createFileItem(InputStream inputStream, String fileName) {
+        FileItemFactory factory = new DiskFileItemFactory(16, null);
+        String textFieldName = "file";
+        FileItem item = factory.createItem(textFieldName, MediaType.MULTIPART_FORM_DATA_VALUE, true, fileName);
+        int bytesRead = 0;
+        byte[] buffer = new byte[10 * 1024 * 1024];
+        OutputStream os = null;
+        //使用输出流输出输入流的字节
+        try {
+            os = item.getOutputStream();
+            while ((bytesRead = inputStream.read(buffer, 0, 8192)) != -1) {
+                os.write(buffer, 0, bytesRead);
+            }
+            inputStream.close();
+        } catch (IOException e) {
+            throw new IllegalArgumentException("文件上传失败");
+        } finally {
+            if (os != null) {
+                try {
+                    os.close();
+                } catch (IOException e) {
+
+                }
+            }
+            if (inputStream != null) {
+                try {
+                    inputStream.close();
+                } catch (IOException e) {
+                }
+            }
+        }
+
+        return item;
+    }
+}

+ 18 - 0
src/main/java/com/template/common/utils/GetVertifyCode.java

@@ -0,0 +1,18 @@
+package com.template.common.utils;
+
+import java.util.Random;
+
+public class GetVertifyCode {
+
+    public static String getRandomNumCode(int number){
+        String codeNum = "";
+        int [] numbers = {0,1,2,3,4,5,6,7,8,9};
+        Random random = new Random();
+        for (int i = 0; i < number; i++) {
+            int next = random.nextInt(10000);
+            codeNum+=numbers[next%10];
+        }
+        return codeNum;
+    }
+
+}

+ 241 - 0
src/main/java/com/template/common/utils/HttpClientUtils.java

@@ -0,0 +1,241 @@
+package com.template.common.utils;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.conn.ssl.DefaultHostnameVerifier;
+import org.apache.http.conn.util.PublicSuffixMatcher;
+import org.apache.http.conn.util.PublicSuffixMatcherLoader;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.message.BasicNameValuePair;
+import org.apache.http.util.EntityUtils;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * <p>Title: HttpClientUtils</p>
+ * <p>Description: httpClient 工具类</p>
+ * @author fengyong
+ * @date 2018年9月7日
+ */
+public class HttpClientUtils {
+	
+	/**
+	 * 默认参数设置
+	 * setConnectTimeout:设置连接超时时间,单位毫秒。
+	 * setConnectionRequestTimeout:设置从connect Manager获取Connection 超时时间,单位毫秒。
+	 * setSocketTimeout:请求获取数据的超时时间,单位毫秒。访问一个接口,多少时间内无法返回数据,就直接放弃此次调用。 暂时定义15分钟
+	 */
+	private RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(600000).setConnectTimeout(600000).setConnectionRequestTimeout(600000).build();
+	
+	/**
+	 * 静态内部类---作用:单例产生类的实例
+	 * @author Administrator
+	 *
+	 */
+	private static class LazyHolder {    
+       private static final HttpClientUtils INSTANCE = new HttpClientUtils();    
+       
+    }  
+	private HttpClientUtils(){}
+	public static HttpClientUtils getInstance(){
+		return LazyHolder.INSTANCE;    
+	}
+	
+	/**
+	 * 发送 post请求
+	 * @param httpUrl 地址
+	 */
+	public String sendHttpPost(String httpUrl) {
+		HttpPost httpPost = new HttpPost(httpUrl);// 创建httpPost  
+		return sendHttpPost(httpPost);
+	}
+	
+	/**
+	 * 发送 post请求
+	 * @param httpUrl 地址
+	 * @param params 参数(格式:key1=value1&key2=value2)
+	 */
+	public String sendHttpPost(String httpUrl, String params) {
+		HttpPost httpPost = new HttpPost(httpUrl);// 创建httpPost  
+		try {
+			//设置参数
+			StringEntity stringEntity = new StringEntity(params, "UTF-8");
+			stringEntity.setContentType("application/x-www-form-urlencoded");
+			httpPost.setEntity(stringEntity);
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return sendHttpPost(httpPost);
+	}
+	
+	/**
+	 * 发送 post请求
+	 * @param httpUrl 地址
+	 * @param maps 参数
+	 */
+	public String sendHttpPost(String httpUrl, Map<String, String> maps) {
+		HttpPost httpPost = new HttpPost(httpUrl);// 创建httpPost  
+		// 创建参数队列  
+		List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
+		for (String key : maps.keySet()) {
+			nameValuePairs.add(new BasicNameValuePair(key, maps.get(key)));
+		}
+		try {
+			httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs, "UTF-8"));
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return sendHttpPost(httpPost);
+	}
+	
+	/**
+	 * 发送Post请求
+	 * @param httpPost
+	 * @return
+	 */
+	private String sendHttpPost(HttpPost httpPost) {
+		CloseableHttpClient httpClient = null;
+		CloseableHttpResponse response = null;
+		HttpEntity entity = null;
+		String responseContent = null;
+		try {
+			// 创建默认的httpClient实例
+			httpClient = HttpClients.createDefault();
+			httpPost.setConfig(requestConfig);
+			// 执行请求
+			long execStart = System.currentTimeMillis();
+			response = httpClient.execute(httpPost);
+			long execEnd = System.currentTimeMillis();
+			System.out.println("=================执行post请求耗时:"+(execEnd-execStart)+"ms");
+			long getStart = System.currentTimeMillis();
+			entity = response.getEntity();
+			responseContent = EntityUtils.toString(entity, "UTF-8");
+			long getEnd = System.currentTimeMillis();
+			System.out.println("=================获取响应结果耗时:"+(getEnd-getStart)+"ms");
+		} catch (Exception e) {
+			e.printStackTrace();
+		} finally {
+			try {
+				// 关闭连接,释放资源
+				if (response != null) {
+					response.close();
+				}
+				if (httpClient != null) {
+					httpClient.close();
+				}
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+		}
+		return responseContent;
+	}
+
+	/**
+	 * 发送 get请求
+	 * @param httpUrl
+	 */
+	public String sendHttpGet(String httpUrl) {
+		HttpGet httpGet = new HttpGet(httpUrl);// 创建get请求
+		return sendHttpGet(httpGet);
+	}
+	
+	/**
+	 * 发送 get请求Https
+	 * @param httpUrl
+	 */
+	public String sendHttpsGet(String httpUrl) {
+		HttpGet httpGet = new HttpGet(httpUrl);// 创建get请求
+		return sendHttpsGet(httpGet);
+	}
+	
+	/**
+	 * 发送Get请求
+	 * @param httpPost
+	 * @return
+	 */
+	private String sendHttpGet(HttpGet httpGet) {
+		CloseableHttpClient httpClient = null;
+		CloseableHttpResponse response = null;
+		HttpEntity entity = null;
+		String responseContent = null;
+		try {
+			// 创建默认的httpClient实例.
+
+			
+			httpClient = HttpClients.createDefault();
+
+			httpGet.setConfig(requestConfig);
+			// 执行请求
+			response = httpClient.execute(httpGet);
+			entity = response.getEntity();
+			responseContent = EntityUtils.toString(entity, "UTF-8");
+		} catch (Exception e) {
+			e.printStackTrace();
+		} finally {
+			try {
+				// 关闭连接,释放资源
+				if (response != null) {
+					response.close();
+				}
+				if (httpClient != null) {
+					httpClient.close();
+				}
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+		}
+		return responseContent;
+	}
+	
+	/**
+	 * 发送Get请求Https
+	 * @param httpPost
+	 * @return
+	 */
+	private String sendHttpsGet(HttpGet httpGet) {
+		CloseableHttpClient httpClient = null;
+		CloseableHttpResponse response = null;
+		HttpEntity entity = null;
+		String responseContent = null;
+		try {
+			// 创建默认的httpClient实例.
+			PublicSuffixMatcher publicSuffixMatcher = PublicSuffixMatcherLoader.load(new URL(httpGet.getURI().toString()));
+			DefaultHostnameVerifier hostnameVerifier = new DefaultHostnameVerifier(publicSuffixMatcher);
+			httpClient = HttpClients.custom().setSSLHostnameVerifier(hostnameVerifier).build();
+			httpGet.setConfig(requestConfig);
+			// 执行请求
+			response = httpClient.execute(httpGet);
+			entity = response.getEntity();
+			responseContent = EntityUtils.toString(entity, "UTF-8");
+		} catch (Exception e) {
+			e.printStackTrace();
+		} finally {
+			try {
+				// 关闭连接,释放资源
+				if (response != null) {
+					response.close();
+				}
+				if (httpClient != null) {
+					httpClient.close();
+				}
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+		}
+		return responseContent;
+	}
+	
+	
+	
+}

+ 112 - 0
src/main/java/com/template/common/utils/HttpUtils.java

@@ -0,0 +1,112 @@
+package com.template.common.utils;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.ClientProtocolException;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.message.BasicNameValuePair;
+import org.apache.http.util.EntityUtils;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @Author: binguo
+ * @Date: 2023/8/21 星期一 14:58
+ * @Description: com.repair.common.utils
+ * @Version: 1.0
+ */
+public class HttpUtils {
+    /**
+     * 发送http post请求
+     *
+     * @param
+     *
+     * @param
+     *
+     */
+    public static String post(String url, Map<String, String> params){
+        CloseableHttpClient httpClient = null;
+        HttpPost httpPost = null;
+        String re = "";
+        try {
+            httpClient = HttpClients.createDefault();
+            RequestConfig requestConfig = RequestConfig.custom()
+                    .setSocketTimeout(20000).setConnectTimeout(20000).build();
+            httpPost = new HttpPost(url);
+            httpPost.setConfig(requestConfig);
+            List<NameValuePair> ps = new ArrayList<NameValuePair>();
+            for (String pKey : params.keySet()) {
+                ps.add(new BasicNameValuePair(pKey, params.get(pKey)));
+            }
+            httpPost.setEntity(new UrlEncodedFormEntity(ps));
+            CloseableHttpResponse response = httpClient.execute(httpPost);
+            HttpEntity httpEntity = response.getEntity();
+            re = EntityUtils.toString(httpEntity, "utf-8");
+        } catch (ClientProtocolException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                if (httpPost != null) {
+                    httpPost.releaseConnection();
+                }
+                if (httpClient != null) {
+                    httpClient.close();
+                }
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        return re;
+    }
+
+    /**
+     * 发送post请求Https,参数是字符串
+     *
+     * @param
+     * @return
+     */
+    public static String post(String url, String body){
+        String str = "";
+        CloseableHttpClient httpClient = null;
+        HttpPost httpPost = null;
+        try {
+            httpClient = HttpClients.createDefault();
+            RequestConfig requestConfig = RequestConfig.custom()
+                    .setSocketTimeout(20000).setConnectTimeout(20000).build();
+            httpPost = new HttpPost(url);
+            httpPost.setConfig(requestConfig);
+            httpPost.setEntity(new StringEntity(body, "utf-8"));
+            CloseableHttpResponse response = httpClient.execute(httpPost);
+            HttpEntity httpEntity = response.getEntity();
+            str = EntityUtils.toString(httpEntity, "utf-8");
+
+        } catch (ClientProtocolException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                if (httpPost != null) {
+                    httpPost.releaseConnection();
+                }
+                if (httpClient != null) {
+                    httpClient.close();
+                }
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        return str;
+    }
+}

+ 530 - 0
src/main/java/com/template/common/utils/HttpsClient.java

@@ -0,0 +1,530 @@
+package com.template.common.utils;
+
+import com.alibaba.fastjson.JSONObject;
+import com.google.gson.Gson;
+import com.google.gson.reflect.TypeToken;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.http.HttpEntity;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.ClientProtocolException;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.ContentType;
+import org.apache.http.entity.mime.MultipartEntityBuilder;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.message.BasicNameValuePair;
+import org.apache.http.util.EntityUtils;
+
+import javax.net.ssl.HttpsURLConnection;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLSocketFactory;
+import javax.net.ssl.TrustManager;
+import java.io.*;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.net.URLConnection;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+/**
+ * HttpsClient类
+ * @author lujunjie
+ * @date   2018/03/01
+ */
+public class HttpsClient {
+
+    /**
+     * GET请求方式
+     */
+    public static final String METHOD_GET = "GET";
+    /**
+     * POST请求方式
+     */
+    public static final String METHOD_POST = "POST";
+    /**
+     * 连接超时时间
+     */
+    private static Integer CONNECTION_TIMEOUT = WxConfig.connectionTimeout;
+    /**
+     * 请求超时时间
+     */
+    private static Integer READ_TIMEOUT = WxConfig.readTimeout;
+
+    /**
+     * 发起https请求
+     * @param requestUrl 请求地址
+     * @param requestMethod 请求方式(Get或者post)
+     * @param postData 提交数据
+     * @return JSONObject
+     */
+    public static JSONObject httpsRequestReturnJSONObject(String requestUrl, String requestMethod, String postData) throws Exception{
+        JSONObject  jsonObject = JSONObject.parseObject(HttpsClient.httpsRequestReturnString(requestUrl,requestMethod,postData));
+        System.out.println("jsonObjectDate:  " + jsonObject);
+        return jsonObject;
+    }
+
+
+    /**
+     * 发起https请求
+     * @param requestUrl 请求地址
+     * @param requestMethod 请求方式(Get或者post)
+     * @param postData 提交数据
+     * @return String
+     */
+    public static String httpsRequestReturnString(String requestUrl, String requestMethod, String postData) throws Exception{
+        String response;
+        HttpsURLConnection httpsUrlConnection = null;
+        try{
+            //创建https请求证书
+            TrustManager[] tm={new MyX509TrustManager()};
+            //创建SSLContext管理器对像,使用我们指定的信任管理器初始化
+            SSLContext sslContext=SSLContext.getInstance("SSL","SunJSSE");
+            sslContext.init(null, tm, new java.security.SecureRandom());
+            SSLSocketFactory ssf=sslContext.getSocketFactory();
+
+            // 创建URL对象
+            URL url= new URL(requestUrl);
+            // 创建HttpsURLConnection对象,并设置其SSLSocketFactory对象
+            httpsUrlConnection=(HttpsURLConnection)url.openConnection();
+            //设置ssl证书
+            httpsUrlConnection.setSSLSocketFactory(ssf);
+
+            //设置header信息
+            httpsUrlConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
+            //设置User-Agent信息
+            httpsUrlConnection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.146 Safari/537.36");
+            //设置可接受信息
+            httpsUrlConnection.setDoOutput(true);
+            //设置可输入信息
+            httpsUrlConnection.setDoInput(true);
+            //不使用缓存
+            httpsUrlConnection.setUseCaches(false);
+            //设置请求方式(GET/POST)
+            httpsUrlConnection.setRequestMethod(requestMethod);
+            //设置连接超时时间
+            if (CONNECTION_TIMEOUT > 0) {
+                httpsUrlConnection.setConnectTimeout(CONNECTION_TIMEOUT);
+            } else {
+                //默认10秒超时
+                httpsUrlConnection.setConnectTimeout(10000);
+            }
+            //设置请求超时
+            if (READ_TIMEOUT > 0) {
+                httpsUrlConnection.setReadTimeout(READ_TIMEOUT);
+            } else {
+                //默认10秒超时
+                httpsUrlConnection.setReadTimeout(10000);
+            }
+            //设置编码
+            httpsUrlConnection.setRequestProperty("Charsert", WxConstants.DEFAULT_CHARSET);
+
+            //判断是否需要提交数据
+            if(StringUtils.equals(requestMethod,HttpsClient.METHOD_POST) && StringUtils.isNotBlank(postData)){
+                //讲参数转换为字节提交
+                byte[] bytes = postData.getBytes(WxConstants.DEFAULT_CHARSET);
+                //设置头信息
+                httpsUrlConnection.setRequestProperty("Content-Length", Integer.toString(bytes.length));
+                //开始连接
+                httpsUrlConnection.connect();
+                //防止中文乱码
+                OutputStream outputStream=httpsUrlConnection.getOutputStream();
+                outputStream.write(postData.getBytes(WxConstants.DEFAULT_CHARSET));
+                outputStream.flush();
+                outputStream.close();
+            }else{
+                //开始连接
+                httpsUrlConnection.connect();
+            }
+            response = WxUtil.getStreamString(httpsUrlConnection.getInputStream());
+        }catch (Exception e){
+            throw new Exception();
+        }finally {
+            if (httpsUrlConnection != null) {
+                // 关闭连接
+                httpsUrlConnection.disconnect();
+            }
+        }
+        return response;
+    }
+
+
+    public static String get(String url, Map<String, String> params){
+        CloseableHttpClient httpClient = null;
+        HttpGet httpGet = null;
+        StringBuffer str = new StringBuffer("");
+        try {
+            httpClient = HttpClients.createDefault();
+            RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(20000).setConnectTimeout(20000).build();
+            String ps = "";
+            for (String pKey : params.keySet()) {
+                if(!"".equals(ps)){
+                    ps = ps + "&";
+                }
+                ps = pKey+"="+params.get(pKey);
+            }
+            if(!"".equals(ps)){
+                url = url + "?" + ps;
+            }
+            httpGet = new HttpGet(url);
+            httpGet.setConfig(requestConfig);
+            CloseableHttpResponse response = httpClient.execute(httpGet);
+            HttpEntity httpEntity = response.getEntity();
+            str.append(EntityUtils.toString(httpEntity,"utf-8"));
+        } catch (ClientProtocolException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }finally{
+            try {
+                if(httpGet!=null){
+                    httpGet.releaseConnection();
+                }
+                if(httpClient!=null){
+                    httpClient.close();
+                }
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        return str.toString();
+    }
+
+    public static String get(String strURL) throws Exception{
+
+        URL url = new URL(strURL);
+        HttpURLConnection httpConn = (HttpURLConnection)
+                url.openConnection();
+        httpConn.setRequestMethod("GET");
+        httpConn.connect();
+        System.out.println("bbb: "+httpConn.getResponseCode());
+        BufferedReader reader = new BufferedReader(new InputStreamReader(
+                httpConn.getInputStream(),"utf-8"));
+        String line;
+        StringBuffer buffer = new StringBuffer();
+        while ((line = reader.readLine()) != null) {
+            buffer.append(line);
+        }
+        reader.close();
+        httpConn.disconnect();
+
+        return buffer.toString();
+    }
+
+    /**
+     * 发送 post请求
+     * @param
+     * @param
+     */
+    public static String post(String url, Map<String, String> params){
+        CloseableHttpClient httpClient = null;
+        HttpPost httpPost = null;
+        StringBuilder sb = new StringBuilder("");
+        try {
+            httpClient = HttpClients.createDefault();
+            RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(20000).setConnectTimeout(20000).build();
+            httpPost = new HttpPost(url);
+            httpPost.setConfig(requestConfig);
+            List<NameValuePair> ps = new ArrayList<NameValuePair>();
+            for (String pKey : params.keySet()) {
+                ps.add(new BasicNameValuePair(pKey, params.get(pKey)));
+            }
+            httpPost.setEntity(new UrlEncodedFormEntity(ps));
+            CloseableHttpResponse response = httpClient.execute(httpPost);
+            HttpEntity httpEntity = response.getEntity();
+            sb.append(EntityUtils.toString(httpEntity,"utf-8"));
+        } catch (ClientProtocolException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }finally{
+            try {
+                if(httpPost!=null){
+                    httpPost.releaseConnection();
+                }
+                if(httpClient!=null){
+                    httpClient.close();
+                }
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        return sb.toString();
+    }
+
+    public static String postFile(String url, File file){
+
+        CloseableHttpClient httpClient = null;
+        HttpPost httpPost = null;
+        StringBuilder sb = new StringBuilder("");
+        try {
+            MultipartEntityBuilder builder = MultipartEntityBuilder.create();
+            builder.addBinaryBody("files", file, ContentType.DEFAULT_BINARY, file.getName());
+            httpClient = HttpClients.createDefault();
+            RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(20000).setConnectTimeout(20000).build();
+            httpPost = new HttpPost(url);
+            httpPost.setConfig(requestConfig);
+            httpPost.setEntity(builder.build());
+            CloseableHttpResponse response = httpClient.execute(httpPost);
+            HttpEntity httpEntity = response.getEntity();
+            sb.append(EntityUtils.toString(httpEntity,"utf-8"));
+        } catch (ClientProtocolException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }finally{
+            try {
+                if(httpPost!=null){
+                    httpPost.releaseConnection();
+                }
+                if(httpClient!=null){
+                    httpClient.close();
+                }
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        JSONObject  jsonObject = JSONObject.parseObject(sb.toString());
+        return jsonObject.get("data").toString();
+    }
+
+    //url表示请求链接,param表示json格式的请求参数		//自定义菜单创建访问方式
+    public static String sendPost(String url, String param) {
+        PrintWriter out = null;
+        BufferedReader in = null;
+        String result = "";
+        try {
+            URL realUrl = new URL(url);
+            // 打开和URL之间的连接
+            URLConnection conn = realUrl.openConnection();
+            // 设置通用的请求属性 注意Authorization生成
+            // conn.setRequestProperty("Content-Type",
+            // "application/x-www-form-urlencoded");
+            // 发送POST请求必须设置如下两行
+            conn.setDoOutput(true);
+            conn.setDoInput(true);
+            // 获取URLConnection对象对应的输出流
+            out = new PrintWriter(new OutputStreamWriter(conn.getOutputStream(),"utf-8"));
+            // 发送请求参数
+            out.print("&"+param);
+            // flush输出流的缓冲
+            out.flush();
+            // 定义BufferedReader输入流来读取URL的响应
+            in = new BufferedReader(
+                    new InputStreamReader(conn.getInputStream(),"utf-8"));
+            String line;
+            while ((line = in.readLine()) != null) {
+                result += line;
+            }
+        } catch (Exception e) {
+            System.out.println("发送 请求出现异常!" + e);
+            e.printStackTrace();
+        }
+        // 使用finally块来关闭输出流、输入流
+        finally {
+            try {
+                if (out != null) {
+                    out.close();
+                }
+                if (in != null) {
+                    in.close();
+                }
+            } catch (IOException ex) {
+                ex.printStackTrace();
+            }
+        }
+        return result;
+    }
+
+
+    //url表示请求链接,param表示json格式的请求参数		//自定义菜单创建访问方式
+    public static String sendPost2(String url, String param) {
+        PrintWriter out = null;
+        BufferedReader in = null;
+        String result = "";
+        try {
+            HttpsURLConnection httpsUrlConnection = null;
+            //创建https请求证书
+            TrustManager[] tm={new MyX509TrustManager()};
+            //创建SSLContext管理器对像,使用我们指定的信任管理器初始化
+            SSLContext sslContext=SSLContext.getInstance("SSL","SunJSSE");
+            sslContext.init(null, tm, new java.security.SecureRandom());
+            SSLSocketFactory ssf=sslContext.getSocketFactory();
+            // 创建URL对象
+            URL realUrl= new URL(url);
+            // 创建HttpsURLConnection对象,并设置其SSLSocketFactory对象,
+            // 打开和URL之间的连接
+            httpsUrlConnection=(HttpsURLConnection)realUrl.openConnection();
+            //设置ssl证书
+            httpsUrlConnection.setSSLSocketFactory(ssf);
+            // 设置通用的请求属性 注意Authorization生成
+            // conn.setRequestProperty("Content-Type",
+            // "application/x-www-form-urlencoded");
+            // 发送POST请求必须设置如下两行
+            httpsUrlConnection.setRequestMethod("POST");
+            httpsUrlConnection.setDoOutput(true);
+            httpsUrlConnection.setDoInput(true);
+            // 获取URLConnection对象对应的输出流
+            out = new PrintWriter(new OutputStreamWriter(httpsUrlConnection.getOutputStream(),"utf-8"));
+            // 发送请求参数
+            out.print("&"+param);
+            // flush输出流的缓冲
+            out.flush();
+            if (httpsUrlConnection.getResponseCode()==200) {
+                // 定义BufferedReader输入流来读取URL的响应
+                in = new BufferedReader(
+                        new InputStreamReader(httpsUrlConnection.getInputStream(), "utf-8"));
+                String line;
+                while ((line = in.readLine()) != null) {
+                    result += line;
+                }
+            }else {
+                result = "获取输入流异常!";
+            }
+        } catch (Exception e) {
+            System.out.println("发送 请求出现异常!" + e);
+            e.printStackTrace();
+        }
+        // 使用finally块来关闭输出流、输入流
+        finally {
+            try {
+                if (out != null) {
+                    out.close();
+                }
+                if (in != null) {
+                    in.close();
+                }
+            } catch (IOException ex) {
+                ex.printStackTrace();
+            }
+        }
+        return result;
+    }
+
+    public static String dateToStamp(String s) throws Exception {
+        String res = "";
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        Date date = simpleDateFormat.parse(s);
+        long time = date.getTime();
+        res = String.valueOf(time);
+        return res;
+    }
+
+    /*
+     * 将时间戳转换为时间
+     */
+    public static String stampToDate(String s){
+        String res;
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        long lt = new Long(s);
+        Date date = new Date(lt);
+        res = simpleDateFormat.format(date);
+        return res;
+    }
+
+    public static String sendJson(String request_url, JSONObject json) {
+        OutputStreamWriter out = null;
+        InputStream is = null;
+        String result = "";
+        try {
+            URL url = new URL(request_url);// 创建连接
+            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+            connection.setDoOutput(true);
+            connection.setDoInput(true);
+            connection.setUseCaches(false);
+            connection.setInstanceFollowRedirects(true);
+            connection.setRequestMethod("POST"); // 设置请求方式
+            // 设置接收数据的格式
+            connection.setRequestProperty("Accept", "application/json");
+            // 设置发送数据的格式
+            connection.setRequestProperty("Content-Type", "application/json");
+            connection.connect();
+            out = new OutputStreamWriter(connection.getOutputStream(), "UTF-8");
+            out.append(json.toString());
+            out.flush();
+            out.close();
+            // 读取响应
+            is = connection.getInputStream();
+            int length = (int) connection.getContentLength();// 获取字节长度
+//            System.out.println(length);
+            if (length != -1) {
+                byte[] data = new byte[length];
+                byte[] temp = new byte[512];
+                int readLen = 0;
+                int destPos = 0;
+                while ((readLen = is.read(temp)) > 0) {
+                    System.arraycopy(temp, 0, data, destPos, readLen);
+                    destPos += readLen;
+                }
+                result = new String(data, "UTF-8"); // utf-8编码
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                is.close();
+                out.close();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        return result;
+    }
+
+    /**
+     * post请求
+     * @param request_url
+     * @param json
+     * @return
+     */
+    public static String sendJson2(String request_url, JSONObject json) {
+        OutputStreamWriter out = null;
+        InputStream is = null;
+        String result = "";
+        try {
+            URL url = new URL(request_url);// 创建连接
+            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+            connection.setDoOutput(true);
+            connection.setDoInput(true);
+            connection.setUseCaches(false);
+            connection.setInstanceFollowRedirects(true);
+            connection.setRequestMethod("POST"); // 设置请求方式
+            // 设置接收数据的格式
+            connection.setRequestProperty("Accept", "application/json");
+            // 设置发送数据的格式
+            connection.setRequestProperty("Content-Type", "application/json");
+            connection.connect();
+            out = new OutputStreamWriter(connection.getOutputStream(), "UTF-8");
+            out.append(json.toString());
+            out.flush();
+            out.close();
+            // 读取响应
+            is = connection.getInputStream();
+            BufferedReader in = new BufferedReader(new InputStreamReader(is));
+            result = in.readLine();
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                is.close();
+                out.close();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        return result;
+    }
+
+    public static void main(String[] args) throws Exception {
+        JSONObject json = new JSONObject();
+        json.put("buildCode", "5栋");
+        json.put("currentAggr", "20");
+        json.put("energyType", "2");
+        json.put("updateTime", "2021-09-09 10:15:33");
+        String msg = sendJson2("https://chtech.ncjti.edu.cn/bigdata-api/api/energy/energyDataUpload", json);
+        System.out.println(msg);
+    }
+}

+ 54 - 0
src/main/java/com/template/common/utils/Md5Utils.java

@@ -0,0 +1,54 @@
+package com.template.common.utils;
+
+import com.alibaba.druid.util.Utils;
+
+import java.math.BigInteger;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+
+public class Md5Utils {
+
+    public static String md5One(String passWord) {
+        byte[] secretBytes = null;
+        try {
+            secretBytes = MessageDigest.getInstance("md5").digest(
+                    passWord.getBytes());
+        } catch (NoSuchAlgorithmException e) {
+            throw new RuntimeException("没有md5这个算法!");
+        }
+        String md5code = new BigInteger(1, secretBytes).toString(16);// 16进制数字
+        // 如果生成数字未满32位,需要前面补0
+        for (int i = 0; i < 32 - md5code.length(); i++) {
+            md5code = "0" + md5code;
+        }
+        return md5code;
+    }
+
+    /**
+     * 工具类md5加密
+     * @param password
+     * @return
+     */
+    public static  String md5Two(String password){
+        String s = Utils.md5(password);
+        return s;
+    }
+
+    /**
+     * 可逆的的加密解密方法;两次是解密,一次是加密
+     * @param inStr
+     * @return
+     */
+    public static String convertMD5(String inStr){
+
+        char[] a = inStr.toCharArray();
+        for (int i = 0; i < a.length; i++){
+            a[i] = (char) (a[i] ^ 't');
+        }
+        String s = new String(a);
+        return s;
+
+    }
+
+
+}

+ 548 - 0
src/main/java/com/template/common/utils/Message.java

@@ -0,0 +1,548 @@
+package com.template.common.utils;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.google.gson.Gson;
+import com.google.gson.reflect.TypeToken;
+
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+// 小程序消息通知
+public class Message {
+
+    /**
+     * hotel_name酒店名称
+     * order_status订单状态,用中文表示
+     * live_time入住时间
+     * end_time离店时间
+     * dom_name房间名称
+     * **/
+
+    public static String send(String openid,String hotel_name,
+                              String order_status,String live_time,
+                              String end_time,String dom_name)
+            throws Exception {
+        JSONObject jsonObject = new JSONObject();
+        jsonObject.put("grant_type", "client_credential");
+        jsonObject.put("appid", "");
+        jsonObject.put("secret","");
+        String msg3 = HttpsClient.sendJson2("https://api.weixin.qq.com/cgi-bin/stable_token",jsonObject);
+        Gson gson = new Gson();
+        HashMap<String, String> userMap = gson.fromJson(msg3.toString(), new TypeToken<HashMap<String, String>>() {}.getType());
+        JSONObject message = new JSONObject();
+        String token = userMap.get("access_token");
+        message.put("touser", openid);
+        message.put("template_id", "c9whRYC3d8ebNI_RdyG2X_1BBDwy2625hHmRWlW5Z9U");
+        message.put("page", "/pages/orderManage/orderManage");
+        message.put("miniprogram_state", "formal");
+        message.put("lang", "zh_CN");
+        JSONObject data = new JSONObject();
+        // 酒店名称
+        JSONObject string1 = new JSONObject();
+        string1.put("value", hotel_name);
+        // 订单状态
+        JSONObject phrase2 = new JSONObject();
+        phrase2.put("value", "");
+        // 到店时间
+        JSONObject date5 = new JSONObject();
+        date5.put("value", live_time);
+        // 离店时间
+        JSONObject date6 = new JSONObject();
+        date6.put("value", end_time);
+        // 房间名称
+        JSONObject thing27 = new JSONObject();
+        thing27.put("value", dom_name);
+        // 酒店名称
+        data.put("thing1",string1);
+        // 订单状态
+        data.put("phrase2",phrase2);
+        // 入住日期
+        data.put("date5",date5);
+        // 离店日期
+        data.put("date6",date6);
+        // 房间名称
+        data.put("thing27",thing27);
+        message.put("data", data);
+        String msg = HttpsClient.sendJson("https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token="+token, message);
+        System.out.println("小程序端消息发生:"+msg);
+        return msg;
+    }
+
+    public static String wxErrorMsg(String mag) {
+        Map mapType = JSON.parseObject(mag, Map.class);
+        Integer errorcode = (Integer) mapType.get("errcode");
+        String errmsg = "";
+        switch (errorcode) {
+            case -1:
+                errmsg = "系统繁忙";
+                break;
+            case 0:
+                errmsg = "请求成功";
+                break;
+            case 40001:
+                errmsg = "获取access_token时Secret错误,或者access_token无效";
+                break;
+            case 40002:
+                errmsg = "不合法的凭证类型";
+                break;
+            case 40003:
+                errmsg = "不合法的UserID";
+                break;
+            case 40004:
+                errmsg = "不合法的媒体文件类型 ";
+                break;
+            case 40005:
+                errmsg = "不合法的文件类型 ";
+                break;
+            case 40006:
+                errmsg = "不合法的文件大小";
+                break;
+            case 40007:
+                errmsg = "不合法的媒体文件id";
+                break;
+            case 40008:
+                errmsg = "不合法的消息类型 ";
+                break;
+            case 40013:
+                errmsg = "不合法的corpid ";
+                break;
+            case 40014:
+                errmsg = "不合法的access_token";
+                break;
+            case 40015:
+                errmsg = "不合法的菜单类型";
+                break;
+            case 40016:
+                errmsg = "不合法的按钮个数";
+                break;
+            case 40017:
+                errmsg = "不合法的按钮类型";
+                break;
+            case 40018:
+                errmsg = "不合法的按钮名字长度";
+                break;
+            case 40019:
+                errmsg = "不合法的按钮KEY长度";
+                break;
+            case 40020:
+                errmsg = "不合法的按钮URL长度 ";
+                break;
+            case 40021:
+                errmsg = "不合法的菜单版本号 ";
+                break;
+            case 40022:
+                errmsg = "不合法的子菜单级数";
+                break;
+            case 40023:
+                errmsg = "不合法的子菜单按钮个数";
+                break;
+            case 40024:
+                errmsg = "不合法的子菜单按钮类型";
+                break;
+            case 40025:
+                errmsg = "不合法的子菜单按钮名字长度";
+                break;
+            case 40026:
+                errmsg = "不合法的子菜单按钮KEY长度";
+                break;
+            case 40027:
+                errmsg = "不合法的子菜单按钮URL长度";
+                break;
+            case 40028:
+                errmsg = "不合法的自定义菜单使用员工";
+                break;
+            case 40029:
+                errmsg = "不合法的oauth_code";
+                break;
+            case 40031:
+                errmsg = "不合法的UserID列表";
+                break;
+            case 40032:
+                errmsg = "不合法的UserID列表长度";
+                break;
+            case 40033:
+                errmsg = "不合法的请求字符,不能包含\\uxxxx格式的字符 ";
+                break;
+            case 40035:
+                errmsg = "不合法的参数 ";
+                break;
+            case 40038:
+                errmsg = "不合法的请求格式 ";
+                break;
+            case 40039:
+                errmsg = "不合法的URL长度";
+                break;
+            case 40040:
+                errmsg = "不合法的插件token";
+                break;
+            case 40041:
+                errmsg = "不合法的插件id";
+                break;
+            case 40042:
+                errmsg = "不合法的插件会话";
+                break;
+            case 40048:
+                errmsg = "url中包含不合法domain";
+                break;
+            case 40054:
+                errmsg = "不合法的子菜单url域名";
+                break;
+            case 40055:
+                errmsg = "不合法的按钮url域名 ";
+                break;
+            case 40056:
+                errmsg = "不合法的agentid";
+                break;
+            case 40057:
+                errmsg = "不合法的callbackurl";
+                break;
+            case 40058:
+                errmsg = "不合法的红包参数 ";
+                break;
+            case 40059:
+                errmsg = "不合法的上报地理位置标志位 ";
+                break;
+            case 40060:
+                errmsg = "设置上报地理位置标志位时没有设置callbackurl";
+                break;
+            case 40061:
+                errmsg = "设置应用头像失败";
+                break;
+            case 40062:
+                errmsg = "不合法的应用模式";
+                break;
+            case 40063:
+                errmsg = "红包参数为空";
+                break;
+            case 40064:
+                errmsg = "管理组名字已存在";
+                break;
+            case 40065:
+                errmsg = "不合法的管理组名字长度";
+                break;
+            case 40066:
+                errmsg = "不合法的部门列表";
+                break;
+            case 40067:
+                errmsg = "标题长度不合法 ";
+                break;
+            case 40068:
+                errmsg = "不合法的标签ID";
+                break;
+            case 40069:
+                errmsg = "不合法的标签ID列表";
+                break;
+            case 40070:
+                errmsg = "列表中所有标签(用户)ID都不合法  ";
+                break;
+            case 40071:
+                errmsg = "不合法的标签名字,标签名字已经存在 ";
+                break;
+            case 40072:
+                errmsg = "不合法的标签名字长度";
+                break;
+            case 40073:
+                errmsg = "不合法的openid";
+                break;
+            case 40074:
+                errmsg = "news消息不支持指定为高保密消息";
+                break;
+            case 41001:
+                errmsg = "缺少access_token参数 ";
+                break;
+            case 41002:
+                errmsg = "缺少corpid参数";
+                break;
+            case 41003:
+                errmsg = "缺少refresh_token参数";
+                break;
+            case 41004:
+                errmsg = "缺少secret参数";
+                break;
+            case 41005:
+                errmsg = "缺少多媒体文件数据";
+                break;
+            case 41006:
+                errmsg = "缺少media_id参数";
+                break;
+            case 41007:
+                errmsg = "缺少子菜单数据";
+                break;
+            case 41008:
+                errmsg = "缺少oauth code";
+                break;
+            case 41009:
+                errmsg = "缺少UserID";
+                break;
+            case 41010:
+                errmsg = "缺少url";
+                break;
+            case 41011:
+                errmsg = "缺少agentid";
+                break;
+            case 41012:
+                errmsg = "缺少应用头像mediaid";
+                break;
+            case 41013:
+                errmsg = "缺少应用名字";
+                break;
+            case 41014:
+                errmsg = "缺少应用描述";
+                break;
+            case 41015:
+                errmsg = "缺少Content";
+                break;
+            case 41016:
+                errmsg = "缺少标题";
+                break;
+            case 41017:
+                errmsg = "缺少标签ID";
+                break;
+            case 41018:
+                errmsg = "缺少标签名字 ";
+                break;
+            case 42001:
+                errmsg = "access_token超时 ";
+                break;
+            case 42002:
+                errmsg = "refresh_token超时";
+                break;
+            case 42003:
+                errmsg = "oauth_code超时 ";
+                break;
+            case 42004:
+                errmsg = "插件token超时";
+                break;
+            case 43001:
+                errmsg = "需要GET请求";
+                break;
+            case 43002:
+                errmsg = "需要POST请求";
+                break;
+            case 43003:
+                errmsg = "需要HTTPS";
+                break;
+            case 43004:
+                errmsg = "需要接收者关注";
+                break;
+            case 43005:
+                errmsg = "需要好友关系";
+                break;
+            case 43006:
+                errmsg = "需要订阅";
+                break;
+            case 43007:
+                errmsg = "需要授权";
+                break;
+            case 43008:
+                errmsg = "需要支付授权";
+                break;
+            case 43009:
+                errmsg = "需要员工已关注";
+                break;
+            case 43010:
+                errmsg = "需要处于回调模式";
+                break;
+            case 43011:
+                errmsg = "需要企业授权";
+                break;
+            case 43101:
+                errmsg = "用户拒绝接受消息,如果用户之前曾经订阅过,则表示用户取消了订阅关系";
+                break;
+            case 44001:
+                errmsg = "多媒体文件为空";
+                break;
+            case 44002:
+                errmsg = "POST的数据包为空";
+                break;
+            case 44003:
+                errmsg = "图文消息内容为空";
+                break;
+            case 44004:
+                errmsg = "文本消息内容为空";
+                break;
+            case 45001:
+                errmsg = "多媒体文件大小超过限制";
+                break;
+            case 45002:
+                errmsg = "消息内容超过限制";
+                break;
+            case 45003:
+                errmsg = "标题字段超过限制";
+                break;
+            case 45004:
+                errmsg = "描述字段超过限制";
+                break;
+            case 45005:
+                errmsg = "链接字段超过限制";
+                break;
+            case 45006:
+                errmsg = "图片链接字段超过限制";
+                break;
+            case 45007:
+                errmsg = "语音播放时间超过限制";
+                break;
+            case 45008:
+                errmsg = "图文消息超过限制";
+                break;
+            case 45009:
+                errmsg = "接口调用超过限制";
+                break;
+            case 45010:
+                errmsg = "创建菜单个数超过限制";
+                break;
+            case 45015:
+                errmsg = "回复时间超过限制";
+                break;
+            case 45016:
+                errmsg = "系统分组,不允许修改";
+                break;
+            case 45017:
+                errmsg = "分组名字过长";
+                break;
+            case 45018:
+                errmsg = "分组数量超过上限";
+                break;
+            case 45024:
+                errmsg = "账号数量超过上限";
+                break;
+            case 46001:
+                errmsg = "不存在媒体数据";
+                break;
+            case 46002:
+                errmsg = "不存在的菜单版本";
+                break;
+            case 46003:
+                errmsg = "不存在的菜单数据";
+                break;
+            case 46004:
+                errmsg = "不存在的员工";
+                break;
+            case 47001:
+                errmsg = "解析JSON/XML内容错误";
+                break;
+            case 48002:
+                errmsg = "Api禁用";
+                break;
+            case 50001:
+                errmsg = "redirect_uri未授权";
+                break;
+            case 50002:
+                errmsg = "员工不在权限范围";
+                break;
+            case 50003:
+                errmsg = "应用已停用";
+                break;
+            case 50004:
+                errmsg = "员工状态不正确(未关注状态) ";
+                break;
+            case 50005:
+                errmsg = "企业已禁用";
+                break;
+            case 60001:
+                errmsg = "部门长度不符合限制";
+                break;
+            case 60002:
+                errmsg = "部门层级深度超过限制";
+                break;
+            case 60003:
+                errmsg = "部门不存在";
+                break;
+            case 60004:
+                errmsg = "父亲部门不存在";
+                break;
+            case 60005:
+                errmsg = "不允许删除有成员的部门";
+                break;
+            case 60006:
+                errmsg = "不允许删除有子部门的部门";
+                break;
+            case 60007:
+                errmsg = "不允许删除根部门";
+                break;
+            case 60008:
+                errmsg = "部门名称已存在";
+                break;
+            case 60009:
+                errmsg = "部门名称含有非法字符";
+                break;
+            case 60010:
+                errmsg = "部门存在循环关系";
+                break;
+            case 60011:
+                errmsg = "管理员权限不足,(user/department/agent)无权限";
+                break;
+            case 60012:
+                errmsg = "不允许删除默认应用";
+                break;
+            case 60013:
+                errmsg = "不允许关闭应用";
+                break;
+            case 60014:
+                errmsg = "不允许开启应用";
+                break;
+            case 60015:
+                errmsg = "不允许修改默认应用可见范围";
+                break;
+            case 60016:
+                errmsg = "不允许删除存在成员的标签";
+                break;
+            case 60017:
+                errmsg = "不允许设置企业";
+                break;
+            case 60102:
+                errmsg = "UserID已存在";
+                break;
+            case 60103:
+                errmsg = "手机号码不合法";
+                break;
+            case 60104:
+                errmsg = "手机号码已存在";
+                break;
+            case 60105:
+                errmsg = "邮箱不合法";
+                break;
+            case 60106:
+                errmsg = "邮箱已存在";
+                break;
+            case 60107:
+                errmsg = "微信号不合法";
+                break;
+            case 60108:
+                errmsg = "微信号已存在";
+                break;
+            case 60109:
+                errmsg = "QQ号已存在";
+                break;
+            case 60110:
+                errmsg = "部门个数超出限制";
+                break;
+            case 60111:
+                errmsg = "UserID不存在";
+                break;
+            case 60112:
+                errmsg = "成员姓名不合法";
+                break;
+            case 60113:
+                errmsg = "身份认证信息(微信号/手机/邮箱)不能同时为空 ";
+                break;
+            case 60114:
+                errmsg = "性别不合法";
+                break;
+
+            default:
+                errmsg = "没有此错误码! ";
+                break;
+        }
+        return errmsg;
+    }
+
+
+    public static void main(String[] args) throws Exception {
+        System.out.println(send("ou2uV5DGDxJ7BouxiAZZigGQFIHU","测试","测试",
+                "2023-08-25","2023-08-26","cesss"));
+    }
+}

+ 113 - 0
src/main/java/com/template/common/utils/Message2.java

@@ -0,0 +1,113 @@
+package com.template.common.utils;
+
+import com.alibaba.druid.sql.visitor.SQLASTOutputVisitor;
+import com.alibaba.fastjson.JSONObject;
+import com.google.gson.Gson;
+import com.google.gson.reflect.TypeToken;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.StatusLine;
+import org.apache.http.client.ClientProtocolException;
+import org.apache.http.client.HttpResponseException;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.util.EntityUtils;
+
+
+import java.io.IOException;
+import java.util.HashMap;
+
+/**
+ * 公众号,推送信息,推给商家信息
+ */
+public class Message2 {
+
+//小程序
+//    static String appId="wx2fc3f45732fae5d3";
+//    static String secret="7eee4a49a4470a77f9222995e8511547";
+
+//公众号
+    static String appId="wxa46ef222053a1047";
+    static String secret="16f74a1265c314fd79fdf90670173467";
+
+    /**
+     * 公众号推送消息
+     * @param openid 公众号openId
+     * @param type  事件
+     * @param location  地点
+     * @param dateTime  时间
+     * @return
+     * @throws Exception
+     */
+    public static String send(String openid,String type,String location,String dateTime)
+            throws Exception {
+
+        String url="https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid="+appId+"&secret="+secret;
+
+        String s = HttpsClient.httpsRequestReturnString(url, "GET", "");
+        JSONObject jsonObject = JSONObject.parseObject(s);
+        String access_token = jsonObject.getString("access_token");
+
+
+        JSONObject message = new JSONObject();
+        message.put("touser", openid);
+        message.put("template_id", "vPuSS7nivkQHxcGzpZB-NedVKzqJ4ifk0FTiBI7Aa20");
+
+        JSONObject small = new JSONObject();
+        small.put("appid", "wx2fc3f45732fae5d3");
+        small.put("pagepath", "pages/msgWarn/msgWarn");
+        message.put("miniprogram", small);
+        // 报警类型
+        JSONObject const2 = new JSONObject();
+        const2.put("value", type);
+        const2.put("color", "#173177");
+
+        // 报警位置
+        JSONObject thing3 = new JSONObject();
+        thing3.put("value", location);
+        thing3.put("color", "#173177");
+
+        // 报警时间
+        JSONObject time4 = new JSONObject();
+        time4.put("value", dateTime);
+        time4.put("color", "#173177");
+
+        // 封装data
+        JSONObject data = new JSONObject();
+        data.put("const2",const2);
+        data.put("thing3",thing3);
+        data.put("time4",time4);
+
+        message.put("data",data);
+
+        String s1 = HttpsClient.sendJson("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + access_token, message);
+        System.out.println("s1 = " + s1);
+        return s1;
+    }
+
+
+    public static String getToken() throws Exception {
+        String url="https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid="+appId+"&secret="+secret;
+
+        String s = HttpsClient.httpsRequestReturnString(url, "GET", "");
+        JSONObject jsonObject = JSONObject.parseObject(s);
+        System.out.println("jsonObject = " + jsonObject);
+        String access_token = jsonObject.getString("access_token");
+//        HttpsClient.httpsRequestReturnString("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token="+access_token, "POST", message.toJSONString());
+        return access_token;
+    }
+
+
+
+
+    public static void main(String[] args) throws Exception {
+        String o9MsY67wqvQ__o_pOzF7oeN4MQPM = send("o9MsY67wqvQ__o_pOzF7oeN4MQPM","进入区域","IPCamera 01","2024-01-29 16:16:14");
+//        String token = getToken();
+//        System.out.println("token = " + token);
+    }
+}

+ 23 - 0
src/main/java/com/template/common/utils/MyX509TrustManager.java

@@ -0,0 +1,23 @@
+package com.template.common.utils;
+
+import javax.net.ssl.X509TrustManager;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+
+/**
+ * X509TrustManager用于实现SSL证书的安全校验
+ * @author lujunjie
+ * @date   2018/03/01
+ */
+public class MyX509TrustManager implements X509TrustManager {
+    @Override
+    public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {}
+
+    @Override
+    public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {}
+
+    @Override
+    public X509Certificate[] getAcceptedIssuers() {
+        return null;
+    }
+}

+ 99 - 0
src/main/java/com/template/common/utils/PropertiesUtil.java

@@ -0,0 +1,99 @@
+package com.template.common.utils;
+
+import java.io.*;
+import java.net.URI;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * <p>Title: PropertiesUtil</p>
+ * <p>Description: properties资源文件解析工具</p>
+ * @author fengyong
+ * @date 2018年9月7日
+ */
+public class PropertiesUtil {
+
+	private static Properties props = null;
+	private static URI uri;
+	private static String fileName = "/application.properties";
+	
+	private static InputStream in = null;
+
+	static {
+		try {
+			props = new Properties();
+			InputStream fis = PropertiesUtil.class.getResourceAsStream(fileName);
+			props.load(fis);
+			uri = PropertiesUtil.class.getResource(fileName).toURI();
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+	}
+
+	/**
+	 * 获取某个属性
+	 */
+	public static String getProperty(String key) {
+		try {
+			props.load(PropertiesUtil.class.getResourceAsStream(fileName));
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		return props.getProperty(key);
+	}
+
+	/**
+	 * 获取所有属性,返回一个map,不常用 可以试试props.putAll(t)
+	 */
+	@SuppressWarnings("rawtypes")
+	public static Map<String, String> getAllProperty() {
+		Map<String, String> map = new HashMap<String, String>();
+		Enumeration enu = props.propertyNames();
+		while (enu.hasMoreElements()) {
+			String key = (String) enu.nextElement();
+			String value = props.getProperty(key);
+			map.put(key, value);
+		}
+		return map;
+	}
+
+	/**
+	 * 在控制台上打印出所有属性,调试时用。
+	 */
+	public static void printProperties() {
+		props.list(System.out);
+	}
+
+	/**
+	 * 写入properties信息
+	 */
+	public static void writeProperties(String key, String value) {
+		try {
+			OutputStream fos = new FileOutputStream(new File(uri));
+			props.setProperty(key, value);
+			// 将此 Properties 表中的属性列表(键和元素对)写入输出流
+			props.store(fos, "『comments』Update key:" + key);
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+	}
+	
+	/**
+	 * 取默认key的value
+	 * */
+	public static String getValue(String key){
+		String value = null;
+		props = new Properties();
+		in = PropertiesUtil.class.getResourceAsStream(fileName);
+		try {
+			props.load(in);
+		} catch (IOException e) {
+//			e.printStackTrace();
+		}
+		value = (String) props.get(key);
+		return value;
+	}
+
+}

Fichier diff supprimé car celui-ci est trop grand
+ 196 - 0
src/main/java/com/template/common/utils/RSAUtils.java


+ 32 - 0
src/main/java/com/template/common/utils/RandomTrackAlgorithm.java

@@ -0,0 +1,32 @@
+package com.template.common.utils;
+
+import com.alibaba.fastjson.JSONObject;
+
+import java.math.BigDecimal;
+import java.util.*;
+
+public class RandomTrackAlgorithm {
+
+    public static BigDecimal makeRandom(float max, float min, int scale){
+        BigDecimal cha = new BigDecimal(Math.random() * (max-min) + min);
+        return cha.setScale(scale,BigDecimal.ROUND_HALF_UP);//保留 scale 位小数,并四舍五入
+    }
+
+    public static List<List<BigDecimal>> getPosition(){
+        List<List<BigDecimal>> all = new ArrayList<>();
+        // 生成随机坐标点
+        BigDecimal x = null;
+        BigDecimal y = null;
+        for (int i = 0; i < 10; i++) {
+            List<BigDecimal> list = new LinkedList<>();
+            // 114.449557,28.109357
+            x = makeRandom(0.001f,0.000001f,6).add(BigDecimal.valueOf(114.449557));
+            y = makeRandom(0.001f,0.000001f,6).add(BigDecimal.valueOf(28.109357));
+            list.add(x);
+            list.add(y);
+            all.add(list);
+        }
+        return all;
+    }
+
+}

+ 126 - 0
src/main/java/com/template/common/utils/RequestUtils.java

@@ -0,0 +1,126 @@
+package com.template.common.utils;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @Author: binguo
+ * @Date: 2023/12/21 星期四 9:39
+ * @Description: com.template.common.utils
+ * @Version: 1.0
+ */
+public class RequestUtils {
+    /**
+     * GET请求
+     * @param url 请求地址
+     * @param param 请求参数
+     * @return
+     */
+    public static String httpGet(String url,String param){
+        String result = "";
+        BufferedReader in = null;
+        try {
+            String urlNameString = url + "?" + param;
+            URL realUrl = new URL(urlNameString);
+            // 打开和URL之间的连接
+            URLConnection connection = realUrl.openConnection();
+            // 设置通用的请求属性
+            connection.setRequestProperty("accept", "*/*");
+            connection.setRequestProperty("connection", "Keep-Alive");
+            connection.setRequestProperty("user-agent",
+                    "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
+            // 建立实际的连接
+            connection.connect();
+            // 获取所有响应头字段
+            Map<String, List<String>> map = connection.getHeaderFields();
+            // 遍历所有的响应头字段
+            for (String key : map.keySet()) {
+                System.out.println(key + "--->" + map.get(key));
+            }
+            // 定义 BufferedReader输入流来读取URL的响应
+            in = new BufferedReader(new InputStreamReader(
+                    connection.getInputStream()));
+            String line;
+            while ((line = in.readLine()) != null) {
+                result += line;
+            }
+        } catch (Exception e) {
+            System.out.println("发送GET请求出现异常!" + e);
+            e.printStackTrace();
+        }
+        // 使用finally块来关闭输入流
+        finally {
+            try {
+                if (in != null) {
+                    in.close();
+                }
+            } catch (Exception e2) {
+                e2.printStackTrace();
+            }
+        }
+        return result;
+    }
+
+
+    /**
+     * POST请求
+     * @param url 请求的url
+     * @param param 参数
+     * @return
+     */
+    public static String httpPost(String url, String param){
+        String dummyData = param.replace("%", "").replace(",", "").replace(" ", "+").replace("/","");
+        PrintWriter out = null;
+        BufferedReader in = null;
+        String result = "";
+        try {
+            URL realUrl = new URL(url);
+            // 打开和URL之间的连接
+            URLConnection conn = realUrl.openConnection();
+            // 设置通用的请求属性
+            conn.setRequestProperty("accept", "*/*");
+            conn.setRequestProperty("connection", "Keep-Alive");
+            conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
+            conn.setRequestProperty("Content-Type", "application/json");
+            // 发送POST请求必须设置如下两行
+            conn.setDoOutput(true);
+            conn.setDoInput(true);
+            // 获取URLConnection对象对应的输出流
+            out = new PrintWriter(conn.getOutputStream());
+            // 发送请求参数
+            out.print(param);
+            // flush输出流的缓冲
+            out.flush();
+            // 定义BufferedReader输入流来读取URL的响应
+            in = new BufferedReader(
+                    new InputStreamReader(conn.getInputStream()));
+            String line;
+            while ((line = in.readLine()) != null) {
+                result += line;
+            }
+        } catch (Exception e) {
+            System.out.println("发送 POST 请求出现异常!" + e);
+            e.printStackTrace();
+        }
+        //使用finally块来关闭输出流、输入流
+        finally {
+            try {
+                if (out != null) {
+                    out.close();
+                }
+                if (in != null) {
+                    in.close();
+                }
+            } catch (IOException ex) {
+                ex.printStackTrace();
+            }
+        }
+        return result;
+    }
+}

+ 42 - 0
src/main/java/com/template/common/utils/SHA1.java

@@ -0,0 +1,42 @@
+package com.template.common.utils;
+import java.security.MessageDigest;
+
+/**
+ * 微信SHA1算法
+ * @author lujunjie
+ * @date   2018/03/01
+ */
+public final class SHA1 {
+
+    private static final char[] HEX_DIGITS = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
+
+    /**
+     *  将字节并格式化
+     * @param bytes 原始字节
+     * @return 格式化字节
+     */
+    private static String getFormattedText(byte[] bytes) {
+        int len = bytes.length;
+        StringBuilder buf = new StringBuilder(len * 2);
+        // 把密文转换成十六进制的字符串形式
+        for (int j = 0; j < len; j++) {
+            buf.append(HEX_DIGITS[(bytes[j] >> 4) & 0x0f]);
+            buf.append(HEX_DIGITS[bytes[j] & 0x0f]);
+        }
+        return buf.toString();
+    }
+
+    public static String encode(String str) {
+        if (str == null) {
+            return null;
+        }
+        try {
+            MessageDigest messageDigest = MessageDigest.getInstance("SHA1");
+            messageDigest.update(str.getBytes());
+            return getFormattedText(messageDigest.digest());
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+}

+ 213 - 0
src/main/java/com/template/common/utils/SendSms.java

@@ -0,0 +1,213 @@
+package com.template.common.utils;
+
+
+import com.tencentcloudapi.common.Credential;
+import com.tencentcloudapi.common.exception.TencentCloudSDKException;
+
+//导入可选配置类
+import com.tencentcloudapi.common.profile.ClientProfile;
+import com.tencentcloudapi.common.profile.HttpProfile;
+
+// 导入对应SMS模块的client
+import com.tencentcloudapi.sms.v20210111.SmsClient;
+
+// 导入要请求接口对应的request response类
+import com.tencentcloudapi.sms.v20210111.models.SendSmsRequest;
+import com.tencentcloudapi.sms.v20210111.models.SendSmsResponse;
+import com.tencentcloudapi.sms.v20210111.models.SendStatus;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+
+import java.util.Date;
+
+/**
+ * Tencent Cloud Sms Sendsms
+ */
+public class SendSms {
+
+
+    //腾讯云上的签名
+//    private static String secretID="AKIDDPo13qZCZqtgJsGQL7AyYu1wc7QVMyLl";
+    private static String secretID = "AKIDCPVZdcWIxgHpy5FYxVyPiqkZGrhdXUBg";
+
+    //腾讯云上的密钥
+//    private static String secretKey="JPGrELFySiv0pOrKOPEwSnulOq9IPPDr";
+    private static String secretKey = "NkyCN3cz97qKaeXLvHOGxOcdS8f184pL";
+
+    //短信应用id
+//    private static String sdkAppid="1400813506";
+    private static String sdkAppid = "1400885930";
+
+    //短信签名内容
+//    private static String signName="华仁享学教育";
+    private static String signName = "江西省创海科技有限公司";
+
+    //模板Id
+//    private static String templateId="1770016";
+    private static String templateId = "2060673"; //验证码
+    private static String templateId2 = "2065770"; //预约短信
+
+    //验证码有效时长
+    private static String smsMin = "1";
+
+
+    public static String sendSms(String phoneNumber, String code) {
+        String returString = "";
+        try {
+            /* 必要步骤:
+             * 实例化一个认证对象,入参需要传入腾讯云账户密钥对secretId,secretKey。
+             * 这里采用的是从环境变量读取的方式,需要在环境变量中先设置这两个值。
+             * 你也可以直接在代码中写死密钥对,但是小心不要将代码复制、上传或者分享给他人,
+             * 以免泄露密钥对危及你的财产安全。
+             * SecretId、SecretKey 查询: https://console.cloud.tencent.com/cam/capi */
+//            Credential cred = new Credential(smsConfig.getSecretID(), smsConfig.getSecretKey());
+            Credential cred = new Credential(secretID, secretKey);
+
+            // 实例化一个http选项,可选,没有特殊需求可以跳过
+            HttpProfile httpProfile = new HttpProfile();
+            // 设置代理(无需要直接忽略)
+            // httpProfile.setProxyHost("真实代理ip");
+            // httpProfile.setProxyPort(真实代理端口);
+            /* SDK默认使用POST方法。
+             * 如果你一定要使用GET方法,可以在这里设置。GET方法无法处理一些较大的请求 */
+            httpProfile.setReqMethod("POST");
+            /* SDK有默认的超时时间,非必要请不要进行调整
+             * 如有需要请在代码中查阅以获取最新的默认值 */
+            httpProfile.setConnTimeout(60);
+            /* 指定接入地域域名,默认就近地域接入域名为 sms.tencentcloudapi.com ,也支持指定地域域名访问,例如广州地域的域名为 sms.ap-guangzhou.tencentcloudapi.com */
+            httpProfile.setEndpoint("sms.tencentcloudapi.com");
+
+            /* 非必要步骤:
+             * 实例化一个客户端配置对象,可以指定超时时间等配置 */
+            ClientProfile clientProfile = new ClientProfile();
+            /* SDK默认用TC3-HMAC-SHA256进行签名
+             * 非必要请不要修改这个字段 */
+            clientProfile.setSignMethod("HmacSHA256");
+            clientProfile.setHttpProfile(httpProfile);
+            /* 实例化要请求产品(以sms为例)的client对象
+             * 第二个参数是地域信息,可以直接填写字符串ap-guangzhou,支持的地域列表参考 https://cloud.tencent.com/document/api/382/52071#.E5.9C.B0.E5.9F.9F.E5.88.97.E8.A1.A8 */
+            SmsClient client = new SmsClient(cred, "ap-guangzhou", clientProfile);
+            /* 实例化一个请求对象,根据调用的接口和实际情况,可以进一步设置请求参数
+             * 你可以直接查询SDK源码确定接口有哪些属性可以设置
+             * 属性可能是基本类型,也可能引用了另一个数据结构
+             * 推荐使用IDE进行开发,可以方便的跳转查阅各个接口和数据结构的文档说明 */
+            SendSmsRequest req = new SendSmsRequest();
+
+            /* 填充请求参数,这里request对象的成员变量即对应接口的入参
+             * 你可以通过官网接口文档或跳转到request对象的定义处查看请求参数的定义
+             * 基本类型的设置:
+             * 帮助链接:
+             * 短信控制台: https://console.cloud.tencent.com/smsv2
+             * 腾讯云短信小助手: https://cloud.tencent.com/document/product/382/3773#.E6.8A.80.E6.9C.AF.E4.BA.A4.E6.B5.81 */
+
+            /* 短信应用ID: 短信SdkAppId在 [短信控制台] 添加应用后生成的实际SdkAppId,示例如1400006666 */
+            // 应用 ID 可前往 [短信控制台](https://console.cloud.tencent.com/smsv2/app-manage) 查看
+//            String sdkAppId = "1400009099";
+//            req.setSmsSdkAppId(smsConfig.getSdkAppid());
+            req.setSmsSdkAppId(sdkAppid);
+
+            /* 短信签名内容: 使用 UTF-8 编码,必须填写已审核通过的签名 */
+            // 签名信息可前往 [国内短信](https://console.cloud.tencent.com/smsv2/csms-sign) 或 [国际/港澳台短信](https://console.cloud.tencent.com/smsv2/isms-sign) 的签名管理查看
+//            String signName = "腾讯云";
+//            req.setSignName(smsConfig.getSignName());
+            req.setSignName(signName);
+
+            /* 模板 ID: 必须填写已审核通过的模板 ID */
+            // 模板 ID 可前往 [国内短信](https://console.cloud.tencent.com/smsv2/csms-template) 或 [国际/港澳台短信](https://console.cloud.tencent.com/smsv2/isms-template) 的正文模板管理查看
+//            String templateId = "449739";
+//            req.setTemplateId(smsConfig.getTemplateId());
+            req.setTemplateId(templateId);
+
+
+            /* 模板参数: 模板参数的个数需要与 TemplateId 对应模板的变量个数保持一致,若无模板参数,则设置为空 */
+//           第一个为验证码,第二个为有效时间
+//            String[] templateParamSet = {code,smsConfig.getSmsMin()};
+            String[] templateParamSet = {code, "1"};
+            req.setTemplateParamSet(templateParamSet);
+
+            /* 下发手机号码,采用 E.164 标准,+[国家或地区码][手机号]
+             * 示例如:+8613711112222, 其中前面有一个+号 ,86为国家码,13711112222为手机号,最多不要超过200个手机号 */
+//            String[] phoneNumberSet = {"+8621212313123", "+8612345678902", "+8612345678903"};
+            String[] phoneNumbers = {phoneNumber};
+            req.setPhoneNumberSet(phoneNumbers);
+
+            /* 用户的 session 内容(无需要可忽略): 可以携带用户侧 ID 等上下文信息,server 会原样返回 */
+//            String sessionContext = "";
+//            req.setSessionContext(sessionContext);
+
+            /* 短信码号扩展号(无需要可忽略): 默认未开通,如需开通请联系 [腾讯云短信小助手] */
+//            String extendCode = "";
+//            req.setExtendCode(extendCode);
+
+            /* 国际/港澳台短信 SenderId(无需要可忽略): 国内短信填空,默认未开通,如需开通请联系 [腾讯云短信小助手] */
+//            String senderid = "";
+//            req.setSenderId(senderid);
+
+            /* 通过 client 对象调用 SendSms 方法发起请求。注意请求方法名与请求对象是对应的
+             * 返回的 res 是一个 SendSmsResponse 类的实例,与请求对象对应 */
+            SendSmsResponse res = client.SendSms(req);
+
+            // 输出json格式的字符串回包
+//            System.out.println(SendSmsResponse.toJsonString(res));
+
+            // 也可以取出单个值,你可以通过官网接口文档或跳转到response对象的定义处查看返回字段的定义
+            // System.out.println(res.getRequestId());
+
+            /* 当出现以下错误码时,快速解决方案参考
+             * [FailedOperation.SignatureIncorrectOrUnapproved](https://cloud.tencent.com/document/product/382/9558#.E7.9F.AD.E4.BF.A1.E5.8F.91.E9.80.81.E6.8F.90.E7.A4.BA.EF.BC.9Afailedoperation.signatureincorrectorunapproved-.E5.A6.82.E4.BD.95.E5.A4.84.E7.90.86.EF.BC.9F)
+             * [FailedOperation.TemplateIncorrectOrUnapproved](https://cloud.tencent.com/document/product/382/9558#.E7.9F.AD.E4.BF.A1.E5.8F.91.E9.80.81.E6.8F.90.E7.A4.BA.EF.BC.9Afailedoperation.templateincorrectorunapproved-.E5.A6.82.E4.BD.95.E5.A4.84.E7.90.86.EF.BC.9F)
+             * [UnauthorizedOperation.SmsSdkAppIdVerifyFail](https://cloud.tencent.com/document/product/382/9558#.E7.9F.AD.E4.BF.A1.E5.8F.91.E9.80.81.E6.8F.90.E7.A4.BA.EF.BC.9Aunauthorizedoperation.smssdkappidverifyfail-.E5.A6.82.E4.BD.95.E5.A4.84.E7.90.86.EF.BC.9F)
+             * [UnsupportedOperation.ContainDomesticAndInternationalPhoneNumber](https://cloud.tencent.com/document/product/382/9558#.E7.9F.AD.E4.BF.A1.E5.8F.91.E9.80.81.E6.8F.90.E7.A4.BA.EF.BC.9Aunsupportedoperation.containdomesticandinternationalphonenumber-.E5.A6.82.E4.BD.95.E5.A4.84.E7.90.86.EF.BC.9F)
+             * 更多错误,可咨询[腾讯云助手](https://tccc.qcloud.com/web/im/index.html#/chat?webAppId=8fa15978f85cb41f7e2ea36920cb3ae1&title=Sms)
+             */
+            SendStatus sendStatus = res.getSendStatusSet()[0];
+            System.out.println(sendStatus.getMessage());
+//            System.out.println("sendStatus = " + sendStatus);
+            returString = sendStatus.getMessage();
+        } catch (TencentCloudSDKException e) {
+            e.printStackTrace();
+        }
+        return returString;
+    }
+
+
+    public static String sendVisitorSms(String phoneNumber, String year, String month, String day, String startTime, String endTime, String code) {
+        String returString = "";
+        try {
+            Credential cred = new Credential(secretID, secretKey);
+
+            HttpProfile httpProfile = new HttpProfile();
+            httpProfile.setReqMethod("POST");
+            httpProfile.setConnTimeout(60);
+            httpProfile.setEndpoint("sms.tencentcloudapi.com");
+            ClientProfile clientProfile = new ClientProfile();
+            clientProfile.setSignMethod("HmacSHA256");
+            clientProfile.setHttpProfile(httpProfile);
+            SmsClient client = new SmsClient(cred, "ap-guangzhou", clientProfile);
+            SendSmsRequest req = new SendSmsRequest();
+            req.setSmsSdkAppId(sdkAppid);
+            req.setSignName(signName);
+            req.setTemplateId(templateId2);
+            String[] templateParamSet = {year, month, day, startTime, endTime, code};
+            req.setTemplateParamSet(templateParamSet);
+            String[] phoneNumbers = {phoneNumber};
+            req.setPhoneNumberSet(phoneNumbers);
+            SendSmsResponse res = client.SendSms(req);
+            SendStatus sendStatus = res.getSendStatusSet()[0];
+            System.out.println(sendStatus.getMessage());
+            returString = sendStatus.getMessage();
+        } catch (TencentCloudSDKException e) {
+            e.printStackTrace();
+        }
+        return returString;
+    }
+
+    public static void main(String[] args) throws TencentCloudSDKException {
+        //这里定义一个存储电话号码的数组
+
+        String tels = "+8618279193722"; // 手机号前面记得带上国家区域编码
+        String test = sendSms("+8618279193722", "123456");
+
+    }
+
+}

+ 731 - 0
src/main/java/com/template/common/utils/TimeExchange.java

@@ -0,0 +1,731 @@
+package com.template.common.utils;
+
+import org.apache.commons.lang3.time.DateFormatUtils;
+import org.apache.commons.lang3.time.DateUtils;
+
+import java.sql.Timestamp;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.time.DayOfWeek;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.time.temporal.ChronoUnit;
+import java.util.*;
+
+/**
+ * 时间转化工具 date转为时间戳 时间戳转date 互相与String的转换
+ * 所有出现的String time 格式都必须为(yyyy-MM-dd HH:mm:ss),否则出错
+ */
+public class TimeExchange {
+
+    /**
+     * 字符串转时间
+     * @param time 时间字符串
+     * @param formatDate 时间格式
+     * @return
+     */
+    public static Date StringToDate(String time, String formatDate) {
+
+        Date date = new Date();
+        // 注意format的格式要与日期String的格式相匹配
+        DateFormat dateFormat = new SimpleDateFormat(formatDate);
+        try {
+            date = dateFormat.parse(time);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        return date;
+    }
+
+    /**
+     * Date转为String
+     * @param time      时间
+     * @param FormatStr 自定义时间格式
+     * @return
+     */
+    public static String DateToString(Date time, String FormatStr) {
+        String dateStr = "";
+        DateFormat dateFormat = new SimpleDateFormat(FormatStr);
+        try {
+            dateStr = dateFormat.format(time);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return dateStr;
+    }
+
+
+    /**
+     * 时间转中文的年月日格式
+     * @param time
+     * @return
+     */
+    public static String chineseDateTime(Date time) {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日 HH时mm分");
+        String dateStringParse = null;
+        try {
+            dateStringParse = sdf.format(time);
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        return dateStringParse;
+    }
+
+    /**
+     * String转时间戳
+     * @param time
+     * @return
+     */
+    public static Integer StringToTimestamp(String time) {
+
+        int times = 0;
+        try {
+            times = (int) ((Timestamp.valueOf(time).getTime()) / 1000);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        if (times == 0) {
+            System.out.println("String转10位时间戳失败");
+        }
+        return times;
+
+    }
+
+    /**
+     * 时间戳转String
+     * 10位int型的时间戳转换为String(yyyy-MM-dd HH:mm:ss)
+     *
+     * @param time
+     * @return
+     */
+    public static String timestampToString(Integer time) {
+        //int转long时,先进行转型再进行计算,否则会是计算结束后在转型
+        long temp = (long) time * 1000;
+        Timestamp ts = new Timestamp(temp);
+        String tsStr = "";
+        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        try {
+            //方法一
+            tsStr = dateFormat.format(ts);
+            System.out.println(tsStr);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return tsStr;
+    }
+
+    /**
+     * 10位时间戳转Date
+     *
+     * @param time
+     * @return
+     */
+    public static Date TimestampToDate(Integer time) {
+        long temp = (long) time * 1000;
+        Timestamp ts = new Timestamp(temp);
+        Date date = new Date();
+        try {
+            date = ts;
+            //System.out.println(date);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return date;
+    }
+
+    /**
+     * 获取当前时间戳
+     *
+     * @return
+     */
+    public static String DateNowTimeStamo() {
+        Date date = new Date();//获取当前的日期
+        SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmssSSS");//设置日期格式
+        String str = df.format(date);//获取String类型的时间
+        return str;
+    }
+
+    /**
+     * Date类型转换为10位时间戳
+     *
+     * @param time
+     * @return
+     */
+    public static Integer DateToTimestamp(Date time) {
+        Timestamp ts = new Timestamp(time.getTime());
+
+        return (int) ((ts.getTime()) / 1000);
+    }
+
+    /**
+     * 时间减小时数
+     * @param time
+     * @param hour
+     * @return
+     */
+    public static String TimeDesH(Date time, int hour) {
+        Calendar nowTime2 = Calendar.getInstance();
+        nowTime2.setTime(time);
+        nowTime2.add(Calendar.HOUR, -hour);
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        return simpleDateFormat.format(nowTime2.getTime());
+    }
+
+    /**
+     * 时间加秒数
+     * @param time
+     * @param s
+     * @return
+     */
+    public static String TimeRangeSrcond(String time, int s) {
+        Calendar nowTime2 = Calendar.getInstance();
+        nowTime2.setTime(StringToDate(time, "yyyy-MM-dd HH:mm:ss"));
+        nowTime2.add(Calendar.SECOND, s);//秒钟
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        return simpleDateFormat.format(nowTime2.getTime());
+    }
+
+    /**
+     * 时间加分钟数
+     * @param time
+     * @param m
+     * @return
+     */
+    public static String TimeRangeMinute(String time, int m) {
+        Calendar nowTime2 = Calendar.getInstance();
+        nowTime2.setTime(StringToDate(time, "yyyy-MM-dd HH:mm:ss"));
+        nowTime2.add(Calendar.MINUTE, m);//分钟
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        return simpleDateFormat.format(nowTime2.getTime());
+    }
+
+    /**
+     * 获取当天开始时间
+     * @return
+     */
+    public static String getStartDate() {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(new Date());
+        int year = calendar.get(Calendar.YEAR);
+        int month = calendar.get(Calendar.MONTH);
+        int day = calendar.get(Calendar.DATE);
+        calendar.setTimeInMillis(0);
+        calendar.set(year, month, day, 0, 0, 0);
+        return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(calendar.getTime());
+    }
+
+    /**
+     * 获取当天结束时间
+     * @return
+     */
+    public static String getEndDate() {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(new Date());
+        int year = calendar.get(Calendar.YEAR);
+        int month = calendar.get(Calendar.MONTH);
+        int day = calendar.get(Calendar.DATE);
+        calendar.setTimeInMillis(0);
+        calendar.set(year, month, day, 23, 59, 59);
+        return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(calendar.getTime());
+    }
+
+    /**
+     * 获取当天的年月日
+     * @return
+     */
+    public static String getDate() {
+        SimpleDateFormat sp = new SimpleDateFormat("yyyy-MM-dd");
+        return sp.format(new Date());
+    }
+
+    /**
+     * 获取当天的年月
+     * @return
+     */
+    public static String getDateMonth() {
+        SimpleDateFormat sp = new SimpleDateFormat("yyyy-MM-");
+        return sp.format(new Date());
+    }
+
+    /**
+     * 获取当前时间的年月日小时分钟秒
+     * @return
+     */
+    public static String getTime() {
+        SimpleDateFormat sp = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        return sp.format(new Date());
+    }
+
+    /**
+     * 获取当前时间的小时分钟
+     * @return
+     */
+    public static String getOnlyMM() {
+        SimpleDateFormat sp = new SimpleDateFormat("HH:mm");
+        return sp.format(new Date());
+    }
+
+    /**
+     * 获取当前时间的年份
+     * @return
+     */
+    public static String getYear() {
+        SimpleDateFormat sp = new SimpleDateFormat("yyyy");
+        return sp.format(new Date());
+    }
+
+    /**
+     * 获取当前时间的年月
+     * @return
+     */
+    public static String getMonth() {
+        SimpleDateFormat sp = new SimpleDateFormat("yyyy-MM");
+        return sp.format(new Date());
+    }
+
+    /**
+     * 获取当前时间的月份
+     * @return
+     */
+    public static String getNowMonth() {
+        SimpleDateFormat sp = new SimpleDateFormat("MM");
+        return sp.format(new Date());
+    }
+
+    /**
+     * 获取当前时间的小时分钟秒
+     * @return
+     */
+    public static String getOnlyTime() {
+        SimpleDateFormat sp = new SimpleDateFormat("HH:mm:ss");
+        return sp.format(new Date());
+    }
+
+    /**
+     * 获取指定时间的年份
+     * @param dateNow
+     * @return
+     */
+    public static String getYear(Date dateNow) {
+        SimpleDateFormat sp = new SimpleDateFormat("yyyy");
+        return sp.format(dateNow);
+    }
+
+    /**
+     * 获取指定时间的月份
+     * @param dateNow
+     * @return
+     */
+    public static String getMonth(Date dateNow) {
+        SimpleDateFormat sp = new SimpleDateFormat("MM");
+        return sp.format(new Date());
+    }
+
+    /**
+     * 获取指定时间的天
+     * @param dateNow
+     * @return
+     */
+    public static String getDay(Date dateNow) {
+        SimpleDateFormat sp = new SimpleDateFormat("dd");
+        return sp.format(new Date());
+    }
+
+    /**
+     * 获取指定时间的小时分钟秒
+     * @param dateNow
+     * @return
+     */
+    public static String getTime(Date dateNow) {
+        SimpleDateFormat sp = new SimpleDateFormat("HH:mm:ss");
+        return sp.format(new Date());
+    }
+
+    /**
+     * 计算两个日期的时间差
+     *
+     * @param time1
+     * @param time2
+     * @return
+     */
+    public static double getTimeDifference(String time1, String time2) {
+        SimpleDateFormat timeformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        long t1 = 0L;
+        long t2 = 0L;
+        try {
+            t1 = timeformat.parse(time1).getTime();
+        } catch (ParseException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        try {
+            t2 = timeformat.parse(time2).getTime();
+        } catch (ParseException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        //因为t1-t2得到的是毫秒级,所以要初3600000得出小时.算天数或秒同理
+        double hours = (double) ((t2 - t1) / 3600000);
+        double minutes = (double) (((t2 - t1) / 1000 - hours * 3600) / 60 / 60);
+        return hours + minutes;
+    }
+
+    /**
+     * 计算两个日期的时间差
+     * @param time1
+     * @param time2
+     * @return
+     */
+    public static double getOnlyTimeDifference(String time1, String time2) {
+        SimpleDateFormat timeformat = new SimpleDateFormat("HH:mm:ss");
+        long t1 = 0L;
+        long t2 = 0L;
+        try {
+            t1 = timeformat.parse(time1).getTime();
+        } catch (ParseException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        try {
+            t2 = timeformat.parse(time2).getTime();
+        } catch (ParseException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        //因为t1-t2得到的是毫秒级,所以要初3600000得出小时.算天数或秒同理
+        double hours = (double) ((t2 - t1) / 3600000);
+        double minutes = (double) (((t2 - t1) / 1000 - hours * 3600) / 60 / 60);
+        return hours + minutes;
+    }
+
+    public static double getDiff(String str1, String str2) {
+        return str2.compareTo(str1);
+    }
+
+    /**
+     * 时间加减分钟数
+     *
+     * @param time      时间
+     * @param FormatStr 时间格式
+     * @param amount    要加减的时间(单位为分钟)
+     * @return
+     * @throws ParseException
+     */
+    public static String TimeRangeMinute(String time, int amount, String FormatStr) throws ParseException {
+        Date endTime = DateUtils.addMinutes(ShortStringToDate(time, FormatStr), amount);
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat(FormatStr);
+        return simpleDateFormat.format(endTime);
+    }
+
+    /**
+     * 时间加减小时数
+     *
+     * @param time      时间
+     * @param FormatStr 时间格式
+     * @param amount    要加减的时间(单位为小时)
+     * @return
+     * @throws ParseException
+     */
+    public static String TimeRangeHour(Date time, int amount, String FormatStr) {
+        Date endTime = DateUtils.addHours(time, amount);
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat(FormatStr);
+        return simpleDateFormat.format(endTime);
+    }
+
+    /**
+     * String 转 Date
+     *
+     * @param time      时间
+     * @param formatStr 自定义时间格式
+     * @return
+     * @throws ParseException
+     */
+    public static Date ShortStringToDate(String time, String formatStr) throws ParseException {
+
+        Date date = new Date();
+        // 注意format的格式要与日期String的格式相匹配
+        DateFormat dateFormat = new SimpleDateFormat(formatStr);
+        try {
+            date = dateFormat.parse(time);
+            System.out.println(date.toString());
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        return date;
+    }
+
+
+
+    /**
+     * 日期路径 即年/月/日 如2018/08/08
+     */
+    public static final String datePath() {
+        Date now = new Date();
+        return DateFormatUtils.format(now, "yyyy/MM/dd");
+    }
+
+    /**
+     * 比较时间1是否小于时间2
+     * 如果时间1小于时间2,接口返回true
+     * 如果时间1大于时间2,接口返回false
+     *
+     * @param dateOne 时间1
+     * @param dateTwo 时间2
+     * @param Forma   时间格式
+     * @return
+     * @throws ParseException
+     */
+    public static boolean CompareDate(String dateOne, String dateTwo, String Forma) throws ParseException {
+        SimpleDateFormat df = new SimpleDateFormat(Forma);
+        Date sd1 = df.parse(dateOne);
+        Date sd2 = df.parse(dateTwo);
+        return sd1.before(sd2);
+    }
+
+    public static LocalDateTime StringToLocalTime(String time, String formatStr) {
+        //1.具有转换功能的对象
+        DateTimeFormatter df = DateTimeFormatter.ofPattern(formatStr);
+        //3.LocalDate发动,将字符串转换成  df格式的LocalDateTime对象,的功能
+        LocalDateTime LocalTime = LocalDateTime.parse(time, df);
+
+        return LocalTime;
+    }
+
+    /**
+     * 获取一周的开始时间和结束时间
+     * 获取本周星期一作为一周的第一天的起始时间和结束时间
+     *
+     * @return 返回的数据中第一个是开始时间 第二个是结束时间
+     */
+    public static String[] getCurrentWeekTimeFrame() {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTimeZone(TimeZone.getTimeZone("GMT+8"));
+        //start of the week
+        if (calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) {
+            calendar.add(Calendar.DAY_OF_YEAR, -1);
+        }
+        calendar.add(Calendar.DAY_OF_WEEK, -(calendar.get(Calendar.DAY_OF_WEEK) - 2));
+        //给0的时候查不出数据
+//        calendar.set(Calendar.HOUR_OF_DAY, 0);
+//        calendar.set(Calendar.MINUTE, 0);
+//        calendar.set(Calendar.SECOND, 0);
+//        calendar.set(Calendar.MILLISECOND, 0);
+
+        String startTime = DateToString(calendar.getTime(), "yyyy-MM-dd");
+        //end of the week
+        calendar.add(Calendar.DAY_OF_WEEK, 6);
+        calendar.set(Calendar.HOUR_OF_DAY, 23);
+        calendar.set(Calendar.MINUTE, 59);
+        calendar.set(Calendar.SECOND, 59);
+        calendar.set(Calendar.MILLISECOND, 999);
+        String endTime = DateToString(calendar.getTime(), "yyyy-MM-dd");
+        return new String[]{startTime, endTime};
+    }
+
+    /**
+     * 获取指定月份有多少天
+     *
+     * @param month
+     * @return
+     */
+    public static int getMonthDays(String date, int month) {
+        int year = Integer.valueOf(date.substring(0, 4));
+        int[] arr = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
+        int day = arr[month - 1];//天数对应=数组-1
+        if (month == 2 && year % 4 == 0 && year % 100 != 0 || year % 400 == 0) {
+            day = 29;
+        }
+
+        return day;
+
+    }
+
+    /**
+     * 获取指定月份的第一天和最后一天
+     *
+     * @param DateStr 指定月份
+     * @return 返回的数据中第一个是开始时间 第二个是结束时间
+     */
+    public static String[] getCurrentMonthTimeFrame(String DateStr) {
+        Calendar c = Calendar.getInstance();//获取Calendar实例
+        c.set(Calendar.YEAR, Integer.parseInt(DateStr.substring(0, 4)));
+        int sss = Integer.parseInt(DateStr.substring(5, 7));
+        c.set(Calendar.MONTH, Integer.parseInt(DateStr.substring(5, 7).replace("-", "")) - 1);
+
+        c.set(Calendar.DAY_OF_MONTH, 1);
+
+        String startDate = new SimpleDateFormat("yyyy-MM-dd").format(c.getTime());
+
+        int lastDay = c.getActualMaximum(Calendar.DAY_OF_MONTH);
+        c.set(Calendar.DAY_OF_MONTH, lastDay);
+        String endDate = new SimpleDateFormat("yyyy-MM-dd").format(c.getTime()) + " 23:59:59";
+
+        return new String[]{startDate, endDate};
+    }
+
+    //region 获取某一天的开始时间
+    public static String getStartOfDayStr(Date date) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date);
+        int year = calendar.get(Calendar.YEAR);
+        int month = calendar.get(Calendar.MONTH);
+        int day = calendar.get(Calendar.DATE);
+        calendar.setTimeInMillis(0);
+        calendar.set(year, month, day, 0, 0, 0);
+        return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(calendar.getTime());
+    }
+    //endregion
+
+    //region 获取某一天的结束时间
+    public static String getEndOfDayStr(Date date) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date);
+        int year = calendar.get(Calendar.YEAR);
+        int month = calendar.get(Calendar.MONTH);
+        int day = calendar.get(Calendar.DATE);
+        calendar.setTimeInMillis(0);
+        calendar.set(year, month, day, 23, 59, 59);
+        return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(calendar.getTime());
+    }
+    //endregion
+
+    //region 获取指定月份的最后一天
+    public static Date getToMonthEndDate(String DateStr) {
+        Calendar c = Calendar.getInstance();
+        c.clear();
+        c.set(Calendar.YEAR, Integer.parseInt(DateStr.substring(0, 4)));
+        c.set(Calendar.MONTH, Integer.parseInt(DateStr.substring(5, 7).replace("-", "")) - 1);
+        c.roll(Calendar.DAY_OF_MONTH, -1);
+        c.set(Calendar.HOUR_OF_DAY, 23);
+        c.set(Calendar.MINUTE, 59);
+        c.set(Calendar.SECOND, 59);
+        c.set(Calendar.MILLISECOND, 999);
+
+        return c.getTime();
+    }
+    //endregion
+
+    //region 获取指定月份的第一天
+    public static Date getToMonthBeginDate(String DateStr) {
+        Calendar c = Calendar.getInstance();
+        c.clear();
+        c.set(Calendar.YEAR, Integer.parseInt(DateStr.substring(0, 4)));
+        c.set(Calendar.MONTH, Integer.parseInt(DateStr.substring(5, 7).replace("-", "")) - 1);
+        c.set(Calendar.HOUR_OF_DAY, 0);
+        c.set(Calendar.MINUTE, 0);
+        c.set(Calendar.SECOND, 0);
+        c.set(Calendar.MILLISECOND, 000);
+        return c.getTime();
+    }
+    //endregion
+
+    //region 获取某一天的开始时间
+    public static Date getStartOfDay(Date date) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date);
+        int year = calendar.get(Calendar.YEAR);
+        int month = calendar.get(Calendar.MONTH);
+        int day = calendar.get(Calendar.DATE);
+        calendar.set(year, month, day, 0, 0, 0);
+        calendar.set(Calendar.MILLISECOND, 000);
+        return calendar.getTime();
+    }
+    //endregion
+
+    //region 获取某一天的结束时间
+    public static Date getEndOfDay(Date date) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date);
+        int year = calendar.get(Calendar.YEAR);
+        int month = calendar.get(Calendar.MONTH);
+        int day = calendar.get(Calendar.DATE);
+        calendar.setTimeInMillis(0);
+        calendar.set(year, month, day, 23, 59, 59);
+        return calendar.getTime();
+    }
+    //endregion
+
+
+    /**
+     * 获取时间date1与date2相差的秒数
+     *
+     * @param date1 起始时间
+     * @param date2 结束时间
+     * @return 返回相差的秒数
+     */
+    public static int getOffsetSeconds(Date date1, Date date2) {
+        int seconds = (int) ((date2.getTime() - date1.getTime()) / 1000);
+        return seconds;
+    }
+
+    /**
+     * 获取时间date1与date2相差的分钟数
+     *
+     * @param date1 起始时间
+     * @param date2 结束时间
+     * @return 返回相差的分钟数
+     */
+    public static int getOffsetMinutes(Date date1, Date date2) {
+        return getOffsetSeconds(date1, date2) / 60;
+    }
+
+    /**
+     * 获取时间date1与date2相差的小时数
+     *
+     * @param date1 起始时间
+     * @param date2 结束时间
+     * @return 返回相差的小时数
+     */
+    public static int getOffsetHours(Date date1, Date date2) {
+        return getOffsetMinutes(date1, date2) / 60;
+    }
+
+    /**
+     * 获取时间date1与date2相差的天数数
+     *
+     * @param date1 起始时间
+     * @param date2 结束时间
+     * @return 返回相差的天数
+     */
+    public static int getOffsetDays(Date date1, Date date2) {
+        return getOffsetHours(date1, date2) / 24 + 1;
+    }
+
+    public static boolean overlapping(String start1, String end1, String start2, String end2) throws ParseException {
+        boolean one = CompareDate(start1, end2, "HH:mm");
+        boolean two = CompareDate(start2, end1, "HH:mm");
+        return (one && two);
+    }
+
+    public static String getWeek(String sdate) throws ParseException {
+        // 再转换为时间
+        Date date = StringToDate(sdate, "yyyy-MM-dd");
+        Calendar c = Calendar.getInstance();
+        c.setTime(date);
+        // int hour=c.get(Calendar.DAY_OF_WEEK);
+        // hour中存的就是星期几了,其范围 1~7
+        // 1=星期日 7=星期六,其他类推
+        return new SimpleDateFormat("EEEE").format(c.getTime());
+    }
+
+    public static void main(String[] args) {
+        String[] s = new String[]{"5","2","C","D","+"};
+
+        int sds = calPoints(s);
+        String sdsd = "";
+    }
+
+
+    public static int calPoints(String[] operations) {
+
+        return 0;
+    }
+
+}
+

+ 628 - 0
src/main/java/com/template/common/utils/TimeExchange2.java

@@ -0,0 +1,628 @@
+package com.template.common.utils;
+
+import java.sql.Timestamp;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+/**
+ * 时间转化工具 date转为时间戳 时间戳转date 互相与String的转换
+ * 所有出现的String time 格式都必须为(yyyy-MM-dd HH:mm:ss),否则出错
+ * @author
+ *
+ */
+public class TimeExchange2 {
+
+    /**
+     * String(yyyy-MM-dd HH:mm:ss) 转 Date
+     *
+     * @param time
+     * @return
+     * @throws ParseException
+     */
+    // String date = "2010/05/04 12:34:23";
+    public static Date StringToDate(String time) throws ParseException {
+
+        Date date = new Date();
+        // 注意format的格式要与日期String的格式相匹配
+        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        try {
+            date = dateFormat.parse(time);
+            System.out.println(date.toString());
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        return date;
+    }
+
+    public static Date StringToDate2(String time) throws ParseException {
+
+        Date date = new Date();
+        // 注意format的格式要与日期String的格式相匹配
+        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        try {
+            date = dateFormat.parse(time);
+            System.out.println(date.toString());
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        return date;
+    }
+
+    /**
+     * String(yyyy-MM-dd HH:mm:ss) 转 Date
+     *
+     * @param time
+     * @return
+     * @throws ParseException
+     */
+    // String date = "2010/05/04 12:34:23";
+    public static Date StringToDate(String time, String formatStr) throws ParseException {
+
+        Date date = new Date();
+        // 注意format的格式要与日期String的格式相匹配
+        DateFormat dateFormat = new SimpleDateFormat(formatStr);
+        try {
+            date = dateFormat.parse(time);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        return date;
+    }
+
+
+    /**
+     * Date转为String(yyyy-MM-dd HH:mm:ss)
+     *
+     * @param time
+     * @return
+     */
+    public static String DateToString(Date time) {
+        String dateStr = "";
+        Date date = new Date();
+        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH/mm/ss");
+        try {
+            dateStr = dateFormat.format(time);
+            System.out.println(dateStr);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return dateStr;
+    }
+
+    public static String ToSimpleMonth(Date time) {
+        String dateStr = "";
+        DateFormat dateFormat = new SimpleDateFormat("M");
+        try {
+            dateStr = dateFormat.format(time);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return dateStr;
+    }
+
+    /**
+     * String(yyyy-MM-dd HH:mm:ss)转10位时间戳
+     * @param time
+     * @return
+     */
+    public static Integer StringToTimestamp(String time){
+
+        int times = 0;
+        try {
+            times = (int) ((Timestamp.valueOf(time).getTime())/1000);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        if(times==0){
+            System.out.println("String转10位时间戳失败");
+        }
+        return times;
+
+    }
+    /**
+     * 10位int型的时间戳转换为String(yyyy-MM-dd HH:mm:ss)
+     * @param time
+     * @return
+     */
+    public static String timestampToString(Integer time){
+        //int转long时,先进行转型再进行计算,否则会是计算结束后在转型
+        long temp = (long)time*1000;
+        Timestamp ts = new Timestamp(temp);
+        String tsStr = "";
+        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        try {
+            //方法一
+            tsStr = dateFormat.format(ts);
+            System.out.println(tsStr);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return tsStr;
+    }
+    /**
+     * 10位时间戳转Date
+     * @param time
+     * @return
+     */
+    public static Date TimestampToDate(Integer time){
+        long temp = (long)time*1000;
+        Timestamp ts = new Timestamp(temp);
+        Date date = new Date();
+        try {
+            date = ts;
+            //System.out.println(date);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return date;
+    }
+    /**
+     * Date类型转换为10位时间戳
+     * @param time
+     * @return
+     */
+    public static Integer DateToTimestamp(Date time){
+        Timestamp ts = new Timestamp(time.getTime());
+
+        return (int) ((ts.getTime())/1000);
+    }
+
+    // 当前时间减1小时
+    public static String TimeDesH(String time) throws ParseException {
+        Calendar nowTime2 = Calendar.getInstance();
+        nowTime2.setTime(StringToDate(time));
+        nowTime2.add(Calendar.HOUR, -1);
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        return simpleDateFormat.format(nowTime2.getTime());
+    }
+
+    // 最近两天
+    public static String getLastTwo() throws ParseException {
+        Calendar nowTime2 = Calendar.getInstance();
+        nowTime2.setTime(StringToDate(getTime()));
+        nowTime2.add(Calendar.DATE, -2);
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        return simpleDateFormat.format(nowTime2.getTime());
+    }
+
+    // 当前时间加2分钟
+    public static String TimeRangeI10(String time,int m) throws ParseException {
+        Calendar nowTime2 = Calendar.getInstance();
+        nowTime2.setTime(StringToDate(time));
+        nowTime2.add(Calendar.SECOND, m);//10分钟前的时间
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        return simpleDateFormat.format(nowTime2.getTime());
+    }
+
+    // 当前时间加多少分钟
+    public static String TimeRangeM(String time,int m) throws ParseException {
+        Calendar nowTime2 = Calendar.getInstance();
+        nowTime2.setTime(StringToDate2(time));
+        nowTime2.add(Calendar.MINUTE, m);//10分钟前的时间
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        return simpleDateFormat.format(nowTime2.getTime());
+    }
+
+
+    // 当前时间减5分钟
+    public static String TimeRangeD(String time) throws ParseException {
+        Calendar nowTime2 = Calendar.getInstance();
+        nowTime2.setTime(StringToDate(time));
+        nowTime2.add(Calendar.MINUTE, -300);//5分钟前的时间
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        return simpleDateFormat.format(nowTime2.getTime());
+    }
+
+    // 获取当前日期
+    public static String getDateStr(){
+        SimpleDateFormat sp = new SimpleDateFormat("yyyy-MM-dd");
+        return sp.format(new Date());
+    }
+
+    // 获取当前日期
+    public static String getDate(){
+        SimpleDateFormat sp = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        return sp.format(new Date());
+    }
+
+    // 获取前天
+    public static String getQianDay() throws ParseException {
+        Calendar nowTime2 = Calendar.getInstance();
+        nowTime2.setTime(StringToDate(getTime()));
+        nowTime2.add(Calendar.DATE, -5);//5分钟前的时间
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        return simpleDateFormat.format(nowTime2.getTime());
+    }
+
+    // 获取明天
+    public static String getTomorrow() throws ParseException {
+        Calendar nowTime2 = Calendar.getInstance();
+        nowTime2.setTime(StringToDate(getTime()));
+        nowTime2.add(Calendar.DATE, 1);//5分钟前的时间
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        return simpleDateFormat.format(nowTime2.getTime());
+    }
+
+    // 获取昨天
+    public static String getYesturday()  {
+        try {
+            Calendar nowTime2 = Calendar.getInstance();
+            nowTime2.setTime(StringToDate(getTime()));
+            nowTime2.add(Calendar.DATE, -1);
+            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+            return simpleDateFormat.format(nowTime2.getTime());
+        } catch (ParseException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    // 获取最近7个月
+    public static List<String> getLastSevenMonth() throws ParseException {
+        List<String> ls = new ArrayList<>();
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM");
+        for (int i = -6; i <= 0; i++) {
+            Calendar nowTime2 = Calendar.getInstance();
+            nowTime2.setTime(StringToDate(getTime()));
+            nowTime2.add(Calendar.MONTH, i);//5分钟前的时间
+            ls.add(simpleDateFormat.format(nowTime2.getTime()));
+        }
+        return ls;
+    }
+
+    public static String getTomorrowTime() throws ParseException {
+        Calendar nowTime2 = Calendar.getInstance();
+        nowTime2.setTime(StringToDate(getTime()));
+        nowTime2.add(Calendar.DATE, 1);//5分钟前的时间
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        return simpleDateFormat.format(nowTime2.getTime());
+    }
+
+    public static String getWeek(String sdate) throws ParseException {
+        // 再转换为时间
+        Date date = StringToDate(sdate,"yyyy-MM-dd");
+        Calendar c = Calendar.getInstance();
+        c.setTime(date);
+        // int hour=c.get(Calendar.DAY_OF_WEEK);
+        // hour中存的就是星期几了,其范围 1~7
+        // 1=星期日 7=星期六,其他类推
+        return new SimpleDateFormat("EEEE").format(c.getTime());
+    }
+
+    // 今天星期几
+    public static String getWeek() throws ParseException {
+        String[] weeks = {"7","1","2","3","4","5","6"};
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(StringToDate(getTime()));
+        int week_index = cal.get(Calendar.DAY_OF_WEEK) - 1;
+        if(week_index<0){
+            week_index = 0;
+        }
+        return weeks[week_index];
+    }
+
+    // 明天星期几
+    public static String getTomorrowWeek() throws ParseException {
+        String[] weeks = {"7","1","2","3","4","5","6"};
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(StringToDate(getTomorrowTime()));
+        int week_index = cal.get(Calendar.DAY_OF_WEEK) - 1;
+        if(week_index<0){
+            week_index = 0;
+        }
+        return weeks[week_index];
+    }
+
+    // 获取当前时间
+    public static String getTime(){
+        SimpleDateFormat sp = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        return sp.format(new Date());
+    }
+
+    public static String getOnlyMM(){
+        SimpleDateFormat sp = new SimpleDateFormat("HH:mm");
+        return sp.format(new Date());
+    }
+
+    public static String getOnlyDesMM() throws ParseException {
+        Calendar nowTime2 = Calendar.getInstance();
+        nowTime2.setTime(StringToDate(getTime()));
+        nowTime2.add(Calendar.MINUTE, -5);//5分钟前的时间
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:mm");
+        return simpleDateFormat.format(nowTime2.getTime());
+    }
+
+    public static String getYear(){
+        SimpleDateFormat sp = new SimpleDateFormat("yyyy");
+        return sp.format(new Date());
+    }
+
+    public static String getMonth(){
+        SimpleDateFormat sp = new SimpleDateFormat("yyyy-MM");
+        return sp.format(new Date());
+    }
+
+    // 获取当前时间
+    public static String getOnlyTime(){
+        SimpleDateFormat sp = new SimpleDateFormat("HH:mm:ss");
+        return sp.format(new Date());
+    }
+    /**
+     * 计算两个日期的时间差
+     * @param time1
+     * @param time2
+     * @return
+     */
+    public static double getTimeDifference(String time1, String time2) {
+        SimpleDateFormat timeformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        long t1 = 0L;
+        long t2 = 0L;
+        try {
+            t1 = timeformat.parse(time1).getTime();
+        } catch (ParseException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        try {
+            t2 = timeformat.parse(time2).getTime();
+        } catch (ParseException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        //因为t1-t2得到的是毫秒级,所以要初3600000得出小时.算天数或秒同理
+        double hours=(double) ((t2 - t1)/3600000);
+        double minutes=(double) (((t2 - t1)/1000-hours*3600)/60/60);
+        return hours+minutes;
+    }
+
+    public static double getOnlyTimeDifference(String time1, String time2) {
+        SimpleDateFormat timeformat = new SimpleDateFormat("HH:mm:ss");
+        long t1 = 0L;
+        long t2 = 0L;
+        try {
+            t1 = timeformat.parse(time1).getTime();
+        } catch (ParseException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        try {
+            t2 = timeformat.parse(time2).getTime();
+        } catch (ParseException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        //因为t1-t2得到的是毫秒级,所以要初3600000得出小时.算天数或秒同理
+        double hours=(double) ((t2 - t1)/3600000);
+        double minutes=(double) (((t2 - t1)/1000-hours*3600)/60/60);
+        return hours+minutes;
+    }
+
+    public static double getDiff(String str1, String str2){
+        return str2.compareTo(str1);
+    }
+
+    /**
+     * String 转 Date
+     * @param time 时间
+     * @param formatStr 自定义时间格式
+     * @return
+     * @throws ParseException
+     */
+    public static Date ShortStringToDate(String time, String formatStr) throws ParseException {
+
+        Date date = new Date();
+        // 注意format的格式要与日期String的格式相匹配
+        DateFormat dateFormat = new SimpleDateFormat(formatStr);
+        try {
+            date = dateFormat.parse(time);
+            System.out.println(date.toString());
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        return date;
+    }
+
+    /**
+     * 获取指定月份有多少天
+     *
+     * @param month
+     * @return
+     */
+    public static int getMonthDays(String date, int month) {
+        int year = Integer.valueOf(date.substring(0, 4));
+        int[] arr = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
+        int day = arr[month - 1];//天数对应=数组-1
+        if (month == 2 && year % 4 == 0 && year % 100 != 0 || year % 400 == 0) {
+            day = 29;
+        }
+
+        return day;
+
+    }
+
+    /**
+     * Date转为String
+     * @param time 时间
+     * @param FormatStr 自定义时间格式
+     * @return
+     */
+    public static String DateToString(Date time, String FormatStr) {
+        String dateStr = "";
+        DateFormat dateFormat = new SimpleDateFormat(FormatStr);
+        try {
+            dateStr = dateFormat.format(time);
+            System.out.println(dateStr);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return dateStr;
+    }
+
+    /**
+     * 比较时间1是否小于时间2
+     * 如果时间1小于时间2,接口返回true
+     * 如果时间1大于时间2,接口返回false
+     * @param dateOne 时间1
+     * @param dateTwo 时间2
+     * @return
+     * @throws ParseException
+     */
+    public static boolean CompareDate(String dateOne, String dateTwo) throws ParseException {
+        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        Date sd1=df.parse(dateOne);
+        Date sd2=df.parse(dateTwo);
+        return sd1.before(sd2);
+    }
+
+    /**
+     * 比较时间1是否小于时间2
+     * 如果时间1小于时间2,接口返回true
+     * 如果时间1大于时间2,接口返回false
+     *
+     * @param dateOne 时间1
+     * @param dateTwo 时间2
+     * @param Forma   时间格式
+     * @return
+     * @throws ParseException
+     */
+    public static boolean CompareDate(String dateOne, String dateTwo, String Forma) throws ParseException {
+        SimpleDateFormat df = new SimpleDateFormat(Forma);
+        Date sd1 = df.parse(dateOne);
+        Date sd2 = df.parse(dateTwo);
+        return sd1.before(sd2);
+    }
+
+    /**
+     * 时间加减天数
+     *
+     * @param time   时间
+     * @param amount 天数 负的为减多少天 正的为加多少天
+     * @return
+     * @throws ParseException
+     */
+    public static String TimeDesD(String time, int amount) throws ParseException {
+        Calendar nowTime2 = Calendar.getInstance();
+        nowTime2.setTime(StringToDate(time, "yyyy-MM-dd"));
+        nowTime2.add(Calendar.DATE, amount);
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        return simpleDateFormat.format(nowTime2.getTime());
+    }
+
+    /**
+     * 相差的天数
+     */
+    public static int daysBetween(String smdate, String bdate) throws ParseException {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        Calendar cal = Calendar.getInstance();
+        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));
+    }
+
+    /**
+     * 获取一周的开始时间和结束时间
+     * 获取本周星期一作为一周的第一天的起始时间和结束时间
+     *
+     * @return 返回的数据中第一个是开始时间 第二个是结束时间
+     */
+    public static String[] getCurrentWeekTimeFrame() {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTimeZone(TimeZone.getTimeZone("GMT+8"));
+        //start of the week
+        if (calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) {
+            calendar.add(Calendar.DAY_OF_YEAR,-1);
+        }
+        calendar.add(Calendar.DAY_OF_WEEK, -(calendar.get(Calendar.DAY_OF_WEEK) - 2));
+        //给0的时候查不出数据
+//        calendar.set(Calendar.HOUR_OF_DAY, 0);
+//        calendar.set(Calendar.MINUTE, 0);
+//        calendar.set(Calendar.SECOND, 0);
+//        calendar.set(Calendar.MILLISECOND, 0);
+
+        String startTime = DateToString(calendar.getTime(), "yyyy-MM-dd");
+        //end of the week
+        calendar.add(Calendar.DAY_OF_WEEK, 6);
+        calendar.set(Calendar.HOUR_OF_DAY, 23);
+        calendar.set(Calendar.MINUTE, 59);
+        calendar.set(Calendar.SECOND, 59);
+        calendar.set(Calendar.MILLISECOND, 999);
+        String endTime = DateToString(calendar.getTime());
+        return new String[]{startTime, endTime};
+    }
+
+    /**
+     * 获取指定月份的第一天和最后一天
+     * @param DateStr 指定月份
+     * @return 返回的数据中第一个是开始时间 第二个是结束时间
+     */
+    public static String[] getCurrentMonthTimeFrame(String DateStr) {
+        Calendar c = Calendar.getInstance();//获取Calendar实例
+        c.set(Calendar.YEAR, Integer.parseInt(DateStr.substring(0, 4)));
+        c.set(Calendar.MONTH, Integer.parseInt(DateStr.substring(5, 7).replace("-", "")) - 1);
+
+        c.set(Calendar.DAY_OF_MONTH, 1);
+
+        String startDate = new SimpleDateFormat("yyyy-MM-dd").format(c.getTime());
+
+        int lastDay = c.getActualMaximum(Calendar.DAY_OF_MONTH);
+        c.set(Calendar.DAY_OF_MONTH, lastDay);
+        String endDate = new SimpleDateFormat("yyyy-MM-dd").format(c.getTime());
+
+        return new String[]{startDate, endDate};
+    }
+
+    public static List<String> getHighTime(){
+        String year = getYear();
+        return Arrays.asList(year+"-"+"08-30",year+"-"+"08-31",year+"-"+"09-01",year+"-"+"09-02",year+"-"+"09-03",year+"-"+"09-04");
+    }
+
+    public static List<String> getDays(String startTime, String endTime) {
+        // 返回的日期集合
+        List<String> days = new ArrayList<String>();
+        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        try {
+            Date start = dateFormat.parse(startTime);
+            Date end = dateFormat.parse(endTime);
+            Calendar tempStart = Calendar.getInstance();
+            tempStart.setTime(start);
+
+            Calendar tempEnd = Calendar.getInstance();
+            tempEnd.setTime(end);
+            tempEnd.add(Calendar.DATE, 0);// 日期加1(包含结束)
+            while (tempStart.before(tempEnd)) {
+                days.add(dateFormat.format(tempStart.getTime()));
+                tempStart.add(Calendar.DAY_OF_YEAR, 1);
+            }
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        return days;
+    }
+
+
+    public static void main(String[] args) throws ParseException {
+        char a = 'A';
+        char b = 'B';
+        int result = b -a;
+
+        String s = "ZY";
+        int ans = 0;
+        for(int i=0;i<s.length();i++) {
+            int num = s.charAt(i) - 'A' + 1;
+            ans = ans * 26 + num;
+        }
+
+        System.out.println(ans);
+    }
+
+}
+

+ 25 - 0
src/main/java/com/template/common/utils/UUIDUtil.java

@@ -0,0 +1,25 @@
+package com.template.common.utils;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Random;
+
+public class UUIDUtil {
+
+    public static long generateID(){
+
+        Random r = new Random();
+        long numbers = 1000000000L + (long)(r.nextDouble() * 999999999L);
+
+        return numbers;
+    }
+
+    public static String getNewDate(){
+        Date nowDate = new Date();// 取当前时间
+        SimpleDateFormat dateFormat = new SimpleDateFormat(
+                "yyyy-MM-dd HH:mm:ss"); // 转换时间格式
+        String date = dateFormat.format(nowDate);
+        return date;
+    }
+
+}

+ 25 - 0
src/main/java/com/template/common/utils/ValidateCode.java

@@ -0,0 +1,25 @@
+package com.template.common.utils;
+
+import java.util.Random;
+
+//验证码随机数
+public  class  ValidateCode {
+
+   public static Integer generateValidateCode(int length){
+       Integer code =null;
+       if(length == 4){
+           code = new Random().nextInt(9999);//生成随机数,最大为9999
+           if(code < 1000){
+               code = code + 1000;//保证随机数为4位数字
+           }
+       }else if(length == 6){
+           code = new Random().nextInt(999999);//生成随机数,最大为999999
+           if(code < 100000){
+               code = code + 100000;//保证随机数为6位数字
+           }
+       }else{
+           throw new RuntimeException("只能生成4位或6位数字验证码");
+       }
+       return code;
+   }
+}

+ 52 - 0
src/main/java/com/template/common/utils/WxConfig.java

@@ -0,0 +1,52 @@
+package com.template.common.utils;
+
+import org.springframework.stereotype.Component;
+
+import java.util.HashMap;
+
+/**
+ * 微信公众号开发配置类
+ * @author lujunjie
+ * @date   2018/03/01
+ */
+@Component
+public class WxConfig {
+
+    /**
+     * 开发者ID
+     */
+    public static String apicode = "CS0001";
+
+    /**
+     * 商户号
+     */
+    public static String apikey  = "XMZnRsZe61hEXyYa7JuAtUupJZ2Q5byc";
+
+
+    /**
+     * 统一下单-通知链接
+     */
+    public static String unifiedorderNotifyUrl = "https://app.dev.9kbs.com/";
+
+
+    /**
+     * 连接超时时间
+     */
+    public static Integer connectionTimeout = 15000;
+
+    /**
+     * 连接超时时间
+     */
+    public static Integer readTimeout = 15000;
+
+    //支付map缓存处理
+    private static HashMap<String,String> payMap = new HashMap<String,String>();
+    public static String getPayMap(String key) {
+        return payMap.get(key);
+    }
+    public static void setPayMap(String key,String value) {
+        payMap.put(key,value);
+    }
+
+
+}

+ 53 - 0
src/main/java/com/template/common/utils/WxConstants.java

@@ -0,0 +1,53 @@
+package com.template.common.utils;
+
+/**
+ * 微信公众号常量类
+ * @author lujunjie
+ * @date   2018/06/28
+ */
+public class WxConstants {
+
+    /**
+     * 默认编码
+     */
+    public static final String DEFAULT_CHARSET = "UTF-8";
+
+    /**
+     * 统一下单-扫描支付
+     */
+    public static String PAY_UNIFIEDORDER = "https://app.dev.9kbs.com/shopOpenApi/services/deviceAntiScode/getStartCode";
+
+    public static String Test = "http://localhost:8088/HotWaters/userget_stu.action";
+
+    public static String Test2 = "http://localhost:8088/HotWaters/userstu_info.action";
+
+    /**
+     * 请求成功返回码
+     */
+    public final static String ERRCODE_OK_CODE = "0";
+    /**
+     * 错误的返回码的Key
+     */
+    public final static String ERRCODE = "errcode";
+
+    /**
+     * 返回状态码
+     */
+    public final static String RETURN_CODE= "return_code";
+
+    /**
+     * access_token 字符串
+     */
+    public final static String ACCESS_TOKEN = "access_token";
+
+    /**
+     * 签名类型 MD5
+     */
+    public final static String SING_MD5 = "MD5";
+
+    /**
+     * 签名类型 HMAC-SHA256
+     */
+    public final static String SING_HMACSHA256 = "HMAC-SHA256";
+
+}

+ 385 - 0
src/main/java/com/template/common/utils/WxUtil.java

@@ -0,0 +1,385 @@
+package com.template.common.utils;
+
+
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import javax.crypto.Mac;
+import javax.crypto.spec.SecretKeySpec;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletResponse;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+import java.io.*;
+import java.security.MessageDigest;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+/**
+ * 微信公众号接口工具类
+ * @author lujunjie
+ * @date   2018/03/01
+ */
+public class WxUtil {
+
+	/**
+	 * 加密/校验流程如下:
+	 * 1. 将token、timestamp、nonce三个参数进行字典序排序<br>
+	 * 2. 将三个参数字符串拼接成一个字符串进行sha1加密<br>
+	 * 3. 开发者获得加密后的字符串可与signature对比,标识该请求来源于微信<br>
+	 *
+	 * @param token Token验证密钥
+	 * @param signature 微信加密签名,signature结合了开发者填写的token参数和请求中的timestamp参数,nonce参数
+	 * @param timestamp 时间戳
+	 * @param nonce 随机数
+	 * @return 验证成功返回:true,失败返回:false
+	 */
+	public static boolean checkSignature(String token, String signature, String timestamp, String nonce) {
+		List<String> params = new ArrayList<String>();
+		params.add(token);
+		params.add(timestamp);
+		params.add(nonce);
+		//1. 将token、timestamp、nonce三个参数进行字典序排序
+		Collections.sort(params, new Comparator<String>() {
+			@Override
+			public int compare(String o1, String o2) {
+				return o1.compareTo(o2);
+			}
+		});
+		//2. 将三个参数字符串拼接成一个字符串进行sha1加密
+		String temp = SHA1.encode(params.get(0) + params.get(1) + params.get(2));
+		//3. 开发者获得加密后的字符串可与signature对比,标识该请求来源于微信
+		return temp.equals(signature);
+	}
+
+	/**
+	 * 输入流转化为字符串
+	 * @param inputStream 流
+	 * @return String 字符串
+	 * @throws Exception
+	 */
+	public static String getStreamString(InputStream inputStream) throws Exception{
+		StringBuffer buffer=new StringBuffer();
+		InputStreamReader inputStreamReader = null;
+		BufferedReader bufferedReader = null;
+		try{
+			inputStreamReader=new InputStreamReader(inputStream, WxConstants.DEFAULT_CHARSET);
+			bufferedReader=new BufferedReader(inputStreamReader);
+			String line;
+			while((line=bufferedReader.readLine())!=null){
+				buffer.append(line);
+			}
+		}catch(Exception e){
+			throw new Exception();
+		}finally {
+			if(bufferedReader != null){
+				bufferedReader.close();
+			}
+			if(inputStreamReader != null){
+				inputStreamReader.close();
+			}
+			if(inputStream != null){
+				inputStream.close();
+			}
+		}
+		return buffer.toString();
+	}
+
+	/**
+	 * 获取随机字符串 Nonce Str
+	 * @return String 随机字符串
+	 */
+	public static String getNonceStr() {
+		return UUID.randomUUID().toString().replaceAll("-", "").substring(0, 32);
+	}
+
+	/**
+	 * 生成签名. 注意,若含有sign_type字段,必须和signType参数保持一致。
+	 * @param data 待签名数据
+	 * @param apikey API密钥
+	 * @return 签名
+	 */
+	public static String getSignature(final Map<String, String> data, String apikey,
+				String signType) throws Exception {
+		Set<String> keySet = data.keySet();
+		String[] keyArray = keySet.toArray(new String[keySet.size()]);
+		Arrays.sort(keyArray);
+		StringBuilder sb = new StringBuilder();
+		sb.append(apikey);
+		sb.append("amount10apicodeCS0001collect_code");
+		sb.append(data.get("collect_code").trim());
+		sb.append("order_no");
+		sb.append(data.get("order_no").trim());
+        sb.append("timestamp");
+        sb.append(data.get("timestamp").trim());
+        sb.append(apikey);
+		System.out.println(sb);
+		if (signType.equals(WxConstants.SING_MD5)) {
+			System.out.println(MD5(sb.toString()).toUpperCase());
+			return MD5(sb.toString()).toLowerCase();
+		}
+		else if (signType.equals(WxConstants.SING_HMACSHA256)) {
+			return HMACSHA256(sb.toString(), apikey);
+		}
+		else {
+			throw new Exception(String.format("Invalid sign_type: %s", signType));
+		}
+	}
+
+	/**
+	 * 生成 MD5
+	 * @param data 待处理数据
+	 * @return MD5结果
+	 */
+	public static String MD5(String data) throws Exception {
+		MessageDigest md = MessageDigest.getInstance("MD5");
+		byte[] array = md.digest(data.getBytes("UTF-8"));
+		StringBuilder sb = new StringBuilder();
+		for (byte item : array) {
+			sb.append(Integer.toHexString((item & 0xFF) | 0x100).substring(1, 3));
+		}
+		return sb.toString().toUpperCase();
+	}
+
+	/**
+	 * 生成 HMACSHA256
+	 * @param data 待处理数据
+	 * @param key 密钥
+	 * @return 加密结果
+	 * @throws Exception
+	 */
+	public static String HMACSHA256(String data, String key) throws Exception {
+		Mac sha256_HMAC = Mac.getInstance("HmacSHA256");
+		SecretKeySpec secret_key = new SecretKeySpec(key.getBytes("UTF-8"), "HmacSHA256");
+		sha256_HMAC.init(secret_key);
+		byte[] array = sha256_HMAC.doFinal(data.getBytes("UTF-8"));
+		StringBuilder sb = new StringBuilder();
+		for (byte item : array) {
+			sb.append(Integer.toHexString((item & 0xFF) | 0x100).substring(1, 3));
+		}
+		return sb.toString().toUpperCase();
+	}
+
+	/**
+	 * @param data Map类型数据
+	 * @return XML格式的字符串
+	 * @throws Exception
+	 */
+	public static String mapToXml(Map<String, String> data) throws Exception {
+		DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
+		DocumentBuilder documentBuilder= documentBuilderFactory.newDocumentBuilder();
+		org.w3c.dom.Document document = documentBuilder.newDocument();
+		org.w3c.dom.Element root = document.createElement("xml");
+		document.appendChild(root);
+		for (String key: data.keySet()) {
+			String value = data.get(key);
+			if (value == null) {
+				value = "";
+			}
+			value = value.trim();
+			org.w3c.dom.Element filed = document.createElement(key);
+			filed.appendChild(document.createTextNode(value));
+			root.appendChild(filed);
+		}
+		TransformerFactory tf = TransformerFactory.newInstance();
+		Transformer transformer = tf.newTransformer();
+		DOMSource source = new DOMSource(document);
+		transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
+		transformer.setOutputProperty(OutputKeys.INDENT, "yes");
+		StringWriter writer = new StringWriter();
+		StreamResult result = new StreamResult(writer);
+		transformer.transform(source, result);
+		String output = writer.getBuffer().toString(); //.replaceAll("\n|\r", "");
+		try {
+			writer.close();
+		}
+		catch (Exception ex) {
+		}
+		return output;
+	}
+
+	/**
+	 * 处理 HTTPS API返回数据,转换成Map对象。return_code为SUCCESS时,验证签名。
+	 * @param xmlStr API返回的XML格式数据
+	 * @return Map类型数据
+	 * @throws Exception
+	 */
+	public static Map<String, String> processResponseXml(String xmlStr,String signType) throws Exception {
+		String RETURN_CODE = WxConstants.RETURN_CODE;
+		String return_code;
+		Map<String, String> respData = xmlToMap(xmlStr);
+		if (respData.containsKey(RETURN_CODE)) {
+			return_code = respData.get(RETURN_CODE);
+		}
+		else {
+			throw new Exception(String.format("No `return_code` in XML: %s", xmlStr));
+		}
+
+		if (return_code.equals("FAIL")) {
+			return respData;
+		}
+		else if (return_code.equals("SUCCESS")) {
+			if (isResponseSignatureValid(respData,signType)) {
+				return respData;
+			}
+			else {
+				throw new Exception(String.format("Invalid sign value in XML: %s", xmlStr));
+			}
+		}
+		else {
+			throw new Exception(String.format("return_code value %s is invalid in XML: %s", return_code, xmlStr));
+		}
+	}
+
+
+	/**
+	 * XML格式字符串转换为Map
+	 * @param strXML XML字符串
+	 * @return XML数据转换后的Map
+	 * @throws Exception
+	 */
+	public static Map<String, String> xmlToMap(String strXML) throws Exception {
+		try {
+			Map<String, String> data = new HashMap<String, String>();
+			DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
+
+			String FEATURE = "http://apache.org/xml/features/disallow-doctype-decl";
+			documentBuilderFactory.setFeature(FEATURE, true);
+
+			FEATURE = "http://xml.org/sax/features/external-general-entities";
+			documentBuilderFactory.setFeature(FEATURE, false);
+
+			FEATURE = "http://xml.org/sax/features/external-parameter-entities";
+			documentBuilderFactory.setFeature(FEATURE, false);
+
+			FEATURE = "http://apache.org/xml/features/nonvalidating/load-external-dtd";
+			documentBuilderFactory.setFeature(FEATURE, false);
+
+			documentBuilderFactory.setXIncludeAware(false);
+			documentBuilderFactory.setExpandEntityReferences(false);
+			DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
+			InputStream stream = new ByteArrayInputStream(strXML.getBytes("UTF-8"));
+			org.w3c.dom.Document doc = documentBuilder.parse(stream);
+			doc.getDocumentElement().normalize();
+			NodeList nodeList = doc.getDocumentElement().getChildNodes();
+			for (int idx = 0; idx < nodeList.getLength(); ++idx) {
+				Node node = nodeList.item(idx);
+				if (node.getNodeType() == Node.ELEMENT_NODE) {
+					org.w3c.dom.Element element = (org.w3c.dom.Element) node;
+					data.put(element.getNodeName(), element.getTextContent());
+				}
+			}
+			try {
+				stream.close();
+			} catch (Exception ex) {
+				// do nothing
+			}
+			return data;
+		} catch (Exception ex) {
+			throw ex;
+		}
+	}
+
+	/**
+	 * 判断xml数据的sign是否有效,必须包含sign字段,否则返回false。
+	 * @param reqData 向wxpay post的请求数据
+	 * @return 签名是否有效
+	 * @throws Exception
+	 */
+	private static boolean isResponseSignatureValid(final Map<String, String> reqData,String signType) throws Exception {
+		// 返回数据的签名方式和请求中给定的签名方式是一致的
+		return isSignatureValid(reqData,WxConfig.apikey,signType);
+	}
+
+	/**
+	 * 判断签名是否正确,必须包含sign字段,否则返回false。
+	 * @param data Map类型数据
+	 * @param key API密钥
+	 * @param signType 签名方式
+	 * @return 签名是否正确
+	 * @throws Exception
+	 */
+	public static boolean isSignatureValid(Map<String, String> data, String key, String signType) throws Exception {
+		if (!data.containsKey("sign")) {
+			return false;
+		}
+		String sign = data.get("sign");
+		return getSignature(data, key, signType).equals(sign);
+	}
+
+//	/**
+//	 * 生成支付二维码
+//	 * @param response 响应
+//	 * @param contents url链接
+//	 * @throws Exception
+//	 */
+//	public static void writerPayImage(HttpServletResponse response, String contents) throws Exception{
+//		ServletOutputStream out = response.getOutputStream();
+//		try {
+//			Map<EncodeHintType,Object> hints = new HashMap<EncodeHintType,Object>();
+//			hints.put(EncodeHintType.CHARACTER_SET,"UTF-8");
+//			hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.L);
+//			hints.put(EncodeHintType.MARGIN, 0);
+//			BitMatrix bitMatrix = new MultiFormatWriter().encode(contents, BarcodeFormat.QR_CODE,300,300,hints);
+//			MatrixToImageWriter.writeToStream(bitMatrix,"jpg",out);
+//		}catch (Exception e){
+//			throw new Exception("生成二维码失败!");
+//		}finally {
+//			if(out != null){
+//				out.flush();
+//				out.close();
+//			}
+//		}
+//	}
+
+	/**
+	 * 生成商户订单号
+	 * @return String
+	 */
+	public static String mchOrderNo(){
+		SimpleDateFormat sdf = new SimpleDateFormat("yyMMddHHmmss");
+		String date = sdf.format(new Date());
+
+		Random random = new Random();
+		String fourRandom = String.valueOf(random.nextInt(10000));
+		int randLength = fourRandom.length();
+		//不足4位继续补充
+		if(randLength<4){
+			for(int remain = 1; remain <= 4 - randLength; remain ++ ){
+				fourRandom += random.nextInt(10)  ;
+			}
+		}
+		return date+fourRandom;
+	}
+
+	/**
+	 * 生成默认用户名
+	 * @return String
+	 */
+	public static String createDefaultUserName(){
+		SimpleDateFormat sdf = new SimpleDateFormat("ddHHmmss");
+		String date = sdf.format(new Date());
+		return "微信用户" + date;
+	}
+
+	/**
+	 * 返回信息给微信
+	 * @param response
+	 * @param content 内容
+	 * @throws Exception
+	 */
+	public static void responsePrint(HttpServletResponse response, String content) throws Exception{
+		response.setCharacterEncoding("UTF-8");
+		response.setContentType("text/xml");
+		response.getWriter().print(content);
+		response.getWriter().flush();
+		response.getWriter().close();
+	}
+
+
+}

+ 47 - 0
src/main/java/com/template/common/utils/imageUtils.java

@@ -0,0 +1,47 @@
+package com.template.common.utils;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.util.Base64;
+
+/**
+ * @Author: binguo
+ * @Date: 2024/1/9 星期二 15:17
+ * @Description: com.template.common.utils
+ * @Version: 1.0
+ */
+public class imageUtils {
+
+    public static String getBase64Url(String imagePath){
+        ByteArrayOutputStream outPut = new ByteArrayOutputStream();
+        byte[] data = new byte[1024];
+        try {
+            // 创建URL
+            URL url = new URL(imagePath);
+            // 创建链接
+            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
+            conn.setRequestMethod("GET");
+            conn.setConnectTimeout(10 * 1000);
+
+            if(conn.getResponseCode() != 200) {
+                return "fail";//连接失败/链接失效/图片不存在
+            }
+            InputStream inStream = conn.getInputStream();
+            int len = -1;
+            while ((len = inStream.read(data)) != -1) {
+                outPut.write(data, 0, len);
+            }
+            inStream.close();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        // 对字节数组Base64编码
+        byte[] encode = Base64.getEncoder().encode(outPut.toByteArray());
+        String res = new String(encode);
+        return res;
+    }
+    //https://www.jb51.net/program/288342ppk.htm 图片压缩大小
+}

+ 27 - 0
src/main/java/com/template/common/utils/paramUtils.java

@@ -0,0 +1,27 @@
+package com.template.common.utils;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.validation.BindingResult;
+import org.springframework.validation.ObjectError;
+
+import java.util.List;
+
+/**
+ * @Author: binguo
+ * @Date: 2023/7/5 星期三 16:11
+ * @Description: com.template.utils
+ * @Version: 1.0
+ */
+@Slf4j
+public class paramUtils {
+    public static String getParamError(BindingResult bindingResult){
+        //有校验没通过
+        List<ObjectError> errorList = bindingResult.getAllErrors();
+        StringBuilder st = new StringBuilder();
+        for (ObjectError error : errorList) {
+            st.append(error.getDefaultMessage()+"! ");//输出具体的错误信息
+        }
+
+        return st.toString();
+    }
+}

+ 25 - 0
src/main/java/com/template/common/utils/smsUtil.java

@@ -0,0 +1,25 @@
+package com.template.common.utils;
+
+/**
+ * @Author: binguo
+ * @Date: 2023/4/20 星期四 8:26
+ * @Description: common
+ * @Version: 1.0
+ */
+public class smsUtil {
+//    @Autowired
+//    private static smsConfig smsConfig;
+//
+//    /**
+//     * 发送单条短信验证码
+//     * @param smmCode 短信验证码
+//     * @param phoneNumber 手机号
+//     * @return
+//     */
+//    public static void sendSingleMessage(String smmCode, String phoneNumber) throws HTTPException, IOException {
+//        String[] params = {smmCode,Integer.toString(smsConfig.getSmsMin())};
+//        SmsSingleSender ssender = new SmsSingleSender(smsConfig.getSdkAppid(), smsConfig.getAppKey());
+//        SmsSingleSenderResult result = ssender.sendWithParam("86", phoneNumber, smsConfig.getTemplateId(), params, smsConfig.getSmsSign(), "", "");
+//        System.out.println(result);
+//    };
+}

+ 52 - 0
src/main/java/com/template/config/MyBatisPlusConfig.java

@@ -0,0 +1,52 @@
+package com.template.config;
+
+import com.baomidou.mybatisplus.core.injector.ISqlInjector;
+import com.baomidou.mybatisplus.extension.injector.LogicSqlInjector;
+import com.baomidou.mybatisplus.extension.plugins.OptimisticLockerInterceptor;
+import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
+import com.baomidou.mybatisplus.extension.plugins.PerformanceInterceptor;
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Profile;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
+
+// 扫描我们的 mapper 文件夹
+@MapperScan("com.template.mapper")
+@EnableTransactionManagement
+@Configuration // 配置类
+public class MyBatisPlusConfig {
+
+    // 注册乐观锁插件
+    @Bean
+    public OptimisticLockerInterceptor optimisticLockerInterceptor() {
+        return new OptimisticLockerInterceptor();
+    }
+
+    // 分页插件
+    @Bean
+    public PaginationInterceptor paginationInterceptor() {
+        return  new PaginationInterceptor();
+    }
+
+    // 逻辑删除组件!
+    @Bean
+    public ISqlInjector sqlInjector() {
+        return new LogicSqlInjector();
+    }
+
+
+    /**
+     * SQL执行效率插件
+     * 在控制台显示sql语句
+     */
+    @Bean
+    @Profile({"dev","test"})// 设置 dev test 环境开启,保证我们的效率
+    public PerformanceInterceptor performanceInterceptor() {
+        PerformanceInterceptor performanceInterceptor = new PerformanceInterceptor();
+        performanceInterceptor.setMaxTime(3000); //ms 设置sql执行的最大时间,如果超过了则不执行
+        performanceInterceptor.setFormat(true);
+        return performanceInterceptor;
+    }
+
+}

+ 36 - 0
src/main/java/com/template/config/smsConfig.java

@@ -0,0 +1,36 @@
+package com.template.config;
+
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+/**
+ * @Author: binguo
+ * @Date: 2023/4/20 星期四 8:29
+ * @Description: com.video.config
+ * @Version: 1.0
+ */
+
+@Component
+@ConfigurationProperties(prefix = "tencentcloud")
+@Data
+public class smsConfig {
+
+    //腾讯云上的签名  AKIDCPVZdcWIxgHpy5FYxVyPiqkZGrhdXUBg
+    private String secretID;
+
+    //腾讯云上的密钥   NkyCN3cz97qKaeXLvHOGxOcdS8f184pL
+    private String secretKey;
+
+    //短信应用id  1400885930
+    private String sdkAppid;
+
+    //短信签名内容  	江西省创海科技有限公司
+    private String signName;
+
+    //模板Id   2060673
+    private String templateId;
+
+    //验证码有效时长
+    private String smsMin;
+}

+ 79 - 0
src/main/java/com/template/controller/CompaniesController.java

@@ -0,0 +1,79 @@
+package com.template.controller;
+
+
+import cn.hutool.core.bean.BeanUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.template.common.result.CommonResult;
+import com.template.model.Companies;
+import com.template.model.Devices;
+import com.template.model.Postions;
+import com.template.services.CompaniesService;
+import com.template.services.DevicesService;
+import com.template.services.PostionsService;
+import com.template.services.UsersService;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * <p>
+ *  前端控制器
+ * </p>
+ *
+ * @author ceshi
+ * @since 2024-06-18
+ */
+@RestController
+@RequestMapping("/api/companies")
+public class CompaniesController {
+
+    @Autowired
+    private CompaniesService companiesService;
+
+    @Autowired
+    private DevicesService devicesService;
+
+    @Autowired
+    private PostionsService postionsService;
+
+    @Autowired
+    private UsersService usersService;
+
+    @RequestMapping("/getAll")
+    public CommonResult getAll() {
+        List<Companies> companiesList=companiesService.list(new QueryWrapper<>());
+        return CommonResult.ok(companiesList);
+    }
+
+    @RequestMapping("/getInfoById")
+    public CommonResult getInfoById(@Param("id") String id) {
+        Companies companies=companiesService.getOne(new QueryWrapper<Companies>().eq("id",id));
+        if (companies==null){
+            return CommonResult.ok("数据为空");
+        }
+        Map<String, Object> companiesMap = BeanUtil.beanToMap(companies);
+        List<Devices> devicesList=devicesService.list(new QueryWrapper<Devices>().eq("company_id",id));
+        Postions postions=postionsService.getOne(new QueryWrapper<Postions>().eq("id",companies.getPostionId()));
+        companiesMap.put("devices",devicesList);
+        companiesMap.put("postions",postions);
+        companiesMap.put("users",usersService.getById(companies.getUserId()));
+        companiesMap.put("maintainUsers",usersService.getById(companies.getMaintainUserId()));
+        return CommonResult.ok(companiesMap);
+    }
+
+    @RequestMapping("/getCount")
+    public CommonResult getCount(@Param("postionId") String postionId) {
+        QueryWrapper<Companies> qw = new QueryWrapper<>();
+        if(postionId!=null&&postionId!=""){
+            qw.eq("postion_id",postionId);
+        }
+        int count=companiesService.count(qw);
+        return CommonResult.ok(count);
+    }
+}
+

+ 47 - 0
src/main/java/com/template/controller/CompaniesPDViewController.java

@@ -0,0 +1,47 @@
+package com.template.controller;
+
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.template.common.result.CommonResult;
+import com.template.model.CompaniesPDView;
+import com.template.services.CompaniesPDViewService;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+ * <p>
+ * VIEW 前端控制器
+ * </p>
+ *
+ * @author ceshi
+ * @since 2024-06-19
+ */
+@RestController
+@RequestMapping("/api/companies-pdview")
+public class CompaniesPDViewController {
+
+
+    @Autowired
+    private CompaniesPDViewService companiesPDViewService;
+
+    @RequestMapping("/getComPage")
+    public CommonResult getComPage(@Param("pageNum") Integer pageNum,@Param("pageSize") Integer pageSize,@Param("town") String town,@Param("companies") String companies) {
+        QueryWrapper<CompaniesPDView> queryWrapper = new QueryWrapper<>();
+        if (town!=null&&town!=""){
+            queryWrapper.like("pname",town);
+        }
+        if (companies!=null&&companies!=""){
+            queryWrapper.like("name",companies);
+        }
+        IPage<CompaniesPDView> page = companiesPDViewService.page(new Page<CompaniesPDView>(pageNum, pageSize), queryWrapper);
+        return CommonResult.ok(page);
+    }
+}
+

+ 21 - 0
src/main/java/com/template/controller/ConfigsController.java

@@ -0,0 +1,21 @@
+package com.template.controller;
+
+
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * <p>
+ *  前端控制器
+ * </p>
+ *
+ * @author ceshi
+ * @since 2024-06-18
+ */
+@RestController
+@RequestMapping("/configs")
+public class ConfigsController {
+
+}
+

+ 42 - 0
src/main/java/com/template/controller/DevicesAlarmController.java

@@ -0,0 +1,42 @@
+package com.template.controller;
+
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.template.common.result.CommonResult;
+import com.template.model.DevicesAlarm;
+import com.template.services.DevicesAlarmService;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+ * <p>
+ *  前端控制器
+ * </p>
+ *
+ * @author ceshi
+ * @since 2024-06-20
+ */
+@RestController
+@RequestMapping("/api/devices-alarm")
+public class DevicesAlarmController {
+
+    @Autowired
+    private DevicesAlarmService devicesAlarmService;
+
+    @RequestMapping("/getInfoByCom")
+    public CommonResult getAll(@Param("companyId") String companyId) {
+        QueryWrapper<DevicesAlarm> qw = new QueryWrapper<>();
+        if (companyId!=null && companyId!=""){
+            qw.eq("company_id",companyId);
+        }
+        qw.last("order by update_at desc");
+        List<DevicesAlarm> companiesList=devicesAlarmService.list(qw);
+        return CommonResult.ok(companiesList);
+    }
+}
+

+ 40 - 0
src/main/java/com/template/controller/DevicesCViewController.java

@@ -0,0 +1,40 @@
+package com.template.controller;
+
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.template.common.result.CommonResult;
+import com.template.model.DevicesCView;
+import com.template.services.DevicesCViewService;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * <p>
+ * VIEW 前端控制器
+ * </p>
+ *
+ * @author ceshi
+ * @since 2024-06-19
+ */
+@RestController
+@RequestMapping("/api/devices-cview")
+public class DevicesCViewController {
+
+    @Autowired
+    private DevicesCViewService devicesCViewService;
+    @RequestMapping("/getInfoById")
+    public CommonResult getInfoById(@Param("companyId") String companyId,@Param("devicesId") String devicesId) {
+        QueryWrapper<DevicesCView> qw = new QueryWrapper<>();
+        if (companyId!=null&&companyId!=""){
+            qw.eq("company_id",companyId);
+        }
+        if (devicesId!=null&&devicesId!=""){
+            qw.eq("id",devicesId);
+        }
+        return CommonResult.ok(devicesCViewService.list(qw));
+    }
+}
+

+ 59 - 0
src/main/java/com/template/controller/DevicesController.java

@@ -0,0 +1,59 @@
+package com.template.controller;
+
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.template.common.result.CommonResult;
+import com.template.model.Devices;
+import com.template.services.DevicesService;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * <p>
+ *  前端控制器
+ * </p>
+ *
+ * @author ceshi
+ * @since 2024-06-18
+ */
+@RestController
+@RequestMapping("/api/devices")
+public class DevicesController {
+
+    @Autowired
+    private DevicesService devicesService;
+
+    @RequestMapping("/getCount")
+    public CommonResult getCount() {
+        int total=devicesService.count(new QueryWrapper<>());
+        QueryWrapper<Devices> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("online",1);
+        int online=devicesService.count(queryWrapper);
+        QueryWrapper<Devices> queryWrapper2 = new QueryWrapper<>();
+        queryWrapper2.eq("online",0);
+        int deline=devicesService.count(queryWrapper2);
+        Map<String,Integer> map=new HashMap<>();
+        map.put("total",total);
+        map.put("online",online);
+        map.put("deline",deline);
+        return CommonResult.ok(map);
+    }
+
+    @RequestMapping("/getInfoByCom")
+    public CommonResult getInfoByCom(@Param("companyId") String companyId) {
+        QueryWrapper<Devices> queryWrapper = new QueryWrapper<>();
+        if (companyId!=null&&companyId!=""){
+            queryWrapper.eq("company_id",companyId);
+        }
+        List<Devices> list = devicesService.list(queryWrapper);
+        return CommonResult.ok(list);
+    }
+}
+

+ 21 - 0
src/main/java/com/template/controller/PostionsController.java

@@ -0,0 +1,21 @@
+package com.template.controller;
+
+
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * <p>
+ *  前端控制器
+ * </p>
+ *
+ * @author ceshi
+ * @since 2024-06-18
+ */
+@RestController
+@RequestMapping("/postions")
+public class PostionsController {
+
+}
+

+ 38 - 0
src/main/java/com/template/controller/RecordDViewController.java

@@ -0,0 +1,38 @@
+package com.template.controller;
+
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.template.common.result.CommonResult;
+import com.template.model.RecordDView;
+import com.template.services.CompaniesService;
+import com.template.services.RecordDViewService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+ * <p>
+ * VIEW 前端控制器
+ * </p>
+ *
+ * @author ceshi
+ * @since 2024-06-19
+ */
+@RestController
+@RequestMapping("/api/record-dview")
+public class RecordDViewController {
+
+    @Autowired
+    private RecordDViewService recordDViewService;
+
+    @RequestMapping("/getRealTime")
+    public CommonResult getAll() {
+        List<RecordDView> companiesList=recordDViewService.list(new QueryWrapper<>());
+        return CommonResult.ok(companiesList);
+    }
+
+}
+

+ 115 - 0
src/main/java/com/template/controller/RecordsController.java

@@ -0,0 +1,115 @@
+package com.template.controller;
+
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.template.common.result.CommonResult;
+import com.template.common.utils.TimeExchange;
+import com.template.model.Records;
+import com.template.services.RecordsService;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.web.bind.annotation.RestController;
+
+import java.math.BigDecimal;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * <p>
+ *  前端控制器
+ * </p>
+ *
+ * @author ceshi
+ * @since 2024-06-18
+ */
+@RestController
+@RequestMapping("/api/records")
+public class RecordsController {
+
+    @Autowired
+    private RecordsService recordsService;
+
+    @RequestMapping("/getEnergyCollect")
+    public CommonResult getEnergyCollect() {
+        QueryWrapper<Records> qw = new QueryWrapper<>();
+        qw.between("update_at", TimeExchange.getMonth(),TimeExchange.getTime());
+        qw.in("type", new String[]{"Electric", "Water"});
+        List<Records> companiesList=recordsService.list(qw);
+        if (companiesList==null||companiesList.isEmpty()){
+            return CommonResult.ok("查询为空");
+        }
+        Double electric = 0.0;
+        Double water= 0.0;
+        for (Records record:companiesList) {
+            if("Electric".equals(record.getType())){
+                BigDecimal bd1 = new BigDecimal(Double.toString(record.getValue()));
+                BigDecimal bd2 = new BigDecimal(Double.toString(electric));
+                electric=bd1.add(bd2).doubleValue();
+            }
+            if("Water".equals(record.getType())){
+                BigDecimal bd1 = new BigDecimal(Double.toString(record.getValue()));
+                BigDecimal bd2 = new BigDecimal(Double.toString(water));
+                water=bd1.add(bd2).doubleValue();
+            }
+        }
+        Map<String,Double> resultMap=new HashMap<>();
+        resultMap.put("electric",electric);
+        resultMap.put("water",water);
+        return CommonResult.ok(resultMap);
+    }
+
+    @RequestMapping("/getTemperature")
+    public CommonResult getTemperature(@Param("deviceId") String deviceId) {
+        QueryWrapper<Records> qw = new QueryWrapper<>();
+        qw.eq("type","Temperature");
+        qw.eq("device_id",deviceId);
+        qw.last("order by id desc limit 100");
+        List<Records> companiesList=recordsService.list(qw);
+        return CommonResult.ok(companiesList);
+    }
+
+    @RequestMapping("/getHumidity")
+    public CommonResult getHumidity(@Param("deviceId") String deviceId) {
+        QueryWrapper<Records> qw = new QueryWrapper<>();
+        qw.eq("type","Humidity");
+        qw.eq("device_id",deviceId);
+        qw.last("order by id desc limit 100");
+        List<Records> companiesList=recordsService.list(qw);
+        return CommonResult.ok(companiesList);
+    }
+
+    @RequestMapping("/getCO2")
+    public CommonResult getCO2(@Param("deviceId") String deviceId) {
+        QueryWrapper<Records> qw = new QueryWrapper<>();
+        qw.eq("type","CO2");
+        qw.eq("device_id",deviceId);
+        qw.last("order by id desc limit 100");
+        List<Records> companiesList=recordsService.list(qw);
+        return CommonResult.ok(companiesList);
+    }
+
+    @RequestMapping("/getLight")
+    public CommonResult getLight(@Param("deviceId") String deviceId) {
+        QueryWrapper<Records> qw = new QueryWrapper<>();
+        qw.eq("type","Light");
+        qw.eq("device_id",deviceId);
+        qw.last("order by id desc limit 100");
+        List<Records> companiesList=recordsService.list(qw);
+        return CommonResult.ok(companiesList);
+    }
+    @RequestMapping("/getWater")
+    public CommonResult getWater(@Param("deviceId") String deviceId) {
+        List<Map<String,Object>> companiesList=recordsService.listWater(deviceId);
+        return CommonResult.ok(companiesList);
+    }
+
+    @RequestMapping("/getElectric")
+    public CommonResult getElectric(@Param("deviceId") String deviceId) {
+        List<Map<String,Object>> companiesList=recordsService.listElectric(deviceId);
+        return CommonResult.ok(companiesList);
+    }
+}
+

+ 38 - 0
src/main/java/com/template/controller/RepairsController.java

@@ -0,0 +1,38 @@
+package com.template.controller;
+
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.template.common.result.CommonResult;
+import com.template.mapper.RepairsMapper;
+import com.template.model.Repairs;
+import com.template.services.RepairsService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * <p>
+ *  前端控制器
+ * </p>
+ *
+ * @author ceshi
+ * @since 2024-06-18
+ */
+@RestController
+@RequestMapping("/api/repairs")
+public class RepairsController {
+
+    @Autowired
+    private RepairsService repairsService;
+
+    @RequestMapping("/getAll")
+    public CommonResult getAll() {
+        List<Map<String,Object>> companiesList=repairsService.listRepair();
+        return CommonResult.ok(companiesList);
+    }
+}
+

+ 21 - 0
src/main/java/com/template/controller/UsersController.java

@@ -0,0 +1,21 @@
+package com.template.controller;
+
+
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * <p>
+ *  前端控制器
+ * </p>
+ *
+ * @author ceshi
+ * @since 2024-06-18
+ */
+@RestController
+@RequestMapping("/users")
+public class UsersController {
+
+}
+

+ 21 - 0
src/main/java/com/template/controller/UsersOnDevicesController.java

@@ -0,0 +1,21 @@
+package com.template.controller;
+
+
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * <p>
+ *  前端控制器
+ * </p>
+ *
+ * @author ceshi
+ * @since 2024-06-18
+ */
+@RestController
+@RequestMapping("/users-on-devices")
+public class UsersOnDevicesController {
+
+}
+

+ 26 - 0
src/main/java/com/template/handle/NonStaticResourceHttpRequestHandler.java

@@ -0,0 +1,26 @@
+package com.template.handle;
+
+import org.springframework.core.io.FileSystemResource;
+import org.springframework.core.io.Resource;
+import org.springframework.stereotype.Component;
+import org.springframework.web.servlet.resource.ResourceHttpRequestHandler;
+
+import javax.servlet.http.HttpServletRequest;
+import java.nio.file.Path;
+
+/**
+ * @Author: binguo
+ * @Date: 2023/3/27 星期一 8:49
+ * @Description: com.video.handle
+ * @Version: 1.0
+ */
+@Component
+public class NonStaticResourceHttpRequestHandler extends ResourceHttpRequestHandler {
+    public final static String ATTR_FILE = "NON-STATIC-FILE";
+
+    @Override
+    protected Resource getResource(HttpServletRequest request) {
+        final Path filePath = (Path) request.getAttribute(ATTR_FILE);
+        return new FileSystemResource(filePath);
+    }
+}

+ 60 - 0
src/main/java/com/template/handler/MyMetaObjectHandler.java

@@ -0,0 +1,60 @@
+package com.template.handler;
+
+import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
+import com.template.common.utils.AesUtils;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.ibatis.reflection.MetaObject;
+import org.springframework.stereotype.Component;
+import org.springframework.web.context.request.RequestAttributes;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.Date;
+
+@Slf4j
+@Component // 一定不要忘记把处理器加到IOC容器中!
+public class MyMetaObjectHandler implements MetaObjectHandler {
+    //创建用户和更新用户填充0的时候则说明不是账号操作的
+
+    // 插入时的填充策略
+    @Override
+    public void insertFill(MetaObject metaObject) {
+        HttpServletRequest request = getHttpServletRequest();
+        if (request != null) {
+            String user_id = request.getHeader("user_head") == null ? "0" : AesUtils.decrypt(request.getHeader("user_head"));
+            log.info("start insert fill.....");
+            // setFieldValByName(String fieldName, Object fieldVal, MetaObject metaObject
+            this.setFieldValByName("createTime", new Date(), metaObject);
+            this.setFieldValByName("updateTime", new Date(), metaObject);
+            this.setFieldValByName("createUser", user_id, metaObject);
+            this.setFieldValByName("updateUser", user_id, metaObject);
+            this.setFieldValByName("deleted", 0, metaObject);
+        } else {
+            this.setFieldValByName("createTime", new Date(), metaObject);
+            this.setFieldValByName("updateTime", new Date(), metaObject);
+            this.setFieldValByName("createUser","0", metaObject);
+            this.setFieldValByName("updateUser","0", metaObject);
+            this.setFieldValByName("deleted", 0, metaObject);
+        }
+    }
+
+    // 更新时的填充策略
+    @Override
+    public void updateFill(MetaObject metaObject) {
+        HttpServletRequest request = getHttpServletRequest();
+        if (request != null) {
+            String user_id = request.getHeader("user_head") == null ? "0" : AesUtils.decrypt(request.getHeader("user_head"));
+            log.info("start update fill.....");
+            this.setFieldValByName("updateTime", new Date(), metaObject);
+            this.setFieldValByName("updateUser", user_id, metaObject);
+        }
+
+    }
+
+    private HttpServletRequest getHttpServletRequest() {
+        RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
+        ServletRequestAttributes attributes = (ServletRequestAttributes) requestAttributes;
+        return attributes == null ? null : attributes.getRequest();
+    }
+}

+ 16 - 0
src/main/java/com/template/mapper/CompaniesMapper.java

@@ -0,0 +1,16 @@
+package com.template.mapper;
+
+import com.template.model.Companies;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author ceshi
+ * @since 2024-06-18
+ */
+public interface CompaniesMapper extends BaseMapper<Companies> {
+
+}

+ 16 - 0
src/main/java/com/template/mapper/CompaniesPDViewMapper.java

@@ -0,0 +1,16 @@
+package com.template.mapper;
+
+import com.template.model.CompaniesPDView;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ * VIEW Mapper 接口
+ * </p>
+ *
+ * @author ceshi
+ * @since 2024-06-19
+ */
+public interface CompaniesPDViewMapper extends BaseMapper<CompaniesPDView> {
+
+}

+ 16 - 0
src/main/java/com/template/mapper/ConfigsMapper.java

@@ -0,0 +1,16 @@
+package com.template.mapper;
+
+import com.template.model.Configs;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author ceshi
+ * @since 2024-06-18
+ */
+public interface ConfigsMapper extends BaseMapper<Configs> {
+
+}

+ 16 - 0
src/main/java/com/template/mapper/DevicesAlarmMapper.java

@@ -0,0 +1,16 @@
+package com.template.mapper;
+
+import com.template.model.DevicesAlarm;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author ceshi
+ * @since 2024-06-20
+ */
+public interface DevicesAlarmMapper extends BaseMapper<DevicesAlarm> {
+
+}

+ 16 - 0
src/main/java/com/template/mapper/DevicesCViewMapper.java

@@ -0,0 +1,16 @@
+package com.template.mapper;
+
+import com.template.model.DevicesCView;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ * VIEW Mapper 接口
+ * </p>
+ *
+ * @author ceshi
+ * @since 2024-06-19
+ */
+public interface DevicesCViewMapper extends BaseMapper<DevicesCView> {
+
+}

+ 16 - 0
src/main/java/com/template/mapper/DevicesMapper.java

@@ -0,0 +1,16 @@
+package com.template.mapper;
+
+import com.template.model.Devices;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author ceshi
+ * @since 2024-06-18
+ */
+public interface DevicesMapper extends BaseMapper<Devices> {
+
+}

+ 16 - 0
src/main/java/com/template/mapper/PostionsMapper.java

@@ -0,0 +1,16 @@
+package com.template.mapper;
+
+import com.template.model.Postions;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author ceshi
+ * @since 2024-06-18
+ */
+public interface PostionsMapper extends BaseMapper<Postions> {
+
+}

+ 16 - 0
src/main/java/com/template/mapper/RecordDViewMapper.java

@@ -0,0 +1,16 @@
+package com.template.mapper;
+
+import com.template.model.RecordDView;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ * VIEW Mapper 接口
+ * </p>
+ *
+ * @author ceshi
+ * @since 2024-06-19
+ */
+public interface RecordDViewMapper extends BaseMapper<RecordDView> {
+
+}

+ 31 - 0
src/main/java/com/template/mapper/RecordsMapper.java

@@ -0,0 +1,31 @@
+package com.template.mapper;
+
+import com.template.model.Records;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author ceshi
+ * @since 2024-06-18
+ */
+@Mapper
+@Component
+public interface RecordsMapper extends BaseMapper<Records> {
+
+    @Select("select 'Electric' type, date_format(update_at, '%Y-%m') mon,sum(value) total from records where `type` ='Electric' and device_id =#{device_id}" +
+            "  group by date_format(update_at, '%Y-%m')")
+    List<Map<String, Object>> listElectric(@Param("device_id") String device_id);
+
+    @Select("select 'Water' type, date_format(update_at, '%Y-%m') mon,sum(value) total from records where `type` ='Water' and device_id =#{device_id} group by date_format(update_at, '%Y-%m')")
+    List<Map<String, Object>> listWater(String device_id);
+}

+ 27 - 0
src/main/java/com/template/mapper/RepairsMapper.java

@@ -0,0 +1,27 @@
+package com.template.mapper;
+
+import com.template.model.Repairs;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Select;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author ceshi
+ * @since 2024-06-18
+ */
+@Mapper
+@Component
+public interface RepairsMapper extends BaseMapper<Repairs> {
+
+    @Select("select r.*,d.name dname,u.name uname from repairs r ,devices d ,users u where \n" +
+            "r.device_id =d.id and u.id=r.user_id and r.deleted =0")
+    List<Map<String, Object>> listRepair();
+}

+ 16 - 0
src/main/java/com/template/mapper/UsersMapper.java

@@ -0,0 +1,16 @@
+package com.template.mapper;
+
+import com.template.model.Users;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author ceshi
+ * @since 2024-06-18
+ */
+public interface UsersMapper extends BaseMapper<Users> {
+
+}

+ 16 - 0
src/main/java/com/template/mapper/UsersOnDevicesMapper.java

@@ -0,0 +1,16 @@
+package com.template.mapper;
+
+import com.template.model.UsersOnDevices;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author ceshi
+ * @since 2024-06-18
+ */
+public interface UsersOnDevicesMapper extends BaseMapper<UsersOnDevices> {
+
+}

+ 50 - 0
src/main/java/com/template/model/Companies.java

@@ -0,0 +1,50 @@
+package com.template.model;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.Version;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.TableLogic;
+import com.baomidou.mybatisplus.annotation.TableField;
+import java.io.Serializable;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author ceshi
+ * @since 2024-06-18
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value="Companies对象", description="")
+public class Companies implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    private String name;
+
+    private String address;
+
+    private Integer userId;
+
+    private Integer maintainUserId;
+
+    private Integer postionId;
+
+    @TableField(fill = FieldFill.INSERT)
+    @TableLogic
+    private Boolean deleted;
+
+
+}

+ 57 - 0
src/main/java/com/template/model/CompaniesPDView.java

@@ -0,0 +1,57 @@
+package com.template.model;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.Version;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.TableLogic;
+import com.baomidou.mybatisplus.annotation.TableField;
+import java.io.Serializable;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+/**
+ * <p>
+ * VIEW
+ * </p>
+ *
+ * @author ceshi
+ * @since 2024-06-19
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value="CompaniesPDView对象", description="VIEW")
+public class CompaniesPDView implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    private Integer id;
+
+    private String name;
+
+    private String address;
+
+    private Integer userId;
+
+    private Integer postionId;
+
+    @TableField(fill = FieldFill.INSERT)
+    @TableLogic
+    private Boolean deleted;
+
+    private String pname;
+
+    private Integer companyId;
+
+    private Long total;
+
+    private Long online;
+
+    private Long deline;
+
+
+}

+ 37 - 0
src/main/java/com/template/model/Configs.java

@@ -0,0 +1,37 @@
+package com.template.model;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.Version;
+import com.baomidou.mybatisplus.annotation.TableId;
+import java.io.Serializable;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author ceshi
+ * @since 2024-06-18
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value="Configs对象", description="")
+public class Configs implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    private String name;
+
+    private String value;
+
+
+}

+ 74 - 0
src/main/java/com/template/model/Devices.java

@@ -0,0 +1,74 @@
+package com.template.model;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import java.util.Date;
+import com.baomidou.mybatisplus.annotation.Version;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.TableLogic;
+import com.baomidou.mybatisplus.annotation.TableField;
+import java.io.Serializable;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author ceshi
+ * @since 2024-06-18
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value="Devices对象", description="")
+public class Devices implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    private String local;
+
+    private String name;
+
+    private Integer ownerId;
+
+    private String picture;
+
+    private Double temperature;
+
+    private Double humidity;
+
+    private Double co2;
+
+    private Double light;
+
+    private Double electric;
+
+    private Double water;
+
+    private Boolean online;
+
+    private Integer postionId;
+
+    private Integer companyId;
+
+    private Date updateAt;
+
+    private Date createAt;
+
+    @TableField(fill = FieldFill.INSERT)
+    @TableLogic
+    private Boolean deleted;
+
+    @TableField("deviceSerial")
+    private String deviceSerial;
+
+
+}

+ 65 - 0
src/main/java/com/template/model/DevicesAlarm.java

@@ -0,0 +1,65 @@
+package com.template.model;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import java.util.Date;
+import com.baomidou.mybatisplus.annotation.Version;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.TableLogic;
+import com.baomidou.mybatisplus.annotation.TableField;
+import java.io.Serializable;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author ceshi
+ * @since 2024-06-20
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value="DevicesAlarm对象", description="")
+public class DevicesAlarm implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    private Integer deviceId;
+
+    private String local;
+
+    private String name;
+
+    private Double temperature;
+
+    private Double humidity;
+
+    private Double co2;
+
+    private Double light;
+
+    private Integer companyId;
+
+    private String companyName;
+
+    private String alarmType;
+
+    private Date updateAt;
+
+    private Date createAt;
+
+    @TableField(fill = FieldFill.INSERT)
+    @TableLogic
+    private Boolean deleted;
+
+
+}

+ 0 - 0
src/main/java/com/template/model/DevicesCView.java


Certains fichiers n'ont pas été affichés car il y a eu trop de fichiers modifiés dans ce diff