Commit 4a17a880 authored by qinhu's avatar qinhu

Initial commit

parents
Pipeline #168 canceled with stages
<?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>
<packaging>pom</packaging>
<modules>
<module>power-common</module>
<module>power-bussiness</module>
</modules>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.6.RELEASE</version>
</parent>
<groupId>cn.wise.sc.energy</groupId>
<artifactId>power-plant</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>power-plant</name>
<properties>
<testcontainers.version>1.77</testcontainers.version>
<spring-cloud-contex.version>2.2.3.RELEASE</spring-cloud-contex.version>
<redisson.version>3.11.1</redisson.version>
<druid.version>1.1.20</druid.version>
<opentsdb-sdk-java.version>0.2.0</opentsdb-sdk-java.version>
<hutool-all.version>5.3.1</hutool-all.version>
<fastjson.version>1.2.72</fastjson.version>
<jjwt.version>0.11.1</jjwt.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-api</artifactId>
<version>${jjwt.version}</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-impl</artifactId>
<version>${jjwt.version}</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-jackson</artifactId>
<version>${jjwt.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-context</artifactId>
<version>${spring-cloud-contex.version}</version>
<scope>test</scope>
</dependency>
<!--redis-->
<dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson</artifactId>
<version>${redisson.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.playtika.testcontainers</groupId>
<artifactId>embedded-mysql</artifactId>
<version>${testcontainers.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>${druid.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.github.chocoboxxf</groupId>
<artifactId>opentsdb-sdk-java</artifactId>
<version>${opentsdb-sdk-java.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>${hutool-all.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>${fastjson.version}</version>
<scope>compile</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<skipTests>true</skipTests> <!--默认关掉单元测试 -->
</configuration>
</plugin>
</plugins>
</build>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>power-plant</artifactId>
<groupId>cn.wise.sc.energy</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>power-bussiness</artifactId>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<!--json模块-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-json</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>cn.wise.sc.energy</groupId>
<artifactId>common-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
<dependency>
<groupId>com.github.chocoboxxf</groupId>
<artifactId>opentsdb-sdk-java</artifactId>
</dependency>
<!--数据库连接-->
<!-- 引入 mysql 数据库连接依赖-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<!--redis-->
<dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.playtika.testcontainers</groupId>
<artifactId>embedded-mysql</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-context</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-api</artifactId>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-impl</artifactId>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-jackson</artifactId>
</dependency>
<!-- Spring Boot HBase 依赖 -->
<dependency>
<groupId>com.spring4all</groupId>
<artifactId>spring-boot-starter-hbase</artifactId>
<version>1.0.0.RELEASE</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
This diff is collapsed.
package cn.wise.sc.energy.power.plant.business;
import cn.wise.sc.energy.power.plant.business.security.SecurityConfig;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Import;
import org.springframework.scheduling.annotation.EnableScheduling;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@EnableSwagger2
@EnableScheduling
@SpringBootApplication
@ImportAutoConfiguration(SecurityConfig.class)
public class PowerPlantApplication {
public static void main(String[] args) {
SpringApplication.run(PowerPlantApplication.class, args);
}
}
package cn.wise.sc.energy.power.plant.business;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
/**
* @Auther: yangjing
* @Date: 2020/3/29 12:17
* @ClassName: PACKAGE_NAME
* @Description: TODO
*/
@Configuration
@EnableSwagger2
public class SwaggerConfig extends WebMvcConfigurerAdapter {
@Bean
public Docket createRestApi() {// 创建API基本信息
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.basePackage("cn.wise.sc.energy.power.plant"))// 扫描该包下的所有需要在Swagger中展示的API,@ApiIgnore注解标注的除外
.paths(PathSelectors.any())//egex("/api/.*") 拦截的接口路径
.build();
}
private ApiInfo apiInfo() {// 创建API的基本信息,这些信息会在Swagger UI中进行显示
return new ApiInfoBuilder()
.title("swagger-api")// API 标题
.description("系统接口测试对接api")// API描述
.contact("杨**")// 联系人
// .license("Apache License Version 2.0")// 开源协议
.version("1.0")// 版本号
.build();
}
/**
* 重定向静态资源的路径,千万不要注释 不然 你们在访问api的时候会404的
* @param registry
*/
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
registry.addResourceHandler("swagger-ui.html") .addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**") .addResourceLocations("classpath:/META-INF/resources/webjars/");
// //下面是图片的虚拟路径配置
// registry.addResourceHandler(fileVirtualPath+"**").
// addResourceLocations("file:"+fileRealPath);
}
}
//package cn.wise.sc.energy.power.plant.business.bean;
//
//import java.util.List;
//
///**
// * @description: 电厂配置bean
// * @author: qh
// * @create: 2020-05-23 10:29
// **/
//public class BasicOption {
//
// private int latitude;
//
// private int longitude;
//
// private String department;
//
// private List<Devices> devices;
//
// public void setLatitude(int latitude){
// this.latitude = latitude;
// }
// public int getLatitude(){
// return this.latitude;
// }
// public void setLongitude(int longitude){
// this.longitude = longitude;
// }
// public int getLongitude(){
// return this.longitude;
// }
// public void setDepartment(String department){
// this.department = department;
// }
// public String getDepartment(){
// return this.department;
// }
// public void setDevices(List<Devices> devices){
// this.devices = devices;
// }
// public List<Devices> getDevices(){
// return this.devices;
// }
//
//}
//package cn.wise.sc.energy.power.plant.business.bean;
//
///**
// * @description: 测点
// * @author: qh
// * @create: 2020-05-23 10:26
// **/
//public class CharacterParamInfoVo {
//
// private String name;
//
// private String kkscode;
//
// private String unit;
//
// private int type;
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getName() {
// return this.name;
// }
//
// public void setKkscode(String kkscode) {
// this.kkscode = kkscode;
// }
//
// public String getKkscode() {
// return this.kkscode;
// }
//
// public void setUnit(String unit) {
// this.unit = unit;
// }
//
// public String getUnit() {
// return this.unit;
// }
//
// public void setType(int type) {
// this.type = type;
// }
//
// public int getType() {
// return this.type;
// }
//}
package cn.wise.sc.energy.power.plant.business.bean;
import lombok.Data;
import org.nustaq.serialization.coders.JSONAsString;
import java.util.ArrayList;
import java.util.List;
/**
* @description: 计算总功率的返回对象
* @author: qh
* @create: 2020-05-23 12:32
**/
@Data
public class DataPower {
/**
* X轴数据
*/
@JSONAsString
List<Object> xAxis = new ArrayList<>();
/**
* 折线图的点数据
*/
List<PowerPoints> dataList = new ArrayList<>();
/**
* 数据
*/
@Data
public static class PowerPoints {
/**
* 测点名
*/
private String name;
/**
* Y轴值集合
*/
private List<String> value = new ArrayList<>();
}
}
package cn.wise.sc.energy.power.plant.business.bean;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ConcurrentLinkedQueue;
/**
* @description: 返回结果 异步
* @author: qh
* @create: 2020-05-26 10:38
**/
@Data
public class DataPowerAsync {
/**
* X轴数据
*/
ConcurrentLinkedQueue<Object> xAxis = new ConcurrentLinkedQueue<>();
/**
* 折线图的点数据
*/
ConcurrentLinkedQueue<DataPowerAsync.PowerPoints> dataList = new ConcurrentLinkedQueue<>();
/**
* 数据
*/
@Data
public static class PowerPoints {
/**
* 测点名
*/
private String name;
/**
* Y轴值集合
*/
private ConcurrentLinkedQueue<String> value = new ConcurrentLinkedQueue<>();
}
}
//package cn.wise.sc.energy.power.plant.business.bean;
//
//import java.util.List;
//
///**
// * @description: 设备
// * @author: qh
// * @create: 2020-05-23 10:27
// **/
//public class Devices
//{
// private String devicename;
//
// private String ratepower;
//
// private String raterpm;
//
// private List<UnitInfoVo> units;
//
// public void setDevicename(String devicename){
// this.devicename = devicename;
// }
// public String getDevicename(){
// return this.devicename;
// }
// public void setRatepower(String ratepower){
// this.ratepower = ratepower;
// }
// public String getRatepower(){
// return this.ratepower;
// }
// public void setRaterpm(String raterpm){
// this.raterpm = raterpm;
// }
// public String getRaterpm(){
// return this.raterpm;
// }
// public void setUnitInfoVo(List<UnitInfoVo> units){
// this.units = units;
// }
// public List<UnitInfoVo> getUnitInfoVos(){
// return this.units;
// }
//}
package cn.wise.sc.energy.power.plant.business.bean;
import cn.wise.sc.energy.power.plant.common.core.exception.ResponseEnum;
import lombok.Data;
/**
* @description: 时间查询对象
* @author: qh
* @create: 2020-05-20 16:18
*/
public class TimeModelQuery {
public long getStart() {
return start;
}
public void setStart(long start) {
if (end != null && end != 0L && start >= end) {
ResponseEnum.BAD_TIME.assertNotNull(null);
}
this.start = start;
}
public long getEnd() {
return end;
}
public void setEnd(long end) {
if (start != null && start != 0L && start >= end) {
ResponseEnum.BAD_TIME.assertNotNull(null);
}
this.end = end;
}
private Long start;
private Long end;
}
//package cn.wise.sc.energy.power.plant.business.bean;
//
//import cn.wise.sc.energy.power.plant.business.bean.BasicOption;
//import lombok.Data;
//
///**
// * @description: 电厂配置最外层
// * @author: qh
// * @create: 2020-05-27 11:16
// **/
//@Data
//public class TurbineOption {
//
// private String plantCode;
// private String plantName;
//
// BasicOption basicOption;
//}
//package cn.wise.sc.energy.power.plant.business.bean;
//
//import java.util.List;
//
///**
// * @description: 部件
// * @author: qh
// * @create: 2020-05-23 10:28
// **/
//public class UnitInfoVo {
//
// private String unitname;
//
// private String unitid;
//
// private int trendanalys;
//
// private int vibrationanalys;
//
// private int binarytreeanalys;
//
// private List<CharacterParamInfoVo> characters;
//
// public void setUnitname(String unitname) {
// this.unitname = unitname;
// }
//
// public String getUnitName() {
// return this.unitname;
// }
//
// public void setUnitid(String unitid) {
// this.unitid = unitid;
// }
//
// public String getUnitid() {
// return this.unitid;
// }
//
// public void setTrendanalys(int trendanalys) {
// this.trendanalys = trendanalys;
// }
//
// public int getTrendanalys() {
// return this.trendanalys;
// }
//
// public void setVibrationanalys(int vibrationanalys) {
// this.vibrationanalys = vibrationanalys;
// }
//
// public int getVibrationanalys() {
// return this.vibrationanalys;
// }
//
// public void setBinarytreeanalys(int binarytreeanalys) {
// this.binarytreeanalys = binarytreeanalys;
// }
//
// public int getBinarytreeanalys() {
// return this.binarytreeanalys;
// }
//
// public void setCharacterParamInfoVo(List<CharacterParamInfoVo> characters) {
// this.characters = characters;
// }
//
// public List<CharacterParamInfoVo> getCharacters() {
// return this.characters;
// }
//
//}
//package cn.wise.sc.energy.power.plant.business.config;
//
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//
///**
// * @description:
// * @author: qh
// * @create: 2020-08-20 14:47
// **/
//@Configuration
//public class HBaseConfiguration {
//
// @Value("${hbase.zookeeper.quorum}")
// private String zookeeperQuorum;
//
// @Value("${hbase.zookeeper.property.clientPort}")
// private String clientPort;
//
// @Value("${zookeeper.znode.parent}")
// private String znodeParent;
//
// @Bean
// public HbaseTemplate hbaseTemplate() {
// org.apache.hadoop.conf.Configuration conf = new org.apache.hadoop.conf.Configuration();
// conf.set("hbase.zookeeper.quorum", zookeeperQuorum);
// conf.set("hbase.zookeeper.property.clientPort", clientPort);
// conf.set("zookeeper.znode.parent", znodeParent);
// return new HbaseTemplate(conf);
// }
//}
\ No newline at end of file
package cn.wise.sc.energy.power.plant.business.config;
import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.core.JdbcTemplate;
import javax.sql.DataSource;
/**
* @ClassNameJdbcConfig
* @Description 数据配置
* 按需注入Bean对象
* @Author qh
* @Date2020/3/5 16:27
* @Version V1.0
**/
@Configuration
public class JdbcConfig {
/**
* 默认的数据库连接池
* @return
*/
@Bean(name = "dataSourceToken")
@ConditionalOnMissingBean(DataSource.class)
public DataSource createDataSource() {
DruidDataSource dataSource = new DruidDataSource();
dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver");
dataSource.setUrl("jdbc:mysql://39.105.38.125:3306/turbinedb?useUnicode=true&characterEncoding=UTF-8&useSSL=false");
dataSource.setUsername("root");
dataSource.setPassword("Qzh-1234");
return dataSource;
}
/**
* jdbcTemplate 注册
* @param dataSourceToken
* @return
*/
@Bean(name = "jdbcTemplate")
public JdbcTemplate createJdbcTemplate(DataSource dataSourceToken) {
return new JdbcTemplate(dataSourceToken);
}
}
\ No newline at end of file
package cn.wise.sc.energy.power.plant.business.config;
import org.apache.commons.lang3.StringUtils;
import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.redisson.config.SingleServerConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
@ConditionalOnClass(Config.class)
@EnableConfigurationProperties(RedissonProperties.class)
public class RedissonAutoConfiguration {
@Autowired
private RedissonProperties redssionProperties;
/**
* 单机模式自动装配
* @return
*/
@Bean
// @Profile({"deve","test"})
@ConditionalOnProperty(name="spring.redisson.address")
RedissonClient redissonSingle() {
Config config = new Config();
SingleServerConfig serverConfig = config.useSingleServer()
.setAddress(redssionProperties.getAddress())
.setTimeout(redssionProperties.getTimeout())
.setConnectionPoolSize(redssionProperties.getConnectionPoolSize())
.setConnectionMinimumIdleSize(redssionProperties.getConnectionMinimumIdleSize());
if(StringUtils.isNotBlank(redssionProperties.getPassword())) {
serverConfig.setPassword(redssionProperties.getPassword());
}
return Redisson.create(config);
}
}
\ No newline at end of file
package cn.wise.sc.energy.power.plant.business.config;
import org.springframework.boot.context.properties.ConfigurationProperties;
@ConfigurationProperties(prefix = "spring.redisson")
public class RedissonProperties {
private int timeout = 3000;
private String address;
private String password;
private int connectionPoolSize = 64;
private int connectionMinimumIdleSize=10;
private int slaveConnectionPoolSize = 250;
private int masterConnectionPoolSize = 250;
private String[] sentinelAddresses;
private String masterName;
public int getTimeout() {
return timeout;
}
public void setTimeout(int timeout) {
this.timeout = timeout;
}
public int getSlaveConnectionPoolSize() {
return slaveConnectionPoolSize;
}
public void setSlaveConnectionPoolSize(int slaveConnectionPoolSize) {
this.slaveConnectionPoolSize = slaveConnectionPoolSize;
}
public int getMasterConnectionPoolSize() {
return masterConnectionPoolSize;
}
public void setMasterConnectionPoolSize(int masterConnectionPoolSize) {
this.masterConnectionPoolSize = masterConnectionPoolSize;
}
public String[] getSentinelAddresses() {
return sentinelAddresses;
}
public void setSentinelAddresses(String sentinelAddresses) {
this.sentinelAddresses = sentinelAddresses.split(",");
}
public String getMasterName() {
return masterName;
}
public void setMasterName(String masterName) {
this.masterName = masterName;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public int getConnectionPoolSize() {
return connectionPoolSize;
}
public void setConnectionPoolSize(int connectionPoolSize) {
this.connectionPoolSize = connectionPoolSize;
}
public int getConnectionMinimumIdleSize() {
return connectionMinimumIdleSize;
}
public void setConnectionMinimumIdleSize(int connectionMinimumIdleSize) {
this.connectionMinimumIdleSize = connectionMinimumIdleSize;
}
}
\ No newline at end of file
package cn.wise.sc.energy.power.plant.business.config;
import lombok.extern.slf4j.Slf4j;
import org.hibernate.validator.HibernateValidator;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.validation.beanvalidation.MethodValidationPostProcessor;
import javax.validation.Validation;
import javax.validation.Validator;
import javax.validation.ValidatorFactory;
@Slf4j(topic = "SYSTEM_LOG")//日志模块
@Configuration
@EnableAutoConfiguration
public class ValidatorConfig {
@Bean
public MethodValidationPostProcessor methodValidationPostProcessor() {
MethodValidationPostProcessor postProcessor = new MethodValidationPostProcessor();
postProcessor.setValidator(validator());
return postProcessor;
}
@Bean
public Validator validator(){
ValidatorFactory validatorFactory = Validation.byProvider( HibernateValidator.class )
.configure()
.addProperty( "hibernate.validator.fail_fast", "true" )
.buildValidatorFactory();
Validator validator = validatorFactory.getValidator();
return validator;
}
}
package cn.wise.sc.energy.power.plant.business.config;
import org.apache.catalina.session.StandardSessionFacade;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;
import javax.servlet.http.HttpSession;
import javax.websocket.HandshakeResponse;
import javax.websocket.server.HandshakeRequest;
import javax.websocket.server.ServerEndpointConfig;
@Configuration
public class WebSocketConfig extends ServerEndpointConfig.Configurator {
private static final Logger log = LoggerFactory.getLogger(WebSocketConfig.class);
/**
* 修改握手信息
*/
@Override
public void modifyHandshake(ServerEndpointConfig sec, HandshakeRequest request, HandshakeResponse response) {
StandardSessionFacade ssf = (StandardSessionFacade) request.getHttpSession();
if (ssf != null) {
HttpSession httpSession = (HttpSession) request.getHttpSession();
//关键操作
sec.getUserProperties().put("sessionId", httpSession.getId());
log.info("获取到的SessionID:" + httpSession.getId());
}
super.modifyHandshake(sec, request, response);
}
/**
* WebSocket的支持
* @return
*/
@Bean
public ServerEndpointExporter serverEndpointExporter() {
//这个对象说一下,貌似只有服务器是tomcat的时候才需要配置,具体我没有研究
return new ServerEndpointExporter();
}
}
package cn.wise.sc.energy.power.plant.business.constant;
/**
* @description: 首页展示的实时数据折线图名字
* @author: qh
* @create: 2020-06-01 10:53
**/
public enum RealTimeDataChartType {
/**
* 各机组功率趋势图
*/
POWER_CHART("POWER_CHART", 1),
/**
* 各机组报警点数对比
*/
WARN_CHART("WARN_CHART", 2),
/**
* 各机组累计报警次数对比
*/
WARN_TOTAL_CHART("WARN_TOTAL_CHART", 3),
/**
* 汇总实时数据
*/
ELECTRICITY_VOLTAGE_CHART("ELECTRICITY_VOLTAGE_CHART", 4),
/**
* 各机组振动棒状对比图
*/
VIBRATION_CHART("VIBRATION_CHART", 5),
/**
* 各机组轴瓦温度柱状图
*/
TEMPERATURE_CHART("TEMPERATURE_CHART", 6);
/**
* 折线图名字
*/
private String name;
/**
* 编码
*/
private int code;
RealTimeDataChartType(String name, int code) {
this.name = name;
this.code = code;
}
public String getName() {
return name;
}
public int getCode() {
return code;
}
}
package cn.wise.sc.energy.power.plant.business.constant;
/**
* @description: 趋势图 计算条件枚举
* @author: qh
* @create: 2020-05-23 13:49
**/
public enum TendencyConditionEnum {
HOUR(1, "时均线"), DAY(2, "日均线"), MONTH(3, "月均线");
/**
* 条件编码
*/
private int code;
public int getCode() {
return code;
}
public String getValue() {
return value;
}
/**
* 值
*/
private String value;
TendencyConditionEnum(int code, String value) {
this.code = code;
this.value = value;
}
}
//package cn.wise.sc.energy.power.plant.business.controller;
//
//import cn.wise.sc.energy.power.plant.common.core.bean.BaseResponse;
//import io.swagger.annotations.Api;
//import org.springframework.web.bind.annotation.CrossOrigin;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//
///**
// * @description: 冷凝水监控 控制器
// * @author: qh
// * @create: 2020-05-20 16:04
// */
//@Deprecated
//@CrossOrigin
//@RestController
//@RequestMapping("/condensate")
//public class CondensateController {
//
// public BaseResponse<String> test() {
// return null;
// }
//
//}
//package cn.wise.sc.energy.power.plant.business.controller;
//
//import cn.wise.sc.energy.power.plant.business.service.MenuService;
//import cn.wise.sc.energy.power.plant.common.core.bean.BaseResponse;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import org.springframework.context.annotation.Description;
//import org.springframework.web.bind.annotation.CrossOrigin;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//
///**
// * @description: 菜单
// * @author: qh
// * @create: 2020-05-23 09:30
// **/
//@Deprecated
//@CrossOrigin
//@RestController
//@RequestMapping("/menu")
//public class MenuController {
//
// final
// MenuService menuService;
//
// public MenuController(MenuService menuService) {
// this.menuService = menuService;
// }
//
// @GetMapping("/menuInfo")
// @ApiOperation("获取菜单信息")
// public BaseResponse<String> getMenuInfo() {
// return menuService.getMenuInfo();
// }
//
//
// @GetMapping("/characterInfo")
// @ApiOperation("获取测点信息")
// public BaseResponse<String> getCharacterInfo(String key) {
// return menuService.getCharacterInfo(key);
// }
//
//}
//package cn.wise.sc.energy.power.plant.business.controller;
//
//import cn.wise.sc.energy.power.plant.business.bean.TimeModelQuery;
//import cn.wise.sc.energy.power.plant.business.service.ISpindleService;
//import cn.wise.sc.energy.power.plant.common.core.bean.BaseResponse;
//import io.swagger.annotations.Api;
//import org.springframework.web.bind.annotation.CrossOrigin;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//
///**
// * @description: 转轴监控
// * @author: qh
// * @create: 2020-05-20 16:13
// */
//@Deprecated
//@CrossOrigin
//@RestController
//@RequestMapping("/spindle")
//public class SpindleController {
//
// final ISpindleService iSpindleService;
//
// public SpindleController(ISpindleService iSpindleService) {
// this.iSpindleService = iSpindleService;
// }
//
// @GetMapping
// public BaseResponse<String> getDataByTime(TimeModelQuery timeModelQuery, String key) {
// return null;
// }
//
//}
//package cn.wise.sc.energy.power.plant.business.controller;
//
//import cn.wise.sc.energy.power.plant.common.kafka.service.IndicatorService;
//import org.springframework.web.bind.annotation.CrossOrigin;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//
///**
// * @description:
// * @author: qh
// * @create: 2020-05-18 14:57
// **/
//@RestController
//@RequestMapping("/test")
//@CrossOrigin
//public class TestController {
//
// final
// IndicatorService indicatorService;
//
// public TestController(IndicatorService indicatorService) {
// this.indicatorService = indicatorService;
// }
//
// @GetMapping
// public void test(){
// indicatorService.sendMessage("thermalpower_plant_1","sssssssss");
// }
//
//
//
//}
package cn.wise.sc.energy.power.plant.business.controller2;
import lombok.extern.slf4j.Slf4j;
import cn.wise.sc.energy.power.plant.business.domain.AbstractEntity;
import cn.wise.sc.energy.power.plant.business.domain.vo.EntityVo;
import cn.wise.sc.energy.power.plant.business.service2.IBaseService;
import cn.wise.sc.energy.power.plant.common.core.bean.EntityQuery;
import cn.wise.sc.energy.power.plant.common.core.bean.BaseResponse;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
/**
* @description: 基础公共控制器
* @author: qh
* @create: 2020-07-20 18:18
**/
@Slf4j
public class BaseController<IService extends IBaseService> {
IService iService;
@GetMapping("{id}")
public BaseResponse<AbstractEntity> getByID(@PathVariable("id") Object id) {
try {
AbstractEntity entity = iService.getByID(id);
return BaseResponse.okData(entity);
} catch (Exception ex) {
log.error(ex.getMessage());
return BaseResponse.errorMsg("查询失败!");
}
}
@DeleteMapping("{id}")
public BaseResponse<AbstractEntity> delByID(@PathVariable("id") Object id) {
try {
iService.delByID(id);
return BaseResponse.okMsg("删除成功");
} catch (Exception ex) {
log.error(ex.getMessage());
return BaseResponse.errorMsg("删除失败失败!");
}
}
@PostMapping
public BaseResponse<EntityVo> addEntity(@RequestBody EntityQuery entityQuery) {
try {
EntityVo baseEntityVo = iService.add(entityQuery);
return BaseResponse.okData(baseEntityVo);
} catch (Exception ex) {
log.error(ex.getMessage());
return BaseResponse.errorMsg("删除失败失败!");
}
}
}
package cn.wise.sc.energy.power.plant.business.controller2;
import cn.wise.sc.energy.power.plant.business.bean.DataPower;
import cn.wise.sc.energy.power.plant.business.bean.TimeModelQuery;
import cn.wise.sc.energy.power.plant.business.domain.TendencyQuery;
import cn.wise.sc.energy.power.plant.business.domain.vo.EntityVo;
import cn.wise.sc.energy.power.plant.business.service2.ICharacterParamService;
import cn.wise.sc.energy.power.plant.business.service2.impl.BaseServiceImpl;
import cn.wise.sc.energy.power.plant.common.core.bean.BaseResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.constraints.NotEmpty;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @description: 测点特征controller
* @author: qh
* @create: 2020-07-20 18:12
**/
@CrossOrigin
@Validated
@RestController
@Api(tags = "测点特征")
@RequestMapping("CharacterParam/")
public class CharacterParamController {
final
ICharacterParamService iCharacterParamService;
public CharacterParamController(ICharacterParamService iCharacterParamService) {
this.iCharacterParamService = iCharacterParamService;
}
@GetMapping("{unitNo}")
public BaseResponse<List<EntityVo>> getUnitAllCharacterParams(
@PathVariable("unitNo") @NotEmpty(message = "unitNo不能为空!") String unitNo) {
return BaseResponse.okData(iCharacterParamService.getUnitAllCharacterParams(unitNo));
}
@GetMapping("/3d")
@ApiImplicitParams({
@ApiImplicitParam(name = "deviceId", value = "机组id"),
@ApiImplicitParam(name = "fileName", value = "文件名 '温度,压力,湿度'")
})
public BaseResponse<Map<String, Map<String, HashMap<Long, Number>>>> get3DCharacter(String deviceId,
String fileName) {
return iCharacterParamService.get3DCharacter(deviceId, fileName);
}
@PostMapping("/tendency")
public BaseResponse<List<DataPower>> getTendency(@RequestBody TendencyQuery tendencyQuery) {
return iCharacterParamService.getTendency(tendencyQuery.getKeys(),
tendencyQuery.getTimeModelQuery(), tendencyQuery.getStatus());
}
}
package cn.wise.sc.energy.power.plant.business.controller2;
import cn.wise.sc.energy.power.plant.business.domain.vo.DeviceInfoVo;
import cn.wise.sc.energy.power.plant.business.domain.vo.EntityVo;
import cn.wise.sc.energy.power.plant.business.service2.IDeviceInfoService;
import cn.wise.sc.energy.power.plant.common.core.bean.BaseResponse;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.constraints.NotEmpty;
import java.util.List;
/**
* @description: 设备信息controller
* @author: qh
* @create: 2020-07-20 18:13
**/
@CrossOrigin
@RestController
@Api(tags = "设备信息")
@RequestMapping("DeviceInfo/")
public class DeviceInfoController {
final
IDeviceInfoService iDeviceInfoService;
public DeviceInfoController(IDeviceInfoService iDeviceInfoService) {
this.iDeviceInfoService = iDeviceInfoService;
}
@GetMapping("{plantId}")
public BaseResponse<List<EntityVo>> getDeviceInfoByPlantCode(
@PathVariable("plantId") @NotEmpty(message = "plantCode不能为空!") String plantId) {
return BaseResponse.okData(iDeviceInfoService.getDeviceInfoByPlantCode(plantId));
}
@GetMapping("deviceAndUnit/{plantId}")
public BaseResponse<List<DeviceInfoVo>> getDeviceAndUnitByPlantCode(
@PathVariable("plantId") @NotEmpty(message = "plantCode不能为空!") String plantId) {
return BaseResponse.okData(iDeviceInfoService.getDeviceAndUnitByPlantCode(plantId));
}
}
package cn.wise.sc.energy.power.plant.business.controller2;
import cn.wise.sc.energy.power.plant.business.bean.DataPower;
import cn.wise.sc.energy.power.plant.business.service.IndexRealTimeDataService;
import cn.wise.sc.energy.power.plant.common.core.bean.BaseResponse;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
/**
* @description: 首页大屏实时数据展示
* @author: qh
* @create: 2020-05-25 10:23
**/
@CrossOrigin
@RestController
@RequestMapping("/indexRealData")
public class IndexRealDataController {
final
IndexRealTimeDataService indexRealTimeDataService;
public IndexRealDataController(IndexRealTimeDataService indexRealTimeDataService) {
this.indexRealTimeDataService = indexRealTimeDataService;
}
//
// @GetMapping("/vibration")
// @ApiOperation("首页实时数据 三相电压/电流 定子电压/电流 (汇总实时数据)")
// public BaseResponse<DataPower> vibrationData(String plantCode) {
//
// return indexRealTimeDataService.realTimeDataVoltage(plantCode);
// }
@GetMapping("/powerTendency")
@ApiOperation("首页各机组功率趋势图")
public BaseResponse<DataPower> powerTendency(String plantCode) {
return indexRealTimeDataService.getIndexPowerInit(plantCode);
}
@GetMapping("/unitLubrication")
@ApiOperation("各机组振动棒状对比图数据")
public BaseResponse<DataPower> realTimeDataUnitLubrication(String plantCode) {
return indexRealTimeDataService.realTimeDataUnitLubrication(plantCode);
}
@GetMapping("/bearingBushC")
@ApiOperation("各机组轴瓦温度柱状图")
public BaseResponse<DataPower> bearingBushC(String plantCode) {
return indexRealTimeDataService.realTimeDataBearingBushC(plantCode);
}
@GetMapping("/3DModel")
@ApiOperation("3D图测点")
public BaseResponse<DataPower> realTimeData3DModel(String unitId, String plantCode) {
return indexRealTimeDataService.realTimeData3DModel(unitId, plantCode);
}
@GetMapping("/alarm")
@ApiOperation("获取各机组报警点数对比")
public BaseResponse<List<DataPower>> realTimeDataAlarm() {
DataPower dataPower = get();
//模拟报警点数的假数据
DataPower dataPower2 = new DataPower();
dataPower2.getXAxis().add("热工参数");
dataPower2.getXAxis().add("机械参数");
dataPower2.getXAxis().add("电气参数");
dataPower2.getXAxis().add("环境参数");
dataPower2.getXAxis().add("辅助参数");
DataPower.PowerPoints powerPoints = new DataPower.PowerPoints();
powerPoints.setName("一号机组");
powerPoints.getValue().add(new Random().nextInt(30) + "");
powerPoints.getValue().add(new Random().nextInt(20) + "");
powerPoints.getValue().add(new Random().nextInt(10) + "");
powerPoints.getValue().add(new Random().nextInt(10) + "");
powerPoints.getValue().add(new Random().nextInt(10) + "");
DataPower.PowerPoints powerPoints1 = new DataPower.PowerPoints();
powerPoints1.setName("二号机组");
powerPoints1.getValue().add(new Random().nextInt(30) + "");
powerPoints1.getValue().add(new Random().nextInt(20) + "");
powerPoints1.getValue().add(new Random().nextInt(10) + "");
powerPoints1.getValue().add(new Random().nextInt(10) + "");
powerPoints1.getValue().add(new Random().nextInt(10) + "");
dataPower2.getDataList().add(powerPoints);
dataPower2.getDataList().add(powerPoints1);
List<DataPower> dataPowers = new ArrayList<>(2);
dataPowers.add(dataPower2);
dataPowers.add(dataPower);
return BaseResponse.okData(dataPowers);
}
@GetMapping("/alarm2")
@ApiOperation("获取各机组报警点数对比")
public BaseResponse<List<DataPower>> realTimeDataAlarm2() {
DataPower dataPower = get();
//模拟报警点数的假数据
DataPower dataPower2 = new DataPower();
dataPower2.getXAxis().add("一号机组");
dataPower2.getXAxis().add("二号机组");
DataPower.PowerPoints powerPoints = new DataPower.PowerPoints();
powerPoints.setName("一号机组");
powerPoints.getValue().add(getTotal(dataPower.getDataList(), 0));
DataPower.PowerPoints powerPoints1 = new DataPower.PowerPoints();
powerPoints1.setName("二号机组");
powerPoints1.getValue().add(getTotal(dataPower.getDataList(), 1));
dataPower2.getDataList().add(powerPoints);
dataPower2.getDataList().add(powerPoints1);
List<DataPower> dataPowers = new ArrayList<>(2);
dataPowers.add(dataPower);
dataPowers.add(dataPower2);
return BaseResponse.okData(dataPowers);
}
private String getTotal(List<DataPower.PowerPoints> powerPoints, int count) {
int rts = 0;
for (DataPower.PowerPoints powerPoints1 : powerPoints) {
rts += Integer.parseInt(powerPoints1.getValue().get(count));
}
return rts + "";
}
private DataPower get() {
//模拟报警点数的假数据
DataPower dataPower = new DataPower();
dataPower.getXAxis().add("一号机组");
dataPower.getXAxis().add("二号机组");
DataPower.PowerPoints powerPoints = new DataPower.PowerPoints();
powerPoints.setName("一级报警");
powerPoints.getValue().add(new Random().nextInt(30) + "");
powerPoints.getValue().add(new Random().nextInt(20) + "");
DataPower.PowerPoints powerPoints1 = new DataPower.PowerPoints();
powerPoints1.setName("二级报警");
powerPoints1.getValue().add(new Random().nextInt(30) + "");
powerPoints1.getValue().add(new Random().nextInt(20) + "");
DataPower.PowerPoints powerPoints2 = new DataPower.PowerPoints();
powerPoints2.setName("三级报警");
powerPoints2.getValue().add(new Random().nextInt(30) + "");
powerPoints2.getValue().add(new Random().nextInt(20) + "");
dataPower.getDataList().add(powerPoints);
dataPower.getDataList().add(powerPoints1);
dataPower.getDataList().add(powerPoints2);
return dataPower;
}
}
package cn.wise.sc.energy.power.plant.business.controller2;
import cn.wise.sc.energy.power.plant.business.domain.vo.EntityVo;
import cn.wise.sc.energy.power.plant.business.service2.IPlantInfoService;
import cn.wise.sc.energy.power.plant.common.core.bean.BaseResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.constraints.NotEmpty;
import java.util.List;
/**
* @description: 电厂信息controller
* @author: qh
* @create: 2020-07-20 18:13
**/
@CrossOrigin
@RestController
@Api(tags = "电厂信息")
@RequestMapping("PlantInfo/")
public class PlantInfoController {
final
IPlantInfoService iPlantInfoService;
public PlantInfoController(IPlantInfoService iPlantInfoService) {
this.iPlantInfoService = iPlantInfoService;
}
@GetMapping("allPlantInfo")
public BaseResponse<List<EntityVo>> getAllPlantInfo() {
List<EntityVo> list = iPlantInfoService.list();
return BaseResponse.okData(list);
}
@GetMapping("power/{plantId}")
@ApiOperation("获取总功率")
@ApiImplicitParam(name = "plantId", value = "电厂id", paramType = "query")
public BaseResponse<Integer> getTotalPower(@PathVariable("plantId")
@NotEmpty(message = "电厂id不能为空!") String plantId) {
return iPlantInfoService.getTotalPower(plantId);
}
}
package cn.wise.sc.energy.power.plant.business.controller2;
import cn.wise.sc.energy.power.plant.business.domain.Oscillogram;
import cn.wise.sc.energy.power.plant.business.domain.OscillogramRowMapper;
import com.spring4all.spring.boot.starter.hbase.api.HbaseTemplate;
import com.spring4all.spring.boot.starter.hbase.api.RowMapper;
import io.swagger.annotations.Api;
import org.apache.hadoop.conf.Configuration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @description: 运行时选项配置controller
* @author: qh
* @create: 2020-07-20 18:13
**/
@CrossOrigin
@RestController
@Api(tags = "系统运行时选项配置")
@RequestMapping("RuntimeOption/")
public class RuntimeOptionController {
@Autowired
HbaseTemplate hbaseTemplate;
@GetMapping("/test")
public void test(){
List<Oscillogram> objects = hbaseTemplate.find("thermalpower-plant-wave-data",
"3c0a00102mka62ce610r1596100323000", new OscillogramRowMapper());
}
}
package cn.wise.sc.energy.power.plant.business.controller2;
import cn.wise.sc.energy.power.plant.business.bean.TimeModelQuery;
import cn.wise.sc.energy.power.plant.business.service.TendencyService;
import cn.wise.sc.energy.power.plant.common.core.bean.BaseResponse;
import lombok.extern.slf4j.Slf4j;
import org.redisson.api.RedissonClient;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @description: 趋势图
* @author: qh
* @create: 2020-05-23 11:51
**/
@Slf4j
@CrossOrigin
@RestController
@RequestMapping("/tendency")
public class TendencyController {
final
RedissonClient redissonClient;
final
TendencyService tendencyService;
public TendencyController(RedissonClient redissonClient, TendencyService tendencyService) {
this.redissonClient = redissonClient;
this.tendencyService = tendencyService;
}
@PostMapping
public BaseResponse<String> getInitData(@RequestBody List<String> keys,
TimeModelQuery timeModelQuery,
Integer status) {
return tendencyService.getInitData(keys, timeModelQuery, status);
}
}
package cn.wise.sc.energy.power.plant.business.controller2;
import cn.wise.sc.energy.power.plant.business.domain.vo.EntityVo;
import cn.wise.sc.energy.power.plant.business.service2.IUnitInfoService;
import cn.wise.sc.energy.power.plant.common.core.bean.BaseResponse;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.constraints.NotEmpty;
import java.util.List;
/**
* @description: 部件信息controller
* @author: qh
* @create: 2020-07-20 18:14
**/
@CrossOrigin
@RestController
@Api(tags = "部件选项")
@RequestMapping("UnitInfo/")
public class UnitInfoController {
final
IUnitInfoService iUnitInfoService;
public UnitInfoController(IUnitInfoService iUnitInfoService) {
this.iUnitInfoService = iUnitInfoService;
}
/**
* 获取设备的测点信息
*
* @param deviceId 设备ID
* @return List<EntityVo>
*/
@GetMapping("{deviceId}")
public BaseResponse<List<EntityVo>> getUnitInfoByDeviceId(
@PathVariable("deviceId") @NotEmpty(message = "deviceId不能为空!") String deviceId) {
List<EntityVo> entityVos = iUnitInfoService.getUnitInfoByDeviceId(deviceId);
return BaseResponse.okData(entityVos);
}
}
package cn.wise.sc.energy.power.plant.business.controller2;
import cn.wise.sc.energy.power.plant.business.domain.PageQuery;
import cn.wise.sc.energy.power.plant.business.domain.UserInfo;
import cn.wise.sc.energy.power.plant.business.domain.UserInfoQuery;
import cn.wise.sc.energy.power.plant.business.domain.vo.EntityVo;
import cn.wise.sc.energy.power.plant.business.service2.IUserInfoService;
import cn.wise.sc.energy.power.plant.common.core.bean.BaseResponse;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @description: 用户信息
* @author: qh
* @create: 2020-08-12 11:28
**/
@Validated
@CrossOrigin
@RestController
@Api(tags = "用户管理")
@RequestMapping("userInfo/")
public class UserInfoController {
final
IUserInfoService iUserInfoService;
public UserInfoController(IUserInfoService iUserInfoService) {
this.iUserInfoService = iUserInfoService;
}
@GetMapping("/page")
public BaseResponse<Page<UserInfo>> page(PageQuery page, String username) {
return iUserInfoService.page(page.getPageNo(), page.getPageSize(), username);
}
@PostMapping("/new")
public BaseResponse<Boolean> add(UserInfoQuery userInfo) {
return iUserInfoService.addUserInfo(userInfo);
}
@PutMapping("/new")
public BaseResponse<Boolean> edit(UserInfoQuery userInfo) {
return iUserInfoService.edit(userInfo);
}
}
package cn.wise.sc.energy.power.plant.business.domain;
import cn.wise.sc.energy.power.plant.business.domain.vo.EntityVo;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.springframework.data.domain.Persistable;
import javax.persistence.MappedSuperclass;
import javax.persistence.PostLoad;
import javax.persistence.PrePersist;
import javax.persistence.Transient;
/**
* @description: 基础实体父类
* @author: qh
* @create: 2020-07-14 16:42
**/
@MappedSuperclass
public abstract class AbstractEntity<ID> implements Persistable<ID> {
@Transient
private boolean isNew = true;
@Override
@JsonIgnore
public boolean isNew() {
return isNew;
}
@PrePersist
@PostLoad
void markNotNew() {
this.isNew = false;
}
/**
* toVo方法 需要子类实现
* @return
*/
public EntityVo toVo() {
return null;
}
}
\ No newline at end of file
package cn.wise.sc.energy.power.plant.business.domain;
import cn.wise.sc.energy.power.plant.business.domain.eum.SignalTypeEnum;
import cn.wise.sc.energy.power.plant.business.domain.vo.CharacterParamInfoVo;
import cn.wise.sc.energy.power.plant.business.domain.vo.EntityVo;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.BeanUtils;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.List;
/**
* @description: 检测特点信息
* @author: qh
* @create: 2020-07-14 09:40
**/
@Entity
@Data
@NoArgsConstructor
@Table(name = "characterparaminfo")
public class CharacterParamInfo extends AbstractEntity<String> {
/**
* 转换成Vo
*
* @return
*/
@Override
public EntityVo toVo() {
CharacterParamInfoVo characterParamInfoVo = new CharacterParamInfoVo();
BeanUtils.copyProperties(this,characterParamInfoVo);
return characterParamInfoVo;
}
/**
* 监测特征所属电站的标识
*/
@Column(name = "plantid")
private String plantId;
/**
* 监测特征所属设备的标识
*/
@Column(name = "deviceid")
private String deviceId;
/**
* 监测特征所属监测单元标识
*/
@Column(name = "unitcodeid")
private String unitCodeId;
/**
* 监测特征唯一标识编码(KKS编码)如:C0A00101CBA00MKF26S101
*/
@Id
@Column(name = "kkscode")
private String kksCode;
/**
* 监测特征名称
*/
@Column(name = "cpname")
private String cpName;
/**
* todo 枚举
* 监测特征计算类型,很重要
*/
@Column(name = "cptype")
private Integer cpType;
/**
* 监测特征的物理单位,如 um/mm 等
*/
@Column(name = "cpunit")
private String cpUnit;
/**
* 监测特征 信号类型:
* T: 温度参数 M: 机械参数
* E: 电气参数 A: 辅机参数
*/
@Enumerated(EnumType.STRING)
@Column(name = "signaltype")
private SignalTypeEnum signalType;
/**
* 特征参数是否属于派生的特征参数
* 1: 是 0: 不是
*/
@Column(name = "isderiveparam")
private Integer isDeriveParam;
/**
* 如果 isderiveparam =1 时,该字段 指名本特征参数是从哪一个 特征参数 计算获得,
* derivefrom 指明该特征参数的KKScode
*/
@Column(name = "derivedfrom")
private String derivedFrom;
/**
* 特征参数保护(一级报警)规则是否有效
* 1: 有效 0:无效(未设定)
*/
@Column(name = "protectrulevalid")
private Integer protectRuleValid;
/**
* 特征参数保护(一级报警)下限值
*/
@Column(name = "protectrulemaxvalue")
private Float protectRuleMaxValue;
/**
* 特征参数保护(一级报警)上限值
*/
@Column(name = "protectruleminvalue")
private Float protectRuleMinValue;
/**
* 特征参数保护(一级报警)规则阈值范围是否是排除范围
* 1: 是排除范围 0:是限定范围
*/
@Column(name = "protectruleexclude")
private Integer protectRuleExclude;
/**
* 特征参数报警(二级报警)规则是否有效
* 1: 有效 0:无效(未设定)
*/
@Column(name = "alertrulevalid")
private Integer alertRuleValid;
/**
* 特征参数警(二级报警)下限值
*/
@Column(name = "alertruleminvalue")
private Float alertRuleMinValue;
/**
* 特征参数报警(二级报警)上限值
*/
@Column(name = "alertrulemaxvalue")
private Float alertRuleMaxValue;
/**
* 特征参数报警(二级报警)规则阈值范围是否是排除范围
* 1: 是排除范围 0:是限定范围
*/
@Column(name = "alertruleexclude")
private Integer alertRuleExclude;
@Column(name = "hasderiveparam")
private Integer hasDeriveParam;
@Override
public String getId() {
return getKksCode();
}
}
package cn.wise.sc.energy.power.plant.business.domain;
import lombok.Data;
/**
* @description: 巡检交互项
* @author: qh
* @create: 2020-08-19 10:03
**/
@Data
public class DetectionInteraction {
private String id;
/**
* 问题描述
*/
private String name;
/**
* 图表数据(无图标为空)
*/
private String data;
/**
* 选项内容
*/
private String select;
}
package cn.wise.sc.energy.power.plant.business.domain;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
/**
* @description: 一键巡检检测项
* @author: qh
* @create: 2020-08-17 10:23
**/
@Data
public class DetectionItem {
/**
* 诊断ID uuid
*/
private String id;
/**
* 有正值表示诊断完成。默认-1。-2表示需要交互
*/
private String grade;
/**
* 监测单元名称
*/
@JSONField(name = "unitname")
private String unitName;
/**
* Kks码
*/
@JSONField(name = "kkscode")
private String kKSCode;
/**
* 测值
*/
@JSONField(name = "cpdata")
private String cpData;
/**
* 监测特征的物理单位,如 um/mm 等
*/
@JSONField(name = "cpunit")
private String cpUnit;
/**
* 特征参数警下限值
*/
@JSONField(name = "alertruleminvalue")
private String alertRuleMinvalue;
/**
* 特征参数报警上限值
*/
@JSONField(name = "alertrulemaxvalue")
private String alertRuleMaxvalue;
/**
* 是否超标
*/
private String overweight;
}
package cn.wise.sc.energy.power.plant.business.domain;
import cn.wise.sc.energy.power.plant.business.domain.vo.DeviceInfoVo;
import cn.wise.sc.energy.power.plant.business.domain.vo.EntityVo;
import lombok.Data;
import org.springframework.beans.BeanUtils;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.Table;
/**
* @description: 设备信息
* @author: qh
* @create: 2020-07-14 09:41
**/
@Data
@Entity
@Table(name = "deviceinfo")
public class DeviceInfo extends AbstractEntity<String> {
@Override
public EntityVo toVo(){
DeviceInfoVo deviceInfoVo = new DeviceInfoVo();
BeanUtils.copyProperties(this,deviceInfoVo);
return deviceInfoVo;
}
/**
* 设备所在电站的标识
*/
@Column(name = "plantid")
private String plantId;
/**
* 设备唯一标识编码如:C0A00101,该标识用于与设备配置信息其他表的关联
*/
@Id
@Column(name = "deviceid")
private String deviceId;
/**
* 设备真是名称
*/
@Column(name = "devicename")
private String deviceName;
/**
* 设备分类, 发电机、汽轮机、水轮机等
*/
@Column(name = "devicetype")
private String deviceType;
/**
* 设备制造厂
*/
@Column(name = "manufacture")
private String manufacture;
/**
* 设备编码
*/
@Column(name = "devicecode")
private String deviceCode;
/**
* 设备静态参数描述;以Json 格式存储,如 {"ratepower":"300MW","raterpm":"3000r/min"}
*/
@Lob
@Column(name = "deviceparam")
private String deviceParam;
@Override
public String getId() {
return getDeviceId();
}
}
package cn.wise.sc.energy.power.plant.business.domain;
import lombok.Data;
/**
* @description: 波形图
* @author: qh
* @create: 2020-08-20 15:24
**/
@Data
public class Oscillogram {
}
package cn.wise.sc.energy.power.plant.business.domain;
import lombok.Data;
/**
* @description: 波形图入参
* @author: qh
* @create: 2020-08-20 09:51
**/
@Data
public class OscillogramQuery {
/**
* 开始时间时间 毫秒
*/
private long startTime;
/**
* 时间间隔 毫秒级
*/
private long timeSpan;
@Data
public static class Record{
/**
* 键相类型(0:波形数据数组下标,1:波形数据相对起始点时间偏移
*/
private Integer keyPhaseTyped;
/**
* 磁极数目
*/
private Integer poleNum;
/**
* 发电机频率单位(Hz)
*/
private String generationFreq;
private Integer direction;
}
}
package cn.wise.sc.energy.power.plant.business.domain;
import com.alibaba.fastjson.JSON;
import com.spring4all.spring.boot.starter.hbase.api.RowMapper;
import org.apache.hadoop.hbase.client.Result;
/**
* @description:
* @author: qh
* @create: 2020-08-20 15:25
**/
public class OscillogramRowMapper implements RowMapper<Oscillogram> {
@Override
public Oscillogram mapRow(Result result, int rowNum) throws Exception {
System.out.println("+==============================================");
System.out.println(JSON.toJSONString(result));
System.out.println(result);
return null;
}
}
package cn.wise.sc.energy.power.plant.business.domain;
import lombok.Data;
import java.io.Serializable;
/**
* @description: 分页参数
* @author: qh
* @create: 2020-08-12 11:33
**/
@Data
public class PageQuery implements Serializable {
private static final long serialVersionUID = 1L;
private Integer pageNo = 0;
private Integer pageSize = 10;
}
package cn.wise.sc.energy.power.plant.business.domain;
import cn.wise.sc.energy.power.plant.business.domain.vo.EntityVo;
import cn.wise.sc.energy.power.plant.business.domain.vo.PlantInfoVo;
import lombok.Data;
import org.springframework.beans.BeanUtils;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.Table;
/**
* @description: 电厂配置信息
* @author: qh
* @create: 2020-07-14 09:41
**/
@Data
@Entity
@Table(name = "plantinfo")
public class PlantInfo extends AbstractEntity<String>{
/**
* 电站唯一标识
*/
@Id
@Column(name = "plantid")
private String plantId;
/**
* 电站数据存放的数据库标识(保留)
*/
@Column(name = "plantdbcode")
private String plantCode;
/**
* 电站真真实名称
*/
@Column(name = "plantname")
private String plantName;
/**
* 电站所在国家
*/
private String country;
/**
* 电站所在省份
*/
private String province;
/**
* 电站所在纬度
*/
private String latitude;
/**
* 电站所在经度
*/
private String longitude;
@Override
public String getId() {
return getPlantId();
}
@Override
public EntityVo toVo(){
PlantInfoVo plantInfoVo = new PlantInfoVo();
BeanUtils.copyProperties(this,plantInfoVo);
return plantInfoVo;
}
}
package cn.wise.sc.energy.power.plant.business.domain;
import cn.wise.sc.energy.power.plant.business.domain.eum.ItemNameEnum;
import lombok.Data;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Id;
import javax.persistence.Table;
/**
* @description: 运行时选项设置信息
* @author: qh
* @create: 2020-07-14 09:41
**/
@Data
@Entity
@Table(name = "runtimeoptioninfo")
public class RuntimeOptionInfo extends AbstractEntity<Long>{
@Id
private Long id;
/**
* 监测特征所属电站的标识
*/
private String plantId;
/**
* 监测特征所属设备的标识
*/
private String deviceId;
/**
* 监测特征所属监测单元标识,
*/
private String unitCodeId;
/**
* 配置项名称,如 ‘stableSaveTime’
*/
@Enumerated(EnumType.STRING)
private ItemNameEnum itemName;
/**
* 配置项取值: 如'1200'
*/
private String itemValue;
/**
* 配置项值类型:
* 0: 配置项值是整型
* 1: 配置项值是浮点型
*/
private String itemType;
}
package cn.wise.sc.energy.power.plant.business.domain;
import cn.wise.sc.energy.power.plant.business.bean.TimeModelQuery;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @description:
* @author: qh
* @create: 2020-08-18 16:53
**/
@Data
public class TendencyQuery implements Serializable {
List<String> keys;
TimeModelQuery timeModelQuery;
Integer status;
}
package cn.wise.sc.energy.power.plant.business.domain;
import cn.wise.sc.energy.power.plant.business.domain.eum.FunctionEnum;
import cn.wise.sc.energy.power.plant.business.domain.vo.EntityVo;
import cn.wise.sc.energy.power.plant.business.domain.vo.UnitInfoVo;
import lombok.Data;
import org.springframework.beans.BeanUtils;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Id;
import javax.persistence.Table;
/**
* @description: 检测方式信息
* @author: qh
* @create: 2020-07-14 09:42
**/
@Data
@Entity
@Table(name = "unitinfo")
public class UnitInfo extends AbstractEntity<String>{
@Override
public EntityVo toVo(){
UnitInfoVo unitInfoVo = new UnitInfoVo();
BeanUtils.copyProperties(this,unitInfoVo);
return unitInfoVo;
}
/**
* 监测单元唯一标识编码如:C0A0010101,该标识用于与监测特征(测点)配置信息表、运行时配置信息表的关联
*/
@Id
@Column(name = "unitcodeid")
private String unitCodeId;
/**
* 监测单元所在电站的标识
*/
@Column(name = "plantid")
private String plantId;
/**
* 监测单元所属设备的标识
*/
@Column(name = "deviceid")
private String deviceId;
/**
* 监测单元名称
*/
@Column(name = "unitname")
private String unitName;
/**
* 设备索引号(保留)
*/
@Column(name = "machineid")
private String machineId;
/**
* 监测单元索引号(保留)
*/
@Column(name = "unitid")
private String unitId;
/**
* 监测单元传输网络代码(保留
*/
@Column(name = "unitnetcode")
private String unitNetCode;
/**
* 监测单元指出的功能
* TrendAnalys|BinaryTreeAnalys|RadarMonitor
* TrendAnalys: 支持趋势分析
* VibrationAnalys: 支持波形频谱分析
* BinaryTreeAnalys: 支持二叉树分析诊断(作废)
* RadarMonitor: 支持雷达图监测(作废)
*/
private String function;
/**
* 监测单元静态参数描述
*/
@Column(name = "unitparam")
private String unitParam;
@Override
public String getId() {
return getUnitId();
}
}
package cn.wise.sc.energy.power.plant.business.domain;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
/**
* @description:
* @author: qh
* @create: 2020-08-10 22:27
**/
@Data
@Entity
@Table(name = "userinfo")
@NoArgsConstructor
public class UserInfo extends AbstractEntity<String> implements UserDetails {
@Id
private String id;
private String username;
private String password;
@Transient
private Collection<? extends GrantedAuthority> authorities;
@Transient
private boolean enabled;
@Transient
private boolean locked;
public UserInfo(
String id,
String username,
String password, List<String> authorities,
boolean enabled
) {
this.id = id;
this.username = username;
this.password = password;
this.authorities = mapToGrantedAuthorities(authorities);
this.enabled = enabled;
}
public UserInfo(
String id,
String username,
String password, String authoritie,
boolean enabled
) {
this.id = id;
this.username = username;
this.password = password;
this.authorities = mapToGrantedAuthorities(authoritie);
this.enabled = enabled;
}
private List<GrantedAuthority> mapToGrantedAuthorities(List<String> authorities) {
return authorities.stream()
.map(authority -> new SimpleGrantedAuthority(authority))
.collect(Collectors.toList());
}
private List<GrantedAuthority> mapToGrantedAuthorities(String authoritie) {
return Arrays.asList(new SimpleGrantedAuthority(authoritie));
}
@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
return authorities;
}
@Override
public boolean isAccountNonExpired() {
return true;
}
@Override
public boolean isAccountNonLocked() {
return locked;
}
@Override
public boolean isCredentialsNonExpired() {
return true;
}
@Override
public boolean isEnabled() {
return enabled;
}
}
\ No newline at end of file
package cn.wise.sc.energy.power.plant.business.domain;
import lombok.Data;
import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import java.io.Serializable;
/**
* @description:
* @author: qh
* @create: 2020-08-12 13:51
**/
@Data
@Valid
public class UserInfoQuery implements Serializable {
private static final long serialVersionUID = 1L;
private String id;
@NotEmpty(message = "username不能为空!")
private String username;
@NotEmpty(message = "password不能为空!")
private String password;
}
package cn.wise.sc.energy.power.plant.business.domain.eum;
import cn.wise.sc.energy.power.plant.common.core.exception.ResponseEnum;
import lombok.Getter;
/**
* @description: 监测单元指出的功能 类别
* @author: qh
* @create: 2020-07-14 15:11
**/
@Getter
public enum FunctionEnum {
/**
* 支持趋势分析
*/
TrendAnalys(1, "TrendAnalys"),
/**
* 支持波形频谱分析
*/
BinaryTreeAnalys(2, "BinaryTreeAnalys"),
/**
* 支持二叉树分析诊断(作废)
*/
@Deprecated
VibrationAnalys(3, "VibrationAnalys"),
/**
* 支持雷达图监测(作废)
*/
@Deprecated
RadarMonitor(3, "RadarMonitor");
private Integer code;
private String name;
FunctionEnum(int code, String name) {
this.code = code;
this.name = name;
}
/**
* 根据名字获取监测单元指出的功能枚举
*
* @param name 条件
* @return FunctionEnum
*/
public static FunctionEnum getFunctionEnumByName(String name) {
ResponseEnum.LICENCE_NOT_FOUND.assertNotEmpty(name);
FunctionEnum[] values = FunctionEnum.values();
FunctionEnum rts = null;
for (FunctionEnum itemNameEnum : values) {
if (itemNameEnum.getName().equals(name)) {
rts = itemNameEnum;
}
}
return rts;
}
/**
* 返回枚举名字
*
* @return getName()
*/
@Override
public String toString() {
return getName();
}
}
package cn.wise.sc.energy.power.plant.business.domain.eum;
import cn.wise.sc.energy.power.plant.common.core.exception.ResponseEnum;
import lombok.Getter;
/**
* @description: 运行时环境配置项目名字
* @author: qh
* @create: 2020-07-14 13:56
**/
@Getter
public enum ItemNameEnum {
/**
* 是否允许保存历史数据
* [1:是] [0:否]
*/
PermitSave(1, "PermitSave"),
/**
* 是否允许报警:
* [1:是] [0:否]
*/
PermitAlert(2, "PermitAlert"),
/**
* 是否保存报警前后数据:
* [1:是] [0:否]
*/
PermitAlertSave(3, "PermitAlertSave"),
/**
* 报警前录波时间(秒)
*/
PREVALERTTIIME(10, "PREVALERTTIIME"),
/**
* 报警后录波时间(秒)
*/
AFTERALERTTIIME(11, "AFTERALERTTIIME"),
/**
* 稳定数据样本存储时间间隔(s)
*/
STABLESAVETIME(12, "STABLESAVETIME"),
/**
* 用于稳定数据的平均时间(s)(报警数据统计时间)
*/
STABLEAVETIME(13, "STABLEAVETIME"),
/**
* 开机过程延迟时间(s)
*/
STARTUPDELAYTIME(14, "STARTUPDELAYTIME"),
/**
* 转速稳定判定时间(s)
*/
RPMCHECKTIME(15, "RPMCHECKTIME"),
/**
* 过渡过程(含开停机)在转速稳定时数据存储时间间隔(s)
*/
TRANSSAVETIME(16, "TRANSSAVETIME"),
/**
* 用于判定机组工况运行稳定的持续时间(s)
*/
STABLECHECKTIME(17, "STABLECHECKTIME");
private Integer code;
private String name;
ItemNameEnum(int code, String name) {
this.code = code;
this.name = name;
}
/**
* 根据名字获取运行时配置项名字
*
* @param name 条件
* @return ItemNameEnum
*/
public static ItemNameEnum getItemNameEnumByName(String name) {
ResponseEnum.LICENCE_NOT_FOUND.assertNotEmpty(name);
ItemNameEnum[] values = ItemNameEnum.values();
ItemNameEnum rts = null;
for (ItemNameEnum itemNameEnum : values) {
if (itemNameEnum.getName().equals(name)) {
rts = itemNameEnum;
}
}
return rts;
}
/**
* 返回枚举名字
*
* @return getName()
*/
@Override
public String toString() {
return getName();
}
}
package cn.wise.sc.energy.power.plant.business.domain.eum;
import cn.wise.sc.energy.power.plant.common.core.exception.ResponseEnum;
import lombok.Getter;
/**
* @description: 检测特征 信号类型
* @author: qh
* @create: 2020-07-14 15:18
**/
@Getter
public enum SignalTypeEnum {
/**
* 温度参数
*/
T(1, "T"),
/**
* 机械参数
*/
M(2, "M"),
/**
* 电气参数
*/
E(3, "E"),
/**
* 辅机参数
*/
A(4, "A")
;
private Integer code;
private String name;
SignalTypeEnum(int code, String name) {
this.code = code;
this.name = name;
}
/**
* 根据名字获取检测特征 信号类型
*
* @param name 条件
* @return SignalTypeEnum
*/
public static SignalTypeEnum getSignalTypeEnumByName(String name) {
ResponseEnum.LICENCE_NOT_FOUND.assertNotEmpty(name);
SignalTypeEnum[] values = SignalTypeEnum.values();
SignalTypeEnum rts = null;
for (SignalTypeEnum itemNameEnum : values) {
if (itemNameEnum.getName().equals(name)) {
rts = itemNameEnum;
}
}
return rts;
}
/**
* 返回枚举名字
*
* @return getName()
*/
@Override
public String toString() {
return getName();
}
}
package cn.wise.sc.energy.power.plant.business.domain.eum;
/**
* @description: 趋势图统计方式
* @author: qh
* @create: 2020-08-18 15:53
**/
public enum TendencyStatus {
YEAR(3, "7d-avg-zero"),
WEEK(1, "1M-avg-zero"),
MONTH(2, "1y-avg-zero");
private Integer code;
private String downSample;
TendencyStatus(Integer code, String downSample) {
this.code = code;
this.downSample = downSample;
}
public Integer getCode() {
return code;
}
public String getDownSample() {
return downSample;
}
public static String getDownSampleByCode(Integer code) {
TendencyStatus[] values = TendencyStatus.values();
for (TendencyStatus tendencyStatus : values) {
if (tendencyStatus.getCode().intValue() == code) {
return tendencyStatus.getDownSample();
}
}
return TendencyStatus.YEAR.getDownSample();
}
}
package cn.wise.sc.energy.power.plant.business.domain.vo;
import cn.wise.sc.energy.power.plant.business.domain.CharacterParamInfo;
import cn.wise.sc.energy.power.plant.business.domain.eum.FunctionEnum;
import cn.wise.sc.energy.power.plant.business.domain.eum.SignalTypeEnum;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.Column;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Id;
import java.util.List;
/**
* @description:特征值
* @author: qh
* @create: 2020-07-22 17:18
**/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CharacterParamInfoVo extends EntityVo{
/**
* 监测特征所属电站的标识
*/
private String plantId;
/**
* 监测特征所属设备的标识
*/
private String deviceId;
/**
* 监测特征所属监测单元标识
*/
private String unitCodeId;
/**
* 监测特征唯一标识编码(KKS编码)如:C0A00101CBA00MKF26S101
*/
private String kksCode;
/**
* 监测特征名称
*/
private String cpName;
/**
* todo 枚举
* 监测特征计算类型,很重要
*/
private Integer cpType;
/**
* 监测特征的物理单位,如 um/mm 等
*/
private String cpUnit;
/**
* 监测特征 信号类型:
* T: 温度参数 M: 机械参数
* E: 电气参数 A: 辅机参数
*/
private SignalTypeEnum signalType;
/**
* 特征参数是否属于派生的特征参数
* 1: 是 0: 不是
*/
private Integer isDeriveParam;
/**
* 如果 isderiveparam =1 时,该字段 指名本特征参数是从哪一个 特征参数 计算获得,
* derivefrom 指明该特征参数的KKScode
*/
private String derivedFrom;
/**
* 特征参数保护(一级报警)规则是否有效
* 1: 有效 0:无效(未设定)
*/
private Integer protectRuleValid;
/**
* 特征参数保护(一级报警)下限值
*/
private Float protectRuleMaxValue;
/**
* 特征参数保护(一级报警)上限值
*/
private Float protectRuleMinValue;
/**
* 特征参数保护(一级报警)规则阈值范围是否是排除范围
* 1: 是排除范围 0:是限定范围
*/
private Integer protectRuleExclude;
/**
* 特征参数报警(二级报警)规则是否有效
* 1: 有效 0:无效(未设定)
*/
private Integer alertRuleValid;
/**
* 特征参数警(二级报警)下限值
*/
private Float alertRuleMinValue;
/**
* 特征参数报警(二级报警)上限值
*/
private Float alertRuleMaxValue;
/**
* 特征参数报警(二级报警)规则阈值范围是否是排除范围
* 1: 是排除范围 0:是限定范围
*/
private Integer alertRuleExclude;
private Integer hasDeriveParam;
private List<CharacterParamInfoVo> child;
/**
* 图形
*/
private String function;
}
package cn.wise.sc.energy.power.plant.business.domain.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.Id;
import java.util.List;
/**
* @description: 设备信息Vo
* @author: qh
* @create: 2020-07-22 17:44
**/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class DeviceInfoVo extends EntityVo {
/**
* 设备所在电站的标识
*/
private String plantId;
/**
* 设备唯一标识编码如:C0A00101,该标识用于与设备配置信息其他表的关联
*/
private String deviceId;
/**
* 设备真是名称
*/
private String deviceName;
/**
* 设备分类, 发电机、汽轮机、水轮机等
*/
private String deviceType;
/**
* 设备制造厂
*/
private String manufacture;
/**
* 设备编码
*/
private String deviceCode;
private String deviceParam;
private List<UnitInfoVo> unitInfoVos;
}
package cn.wise.sc.energy.power.plant.business.domain.vo;
import java.io.Serializable;
/**
* @description:
* @author: qh
* @create: 2020-07-22 14:37
**/
public class EntityVo implements Serializable {
}
package cn.wise.sc.energy.power.plant.business.domain.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.Id;
/**
* @description:
* @author: qh
* @create: 2020-07-22 16:42
**/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class PlantInfoVo extends EntityVo{
/**
* 电站唯一标识
*/
private String plantId;
/**
* 电站真真实名称
*/
private String plantName;
/**
* 电站所在国家
*/
private String country;
/**
* 电站所在省份
*/
private String province;
/**
* 电站所在纬度
*/
private String latitude;
/**
* 电站所在经度
*/
private String longitude;
private String plantCode;
}
package cn.wise.sc.energy.power.plant.business.domain.vo;
/**
* @description: 电厂所有信息
* @author: qh
* @create: 2020-07-25 10:37
**/
public class PlantTotalInfoVo {
/**
* 机组
*/
public class Group {
}
/**
* 部件
*/
public class Device {
}
/**
* 测点
*/
public class Unit {
}
}
package cn.wise.sc.energy.power.plant.business.domain.vo;
import lombok.Data;
import java.util.List;
/**
* @description:
* @author: qh
* @create: 2020-07-22 20:19
**/
@Data
public class UnitInfoVo extends EntityVo {
private String unitCodeId;
/**
* 监测单元所在电站的标识
*/
private String plantId;
/**
* 监测单元所属设备的标识
*/
private String deviceId;
/**
* 监测单元名称
*/
private String unitName;
/**
* 设备索引号(保留)
*/
private String machineId;
/**
* 监测单元索引号(保留)
*/
private String unitId;
/**
* 监测单元传输网络代码(保留
*/
private String unitNetCode;
/**
* 监测单元指出的功能
* TrendAnalys|BinaryTreeAnalys|RadarMonitor
* TrendAnalys: 支持趋势分析
* VibrationAnalys: 支持波形频谱分析
* BinaryTreeAnalys: 支持二叉树分析诊断(作废)
* RadarMonitor: 支持雷达图监测(作废)
*/
private String function;
/**
* 监测单元静态参数描述
*/
private String unitParam;
private List<CharacterParamInfoVo> characters;
}
package cn.wise.sc.energy.power.plant.business.opentsdb;
import net.opentsdb.client.OpenTSDBClient;
import net.opentsdb.client.OpenTSDBConfig;
import net.opentsdb.client.bean.Query;
import net.opentsdb.client.bean.QueryResult;
import org.apache.http.HttpException;
import org.apache.http.nio.reactor.IOReactorException;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.function.Consumer;
/**
* opentsdb工具类
* @author neo.shu
* @since 2020/4/28 15:41
*//*
public class OpentsdbHttpClient {
public static OpenTSDBConfig config = OpenTSDBConfig.address("http://192.168.110.75", 4342)
.httpConnectionPool(100)
.httpConnectTimeout(100)
.batchPutBufferSize(20000)
.batchPutSize(50)
.batchPutTimeLimit(300)
.config();
*/
/**
* 使用查询Query,同步查询
*
* @param query
* @return
*//*
public static List<QueryResult> query(Query query) {
OpenTSDBClient client = null;
try {
client = OpenTSDBClientFactory.connect(config);
return client.query(query);
} catch (IOReactorException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
client.gracefulClose();
} catch (IOException e) {
e.printStackTrace();
}
}
return null;
}
*/
/**
* 使用查询参数,异步调用
*
* @param query
* @param consumer
*//*
public static void queryAsyn(Query query, Consumer<List<QueryResult>> consumer) {
OpenTSDBClient client = null;
try {
client.query(query, new QueryHttpResponseCallback.QueryCallback() {
@Override
public void response(Query query, List<QueryResult> queryResults) {
// 在请求完成并且response code成功时回调
consumer.accept(queryResults);
}
@Override
public void responseError(Query query, HttpException e) {
// 在response code失败时回调
}
@Override
public void failed(Query query, Exception e) {
// 在发生错误是回调
}
});
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
client.gracefulClose();
} catch (IOException e) {
e.printStackTrace();
}
}
}
*/
/**
* 写入数据
*
* @param point
* @return
*//*
public static boolean put(Point point) {
OpenTSDBClient client = null;
try {
client = OpenTSDBClientFactory.connect(config);
client.put(point);
return true;
} catch (IOReactorException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
client.gracefulClose();
} catch (IOException e) {
e.printStackTrace();
}
}
return false;
}
*/
/**
* 查询最新数据
* @param query
* @return
*//*
public static List<LastPointQueryResult> queryLast(LastPointQuery query) {
OpenTSDBClient client = null;
try {
client = OpenTSDBClientFactory.connect(config);
return client.queryLast(query);
} catch (IOReactorException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
} finally {
try {
client.gracefulClose();
} catch (IOException e) {
e.printStackTrace();
}
}
return null;
}
*/
/**
* 查询基本信息
* @param query
* @return
*//*
public static List<String> querySuggest(SuggestQuery query) {
OpenTSDBClient client = null;
try {
client = OpenTSDBClientFactory.connect(config);
return client.querySuggest(query);
} catch (IOReactorException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
} finally {
try {
client.gracefulClose();
} catch (IOException e) {
e.printStackTrace();
}
}
return null;
}
}
*/
package cn.wise.sc.energy.power.plant.business.opentsdb.bean;
import lombok.Data;
/**
* @author neo.shu
* @since 2020/5/19 19:08
*/
@Data
public class KafkaConsumeBean {
private short DataType;
private short SignalType;
private short PartType;
private long StartTime;
private short TimeSpan;
private KafkaRecordBean Record;
}
package cn.wise.sc.energy.power.plant.business.opentsdb.bean;
import lombok.Data;
/**
* @author neo.shu
* @since 2020/5/19 19:12
*/
@Data
public class KafkaDataBean {
private String KKSCode;
private double Data;
}
package cn.wise.sc.energy.power.plant.business.opentsdb.bean;
import lombok.Data;
import java.util.List;
/**
* @author neo.shu
* @since 2020/5/20 09:48
*/
@Data
public class KafkaJsonBean {
private List<KafkaConsumeBean> Record;
}
package cn.wise.sc.energy.power.plant.business.opentsdb.bean;
import lombok.Data;
import java.util.List;
/**
* @author neo.shu
* @since 2020/5/19 19:08
*/
@Data
public class KafkaRecordBean {
List<KafkaDataBean> Data;
}
package cn.wise.sc.energy.power.plant.business.opentsdb.bean;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import net.opentsdb.client.bean.BaseBean;
import java.util.HashMap;
import java.util.Map;
/**
* @description:
* @author: qh
* @create: 2020-05-06 15:51
**/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class PutExt extends BaseBean {
private String metric;
private Long timestamp;
private Number value;
private Map<String, String> tags;
public PutExt putTag(String key, String value) {
if (getTags() == null) {
setTags(new HashMap<>());
}
getTags().putIfAbsent(key, value);
return this;
}
}
package cn.wise.sc.energy.power.plant.business.opentsdb.bean;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import net.opentsdb.client.api.BaseRequest;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
/**
* @description:
* @author: qh
* @create: 2020-05-06 15:52
**/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class PutRequestExt extends BaseRequest {
private Boolean summary = false;
private Boolean details = false;
private Boolean sync = false;
private Long syncTimeout = 0L;
private List<PutExt> dataPoints;
public PutRequestExt addDataPoints(PutExt query) {
if (getDataPoints() == null) {
setDataPoints(new ArrayList<>());
}
getDataPoints().add(query);
return this;
}
public Map<String, String> getParameters() {
Map<String, String> parameters = new LinkedHashMap();
if (this.summary != null && this.summary) {
parameters.put("summary", "");
}
if (this.details != null && this.details) {
parameters.put("details", "");
}
if (this.sync != null && this.sync) {
parameters.put("sync", "");
}
if (this.sync != null && this.sync && this.syncTimeout != null && this.syncTimeout > 0L) {
parameters.put("sync_timeout", this.syncTimeout.toString());
}
return parameters;
}
}
package cn.wise.sc.energy.power.plant.business.opentsdb.bean;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import net.opentsdb.client.bean.Aggregator;
import net.opentsdb.client.bean.BaseBean;
import net.opentsdb.client.bean.Filter;
import net.opentsdb.client.bean.RateOptions;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author neo.shu
* @since 2020/4/28 19:35
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class QueryExt extends BaseBean {
private Aggregator aggregator;
private String metric;
private Boolean rate;
private RateOptions rateOptions;
private String downsample;
private Map<String, String> tags;
private List<Filter> filters;
private Boolean explicitTags;
private List<Float> percentiles;
private String rollupUsage;
public QueryExt addFilter(Filter filter) {
if (getFilters() == null) {
setFilters(new ArrayList<>());
}
getFilters().add(filter);
return this;
}
public QueryExt putTag(String key, String value) {
if (getTags() == null) {
setTags(new HashMap<>());
}
getTags().putIfAbsent(key, value);
return this;
}
}
package cn.wise.sc.energy.power.plant.business.opentsdb.bean;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import net.opentsdb.client.api.BaseRequest;
import java.util.ArrayList;
import java.util.List;
/**
* 查询请求类,用于实现queries的链式封装m
* @author neo.shu
* @since 2020/4/28 19:04
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class QueryRequestExt extends BaseRequest {
private String start;
private String end;
private List<QueryExt> queries=new ArrayList<>();
private Boolean noAnnotations;
private Boolean globalAnnotations;
private Boolean msResolution;
private Boolean showTSUIDs;
private Boolean showStats;
private Boolean showQuery;
private String timezone;
private Boolean useCalendar;
public QueryRequestExt addQuery(QueryExt query){
if (getQueries() == null) {
setQueries(new ArrayList<>());
}
getQueries().add(query);
return this;
}
}
package cn.wise.sc.energy.power.plant.business.opentsdb.test;
/**
* @description:
* @author: qh
* @create: 2020-05-13 10:51
**/
public class AsyncToolTest {
public static void main(String[] args) {
// ResponseEnum.LICENCE_NOT_FOUND.assertNotNull(null);
Object object = "11111";
System.out.println((int)object == 0);
}
}
package cn.wise.sc.energy.power.plant.business.repository;
import cn.wise.sc.energy.power.plant.business.domain.CharacterParamInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;
/**
* @description: 测点特征仓储
* @author: qh
* @create: 2020-07-14 16:24
**/
@Repository
public interface CharacterParamRepository extends
JpaRepository<CharacterParamInfo, String>,
JpaSpecificationExecutor<CharacterParamInfo> {
}
package cn.wise.sc.energy.power.plant.business.repository;
import cn.wise.sc.energy.power.plant.business.domain.DeviceInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;
/**
* @description: 设备仓储
* @author: qh
* @create: 2020-07-14 16:19
**/
@Repository
public interface DeviceInfoRepository extends
JpaRepository<DeviceInfo, String> ,
JpaSpecificationExecutor<DeviceInfo> {
}
package cn.wise.sc.energy.power.plant.business.repository;
import cn.wise.sc.energy.power.plant.business.domain.PlantInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;
/**
* @description: 电厂仓储
* @author: qh
* @create: 2020-07-14 16:21
**/
@Repository
public interface PlantInfoRepository extends
JpaRepository<PlantInfo,String> ,
JpaSpecificationExecutor<PlantInfo> {
}
package cn.wise.sc.energy.power.plant.business.security;
public interface SecurityConstants {
String AUTHORIZATION_HEADER = "Authorization";
String TOKEN_PREFIX = "Bearer ";
String AUTH_COOKIE = "plant-auth";
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment