shilin 6 месяцев назад
Родитель
Сommit
301a79cd88

+ 58 - 26
pom.xml

@@ -13,30 +13,48 @@
 
     <properties>
 
-        <springboot.version>2.7.18</springboot.version>
+        <springboot.version>3.2.2</springboot.version>
         <powerjob.worker.starter.version>4.3.9</powerjob.worker.starter.version>
         <fastjson.version>1.2.83</fastjson.version>
-        <lombok.version>1.18.12</lombok.version>
+        <lombok.version>1.18.32</lombok.version>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
         <java.version>1.8</java.version>
         <maven.compiler.source>1.8</maven.compiler.source>
         <maven.compiler.target>1.8</maven.compiler.target>
         <maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
-        <mybatis.spring.boot.version>2.3.2</mybatis.spring.boot.version>
-        <mybatis-plus.boot.starter.version>3.2.0</mybatis-plus.boot.starter.version>
-        <mybatis-plus.generator.version>3.3.2</mybatis-plus.generator.version>
-        <druid.version>1.2.5</druid.version>
+
+        <druid.version>1.2.21</druid.version>
         <mariadb.version>3.4.0</mariadb.version>
         <taosdata.version>3.2.11</taosdata.version>
         <hutool.version>5.8.27</hutool.version>
-        <dynamic-datasource.version>3.5.0</dynamic-datasource.version>
+
         <netty.version>4.1.110.Final</netty.version>
         <poi.version>3.17</poi.version>
         <freemarker.version>2.3.28</freemarker.version>
+
+
+
+
+        <dynamic-datasource.version>4.3.0</dynamic-datasource.version>
+        <mybatis-plus.version>3.5.5</mybatis-plus.version>
+        <mybatis-plus-generator.version>3.5.5</mybatis-plus-generator.version>
+
     </properties>
 
     <dependencies>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-jdbc</artifactId>
+            <version>${springboot.version}</version>
+        </dependency>
+
+        <!--mybatis-plus 代码生成器的模板引擎-->
+        <dependency>
+            <groupId>org.apache.velocity</groupId>
+            <artifactId>velocity-engine-core</artifactId>
+            <version>2.3</version>
+        </dependency>
 
         <dependency>
             <groupId>org.freemarker</groupId>
@@ -75,7 +93,22 @@
             <artifactId>spring-boot-starter-web</artifactId>
             <version>${springboot.version}</version>
         </dependency>
-
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter</artifactId>
+            <version>${springboot.version}</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.springframework.boot</groupId>
+                    <artifactId>spring-boot-starter-logging</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-log4j2</artifactId>
+            <version>${springboot.version}</version>
+        </dependency>
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-autoconfigure</artifactId>
@@ -116,12 +149,7 @@
             <version>2.3.1</version>
         </dependency>
         -->
-        <!-- druid -->
-        <dependency>
-            <groupId>com.alibaba</groupId>
-            <artifactId>druid</artifactId>
-            <version>${druid.version}</version>
-        </dependency>
+
         <dependency>
             <groupId>org.mariadb.jdbc</groupId>
             <artifactId>mariadb-java-client</artifactId>
@@ -140,11 +168,7 @@
             <version>${hutool.version}</version>
         </dependency>
 
-        <dependency>
-            <groupId>com.baomidou</groupId>
-            <artifactId>dynamic-datasource-spring-boot-starter</artifactId>
-            <version>${dynamic-datasource.version}</version>
-        </dependency>
+
 
         <dependency>
             <groupId>org.springframework.boot</groupId>
@@ -152,22 +176,30 @@
             <version>${springboot.version}</version>
         </dependency>
 
+
+        <dependency>
+            <groupId>com.baomidou</groupId>
+            <artifactId>dynamic-datasource-spring-boot3-starter</artifactId>
+            <version>${dynamic-datasource.version}</version>
+        </dependency>
         <dependency>
-            <groupId>org.mybatis.spring.boot</groupId>
-            <artifactId>mybatis-spring-boot-starter</artifactId>
-            <version>${mybatis.spring.boot.version}</version>
+            <groupId>com.alibaba</groupId>
+            <artifactId>druid-spring-boot-3-starter</artifactId>
+            <version>${druid.version}</version>
         </dependency>
         <dependency>
             <groupId>com.baomidou</groupId>
-            <artifactId>mybatis-plus-boot-starter</artifactId>
-            <version>${mybatis-plus.boot.starter.version}</version>
+            <artifactId>mybatis-plus-spring-boot3-starter</artifactId>
+            <version>${mybatis-plus.version}</version>
         </dependency>
         <dependency>
             <groupId>com.baomidou</groupId>
-            <artifactId>mybatis-plus-generator</artifactId>
-            <version>${mybatis-plus.generator.version}</version>
+            <artifactId>mybatis-plus-generator</artifactId> <!-- 代码生成器,使用它解析表结构 -->
+            <version>${mybatis-plus-generator.version}</version>
         </dependency>
 
+
+
         <dependency>
             <groupId>io.netty</groupId>
             <artifactId>netty-all</artifactId>

+ 3 - 2
src/main/java/com/gyee/generation/GenerationMain.java

@@ -11,8 +11,9 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
  * @param: 
  * @return: 
  **/
-@SpringBootApplication
-@MapperScan("com.gyee.generation.mapper")
+
+
+@SpringBootApplication(scanBasePackages = {"com.gyee.generation"})
 public class GenerationMain {
 
 

+ 58 - 120
src/main/java/com/gyee/generation/config/GeneratorCodeConfig.java

@@ -2,12 +2,18 @@ package com.gyee.generation.config;
 
 
 import com.baomidou.mybatisplus.core.exceptions.MybatisPlusException;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.baomidou.mybatisplus.generator.AutoGenerator;
+import com.baomidou.mybatisplus.generator.FastAutoGenerator;
 import com.baomidou.mybatisplus.generator.config.*;
+import com.baomidou.mybatisplus.generator.config.rules.DateType;
 import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
 import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
 
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
 import java.util.Scanner;
 
 /**
@@ -33,129 +39,61 @@ public class GeneratorCodeConfig {
     }
 
     public static void main(String[] args) {
-        // 代码生成器
-        AutoGenerator mpg = new AutoGenerator();
+            FastAutoGenerator.create("jdbc:mysql://127.0.0.1:3306/eladmin?characterEncoding=UTF-8&useUnicode=true&useSSL=false", "root", "abc123")
+                    // 全局配置
+                    .globalConfig(builder -> {
+                        builder.author("wanggc") // 设置作者
+                                .commentDate("yyyy-MM-dd hh:mm:ss")   //注释日期
+                                .outputDir(System.getProperty("user.dir") + "/src/main/java") // 指定输出目录
+                                .disableOpenDir() //禁止打开输出目录,默认打开
+                        ;
+                    })
+                    // 包配置
+                    .packageConfig(builder -> {
+                        builder.parent("demo.generator") // 设置父包名
+                                .pathInfo(Collections.singletonMap(OutputFile.xml, System.getProperty("user.dir") + "/src/main/resources/mappers")); // 设置mapperXml生成路径
+                    })
+//                    //包配置
+//                    .packageConfig(builder -> {
+//                        builder.parent("com.example.demo")     //父包名
+//                                .entity("bean")                 //Entity 包名
+//                                .service("service")             //	Service 包名
+//                                .serviceImpl("service.impl")    //Service Impl 包名
+//                                .mapper("mapper")               //Mapper 包名
+//                                .xml("mapper.xml")              //	Mapper XML 包名
+//                                .controller("controller")       //Controller 包名
+//                                .other("config")                //自定义文件包名	输出自定义文件时所用到的包名
+//                                .pathInfo(Collections.singletonMap(OutputFile.xml, System.getProperty("user.dir") + "\\src\\main\\resources\\mapper"));//指定xml位置
+//                    })
+                    // 策略配置
+                    .strategyConfig(builder -> {
+                        builder.addInclude("sys_menu") // 设置需要生成的表名
+                                .addTablePrefix("sys_") // 设置过滤表前缀
+                                // Entity 策略配置
+                                .entityBuilder()
+                                .enableLombok() //开启 Lombok
+                                .enableFileOverride() // 覆盖已生成文件
+                                .naming(NamingStrategy.underline_to_camel)  //数据库表映射到实体的命名策略:下划线转驼峰命
+                                .columnNaming(NamingStrategy.underline_to_camel)    //数据库表字段映射到实体的命名策略:下划线转驼峰命
+                                // Mapper 策略配置
+                                .mapperBuilder().superClass(BaseMapper.class)
+                                .formatMapperFileName("%sMapper")
+                                .enableFileOverride() // 覆盖已生成文件
+                                // Service 策略配置
+                                .serviceBuilder()
+                                .enableFileOverride() // 覆盖已生成文件
+                                .formatServiceFileName("%sService") //格式化 service 接口文件名称,%s进行匹配表名,如 UserService
+                                .formatServiceImplFileName("%sServiceImpl") //格式化 service 实现类文件名称,%s进行匹配表名,如 UserServiceImpl
+                                // Controller 策略配置
+                                .controllerBuilder().enableRestStyle()
+                                .enableFileOverride() // 覆盖已生成文件
+                        ;
+                    })
+                    .execute();
 
-        // 全局配置
-        GlobalConfig gc = new GlobalConfig();
-        String projectPath = System.getProperty("user.dir");
-        gc.setOutputDir(projectPath+"/src/main/java");
-        gc.setAuthor("shilin");
-        gc.setOpen(false);
-        //实体属性 Swagger2 注解
-        gc.setSwagger2(false);
-        mpg.setGlobalConfig(gc);
 
-        // 数据源配置
-        DataSourceConfig dsc = new DataSourceConfig();
-        /*dsc.setUrl("jdbc:mysql://127.0.0.1:3306/test?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true");
-        dsc.setDriverName("com.mysql.jdbc.Driver");
-        dsc.setUsername("root");
-        dsc.setPassword("root");
-        mpg.setDataSource(dsc);*/
-//        dsc.setDriverName("oracle.jdbc.driver.OracleDriver");
-//        dsc.setUsername("gdprod");
-//        dsc.setPassword("gd123");
-//        dsc.setUrl("jdbc:oracle:thin:@10.83.68.165:1521:gdsj");
-
-//        dsc.setDriverName("org.postgresql.Driver");
-//        dsc.setUsername("postgres");
-//        dsc.setPassword("gd123");
-//        dsc.setUrl("jdbc:postgresql://10.81.3.151:5432/IMS_NEM_JN");
-//        dsc.setDriverName("org.postgresql.Driver");
-//        dsc.setUsername("postgres");
-//        dsc.setPassword("postgres");
-//        dsc.setUrl("jdbc:postgresql://192.168.11.248:5432/IMS_NEM_SD");
-//        dsc.setUrl("jdbc:postgresql://124.70.75.91:5432/jn_test");
-//        dsc.setUsername("postgres");
-//        dsc.setPassword("gd123");
-
-        dsc.setDriverName("com.mysql.jdbc.Driver");
-        dsc.setUsername("root");
-        dsc.setPassword("123456");
-        dsc.setUrl("jdbc:mysql://localhost:3306/test1");
-
-        mpg.setDataSource(dsc);
-
-
-
-        // 包配置
-        PackageConfig pc = new PackageConfig();
-//        pc.setModuleName(scanner("模块名"));
-        pc.setParent("com.gyee.generation");
-        pc.setEntity("model.auto");
-        pc.setMapper("mapper.auto");
-        pc.setService("service.auto");
-        pc.setServiceImpl("service.auto.impl");
-        mpg.setPackageInfo(pc);
-
-        // 自定义配置
-//        InjectionConfig cfg = new InjectionConfig() {
-//            @Override
-//            public void initMap() {
-//                // to do nothing
-//            }
-//        };
-
-        // 如果模板引擎是 freemarker
-//        String templatePath = "/templates/mapper.xml.ftl";
-        // 如果模板引擎是 velocity
-        // String templatePath = "/templates/mapper.xml.vm";
-
-        // 自定义输出配置
-//        List<FileOutConfig> focList = new ArrayList<>();
-        // 自定义配置会被优先输出
-//        focList.add(new FileOutConfig(templatePath) {
-//            @Override
-//            public String outputFile(TableInfo tableInfo) {
-//                // 自定义输出文件名 , 如果你 Entity 设置了前后缀、此处注意 xml 的名称会跟着发生变化!!
-//                return projectPath + "/src/main/resources/mapper/" + pc.getModuleName()
-//                        + "/" + tableInfo.getEntityName() + "Mapper" + StringPool.DOT_XML;
-//            }
-//        });
-        /*
-        cfg.setFileCreate(new IFileCreate() {
-            @Override
-            public boolean isCreate(ConfigBuilder configBuilder, FileType fileType, String filePath) {
-                // 判断自定义文件夹是否需要创建
-                checkDir("调用默认方法创建的目录");
-                return false;
-            }
-        });
-        */
-//        cfg.setFileOutConfigList(focList);
-//        mpg.setCfg(cfg);
-
-        // 配置模板
-        TemplateConfig templateConfig = new TemplateConfig();
-
-        // 配置自定义输出模板
-        //指定自定义模板路径,注意不要带上.ftl/.vm, 会根据使用的模板引擎自动识别
-        // templateConfig.setEntity("templates/entity2.java");
-        // templateConfig.setService();
-        // templateConfig.setController();
+    }
 
-        templateConfig.setXml(null);
-        mpg.setTemplate(templateConfig);
 
-        // 策略配置
-        StrategyConfig strategy = new StrategyConfig();
-        strategy.setNaming(NamingStrategy.underline_to_camel);
-        strategy.setColumnNaming(NamingStrategy.underline_to_camel);
-        strategy.setSuperEntityClass("com.baomidou.mybatisplus.extension.activerecord.Model");
-        strategy.setEntityLombokModel(true);
-        strategy.setRestControllerStyle(true);
 
-        strategy.setEntityLombokModel(true);
-        // 公共父类
-//        strategy.setSuperControllerClass("com.baomidou.ant.common.BaseController");
-        // 写于父类中的公共字段
-//        strategy.setSuperEntityColumns("id");
-        strategy.setInclude(scanner("表名,多个英文逗号分割").split(","));
-        strategy.setControllerMappingHyphenStyle(true);
-        strategy.setTablePrefix(pc.getModuleName() + "_");
-        mpg.setStrategy(strategy);
-        mpg.setTemplateEngine(new FreemarkerTemplateEngine());
-        mpg.execute();
-    }
 }

+ 31 - 0
src/main/java/com/gyee/generation/config/MybatisPlusConfig.java

@@ -0,0 +1,31 @@
+package com.gyee.generation.config;
+
+
+import com.baomidou.mybatisplus.annotation.DbType;
+import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
+import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
+import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
+
+@EnableTransactionManagement  //开启事务
+@Configuration  //配置类注解
+@MapperScan("com.gyee.generation.mapper")
+public class MybatisPlusConfig {
+
+    //配置拦截器
+    @Bean
+    public MybatisPlusInterceptor mybatisPlusInterceptor() {
+        MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
+        //创建乐观锁拦截器 OptimisticLockerInnerInterceptor
+        mybatisPlusInterceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
+        //插件分页拦截器,我的是mysql
+        // 分页插件放到最后面
+        mybatisPlusInterceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MARIADB));
+        return mybatisPlusInterceptor;
+    }
+
+}
+

+ 2 - 1
src/main/java/com/gyee/generation/init/CacheContext.java

@@ -8,13 +8,14 @@ import com.gyee.generation.model.auto.*;
 import com.gyee.generation.service.auto.*;
 
 import com.gyee.generation.util.redis.RedisService;
+import jakarta.annotation.Resource;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.boot.CommandLineRunner;
 import org.springframework.stereotype.Component;
 
-import javax.annotation.Resource;
+import jakarta.annotation.Resource;
 import java.util.*;
 import java.util.stream.Collectors;
 

+ 65 - 96
src/main/java/com/gyee/generation/mapper/auto/AlarmTsMapper.java

@@ -1,96 +1,65 @@
-package com.gyee.generation.mapper.auto;
-
-
-import com.baomidou.dynamic.datasource.annotation.DS;
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.gyee.generation.model.auto.AlarmTs;
-import com.gyee.generation.model.vo.AlarmSimpleVo;
-import com.gyee.generation.model.vo.AlarmTsVo;
-import com.gyee.generation.model.vo.AlarmVo;
-import org.apache.ibatis.annotations.Insert;
-import org.apache.ibatis.annotations.Param;
-import org.apache.ibatis.annotations.Select;
-import org.apache.ibatis.annotations.Update;
-
-import java.util.List;
-
-
-@DS("slave")
-public interface AlarmTsMapper extends BaseMapper<AlarmTs> {
-
-
-    @Update("CREATE STABLE if not exists ${superTableName} (ts TIMESTAMP,val INT,confirmed BOOL,endts TIMESTAMP,timeLong DOUBLE) " +
-            "TAGS (alarmid NCHAR(100),alarmtype NCHAR(50),characteristic NCHAR(50)," +
-            "components NCHAR(50),description NCHAR(500),deviceid NCHAR(50),devicename NCHAR(70)," +
-            "devicetype NCHAR(50),enabled BOOL,lineid NCHAR(50),linename NCHAR(70),modelId NCHAR(50),projectid NCHAR(50)," +
-            "projectname NCHAR(70),rank INT,resettable BOOL,stationid NCHAR(50),stationname NCHAR(70),subcomponents NCHAR(50)," +
-            "suffix NCHAR(50),tagid NCHAR(100),triggertype INT,uniformcode NCHAR(50));")
-    int createAlarmSuperTable(@Param("superTableName") String superTableName);
-
-
-
-    @Update("create table if not exists ${tbName} using ${superTableName} tags( #{alarmid}, #{alarmtype}," +
-            "#{characteristic}, #{components},  #{description}, #{deviceid}, #{devicename}," +
-            "#{devicetype}, #{enabled}, #{lineid}, #{linename}, #{modelId}, #{projectid}," +
-            "#{projectname}, #{rank}, #{resettable}, #{stationid}, #{stationname}, #{subcomponents}," +
-            "#{suffix},  #{tagid}, #{triggertype}, #{uniformcode}" +
-            ")")
-    int createTable(@Param("tbName") String tbName, @Param("alarmid") String alarmid, @Param("alarmtype") String alarmtype,
-                    @Param("characteristic") String characteristic, @Param("components") String components,
-                    @Param("description") String description,
-                    @Param("deviceid") String deviceid, @Param("devicename") String devicename,
-                    @Param("devicetype") String devicetype, @Param("enabled") Boolean enabled,
-                    @Param("lineid") String lineid, @Param("linename") String linename,
-                    @Param("modelId") String modelId, @Param("projectid") String projectid,
-                    @Param("projectname") String projectname, @Param("rank") Integer rank,
-                    @Param("resettable") Boolean resettable, @Param("stationid") String stationid,
-                    @Param("stationname") String stationname, @Param("subcomponents") String subcomponents,
-                    @Param("suffix") String suffix, @Param("tagid") String tagid,
-                    @Param("triggertype") Integer triggertype, @Param("uniformcode") String uniformcode, @Param("superTableName") String superTableName
-
-    );
-
-
-
-    @Update("create table  if not exists ${tbName} using ${superTableName} tags( #{alarmid}, #{alarmtype}," +
-            "#{characteristic}, #{components}, #{description}, #{deviceid}, #{devicename}," +
-            "#{devicetype}, #{enabled}, #{lineid}, #{linename}, #{modelId}, #{projectid}," +
-            "#{projectname}, #{rank}, #{resettable}, #{stationid}, #{stationname}, #{subcomponents}," +
-            "#{suffix},  #{tagid}, #{triggertype}, #{uniformcode}" +
-            ")")
-    int createTable(AlarmVo vo);
-
-    @Update("drop table if exists ${superTableName}")
-    void dropSuperTable(@Param("superTableName")String superTableName);
-
-    @Insert("insert into ${tbName} (ts, val,oval,confirmed) values(#{ts}, #{val}, #{oval}, #{confirmed})")
-    int insertOne(AlarmTs one);
-
-
-
-    @Insert("${sql}")
-    int insertList(@Param("sql") String sql);
-
-    @Select("select last_row(*),alarmid,alarmtype,characteristic,components,confirmed,description,deviceid,devicename,devicetype,enabled,lineid,linename," +
-            "modelId,projectid,projectname,rank,resettable,stationid,stationname,subcomponents,suffix,tagid,triggertype,uniformcode from #{stbaleName} group by tbname")
-    List<AlarmVo> findTags(@Param("stbaleName") String stbaleName);
-
-
-    @Select("select deviceid,description,count(*) as val,sum(timeLong) as timeLong from #{superTableName} where ts>=#{begin} and ts<=#{end}  stationid=#{stationid}  group by description,deviceid  ")
-    List<AlarmTsVo> selectByGroup(@Param("superTableName") String superTableName, @Param("stationid") String stationid, @Param("begin")long begin, @Param("end") long end);
-
-
-    @Select("select ts,val,confirmed,endts,timeLong,alarmid,alarmtype,characteristic,components,confirmed,description,deviceid,devicename,devicetype,enabled,lineid,linename," +
-            "modelId,projectid,projectname,rank,resettable,stationid,stationname,subcomponents,suffix,tagid,triggertype,uniformcode from #{tbName}   limit #{limit} offset #{offset} ")
-    List<AlarmVo> selectByTbName(@Param("tbName") String tbName,@Param("limit") long limit,@Param("offset") long offset);
-
-
-    @Select("select last_row(*),tbname from #{superTableName} where tbname in( #{tbnames} ) group by tbname")
-    List<AlarmSimpleVo> selectLastRowByTbname(@Param("superTableName") String superTableName, @Param("tbnames") String tbnames);
-
-    @Select("select last_row(*),alarmid,alarmtype,characteristic,components,confirmed,description,deviceid,devicename,devicetype,enabled,lineid,linename," +
-            "modelId,projectid,projectname,rank,resettable,stationid,stationname,subcomponents,suffix,tagid,triggertype,uniformcode,nemCode ,faultCause,resolvent from #{superTableName}" +
-            " where deviceid=#{deviceid} order by rank desc,ts desc limit 0,1")
-    List<AlarmVo> selectLastRowByDeviceid(@Param("superTableName") String superTableName, @Param("deviceid") String deviceid);
-
-}
+//package com.gyee.generation.mapper.auto;
+//
+//
+//import com.baomidou.dynamic.datasource.annotation.DS;
+//import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+//import com.gyee.generation.model.auto.PointDataTaos;
+//import com.gyee.generation.model.vo.AlarmSimpleVo;
+//import com.gyee.generation.model.vo.AlarmTsVo;
+//import com.gyee.generation.model.vo.AlarmVo;
+//import org.apache.ibatis.annotations.Insert;
+//import org.apache.ibatis.annotations.Param;
+//import org.apache.ibatis.annotations.Select;
+//import org.apache.ibatis.annotations.Update;
+//
+//import java.util.List;
+//
+//
+//@DS("slave")
+//public interface AlarmTsMapper extends BaseMapper<PointDataTaos> {
+//
+//
+//    @Update("CREATE STABLE if not exists ${superTableName} (ts TIMESTAMP,val DOUBLE,metric BIGINT) );")
+//    int createAlarmSuperTable(@Param("superTableName") String superTableName);
+//
+//
+//
+//    @Update("create table if not exists ${tbName} using ${superTableName} ")
+//    int createTable(@Param("tbName") String tbName, @Param("superTableName") String superTableName
+//
+//    );
+//
+//
+//    @Update("drop table if exists ${superTableName}")
+//    void dropSuperTable(@Param("superTableName")String superTableName);
+//
+//    @Insert("insert into ${tbName} (ts, val,metric,confirmed) values(#{ts}, #{val}, #{metric})")
+//    int insertOne(PointDataTaos one);
+//
+//
+//
+//    @Insert("${sql}")
+//    int insertList(@Param("sql") String sql);
+//
+//    @Select("SELECT LAST_ROW(*)  FROM from #{tbname} ")
+//    List<AlarmVo> getRealData(@Param("tbname") String tbname);
+//
+//
+//    @Select("select deviceid,description,count(*) as val,sum(timeLong) as timeLong from #{superTableName} where ts>=#{begin} and ts<=#{end}  stationid=#{stationid}  group by description,deviceid  ")
+//    List<AlarmTsVo> selectByGroup(@Param("superTableName") String superTableName, @Param("stationid") String stationid, @Param("begin")long begin, @Param("end") long end);
+//
+//
+//    @Select("select ts,val,confirmed,endts,timeLong,alarmid,alarmtype,characteristic,components,confirmed,description,deviceid,devicename,devicetype,enabled,lineid,linename," +
+//            "modelId,projectid,projectname,rank,resettable,stationid,stationname,subcomponents,suffix,tagid,triggertype,uniformcode from #{tbName}   limit #{limit} offset #{offset} ")
+//    List<AlarmVo> selectByTbName(@Param("tbName") String tbName,@Param("limit") long limit,@Param("offset") long offset);
+//
+//
+//    @Select("select last_row(*),tbname from #{superTableName} where tbname in( #{tbnames} ) group by tbname")
+//    List<AlarmSimpleVo> selectLastRowByTbname(@Param("superTableName") String superTableName, @Param("tbnames") String tbnames);
+//
+//    @Select("select last_row(*),alarmid,alarmtype,characteristic,components,confirmed,description,deviceid,devicename,devicetype,enabled,lineid,linename," +
+//            "modelId,projectid,projectname,rank,resettable,stationid,stationname,subcomponents,suffix,tagid,triggertype,uniformcode,nemCode ,faultCause,resolvent from #{superTableName}" +
+//            " where deviceid=#{deviceid} order by rank desc,ts desc limit 0,1")
+//    List<AlarmVo> selectLastRowByDeviceid(@Param("superTableName") String superTableName, @Param("deviceid") String deviceid);
+//
+//}

+ 3 - 5
src/main/java/com/gyee/generation/model/auto/AlarmTs.java

@@ -7,12 +7,10 @@ import java.sql.Timestamp;
 
 @Data
 @ToString
-public class AlarmTs {
+public class PointDataTaos {
 
     private Timestamp ts;
     private Integer val;
-    private Integer oval;
-    private Boolean confirmed;
-    private Timestamp endts;
-    private String tbName;
+    private Long metric;
+
 }

+ 1 - 1
src/main/java/com/gyee/generation/service/initalcache/CacheService.java

@@ -10,7 +10,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import javax.annotation.Resource;
+import jakarta.annotation.Resource;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;

+ 1 - 1
src/main/java/com/gyee/generation/service/initialpoint/InitialPointService.java

@@ -11,7 +11,7 @@ import com.gyee.generation.util.ExcelExport;
 
 import org.springframework.stereotype.Service;
 
-import javax.annotation.Resource;
+import jakarta.annotation.Resource;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;

+ 1 - 99
src/main/java/com/gyee/generation/util/ExcelExport.java

@@ -13,7 +13,7 @@ import org.apache.poi.ss.usermodel.HorizontalAlignment;
 import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.util.CellRangeAddress;
 
-import javax.servlet.http.HttpServletResponse;
+
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
@@ -31,104 +31,6 @@ import java.util.List;
  */
 public final class ExcelExport {
 
-    /**
-     * 将传入的数据导出excel表并下载
-     * @param response 返回的HttpServletResponse
-     * @param importlist 要导出的对象的集合
-     * @param attributeNames 含有每个对象属性在excel表中对应的标题字符串的数组(请按对象中属性排序调整字符串在数组中的位置)
-     * @param heardName 导出文件 标题名称
-     * @param cnt 合并单元格数 (一般标题字符串的数组长度-1)
-     */
-    public static void export(HttpServletResponse response, List<?> importlist, String[] attributeNames,
-                              String heardName, int cnt ) {
-        //获取数据集
-        List<?> datalist = importlist;
-
-        //声明一个工作薄
-        HSSFWorkbook workbook = new HSSFWorkbook();
-        //生成一个表格
-        HSSFSheet sheet = workbook.createSheet();
-        //设置表格默认列宽度为15个字节
-        sheet.setDefaultColumnWidth((short) 18);
-        //用于设置表格字体
-        HSSFCellStyle style = workbook.createCellStyle();
-
-        //获取字段名数组
-        String[] tableAttributeName = attributeNames;
-        //获取对象属性
-        Field[] fields = ClassUtil.getClassAttribute(importlist.get(0));
-        //获取对象get方法
-        List<Method> methodList = ClassUtil.getMethodGet(importlist.get(0));
-
-        //设置标题样式
-        HSSFCellStyle headerStyle = workbook.createCellStyle();
-        HSSFFont headerFont = workbook.createFont();
-        headerFont.setFontHeightInPoints((short) 14);
-        headerFont.setBold(true);
-        headerStyle.setAlignment(HorizontalAlignment.CENTER);
-        headerStyle.setFont(headerFont);
-        CellRangeAddress cra0 = new CellRangeAddress(0, 1, 0, cnt);// 合并单元格
-        sheet.addMergedRegion(cra0);
-        //创建标标题题
-        Row row = sheet.createRow(0);
-        Cell cell1 = row.createCell(0);
-        cell1.setCellValue(heardName);
-        cell1.setCellStyle(headerStyle);
-
-        // 设置字体样式
-        HSSFFont titleFont = workbook.createFont();
-        titleFont.setBold(true);
-        titleFont.setFontHeightInPoints((short) 10);
-
-        style.setFont(titleFont);
-        style.setAlignment(HorizontalAlignment.CENTER);
-        //循环字段名数组,创建标题行
-        row = sheet.createRow(2);
-        for (int j = 0; j< tableAttributeName.length; j++){
-            //创建列
-            Cell cell = row.createCell(j);
-            cell.setCellStyle(style);
-            //设置单元类型为String
-            cell.setCellType(CellType.STRING);
-            cell.setCellValue(transCellType(tableAttributeName[j]));
-        }
-        //创建普通行
-        for (int i = 0;i<datalist.size();i++){
-            //因为第一行已经用于创建标题行,故从第二行开始创建
-            row = sheet.createRow(i+3);
-            //如果是第一行就让其为标题行
-            Object targetObj = datalist.get(i);
-            for (int j = 0;j<fields.length;j++){
-                //创建列
-                Cell cell = row.createCell(j);
-                cell.setCellType(CellType.STRING);
-                //
-                try {
-                    Object value = methodList.get(j).invoke(targetObj, new Object[]{});
-                    cell.setCellValue(transCellType(value));
-                } catch (IllegalAccessException e) {
-                    e.printStackTrace();
-                } catch (InvocationTargetException e) {
-                    e.printStackTrace();
-                }
-            }
-        }
-        response.setContentType("application/octet-stream");
-        //默认Excel名称
-        response.setHeader("Content-Disposition", "attachment;fileName="+"test.xls");
-        try {
-            OutputStream outputStream = response.getOutputStream();
-            workbook.write(outputStream);
-            outputStream.flush();
-            outputStream.close();
-
-//            response.flushBuffer();
-//            workbook.write(response.getOutputStream());
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-
-    }
 
 
 

+ 1 - 1
src/main/java/com/gyee/generation/util/realtimesource/EdosUtil.java

@@ -37,7 +37,7 @@ public class EdosUtil implements IEdosUtil {
     @Override
     public PointData getRealData(ProBasicPowerstationPoint point) throws Exception {
 
-        if(ObjectUtil.isNotEmpty(point) && ObjectUtil.isNotEmpty(point.getNemCode()) && !initialcode.equals(point.getNemCode()))
+        if(ObjectUtil.isNotEmpty(point) && StrUtil.isNotEmpty(point.getNemCode()) && !initialcode.equals(point.getNemCode()))
         {
             try {
                 Optional<String> keys = Optional.ofNullable(point.getNemCode());

+ 1 - 1
src/main/java/com/gyee/generation/util/redis/RedisServiceImpl.java

@@ -9,7 +9,7 @@ import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.data.redis.serializer.RedisSerializer;
 import org.springframework.stereotype.Service;
 
-import javax.annotation.Resource;
+import jakarta.annotation.Resource;
 import java.lang.reflect.Field;
 import java.util.*;
 import java.util.concurrent.TimeUnit;

+ 13 - 20
src/main/resources/application-hwy.yml

@@ -10,26 +10,19 @@ spring:
     allow-bean-definition-overriding: true #当遇到同样名字的时候,是否允许覆盖注册
   #redis集群
   redis:
-    #host: 127.0.0.1
-    host: 123.60.223.250
-    port: 6379
-    timeout: 100000
-    #    集群环境打开下面注释,单机不需要打开
-    #    cluster:
-    #      #集群信息
-    #      nodes: 10.83.68.151:6379,10.83.68.152:6379,10.83.68.153:6379,10.83.68.154:6379,10.83.68.155:6379,10.83.68.156:6379,10.83.68.157:6379,10.83.68.158:6379,10.83.68.159:6379
-    #      #默认值是5 一般当此值设置过大时,容易报:Too many Cluster redirections
-    #      maxRedirects: 3
-    password:
-    application:
-      name: test
-    jedis:
-      pool:
-        max-active: 8
-        min-idle: 0
-        max-idle: 8
-        max-wait: -1
-    database: 2
+    data:
+      redis:
+        timeout: 100000
+        host: 127.0.0.1
+        port: 6379
+        password:
+        database: 2
+      jedis:
+        pool:
+          max-active: 8
+          min-idle: 0
+          max-idle: 8
+          max-wait: -1
   autoconfigure:
     exclude: org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration,org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration
   datasource:

+ 17 - 16
src/main/resources/application-jn.yml

@@ -8,28 +8,19 @@ server:
 spring:
   main:
     allow-bean-definition-overriding: true #当遇到同样名字的时候,是否允许覆盖注册
-  #redis集群
-  redis:
-    host: 127.0.0.1
-    #host: 123.60.223.250
-    port: 6379
-    timeout: 100000
-    #    集群环境打开下面注释,单机不需要打开
-    #    cluster:
-    #      #集群信息
-    #      nodes: 10.83.68.151:6379,10.83.68.152:6379,10.83.68.153:6379,10.83.68.154:6379,10.83.68.155:6379,10.83.68.156:6379,10.83.68.157:6379,10.83.68.158:6379,10.83.68.159:6379
-    #      #默认值是5 一般当此值设置过大时,容易报:Too many Cluster redirections
-    #      maxRedirects: 3
-    password:
-    application:
-      name: test
+  data:
+    redis:
+      timeout: 100000
+      host: 127.0.0.1
+      port: 6379
+      password:
+      database: 2
     jedis:
       pool:
         max-active: 8
         min-idle: 0
         max-idle: 8
         max-wait: -1
-    database: 2
   autoconfigure:
     exclude: org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration,org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration
   datasource:
@@ -82,6 +73,7 @@ spring:
           config:
             multi-statement-allow: true
 
+
 mybatis-plus:
   configuration:
     map-underscore-to-camel-case: true
@@ -144,14 +136,23 @@ frequency:
 notCalculatePower: SXJ_KGDL_YTY_FDC_STA
 powerjob:
   worker:
+    #打开测试模式,不强制验证服务器连接
     allow-lazy-connect-server: false
+    #应用程序名称,用于对应用程序进行分组。建议设置与项目名称相同的值。
     app-name: powerjob-worker-sample
+    #是否启用PowerJob Worker,默认为true
     enabled: true
+    #附加的工作流上下文的最大长度。将忽略比该值长的附加工作流上下文值。
     max-appended-wf-context-length: 4096
+    #结果的最大长度。超过该值的结果将被截断。
     max-result-length: 4096
+    #传输端口,默认为27777
     port: 27777
+    #服务器和工作程序之间的传输协议
     protocol: http
+    #PowerJob服务器节点的地址。Ip:端口或域。多个地址应使用逗号分隔。
     server-address: 120.46.128.147:7700,120.46.128.147:7701
+    #H2数据库的存储策略。磁盘或内存。默认值为磁盘。
     store-strategy: disk