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
a96501c6
Commit
a96501c6
authored
Feb 23, 2023
by
高建强
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
item:稳压泵统计与分析新增今日累计业务
parent
0175e81f
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
125 additions
and
8 deletions
+125
-8
PressurePumpAnalysisEnum.java
...in/equipmanage/common/enums/PressurePumpAnalysisEnum.java
+2
-1
PressurePumpRelateEnum.java
...join/equipmanage/common/enums/PressurePumpRelateEnum.java
+1
-0
PressurePumpCountVo.java
...om/yeejoin/equipmanage/common/vo/PressurePumpCountVo.java
+19
-0
IPressurePumpService.java
...com/yeejoin/equipmanage/service/IPressurePumpService.java
+3
-0
EmergencyServiceImpl.java
...eejoin/equipmanage/service/impl/EmergencyServiceImpl.java
+15
-2
PressurePumpServiceImpl.java
...oin/equipmanage/service/impl/PressurePumpServiceImpl.java
+84
-5
nameKeyInfo.json
...oot-system-equip/src/main/resources/json/nameKeyInfo.json
+1
-0
No files found.
amos-boot-module/amos-boot-module-api/amos-boot-module-equip-api/src/main/java/com/yeejoin/equipmanage/common/enums/PressurePumpAnalysisEnum.java
View file @
a96501c6
...
...
@@ -16,7 +16,8 @@ public enum PressurePumpAnalysisEnum {
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_TWO("5", "5", "2小时启动", 0, "次"),
PRESSURE_PUMP_DAY_AVG
(
"5"
,
"5"
,
"今日累计启动"
,
0
,
"次"
),
PRESSURE_PUMP_PIPE
(
"6"
,
"6"
,
"管网压力"
,
"正常"
,
""
);
private
String
key
;
...
...
amos-boot-module/amos-boot-module-api/amos-boot-module-equip-api/src/main/java/com/yeejoin/equipmanage/common/enums/PressurePumpRelateEnum.java
View file @
a96501c6
...
...
@@ -17,6 +17,7 @@ public enum PressurePumpRelateEnum {
ONE_HOUR
(
"1.0"
,
"1小时"
),
TWO_HOUR
(
"2.0"
,
"2小时"
),
FOUR_HOUR
(
"4.0"
,
"4小时"
),
DAY_AVG
(
"-3"
,
"今日累计启停次数,取前3天平均值"
),
START_FIVE
(
"5"
,
"稳压泵启动5分钟"
),
PIPE_PRESSURE_DIFF
(
"0.05"
,
"管网压力差判定标准,> 0.05Mpa 异常, <= 0.05 正常"
),
PRESSURE_PUMP_START_BEFORE_MINUTE
(
"-5"
,
"稳压泵启泵前分钟数"
),
...
...
amos-boot-module/amos-boot-module-api/amos-boot-module-equip-api/src/main/java/com/yeejoin/equipmanage/common/vo/PressurePumpCountVo.java
0 → 100644
View file @
a96501c6
package
com
.
yeejoin
.
equipmanage
.
common
.
vo
;
import
lombok.Data
;
/**
* @author Gao Jianqiang
* @title: PressurePumpCountVo
* <pre>
* @description: 稳压泵统计 Vo
* </pre>
* @date 2023/2/22 16:15
*/
@Data
public
class
PressurePumpCountVo
{
private
Integer
value
;
private
String
time
;
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/service/IPressurePumpService.java
View file @
a96501c6
package
com
.
yeejoin
.
equipmanage
.
service
;
import
com.yeejoin.equipmanage.common.vo.IotDataVO
;
import
com.yeejoin.equipmanage.common.vo.PressurePumpCountVo
;
import
java.util.Date
;
import
java.util.List
;
...
...
@@ -132,4 +133,6 @@ public interface IPressurePumpService {
* @return
*/
Object
mapToObject
(
Map
<
String
,
String
>
map
,
Class
<?>
aClass
,
String
indexKey
)
throws
IllegalAccessException
,
InstantiationException
;
List
<
PressurePumpCountVo
>
getDayAvgDataList
(
List
<
Map
<
String
,
Object
>>
pumpInfoList
,
String
infoCode
,
String
equipmentCode
,
String
nameKey
,
String
bizOrgCode
,
long
countExpire
);
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/service/impl/EmergencyServiceImpl.java
View file @
a96501c6
...
...
@@ -9,6 +9,7 @@ import com.yeejoin.equipmanage.common.enums.PressurePumpRelateEnum;
import
com.yeejoin.equipmanage.common.utils.StringUtil
;
import
com.yeejoin.equipmanage.common.utils.UnitTransformUtil
;
import
com.yeejoin.equipmanage.common.vo.IotDataVO
;
import
com.yeejoin.equipmanage.common.vo.PressurePumpCountVo
;
import
com.yeejoin.equipmanage.mapper.EmergencyMapper
;
import
com.yeejoin.equipmanage.service.IEmergencyService
;
import
com.yeejoin.equipmanage.service.IEquipmentSpecificAlarmLogService
;
...
...
@@ -22,6 +23,7 @@ import org.springframework.stereotype.Service;
import
org.springframework.util.CollectionUtils
;
import
java.util.*
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
java.util.stream.Collectors
;
/**
...
...
@@ -231,10 +233,12 @@ public class EmergencyServiceImpl implements IEmergencyService {
String
pipePressureEquipmentCode
=
map
.
get
(
"pipePressureEquipmentCode"
).
toString
();
String
faultNameKey
=
map
.
get
(
"faultNameKey"
).
toString
();
String
top
=
map
.
get
(
"top"
).
toString
();
long
countExpire
=
Long
.
parseLong
(
map
.
get
(
"countExpire"
).
toString
());
// 1. 判断稳压泵整体是否故障
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
());
// 获取稳压泵数据,redis没有,从iot取
List
<
Map
<
String
,
Object
>>
pumpInfoList
=
equipmentSpecificSerivce
.
getFirePumpInfoEQ
(
equipmentCode
,
bizOrgCode
);
Map
<
String
,
List
<
IotDataVO
>>
dataMap
=
pressurePumpService
.
getDataList
(
PressurePumpRelateEnum
.
PRESSURE_PUMP
.
getValue
(),
equipmentCode
,
top
,
pressurePumpStart
,
bizOrgCode
,
null
);
List
<
IotDataVO
>
dataList
=
dataMap
.
get
(
"dataList"
);
List
<
IotDataVO
>
dataListFilterTrue
=
dataMap
.
get
(
"dataListFilterTrue"
);
...
...
@@ -254,8 +258,17 @@ public class EmergencyServiceImpl implements IEmergencyService {
int
halfFrequency
=
pressurePumpService
.
getAllPressurePumpStartFrequency
(
Double
.
parseDouble
(
PressurePumpRelateEnum
.
HALF_HOUR
.
getValue
()),
dataListFilterTrue
,
dateNow
);
PressurePumpAnalysisEnum
.
PRESSURE_PUMP_HALF
.
setValue
(
halfFrequency
);
// 5. 2小时启动
int
twoFrequency
=
pressurePumpService
.
getAllPressurePumpStartFrequency
(
Double
.
parseDouble
(
PressurePumpRelateEnum
.
TWO_HOUR
.
getValue
()),
dataListFilterTrue
,
dateNow
);
PressurePumpAnalysisEnum
.
PRESSURE_PUMP_TWO
.
setValue
(
twoFrequency
);
// int twoFrequency = pressurePumpService.getAllPressurePumpStartFrequency(Double.parseDouble(PressurePumpRelateEnum.TWO_HOUR.getValue()), dataListFilterTrue, dateNow);
// PressurePumpAnalysisEnum.PRESSURE_PUMP_TWO.setValue(twoFrequency);
// 5. 今日启动次数,前3天启动次数的均值
// 获取稳压泵数据,redis没有,从iot取
List
<
PressurePumpCountVo
>
dayAvgDataList
=
pressurePumpService
.
getDayAvgDataList
(
pumpInfoList
,
PressurePumpRelateEnum
.
PRESSURE_PUMP
.
getValue
(),
equipmentCode
,
pressurePumpStart
,
bizOrgCode
,
countExpire
);
AtomicInteger
dayAvgFrequency
=
new
AtomicInteger
();
if
(!
CollectionUtils
.
isEmpty
(
dayAvgDataList
))
{
dayAvgDataList
.
forEach
(
x
->
dayAvgFrequency
.
addAndGet
(
x
.
getValue
()));
}
// int dayAvgFrequency = pressurePumpService.getAllPressurePumpStartDayAvgFrequency(Double.parseDouble(PressurePumpRelateEnum.DAY_AVG.getValue()), dataListFilterTrue, dateNow);
PressurePumpAnalysisEnum
.
PRESSURE_PUMP_DAY_AVG
.
setValue
(
dayAvgFrequency
.
get
());
// 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
());
...
...
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/service/impl/PressurePumpServiceImpl.java
View file @
a96501c6
...
...
@@ -7,6 +7,7 @@ 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.common.vo.PressurePumpCountVo
;
import
com.yeejoin.equipmanage.fegin.IotFeign
;
import
com.yeejoin.equipmanage.service.IEquipmentSpecificSerivce
;
import
com.yeejoin.equipmanage.service.IPressurePumpService
;
...
...
@@ -68,23 +69,37 @@ public class PressurePumpServiceImpl implements IPressurePumpService {
for
(
IotDataVO
vo
:
iotDatalist
)
{
String
key
=
vo
.
getKey
();
if
(
nameKey
.
contains
(
vo
.
getKey
()))
{
vo
.
setCreatedTime
(
nowString
);
String
[]
split
=
topic
.
split
(
"/"
);
topic
=
split
.
length
>
2
?
String
.
join
(
""
,
split
[
0
],
split
[
1
])
:
""
;
vo
.
setCreatedTime
(
nowString
);
redisUtils
.
set
(
String
.
join
(
":"
,
pressurePumpValue
,
key
,
topic
,
String
.
valueOf
(
timeMillis
)),
JSONObject
.
toJSONString
(
vo
),
expire
);
}
}
}
}
// @Async
// public void saveDataToRedis(String key, String json, long expire) {
// String pressurePumpValue = PressurePumpRelateEnum.PRESSURE_PUMP.getValue();
// // 获取配置JSON信息集合
// List<Map> list = getNameKeyInfoList(pressurePumpValue);
// if (CollectionUtils.isNotEmpty(list)) {
// Map map = list.get(0);
// String nameKey = map.get("nameKey").toString();
// int expire = Integer.parseInt(map.get("expire").toString());
// String nowString = DateUtils.getDateNowString();
// long timeMillis = System.currentTimeMillis();
// topic = split.length > 2 ? String.join("", split[0], split[1]) : "";
// redisUtils.set(topic, json, expire);
// }
// }
@Override
public
List
<
IotDataVO
>
getDataToRedis
(
String
infoCode
,
String
nameKey
,
String
iotCode
)
{
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
->
{
list
.
add
(
JSON
.
parseObject
(
redisUtils
.
get
(
x
).
toString
(),
IotDataVO
.
class
));
});
keys
.
forEach
(
x
->
list
.
add
(
JSON
.
parseObject
(
redisUtils
.
get
(
x
).
toString
(),
IotDataVO
.
class
)));
// 时间倒序排序
list
.
sort
((
t1
,
t2
)
->
t2
.
getCreatedTime
().
compareTo
(
t1
.
getCreatedTime
()));
}
...
...
@@ -114,6 +129,29 @@ public class PressurePumpServiceImpl implements IPressurePumpService {
return
list
;
}
public
List
<
PressurePumpCountVo
>
getCountDataToRedisByDateBetween
(
String
infoCode
,
String
nameKey
,
String
iotCode
,
Date
startDate
,
Date
endDate
)
{
List
<
PressurePumpCountVo
>
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
(
":"
);
String
time
=
split
.
length
>
0
?
(
split
[
split
.
length
-
1
])
:
""
;
try
{
Date
date
=
DateUtils
.
convertStrToDate
(
time
,
DateUtils
.
DATE_PATTERN
);
// 结束日期不包含今天,获取3天前数据
if
(
DateUtils
.
dateCompare
(
date
,
startDate
)
>=
0
&&
DateUtils
.
dateCompare
(
endDate
,
date
)
>
0
)
{
list
.
add
(
JSON
.
parseObject
(
redisUtils
.
get
(
x
).
toString
(),
PressurePumpCountVo
.
class
));
}
}
catch
(
ParseException
e
)
{
log
.
error
(
"getDataToRedisByDateBetween-->字符串转日期失败:{}"
,
e
.
getMessage
());
}
});
// 时间升序排序
list
.
sort
(
Comparator
.
comparing
(
PressurePumpCountVo:
:
getTime
));
}
return
list
;
}
@Override
public
List
<
Map
>
getNameKeyInfoList
(
String
code
)
{
String
json
=
null
;
...
...
@@ -247,11 +285,52 @@ public class PressurePumpServiceImpl implements IPressurePumpService {
}
else
{
field
.
set
(
o
,
map
.
get
(
field
.
getName
()));
}
}
return
o
;
}
@Override
public
List
<
PressurePumpCountVo
>
getDayAvgDataList
(
List
<
Map
<
String
,
Object
>>
pumpInfoList
,
String
infoCode
,
String
equipmentCode
,
String
nameKey
,
String
bizOrgCode
,
long
countExpire
)
{
try
{
Date
dateNow
=
DateUtils
.
convertStrToDate
(
DateUtils
.
getDateNowString
(),
DateUtils
.
DATE_PATTERN
);
Date
beforeDate
=
DateUtils
.
dateAddDays
(
dateNow
,
Integer
.
parseInt
(
PressurePumpRelateEnum
.
DAY_AVG
.
getValue
()));
List
<
PressurePumpCountVo
>
dataList
=
getCountDataToRedisByDateBetween
(
PressurePumpRelateEnum
.
PRESSURE_PUMP
.
getValue
(),
nameKey
,
null
,
beforeDate
,
dateNow
);
if
(
CollectionUtils
.
isNotEmpty
(
pumpInfoList
)
&&
(
CollectionUtils
.
isEmpty
(
dataList
)
||
dataList
.
size
()
<
Math
.
abs
(
Integer
.
parseInt
(
PressurePumpRelateEnum
.
DAY_AVG
.
getValue
()))))
{
// iot获取数据,返回并存储redis
String
startTime
=
DateUtils
.
convertDateToString
(
dateNow
,
DateUtils
.
DATE_PATTERN
);
String
endTime
=
DateUtils
.
convertDateToString
(
beforeDate
,
DateUtils
.
DATE_PATTERN
);
Object
iotCode
=
pumpInfoList
.
get
(
0
).
get
(
"iotCode"
);
String
prefix
=
ObjectUtils
.
isEmpty
(
iotCode
)
?
""
:
iotCode
.
toString
().
substring
(
0
,
8
);
dataList
=
getIotCountData
(
startTime
,
endTime
,
infoCode
,
prefix
,
null
,
PressurePumpRelateEnum
.
IOT_INDEX_VALUE_TRUE
.
getValue
(),
nameKey
,
countExpire
);
}
return
dataList
;
}
catch
(
ParseException
e
)
{
log
.
error
(
"获取稳压泵天启动次数失败:{}"
,
e
.
getMessage
());
}
return
Collections
.
emptyList
();
}
private
List
<
PressurePumpCountVo
>
getIotCountData
(
String
startTime
,
String
endTime
,
String
infoCode
,
String
prefix
,
String
suffix
,
String
key
,
String
fieldKey
,
long
expire
)
{
List
<
Map
<
String
,
String
>>
dataMapList
=
getIotCommonListData
(
startTime
,
endTime
,
prefix
,
suffix
,
key
,
fieldKey
);
if
(
CollectionUtils
.
isNotEmpty
(
dataMapList
)
&&
StringUtils
.
isNotBlank
(
key
))
{
Map
<
String
,
List
<
Map
<
String
,
String
>>>
dataMap
=
dataMapList
.
stream
().
filter
(
y
->
y
.
containsKey
(
PressurePumpRelateEnum
.
CREATED_TIME
.
getValue
())
&&
y
.
get
(
fieldKey
)
!=
null
&&
key
.
equalsIgnoreCase
(
y
.
get
(
fieldKey
))).
collect
(
Collectors
.
groupingBy
(
e
->
e
.
get
(
PressurePumpRelateEnum
.
CREATED_TIME
.
getValue
()).
substring
(
0
,
10
)));
if
(!
dataMap
.
isEmpty
())
{
List
<
PressurePumpCountVo
>
dataList
=
new
ArrayList
<>();
String
iotCode
=
String
.
join
(
""
,
StringUtils
.
isNotEmpty
(
prefix
)
?
prefix
:
""
,
StringUtils
.
isNotEmpty
(
suffix
)
?
suffix
:
""
);
for
(
String
time
:
dataMap
.
keySet
())
{
PressurePumpCountVo
countVo
=
new
PressurePumpCountVo
();
countVo
.
setTime
(
time
);
countVo
.
setValue
(
dataMap
.
get
(
key
).
size
());
// 获取的数据存储到redis
String
topic
=
String
.
join
(
":"
,
infoCode
,
fieldKey
,
iotCode
,
time
);
redisUtils
.
set
(
topic
,
JSON
.
toJSONString
(
countVo
),
expire
);
}
return
dataList
;
}
}
return
Collections
.
emptyList
();
}
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
());
}
...
...
amos-boot-system-equip/src/main/resources/json/nameKeyInfo.json
View file @
a96501c6
...
...
@@ -5,6 +5,7 @@
"nameKey"
:
"FHS_PressurePump_Start,FHS_PipePressureDetector_PipePressure"
,
"faultNameKey"
:
"FHS_PressurePump_Fault,FHS_PressurePump_RunFault,FHS_PressurePump_OverLoadFault"
,
"expire"
:
14400
,
"countExpire"
:
1209600
,
"equipmentCode"
:
"92010800KAL44"
,
"pipePressureEquipmentCode"
:
"92011000T5Q44"
,
"top"
:
"100"
...
...
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