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
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
383 additions
and
374 deletions
+383
-374
DemoController.java
...amos/boot/module/jxiop/biz/controller/DemoController.java
+370
-367
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
;
package
com
.
yeejoin
.
amos
.
boot
.
module
.
jxiop
.
biz
.
controller
;
import
com.alibaba.excel.EasyExcel
;
import
com.alibaba.excel.EasyExcel
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
...
@@ -57,111 +56,101 @@ import java.io.InputStream;
...
@@ -57,111 +56,101 @@ import java.io.InputStream;
import
java.text.DecimalFormat
;
import
java.text.DecimalFormat
;
import
java.util.*
;
import
java.util.*
;
@RestController
@RestController
@Api
(
tags
=
"Demo-test"
)
@Api
(
tags
=
"Demo-test"
)
@RequestMapping
(
value
=
"/demo"
)
@RequestMapping
(
value
=
"/demo"
)
public
class
DemoController
extends
BaseController
{
public
class
DemoController
extends
BaseController
{
//
@Autowired
//
@Autowired
// LargeScreenImpl largeScreenImpl;
// LargeScreenImpl largeScreenImpl;
private
final
String
ss
=
"瞬时风速"
;
private
final
String
ss
=
"瞬时风速"
;
private
final
String
zfs
=
"WTX-801_25_WTX-801_总辐射"
;
private
final
String
zfs
=
"WTX-801_25_WTX-801_总辐射"
;
private
final
String
zfslj
=
"WTX-801_25_WTX-801_总辐射累计"
;
private
final
String
zfslj
=
"WTX-801_25_WTX-801_总辐射累计"
;
// @Resource
// @Resource
// InfluxDbConnection influxDbConnection;
// InfluxDbConnection influxDbConnection;
//
@Autowired
//
@Autowired
// InfluxDButils influxDButils;
// InfluxDButils influxDButils;
private
final
String
dayvalue
=
"日发电量"
;
private
final
String
dayvalue
=
"日发电量"
;
private
final
String
moonValue
=
"月发电量"
;
private
final
String
moonValue
=
"月发电量"
;
private
final
String
yearValue
=
"年发电量"
;
private
final
String
yearValue
=
"年发电量"
;
private
final
String
dayDateFormat
=
"yyyy-MM-dd"
;
private
final
String
dayDateFormat
=
"yyyy-MM-dd"
;
private
final
String
moonDateFormat
=
"yyyy-MM"
;
private
final
String
moonDateFormat
=
"yyyy-MM"
;
private
final
String
yearDateFormat
=
"yyyy"
;
private
final
String
yearDateFormat
=
"yyyy"
;
//
@Autowired
//
@Autowired
// PowerGenerationImpl powerGenerationImpl;
// PowerGenerationImpl powerGenerationImpl;
private
final
String
dayType
=
"day"
;
private
final
String
dayType
=
"day"
;
private
final
String
moonType
=
"moon"
;
private
final
String
moonType
=
"moon"
;
private
final
String
yearType
=
"year"
;
private
final
String
yearType
=
"year"
;
Logger
logger
=
LoggerFactory
.
getLogger
(
DemoController
.
class
);
Logger
logger
=
LoggerFactory
.
getLogger
(
DemoController
.
class
);
@Autowired
@Autowired
StationBasicServiceImpl
stationBasicServiceimpl
;
StationBasicServiceImpl
stationBasicServiceimpl
;
@Autowired
@Autowired
TestServiceImpl
testServiceimpl
;
TestServiceImpl
testServiceimpl
;
@Autowired
@Autowired
EmqKeeper
emqKeeper
;
EmqKeeper
emqKeeper
;
@Autowired
@Autowired
ESEquipmentsRepository
equipmentsRepository
;
ESEquipmentsRepository
equipmentsRepository
;
@Autowired
@Autowired
CommonServiceImpl
commonServiceImpl
;
CommonServiceImpl
commonServiceImpl
;
@Autowired
@Autowired
ElasticSearchUtil
elasticSearchUtil
;
ElasticSearchUtil
elasticSearchUtil
;
@Autowired
@Autowired
private
MonitorFanIndicatorMapper
monitorFanIndicatorregionMapper
;
private
MonitorFanIndicatorMapper
monitorFanIndicatorregionMapper
;
@Autowired
@Autowired
private
ElasticsearchRestTemplate
elasticsearchTemplate
;
private
ElasticsearchRestTemplate
elasticsearchTemplate
;
@Autowired
@Autowired
private
EquipmentsJxiopDocMysqlMapper
equipmentsJxiopDocMysqlMapper
;
private
EquipmentsJxiopDocMysqlMapper
equipmentsJxiopDocMysqlMapper
;
@TycloudOperation
(
needAuth
=
false
,
ApiLevel
=
UserType
.
AGENCY
)
@TycloudOperation
(
needAuth
=
false
,
ApiLevel
=
UserType
.
AGENCY
)
@ApiOperation
(
value
=
"手动更新场站缓存信息接口"
)
@ApiOperation
(
value
=
"手动更新场站缓存信息接口"
)
@GetMapping
(
"/updateStationCacheInfo"
)
@GetMapping
(
"/updateStationCacheInfo"
)
public
String
updateStationCacheInfo
()
{
public
String
updateStationCacheInfo
()
{
String
updateResult
=
"更新场站信息缓存成功"
;
String
updateResult
=
"更新场站信息缓存成功"
;
try
{
try
{
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
updateResult
=
"更新场站信息缓存成功"
;
updateResult
=
"更新场站信息缓存成功"
;
throw
new
RuntimeException
(
e
);
throw
new
RuntimeException
(
e
);
}
}
return
updateResult
;
return
updateResult
;
}
}
@TycloudOperation
(
needAuth
=
false
,
ApiLevel
=
UserType
.
AGENCY
)
@TycloudOperation
(
needAuth
=
false
,
ApiLevel
=
UserType
.
AGENCY
)
@ApiOperation
(
value
=
"初始化influxdb-风电、光伏、升压站"
)
@ApiOperation
(
value
=
"初始化influxdb-风电、光伏、升压站"
)
@GetMapping
(
"doc/test4"
)
@GetMapping
(
"doc/test4"
)
public
ResponseModel
<
Integer
>
demoTest3
()
{
public
ResponseModel
<
Integer
>
demoTest3
()
{
//数据说明 夏造风电、泰和光伏、夏造升压站、泰和升压站
// 数据说明 夏造风电、泰和光伏、夏造升压站、泰和升压站
String
[]
strings
=
{
"1668801435891929089"
,
"1669524885619085313"
,
"1668801570352926721"
,
"1669525017559306241"
};
String
[]
strings
=
{
"1668801435891929089"
,
"1669524885619085313"
,
"1668801570352926721"
,
elasticsearchTemplate
.
deleteIndex
(
ESEquipments
.
class
);
"1669525017559306241"
};
int
num
=
0
;
elasticsearchTemplate
.
deleteIndex
(
ESEquipments
.
class
);
for
(
int
i
=
0
;
i
<
strings
.
length
;
i
++)
{
int
num
=
0
;
QueryWrapper
<
EquipmentsJxiopDocMysql
>
QueryWrapper
=
new
QueryWrapper
<>();
for
(
int
i
=
0
;
i
<
strings
.
length
;
i
++)
{
QueryWrapper
<
EquipmentsJxiopDocMysql
>
QueryWrapper
=
new
QueryWrapper
<>();
// 夏造风电
// 夏造风电
// QueryWrapper.eq("gateway", "1668801435891929089");
// QueryWrapper.eq("gateway", "1668801435891929089");
// 泰和光伏
// 泰和光伏
QueryWrapper
.
eq
(
"gateway"
,
strings
[
i
]);
QueryWrapper
.
eq
(
"gateway"
,
strings
[
i
]);
long
DATE
=
new
Date
().
getTime
();
long
DATE
=
new
Date
().
getTime
();
System
.
out
.
println
(
DATE
);
System
.
out
.
println
(
DATE
);
List
<
EquipmentsJxiopDocMysql
>
list
=
equipmentsJxiopDocMysqlMapper
.
selectList
(
QueryWrapper
);
List
<
EquipmentsJxiopDocMysql
>
list
=
equipmentsJxiopDocMysqlMapper
.
selectList
(
QueryWrapper
);
num
=
num
+
list
.
size
();
num
=
num
+
list
.
size
();
List
<
ESEquipments
>
listit
=
new
ArrayList
<>();
List
<
ESEquipments
>
listit
=
new
ArrayList
<>();
for
(
EquipmentsJxiopDocMysql
monitorFanIndicator
:
list
)
{
for
(
EquipmentsJxiopDocMysql
monitorFanIndicator
:
list
)
{
ESEquipments
eSEquipments
=
new
ESEquipments
(
ESEquipments
eSEquipments
=
new
ESEquipments
(
monitorFanIndicator
.
getValueF
(),
monitorFanIndicator
.
getValueF
(),
monitorFanIndicator
.
getId
(),
monitorFanIndicator
.
getAddress
(),
monitorFanIndicator
.
getId
(),
monitorFanIndicator
.
getDataType
(),
monitorFanIndicator
.
getEquipmentSpecificName
(),
monitorFanIndicator
.
getAddress
(),
monitorFanIndicator
.
getGatewayId
(),
monitorFanIndicator
.
getIsAlarm
(),
monitorFanIndicator
.
getDataType
(),
monitorFanIndicator
.
getCreatedTime
(),
monitorFanIndicator
.
getUnit
(),
monitorFanIndicator
.
getEquipmentSpecificName
(),
monitorFanIndicator
.
getValue
(),
monitorFanIndicator
.
getValueLabel
(),
monitorFanIndicator
.
getGatewayId
(),
monitorFanIndicator
.
getTraceId
(),
monitorFanIndicator
.
getEquipmentIndexName
(),
monitorFanIndicator
.
getIsAlarm
(),
monitorFanIndicator
.
getEquipmentNumber
(),
monitorFanIndicator
.
getFrontModule
(),
monitorFanIndicator
.
getCreatedTime
(),
monitorFanIndicator
.
getSystemType
(),
monitorFanIndicator
.
getPictureName
(),
monitorFanIndicator
.
getUnit
(),
monitorFanIndicator
.
getDisplayName
());
monitorFanIndicator
.
getValue
(),
monitorFanIndicator
.
getValueLabel
(),
listit
.
add
(
eSEquipments
);
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, String> tag = new HashMap<>();
// Map<String, Object> maps2 = new HashMap<>();
// Map<String, Object> maps2 = new HashMap<>();
...
@@ -186,174 +175,200 @@ public class DemoController extends BaseController {
...
@@ -186,174 +175,200 @@ public class DemoController extends BaseController {
// maps2.put("displayName", "");
// maps2.put("displayName", "");
// influxDbConnection.insert("indicators_" + monitorFanIndicator.getGateway(), tag, maps2, 1688558007051L, TimeUnit.MILLISECONDS);
// influxDbConnection.insert("indicators_" + monitorFanIndicator.getGateway(), tag, maps2, 1688558007051L, TimeUnit.MILLISECONDS);
}
}
equipmentsRepository
.
saveAll
(
listit
);
equipmentsRepository
.
saveAll
(
listit
);
}
}
return
ResponseHelper
.
buildResponse
(
num
);
return
ResponseHelper
.
buildResponse
(
num
);
}
}
@TycloudOperation
(
needAuth
=
false
,
ApiLevel
=
UserType
.
AGENCY
)
@TycloudOperation
(
needAuth
=
false
,
ApiLevel
=
UserType
.
AGENCY
)
@ApiOperation
(
value
=
"从ES获取数据反向插入mysql"
)
@ApiOperation
(
value
=
"从ES获取数据反向插入mysql"
)
@GetMapping
(
"doc/getDatafromEsToMysql"
)
@GetMapping
(
"doc/getDatafromEsToMysql"
)
public
void
getDatafromEsToMysql
()
{
public
void
getDatafromEsToMysql
()
{
try
{
try
{
List
<
ESEquipments
>
result
=
elasticSearchUtil
.
searchResponse
(
"jxiop_equipments"
,
null
,
hit
->
JSONObject
.
parseObject
(
hit
.
getSourceAsString
(),
ESEquipments
.
class
));
List
<
ESEquipments
>
result
=
elasticSearchUtil
.
searchResponse
(
"jxiop_equipments"
,
null
,
result
.
forEach
(
esEquipments
->
{
hit
->
JSONObject
.
parseObject
(
hit
.
getSourceAsString
(),
ESEquipments
.
class
));
EquipmentsJxiopDocMysql
equipmentsJxiopDocMysql
=
new
EquipmentsJxiopDocMysql
();
result
.
forEach
(
esEquipments
->
{
BeanUtils
.
copyProperties
(
esEquipments
,
equipmentsJxiopDocMysql
);
EquipmentsJxiopDocMysql
equipmentsJxiopDocMysql
=
new
EquipmentsJxiopDocMysql
();
if
(
ObjectUtils
.
isEmpty
(
equipmentsJxiopDocMysqlMapper
.
selectList
(
new
QueryWrapper
<
EquipmentsJxiopDocMysql
>().
eq
(
"id"
,
equipmentsJxiopDocMysql
.
getId
()))))
{
BeanUtils
.
copyProperties
(
esEquipments
,
equipmentsJxiopDocMysql
);
equipmentsJxiopDocMysqlMapper
.
insert
(
equipmentsJxiopDocMysql
);
if
(
ObjectUtils
.
isEmpty
(
equipmentsJxiopDocMysqlMapper
.
selectList
(
}
else
{
new
QueryWrapper
<
EquipmentsJxiopDocMysql
>().
eq
(
"id"
,
equipmentsJxiopDocMysql
.
getId
()))))
{
equipmentsJxiopDocMysqlMapper
.
updateById
(
equipmentsJxiopDocMysql
);
equipmentsJxiopDocMysqlMapper
.
insert
(
equipmentsJxiopDocMysql
);
}
}
else
{
equipmentsJxiopDocMysqlMapper
.
updateById
(
equipmentsJxiopDocMysql
);
});
}
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
});
}
}
catch
(
Exception
e
)
{
}
throw
new
RuntimeException
(
e
);
}
@TycloudOperation
(
needAuth
=
false
,
ApiLevel
=
UserType
.
AGENCY
)
}
@ApiOperation
(
value
=
"从Mysql同步数据到ES"
)
@GetMapping
(
"doc/getDatafromMySqlToES"
)
@TycloudOperation
(
needAuth
=
false
,
ApiLevel
=
UserType
.
AGENCY
)
public
void
getDatafromMySqlToES
()
{
@ApiOperation
(
value
=
"从Mysql同步数据到ES"
)
@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>().eq("id","24_1669525017559306241"));
List
<
EquipmentsJxiopDocMysql
>
equipmentsJxiopDocMysqlList
=
equipmentsJxiopDocMysqlMapper
.
selectList
(
new
QueryWrapper
<
EquipmentsJxiopDocMysql
>().
isNotNull
(
"id"
));
List
<
EquipmentsJxiopDocMysql
>
equipmentsJxiopDocMysqlList
=
equipmentsJxiopDocMysqlMapper
equipmentsJxiopDocMysqlList
.
forEach
(
equipmentsJxiopDocMysql
->
{
.
selectList
(
new
QueryWrapper
<
EquipmentsJxiopDocMysql
>().
isNotNull
(
"id"
));
ESEquipments
esEquipments
=
equipmentsRepository
.
findById
(
equipmentsJxiopDocMysql
.
getId
()).
get
();
int
i
=
0
;
esEquipments
.
setEquipmentIndexName
(
equipmentsJxiopDocMysql
.
getEquipmentIndexName
());
for
(
EquipmentsJxiopDocMysql
equipmentsJxiopDocMysql
:
equipmentsJxiopDocMysqlList
)
{
esEquipments
.
setEquipmentNumber
(
ObjectUtils
.
isEmpty
(
equipmentsJxiopDocMysql
.
getEquipmentNumber
())
?
""
:
equipmentsJxiopDocMysql
.
getEquipmentNumber
());
// ESEquipments esEquipments =
esEquipments
.
setIsAlarm
(
equipmentsJxiopDocMysql
.
getIsAlarm
());
// equipmentsRepository.findById(equipmentsJxiopDocMysql.getId()).get();
esEquipments
.
setDataType
(
equipmentsJxiopDocMysql
.
getDataType
());
ESEquipments
esEquipments
=
new
ESEquipments
();
esEquipments
.
setGatewayId
(
equipmentsJxiopDocMysql
.
getGatewayId
());
esEquipments
.
setId
(
equipmentsJxiopDocMysql
.
getId
());
esEquipments
.
setAddress
(
equipmentsJxiopDocMysql
.
getAddress
());
esEquipments
.
setAddress
(
equipmentsJxiopDocMysql
.
getAddress
());
esEquipments
.
setEquipmentSpecificName
(
equipmentsJxiopDocMysql
.
getEquipmentSpecificName
());
esEquipments
.
setDataType
(
equipmentsJxiopDocMysql
.
getDataType
());
//更新显示名称
esEquipments
.
setEquipmentSpecificName
(
equipmentsJxiopDocMysql
.
getEquipmentSpecificName
());
esEquipments
.
setDisplayName
(
ObjectUtils
.
isEmpty
(
equipmentsJxiopDocMysql
.
getDisplayName
())
?
""
:
equipmentsJxiopDocMysql
.
getDisplayName
());
esEquipments
.
setGatewayId
(
equipmentsJxiopDocMysql
.
getGatewayId
());
//更新排序号
esEquipments
.
setIsAlarm
(
equipmentsJxiopDocMysql
.
getIsAlarm
());
esEquipments
.
setTraceId
(
ObjectUtils
.
isEmpty
(
equipmentsJxiopDocMysql
.
getTraceId
())
?
""
:
equipmentsJxiopDocMysql
.
getTraceId
());
// 更新单位
//更新单位
esEquipments
.
setUnit
(
esEquipments
.
setUnit
(
ObjectUtils
.
isEmpty
(
equipmentsJxiopDocMysql
.
getUnit
())
?
""
:
equipmentsJxiopDocMysql
.
getUnit
());
ObjectUtils
.
isEmpty
(
equipmentsJxiopDocMysql
.
getUnit
())
?
""
:
equipmentsJxiopDocMysql
.
getUnit
());
//更新frontModule
esEquipments
.
setCreatedTime
(
equipmentsJxiopDocMysql
.
getCreatedTime
());
esEquipments
.
setFrontModule
(
ObjectUtils
.
isEmpty
(
equipmentsJxiopDocMysql
.
getFrontModule
())
?
""
:
equipmentsJxiopDocMysql
.
getFrontModule
());
esEquipments
.
setValue
(
//更新systemType
ObjectUtils
.
isEmpty
(
equipmentsJxiopDocMysql
.
getValue
())
?
""
:
equipmentsJxiopDocMysql
.
getValue
());
esEquipments
.
setSystemType
(
ObjectUtils
.
isEmpty
(
equipmentsJxiopDocMysql
.
getSystemType
())
?
""
:
equipmentsJxiopDocMysql
.
getSystemType
());
esEquipments
.
setValueF
(
//更新图片名称
ObjectUtils
.
isEmpty
(
equipmentsJxiopDocMysql
.
getValueF
())
?
0
:
equipmentsJxiopDocMysql
.
getValueF
());
esEquipments
.
setPictureName
(
ObjectUtils
.
isEmpty
(
equipmentsJxiopDocMysql
.
getPictureName
())
?
""
:
equipmentsJxiopDocMysql
.
getPictureName
());
esEquipments
.
setValueLabel
(
ObjectUtils
.
isEmpty
(
equipmentsJxiopDocMysql
.
getValueLabel
())
?
""
equipmentsRepository
.
save
(
esEquipments
);
:
equipmentsJxiopDocMysql
.
getValueLabel
());
});
// 更新排序号
esEquipments
.
setTraceId
(
ObjectUtils
.
isEmpty
(
equipmentsJxiopDocMysql
.
getTraceId
())
?
""
}
:
equipmentsJxiopDocMysql
.
getTraceId
());
esEquipments
.
setEquipmentIndexName
(
ObjectUtils
.
isEmpty
(
equipmentsJxiopDocMysql
.
getEquipmentIndexName
())
?
""
@TycloudOperation
(
needAuth
=
false
,
ApiLevel
=
UserType
.
AGENCY
)
:
equipmentsJxiopDocMysql
.
getEquipmentIndexName
());
@ApiOperation
(
value
=
"导入整理的测点数据到MySQL同时更新es"
)
esEquipments
.
setEquipmentNumber
(
ObjectUtils
.
isEmpty
(
equipmentsJxiopDocMysql
.
getEquipmentNumber
())
?
""
@PostMapping
(
"doc/importDatafAndUpdateEs"
)
:
equipmentsJxiopDocMysql
.
getEquipmentNumber
());
public
void
getDatafromMySqlToES
(
@RequestParam
String
filePath
)
{
// 更新显示名称
try
{
esEquipments
.
setDisplayName
(
ObjectUtils
.
isEmpty
(
equipmentsJxiopDocMysql
.
getDisplayName
())
?
""
InputStream
inputStream
=
new
FileInputStream
(
filePath
);
:
equipmentsJxiopDocMysql
.
getDisplayName
());
List
<
Object
>
pointImportDtoList
=
EasyExcel
.
read
(
inputStream
).
head
(
PointImportDto
.
class
).
sheet
(
0
).
headRowNumber
(
1
).
doReadSync
();
// 更新frontModule
pointImportDtoList
.
forEach
(
o
->
{
esEquipments
.
setFrontModule
(
ObjectUtils
.
isEmpty
(
equipmentsJxiopDocMysql
.
getFrontModule
())
?
""
PointImportDto
pointImportDto
=
(
PointImportDto
)
o
;
:
equipmentsJxiopDocMysql
.
getFrontModule
());
List
<
EquipmentsJxiopDocMysql
>
equipmentsJxiopDocMysqlList
=
equipmentsJxiopDocMysqlMapper
.
selectList
(
new
QueryWrapper
<
EquipmentsJxiopDocMysql
>().
eq
(
"gateway_id"
,
pointImportDto
.
getGatewayId
()).
eq
(
"equipment_index_name"
,
pointImportDto
.
getEquipmentIndexName
()));
// 更新systemType
if
(!
ObjectUtils
.
isEmpty
(
equipmentsJxiopDocMysqlList
))
{
esEquipments
.
setSystemType
(
ObjectUtils
.
isEmpty
(
equipmentsJxiopDocMysql
.
getSystemType
())
?
""
equipmentsJxiopDocMysqlList
.
forEach
(
equipmentsJxiopDocMysql
->
{
:
equipmentsJxiopDocMysql
.
getSystemType
());
ESEquipments
esEquipments
=
equipmentsRepository
.
findById
(
equipmentsJxiopDocMysql
.
getId
()).
get
();
// 更新图片名称
//更新模块
esEquipments
.
setPictureName
(
ObjectUtils
.
isEmpty
(
equipmentsJxiopDocMysql
.
getPictureName
())
?
""
if
(!
equipmentsJxiopDocMysql
.
getFrontModule
().
contains
(
pointImportDto
.
getFrontModule
()))
{
:
equipmentsJxiopDocMysql
.
getPictureName
());
equipmentsJxiopDocMysql
.
setFrontModule
(
equipmentsJxiopDocMysql
.
getFrontModule
()
+
","
+
pointImportDto
.
getFrontModule
());
System
.
out
.
println
(
"开始保存es"
+
++
i
);
esEquipments
.
setFrontModule
(
equipmentsJxiopDocMysql
.
getFrontModule
()
+
","
+
pointImportDto
.
getFrontModule
());
try
{
}
equipmentsRepository
.
save
(
esEquipments
);
//更新类型
}
catch
(
Exception
e
)
{
if
(!
equipmentsJxiopDocMysql
.
getSystemType
().
contains
(
pointImportDto
.
getSystemType
()))
{
e
.
printStackTrace
();
equipmentsJxiopDocMysql
.
setSystemType
(
equipmentsJxiopDocMysql
.
getSystemType
()+
","
+
pointImportDto
.
getSystemType
());
}
esEquipments
.
setSystemType
(
equipmentsJxiopDocMysql
.
getSystemType
()+
","
+
pointImportDto
.
getSystemType
());
System
.
out
.
println
(
"结束保存es"
+
i
);
}
}
//更新排序号
}
equipmentsJxiopDocMysql
.
setTraceId
(
pointImportDto
.
getTraceId
());
esEquipments
.
setTraceId
(
pointImportDto
.
getTraceId
());
@TycloudOperation
(
needAuth
=
false
,
ApiLevel
=
UserType
.
AGENCY
)
//更新显示名称
@ApiOperation
(
value
=
"导入整理的测点数据到MySQL同时更新es"
)
equipmentsJxiopDocMysql
.
setDisplayName
(
pointImportDto
.
getDisplayName
());
@PostMapping
(
"doc/importDatafAndUpdateEs"
)
esEquipments
.
setDisplayName
(
pointImportDto
.
getDisplayName
());
public
void
getDatafromMySqlToES
(
@RequestParam
String
filePath
)
{
//更新单位 如果单位为空或者单位超过周期性数据存储长度则丢弃单位更新操作
try
{
if
(!
ObjectUtils
.
isEmpty
(
pointImportDto
.
getUnit
())
&&
(
pointImportDto
.
getUnit
().
toCharArray
().
length
<
24
))
{
InputStream
inputStream
=
new
FileInputStream
(
filePath
);
equipmentsJxiopDocMysql
.
setUnit
(
pointImportDto
.
getUnit
());
List
<
Object
>
pointImportDtoList
=
EasyExcel
.
read
(
inputStream
).
head
(
PointImportDto
.
class
).
sheet
(
0
)
esEquipments
.
setUnit
(
pointImportDto
.
getUnit
());
.
headRowNumber
(
1
).
doReadSync
();
}
pointImportDtoList
.
forEach
(
o
->
{
equipmentsJxiopDocMysqlMapper
.
updateById
(
equipmentsJxiopDocMysql
);
PointImportDto
pointImportDto
=
(
PointImportDto
)
o
;
equipmentsRepository
.
save
(
esEquipments
);
List
<
EquipmentsJxiopDocMysql
>
equipmentsJxiopDocMysqlList
=
equipmentsJxiopDocMysqlMapper
.
selectList
(
});
new
QueryWrapper
<
EquipmentsJxiopDocMysql
>().
eq
(
"gateway_id"
,
pointImportDto
.
getGatewayId
())
}
.
eq
(
"equipment_index_name"
,
pointImportDto
.
getEquipmentIndexName
()));
});
if
(!
ObjectUtils
.
isEmpty
(
equipmentsJxiopDocMysqlList
))
{
}
catch
(
Exception
e
)
{
equipmentsJxiopDocMysqlList
.
forEach
(
equipmentsJxiopDocMysql
->
{
ESEquipments
esEquipments
=
equipmentsRepository
.
findById
(
equipmentsJxiopDocMysql
.
getId
())
}
.
get
();
// 更新模块
}
if
(!
equipmentsJxiopDocMysql
.
getFrontModule
().
contains
(
pointImportDto
.
getFrontModule
()))
{
equipmentsJxiopDocMysql
.
setFrontModule
(
@TycloudOperation
(
needAuth
=
false
,
ApiLevel
=
UserType
.
AGENCY
)
equipmentsJxiopDocMysql
.
getFrontModule
()
+
","
+
pointImportDto
.
getFrontModule
());
@ApiOperation
(
value
=
"测试消息发送"
)
esEquipments
.
setFrontModule
(
@GetMapping
(
"/test5"
)
equipmentsJxiopDocMysql
.
getFrontModule
()
+
","
+
pointImportDto
.
getFrontModule
());
public
void
demoTest4
()
{
}
HashMap
<
String
,
String
>
hashMap
=
new
HashMap
<>();
// 更新类型
hashMap
.
put
(
"test"
,
String
.
valueOf
(
Math
.
random
()
*
1000
));
if
(!
equipmentsJxiopDocMysql
.
getSystemType
().
contains
(
pointImportDto
.
getSystemType
()))
{
hashMap
.
put
(
"test1"
,
String
.
valueOf
(
Math
.
random
()
*
100
));
equipmentsJxiopDocMysql
.
setSystemType
(
try
{
equipmentsJxiopDocMysql
.
getSystemType
()
+
","
+
pointImportDto
.
getSystemType
());
emqKeeper
.
getMqttClient
().
publish
(
"test_topic"
,
JSON
.
toJSON
(
hashMap
).
toString
().
getBytes
(
"UTF-8"
),
1
,
true
);
esEquipments
.
setSystemType
(
emqKeeper
.
getMqttClient
().
publish
(
"test_topic1"
,
JSON
.
toJSON
(
hashMap
).
toString
().
getBytes
(
"UTF-8"
),
1
,
true
);
equipmentsJxiopDocMysql
.
getSystemType
()
+
","
+
pointImportDto
.
getSystemType
());
logger
.
info
(
"++++++++++++++++++++++++++++++++++发送消息成功++++++++++++++++++++++++++++++++++++++"
);
}
}
catch
(
Exception
exception
)
{
// 更新排序号
logger
.
error
(
"============================================================发送消息报错"
);
equipmentsJxiopDocMysql
.
setTraceId
(
pointImportDto
.
getTraceId
());
}
esEquipments
.
setTraceId
(
pointImportDto
.
getTraceId
());
}
// 更新显示名称
equipmentsJxiopDocMysql
.
setDisplayName
(
pointImportDto
.
getDisplayName
());
@TycloudOperation
(
needAuth
=
false
,
ApiLevel
=
UserType
.
AGENCY
)
esEquipments
.
setDisplayName
(
pointImportDto
.
getDisplayName
());
@ApiOperation
(
value
=
"初始化升压站"
)
// 更新单位 如果单位为空或者单位超过周期性数据存储长度则丢弃单位更新操作
@GetMapping
(
"/test6"
)
if
(!
ObjectUtils
.
isEmpty
(
pointImportDto
.
getUnit
())
public
ResponseModel
<
Integer
>
demoTest5
()
{
&&
(
pointImportDto
.
getUnit
().
toCharArray
().
length
<
24
))
{
//数据说明 夏造风电、泰和光伏、夏造升压站、泰和升压站
equipmentsJxiopDocMysql
.
setUnit
(
pointImportDto
.
getUnit
());
String
[]
strings
=
{
"1668801570352926721"
,
"1669525017559306241"
};
esEquipments
.
setUnit
(
pointImportDto
.
getUnit
());
}
equipmentsJxiopDocMysqlMapper
.
updateById
(
equipmentsJxiopDocMysql
);
equipmentsRepository
.
save
(
esEquipments
);
});
}
});
}
catch
(
Exception
e
)
{
}
}
@TycloudOperation
(
needAuth
=
false
,
ApiLevel
=
UserType
.
AGENCY
)
@ApiOperation
(
value
=
"测试消息发送"
)
@GetMapping
(
"/test5"
)
public
void
demoTest4
()
{
HashMap
<
String
,
String
>
hashMap
=
new
HashMap
<>();
hashMap
.
put
(
"test"
,
String
.
valueOf
(
Math
.
random
()
*
1000
));
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
);
logger
.
info
(
"++++++++++++++++++++++++++++++++++发送消息成功++++++++++++++++++++++++++++++++++++++"
);
}
catch
(
Exception
exception
)
{
logger
.
error
(
"============================================================发送消息报错"
);
}
}
@TycloudOperation
(
needAuth
=
false
,
ApiLevel
=
UserType
.
AGENCY
)
@ApiOperation
(
value
=
"初始化升压站"
)
@GetMapping
(
"/test6"
)
public
ResponseModel
<
Integer
>
demoTest5
()
{
// 数据说明 夏造风电、泰和光伏、夏造升压站、泰和升压站
String
[]
strings
=
{
"1668801570352926721"
,
"1669525017559306241"
};
// String [] strings = {"1669525017559306241"};
// String [] strings = {"1669525017559306241"};
// Object o=this.monitorFanIndicatorImpl.getIndicatoralueAvage("1668801435891929089","60秒平均风速");
// Object o=this.monitorFanIndicatorImpl.getIndicatoralueAvage("1668801435891929089","60秒平均风速");
// System.out.println(o.toString());
// System.out.println(o.toString());
int
num
=
0
;
int
num
=
0
;
for
(
int
i
=
0
;
i
<
strings
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
strings
.
length
;
i
++)
{
QueryWrapper
<
EquipmentsJxiopDocMysql
>
QueryWrapper
=
new
QueryWrapper
<>();
QueryWrapper
<
EquipmentsJxiopDocMysql
>
QueryWrapper
=
new
QueryWrapper
<>();
// 夏造风电
// 夏造风电
// QueryWrapper.eq("gateway", "1668801435891929089");
// QueryWrapper.eq("gateway", "1668801435891929089");
// 泰和光伏
// 泰和光伏
QueryWrapper
.
eq
(
"gateway"
,
strings
[
i
]);
QueryWrapper
.
eq
(
"gateway"
,
strings
[
i
]);
long
DATE
=
new
Date
().
getTime
();
long
DATE
=
new
Date
().
getTime
();
System
.
out
.
println
(
DATE
);
System
.
out
.
println
(
DATE
);
List
<
EquipmentsJxiopDocMysql
>
list
=
equipmentsJxiopDocMysqlMapper
.
selectList
(
QueryWrapper
);
List
<
EquipmentsJxiopDocMysql
>
list
=
equipmentsJxiopDocMysqlMapper
.
selectList
(
QueryWrapper
);
num
=
num
+
list
.
size
();
num
=
num
+
list
.
size
();
List
<
ESEquipments
>
listit
=
new
ArrayList
<>();
List
<
ESEquipments
>
listit
=
new
ArrayList
<>();
for
(
EquipmentsJxiopDocMysql
monitorFanIndicator
:
list
)
{
for
(
EquipmentsJxiopDocMysql
monitorFanIndicator
:
list
)
{
ESEquipments
eSEquipments
=
new
ESEquipments
(
monitorFanIndicator
.
getValueF
(),
ESEquipments
eSEquipments
=
new
ESEquipments
(
monitorFanIndicator
.
getId
(),
monitorFanIndicator
.
getAddress
(),
monitorFanIndicator
.
getValueF
(),
monitorFanIndicator
.
getDataType
(),
monitorFanIndicator
.
getEquipmentSpecificName
(),
monitorFanIndicator
.
getId
(),
monitorFanIndicator
.
getGatewayId
(),
monitorFanIndicator
.
getIsAlarm
(),
monitorFanIndicator
.
getAddress
(),
monitorFanIndicator
.
getCreatedTime
(),
monitorFanIndicator
.
getUnit
(),
monitorFanIndicator
.
getDataType
(),
monitorFanIndicator
.
getValue
(),
monitorFanIndicator
.
getValueLabel
(),
monitorFanIndicator
.
getEquipmentSpecificName
(),
monitorFanIndicator
.
getTraceId
(),
monitorFanIndicator
.
getEquipmentIndexName
(),
monitorFanIndicator
.
getGatewayId
(),
monitorFanIndicator
.
getEquipmentNumber
(),
monitorFanIndicator
.
getFrontModule
(),
monitorFanIndicator
.
getIsAlarm
(),
monitorFanIndicator
.
getSystemType
(),
monitorFanIndicator
.
getPictureName
(),
monitorFanIndicator
.
getCreatedTime
(),
monitorFanIndicator
.
getDisplayName
());
monitorFanIndicator
.
getUnit
(),
monitorFanIndicator
.
getValue
(),
listit
.
add
(
eSEquipments
);
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, String> tag = new HashMap<>();
// Map<String, Object> maps2 = new HashMap<>();
// Map<String, Object> maps2 = new HashMap<>();
...
@@ -377,124 +392,112 @@ public class DemoController extends BaseController {
...
@@ -377,124 +392,112 @@ public class DemoController extends BaseController {
// //升压站的字段显示名称
// //升压站的字段显示名称
// maps2.put("displayName", monitorFanIndicator.getEquipmentNumber());
// maps2.put("displayName", monitorFanIndicator.getEquipmentNumber());
// influxDbConnection.insert("indicators_" + monitorFanIndicator.getGateway(), tag, maps2, 1688558007051L, TimeUnit.MILLISECONDS);
// influxDbConnection.insert("indicators_" + monitorFanIndicator.getGateway(), tag, maps2, 1688558007051L, TimeUnit.MILLISECONDS);
}
}
equipmentsRepository
.
saveAll
(
listit
);
equipmentsRepository
.
saveAll
(
listit
);
}
}
return
ResponseHelper
.
buildResponse
(
num
);
return
ResponseHelper
.
buildResponse
(
num
);
}
}
@TycloudOperation
(
needAuth
=
false
,
ApiLevel
=
UserType
.
AGENCY
)
@TycloudOperation
(
needAuth
=
false
,
ApiLevel
=
UserType
.
AGENCY
)
@ApiOperation
(
value
=
"测试动态图片"
)
@ApiOperation
(
value
=
"测试动态图片"
)
@GetMapping
(
"/test7"
)
@GetMapping
(
"/test7"
)
public
ResponseModel
<
HashMap
<
String
,
String
>>
demoTest6
()
{
public
ResponseModel
<
HashMap
<
String
,
String
>>
demoTest6
()
{
HashMap
<
String
,
String
>
hashMap
=
new
HashMap
<>();
HashMap
<
String
,
String
>
hashMap
=
new
HashMap
<>();
hashMap
.
put
(
"url"
,
"upload/jxiop/amos_studio/758F6F4BC695B777899485DB0C7E5D3.gif"
);
hashMap
.
put
(
"url"
,
"upload/jxiop/amos_studio/758F6F4BC695B777899485DB0C7E5D3.gif"
);
return
ResponseHelper
.
buildResponse
(
hashMap
);
return
ResponseHelper
.
buildResponse
(
hashMap
);
}
}
@TycloudOperation
(
needAuth
=
false
,
ApiLevel
=
UserType
.
AGENCY
)
@TycloudOperation
(
needAuth
=
false
,
ApiLevel
=
UserType
.
AGENCY
)
@ApiOperation
(
value
=
"测试求和"
)
@ApiOperation
(
value
=
"测试求和"
)
@GetMapping
(
"/test8"
)
@GetMapping
(
"/test8"
)
public
ResponseModel
<
Object
>
demoTest8
()
{
public
ResponseModel
<
Object
>
demoTest8
()
{
QueryBuilder
queryBuilder
=
QueryBuilders
.
matchQuery
(
"equipmentIndexName"
,
"有功功率"
);
QueryBuilder
queryBuilder
=
QueryBuilders
.
matchQuery
(
"equipmentIndexName"
,
"有功功率"
);
SumAggregationBuilder
buyCountSum
=
AggregationBuilders
.
sum
(
"buyCountSum"
).
field
(
"valueF"
);
SumAggregationBuilder
buyCountSum
=
AggregationBuilders
.
sum
(
"buyCountSum"
).
field
(
"valueF"
);
Query
query
=
new
NativeSearchQueryBuilder
()
Query
query
=
new
NativeSearchQueryBuilder
().
withQuery
(
queryBuilder
).
addAggregation
(
buyCountSum
)
.
withQuery
(
queryBuilder
)
.
withPageable
(
PageRequest
.
of
(
0
,
1
)).
build
();
.
addAggregation
(
buyCountSum
)
query
.
setTrackTotalHits
(
true
);
// 允许返回查询结果的total - search.getTotalHits()
.
withPageable
(
PageRequest
.
of
(
0
,
1
))
SearchHits
<
ESEquipments
>
search
=
elasticsearchTemplate
.
search
(
query
,
ESEquipments
.
class
);
.
build
();
return
ResponseHelper
.
buildResponse
(
search
);
query
.
setTrackTotalHits
(
true
);
// 允许返回查询结果的total - search.getTotalHits()
SearchHits
<
ESEquipments
>
search
=
elasticsearchTemplate
.
search
(
query
,
ESEquipments
.
class
);
}
return
ResponseHelper
.
buildResponse
(
search
);
@TycloudOperation
(
needAuth
=
false
,
ApiLevel
=
UserType
.
AGENCY
)
}
@ApiOperation
(
value
=
"测试平均数"
)
@GetMapping
(
"/test9"
)
@TycloudOperation
(
needAuth
=
false
,
ApiLevel
=
UserType
.
AGENCY
)
public
ResponseModel
<
Object
>
demoTest9
()
{
@ApiOperation
(
value
=
"测试平均数"
)
QueryBuilder
queryBuilder
=
QueryBuilders
.
matchQuery
(
"equipmentIndexName"
,
"有功功率"
);
@GetMapping
(
"/test9"
)
public
ResponseModel
<
Object
>
demoTest9
()
{
AvgAggregationBuilder
buyCountAvg
=
AggregationBuilders
.
avg
(
"buyCountAvg"
).
field
(
"valueF"
);
QueryBuilder
queryBuilder
=
QueryBuilders
.
matchQuery
(
"equipmentIndexName"
,
"有功功率"
);
Query
query
=
new
NativeSearchQueryBuilder
().
withQuery
(
queryBuilder
).
addAggregation
(
buyCountAvg
)
.
withPageable
(
PageRequest
.
of
(
0
,
1
)).
build
();
AvgAggregationBuilder
buyCountAvg
=
AggregationBuilders
.
avg
(
"buyCountAvg"
).
field
(
"valueF"
);
Query
query
=
new
NativeSearchQueryBuilder
()
query
.
setTrackTotalHits
(
true
);
.
withQuery
(
queryBuilder
)
SearchHits
<
ESEquipments
>
search
=
elasticsearchTemplate
.
search
(
query
,
ESEquipments
.
class
);
.
addAggregation
(
buyCountAvg
)
.
withPageable
(
PageRequest
.
of
(
0
,
1
))
return
ResponseHelper
.
buildResponse
(
search
);
.
build
();
}
query
.
setTrackTotalHits
(
true
);
@TycloudOperation
(
needAuth
=
false
,
ApiLevel
=
UserType
.
AGENCY
)
SearchHits
<
ESEquipments
>
search
=
elasticsearchTemplate
.
search
(
query
,
ESEquipments
.
class
);
@ApiOperation
(
value
=
"分组求和数"
)
@GetMapping
(
"/test10"
)
return
ResponseHelper
.
buildResponse
(
search
);
public
SearchHits
demoTest10
()
{
}
QueryBuilder
queryBuilder
=
QueryBuilders
.
matchQuery
(
"equipmentIndexName"
,
"年发电量"
);
// 如果只对一个字段进行分组写一个就好
@TycloudOperation
(
needAuth
=
false
,
ApiLevel
=
UserType
.
AGENCY
)
TermsAggregationBuilder
tb1
=
AggregationBuilders
.
terms
(
"group_gatewayId"
).
field
(
"gatewayId.keyword"
);
// gatewayId
@ApiOperation
(
value
=
"分组求和数"
)
// 是分组字段名,group_gatewayId是查询结果的别名
@GetMapping
(
"/test10"
)
public
SearchHits
demoTest10
()
{
QueryBuilder
queryBuilder
=
QueryBuilders
.
matchQuery
(
"equipmentIndexName"
,
"年发电量"
);
// 如果只对一个字段进行分组写一个就好
TermsAggregationBuilder
tb1
=
AggregationBuilders
.
terms
(
"group_gatewayId"
).
field
(
"gatewayId.keyword"
);
//gatewayId 是分组字段名,group_gatewayId是查询结果的别名
// TermsAggregationBuilder tb2 = AggregationBuilders.terms("group_equipmentNumber").field("equipmentNumber.keyword");//equipmentNumber 是分组字段名,group_equipmentNumber是查询结果的别名
// 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字段分组统计总数
tb1
.
subAggregation
(
sb
);
// 通过typeId字段分组统计总数
// tb2.subAggregation(sb); // 通过houseId字段分组统计总数
// tb2.subAggregation(sb); // 通过houseId字段分组统计总数
// tb1.subAggregation(tb2); // 合并
// tb1.subAggregation(tb2); // 合并
Query
query
=
new
NativeSearchQueryBuilder
().
withQuery
(
queryBuilder
).
addAggregation
(
tb1
)
Query
query
=
new
NativeSearchQueryBuilder
()
.
withPageable
(
PageRequest
.
of
(
0
,
1
)).
build
();
.
withQuery
(
queryBuilder
)
.
addAggregation
(
tb1
)
query
.
setTrackTotalHits
(
true
);
.
withPageable
(
PageRequest
.
of
(
0
,
1
))
SearchHits
search
=
elasticsearchTemplate
.
search
(
query
,
ESEquipments
.
class
);
.
build
();
return
search
;
query
.
setTrackTotalHits
(
true
);
}
SearchHits
search
=
elasticsearchTemplate
.
search
(
query
,
ESEquipments
.
class
);
@TycloudOperation
(
needAuth
=
false
,
ApiLevel
=
UserType
.
AGENCY
)
return
search
;
@ApiOperation
(
value
=
"分组求和数"
)
}
@GetMapping
(
"/test11"
)
public
Map
demoTest11
()
{
@TycloudOperation
(
needAuth
=
false
,
ApiLevel
=
UserType
.
AGENCY
)
@ApiOperation
(
value
=
"分组求和数"
)
List
<
QueryDto
>
queryDto
=
new
ArrayList
<>();
@GetMapping
(
"/test11"
)
QueryDto
ff1
=
new
QueryDto
(
"gatewayId.keyword"
,
"1668801435891929089"
);
public
Map
demoTest11
()
{
QueryDto
ff2
=
new
QueryDto
(
"equipmentIndexName.keyword"
,
"有功功率"
);
queryDto
.
add
(
ff1
);
List
<
QueryDto
>
queryDto
=
new
ArrayList
<>();
queryDto
.
add
(
ff2
);
QueryDto
ff1
=
new
QueryDto
(
"gatewayId.keyword"
,
"1668801435891929089"
);
Double
avg
=
commonServiceImpl
.
getavg
(
queryDto
,
"valueF"
,
ESEquipments
.
class
);
QueryDto
ff2
=
new
QueryDto
(
"equipmentIndexName.keyword"
,
"有功功率"
);
Double
sum
=
commonServiceImpl
.
getsum
(
queryDto
,
"valueF"
,
ESEquipments
.
class
);
queryDto
.
add
(
ff1
);
queryDto
.
add
(
ff2
);
Map
<
String
,
Double
>
map
=
new
HashMap
();
Double
avg
=
commonServiceImpl
.
getavg
(
queryDto
,
"valueF"
,
ESEquipments
.
class
);
map
.
put
(
"1668801435891929089_avg"
,
avg
);
Double
sum
=
commonServiceImpl
.
getsum
(
queryDto
,
"valueF"
,
ESEquipments
.
class
);
map
.
put
(
"1668801435891929089_sum"
,
sum
);
return
map
;
Map
<
String
,
Double
>
map
=
new
HashMap
();
}
map
.
put
(
"1668801435891929089_avg"
,
avg
);
map
.
put
(
"1668801435891929089_sum"
,
sum
);
@TycloudOperation
(
needAuth
=
false
,
ApiLevel
=
UserType
.
AGENCY
)
return
map
;
@ApiOperation
(
value
=
"取缓存数据"
)
}
@GetMapping
(
"/test12"
)
public
List
<
StationCacheInfoDto
>
demoTest12
()
{
@TycloudOperation
(
needAuth
=
false
,
ApiLevel
=
UserType
.
AGENCY
)
return
commonServiceImpl
.
getListStationCacheInfoDto
();
@ApiOperation
(
value
=
"取缓存数据"
)
}
@GetMapping
(
"/test12"
)
public
List
<
StationCacheInfoDto
>
demoTest12
()
{
@TycloudOperation
(
needAuth
=
false
,
ApiLevel
=
UserType
.
AGENCY
)
return
commonServiceImpl
.
getListStationCacheInfoDto
();
@ApiOperation
(
value
=
"es获取数据"
)
}
@GetMapping
(
"/test19"
)
public
void
test19
()
{
@TycloudOperation
(
needAuth
=
false
,
ApiLevel
=
UserType
.
AGENCY
)
Map
<
String
,
List
<
String
>>
queryConditon
=
new
HashMap
<>();
@ApiOperation
(
value
=
"es获取数据"
)
queryConditon
.
put
(
"equipmentIndexName.keyword"
,
Arrays
.
asList
(
"日发电量"
,
"月发电量"
,
"年发电量"
));
@GetMapping
(
"/test19"
)
commonServiceImpl
.
getListDataByCondtions
(
queryConditon
,
null
,
ESEquipments
.
class
);
public
void
test19
()
{
}
Map
<
String
,
List
<
String
>>
queryConditon
=
new
HashMap
<>();
queryConditon
.
put
(
"equipmentIndexName.keyword"
,
Arrays
.
asList
(
"日发电量"
,
"月发电量"
,
"年发电量"
));
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
...
@@ -64,10 +64,16 @@ public class EquipAlarmEventServiceImpl
}
else
if
(
"false"
.
equals
(
i
.
getValue
()))
{
}
else
if
(
"false"
.
equals
(
i
.
getValue
()))
{
i
.
setValue
(
"分"
);
i
.
setValue
(
"分"
);
}
}
long
mills
=
i
.
getCreatedTime
()
/
1000000
;
long
mills
=
i
.
getCreatedTime
()
;
car
.
setTimeInMillis
(
mills
);
car
.
setTimeInMillis
(
mills
);
// System.out.println(sdf.format(car.getTime()));
// 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);
// car.add(Calendar.HOUR, 12);
// System.out.println(sdf.format(car.getTime()));
// 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
...
@@ -14,17 +14,17 @@ spring.db2.datasource.driver-class-name: com.mysql.cj.jdbc.Driver
## db3-td-engine
## db3-td-engine
#spring.db3.datasource.type: com.alibaba.druid.pool.DruidDataSource
#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.username
=
root
spring.db3.datasource.password
=
taosdata
spring.db3.datasource.password
=
taosdata
spring.db3.datasource.driver-class-name
:
com.taosdata.jdbc.rs.RestfulDriver
spring.db3.datasource.driver-class-name
:
com.taosdata.jdbc.rs.RestfulDriver
## eureka properties:
## 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/
eureka.client.serviceUrl.defaultZone
=
http://admin:a1234560@${eureka.instance.hostname}:10001/eureka/
## redis properties:
## redis properties:
spring.redis.database
=
1
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.port
=
6379
spring.redis.password
=
yeejoin@2020
spring.redis.password
=
yeejoin@2020
...
@@ -60,10 +60,10 @@ lettuce.timeout=10000
...
@@ -60,10 +60,10 @@ lettuce.timeout=10000
emqx.clean-session
=
true
emqx.clean-session
=
true
emqx.client-id
=
${spring.application.name}-${random.int[1024,65536]}
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.user-name
=
admin
emqx.password
=
public
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.client.product.id
=
mqtt
mqtt.topic
=
topic_mqtt
mqtt.topic
=
topic_mqtt
spring.mqtt.completionTimeout
=
3000
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