Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
YeeAmosFireAutoSysRoot
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
station
YeeAmosFireAutoSysRoot
Commits
c747033e
Commit
c747033e
authored
May 27, 2020
by
吴江
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复冲突代码
parent
35d85995
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
160 additions
and
164 deletions
+160
-164
RiskSourceServiceImpl.java
...amos/fas/business/service/impl/RiskSourceServiceImpl.java
+160
-164
No files found.
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/service/impl/RiskSourceServiceImpl.java
View file @
c747033e
...
...
@@ -4,7 +4,6 @@ package com.yeejoin.amos.fas.business.service.impl;
import
java.math.BigDecimal
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.HashSet
;
...
...
@@ -128,15 +127,15 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
private
final
Logger
log
=
LoggerFactory
.
getLogger
(
RiskSourceServiceImpl
.
class
);
private
static
final
String
DATETYPE_YYYYMMDD
=
"yyyyMMdd"
;
//
天
private
static
final
String
DATETYPE_YYYYMMDD
=
"yyyyMMdd"
;
//
天
private
static
final
String
DATETYPE_YYYYWW
=
"yyyyWW"
;
//
周
private
static
final
String
DATETYPE_YYYYWW
=
"yyyyWW"
;
//
周
private
static
final
String
DATETYPE_YYYYS
=
"yyyyS"
;
//
季节
private
static
final
String
DATETYPE_YYYYS
=
"yyyyS"
;
//
季节
private
static
final
String
DATETYPE_YYYYMM
=
"yyyyMM"
;
//
月
private
static
final
String
DATETYPE_YYYYMM
=
"yyyyMM"
;
//
月
private
static
final
String
DATETYPE_YYYY
=
"yyyy"
;
//
年
private
static
final
String
DATETYPE_YYYY
=
"yyyy"
;
//
年
@Autowired
private
IRiskSourceDao
iRiskSourceDao
;
...
...
@@ -144,6 +143,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
@Autowired
private
AppMessagePushService
appMessagePushService
;
@Autowired
private
IRiskLevelDao
riskLevelDao
;
...
...
@@ -174,6 +174,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
@Autowired
private
IRiskLevelDao
iRiskLevelDao
;
@Autowired
private
RemoteSecurityService
remoteSecurityService
;
...
...
@@ -244,7 +245,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
if
(
oldRiskSource1
.
isPresent
())
{
oldRiskSource
=
oldRiskSource1
.
get
();
}
if
(
id
==
0
)
{
//
新增
if
(
id
==
0
)
{
//
新增
riskSource
.
setStatus
(
FasConstant
.
RISK_SOURCE_STATUS_NORMAL
);
riskSource
.
setCreateDate
(
new
Date
());
}
else
{
// 更新
...
...
@@ -267,14 +268,18 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
int
count
=
iRiskSourceDao
.
countByParentId
(
rId
);
Optional
<
RiskSource
>
rs
=
iRiskSourceDao
.
findById
(
rId
);
rs
.
ifPresent
(
riskSource
->
parentIds
.
add
(
riskSource
.
getParentId
()));
if
(
parentIds
.
contains
(
0
l
)){
throw
new
YeeException
(
"公司节点不能删除"
);
}
if
(
count
>
0
)
{
throw
new
YeeException
(
"该数据有关联子项,请先删除子项数据"
);
}
iRiskSourceDao
.
deleteById
(
rId
);
}
// 1.重新计算rpn
List
<
Long
>
existIds
=
parentIds
.
stream
().
filter
(
e
->
iRiskSourceDao
.
findById
(
e
).
isPresent
())
.
collect
(
Collectors
.
toList
());
//1.重新计算rpn
List
<
Long
>
existIds
=
parentIds
.
stream
().
filter
(
e
->
iRiskSourceDao
.
findById
(
e
).
isPresent
()
).
collect
(
Collectors
.
toList
());
RsDataQueue
rs
=
RsDataQueue
.
getInstance
();
existIds
.
forEach
(
rs:
:
addRiskSourcePointDeleteMessage
);
}
...
...
@@ -286,6 +291,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
return
new
PageImpl
<>(
content
,
param
,
total
);
}
@Override
public
List
<
Map
>
queryForRegion
()
{
List
<
Map
>
result
=
riskSourceMapper
.
queryForRegion
();
...
...
@@ -298,6 +304,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
return
result
;
}
@Override
public
Map
queryFor3DStatistics
()
{
Map
<
String
,
List
>
result
=
riskSourceMapper
.
statistics3dCount
();
...
...
@@ -307,11 +314,13 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
return
result
;
}
@Override
public
List
<
Map
>
queryRPNReport
()
{
return
riskSourceMapper
.
queryRPNReport
();
}
@Override
public
Map
queryForRiseUp
()
throws
Exception
{
Map
<
String
,
Map
>
result
=
new
HashMap
<>();
...
...
@@ -324,17 +333,18 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
SimpleDateFormat
format
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
//
当月的升上率
//
当月的升上率
startTime
=
format
.
format
(
timeArrayMonth
[
0
]);
endTime
=
format
.
format
(
timeArrayMonth
[
1
]);
Map
resultMonth
=
this
.
riskSourceMapper
.
queryForRiseUp
(
startTime
,
endTime
);
//
当季度的升上率
//
当季度的升上率
startTime
=
format
.
format
(
timeArraySeason
[
0
]);
endTime
=
format
.
format
(
timeArraySeason
[
1
]);
Map
resultSeason
=
this
.
riskSourceMapper
.
queryForRiseUp
(
startTime
,
endTime
);
// 当年的升上率
//当年的升上率
startTime
=
format
.
format
(
timeArrayYear
[
0
]);
endTime
=
format
.
format
(
timeArrayYear
[
1
]);
Map
resultYear
=
this
.
riskSourceMapper
.
queryForRiseUp
(
startTime
,
endTime
);
...
...
@@ -353,6 +363,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
private
static
Date
[]
getDateInfo
(
Date
date
,
String
datetype
)
throws
Exception
{
Date
[]
returnDate
=
new
Date
[
2
];
Date
start
=
null
;
Date
end
=
null
;
if
(
DATETYPE_YYYYMMDD
.
equals
(
datetype
))
{
...
...
@@ -385,16 +396,15 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
}
@Override
public
List
<
RiskSourceTreeResponse
>
findRiskSourceTrees
(
)
{
return
riskSourceMapper
.
getRiskSources
(
);
public
List
<
RiskSourceTreeResponse
>
findRiskSourceTrees
(
String
compCode
)
{
return
riskSourceMapper
.
getRiskSources
(
compCode
);
}
@Override
public
List
<
FmeaEquipmentPoint
>
bindFireEquiment
(
FmeaBindParam
fmeaBindParam
)
{
Long
fmeaId
=
fmeaBindParam
.
getFmeaId
();
Long
importantEquipId
=
fmeaBindParam
.
getImportantEquipmentId
();
List
<
Long
>
equipmentPointIds
=
fmeaEquipmentPointMapper
.
listEquipmentPointIdsByEquipmentId
(
fmeaBindParam
.
getEquipmentId
());
List
<
Long
>
equipmentPointIds
=
fmeaEquipmentPointMapper
.
listEquipmentPointIdsByEquipmentId
(
fmeaBindParam
.
getEquipmentId
());
if
(!
CollectionUtils
.
isEmpty
(
equipmentPointIds
))
{
fmeaEquipmentPointMapper
.
deleteByFmeaIdAndEquipmentPointIds
(
fmeaId
,
importantEquipId
,
equipmentPointIds
);
}
...
...
@@ -410,7 +420,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
if
(!
CollectionUtils
.
isEmpty
(
returnList
)
&&
equipment
!=
null
)
{
fmeaEquipmentPointMapper
.
saveBatch
(
returnList
);
RsDataQueue
rsDataQueue
=
RsDataQueue
.
getInstance
();
rsDataQueue
.
addEquipmentMessage
(
fmeaId
,
equipment
.
getName
());
rsDataQueue
.
addEquipmentMessage
(
fmeaId
,
equipment
.
getName
());
}
return
returnList
;
}
...
...
@@ -418,8 +428,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
@Override
public
List
<
FmeaPointInputitem
>
bindPointInputitem
(
FmeaBindParam
fmeaBindParam
)
{
Long
fmeaId
=
fmeaBindParam
.
getFmeaId
();
List
<
Long
>
pointInputitemIds
=
fmeaPointInputitemMapper
.
listPointInputitemIdsByPointId
(
fmeaBindParam
.
getPointId
());
List
<
Long
>
pointInputitemIds
=
fmeaPointInputitemMapper
.
listPointInputitemIdsByPointId
(
fmeaBindParam
.
getPointId
());
if
(!
CollectionUtils
.
isEmpty
(
pointInputitemIds
))
{
fmeaPointInputitemMapper
.
deleteByFmeaIdAndPointInputitemIds
(
fmeaId
,
pointInputitemIds
);
}
...
...
@@ -444,16 +453,13 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
@Override
public
Page
<
Map
>
queryEquimentRelation
(
CommonPageable
commonPageable
,
String
equipmentId
,
String
fname
)
{
Long
total
=
fireEquipMapper
.
queryEquimentRelationCount
(
equipmentId
,
fname
);
List
<
Map
>
list
=
fireEquipMapper
.
queryEquimentRelation
(
commonPageable
.
getOffset
(),
commonPageable
.
getPageSize
(),
equipmentId
,
fname
);
List
<
Map
>
list
=
fireEquipMapper
.
queryEquimentRelation
(
commonPageable
.
getOffset
(),
commonPageable
.
getPageSize
(),
equipmentId
,
fname
);
return
new
PageImpl
<>(
list
,
commonPageable
,
total
);
}
@Override
public
List
<
Map
<
String
,
Object
>>
listEquipmentPointById
(
Long
fmeaId
,
Long
importantEquipId
,
Long
equipmentId
,
String
equipmentPointName
)
{
List
<
Map
<
String
,
Object
>>
list
=
fmeaEquipmentPointMapper
.
listEquipmentPoint
(
fmeaId
,
importantEquipId
,
equipmentId
,
equipmentPointName
);
public
List
<
Map
<
String
,
Object
>>
listEquipmentPointById
(
Long
fmeaId
,
Long
importantEquipId
,
Long
equipmentId
,
String
equipmentPointName
)
{
List
<
Map
<
String
,
Object
>>
list
=
fmeaEquipmentPointMapper
.
listEquipmentPoint
(
fmeaId
,
importantEquipId
,
equipmentId
,
equipmentPointName
);
if
(
CollectionUtils
.
isEmpty
(
list
))
{
return
Lists
.
newArrayList
();
}
...
...
@@ -464,7 +470,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
@Override
@Async
public
String
processFireEqumtData
(
FireEquimentDataRo
deviceData
)
throws
Exception
{
//
处理设备和巡检数据
//
处理设备和巡检数据
deviceData
.
setNodeState
(
deviceData
.
getValue
());
String
batchNo
=
UUID
.
randomUUID
().
toString
();
deviceData
.
setBatchNo
(
batchNo
);
...
...
@@ -482,15 +488,11 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
deviceData
.
setMonitor
(
equipment
.
getName
());
deviceData
.
setEquimentId
(
String
.
valueOf
(
equipment
.
getId
()));
// Object result = remoteRuleServer.fireRule(deviceData,
// "风险管控/fireEquiment");
// 处理返回结果
//Object result = remoteRuleServer.fireRule(deviceData, "风险管控/fireEquiment");
//处理返回结果
List
<
RiskSource
>
riskSources
=
this
.
riskSourceMapper
.
queryByFireEqument
(
deviceData
.
getFireEquimentId
());
// asymbleWithParent(batchNo, riskSources,
// FireEquimentDataRo.class.getSimpleName(),
// deviceData.getFireEquimentId(), deviceData.getNodeState(),
// null, null);
//asymbleWithParent(batchNo, riskSources, FireEquimentDataRo.class.getSimpleName(), deviceData.getFireEquimentId(), deviceData.getNodeState(), null, null);
try
{
alermContingency
(
deviceData
.
getBatchNo
(),
fireEquipment
,
equipment
);
...
...
@@ -500,9 +502,11 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
}
}
return
"SUCCESS"
;
}
public
void
alermContingency
(
String
batchNo
,
FireEquipment
fireEquipment
,
Equipment
equipment
)
throws
Exception
{
ContingencyRo
contingencyRo
=
new
ContingencyRo
();
contingencyRo
.
setBatchNo
(
batchNo
);
...
...
@@ -511,11 +515,12 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
contingencyRo
.
setFireEquipmentId
(
String
.
valueOf
(
fireEquipment
.
getId
()));
contingencyRo
.
setFireEquipmentName
(
fireEquipment
.
getName
());
contingencyRo
.
setStep
(
"0"
);
//
contingencyRo.setNodeState(deviceData.getNodeState());
//
contingencyRo.setNodeState(deviceData.getNodeState());
contingencyRo
.
setConfirm
(
"NONE"
);
contingencyRo
.
setFireTruckRoute
(
equipment
.
getFireTruckRoute
());
contingencyRo
.
setRunstep
(
false
);
contingencyRo
.
setEquipmentPosition3d
(
equipment
.
getPosition3d
());
Map
cameraInfo
=
impAndFireEquipMapper
.
queryForCamera
(
String
.
valueOf
(
equipment
.
getId
()));
if
(
cameraInfo
!=
null
)
{
...
...
@@ -544,15 +549,15 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
}
}
// Object result = remoteRuleServer.fireRuleFlow(contingencyRo,
// equipment.getReservePlan(), equipment.getName());
//Object result = remoteRuleServer.fireRuleFlow(contingencyRo, equipment.getReservePlan(), equipment.getName());
equipment
.
setName
(
"极Ⅰ高端YY换流变A相"
);
ruleTrigger
.
publish
(
contingencyRo
,
equipment
.
getReservePlan
(),
ArrayUtils
.
toArray
(
equipment
.
getName
()));
ruleTrigger
.
publish
(
contingencyRo
,
equipment
.
getReservePlan
(),
ArrayUtils
.
toArray
(
equipment
.
getName
()));
ContingencyOriginalData
contingencyOriginalData
=
new
ContingencyOriginalData
();
BeanUtils
.
copyProperties
(
contingencyRo
,
contingencyOriginalData
);
iContingencyOriginalDataDao
.
save
(
contingencyOriginalData
);
}
private
Integer
findRegionMaxLevel
(
Long
regionRiskSourceId
)
{
Integer
maxLevel
=
0
;
List
<
RiskSource
>
anomalyRiskSource
=
findAnomalyRiskSource
(
regionRiskSourceId
);
...
...
@@ -570,6 +575,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
}
private
List
<
RiskSource
>
findAnomalyRiskSource
(
Long
riskSourceId
)
{
List
<
RiskSource
>
returnList
=
new
ArrayList
<>();
List
<
RiskSource
>
childs
=
iRiskSourceDao
.
findByParentId
(
riskSourceId
);
...
...
@@ -585,18 +591,19 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
}
@Override
public
Page
<
Map
<
String
,
Object
>>
listFmeaPointInputitem
(
String
toke
,
String
product
,
String
appKey
,
Long
fmeaId
,
Integer
pageNumber
,
Integer
pageSize
)
{
public
Page
<
Map
<
String
,
Object
>>
listFmeaPointInputitem
(
String
toke
,
String
product
,
String
appKey
,
Long
fmeaId
,
Integer
pageNumber
,
Integer
pageSize
)
{
List
<
Map
<
String
,
Object
>>
content
=
Lists
.
newArrayList
();
CommonPageable
pageable
=
new
CommonPageable
(
pageNumber
,
pageSize
);
long
total
=
fmeaPointInputitemMapper
.
countByFmeaId
(
fmeaId
);
if
(
total
==
0L
)
{
return
new
PageImpl
<>(
content
,
null
,
total
);
return
new
PageImpl
<>(
content
,
pageable
,
total
);
}
content
=
fmeaPointInputitemMapper
.
listByFmeaId
(
fmeaId
,
pageNumber
,
pageSize
);
if
(!
CollectionUtils
.
isEmpty
(
content
))
{
if
(!
CollectionUtils
.
isEmpty
(
content
))
{
Set
<
String
>
userIds
=
new
HashSet
<>();
Set
<
String
>
deptIds
=
new
HashSet
<>();
for
(
Map
<
String
,
Object
>
map
:
content
)
{
for
(
Map
<
String
,
Object
>
map
:
content
)
{
String
userId
=
String
.
valueOf
(
map
.
get
(
"userId"
));
String
deptId
=
String
.
valueOf
(
map
.
get
(
"deptId"
));
userIds
.
add
(
userId
);
...
...
@@ -605,41 +612,40 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
userIds
.
remove
(
null
);
deptIds
.
remove
(
null
);
List
<
AgencyUserModel
>
users
=
new
ArrayList
<>();
if
(!
CollectionUtils
.
isEmpty
(
userIds
))
{
if
(!
CollectionUtils
.
isEmpty
(
userIds
))
{
users
=
remoteSecurityService
.
listUserByUserIds
(
toke
,
product
,
appKey
,
Joiner
.
on
(
","
).
join
(
userIds
));
}
Map
<
String
,
String
>
userMap
=
users
.
stream
()
.
collect
(
Collectors
.
toMap
(
AgencyUserModel:
:
getUserId
,
AgencyUserModel:
:
getRealName
));
Map
<
String
,
String
>
userMap
=
users
.
stream
().
collect
(
Collectors
.
toMap
(
AgencyUserModel:
:
getUserId
,
AgencyUserModel:
:
getRealName
));
List
<
DepartmentModel
>
depts
=
new
ArrayList
<>();
if
(!
CollectionUtils
.
isEmpty
(
deptIds
))
{
depts
=
remoteSecurityService
.
listDepartmentByDeptIds
(
toke
,
product
,
appKey
,
Joiner
.
on
(
","
).
join
(
deptIds
));
if
(!
CollectionUtils
.
isEmpty
(
deptIds
)){
depts
=
remoteSecurityService
.
listDepartmentByDeptIds
(
toke
,
product
,
appKey
,
Joiner
.
on
(
","
).
join
(
deptIds
));
}
Map
<
Long
,
String
>
deptMap
=
depts
.
stream
()
.
collect
(
Collectors
.
toMap
(
DepartmentModel:
:
getSequenceNbr
,
DepartmentModel:
:
getDepartmentName
));
Map
<
Long
,
String
>
deptMap
=
depts
.
stream
().
collect
(
Collectors
.
toMap
(
DepartmentModel:
:
getSequenceNbr
,
DepartmentModel:
:
getDepartmentName
));
content
.
forEach
(
e
->
{
e
.
put
(
"userName"
,
userMap
.
get
(
e
.
get
(
"userId"
)));
e
.
put
(
"deptName"
,
deptMap
.
get
(
e
.
get
(
"deptId"
)));
e
.
put
(
"tel"
,
userMap
.
get
(
String
.
valueOf
(
e
.
get
(
"deptId"
)
+
"tel"
)));
e
.
put
(
"userName"
,
userMap
.
get
(
e
.
get
(
"userId"
)));
e
.
put
(
"deptName"
,
deptMap
.
get
(
e
.
get
(
"deptId"
)));
e
.
put
(
"tel"
,
userMap
.
get
(
String
.
valueOf
(
e
.
get
(
"deptId"
)+
"tel"
)));
});
}
return
new
PageImpl
<>(
content
,
null
,
total
);
return
new
PageImpl
<>(
content
,
pageable
,
total
);
}
@Override
public
Page
<
Map
<
String
,
Object
>>
listFeamEquipmentPoint
(
Long
fmeaId
,
Integer
pageNumber
,
Integer
pageSize
)
{
long
total
=
fmeaEquipmentPointMapper
.
countByFmeaId
(
fmeaId
);
List
<
Map
<
String
,
Object
>>
content
=
fmeaEquipmentPointMapper
.
listByFmeaId
(
fmeaId
,
pageNumber
,
pageSize
);
return
new
PageImpl
<>(
content
,
null
,
total
);
return
new
PageImpl
<>(
content
,
new
CommonPageable
(
pageNumber
,
pageSize
)
,
total
);
}
@Override
public
boolean
processTaskData
(
ProtalDataRo
taskData
)
throws
Exception
{
taskData
.
setBatchNo
(
UUID
.
randomUUID
().
toString
());
//
Object result = remoteRuleServer.fireRule(taskData, "风险管控/patrol");
//
Object result = remoteRuleServer.fireRule(taskData, "风险管控/patrol");
return
true
;
}
@Override
@Async
public
void
processProtalData
(
String
toke
,
String
product
,
String
appKey
,
ProtalDataRo
protalData
)
{
...
...
@@ -651,8 +657,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
inputIds
.
add
(
checkInputItemRo
.
getPointInputitemId
());
map
.
put
(
checkInputItemRo
.
getPointInputitemId
(),
checkInputItemRo
);
}
List
<
FmeaPointInputitem
>
fmeaPointInputitems
=
fmeaPointInputitemMapper
.
listByPointIdAndInputItemIds
(
pointId
,
inputIds
);
List
<
FmeaPointInputitem
>
fmeaPointInputitems
=
fmeaPointInputitemMapper
.
listByPointIdAndInputItemIds
(
pointId
,
inputIds
);
Set
<
Long
>
fmeaIds
=
Sets
.
newHashSet
();
List
<
Long
>
failIds
=
Lists
.
newArrayList
();
List
<
Long
>
successIds
=
Lists
.
newArrayList
();
...
...
@@ -673,8 +678,8 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
fmeaPointInputitemMapper
.
updateStateByIds
(
0
,
successIds
);
}
RsDataQueue
rsDataQueue
=
RsDataQueue
.
getInstance
();
fmeaIds
.
forEach
(
fmeaId
->
rsDataQueue
.
addPatrolMessage
(
fmeaId
,
protalData
.
getCheckUser
(),
protalData
.
getName
(),
protalData
.
getNodeState
()));
fmeaIds
.
forEach
(
fmeaId
->
rsDataQueue
.
addPatrolMessage
(
fmeaId
,
protalData
.
getCheckUser
(),
protalData
.
getName
(),
protalData
.
getNodeState
()));
}
iDataRefreshService
.
refreshViewData
(
DataRefreshTypeEum
.
check
.
getCode
());
}
...
...
@@ -685,6 +690,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
return
det
;
}
@Override
public
Map
earlyWarning
(
Long
riskSourceId
)
{
Map
returnMap
=
new
HashMap
();
...
...
@@ -699,6 +705,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
return
returnMap
;
}
@Override
public
List
<
HashMap
<
String
,
Object
>>
queryRiskAreaRpn
()
{
return
riskSourceMapper
.
queryRiskAreaRpn
();
...
...
@@ -748,9 +755,9 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
}
private
void
processFireData
(
AlarmParam
deviceData
)
throws
Exception
{
deviceData
.
setPointCode
(
"2"
);
// 处理设备和巡检数据
//处理设备和巡检数据
deviceData
.
setNodeState
(
deviceData
.
getState
());
FireEquipmentPoint
fireEquipmentPoint
=
iFireEquipmentPointDao
.
findOneByCode
(
deviceData
.
getPointCode
());
fireEquipmentPoint
.
setValue
(
deviceData
.
getState
());
...
...
@@ -760,8 +767,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
Dict
dict
=
dictDao
.
getOne
(
fireEquipmentPoint
.
getAlarmType
());
fireEquipmentPointType
=
dict
.
getDictValue
();
}
Optional
<
FireEquipment
>
fireEquipment1
=
this
.
iFireEquipmentDao
.
findById
(
fireEquipmentPoint
.
getFireEquipmentId
());
Optional
<
FireEquipment
>
fireEquipment1
=
this
.
iFireEquipmentDao
.
findById
(
fireEquipmentPoint
.
getFireEquipmentId
());
FireEquipment
fireEquipment
=
null
;
if
(
fireEquipment1
.
isPresent
())
{
fireEquipment
=
fireEquipment1
.
get
();
...
...
@@ -769,11 +775,11 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
Equipment
equipment
=
null
;
if
(
fireEquipment
!=
null
)
{
deviceData
.
setCode
(
fireEquipment
.
getCode
());
//
保存实时数据
//
保存实时数据
saveFireEquipmentData
(
fireEquipmentPoint
,
fireEquipment
,
deviceData
,
fireEquipmentPointType
);
equipment
=
impAndFireEquipMapper
.
queryImpEqumtByFireEquipmt
(
fireEquipmentPoint
.
getFireEquipmentId
());
if
(
equipment
!=
null
)
{
//
动态预案执行
//
动态预案执行
dynamicPlan
(
deviceData
,
equipment
,
fireEquipment
,
fireEquipmentPointType
);
}
}
...
...
@@ -781,15 +787,13 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
/**
* 预案执行
*
* @param deviceData
* @param equipment
* @param fireEquipment
* @param fireEquipmentPointType
*/
@Async
private
void
dynamicPlan
(
AlarmParam
deviceData
,
Equipment
equipment
,
FireEquipment
fireEquipment
,
String
fireEquipmentPointType
)
{
private
void
dynamicPlan
(
AlarmParam
deviceData
,
Equipment
equipment
,
FireEquipment
fireEquipment
,
String
fireEquipmentPointType
){
String
batchNo
=
null
;
Object
batch
=
null
;
Dict
dict
=
null
;
...
...
@@ -834,8 +838,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
}
else
{
String
alarmType
=
(
String
)
redisTemplate
.
opsForHash
().
get
(
"currentContingency"
,
"alarmType"
);
if
(!
ObjectUtils
.
isEmpty
(
alarmType
)
&&
dict
.
getDictValue
().
equals
(
alarmType
))
{
ContingencyDeviceStatus
contingencyDeviceStatus
=
(
ContingencyDeviceStatus
)
redisTemplate
.
opsForHash
()
.
get
(
"currentContingency"
,
"contingencyPlan"
);
ContingencyDeviceStatus
contingencyDeviceStatus
=
(
ContingencyDeviceStatus
)
redisTemplate
.
opsForHash
().
get
(
"currentContingency"
,
"contingencyPlan"
);
contingencyDeviceStatus
.
setNeedStatus
(
"true"
);
autoProcessContingency
(
contingencyDeviceStatus
,
alarmType
);
}
...
...
@@ -849,22 +852,22 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
return
"SUCCESS"
;
}
private
void
saveFireEquipmentData
(
FireEquipmentPoint
fireEquipmentPoint
,
FireEquipment
fireEquipment
,
AlarmParam
deviceData
,
String
fireEquipmentPointType
)
{
if
(
"alarm_type_fire"
.
equals
(
fireEquipmentPointType
)
||
"alarm_type_trouble"
.
equals
(
fireEquipmentPointType
))
{
private
void
saveFireEquipmentData
(
FireEquipmentPoint
fireEquipmentPoint
,
FireEquipment
fireEquipment
,
AlarmParam
deviceData
,
String
fireEquipmentPointType
)
{
if
(
"alarm_type_fire"
.
equals
(
fireEquipmentPointType
)
||
"alarm_type_trouble"
.
equals
(
fireEquipmentPointType
))
{
Alarm
alarm
=
iAlarmDao
.
findByStatusTrueAndFireEquipmentPointCode
(
deviceData
.
getPointCode
());
if
(
alarm
!=
null
)
{
if
(
alarm
!=
null
)
{
alarm
.
setFireEquipmentPointValue
(
deviceData
.
getState
());
if
(
"false"
.
equals
(
deviceData
.
getState
()))
{
if
(
"false"
.
equals
(
deviceData
.
getState
()))
{
alarm
.
setRecoveryDate
(
new
Date
());
alarm
.
setStatus
(
false
);
}
else
{
alarm
.
setFrequency
((
alarm
.
getFrequency
()
+
1
));
}
else
{
alarm
.
setFrequency
((
alarm
.
getFrequency
()+
1
));
alarm
.
setUpdateDate
(
new
Date
());
}
iAlarmDao
.
save
(
alarm
);
}
else
{
if
(
"true"
.
equals
(
deviceData
.
getState
()))
{
}
else
{
if
(
"true"
.
equals
(
deviceData
.
getState
()))
{
alarm
=
new
Alarm
();
alarm
.
setFireEquipmentCode
(
fireEquipment
.
getCode
());
alarm
.
setFireEquipmentId
(
fireEquipment
.
getId
());
...
...
@@ -878,20 +881,20 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
iAlarmDao
.
save
(
alarm
);
}
}
if
(
alarm
!=
null
)
{
if
(
alarm
!=
null
)
{
if
(
"alarm_type_trouble"
.
equals
(
fireEquipmentPointType
))
{
//
通知刷新3d页面相关故障数据
if
(
alarm
.
getFrequency
()
==
1
||
alarm
.
getStatus
()
==
false
)
{
//
通知刷新3d页面相关故障数据
if
(
alarm
.
getFrequency
()==
1
||
alarm
.
getStatus
()
==
false
)
{
notifyAlarm
(
fireEquipmentPoint
,
deviceData
);
iDataRefreshService
.
refreshViewData
(
DataRefreshTypeEum
.
trouble
.
getCode
());
}
}
else
{
//
通知刷新3d页面告警数据
}
else
{
//
通知刷新3d页面告警数据
iDataRefreshService
.
refreshViewData
(
DataRefreshTypeEum
.
alarm
.
getCode
());
}
}
}
else
{
if
(
"SWITCH"
.
equals
(
fireEquipmentPoint
.
getType
()))
{
//
保存遥信信号数据到mysql中
}
else
{
if
(
"SWITCH"
.
equals
(
fireEquipmentPoint
.
getType
())){
//
保存遥信信号数据到mysql中
FireEquipmentData
fireEquipmentData
=
new
FireEquipmentData
();
fireEquipmentData
.
setEqPointCode
(
deviceData
.
getPointCode
());
fireEquipmentData
.
seteValue
(
deviceData
.
getState
());
...
...
@@ -915,10 +918,12 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
}
List
<
AlarmParam
>
list
=
new
ArrayList
<>();
list
.
add
(
deviceData
);
//
保存所有数据(遥测,遥信)到mongo
//
保存所有数据(遥测,遥信)到mongo
saveData
(
list
,
"soe"
);
}
@Override
public
void
saveData
(
List
<
AlarmParam
>
deviceDatas
,
String
type
)
{
List
<
EquipCommunicationData
>
list
=
deviceDatas
.
stream
().
map
(
param
->
{
...
...
@@ -956,8 +961,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
if
(!
param
.
getState
().
equals
(
fireEquipmentPoint
.
getValue
()))
{
fireEquipmentPoint
.
setValue
(
param
.
getState
());
updateFirePointValue
(
fireEquipmentPoint
.
getId
(),
param
.
getState
());
Equipment
equipment
=
impAndFireEquipMapper
.
queryImpEqumtByFireEquipmt
(
Long
.
valueOf
(
data
.
getFireEquipmentId
()));
Equipment
equipment
=
impAndFireEquipMapper
.
queryImpEqumtByFireEquipmt
(
Long
.
valueOf
(
data
.
getFireEquipmentId
()));
if
(!
ObjectUtils
.
isEmpty
(
equipment
))
{
if
(
dict
!=
null
&&
dict
.
getDictValue
().
equals
(
"alarm_type_trouble"
))
{
notifyAlarm
(
fireEquipmentPoint
,
param
);
...
...
@@ -978,8 +982,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
* 设备告警触发fema的sod值
*/
private
void
notifyAlarm
(
FireEquipmentPoint
fireEquipmentPoint
,
AlarmParam
param
)
{
List
<
FmeaEquipmentPoint
>
fmeaEquipmentPoints
=
fmeaEquipmentPointMapper
.
listByEquipmentPointId
(
fireEquipmentPoint
.
getId
());
List
<
FmeaEquipmentPoint
>
fmeaEquipmentPoints
=
fmeaEquipmentPointMapper
.
listByEquipmentPointId
(
fireEquipmentPoint
.
getId
());
Set
<
Long
>
fmeaIds
=
Sets
.
newHashSet
();
List
<
Long
>
ids
=
Lists
.
newArrayList
();
fmeaEquipmentPoints
.
forEach
(
fmeaEquipmentPoint
->
{
...
...
@@ -997,7 +1000,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
fmeaEquipmentPointMapper
.
updateStateByIds
(
state
,
ids
);
}
RsDataQueue
rsDataQueue
=
RsDataQueue
.
getInstance
();
fmeaIds
.
forEach
(
fmeaId
->
rsDataQueue
.
addEquipmentMessage
(
fmeaId
,
param
.
getMonitor
()));
fmeaIds
.
forEach
(
fmeaId
->
rsDataQueue
.
addEquipmentMessage
(
fmeaId
,
param
.
getMonitor
()));
}
}
...
...
@@ -1012,9 +1015,9 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
}
@Override
public
List
<
HashMap
<
String
,
Object
>>
queryRiskSourceSecondLevel
(
)
{
public
List
<
HashMap
<
String
,
Object
>>
queryRiskSourceSecondLevel
(
String
compCode
)
{
// TODO Auto-generated method stub
return
riskSourceMapper
.
queryRiskSourceSecondLevel
(
);
return
riskSourceMapper
.
queryRiskSourceSecondLevel
(
compCode
);
}
@Override
...
...
@@ -1038,8 +1041,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
switch
(
contingencyDeviceStatus
.
getActionName
())
{
case
"确认灾情"
:
// redisTemplate.opsForHash().put("currentContingency",
// "equipmentId", contingencyDeviceStatus.getEquipmentId());
// redisTemplate.opsForHash().put("currentContingency", "equipmentId", contingencyDeviceStatus.getEquipmentId());
redisTemplate
.
opsForValue
().
set
(
"equipmentId"
,
contingencyDeviceStatus
.
getEquipmentId
());
break
;
case
"断开上级电源"
:
...
...
@@ -1075,18 +1077,13 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
if
(
ObjectUtils
.
isEmpty
(
contingencyDeviceStatus
))
{
return
;
}
int
pointCount
=
fireEquipPointMapper
.
queryCountByEuipmentIdAndAlarmType
(
contingencyDeviceStatus
.
getEquipmentId
(),
alarmType
);
int
count
=
fireEquipPointMapper
.
queryStopCountByEuipmentIdAndAlarmType
(
contingencyDeviceStatus
.
getEquipmentId
(),
alarmType
,
contingencyDeviceStatus
.
getNeedStatus
());
int
pointCount
=
fireEquipPointMapper
.
queryCountByEuipmentIdAndAlarmType
(
contingencyDeviceStatus
.
getEquipmentId
(),
alarmType
);
int
count
=
fireEquipPointMapper
.
queryStopCountByEuipmentIdAndAlarmType
(
contingencyDeviceStatus
.
getEquipmentId
(),
alarmType
,
contingencyDeviceStatus
.
getNeedStatus
());
if
(
pointCount
>
0
&&
pointCount
==
count
)
{
try
{
String
batchNo
=
(
String
)
redisTemplate
.
opsForHash
().
get
(
"currentContingency"
,
"batchNo"
);
iContingencyInstance
.
setButtonExecuted
(
batchNo
,
contingencyDeviceStatus
.
getContingencyPlanId
(),
contingencyDeviceStatus
.
getButtonCode
(),
contingencyDeviceStatus
.
getConfirm
());
iContingencyInstance
.
fire
(
batchNo
,
contingencyDeviceStatus
.
getStepCode
(),
contingencyDeviceStatus
.
getContingencyPlanId
(),
contingencyDeviceStatus
.
getButtonCode
(),
contingencyDeviceStatus
.
getConfirm
(),
contingencyDeviceStatus
.
getStepState
());
iContingencyInstance
.
setButtonExecuted
(
batchNo
,
contingencyDeviceStatus
.
getContingencyPlanId
(),
contingencyDeviceStatus
.
getButtonCode
(),
contingencyDeviceStatus
.
getConfirm
());
iContingencyInstance
.
fire
(
batchNo
,
contingencyDeviceStatus
.
getStepCode
(),
contingencyDeviceStatus
.
getContingencyPlanId
(),
contingencyDeviceStatus
.
getButtonCode
(),
contingencyDeviceStatus
.
getConfirm
(),
contingencyDeviceStatus
.
getStepState
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
...
...
@@ -1103,9 +1100,8 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
if
(!
ObjectUtils
.
isEmpty
(
map
.
get
(
"area"
)))
{
area
=
Double
.
valueOf
(
map
.
get
(
"area"
).
toString
());
}
String
maxlevel
=
map
.
get
(
"max_level"
)
!=
null
?
map
.
get
(
"max_level"
).
toString
()
:
"0.0"
;
String
level
=
map
.
get
(
"value"
)
!=
null
&&
StringUtil
.
isNumeric
(
map
.
get
(
"value"
).
toString
())
?
String
.
format
(
"%.2f"
,
(
Double
.
valueOf
(
map
.
get
(
"value"
).
toString
())))
:
maxlevel
;
String
maxlevel
=
map
.
get
(
"max_level"
)
!=
null
?
map
.
get
(
"max_level"
).
toString
():
"0.0"
;
String
level
=
map
.
get
(
"value"
)
!=
null
&&
StringUtil
.
isNumeric
(
map
.
get
(
"value"
).
toString
())?
String
.
format
(
"%.2f"
,
(
Double
.
valueOf
(
map
.
get
(
"value"
).
toString
()))):
maxlevel
;
String
volume
=
String
.
format
(
"%.2f"
,
Double
.
valueOf
(
level
)
*
area
);
if
(
hashOperations
.
size
(
"Analogue"
)
>
0
)
{
...
...
@@ -1115,8 +1111,8 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
continue
;
}
EquipCommunicationData
data
=
(
EquipCommunicationData
)
hashOperations
.
get
(
"Analogue"
,
map
.
get
(
"CODE"
));
map
.
put
(
"level"
,
StringUtil
.
isNumeric
(
data
.
getState
())
?
data
.
getState
()
:
level
);
map
.
put
(
"volume"
,
String
.
format
(
"%.2f"
,
(
Double
.
valueOf
(
map
.
get
(
"level"
).
toString
())
*
area
)));
map
.
put
(
"level"
,
StringUtil
.
isNumeric
(
data
.
getState
())?
data
.
getState
():
level
);
map
.
put
(
"volume"
,
String
.
format
(
"%.2f"
,
(
Double
.
valueOf
(
map
.
get
(
"level"
).
toString
())
*
area
)));
}
else
{
map
.
put
(
"level"
,
level
);
map
.
put
(
"volume"
,
volume
);
...
...
@@ -1134,12 +1130,12 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
public
Integer
getChildTypeByPid
(
Long
riskSourceId
)
{
Long
regionCount
=
riskSourceMapper
.
countByParentIdAndIsRegion
(
riskSourceId
,
"TRUE"
);
if
(!
regionCount
.
equals
(
0L
))
{
//
子节点有风险区域
//
子节点有风险区域
return
1
;
}
Long
pointCount
=
riskSourceMapper
.
countByParentIdAndIsRegion
(
riskSourceId
,
"FALSE"
);
if
(!
pointCount
.
equals
(
0L
))
{
//
子节点有风险点
//
子节点有风险点
return
2
;
}
return
3
;
...
...
@@ -1149,8 +1145,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
* 修改、添加导致rpn、rpni改变
*/
@Override
public
void
notifyFmeaFromUpdate
(
String
toke
,
String
product
,
String
appKey
,
Long
fmeaId
,
String
nofityType
,
String
userName
)
{
public
void
notifyFmeaFromUpdate
(
String
toke
,
String
product
,
String
appKey
,
Long
fmeaId
,
String
nofityType
,
String
userName
)
{
Fmea
fmea
=
fmeaMapper
.
getById
(
fmeaId
);
if
(
fmea
==
null
)
{
return
;
...
...
@@ -1160,12 +1155,12 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
BigDecimal
oidValue
=
new
BigDecimal
(
fmea
.
getOidValue
());
BigDecimal
sidValue
=
new
BigDecimal
(
fmea
.
getSidValue
());
BigDecimal
didValue
=
new
BigDecimal
(
fmea
.
getDidValue
());
//
1.1计算rpni
//
1.1计算rpni
BigDecimal
rpni
=
oidValue
.
multiply
(
sidValue
).
multiply
(
didValue
).
setScale
(
2
,
BigDecimal
.
ROUND_HALF_UP
);
BigDecimal
rpn
;
//
1.2计算rpn:为空则rpni = rpn;不为空则重新计算s*d*newo
//
1.2计算rpn:为空则rpni = rpn;不为空则重新计算s*d*newo
if
(
fmea
.
getNewEvaluationOid
()
==
null
)
{
fmea
.
setNewEvaluationOid
(
fmea
.
getEvaluationOid
());
rpn
=
rpni
;
...
...
@@ -1191,19 +1186,18 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
msgParamBo
.
setNotifyType
(
nofityType
);
jpushMsgBo
=
this
.
getJushMessageInfo
(
msgParamBo
);
}
//
1.3更新fmea
//
1.3更新fmea
fmeaMapper
.
updateRpn
(
fmea
);
//
2.计算上级风险值(风险点及父节点)
//
2.计算上级风险值(风险点及父节点)
this
.
notifyRiskSource
(
fmeaId
,
fmea
.
getRiskSourceId
(),
nofityType
,
jpushMsgBo
);
}
}
private
JpushMsgBo
getJushMessageInfo
(
MsgParamBo
msgParam
)
{
private
JpushMsgBo
getJushMessageInfo
(
MsgParamBo
msgParam
)
{
JpushMsgBo
msgBo
=
new
JpushMsgBo
();
Optional
<
RiskFactor
>
optional
=
iRiskFactorDao
.
findById
(
msgParam
.
getFmea
().
getRiskFactorsId
());
if
(
optional
.
isPresent
())
{
JpushMsgContentBo
jpushMsgContentBo
=
new
JpushMsgContentBo
(
optional
.
get
().
getName
(),
msgParam
.
getNotifyType
());
if
(
optional
.
isPresent
()){
JpushMsgContentBo
jpushMsgContentBo
=
new
JpushMsgContentBo
(
optional
.
get
().
getName
(),
msgParam
.
getNotifyType
());
jpushMsgContentBo
.
setExecute
(
msgParam
.
getUserName
());
jpushMsgContentBo
.
setLevelIsChange
(
msgParam
.
getLevelIsChange
());
jpushMsgContentBo
.
setLevel
(
msgParam
.
getLevel
());
...
...
@@ -1219,8 +1213,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
Set
<
String
>
targets
=
new
LinkedHashSet
<>();
Set
<
String
>
userIds
=
this
.
getUsersByLevel
(
msgParam
.
getManagerLevel
(),
msgParam
.
getFmea
());
userIds
.
forEach
(
userId
->
{
AgencyUserModel
user
=
remoteSecurityService
.
getUserById
(
msgParam
.
getToke
(),
msgParam
.
getProduct
(),
msgParam
.
getAppKey
(),
userId
);
AgencyUserModel
user
=
remoteSecurityService
.
getUserById
(
msgParam
.
getToke
(),
msgParam
.
getProduct
(),
msgParam
.
getAppKey
(),
userId
);
if
(
user
!=
null
)
{
String
target
=
user
.
getMobile
();
targets
.
add
(
target
);
...
...
@@ -1254,8 +1247,9 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
* 告警或者不合格项导致fmea的rpn、new_evaluation_oid改变
*/
@Override
public
void
notifyFmeaFromAbnormal
(
String
toke
,
String
product
,
String
appKey
,
Long
fmeaId
,
String
notifyType
,
String
userName
,
String
relationName
)
{
public
void
notifyFmeaFromAbnormal
(
String
toke
,
String
product
,
String
appKey
,
Long
fmeaId
,
String
notifyType
,
String
userName
,
String
relationName
)
{
Fmea
fmea
=
fmeaMapper
.
getById
(
fmeaId
);
if
(
fmea
==
null
)
{
return
;
...
...
@@ -1263,18 +1257,17 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
if
(
fmea
.
getEvaluationOid
()
!=
null
&&
fmea
.
getEvaluationSid
()
!=
null
&&
fmea
.
getEvaluationDid
()
!=
null
)
{
List
<
FmeaEquipmentPoint
>
equipmentPoints
=
fmeaEquipmentPointMapper
.
listFmeaByFmeaId
(
fmeaId
);
List
<
FmeaPointInputitem
>
pointInputitems
=
fmeaPointInputitemMapper
.
listFmeaByFmeaId
(
fmeaId
);
//
1.准备更新数据
//
1.准备更新数据
Double
maxRate
=
RpnUtils
.
getMaxRate
(
equipmentPoints
,
pointInputitems
);
if
(
maxRate
!=
null
)
{
//
1.1根据设备和巡检数据获取高的故障率
//
1.1根据设备和巡检数据获取高的故障率
List
<
EvaluationModel
>
oModels
=
iEvaluationModelDao
.
findAllByType
(
"O"
);
EvaluationModel
oEvaluationModel
=
getBetweenModel
(
maxRate
,
oModels
);
if
(
oEvaluationModel
!=
null
)
{
BigDecimal
newOidValue
=
new
BigDecimal
(
oEvaluationModel
.
getCoefficient
());
BigDecimal
sidValue
=
new
BigDecimal
(
fmea
.
getSidValue
());
BigDecimal
didValue
=
new
BigDecimal
(
fmea
.
getDidValue
());
BigDecimal
rpn
=
newOidValue
.
multiply
(
sidValue
).
multiply
(
didValue
).
setScale
(
2
,
BigDecimal
.
ROUND_HALF_UP
);
BigDecimal
rpn
=
newOidValue
.
multiply
(
sidValue
).
multiply
(
didValue
).
setScale
(
2
,
BigDecimal
.
ROUND_HALF_UP
);
List
<
RiskLevel
>
levels
=
riskLevelDao
.
findAll
();
RiskLevel
newLevel
=
RpnUtils
.
getBetweenLevel
(
rpn
,
levels
);
fmea
.
setRpn
(
rpn
);
...
...
@@ -1282,7 +1275,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
JpushMsgBo
jpushMsgBo
=
new
JpushMsgBo
();
MsgParamBo
msgParamBo
=
new
MsgParamBo
();
if
(
newLevel
!=
null
)
{
//
1.2根据风险等级对应的责任等级获取责任人
//
1.2根据风险等级对应的责任等级获取责任人
fmea
.
setRiskLevelId
(
newLevel
.
getId
());
msgParamBo
.
setAppKey
(
appKey
);
msgParamBo
.
setToke
(
toke
);
...
...
@@ -1295,16 +1288,16 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
msgParamBo
.
setRelationName
(
relationName
);
jpushMsgBo
=
this
.
getJushMessageInfo
(
msgParamBo
);
}
//
1.3.更新fmea的rpn、风险等级及newOid
//
1.3.更新fmea的rpn、风险等级及newOid
fmeaMapper
.
updateRpn
(
fmea
);
//
2.计算风险点rpn、rpni、riskLevelId
//
2.计算风险点rpn、rpni、riskLevelId
this
.
notifyRiskSource
(
fmeaId
,
fmea
.
getRiskSourceId
(),
notifyType
,
jpushMsgBo
);
}
}
}
}
private
void
saveRpnLog
(
Long
riskSourceId
,
Long
fmeaId
,
BigDecimal
rpn
,
BigDecimal
rpni
,
String
notifyType
)
{
private
void
saveRpnLog
(
Long
riskSourceId
,
Long
fmeaId
,
BigDecimal
rpn
,
BigDecimal
rpni
,
String
notifyType
)
{
RpnChangeLog
rpnChangeLog
=
new
RpnChangeLog
();
rpnChangeLog
.
setRiskSourceId
(
riskSourceId
);
rpnChangeLog
.
setRpn
(
rpn
);
...
...
@@ -1340,22 +1333,22 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
return
;
}
List
<
Fmea
>
fmeas
=
fmeaMapper
.
listByRiskSourceId
(
riskSourceId
);
if
(
CollectionUtils
.
isEmpty
(
fmeas
))
{
//
fema全部删除
if
(
CollectionUtils
.
isEmpty
(
fmeas
))
{
//
fema全部删除
BigDecimal
resetValue
=
new
BigDecimal
(
"0"
);
riskSource
.
setRpn
(
null
);
riskSource
.
setRpni
(
null
);
riskSource
.
setRiskLevelId
(
null
);
riskSource
.
setFlickerFrequency
(
0
);
//
1.更新fmea对应风险点rpn、rpni、level
//
1.更新fmea对应风险点rpn、rpni、level
riskSourceMapper
.
updateRpn
(
riskSource
);
//
2.记录风险点rpn变化流水
//
2.记录风险点rpn变化流水
this
.
saveRpnLog
(
riskSource
.
getId
(),
fmeaId
,
resetValue
,
resetValue
,
notifyType
);
//
3.更新父节点rpn、rpni、风险等级
//
3.更新父节点rpn、rpni、风险等级
this
.
updateParentRpn
(
riskSource
.
getParentId
());
//
4.通知全景监控屏幕数据刷新
//
4.通知全景监控屏幕数据刷新
iDataRefreshService
.
refreshViewData
(
DataRefreshTypeEum
.
rpn
.
getCode
());
}
else
{
//
fmea评价、巡检、告警
}
else
{
//
fmea评价、巡检、告警
RpnCalculationBo
rpnValueBo
=
RpnUtils
.
calRpnAndRpni
(
fmeas
);
if
(
rpnValueBo
.
isEmpty
())
{
return
;
...
...
@@ -1369,20 +1362,20 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
riskSource
.
setRpn
(
rpn
);
riskSource
.
setRpni
(
rpni
);
riskSource
.
setRiskLevelId
(
newRiskLevel
.
getId
());
String
changeType
=
RpnUtils
.
calChangeTypeByLevel
(
oldRiskLevel
.
getLevel
(),
newRiskLevel
.
getLevel
());
riskSource
.
setFlickerFrequency
(
RpnUtils
.
calRiskPointFrequency
(
rpn
,
rpni
,
changeType
));
//
1.更新fmea对应风险点rpn、rpni、level
String
changeType
=
RpnUtils
.
calChangeTypeByLevel
(
oldRiskLevel
.
getLevel
(),
newRiskLevel
.
getLevel
());
riskSource
.
setFlickerFrequency
(
RpnUtils
.
calRiskPointFrequency
(
rpn
,
rpni
,
changeType
));
//
1.更新fmea对应风险点rpn、rpni、level
riskSourceMapper
.
updateRpn
(
riskSource
);
//
2.记录风险点rpn变化流水
//
2.记录风险点rpn变化流水
this
.
saveRpnLog
(
riskSource
.
getId
(),
fmeaId
,
rpn
,
rpni
,
notifyType
);
//
3.更新父节点rpn、rpni、风险等级
//
3.更新父节点rpn、rpni、风险等级
this
.
updateParentRpn
(
riskSource
.
getParentId
());
//
4.极光推送给手机客户端
//
4.极光推送给手机客户端
jpushRiskSourceMessage
(
jpushMsgBo
);
//
5.规则告警(消息)TODO
notifyRule
(
riskSourceId
,
rpn
,
rpni
,
notifyType
,
changeType
);
//
6.通知全景监控屏幕数据刷新
//
5.规则告警(消息)TODO
notifyRule
(
riskSourceId
,
rpn
,
rpni
,
notifyType
,
changeType
);
//
6.通知全景监控屏幕数据刷新
iDataRefreshService
.
refreshViewData
(
DataRefreshTypeEum
.
rpn
.
getCode
());
}
}
...
...
@@ -1390,15 +1383,15 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
@Override
public
void
notifyFmeaFromDelete
(
Long
riskSourceId
,
String
from
)
{
//
1.计算风险点风险值信息
//
1.计算风险点风险值信息
this
.
notifyRiskSource
(
0L
,
riskSourceId
,
from
,
null
);
}
@Override
public
void
notifyRiskSourceDelete
(
Long
parentId
)
{
//
1.风险点删除触发更新父节点rpn、rpni、风险等级
//
1.风险点删除触发更新父节点rpn、rpni、风险等级
this
.
updateParentRpn
(
parentId
);
//
2.通知全景监控屏幕数据刷新
//
2.通知全景监控屏幕数据刷新
iDataRefreshService
.
refreshViewData
(
DataRefreshTypeEum
.
rpn
.
getCode
());
}
...
...
@@ -1412,9 +1405,9 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
List
<
RiskSource
>
riskSourceList
=
new
ArrayList
<>();
List
<
Long
>
ids
=
new
ArrayList
<>();
riskSourceList
=
iRiskSourceDao
.
findByParentId
(
riskSource
.
getId
());
//
递归获取区域(含子区域)所有点
//
递归获取区域(含子区域)所有点
this
.
getAllRiskPoint
(
ids
,
riskSourceList
);
if
(
CollectionUtils
.
isEmpty
(
ids
))
{
//
没有风险点,则赋初始值null
if
(
CollectionUtils
.
isEmpty
(
ids
))
{
//
没有风险点,则赋初始值null
riskSource
.
setRpn
(
null
);
riskSource
.
setRpni
(
null
);
riskSource
.
setRiskLevelId
(
null
);
...
...
@@ -1442,13 +1435,11 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
/**
* 获得子节点:巡检点
*
* @param ids
* 返回
* @param riskSourceList
* 风险点区域列表
* @param ids 返回
* @param riskSourceList 风险点区域列表
*/
private
void
getAllRiskPoint
(
List
<
Long
>
ids
,
List
<
RiskSource
>
riskSourceList
)
{
//
TODO 递归
//
TODO 递归
for
(
RiskSource
riskSource
:
riskSourceList
)
{
if
(
riskSource
.
getIsRegion
().
equalsIgnoreCase
(
"TRUE"
))
{
List
<
RiskSource
>
list
=
iRiskSourceDao
.
findByParentId
(
riskSource
.
getId
());
...
...
@@ -1470,7 +1461,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
}
JpushMsgContentBo
jpushMsgContentBo
=
jpushMsgBo
.
getMsg
();
Set
<
String
>
target
=
jpushMsgBo
.
getTarget
();
if
(
jpushMsgContentBo
.
getSend
())
{
if
(
jpushMsgContentBo
.
getSend
())
{
PushMsgParam
pushMsgParam
=
new
PushMsgParam
();
pushMsgParam
.
setRecivers
(
Lists
.
newArrayList
(
target
));
pushMsgParam
.
setContent
(
jpushMsgContentBo
.
genMessage
());
...
...
@@ -1483,7 +1474,12 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
/**
* 规则告警
*/
private
void
notifyRule
(
Long
id
,
BigDecimal
rpnr
,
BigDecimal
rpni
,
String
notifyType
,
String
changeType
)
{
private
void
notifyRule
(
Long
id
,
BigDecimal
rpnr
,
BigDecimal
rpni
,
String
notifyType
,
String
changeType
)
{
RiskSourceRuleRo
riskSourceRuleRo
=
new
RiskSourceRuleRo
();
riskSourceRuleRo
.
setId
(
id
);
riskSourceRuleRo
.
setRpnr
(
rpnr
);
...
...
@@ -1503,7 +1499,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
return
getRiskRegionTree
(
regionList
);
}
//
区域列表转树
//
区域列表转树
private
static
List
<
RegionTreeResponse
>
getRiskRegionTree
(
List
<
RegionTreeResponse
>
list
)
{
HashMap
<
Long
,
RegionTreeResponse
>
hashMap
=
new
HashMap
<>();
list
.
forEach
(
e
->
hashMap
.
put
(
e
.
getId
(),
e
));
...
...
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