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
4a95ea97
Commit
4a95ea97
authored
Jan 21, 2021
by
田涛
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
代码合并
parent
3286e4a3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
107 additions
and
108 deletions
+107
-108
ContingencyPlanServiceImpl.java
...fas/business/service/impl/ContingencyPlanServiceImpl.java
+107
-108
No files found.
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/service/impl/ContingencyPlanServiceImpl.java
View file @
4a95ea97
...
@@ -101,131 +101,129 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
...
@@ -101,131 +101,129 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
ContingencyPlanResponseVo
result
=
new
ContingencyPlanResponseVo
();
ContingencyPlanResponseVo
result
=
new
ContingencyPlanResponseVo
();
//状态校验
//状态校验
ReserveEnum
reserveEnum
=
this
.
runCheck
(
vo
);
ReserveEnum
reserveEnum
=
this
.
runCheck
(
vo
);
if
(
ReserveEnum
.
THISRUNNING
.
getStatus
()
==
reserveEnum
.
getStatus
())
{
if
(
ReserveEnum
.
THISRUNNING
.
getStatus
()
==
reserveEnum
.
getStatus
())
{
List
<
PlanOperationRecord
>
recordList
=
planOperationRecordDao
.
findByPlanId1
(
Long
.
valueOf
(
vo
.
getPlanId
()));
List
<
PlanOperationRecord
>
recordList
=
planOperationRecordDao
.
findByPlanId1
(
Long
.
valueOf
(
vo
.
getPlanId
()));
result
.
setMessage
(
ReserveEnum
.
THISRUNNING
.
getText
());
result
.
setMessage
(
ReserveEnum
.
THISRUNNING
.
getText
());
result
.
setBatchNo
(
recordList
.
get
(
0
).
getBatchNo
());
result
.
setBatchNo
(
recordList
.
get
(
0
).
getBatchNo
());
return
result
;
return
result
;
}
else
if
(
ReserveEnum
.
RUN
.
getStatus
()
==
reserveEnum
.
getStatus
())
{
}
else
if
(
ReserveEnum
.
RUN
.
getStatus
()
==
reserveEnum
.
getStatus
())
{
Optional
<
PlanDetail
>
PlanDetailOp
=
planDetailDao
.
findById
(
Long
.
valueOf
(
vo
.
getPlanId
()));
Optional
<
PlanDetail
>
PlanDetailOp
=
planDetailDao
.
findById
(
Long
.
valueOf
(
vo
.
getPlanId
()));
List
<
PlanEquipment
>
equipmentList
=
planEquipmentDao
.
findByPlanId
(
PlanDetailOp
.
get
().
getId
());
List
<
PlanEquipment
>
equipmentList
=
planEquipmentDao
.
findByPlanId
(
PlanDetailOp
.
get
().
getId
());
//预案启动
//预案启动
if
(
PlanDetailOp
.
get
()
!=
null
)
{
if
(
PlanDetailOp
.
get
()
!=
null
)
{
//电力设备
//电力设备
Equipment
equipment
=
equipmentService
.
queryOne
(
equipmentList
.
get
(
0
).
getFireEquipmentId
());
Equipment
equipment
=
equipmentService
.
queryOne
(
equipmentList
.
get
(
0
).
getFireEquipmentId
());
//获取规则名称
//获取规则名称
List
<
PlanRule
>
planRuleList
=
planRuleDao
.
getPlanDocsByPlanId
(
Long
.
valueOf
(
vo
.
getPlanId
()));
List
<
PlanRule
>
planRuleList
=
planRuleDao
.
getPlanDocsByPlanId
(
Long
.
valueOf
(
vo
.
getPlanId
()));
if
(
planRuleList
.
size
()==
0
)
{
if
(
planRuleList
.
size
()
==
0
)
{
result
.
setMessage
(
ReserveEnum
.
NOPLAN
.
getText
());
result
.
setMessage
(
ReserveEnum
.
NOPLAN
.
getText
());
}
}
equipment
.
setReservePlan
(
"换流站消防专项预案"
+
"/"
+
planRuleList
.
get
(
0
).
getRuleId
());
equipment
.
setReservePlan
(
"换流站消防专项预案"
+
"/"
+
planRuleList
.
get
(
0
).
getRuleId
());
if
(
equipment
==
null
)
{
if
(
equipment
==
null
)
{
result
.
setMessage
(
ReserveEnum
.
NOEQUIP
.
getText
());
result
.
setMessage
(
ReserveEnum
.
NOEQUIP
.
getText
());
}
}
//电力设备绑定装备
//电力设备绑定装备
List
<
EquipmentFireEquipment
>
equipmentFireEquipmentList
=
equipmentFireEquipmentDao
.
findAllByEquipmentId
(
equipmentList
.
get
(
0
).
getFireEquipmentId
());
List
<
EquipmentFireEquipment
>
equipmentFireEquipmentList
=
equipmentFireEquipmentDao
.
findAllByEquipmentId
(
equipmentList
.
get
(
0
).
getFireEquipmentId
());
if
(
equipmentFireEquipmentList
.
size
()==
0
)
{
if
(
equipmentFireEquipmentList
.
size
()
==
0
)
{
result
.
setMessage
(
ReserveEnum
.
NOFIRE
.
getText
());
result
.
setMessage
(
ReserveEnum
.
NOFIRE
.
getText
());
}
}
//查询设备
//查询设备
EquipmentSpecificForRiskVo
equipmentSpecific
=
equipmentSpecificMapper
.
getOneById
(
equipmentFireEquipmentList
.
get
(
0
).
getFireEquipmentId
());
EquipmentSpecificForRiskVo
equipmentSpecific
=
equipmentSpecificMapper
.
getOneById
(
equipmentFireEquipmentList
.
get
(
0
).
getFireEquipmentId
());
if
(
equipmentSpecific
==
null
)
{
if
(
equipmentSpecific
==
null
)
{
result
.
setMessage
(
ReserveEnum
.
NOFIRE
.
getText
());
result
.
setMessage
(
ReserveEnum
.
NOFIRE
.
getText
());
}
}
//插入运行记录表
//插入运行记录表
PlanOperationRecord
planOperationRecord
=
new
PlanOperationRecord
();
PlanOperationRecord
planOperationRecord
=
new
PlanOperationRecord
();
planOperationRecord
.
setStatus
(
PlanRecordStatusEnum
.
OPERATION
.
getCode
());
planOperationRecord
.
setStatus
(
PlanRecordStatusEnum
.
OPERATION
.
getCode
());
planOperationRecord
.
setPlanId
(
PlanDetailOp
.
get
().
getId
());
planOperationRecord
.
setPlanId
(
PlanDetailOp
.
get
().
getId
());
planOperationRecord
.
setIsDelete
(
false
);
planOperationRecord
.
setIsDelete
(
false
);
planOperationRecord
.
setStartTime
(
new
Date
());
planOperationRecord
.
setStartTime
(
new
Date
());
planOperationRecord
.
setPlanPattern
(
vo
.
getStatus
());
planOperationRecord
.
setPlanPattern
(
vo
.
getStatus
());
planOperationRecord
.
setStartUserId
(
vo
.
getUserId
());
planOperationRecord
.
setStartUserId
(
vo
.
getUserId
());
planOperationRecord
.
setStartUserName
(
vo
.
getUserName
());
planOperationRecord
.
setStartUserName
(
vo
.
getUserName
());
planOperationRecord
.
setEquipmentCode
(
equipmentSpecific
.
getCode
());
planOperationRecord
.
setEquipmentCode
(
equipmentSpecific
.
getCode
());
planOperationRecord
.
setEquipmentName
(
equipmentSpecific
.
getName
());
planOperationRecord
.
setEquipmentName
(
equipmentSpecific
.
getName
());
if
(
ContingencyPlanStatusEnum
.
SIMULATION_START
.
getCode
()==
vo
.
getStatus
())
{
if
(
ContingencyPlanStatusEnum
.
SIMULATION_START
.
getCode
()
==
vo
.
getStatus
())
{
planOperationRecord
.
setExecutionType
(
ExecutionTypeEnum
.
PLANCHECK
.
getCode
());
planOperationRecord
.
setExecutionType
(
ExecutionTypeEnum
.
PLANCHECK
.
getCode
());
}
else
{
}
else
{
planOperationRecord
.
setExecutionType
(
ExecutionTypeEnum
.
FIREMANAGEMENT
.
getCode
());
planOperationRecord
.
setExecutionType
(
ExecutionTypeEnum
.
FIREMANAGEMENT
.
getCode
());
}
}
PlanOperationRecord
operationRecord
=
planOperationRecordDao
.
save
(
planOperationRecord
);
PlanOperationRecord
operationRecord
=
planOperationRecordDao
.
save
(
planOperationRecord
);
//预案启动
//预案启动
AlarmParam
deviceData
=
new
AlarmParam
();
AlarmParam
deviceData
=
new
AlarmParam
();
deviceData
.
setMonitor
(
equipment
!=
null
?
equipment
.
getName
()
:
""
);
deviceData
.
setMonitor
(
equipment
!=
null
?
equipment
.
getName
()
:
""
);
deviceData
.
setId
(
String
.
valueOf
(
equipmentSpecific
.
getId
()));
deviceData
.
setId
(
String
.
valueOf
(
equipmentSpecific
.
getId
()));
deviceData
.
setCode
(
equipmentSpecific
.
getCode
());
deviceData
.
setCode
(
equipmentSpecific
.
getCode
());
String
batchNo
=
equipmentHandlerService
.
executeDynamicPlan
(
deviceData
,
equipment
,
equipmentSpecific
,
toke
,
operationRecord
.
getId
());
String
batchNo
=
equipmentHandlerService
.
executeDynamicPlan
(
deviceData
,
equipment
,
equipmentSpecific
,
toke
,
operationRecord
.
getId
());
//更新模型状态
//更新模型状态
PlanDetail
planDetail
=
PlanDetailOp
.
get
();
PlanDetail
planDetail
=
PlanDetailOp
.
get
();
planDetail
.
setStatus
(
ContingencyPlanStatusEnum
.
SIMULATION_START
.
getCode
());
planDetail
.
setStatus
(
ContingencyPlanStatusEnum
.
SIMULATION_START
.
getCode
());
planDetailDao
.
save
(
planDetail
);
planDetailDao
.
save
(
planDetail
);
//更新预案执行记录表的批次号
//更新预案执行记录表的批次号
operationRecord
.
setBatchNo
(
batchNo
);
operationRecord
.
setBatchNo
(
batchNo
);
planOperationRecordDao
.
save
(
operationRecord
);
planOperationRecordDao
.
save
(
operationRecord
);
result
.
setMessage
(
ReserveEnum
.
RUN
.
getText
());
result
.
setMessage
(
ReserveEnum
.
RUN
.
getText
());
result
.
setBatchNo
(
batchNo
);
result
.
setBatchNo
(
batchNo
);
}
}
}
}
return
result
;
return
result
;
}
}
@Override
@Override
public
Map
<
String
,
Object
>
firstGetRecord
(
String
batchNo
)
{
public
Map
<
String
,
Object
>
firstGetRecord
(
String
batchNo
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
PlanOperationRecord
planOperationRecord
=
planOperationRecordDao
.
findByBatchNo
(
batchNo
);
PlanOperationRecord
planOperationRecord
=
planOperationRecordDao
.
findByBatchNo
(
batchNo
);
if
(
planOperationRecord
==
null
)
{
if
(
planOperationRecord
==
null
)
{
throw
new
YeeException
(
"执行记录不存在"
);
throw
new
YeeException
(
"执行记录不存在"
);
}
else
{
}
else
{
PlanDetail
planDetail
=
planDetailDao
.
getOne
(
planOperationRecord
.
getPlanId
());
PlanDetail
planDetail
=
planDetailDao
.
getOne
(
planOperationRecord
.
getPlanId
());
if
(
planDetail
==
null
){
if
(
planDetail
==
null
)
{
throw
new
YeeException
(
"数字预案模型被删除"
);
throw
new
YeeException
(
"数字预案模型被删除"
);
}
List
<
PlanEquipment
>
equipmentList
=
planEquipmentDao
.
findByPlanId
(
planDetail
.
getId
());
Equipment
equipment
=
equipmentService
.
queryOne
(
equipmentList
.
get
(
0
).
getFireEquipmentId
());
map
.
put
(
"status"
,
planOperationRecord
.
getStatus
());
if
(
PlanRecordStatusEnum
.
OPERATION
.
getCode
()==
planOperationRecord
.
getStatus
()){
map
.
put
(
"executionTime"
,(
new
Date
().
getTime
()-
planOperationRecord
.
getStartTime
().
getTime
())/
1000
);
}
else
{
map
.
put
(
"executionTime"
,(
planOperationRecord
.
getEndTime
().
getTime
()-
planOperationRecord
.
getStartTime
().
getTime
())/
1000
);
}
}
map
.
put
(
"crateDate"
,
planOperationRecord
.
getStartTime
());
map
.
put
(
"status"
,
planOperationRecord
.
getStatus
());
if
(
planOperationRecord
.
getPlanPattern
()==
ContingencyPlanStatusEnum
.
SIMULATION_START
.
getCode
()){
if
(
PlanRecordStatusEnum
.
OPERATION
==
PlanRecordStatusEnum
.
getEnum
(
planOperationRecord
.
getStatus
()))
{
map
.
put
(
"userName"
,
planOperationRecord
.
getStartUserName
());
map
.
put
(
"executionTime"
,
(
System
.
currentTimeMillis
()
-
planOperationRecord
.
getStartTime
().
getTime
())
/
1000
);
map
.
put
(
"startType"
,
"手动"
);
}
else
{
}
else
{
map
.
put
(
"executionTime"
,
(
planOperationRecord
.
getEndTime
().
getTime
()
-
planOperationRecord
.
getStartTime
().
getTime
())
/
1000
);
map
.
put
(
"userName"
,
"系统"
);
}
map
.
put
(
"startType"
,
"自动"
);
map
.
put
(
"crateDate"
,
planOperationRecord
.
getStartTime
());
if
(
ContingencyPlanStatusEnum
.
getEnum
(
planOperationRecord
.
getPlanPattern
())
==
ContingencyPlanStatusEnum
.
SIMULATION_START
)
{
map
.
put
(
"userName"
,
planOperationRecord
.
getStartUserName
());
map
.
put
(
"startType"
,
"手动"
);
}
else
{
map
.
put
(
"userName"
,
"系统"
);
map
.
put
(
"startType"
,
"自动"
);
}
}
map
.
put
(
"executionType"
,
planOperationRecord
.
getExecutionType
());
map
.
put
(
"executionType"
,
planOperationRecord
.
getExecutionType
());
map
.
put
(
"equipmentName"
,
planOperationRecord
.
getEquipmentName
());
map
.
put
(
"equipmentName"
,
planOperationRecord
.
getEquipmentName
());
map
.
put
(
"PlanName"
,
planDetail
.
getPlanName
());
map
.
put
(
"PlanName"
,
planDetail
.
getPlanName
());
}
}
return
map
;
return
map
;
}
}
@Override
@Override
public
List
<
HashMap
<
String
,
Object
>>
getRecordList
(
String
batchNo
)
{
public
List
<
HashMap
<
String
,
Object
>>
getRecordList
(
String
batchNo
)
{
List
<
HashMap
<
String
,
Object
>>
list
=
new
ArrayList
<>();
List
<
HashMap
<
String
,
Object
>>
list
=
new
ArrayList
<>();
List
<
ContingencyPlanInstance
>
instancesList
=
repository
.
queryForCategory
(
batchNo
,
"MESSAGE"
);
List
<
ContingencyPlanInstance
>
instancesList
=
repository
.
queryForCategory
(
batchNo
,
"MESSAGE"
);
instancesList
.
forEach
(
contingencyPlanInstance
->
{
instancesList
.
forEach
(
contingencyPlanInstance
->
{
HashMap
<
String
,
Object
>
map
=
new
HashMap
<>();
HashMap
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"crateDate"
,
contingencyPlanInstance
.
getCreateDate
());
map
.
put
(
"crateDate"
,
contingencyPlanInstance
.
getCreateDate
());
map
.
put
(
"content"
,
contingencyPlanInstance
.
getContent
());
map
.
put
(
"content"
,
contingencyPlanInstance
.
getContent
());
list
.
add
(
map
);
list
.
add
(
map
);
});
});
return
list
;
return
list
;
}
}
//启动状态校验
//启动状态校验
public
ReserveEnum
runCheck
(
ContingencyPlanParamVo
vo
){
public
ReserveEnum
runCheck
(
ContingencyPlanParamVo
vo
)
{
if
(
EquipmentRiskTypeEnum
.
HZGJ
.
getCode
().
equals
(
vo
.
getRiskType
())
||
StringUtils
.
isBlank
(
vo
.
getRiskType
()))
{
if
(
EquipmentRiskTypeEnum
.
HZGJ
.
getCode
().
equals
(
vo
.
getRiskType
())
||
StringUtils
.
isBlank
(
vo
.
getRiskType
()))
{
List
<
PlanOperationRecord
>
recordList
=
planOperationRecordDao
.
findByPlanId1
(
Long
.
valueOf
(
vo
.
getPlanId
()));
List
<
PlanOperationRecord
>
recordList
=
planOperationRecordDao
.
findByPlanId1
(
Long
.
valueOf
(
vo
.
getPlanId
()));
if
(
recordList
.
size
()>
0
)
{
if
(
recordList
.
size
()
>
0
)
{
return
ReserveEnum
.
THISRUNNING
;
return
ReserveEnum
.
THISRUNNING
;
}
}
if
(
ContingencyPlanStatusEnum
.
SIMULATION_START
.
getCode
().
equals
(
vo
.
getStatus
()))
{
if
(
ContingencyPlanStatusEnum
.
SIMULATION_START
.
getCode
().
equals
(
vo
.
getStatus
()))
{
Integer
[]
statusArray
=
(
Integer
[])
Arrays
.
asList
(
ContingencyPlanStatusEnum
.
SIMULATION_START
.
getCode
(),
ContingencyPlanStatusEnum
.
ONGOING
.
getCode
()).
toArray
();
Integer
[]
statusArray
=
(
Integer
[])
Arrays
.
asList
(
ContingencyPlanStatusEnum
.
SIMULATION_START
.
getCode
(),
ContingencyPlanStatusEnum
.
ONGOING
.
getCode
()).
toArray
();
int
count
=
planDetailDao
.
findByStatus
(
statusArray
);
int
count
=
planDetailDao
.
findByStatus
(
statusArray
);
...
@@ -243,15 +241,16 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
...
@@ -243,15 +241,16 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
}
else
{
}
else
{
return
ReserveEnum
.
PLANSTATUSERROR
;
return
ReserveEnum
.
PLANSTATUSERROR
;
}
}
}
else
{
}
else
{
}
}
return
ReserveEnum
.
RUN
;
return
ReserveEnum
.
RUN
;
}
}
@Override
@Override
public
ContingencyPlanParamVo
equipmentScene
(
Long
equipmentId
,
String
riskType
)
{
public
ContingencyPlanParamVo
equipmentScene
(
Long
equipmentId
,
String
riskType
)
{
ContingencyPlanParamVo
vo
=
null
;
ContingencyPlanParamVo
vo
=
null
;
if
(
EquipmentRiskTypeEnum
.
HZGJ
.
getCode
().
equals
(
riskType
))
{
if
(
EquipmentRiskTypeEnum
.
HZGJ
.
getCode
().
equals
(
riskType
))
{
List
<
EquipmentFireEquipment
>
equipmentFireEquipmentList
=
equipmentFireEquipmentDao
.
findAllByFireEquipmentId
(
equipmentId
);
List
<
EquipmentFireEquipment
>
equipmentFireEquipmentList
=
equipmentFireEquipmentDao
.
findAllByFireEquipmentId
(
equipmentId
);
if
(
equipmentFireEquipmentList
.
size
()
>
0
)
{
if
(
equipmentFireEquipmentList
.
size
()
>
0
)
{
Equipment
equipment
=
equipmentDao
.
findById
(
equipmentFireEquipmentList
.
get
(
0
).
getEquipmentId
()).
orElse
(
null
);
Equipment
equipment
=
equipmentDao
.
findById
(
equipmentFireEquipmentList
.
get
(
0
).
getEquipmentId
()).
orElse
(
null
);
...
...
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