Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
device-new-platform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赵啸非
device-new-platform
Commits
96922b59
Commit
96922b59
authored
Oct 18, 2024
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加巴中经开区windows shell
parent
8c5caeb8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
41 deletions
+26
-41
device-manager/src/main/java/com/mortals/xhx/daemon/applicationservice/RabbitMsgComsumerStartedService.java
...n/applicationservice/RabbitMsgComsumerStartedService.java
+1
-1
device-manager/src/main/java/com/mortals/xhx/module/device/service/impl/DeviceServiceImpl.java
...als/xhx/module/device/service/impl/DeviceServiceImpl.java
+25
-40
No files found.
device-manager/src/main/java/com/mortals/xhx/daemon/applicationservice/RabbitMsgComsumerStartedService.java
View file @
96922b59
...
...
@@ -46,7 +46,7 @@ public class RabbitMsgComsumerStartedService implements IApplicationStartedServi
.
toArray
(
String
[]::
new
);
simpleContainer
.
addQueueNames
(
queues
);
simpleContainer
.
start
();
simpleContainer
.
addQueueNames
(
"123"
);
//
simpleContainer.addQueueNames("123");
simpleContainer
.
setMessageListener
(
simpleDynamicListener
);
}
...
...
device-manager/src/main/java/com/mortals/xhx/module/device/service/impl/DeviceServiceImpl.java
View file @
96922b59
...
...
@@ -45,6 +45,7 @@ import com.mortals.xhx.module.site.model.SiteEntity;
import
com.mortals.xhx.module.site.service.SiteService
;
import
com.mortals.xhx.queue.*
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.amqp.rabbit.connection.CorrelationData
;
import
org.springframework.amqp.rabbit.listener.DirectMessageListenerContainer
;
import
org.springframework.beans.BeanUtils
;
...
...
@@ -107,7 +108,6 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
@Autowired
private
SiteService
siteService
;
public
void
refresh
()
{
log
.
info
(
"开始初始化系统参数..."
);
try
{
...
...
@@ -222,7 +222,8 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
messageProducer
.
queueAddAndBinds
(
QueueKey
.
DEFAULT_EXCHANGE
,
Constant
.
UPLOAD_TOPIC
+
deviceCode
,
Constant
.
UPLOAD_TOPIC
+
deviceCode
);
messageProducer
.
queueAddAndBinds
(
QueueKey
.
DEFAULT_EXCHANGE
,
Constant
.
DOWN_TOPIC
+
deviceCode
,
Constant
.
DOWN_TOPIC
+
deviceCode
);
//订阅上行队列
container
.
addQueueNames
(
Constant
.
UPLOAD_TOPIC
+
deviceCode
);
// container.addQueueNames(Constant.UPLOAD_TOPIC + deviceCode);
restartMessageListener
(
Constant
.
UPLOAD_TOPIC
+
deviceCode
);
//新增设备通知第三方平台,先新增后激活
sendThirdParty
(
deviceEntity
,
productEntity
,
platformEntity
,
DeviceMethodEnum
.
ADD
);
...
...
@@ -369,7 +370,8 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
//注册rabbmit相关队列与绑定
messageProducer
.
queueAddAndBinds
(
QueueKey
.
DEFAULT_EXCHANGE
,
Constant
.
UPLOAD_TOPIC
+
entity
.
getDeviceCode
(),
Constant
.
UPLOAD_TOPIC
+
entity
.
getDeviceCode
());
messageProducer
.
queueAddAndBinds
(
QueueKey
.
DEFAULT_EXCHANGE
,
Constant
.
DOWN_TOPIC
+
entity
.
getDeviceCode
(),
Constant
.
DOWN_TOPIC
+
entity
.
getDeviceCode
());
restartMessageListener
(
Constant
.
UPLOAD_TOPIC
+
entity
.
getDeviceCode
());
//监听上行队列
sendThirdParty
(
entity
,
productEntity
,
platformEntity
,
DeviceMethodEnum
.
UPDATE
);
}
}
...
...
@@ -386,10 +388,7 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
deviceReq
.
setDeviceInFloor
(
entity
.
getDeviceInFloor
()
==
null
?
0
:
entity
.
getDeviceInFloor
());
//http://192.168.0.98:8090/inter/device/deviceIn
//判断是否是php,如果不是 则是java 则内部调用
try
{
if
(
"smartOffice"
.
equals
(
platformEntity
.
getPlatformSn
()))
{
deviceReq
.
setReceiveMethod
(
update
.
getValue
());
//todo 调用智慧办公系统
...
...
@@ -417,16 +416,6 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
log
.
info
(
"fill resp ==>{}"
,
JSON
.
toJSONString
(
fillRest
));
}
else
{
cacheService
.
lpush
(
RedisKey
.
KEY_DEVICE_THIRDPARTY_QUEUE
,
deviceReq
);
// log.info("lpush:{}",lpush);
// String phpInUrl = GlobalSysInfo.getParamValue(PARAM_SERVER_PHP_IN_HTTP_URL, "http://172.15.28.116:8090");
// ApiResp<String> resp = messageService.sendThirdParty(UrlBuilder.of(phpInUrl).addPath(thirdPartyPath).build(), deviceReq);
// log.info("sendThirty resp ==>{}", JSON.toJSONString(resp));
//
// if (!ObjectUtils.isEmpty(resp) && resp.getCode() == YesNoEnum.YES.getValue()) {
// return Rest.ok("成功!");
// } else {
// return Rest.fail("发送失败");
// }
}
}
catch
(
Exception
e
)
{
log
.
error
(
"feign调用异常!"
);
...
...
@@ -648,7 +637,8 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
if
(!
ObjectUtils
.
isEmpty
(
entity
.
getDeviceStatus
())
&&
entity
.
getDeviceStatus
()
>
DeviceStatusEnum
.
未激活
.
getValue
())
{
//激活设备,添加队列订阅
container
.
addQueueNames
(
Constant
.
UPLOAD_TOPIC
+
entity
.
getDeviceCode
());
//container.addQueueNames(Constant.UPLOAD_TOPIC + entity.getDeviceCode());
restartMessageListener
(
Constant
.
UPLOAD_TOPIC
+
entity
.
getDeviceCode
());
PlatformEntity
platformEntity
=
platformService
.
getCache
(
entity
.
getPlatformId
().
toString
());
ProductEntity
productEntity
=
productService
.
getCache
(
entity
.
getProductId
().
toString
());
sendThirdParty
(
entity
,
productEntity
,
platformEntity
,
DeviceMethodEnum
.
ADD
);
...
...
@@ -737,40 +727,35 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
correlationData
.
setId
(
deviceEntity
.
getDeviceCode
());
log
.
info
(
"send rabbitmq msg:{}"
,
item
.
getDeviceCode
());
messageProducer
.
sendMsg
(
QueueKey
.
DEFAULT_EXCHANGE
,
Constant
.
DOWN_TOPIC
+
deviceEntity
.
getDeviceCode
(),
JSON
.
toJSONString
(
queueMsg
),
correlationData
);
/* DeviceLogEntity deviceLogEntity = new DeviceLogEntity();
deviceLogEntity.initAttrValue();
deviceLogEntity.setTraceID(IdUtil.fastSimpleUUID());
deviceLogEntity.setSiteId(deviceEntity.getSiteId());
deviceLogEntity.setDeviceId(deviceEntity.getId());
deviceLogEntity.setDeviceName(deviceEntity.getDeviceName());
deviceLogEntity.setDeviceCode(deviceEntity.getDeviceCode());
deviceLogEntity.setMessageHead(item.getMessageType());
deviceLogEntity.setContent(item.getData());
deviceLogEntity.setLogType(LogTypeEnum.下发服务.getValue());
deviceLogEntity.setCreateUserId(1L);
deviceLogEntity.setCreateTime(new Date());
deviceLogList.add(deviceLogEntity);*/
// deviceLogService.save(deviceLogEntity, null);
}
else
{
log
.
info
(
"未找到设备,deviceCode:{}"
,
item
.
getDeviceCode
());
}
}
/* if (!ObjectUtils.isEmpty(deviceLogList)) {
List<List<DeviceLogEntity>> partitionlogs = ListUtil.partition(deviceLogList, 100);
for (List<DeviceLogEntity> deviceLogEntities : partitionlogs) {
deviceLogService.save(deviceLogEntities);
}
}*/
}
catch
(
Exception
e
)
{
log
.
error
(
"异常:"
,
e
);
}
}
/**
* 重启对消息队列的监听
* @param queueName
* @return
*/
public
boolean
restartMessageListener
(
String
queueName
)
{
String
key
=
StringUtils
.
trim
(
queueName
);
container
.
addQueueNames
(
key
);
if
(
container
.
isRunning
()){
container
.
stop
();
container
.
start
();
}
container
.
start
();
return
true
;
}
public
static
void
main
(
String
[]
args
)
{
BigDecimal
bigDecimal
=
new
BigDecimal
(
"104.22241"
);
BigDecimal
add
=
bigDecimal
.
add
(
new
BigDecimal
(
"0.01"
));
...
...
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