Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
browser-backend
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
browser-backend
Commits
3b1002a9
Commit
3b1002a9
authored
Mar 18, 2020
by
renjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
批量添加文件bug
parent
3cbe5a56
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
80 additions
and
3 deletions
+80
-3
ShopController.java
...gec/browserbackend/browser/controller/ShopController.java
+3
-2
FileUtil.java
.../java/com/edgec/browserbackend/common/utils/FileUtil.java
+1
-1
PollerUtils.java
...va/com/edgec/browserbackend/common/utils/PollerUtils.java
+30
-0
ThreadPoolUtils.java
...om/edgec/browserbackend/common/utils/ThreadPoolUtils.java
+46
-0
No files found.
src/main/java/com/edgec/browserbackend/browser/controller/ShopController.java
View file @
3b1002a9
...
...
@@ -51,7 +51,7 @@ public class ShopController {
}
@RequestMapping
(
value
=
"/multiadd"
,
method
=
RequestMethod
.
POST
)
public
List
<
String
>
addShops
(
Principal
principal
,
@RequestParam
(
"file"
)
MultipartFile
file
)
{
public
ResultDto
addShops
(
Principal
principal
,
@RequestParam
(
"file"
)
MultipartFile
file
)
{
ResultDto
resultDto
=
new
ResultDto
();
String
name
=
file
.
getOriginalFilename
();
if
(
name
.
length
()<
6
||
!
name
.
substring
(
name
.
length
()-
5
).
equals
(
".xlsx"
)){
...
...
@@ -63,6 +63,7 @@ public class ShopController {
}
try
{
shopService
.
addShops
(
principal
.
getName
(),
file
);
resultDto
.
setStatus
(
0
);
}
catch
(
ClientRequestException
|
IOException
e
)
{
resultDto
.
setStatus
(-
1
);
Map
<
String
,
Object
>
statusInfo
=
new
HashMap
<>();
...
...
@@ -72,7 +73,7 @@ public class ShopController {
}
return
null
;
return
resultDto
;
}
...
...
src/main/java/com/edgec/browserbackend/common/utils/FileUtil.java
View file @
3b1002a9
...
...
@@ -87,7 +87,7 @@ public class FileUtil {
//得到指定的单元格
Cell
cell
=
row
.
getCell
(
0
);;
int
size
=
1
;
for
(
int
i
=
2
;
i
<
rowLength
;
i
++)
{
for
(
int
i
=
1
;
i
<
rowLength
;
i
++)
{
row
=
sheet
.
getRow
(
i
);
List
<
Object
>
rowvalue
=
new
ArrayList
<>();
size
=
0
;
...
...
src/main/java/com/edgec/browserbackend/common/utils/PollerUtils.java
0 → 100644
View file @
3b1002a9
package
com
.
edgec
.
browserbackend
.
common
.
utils
;
import
java.time.Instant
;
public
class
PollerUtils
{
public
static
void
poll
(
int
timeoutInSeconds
,
int
intervalInSeconds
,
Evaluator
evaluator
)
{
boolean
result
=
evaluator
.
eval
();
long
start
=
Instant
.
now
().
toEpochMilli
();
while
(!
result
)
{
long
end
=
Instant
.
now
().
toEpochMilli
();
if
((
end
-
start
)
>
timeoutInSeconds
*
1000
)
return
;
try
{
Thread
.
sleep
(
intervalInSeconds
*
1000
);
}
catch
(
InterruptedException
e
)
{
}
result
=
evaluator
.
eval
();
}
}
public
static
interface
Evaluator
{
boolean
eval
();
}
}
src/main/java/com/edgec/browserbackend/common/utils/ThreadPoolUtils.java
0 → 100644
View file @
3b1002a9
package
com
.
edgec
.
browserbackend
.
common
.
utils
;
import
com.edgec.browserbackend.common.commons.utils.PriorityThreadPoolExecutor
;
import
com.edgec.browserbackend.common.commons.utils.UniquePriorityBlockingQueue
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.util.concurrent.*
;
public
abstract
class
ThreadPoolUtils
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
ThreadPoolUtils
.
class
);
private
static
final
int
SCHEDULER_POOL_COUNT
=
50
;
public
static
final
int
MAX_WAITING_TASKS
=
10
;
public
static
final
BlockingQueue
<
Runnable
>
schedulerQueue
=
new
UniquePriorityBlockingQueue
<>(
50
);
private
static
final
int
TASK_POOL_COUNT
=
80
;
public
static
final
ExecutorService
taskExecutorPool
=
Executors
.
newFixedThreadPool
(
TASK_POOL_COUNT
,
new
ThreadFactory
()
{
int
count
=
1
;
@Override
public
Thread
newThread
(
Runnable
runnable
)
{
return
new
Thread
(
runnable
,
"intelligroup-taskexec-"
+
count
++);
}
});
private
static
final
int
TIME_SCHEDULER_POOL_COUNT
=
10
;
public
static
final
ScheduledExecutorService
timeSchedulerPool
=
Executors
.
newScheduledThreadPool
(
TIME_SCHEDULER_POOL_COUNT
,
new
ThreadFactory
()
{
int
count
=
1
;
@Override
public
Thread
newThread
(
Runnable
runnable
)
{
return
new
Thread
(
runnable
,
"intelligroup-time-scheduler-"
+
count
++);
}
});
}
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