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
f6fa54f6
Commit
f6fa54f6
authored
May 09, 2020
by
suhuiguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.计算rpn
parent
cc82472f
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
549 additions
and
602 deletions
+549
-602
RpnChangeLogTypeEum.java
...om/yeejoin/amos/fas/common/enums/RpnChangeLogTypeEum.java
+36
-0
TriggerRpnChangeTypeEum.java
...eejoin/amos/fas/common/enums/TriggerRpnChangeTypeEum.java
+40
-0
RiskLevel.java
.../main/java/com/yeejoin/amos/fas/dao/entity/RiskLevel.java
+11
-0
RpnCalculationBo.java
...va/com/yeejoin/amos/fas/business/bo/RpnCalculationBo.java
+49
-0
FmeaMapper.java
.../com/yeejoin/amos/fas/business/dao/mapper/FmeaMapper.java
+2
-0
IFmeaDao.java
...om/yeejoin/amos/fas/business/dao/repository/IFmeaDao.java
+4
-1
FmeaServiceImpl.java
...ejoin/amos/fas/business/service/impl/FmeaServiceImpl.java
+1
-4
RiskSourceServiceImpl.java
...amos/fas/business/service/impl/RiskSourceServiceImpl.java
+186
-580
IRiskSourceService.java
...n/amos/fas/business/service/intfc/IRiskSourceService.java
+6
-1
RpnUtils.java
...ain/java/com/yeejoin/amos/fas/business/util/RpnUtils.java
+144
-0
RsDataQueue.java
.../java/com/yeejoin/amos/fas/client/invoke/RsDataQueue.java
+25
-15
fas-1.0.2.xml
...utoSysStart/src/main/resources/db/changelog/fas-1.0.2.xml
+11
-0
dbTemplate_fmea.xml
...SysStart/src/main/resources/db/mapper/dbTemplate_fmea.xml
+24
-0
pom.xml
pom.xml
+10
-1
No files found.
YeeAmosFireAutoSysCommon/src/main/java/com/yeejoin/amos/fas/common/enums/RpnChangeLogTypeEum.java
0 → 100644
View file @
f6fa54f6
package
com
.
yeejoin
.
amos
.
fas
.
common
.
enums
;
/**
* rpn变化类型枚举
*/
public
enum
RpnChangeLogTypeEum
{
/**
* 类型枚举
*/
upper
(
"上升"
,
0
),
down
(
"下降"
,
1
),
unChange
(
"未发生变化"
,
2
);
private
String
name
;
private
int
code
;
RpnChangeLogTypeEum
(
String
name
,
int
code
){
this
.
name
=
name
;
this
.
code
=
code
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
int
getCode
()
{
return
code
;
}
public
void
setCode
(
int
code
)
{
this
.
code
=
code
;
}
}
YeeAmosFireAutoSysCommon/src/main/java/com/yeejoin/amos/fas/common/enums/TriggerRpnChangeTypeEum.java
0 → 100644
View file @
f6fa54f6
package
com
.
yeejoin
.
amos
.
fas
.
common
.
enums
;
/**
* @author DELL
*/
public
enum
TriggerRpnChangeTypeEum
{
/**
* 触发类型枚举
*/
patrol
(
"巡检"
,
"patrol"
),
equipment
(
"设备告警"
,
"equipment"
),
fmeaUpdate
(
"危险因素评价"
,
"fmeaUpdate"
),
fmeaDelete
(
"危险因素删除"
,
"fmeaDelete"
),
riskDelete
(
"风险点删除"
,
"riskDelete"
);
private
String
name
;
private
String
code
;
TriggerRpnChangeTypeEum
(
String
name
,
String
code
){
this
.
name
=
name
;
this
.
code
=
code
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getCode
()
{
return
code
;
}
public
void
setCode
(
String
code
)
{
this
.
code
=
code
;
}
}
YeeAmosFireAutoSysCommon/src/main/java/com/yeejoin/amos/fas/dao/entity/RiskLevel.java
View file @
f6fa54f6
...
@@ -47,6 +47,8 @@ public class RiskLevel extends BasicEntity {
...
@@ -47,6 +47,8 @@ public class RiskLevel extends BasicEntity {
@Column
(
name
=
"down_limit"
)
@Column
(
name
=
"down_limit"
)
private
BigDecimal
downLimit
;
private
BigDecimal
downLimit
;
private
Integer
manageLevel
;
private
String
remark
;
private
String
remark
;
private
String
severity
;
private
String
severity
;
...
@@ -125,4 +127,12 @@ public class RiskLevel extends BasicEntity {
...
@@ -125,4 +127,12 @@ public class RiskLevel extends BasicEntity {
public
void
setDownLimit
(
BigDecimal
downLimit
)
{
public
void
setDownLimit
(
BigDecimal
downLimit
)
{
this
.
downLimit
=
downLimit
;
this
.
downLimit
=
downLimit
;
}
}
public
Integer
getManageLevel
()
{
return
manageLevel
;
}
public
void
setManageLevel
(
Integer
manageLevel
)
{
this
.
manageLevel
=
manageLevel
;
}
}
}
\ No newline at end of file
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/bo/RpnCalculationBo.java
0 → 100644
View file @
f6fa54f6
package
com
.
yeejoin
.
amos
.
fas
.
business
.
bo
;
import
java.math.BigDecimal
;
/**
* @author DELL
*/
public
class
RpnCalculationBo
{
/**
* rpn
*/
BigDecimal
rpn
;
/**
* rpni
*/
BigDecimal
rpni
;
/**
* 长度
*/
long
size
;
public
long
getSize
()
{
return
size
;
}
public
void
setSize
(
long
size
)
{
this
.
size
=
size
;
}
public
BigDecimal
getRpn
()
{
return
rpn
;
}
public
void
setRpn
(
BigDecimal
rpn
)
{
this
.
rpn
=
rpn
;
}
public
BigDecimal
getRpni
()
{
return
rpni
;
}
public
void
setRpni
(
BigDecimal
rpni
)
{
this
.
rpni
=
rpni
;
}
public
boolean
isEmpty
(){
return
size
<=
0
;
}
}
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/dao/mapper/FmeaMapper.java
View file @
f6fa54f6
...
@@ -36,5 +36,7 @@ public interface FmeaMapper extends BaseMapper {
...
@@ -36,5 +36,7 @@ public interface FmeaMapper extends BaseMapper {
List
<
Fmea
>
listByRiskSourceId
(
Long
riskSourceId
);
List
<
Fmea
>
listByRiskSourceId
(
Long
riskSourceId
);
List
<
Fmea
>
listByRiskSourceIds
(
@Param
(
"ids"
)
List
<
Long
>
ids
);
void
updateRpn
(
Fmea
fmea
);
void
updateRpn
(
Fmea
fmea
);
}
}
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/dao/repository/IFmeaDao.java
View file @
f6fa54f6
...
@@ -29,7 +29,7 @@ public interface IFmeaDao extends BaseDao<Fmea, Long> {
...
@@ -29,7 +29,7 @@ public interface IFmeaDao extends BaseDao<Fmea, Long> {
/**
/**
* 根据ID删除fmea对象
* 根据ID删除fmea对象
*
*
* @param
riskSourceId
* @param
fmeaIds
*/
*/
@Modifying
@Modifying
@Transactional
@Transactional
...
@@ -44,4 +44,7 @@ public interface IFmeaDao extends BaseDao<Fmea, Long> {
...
@@ -44,4 +44,7 @@ public interface IFmeaDao extends BaseDao<Fmea, Long> {
@Query
(
value
=
"SELECT count(1) FROM `f_fmea_equipment_point` WHERE fmea_id in ?1"
,
nativeQuery
=
true
)
@Query
(
value
=
"SELECT count(1) FROM `f_fmea_equipment_point` WHERE fmea_id in ?1"
,
nativeQuery
=
true
)
int
countAssociatedEquipPointByIds
(
String
[]
ids
);
int
countAssociatedEquipPointByIds
(
String
[]
ids
);
@Query
(
value
=
"select * from `f_fmea` where id in ?1"
,
nativeQuery
=
true
)
List
<
Fmea
>
findAllByRiskSourceIds
(
List
<
Long
>
ids
);
}
}
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/service/impl/FmeaServiceImpl.java
View file @
f6fa54f6
...
@@ -66,10 +66,7 @@ public class FmeaServiceImpl implements IFmeaService {
...
@@ -66,10 +66,7 @@ public class FmeaServiceImpl implements IFmeaService {
fmeas
.
forEach
(
fmea
->
{
fmeas
.
forEach
(
fmea
->
{
String
userId
=
paramMap
.
get
(
"user_id"
)
==
null
?
"0"
:
paramMap
.
get
(
"user_id"
).
toString
();
String
userId
=
paramMap
.
get
(
"user_id"
)
==
null
?
"0"
:
paramMap
.
get
(
"user_id"
).
toString
();
fmea
.
setCreateBy
(
Integer
.
parseInt
(
userId
));
fmea
.
setCreateBy
(
Integer
.
parseInt
(
userId
));
// RiskSource riskSource = iRiskSourceDao.findById(fmea.getRiskSourceId());
// fmea.setRiskSource(riskSource);
iFmeaDao
.
save
(
fmea
);
iFmeaDao
.
save
(
fmea
);
//updateRpniInfo(fmea.getRiskSourceId());
});
});
}
}
...
@@ -255,7 +252,7 @@ public class FmeaServiceImpl implements IFmeaService {
...
@@ -255,7 +252,7 @@ public class FmeaServiceImpl implements IFmeaService {
Map
map
=
(
Map
)
result
;
Map
map
=
(
Map
)
result
;
RPNi
=
new
BigDecimal
(
Double
.
parseDouble
(
String
.
valueOf
(
map
.
get
(
"RPNi"
)
)));
RPNi
=
new
BigDecimal
(
String
.
valueOf
(
map
.
get
(
"RPNi"
)));
if
(
RPNi
!=
null
)
{
if
(
RPNi
!=
null
)
{
riskSource
.
setRpni
(
RPNi
);
riskSource
.
setRpni
(
RPNi
);
this
.
iRiskSourceDao
.
save
(
riskSource
);
this
.
iRiskSourceDao
.
save
(
riskSource
);
...
...
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/service/impl/RiskSourceServiceImpl.java
View file @
f6fa54f6
...
@@ -4,29 +4,11 @@ import com.alibaba.fastjson.JSON;
...
@@ -4,29 +4,11 @@ import com.alibaba.fastjson.JSON;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
import
com.google.common.collect.Maps
;
import
com.google.common.collect.Sets
;
import
com.google.common.collect.Sets
;
import
com.yeejoin.amos.fas.business.bo.RpnCalculationBo
;
import
com.yeejoin.amos.fas.business.constants.FasConstant
;
import
com.yeejoin.amos.fas.business.constants.FasConstant
;
import
com.yeejoin.amos.fas.business.dao.mapper.FireEquipMapper
;
import
com.yeejoin.amos.fas.business.dao.mapper.*
;
import
com.yeejoin.amos.fas.business.dao.mapper.FireEquipPointMapper
;
import
com.yeejoin.amos.fas.business.dao.mapper.FmeaEquipmentPointMapper
;
import
com.yeejoin.amos.fas.business.dao.mapper.FmeaMapper
;
import
com.yeejoin.amos.fas.business.dao.mapper.FmeaPointInputitemMapper
;
import
com.yeejoin.amos.fas.business.dao.mapper.ImpAndFireEquipMapper
;
import
com.yeejoin.amos.fas.business.dao.mapper.RiskSourceMapper
;
import
com.yeejoin.amos.fas.business.dao.mongo.EquipCommunicationDao
;
import
com.yeejoin.amos.fas.business.dao.mongo.EquipCommunicationDao
;
import
com.yeejoin.amos.fas.business.dao.repository.IContingencyOriginalDataDao
;
import
com.yeejoin.amos.fas.business.dao.repository.*
;
import
com.yeejoin.amos.fas.business.dao.repository.IDictDao
;
import
com.yeejoin.amos.fas.business.dao.repository.IEvaluationModelDao
;
import
com.yeejoin.amos.fas.business.dao.repository.IFireEquipmentDao
;
import
com.yeejoin.amos.fas.business.dao.repository.IFireEquipmentDataDao
;
import
com.yeejoin.amos.fas.business.dao.repository.IFireEquipmentPointDao
;
import
com.yeejoin.amos.fas.business.dao.repository.IFmeaDao
;
import
com.yeejoin.amos.fas.business.dao.repository.IPPointDao
;
import
com.yeejoin.amos.fas.business.dao.repository.IPreplanPictureDao
;
import
com.yeejoin.amos.fas.business.dao.repository.IRiskFactorDao
;
import
com.yeejoin.amos.fas.business.dao.repository.IRiskLevelDao
;
import
com.yeejoin.amos.fas.business.dao.repository.IRiskSourceDao
;
import
com.yeejoin.amos.fas.business.dao.repository.IRpnChangeLogDao
;
import
com.yeejoin.amos.fas.business.dao.repository.IUserDao
;
import
com.yeejoin.amos.fas.business.feign.RemoteRuleServer
;
import
com.yeejoin.amos.fas.business.feign.RemoteRuleServer
;
import
com.yeejoin.amos.fas.business.feign.RemoteWebSocketServer
;
import
com.yeejoin.amos.fas.business.feign.RemoteWebSocketServer
;
import
com.yeejoin.amos.fas.business.jpush.AppMessagePushService
;
import
com.yeejoin.amos.fas.business.jpush.AppMessagePushService
;
...
@@ -39,36 +21,15 @@ import com.yeejoin.amos.fas.business.service.intfc.IContingencyInstance;
...
@@ -39,36 +21,15 @@ import com.yeejoin.amos.fas.business.service.intfc.IContingencyInstance;
import
com.yeejoin.amos.fas.business.service.intfc.IEquipmentService
;
import
com.yeejoin.amos.fas.business.service.intfc.IEquipmentService
;
import
com.yeejoin.amos.fas.business.service.intfc.IRiskSourceService
;
import
com.yeejoin.amos.fas.business.service.intfc.IRiskSourceService
;
import
com.yeejoin.amos.fas.business.service.intfc.Node3dVoService
;
import
com.yeejoin.amos.fas.business.service.intfc.Node3dVoService
;
import
com.yeejoin.amos.fas.business.service.model.CheckInputItemRo
;
import
com.yeejoin.amos.fas.business.service.model.*
;
import
com.yeejoin.amos.fas.business.service.model.ContingencyDeviceStatus
;
import
com.yeejoin.amos.fas.business.service.model.ContingencyRo
;
import
com.yeejoin.amos.fas.business.service.model.FireEquimentDataRo
;
import
com.yeejoin.amos.fas.business.service.model.ProtalDataRo
;
import
com.yeejoin.amos.fas.business.service.model.RiskSourceRo
;
import
com.yeejoin.amos.fas.business.service.model.RiskSourceRuleRo
;
import
com.yeejoin.amos.fas.business.util.DateUtils
;
import
com.yeejoin.amos.fas.business.util.DateUtils
;
import
com.yeejoin.amos.fas.business.util.JexlUtil
;
import
com.yeejoin.amos.fas.business.util.JexlUtil
;
import
com.yeejoin.amos.fas.business.util.RpnUtils
;
import
com.yeejoin.amos.fas.business.vo.EquipCommunicationData
;
import
com.yeejoin.amos.fas.business.vo.EquipCommunicationData
;
import
com.yeejoin.amos.fas.client.invoke.RsDataQueue
;
import
com.yeejoin.amos.fas.client.invoke.RsDataQueue
;
import
com.yeejoin.amos.fas.core.common.request.CommonPageable
;
import
com.yeejoin.amos.fas.core.common.request.CommonPageable
;
import
com.yeejoin.amos.fas.core.common.response.RiskSourceTreeResponse
;
import
com.yeejoin.amos.fas.core.common.response.RiskSourceTreeResponse
;
import
com.yeejoin.amos.fas.dao.entity.ContingencyOriginalData
;
import
com.yeejoin.amos.fas.dao.entity.*
;
import
com.yeejoin.amos.fas.dao.entity.Dict
;
import
com.yeejoin.amos.fas.dao.entity.Equipment
;
import
com.yeejoin.amos.fas.dao.entity.EvaluationModel
;
import
com.yeejoin.amos.fas.dao.entity.FireEquipment
;
import
com.yeejoin.amos.fas.dao.entity.FireEquipmentData
;
import
com.yeejoin.amos.fas.dao.entity.FireEquipmentPoint
;
import
com.yeejoin.amos.fas.dao.entity.Fmea
;
import
com.yeejoin.amos.fas.dao.entity.FmeaEquipmentPoint
;
import
com.yeejoin.amos.fas.dao.entity.FmeaPointInputitem
;
import
com.yeejoin.amos.fas.dao.entity.PPoint
;
import
com.yeejoin.amos.fas.dao.entity.PreplanPicture
;
import
com.yeejoin.amos.fas.dao.entity.RiskFactor
;
import
com.yeejoin.amos.fas.dao.entity.RiskLevel
;
import
com.yeejoin.amos.fas.dao.entity.RiskSource
;
import
com.yeejoin.amos.fas.dao.entity.RpnChangeLog
;
import
com.yeejoin.amos.fas.dao.entity.SUser
;
import
com.yeejoin.amos.fas.exception.YeeException
;
import
com.yeejoin.amos.fas.exception.YeeException
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
...
@@ -80,29 +41,17 @@ import org.springframework.data.redis.core.HashOperations;
...
@@ -80,29 +41,17 @@ import org.springframework.data.redis.core.HashOperations;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.StringUtils
;
import
org.typroject.tyboot.component.cache.Redis
;
import
org.typroject.tyboot.component.cache.Redis
;
import
org.typroject.tyboot.component.cache.enumeration.CacheType
;
import
org.typroject.tyboot.component.cache.enumeration.CacheType
;
import
javax.annotation.PostConstruct
;
import
javax.annotation.PostConstruct
;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.*
;
import
java.util.Arrays
;
import
java.util.concurrent.*
;
import
java.util.Collections
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.UUID
;
import
java.util.concurrent.BlockingQueue
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.LinkedBlockingQueue
;
import
java.util.concurrent.TimeUnit
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -145,9 +94,6 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
...
@@ -145,9 +94,6 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
private
FmeaMapper
fmeaMapper
;
private
FmeaMapper
fmeaMapper
;
@Autowired
@Autowired
private
IRiskFactorDao
iRiskFactorDao
;
@Autowired
private
RiskSourceMapper
riskSourceMapper
;
private
RiskSourceMapper
riskSourceMapper
;
@Autowired
@Autowired
...
@@ -223,7 +169,6 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
...
@@ -223,7 +169,6 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
@Override
@Override
public
RiskSource
editRiskSource
(
HashMap
<
String
,
Object
>
map
)
throws
Exception
{
public
RiskSource
editRiskSource
(
HashMap
<
String
,
Object
>
map
)
throws
Exception
{
RiskSource
riskSource
=
(
RiskSource
)
map
.
get
(
"param"
);
RiskSource
riskSource
=
(
RiskSource
)
map
.
get
(
"param"
);
// String id = String.valueOf(map.get("id"));
Long
id
=
riskSource
.
getId
();
Long
id
=
riskSource
.
getId
();
String
orgCode
=
map
.
get
(
"org_code"
)
==
null
?
""
:
map
.
get
(
"org_code"
).
toString
();
String
orgCode
=
map
.
get
(
"org_code"
)
==
null
?
""
:
map
.
get
(
"org_code"
).
toString
();
String
userId
=
map
.
get
(
"user_id"
)
==
null
?
"0"
:
map
.
get
(
"user_id"
).
toString
();
String
userId
=
map
.
get
(
"user_id"
)
==
null
?
"0"
:
map
.
get
(
"user_id"
).
toString
();
...
@@ -237,48 +182,45 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
...
@@ -237,48 +182,45 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
riskSource
.
setCreateDate
(
oldRiskSource
.
getCreateDate
());
riskSource
.
setCreateDate
(
oldRiskSource
.
getCreateDate
());
riskSource
.
setFmeaList
(
oldRiskSource
.
getFmeaList
());
riskSource
.
setFmeaList
(
oldRiskSource
.
getFmeaList
());
riskSource
.
setIncrement
(
oldRiskSource
.
getIncrement
());
riskSource
.
setIncrement
(
oldRiskSource
.
getIncrement
());
// riskSource.setRiskSourceEquipment(oldRiskSource.getRiskSourceEquipment());
// riskSource.setRiskSourcePointInputitem(oldRiskSource.getRiskSourcePointInputitem());
riskSource
.
setRpn
(
oldRiskSource
.
getRpn
());
riskSource
.
setRpn
(
oldRiskSource
.
getRpn
());
riskSource
.
setRpnChangeLogList
(
oldRiskSource
.
getRpnChangeLogList
());
riskSource
.
setRpnChangeLogList
(
oldRiskSource
.
getRpnChangeLogList
());
riskSource
.
setRpni
(
oldRiskSource
.
getRpni
());
riskSource
.
setRpni
(
oldRiskSource
.
getRpni
());
riskSource
.
setStatus
(
oldRiskSource
.
getStatus
());
riskSource
.
setStatus
(
oldRiskSource
.
getStatus
());
}
}
iRiskSourceDao
.
saveAndFlush
(
riskSource
);
iRiskSourceDao
.
saveAndFlush
(
riskSource
);
//同步数据
//同步数据
if
(
id
==
null
||
id
==
0
)
if
(
id
==
0
)
{
node3dVoService
.
syncData
(()
->
node3dVoService
.
incrementalCreate
(
Node3dVoService
.
DATATYPE_RISKSOURCE
));
node3dVoService
.
syncData
(()
->
node3dVoService
.
incrementalCreate
(
Node3dVoService
.
DATATYPE_RISKSOURCE
));
else
}
else
{
node3dVoService
.
syncData
(()
->
node3dVoService
.
incrementalUpdate
(
Node3dVoService
.
DATATYPE_RISKSOURCE
));
node3dVoService
.
syncData
(()
->
node3dVoService
.
incrementalUpdate
(
Node3dVoService
.
DATATYPE_RISKSOURCE
));
}
return
riskSource
;
return
riskSource
;
}
}
@Override
@Override
public
void
deleteRiskSource
(
Long
[]
riskSourceId
)
throws
Exception
{
public
void
deleteRiskSource
(
Long
[]
riskSourceId
)
throws
Exception
{
Long
id
=
Collections
.
min
(
Arrays
.
asList
(
riskSourceId
));
Long
id
=
Collections
.
min
(
Arrays
.
asList
(
riskSourceId
));
Long
parentId
=
0L
;
Set
<
Long
>
parentIds
=
new
LinkedHashSet
<>()
;
if
(
null
!=
id
)
{
if
(
null
!=
id
)
{
RiskSource
rs
=
iRiskSourceDao
.
findById
(
id
);
RiskSource
rs
=
iRiskSourceDao
.
findById
(
id
);
parentId
=
rs
.
getParentId
();
}
}
for
(
Long
rId
:
riskSourceId
)
{
for
(
Long
rId
:
riskSourceId
)
{
int
count
=
iRiskSourceDao
.
countByParentId
(
rId
);
int
count
=
iRiskSourceDao
.
countByParentId
(
rId
);
RiskSource
rs
=
iRiskSourceDao
.
findById
(
rId
);
parentIds
.
add
(
rs
.
getParentId
());
if
(
count
>
0
)
{
if
(
count
>
0
)
{
throw
new
YeeException
(
"该数据有关联子项,请先删除子项数据"
);
throw
new
YeeException
(
"该数据有关联子项,请先删除子项数据"
);
}
}
iRiskSourceDao
.
delete
(
rId
);
iRiskSourceDao
.
delete
(
rId
);
}
}
// if (null != parentId) {
List
<
Long
>
existIds
=
parentIds
.
stream
().
filter
(
e
->
//// updateRiskSourceRpni(parentId);
iRiskSourceDao
.
findById
(
e
)
!=
null
//// }
).
collect
(
Collectors
.
toList
());
RsDataQueue
rs
=
RsDataQueue
.
getInstance
();
existIds
.
forEach
(
rs:
:
addRiskSourcePointDeleteMessage
);
//同步数据
//同步数据
node3dVoService
.
syncData
(()
->
node3dVoService
.
incrementalRemove
(
Node3dVoService
.
DATATYPE_RISKSOURCE
));
node3dVoService
.
syncData
(()
->
node3dVoService
.
incrementalRemove
(
Node3dVoService
.
DATATYPE_RISKSOURCE
));
}
}
@Override
@Override
...
@@ -289,6 +231,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
...
@@ -289,6 +231,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
}
}
@Override
public
List
<
Map
>
queryForRegion
()
{
public
List
<
Map
>
queryForRegion
()
{
List
<
Map
>
result
=
riskSourceMapper
.
queryForRegion
();
List
<
Map
>
result
=
riskSourceMapper
.
queryForRegion
();
if
(!
CollectionUtils
.
isEmpty
(
result
))
{
if
(!
CollectionUtils
.
isEmpty
(
result
))
{
...
@@ -301,6 +244,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
...
@@ -301,6 +244,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
}
}
@Override
public
Map
queryFor3DStatistics
()
{
public
Map
queryFor3DStatistics
()
{
Map
<
String
,
List
>
result
=
riskSourceMapper
.
statistics3dCount
();
Map
<
String
,
List
>
result
=
riskSourceMapper
.
statistics3dCount
();
result
.
put
(
"equipClassify"
,
riskSourceMapper
.
statisticsEquipClassify
());
result
.
put
(
"equipClassify"
,
riskSourceMapper
.
statisticsEquipClassify
());
...
@@ -310,11 +254,13 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
...
@@ -310,11 +254,13 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
}
}
@Override
public
List
<
Map
>
queryRPNReport
()
{
public
List
<
Map
>
queryRPNReport
()
{
return
riskSourceMapper
.
queryRPNReport
();
return
riskSourceMapper
.
queryRPNReport
();
}
}
@Override
public
Map
queryForRiseUp
()
throws
Exception
{
public
Map
queryForRiseUp
()
throws
Exception
{
Map
<
String
,
Map
>
result
=
new
HashMap
<>();
Map
<
String
,
Map
>
result
=
new
HashMap
<>();
...
@@ -348,6 +294,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
...
@@ -348,6 +294,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
return
result
;
return
result
;
}
}
@Override
public
List
<
Map
>
queryForMatrix
()
{
public
List
<
Map
>
queryForMatrix
()
{
return
this
.
riskSourceMapper
.
queryForMatrix
();
return
this
.
riskSourceMapper
.
queryForMatrix
();
}
}
...
@@ -392,14 +339,6 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
...
@@ -392,14 +339,6 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
return
riskSourceMapper
.
getRiskSources
();
return
riskSourceMapper
.
getRiskSources
();
}
}
// @Override
// public Page<HashMap<String, Object>> getRiskSourcePoints(RiskSourceParam param) {
// long total = riskSourceMapper.getRiskSourcePointCount(param);
// List<HashMap<String, Object>> content = riskSourceMapper.getRiskSourcePoints(param);
// Page<HashMap<String, Object>> result = new PageImpl<HashMap<String, Object>>(content, param, total);
// return result;
// }
@Override
@Override
public
List
<
FmeaEquipmentPoint
>
bindFireEquiment
(
FmeaBindParam
fmeaBindParam
)
{
public
List
<
FmeaEquipmentPoint
>
bindFireEquiment
(
FmeaBindParam
fmeaBindParam
)
{
Long
fmeaId
=
fmeaBindParam
.
getFmeaId
();
Long
fmeaId
=
fmeaBindParam
.
getFmeaId
();
...
@@ -446,21 +385,17 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
...
@@ -446,21 +385,17 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
return
returnList
;
return
returnList
;
}
}
// public String[] removeBoundRelation(String[] idArray) {
// for (String id : idArray)
// this.iRiskSourceEquipmentDao.delete(Long.parseLong(id));
// return idArray;
// }
/**
/**
* 查询指定风险点和设备之间的关系,包含绑定和未绑定
* 查询指定风险点和设备之间的关系,包含绑定和未绑定
*/
*/
@Override
public
Page
<
Map
>
queryEquimentRelation
(
CommonPageable
commonPageable
,
String
equipmentId
,
String
fname
)
{
public
Page
<
Map
>
queryEquimentRelation
(
CommonPageable
commonPageable
,
String
equipmentId
,
String
fname
)
{
Long
total
=
fireEquipMapper
.
queryEquimentRelationCount
(
equipmentId
,
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
);
return
new
PageImpl
<>(
list
,
commonPageable
,
total
);
}
}
@Override
public
List
<
Map
<
String
,
Object
>>
listEquipmentPointById
(
Long
fmeaId
,
Long
importantEquipId
,
Long
equipmentId
,
String
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
);
List
<
Map
<
String
,
Object
>>
list
=
fmeaEquipmentPointMapper
.
listEquipmentPoint
(
fmeaId
,
importantEquipId
,
equipmentId
,
equipmentPointName
);
if
(
CollectionUtils
.
isEmpty
(
list
))
{
if
(
CollectionUtils
.
isEmpty
(
list
))
{
...
@@ -470,6 +405,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
...
@@ -470,6 +405,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
}
}
@Override
@Async
@Async
public
String
processFireEqumtData
(
FireEquimentDataRo
deviceData
)
throws
Exception
{
public
String
processFireEqumtData
(
FireEquimentDataRo
deviceData
)
throws
Exception
{
//处理设备和巡检数据
//处理设备和巡检数据
...
@@ -506,8 +442,6 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
...
@@ -506,8 +442,6 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
public
void
alermContingency
(
String
batchNo
,
FireEquipment
fireEquipment
,
Equipment
equipment
)
throws
Exception
{
public
void
alermContingency
(
String
batchNo
,
FireEquipment
fireEquipment
,
Equipment
equipment
)
throws
Exception
{
ContingencyRo
contingencyRo
=
new
ContingencyRo
();
ContingencyRo
contingencyRo
=
new
ContingencyRo
();
contingencyRo
.
setBatchNo
(
batchNo
);
contingencyRo
.
setBatchNo
(
batchNo
);
contingencyRo
.
setEquipmentId
(
String
.
valueOf
(
equipment
.
getId
()));
contingencyRo
.
setEquipmentId
(
String
.
valueOf
(
equipment
.
getId
()));
contingencyRo
.
setEquipmentName
(
equipment
.
getName
());
contingencyRo
.
setEquipmentName
(
equipment
.
getName
());
...
@@ -530,212 +464,40 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
...
@@ -530,212 +464,40 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
contingencyRo
.
setAdminName
(
"admin"
);
contingencyRo
.
setAdminName
(
"admin"
);
contingencyRo
.
setFireEquipmentPosition
(
fireEquipment
.
getPosition3d
());
contingencyRo
.
setFireEquipmentPosition
(
fireEquipment
.
getPosition3d
());
List
<
PreplanPicture
>
pictures
=
iPreplanPictureDao
.
findByEquipmentId
(
Long
.
valueOf
(
equipment
.
getId
()));
List
<
PreplanPicture
>
pictures
=
iPreplanPictureDao
.
findByEquipmentId
(
Long
.
valueOf
(
equipment
.
getId
()));
if
(!
CollectionUtils
.
isEmpty
(
pictures
))
{
if
(!
CollectionUtils
.
isEmpty
(
pictures
))
{
for
(
PreplanPicture
picture
:
pictures
)
{
for
(
PreplanPicture
picture
:
pictures
)
{
if
(
1
==
picture
.
getType
())
if
(
1
==
picture
.
getType
())
{
contingencyRo
.
setPicture1
(
picture
.
getPicture
());
contingencyRo
.
setPicture1
(
picture
.
getPicture
());
if
(
2
==
picture
.
getType
())
}
if
(
2
==
picture
.
getType
()){
contingencyRo
.
setPicture2
(
picture
.
getPicture
());
contingencyRo
.
setPicture2
(
picture
.
getPicture
());
if
(
3
==
picture
.
getType
())
}
if
(
3
==
picture
.
getType
()){
contingencyRo
.
setPicture3
(
picture
.
getPicture
());
contingencyRo
.
setPicture3
(
picture
.
getPicture
());
if
(
4
==
picture
.
getType
())
}
if
(
4
==
picture
.
getType
()){
contingencyRo
.
setPicture4
(
picture
.
getPicture
());
contingencyRo
.
setPicture4
(
picture
.
getPicture
());
}
}
}
}
}
Object
result
=
remoteRuleServer
.
fireRuleFlow
(
contingencyRo
,
equipment
.
getReservePlan
(),
equipment
.
getName
());
Object
result
=
remoteRuleServer
.
fireRuleFlow
(
contingencyRo
,
equipment
.
getReservePlan
(),
equipment
.
getName
());
ContingencyOriginalData
contingencyOriginalData
=
new
ContingencyOriginalData
();
ContingencyOriginalData
contingencyOriginalData
=
new
ContingencyOriginalData
();
BeanUtils
.
copyProperties
(
contingencyRo
,
contingencyOriginalData
);
BeanUtils
.
copyProperties
(
contingencyRo
,
contingencyOriginalData
);
iContingencyOriginalDataDao
.
save
(
contingencyOriginalData
);
iContingencyOriginalDataDao
.
save
(
contingencyOriginalData
);
}
}
// public boolean asymbleWithParent(String bacthNo, List<RiskSource> riskSourceList, String from, Long fromId, String nodeState, String originalNodeState, List<FmeaPointInputitem> pointInputitems) throws Exception {
// if (!CollectionUtils.isEmpty(riskSourceList)) {
// for (RiskSource riskSource : riskSourceList) {
// //当前规则
// RiskSourceRo riskSourceRo = this.transfer(bacthNo, riskSource, from, nodeState, originalNodeState, new BigDecimal(0), pointInputitems);
//
// Object result = remoteRuleServer.fireRule(riskSourceRo, PACKAGE_ID);
// //BigDecimal RPNi = updateRpn(result,riskSource,null,fromId);
// //处理返回结果
//
// //反查 父级风险点,取得处于第二级的父级风险点
// findParent(bacthNo, riskSource, nodeState, originalNodeState, new BigDecimal(0), fromId);
// }
// }
// return true;
// }
// /**
// * 查询父节点风险点
// *
// * @param riskSource
// * @param nodeState
// * @param originalNodeState
// * @param RPNi
// * @return
// */
// private BigDecimal findParent(String bacthNo, RiskSource riskSource, String nodeState, String originalNodeState,
// BigDecimal RPNi, Long fromId) throws Exception {
// if (riskSource != null && riskSource.getId() != 0 && RPNi.doubleValue() != 0) {
// RiskSource parent = this.iRiskSourceDao.findById(riskSource.getParentId());
// if (null != parent) {
// RiskSourceRo parentRiskResource = this.transfer(bacthNo, parent, "child", nodeState, originalNodeState,
// RPNi, null);
// Object result = remoteRuleServer.fireRule(parentRiskResource, "风险管控/parentRisk");
// //updateRpn(result, parent, RPNi, fromId);
//
// if (parent.getParentId() != 0)
// this.findParent(bacthNo, parent, nodeState, originalNodeState, RPNi, fromId);
// }
// }
//
// return RPNi;
// }
private
RiskSourceRo
transfer
(
String
bacthNo
,
RiskSource
riskSource
,
String
from
,
String
nodeState
,
String
originalNodeState
,
BigDecimal
rpni
,
List
<
FmeaPointInputitem
>
pointInputitems
)
{
RiskSourceRo
riskSourceRo
=
new
RiskSourceRo
();
riskSourceRo
.
setBatchNo
(
bacthNo
);
riskSourceRo
.
setId
(
String
.
valueOf
(
riskSource
.
getId
()));
riskSourceRo
.
setCode
(
riskSource
.
getCode
());
riskSourceRo
.
setFrom
(
from
);
riskSourceRo
.
setName
(
riskSource
.
getName
());
riskSourceRo
.
setNodeState
(
nodeState
);
riskSourceRo
.
setOriginalNodeState
(
originalNodeState
);
riskSourceRo
.
setIsRegion
(
riskSource
.
getIsRegion
());
riskSourceRo
.
setRiskFactor
(
null
);
riskSourceRo
.
setRpn
(
riskSource
.
getRpn
());
riskSourceRo
.
setRiskState
(
riskSource
.
getStatus
());
riskSourceRo
.
setRpni
(
rpni
);
RiskLevel
riskLevel
=
iRiskLevelDao
.
findById
(
riskSource
.
getRiskLevelId
());
if
(
riskLevel
!=
null
)
{
riskSourceRo
.
setRiskLevel
(
riskLevel
.
getLevel
());
}
List
<
BigDecimal
>
RPNiSum
=
new
ArrayList
<>();
List
<
Fmea
>
fmeaList
=
iFmeaDao
.
findByRiskSourceId
(
riskSource
.
getId
());
String
riskFactor
=
""
;
if
(!
CollectionUtils
.
isEmpty
(
fmeaList
))
{
for
(
Fmea
fmea
:
fmeaList
)
{
RPNiSum
.
add
(
fmea
.
getRpni
());
RiskFactor
factor
=
iRiskFactorDao
.
findById
(
fmea
.
getRiskFactorsId
());
if
(
factor
!=
null
)
riskFactor
+=
factor
.
getName
()
+
"\n"
;
}
}
//获取所有子节点的rpni值
List
<
Map
<
String
,
BigDecimal
>>
rpniList
=
riskSourceMapper
.
queryForRiskSourceRpni
(
riskSource
.
getId
());
if
(!
CollectionUtils
.
isEmpty
(
rpniList
))
{
for
(
Map
<
String
,
BigDecimal
>
map
:
rpniList
)
{
RPNiSum
.
addAll
(
map
.
values
());
}
}
/* for(Fmea fmea:fmeaList)
{
Map<String,BigDecimal> map = new HashMap<>();
map.put("rpni",fmea.getRpni());
RPNiSum.add(map);
}*/
//巡检
if
(
ProtalDataRo
.
class
.
getSimpleName
().
equals
(
from
))
{
if
(!
CollectionUtils
.
isEmpty
(
pointInputitems
))
{
// for (RiskSourcePointInputitem pointInputitem : pointInputitems) {
// RiskSourcePointInputitem riskSourcePointInputitem = iRiskSourcePointInputitemDao.findAllByRiskSourceIdAndPointIdAndPointInputitemId(riskSource.getId(), pointInputitem.getPointId(), pointInputitem.getPointInputitemId());
//
// if (riskSourcePointInputitem != null) {
// riskSourcePointInputitem.setCheckInputitemId(pointInputitem.getCheckInputitemId());
// /*//正常1,异常2 正常变异常 负的,异常变正常 正的
// String status = pointInputitem.getStatus();
// String oldStatus = riskSourcePointInputitem.getStatus();
//
// *//*if(StringUtils.isEmpty(oldStatus))
// oldStatus = "1";
//
// if("1".equals(oldStatus) && "2".equals(status))
// {
// if(!CollectionUtils.isEmpty(fmeaList))
// {
// for(Fmea fmea:fmeaList)
// {
// Map<String,BigDecimal> map = new HashMap<>();
//
// //正常变异常 累加负的
// map.put("rpni",fmea.getRpni().multiply(new BigDecimal(-1)));
// RPNiSum.add(map);
// }
// }
// riskSourcePointInputitem.setStatus(status);
// }
//
// if("2".equals(oldStatus) && "1".equals(status))
// {
// if(!CollectionUtils.isEmpty(fmeaList))
// {
// for(Fmea fmea:fmeaList)
// {
// Map<String,BigDecimal> map = new HashMap<>();
// map.put("rpni",fmea.getRpni());
// RPNiSum.add(map);
// }
// }
// riskSourcePointInputitem.setStatus(status);
// }*//*
//
//
// for(Fmea fmea:fmeaList)
// {
// Map<String,BigDecimal> map = new HashMap<>();
// map.put("rpni",fmea.getRpni());
// RPNiSum.add(map);
// }
// // riskSourcePointInputitem.setStatus(status);*/
// riskSourcePointInputitem.setStatus(pointInputitem.getStatus());
// iRiskSourcePointInputitemDao.save(riskSourcePointInputitem);
// }
// }
}
}
riskSourceRo
.
setRiskFactor
(
riskFactor
);
riskSourceRo
.
setRPNiSum
(
RPNiSum
);
//是否是区域节点
if
(
"TRUE"
.
equals
(
riskSource
.
getIsRegion
()))
{
riskSourceRo
.
setRegionMaxLevel
(
findRegionMaxLevel
(
riskSource
.
getId
()));
}
return
riskSourceRo
;
}
private
Integer
findRegionMaxLevel
(
Long
regionRiskSourceId
)
{
private
Integer
findRegionMaxLevel
(
Long
regionRiskSourceId
)
{
Integer
maxLevel
=
0
;
Integer
maxLevel
=
0
;
List
<
RiskSource
>
anomalyRiskSource
=
findAnomalyRiskSource
(
regionRiskSourceId
);
List
<
RiskSource
>
anomalyRiskSource
=
findAnomalyRiskSource
(
regionRiskSourceId
);
for
(
RiskSource
anomaly
:
anomalyRiskSource
)
{
for
(
RiskSource
anomaly
:
anomalyRiskSource
)
{
RiskLevel
anomalyLevel
=
this
.
iRiskLevelDao
.
findById
(
anomaly
.
getRiskLevelId
());
RiskLevel
anomalyLevel
=
this
.
iRiskLevelDao
.
findById
(
anomaly
.
getRiskLevelId
());
if
(
anomalyLevel
!=
null
&&
anomalyLevel
.
getLevel
()
>
maxLevel
)
if
(
anomalyLevel
!=
null
&&
anomalyLevel
.
getLevel
()
>
maxLevel
)
{
maxLevel
=
anomalyLevel
.
getLevel
();
maxLevel
=
anomalyLevel
.
getLevel
();
}
}
}
return
maxLevel
;
return
maxLevel
;
}
}
...
@@ -744,63 +506,16 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
...
@@ -744,63 +506,16 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
List
<
RiskSource
>
returnList
=
new
ArrayList
<>();
List
<
RiskSource
>
returnList
=
new
ArrayList
<>();
List
<
RiskSource
>
childs
=
iRiskSourceDao
.
findByParentId
(
riskSourceId
);
List
<
RiskSource
>
childs
=
iRiskSourceDao
.
findByParentId
(
riskSourceId
);
if
(
CollectionUtils
.
isEmpty
(
childs
))
if
(
CollectionUtils
.
isEmpty
(
childs
))
{
return
returnList
;
return
returnList
;
}
for
(
RiskSource
child
:
childs
)
{
for
(
RiskSource
child
:
childs
)
{
/*if("ANOMALY".equals(child.getStatus()))
{
returnList.add(child);
}*/
returnList
.
add
(
child
);
returnList
.
add
(
child
);
returnList
.
addAll
(
this
.
findAnomalyRiskSource
(
child
.
getId
()));
returnList
.
addAll
(
this
.
findAnomalyRiskSource
(
child
.
getId
()));
}
}
return
returnList
;
return
returnList
;
}
}
/*private BigDecimal updateRpn(Object result,RiskSource riskSource,BigDecimal RPNi,Long fromId)
{
*//*"RPNr": 16,
"RPNi": -14*//*
Map map = (Map) result;
RPNi = new BigDecimal(Double.parseDouble(String.valueOf(map.get("RPNi"))));
if(RPNi != null)
{
riskSource.setRpni(RPNi);
this.iRiskSourceDao.save(riskSource);
}
*//*if(RPNr.doubleValue() != 0 && !"ANOMALY".equals(riskSource.getStatus()))
{
riskSource.setStatus("ANOMALY");
this.iRiskSourceDao.save(riskSource);
}
if(RPNr.doubleValue() == 0 && !"NORMAL".equals(riskSource.getStatus()))
{
riskSource.setStatus("NORMAL");
this.iRiskSourceDao.save(riskSource);
}*//*
return RPNi;
}*/
private
void
createRpnChangeLog
(
BigDecimal
rpni
,
BigDecimal
rpnr
,
Long
riskSourceId
,
Long
fromId
)
{
RpnChangeLog
rpnChangeLog
=
new
RpnChangeLog
();
rpnChangeLog
.
setCreateDate
(
new
Date
());
rpnChangeLog
.
setRiskSourceId
(
Long
.
valueOf
(
riskSourceId
));
rpnChangeLog
.
setRpn
(
rpnr
);
rpnChangeLog
.
setRpni
(
rpni
);
rpnChangeLog
.
setTriggerBy
(
Long
.
valueOf
(
fromId
));
rpnChangeLog
.
setType
(
rpni
.
doubleValue
()
>
0
?
0
:
1
);
iRpnChangeLogDao
.
save
(
rpnChangeLog
);
}
@Override
@Override
public
Page
<
Map
<
String
,
Object
>>
listFmeaPointInputitem
(
Long
fmeaId
,
Integer
pageNumber
,
Integer
pageSize
)
{
public
Page
<
Map
<
String
,
Object
>>
listFmeaPointInputitem
(
Long
fmeaId
,
Integer
pageNumber
,
Integer
pageSize
)
{
List
<
Map
<
String
,
Object
>>
content
=
Lists
.
newArrayList
();
List
<
Map
<
String
,
Object
>>
content
=
Lists
.
newArrayList
();
...
@@ -820,6 +535,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
...
@@ -820,6 +535,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
}
}
@Override
public
boolean
processTaskData
(
ProtalDataRo
taskData
)
throws
Exception
{
public
boolean
processTaskData
(
ProtalDataRo
taskData
)
throws
Exception
{
taskData
.
setBatchNo
(
UUID
.
randomUUID
().
toString
());
taskData
.
setBatchNo
(
UUID
.
randomUUID
().
toString
());
//Object result = remoteRuleServer.fireRule(taskData, "风险管控/patrol");
//Object result = remoteRuleServer.fireRule(taskData, "风险管控/patrol");
...
@@ -827,6 +543,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
...
@@ -827,6 +543,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
}
}
@Override
@Async
@Async
public
void
processProtalData
(
ProtalDataRo
protalData
)
{
public
void
processProtalData
(
ProtalDataRo
protalData
)
{
String
bacthNo
=
UUID
.
randomUUID
().
toString
();
String
bacthNo
=
UUID
.
randomUUID
().
toString
();
...
@@ -876,22 +593,8 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
...
@@ -876,22 +593,8 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
RsDataQueue
rsDataQueue
=
RsDataQueue
.
getInstance
();
RsDataQueue
rsDataQueue
=
RsDataQueue
.
getInstance
();
fmeaIds
.
forEach
(
fmeaId
->
rsDataQueue
.
addPatrolMessage
(
fmeaId
));
fmeaIds
.
forEach
(
fmeaId
->
rsDataQueue
.
addPatrolMessage
(
fmeaId
));
}
}
//asymbleWithParent(bacthNo,riskSources, ProtalDataRo.class.getSimpleName(),protalData.getId(),protalData.getNodeState(),protalData.getOriginalNodeState(),protalData.getPointInputitems());
}
}
// @Override
// @Transactional
// public void removeByRSIdAndPId(List<HashMap<String, String>> list) {
// // TODO Auto-generated method stub
// if (list.size() > 0) {
// for (HashMap<String, String> hashMap : list) {
// iRiskSourcePointInputitemDao.removeByRSIdAndPId(hashMap.get("riskId"), hashMap.get("pointId"));
// }
//
// }
//
// }
@Override
@Override
public
RiskSourceTreeResponse
queryRiskSourceDetailById
(
Long
id
)
{
public
RiskSourceTreeResponse
queryRiskSourceDetailById
(
Long
id
)
{
RiskSourceTreeResponse
det
=
riskSourceMapper
.
findRiskSourceDetatil
(
id
);
RiskSourceTreeResponse
det
=
riskSourceMapper
.
findRiskSourceDetatil
(
id
);
...
@@ -899,6 +602,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
...
@@ -899,6 +602,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
}
}
@Override
public
Map
earlyWarning
(
Long
riskSourceId
)
{
public
Map
earlyWarning
(
Long
riskSourceId
)
{
Map
returnMap
=
new
HashMap
();
Map
returnMap
=
new
HashMap
();
Map
riskSourceInfo
=
this
.
riskSourceMapper
.
queryForRiskSourceLevel
(
riskSourceId
);
Map
riskSourceInfo
=
this
.
riskSourceMapper
.
queryForRiskSourceLevel
(
riskSourceId
);
...
@@ -913,26 +617,6 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
...
@@ -913,26 +617,6 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
return
returnMap
;
return
returnMap
;
}
}
// @Override
// public BigDecimal updateRiskSourceRpni(Long riskSourceId) throws Exception {
// BigDecimal newRpni = new BigDecimal(0);
// //风险点添加或删除风险因素时
// RiskSource riskSource = iRiskSourceDao.findById(riskSourceId);
// if (null != riskSource) {
// List<BigDecimal> childRpniList = new ArrayList<>();
// List<RiskSource> children = iRiskSourceDao.findByParentId(riskSource.getId());
// for (RiskSource child : children) {
// childRpniList.add(child.getRpni());
// }
// RiskSourceRo riskSourceRo = fillRiskSourceRo(riskSource, childRpniList);
// //Object result = remoteRuleServer.fireRule(riskSourceRo, PACKAGE_ID_COUNT_RPNI);
// //BigDecimal RPNi = updateRpni(result, riskSource);
// //findParent(riskSource, RPNi);
// //newRpni = RPNi;
// }
// return newRpni;
// }
private
RiskSourceRo
fillRiskSourceRo
(
RiskSource
riskSource
,
List
<
BigDecimal
>
rpniList
)
{
private
RiskSourceRo
fillRiskSourceRo
(
RiskSource
riskSource
,
List
<
BigDecimal
>
rpniList
)
{
RiskSourceRo
riskSourceRo
=
new
RiskSourceRo
();
RiskSourceRo
riskSourceRo
=
new
RiskSourceRo
();
String
batchNo
=
UUID
.
randomUUID
().
toString
();
String
batchNo
=
UUID
.
randomUUID
().
toString
();
...
@@ -956,66 +640,18 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
...
@@ -956,66 +640,18 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
return
riskSourceRo
;
return
riskSourceRo
;
}
}
private
BigDecimal
updateRpni
(
Object
result
,
RiskSource
riskSource
)
{
/*
* "RPNr": 16, "RPNi": -14
*/
BigDecimal
RPNi
=
null
;
Map
map
=
(
Map
)
result
;
if
(
null
!=
map
.
get
(
"RPNi"
))
{
RPNi
=
new
BigDecimal
(
Double
.
parseDouble
(
String
.
valueOf
(
map
.
get
(
"RPNi"
))));
if
(
RPNi
!=
null
)
{
riskSource
.
setRpni
(
RPNi
);
this
.
iRiskSourceDao
.
save
(
riskSource
);
}
}
return
RPNi
;
}
/**
* 查询父节点风险点
*
* @param riskSource
* @param RPNi
* @return
*/
private
BigDecimal
findParent
(
RiskSource
riskSource
,
BigDecimal
RPNi
)
throws
Exception
{
if
(
null
!=
riskSource
&&
riskSource
.
getId
()
!=
0
&&
riskSource
.
getParentId
()
!=
0
&&
null
!=
RPNi
&&
RPNi
.
doubleValue
()
!=
0
)
{
// RiskSource parent = iRiskSourceDao.getOne(0L);
RiskSource
parent
=
iRiskSourceDao
.
findById
(
riskSource
.
getParentId
());
if
(
null
!=
parent
)
{
List
<
BigDecimal
>
childRpniList
=
new
ArrayList
<>();
List
<
RiskSource
>
children
=
iRiskSourceDao
.
findByParentId
(
parent
.
getId
());
for
(
RiskSource
child
:
children
)
{
childRpniList
.
add
(
child
.
getRpni
());
}
RiskSourceRo
parentRiskResourceRo
=
fillRiskSourceRo
(
parent
,
childRpniList
);
//Object result = remoteRuleServer.fireRule(parentRiskResourceRo, PACKAGE_ID_COUNT_RPNI);
//updateRpni(result, parent);
if
(
parent
.
getParentId
()
!=
0
)
this
.
findParent
(
parent
,
RPNi
);
}
}
return
RPNi
;
}
@Override
@Override
public
List
<
HashMap
<
String
,
Object
>>
queryRiskAreaRpn
()
{
public
List
<
HashMap
<
String
,
Object
>>
queryRiskAreaRpn
()
{
return
riskSourceMapper
.
queryRiskAreaRpn
();
return
riskSourceMapper
.
queryRiskAreaRpn
();
}
}
@
javax
.
transaction
.
Transactional
@Transactional
public
void
updateFirePointValue
(
Long
id
,
String
state
)
{
public
void
updateFirePointValue
(
Long
id
,
String
state
)
{
fireEquipPointMapper
.
updateValue
(
id
,
state
);
fireEquipPointMapper
.
updateValue
(
id
,
state
);
}
}
private
static
final
BlockingQueue
<
AlarmParam
>
blockingQueue
=
new
LinkedBlockingQueue
<
AlarmParam
>();
private
static
final
BlockingQueue
<
AlarmParam
>
blockingQueue
=
new
LinkedBlockingQueue
<
AlarmParam
>();
private
static
ExecutorService
executorService
=
Executors
.
newSingleThreadExecutor
();
private
static
ExecutorService
executorService
=
Executors
.
newSingleThreadExecutor
();
private
static
boolean
isRunning
=
true
;
@PostConstruct
@PostConstruct
public
void
start
()
{
public
void
start
()
{
...
@@ -1029,6 +665,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
...
@@ -1029,6 +665,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
*/
*/
@Override
@Override
public
void
run
()
{
public
void
run
()
{
boolean
isRunning
=
true
;
while
(
isRunning
)
{
while
(
isRunning
)
{
AlarmParam
alarmParam
=
null
;
AlarmParam
alarmParam
=
null
;
try
{
try
{
...
@@ -1076,7 +713,6 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
...
@@ -1076,7 +713,6 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
list
.
add
(
deviceData
);
list
.
add
(
deviceData
);
//保存到mongo
//保存到mongo
saveData
(
list
,
"soe"
);
saveData
(
list
,
"soe"
);
if
(
equipment
!=
null
)
{
if
(
equipment
!=
null
)
{
String
batchNo
=
null
;
String
batchNo
=
null
;
Object
batch
=
null
;
Object
batch
=
null
;
...
@@ -1099,38 +735,10 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
...
@@ -1099,38 +735,10 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
if
(
ObjectUtils
.
isEmpty
(
batchNo
))
{
if
(
ObjectUtils
.
isEmpty
(
batchNo
))
{
return
;
return
;
}
}
// if (batch == null) {
// batchNo = UUID.randomUUID().toString();
deviceData
.
setBatchNo
(
batchNo
);
deviceData
.
setBatchNo
(
batchNo
);
deviceData
.
setMonitor
(
equipment
.
getName
());
deviceData
.
setMonitor
(
equipment
.
getName
());
deviceData
.
setEquimentId
(
String
.
valueOf
(
equipment
.
getId
()));
deviceData
.
setEquimentId
(
String
.
valueOf
(
equipment
.
getId
()));
// FireEquimentDataRo ruleData = new FireEquimentDataRo();
// ruleData.setBatchNo(batchNo);
// ruleData.setEquimentId(String.valueOf(equipment.getId()));
// ruleData.setMonitor(equipment.getName());
// ruleData.setCode(deviceData.getCode());
// ruleData.setFireEquimentId(fireEquipment.getId());
// ruleData.setName(fireEquipmentPoint.getName());
// ruleData.setNodeState("true".equals(deviceData.getState()) ? "1" : "0");
// ruleData.setUnit(fireEquipmentPoint.getUnit());
// ruleData.setValue(deviceData.getState());
// ruleData.setFireEqumentName(fireEquipment.getName());
// Object result = remoteRuleServer.fireRule(ruleData, "风险管控/fireEquiment");
//处理返回结果
// } else {
// if (batch == null) {
// batchNo = batch.toString();
// }
//List<RiskSource> riskSources = this.riskSourceMapper.queryByFireEqument(fireEquipmentPoint.getFireEquipmentId());
//asymbleWithParent(batchNo, riskSources, FireEquimentDataRo.class.getSimpleName(), fireEquipmentPoint.getFireEquipmentId(), deviceData.getNodeState(), null, null);
// if (ObjectUtils.isEmpty(fireEquipmentPointType) || "false".equals(deviceData.getState())) {
// return;
// }
if
(
"alarm_type_fire"
.
equals
(
fireEquipmentPointType
))
{
if
(
"alarm_type_fire"
.
equals
(
fireEquipmentPointType
))
{
if
(
deviceData
.
getIsMock
())
{
if
(
deviceData
.
getIsMock
())
{
redisTemplate
.
delete
(
RiskSourceServiceImpl
.
cacheKeyForCanBeRunning
());
redisTemplate
.
delete
(
RiskSourceServiceImpl
.
cacheKeyForCanBeRunning
());
...
@@ -1149,7 +757,6 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
...
@@ -1149,7 +757,6 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
redisTemplate
.
opsForHash
().
put
(
"currentContingency"
,
"batchNo"
,
batchNo
);
redisTemplate
.
opsForHash
().
put
(
"currentContingency"
,
"batchNo"
,
batchNo
);
redisTemplate
.
opsForHash
().
put
(
"currentContingency"
,
"contingencyPlan"
,
null
);
redisTemplate
.
opsForHash
().
put
(
"currentContingency"
,
"contingencyPlan"
,
null
);
redisTemplate
.
opsForHash
().
put
(
"currentContingency"
,
"alarmType"
,
null
);
redisTemplate
.
opsForHash
().
put
(
"currentContingency"
,
"alarmType"
,
null
);
// redisTemplate.opsForValue().set("equipmentId", null);
}
else
{
}
else
{
if
(
"alarm_type_trouble"
.
equals
(
fireEquipmentPointType
))
{
if
(
"alarm_type_trouble"
.
equals
(
fireEquipmentPointType
))
{
notifyAlarm
(
fireEquipmentPoint
,
deviceData
);
notifyAlarm
(
fireEquipmentPoint
,
deviceData
);
...
@@ -1229,23 +836,6 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
...
@@ -1229,23 +836,6 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
if
(
dict
!=
null
&&
dict
.
getDictValue
().
equals
(
"alarm_type_trouble"
))
{
if
(
dict
!=
null
&&
dict
.
getDictValue
().
equals
(
"alarm_type_trouble"
))
{
notifyAlarm
(
fireEquipmentPoint
,
param
);
notifyAlarm
(
fireEquipmentPoint
,
param
);
}
}
// String batchNo = UUID.randomUUID().toString();
// FireEquimentDataRo ruleData = new FireEquimentDataRo();
// ruleData.setBatchNo(batchNo);
// ruleData.setEquimentId(String.valueOf(equipment.getId()));
// ruleData.setMonitor(equipment.getName());
// ruleData.setCode(data.getFireEquipmentCode());
// ruleData.setFireEquimentId(Long.valueOf(data.getFireEquipmentId()));
// ruleData.setName(data.getPointName());
// ruleData.setNodeState("true".equals(data.getState()) ? "1" : "0");
// ruleData.setUnit(data.getUnit());
// ruleData.setValue(data.getSoe() + "");
// ruleData.setFireEqumentName(data.getFireEquipmentName());
// try {
// Object result = remoteRuleServer.fireRule(ruleData, "风险管控/fireEquiment");
// } catch (Exception e) {
// e.printStackTrace();
// }
}
}
}
}
}
}
...
@@ -1343,9 +933,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
...
@@ -1343,9 +933,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
redisTemplate
.
opsForValue
().
set
(
"equipmentId"
,
null
);
redisTemplate
.
opsForValue
().
set
(
"equipmentId"
,
null
);
break
;
break
;
default
:
default
:
// redisTemplate.opsForHash().put("currentContingency", "contingencyPlan", null);
redisTemplate
.
opsForValue
().
set
(
"equipmentId"
,
contingencyDeviceStatus
.
getEquipmentId
());
redisTemplate
.
opsForValue
().
set
(
"equipmentId"
,
contingencyDeviceStatus
.
getEquipmentId
());
// redisTemplate.opsForHash().put("currentContingency", "equipmentId", null);
break
;
break
;
}
}
if
(
alarmType
==
null
)
{
if
(
alarmType
==
null
)
{
...
@@ -1428,6 +1016,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
...
@@ -1428,6 +1016,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
*/
*/
@Override
@Override
public
void
notifyFmeaFromUpdate
(
Long
fmeaId
,
String
nofityType
)
{
public
void
notifyFmeaFromUpdate
(
Long
fmeaId
,
String
nofityType
)
{
//1.更新危险因素:rpn、rpni、风险等级
Fmea
fmea
=
fmeaMapper
.
getById
(
fmeaId
);
Fmea
fmea
=
fmeaMapper
.
getById
(
fmeaId
);
if
(
fmea
==
null
)
{
if
(
fmea
==
null
)
{
return
;
return
;
...
@@ -1436,8 +1025,10 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
...
@@ -1436,8 +1025,10 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
BigDecimal
oidValue
=
new
BigDecimal
(
fmea
.
getOidValue
());
BigDecimal
oidValue
=
new
BigDecimal
(
fmea
.
getOidValue
());
BigDecimal
sidValue
=
new
BigDecimal
(
fmea
.
getSidValue
());
BigDecimal
sidValue
=
new
BigDecimal
(
fmea
.
getSidValue
());
BigDecimal
didValue
=
new
BigDecimal
(
fmea
.
getDidValue
());
BigDecimal
didValue
=
new
BigDecimal
(
fmea
.
getDidValue
());
//1.1计算rpni
BigDecimal
rpni
=
oidValue
.
multiply
(
sidValue
).
multiply
(
didValue
);
BigDecimal
rpni
=
oidValue
.
multiply
(
sidValue
).
multiply
(
didValue
);
BigDecimal
rpn
;
BigDecimal
rpn
;
//1.2计算rpn:为空则rpni = rpn;不为空则重新计算s*d*newo
if
(
fmea
.
getNewEvaluationOid
()
==
null
)
{
if
(
fmea
.
getNewEvaluationOid
()
==
null
)
{
fmea
.
setNewEvaluationOid
(
fmea
.
getEvaluationOid
());
fmea
.
setNewEvaluationOid
(
fmea
.
getEvaluationOid
());
rpn
=
rpni
;
rpn
=
rpni
;
...
@@ -1446,39 +1037,54 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
...
@@ -1446,39 +1037,54 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
rpn
=
newOidValue
.
multiply
(
sidValue
).
multiply
(
didValue
);
rpn
=
newOidValue
.
multiply
(
sidValue
).
multiply
(
didValue
);
}
}
List
<
RiskLevel
>
levels
=
riskLevelDao
.
findAll
();
List
<
RiskLevel
>
levels
=
riskLevelDao
.
findAll
();
RiskLevel
newLevel
=
getBetweenLevel
(
rpn
,
levels
);
RiskLevel
newLevel
=
RpnUtils
.
getBetweenLevel
(
rpn
,
levels
);
S
tring
jpushTarget
=
null
;
S
et
<
String
>
jpushTargets
=
new
LinkedHashSet
<>()
;
fmea
.
setRpni
(
rpni
);
fmea
.
setRpni
(
rpni
);
fmea
.
setRpn
(
rpn
);
fmea
.
setRpn
(
rpn
);
if
(
newLevel
!=
null
)
{
if
(
newLevel
!=
null
)
{
fmea
.
setRiskLevelId
(
newLevel
.
getId
());
fmea
.
setRiskLevelId
(
newLevel
.
getId
());
jpushTarget
=
getJpushTarget
(
fmea
,
newLevel
.
get
Level
());
jpushTarget
s
=
getJpushTarget
(
fmea
,
newLevel
.
getManage
Level
());
}
}
//1.3更新fmea
fmeaMapper
.
updateRpn
(
fmea
);
fmeaMapper
.
updateRpn
(
fmea
);
saveRpnLog
(
fmea
.
getRiskSourceId
(),
fmeaId
,
rpn
,
rpni
);
//2.计算上级风险值(风险点及父节点)
this
.
notifyRiskSource
(
fmea
.
getRiskSourceId
(),
nofityType
,
jpushTarget
);
this
.
notifyRiskSource
(
fmeaId
,
fmea
.
getRiskSourceId
(),
nofityType
,
jpushTargets
);
}
}
private
Set
<
String
>
getJpushTarget
(
Fmea
fmea
,
Integer
managerLevel
)
{
Set
<
String
>
targets
=
new
LinkedHashSet
<>();
//TODO:新平台待调整userId:Long->String,接受者(极光注册者)按照项目进行调整
Set
<
Long
>
userIds
=
this
.
getUsersByLevel
(
managerLevel
,
fmea
);
userIds
.
forEach
(
userId
->{
SUser
user
=
iUserDao
.
findById
(
userId
);
if
(
user
!=
null
)
{
String
target
=
user
.
getMobile
();
targets
.
add
(
target
);
}
}
});
return
targets
;
}
}
private
String
getJpushTarget
(
Fmea
fmea
,
Integer
level
)
{
private
Set
<
Long
>
getUsersByLevel
(
Integer
level
,
Fmea
fmea
)
{
String
jpushTarget
=
null
;
Set
<
Long
>
userIds
=
new
HashSet
<>();
Long
userId
=
null
;
if
(
level
.
equals
(
1
))
{
if
(
level
.
equals
(
1
))
{
userId
=
fmea
.
getCompanyLeader
();
userIds
.
add
(
fmea
.
getCompanyLeader
());
userIds
.
add
(
fmea
.
getDepartmentLeader
());
userIds
.
add
(
fmea
.
getGroupLeader
());
userIds
.
add
(
fmea
.
getPersonLeader
());
}
else
if
(
level
.
equals
(
2
))
{
}
else
if
(
level
.
equals
(
2
))
{
userId
=
fmea
.
getDepartmentLeader
();
userIds
.
add
(
fmea
.
getDepartmentLeader
());
userIds
.
add
(
fmea
.
getGroupLeader
());
userIds
.
add
(
fmea
.
getPersonLeader
());
}
else
if
(
level
.
equals
(
3
))
{
}
else
if
(
level
.
equals
(
3
))
{
userId
=
fmea
.
getGroupLeader
();
userIds
.
add
(
fmea
.
getGroupLeader
());
userIds
.
add
(
fmea
.
getPersonLeader
());
}
else
if
(
level
.
equals
(
4
))
{
}
else
if
(
level
.
equals
(
4
))
{
userId
=
fmea
.
getPersonLeader
();
userIds
.
add
(
fmea
.
getPersonLeader
());
}
if
(
userId
!=
null
)
{
SUser
user
=
iUserDao
.
findById
(
userId
);
if
(
user
!=
null
)
{
jpushTarget
=
user
.
getMobile
();
}
}
}
return
jpushTarget
;
userIds
.
remove
(
null
);
return
userIds
;
}
}
/**
/**
...
@@ -1493,9 +1099,10 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
...
@@ -1493,9 +1099,10 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
if
(
fmea
.
getEvaluationOid
()
!=
null
&&
fmea
.
getEvaluationSid
()
!=
null
&&
fmea
.
getEvaluationDid
()
!=
null
)
{
if
(
fmea
.
getEvaluationOid
()
!=
null
&&
fmea
.
getEvaluationSid
()
!=
null
&&
fmea
.
getEvaluationDid
()
!=
null
)
{
List
<
FmeaEquipmentPoint
>
equipmentPoints
=
fmeaEquipmentPointMapper
.
listFmeaByFmeaId
(
fmeaId
);
List
<
FmeaEquipmentPoint
>
equipmentPoints
=
fmeaEquipmentPointMapper
.
listFmeaByFmeaId
(
fmeaId
);
List
<
FmeaPointInputitem
>
pointInputitems
=
fmeaPointInputitemMapper
.
listFmeaByFmeaId
(
fmeaId
);
List
<
FmeaPointInputitem
>
pointInputitems
=
fmeaPointInputitemMapper
.
listFmeaByFmeaId
(
fmeaId
);
//
根据设备和巡检数据获取高的故障率
//
1.准备更新数据
Double
maxRate
=
getMaxRate
(
equipmentPoints
,
pointInputitems
);
Double
maxRate
=
RpnUtils
.
getMaxRate
(
equipmentPoints
,
pointInputitems
);
if
(
maxRate
!=
null
)
{
if
(
maxRate
!=
null
)
{
//1.1根据设备和巡检数据获取高的故障率
List
<
EvaluationModel
>
oModels
=
iEvaluationModelDao
.
findAllByType
(
"O"
);
List
<
EvaluationModel
>
oModels
=
iEvaluationModelDao
.
findAllByType
(
"O"
);
EvaluationModel
oEvaluationModel
=
getBetweenModel
(
maxRate
,
oModels
);
EvaluationModel
oEvaluationModel
=
getBetweenModel
(
maxRate
,
oModels
);
if
(
oEvaluationModel
!=
null
)
{
if
(
oEvaluationModel
!=
null
)
{
...
@@ -1504,18 +1111,19 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
...
@@ -1504,18 +1111,19 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
BigDecimal
didValue
=
new
BigDecimal
(
fmea
.
getDidValue
());
BigDecimal
didValue
=
new
BigDecimal
(
fmea
.
getDidValue
());
BigDecimal
rpn
=
newOidValue
.
multiply
(
sidValue
).
multiply
(
didValue
);
BigDecimal
rpn
=
newOidValue
.
multiply
(
sidValue
).
multiply
(
didValue
);
List
<
RiskLevel
>
levels
=
riskLevelDao
.
findAll
();
List
<
RiskLevel
>
levels
=
riskLevelDao
.
findAll
();
RiskLevel
newLevel
=
getBetweenLevel
(
rpn
,
levels
);
RiskLevel
newLevel
=
RpnUtils
.
getBetweenLevel
(
rpn
,
levels
);
fmea
.
setRpn
(
rpn
);
fmea
.
setRpn
(
rpn
);
fmea
.
setNewEvaluationOid
(
oEvaluationModel
.
getId
());
fmea
.
setNewEvaluationOid
(
oEvaluationModel
.
getId
());
S
tring
jpushTarget
=
null
;
S
et
<
String
>
jpushTargets
=
new
LinkedHashSet
<>()
;
if
(
newLevel
!=
null
)
{
if
(
newLevel
!=
null
)
{
jpushTarget
=
getJpushTarget
(
fmea
,
newLevel
.
getLevel
());
//1.2根据风险等级对应的责任等级获取责任人
jpushTargets
=
getJpushTarget
(
fmea
,
newLevel
.
getManageLevel
());
fmea
.
setRiskLevelId
(
newLevel
.
getId
());
fmea
.
setRiskLevelId
(
newLevel
.
getId
());
}
}
//1.3.更新fmea的rpn、风险等级及newOid
fmeaMapper
.
updateRpn
(
fmea
);
fmeaMapper
.
updateRpn
(
fmea
);
saveRpnLog
(
fmea
.
getRiskSourceId
(),
fmeaId
,
rpn
,
fmea
.
getRpni
());
//2.计算风险点rpn、rpni、riskLevelId
//影响风险点的sod值
this
.
notifyRiskSource
(
fmeaId
,
fmea
.
getRiskSourceId
(),
notifyType
,
jpushTargets
);
this
.
notifyRiskSource
(
fmea
.
getRiskSourceId
(),
notifyType
,
jpushTarget
);
}
}
}
}
}
}
...
@@ -1524,9 +1132,11 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
...
@@ -1524,9 +1132,11 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
private
void
saveRpnLog
(
Long
riskSourceId
,
Long
fmeaId
,
BigDecimal
rpn
,
BigDecimal
rpni
)
{
private
void
saveRpnLog
(
Long
riskSourceId
,
Long
fmeaId
,
BigDecimal
rpn
,
BigDecimal
rpni
)
{
RpnChangeLog
rpnChangeLog
=
new
RpnChangeLog
();
RpnChangeLog
rpnChangeLog
=
new
RpnChangeLog
();
rpnChangeLog
.
setRiskSourceId
(
riskSourceId
);
rpnChangeLog
.
setRiskSourceId
(
riskSourceId
);
rpnChangeLog
.
setFmeaId
(
fmeaId
);
rpnChangeLog
.
setRpn
(
rpn
);
rpnChangeLog
.
setRpn
(
rpn
);
rpnChangeLog
.
setRpni
(
rpni
);
rpnChangeLog
.
setRpni
(
rpni
);
rpnChangeLog
.
setType
(
RpnUtils
.
getChangeType
(
rpn
,
rpni
));
rpnChangeLog
.
setTriggerBy
(
fmeaId
);
rpnChangeLog
.
setFmeaId
(
fmeaId
);
iRpnChangeLogDao
.
save
(
rpnChangeLog
);
iRpnChangeLogDao
.
save
(
rpnChangeLog
);
}
}
...
@@ -1540,114 +1150,124 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
...
@@ -1540,114 +1150,124 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
return
null
;
return
null
;
}
}
private
Double
getMaxRate
(
List
<
FmeaEquipmentPoint
>
equipmentPoints
,
List
<
FmeaPointInputitem
>
pointInputitems
)
{
Double
pointInputitemRate
=
null
;
if
(!
CollectionUtils
.
isEmpty
(
pointInputitems
))
{
int
totalPointInputitem
=
pointInputitems
.
size
();
int
pointInputitemUnNormal
=
0
;
for
(
FmeaPointInputitem
pointInputitem
:
pointInputitems
)
{
if
(
pointInputitem
.
getState
()
==
1
)
{
pointInputitemUnNormal
++;
}
}
pointInputitemRate
=
pointInputitemUnNormal
*
1.0
/
totalPointInputitem
;
}
Double
equipmentPointRate
=
null
;
if
(!
CollectionUtils
.
isEmpty
(
equipmentPoints
))
{
int
totalEquipmentPoint
=
equipmentPoints
.
size
();
int
equipmentPointUnNormal
=
0
;
for
(
FmeaEquipmentPoint
equipmentPoint
:
equipmentPoints
)
{
if
(
equipmentPoint
.
getState
()
==
1
)
{
equipmentPointUnNormal
++;
}
}
equipmentPointRate
=
equipmentPointUnNormal
*
1.0
/
totalEquipmentPoint
;
}
if
(
equipmentPointRate
==
null
)
{
if
(
pointInputitemRate
==
null
)
{
return
null
;
}
else
{
return
pointInputitemRate
;
}
}
else
{
if
(
pointInputitemRate
==
null
)
{
return
equipmentPointRate
;
}
else
{
if
(
pointInputitemRate
<
equipmentPointRate
)
{
return
equipmentPointRate
;
}
else
{
return
pointInputitemRate
;
}
}
}
}
/**
/**
* fmea的更新导致rpn、rpni的值改变
* fmea的更新导致rpn、rpni的值改变
*/
*/
@Override
@Override
public
void
notifyRiskSource
(
Long
riskSourceId
,
String
notifyType
,
String
jpushTarget
)
{
public
void
notifyRiskSource
(
Long
fmeaId
,
Long
riskSourceId
,
String
notifyType
,
Set
<
String
>
jpushTargets
)
{
RiskSource
riskSource
=
iRiskSourceDao
.
findById
(
riskSourceId
);
RiskSource
riskSource
=
iRiskSourceDao
.
findById
(
riskSourceId
);
if
(
riskSource
==
null
)
{
if
(
riskSource
==
null
)
{
return
;
return
;
}
}
List
<
Fmea
>
fmeas
=
fmeaMapper
.
listByRiskSourceId
(
riskSourceId
);
List
<
Fmea
>
fmeas
=
fmeaMapper
.
listByRiskSourceId
(
riskSourceId
);
if
(
CollectionUtils
.
isEmpty
(
fmeas
))
{
if
(
CollectionUtils
.
isEmpty
(
fmeas
))
{
//fema删除
BigDecimal
resetValue
=
new
BigDecimal
(
"0"
);
BigDecimal
resetValue
=
new
BigDecimal
(
"0"
);
riskSource
.
setRpn
(
resetValue
);
riskSource
.
setRpn
(
null
);
riskSource
.
setRpni
(
resetValue
);
riskSource
.
setRpni
(
null
);
riskSource
.
setRiskLevelId
(
0L
);
riskSource
.
setRiskLevelId
(
null
);
//1.更新fmea对应风险点rpn、rpni、level
riskSourceMapper
.
updateRpn
(
riskSource
);
riskSourceMapper
.
updateRpn
(
riskSource
);
//2.记录风险点rpn变化流水
this
.
saveRpnLog
(
riskSource
.
getId
(),
fmeaId
,
resetValue
,
resetValue
);
//3.更新父节点rpn、rpni、风险等级
this
.
updateParentRpn
(
riskSource
.
getParentId
());
}
else
{
//fmea评价、巡检、告警
RpnCalculationBo
rpnValueBo
=
RpnUtils
.
calRpnAndRpni
(
fmeas
);
if
(
rpnValueBo
.
isEmpty
()){
return
;
}
}
BigDecimal
maxSidValue
=
new
BigDecimal
(
"0"
);
BigDecimal
rpn
=
rpnValueBo
.
getRpn
();
BigDecimal
maxDidValue
=
new
BigDecimal
(
"0"
);
BigDecimal
rpni
=
rpnValueBo
.
getRpni
();
BigDecimal
totalOidValue
=
new
BigDecimal
(
"0"
);
List
<
RiskLevel
>
levels
=
riskLevelDao
.
findAll
();
BigDecimal
totalNewOidValue
=
new
BigDecimal
(
"0"
);
RiskLevel
newRiskLevel
=
RpnUtils
.
getBetweenLevel
(
rpn
,
levels
);
long
count
=
0L
;
RiskLevel
oldRiskLevel
=
RpnUtils
.
getBetweenLevel
(
rpni
,
levels
);
for
(
Fmea
fmea
:
fmeas
)
{
if
(
newRiskLevel
!=
null
&&
oldRiskLevel
!=
null
)
{
if
(
fmea
.
getEvaluationDid
()
!=
null
&&
fmea
.
getEvaluationSid
()
!=
null
&&
fmea
.
getEvaluationOid
()
!=
null
&&
fmea
.
getNewEvaluationOid
()
!=
null
)
{
riskSource
.
setRpn
(
rpn
);
BigDecimal
didValue
=
new
BigDecimal
(
fmea
.
getDidValue
());
riskSource
.
setRpni
(
rpni
);
BigDecimal
sidValue
=
new
BigDecimal
(
fmea
.
getSidValue
());
riskSource
.
setRiskLevelId
(
newRiskLevel
.
getId
());
BigDecimal
oidValue
=
new
BigDecimal
(
fmea
.
getOidValue
());
//1.更新fmea对应风险点rpn、rpni、level
BigDecimal
newOidValue
=
new
BigDecimal
(
fmea
.
getNewOidValue
());
riskSourceMapper
.
updateRpn
(
riskSource
);
if
(
didValue
.
compareTo
(
maxDidValue
)
==
1
)
{
//2.记录风险点rpn变化流水
maxDidValue
=
didValue
;
this
.
saveRpnLog
(
riskSource
.
getId
(),
fmeaId
,
rpn
,
rpni
);
//3.更新父节点rpn、rpni、风险等级
this
.
updateParentRpn
(
riskSource
.
getParentId
());
//4.极光推送给手机客户端
jpushRiskSourceMessage
(
"风险预警"
,
jpushTargets
);
//5.规则告警(消息)TODO
notifyRule
(
riskSourceId
,
rpn
,
rpni
,
oldRiskLevel
.
getLevel
(),
newRiskLevel
.
getLevel
(),
notifyType
);
}
}
if
(
sidValue
.
compareTo
(
maxSidValue
)
==
1
)
{
maxSidValue
=
sidValue
;
}
}
totalOidValue
=
totalOidValue
.
add
(
oidValue
);
totalNewOidValue
=
totalNewOidValue
.
add
(
newOidValue
);
count
++;
}
}
@Override
public
void
notifyFmeaFromDelete
(
Long
riskSourceId
,
String
from
)
{
//1.计算风险点风险值信息
this
.
notifyRiskSource
(
0L
,
riskSourceId
,
from
,
null
);
}
}
if
(
count
==
0
)
{
@Override
public
void
notifyRiskSourceDelete
(
Long
parentId
)
{
//1.风险点删除触发更新父节点rpn、rpni、风险等级
this
.
updateParentRpn
(
parentId
);
}
private
void
updateParentRpn
(
long
parentId
)
{
RiskSource
riskSource
=
iRiskSourceDao
.
findById
(
parentId
);
if
(
riskSource
!=
null
){
List
<
RiskSource
>
riskSourceList
=
new
ArrayList
<>();
List
<
Long
>
ids
=
new
ArrayList
<>();
riskSourceList
=
iRiskSourceDao
.
findByParentId
(
riskSource
.
getId
());
//递归获取区域(含子区域)所有点
this
.
getAllRiskPoint
(
ids
,
riskSourceList
);
if
(
CollectionUtils
.
isEmpty
(
ids
)){
//没有风险点,则赋初始值null
riskSource
.
setRpn
(
null
);
riskSource
.
setRpni
(
null
);
riskSource
.
setRiskLevelId
(
null
);
}
else
{
List
<
Fmea
>
fmeas
=
fmeaMapper
.
listByRiskSourceIds
(
ids
);
RpnCalculationBo
rpnValueBo
=
RpnUtils
.
calRpnAndRpni
(
fmeas
);
if
(
rpnValueBo
.
isEmpty
()){
return
;
return
;
}
}
BigDecimal
averageOidValue
=
totalOidValue
.
divide
(
BigDecimal
.
valueOf
(
count
));
BigDecimal
rpn
=
rpnValueBo
.
getRpn
();
BigDecimal
averageNewOidValue
=
totalNewOidValue
.
divide
(
BigDecimal
.
valueOf
(
count
));
BigDecimal
rpni
=
rpnValueBo
.
getRpni
();
BigDecimal
rpn
=
maxDidValue
.
multiply
(
maxSidValue
).
multiply
(
averageNewOidValue
);
BigDecimal
rpni
=
maxDidValue
.
multiply
(
maxSidValue
).
multiply
(
averageOidValue
);
List
<
RiskLevel
>
levels
=
riskLevelDao
.
findAll
();
List
<
RiskLevel
>
levels
=
riskLevelDao
.
findAll
();
RiskLevel
newRiskLevel
=
getBetweenLevel
(
rpn
,
levels
);
RiskLevel
newRiskLevel
=
RpnUtils
.
getBetweenLevel
(
rpn
,
levels
);
RiskLevel
oldRiskLevel
=
getBetweenLevel
(
rpni
,
levels
);
if
(
newRiskLevel
!=
null
){
if
(
newRiskLevel
!=
null
)
{
riskSource
.
setRpn
(
rpn
);
riskSource
.
setRpn
(
rpn
);
riskSource
.
setRpni
(
rpni
);
riskSource
.
setRpni
(
rpni
);
riskSource
.
setRiskLevelId
(
newRiskLevel
.
getId
());
riskSource
.
setRiskLevelId
(
newRiskLevel
.
getId
());
riskSourceMapper
.
updateRpn
(
riskSource
);
}
//极光推送给手机客户端
}
jpushRiskSourceMessage
(
"风险点告警"
,
jpushTarget
);
iRiskSourceDao
.
save
(
riskSource
);
//规则告警
this
.
updateParentRpn
(
riskSource
.
getParentId
());
notifyRule
(
riskSourceId
,
rpn
,
rpni
,
oldRiskLevel
.
getLevel
(),
newRiskLevel
.
getLevel
(),
notifyType
);
}
}
/**
* 获得子节点:巡检点
* @param ids 返回
* @param riskSourceList 风险点区域列表
*/
private
void
getAllRiskPoint
(
List
<
Long
>
ids
,
List
<
RiskSource
>
riskSourceList
)
{
//TODO 递归
for
(
RiskSource
riskSource
:
riskSourceList
){
if
(
riskSource
.
getIsRegion
().
equalsIgnoreCase
(
"TRUE"
)){
List
<
RiskSource
>
list
=
iRiskSourceDao
.
findByParentId
(
riskSource
.
getId
());
if
(
list
!=
null
){
this
.
getAllRiskPoint
(
ids
,
list
);
}
}
else
{
ids
.
add
(
riskSource
.
getId
());
}
}
}
}
}
/**
/**
* 极光推送
* 极光推送
*/
*/
private
void
jpushRiskSourceMessage
(
String
content
,
S
tring
jpushTarget
)
{
private
void
jpushRiskSourceMessage
(
String
content
,
S
et
<
String
>
jpushTarget
)
{
if
(
String
Utils
.
isEmpty
(
jpushTarget
))
{
if
(
Collection
Utils
.
isEmpty
(
jpushTarget
))
{
return
;
return
;
}
}
PushMsgParam
pushMsgParam
=
new
PushMsgParam
();
PushMsgParam
pushMsgParam
=
new
PushMsgParam
();
...
@@ -1686,23 +1306,9 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
...
@@ -1686,23 +1306,9 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
}
}
node3dVoService
.
updateByRiskSourceId
(
riskSourceRuleRo
.
getId
(),
frequency
);
node3dVoService
.
updateByRiskSourceId
(
riskSourceRuleRo
.
getId
(),
frequency
);
try
{
try
{
remoteRuleServer
.
fireRule
(
riskSourceRuleRo
,
"风险管控/riskSource"
);
//
remoteRuleServer.fireRule(riskSourceRuleRo, "风险管控/riskSource");
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"调用规则异常"
,
e
);
log
.
error
(
"调用规则异常"
,
e
);
}
}
}
}
private
RiskLevel
getBetweenLevel
(
BigDecimal
rpni
,
List
<
RiskLevel
>
levels
)
{
if
(
CollectionUtils
.
isEmpty
(
levels
))
{
return
null
;
}
for
(
RiskLevel
level
:
levels
)
{
int
downResult
=
level
.
getDownLimit
().
compareTo
(
rpni
);
int
topResult
=
level
.
getTopLimit
().
compareTo
(
rpni
);
if
(
downResult
==
-
1
&&
topResult
!=
-
1
)
{
return
level
;
}
}
return
null
;
}
}
}
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/service/intfc/IRiskSourceService.java
View file @
f6fa54f6
...
@@ -16,6 +16,7 @@ import org.springframework.data.domain.Page;
...
@@ -16,6 +16,7 @@ import org.springframework.data.domain.Page;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Set
;
public
interface
IRiskSourceService
{
public
interface
IRiskSourceService
{
...
@@ -111,5 +112,9 @@ public interface IRiskSourceService {
...
@@ -111,5 +112,9 @@ public interface IRiskSourceService {
void
notifyFmeaFromUpdate
(
Long
fmeaId
,
String
nofityType
);
void
notifyFmeaFromUpdate
(
Long
fmeaId
,
String
nofityType
);
void
notifyRiskSource
(
Long
riskSourceId
,
String
notifyType
,
String
jpushTarget
);
void
notifyRiskSource
(
Long
fmeaId
,
Long
riskSourceId
,
String
notifyType
,
Set
<
String
>
jpushTargets
);
void
notifyFmeaFromDelete
(
Long
handId
,
String
from
);
void
notifyRiskSourceDelete
(
Long
handId
);
}
}
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/util/RpnUtils.java
0 → 100644
View file @
f6fa54f6
package
com
.
yeejoin
.
amos
.
fas
.
business
.
util
;
import
com.yeejoin.amos.fas.business.bo.RpnCalculationBo
;
import
com.yeejoin.amos.fas.common.enums.RpnChangeLogTypeEum
;
import
com.yeejoin.amos.fas.dao.entity.Fmea
;
import
com.yeejoin.amos.fas.dao.entity.FmeaEquipmentPoint
;
import
com.yeejoin.amos.fas.dao.entity.FmeaPointInputitem
;
import
com.yeejoin.amos.fas.dao.entity.RiskLevel
;
import
org.springframework.util.CollectionUtils
;
import
java.math.BigDecimal
;
import
java.util.List
;
/**
* @author DELL
*/
public
class
RpnUtils
{
/**
* 计算风险值
* @param fmeas
* @return RpnCalculationBo
*/
public
static
RpnCalculationBo
calRpnAndRpni
(
List
<
Fmea
>
fmeas
){
BigDecimal
maxSidValue
=
new
BigDecimal
(
"0"
);
BigDecimal
maxDidValue
=
new
BigDecimal
(
"0"
);
BigDecimal
totalOidValue
=
new
BigDecimal
(
"0"
);
BigDecimal
totalNewOidValue
=
new
BigDecimal
(
"0"
);
long
count
=
0L
;
for
(
Fmea
fmea
:
fmeas
)
{
if
(
fmea
.
getEvaluationDid
()
!=
null
&&
fmea
.
getEvaluationSid
()
!=
null
&&
fmea
.
getEvaluationOid
()
!=
null
&&
fmea
.
getNewEvaluationOid
()
!=
null
)
{
BigDecimal
didValue
=
new
BigDecimal
(
fmea
.
getDidValue
());
BigDecimal
sidValue
=
new
BigDecimal
(
fmea
.
getSidValue
());
BigDecimal
oidValue
=
new
BigDecimal
(
fmea
.
getOidValue
());
BigDecimal
newOidValue
=
new
BigDecimal
(
fmea
.
getNewOidValue
());
if
(
didValue
.
compareTo
(
maxDidValue
)
==
1
)
{
maxDidValue
=
didValue
;
}
if
(
sidValue
.
compareTo
(
maxSidValue
)
==
1
)
{
maxSidValue
=
sidValue
;
}
totalOidValue
=
totalOidValue
.
add
(
oidValue
);
totalNewOidValue
=
totalNewOidValue
.
add
(
newOidValue
);
count
++;
}
}
RpnCalculationBo
rpnValue
=
new
RpnCalculationBo
();
rpnValue
.
setSize
(
count
);
if
(
count
==
0
)
{
return
rpnValue
;
}
BigDecimal
averageOidValue
=
totalOidValue
.
divide
(
BigDecimal
.
valueOf
(
count
),
2
,
BigDecimal
.
ROUND_HALF_UP
);
BigDecimal
averageNewOidValue
=
totalNewOidValue
.
divide
(
BigDecimal
.
valueOf
(
count
),
2
,
BigDecimal
.
ROUND_HALF_UP
);
BigDecimal
rpn
=
maxDidValue
.
multiply
(
maxSidValue
).
multiply
(
averageNewOidValue
).
setScale
(
2
,
BigDecimal
.
ROUND_HALF_UP
);
BigDecimal
rpni
=
maxDidValue
.
multiply
(
maxSidValue
).
multiply
(
averageOidValue
).
setScale
(
2
,
BigDecimal
.
ROUND_HALF_UP
);
rpnValue
.
setRpn
(
rpn
);
rpnValue
.
setRpni
(
rpni
);
return
rpnValue
;
}
/**
* 计算最大故障率
* @param equipmentPoints
* @param pointInputitems
* @return
*/
public
static
Double
getMaxRate
(
List
<
FmeaEquipmentPoint
>
equipmentPoints
,
List
<
FmeaPointInputitem
>
pointInputitems
)
{
Double
pointInputitemRate
=
null
;
if
(!
CollectionUtils
.
isEmpty
(
pointInputitems
))
{
int
totalPointInputitem
=
pointInputitems
.
size
();
int
pointInputitemUnNormal
=
0
;
for
(
FmeaPointInputitem
pointInputitem
:
pointInputitems
)
{
if
(
pointInputitem
.
getState
()
==
1
)
{
pointInputitemUnNormal
++;
}
}
pointInputitemRate
=
pointInputitemUnNormal
*
1.0
/
totalPointInputitem
;
}
Double
equipmentPointRate
=
null
;
if
(!
CollectionUtils
.
isEmpty
(
equipmentPoints
))
{
int
totalEquipmentPoint
=
equipmentPoints
.
size
();
int
equipmentPointUnNormal
=
0
;
for
(
FmeaEquipmentPoint
equipmentPoint
:
equipmentPoints
)
{
if
(
equipmentPoint
.
getState
()
==
1
)
{
equipmentPointUnNormal
++;
}
}
equipmentPointRate
=
equipmentPointUnNormal
*
1.0
/
totalEquipmentPoint
;
}
if
(
equipmentPointRate
==
null
)
{
if
(
pointInputitemRate
==
null
)
{
return
null
;
}
else
{
return
pointInputitemRate
;
}
}
else
{
if
(
pointInputitemRate
==
null
)
{
return
equipmentPointRate
;
}
else
{
if
(
pointInputitemRate
<
equipmentPointRate
)
{
return
equipmentPointRate
;
}
else
{
return
pointInputitemRate
;
}
}
}
}
/**
* 获得风险等级
* @param rpni
* @param levels
* @return
*/
public
static
RiskLevel
getBetweenLevel
(
BigDecimal
rpni
,
List
<
RiskLevel
>
levels
)
{
if
(
CollectionUtils
.
isEmpty
(
levels
))
{
return
null
;
}
for
(
RiskLevel
level
:
levels
)
{
int
downResult
=
level
.
getDownLimit
().
compareTo
(
rpni
);
int
topResult
=
level
.
getTopLimit
().
compareTo
(
rpni
);
if
(
downResult
==
-
1
&&
topResult
!=
-
1
)
{
return
level
;
}
}
return
null
;
}
/**
* 获取风险变化类型
* @param rpn
* @param rpni
* @return
*/
public
static
int
getChangeType
(
BigDecimal
rpn
,
BigDecimal
rpni
)
{
if
(
rpn
.
subtract
(
rpni
).
doubleValue
()
>
0
){
return
RpnChangeLogTypeEum
.
upper
.
getCode
();
}
else
if
(
rpn
.
subtract
(
rpni
).
doubleValue
()
<
0
){
return
RpnChangeLogTypeEum
.
down
.
getCode
();
}
else
{
return
RpnChangeLogTypeEum
.
unChange
.
getCode
();
}
}
}
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/client/invoke/RsDataQueue.java
View file @
f6fa54f6
package
com
.
yeejoin
.
amos
.
fas
.
client
.
invoke
;
package
com
.
yeejoin
.
amos
.
fas
.
client
.
invoke
;
import
com.yeejoin.amos.fas.business.service.intfc.IRiskSourceService
;
import
com.yeejoin.amos.fas.business.service.intfc.IRiskSourceService
;
import
com.yeejoin.amos.fas.common.enums.TriggerRpnChangeTypeEum
;
import
com.yeejoin.amos.fas.context.IotContext
;
import
com.yeejoin.amos.fas.context.IotContext
;
import
org.apache.log4j.Logger
;
import
org.apache.log4j.Logger
;
import
java.util.concurrent.BlockingQueue
;
import
java.util.concurrent.BlockingQueue
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.LinkedBlockingQueue
;
import
java.util.concurrent.LinkedBlockingQueue
;
...
@@ -24,7 +24,10 @@ public class RsDataQueue {
...
@@ -24,7 +24,10 @@ public class RsDataQueue {
riskSourceService
=
(
IRiskSourceService
)
IotContext
.
getInstance
().
getBean
(
IRiskSourceService
.
class
);
riskSourceService
=
(
IRiskSourceService
)
IotContext
.
getInstance
().
getBean
(
IRiskSourceService
.
class
);
}
}
//获取RsDataQueue 的实例
/**
* 获取RsDataQueue 的实例
* @return 获RsDataQueue
*/
public
static
RsDataQueue
getInstance
()
{
public
static
RsDataQueue
getInstance
()
{
//先检查实例是否存在,如果不存在才进入下面的同步块
//先检查实例是否存在,如果不存在才进入下面的同步块
if
(
instance
==
null
)
{
if
(
instance
==
null
)
{
...
@@ -49,22 +52,27 @@ public class RsDataQueue {
...
@@ -49,22 +52,27 @@ public class RsDataQueue {
}
}
public
void
addUpdateMessage
(
Long
fmeaId
)
{
public
void
addUpdateMessage
(
Long
fmeaId
)
{
blockingQueue
.
add
(
new
FmeaMessage
(
fmeaId
,
"update"
));
blockingQueue
.
add
(
new
FmeaMessage
(
fmeaId
,
TriggerRpnChangeTypeEum
.
fmeaUpdate
.
getCode
()
));
}
}
public
void
addPatrolMessage
(
Long
fmeaId
)
{
public
void
addPatrolMessage
(
Long
fmeaId
)
{
blockingQueue
.
add
(
new
FmeaMessage
(
fmeaId
,
"patrol"
));
blockingQueue
.
add
(
new
FmeaMessage
(
fmeaId
,
TriggerRpnChangeTypeEum
.
patrol
.
getCode
()
));
}
}
public
void
addEquipmentMessage
(
Long
fmeaId
)
{
public
void
addEquipmentMessage
(
Long
fmeaId
)
{
blockingQueue
.
add
(
new
FmeaMessage
(
fmeaId
,
"equipment"
));
blockingQueue
.
add
(
new
FmeaMessage
(
fmeaId
,
TriggerRpnChangeTypeEum
.
equipment
.
getCode
()
));
}
}
public
void
addDeleteMessage
(
Long
riskSourceId
)
{
public
void
addDeleteMessage
(
Long
riskSourceId
)
{
blockingQueue
.
add
(
new
FmeaMessage
(
riskSourceId
,
"delete"
));
blockingQueue
.
add
(
new
FmeaMessage
(
riskSourceId
,
TriggerRpnChangeTypeEum
.
fmeaDelete
.
getCode
()));
}
public
void
addRiskSourcePointDeleteMessage
(
Long
parentId
){
blockingQueue
.
add
(
new
FmeaMessage
(
parentId
,
TriggerRpnChangeTypeEum
.
riskDelete
.
getCode
()));
}
}
Runnable
task_runnable
=
new
Runnable
()
{
private
Runnable
task_runnable
=
new
Runnable
()
{
@Override
public
void
run
()
{
public
void
run
()
{
while
(
true
)
{
while
(
true
)
{
try
{
try
{
...
@@ -72,23 +80,25 @@ public class RsDataQueue {
...
@@ -72,23 +80,25 @@ public class RsDataQueue {
if
(
riskSourceService
!=
null
)
{
if
(
riskSourceService
!=
null
)
{
String
from
=
fmeaMessage
.
getNorifyFrom
();
String
from
=
fmeaMessage
.
getNorifyFrom
();
Long
handId
=
fmeaMessage
.
getHandId
();
Long
handId
=
fmeaMessage
.
getHandId
();
if
(
from
.
equals
(
"patrol"
))
{
if
(
from
.
equals
(
TriggerRpnChangeTypeEum
.
patrol
.
getCode
()
))
{
//巡检不合格通知
//巡检不合格通知
riskSourceService
.
notifyFmeaFromAbnormal
(
handId
,
from
);
riskSourceService
.
notifyFmeaFromAbnormal
(
handId
,
from
);
}
else
if
(
from
.
equals
(
"equipment"
))
{
}
else
if
(
from
.
equals
(
TriggerRpnChangeTypeEum
.
equipment
.
getCode
()
))
{
//设备告警
//设备告警
riskSourceService
.
notifyFmeaFromAbnormal
(
handId
,
from
);
riskSourceService
.
notifyFmeaFromAbnormal
(
handId
,
from
);
}
else
if
(
from
.
equals
(
"update"
))
{
}
else
if
(
from
.
equals
(
TriggerRpnChangeTypeEum
.
fmeaUpdate
.
getCode
()
))
{
//修改通知
//
危险因素评价
修改通知
riskSourceService
.
notifyFmeaFromUpdate
(
handId
,
from
);
riskSourceService
.
notifyFmeaFromUpdate
(
handId
,
from
);
}
else
if
(
from
.
equals
(
"delete"
))
{
}
else
if
(
from
.
equals
(
TriggerRpnChangeTypeEum
.
fmeaDelete
.
getCode
()))
{
//删除通知
//危险因素删除通知
riskSourceService
.
notifyRiskSource
(
handId
,
from
,
null
);
riskSourceService
.
notifyFmeaFromDelete
(
handId
,
from
);
}
else
if
(
from
.
equals
(
TriggerRpnChangeTypeEum
.
riskDelete
.
getCode
())){
//风险点删除通知
riskSourceService
.
notifyRiskSourceDelete
(
handId
);
}
}
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
Logger
.
getLogger
(
this
.
getClass
()).
error
(
e
.
getMessage
());
Logger
.
getLogger
(
this
.
getClass
()).
error
(
e
.
getMessage
());
e
.
printStackTrace
();
}
}
}
}
}
}
...
...
YeeAmosFireAutoSysStart/src/main/resources/db/changelog/fas-1.0.2.xml
View file @
f6fa54f6
...
@@ -368,5 +368,15 @@
...
@@ -368,5 +368,15 @@
MODIFY COLUMN `nodeid` varchar(36) DEFAULT NULL;
MODIFY COLUMN `nodeid` varchar(36) DEFAULT NULL;
</sql>
</sql>
</changeSet>
</changeSet>
<changeSet
author=
"suhuiguang"
id=
"1588990926789-1"
>
<preConditions
onFail=
"MARK_RAN"
>
<columnExists
tableName=
"f_risk_level "
columnName=
"manage_level"
/>
</preConditions>
<comment>
f_risk_level add column manage_level 管控级别
</comment>
<sql>
ALTER TABLE `f_risk_level`
add COLUMN `manage_level` tinyint(4) DEFAULT NULL COMMENT '管控级别';
</sql>
</changeSet>
</databaseChangeLog>
</databaseChangeLog>
\ No newline at end of file
YeeAmosFireAutoSysStart/src/main/resources/db/mapper/dbTemplate_fmea.xml
View file @
f6fa54f6
...
@@ -154,4 +154,27 @@
...
@@ -154,4 +154,27 @@
</set>
</set>
where id = #{id}
where id = #{id}
</update>
</update>
<select
id=
"listByRiskSourceIds"
resultType=
"com.yeejoin.amos.fas.dao.entity.Fmea"
>
select
a.id,
a.risk_source_id as riskSourceId,
a.risk_factors_id as riskFactorsId,
a.evaluation_sid as evaluationSid,
a.evaluation_oid as evaluationOid,
a.evaluation_did as evaluationDid,
a.new_evaluation_oid as newEvaluationOid,
a.rpni,
a.rpn,
(select coefficient from f_evaluation_model where id = a.evaluation_sid) as sidValue,
(select coefficient from f_evaluation_model where id = a.evaluation_oid) as oidValue,
(select coefficient from f_evaluation_model where id = a.evaluation_did) as didValue,
(select coefficient from f_evaluation_model where id = a.new_evaluation_oid) as newOidValue
from
f_fmea as a
where
a.risk_source_id in
<foreach
collection=
"ids"
item=
"item"
index=
"index"
open=
"("
separator=
","
close=
")"
>
#{item}
</foreach>
</select>
</mapper>
</mapper>
\ No newline at end of file
pom.xml
View file @
f6fa54f6
...
@@ -251,7 +251,16 @@
...
@@ -251,7 +251,16 @@
<name>
maven-public
</name>
<name>
maven-public
</name>
<url>
http://172.16.1.6:8081/nexus/content/repositories/maven-public/
</url>
<url>
http://172.16.1.6:8081/nexus/content/repositories/maven-public/
</url>
</repository>
</repository>
<repository>
<id>
maven-public
</id>
<name>
maven-public
</name>
<url>
http://repo.typroject.org:8081/repository/maven-public/
</url>
</repository>
<repository>
<id>
maven-snapshot
</id>
<name>
maven-snapshot
</name>
<url>
http://repo.typroject.org:8081/repository/maven-snapshots/
</url>
</repository>
</repositories>
</repositories>
<pluginRepositories>
<pluginRepositories>
...
...
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