Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
plant
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
qinhu
plant
Commits
773e4177
Commit
773e4177
authored
Aug 24, 2020
by
qinhu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
波形图
parent
4bb77a2e
Hide whitespace changes
Inline
Side-by-side
Showing
37 changed files
with
589 additions
and
666 deletions
+589
-666
pom.xml
power-bussiness/pom.xml
+13
-0
power-bussiness.iml
power-bussiness/power-bussiness.iml
+11
-23
PowerPlantApplication.java
...sc/energy/power/plant/business/PowerPlantApplication.java
+1
-4
SwaggerConfig.java
...cn/wise/sc/energy/power/plant/business/SwaggerConfig.java
+66
-66
BasicOption.java
...wise/sc/energy/power/plant/business/bean/BasicOption.java
+0
-45
Characters.java
.../wise/sc/energy/power/plant/business/bean/Characters.java
+0
-49
DataPower.java
...n/wise/sc/energy/power/plant/business/bean/DataPower.java
+4
-0
Devices.java
.../cn/wise/sc/energy/power/plant/business/bean/Devices.java
+0
-44
TurbineOption.java
...se/sc/energy/power/plant/business/bean/TurbineOption.java
+0
-18
Units.java
...va/cn/wise/sc/energy/power/plant/business/bean/Units.java
+0
-72
CharacterParamController.java
...r/plant/business/controller/CharacterParamController.java
+41
-11
DeviceInfoController.java
...power/plant/business/controller/DeviceInfoController.java
+2
-4
PlantInfoController.java
.../power/plant/business/controller/PlantInfoController.java
+43
-11
RuntimeOptionController.java
...er/plant/business/controller/RuntimeOptionController.java
+3
-11
UnitInfoController.java
...y/power/plant/business/controller/UnitInfoController.java
+2
-3
UserInfoController.java
...y/power/plant/business/controller/UserInfoController.java
+4
-4
AbstractEntity.java
...sc/energy/power/plant/business/domain/AbstractEntity.java
+1
-0
DetecInteractionQuery.java
...gy/power/plant/business/domain/DetecInteractionQuery.java
+29
-0
DetectionItem.java
.../sc/energy/power/plant/business/domain/DetectionItem.java
+56
-0
Oscillogram.java
...se/sc/energy/power/plant/business/domain/Oscillogram.java
+19
-25
OscillogramRowMapper.java
...rgy/power/plant/business/domain/OscillogramRowMapper.java
+91
-6
UserInfo.java
.../wise/sc/energy/power/plant/business/domain/UserInfo.java
+5
-2
JWTAuthenticationFilter.java
...ower/plant/business/security/JWTAuthenticationFilter.java
+6
-5
JwtUserDetailsService.java
.../power/plant/business/security/JwtUserDetailsService.java
+42
-45
SecurityConfig.java
.../energy/power/plant/business/security/SecurityConfig.java
+26
-26
ICharacterParamService.java
.../power/plant/business/service/ICharacterParamService.java
+8
-1
IDetectionService.java
...nergy/power/plant/business/service/IDetectionService.java
+14
-0
IPlantInfoService.java
...nergy/power/plant/business/service/IPlantInfoService.java
+1
-1
CharacterParamServiceImpl.java
...lant/business/service/impl/CharacterParamServiceImpl.java
+26
-10
DetectionServiceImpl.java
...wer/plant/business/service/impl/DetectionServiceImpl.java
+38
-6
PlantInfoServiceImpl.java
...wer/plant/business/service/impl/PlantInfoServiceImpl.java
+4
-4
UserInfoServiceImpl.java
...ower/plant/business/service/impl/UserInfoServiceImpl.java
+18
-6
ScheduledModel.java
...e/sc/energy/power/plant/business/task/ScheduledModel.java
+2
-6
WebSocketServer2.java
...sc/energy/power/plant/business/task/WebSocketServer2.java
+0
-129
OkHttpClientUtil.java
...c/energy/power/plant/business/utils/OkHttpClientUtil.java
+0
-2
common-core.iml
power-common/common-core/common-core.iml
+2
-16
pom.xml
power-common/common-core/pom.xml
+11
-11
No files found.
power-bussiness/pom.xml
View file @
773e4177
...
...
@@ -126,7 +126,20 @@
<groupId>
com.spring4all
</groupId>
<artifactId>
spring-boot-starter-hbase
</artifactId>
<version>
1.0.0.RELEASE
</version>
<exclusions>
<exclusion>
<groupId>
com.google.guava
</groupId>
<artifactId>
guava
</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
<dependency>
<groupId>
com.google.guava
</groupId>
<artifactId>
guava
</artifactId>
<version>
16.0.1
</version>
</dependency>
</dependencies>
<build>
<plugins>
...
...
power-bussiness/power-bussiness.iml
View file @
773e4177
<?xml version="1.0" encoding="UTF-8"?>
<module
org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule=
"true"
type=
"JAVA_MODULE"
version=
"4"
>
<component
name=
"FacetManager"
>
<facet
type=
"jpa"
name=
"JPA"
>
<configuration>
<setting
name=
"validation-enabled"
value=
"true"
/>
<setting
name=
"provider-name"
value=
"Hibernate"
/>
<datasource-mapping>
<factory-entry
name=
"entityManagerFactory"
/>
</datasource-mapping>
<naming-strategy-map
/>
</configuration>
</facet>
<facet
type=
"Spring"
name=
"Spring"
>
<configuration
/>
</facet>
...
...
@@ -13,16 +23,6 @@
</sourceRoots>
</configuration>
</facet>
<facet
type=
"jpa"
name=
"JPA"
>
<configuration>
<setting
name=
"validation-enabled"
value=
"true"
/>
<setting
name=
"provider-name"
value=
"Hibernate"
/>
<datasource-mapping>
<factory-entry
name=
"entityManagerFactory"
/>
</datasource-mapping>
<naming-strategy-map
/>
</configuration>
</facet>
</component>
<component
name=
"NewModuleRootManager"
LANGUAGE_LEVEL=
"JDK_1_8"
>
<output
url=
"file://$MODULE_DIR$/target/classes"
/>
...
...
@@ -88,19 +88,6 @@
<orderEntry
type=
"library"
name=
"Maven: org.apache.tomcat.embed:tomcat-embed-el:9.0.33"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.hibernate.validator:hibernate-validator:6.0.18.Final"
level=
"project"
/>
<orderEntry
type=
"module"
module-name=
"common-core"
/>
<orderEntry
type=
"library"
name=
"Maven: io.springfox:springfox-swagger2:2.9.2"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: io.swagger:swagger-annotations:1.5.20"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: io.swagger:swagger-models:1.5.20"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: io.springfox:springfox-spi:2.9.2"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: io.springfox:springfox-core:2.9.2"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: io.springfox:springfox-schema:2.9.2"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: io.springfox:springfox-swagger-common:2.9.2"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: io.springfox:springfox-spring-web:2.9.2"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: com.google.guava:guava:20.0"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.plugin:spring-plugin-core:1.2.0.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.plugin:spring-plugin-metadata:1.2.0.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.mapstruct:mapstruct:1.2.0.Final"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: io.springfox:springfox-swagger-ui:2.9.2"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework:spring-context:5.2.5.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework:spring-expression:5.2.5.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.boot:spring-boot-starter-web:2.2.6.RELEASE"
level=
"project"
/>
...
...
@@ -273,5 +260,6 @@
<orderEntry
type=
"library"
name=
"Maven: org.apache.directory.api:api-util:1.0.0-M20"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.apache.curator:curator-framework:2.7.1"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: com.github.stephenc.findbugs:findbugs-annotations:1.3.9-1"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: com.google.guava:guava:16.0.1"
level=
"project"
/>
</component>
</module>
\ No newline at end of file
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/PowerPlantApplication.java
View file @
773e4177
...
...
@@ -2,14 +2,11 @@ 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
//
@EnableSwagger2
@EnableScheduling
@SpringBootApplication
@ImportAutoConfiguration
(
SecurityConfig
.
class
)
...
...
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/SwaggerConfig.java
View file @
773e4177
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;
//
//
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);
//
}
//
//
//
}
//
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/bean/BasicOption.java
deleted
100644 → 0
View file @
4bb77a2e
//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;
// }
//
//}
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/bean/Characters.java
deleted
100644 → 0
View file @
4bb77a2e
//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;
// }
//}
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/bean/DataPower.java
View file @
773e4177
...
...
@@ -33,6 +33,10 @@ public class DataPower {
* 测点名
*/
private
String
name
;
/**
* 颜色
*/
private
String
color
;
/**
* Y轴值集合
*/
...
...
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/bean/Devices.java
deleted
100644 → 0
View file @
4bb77a2e
//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;
// }
//}
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/bean/TurbineOption.java
deleted
100644 → 0
View file @
4bb77a2e
//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;
//}
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/bean/Units.java
deleted
100644 → 0
View file @
4bb77a2e
//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;
// }
//
//}
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/controller/CharacterParamController.java
View file @
773e4177
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
controller
;
import
cn.wise.sc.energy.power.plant.business.bean.DataPower
;
import
cn.wise.sc.energy.power.plant.business.domain.CharacterParamInfo
;
import
cn.wise.sc.energy.power.plant.business.domain.Oscillogram
;
import
cn.wise.sc.energy.power.plant.business.domain.OscillogramRowMapper
;
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.service.ICharacterParamService
;
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
com.alibaba.fastjson.JSON
;
import
com.spring4all.spring.boot.starter.hbase.api.HbaseTemplate
;
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
;
...
...
@@ -18,6 +21,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.validation.constraints.NotEmpty
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -30,15 +34,19 @@ import java.util.Map;
@CrossOrigin
@Validated
@RestController
@Api
(
tags
=
"测点特征"
)
@RequestMapping
(
"
C
haracterParam/"
)
//
@Api(tags = "测点特征")
@RequestMapping
(
"
c
haracterParam/"
)
public
class
CharacterParamController
{
final
ICharacterParamService
iCharacterParamService
;
final
HbaseTemplate
hbaseTemplate
;
public
CharacterParamController
(
ICharacterParamService
iCharacterParamService
)
{
public
CharacterParamController
(
ICharacterParamService
iCharacterParamService
,
HbaseTemplate
hbaseTemplate
)
{
this
.
iCharacterParamService
=
iCharacterParamService
;
this
.
hbaseTemplate
=
hbaseTemplate
;
}
@GetMapping
(
"{unitNo}"
)
...
...
@@ -48,18 +56,40 @@ public class CharacterParamController {
}
@GetMapping
(
"/3d"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"deviceId"
,
value
=
"机组id"
),
@ApiImplicitParam
(
name
=
"fileName"
,
value
=
"文件名 '温度,压力,湿度'"
)
})
//
@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
)
{
public
BaseResponse
<
DataPower
>
getTendency
(
@RequestBody
TendencyQuery
tendencyQuery
)
{
return
iCharacterParamService
.
getTendency
(
tendencyQuery
.
getKeys
(),
tendencyQuery
.
getTimeModelQuery
(),
tendencyQuery
.
getStatus
());
}
@PostMapping
(
"/test"
)
public
BaseResponse
<
List
<
Oscillogram
>>
test
(
@RequestBody
List
<
String
>
kksCodes
)
{
List
<
Oscillogram
>
oscillograms
=
hbaseTemplate
.
find
(
"thermalpower-plant-wave-data"
,
"records"
,
new
OscillogramRowMapper
());
System
.
out
.
println
(
JSON
.
toJSONString
(
oscillograms
));
List
<
CharacterParamInfo
>
characterParamInfos
=
iCharacterParamService
.
getByKksCodes
(
kksCodes
);
List
<
Oscillogram
>
rts
=
new
ArrayList
<>(
oscillograms
.
size
());
for
(
Oscillogram
oscillogram
:
oscillograms
)
{
characterParamInfos
.
forEach
(
arg
->
{
if
(
oscillogram
.
getKKsCode
().
equals
(
arg
.
getKksCode
()))
{
oscillogram
.
setKKsCode
(
arg
.
getCpName
());
rts
.
add
(
oscillogram
);
}
});
}
return
BaseResponse
.
okData
(
rts
);
}
}
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/controller/DeviceInfoController.java
View file @
773e4177
...
...
@@ -4,13 +4,11 @@ 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.service.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
;
...
...
@@ -21,8 +19,8 @@ import java.util.List;
**/
@CrossOrigin
@RestController
@Api
(
tags
=
"设备信息"
)
@RequestMapping
(
"
D
eviceInfo/"
)
//
@Api(tags = "设备信息")
@RequestMapping
(
"
d
eviceInfo/"
)
public
class
DeviceInfoController
{
final
...
...
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/controller/PlantInfoController.java
View file @
773e4177
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
controller
;
import
cn.wise.sc.energy.power.plant.business.bean.DataPower
;
import
cn.wise.sc.energy.power.plant.business.domain.DetecInteractionQuery
;
import
cn.wise.sc.energy.power.plant.business.domain.vo.EntityVo
;
import
cn.wise.sc.energy.power.plant.business.service.IDetectionService
;
import
cn.wise.sc.energy.power.plant.business.service.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.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.List
;
import
java.util.UUID
;
/**
* @description: 电厂信息controller
...
...
@@ -22,15 +25,19 @@ import java.util.List;
**/
@CrossOrigin
@RestController
@Api
(
tags
=
"电厂信息"
)
@RequestMapping
(
"
P
lantInfo/"
)
//
@Api(tags = "电厂信息")
@RequestMapping
(
"
p
lantInfo/"
)
public
class
PlantInfoController
{
final
IPlantInfoService
iPlantInfoService
;
final
IDetectionService
iDetectionService
;
public
PlantInfoController
(
IPlantInfoService
iPlantInfoService
)
{
public
PlantInfoController
(
IPlantInfoService
iPlantInfoService
,
IDetectionService
iDetectionService
)
{
this
.
iPlantInfoService
=
iPlantInfoService
;
this
.
iDetectionService
=
iDetectionService
;
}
@GetMapping
(
"allPlantInfo"
)
...
...
@@ -40,10 +47,35 @@ public class PlantInfoController {
}
@GetMapping
(
"power/{plantId}"
)
@ApiOperation
(
"获取总功率"
)
@ApiImplicitParam
(
name
=
"plantId"
,
value
=
"电厂id"
,
paramType
=
"query"
)
public
BaseResponse
<
Integer
>
getTotalPower
(
@PathVariable
(
"plantId"
)
@NotEmpty
(
message
=
"电厂id不能为空!"
)
String
plantId
)
{
public
BaseResponse
<
Double
>
getTotalPower
(
@PathVariable
(
"plantId"
)
@NotEmpty
(
message
=
"电厂id不能为空!"
)
String
plantId
)
{
return
iPlantInfoService
.
getTotalPower
(
plantId
);
}
}
@GetMapping
(
"detection"
)
public
BaseResponse
<
String
>
startDetection
()
{
String
sessionId
=
UUID
.
randomUUID
().
toString
();
Boolean
aBoolean
=
iDetectionService
.
startDetection
(
sessionId
);
if
(
aBoolean
)
{
return
BaseResponse
.
okData
(
sessionId
);
}
else
{
return
BaseResponse
.
errorMsg
(
"启动失败!"
);
}
}
@PostMapping
(
"interaction"
)
public
BaseResponse
<
Boolean
>
detectionInteractionSelect
(
@RequestBody
DetecInteractionQuery
query
)
{
Boolean
aBoolean
=
iDetectionService
.
interactionChose
(
query
.
getId
(),
query
.
getQid
(),
query
.
getSelect
());
if
(
aBoolean
)
{
return
BaseResponse
.
okData
(
true
);
}
else
{
return
BaseResponse
.
errorMsg
(
"请求失败!"
);
}
}
// @GetMapping("/initPower")
// public BaseResponse<List<DataPower>> getInitPower(String plantId, String deviceId) {
//
//
// }
//}
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/controller/RuntimeOptionController.java
View file @
773e4177
...
...
@@ -2,8 +2,8 @@ package cn.wise.sc.energy.power.plant.business.controller;
import
cn.wise.sc.energy.power.plant.business.domain.Oscillogram
;
import
cn.wise.sc.energy.power.plant.business.domain.OscillogramRowMapper
;
import
cn.wise.sc.energy.power.plant.common.core.bean.BaseResponse
;
import
com.spring4all.spring.boot.starter.hbase.api.HbaseTemplate
;
import
io.swagger.annotations.Api
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.CrossOrigin
;
import
org.springframework.web.bind.annotation.GetMapping
;
...
...
@@ -19,20 +19,12 @@ import java.util.List;
**/
@CrossOrigin
@RestController
@Api
(
tags
=
"系统运行时选项配置"
)
@RequestMapping
(
"
R
untimeOption/"
)
//
@Api(tags = "系统运行时选项配置")
@RequestMapping
(
"
r
untimeOption/"
)
public
class
RuntimeOptionController
{
@Autowired
HbaseTemplate
hbaseTemplate
;
@GetMapping
(
"/test"
)
public
void
test
(){
List
<
Oscillogram
>
objects
=
hbaseTemplate
.
find
(
"thermalpower-plant-wave-data"
,
"3c0a00102mka62ce610r1596100323000"
,
new
OscillogramRowMapper
());
}
}
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/controller/UnitInfoController.java
View file @
773e4177
...
...
@@ -3,7 +3,6 @@ package cn.wise.sc.energy.power.plant.business.controller;
import
cn.wise.sc.energy.power.plant.business.domain.vo.EntityVo
;
import
cn.wise.sc.energy.power.plant.business.service.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
;
...
...
@@ -19,8 +18,8 @@ import java.util.List;
**/
@CrossOrigin
@RestController
@Api
(
tags
=
"部件选项"
)
@RequestMapping
(
"
U
nitInfo/"
)
//
@Api(tags = "部件选项")
@RequestMapping
(
"
u
nitInfo/"
)
public
class
UnitInfoController
{
final
...
...
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/controller/UserInfoController.java
View file @
773e4177
...
...
@@ -5,13 +5,13 @@ 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.service.IUserInfoService
;
import
cn.wise.sc.energy.power.plant.common.core.bean.BaseResponse
;
import
io.swagger.annotations.Api
;
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.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
...
...
@@ -23,7 +23,7 @@ import org.springframework.web.bind.annotation.RestController;
@Validated
@CrossOrigin
@RestController
@Api
(
tags
=
"用户管理"
)
//
@Api(tags = "用户管理")
@RequestMapping
(
"userInfo/"
)
public
class
UserInfoController
{
...
...
@@ -40,12 +40,12 @@ public class UserInfoController {
}
@PostMapping
(
"/new"
)
public
BaseResponse
<
Boolean
>
add
(
UserInfoQuery
userInfo
)
{
public
BaseResponse
<
Boolean
>
add
(
@RequestBody
UserInfoQuery
userInfo
)
{
return
iUserInfoService
.
addUserInfo
(
userInfo
);
}
@PutMapping
(
"/edit"
)
public
BaseResponse
<
Boolean
>
edit
(
UserInfoQuery
userInfo
)
{
public
BaseResponse
<
Boolean
>
edit
(
@RequestBody
UserInfoQuery
userInfo
)
{
return
iUserInfoService
.
edit
(
userInfo
);
}
...
...
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/domain/AbstractEntity.java
View file @
773e4177
...
...
@@ -34,6 +34,7 @@ public abstract class AbstractEntity<ID> implements Persistable<ID> {
/**
* toVo方法 需要子类实现
*
* @return
*/
public
EntityVo
toVo
()
{
...
...
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/domain/DetecInteractionQuery.java
0 → 100644
View file @
773e4177
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
domain
;
import
lombok.Data
;
import
java.util.List
;
/**
* @description: 检测项交互选择项
* @author: qh
* @create: 2020-08-21 11:54
**/
@Data
public
class
DetecInteractionQuery
{
/**
* 会话id
*/
private
String
id
;
/**
* 问题id
*/
private
String
qid
;
/**
* 选项下标
*/
private
List
<
Integer
>
select
;
}
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/domain/DetectionItem.java
View file @
773e4177
...
...
@@ -3,6 +3,8 @@ package cn.wise.sc.energy.power.plant.business.domain;
import
com.alibaba.fastjson.annotation.JSONField
;
import
lombok.Data
;
import
java.util.List
;
/**
* @description: 一键巡检检测项
* @author: qh
...
...
@@ -62,4 +64,58 @@ public class DetectionItem {
*/
private
String
overweight
;
/**
* 交互内容
*/
private
Interaction
interaction
;
@Data
public
static
class
Interaction
{
/**
* 会话id
*/
private
String
id
;
/**
* 问题id
*/
private
String
qid
;
/**
* 问题描述
*/
private
String
name
;
/**
* 图表数据
*/
private
String
data
;
/**
* 选项内容
*/
private
String
select
;
}
/**
* 交互结果对象
*/
@Data
public
static
class
InteractionResult
{
/**
* 会话id
*/
private
String
id
;
/**
* 问题id
*/
private
String
qid
;
/**
* 选项下标
*/
private
List
<
Integer
>
select
;
}
}
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/domain/Oscillogram.java
View file @
773e4177
...
...
@@ -3,6 +3,7 @@ package cn.wise.sc.energy.power.plant.business.domain;
import
lombok.Data
;
import
java.util.List
;
import
java.util.Map
;
/**
* @description: 波形图
...
...
@@ -12,39 +13,32 @@ import java.util.List;
@Data
public
class
Oscillogram
{
/**
*
功率谱数据
*
kkscode
*/
private
List
<
Data
>
power
;
private
String
kKsCode
;
/**
*
阶次比数据
*
开始时间
*/
private
L
ist
<
Data
>
orderRatio
;
private
L
ong
start
;
/**
*
相位谱
数据
* 数据
*/
private
List
<
Data
>
phaseSpectrum
;
private
String
mapData
;
public
static
class
Data
{
/**
* 测点对应KKS编码
*/
private
String
kKSCode
;
/**
* 幅值(Y轴坐标值)
*/
private
List
<
Double
>
data
;
/**
* 偏移量
*/
private
String
mapKeyPhaseOffset
;
/**
* 频率(X轴坐标值)
*/
private
List
<
Double
>
index
;
}
/**
* 特征信息
*/
private
String
noVersionData
;
/**
* 特征偏移
*/
private
String
noVersionKeyPhaseOffset
;
}
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/domain/OscillogramRowMapper.java
View file @
773e4177
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
domain
;
import
com.alibaba.fastjson.JSON
;
import
cn.hutool.core.codec.Base64Decoder
;
import
cn.hutool.core.codec.Base64Encoder
;
import
cn.hutool.core.util.StrUtil
;
import
com.spring4all.spring.boot.starter.hbase.api.RowMapper
;
import
org.apache.hadoop.hbase.client.Result
;
import
java.util.NavigableMap
;
/**
* @description:
* @author: qh
* @create: 2020-08-20 15:25
**/
public
class
OscillogramRowMapper
implements
RowMapper
<
Oscillogram
>
{
public
class
OscillogramRowMapper
implements
RowMapper
<
Oscillogram
>
{
private
static
byte
[]
RECORDS
=
"records"
.
getBytes
();
private
static
byte
[]
MAP
=
"map"
.
getBytes
();
private
static
byte
[]
DATA
=
"Data"
.
getBytes
();
private
static
byte
[]
OFFSET
=
"KeyPhaseOffset"
.
getBytes
();
@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
;
Oscillogram
oscillogram
=
new
Oscillogram
();
//解密当前kkscode
oscillogram
.
setKKsCode
(
getKKsCode
(
result
.
getRow
()));
//获取特征信息
NavigableMap
<
byte
[],
NavigableMap
<
byte
[],
byte
[]>>
noVersionMap
=
result
.
getNoVersionMap
();
NavigableMap
<
byte
[],
byte
[]>
navigableMap1
=
noVersionMap
.
get
(
RECORDS
);
//获取特征数据
byte
[]
noVersionDataByte
=
navigableMap1
.
get
(
DATA
);
String
noVersionData
=
Base64Decoder
.
decodeStr
(
Base64Encoder
.
encode
(
noVersionDataByte
));
oscillogram
.
setNoVersionData
(
noVersionData
);
byte
[]
noVersionOffSetByte
=
navigableMap1
.
get
(
OFFSET
);
oscillogram
.
setNoVersionData
(
Base64Decoder
.
decodeStr
(
Base64Encoder
.
encode
(
noVersionOffSetByte
)));
//=============================================================================
//获取值信息
NavigableMap
<
byte
[],
NavigableMap
<
byte
[],
NavigableMap
<
Long
,
byte
[]>>>
dataMap
=
result
.
getMap
();
NavigableMap
<
byte
[],
NavigableMap
<
Long
,
byte
[]>>
navigableMapNavigableMap1
=
dataMap
.
get
(
RECORDS
);
NavigableMap
<
Long
,
byte
[]>
longNavigableMapData
=
navigableMapNavigableMap1
.
get
(
DATA
);
Long
firstKey
=
longNavigableMapData
.
firstKey
();
oscillogram
.
setStart
(
firstKey
);
byte
[]
mapDataByte
=
longNavigableMapData
.
get
(
firstKey
);
String
mapData
=
Base64Decoder
.
decodeStr
(
Base64Encoder
.
encode
(
mapDataByte
));
oscillogram
.
setMapData
(
mapData
);
//获取偏移量
NavigableMap
<
Long
,
byte
[]>
longNavigableMapOffset
=
navigableMapNavigableMap1
.
get
(
OFFSET
);
Long
firstOffsetKey
=
longNavigableMapOffset
.
firstKey
();
byte
[]
offSetByte
=
longNavigableMapOffset
.
get
(
firstOffsetKey
);
oscillogram
.
setNoVersionKeyPhaseOffset
(
Base64Decoder
.
decodeStr
(
Base64Encoder
.
encode
(
offSetByte
)));
return
oscillogram
;
//获取偏移量
// Set<byte[]> keySet = noVersionMap.keySet();
// for (byte[] keyByte : keySet) {
// System.out.println(Base64Decoder.decodeStr(Base64Encoder.encode(keyByte)));
// NavigableMap<byte[], byte[]> navigableMap = noVersionMap.get(keyByte);
// for (byte[] keyByteIn : navigableMap.keySet()) {
// System.out.println("-----------------------");
// System.out.println(Base64Decoder.decodeStr(Base64Encoder.encode(keyByteIn)));
// }
// }
//
// Set<byte[]> keySet2 = dataMap.keySet();
// System.out.println("========================================");
// System.out.println("========================================");
// System.out.println("========================================");
// System.out.println("========================================");
// for (byte[] keyByte : keySet2) {
// System.out.println(Base64Decoder.decodeStr(Base64Encoder.encode(keyByte)));
// NavigableMap<byte[], NavigableMap<Long, byte[]>> navigableMapNavigableMap = dataMap.get(keyByte);
// System.out.println("第二层");
// for (byte[] keyByteIn : navigableMapNavigableMap.keySet()) {
// System.out.println("-----------------------");
// System.out.println(Base64Decoder.decodeStr(Base64Encoder.encode(keyByteIn)));
// NavigableMap<Long, byte[]> longNavigableMap = navigableMapNavigableMap.get(keyByteIn);
// System.out.println("第三层");
// for (Long l : longNavigableMap.keySet()) {
// System.out.println("++++++++++++++++++++++++");
// System.out.println(l);
// }
// }
// }
//
}
/**
* 解密kkscode
* <p>
* rowkey:UNIX时间第10位+KKS+UNIX时间:0rm0000000000000000000002171589741900581
*
* @param row 带解密
* @return str
*/
private
String
getKKsCode
(
byte
[]
row
)
{
if
(
row
.
length
==
0
)
{
throw
new
RuntimeException
(
"获取Hbase数据失败,RowKey为空!"
);
}
String
kksCodeEncode
=
Base64Decoder
.
decodeStr
(
Base64Encoder
.
encode
(
row
));
return
StrUtil
.
swapCase
(
StrUtil
.
sub
(
kksCodeEncode
,
1
,
kksCodeEncode
.
length
()
-
13
));
}
}
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/domain/UserInfo.java
View file @
773e4177
...
...
@@ -9,6 +9,8 @@ import org.springframework.security.core.userdetails.UserDetails;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.GenerationType
;
import
javax.persistence.Id
;
import
javax.persistence.Table
;
import
javax.persistence.Transient
;
...
...
@@ -29,6 +31,7 @@ import java.util.stream.Collectors;
public
class
UserInfo
extends
AbstractEntity
<
String
>
implements
UserDetails
{
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
private
String
id
;
private
String
username
;
private
String
password
;
...
...
@@ -86,7 +89,7 @@ public class UserInfo extends AbstractEntity<String> implements UserDetails {
@Override
public
boolean
isAccountNonLocked
()
{
return
locked
;
return
true
;
}
@Override
...
...
@@ -96,6 +99,6 @@ public class UserInfo extends AbstractEntity<String> implements UserDetails {
@Override
public
boolean
isEnabled
()
{
return
enabled
;
return
true
;
}
}
\ No newline at end of file
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/security/JWTAuthenticationFilter.java
View file @
773e4177
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
security
;
import
cn.wise.sc.energy.power.plant.business.domain.UserInfo
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
io.jsonwebtoken.Jwts
;
import
io.jsonwebtoken.SignatureAlgorithm
;
...
...
@@ -54,11 +55,11 @@ public class JWTAuthenticationFilter extends
final
HttpServletResponse
response
,
final
FilterChain
chain
,
final
Authentication
authResult
)
{
final
String
token
=
Jwts
.
builder
()
.
setSubject
(((
User
)
authResult
.
getPrincipal
()).
getUsername
())
.
setIssuedAt
(
new
Date
())
.
setExpiration
(
Date
.
from
(
OffsetDateTime
.
now
().
plusDays
(
5
).
toInstant
()))
.
signWith
(
JWTKeyHolder
.
KEY
,
SignatureAlgorithm
.
HS512
)
.
compact
();
.
setSubject
(((
User
Info
)
authResult
.
getPrincipal
()).
getUsername
())
.
setIssuedAt
(
new
Date
())
.
setExpiration
(
Date
.
from
(
OffsetDateTime
.
now
().
plusDays
(
5
).
toInstant
()))
.
signWith
(
JWTKeyHolder
.
KEY
,
SignatureAlgorithm
.
HS512
)
.
compact
();
response
.
addHeader
(
AUTHORIZATION_HEADER
,
TOKEN_PREFIX
+
token
);
response
.
addCookie
(
new
Cookie
(
SecurityConstants
.
AUTH_COOKIE
,
token
));
}
...
...
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/security/JwtUserDetailsService.java
View file @
773e4177
//package cn.wise.sc.energy.power.plant.business.security;
//
//import cn.wise.sc.energy.power.plant.business.domain.UserInfo;
//import cn.wise.sc.energy.power.plant.business.service2.IUserInfoService;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.security.core.userdetails.UserDetails;
//import org.springframework.security.core.userdetails.UserDetailsService;
//import org.springframework.security.core.userdetails.UsernameNotFoundException;
//import org.springframework.stereotype.Component;
//import java.util.List;
//
///**
// * JwtUserDetailsService
// * 实现UserDetailsService,重写loadUserByUsername方法
// */
//@Slf4j
//@Component
//public class JwtUserDetailsService implements UserDetailsService {
//
// final
// IUserInfoService iUserInfoService;
//
// @Value("${spring.datasource.dtn.userbac.prefix}")
// private String prefix;
//
// public JwtUserDetailsService(IUserInfoService iUserInfoService) {
// this.iUserInfoService = iUserInfoService;
// }
//
// @Override
// public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
//
// //获取数据库用户信息
// List<UserInfo> list = iUserInfoService.getSysUserByUsername( username);
// //todo 权限获取
// if (list.size() == 0) {
// log.warn("未找到当前用户:{} \n ====== cn.wise.sc.pay.common.security2.userDetail.JwtUserDetailsService.loadUserByUsername()", username);
// throw new UsernameNotFoundException("未找到当前用户!");
// }
// UserDetails userDetails = list.get(0);
//
// return userDetails;
// }
//}
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
security
;
import
cn.wise.sc.energy.power.plant.business.domain.UserInfo
;
import
cn.wise.sc.energy.power.plant.business.service.IUserInfoService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.security.core.userdetails.UserDetails
;
import
org.springframework.security.core.userdetails.UserDetailsService
;
import
org.springframework.security.core.userdetails.UsernameNotFoundException
;
import
org.springframework.stereotype.Component
;
import
java.util.List
;
/**
* JwtUserDetailsService
* 实现UserDetailsService,重写loadUserByUsername方法
*/
@Slf4j
@Component
public
class
JwtUserDetailsService
implements
UserDetailsService
{
final
IUserInfoService
iUserInfoService
;
public
JwtUserDetailsService
(
IUserInfoService
iUserInfoService
)
{
this
.
iUserInfoService
=
iUserInfoService
;
}
@Override
public
UserDetails
loadUserByUsername
(
String
username
)
throws
UsernameNotFoundException
{
//获取数据库用户信息
List
<
UserInfo
>
list
=
iUserInfoService
.
getSysUserByUsername
(
username
);
//todo 权限获取
if
(
list
.
size
()
==
0
)
{
log
.
warn
(
"未找到当前用户:{} \n ====== cn.wise.sc.pay.common.security2.userDetail.JwtUserDetailsService.loadUserByUsername()"
,
username
);
throw
new
UsernameNotFoundException
(
"未找到当前用户!"
);
}
UserDetails
userDetails
=
list
.
get
(
0
);
return
userDetails
;
}
}
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/security/SecurityConfig.java
View file @
773e4177
...
...
@@ -18,20 +18,20 @@ import org.springframework.security.web.authentication.UsernamePasswordAuthentic
@EnableGlobalMethodSecurity
(
securedEnabled
=
true
)
public
class
SecurityConfig
extends
WebSecurityConfigurerAdapter
{
// final
// JwtUserDetailsService jwtUserDetailsService;
//
// public SecurityConfig(JwtUserDetailsService jwtUserDetailsService) {
// this.jwtUserDetailsService = jwtUserDetailsService;
// }
final
JwtUserDetailsService
jwtUserDetailsService
;
// @Autowired
// public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// // configure AuthenticationManager so that it knows from where to load
// // user for matching credentials
// // Use BCryptPasswordEncoder
// auth.userDetailsService(jwtUserDetailsService).passwordEncoder(passwordEncoder());
// }
public
SecurityConfig
(
JwtUserDetailsService
jwtUserDetailsService
)
{
this
.
jwtUserDetailsService
=
jwtUserDetailsService
;
}
@Autowired
public
void
configureGlobal
(
AuthenticationManagerBuilder
auth
)
throws
Exception
{
// configure AuthenticationManager so that it knows from where to load
// user for matching credentials
// Use BCryptPasswordEncoder
auth
.
userDetailsService
(
jwtUserDetailsService
).
passwordEncoder
(
passwordEncoder
());
}
@Override
protected
void
configure
(
final
HttpSecurity
http
)
throws
Exception
{
http
.
csrf
().
disable
()
...
...
@@ -53,24 +53,24 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
.
and
()
.
addFilter
(
new
JWTAuthenticationFilter
(
this
.
authenticationManager
()))
.
addFilterBefore
(
new
JWTFilter
(
this
.
authenticationManager
(),
this
.
userDetailsService
()
),
jwtUserDetailsService
),
UsernamePasswordAuthenticationFilter
.
class
)
.
sessionManagement
()
.
sessionCreationPolicy
(
SessionCreationPolicy
.
STATELESS
);
}
@Override
protected
void
configure
(
final
AuthenticationManagerBuilder
auth
)
throws
Exception
{
auth
.
inMemoryAuthentication
()
.
withUser
(
"admin"
)
.
password
(
this
.
passwordEncoder
().
encode
(
"password"
))
.
roles
(
"ADMIN"
)
.
and
()
.
withUser
(
"user"
)
.
password
(
this
.
passwordEncoder
().
encode
(
"password"
))
.
roles
(
"USER"
);
}
//
@Override
//
protected void configure(final AuthenticationManagerBuilder auth)
//
throws Exception {
//
auth.inMemoryAuthentication()
//
.withUser("admin")
//
.password(this.passwordEncoder().encode("password"))
//
.roles("ADMIN")
//
.and()
//
.withUser("user")
//
.password(this.passwordEncoder().encode("password"))
//
.roles("USER");
//
}
@Bean
public
PasswordEncoder
passwordEncoder
()
{
...
...
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/service/ICharacterParamService.java
View file @
773e4177
...
...
@@ -88,5 +88,12 @@ public interface ICharacterParamService extends IBaseService<String, CharacterPa
* @param status 统计方式
* @return list
*/
BaseResponse
<
List
<
DataPower
>>
getTendency
(
List
<
String
>
keys
,
TimeModelQuery
timeModelQuery
,
Integer
status
);
BaseResponse
<
DataPower
>
getTendency
(
List
<
String
>
keys
,
TimeModelQuery
timeModelQuery
,
Integer
status
);
/**
* 感觉kkscode获取测点
* @param kksCodes kks
* @return list
*/
List
<
CharacterParamInfo
>
getByKksCodes
(
List
<
String
>
kksCodes
);
}
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/service/IDetectionService.java
View file @
773e4177
...
...
@@ -2,6 +2,8 @@ package cn.wise.sc.energy.power.plant.business.service;
import
cn.wise.sc.energy.power.plant.business.domain.DetectionItem
;
import
java.util.List
;
/**
* @description: 检测service
* @author: qh
...
...
@@ -11,6 +13,7 @@ public interface IDetectionService {
/**
* 发起一键巡检
*
* @param sessionId 会话id
* @return 是否成功
*/
...
...
@@ -18,9 +21,20 @@ public interface IDetectionService {
/**
* 获取下一个检测项
*
* @param sessionId 会话id
* @return 下一个项目
*/
DetectionItem
nextItem
(
String
sessionId
);
/**
* 交互选择
*
* @param sessionId 会话id
* @param qid 问题id
* @param selectIndex 选择项id集合
* @return bool
*/
Boolean
interactionChose
(
String
sessionId
,
String
qid
,
List
<
Integer
>
selectIndex
);
}
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/service/IPlantInfoService.java
View file @
773e4177
...
...
@@ -15,5 +15,5 @@ public interface IPlantInfoService extends IBaseService<String, PlantInfo> {
* @param plantId 电厂id
* @return total
*/
BaseResponse
<
Integer
>
getTotalPower
(
String
plantId
);
BaseResponse
<
Double
>
getTotalPower
(
String
plantId
);
}
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/service/impl/CharacterParamServiceImpl.java
View file @
773e4177
...
...
@@ -228,9 +228,9 @@ public class CharacterParamServiceImpl extends BaseServiceImpl<String, Character
}
@Override
public
BaseResponse
<
List
<
DataPower
>
>
getTendency
(
List
<
String
>
keys
,
TimeModelQuery
timeModelQuery
,
Integer
status
)
{
public
BaseResponse
<
DataPower
>
getTendency
(
List
<
String
>
keys
,
TimeModelQuery
timeModelQuery
,
Integer
status
)
{
//去数据库匹配测点
List
<
CharacterParamInfo
>
characterParamInfos
=
characterParamRepository
...
...
@@ -272,30 +272,46 @@ public class CharacterParamServiceImpl extends BaseServiceImpl<String, Character
characterParamInfos
));
}
private
List
<
DataPower
>
buildDataPower
(
List
<
QueryResult
>
results
,
List
<
CharacterParamInfo
>
characterParamInfos
)
{
@Override
public
List
<
CharacterParamInfo
>
getByKksCodes
(
List
<
String
>
kksCodes
)
{
ResponseEnum
.
COLLECTION_NOT_ILLEGAL
.
assertCollectionNotILLEGAL
(
kksCodes
);
//去数据库匹配测点
return
characterParamRepository
.
findAll
((
Specification
<
CharacterParamInfo
>)
(
root
,
query
,
criteriaBuilder
)
->
{
Path
<
String
>
kkscodePath
=
root
.
get
(
"kksCode"
);
CriteriaBuilder
.
In
<
String
>
in
=
criteriaBuilder
.
in
(
kkscodePath
);
for
(
String
kkscode
:
kksCodes
)
{
in
.
value
(
kkscode
);
}
return
in
;
});
}
private
DataPower
buildDataPower
(
List
<
QueryResult
>
results
,
List
<
CharacterParamInfo
>
characterParamInfos
)
{
ResponseEnum
.
COLLECTION_NOT_ILLEGAL
.
assertCollectionNotILLEGAL
(
results
);
List
<
DataPower
>
rts
=
new
ArrayList
<>(
results
.
size
()
);
DataPower
dataPower
=
new
DataPower
(
);
for
(
QueryResult
queryResult
:
results
)
{
CharacterParamInfo
characterParamInfo
=
characterParamInfos
.
stream
()
.
filter
(
arg
->
arg
.
getKksCode
().
equals
(
queryResult
.
getMetric
()))
.
findFirst
().
get
();
String
cpName
=
characterParamInfo
.
getCpName
();
DataPower
dataPower
=
new
DataPower
();
DataPower
.
PowerPoints
powerPoints
=
new
DataPower
.
PowerPoints
();
dataPower
.
getDataList
().
add
(
powerPoints
);
powerPoints
.
setName
(
cpName
);
queryResult
.
getDps
().
keySet
().
forEach
(
arg
->
{
dataPower
.
getXAxis
().
add
(
arg
.
toString
());
powerPoints
.
getValue
().
add
(
queryResult
.
getDps
().
get
(
arg
).
toString
());
});
if
(
powerPoints
.
getValue
().
size
()
==
0
)
{
powerPoints
.
getValue
().
add
(
"0"
);
}
rts
.
add
(
dataPower
);
//todo 查询阈值 color中添加阈值集合
}
return
rts
;
return
dataPower
;
}
private
Map
<
String
,
Number
>
cutOneDataAnd2Map
(
List
<
QueryResult
>
results
,
...
...
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/service/impl/DetectionServiceImpl.java
View file @
773e4177
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
service
.
impl
;
import
cn.hutool.core.util.StrUtil
;
import
cn.wise.sc.energy.power.plant.business.domain.DetectionItem
;
import
cn.wise.sc.energy.power.plant.business.service.IDetectionService
;
import
cn.wise.sc.energy.power.plant.common.core.exception.ResponseEnum
;
import
com.alibaba.fastjson.JSON
;
import
org.redisson.api.RBucket
;
import
org.redisson.api.RQueue
;
import
org.redisson.api.RedissonClient
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
/**
* @description: 一键巡检
* @author: qh
...
...
@@ -23,14 +27,18 @@ public class DetectionServiceImpl implements IDetectionService {
this
.
redissonClient
=
redissonClient
;
}
private
native
String
start
(
String
sessionId
);
private
native
String
start
(
String
sessionId
,
Integer
status
);
@Override
public
Boolean
startDetection
(
String
sessionId
)
{
//todo 调取C函数 发起巡检
String
start
=
start
(
sessionId
);
return
null
;
String
start
=
start
(
sessionId
,
0
);
if
(
StrUtil
.
isNotBlank
(
start
)
&&
"0"
.
equals
(
start
))
{
return
true
;
}
else
{
return
false
;
}
}
@Override
...
...
@@ -42,13 +50,37 @@ public class DetectionServiceImpl implements IDetectionService {
//判断是否为最后一个
if
(
queue
.
size
()
==
0
)
{
//判断是否存在交互
String
interactionKey
=
sessionId
+
"
:i
nteraction"
;
String
interactionKey
=
sessionId
+
"
_I
nteraction"
;
RBucket
<
String
>
bucket
=
redissonClient
.
getBucket
(
interactionKey
);
if
(
bucket
.
isExists
())
{
// poll.setInteraction(bucket.get());
poll
.
setInteraction
(
JSON
.
parseObject
(
bucket
.
get
(),
DetectionItem
.
Interaction
.
class
));
return
poll
;
}
}
return
poll
;
}
@Override
public
Boolean
interactionChose
(
String
sessionId
,
String
qid
,
List
<
Integer
>
selectIndex
)
{
ResponseEnum
.
COLLECTION_NOT_ILLEGAL
.
assertNotEmpty
(
sessionId
);
ResponseEnum
.
COLLECTION_NOT_ILLEGAL
.
assertNotEmpty
(
qid
);
ResponseEnum
.
COLLECTION_NOT_ILLEGAL
.
assertNotNull
(
selectIndex
);
//拿到交互项redis这中存 数据
String
key
=
sessionId
+
"_Result"
;
RBucket
<
Object
>
bucket
=
redissonClient
.
getBucket
(
key
);
DetectionItem
.
InteractionResult
result
=
new
DetectionItem
.
InteractionResult
();
result
.
setId
(
sessionId
);
result
.
setQid
(
qid
);
result
.
setSelect
(
selectIndex
);
bucket
.
set
(
JSON
.
toJSONString
(
result
));
return
true
;
}
}
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/service/impl/PlantInfoServiceImpl.java
View file @
773e4177
...
...
@@ -27,19 +27,19 @@ public class PlantInfoServiceImpl extends BaseServiceImpl<String, PlantInfo> imp
}
@Override
public
BaseResponse
<
Integer
>
getTotalPower
(
String
plantId
)
{
public
BaseResponse
<
Double
>
getTotalPower
(
String
plantId
)
{
List
<
DeviceInfo
>
deviceInfos
=
deviceInfoRepository
.
findAll
((
root
,
query
,
criteriaBuilder
)
->
criteriaBuilder
.
equal
(
root
.
get
(
"plantId"
),
plantId
));
if
(
deviceInfos
.
size
()
==
0
)
{
return
BaseResponse
.
okData
(
10
);
return
BaseResponse
.
okData
(
10
D
);
}
else
{
//设备不为空
int
totalPower
=
0
;
Double
totalPower
=
0
D
;
for
(
DeviceInfo
deviceInfo
:
deviceInfos
)
{
ResponseEnum
.
LICENCE_NOT_FOUND
.
assertNotEmpty
(
deviceInfo
.
getDeviceParam
());
DeviceParam
deviceParam
=
JSON
.
parseObject
(
deviceInfo
.
getDeviceParam
(),
DeviceParam
.
class
);
ResponseEnum
.
LICENCE_NOT_FOUND
.
assertNotEmpty
(
deviceParam
.
getRatepower
());
int
power
=
Integer
.
parseInt
(
deviceParam
.
getRatepower
().
replace
(
"MW"
,
""
));
Double
power
=
Double
.
parseDouble
(
deviceParam
.
getRatepower
().
replace
(
"MW"
,
""
));
totalPower
+=
power
;
}
return
BaseResponse
.
okData
(
totalPower
);
...
...
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/service/impl/UserInfoServiceImpl.java
View file @
773e4177
...
...
@@ -8,11 +8,14 @@ import cn.wise.sc.energy.power.plant.business.service.IUserInfoService;
import
cn.wise.sc.energy.power.plant.common.core.bean.BaseResponse
;
import
cn.wise.sc.energy.power.plant.common.core.exception.ResponseEnum
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.data.jpa.domain.Specification
;
import
org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder
;
import
org.springframework.security.crypto.password.PasswordEncoder
;
import
org.springframework.stereotype.Service
;
import
javax.persistence.criteria.Path
;
...
...
@@ -29,6 +32,9 @@ public class UserInfoServiceImpl implements IUserInfoService {
final
UserInfoRepository
userInfoRepository
;
PasswordEncoder
passwordEncoder
=
new
BCryptPasswordEncoder
();
public
UserInfoServiceImpl
(
UserInfoRepository
userInfoRepository
)
{
this
.
userInfoRepository
=
userInfoRepository
;
}
...
...
@@ -38,8 +44,8 @@ public class UserInfoServiceImpl implements IUserInfoService {
ResponseEnum
.
LICENCE_NOT_FOUND
.
assertNotEmpty
(
username
);
List
<
UserInfo
>
userInfos
=
userInfoRepository
.
findAll
((
root
,
query
,
criteriaBuilder
)
->
{
Path
<
Object
>
username1
=
root
.
get
(
"username"
);
return
criteriaBuilder
.
equal
(
username1
,
username
1
);
Path
<
String
>
username1
=
root
.
get
(
"username"
);
return
criteriaBuilder
.
equal
(
username1
,
username
);
});
return
userInfos
;
...
...
@@ -69,6 +75,13 @@ public class UserInfoServiceImpl implements IUserInfoService {
UserInfo
userInfoNew
=
new
UserInfo
();
BeanUtils
.
copyProperties
(
userInfo
,
userInfoNew
);
userInfoNew
.
setPassword
(
passwordEncoder
.
encode
(
userInfoNew
.
getPassword
()));
int
size
=
getSysUserByUsername
(
userInfo
.
getUsername
()).
size
();
if
(
size
>
0
)
{
return
BaseResponse
.
errorMsg
(
"用户名已存在!"
);
}
userInfoNew
.
setId
(
null
);
UserInfo
save
=
userInfoRepository
.
save
(
userInfoNew
);
if
(
save
.
getId
()
!=
null
)
{
return
BaseResponse
.
okData
(
true
);
...
...
@@ -81,10 +94,9 @@ public class UserInfoServiceImpl implements IUserInfoService {
public
BaseResponse
<
Boolean
>
edit
(
UserInfoQuery
userInfo
)
{
UserInfo
one
=
userInfoRepository
.
getOne
(
userInfo
.
getId
());
UserInfo
update
=
new
UserInfo
();
BeanUtils
.
copyProperties
(
one
,
update
);
update
.
setPassword
(
userInfo
.
getPassword
());
userInfoRepository
.
save
(
update
);
one
.
setPassword
(
passwordEncoder
.
encode
(
userInfo
.
getPassword
()));
userInfoRepository
.
saveAndFlush
(
one
);
return
BaseResponse
.
okData
(
true
);
}
}
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/task/ScheduledModel.java
View file @
773e4177
...
...
@@ -25,15 +25,11 @@ public class ScheduledModel {
final
WebSocketServer
webSocketServer
;
final
WebSocketServer2
webSocketServer2
;
final
ICharacterParamService
iCharacterParamService
;
public
ScheduledModel
(
WebSocketServer
webSocketServer
,
WebSocketServer2
webSocketServer2
,
ICharacterParamService
iCharacterParamService
)
{
this
.
webSocketServer
=
webSocketServer
;
this
.
webSocketServer2
=
webSocketServer2
;
this
.
iCharacterParamService
=
iCharacterParamService
;
}
...
...
@@ -146,10 +142,10 @@ public class ScheduledModel {
Double
power2F
=
0
D
;
for
(
String
key
:
realTimeDataAndCpName
.
keySet
())
{
if
(
key
.
contains
(
"1F"
))
{
power1F
+=
(
Double
)
realTimeDataAndCpName
.
get
(
key
);
power1F
+=
Double
.
parseDouble
(
realTimeDataAndCpName
.
get
(
key
)
+
""
);
}
if
(
key
.
contains
(
"2F"
))
{
power2F
+=
(
Double
)
realTimeDataAndCpName
.
get
(
key
);
power2F
+=
Double
.
parseDouble
(
realTimeDataAndCpName
.
get
(
key
)
+
""
);
}
}
DataPower
.
PowerPoints
powerPoints
=
new
DataPower
.
PowerPoints
();
...
...
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/task/WebSocketServer2.java
deleted
100644 → 0
View file @
4bb77a2e
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
task
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.stereotype.Component
;
import
javax.websocket.OnClose
;
import
javax.websocket.OnError
;
import
javax.websocket.OnMessage
;
import
javax.websocket.OnOpen
;
import
javax.websocket.Session
;
import
javax.websocket.server.PathParam
;
import
javax.websocket.server.ServerEndpoint
;
import
java.io.IOException
;
import
java.util.concurrent.ConcurrentHashMap
;
@Slf4j
@Component
@ServerEndpoint
(
"/index/realTimeData/8/{plantCode}"
)
public
class
WebSocketServer2
{
/**
* 静态变量,用来记录当前在线连接数。应该把它设计成线程安全的。
*/
private
static
int
onlineCount
=
0
;
/**
* concurrent包的线程安全Set,用来存放每个客户端对应的MyWebSocket对象。
*/
public
static
ConcurrentHashMap
<
String
,
WebSocketServer2
>
webSocketMap
=
new
ConcurrentHashMap
<>();
/**
* 与某个客户端的连接会话,需要通过它来给客户端发送数据
*/
private
Session
session
;
/**
* 接收userId
*/
private
String
plantCode
=
""
;
/**
* 连接建立成功调用的方法
*/
@OnOpen
public
void
onOpen
(
Session
session
,
@PathParam
(
"plantCode"
)
String
plantCode
)
{
this
.
session
=
session
;
this
.
plantCode
=
plantCode
;
if
(
webSocketMap
.
containsKey
(
plantCode
))
{
webSocketMap
.
remove
(
plantCode
);
webSocketMap
.
put
(
plantCode
,
this
);
//加入set中
}
else
{
webSocketMap
.
put
(
plantCode
,
this
);
//加入set中
addOnlineCount
();
//在线数加1
}
log
.
info
(
"用户连接:"
+
plantCode
+
",当前在线人数为:"
+
getOnlineCount
());
}
/**
* 连接关闭调用的方法
*/
@OnClose
public
void
onClose
()
{
if
(
webSocketMap
.
containsKey
(
plantCode
))
{
webSocketMap
.
remove
(
plantCode
);
//从set中删除
subOnlineCount
();
}
log
.
info
(
"用户退出:"
+
plantCode
+
",当前在线人数为:"
+
getOnlineCount
());
}
/**
* 收到客户端消息后调用的方法
*
* @param message 客户端发送过来的消息
*/
@OnMessage
public
void
onMessage
(
String
message
,
Session
session
)
throws
IOException
{
log
.
info
(
"用户消息:"
+
plantCode
+
",报文:"
+
message
);
//可以群发消息
//消息保存到数据库、redis
if
(
StringUtils
.
isNotBlank
(
message
))
{
webSocketMap
.
get
(
plantCode
).
sendMessage
(
"111111111"
);
}
}
/**
* @param session
* @param error
*/
@OnError
public
void
onError
(
Session
session
,
Throwable
error
)
{
log
.
error
(
"用户错误:"
+
this
.
plantCode
+
",原因:"
+
error
.
getMessage
());
error
.
printStackTrace
();
}
/**
* 实现服务器主动推送
*/
public
void
sendMessage
(
String
message
)
throws
IOException
{
this
.
session
.
getBasicRemote
().
sendText
(
message
);
}
/**
* 发送自定义消息
*/
public
static
void
sendInfo
(
String
message
,
@PathParam
(
"userId"
)
String
userId
)
throws
IOException
{
log
.
info
(
"发送消息到:"
+
userId
+
",报文:"
+
message
);
if
(
StringUtils
.
isNotBlank
(
userId
)
&&
webSocketMap
.
containsKey
(
userId
))
{
webSocketMap
.
get
(
userId
).
sendMessage
(
message
);
}
else
{
log
.
error
(
"用户"
+
userId
+
",不在线!"
);
}
}
public
static
synchronized
int
getOnlineCount
()
{
return
onlineCount
;
}
public
static
synchronized
void
addOnlineCount
()
{
WebSocketServer2
.
onlineCount
++;
}
public
static
synchronized
void
subOnlineCount
()
{
WebSocketServer2
.
onlineCount
--;
}
}
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/utils/OkHttpClientUtil.java
View file @
773e4177
...
...
@@ -9,8 +9,6 @@ import okhttp3.OkHttpClient;
import
okhttp3.Request
;
import
okhttp3.RequestBody
;
import
okhttp3.Response
;
import
springfox.documentation.spring.web.json.Json
;
import
java.io.IOException
;
import
java.util.Iterator
;
import
java.util.Map
;
...
...
power-common/common-core/common-core.iml
View file @
773e4177
...
...
@@ -19,22 +19,6 @@
</content>
<orderEntry
type=
"inheritedJdk"
/>
<orderEntry
type=
"sourceFolder"
forTests=
"false"
/>
<orderEntry
type=
"library"
name=
"Maven: io.springfox:springfox-swagger2:2.9.2"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: io.swagger:swagger-annotations:1.5.20"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: io.swagger:swagger-models:1.5.20"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: io.springfox:springfox-spi:2.9.2"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: io.springfox:springfox-core:2.9.2"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: net.bytebuddy:byte-buddy:1.10.8"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: io.springfox:springfox-schema:2.9.2"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: io.springfox:springfox-swagger-common:2.9.2"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: io.springfox:springfox-spring-web:2.9.2"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: com.google.guava:guava:20.0"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: com.fasterxml:classmate:1.5.1"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.slf4j:slf4j-api:1.7.30"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.plugin:spring-plugin-core:1.2.0.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.plugin:spring-plugin-metadata:1.2.0.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.mapstruct:mapstruct:1.2.0.Final"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: io.springfox:springfox-swagger-ui:2.9.2"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: com.fasterxml.jackson.module:jackson-module-parameter-names:2.10.3"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: com.fasterxml.jackson.core:jackson-core:2.10.3"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.10.3"
level=
"project"
/>
...
...
@@ -55,6 +39,7 @@
<orderEntry
type=
"library"
name=
"Maven: org.springframework.boot:spring-boot-starter-logging:2.2.6.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: ch.qos.logback:logback-classic:1.2.3"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: ch.qos.logback:logback-core:1.2.3"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.slf4j:slf4j-api:1.7.30"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.apache.logging.log4j:log4j-to-slf4j:2.12.1"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.apache.logging.log4j:log4j-api:2.12.1"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.slf4j:jul-to-slf4j:1.7.30"
level=
"project"
/>
...
...
@@ -68,6 +53,7 @@
<orderEntry
type=
"library"
name=
"Maven: org.springframework.boot:spring-boot-starter-validation:2.2.6.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.hibernate.validator:hibernate-validator:6.0.18.Final"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.jboss.logging:jboss-logging:3.4.1.Final"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: com.fasterxml:classmate:1.5.1"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework:spring-webmvc:5.2.5.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: jakarta.validation:jakarta.validation-api:2.0.2"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.projectlombok:lombok:1.18.10"
level=
"project"
/>
...
...
power-common/common-core/pom.xml
View file @
773e4177
...
...
@@ -18,22 +18,22 @@
<hutool.version>
4.6.8
</hutool.version>
<lombok.version>
1.18.10
</lombok.version>
<fastjson.version>
1.2.62
</fastjson.version>
<swagger.fox.version>
2.9.2
</swagger.fox.version>
<swagger.fox.version>
z
</swagger.fox.version>
<swagger-bootstrap-ui.version>
1.9.3
</swagger-bootstrap-ui.version>
<swagger.fox.version>
2.9.2
</swagger.fox.version>
</properties>
<dependencies>
<!--swagger-->
<dependency
>
<groupId>
io.springfox
</groupId
>
<artifactId>
springfox-swagger2
</artifactId
>
<version>
${swagger.fox.version}
</version
>
</dependency
>
<dependency
>
<groupId>
io.springfox
</groupId
>
<artifactId>
springfox-swagger-ui
</artifactId
>
<version>
${swagger.fox.version}
</version
>
</dependency
>
<!-- <dependency>--
>
<!-- <groupId>io.springfox</groupId>--
>
<!-- <artifactId>springfox-swagger2</artifactId>--
>
<!-- <version>${swagger.fox.version}</version>--
>
<!-- </dependency>--
>
<!-- <dependency>--
>
<!-- <groupId>io.springfox</groupId>--
>
<!-- <artifactId>springfox-swagger-ui</artifactId>--
>
<!-- <version>${swagger.fox.version}</version>--
>
<!-- </dependency>--
>
<!--jackson模块-->
<dependency>
<groupId>
com.fasterxml.jackson.module
</groupId>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment