Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cneeds-server
Overview
Overview
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
zhangzr
cneeds-server
Commits
3694c093
Commit
3694c093
authored
Apr 17, 2020
by
zzrdark
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.修改渠道管理
2.增加测试环境配置
parent
c070b6b0
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
157 additions
and
59 deletions
+157
-59
ResultCode.java
...c/main/java/com/mx/cneeds/common/constant/ResultCode.java
+16
-0
OAuth2ResourceServer.java
...x/cneeds/server/datashow/config/OAuth2ResourceServer.java
+1
-1
DeviceController.java
...x/cneeds/server/datashow/web/device/DeviceController.java
+16
-2
application-dev.yml
...ds-server-datashow/src/main/resources/application-dev.yml
+1
-1
application-prod.yml
...s-server-datashow/src/main/resources/application-prod.yml
+2
-2
DeviceInfoController.java
...com/mx/cneeds/server/device/web/DeviceInfoController.java
+7
-2
application-dev.yml
cneeds-server-device/src/main/resources/application-dev.yml
+0
-23
application-prod.yml
cneeds-server-device/src/main/resources/application-prod.yml
+28
-2
application.yml
cneeds-server-device/src/main/resources/application.yml
+1
-1
pom.xml
cneeds-server-user/pom.xml
+2
-0
BaseMqttBean.java
...ava/com/mx/cneeds/server/user/mqtt/bean/BaseMqttBean.java
+15
-0
RemoteControl.java
...va/com/mx/cneeds/server/user/mqtt/bean/RemoteControl.java
+14
-0
MqttConfiguration.java
.../mx/cneeds/server/user/mqtt/config/MqttConfiguration.java
+8
-12
MqttProperties.java
...com/mx/cneeds/server/user/mqtt/config/MqttProperties.java
+4
-1
JobListener.java
.../com/mx/cneeds/server/user/mqtt/listener/JobListener.java
+8
-2
EmqttPredicate.java
.../com/mx/cneeds/server/user/mqtt/utils/EmqttPredicate.java
+8
-0
application-dev.yml
cneeds-server-user/src/main/resources/application-dev.yml
+7
-5
application-prod.yml
cneeds-server-user/src/main/resources/application-prod.yml
+18
-4
application.yml
cneeds-server-user/src/main/resources/application.yml
+1
-1
No files found.
cneeds-server-datashow/src/main/java/com/mx/cneeds/common/constant/ResultCode.java
0 → 100644
View file @
3694c093
package
com
.
mx
.
cneeds
.
common
.
constant
;
/**
* @ClassName ResultCode
* @Author zzrdark
* @Date 2020-04-16 17:15
* @Description TODO
**/
public
class
ResultCode
{
//没有发现IMEI
public
static
Integer
NOTFOUND_IMEI
=
1
;
//没有设置渠道商
public
static
Integer
NOTSET_CHANNEL
=
2
;
}
cneeds-server-datashow/src/main/java/com/mx/cneeds/server/datashow/config/OAuth2ResourceServer.java
View file @
3694c093
...
...
@@ -20,7 +20,7 @@ public class OAuth2ResourceServer extends ResourceServerConfigurerAdapter {
public
void
configure
(
HttpSecurity
http
)
throws
Exception
{
http
.
authorizeRequests
()
.
antMatchers
(
"/user/login"
,
"/device/getChannel_nums"
,
"/device/
device/
getChannel_nums"
,
// "/user/info",
"/statics/**"
)
.
permitAll
()
...
...
cneeds-server-datashow/src/main/java/com/mx/cneeds/server/datashow/web/device/DeviceController.java
View file @
3694c093
package
com
.
mx
.
cneeds
.
server
.
datashow
.
web
.
device
;
import
com.mx.cneeds.common.constant.ResultCode
;
import
com.mx.cneeds.common.converter.RequestParamterConverter
;
import
com.mx.cneeds.common.dto.*
;
import
com.mx.cneeds.common.result.R
;
...
...
@@ -31,11 +32,24 @@ public class DeviceController {
private
DeviceClient
deviceClient
;
@GetMapping
(
"/device/getChannel"
)
@GetMapping
(
"/device/getChannel
_nums
"
)
public
R
getChannel_nums
(
String
imei
){
DeviceChannelVo
channelVo
=
new
DeviceChannelVo
();
DeviceInfoDto
deviceInfoDto
=
deviceClient
.
queryDeviceByImei
(
imei
);
DeviceInfoDto
deviceInfoDto
=
null
;
try
{
deviceInfoDto
=
deviceClient
.
queryDeviceByImei
(
imei
);
if
(
deviceInfoDto
==
null
){
return
R
.
error
(
ResultCode
.
NOTFOUND_IMEI
,
"没有该imei的设备"
);
}
}
catch
(
Exception
e
)
{
return
R
.
error
(
ResultCode
.
NOTFOUND_IMEI
,
"没有该imei的设备"
);
}
if
(
deviceInfoDto
.
getChannelNums
()
==
null
||
deviceInfoDto
.
getChannelRules
()
==
null
)
{
return
R
.
error
(
ResultCode
.
NOTSET_CHANNEL
,
"该设备没有设置渠道商号"
);
}
BeanUtils
.
copyProperties
(
deviceInfoDto
,
channelVo
);
return
new
R
().
put
(
"data"
,
channelVo
);
}
...
...
cneeds-server-datashow/src/main/resources/application-dev.yml
View file @
3694c093
...
...
@@ -4,5 +4,5 @@ eureka:
defaultZone
:
http://192.168.2.244:8761/eureka/
instance
:
prefer-ip-address
:
true
# ip-address: 192.168.2.244
cneeds-server-datashow/src/main/resources/application-prod.yml
View file @
3694c093
eureka
:
client
:
service-url
:
defaultZone
:
http://1
27.0.0.1
:8761/eureka/
defaultZone
:
http://1
92.168.2.244
:8761/eureka/
instance
:
prefer-ip-address
:
true
ip-address
:
192.168.2.244
cneeds-server-device/src/main/java/com/mx/cneeds/server/device/web/DeviceInfoController.java
View file @
3694c093
...
...
@@ -60,8 +60,13 @@ public class DeviceInfoController {
public
DeviceInfoDto
infoByimei
(
String
imei
){
DeviceInfoEntity
deviceInfoEntity
=
deviceInfoService
.
queryDeviceByImei
(
imei
);
DeviceInfoDto
deviceInfoDto
=
new
DeviceInfoDto
();
BeanUtils
.
copyProperties
(
deviceInfoEntity
,
deviceInfoDto
);
return
deviceInfoDto
;
if
(
deviceInfoEntity
!=
null
){
BeanUtils
.
copyProperties
(
deviceInfoEntity
,
deviceInfoDto
);
return
deviceInfoDto
;
}
else
{
return
null
;
}
}
@RequestMapping
(
"/infoByIds"
)
...
...
cneeds-server-device/src/main/resources/application-dev.yml
View file @
3694c093
...
...
@@ -50,29 +50,6 @@ eureka:
defaultZone
:
http://192.168.2.244:8761/eureka/
instance
:
prefer-ip-address
:
true
ip-address
:
192.168.2.244
mybatis-plus
:
mapper-locations
:
classpath:mapper/*.xml
#实体扫描,多个package用逗号或者分号分隔
typeAliasesPackage
:
com.mx.cneeds.server.entity
global-config
:
#数据库相关配置
db-config
:
#主键类型 AUTO:"数据库ID自增", INPUT:"用户输入ID", ID_WORKER:"全局唯一ID (数字类型唯一ID)", UUID:"全局唯一ID UUID";
id-type
:
AUTO
#字段策略 IGNORED:"忽略判断",NOT_NULL:"非 NULL 判断"),NOT_EMPTY:"非空判断"
field-strategy
:
NOT_NULL
#驼峰下划线转换
column-underline
:
true
logic-delete-value
:
-1
logic-not-delete-value
:
0
banner
:
false
#原生配置
configuration
:
map-underscore-to-camel-case
:
true
cache-enabled
:
false
call-setters-on-nulls
:
true
jdbc-type-for-null
:
'
null'
cneeds-server-device/src/main/resources/application-prod.yml
View file @
3694c093
spring
:
datasource
:
driver-class-name
:
com.mysql.cj.jdbc.Driver
url
:
jdbc:mysql://1
27.0.0.1
:3306/cneeds_server?useUnicode=true&characterEncoding=UTF-8&useSSL=false
url
:
jdbc:mysql://1
92.168.2.244
:3306/cneeds_server?useUnicode=true&characterEncoding=UTF-8&useSSL=false
password
:
cneeds!QAZ1qaz
username
:
root
...
...
@@ -9,6 +9,31 @@ spring:
eureka
:
client
:
service-url
:
defaultZone
:
http://1
27.0.0.1
:8761/eureka/
defaultZone
:
http://1
92.168.2.244
:8761/eureka/
instance
:
prefer-ip-address
:
true
ip-address
:
192.168.2.244
mybatis-plus
:
mapper-locations
:
classpath:mapper/*.xml
#实体扫描,多个package用逗号或者分号分隔
typeAliasesPackage
:
com.mx.cneeds.server.entity
global-config
:
#数据库相关配置
db-config
:
#主键类型 AUTO:"数据库ID自增", INPUT:"用户输入ID", ID_WORKER:"全局唯一ID (数字类型唯一ID)", UUID:"全局唯一ID UUID";
id-type
:
AUTO
#字段策略 IGNORED:"忽略判断",NOT_NULL:"非 NULL 判断"),NOT_EMPTY:"非空判断"
field-strategy
:
NOT_NULL
#驼峰下划线转换
column-underline
:
true
logic-delete-value
:
-1
logic-not-delete-value
:
0
banner
:
false
#原生配置
configuration
:
map-underscore-to-camel-case
:
true
cache-enabled
:
false
call-setters-on-nulls
:
true
jdbc-type-for-null
:
'
null'
\ No newline at end of file
cneeds-server-device/src/main/resources/application.yml
View file @
3694c093
spring
:
profiles
:
active
:
dev
active
:
prod
application
:
name
:
cneeds-server-device
...
...
cneeds-server-user/pom.xml
View file @
3694c093
...
...
@@ -46,6 +46,8 @@
<version>
${mysql.version}
</version>
</dependency>
<dependency>
<groupId>
org.springframework.integration
</groupId>
<artifactId>
spring-integration-mqtt
</artifactId>
...
...
cneeds-server-user/src/main/java/com/mx/cneeds/server/user/mqtt/bean/BaseMqttBean.java
0 → 100644
View file @
3694c093
package
com
.
mx
.
cneeds
.
server
.
user
.
mqtt
.
bean
;
/**
* @ClassName BaseMqttBean
* @Author zzrdark
* @Date 2020-04-16 21:01
* @Description TODO
**/
public
class
BaseMqttBean
{
String
command
;
String
serialNum
;
String
imei
;
}
cneeds-server-user/src/main/java/com/mx/cneeds/server/user/mqtt/bean/RemoteControl.java
0 → 100644
View file @
3694c093
package
com
.
mx
.
cneeds
.
server
.
user
.
mqtt
.
bean
;
/**
* @ClassName RemoteControl
* @Author zzrdark
* @Date 2020-04-16 20:53
* @Description TODO
**/
public
class
RemoteControl
extends
BaseMqttBean
{
String
shell
;
}
cneeds-server-user/src/main/java/com/mx/cneeds/server/user/mqtt/config/MqttConfiguration.java
View file @
3694c093
...
...
@@ -19,6 +19,8 @@ import org.springframework.messaging.Message;
import
org.springframework.messaging.MessageChannel
;
import
org.springframework.messaging.MessageHandler
;
import
java.util.Map
;
/**
* @ClassName MqttConfiguration
* @author zzrdark
...
...
@@ -61,12 +63,15 @@ public class MqttConfiguration {
@Bean
public
MessageProducer
inbound
(
@Autowired
MessageChannel
mqttInputChannel
)
{
MqttPahoMessageDrivenChannelAdapter
adapter
=
new
MqttPahoMessageDrivenChannelAdapter
(
mqttProperties
.
getClientId
()+
"_inbound"
,
mqttClientFactory
(),
"hello"
,
"hello1"
);
new
MqttPahoMessageDrivenChannelAdapter
(
mqttProperties
.
getClientId
()+
"_inbound"
,
mqttClientFactory
());
adapter
.
setCompletionTimeout
(
Integer
.
valueOf
(
mqttProperties
.
getCompletionTimeout
()));
adapter
.
setConverter
(
new
DefaultPahoMessageConverter
());
adapter
.
setQos
(
1
);
adapter
.
setOutputChannel
(
mqttInputChannel
);
for
(
Map
<
String
,
String
>
map
:
mqttProperties
.
getTopics
()){
adapter
.
addTopic
(
map
.
get
(
"topicname"
),
Integer
.
valueOf
(
map
.
get
(
"qos"
)));
}
return
adapter
;
}
...
...
@@ -84,16 +89,8 @@ public class MqttConfiguration {
@Override
public
void
handleMessage
(
Message
<?>
message
)
{
String
topic
=
message
.
getHeaders
().
get
(
"mqtt_receivedTopic"
).
toString
();
// String type = topic.substring(topic.lastIndexOf("/")+1, topic.length());
String
qos
=
message
.
getHeaders
().
get
(
"mqtt_receivedQos"
).
toString
();
/*if("hello".equalsIgnoreCase(topic)){
System.out.println("hello,fuckXX,"+message.getPayload().toString());
}else if("hello1".equalsIgnoreCase(topic)){
System.out.println("hello1,fuckXX,"+message.getPayload().toString());
}*/
eventPublisher
.
publishEvent
(
new
MqttEvent
(
this
,
topic
,
message
.
getPayload
().
toString
()));
log
.
info
(
"topic:"
+
topic
+
" Qos:"
+
qos
+
" message:"
+
message
.
getPayload
());
}
};
}
...
...
@@ -101,13 +98,12 @@ public class MqttConfiguration {
//发送数据
@Bean
@ServiceActivator
(
inputChannel
=
"mqttOutboundChannel"
)
public
MessageHandler
mqttOutbound
()
{
MqttPahoMessageHandler
messageHandler
=
new
MqttPahoMessageHandler
(
mqttProperties
.
getClientId
(),
mqttClientFactory
());
messageHandler
.
setAsync
(
true
);
messageHandler
.
setDefaultTopic
(
mqttProperties
.
getDefaultTopic
());
//
messageHandler.setDefaultTopic(mqttProperties.getDefaultTopic());
return
messageHandler
;
}
@Bean
...
...
cneeds-server-user/src/main/java/com/mx/cneeds/server/user/mqtt/config/MqttProperties.java
View file @
3694c093
...
...
@@ -5,6 +5,9 @@ import lombok.Setter;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.stereotype.Component
;
import
java.util.List
;
import
java.util.Map
;
/**
* @author zzrdark
*/
...
...
@@ -22,7 +25,7 @@ public class MqttProperties {
private
String
clientId
;
private
String
defaultTopic
;
private
List
<
Map
<
String
,
String
>>
topics
;
private
String
completionTimeout
;
...
...
cneeds-server-user/src/main/java/com/mx/cneeds/server/user/mqtt/listener/JobListener.java
View file @
3694c093
...
...
@@ -19,12 +19,18 @@ public class JobListener {
* 监听topic
* @param mqttEvent
*/
@EventListener
(
condition
=
"# mqttEvent.topic.equals(T(com.zzr.mqtt.qmemqtt.defalut.utils.TopicName).ROLL_CALL_2.getValue())"
)
/*
@EventListener(condition = "# mqttEvent.topic.equals(T(com.zzr.mqtt.qmemqtt.defalut.utils.TopicName).ROLL_CALL_2.getValue())")
public void onEmqttCall(MqttEvent mqttEvent){
log.info("接收到消息:"+mqttEvent.getMessage());
}
}*/
@EventListener
(
condition
=
"@ emqttPredicate.test(#mqttEvent)"
)
public
void
onEmqttCallTest
(
MqttEvent
mqttEvent
){
log
.
info
(
"测试通过:"
+
mqttEvent
.
getMessage
());
}
@EventListener
(
condition
=
"@ emqttPredicate.isDeviceTopic(#mqttEvent)"
)
public
void
executeDevice
(
MqttEvent
mqttEvent
)
{
log
.
info
(
"Topic:"
+
mqttEvent
.
getTopic
()+
""
+
"\n收到设备信息:"
+
mqttEvent
.
getMessage
());
}
}
cneeds-server-user/src/main/java/com/mx/cneeds/server/user/mqtt/utils/EmqttPredicate.java
View file @
3694c093
...
...
@@ -16,4 +16,12 @@ public class EmqttPredicate {
return
Boolean
.
FALSE
;
}
public
Boolean
isDeviceTopic
(
MqttEvent
event
){
if
(
event
.
getTopic
().
contains
(
"device/"
)){
return
true
;
}
else
{
return
false
;
}
}
}
cneeds-server-user/src/main/resources/application-dev.yml
View file @
3694c093
...
...
@@ -48,13 +48,15 @@ spring:
host-url
:
tcp://120.25.162.101:1883
# client-id: zhjsbackground${random.value}
client-id
:
server
# default-topic: brokers/1
# default-topic: brokers/2
default-topic
:
brokers/#
# default-topic: $SYS/brokers/+/clients/#
completionTimeout
:
3000
keepAlive
:
60
topics[0]
:
topicname
:
device/+/+/push
qos
:
0
topics[1]
:
topicname
:
server/receive/
qos
:
0
eureka
:
client
:
...
...
@@ -62,7 +64,7 @@ eureka:
defaultZone
:
http://192.168.2.244:8761/eureka/
instance
:
prefer-ip-address
:
true
ip-address
:
192.168.2.244
...
...
cneeds-server-user/src/main/resources/application-prod.yml
View file @
3694c093
spring
:
datasource
:
driver-class-name
:
com.mysql.cj.jdbc.Driver
url
:
jdbc:mysql://1
27.0.0.1
:3306/cneeds_server?useUnicode=true&characterEncoding=UTF-8&useSSL=false
url
:
jdbc:mysql://1
92.168.2.244
:3306/cneeds_server?useUnicode=true&characterEncoding=UTF-8&useSSL=false
password
:
cneeds!QAZ1qaz
username
:
root
mqtt
:
username
:
admin
password
:
public
host-url
:
tcp://120.25.162.101:1883
# client-id: zhjsbackground${random.value}
client-id
:
server
# default-topic: $SYS/brokers/+/clients/#
completionTimeout
:
3000
keepAlive
:
60
topics[0]
:
topicname
:
device/+/+/push
qos
:
0
topics[1]
:
topicname
:
server/receive/
qos
:
0
eureka
:
client
:
service-url
:
defaultZone
:
http://1
27.0.0.1
:8761/eureka/
defaultZone
:
http://1
92.168.2.244
:8761/eureka/
instance
:
prefer-ip-address
:
true
ip-address
:
192.168.2.244
cneeds-server-user/src/main/resources/application.yml
View file @
3694c093
spring
:
profiles
:
active
:
dev
active
:
prod
application
:
name
:
cneeds-server-user
...
...
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