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
5f874a73
Commit
5f874a73
authored
Aug 20, 2020
by
qinhu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Hbase配置引入
parent
4a17a880
Show whitespace changes
Inline
Side-by-side
Showing
42 changed files
with
117 additions
and
3161 deletions
+117
-3161
PowerPlantRunner.java
...wise/sc/energy/power/plant/business/PowerPlantRunner.java
+2
-2
BaseController.java
...nergy/power/plant/business/controller/BaseController.java
+2
-2
CharacterParamController.java
...r/plant/business/controller/CharacterParamController.java
+2
-6
CondensateController.java
...power/plant/business/controller/CondensateController.java
+0
-24
DeviceInfoController.java
...power/plant/business/controller/DeviceInfoController.java
+2
-2
MenuController.java
...nergy/power/plant/business/controller/MenuController.java
+0
-44
PlantInfoController.java
.../power/plant/business/controller/PlantInfoController.java
+2
-2
RuntimeOptionController.java
...er/plant/business/controller/RuntimeOptionController.java
+1
-3
SpindleController.java
...gy/power/plant/business/controller/SpindleController.java
+0
-34
TestController.java
...nergy/power/plant/business/controller/TestController.java
+0
-33
UnitInfoController.java
...y/power/plant/business/controller/UnitInfoController.java
+2
-2
UserInfoController.java
...y/power/plant/business/controller/UserInfoController.java
+4
-5
IndexRealDataController.java
...r/plant/business/controller2/IndexRealDataController.java
+0
-160
TendencyController.java
.../power/plant/business/controller2/TendencyController.java
+0
-44
Oscillogram.java
...se/sc/energy/power/plant/business/domain/Oscillogram.java
+37
-0
OscillogramQuery.java
.../energy/power/plant/business/domain/OscillogramQuery.java
+38
-1
DataBaseService.java
.../energy/power/plant/business/service/DataBaseService.java
+0
-111
IBaseService.java
.../sc/energy/power/plant/business/service/IBaseService.java
+1
-1
ICharacterParamService.java
.../power/plant/business/service/ICharacterParamService.java
+1
-4
IDetectionService.java
...nergy/power/plant/business/service/IDetectionService.java
+1
-1
IDeviceInfoService.java
...ergy/power/plant/business/service/IDeviceInfoService.java
+1
-1
IPlantInfoService.java
...nergy/power/plant/business/service/IPlantInfoService.java
+1
-6
IRuntimeOptionService.java
...y/power/plant/business/service/IRuntimeOptionService.java
+1
-1
IService.java
...wise/sc/energy/power/plant/business/service/IService.java
+0
-21
ISpindleService.java
.../energy/power/plant/business/service/ISpindleService.java
+0
-11
IUnitInfoService.java
...energy/power/plant/business/service/IUnitInfoService.java
+1
-1
IUserInfoService.java
...energy/power/plant/business/service/IUserInfoService.java
+1
-2
IndexRealTimeDataService.java
...ower/plant/business/service/IndexRealTimeDataService.java
+0
-676
IndexRealTimeDataServiceV0.java
...er/plant/business/service/IndexRealTimeDataServiceV0.java
+0
-678
IndexRealTimeDataServiceV2.java
...er/plant/business/service/IndexRealTimeDataServiceV2.java
+0
-681
MenuService.java
...e/sc/energy/power/plant/business/service/MenuService.java
+0
-157
SpindleServiceImpl.java
...ergy/power/plant/business/service/SpindleServiceImpl.java
+0
-49
TendencyService.java
.../energy/power/plant/business/service/TendencyService.java
+0
-334
BaseServiceImpl.java
...gy/power/plant/business/service/impl/BaseServiceImpl.java
+2
-5
CharacterParamServiceImpl.java
...lant/business/service/impl/CharacterParamServiceImpl.java
+2
-4
DetectionServiceImpl.java
...wer/plant/business/service/impl/DetectionServiceImpl.java
+2
-2
DeviceInfoServiceImpl.java
...er/plant/business/service/impl/DeviceInfoServiceImpl.java
+3
-12
PlantInfoServiceImpl.java
...wer/plant/business/service/impl/PlantInfoServiceImpl.java
+2
-2
RuntimeOptionServiceImpl.java
...plant/business/service/impl/RuntimeOptionServiceImpl.java
+1
-1
UnitInfoServiceImpl.java
...ower/plant/business/service/impl/UnitInfoServiceImpl.java
+2
-3
UserInfoServiceImpl.java
...ower/plant/business/service/impl/UserInfoServiceImpl.java
+2
-15
ScheduledModel.java
...e/sc/energy/power/plant/business/task/ScheduledModel.java
+1
-18
No files found.
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/PowerPlantRunner.java
View file @
5f874a73
...
@@ -5,8 +5,8 @@ import cn.wise.sc.energy.power.plant.business.domain.vo.DeviceInfoVo;
...
@@ -5,8 +5,8 @@ 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.domain.vo.EntityVo
;
import
cn.wise.sc.energy.power.plant.business.domain.vo.PlantInfoVo
;
import
cn.wise.sc.energy.power.plant.business.domain.vo.PlantInfoVo
;
import
cn.wise.sc.energy.power.plant.business.domain.vo.UnitInfoVo
;
import
cn.wise.sc.energy.power.plant.business.domain.vo.UnitInfoVo
;
import
cn.wise.sc.energy.power.plant.business.service
2
.IDeviceInfoService
;
import
cn.wise.sc.energy.power.plant.business.service.IDeviceInfoService
;
import
cn.wise.sc.energy.power.plant.business.service
2
.IPlantInfoService
;
import
cn.wise.sc.energy.power.plant.business.service.IPlantInfoService
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
org.redisson.api.RedissonClient
;
import
org.redisson.api.RedissonClient
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/controller
2
/BaseController.java
→
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/controller/BaseController.java
View file @
5f874a73
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
controller
2
;
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
controller
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
cn.wise.sc.energy.power.plant.business.domain.AbstractEntity
;
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.domain.vo.EntityVo
;
import
cn.wise.sc.energy.power.plant.business.service
2
.IBaseService
;
import
cn.wise.sc.energy.power.plant.business.service.IBaseService
;
import
cn.wise.sc.energy.power.plant.common.core.bean.EntityQuery
;
import
cn.wise.sc.energy.power.plant.common.core.bean.EntityQuery
;
import
cn.wise.sc.energy.power.plant.common.core.bean.BaseResponse
;
import
cn.wise.sc.energy.power.plant.common.core.bean.BaseResponse
;
import
org.springframework.web.bind.annotation.DeleteMapping
;
import
org.springframework.web.bind.annotation.DeleteMapping
;
...
...
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/controller
2
/CharacterParamController.java
→
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/controller/CharacterParamController.java
View file @
5f874a73
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
controller
2
;
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.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.TendencyQuery
;
import
cn.wise.sc.energy.power.plant.business.domain.vo.EntityVo
;
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.service.ICharacterParamService
;
import
cn.wise.sc.energy.power.plant.business.service2.impl.BaseServiceImpl
;
import
cn.wise.sc.energy.power.plant.common.core.bean.BaseResponse
;
import
cn.wise.sc.energy.power.plant.common.core.bean.BaseResponse
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
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.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.CrossOrigin
;
import
org.springframework.web.bind.annotation.CrossOrigin
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
...
...
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/controller/CondensateController.java
deleted
100644 → 0
View file @
4a17a880
//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;
// }
//
//}
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/controller
2
/DeviceInfoController.java
→
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/controller/DeviceInfoController.java
View file @
5f874a73
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
controller
2
;
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
controller
;
import
cn.wise.sc.energy.power.plant.business.domain.vo.DeviceInfoVo
;
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.domain.vo.EntityVo
;
import
cn.wise.sc.energy.power.plant.business.service
2
.IDeviceInfoService
;
import
cn.wise.sc.energy.power.plant.business.service.IDeviceInfoService
;
import
cn.wise.sc.energy.power.plant.common.core.bean.BaseResponse
;
import
cn.wise.sc.energy.power.plant.common.core.bean.BaseResponse
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
org.springframework.web.bind.annotation.CrossOrigin
;
import
org.springframework.web.bind.annotation.CrossOrigin
;
...
...
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/controller/MenuController.java
deleted
100644 → 0
View file @
4a17a880
//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);
// }
//
//}
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/controller
2
/PlantInfoController.java
→
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/controller/PlantInfoController.java
View file @
5f874a73
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
controller
2
;
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.domain.vo.EntityVo
;
import
cn.wise.sc.energy.power.plant.business.service
2
.IPlantInfoService
;
import
cn.wise.sc.energy.power.plant.business.service.IPlantInfoService
;
import
cn.wise.sc.energy.power.plant.common.core.bean.BaseResponse
;
import
cn.wise.sc.energy.power.plant.common.core.bean.BaseResponse
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParam
;
...
...
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/controller
2
/RuntimeOptionController.java
→
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/controller/RuntimeOptionController.java
View file @
5f874a73
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
controller
2
;
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.Oscillogram
;
import
cn.wise.sc.energy.power.plant.business.domain.OscillogramRowMapper
;
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.HbaseTemplate
;
import
com.spring4all.spring.boot.starter.hbase.api.RowMapper
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
org.apache.hadoop.conf.Configuration
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.CrossOrigin
;
import
org.springframework.web.bind.annotation.CrossOrigin
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
...
...
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/controller/SpindleController.java
deleted
100644 → 0
View file @
4a17a880
//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;
// }
//
//}
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/controller/TestController.java
deleted
100644 → 0
View file @
4a17a880
//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");
// }
//
//
//
//}
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/controller
2
/UnitInfoController.java
→
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/controller/UnitInfoController.java
View file @
5f874a73
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
controller
2
;
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.domain.vo.EntityVo
;
import
cn.wise.sc.energy.power.plant.business.service
2
.IUnitInfoService
;
import
cn.wise.sc.energy.power.plant.business.service.IUnitInfoService
;
import
cn.wise.sc.energy.power.plant.common.core.bean.BaseResponse
;
import
cn.wise.sc.energy.power.plant.common.core.bean.BaseResponse
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
org.springframework.web.bind.annotation.CrossOrigin
;
import
org.springframework.web.bind.annotation.CrossOrigin
;
...
...
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/controller
2
/UserInfoController.java
→
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/controller/UserInfoController.java
View file @
5f874a73
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
controller
2
;
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
controller
;
import
cn.wise.sc.energy.power.plant.business.domain.PageQuery
;
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.UserInfo
;
import
cn.wise.sc.energy.power.plant.business.domain.UserInfoQuery
;
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.service.IUserInfoService
;
import
cn.wise.sc.energy.power.plant.business.service2.IUserInfoService
;
import
cn.wise.sc.energy.power.plant.common.core.bean.BaseResponse
;
import
cn.wise.sc.energy.power.plant.common.core.bean.BaseResponse
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Page
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.CrossOrigin
;
import
org.springframework.web.bind.annotation.CrossOrigin
;
...
@@ -45,7 +43,8 @@ public class UserInfoController {
...
@@ -45,7 +43,8 @@ public class UserInfoController {
public
BaseResponse
<
Boolean
>
add
(
UserInfoQuery
userInfo
)
{
public
BaseResponse
<
Boolean
>
add
(
UserInfoQuery
userInfo
)
{
return
iUserInfoService
.
addUserInfo
(
userInfo
);
return
iUserInfoService
.
addUserInfo
(
userInfo
);
}
}
@PutMapping
(
"/new"
)
@PutMapping
(
"/edit"
)
public
BaseResponse
<
Boolean
>
edit
(
UserInfoQuery
userInfo
)
{
public
BaseResponse
<
Boolean
>
edit
(
UserInfoQuery
userInfo
)
{
return
iUserInfoService
.
edit
(
userInfo
);
return
iUserInfoService
.
edit
(
userInfo
);
}
}
...
...
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/controller2/IndexRealDataController.java
deleted
100644 → 0
View file @
4a17a880
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
;
}
}
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/controller2/TendencyController.java
deleted
100644 → 0
View file @
4a17a880
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
);
}
}
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/domain/Oscillogram.java
View file @
5f874a73
...
@@ -2,6 +2,8 @@ package cn.wise.sc.energy.power.plant.business.domain;
...
@@ -2,6 +2,8 @@ package cn.wise.sc.energy.power.plant.business.domain;
import
lombok.Data
;
import
lombok.Data
;
import
java.util.List
;
/**
/**
* @description: 波形图
* @description: 波形图
* @author: qh
* @author: qh
...
@@ -10,4 +12,39 @@ import lombok.Data;
...
@@ -10,4 +12,39 @@ import lombok.Data;
@Data
@Data
public
class
Oscillogram
{
public
class
Oscillogram
{
/**
* 功率谱数据
*/
private
List
<
Data
>
power
;
/**
* 阶次比数据
*/
private
List
<
Data
>
orderRatio
;
/**
* 相位谱数据
*/
private
List
<
Data
>
phaseSpectrum
;
public
static
class
Data
{
/**
* 测点对应KKS编码
*/
private
String
kKSCode
;
/**
* 幅值(Y轴坐标值)
*/
private
List
<
Double
>
data
;
/**
* 频率(X轴坐标值)
*/
private
List
<
Double
>
index
;
}
}
}
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/domain/OscillogramQuery.java
View file @
5f874a73
...
@@ -2,6 +2,8 @@ package cn.wise.sc.energy.power.plant.business.domain;
...
@@ -2,6 +2,8 @@ package cn.wise.sc.energy.power.plant.business.domain;
import
lombok.Data
;
import
lombok.Data
;
import
java.util.List
;
/**
/**
* @description: 波形图入参
* @description: 波形图入参
* @author: qh
* @author: qh
...
@@ -23,7 +25,7 @@ public class OscillogramQuery {
...
@@ -23,7 +25,7 @@ public class OscillogramQuery {
@Data
@
lombok
.
Data
public
static
class
Record
{
public
static
class
Record
{
/**
/**
...
@@ -41,6 +43,41 @@ public class OscillogramQuery {
...
@@ -41,6 +43,41 @@ public class OscillogramQuery {
*/
*/
private
String
generationFreq
;
private
String
generationFreq
;
/**
* 旋转方向(0:顺时针,1:逆时针)
*/
private
Integer
direction
;
private
Integer
direction
;
/**
* 记录类型(0:连续采样,1定时采样:)
*/
private
Integer
recordFlag
;
private
List
<
Data
>
data
;
}
@lombok
.
Data
public
static
class
Data
{
/**
* 测点对应KKS编码
*/
private
String
kKSCode
;
/**
* 样包采样周期数
*/
private
Long
period
;
/**
* 各键相点相对起始时间偏移
*/
private
Long
keyPhaseOffset
;
/**
* 数据区域
*/
private
String
data
;
}
}
}
}
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/service/DataBaseService.java
deleted
100644 → 0
View file @
4a17a880
//package cn.wise.sc.energy.power.plant.business.service;
//
//import cn.wise.sc.energy.power.plant.business.bean.BasicOption;
//import cn.wise.sc.energy.power.plant.business.bean.TurbineOption;
//import cn.wise.sc.energy.power.plant.common.core.exception.ResponseEnum;
//import com.alibaba.fastjson.JSON;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.jdbc.core.JdbcTemplate;
//import org.springframework.stereotype.Component;
//
//import java.util.List;
//
///**
// * @description: 数据库操作
// * @author: qh
// * @create: 2020-05-23 09:36
// */
//@Slf4j
//@Component
//public class DataBaseService {
//
// final JdbcTemplate jdbcTemplate;
//
// /**
// * 根据plantCode获取电厂配置
// */
// private final String GET_TURBINE_CONFIG_BY_PLANT_CODE = "SELECT basicoption FROM turbineoption WHERE plantcode = ?";
//
// /**
// * 获取所有电厂配置
// */
// private final String GET_TURBINE_CONFIG = "SELECT basicoption FROM turbineoption";
//
// /**
// * 获取所有电厂信息
// */
// private final String GET_TURBINE = "SELECT plantcode,plantname,basicoption FROM turbineoption";
//
// public DataBaseService(JdbcTemplate jdbcTemplate) {
// this.jdbcTemplate = jdbcTemplate;
// }
//
// /**
// * 根据plantCode获取电厂配置文件信息
// *
// * @param plantCode 电厂编码
// * @return 配置文件
// */
// public String getTurbineConfigJson(String plantCode) {
//
// //判断plantCode不为空
// ResponseEnum.BAD_LICENCE_TYPE.assertNotEmpty(plantCode);
//
// List<String> rts = jdbcTemplate.query(GET_TURBINE_CONFIG_BY_PLANT_CODE, new String[]{plantCode}, (resultSet, i) -> resultSet.getNString(1));
//
// if (rts != null && rts.size() > 0) {
// return rts.get(0);
// } else {
// log.info("没有找到相关电厂配置信息! 电厂编号:{}", plantCode);
// throw new RuntimeException("没有找到相关数据");
// }
// }
//
// /**
// * 获取所有电厂配置文件信息
// *
// * @return 配置文件
// */
// public List<String> getAllTurbineConfigJson() {
//
// return jdbcTemplate.query(GET_TURBINE_CONFIG, new String[]{}, (resultSet, i) -> resultSet.getNString(1)
// );
// }
//
// /**
// * 获取所有电厂信息
// * @return 电厂信息集合
// */
// public List<TurbineOption> getAllTurbine() {
// return jdbcTemplate.query(GET_TURBINE, new String[]{}, (resultSet, i) -> {
//
// TurbineOption turbineOption = new TurbineOption();
// turbineOption.setPlantCode(resultSet.getNString(1));
// turbineOption.setPlantName(resultSet.getNString(2));
// String basicOptionStr = resultSet.getNString(3);
//
// ResponseEnum.LICENCE_NOT_FOUND.assertNotEmpty(basicOptionStr);
// turbineOption.setBasicOption(JSON.parseObject(basicOptionStr,BasicOption.class));
//
// return turbineOption;
// }
//
// );
// }
//
// /**
// * 获取所有信息
// *
// * @return
// */
// public List<TurbineOption> getAllTurbineOption() {
// return jdbcTemplate.query(GET_TURBINE, new String[]{}, (resultSet, i) -> {
// TurbineOption turbineOption = new TurbineOption();
// turbineOption.setPlantCode(resultSet.getNString(1));
// turbineOption.setPlantName(resultSet.getNString(2));
// turbineOption.setBasicOption(JSON.parseObject(resultSet.getNString(3), BasicOption.class));
// return turbineOption;
// }
// );
// }
//}
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/service
2
/IBaseService.java
→
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/service/IBaseService.java
View file @
5f874a73
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
service
2
;
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
service
;
import
cn.wise.sc.energy.power.plant.business.domain.AbstractEntity
;
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.domain.vo.EntityVo
;
...
...
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/service
2
/ICharacterParamService.java
→
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/service/ICharacterParamService.java
View file @
5f874a73
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
service
2
;
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
service
;
import
cn.wise.sc.energy.power.plant.business.bean.DataPower
;
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.bean.TimeModelQuery
;
...
@@ -6,11 +6,8 @@ import cn.wise.sc.energy.power.plant.business.domain.CharacterParamInfo;
...
@@ -6,11 +6,8 @@ import cn.wise.sc.energy.power.plant.business.domain.CharacterParamInfo;
import
cn.wise.sc.energy.power.plant.business.domain.vo.CharacterParamInfoVo
;
import
cn.wise.sc.energy.power.plant.business.domain.vo.CharacterParamInfoVo
;
import
cn.wise.sc.energy.power.plant.business.domain.vo.EntityVo
;
import
cn.wise.sc.energy.power.plant.business.domain.vo.EntityVo
;
import
cn.wise.sc.energy.power.plant.common.core.bean.BaseResponse
;
import
cn.wise.sc.energy.power.plant.common.core.bean.BaseResponse
;
import
net.opentsdb.client.api.query.response.QueryResponse
;
import
org.springframework.stereotype.Service
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
...
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/service
2
/IDetectionService.java
→
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/service/IDetectionService.java
View file @
5f874a73
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
service
2
;
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
service
;
import
cn.wise.sc.energy.power.plant.business.domain.DetectionItem
;
import
cn.wise.sc.energy.power.plant.business.domain.DetectionItem
;
...
...
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/service
2
/IDeviceInfoService.java
→
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/service/IDeviceInfoService.java
View file @
5f874a73
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
service
2
;
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
service
;
import
cn.wise.sc.energy.power.plant.business.domain.DeviceInfo
;
import
cn.wise.sc.energy.power.plant.business.domain.DeviceInfo
;
import
cn.wise.sc.energy.power.plant.business.domain.vo.DeviceInfoVo
;
import
cn.wise.sc.energy.power.plant.business.domain.vo.DeviceInfoVo
;
...
...
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/service
2
/IPlantInfoService.java
→
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/service/IPlantInfoService.java
View file @
5f874a73
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
service
2
;
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
service
;
import
cn.wise.sc.energy.power.plant.business.domain.PlantInfo
;
import
cn.wise.sc.energy.power.plant.business.domain.PlantInfo
;
import
cn.wise.sc.energy.power.plant.business.domain.vo.EntityVo
;
import
cn.wise.sc.energy.power.plant.business.domain.vo.PlantInfoVo
;
import
cn.wise.sc.energy.power.plant.common.core.bean.BaseResponse
;
import
cn.wise.sc.energy.power.plant.common.core.bean.BaseResponse
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
/**
/**
* @description: 电厂信息服务层
* @description: 电厂信息服务层
...
...
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/service
2
/IRuntimeOptionService.java
→
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/service/IRuntimeOptionService.java
View file @
5f874a73
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
service
2
;
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
service
;
import
cn.wise.sc.energy.power.plant.business.domain.RuntimeOptionInfo
;
import
cn.wise.sc.energy.power.plant.business.domain.RuntimeOptionInfo
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
...
...
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/service/IService.java
deleted
100644 → 0
View file @
4a17a880
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
service
;
import
cn.wise.sc.energy.power.plant.business.bean.TimeModelQuery
;
import
cn.wise.sc.energy.power.plant.common.core.bean.BaseResponse
;
/**
* @description: 基础接口
* @author: qh
* @create: 2020-05-20 18:00
*/
public
interface
IService
{
/**
* 根据时间和测点查询 数据
*
* @param timeModelQuery 时间段
* @param key 测点
* @return
*/
BaseResponse
<
String
>
getDataByTime
(
TimeModelQuery
timeModelQuery
,
String
key
);
}
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/service/ISpindleService.java
deleted
100644 → 0
View file @
4a17a880
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
service
;
/**
* @description: 转轴监控
* @author: qh
* @create: 2020-05-20 18:00
**/
public
interface
ISpindleService
extends
IService
{
}
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/service
2
/IUnitInfoService.java
→
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/service/IUnitInfoService.java
View file @
5f874a73
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
service
2
;
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
service
;
import
cn.wise.sc.energy.power.plant.business.domain.UnitInfo
;
import
cn.wise.sc.energy.power.plant.business.domain.UnitInfo
;
import
cn.wise.sc.energy.power.plant.business.domain.vo.EntityVo
;
import
cn.wise.sc.energy.power.plant.business.domain.vo.EntityVo
;
...
...
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/service
2
/IUserInfoService.java
→
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/service/IUserInfoService.java
View file @
5f874a73
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
service
2
;
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
service
;
import
cn.wise.sc.energy.power.plant.business.domain.UserInfo
;
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.UserInfoQuery
;
import
cn.wise.sc.energy.power.plant.business.domain.vo.EntityVo
;
import
cn.wise.sc.energy.power.plant.common.core.bean.BaseResponse
;
import
cn.wise.sc.energy.power.plant.common.core.bean.BaseResponse
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Page
;
...
...
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/service/IndexRealTimeDataService.java
deleted
100644 → 0
View file @
4a17a880
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
service
;
import
cn.hutool.core.date.DateField
;
import
cn.hutool.core.date.DateUtil
;
import
cn.wise.sc.energy.power.plant.business.bean.DataPower
;
import
cn.wise.sc.energy.power.plant.business.domain.vo.CharacterParamInfoVo
;
import
cn.wise.sc.energy.power.plant.business.domain.vo.DeviceInfoVo
;
import
cn.wise.sc.energy.power.plant.business.domain.vo.UnitInfoVo
;
import
cn.wise.sc.energy.power.plant.business.opentsdb.OpentsdbOkHttpClient
;
import
cn.wise.sc.energy.power.plant.business.opentsdb.bean.QueryExt
;
import
cn.wise.sc.energy.power.plant.business.opentsdb.bean.QueryRequestExt
;
import
cn.wise.sc.energy.power.plant.business.service2.ICharacterParamService
;
import
cn.wise.sc.energy.power.plant.business.service2.IDeviceInfoService
;
import
cn.wise.sc.energy.power.plant.business.service2.IUnitInfoService
;
import
cn.wise.sc.energy.power.plant.common.core.bean.BaseResponse
;
import
cn.wise.sc.energy.power.plant.common.core.exception.ResponseEnum
;
import
com.alibaba.fastjson.JSON
;
import
lombok.extern.slf4j.Slf4j
;
import
net.opentsdb.client.api.query.response.QueryResponse
;
import
net.opentsdb.client.bean.Aggregator
;
import
net.opentsdb.client.bean.QueryResult
;
import
org.redisson.api.RedissonClient
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.concurrent.atomic.AtomicReference
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
java.util.stream.Collectors
;
/**
* @description: 首页实时数据
* @author: 7
* @create: 2020-05-25 10:40
**/
@Slf4j
@Component
public
class
IndexRealTimeDataService
{
final
RedissonClient
redissonClient
;
@Autowired
IDeviceInfoService
iDeviceInfoService
;
@Autowired
IUnitInfoService
iUnitInfoService
;
@Autowired
ICharacterParamService
iCharacterParamService
;
public
IndexRealTimeDataService
(
RedissonClient
redissonClient
)
{
this
.
redissonClient
=
redissonClient
;
}
/**
* 首页实时数据 各机组振动棒状对比图数据
*
* @param plantCode 电厂唯一标识
* @return DataPower {@link DataPower}
*/
public
BaseResponse
<
DataPower
>
realTimeDataUnitLubrication
(
String
plantCode
)
{
//获取当前电厂下的所有设备
List
<
DeviceInfoVo
>
deviceInfoVos
=
iDeviceInfoService
.
getDeviceUnitAndCharacterPlantCode
(
plantCode
);
//todo 正式时 使用下面的 1s-ago
long
end
=
1590375153L
;
long
start
=
end
-
1
;
QueryRequestExt
queryRequestExt
=
QueryRequestExt
.
builder
()
// .start(start + "")
// .end(end + "")
.
start
(
"100h-ago"
)
.
build
();
//返回结果
DataPower
dataPower
=
new
DataPower
();
dataPower
.
getXAxis
().
add
(
"汽端座振X"
);
dataPower
.
getXAxis
().
add
(
"汽端轴振X"
);
dataPower
.
getXAxis
().
add
(
"励端座振X"
);
dataPower
.
getXAxis
().
add
(
"励端轴振X"
);
//循环处理机组的的轴系振动
for
(
DeviceInfoVo
device
:
deviceInfoVos
)
{
//构造value的key
DataPower
.
PowerPoints
powerPoint
=
new
DataPower
.
PowerPoints
();
powerPoint
.
setName
(
device
.
getDeviceName
());
//构造返回数据类型
dataPower
.
getDataList
().
add
(
powerPoint
);
//获取振动数据所在的部件信息 n号机轴振监测
UnitInfoVo
lubricationUnit
=
device
.
getUnitInfoVos
().
stream
().
filter
(
unit
->
{
//todo 1号机轴振监测 这个名字是写死的
return
unit
.
getUnitName
().
contains
(
"轴系振动监测"
);
}).
findFirst
().
orElse
(
null
);
if
(
lubricationUnit
!=
null
)
{
//筛选 1F汽端轴承座振动(绝对值)1 汽端轴承座振动(绝对值)2 汽端轴承振动1 F汽端轴承振动2
List
<
CharacterParamInfoVo
>
waitDoLubricationCharacterParamInfoVo
=
lubricationUnit
.
getCharacters
().
stream
().
filter
(
characters
->
characters
.
getCpName
().
contains
(
"F汽端座振X"
)
||
characters
.
getCpName
().
contains
(
"F汽端轴振X"
)
||
characters
.
getCpName
().
contains
(
"F励端座振X"
)
||
characters
.
getCpName
().
contains
(
"F励端轴振X"
)
).
collect
(
Collectors
.
toList
());
//集合为空时 抛出异常
if
(
waitDoLubricationCharacterParamInfoVo
.
size
()
!=
0
)
{
ResponseEnum
.
COLLECTION_NOT_ILLEGAL
.
assertCollectionNotILLEGAL
(
waitDoLubricationCharacterParamInfoVo
);
waitDoLubricationCharacterParamInfoVo
.
forEach
(
characters
->
{
String
kkscode
=
characters
.
getKksCode
();
QueryExt
queryExt
=
QueryExt
.
builder
()
.
aggregator
(
Aggregator
.
AVG
)
.
metric
(
kkscode
)
.
build
();
queryRequestExt
.
addQuery
(
queryExt
);
});
}
}
}
try
{
QueryResponse
response
=
OpentsdbOkHttpClient
.
query
(
queryRequestExt
);
List
<
QueryResult
>
results
=
response
.
getResults
();
//处理X轴坐标
results
.
forEach
(
arg
->
{
String
kksCode
=
arg
.
getMetric
();
HashMap
<
String
,
String
>
deviceNameAndCharacterName
=
findDeviceNameAndCharacterName
(
kksCode
,
deviceInfoVos
);
String
deviceName
=
deviceNameAndCharacterName
.
get
(
"deviceName"
);
String
characterName
=
deviceNameAndCharacterName
.
get
(
"characterName"
);
int
xCount
=
dataPower
.
getXAxis
().
size
();
int
yCount
=
dataPower
.
getDataList
().
size
();
int
xPosition
=
-
1
,
yPosition
=
-
1
;
for
(
int
i
=
0
;
i
<
xCount
;
i
++)
{
if
(
characterName
.
contains
(
dataPower
.
getXAxis
().
get
(
i
).
toString
()))
{
xPosition
=
i
;
}
}
for
(
int
i
=
0
;
i
<
yCount
;
i
++)
{
if
(
deviceName
.
equals
(
dataPower
.
getDataList
().
get
(
i
).
getName
()))
{
yPosition
=
i
;
}
}
//关联数据位置
for
(
Long
timeKey
:
arg
.
getDps
().
keySet
())
{
dataPower
.
getDataList
().
get
(
yPosition
).
getValue
().
add
(
xPosition
,
String
.
valueOf
(
arg
.
getDps
().
get
(
timeKey
)));
}
});
//处理X轴坐标名称
return
BaseResponse
.
okData
(
formatDataPowerXY
(
dataPower
));
}
catch
(
Exception
e
)
{
log
.
error
(
"请求各机组实时振动对比数据失败!"
);
//抛出业务异常
ResponseEnum
.
OPEN_TS_DB_CONNECTION_ERROR
.
assertIsException
(
e
);
}
return
BaseResponse
.
errorMsg
(
"获取失败"
);
}
/**
* 首页实时数据 三相电压/电流 定子电压/电流 (汇总实时数据)
*
* @param plantCode 点电唯一标识
* @return DataPower
*/
public
BaseResponse
<
DataPower
>
realTimeDataVoltage
(
String
plantCode
)
{
//获取当前电厂下的所有设备
List
<
DeviceInfoVo
>
deviceInfoVos
=
iDeviceInfoService
.
getDeviceUnitAndCharacterPlantCode
(
plantCode
);
//构建时间条件 前1s->当前时间 构建opentsdb查询条件
long
end
=
1590373722L
;
long
start
=
end
-
1
;
QueryRequestExt
queryRequestExt
=
QueryRequestExt
.
builder
()
// .start(start + "")
// .end(end + "")
.
start
(
"100h-ago"
)
.
build
();
//返回结果
DataPower
dataPower
=
new
DataPower
();
dataPower
.
getXAxis
().
add
(
"发电机定子A相电流"
);
dataPower
.
getXAxis
().
add
(
"发电机定子B相电流"
);
dataPower
.
getXAxis
().
add
(
"发电机定子C相电流"
);
dataPower
.
getXAxis
().
add
(
"发电机定子AB线电压"
);
dataPower
.
getXAxis
().
add
(
"发电机定子BC线电压"
);
dataPower
.
getXAxis
().
add
(
"发电机定子CA线电压"
);
//循环处理机组的的轴系振动
for
(
DeviceInfoVo
deviceInfoVo
:
deviceInfoVos
)
{
if
(!
deviceInfoVo
.
getDeviceName
().
contains
(
"1号"
))
{
continue
;
}
//获取定子电流电压数据所在的部件信息 n号机定子电流电压
UnitInfoVo
lubricationUnit
=
deviceInfoVo
.
getUnitInfoVos
()
.
stream
().
filter
(
unit
->
{
//todo 1号机定子电流电压 这个名字是写死的
return
unit
.
getUnitName
().
contains
(
"定子电气参数监测"
);
}).
findFirst
().
orElse
(
null
);
//构造value的key
DataPower
.
PowerPoints
powerPoint
=
new
DataPower
.
PowerPoints
();
powerPoint
.
setName
(
deviceInfoVo
.
getDeviceName
());
if
(
lubricationUnit
!=
null
)
{
//构造返回数据类型
dataPower
.
getDataList
().
add
(
powerPoint
);
//筛选 1FA相电压 1FB相电压 1FC相电压1 1FA相电流 1FB相电流 1FC相电流
List
<
CharacterParamInfoVo
>
waitDoLubricationCharacterParamInfoVo
=
lubricationUnit
.
getCharacters
().
stream
().
filter
(
characters
->
characters
.
getCpName
().
contains
(
"F发电机定子A相电流"
)
||
characters
.
getCpName
().
contains
(
"F发电机定子AB线电压"
)
||
characters
.
getCpName
().
contains
(
"F发电机定子BC线电压"
)
||
characters
.
getCpName
().
contains
(
"F发电机定子CA线电压"
)
||
characters
.
getCpName
().
contains
(
"F发电机定子B相电流"
)
||
characters
.
getCpName
().
contains
(
"F发电机定子C相电流"
)
).
collect
(
Collectors
.
toList
());
//集合为空时 抛出异常
if
(
waitDoLubricationCharacterParamInfoVo
.
size
()
==
0
)
{
continue
;
}
ResponseEnum
.
COLLECTION_NOT_ILLEGAL
.
assertCollectionNotILLEGAL
(
waitDoLubricationCharacterParamInfoVo
);
waitDoLubricationCharacterParamInfoVo
.
forEach
(
characters
->
{
String
kkscode
=
characters
.
getKksCode
();
QueryExt
queryExt
=
QueryExt
.
builder
()
.
aggregator
(
Aggregator
.
NONE
)
.
metric
(
kkscode
)
.
build
();
queryRequestExt
.
addQuery
(
queryExt
);
});
}
}
try
{
QueryResponse
response
=
OpentsdbOkHttpClient
.
query
(
queryRequestExt
);
List
<
QueryResult
>
results
=
response
.
getResults
();
//处理X轴坐标
results
.
forEach
(
arg
->
{
String
kksCode
=
arg
.
getMetric
();
HashMap
<
String
,
String
>
deviceNameAndCharacterName
=
findDeviceNameAndCharacterName
(
kksCode
,
deviceInfoVos
);
String
deviceName
=
deviceNameAndCharacterName
.
get
(
"deviceName"
);
String
characterName
=
deviceNameAndCharacterName
.
get
(
"characterName"
);
int
xCount
=
dataPower
.
getXAxis
().
size
();
int
yCount
=
dataPower
.
getDataList
().
size
();
int
xPosition
=
-
1
,
yPosition
=
-
1
;
for
(
int
i
=
0
;
i
<
xCount
;
i
++)
{
if
(
characterName
.
contains
(
dataPower
.
getXAxis
().
get
(
i
)
+
""
))
{
xPosition
=
i
;
}
}
for
(
int
i
=
0
;
i
<
yCount
;
i
++)
{
if
(
deviceName
.
equals
(
dataPower
.
getDataList
().
get
(
i
).
getName
()))
{
yPosition
=
i
;
}
}
//关联数据位置
for
(
Long
timeKey
:
arg
.
getDps
().
keySet
())
{
dataPower
.
getDataList
().
get
(
yPosition
).
getValue
().
add
(
xPosition
,
arg
.
getDps
().
get
(
timeKey
)
+
""
);
}
});
DataPower
rts
=
new
DataPower
();
List
<
Integer
>
currentPositions
=
new
ArrayList
<>(
3
);
List
<
Integer
>
voltagePositions
=
new
ArrayList
<>(
3
);
//获取电流和电压的索引位置
dataPower
.
getXAxis
().
forEach
(
arg
->
{
if
(
arg
.
toString
().
contains
(
"电流"
))
{
currentPositions
.
add
(
dataPower
.
getXAxis
().
indexOf
(
arg
));
}
if
(
arg
.
toString
().
contains
(
"电压"
))
{
voltagePositions
.
add
(
dataPower
.
getXAxis
().
indexOf
(
arg
));
}
});
rts
.
getXAxis
().
add
(
"三项电流"
);
rts
.
getXAxis
().
add
(
"三项电压"
);
rts
.
getXAxis
().
add
(
"定子电流"
);
rts
.
getXAxis
().
add
(
"定子电压"
);
dataPower
.
getDataList
().
forEach
(
arg
->
{
DataPower
.
PowerPoints
powerPoints
=
new
DataPower
.
PowerPoints
();
powerPoints
.
setName
(
arg
.
getName
());
if
(
arg
.
getValue
()
!=
null
&&
arg
.
getValue
().
size
()
!=
0
)
{
double
currentTotal
=
Double
.
parseDouble
(
arg
.
getValue
().
get
(
currentPositions
.
get
(
0
)))
+
Double
.
parseDouble
(
arg
.
getValue
().
get
(
currentPositions
.
get
(
1
)))
+
Double
.
parseDouble
(
arg
.
getValue
().
get
(
currentPositions
.
get
(
2
)));
double
voltageTotal
=
Double
.
parseDouble
(
arg
.
getValue
().
get
(
voltagePositions
.
get
(
0
)))
+
Double
.
parseDouble
(
arg
.
getValue
().
get
(
voltagePositions
.
get
(
1
)))
+
Double
.
parseDouble
(
arg
.
getValue
().
get
(
voltagePositions
.
get
(
2
)));
powerPoints
.
getValue
().
add
(
currentTotal
+
""
);
powerPoints
.
getValue
().
add
(
voltageTotal
+
""
);
powerPoints
.
getValue
().
add
(
arg
.
getValue
().
get
(
currentPositions
.
get
(
1
)));
powerPoints
.
getValue
().
add
(
arg
.
getValue
().
get
(
currentPositions
.
get
(
2
)));
rts
.
getDataList
().
add
(
powerPoints
);
}
});
//处理X轴坐标名称
return
BaseResponse
.
okData
(
formatDataPowerXY
(
rts
));
}
catch
(
Exception
e
)
{
log
.
error
(
"请求各机组电流对比数据失败!"
);
//抛出业务异常
ResponseEnum
.
OPEN_TS_DB_CONNECTION_ERROR
.
assertIsException
(
e
);
}
return
BaseResponse
.
errorMsg
(
"获取失败"
);
}
/**
* 首页实时数据 各机组轴瓦温度柱状图
*
* @param plantCode 电厂名字
* @return DataPower
*/
public
BaseResponse
<
DataPower
>
realTimeDataBearingBushC
(
String
plantCode
)
{
List
<
DeviceInfoVo
>
deviceInfoVos
=
iDeviceInfoService
.
getDeviceUnitAndCharacterPlantCode
(
plantCode
);
//构建时间条件 前1s->当前时间 构建opentsdb查询条件
long
end
=
1590373710L
;
long
start
=
end
-
1
;
QueryRequestExt
queryRequestExt
=
QueryRequestExt
.
builder
()
// .start(start + "")
// .end(end + "")
.
start
(
"100h-ago"
)
.
build
();
DataPower
dataPower
=
new
DataPower
();
dataPower
.
getXAxis
().
add
(
"汽端轴瓦温度4"
);
dataPower
.
getXAxis
().
add
(
"汽端轴瓦温度5"
);
dataPower
.
getXAxis
().
add
(
"励端轴瓦温度1"
);
dataPower
.
getXAxis
().
add
(
"励端轴瓦温度2"
);
//循环处理机组的的轴系振动
for
(
DeviceInfoVo
device
:
deviceInfoVos
)
{
if
(!
device
.
getDeviceName
().
contains
(
"1号"
))
{
continue
;
}
//获取润滑参数 n号机润滑参数
UnitInfoVo
lubricationUnit
=
device
.
getUnitInfoVos
().
stream
().
filter
(
unit
->
{
//todo 1号机润滑参数 这个名字是写死的
return
unit
.
getUnitName
().
contains
(
"发电机本体温度监测"
);
}).
findFirst
().
orElse
(
null
);
if
(
lubricationUnit
!=
null
)
{
//构造value的key
DataPower
.
PowerPoints
powerPoint
=
new
DataPower
.
PowerPoints
();
powerPoint
.
setName
(
device
.
getDeviceName
());
//构造返回数据类型
dataPower
.
getDataList
().
add
(
powerPoint
);
//筛选 1F汽端轴瓦温度 1F汽端轴瓦温度A 1F励端轴瓦温度 1F励端轴瓦温度A
List
<
CharacterParamInfoVo
>
waitDoLubricationCharacterParamInfoVo
=
lubricationUnit
.
getCharacters
().
stream
().
filter
(
characters
->
characters
.
getCpName
().
contains
(
"F汽端轴瓦温度4"
)
||
characters
.
getCpName
().
contains
(
"F汽端轴瓦温度5"
)
||
characters
.
getCpName
().
contains
(
"F励端轴瓦温度1"
)
||
characters
.
getCpName
().
contains
(
"F励端轴瓦温度2"
)
).
collect
(
Collectors
.
toList
());
if
(
waitDoLubricationCharacterParamInfoVo
.
size
()
!=
0
)
{
//集合为空时 抛出异常
ResponseEnum
.
COLLECTION_NOT_ILLEGAL
.
assertCollectionNotILLEGAL
(
waitDoLubricationCharacterParamInfoVo
);
waitDoLubricationCharacterParamInfoVo
.
forEach
(
characters
->
{
String
kkscode
=
characters
.
getKksCode
();
QueryExt
queryExt
=
QueryExt
.
builder
()
.
aggregator
(
Aggregator
.
NONE
)
.
metric
(
kkscode
)
.
build
();
queryRequestExt
.
addQuery
(
queryExt
);
});
}
}
}
try
{
QueryResponse
response
=
OpentsdbOkHttpClient
.
query
(
queryRequestExt
);
List
<
QueryResult
>
results
=
response
.
getResults
();
//处理X轴坐标
results
.
forEach
(
arg
->
{
String
kksCode
=
arg
.
getMetric
();
HashMap
<
String
,
String
>
deviceNameAndCharacterName
=
findDeviceNameAndCharacterName
(
kksCode
,
deviceInfoVos
);
String
deviceName
=
deviceNameAndCharacterName
.
get
(
"deviceName"
);
String
characterName
=
deviceNameAndCharacterName
.
get
(
"characterName"
);
int
xCount
=
dataPower
.
getXAxis
().
size
();
int
yCount
=
dataPower
.
getDataList
().
size
();
int
xPosition
=
-
1
,
yPosition
=
-
1
;
for
(
int
i
=
0
;
i
<
xCount
;
i
++)
{
if
(
characterName
.
contains
(
dataPower
.
getXAxis
().
get
(
i
).
toString
()))
{
xPosition
=
i
;
}
}
for
(
int
i
=
0
;
i
<
yCount
;
i
++)
{
if
(
deviceName
.
equals
(
dataPower
.
getDataList
().
get
(
i
).
getName
()))
{
yPosition
=
i
;
}
}
//关联数据位置
for
(
Long
timeKey
:
arg
.
getDps
().
keySet
())
{
dataPower
.
getDataList
().
get
(
yPosition
).
getValue
().
add
(
xPosition
,
String
.
valueOf
(
arg
.
getDps
().
get
(
timeKey
)));
}
});
//处理X轴坐标名称
return
BaseResponse
.
okData
(
formatDataPowerXY
(
dataPower
));
}
catch
(
Exception
e
)
{
log
.
error
(
"获取个机组轴瓦温度柱状图失败!"
);
//抛出业务异常
ResponseEnum
.
OPEN_TS_DB_CONNECTION_ERROR
.
assertIsException
(
e
);
}
return
BaseResponse
.
errorMsg
(
"获取失败"
);
}
/**
* 获取首页3D部件下测点信息和值
*
* @param unitNo 部件唯一标识
* @param plantCode 电厂唯一标识
* @return DataPower
*/
public
BaseResponse
<
DataPower
>
realTimeData3DModel
(
String
unitNo
,
String
plantCode
)
{
List
<
DeviceInfoVo
>
deviceInfoVos
=
iDeviceInfoService
.
getDeviceUnitAndCharacterPlantCode
(
plantCode
);
AtomicReference
<
List
<
CharacterParamInfoVo
>>
listAtomicReference
=
new
AtomicReference
<>();
deviceInfoVos
.
forEach
(
devices
->
devices
.
getUnitInfoVos
().
forEach
(
units
->
{
if
(
unitNo
.
equals
(
units
.
getUnitCodeId
()))
{
listAtomicReference
.
set
(
units
.
getCharacters
());
}
}));
List
<
CharacterParamInfoVo
>
characters
=
listAtomicReference
.
get
();
// long endTime = 1590373722L;
// long startTime = endTime - 1;
//组装当前部件下的所有测点请求
QueryRequestExt
queryRequestExt
=
QueryRequestExt
.
builder
()
// .start(startTime + "")
// .end(endTime + "")
.
start
(
"100h-ago"
)
.
build
();
for
(
CharacterParamInfoVo
character
:
characters
)
{
QueryExt
queryExt
=
QueryExt
.
builder
()
.
metric
(
character
.
getKksCode
())
.
aggregator
(
Aggregator
.
AVG
)
.
build
();
queryRequestExt
.
addQuery
(
queryExt
);
}
DataPower
dataPower
=
new
DataPower
();
try
{
//封装响应数据
QueryResponse
response
=
OpentsdbOkHttpClient
.
query
(
queryRequestExt
);
response
.
getResults
().
forEach
(
arg
->
{
DataPower
.
PowerPoints
powerPoints
=
new
DataPower
.
PowerPoints
();
powerPoints
.
setName
(
arg
.
getMetric
());
for
(
Long
dataKey
:
arg
.
getDps
().
keySet
())
{
powerPoints
.
getValue
().
add
(
arg
.
getDps
().
get
(
dataKey
).
toString
());
}
dataPower
.
getDataList
().
add
(
powerPoints
);
});
//将kksCode 换成中文
for
(
DataPower
.
PowerPoints
powerPoints
:
dataPower
.
getDataList
())
{
characters
.
stream
()
.
filter
(
characters1
->
characters1
.
getKksCode
().
equals
(
powerPoints
.
getName
()))
.
findFirst
().
ifPresent
(
characters2
->
{
powerPoints
.
setName
(
characters2
.
getKksCode
());
List
<
String
>
subList
=
powerPoints
.
getValue
().
isEmpty
()
?
new
ArrayList
<>()
:
powerPoints
.
getValue
().
subList
(
0
,
1
);
powerPoints
.
setValue
(
subList
);
});
}
return
BaseResponse
.
okData
(
dataPower
);
}
catch
(
Exception
e
)
{
ResponseEnum
.
OPEN_TS_DB_CONNECTION_ERROR
.
assertIsException
(
e
);
}
return
BaseResponse
.
errorMsg
(
"查询失败!"
);
}
public
static
void
main
(
String
[]
args
)
{
String
power
=
"(燃机发电机有功功率\\d\\s*)$"
;
//原来是 "F功率"
final
Pattern
endFpower
=
Pattern
.
compile
(
power
,
Pattern
.
MULTILINE
);
final
Matcher
endFpowerMatcher
=
endFpower
.
matcher
(
"2燃机发电机有功功率9"
);
}
/**
* 获取首页各机组功率趋势图
*
* @param plantCode 电厂唯一标识
* @return 返回电压数据点线
*/
public
BaseResponse
<
DataPower
>
getIndexPowerInit
(
String
plantCode
)
{
List
<
DeviceInfoVo
>
deviceInfoVos
=
iDeviceInfoService
.
getDeviceUnitAndCharacterPlantCode
(
plantCode
);
//待查询的key值 结构:电机名|功率kkscode
List
<
String
>
keys
=
new
ArrayList
<>();
//筛选出每个机组的名字
String
statorCurrent
=
"(F定子电气参数监测\\s*)$"
;
//原来是 "号机定子电流电压"
final
Pattern
endStatorCurrentPattern
=
Pattern
.
compile
(
statorCurrent
,
Pattern
.
MULTILINE
);
String
power
=
"(燃机发电机有功功率\\d\\s*)$"
;
//原来是 "F功率"
final
Pattern
endFpower
=
Pattern
.
compile
(
power
,
Pattern
.
MULTILINE
);
deviceInfoVos
.
forEach
(
devices
->
{
//正则匹配 已"号机定子电流电压"结尾
UnitInfoVo
units
=
devices
.
getUnitInfoVos
().
stream
().
filter
(
unit
->
{
final
Matcher
endStatorCurrentMatcher
=
endStatorCurrentPattern
.
matcher
(
unit
.
getUnitName
());
return
endStatorCurrentMatcher
.
find
();
}).
findFirst
().
orElse
(
null
);
//正则匹配 已"F功率"结尾
ResponseEnum
.
LICENCE_NOT_FOUND
.
assertNotNull
(
units
);
CharacterParamInfoVo
characters
=
units
.
getCharacters
().
stream
().
filter
(
character
->
{
final
Matcher
endFpowerMatcher
=
endFpower
.
matcher
(
character
.
getCpName
());
return
endFpowerMatcher
.
find
();
}).
findFirst
().
orElse
(
null
);
ResponseEnum
.
LICENCE_NOT_FOUND
.
assertNotNull
(
characters
);
String
key
=
devices
.
getDeviceName
()
+
"|"
+
characters
.
getKksCode
();
keys
.
add
(
key
);
});
//计算当前需要的偏移量
Calendar
calendar
=
DateUtil
.
calendar
();
int
nowHour
=
calendar
.
get
(
Calendar
.
HOUR_OF_DAY
);
int
count
=
nowHour
/
6
;
int
endHour
=
(
count
-
1
)
*
6
+
2
;
//构建结尾时间
calendar
.
set
(
calendar
.
get
(
Calendar
.
YEAR
),
calendar
.
get
(
Calendar
.
MONTH
),
calendar
.
get
(
Calendar
.
DAY_OF_MONTH
),
endHour
,
0
);
Date
endHourTime
=
calendar
.
getTime
();
Date
startHour
;
DataPower
dataPower
=
new
DataPower
();
try
{
//构建查询语句 时间条件:2-8 8-14 14-20 20-2
for
(
int
i
=
1
;
i
<
6
;
i
++)
{
startHour
=
DateUtil
.
offset
(
endHourTime
,
DateField
.
HOUR_OF_DAY
,
i
*
-
6
);
dataPower
.
getXAxis
().
add
(
DateUtil
.
formatDateTime
(
endHourTime
));
QueryRequestExt
requestz
=
QueryRequestExt
.
builder
()
.
start
(
startHour
.
getTime
()
+
""
)
.
end
(
endHourTime
.
getTime
()
+
""
)
.
build
();
endHourTime
=
startHour
;
for
(
String
key
:
keys
)
{
//查询
String
kkscode
=
key
.
split
(
"\\|"
)[
1
];
requestz
.
addQuery
(
QueryExt
.
builder
()
.
aggregator
(
Aggregator
.
AVG
)
.
metric
(
kkscode
)
.
build
()
);
}
QueryResponse
response
=
null
;
response
=
OpentsdbOkHttpClient
.
query
(
requestz
);
//根据返回的的数据 处理点
List
<
QueryResult
>
results
=
response
.
getResults
();
for
(
QueryResult
queryResult
:
results
)
{
boolean
flag
=
dataPower
.
getDataList
().
stream
().
noneMatch
(
arg
->
arg
.
getName
().
equals
(
queryResult
.
getMetric
()));
if
(!
flag
)
{
dataPower
.
getDataList
().
forEach
(
arg
->
{
if
(
arg
.
getName
().
equals
(
queryResult
.
getMetric
()))
{
for
(
Long
key
:
queryResult
.
getDps
().
keySet
())
{
arg
.
getValue
().
add
(
queryResult
.
getDps
().
get
(
key
)
+
""
);
}
}
});
}
else
{
DataPower
.
PowerPoints
powerPoints
=
new
DataPower
.
PowerPoints
();
powerPoints
.
setName
(
queryResult
.
getMetric
());
for
(
Long
key
:
queryResult
.
getDps
().
keySet
())
{
powerPoints
.
getValue
().
add
(
queryResult
.
getDps
().
get
(
key
)
+
""
);
}
dataPower
.
getDataList
().
add
(
powerPoints
);
}
}
//处理获取到的数据
}
}
catch
(
Exception
e
)
{
return
BaseResponse
.
errorMsg
(
"查询失败"
);
}
for
(
DataPower
.
PowerPoints
powerPoints
:
dataPower
.
getDataList
())
{
//todo 这里求的是平均数理应只有一个指 但是他不是 它没平均
//todo 下面强制删除 数据对的时候记得删除
List
<
String
>
list
=
powerPoints
.
getValue
().
isEmpty
()
?
new
ArrayList
<>()
:
powerPoints
.
getValue
().
subList
(
0
,
5
);
powerPoints
.
setValue
(
list
);
String
nameByKKSCode
=
getNameByKKSCode
(
powerPoints
.
getName
(),
deviceInfoVos
);
powerPoints
.
setName
(
nameByKKSCode
);
}
return
BaseResponse
.
okData
(
dataPower
);
}
/**
* 根据kksCode反向找到 所属的机组名和kksCode所属的测点类型
*
* @param kksCode kksCode
* @param deviceInfoVos 电厂配置类
* @return 电厂名字和测点名字
*/
private
HashMap
<
String
,
String
>
findDeviceNameAndCharacterName
(
String
kksCode
,
List
<
DeviceInfoVo
>
deviceInfoVos
)
{
HashMap
<
String
,
String
>
rts
=
new
HashMap
<>(
2
);
//由kksCode向上找到device机组名和测点名字
AtomicReference
<
String
>
characterName
=
new
AtomicReference
<>();
DeviceInfoVo
device
=
deviceInfoVos
.
stream
().
filter
(
devices
->
devices
.
getUnitInfoVos
().
stream
().
anyMatch
(
units
->
units
.
getCharacters
().
stream
().
anyMatch
(
characters
->
{
if
(
kksCode
.
equals
(
characters
.
getKksCode
()))
{
characterName
.
set
(
characters
.
getCpName
());
return
true
;
}
else
{
return
false
;
}
}))
).
findFirst
().
orElse
(
null
);
ResponseEnum
.
LICENCE_NOT_FOUND
.
assertNotNull
(
device
);
rts
.
put
(
"deviceName"
,
device
.
getDeviceName
());
rts
.
put
(
"characterName"
,
characterName
.
get
());
return
rts
;
}
/**
* 通过kksCode获取 测点名字
*
* @param KKSCode 测点编号
* @return 测点名字
*/
private
String
getNameByKKSCode
(
String
KKSCode
,
List
<
DeviceInfoVo
>
deviceInfoVos
)
{
AtomicReference
<
String
>
rts
=
new
AtomicReference
<>(
""
);
deviceInfoVos
.
forEach
(
devices
->
devices
.
getUnitInfoVos
().
forEach
(
units
->
{
units
.
getCharacters
().
forEach
(
characters
->
{
if
(
KKSCode
.
equals
(
characters
.
getCpName
()))
{
rts
.
set
(
devices
.
getDeviceName
());
}
});
}));
return
rts
.
get
();
}
/**
* 将dataPower 的 X轴转换成机组 PowerPoints转换成设备
*
* @param dataPower
* @return
*/
private
DataPower
formatDataPowerXY
(
DataPower
dataPower
)
{
DataPower
rts
=
new
DataPower
();
//将x轴下沉到 PowerPoints
int
count
=
0
;
for
(
Object
x
:
dataPower
.
getXAxis
())
{
DataPower
.
PowerPoints
newPowerPoints
=
new
DataPower
.
PowerPoints
();
newPowerPoints
.
setName
(
x
+
""
);
rts
.
getDataList
().
add
(
newPowerPoints
);
for
(
DataPower
.
PowerPoints
powerPoints
:
dataPower
.
getDataList
())
{
if
(
powerPoints
.
getValue
().
isEmpty
())
{
newPowerPoints
.
setValue
(
new
ArrayList
<>());
}
else
{
newPowerPoints
.
getValue
().
add
(
powerPoints
.
getValue
().
get
(
count
));
}
}
count
++;
}
//将PowerPoints的name变成X轴
for
(
DataPower
.
PowerPoints
powerPoints
:
dataPower
.
getDataList
())
{
rts
.
getXAxis
().
add
(
powerPoints
.
getName
());
}
return
rts
;
}
}
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/service/IndexRealTimeDataServiceV0.java
deleted
100644 → 0
View file @
4a17a880
//package cn.wise.sc.energy.power.plant.business.service;
//
//import cn.hutool.core.date.DateField;
//import cn.hutool.core.date.DateUtil;
//import cn.wise.sc.energy.power.plant.business.bean.DataPower;
//import cn.wise.sc.energy.power.plant.business.domain.vo.CharacterParamInfoVo;
//import cn.wise.sc.energy.power.plant.business.domain.vo.DeviceInfoVo;
//import cn.wise.sc.energy.power.plant.business.domain.vo.UnitInfoVo;
//import cn.wise.sc.energy.power.plant.business.opentsdb.OpentsdbOkHttpClient;
//import cn.wise.sc.energy.power.plant.business.opentsdb.bean.QueryExt;
//import cn.wise.sc.energy.power.plant.business.opentsdb.bean.QueryRequestExt;
//import cn.wise.sc.energy.power.plant.business.service2.IDeviceInfoService;
//import cn.wise.sc.energy.power.plant.common.core.bean.BaseResponse;
//import cn.wise.sc.energy.power.plant.common.core.exception.ResponseEnum;
//import com.alibaba.fastjson.JSON;
//import lombok.extern.slf4j.Slf4j;
//import net.opentsdb.client.api.query.response.QueryResponse;
//import net.opentsdb.client.bean.Aggregator;
//import net.opentsdb.client.bean.QueryResult;
//import org.redisson.api.RBucket;
//import org.redisson.api.RedissonClient;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//
//import java.util.ArrayList;
//import java.util.Calendar;
//import java.util.Date;
//import java.util.HashMap;
//import java.util.List;
//import java.util.concurrent.atomic.AtomicReference;
//import java.util.regex.Matcher;
//import java.util.regex.Pattern;
//import java.util.stream.Collectors;
//
///**
// * @description: 首页实时数据
// * @author: 7
// * @create: 2020-05-25 10:40
// **/
//@Slf4j
//@Component
//@Deprecated
//public class IndexRealTimeDataServiceV0 {
// final
// RedissonClient redissonClient;
//
// @Autowired
// IDeviceInfoService iDeviceInfoService;
// public IndexRealTimeDataServiceV0(RedissonClient redissonClient) {
// this.redissonClient = redissonClient;
// }
//
// /**
// * 首页实时数据 各机组振动棒状对比图数据
// *
// * @param plantCode 电厂唯一标识
// * @return DataPower {@link DataPower}
// */
// public BaseResponse<DataPower> realTimeDataUnitLubrication(String plantCode) {
//
// List<DeviceInfoVo> deviceInfoVos = iDeviceInfoService.getDeviceUnitAndCharacterPlantCode(plantCode);
// //构建时间条件 前1s->当前时间 构建opentsdb查询条件
// //todo 正式时 使用下面的 1s-ago
// long end = 1590375153L;
// long start = end - 1;
// QueryRequestExt queryRequestExt = QueryRequestExt.builder()
// .start(start + "")
// .end(end + "")
//// .start("1s-ago")
// .build();
// //返回结果
// DataPower dataPower = new DataPower();
// dataPower.getXAxis().add("汽端轴承座振动(绝对值)1");
// dataPower.getXAxis().add("汽端轴承座振动(绝对值)2");
// dataPower.getXAxis().add("汽端轴承振动1");
// dataPower.getXAxis().add("汽端轴承振动2");
// //循环处理机组的的轴系振动
// for (DeviceInfoVo device : deviceInfoVos) {
// //构造value的key
// DataPower.PowerPoints powerPoint = new DataPower.PowerPoints();
// powerPoint.setName(device.getDeviceName());
// //构造返回数据类型
// dataPower.getDataList().add(powerPoint);
//
// //获取振动数据所在的部件信息 n号机轴振监测
// UnitInfoVo lubricationUnit = device.getUnitInfoVos().stream().filter(unit -> {
// //todo 1号机轴振监测 这个名字是写死的
// return unit.getUnitName().contains("号机轴振监测");
// }).findFirst().orElse(null);
// if (lubricationUnit != null) {
//
// //筛选 1F汽端轴承座振动(绝对值)1 汽端轴承座振动(绝对值)2 汽端轴承振动1 F汽端轴承振动2
// List<CharacterParamInfoVo> waitDoLubricationCharacterParamInfoVo = lubricationUnit.getCharacters().stream().filter(characters ->
// characters.getCpName().contains("F汽端轴承座振动(绝对值)")
// || characters.getCpName().contains("F汽端轴承振动1(CY511)")
// || characters.getCpName().contains("F汽端轴承振动2(CY512)")).collect(Collectors.toList());
// //集合为空时 抛出异常
// if (waitDoLubricationCharacterParamInfoVo.size() != 0) {
// ResponseEnum.COLLECTION_NOT_ILLEGAL.assertCollectionNotILLEGAL(waitDoLubricationCharacterParamInfoVo);
// waitDoLubricationCharacterParamInfoVo.stream().forEach(characters -> {
// String kkscode = characters.getKksCode();
// QueryExt queryExt = QueryExt.builder()
// .aggregator(Aggregator.AVG)
// .metric(kkscode)
// .build();
// queryRequestExt.addQuery(queryExt);
// });
// }
// }
// }
// try {
// QueryResponse response = OpentsdbOkHttpClient.query(queryRequestExt);
// List<QueryResult> results = response.getResults();
// //处理X轴坐标
// results.forEach(arg -> {
// String kksCode = arg.getMetric();
// HashMap<String, String> deviceNameAndCharacterName = findDeviceNameAndCharacterName(kksCode, deviceInfoVos);
// String deviceName = deviceNameAndCharacterName.get("deviceName");
// String characterName = deviceNameAndCharacterName.get("characterName");
//
// int xCount = dataPower.getXAxis().size();
// int yCount = dataPower.getDataList().size();
// int xPosition = -1, yPosition = -1;
// for (int i = 0; i < xCount; i++) {
// if (characterName.contains(dataPower.getXAxis().get(i).toString())) {
// xPosition = i;
// }
// }
// for (int i = 0; i < yCount; i++) {
// if (deviceName.equals(dataPower.getDataList().get(i).getName())) {
// yPosition = i;
// }
// }
// //关联数据位置
// for (Long timeKey : arg.getDps().keySet()) {
// dataPower.getDataList().get(yPosition).getValue().add(xPosition, String.valueOf(arg.getDps().get(timeKey)));
// }
// });
// //处理X轴坐标名称
// return BaseResponse.okData(formatDataPowerXY(dataPower));
// } catch (Exception e) {
// log.error("请求各机组实时振动对比数据失败!");
// //抛出业务异常
// ResponseEnum.OPEN_TS_DB_CONNECTION_ERROR.assertIsException(e);
// }
// return BaseResponse.errorMsg("获取失败");
// }
//
// /**
// * 首页实时数据 三相电压/电流 定子电压/电流 (汇总实时数据)
// *
// * @param plantCode 点电唯一标识
// * @return DataPower
// */
// public BaseResponse<DataPower> realTimeDataVoltage(String plantCode) {
//
// String basicOptionsJSON = getBasicOptions(plantCode);
// List<DeviceInfoVo> deviceInfoVos = iDeviceInfoService.getDeviceUnitAndCharacterPlantCode(plantCode);
// //构建时间条件 前1s->当前时间 构建opentsdb查询条件
// long end = 1590373722L;
// long start = end - 1;
//
// QueryRequestExt queryRequestExt = QueryRequestExt.builder()
// .start(start + "")
// .end(end + "")
//// .start("1s-ago")
// .build();
// //返回结果
// DataPower dataPower = new DataPower();
// dataPower.getXAxis().add("FA相电压");
// dataPower.getXAxis().add("FB相电压");
// dataPower.getXAxis().add("FC相电压1");
// dataPower.getXAxis().add("FA相电流");
// dataPower.getXAxis().add("FB相电流");
// dataPower.getXAxis().add("FC相电流");
// //循环处理机组的的轴系振动
// for (DeviceInfoVo device : deviceInfoVos) {
//
// //获取定子电流电压数据所在的部件信息 n号机定子电流电压
// UnitInfoVo lubricationUnit = device.getUnitInfoVos().stream().filter(unit -> {
// //todo 1号机定子电流电压 这个名字是写死的
// return unit.getUnitName().contains("号机定子电流电压");
// }).findFirst().orElse(null);
// if (lubricationUnit != null) {
// //构造value的key
// DataPower.PowerPoints powerPoint = new DataPower.PowerPoints();
// powerPoint.setName(device.getDeviceName());
// //构造返回数据类型
// dataPower.getDataList().add(powerPoint);
// //筛选 1FA相电压 1FB相电压 1FC相电压1 1FA相电流 1FB相电流 1FC相电流
// List<CharacterParamInfoVo> waitDoLubricationCharacterParamInfoVo =
// lubricationUnit.getCharacters().stream().filter(characters ->
// characters.getCpName().contains("FA相电压")
// || characters.getCpName().contains("FB相电压")
// || characters.getCpName().contains("FC相电压1")
// || characters.getCpName().contains("FA相电流")
// || characters.getCpName().contains("FB相电流")
// || characters.getCpName().contains("FC相电流")
// ).collect(Collectors.toList());
// //集合为空时 抛出异常
// if (waitDoLubricationCharacterParamInfoVo.size() == 0) {
// continue;
// }
// ResponseEnum.COLLECTION_NOT_ILLEGAL.assertCollectionNotILLEGAL(waitDoLubricationCharacterParamInfoVo);
// waitDoLubricationCharacterParamInfoVo.forEach(characters -> {
// String kkscode = characters.getKksCode();
// QueryExt queryExt = QueryExt.builder()
// .aggregator(Aggregator.NONE)
// .metric(kkscode)
// .build();
// queryRequestExt.addQuery(queryExt);
// });
// }
// }
// try {
// QueryResponse response = OpentsdbOkHttpClient.query(queryRequestExt);
// List<QueryResult> results = response.getResults();
// //处理X轴坐标
// results.forEach(arg -> {
// String kksCode = arg.getMetric();
// HashMap<String, String> deviceNameAndCharacterName = findDeviceNameAndCharacterName(kksCode, deviceInfoVos);
// String deviceName = deviceNameAndCharacterName.get("deviceName");
// String characterName = deviceNameAndCharacterName.get("characterName");
//
// int xCount = dataPower.getXAxis().size();
// int yCount = dataPower.getDataList().size();
// int xPosition = -1, yPosition = -1;
// for (int i = 0; i < xCount; i++) {
// if (characterName.contains(dataPower.getXAxis().get(i) + "")) {
// xPosition = i;
// }
// }
// for (int i = 0; i < yCount; i++) {
// if (deviceName.equals(dataPower.getDataList().get(i).getName())) {
// yPosition = i;
// }
// }
// //关联数据位置
// for (Long timeKey : arg.getDps().keySet()) {
// dataPower.getDataList().get(yPosition).getValue().add(xPosition, arg.getDps().get(timeKey) + "");
// }
// });
//
// DataPower rts = new DataPower();
// List<Integer> currentPositions = new ArrayList<>(3);
// List<Integer> voltagePositions = new ArrayList<>(3);
//
// //获取电流和电压的索引位置
// dataPower.getXAxis().forEach(arg -> {
// if (arg.toString().contains("电流")) {
// currentPositions.add(dataPower.getXAxis().indexOf(arg));
// }
// if (arg.toString().contains("电压")) {
// voltagePositions.add(dataPower.getXAxis().indexOf(arg));
// }
// });
//
// rts.getXAxis().add("三项电流");
// rts.getXAxis().add("三项电压");
// rts.getXAxis().add("定子电流");
// rts.getXAxis().add("定子电压");
//
// dataPower.getDataList().forEach(arg -> {
// DataPower.PowerPoints powerPoints = new DataPower.PowerPoints();
// powerPoints.setName(arg.getName());
// if (arg.getValue() != null && arg.getValue().size() != 0) {
// double currentTotal =
// Double.parseDouble(arg.getValue().get(currentPositions.get(0)))
// + Double.parseDouble(arg.getValue().get(currentPositions.get(1)))
// + Double.parseDouble(arg.getValue().get(currentPositions.get(2)));
// double voltageTotal =
// Double.parseDouble(arg.getValue().get(voltagePositions.get(0)))
// + Double.parseDouble(arg.getValue().get(voltagePositions.get(1)))
// + Double.parseDouble(arg.getValue().get(voltagePositions.get(2)));
// powerPoints.getValue().add(currentTotal + "");
// powerPoints.getValue().add(voltageTotal + "");
// powerPoints.getValue().add(arg.getValue().get(currentPositions.get(1)));
// powerPoints.getValue().add(arg.getValue().get(currentPositions.get(2)));
//
// rts.getDataList().add(powerPoints);
// }
// });
//
// //处理X轴坐标名称
// return BaseResponse.okData(formatDataPowerXY(rts));
// } catch (Exception e) {
// log.error("请求各机组实时振动对比数据失败!");
// //抛出业务异常
// ResponseEnum.OPEN_TS_DB_CONNECTION_ERROR.assertIsException(e);
// }
// return BaseResponse.errorMsg("获取失败");
// }
//
// /**
// * 首页实时数据 各机组轴瓦温度柱状图
// *
// * @param plantCode 电厂名字
// * @return DataPower
// */
// public BaseResponse<DataPower> realTimeDataBearingBushC(String plantCode) {
//
// String basicOptionsJSON = getBasicOptions(plantCode);
// BasicOption basicOption = JSON.parseObject(basicOptionsJSON, BasicOption.class);
// //获取所有机组信息
// List<Devices> devices = basicOption.getDevices();
// //构建时间条件 前1s->当前时间 构建opentsdb查询条件
// long end = 1590373710L;
// long start = end - 1;
// QueryRequestExt queryRequestExt = QueryRequestExt.builder()
// .start(start + "")
// .end(end + "")
//// .start("1s-ago")
// .build();
//
// DataPower dataPower = new DataPower();
// dataPower.getXAxis().add("汽端轴瓦温度");
// dataPower.getXAxis().add("励端轴瓦温度");
// dataPower.getXAxis().add("出线端端轴瓦温温度");
// dataPower.getXAxis().add("出线端轴瓦温度");
// //循环处理机组的的轴系振动
// for (Devices device : devices) {
//
// //获取润滑参数 n号机润滑参数
// UnitInfoVo lubricationUnit = device.getUnitInfoVos().stream().filter(unit -> {
// //todo 1号机润滑参数 这个名字是写死的
// return unit.getUnitName().contains("号机润滑参数");
// }).findFirst().orElse(null);
// if (lubricationUnit != null) {
// //构造value的key
// DataPower.PowerPoints powerPoint = new DataPower.PowerPoints();
// powerPoint.setName(device.getDeviceName());
// //构造返回数据类型
// dataPower.getDataList().add(powerPoint);
// //筛选 1F汽端轴瓦温度 1F汽端轴瓦温度A 1F励端轴瓦温度 1F励端轴瓦温度A
// List<CharacterParamInfoVo> waitDoLubricationCharacterParamInfoVo = lubricationUnit.getCharacters().stream().filter(characters ->
// characters.getCpName().contains("F汽端轴瓦温度")
// || characters.getCpName().contains("F汽端轴瓦温度A")
// || characters.getCpName().contains("F励端轴瓦温度")
// || characters.getCpName().contains("F励端轴瓦温度A")
// ).collect(Collectors.toList());
//
// if (waitDoLubricationCharacterParamInfoVo.size() != 0) {
// //集合为空时 抛出异常
// ResponseEnum.COLLECTION_NOT_ILLEGAL.assertCollectionNotILLEGAL(waitDoLubricationCharacterParamInfoVo);
//
// waitDoLubricationCharacterParamInfoVo.forEach(characters -> {
// String kkscode = characters.getKksCode();
// QueryExt queryExt = QueryExt.builder()
// .aggregator(Aggregator.NONE)
// .metric(kkscode)
// .build();
// queryRequestExt.addQuery(queryExt);
// });
// }
// }
// }
//
// try {
// QueryResponse response = OpentsdbOkHttpClient.query(queryRequestExt);
//
// List<QueryResult> results = response.getResults();
// //处理X轴坐标
// results.forEach(arg -> {
// String kksCode = arg.getMetric();
// HashMap<String, String> deviceNameAndCharacterName = findDeviceNameAndCharacterName(kksCode, basicOption);
// String deviceName = deviceNameAndCharacterName.get("deviceName");
// String characterName = deviceNameAndCharacterName.get("characterName");
//
// int xCount = dataPower.getXAxis().size();
// int yCount = dataPower.getDataList().size();
// int xPosition = -1, yPosition = -1;
// for (int i = 0; i < xCount; i++) {
// if (characterName.contains(dataPower.getXAxis().get(i).toString())) {
// xPosition = i;
// }
// }
// for (int i = 0; i < yCount; i++) {
// if (deviceName.equals(dataPower.getDataList().get(i).getCpName())) {
// yPosition = i;
// }
// }
// //关联数据位置
// for (Long timeKey : arg.getDps().keySet()) {
// dataPower.getDataList().get(yPosition).getValue().add(xPosition, String.valueOf(arg.getDps().get(timeKey)));
// }
// });
// //处理X轴坐标名称
// return BaseResponse.okData(formatDataPowerXY(dataPower));
// } catch (Exception e) {
// log.error("获取个机组轴瓦温度柱状图失败!");
// //抛出业务异常
// ResponseEnum.OPEN_TS_DB_CONNECTION_ERROR.assertIsException(e);
// }
// return BaseResponse.errorMsg("获取失败");
// }
//
// /**
// * 获取首页3D部件下测点信息和值
// *
// * @param unitNo 部件唯一标识
// * @param plantCode 电厂唯一标识
// * @return DataPower
// */
// public BaseResponse<DataPower> realTimeData3DModel(String unitNo, String plantCode) {
//
// String basicOptions = getBasicOptions(plantCode);
// BasicOption basicOption = JSON.parseObject(basicOptions, BasicOption.class);
// AtomicReference<List<CharacterParamInfoVo>> listAtomicReference = new AtomicReference<>();
// basicOption.getDevices().forEach(devices -> devices.getUnitInfoVos().forEach(units -> {
// if (unitNo.equals(units.getUnitid())) {
// listAtomicReference.set(units.getCharacters());
// }
// }));
//
// List<CharacterParamInfoVo> characters = listAtomicReference.get();
// long endTime = 1590373722L;
// long startTime = endTime - 1;
//
// //组装当前部件下的所有测点请求
// QueryRequestExt queryRequestExt = QueryRequestExt.builder()
// .start(startTime + "")
// .end(endTime + "")
//// .start("1s-ago")
// .build();
// for (CharacterParamInfoVo character : characters) {
// QueryExt queryExt = QueryExt.builder()
// .metric(character.getKksCode())
// .aggregator(Aggregator.AVG)
// .build();
// queryRequestExt.addQuery(queryExt);
// }
//
// DataPower dataPower = new DataPower();
// try {
// //封装响应数据
// QueryResponse response = OpentsdbOkHttpClient.query(queryRequestExt);
// response.getResults().forEach(arg -> {
// DataPower.PowerPoints powerPoints = new DataPower.PowerPoints();
// powerPoints.setName(arg.getMetric());
// for (Long dataKey : arg.getDps().keySet()) {
// powerPoints.getValue().add(arg.getDps().get(dataKey).toString());
// }
// dataPower.getDataList().add(powerPoints);
// });
//
// //将kksCode 换成中文
// for (DataPower.PowerPoints powerPoints : dataPower.getDataList()) {
// characters.stream()
// .filter(characters1 -> characters1.getKksCode().equals(powerPoints.getCpName()))
// .findFirst().ifPresent(characters2 -> {
// powerPoints.setName(characters2.getCpName());
// List<String> subList = powerPoints.getValue().subList(0, 1);
// powerPoints.setValue(subList);
// });
// }
// return BaseResponse.okData(dataPower);
// } catch (Exception e) {
// ResponseEnum.OPEN_TS_DB_CONNECTION_ERROR.assertIsException(e);
// }
// return BaseResponse.errorMsg("查询失败!");
// }
//
// /**
// * 获取首页各机组功率趋势图
// *
// * @param plantCode 电厂唯一标识
// * @return 返回电压数据点线
// */
// public BaseResponse<DataPower> getIndexPowerInit(String plantCode) {
//
// String basicOptionsJSON = getBasicOptions(plantCode);
// BasicOption basicOption = JSON.parseObject(basicOptionsJSON, BasicOption.class);
//
// //待查询的key值 结构:电机名|功率kkscode
// List<String> keys = new ArrayList<>();
// //筛选出每个机组的名字
// String statorCurrent = "(号机定子电流电压\\s*)$";
// final Pattern endStatorCurrentPattern = Pattern.compile(statorCurrent, Pattern.MULTILINE);
// String power = "(F功率\\s*)$";
// final Pattern endFpower = Pattern.compile(power, Pattern.MULTILINE);
//
// basicOption.getDevices().forEach(devices -> {
// //正则匹配 已"号机定子电流电压"结尾
// UnitInfoVo units = devices.getUnitInfoVos().stream().filter(unit -> {
// final Matcher endStatorCurrentMatcher = endStatorCurrentPattern.matcher(unit.getUnitName());
// return endStatorCurrentMatcher.find();
// }).findFirst().orElse(null);
// //正则匹配 已"F功率"结尾
// ResponseEnum.LICENCE_NOT_FOUND.assertNotNull(units);
// CharacterParamInfoVo characters = units.getCharacters().stream().filter(character -> {
// final Matcher endFpowerMatcher = endFpower.matcher(character.getCpName());
// return endFpowerMatcher.find();
// }).findFirst().orElse(null);
//
// ResponseEnum.LICENCE_NOT_FOUND.assertNotNull(characters);
// String key = devices.getDeviceName() + "|" + characters.getKksCode();
// keys.add(key);
// });
//
// //计算当前需要的偏移量
// Calendar calendar = DateUtil.calendar();
// int nowHour = calendar.get(Calendar.HOUR_OF_DAY);
// int count = nowHour / 6;
// int endHour = (count - 1) * 6 + 2;
// //构建结尾时间
// calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH), endHour, 0);
// Date endHourTime = calendar.getTime();
// Date startHour;
// DataPower dataPower = new DataPower();
// try {
// //构建查询语句 时间条件:2-8 8-14 14-20 20-2
// for (int i = 1; i < 6; i++) {
//
// startHour = DateUtil.offset(endHourTime, DateField.HOUR_OF_DAY, i * -6);
// dataPower.getXAxis().add(DateUtil.formatDateTime(endHourTime));
// QueryRequestExt requestz = QueryRequestExt.builder()
// .start(startHour.getTime() + "")
// .end(endHourTime.getTime() + "")
// .build();
//
// endHourTime = startHour;
//
// for (String key : keys) {
// //查询
// String kkscode = key.split("\\|")[1];
// requestz.addQuery(QueryExt.builder()
// .aggregator(Aggregator.AVG)
// .metric(kkscode)
// .build()
// );
// }
// QueryResponse response = null;
//
// //todo 目前机组二没得数据 所以删掉 请去掉
// requestz.getQueries().remove(1);
// response = OpentsdbOkHttpClient.query(requestz);
// //根据返回的的数据 处理点
// List<QueryResult> results = response.getResults();
// for (QueryResult queryResult : results) {
// boolean flag = dataPower.getDataList().stream().filter(arg -> arg.getCpName() == queryResult.getMetric()).count() == 0;
// if (!flag) {
// dataPower.getDataList().forEach(arg -> {
// if (arg.getCpName().equals(queryResult.getMetric())) {
// for (Long key : queryResult.getDps().keySet()) {
// arg.getValue().add(queryResult.getDps().get(key) + "");
// }
// }
// });
// } else {
// DataPower.PowerPoints powerPoints = new DataPower.PowerPoints();
// powerPoints.setName(queryResult.getMetric());
// for (Long key : queryResult.getDps().keySet()) {
// powerPoints.getValue().add(queryResult.getDps().get(key) + "");
// }
//
// dataPower.getDataList().add(powerPoints);
// }
//
// }
// //处理获取到的数据
// }
// } catch (Exception e) {
// return BaseResponse.errorMsg("查询失败");
// }
//
// for (DataPower.PowerPoints powerPoints : dataPower.getDataList()) {
// //todo 这里求的是平均数理应只有一个指 但是他不是 它没平均
// //todo 下面强制删除 数据对的时候记得删除
// List<String> list = powerPoints.getValue().subList(0, 5);
// powerPoints.setValue(list);
//
// String nameByKKSCode = getNameByKKSCode(powerPoints.getCpName(), basicOption);
// powerPoints.setName(nameByKKSCode);
// }
//
// return BaseResponse.okData(dataPower);
// }
//
//
// /**
// * 根据kksCode反向找到 所属的机组名和kksCode所属的测点类型
// *
// * @param kksCode kksCode
// * @param basicOption 电厂配置类
// * @return 电厂名字和测点名字
// */
// private HashMap<String, String> findDeviceNameAndCharacterName(String kksCode, BasicOption basicOption) {
//
// HashMap<String, String> rts = new HashMap<>(2);
// //由kksCode向上找到device机组名和测点名字
// AtomicReference<String> characterName = new AtomicReference<>();
// Devices device = basicOption.getDevices().stream().filter(devices ->
// devices.getUnitInfoVos().stream().anyMatch(units ->
// units.getCharacters().stream().anyMatch(characters -> {
// if (kksCode.equals(characters.getKksCode())) {
// characterName.set(characters.getCpName());
// return true;
// } else {
// return false;
// }
// }))
// ).findFirst().orElse(null);
// assert device != null;
// rts.put("deviceName", device.getDeviceName());
// rts.put("characterName", characterName.get());
// return rts;
// }
//
// /**
// * 根据点工厂唯一标识 获取电厂配置
// *
// * @param plantCode 电厂唯一标识
// * @return 电厂配置JSON
// */
// private String getBasicOptions(String plantCode) {
//
// ResponseEnum.LICENCE_NOT_FOUND.assertNotEmpty(plantCode);
// RBucket<String> bucket = redissonClient.getBucket(plantCode);
// if (!bucket.isExists()) {
// String turbineConfigJson = dataBaseService.getTurbineConfigJson(plantCode);
// bucket.set(turbineConfigJson);
// return turbineConfigJson;
// } else {
// return bucket.get();
// }
// }
//
// /**
// * 通过kksCode获取 测点名字
// *
// * @param KKSCode 测点编号
// * @return 测点名字
// */
// private String getNameByKKSCode(String KKSCode, BasicOption basicOption) {
// AtomicReference<String> rts = new AtomicReference<>("");
// basicOption.getDevices().forEach(devices -> {
// devices.getUnitInfoVos().forEach(units -> {
// units.getCharacters().forEach(characters -> {
// if (KKSCode.equals(characters.getKksCode())) {
// rts.set(devices.getDeviceName());
// }
// });
// });
// });
//
// return rts.get();
// }
//
// /**
// * 将dataPower 的 X轴转换成机组 PowerPoints转换成设备
// *
// * @param dataPower
// * @return
// */
// private DataPower formatDataPowerXY(DataPower dataPower) {
// DataPower rts = new DataPower();
//
// //将x轴下沉到 PowerPoints
// int count = 0;
// for (Object x : dataPower.getXAxis()) {
// DataPower.PowerPoints newPowerPoints = new DataPower.PowerPoints();
// newPowerPoints.setName(x + "");
// rts.getDataList().add(newPowerPoints);
// for (DataPower.PowerPoints powerPoints : dataPower.getDataList()) {
// if (powerPoints.getValue().size() != 0) {
// newPowerPoints.getValue().add(powerPoints.getValue().get(count));
// }
// }
// }
//
// //将PowerPoints的name变成X轴
// for (DataPower.PowerPoints powerPoints : dataPower.getDataList()) {
// rts.getXAxis().add(powerPoints.getCpName());
// }
//
// return rts;
// }
//}
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/service/IndexRealTimeDataServiceV2.java
deleted
100644 → 0
View file @
4a17a880
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
service
;
import
cn.hutool.core.date.DateField
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.lang.Assert
;
import
cn.wise.sc.energy.power.plant.business.bean.DataPower
;
import
cn.wise.sc.energy.power.plant.business.constant.RealTimeDataChartType
;
import
cn.wise.sc.energy.power.plant.business.domain.vo.CharacterParamInfoVo
;
import
cn.wise.sc.energy.power.plant.business.domain.vo.DeviceInfoVo
;
import
cn.wise.sc.energy.power.plant.business.domain.vo.UnitInfoVo
;
import
cn.wise.sc.energy.power.plant.business.opentsdb.OpentsdbOkHttpClient
;
import
cn.wise.sc.energy.power.plant.business.opentsdb.bean.QueryExt
;
import
cn.wise.sc.energy.power.plant.business.opentsdb.bean.QueryRequestExt
;
import
cn.wise.sc.energy.power.plant.business.service2.ICharacterParamService
;
import
cn.wise.sc.energy.power.plant.business.service2.IDeviceInfoService
;
import
cn.wise.sc.energy.power.plant.business.service2.IUnitInfoService
;
import
cn.wise.sc.energy.power.plant.common.core.bean.BaseResponse
;
import
cn.wise.sc.energy.power.plant.common.core.exception.ResponseEnum
;
import
com.alibaba.fastjson.JSON
;
import
lombok.extern.slf4j.Slf4j
;
import
net.opentsdb.client.api.query.request.QueryRequest
;
import
net.opentsdb.client.api.query.response.QueryResponse
;
import
net.opentsdb.client.bean.Aggregator
;
import
net.opentsdb.client.bean.QueryResult
;
import
org.redisson.api.RBucket
;
import
org.redisson.api.RedissonClient
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.concurrent.atomic.AtomicReference
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
java.util.stream.Collectors
;
/**
* @description: 首页实时数据
* @author: 7
* @create: 2020-05-25 10:40
**/
@Slf4j
@Component
public
class
IndexRealTimeDataServiceV2
{
@Autowired
RedissonClient
redissonClient
;
@Autowired
IDeviceInfoService
iDeviceInfoService
;
@Autowired
IUnitInfoService
iUnitInfoService
;
@Autowired
ICharacterParamService
iCharacterParamService
;
public
IndexRealTimeDataServiceV2
(
RedissonClient
redissonClient
)
{
this
.
redissonClient
=
redissonClient
;
}
/**
* 首页实时数据 各机组振动棒状对比图数据
*
* @param plantCode 电厂唯一标识
* @return DataPower {@link DataPower}
*/
public
BaseResponse
<
DataPower
>
realTimeDataUnitLubrication
(
String
plantCode
)
{
//获取当前电厂下的所有设备
List
<
DeviceInfoVo
>
deviceInfoVos
=
iDeviceInfoService
.
getDeviceUnitAndCharacterPlantCode
(
plantCode
);
//todo 正式时 使用下面的 1s-ago
long
end
=
1590375153L
;
long
start
=
end
-
1
;
QueryRequestExt
queryRequestExt
=
QueryRequestExt
.
builder
()
// .start(start + "")
// .end(end + "")
.
start
(
"100h-ago"
)
.
build
();
//返回结果
DataPower
dataPower
=
new
DataPower
();
dataPower
.
getXAxis
().
add
(
"汽端座振X"
);
dataPower
.
getXAxis
().
add
(
"汽端轴振X"
);
dataPower
.
getXAxis
().
add
(
"励端座振X"
);
dataPower
.
getXAxis
().
add
(
"励端轴振X"
);
//循环处理机组的的轴系振动
for
(
DeviceInfoVo
device
:
deviceInfoVos
)
{
//构造value的key
DataPower
.
PowerPoints
powerPoint
=
new
DataPower
.
PowerPoints
();
powerPoint
.
setName
(
device
.
getDeviceName
());
//构造返回数据类型
dataPower
.
getDataList
().
add
(
powerPoint
);
//获取振动数据所在的部件信息 n号机轴振监测
UnitInfoVo
lubricationUnit
=
device
.
getUnitInfoVos
().
stream
().
filter
(
unit
->
{
//todo 1号机轴振监测 这个名字是写死的
return
unit
.
getUnitName
().
contains
(
"轴系振动监测"
);
}).
findFirst
().
orElse
(
null
);
if
(
lubricationUnit
!=
null
)
{
//筛选 1F汽端轴承座振动(绝对值)1 汽端轴承座振动(绝对值)2 汽端轴承振动1 F汽端轴承振动2
List
<
CharacterParamInfoVo
>
waitDoLubricationCharacterParamInfoVo
=
lubricationUnit
.
getCharacters
().
stream
().
filter
(
characters
->
characters
.
getCpName
().
contains
(
"F汽端座振X"
)
||
characters
.
getCpName
().
contains
(
"F汽端轴振X"
)
||
characters
.
getCpName
().
contains
(
"F励端座振X"
)
||
characters
.
getCpName
().
contains
(
"F励端轴振X"
)
).
collect
(
Collectors
.
toList
());
//集合为空时 抛出异常
if
(
waitDoLubricationCharacterParamInfoVo
.
size
()
!=
0
)
{
ResponseEnum
.
COLLECTION_NOT_ILLEGAL
.
assertCollectionNotILLEGAL
(
waitDoLubricationCharacterParamInfoVo
);
waitDoLubricationCharacterParamInfoVo
.
forEach
(
characters
->
{
String
kkscode
=
characters
.
getKksCode
();
QueryExt
queryExt
=
QueryExt
.
builder
()
.
aggregator
(
Aggregator
.
AVG
)
.
metric
(
kkscode
)
.
build
();
queryRequestExt
.
addQuery
(
queryExt
);
});
}
}
}
try
{
QueryResponse
response
=
OpentsdbOkHttpClient
.
query
(
queryRequestExt
);
List
<
QueryResult
>
results
=
response
.
getResults
();
//处理X轴坐标
results
.
forEach
(
arg
->
{
String
kksCode
=
arg
.
getMetric
();
HashMap
<
String
,
String
>
deviceNameAndCharacterName
=
findDeviceNameAndCharacterName
(
kksCode
,
deviceInfoVos
);
String
deviceName
=
deviceNameAndCharacterName
.
get
(
"deviceName"
);
String
characterName
=
deviceNameAndCharacterName
.
get
(
"characterName"
);
int
xCount
=
dataPower
.
getXAxis
().
size
();
int
yCount
=
dataPower
.
getDataList
().
size
();
int
xPosition
=
-
1
,
yPosition
=
-
1
;
for
(
int
i
=
0
;
i
<
xCount
;
i
++)
{
if
(
characterName
.
contains
(
dataPower
.
getXAxis
().
get
(
i
).
toString
()))
{
xPosition
=
i
;
}
}
for
(
int
i
=
0
;
i
<
yCount
;
i
++)
{
if
(
deviceName
.
equals
(
dataPower
.
getDataList
().
get
(
i
).
getName
()))
{
yPosition
=
i
;
}
}
//关联数据位置
for
(
Long
timeKey
:
arg
.
getDps
().
keySet
())
{
dataPower
.
getDataList
().
get
(
yPosition
).
getValue
().
add
(
xPosition
,
String
.
valueOf
(
arg
.
getDps
().
get
(
timeKey
)));
}
});
//处理X轴坐标名称
return
BaseResponse
.
okData
(
formatDataPowerXY
(
dataPower
));
}
catch
(
Exception
e
)
{
log
.
error
(
"请求各机组实时振动对比数据失败!"
);
//抛出业务异常
ResponseEnum
.
OPEN_TS_DB_CONNECTION_ERROR
.
assertIsException
(
e
);
}
return
BaseResponse
.
errorMsg
(
"获取失败"
);
}
/**
* 首页实时数据 三相电压/电流 定子电压/电流 (汇总实时数据)
*
* @param plantCode 点电唯一标识
* @return DataPower
*/
public
BaseResponse
<
DataPower
>
realTimeDataVoltage
(
String
plantCode
)
{
//获取当前电厂下的所有设备
List
<
DeviceInfoVo
>
deviceInfoVos
=
iDeviceInfoService
.
getDeviceUnitAndCharacterPlantCode
(
plantCode
);
//构建时间条件 前1s->当前时间 构建opentsdb查询条件
long
end
=
1590373722L
;
long
start
=
end
-
1
;
QueryRequestExt
queryRequestExt
=
QueryRequestExt
.
builder
()
// .start(start + "")
// .end(end + "")
.
start
(
"100h-ago"
)
.
build
();
//返回结果
DataPower
dataPower
=
new
DataPower
();
dataPower
.
getXAxis
().
add
(
"发电机定子A相电流"
);
dataPower
.
getXAxis
().
add
(
"发电机定子B相电流"
);
dataPower
.
getXAxis
().
add
(
"发电机定子C相电流"
);
dataPower
.
getXAxis
().
add
(
"发电机定子AB线电压"
);
dataPower
.
getXAxis
().
add
(
"发电机定子BC线电压"
);
dataPower
.
getXAxis
().
add
(
"发电机定子CA线电压"
);
//循环处理机组的的轴系振动
for
(
DeviceInfoVo
deviceInfoVo
:
deviceInfoVos
)
{
if
(!
deviceInfoVo
.
getDeviceName
().
contains
(
"2号"
))
{
continue
;
}
//获取定子电流电压数据所在的部件信息 n号机定子电流电压
UnitInfoVo
lubricationUnit
=
deviceInfoVo
.
getUnitInfoVos
()
.
stream
().
filter
(
unit
->
{
//todo 1号机定子电流电压 这个名字是写死的
return
unit
.
getUnitName
().
contains
(
"定子电气参数监测"
);
}).
findFirst
().
orElse
(
null
);
//构造value的key
DataPower
.
PowerPoints
powerPoint
=
new
DataPower
.
PowerPoints
();
powerPoint
.
setName
(
deviceInfoVo
.
getDeviceName
());
if
(
lubricationUnit
!=
null
)
{
//构造返回数据类型
dataPower
.
getDataList
().
add
(
powerPoint
);
//筛选 1FA相电压 1FB相电压 1FC相电压1 1FA相电流 1FB相电流 1FC相电流
List
<
CharacterParamInfoVo
>
waitDoLubricationCharacterParamInfoVo
=
lubricationUnit
.
getCharacters
().
stream
().
filter
(
characters
->
characters
.
getCpName
().
contains
(
"F发电机定子A相电流"
)
||
characters
.
getCpName
().
contains
(
"F发电机定子AB线电压"
)
||
characters
.
getCpName
().
contains
(
"F发电机定子BC线电压"
)
||
characters
.
getCpName
().
contains
(
"F发电机定子CA线电压"
)
||
characters
.
getCpName
().
contains
(
"F发电机定子B相电流"
)
||
characters
.
getCpName
().
contains
(
"F发电机定子C相电流"
)
).
collect
(
Collectors
.
toList
());
//集合为空时 抛出异常
if
(
waitDoLubricationCharacterParamInfoVo
.
size
()
==
0
)
{
continue
;
}
ResponseEnum
.
COLLECTION_NOT_ILLEGAL
.
assertCollectionNotILLEGAL
(
waitDoLubricationCharacterParamInfoVo
);
waitDoLubricationCharacterParamInfoVo
.
forEach
(
characters
->
{
String
kkscode
=
characters
.
getKksCode
();
QueryExt
queryExt
=
QueryExt
.
builder
()
.
aggregator
(
Aggregator
.
NONE
)
.
metric
(
kkscode
)
.
build
();
queryRequestExt
.
addQuery
(
queryExt
);
});
}
}
try
{
QueryResponse
response
=
OpentsdbOkHttpClient
.
query
(
queryRequestExt
);
List
<
QueryResult
>
results
=
response
.
getResults
();
//处理X轴坐标
results
.
forEach
(
arg
->
{
String
kksCode
=
arg
.
getMetric
();
HashMap
<
String
,
String
>
deviceNameAndCharacterName
=
findDeviceNameAndCharacterName
(
kksCode
,
deviceInfoVos
);
String
deviceName
=
deviceNameAndCharacterName
.
get
(
"deviceName"
);
String
characterName
=
deviceNameAndCharacterName
.
get
(
"characterName"
);
int
xCount
=
dataPower
.
getXAxis
().
size
();
int
yCount
=
dataPower
.
getDataList
().
size
();
int
xPosition
=
-
1
,
yPosition
=
-
1
;
for
(
int
i
=
0
;
i
<
xCount
;
i
++)
{
if
(
characterName
.
contains
(
dataPower
.
getXAxis
().
get
(
i
)
+
""
))
{
xPosition
=
i
;
}
}
for
(
int
i
=
0
;
i
<
yCount
;
i
++)
{
if
(
deviceName
.
equals
(
dataPower
.
getDataList
().
get
(
i
).
getName
()))
{
yPosition
=
i
;
}
}
//关联数据位置
for
(
Long
timeKey
:
arg
.
getDps
().
keySet
())
{
dataPower
.
getDataList
().
get
(
yPosition
).
getValue
().
add
(
xPosition
,
arg
.
getDps
().
get
(
timeKey
)
+
""
);
}
});
DataPower
rts
=
new
DataPower
();
List
<
Integer
>
currentPositions
=
new
ArrayList
<>(
3
);
List
<
Integer
>
voltagePositions
=
new
ArrayList
<>(
3
);
//获取电流和电压的索引位置
dataPower
.
getXAxis
().
forEach
(
arg
->
{
if
(
arg
.
toString
().
contains
(
"电流"
))
{
currentPositions
.
add
(
dataPower
.
getXAxis
().
indexOf
(
arg
));
}
if
(
arg
.
toString
().
contains
(
"电压"
))
{
voltagePositions
.
add
(
dataPower
.
getXAxis
().
indexOf
(
arg
));
}
});
rts
.
getXAxis
().
add
(
"三项电流"
);
rts
.
getXAxis
().
add
(
"三项电压"
);
rts
.
getXAxis
().
add
(
"定子电流"
);
rts
.
getXAxis
().
add
(
"定子电压"
);
dataPower
.
getDataList
().
forEach
(
arg
->
{
DataPower
.
PowerPoints
powerPoints
=
new
DataPower
.
PowerPoints
();
powerPoints
.
setName
(
arg
.
getName
());
if
(
arg
.
getValue
()
!=
null
&&
arg
.
getValue
().
size
()
!=
0
)
{
double
currentTotal
=
Double
.
parseDouble
(
arg
.
getValue
().
get
(
currentPositions
.
get
(
0
)))
+
Double
.
parseDouble
(
arg
.
getValue
().
get
(
currentPositions
.
get
(
1
)))
+
Double
.
parseDouble
(
arg
.
getValue
().
get
(
currentPositions
.
get
(
2
)));
double
voltageTotal
=
Double
.
parseDouble
(
arg
.
getValue
().
get
(
voltagePositions
.
get
(
0
)))
+
Double
.
parseDouble
(
arg
.
getValue
().
get
(
voltagePositions
.
get
(
1
)))
+
Double
.
parseDouble
(
arg
.
getValue
().
get
(
voltagePositions
.
get
(
2
)));
powerPoints
.
getValue
().
add
(
currentTotal
+
""
);
powerPoints
.
getValue
().
add
(
voltageTotal
+
""
);
powerPoints
.
getValue
().
add
(
arg
.
getValue
().
get
(
currentPositions
.
get
(
1
)));
powerPoints
.
getValue
().
add
(
arg
.
getValue
().
get
(
currentPositions
.
get
(
2
)));
rts
.
getDataList
().
add
(
powerPoints
);
}
});
//处理X轴坐标名称
return
BaseResponse
.
okData
(
formatDataPowerXY
(
rts
));
}
catch
(
Exception
e
)
{
log
.
error
(
"请求各机组电流对比数据失败!"
);
//抛出业务异常
ResponseEnum
.
OPEN_TS_DB_CONNECTION_ERROR
.
assertIsException
(
e
);
}
return
BaseResponse
.
errorMsg
(
"获取失败"
);
}
/**
* 首页实时数据 各机组轴瓦温度柱状图
*
* @param plantCode 电厂名字
* @return DataPower
*/
public
BaseResponse
<
DataPower
>
realTimeDataBearingBushC
(
String
plantCode
)
{
List
<
DeviceInfoVo
>
deviceInfoVos
=
iDeviceInfoService
.
getDeviceUnitAndCharacterPlantCode
(
plantCode
);
//构建时间条件 前1s->当前时间 构建opentsdb查询条件
long
end
=
1590373710L
;
long
start
=
end
-
1
;
QueryRequestExt
queryRequestExt
=
QueryRequestExt
.
builder
()
// .start(start + "")
// .end(end + "")
.
start
(
"100h-ago"
)
.
build
();
DataPower
dataPower
=
new
DataPower
();
dataPower
.
getXAxis
().
add
(
"汽端轴瓦温度4"
);
dataPower
.
getXAxis
().
add
(
"汽端轴瓦温度5"
);
dataPower
.
getXAxis
().
add
(
"励端轴瓦温度1"
);
dataPower
.
getXAxis
().
add
(
"励端轴瓦温度2"
);
//循环处理机组的的轴系振动
for
(
DeviceInfoVo
device
:
deviceInfoVos
)
{
if
(!
device
.
getDeviceName
().
contains
(
"2号"
))
{
continue
;
}
//获取润滑参数 n号机润滑参数
UnitInfoVo
lubricationUnit
=
device
.
getUnitInfoVos
().
stream
().
filter
(
unit
->
{
return
unit
.
getUnitName
().
contains
(
"发电机本体温度监测"
);
}).
findFirst
().
orElse
(
null
);
if
(
lubricationUnit
!=
null
)
{
//构造value的key
DataPower
.
PowerPoints
powerPoint
=
new
DataPower
.
PowerPoints
();
powerPoint
.
setName
(
device
.
getDeviceName
());
//构造返回数据类型
dataPower
.
getDataList
().
add
(
powerPoint
);
//筛选 1F汽端轴瓦温度 1F汽端轴瓦温度A 1F励端轴瓦温度 1F励端轴瓦温度A
List
<
CharacterParamInfoVo
>
waitDoLubricationCharacterParamInfoVo
=
lubricationUnit
.
getCharacters
().
stream
().
filter
(
characters
->
characters
.
getCpName
().
contains
(
"F汽端轴瓦温度4"
)
||
characters
.
getCpName
().
contains
(
"F汽端轴瓦温度5"
)
||
characters
.
getCpName
().
contains
(
"F励端轴瓦温度1"
)
||
characters
.
getCpName
().
contains
(
"F励端轴瓦温度2"
)
).
collect
(
Collectors
.
toList
());
if
(
waitDoLubricationCharacterParamInfoVo
.
size
()
!=
0
)
{
//集合为空时 抛出异常
ResponseEnum
.
COLLECTION_NOT_ILLEGAL
.
assertCollectionNotILLEGAL
(
waitDoLubricationCharacterParamInfoVo
);
waitDoLubricationCharacterParamInfoVo
.
forEach
(
characters
->
{
String
kkscode
=
characters
.
getKksCode
();
QueryExt
queryExt
=
QueryExt
.
builder
()
.
aggregator
(
Aggregator
.
NONE
)
.
metric
(
kkscode
)
.
build
();
queryRequestExt
.
addQuery
(
queryExt
);
});
}
}
}
try
{
QueryResponse
response
=
OpentsdbOkHttpClient
.
query
(
queryRequestExt
);
List
<
QueryResult
>
results
=
response
.
getResults
();
//处理X轴坐标
results
.
forEach
(
arg
->
{
String
kksCode
=
arg
.
getMetric
();
HashMap
<
String
,
String
>
deviceNameAndCharacterName
=
findDeviceNameAndCharacterName
(
kksCode
,
deviceInfoVos
);
String
deviceName
=
deviceNameAndCharacterName
.
get
(
"deviceName"
);
String
characterName
=
deviceNameAndCharacterName
.
get
(
"characterName"
);
int
xCount
=
dataPower
.
getXAxis
().
size
();
int
yCount
=
dataPower
.
getDataList
().
size
();
int
xPosition
=
-
1
,
yPosition
=
-
1
;
for
(
int
i
=
0
;
i
<
xCount
;
i
++)
{
if
(
characterName
.
contains
(
dataPower
.
getXAxis
().
get
(
i
).
toString
()))
{
xPosition
=
i
;
}
}
for
(
int
i
=
0
;
i
<
yCount
;
i
++)
{
if
(
deviceName
.
equals
(
dataPower
.
getDataList
().
get
(
i
).
getName
()))
{
yPosition
=
i
;
}
}
//关联数据位置
for
(
Long
timeKey
:
arg
.
getDps
().
keySet
())
{
dataPower
.
getDataList
().
get
(
yPosition
).
getValue
().
add
(
xPosition
,
String
.
valueOf
(
arg
.
getDps
().
get
(
timeKey
)));
}
});
//处理X轴坐标名称
return
BaseResponse
.
okData
(
formatDataPowerXY
(
dataPower
));
}
catch
(
Exception
e
)
{
log
.
error
(
"获取个机组轴瓦温度柱状图失败!"
);
//抛出业务异常
ResponseEnum
.
OPEN_TS_DB_CONNECTION_ERROR
.
assertIsException
(
e
);
}
return
BaseResponse
.
errorMsg
(
"获取失败"
);
}
/**
* 获取首页3D部件下测点信息和值
*
* @param unitNo 部件唯一标识
* @param plantCode 电厂唯一标识
* @return DataPower
*/
public
BaseResponse
<
DataPower
>
realTimeData3DModel
(
String
unitNo
,
String
plantCode
)
{
List
<
DeviceInfoVo
>
deviceInfoVos
=
iDeviceInfoService
.
getDeviceUnitAndCharacterPlantCode
(
plantCode
);
AtomicReference
<
List
<
CharacterParamInfoVo
>>
listAtomicReference
=
new
AtomicReference
<>();
deviceInfoVos
.
forEach
(
devices
->
devices
.
getUnitInfoVos
().
forEach
(
units
->
{
if
(
unitNo
.
equals
(
units
.
getUnitCodeId
()))
{
listAtomicReference
.
set
(
units
.
getCharacters
());
}
}));
List
<
CharacterParamInfoVo
>
characters
=
listAtomicReference
.
get
();
// long endTime = 1590373722L;
// long startTime = endTime - 1;
//组装当前部件下的所有测点请求
QueryRequestExt
queryRequestExt
=
QueryRequestExt
.
builder
()
// .start(startTime + "")
// .end(endTime + "")
.
start
(
"100h-ago"
)
.
build
();
for
(
CharacterParamInfoVo
character
:
characters
)
{
QueryExt
queryExt
=
QueryExt
.
builder
()
.
metric
(
character
.
getKksCode
())
.
aggregator
(
Aggregator
.
AVG
)
.
build
();
queryRequestExt
.
addQuery
(
queryExt
);
}
DataPower
dataPower
=
new
DataPower
();
try
{
//封装响应数据
QueryResponse
response
=
OpentsdbOkHttpClient
.
query
(
queryRequestExt
);
response
.
getResults
().
forEach
(
arg
->
{
DataPower
.
PowerPoints
powerPoints
=
new
DataPower
.
PowerPoints
();
powerPoints
.
setName
(
arg
.
getMetric
());
for
(
Long
dataKey
:
arg
.
getDps
().
keySet
())
{
powerPoints
.
getValue
().
add
(
arg
.
getDps
().
get
(
dataKey
).
toString
());
}
dataPower
.
getDataList
().
add
(
powerPoints
);
});
//将kksCode 换成中文
for
(
DataPower
.
PowerPoints
powerPoints
:
dataPower
.
getDataList
())
{
characters
.
stream
()
.
filter
(
characters1
->
characters1
.
getKksCode
().
equals
(
powerPoints
.
getName
()))
.
findFirst
().
ifPresent
(
characters2
->
{
powerPoints
.
setName
(
characters2
.
getKksCode
());
List
<
String
>
subList
=
powerPoints
.
getValue
().
isEmpty
()
?
new
ArrayList
<>()
:
powerPoints
.
getValue
().
subList
(
0
,
1
);
powerPoints
.
setValue
(
subList
);
});
}
return
BaseResponse
.
okData
(
dataPower
);
}
catch
(
Exception
e
)
{
ResponseEnum
.
OPEN_TS_DB_CONNECTION_ERROR
.
assertIsException
(
e
);
}
return
BaseResponse
.
errorMsg
(
"查询失败!"
);
}
public
static
void
main
(
String
[]
args
)
{
String
power
=
"(燃机发电机有功功率\\d\\s*)$"
;
//原来是 "F功率"
final
Pattern
endFpower
=
Pattern
.
compile
(
power
,
Pattern
.
MULTILINE
);
final
Matcher
endFpowerMatcher
=
endFpower
.
matcher
(
"2燃机发电机有功功率9"
);
}
/**
* 获取首页各机组功率趋势图
*
* @param plantCode 电厂唯一标识
* @return 返回电压数据点线
*/
public
BaseResponse
<
DataPower
>
getIndexPowerInit
(
String
plantCode
)
{
List
<
DeviceInfoVo
>
deviceInfoVos
=
iDeviceInfoService
.
getDeviceUnitAndCharacterPlantCode
(
plantCode
);
//待查询的key值 结构:电机名|功率kkscode
List
<
String
>
keys
=
new
ArrayList
<>();
//筛选出每个机组的名字
String
statorCurrent
=
"(F定子电气参数监测\\s*)$"
;
//原来是 "号机定子电流电压"
final
Pattern
endStatorCurrentPattern
=
Pattern
.
compile
(
statorCurrent
,
Pattern
.
MULTILINE
);
String
power
=
"(燃机发电机有功功率\\d\\s*)$"
;
//原来是 "F功率"
final
Pattern
endFpower
=
Pattern
.
compile
(
power
,
Pattern
.
MULTILINE
);
deviceInfoVos
.
forEach
(
devices
->
{
//正则匹配 已"号机定子电流电压"结尾
UnitInfoVo
units
=
devices
.
getUnitInfoVos
().
stream
().
filter
(
unit
->
{
final
Matcher
endStatorCurrentMatcher
=
endStatorCurrentPattern
.
matcher
(
unit
.
getUnitName
());
return
endStatorCurrentMatcher
.
find
();
}).
findFirst
().
orElse
(
null
);
//正则匹配 已"F功率"结尾
ResponseEnum
.
LICENCE_NOT_FOUND
.
assertNotNull
(
units
);
CharacterParamInfoVo
characters
=
units
.
getCharacters
().
stream
().
filter
(
character
->
{
final
Matcher
endFpowerMatcher
=
endFpower
.
matcher
(
character
.
getCpName
());
return
endFpowerMatcher
.
find
();
}).
findFirst
().
orElse
(
null
);
ResponseEnum
.
LICENCE_NOT_FOUND
.
assertNotNull
(
characters
);
String
key
=
devices
.
getDeviceName
()
+
"|"
+
characters
.
getKksCode
();
keys
.
add
(
key
);
});
//计算当前需要的偏移量
Calendar
calendar
=
DateUtil
.
calendar
();
int
nowHour
=
calendar
.
get
(
Calendar
.
HOUR_OF_DAY
);
int
count
=
nowHour
/
6
;
int
endHour
=
(
count
-
1
)
*
6
+
2
;
//构建结尾时间
calendar
.
set
(
calendar
.
get
(
Calendar
.
YEAR
),
calendar
.
get
(
Calendar
.
MONTH
),
calendar
.
get
(
Calendar
.
DAY_OF_MONTH
),
endHour
,
0
);
Date
endHourTime
=
calendar
.
getTime
();
Date
startHour
;
DataPower
dataPower
=
new
DataPower
();
try
{
//构建查询语句 时间条件:2-8 8-14 14-20 20-2
for
(
int
i
=
1
;
i
<
6
;
i
++)
{
startHour
=
DateUtil
.
offset
(
endHourTime
,
DateField
.
HOUR_OF_DAY
,
i
*
-
6
);
dataPower
.
getXAxis
().
add
(
DateUtil
.
formatDateTime
(
endHourTime
));
QueryRequestExt
requestz
=
QueryRequestExt
.
builder
()
.
start
(
startHour
.
getTime
()
+
""
)
.
end
(
endHourTime
.
getTime
()
+
""
)
.
build
();
endHourTime
=
startHour
;
for
(
String
key
:
keys
)
{
//查询
String
kkscode
=
key
.
split
(
"\\|"
)[
1
];
requestz
.
addQuery
(
QueryExt
.
builder
()
.
aggregator
(
Aggregator
.
AVG
)
.
metric
(
kkscode
)
.
build
()
);
}
QueryResponse
response
=
null
;
response
=
OpentsdbOkHttpClient
.
query
(
requestz
);
//根据返回的的数据 处理点
List
<
QueryResult
>
results
=
response
.
getResults
();
for
(
QueryResult
queryResult
:
results
)
{
boolean
flag
=
dataPower
.
getDataList
().
stream
().
noneMatch
(
arg
->
arg
.
getName
().
equals
(
queryResult
.
getMetric
()));
if
(!
flag
)
{
dataPower
.
getDataList
().
forEach
(
arg
->
{
if
(
arg
.
getName
().
equals
(
queryResult
.
getMetric
()))
{
for
(
Long
key
:
queryResult
.
getDps
().
keySet
())
{
arg
.
getValue
().
add
(
queryResult
.
getDps
().
get
(
key
)
+
""
);
}
}
});
}
else
{
DataPower
.
PowerPoints
powerPoints
=
new
DataPower
.
PowerPoints
();
powerPoints
.
setName
(
queryResult
.
getMetric
());
for
(
Long
key
:
queryResult
.
getDps
().
keySet
())
{
powerPoints
.
getValue
().
add
(
queryResult
.
getDps
().
get
(
key
)
+
""
);
}
dataPower
.
getDataList
().
add
(
powerPoints
);
}
}
//处理获取到的数据
}
}
catch
(
Exception
e
)
{
return
BaseResponse
.
errorMsg
(
"查询失败"
);
}
for
(
DataPower
.
PowerPoints
powerPoints
:
dataPower
.
getDataList
())
{
//todo 这里求的是平均数理应只有一个指 但是他不是 它没平均
//todo 下面强制删除 数据对的时候记得删除
List
<
String
>
list
=
powerPoints
.
getValue
().
isEmpty
()
?
new
ArrayList
<>()
:
powerPoints
.
getValue
().
subList
(
0
,
5
);
powerPoints
.
setValue
(
list
);
String
nameByKKSCode
=
getNameByKKSCode
(
powerPoints
.
getName
(),
deviceInfoVos
);
powerPoints
.
setName
(
nameByKKSCode
);
}
return
BaseResponse
.
okData
(
dataPower
);
}
/**
* 根据kksCode反向找到 所属的机组名和kksCode所属的测点类型
*
* @param kksCode kksCode
* @param deviceInfoVos 电厂配置类
* @return 电厂名字和测点名字
*/
private
HashMap
<
String
,
String
>
findDeviceNameAndCharacterName
(
String
kksCode
,
List
<
DeviceInfoVo
>
deviceInfoVos
)
{
HashMap
<
String
,
String
>
rts
=
new
HashMap
<>(
2
);
//由kksCode向上找到device机组名和测点名字
AtomicReference
<
String
>
characterName
=
new
AtomicReference
<>();
DeviceInfoVo
device
=
deviceInfoVos
.
stream
().
filter
(
devices
->
devices
.
getUnitInfoVos
().
stream
().
anyMatch
(
units
->
units
.
getCharacters
().
stream
().
anyMatch
(
characters
->
{
if
(
kksCode
.
equals
(
characters
.
getKksCode
()))
{
characterName
.
set
(
characters
.
getCpName
());
return
true
;
}
else
{
return
false
;
}
}))
).
findFirst
().
orElse
(
null
);
ResponseEnum
.
LICENCE_NOT_FOUND
.
assertNotNull
(
device
);
rts
.
put
(
"deviceName"
,
device
.
getDeviceName
());
rts
.
put
(
"characterName"
,
characterName
.
get
());
return
rts
;
}
/**
* 通过kksCode获取 测点名字
*
* @param KKSCode 测点编号
* @return 测点名字
*/
private
String
getNameByKKSCode
(
String
KKSCode
,
List
<
DeviceInfoVo
>
deviceInfoVos
)
{
AtomicReference
<
String
>
rts
=
new
AtomicReference
<>(
""
);
deviceInfoVos
.
forEach
(
devices
->
devices
.
getUnitInfoVos
().
forEach
(
units
->
{
units
.
getCharacters
().
forEach
(
characters
->
{
if
(
KKSCode
.
equals
(
characters
.
getCpName
()))
{
rts
.
set
(
devices
.
getDeviceName
());
}
});
}));
return
rts
.
get
();
}
/**
* 将dataPower 的 X轴转换成机组 PowerPoints转换成设备
*
* @param dataPower
* @return
*/
private
DataPower
formatDataPowerXY
(
DataPower
dataPower
)
{
DataPower
rts
=
new
DataPower
();
//将x轴下沉到 PowerPoints
int
count
=
0
;
for
(
Object
x
:
dataPower
.
getXAxis
())
{
DataPower
.
PowerPoints
newPowerPoints
=
new
DataPower
.
PowerPoints
();
newPowerPoints
.
setName
(
x
+
""
);
rts
.
getDataList
().
add
(
newPowerPoints
);
for
(
DataPower
.
PowerPoints
powerPoints
:
dataPower
.
getDataList
())
{
if
(
powerPoints
.
getValue
().
isEmpty
())
{
newPowerPoints
.
setValue
(
new
ArrayList
<>());
}
else
{
newPowerPoints
.
getValue
().
add
(
powerPoints
.
getValue
().
get
(
count
));
}
}
count
++;
}
//将PowerPoints的name变成X轴
for
(
DataPower
.
PowerPoints
powerPoints
:
dataPower
.
getDataList
())
{
rts
.
getXAxis
().
add
(
powerPoints
.
getName
());
}
return
rts
;
}
}
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/service/MenuService.java
deleted
100644 → 0
View file @
4a17a880
//package cn.wise.sc.energy.power.plant.business.service;
//
//import cn.wise.sc.energy.power.plant.common.core.bean.BaseResponse;
//import com.alibaba.fastjson.JSON;
//import org.redisson.api.RBucket;
//import org.redisson.api.RedissonClient;
//import org.springframework.scheduling.annotation.Async;
//import org.springframework.stereotype.Component;
//
//import java.util.ArrayList;
//import java.util.List;
//import java.util.concurrent.atomic.AtomicReference;
//
///**
// * @description: 菜单配置
// * @author: qh
// * @create: 2020-05-23 10:20
// **/
//@Component
//public class MenuService {
//
// final
// DataBaseService baseService;
// final
// RedissonClient redissonClient;
//
// public MenuService(DataBaseService baseService, RedissonClient redissonClient) {
// this.baseService = baseService;
// this.redissonClient = redissonClient;
// }
//
// /**
// * 获取菜单信息
// * <p>
// * // * @param plantCode 菜单编码
// *
// * @return String
// */
// public BaseResponse<String> getMenuInfo() {
//
// List<TurbineOption> configJsons = baseService.getAllTurbineOption();
// List<TurbineOption> rts = new ArrayList<>(configJsons.size());
// for (TurbineOption configJson : configJsons) {
// if (JSON.toJSONString(configJson).contains("阻尼器")) {
// continue;
// }
// //去掉配置里面的测点
// configJson.getBasicOption().getDevices().stream()
// .forEach(device -> device.getUnitInfoVos().stream()
// .forEach(unit -> unit.setCharacterParamInfoVo(null)));
// rts.add(configJson);
// }
//
// return BaseResponse.okData(JSON.toJSONString(rts));
// }
//
// /**
// * 初始化redis信息
// */
// @Async
// public void initRedis() {
// List<String> configJsons = baseService.getAllTurbineConfigJson();
// for (String configJson : configJsons) {
// //解析配置文件 拆分部件 初始化redis
// List<UnitInfoVo> units = getUnitInfoVos(configJson);
// //判断是否已经存进去了
// UnitInfoVo firstUnit = units.get(0);
// RBucket<Object> firstUnitInfo = redissonClient.getBucket(firstUnit.getUnitid());
// if (firstUnitInfo.isExists()) {
// return;
// }
// BasicOption basicOption = JSON.parseObject(configJson, BasicOption.class);
//
// //redis缓存机组信息
// for (Devices device : basicOption.getDevices()) {
// RBucket<String> rBucket = redissonClient.getBucket(basicOption.getDepartment() + ":" + device.getDevicename());
// rBucket.set(JSON.toJSONString(device));
// }
//
// //redis缓存部件信息
// for (UnitInfoVo unit : units) {
// RBucket<Object> bucket = redissonClient.getBucket(basicOption.getDepartment() + ":" + unit.getUnitid());
// bucket.set(JSON.toJSONString(unit));
// }
// }
// }
//
// /**
// * 获取部件信息
// *
// * @param configJson 电厂配置文件
// * @return 部件集合
// */
// private List<UnitInfoVo> getUnitInfoVos(String configJson) {
// //解析配置文件 UnitInfoVo
// BasicOption basicOption = JSON.parseObject(configJson, BasicOption.class);
// //获取部件信息
// List<UnitInfoVo> units = new ArrayList<>();
// basicOption.getDevices().stream()
// .forEach(device -> units.addAll(device.getUnitInfoVos()));
// return units;
// }
//
// /**
// * 获取配置文件里面的
// *
// * @param configJson 配置文件
// * @return 测点集合
// */
// private List<CharacterParamInfoVo> getCharacters(String configJson) {
//
// //解析配置文件 拆分characters
// BasicOption basicOption = JSON.parseObject(configJson, BasicOption.class);
//
// //获取测点信息
// List<CharacterParamInfoVo> characters = new ArrayList<>();
// basicOption.getDevices().stream()
// .forEach(device -> device.getUnitInfoVos().stream()
// .forEach(unit -> characters.addAll(unit.getCharacters())));
// return characters;
// }
//
// /**
// * 获取测点信息
// *
// * @param key 部件编号
// * @return String
// */
// public BaseResponse<String> getCharacterInfo(String key) {
// AtomicReference<List<CharacterParamInfoVo>> characters = new AtomicReference<>();
// RBucket<String> bucket = redissonClient.getBucket(key);
// if (bucket.isExists()) {
// return BaseResponse.okData(bucket.get());
// } else {
// List<String> allTurbineConfigJson = baseService.getAllTurbineConfigJson();
// List<BasicOption> basicOptions = new ArrayList<>(allTurbineConfigJson.size());
// for (String turbineConfigJson : allTurbineConfigJson) {
// if (turbineConfigJson.contains("阻尼器")) {
// continue;
// }
// basicOptions.add(JSON.parseObject(turbineConfigJson, BasicOption.class));
// }
// basicOptions.stream().forEach(basicOption -> {
// basicOption.getDevices().stream().forEach(devices -> {
// UnitInfoVo units1 = devices.getUnitInfoVos().stream().filter(units ->
// key.equals(units.getUnitid())
// ).findFirst().orElse(null);
// if (units1 != null) {
// characters.set(units1.getCharacters());
// }
// });
// });
// bucket.set(JSON.toJSONString(characters.get()));
// }
// return BaseResponse.okData(JSON.toJSONString(characters.get()));
// }
//}
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/service/SpindleServiceImpl.java
deleted
100644 → 0
View file @
4a17a880
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
service
;
import
cn.wise.sc.energy.power.plant.business.bean.TimeModelQuery
;
import
cn.wise.sc.energy.power.plant.business.opentsdb.OpentsdbOkHttpClient
;
import
cn.wise.sc.energy.power.plant.business.opentsdb.bean.QueryExt
;
import
cn.wise.sc.energy.power.plant.business.opentsdb.bean.QueryRequestExt
;
import
cn.wise.sc.energy.power.plant.common.core.bean.BaseResponse
;
import
cn.wise.sc.energy.power.plant.common.core.exception.ResponseEnum
;
import
net.opentsdb.client.api.query.response.QueryResponse
;
import
net.opentsdb.client.bean.Aggregator
;
import
net.opentsdb.client.bean.QueryResult
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
/**
* @description: 转轴监控
* @author: qh
* @create: 2020-05-20 17:39
*/
@Service
public
class
SpindleServiceImpl
implements
ISpindleService
{
@Override
public
BaseResponse
<
String
>
getDataByTime
(
TimeModelQuery
timeModelQuery
,
String
key
)
{
QueryResponse
queryResponse
=
null
;
try
{
queryResponse
=
OpentsdbOkHttpClient
.
query
(
QueryRequestExt
.
builder
()
.
start
(
"1589529222621"
)
.
end
(
"1589529223621"
)
.
build
()
.
addQuery
(
QueryExt
.
builder
()
.
aggregator
(
Aggregator
.
AVG
)
.
metric
(
"rm000000000000000000001292"
)
.
build
()));
}
catch
(
Exception
e
)
{
ResponseEnum
.
BUSINESS_ERROR
.
assertNotNull
(
null
);
}
ResponseEnum
.
LICENCE_NOT_FOUND
.
assertNotNull
(
queryResponse
);
List
<
QueryResult
>
results
=
queryResponse
.
getResults
();
// todo results处理
return
null
;
}
}
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/service/TendencyService.java
deleted
100644 → 0
View file @
4a17a880
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
service
;
import
cn.hutool.core.date.DateField
;
import
cn.hutool.core.date.DateUnit
;
import
cn.hutool.core.date.DateUtil
;
import
cn.wise.sc.energy.power.plant.business.bean.DataPower
;
import
cn.wise.sc.energy.power.plant.business.bean.DataPowerAsync
;
import
cn.wise.sc.energy.power.plant.business.bean.TimeModelQuery
;
import
cn.wise.sc.energy.power.plant.business.constant.TendencyConditionEnum
;
import
cn.wise.sc.energy.power.plant.business.opentsdb.OpentsdbOkHttpClient
;
import
cn.wise.sc.energy.power.plant.business.opentsdb.bean.QueryExt
;
import
cn.wise.sc.energy.power.plant.business.opentsdb.bean.QueryRequestExt
;
import
cn.wise.sc.energy.power.plant.common.core.bean.BaseResponse
;
import
cn.wise.sc.energy.power.plant.common.core.exception.ResponseEnum
;
import
com.alibaba.fastjson.JSON
;
import
lombok.extern.slf4j.Slf4j
;
import
net.opentsdb.client.api.query.response.QueryResponse
;
import
net.opentsdb.client.bean.Aggregator
;
import
net.opentsdb.client.bean.QueryResult
;
import
org.redisson.api.RedissonClient
;
import
org.springframework.stereotype.Component
;
import
java.io.IOException
;
import
java.net.URISyntaxException
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.List
;
import
java.util.concurrent.CompletableFuture
;
import
java.util.concurrent.ConcurrentLinkedQueue
;
import
java.util.concurrent.CountDownLatch
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.atomic.AtomicInteger
;
/**
* @description: 趋势图
* @author: qh
* @create: 2020-05-23 11:56
**/
@Slf4j
@Component
public
class
TendencyService
{
final
RedissonClient
redissonClient
;
public
TendencyService
(
RedissonClient
redissonClient
)
{
this
.
redissonClient
=
redissonClient
;
}
/**
* 获取趋势图数据
*
* @param keys 带查询的key
* @param timeModelQuery 时间段
* @param status X轴条件 code {@link TendencyConditionEnum}
* @return
*/
public
BaseResponse
<
String
>
getInitData
(
List
<
String
>
keys
,
TimeModelQuery
timeModelQuery
,
Integer
status
)
{
//判断key参数集合不为空
ResponseEnum
.
COLLECTION_NOT_ILLEGAL
.
assertCollectionNotILLEGAL
(
keys
);
DataPowerAsync
dataPower
=
buildQueryRequest
(
status
,
keys
,
timeModelQuery
);
int
count
=
0
;
for
(
DataPowerAsync
.
PowerPoints
powerPoints
:
dataPower
.
getDataList
())
{
if
(
powerPoints
.
getValue
().
size
()
==
0
)
{
dataPower
.
getDataList
().
remove
(
powerPoints
);
continue
;
}
if
(
count
>
keys
.
size
())
{
break
;
}
List
<
String
>
newList
=
new
ArrayList
(
powerPoints
.
getValue
());
powerPoints
.
setValue
(
new
ConcurrentLinkedQueue
<>(
newList
));
count
++;
}
return
BaseResponse
.
okData
(
JSON
.
toJSONString
(
dataPower
));
}
/**
* 构造QueryRequestExt对象
*
* @param conditionCode 时均/日均/月均 {@link TendencyConditionEnum}
* @param keyCodes opentsdb查询条件
* @param timeModelQuery 时间条件
* @return QueryRequestExt
*/
private
DataPowerAsync
buildQueryRequest
(
Integer
conditionCode
,
List
<
String
>
keyCodes
,
TimeModelQuery
timeModelQuery
)
{
long
start
=
timeModelQuery
.
getStart
();
long
end
=
timeModelQuery
.
getEnd
();
//时均线
if
(
conditionCode
==
TendencyConditionEnum
.
HOUR
.
getCode
())
{
//构造每小时累积条件
//1.构建开始时间向前取整的整数时间戳
long
finalStartTime
=
timeBeforeInteger
(
start
);
//2.构建结束时间向前取整的整数时间戳
long
finalEndTime
=
timeBeforeInteger
(
end
);
//3.开始和结束之间-间隔的小时
int
intervalTime
=
Math
.
abs
((
int
)
DateUtil
.
between
(
DateUtil
.
date
(
finalStartTime
),
DateUtil
.
date
(
finalEndTime
),
DateUnit
.
HOUR
));
CountDownLatch
count
=
new
CountDownLatch
(
intervalTime
);
DataPowerAsync
dataPower
=
new
DataPowerAsync
();
try
{
for
(
int
i
=
0
;
i
<
intervalTime
;
i
++)
{
AtomicInteger
changeCount
=
new
AtomicInteger
(
i
);
long
endTime
=
DateUtil
.
offset
(
DateUtil
.
date
(
finalStartTime
),
DateField
.
HOUR_OF_DAY
,
changeCount
.
get
()).
getTime
();
long
startTime
=
DateUtil
.
offset
(
DateUtil
.
date
(
endTime
),
DateField
.
HOUR_OF_DAY
,
-
1
).
getTime
();
dataPower
.
getXAxis
().
add
(
DateUtil
.
format
(
DateUtil
.
date
(
endTime
),
"yyyy-MM-dd HH"
));
CompletableFuture
<
DataPowerAsync
>
completableFuture
=
CompletableFuture
.
supplyAsync
(()
->
{
//判断最后结束时间
if
(
DateUtil
.
calendar
(
endTime
).
getTimeInMillis
()
<=
finalEndTime
)
{
RequestQuery
(
startTime
,
endTime
,
keyCodes
,
dataPower
);
}
count
.
countDown
();
return
dataPower
;
});
}
}
catch
(
Exception
e
)
{
return
new
DataPowerAsync
();
}
try
{
count
.
await
(
2
,
TimeUnit
.
SECONDS
);
if
(
count
.
getCount
()
==
0
)
{
return
dataPower
;
}
else
{
count
.
await
(
4
,
TimeUnit
.
SECONDS
);
return
dataPower
;
}
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
}
else
if
(
conditionCode
==
TendencyConditionEnum
.
DAY
.
getCode
())
{
//日均线
//构造每小时累积条件
int
startYear
=
DateUtil
.
calendar
(
start
).
get
(
Calendar
.
YEAR
);
int
startMonth
=
DateUtil
.
calendar
(
start
).
get
(
Calendar
.
MONTH
);
int
startDay
=
DateUtil
.
calendar
(
start
).
get
(
Calendar
.
DAY_OF_MONTH
);
Calendar
startCalendar
=
Calendar
.
getInstance
();
startCalendar
.
set
(
startYear
,
startMonth
,
startDay
);
long
finalStartTime
=
startCalendar
.
getTimeInMillis
();
int
endDay
=
DateUtil
.
calendar
(
end
).
get
(
Calendar
.
DAY_OF_MONTH
);
//计算间隔时间
int
intervalCount
=
(
int
)
Math
.
abs
(
DateUtil
.
betweenDay
(
DateUtil
.
date
(
start
),
DateUtil
.
date
(
end
),
false
));
CountDownLatch
count
=
new
CountDownLatch
(
intervalCount
);
DataPowerAsync
dataPower
=
new
DataPowerAsync
();
try
{
for
(
int
i
=
1
;
i
<=
intervalCount
;
i
++)
{
//获取结束时间
long
endTime
=
DateUtil
.
offset
(
DateUtil
.
date
(
finalStartTime
),
DateField
.
DAY_OF_MONTH
,
1
).
getTime
();
long
startTime
=
finalStartTime
;
//将时间向后推1Day
finalStartTime
=
endTime
;
dataPower
.
getXAxis
().
add
(
DateUtil
.
format
(
DateUtil
.
date
(
endTime
),
"yyyy-MM-dd"
));
long
finalStartTime1
=
finalStartTime
;
CompletableFuture
<
DataPowerAsync
>
completableFuture
=
CompletableFuture
.
supplyAsync
(()
->
{
//判断最后结束时间
if
(
DateUtil
.
calendar
(
endTime
).
get
(
Calendar
.
DAY_OF_MONTH
)
<=
endDay
)
{
RequestQuery
(
startTime
,
endTime
,
keyCodes
,
dataPower
);
}
count
.
countDown
();
return
dataPower
;
});
}
}
catch
(
Exception
e
)
{
return
new
DataPowerAsync
();
}
try
{
count
.
await
(
2
,
TimeUnit
.
SECONDS
);
if
(
count
.
getCount
()
==
0
)
{
return
dataPower
;
}
else
{
count
.
await
(
4
,
TimeUnit
.
SECONDS
);
return
dataPower
;
}
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
}
else
if
(
conditionCode
==
TendencyConditionEnum
.
MONTH
.
getCode
())
{
//月均线
int
startYear
=
DateUtil
.
calendar
(
start
).
get
(
Calendar
.
YEAR
);
//获取开始时间所在的月份
int
finalStartMonth
=
DateUtil
.
calendar
(
start
).
get
(
Calendar
.
MONTH
);
Calendar
startCalendar
=
Calendar
.
getInstance
();
startCalendar
.
set
(
startYear
,
finalStartMonth
,
0
);
long
finalStartTime
=
startCalendar
.
getTimeInMillis
();
//获取结束时间所在的月份
int
finalEndMonth
=
DateUtil
.
calendar
(
end
).
get
(
Calendar
.
MONTH
);
int
intervalCount
=
Math
.
abs
(
finalEndMonth
-
finalStartMonth
);
//获取间隔时间
CountDownLatch
count
=
new
CountDownLatch
(
intervalCount
);
DataPowerAsync
dataPower
=
new
DataPowerAsync
();
try
{
for
(
int
i
=
1
;
i
<=
intervalCount
;
i
++)
{
//hour获取结束时间
long
endTime
=
DateUtil
.
offset
(
DateUtil
.
date
(
finalStartTime
),
DateField
.
MONTH
,
1
).
getTime
();
long
startTime
=
finalStartTime
;
dataPower
.
getXAxis
().
add
(
DateUtil
.
format
(
DateUtil
.
date
(
endTime
),
"yyyy-MM"
));
finalStartTime
=
endTime
;
CompletableFuture
<
DataPowerAsync
>
completableFuture
=
CompletableFuture
.
supplyAsync
(()
->
{
//判断最后结束时间
if
(
DateUtil
.
calendar
(
endTime
).
get
(
Calendar
.
MONTH
)
<=
finalStartMonth
)
{
RequestQuery
(
startTime
,
endTime
,
keyCodes
,
dataPower
);
}
count
.
countDown
();
return
dataPower
;
});
}
}
catch
(
Exception
e
)
{
return
new
DataPowerAsync
();
}
try
{
count
.
await
(
2
,
TimeUnit
.
SECONDS
);
if
(
count
.
getCount
()
==
0
)
{
return
dataPower
;
}
else
{
count
.
await
(
4
,
TimeUnit
.
SECONDS
);
return
dataPower
;
}
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
}
return
null
;
}
/**
* 发起主动查询
*
* @param startTime 开始时间段
* @param endTime 结束时间段
* @param keyCodes 带查询的key集合
* @param dataPower 最终返回的数据结果
*/
private
void
RequestQuery
(
long
startTime
,
long
endTime
,
List
<
String
>
keyCodes
,
DataPowerAsync
dataPower
)
{
QueryRequestExt
requestz
=
QueryRequestExt
.
builder
()
.
start
(
startTime
+
""
)
.
end
(
endTime
+
""
)
.
build
();
//封装多个条件测点的key值 一次性请求 这1小时的内容
for
(
String
keyCode
:
keyCodes
)
{
requestz
.
addQuery
(
QueryExt
.
builder
()
.
aggregator
(
Aggregator
.
AVG
)
.
metric
(
keyCode
)
.
build
());
}
QueryResponse
response
=
null
;
try
{
response
=
OpentsdbOkHttpClient
.
query
(
requestz
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
catch
(
URISyntaxException
e
)
{
e
.
printStackTrace
();
}
//根据返回的的数据 处理点
List
<
QueryResult
>
results
=
response
.
getResults
();
ThreadLocal
<
Boolean
>
flag
=
ThreadLocal
.
withInitial
(()
->
false
);
synchronized
(
"ConcurrentLinkedQueue你个假的!!!"
){
if
(
results
.
size
()
==
0
)
{
for
(
String
key
:
keyCodes
)
{
long
count
=
dataPower
.
getDataList
().
stream
()
.
filter
(
arg
->
key
.
equals
(
arg
.
getName
())).
count
();
if
(
count
==
0
)
{
DataPowerAsync
.
PowerPoints
powerPoints
=
new
DataPowerAsync
.
PowerPoints
();
powerPoints
.
setName
(
key
);
powerPoints
.
getValue
().
add
(
"0"
);
dataPower
.
getDataList
().
add
(
powerPoints
);
}
else
{
DataPowerAsync
.
PowerPoints
powerPoints
=
dataPower
.
getDataList
().
stream
()
.
filter
(
arg
->
key
.
equals
(
arg
.
getName
())).
findFirst
().
orElse
(
null
);
powerPoints
.
getValue
().
add
(
"0"
);
}
}
}
}
for
(
QueryResult
queryResult
:
results
)
{
long
count
=
dataPower
.
getDataList
().
stream
()
.
filter
(
arg
->
queryResult
.
getMetric
().
equals
(
arg
.
getName
())).
count
();
if
(
count
==
0
)
{
DataPowerAsync
.
PowerPoints
powerPoints
=
new
DataPowerAsync
.
PowerPoints
();
powerPoints
.
setName
(
queryResult
.
getMetric
());
if
(
queryResult
.
getDps
().
isEmpty
())
{
powerPoints
.
getValue
().
add
(
"0"
);
}
else
{
powerPoints
.
getValue
().
add
(
queryResult
.
getDps
().
entrySet
().
iterator
().
next
().
getValue
()
+
""
);
}
dataPower
.
getDataList
().
add
(
powerPoints
);
}
else
{
dataPower
.
getDataList
().
stream
().
forEach
(
arg
->
{
if
(
arg
.
getName
().
equals
(
queryResult
.
getMetric
()))
{
//判断是否已存在当前测点的数据结构
if
(
queryResult
.
getDps
().
isEmpty
())
{
arg
.
getValue
().
add
(
"0"
);
}
else
{
arg
.
getValue
().
add
(
queryResult
.
getDps
().
entrySet
().
iterator
().
next
().
getValue
()
+
""
);
}
}
});
}
}
}
/**
* 将时间戳向前取整小时
*
* @param time 待取时间戳
* @return 向前取整的时间戳
*/
private
Long
timeBeforeInteger
(
Long
time
)
{
int
startHour
=
DateUtil
.
calendar
(
time
).
get
(
Calendar
.
HOUR_OF_DAY
);
int
startYear
=
DateUtil
.
calendar
(
time
).
get
(
Calendar
.
YEAR
);
int
startMonth
=
DateUtil
.
calendar
(
time
).
get
(
Calendar
.
MONTH
);
int
startDay
=
DateUtil
.
calendar
(
time
).
get
(
Calendar
.
DAY_OF_MONTH
);
Calendar
startCalendar
=
Calendar
.
getInstance
();
startCalendar
.
set
(
startYear
,
startMonth
,
startDay
,
startHour
,
0
);
return
startCalendar
.
getTimeInMillis
();
}
}
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/service
2
/impl/BaseServiceImpl.java
→
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/service/impl/BaseServiceImpl.java
View file @
5f874a73
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
service
2
.
impl
;
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
service
.
impl
;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.wise.sc.energy.power.plant.business.domain.AbstractEntity
;
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.domain.vo.EntityVo
;
import
cn.wise.sc.energy.power.plant.business.service
2
.IBaseService
;
import
cn.wise.sc.energy.power.plant.business.service.IBaseService
;
import
cn.wise.sc.energy.power.plant.common.core.bean.EntityQuery
;
import
cn.wise.sc.energy.power.plant.common.core.bean.EntityQuery
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
import
org.springframework.data.jpa.repository.support.SimpleJpaRepository
;
import
javax.persistence.Entity
;
import
javax.persistence.Entity
;
import
javax.persistence.EntityManager
;
import
java.lang.reflect.ParameterizedType
;
import
java.lang.reflect.ParameterizedType
;
import
java.lang.reflect.Type
;
import
java.lang.reflect.Type
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
...
...
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/service
2
/impl/CharacterParamServiceImpl.java
→
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/service/impl/CharacterParamServiceImpl.java
View file @
5f874a73
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
service
2
.
impl
;
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
service
.
impl
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.wise.sc.energy.power.plant.business.bean.DataPower
;
import
cn.wise.sc.energy.power.plant.business.bean.DataPower
;
...
@@ -13,12 +13,10 @@ import cn.wise.sc.energy.power.plant.business.opentsdb.bean.QueryExt;
...
@@ -13,12 +13,10 @@ import cn.wise.sc.energy.power.plant.business.opentsdb.bean.QueryExt;
import
cn.wise.sc.energy.power.plant.business.opentsdb.bean.QueryRequestExt
;
import
cn.wise.sc.energy.power.plant.business.opentsdb.bean.QueryRequestExt
;
import
cn.wise.sc.energy.power.plant.business.repository.CharacterParamRepository
;
import
cn.wise.sc.energy.power.plant.business.repository.CharacterParamRepository
;
import
cn.wise.sc.energy.power.plant.business.repository.UnitInfoRepository
;
import
cn.wise.sc.energy.power.plant.business.repository.UnitInfoRepository
;
import
cn.wise.sc.energy.power.plant.business.service
2
.ICharacterParamService
;
import
cn.wise.sc.energy.power.plant.business.service.ICharacterParamService
;
import
cn.wise.sc.energy.power.plant.common.core.bean.BaseResponse
;
import
cn.wise.sc.energy.power.plant.common.core.bean.BaseResponse
;
import
cn.wise.sc.energy.power.plant.common.core.exception.ResponseEnum
;
import
cn.wise.sc.energy.power.plant.common.core.exception.ResponseEnum
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
import
com.google.common.collect.Range
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
net.opentsdb.client.api.query.response.QueryResponse
;
import
net.opentsdb.client.api.query.response.QueryResponse
;
import
net.opentsdb.client.bean.Aggregator
;
import
net.opentsdb.client.bean.Aggregator
;
...
...
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/service
2
/impl/DetectionServiceImpl.java
→
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/service/impl/DetectionServiceImpl.java
View file @
5f874a73
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
service
2
.
impl
;
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
service
.
impl
;
import
cn.wise.sc.energy.power.plant.business.domain.DetectionItem
;
import
cn.wise.sc.energy.power.plant.business.domain.DetectionItem
;
import
cn.wise.sc.energy.power.plant.business.service
2
.IDetectionService
;
import
cn.wise.sc.energy.power.plant.business.service.IDetectionService
;
import
cn.wise.sc.energy.power.plant.common.core.exception.ResponseEnum
;
import
cn.wise.sc.energy.power.plant.common.core.exception.ResponseEnum
;
import
org.redisson.api.RBucket
;
import
org.redisson.api.RBucket
;
import
org.redisson.api.RQueue
;
import
org.redisson.api.RQueue
;
...
...
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/service
2
/impl/DeviceInfoServiceImpl.java
→
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/service/impl/DeviceInfoServiceImpl.java
View file @
5f874a73
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
service
2
.
impl
;
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
service
.
impl
;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.collection.ListUtil
;
import
cn.wise.sc.energy.power.plant.business.domain.CharacterParamInfo
;
import
cn.wise.sc.energy.power.plant.business.domain.CharacterParamInfo
;
import
cn.wise.sc.energy.power.plant.business.domain.DeviceInfo
;
import
cn.wise.sc.energy.power.plant.business.domain.DeviceInfo
;
import
cn.wise.sc.energy.power.plant.business.domain.UnitInfo
;
import
cn.wise.sc.energy.power.plant.business.domain.UnitInfo
;
...
@@ -12,15 +11,11 @@ import cn.wise.sc.energy.power.plant.business.domain.vo.UnitInfoVo;
...
@@ -12,15 +11,11 @@ import cn.wise.sc.energy.power.plant.business.domain.vo.UnitInfoVo;
import
cn.wise.sc.energy.power.plant.business.opentsdb.OpentsdbOkHttpClient
;
import
cn.wise.sc.energy.power.plant.business.opentsdb.OpentsdbOkHttpClient
;
import
cn.wise.sc.energy.power.plant.business.opentsdb.bean.QueryExt
;
import
cn.wise.sc.energy.power.plant.business.opentsdb.bean.QueryExt
;
import
cn.wise.sc.energy.power.plant.business.opentsdb.bean.QueryRequestExt
;
import
cn.wise.sc.energy.power.plant.business.opentsdb.bean.QueryRequestExt
;
import
cn.wise.sc.energy.power.plant.business.repository.CharacterParamRepository
;
import
cn.wise.sc.energy.power.plant.business.repository.UnitInfoRepository
;
import
cn.wise.sc.energy.power.plant.business.repository.UnitInfoRepository
;
import
cn.wise.sc.energy.power.plant.business.service2.ICharacterParamService
;
import
cn.wise.sc.energy.power.plant.business.service.ICharacterParamService
;
import
cn.wise.sc.energy.power.plant.business.service2.IDeviceInfoService
;
import
cn.wise.sc.energy.power.plant.business.service.IDeviceInfoService
;
import
cn.wise.sc.energy.power.plant.common.core.bean.BaseResponse
;
import
cn.wise.sc.energy.power.plant.common.core.exception.ResponseEnum
;
import
cn.wise.sc.energy.power.plant.common.core.exception.ResponseEnum
;
import
com.google.common.collect.Lists
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
net.opentsdb.client.api.query.request.QueryRequest
;
import
net.opentsdb.client.api.query.response.QueryResponse
;
import
net.opentsdb.client.api.query.response.QueryResponse
;
import
net.opentsdb.client.bean.Aggregator
;
import
net.opentsdb.client.bean.Aggregator
;
import
net.opentsdb.client.bean.QueryResult
;
import
net.opentsdb.client.bean.QueryResult
;
...
@@ -29,12 +24,8 @@ import org.springframework.data.domain.Example;
...
@@ -29,12 +24,8 @@ import org.springframework.data.domain.Example;
import
org.springframework.data.jpa.domain.Specification
;
import
org.springframework.data.jpa.domain.Specification
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
javax.persistence.EntityManager
;
import
javax.persistence.criteria.CriteriaBuilder
;
import
javax.persistence.criteria.CriteriaBuilder
;
import
javax.persistence.criteria.CriteriaQuery
;
import
javax.persistence.criteria.Path
;
import
javax.persistence.criteria.Path
;
import
javax.persistence.criteria.Predicate
;
import
javax.persistence.criteria.Root
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.net.URISyntaxException
;
import
java.net.URISyntaxException
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
...
...
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/service
2
/impl/PlantInfoServiceImpl.java
→
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/service/impl/PlantInfoServiceImpl.java
View file @
5f874a73
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
service
2
.
impl
;
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
service
.
impl
;
import
cn.wise.sc.energy.power.plant.business.domain.DeviceInfo
;
import
cn.wise.sc.energy.power.plant.business.domain.DeviceInfo
;
import
cn.wise.sc.energy.power.plant.business.domain.PlantInfo
;
import
cn.wise.sc.energy.power.plant.business.domain.PlantInfo
;
import
cn.wise.sc.energy.power.plant.business.repository.DeviceInfoRepository
;
import
cn.wise.sc.energy.power.plant.business.repository.DeviceInfoRepository
;
import
cn.wise.sc.energy.power.plant.business.service
2
.IPlantInfoService
;
import
cn.wise.sc.energy.power.plant.business.service.IPlantInfoService
;
import
cn.wise.sc.energy.power.plant.common.core.bean.BaseResponse
;
import
cn.wise.sc.energy.power.plant.common.core.bean.BaseResponse
;
import
cn.wise.sc.energy.power.plant.common.core.exception.ResponseEnum
;
import
cn.wise.sc.energy.power.plant.common.core.exception.ResponseEnum
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
...
...
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/service
2
/impl/RuntimeOptionServiceImpl.java
→
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/service/impl/RuntimeOptionServiceImpl.java
View file @
5f874a73
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
service
2
.
impl
;
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
service
.
impl
;
/**
/**
* @description: 运行时设置服务实现
* @description: 运行时设置服务实现
...
...
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/service
2
/impl/UnitInfoServiceImpl.java
→
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/service/impl/UnitInfoServiceImpl.java
View file @
5f874a73
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
service
2
.
impl
;
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
service
.
impl
;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.wise.sc.energy.power.plant.business.domain.UnitInfo
;
import
cn.wise.sc.energy.power.plant.business.domain.UnitInfo
;
import
cn.wise.sc.energy.power.plant.business.domain.vo.EntityVo
;
import
cn.wise.sc.energy.power.plant.business.domain.vo.EntityVo
;
import
cn.wise.sc.energy.power.plant.business.domain.vo.UnitInfoVo
;
import
cn.wise.sc.energy.power.plant.business.domain.vo.UnitInfoVo
;
import
cn.wise.sc.energy.power.plant.business.service
2
.IUnitInfoService
;
import
cn.wise.sc.energy.power.plant.business.service.IUnitInfoService
;
import
cn.wise.sc.energy.power.plant.common.core.exception.ResponseEnum
;
import
cn.wise.sc.energy.power.plant.common.core.exception.ResponseEnum
;
import
org.springframework.data.domain.Example
;
import
org.springframework.data.domain.Example
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
javax.persistence.EntityManager
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
...
...
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/service
2
/impl/UserInfoServiceImpl.java
→
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/service/impl/UserInfoServiceImpl.java
View file @
5f874a73
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
service
2
.
impl
;
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
service
.
impl
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.wise.sc.energy.power.plant.business.domain.CharacterParamInfo
;
import
cn.wise.sc.energy.power.plant.business.domain.UserInfo
;
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.UserInfoQuery
;
import
cn.wise.sc.energy.power.plant.business.domain.vo.EntityVo
;
import
cn.wise.sc.energy.power.plant.business.repository.UserInfoRepository
;
import
cn.wise.sc.energy.power.plant.business.repository.UserInfoRepository
;
import
cn.wise.sc.energy.power.plant.business.service
2
.IUserInfoService
;
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.bean.BaseResponse
;
import
cn.wise.sc.energy.power.plant.common.core.exception.BusinessException
;
import
cn.wise.sc.energy.power.plant.common.core.exception.BusinessExceptionAssert
;
import
cn.wise.sc.energy.power.plant.common.core.exception.ResponseEnum
;
import
cn.wise.sc.energy.power.plant.common.core.exception.ResponseEnum
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Example
;
import
org.springframework.data.domain.ExampleMatcher
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageImpl
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.data.jpa.domain.Specification
;
import
org.springframework.data.jpa.domain.Specification
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
javax.persistence.criteria.CriteriaBuilder
;
import
javax.persistence.criteria.CriteriaQuery
;
import
javax.persistence.criteria.Path
;
import
javax.persistence.criteria.Path
;
import
javax.persistence.criteria.Predicate
;
import
javax.persistence.criteria.Root
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Optional
;
/**
/**
* @description:
* @description:
...
...
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/task/ScheduledModel.java
View file @
5f874a73
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
task
;
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
task
;
import
cn.wise.sc.energy.power.plant.business.bean.DataPower
;
import
cn.wise.sc.energy.power.plant.business.bean.DataPower
;
import
cn.wise.sc.energy.power.plant.business.controller2.IndexRealDataController
;
import
cn.wise.sc.energy.power.plant.business.domain.vo.CharacterParamInfoVo
;
import
cn.wise.sc.energy.power.plant.business.domain.vo.CharacterParamInfoVo
;
import
cn.wise.sc.energy.power.plant.business.service.IndexRealTimeDataService
;
import
cn.wise.sc.energy.power.plant.business.service.ICharacterParamService
;
import
cn.wise.sc.energy.power.plant.business.service.IndexRealTimeDataServiceV2
;
import
cn.wise.sc.energy.power.plant.business.service2.ICharacterParamService
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.ConcurrentHashMap
;
...
@@ -31,26 +27,13 @@ public class ScheduledModel {
...
@@ -31,26 +27,13 @@ public class ScheduledModel {
final
final
WebSocketServer2
webSocketServer2
;
WebSocketServer2
webSocketServer2
;
final
final
IndexRealDataController
indexRealDataController
;
final
IndexRealTimeDataServiceV2
indexRealTimeDataServiceV2
;
final
IndexRealTimeDataService
indexRealTimeDataService
;
final
ICharacterParamService
iCharacterParamService
;
ICharacterParamService
iCharacterParamService
;
public
ScheduledModel
(
WebSocketServer
webSocketServer
,
public
ScheduledModel
(
WebSocketServer
webSocketServer
,
IndexRealTimeDataService
indexRealTimeDataService
,
WebSocketServer2
webSocketServer2
,
WebSocketServer2
webSocketServer2
,
IndexRealDataController
indexRealDataController
,
IndexRealTimeDataServiceV2
indexRealTimeDataServiceV2
,
ICharacterParamService
iCharacterParamService
)
{
ICharacterParamService
iCharacterParamService
)
{
this
.
webSocketServer
=
webSocketServer
;
this
.
webSocketServer
=
webSocketServer
;
this
.
indexRealTimeDataService
=
indexRealTimeDataService
;
this
.
webSocketServer2
=
webSocketServer2
;
this
.
webSocketServer2
=
webSocketServer2
;
this
.
indexRealDataController
=
indexRealDataController
;
this
.
indexRealTimeDataServiceV2
=
indexRealTimeDataServiceV2
;
this
.
iCharacterParamService
=
iCharacterParamService
;
this
.
iCharacterParamService
=
iCharacterParamService
;
}
}
...
...
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