Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yd-oss
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
xingmin
yd-oss
Commits
c02f3a24
Commit
c02f3a24
authored
Dec 30, 2025
by
zhangxingmin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
oss-v1版本
parent
0223c57a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
25 deletions
+27
-25
yd-oss-service/src/main/java/com/yd/oss/service/service/impl/ExcelImportServiceImpl.java
+27
-25
No files found.
yd-oss-service/src/main/java/com/yd/oss/service/service/impl/ExcelImportServiceImpl.java
View file @
c02f3a24
...
@@ -56,15 +56,6 @@ public class ExcelImportServiceImpl implements ExcelImportService {
...
@@ -56,15 +56,6 @@ public class ExcelImportServiceImpl implements ExcelImportService {
ExcelImportResult
<
Map
<
String
,
Object
>>
importResult
=
ExcelImportResult
<
Map
<
String
,
Object
>>
importResult
=
importExcel
(
file
,
headerRowNum
,
dataStartRowNum
);
importExcel
(
file
,
headerRowNum
,
dataStartRowNum
);
log
.
info
(
"EasyPOI导入结果:总行数={}, 成功行数={}, 失败行数={}"
,
importResult
.
getList
()
!=
null
?
importResult
.
getList
().
size
()
:
0
,
importResult
.
getList
()
!=
null
?
"N/A"
:
"N/A"
,
importResult
.
isVerifyFail
());
if
(
importResult
.
getList
()
!=
null
)
{
System
.
out
.
println
(
"原始数据:"
+
JSON
.
toJSONString
(
importResult
.
getList
()));
}
// 3. 处理导入结果
// 3. 处理导入结果
List
<
Map
<
String
,
Object
>>
data
=
List
<
Map
<
String
,
Object
>>
data
=
processImportResult
(
importResult
,
headers
);
processImportResult
(
importResult
,
headers
);
...
@@ -235,37 +226,48 @@ public class ExcelImportServiceImpl implements ExcelImportService {
...
@@ -235,37 +226,48 @@ public class ExcelImportServiceImpl implements ExcelImportService {
}
}
/**
/**
* 判断一行数据是否为空行
* 判断一行数据是否为空行(更严格的条件)
* @param rowData 行数据
* @param headers 表头列表
* @return true-空行, false-非空行
*/
*/
private
static
boolean
isEmptyRow
(
Map
<
String
,
Object
>
rowData
,
List
<
String
>
headers
)
{
private
static
boolean
isEmptyRow
(
Map
<
String
,
Object
>
rowData
,
List
<
String
>
headers
)
{
if
(
rowData
==
null
||
rowData
.
isEmpty
())
{
if
(
rowData
==
null
||
rowData
.
isEmpty
())
{
return
true
;
return
true
;
}
}
//
检查所有业务字段是否都为空(排除excelRowNum等系统字段)
//
方法1:检查所有业务字段是否都为空
for
(
String
header
:
headers
)
{
for
(
String
header
:
headers
)
{
Object
value
=
rowData
.
get
(
header
);
Object
value
=
rowData
.
get
(
header
);
if
(
value
!=
null
&&
!
value
.
toString
().
trim
().
isEmpty
())
{
if
(
value
!=
null
)
{
return
false
;
// 发现非空值,不是空行
String
strValue
=
value
.
toString
().
trim
();
// 排除常见的空值表示
if
(!
strValue
.
isEmpty
()
&&
!
strValue
.
equals
(
"-"
)
&&
!
strValue
.
equals
(
"null"
)
&&
!
strValue
.
equals
(
"NULL"
))
{
return
false
;
}
}
}
}
}
// 额外检查:如果只有系统字段有值,也算空行
// 方法2:检查所有键值对(包括系统字段)
boolean
hasOnlySystemFields
=
true
;
int
validCount
=
0
;
for
(
String
key
:
rowData
.
keySet
())
{
for
(
Map
.
Entry
<
String
,
Object
>
entry
:
rowData
.
entrySet
())
{
if
(!
key
.
equals
(
"excelRowNum"
)
&&
!
key
.
startsWith
(
"_"
))
{
String
key
=
entry
.
getKey
();
Object
value
=
rowData
.
get
(
key
);
Object
value
=
entry
.
getValue
();
if
(
value
!=
null
&&
!
value
.
toString
().
trim
().
isEmpty
())
{
hasOnlySystemFields
=
false
;
// 跳过系统字段
break
;
if
(
key
.
equals
(
"excelRowNum"
)
||
key
.
startsWith
(
"_"
))
{
continue
;
}
if
(
value
!=
null
)
{
String
strValue
=
value
.
toString
().
trim
();
if
(!
strValue
.
isEmpty
())
{
validCount
++;
}
}
}
}
}
}
return
hasOnlySystemFields
;
return
validCount
==
0
;
}
}
/**
/**
...
...
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