Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation
This project
Loading...
Sign in
谢明辉
/
recv_data_longhua
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit eb5ca491
authored
Aug 21, 2020
by
xmh
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
1
1 parent
ce3e7046
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
16 deletions
src/main/java/com/viontech/configuration/FtpConfiguration.java
src/main/java/com/viontech/model/BaseModel.java
src/main/java/com/viontech/model/LoginData.java
src/main/java/com/viontech/configuration/FtpConfiguration.java
View file @
eb5ca49
...
...
@@ -14,13 +14,13 @@ import org.springframework.context.annotation.Configuration;
public
class
FtpConfiguration
{
@Value
(
"${ftp.host:127.0.0.1}"
)
private
String
host
;
//主机名
private
String
host
;
@Value
(
"${ftp.port:21}"
)
private
int
port
;
//端口
private
int
port
;
@Value
(
"${ftp.username:}"
)
private
String
username
;
//用户名
private
String
username
;
@Value
(
"${ftp.password:}"
)
private
String
password
;
//密码
private
String
password
;
@Value
(
"${ftp.tempPath:}"
)
private
String
tempPath
;
...
...
@@ -33,7 +33,6 @@ public class FtpConfiguration {
ftpPoolConfig
.
setUsername
(
username
);
ftpPoolConfig
.
setPassword
(
password
);
//ftpPoolConfig.setMaxWaitMillis(1000);
//ftpPoolConfig.setMaxIdle(2);
return
ftpPoolConfig
;
}
...
...
@@ -48,8 +47,7 @@ public class FtpConfiguration {
@Bean
(
"ftpClientPool"
)
@ConditionalOnBean
(
FTPClientFactory
.
class
)
public
FTPClientPool
ftpClientPool
(
FTPClientFactory
ftpClientFactory
)
{
FTPClientPool
ftpClientPool
=
new
FTPClientPool
(
ftpClientFactory
);
return
ftpClientPool
;
return
new
FTPClientPool
(
ftpClientFactory
);
}
@Bean
(
"ftpClientHelper"
)
...
...
src/main/java/com/viontech/model/BaseModel.java
View file @
eb5ca49
...
...
@@ -13,7 +13,7 @@ import lombok.Setter;
@Getter
@Setter
public
abstract
class
BaseModel
{
protected
Long
empty
;
protected
Long
deviceId
;
protected
Long
length
;
protected
Long
firstInt
;
protected
Long
secondInt
;
...
...
@@ -27,12 +27,37 @@ public abstract class BaseModel {
*
* @return model
*/
abstract
public
BaseModel
decode
(
ByteBuf
byteBuf
);
public
void
decode
(
ByteBuf
byteBuf
)
{
this
.
deviceId
=
byteBuf
.
readUnsignedInt
();
this
.
length
=
byteBuf
.
readUnsignedInt
();
this
.
firstInt
=
byteBuf
.
readUnsignedInt
();
this
.
secondInt
=
byteBuf
.
readUnsignedInt
();
this
.
data
=
new
byte
[(
int
)
(
length
-
16
)];
byteBuf
.
readBytes
(
data
);
decodeData
();
}
;
/**
* 将 model 转换为 byteBuf
*
* @return byteBuf
*/
abstract
public
ByteBuf
encode
();
public
void
encode
(
ByteBuf
byteBuf
)
{
encodeData
();
byteBuf
.
writeInt
((
int
)
(
deviceId
&
0xff
));
byteBuf
.
writeInt
((
int
)
(
length
&
0xff
));
byteBuf
.
writeInt
((
int
)
(
firstInt
&
0xff
));
byteBuf
.
writeInt
((
int
)
(
secondInt
&
0xff
));
byteBuf
.
writeBytes
(
data
);
}
;
abstract
protected
void
encodeData
();
abstract
protected
void
decodeData
();
}
src/main/java/com/viontech/model/LoginData.java
View file @
eb5ca49
package
com
.
viontech
.
model
;
import
io.netty.buffer.ByteBuf
;
import
lombok.Getter
;
import
lombok.Setter
;
import
java.nio.charset.StandardCharsets
;
/**
* .
*
...
...
@@ -17,14 +18,14 @@ public class LoginData extends BaseModel {
private
String
username
;
private
String
password
;
@Override
public
BaseModel
decode
(
ByteBuf
byteBuf
)
{
return
null
;
protected
void
decodeData
()
{
this
.
username
=
new
String
(
data
,
0
,
32
,
StandardCharsets
.
UTF_8
);
this
.
password
=
new
String
(
data
,
32
,
32
,
StandardCharsets
.
UTF_8
);
}
@Override
p
ublic
ByteBuf
encode
()
{
return
null
;
p
rotected
void
encodeData
()
{
}
}
Write
Preview
Markdown
is supported
Attach a file
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 post a comment