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
da8e9d03
Commit
da8e9d03
authored
Feb 21, 2023
by
高建强
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
item:稳压泵统计与分析优化涉及业务调整
parent
484165db
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
244 additions
and
191 deletions
+244
-191
IPressurePumpService.java
...com/yeejoin/equipmanage/service/IPressurePumpService.java
+38
-3
EmergencyServiceImpl.java
...eejoin/equipmanage/service/impl/EmergencyServiceImpl.java
+13
-51
PressurePumpServiceImpl.java
...oin/equipmanage/service/impl/PressurePumpServiceImpl.java
+107
-23
SupervisionVideoServiceImpl.java
...equipmanage/service/impl/SupervisionVideoServiceImpl.java
+86
-114
No files found.
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/service/IPressurePumpService.java
View file @
da8e9d03
...
@@ -38,24 +38,32 @@ public interface IPressurePumpService {
...
@@ -38,24 +38,32 @@ public interface IPressurePumpService {
/**
/**
* 获取所有稳压泵最近一次启停间隔,min
* 获取所有稳压泵最近一次启停间隔,min
*
* @param dataList
* @param dataList
* @param dataListFilterTrue
* @param dataListFilterFalse
* @param nowStrLong
* @param nowStrLong
*/
*/
long
getAllPressurePumpStartStopInterval
(
List
<
IotDataVO
>
dataList
,
String
nowStrLong
);
long
getAllPressurePumpStartStopInterval
(
List
<
IotDataVO
>
dataList
,
List
<
IotDataVO
>
dataListFilterTrue
,
List
<
IotDataVO
>
dataListFilterFalse
,
String
nowStrLong
);
/**
/**
* 获取稳压泵一定时间内启动频率或次数
* 获取稳压泵一定时间内启动频率或次数
*
* @param hour
* @param hour
* @param dataList
* @param dateNow
* @param dateNow
*/
*/
int
getAllPressurePumpStartFrequency
(
double
hour
,
Date
dateNow
);
int
getAllPressurePumpStartFrequency
(
double
hour
,
List
<
IotDataVO
>
dataList
,
Date
dateNow
);
/**
/**
* 获取稳压泵最近一次启停时长,min
* 获取稳压泵最近一次启停时长,min
*
* @param dataList
* @param dataList
* @param dataListFilterTrue
* @param dataListFilterFalse
* @param nowStrLong
* @param nowStrLong
*/
*/
long
getAllPressurePumpStartStopDuration
(
List
<
IotDataVO
>
dataList
,
String
nowStrLong
);
long
getAllPressurePumpStartStopDuration
(
List
<
IotDataVO
>
dataList
,
List
<
IotDataVO
>
dataListFilterTrue
,
List
<
IotDataVO
>
dataListFilterFalse
,
String
nowStrLong
);
/**
/**
* 获取稳压泵指定启泵前 minutes 分钟,管网压力差绝对值
* 获取稳压泵指定启泵前 minutes 分钟,管网压力差绝对值
...
@@ -97,4 +105,31 @@ public interface IPressurePumpService {
...
@@ -97,4 +105,31 @@ public interface IPressurePumpService {
*/
*/
List
<
Map
<
String
,
String
>>
getIotCommonListData
(
String
startTime
,
String
endTime
,
String
prefix
,
String
suffix
,
String
key
,
String
fieldKey
);
List
<
Map
<
String
,
String
>>
getIotCommonListData
(
String
startTime
,
String
endTime
,
String
prefix
,
String
suffix
,
String
key
,
String
fieldKey
);
/**
* 数据根据指定值过滤
* @param dataList
* @param value
*/
List
<
IotDataVO
>
getDataListFilter
(
List
<
IotDataVO
>
dataList
,
String
value
);
/**
* 获取稳压泵数据,redis没有,从iot取
*
* @param infoCode
* @param equipmentCode
* @param top
* @param nameKey
* @param bizOrgCode
* @param iotCode
* @return
*/
Map
<
String
,
List
<
IotDataVO
>>
getDataList
(
String
infoCode
,
String
equipmentCode
,
String
top
,
String
nameKey
,
String
bizOrgCode
,
String
iotCode
);
/**
* map 转化为对象
* @param map
* @param aClass
* @return
*/
Object
mapToObject
(
Map
<
String
,
String
>
map
,
Class
<?>
aClass
)
throws
IllegalAccessException
,
InstantiationException
;
}
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/service/impl/EmergencyServiceImpl.java
View file @
da8e9d03
...
@@ -9,7 +9,6 @@ import com.yeejoin.equipmanage.common.enums.PressurePumpRelateEnum;
...
@@ -9,7 +9,6 @@ import com.yeejoin.equipmanage.common.enums.PressurePumpRelateEnum;
import
com.yeejoin.equipmanage.common.utils.StringUtil
;
import
com.yeejoin.equipmanage.common.utils.StringUtil
;
import
com.yeejoin.equipmanage.common.utils.UnitTransformUtil
;
import
com.yeejoin.equipmanage.common.utils.UnitTransformUtil
;
import
com.yeejoin.equipmanage.common.vo.IotDataVO
;
import
com.yeejoin.equipmanage.common.vo.IotDataVO
;
import
com.yeejoin.equipmanage.fegin.IotFeign
;
import
com.yeejoin.equipmanage.mapper.EmergencyMapper
;
import
com.yeejoin.equipmanage.mapper.EmergencyMapper
;
import
com.yeejoin.equipmanage.service.IEmergencyService
;
import
com.yeejoin.equipmanage.service.IEmergencyService
;
import
com.yeejoin.equipmanage.service.IEquipmentSpecificAlarmLogService
;
import
com.yeejoin.equipmanage.service.IEquipmentSpecificAlarmLogService
;
...
@@ -21,8 +20,6 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -21,8 +20,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.ObjectUtils
;
import
org.typroject.tyboot.core.restful.exception.instance.BadRequest
;
import
java.util.*
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -48,9 +45,6 @@ public class EmergencyServiceImpl implements IEmergencyService {
...
@@ -48,9 +45,6 @@ public class EmergencyServiceImpl implements IEmergencyService {
private
SupervisionVideoServiceImpl
supervisionVideoService
;
private
SupervisionVideoServiceImpl
supervisionVideoService
;
@Autowired
@Autowired
private
IotFeign
iotFeign
;
@Autowired
private
IPressurePumpService
pressurePumpService
;
private
IPressurePumpService
pressurePumpService
;
@Value
(
"${equipment.pressurepump.start}"
)
@Value
(
"${equipment.pressurepump.start}"
)
...
@@ -235,71 +229,39 @@ public class EmergencyServiceImpl implements IEmergencyService {
...
@@ -235,71 +229,39 @@ public class EmergencyServiceImpl implements IEmergencyService {
Map
map
=
infoList
.
get
(
0
);
Map
map
=
infoList
.
get
(
0
);
String
equipmentCode
=
map
.
get
(
"equipmentCode"
).
toString
();
String
equipmentCode
=
map
.
get
(
"equipmentCode"
).
toString
();
String
faultNameKey
=
map
.
get
(
"faultNameKey"
).
toString
();
String
faultNameKey
=
map
.
get
(
"faultNameKey"
).
toString
();
String
top
=
map
.
get
(
"top"
).
toString
();
// 1. 判断稳压泵整体是否故障
// 1. 判断稳压泵整体是否故障
List
<
EquipmentSpecificAlarmLog
>
alarmLogList
=
equipmentSpecificAlarmLogService
.
getAlarmLogInfoList
(
equipmentCode
,
faultNameKey
,
PressurePumpRelateEnum
.
IOT_INDEX_VALUE_TRUE
.
getValue
(),
PressurePumpRelateEnum
.
UN_CLEAN_TIME
.
getValue
(),
bizOrgCode
);
List
<
EquipmentSpecificAlarmLog
>
alarmLogList
=
equipmentSpecificAlarmLogService
.
getAlarmLogInfoList
(
equipmentCode
,
faultNameKey
,
PressurePumpRelateEnum
.
IOT_INDEX_VALUE_TRUE
.
getValue
(),
PressurePumpRelateEnum
.
UN_CLEAN_TIME
.
getValue
(),
bizOrgCode
);
PressurePumpAnalysisEnum
.
PRESSURE_PUMP_FAULT
.
setValue
(
CollectionUtils
.
isEmpty
(
alarmLogList
)
?
PressurePumpRelateEnum
.
NOT_FAULT
.
getValue
()
:
PressurePumpRelateEnum
.
FAULT
.
getValue
());
PressurePumpAnalysisEnum
.
PRESSURE_PUMP_FAULT
.
setValue
(
CollectionUtils
.
isEmpty
(
alarmLogList
)
?
PressurePumpRelateEnum
.
NOT_FAULT
.
getValue
()
:
PressurePumpRelateEnum
.
FAULT
.
getValue
());
// 获取redis稳压泵缓存数据,默认JSON配置最近4小时
// 获取稳压泵数据,redis没有,从iot取
List
<
IotDataVO
>
DataList
=
pressurePumpService
.
getDataToRedis
(
PressurePumpRelateEnum
.
PRESSURE_PUMP
.
getValue
(),
pressurePumpStart
,
null
);
Map
<
String
,
List
<
IotDataVO
>>
dataMap
=
pressurePumpService
.
getDataList
(
PressurePumpRelateEnum
.
PRESSURE_PUMP
.
getValue
(),
equipmentCode
,
top
,
pressurePumpStart
,
bizOrgCode
,
null
);
List
<
IotDataVO
>
DataPipeList
=
pressurePumpService
.
getDataToRedis
(
PressurePumpRelateEnum
.
PRESSURE_PUMP
.
getValue
(),
pressurePumpPipePressure
,
null
);
List
<
IotDataVO
>
dataList
=
dataMap
.
get
(
"dataList"
);
String
top
=
map
.
get
(
"top"
).
toString
();
List
<
IotDataVO
>
dataListFilterTrue
=
dataMap
.
get
(
"dataListFilterTrue"
);
// 通过 equipmentCode 获取装备
List
<
IotDataVO
>
dataListFilterFalse
=
dataMap
.
get
(
"dataListFilterFalse"
);
List
<
Map
<
String
,
Object
>>
pumpInfoList
=
equipmentSpecificSerivce
.
getFirePumpInfoEQ
(
equipmentCode
,
bizOrgCode
);
Map
<
String
,
List
<
IotDataVO
>>
dataPipMap
=
pressurePumpService
.
getDataList
(
PressurePumpRelateEnum
.
PRESSURE_PUMP
.
getValue
(),
equipmentCode
,
top
,
pressurePumpPipePressure
,
bizOrgCode
,
null
);
if
(!
ObjectUtils
.
isEmpty
(
pumpInfoList
))
{
List
<
IotDataVO
>
dataPipeList
=
dataPipMap
.
get
(
"dataList"
);
String
iotCode
=
pumpInfoList
.
get
(
0
).
get
(
"iotCode"
).
toString
();
if
(
iotCode
.
length
()
>
8
)
{
String
prefix
=
iotCode
.
substring
(
0
,
8
);
//获取iot的数据
if
(
ObjectUtils
.
isEmpty
(
DataList
)){
DataList
=
getIotData
(
top
,
prefix
,
pressurePumpStart
);
}
if
(
ObjectUtils
.
isEmpty
(
DataPipeList
)){
DataPipeList
=
getIotData
(
top
,
prefix
,
pressurePumpPipePressure
);
}
}
else
{
throw
new
BadRequest
(
"装备物联编码错误,请确认!"
);
}
}
String
nowStrLong
=
DateUtils
.
getDateNowString
();
String
nowStrLong
=
DateUtils
.
getDateNowString
();
// 2. 最近一次启停间隔
long
interval
=
pressurePumpService
.
getAllPressurePumpStartStopInterval
(
DataList
,
nowStrLong
);
// 3. 最近一次启动时长
long
duration
=
pressurePumpService
.
getAllPressurePumpStartStopDuration
(
DataList
,
nowStrLong
);
// 6. 管网压力状态
double
pressureDiff
=
pressurePumpService
.
getAllPressurePumpPipePressureDiff
(
DataList
,
DataPipeList
,
PressurePumpRelateEnum
.
PRESSURE_PUMP_START_BEFORE_MINUTE
.
getValue
());
Date
dateNow
=
DateUtils
.
getDateNow
();
Date
dateNow
=
DateUtils
.
getDateNow
();
// 2. 最近一次启停间隔
// 2. 最近一次启停间隔
long
interval
=
pressurePumpService
.
getAllPressurePumpStartStopInterval
(
dataList
,
dataListFilterTrue
,
dataListFilterFalse
,
nowStrLong
);
PressurePumpAnalysisEnum
.
PRESSURE_PUMP_INTERVAL
.
setValue
(
interval
);
PressurePumpAnalysisEnum
.
PRESSURE_PUMP_INTERVAL
.
setValue
(
interval
);
// 3. 最近一次启动时长
// 3. 最近一次启动时长
long
duration
=
pressurePumpService
.
getAllPressurePumpStartStopDuration
(
dataList
,
dataListFilterTrue
,
dataListFilterFalse
,
nowStrLong
);
PressurePumpAnalysisEnum
.
PRESSURE_PUMP_DURATION
.
setValue
(
duration
);
PressurePumpAnalysisEnum
.
PRESSURE_PUMP_DURATION
.
setValue
(
duration
);
// 4. 半小时启动
// 4. 半小时启动
int
halfFrequency
=
pressurePumpService
.
getAllPressurePumpStartFrequency
(
Double
.
parseDouble
(
PressurePumpRelateEnum
.
HALF_HOUR
.
getValue
()),
dateNow
);
int
halfFrequency
=
pressurePumpService
.
getAllPressurePumpStartFrequency
(
Double
.
parseDouble
(
PressurePumpRelateEnum
.
HALF_HOUR
.
getValue
()),
dat
aListFilterTrue
,
dat
eNow
);
PressurePumpAnalysisEnum
.
PRESSURE_PUMP_HALF
.
setValue
(
halfFrequency
);
PressurePumpAnalysisEnum
.
PRESSURE_PUMP_HALF
.
setValue
(
halfFrequency
);
// 5. 2小时启动
// 5. 2小时启动
int
twoFrequency
=
pressurePumpService
.
getAllPressurePumpStartFrequency
(
Double
.
parseDouble
(
PressurePumpRelateEnum
.
TWO_HOUR
.
getValue
()),
dateNow
);
int
twoFrequency
=
pressurePumpService
.
getAllPressurePumpStartFrequency
(
Double
.
parseDouble
(
PressurePumpRelateEnum
.
TWO_HOUR
.
getValue
()),
dat
aListFilterTrue
,
dat
eNow
);
PressurePumpAnalysisEnum
.
PRESSURE_PUMP_TWO
.
setValue
(
twoFrequency
);
PressurePumpAnalysisEnum
.
PRESSURE_PUMP_TWO
.
setValue
(
twoFrequency
);
// 6. 管网压力状态
// 6. 管网压力状态
double
pressureDiff
=
pressurePumpService
.
getAllPressurePumpPipePressureDiff
(
dataList
,
dataPipeList
,
PressurePumpRelateEnum
.
PRESSURE_PUMP_START_BEFORE_MINUTE
.
getValue
());
PressurePumpAnalysisEnum
.
PRESSURE_PUMP_PIPE
.
setValue
(
pressureDiff
>
Double
.
parseDouble
(
PressurePumpRelateEnum
.
PIPE_PRESSURE_DIFF
.
getValue
())
?
PressurePumpRelateEnum
.
PIPE_PRESSURE_ABNORMAL_STATUS
.
getValue
()
:
PressurePumpRelateEnum
.
PIPE_PRESSURE_NORMAL_STATUS
.
getValue
());
PressurePumpAnalysisEnum
.
PRESSURE_PUMP_PIPE
.
setValue
(
pressureDiff
>
Double
.
parseDouble
(
PressurePumpRelateEnum
.
PIPE_PRESSURE_DIFF
.
getValue
())
?
PressurePumpRelateEnum
.
PIPE_PRESSURE_ABNORMAL_STATUS
.
getValue
()
:
PressurePumpRelateEnum
.
PIPE_PRESSURE_NORMAL_STATUS
.
getValue
());
}
}
return
PressurePumpAnalysisEnum
.
getList
();
return
PressurePumpAnalysisEnum
.
getList
();
}
}
private
List
<
IotDataVO
>
getIotData
(
String
top
,
String
prefix
,
String
indexKey
)
{
List
<
IotDataVO
>
DataList
=
new
ArrayList
<>();
List
<
Map
<
String
,
String
>>
iotDataList
=
pressurePumpService
.
getIotTopSingleField
(
top
,
prefix
,
null
,
null
,
indexKey
);
//将iot的List<Map<String, String>>转化为List<IotDataVO>类型
iotDataList
.
stream
().
forEach
(
e
->
{
try
{
IotDataVO
iotDataVO
=
(
IotDataVO
)
supervisionVideoService
.
mapToObject
(
e
,
IotDataVO
.
class
);
DataList
.
add
(
iotDataVO
);
}
catch
(
Exception
el
)
{
throw
new
BadRequest
(
"IOT数据类型转换失败"
);
}
});
return
DataList
;
}
@Override
@Override
public
Map
<
String
,
Object
>
getPressurePumpStatusChart
(
String
startTime
,
String
endTime
,
String
bizOrgCode
)
{
public
Map
<
String
,
Object
>
getPressurePumpStatusChart
(
String
startTime
,
String
endTime
,
String
bizOrgCode
)
{
Map
<
String
,
Object
>
map
=
new
LinkedHashMap
<>();
Map
<
String
,
Object
>
map
=
new
LinkedHashMap
<>();
...
...
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/service/impl/PressurePumpServiceImpl.java
View file @
da8e9d03
...
@@ -8,6 +8,7 @@ import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
...
@@ -8,6 +8,7 @@ import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import
com.yeejoin.equipmanage.common.enums.PressurePumpRelateEnum
;
import
com.yeejoin.equipmanage.common.enums.PressurePumpRelateEnum
;
import
com.yeejoin.equipmanage.common.vo.IotDataVO
;
import
com.yeejoin.equipmanage.common.vo.IotDataVO
;
import
com.yeejoin.equipmanage.fegin.IotFeign
;
import
com.yeejoin.equipmanage.fegin.IotFeign
;
import
com.yeejoin.equipmanage.service.IEquipmentSpecificSerivce
;
import
com.yeejoin.equipmanage.service.IPressurePumpService
;
import
com.yeejoin.equipmanage.service.IPressurePumpService
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.collections4.CollectionUtils
;
...
@@ -18,9 +19,13 @@ import org.springframework.beans.factory.annotation.Value;
...
@@ -18,9 +19,13 @@ import org.springframework.beans.factory.annotation.Value;
import
org.springframework.core.io.Resource
;
import
org.springframework.core.io.Resource
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.ObjectUtils
;
import
org.typroject.tyboot.core.restful.exception.instance.BadRequest
;
import
org.typroject.tyboot.core.restful.utils.ResponseModel
;
import
org.typroject.tyboot.core.restful.utils.ResponseModel
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.lang.reflect.Field
;
import
java.lang.reflect.Modifier
;
import
java.nio.charset.StandardCharsets
;
import
java.nio.charset.StandardCharsets
;
import
java.text.ParseException
;
import
java.text.ParseException
;
import
java.util.*
;
import
java.util.*
;
...
@@ -31,6 +36,9 @@ import java.util.stream.Collectors;
...
@@ -31,6 +36,9 @@ import java.util.stream.Collectors;
public
class
PressurePumpServiceImpl
implements
IPressurePumpService
{
public
class
PressurePumpServiceImpl
implements
IPressurePumpService
{
@Autowired
@Autowired
private
IEquipmentSpecificSerivce
equipmentSpecificSerivce
;
@Autowired
private
IotFeign
iotFeign
;
private
IotFeign
iotFeign
;
@Autowired
@Autowired
...
@@ -122,28 +130,26 @@ public class PressurePumpServiceImpl implements IPressurePumpService {
...
@@ -122,28 +130,26 @@ public class PressurePumpServiceImpl implements IPressurePumpService {
}
}
@Override
@Override
public
long
getAllPressurePumpStartStopInterval
(
List
<
IotDataVO
>
dataList
,
String
nowStrLong
)
{
public
long
getAllPressurePumpStartStopInterval
(
List
<
IotDataVO
>
dataList
,
List
<
IotDataVO
>
dataListFilterTrue
,
List
<
IotDataVO
>
dataListFilterFalse
,
String
nowStrLong
)
{
String
intervalTime1
=
nowStrLong
;
String
intervalTime1
=
nowStrLong
;
String
intervalTime2
=
nowStrLong
;
String
intervalTime2
=
nowStrLong
;
if
(
CollectionUtils
.
isNotEmpty
(
dataList
))
{
if
(
CollectionUtils
.
isNotEmpty
(
dataList
))
{
IotDataVO
iotDataVO
=
dataList
.
get
(
0
);
IotDataVO
iotDataVO
=
dataList
.
get
(
0
);
String
value
=
iotDataVO
.
getValue
().
toString
();
String
value
=
iotDataVO
.
getValue
().
toString
();
String
createdTime
=
iotDataVO
.
getCreatedTime
();
String
createdTime
=
iotDataVO
.
getCreatedTime
();
List
<
IotDataVO
>
falseDataList
=
getRedisDataFilterList
(
dataList
,
PressurePumpRelateEnum
.
IOT_INDEX_VALUE_FALSE
.
getValue
());
if
(
PressurePumpRelateEnum
.
IOT_INDEX_VALUE_TRUE
.
getValue
().
equalsIgnoreCase
(
value
))
{
if
(
PressurePumpRelateEnum
.
IOT_INDEX_VALUE_TRUE
.
getValue
().
equalsIgnoreCase
(
value
))
{
intervalTime1
=
createdTime
;
intervalTime1
=
createdTime
;
if
(
CollectionUtils
.
isNotEmpty
(
falseDataList
))
{
if
(
CollectionUtils
.
isNotEmpty
(
dataListFilterFalse
))
{
// 获取最新的停止时间
// 获取最新的停止时间
intervalTime2
=
falseDataList
.
get
(
0
).
getCreatedTime
();
intervalTime2
=
dataListFilterFalse
.
get
(
0
).
getCreatedTime
();
}
}
}
else
{
}
else
{
List
<
IotDataVO
>
trueDataList
=
getRedisDataFilterList
(
dataList
,
PressurePumpRelateEnum
.
IOT_INDEX_VALUE_TRUE
.
getValue
());
if
(
CollectionUtils
.
isNotEmpty
(
dataListFilterFalse
)
&&
CollectionUtils
.
isNotEmpty
(
dataListFilterTrue
))
{
if
(
CollectionUtils
.
isNotEmpty
(
falseDataList
)
&&
CollectionUtils
.
isNotEmpty
(
trueDataList
))
{
// 获取最新的启动时间
// 获取最新的启动时间
intervalTime1
=
trueDataList
.
get
(
0
).
getCreatedTime
();
intervalTime1
=
dataListFilterTrue
.
get
(
0
).
getCreatedTime
();
// 获取大于启动信号,且最近停止信号的时间
// 获取大于启动信号,且最近停止信号的时间
String
finalIntervalTime
=
intervalTime1
;
String
finalIntervalTime
=
intervalTime1
;
List
<
IotDataVO
>
timeList
=
falseDataList
.
stream
().
filter
(
x
->
DateUtils
.
getDurationSeconds
(
finalIntervalTime
,
x
.
getCreatedTime
(),
DateUtils
.
DATE_TIME_PATTERN
)
>=
0
).
collect
(
Collectors
.
toList
());
List
<
IotDataVO
>
timeList
=
dataListFilterFalse
.
stream
().
filter
(
x
->
DateUtils
.
getDurationSeconds
(
finalIntervalTime
,
x
.
getCreatedTime
(),
DateUtils
.
DATE_TIME_PATTERN
)
>=
0
).
collect
(
Collectors
.
toList
());
if
(
CollectionUtils
.
isNotEmpty
(
timeList
))
{
if
(
CollectionUtils
.
isNotEmpty
(
timeList
))
{
intervalTime2
=
timeList
.
get
(
timeList
.
size
()
-
1
).
getCreatedTime
();
intervalTime2
=
timeList
.
get
(
timeList
.
size
()
-
1
).
getCreatedTime
();
}
}
...
@@ -155,15 +161,96 @@ public class PressurePumpServiceImpl implements IPressurePumpService {
...
@@ -155,15 +161,96 @@ public class PressurePumpServiceImpl implements IPressurePumpService {
return
new
Double
(
ceil
).
longValue
();
return
new
Double
(
ceil
).
longValue
();
}
}
private
List
<
IotDataVO
>
getRedisDataFilterList
(
List
<
IotDataVO
>
dataList
,
String
value
)
{
@Override
return
dataList
.
stream
().
filter
(
x
->
value
.
equalsIgnoreCase
(
x
.
getValue
().
toString
())).
collect
(
Collectors
.
toList
());
public
List
<
IotDataVO
>
getDataListFilter
(
List
<
IotDataVO
>
dataList
,
String
value
)
{
return
dataList
.
stream
().
filter
(
x
->
x
.
getValue
()
!=
null
&&
StringUtils
.
isNotBlank
(
x
.
getCreatedTime
())
&&
value
.
equalsIgnoreCase
(
x
.
getValue
().
toString
())).
collect
(
Collectors
.
toList
());
}
@Override
public
Map
<
String
,
List
<
IotDataVO
>>
getDataList
(
String
infoCode
,
String
equipmentCode
,
String
top
,
String
nameKey
,
String
bizOrgCode
,
String
iotCode
)
{
Map
<
String
,
List
<
IotDataVO
>>
map
=
new
HashMap
<>();
// 获取redis稳压泵缓存数据,默认JSON配置最近4小时
List
<
IotDataVO
>
dataList
=
getDataToRedis
(
infoCode
,
nameKey
,
iotCode
);
// 过滤指定值数据
List
<
IotDataVO
>
dataListFilterTrue
=
getDataListFilter
(
dataList
,
PressurePumpRelateEnum
.
IOT_INDEX_VALUE_TRUE
.
getValue
());
List
<
IotDataVO
>
dataListFilterFalse
=
getDataListFilter
(
dataList
,
PressurePumpRelateEnum
.
IOT_INDEX_VALUE_FALSE
.
getValue
());
// 通过 equipmentCode 获取装备
List
<
Map
<
String
,
Object
>>
pumpInfoList
=
equipmentSpecificSerivce
.
getFirePumpInfoEQ
(
equipmentCode
,
bizOrgCode
);
if
(!
ObjectUtils
.
isEmpty
(
pumpInfoList
))
{
iotCode
=
pumpInfoList
.
get
(
0
).
get
(
"iotCode"
).
toString
();
if
(
iotCode
.
length
()
>
8
)
{
String
prefix
=
iotCode
.
substring
(
0
,
8
);
//获取iot的数据
if
(
ObjectUtils
.
isEmpty
(
dataList
)
||
ObjectUtils
.
isEmpty
(
dataListFilterTrue
)
||
ObjectUtils
.
isEmpty
(
dataListFilterFalse
)){
dataList
=
getIotData
(
top
,
prefix
,
nameKey
);
// 过滤物联指定值数据
dataListFilterTrue
=
getDataListFilter
(
dataList
,
PressurePumpRelateEnum
.
IOT_INDEX_VALUE_TRUE
.
getValue
());
dataListFilterFalse
=
getDataListFilter
(
dataList
,
PressurePumpRelateEnum
.
IOT_INDEX_VALUE_FALSE
.
getValue
());
}
}
else
{
throw
new
BadRequest
(
"装备物联编码错误,请确认!"
);
}
}
map
.
put
(
"dataList"
,
dataList
);
map
.
put
(
"dataListFilterTrue"
,
dataListFilterTrue
);
map
.
put
(
"dataListFilterFalse"
,
dataListFilterFalse
);
return
map
;
}
private
List
<
IotDataVO
>
getIotData
(
String
top
,
String
prefix
,
String
indexKey
)
{
List
<
IotDataVO
>
dataList
=
new
ArrayList
<>();
List
<
Map
<
String
,
String
>>
iotDataList
=
getIotTopSingleField
(
top
,
prefix
,
null
,
null
,
indexKey
);
//将iot的List<Map<String, String>>转化为List<IotDataVO>类型
iotDataList
.
stream
().
forEach
(
e
->
{
try
{
IotDataVO
iotDataVO
=
(
IotDataVO
)
mapToObject
(
e
,
IotDataVO
.
class
);
dataList
.
add
(
iotDataVO
);
}
catch
(
Exception
el
)
{
throw
new
BadRequest
(
"IOT数据类型转换失败"
);
}
});
return
dataList
;
}
/**
* map 转化为对象
* @param map 需要转化的参数
* @param aClass 要转化成的对象
* @return 转化成功的对象
* @throws IllegalAccessException 非法访问异常
* @throws InstantiationException 实例化异常
*/
@Override
public
Object
mapToObject
(
Map
<
String
,
String
>
map
,
Class
<?>
aClass
)
throws
IllegalAccessException
,
InstantiationException
{
if
(
map
.
isEmpty
()){
return
null
;
}
Object
o
=
aClass
.
newInstance
();
Field
[]
declaredFields
=
o
.
getClass
().
getDeclaredFields
();
for
(
Field
field
:
declaredFields
)
{
int
modifiers
=
field
.
getModifiers
();
if
(
Modifier
.
isStatic
(
modifiers
)
||
Modifier
.
isFinal
(
modifiers
)){
continue
;
}
// (此处如果不设置 无法获取对象的私有属性)
field
.
setAccessible
(
true
);
if
(
"key"
.
equals
(
field
.
getName
())){
field
.
set
(
o
,
pressurePumpStart
);
}
else
if
(
"value"
.
equals
(
field
.
getName
())){
field
.
set
(
o
,
map
.
get
(
pressurePumpStart
));
}
else
{
field
.
set
(
o
,
map
.
get
(
field
.
getName
()));
}
}
return
o
;
}
}
private
List
<
Map
<
String
,
String
>>
getIotDataFilterList
(
List
<
Map
<
String
,
String
>>
iotDataList
,
String
value
)
{
private
List
<
Map
<
String
,
String
>>
getIotDataFilterList
(
List
<
Map
<
String
,
String
>>
iotDataList
,
String
value
)
{
return
iotDataList
.
stream
().
filter
(
x
->
x
.
containsKey
(
PressurePumpRelateEnum
.
CREATED_TIME
.
getValue
())
&&
value
.
equalsIgnoreCase
(
x
.
get
(
pressurePumpStart
))).
collect
(
Collectors
.
toList
());
return
iotDataList
.
stream
().
filter
(
x
->
x
.
containsKey
(
PressurePumpRelateEnum
.
CREATED_TIME
.
getValue
())
&&
value
.
equalsIgnoreCase
(
x
.
get
(
pressurePumpStart
))).
collect
(
Collectors
.
toList
());
}
}
private
List
<
IotDataVO
>
get
RedisDataFilterList
(
List
<
IotDataVO
>
dataList
,
String
value
,
Date
beforeDate
)
{
private
List
<
IotDataVO
>
get
DataListFilter
(
List
<
IotDataVO
>
dataList
,
String
value
,
Date
beforeDate
)
{
if
(
beforeDate
!=
null
)
{
if
(
beforeDate
!=
null
)
{
return
dataList
.
stream
().
filter
(
x
->
DateUtils
.
dateCompare
(
DateUtils
.
longStr2Date
(
x
.
getCreatedTime
()),
beforeDate
)
>=
0
&&
value
.
equalsIgnoreCase
(
x
.
getValue
().
toString
())).
collect
(
Collectors
.
toList
());
return
dataList
.
stream
().
filter
(
x
->
DateUtils
.
dateCompare
(
DateUtils
.
longStr2Date
(
x
.
getCreatedTime
()),
beforeDate
)
>=
0
&&
value
.
equalsIgnoreCase
(
x
.
getValue
().
toString
())).
collect
(
Collectors
.
toList
());
}
}
...
@@ -178,18 +265,17 @@ public class PressurePumpServiceImpl implements IPressurePumpService {
...
@@ -178,18 +265,17 @@ public class PressurePumpServiceImpl implements IPressurePumpService {
}
}
@Override
@Override
public
int
getAllPressurePumpStartFrequency
(
double
hour
,
Date
dateNow
)
{
public
int
getAllPressurePumpStartFrequency
(
double
hour
,
List
<
IotDataVO
>
dataList
,
Date
dateNow
)
{
List
<
IotDataVO
>
list
=
getDataToRedis
(
PressurePumpRelateEnum
.
PRESSURE_PUMP
.
getValue
(),
pressurePumpStart
,
null
);
if
(
CollectionUtils
.
isNotEmpty
(
dataList
))
{
if
(
CollectionUtils
.
isNotEmpty
(
list
))
{
Date
beforeDate
=
DateUtils
.
dateAddMinutes
(
dateNow
,
(
int
)
(
hour
*
Integer
.
parseInt
(
PressurePumpRelateEnum
.
ONE_HOUR_MINUTE
.
getValue
())
*
-
1
));
Date
beforeDate
=
DateUtils
.
dateAddMinutes
(
dateNow
,
(
int
)
(
hour
*
Integer
.
parseInt
(
PressurePumpRelateEnum
.
ONE_HOUR_MINUTE
.
getValue
())
*
-
1
));
List
<
IotDataVO
>
collect
=
list
.
stream
().
filter
(
x
->
DateUtils
.
dateCompare
(
DateUtils
.
longStr2Date
(
x
.
getCreatedTime
()),
beforeDate
)
>=
0
&&
PressurePumpRelateEnum
.
IOT_INDEX_VALUE_TRUE
.
getValue
().
equalsIgnoreCase
(
x
.
getValue
().
toString
())
).
collect
(
Collectors
.
toList
());
List
<
IotDataVO
>
collect
=
dataList
.
stream
().
filter
(
x
->
DateUtils
.
dateCompare
(
DateUtils
.
longStr2Date
(
x
.
getCreatedTime
()),
beforeDate
)
>=
0
).
collect
(
Collectors
.
toList
());
return
collect
.
size
();
return
collect
.
size
();
}
}
return
0
;
return
0
;
}
}
@Override
@Override
public
long
getAllPressurePumpStartStopDuration
(
List
<
IotDataVO
>
dataList
,
String
nowStrLong
)
{
public
long
getAllPressurePumpStartStopDuration
(
List
<
IotDataVO
>
dataList
,
List
<
IotDataVO
>
dataListFilterTrue
,
List
<
IotDataVO
>
dataListFilterFalse
,
String
nowStrLong
)
{
String
durationTime
=
nowStrLong
;
String
durationTime
=
nowStrLong
;
if
(
CollectionUtils
.
isNotEmpty
(
dataList
))
{
if
(
CollectionUtils
.
isNotEmpty
(
dataList
))
{
IotDataVO
iotDataVO
=
dataList
.
get
(
0
);
IotDataVO
iotDataVO
=
dataList
.
get
(
0
);
...
@@ -198,14 +284,12 @@ public class PressurePumpServiceImpl implements IPressurePumpService {
...
@@ -198,14 +284,12 @@ public class PressurePumpServiceImpl implements IPressurePumpService {
if
(
PressurePumpRelateEnum
.
IOT_INDEX_VALUE_TRUE
.
getValue
().
equalsIgnoreCase
(
value
))
{
if
(
PressurePumpRelateEnum
.
IOT_INDEX_VALUE_TRUE
.
getValue
().
equalsIgnoreCase
(
value
))
{
durationTime
=
createdTime
;
durationTime
=
createdTime
;
}
else
{
}
else
{
List
<
IotDataVO
>
falseDataList
=
getRedisDataFilterList
(
dataList
,
PressurePumpRelateEnum
.
IOT_INDEX_VALUE_FALSE
.
getValue
());
if
(
CollectionUtils
.
isNotEmpty
(
dataListFilterFalse
)
&&
CollectionUtils
.
isNotEmpty
(
dataListFilterTrue
))
{
List
<
IotDataVO
>
trueDataList
=
getRedisDataFilterList
(
dataList
,
PressurePumpRelateEnum
.
IOT_INDEX_VALUE_TRUE
.
getValue
());
if
(
CollectionUtils
.
isNotEmpty
(
falseDataList
)
&&
CollectionUtils
.
isNotEmpty
(
trueDataList
))
{
// 获取最新启动时间
// 获取最新启动时间
durationTime
=
trueDataList
.
get
(
0
).
getCreatedTime
();
durationTime
=
dataListFilterTrue
.
get
(
0
).
getCreatedTime
();
// 获取大于启动信号,且最近停止信号的时间
// 获取大于启动信号,且最近停止信号的时间
String
finalDurationTime
=
durationTime
;
String
finalDurationTime
=
durationTime
;
List
<
IotDataVO
>
timeList
=
falseDataList
.
stream
().
filter
(
x
->
DateUtils
.
getDurationSeconds
(
finalDurationTime
,
x
.
getCreatedTime
(),
DateUtils
.
DATE_TIME_PATTERN
)
>=
0
).
collect
(
Collectors
.
toList
());
List
<
IotDataVO
>
timeList
=
dataListFilterFalse
.
stream
().
filter
(
x
->
DateUtils
.
getDurationSeconds
(
finalDurationTime
,
x
.
getCreatedTime
(),
DateUtils
.
DATE_TIME_PATTERN
)
>=
0
).
collect
(
Collectors
.
toList
());
if
(
CollectionUtils
.
isNotEmpty
(
timeList
))
{
if
(
CollectionUtils
.
isNotEmpty
(
timeList
))
{
nowStrLong
=
timeList
.
get
(
timeList
.
size
()
-
1
).
getCreatedTime
();
nowStrLong
=
timeList
.
get
(
timeList
.
size
()
-
1
).
getCreatedTime
();
}
}
...
@@ -223,13 +307,13 @@ public class PressurePumpServiceImpl implements IPressurePumpService {
...
@@ -223,13 +307,13 @@ public class PressurePumpServiceImpl implements IPressurePumpService {
IotDataVO
iotDataVO
=
dataList
.
get
(
0
);
IotDataVO
iotDataVO
=
dataList
.
get
(
0
);
String
value
=
iotDataVO
.
getValue
().
toString
();
String
value
=
iotDataVO
.
getValue
().
toString
();
if
(
PressurePumpRelateEnum
.
IOT_INDEX_VALUE_TRUE
.
getValue
().
equalsIgnoreCase
(
value
))
{
if
(
PressurePumpRelateEnum
.
IOT_INDEX_VALUE_TRUE
.
getValue
().
equalsIgnoreCase
(
value
))
{
List
<
IotDataVO
>
falseDataList
=
get
RedisDataFilterList
(
dataList
,
PressurePumpRelateEnum
.
IOT_INDEX_VALUE_FALSE
.
getValue
());
List
<
IotDataVO
>
falseDataList
=
get
DataListFilter
(
dataList
,
PressurePumpRelateEnum
.
IOT_INDEX_VALUE_FALSE
.
getValue
());
if
(
CollectionUtils
.
isNotEmpty
(
falseDataList
))
{
if
(
CollectionUtils
.
isNotEmpty
(
falseDataList
))
{
String
createdTime
=
falseDataList
.
get
(
0
).
getCreatedTime
();
String
createdTime
=
falseDataList
.
get
(
0
).
getCreatedTime
();
try
{
try
{
Date
stop5BeforeDate
=
DateUtils
.
dateAddMinutes
(
DateUtils
.
convertStrToDate
(
createdTime
,
DateUtils
.
DATE_TIME_PATTERN
),
Integer
.
parseInt
(
minutes
));
Date
stop5BeforeDate
=
DateUtils
.
dateAddMinutes
(
DateUtils
.
convertStrToDate
(
createdTime
,
DateUtils
.
DATE_TIME_PATTERN
),
Integer
.
parseInt
(
minutes
));
// 获取指定之前时间,指定值数据
// 获取指定之前时间,指定值数据
List
<
IotDataVO
>
dataFilterList
=
get
RedisDataFilterList
(
dataPipeList
,
value
,
stop5BeforeDate
);
List
<
IotDataVO
>
dataFilterList
=
get
DataListFilter
(
dataPipeList
,
value
,
stop5BeforeDate
);
if
(
CollectionUtils
.
isNotEmpty
(
dataFilterList
))
{
if
(
CollectionUtils
.
isNotEmpty
(
dataFilterList
))
{
double
val1
=
Double
.
parseDouble
(
dataPipeList
.
get
(
0
).
getValue
().
toString
());
double
val1
=
Double
.
parseDouble
(
dataPipeList
.
get
(
0
).
getValue
().
toString
());
double
val2
=
Double
.
parseDouble
(
dataFilterList
.
get
(
dataFilterList
.
size
()
-
1
).
getValue
().
toString
());
double
val2
=
Double
.
parseDouble
(
dataFilterList
.
get
(
dataFilterList
.
size
()
-
1
).
getValue
().
toString
());
...
...
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/service/impl/SupervisionVideoServiceImpl.java
View file @
da8e9d03
...
@@ -3,7 +3,6 @@ package com.yeejoin.equipmanage.service.impl;
...
@@ -3,7 +3,6 @@ package com.yeejoin.equipmanage.service.impl;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.yeejoin.amos.boot.biz.common.utils.CommonUtils
;
import
com.yeejoin.equipmanage.common.entity.SupervisionVideo
;
import
com.yeejoin.equipmanage.common.entity.SupervisionVideo
;
import
com.yeejoin.equipmanage.common.entity.vo.AlamVideoVO
;
import
com.yeejoin.equipmanage.common.entity.vo.AlamVideoVO
;
import
com.yeejoin.equipmanage.common.enums.PressurePumpRelateEnum
;
import
com.yeejoin.equipmanage.common.enums.PressurePumpRelateEnum
;
...
@@ -23,8 +22,6 @@ import org.springframework.util.CollectionUtils;
...
@@ -23,8 +22,6 @@ import org.springframework.util.CollectionUtils;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.ObjectUtils
;
import
org.typroject.tyboot.core.restful.exception.instance.BadRequest
;
import
org.typroject.tyboot.core.restful.exception.instance.BadRequest
;
import
java.lang.reflect.Field
;
import
java.lang.reflect.Modifier
;
import
java.text.ParseException
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.*
;
...
@@ -85,138 +82,113 @@ public class SupervisionVideoServiceImpl extends ServiceImpl<SupervisionVideoMap
...
@@ -85,138 +82,113 @@ public class SupervisionVideoServiceImpl extends ServiceImpl<SupervisionVideoMap
@Override
@Override
public
Page
<
Map
<
String
,
Object
>>
queryPumpInfo
(
Page
page
,
String
bizOrgCode
)
{
public
Page
<
Map
<
String
,
Object
>>
queryPumpInfo
(
Page
page
,
String
bizOrgCode
)
{
Date
dateNow
=
DateUtils
.
getDateNow
();
// 从 json 配置文件获取配置信息
String
nowStrLong
=
DateUtils
.
getNowStrLong
();
List
<
Map
>
infoList
=
pressurePumpService
.
getNameKeyInfoList
(
PressurePumpRelateEnum
.
PRESSURE_PUMP
.
getValue
());
Long
interval
=
0L
;
Page
<
Map
<
String
,
Object
>>
pressurePumpInfo
=
new
Page
<>();
//全部稳压泵半小时、一小时、两小时、四小时启动次数
if
(!
CollectionUtils
.
isEmpty
(
infoList
))
{
int
halfHourStartNum
=
pressurePumpService
.
getAllPressurePumpStartFrequency
(
Double
.
parseDouble
(
PressurePumpRelateEnum
.
HALF_HOUR
.
getValue
()),
dateNow
);
Map
map
=
infoList
.
get
(
0
);
int
oneHourStartNum
=
pressurePumpService
.
getAllPressurePumpStartFrequency
(
Double
.
parseDouble
(
PressurePumpRelateEnum
.
ONE_HOUR
.
getValue
()),
dateNow
);
String
equipmentCode
=
map
.
get
(
"equipmentCode"
).
toString
();
int
twoHourStartNum
=
pressurePumpService
.
getAllPressurePumpStartFrequency
(
Double
.
parseDouble
(
PressurePumpRelateEnum
.
TWO_HOUR
.
getValue
()),
dateNow
);
String
top
=
map
.
get
(
"top"
).
toString
();
int
fourHourStartNum
=
pressurePumpService
.
getAllPressurePumpStartFrequency
(
Double
.
parseDouble
(
PressurePumpRelateEnum
.
FOUR_HOUR
.
getValue
()),
dateNow
);
Date
dateNow
=
DateUtils
.
getDateNow
();
Page
<
Map
<
String
,
Object
>>
pressurePumpInfo
=
fireFightingSystemMapper
.
getPressurePumpInfo
(
page
,
bizOrgCode
,
null
);
String
nowStrLong
=
DateUtils
.
getNowStrLong
();
String
prefix
=
null
;
// 获取稳压泵数据,redis没有,从iot取
for
(
Map
<
String
,
Object
>
item
:
pressurePumpInfo
.
getRecords
())
{
Map
<
String
,
List
<
IotDataVO
>>
dataMap
=
pressurePumpService
.
getDataList
(
PressurePumpRelateEnum
.
PRESSURE_PUMP
.
getValue
(),
equipmentCode
,
top
,
pressurePumpStart
,
bizOrgCode
,
null
);
String
suffix
=
null
;
List
<
IotDataVO
>
dataListFilterTrue
=
dataMap
.
get
(
"dataListFilterTrue"
);
String
iotCode
=
item
.
get
(
"iot_code"
).
toString
();
List
<
IotDataVO
>
dataListFilterFalse
=
dataMap
.
get
(
"dataListFilterFalse"
);
if
(
iotCode
.
length
()
>
8
)
{
Long
interval
=
0L
;
prefix
=
iotCode
.
substring
(
0
,
8
);
//全部稳压泵半小时、一小时、两小时、四小时启动次数
suffix
=
iotCode
.
substring
(
8
);
int
halfHourStartNum
=
pressurePumpService
.
getAllPressurePumpStartFrequency
(
Double
.
parseDouble
(
PressurePumpRelateEnum
.
HALF_HOUR
.
getValue
()),
dataListFilterTrue
,
dateNow
);
}
else
{
int
oneHourStartNum
=
pressurePumpService
.
getAllPressurePumpStartFrequency
(
Double
.
parseDouble
(
PressurePumpRelateEnum
.
ONE_HOUR
.
getValue
()),
dataListFilterTrue
,
dateNow
);
throw
new
BadRequest
(
"装备物联编码错误,请确认!"
);
int
twoHourStartNum
=
pressurePumpService
.
getAllPressurePumpStartFrequency
(
Double
.
parseDouble
(
PressurePumpRelateEnum
.
TWO_HOUR
.
getValue
()),
dataListFilterTrue
,
dateNow
);
}
int
fourHourStartNum
=
pressurePumpService
.
getAllPressurePumpStartFrequency
(
Double
.
parseDouble
(
PressurePumpRelateEnum
.
FOUR_HOUR
.
getValue
()),
dataListFilterTrue
,
dateNow
);
Date
mounthDate
=
null
;
pressurePumpInfo
=
fireFightingSystemMapper
.
getPressurePumpInfo
(
page
,
bizOrgCode
,
null
);
try
{
String
prefix
=
null
;
mounthDate
=
DateUtils
.
getCurrentMonthStartTime
(
new
Date
());
for
(
Map
<
String
,
Object
>
item
:
pressurePumpInfo
.
getRecords
())
{
}
catch
(
Exception
e
)
{
String
suffix
=
null
;
throw
new
RuntimeException
(
e
);
String
iotCode
=
item
.
get
(
"iot_code"
).
toString
();
}
if
(
iotCode
.
length
()
>
8
)
{
String
startDateStr
=
DateUtils
.
convertDateToString
(
mounthDate
,
DateUtils
.
DATE_TIME_PATTERN
);
prefix
=
iotCode
.
substring
(
0
,
8
);
//稳压泵本月累计启动统计
suffix
=
iotCode
.
substring
(
8
);
List
<
Map
<
String
,
String
>>
mounthEntity
=
}
else
{
pressurePumpService
.
getIotCommonListData
(
startDateStr
,
nowStrLong
,
prefix
,
suffix
,
(
PressurePumpRelateEnum
.
IOT_INDEX_VALUE_TRUE
.
getValue
()),
pressurePumpStart
);
throw
new
BadRequest
(
"装备物联编码错误,请确认!"
);
item
.
put
(
"monthStartNum"
,
ObjectUtils
.
isEmpty
(
mounthEntity
)
?
0
:
mounthEntity
.
size
());
}
item
.
put
(
"halfHourStartNum"
,
halfHourStartNum
);
Date
mounthDate
=
null
;
item
.
put
(
"oneHourStartNum"
,
oneHourStartNum
);
item
.
put
(
"twoHourStartNum"
,
twoHourStartNum
);
item
.
put
(
"fourHourStartNum"
,
fourHourStartNum
);
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
long
nowDateTime
=
new
Date
().
getTime
();
//当前时间戳
boolean
time
=
true
;
//获取最近的一个触发物联指标的时间
Map
<
String
,
String
>
stateMap
=
fireFightingSystemMapper
.
queryPressureNowSignalBySpecificId
((
Long
)
item
.
get
(
"id"
));
Long
update_date
=
0L
;
if
(!
ObjectUtils
.
isEmpty
(
stateMap
))
{
try
{
try
{
//如果当前指标为启动,并且指标值为true,计算启动时长
mounthDate
=
DateUtils
.
getCurrentMonthStartTime
(
new
Date
());
if
(
PressurePumpRelateEnum
.
START
.
getDesc
().
contains
(
stateMap
.
get
(
"equipment_index_name"
))
&&
PressurePumpRelateEnum
.
IOT_INDEX_VALUE_FALSE
.
getValue
().
contains
(
stateMap
.
get
(
"equipment_index_name"
))){
}
catch
(
Exception
e
)
{
update_date
=
sdf
.
parse
(
stateMap
.
get
(
"update_date"
)).
getTime
();
throw
new
RuntimeException
(
e
);
long
res
=
nowDateTime
-
update_date
;
}
long
diffMinute
=
res
/
1000
/
60
;
String
startDateStr
=
DateUtils
.
convertDateToString
(
mounthDate
,
DateUtils
.
DATE_TIME_PATTERN
);
if
(
diffMinute
>
Long
.
valueOf
(
PressurePumpRelateEnum
.
START_FIVE
.
getValue
()))
{
//稳压泵本月累计启动统计
time
=
false
;
List
<
Map
<
String
,
String
>>
mounthEntity
=
pressurePumpService
.
getIotCommonListData
(
startDateStr
,
nowStrLong
,
prefix
,
suffix
,
(
PressurePumpRelateEnum
.
IOT_INDEX_VALUE_TRUE
.
getValue
()),
pressurePumpStart
);
item
.
put
(
"monthStartNum"
,
ObjectUtils
.
isEmpty
(
mounthEntity
)
?
0
:
mounthEntity
.
size
());
item
.
put
(
"halfHourStartNum"
,
halfHourStartNum
);
item
.
put
(
"oneHourStartNum"
,
oneHourStartNum
);
item
.
put
(
"twoHourStartNum"
,
twoHourStartNum
);
item
.
put
(
"fourHourStartNum"
,
fourHourStartNum
);
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
long
nowDateTime
=
new
Date
().
getTime
();
//当前时间戳
boolean
time
=
true
;
//获取最近的一个触发物联指标的时间
Map
<
String
,
String
>
stateMap
=
fireFightingSystemMapper
.
queryPressureNowSignalBySpecificId
((
Long
)
item
.
get
(
"id"
));
Long
update_date
=
0L
;
if
(!
ObjectUtils
.
isEmpty
(
stateMap
))
{
try
{
//如果当前指标为启动,并且指标值为true,计算启动时长
if
(
PressurePumpRelateEnum
.
START
.
getDesc
().
contains
(
stateMap
.
get
(
"equipment_index_name"
))
&&
PressurePumpRelateEnum
.
IOT_INDEX_VALUE_FALSE
.
getValue
().
contains
(
stateMap
.
get
(
"equipment_index_name"
))){
update_date
=
sdf
.
parse
(
stateMap
.
get
(
"update_date"
)).
getTime
();
long
res
=
nowDateTime
-
update_date
;
long
diffMinute
=
res
/
1000
/
60
;
if
(
diffMinute
>
Long
.
valueOf
(
PressurePumpRelateEnum
.
START_FIVE
.
getValue
()))
{
time
=
false
;
}
}
}
item
.
put
(
"equipment_index_name"
,
stateMap
.
get
(
"equipment_index_name"
));
item
.
put
(
"update_time"
,
stateMap
.
get
(
"update_date"
));
}
catch
(
ParseException
e
)
{
throw
new
BadRequest
(
"稳压泵最新指标时间转换失败!"
);
}
}
item
.
put
(
"equipment_index_name"
,
stateMap
.
get
(
"equipment_index_name"
));
}
else
{
item
.
put
(
"update_time"
,
stateMap
.
get
(
"update_date"
));
item
.
put
(
"equipment_index_name"
,
"无信号"
);
}
catch
(
ParseException
e
)
{
item
.
put
(
"update_time"
,
false
);
throw
new
BadRequest
(
"稳压泵最新指标时间转换失败!"
);
}
}
}
else
{
//稳压泵当前状态 无告警并且启动时长小于5分钟为正常
item
.
put
(
"equipment_index_name"
,
"无信号"
);
item
.
put
(
"stateDesc"
,
Integer
.
parseInt
(
String
.
valueOf
(
item
.
get
(
"isAlarm"
)))
==
0
&&
time
?
PressurePumpRelateEnum
.
PIPE_PRESSURE_NORMAL_STATUS
.
getValue
()
:
PressurePumpRelateEnum
.
PIPE_PRESSURE_ABNORMAL_STATUS
.
getValue
());
item
.
put
(
"update_time"
,
false
);
}
}
//稳压泵当前状态 无告警并且启动时长小于5分钟为正常
item
.
put
(
"stateDesc"
,
Integer
.
parseInt
(
String
.
valueOf
(
item
.
get
(
"isAlarm"
)))
==
0
&&
time
?
PressurePumpRelateEnum
.
PIPE_PRESSURE_NORMAL_STATUS
.
getValue
()
:
PressurePumpRelateEnum
.
PIPE_PRESSURE_ABNORMAL_STATUS
.
getValue
());
}
List
<
Map
>
infoList
=
pressurePumpService
.
getNameKeyInfoList
(
PressurePumpRelateEnum
.
PRESSURE_PUMP
.
getValue
());
if
(!
CollectionUtils
.
isEmpty
(
infoList
))
{
// 获取redis稳压泵缓存数据,默认JSON配置最近4小时
// 获取redis稳压泵缓存数据,默认JSON配置最近4小时
List
<
IotDataVO
>
DataList
=
pressurePumpService
.
getDataToRedis
(
PressurePumpRelateEnum
.
PRESSURE_PUMP
.
getValue
(),
pressurePumpStart
,
null
);
List
<
IotDataVO
>
DataList
=
pressurePumpService
.
getDataToRedis
(
PressurePumpRelateEnum
.
PRESSURE_PUMP
.
getValue
(),
pressurePumpStart
,
null
);
if
(
CollectionUtils
.
isEmpty
(
DataList
)){
if
(
CollectionUtils
.
isEmpty
(
DataList
)){
//从influxdb中获取最近一次启停间隔
//从influxdb中获取最近一次启停间隔
String
top
=
infoList
.
get
(
0
).
get
(
"top"
).
toString
();
List
<
Map
<
String
,
String
>>
iotDataList
=
pressurePumpService
.
getIotTopSingleField
(
top
,
prefix
,
null
,
null
,
pressurePumpStart
);
List
<
Map
<
String
,
String
>>
iotDataList
=
pressurePumpService
.
getIotTopSingleField
(
top
,
prefix
,
null
,
null
,
pressurePumpStart
);
iotDataList
.
stream
().
forEach
(
e
->
{
iotDataList
.
stream
().
forEach
(
e
->
{
try
{
try
{
IotDataVO
iotDataVO
=
(
IotDataVO
)
mapToObject
(
e
,
IotDataVO
.
class
);
IotDataVO
iotDataVO
=
(
IotDataVO
)
pressurePumpService
.
mapToObject
(
e
,
IotDataVO
.
class
);
DataList
.
add
(
iotDataVO
);
DataList
.
add
(
iotDataVO
);
}
catch
(
Exception
el
)
{
}
catch
(
Exception
el
)
{
throw
new
RuntimeException
();
throw
new
RuntimeException
();
}
}
});
});
}
}
interval
=
pressurePumpService
.
getAllPressurePumpStartStopInterval
(
DataList
,
nowStrLong
);
interval
=
pressurePumpService
.
getAllPressurePumpStartStopInterval
(
DataList
,
dataListFilterTrue
,
dataListFilterFalse
,
nowStrLong
);
double
finalDiffMinute
=
(
double
)
interval
;
pressurePumpInfo
.
getRecords
().
stream
(
).
map
(
item
->
{
item
.
put
(
"startAndStopInterval"
,
finalDiffMinute
);
if
(
finalDiffMinute
>
Long
.
valueOf
(
PressurePumpRelateEnum
.
START_FIVE
.
getValue
()))
{
item
.
put
(
"generalState"
,
PressurePumpRelateEnum
.
PIPE_PRESSURE_ABNORMAL_STATUS
.
getValue
());
}
else
{
item
.
put
(
"generalState"
,
PressurePumpRelateEnum
.
PIPE_PRESSURE_NORMAL_STATUS
.
getValue
());
}
item
.
put
(
"nameKey"
,
pressurePumpStart
);
return
item
;
}).
collect
(
Collectors
.
toList
());
List
<
Map
<
String
,
Object
>>
records
=
pressurePumpInfo
.
getRecords
();
records
.
sort
((
t1
,
t2
)
->
t1
.
get
(
"stateDesc"
).
toString
().
compareTo
(
t2
.
get
(
"stateDesc"
).
toString
()));
pressurePumpInfo
.
setRecords
(
records
);
}
}
double
finalDiffMinute
=
(
double
)
interval
;
pressurePumpInfo
.
getRecords
().
stream
(
).
map
(
item
->
{
item
.
put
(
"startAndStopInterval"
,
finalDiffMinute
);
if
(
finalDiffMinute
>
Long
.
valueOf
(
PressurePumpRelateEnum
.
START_FIVE
.
getValue
()))
{
item
.
put
(
"generalState"
,
PressurePumpRelateEnum
.
PIPE_PRESSURE_ABNORMAL_STATUS
.
getValue
());
}
else
{
item
.
put
(
"generalState"
,
PressurePumpRelateEnum
.
PIPE_PRESSURE_NORMAL_STATUS
.
getValue
());
}
item
.
put
(
"nameKey"
,
pressurePumpStart
);
return
item
;
}).
collect
(
Collectors
.
toList
());
List
<
Map
<
String
,
Object
>>
records
=
pressurePumpInfo
.
getRecords
();
records
.
sort
((
t1
,
t2
)
->
t1
.
get
(
"stateDesc"
).
toString
().
compareTo
(
t2
.
get
(
"stateDesc"
).
toString
()));
pressurePumpInfo
.
setRecords
(
records
);
return
pressurePumpInfo
;
return
pressurePumpInfo
;
}
}
/**
* map 转化为对象
* @param map 需要转化的参数
* @param aClass 要转化成的对象
* @return 转化成功的对象
* @throws IllegalAccessException 非法访问异常
* @throws InstantiationException 实例化异常
*/
public
Object
mapToObject
(
Map
<
String
,
String
>
map
,
Class
<?>
aClass
)
throws
IllegalAccessException
,
InstantiationException
{
if
(
null
==
map
||
map
.
size
()<=
0
){
return
null
;
}
Object
o
=
aClass
.
newInstance
();
Field
[]
declaredFields
=
o
.
getClass
().
getDeclaredFields
();
for
(
Field
field
:
declaredFields
)
{
int
modifiers
=
field
.
getModifiers
();
if
(
Modifier
.
isStatic
(
modifiers
)
||
Modifier
.
isFinal
(
modifiers
)){
continue
;
}
// (此处如果不设置 无法获取对象的私有属性)
field
.
setAccessible
(
true
);
if
(
"key"
.
equals
(
field
.
getName
())){
field
.
set
(
o
,
pressurePumpStart
);
}
else
if
(
"value"
.
equals
(
field
.
getName
())){
field
.
set
(
o
,
map
.
get
(
pressurePumpStart
));
}
else
{
field
.
set
(
o
,
map
.
get
(
field
.
getName
()));
}
}
return
o
;
}
}
}
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