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
098cbf6c
Commit
098cbf6c
authored
Feb 24, 2023
by
高建强
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
item:稳压泵启动次数展示弹窗接口新增
parent
c5e0e901
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
149 additions
and
30 deletions
+149
-30
DateUtils.java
...ava/com/yeejoin/amos/boot/biz/common/utils/DateUtils.java
+32
-0
PressurePumpCountVo.java
...om/yeejoin/equipmanage/common/vo/PressurePumpCountVo.java
+3
-0
EmergencyController.java
...m/yeejoin/equipmanage/controller/EmergencyController.java
+19
-0
IEmergencyService.java
...va/com/yeejoin/equipmanage/service/IEmergencyService.java
+9
-0
IPressurePumpService.java
...com/yeejoin/equipmanage/service/IPressurePumpService.java
+2
-0
EmergencyServiceImpl.java
...eejoin/equipmanage/service/impl/EmergencyServiceImpl.java
+46
-6
PressurePumpServiceImpl.java
...oin/equipmanage/service/impl/PressurePumpServiceImpl.java
+38
-24
No files found.
amos-boot-biz-common/src/main/java/com/yeejoin/amos/boot/biz/common/utils/DateUtils.java
View file @
098cbf6c
...
...
@@ -26,6 +26,7 @@ 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_PATTERN
=
"MM-dd"
;
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"
;
...
...
@@ -911,6 +912,8 @@ public class DateUtils {
while
(
true
)
{
if
(
MONTH_DAY_HOUR_PATTERN
.
equals
(
pattern
))
{
date
=
dateAddMinutes
(
date
,
60
);
}
else
if
(
MONTH_DAY_PATTERN
.
equals
(
pattern
))
{
date
=
dateAddDays
(
date
,
1
);
}
else
{
date
=
dateAddMinutes
(
date
,
1
);
}
...
...
@@ -1012,4 +1015,33 @@ public class DateUtils {
final
LocalDateTime
end
=
LocalDateTime
.
parse
(
sdf
.
format
(
endTime
),
DateTimeFormatter
.
ofPattern
(
pattern
));
return
Duration
.
between
(
start
,
end
).
toHours
();
}
/**
* 获取两个时间段之间的天数
*
* @param startTime 开始时间
* @param endTime 结束时间
* @param pattern 时间格式
* @return 天数
*/
public
static
Long
getDurationDays
(
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
).
toDays
();
}
/**
* 获取两个时间段之间的天数
*
* @param startTime 开始时间
* @param endTime 结束时间
* @param pattern 时间格式
* @return 天数
*/
public
static
Long
getDurationDays
(
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
).
toDays
();
}
}
amos-boot-module/amos-boot-module-api/amos-boot-module-equip-api/src/main/java/com/yeejoin/equipmanage/common/vo/PressurePumpCountVo.java
View file @
098cbf6c
...
...
@@ -16,4 +16,7 @@ public class PressurePumpCountVo {
private
Integer
value
;
private
String
time
;
private
String
iotCode
;
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/controller/EmergencyController.java
View file @
098cbf6c
...
...
@@ -613,6 +613,25 @@ public class EmergencyController extends AbstractBaseController {
@PersonIdentify
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@GetMapping
(
value
=
"/getPressurePumpStartStatistics"
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"四横八纵-稳压泵启动统计"
,
notes
=
"四横八纵-稳压泵启动统计"
)
public
ResponseModel
getPressurePumpStartStatistics
(
@RequestParam
String
startTime
,
@RequestParam
String
endTime
,
@RequestParam
(
required
=
false
)
String
bizOrgCode
)
{
if
(
StringUtils
.
isEmpty
(
bizOrgCode
))
{
ReginParams
reginParams
=
getSelectedOrgInfo
();
ReginParams
.
PersonIdentity
personIdentity
=
reginParams
.
getPersonIdentity
();
if
(!
ValidationUtil
.
isEmpty
(
personIdentity
))
{
bizOrgCode
=
personIdentity
.
getBizOrgCode
();
if
(
bizOrgCode
==
null
)
{
return
CommonResponseUtil
.
success
(
Collections
.
EMPTY_MAP
);
}
}
}
return
CommonResponseUtil
.
success
(
iEmergencyService
.
getPressurePumpStartStatistics
(
startTime
,
endTime
,
bizOrgCode
));
}
@PersonIdentify
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@GetMapping
(
value
=
"/getPressurePumpDay"
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"四横八纵-稳压泵诊断分析"
,
notes
=
"四横八纵-稳压泵诊断分析"
)
public
ResponseModel
getPressurePumpDay
(
@RequestParam
(
required
=
false
)
String
bizOrgCode
)
{
...
...
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/service/IEmergencyService.java
View file @
098cbf6c
...
...
@@ -62,4 +62,13 @@ public interface IEmergencyService {
Page
<
Map
<
String
,
Object
>>
alarmList
(
Page
<
Map
<
String
,
Object
>>
page
,
String
bizOrgCode
,
List
<
String
>
types
,
List
<
String
>
emergencyLevels
,
String
name
,
Integer
cleanStatus
,
Integer
handleStatus
);
List
<
PressurePumpCountVo
>
getPressurePumpDay
(
String
bizOrgCode
);
/**
* 稳压泵启动统计
* @param startTime
* @param endTime
* @param bizOrgCode
* @return
*/
Map
<
String
,
Object
>
getPressurePumpStartStatistics
(
String
startTime
,
String
endTime
,
String
bizOrgCode
);
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/service/IPressurePumpService.java
View file @
098cbf6c
...
...
@@ -137,4 +137,6 @@ public interface IPressurePumpService {
List
<
PressurePumpCountVo
>
getDayAvgDataList
(
List
<
Map
<
String
,
Object
>>
pumpInfoList
,
String
infoCode
,
String
countRedisKey
,
String
equipmentCode
,
String
nameKey
,
String
bizOrgCode
,
long
countExpire
);
List
<
PressurePumpCountVo
>
getIotCountData
(
String
startTime
,
String
endTime
,
String
infoCode
,
String
countRedisKey
,
String
prefix
,
String
suffix
,
String
key
,
String
fieldKey
,
long
expire
);
Map
<
String
,
List
<
PressurePumpCountVo
>>
getDateRangeCountList
(
List
<
Map
<
String
,
Object
>>
pumpInfoList
,
String
startTime
,
String
endTime
,
String
infoCode
,
String
countRedisKey
,
String
equipmentCode
,
String
nameKey
,
long
countExpire
,
String
bizOrgCode
);
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/service/impl/EmergencyServiceImpl.java
View file @
098cbf6c
...
...
@@ -2,8 +2,6 @@ package com.yeejoin.equipmanage.service.impl;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.yeejoin.amos.boot.biz.common.utils.DateUtils
;
import
com.yeejoin.amos.boot.biz.common.utils.RedisUtils
;
import
com.yeejoin.amos.component.robot.AmosRequestContext
;
import
com.yeejoin.equipmanage.common.entity.EquipmentSpecificAlarmLog
;
import
com.yeejoin.equipmanage.common.enums.IndexStatusEnum
;
import
com.yeejoin.equipmanage.common.enums.PressurePumpAnalysisEnum
;
...
...
@@ -19,6 +17,7 @@ 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.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.scheduling.annotation.Scheduled
;
...
...
@@ -266,9 +265,6 @@ public class EmergencyServiceImpl implements IEmergencyService {
// 4. 半小时启动
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);
// 5. 今日启动次数,前3天启动次数的均值
// 获取稳压泵数据,redis没有,从iot取
List
<
PressurePumpCountVo
>
dayAvgDataList
=
pressurePumpService
.
getDayAvgDataList
(
pumpInfoList
,
PressurePumpRelateEnum
.
PRESSURE_PUMP
.
getValue
(),
countRedisKey
,
equipmentCode
,
pressurePumpStart
,
bizOrgCode
,
countExpire
);
...
...
@@ -276,7 +272,6 @@ public class EmergencyServiceImpl implements IEmergencyService {
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
(
Math
.
round
(
dayAvgFrequency
.
get
()
/
Math
.
abs
(
Integer
.
parseInt
(
PressurePumpRelateEnum
.
DAY_AVG
.
getValue
()))));
// 6. 管网压力状态
double
pressureDiff
=
pressurePumpService
.
getAllPressurePumpPipePressureDiff
(
dataList
,
dataPipeList
,
PressurePumpRelateEnum
.
PRESSURE_PUMP_START_BEFORE_MINUTE
.
getValue
());
...
...
@@ -286,6 +281,51 @@ public class EmergencyServiceImpl implements IEmergencyService {
}
@Override
public
Map
<
String
,
Object
>
getPressurePumpStartStatistics
(
String
startTime
,
String
endTime
,
String
bizOrgCode
)
{
Map
<
String
,
Object
>
map
=
new
LinkedHashMap
<>();
if
(
StringUtils
.
isNotBlank
(
startTime
)
&&
StringUtils
.
isNotBlank
(
endTime
)
&&
StringUtils
.
isNotBlank
(
bizOrgCode
))
{
// 从 json 配置文件获取配置信息
List
<
Map
>
infoList
=
pressurePumpService
.
getNameKeyInfoList
(
PressurePumpRelateEnum
.
PRESSURE_PUMP
.
getValue
());
if
(!
CollectionUtils
.
isEmpty
(
infoList
))
{
Map
infoMap
=
infoList
.
get
(
0
);
String
equipmentCode
=
infoMap
.
get
(
"equipmentCode"
).
toString
();
String
countRedisKey
=
infoMap
.
get
(
"countRedisKey"
).
toString
();
long
countExpire
=
Long
.
parseLong
(
infoMap
.
get
(
"countExpire"
).
toString
());
// 获取所有稳压泵信息
List
<
Map
<
String
,
Object
>>
pumpInfoList
=
equipmentSpecificSerivce
.
getFirePumpInfoEQ
(
equipmentCode
,
bizOrgCode
);
// 从redis获取日期范围数据,没有从iot获取。redis存储数据并返回
Map
<
String
,
List
<
PressurePumpCountVo
>>
dateRangeCountMap
=
pressurePumpService
.
getDateRangeCountList
(
pumpInfoList
,
startTime
,
endTime
,
PressurePumpRelateEnum
.
PRESSURE_PUMP
.
getValue
(),
countRedisKey
,
equipmentCode
,
pressurePumpStart
,
countExpire
,
bizOrgCode
);
if
(!
CollectionUtils
.
isEmpty
(
pumpInfoList
))
{
List
<
String
>
timeList
=
DateUtils
.
getTimeStrListByStartAndEnd
(
startTime
,
endTime
,
DateUtils
.
MONTH_DAY_PATTERN
);
List
<
Map
<
String
,
Object
>>
yDataList
=
new
ArrayList
<>();
for
(
Map
<
String
,
Object
>
pumpMap
:
pumpInfoList
)
{
Object
iotCode
=
pumpMap
.
get
(
"iotCode"
);
Map
<
String
,
Object
>
dataMap
=
new
HashMap
<>();
List
<
Integer
>
dataList
=
new
ArrayList
<>();
for
(
String
time
:
timeList
)
{
if
(!
ObjectUtils
.
isEmpty
(
iotCode
)
&&
!
CollectionUtils
.
isEmpty
(
dateRangeCountMap
))
{
String
iotCodeStr
=
iotCode
.
toString
();
List
<
PressurePumpCountVo
>
countVoList
=
dateRangeCountMap
.
get
(
iotCodeStr
);
Map
<
String
,
List
<
PressurePumpCountVo
>>
collect
=
countVoList
.
stream
().
collect
(
Collectors
.
groupingBy
(
PressurePumpCountVo:
:
getTime
));
List
<
PressurePumpCountVo
>
data
=
collect
.
get
(
"2023-"
+
time
);
dataList
.
add
(
CollectionUtils
.
isEmpty
(
data
)
?
0
:
data
.
get
(
0
).
getValue
());
}
else
{
dataList
.
add
(
0
);
}
}
dataMap
.
put
(
"name"
,
pumpMap
.
get
(
"name"
));
dataMap
.
put
(
"data"
,
dataList
);
yDataList
.
add
(
dataMap
);
}
map
.
put
(
"xData"
,
timeList
);
map
.
put
(
"yData"
,
yDataList
);
}
}
}
return
map
;
}
@Override
public
Map
<
String
,
Object
>
getPressurePumpStatusChart
(
String
startTime
,
String
endTime
,
String
bizOrgCode
)
{
Map
<
String
,
Object
>
map
=
new
LinkedHashMap
<>();
try
{
...
...
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/service/impl/PressurePumpServiceImpl.java
View file @
098cbf6c
...
...
@@ -78,22 +78,6 @@ public class PressurePumpServiceImpl implements IPressurePumpService {
}
}
// @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
<>();
...
...
@@ -324,6 +308,7 @@ public class PressurePumpServiceImpl implements IPressurePumpService {
countVo
.
setValue
(
dataMap
.
get
(
time
).
size
());
// 获取的数据存储到redis
String
topic
=
String
.
join
(
":"
,
infoCode
,
countRedisKey
,
fieldKey
,
iotCode
,
time
);
countVo
.
setIotCode
(
topic
);
redisUtils
.
set
(
topic
,
JSON
.
toJSONString
(
countVo
),
expire
);
dataList
.
add
(
countVo
);
}
...
...
@@ -333,17 +318,46 @@ public class PressurePumpServiceImpl implements IPressurePumpService {
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
());
}
private
List
<
IotDataVO
>
getDataListFilter
(
List
<
IotDataVO
>
dataList
,
String
value
,
Date
beforeDate
)
{
if
(
beforeDate
!=
null
)
{
return
dataList
.
stream
().
filter
(
x
->
DateUtils
.
dateCompare
(
DateUtils
.
longStr2Date
(
x
.
getCreatedTime
()),
beforeDate
)
>=
0
&&
value
.
equalsIgnoreCase
(
x
.
getValue
().
toString
())).
collect
(
Collectors
.
toList
());
@Override
public
Map
<
String
,
List
<
PressurePumpCountVo
>>
getDateRangeCountList
(
List
<
Map
<
String
,
Object
>>
pumpInfoList
,
String
startTime
,
String
endTime
,
String
infoCode
,
String
countRedisKey
,
String
equipmentCode
,
String
nameKey
,
long
countExpire
,
String
bizOrgCode
)
{
Map
<
String
,
List
<
PressurePumpCountVo
>>
dataMap
=
new
HashMap
<>();
try
{
if
(
CollectionUtils
.
isNotEmpty
(
pumpInfoList
))
{
for
(
Map
<
String
,
Object
>
map
:
pumpInfoList
)
{
// iot获取数据,返回并存储redis
Object
iotCode
=
map
.
get
(
"iotCode"
);
if
(!
ObjectUtils
.
isEmpty
(
iotCode
))
{
String
iotCodeStr
=
iotCode
.
toString
();
Date
startDate
=
DateUtils
.
convertStrToDate
(
startTime
,
DateUtils
.
DATE_PATTERN
);
Date
endDate
=
DateUtils
.
convertStrToDate
(
endTime
,
DateUtils
.
DATE_PATTERN
);
List
<
PressurePumpCountVo
>
dataList
=
getCountDataToRedisByDateBetween
(
PressurePumpRelateEnum
.
PRESSURE_PUMP
.
getValue
(),
countRedisKey
,
nameKey
,
iotCodeStr
,
startDate
,
endDate
);
Long
days
=
DateUtils
.
getDurationDays
(
startTime
,
endTime
,
DateUtils
.
DATE_TIME_PATTERN
);
if
(
CollectionUtils
.
isEmpty
(
dataList
)
||
(
CollectionUtils
.
isNotEmpty
(
dataList
)
&&
dataList
.
size
()
<
days
))
{
String
prefix
=
ObjectUtils
.
isEmpty
(
iotCode
)
?
""
:
iotCodeStr
.
substring
(
0
,
8
);
String
suffix
=
ObjectUtils
.
isEmpty
(
iotCode
)
?
""
:
iotCodeStr
.
substring
(
8
);
dataList
=
getIotCountData
(
startTime
,
endTime
,
infoCode
,
countRedisKey
,
prefix
,
suffix
,
PressurePumpRelateEnum
.
IOT_INDEX_VALUE_TRUE
.
getValue
(),
nameKey
,
countExpire
);
dataMap
.
put
(
iotCodeStr
,
dataList
);
}
}
}
}
}
catch
(
ParseException
e
)
{
log
.
error
(
"获取稳压泵范围启动统计失败:{}"
,
e
.
getMessage
());
}
return
data
List
.
stream
().
filter
(
x
->
value
.
equalsIgnoreCase
(
x
.
getValue
().
toString
())).
collect
(
Collectors
.
toList
())
;
return
data
Map
;
}
// 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());
// }
//
// private List<IotDataVO> getDataListFilter(List<IotDataVO> dataList, String value, Date beforeDate) {
// if (beforeDate != null) {
// return dataList.stream().filter(x -> DateUtils.dateCompare(DateUtils.longStr2Date(x.getCreatedTime()), beforeDate) >= 0 && value.equalsIgnoreCase(x.getValue().toString())).collect(Collectors.toList());
// }
// return dataList.stream().filter(x -> value.equalsIgnoreCase(x.getValue().toString())).collect(Collectors.toList());
// }
private
List
<
IotDataVO
>
getDataListFilter
(
List
<
IotDataVO
>
dataList
,
Date
beforeDate
)
{
if
(
beforeDate
!=
null
)
{
return
dataList
.
stream
().
filter
(
x
->
DateUtils
.
dateCompare
(
DateUtils
.
longStr2Date
(
x
.
getCreatedTime
()),
beforeDate
)
>=
0
).
collect
(
Collectors
.
toList
());
...
...
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