Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation
This project
Loading...
Sign in
platform
/
finance_serv
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 219276ec
authored
Aug 24, 2018
by
王军业
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
211245412
1 parent
34d5144c
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
0 deletions
code/finance_serv/src/main/java/com/vion/financial/handler/ImportExcel.java
code/finance_serv/src/main/java/com/vion/financial/handler/ImportExcel.java
0 → 100644
View file @
219276e
package
com
.
vion
.
financial
.
handler
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.List
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.web.multipart.MultipartFile
;
import
com.vion.financial.excel.ImportModel
;
import
cn.afterturn.easypoi.excel.ExcelImportUtil
;
import
cn.afterturn.easypoi.excel.entity.ImportParams
;
import
cn.afterturn.easypoi.excel.entity.result.ExcelImportResult
;
import
cn.afterturn.easypoi.handler.inter.IExcelDataHandler
;
public
class
ImportExcel
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
ImportExcel
.
class
);
public
List
<
ImportModel
>
Import
(
MultipartFile
file
)
throws
IOException
,
Exception
{
ImportParams
importParams
=
new
ImportParams
();
IExcelDataHandler
<
ImportModel
>
handle
=
new
ImportHandle
();
handle
.
setNeedHandlerFields
(
new
String
[]
{
"合同编号"
});
importParams
.
setDataHanlder
(
handle
);
importParams
.
setNeedVerfiy
(
true
);
ExcelImportResult
<
ImportModel
>
result
=
ExcelImportUtil
.
importExcelMore
(
file
.
getInputStream
(),
ImportModel
.
class
,
importParams
);
List
<
ImportModel
>
successList
=
result
.
getList
();
List
<
ImportModel
>
failList
=
result
.
getFailList
();
log
.
info
(
"是否存在验证未通过的数据:"
+
result
.
isVerfiyFail
());
log
.
info
(
"验证通过的数量:"
+
successList
.
size
());
log
.
info
(
"验证未通过的数量"
+
failList
.
size
());
for
(
ImportModel
importModel:
successList
)
{
log
.
info
(
"导入成功数据,编号="
+
importModel
.
getContract_unid
()+
";签订时间="
+
importModel
.
getSign_date
());
}
for
(
ImportModel
importModel:
failList
)
{
log
.
info
(
"导入失败数据,编号"
+
importModel
.
getContract_unid
());
}
return
successList
;
}
}
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