Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-biz
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
项目统一框架
amos-boot-biz
Commits
f02aed27
Commit
f02aed27
authored
Jan 11, 2024
by
wujiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改告警时间格式化
parent
d05bf786
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
120 additions
and
111 deletions
+120
-111
DemoController.java
...amos/boot/module/jxiop/biz/controller/DemoController.java
+107
-104
EquipAlarmEventServiceImpl.java
...le/jxiop/biz/service/impl/EquipAlarmEventServiceImpl.java
+8
-2
application-dev.properties
...op-warn-biz/src/main/resources/application-dev.properties
+5
-5
No files found.
amos-boot-system-jxiop/amos-boot-module-jxiop-monitor-biz/src/main/java/com/yeejoin/amos/boot/module/jxiop/biz/controller/DemoController.java
View file @
f02aed27
package
com
.
yeejoin
.
amos
.
boot
.
module
.
jxiop
.
biz
.
controller
;
import
com.alibaba.excel.EasyExcel
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
...
...
@@ -57,7 +56,6 @@ import java.io.InputStream;
import
java.text.DecimalFormat
;
import
java.util.*
;
@RestController
@Api
(
tags
=
"Demo-test"
)
@RequestMapping
(
value
=
"/demo"
)
...
...
@@ -123,8 +121,9 @@ public class DemoController extends BaseController {
@ApiOperation
(
value
=
"初始化influxdb-风电、光伏、升压站"
)
@GetMapping
(
"doc/test4"
)
public
ResponseModel
<
Integer
>
demoTest3
()
{
//数据说明 夏造风电、泰和光伏、夏造升压站、泰和升压站
String
[]
strings
=
{
"1668801435891929089"
,
"1669524885619085313"
,
"1668801570352926721"
,
"1669525017559306241"
};
// 数据说明 夏造风电、泰和光伏、夏造升压站、泰和升压站
String
[]
strings
=
{
"1668801435891929089"
,
"1669524885619085313"
,
"1668801570352926721"
,
"1669525017559306241"
};
elasticsearchTemplate
.
deleteIndex
(
ESEquipments
.
class
);
int
num
=
0
;
for
(
int
i
=
0
;
i
<
strings
.
length
;
i
++)
{
...
...
@@ -140,29 +139,19 @@ public class DemoController extends BaseController {
List
<
ESEquipments
>
listit
=
new
ArrayList
<>();
for
(
EquipmentsJxiopDocMysql
monitorFanIndicator
:
list
)
{
ESEquipments
eSEquipments
=
new
ESEquipments
(
monitorFanIndicator
.
getValueF
(),
monitorFanIndicator
.
getId
(),
monitorFanIndicator
.
getAddress
(),
monitorFanIndicator
.
getDataType
(),
monitorFanIndicator
.
getEquipmentSpecificName
(),
monitorFanIndicator
.
getGatewayId
(),
monitorFanIndicator
.
getIsAlarm
(),
monitorFanIndicator
.
getCreatedTime
(),
monitorFanIndicator
.
getUnit
(),
monitorFanIndicator
.
getValue
(),
monitorFanIndicator
.
getValueLabel
(),
monitorFanIndicator
.
getTraceId
(),
monitorFanIndicator
.
getEquipmentIndexName
(),
monitorFanIndicator
.
getEquipmentNumber
(),
monitorFanIndicator
.
getFrontModule
(),
monitorFanIndicator
.
getSystemType
(),
monitorFanIndicator
.
getPictureName
(),
ESEquipments
eSEquipments
=
new
ESEquipments
(
monitorFanIndicator
.
getValueF
(),
monitorFanIndicator
.
getId
(),
monitorFanIndicator
.
getAddress
(),
monitorFanIndicator
.
getDataType
(),
monitorFanIndicator
.
getEquipmentSpecificName
(),
monitorFanIndicator
.
getGatewayId
(),
monitorFanIndicator
.
getIsAlarm
(),
monitorFanIndicator
.
getCreatedTime
(),
monitorFanIndicator
.
getUnit
(),
monitorFanIndicator
.
getValue
(),
monitorFanIndicator
.
getValueLabel
(),
monitorFanIndicator
.
getTraceId
(),
monitorFanIndicator
.
getEquipmentIndexName
(),
monitorFanIndicator
.
getEquipmentNumber
(),
monitorFanIndicator
.
getFrontModule
(),
monitorFanIndicator
.
getSystemType
(),
monitorFanIndicator
.
getPictureName
(),
monitorFanIndicator
.
getDisplayName
());
listit
.
add
(
eSEquipments
);
// Map<String, String> tag = new HashMap<>();
// Map<String, Object> maps2 = new HashMap<>();
//
...
...
@@ -197,11 +186,13 @@ public class DemoController extends BaseController {
@GetMapping
(
"doc/getDatafromEsToMysql"
)
public
void
getDatafromEsToMysql
()
{
try
{
List
<
ESEquipments
>
result
=
elasticSearchUtil
.
searchResponse
(
"jxiop_equipments"
,
null
,
hit
->
JSONObject
.
parseObject
(
hit
.
getSourceAsString
(),
ESEquipments
.
class
));
List
<
ESEquipments
>
result
=
elasticSearchUtil
.
searchResponse
(
"jxiop_equipments"
,
null
,
hit
->
JSONObject
.
parseObject
(
hit
.
getSourceAsString
(),
ESEquipments
.
class
));
result
.
forEach
(
esEquipments
->
{
EquipmentsJxiopDocMysql
equipmentsJxiopDocMysql
=
new
EquipmentsJxiopDocMysql
();
BeanUtils
.
copyProperties
(
esEquipments
,
equipmentsJxiopDocMysql
);
if
(
ObjectUtils
.
isEmpty
(
equipmentsJxiopDocMysqlMapper
.
selectList
(
new
QueryWrapper
<
EquipmentsJxiopDocMysql
>().
eq
(
"id"
,
equipmentsJxiopDocMysql
.
getId
()))))
{
if
(
ObjectUtils
.
isEmpty
(
equipmentsJxiopDocMysqlMapper
.
selectList
(
new
QueryWrapper
<
EquipmentsJxiopDocMysql
>().
eq
(
"id"
,
equipmentsJxiopDocMysql
.
getId
()))))
{
equipmentsJxiopDocMysqlMapper
.
insert
(
equipmentsJxiopDocMysql
);
}
else
{
equipmentsJxiopDocMysqlMapper
.
updateById
(
equipmentsJxiopDocMysql
);
...
...
@@ -218,31 +209,56 @@ public class DemoController extends BaseController {
@GetMapping
(
"doc/getDatafromMySqlToES"
)
public
void
getDatafromMySqlToES
()
{
// List<EquipmentsJxiopDocMysql> equipmentsJxiopDocMysqlList = equipmentsJxiopDocMysqlMapper.selectList(new QueryWrapper<EquipmentsJxiopDocMysql>().eq("id","24_1669525017559306241"));
List
<
EquipmentsJxiopDocMysql
>
equipmentsJxiopDocMysqlList
=
equipmentsJxiopDocMysqlMapper
.
selectList
(
new
QueryWrapper
<
EquipmentsJxiopDocMysql
>().
isNotNull
(
"id"
));
equipmentsJxiopDocMysqlList
.
forEach
(
equipmentsJxiopDocMysql
->
{
ESEquipments
esEquipments
=
equipmentsRepository
.
findById
(
equipmentsJxiopDocMysql
.
getId
()).
get
()
;
esEquipments
.
setEquipmentIndexName
(
equipmentsJxiopDocMysql
.
getEquipmentIndexName
());
esEquipments
.
setEquipmentNumber
(
ObjectUtils
.
isEmpty
(
equipmentsJxiopDocMysql
.
getEquipmentNumber
())
?
""
:
equipmentsJxiopDocMysql
.
getEquipmentNumber
());
esEquipments
.
setIsAlarm
(
equipmentsJxiopDocMysql
.
getIsAlarm
()
);
esEquipments
.
setDataType
(
equipmentsJxiopDocMysql
.
getDataType
()
);
esEquipments
.
setGatewayId
(
equipmentsJxiopDocMysql
.
getGateway
Id
());
List
<
EquipmentsJxiopDocMysql
>
equipmentsJxiopDocMysqlList
=
equipmentsJxiopDocMysqlMapper
.
selectList
(
new
QueryWrapper
<
EquipmentsJxiopDocMysql
>().
isNotNull
(
"id"
));
int
i
=
0
;
for
(
EquipmentsJxiopDocMysql
equipmentsJxiopDocMysql
:
equipmentsJxiopDocMysqlList
)
{
// ESEquipments esEquipments =
// equipmentsRepository.findById(equipmentsJxiopDocMysql.getId()).get(
);
ESEquipments
esEquipments
=
new
ESEquipments
(
);
esEquipments
.
setId
(
equipmentsJxiopDocMysql
.
get
Id
());
esEquipments
.
setAddress
(
equipmentsJxiopDocMysql
.
getAddress
());
esEquipments
.
setDataType
(
equipmentsJxiopDocMysql
.
getDataType
());
esEquipments
.
setEquipmentSpecificName
(
equipmentsJxiopDocMysql
.
getEquipmentSpecificName
());
//更新显示名称
esEquipments
.
setDisplayName
(
ObjectUtils
.
isEmpty
(
equipmentsJxiopDocMysql
.
getDisplayName
())
?
""
:
equipmentsJxiopDocMysql
.
getDisplayName
());
//更新排序号
esEquipments
.
setTraceId
(
ObjectUtils
.
isEmpty
(
equipmentsJxiopDocMysql
.
getTraceId
())
?
""
:
equipmentsJxiopDocMysql
.
getTraceId
());
//更新单位
esEquipments
.
setUnit
(
ObjectUtils
.
isEmpty
(
equipmentsJxiopDocMysql
.
getUnit
())
?
""
:
equipmentsJxiopDocMysql
.
getUnit
());
//更新frontModule
esEquipments
.
setFrontModule
(
ObjectUtils
.
isEmpty
(
equipmentsJxiopDocMysql
.
getFrontModule
())
?
""
:
equipmentsJxiopDocMysql
.
getFrontModule
());
//更新systemType
esEquipments
.
setSystemType
(
ObjectUtils
.
isEmpty
(
equipmentsJxiopDocMysql
.
getSystemType
())
?
""
:
equipmentsJxiopDocMysql
.
getSystemType
());
//更新图片名称
esEquipments
.
setPictureName
(
ObjectUtils
.
isEmpty
(
equipmentsJxiopDocMysql
.
getPictureName
())
?
""
:
equipmentsJxiopDocMysql
.
getPictureName
());
esEquipments
.
setGatewayId
(
equipmentsJxiopDocMysql
.
getGatewayId
());
esEquipments
.
setIsAlarm
(
equipmentsJxiopDocMysql
.
getIsAlarm
());
// 更新单位
esEquipments
.
setUnit
(
ObjectUtils
.
isEmpty
(
equipmentsJxiopDocMysql
.
getUnit
())
?
""
:
equipmentsJxiopDocMysql
.
getUnit
());
esEquipments
.
setCreatedTime
(
equipmentsJxiopDocMysql
.
getCreatedTime
());
esEquipments
.
setValue
(
ObjectUtils
.
isEmpty
(
equipmentsJxiopDocMysql
.
getValue
())
?
""
:
equipmentsJxiopDocMysql
.
getValue
());
esEquipments
.
setValueF
(
ObjectUtils
.
isEmpty
(
equipmentsJxiopDocMysql
.
getValueF
())
?
0
:
equipmentsJxiopDocMysql
.
getValueF
());
esEquipments
.
setValueLabel
(
ObjectUtils
.
isEmpty
(
equipmentsJxiopDocMysql
.
getValueLabel
())
?
""
:
equipmentsJxiopDocMysql
.
getValueLabel
());
// 更新排序号
esEquipments
.
setTraceId
(
ObjectUtils
.
isEmpty
(
equipmentsJxiopDocMysql
.
getTraceId
())
?
""
:
equipmentsJxiopDocMysql
.
getTraceId
());
esEquipments
.
setEquipmentIndexName
(
ObjectUtils
.
isEmpty
(
equipmentsJxiopDocMysql
.
getEquipmentIndexName
())
?
""
:
equipmentsJxiopDocMysql
.
getEquipmentIndexName
());
esEquipments
.
setEquipmentNumber
(
ObjectUtils
.
isEmpty
(
equipmentsJxiopDocMysql
.
getEquipmentNumber
())
?
""
:
equipmentsJxiopDocMysql
.
getEquipmentNumber
());
// 更新显示名称
esEquipments
.
setDisplayName
(
ObjectUtils
.
isEmpty
(
equipmentsJxiopDocMysql
.
getDisplayName
())
?
""
:
equipmentsJxiopDocMysql
.
getDisplayName
());
// 更新frontModule
esEquipments
.
setFrontModule
(
ObjectUtils
.
isEmpty
(
equipmentsJxiopDocMysql
.
getFrontModule
())
?
""
:
equipmentsJxiopDocMysql
.
getFrontModule
());
// 更新systemType
esEquipments
.
setSystemType
(
ObjectUtils
.
isEmpty
(
equipmentsJxiopDocMysql
.
getSystemType
())
?
""
:
equipmentsJxiopDocMysql
.
getSystemType
());
// 更新图片名称
esEquipments
.
setPictureName
(
ObjectUtils
.
isEmpty
(
equipmentsJxiopDocMysql
.
getPictureName
())
?
""
:
equipmentsJxiopDocMysql
.
getPictureName
());
System
.
out
.
println
(
"开始保存es"
+
++
i
);
try
{
equipmentsRepository
.
save
(
esEquipments
);
});
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
System
.
out
.
println
(
"结束保存es"
+
i
);
}
}
@TycloudOperation
(
needAuth
=
false
,
ApiLevel
=
UserType
.
AGENCY
)
...
...
@@ -251,31 +267,40 @@ public class DemoController extends BaseController {
public
void
getDatafromMySqlToES
(
@RequestParam
String
filePath
)
{
try
{
InputStream
inputStream
=
new
FileInputStream
(
filePath
);
List
<
Object
>
pointImportDtoList
=
EasyExcel
.
read
(
inputStream
).
head
(
PointImportDto
.
class
).
sheet
(
0
).
headRowNumber
(
1
).
doReadSync
();
List
<
Object
>
pointImportDtoList
=
EasyExcel
.
read
(
inputStream
).
head
(
PointImportDto
.
class
).
sheet
(
0
)
.
headRowNumber
(
1
).
doReadSync
();
pointImportDtoList
.
forEach
(
o
->
{
PointImportDto
pointImportDto
=
(
PointImportDto
)
o
;
List
<
EquipmentsJxiopDocMysql
>
equipmentsJxiopDocMysqlList
=
equipmentsJxiopDocMysqlMapper
.
selectList
(
new
QueryWrapper
<
EquipmentsJxiopDocMysql
>().
eq
(
"gateway_id"
,
pointImportDto
.
getGatewayId
()).
eq
(
"equipment_index_name"
,
pointImportDto
.
getEquipmentIndexName
()));
List
<
EquipmentsJxiopDocMysql
>
equipmentsJxiopDocMysqlList
=
equipmentsJxiopDocMysqlMapper
.
selectList
(
new
QueryWrapper
<
EquipmentsJxiopDocMysql
>().
eq
(
"gateway_id"
,
pointImportDto
.
getGatewayId
())
.
eq
(
"equipment_index_name"
,
pointImportDto
.
getEquipmentIndexName
()));
if
(!
ObjectUtils
.
isEmpty
(
equipmentsJxiopDocMysqlList
))
{
equipmentsJxiopDocMysqlList
.
forEach
(
equipmentsJxiopDocMysql
->
{
ESEquipments
esEquipments
=
equipmentsRepository
.
findById
(
equipmentsJxiopDocMysql
.
getId
()).
get
();
//更新模块
ESEquipments
esEquipments
=
equipmentsRepository
.
findById
(
equipmentsJxiopDocMysql
.
getId
())
.
get
();
// 更新模块
if
(!
equipmentsJxiopDocMysql
.
getFrontModule
().
contains
(
pointImportDto
.
getFrontModule
()))
{
equipmentsJxiopDocMysql
.
setFrontModule
(
equipmentsJxiopDocMysql
.
getFrontModule
()
+
","
+
pointImportDto
.
getFrontModule
());
esEquipments
.
setFrontModule
(
equipmentsJxiopDocMysql
.
getFrontModule
()
+
","
+
pointImportDto
.
getFrontModule
());
equipmentsJxiopDocMysql
.
setFrontModule
(
equipmentsJxiopDocMysql
.
getFrontModule
()
+
","
+
pointImportDto
.
getFrontModule
());
esEquipments
.
setFrontModule
(
equipmentsJxiopDocMysql
.
getFrontModule
()
+
","
+
pointImportDto
.
getFrontModule
());
}
//
更新类型
//
更新类型
if
(!
equipmentsJxiopDocMysql
.
getSystemType
().
contains
(
pointImportDto
.
getSystemType
()))
{
equipmentsJxiopDocMysql
.
setSystemType
(
equipmentsJxiopDocMysql
.
getSystemType
()+
","
+
pointImportDto
.
getSystemType
());
esEquipments
.
setSystemType
(
equipmentsJxiopDocMysql
.
getSystemType
()+
","
+
pointImportDto
.
getSystemType
());
equipmentsJxiopDocMysql
.
setSystemType
(
equipmentsJxiopDocMysql
.
getSystemType
()
+
","
+
pointImportDto
.
getSystemType
());
esEquipments
.
setSystemType
(
equipmentsJxiopDocMysql
.
getSystemType
()
+
","
+
pointImportDto
.
getSystemType
());
}
//
更新排序号
//
更新排序号
equipmentsJxiopDocMysql
.
setTraceId
(
pointImportDto
.
getTraceId
());
esEquipments
.
setTraceId
(
pointImportDto
.
getTraceId
());
//
更新显示名称
//
更新显示名称
equipmentsJxiopDocMysql
.
setDisplayName
(
pointImportDto
.
getDisplayName
());
esEquipments
.
setDisplayName
(
pointImportDto
.
getDisplayName
());
//更新单位 如果单位为空或者单位超过周期性数据存储长度则丢弃单位更新操作
if
(!
ObjectUtils
.
isEmpty
(
pointImportDto
.
getUnit
())
&&
(
pointImportDto
.
getUnit
().
toCharArray
().
length
<
24
))
{
// 更新单位 如果单位为空或者单位超过周期性数据存储长度则丢弃单位更新操作
if
(!
ObjectUtils
.
isEmpty
(
pointImportDto
.
getUnit
())
&&
(
pointImportDto
.
getUnit
().
toCharArray
().
length
<
24
))
{
equipmentsJxiopDocMysql
.
setUnit
(
pointImportDto
.
getUnit
());
esEquipments
.
setUnit
(
pointImportDto
.
getUnit
());
}
...
...
@@ -299,7 +324,8 @@ public class DemoController extends BaseController {
hashMap
.
put
(
"test1"
,
String
.
valueOf
(
Math
.
random
()
*
100
));
try
{
emqKeeper
.
getMqttClient
().
publish
(
"test_topic"
,
JSON
.
toJSON
(
hashMap
).
toString
().
getBytes
(
"UTF-8"
),
1
,
true
);
emqKeeper
.
getMqttClient
().
publish
(
"test_topic1"
,
JSON
.
toJSON
(
hashMap
).
toString
().
getBytes
(
"UTF-8"
),
1
,
true
);
emqKeeper
.
getMqttClient
().
publish
(
"test_topic1"
,
JSON
.
toJSON
(
hashMap
).
toString
().
getBytes
(
"UTF-8"
),
1
,
true
);
logger
.
info
(
"++++++++++++++++++++++++++++++++++发送消息成功++++++++++++++++++++++++++++++++++++++"
);
}
catch
(
Exception
exception
)
{
logger
.
error
(
"============================================================发送消息报错"
);
...
...
@@ -310,8 +336,8 @@ public class DemoController extends BaseController {
@ApiOperation
(
value
=
"初始化升压站"
)
@GetMapping
(
"/test6"
)
public
ResponseModel
<
Integer
>
demoTest5
()
{
//
数据说明 夏造风电、泰和光伏、夏造升压站、泰和升压站
String
[]
strings
=
{
"1668801570352926721"
,
"1669525017559306241"
};
//
数据说明 夏造风电、泰和光伏、夏造升压站、泰和升压站
String
[]
strings
=
{
"1668801570352926721"
,
"1669525017559306241"
};
// String [] strings = {"1669525017559306241"};
// Object o=this.monitorFanIndicatorImpl.getIndicatoralueAvage("1668801435891929089","60秒平均风速");
// System.out.println(o.toString());
...
...
@@ -331,30 +357,19 @@ public class DemoController extends BaseController {
List
<
ESEquipments
>
listit
=
new
ArrayList
<>();
for
(
EquipmentsJxiopDocMysql
monitorFanIndicator
:
list
)
{
ESEquipments
eSEquipments
=
new
ESEquipments
(
monitorFanIndicator
.
getValueF
(),
monitorFanIndicator
.
getId
(),
monitorFanIndicator
.
getAddress
(),
monitorFanIndicator
.
getDataType
(),
monitorFanIndicator
.
getEquipmentSpecificName
(),
monitorFanIndicator
.
getGatewayId
(),
monitorFanIndicator
.
getIsAlarm
(),
monitorFanIndicator
.
getCreatedTime
(),
monitorFanIndicator
.
getUnit
(),
monitorFanIndicator
.
getValue
(),
monitorFanIndicator
.
getValueLabel
(),
monitorFanIndicator
.
getTraceId
(),
monitorFanIndicator
.
getEquipmentIndexName
(),
monitorFanIndicator
.
getEquipmentNumber
(),
monitorFanIndicator
.
getFrontModule
(),
monitorFanIndicator
.
getSystemType
(),
monitorFanIndicator
.
getPictureName
(),
ESEquipments
eSEquipments
=
new
ESEquipments
(
monitorFanIndicator
.
getValueF
(),
monitorFanIndicator
.
getId
(),
monitorFanIndicator
.
getAddress
(),
monitorFanIndicator
.
getDataType
(),
monitorFanIndicator
.
getEquipmentSpecificName
(),
monitorFanIndicator
.
getGatewayId
(),
monitorFanIndicator
.
getIsAlarm
(),
monitorFanIndicator
.
getCreatedTime
(),
monitorFanIndicator
.
getUnit
(),
monitorFanIndicator
.
getValue
(),
monitorFanIndicator
.
getValueLabel
(),
monitorFanIndicator
.
getTraceId
(),
monitorFanIndicator
.
getEquipmentIndexName
(),
monitorFanIndicator
.
getEquipmentNumber
(),
monitorFanIndicator
.
getFrontModule
(),
monitorFanIndicator
.
getSystemType
(),
monitorFanIndicator
.
getPictureName
(),
monitorFanIndicator
.
getDisplayName
());
listit
.
add
(
eSEquipments
);
// Map<String, String> tag = new HashMap<>();
// Map<String, Object> maps2 = new HashMap<>();
//
...
...
@@ -401,11 +416,8 @@ public class DemoController extends BaseController {
QueryBuilder
queryBuilder
=
QueryBuilders
.
matchQuery
(
"equipmentIndexName"
,
"有功功率"
);
SumAggregationBuilder
buyCountSum
=
AggregationBuilders
.
sum
(
"buyCountSum"
).
field
(
"valueF"
);
Query
query
=
new
NativeSearchQueryBuilder
()
.
withQuery
(
queryBuilder
)
.
addAggregation
(
buyCountSum
)
.
withPageable
(
PageRequest
.
of
(
0
,
1
))
.
build
();
Query
query
=
new
NativeSearchQueryBuilder
().
withQuery
(
queryBuilder
).
addAggregation
(
buyCountSum
)
.
withPageable
(
PageRequest
.
of
(
0
,
1
)).
build
();
query
.
setTrackTotalHits
(
true
);
// 允许返回查询结果的total - search.getTotalHits()
SearchHits
<
ESEquipments
>
search
=
elasticsearchTemplate
.
search
(
query
,
ESEquipments
.
class
);
return
ResponseHelper
.
buildResponse
(
search
);
...
...
@@ -419,11 +431,8 @@ public class DemoController extends BaseController {
QueryBuilder
queryBuilder
=
QueryBuilders
.
matchQuery
(
"equipmentIndexName"
,
"有功功率"
);
AvgAggregationBuilder
buyCountAvg
=
AggregationBuilders
.
avg
(
"buyCountAvg"
).
field
(
"valueF"
);
Query
query
=
new
NativeSearchQueryBuilder
()
.
withQuery
(
queryBuilder
)
.
addAggregation
(
buyCountAvg
)
.
withPageable
(
PageRequest
.
of
(
0
,
1
))
.
build
();
Query
query
=
new
NativeSearchQueryBuilder
().
withQuery
(
queryBuilder
).
addAggregation
(
buyCountAvg
)
.
withPageable
(
PageRequest
.
of
(
0
,
1
)).
build
();
query
.
setTrackTotalHits
(
true
);
SearchHits
<
ESEquipments
>
search
=
elasticsearchTemplate
.
search
(
query
,
ESEquipments
.
class
);
...
...
@@ -431,30 +440,25 @@ public class DemoController extends BaseController {
return
ResponseHelper
.
buildResponse
(
search
);
}
@TycloudOperation
(
needAuth
=
false
,
ApiLevel
=
UserType
.
AGENCY
)
@ApiOperation
(
value
=
"分组求和数"
)
@GetMapping
(
"/test10"
)
public
SearchHits
demoTest10
()
{
QueryBuilder
queryBuilder
=
QueryBuilders
.
matchQuery
(
"equipmentIndexName"
,
"年发电量"
);
// 如果只对一个字段进行分组写一个就好
TermsAggregationBuilder
tb1
=
AggregationBuilders
.
terms
(
"group_gatewayId"
).
field
(
"gatewayId.keyword"
);
//gatewayId 是分组字段名,group_gatewayId是查询结果的别名
TermsAggregationBuilder
tb1
=
AggregationBuilders
.
terms
(
"group_gatewayId"
).
field
(
"gatewayId.keyword"
);
// gatewayId
// 是分组字段名,group_gatewayId是查询结果的别名
// TermsAggregationBuilder tb2 = AggregationBuilders.terms("group_equipmentNumber").field("equipmentNumber.keyword");//equipmentNumber 是分组字段名,group_equipmentNumber是查询结果的别名
SumAggregationBuilder
sb
=
AggregationBuilders
.
sum
(
"sum_valueDouble"
).
field
(
"valueF"
);
//
valueF是求和字段名称,sun_valueDouble是结果别名
SumAggregationBuilder
sb
=
AggregationBuilders
.
sum
(
"sum_valueDouble"
).
field
(
"valueF"
);
//
valueF是求和字段名称,sun_valueDouble是结果别名
// 注意顺序,决定先通过谁分组
tb1
.
subAggregation
(
sb
);
// 通过typeId字段分组统计总数
// tb2.subAggregation(sb); // 通过houseId字段分组统计总数
// tb1.subAggregation(tb2); // 合并
Query
query
=
new
NativeSearchQueryBuilder
()
.
withQuery
(
queryBuilder
)
.
addAggregation
(
tb1
)
.
withPageable
(
PageRequest
.
of
(
0
,
1
))
.
build
();
Query
query
=
new
NativeSearchQueryBuilder
().
withQuery
(
queryBuilder
).
addAggregation
(
tb1
)
.
withPageable
(
PageRequest
.
of
(
0
,
1
)).
build
();
query
.
setTrackTotalHits
(
true
);
SearchHits
search
=
elasticsearchTemplate
.
search
(
query
,
ESEquipments
.
class
);
...
...
@@ -497,4 +501,3 @@ public class DemoController extends BaseController {
commonServiceImpl
.
getListDataByCondtions
(
queryConditon
,
null
,
ESEquipments
.
class
);
}
}
amos-boot-system-jxiop/amos-boot-module-jxiop-warn-biz/src/main/java/com/yeejoin/amos/boot/module/jxiop/biz/service/impl/EquipAlarmEventServiceImpl.java
View file @
f02aed27
...
...
@@ -64,10 +64,16 @@ public class EquipAlarmEventServiceImpl
}
else
if
(
"false"
.
equals
(
i
.
getValue
()))
{
i
.
setValue
(
"分"
);
}
long
mills
=
i
.
getCreatedTime
()
/
1000000
;
long
mills
=
i
.
getCreatedTime
()
;
car
.
setTimeInMillis
(
mills
);
// System.out.println(sdf.format(car.getTime()));
i
.
setTime
(
sdf
.
format
(
car
.
getTime
()));
String
time
=
sdf
.
format
(
car
.
getTime
());
if
(
time
.
contains
(
"1970"
))
{
mills
=
i
.
getCreatedTime
()/
1000000
;;
car
.
setTimeInMillis
(
mills
);
time
=
sdf
.
format
(
car
.
getTime
());
}
i
.
setTime
(
time
);
// car.add(Calendar.HOUR, 12);
// System.out.println(sdf.format(car.getTime()));
});
...
...
amos-boot-system-jxiop/amos-boot-module-jxiop-warn-biz/src/main/resources/application-dev.properties
View file @
f02aed27
...
...
@@ -14,17 +14,17 @@ spring.db2.datasource.driver-class-name: com.mysql.cj.jdbc.Driver
## db3-td-engine
#spring.db3.datasource.type: com.alibaba.druid.pool.DruidDataSource
spring.db3.datasource.url
=
jdbc:TAOS-RS://1
39.9.170.47
:6041/iot_data?user=root&password=taosdata&timezone=GMT%2b8&allowMultiQueries=true
spring.db3.datasource.url
=
jdbc:TAOS-RS://1
0.20.0.203
:6041/iot_data?user=root&password=taosdata&timezone=GMT%2b8&allowMultiQueries=true
spring.db3.datasource.username
=
root
spring.db3.datasource.password
=
taosdata
spring.db3.datasource.driver-class-name
:
com.taosdata.jdbc.rs.RestfulDriver
## eureka properties:
eureka.instance.hostname
=
1
72.16.10.220
eureka.instance.hostname
=
1
39.9.173.44
eureka.client.serviceUrl.defaultZone
=
http://admin:a1234560@${eureka.instance.hostname}:10001/eureka/
## redis properties:
spring.redis.database
=
1
spring.redis.host
=
1
72.16.10.220
spring.redis.host
=
1
39.9.173.44
spring.redis.port
=
6379
spring.redis.password
=
yeejoin@2020
...
...
@@ -60,10 +60,10 @@ lettuce.timeout=10000
emqx.clean-session
=
true
emqx.client-id
=
${spring.application.name}-${random.int[1024,65536]}
emqx.broker
=
tcp://1
72.16.10.220:1
883
emqx.broker
=
tcp://1
39.9.173.44:2
883
emqx.user-name
=
admin
emqx.password
=
public
mqtt.scene.host
=
mqtt://1
72.16.10.220
:8083/mqtt
mqtt.scene.host
=
mqtt://1
39.9.173.44
:8083/mqtt
mqtt.client.product.id
=
mqtt
mqtt.topic
=
topic_mqtt
spring.mqtt.completionTimeout
=
3000
...
...
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