Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
manager
Project
Overview
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
reyun
manager
Commits
1b084492
Commit
1b084492
authored
Aug 31, 2021
by
kangxiaoshan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改提示
parent
174f5525
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
26 deletions
+29
-26
DmpIncomeController.java
src/main/java/common/controller/DmpIncomeController.java
+1
-2
DmpIncomeServiceImpl.java
src/main/java/common/service/impl/DmpIncomeServiceImpl.java
+28
-24
No files found.
src/main/java/common/controller/DmpIncomeController.java
View file @
1b084492
...
...
@@ -47,8 +47,7 @@ public class DmpIncomeController {
@PostMapping
(
"/upload"
)
public
ResultModel
uploadList
(
@RequestParam
(
"file"
)
MultipartFile
file
,
@CurrentAccount
User
loginAccount
)
{
//上传收入数据
dmpIncomeService
.
uploadFile
(
file
,
"dmp"
,
loginAccount
);
return
ResultModel
.
OK
();
return
dmpIncomeService
.
uploadFile
(
file
,
"dmp"
,
loginAccount
);
}
...
...
src/main/java/common/service/impl/DmpIncomeServiceImpl.java
View file @
1b084492
...
...
@@ -201,30 +201,37 @@ public class DmpIncomeServiceImpl implements DmpIncomeService {
Sheet
sheet
=
workbook
.
getSheetAt
(
0
);
DecimalFormat
df
=
new
DecimalFormat
(
"##,##0.00"
);
CompletableFuture
.
runAsync
(()
->
{
StopWatch
stopWatch
=
new
StopWatch
();
stopWatch
.
start
();
ExecutorService
executorService
=
Executors
.
newFixedThreadPool
(
30
);
CompletableFuture
[]
futures
=
Stream
.
iterate
(
1
,
n
->
n
+
1
).
limit
(
rowNumber
-
1
).
map
(
index
->
CompletableFuture
.
runAsync
(
()
->
{
DmpIncome
income
=
saveDmpIncomeItem
(
sheet
,
index
,
loginAccount
);
if
(
income
!=
null
)
{
StringBuffer
erroMessage
=
new
StringBuffer
();
StopWatch
stopWatch
=
new
StopWatch
();
stopWatch
.
start
();
ExecutorService
executorService
=
Executors
.
newFixedThreadPool
(
30
);
CompletableFuture
[]
futures
=
Stream
.
iterate
(
1
,
n
->
n
+
1
).
limit
(
rowNumber
-
1
).
map
(
index
->
CompletableFuture
.
runAsync
(
()
->
{
DmpIncome
income
=
saveDmpIncomeItem
(
sheet
,
index
,
loginAccount
);
if
(
income
!=
null
)
{
if
(
"erro"
.
equals
(
income
.
getIncomeMonth
()))
{
erroMessage
.
append
(
index
).
append
(
" 行 收入月份错误"
).
append
(
";\n"
);
}
else
{
income
.
setConfirmSettlement
(
new
BigDecimal
(
income
.
getConfirmSettlement
()).
setScale
(
2
,
BigDecimal
.
ROUND_HALF_UP
).
toString
());
dmpIncomeRepository
.
save
(
income
);
}
},
executorService
)
.
exceptionally
((
t
)
->
{
logger
.
error
(
"the line "
+
index
,
t
);
return
null
;
})
).
toArray
(
size
->
new
CompletableFuture
[
size
]);
CompletableFuture
.
allOf
(
futures
).
join
();
executorService
.
shutdownNow
();
stopWatch
.
stop
();
logger
.
info
(
"dmp income upload {} line data use all {}s "
,
rowNumber
-
1
,
stopWatch
.
getTotalTimeSeconds
());
});
}
},
executorService
)
.
exceptionally
((
t
)
->
{
erroMessage
.
append
(
index
).
append
(
" 行 错误"
).
append
(
t
.
getMessage
()).
append
(
";\n"
);
logger
.
error
(
"the line "
+
index
,
t
);
return
null
;
})
).
toArray
(
size
->
new
CompletableFuture
[
size
]);
CompletableFuture
.
allOf
(
futures
).
join
();
executorService
.
shutdownNow
();
stopWatch
.
stop
();
logger
.
info
(
"dmp income upload {} line data use all {}s "
,
rowNumber
-
1
,
stopWatch
.
getTotalTimeSeconds
());
if
(
erroMessage
.
length
()
>
0
)
{
return
ResultModel
.
ERROR
(
erroMessage
.
toString
());
}
return
ResultModel
.
OK
();
}
...
...
@@ -488,13 +495,11 @@ public class DmpIncomeServiceImpl implements DmpIncomeService {
private
String
getCellDateValue
(
Row
row
,
int
index
,
String
fm
)
{
Cell
cell
=
row
.
getCell
(
index
);
if
(
cell
==
null
)
{
return
"erro"
;
}
String
dfmate
=
cell
.
getCellStyle
().
getDataFormatString
();
if
(!
"yyyy/mm;@"
.
equals
(
dfmate
)
&&
!
"m/d/yy"
.
equals
(
dfmate
)
&&
!
"yy/m/d"
.
equals
(
dfmate
)
&&
!
"mm/dd/yy"
.
equals
(
dfmate
)
&&
!
"dd-mmm-yy"
.
equals
(
dfmate
)
&&
!
"yyyy/m/d"
.
equals
(
dfmate
)
&&
!
"yyyy/m/d;@"
.
equals
(
dfmate
)
&&
!
"yyyy\"年\"m\"月\";@"
.
equals
(
dfmate
))
{
return
"erro"
;
}
...
...
@@ -506,7 +511,6 @@ public class DmpIncomeServiceImpl implements DmpIncomeService {
if
(
org
.
apache
.
poi
.
ss
.
usermodel
.
DateUtil
.
isCellDateFormatted
(
cell
))
{
// 用于转化为日期格式
Date
d
=
cell
.
getDateCellValue
();
DateFormat
formater
=
new
SimpleDateFormat
(
fm
);
return
formater
.
format
(
d
);
}
...
...
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