Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bme-access-upload
Project
Project
Details
Activity
Releases
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
李洪明
bme-access-upload
Commits
af24f2c4
Commit
af24f2c4
authored
Jul 10, 2025
by
李洪明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改长传数据
parent
8932b4c9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
0 deletions
+36
-0
InAndOutDateService.java
...bme/access/upload/module/service/InAndOutDateService.java
+2
-0
Base64Utils.java
.../java/com/bme/access/upload/module/utils/Base64Utils.java
+34
-0
No files found.
src/main/java/com/bme/access/upload/module/service/InAndOutDateService.java
View file @
af24f2c4
...
...
@@ -10,6 +10,7 @@ import com.bme.access.upload.module.dao.DataUploadTimeMapper;
import
com.bme.access.upload.module.dao.InAndOutDateUploadFailMapper
;
import
com.bme.access.upload.module.dao.InAndOutDateUrlMapper
;
import
com.bme.access.upload.module.dao.TransportDateMapper
;
import
com.bme.access.upload.module.utils.Base64Utils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.http.HttpResponse
;
...
...
@@ -109,6 +110,7 @@ public class InAndOutDateService {
// 出入口编号
String
entryExitNumber
=
Objects
.
equals
(
inAndOutDateUrl
.
getGatePostCode
(),
"GC-2MEN"
)
?
"B"
:
Objects
.
equals
(
inAndOutDateUrl
.
getGatePostCode
(),
"GC-3MEN"
)
?
"C"
:
Objects
.
equals
(
inAndOutDateUrl
.
getGatePostCode
(),
"GC_1MEN"
)
?
"A"
:
""
;
inAndOutDate
.
setEntryexitnumber
(
entryExitNumber
);
inAndOutDate
.
setPhotos
(
Base64Utils
.
imgToBase64
(
inAndOutDateUrl
.
getInOutImage
()));
// 道闸编号
if
(
StringUtils
.
isNotEmpty
(
entryExitNumber
))
{
String
barrierNumber
=
Objects
.
equals
(
inAndOutDateUrl
.
getInOrOut
(),
1
)
?
entryExitNumber
.
concat
(
"01"
)
:
Objects
.
equals
(
inAndOutDateUrl
.
getInOrOut
(),
2
)
?
entryExitNumber
.
concat
(
"02"
)
:
""
;
...
...
src/main/java/com/bme/access/upload/module/utils/Base64Utils.java
View file @
af24f2c4
...
...
@@ -2,6 +2,7 @@ package com.bme.access.upload.module.utils;
import
net.coobird.thumbnailator.Thumbnails
;
import
org.springframework.util.StringUtils
;
import
sun.misc.BASE64Encoder
;
import
java.io.*
;
import
java.net.HttpURLConnection
;
...
...
@@ -157,6 +158,39 @@ public class Base64Utils {
return
null
;
}
public
static
String
imgToBase64
(
String
imageUrl
)
{
String
encoder
=
"data:image/jpg;"
;
try
{
URL
url
=
new
URL
(
imageUrl
);
// 打开链接
HttpURLConnection
conn
=
(
HttpURLConnection
)
url
.
openConnection
();
// 设置请求方式为"GET"
conn
.
setRequestMethod
(
"GET"
);
// 超时响应时间为5秒
conn
.
setConnectTimeout
(
5
*
1000
);
// 通过输入流获取图片数据
InputStream
inStream
=
conn
.
getInputStream
();
ByteArrayOutputStream
outStream
=
new
ByteArrayOutputStream
();
// 创建一个Buffer字符串
byte
[]
buffer
=
new
byte
[
1024
];
// 每次读取的字符串长度,如果为-1,代表全部读取完毕
int
len
=
0
;
// 使用一个输入流从buffer里把数据读取出来
while
((
len
=
inStream
.
read
(
buffer
))
!=
-
1
)
{
// 用输出流往buffer里写入数据,中间参数代表从哪个位置开始读,len代表读取的长度
outStream
.
write
(
buffer
,
0
,
len
);
}
// 关闭输入流
inStream
.
close
();
BASE64Encoder
base64Encoder
=
new
BASE64Encoder
();
encoder
=
encoder
+
base64Encoder
.
encode
(
outStream
.
toByteArray
());
return
encoder
;
}
catch
(
Exception
ex
)
{
ex
.
printStackTrace
();
}
return
null
;
}
public
static
void
main
(
String
[]
args
)
{
byte
[]
bytes
=
getByteImgByUrl
(
"https://q1.itc.cn/q_70/images03/20240430/59fe8596e4cb4824a6f27315328a3559.jpeg"
);
System
.
out
.
println
(
bytes
);
...
...
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