Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
T
terminal-protocol-proxy-service
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fox-energy
backend
terminal-protocol-proxy-service
Commits
5c660e6d
Commit
5c660e6d
authored
Jan 04, 2023
by
xieshaojun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新代码
parent
728e4d5f
Pipeline
#40454
canceled with stages
in 12 seconds
Changes
13
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
100 additions
and
229 deletions
+100
-229
pom.xml
pom.xml
+8
-5
DeviceInfoConfig.java
src/main/java/vc/thinker/config/device/DeviceInfoConfig.java
+17
-0
ThinkerProdMqttConnectionProperties.java
...nker/mqtt/config/ThinkerProdMqttConnectionProperties.java
+0
-23
ThinkerTestMqttConnectionProperties.java
...nker/mqtt/config/ThinkerTestMqttConnectionProperties.java
+0
-23
ThinkerProdProtocolClient.java
...hinker/mqtt/forwardthinker/ThinkerProdProtocolClient.java
+0
-30
ThinkerTestDataProtocol.java
.../thinker/mqtt/forwardthinker/ThinkerTestDataProtocol.java
+0
-39
ThirdPartyReportDataActor.java
...tt/forwardthinker/actor/up/ThirdPartyReportDataActor.java
+0
-45
FoxGatewayTopicDefinition.java
.../mqtt/forwardthinker/enums/FoxGatewayTopicDefinition.java
+0
-46
CentralAirProtocol.java
...rtyproxy/protocolimpls/centralAir/CentralAirProtocol.java
+18
-1
CentralAirController.java
src/main/java/vc/thinker/web/CentralAirController.java
+2
-5
application.yml
src/main/resources/application.yml
+15
-12
proguard.cfg
src/main/resources/proguard.cfg
+11
-0
IParameterModelEventServiceTest.java
src/main/test/IParameterModelEventServiceTest.java
+29
-0
No files found.
pom.xml
View file @
5c660e6d
...
...
@@ -122,11 +122,6 @@
<artifactId>
transmittable-thread-local
</artifactId>
<version>
2.2.0
</version>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-test
</artifactId>
...
...
@@ -149,6 +144,14 @@
<groupId>
org.springframework
</groupId>
<artifactId>
spring-test
</artifactId>
</dependency>
<!--jasypt加密-->
<dependency>
<groupId>
com.github.ulisesbocchio
</groupId>
<artifactId>
jasypt-spring-boot-starter
</artifactId>
<version>
3.0.3
</version>
</dependency>
</dependencies>
<build>
<plugins>
...
...
src/main/java/vc/thinker/config/device/DeviceInfoConfig.java
0 → 100644
View file @
5c660e6d
package
vc
.
thinker
.
config
.
device
;
import
lombok.Data
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.context.annotation.Configuration
;
/**
* @author : xieshaojun
* @date : 2023/1/4 14:39
*/
@Data
@Configuration
@ConfigurationProperties
(
prefix
=
"device"
)
public
class
DeviceInfoConfig
{
private
String
code
;
}
src/main/java/vc/thinker/mqtt/config/ThinkerProdMqttConnectionProperties.java
deleted
100644 → 0
View file @
728e4d5f
package
vc
.
thinker
.
mqtt
.
config
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnExpression
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.context.annotation.Configuration
;
import
vc.thinker.absctacts.mqtt.connection.MqttConnectionProperties
;
/**
* 新科云 Mqtt 属性配置
*
* @author HeTongHao
* @since 2019-10-29 16:00
*/
@Data
@Configuration
@EqualsAndHashCode
(
callSuper
=
true
)
@ConditionalOnExpression
(
"${mqtt.run:false}"
)
@ConfigurationProperties
(
prefix
=
"mqtt.connection.thinker-prod"
)
public
class
ThinkerProdMqttConnectionProperties
extends
MqttConnectionProperties
{
}
src/main/java/vc/thinker/mqtt/config/ThinkerTestMqttConnectionProperties.java
deleted
100644 → 0
View file @
728e4d5f
package
vc
.
thinker
.
mqtt
.
config
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnExpression
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.context.annotation.Configuration
;
import
vc.thinker.absctacts.mqtt.connection.MqttConnectionProperties
;
/**
* 新科云 Mqtt 属性配置
*
* @author HeTongHao
* @since 2019-10-29 16:00
*/
@Data
@Configuration
@EqualsAndHashCode
(
callSuper
=
true
)
@ConditionalOnExpression
(
"${mqtt.run:false}"
)
@ConfigurationProperties
(
prefix
=
"mqtt.connection.thinker-test"
)
public
class
ThinkerTestMqttConnectionProperties
extends
MqttConnectionProperties
{
}
src/main/java/vc/thinker/mqtt/forwardthinker/ThinkerProdProtocolClient.java
deleted
100644 → 0
View file @
728e4d5f
package
vc
.
thinker
.
mqtt
.
forwardthinker
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnBean
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
import
vc.thinker.absctacts.mqtt.protocol.AbstractNotSubscriptionMqttProtocol
;
import
vc.thinker.mqtt.config.ThinkerProdMqttConnectionProperties
;
import
vc.thinker.mqtt.forwardthinker.enums.FoxGatewayTopicDefinition
;
/**
* 富士康数据转发新科云 客户端
*
* @author HeTongHao
* @since 2022-06-28 16:00
*/
@Slf4j
@Component
@ConditionalOnBean
(
ThinkerProdMqttConnectionProperties
.
class
)
public
class
ThinkerProdProtocolClient
extends
AbstractNotSubscriptionMqttProtocol
{
public
ThinkerProdProtocolClient
(
ThinkerProdMqttConnectionProperties
mqttConnectionProperties
)
{
super
(
mqttConnectionProperties
);
}
@Scheduled
(
cron
=
"0 0/1 * * * ?"
)
public
void
timeReport
()
{
String
json
=
"[{\"deviceCode\":\"ZGZC_NXTX_001\",\"events\":{\"ddeedww\":1,\"21312312\":1,\"686787887\":1,\"78078078088\":1,\"532637828739\":1},\"timestamp\":"
+
System
.
currentTimeMillis
()
+
"}]"
;
super
.
getMqttCommandPush
().
sendMqttMessage
(
FoxGatewayTopicDefinition
.
report
.
genTopic
(
"CRRC_SMART_COCKPIT_SYSTEM"
),
json
.
getBytes
());
}
}
src/main/java/vc/thinker/mqtt/forwardthinker/ThinkerTestDataProtocol.java
deleted
100644 → 0
View file @
728e4d5f
package
vc
.
thinker
.
mqtt
.
forwardthinker
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnBean
;
import
org.springframework.stereotype.Component
;
import
vc.thinker.absctacts.mqtt.protocol.AbstractCommonBytesHandleMqttProtocol
;
import
vc.thinker.absctacts.mqtt.topic.TopicDefinition
;
import
vc.thinker.mqtt.config.ThinkerTestMqttConnectionProperties
;
import
vc.thinker.mqtt.forwardthinker.enums.FoxGatewayTopicDefinition
;
/**
* 富士康网关数据上报
*
* @author HeTongHao
* @since 2022-06-28 16:00
*/
@Slf4j
@Component
@ConditionalOnBean
(
ThinkerTestMqttConnectionProperties
.
class
)
public
class
ThinkerTestDataProtocol
extends
AbstractCommonBytesHandleMqttProtocol
{
public
ThinkerTestDataProtocol
(
ThinkerTestMqttConnectionProperties
mqttConnectionProperties
)
{
super
(
mqttConnectionProperties
);
}
@Override
public
String
[]
subscribe
()
{
return
new
String
[]{
FoxGatewayTopicDefinition
.
report
.
getTopic
(),
FoxGatewayTopicDefinition
.
report_version
.
getTopic
(),
};
}
@Override
protected
TopicDefinition
resolveByTopic
(
String
topic
)
{
String
protocolCode
=
FoxGatewayTopicDefinition
.
resolveProtocolCodeByTopic
(
topic
);
String
matchTopic
=
topic
.
replace
(
protocolCode
,
"+"
);
return
FoxGatewayTopicDefinition
.
RESOLVE_BY_TOPIC
.
resolve
(
matchTopic
);
}
}
src/main/java/vc/thinker/mqtt/forwardthinker/actor/up/ThirdPartyReportDataActor.java
deleted
100644 → 0
View file @
728e4d5f
package
vc
.
thinker
.
mqtt
.
forwardthinker
.
actor
.
up
;
import
akka.actor.AbstractActor
;
import
akka.japi.pf.ReceiveBuilder
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.config.ConfigurableBeanFactory
;
import
org.springframework.context.annotation.Scope
;
import
org.springframework.stereotype.Component
;
import
vc.thinker.absctacts.mqtt.entity.MqttResponseBytes
;
import
vc.thinker.mqtt.forwardthinker.ThinkerProdProtocolClient
;
import
vc.thinker.mqtt.forwardthinker.enums.FoxGatewayTopicDefinition
;
import
javax.annotation.Resource
;
import
java.util.List
;
/**
* 网关上报数据接收
*
* @author HeTongHao
* @since 2022/6/28 14:10
*/
@Slf4j
@Component
@Scope
(
ConfigurableBeanFactory
.
SCOPE_PROTOTYPE
)
public
class
ThirdPartyReportDataActor
extends
AbstractActor
{
@Resource
private
ThinkerProdProtocolClient
thinkerProdProtocolClient
;
/**
* 转发的网关编号列表
*/
private
static
final
List
<
String
>
PROTOCOL_CODES
=
List
.
of
(
"CRRC_SMART_COCKPIT_SYSTEM"
,
"WF_IOT_FUSE_SYSTEM"
);
public
ThirdPartyReportDataActor
()
{
receive
(
ReceiveBuilder
.
match
(
MqttResponseBytes
.
class
,
mqttResponse
->
{
String
protocolCode
=
FoxGatewayTopicDefinition
.
resolveProtocolCodeByTopic
(
mqttResponse
.
getTopic
());
// 指转发指定协议下的设备
if
(
PROTOCOL_CODES
.
contains
(
protocolCode
))
{
thinkerProdProtocolClient
.
getMqttCommandPush
()
.
sendMqttMessage
(
mqttResponse
.
getTopic
(),
mqttResponse
.
getMessage
());
}
}).
build
());
}
}
src/main/java/vc/thinker/mqtt/forwardthinker/enums/FoxGatewayTopicDefinition.java
deleted
100644 → 0
View file @
728e4d5f
package
vc
.
thinker
.
mqtt
.
forwardthinker
.
enums
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
import
vc.thinker.absctacts.mqtt.topic.TopicDefinition
;
import
vc.thinker.absctacts.mqtt.utils.StringFormatUtils
;
import
vc.thinker.mqtt.forwardthinker.actor.up.ThirdPartyReportDataActor
;
import
vc.thinker.utils.Resolve
;
/**
* Topic-actor 定义
*
* @author HeTongHao
* @since 2022-06-28 16:00
*/
@Getter
@AllArgsConstructor
public
enum
FoxGatewayTopicDefinition
implements
TopicDefinition
{
/**
* Topic-actor 定义
*/
report
(
"third-party/+/up/report"
,
ThirdPartyReportDataActor
.
class
),
report_version
(
"third-party/+/v2/up/report"
,
ThirdPartyReportDataActor
.
class
),
;
private
final
String
topic
;
private
final
Class
<?>
actorClass
;
public
static
final
Resolve
<
FoxGatewayTopicDefinition
,
String
>
RESOLVE_BY_TOPIC
=
new
Resolve
<>(
values
(),
FoxGatewayTopicDefinition:
:
getTopic
);
public
String
getActorInstanceName
()
{
return
StringFormatUtils
.
classNameLowercaseFirst
(
this
.
actorClass
);
}
public
String
genTopic
(
String
protocolCode
)
{
return
this
.
topic
.
replace
(
"+"
,
protocolCode
);
}
/**
* 根据topic解析第三方协议编号
*
* @param topic topic
* @return 第三方协议编号
*/
public
static
String
resolveProtocolCodeByTopic
(
String
topic
)
{
return
topic
.
split
(
"/"
)[
1
];
}
}
src/main/java/vc/thinker/thirdpartyproxy/protocolimpls/centralAir/CentralAirProtocol.java
View file @
5c660e6d
package
vc
.
thinker
.
thirdpartyproxy
.
protocolimpls
.
centralAir
;
import
com.alibaba.fastjson.JSONObject
;
import
com.google.common.collect.Lists
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.ObjectUtils
;
import
vc.thinker.absctacts.protocolproxy.dto.IMeterReportEntity
;
import
vc.thinker.absctacts.protocolproxy.dto.MeterReportEntity
;
import
vc.thinker.absctacts.protocolproxy.enums.IProtocolType
;
import
vc.thinker.absctacts.protocolproxy.protocol.AbstractThirdPartyProtocolSyncMeterInfo
;
import
vc.thinker.config.device.DeviceInfoConfig
;
import
vc.thinker.mqtt.proxyclient.entity.up.ThirdPartyProxyReport
;
import
vc.thinker.mqtt.proxyclient.service.ThirdPartyProxyClientService
;
import
vc.thinker.thirdpartyproxy.ProtocolType
;
import
vc.thinker.thirdpartyproxy.protocolimpls.centralAir.dto.DataReportInfoDTO
;
import
vc.thinker.thirdpartyproxy.protocolimpls.centralAir.dto.DataReportParamDTO
;
...
...
@@ -26,11 +32,22 @@ import java.time.ZoneOffset;
@RequiredArgsConstructor
public
class
CentralAirProtocol
extends
AbstractThirdPartyProtocolSyncMeterInfo
implements
TerminalReportData
{
@Autowired
private
DeviceInfoConfig
deviceInfoConfig
;
@Autowired
private
ThirdPartyProxyClientService
thirdPartyProxyClientService
;
@Override
public
IProtocolType
protocolType
()
{
return
ProtocolType
.
central_air_conditioning
;
}
@Override
public
String
lastDeviceId
(
DataReportInfoDTO
dataReportInfoDTO
)
{
return
deviceInfoConfig
.
getCode
();
}
@Override
public
void
dataReport
(
DataReportInfoDTO
dataReportInfoDTO
)
{
LocalDateTime
time
=
LocalDateTime
.
ofEpochSecond
(
dataReportInfoDTO
.
getTimestamp
()/
1000L
,
0
,
ZoneOffset
.
of
(
"+8"
));
...
...
@@ -57,6 +74,6 @@ public class CentralAirProtocol extends AbstractThirdPartyProtocolSyncMeterInfo
}
MeterReportEntity
meterReport
=
builder
.
build
();
System
.
out
.
println
(
"____"
+
JSONObject
.
toJSONString
(
meterReport
));
//
report(meterReport);
report
(
meterReport
);
}
}
src/main/java/vc/thinker/web/CentralAirController.java
View file @
5c660e6d
...
...
@@ -6,10 +6,7 @@ import io.swagger.annotations.ApiOperation;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PutMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.*
;
import
vc.thinker.thirdpartyproxy.ProtocolType
;
import
vc.thinker.thirdpartyproxy.protocolimpls.centralAir.CentralAirProtocol
;
import
vc.thinker.thirdpartyproxy.protocolimpls.centralAir.dto.DataReportInfoDTO
;
...
...
@@ -35,7 +32,7 @@ public class CentralAirController {
@ApiOperation
(
"设备数据上报接口"
)
@P
u
tMapping
(
"data-report"
)
@P
os
tMapping
(
"data-report"
)
public
Boolean
dataReport
(
@RequestBody
@Valid
TerminalDataReportVO
reportVO
)
{
if
(
Objects
.
equals
(
reportVO
.
getProtocolCode
(),
ProtocolType
.
central_air_conditioning
.
getCode
())){
DataReportInfoDTO
dto
=
DataReportInfoDTO
.
builder
()
...
...
src/main/resources/application.yml
View file @
5c660e6d
...
...
@@ -26,15 +26,18 @@ mqtt:
username
:
${ MQTT_CONNECTION_USERNAME:thinker}
password
:
${ MQTT_CONNECTION_PASSWORD:123456}
cleanSession
:
${ MQTT_CONNECTION_CLEANSESSION:
false
}
thinker-test
:
broker
:
${ MQTT_CONNECTION_THINKER_TEST_BROKER:tcp://120.79.30.193:1883}
clientId
:
${ MQTT_CONNECTION_CLIENTID:protocol-proxy-service}
username
:
${ MQTT_CONNECTION_USERNAME:thinker}
password
:
${ MQTT_CONNECTION_PASSWORD:123456}
cleanSession
:
${ MQTT_CONNECTION_CLEANSESSION:
false
}
thinker-prod
:
broker
:
${ MQTT_CONNECTION_THINKER_PROD_BROKER:tcp://39.108.210.27:1883}
clientId
:
${ MQTT_CONNECTION_CLIENTID:protocol-proxy-service}
username
:
${ MQTT_CONNECTION_USERNAME:thinker}
password
:
${ MQTT_CONNECTION_PASSWORD:123456}
cleanSession
:
${ MQTT_CONNECTION_CLEANSESSION:
false
}
# broker: ${ MQTT_CONNECTION_BROKER:tcp://119.23.65.157:1883}
# clientId: ${ MQTT_CONNECTION_CLIENTID:fox_device_service}
# username: ${ MQTT_CONNECTION_USERNAME:thinker}
# password: ${ MQTT_CONNECTION_PASSWORD:123456}
# cleanSession: ${ MQTT_CONNECTION_CLEANSESSION:false}
# 设备信息
device
:
code
:
zykt-test1
jasypt
:
encryptor
:
# 加密算法
algorithm
:
PBEWITHHMACSHA512ANDAES_256
# 加密使用的盐
password
:
jaspyt_password
src/main/resources/proguard.cfg
0 → 100644
View file @
5c660e6d
-target 14
-dontshrink
-dontoptimize
-useuniqueclassmembernames
-adaptclassstrings
-dontusemixedcaseclassnames
-keepattributes Exceptions,InnerClasses,Signature,Deprecated,SourceFile,LineNumberTable,*Annotation*,EnclosingMethod
-libraryjars <java.home>/jmods/java.base.jmod(!.jar;!module-info.class)
-keep public class vc.thinker.ProtocolProxyApplication {
public static void main(java.lang.String[]);
}
src/main/test/IParameterModelEventServiceTest.java
0 → 100644
View file @
5c660e6d
import
org.jasypt.encryption.StringEncryptor
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
vc.thinker.ProtocolProxyApplication
;
/**
* @author xieshaojun
* @date 2021/8/13 上午 9:32
*/
@RunWith
(
SpringRunner
.
class
)
@SpringBootTest
(
webEnvironment
=
SpringBootTest
.
WebEnvironment
.
RANDOM_PORT
,
classes
=
ProtocolProxyApplication
.
class
)
public
class
IParameterModelEventServiceTest
{
@Autowired
private
StringEncryptor
stringEncryptor
;
@Test
public
void
test
()
{
//加密
System
.
out
.
println
(
stringEncryptor
.
encrypt
(
"tcp://120.79.30.193:1883"
));
// System.out.println(stringEncryptor.encrypt("thinker"));
// System.out.println(stringEncryptor.encrypt("123456"));
}
}
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