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
9803ced7
Commit
9803ced7
authored
Sep 20, 2024
by
张森
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
30546 运行趋势页签接口开发
parent
8cbb0c18
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
318 additions
and
29 deletions
+318
-29
EquipTrendResultVo.java
...join/equipmanage/common/entity/vo/EquipTrendResultVo.java
+3
-3
SupervisionConfigureController.java
...quipmanage/controller/SupervisionConfigureController.java
+21
-0
EquipmentSpecificMapper.java
...m/yeejoin/equipmanage/mapper/EquipmentSpecificMapper.java
+35
-22
IEquipmentSpecificSerivce.java
...eejoin/equipmanage/service/IEquipmentSpecificSerivce.java
+2
-0
EquipmentSpecificSerivceImpl.java
...quipmanage/service/impl/EquipmentSpecificSerivceImpl.java
+212
-4
EquipmentSpecificMapper.xml
...uip/src/main/resources/mapper/EquipmentSpecificMapper.xml
+45
-0
No files found.
amos-boot-module/amos-boot-module-api/amos-boot-module-equip-api/src/main/java/com/yeejoin/equipmanage/common/entity/vo/EquipTrendResultVo.java
View file @
9803ced7
...
...
@@ -8,7 +8,7 @@ public class EquipTrendResultVo {
private
List
<
String
>
legends
;
private
String
yAxisName
;
private
List
<
String
>
xAxisData
;
private
List
<
List
<
String
>>
yAxisData
;
private
List
<
List
<
Object
>>
yAxisData
;
private
List
<
List
<
String
>>
threshold
;
public
List
<
String
>
getLegends
()
{
...
...
@@ -35,11 +35,11 @@ public class EquipTrendResultVo {
this
.
xAxisData
=
xAxisData
;
}
public
List
<
List
<
String
>>
getyAxisData
()
{
public
List
<
List
<
Object
>>
getyAxisData
()
{
return
yAxisData
;
}
public
void
setyAxisData
(
List
<
List
<
String
>>
yAxisData
)
{
public
void
setyAxisData
(
List
<
List
<
Object
>>
yAxisData
)
{
this
.
yAxisData
=
yAxisData
;
}
...
...
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/controller/SupervisionConfigureController.java
View file @
9803ced7
...
...
@@ -873,4 +873,25 @@ public class SupervisionConfigureController extends AbstractBaseController {
EquipTrendResultVo
equipTrendResultVo
=
equipmentSpecificService
.
operatingTrendPressurePump
(
startTime
,
endTime
,
bizOrgCode
,
equipCode
,
indexKey
);
return
CommonResponseUtil
.
success
(
equipTrendResultVo
);
}
@PersonIdentify
@RequestMapping
(
value
=
"/operatingTrendWater"
,
method
=
RequestMethod
.
GET
)
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"设备平台运行趋势 水池液位趋势API"
,
produces
=
"application/json;charset=UTF-8"
,
notes
=
"设备平台运行趋势 水池液位趋势API"
)
public
ResponseModel
operatingTrendWater
(
@RequestParam
(
value
=
"startTime"
,
required
=
false
)
String
startTime
,
@RequestParam
(
value
=
"endTime"
,
required
=
false
)
String
endTime
,
@RequestParam
(
value
=
"bizOrgCode"
,
required
=
false
)
String
bizOrgCode
)
throws
ParseException
{
if
(
ObjectUtils
.
isEmpty
(
bizOrgCode
))
{
ReginParams
reginParams
=
getSelectedOrgInfo
();
ReginParams
.
PersonIdentity
personIdentity
=
reginParams
.
getPersonIdentity
();
if
(!
ValidationUtil
.
isEmpty
(
personIdentity
))
{
bizOrgCode
=
personIdentity
.
getBizOrgCode
();
if
(
bizOrgCode
==
null
)
{
return
CommonResponseUtil
.
success
(
null
);
}
}
}
EquipTrendResultVo
equipTrendResultVo
=
equipmentSpecificService
.
operatingTrendWater
(
startTime
,
endTime
,
bizOrgCode
);
return
CommonResponseUtil
.
success
(
equipTrendResultVo
);
}
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/mapper/EquipmentSpecificMapper.java
View file @
9803ced7
...
...
@@ -75,18 +75,20 @@ public interface EquipmentSpecificMapper extends BaseMapper<EquipmentSpecific> {
/**
* 根据画布id获取画布绑定设备最新指标状态
*
* @param sceneId
* @return
*/
List
<
EquipmentSpecificIndex
>
getEquipLatestStatusBySceneId
(
String
sceneId
);
List
<
Map
<
String
,
Object
>>
getStatusAll
(
@Param
(
"sceneId"
)
String
sceneId
);
List
<
Map
<
String
,
Object
>>
getStatusAll
(
@Param
(
"sceneId"
)
String
sceneId
);
List
<
String
>
getEquipmentIotCodeLists
();
List
<
HashMap
<
String
,
Object
>>
getEquipBySourceId
(
@Param
(
"sourceIds"
)
List
<
Long
>
sourceIds
,
@Param
(
"categoryId"
)
List
<
Long
>
categoryId
,
@Param
(
"equipCode"
)
String
equipCode
,
@Param
(
"equipName"
)
String
equipName
,
@Param
(
"companyId"
)
String
companyId
,
@Param
(
"current"
)
Long
current
,
@Param
(
"size"
)
Long
size
);
List
<
HashMap
<
String
,
Object
>>
getEquipBySourceId
(
@Param
(
"sourceIds"
)
List
<
Long
>
sourceIds
,
@Param
(
"categoryId"
)
List
<
Long
>
categoryId
,
@Param
(
"equipCode"
)
String
equipCode
,
@Param
(
"equipName"
)
String
equipName
,
@Param
(
"companyId"
)
String
companyId
,
@Param
(
"current"
)
Long
current
,
@Param
(
"size"
)
Long
size
);
int
getEquipBySourceIdCount
(
@Param
(
"sourceIds"
)
List
<
Long
>
sourceIds
,
@Param
(
"categoryId"
)
List
<
Long
>
categoryId
,
@Param
(
"equipCode"
)
String
equipCode
,
@Param
(
"equipName"
)
String
equipName
,
@Param
(
"companyId"
)
String
companyId
);
int
getEquipBySourceIdCount
(
@Param
(
"sourceIds"
)
List
<
Long
>
sourceIds
,
@Param
(
"categoryId"
)
List
<
Long
>
categoryId
,
@Param
(
"equipCode"
)
String
equipCode
,
@Param
(
"equipName"
)
String
equipName
,
@Param
(
"companyId"
)
String
companyId
);
List
getMenuChildren
(
@Param
(
"id"
)
Long
id
);
...
...
@@ -167,18 +169,19 @@ public interface EquipmentSpecificMapper extends BaseMapper<EquipmentSpecific> {
List
<
MaintenanceResourceData
>
getSysEquipClassifyDataList
();
IPage
<
MaintenanceResourceDataVo
>
getSysEquipClassifyDataPage
(
Page
page
,
Long
fireFightSysId
,
String
fireFacilityName
,
String
classifyId
,
Long
fireFacilityId
,
List
<
Long
>
buildingId
,
List
<
String
>
bandWbCompany
);
IPage
<
MaintenanceResourceDataVo
>
getSysEquipClassifyDataPage
(
Page
page
,
Long
fireFightSysId
,
String
fireFacilityName
,
String
classifyId
,
Long
fireFacilityId
,
List
<
Long
>
buildingId
,
List
<
String
>
bandWbCompany
);
IPage
<
MaintenanceResourceDataVo
>
getEquipClassifyDataPage
(
Page
page
,
Long
fireFightSysId
,
String
fireFacilityName
,
String
classifyId
,
Long
fireFacilityId
,
List
<
Long
>
buildingId
,
List
<
String
>
bandWbCompany
);
IPage
<
MaintenanceResourceDataVo
>
getEquipClassifyDataPage
(
Page
page
,
Long
fireFightSysId
,
String
fireFacilityName
,
String
classifyId
,
Long
fireFacilityId
,
List
<
Long
>
buildingId
,
List
<
String
>
bandWbCompany
);
List
<
UserDto
>
getEquipSpecificLocationInfo
(
Long
equipmentSpecificId
,
String
[]
fieldName
);
Map
<
String
,
Double
>
getEquipLocationInfo
(
Long
equipmentSpecificId
);
Map
<
String
,
Double
>
getEquipLocationInfo
(
Long
equipmentSpecificId
);
Map
<
String
,
Object
>
getEquipSpeInfo
(
@Param
(
"equipmentSpecificId"
)
Long
equipmentSpecificId
);
/**
* 根据specificId删除装备相关数据
*
* @param specificId specificId
*/
// void deleteEquipDataBySpecificId(@Param("specificId") Long specificId, @Param("equipDetailId") Long equipDetailId);
...
...
@@ -202,31 +205,36 @@ public interface EquipmentSpecificMapper extends BaseMapper<EquipmentSpecific> {
/**
* 根据库存id删除装备相关库存数据
*
* @param stockDetailId 库存明细id
* @param specificId specificId
* @param specificId
specificId
*/
void
deleteEquipDataByStockDetailId
(
@Param
(
"stockDetailId"
)
Long
stockDetailId
,
@Param
(
"specificId"
)
Long
specificId
);
/**
* 获取雨淋阀室指标详情
*
* @return 指标详情
*/
List
<
Map
<
String
,
String
>>
getRainRoomIndexDetails
();
/**
* 消防管网指标详情
*
* @return 指标详情
*/
List
<
Map
<
String
,
String
>>
getTropicsIndexDetails
();
/**
* 选择阀室指标详情
*
* @return 指标详情
*/
List
<
Map
<
String
,
String
>>
getChoiceRoomIndexDetails
();
/**
* 消防炮伴热带指标详情
*
* @return 指标详情
*/
List
<
Map
<
String
,
String
>>
getBoxTropicsIndexDetails
();
...
...
@@ -234,6 +242,7 @@ public interface EquipmentSpecificMapper extends BaseMapper<EquipmentSpecific> {
/**
* 统计数据
*
* @return
*/
List
<
Map
<
String
,
Object
>>
queryCompanyStaData
();
...
...
@@ -241,21 +250,21 @@ public interface EquipmentSpecificMapper extends BaseMapper<EquipmentSpecific> {
Equipment
getEquipmentBySpecificId
(
@Param
(
"specificId"
)
Long
specificId
);
/**
*
* @param floorId 建筑id
* @param isIot 是否物联设备
* @param isIot
是否物联设备
* @return
*/
List
<
EquiplistSpecificBySystemVO
>
getListByWarehouseStructureId
(
Long
floorId
,
Integer
isIot
);
List
<
Map
<
String
,
String
>>
getStationInfo
();
List
<
Map
<
String
,
String
>>
getStationInfo
();
List
<
Map
<
String
,
Object
>>
getFireMonitorInfo
(
@Param
(
"equipmentId"
)
Long
fireEquipmentId
,
@Param
(
"list"
)
String
[]
strings
);
List
<
Map
<
String
,
Object
>>
getFirePumpInfo
(
@Param
(
"list"
)
String
[]
strings
,
@Param
(
"bizOrgCode"
)
String
bizOrgCode
);
List
<
Map
<
String
,
Object
>>
getFirePumpInfoEQ
(
@Param
(
"list"
)
String
[]
strings
,
@Param
(
"bizOrgCode"
)
String
bizOrgCode
);
List
<
Map
<
String
,
Object
>>
getFirePumpInfo
(
@Param
(
"list"
)
String
[]
strings
,
@Param
(
"bizOrgCode"
)
String
bizOrgCode
);
List
<
Map
<
String
,
Object
>>
getFirePumpInfoEQ
(
@Param
(
"list"
)
String
[]
strings
,
@Param
(
"bizOrgCode"
)
String
bizOrgCode
);
List
<
Map
<
String
,
Object
>>
getListByEquipmentCode
(
@Param
(
"list"
)
String
[]
strings
,
@Param
(
"bizOrgCode"
)
String
bizOrgCode
);
...
...
@@ -264,7 +273,7 @@ public interface EquipmentSpecificMapper extends BaseMapper<EquipmentSpecific> {
List
<
Map
<
String
,
Object
>>
normalIndexInfoList
(
@Param
(
"startDate"
)
String
startDate
,
@Param
(
"endDate"
)
String
endDate
);
Page
<
Map
<
String
,
Object
>>
normalIndexInfoListByPage
(
@Param
(
"Page"
)
Page
<
Map
<
String
,
Object
>>
page
,
@Param
(
"startDate"
)
String
startDate
,
@Param
(
"endDate"
)
String
endDate
,
@Param
(
"systemCode"
)
String
systemCode
,
@Param
(
"name"
)
String
name
);
Page
<
Map
<
String
,
Object
>>
normalIndexInfoListByPage
(
@Param
(
"Page"
)
Page
<
Map
<
String
,
Object
>>
page
,
@Param
(
"startDate"
)
String
startDate
,
@Param
(
"endDate"
)
String
endDate
,
@Param
(
"systemCode"
)
String
systemCode
,
@Param
(
"name"
)
String
name
);
Map
<
String
,
Object
>
getFireAutoSysInfo
();
...
...
@@ -280,11 +289,11 @@ public interface EquipmentSpecificMapper extends BaseMapper<EquipmentSpecific> {
List
<
Map
>
getWater
(
@Param
(
"id"
)
Long
id
);
Map
<
String
,
Object
>
getStationCode
(
@Param
(
"id"
)
Long
id
);
Map
<
String
,
Object
>
getStationCode
(
@Param
(
"id"
)
Long
id
);
EquipmentSpecific
getEquipSpecificEntityByCode
(
@Param
(
"code"
)
String
code
);
Integer
updateEquipSpecificStatus
(
String
status
,
String
id
);
Integer
updateEquipSpecificStatus
(
String
status
,
String
id
);
String
getEquipStatusList
(
@Param
(
"id"
)
String
id
);
...
...
@@ -298,15 +307,15 @@ public interface EquipmentSpecificMapper extends BaseMapper<EquipmentSpecific> {
String
updateEquipSpecificStatusByCheckInput
(
String
id
);
Page
<
Map
<
String
,
Object
>>
selectListByPatrolCheck
(
Page
<
Map
<
String
,
Object
>>
page
,
String
id
);
Page
<
Map
<
String
,
Object
>>
selectListByPatrolCheck
(
Page
<
Map
<
String
,
Object
>>
page
,
String
id
);
List
<
String
>
selectIdsByPatrolCheck
(
String
id
);
List
<
Map
<
String
,
Object
>>
queryCheckInputItemsByCheckId
(
@Param
(
value
=
"checkId"
)
String
checkId
);
List
<
Map
<
String
,
Object
>>
queryCheckInputItemsByCheckId
(
@Param
(
value
=
"checkId"
)
String
checkId
);
Map
<
String
,
Object
>
getPointById
(
@Param
(
value
=
"pointId"
)
Long
id
);
Map
<
String
,
Object
>
getPointById
(
@Param
(
value
=
"pointId"
)
Long
id
);
Map
<
String
,
Object
>
getPatrolData
(
@Param
(
value
=
"checkId"
)
Long
checkId
);
Map
<
String
,
Object
>
getPatrolData
(
@Param
(
value
=
"checkId"
)
Long
checkId
);
List
<
Map
<
String
,
Object
>>
getListByIds
(
@Param
(
"list"
)
String
[]
list
,
@Param
(
"bizOrgCode"
)
String
bizOrgCode
);
...
...
@@ -318,9 +327,9 @@ public interface EquipmentSpecificMapper extends BaseMapper<EquipmentSpecific> {
@Param
(
"useSource"
)
String
useSource
);
List
<
Map
<
String
,
Object
>>
getMonitoringCount
(
String
bizOrgCode
);
List
<
Map
<
String
,
Object
>>
getMonitoringCount
(
String
bizOrgCode
);
String
getEquipIdByCheckInputId
(
@Param
(
value
=
"id"
)
String
id
);
String
getEquipIdByCheckInputId
(
@Param
(
value
=
"id"
)
String
id
);
Map
<
String
,
Object
>
getMonitoringEquip
(
String
id
);
...
...
@@ -328,7 +337,7 @@ public interface EquipmentSpecificMapper extends BaseMapper<EquipmentSpecific> {
void
updateEquipQrCode
(
List
<
String
>
ids
,
String
status
);
String
selectEquipRealtimeSignal
(
@Param
(
value
=
"id"
)
long
id
);
String
selectEquipRealtimeSignal
(
@Param
(
value
=
"id"
)
long
id
);
List
<
Map
<
String
,
Object
>>
getPatrolInfo
(
String
bizOrgCode
);
...
...
@@ -347,4 +356,8 @@ public interface EquipmentSpecificMapper extends BaseMapper<EquipmentSpecific> {
Integer
selectEquipmentCountBySystemId
(
@Param
(
"systemId"
)
Long
systemId
);
List
<
EquipTrendInfoVo
>
getEquipListByCode
(
@Param
(
"code"
)
String
code
,
@Param
(
"indexKey"
)
String
indexKey
,
@Param
(
"bizOrgCode"
)
String
bizOrgCode
);
List
<
EquipTrendInfoVo
>
getWaterList
(
@Param
(
"bizOrgCode"
)
String
bizOrgCode
);
List
<
Map
<
String
,
String
>>
getIndexKeyByIotCode
(
@Param
(
"list"
)
Set
<
String
>
list
);
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/service/IEquipmentSpecificSerivce.java
View file @
9803ced7
...
...
@@ -334,4 +334,6 @@ public interface IEquipmentSpecificSerivce extends IService<EquipmentSpecific> {
EquipTrendResultVo
operatingTrendIot
(
String
startTime
,
String
endTime
,
String
bizOrgCode
,
String
equipCode
,
String
indexKey
);
EquipTrendResultVo
operatingTrendPressurePump
(
String
startTime
,
String
endTime
,
String
bizOrgCode
,
String
equipCode
,
String
indexKey
)
throws
ParseException
;
EquipTrendResultVo
operatingTrendWater
(
String
startTime
,
String
endTime
,
String
bizOrgCode
)
throws
ParseException
;
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/service/impl/EquipmentSpecificSerivceImpl.java
View file @
9803ced7
...
...
@@ -62,6 +62,7 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel;
import
java.io.IOException
;
import
java.math.BigDecimal
;
import
java.math.RoundingMode
;
import
java.nio.charset.StandardCharsets
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
...
...
@@ -2316,11 +2317,11 @@ public class EquipmentSpecificSerivceImpl extends ServiceImpl<EquipmentSpecificM
equipTrendResultVo
.
setLegends
(
legends
);
equipTrendResultVo
.
setThreshold
(
threshold
);
List
<
List
<
String
>>
yaxisList
=
new
ArrayList
<>();
List
<
List
<
Object
>>
yaxisList
=
new
ArrayList
<>();
for
(
EquipTrendInfoVo
info
:
equipList
)
{
//key:时间 value:数值
Map
<
String
,
String
>
dateValueDataMap
=
dateValueMapInfo
.
get
(
info
.
getId
());
List
<
String
>
values
=
new
ArrayList
<>();
List
<
Object
>
values
=
new
ArrayList
<>();
String
lastValue
=
"0"
;
List
<
String
>
allTimeListNew
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
allTimeList
.
size
();
i
++)
{
...
...
@@ -2359,7 +2360,7 @@ public class EquipmentSpecificSerivceImpl extends ServiceImpl<EquipmentSpecificM
List
<
String
>
legends
=
new
ArrayList
<>();
List
<
List
<
String
>>
threshold
=
new
ArrayList
<>();
List
<
List
<
String
>>
yaxisList
=
new
ArrayList
<>();
List
<
List
<
Object
>>
yaxisList
=
new
ArrayList
<>();
EquipTrendResultVo
equipTrendResultVo
=
new
EquipTrendResultVo
();
//横坐标数据
List
<
String
>
allTimeListNew
=
new
ArrayList
<>();
...
...
@@ -2403,7 +2404,7 @@ public class EquipmentSpecificSerivceImpl extends ServiceImpl<EquipmentSpecificM
}
}
List
<
String
>
values
=
new
ArrayList
<>();
List
<
Object
>
values
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
allTimeList
.
size
();
i
++)
{
values
.
add
(
stringIntegerHashMap
.
getOrDefault
(
allTimeList
.
get
(
i
),
0
).
toString
());
}
...
...
@@ -2417,6 +2418,119 @@ public class EquipmentSpecificSerivceImpl extends ServiceImpl<EquipmentSpecificM
return
equipTrendResultVo
;
}
@Override
public
EquipTrendResultVo
operatingTrendWater
(
String
startTime
,
String
endTime
,
String
bizOrgCode
)
throws
ParseException
{
//横坐标数据
List
<
String
>
allTimeList
=
getTimePoints
(
startTime
,
endTime
);
List
<
EquipTrendInfoVo
>
equipList
=
equipmentSpecificMapper
.
getWaterList
(
bizOrgCode
);
ResponseModel
entity
=
null
;
Set
<
String
>
strings
=
new
HashSet
<>();
equipList
.
forEach
(
item
->
{
String
[]
split
=
item
.
getIotCode
().
split
(
","
);
strings
.
addAll
(
Arrays
.
asList
(
split
));
});
List
<
Map
<
String
,
String
>>
indexKeyByIotCode
=
equipmentSpecificMapper
.
getIndexKeyByIotCode
(
strings
);
Map
<
String
,
String
>
iotCodeIndexKeyMap
=
indexKeyByIotCode
.
stream
().
collect
(
Collectors
.
toMap
(
t
->
t
.
get
(
"iotCode"
),
t
->
t
.
get
(
"indexKey"
)));
// iot服务查到的数据,存储为map key:iotCode value: iot查询的液位数据
HashMap
<
String
,
List
<
Map
<
String
,
String
>>>
iotDataInfoMap
=
new
HashMap
<>();
for
(
String
iotCode
:
strings
)
{
//iot数据查询组装
String
prefix
=
null
;
String
suffix
=
null
;
if
(
StringUtil
.
isNotEmpty
(
iotCode
)
&&
iotCode
.
length
()
>
8
)
{
prefix
=
iotCode
.
substring
(
0
,
8
);
suffix
=
iotCode
.
substring
(
8
);
}
else
{
throw
new
BadRequest
(
"装备物联编码不存在或编码错误,请确认!"
);
}
try
{
if
(
iotCodeIndexKeyMap
.
containsKey
(
iotCode
)
&&
StringUtil
.
isNotEmpty
(
iotCodeIndexKeyMap
.
get
(
iotCode
)))
{
entity
=
iotFeign
.
selectList
(
getAppKey
(),
getProduct
(),
getToken
(),
startTime
,
endTime
,
prefix
,
suffix
,
iotCodeIndexKeyMap
.
get
(
iotCode
));
if
(
200
==
entity
.
getStatus
()
&&
!
ObjectUtils
.
isEmpty
(
entity
.
getResult
()))
{
String
json
=
JSON
.
toJSONString
(
entity
.
getResult
());
List
<
Map
<
String
,
String
>>
listObject
=
(
List
<
Map
<
String
,
String
>>)
JSONArray
.
parse
(
json
);
if
(!
CollectionUtils
.
isEmpty
(
listObject
))
{
iotDataInfoMap
.
put
(
iotCode
,
listObject
);
}
}
}
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
"调用AMOS-API-IOT服务失败,请检查服务是否正常!"
);
}
}
//返回数据组装定义
List
<
String
>
legends
=
new
ArrayList
<>();
List
<
List
<
String
>>
threshold
=
new
ArrayList
<>();
List
<
List
<
Object
>>
yaxisList
=
new
ArrayList
<>();
EquipTrendResultVo
equipTrendResultVo
=
new
EquipTrendResultVo
();
for
(
EquipTrendInfoVo
equipInfo
:
equipList
)
{
//返回数据组装
List
<
String
>
maxMinInfo
=
new
ArrayList
<>();
maxMinInfo
.
add
(
equipInfo
.
getMinNum
());
maxMinInfo
.
add
(
equipInfo
.
getMaxNum
());
threshold
.
add
(
maxMinInfo
);
legends
.
add
(
equipInfo
.
getName
());
equipTrendResultVo
.
setyAxisName
(
equipInfo
.
getUnit
());
HashMap
<
String
,
List
<
BigDecimal
>>
stringIntegerHashMap
=
new
HashMap
<>();
String
[]
split
=
equipInfo
.
getIotCode
().
split
(
","
);
for
(
String
iotCode
:
split
)
{
String
indexKey
=
iotCodeIndexKeyMap
.
get
(
iotCode
);
if
(!
ObjectUtils
.
isEmpty
(
iotDataInfoMap
)
&&
iotDataInfoMap
.
containsKey
(
iotCode
))
{
List
<
Map
<
String
,
String
>>
listObject
=
iotDataInfoMap
.
get
(
iotCode
);
for
(
Map
<
String
,
String
>
mapList
:
listObject
)
{
String
time
=
change
(
mapList
.
get
(
"time"
));
String
dateX
=
roundToNearestFiveMinutes
(
time
);
if
(
stringIntegerHashMap
.
containsKey
(
dateX
)){
if
(
mapList
.
containsKey
(
indexKey
)
&&
!
ObjectUtils
.
isEmpty
(
mapList
.
get
(
indexKey
)))
{
stringIntegerHashMap
.
get
(
dateX
).
add
(
new
BigDecimal
(
mapList
.
get
(
indexKey
)));
}
}
else
{
stringIntegerHashMap
.
put
(
dateX
,
new
ArrayList
<>());
}
}
}
}
List
<
Object
>
values
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
allTimeList
.
size
();
i
++)
{
List
<
BigDecimal
>
orDefault
=
stringIntegerHashMap
.
getOrDefault
(
allTimeList
.
get
(
i
),
new
ArrayList
<>());
// 计算非空值的总和
BigDecimal
sum
=
orDefault
.
stream
()
.
filter
(
Objects:
:
nonNull
)
.
reduce
(
BigDecimal
.
ZERO
,
BigDecimal:
:
add
);
// 计算非空值的数量
long
count
=
orDefault
.
stream
().
filter
(
Objects:
:
nonNull
).
count
();
// 检查除数是否为0
BigDecimal
divide
;
if
(
count
==
0
)
{
// 如果非空值数量为0,可以选择返回0或其他默认值
divide
=
BigDecimal
.
ZERO
;
}
else
{
// 否则,进行除法运算
divide
=
sum
.
divide
(
new
BigDecimal
(
count
),
2
,
RoundingMode
.
HALF_UP
);
}
values
.
add
(
divide
);
}
yaxisList
.
add
(
values
);
}
List
<
String
>
collect
=
allTimeList
.
stream
().
map
(
item
->
item
+
":00"
).
collect
(
Collectors
.
toList
());
equipTrendResultVo
.
setxAxisData
(
collect
);
equipTrendResultVo
.
setLegends
(
legends
);
equipTrendResultVo
.
setThreshold
(
threshold
);
equipTrendResultVo
.
setyAxisData
(
yaxisList
);
return
equipTrendResultVo
;
}
private
String
change
(
String
time
)
throws
ParseException
{
Date
date1
=
null
;
try
{
...
...
@@ -2453,4 +2567,98 @@ public class EquipmentSpecificSerivceImpl extends ServiceImpl<EquipmentSpecificM
}
return
hourlyTimes
;
}
// 格式化时间显示
private
static
final
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm"
);
/**
* 根据开始时间和结束时间,每隔五分钟获取一个时间点
*
* @param startTimeStr 开始时间字符串,格式为"yyyy-MM-dd HH:mm:ss"
* @param endTimeStr 结束时间字符串,格式为"yyyy-MM-dd HH:mm:ss"
* @return 时间点列表,每个时间点格式为"yyyy-MM-dd HH:mm"
*/
public
static
List
<
String
>
getTimePoints
(
String
startTimeStr
,
String
endTimeStr
)
{
List
<
String
>
timePoints
=
new
ArrayList
<>();
try
{
// 将字符串时间转换为Date对象
Date
startTime
=
sdf
.
parse
(
startTimeStr
.
substring
(
0
,
16
)
+
":00"
);
// 截取到分钟,因为我们是按五分钟计算
Date
endTime
=
sdf
.
parse
(
endTimeStr
);
// 初始时间点为开始时间的五分钟后的时间
Date
currentTime
=
new
Date
(
startTime
.
getTime
()
+
5
*
60
*
1000
);
// 加上五分钟的时间
// 循环直到当前时间超过结束时间
while
(
currentTime
.
before
(
endTime
)
||
currentTime
.
equals
(
endTime
))
{
// 格式化当前时间并添加到列表中
timePoints
.
add
(
sdf
.
format
(
currentTime
));
// 计算下一个时间点(五分钟后的时间)
currentTime
=
new
Date
(
currentTime
.
getTime
()
+
5
*
60
*
1000
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
timePoints
;
}
// 定义一个DateTimeFormatter用于解析输入时间(包含秒)
// 但实际上在这个方法中我们不会直接使用它,因为我们可以直接截取字符串
private
static
final
DateTimeFormatter
parserWithSeconds
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm:ss"
);
// 定义一个DateTimeFormatter用于格式化输出时间(不包含秒)
private
static
final
DateTimeFormatter
formatterFive
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm"
);
/**
* 将给定的时间转换为最接近的5分钟节点
*
* @param timeStr 输入的时间字符串,格式为"yyyy-MM-dd HH:mm:ss"
* @return 转换后的时间字符串,格式为"yyyy-MM-dd HH:mm"
*/
public
static
String
roundToNearestFiveMinutes
(
String
timeStr
)
{
// 截取时间字符串到分钟部分(这里我们不需要真的解析秒,只是确保格式正确)
String
timeStrToMinute
=
timeStr
.
substring
(
0
,
16
);
// 假设timeStrToMinute已经是"yyyy-MM-dd HH:mm"格式,我们可以直接用它来构造LocalDateTime
// 但为了严谨性,我们还是使用formatter来解析(尽管在这个特定情况下不是必需的)
// LocalDateTime dateTime = LocalDateTime.parse(timeStrToMinute, formatter); // 这行其实可以省略,因为我们没有用到formatter的解析功能
// 但为了简化,我们直接构造LocalDateTime(因为我们已经知道字符串是有效的)
LocalDateTime
dateTime
=
LocalDateTime
.
of
(
Integer
.
parseInt
(
timeStr
.
substring
(
0
,
4
)),
// 年
Integer
.
parseInt
(
timeStr
.
substring
(
5
,
7
)),
// 月
Integer
.
parseInt
(
timeStr
.
substring
(
8
,
10
)),
// 日
Integer
.
parseInt
(
timeStr
.
substring
(
11
,
13
)),
// 时
Integer
.
parseInt
(
timeStr
.
substring
(
14
,
16
))
// 分
);
// 获取分钟数
int
minute
=
dateTime
.
getMinute
();
// 计算与最近5分钟节点的差距
// 注意:这里的计算方式需要调整,以确保正确向上或向下舍入
int
adjustment
=
(
minute
/
5
)
*
5
;
// 向下舍入到最近的5分钟
if
(
minute
%
5
>=
3
)
{
// 如果分钟数距离下一个5分钟节点较近,则调整为下一个5分钟节点
adjustment
+=
5
;
}
// 加上差距值(可能是0,可能是5)
dateTime
=
dateTime
.
plusMinutes
(
adjustment
-
minute
);
// 使用差值来调整
// 格式化并返回结果
return
dateTime
.
format
(
formatterFive
);
}
// public static void main(String[] args) {
// String time1 = "2024-09-19 03:54:10";
// String time2 = "2024-09-19 03:56:10";
//
// System.out.println(roundToNearestFiveMinutes(time1)); // 输出: 2024-09-19 03:55
// System.out.println(roundToNearestFiveMinutes(time2)); // 输出: 2024-09-19 04:00
// }
//}
}
amos-boot-system-equip/src/main/resources/mapper/EquipmentSpecificMapper.xml
View file @
9803ced7
...
...
@@ -3034,4 +3034,48 @@
GROUP BY
a.id
</select>
<select
id=
"getWaterList"
resultType=
"com.yeejoin.equipmanage.common.entity.vo.EquipTrendInfoVo"
>
SELECT
a.sequence_nbr AS id,
a.`name` AS `name`,
GROUP_CONCAT( c.iot_code ) AS iotCode,
b.min_water_level AS minNum,
b.max_water_level AS maxNum,
'液位(M)' AS unit
FROM
`cb_water_resource` AS a
LEFT JOIN cb_water_resource_pool b ON a.sequence_nbr = b.resource_id
LEFT JOIN wl_equipment_specific c ON FIND_IN_SET( c.id, b.level_device_id )
WHERE
b.level_device_id IS NOT NULL
AND b.level_device_id != ''
AND a.resource_type IN ( 'pool', 'industryPool' )
<if
test=
"bizOrgCode != null and bizOrgCode != ''"
>
AND a.biz_org_code LIKE concat(#{bizOrgCode}, '%')
</if>
GROUP BY
a.sequence_nbr
HAVING
iotCode IS NOT NULL
AND iotCode != ''
</select>
<select
id=
"getIndexKeyByIotCode"
resultType=
"java.util.Map"
>
SELECT
a.iot_code as iotCode,
max(case when b.type_code = 'LiquidLevel' then equipment_index_key end) as indexKey
FROM
wl_equipment_specific a
LEFT JOIN wl_equipment_specific_index b ON a.id = b.equipment_specific_id
WHERE
a.iot_code
IN
<foreach
item=
"item"
collection=
"list"
separator=
","
open=
"("
close=
")"
index=
""
>
#{item}
</foreach>
GROUP BY
a.iot_code
</select>
</mapper>
\ No newline at end of file
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