Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation
This project
Loading...
Sign in
谢明辉
/
oss-update-application
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 9cca5a8b
authored
Mar 22, 2019
by
谢明辉
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
123
1 parent
da6dec3a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
32 deletions
src/main/java/com/vion/Application.java
src/main/java/com/vion/utils/FileUtils.java
src/main/resources/application-pro.properties
src/main/java/com/vion/Application.java
View file @
9cca5a8
package
com
.
vion
;
package
com
.
vion
;
import
com.aliyun.oss.model.GetObjectRequest
;
import
com.aliyun.oss.model.ObjectListing
;
import
com.vion.configuration.OssConfigration
;
import
com.vion.configuration.OssConfigration
;
import
com.vion.dao.IDao
;
import
com.vion.dao.IDao
;
import
com.vion.entity.OssClientEntity
;
import
com.vion.entity.OssClientEntity
;
import
com.vion.utils.OssFileUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
...
@@ -13,10 +16,10 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
...
@@ -13,10 +16,10 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import
org.springframework.context.annotation.ComponentScan
;
import
org.springframework.context.annotation.ComponentScan
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.io.File
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.concurrent.ArrayBlockingQueue
;
import
java.util.concurrent.ArrayBlockingQueue
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.ThreadPoolExecutor
;
import
java.util.concurrent.ThreadPoolExecutor
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
...
@@ -52,36 +55,45 @@ public class Application implements CommandLineRunner {
...
@@ -52,36 +55,45 @@ public class Application implements CommandLineRunner {
@Override
@Override
public
void
run
(
String
...
args
)
throws
Exception
{
public
void
run
(
String
...
args
)
throws
Exception
{
// File file = new File(facePath);
// if (!file.exists()) {
// log.error("face路径不存在!!!!!:{}", facePath);
// System.exit(1);
// }
// File file1 = new File(featurePath);
// if (!file1.exists()) {
// log.error("feature路径不存在!!!!!!!!!!{}", featurePath);
// System.exit(2);
// }
/*下载文件*/
/*下载文件*/
// OssFileUtil ossFileUtil = new OssFileUtil();
OssFileUtil
ossFileUtil
=
new
OssFileUtil
();
// ObjectListing objectListing = ossFileUtil.getFilesInPrefix(ossClientEntity.getBucket(), "picture/face/20180808/", ossClientEntity.getOssClient(), 1000, false);
ObjectListing
objectListing
=
ossFileUtil
.
getFilesInPrefix
(
ossClientEntity
.
getBucket
(),
"picture/face/20190322/08A0-F93D-CEFE-9881-01/"
,
ossClientEntity
.
getOssClient
(),
1000
,
false
);
// objectListing.getObjectSummaries().forEach(summery -> {
objectListing
.
getObjectSummaries
().
forEach
(
summery
->
{
// String[] strings = summery.getKey().split("/");
File
f
=
new
File
(
"D:\\"
+
summery
.
getKey
().
replace
(
"\\"
,
"/"
));
// File file = new File("D:/picture/face/20180808/" + strings[3]);
if
(!
f
.
getParentFile
().
exists
())
{
// if (!file.exists()) {
f
.
getParentFile
().
mkdirs
();
// if (!file.mkdir()) {
}
// System.out.println("创建文件夹失败:" + file.getName());
ossClientEntity
.
getOssClient
().
getObject
(
new
GetObjectRequest
(
ossClientEntity
.
getBucket
(),
summery
.
getKey
()),
f
);
// }
}
// }
);
// ossClientEntity.getOssClient().getObject(new GetObjectRequest(ossClientEntity.getBucket(), summery.getKey()), new File("D:\\" + summery.getKey().replace("\\", "/")));
// }
// );
//上传文件
//上传文件
// 建立线程池
// 建立线程池
//
ThreadPoolExecutor
threadPool
=
new
ThreadPoolExecutor
(
50
,
100
,
10
,
TimeUnit
.
MINUTES
,
new
ArrayBlockingQueue
<
Runnable
>(
250
),
r
->
{
//
ThreadPoolExecutor threadPool = new ThreadPoolExecutor(50, 100, 10, TimeUnit.MINUTES, new ArrayBlockingQueue<Runnable>(250), r -> {
Thread
t
=
new
Thread
(
r
);
//
Thread t = new Thread(r);
t
.
setName
(
"线程"
+
OssConfigration
.
COUNT
);
//
t.setName("线程" + OssConfigration.COUNT);
OssConfigration
.
COUNT
++;
//
OssConfigration.COUNT++;
return
t
;
//
return t;
});
//
});
//
//
SimpleDateFormat
format
=
new
SimpleDateFormat
(
"yyyyMMdd"
);
//
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
Date
beginDate
=
format
.
parse
(
begin
);
//
Date beginDate = format.parse(begin);
Date
endDate
=
format
.
parse
(
end
);
//
Date endDate = format.parse(end);
//
dao
.
getAll
(
beginDate
,
endDate
,
ossClientEntity
,
facePath
,
featurePath
,
threadPool
);
//
dao.getAll(beginDate, endDate, ossClientEntity, facePath, featurePath, threadPool);
}
}
}
}
src/main/java/com/vion/utils/FileUtils.java
View file @
9cca5a8
...
@@ -6,6 +6,7 @@ import java.util.ArrayList;
...
@@ -6,6 +6,7 @@ import java.util.ArrayList;
import
java.util.List
;
import
java.util.List
;
import
java.util.regex.Pattern
;
import
java.util.regex.Pattern
;
/**
/**
* @author 谢明辉
* @author 谢明辉
* @createDate 2018-10-30
* @createDate 2018-10-30
...
@@ -13,6 +14,7 @@ import java.util.regex.Pattern;
...
@@ -13,6 +14,7 @@ import java.util.regex.Pattern;
*/
*/
public
class
FileUtils
{
public
class
FileUtils
{
public
static
Pattern
pattern
=
Pattern
.
compile
(
"[0-9]{8}"
);
public
static
Pattern
pattern
=
Pattern
.
compile
(
"[0-9]{8}"
);
public
static
void
getFiles
(
List
<
File
>
fileList
,
String
basePath
,
Integer
begin
,
Integer
end
)
{
public
static
void
getFiles
(
List
<
File
>
fileList
,
String
basePath
,
Integer
begin
,
Integer
end
)
{
...
@@ -104,14 +106,15 @@ public class FileUtils {
...
@@ -104,14 +106,15 @@ public class FileUtils {
public
static
String
getPathName
(
String
basePath
,
Integer
dateNumber
,
String
channelSerialNum
,
String
fileName
,
boolean
isFeature
)
{
public
static
String
getPathName
(
String
basePath
,
Integer
dateNumber
,
String
channelSerialNum
,
String
fileName
,
boolean
isFeature
)
{
StringBuilder
sb
=
new
StringBuilder
();
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
basePath
).
append
(
dateNumber
).
append
(
"\\"
);
sb
.
append
(
basePath
).
append
(
dateNumber
).
append
(
File
.
separator
);
if
(
isNotNull
(
channelSerialNum
))
{
if
(
isNotNull
(
channelSerialNum
))
{
sb
.
append
(
channelSerialNum
).
append
(
"\\"
);
sb
.
append
(
channelSerialNum
).
append
(
File
.
separator
);
}
}
sb
.
append
(
fileName
);
sb
.
append
(
fileName
);
if
(
isFeature
)
{
if
(
isFeature
)
{
sb
.
append
(
".feature"
);
sb
.
append
(
".feature"
);
}
}
System
.
out
.
println
(
sb
.
toString
());
return
sb
.
toString
();
return
sb
.
toString
();
}
}
}
}
src/main/resources/application-pro.properties
View file @
9cca5a8
oss.config.bucket
=
vion-
retai
l
oss.config.bucket
=
vion-
mal
l
oss.config.endPoint
=
oss-cn-beijing.aliyuncs.com
oss.config.endPoint
=
oss-cn-beijing.aliyuncs.com
oss.config.accessKeyId
=
LTAI9WfUr3GDne4c
oss.config.accessKeyId
=
LTAI9WfUr3GDne4c
oss.config.accessKeySecret
=
SDzMs26kNyiDIIRJIY2qUBxBOeUEZ8
oss.config.accessKeySecret
=
SDzMs26kNyiDIIRJIY2qUBxBOeUEZ8
#######################Face root directory#######################
#######################Face root directory#######################
path.picture
=
D:
\\
face
\\
s
path.picture
=
D:
\\
face
\\
##################Feature root directory######################
##################Feature root directory######################
path.feature
=
D:
\\
feature
\\
path.feature
=
D:
\\
feature
\\
#########################the application will upload the data in [beginDate,endDate]
#########################the application will upload the data in [beginDate,endDate]
...
...
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