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
b0928098
Commit
b0928098
authored
Feb 17, 2023
by
高建强
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
item:稳压泵指标统计细化重构提交
parent
ebe0d4ea
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
651 additions
and
438 deletions
+651
-438
DateUtils.java
...ava/com/yeejoin/amos/boot/biz/common/utils/DateUtils.java
+3
-2
PressurePumpAnalysisEnum.java
...in/equipmanage/common/enums/PressurePumpAnalysisEnum.java
+5
-5
PressurePumpRelateEnum.java
...join/equipmanage/common/enums/PressurePumpRelateEnum.java
+2
-0
DateUtils.java
.../java/com/yeejoin/equipmanage/common/utils/DateUtils.java
+0
-128
SupervisionConfigureController.java
...quipmanage/controller/SupervisionConfigureController.java
+2
-2
IotFeign.java
...src/main/java/com/yeejoin/equipmanage/fegin/IotFeign.java
+0
-3
IPressurePumpService.java
...com/yeejoin/equipmanage/service/IPressurePumpService.java
+50
-8
EmergencyServiceImpl.java
...eejoin/equipmanage/service/impl/EmergencyServiceImpl.java
+399
-255
MqttReceiveServiceImpl.java
...join/equipmanage/service/impl/MqttReceiveServiceImpl.java
+1
-1
PressurePumpServiceImpl.java
...oin/equipmanage/service/impl/PressurePumpServiceImpl.java
+184
-32
nameKeyInfo.json
...oot-system-equip/src/main/resources/json/nameKeyInfo.json
+3
-1
EquipmentSpecificMapper.xml
...uip/src/main/resources/mapper/EquipmentSpecificMapper.xml
+2
-1
No files found.
amos-boot-biz-common/src/main/java/com/yeejoin/amos/boot/biz/common/utils/DateUtils.java
View file @
b0928098
...
...
@@ -27,6 +27,7 @@ public class DateUtils {
public
static
final
String
MINUTE_ONLY_PATTERN
=
"mm"
;
public
static
final
String
HOUR_ONLY_PATTERN
=
"HH"
;
public
static
final
String
MONTH_DAY_HOUR_PATTERN
=
"MM-dd HH"
;
public
static
final
String
MONTH_DAY_HOUR_MINUTE_PATTERN
=
"MM-dd HH:mm"
;
public
static
final
String
DATE_PATTERN_NUM
=
"yyyyMMdd"
;
public
static
final
String
CHN_DATE_PATTERN_YEAR
=
"yyyy年"
;
public
static
final
String
CHN_DATE_PATTERN_MONTH
=
"MM月"
;
...
...
@@ -933,7 +934,7 @@ public class DateUtils {
* @param pattern 时间格式
* @return 秒数
*/
public
static
Long
getDurationSec
c
onds
(
String
startTime
,
String
endTime
,
String
pattern
)
{
public
static
Long
getDurationSeconds
(
String
startTime
,
String
endTime
,
String
pattern
)
{
final
LocalDateTime
start
=
LocalDateTime
.
parse
(
startTime
,
DateTimeFormatter
.
ofPattern
(
pattern
));
final
LocalDateTime
end
=
LocalDateTime
.
parse
(
endTime
,
DateTimeFormatter
.
ofPattern
(
pattern
));
return
Duration
.
between
(
start
,
end
).
getSeconds
();
...
...
@@ -947,7 +948,7 @@ public class DateUtils {
* @param pattern 时间格式
* @return 秒数
*/
public
static
Long
getDurationSec
c
onds
(
Date
startTime
,
Date
endTime
,
String
pattern
)
{
public
static
Long
getDurationSeconds
(
Date
startTime
,
Date
endTime
,
String
pattern
)
{
final
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
pattern
);
final
LocalDateTime
start
=
LocalDateTime
.
parse
(
sdf
.
format
(
startTime
),
DateTimeFormatter
.
ofPattern
(
pattern
));
final
LocalDateTime
end
=
LocalDateTime
.
parse
(
sdf
.
format
(
endTime
),
DateTimeFormatter
.
ofPattern
(
pattern
));
...
...
amos-boot-module/amos-boot-module-api/amos-boot-module-equip-api/src/main/java/com/yeejoin/equipmanage/common/enums/PressurePumpAnalysisEnum.java
View file @
b0928098
...
...
@@ -8,11 +8,11 @@ package com.yeejoin.equipmanage.common.enums;
public
enum
PressurePumpAnalysisEnum
{
PRESSURE_PUMP_FAULT
(
"1"
,
"1"
,
"稳压泵是否故障"
,
"无"
,
""
),
PRESSURE_PUMP_INTERVAL
(
"2"
,
"2"
,
"最近一次启停间隔"
,
"
无
"
,
"分钟"
),
PRESSURE_PUMP_DURATION
(
"3"
,
"3"
,
"最近一次启动时长"
,
"
无
"
,
"分钟"
),
PRESSURE_PUMP_HALF
(
"4"
,
"4"
,
"半小时启动"
,
"
无
"
,
"次"
),
PRESSURE_PUMP_TWO
(
"5"
,
"5"
,
"2小时启动"
,
"
无
"
,
"次"
),
PRESSURE_PUMP_PIPE
(
"6"
,
"6"
,
"管网压力"
,
"
无
"
,
""
);
PRESSURE_PUMP_INTERVAL
(
"2"
,
"2"
,
"最近一次启停间隔"
,
"
0
"
,
"分钟"
),
PRESSURE_PUMP_DURATION
(
"3"
,
"3"
,
"最近一次启动时长"
,
"
0
"
,
"分钟"
),
PRESSURE_PUMP_HALF
(
"4"
,
"4"
,
"半小时启动"
,
"
0
"
,
"次"
),
PRESSURE_PUMP_TWO
(
"5"
,
"5"
,
"2小时启动"
,
"
0
"
,
"次"
),
PRESSURE_PUMP_PIPE
(
"6"
,
"6"
,
"管网压力"
,
"
正常
"
,
""
);
private
final
String
key
;
private
final
String
code
;
...
...
amos-boot-module/amos-boot-module-api/amos-boot-module-equip-api/src/main/java/com/yeejoin/equipmanage/common/enums/PressurePumpRelateEnum.java
View file @
b0928098
...
...
@@ -19,6 +19,8 @@ public enum PressurePumpRelateEnum {
PRESSURE_PUMP_START_BEFORE_MINUTE
(
"-5"
,
"稳压泵启泵前分钟数"
),
PIPE_PRESSURE_NORMAL_STATUS
(
"正常"
,
"稳压泵管网压力正常状态"
),
PIPE_PRESSURE_ABNORMAL_STATUS
(
"异常"
,
"稳压泵管网压力异常状态"
),
START
(
"1"
,
"稳压泵启动"
),
STOP
(
"0"
,
"稳压泵停止"
),
UN_CLEAN_TIME
(
"false"
,
"未消除"
);
private
final
String
value
;
...
...
amos-boot-module/amos-boot-module-api/amos-boot-module-equip-api/src/main/java/com/yeejoin/equipmanage/common/utils/DateUtils.java
View file @
b0928098
...
...
@@ -7,9 +7,6 @@ import java.text.DateFormat;
import
java.text.ParseException
;
import
java.text.ParsePosition
;
import
java.text.SimpleDateFormat
;
import
java.time.Duration
;
import
java.time.LocalDateTime
;
import
java.time.format.DateTimeFormatter
;
import
java.util.*
;
/**
...
...
@@ -27,7 +24,6 @@ public class DateUtils {
public
static
final
String
YEAR_PATTERN
=
"yyyy"
;
public
static
final
String
MINUTE_ONLY_PATTERN
=
"mm"
;
public
static
final
String
HOUR_ONLY_PATTERN
=
"HH"
;
public
static
final
String
MONTH_DAY_HOUR_PATTERN
=
"MM-dd HH"
;
public
static
final
String
DATE_TIME_T_PATTERN
=
"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
;
public
static
final
String
[]
TWENTY_FOUR
=
new
String
[]{
" 00:00:00"
,
" 01:00:00"
,
" 02:00:00"
,
" 03:00:00"
,
" 04:00:00"
,
" 05:00:00"
,
" 06:00:00"
,
" 07:00:00"
,
" 08:00:00"
,
" 09:00:00"
,
" 10:00:00"
,
" 11:00:00"
,
" 12:00:00"
,
" 13:00:00"
,
...
...
@@ -92,18 +88,6 @@ public class DateUtils {
}
/**
* 将字符换转换为日期
* @param date
* @param pattern
* @return
* @throws ParseException
*/
public
static
Date
convertStrToDate
(
String
date
,
String
pattern
)
throws
ParseException
{
SimpleDateFormat
formatter
=
new
SimpleDateFormat
(
pattern
);
return
formatter
.
parse
(
date
);
}
/**
* 获取当前时间任意
* @return
*/
...
...
@@ -1031,118 +1015,6 @@ public class DateUtils {
return
now
;
}
public
static
List
<
String
>
getTimeStrListByStartAndEnd
(
String
startTime
,
String
endTime
,
String
pattern
)
{
try
{
List
<
String
>
list
=
new
ArrayList
<>();
Date
startDate
=
convertStrToDate
(
startTime
,
DATE_TIME_PATTERN
);
Date
endDate
=
convertStrToDate
(
endTime
,
DATE_TIME_PATTERN
);
list
.
add
(
convertDateToString
(
startDate
,
pattern
));
Date
date
=
startDate
;
while
(
true
)
{
if
(
MONTH_DAY_HOUR_PATTERN
.
equals
(
pattern
))
{
date
=
dateAddMinutes
(
date
,
60
);
}
else
{
date
=
dateAddMinutes
(
date
,
1
);
}
if
(
dateCompare
(
endDate
,
date
)
==
1
)
{
list
.
add
(
convertDateToString
(
date
,
pattern
));
}
else
{
break
;
}
}
return
list
;
}
catch
(
ParseException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
/**
* 获取两个时间段之间的秒数
*
* @param startTime 开始时间
* @param endTime 结束时间
* @param pattern 时间格式
* @return 秒数
*/
public
static
Long
getDurationSecconds
(
String
startTime
,
String
endTime
,
String
pattern
)
{
final
LocalDateTime
start
=
LocalDateTime
.
parse
(
startTime
,
DateTimeFormatter
.
ofPattern
(
pattern
));
final
LocalDateTime
end
=
LocalDateTime
.
parse
(
endTime
,
DateTimeFormatter
.
ofPattern
(
pattern
));
return
Duration
.
between
(
start
,
end
).
getSeconds
();
}
/**
* 获取两个时间段之间的秒数
*
* @param startTime 开始时间
* @param endTime 结束时间
* @param pattern 时间格式
* @return 秒数
*/
public
static
Long
getDurationSecconds
(
Date
startTime
,
Date
endTime
,
String
pattern
)
{
final
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
pattern
);
final
LocalDateTime
start
=
LocalDateTime
.
parse
(
sdf
.
format
(
startTime
),
DateTimeFormatter
.
ofPattern
(
pattern
));
final
LocalDateTime
end
=
LocalDateTime
.
parse
(
sdf
.
format
(
endTime
),
DateTimeFormatter
.
ofPattern
(
pattern
));
return
Duration
.
between
(
start
,
end
).
getSeconds
();
}
/**
* 获取两个时间段之间的分钟数
*
* @param startTime 开始时间
* @param endTime 结束时间
* @param pattern 时间格式
* @return 分钟数
*/
public
static
Long
getDurationMinutes
(
String
startTime
,
String
endTime
,
String
pattern
)
{
final
LocalDateTime
start
=
LocalDateTime
.
parse
(
startTime
,
DateTimeFormatter
.
ofPattern
(
pattern
));
final
LocalDateTime
end
=
LocalDateTime
.
parse
(
endTime
,
DateTimeFormatter
.
ofPattern
(
pattern
));
return
Duration
.
between
(
start
,
end
).
toMinutes
();
}
/**
* 获取两个时间段之间的分钟数
*
* @param startTime 开始时间
* @param endTime 结束时间
* @param pattern 时间格式
* @return 分钟数
*/
public
static
Long
getDurationMinutes
(
Date
startTime
,
Date
endTime
,
String
pattern
)
{
final
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
pattern
);
final
LocalDateTime
start
=
LocalDateTime
.
parse
(
sdf
.
format
(
startTime
),
DateTimeFormatter
.
ofPattern
(
pattern
));
final
LocalDateTime
end
=
LocalDateTime
.
parse
(
sdf
.
format
(
endTime
),
DateTimeFormatter
.
ofPattern
(
pattern
));
return
Duration
.
between
(
start
,
end
).
toMinutes
();
}
/**
* 获取两个时间段之间的小时数
*
* @param startTime 开始时间
* @param endTime 结束时间
* @param pattern 时间格式
* @return 小时
*/
public
static
Long
getDurationHours
(
String
startTime
,
String
endTime
,
String
pattern
)
{
final
LocalDateTime
start
=
LocalDateTime
.
parse
(
startTime
,
DateTimeFormatter
.
ofPattern
(
pattern
));
final
LocalDateTime
end
=
LocalDateTime
.
parse
(
endTime
,
DateTimeFormatter
.
ofPattern
(
pattern
));
return
Duration
.
between
(
start
,
end
).
toHours
();
}
/**
* 获取两个时间段之间的小时数
*
* @param startTime 开始时间
* @param endTime 结束时间
* @param pattern 时间格式
* @return 小时
*/
public
static
Long
getDurationHours
(
Date
startTime
,
Date
endTime
,
String
pattern
)
{
final
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
pattern
);
final
LocalDateTime
start
=
LocalDateTime
.
parse
(
sdf
.
format
(
startTime
),
DateTimeFormatter
.
ofPattern
(
pattern
));
final
LocalDateTime
end
=
LocalDateTime
.
parse
(
sdf
.
format
(
endTime
),
DateTimeFormatter
.
ofPattern
(
pattern
));
return
Duration
.
between
(
start
,
end
).
toHours
();
}
public
static
Date
getBeginDayOfWeek
()
{
Date
date
=
new
Date
();
if
(
date
==
null
)
{
...
...
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/controller/SupervisionConfigureController.java
View file @
b0928098
...
...
@@ -325,8 +325,8 @@ public class SupervisionConfigureController extends AbstractBaseController {
twoHourEntity
=
iotFeign
.
selectList
(
getAppKey
(),
getProduct
(),
getToken
(),
two
,
nowStrLong
,
prefix
,
suffix
,
pressurePumpStart
);
fourHourEntity
=
iotFeign
.
selectList
(
getAppKey
(),
getProduct
(),
getToken
(),
four
,
nowStrLong
,
prefix
,
suffix
,
pressurePumpStart
);
oneHourEntity
=
iotFeign
.
selectList
(
getAppKey
(),
getProduct
(),
getToken
(),
one
,
nowStrLong
,
prefix
,
suffix
,
pressurePumpStart
);
start
=
iotFeign
.
topSingleField
(
getAppKey
(),
getProduct
(),
getToken
(),
"1"
,
prefix
,
suffix
,
"true"
,
pressurePumpStart
);
stop
=
iotFeign
.
topSingleField
(
getAppKey
(),
getProduct
(),
getToken
(),
"1"
,
prefix
,
suffix
,
"false"
,
pressurePumpStart
);
start
=
iotFeign
.
topSingleField
(
"1"
,
prefix
,
suffix
,
"true"
,
pressurePumpStart
);
stop
=
iotFeign
.
topSingleField
(
"1"
,
prefix
,
suffix
,
"false"
,
pressurePumpStart
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
...
...
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/fegin/IotFeign.java
View file @
b0928098
...
...
@@ -53,9 +53,6 @@ public interface IotFeign {
@RequestMapping
(
value
=
"v1/livedata/common/top/single-field"
,
method
=
RequestMethod
.
GET
,
consumes
=
"application/json"
)
ResponseModel
topSingleField
(
@RequestHeader
(
"appKey"
)
String
appKey
,
@RequestHeader
(
"product"
)
String
product
,
@RequestHeader
(
"token"
)
String
token
,
@RequestParam
(
value
=
"top"
)
String
top
,
@RequestParam
(
value
=
"productKey"
)
String
productKey
,
@RequestParam
(
required
=
false
,
value
=
"deviceName"
)
String
deviceName
,
...
...
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/service/IPressurePumpService.java
View file @
b0928098
...
...
@@ -15,17 +15,20 @@ public interface IPressurePumpService {
/**
* redis缓存物联采集数据,内部读取JSON配置指定有效期
*
@param message
*
* @param iotDatalist
* @param topic
*/
void
saveDataToRedis
(
List
<
IotDataVO
>
iotDatalist
);
void
saveDataToRedis
(
List
<
IotDataVO
>
iotDatalist
,
String
topic
);
/**
* 根据key,模糊查询所有的redis缓存数据
* @param key
* 根据nameKey,模糊查询所有的redis缓存数据
* @param infoCode
* @param nameKey
* @param iotCode
* @return
*/
List
<
IotDataVO
>
getDataToRedis
(
String
key
);
List
<
IotDataVO
>
getDataToRedis
(
String
infoCode
,
String
nameKey
,
String
iotCode
);
/**
* 获取指标配置JSON信息集合
...
...
@@ -37,7 +40,7 @@ public interface IPressurePumpService {
* 获取所有稳压泵最近一次启停间隔,min
* @return
*/
long
getAllPressurePumpStartStopInterval
(
List
<
IotDataVO
>
redisDataList
,
String
nowStrLong
,
String
bizOrgCode
);
long
getAllPressurePumpStartStopInterval
(
List
<
IotDataVO
>
redisDataList
,
List
<
Map
<
String
,
String
>>
iotDataList
,
String
nowStrLong
,
String
bizOrgCode
);
/**
* 获取稳压泵一定时间内启动频率或次数
...
...
@@ -50,21 +53,60 @@ public interface IPressurePumpService {
/**
* 获取稳压泵最近一次启停时长,min
*
* @param redisDataList
* @param iotDataList
* @param nowStrLong
* @param bizOrgCode
* @return
*/
long
getAllPressurePumpStartStopDuration
(
List
<
IotDataVO
>
redisDataList
,
String
nowStrLong
,
String
bizOrgCode
);
long
getAllPressurePumpStartStopDuration
(
List
<
IotDataVO
>
redisDataList
,
List
<
Map
<
String
,
String
>>
iotDataList
,
String
nowStrLong
,
String
bizOrgCode
);
/**
* 获取稳压泵指定启泵前 minutes 分钟,管网压力差绝对值
*
* @param redisDataList
* @param redisDataPipeList
* @param iotDataList
* @param iotDataPipeList
* @param nowStrLong
* @param minutes
* @return
*/
double
getAllPressurePumpPipePressureDiff
(
List
<
IotDataVO
>
redisDataList
,
List
<
IotDataVO
>
redisDataPipeList
,
String
nowStrLong
,
String
minutes
);
double
getAllPressurePumpPipePressureDiff
(
List
<
IotDataVO
>
redisDataList
,
List
<
IotDataVO
>
redisDataPipeList
,
List
<
Map
<
String
,
String
>>
iotDataList
,
List
<
Map
<
String
,
String
>>
iotDataPipeList
,
String
nowStrLong
,
String
minutes
);
/**
* 根据指标,获取物联top数据,influxdb
* @param top
* @param productKey
* @param deviceName
* @param key
* @param fieldKey
* @return
*/
List
<
Map
<
String
,
String
>>
getIotTopSingleField
(
String
top
,
String
productKey
,
String
deviceName
,
String
key
,
String
fieldKey
);
/**
* 根据时间范围,获取redis指定指标或指定指标设备的缓存数据
* @param infoCode
* @param nameKey
* @param iotCode
* @param startDate
* @param endDate
* @return
*/
List
<
IotDataVO
>
getDataToRedisByDateBetween
(
String
infoCode
,
String
nameKey
,
String
iotCode
,
Date
startDate
,
Date
endDate
);
/**
* 根据时间范围获取iot物联数据集合
* @param startTime
* @param endTime
* @param prefix
* @param suffix
* @param o
* @param pressurePumpStart
* @return
*/
List
<
Map
<
String
,
String
>>
getIotCommonListData
(
String
startTime
,
String
endTime
,
String
prefix
,
String
suffix
,
String
key
,
String
fieldKey
);
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/service/impl/EmergencyServiceImpl.java
View file @
b0928098
...
...
@@ -3,11 +3,11 @@ package com.yeejoin.equipmanage.service.impl;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.yeejoin.amos.boot.biz.common.utils.DateUtils
;
import
com.yeejoin.equipmanage.common.entity.EquipmentSpecificAlarmLog
;
import
com.yeejoin.equipmanage.common.enums.IndexStatusEnum
;
import
com.yeejoin.equipmanage.common.enums.PressurePumpAnalysisEnum
;
import
com.yeejoin.equipmanage.common.enums.PressurePumpRelateEnum
;
import
com.yeejoin.amos.boot.biz.common.utils.DateUtils
;
import
com.yeejoin.equipmanage.common.utils.StringUtil
;
import
com.yeejoin.equipmanage.common.utils.UnitTransformUtil
;
import
com.yeejoin.equipmanage.common.vo.IotDataVO
;
...
...
@@ -17,6 +17,7 @@ import com.yeejoin.equipmanage.service.IEmergencyService;
import
com.yeejoin.equipmanage.service.IEquipmentSpecificAlarmLogService
;
import
com.yeejoin.equipmanage.service.IEquipmentSpecificSerivce
;
import
com.yeejoin.equipmanage.service.IPressurePumpService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.compress.utils.Lists
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
...
...
@@ -24,9 +25,7 @@ import org.springframework.stereotype.Service;
import
org.springframework.util.CollectionUtils
;
import
org.typroject.tyboot.core.restful.utils.ResponseModel
;
import
java.text.ParseException
;
import
java.util.*
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
java.util.stream.Collectors
;
/**
...
...
@@ -35,6 +34,7 @@ import java.util.stream.Collectors;
*
*/
@Service
@Slf4j
public
class
EmergencyServiceImpl
implements
IEmergencyService
{
...
...
@@ -227,8 +227,8 @@ public class EmergencyServiceImpl implements IEmergencyService {
return
emergencyMapper
.
getStockEquipStatistics
();
}
//
@Override
public
List
<
Map
<
String
,
Object
>>
getPressurePumpDiagnosticAnalysis
1
(
String
equipmentCode
,
String
nameKeys
,
String
fieldKey
,
String
bizOrgCode
,
String
appKey
,
String
product
,
String
token
)
{
@Override
public
List
<
Map
<
String
,
Object
>>
getPressurePumpDiagnosticAnalysis
(
String
equipmentCode1
,
String
nameKeys
,
String
fieldKey
,
String
bizOrgCode
,
String
appKey
,
String
product
,
String
token
)
{
PressurePumpAnalysisEnum
[]
values
=
PressurePumpAnalysisEnum
.
values
();
List
<
Map
<
String
,
Object
>>
list
=
new
ArrayList
<>();
for
(
PressurePumpAnalysisEnum
value
:
values
)
{
...
...
@@ -240,277 +240,421 @@ public class EmergencyServiceImpl implements IEmergencyService {
map
.
put
(
"unit"
,
value
.
getUnit
());
list
.
add
(
map
);
}
// 获取redis稳压泵缓存数据,默认JSON配置最近4小时
List
<
IotDataVO
>
redisDataList
=
pressurePumpService
.
getDataToRedis
(
pressurePumpStart
);
List
<
IotDataVO
>
redisDataPipeList
=
pressurePumpService
.
getDataToRedis
(
pressurePumpPipePressure
);
String
nowStrLong
=
DateUtils
.
getDateNowString
();
Date
dateNow
=
DateUtils
.
getDateNow
();
// 1. 判断稳压泵整体是否故障
List
<
EquipmentSpecificAlarmLog
>
alarmLogList
=
equipmentSpecificAlarmLogService
.
getAlarmLogInfoList
(
equipmentCode
,
nameKeys
,
PressurePumpRelateEnum
.
IOT_INDEX_VALUE_TRUE
.
getValue
(),
PressurePumpRelateEnum
.
UN_CLEAN_TIME
.
getValue
(),
bizOrgCode
);
list
.
get
(
0
).
put
(
"value"
,
CollectionUtils
.
isEmpty
(
alarmLogList
)
?
PressurePumpRelateEnum
.
NOT_FAULT
.
getValue
()
:
PressurePumpRelateEnum
.
FAULT
.
getValue
());
// 2. 最近一次启停间隔
long
interval
=
pressurePumpService
.
getAllPressurePumpStartStopInterval
(
redisDataList
,
nowStrLong
,
bizOrgCode
);
list
.
get
(
1
).
put
(
"value"
,
interval
);
// 3. 最近一次启动时长s
long
duration
=
pressurePumpService
.
getAllPressurePumpStartStopDuration
(
redisDataList
,
nowStrLong
,
bizOrgCode
);
list
.
get
(
1
).
put
(
"value"
,
duration
);
// 4. 半小时启动
int
halfFrequency
=
pressurePumpService
.
getAllPressurePumpStartFrequency
(
Double
.
parseDouble
(
PressurePumpRelateEnum
.
HALF_HOUR
.
getValue
()),
dateNow
);
list
.
get
(
3
).
put
(
"value"
,
interval
);
// 5. 2小时启动
int
twoFrequency
=
pressurePumpService
.
getAllPressurePumpStartFrequency
(
Double
.
parseDouble
(
PressurePumpRelateEnum
.
TWO_HOUR
.
getValue
()),
dateNow
);
list
.
get
(
4
).
put
(
"value"
,
interval
);
// 6. 管网压力状态
double
pressureDiff
=
pressurePumpService
.
getAllPressurePumpPipePressureDiff
(
redisDataList
,
redisDataPipeList
,
nowStrLong
,
PressurePumpRelateEnum
.
PRESSURE_PUMP_START_BEFORE_MINUTE
.
getValue
());
list
.
get
(
5
).
put
(
"value"
,
pressureDiff
>
Double
.
parseDouble
(
PressurePumpRelateEnum
.
PIPE_PRESSURE_DIFF
.
getValue
())
?
PressurePumpRelateEnum
.
PIPE_PRESSURE_ABNORMAL_STATUS
.
getValue
()
:
PressurePumpRelateEnum
.
PIPE_PRESSURE_NORMAL_STATUS
.
getValue
());
// 从 json 配置文件获取配置信息
List
<
Map
>
infoList
=
pressurePumpService
.
getNameKeyInfoList
(
PressurePumpRelateEnum
.
PRESSURE_PUMP
.
getValue
());
if
(!
CollectionUtils
.
isEmpty
(
infoList
))
{
Map
map
=
infoList
.
get
(
0
);
String
equipmentCode
=
map
.
get
(
"equipmentCode"
).
toString
();
// 获取redis稳压泵缓存数据,默认JSON配置最近4小时
List
<
IotDataVO
>
redisDataList
=
pressurePumpService
.
getDataToRedis
(
PressurePumpRelateEnum
.
PRESSURE_PUMP
.
getValue
(),
pressurePumpStart
,
null
);
List
<
IotDataVO
>
redisDataPipeList
=
pressurePumpService
.
getDataToRedis
(
PressurePumpRelateEnum
.
PRESSURE_PUMP
.
getValue
(),
pressurePumpPipePressure
,
null
);
String
nowStrLong
=
DateUtils
.
getDateNowString
();
Date
dateNow
=
DateUtils
.
getDateNow
();
// 1. 判断稳压泵整体是否故障
List
<
EquipmentSpecificAlarmLog
>
alarmLogList
=
equipmentSpecificAlarmLogService
.
getAlarmLogInfoList
(
equipmentCode
,
nameKeys
,
PressurePumpRelateEnum
.
IOT_INDEX_VALUE_TRUE
.
getValue
(),
PressurePumpRelateEnum
.
UN_CLEAN_TIME
.
getValue
(),
bizOrgCode
);
list
.
get
(
0
).
put
(
"value"
,
CollectionUtils
.
isEmpty
(
alarmLogList
)
?
PressurePumpRelateEnum
.
NOT_FAULT
.
getValue
()
:
PressurePumpRelateEnum
.
FAULT
.
getValue
());
long
interval
=
0
;
long
duration
=
0
;
double
pressureDiff
=
0.0
;
if
(!
CollectionUtils
.
isEmpty
(
redisDataList
))
{
// 2. 最近一次启停间隔
interval
=
pressurePumpService
.
getAllPressurePumpStartStopInterval
(
redisDataList
,
null
,
nowStrLong
,
bizOrgCode
);
// 3. 最近一次启动时长
duration
=
pressurePumpService
.
getAllPressurePumpStartStopDuration
(
redisDataList
,
null
,
nowStrLong
,
bizOrgCode
);
// 6. 管网压力状态
pressureDiff
=
pressurePumpService
.
getAllPressurePumpPipePressureDiff
(
redisDataList
,
redisDataPipeList
,
null
,
null
,
nowStrLong
,
PressurePumpRelateEnum
.
PRESSURE_PUMP_START_BEFORE_MINUTE
.
getValue
());
}
else
{
String
top
=
map
.
get
(
"top"
).
toString
();
// 通过 equipmentCode 获取装备
List
<
Map
<
String
,
Object
>>
pumpInfoList
=
equipmentSpecificSerivce
.
getFirePumpInfoEQ
(
equipmentCode
,
bizOrgCode
);
if
(!
CollectionUtils
.
isEmpty
(
pumpInfoList
))
{
String
iotCode
=
pumpInfoList
.
get
(
0
).
get
(
"iotCode"
).
toString
();
if
(
StringUtil
.
isNotEmpty
(
iotCode
))
{
String
prefix
=
iotCode
.
substring
(
0
,
8
);
// 获取物联稳压泵启动 top 数据
List
<
Map
<
String
,
String
>>
iotDataList
=
pressurePumpService
.
getIotTopSingleField
(
top
,
prefix
,
null
,
null
,
pressurePumpStart
);
// 获取物联稳压泵管网压力 top 数据
List
<
Map
<
String
,
String
>>
iotDataPipeList
=
pressurePumpService
.
getIotTopSingleField
(
top
,
prefix
,
null
,
null
,
pressurePumpPipePressure
);
// 2. 最近一次启停间隔
interval
=
pressurePumpService
.
getAllPressurePumpStartStopInterval
(
null
,
iotDataList
,
nowStrLong
,
bizOrgCode
);
// 3. 最近一次启动时长
duration
=
pressurePumpService
.
getAllPressurePumpStartStopDuration
(
null
,
iotDataList
,
nowStrLong
,
bizOrgCode
);
// 6. 管网压力状态
pressureDiff
=
pressurePumpService
.
getAllPressurePumpPipePressureDiff
(
null
,
null
,
iotDataList
,
iotDataPipeList
,
nowStrLong
,
PressurePumpRelateEnum
.
PRESSURE_PUMP_START_BEFORE_MINUTE
.
getValue
());
}
}
}
// 2. 最近一次启停间隔
list
.
get
(
1
).
put
(
"value"
,
interval
);
// 3. 最近一次启动时长
list
.
get
(
2
).
put
(
"value"
,
duration
);
// 4. 半小时启动
int
halfFrequency
=
pressurePumpService
.
getAllPressurePumpStartFrequency
(
Double
.
parseDouble
(
PressurePumpRelateEnum
.
HALF_HOUR
.
getValue
()),
dateNow
);
list
.
get
(
3
).
put
(
"value"
,
halfFrequency
);
// 5. 2小时启动
int
twoFrequency
=
pressurePumpService
.
getAllPressurePumpStartFrequency
(
Double
.
parseDouble
(
PressurePumpRelateEnum
.
TWO_HOUR
.
getValue
()),
dateNow
);
list
.
get
(
4
).
put
(
"value"
,
twoFrequency
);
// 6. 管网压力状态
list
.
get
(
5
).
put
(
"value"
,
pressureDiff
>
Double
.
parseDouble
(
PressurePumpRelateEnum
.
PIPE_PRESSURE_DIFF
.
getValue
())
?
PressurePumpRelateEnum
.
PIPE_PRESSURE_ABNORMAL_STATUS
.
getValue
()
:
PressurePumpRelateEnum
.
PIPE_PRESSURE_NORMAL_STATUS
.
getValue
());
}
return
list
;
}
@Override
public
Map
<
String
,
Object
>
getPressurePumpStatusChart
(
String
equipmentCode
,
String
startTime
,
String
endTime
,
String
bizOrgCode
,
String
appKey
,
String
product
,
String
token
)
{
Map
<
String
,
Object
>
map
=
new
LinkedHashMap
<>();
// 获取稳压泵
List
<
Map
<
String
,
Object
>>
list
=
equipmentSpecificSerivce
.
getListByEquipmentCode
(
equipmentCode
,
bizOrgCode
);
// 获取各稳压泵数据,及时间戳
if
(!
CollectionUtils
.
isEmpty
(
list
))
{
// 获取查询时间范围内的时间戳
List
<
String
>
timeHourList
=
DateUtils
.
getTimeStrListByStartAndEnd
(
startTime
,
endTime
,
"MM-dd HH:mm"
);
Set
<
String
>
timeSet
=
new
LinkedHashSet
<>();
List
<
Map
<
String
,
Object
>>
yData
=
new
ArrayList
<>();
LinkedHashMap
<
String
,
List
<
Map
<
String
,
String
>>>
dataListMap
=
new
LinkedHashMap
<>();
list
.
forEach
(
x
->
{
Object
iotCode
=
x
.
get
(
"iotCode"
);
String
prefix
=
null
;
String
suffix
=
null
;
if
(
x
.
get
(
"iotCode"
)
!=
null
&&
iotCode
.
toString
().
length
()
>
8
)
{
prefix
=
iotCode
.
toString
().
substring
(
0
,
8
);
suffix
=
iotCode
.
toString
().
substring
(
8
);
try
{
ResponseModel
responseModel
=
iotFeign
.
selectListNew
(
prefix
,
suffix
,
startTime
,
endTime
,
null
,
pressurePumpStart
);
if
(
200
==
responseModel
.
getStatus
())
{
String
json
=
JSON
.
toJSONString
(
responseModel
.
getResult
());
List
<
Map
<
String
,
String
>>
dataList
=
(
List
<
Map
<
String
,
String
>>)
JSONArray
.
parse
(
json
);
if
(!
CollectionUtils
.
isEmpty
(
dataList
))
{
dataList
.
stream
().
filter
(
y
->
y
.
containsKey
(
"createdTime"
)).
forEach
(
z
->
timeSet
.
add
(
z
.
get
(
"createdTime"
)));
try
{
// 获取稳压泵
List
<
Map
<
String
,
Object
>>
list
=
equipmentSpecificSerivce
.
getListByEquipmentCode
(
equipmentCode
,
bizOrgCode
);
// 获取各稳压泵数据,及时间戳
if
(!
CollectionUtils
.
isEmpty
(
list
))
{
// 获取查询时间范围内的时间戳
List
<
String
>
timeHourList
=
DateUtils
.
getTimeStrListByStartAndEnd
(
startTime
,
endTime
,
DateUtils
.
MONTH_DAY_HOUR_MINUTE_PATTERN
);
Set
<
String
>
timeSet
=
new
LinkedHashSet
<>();
List
<
Map
<
String
,
Object
>>
yData
=
new
ArrayList
<>();
LinkedHashMap
<
String
,
List
<
Map
<
String
,
String
>>>
dataListMap
=
new
LinkedHashMap
<>();
for
(
Map
<
String
,
Object
>
x
:
list
)
{
Object
iotCode
=
x
.
get
(
"iotCode"
);
if
(
iotCode
!=
null
)
{
// 判断开始时间,是否在redis缓存有效期之内,是,redis获取数据,否则,iot获取数据
List
<
Map
>
infoList
=
pressurePumpService
.
getNameKeyInfoList
(
PressurePumpRelateEnum
.
PRESSURE_PUMP
.
getValue
());
if
(!
CollectionUtils
.
isEmpty
(
infoList
))
{
int
expire
=
Integer
.
parseInt
(
infoList
.
get
(
0
).
get
(
"expire"
).
toString
())
*
-
1
;
Date
dateNow
=
DateUtils
.
getDateNow
();
Date
beforeDate
=
DateUtils
.
dateAddSeconds
(
dateNow
,
expire
);
Date
startDate
=
DateUtils
.
convertStrToDate
(
startTime
,
DateUtils
.
DATE_TIME_PATTERN
);
Date
endDate
=
DateUtils
.
convertStrToDate
(
endTime
,
DateUtils
.
DATE_TIME_PATTERN
);
if
(
DateUtils
.
dateCompare
(
startDate
,
beforeDate
)
>=
0
)
{
// 获取redis稳压泵缓存数据,默认JSON配置最近4小时
List
<
IotDataVO
>
redisDataList
=
pressurePumpService
.
getDataToRedisByDateBetween
(
PressurePumpRelateEnum
.
PRESSURE_PUMP
.
getValue
(),
pressurePumpStart
,
iotCode
.
toString
(),
startDate
,
endDate
);
if
(!
CollectionUtils
.
isEmpty
(
redisDataList
))
{
List
<
Map
<
String
,
String
>>
dataList
=
new
ArrayList
<>();
redisDataList
.
forEach
(
y
->
{
timeSet
.
add
(
y
.
getCreatedTime
());
Map
<
String
,
String
>
xMap
=
new
HashMap
<>();
xMap
.
put
(
pressurePumpStart
,
y
.
getValue
().
toString
());
xMap
.
put
(
"createdTime"
,
y
.
getCreatedTime
());
dataList
.
add
(
xMap
);
});
dataListMap
.
put
(
iotCode
.
toString
(),
dataList
);
}
}
else
if
(
iotCode
.
toString
().
length
()
>
8
)
{
// iot获取数据
String
prefix
=
iotCode
.
toString
().
substring
(
0
,
8
);
String
suffix
=
iotCode
.
toString
().
substring
(
8
);
List
<
Map
<
String
,
String
>>
dataList
=
pressurePumpService
.
getIotCommonListData
(
startTime
,
endTime
,
prefix
,
suffix
,
null
,
pressurePumpStart
);
dataList
.
forEach
(
z
->
timeSet
.
add
(
z
.
get
(
"createdTime"
)));
dataListMap
.
put
(
iotCode
.
toString
(),
dataList
);
}
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
});
// 数据时间排序
List
<
String
>
sortTimeList
=
new
ArrayList
<>(
timeSet
);
Collections
.
sort
(
sortTimeList
);
// 数据时间截取,MM-dd HH:mm
List
<
String
>
sortTimeCollectList
=
sortTimeList
.
stream
().
map
(
x
->
x
.
substring
(
5
,
x
.
length
()
-
3
)).
collect
(
Collectors
.
toList
());
// 数据时间截取,MM-dd HH
List
<
String
>
sortTimeTmpCollectList
=
sortTimeList
.
stream
().
map
(
x
->
x
.
substring
(
5
,
x
.
length
()
-
6
)).
collect
(
Collectors
.
toList
());
// 组装x时间轴数据
List
<
String
>
timeList
=
new
ArrayList
<>();
timeHourList
.
forEach
(
t
->
{
String
strTime
=
t
.
substring
(
0
,
t
.
length
()
-
3
);
if
(
sortTimeCollectList
.
contains
(
t
))
{
timeList
.
add
(
t
);
}
else
if
(!
sortTimeTmpCollectList
.
contains
(
strTime
))
{
timeList
.
add
(
strTime
+
":00"
);
sortTimeTmpCollectList
.
add
(
strTime
);
}
});
// 遍历稳压泵,dataListMap获取各稳压泵数据,没有数据的进行补0
list
.
forEach
(
x
->
{
Map
<
String
,
Object
>
yMap
=
new
HashMap
<>();
List
<
Integer
>
yList
=
new
ArrayList
<>();
String
name
=
x
.
get
(
"name"
).
toString
();
yMap
.
put
(
"name"
,
name
);
Object
iotCode
=
x
.
get
(
"iotCode"
);
if
(
x
.
get
(
"iotCode"
)
!=
null
)
{
List
<
Map
<
String
,
String
>>
dataList
=
dataListMap
.
get
(
iotCode
.
toString
());
if
(!
CollectionUtils
.
isEmpty
(
dataList
))
{
Collections
.
reverse
(
dataList
);
Map
<
String
,
List
<
Map
<
String
,
String
>>>
dataMap
=
dataList
.
stream
().
filter
(
y
->
y
.
containsKey
(
"createdTime"
)).
collect
(
Collectors
.
groupingBy
(
e
->
e
.
get
(
"createdTime"
).
substring
(
5
,
16
)));
List
<
Map
<
String
,
String
>>
yDataList
=
null
;
String
flag
=
"true"
;
for
(
String
t
:
timeList
)
{
List
<
Map
<
String
,
String
>>
data
=
dataMap
.
get
(
t
);
if
(!
CollectionUtils
.
isEmpty
(
data
))
{
yDataList
=
data
.
stream
().
filter
(
o
->
"true"
.
equalsIgnoreCase
(
o
.
get
(
pressurePumpStart
))).
collect
(
Collectors
.
toList
());
yList
.
add
(!
CollectionUtils
.
isEmpty
(
yDataList
)
&&
"true"
.
equalsIgnoreCase
(
flag
)
?
1
:
0
);
//flag = data.get(data.size() - 1).get(pressurePumpStart);
// 原有逻辑仅限第一次启停、第一次经历启停处理完后、flag 为 false(未恢复起始默认状态) 导致后续启动后状态判断失效数据异常
flag
=
"true"
.
equals
(
flag
)
?
"false"
:
"true"
;
}
else
{
yList
.
add
(
0
);
}
}
}
else
{
timeList
.
forEach
(
t
->
{
yList
.
add
(
0
);
});
}
yMap
.
put
(
"data"
,
yList
);
yData
.
add
(
yMap
);
}
});
map
.
put
(
"xData"
,
timeList
);
map
.
put
(
"yData"
,
yData
);
}
return
map
;
}
@Override
public
List
<
Map
<
String
,
Object
>>
getPressurePumpDiagnosticAnalysis
(
String
equipmentCode
,
String
nameKeys
,
String
fieldKey
,
String
bizOrgCode
,
String
appKey
,
String
product
,
String
token
)
{
List
<
Map
<
String
,
Object
>>
list
=
new
ArrayList
<>();
// 1. 判断稳压泵整体是否故障
List
<
EquipmentSpecificAlarmLog
>
alarmLogList
=
equipmentSpecificAlarmLogService
.
getAlarmLogInfoList
(
equipmentCode
,
nameKeys
,
"true"
,
"false"
,
bizOrgCode
);
HashMap
<
String
,
Object
>
isFaultMap
=
new
HashMap
<>();
isFaultMap
.
put
(
"key"
,
1
);
isFaultMap
.
put
(
"code"
,
1
);
isFaultMap
.
put
(
"name"
,
"稳压泵是否故障"
);
isFaultMap
.
put
(
"value"
,
CollectionUtils
.
isEmpty
(
alarmLogList
)
?
"无"
:
"有"
);
isFaultMap
.
put
(
"unit"
,
""
);
list
.
add
(
isFaultMap
);
// 2. 最近一次启停间隔
HashMap
<
String
,
Object
>
intervalMap
=
new
HashMap
<>();
intervalMap
.
put
(
"key"
,
2
);
intervalMap
.
put
(
"code"
,
2
);
intervalMap
.
put
(
"name"
,
"最近一次启停间隔"
);
intervalMap
.
put
(
"unit"
,
"分钟"
);
// 3. 最近一次启动时长
HashMap
<
String
,
Object
>
durationlMap
=
new
HashMap
<>();
durationlMap
.
put
(
"key"
,
3
);
durationlMap
.
put
(
"code"
,
3
);
durationlMap
.
put
(
"name"
,
"最近一次启动时长"
);
durationlMap
.
put
(
"unit"
,
"分钟"
);
// 4. 半小时启动
// 5. 2小时启动
String
nowStrLong
=
DateUtils
.
getDateNowString
();
Date
halfHour
=
DateUtils
.
dateAddMinutes
(
null
,
-
30
);
Date
twoHour
=
DateUtils
.
dateAddHours
(
null
,
-
2
);
String
half
=
DateUtils
.
convertDateToString
(
halfHour
,
DateUtils
.
DATE_TIME_PATTERN
);
String
two
=
DateUtils
.
convertDateToString
(
twoHour
,
DateUtils
.
DATE_TIME_PATTERN
);
HashMap
<
String
,
Object
>
pipeMap
=
new
HashMap
<>();
pipeMap
.
put
(
"key"
,
6
);
pipeMap
.
put
(
"code"
,
6
);
pipeMap
.
put
(
"name"
,
"管网压力"
);
pipeMap
.
put
(
"value"
,
"正常"
);
pipeMap
.
put
(
"unit"
,
""
);
// 获取稳压泵
List
<
Map
<
String
,
Object
>>
specificList
=
equipmentSpecificSerivce
.
getListByEquipmentCode
(
equipmentCode
,
bizOrgCode
);
AtomicInteger
halfNum
=
new
AtomicInteger
();
AtomicInteger
twoNum
=
new
AtomicInteger
();
if
(!
CollectionUtils
.
isEmpty
(
specificList
))
{
String
prefix
=
null
;
String
suffix
=
null
;
for
(
Map
<
String
,
Object
>
x
:
specificList
)
{
Object
iotCode
=
x
.
get
(
"iotCode"
);
if
(
x
.
get
(
"iotCode"
)
!=
null
&&
iotCode
.
toString
().
length
()
>
8
)
{
prefix
=
iotCode
.
toString
().
substring
(
0
,
8
);
suffix
=
iotCode
.
toString
().
substring
(
8
);
try
{
ResponseModel
halfResponseModel
=
iotFeign
.
selectList
(
appKey
,
product
,
token
,
half
,
nowStrLong
,
prefix
,
suffix
,
pressurePumpStart
);
ResponseModel
twoResponseModel
=
iotFeign
.
selectList
(
appKey
,
product
,
token
,
two
,
nowStrLong
,
prefix
,
suffix
,
pressurePumpStart
);
if
(
200
==
halfResponseModel
.
getStatus
())
{
String
json
=
JSON
.
toJSONString
(
halfResponseModel
.
getResult
());
List
<
Map
<
String
,
String
>>
halfDataList
=
(
List
<
Map
<
String
,
String
>>)
JSONArray
.
parse
(
json
);
List
<
Map
<
String
,
String
>>
halfCollect
=
halfDataList
.
stream
().
filter
(
o
->
"true"
.
equalsIgnoreCase
(
o
.
get
(
pressurePumpStart
))).
collect
(
Collectors
.
toList
());
halfNum
.
addAndGet
(
halfCollect
.
size
());
}
if
(
200
==
twoResponseModel
.
getStatus
())
{
String
json
=
JSON
.
toJSONString
(
twoResponseModel
.
getResult
());
List
<
Map
<
String
,
String
>>
twoDataList
=
(
List
<
Map
<
String
,
String
>>)
JSONArray
.
parse
(
json
);
List
<
Map
<
String
,
String
>>
twoCollect
=
twoDataList
.
stream
().
filter
(
o
->
"true"
.
equalsIgnoreCase
(
o
.
get
(
pressurePumpStart
))).
collect
(
Collectors
.
toList
());
twoNum
.
addAndGet
(
twoCollect
.
size
());
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
// 数据时间排序
List
<
String
>
sortTimeList
=
new
ArrayList
<>(
timeSet
);
Collections
.
sort
(
sortTimeList
);
// 数据时间截取,MM-dd HH:mm
// List<String> sortTimeCollectList = sortTimeList.stream().map(x -> DateUtils.dateFormat(DateUtils.convertStrToDate(x, DateUtils.DATE_TIME_PATTERN),DateUtils.MONTH_DAY_HOUR_MINUTE_PATTERN)).collect(Collectors.toList());
List
<
String
>
sortTimeCollectList
=
sortTimeList
.
stream
().
map
(
x
->
x
.
substring
(
5
,
x
.
length
()
-
3
)).
collect
(
Collectors
.
toList
());
// 数据时间截取,MM-dd HH
List
<
String
>
sortTimeTmpCollectList
=
sortTimeList
.
stream
().
map
(
x
->
x
.
substring
(
5
,
x
.
length
()
-
6
)).
collect
(
Collectors
.
toList
());
// 组装x时间轴数据
List
<
String
>
timeList
=
new
ArrayList
<>();
timeHourList
.
forEach
(
t
->
{
String
strTime
=
t
.
substring
(
0
,
t
.
length
()
-
3
);
if
(
sortTimeCollectList
.
contains
(
t
))
{
timeList
.
add
(
t
);
}
else
if
(!
sortTimeTmpCollectList
.
contains
(
strTime
))
{
timeList
.
add
(
strTime
+
":00"
);
sortTimeTmpCollectList
.
add
(
strTime
);
}
}
}
ResponseModel
intervalResponseModel
=
iotFeign
.
topSingleField
(
appKey
,
product
,
token
,
"100"
,
prefix
,
null
,
null
,
pressurePumpStart
);
String
intervalTime1
=
nowStrLong
;
String
intervalTime2
=
nowStrLong
;
String
durationTime
=
nowStrLong
;
if
(
200
==
intervalResponseModel
.
getStatus
())
{
String
json
=
JSON
.
toJSONString
(
intervalResponseModel
.
getResult
());
List
<
Map
<
String
,
String
>>
intervalDataList
=
(
List
<
Map
<
String
,
String
>>)
JSONArray
.
parse
(
json
);
if
(!
CollectionUtils
.
isEmpty
(
intervalDataList
))
{
String
value
=
intervalDataList
.
get
(
0
).
get
(
pressurePumpStart
);
List
<
Map
<
String
,
String
>>
falseDataList
=
intervalDataList
.
stream
().
filter
(
x
->
x
.
containsKey
(
"createdTime"
)
&&
"false"
.
equalsIgnoreCase
(
x
.
get
(
pressurePumpStart
))).
collect
(
Collectors
.
toList
());
List
<
Map
<
String
,
String
>>
trueDataList
=
intervalDataList
.
stream
().
filter
(
x
->
x
.
containsKey
(
"createdTime"
)
&&
"true"
.
equalsIgnoreCase
(
x
.
get
(
pressurePumpStart
))).
collect
(
Collectors
.
toList
());
if
(!
CollectionUtils
.
isEmpty
(
trueDataList
))
{
intervalTime2
=
trueDataList
.
get
(
0
).
get
(
"createdTime"
);
}
if
(
"true"
.
equalsIgnoreCase
(
value
))
{
if
(!
CollectionUtils
.
isEmpty
(
falseDataList
))
{
try
{
durationTime
=
intervalTime2
;
intervalTime1
=
falseDataList
.
get
(
0
).
get
(
"createdTime"
);
String
stop5BeforeTime
=
DateUtils
.
convertDateToString
(
DateUtils
.
dateAddMinutes
(
DateUtils
.
convertStrToDate
(
intervalTime1
,
"yyyy-MM-dd HH:mm:ss"
),
-
5
),
"yyyy-MM-dd HH:mm:ss"
);
ResponseModel
pipeResponseModel
=
iotFeign
.
selectListNew
(
prefix
,
null
,
stop5BeforeTime
,
intervalTime2
,
null
,
"FHS_PipePressureDetector_PipePressure"
);
if
(
200
==
pipeResponseModel
.
getStatus
())
{
String
pipeJson
=
JSON
.
toJSONString
(
pipeResponseModel
.
getResult
());
List
<
Map
<
String
,
String
>>
pipeDataList
=
(
List
<
Map
<
String
,
String
>>)
JSONArray
.
parse
(
pipeJson
);
List
<
Map
<
String
,
String
>>
collect1
=
pipeDataList
.
stream
().
filter
(
o
->
o
.
containsKey
(
"FHS_PipePressureDetector_PipePressure"
)).
collect
(
Collectors
.
toList
());
if
(!
CollectionUtils
.
isEmpty
(
collect1
))
{
double
val1
=
Double
.
parseDouble
(
collect1
.
get
(
0
).
get
(
"FHS_PipePressureDetector_PipePressure"
));
double
val2
=
Double
.
parseDouble
(
collect1
.
get
(
collect1
.
size
()
-
1
).
get
(
"FHS_PipePressureDetector_PipePressure"
));
pipeMap
.
put
(
"value"
,
Math
.
abs
(
val1
-
val2
)
>
0.05
?
"异常"
:
"正常"
);
}
});
// 遍历稳压泵,dataListMap获取各稳压泵数据,没有数据的进行补0
list
.
forEach
(
x
->
{
Map
<
String
,
Object
>
yMap
=
new
HashMap
<>();
List
<
Integer
>
yList
=
new
ArrayList
<>();
String
name
=
x
.
get
(
"name"
).
toString
();
yMap
.
put
(
"name"
,
name
);
Object
iotCode
=
x
.
get
(
"iotCode"
);
if
(
x
.
get
(
"iotCode"
)
!=
null
)
{
List
<
Map
<
String
,
String
>>
dataList
=
dataListMap
.
get
(
iotCode
.
toString
());
if
(!
CollectionUtils
.
isEmpty
(
dataList
))
{
Collections
.
reverse
(
dataList
);
Map
<
String
,
List
<
Map
<
String
,
String
>>>
dataMap
=
dataList
.
stream
().
filter
(
y
->
y
.
containsKey
(
"createdTime"
)).
collect
(
Collectors
.
groupingBy
(
e
->
e
.
get
(
"createdTime"
).
substring
(
5
,
16
)));
List
<
Map
<
String
,
String
>>
yDataList
=
null
;
for
(
String
t
:
timeList
)
{
List
<
Map
<
String
,
String
>>
data
=
dataMap
.
get
(
t
);
if
(!
CollectionUtils
.
isEmpty
(
data
))
{
yDataList
=
data
.
stream
().
filter
(
o
->
PressurePumpRelateEnum
.
IOT_INDEX_VALUE_TRUE
.
getValue
().
equalsIgnoreCase
(
o
.
get
(
pressurePumpStart
))).
collect
(
Collectors
.
toList
());
String
flag
=
data
.
get
(
data
.
size
()
-
1
).
get
(
pressurePumpStart
);
yList
.
add
(!
CollectionUtils
.
isEmpty
(
yDataList
)
?
Integer
.
parseInt
(
PressurePumpRelateEnum
.
START
.
getValue
())
:
PressurePumpRelateEnum
.
IOT_INDEX_VALUE_TRUE
.
getValue
().
equalsIgnoreCase
(
flag
)
?
Integer
.
parseInt
(
PressurePumpRelateEnum
.
START
.
getValue
()):
Integer
.
parseInt
(
PressurePumpRelateEnum
.
STOP
.
getValue
()));
}
else
{
yList
.
add
(
Integer
.
parseInt
(
PressurePumpRelateEnum
.
STOP
.
getValue
()));
}
}
catch
(
ParseException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
else
{
timeList
.
forEach
(
t
->
{
yList
.
add
(
Integer
.
parseInt
(
PressurePumpRelateEnum
.
STOP
.
getValue
()));
});
}
}
else
{
if
(!
CollectionUtils
.
isEmpty
(
falseDataList
)
&&
!
CollectionUtils
.
isEmpty
(
trueDataList
))
{
durationTime
=
trueDataList
.
get
(
0
).
get
(
"createdTime"
);
nowStrLong
=
falseDataList
.
get
(
0
).
get
(
"createdTime"
);
// 获取最接近最新启动信号,且时间大于启动信号的停止信号时间值
String
finalIntervalTime
=
intervalTime2
;
List
<
Map
<
String
,
String
>>
timeList
=
falseDataList
.
stream
().
filter
(
x
->
DateUtils
.
getDurationSecconds
(
finalIntervalTime
,
x
.
get
(
"createdTime"
),
"yyyy-MM-dd HH:mm:ss"
)
>=
0
).
collect
(
Collectors
.
toList
());
intervalTime1
=
timeList
.
get
(
timeList
.
size
()
-
1
).
get
(
"createdTime"
);
}
yMap
.
put
(
"data"
,
yList
);
yData
.
add
(
yMap
);
}
}
});
map
.
put
(
"xData"
,
timeList
);
map
.
put
(
"yData"
,
yData
);
}
intervalMap
.
put
(
"value"
,
Math
.
ceil
((
double
)
Math
.
abs
(
DateUtils
.
getDurationSecconds
(
intervalTime1
,
intervalTime2
,
"yyyy-MM-dd HH:mm:ss"
))
/
60
));
durationlMap
.
put
(
"value"
,
Math
.
ceil
((
double
)
Math
.
abs
(
DateUtils
.
getDurationSecconds
(
durationTime
,
nowStrLong
,
"yyyy-MM-dd HH:mm:ss"
))
/
60
));
}
else
{
intervalMap
.
put
(
"value"
,
0
);
durationlMap
.
put
(
"value"
,
0
);
pipeMap
.
put
(
"value"
,
"正常"
);
}
catch
(
Exception
e
)
{
log
.
error
(
"getPressurePumpStatusChart-->获取稳压泵启停状态图失败:{}"
,
e
.
getMessage
());
}
list
.
add
(
intervalMap
);
list
.
add
(
durationlMap
);
HashMap
<
String
,
Object
>
halfMap
=
new
HashMap
<>();
halfMap
.
put
(
"key"
,
4
);
halfMap
.
put
(
"code"
,
4
);
halfMap
.
put
(
"name"
,
"半小时启动"
);
halfMap
.
put
(
"value"
,
halfNum
);
halfMap
.
put
(
"unit"
,
"次"
);
list
.
add
(
halfMap
);
HashMap
<
String
,
Object
>
twoMap
=
new
HashMap
<>();
twoMap
.
put
(
"key"
,
5
);
twoMap
.
put
(
"code"
,
5
);
twoMap
.
put
(
"name"
,
"2小时启动"
);
twoMap
.
put
(
"value"
,
twoNum
);
twoMap
.
put
(
"unit"
,
"次"
);
list
.
add
(
twoMap
);
// 6. 管网压力
list
.
add
(
pipeMap
);
return
list
;
return
map
;
}
// @Override
// public Map<String, Object> getPressurePumpStatusChart(String equipmentCode, String startTime, String endTime, String bizOrgCode, String appKey, String product, String token) {
// Map<String, Object> map = new LinkedHashMap<>();
// // 获取稳压泵
// List<Map<String, Object>> list = equipmentSpecificSerivce.getListByEquipmentCode(equipmentCode, bizOrgCode);
// // 获取各稳压泵数据,及时间戳
// if (!CollectionUtils.isEmpty(list)) {
// // 获取查询时间范围内的时间戳
// List<String> timeHourList = DateUtils.getTimeStrListByStartAndEnd(startTime, endTime, "MM-dd HH:mm");
// Set<String> timeSet = new LinkedHashSet<>();
// List<Map<String, Object>> yData = new ArrayList<>();
// LinkedHashMap<String, List<Map<String, String>>> dataListMap = new LinkedHashMap<>();
// list.forEach(x -> {
// Object iotCode = x.get("iotCode");
// String prefix = null;
// String suffix = null;
// if (x.get("iotCode") != null && iotCode.toString().length() > 8) {
// prefix = iotCode.toString().substring(0, 8);
// suffix = iotCode.toString().substring(8);
// try {
// ResponseModel responseModel = iotFeign.selectListNew( prefix, suffix, startTime, endTime, null, pressurePumpStart);
// if (200 == responseModel.getStatus()) {
// String json = JSON.toJSONString(responseModel.getResult());
// List<Map<String, String>> dataList = (List<Map<String, String>>) JSONArray.parse(json);
// if (!CollectionUtils.isEmpty(dataList)) {
// dataList.stream().filter(y -> y.containsKey("createdTime")).forEach(z -> timeSet.add(z.get("createdTime")));
// dataListMap.put(iotCode.toString(), dataList);
// }
// }
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// });
// // 数据时间排序
// List<String> sortTimeList = new ArrayList<>(timeSet);
// Collections.sort(sortTimeList);
// // 数据时间截取,MM-dd HH:mm
// List<String> sortTimeCollectList = sortTimeList.stream().map(x -> x.substring(5, x.length() - 3)).collect(Collectors.toList());
// // 数据时间截取,MM-dd HH
// List<String> sortTimeTmpCollectList = sortTimeList.stream().map(x -> x.substring(5, x.length() - 6)).collect(Collectors.toList());
// // 组装x时间轴数据
// List<String> timeList = new ArrayList<>();
// timeHourList.forEach(t -> {
// String strTime = t.substring(0, t.length() - 3);
// if (sortTimeCollectList.contains(t)) {
// timeList.add(t);
// } else if (!sortTimeTmpCollectList.contains(strTime)) {
// timeList.add(strTime + ":00");
// sortTimeTmpCollectList.add(strTime);
// }
// });
//
// // 遍历稳压泵,dataListMap获取各稳压泵数据,没有数据的进行补0
// list.forEach(x -> {
// Map<String, Object> yMap = new HashMap<>();
// List<Integer> yList = new ArrayList<>();
// String name = x.get("name").toString();
// yMap.put("name", name);
// Object iotCode = x.get("iotCode");
// if (x.get("iotCode") != null) {
// List<Map<String, String>> dataList = dataListMap.get(iotCode.toString());
// if (!CollectionUtils.isEmpty(dataList)) {
// Collections.reverse(dataList);
// Map<String, List<Map<String, String>>> dataMap = dataList.stream().filter(y -> y.containsKey("createdTime")).collect(Collectors.groupingBy(e -> e.get("createdTime").substring(5, 16)));
// List<Map<String, String>> yDataList = null;
// String flag = "true";
// for (String t : timeList) {
// List<Map<String, String>> data = dataMap.get(t);
// if (!CollectionUtils.isEmpty(data)) {
// yDataList = data.stream().filter(o -> "true".equalsIgnoreCase(o.get(pressurePumpStart))).collect(Collectors.toList());
// yList.add(!CollectionUtils.isEmpty(yDataList) && "true".equalsIgnoreCase(flag) ? 1 : 0);
// //flag = data.get(data.size() - 1).get(pressurePumpStart);
// // 原有逻辑仅限第一次启停、第一次经历启停处理完后、flag 为 false(未恢复起始默认状态) 导致后续启动后状态判断失效数据异常
// flag = "true".equals(flag) ? "false" : "true";
// } else {
// yList.add(0);
// }
// }
// } else {
// timeList.forEach(t -> {
// yList.add(0);
// });
// }
// yMap.put("data", yList);
// yData.add(yMap);
// }
// });
// map.put("xData", timeList);
// map.put("yData", yData);
// }
// return map;
// }
//
// @Override
// public List<Map<String, Object>> getPressurePumpDiagnosticAnalysis(String equipmentCode, String nameKeys, String fieldKey, String bizOrgCode, String appKey, String product, String token) {
// List<Map<String, Object>> list = new ArrayList<>();
// // 1. 判断稳压泵整体是否故障
// List<EquipmentSpecificAlarmLog> alarmLogList = equipmentSpecificAlarmLogService.getAlarmLogInfoList(equipmentCode, nameKeys, "true", "false", bizOrgCode);
// HashMap<String, Object> isFaultMap = new HashMap<>();
// isFaultMap.put("key", 1);
// isFaultMap.put("code", 1);
// isFaultMap.put("name", "稳压泵是否故障");
// isFaultMap.put("value", CollectionUtils.isEmpty(alarmLogList) ? "无" : "有");
// isFaultMap.put("unit", "");
// list.add(isFaultMap);
// // 2. 最近一次启停间隔
// HashMap<String, Object> intervalMap = new HashMap<>();
// intervalMap.put("key", 2);
// intervalMap.put("code", 2);
// intervalMap.put("name", "最近一次启停间隔");
// intervalMap.put("unit", "分钟");
// // 3. 最近一次启动时长
// HashMap<String, Object> durationlMap = new HashMap<>();
// durationlMap.put("key", 3);
// durationlMap.put("code", 3);
// durationlMap.put("name", "最近一次启动时长");
// durationlMap.put("unit", "分钟");
// // 4. 半小时启动
// // 5. 2小时启动
// String nowStrLong = DateUtils.getDateNowString();
// Date halfHour = DateUtils.dateAddMinutes(null, -30);
// Date twoHour = DateUtils.dateAddHours(null, -2);
// String half = DateUtils.convertDateToString(halfHour, DateUtils.DATE_TIME_PATTERN);
// String two = DateUtils.convertDateToString(twoHour, DateUtils.DATE_TIME_PATTERN);
//
// HashMap<String, Object> pipeMap = new HashMap<>();
// pipeMap.put("key", 6);
// pipeMap.put("code", 6);
// pipeMap.put("name", "管网压力");
// pipeMap.put("value", "正常");
// pipeMap.put("unit", "");
//
// // 获取稳压泵
// List<Map<String, Object>> specificList = equipmentSpecificSerivce.getListByEquipmentCode(equipmentCode, bizOrgCode);
// AtomicInteger halfNum = new AtomicInteger();
// AtomicInteger twoNum = new AtomicInteger();
// if (!CollectionUtils.isEmpty(specificList)) {
// String prefix = null;
// String suffix = null;
// for (Map<String, Object> x : specificList) {
// Object iotCode = x.get("iotCode");
// if (x.get("iotCode") != null && iotCode.toString().length() > 8) {
// prefix = iotCode.toString().substring(0, 8);
// suffix = iotCode.toString().substring(8);
// try {
// ResponseModel halfResponseModel = iotFeign.selectList(appKey, product, token, half, nowStrLong, prefix, suffix, pressurePumpStart);
// ResponseModel twoResponseModel = iotFeign.selectList(appKey, product, token, two, nowStrLong, prefix, suffix, pressurePumpStart);
// if (200 == halfResponseModel.getStatus()) {
// String json = JSON.toJSONString(halfResponseModel.getResult());
// List<Map<String, String>> halfDataList = (List<Map<String, String>>) JSONArray.parse(json);
// List<Map<String, String>> halfCollect = halfDataList.stream().filter(o -> "true".equalsIgnoreCase(o.get(pressurePumpStart))).collect(Collectors.toList());
// halfNum.addAndGet(halfCollect.size());
// }
// if (200 == twoResponseModel.getStatus()) {
// String json = JSON.toJSONString(twoResponseModel.getResult());
// List<Map<String, String>> twoDataList = (List<Map<String, String>>) JSONArray.parse(json);
// List<Map<String, String>> twoCollect = twoDataList.stream().filter(o -> "true".equalsIgnoreCase(o.get(pressurePumpStart))).collect(Collectors.toList());
// twoNum.addAndGet(twoCollect.size());
// }
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// }
// ResponseModel intervalResponseModel = iotFeign.topSingleField(appKey, product, token, "100", prefix, null, null, pressurePumpStart);
// String intervalTime1 = nowStrLong;
// String intervalTime2 = nowStrLong;
// String durationTime = nowStrLong;
// if (200 == intervalResponseModel.getStatus()) {
// String json = JSON.toJSONString(intervalResponseModel.getResult());
// List<Map<String, String>> intervalDataList = (List<Map<String, String>>) JSONArray.parse(json);
// if (!CollectionUtils.isEmpty(intervalDataList)) {
// String value = intervalDataList.get(0).get(pressurePumpStart);
// List<Map<String, String>> falseDataList = intervalDataList.stream().filter(x -> x.containsKey("createdTime") && "false".equalsIgnoreCase(x.get(pressurePumpStart))).collect(Collectors.toList());
// List<Map<String, String>> trueDataList = intervalDataList.stream().filter(x -> x.containsKey("createdTime") && "true".equalsIgnoreCase(x.get(pressurePumpStart))).collect(Collectors.toList());
// if (!CollectionUtils.isEmpty(trueDataList)) {
// intervalTime2 = trueDataList.get(0).get("createdTime");
// }
// if ("true".equalsIgnoreCase(value)) {
// if (!CollectionUtils.isEmpty(falseDataList)) {
// try {
// durationTime = intervalTime2;
// intervalTime1 = falseDataList.get(0).get("createdTime");
// String stop5BeforeTime = DateUtils.convertDateToString(DateUtils.dateAddMinutes(DateUtils.convertStrToDate(intervalTime1, "yyyy-MM-dd HH:mm:ss"), -5), "yyyy-MM-dd HH:mm:ss");
// ResponseModel pipeResponseModel = iotFeign.selectListNew( prefix, null, stop5BeforeTime, intervalTime2, null, "FHS_PipePressureDetector_PipePressure");
// if (200 == pipeResponseModel.getStatus()) {
// String pipeJson = JSON.toJSONString(pipeResponseModel.getResult());
// List<Map<String, String>> pipeDataList = (List<Map<String, String>>) JSONArray.parse(pipeJson);
// List<Map<String, String>> collect1 = pipeDataList.stream().filter(o -> o.containsKey("FHS_PipePressureDetector_PipePressure")).collect(Collectors.toList());
// if (!CollectionUtils.isEmpty(collect1)) {
// double val1 = Double.parseDouble(collect1.get(0).get("FHS_PipePressureDetector_PipePressure"));
// double val2 = Double.parseDouble(collect1.get(collect1.size() - 1).get("FHS_PipePressureDetector_PipePressure"));
// pipeMap.put("value", Math.abs(val1 - val2) > 0.05 ? "异常" : "正常");
// }
// }
// } catch (ParseException e) {
// throw new RuntimeException(e);
// }
// }
// } else {
// if (!CollectionUtils.isEmpty(falseDataList) && !CollectionUtils.isEmpty(trueDataList)) {
// durationTime = trueDataList.get(0).get("createdTime");
// nowStrLong = falseDataList.get(0).get("createdTime");
// // 获取最接近最新启动信号,且时间大于启动信号的停止信号时间值
// String finalIntervalTime = intervalTime2;
// List<Map<String, String>> timeList = falseDataList.stream().filter(x -> DateUtils.getDurationSeconds(finalIntervalTime, x.get("createdTime"), "yyyy-MM-dd HH:mm:ss") >= 0).collect(Collectors.toList());
// intervalTime1 = timeList.get(timeList.size() - 1).get("createdTime");
// }
// }
// }
// }
// intervalMap.put("value", Math.ceil((double) Math.abs(DateUtils.getDurationSeconds(intervalTime1, intervalTime2, "yyyy-MM-dd HH:mm:ss")) / 60));
// durationlMap.put("value", Math.ceil((double) Math.abs(DateUtils.getDurationSeconds(durationTime, nowStrLong, "yyyy-MM-dd HH:mm:ss")) / 60));
// } else {
// intervalMap.put("value", 0);
// durationlMap.put("value", 0);
// pipeMap.put("value", "正常");
// }
// list.add(intervalMap);
// list.add(durationlMap);
// HashMap<String, Object> halfMap = new HashMap<>();
// halfMap.put("key", 4);
// halfMap.put("code", 4);
// halfMap.put("name", "半小时启动");
// halfMap.put("value", halfNum);
// halfMap.put("unit", "次");
// list.add(halfMap);
//
// HashMap<String, Object> twoMap = new HashMap<>();
// twoMap.put("key", 5);
// twoMap.put("code", 5);
// twoMap.put("name", "2小时启动");
// twoMap.put("value", twoNum);
// twoMap.put("unit", "次");
// list.add(twoMap);
// // 6. 管网压力
// list.add(pipeMap);
// return list;
// }
@Override
public
double
getPressurePumpIntervalTime
(
String
prefix
,
String
appKey
,
String
product
,
String
token
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
ResponseModel
intervalResponseModel
=
iotFeign
.
topSingleField
(
appKey
,
product
,
token
,
"100"
,
prefix
,
null
,
null
,
pressurePumpStart
);
ResponseModel
intervalResponseModel
=
iotFeign
.
topSingleField
(
"100"
,
prefix
,
null
,
null
,
pressurePumpStart
);
String
nowStrLong
=
DateUtils
.
getDateNowString
();
String
intervalTime1
=
nowStrLong
;
String
intervalTime2
=
nowStrLong
;
...
...
@@ -533,13 +677,13 @@ public class EmergencyServiceImpl implements IEmergencyService {
nowStrLong
=
falseDataList
.
get
(
0
).
get
(
"createdTime"
);
// 获取最接近最新启动信号,且时间大于启动信号的停止信号时间值
String
finalIntervalTime
=
intervalTime2
;
List
<
Map
<
String
,
String
>>
timeList
=
falseDataList
.
stream
().
filter
(
x
->
DateUtils
.
getDurationSec
c
onds
(
finalIntervalTime
,
x
.
get
(
"createdTime"
),
"yyyy-MM-dd HH:mm:ss"
)
>=
0
).
collect
(
Collectors
.
toList
());
List
<
Map
<
String
,
String
>>
timeList
=
falseDataList
.
stream
().
filter
(
x
->
DateUtils
.
getDurationSeconds
(
finalIntervalTime
,
x
.
get
(
"createdTime"
),
"yyyy-MM-dd HH:mm:ss"
)
>=
0
).
collect
(
Collectors
.
toList
());
intervalTime1
=
timeList
.
get
(
timeList
.
size
()
-
1
).
get
(
"createdTime"
);
}
}
}
}
return
Math
.
ceil
((
double
)
Math
.
abs
(
DateUtils
.
getDurationSec
c
onds
(
intervalTime1
,
intervalTime2
,
"yyyy-MM-dd HH:mm:ss"
))
/
60
);
return
Math
.
ceil
((
double
)
Math
.
abs
(
DateUtils
.
getDurationSeconds
(
intervalTime1
,
intervalTime2
,
"yyyy-MM-dd HH:mm:ss"
))
/
60
);
}
@Override
...
...
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/service/impl/MqttReceiveServiceImpl.java
View file @
b0928098
...
...
@@ -317,7 +317,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
}
// redis缓存指定指标、指定时长物联数据
pressurePumpService
.
saveDataToRedis
(
iotDatalist
);
pressurePumpService
.
saveDataToRedis
(
iotDatalist
,
topic
);
if
(!
StringUtils
.
isEmpty
(
traceId
))
{
String
finalTraceId
=
traceId
;
...
...
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/service/impl/PressurePumpServiceImpl.java
View file @
b0928098
package
com
.
yeejoin
.
equipmanage
.
service
.
impl
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.yeejoin.amos.boot.biz.common.utils.DateUtils
;
import
com.yeejoin.amos.boot.biz.common.utils.RedisUtils
;
import
com.yeejoin.equipmanage.common.enums.PressurePumpRelateEnum
;
import
com.yeejoin.equipmanage.common.vo.IotDataVO
;
import
com.yeejoin.equipmanage.
service.IEquipmentSpecificSerivce
;
import
com.yeejoin.equipmanage.
fegin.IotFeign
;
import
com.yeejoin.equipmanage.service.IPressurePumpService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.io.IOUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.core.io.Resource
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.stereotype.Service
;
import
org.typroject.tyboot.core.restful.utils.ResponseModel
;
import
java.io.IOException
;
import
java.nio.charset.StandardCharsets
;
...
...
@@ -28,7 +31,7 @@ import java.util.stream.Collectors;
public
class
PressurePumpServiceImpl
implements
IPressurePumpService
{
@Autowired
private
I
EquipmentSpecificSerivce
equipmentSpecificSerivce
;
private
I
otFeign
iotFeign
;
@Autowired
private
RedisUtils
redisUtils
;
...
...
@@ -44,7 +47,7 @@ public class PressurePumpServiceImpl implements IPressurePumpService {
@Override
@Async
public
void
saveDataToRedis
(
List
<
IotDataVO
>
iotDatalist
)
{
public
void
saveDataToRedis
(
List
<
IotDataVO
>
iotDatalist
,
String
topic
)
{
String
pressurePumpValue
=
PressurePumpRelateEnum
.
PRESSURE_PUMP
.
getValue
();
// 获取配置JSON信息集合
List
<
Map
>
list
=
getNameKeyInfoList
(
pressurePumpValue
);
...
...
@@ -58,16 +61,18 @@ public class PressurePumpServiceImpl implements IPressurePumpService {
String
key
=
vo
.
getKey
();
if
(
nameKey
.
contains
(
vo
.
getKey
()))
{
vo
.
setCreatedTime
(
nowString
);
redisUtils
.
set
(
String
.
join
(
":"
,
pressurePumpValue
,
key
,
String
.
valueOf
(
timeMillis
)),
JSONObject
.
toJSONString
(
vo
),
expire
);
String
[]
split
=
topic
.
split
(
"/"
);
topic
=
split
.
length
>
2
?
String
.
join
(
""
,
split
[
0
],
split
[
1
])
:
""
;
redisUtils
.
set
(
String
.
join
(
":"
,
pressurePumpValue
,
key
,
topic
,
String
.
valueOf
(
timeMillis
)),
JSONObject
.
toJSONString
(
vo
),
expire
);
}
}
}
}
@Override
public
List
<
IotDataVO
>
getDataToRedis
(
String
key
)
{
public
List
<
IotDataVO
>
getDataToRedis
(
String
infoCode
,
String
nameKey
,
String
iotCode
)
{
List
<
IotDataVO
>
list
=
new
ArrayList
<>();
Set
<
String
>
keys
=
redisUtils
.
getKeys
(
String
.
join
(
":"
,
PressurePumpRelateEnum
.
PRESSURE_PUMP
.
getValue
(),
key
));
Set
<
String
>
keys
=
redisUtils
.
getKeys
(
String
.
join
(
":"
,
infoCode
,
nameKey
,
StringUtils
.
isNotEmpty
(
iotCode
)
?
iotCode
:
""
));
if
(
CollectionUtils
.
isNotEmpty
(
keys
))
{
keys
.
forEach
(
x
->
{
list
.
add
(
JSON
.
parseObject
(
redisUtils
.
get
(
x
).
toString
(),
IotDataVO
.
class
));
...
...
@@ -79,6 +84,29 @@ public class PressurePumpServiceImpl implements IPressurePumpService {
}
@Override
public
List
<
IotDataVO
>
getDataToRedisByDateBetween
(
String
infoCode
,
String
nameKey
,
String
iotCode
,
Date
startDate
,
Date
endDate
)
{
List
<
IotDataVO
>
list
=
new
ArrayList
<>();
Set
<
String
>
keys
=
redisUtils
.
getKeys
(
String
.
join
(
":"
,
infoCode
,
nameKey
,
StringUtils
.
isNotEmpty
(
iotCode
)
?
iotCode
:
""
));
if
(
CollectionUtils
.
isNotEmpty
(
keys
))
{
keys
.
forEach
(
x
->
{
String
[]
split
=
x
.
split
(
":"
);
long
time
=
split
.
length
>
0
?
Long
.
parseLong
(
split
[
split
.
length
-
1
])
:
0
;
try
{
Date
date
=
DateUtils
.
convertStrToDate
(
DateUtils
.
stampToDate
(
time
,
DateUtils
.
DATE_TIME_PATTERN
),
DateUtils
.
DATE_TIME_PATTERN
);
if
(
DateUtils
.
dateCompare
(
date
,
startDate
)
>=
0
&&
DateUtils
.
dateCompare
(
endDate
,
date
)
>=
0
)
{
list
.
add
(
JSON
.
parseObject
(
redisUtils
.
get
(
x
).
toString
(),
IotDataVO
.
class
));
}
}
catch
(
ParseException
e
)
{
log
.
error
(
"getDataToRedisByDateBetween-->字符串转日期失败:{}"
,
e
.
getMessage
());
}
});
// 时间倒序排序
list
.
sort
((
t1
,
t2
)
->
t2
.
getCreatedTime
().
compareTo
(
t1
.
getCreatedTime
()));
}
return
list
;
}
@Override
public
List
<
Map
>
getNameKeyInfoList
(
String
code
)
{
String
json
=
null
;
try
{
...
...
@@ -94,7 +122,7 @@ public class PressurePumpServiceImpl implements IPressurePumpService {
}
@Override
public
long
getAllPressurePumpStartStopInterval
(
List
<
IotDataVO
>
redisDataList
,
String
nowStrLong
,
String
bizOrgCode
)
{
public
long
getAllPressurePumpStartStopInterval
(
List
<
IotDataVO
>
redisDataList
,
List
<
Map
<
String
,
String
>>
iotDataList
,
String
nowStrLong
,
String
bizOrgCode
)
{
String
intervalTime1
=
nowStrLong
;
String
intervalTime2
=
nowStrLong
;
if
(
CollectionUtils
.
isNotEmpty
(
redisDataList
))
{
...
...
@@ -104,44 +132,91 @@ public class PressurePumpServiceImpl implements IPressurePumpService {
if
(
PressurePumpRelateEnum
.
IOT_INDEX_VALUE_TRUE
.
getValue
().
equalsIgnoreCase
(
value
))
{
intervalTime1
=
createdTime
;
}
else
{
List
<
IotDataVO
>
falseDataList
=
get
Iot
DataFilterList
(
redisDataList
,
PressurePumpRelateEnum
.
IOT_INDEX_VALUE_FALSE
.
getValue
());
List
<
IotDataVO
>
trueDataList
=
get
Iot
DataFilterList
(
redisDataList
,
PressurePumpRelateEnum
.
IOT_INDEX_VALUE_TRUE
.
getValue
());
List
<
IotDataVO
>
falseDataList
=
get
Redis
DataFilterList
(
redisDataList
,
PressurePumpRelateEnum
.
IOT_INDEX_VALUE_FALSE
.
getValue
());
List
<
IotDataVO
>
trueDataList
=
get
Redis
DataFilterList
(
redisDataList
,
PressurePumpRelateEnum
.
IOT_INDEX_VALUE_TRUE
.
getValue
());
if
(
CollectionUtils
.
isNotEmpty
(
falseDataList
)
&&
CollectionUtils
.
isNotEmpty
(
trueDataList
))
{
intervalTime1
=
trueDataList
.
get
(
0
).
getCreatedTime
();
// 获取大于启动信号,且最近停止信号的时间
String
finalNowStrLong
=
nowStrLong
;
List
<
IotDataVO
>
timeList
=
falseDataList
.
stream
().
filter
(
x
->
DateUtils
.
getDurationSecconds
(
finalNowStrLong
,
x
.
getCreatedTime
(),
DateUtils
.
DATE_TIME_PATTERN
)
>=
0
).
collect
(
Collectors
.
toList
());
nowStrLong
=
timeList
.
get
(
timeList
.
size
()
-
1
).
getCreatedTime
();
String
finalIntervalTime
=
intervalTime1
;
List
<
IotDataVO
>
timeList
=
falseDataList
.
stream
().
filter
(
x
->
DateUtils
.
getDurationSeconds
(
finalIntervalTime
,
x
.
getCreatedTime
(),
DateUtils
.
DATE_TIME_PATTERN
)
>=
0
).
collect
(
Collectors
.
toList
());
if
(
CollectionUtils
.
isNotEmpty
(
timeList
))
{
intervalTime2
=
timeList
.
get
(
timeList
.
size
()
-
1
).
getCreatedTime
();
}
}
}
}
else
if
(
CollectionUtils
.
isNotEmpty
(
iotDataList
))
{
// redis缓存为空,从iot获取top条数据,top来源 nameKeyInfo.json 配置
return
getAllPressurePumpStartStopIntervalByIot
(
iotDataList
,
nowStrLong
);
}
return
Math
.
abs
(
DateUtils
.
getDurationSecconds
(
intervalTime1
,
intervalTime2
,
DateUtils
.
DATE_TIME_PATTERN
));
// 结果向上取整
double
ceil
=
Math
.
ceil
(
Math
.
abs
(
DateUtils
.
getDurationSeconds
(
intervalTime1
,
intervalTime2
,
DateUtils
.
DATE_TIME_PATTERN
))
*
1.0
/
Double
.
parseDouble
(
PressurePumpRelateEnum
.
ONE_HOUR_MINUTE
.
getValue
()));
return
new
Double
(
ceil
).
longValue
();
}
private
List
<
IotDataVO
>
getIotDataFilterList
(
List
<
IotDataVO
>
redisDataList
,
String
value
)
{
return
redisDataList
.
stream
().
filter
(
x
->
value
.
equalsIgnoreCase
((
String
)
x
.
getValue
())).
collect
(
Collectors
.
toList
());
public
long
getAllPressurePumpStartStopIntervalByIot
(
List
<
Map
<
String
,
String
>>
iotDataList
,
String
nowStrLong
)
{
String
intervalTime1
=
nowStrLong
;
String
intervalTime2
=
nowStrLong
;
if
(
CollectionUtils
.
isNotEmpty
(
iotDataList
))
{
String
value
=
iotDataList
.
get
(
0
).
get
(
pressurePumpStart
);
List
<
Map
<
String
,
String
>>
falseDataList
=
iotDataList
.
stream
().
filter
(
x
->
x
.
containsKey
(
"createdTime"
)
&&
"false"
.
equalsIgnoreCase
(
x
.
get
(
pressurePumpStart
))).
collect
(
Collectors
.
toList
());
List
<
Map
<
String
,
String
>>
trueDataList
=
iotDataList
.
stream
().
filter
(
x
->
x
.
containsKey
(
"createdTime"
)
&&
"true"
.
equalsIgnoreCase
(
x
.
get
(
pressurePumpStart
))).
collect
(
Collectors
.
toList
());
if
(
CollectionUtils
.
isNotEmpty
(
trueDataList
))
{
intervalTime1
=
trueDataList
.
get
(
0
).
get
(
"createdTime"
);
}
if
(
PressurePumpRelateEnum
.
IOT_INDEX_VALUE_TRUE
.
getValue
().
equalsIgnoreCase
(
value
))
{
if
(
CollectionUtils
.
isNotEmpty
(
falseDataList
))
{
intervalTime2
=
falseDataList
.
get
(
0
).
get
(
"createdTime"
);
}
}
else
{
if
(
CollectionUtils
.
isNotEmpty
(
falseDataList
)
&&
CollectionUtils
.
isNotEmpty
(
trueDataList
))
{
// 获取最接近最新启动信号,且时间大于启动信号的停止信号时间值
String
finalIntervalTime
=
intervalTime2
;
List
<
Map
<
String
,
String
>>
timeList
=
falseDataList
.
stream
().
filter
(
x
->
DateUtils
.
getDurationSeconds
(
finalIntervalTime
,
x
.
get
(
"createdTime"
),
"yyyy-MM-dd HH:mm:ss"
)
>=
0
).
collect
(
Collectors
.
toList
());
if
(
CollectionUtils
.
isNotEmpty
(
timeList
))
{
intervalTime1
=
timeList
.
get
(
timeList
.
size
()
-
1
).
get
(
"createdTime"
);
}
}
}
}
// 结果向上取整
double
ceil
=
Math
.
ceil
(
Math
.
abs
(
DateUtils
.
getDurationSeconds
(
intervalTime1
,
intervalTime2
,
DateUtils
.
DATE_TIME_PATTERN
))
*
1.0
/
Double
.
parseDouble
(
PressurePumpRelateEnum
.
ONE_HOUR_MINUTE
.
getValue
()));
return
new
Double
(
ceil
).
longValue
();
}
private
List
<
IotDataVO
>
getRedisDataFilterList
(
List
<
IotDataVO
>
redisDataList
,
String
value
)
{
return
redisDataList
.
stream
().
filter
(
x
->
value
.
equalsIgnoreCase
(
x
.
getValue
().
toString
())).
collect
(
Collectors
.
toList
());
}
private
List
<
Map
<
String
,
String
>>
getIotDataFilterList
(
List
<
Map
<
String
,
String
>>
iotDataList
,
String
value
)
{
return
iotDataList
.
stream
().
filter
(
x
->
value
.
equalsIgnoreCase
(
x
.
get
(
pressurePumpStart
))).
collect
(
Collectors
.
toList
());
}
private
List
<
IotDataVO
>
getRedisDataFilterList
(
List
<
IotDataVO
>
redisDataList
,
String
value
,
Date
beforeDate
)
{
if
(
beforeDate
!=
null
)
{
return
redisDataList
.
stream
().
filter
(
x
->
DateUtils
.
dateCompare
(
DateUtils
.
longStr2Date
(
x
.
getCreatedTime
()),
beforeDate
)
>=
0
&&
value
.
equalsIgnoreCase
(
x
.
getValue
().
toString
())).
collect
(
Collectors
.
toList
());
}
return
redisDataList
.
stream
().
filter
(
x
->
value
.
equalsIgnoreCase
(
x
.
getValue
().
toString
())).
collect
(
Collectors
.
toList
());
}
private
List
<
IotDataVO
>
getIotDataFilterList
(
List
<
IotDataVO
>
redis
DataList
,
String
value
,
Date
beforeDate
)
{
private
List
<
Map
<
String
,
String
>>
getIotDataFilterList
(
List
<
Map
<
String
,
String
>>
iot
DataList
,
String
value
,
Date
beforeDate
)
{
if
(
beforeDate
!=
null
)
{
return
redisDataList
.
stream
().
filter
(
x
->
DateUtils
.
dateCompare
(
DateUtils
.
longStr2Date
(
x
.
getCreatedTime
()),
beforeDate
)
>=
0
&&
value
.
equalsIgnoreCase
((
String
)
x
.
getValue
(
))).
collect
(
Collectors
.
toList
());
return
iotDataList
.
stream
().
filter
(
x
->
DateUtils
.
dateCompare
(
DateUtils
.
longStr2Date
(
x
.
get
(
"createdTime"
)),
beforeDate
)
>=
0
&&
value
.
equalsIgnoreCase
(
x
.
get
(
pressurePumpPipePressure
))).
collect
(
Collectors
.
toList
());
}
return
redisDataList
.
stream
().
filter
(
x
->
value
.
equalsIgnoreCase
((
String
)
x
.
getValue
(
))).
collect
(
Collectors
.
toList
());
return
iotDataList
.
stream
().
filter
(
x
->
value
.
equalsIgnoreCase
(
x
.
get
(
pressurePumpPipePressure
))).
collect
(
Collectors
.
toList
());
}
@Override
public
int
getAllPressurePumpStartFrequency
(
double
hour
,
Date
dateNow
)
{
List
<
IotDataVO
>
list
=
getDataToRedis
(
pressurePumpStart
);
List
<
IotDataVO
>
list
=
getDataToRedis
(
PressurePumpRelateEnum
.
PRESSURE_PUMP
.
getValue
(),
pressurePumpStart
,
null
);
if
(
CollectionUtils
.
isNotEmpty
(
list
))
{
Date
beforeDate
=
DateUtils
.
dateAddMinutes
(
dateNow
,
Integer
.
parseInt
(
String
.
valueOf
(
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
(
(
String
)
x
.
getValue
())).
collect
(
Collectors
.
toList
());
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
());
return
collect
.
size
();
}
return
0
;
}
@Override
public
long
getAllPressurePumpStartStopDuration
(
List
<
IotDataVO
>
redisDataList
,
String
nowStrLong
,
String
bizOrgCode
)
{
public
long
getAllPressurePumpStartStopDuration
(
List
<
IotDataVO
>
redisDataList
,
List
<
Map
<
String
,
String
>>
iotDataList
,
String
nowStrLong
,
String
bizOrgCode
)
{
String
durationTime
=
nowStrLong
;
if
(
CollectionUtils
.
isNotEmpty
(
redisDataList
))
{
IotDataVO
iotDataVO
=
redisDataList
.
get
(
0
);
...
...
@@ -150,33 +225,64 @@ public class PressurePumpServiceImpl implements IPressurePumpService {
if
(
PressurePumpRelateEnum
.
IOT_INDEX_VALUE_TRUE
.
getValue
().
equalsIgnoreCase
(
value
))
{
durationTime
=
createdTime
;
}
else
{
List
<
IotDataVO
>
falseDataList
=
get
Iot
DataFilterList
(
redisDataList
,
PressurePumpRelateEnum
.
IOT_INDEX_VALUE_FALSE
.
getValue
());
List
<
IotDataVO
>
trueDataList
=
get
Iot
DataFilterList
(
redisDataList
,
PressurePumpRelateEnum
.
IOT_INDEX_VALUE_TRUE
.
getValue
());
List
<
IotDataVO
>
falseDataList
=
get
Redis
DataFilterList
(
redisDataList
,
PressurePumpRelateEnum
.
IOT_INDEX_VALUE_FALSE
.
getValue
());
List
<
IotDataVO
>
trueDataList
=
get
Redis
DataFilterList
(
redisDataList
,
PressurePumpRelateEnum
.
IOT_INDEX_VALUE_TRUE
.
getValue
());
if
(
CollectionUtils
.
isNotEmpty
(
falseDataList
)
&&
CollectionUtils
.
isNotEmpty
(
trueDataList
))
{
durationTime
=
trueDataList
.
get
(
0
).
getCreatedTime
();
// 获取大于启动信号,且最近停止信号的时间
String
finalNowStrLong
=
nowStrLong
;
List
<
IotDataVO
>
timeList
=
falseDataList
.
stream
().
filter
(
x
->
DateUtils
.
getDurationSecconds
(
finalNowStrLong
,
x
.
getCreatedTime
(),
DateUtils
.
DATE_TIME_PATTERN
)
>=
0
).
collect
(
Collectors
.
toList
());
nowStrLong
=
timeList
.
get
(
timeList
.
size
()
-
1
).
getCreatedTime
();
List
<
IotDataVO
>
timeList
=
falseDataList
.
stream
().
filter
(
x
->
DateUtils
.
getDurationSeconds
(
finalNowStrLong
,
x
.
getCreatedTime
(),
DateUtils
.
DATE_TIME_PATTERN
)
>=
0
).
collect
(
Collectors
.
toList
());
if
(
CollectionUtils
.
isNotEmpty
(
timeList
))
{
nowStrLong
=
timeList
.
get
(
timeList
.
size
()
-
1
).
getCreatedTime
();
}
}
}
}
else
if
(
CollectionUtils
.
isNotEmpty
(
iotDataList
))
{
return
getAllPressurePumpStartStopDurationByIot
(
iotDataList
,
nowStrLong
);
}
return
Math
.
abs
(
DateUtils
.
getDurationSecconds
(
durationTime
,
nowStrLong
,
DateUtils
.
DATE_TIME_PATTERN
));
// 结果向上取整
double
ceil
=
Math
.
ceil
(
Math
.
abs
(
DateUtils
.
getDurationSeconds
(
durationTime
,
nowStrLong
,
DateUtils
.
DATE_TIME_PATTERN
))
*
1.0
/
Double
.
parseDouble
(
PressurePumpRelateEnum
.
ONE_HOUR_MINUTE
.
getValue
()));
return
new
Double
(
ceil
).
longValue
();
}
public
long
getAllPressurePumpStartStopDurationByIot
(
List
<
Map
<
String
,
String
>>
iotDataList
,
String
nowStrLong
)
{
String
durationTime
=
nowStrLong
;
if
(
CollectionUtils
.
isNotEmpty
(
iotDataList
))
{
String
value
=
iotDataList
.
get
(
0
).
get
(
pressurePumpStart
);
List
<
Map
<
String
,
String
>>
falseDataList
=
iotDataList
.
stream
().
filter
(
x
->
x
.
containsKey
(
"createdTime"
)
&&
"false"
.
equalsIgnoreCase
(
x
.
get
(
pressurePumpStart
))).
collect
(
Collectors
.
toList
());
List
<
Map
<
String
,
String
>>
trueDataList
=
iotDataList
.
stream
().
filter
(
x
->
x
.
containsKey
(
"createdTime"
)
&&
"true"
.
equalsIgnoreCase
(
x
.
get
(
pressurePumpStart
))).
collect
(
Collectors
.
toList
());
if
(
"true"
.
equalsIgnoreCase
(
value
))
{
durationTime
=
iotDataList
.
get
(
0
).
get
(
"createdTime"
);
}
else
{
if
(
CollectionUtils
.
isNotEmpty
(
falseDataList
)
&&
CollectionUtils
.
isNotEmpty
(
trueDataList
))
{
durationTime
=
trueDataList
.
get
(
0
).
get
(
"createdTime"
);
// 获取最接近最新启动信号,且时间大于启动信号的停止信号时间值
String
finalDurationTime
=
durationTime
;
List
<
Map
<
String
,
String
>>
timeList
=
falseDataList
.
stream
().
filter
(
x
->
DateUtils
.
getDurationSeconds
(
finalDurationTime
,
x
.
get
(
"createdTime"
),
"yyyy-MM-dd HH:mm:ss"
)
>=
0
).
collect
(
Collectors
.
toList
());
if
(
CollectionUtils
.
isNotEmpty
(
timeList
))
{
nowStrLong
=
timeList
.
get
(
timeList
.
size
()
-
1
).
get
(
"createdTime"
);
}
}
}
}
// 结果向上取整
double
ceil
=
Math
.
ceil
(
Math
.
abs
(
DateUtils
.
getDurationSeconds
(
durationTime
,
nowStrLong
,
DateUtils
.
DATE_TIME_PATTERN
))
*
1.0
/
Double
.
parseDouble
(
PressurePumpRelateEnum
.
ONE_HOUR_MINUTE
.
getValue
()));
return
new
Double
(
ceil
).
longValue
();
}
@Override
public
double
getAllPressurePumpPipePressureDiff
(
List
<
IotDataVO
>
redisDataList
,
List
<
IotDataVO
>
redisDataPipeList
,
String
nowStrLong
,
String
minutes
)
{
if
(
CollectionUtils
.
isNotEmpty
(
redisDataList
))
{
public
double
getAllPressurePumpPipePressureDiff
(
List
<
IotDataVO
>
redisDataList
,
List
<
IotDataVO
>
redisDataPipeList
,
List
<
Map
<
String
,
String
>>
iotDataList
,
List
<
Map
<
String
,
String
>>
iotDataPipeList
,
String
nowStrLong
,
String
minutes
)
{
if
(
CollectionUtils
.
isNotEmpty
(
redisDataList
)
&&
CollectionUtils
.
isNotEmpty
(
redisDataPipeList
)
)
{
IotDataVO
iotDataVO
=
redisDataList
.
get
(
0
);
String
value
=
iotDataVO
.
getValue
().
toString
();
if
(
PressurePumpRelateEnum
.
IOT_INDEX_VALUE_TRUE
.
getValue
().
equalsIgnoreCase
(
value
))
{
List
<
IotDataVO
>
falseDataList
=
get
Iot
DataFilterList
(
redisDataList
,
PressurePumpRelateEnum
.
IOT_INDEX_VALUE_FALSE
.
getValue
());
List
<
IotDataVO
>
falseDataList
=
get
Redis
DataFilterList
(
redisDataList
,
PressurePumpRelateEnum
.
IOT_INDEX_VALUE_FALSE
.
getValue
());
if
(
CollectionUtils
.
isNotEmpty
(
falseDataList
))
{
String
createdTime
=
falseDataList
.
get
(
0
).
getCreatedTime
();
try
{
Date
stop5BeforeDate
=
DateUtils
.
dateAddMinutes
(
DateUtils
.
convertStrToDate
(
createdTime
,
DateUtils
.
DATE_TIME_PATTERN
),
Integer
.
parseInt
(
minutes
));
// 获取指定之前时间,指定值数据
List
<
IotDataVO
>
dataFilterList
=
get
Iot
DataFilterList
(
redisDataPipeList
,
value
,
stop5BeforeDate
);
List
<
IotDataVO
>
dataFilterList
=
get
Redis
DataFilterList
(
redisDataPipeList
,
value
,
stop5BeforeDate
);
if
(
CollectionUtils
.
isNotEmpty
(
dataFilterList
))
{
double
val1
=
Double
.
parseDouble
(
redisDataPipeList
.
get
(
0
).
getValue
().
toString
());
double
val2
=
Double
.
parseDouble
(
dataFilterList
.
get
(
dataFilterList
.
size
()
-
1
).
getValue
().
toString
());
...
...
@@ -188,6 +294,52 @@ public class PressurePumpServiceImpl implements IPressurePumpService {
}
}
}
return
getAllPressurePumpPipePressureDiffByIot
(
iotDataList
,
iotDataPipeList
);
}
private
double
getAllPressurePumpPipePressureDiffByIot
(
List
<
Map
<
String
,
String
>>
iotDataList
,
List
<
Map
<
String
,
String
>>
iotDataPipeList
)
{
if
(
CollectionUtils
.
isNotEmpty
(
iotDataList
)
&&
CollectionUtils
.
isNotEmpty
(
iotDataPipeList
))
{
String
value
=
iotDataList
.
get
(
0
).
get
(
pressurePumpStart
);
if
(
"true"
.
equalsIgnoreCase
(
value
))
{
List
<
Map
<
String
,
String
>>
falseDataList
=
getIotDataFilterList
(
iotDataList
,
PressurePumpRelateEnum
.
IOT_INDEX_VALUE_FALSE
.
getValue
());
if
(
CollectionUtils
.
isNotEmpty
(
falseDataList
))
{
String
createdTime
=
falseDataList
.
get
(
0
).
get
(
"createdTime"
);
try
{
Date
stop5BeforeDate
=
DateUtils
.
dateAddMinutes
(
DateUtils
.
convertStrToDate
(
createdTime
,
DateUtils
.
DATE_TIME_PATTERN
),
Integer
.
parseInt
(
PressurePumpRelateEnum
.
PRESSURE_PUMP_START_BEFORE_MINUTE
.
getValue
()));
// 获取指定之前时间,指定值数据
List
<
Map
<
String
,
String
>>
dataFilterList
=
getIotDataFilterList
(
iotDataPipeList
,
value
,
stop5BeforeDate
);
if
(
CollectionUtils
.
isNotEmpty
(
dataFilterList
))
{
double
val1
=
Double
.
parseDouble
(
iotDataPipeList
.
get
(
0
).
get
(
pressurePumpPipePressure
));
double
val2
=
Double
.
parseDouble
(
dataFilterList
.
get
(
dataFilterList
.
size
()
-
1
).
get
(
pressurePumpPipePressure
));
return
Math
.
abs
(
val1
-
val2
);
}
}
catch
(
ParseException
e
)
{
log
.
error
(
"获取所有稳压泵管网压力差失败:{}"
,
e
.
getMessage
());
}
}
}
}
return
0
;
}
@Override
public
List
<
Map
<
String
,
String
>>
getIotTopSingleField
(
String
top
,
String
productKey
,
String
deviceName
,
String
key
,
String
fieldKey
)
{
ResponseModel
responseModel
=
iotFeign
.
topSingleField
(
top
,
productKey
,
deviceName
,
key
,
fieldKey
);
if
(
responseModel
!=
null
&&
200
==
responseModel
.
getStatus
())
{
String
json
=
JSON
.
toJSONString
(
responseModel
.
getResult
());
return
(
List
<
Map
<
String
,
String
>>)
JSONArray
.
parse
(
json
);
}
return
Collections
.
emptyList
();
}
@Override
public
List
<
Map
<
String
,
String
>>
getIotCommonListData
(
String
startTime
,
String
endTime
,
String
prefix
,
String
suffix
,
String
key
,
String
fieldKey
)
{
ResponseModel
responseModel
=
iotFeign
.
selectListNew
(
prefix
,
suffix
,
startTime
,
endTime
,
key
,
fieldKey
);
if
(
responseModel
!=
null
&&
200
==
responseModel
.
getStatus
())
{
String
json
=
JSON
.
toJSONString
(
responseModel
.
getResult
());
return
(
List
<
Map
<
String
,
String
>>)
JSONArray
.
parse
(
json
);
}
return
Collections
.
emptyList
();
}
}
amos-boot-system-equip/src/main/resources/json/nameKeyInfo.json
View file @
b0928098
...
...
@@ -4,6 +4,7 @@
"code"
:
"PressurePump"
,
"nameKey"
:
"FHS_PressurePump_Start,FHS_PipePressureDetector_PipePressure"
,
"expire"
:
14400
,
"equipmentCode"
:
"92010800KAL44"
"equipmentCode"
:
"92010800KAL44"
,
"top"
:
"100"
}
]
\ No newline at end of file
amos-boot-system-equip/src/main/resources/mapper/EquipmentSpecificMapper.xml
View file @
b0928098
...
...
@@ -1728,7 +1728,8 @@
wes.value_label valueLabel,
wes.realtime_iot_es_index_id realtimeIotSpecificIndexId,
wes.realtime_iot_index_update_date realtiemIotIndexUpdateDate,
wes.realtime_iot_index_id realtimeIotIndexId
wes.realtime_iot_index_id realtimeIotIndexId,
wes.iot_code iotCode
FROM
wl_equipment_specific wes
<where>
...
...
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