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
4fb23d57
Commit
4fb23d57
authored
Apr 06, 2023
by
KeYong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化预案流程
parent
95f60d8e
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
556 additions
and
76 deletions
+556
-76
ContingencyAction.java
...m/yeejoin/amos/fas/business/action/ContingencyAction.java
+1
-0
EquipmentController.java
...oin/amos/fas/business/controller/EquipmentController.java
+0
-1
EquipmentSpecificIndexController.java
...business/controller/EquipmentSpecificIndexController.java
+0
-2
FireEquimtPointController.java
...os/fas/business/controller/FireEquimtPointController.java
+0
-4
FireSourceController.java
...in/amos/fas/business/controller/FireSourceController.java
+0
-2
LoginController.java
...yeejoin/amos/fas/business/controller/LoginController.java
+0
-3
TimeLineController.java
...join/amos/fas/business/controller/TimeLineController.java
+0
-7
BizContingencyHandler.java
...eejoin/amos/fas/business/event/BizContingencyHandler.java
+0
-0
ContingecyExecEvent.java
.../yeejoin/amos/fas/business/event/ContingecyExecEvent.java
+56
-0
ContingercyAsyncEventListener.java
...mos/fas/business/event/ContingercyAsyncEventListener.java
+50
-0
EventHandler.java
...ava/com/yeejoin/amos/fas/business/event/EventHandler.java
+16
-0
EventType.java
...n/java/com/yeejoin/amos/fas/business/event/EventType.java
+24
-0
FireContingencyHandler.java
...ejoin/amos/fas/business/event/FireContingencyHandler.java
+209
-0
ListenerConfig.java
...a/com/yeejoin/amos/fas/business/event/ListenerConfig.java
+60
-0
RequestContextHolder.java
...yeejoin/amos/fas/business/event/RequestContextHolder.java
+18
-0
ContingencyInstanceImpl.java
...os/fas/business/service/impl/ContingencyInstanceImpl.java
+66
-29
ContingencyPlanServiceImpl.java
...fas/business/service/impl/ContingencyPlanServiceImpl.java
+4
-2
HandlerMqttMessageImpl.java
...mos/fas/business/service/impl/HandlerMqttMessageImpl.java
+6
-3
IEquipmentHandlerService.java
.../fas/business/service/intfc/IEquipmentHandlerService.java
+1
-1
PlanExecuteVo.java
.../java/com/yeejoin/amos/fas/business/vo/PlanExecuteVo.java
+2
-0
dbTemplate_equipment_specific_index.xml
...sources/db/mapper/dbTemplate_equipment_specific_index.xml
+2
-2
plan-step.json
...osFireAutoSysStart/src/main/resources/json/plan-step.json
+41
-20
No files found.
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/action/ContingencyAction.java
View file @
4fb23d57
...
...
@@ -771,6 +771,7 @@ public class ContingencyAction implements CustomerAction {
RequestContext
.
setProduct
(
toke
.
getProduct
());
try
{
iContingencyInstance
.
setButtonExecuted
(
contingencyRo
.
getBatchNo
(),
contingencyPlanInstance
.
getId
(),
buttonCode
,
"CONFIRM"
,
null
);
iContingencyInstance
.
fire
(
contingencyRo
.
getBatchNo
(),
stepCode
,
contingencyPlanInstance
.
getId
(),
buttonCode
,
"CONFIRM"
,
stepState
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
...
...
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/controller/EquipmentController.java
View file @
4fb23d57
package
com
.
yeejoin
.
amos
.
fas
.
business
.
controller
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Date
;
import
java.util.List
;
...
...
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/controller/EquipmentSpecificIndexController.java
View file @
4fb23d57
package
com
.
yeejoin
.
amos
.
fas
.
business
.
controller
;
import
com.yeejoin.amos.fas.business.service.intfc.EquipmentSpecificIndexService
;
import
com.yeejoin.amos.fas.config.Permission
;
import
com.yeejoin.amos.fas.core.util.CommonResponse
;
import
com.yeejoin.amos.fas.core.util.CommonResponseUtil
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiParam
;
import
lombok.val
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
...
...
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/controller/FireEquimtPointController.java
View file @
4fb23d57
...
...
@@ -2,7 +2,6 @@ package com.yeejoin.amos.fas.business.controller;
import
com.google.common.collect.Maps
;
import
com.yeejoin.amos.fas.business.dao.mapper.FireEquipPointMapper
;
import
com.yeejoin.amos.fas.business.entity.mybatis.FireEquipmentPointEntity
;
import
com.yeejoin.amos.fas.business.service.intfc.IFireEquipPontService
;
import
com.yeejoin.amos.fas.business.vo.ReginParams
;
import
com.yeejoin.amos.fas.config.Permission
;
...
...
@@ -19,15 +18,12 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.util.StringUtils
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.Arrays
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
...
...
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/controller/FireSourceController.java
View file @
4fb23d57
...
...
@@ -6,7 +6,6 @@ import com.yeejoin.amos.fas.business.service.intfc.IFireCarService;
import
com.yeejoin.amos.fas.business.service.intfc.IFireEquipService
;
//import com.yeejoin.amos.fas.business.service.intfc.IWaterResourceService;
import
com.yeejoin.amos.fas.business.util.CommonPageParamUtil
;
import
com.yeejoin.amos.fas.business.vo.ReginParams
;
import
com.yeejoin.amos.fas.config.Permission
;
import
com.yeejoin.amos.fas.core.common.request.CommonPageable
;
import
com.yeejoin.amos.fas.core.common.request.CommonRequest
;
...
...
@@ -24,7 +23,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.data.domain.Page
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
...
...
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/controller/LoginController.java
View file @
4fb23d57
...
...
@@ -4,14 +4,12 @@ import com.alibaba.fastjson.JSON;
import
com.alibaba.fastjson.JSONObject
;
import
com.yeejoin.amos.component.feign.config.TokenOperation
;
import
com.yeejoin.amos.component.feign.model.FeignClientResult
;
import
com.yeejoin.amos.fas.business.feign.OutTokenLoginFeign
;
import
com.yeejoin.amos.fas.business.feign.PrivilegeFeign
;
import
com.yeejoin.amos.fas.business.feign.RemoteSecurityService
;
import
com.yeejoin.amos.fas.business.vo.CompanyBo
;
import
com.yeejoin.amos.fas.business.vo.DepartmentBo
;
import
com.yeejoin.amos.fas.business.vo.ReginParams
;
import
com.yeejoin.amos.fas.business.vo.RoleBo
;
import
com.yeejoin.amos.fas.business.vo.Toke
;
import
com.yeejoin.amos.feign.privilege.Privilege
;
import
com.yeejoin.amos.feign.privilege.model.AgencyUserModel
;
import
com.yeejoin.amos.feign.privilege.model.ApplicationModel
;
...
...
@@ -35,7 +33,6 @@ import org.springframework.web.context.request.ServletRequestAttributes;
import
org.typroject.tyboot.core.foundation.context.RequestContext
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.TimeUnit
;
...
...
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/controller/TimeLineController.java
View file @
4fb23d57
...
...
@@ -20,21 +20,14 @@ import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiParam
;
import
javafx.application.Application
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.context.request.RequestAttributes
;
import
org.springframework.web.context.request.RequestContextHolder
;
import
org.typroject.tyboot.core.foundation.context.RequestContext
;
import
org.typroject.tyboot.core.foundation.context.RequestContextEntityType
;
import
java.applet.AppletContext
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
...
...
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/event/BizContingencyHandler.java
0 → 100644
View file @
4fb23d57
This diff is collapsed.
Click to expand it.
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/event/ContingecyExecEvent.java
0 → 100644
View file @
4fb23d57
package
com
.
yeejoin
.
amos
.
fas
.
business
.
event
;
import
com.yeejoin.amos.fas.business.vo.PlanExecuteVo
;
import
org.springframework.context.ApplicationEvent
;
import
org.typroject.tyboot.core.foundation.context.RequestContextModel
;
/**
* @author keyong
* @title: ContingecyEvent
* <pre>
* @description: TODO
* </pre>
* @date 2023/4/4 16:31
*/
public
class
ContingecyExecEvent
extends
ApplicationEvent
{
/**
* Create a new ApplicationEvent.
*
* @param source the object on which the event initially occurred (never {@code null})
*/
private
String
eventType
;
private
RequestContextModel
context
;
// 根据业务需要添加属性
private
PlanExecuteVo
planExecute
;
public
ContingecyExecEvent
(
Object
source
)
{
super
(
source
);
}
public
String
getEventType
()
{
return
eventType
;
}
public
void
setEventType
(
String
eventType
)
{
this
.
eventType
=
eventType
;
}
public
PlanExecuteVo
getPlanExecute
()
{
return
planExecute
;
}
public
void
setPlanExecute
(
PlanExecuteVo
planExecute
)
{
this
.
planExecute
=
planExecute
;
}
public
RequestContextModel
getContext
()
{
return
context
;
}
public
void
setContext
(
RequestContextModel
context
)
{
this
.
context
=
context
;
}
}
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/event/ContingercyAsyncEventListener.java
0 → 100644
View file @
4fb23d57
package
com
.
yeejoin
.
amos
.
fas
.
business
.
event
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.ApplicationListener
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.scheduling.annotation.Async
;
import
org.typroject.tyboot.core.foundation.context.RequestContext
;
import
java.util.List
;
/**
* @author keyong
* @title: AsynEventListener
* <pre>
* @description: TODO
* </pre>
* @date 2023/4/4 16:34
*/
@Configuration
public
class
ContingercyAsyncEventListener
implements
ApplicationListener
<
ContingecyExecEvent
>
{
@Autowired
List
<
EventHandler
>
handlers
;
@Override
@Async
public
void
onApplicationEvent
(
ContingecyExecEvent
event
)
{
if
(
handlers
==
null
)
return
;
RequestContext
.
setLoginId
(
event
.
getContext
().
getLoginId
());
RequestContext
.
setToken
(
event
.
getContext
().
getToken
());
RequestContext
.
setProduct
(
event
.
getContext
().
getProduct
());
RequestContext
.
setAppKey
(
event
.
getContext
().
getAppKey
());
RequestContext
.
setAgencyCode
(
event
.
getContext
().
getAgencyCode
());
RequestContext
.
setExeUserId
(
event
.
getContext
().
getExcutedUserId
());
for
(
EventHandler
handler
:
handlers
)
{
if
(
handler
.
getEventType
().
equals
(
event
.
getEventType
()))
{
try
{
handler
.
handler
(
event
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
RequestContext
.
clean
();
}
}
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/event/EventHandler.java
0 → 100644
View file @
4fb23d57
package
com
.
yeejoin
.
amos
.
fas
.
business
.
event
;
/**
* @author keyong
* @title: EventHandler
* <pre>
* @description: TODO
* </pre>
* @date 2023/4/4 16:31
*/
public
interface
EventHandler
{
public
void
handler
(
ContingecyExecEvent
event
)
throws
Exception
;
public
String
getEventType
();
}
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/event/EventType.java
0 → 100644
View file @
4fb23d57
package
com
.
yeejoin
.
amos
.
fas
.
business
.
event
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
/**
* @author keyong
* @title: EventType
* <pre>
* @description: TODO
* </pre>
* @date 2023/4/4 16:33
*/
@Getter
@AllArgsConstructor
public
enum
EventType
{
FIRE_NEXT_RULE
(
"触发下一个预案"
,
"FIRE_NEXT_RULE"
),
UPDATE_CONTINGENCY_DATE
(
"更新业务预案数据"
,
"FIRE_NEXT_RULE"
);
private
String
name
;
private
String
code
;
}
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/event/FireContingencyHandler.java
0 → 100644
View file @
4fb23d57
package
com
.
yeejoin
.
amos
.
fas
.
business
.
event
;
import
com.alibaba.fastjson.JSONObject
;
import
com.yeejoin.amos.component.rule.RuleTrigger
;
import
com.yeejoin.amos.fas.business.action.ContingencyAction
;
import
com.yeejoin.amos.fas.business.action.model.ContingencyEvent
;
import
com.yeejoin.amos.fas.business.action.model.ContingencyRo
;
import
com.yeejoin.amos.fas.business.action.util.ContingencyLogPublisher
;
import
com.yeejoin.amos.fas.business.dao.mapper.*
;
import
com.yeejoin.amos.fas.business.dao.repository.IContingencyOriginalDataDao
;
import
com.yeejoin.amos.fas.business.service.intfc.*
;
import
com.yeejoin.amos.fas.business.vo.ContingencyInstanceInfoVO
;
import
com.yeejoin.amos.fas.dao.entity.ContingencyOriginalData
;
import
com.yeejoin.amos.fas.dao.entity.Equipment
;
import
org.apache.commons.lang3.ArrayUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.ObjectUtils
;
import
org.typroject.tyboot.core.foundation.context.RequestContext
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
* @author keyong
* @title: FireContingencyHandler
* <pre>
* @description: TODO
* </pre>
* @date 2023/4/4 16:33
*/
@Component
public
class
FireContingencyHandler
implements
EventHandler
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
FireContingencyHandler
.
class
);
@Autowired
IContingencyOriginalDataDao
iContingencyOriginalDataDao
;
@Autowired
private
ImpAndFireEquipMapper
impAndFireEquipMapper
;
@Autowired
private
RedisTemplate
redisTemplate
;
@Autowired
private
ContingencyLogPublisher
contingencyLogPublisher
;
@Autowired
private
PlanDetailMapper
planDetailMapper
;
@Autowired
IRocketMQService
rocketMQService
;
@Autowired
private
ContingencyInstanceInfoService
contingencyInstanceInfoService
;
@Autowired
private
RuleTrigger
ruleTrigger
;
@Autowired
ContingencyAction
contingencyAction
;
private
static
Map
<
String
,
String
>
stepMap
=
new
HashMap
<>();
@Value
(
"${spring.application.name}"
)
private
String
serviceName
;
@Value
(
"${station.name}"
)
private
String
stationName
;
@Override
public
void
handler
(
ContingecyExecEvent
event
)
throws
Exception
{
/**
* TODO 只处理调用触发下次原,不错业务数据更新
*/
fire
(
event
.
getPlanExecute
().
getBatchNo
(),
event
.
getPlanExecute
().
getStepCode
(),
event
.
getPlanExecute
().
getContingencyPlanId
(),
event
.
getPlanExecute
().
getButtonCode
(),
event
.
getPlanExecute
().
getConfirm
(),
event
.
getPlanExecute
().
getStepState
());
}
@Override
public
String
getEventType
()
{
return
EventType
.
FIRE_NEXT_RULE
.
name
();
}
public
void
fire
(
String
batchNo
,
String
stepCode
,
String
contingencyPlanId
,
String
buttonCode
,
String
buttonState
,
String
stepStateOnbutton
)
throws
Exception
{
//火灾误报
ContingencyOriginalData
contingencyOriginalData
=
iContingencyOriginalDataDao
.
findByBatchNo
(
batchNo
);
String
stepKey
=
batchNo
+
"_"
+
stepCode
;
if
(
stepMap
.
get
(
stepKey
)
==
null
)
stepMap
.
put
(
stepKey
,
""
);
Equipment
equipment
;
if
(
contingencyOriginalData
!=
null
)
{
log
.
info
(
"数据库中的stepcode:"
+
contingencyOriginalData
.
getStep
());
contingencyOriginalData
.
setConfirm
(
buttonState
);
contingencyOriginalData
.
setRunstep
(
false
);
if
(
contingencyOriginalData
.
getStepState
()
==
null
)
contingencyOriginalData
.
setStepState
(
""
);
if
(
"CONFIRM"
.
equals
(
buttonState
)
&&
!
contingencyOriginalData
.
getStepState
().
contains
(
stepStateOnbutton
)
&&
stepCode
.
equals
(
contingencyOriginalData
.
getStep
()))
contingencyOriginalData
.
setStepState
(
contingencyOriginalData
.
getStepState
()
+
stepStateOnbutton
);
//请求中的步骤小于以保存的步骤
// if (Integer.parseInt(stepCode) < Integer.parseInt(contingencyOriginalData.getStep()) ) {
// contingencyOriginalData.setRunstep(true);
// }
if
(
Integer
.
parseInt
(
stepCode
)
>
Integer
.
parseInt
(
contingencyOriginalData
.
getStep
()))
{
contingencyOriginalData
.
setStepState
(
stepStateOnbutton
);
}
//使用原始数据触发规则
if
(
"CONFIRM"
.
equals
(
buttonState
)
&&
!
stepMap
.
get
(
stepKey
).
contains
(
stepStateOnbutton
))
stepMap
.
put
(
stepKey
,
stepMap
.
get
(
stepKey
)
+
stepStateOnbutton
);
ContingencyRo
contingencyRo
=
new
ContingencyRo
();
contingencyRo
.
setButtonCode
(
buttonCode
);
contingencyRo
.
setButtonState
(
buttonState
);
ContingencyInstanceInfoVO
infoVO
=
contingencyInstanceInfoService
.
selectDisposalDetails
(
batchNo
);
if
(!
ObjectUtils
.
isEmpty
(
infoVO
.
getPosition
()))
{
contingencyOriginalData
.
setPosition
(
infoVO
.
getPosition
());
}
BeanUtils
.
copyProperties
(
contingencyOriginalData
,
contingencyRo
);
contingencyRo
.
setStep
(
stepCode
);
contingencyRo
.
setStepState
(
stepMap
.
get
(
stepKey
));
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
()));
if
(
equipment
!=
null
)
{
contingencyRo
.
setEquipmentCode
(
equipment
.
getCode
());
Map
<
String
,
Object
>
params
=
contingencyRo
.
getParams
();
params
.
put
(
"appKey"
,
RequestContext
.
getAppKey
());
params
.
put
(
"product"
,
RequestContext
.
getProduct
());
params
.
put
(
"token"
,
RequestContext
.
getToken
());
contingencyRo
.
setParams
(
params
);
List
<
String
>
plan
=
this
.
getNumberPlan
(
Long
.
parseLong
(
contingencyRo
.
getEquipmentId
()));
ruleTrigger
.
publish
(
contingencyRo
,
"换流站消防专项预案/"
+
plan
.
get
(
0
),
ArrayUtils
.
toArray
(
equipment
.
getName
()));
}
iContingencyOriginalDataDao
.
updateByButton
(
contingencyOriginalData
.
getConfirm
(),
contingencyOriginalData
.
getRunstep
(),
contingencyOriginalData
.
getStepState
(),
batchNo
);
if
(
equipment
!=
null
)
{
publisherPlanLog
(
stepCode
,
buttonCode
,
batchNo
);
}
}
else
{
throw
new
Exception
(
"数据异常,请联系管理员."
);
}
return
;
}
public
List
<
String
>
getNumberPlan
(
Long
id
)
{
List
<
String
>
ruleId
=
planDetailMapper
.
getRuleIdByEquipment
(
id
);
return
ruleId
;
}
private
void
publisherPlanLog
(
String
stepCode
,
String
buttonCode
,
String
batchNo
)
{
ContingencyEvent
event
=
new
ContingencyEvent
(
this
);
JSONObject
json
=
new
JSONObject
();
JSONObject
msgContext
=
new
JSONObject
();
JSONObject
content
=
new
JSONObject
();
content
.
put
(
"stepCode"
,
stepCode
);
content
.
put
(
"buttonCode"
,
buttonCode
);
msgContext
.
put
(
"type"
,
"clickEvent"
);
msgContext
.
put
(
"content"
,
content
);
json
.
put
(
"msgType"
,
"message"
);
json
.
put
(
"msgContext"
,
msgContext
);
event
.
setMsgBody
(
json
.
toJSONString
());
String
topic
=
String
.
format
(
"/%s/%s/%s"
,
serviceName
,
stationName
,
"plan"
);
event
.
setTopic
(
topic
);
event
.
setMsgType
(
"clickEvent"
);
event
.
setContingency
(
batchNo
);
contingencyLogPublisher
.
publish
(
event
);
}
}
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/event/ListenerConfig.java
0 → 100644
View file @
4fb23d57
package
com
.
yeejoin
.
amos
.
fas
.
business
.
event
;
import
org.springframework.beans.factory.BeanFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.event.SimpleApplicationEventMulticaster
;
import
org.springframework.scheduling.annotation.AsyncConfigurer
;
import
org.springframework.scheduling.annotation.EnableAsync
;
import
org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor
;
import
java.util.concurrent.Executor
;
import
java.util.concurrent.ThreadPoolExecutor
;
/**
* @author keyong
* @title: ListenerConfig
* <pre>
* @description: TODO
* </pre>
* @date 2023/4/4 18:26
*/
@Configuration
@EnableAsync
public
class
ListenerConfig
{
// @Autowired
// ContingercyAsyncEventListener listener;
//
// public ContingercyAsyncEventListener applicationStartListener(){
// ContingercyAsyncEventListener listener = new ContingercyAsyncEventListener();
// return listener;
// }
// @Override
// public Executor getAsyncExecutor() {
// ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
// // 核心线程数
// taskExecutor.setCorePoolSize(2);
// // 最大线程数
// taskExecutor.setMaxPoolSize(10);
// // 队列大小
// taskExecutor.setQueueCapacity(15);
// // 线程名的前缀
// taskExecutor.setThreadNamePrefix("async-thread-");
// taskExecutor.initialize();
// return taskExecutor;
// }
// @Bean("applicationEventMulticaster")
// public SimpleApplicationEventMulticaster aimpleApplicationEventMulticaster(BeanFactory beanFactory, ThreadPoolExecutor threadPoolExecutor) {
// SimpleApplicationEventMulticaster s = new SimpleApplicationEventMulticaster(beanFactory);
// s.setTaskExecutor(new ThreadPoolExecutor());
// return s;
// }
}
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/event/RequestContextHolder.java
0 → 100644
View file @
4fb23d57
package
com
.
yeejoin
.
amos
.
fas
.
business
.
event
;
import
lombok.Data
;
import
org.typroject.tyboot.core.foundation.context.RequestContext
;
import
org.typroject.tyboot.core.foundation.context.RequestContextModel
;
/**
* @author keyong
* @title: RequestContextHolder
* <pre>
* @description: TODO
* </pre>
* @date 2023/4/4 16:46
*/
@Data
public
class
RequestContextHolder
{
private
RequestContextModel
context
;
}
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/service/impl/ContingencyInstanceImpl.java
View file @
4fb23d57
...
...
@@ -13,15 +13,15 @@ import com.yeejoin.amos.fas.business.bo.FirePlanAlarmBo;
import
com.yeejoin.amos.fas.business.dao.mapper.*
;
import
com.yeejoin.amos.fas.business.dao.repository.IContingencyOriginalDataDao
;
import
com.yeejoin.amos.fas.business.dao.repository.IContingencyPlanInstanceRepository
;
import
com.yeejoin.amos.fas.business.event.ContingecyExecEvent
;
import
com.yeejoin.amos.fas.business.event.EventHandler
;
import
com.yeejoin.amos.fas.business.event.EventType
;
import
com.yeejoin.amos.fas.business.feign.RemoteSecurityService
;
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.ContingencyInstanceInfoVO
;
import
com.yeejoin.amos.fas.business.vo.PlanStepJsonVO
;
import
com.yeejoin.amos.fas.business.vo.Toke
;
import
com.yeejoin.amos.fas.business.vo.*
;
import
com.yeejoin.amos.fas.common.enums.PlanReplyMessageEnum
;
import
com.yeejoin.amos.fas.dao.entity.ContingencyOriginalData
;
import
com.yeejoin.amos.fas.dao.entity.ContingencyPlanInstance
;
...
...
@@ -38,8 +38,8 @@ import org.slf4j.LoggerFactory;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.ApplicationEventPublisher
;
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.util.CollectionUtils
;
...
...
@@ -132,6 +132,9 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
@Autowired
private
PlanDetailMapper
planDetailMapper
;
@Autowired
private
ApplicationEventPublisher
applicationContext
;
/**
* 创建预案执行记录
*
...
...
@@ -217,9 +220,9 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
contingencyOriginalData
.
setStepState
(
contingencyOriginalData
.
getStepState
()
+
stepStateOnbutton
);
//请求中的步骤小于以保存的步骤
if
(
Integer
.
parseInt
(
stepCode
)
<
Integer
.
parseInt
(
contingencyOriginalData
.
getStep
()))
{
contingencyOriginalData
.
setRunstep
(
true
);
}
//
if (Integer.parseInt(stepCode) < Integer.parseInt(contingencyOriginalData.getStep())) {
//
contingencyOriginalData.setRunstep(true);
//
}
if
(
Integer
.
parseInt
(
stepCode
)
>
Integer
.
parseInt
(
contingencyOriginalData
.
getStep
()))
{
contingencyOriginalData
.
setStepState
(
stepStateOnbutton
);
...
...
@@ -270,7 +273,7 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
contingencyRo
.
setParams
(
params
);
List
<
String
>
plan
=
this
.
getNumberPlan
(
Long
.
parseLong
(
contingencyRo
.
getEquipmentId
()));
// contingencyRo.setRunstep(false);
ruleTrigger
.
publish
(
contingencyRo
,
"换流站消防专项预案/"
+
plan
.
get
(
0
),
ArrayUtils
.
toArray
(
equipment
.
getName
()));
publisherPlanLog
(
stepCode
,
buttonCode
,
batchNo
);
...
...
@@ -429,31 +432,64 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
@Override
public
Optional
<
Equipment
>
fire
(
String
batchNo
,
String
stepCode
,
String
buttonJson
,
String
contingencyPlanId
,
String
buttonCode
,
String
buttonState
,
String
stepStateOnbutton
,
String
isExecute
,
String
isAuto
,
String
token
,
String
product
,
String
appKey
,
String
startUserName
)
throws
Exception
{
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"batchNo"
,
batchNo
);
map
.
put
(
"stepCode"
,
stepCode
);
map
.
put
(
"buttonCode"
,
buttonCode
);
map
.
put
(
"confirm"
,
buttonState
);
map
.
put
(
"contingencyPlanId"
,
contingencyPlanId
);
map
.
put
(
"stepState"
,
stepStateOnbutton
);
// 是否执行
map
.
put
(
"isExecute"
,
isExecute
);
// 是否自动执行
map
.
put
(
"isAuto"
,
isAuto
);
if
(
startUserName
!=
null
)
{
map
.
put
(
"startUserName"
,
startUserName
);
// Map<String, String> map = new HashMap<>();
// map.put("batchNo", batchNo);
// map.put("stepCode", stepCode);
// map.put("buttonCode", buttonCode);
// map.put("confirm", buttonState);
// map.put("contingencyPlanId", contingencyPlanId);
// map.put("stepState", stepStateOnbutton);
// // 是否执行
// map.put("isExecute", isExecute);
// // 是否自动执行
// map.put("isAuto", isAuto);
// if(startUserName != null) {
// map.put("startUserName", startUserName);
// }
// map.put("buttonJson", buttonJson);
// map.put("appKey", RequestContext.getAppKey());
// map.put("token", RequestContext.getToken());
// map.put("product", RequestContext.getProduct());
PlanExecuteVo
vo
=
new
PlanExecuteVo
();
vo
.
setConfirm
(
buttonState
);
vo
.
setStepState
(
stepStateOnbutton
);
vo
.
setBatchNo
(
batchNo
);
vo
.
setStepCode
(
stepCode
);
vo
.
setButtonCode
(
buttonCode
);
vo
.
setContingencyPlanId
(
contingencyPlanId
);
vo
.
setButtonJson
(
buttonJson
);
vo
.
setIsAuto
(
isAuto
);
vo
.
setIsExecute
(
isExecute
);
ContingecyExecEvent
fireEvent
=
new
ContingecyExecEvent
(
this
);
fireEvent
.
setEventType
(
EventType
.
FIRE_NEXT_RULE
.
name
());
fireEvent
.
setPlanExecute
(
vo
);
fireEvent
.
setContext
(
RequestContext
.
cloneRequestContext
());
applicationContext
.
publishEvent
(
fireEvent
);
ContingecyExecEvent
updateEvent
=
new
ContingecyExecEvent
(
this
);
updateEvent
.
setEventType
(
EventType
.
UPDATE_CONTINGENCY_DATE
.
name
());
updateEvent
.
setPlanExecute
(
vo
);
updateEvent
.
setContext
(
RequestContext
.
cloneRequestContext
());
// TODO 构建event对象,
try
{
applicationContext
.
publishEvent
(
updateEvent
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
map
.
put
(
"buttonJson"
,
buttonJson
);
map
.
put
(
"appKey"
,
RequestContext
.
getAppKey
());
map
.
put
(
"token"
,
RequestContext
.
getToken
());
map
.
put
(
"product"
,
RequestContext
.
getProduct
());
fireQueue
.
addLast
(
map
);
// 下面代码之后去掉。
// fireQueue.addLast(map);
//应急指挥给总部推送消息
// sendPlanAlarm(batchNo, buttonCode);
return
Optional
.
empty
();
}
@Autowired
List
<
EventHandler
>
handlers
;
@Override
public
ContingencyPlanInstance
updateExtendColumn
(
ContingencyPlanInstance
contingencyPlanInstance
)
{
String
recordType
=
contingencyPlanInstance
.
getRecordType
();
...
...
@@ -534,7 +570,7 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
}
@Scheduled
(
cron
=
"*/2 * * * * ?"
)
//
@Scheduled(cron = "*/2 * * * * ?")
public
void
runFireQueue
()
throws
Exception
{
if
(
fireQueue
.
size
()
==
0
)
...
...
@@ -558,10 +594,11 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
RequestContext
.
setAppKey
(
appKey
);
RequestContext
.
setProduct
(
product
);
RequestContext
.
setToken
(
token
);
fire
(
batchNo
,
stepCode
,
contingencyPlanId
,
buttonCode
,
confirm
,
stepState
);
// 更新redis中预案步骤数据
planVisual3dService
.
updatePlanStepToRedis
(
batchNo
,
stepCode
,
buttonJson
,
contingencyPlanId
,
buttonCode
,
isExecute
,
isAuto
);
setButtonExecuted
(
batchNo
,
contingencyPlanId
,
buttonCode
,
confirm
,
user
);
fire
(
batchNo
,
stepCode
,
contingencyPlanId
,
buttonCode
,
confirm
,
stepState
);
}
catch
(
Exception
e
)
{
throw
e
;
}
finally
{
...
...
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/service/impl/ContingencyPlanServiceImpl.java
View file @
4fb23d57
...
...
@@ -222,7 +222,9 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
boolean
isMock
=
vo
.
getStatus
()
==
4
;
deviceData
.
setIsMock
(
isMock
);
redisTemplate
.
opsForValue
().
set
(
"isMock"
,
isMock
?
"true"
:
"false"
);
String
batchNo
=
equipmentHandlerService
.
executeDynamicPlan
(
deviceData
,
equipment
,
equipmentSpecific
,
toke
,
operationRecord
.
getId
());
String
batchNo
=
UUID
.
randomUUID
().
toString
();
//更新模型状态
PlanDetail
planDetail
=
PlanDetailOp
.
get
();
planDetail
.
setStatus
(
vo
.
getStatus
());
...
...
@@ -243,7 +245,7 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
planOperationRecordDataSync
(
record
);
result
.
setMessage
(
ReserveEnum
.
RUN
.
getText
());
result
.
setBatchNo
(
batchNo
);
equipmentHandlerService
.
executeDynamicPlan
(
batchNo
,
deviceData
,
equipment
,
equipmentSpecific
,
toke
,
operationRecord
.
getId
());
// String topic = String.format("/%s/%s/%s", serviceName, stationName, "plan");
// Map<String, Object> map = new HashMap<>();
// JSONObject msgContext = new JSONObject();
...
...
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/service/impl/HandlerMqttMessageImpl.java
View file @
4fb23d57
...
...
@@ -48,6 +48,8 @@ import java.util.*;
import
java.util.stream.Collectors
;
import
java.util.stream.Stream
;
import
static
java
.
lang
.
Thread
.*;
/**
* @author keyong
* @title: HandlerMqttMessageImpl
...
...
@@ -521,13 +523,14 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService {
* @Author keyong
* @Date 2020/11/11 20:46
*/
//
@Async
@Async
@Override
public
String
executeDynamicPlan
(
AlarmParam
deviceData
,
Equipment
equipment
,
EquipmentSpecificForRiskVo
equipmentSpecific
,
Toke
toke
,
Long
recordId
)
{
String
batchNo
=
UUID
.
randomUUID
().
toString
();
public
String
executeDynamicPlan
(
String
batchNo
,
AlarmParam
deviceData
,
Equipment
equipment
,
EquipmentSpecificForRiskVo
equipmentSpecific
,
Toke
toke
,
Long
recordId
)
{
RequestContext
.
setToken
(
toke
.
getToke
());
RequestContext
.
setProduct
(
toke
.
getProduct
());
try
{
sleep
(
1000
);
alarmContingency
(
batchNo
,
equipmentSpecific
,
equipment
,
recordId
,
deviceData
.
getIsMock
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
...
...
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/service/intfc/IEquipmentHandlerService.java
View file @
4fb23d57
...
...
@@ -20,5 +20,5 @@ public interface IEquipmentHandlerService {
void
subscribeTopic
();
String
executeDynamicPlan
(
AlarmParam
deviceData
,
Equipment
equipment
,
EquipmentSpecificForRiskVo
equipmentSpecific
,
Toke
toke
,
Long
recordId
);
String
executeDynamicPlan
(
String
batchNO
,
AlarmParam
deviceData
,
Equipment
equipment
,
EquipmentSpecificForRiskVo
equipmentSpecific
,
Toke
toke
,
Long
recordId
);
}
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/vo/PlanExecuteVo.java
View file @
4fb23d57
...
...
@@ -12,4 +12,6 @@ public class PlanExecuteVo {
private
String
confirm
;
private
String
contingencyPlanId
;
private
String
stepState
;
private
String
isAuto
;
private
String
isExecute
;
}
YeeAmosFireAutoSysStart/src/main/resources/db/mapper/dbTemplate_equipment_specific_index.xml
View file @
4fb23d57
...
...
@@ -143,14 +143,14 @@
<when
test =
"outAndOr != null and outAndOr != '' and outAndOr == 'and'"
>
<if
test=
"list != null and list.size() > 0"
>
<foreach
collection=
"list"
item=
"item"
index=
"index"
open=
"("
close=
")"
separator=
"and"
>
esi.equipment_index_key = #{item.equipSpeIndexKey}
esi.equipment_index_key = #{item.equipSpeIndexKey}
and esi.`value` = #{item.standardValue}
</foreach>
</if>
</when>
<otherwise>
<if
test=
"list != null and list.size() > 0"
>
<foreach
collection=
"list"
item=
"item"
index=
"index"
open=
"("
close=
")"
separator=
"or"
>
esi.equipment_index_key = #{item.equipSpeIndexKey}
esi.equipment_index_key = #{item.equipSpeIndexKey}
and esi.`value` = #{item.standardValue}
</foreach>
</if>
</otherwise>
...
...
YeeAmosFireAutoSysStart/src/main/resources/json/plan-step.json
View file @
4fb23d57
...
...
@@ -7,7 +7,8 @@
"isParallel"
:
"1"
,
"roleCode"
:
"Digital_Responsing_Plan_A"
,
"index"
:
0
,
"isAuto"
:
0
"isAuto"
:
0
,
"checkYesOrNo"
:
""
},
{
"stepCode"
:
"15"
,
...
...
@@ -17,7 +18,8 @@
"isParallel"
:
"1"
,
"roleCode"
:
"Digital_Responsing_Plan_A"
,
"index"
:
1
,
"isAuto"
:
0
"isAuto"
:
0
,
"checkYesOrNo"
:
""
},
{
"stepCode"
:
"2"
,
...
...
@@ -27,7 +29,8 @@
"isParallel"
:
"0"
,
"roleCode"
:
"Digital_Responsing_Plan_A"
,
"index"
:
2
,
"isAuto"
:
0
"isAuto"
:
0
,
"checkYesOrNo"
:
""
},
{
"stepCode"
:
"16"
,
...
...
@@ -49,7 +52,8 @@
}
],
"outAndOr"
:
"and"
,
"isAuto"
:
0
"isAuto"
:
0
,
"checkYesOrNo"
:
""
},
{
"stepCode"
:
"3"
,
...
...
@@ -71,7 +75,8 @@
}
],
"outAndOr"
:
"and"
,
"isAuto"
:
0
"isAuto"
:
0
,
"checkYesOrNo"
:
""
},
{
"stepCode"
:
"4"
,
...
...
@@ -93,7 +98,8 @@
}
],
"outAndOr"
:
"and"
,
"isAuto"
:
0
"isAuto"
:
0
,
"checkYesOrNo"
:
""
},
{
"stepCode"
:
"7"
,
...
...
@@ -115,7 +121,8 @@
}
],
"outAndOr"
:
"and"
,
"isAuto"
:
0
"isAuto"
:
0
,
"checkYesOrNo"
:
""
},
{
"stepCode"
:
"17"
,
...
...
@@ -137,7 +144,8 @@
}
],
"outAndOr"
:
"and"
,
"isAuto"
:
0
"isAuto"
:
0
,
"checkYesOrNo"
:
""
},
{
"stepCode"
:
"18"
,
...
...
@@ -147,7 +155,8 @@
"isParallel"
:
"0"
,
"roleCode"
:
"Digital_Responsing_Plan_B"
,
"index"
:
8
,
"isAuto"
:
0
"isAuto"
:
0
,
"checkYesOrNo"
:
""
},
{
"stepCode"
:
"19"
,
...
...
@@ -169,7 +178,8 @@
}
],
"outAndOr"
:
"and"
,
"isAuto"
:
0
"isAuto"
:
0
,
"checkYesOrNo"
:
""
},
{
"stepCode"
:
"20"
,
...
...
@@ -191,7 +201,8 @@
}
],
"outAndOr"
:
"and"
,
"isAuto"
:
0
"isAuto"
:
0
,
"checkYesOrNo"
:
""
},
{
"stepCode"
:
"6"
,
...
...
@@ -213,7 +224,8 @@
}
],
"outAndOr"
:
"and"
,
"isAuto"
:
0
"isAuto"
:
0
,
"checkYesOrNo"
:
""
},
{
"stepCode"
:
"5"
,
...
...
@@ -223,7 +235,8 @@
"isParallel"
:
"0"
,
"roleCode"
:
"Digital_Responsing_Plan_B"
,
"index"
:
12
,
"isAuto"
:
0
"isAuto"
:
0
,
"checkYesOrNo"
:
""
},
{
"stepCode"
:
"21"
,
...
...
@@ -245,7 +258,8 @@
}
],
"outAndOr"
:
"and"
,
"isAuto"
:
0
"isAuto"
:
0
,
"checkYesOrNo"
:
""
},
{
"stepCode"
:
"22"
,
...
...
@@ -255,7 +269,8 @@
"isParallel"
:
"1"
,
"roleCode"
:
"Digital_Responsing_Plan_B"
,
"index"
:
14
,
"isAuto"
:
0
"isAuto"
:
0
,
"checkYesOrNo"
:
""
},
{
"stepCode"
:
"8"
,
...
...
@@ -265,7 +280,8 @@
"isParallel"
:
"0"
,
"roleCode"
:
"Digital_Responsing_Plan_B"
,
"index"
:
15
,
"isAuto"
:
0
"isAuto"
:
0
,
"checkYesOrNo"
:
""
},
{
"stepCode"
:
"13"
,
...
...
@@ -275,7 +291,8 @@
"isParallel"
:
"0"
,
"roleCode"
:
"Digital_Responsing_Plan_B"
,
"index"
:
16
,
"isAuto"
:
0
"isAuto"
:
0
,
"checkYesOrNo"
:
""
},
{
"stepCode"
:
"23"
,
...
...
@@ -285,7 +302,8 @@
"isParallel"
:
"0"
,
"roleCode"
:
"Digital_Responsing_Plan_B"
,
"index"
:
17
,
"isAuto"
:
0
"isAuto"
:
0
,
"checkYesOrNo"
:
""
},
{
"stepCode"
:
"24"
,
...
...
@@ -295,7 +313,8 @@
"isParallel"
:
"0"
,
"roleCode"
:
"Digital_Responsing_Plan_B"
,
"index"
:
18
,
"isAuto"
:
0
"isAuto"
:
0
,
"checkYesOrNo"
:
""
},
{
"stepCode"
:
"14"
,
...
...
@@ -305,6 +324,7 @@
"isParallel"
:
"1"
,
"roleCode"
:
"Digital_Responsing_Plan_B"
,
"index"
:
19
,
"isAuto"
:
0
"isAuto"
:
0
,
"checkYesOrNo"
:
""
}
]
\ No newline at end of file
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