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
c0ed1a43
Commit
c0ed1a43
authored
Dec 02, 2022
by
高建强
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
item:应急处置同步调整提交
parent
02fe2ef2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
65 additions
and
101 deletions
+65
-101
ContingencyAction.java
...m/yeejoin/amos/fas/business/action/ContingencyAction.java
+0
-11
ContingencyInstanceImpl.java
...os/fas/business/service/impl/ContingencyInstanceImpl.java
+59
-89
ContingencyPlanServiceImpl.java
...fas/business/service/impl/ContingencyPlanServiceImpl.java
+1
-1
PlanRuleServiceImpl.java
...n/amos/fas/business/service/impl/PlanRuleServiceImpl.java
+5
-0
No files found.
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/action/ContingencyAction.java
View file @
c0ed1a43
...
...
@@ -466,19 +466,8 @@ public class ContingencyAction implements CustomerAction {
tempmap1
.
put
(
"button"
,
buttonJson
);
tempmap1
.
put
(
"caseId"
,
contingencyPlanId
);
result
.
add
(
tempmap1
);
this
.
sendcmd
(
"optionarea"
,
paramObj
,
result
);
ContingencyPlanInstance
instance
=
contingencyInstance
.
getMessageById
(
contingencyPlanId
);
if
(
instance
!=
null
)
{
String
roleCode
=
contingencyInstance
.
getPlanStepRoleCodeByButtonCode
(
buttonCode
);
if
(
StringUtils
.
isNotBlank
(
roleCode
))
{
instance
.
setRoleCode
(
roleCode
);
}
else
{
instance
.
setRoleCode
(
defaultRoleCode
);
}
contingencyPlanInstanceMapper
.
updateMessageById
(
instance
);
}
try
{
System
.
out
.
println
(
"======optionarea 加入队列参数信息======action====="
);
...
...
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/service/impl/ContingencyInstanceImpl.java
View file @
c0ed1a43
package
com
.
yeejoin
.
amos
.
fas
.
business
.
service
.
impl
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.yeejoin.amos.component.feign.model.FeignClientResult
;
import
com.yeejoin.amos.component.rule.RuleTrigger
;
...
...
@@ -18,6 +17,7 @@ import com.yeejoin.amos.fas.business.service.intfc.*;
import
com.yeejoin.amos.fas.business.service.model.Operate
;
import
com.yeejoin.amos.fas.business.service.model.OperateGroup
;
import
com.yeejoin.amos.fas.business.util.DateUtils
;
import
com.yeejoin.amos.fas.business.vo.ButtonJsonVO
;
import
com.yeejoin.amos.fas.business.vo.PlanStepJsonVO
;
import
com.yeejoin.amos.fas.business.vo.Toke
;
import
com.yeejoin.amos.fas.common.enums.PlanReplyMessageEnum
;
...
...
@@ -42,8 +42,6 @@ import org.springframework.data.redis.core.RedisTemplate;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.support.TransactionSynchronization
;
import
org.springframework.transaction.support.TransactionSynchronizationManager
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.ObjectUtils
;
import
org.typroject.tyboot.core.foundation.context.RequestContext
;
...
...
@@ -148,6 +146,7 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
* @param recordType 信息分类
* @param icon 信息显示图标
*/
@Transactional
public
ContingencyPlanInstance
createInstanceRecord
(
String
instanceNo
,
String
category
,
String
subCategory
,
String
content
,
String
recordType
,
String
icon
)
{
ContingencyPlanInstance
planInstance
=
new
ContingencyPlanInstance
();
if
(
"MESSAGE"
.
equalsIgnoreCase
(
recordType
))
{
...
...
@@ -244,12 +243,12 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
BeanUtils
.
copyProperties
(
contingencyOriginalData
,
contingencyRo
);
contingencyRo
.
setStep
(
stepCode
);
contingencyRo
.
setStepState
(
stepMap
.
get
(
stepKey
));
// Object isMock = redisTemplate.opsForValue().get("isMock"
);
//
if (isMock != null) {
// contingencyRo.setIsMock("1".equals(isMock.toString()
));
//
} else {
//
contingencyRo.setIsMock(false);
//
}
String
isMock
=
redisTemplate
.
boundValueOps
(
"isMock"
).
get
(
0
,
-
1
);
if
(
isMock
!=
null
)
{
contingencyRo
.
setIsMock
(
"true"
.
equals
(
isMock
));
}
else
{
contingencyRo
.
setIsMock
(
false
);
}
log
.
info
(
"stepstate:"
+
contingencyRo
.
getStepState
());
log
.
info
(
"stepCode:"
+
stepCode
);
equipment
=
impAndFireEquipMapper
.
queryImpEqumtByFireEquipmt
(
Long
.
parseLong
(
contingencyRo
.
getFireEquipmentId
()));
...
...
@@ -284,9 +283,6 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
ruleTrigger
.
publish
(
contingencyRo
,
"换流站消防专项预案/"
+
plan
.
get
(
0
),
ArrayUtils
.
toArray
(
equipment
.
getName
()));
publisherPlanLog
(
stepCode
,
buttonCode
,
batchNo
);
// 更新预案执行Json串
// planVisual3dService.updatePlanStep(batchNo, stepCode, contingencyPlanId, buttonCode);
}
}
else
{
throw
new
Exception
(
"数据异常,请联系管理员."
);
...
...
@@ -331,12 +327,7 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
@Transactional
public
void
setButtonExecuted
(
String
batchNo
,
String
contingencyPlanId
,
String
code
,
String
buttonState
)
throws
Exception
{
ObjectMapper
objectMapper
=
new
ObjectMapper
();
// Optional<ContingencyPlanInstance> contingencyPlanInstance1 = repository.findById(contingencyPlanId);
System
.
out
.
println
(
"=========================setButtonExecuted======================"
);
ContingencyPlanInstance
contingencyPlanInstance
=
contingencyInstance
.
getMessageById
(
contingencyPlanId
);
// ContingencyPlanInstance contingencyPlanInstance = contingencyPlanInstance1.get();
System
.
out
.
println
(
JSON
.
toJSON
(
contingencyPlanInstance
));
if
(
contingencyPlanInstance
!=
null
)
{
if
(
"OPERATE"
.
equals
(
contingencyPlanInstance
.
getRecordType
()))
{
String
operateJson
=
contingencyPlanInstance
.
getContent
();
...
...
@@ -345,7 +336,6 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
List
<
Operate
>
operates
=
operateGroup
.
getOperate
();
if
(!
CollectionUtils
.
isEmpty
(
operates
))
{
for
(
Operate
operate
:
operates
)
{
// if (code.equals(operate.getCode()) && ("executed".equals(operate.getState()) || "disable".equals(operate.getState()))) {
if
(
code
.
equals
(
operate
.
getCode
())
&&
(
"executed"
.
equals
(
operate
.
getState
())))
{
if
(
"FIRE_CANCEL"
.
equals
(
code
)
||
"END_EMERGENCY"
.
equals
(
code
))
{
...
...
@@ -389,17 +379,6 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
String
topic
=
String
.
format
(
"/%s/%s/%s"
,
serviceName
,
stationName
,
"plan"
);
webMqttComponent
.
publish
(
topic
,
"{\"msgType\":\"operateConfirmMessage\"}"
);
}
// if (buttonState.equals("CONFIRM")) {
// // TODO 数字化换流站组态屏数据推送,需要在事务提交之后,否侧事务隔离查询不出数据
// TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
// @Override
// public void afterCommit() {
// // 事物提交后业务逻辑
// String topic = String.format("/%s/%s/%s", serviceName, stationName, "plan");
// webMqttComponent.publish(topic, "{\"msgType\":\"operateConfirmMessage\"}");
// }
// });
// }
// 异步数据同步之消息发送
contingencyPlanInstanceDataSync
(
instance
);
}
...
...
@@ -490,50 +469,57 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
@Override
public
ContingencyPlanInstance
updateExtendColumn
(
ContingencyPlanInstance
contingencyPlanInstance
)
{
String
appKey
=
redisTemplate
.
opsForValue
().
get
(
"action:appKey"
).
toString
();
String
product
=
redisTemplate
.
opsForValue
().
get
(
"action:product"
).
toString
();
String
token
=
redisTemplate
.
opsForValue
().
get
(
"action:token"
).
toString
();
if
(
StringUtils
.
isBlank
(
appKey
)
||
StringUtils
.
isBlank
(
product
)
||
StringUtils
.
isBlank
(
token
))
{
Toke
toke
=
remoteSecurityService
.
getServerToken
();
RequestContext
.
setToken
(
toke
.
getToke
());
RequestContext
.
setProduct
(
toke
.
getProduct
());
RequestContext
.
setAppKey
(
toke
.
getAppKey
());
String
recordType
=
contingencyPlanInstance
.
getRecordType
();
if
(
"OPERATE"
.
equals
(
recordType
))
{
ButtonJsonVO
buttonJsonVO
=
JSONObject
.
parseObject
(
contingencyPlanInstance
.
getContent
(),
ButtonJsonVO
.
class
);
Map
<
String
,
Object
>
map
=
buttonJsonVO
.
getOperate
().
get
(
buttonJsonVO
.
getOperate
().
size
()
-
1
);
contingencyPlanInstance
.
setRoleCode
(
getPlanStepRoleCodeByButtonCode
(
map
.
get
(
"code"
).
toString
()));
}
else
{
RequestContext
.
setAppKey
(
appKey
);
RequestContext
.
setProduct
(
product
);
RequestContext
.
setToken
(
token
);
}
String
appKey
=
redisTemplate
.
opsForValue
().
get
(
"action:appKey"
).
toString
();
String
product
=
redisTemplate
.
opsForValue
().
get
(
"action:product"
).
toString
();
String
token
=
redisTemplate
.
opsForValue
().
get
(
"action:token"
).
toString
();
if
(
StringUtils
.
isBlank
(
appKey
)
||
StringUtils
.
isBlank
(
product
)
||
StringUtils
.
isBlank
(
token
))
{
Toke
toke
=
remoteSecurityService
.
getServerToken
();
RequestContext
.
setToken
(
toke
.
getToke
());
RequestContext
.
setProduct
(
toke
.
getProduct
());
RequestContext
.
setAppKey
(
toke
.
getAppKey
());
}
else
{
RequestContext
.
setAppKey
(
appKey
);
RequestContext
.
setProduct
(
product
);
RequestContext
.
setToken
(
token
);
}
FeignClientResult
<
AgencyUserModel
>
feignClientResult
=
Privilege
.
agencyUserClient
.
getme
();
AgencyUserModel
user
=
(
AgencyUserModel
)
feignClientResult
.
getResult
();
FeignClientResult
<
AgencyUserModel
>
feignClientResult
=
Privilege
.
agencyUserClient
.
getme
();
AgencyUserModel
user
=
(
AgencyUserModel
)
feignClientResult
.
getResult
();
List
<
PlanStepJsonVO
>
result
=
getPlanStepJsonVOS
();
List
<
String
>
roleCode
=
result
.
stream
().
map
(
PlanStepJsonVO:
:
getRoleCode
).
distinct
().
collect
(
Collectors
.
toList
());
List
<
PlanStepJsonVO
>
result
=
getPlanStepJsonVOS
();
List
<
String
>
roleCode
=
result
.
stream
().
map
(
PlanStepJsonVO:
:
getRoleCode
).
distinct
().
collect
(
Collectors
.
toList
());
List
<
RoleModel
>
roleModelList
=
new
ArrayList
<>();
for
(
Long
key
:
user
.
getOrgRoles
().
keySet
())
{
roleModelList
.
addAll
(
user
.
getOrgRoles
().
get
(
key
));
}
List
<
String
>
roleCodeList
=
new
ArrayList
<>();
List
<
String
>
roleNameList
=
new
ArrayList
<>();
List
<
String
>
realRoleCode
=
roleModelList
.
stream
().
map
(
RoleModel:
:
getRoleName
).
distinct
().
collect
(
Collectors
.
toList
());
realRoleCode
.
forEach
(
item
->
{
if
(
roleCode
.
contains
(
item
))
{
roleCodeList
.
add
(
item
);
}
});
roleModelList
.
forEach
(
item
->
{
if
(!
roleNameList
.
contains
(
item
.
getRoleDesc
())
&&
roleCode
.
contains
(
item
.
getRoleName
()))
{
roleNameList
.
add
(
item
.
getRoleDesc
());
List
<
RoleModel
>
roleModelList
=
new
ArrayList
<>();
for
(
Long
key
:
user
.
getOrgRoles
().
keySet
())
{
roleModelList
.
addAll
(
user
.
getOrgRoles
().
get
(
key
));
}
});
contingencyPlanInstance
.
setRoleCode
(
String
.
join
(
"-"
,
roleCodeList
));
contingencyPlanInstance
.
setRoleName
(
String
.
join
(
"-"
,
roleNameList
));
contingencyPlanInstance
.
setStartUserId
(
user
.
getUserId
());
contingencyPlanInstance
.
setStartUserName
(
user
.
getRealName
());
Map
<
String
,
String
>
userInfo
=
contingencyPlanInstanceMapper
.
getUserByUserId
(
user
.
getUserId
());
contingencyPlanInstance
.
setPersonImg
(
ObjectUtils
.
isEmpty
(
userInfo
)
?
personImg
:
userInfo
.
getOrDefault
(
"personImg"
,
personImg
));
List
<
String
>
roleCodeList
=
new
ArrayList
<>();
List
<
String
>
roleNameList
=
new
ArrayList
<>();
List
<
String
>
realRoleCode
=
roleModelList
.
stream
().
map
(
RoleModel:
:
getRoleName
).
distinct
().
collect
(
Collectors
.
toList
());
realRoleCode
.
forEach
(
item
->
{
if
(
roleCode
.
contains
(
item
))
{
roleCodeList
.
add
(
item
);
}
});
roleModelList
.
forEach
(
item
->
{
if
(!
roleNameList
.
contains
(
item
.
getRoleDesc
())
&&
roleCode
.
contains
(
item
.
getRoleName
()))
{
roleNameList
.
add
(
item
.
getRoleDesc
());
}
});
contingencyPlanInstance
.
setRoleCode
(
String
.
join
(
"-"
,
roleCodeList
));
contingencyPlanInstance
.
setRoleName
(
String
.
join
(
"-"
,
roleNameList
));
contingencyPlanInstance
.
setStartUserId
(
user
.
getUserId
());
contingencyPlanInstance
.
setStartUserName
(
user
.
getRealName
());
Map
<
String
,
String
>
userInfo
=
contingencyPlanInstanceMapper
.
getUserByUserId
(
user
.
getUserId
());
contingencyPlanInstance
.
setPersonImg
(
ObjectUtils
.
isEmpty
(
userInfo
)
?
personImg
:
userInfo
.
getOrDefault
(
"personImg"
,
personImg
));
}
return
contingencyPlanInstance
;
}
...
...
@@ -550,21 +536,21 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
private
void
sendPlanAlarm
(
String
batchNo
,
String
buttonCode
)
{
//确警后推送报警数据
List
<
FirePlanAlarmBo
>
list
=
new
ArrayList
<
FirePlanAlarmBo
>();
List
<
FirePlanAlarmBo
>
list
=
new
ArrayList
<
FirePlanAlarmBo
>();
if
(
"FIRE_CONFIRM"
.
equals
(
buttonCode
))
{
FirePlanAlarmBo
firePlanAlarm
=
view3dMapper
.
getPlanAlarmInfo
(
batchNo
);
firePlanAlarm
.
setWarningState
(
"1"
);
list
.
add
(
firePlanAlarm
);
}
else
if
(
"END_EMERGENCY"
.
equals
(
buttonCode
))
{
}
else
if
(
"END_EMERGENCY"
.
equals
(
buttonCode
))
{
FirePlanAlarmBo
firePlanAlarm
=
view3dMapper
.
getPlanAlarmInfo
(
batchNo
);
firePlanAlarm
.
setWarningState
(
"0"
);
firePlanAlarm
.
setWarningTime
(
DateUtils
.
date2LongStr
(
new
Date
()));
list
.
add
(
firePlanAlarm
);
}
if
(!
ObjectUtils
.
isEmpty
(
list
))
{
rocketMQService
.
sendMsg
(
rocketTopicFireEquipAlarm
,
"plan_alarm"
,
list
);
if
(!
ObjectUtils
.
isEmpty
(
list
))
{
rocketMQService
.
sendMsg
(
rocketTopicFireEquipAlarm
,
"plan_alarm"
,
list
);
}
}
@Scheduled
(
cron
=
"*/2 * * * * ?"
)
...
...
@@ -604,22 +590,6 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
setButtonExecuted
(
batchNo
,
contingencyPlanId
,
buttonCode
,
confirm
);
fire
(
batchNo
,
stepCode
,
contingencyPlanId
,
buttonCode
,
confirm
,
stepState
);
planVisual3dService
.
updatePlanStep
(
batchNo
,
stepCode
,
contingencyPlanId
,
buttonCode
,
isExecute
);
// TODO 数字化换流站组态屏数据推送,需要在事务提交之后,否侧事务隔离查询不出数据
// TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
// @Override
// public void afterCommit() {
// // 事物提交后业务逻辑
// // 更新预案执行Json串
//// ToipResponse byBatchNo = planVisual3dService.getPlanStepByBatchNo(batchNo);
// try {
// setButtonExecuted(batchNo, contingencyPlanId, buttonCode, confirm);
// fire(batchNo, stepCode, contingencyPlanId, buttonCode, confirm, stepState);
// planVisual3dService.updatePlanStep(batchNo, stepCode, contingencyPlanId, buttonCode, isExecute);
// } catch (Exception e) {
// throw new RuntimeException(e);
// }
// }
// });
}
catch
(
Exception
e
)
{
throw
e
;
}
finally
{
...
...
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/service/impl/ContingencyPlanServiceImpl.java
View file @
c0ed1a43
...
...
@@ -208,7 +208,7 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
deviceData
.
setCode
(
equipmentSpecific
.
getCode
());
boolean
isMock
=
vo
.
getStatus
()
==
4
;
deviceData
.
setIsMock
(
isMock
);
redisTemplate
.
opsForValue
().
set
(
"isMock"
,
isMock
?
"
1"
:
"0
"
);
redisTemplate
.
opsForValue
().
set
(
"isMock"
,
isMock
?
"
true"
:
"false
"
);
String
batchNo
=
equipmentHandlerService
.
executeDynamicPlan
(
deviceData
,
equipment
,
equipmentSpecific
,
toke
,
operationRecord
.
getId
());
//更新模型状态
PlanDetail
planDetail
=
PlanDetailOp
.
get
();
...
...
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/service/impl/PlanRuleServiceImpl.java
View file @
c0ed1a43
...
...
@@ -8,6 +8,7 @@ import org.apache.commons.io.IOUtils;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.core.io.Resource
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.stereotype.Service
;
import
java.io.IOException
;
...
...
@@ -25,6 +26,9 @@ public class PlanRuleServiceImpl implements IPlanRuleService {
@Value
(
"classpath:/json/plan-step.json"
)
private
Resource
planStepResource
;
@Autowired
private
RedisTemplate
redisTemplate
;
@Override
public
void
updatePlanRuleByBatchNo
(
String
batchNo
)
{
try
{
...
...
@@ -33,6 +37,7 @@ public class PlanRuleServiceImpl implements IPlanRuleService {
String
json
=
IOUtils
.
toString
(
planStepResource
.
getInputStream
(),
String
.
valueOf
(
StandardCharsets
.
UTF_8
));
planRule
.
setPlanStep
(
json
);
planRuleDao
.
save
(
planRule
);
redisTemplate
.
delete
(
"isMock"
);
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
"初始化预案规则planStep数据失败!"
);
}
...
...
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