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
f034e394
Commit
f034e394
authored
Mar 17, 2023
by
KeYong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新
parent
e86ab82b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
79 additions
and
56 deletions
+79
-56
WebMqttComponent.java
...yeejoin/amos/fas/business/action/mq/WebMqttComponent.java
+54
-6
WebMqttSubscribe.java
...yeejoin/amos/fas/business/action/mq/WebMqttSubscribe.java
+2
-2
ContingencyInstanceImpl.java
...os/fas/business/service/impl/ContingencyInstanceImpl.java
+22
-47
pom.xml
pom.xml
+1
-1
No files found.
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/action/mq/WebMqttComponent.java
View file @
f034e394
...
@@ -6,18 +6,66 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -6,18 +6,66 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
org.typroject.tyboot.component.emq.EmqKeeper
;
import
org.typroject.tyboot.component.emq.EmqKeeper
;
import
javax.annotation.PostConstruct
;
import
java.util.concurrent.BlockingQueue
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.LinkedBlockingQueue
;
@Component
@Component
public
class
WebMqttComponent
{
public
class
WebMqttComponent
{
@Autowired
@Autowired
private
EmqKeeper
emqKeeper
;
private
EmqKeeper
emqKeeper
;
BlockingQueue
<
Message
>
queue
=
new
LinkedBlockingQueue
<
Message
>();
ExecutorService
service
=
null
;
@PostConstruct
public
void
init
()
{
service
=
Executors
.
newSingleThreadExecutor
();
service
.
execute
(
new
Runnable
()
{
@Override
public
void
run
()
{
while
(
true
)
{
try
{
Message
msg
=
queue
.
take
();
emqKeeper
.
getMqttClient
().
publish
(
msg
.
getTopic
(),
msg
.
getJsonStr
().
getBytes
(),
0
,
false
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
});
}
public
void
publish
(
String
topic
,
String
jsonStr
)
{
public
void
publish
(
String
topic
,
String
jsonStr
)
{
try
{
Message
msg
=
new
Message
(
topic
,
jsonStr
);
this
.
emqKeeper
.
getMqttClient
().
publish
(
topic
,
jsonStr
.
getBytes
(),
2
,
false
);
queue
.
add
(
msg
);
}
catch
(
MqttPersistenceException
e
)
{
}
e
.
printStackTrace
();
}
catch
(
MqttException
e
)
{
class
Message
{
e
.
printStackTrace
();
private
String
topic
;
private
String
jsonStr
;
public
Message
(
String
topic
,
String
jsonStr
)
{
this
.
topic
=
topic
;
this
.
jsonStr
=
jsonStr
;
}
public
String
getTopic
()
{
return
topic
;
}
public
void
setTopic
(
String
topic
)
{
this
.
topic
=
topic
;
}
public
String
getJsonStr
()
{
return
jsonStr
;
}
public
void
setJsonStr
(
String
jsonStr
)
{
this
.
jsonStr
=
jsonStr
;
}
}
}
}
}
}
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/action/mq/WebMqttSubscribe.java
View file @
f034e394
...
@@ -31,10 +31,10 @@ import org.springframework.messaging.MessageHandler;
...
@@ -31,10 +31,10 @@ import org.springframework.messaging.MessageHandler;
@IntegrationComponentScan
@IntegrationComponentScan
public
class
WebMqttSubscribe
{
public
class
WebMqttSubscribe
{
@Value
(
"${emqx.user-name}"
)
@Value
(
"${emqx.
client-
user-name}"
)
private
String
userName
;
private
String
userName
;
@Value
(
"${emqx.password}"
)
@Value
(
"${emqx.
client-
password}"
)
private
String
password
;
private
String
password
;
@Value
(
"${emqx.broker}"
)
@Value
(
"${emqx.broker}"
)
...
...
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/service/impl/ContingencyInstanceImpl.java
View file @
f034e394
...
@@ -159,21 +159,21 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
...
@@ -159,21 +159,21 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
ContingencyPlanInstance
contingencyPlanInstance
=
contingencyInstance
.
updateExtendColumn
(
planInstance
);
ContingencyPlanInstance
contingencyPlanInstance
=
contingencyInstance
.
updateExtendColumn
(
planInstance
);
ContingencyPlanInstance
instance
=
this
.
repository
.
save
(
contingencyPlanInstance
);
ContingencyPlanInstance
instance
=
this
.
repository
.
save
(
contingencyPlanInstance
);
// 异步数据同步之消息发送
// 异步数据同步之消息发送
contingencyPlanInstanceDataSync
(
instance
);
//
contingencyPlanInstanceDataSync(instance);
return
instance
;
return
instance
;
}
}
private
void
contingencyPlanInstanceDataSync
(
ContingencyPlanInstance
instance
)
{
//
private void contingencyPlanInstanceDataSync(ContingencyPlanInstance instance) {
if
(
dataSyncSwitch
)
{
//
if (dataSyncSwitch) {
try
{
//
try {
dataSyncService
.
asyncInvoke
(()
->
{
//
dataSyncService.asyncInvoke(() -> {
dataSyncService
.
syncCreatedContingencyPlanInstance
(
instance
);
//
dataSyncService.syncCreatedContingencyPlanInstance(instance);
});
//
});
}
catch
(
Exception
e
)
{
//
} catch (Exception e) {
log
.
info
(
"数据同步之消息发送. [method='{}']"
,
"createInstanceRecord==>syncCreatedContingencyPlanInstance"
,
e
);
//
log.info("数据同步之消息发送. [method='{}']", "createInstanceRecord==>syncCreatedContingencyPlanInstance", e);
}
//
}
}
//
}
}
//
}
/**
/**
...
@@ -224,8 +224,8 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
...
@@ -224,8 +224,8 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
batchNo
batchNo
);
);
// 异步数据同步之消息发送
// 异步数据同步之消息发送
暂时屏蔽 原数字化1.0 同步数据
contingencyOriginalDataDataSync
(
batchNo
,
update
);
//
contingencyOriginalDataDataSync(batchNo, update);
//使用原始数据触发规则
//使用原始数据触发规则
if
(
"CONFIRM"
.
equals
(
buttonState
)
if
(
"CONFIRM"
.
equals
(
buttonState
)
...
@@ -254,24 +254,7 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
...
@@ -254,24 +254,7 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
log
.
info
(
"stepCode:"
+
stepCode
);
log
.
info
(
"stepCode:"
+
stepCode
);
equipment
=
impAndFireEquipMapper
.
queryImpEqumtByFireEquipmt
(
Long
.
parseLong
(
contingencyRo
.
getFireEquipmentId
()));
equipment
=
impAndFireEquipMapper
.
queryImpEqumtByFireEquipmt
(
Long
.
parseLong
(
contingencyRo
.
getFireEquipmentId
()));
if
(
equipment
!=
null
)
{
if
(
equipment
!=
null
)
{
// 获取重点设备胚胎指标
// 获取遥信指标
List
<
Map
>
points
=
fireEquipPointMapper
.
getPointsByEquipmentIdAndType
(
equipment
.
getId
(),
"SWITCH"
);
HashMap
<
String
,
Integer
>
telesignallingMap
=
new
HashMap
<>();
for
(
Map
map
:
points
)
{
telesignallingMap
.
put
(
map
.
get
(
"code"
)
+
""
,
(
ObjectUtils
.
isEmpty
(
map
.
get
(
"value"
))
||
"false"
.
equals
(
map
.
get
(
"value"
).
toString
()))
?
0
:
1
);
}
contingencyRo
.
setTelesignallingMap
(
telesignallingMap
);
//获取遥测指标
points
=
fireEquipPointMapper
.
getPointsByEquipmentIdAndType
(
equipment
.
getId
(),
"ANALOGUE"
);
HashMap
<
String
,
Double
>
telemetryMap
=
new
HashMap
<>();
for
(
Map
map
:
points
)
{
telemetryMap
.
put
(
map
.
get
(
"code"
)
+
""
,
Double
.
valueOf
(
ObjectUtils
.
isEmpty
(
map
.
get
(
"value"
))
?
"0"
:
map
.
get
(
"value"
).
toString
()));
}
contingencyRo
.
setTelemetryMap
(
telemetryMap
);
contingencyRo
.
setEquipmentCode
(
equipment
.
getCode
());
contingencyRo
.
setEquipmentCode
(
equipment
.
getCode
());
Map
<
String
,
Object
>
params
=
contingencyRo
.
getParams
();
Map
<
String
,
Object
>
params
=
contingencyRo
.
getParams
();
params
.
put
(
"appKey"
,
RequestContext
.
getAppKey
());
params
.
put
(
"appKey"
,
RequestContext
.
getAppKey
());
params
.
put
(
"product"
,
RequestContext
.
getProduct
());
params
.
put
(
"product"
,
RequestContext
.
getProduct
());
...
@@ -290,7 +273,7 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
...
@@ -290,7 +273,7 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
}
}
return
Optional
.
ofNullable
(
equipment
);
return
Optional
.
ofNullable
(
equipment
);
}
}
// 异步数据同步之消息发送 暂时屏蔽 原数字化1.0 同步数据
private
void
contingencyOriginalDataDataSync
(
String
batchNo
,
int
update
)
{
private
void
contingencyOriginalDataDataSync
(
String
batchNo
,
int
update
)
{
if
(
update
>
0
&&
dataSyncSwitch
)
{
if
(
update
>
0
&&
dataSyncSwitch
)
{
try
{
try
{
...
@@ -383,7 +366,7 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
...
@@ -383,7 +366,7 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
webMqttComponent
.
publish
(
topic
,
JSON
.
toJSONString
(
map
));
webMqttComponent
.
publish
(
topic
,
JSON
.
toJSONString
(
map
));
}
}
// 异步数据同步之消息发送
// 异步数据同步之消息发送
contingencyPlanInstanceDataSync
(
instance
);
//
contingencyPlanInstanceDataSync(instance);
if
(
"CONFIRM"
.
equals
(
buttonState
)
&&
(
"FIRE_CANCEL"
.
equals
(
code
)
||
"END_EMERGENCY"
.
equals
(
code
)))
{
if
(
"CONFIRM"
.
equals
(
buttonState
)
&&
(
"FIRE_CANCEL"
.
equals
(
code
)
||
"END_EMERGENCY"
.
equals
(
code
)))
{
redisTemplate
.
delete
(
RiskSourceServiceImpl
.
cacheKeyForCanBeRunning
());
redisTemplate
.
delete
(
RiskSourceServiceImpl
.
cacheKeyForCanBeRunning
());
// 应急处置中断,初始化planStep,json数据
// 应急处置中断,初始化planStep,json数据
...
@@ -425,7 +408,7 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
...
@@ -425,7 +408,7 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
contingencyPlanInstance
.
setContent
(
operateJson
);
contingencyPlanInstance
.
setContent
(
operateJson
);
ContingencyPlanInstance
instance
=
repository
.
save
(
contingencyPlanInstance
);
ContingencyPlanInstance
instance
=
repository
.
save
(
contingencyPlanInstance
);
// 异步数据同步之消息发送
// 异步数据同步之消息发送
contingencyPlanInstanceDataSync
(
instance
);
//
contingencyPlanInstanceDataSync(instance);
}
}
}
}
...
@@ -434,7 +417,7 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
...
@@ -434,7 +417,7 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
public
void
updateStep
(
String
step
,
String
batchNo
)
{
public
void
updateStep
(
String
step
,
String
batchNo
)
{
int
update
=
iContingencyOriginalDataDao
.
updateByButtonStep
(
step
,
batchNo
);
int
update
=
iContingencyOriginalDataDao
.
updateByButtonStep
(
step
,
batchNo
);
// 异步数据同步之消息发送
// 异步数据同步之消息发送
contingencyOriginalDataDataSync
(
batchNo
,
update
);
//
contingencyOriginalDataDataSync(batchNo, update);
}
}
@Override
@Override
...
@@ -454,20 +437,13 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
...
@@ -454,20 +437,13 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
map
.
put
(
"startUserName"
,
startUserName
);
map
.
put
(
"startUserName"
,
startUserName
);
}
}
map
.
put
(
"buttonJson"
,
buttonJson
);
map
.
put
(
"buttonJson"
,
buttonJson
);
map
.
put
(
"appKey"
,
RequestContext
.
getAppKey
());
map
.
put
(
"token"
,
RequestContext
.
getToken
());
map
.
put
(
"product"
,
RequestContext
.
getProduct
());
if
(
StringUtils
.
isBlank
(
token
)
||
StringUtils
.
isBlank
(
product
))
{
Toke
serverToken
=
remoteSecurityService
.
getServerToken
();
map
.
put
(
"token"
,
serverToken
.
getToke
());
map
.
put
(
"product"
,
serverToken
.
getProduct
());
map
.
put
(
"appKey"
,
serverToken
.
getAppKey
());
}
else
{
map
.
put
(
"token"
,
token
);
map
.
put
(
"product"
,
product
);
map
.
put
(
"appKey"
,
appKey
);
}
fireQueue
.
addLast
(
map
);
fireQueue
.
addLast
(
map
);
//应急指挥给总部推送消息
//应急指挥给总部推送消息
sendPlanAlarm
(
batchNo
,
buttonCode
);
//
sendPlanAlarm(batchNo, buttonCode);
return
Optional
.
empty
();
return
Optional
.
empty
();
}
}
...
@@ -589,7 +565,6 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
...
@@ -589,7 +565,6 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
result
.
put
(
"msgContext"
,
Collections
.
EMPTY_MAP
);
result
.
put
(
"msgContext"
,
Collections
.
EMPTY_MAP
);
result
.
put
(
"msgType"
,
"refreshRecord"
);
result
.
put
(
"msgType"
,
"refreshRecord"
);
webMqttComponent
.
publish
(
topic
,
JSON
.
toJSONString
(
result
));
webMqttComponent
.
publish
(
topic
,
JSON
.
toJSONString
(
result
));
// webMqttComponent.publish(topic, "{\"msgType\":\"refreshRecord\"}");
fireQueue
.
removeFirst
();
fireQueue
.
removeFirst
();
}
}
}
}
...
...
pom.xml
View file @
f034e394
...
@@ -34,7 +34,7 @@
...
@@ -34,7 +34,7 @@
<dependency>
<dependency>
<groupId>
com.yeejoin
</groupId>
<groupId>
com.yeejoin
</groupId>
<artifactId>
amos-component-rule
</artifactId>
<artifactId>
amos-component-rule
</artifactId>
<version>
1.
7.8
-SNAPSHOT
</version>
<version>
1.
8.5
-SNAPSHOT
</version>
</dependency>
</dependency>
<dependency>
<dependency>
...
...
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